@jiovan-labs/react-condition 0.0.0-stage → 2.0.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/LICENSE.txt +21 -0
- package/README.md +303 -2
- package/README.zh-CN.md +304 -0
- package/README.zh-TW.md +304 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +50 -0
- package/dist/cjs/util/Do.d.ts +6 -0
- package/dist/cjs/util/Do.js +44 -0
- package/dist/cjs/util/For.d.ts +6 -0
- package/dist/cjs/util/For.js +39 -0
- package/dist/cjs/util/If.d.ts +10 -0
- package/dist/cjs/util/If.js +69 -0
- package/dist/cjs/util/MapIterator.d.ts +6 -0
- package/dist/cjs/util/MapIterator.js +39 -0
- package/dist/cjs/util/ObjectIterator.d.ts +6 -0
- package/dist/cjs/util/ObjectIterator.js +42 -0
- package/dist/cjs/util/SetIterator.d.ts +6 -0
- package/dist/cjs/util/SetIterator.js +39 -0
- package/dist/cjs/util/Switch.d.ts +12 -0
- package/dist/cjs/util/Switch.js +80 -0
- package/dist/cjs/util/While.d.ts +6 -0
- package/dist/cjs/util/While.js +44 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/util/Do.d.ts +6 -0
- package/dist/esm/util/Do.js +18 -0
- package/dist/esm/util/For.d.ts +6 -0
- package/dist/esm/util/For.js +15 -0
- package/dist/esm/util/If.d.ts +10 -0
- package/dist/esm/util/If.js +32 -0
- package/dist/esm/util/MapIterator.d.ts +6 -0
- package/dist/esm/util/MapIterator.js +15 -0
- package/dist/esm/util/ObjectIterator.d.ts +6 -0
- package/dist/esm/util/ObjectIterator.js +18 -0
- package/dist/esm/util/SetIterator.d.ts +6 -0
- package/dist/esm/util/SetIterator.js +15 -0
- package/dist/esm/util/Switch.d.ts +12 -0
- package/dist/esm/util/Switch.js +47 -0
- package/dist/esm/util/While.d.ts +6 -0
- package/dist/esm/util/While.js +18 -0
- package/dist/umd/react-condition.min.js +1 -0
- package/package.json +122 -5
package/README.zh-TW.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# @jiovan-labs/react-condition
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/package/@jiovan-labs/react-condition)
|
|
4
|
+
[](LICENSE.txt)
|
|
5
|
+
[](https://npmjs.org/package/@jiovan-labs/react-condition)
|
|
6
|
+
|
|
7
|
+
🏅 React 條件性渲染組件 👍
|
|
8
|
+
|
|
9
|
+
## 特性
|
|
10
|
+
|
|
11
|
+
✅ 支持 'If' 條件渲染
|
|
12
|
+
|
|
13
|
+
✅ 支持 'If'-'Then' 條件渲染
|
|
14
|
+
|
|
15
|
+
✅ 支持 'If'-'Else' 條件渲染
|
|
16
|
+
|
|
17
|
+
✅ 支持 'If'-'Then'-Else' 條件渲染
|
|
18
|
+
|
|
19
|
+
✅ 支持 'For' 條件渲染
|
|
20
|
+
|
|
21
|
+
✅ 支持 'Do' 條件渲染
|
|
22
|
+
|
|
23
|
+
✅ 支持 'While' 條件渲染
|
|
24
|
+
|
|
25
|
+
✅ 支持 'MapIterator' 條件渲染
|
|
26
|
+
|
|
27
|
+
✅ 支持 'SetIterator' 條件渲染
|
|
28
|
+
|
|
29
|
+
✅ 支持 'ObjectIterator' 條件渲染
|
|
30
|
+
|
|
31
|
+
## 快速開始
|
|
32
|
+
|
|
33
|
+
您可以在您的 React 項目中使用以下命令來安裝本組件庫:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
$ npm install @jiovan-labs/react-condition --save
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
然后,您可以使用以下命令來導入組件:
|
|
40
|
+
|
|
41
|
+
```tsx | pure
|
|
42
|
+
import { If, For, Switch, Do, While } from '@jiovan-labs/react-condition';
|
|
43
|
+
import { MapIterator, SetIterator, ObjectIterator } from '@jiovan-labs/react-condition';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
享受您和 `react-condition` 的編程之旅吧 ✌️
|
|
47
|
+
|
|
48
|
+
## 示例
|
|
49
|
+
|
|
50
|
+
### If
|
|
51
|
+
|
|
52
|
+
> `If.Then` 和 `If.Else` 都有一個 `render` 屬性 `() => React.ReactNode`,這樣您也可以通過它來返回自定義的渲染內容, 比 React 的 `children` 屬性權重要高。
|
|
53
|
+
|
|
54
|
+
#### If
|
|
55
|
+
|
|
56
|
+
```tsx | pure
|
|
57
|
+
import React from 'react';
|
|
58
|
+
import { If } from '@jiovan-labs/react-condition';
|
|
59
|
+
|
|
60
|
+
export default () => {
|
|
61
|
+
const param: boolean = true;
|
|
62
|
+
return (
|
|
63
|
+
<If condition={param}>
|
|
64
|
+
<span>Hello World</span>
|
|
65
|
+
</If>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### If-Then
|
|
71
|
+
|
|
72
|
+
```tsx | pure
|
|
73
|
+
import React from 'react';
|
|
74
|
+
import { If } from '@jiovan-labs/react-condition';
|
|
75
|
+
|
|
76
|
+
export default () => {
|
|
77
|
+
const param: number = 1;
|
|
78
|
+
return (
|
|
79
|
+
<If condition={param}>
|
|
80
|
+
<If.Then>
|
|
81
|
+
<span>Hello World</span>
|
|
82
|
+
</If.Then>
|
|
83
|
+
</If>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### If-Else
|
|
89
|
+
|
|
90
|
+
```tsx | pure
|
|
91
|
+
import React from 'react';
|
|
92
|
+
import { If } from '@jiovan-labs/react-condition';
|
|
93
|
+
|
|
94
|
+
export default () => {
|
|
95
|
+
const param: boolean = false;
|
|
96
|
+
return (
|
|
97
|
+
<If condition={param}>
|
|
98
|
+
<span>Hello World</span>
|
|
99
|
+
<If.Else>
|
|
100
|
+
<span>Hello Jiovan</span>
|
|
101
|
+
</If.Else>
|
|
102
|
+
</If>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### If-Then-Else
|
|
108
|
+
|
|
109
|
+
```tsx | pure
|
|
110
|
+
import React from 'react';
|
|
111
|
+
import { If } from '@jiovan-labs/react-condition';
|
|
112
|
+
|
|
113
|
+
export default () => {
|
|
114
|
+
const param: boolean = false;
|
|
115
|
+
return (
|
|
116
|
+
<If condition={param}>
|
|
117
|
+
<If.Then>
|
|
118
|
+
<span>Hello World</span>
|
|
119
|
+
</If.Then>
|
|
120
|
+
<If.Else>
|
|
121
|
+
<span>Hello Jiovan</span>
|
|
122
|
+
</If.Else>
|
|
123
|
+
</If>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### For
|
|
129
|
+
|
|
130
|
+
```tsx | pure
|
|
131
|
+
import React from 'react';
|
|
132
|
+
import { For } from '@jiovan-labs/react-condition';
|
|
133
|
+
|
|
134
|
+
export default () => {
|
|
135
|
+
return (
|
|
136
|
+
<For
|
|
137
|
+
of={['foo', 'bar']}
|
|
138
|
+
render={(item, index) => {
|
|
139
|
+
return (
|
|
140
|
+
<span key={index}>Hello, {item}</span>
|
|
141
|
+
);
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Switch
|
|
149
|
+
|
|
150
|
+
> `Switch.Case` 和 `Switch.Default` 都有一個 `render` 屬性 `() => React.ReactNode`,這樣您也可以通過它來返回自定義的渲染內容, 比 React 的 `children` 屬性權重要高。
|
|
151
|
+
|
|
152
|
+
```tsx | pure
|
|
153
|
+
import React from 'react';
|
|
154
|
+
import { Switch } from '@jiovan-labs/react-condition';
|
|
155
|
+
|
|
156
|
+
export default () => {
|
|
157
|
+
const username: string = 'admin';
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<Switch>
|
|
161
|
+
<Switch.Case condition={username.includes('admin')}>
|
|
162
|
+
<span>admin</span>
|
|
163
|
+
</Switch.Case>
|
|
164
|
+
<Switch.Case condition={username.includes('guest')}>
|
|
165
|
+
<span>guest</span>
|
|
166
|
+
</Switch.Case>
|
|
167
|
+
<Switch.Default>
|
|
168
|
+
<span>root</span>
|
|
169
|
+
</Switch.Default>
|
|
170
|
+
</Switch>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Do
|
|
176
|
+
|
|
177
|
+
```tsx | pure
|
|
178
|
+
import React from 'react';
|
|
179
|
+
import { Do } from '@jiovan-labs/react-condition';
|
|
180
|
+
|
|
181
|
+
export default () => {
|
|
182
|
+
let param: number = 0;
|
|
183
|
+
return (
|
|
184
|
+
<Do
|
|
185
|
+
condition={() => {
|
|
186
|
+
return param < 2;
|
|
187
|
+
}}
|
|
188
|
+
render={(index) => {
|
|
189
|
+
param++;
|
|
190
|
+
return (
|
|
191
|
+
<span key={index}>Hello, {index}</span>
|
|
192
|
+
);
|
|
193
|
+
}}
|
|
194
|
+
/>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### While
|
|
200
|
+
|
|
201
|
+
```tsx | pure
|
|
202
|
+
import React from 'react';
|
|
203
|
+
import { While } from '@jiovan-labs/react-condition';
|
|
204
|
+
|
|
205
|
+
export default () => {
|
|
206
|
+
let param: number = 0;
|
|
207
|
+
return (
|
|
208
|
+
<While
|
|
209
|
+
condition={() => {
|
|
210
|
+
return param++ < 2;
|
|
211
|
+
}}
|
|
212
|
+
render={(index) => {
|
|
213
|
+
return (
|
|
214
|
+
<span key={index}>Hello, {index}</span>
|
|
215
|
+
);
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### MapIterator
|
|
223
|
+
|
|
224
|
+
```tsx | pure
|
|
225
|
+
import React from 'react';
|
|
226
|
+
import { MapIterator } from '@jiovan-labs/react-condition';
|
|
227
|
+
|
|
228
|
+
export default () => {
|
|
229
|
+
const map = new Map([
|
|
230
|
+
['foo', 'bar'],
|
|
231
|
+
['hello', 'world'],
|
|
232
|
+
]);
|
|
233
|
+
return (
|
|
234
|
+
<MapIterator
|
|
235
|
+
of={map}
|
|
236
|
+
render={(value, key, index) => {
|
|
237
|
+
return (
|
|
238
|
+
<span key={index}>Hooray, {key}-{value}</span>
|
|
239
|
+
);
|
|
240
|
+
}}
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### SetIterator
|
|
247
|
+
|
|
248
|
+
```tsx | pure
|
|
249
|
+
import React from 'react';
|
|
250
|
+
import { SetIterator } from '@jiovan-labs/react-condition';
|
|
251
|
+
|
|
252
|
+
export default () => {
|
|
253
|
+
const set = new Set<string>([
|
|
254
|
+
'foo-bar',
|
|
255
|
+
'hello-world',
|
|
256
|
+
]);
|
|
257
|
+
return (
|
|
258
|
+
<SetIterator
|
|
259
|
+
of={set}
|
|
260
|
+
render={(item, index) => {
|
|
261
|
+
return (
|
|
262
|
+
<span key={index}>Hooray, {item}</span>
|
|
263
|
+
);
|
|
264
|
+
}}
|
|
265
|
+
/>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### ObjectIterator
|
|
271
|
+
|
|
272
|
+
```tsx | pure
|
|
273
|
+
import React from 'react';
|
|
274
|
+
import { ObjectIterator } from '@jiovan-labs/react-condition';
|
|
275
|
+
|
|
276
|
+
export default () => {
|
|
277
|
+
const param: object = {
|
|
278
|
+
'foo': 'bar',
|
|
279
|
+
'hello': 'world',
|
|
280
|
+
};
|
|
281
|
+
return (
|
|
282
|
+
<ObjectIterator
|
|
283
|
+
of={param}
|
|
284
|
+
render={(value, key, index) => {
|
|
285
|
+
return (
|
|
286
|
+
<span key={index}>Hooray, {key}-{value}</span>
|
|
287
|
+
);
|
|
288
|
+
}}
|
|
289
|
+
/>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## 授權
|
|
295
|
+
|
|
296
|
+
本組件庫授權基于 [MIT License](https://mit-license.org/) 協議
|
|
297
|
+
|
|
298
|
+
## 版權
|
|
299
|
+
|
|
300
|
+
北京玖漫科技有限公司
|
|
301
|
+
|
|
302
|
+
## 網站
|
|
303
|
+
|
|
304
|
+
- Jiovan: [https://joivan.com](https://joivan.com)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Do, type DoProps } from './util/Do';
|
|
2
|
+
export { For, type ForProps } from './util/For';
|
|
3
|
+
export { If, type IfProps, type IfThenProps, type IfElseProps } from './util/If';
|
|
4
|
+
export { MapIterator, type MapIteratorProps } from './util/MapIterator';
|
|
5
|
+
export { ObjectIterator, type ObjectIteratorProps } from './util/ObjectIterator';
|
|
6
|
+
export { SetIterator, type SetIteratorProps } from './util/SetIterator';
|
|
7
|
+
export { Switch, type SwitchCaseProps, type SwitchDefaultProps } from './util/Switch';
|
|
8
|
+
export { While, type WhileProps } from './util/While';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/index.ts
|
|
20
|
+
var src_exports = {};
|
|
21
|
+
__export(src_exports, {
|
|
22
|
+
Do: () => import_Do.Do,
|
|
23
|
+
For: () => import_For.For,
|
|
24
|
+
If: () => import_If.If,
|
|
25
|
+
MapIterator: () => import_MapIterator.MapIterator,
|
|
26
|
+
ObjectIterator: () => import_ObjectIterator.ObjectIterator,
|
|
27
|
+
SetIterator: () => import_SetIterator.SetIterator,
|
|
28
|
+
Switch: () => import_Switch.Switch,
|
|
29
|
+
While: () => import_While.While
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
var import_Do = require("./util/Do");
|
|
33
|
+
var import_For = require("./util/For");
|
|
34
|
+
var import_If = require("./util/If");
|
|
35
|
+
var import_MapIterator = require("./util/MapIterator");
|
|
36
|
+
var import_ObjectIterator = require("./util/ObjectIterator");
|
|
37
|
+
var import_SetIterator = require("./util/SetIterator");
|
|
38
|
+
var import_Switch = require("./util/Switch");
|
|
39
|
+
var import_While = require("./util/While");
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
Do,
|
|
43
|
+
For,
|
|
44
|
+
If,
|
|
45
|
+
MapIterator,
|
|
46
|
+
ObjectIterator,
|
|
47
|
+
SetIterator,
|
|
48
|
+
Switch,
|
|
49
|
+
While
|
|
50
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/util/Do.tsx
|
|
20
|
+
var Do_exports = {};
|
|
21
|
+
__export(Do_exports, {
|
|
22
|
+
Do: () => Do
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Do_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var Do = (props) => {
|
|
27
|
+
const result = [];
|
|
28
|
+
let index = 0;
|
|
29
|
+
do {
|
|
30
|
+
if (props.render) {
|
|
31
|
+
result.push(props == null ? void 0 : props.render(index));
|
|
32
|
+
} else if (!props.render && props.children) {
|
|
33
|
+
result.push(
|
|
34
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "condition-do", children: props.children }, index)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
index++;
|
|
38
|
+
} while (props.condition());
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
Do
|
|
44
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/util/For.tsx
|
|
20
|
+
var For_exports = {};
|
|
21
|
+
__export(For_exports, {
|
|
22
|
+
For: () => For
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(For_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var For = (props) => {
|
|
27
|
+
return props.of.map((item, index) => {
|
|
28
|
+
if (props.render) {
|
|
29
|
+
return props.render(item, index);
|
|
30
|
+
} else if (!props.render && props.children) {
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "condition-for", children: props.children }, index);
|
|
32
|
+
}
|
|
33
|
+
return void 0;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
For
|
|
39
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type IfProps = React.PropsWithChildren<{
|
|
3
|
+
condition: boolean | number | string | undefined | null;
|
|
4
|
+
validation?: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
export type IfThenProps = IfProps & {
|
|
7
|
+
render?: () => React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export type IfElseProps = IfThenProps;
|
|
10
|
+
export declare const If: any;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/util/If.tsx
|
|
30
|
+
var If_exports = {};
|
|
31
|
+
__export(If_exports, {
|
|
32
|
+
If: () => If
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(If_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var If = (props) => {
|
|
37
|
+
if (!props.children) {
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
if (props.validation !== false) {
|
|
41
|
+
let thenCount = 0, elseCount = 0;
|
|
42
|
+
import_react.default.Children.forEach(props.children, (item) => {
|
|
43
|
+
const childType = item == null ? void 0 : item.type;
|
|
44
|
+
if (childType === If.Then) {
|
|
45
|
+
thenCount++;
|
|
46
|
+
}
|
|
47
|
+
if (childType === If.Else) {
|
|
48
|
+
elseCount++;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (thenCount > 1 || elseCount > 1) {
|
|
52
|
+
throw SyntaxError(`Each statement of 'If.Then/If.Else' for [If condition='${props.condition}'] must be a single one!`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return import_react.default.Children.map(props.children, (item) => {
|
|
56
|
+
const isElse = (item == null ? void 0 : item.type) === If.Else;
|
|
57
|
+
return props.condition && !isElse || !props.condition && isElse ? item : void 0;
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
If.Then = (props) => {
|
|
61
|
+
return (props == null ? void 0 : props.render) ? props.render() : props == null ? void 0 : props.children;
|
|
62
|
+
};
|
|
63
|
+
If.Else = (props) => {
|
|
64
|
+
return (props == null ? void 0 : props.render) ? props.render() : props == null ? void 0 : props.children;
|
|
65
|
+
};
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
If
|
|
69
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/util/MapIterator.tsx
|
|
20
|
+
var MapIterator_exports = {};
|
|
21
|
+
__export(MapIterator_exports, {
|
|
22
|
+
MapIterator: () => MapIterator
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(MapIterator_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var MapIterator = (props) => {
|
|
27
|
+
return Array.from(props.of).map((item, index) => {
|
|
28
|
+
if (props.render) {
|
|
29
|
+
return (item == null ? void 0 : item.length) > 1 ? props.render(item[1], item[0], index) : void 0;
|
|
30
|
+
} else if (!props.render && props.children) {
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "condition-map-iterator", children: props.children }, index);
|
|
32
|
+
}
|
|
33
|
+
return void 0;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
MapIterator
|
|
39
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/util/ObjectIterator.tsx
|
|
20
|
+
var ObjectIterator_exports = {};
|
|
21
|
+
__export(ObjectIterator_exports, {
|
|
22
|
+
ObjectIterator: () => ObjectIterator
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ObjectIterator_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var ObjectIterator = (props) => {
|
|
27
|
+
if (!props.of) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
return Object.keys(props.of).map((item, index) => {
|
|
31
|
+
if (props.render) {
|
|
32
|
+
return props.render(props.of[item], item, index);
|
|
33
|
+
} else if (!props.render && props.children) {
|
|
34
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "condition-object-iterator", children: props.children }, index);
|
|
35
|
+
}
|
|
36
|
+
return void 0;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
ObjectIterator
|
|
42
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/util/SetIterator.tsx
|
|
20
|
+
var SetIterator_exports = {};
|
|
21
|
+
__export(SetIterator_exports, {
|
|
22
|
+
SetIterator: () => SetIterator
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(SetIterator_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var SetIterator = (props) => {
|
|
27
|
+
return Array.from(props.of).map((item, index) => {
|
|
28
|
+
if (props.render) {
|
|
29
|
+
return props.render(item, index);
|
|
30
|
+
} else if (!props.render && props.children) {
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "condition-set-iterator", children: props.children }, index);
|
|
32
|
+
}
|
|
33
|
+
return void 0;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
SetIterator
|
|
39
|
+
});
|