@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.
Files changed (70) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/antd.esm.js +339 -233
  3. package/dist/antd.esm.js.map +1 -1
  4. package/dist/index.js +339 -233
  5. package/dist/index.js.map +1 -1
  6. package/dist/registerForm.d.ts +18 -15
  7. package/dist/utils.d.ts +2 -1
  8. package/package.json +2 -2
  9. package/skinny/registerAvatar.cjs.js +1 -1
  10. package/skinny/registerAvatar.esm.js +1 -1
  11. package/skinny/registerButton.cjs.js +1 -1
  12. package/skinny/registerButton.esm.js +1 -1
  13. package/skinny/registerCheckbox.cjs.js +1 -1
  14. package/skinny/registerCheckbox.esm.js +1 -1
  15. package/skinny/registerCollapse.cjs.js +1 -1
  16. package/skinny/registerCollapse.esm.js +1 -1
  17. package/skinny/registerColorPicker.cjs.js +1 -1
  18. package/skinny/registerColorPicker.esm.js +1 -1
  19. package/skinny/registerConfigProvider.cjs.js +1 -1
  20. package/skinny/registerConfigProvider.esm.js +1 -1
  21. package/skinny/registerDatePicker.cjs.js +1 -1
  22. package/skinny/registerDatePicker.esm.js +1 -1
  23. package/skinny/registerDrawer.cjs.js +1 -1
  24. package/skinny/registerDrawer.esm.js +1 -1
  25. package/skinny/registerDropdown.cjs.js +1 -1
  26. package/skinny/registerDropdown.esm.js +1 -1
  27. package/skinny/registerForm.cjs.js +304 -230
  28. package/skinny/registerForm.cjs.js.map +1 -1
  29. package/skinny/registerForm.d.ts +18 -15
  30. package/skinny/registerForm.esm.js +304 -230
  31. package/skinny/registerForm.esm.js.map +1 -1
  32. package/skinny/registerInput.cjs.js +1 -1
  33. package/skinny/registerInput.esm.js +1 -1
  34. package/skinny/registerMenu.cjs.js +1 -1
  35. package/skinny/registerMenu.esm.js +1 -1
  36. package/skinny/registerModal.cjs.js +1 -1
  37. package/skinny/registerModal.esm.js +1 -1
  38. package/skinny/registerPopover.cjs.js +1 -1
  39. package/skinny/registerPopover.esm.js +1 -1
  40. package/skinny/registerRadio.cjs.js +1 -1
  41. package/skinny/registerRadio.esm.js +1 -1
  42. package/skinny/registerRate.cjs.js +1 -1
  43. package/skinny/registerRate.esm.js +1 -1
  44. package/skinny/{registerSelect-3273fe93.esm.js → registerSelect-d2c8e1c0.esm.js} +2 -2
  45. package/skinny/{registerSelect-3273fe93.esm.js.map → registerSelect-d2c8e1c0.esm.js.map} +1 -1
  46. package/skinny/{registerSelect-f0e24345.cjs.js → registerSelect-dfdd1699.cjs.js} +2 -2
  47. package/skinny/{registerSelect-f0e24345.cjs.js.map → registerSelect-dfdd1699.cjs.js.map} +1 -1
  48. package/skinny/registerSelect.cjs.js +2 -2
  49. package/skinny/registerSelect.esm.js +2 -2
  50. package/skinny/registerSteps.cjs.js +1 -1
  51. package/skinny/registerSteps.esm.js +1 -1
  52. package/skinny/registerSwitch.cjs.js +1 -1
  53. package/skinny/registerSwitch.esm.js +1 -1
  54. package/skinny/registerTable.cjs.js +1 -1
  55. package/skinny/registerTable.esm.js +1 -1
  56. package/skinny/registerTabs.cjs.js +1 -1
  57. package/skinny/registerTabs.esm.js +1 -1
  58. package/skinny/registerTooltip.cjs.js +1 -1
  59. package/skinny/registerTooltip.esm.js +1 -1
  60. package/skinny/registerTree.cjs.js +1 -1
  61. package/skinny/registerTree.esm.js +1 -1
  62. package/skinny/registerUpload.cjs.js +1 -1
  63. package/skinny/registerUpload.esm.js +1 -1
  64. package/skinny/{utils-c2d6f0e8.cjs.js → utils-174b9d45.cjs.js} +39 -6
  65. package/skinny/utils-174b9d45.cjs.js.map +1 -0
  66. package/skinny/{utils-040cbe4d.esm.js → utils-7d8f2418.esm.js} +39 -7
  67. package/skinny/utils-7d8f2418.esm.js.map +1 -0
  68. package/skinny/utils.d.ts +2 -1
  69. package/skinny/utils-040cbe4d.esm.js.map +0 -1
  70. 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
- function get(obj, key, def, undef) {
130
- key = key.split ? key.split(".") : key;
131
- for (let p = 0; p < key.length; p++) {
132
- obj = obj ? obj[key[p]] : undef;
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 obj === undef ? def : obj;
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, _f;
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
- setRegisteredFields,
2774
- registeredFields
2805
+ formLayout,
2806
+ internalFieldCtx,
2807
+ setInternalFieldCtx
2775
2808
  } = _a, rest = __objRest$a(_a, [
2776
2809
  "extendedOnValuesChange",
2777
2810
  "forceRemount",
2778
- "setRegisteredFields",
2779
- "registeredFields"
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((fieldEntity) => {
2861
- setRegisteredFields((f) => [...f, fieldEntity]);
2862
- return () => {
2863
- setRegisteredFields((f) => f.filter((ent) => ent !== fieldEntity));
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
- registeredFields,
2875
- initialValues: (_d = props.initialValues) != null ? _d : {}
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(props, form.getFieldsValue(true));
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: ((_e = props.labelCol) == null ? void 0 : _e.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
2893
- wrapperCol: ((_f = props.wrapperCol) == null ? void 0 : _f.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.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, registeredFields) {
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
- registeredFields
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
- registeredFields
2943
- });
2988
+ formInstance
2989
+ }, commonFormCtxData));
2944
2990
  return mergedFields;
2945
- }, [mode, setControlContextData, dataFormItems, rawData, formInstance]);
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 [registeredFields, setRegisteredFields] = React.useState([]);
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
- registeredFields
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 _a = props, { dataFormItems, formItems, data } = _a, rest = __objRest$a(_a, ["dataFormItems", "formItems", "data"]);
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
- setRegisteredFields,
3008
- registeredFields,
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
- const fullPath = React.useContext(PathContext).fullPath;
3522
- const internalFormCtx = React.useContext(InternalFormInstanceContext);
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
- }, [form, props.initialValue, fullFormItemName]);
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
- const commonFormItemProps = (usage) => ({
3675
- name: {
3676
- type: "string",
3677
- required: true,
3678
- validator: (value, _props, ctx) => {
3679
- var _a, _b, _c;
3680
- const currFullPath = [...(_a = ctx == null ? void 0 : ctx.parentFormItemPath) != null ? _a : [], value];
3681
- const nameCounter = ((_c = (_b = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _b.registeredFields) != null ? _c : []).filter(
3682
- (formItem) => arrayEq(formItem.fullPath, currFullPath)
3683
- ).length;
3684
- return nameCounter === 1 ? true : `Repeated form item name: ${currFullPath.join(" \u2192 ")}`;
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
- defaultValueHint: getDefaultValueHint("name")
3687
- },
3688
- initialValue: {
3689
- type: "dynamic",
3690
- control: (ps, ctx, {
3691
- item,
3692
- path
3693
- }) => {
3694
- var _a, _b, _c, _d;
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
- } else if (path != null && typeof path[1] === "number") {
3701
- inputType = (_b = (_a = ctx == null ? void 0 : ctx.mergedFields) == null ? void 0 : _a[path[1]].inputType) != null ? _b : "Unkown" /* Unknown */;
3702
- }
3703
- } else {
3704
- if (!React.isValidElement(ps.children) || typeof ps.children.type === "string") {
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 (mapAntdComponentToInputType.has(ps.children.type)) {
3708
- inputType = (_c = mapAntdComponentToInputType.get(ps.children.type)) != null ? _c : "Unkown" /* Unknown */;
3709
- } else if ("__plumeType" in ps.children.type) {
3710
- inputType = (_d = mapPlumeTypeToInputType.get(
3711
- ps.children.type.__plumeType
3712
- )) != null ? _d : "Unkown" /* Unknown */;
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
- if ([
3717
- "Text" /* Text */,
3718
- "Text Area" /* TextArea */,
3719
- "Password" /* Password */,
3720
- "Select" /* Select */,
3721
- "Radio Group" /* RadioGroup */
3722
- ].includes(inputType)) {
3723
- return {
3724
- type: "string",
3725
- defaultValueHint: getDefaultValueHint("initialValue")
3726
- };
3727
- } else if ("Number" /* Number */ === inputType) {
3728
- return {
3729
- type: "number",
3730
- defaultValueHint: getDefaultValueHint("initialValue")
3731
- };
3732
- } else if ("Checkbox" /* Checkbox */ === inputType) {
3733
- return {
3734
- type: "boolean",
3735
- defaultValueHint: getDefaultValueHint("initialValue")
3736
- };
3737
- } else if ("DatePicker" /* DatePicker */ === inputType) {
3738
- return {
3739
- type: "dateString",
3740
- defaultValueHint: getDefaultValueHint("initialValue")
3741
- };
3742
- } else {
3743
- return {
3744
- type: "exprEditor",
3745
- defaultValueHint: getDefaultValueHint("initialValue")
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
- defaultValueHint: true
3780
- },
3781
- colon: {
3782
- type: "boolean",
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
- advanced: true
3839
- },
3840
- noStyle: {
3841
- type: "boolean",
3842
- displayName: "Field control only",
3843
- description: "Don't render anything but the field control - so no label, help text, validation error, etc.",
3844
- advanced: true
3845
- },
3846
- preserve: {
3847
- type: "boolean",
3848
- advanced: true,
3849
- defaultValueHint: true,
3850
- description: "Keep field value even when field removed."
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({