@faasjs/ant-design 0.0.2-beta.376 → 0.0.2-beta.379
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 +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -4
- package/dist/index.mjs +9 -4
- 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
|
|
|
@@ -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
|
|
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
|
};
|
package/dist/index.js
CHANGED
|
@@ -444,27 +444,32 @@ 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
|
-
await
|
|
457
|
+
await props.onFinish(values);
|
|
457
458
|
} catch (error) {
|
|
458
459
|
console.error(error);
|
|
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
|
@@ -416,27 +416,32 @@ 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
|
-
await
|
|
429
|
+
await props.onFinish(values);
|
|
429
430
|
} catch (error) {
|
|
430
431
|
console.error(error);
|
|
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.379",
|
|
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.379",
|
|
32
32
|
"react-use": "*",
|
|
33
33
|
"react-router-dom": "*",
|
|
34
34
|
"dayjs": "*"
|