@faasjs/ant-design 0.0.2-beta.375 → 0.0.2-beta.378
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 +7 -7
- package/dist/index.d.ts +5 -2
- package/dist/index.js +16 -11
- package/dist/index.mjs +16 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -305,7 +305,7 @@ ___
|
|
|
305
305
|
|
|
306
306
|
### FormProps
|
|
307
307
|
|
|
308
|
-
Ƭ **FormProps**<`Values`, `ExtendItemProps`\>: { `extendTypes?`: { `[type: string]`: [`ExtendFormTypeProps`](#extendformtypeprops); } ; `items?`: ([`FormItemProps`](#formitemprops) \| `ExtendItemProps`)[] ; `submit?`: ``false`` \| { `text?`: `string` ; `to?`: { `action`: `string` ; `params?`: `Record`<`string`, `any`\> } } ; `onFinish?`: (`values`: `Values`, `submit?`: (`values`: `any`) => `Promise`<`any`\>) => `Promise`<`any`\> } & `Omit`<`AntdFormProps`<`Values`\>, ``"onFinish"``\>
|
|
308
|
+
Ƭ **FormProps**<`Values`, `ExtendItemProps`\>: { `beforeItems?`: `JSX.Element` \| `JSX.Element`[] ; `extendTypes?`: { `[type: string]`: [`ExtendFormTypeProps`](#extendformtypeprops); } ; `items?`: ([`FormItemProps`](#formitemprops) \| `ExtendItemProps`)[] ; `submit?`: ``false`` \| { `text?`: `string` ; `to?`: { `action`: `string` ; `params?`: `Record`<`string`, `any`\> } } ; `onFinish?`: (`values`: `Values`, `submit?`: (`values`: `any`) => `Promise`<`any`\>) => `Promise`<`any`\> } & `Omit`<`AntdFormProps`<`Values`\>, ``"onFinish"``\>
|
|
309
309
|
|
|
310
310
|
#### Type parameters
|
|
311
311
|
|
|
@@ -318,7 +318,7 @@ ___
|
|
|
318
318
|
|
|
319
319
|
### ModalProps
|
|
320
320
|
|
|
321
|
-
Ƭ **ModalProps**: `AntdModalProps` & { `children?`: `JSX.Element` \| `JSX.Element`[] }
|
|
321
|
+
Ƭ **ModalProps**: `AntdModalProps` & { `children?`: `JSX.Element` \| `JSX.Element`[] \| `string` }
|
|
322
322
|
|
|
323
323
|
___
|
|
324
324
|
|
|
@@ -425,13 +425,13 @@ ___
|
|
|
425
425
|
|
|
426
426
|
### DatePicker
|
|
427
427
|
|
|
428
|
-
• **DatePicker**: `PickerComponentClass`<`PickerProps`<`Dayjs`\>, `unknown`\> & {}
|
|
428
|
+
• `Const` **DatePicker**: `PickerComponentClass`<`PickerProps`<`Dayjs`\>, `unknown`\> & {}
|
|
429
429
|
|
|
430
430
|
___
|
|
431
431
|
|
|
432
432
|
### TimePicker
|
|
433
433
|
|
|
434
|
-
• **TimePicker**: `ForwardRefExoticComponent`<[`TimePickerProps`](#timepickerprops) & `RefAttributes`<`any`\>\>
|
|
434
|
+
• `Const` **TimePicker**: `ForwardRefExoticComponent`<[`TimePickerProps`](#timepickerprops) & `RefAttributes`<`any`\>\>
|
|
435
435
|
|
|
436
436
|
## Functions
|
|
437
437
|
|
|
@@ -459,7 +459,7 @@ ___
|
|
|
459
459
|
|
|
460
460
|
### Calendar
|
|
461
461
|
|
|
462
|
-
▸
|
|
462
|
+
▸ **Calendar**(`props`): `Element`
|
|
463
463
|
|
|
464
464
|
#### Parameters
|
|
465
465
|
|
|
@@ -691,7 +691,7 @@ ___
|
|
|
691
691
|
|
|
692
692
|
### useFaasState
|
|
693
693
|
|
|
694
|
-
▸
|
|
694
|
+
▸ **useFaasState**(): [[`FaasState`](#faasstate), (`state`: `IHookStateSetAction`<[`FaasState`](#faasstate)\>) => `void`]
|
|
695
695
|
|
|
696
696
|
#### Returns
|
|
697
697
|
|
|
@@ -709,7 +709,7 @@ Hook style modal.
|
|
|
709
709
|
|
|
710
710
|
| Name | Type | Description |
|
|
711
711
|
| :------ | :------ | :------ |
|
|
712
|
-
| `init?` | [`ModalProps`](#modalprops) | initial props ```ts function Example() { const { modal, setModalProps } = useModal() return <>{modal}</> } ``` |
|
|
712
|
+
| `init?` | [`ModalProps`](#modalprops) | initial props ```ts function Example() { const { modal, setModalProps } = useModal() return <> <Button onClick={() => setModalProps({ visible: true })}>Open Modal</Button> {modal}</> } ``` |
|
|
713
713
|
|
|
714
714
|
#### Returns
|
|
715
715
|
|
package/dist/index.d.ts
CHANGED
|
@@ -263,6 +263,7 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
|
263
263
|
};
|
|
264
264
|
};
|
|
265
265
|
onFinish?: (values: Values, submit?: (values: any) => Promise<any>) => Promise<any>;
|
|
266
|
+
beforeItems?: JSX.Element | JSX.Element[];
|
|
266
267
|
extendTypes?: {
|
|
267
268
|
[type: string]: ExtendFormTypeProps;
|
|
268
269
|
};
|
|
@@ -274,7 +275,7 @@ declare namespace Form {
|
|
|
274
275
|
}
|
|
275
276
|
|
|
276
277
|
declare type ModalProps = ModalProps$1 & {
|
|
277
|
-
children?: JSX.Element | JSX.Element[];
|
|
278
|
+
children?: JSX.Element | JSX.Element[] | string;
|
|
278
279
|
};
|
|
279
280
|
declare type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
280
281
|
/**
|
|
@@ -285,7 +286,9 @@ declare type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
|
285
286
|
* function Example() {
|
|
286
287
|
* const { modal, setModalProps } = useModal()
|
|
287
288
|
*
|
|
288
|
-
* return <>
|
|
289
|
+
* return <>
|
|
290
|
+
* <Button onClick={() => setModalProps({ visible: true })}>Open Modal</Button>
|
|
291
|
+
* {modal}</>
|
|
289
292
|
* }
|
|
290
293
|
* ```
|
|
291
294
|
*/
|
package/dist/index.js
CHANGED
|
@@ -178,22 +178,22 @@ function DescriptionItemContent(props) {
|
|
|
178
178
|
values: computedProps.values
|
|
179
179
|
});
|
|
180
180
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
181
|
-
return computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values);
|
|
181
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values));
|
|
182
182
|
else
|
|
183
183
|
throw Error(computedProps.item.type + " requires children or render");
|
|
184
184
|
if (computedProps.item.children)
|
|
185
185
|
return (0, import_react3.cloneElement)(computedProps.item.children, { value: computedProps.value });
|
|
186
186
|
if (computedProps.item.render)
|
|
187
|
-
return computedProps.item.render(computedProps.value, computedProps.values);
|
|
187
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.item.render(computedProps.value, computedProps.values));
|
|
188
188
|
if (typeof computedProps.value === "undefined" || computedProps.value === null)
|
|
189
189
|
return null;
|
|
190
190
|
switch (computedProps.item.type) {
|
|
191
191
|
case "string[]":
|
|
192
|
-
return computedProps.value.join(", ");
|
|
192
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.value.join(", "));
|
|
193
193
|
case "number":
|
|
194
|
-
return computedProps.value;
|
|
194
|
+
return computedProps.value || null;
|
|
195
195
|
case "number[]":
|
|
196
|
-
return computedProps.value.join(", ");
|
|
196
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.value.join(", "));
|
|
197
197
|
case "boolean":
|
|
198
198
|
return computedProps.value ? /* @__PURE__ */ import_react.default.createElement(import_icons.CheckOutlined, {
|
|
199
199
|
style: {
|
|
@@ -207,11 +207,11 @@ function DescriptionItemContent(props) {
|
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
case "time":
|
|
210
|
-
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? import_dayjs3.default.unix(computedProps.value).format("YYYY-MM-DD HH:mm:ss") : (0, import_dayjs3.default)(computedProps.value).format("YYYY-MM-DD HH:mm:ss");
|
|
210
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? import_dayjs3.default.unix(computedProps.value).format("YYYY-MM-DD HH:mm:ss") : (0, import_dayjs3.default)(computedProps.value).format("YYYY-MM-DD HH:mm:ss"));
|
|
211
211
|
case "date":
|
|
212
|
-
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? import_dayjs3.default.unix(computedProps.value).format("YYYY-MM-DD") : (0, import_dayjs3.default)(computedProps.value).format("YYYY-MM-DD");
|
|
212
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? import_dayjs3.default.unix(computedProps.value).format("YYYY-MM-DD") : (0, import_dayjs3.default)(computedProps.value).format("YYYY-MM-DD"));
|
|
213
213
|
default:
|
|
214
|
-
return computedProps.value;
|
|
214
|
+
return computedProps.value || null;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
function Description(props) {
|
|
@@ -444,13 +444,14 @@ function Form(props) {
|
|
|
444
444
|
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
445
445
|
const [config] = useFaasState();
|
|
446
446
|
(0, import_react9.useEffect)(() => {
|
|
447
|
+
var _a2;
|
|
447
448
|
const propsCopy = __spreadValues({}, props);
|
|
448
449
|
if (propsCopy.onFinish) {
|
|
449
450
|
propsCopy.onFinish = async (values) => {
|
|
450
|
-
var
|
|
451
|
+
var _a3;
|
|
451
452
|
setLoading(true);
|
|
452
453
|
try {
|
|
453
|
-
if (propsCopy.submit && ((
|
|
454
|
+
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
454
455
|
await props.onFinish(values, async (values2) => (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values2), propsCopy.submit.to.params) : values2));
|
|
455
456
|
} else
|
|
456
457
|
await propsCopy.onFinish(values);
|
|
@@ -459,12 +460,16 @@ function Form(props) {
|
|
|
459
460
|
}
|
|
460
461
|
setLoading(false);
|
|
461
462
|
};
|
|
463
|
+
} else if (propsCopy.submit && ((_a2 = propsCopy.submit.to) == null ? void 0 : _a2.action)) {
|
|
464
|
+
propsCopy.onFinish = async (values) => {
|
|
465
|
+
return await (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values), propsCopy.submit.to.params) : values);
|
|
466
|
+
};
|
|
462
467
|
}
|
|
463
468
|
setComputedProps(propsCopy);
|
|
464
469
|
}, []);
|
|
465
470
|
if (!computedProps)
|
|
466
471
|
return null;
|
|
467
|
-
return /* @__PURE__ */ import_react.default.createElement(import_antd5.Form, __spreadValues({}, computedProps), (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ import_react.default.createElement(FormItem, __spreadProps(__spreadValues({
|
|
472
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd5.Form, __spreadValues({}, computedProps), computedProps.beforeItems, (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ import_react.default.createElement(FormItem, __spreadProps(__spreadValues({
|
|
468
473
|
key: item.id
|
|
469
474
|
}, item), {
|
|
470
475
|
extendTypes: computedProps.extendTypes
|
package/dist/index.mjs
CHANGED
|
@@ -138,22 +138,22 @@ function DescriptionItemContent(props) {
|
|
|
138
138
|
values: computedProps.values
|
|
139
139
|
});
|
|
140
140
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
141
|
-
return computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values);
|
|
141
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values));
|
|
142
142
|
else
|
|
143
143
|
throw Error(computedProps.item.type + " requires children or render");
|
|
144
144
|
if (computedProps.item.children)
|
|
145
145
|
return cloneElement(computedProps.item.children, { value: computedProps.value });
|
|
146
146
|
if (computedProps.item.render)
|
|
147
|
-
return computedProps.item.render(computedProps.value, computedProps.values);
|
|
147
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.item.render(computedProps.value, computedProps.values));
|
|
148
148
|
if (typeof computedProps.value === "undefined" || computedProps.value === null)
|
|
149
149
|
return null;
|
|
150
150
|
switch (computedProps.item.type) {
|
|
151
151
|
case "string[]":
|
|
152
|
-
return computedProps.value.join(", ");
|
|
152
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.value.join(", "));
|
|
153
153
|
case "number":
|
|
154
|
-
return computedProps.value;
|
|
154
|
+
return computedProps.value || null;
|
|
155
155
|
case "number[]":
|
|
156
|
-
return computedProps.value.join(", ");
|
|
156
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.value.join(", "));
|
|
157
157
|
case "boolean":
|
|
158
158
|
return computedProps.value ? /* @__PURE__ */ React.createElement(CheckOutlined, {
|
|
159
159
|
style: {
|
|
@@ -167,11 +167,11 @@ function DescriptionItemContent(props) {
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
case "time":
|
|
170
|
-
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? dayjs.unix(computedProps.value).format("YYYY-MM-DD HH:mm:ss") : dayjs(computedProps.value).format("YYYY-MM-DD HH:mm:ss");
|
|
170
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? dayjs.unix(computedProps.value).format("YYYY-MM-DD HH:mm:ss") : dayjs(computedProps.value).format("YYYY-MM-DD HH:mm:ss"));
|
|
171
171
|
case "date":
|
|
172
|
-
return typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? dayjs.unix(computedProps.value).format("YYYY-MM-DD") : dayjs(computedProps.value).format("YYYY-MM-DD");
|
|
172
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, typeof computedProps.value === "number" && computedProps.value.toString().length === 10 ? dayjs.unix(computedProps.value).format("YYYY-MM-DD") : dayjs(computedProps.value).format("YYYY-MM-DD"));
|
|
173
173
|
default:
|
|
174
|
-
return computedProps.value;
|
|
174
|
+
return computedProps.value || null;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
function Description(props) {
|
|
@@ -416,13 +416,14 @@ function Form(props) {
|
|
|
416
416
|
const [computedProps, setComputedProps] = useState4();
|
|
417
417
|
const [config] = useFaasState();
|
|
418
418
|
useEffect4(() => {
|
|
419
|
+
var _a2;
|
|
419
420
|
const propsCopy = __spreadValues({}, props);
|
|
420
421
|
if (propsCopy.onFinish) {
|
|
421
422
|
propsCopy.onFinish = async (values) => {
|
|
422
|
-
var
|
|
423
|
+
var _a3;
|
|
423
424
|
setLoading(true);
|
|
424
425
|
try {
|
|
425
|
-
if (propsCopy.submit && ((
|
|
426
|
+
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
426
427
|
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values2), propsCopy.submit.to.params) : values2));
|
|
427
428
|
} else
|
|
428
429
|
await propsCopy.onFinish(values);
|
|
@@ -431,12 +432,16 @@ function Form(props) {
|
|
|
431
432
|
}
|
|
432
433
|
setLoading(false);
|
|
433
434
|
};
|
|
435
|
+
} else if (propsCopy.submit && ((_a2 = propsCopy.submit.to) == null ? void 0 : _a2.action)) {
|
|
436
|
+
propsCopy.onFinish = async (values) => {
|
|
437
|
+
return await faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values), propsCopy.submit.to.params) : values);
|
|
438
|
+
};
|
|
434
439
|
}
|
|
435
440
|
setComputedProps(propsCopy);
|
|
436
441
|
}, []);
|
|
437
442
|
if (!computedProps)
|
|
438
443
|
return null;
|
|
439
|
-
return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ React.createElement(FormItem, __spreadProps(__spreadValues({
|
|
444
|
+
return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), computedProps.beforeItems, (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ React.createElement(FormItem, __spreadProps(__spreadValues({
|
|
440
445
|
key: item.id
|
|
441
446
|
}, item), {
|
|
442
447
|
extendTypes: computedProps.extendTypes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.378",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.378",
|
|
32
32
|
"react-use": "*",
|
|
33
33
|
"react-router-dom": "*",
|
|
34
34
|
"dayjs": "*"
|