@plasmicpkgs/antd5 0.0.190 → 0.0.192
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 +49 -5
- package/dist/antd.esm.js.map +1 -1
- package/dist/form/Form.d.ts +2 -0
- package/dist/index.js +49 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/skinny/Form.cjs.js +25 -5
- package/skinny/Form.cjs.js.map +1 -1
- package/skinny/Form.esm.js +25 -5
- package/skinny/Form.esm.js.map +1 -1
- package/skinny/registerForm.cjs.js +24 -0
- package/skinny/registerForm.cjs.js.map +1 -1
- package/skinny/registerForm.esm.js +24 -0
- package/skinny/registerForm.esm.js.map +1 -1
package/dist/form/Form.d.ts
CHANGED
|
@@ -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
|
-
(
|
|
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: {
|