@plasmicpkgs/antd5 0.0.125 → 0.0.126
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/.tsbuildinfo +1 -1
- package/dist/antd.esm.js +339 -233
- package/dist/antd.esm.js.map +1 -1
- package/dist/index.js +339 -233
- package/dist/index.js.map +1 -1
- package/dist/registerForm.d.ts +18 -15
- package/dist/utils.d.ts +2 -1
- package/package.json +2 -2
- package/skinny/registerAvatar.cjs.js +1 -1
- package/skinny/registerAvatar.esm.js +1 -1
- package/skinny/registerButton.cjs.js +1 -1
- package/skinny/registerButton.esm.js +1 -1
- package/skinny/registerCheckbox.cjs.js +1 -1
- package/skinny/registerCheckbox.esm.js +1 -1
- package/skinny/registerCollapse.cjs.js +1 -1
- package/skinny/registerCollapse.esm.js +1 -1
- package/skinny/registerColorPicker.cjs.js +1 -1
- package/skinny/registerColorPicker.esm.js +1 -1
- package/skinny/registerConfigProvider.cjs.js +1 -1
- package/skinny/registerConfigProvider.esm.js +1 -1
- package/skinny/registerDatePicker.cjs.js +1 -1
- package/skinny/registerDatePicker.esm.js +1 -1
- package/skinny/registerDrawer.cjs.js +1 -1
- package/skinny/registerDrawer.esm.js +1 -1
- package/skinny/registerDropdown.cjs.js +1 -1
- package/skinny/registerDropdown.esm.js +1 -1
- package/skinny/registerForm.cjs.js +304 -230
- package/skinny/registerForm.cjs.js.map +1 -1
- package/skinny/registerForm.d.ts +18 -15
- package/skinny/registerForm.esm.js +304 -230
- package/skinny/registerForm.esm.js.map +1 -1
- package/skinny/registerInput.cjs.js +1 -1
- package/skinny/registerInput.esm.js +1 -1
- package/skinny/registerMenu.cjs.js +1 -1
- package/skinny/registerMenu.esm.js +1 -1
- package/skinny/registerModal.cjs.js +1 -1
- package/skinny/registerModal.esm.js +1 -1
- package/skinny/registerPopover.cjs.js +1 -1
- package/skinny/registerPopover.esm.js +1 -1
- package/skinny/registerRadio.cjs.js +1 -1
- package/skinny/registerRadio.esm.js +1 -1
- package/skinny/registerRate.cjs.js +1 -1
- package/skinny/registerRate.esm.js +1 -1
- package/skinny/{registerSelect-3273fe93.esm.js → registerSelect-d2c8e1c0.esm.js} +2 -2
- package/skinny/{registerSelect-3273fe93.esm.js.map → registerSelect-d2c8e1c0.esm.js.map} +1 -1
- package/skinny/{registerSelect-f0e24345.cjs.js → registerSelect-dfdd1699.cjs.js} +2 -2
- package/skinny/{registerSelect-f0e24345.cjs.js.map → registerSelect-dfdd1699.cjs.js.map} +1 -1
- package/skinny/registerSelect.cjs.js +2 -2
- package/skinny/registerSelect.esm.js +2 -2
- package/skinny/registerSteps.cjs.js +1 -1
- package/skinny/registerSteps.esm.js +1 -1
- package/skinny/registerSwitch.cjs.js +1 -1
- package/skinny/registerSwitch.esm.js +1 -1
- package/skinny/registerTable.cjs.js +1 -1
- package/skinny/registerTable.esm.js +1 -1
- package/skinny/registerTabs.cjs.js +1 -1
- package/skinny/registerTabs.esm.js +1 -1
- package/skinny/registerTooltip.cjs.js +1 -1
- package/skinny/registerTooltip.esm.js +1 -1
- package/skinny/registerTree.cjs.js +1 -1
- package/skinny/registerTree.esm.js +1 -1
- package/skinny/registerUpload.cjs.js +1 -1
- package/skinny/registerUpload.esm.js +1 -1
- package/skinny/{utils-c2d6f0e8.cjs.js → utils-174b9d45.cjs.js} +39 -6
- package/skinny/utils-174b9d45.cjs.js.map +1 -0
- package/skinny/{utils-040cbe4d.esm.js → utils-7d8f2418.esm.js} +39 -7
- package/skinny/utils-7d8f2418.esm.js.map +1 -0
- package/skinny/utils.d.ts +2 -1
- package/skinny/utils-040cbe4d.esm.js.map +0 -1
- package/skinny/utils-c2d6f0e8.cjs.js.map +0 -1
package/dist/antd.esm.js
CHANGED
|
@@ -126,12 +126,44 @@ class ErrorBoundary extends React.Component {
|
|
|
126
126
|
return this.props.children;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
var hasOwnProp = Object.prototype.hasOwnProperty;
|
|
130
|
+
function isSafeKey(key) {
|
|
131
|
+
return key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
132
|
+
}
|
|
133
|
+
function get(obj, path) {
|
|
134
|
+
var keys = Array.isArray(path) ? path : path.split(".");
|
|
135
|
+
for (var i = 0; i < keys.length; i++) {
|
|
136
|
+
var key = keys[i];
|
|
137
|
+
if (!obj || !hasOwnProp.call(obj, key) || !isSafeKey(key)) {
|
|
138
|
+
obj = void 0;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
obj = obj[key];
|
|
142
|
+
}
|
|
143
|
+
return obj;
|
|
144
|
+
}
|
|
145
|
+
function set(obj, path, value) {
|
|
146
|
+
var keys = Array.isArray(path) ? path : path.split(".");
|
|
147
|
+
for (var i = 0; i < keys.length - 1; i++) {
|
|
148
|
+
var key = keys[i];
|
|
149
|
+
if (!isSafeKey(key))
|
|
150
|
+
return;
|
|
151
|
+
if (hasOwnProp.call(obj, key))
|
|
152
|
+
obj[key] = {};
|
|
153
|
+
obj = obj[key];
|
|
154
|
+
}
|
|
155
|
+
obj[keys[i]] = value;
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
function pick(obj, ...paths) {
|
|
159
|
+
if (Object.keys(obj).length === 0) {
|
|
160
|
+
return obj;
|
|
161
|
+
}
|
|
162
|
+
const res = {};
|
|
163
|
+
for (const path of paths) {
|
|
164
|
+
set(res, path, get(obj, path));
|
|
133
165
|
}
|
|
134
|
-
return
|
|
166
|
+
return res;
|
|
135
167
|
}
|
|
136
168
|
|
|
137
169
|
var __defProp$o = Object.defineProperty;
|
|
@@ -2763,20 +2795,22 @@ const InternalFormInstanceContext = React.createContext(void 0);
|
|
|
2763
2795
|
const FormLayoutContext = React.createContext(void 0);
|
|
2764
2796
|
const Internal = React.forwardRef(
|
|
2765
2797
|
(props, ref) => {
|
|
2766
|
-
var _b, _c, _d, _e
|
|
2798
|
+
var _b, _c, _d, _e;
|
|
2767
2799
|
const [form] = Form.useForm();
|
|
2768
2800
|
const values = form.getFieldsValue(true);
|
|
2769
2801
|
const lastValue = React.useRef(values);
|
|
2770
2802
|
const _a = props, {
|
|
2771
2803
|
extendedOnValuesChange,
|
|
2772
2804
|
forceRemount,
|
|
2773
|
-
|
|
2774
|
-
|
|
2805
|
+
formLayout,
|
|
2806
|
+
internalFieldCtx,
|
|
2807
|
+
setInternalFieldCtx
|
|
2775
2808
|
} = _a, rest = __objRest$a(_a, [
|
|
2776
2809
|
"extendedOnValuesChange",
|
|
2777
2810
|
"forceRemount",
|
|
2778
|
-
"
|
|
2779
|
-
"
|
|
2811
|
+
"formLayout",
|
|
2812
|
+
"internalFieldCtx",
|
|
2813
|
+
"setInternalFieldCtx"
|
|
2780
2814
|
]);
|
|
2781
2815
|
let childrenNode;
|
|
2782
2816
|
if (props.mode !== "simplified") {
|
|
@@ -2819,16 +2853,6 @@ const Internal = React.forwardRef(
|
|
|
2819
2853
|
React.useEffect(() => {
|
|
2820
2854
|
fireOnValuesChange();
|
|
2821
2855
|
}, []);
|
|
2822
|
-
const formLayout = React.useMemo(
|
|
2823
|
-
() => {
|
|
2824
|
-
var _a2;
|
|
2825
|
-
return {
|
|
2826
|
-
layout: props.layout,
|
|
2827
|
-
labelSpan: (_a2 = props.labelCol) == null ? void 0 : _a2.span
|
|
2828
|
-
};
|
|
2829
|
-
},
|
|
2830
|
-
[props.layout, (_c = props.labelCol) == null ? void 0 : _c.span]
|
|
2831
|
-
);
|
|
2832
2856
|
React.useImperativeHandle(ref, () => ({
|
|
2833
2857
|
formInstance: form,
|
|
2834
2858
|
setFieldsValue: (newValues) => {
|
|
@@ -2857,12 +2881,28 @@ const Internal = React.forwardRef(
|
|
|
2857
2881
|
extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(form.getFieldsValue(true));
|
|
2858
2882
|
}
|
|
2859
2883
|
}));
|
|
2860
|
-
const registerField = React.useCallback(
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2884
|
+
const registerField = React.useCallback(
|
|
2885
|
+
(fieldEntity) => {
|
|
2886
|
+
setInternalFieldCtx((ctx) => ({
|
|
2887
|
+
registeredFields: [...ctx.registeredFields, fieldEntity],
|
|
2888
|
+
preservedRegisteredFields: [
|
|
2889
|
+
...ctx.preservedRegisteredFields,
|
|
2890
|
+
fieldEntity
|
|
2891
|
+
]
|
|
2892
|
+
}));
|
|
2893
|
+
return () => {
|
|
2894
|
+
setInternalFieldCtx((ctx) => ({
|
|
2895
|
+
registeredFields: ctx.registeredFields.filter(
|
|
2896
|
+
(ent) => ent !== fieldEntity
|
|
2897
|
+
),
|
|
2898
|
+
preservedRegisteredFields: ctx.preservedRegisteredFields.filter(
|
|
2899
|
+
(ent) => ent !== fieldEntity || fieldEntity.preserve
|
|
2900
|
+
)
|
|
2901
|
+
}));
|
|
2902
|
+
};
|
|
2903
|
+
},
|
|
2904
|
+
[setInternalFieldCtx]
|
|
2905
|
+
);
|
|
2866
2906
|
return /* @__PURE__ */ React.createElement(
|
|
2867
2907
|
InternalFormInstanceContext.Provider,
|
|
2868
2908
|
{
|
|
@@ -2871,8 +2911,8 @@ const Internal = React.forwardRef(
|
|
|
2871
2911
|
fireOnValuesChange,
|
|
2872
2912
|
forceRemount,
|
|
2873
2913
|
registerField,
|
|
2874
|
-
|
|
2875
|
-
initialValues: (
|
|
2914
|
+
internalFieldCtx,
|
|
2915
|
+
initialValues: (_c = props.initialValues) != null ? _c : {}
|
|
2876
2916
|
}
|
|
2877
2917
|
},
|
|
2878
2918
|
/* @__PURE__ */ React.createElement(FormLayoutContext.Provider, { value: formLayout }, /* @__PURE__ */ React.createElement(
|
|
@@ -2886,11 +2926,19 @@ const Internal = React.forwardRef(
|
|
|
2886
2926
|
},
|
|
2887
2927
|
onFinish: () => {
|
|
2888
2928
|
var _a2;
|
|
2889
|
-
(_a2 = props.onFinish) == null ? void 0 : _a2.call(
|
|
2929
|
+
(_a2 = props.onFinish) == null ? void 0 : _a2.call(
|
|
2930
|
+
props,
|
|
2931
|
+
pick(
|
|
2932
|
+
form.getFieldsValue(true),
|
|
2933
|
+
...internalFieldCtx.preservedRegisteredFields.map(
|
|
2934
|
+
(field) => field.fullPath
|
|
2935
|
+
)
|
|
2936
|
+
)
|
|
2937
|
+
);
|
|
2890
2938
|
},
|
|
2891
2939
|
form,
|
|
2892
|
-
labelCol: ((
|
|
2893
|
-
wrapperCol: ((
|
|
2940
|
+
labelCol: ((_d = props.labelCol) == null ? void 0 : _d.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
|
|
2941
|
+
wrapperCol: ((_e = props.wrapperCol) == null ? void 0 : _e.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
|
|
2894
2942
|
}),
|
|
2895
2943
|
/* @__PURE__ */ React.createElement("style", null, `
|
|
2896
2944
|
.ant-form-item-explain + div, .ant-form-item-margin-offset {
|
|
@@ -2902,17 +2950,16 @@ const Internal = React.forwardRef(
|
|
|
2902
2950
|
);
|
|
2903
2951
|
}
|
|
2904
2952
|
);
|
|
2905
|
-
function useFormItemDefinitions(rawData, props, formRef,
|
|
2953
|
+
function useFormItemDefinitions(rawData, props, formRef, commonFormCtxData) {
|
|
2906
2954
|
const { mode, dataFormItems, setControlContextData } = props;
|
|
2907
2955
|
const formInstance = formRef == null ? void 0 : formRef.formInstance;
|
|
2908
2956
|
return React.useMemo(() => {
|
|
2909
2957
|
const data = rawData && normalizeData(rawData);
|
|
2910
2958
|
const schema = data && (data == null ? void 0 : data.schema);
|
|
2911
2959
|
if (mode !== "simplified" || !rawData || rawData.isLoading || rawData.error || !data || !schema || !data.data) {
|
|
2912
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
2913
|
-
formInstance
|
|
2914
|
-
|
|
2915
|
-
});
|
|
2960
|
+
setControlContextData == null ? void 0 : setControlContextData(__spreadValues$d({
|
|
2961
|
+
formInstance
|
|
2962
|
+
}, commonFormCtxData));
|
|
2916
2963
|
return void 0;
|
|
2917
2964
|
}
|
|
2918
2965
|
const row = data.data.length > 0 ? data.data[0] : void 0;
|
|
@@ -2934,15 +2981,21 @@ function useFormItemDefinitions(rawData, props, formRef, registeredFields) {
|
|
|
2934
2981
|
});
|
|
2935
2982
|
}
|
|
2936
2983
|
);
|
|
2937
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
2984
|
+
setControlContextData == null ? void 0 : setControlContextData(__spreadValues$d({
|
|
2938
2985
|
schema: data.schema,
|
|
2939
2986
|
minimalFullLengthFields,
|
|
2940
2987
|
mergedFields,
|
|
2941
|
-
formInstance
|
|
2942
|
-
|
|
2943
|
-
});
|
|
2988
|
+
formInstance
|
|
2989
|
+
}, commonFormCtxData));
|
|
2944
2990
|
return mergedFields;
|
|
2945
|
-
}, [
|
|
2991
|
+
}, [
|
|
2992
|
+
mode,
|
|
2993
|
+
setControlContextData,
|
|
2994
|
+
dataFormItems,
|
|
2995
|
+
rawData,
|
|
2996
|
+
formInstance,
|
|
2997
|
+
commonFormCtxData
|
|
2998
|
+
]);
|
|
2946
2999
|
}
|
|
2947
3000
|
const useRawData = (props) => {
|
|
2948
3001
|
const rawData = usePlasmicDataOp(props.data);
|
|
@@ -2950,6 +3003,7 @@ const useRawData = (props) => {
|
|
|
2950
3003
|
};
|
|
2951
3004
|
const FormWrapper = React.forwardRef(
|
|
2952
3005
|
(props, ref) => {
|
|
3006
|
+
var _a;
|
|
2953
3007
|
const [remountKey, setRemountKey] = React.useState(0);
|
|
2954
3008
|
const forceRemount = React.useCallback(
|
|
2955
3009
|
() => setRemountKey((k) => k + 1),
|
|
@@ -2962,17 +3016,37 @@ const FormWrapper = React.forwardRef(
|
|
|
2962
3016
|
forceRemount();
|
|
2963
3017
|
}
|
|
2964
3018
|
}, [previousInitialValues, props.initialValues]);
|
|
2965
|
-
const [
|
|
3019
|
+
const [internalFieldCtx, setInternalFieldCtx] = React.useState({
|
|
3020
|
+
registeredFields: [],
|
|
3021
|
+
preservedRegisteredFields: []
|
|
3022
|
+
});
|
|
2966
3023
|
React.useImperativeHandle(
|
|
2967
3024
|
ref,
|
|
2968
3025
|
() => wrapperRef.current ? __spreadValues$d({}, wrapperRef.current) : {}
|
|
2969
3026
|
);
|
|
3027
|
+
const formLayout = React.useMemo(
|
|
3028
|
+
() => {
|
|
3029
|
+
var _a2;
|
|
3030
|
+
return {
|
|
3031
|
+
layout: props.layout,
|
|
3032
|
+
labelSpan: (_a2 = props.labelCol) == null ? void 0 : _a2.span
|
|
3033
|
+
};
|
|
3034
|
+
},
|
|
3035
|
+
[props.layout, (_a = props.labelCol) == null ? void 0 : _a.span]
|
|
3036
|
+
);
|
|
3037
|
+
const commonFormCtxData = React.useMemo(
|
|
3038
|
+
() => ({
|
|
3039
|
+
layout: formLayout,
|
|
3040
|
+
internalFieldCtx
|
|
3041
|
+
}),
|
|
3042
|
+
[formLayout, internalFieldCtx]
|
|
3043
|
+
);
|
|
2970
3044
|
const rawData = useRawData(props);
|
|
2971
3045
|
const formItemDefinitions = useFormItemDefinitions(
|
|
2972
3046
|
rawData,
|
|
2973
3047
|
props,
|
|
2974
3048
|
wrapperRef.current,
|
|
2975
|
-
|
|
3049
|
+
commonFormCtxData
|
|
2976
3050
|
);
|
|
2977
3051
|
React.useEffect(() => {
|
|
2978
3052
|
if (rawData && !rawData.isLoading) {
|
|
@@ -2985,7 +3059,7 @@ const FormWrapper = React.forwardRef(
|
|
|
2985
3059
|
forceRemount();
|
|
2986
3060
|
}
|
|
2987
3061
|
}, [props.data]);
|
|
2988
|
-
const
|
|
3062
|
+
const _b = props, { dataFormItems, formItems, data } = _b, rest = __objRest$a(_b, ["dataFormItems", "formItems", "data"]);
|
|
2989
3063
|
const actualFormItems = props.mode === "simplified" && formItemDefinitions ? formItemDefinitions : data ? dataFormItems : formItems;
|
|
2990
3064
|
const previousFormItems = React.useRef([]);
|
|
2991
3065
|
React.useEffect(() => {
|
|
@@ -3004,8 +3078,9 @@ const FormWrapper = React.forwardRef(
|
|
|
3004
3078
|
key: remountKey
|
|
3005
3079
|
}, rest), {
|
|
3006
3080
|
forceRemount,
|
|
3007
|
-
|
|
3008
|
-
|
|
3081
|
+
formLayout,
|
|
3082
|
+
internalFieldCtx,
|
|
3083
|
+
setInternalFieldCtx,
|
|
3009
3084
|
formItems: rawData && rawData.isLoading ? previousFormItems.current : actualFormItems,
|
|
3010
3085
|
ref: wrapperRef,
|
|
3011
3086
|
style: isSchemaForm && isLoadingData ? {
|
|
@@ -3478,7 +3553,7 @@ function useFormInstanceMaybe() {
|
|
|
3478
3553
|
return Form.useFormInstance();
|
|
3479
3554
|
}
|
|
3480
3555
|
function FormItemWrapper(props) {
|
|
3481
|
-
var _b;
|
|
3556
|
+
var _b, _c, _d;
|
|
3482
3557
|
const _a = props, {
|
|
3483
3558
|
rules: plasmicRules,
|
|
3484
3559
|
description,
|
|
@@ -3502,6 +3577,7 @@ function FormItemWrapper(props) {
|
|
|
3502
3577
|
const fullFormItemName = useFormItemFullName(name);
|
|
3503
3578
|
const pathCtx = React.useContext(PathContext);
|
|
3504
3579
|
const fieldEntity = React.useRef({
|
|
3580
|
+
preserve: (_b = props.preserve) != null ? _b : true,
|
|
3505
3581
|
fullPath: pathCtx.fullPath,
|
|
3506
3582
|
name
|
|
3507
3583
|
}).current;
|
|
@@ -3512,30 +3588,26 @@ function FormItemWrapper(props) {
|
|
|
3512
3588
|
) : void 0;
|
|
3513
3589
|
const layoutContext = React.useContext(FormLayoutContext);
|
|
3514
3590
|
const inCanvas = !!usePlasmicCanvasContext();
|
|
3591
|
+
const {
|
|
3592
|
+
fireOnValuesChange,
|
|
3593
|
+
forceRemount,
|
|
3594
|
+
registerField,
|
|
3595
|
+
initialValues,
|
|
3596
|
+
internalFieldCtx
|
|
3597
|
+
} = (_c = React.useContext(InternalFormInstanceContext)) != null ? _c : {};
|
|
3515
3598
|
if (inCanvas) {
|
|
3516
3599
|
const form = useFormInstanceMaybe();
|
|
3517
3600
|
const prevPropValues = React.useRef({
|
|
3518
3601
|
initialValue: props.initialValue,
|
|
3519
3602
|
name: props.name
|
|
3520
3603
|
});
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
const { fireOnValuesChange, forceRemount, registerField, initialValues } = internalFormCtx != null ? internalFormCtx : {};
|
|
3524
|
-
(_b = props.setControlContextData) == null ? void 0 : _b.call(props, {
|
|
3525
|
-
internalFormCtx,
|
|
3604
|
+
(_d = props.setControlContextData) == null ? void 0 : _d.call(props, {
|
|
3605
|
+
internalFieldCtx,
|
|
3526
3606
|
formInstance: form,
|
|
3527
|
-
parentFormItemPath: fullPath
|
|
3607
|
+
parentFormItemPath: pathCtx.fullPath,
|
|
3608
|
+
layout: layoutContext
|
|
3528
3609
|
});
|
|
3529
3610
|
React.useEffect(() => {
|
|
3530
|
-
const unregister = registerField == null ? void 0 : registerField(fieldEntity);
|
|
3531
|
-
return () => unregister == null ? void 0 : unregister();
|
|
3532
|
-
}, []);
|
|
3533
|
-
React.useEffect(() => {
|
|
3534
|
-
fieldEntity.fullPath = [
|
|
3535
|
-
...pathCtx.fullPath,
|
|
3536
|
-
...props.name != null ? [props.name] : []
|
|
3537
|
-
];
|
|
3538
|
-
fieldEntity.name = props.name;
|
|
3539
3611
|
if (prevPropValues.current.name !== props.name) {
|
|
3540
3612
|
forceRemount == null ? void 0 : forceRemount();
|
|
3541
3613
|
}
|
|
@@ -3545,8 +3617,27 @@ function FormItemWrapper(props) {
|
|
|
3545
3617
|
form == null ? void 0 : form.setFieldValue(fullFormItemName, props.initialValue);
|
|
3546
3618
|
prevPropValues.current.initialValue = props.initialValue;
|
|
3547
3619
|
fireOnValuesChange == null ? void 0 : fireOnValuesChange();
|
|
3548
|
-
}, [
|
|
3620
|
+
}, [
|
|
3621
|
+
form,
|
|
3622
|
+
props.initialValue,
|
|
3623
|
+
pathCtx.fullPath,
|
|
3624
|
+
props.name,
|
|
3625
|
+
props.preserve
|
|
3626
|
+
]);
|
|
3549
3627
|
}
|
|
3628
|
+
React.useEffect(() => {
|
|
3629
|
+
var _a2;
|
|
3630
|
+
fieldEntity.fullPath = [
|
|
3631
|
+
...pathCtx.fullPath,
|
|
3632
|
+
...props.name != null ? [props.name] : []
|
|
3633
|
+
];
|
|
3634
|
+
fieldEntity.name = props.name;
|
|
3635
|
+
fieldEntity.preserve = (_a2 = props.preserve) != null ? _a2 : true;
|
|
3636
|
+
}, [pathCtx.fullPath, props.name, props.preserve]);
|
|
3637
|
+
React.useEffect(() => {
|
|
3638
|
+
const unregister = registerField == null ? void 0 : registerField(fieldEntity);
|
|
3639
|
+
return () => unregister == null ? void 0 : unregister();
|
|
3640
|
+
}, []);
|
|
3550
3641
|
return /* @__PURE__ */ React.createElement(
|
|
3551
3642
|
FormItem,
|
|
3552
3643
|
__spreadProps$9(__spreadValues$d({}, rest), {
|
|
@@ -3671,185 +3762,200 @@ const mapPlumeTypeToInputType = /* @__PURE__ */ new Map([
|
|
|
3671
3762
|
["checkbox", "Checkbox" /* Checkbox */],
|
|
3672
3763
|
["switch", "Checkbox" /* Checkbox */]
|
|
3673
3764
|
]);
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3765
|
+
function commonFormItemProps(usage) {
|
|
3766
|
+
const getFormItemProps = (ps, _ctx, { item }) => {
|
|
3767
|
+
if (usage === "simplified-form-item") {
|
|
3768
|
+
return item;
|
|
3769
|
+
} else {
|
|
3770
|
+
return ps;
|
|
3771
|
+
}
|
|
3772
|
+
};
|
|
3773
|
+
return {
|
|
3774
|
+
name: {
|
|
3775
|
+
type: "string",
|
|
3776
|
+
required: true,
|
|
3777
|
+
validator: (value, _ps, ctx) => {
|
|
3778
|
+
var _a, _b, _c;
|
|
3779
|
+
let currFullPath = [];
|
|
3780
|
+
if (usage === "simplified-form-item") {
|
|
3781
|
+
currFullPath = [value];
|
|
3782
|
+
} else {
|
|
3783
|
+
const formItemCtx = ctx;
|
|
3784
|
+
currFullPath = [...(_a = formItemCtx == null ? void 0 : formItemCtx.parentFormItemPath) != null ? _a : [], value];
|
|
3785
|
+
}
|
|
3786
|
+
const nameCounter = ((_c = (_b = ctx == null ? void 0 : ctx.internalFieldCtx) == null ? void 0 : _b.registeredFields) != null ? _c : []).filter((formItem) => arrayEq(formItem.fullPath, currFullPath)).length;
|
|
3787
|
+
return nameCounter === 1 ? true : `Repeated form item name: ${currFullPath.join(" \u2192 ")}`;
|
|
3788
|
+
},
|
|
3789
|
+
defaultValueHint: getDefaultValueHint("name")
|
|
3685
3790
|
},
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
let inputType = "Unkown" /* Unknown */;
|
|
3696
|
-
if (usage === "simplified-form-item") {
|
|
3697
|
-
inputType = item.inputType;
|
|
3698
|
-
if (!ps.data) {
|
|
3791
|
+
initialValue: {
|
|
3792
|
+
type: "dynamic",
|
|
3793
|
+
control: (ps, ctx, {
|
|
3794
|
+
item,
|
|
3795
|
+
path
|
|
3796
|
+
}) => {
|
|
3797
|
+
var _a, _b, _c, _d;
|
|
3798
|
+
let inputType = "Unkown" /* Unknown */;
|
|
3799
|
+
if (usage === "simplified-form-item") {
|
|
3699
3800
|
inputType = item.inputType;
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
inputType = "Unkown" /* Unknown */;
|
|
3801
|
+
if (!ps.data) {
|
|
3802
|
+
inputType = item.inputType;
|
|
3803
|
+
} else if (path != null && typeof path[1] === "number") {
|
|
3804
|
+
inputType = (_b = (_a = ctx == null ? void 0 : ctx.mergedFields) == null ? void 0 : _a[path[1]].inputType) != null ? _b : "Unkown" /* Unknown */;
|
|
3805
|
+
}
|
|
3706
3806
|
} else {
|
|
3707
|
-
if (
|
|
3708
|
-
inputType =
|
|
3709
|
-
} else
|
|
3710
|
-
|
|
3711
|
-
ps.children.type
|
|
3712
|
-
|
|
3807
|
+
if (!React.isValidElement(ps.children) || typeof ps.children.type === "string") {
|
|
3808
|
+
inputType = "Unkown" /* Unknown */;
|
|
3809
|
+
} else {
|
|
3810
|
+
if (mapAntdComponentToInputType.has(ps.children.type)) {
|
|
3811
|
+
inputType = (_c = mapAntdComponentToInputType.get(ps.children.type)) != null ? _c : "Unkown" /* Unknown */;
|
|
3812
|
+
} else if ("__plumeType" in ps.children.type) {
|
|
3813
|
+
inputType = (_d = mapPlumeTypeToInputType.get(
|
|
3814
|
+
ps.children.type.__plumeType
|
|
3815
|
+
)) != null ? _d : "Unkown" /* Unknown */;
|
|
3816
|
+
}
|
|
3713
3817
|
}
|
|
3714
3818
|
}
|
|
3819
|
+
if ([
|
|
3820
|
+
"Text" /* Text */,
|
|
3821
|
+
"Text Area" /* TextArea */,
|
|
3822
|
+
"Password" /* Password */,
|
|
3823
|
+
"Select" /* Select */,
|
|
3824
|
+
"Radio Group" /* RadioGroup */
|
|
3825
|
+
].includes(inputType)) {
|
|
3826
|
+
return {
|
|
3827
|
+
type: "string",
|
|
3828
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3829
|
+
};
|
|
3830
|
+
} else if ("Number" /* Number */ === inputType) {
|
|
3831
|
+
return {
|
|
3832
|
+
type: "number",
|
|
3833
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3834
|
+
};
|
|
3835
|
+
} else if ("Checkbox" /* Checkbox */ === inputType) {
|
|
3836
|
+
return {
|
|
3837
|
+
type: "boolean",
|
|
3838
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3839
|
+
};
|
|
3840
|
+
} else if ("DatePicker" /* DatePicker */ === inputType) {
|
|
3841
|
+
return {
|
|
3842
|
+
type: "dateString",
|
|
3843
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3844
|
+
};
|
|
3845
|
+
} else {
|
|
3846
|
+
return {
|
|
3847
|
+
type: "exprEditor",
|
|
3848
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3849
|
+
};
|
|
3850
|
+
}
|
|
3715
3851
|
}
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3852
|
+
},
|
|
3853
|
+
rules: {
|
|
3854
|
+
displayName: "Validation rules",
|
|
3855
|
+
type: "formValidationRules"
|
|
3856
|
+
},
|
|
3857
|
+
valuePropName: {
|
|
3858
|
+
type: "string",
|
|
3859
|
+
advanced: true,
|
|
3860
|
+
defaultValueHint: "value",
|
|
3861
|
+
description: "The prop name for specifying the value of the form control component"
|
|
3862
|
+
},
|
|
3863
|
+
trigger: {
|
|
3864
|
+
type: "string",
|
|
3865
|
+
displayName: "Trigger prop name",
|
|
3866
|
+
advanced: true,
|
|
3867
|
+
defaultValueHint: "onChange",
|
|
3868
|
+
description: "The prop name of event handler that is called when value is changed"
|
|
3869
|
+
},
|
|
3870
|
+
noLabel: {
|
|
3871
|
+
type: "boolean",
|
|
3872
|
+
advanced: true
|
|
3873
|
+
},
|
|
3874
|
+
alignLabellessWithControls: {
|
|
3875
|
+
type: "boolean",
|
|
3876
|
+
displayName: "Align with controls?",
|
|
3877
|
+
description: "Aligns the content with form controls in the grid",
|
|
3878
|
+
hidden: (ps, ctx, extras) => {
|
|
3879
|
+
var _a;
|
|
3880
|
+
const formItem = getFormItemProps(ps, ctx, extras);
|
|
3881
|
+
return !(formItem == null ? void 0 : formItem.noLabel) || ((_a = ctx == null ? void 0 : ctx.layout) == null ? void 0 : _a.layout) !== "horizontal";
|
|
3882
|
+
},
|
|
3883
|
+
defaultValueHint: true
|
|
3884
|
+
},
|
|
3885
|
+
colon: {
|
|
3886
|
+
type: "boolean",
|
|
3887
|
+
defaultValueHint: true,
|
|
3888
|
+
advanced: true,
|
|
3889
|
+
hidden: () => true
|
|
3890
|
+
},
|
|
3891
|
+
labelAlign: {
|
|
3892
|
+
type: "choice",
|
|
3893
|
+
options: ["left", "right"],
|
|
3894
|
+
advanced: true,
|
|
3895
|
+
hidden: (ps, ctx, extras) => {
|
|
3896
|
+
var _a;
|
|
3897
|
+
const formItem = getFormItemProps(ps, ctx, extras);
|
|
3898
|
+
return !!(formItem == null ? void 0 : formItem.noLabel) || ((_a = ctx == null ? void 0 : ctx.layout) == null ? void 0 : _a.layout) !== "horizontal";
|
|
3747
3899
|
}
|
|
3748
|
-
}
|
|
3749
|
-
},
|
|
3750
|
-
rules: {
|
|
3751
|
-
displayName: "Validation rules",
|
|
3752
|
-
type: "formValidationRules"
|
|
3753
|
-
},
|
|
3754
|
-
valuePropName: {
|
|
3755
|
-
type: "string",
|
|
3756
|
-
advanced: true,
|
|
3757
|
-
defaultValueHint: "value",
|
|
3758
|
-
description: "The prop name for specifying the value of the form control component"
|
|
3759
|
-
},
|
|
3760
|
-
trigger: {
|
|
3761
|
-
type: "string",
|
|
3762
|
-
displayName: "Trigger prop name",
|
|
3763
|
-
advanced: true,
|
|
3764
|
-
defaultValueHint: "onChange",
|
|
3765
|
-
description: "The prop name of event handler that is called when value is changed"
|
|
3766
|
-
},
|
|
3767
|
-
noLabel: {
|
|
3768
|
-
type: "boolean",
|
|
3769
|
-
advanced: true
|
|
3770
|
-
},
|
|
3771
|
-
alignLabellessWithControls: {
|
|
3772
|
-
type: "boolean",
|
|
3773
|
-
displayName: "Align with controls?",
|
|
3774
|
-
description: "Aligns the content with form controls in the grid",
|
|
3775
|
-
hidden: (ps, ctx) => {
|
|
3776
|
-
var _a;
|
|
3777
|
-
return !ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
|
|
3778
3900
|
},
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
defaultValueHint: true,
|
|
3784
|
-
advanced: true,
|
|
3785
|
-
hidden: () => true
|
|
3786
|
-
},
|
|
3787
|
-
labelAlign: {
|
|
3788
|
-
type: "choice",
|
|
3789
|
-
options: ["left", "right"],
|
|
3790
|
-
advanced: true,
|
|
3791
|
-
hidden: (ps, ctx) => {
|
|
3792
|
-
var _a;
|
|
3793
|
-
return !!ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
|
|
3794
|
-
}
|
|
3795
|
-
},
|
|
3796
|
-
hidden: {
|
|
3797
|
-
type: "boolean",
|
|
3798
|
-
advanced: true,
|
|
3799
|
-
defaultValueHint: getDefaultValueHint("hidden")
|
|
3800
|
-
},
|
|
3801
|
-
validateTrigger: {
|
|
3802
|
-
type: "choice",
|
|
3803
|
-
options: ["onSubmit", "onChange", "onBlur"],
|
|
3804
|
-
multiSelect: true,
|
|
3805
|
-
advanced: true
|
|
3806
|
-
},
|
|
3807
|
-
shouldUpdate: {
|
|
3808
|
-
type: "boolean",
|
|
3809
|
-
advanced: true,
|
|
3810
|
-
displayName: "Always re-render",
|
|
3811
|
-
description: "Form fields normally only re-render when the corresponding form value changes, for performance. This forces it to always re-render."
|
|
3812
|
-
},
|
|
3813
|
-
dependencies: {
|
|
3814
|
-
type: "array",
|
|
3815
|
-
advanced: true,
|
|
3816
|
-
displayName: "Dependencies",
|
|
3817
|
-
description: "Form fields can depend on other form fields. This forces it to re-evaluate the validation rules when the other form fields changes."
|
|
3818
|
-
},
|
|
3819
|
-
hideValidationMessage: {
|
|
3820
|
-
type: "boolean",
|
|
3821
|
-
displayName: "Hide validation message?",
|
|
3822
|
-
description: "If true, will hide the validation error message",
|
|
3823
|
-
defaultValueHint: false,
|
|
3824
|
-
advanced: true
|
|
3825
|
-
},
|
|
3826
|
-
customizeProps: {
|
|
3827
|
-
type: "function",
|
|
3828
|
-
description: "Customize the props passed into the wrapped field component. Takes the current status ('success', 'warning', 'error', or 'validating').)",
|
|
3829
|
-
argNames: ["fieldData"],
|
|
3830
|
-
argValues: (_ps, ctx) => {
|
|
3831
|
-
var _a;
|
|
3832
|
-
return [
|
|
3833
|
-
{
|
|
3834
|
-
status: (_a = ctx == null ? void 0 : ctx.status) == null ? void 0 : _a.status
|
|
3835
|
-
}
|
|
3836
|
-
];
|
|
3901
|
+
hidden: {
|
|
3902
|
+
type: "boolean",
|
|
3903
|
+
advanced: true,
|
|
3904
|
+
defaultValueHint: getDefaultValueHint("hidden")
|
|
3837
3905
|
},
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3906
|
+
validateTrigger: {
|
|
3907
|
+
type: "choice",
|
|
3908
|
+
options: ["onSubmit", "onChange", "onBlur"],
|
|
3909
|
+
multiSelect: true,
|
|
3910
|
+
advanced: true
|
|
3911
|
+
},
|
|
3912
|
+
shouldUpdate: {
|
|
3913
|
+
type: "boolean",
|
|
3914
|
+
advanced: true,
|
|
3915
|
+
displayName: "Always re-render",
|
|
3916
|
+
description: "Form fields normally only re-render when the corresponding form value changes, for performance. This forces it to always re-render."
|
|
3917
|
+
},
|
|
3918
|
+
dependencies: {
|
|
3919
|
+
type: "array",
|
|
3920
|
+
advanced: true,
|
|
3921
|
+
displayName: "Dependencies",
|
|
3922
|
+
description: "Form fields can depend on other form fields. This forces it to re-evaluate the validation rules when the other form fields changes."
|
|
3923
|
+
},
|
|
3924
|
+
hideValidationMessage: {
|
|
3925
|
+
type: "boolean",
|
|
3926
|
+
displayName: "Hide validation message?",
|
|
3927
|
+
description: "If true, will hide the validation error message",
|
|
3928
|
+
defaultValueHint: false,
|
|
3929
|
+
advanced: true
|
|
3930
|
+
},
|
|
3931
|
+
customizeProps: {
|
|
3932
|
+
type: "function",
|
|
3933
|
+
description: "Customize the props passed into the wrapped field component. Takes the current status ('success', 'warning', 'error', or 'validating').)",
|
|
3934
|
+
argNames: ["fieldData"],
|
|
3935
|
+
argValues: (_ps, ctx) => {
|
|
3936
|
+
var _a;
|
|
3937
|
+
return [
|
|
3938
|
+
{
|
|
3939
|
+
status: (_a = ctx == null ? void 0 : ctx.status) == null ? void 0 : _a.status
|
|
3940
|
+
}
|
|
3941
|
+
];
|
|
3942
|
+
},
|
|
3943
|
+
advanced: true
|
|
3944
|
+
},
|
|
3945
|
+
noStyle: {
|
|
3946
|
+
type: "boolean",
|
|
3947
|
+
displayName: "Field control only",
|
|
3948
|
+
description: "Don't render anything but the field control - so no label, help text, validation error, etc.",
|
|
3949
|
+
advanced: true
|
|
3950
|
+
},
|
|
3951
|
+
preserve: {
|
|
3952
|
+
type: "boolean",
|
|
3953
|
+
advanced: true,
|
|
3954
|
+
defaultValueHint: true,
|
|
3955
|
+
description: "Keep field value even when field removed."
|
|
3956
|
+
}
|
|
3957
|
+
};
|
|
3958
|
+
}
|
|
3853
3959
|
const commonSimplifiedFormArrayItemType = (propName) => ({
|
|
3854
3960
|
type: "object",
|
|
3855
3961
|
fields: __spreadValues$d({
|