@wwog/react 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/index.d.mts +4 -7
- package/dist/index.js +1 -1
- package/package.json +7 -1
- package/src/ProcessControl/If.tsx +3 -3
- package/src/utils/index.ts +0 -1
package/README.md
CHANGED
|
@@ -30,25 +30,25 @@ pnpm add @wwog/react
|
|
|
30
30
|
|
|
31
31
|
### 流程控制组件
|
|
32
32
|
|
|
33
|
-
#### `<If
|
|
33
|
+
#### `<If>`
|
|
34
34
|
|
|
35
35
|
声明式的条件渲染组件,类似于 if-else 语句,但在 JSX 中使用。
|
|
36
36
|
|
|
37
37
|
```tsx
|
|
38
|
-
import { If
|
|
38
|
+
import { If } from '@wwog/react';
|
|
39
39
|
|
|
40
40
|
function Example({ count }) {
|
|
41
41
|
return (
|
|
42
42
|
<If condition={count > 10}>
|
|
43
|
-
<Then>
|
|
43
|
+
<If.Then>
|
|
44
44
|
<p>Count is greater than 10</p>
|
|
45
|
-
</Then>
|
|
46
|
-
<ElseIf condition={count > 5}>
|
|
45
|
+
</If.Then>
|
|
46
|
+
<If.ElseIf condition={count > 5}>
|
|
47
47
|
<p>Count is greater than 5</p>
|
|
48
|
-
</ElseIf>
|
|
49
|
-
<Else>
|
|
48
|
+
</If.ElseIf>
|
|
49
|
+
<If.Else>
|
|
50
50
|
<p>Count is 5 or less</p>
|
|
51
|
-
</Else>
|
|
51
|
+
</If.Else>
|
|
52
52
|
</If>
|
|
53
53
|
);
|
|
54
54
|
}
|
|
@@ -59,23 +59,23 @@ function Example({ count }) {
|
|
|
59
59
|
类似于 JavaScript 的 switch 语句,但更具声明性和类型安全性。
|
|
60
60
|
|
|
61
61
|
```tsx
|
|
62
|
-
import { Switch
|
|
62
|
+
import { Switch } from '@wwog/react';
|
|
63
63
|
|
|
64
64
|
function Example({ status }) {
|
|
65
65
|
return (
|
|
66
66
|
<Switch value={status}>
|
|
67
|
-
<Case value="loading">
|
|
67
|
+
<Switch.Case value="loading">
|
|
68
68
|
<Loading />
|
|
69
|
-
</Case>
|
|
70
|
-
<Case value="success">
|
|
69
|
+
</Switch.Case>
|
|
70
|
+
<Switch.Case value="success">
|
|
71
71
|
<Success />
|
|
72
|
-
</Case>
|
|
73
|
-
<Case value="error">
|
|
72
|
+
</Switch.Case>
|
|
73
|
+
<Switch.Case value="error">
|
|
74
74
|
<Error />
|
|
75
|
-
</Case>
|
|
76
|
-
<Default>
|
|
75
|
+
</Switch.Case>
|
|
76
|
+
<Switch.Default>
|
|
77
77
|
<p>Unknown status</p>
|
|
78
|
-
</Default>
|
|
78
|
+
</Switch.Default>
|
|
79
79
|
</Switch>
|
|
80
80
|
);
|
|
81
81
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -63,15 +63,12 @@ interface ElseIfProps {
|
|
|
63
63
|
condition: boolean;
|
|
64
64
|
children?: React$1.ReactNode;
|
|
65
65
|
}
|
|
66
|
-
declare const Then: FC<ThenProps>;
|
|
67
|
-
declare const Else: FC<ElseProps>;
|
|
68
|
-
declare const ElseIf: FC<ElseIfProps>;
|
|
69
66
|
declare const If: {
|
|
70
67
|
({ condition, children, }: IfProps): React$1.ReactElement | null;
|
|
71
68
|
displayName: string;
|
|
72
|
-
Then: FC<ThenProps>;
|
|
73
|
-
ElseIf: FC<ElseIfProps>;
|
|
74
|
-
Else: FC<ElseProps>;
|
|
69
|
+
Then: React$1.FC<ThenProps>;
|
|
70
|
+
ElseIf: React$1.FC<ElseIfProps>;
|
|
71
|
+
Else: React$1.FC<ElseProps>;
|
|
75
72
|
createTyped(): {
|
|
76
73
|
If: (props: IfProps) => React$1.ReactElement | null;
|
|
77
74
|
Then: (props: ThenProps) => React$1.ReactElement;
|
|
@@ -106,5 +103,5 @@ declare function ArrayRender<T>(props: ArrayRenderProps<T>): ReactNode;
|
|
|
106
103
|
*/
|
|
107
104
|
declare function childrenLoop(children: React$1.ReactNode | undefined, callback: (child: React$1.ReactNode, index: number) => boolean | void): void;
|
|
108
105
|
|
|
109
|
-
export { ArrayRender,
|
|
106
|
+
export { ArrayRender, If, SizeBox, Switch, childrenLoop };
|
|
110
107
|
export type { ArrayRenderProps, ElseIfProps, ElseProps, IfProps, SwitchCaseProps, SwitchDefaultProps, SwitchProps, ThenProps };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wwog/react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "wwog",
|
|
@@ -24,11 +24,17 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@biomejs/biome": "^1.9.4",
|
|
27
|
+
"@types/react": "^19.1.2",
|
|
28
|
+
"@types/react-dom": "^19.1.2",
|
|
27
29
|
"@vitest/coverage-v8": "^3.1.1",
|
|
28
30
|
"typescript": "^5.8.3",
|
|
29
31
|
"unbuild": "^3.5.0",
|
|
30
32
|
"vitest": "^3.1.1"
|
|
31
33
|
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": ">=16.8.0",
|
|
36
|
+
"react-dom": ">=16.8.0"
|
|
37
|
+
},
|
|
32
38
|
"engines": {
|
|
33
39
|
"node": ">= 20.0.0",
|
|
34
40
|
"pnpm": ">=8.15.0"
|
|
@@ -18,13 +18,13 @@ export interface ElseIfProps {
|
|
|
18
18
|
children?: React.ReactNode;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const Then: FC<ThenProps> = (props) => {
|
|
22
22
|
return <>{props.children}</>;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
const Else: FC<ElseProps> = ({ children }) => {
|
|
25
25
|
return <>{children}</>;
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
const ElseIf: FC<ElseIfProps> = (props) => {
|
|
28
28
|
return <>{props.children}</>;
|
|
29
29
|
};
|
|
30
30
|
Then.displayName = "If_Then";
|