@wwog/react 1.1.3 → 1.1.4

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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import React$1, { FC, ReactNode } from 'react';
1
+ import React, { FC, ReactNode } from 'react';
2
2
 
3
3
  interface SwitchProps<T> {
4
4
  value: T;
@@ -7,7 +7,7 @@ interface SwitchProps<T> {
7
7
  * @description_en optional compare function, default to () => a === b
8
8
  **/
9
9
  compare?: (a: T, b: T) => boolean;
10
- children?: React$1.ReactNode;
10
+ children?: React.ReactNode;
11
11
  /**
12
12
  * @description 是否严格模式,默认 false.建议跟随开发环境变化,严格模式下,会循环所有节点来提供更多的错误提示
13
13
  * @description_en strict mode, default to false. It is recommended to follow the development environment changes. In strict mode, all nodes will be looped to provide more error prompts
@@ -22,58 +22,58 @@ interface SwitchProps<T> {
22
22
  }
23
23
  interface SwitchCaseProps<T> {
24
24
  value: T;
25
- children?: React$1.ReactNode;
25
+ children?: React.ReactNode;
26
26
  }
27
27
  interface SwitchDefaultProps {
28
- children?: React$1.ReactNode;
28
+ children?: React.ReactNode;
29
29
  }
30
30
  /**
31
31
  * @description Switch 组件用于根据传入的 value 渲染不同的子组件
32
32
  * @description_en The Switch component is used to render different child components based on the passed value
33
33
  */
34
34
  declare const Switch: {
35
- <T>(props: SwitchProps<T>): React$1.ReactElement | null;
35
+ <T>(props: SwitchProps<T>): React.ReactElement | null;
36
36
  displayName: string;
37
37
  Case: {
38
- <T>(props: SwitchCaseProps<T>): React$1.ReactElement;
38
+ <T>(props: SwitchCaseProps<T>): React.ReactElement;
39
39
  displayName: string;
40
40
  };
41
41
  Default: {
42
- (props: SwitchDefaultProps): React$1.ReactElement;
42
+ (props: SwitchDefaultProps): React.ReactElement;
43
43
  displayName: string;
44
44
  };
45
45
  createTyped<T>(): {
46
- Switch: (props: SwitchProps<T>) => React$1.ReactElement | null;
47
- Case: (props: SwitchCaseProps<T>) => React$1.ReactElement;
48
- Default: (props: SwitchDefaultProps) => React$1.ReactElement;
46
+ Switch: (props: SwitchProps<T>) => React.ReactElement | null;
47
+ Case: (props: SwitchCaseProps<T>) => React.ReactElement;
48
+ Default: (props: SwitchDefaultProps) => React.ReactElement;
49
49
  };
50
50
  };
51
51
 
52
52
  interface IfProps {
53
53
  condition: boolean;
54
- children?: React$1.ReactNode;
54
+ children?: React.ReactNode;
55
55
  }
56
56
  interface ThenProps {
57
- children?: React$1.ReactNode;
57
+ children?: React.ReactNode;
58
58
  }
59
59
  interface ElseProps {
60
- children?: React$1.ReactNode;
60
+ children?: React.ReactNode;
61
61
  }
62
62
  interface ElseIfProps {
63
63
  condition: boolean;
64
- children?: React$1.ReactNode;
64
+ children?: React.ReactNode;
65
65
  }
66
66
  declare const If: {
67
- ({ condition, children, }: IfProps): React$1.ReactElement | null;
67
+ ({ condition, children, }: IfProps): React.ReactElement | null;
68
68
  displayName: string;
69
- Then: React$1.FC<ThenProps>;
70
- ElseIf: React$1.FC<ElseIfProps>;
71
- Else: React$1.FC<ElseProps>;
69
+ Then: React.FC<ThenProps>;
70
+ ElseIf: React.FC<ElseIfProps>;
71
+ Else: React.FC<ElseProps>;
72
72
  createTyped(): {
73
- If: (props: IfProps) => React$1.ReactElement | null;
74
- Then: (props: ThenProps) => React$1.ReactElement;
75
- ElseIf: (props: ElseIfProps) => React$1.ReactElement;
76
- Else: (props: ElseProps) => React$1.ReactElement;
73
+ If: (props: IfProps) => React.ReactElement | null;
74
+ Then: (props: ThenProps) => React.ReactElement;
75
+ ElseIf: (props: ElseIfProps) => React.ReactElement;
76
+ Else: (props: ElseProps) => React.ReactElement;
77
77
  };
78
78
  };
79
79
 
@@ -101,7 +101,7 @@ declare function ArrayRender<T>(props: ArrayRenderProps<T>): ReactNode;
101
101
  * @description 性能优化,替代 React.Children.forEach, 回调可以返回 false 来中断循环
102
102
  * @description_en Replace React.Children.forEach, the callback can return false to interrupt the loop
103
103
  */
104
- declare function childrenLoop(children: React$1.ReactNode | undefined, callback: (child: React$1.ReactNode, index: number) => boolean | void): void;
104
+ declare function childrenLoop(children: React.ReactNode | undefined, callback: (child: React.ReactNode, index: number) => boolean | void): void;
105
105
 
106
106
  export { ArrayRender, If, SizeBox, Switch, childrenLoop };
107
107
  export type { ArrayRenderProps, ElseIfProps, ElseProps, IfProps, SwitchCaseProps, SwitchDefaultProps, SwitchProps, ThenProps };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import React$1, { Fragment } from 'react';
1
+ import React, { Fragment } from 'react';
2
2
 
3
3
  function childrenLoop(children, callback) {
4
4
  if (children === void 0) return;
@@ -19,11 +19,11 @@ const defaultCompare = (a, b) => {
19
19
  return a === b;
20
20
  };
21
21
  const Case = (props) => {
22
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, props.children);
22
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
23
23
  };
24
24
  Case.displayName = "Switch_Case";
25
25
  const Default = (props) => {
26
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, props.children);
26
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
27
27
  };
28
28
  Default.displayName = "Switch_Default";
29
29
  const Switch = (props) => {
@@ -33,7 +33,7 @@ const Switch = (props) => {
33
33
  let defaultChild = null;
34
34
  let hasDefault = false;
35
35
  childrenLoop(children, (child, index) => {
36
- if (!React$1.isValidElement(child)) {
36
+ if (!React.isValidElement(child)) {
37
37
  throw new Error(
38
38
  `Switch Children only accepts valid React elements at index ${index}`
39
39
  );
@@ -74,7 +74,7 @@ const Switch = (props) => {
74
74
  );
75
75
  }
76
76
  });
77
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, matchedChildren ?? defaultChild);
77
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, matchedChildren ?? defaultChild);
78
78
  };
79
79
  Switch.displayName = "Switch";
80
80
  Switch.Case = Case;
@@ -88,13 +88,13 @@ Switch.createTyped = function() {
88
88
  };
89
89
 
90
90
  const Then = (props) => {
91
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, props.children);
91
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
92
92
  };
93
93
  const Else = ({ children }) => {
94
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, children);
94
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
95
95
  };
96
96
  const ElseIf = (props) => {
97
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, props.children);
97
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
98
98
  };
99
99
  Then.displayName = "If_Then";
100
100
  Else.displayName = "If_Else";
@@ -106,8 +106,8 @@ const If = ({
106
106
  let thenChild = null;
107
107
  let elseChild = null;
108
108
  const elseIfChildren = [];
109
- React$1.Children.forEach(children, (child) => {
110
- if (!React$1.isValidElement(child)) {
109
+ React.Children.forEach(children, (child) => {
110
+ if (!React.isValidElement(child)) {
111
111
  throw new Error("If component only accepts valid React elements");
112
112
  }
113
113
  const type = child.type;
@@ -132,15 +132,15 @@ const If = ({
132
132
  }
133
133
  });
134
134
  if (condition) {
135
- return thenChild ? /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, thenChild.props.children) : null;
135
+ return thenChild ? /* @__PURE__ */ React.createElement(React.Fragment, null, thenChild.props.children) : null;
136
136
  }
137
137
  for (const elseIf of elseIfChildren) {
138
138
  if (elseIf.props.condition) {
139
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, elseIf.props.children);
139
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, elseIf.props.children);
140
140
  }
141
141
  }
142
142
  if (elseChild) {
143
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, elseChild.props.children);
143
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, elseChild.props.children);
144
144
  }
145
145
  return null;
146
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wwog/react",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "wwog",
@@ -1,4 +1,4 @@
1
- import { Fragment, type ReactNode } from "react";
1
+ import React, { Fragment, type ReactNode } from "react";
2
2
 
3
3
  //#region component Types
4
4
  export interface ArrayRenderProps<T> {
@@ -1,4 +1,4 @@
1
- import { FC, ReactNode } from "react";
1
+ import React, { FC, ReactNode } from "react";
2
2
 
3
3
  interface SizeBoxProps {
4
4
  size?: number | string;