@faasjs/ant-design 0.0.2-beta.374 → 0.0.2-beta.377
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 +37 -3
- package/dist/index.js +36 -31
- package/dist/index.mjs +19 -14
- 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` } } & `AntdFormProps`<`Values
|
|
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
|
@@ -231,11 +231,43 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
|
231
231
|
submit?: false | {
|
|
232
232
|
/** Default: Submit */
|
|
233
233
|
text?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Submit to FaasJS server.
|
|
236
|
+
*
|
|
237
|
+
* If use onFinish, you should call submit manually.
|
|
238
|
+
* ```ts
|
|
239
|
+
* {
|
|
240
|
+
* submit: {
|
|
241
|
+
* to: {
|
|
242
|
+
* action: 'action_name'
|
|
243
|
+
* }
|
|
244
|
+
* },
|
|
245
|
+
* onFinish: (values, submit) => {
|
|
246
|
+
* // do something before submit
|
|
247
|
+
*
|
|
248
|
+
* // submit
|
|
249
|
+
* await submit({
|
|
250
|
+
* ...values,
|
|
251
|
+
* extraProps: 'some extra props'
|
|
252
|
+
* })
|
|
253
|
+
*
|
|
254
|
+
* // do something after submit
|
|
255
|
+
* }
|
|
256
|
+
* }
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
to?: {
|
|
260
|
+
action: string;
|
|
261
|
+
/** params will overwrite form values before submit */
|
|
262
|
+
params?: Record<string, any>;
|
|
263
|
+
};
|
|
234
264
|
};
|
|
265
|
+
onFinish?: (values: Values, submit?: (values: any) => Promise<any>) => Promise<any>;
|
|
266
|
+
beforeItems?: JSX.Element | JSX.Element[];
|
|
235
267
|
extendTypes?: {
|
|
236
268
|
[type: string]: ExtendFormTypeProps;
|
|
237
269
|
};
|
|
238
|
-
} & FormProps$1<Values>;
|
|
270
|
+
} & Omit<FormProps$1<Values>, 'onFinish'>;
|
|
239
271
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
240
272
|
declare namespace Form {
|
|
241
273
|
var useForm: typeof antd_lib_form_Form.useForm;
|
|
@@ -243,7 +275,7 @@ declare namespace Form {
|
|
|
243
275
|
}
|
|
244
276
|
|
|
245
277
|
declare type ModalProps = ModalProps$1 & {
|
|
246
|
-
children?: JSX.Element | JSX.Element[];
|
|
278
|
+
children?: JSX.Element | JSX.Element[] | string;
|
|
247
279
|
};
|
|
248
280
|
declare type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
249
281
|
/**
|
|
@@ -254,7 +286,9 @@ declare type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
|
254
286
|
* function Example() {
|
|
255
287
|
* const { modal, setModalProps } = useModal()
|
|
256
288
|
*
|
|
257
|
-
* return <>
|
|
289
|
+
* return <>
|
|
290
|
+
* <Button onClick={() => setModalProps({ visible: true })}>Open Modal</Button>
|
|
291
|
+
* {modal}</>
|
|
258
292
|
* }
|
|
259
293
|
* ```
|
|
260
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) {
|
|
@@ -261,8 +261,9 @@ function useDrawer(init) {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
// src/Form.tsx
|
|
264
|
+
var import_react8 = require("@faasjs/react");
|
|
264
265
|
var import_antd5 = require("antd");
|
|
265
|
-
var
|
|
266
|
+
var import_react9 = require("react");
|
|
266
267
|
|
|
267
268
|
// src/FormItem.tsx
|
|
268
269
|
var import_antd4 = require("antd");
|
|
@@ -439,44 +440,48 @@ function FormItem(props) {
|
|
|
439
440
|
// src/Form.tsx
|
|
440
441
|
function Form(props) {
|
|
441
442
|
var _a, _b;
|
|
442
|
-
const [loading, setLoading] = (0,
|
|
443
|
-
const [computedProps, setComputedProps] = (0,
|
|
443
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
444
|
+
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
444
445
|
const [config] = useFaasState();
|
|
445
|
-
(0,
|
|
446
|
+
(0, import_react9.useEffect)(() => {
|
|
446
447
|
const propsCopy = __spreadValues({}, props);
|
|
447
448
|
if (propsCopy.onFinish) {
|
|
448
449
|
propsCopy.onFinish = async (values) => {
|
|
450
|
+
var _a2;
|
|
449
451
|
setLoading(true);
|
|
450
452
|
try {
|
|
451
|
-
|
|
453
|
+
if (propsCopy.submit && ((_a2 = propsCopy.submit.to) == null ? void 0 : _a2.action)) {
|
|
454
|
+
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
|
+
} else
|
|
456
|
+
await propsCopy.onFinish(values);
|
|
452
457
|
} catch (error) {
|
|
453
458
|
console.error(error);
|
|
454
459
|
}
|
|
455
460
|
setLoading(false);
|
|
456
461
|
};
|
|
457
462
|
}
|
|
458
|
-
setComputedProps(
|
|
463
|
+
setComputedProps(propsCopy);
|
|
459
464
|
}, []);
|
|
460
465
|
if (!computedProps)
|
|
461
466
|
return null;
|
|
462
|
-
return /* @__PURE__ */ import_react.default.createElement(import_antd5.Form, __spreadValues({}, computedProps), (_a =
|
|
467
|
+
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({
|
|
463
468
|
key: item.id
|
|
464
469
|
}, item), {
|
|
465
|
-
extendTypes:
|
|
466
|
-
}))),
|
|
470
|
+
extendTypes: computedProps.extendTypes
|
|
471
|
+
}))), computedProps.children, computedProps.submit !== false && /* @__PURE__ */ import_react.default.createElement(import_antd5.Button, {
|
|
467
472
|
htmlType: "submit",
|
|
468
473
|
type: "primary",
|
|
469
474
|
loading
|
|
470
|
-
}, ((_b =
|
|
475
|
+
}, ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text));
|
|
471
476
|
}
|
|
472
477
|
Form.useForm = import_antd5.Form.useForm;
|
|
473
478
|
Form.Item = FormItem;
|
|
474
479
|
|
|
475
480
|
// src/Modal.tsx
|
|
476
481
|
var import_antd6 = require("antd");
|
|
477
|
-
var
|
|
482
|
+
var import_react10 = require("react");
|
|
478
483
|
function useModal(init) {
|
|
479
|
-
const [props, setProps] = (0,
|
|
484
|
+
const [props, setProps] = (0, import_react10.useState)(__spreadValues({
|
|
480
485
|
visible: false,
|
|
481
486
|
onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
482
487
|
visible: false
|
|
@@ -493,7 +498,7 @@ function useModal(init) {
|
|
|
493
498
|
|
|
494
499
|
// src/Routers.tsx
|
|
495
500
|
var import_antd7 = require("antd");
|
|
496
|
-
var
|
|
501
|
+
var import_react11 = require("react");
|
|
497
502
|
var import_react_router_dom = require("react-router-dom");
|
|
498
503
|
function NotFound() {
|
|
499
504
|
const [config] = useFaasState();
|
|
@@ -506,7 +511,7 @@ function Routes(props) {
|
|
|
506
511
|
return /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Routes, null, props.routes.map((r) => /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Route, __spreadProps(__spreadValues({
|
|
507
512
|
key: r.path
|
|
508
513
|
}, r), {
|
|
509
|
-
element: r.element || /* @__PURE__ */ import_react.default.createElement(
|
|
514
|
+
element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react11.Suspense, {
|
|
510
515
|
fallback: props.fallback || /* @__PURE__ */ import_react.default.createElement("div", {
|
|
511
516
|
style: { padding: "24px" }
|
|
512
517
|
}, /* @__PURE__ */ import_react.default.createElement(import_antd7.Skeleton, {
|
|
@@ -521,12 +526,12 @@ function Routes(props) {
|
|
|
521
526
|
}
|
|
522
527
|
|
|
523
528
|
// src/Table.tsx
|
|
524
|
-
var
|
|
529
|
+
var import_react12 = require("react");
|
|
525
530
|
var import_antd8 = require("antd");
|
|
526
531
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
527
532
|
var import_icons3 = require("@ant-design/icons");
|
|
528
533
|
var import_lodash5 = require("lodash");
|
|
529
|
-
var
|
|
534
|
+
var import_react13 = require("@faasjs/react");
|
|
530
535
|
function processValue(item, value) {
|
|
531
536
|
var _a;
|
|
532
537
|
if (typeof value !== "undefined" && value !== null) {
|
|
@@ -557,9 +562,9 @@ function processValue(item, value) {
|
|
|
557
562
|
return value;
|
|
558
563
|
}
|
|
559
564
|
function Table(props) {
|
|
560
|
-
const [columns, setColumns] = (0,
|
|
565
|
+
const [columns, setColumns] = (0, import_react12.useState)();
|
|
561
566
|
const [config] = useFaasState();
|
|
562
|
-
(0,
|
|
567
|
+
(0, import_react12.useEffect)(() => {
|
|
563
568
|
var _a;
|
|
564
569
|
for (const item of props.items) {
|
|
565
570
|
if (!item.key)
|
|
@@ -583,7 +588,7 @@ function Table(props) {
|
|
|
583
588
|
delete item.children;
|
|
584
589
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
585
590
|
if (props.extendTypes[item.type].children) {
|
|
586
|
-
item.render = (value, values) => (0,
|
|
591
|
+
item.render = (value, values) => (0, import_react12.cloneElement)(props.extendTypes[item.type].children, {
|
|
587
592
|
value,
|
|
588
593
|
values
|
|
589
594
|
});
|
|
@@ -694,7 +699,7 @@ function Table(props) {
|
|
|
694
699
|
columns,
|
|
695
700
|
dataSource: props.dataSource
|
|
696
701
|
}));
|
|
697
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
702
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react13.FaasDataWrapper, __spreadValues({
|
|
698
703
|
fallback: props.faasData.fallback || /* @__PURE__ */ import_react.default.createElement(import_antd8.Skeleton, {
|
|
699
704
|
active: true
|
|
700
705
|
}),
|
|
@@ -742,10 +747,10 @@ function Table(props) {
|
|
|
742
747
|
}
|
|
743
748
|
|
|
744
749
|
// src/Title.tsx
|
|
745
|
-
var
|
|
750
|
+
var import_react14 = require("react");
|
|
746
751
|
function Title(props) {
|
|
747
752
|
const [config] = useFaasState();
|
|
748
|
-
(0,
|
|
753
|
+
(0, import_react14.useEffect)(() => {
|
|
749
754
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
750
755
|
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
751
756
|
}, []);
|
|
@@ -758,7 +763,7 @@ function Title(props) {
|
|
|
758
763
|
}, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
759
764
|
}
|
|
760
765
|
if (props.children)
|
|
761
|
-
return (0,
|
|
766
|
+
return (0, import_react14.cloneElement)(props.children, { title: props.title });
|
|
762
767
|
return null;
|
|
763
768
|
}
|
|
764
769
|
module.exports = __toCommonJS(src_exports);
|
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) {
|
|
@@ -221,6 +221,7 @@ function useDrawer(init) {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
// src/Form.tsx
|
|
224
|
+
import { faas } from "@faasjs/react";
|
|
224
225
|
import {
|
|
225
226
|
Button as Button2,
|
|
226
227
|
Form as AntdForm2
|
|
@@ -418,28 +419,32 @@ function Form(props) {
|
|
|
418
419
|
const propsCopy = __spreadValues({}, props);
|
|
419
420
|
if (propsCopy.onFinish) {
|
|
420
421
|
propsCopy.onFinish = async (values) => {
|
|
422
|
+
var _a2;
|
|
421
423
|
setLoading(true);
|
|
422
424
|
try {
|
|
423
|
-
|
|
425
|
+
if (propsCopy.submit && ((_a2 = propsCopy.submit.to) == null ? void 0 : _a2.action)) {
|
|
426
|
+
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values2), propsCopy.submit.to.params) : values2));
|
|
427
|
+
} else
|
|
428
|
+
await propsCopy.onFinish(values);
|
|
424
429
|
} catch (error) {
|
|
425
430
|
console.error(error);
|
|
426
431
|
}
|
|
427
432
|
setLoading(false);
|
|
428
433
|
};
|
|
429
434
|
}
|
|
430
|
-
setComputedProps(
|
|
435
|
+
setComputedProps(propsCopy);
|
|
431
436
|
}, []);
|
|
432
437
|
if (!computedProps)
|
|
433
438
|
return null;
|
|
434
|
-
return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), (_a =
|
|
439
|
+
return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), computedProps.beforeItems, (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ React.createElement(FormItem, __spreadProps(__spreadValues({
|
|
435
440
|
key: item.id
|
|
436
441
|
}, item), {
|
|
437
|
-
extendTypes:
|
|
438
|
-
}))),
|
|
442
|
+
extendTypes: computedProps.extendTypes
|
|
443
|
+
}))), computedProps.children, computedProps.submit !== false && /* @__PURE__ */ React.createElement(Button2, {
|
|
439
444
|
htmlType: "submit",
|
|
440
445
|
type: "primary",
|
|
441
446
|
loading
|
|
442
|
-
}, ((_b =
|
|
447
|
+
}, ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text));
|
|
443
448
|
}
|
|
444
449
|
Form.useForm = AntdForm2.useForm;
|
|
445
450
|
Form.Item = FormItem;
|
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.377",
|
|
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.377",
|
|
32
32
|
"react-use": "*",
|
|
33
33
|
"react-router-dom": "*",
|
|
34
34
|
"dayjs": "*"
|