@faasjs/ant-design 0.0.2-beta.452 → 0.0.2-beta.454
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/dist/index.d.ts +84 -47
- package/dist/index.js +177 -173
- package/dist/index.mjs +29 -25
- package/package.json +3 -5
package/dist/index.mjs
CHANGED
|
@@ -417,16 +417,34 @@ function FormItem(props) {
|
|
|
417
417
|
const [computedProps, setComputedProps] = useState4();
|
|
418
418
|
const [extendTypes, setExtendTypes] = useState4();
|
|
419
419
|
const config = useConfigContext();
|
|
420
|
+
const [hidden, setHidden] = useState4(false);
|
|
420
421
|
useEffect3(() => {
|
|
421
422
|
const propsCopy = { ...props };
|
|
422
423
|
if (propsCopy.extendTypes) {
|
|
423
424
|
setExtendTypes(propsCopy.extendTypes);
|
|
424
425
|
delete propsCopy.extendTypes;
|
|
425
426
|
}
|
|
427
|
+
if (propsCopy.if) {
|
|
428
|
+
const condition = propsCopy.if;
|
|
429
|
+
propsCopy.shouldUpdate = (_, cur) => {
|
|
430
|
+
const show = condition(cur);
|
|
431
|
+
setHidden(!show);
|
|
432
|
+
return show;
|
|
433
|
+
};
|
|
434
|
+
delete propsCopy.if;
|
|
435
|
+
}
|
|
426
436
|
setComputedProps(processProps(propsCopy, config));
|
|
427
437
|
}, [props]);
|
|
428
438
|
if (!computedProps)
|
|
429
439
|
return null;
|
|
440
|
+
if (hidden)
|
|
441
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
442
|
+
...computedProps,
|
|
443
|
+
noStyle: true,
|
|
444
|
+
children: /* @__PURE__ */ jsx6(Input, {
|
|
445
|
+
hidden: true
|
|
446
|
+
})
|
|
447
|
+
});
|
|
430
448
|
if (extendTypes && extendTypes[computedProps.type])
|
|
431
449
|
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
432
450
|
...computedProps,
|
|
@@ -713,21 +731,22 @@ function Form(props) {
|
|
|
713
731
|
const config = useConfigContext();
|
|
714
732
|
const [extendTypes, setExtendTypes] = useState5();
|
|
715
733
|
const [form] = AntdForm2.useForm(props.form);
|
|
734
|
+
const [initialValues, setInitialValues] = useState5(props.initialValues);
|
|
716
735
|
useEffect4(() => {
|
|
717
736
|
var _a2, _b2;
|
|
718
737
|
const propsCopy = {
|
|
719
738
|
...props,
|
|
720
|
-
items: (props.items || []).filter((it) => {
|
|
721
|
-
return !it.if || it.if(props.initialValues || {});
|
|
722
|
-
}),
|
|
723
739
|
form
|
|
724
740
|
};
|
|
725
|
-
if (propsCopy.initialValues)
|
|
741
|
+
if (propsCopy.initialValues) {
|
|
726
742
|
for (const key in propsCopy.initialValues)
|
|
727
743
|
propsCopy.initialValues[key] = transferValue(
|
|
728
744
|
(_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
|
|
729
745
|
propsCopy.initialValues[key]
|
|
730
746
|
);
|
|
747
|
+
setInitialValues(propsCopy.initialValues);
|
|
748
|
+
delete propsCopy.initialValues;
|
|
749
|
+
}
|
|
731
750
|
if (propsCopy.onFinish) {
|
|
732
751
|
propsCopy.onFinish = async (values) => {
|
|
733
752
|
var _a3;
|
|
@@ -771,27 +790,12 @@ function Form(props) {
|
|
|
771
790
|
if (item == null ? void 0 : item.onValueChange)
|
|
772
791
|
item.onValueChange(changedValues[key], allValues, form);
|
|
773
792
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
props.form.setFields([
|
|
781
|
-
{
|
|
782
|
-
name: it.id,
|
|
783
|
-
errors: null
|
|
784
|
-
}
|
|
785
|
-
]);
|
|
786
|
-
}
|
|
787
|
-
return show;
|
|
788
|
-
});
|
|
789
|
-
if (computedProps.items.length !== filterItems.length || computedProps.items.some((it, i) => it !== filterItems[i])) {
|
|
790
|
-
setComputedProps({
|
|
791
|
-
...computedProps,
|
|
792
|
-
items: filterItems
|
|
793
|
-
});
|
|
794
|
-
}
|
|
793
|
+
}, [computedProps]);
|
|
794
|
+
useEffect4(() => {
|
|
795
|
+
if (!initialValues)
|
|
796
|
+
return;
|
|
797
|
+
form.setFieldsValue(initialValues);
|
|
798
|
+
setInitialValues(null);
|
|
795
799
|
}, [computedProps]);
|
|
796
800
|
if (!computedProps)
|
|
797
801
|
return null;
|
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.454",
|
|
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.454",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|
|
@@ -36,9 +36,7 @@
|
|
|
36
36
|
"@types/lodash": "*",
|
|
37
37
|
"@testing-library/jest-dom": "*",
|
|
38
38
|
"@testing-library/react": "*",
|
|
39
|
-
"@testing-library/user-event": "*"
|
|
40
|
-
"tsup": "*",
|
|
41
|
-
"typescript": "*"
|
|
39
|
+
"@testing-library/user-event": "*"
|
|
42
40
|
},
|
|
43
41
|
"engines": {
|
|
44
42
|
"npm": ">=8.0.0",
|