@plasmicpkgs/antd5 0.0.122 → 0.0.124
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 +649 -436
- package/dist/antd.esm.js.map +1 -1
- package/dist/index.js +647 -434
- package/dist/index.js.map +1 -1
- package/dist/registerDatePicker.d.ts +2 -2
- package/dist/registerForm.d.ts +23 -10
- package/dist/registerRadio.d.ts +1 -1
- package/dist/utils.d.ts +2 -0
- package/package.json +26 -6
- package/skinny/registerAvatar.cjs.js +1 -1
- package/skinny/registerAvatar.esm.js +1 -1
- 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/registerCollapse.cjs.js +1 -1
- package/skinny/registerCollapse.esm.js +1 -1
- package/skinny/registerColorPicker.cjs.js +1 -1
- package/skinny/registerColorPicker.esm.js +1 -1
- package/skinny/registerConfigProvider.cjs.js +1 -1
- package/skinny/registerConfigProvider.esm.js +1 -1
- package/skinny/registerDatePicker.cjs.js +4 -3
- package/skinny/registerDatePicker.cjs.js.map +1 -1
- package/skinny/registerDatePicker.d.ts +2 -2
- package/skinny/registerDatePicker.esm.js +4 -3
- package/skinny/registerDatePicker.esm.js.map +1 -1
- package/skinny/registerDrawer.cjs.js +1 -1
- package/skinny/registerDrawer.esm.js +1 -1
- package/skinny/registerDropdown.cjs.js +1 -1
- package/skinny/registerDropdown.esm.js +1 -1
- package/skinny/registerForm.cjs.js +337 -145
- package/skinny/registerForm.cjs.js.map +1 -1
- package/skinny/registerForm.d.ts +23 -10
- package/skinny/registerForm.esm.js +340 -148
- 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/registerPopover.cjs.js +1 -1
- package/skinny/registerPopover.esm.js +1 -1
- package/skinny/registerRadio.cjs.js +1 -1
- package/skinny/registerRadio.d.ts +1 -1
- package/skinny/registerRadio.esm.js +1 -1
- package/skinny/registerRate.cjs.js +1 -1
- package/skinny/registerRate.esm.js +1 -1
- package/skinny/{registerSelect-6b399103.esm.js → registerSelect-3273fe93.esm.js} +3 -3
- package/skinny/{registerSelect-6b399103.esm.js.map → registerSelect-3273fe93.esm.js.map} +1 -1
- package/skinny/{registerSelect-40844a74.cjs.js → registerSelect-f0e24345.cjs.js} +2 -2
- package/skinny/{registerSelect-40844a74.cjs.js.map → registerSelect-f0e24345.cjs.js.map} +1 -1
- package/skinny/registerSelect.cjs.js +2 -2
- package/skinny/registerSelect.esm.js +2 -2
- package/skinny/registerSteps.cjs.js +1 -1
- package/skinny/registerSteps.esm.js +1 -1
- package/skinny/registerSwitch.cjs.js +1 -1
- package/skinny/registerSwitch.esm.js +1 -1
- package/skinny/registerTable.cjs.js +1 -1
- package/skinny/registerTable.esm.js +1 -1
- package/skinny/registerTabs.cjs.js +1 -1
- package/skinny/registerTabs.esm.js +1 -1
- package/skinny/registerTooltip.cjs.js +1 -1
- package/skinny/registerTooltip.esm.js +1 -1
- package/skinny/registerTree.cjs.js +1 -1
- package/skinny/registerTree.esm.js +1 -1
- package/skinny/registerUpload.cjs.js +1 -1
- package/skinny/registerUpload.esm.js +1 -1
- package/skinny/{utils-94ad8c63.esm.js → utils-040cbe4d.esm.js} +24 -2
- package/skinny/utils-040cbe4d.esm.js.map +1 -0
- package/skinny/{utils-833cc295.cjs.js → utils-c2d6f0e8.cjs.js} +26 -1
- package/skinny/utils-c2d6f0e8.cjs.js.map +1 -0
- package/skinny/utils.d.ts +2 -0
- package/skinny/utils-833cc295.cjs.js.map +0 -1
- package/skinny/utils-94ad8c63.esm.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -68,6 +68,18 @@ function asArray(x) {
|
|
|
68
68
|
return [x];
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
function omit(obj, ...keys) {
|
|
72
|
+
if (Object.keys(obj).length === 0) {
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
const res = {};
|
|
76
|
+
for (const key of Object.keys(obj)) {
|
|
77
|
+
if (!keys.includes(key)) {
|
|
78
|
+
res[key] = obj[key];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return res;
|
|
82
|
+
}
|
|
71
83
|
function usePrevious(value) {
|
|
72
84
|
const prevValue = React__default.default.useRef(void 0);
|
|
73
85
|
React__default.default.useEffect(() => {
|
|
@@ -94,6 +106,9 @@ function setFieldsToUndefined(obj) {
|
|
|
94
106
|
}
|
|
95
107
|
}
|
|
96
108
|
}
|
|
109
|
+
function arrayEq(xs, ys) {
|
|
110
|
+
return xs.length === ys.length && xs.every((x, i) => x === ys[i]);
|
|
111
|
+
}
|
|
97
112
|
class ErrorBoundary extends React__default.default.Component {
|
|
98
113
|
constructor() {
|
|
99
114
|
super(...arguments);
|
|
@@ -125,6 +140,13 @@ class ErrorBoundary extends React__default.default.Component {
|
|
|
125
140
|
return this.props.children;
|
|
126
141
|
}
|
|
127
142
|
}
|
|
143
|
+
function get(obj, key, def, undef) {
|
|
144
|
+
key = key.split ? key.split(".") : key;
|
|
145
|
+
for (let p = 0; p < key.length; p++) {
|
|
146
|
+
obj = obj ? obj[key[p]] : undef;
|
|
147
|
+
}
|
|
148
|
+
return obj === undef ? def : obj;
|
|
149
|
+
}
|
|
128
150
|
|
|
129
151
|
var __defProp$o = Object.defineProperty;
|
|
130
152
|
var __defProps$i = Object.defineProperties;
|
|
@@ -2524,6 +2546,210 @@ var __objRest$b = (source, exclude) => {
|
|
|
2524
2546
|
}
|
|
2525
2547
|
return target;
|
|
2526
2548
|
};
|
|
2549
|
+
function AntdDatePicker(props) {
|
|
2550
|
+
const nativeInput = React__default.default.useRef(null);
|
|
2551
|
+
const [open, setOpen] = React.useState(false);
|
|
2552
|
+
const strValue = props.value && typeof props.value === "object" && "toISOString" in props.value ? props.value.toISOString() : props.value === null ? void 0 : props.value;
|
|
2553
|
+
const _a = props, { picker, popupScopeClassName } = _a, rest = __objRest$b(_a, ["picker", "popupScopeClassName"]);
|
|
2554
|
+
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
|
|
2555
|
+
antd.DatePicker,
|
|
2556
|
+
__spreadProps$a(__spreadValues$e({}, rest), {
|
|
2557
|
+
picker,
|
|
2558
|
+
value: props.value === void 0 ? void 0 : !props.value ? null : dayjs__default.default(props.value),
|
|
2559
|
+
defaultValue: props.defaultValue === void 0 ? void 0 : dayjs__default.default(props.defaultValue),
|
|
2560
|
+
popupClassName: popupScopeClassName,
|
|
2561
|
+
onChange: (value, _dateString) => {
|
|
2562
|
+
var _a2;
|
|
2563
|
+
(_a2 = props.onChange) == null ? void 0 : _a2.call(props, value !== null ? value.toISOString() : null);
|
|
2564
|
+
},
|
|
2565
|
+
open,
|
|
2566
|
+
onOpenChange: (_open) => {
|
|
2567
|
+
if (_open && window.innerWidth < 500) {
|
|
2568
|
+
nativeInput.current.showPicker();
|
|
2569
|
+
} else {
|
|
2570
|
+
setOpen(_open);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
})
|
|
2574
|
+
), /* @__PURE__ */ React__default.default.createElement(
|
|
2575
|
+
"input",
|
|
2576
|
+
{
|
|
2577
|
+
hidden: true,
|
|
2578
|
+
ref: nativeInput,
|
|
2579
|
+
type: props.showTime ? "datetime-local" : "date",
|
|
2580
|
+
value: strValue || "",
|
|
2581
|
+
onChange: (e) => {
|
|
2582
|
+
var _a2;
|
|
2583
|
+
(_a2 = props.onChange) == null ? void 0 : _a2.call(props, e.target.value);
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
));
|
|
2587
|
+
}
|
|
2588
|
+
const datePickerComponentName = "plasmic-antd5-date-picker";
|
|
2589
|
+
function registerDatePicker(loader) {
|
|
2590
|
+
registerComponentHelper(loader, AntdDatePicker, {
|
|
2591
|
+
name: datePickerComponentName,
|
|
2592
|
+
displayName: "Date/Time Picker",
|
|
2593
|
+
props: {
|
|
2594
|
+
value: {
|
|
2595
|
+
type: "string",
|
|
2596
|
+
editOnly: true,
|
|
2597
|
+
uncontrolledProp: "defaultValue",
|
|
2598
|
+
description: "The current date/time as an ISO string, Date object, or dayjs object",
|
|
2599
|
+
hidden: (ps) => !!ps.__plasmicFormField
|
|
2600
|
+
},
|
|
2601
|
+
disabled: {
|
|
2602
|
+
type: "boolean",
|
|
2603
|
+
defaultValueHint: false
|
|
2604
|
+
},
|
|
2605
|
+
autoFocus: {
|
|
2606
|
+
type: "boolean",
|
|
2607
|
+
description: "Focus when component is rendered",
|
|
2608
|
+
defaultValueHint: false,
|
|
2609
|
+
advanced: true
|
|
2610
|
+
},
|
|
2611
|
+
onChange: {
|
|
2612
|
+
type: "eventHandler",
|
|
2613
|
+
argTypes: [{ name: "value", type: "string" }]
|
|
2614
|
+
},
|
|
2615
|
+
picker: {
|
|
2616
|
+
type: "choice",
|
|
2617
|
+
options: ["date", "week", "month", "quarter", "year"].map((value) => ({
|
|
2618
|
+
value,
|
|
2619
|
+
label: capitalize(value)
|
|
2620
|
+
})),
|
|
2621
|
+
defaultValueHint: "date"
|
|
2622
|
+
},
|
|
2623
|
+
popupScopeClassName: {
|
|
2624
|
+
type: "styleScopeClass",
|
|
2625
|
+
scopeName: "datePickerPopup"
|
|
2626
|
+
},
|
|
2627
|
+
popupClassName: {
|
|
2628
|
+
type: "class",
|
|
2629
|
+
displayName: "Popup container",
|
|
2630
|
+
selectors: [
|
|
2631
|
+
{
|
|
2632
|
+
selector: ":datePickerPopup .ant-picker-panel-container",
|
|
2633
|
+
label: "Base"
|
|
2634
|
+
}
|
|
2635
|
+
]
|
|
2636
|
+
},
|
|
2637
|
+
popupHeaderClassName: {
|
|
2638
|
+
type: "class",
|
|
2639
|
+
displayName: "Popup header",
|
|
2640
|
+
selectors: [
|
|
2641
|
+
{
|
|
2642
|
+
selector: ":datePickerPopup .ant-picker-header",
|
|
2643
|
+
label: "Base"
|
|
2644
|
+
}
|
|
2645
|
+
]
|
|
2646
|
+
},
|
|
2647
|
+
popupBodyClassName: {
|
|
2648
|
+
type: "class",
|
|
2649
|
+
displayName: "Popup body",
|
|
2650
|
+
selectors: [
|
|
2651
|
+
{
|
|
2652
|
+
selector: ":datePickerPopup .ant-picker-body",
|
|
2653
|
+
label: "Base"
|
|
2654
|
+
}
|
|
2655
|
+
]
|
|
2656
|
+
},
|
|
2657
|
+
popupFooterClassName: {
|
|
2658
|
+
type: "class",
|
|
2659
|
+
displayName: "Popup footer",
|
|
2660
|
+
selectors: [
|
|
2661
|
+
{
|
|
2662
|
+
selector: ":datePickerPopup .ant-picker-footer",
|
|
2663
|
+
label: "Base"
|
|
2664
|
+
}
|
|
2665
|
+
]
|
|
2666
|
+
},
|
|
2667
|
+
showTime: {
|
|
2668
|
+
type: "boolean",
|
|
2669
|
+
description: "Enable time selection"
|
|
2670
|
+
},
|
|
2671
|
+
bordered: {
|
|
2672
|
+
type: "boolean",
|
|
2673
|
+
advanced: true
|
|
2674
|
+
},
|
|
2675
|
+
// TODO - see how it works with plasmic-rich-components
|
|
2676
|
+
// format: {
|
|
2677
|
+
// advanced: true
|
|
2678
|
+
// },
|
|
2679
|
+
showNow: {
|
|
2680
|
+
type: "boolean",
|
|
2681
|
+
advanced: true,
|
|
2682
|
+
description: 'Whether to show the "Now" button',
|
|
2683
|
+
defaultValueHint: true,
|
|
2684
|
+
hidden: (ps) => !ps.showTime
|
|
2685
|
+
},
|
|
2686
|
+
showToday: {
|
|
2687
|
+
type: "boolean",
|
|
2688
|
+
advanced: true,
|
|
2689
|
+
description: 'Whether to show the "Today" button',
|
|
2690
|
+
defaultValueHint: true,
|
|
2691
|
+
hidden: (ps) => ps.showTime
|
|
2692
|
+
},
|
|
2693
|
+
// disabledDate: {
|
|
2694
|
+
// type: "function",
|
|
2695
|
+
// advanced: true,
|
|
2696
|
+
// description: "Dates to disable",
|
|
2697
|
+
// },
|
|
2698
|
+
// disabledTime: {
|
|
2699
|
+
// type: "function",
|
|
2700
|
+
// advanced: true,
|
|
2701
|
+
// description: "Times to disable",
|
|
2702
|
+
// },
|
|
2703
|
+
allowClear: {
|
|
2704
|
+
type: "boolean",
|
|
2705
|
+
advanced: true,
|
|
2706
|
+
description: "Whether to show the clear button"
|
|
2707
|
+
}
|
|
2708
|
+
},
|
|
2709
|
+
states: {
|
|
2710
|
+
value: {
|
|
2711
|
+
type: "writable",
|
|
2712
|
+
valueProp: "value",
|
|
2713
|
+
onChangeProp: "onChange",
|
|
2714
|
+
variableType: "text"
|
|
2715
|
+
}
|
|
2716
|
+
},
|
|
2717
|
+
importPath: "@plasmicpkgs/antd5/skinny/registerDatePicker",
|
|
2718
|
+
importName: "AntdDatePicker"
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
var __defProp$d = Object.defineProperty;
|
|
2723
|
+
var __defProps$9 = Object.defineProperties;
|
|
2724
|
+
var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
|
|
2725
|
+
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
2726
|
+
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
2727
|
+
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
2728
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2729
|
+
var __spreadValues$d = (a, b) => {
|
|
2730
|
+
for (var prop in b || (b = {}))
|
|
2731
|
+
if (__hasOwnProp$d.call(b, prop))
|
|
2732
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
2733
|
+
if (__getOwnPropSymbols$d)
|
|
2734
|
+
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
2735
|
+
if (__propIsEnum$d.call(b, prop))
|
|
2736
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
2737
|
+
}
|
|
2738
|
+
return a;
|
|
2739
|
+
};
|
|
2740
|
+
var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
|
|
2741
|
+
var __objRest$a = (source, exclude) => {
|
|
2742
|
+
var target = {};
|
|
2743
|
+
for (var prop in source)
|
|
2744
|
+
if (__hasOwnProp$d.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2745
|
+
target[prop] = source[prop];
|
|
2746
|
+
if (source != null && __getOwnPropSymbols$d)
|
|
2747
|
+
for (var prop of __getOwnPropSymbols$d(source)) {
|
|
2748
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$d.call(source, prop))
|
|
2749
|
+
target[prop] = source[prop];
|
|
2750
|
+
}
|
|
2751
|
+
return target;
|
|
2752
|
+
};
|
|
2527
2753
|
const FormItem = antd.Form.Item;
|
|
2528
2754
|
const FormList = antd.Form.List;
|
|
2529
2755
|
var InputType = /* @__PURE__ */ ((InputType2) => {
|
|
@@ -2538,6 +2764,7 @@ var InputType = /* @__PURE__ */ ((InputType2) => {
|
|
|
2538
2764
|
InputType2["RadioGroup"] = "Radio Group";
|
|
2539
2765
|
InputType2["Checkbox"] = "Checkbox";
|
|
2540
2766
|
InputType2["DatePicker"] = "DatePicker";
|
|
2767
|
+
InputType2["Unknown"] = "Unkown";
|
|
2541
2768
|
return InputType2;
|
|
2542
2769
|
})(InputType || {});
|
|
2543
2770
|
var FormType = /* @__PURE__ */ ((FormType2) => {
|
|
@@ -2550,17 +2777,27 @@ const InternalFormInstanceContext = React__default.default.createContext(void 0)
|
|
|
2550
2777
|
const FormLayoutContext = React__default.default.createContext(void 0);
|
|
2551
2778
|
const Internal = React__default.default.forwardRef(
|
|
2552
2779
|
(props, ref) => {
|
|
2553
|
-
var _b, _c, _d, _e;
|
|
2780
|
+
var _b, _c, _d, _e, _f;
|
|
2554
2781
|
const [form] = antd.Form.useForm();
|
|
2555
2782
|
const values = form.getFieldsValue(true);
|
|
2556
2783
|
const lastValue = React__default.default.useRef(values);
|
|
2557
|
-
const _a = props, {
|
|
2784
|
+
const _a = props, {
|
|
2785
|
+
extendedOnValuesChange,
|
|
2786
|
+
forceRemount,
|
|
2787
|
+
setRegisteredFields,
|
|
2788
|
+
registeredFields
|
|
2789
|
+
} = _a, rest = __objRest$a(_a, [
|
|
2790
|
+
"extendedOnValuesChange",
|
|
2791
|
+
"forceRemount",
|
|
2792
|
+
"setRegisteredFields",
|
|
2793
|
+
"registeredFields"
|
|
2794
|
+
]);
|
|
2558
2795
|
let childrenNode;
|
|
2559
2796
|
if (props.mode !== "simplified") {
|
|
2560
2797
|
childrenNode = typeof props.children === "function" ? props.children(values, form) : props.children;
|
|
2561
2798
|
} else {
|
|
2562
2799
|
childrenNode = /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, ((_b = props.formItems) != null ? _b : []).map((formItem) => {
|
|
2563
|
-
var _a2, _b2;
|
|
2800
|
+
var _a2, _b2, _c2;
|
|
2564
2801
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
2565
2802
|
ErrorBoundary,
|
|
2566
2803
|
{
|
|
@@ -2569,12 +2806,13 @@ const Internal = React__default.default.forwardRef(
|
|
|
2569
2806
|
},
|
|
2570
2807
|
/* @__PURE__ */ React__default.default.createElement(
|
|
2571
2808
|
FormItemWrapper,
|
|
2572
|
-
__spreadProps$
|
|
2809
|
+
__spreadProps$9(__spreadValues$d({}, omit(formItem, "key")), {
|
|
2573
2810
|
noLabel: formItem.inputType === "Checkbox" /* Checkbox */ || formItem.noLabel,
|
|
2811
|
+
valuePropName: (_c2 = formItem.valuePropName) != null ? _c2 : formItem.inputType === "Checkbox" /* Checkbox */ ? "checked" : void 0,
|
|
2574
2812
|
style: { width: "100%" }
|
|
2575
2813
|
}),
|
|
2576
|
-
formItem.inputType === "Text" /* Text */ ? /* @__PURE__ */ React__default.default.createElement(antd.Input, null) : formItem.inputType === "Password" /* Password */ ? /* @__PURE__ */ React__default.default.createElement(antd.Input.Password, null) : formItem.inputType === "Text Area" /* TextArea */ ? /* @__PURE__ */ React__default.default.createElement(antd.Input.TextArea, null) : formItem.inputType === "Number" /* Number */ ? /* @__PURE__ */ React__default.default.createElement(antd.InputNumber, null) : formItem.inputType === "Checkbox" /* Checkbox */ ? /* @__PURE__ */ React__default.default.createElement(
|
|
2577
|
-
|
|
2814
|
+
formItem.inputType === "Text" /* Text */ ? /* @__PURE__ */ React__default.default.createElement(antd.Input, null) : formItem.inputType === "Password" /* Password */ ? /* @__PURE__ */ React__default.default.createElement(antd.Input.Password, null) : formItem.inputType === "Text Area" /* TextArea */ ? /* @__PURE__ */ React__default.default.createElement(antd.Input.TextArea, null) : formItem.inputType === "Number" /* Number */ ? /* @__PURE__ */ React__default.default.createElement(antd.InputNumber, null) : formItem.inputType === "Checkbox" /* Checkbox */ ? /* @__PURE__ */ React__default.default.createElement(AntdCheckbox, null, formItem.label) : formItem.inputType === "Select" /* Select */ ? /* @__PURE__ */ React__default.default.createElement(AntdSelect, { options: formItem.options }) : formItem.inputType === "DatePicker" /* DatePicker */ ? /* @__PURE__ */ React__default.default.createElement(AntdDatePicker, { showTime: formItem.showTime }) : formItem.inputType === "Radio Group" /* RadioGroup */ ? /* @__PURE__ */ React__default.default.createElement(
|
|
2815
|
+
AntdRadioGroup,
|
|
2578
2816
|
{
|
|
2579
2817
|
options: formItem.options,
|
|
2580
2818
|
optionType: formItem.optionType,
|
|
@@ -2619,6 +2857,13 @@ const Internal = React__default.default.forwardRef(
|
|
|
2619
2857
|
form.resetFields();
|
|
2620
2858
|
extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(form.getFieldsValue(true));
|
|
2621
2859
|
},
|
|
2860
|
+
validateFields: async (...args) => {
|
|
2861
|
+
try {
|
|
2862
|
+
return await form.validateFields(...args);
|
|
2863
|
+
} catch (err) {
|
|
2864
|
+
return err;
|
|
2865
|
+
}
|
|
2866
|
+
},
|
|
2622
2867
|
clearFields: () => {
|
|
2623
2868
|
const values2 = form.getFieldsValue(true);
|
|
2624
2869
|
setFieldsToUndefined(values2);
|
|
@@ -2626,27 +2871,40 @@ const Internal = React__default.default.forwardRef(
|
|
|
2626
2871
|
extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(form.getFieldsValue(true));
|
|
2627
2872
|
}
|
|
2628
2873
|
}));
|
|
2874
|
+
const registerField = React__default.default.useCallback((fieldEntity) => {
|
|
2875
|
+
setRegisteredFields((f) => [...f, fieldEntity]);
|
|
2876
|
+
return () => {
|
|
2877
|
+
setRegisteredFields((f) => f.filter((ent) => ent !== fieldEntity));
|
|
2878
|
+
};
|
|
2879
|
+
}, []);
|
|
2629
2880
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
2630
2881
|
InternalFormInstanceContext.Provider,
|
|
2631
2882
|
{
|
|
2632
2883
|
value: {
|
|
2633
2884
|
layout: formLayout,
|
|
2634
2885
|
fireOnValuesChange,
|
|
2635
|
-
forceRemount
|
|
2886
|
+
forceRemount,
|
|
2887
|
+
registerField,
|
|
2888
|
+
registeredFields,
|
|
2889
|
+
initialValues: (_d = props.initialValues) != null ? _d : {}
|
|
2636
2890
|
}
|
|
2637
2891
|
},
|
|
2638
2892
|
/* @__PURE__ */ React__default.default.createElement(FormLayoutContext.Provider, { value: formLayout }, /* @__PURE__ */ React__default.default.createElement(
|
|
2639
2893
|
antd.Form,
|
|
2640
|
-
__spreadProps$
|
|
2894
|
+
__spreadProps$9(__spreadValues$d({}, rest), {
|
|
2641
2895
|
key: props.initialValues ? JSON.stringify(props.initialValues) : void 0,
|
|
2642
2896
|
onValuesChange: (...args) => {
|
|
2643
2897
|
var _a2;
|
|
2644
2898
|
(_a2 = props.onValuesChange) == null ? void 0 : _a2.call(props, ...args);
|
|
2645
|
-
extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(
|
|
2899
|
+
extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(form.getFieldsValue(true));
|
|
2900
|
+
},
|
|
2901
|
+
onFinish: () => {
|
|
2902
|
+
var _a2;
|
|
2903
|
+
(_a2 = props.onFinish) == null ? void 0 : _a2.call(props, form.getFieldsValue(true));
|
|
2646
2904
|
},
|
|
2647
2905
|
form,
|
|
2648
|
-
labelCol: ((
|
|
2649
|
-
wrapperCol: ((
|
|
2906
|
+
labelCol: ((_e = props.labelCol) == null ? void 0 : _e.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
|
|
2907
|
+
wrapperCol: ((_f = props.wrapperCol) == null ? void 0 : _f.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
|
|
2650
2908
|
}),
|
|
2651
2909
|
/* @__PURE__ */ React__default.default.createElement("style", null, `
|
|
2652
2910
|
.ant-form-item-explain + div, .ant-form-item-margin-offset {
|
|
@@ -2658,42 +2916,47 @@ const Internal = React__default.default.forwardRef(
|
|
|
2658
2916
|
);
|
|
2659
2917
|
}
|
|
2660
2918
|
);
|
|
2661
|
-
function useFormItemDefinitions(rawData, props, formRef) {
|
|
2662
|
-
const { mode,
|
|
2919
|
+
function useFormItemDefinitions(rawData, props, formRef, registeredFields) {
|
|
2920
|
+
const { mode, dataFormItems, setControlContextData } = props;
|
|
2921
|
+
const formInstance = formRef == null ? void 0 : formRef.formInstance;
|
|
2663
2922
|
return React__default.default.useMemo(() => {
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2923
|
+
const data = rawData && dataSources.normalizeData(rawData);
|
|
2924
|
+
const schema = data && (data == null ? void 0 : data.schema);
|
|
2925
|
+
if (mode !== "simplified" || !rawData || rawData.isLoading || rawData.error || !data || !schema || !data.data) {
|
|
2926
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
2927
|
+
formInstance,
|
|
2928
|
+
registeredFields
|
|
2929
|
+
});
|
|
2670
2930
|
return void 0;
|
|
2671
2931
|
}
|
|
2672
2932
|
const row = data.data.length > 0 ? data.data[0] : void 0;
|
|
2673
2933
|
const { mergedFields, minimalFullLengthFields } = dataSources.deriveFieldConfigs(
|
|
2674
|
-
|
|
2934
|
+
dataFormItems != null ? dataFormItems : [],
|
|
2675
2935
|
schema,
|
|
2676
|
-
(field) =>
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2936
|
+
(field) => {
|
|
2937
|
+
var _a;
|
|
2938
|
+
return __spreadValues$d({
|
|
2939
|
+
inputType: "Text" /* Text */
|
|
2940
|
+
}, field && {
|
|
2941
|
+
key: field.id,
|
|
2942
|
+
fieldId: field.id,
|
|
2943
|
+
label: (_a = field.label) != null ? _a : field.id,
|
|
2944
|
+
name: field.id,
|
|
2945
|
+
inputType: field.type === "string" ? "Text" /* Text */ : field.type === "number" ? "Number" /* Number */ : field.type === "boolean" ? "Checkbox" /* Checkbox */ : "Text" /* Text */,
|
|
2946
|
+
//missing date and date-time
|
|
2947
|
+
initialValue: row ? row[field.id] : void 0
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2688
2950
|
);
|
|
2689
2951
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2690
2952
|
schema: data.schema,
|
|
2691
2953
|
minimalFullLengthFields,
|
|
2692
2954
|
mergedFields,
|
|
2693
|
-
formInstance
|
|
2955
|
+
formInstance,
|
|
2956
|
+
registeredFields
|
|
2694
2957
|
});
|
|
2695
2958
|
return mergedFields;
|
|
2696
|
-
}, [mode, setControlContextData,
|
|
2959
|
+
}, [mode, setControlContextData, dataFormItems, rawData, formInstance]);
|
|
2697
2960
|
}
|
|
2698
2961
|
const useRawData = (props) => {
|
|
2699
2962
|
const rawData = dataSources.usePlasmicDataOp(props.data);
|
|
@@ -2702,34 +2965,46 @@ const useRawData = (props) => {
|
|
|
2702
2965
|
const FormWrapper = React__default.default.forwardRef(
|
|
2703
2966
|
(props, ref) => {
|
|
2704
2967
|
const [remountKey, setRemountKey] = React__default.default.useState(0);
|
|
2968
|
+
const forceRemount = React__default.default.useCallback(
|
|
2969
|
+
() => setRemountKey((k) => k + 1),
|
|
2970
|
+
[setRemountKey]
|
|
2971
|
+
);
|
|
2705
2972
|
const previousInitialValues = usePrevious(props.initialValues);
|
|
2706
2973
|
const wrapperRef = React__default.default.useRef(null);
|
|
2707
2974
|
React__default.default.useEffect(() => {
|
|
2708
2975
|
if (previousInitialValues !== props.initialValues && JSON.stringify(previousInitialValues) !== JSON.stringify(props.initialValues)) {
|
|
2709
|
-
|
|
2976
|
+
forceRemount();
|
|
2710
2977
|
}
|
|
2711
2978
|
}, [previousInitialValues, props.initialValues]);
|
|
2979
|
+
const [registeredFields, setRegisteredFields] = React__default.default.useState([]);
|
|
2712
2980
|
React__default.default.useImperativeHandle(
|
|
2713
2981
|
ref,
|
|
2714
|
-
() => wrapperRef.current ? __spreadValues$
|
|
2982
|
+
() => wrapperRef.current ? __spreadValues$d({}, wrapperRef.current) : {}
|
|
2715
2983
|
);
|
|
2716
2984
|
const rawData = useRawData(props);
|
|
2717
2985
|
const formItemDefinitions = useFormItemDefinitions(
|
|
2718
2986
|
rawData,
|
|
2719
2987
|
props,
|
|
2720
|
-
wrapperRef.current
|
|
2988
|
+
wrapperRef.current,
|
|
2989
|
+
registeredFields
|
|
2721
2990
|
);
|
|
2722
2991
|
React__default.default.useEffect(() => {
|
|
2723
2992
|
if (rawData && !rawData.isLoading) {
|
|
2724
|
-
|
|
2993
|
+
forceRemount();
|
|
2725
2994
|
}
|
|
2726
2995
|
}, [rawData]);
|
|
2727
|
-
const
|
|
2728
|
-
|
|
2996
|
+
const previousDataOp = usePrevious(props.data);
|
|
2997
|
+
React__default.default.useEffect(() => {
|
|
2998
|
+
if (previousDataOp == null && props.data != null || previousDataOp != null && props.data == null) {
|
|
2999
|
+
forceRemount();
|
|
3000
|
+
}
|
|
3001
|
+
}, [props.data]);
|
|
3002
|
+
const _a = props, { dataFormItems, formItems, data } = _a, rest = __objRest$a(_a, ["dataFormItems", "formItems", "data"]);
|
|
3003
|
+
const actualFormItems = props.mode === "simplified" && formItemDefinitions ? formItemDefinitions : data ? dataFormItems : formItems;
|
|
2729
3004
|
const previousFormItems = React__default.default.useRef([]);
|
|
2730
3005
|
React__default.default.useEffect(() => {
|
|
2731
3006
|
if (!(rawData && rawData.isLoading)) {
|
|
2732
|
-
previousFormItems.current = actualFormItems;
|
|
3007
|
+
previousFormItems.current = actualFormItems != null ? actualFormItems : [];
|
|
2733
3008
|
}
|
|
2734
3009
|
}, [rawData, actualFormItems]);
|
|
2735
3010
|
if (props.mode === "simplified" && rawData && "error" in rawData) {
|
|
@@ -2739,10 +3014,12 @@ const FormWrapper = React__default.default.forwardRef(
|
|
|
2739
3014
|
const isLoadingData = rawData == null ? void 0 : rawData.isLoading;
|
|
2740
3015
|
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
|
|
2741
3016
|
Internal,
|
|
2742
|
-
__spreadProps$
|
|
3017
|
+
__spreadProps$9(__spreadValues$d({
|
|
2743
3018
|
key: remountKey
|
|
2744
3019
|
}, rest), {
|
|
2745
|
-
|
|
3020
|
+
forceRemount,
|
|
3021
|
+
setRegisteredFields,
|
|
3022
|
+
registeredFields,
|
|
2746
3023
|
formItems: rawData && rawData.isLoading ? previousFormItems.current : actualFormItems,
|
|
2747
3024
|
ref: wrapperRef,
|
|
2748
3025
|
style: isSchemaForm && isLoadingData ? {
|
|
@@ -2880,97 +3157,7 @@ function registerForm(loader) {
|
|
|
2880
3157
|
formItems: {
|
|
2881
3158
|
displayName: "Fields",
|
|
2882
3159
|
type: "array",
|
|
2883
|
-
itemType:
|
|
2884
|
-
type: "object",
|
|
2885
|
-
fields: __spreadValues$e({
|
|
2886
|
-
label: {
|
|
2887
|
-
type: "string",
|
|
2888
|
-
defaultValueHint: getDefaultValueHint("label")
|
|
2889
|
-
},
|
|
2890
|
-
inputType: {
|
|
2891
|
-
type: "choice",
|
|
2892
|
-
options: Object.values(InputType).filter(
|
|
2893
|
-
(inputType) => ![
|
|
2894
|
-
"Option" /* Option */,
|
|
2895
|
-
"Option Group" /* OptionGroup */,
|
|
2896
|
-
"Radio" /* Radio */
|
|
2897
|
-
].includes(inputType)
|
|
2898
|
-
),
|
|
2899
|
-
defaultValue: "Text" /* Text */,
|
|
2900
|
-
defaultValueHint: getDefaultValueHint("inputType")
|
|
2901
|
-
},
|
|
2902
|
-
options: {
|
|
2903
|
-
type: "array",
|
|
2904
|
-
itemType: {
|
|
2905
|
-
type: "object",
|
|
2906
|
-
fields: {
|
|
2907
|
-
type: {
|
|
2908
|
-
type: "choice",
|
|
2909
|
-
options: [
|
|
2910
|
-
{ value: "option", label: "Option" },
|
|
2911
|
-
{ value: "option-group", label: "Option Group" }
|
|
2912
|
-
],
|
|
2913
|
-
defaultValue: "option",
|
|
2914
|
-
hidden: (ps, _ctx, { path }) => {
|
|
2915
|
-
var _a, _b;
|
|
2916
|
-
if (((_b = (_a = ps.formItems) == null ? void 0 : _a[path[1]]) == null ? void 0 : _b.inputType) !== "Select" /* Select */) {
|
|
2917
|
-
return true;
|
|
2918
|
-
}
|
|
2919
|
-
return false;
|
|
2920
|
-
}
|
|
2921
|
-
},
|
|
2922
|
-
label: "string",
|
|
2923
|
-
value: {
|
|
2924
|
-
type: "string",
|
|
2925
|
-
hidden: (ps, _ctx, { path, item }) => {
|
|
2926
|
-
var _a, _b;
|
|
2927
|
-
if (((_b = (_a = ps.formItems) == null ? void 0 : _a[path[1]]) == null ? void 0 : _b.inputType) !== "Select" /* Select */) {
|
|
2928
|
-
return false;
|
|
2929
|
-
}
|
|
2930
|
-
return item.type !== "option";
|
|
2931
|
-
}
|
|
2932
|
-
},
|
|
2933
|
-
options: {
|
|
2934
|
-
type: "array",
|
|
2935
|
-
itemType: {
|
|
2936
|
-
type: "object",
|
|
2937
|
-
nameFunc: (item) => item.label || item.value,
|
|
2938
|
-
fields: {
|
|
2939
|
-
value: "string",
|
|
2940
|
-
label: "string"
|
|
2941
|
-
}
|
|
2942
|
-
},
|
|
2943
|
-
hidden: (ps, _ctx, { path, item }) => {
|
|
2944
|
-
var _a, _b;
|
|
2945
|
-
if (((_b = (_a = ps.formItems) == null ? void 0 : _a[path[1]]) == null ? void 0 : _b.inputType) !== "Select" /* Select */) {
|
|
2946
|
-
return true;
|
|
2947
|
-
}
|
|
2948
|
-
return item.type !== "option-group";
|
|
2949
|
-
}
|
|
2950
|
-
}
|
|
2951
|
-
},
|
|
2952
|
-
nameFunc: (item) => item == null ? void 0 : item.label
|
|
2953
|
-
},
|
|
2954
|
-
hidden: (_ps, _ctx, { item }) => !["Select" /* Select */, "Radio Group" /* RadioGroup */].includes(
|
|
2955
|
-
item.inputType
|
|
2956
|
-
)
|
|
2957
|
-
},
|
|
2958
|
-
optionType: {
|
|
2959
|
-
type: "choice",
|
|
2960
|
-
options: [
|
|
2961
|
-
{ value: "default", label: "Radio" },
|
|
2962
|
-
{ value: "button", label: "Button" }
|
|
2963
|
-
],
|
|
2964
|
-
hidden: (_ps, _ctx, { item }) => "Radio Group" /* RadioGroup */ !== item.inputType,
|
|
2965
|
-
defaultValueHint: "Radio",
|
|
2966
|
-
displayName: "Option Type"
|
|
2967
|
-
}
|
|
2968
|
-
}, commonFormItemProps),
|
|
2969
|
-
nameFunc: (item) => {
|
|
2970
|
-
var _a, _b;
|
|
2971
|
-
return (_b = (_a = item.fieldId) != null ? _a : item.label) != null ? _b : item.name;
|
|
2972
|
-
}
|
|
2973
|
-
},
|
|
3160
|
+
itemType: commonSimplifiedFormArrayItemType("formItems"),
|
|
2974
3161
|
defaultValue: [
|
|
2975
3162
|
{
|
|
2976
3163
|
label: "Name",
|
|
@@ -2987,17 +3174,31 @@ function registerForm(loader) {
|
|
|
2987
3174
|
if (ps.mode === "advanced") {
|
|
2988
3175
|
return true;
|
|
2989
3176
|
}
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
3177
|
+
return !!ps.data;
|
|
3178
|
+
}
|
|
3179
|
+
},
|
|
3180
|
+
/**
|
|
3181
|
+
* dataFormItems are used to expand the form items from schema forms.
|
|
3182
|
+
* We can't use the formItems prop because it has a default value. Therefore, if we unset the formItems prop,
|
|
3183
|
+
* we would end up with the default value of formItems + schema form items.
|
|
3184
|
+
* Ideally, we would need to support dynamic default value.
|
|
3185
|
+
*/
|
|
3186
|
+
dataFormItems: {
|
|
3187
|
+
displayName: "Data Fields",
|
|
3188
|
+
type: "array",
|
|
3189
|
+
itemType: commonSimplifiedFormArrayItemType("dataFormItems"),
|
|
3190
|
+
hidden: (ps) => {
|
|
3191
|
+
if (ps.mode === "advanced") {
|
|
3192
|
+
return true;
|
|
3193
|
+
}
|
|
3194
|
+
return !ps.data;
|
|
3195
|
+
},
|
|
3196
|
+
unstable__keyFunc: (x) => x.key,
|
|
3197
|
+
unstable__minimalValue: (ps, contextData) => {
|
|
3198
|
+
return ps.data ? contextData == null ? void 0 : contextData.minimalFullLengthFields : void 0;
|
|
3199
|
+
},
|
|
2999
3200
|
unstable__canDelete: (item, ps, ctx) => {
|
|
3000
|
-
if (ps.mode !== "
|
|
3201
|
+
if (ps.mode !== "simplified") {
|
|
3001
3202
|
return true;
|
|
3002
3203
|
}
|
|
3003
3204
|
if (!(ctx == null ? void 0 : ctx.schema)) {
|
|
@@ -3009,7 +3210,7 @@ function registerForm(loader) {
|
|
|
3009
3210
|
return true;
|
|
3010
3211
|
}
|
|
3011
3212
|
},
|
|
3012
|
-
submitSlot: __spreadValues$
|
|
3213
|
+
submitSlot: __spreadValues$d({
|
|
3013
3214
|
type: "slot",
|
|
3014
3215
|
hidden: () => true,
|
|
3015
3216
|
defaultValue: {
|
|
@@ -3203,6 +3404,21 @@ function registerForm(loader) {
|
|
|
3203
3404
|
clearFields: {
|
|
3204
3405
|
displayName: "Clear fields",
|
|
3205
3406
|
argTypes: []
|
|
3407
|
+
},
|
|
3408
|
+
validateFields: {
|
|
3409
|
+
displayName: "Validate fields",
|
|
3410
|
+
argTypes: [
|
|
3411
|
+
{
|
|
3412
|
+
name: "nameList",
|
|
3413
|
+
displayName: "Name List",
|
|
3414
|
+
type: "object"
|
|
3415
|
+
},
|
|
3416
|
+
{
|
|
3417
|
+
name: "options",
|
|
3418
|
+
displayName: "Options",
|
|
3419
|
+
type: "object"
|
|
3420
|
+
}
|
|
3421
|
+
]
|
|
3206
3422
|
}
|
|
3207
3423
|
},
|
|
3208
3424
|
importPath: "@plasmicpkgs/antd5/skinny/registerForm",
|
|
@@ -3286,7 +3502,7 @@ function FormItemWrapper(props) {
|
|
|
3286
3502
|
customizeProps,
|
|
3287
3503
|
setControlContextData,
|
|
3288
3504
|
alignLabellessWithControls = true
|
|
3289
|
-
} = _a, rest = __objRest$
|
|
3505
|
+
} = _a, rest = __objRest$a(_a, [
|
|
3290
3506
|
"rules",
|
|
3291
3507
|
"description",
|
|
3292
3508
|
"noLabel",
|
|
@@ -3298,6 +3514,11 @@ function FormItemWrapper(props) {
|
|
|
3298
3514
|
]);
|
|
3299
3515
|
const relativeFormItemName = useFormItemRelativeName(name);
|
|
3300
3516
|
const fullFormItemName = useFormItemFullName(name);
|
|
3517
|
+
const pathCtx = React__default.default.useContext(PathContext);
|
|
3518
|
+
const fieldEntity = React__default.default.useRef({
|
|
3519
|
+
fullPath: pathCtx.fullPath,
|
|
3520
|
+
name
|
|
3521
|
+
}).current;
|
|
3301
3522
|
const bestEffortLabel = !noLabel && reactNodeToString(props.label) || ensureArray(props.name).slice(-1)[0];
|
|
3302
3523
|
const rules = plasmicRules ? plasmicRulesToAntdRules(
|
|
3303
3524
|
plasmicRules,
|
|
@@ -3313,17 +3534,26 @@ function FormItemWrapper(props) {
|
|
|
3313
3534
|
});
|
|
3314
3535
|
const fullPath = React__default.default.useContext(PathContext).fullPath;
|
|
3315
3536
|
const internalFormCtx = React__default.default.useContext(InternalFormInstanceContext);
|
|
3316
|
-
const { fireOnValuesChange, forceRemount } = internalFormCtx != null ? internalFormCtx : {};
|
|
3537
|
+
const { fireOnValuesChange, forceRemount, registerField, initialValues } = internalFormCtx != null ? internalFormCtx : {};
|
|
3317
3538
|
(_b = props.setControlContextData) == null ? void 0 : _b.call(props, {
|
|
3318
3539
|
internalFormCtx,
|
|
3319
3540
|
formInstance: form,
|
|
3320
3541
|
parentFormItemPath: fullPath
|
|
3321
3542
|
});
|
|
3322
3543
|
React__default.default.useEffect(() => {
|
|
3544
|
+
const unregister = registerField == null ? void 0 : registerField(fieldEntity);
|
|
3545
|
+
return () => unregister == null ? void 0 : unregister();
|
|
3546
|
+
}, []);
|
|
3547
|
+
React__default.default.useEffect(() => {
|
|
3548
|
+
fieldEntity.fullPath = [
|
|
3549
|
+
...pathCtx.fullPath,
|
|
3550
|
+
...props.name != null ? [props.name] : []
|
|
3551
|
+
];
|
|
3552
|
+
fieldEntity.name = props.name;
|
|
3323
3553
|
if (prevPropValues.current.name !== props.name) {
|
|
3324
3554
|
forceRemount == null ? void 0 : forceRemount();
|
|
3325
3555
|
}
|
|
3326
|
-
if (!fullFormItemName || (
|
|
3556
|
+
if (!fullFormItemName || get(initialValues, fullFormItemName) != null) {
|
|
3327
3557
|
return;
|
|
3328
3558
|
}
|
|
3329
3559
|
form == null ? void 0 : form.setFieldValue(fullFormItemName, props.initialValue);
|
|
@@ -3333,7 +3563,7 @@ function FormItemWrapper(props) {
|
|
|
3333
3563
|
}
|
|
3334
3564
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
3335
3565
|
FormItem,
|
|
3336
|
-
__spreadProps$
|
|
3566
|
+
__spreadProps$9(__spreadValues$d({}, rest), {
|
|
3337
3567
|
label: noLabel ? void 0 : props.label,
|
|
3338
3568
|
name: relativeFormItemName,
|
|
3339
3569
|
rules,
|
|
@@ -3398,7 +3628,7 @@ function deriveOnChangePropName(props) {
|
|
|
3398
3628
|
return void 0;
|
|
3399
3629
|
}
|
|
3400
3630
|
function FormItemForwarder(_a) {
|
|
3401
|
-
var _b = _a, { formItemProps } = _b, props = __objRest$
|
|
3631
|
+
var _b = _a, { formItemProps } = _b, props = __objRest$a(_b, ["formItemProps"]);
|
|
3402
3632
|
var _a2;
|
|
3403
3633
|
const status = antd.Form.Item.useStatus();
|
|
3404
3634
|
const internalFormCtx = React__default.default.useContext(InternalFormInstanceContext);
|
|
@@ -3411,7 +3641,7 @@ function FormItemForwarder(_a) {
|
|
|
3411
3641
|
});
|
|
3412
3642
|
return React__default.default.Children.map(formItemProps.children, (child, i) => {
|
|
3413
3643
|
var _a3;
|
|
3414
|
-
let newProps = __spreadProps$
|
|
3644
|
+
let newProps = __spreadProps$9(__spreadValues$d(__spreadValues$d({}, (_a3 = child.props) != null ? _a3 : {}), props), {
|
|
3415
3645
|
__plasmicFormField: true
|
|
3416
3646
|
});
|
|
3417
3647
|
if (formItemProps.customizeProps) {
|
|
@@ -3425,11 +3655,12 @@ function FormItemForwarder(_a) {
|
|
|
3425
3655
|
}
|
|
3426
3656
|
function getDefaultValueHint(field) {
|
|
3427
3657
|
return (_props, contextData, { item }) => {
|
|
3658
|
+
var _a;
|
|
3428
3659
|
if (!contextData || !("mergedFields" in contextData)) {
|
|
3429
3660
|
return void 0;
|
|
3430
3661
|
}
|
|
3431
3662
|
if (item == null ? void 0 : item.fieldId) {
|
|
3432
|
-
const fieldSetting = contextData.mergedFields.find(
|
|
3663
|
+
const fieldSetting = (_a = contextData.mergedFields) == null ? void 0 : _a.find(
|
|
3433
3664
|
(f) => f.fieldId === item.fieldId
|
|
3434
3665
|
);
|
|
3435
3666
|
return fieldSetting == null ? void 0 : fieldSetting[field];
|
|
@@ -3437,15 +3668,98 @@ function getDefaultValueHint(field) {
|
|
|
3437
3668
|
return void 0;
|
|
3438
3669
|
};
|
|
3439
3670
|
}
|
|
3440
|
-
const
|
|
3671
|
+
const mapAntdComponentToInputType = /* @__PURE__ */ new Map([
|
|
3672
|
+
[antd.Input, "Text" /* Text */],
|
|
3673
|
+
[antd.Input.TextArea, "Text Area" /* TextArea */],
|
|
3674
|
+
[antd.Input.Password, "Password" /* Password */],
|
|
3675
|
+
[antd.InputNumber, "Number" /* Number */],
|
|
3676
|
+
[AntdSelect, "Select" /* Select */],
|
|
3677
|
+
[AntdRadioGroup, "Radio Group" /* RadioGroup */],
|
|
3678
|
+
[antd.Radio, "Radio" /* Radio */],
|
|
3679
|
+
[AntdDatePicker, "DatePicker" /* DatePicker */],
|
|
3680
|
+
[AntdCheckbox, "Checkbox" /* Checkbox */]
|
|
3681
|
+
]);
|
|
3682
|
+
const mapPlumeTypeToInputType = /* @__PURE__ */ new Map([
|
|
3683
|
+
["text-input", "Text" /* Text */],
|
|
3684
|
+
["select", "Select" /* Select */],
|
|
3685
|
+
["checkbox", "Checkbox" /* Checkbox */],
|
|
3686
|
+
["switch", "Checkbox" /* Checkbox */]
|
|
3687
|
+
]);
|
|
3688
|
+
const commonFormItemProps = (usage) => ({
|
|
3441
3689
|
name: {
|
|
3442
3690
|
type: "string",
|
|
3443
3691
|
required: true,
|
|
3692
|
+
validator: (value, _props, ctx) => {
|
|
3693
|
+
var _a, _b, _c;
|
|
3694
|
+
const currFullPath = [...(_a = ctx == null ? void 0 : ctx.parentFormItemPath) != null ? _a : [], value];
|
|
3695
|
+
const nameCounter = ((_c = (_b = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _b.registeredFields) != null ? _c : []).filter(
|
|
3696
|
+
(formItem) => arrayEq(formItem.fullPath, currFullPath)
|
|
3697
|
+
).length;
|
|
3698
|
+
return nameCounter === 1 ? true : `Repeated form item name: ${currFullPath.join(" \u2192 ")}`;
|
|
3699
|
+
},
|
|
3444
3700
|
defaultValueHint: getDefaultValueHint("name")
|
|
3445
3701
|
},
|
|
3446
3702
|
initialValue: {
|
|
3447
|
-
type: "
|
|
3448
|
-
|
|
3703
|
+
type: "dynamic",
|
|
3704
|
+
control: (ps, ctx, {
|
|
3705
|
+
item,
|
|
3706
|
+
path
|
|
3707
|
+
}) => {
|
|
3708
|
+
var _a, _b, _c, _d;
|
|
3709
|
+
let inputType = "Unkown" /* Unknown */;
|
|
3710
|
+
if (usage === "simplified-form-item") {
|
|
3711
|
+
inputType = item.inputType;
|
|
3712
|
+
if (!ps.data) {
|
|
3713
|
+
inputType = item.inputType;
|
|
3714
|
+
} else if (path != null && typeof path[1] === "number") {
|
|
3715
|
+
inputType = (_b = (_a = ctx == null ? void 0 : ctx.mergedFields) == null ? void 0 : _a[path[1]].inputType) != null ? _b : "Unkown" /* Unknown */;
|
|
3716
|
+
}
|
|
3717
|
+
} else {
|
|
3718
|
+
if (!React__default.default.isValidElement(ps.children) || typeof ps.children.type === "string") {
|
|
3719
|
+
inputType = "Unkown" /* Unknown */;
|
|
3720
|
+
} else {
|
|
3721
|
+
if (mapAntdComponentToInputType.has(ps.children.type)) {
|
|
3722
|
+
inputType = (_c = mapAntdComponentToInputType.get(ps.children.type)) != null ? _c : "Unkown" /* Unknown */;
|
|
3723
|
+
} else if ("__plumeType" in ps.children.type) {
|
|
3724
|
+
inputType = (_d = mapPlumeTypeToInputType.get(
|
|
3725
|
+
ps.children.type.__plumeType
|
|
3726
|
+
)) != null ? _d : "Unkown" /* Unknown */;
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
if ([
|
|
3731
|
+
"Text" /* Text */,
|
|
3732
|
+
"Text Area" /* TextArea */,
|
|
3733
|
+
"Password" /* Password */,
|
|
3734
|
+
"Select" /* Select */,
|
|
3735
|
+
"Radio Group" /* RadioGroup */
|
|
3736
|
+
].includes(inputType)) {
|
|
3737
|
+
return {
|
|
3738
|
+
type: "string",
|
|
3739
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3740
|
+
};
|
|
3741
|
+
} else if ("Number" /* Number */ === inputType) {
|
|
3742
|
+
return {
|
|
3743
|
+
type: "number",
|
|
3744
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3745
|
+
};
|
|
3746
|
+
} else if ("Checkbox" /* Checkbox */ === inputType) {
|
|
3747
|
+
return {
|
|
3748
|
+
type: "boolean",
|
|
3749
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3750
|
+
};
|
|
3751
|
+
} else if ("DatePicker" /* DatePicker */ === inputType) {
|
|
3752
|
+
return {
|
|
3753
|
+
type: "dateString",
|
|
3754
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3755
|
+
};
|
|
3756
|
+
} else {
|
|
3757
|
+
return {
|
|
3758
|
+
type: "exprEditor",
|
|
3759
|
+
defaultValueHint: getDefaultValueHint("initialValue")
|
|
3760
|
+
};
|
|
3761
|
+
}
|
|
3762
|
+
}
|
|
3449
3763
|
},
|
|
3450
3764
|
rules: {
|
|
3451
3765
|
displayName: "Validation rules",
|
|
@@ -3542,11 +3856,113 @@ const commonFormItemProps = {
|
|
|
3542
3856
|
displayName: "Field control only",
|
|
3543
3857
|
description: "Don't render anything but the field control - so no label, help text, validation error, etc.",
|
|
3544
3858
|
advanced: true
|
|
3859
|
+
},
|
|
3860
|
+
preserve: {
|
|
3861
|
+
type: "boolean",
|
|
3862
|
+
advanced: true,
|
|
3863
|
+
defaultValueHint: true,
|
|
3864
|
+
description: "Keep field value even when field removed."
|
|
3545
3865
|
}
|
|
3546
|
-
};
|
|
3866
|
+
});
|
|
3867
|
+
const commonSimplifiedFormArrayItemType = (propName) => ({
|
|
3868
|
+
type: "object",
|
|
3869
|
+
fields: __spreadValues$d({
|
|
3870
|
+
label: {
|
|
3871
|
+
type: "string",
|
|
3872
|
+
defaultValueHint: getDefaultValueHint("label")
|
|
3873
|
+
},
|
|
3874
|
+
inputType: {
|
|
3875
|
+
type: "choice",
|
|
3876
|
+
options: Object.values(InputType).filter(
|
|
3877
|
+
(inputType) => ![
|
|
3878
|
+
"Option" /* Option */,
|
|
3879
|
+
"Option Group" /* OptionGroup */,
|
|
3880
|
+
"Radio" /* Radio */,
|
|
3881
|
+
"Unkown" /* Unknown */
|
|
3882
|
+
].includes(inputType)
|
|
3883
|
+
),
|
|
3884
|
+
defaultValue: "Text" /* Text */,
|
|
3885
|
+
defaultValueHint: getDefaultValueHint("inputType")
|
|
3886
|
+
},
|
|
3887
|
+
options: {
|
|
3888
|
+
type: "array",
|
|
3889
|
+
itemType: {
|
|
3890
|
+
type: "object",
|
|
3891
|
+
fields: {
|
|
3892
|
+
type: {
|
|
3893
|
+
type: "choice",
|
|
3894
|
+
options: [
|
|
3895
|
+
{ value: "option", label: "Option" },
|
|
3896
|
+
{ value: "option-group", label: "Option Group" }
|
|
3897
|
+
],
|
|
3898
|
+
defaultValue: "option",
|
|
3899
|
+
hidden: (ps, _ctx, { path }) => {
|
|
3900
|
+
var _a, _b;
|
|
3901
|
+
if (((_b = (_a = ps[propName]) == null ? void 0 : _a[path[1]]) == null ? void 0 : _b.inputType) !== "Select" /* Select */) {
|
|
3902
|
+
return true;
|
|
3903
|
+
}
|
|
3904
|
+
return false;
|
|
3905
|
+
}
|
|
3906
|
+
},
|
|
3907
|
+
label: "string",
|
|
3908
|
+
value: {
|
|
3909
|
+
type: "string",
|
|
3910
|
+
hidden: (ps, _ctx, { path, item }) => {
|
|
3911
|
+
var _a, _b;
|
|
3912
|
+
if (((_b = (_a = ps[propName]) == null ? void 0 : _a[path[1]]) == null ? void 0 : _b.inputType) !== "Select" /* Select */) {
|
|
3913
|
+
return false;
|
|
3914
|
+
}
|
|
3915
|
+
return item.type !== "option";
|
|
3916
|
+
}
|
|
3917
|
+
},
|
|
3918
|
+
options: {
|
|
3919
|
+
type: "array",
|
|
3920
|
+
itemType: {
|
|
3921
|
+
type: "object",
|
|
3922
|
+
nameFunc: (item) => item.label || item.value,
|
|
3923
|
+
fields: {
|
|
3924
|
+
value: "string",
|
|
3925
|
+
label: "string"
|
|
3926
|
+
}
|
|
3927
|
+
},
|
|
3928
|
+
hidden: (ps, _ctx, { path, item }) => {
|
|
3929
|
+
var _a, _b;
|
|
3930
|
+
if (((_b = (_a = ps[propName]) == null ? void 0 : _a[path[1]]) == null ? void 0 : _b.inputType) !== "Select" /* Select */) {
|
|
3931
|
+
return true;
|
|
3932
|
+
}
|
|
3933
|
+
return item.type !== "option-group";
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
},
|
|
3937
|
+
nameFunc: (item) => item == null ? void 0 : item.label
|
|
3938
|
+
},
|
|
3939
|
+
hidden: (_ps, _ctx, { item }) => !["Select" /* Select */, "Radio Group" /* RadioGroup */].includes(item.inputType)
|
|
3940
|
+
},
|
|
3941
|
+
optionType: {
|
|
3942
|
+
type: "choice",
|
|
3943
|
+
options: [
|
|
3944
|
+
{ value: "default", label: "Radio" },
|
|
3945
|
+
{ value: "button", label: "Button" }
|
|
3946
|
+
],
|
|
3947
|
+
hidden: (_ps, _ctx, { item }) => "Radio Group" /* RadioGroup */ !== item.inputType,
|
|
3948
|
+
defaultValueHint: "Radio",
|
|
3949
|
+
displayName: "Option Type"
|
|
3950
|
+
},
|
|
3951
|
+
showTime: {
|
|
3952
|
+
type: "boolean",
|
|
3953
|
+
displayName: "Show Time",
|
|
3954
|
+
description: "To provide an additional time selection",
|
|
3955
|
+
hidden: (_ps, _ctx, { item }) => !["DatePicker" /* DatePicker */].includes(item.inputType)
|
|
3956
|
+
}
|
|
3957
|
+
}, commonFormItemProps("simplified-form-item")),
|
|
3958
|
+
nameFunc: (item) => {
|
|
3959
|
+
var _a, _b;
|
|
3960
|
+
return (_b = (_a = item.fieldId) != null ? _a : item.label) != null ? _b : item.name;
|
|
3961
|
+
}
|
|
3962
|
+
});
|
|
3547
3963
|
const formItemComponentName = "plasmic-antd5-form-item";
|
|
3548
3964
|
function registerFormItem(loader) {
|
|
3549
|
-
registerComponentHelper(loader, FormItemWrapper, __spreadValues$
|
|
3965
|
+
registerComponentHelper(loader, FormItemWrapper, __spreadValues$d({
|
|
3550
3966
|
name: formItemComponentName,
|
|
3551
3967
|
displayName: "Form Field",
|
|
3552
3968
|
parentComponentName: formComponentName,
|
|
@@ -3554,8 +3970,8 @@ function registerFormItem(loader) {
|
|
|
3554
3970
|
marginBottom: "24px",
|
|
3555
3971
|
width: "stretch"
|
|
3556
3972
|
},
|
|
3557
|
-
props: __spreadValues$
|
|
3558
|
-
label: __spreadValues$
|
|
3973
|
+
props: __spreadValues$d({
|
|
3974
|
+
label: __spreadValues$d({
|
|
3559
3975
|
type: "slot",
|
|
3560
3976
|
defaultValue: {
|
|
3561
3977
|
type: "text",
|
|
@@ -3563,14 +3979,14 @@ function registerFormItem(loader) {
|
|
|
3563
3979
|
},
|
|
3564
3980
|
hidden: (ps) => !!ps.noLabel
|
|
3565
3981
|
}, { mergeWithParent: true }),
|
|
3566
|
-
children: __spreadValues$
|
|
3982
|
+
children: __spreadValues$d({
|
|
3567
3983
|
type: "slot",
|
|
3568
3984
|
defaultValue: {
|
|
3569
3985
|
type: "component",
|
|
3570
3986
|
name: inputComponentName
|
|
3571
3987
|
}
|
|
3572
3988
|
}, { mergeWithParent: true })
|
|
3573
|
-
}, commonFormItemProps),
|
|
3989
|
+
}, commonFormItemProps("advanced-form-item")),
|
|
3574
3990
|
importPath: "@plasmicpkgs/antd5/skinny/registerForm",
|
|
3575
3991
|
importName: "FormItemWrapper",
|
|
3576
3992
|
treeLabel: (ps) => ps.name,
|
|
@@ -3738,7 +4154,7 @@ const FormListWrapper = React__default.default.forwardRef(function FormListWrapp
|
|
|
3738
4154
|
}
|
|
3739
4155
|
}, [props.initialValue, fullFormItemName]);
|
|
3740
4156
|
}
|
|
3741
|
-
return /* @__PURE__ */ React__default.default.createElement(FormList, __spreadProps$
|
|
4157
|
+
return /* @__PURE__ */ React__default.default.createElement(FormList, __spreadProps$9(__spreadValues$d({}, props), { name: relativeFormItemName != null ? relativeFormItemName : [] }), (...args) => {
|
|
3742
4158
|
operationsRef.current = args;
|
|
3743
4159
|
return args[0].map((field, index) => /* @__PURE__ */ React__default.default.createElement(
|
|
3744
4160
|
PathContext.Provider,
|
|
@@ -3865,33 +4281,33 @@ function registerFormList(loader) {
|
|
|
3865
4281
|
});
|
|
3866
4282
|
}
|
|
3867
4283
|
|
|
3868
|
-
var __defProp$
|
|
3869
|
-
var __defProps$
|
|
3870
|
-
var __getOwnPropDescs$
|
|
3871
|
-
var __getOwnPropSymbols$
|
|
3872
|
-
var __hasOwnProp$
|
|
3873
|
-
var __propIsEnum$
|
|
3874
|
-
var __defNormalProp$
|
|
3875
|
-
var __spreadValues$
|
|
4284
|
+
var __defProp$c = Object.defineProperty;
|
|
4285
|
+
var __defProps$8 = Object.defineProperties;
|
|
4286
|
+
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
4287
|
+
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
4288
|
+
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
4289
|
+
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
4290
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4291
|
+
var __spreadValues$c = (a, b) => {
|
|
3876
4292
|
for (var prop in b || (b = {}))
|
|
3877
|
-
if (__hasOwnProp$
|
|
3878
|
-
__defNormalProp$
|
|
3879
|
-
if (__getOwnPropSymbols$
|
|
3880
|
-
for (var prop of __getOwnPropSymbols$
|
|
3881
|
-
if (__propIsEnum$
|
|
3882
|
-
__defNormalProp$
|
|
4293
|
+
if (__hasOwnProp$c.call(b, prop))
|
|
4294
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
4295
|
+
if (__getOwnPropSymbols$c)
|
|
4296
|
+
for (var prop of __getOwnPropSymbols$c(b)) {
|
|
4297
|
+
if (__propIsEnum$c.call(b, prop))
|
|
4298
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
3883
4299
|
}
|
|
3884
4300
|
return a;
|
|
3885
4301
|
};
|
|
3886
|
-
var __spreadProps$
|
|
3887
|
-
var __objRest$
|
|
4302
|
+
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
4303
|
+
var __objRest$9 = (source, exclude) => {
|
|
3888
4304
|
var target = {};
|
|
3889
4305
|
for (var prop in source)
|
|
3890
|
-
if (__hasOwnProp$
|
|
4306
|
+
if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3891
4307
|
target[prop] = source[prop];
|
|
3892
|
-
if (source != null && __getOwnPropSymbols$
|
|
3893
|
-
for (var prop of __getOwnPropSymbols$
|
|
3894
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
4308
|
+
if (source != null && __getOwnPropSymbols$c)
|
|
4309
|
+
for (var prop of __getOwnPropSymbols$c(source)) {
|
|
4310
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
|
|
3895
4311
|
target[prop] = source[prop];
|
|
3896
4312
|
}
|
|
3897
4313
|
return target;
|
|
@@ -3905,7 +4321,7 @@ function AntdModal(props) {
|
|
|
3905
4321
|
footer,
|
|
3906
4322
|
modalScopeClassName,
|
|
3907
4323
|
wrapClassName
|
|
3908
|
-
} = _a, rest = __objRest$
|
|
4324
|
+
} = _a, rest = __objRest$9(_a, [
|
|
3909
4325
|
"onOpenChange",
|
|
3910
4326
|
"onOk",
|
|
3911
4327
|
"onCancel",
|
|
@@ -3936,7 +4352,7 @@ function AntdModal(props) {
|
|
|
3936
4352
|
}, [onOpenChange, onCancel]);
|
|
3937
4353
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
3938
4354
|
antd.Modal,
|
|
3939
|
-
__spreadProps$
|
|
4355
|
+
__spreadProps$8(__spreadValues$c({}, rest), {
|
|
3940
4356
|
onOk: memoOnOk,
|
|
3941
4357
|
onCancel: memoOnCancel,
|
|
3942
4358
|
open,
|
|
@@ -4045,30 +4461,30 @@ function registerModal(loader) {
|
|
|
4045
4461
|
});
|
|
4046
4462
|
}
|
|
4047
4463
|
|
|
4048
|
-
var __defProp$
|
|
4049
|
-
var __getOwnPropSymbols$
|
|
4050
|
-
var __hasOwnProp$
|
|
4051
|
-
var __propIsEnum$
|
|
4052
|
-
var __defNormalProp$
|
|
4053
|
-
var __spreadValues$
|
|
4464
|
+
var __defProp$b = Object.defineProperty;
|
|
4465
|
+
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
4466
|
+
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
4467
|
+
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
4468
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4469
|
+
var __spreadValues$b = (a, b) => {
|
|
4054
4470
|
for (var prop in b || (b = {}))
|
|
4055
|
-
if (__hasOwnProp$
|
|
4056
|
-
__defNormalProp$
|
|
4057
|
-
if (__getOwnPropSymbols$
|
|
4058
|
-
for (var prop of __getOwnPropSymbols$
|
|
4059
|
-
if (__propIsEnum$
|
|
4060
|
-
__defNormalProp$
|
|
4471
|
+
if (__hasOwnProp$b.call(b, prop))
|
|
4472
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
4473
|
+
if (__getOwnPropSymbols$b)
|
|
4474
|
+
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
4475
|
+
if (__propIsEnum$b.call(b, prop))
|
|
4476
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
4061
4477
|
}
|
|
4062
4478
|
return a;
|
|
4063
4479
|
};
|
|
4064
|
-
var __objRest$
|
|
4480
|
+
var __objRest$8 = (source, exclude) => {
|
|
4065
4481
|
var target = {};
|
|
4066
4482
|
for (var prop in source)
|
|
4067
|
-
if (__hasOwnProp$
|
|
4483
|
+
if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
4068
4484
|
target[prop] = source[prop];
|
|
4069
|
-
if (source != null && __getOwnPropSymbols$
|
|
4070
|
-
for (var prop of __getOwnPropSymbols$
|
|
4071
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
4485
|
+
if (source != null && __getOwnPropSymbols$b)
|
|
4486
|
+
for (var prop of __getOwnPropSymbols$b(source)) {
|
|
4487
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
|
|
4072
4488
|
target[prop] = source[prop];
|
|
4073
4489
|
}
|
|
4074
4490
|
return target;
|
|
@@ -4083,7 +4499,7 @@ const AntdTable = React__default.default.forwardRef(function AntdTable2(props, r
|
|
|
4083
4499
|
setControlContextData,
|
|
4084
4500
|
selectedRowKeys,
|
|
4085
4501
|
defaultSelectedRowKeys
|
|
4086
|
-
} = _a, rest = __objRest$
|
|
4502
|
+
} = _a, rest = __objRest$8(_a, [
|
|
4087
4503
|
"data",
|
|
4088
4504
|
"onSelectedRowKeysChange",
|
|
4089
4505
|
"onSelectedRowsChange",
|
|
@@ -4149,7 +4565,7 @@ const AntdTable = React__default.default.forwardRef(function AntdTable2(props, r
|
|
|
4149
4565
|
);
|
|
4150
4566
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
4151
4567
|
antd.Table,
|
|
4152
|
-
__spreadValues$
|
|
4568
|
+
__spreadValues$b({
|
|
4153
4569
|
loading: data == null ? void 0 : data.isLoading,
|
|
4154
4570
|
dataSource: data == null ? void 0 : data.data,
|
|
4155
4571
|
rowSelection: selection,
|
|
@@ -4258,7 +4674,7 @@ function registerTable(loader) {
|
|
|
4258
4674
|
}
|
|
4259
4675
|
}
|
|
4260
4676
|
});
|
|
4261
|
-
registerComponentHelper(loader, AntdColumn, __spreadValues$
|
|
4677
|
+
registerComponentHelper(loader, AntdColumn, __spreadValues$b({
|
|
4262
4678
|
name: "plasmic-antd5-table-column",
|
|
4263
4679
|
displayName: "Column",
|
|
4264
4680
|
parentComponentName: "plasmic-antd5-table",
|
|
@@ -4295,7 +4711,7 @@ function registerTable(loader) {
|
|
|
4295
4711
|
importPath: "@plasmicpkgs/antd5/skinny/registerTable",
|
|
4296
4712
|
importName: "AntdColumn"
|
|
4297
4713
|
}, { isRenderless: true }));
|
|
4298
|
-
registerComponentHelper(loader, AntdColumnGroup, __spreadValues$
|
|
4714
|
+
registerComponentHelper(loader, AntdColumnGroup, __spreadValues$b({
|
|
4299
4715
|
name: "plasmic-antd5-table-column-group",
|
|
4300
4716
|
displayName: "Column Group",
|
|
4301
4717
|
parentComponentName: "plasmic-antd5-table",
|
|
@@ -4314,39 +4730,39 @@ function registerTable(loader) {
|
|
|
4314
4730
|
}, { isRenderless: true }));
|
|
4315
4731
|
}
|
|
4316
4732
|
|
|
4317
|
-
var __defProp$
|
|
4318
|
-
var __defProps$
|
|
4319
|
-
var __getOwnPropDescs$
|
|
4320
|
-
var __getOwnPropSymbols$
|
|
4321
|
-
var __hasOwnProp$
|
|
4322
|
-
var __propIsEnum$
|
|
4323
|
-
var __defNormalProp$
|
|
4324
|
-
var __spreadValues$
|
|
4733
|
+
var __defProp$a = Object.defineProperty;
|
|
4734
|
+
var __defProps$7 = Object.defineProperties;
|
|
4735
|
+
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
4736
|
+
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
4737
|
+
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
4738
|
+
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
4739
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4740
|
+
var __spreadValues$a = (a, b) => {
|
|
4325
4741
|
for (var prop in b || (b = {}))
|
|
4326
|
-
if (__hasOwnProp$
|
|
4327
|
-
__defNormalProp$
|
|
4328
|
-
if (__getOwnPropSymbols$
|
|
4329
|
-
for (var prop of __getOwnPropSymbols$
|
|
4330
|
-
if (__propIsEnum$
|
|
4331
|
-
__defNormalProp$
|
|
4742
|
+
if (__hasOwnProp$a.call(b, prop))
|
|
4743
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
4744
|
+
if (__getOwnPropSymbols$a)
|
|
4745
|
+
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
4746
|
+
if (__propIsEnum$a.call(b, prop))
|
|
4747
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
4332
4748
|
}
|
|
4333
4749
|
return a;
|
|
4334
4750
|
};
|
|
4335
|
-
var __spreadProps$
|
|
4336
|
-
var __objRest$
|
|
4751
|
+
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
4752
|
+
var __objRest$7 = (source, exclude) => {
|
|
4337
4753
|
var target = {};
|
|
4338
4754
|
for (var prop in source)
|
|
4339
|
-
if (__hasOwnProp$
|
|
4755
|
+
if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
4340
4756
|
target[prop] = source[prop];
|
|
4341
|
-
if (source != null && __getOwnPropSymbols$
|
|
4342
|
-
for (var prop of __getOwnPropSymbols$
|
|
4343
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
4757
|
+
if (source != null && __getOwnPropSymbols$a)
|
|
4758
|
+
for (var prop of __getOwnPropSymbols$a(source)) {
|
|
4759
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
|
|
4344
4760
|
target[prop] = source[prop];
|
|
4345
4761
|
}
|
|
4346
4762
|
return target;
|
|
4347
4763
|
};
|
|
4348
4764
|
function UploadWrapper(props) {
|
|
4349
|
-
const _a = props, { files, onFilesChange } = _a, rest = __objRest$
|
|
4765
|
+
const _a = props, { files, onFilesChange } = _a, rest = __objRest$7(_a, ["files", "onFilesChange"]);
|
|
4350
4766
|
const handleChange = (info) => {
|
|
4351
4767
|
const { file } = info;
|
|
4352
4768
|
if (file.status === "removed") {
|
|
@@ -4361,7 +4777,7 @@ function UploadWrapper(props) {
|
|
|
4361
4777
|
};
|
|
4362
4778
|
onFilesChange == null ? void 0 : onFilesChange([
|
|
4363
4779
|
...files,
|
|
4364
|
-
__spreadProps$
|
|
4780
|
+
__spreadProps$7(__spreadValues$a({}, metadata), {
|
|
4365
4781
|
status: "uploading"
|
|
4366
4782
|
})
|
|
4367
4783
|
]);
|
|
@@ -4369,7 +4785,7 @@ function UploadWrapper(props) {
|
|
|
4369
4785
|
reader.onload = () => {
|
|
4370
4786
|
onFilesChange == null ? void 0 : onFilesChange([
|
|
4371
4787
|
...files.filter((f) => f.uid !== file.uid),
|
|
4372
|
-
__spreadProps$
|
|
4788
|
+
__spreadProps$7(__spreadValues$a({}, metadata), {
|
|
4373
4789
|
contents: reader.result.replace(
|
|
4374
4790
|
/^data:[^;]+;base64,/,
|
|
4375
4791
|
""
|
|
@@ -4381,7 +4797,7 @@ function UploadWrapper(props) {
|
|
|
4381
4797
|
reader.onerror = (error) => {
|
|
4382
4798
|
onFilesChange == null ? void 0 : onFilesChange([
|
|
4383
4799
|
...files.filter((f) => f.uid !== file.uid),
|
|
4384
|
-
__spreadProps$
|
|
4800
|
+
__spreadProps$7(__spreadValues$a({}, metadata), {
|
|
4385
4801
|
status: "error"
|
|
4386
4802
|
})
|
|
4387
4803
|
]);
|
|
@@ -4393,7 +4809,7 @@ function UploadWrapper(props) {
|
|
|
4393
4809
|
};
|
|
4394
4810
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
4395
4811
|
antd.Upload,
|
|
4396
|
-
__spreadProps$
|
|
4812
|
+
__spreadProps$7(__spreadValues$a({}, rest), {
|
|
4397
4813
|
fileList: files,
|
|
4398
4814
|
beforeUpload: () => {
|
|
4399
4815
|
return false;
|
|
@@ -4412,7 +4828,7 @@ UploadWrapper.__plasmicFormFieldMeta = {
|
|
|
4412
4828
|
onChangePropName: "onFilesChange"
|
|
4413
4829
|
};
|
|
4414
4830
|
function registerUpload(loader) {
|
|
4415
|
-
registerComponentHelper(loader, UploadWrapper, __spreadProps$
|
|
4831
|
+
registerComponentHelper(loader, UploadWrapper, __spreadProps$7(__spreadValues$a({
|
|
4416
4832
|
name: "plasmic-antd5-upload",
|
|
4417
4833
|
displayName: "Upload",
|
|
4418
4834
|
props: {
|
|
@@ -4499,209 +4915,6 @@ function registerUpload(loader) {
|
|
|
4499
4915
|
}));
|
|
4500
4916
|
}
|
|
4501
4917
|
|
|
4502
|
-
var __defProp$a = Object.defineProperty;
|
|
4503
|
-
var __defProps$7 = Object.defineProperties;
|
|
4504
|
-
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
4505
|
-
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
4506
|
-
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
4507
|
-
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
4508
|
-
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4509
|
-
var __spreadValues$a = (a, b) => {
|
|
4510
|
-
for (var prop in b || (b = {}))
|
|
4511
|
-
if (__hasOwnProp$a.call(b, prop))
|
|
4512
|
-
__defNormalProp$a(a, prop, b[prop]);
|
|
4513
|
-
if (__getOwnPropSymbols$a)
|
|
4514
|
-
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
4515
|
-
if (__propIsEnum$a.call(b, prop))
|
|
4516
|
-
__defNormalProp$a(a, prop, b[prop]);
|
|
4517
|
-
}
|
|
4518
|
-
return a;
|
|
4519
|
-
};
|
|
4520
|
-
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
4521
|
-
var __objRest$7 = (source, exclude) => {
|
|
4522
|
-
var target = {};
|
|
4523
|
-
for (var prop in source)
|
|
4524
|
-
if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
4525
|
-
target[prop] = source[prop];
|
|
4526
|
-
if (source != null && __getOwnPropSymbols$a)
|
|
4527
|
-
for (var prop of __getOwnPropSymbols$a(source)) {
|
|
4528
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
|
|
4529
|
-
target[prop] = source[prop];
|
|
4530
|
-
}
|
|
4531
|
-
return target;
|
|
4532
|
-
};
|
|
4533
|
-
function AntdDatePicker(props) {
|
|
4534
|
-
const nativeInput = React__default.default.useRef(null);
|
|
4535
|
-
const [open, setOpen] = React.useState(false);
|
|
4536
|
-
const strValue = props.value && !(typeof props.value === "string") && "toISOString" in props.value ? props.value.toISOString() : props.value === null ? void 0 : props.value;
|
|
4537
|
-
const _a = props, { picker, popupScopeClassName } = _a, rest = __objRest$7(_a, ["picker", "popupScopeClassName"]);
|
|
4538
|
-
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
|
|
4539
|
-
antd.DatePicker,
|
|
4540
|
-
__spreadProps$7(__spreadValues$a({}, rest), {
|
|
4541
|
-
picker,
|
|
4542
|
-
value: props.value === void 0 ? void 0 : !props.value ? null : dayjs__default.default(props.value),
|
|
4543
|
-
defaultValue: props.defaultValue === void 0 ? void 0 : dayjs__default.default(props.defaultValue),
|
|
4544
|
-
popupClassName: popupScopeClassName,
|
|
4545
|
-
onChange: (value, _dateString) => {
|
|
4546
|
-
var _a2;
|
|
4547
|
-
(_a2 = props.onChange) == null ? void 0 : _a2.call(props, value !== null ? value.toISOString() : null);
|
|
4548
|
-
},
|
|
4549
|
-
open,
|
|
4550
|
-
onOpenChange: (_open) => {
|
|
4551
|
-
if (_open && window.innerWidth < 500) {
|
|
4552
|
-
nativeInput.current.showPicker();
|
|
4553
|
-
} else {
|
|
4554
|
-
setOpen(_open);
|
|
4555
|
-
}
|
|
4556
|
-
}
|
|
4557
|
-
})
|
|
4558
|
-
), /* @__PURE__ */ React__default.default.createElement(
|
|
4559
|
-
"input",
|
|
4560
|
-
{
|
|
4561
|
-
hidden: true,
|
|
4562
|
-
ref: nativeInput,
|
|
4563
|
-
type: props.showTime ? "datetime-local" : "date",
|
|
4564
|
-
value: strValue || "",
|
|
4565
|
-
onChange: (e) => {
|
|
4566
|
-
props.onChange(e.target.value);
|
|
4567
|
-
}
|
|
4568
|
-
}
|
|
4569
|
-
));
|
|
4570
|
-
}
|
|
4571
|
-
const datePickerComponentName = "plasmic-antd5-date-picker";
|
|
4572
|
-
function registerDatePicker(loader) {
|
|
4573
|
-
registerComponentHelper(loader, AntdDatePicker, {
|
|
4574
|
-
name: datePickerComponentName,
|
|
4575
|
-
displayName: "Date/Time Picker",
|
|
4576
|
-
props: {
|
|
4577
|
-
value: {
|
|
4578
|
-
type: "string",
|
|
4579
|
-
editOnly: true,
|
|
4580
|
-
uncontrolledProp: "defaultValue",
|
|
4581
|
-
description: "The current date/time as an ISO string, Date object, or dayjs object",
|
|
4582
|
-
hidden: (ps) => !!ps.__plasmicFormField
|
|
4583
|
-
},
|
|
4584
|
-
disabled: {
|
|
4585
|
-
type: "boolean",
|
|
4586
|
-
defaultValueHint: false
|
|
4587
|
-
},
|
|
4588
|
-
autoFocus: {
|
|
4589
|
-
type: "boolean",
|
|
4590
|
-
description: "Focus when component is rendered",
|
|
4591
|
-
defaultValueHint: false,
|
|
4592
|
-
advanced: true
|
|
4593
|
-
},
|
|
4594
|
-
onChange: {
|
|
4595
|
-
type: "eventHandler",
|
|
4596
|
-
argTypes: [{ name: "value", type: "string" }]
|
|
4597
|
-
},
|
|
4598
|
-
picker: {
|
|
4599
|
-
type: "choice",
|
|
4600
|
-
options: ["date", "week", "month", "quarter", "year"].map((value) => ({
|
|
4601
|
-
value,
|
|
4602
|
-
label: capitalize(value)
|
|
4603
|
-
})),
|
|
4604
|
-
defaultValueHint: "date"
|
|
4605
|
-
},
|
|
4606
|
-
popupScopeClassName: {
|
|
4607
|
-
type: "styleScopeClass",
|
|
4608
|
-
scopeName: "datePickerPopup"
|
|
4609
|
-
},
|
|
4610
|
-
popupClassName: {
|
|
4611
|
-
type: "class",
|
|
4612
|
-
displayName: "Popup container",
|
|
4613
|
-
selectors: [
|
|
4614
|
-
{
|
|
4615
|
-
selector: ":datePickerPopup .ant-picker-panel-container",
|
|
4616
|
-
label: "Base"
|
|
4617
|
-
}
|
|
4618
|
-
]
|
|
4619
|
-
},
|
|
4620
|
-
popupHeaderClassName: {
|
|
4621
|
-
type: "class",
|
|
4622
|
-
displayName: "Popup header",
|
|
4623
|
-
selectors: [
|
|
4624
|
-
{
|
|
4625
|
-
selector: ":datePickerPopup .ant-picker-header",
|
|
4626
|
-
label: "Base"
|
|
4627
|
-
}
|
|
4628
|
-
]
|
|
4629
|
-
},
|
|
4630
|
-
popupBodyClassName: {
|
|
4631
|
-
type: "class",
|
|
4632
|
-
displayName: "Popup body",
|
|
4633
|
-
selectors: [
|
|
4634
|
-
{
|
|
4635
|
-
selector: ":datePickerPopup .ant-picker-body",
|
|
4636
|
-
label: "Base"
|
|
4637
|
-
}
|
|
4638
|
-
]
|
|
4639
|
-
},
|
|
4640
|
-
popupFooterClassName: {
|
|
4641
|
-
type: "class",
|
|
4642
|
-
displayName: "Popup footer",
|
|
4643
|
-
selectors: [
|
|
4644
|
-
{
|
|
4645
|
-
selector: ":datePickerPopup .ant-picker-footer",
|
|
4646
|
-
label: "Base"
|
|
4647
|
-
}
|
|
4648
|
-
]
|
|
4649
|
-
},
|
|
4650
|
-
showTime: {
|
|
4651
|
-
type: "boolean",
|
|
4652
|
-
description: "Enable time selection"
|
|
4653
|
-
},
|
|
4654
|
-
bordered: {
|
|
4655
|
-
type: "boolean",
|
|
4656
|
-
advanced: true
|
|
4657
|
-
},
|
|
4658
|
-
// TODO - see how it works with plasmic-rich-components
|
|
4659
|
-
// format: {
|
|
4660
|
-
// advanced: true
|
|
4661
|
-
// },
|
|
4662
|
-
showNow: {
|
|
4663
|
-
type: "boolean",
|
|
4664
|
-
advanced: true,
|
|
4665
|
-
description: 'Whether to show the "Now" button',
|
|
4666
|
-
defaultValueHint: true,
|
|
4667
|
-
hidden: (ps) => !ps.showTime
|
|
4668
|
-
},
|
|
4669
|
-
showToday: {
|
|
4670
|
-
type: "boolean",
|
|
4671
|
-
advanced: true,
|
|
4672
|
-
description: 'Whether to show the "Today" button',
|
|
4673
|
-
defaultValueHint: true,
|
|
4674
|
-
hidden: (ps) => ps.showTime
|
|
4675
|
-
},
|
|
4676
|
-
// disabledDate: {
|
|
4677
|
-
// type: "function",
|
|
4678
|
-
// advanced: true,
|
|
4679
|
-
// description: "Dates to disable",
|
|
4680
|
-
// },
|
|
4681
|
-
// disabledTime: {
|
|
4682
|
-
// type: "function",
|
|
4683
|
-
// advanced: true,
|
|
4684
|
-
// description: "Times to disable",
|
|
4685
|
-
// },
|
|
4686
|
-
allowClear: {
|
|
4687
|
-
type: "boolean",
|
|
4688
|
-
advanced: true,
|
|
4689
|
-
description: "Whether to show the clear button"
|
|
4690
|
-
}
|
|
4691
|
-
},
|
|
4692
|
-
states: {
|
|
4693
|
-
value: {
|
|
4694
|
-
type: "writable",
|
|
4695
|
-
valueProp: "value",
|
|
4696
|
-
onChangeProp: "onChange",
|
|
4697
|
-
variableType: "text"
|
|
4698
|
-
}
|
|
4699
|
-
},
|
|
4700
|
-
importPath: "@plasmicpkgs/antd5/skinny/registerDatePicker",
|
|
4701
|
-
importName: "AntdDatePicker"
|
|
4702
|
-
});
|
|
4703
|
-
}
|
|
4704
|
-
|
|
4705
4918
|
var __defProp$9 = Object.defineProperty;
|
|
4706
4919
|
var __defProps$6 = Object.defineProperties;
|
|
4707
4920
|
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|