@plasmicpkgs/antd5 0.0.191 → 0.0.193

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.
@@ -59,6 +59,8 @@ export interface FormWrapperProps extends FormProps, CanvasComponentProps<FormWr
59
59
  formType?: "new-entry" | "update-entry";
60
60
  submitSlot?: React.ReactNode;
61
61
  data?: DataOp;
62
+ autoDisableWhileSubmitting?: boolean;
63
+ onIsSubmittingChange?: (isSubmitting: boolean) => void;
62
64
  }
63
65
  export interface FormRefActions extends Pick<FormInstance<any>, "setFieldsValue" | "resetFields" | "setFieldValue" | "validateFields"> {
64
66
  clearFields: () => void;
package/dist/index.js CHANGED
@@ -256,6 +256,7 @@ var FormType = /* @__PURE__ */ ((FormType2) => {
256
256
  const Internal = React__default.default.forwardRef(
257
257
  (props, ref) => {
258
258
  var _b, _c, _d, _e;
259
+ const [isSubmitting, setIsSubmitting] = React__default.default.useState(false);
259
260
  const [form] = antd.Form.useForm();
260
261
  const values = form.getFieldsValue(true);
261
262
  const lastValue = React__default.default.useRef(values);
@@ -264,13 +265,15 @@ const Internal = React__default.default.forwardRef(
264
265
  forceRemount,
265
266
  formLayout,
266
267
  internalFieldCtx,
267
- setInternalFieldCtx
268
+ setInternalFieldCtx,
269
+ autoDisableWhileSubmitting = true
268
270
  } = _a, rest = __objRest$o(_a, [
269
271
  "extendedOnValuesChange",
270
272
  "forceRemount",
271
273
  "formLayout",
272
274
  "internalFieldCtx",
273
- "setInternalFieldCtx"
275
+ "setInternalFieldCtx",
276
+ "autoDisableWhileSubmitting"
274
277
  ]);
275
278
  const childrenNode = typeof props.children === "function" ? props.children(values, form) : props.children;
276
279
  const fireOnValuesChange = React__default.default.useCallback(() => {
@@ -339,6 +342,14 @@ const Internal = React__default.default.forwardRef(
339
342
  layout: formLayout,
340
343
  internalFieldCtx
341
344
  }, schemaFormCtx ? schemaFormCtx : {}));
345
+ const updateIsSubmitting = React__default.default.useCallback(
346
+ (newValue) => {
347
+ var _a2;
348
+ setIsSubmitting(newValue);
349
+ (_a2 = props.onIsSubmittingChange) == null ? void 0 : _a2.call(props, newValue);
350
+ },
351
+ [props.onIsSubmittingChange, setIsSubmitting]
352
+ );
342
353
  return /* @__PURE__ */ React__default.default.createElement(
343
354
  InternalFormInstanceContext.Provider,
344
355
  {
@@ -360,9 +371,13 @@ const Internal = React__default.default.forwardRef(
360
371
  (_a2 = props.onValuesChange) == null ? void 0 : _a2.call(props, ...args);
361
372
  extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(form.getFieldsValue(true));
362
373
  },
363
- onFinish: () => {
374
+ onFinish: async () => {
364
375
  var _a2;
365
- (_a2 = props.onFinish) == null ? void 0 : _a2.call(
376
+ if (isSubmitting && autoDisableWhileSubmitting) {
377
+ return;
378
+ }
379
+ updateIsSubmitting(true);
380
+ const submission = (_a2 = props.onFinish) == null ? void 0 : _a2.call(
366
381
  props,
367
382
  pick(
368
383
  form.getFieldsValue(true),
@@ -371,10 +386,15 @@ const Internal = React__default.default.forwardRef(
371
386
  )
372
387
  )
373
388
  );
389
+ if (typeof submission === "object" && typeof submission.then === "function") {
390
+ await submission;
391
+ }
392
+ updateIsSubmitting(false);
374
393
  },
375
394
  form,
376
395
  labelCol: ((_d = props.labelCol) == null ? void 0 : _d.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
377
- wrapperCol: ((_e = props.wrapperCol) == null ? void 0 : _e.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
396
+ wrapperCol: ((_e = props.wrapperCol) == null ? void 0 : _e.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol,
397
+ disabled: isSubmitting && autoDisableWhileSubmitting
378
398
  }),
379
399
  /* @__PURE__ */ React__default.default.createElement("style", null, `
380
400
  .ant-form-item-explain + div, .ant-form-item-margin-offset {
@@ -2746,6 +2766,24 @@ function registerForm(loader) {
2746
2766
  multiSelect: true,
2747
2767
  defaultValueHint: ["onChange"],
2748
2768
  advanced: true
2769
+ },
2770
+ autoDisableWhileSubmitting: {
2771
+ displayName: "Auto disable while submitting",
2772
+ type: "boolean",
2773
+ defaultValueHint: true,
2774
+ advanced: true,
2775
+ description: "When disabled, it allows the creation of new submissions even while existing submissions are in progress."
2776
+ },
2777
+ onIsSubmittingChange: {
2778
+ type: "eventHandler",
2779
+ displayName: "On Is Submitting Change",
2780
+ argTypes: [
2781
+ {
2782
+ name: "isSubmitting",
2783
+ type: "boolean"
2784
+ }
2785
+ ],
2786
+ advanced: true
2749
2787
  }
2750
2788
  },
2751
2789
  actions: [
@@ -2760,6 +2798,12 @@ function registerForm(loader) {
2760
2798
  type: "readonly",
2761
2799
  variableType: "object",
2762
2800
  onChangeProp: "extendedOnValuesChange"
2801
+ },
2802
+ isSubmitting: {
2803
+ type: "readonly",
2804
+ variableType: "boolean",
2805
+ onChangeProp: "onIsSubmittingChange",
2806
+ initVal: false
2763
2807
  }
2764
2808
  },
2765
2809
  componentHelpers: {
@@ -5693,6 +5737,7 @@ function registerInput(loader) {
5693
5737
  registerComponentHelper(loader, AntdInput, __spreadProps$6(__spreadValues$e({
5694
5738
  name: inputComponentName,
5695
5739
  displayName: "Input",
5740
+ styleSections: false,
5696
5741
  props: __spreadValues$e(__spreadValues$e(__spreadValues$e({
5697
5742
  value: {
5698
5743
  type: "string",
@@ -5726,6 +5771,7 @@ function registerTextArea(loader) {
5726
5771
  name: textAreaComponentName,
5727
5772
  parentComponentName: inputComponentName,
5728
5773
  displayName: "Text Area",
5774
+ styleSections: false,
5729
5775
  props: __spreadValues$e({
5730
5776
  value: {
5731
5777
  type: "string",
@@ -5762,6 +5808,7 @@ function registerPasswordInput(loader) {
5762
5808
  name: passwordComponentName,
5763
5809
  parentComponentName: inputComponentName,
5764
5810
  displayName: "Password Input",
5811
+ styleSections: false,
5765
5812
  props: __spreadValues$e({
5766
5813
  value: {
5767
5814
  type: "string",
@@ -5794,6 +5841,7 @@ function registerNumberInput(loader) {
5794
5841
  name: inputNumberComponentName,
5795
5842
  parentComponentName: inputComponentName,
5796
5843
  displayName: "Number Input",
5844
+ styleSections: false,
5797
5845
  props: __spreadProps$6(__spreadValues$e(__spreadValues$e(__spreadValues$e({
5798
5846
  value: {
5799
5847
  type: "number",