@faasjs/ant-design 0.0.2-beta.373 → 0.0.2-beta.376
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 +18 -11
- package/dist/index.d.ts +49 -7
- package/dist/index.js +37 -30
- package/dist/index.mjs +22 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -158,7 +158,7 @@ ___
|
|
|
158
158
|
|
|
159
159
|
### DescriptionProps
|
|
160
160
|
|
|
161
|
-
Ƭ **DescriptionProps**<`T`, `ExtendItemProps`\>: { `dataSource?`: `T` ; `extendTypes?`: { [key: string]
|
|
161
|
+
Ƭ **DescriptionProps**<`T`, `ExtendItemProps`\>: { `dataSource?`: `T` ; `extendTypes?`: { `[key: string]`: [`ExtendDescriptionTypeProps`](#extenddescriptiontypeprops); } ; `faasData?`: `FaasDataWrapperProps`<`T`\> ; `items`: ([`DescriptionItemProps`](#descriptionitemprops) \| `ExtendItemProps`)[] } & `DescriptionsProps`
|
|
162
162
|
|
|
163
163
|
#### Type parameters
|
|
164
164
|
|
|
@@ -293,7 +293,7 @@ ___
|
|
|
293
293
|
|
|
294
294
|
### FormItemProps
|
|
295
295
|
|
|
296
|
-
Ƭ **FormItemProps**<`T`\>: { `children?`: `JSX.Element` \| ``null`` ; `extendTypes?`: { [type: string]
|
|
296
|
+
Ƭ **FormItemProps**<`T`\>: { `children?`: `JSX.Element` \| ``null`` ; `extendTypes?`: { `[type: string]`: [`ExtendFormTypeProps`](#extendformtypeprops); } ; `label?`: `string` \| ``false`` ; `rules?`: `RuleObject`[] ; `render?`: () => `Element` } & `FormItemInputProps`<`T`\> & [`FaasItemProps`](#faasitemprops) & `AntdFormItemProps`<`T`\>
|
|
297
297
|
|
|
298
298
|
#### Type parameters
|
|
299
299
|
|
|
@@ -305,7 +305,7 @@ ___
|
|
|
305
305
|
|
|
306
306
|
### FormProps
|
|
307
307
|
|
|
308
|
-
Ƭ **FormProps**<`Values`, `ExtendItemProps`\>: { `extendTypes?`: { [type: string]
|
|
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"``\>
|
|
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
|
|
|
@@ -350,7 +350,7 @@ ___
|
|
|
350
350
|
|
|
351
351
|
### TableProps
|
|
352
352
|
|
|
353
|
-
Ƭ **TableProps**<`T`, `ExtendTypes`\>: { `extendTypes?`: { [key: string]
|
|
353
|
+
Ƭ **TableProps**<`T`, `ExtendTypes`\>: { `extendTypes?`: { `[key: string]`: [`ExtendTableTypeProps`](#extendtabletypeprops); } ; `faasData?`: `FaasDataWrapperProps`<`T`\> ; `items`: ([`TableItemProps`](#tableitemprops) \| `ExtendTypes` & [`ExtendTableItemProps`](#extendtableitemprops))[] ; `onChange?`: (`pagination`: `TablePaginationConfig`, `filters`: `Record`<`string`, `FilterValue`\>, `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[], `extra`: `TableCurrentDataSource`<`T`\>) => { `extra`: `TableCurrentDataSource`<`T`\> ; `filters`: `Record`<`string`, `FilterValue` \| ``null``\> ; `pagination`: `TablePaginationConfig` ; `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[] } } & `AntdTableProps`<`T`\>
|
|
354
354
|
|
|
355
355
|
#### Type parameters
|
|
356
356
|
|
|
@@ -375,7 +375,8 @@ ___
|
|
|
375
375
|
|
|
376
376
|
| Name | Type | Description |
|
|
377
377
|
| :------ | :------ | :------ |
|
|
378
|
-
| `
|
|
378
|
+
| `children?` | `JSX.Element` | return children |
|
|
379
|
+
| `h1?` | `boolean` \| { `className?`: `string` ; `style?`: `React.CSSProperties` } | return a h1 element |
|
|
379
380
|
| `separator?` | `string` | ` - ` as default |
|
|
380
381
|
| `suffix?` | `string` | - |
|
|
381
382
|
| `title` | `string` \| `string`[] | - |
|
|
@@ -621,13 +622,19 @@ ___
|
|
|
621
622
|
▸ **Title**(`props`): `JSX.Element`
|
|
622
623
|
|
|
623
624
|
Title is used to change the title of the page.
|
|
625
|
+
Return null by default.
|
|
624
626
|
|
|
625
627
|
```ts
|
|
626
|
-
|
|
627
|
-
<Title title=
|
|
628
|
+
// return null
|
|
629
|
+
<Title title='hi' /> // => change the document.title to 'hi'
|
|
630
|
+
<Title title={['a', 'b']} /> // => change the document.title to 'a - b'
|
|
628
631
|
|
|
629
|
-
|
|
630
|
-
<Title title=
|
|
632
|
+
// return h1
|
|
633
|
+
<Title title='hi' h1 /> // => <h1>hi</h1>
|
|
634
|
+
<Title title={['a', 'b']} h1 /> // => <h1>a</h1>
|
|
635
|
+
|
|
636
|
+
// return children
|
|
637
|
+
<Title title='hi'><CustomTitle /></Title> // => <CustomTitle />
|
|
631
638
|
```
|
|
632
639
|
|
|
633
640
|
#### Parameters
|
|
@@ -702,7 +709,7 @@ Hook style modal.
|
|
|
702
709
|
|
|
703
710
|
| Name | Type | Description |
|
|
704
711
|
| :------ | :------ | :------ |
|
|
705
|
-
| `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}</> } ``` |
|
|
706
713
|
|
|
707
714
|
#### Returns
|
|
708
715
|
|
package/dist/index.d.ts
CHANGED
|
@@ -231,11 +231,42 @@ 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>;
|
|
235
266
|
extendTypes?: {
|
|
236
267
|
[type: string]: ExtendFormTypeProps;
|
|
237
268
|
};
|
|
238
|
-
} & FormProps$1<Values>;
|
|
269
|
+
} & Omit<FormProps$1<Values>, 'onFinish'>;
|
|
239
270
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
240
271
|
declare namespace Form {
|
|
241
272
|
var useForm: typeof antd_lib_form_Form.useForm;
|
|
@@ -243,7 +274,7 @@ declare namespace Form {
|
|
|
243
274
|
}
|
|
244
275
|
|
|
245
276
|
declare type ModalProps = ModalProps$1 & {
|
|
246
|
-
children?: JSX.Element | JSX.Element[];
|
|
277
|
+
children?: JSX.Element | JSX.Element[] | string;
|
|
247
278
|
};
|
|
248
279
|
declare type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
249
280
|
/**
|
|
@@ -254,7 +285,9 @@ declare type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
|
254
285
|
* function Example() {
|
|
255
286
|
* const { modal, setModalProps } = useModal()
|
|
256
287
|
*
|
|
257
|
-
* return <>
|
|
288
|
+
* return <>
|
|
289
|
+
* <Button onClick={() => setModalProps({ visible: true })}>Open Modal</Button>
|
|
290
|
+
* {modal}</>
|
|
258
291
|
* }
|
|
259
292
|
* ```
|
|
260
293
|
*/
|
|
@@ -305,20 +338,29 @@ declare type TitleProps = {
|
|
|
305
338
|
/** ` - ` as default */
|
|
306
339
|
separator?: string;
|
|
307
340
|
suffix?: string;
|
|
341
|
+
/** return a h1 element */
|
|
308
342
|
h1?: boolean | {
|
|
309
343
|
className?: string;
|
|
310
344
|
style?: React.CSSProperties;
|
|
311
345
|
};
|
|
346
|
+
/** return children */
|
|
347
|
+
children?: JSX.Element;
|
|
312
348
|
};
|
|
313
349
|
/**
|
|
314
350
|
* Title is used to change the title of the page.
|
|
351
|
+
* Return null by default.
|
|
315
352
|
*
|
|
316
353
|
* ```ts
|
|
317
|
-
*
|
|
318
|
-
* <Title title=
|
|
354
|
+
* // return null
|
|
355
|
+
* <Title title='hi' /> // => change the document.title to 'hi'
|
|
356
|
+
* <Title title={['a', 'b']} /> // => change the document.title to 'a - b'
|
|
357
|
+
*
|
|
358
|
+
* // return h1
|
|
359
|
+
* <Title title='hi' h1 /> // => <h1>hi</h1>
|
|
360
|
+
* <Title title={['a', 'b']} h1 /> // => <h1>a</h1>
|
|
319
361
|
*
|
|
320
|
-
*
|
|
321
|
-
* <Title title=
|
|
362
|
+
* // return children
|
|
363
|
+
* <Title title='hi'><CustomTitle /></Title> // => <CustomTitle />
|
|
322
364
|
* ```
|
|
323
365
|
*/
|
|
324
366
|
declare function Title(props: TitleProps): JSX.Element;
|
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), (_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
|
}, []);
|
|
@@ -757,6 +762,8 @@ function Title(props) {
|
|
|
757
762
|
style: props.h1.style
|
|
758
763
|
}, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
759
764
|
}
|
|
765
|
+
if (props.children)
|
|
766
|
+
return (0, import_react14.cloneElement)(props.children, { title: props.title });
|
|
760
767
|
return null;
|
|
761
768
|
}
|
|
762
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), (_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;
|
|
@@ -727,7 +732,7 @@ function Table(props) {
|
|
|
727
732
|
}
|
|
728
733
|
|
|
729
734
|
// src/Title.tsx
|
|
730
|
-
import { useEffect as useEffect6 } from "react";
|
|
735
|
+
import { useEffect as useEffect6, cloneElement as cloneElement3 } from "react";
|
|
731
736
|
function Title(props) {
|
|
732
737
|
const [config] = useFaasState();
|
|
733
738
|
useEffect6(() => {
|
|
@@ -742,6 +747,8 @@ function Title(props) {
|
|
|
742
747
|
style: props.h1.style
|
|
743
748
|
}, Array.isArray(props.title) ? props.title[0] : props.title);
|
|
744
749
|
}
|
|
750
|
+
if (props.children)
|
|
751
|
+
return cloneElement3(props.children, { title: props.title });
|
|
745
752
|
return null;
|
|
746
753
|
}
|
|
747
754
|
export {
|
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.376",
|
|
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.376",
|
|
32
32
|
"react-use": "*",
|
|
33
33
|
"react-router-dom": "*",
|
|
34
34
|
"dayjs": "*"
|