@plasmicpkgs/antd5 0.0.54 → 0.0.55
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 +250 -115
- package/dist/antd.esm.js.map +1 -1
- package/dist/index.js +250 -115
- package/dist/index.js.map +1 -1
- package/dist/registerForm.d.ts +9 -1
- package/package.json +2 -2
- 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/registerConfigProvider.cjs.js +1 -1
- package/skinny/registerConfigProvider.esm.js +1 -1
- package/skinny/registerDropdown.cjs.js +1 -1
- package/skinny/registerDropdown.esm.js +1 -1
- package/skinny/registerForm.cjs.js +227 -97
- package/skinny/registerForm.cjs.js.map +1 -1
- package/skinny/registerForm.d.ts +9 -1
- package/skinny/registerForm.esm.js +227 -97
- 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/registerRadio.cjs.js +25 -8
- package/skinny/registerRadio.cjs.js.map +1 -1
- package/skinny/registerRadio.esm.js +25 -8
- package/skinny/registerRadio.esm.js.map +1 -1
- package/skinny/registerSelect.cjs.js +1 -1
- package/skinny/registerSelect.esm.js +1 -1
- package/skinny/registerTable.cjs.js +1 -1
- package/skinny/registerTable.esm.js +1 -1
- package/skinny/registerUpload.cjs.js +1 -1
- package/skinny/registerUpload.esm.js +1 -1
- package/skinny/{utils-dff55ae0.cjs.js → utils-2d964db8.cjs.js} +1 -14
- package/skinny/{utils-dff55ae0.cjs.js.map → utils-2d964db8.cjs.js.map} +1 -1
- package/skinny/{utils-94b1c934.esm.js → utils-d0e80a56.esm.js} +2 -14
- package/skinny/{utils-94b1c934.esm.js.map → utils-d0e80a56.esm.js.map} +1 -1
|
@@ -3,7 +3,7 @@ import { Form } from 'antd';
|
|
|
3
3
|
import equal from 'fast-deep-equal';
|
|
4
4
|
import React, { isValidElement, cloneElement } from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { u as usePrevious, r as registerComponentHelper
|
|
6
|
+
import { u as usePrevious, r as registerComponentHelper } from './utils-d0e80a56.esm.js';
|
|
7
7
|
import '@plasmicapp/host/registerComponent';
|
|
8
8
|
import '@plasmicapp/host/registerGlobalContext';
|
|
9
9
|
|
|
@@ -141,8 +141,9 @@ const FormItem = Form.Item;
|
|
|
141
141
|
const FormList = Form.List;
|
|
142
142
|
const PathContext = React.createContext({ relativePath: [], fullPath: [] });
|
|
143
143
|
const InternalFormInstanceContext = React.createContext(void 0);
|
|
144
|
+
const FormLayoutContext = React.createContext(void 0);
|
|
144
145
|
const Internal = (props) => {
|
|
145
|
-
var _b, _c;
|
|
146
|
+
var _b, _c, _d;
|
|
146
147
|
const [form] = Form.useForm();
|
|
147
148
|
const values = form.getFieldsValue(true);
|
|
148
149
|
const lastValue = React.useRef(values);
|
|
@@ -158,15 +159,26 @@ const Internal = (props) => {
|
|
|
158
159
|
React.useEffect(() => {
|
|
159
160
|
fireOnValuesChange();
|
|
160
161
|
}, []);
|
|
162
|
+
const formLayout = React.useMemo(
|
|
163
|
+
() => {
|
|
164
|
+
var _a2;
|
|
165
|
+
return {
|
|
166
|
+
layout: props.layout,
|
|
167
|
+
labelSpan: (_a2 = props.labelCol) == null ? void 0 : _a2.span
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
[props.layout, (_b = props.labelCol) == null ? void 0 : _b.span]
|
|
171
|
+
);
|
|
161
172
|
return /* @__PURE__ */ React.createElement(
|
|
162
173
|
InternalFormInstanceContext.Provider,
|
|
163
174
|
{
|
|
164
175
|
value: {
|
|
176
|
+
layout: formLayout,
|
|
165
177
|
fireOnValuesChange,
|
|
166
178
|
forceRemount: () => setRemountKey((k) => k + 1)
|
|
167
179
|
}
|
|
168
180
|
},
|
|
169
|
-
/* @__PURE__ */ React.createElement(
|
|
181
|
+
/* @__PURE__ */ React.createElement(FormLayoutContext.Provider, { value: formLayout }, /* @__PURE__ */ React.createElement(
|
|
170
182
|
Form,
|
|
171
183
|
__spreadProps(__spreadValues({}, rest), {
|
|
172
184
|
key: props.initialValues ? JSON.stringify(props.initialValues) : void 0,
|
|
@@ -176,16 +188,16 @@ const Internal = (props) => {
|
|
|
176
188
|
extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(args[1]);
|
|
177
189
|
},
|
|
178
190
|
form,
|
|
179
|
-
labelCol: ((
|
|
180
|
-
wrapperCol: ((
|
|
191
|
+
labelCol: ((_c = props.labelCol) == null ? void 0 : _c.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
|
|
192
|
+
wrapperCol: ((_d = props.wrapperCol) == null ? void 0 : _d.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
|
|
181
193
|
}),
|
|
182
194
|
/* @__PURE__ */ React.createElement("style", null, `
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
.ant-form-item-explain + div, .ant-form-item-margin-offset {
|
|
196
|
+
display: none;
|
|
197
|
+
}
|
|
198
|
+
`),
|
|
187
199
|
childrenNode
|
|
188
|
-
)
|
|
200
|
+
))
|
|
189
201
|
);
|
|
190
202
|
};
|
|
191
203
|
function FormWrapper(props) {
|
|
@@ -239,40 +251,41 @@ const COMMON_ACTIONS = [
|
|
|
239
251
|
// },
|
|
240
252
|
// },
|
|
241
253
|
];
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
max: 24
|
|
254
|
-
},
|
|
255
|
-
offset: {
|
|
256
|
-
type: "number",
|
|
257
|
-
displayName: "Offset columns",
|
|
258
|
-
description: "Number of grid columns to skip from the left",
|
|
259
|
-
min: 0,
|
|
260
|
-
max: 23
|
|
261
|
-
},
|
|
262
|
-
horizontalOnly: {
|
|
263
|
-
type: "boolean",
|
|
264
|
-
displayName: "Horizontal only",
|
|
265
|
-
description: "Only apply to horizontal layout"
|
|
266
|
-
}
|
|
254
|
+
const colProp = (displayName, defaultValue, description) => ({
|
|
255
|
+
type: "object",
|
|
256
|
+
displayName,
|
|
257
|
+
advanced: true,
|
|
258
|
+
fields: {
|
|
259
|
+
span: {
|
|
260
|
+
type: "number",
|
|
261
|
+
displayName: "Width",
|
|
262
|
+
description: "The number of grid columns to span in width (out of 24 columns total)",
|
|
263
|
+
min: 1,
|
|
264
|
+
max: 24
|
|
267
265
|
},
|
|
268
|
-
|
|
269
|
-
|
|
266
|
+
offset: {
|
|
267
|
+
type: "number",
|
|
268
|
+
displayName: "Offset",
|
|
269
|
+
description: "Number of grid columns to skip from the left (out of 24 columns total)",
|
|
270
|
+
min: 0,
|
|
271
|
+
max: 23
|
|
272
|
+
},
|
|
273
|
+
horizontalOnly: {
|
|
274
|
+
type: "boolean",
|
|
275
|
+
displayName: "Horizontal only",
|
|
276
|
+
description: "Only apply to horizontal layout"
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
description,
|
|
280
|
+
defaultValue
|
|
281
|
+
});
|
|
282
|
+
function registerForm(loader) {
|
|
270
283
|
registerComponentHelper(loader, FormWrapper, {
|
|
271
284
|
name: "plasmic-antd5-form",
|
|
272
285
|
displayName: "Form",
|
|
273
286
|
defaultStyles: {
|
|
274
|
-
|
|
275
|
-
|
|
287
|
+
layout: "vbox",
|
|
288
|
+
alignItems: "flex-start"
|
|
276
289
|
},
|
|
277
290
|
props: {
|
|
278
291
|
children: {
|
|
@@ -310,13 +323,21 @@ function registerForm(loader) {
|
|
|
310
323
|
},
|
|
311
324
|
{
|
|
312
325
|
type: "component",
|
|
313
|
-
name: "plasmic-antd5-
|
|
326
|
+
name: "plasmic-antd5-form-item",
|
|
314
327
|
props: {
|
|
328
|
+
noLabel: true,
|
|
315
329
|
children: {
|
|
316
|
-
type: "
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
330
|
+
type: "component",
|
|
331
|
+
name: "plasmic-antd5-button",
|
|
332
|
+
props: {
|
|
333
|
+
children: {
|
|
334
|
+
type: "text",
|
|
335
|
+
value: "Submit"
|
|
336
|
+
},
|
|
337
|
+
type: "primary",
|
|
338
|
+
submitsForm: true
|
|
339
|
+
}
|
|
340
|
+
}
|
|
320
341
|
}
|
|
321
342
|
}
|
|
322
343
|
]
|
|
@@ -333,16 +354,25 @@ function registerForm(loader) {
|
|
|
333
354
|
type: "choice",
|
|
334
355
|
options: ["left", "right"],
|
|
335
356
|
defaultValueHint: "right",
|
|
336
|
-
advanced: true
|
|
357
|
+
advanced: true,
|
|
358
|
+
hidden: (ps) => ps.layout !== "horizontal"
|
|
337
359
|
},
|
|
338
|
-
labelCol: colProp(
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
360
|
+
labelCol: colProp(
|
|
361
|
+
"Label layout",
|
|
362
|
+
{
|
|
363
|
+
span: 8,
|
|
364
|
+
horizontalOnly: true
|
|
365
|
+
},
|
|
366
|
+
"Set the width and offset of the labels"
|
|
367
|
+
),
|
|
368
|
+
wrapperCol: colProp(
|
|
369
|
+
"Control layout",
|
|
370
|
+
{
|
|
371
|
+
span: 16,
|
|
372
|
+
horizontalOnly: true
|
|
373
|
+
},
|
|
374
|
+
"Set the width and offset of the form controls"
|
|
375
|
+
),
|
|
346
376
|
colon: {
|
|
347
377
|
type: "boolean",
|
|
348
378
|
description: `Show a colon after labels by default (only for horizontal layout)`,
|
|
@@ -495,14 +525,34 @@ function useFormInstanceMaybe() {
|
|
|
495
525
|
return Form.useFormInstance();
|
|
496
526
|
}
|
|
497
527
|
function FormItemWrapper(props) {
|
|
498
|
-
var
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
528
|
+
var _b;
|
|
529
|
+
const _a = props, {
|
|
530
|
+
rules: plasmicRules,
|
|
531
|
+
description,
|
|
532
|
+
noLabel,
|
|
533
|
+
name,
|
|
534
|
+
hideValidationMessage,
|
|
535
|
+
customizeProps,
|
|
536
|
+
setControlContextData,
|
|
537
|
+
alignLabellessWithControls = true
|
|
538
|
+
} = _a, rest = __objRest(_a, [
|
|
539
|
+
"rules",
|
|
540
|
+
"description",
|
|
541
|
+
"noLabel",
|
|
542
|
+
"name",
|
|
543
|
+
"hideValidationMessage",
|
|
544
|
+
"customizeProps",
|
|
545
|
+
"setControlContextData",
|
|
546
|
+
"alignLabellessWithControls"
|
|
547
|
+
]);
|
|
548
|
+
const relativeFormItemName = useFormItemRelativeName(name);
|
|
549
|
+
const fullFormItemName = useFormItemFullName(name);
|
|
550
|
+
const bestEffortLabel = !noLabel && reactNodeToString(props.label) || ensureArray(props.name).slice(-1)[0];
|
|
551
|
+
const rules = plasmicRules ? plasmicRulesToAntdRules(
|
|
552
|
+
plasmicRules,
|
|
504
553
|
typeof bestEffortLabel === "number" ? "" + bestEffortLabel : bestEffortLabel
|
|
505
554
|
) : void 0;
|
|
555
|
+
const layoutContext = React.useContext(FormLayoutContext);
|
|
506
556
|
const inCanvas = !!usePlasmicCanvasContext();
|
|
507
557
|
if (inCanvas) {
|
|
508
558
|
const form = useFormInstanceMaybe();
|
|
@@ -512,7 +562,7 @@ function FormItemWrapper(props) {
|
|
|
512
562
|
});
|
|
513
563
|
const internalFormCtx = React.useContext(InternalFormInstanceContext);
|
|
514
564
|
const { fireOnValuesChange, forceRemount } = internalFormCtx != null ? internalFormCtx : {};
|
|
515
|
-
(
|
|
565
|
+
(_b = props.setControlContextData) == null ? void 0 : _b.call(props, {
|
|
516
566
|
internalFormCtx
|
|
517
567
|
});
|
|
518
568
|
React.useEffect(() => {
|
|
@@ -529,14 +579,15 @@ function FormItemWrapper(props) {
|
|
|
529
579
|
}
|
|
530
580
|
return /* @__PURE__ */ React.createElement(
|
|
531
581
|
FormItem,
|
|
532
|
-
|
|
533
|
-
label:
|
|
582
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
583
|
+
label: noLabel ? void 0 : props.label,
|
|
534
584
|
name: relativeFormItemName,
|
|
535
|
-
rules
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
585
|
+
rules,
|
|
586
|
+
extra: description,
|
|
587
|
+
help: hideValidationMessage ? "" : props.help,
|
|
588
|
+
colon: noLabel ? false : void 0,
|
|
589
|
+
wrapperCol: (layoutContext == null ? void 0 : layoutContext.layout) === "horizontal" && noLabel && alignLabellessWithControls && layoutContext.labelSpan ? { offset: layoutContext.labelSpan } : void 0
|
|
590
|
+
}),
|
|
540
591
|
props.customizeProps ? /* @__PURE__ */ React.createElement(FormItemForwarder, { formItemProps: props }) : props.children
|
|
541
592
|
);
|
|
542
593
|
}
|
|
@@ -566,13 +617,18 @@ function registerFormItem(loader) {
|
|
|
566
617
|
name: "plasmic-antd5-form-item",
|
|
567
618
|
displayName: "Form Item",
|
|
568
619
|
parentComponentName: "plasmic-antd5-form",
|
|
620
|
+
defaultStyles: {
|
|
621
|
+
marginBottom: "24px",
|
|
622
|
+
width: "stretch"
|
|
623
|
+
},
|
|
569
624
|
props: {
|
|
570
625
|
label: {
|
|
571
626
|
type: "slot",
|
|
572
627
|
defaultValue: {
|
|
573
628
|
type: "text",
|
|
574
629
|
value: "Label"
|
|
575
|
-
}
|
|
630
|
+
},
|
|
631
|
+
hidden: (ps) => !!ps.noLabel
|
|
576
632
|
},
|
|
577
633
|
children: {
|
|
578
634
|
type: "slot",
|
|
@@ -590,10 +646,26 @@ function registerFormItem(loader) {
|
|
|
590
646
|
rules: {
|
|
591
647
|
type: "formValidationRules"
|
|
592
648
|
},
|
|
649
|
+
valuePropName: {
|
|
650
|
+
type: "string",
|
|
651
|
+
advanced: true,
|
|
652
|
+
defaultValueHint: "value",
|
|
653
|
+
description: "The prop name for specifying the value of the form control component"
|
|
654
|
+
},
|
|
593
655
|
noLabel: {
|
|
594
656
|
type: "boolean",
|
|
595
657
|
advanced: true
|
|
596
658
|
},
|
|
659
|
+
alignLabellessWithControls: {
|
|
660
|
+
type: "boolean",
|
|
661
|
+
displayName: "Align with controls?",
|
|
662
|
+
description: "Aligns the content with form controls in the grid",
|
|
663
|
+
hidden: (ps, ctx) => {
|
|
664
|
+
var _a;
|
|
665
|
+
return !ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
|
|
666
|
+
},
|
|
667
|
+
defaultValueHint: true
|
|
668
|
+
},
|
|
597
669
|
colon: {
|
|
598
670
|
type: "boolean",
|
|
599
671
|
defaultValueHint: true,
|
|
@@ -603,7 +675,11 @@ function registerFormItem(loader) {
|
|
|
603
675
|
labelAlign: {
|
|
604
676
|
type: "choice",
|
|
605
677
|
options: ["left", "right"],
|
|
606
|
-
advanced: true
|
|
678
|
+
advanced: true,
|
|
679
|
+
hidden: (ps, ctx) => {
|
|
680
|
+
var _a;
|
|
681
|
+
return !!ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
|
|
682
|
+
}
|
|
607
683
|
},
|
|
608
684
|
hidden: {
|
|
609
685
|
type: "boolean",
|
|
@@ -627,34 +703,16 @@ function registerFormItem(loader) {
|
|
|
627
703
|
displayName: "Dependencies",
|
|
628
704
|
description: "Form items can depend on other form items. This forces it to reevaluate the validation rules when the other form item changes."
|
|
629
705
|
},
|
|
630
|
-
|
|
631
|
-
type: "
|
|
632
|
-
displayName: "
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
label: "Validation errors"
|
|
637
|
-
},
|
|
638
|
-
{
|
|
639
|
-
value: "extra",
|
|
640
|
-
label: "Custom help text and validation errors"
|
|
641
|
-
},
|
|
642
|
-
{
|
|
643
|
-
value: "help",
|
|
644
|
-
label: "Custom help text, no validation errors"
|
|
645
|
-
}
|
|
646
|
-
],
|
|
647
|
-
defaultValueHint: "Show validation errors",
|
|
648
|
-
description: "What to show in the help text. Edit help text by editing the 'help' slot in the outline."
|
|
706
|
+
hideValidationMessage: {
|
|
707
|
+
type: "boolean",
|
|
708
|
+
displayName: "Hide validation message?",
|
|
709
|
+
description: "If true, will hide the validation error message",
|
|
710
|
+
defaultValueHint: false,
|
|
711
|
+
advanced: true
|
|
649
712
|
},
|
|
650
|
-
|
|
713
|
+
description: {
|
|
651
714
|
type: "slot",
|
|
652
|
-
hidden: (ps) => {
|
|
653
|
-
var _a;
|
|
654
|
-
return !["extra", "help"].includes((_a = ps.helpTextMode) != null ? _a : "");
|
|
655
|
-
},
|
|
656
715
|
hidePlaceholder: true
|
|
657
|
-
// advanced: true,
|
|
658
716
|
},
|
|
659
717
|
customizeProps: {
|
|
660
718
|
type: "function",
|
|
@@ -672,13 +730,85 @@ function registerFormItem(loader) {
|
|
|
672
730
|
},
|
|
673
731
|
noStyle: {
|
|
674
732
|
type: "boolean",
|
|
675
|
-
displayName: "Field only",
|
|
676
|
-
description: "Don't render anything but the
|
|
733
|
+
displayName: "Field control only",
|
|
734
|
+
description: "Don't render anything but the field control - so no label, help text, validation error, etc.",
|
|
677
735
|
advanced: true
|
|
678
736
|
}
|
|
679
737
|
},
|
|
680
738
|
importPath: "@plasmicpkgs/antd5/skinny/registerForm",
|
|
681
|
-
importName: "FormItemWrapper"
|
|
739
|
+
importName: "FormItemWrapper",
|
|
740
|
+
templates: {
|
|
741
|
+
Text: {
|
|
742
|
+
props: {
|
|
743
|
+
children: {
|
|
744
|
+
type: "component",
|
|
745
|
+
name: "plasmic-antd5-input"
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
"Long Text": {
|
|
750
|
+
props: {
|
|
751
|
+
children: {
|
|
752
|
+
type: "component",
|
|
753
|
+
name: "plasmic-antd5-textarea"
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
"Select dropdown": {
|
|
758
|
+
props: {
|
|
759
|
+
children: {
|
|
760
|
+
type: "component",
|
|
761
|
+
name: "plasmic-antd5-select"
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
Number: {
|
|
766
|
+
props: {
|
|
767
|
+
children: {
|
|
768
|
+
type: "component",
|
|
769
|
+
name: "plasmic-antd5-input-number"
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
Checkbox: {
|
|
774
|
+
props: {
|
|
775
|
+
children: {
|
|
776
|
+
type: "component",
|
|
777
|
+
name: "plasmic-antd5-checkbox"
|
|
778
|
+
},
|
|
779
|
+
valuePropName: "checked",
|
|
780
|
+
noLabel: true
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
Radios: {
|
|
784
|
+
props: {
|
|
785
|
+
children: {
|
|
786
|
+
type: "component",
|
|
787
|
+
name: "plasmic-antd5-radio-group"
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
},
|
|
791
|
+
Password: {
|
|
792
|
+
props: {
|
|
793
|
+
children: {
|
|
794
|
+
type: "component",
|
|
795
|
+
name: "plasmic-antd5-input-password"
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
"Submit button": {
|
|
800
|
+
props: {
|
|
801
|
+
children: {
|
|
802
|
+
type: "component",
|
|
803
|
+
name: "plasmic-antd5-button",
|
|
804
|
+
props: {
|
|
805
|
+
type: "primary"
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
noLabel: true
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
682
812
|
});
|
|
683
813
|
}
|
|
684
814
|
function FormGroup(props) {
|