Skip to content

Commit 6058d06

Browse files
committed
chore: address util review feedback
1 parent 82007e8 commit 6058d06

10 files changed

Lines changed: 75 additions & 67 deletions

File tree

.dumirc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export default defineConfig({
1616
base: basePath,
1717
publicPath,
1818
alias: {
19-
'rc-util/es': path.resolve(__dirname, 'src'),
19+
'@rc-component/util/es': path.resolve(__dirname, 'src'),
2020
},
2121
});

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ jobs:
2929
persist-credentials: false
3030

3131
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
32+
uses: github/codeql-action/init@411bbbe57033eedfc1a82d68c01345aa96c737d7
3333
with:
3434
languages: ${{ matrix.language }}
3535
queries: +security-and-quality
3636

3737
- name: Autobuild
38-
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
38+
uses: github/codeql-action/autobuild@411bbbe57033eedfc1a82d68c01345aa96c737d7
3939

4040
- name: Perform CodeQL Analysis
41-
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
41+
uses: github/codeql-action/analyze@411bbbe57033eedfc1a82d68c01345aa96c737d7
4242
with:
4343
category: '/language:${{ matrix.language }}'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
- React 18+ compatible helpers used by rc-component packages.
3131
- Ref composition, React 19 ref compatibility checks, and portal helpers.
3232
- DOM helpers for focus management, dynamic styles, visibility, shadow roots, and scrollbar measurement.
33-
- Hooks for controlled state, layout effects, stable callbacks, memo comparison, ids, and mobile detection.
33+
- Hooks for controlled state, layout effects, stable callbacks, memo comparison, and ids.
3434
- Small data utilities for object paths, shallow props merging, omission, equality checks, and child flattening.
3535

3636
## Install

docs/examples/dynaymicCSS.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Prepend } from 'rc-util/es/Dom/dynamicCSS';
2-
import { removeCSS, updateCSS } from 'rc-util/es/Dom/dynamicCSS';
1+
import type { Prepend } from '@rc-component/util/es/Dom/dynamicCSS';
2+
import { removeCSS, updateCSS } from '@rc-component/util/es/Dom/dynamicCSS';
33
import React from 'react';
44

55
function injectStyle(id: number, prepend?: Prepend, priority?: number) {

docs/examples/focus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { useLockFocus } from '@rc-component/util/es/Dom/focus';
12
import React, { useRef } from 'react';
2-
import { useLockFocus } from '../../src/Dom/focus';
33

44
export default function FocusDemo() {
55
const containerRef = useRef<HTMLDivElement>(null);

docs/examples/getScrollBarSize.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import getScrollBarSize, {
22
getTargetScrollBarSize,
3-
} from 'rc-util/es/getScrollBarSize';
3+
} from '@rc-component/util/es/getScrollBarSize';
44
import React from 'react';
55

66
const cssText = `

docs/examples/portal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import PortalWrapper from 'rc-util/es/PortalWrapper';
2+
import PortalWrapper from '@rc-component/util/es/PortalWrapper';
33

44
const Demo: React.FC = () => {
55
const divRef = React.useRef<HTMLDivElement>(null);

docs/examples/styleChecker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { isStyleSupport } from 'rc-util/es/Dom/styleChecker';
2+
import { isStyleSupport } from '@rc-component/util/es/Dom/styleChecker';
33

44
export default () => {
55
const supportFlex = isStyleSupport('flex');

docs/examples/toArray.tsx

Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import toArray, { type Option } from 'rc-util/es/Children/toArray';
2+
import toArray, { type Option } from '@rc-component/util/es/Children/toArray';
33

44
const initialState = {
55
'no-children': false,
@@ -8,45 +8,56 @@ const initialState = {
88
'nested-children': false,
99
'array-of-children': false,
1010
'is-falsy': false,
11-
'fragment': false,
12-
} as const
11+
fragment: false,
12+
} as const;
1313

14-
type Action = keyof typeof initialState
14+
type Action = keyof typeof initialState;
1515

16-
const Wrapper = ({ children, ...options }: { children?: React.ReactNode } & Option) => {
16+
const Wrapper = ({
17+
children,
18+
...options
19+
}: { children?: React.ReactNode } & Option) => {
1720
window.console.log(toArray(children, options));
1821

1922
return children as any;
2023
};
2124

22-
const DemoBox = React.memo(({ children, name }: { children?: any, name: Action }) => {
23-
const [keepEmpty, setkeepEmpty] = React.useState(false);
24-
const [show, setShow] = React.useState(false)
25-
return (
26-
<React.Fragment key={name}>
27-
<label style={{ display: 'inline-block', width: 180 }}>
28-
<input type="checkbox" checked={show} onChange={() => setShow(prev => !prev)} />
29-
{name}
30-
</label>
31-
<label>
32-
<input
33-
type="checkbox"
34-
checked={keepEmpty}
35-
onChange={() => setkeepEmpty(prev => !prev)}
36-
disabled={!show}
37-
/>
38-
keepEmpty={keepEmpty ? 'true' : 'false'}
39-
</label>
40-
<br />
41-
{show && React.cloneElement<any>(children, { keepEmpty })}
42-
<br />
43-
</React.Fragment>
44-
)
45-
})
25+
const DemoBox = React.memo(
26+
({ children, name }: { children?: any; name: Action }) => {
27+
const [keepEmpty, setkeepEmpty] = React.useState(false);
28+
const [show, setShow] = React.useState(false);
29+
return (
30+
<React.Fragment key={name}>
31+
<label style={{ display: 'inline-block', width: 180 }}>
32+
<input
33+
type="checkbox"
34+
checked={show}
35+
onChange={() => setShow(prev => !prev)}
36+
/>
37+
{name}
38+
</label>
39+
<label>
40+
<input
41+
type="checkbox"
42+
checked={keepEmpty}
43+
onChange={() => setkeepEmpty(prev => !prev)}
44+
disabled={!show}
45+
/>
46+
keepEmpty={keepEmpty ? 'true' : 'false'}
47+
</label>
48+
<br />
49+
{show && React.cloneElement<any>(children, { keepEmpty })}
50+
<br />
51+
</React.Fragment>
52+
);
53+
},
54+
);
4655

4756
const App = () => (
4857
<>
49-
<p onClick={window.console.clear}>Press F12 to open the console (Click Clear Console)</p>
58+
<p onClick={window.console.clear}>
59+
Press F12 to open the console (Click Clear Console)
60+
</p>
5061

5162
<DemoBox name="no-children">
5263
<Wrapper />
@@ -59,42 +70,42 @@ const App = () => (
5970
</DemoBox>
6071

6172
<DemoBox name="multiple-children">
62-
<Wrapper >
73+
<Wrapper>
6374
<p>1</p>
6475
<span>2</span>
6576
</Wrapper>
6677
</DemoBox>
6778

6879
<DemoBox name="nested-children">
69-
<Wrapper >
80+
<Wrapper>
7081
<ul>
71-
{Array.from({ length: 5 }, (_, i) => <li key={i}>{i}</li>)}
82+
{Array.from({ length: 5 }, (_, i) => (
83+
<li key={i}>{i}</li>
84+
))}
7285
</ul>
7386
</Wrapper>
7487
</DemoBox>
7588

7689
<DemoBox name="array-of-children">
77-
<Wrapper >
78-
{
90+
<Wrapper>
91+
{[
7992
[
8093
[
81-
[
82-
<span key="1">111</span>,
83-
<span key="2">222</span>,
84-
<span key="3">333</span>
85-
],
86-
<span key="4">444</span>,
87-
<span key="5">555</span>
94+
<span key="1">111</span>,
95+
<span key="2">222</span>,
96+
<span key="3">333</span>,
8897
],
89-
<span key="6">666</span>,
90-
<span key="7">777</span>
91-
]
92-
}
98+
<span key="4">444</span>,
99+
<span key="5">555</span>,
100+
],
101+
<span key="6">666</span>,
102+
<span key="7">777</span>,
103+
]}
93104
</Wrapper>
94105
</DemoBox>
95106

96107
<DemoBox name="is-falsy">
97-
<Wrapper >
108+
<Wrapper>
98109
{null}
99110
{undefined}
100111
{false}
@@ -106,18 +117,16 @@ const App = () => (
106117
</DemoBox>
107118

108119
<DemoBox name="fragment">
109-
<Wrapper >
120+
<Wrapper>
110121
<React.Fragment />
111-
<React.Fragment >A</React.Fragment>
112-
<React.Fragment >
122+
<React.Fragment>A</React.Fragment>
123+
<React.Fragment>
113124
<React.Fragment />
114-
<React.Fragment >B</React.Fragment>
125+
<React.Fragment>B</React.Fragment>
115126
</React.Fragment>
116127
</Wrapper>
117128
</DemoBox>
118129
</>
119130
);
120131

121-
122-
123-
export default App;
132+
export default App;

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
"@/*": ["src/*"],
1212
"@@/*": [".dumi/tmp/*"],
1313
"@rc-component/util": ["src/index.ts"],
14-
"rc-util": ["src/index.ts"],
15-
"rc-util/es/*": ["src/*"]
14+
"@rc-component/util/es/*": ["src/*"]
1615
}
1716
},
1817
"include": [".dumirc.ts", ".fatherrc.ts", "docs", "src", "tests"]

0 commit comments

Comments
 (0)