@faasjs/ant-design 0.0.2-beta.445 → 0.0.2-beta.447
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 +23 -5
- package/dist/index.js +34 -35
- package/dist/index.mjs +36 -36
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -96,6 +96,7 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
|
|
|
96
96
|
- [TimePicker](#timepicker)
|
|
97
97
|
- [Title](#title)
|
|
98
98
|
- [transferOptions](#transferoptions)
|
|
99
|
+
- [transferValue](#transfervalue)
|
|
99
100
|
- [useConfigContext](#useconfigcontext)
|
|
100
101
|
- [useDrawer](#usedrawer)
|
|
101
102
|
- [useModal](#usemodal)
|
|
@@ -183,7 +184,7 @@ ___
|
|
|
183
184
|
|
|
184
185
|
### DescriptionItemProps
|
|
185
186
|
|
|
186
|
-
Ƭ **DescriptionItemProps**<`T`\>: { `children?`: `JSX.Element` ; `render?`: (`value`: `T`, `values`: `any`) => `ReactNode` \| `JSX.Element` } & [`FaasItemProps`](#faasitemprops) & { `object?`: [`DescriptionItemProps`](#descriptionitemprops)[] }
|
|
187
|
+
Ƭ **DescriptionItemProps**<`T`\>: { `children?`: `JSX.Element` ; `if?`: (`values`: `Record`<`string`, `any`\>) => `boolean` ; `render?`: (`value`: `T`, `values`: `any`) => `ReactNode` \| `JSX.Element` } & [`FaasItemProps`](#faasitemprops) & { `object?`: [`DescriptionItemProps`](#descriptionitemprops)[] }
|
|
187
188
|
|
|
188
189
|
#### Type parameters
|
|
189
190
|
|
|
@@ -320,7 +321,7 @@ ___
|
|
|
320
321
|
|
|
321
322
|
### FormItemProps
|
|
322
323
|
|
|
323
|
-
Ƭ **FormItemProps**<`T`\>: { `children?`: `ReactNode` ; `extendTypes?`: [`ExtendTypes`](#extendtypes) ; `label?`: `string` \| ``false`` ; `render?`: (`value?`: `
|
|
324
|
+
Ƭ **FormItemProps**<`T`\>: { `children?`: `ReactNode` ; `extendTypes?`: [`ExtendTypes`](#extendtypes) ; `if?`: (`values`: `Record`<`string`, `any`\>) => `boolean` ; `label?`: `string` \| ``false`` ; `onValueChange?`: (`value`: `T`, `values`: `any`, `form`: `FormInstance`) => `void` ; `render?`: (`value?`: `T`) => `ReactNode` \| `JSX.Element` ; `rules?`: `RuleObject`[] } & `FormItemInputProps` & [`FaasItemProps`](#faasitemprops) & `Omit`<`AntdFormItemProps`<`T`\>, ``"children"``\>
|
|
324
325
|
|
|
325
326
|
#### Type parameters
|
|
326
327
|
|
|
@@ -332,13 +333,13 @@ ___
|
|
|
332
333
|
|
|
333
334
|
### FormProps
|
|
334
335
|
|
|
335
|
-
Ƭ **FormProps**<`Values`, `ExtendItemProps`\>: { `beforeItems?`: `JSX.Element` \| `JSX.Element`[] ; `children?`: `ReactNode` ; `extendTypes?`: [`ExtendTypes`](#extendtypes) ; `footer?`: `JSX.Element` \| `JSX.Element`[] ; `items?`: ([`FormItemProps`](#formitemprops) \| `ExtendItemProps`)[] ; `onFinish?`: (`values`: `Values`, `submit?`: (`values`: `any`) => `Promise`<`any`\>) => `Promise`<`any`\> ; `submit?`: ``false`` \| { `text?`: `string` ; `to?`: { `action`: `string` ; `params?`: `Record`<`string`, `any`\> } } } & `Omit`<`AntdFormProps`<`Values`\>, ``"onFinish"`` \| ``"children"``\>
|
|
336
|
+
Ƭ **FormProps**<`Values`, `ExtendItemProps`\>: { `beforeItems?`: `JSX.Element` \| `JSX.Element`[] ; `children?`: `ReactNode` ; `extendTypes?`: [`ExtendTypes`](#extendtypes) ; `footer?`: `JSX.Element` \| `JSX.Element`[] ; `initialValues?`: `Values` ; `items?`: ([`FormItemProps`](#formitemprops) \| `ExtendItemProps`)[] ; `onFinish?`: (`values`: `Values`, `submit?`: (`values`: `any`) => `Promise`<`any`\>) => `Promise`<`any`\> ; `submit?`: ``false`` \| { `text?`: `string` ; `to?`: { `action`: `string` ; `params?`: `Record`<`string`, `any`\> } } } & `Omit`<`AntdFormProps`<`Values`\>, ``"onFinish"`` \| ``"children"`` \| ``"initialValues"``\>
|
|
336
337
|
|
|
337
338
|
#### Type parameters
|
|
338
339
|
|
|
339
340
|
| Name | Type |
|
|
340
341
|
| :------ | :------ |
|
|
341
|
-
| `Values` | `any` |
|
|
342
|
+
| `Values` | extends `Record`<`string`, `any`\> = `any` |
|
|
342
343
|
| `ExtendItemProps` | `any` |
|
|
343
344
|
|
|
344
345
|
___
|
|
@@ -382,7 +383,7 @@ ___
|
|
|
382
383
|
|
|
383
384
|
### TableItemProps
|
|
384
385
|
|
|
385
|
-
Ƭ **TableItemProps**<`T`\>: { `children?`: `JSX.Element` \| ``null`` ; `optionsType?`: ``"auto"`` } & [`FaasItemProps`](#faasitemprops) & `Omit`<`AntdTableColumnProps`<`T`\>, ``"children"``\>
|
|
386
|
+
Ƭ **TableItemProps**<`T`\>: { `children?`: `JSX.Element` \| ``null`` ; `object?`: [`TableItemProps`](#tableitemprops)[] ; `optionsType?`: ``"auto"`` } & [`FaasItemProps`](#faasitemprops) & `Omit`<`AntdTableColumnProps`<`T`\>, ``"children"``\>
|
|
386
387
|
|
|
387
388
|
#### Type parameters
|
|
388
389
|
|
|
@@ -796,6 +797,23 @@ ___
|
|
|
796
797
|
|
|
797
798
|
___
|
|
798
799
|
|
|
800
|
+
### transferValue
|
|
801
|
+
|
|
802
|
+
▸ **transferValue**(`type`, `value`): `any`
|
|
803
|
+
|
|
804
|
+
#### Parameters
|
|
805
|
+
|
|
806
|
+
| Name | Type |
|
|
807
|
+
| :------ | :------ |
|
|
808
|
+
| `type` | [`FaasItemType`](#faasitemtype) |
|
|
809
|
+
| `value` | `any` |
|
|
810
|
+
|
|
811
|
+
#### Returns
|
|
812
|
+
|
|
813
|
+
`any`
|
|
814
|
+
|
|
815
|
+
___
|
|
816
|
+
|
|
799
817
|
### useConfigContext
|
|
800
818
|
|
|
801
819
|
▸ **useConfigContext**(): [`ConfigProviderProps`](#configproviderprops)
|
package/dist/index.js
CHANGED
|
@@ -797,47 +797,46 @@ function Form(props) {
|
|
|
797
797
|
setExtendTypes(propsCopy.extendTypes);
|
|
798
798
|
delete propsCopy.extendTypes;
|
|
799
799
|
}
|
|
800
|
-
let originValuesChange;
|
|
801
|
-
if (propsCopy.onValuesChange)
|
|
802
|
-
originValuesChange = propsCopy.onValuesChange;
|
|
803
|
-
propsCopy.onValuesChange = (changedValues, allValues) => {
|
|
804
|
-
if (originValuesChange)
|
|
805
|
-
originValuesChange(changedValues, allValues);
|
|
806
|
-
if (!props.items)
|
|
807
|
-
return;
|
|
808
|
-
for (const key in changedValues) {
|
|
809
|
-
const item = propsCopy.items.find((i) => i.id === key);
|
|
810
|
-
if (item == null ? void 0 : item.onValueChange)
|
|
811
|
-
item.onValueChange(changedValues[key], allValues, form);
|
|
812
|
-
}
|
|
813
|
-
const filterItems = props.items.filter((it) => {
|
|
814
|
-
if (!it.if) {
|
|
815
|
-
return true;
|
|
816
|
-
}
|
|
817
|
-
const show = it.if(allValues);
|
|
818
|
-
if (show) {
|
|
819
|
-
propsCopy.form.setFields([
|
|
820
|
-
{
|
|
821
|
-
name: it.id,
|
|
822
|
-
errors: null
|
|
823
|
-
}
|
|
824
|
-
]);
|
|
825
|
-
}
|
|
826
|
-
return show;
|
|
827
|
-
});
|
|
828
|
-
if (propsCopy.items.length !== filterItems.length || propsCopy.items.some((it, i) => it !== filterItems[i])) {
|
|
829
|
-
setComputedProps({
|
|
830
|
-
...propsCopy,
|
|
831
|
-
items: filterItems
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
};
|
|
835
800
|
setComputedProps(propsCopy);
|
|
836
801
|
}, [props]);
|
|
802
|
+
const onValuesChange = (0, import_react9.useCallback)((changedValues, allValues) => {
|
|
803
|
+
if (props.onValuesChange) {
|
|
804
|
+
props.onValuesChange(changedValues, allValues);
|
|
805
|
+
}
|
|
806
|
+
if (!props.items)
|
|
807
|
+
return;
|
|
808
|
+
for (const key in changedValues) {
|
|
809
|
+
const item = computedProps.items.find((i) => i.id === key);
|
|
810
|
+
if (item == null ? void 0 : item.onValueChange)
|
|
811
|
+
item.onValueChange(changedValues[key], allValues, form);
|
|
812
|
+
}
|
|
813
|
+
const filterItems = props.items.filter((it) => {
|
|
814
|
+
if (!it.if) {
|
|
815
|
+
return true;
|
|
816
|
+
}
|
|
817
|
+
const show = it.if(allValues);
|
|
818
|
+
if (show) {
|
|
819
|
+
props.form.setFields([
|
|
820
|
+
{
|
|
821
|
+
name: it.id,
|
|
822
|
+
errors: null
|
|
823
|
+
}
|
|
824
|
+
]);
|
|
825
|
+
}
|
|
826
|
+
return show;
|
|
827
|
+
});
|
|
828
|
+
if (computedProps.items.length !== filterItems.length || computedProps.items.some((it, i) => it !== filterItems[i])) {
|
|
829
|
+
setComputedProps({
|
|
830
|
+
...computedProps,
|
|
831
|
+
items: filterItems
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
}, [computedProps]);
|
|
837
835
|
if (!computedProps)
|
|
838
836
|
return null;
|
|
839
837
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd6.Form, {
|
|
840
838
|
...computedProps,
|
|
839
|
+
onValuesChange,
|
|
841
840
|
children: [
|
|
842
841
|
computedProps.beforeItems,
|
|
843
842
|
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FormItem, {
|
package/dist/index.mjs
CHANGED
|
@@ -327,7 +327,8 @@ import {
|
|
|
327
327
|
} from "antd";
|
|
328
328
|
import {
|
|
329
329
|
useEffect as useEffect4,
|
|
330
|
-
useState as useState5
|
|
330
|
+
useState as useState5,
|
|
331
|
+
useCallback
|
|
331
332
|
} from "react";
|
|
332
333
|
|
|
333
334
|
// src/FormItem.tsx
|
|
@@ -776,47 +777,46 @@ function Form(props) {
|
|
|
776
777
|
setExtendTypes(propsCopy.extendTypes);
|
|
777
778
|
delete propsCopy.extendTypes;
|
|
778
779
|
}
|
|
779
|
-
let originValuesChange;
|
|
780
|
-
if (propsCopy.onValuesChange)
|
|
781
|
-
originValuesChange = propsCopy.onValuesChange;
|
|
782
|
-
propsCopy.onValuesChange = (changedValues, allValues) => {
|
|
783
|
-
if (originValuesChange)
|
|
784
|
-
originValuesChange(changedValues, allValues);
|
|
785
|
-
if (!props.items)
|
|
786
|
-
return;
|
|
787
|
-
for (const key in changedValues) {
|
|
788
|
-
const item = propsCopy.items.find((i) => i.id === key);
|
|
789
|
-
if (item == null ? void 0 : item.onValueChange)
|
|
790
|
-
item.onValueChange(changedValues[key], allValues, form);
|
|
791
|
-
}
|
|
792
|
-
const filterItems = props.items.filter((it) => {
|
|
793
|
-
if (!it.if) {
|
|
794
|
-
return true;
|
|
795
|
-
}
|
|
796
|
-
const show = it.if(allValues);
|
|
797
|
-
if (show) {
|
|
798
|
-
propsCopy.form.setFields([
|
|
799
|
-
{
|
|
800
|
-
name: it.id,
|
|
801
|
-
errors: null
|
|
802
|
-
}
|
|
803
|
-
]);
|
|
804
|
-
}
|
|
805
|
-
return show;
|
|
806
|
-
});
|
|
807
|
-
if (propsCopy.items.length !== filterItems.length || propsCopy.items.some((it, i) => it !== filterItems[i])) {
|
|
808
|
-
setComputedProps({
|
|
809
|
-
...propsCopy,
|
|
810
|
-
items: filterItems
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
};
|
|
814
780
|
setComputedProps(propsCopy);
|
|
815
781
|
}, [props]);
|
|
782
|
+
const onValuesChange = useCallback((changedValues, allValues) => {
|
|
783
|
+
if (props.onValuesChange) {
|
|
784
|
+
props.onValuesChange(changedValues, allValues);
|
|
785
|
+
}
|
|
786
|
+
if (!props.items)
|
|
787
|
+
return;
|
|
788
|
+
for (const key in changedValues) {
|
|
789
|
+
const item = computedProps.items.find((i) => i.id === key);
|
|
790
|
+
if (item == null ? void 0 : item.onValueChange)
|
|
791
|
+
item.onValueChange(changedValues[key], allValues, form);
|
|
792
|
+
}
|
|
793
|
+
const filterItems = props.items.filter((it) => {
|
|
794
|
+
if (!it.if) {
|
|
795
|
+
return true;
|
|
796
|
+
}
|
|
797
|
+
const show = it.if(allValues);
|
|
798
|
+
if (show) {
|
|
799
|
+
props.form.setFields([
|
|
800
|
+
{
|
|
801
|
+
name: it.id,
|
|
802
|
+
errors: null
|
|
803
|
+
}
|
|
804
|
+
]);
|
|
805
|
+
}
|
|
806
|
+
return show;
|
|
807
|
+
});
|
|
808
|
+
if (computedProps.items.length !== filterItems.length || computedProps.items.some((it, i) => it !== filterItems[i])) {
|
|
809
|
+
setComputedProps({
|
|
810
|
+
...computedProps,
|
|
811
|
+
items: filterItems
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
}, [computedProps]);
|
|
816
815
|
if (!computedProps)
|
|
817
816
|
return null;
|
|
818
817
|
return /* @__PURE__ */ jsxs2(AntdForm2, {
|
|
819
818
|
...computedProps,
|
|
819
|
+
onValuesChange,
|
|
820
820
|
children: [
|
|
821
821
|
computedProps.beforeItems,
|
|
822
822
|
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx7(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.447",
|
|
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.447",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|