@wwog/react 1.1.0 → 1.1.1

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 CHANGED
@@ -30,25 +30,25 @@ pnpm add @wwog/react
30
30
 
31
31
  ### 流程控制组件
32
32
 
33
- #### `<If>`, `<Then>`, `<Else>`, `<ElseIf>`
33
+ #### `<If>`
34
34
 
35
35
  声明式的条件渲染组件,类似于 if-else 语句,但在 JSX 中使用。
36
36
 
37
37
  ```tsx
38
- import { If, Then, Else, ElseIf } from '@wwog/react';
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, Case, Default } from '@wwog/react';
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
@@ -1,4 +1,4 @@
1
- import React$1, { FC, ReactNode } from 'react';
1
+ import React$1, { FC as FC$1, ReactNode } from 'react';
2
2
 
3
3
  interface SwitchProps<T> {
4
4
  value: T;
@@ -63,9 +63,6 @@ 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;
@@ -91,7 +88,7 @@ interface SizeBoxProps {
91
88
  /**
92
89
  * @description SizeBox 组件用于设置一个固定大小的盒子
93
90
  */
94
- declare const SizeBox: FC<SizeBoxProps>;
91
+ declare const SizeBox: FC$1<SizeBoxProps>;
95
92
 
96
93
  interface ArrayRenderProps<T> {
97
94
  items: T[];
@@ -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, Else, ElseIf, If, SizeBox, Switch, Then, childrenLoop };
106
+ export { ArrayRender, If, SizeBox, Switch, childrenLoop };
110
107
  export type { ArrayRenderProps, ElseIfProps, ElseProps, IfProps, SwitchCaseProps, SwitchDefaultProps, SwitchProps, ThenProps };
package/dist/index.js CHANGED
@@ -180,4 +180,4 @@ function ArrayRender(props) {
180
180
  }));
181
181
  }
182
182
 
183
- export { ArrayRender, Else, ElseIf, If, SizeBox, Switch, Then, childrenLoop };
183
+ export { ArrayRender, If, SizeBox, Switch, childrenLoop };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wwog/react",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "wwog",
@@ -18,13 +18,13 @@ export interface ElseIfProps {
18
18
  children?: React.ReactNode;
19
19
  }
20
20
 
21
- export const Then: FC<ThenProps> = (props) => {
21
+ const Then: FC<ThenProps> = (props) => {
22
22
  return <>{props.children}</>;
23
23
  };
24
- export const Else: FC<ElseProps> = ({ children }) => {
24
+ const Else: FC<ElseProps> = ({ children }) => {
25
25
  return <>{children}</>;
26
26
  };
27
- export const ElseIf: FC<ElseIfProps> = (props) => {
27
+ const ElseIf: FC<ElseIfProps> = (props) => {
28
28
  return <>{props.children}</>;
29
29
  };
30
30
  Then.displayName = "If_Then";