@faasjs/ant-design 2.6.0 → 2.6.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/README.md +1 -1
- package/dist/index.d.mts +53 -6
- package/dist/index.d.ts +53 -6
- package/dist/index.js +25 -22
- package/dist/index.mjs +26 -23
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ type FaasItemProps = {
|
|
|
42
42
|
- [DrawerProps](interfaces/DrawerProps.md)
|
|
43
43
|
- [ErrorBoundaryProps](interfaces/ErrorBoundaryProps.md)
|
|
44
44
|
- [ExtendDescriptionTypeProps](interfaces/ExtendDescriptionTypeProps.md)
|
|
45
|
+
- [ExtendFormItemProps](interfaces/ExtendFormItemProps.md)
|
|
45
46
|
- [FaasDataWrapperProps](interfaces/FaasDataWrapperProps.md)
|
|
46
47
|
- [FaasItemProps](interfaces/FaasItemProps.md)
|
|
47
48
|
- [FormItemProps](interfaces/FormItemProps.md)
|
|
@@ -60,7 +61,6 @@ type FaasItemProps = {
|
|
|
60
61
|
|
|
61
62
|
- [BaseOption](type-aliases/BaseOption.md)
|
|
62
63
|
- [ExtendDescriptionItemProps](type-aliases/ExtendDescriptionItemProps.md)
|
|
63
|
-
- [ExtendFormItemProps](type-aliases/ExtendFormItemProps.md)
|
|
64
64
|
- [ExtendFormTypeProps](type-aliases/ExtendFormTypeProps.md)
|
|
65
65
|
- [ExtendTableItemProps](type-aliases/ExtendTableItemProps.md)
|
|
66
66
|
- [ExtendTableTypeProps](type-aliases/ExtendTableTypeProps.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ import * as antd_es_modal_confirm from 'antd/es/modal/confirm';
|
|
|
11
11
|
import * as react from 'react';
|
|
12
12
|
import { Dispatch, SetStateAction, CSSProperties, ReactNode, ReactElement, LazyExoticComponent, ComponentType } from 'react';
|
|
13
13
|
export { lazy } from 'react';
|
|
14
|
-
import { ModalProps as ModalProps$1, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps,
|
|
14
|
+
import { ModalProps as ModalProps$1, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, FormInstance, InputProps, SelectProps, RadioProps, InputNumberProps, SwitchProps, DatePickerProps, DescriptionsProps, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, FormProps as FormProps$1, ButtonProps, TabsProps as TabsProps$1 } from 'antd';
|
|
15
15
|
import { BrowserRouterProps, RouteProps } from 'react-router-dom';
|
|
16
16
|
import { Dayjs } from 'dayjs';
|
|
17
17
|
import * as antd_es_form_FormItem from 'antd/es/form/FormItem';
|
|
@@ -234,9 +234,20 @@ type ExtendFormTypeProps<T = any> = {
|
|
|
234
234
|
type ExtendTypes = {
|
|
235
235
|
[type: string]: ExtendFormTypeProps;
|
|
236
236
|
};
|
|
237
|
-
type
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
type InputTypeMap<T> = {
|
|
238
|
+
string: InputProps | SelectProps<T> | RadioProps;
|
|
239
|
+
'string[]': InputProps | SelectProps<T> | RadioProps;
|
|
240
|
+
number: InputNumberProps | SelectProps<T> | RadioProps;
|
|
241
|
+
'number[]': InputNumberProps | SelectProps<T> | RadioProps;
|
|
242
|
+
boolean: SwitchProps;
|
|
243
|
+
date: DatePickerProps;
|
|
244
|
+
time: DatePickerProps;
|
|
245
|
+
object: never;
|
|
246
|
+
'object[]': never;
|
|
247
|
+
};
|
|
248
|
+
interface FormItemProps<T = any> extends BaseItemProps, Omit<FormItemProps$1<T>, 'id' | 'children' | 'render'> {
|
|
249
|
+
type?: FaasItemType;
|
|
250
|
+
input?: InputTypeMap<T>[FaasItemType];
|
|
240
251
|
maxCount?: number;
|
|
241
252
|
object?: FormItemProps[];
|
|
242
253
|
disabled?: boolean;
|
|
@@ -254,6 +265,42 @@ interface FormItemProps<T = any> extends FaasItemProps, Omit<FormItemProps$1<T>,
|
|
|
254
265
|
/** trigger when any item's value changed */
|
|
255
266
|
if?: (values: Record<string, any>) => boolean;
|
|
256
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Extend custom form item types.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* import type { ExtendFormItemProps, FormProps } from '@faasjs/ant-design'
|
|
274
|
+
*
|
|
275
|
+
* // define custom type
|
|
276
|
+
* interface ExtendTypes extends ExtendFormItemProps {
|
|
277
|
+
* type: 'password'
|
|
278
|
+
* }
|
|
279
|
+
*
|
|
280
|
+
* // extend form
|
|
281
|
+
* function ExtendForm(props: FormProps<any, ExtendTypes>) {
|
|
282
|
+
* return (
|
|
283
|
+
* <Form
|
|
284
|
+
* {...props}
|
|
285
|
+
* extendTypes={{ password: { children: <Input.Password /> } }}
|
|
286
|
+
* />
|
|
287
|
+
* )
|
|
288
|
+
* }
|
|
289
|
+
*
|
|
290
|
+
* // use custom type
|
|
291
|
+
* <ExtendForm
|
|
292
|
+
* items={[
|
|
293
|
+
* {
|
|
294
|
+
* id: 'test',
|
|
295
|
+
* type: 'password',
|
|
296
|
+
* },
|
|
297
|
+
* ]}
|
|
298
|
+
* />
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
interface ExtendFormItemProps extends Omit<FormItemProps, 'type'> {
|
|
302
|
+
type?: string;
|
|
303
|
+
}
|
|
257
304
|
/**
|
|
258
305
|
* FormItem
|
|
259
306
|
*
|
|
@@ -515,8 +562,8 @@ type FormSubmitProps = {
|
|
|
515
562
|
finally?: () => void;
|
|
516
563
|
};
|
|
517
564
|
};
|
|
518
|
-
interface FormProps<Values extends Record<string, any> = any, ExtendItemProps =
|
|
519
|
-
items?: (
|
|
565
|
+
interface FormProps<Values extends Record<string, any> = any, ExtendItemProps extends ExtendFormItemProps = ExtendFormItemProps> extends Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> {
|
|
566
|
+
items?: ((ExtendItemProps extends ExtendFormItemProps ? ExtendItemProps | FormItemProps : FormItemProps) | JSX.Element)[];
|
|
520
567
|
/** Default: { text: 'Submit' }, set false to disable it */
|
|
521
568
|
submit?: false | FormSubmitProps;
|
|
522
569
|
onFinish?: (values: Values, submit?: (values: any) => Promise<any>) => Promise<any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import * as antd_es_modal_confirm from 'antd/es/modal/confirm';
|
|
|
11
11
|
import * as react from 'react';
|
|
12
12
|
import { Dispatch, SetStateAction, CSSProperties, ReactNode, ReactElement, LazyExoticComponent, ComponentType } from 'react';
|
|
13
13
|
export { lazy } from 'react';
|
|
14
|
-
import { ModalProps as ModalProps$1, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps,
|
|
14
|
+
import { ModalProps as ModalProps$1, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, FormInstance, InputProps, SelectProps, RadioProps, InputNumberProps, SwitchProps, DatePickerProps, DescriptionsProps, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, FormProps as FormProps$1, ButtonProps, TabsProps as TabsProps$1 } from 'antd';
|
|
15
15
|
import { BrowserRouterProps, RouteProps } from 'react-router-dom';
|
|
16
16
|
import { Dayjs } from 'dayjs';
|
|
17
17
|
import * as antd_es_form_FormItem from 'antd/es/form/FormItem';
|
|
@@ -234,9 +234,20 @@ type ExtendFormTypeProps<T = any> = {
|
|
|
234
234
|
type ExtendTypes = {
|
|
235
235
|
[type: string]: ExtendFormTypeProps;
|
|
236
236
|
};
|
|
237
|
-
type
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
type InputTypeMap<T> = {
|
|
238
|
+
string: InputProps | SelectProps<T> | RadioProps;
|
|
239
|
+
'string[]': InputProps | SelectProps<T> | RadioProps;
|
|
240
|
+
number: InputNumberProps | SelectProps<T> | RadioProps;
|
|
241
|
+
'number[]': InputNumberProps | SelectProps<T> | RadioProps;
|
|
242
|
+
boolean: SwitchProps;
|
|
243
|
+
date: DatePickerProps;
|
|
244
|
+
time: DatePickerProps;
|
|
245
|
+
object: never;
|
|
246
|
+
'object[]': never;
|
|
247
|
+
};
|
|
248
|
+
interface FormItemProps<T = any> extends BaseItemProps, Omit<FormItemProps$1<T>, 'id' | 'children' | 'render'> {
|
|
249
|
+
type?: FaasItemType;
|
|
250
|
+
input?: InputTypeMap<T>[FaasItemType];
|
|
240
251
|
maxCount?: number;
|
|
241
252
|
object?: FormItemProps[];
|
|
242
253
|
disabled?: boolean;
|
|
@@ -254,6 +265,42 @@ interface FormItemProps<T = any> extends FaasItemProps, Omit<FormItemProps$1<T>,
|
|
|
254
265
|
/** trigger when any item's value changed */
|
|
255
266
|
if?: (values: Record<string, any>) => boolean;
|
|
256
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Extend custom form item types.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* import type { ExtendFormItemProps, FormProps } from '@faasjs/ant-design'
|
|
274
|
+
*
|
|
275
|
+
* // define custom type
|
|
276
|
+
* interface ExtendTypes extends ExtendFormItemProps {
|
|
277
|
+
* type: 'password'
|
|
278
|
+
* }
|
|
279
|
+
*
|
|
280
|
+
* // extend form
|
|
281
|
+
* function ExtendForm(props: FormProps<any, ExtendTypes>) {
|
|
282
|
+
* return (
|
|
283
|
+
* <Form
|
|
284
|
+
* {...props}
|
|
285
|
+
* extendTypes={{ password: { children: <Input.Password /> } }}
|
|
286
|
+
* />
|
|
287
|
+
* )
|
|
288
|
+
* }
|
|
289
|
+
*
|
|
290
|
+
* // use custom type
|
|
291
|
+
* <ExtendForm
|
|
292
|
+
* items={[
|
|
293
|
+
* {
|
|
294
|
+
* id: 'test',
|
|
295
|
+
* type: 'password',
|
|
296
|
+
* },
|
|
297
|
+
* ]}
|
|
298
|
+
* />
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
interface ExtendFormItemProps extends Omit<FormItemProps, 'type'> {
|
|
302
|
+
type?: string;
|
|
303
|
+
}
|
|
257
304
|
/**
|
|
258
305
|
* FormItem
|
|
259
306
|
*
|
|
@@ -515,8 +562,8 @@ type FormSubmitProps = {
|
|
|
515
562
|
finally?: () => void;
|
|
516
563
|
};
|
|
517
564
|
};
|
|
518
|
-
interface FormProps<Values extends Record<string, any> = any, ExtendItemProps =
|
|
519
|
-
items?: (
|
|
565
|
+
interface FormProps<Values extends Record<string, any> = any, ExtendItemProps extends ExtendFormItemProps = ExtendFormItemProps> extends Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> {
|
|
566
|
+
items?: ((ExtendItemProps extends ExtendFormItemProps ? ExtendItemProps | FormItemProps : FormItemProps) | JSX.Element)[];
|
|
520
567
|
/** Default: { text: 'Submit' }, set false to disable it */
|
|
521
568
|
submit?: false | FormSubmitProps;
|
|
522
569
|
onFinish?: (values: Values, submit?: (values: any) => Promise<any>) => Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -449,6 +449,9 @@ function Description(props) {
|
|
|
449
449
|
);
|
|
450
450
|
}
|
|
451
451
|
Description.whyDidYouRender = true;
|
|
452
|
+
function isOptionsProps(item) {
|
|
453
|
+
return item && Array.isArray(item.options);
|
|
454
|
+
}
|
|
452
455
|
function processProps(propsCopy, config) {
|
|
453
456
|
if (!propsCopy.title) propsCopy.title = lodashEs.upperFirst(propsCopy.id);
|
|
454
457
|
if (!propsCopy.label && propsCopy.label !== false)
|
|
@@ -474,10 +477,8 @@ function processProps(propsCopy, config) {
|
|
|
474
477
|
});
|
|
475
478
|
}
|
|
476
479
|
if (!propsCopy.input) propsCopy.input = {};
|
|
477
|
-
if (propsCopy
|
|
478
|
-
propsCopy.input.options = transferOptions(
|
|
479
|
-
propsCopy.options
|
|
480
|
-
);
|
|
480
|
+
if (isOptionsProps(propsCopy))
|
|
481
|
+
propsCopy.input.options = transferOptions(propsCopy.options);
|
|
481
482
|
switch (propsCopy.type) {
|
|
482
483
|
case "boolean":
|
|
483
484
|
propsCopy.valuePropName = "checked";
|
|
@@ -485,8 +486,7 @@ function processProps(propsCopy, config) {
|
|
|
485
486
|
case "object":
|
|
486
487
|
if (!Array.isArray(propsCopy.name)) propsCopy.name = [propsCopy.name];
|
|
487
488
|
for (const sub of propsCopy.object) {
|
|
488
|
-
if (!sub.name)
|
|
489
|
-
sub.name = propsCopy.name.concat(sub.id);
|
|
489
|
+
if (!sub.name) sub.name = propsCopy.name.concat(sub.id);
|
|
490
490
|
processProps(sub, config);
|
|
491
491
|
}
|
|
492
492
|
break;
|
|
@@ -537,11 +537,11 @@ function FormItem(props) {
|
|
|
537
537
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: computedProps.render(null, null, 0, "form") });
|
|
538
538
|
switch (computedProps.type) {
|
|
539
539
|
case "string":
|
|
540
|
-
if (computedProps
|
|
540
|
+
if (isOptionsProps(computedProps))
|
|
541
541
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: computedProps.options.length > 10 ? /* @__PURE__ */ jsxRuntime.jsx(antd.Select, { ...computedProps.input }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Group, { ...computedProps.input }) });
|
|
542
542
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { ...computedProps.input }) });
|
|
543
543
|
case "string[]":
|
|
544
|
-
if (computedProps
|
|
544
|
+
if (isOptionsProps(computedProps))
|
|
545
545
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Select, { mode: "multiple", ...computedProps.input }) });
|
|
546
546
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
547
547
|
antd.Form.List,
|
|
@@ -733,6 +733,9 @@ function FormItem(props) {
|
|
|
733
733
|
}
|
|
734
734
|
FormItem.whyDidYouRender = true;
|
|
735
735
|
FormItem.useStatus = antd.Form.Item.useStatus;
|
|
736
|
+
function isFormItemProps(item) {
|
|
737
|
+
return item.id !== void 0;
|
|
738
|
+
}
|
|
736
739
|
function Form(props) {
|
|
737
740
|
var _a, _b;
|
|
738
741
|
const [loading, setLoading] = react$1.useState(false);
|
|
@@ -752,14 +755,17 @@ function Form(props) {
|
|
|
752
755
|
if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
|
|
753
756
|
for (const key in propsCopy.initialValues) {
|
|
754
757
|
propsCopy.initialValues[key] = transferValue(
|
|
755
|
-
(_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
|
|
758
|
+
(_b2 = propsCopy.items.find((item2) => isFormItemProps(item2) && item2.id === key)) == null ? void 0 : _b2.type,
|
|
756
759
|
propsCopy.initialValues[key]
|
|
757
760
|
);
|
|
758
|
-
const item = propsCopy.items.find(
|
|
761
|
+
const item = propsCopy.items.find(
|
|
762
|
+
(item2) => isFormItemProps(item2) && item2.id === key
|
|
763
|
+
);
|
|
759
764
|
if (item == null ? void 0 : item.if) item.hidden = !item.if(propsCopy.initialValues);
|
|
760
765
|
}
|
|
761
766
|
for (const item of propsCopy.items) {
|
|
762
|
-
if (item
|
|
767
|
+
if (isFormItemProps(item) && item.if)
|
|
768
|
+
item.hidden = !item.if(propsCopy.initialValues);
|
|
763
769
|
}
|
|
764
770
|
setInitialValues(propsCopy.initialValues);
|
|
765
771
|
delete propsCopy.initialValues;
|
|
@@ -824,7 +830,9 @@ function Form(props) {
|
|
|
824
830
|
}
|
|
825
831
|
if (!props.items) return;
|
|
826
832
|
for (const key in changedValues) {
|
|
827
|
-
const item = computedProps.items.find(
|
|
833
|
+
const item = computedProps.items.find(
|
|
834
|
+
(i) => isFormItemProps(i) && i.id === key
|
|
835
|
+
);
|
|
828
836
|
if (item == null ? void 0 : item.onValueChange)
|
|
829
837
|
item.onValueChange(changedValues[key], allValues, form);
|
|
830
838
|
}
|
|
@@ -840,16 +848,11 @@ function Form(props) {
|
|
|
840
848
|
if (!computedProps) return null;
|
|
841
849
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Form, { ...computedProps, onValuesChange, children: [
|
|
842
850
|
computedProps.beforeItems,
|
|
843
|
-
(_a = computedProps.items) == null ? void 0 : _a.map(
|
|
844
|
-
|
|
845
|
-
FormItem,
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
extendTypes
|
|
849
|
-
},
|
|
850
|
-
item.id
|
|
851
|
-
)
|
|
852
|
-
),
|
|
851
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => {
|
|
852
|
+
if (isFormItemProps(item))
|
|
853
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormItem, { ...item, extendTypes }, item.id);
|
|
854
|
+
return item;
|
|
855
|
+
}),
|
|
853
856
|
computedProps.children,
|
|
854
857
|
computedProps.submit !== false && /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.theme.Form.submit.text }),
|
|
855
858
|
computedProps.footer
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createSplitedContext, ErrorBoundary as ErrorBoundary$1, FaasReactClient
|
|
|
2
2
|
export { faas, useFaas } from '@faasjs/react';
|
|
3
3
|
import { Form as Form$1, Modal as Modal$1, Drawer as Drawer$1, message, notification, ConfigProvider as ConfigProvider$1, Typography, Spin, Descriptions, Input, Button, Row, Col, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1, Alert, Space } from 'antd';
|
|
4
4
|
import { legacyLogicalPropertiesTransformer, StyleProvider } from '@ant-design/cssinjs';
|
|
5
|
-
import { createContext, useState, useCallback, useEffect, useContext, useMemo, cloneElement,
|
|
5
|
+
import { createContext, useState, useCallback, useEffect, useContext, useMemo, cloneElement, Suspense } from 'react';
|
|
6
6
|
export { lazy } from 'react';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import { BrowserRouter, useNavigate, Link as Link$1, Routes as Routes$1, Route, useLocation } from 'react-router-dom';
|
|
@@ -445,6 +445,9 @@ function Description(props) {
|
|
|
445
445
|
);
|
|
446
446
|
}
|
|
447
447
|
Description.whyDidYouRender = true;
|
|
448
|
+
function isOptionsProps(item) {
|
|
449
|
+
return item && Array.isArray(item.options);
|
|
450
|
+
}
|
|
448
451
|
function processProps(propsCopy, config) {
|
|
449
452
|
if (!propsCopy.title) propsCopy.title = upperFirst(propsCopy.id);
|
|
450
453
|
if (!propsCopy.label && propsCopy.label !== false)
|
|
@@ -470,10 +473,8 @@ function processProps(propsCopy, config) {
|
|
|
470
473
|
});
|
|
471
474
|
}
|
|
472
475
|
if (!propsCopy.input) propsCopy.input = {};
|
|
473
|
-
if (propsCopy
|
|
474
|
-
propsCopy.input.options = transferOptions(
|
|
475
|
-
propsCopy.options
|
|
476
|
-
);
|
|
476
|
+
if (isOptionsProps(propsCopy))
|
|
477
|
+
propsCopy.input.options = transferOptions(propsCopy.options);
|
|
477
478
|
switch (propsCopy.type) {
|
|
478
479
|
case "boolean":
|
|
479
480
|
propsCopy.valuePropName = "checked";
|
|
@@ -481,8 +482,7 @@ function processProps(propsCopy, config) {
|
|
|
481
482
|
case "object":
|
|
482
483
|
if (!Array.isArray(propsCopy.name)) propsCopy.name = [propsCopy.name];
|
|
483
484
|
for (const sub of propsCopy.object) {
|
|
484
|
-
if (!sub.name)
|
|
485
|
-
sub.name = propsCopy.name.concat(sub.id);
|
|
485
|
+
if (!sub.name) sub.name = propsCopy.name.concat(sub.id);
|
|
486
486
|
processProps(sub, config);
|
|
487
487
|
}
|
|
488
488
|
break;
|
|
@@ -533,11 +533,11 @@ function FormItem(props) {
|
|
|
533
533
|
return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, children: computedProps.render(null, null, 0, "form") });
|
|
534
534
|
switch (computedProps.type) {
|
|
535
535
|
case "string":
|
|
536
|
-
if (computedProps
|
|
536
|
+
if (isOptionsProps(computedProps))
|
|
537
537
|
return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, children: computedProps.options.length > 10 ? /* @__PURE__ */ jsx(Select, { ...computedProps.input }) : /* @__PURE__ */ jsx(Radio.Group, { ...computedProps.input }) });
|
|
538
538
|
return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, children: /* @__PURE__ */ jsx(Input, { ...computedProps.input }) });
|
|
539
539
|
case "string[]":
|
|
540
|
-
if (computedProps
|
|
540
|
+
if (isOptionsProps(computedProps))
|
|
541
541
|
return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, children: /* @__PURE__ */ jsx(Select, { mode: "multiple", ...computedProps.input }) });
|
|
542
542
|
return /* @__PURE__ */ jsx(
|
|
543
543
|
Form$1.List,
|
|
@@ -729,6 +729,9 @@ function FormItem(props) {
|
|
|
729
729
|
}
|
|
730
730
|
FormItem.whyDidYouRender = true;
|
|
731
731
|
FormItem.useStatus = Form$1.Item.useStatus;
|
|
732
|
+
function isFormItemProps(item) {
|
|
733
|
+
return item.id !== void 0;
|
|
734
|
+
}
|
|
732
735
|
function Form(props) {
|
|
733
736
|
var _a, _b;
|
|
734
737
|
const [loading, setLoading] = useState(false);
|
|
@@ -748,14 +751,17 @@ function Form(props) {
|
|
|
748
751
|
if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
|
|
749
752
|
for (const key in propsCopy.initialValues) {
|
|
750
753
|
propsCopy.initialValues[key] = transferValue(
|
|
751
|
-
(_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
|
|
754
|
+
(_b2 = propsCopy.items.find((item2) => isFormItemProps(item2) && item2.id === key)) == null ? void 0 : _b2.type,
|
|
752
755
|
propsCopy.initialValues[key]
|
|
753
756
|
);
|
|
754
|
-
const item = propsCopy.items.find(
|
|
757
|
+
const item = propsCopy.items.find(
|
|
758
|
+
(item2) => isFormItemProps(item2) && item2.id === key
|
|
759
|
+
);
|
|
755
760
|
if (item == null ? void 0 : item.if) item.hidden = !item.if(propsCopy.initialValues);
|
|
756
761
|
}
|
|
757
762
|
for (const item of propsCopy.items) {
|
|
758
|
-
if (item
|
|
763
|
+
if (isFormItemProps(item) && item.if)
|
|
764
|
+
item.hidden = !item.if(propsCopy.initialValues);
|
|
759
765
|
}
|
|
760
766
|
setInitialValues(propsCopy.initialValues);
|
|
761
767
|
delete propsCopy.initialValues;
|
|
@@ -820,7 +826,9 @@ function Form(props) {
|
|
|
820
826
|
}
|
|
821
827
|
if (!props.items) return;
|
|
822
828
|
for (const key in changedValues) {
|
|
823
|
-
const item = computedProps.items.find(
|
|
829
|
+
const item = computedProps.items.find(
|
|
830
|
+
(i) => isFormItemProps(i) && i.id === key
|
|
831
|
+
);
|
|
824
832
|
if (item == null ? void 0 : item.onValueChange)
|
|
825
833
|
item.onValueChange(changedValues[key], allValues, form);
|
|
826
834
|
}
|
|
@@ -836,16 +844,11 @@ function Form(props) {
|
|
|
836
844
|
if (!computedProps) return null;
|
|
837
845
|
return /* @__PURE__ */ jsxs(Form$1, { ...computedProps, onValuesChange, children: [
|
|
838
846
|
computedProps.beforeItems,
|
|
839
|
-
(_a = computedProps.items) == null ? void 0 : _a.map(
|
|
840
|
-
|
|
841
|
-
FormItem,
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
extendTypes
|
|
845
|
-
},
|
|
846
|
-
item.id
|
|
847
|
-
)
|
|
848
|
-
),
|
|
847
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => {
|
|
848
|
+
if (isFormItemProps(item))
|
|
849
|
+
return /* @__PURE__ */ jsx(FormItem, { ...item, extendTypes }, item.id);
|
|
850
|
+
return item;
|
|
851
|
+
}),
|
|
849
852
|
computedProps.children,
|
|
850
853
|
computedProps.submit !== false && /* @__PURE__ */ jsx(Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.theme.Form.submit.text }),
|
|
851
854
|
computedProps.footer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"lodash-es": "*"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@faasjs/react": "2.6.
|
|
41
|
+
"@faasjs/react": "2.6.1",
|
|
42
42
|
"antd": "*",
|
|
43
43
|
"react": "*",
|
|
44
44
|
"react-dom": "*",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@testing-library/react": "*",
|
|
51
51
|
"@testing-library/user-event": "*",
|
|
52
52
|
"@welldone-software/why-did-you-render": "*",
|
|
53
|
-
"@faasjs/react": "2.6.
|
|
53
|
+
"@faasjs/react": "2.6.1",
|
|
54
54
|
"antd": "*",
|
|
55
55
|
"react": "*",
|
|
56
56
|
"react-dom": "*",
|