@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.
package/dist/antd.esm.js CHANGED
@@ -239,6 +239,7 @@ var FormType = /* @__PURE__ */ ((FormType2) => {
239
239
  const Internal = React.forwardRef(
240
240
  (props, ref) => {
241
241
  var _b, _c, _d, _e;
242
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
242
243
  const [form] = Form.useForm();
243
244
  const values = form.getFieldsValue(true);
244
245
  const lastValue = React.useRef(values);
@@ -247,13 +248,15 @@ const Internal = React.forwardRef(
247
248
  forceRemount,
248
249
  formLayout,
249
250
  internalFieldCtx,
250
- setInternalFieldCtx
251
+ setInternalFieldCtx,
252
+ autoDisableWhileSubmitting = true
251
253
  } = _a, rest = __objRest$o(_a, [
252
254
  "extendedOnValuesChange",
253
255
  "forceRemount",
254
256
  "formLayout",
255
257
  "internalFieldCtx",
256
- "setInternalFieldCtx"
258
+ "setInternalFieldCtx",
259
+ "autoDisableWhileSubmitting"
257
260
  ]);
258
261
  const childrenNode = typeof props.children === "function" ? props.children(values, form) : props.children;
259
262
  const fireOnValuesChange = React.useCallback(() => {
@@ -322,6 +325,14 @@ const Internal = React.forwardRef(
322
325
  layout: formLayout,
323
326
  internalFieldCtx
324
327
  }, schemaFormCtx ? schemaFormCtx : {}));
328
+ const updateIsSubmitting = React.useCallback(
329
+ (newValue) => {
330
+ var _a2;
331
+ setIsSubmitting(newValue);
332
+ (_a2 = props.onIsSubmittingChange) == null ? void 0 : _a2.call(props, newValue);
333
+ },
334
+ [props.onIsSubmittingChange, setIsSubmitting]
335
+ );
325
336
  return /* @__PURE__ */ React.createElement(
326
337
  InternalFormInstanceContext.Provider,
327
338
  {
@@ -343,9 +354,13 @@ const Internal = React.forwardRef(
343
354
  (_a2 = props.onValuesChange) == null ? void 0 : _a2.call(props, ...args);
344
355
  extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(form.getFieldsValue(true));
345
356
  },
346
- onFinish: () => {
357
+ onFinish: async () => {
347
358
  var _a2;
348
- (_a2 = props.onFinish) == null ? void 0 : _a2.call(
359
+ if (isSubmitting && autoDisableWhileSubmitting) {
360
+ return;
361
+ }
362
+ updateIsSubmitting(true);
363
+ const submission = (_a2 = props.onFinish) == null ? void 0 : _a2.call(
349
364
  props,
350
365
  pick(
351
366
  form.getFieldsValue(true),
@@ -354,10 +369,15 @@ const Internal = React.forwardRef(
354
369
  )
355
370
  )
356
371
  );
372
+ if (typeof submission === "object" && typeof submission.then === "function") {
373
+ await submission;
374
+ }
375
+ updateIsSubmitting(false);
357
376
  },
358
377
  form,
359
378
  labelCol: ((_d = props.labelCol) == null ? void 0 : _d.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
360
- wrapperCol: ((_e = props.wrapperCol) == null ? void 0 : _e.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
379
+ wrapperCol: ((_e = props.wrapperCol) == null ? void 0 : _e.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol,
380
+ disabled: isSubmitting && autoDisableWhileSubmitting
361
381
  }),
362
382
  /* @__PURE__ */ React.createElement("style", null, `
363
383
  .ant-form-item-explain + div, .ant-form-item-margin-offset {
@@ -2729,6 +2749,24 @@ function registerForm(loader) {
2729
2749
  multiSelect: true,
2730
2750
  defaultValueHint: ["onChange"],
2731
2751
  advanced: true
2752
+ },
2753
+ autoDisableWhileSubmitting: {
2754
+ displayName: "Auto disable while submitting",
2755
+ type: "boolean",
2756
+ defaultValueHint: true,
2757
+ advanced: true,
2758
+ description: "When disabled, it allows the creation of new submissions even while existing submissions are in progress."
2759
+ },
2760
+ onIsSubmittingChange: {
2761
+ type: "eventHandler",
2762
+ displayName: "On Is Submitting Change",
2763
+ argTypes: [
2764
+ {
2765
+ name: "isSubmitting",
2766
+ type: "boolean"
2767
+ }
2768
+ ],
2769
+ advanced: true
2732
2770
  }
2733
2771
  },
2734
2772
  actions: [
@@ -2743,6 +2781,12 @@ function registerForm(loader) {
2743
2781
  type: "readonly",
2744
2782
  variableType: "object",
2745
2783
  onChangeProp: "extendedOnValuesChange"
2784
+ },
2785
+ isSubmitting: {
2786
+ type: "readonly",
2787
+ variableType: "boolean",
2788
+ onChangeProp: "onIsSubmittingChange",
2789
+ initVal: false
2746
2790
  }
2747
2791
  },
2748
2792
  componentHelpers: {
@@ -5676,6 +5720,7 @@ function registerInput(loader) {
5676
5720
  registerComponentHelper(loader, AntdInput, __spreadProps$6(__spreadValues$e({
5677
5721
  name: inputComponentName,
5678
5722
  displayName: "Input",
5723
+ styleSections: false,
5679
5724
  props: __spreadValues$e(__spreadValues$e(__spreadValues$e({
5680
5725
  value: {
5681
5726
  type: "string",
@@ -5709,6 +5754,7 @@ function registerTextArea(loader) {
5709
5754
  name: textAreaComponentName,
5710
5755
  parentComponentName: inputComponentName,
5711
5756
  displayName: "Text Area",
5757
+ styleSections: false,
5712
5758
  props: __spreadValues$e({
5713
5759
  value: {
5714
5760
  type: "string",
@@ -5745,6 +5791,7 @@ function registerPasswordInput(loader) {
5745
5791
  name: passwordComponentName,
5746
5792
  parentComponentName: inputComponentName,
5747
5793
  displayName: "Password Input",
5794
+ styleSections: false,
5748
5795
  props: __spreadValues$e({
5749
5796
  value: {
5750
5797
  type: "string",
@@ -5777,6 +5824,7 @@ function registerNumberInput(loader) {
5777
5824
  name: inputNumberComponentName,
5778
5825
  parentComponentName: inputComponentName,
5779
5826
  displayName: "Number Input",
5827
+ styleSections: false,
5780
5828
  props: __spreadProps$6(__spreadValues$e(__spreadValues$e(__spreadValues$e({
5781
5829
  value: {
5782
5830
  type: "number",