@plasmicpkgs/antd5 0.0.56 → 0.0.59

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.
Files changed (61) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/antd.esm.js +2047 -1788
  3. package/dist/antd.esm.js.map +1 -1
  4. package/dist/index.d.ts +19 -0
  5. package/dist/index.js +2053 -1786
  6. package/dist/index.js.map +1 -1
  7. package/dist/registerButton.d.ts +1 -0
  8. package/dist/registerCheckbox.d.ts +7 -0
  9. package/dist/registerForm.d.ts +34 -0
  10. package/dist/registerInput.d.ts +4 -0
  11. package/dist/registerMenu.d.ts +46 -0
  12. package/dist/registerRadio.d.ts +3 -0
  13. package/dist/registerSelect.d.ts +3 -0
  14. package/dist/registerSwitch.d.ts +11 -0
  15. package/package.json +3 -3
  16. package/skinny/registerButton.cjs.js +3 -1
  17. package/skinny/registerButton.cjs.js.map +1 -1
  18. package/skinny/registerButton.d.ts +1 -0
  19. package/skinny/registerButton.esm.js +3 -2
  20. package/skinny/registerButton.esm.js.map +1 -1
  21. package/skinny/registerCheckbox.cjs.js +11 -10
  22. package/skinny/registerCheckbox.cjs.js.map +1 -1
  23. package/skinny/registerCheckbox.d.ts +7 -0
  24. package/skinny/registerCheckbox.esm.js +10 -11
  25. package/skinny/registerCheckbox.esm.js.map +1 -1
  26. package/skinny/registerConfigProvider.cjs.js.map +1 -1
  27. package/skinny/registerConfigProvider.esm.js.map +1 -1
  28. package/skinny/registerDropdown.cjs.js +1 -1
  29. package/skinny/registerDropdown.cjs.js.map +1 -1
  30. package/skinny/registerDropdown.esm.js +2 -2
  31. package/skinny/registerDropdown.esm.js.map +1 -1
  32. package/skinny/registerForm.cjs.js +312 -153
  33. package/skinny/registerForm.cjs.js.map +1 -1
  34. package/skinny/registerForm.d.ts +34 -0
  35. package/skinny/registerForm.esm.js +309 -155
  36. package/skinny/registerForm.esm.js.map +1 -1
  37. package/skinny/registerInput.cjs.js +23 -11
  38. package/skinny/registerInput.cjs.js.map +1 -1
  39. package/skinny/registerInput.d.ts +4 -0
  40. package/skinny/registerInput.esm.js +20 -12
  41. package/skinny/registerInput.esm.js.map +1 -1
  42. package/skinny/registerMenu.cjs.js +17 -0
  43. package/skinny/registerMenu.cjs.js.map +1 -1
  44. package/skinny/registerMenu.d.ts +46 -0
  45. package/skinny/registerMenu.esm.js +17 -1
  46. package/skinny/registerMenu.esm.js.map +1 -1
  47. package/skinny/registerRadio.cjs.js +14 -7
  48. package/skinny/registerRadio.cjs.js.map +1 -1
  49. package/skinny/registerRadio.d.ts +3 -0
  50. package/skinny/registerRadio.esm.js +12 -8
  51. package/skinny/registerRadio.esm.js.map +1 -1
  52. package/skinny/registerSelect.cjs.js +15 -8
  53. package/skinny/registerSelect.cjs.js.map +1 -1
  54. package/skinny/registerSelect.d.ts +3 -0
  55. package/skinny/registerSelect.esm.js +13 -9
  56. package/skinny/registerSelect.esm.js.map +1 -1
  57. package/skinny/registerSwitch.cjs.js +79 -0
  58. package/skinny/registerSwitch.cjs.js.map +1 -0
  59. package/skinny/registerSwitch.d.ts +11 -0
  60. package/skinny/registerSwitch.esm.js +71 -0
  61. package/skinny/registerSwitch.esm.js.map +1 -0
package/dist/index.js CHANGED
@@ -74,33 +74,33 @@ function usePrevious(value) {
74
74
  return prevValue.current;
75
75
  }
76
76
 
77
- var __defProp$c = Object.defineProperty;
78
- var __defProps$9 = Object.defineProperties;
79
- var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
80
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
81
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
82
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
83
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
84
- var __spreadValues$c = (a, b) => {
77
+ var __defProp$d = Object.defineProperty;
78
+ var __defProps$a = Object.defineProperties;
79
+ var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
80
+ var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
81
+ var __hasOwnProp$d = Object.prototype.hasOwnProperty;
82
+ var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
83
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
84
+ var __spreadValues$d = (a, b) => {
85
85
  for (var prop in b || (b = {}))
86
- if (__hasOwnProp$c.call(b, prop))
87
- __defNormalProp$c(a, prop, b[prop]);
88
- if (__getOwnPropSymbols$c)
89
- for (var prop of __getOwnPropSymbols$c(b)) {
90
- if (__propIsEnum$c.call(b, prop))
91
- __defNormalProp$c(a, prop, b[prop]);
86
+ if (__hasOwnProp$d.call(b, prop))
87
+ __defNormalProp$d(a, prop, b[prop]);
88
+ if (__getOwnPropSymbols$d)
89
+ for (var prop of __getOwnPropSymbols$d(b)) {
90
+ if (__propIsEnum$d.call(b, prop))
91
+ __defNormalProp$d(a, prop, b[prop]);
92
92
  }
93
93
  return a;
94
94
  };
95
- var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
95
+ var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
96
96
  var __objRest$9 = (source, exclude) => {
97
97
  var target = {};
98
98
  for (var prop in source)
99
- if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
99
+ if (__hasOwnProp$d.call(source, prop) && exclude.indexOf(prop) < 0)
100
100
  target[prop] = source[prop];
101
- if (source != null && __getOwnPropSymbols$c)
102
- for (var prop of __getOwnPropSymbols$c(source)) {
103
- if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
101
+ if (source != null && __getOwnPropSymbols$d)
102
+ for (var prop of __getOwnPropSymbols$d(source)) {
103
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$d.call(source, prop))
104
104
  target[prop] = source[prop];
105
105
  }
106
106
  return target;
@@ -110,16 +110,17 @@ function AntdButton(props) {
110
110
  const target = props.target === true ? "_blank" : props.target === false ? void 0 : props.target;
111
111
  return /* @__PURE__ */ React__default.default.createElement(
112
112
  antd.Button,
113
- __spreadProps$9(__spreadValues$c(__spreadProps$9(__spreadValues$c({}, rest), {
113
+ __spreadProps$a(__spreadValues$d(__spreadProps$a(__spreadValues$d({}, rest), {
114
114
  htmlType: submitsForm ? "submit" : "button"
115
115
  }), rest), {
116
116
  target
117
117
  })
118
118
  );
119
119
  }
120
+ const buttonComponentName = "plasmic-antd5-button";
120
121
  function registerButton(loader) {
121
122
  registerComponentHelper(loader, AntdButton, {
122
- name: "plasmic-antd5-button",
123
+ name: buttonComponentName,
123
124
  displayName: "Button",
124
125
  props: {
125
126
  type: {
@@ -180,7 +181,7 @@ function registerButton(loader) {
180
181
  hidden: (props) => !props.href,
181
182
  defaultValueHint: false
182
183
  },
183
- children: __spreadValues$c({
184
+ children: __spreadValues$d({
184
185
  type: "slot",
185
186
  defaultValue: [
186
187
  {
@@ -204,33 +205,33 @@ function registerButton(loader) {
204
205
  });
205
206
  }
206
207
 
207
- var __defProp$b = Object.defineProperty;
208
- var __defProps$8 = Object.defineProperties;
209
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
210
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
211
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
212
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
213
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
214
- var __spreadValues$b = (a, b) => {
208
+ var __defProp$c = Object.defineProperty;
209
+ var __defProps$9 = Object.defineProperties;
210
+ var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
211
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
212
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
213
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
214
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
215
+ var __spreadValues$c = (a, b) => {
215
216
  for (var prop in b || (b = {}))
216
- if (__hasOwnProp$b.call(b, prop))
217
- __defNormalProp$b(a, prop, b[prop]);
218
- if (__getOwnPropSymbols$b)
219
- for (var prop of __getOwnPropSymbols$b(b)) {
220
- if (__propIsEnum$b.call(b, prop))
221
- __defNormalProp$b(a, prop, b[prop]);
217
+ if (__hasOwnProp$c.call(b, prop))
218
+ __defNormalProp$c(a, prop, b[prop]);
219
+ if (__getOwnPropSymbols$c)
220
+ for (var prop of __getOwnPropSymbols$c(b)) {
221
+ if (__propIsEnum$c.call(b, prop))
222
+ __defNormalProp$c(a, prop, b[prop]);
222
223
  }
223
224
  return a;
224
225
  };
225
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
226
+ var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
226
227
  var __objRest$8 = (source, exclude) => {
227
228
  var target = {};
228
229
  for (var prop in source)
229
- if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
230
+ if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
230
231
  target[prop] = source[prop];
231
- if (source != null && __getOwnPropSymbols$b)
232
- for (var prop of __getOwnPropSymbols$b(source)) {
233
- if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
232
+ if (source != null && __getOwnPropSymbols$c)
233
+ for (var prop of __getOwnPropSymbols$c(source)) {
234
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
234
235
  target[prop] = source[prop];
235
236
  }
236
237
  return target;
@@ -244,12 +245,15 @@ function AntdCheckbox(props) {
244
245
  return void 0;
245
246
  }
246
247
  }, [onChange]);
247
- return /* @__PURE__ */ React__default.default.createElement(antd.Checkbox, __spreadProps$8(__spreadValues$b({}, rest), { onChange: wrappedOnChange }));
248
+ return /* @__PURE__ */ React__default.default.createElement(antd.Checkbox, __spreadProps$9(__spreadValues$c({}, rest), { onChange: wrappedOnChange }));
248
249
  }
250
+ AntdCheckbox.__plasmicFormFieldMeta = { valueProp: "checked" };
249
251
  const AntdCheckboxGroup = antd.Checkbox.Group;
252
+ const checkboxComponentName = "plasmic-antd5-checkbox";
253
+ const checkboxGroupComponentName = "plasmic-antd5-checkbox";
250
254
  function registerCheckbox(loader) {
251
255
  registerComponentHelper(loader, AntdCheckbox, {
252
- name: "plasmic-antd5-checkbox",
256
+ name: checkboxComponentName,
253
257
  displayName: "Checkbox",
254
258
  props: {
255
259
  checked: {
@@ -257,11 +261,12 @@ function registerCheckbox(loader) {
257
261
  editOnly: true,
258
262
  uncontrolledProp: "defaultChecked",
259
263
  description: "Specifies the initial state: whether or not the checkbox is selected",
260
- defaultValueHint: false
264
+ defaultValueHint: false,
265
+ hidden: (ps) => !!ps.__plasmicFormField
261
266
  },
262
267
  disabled: {
263
268
  type: "boolean",
264
- description: "If disable checkbox",
269
+ description: "If checkbox is disabled",
265
270
  defaultValueHint: false
266
271
  },
267
272
  indeterminate: {
@@ -269,18 +274,13 @@ function registerCheckbox(loader) {
269
274
  description: "The indeterminate checked state of checkbox",
270
275
  defaultValueHint: false
271
276
  },
272
- value: {
273
- type: "string",
274
- description: "The checkbox value",
275
- advanced: true
276
- },
277
277
  autoFocus: {
278
278
  type: "boolean",
279
279
  description: "If get focus when component mounted",
280
280
  defaultValueHint: false,
281
281
  advanced: true
282
282
  },
283
- children: __spreadValues$b({
283
+ children: __spreadValues$c({
284
284
  type: "slot",
285
285
  defaultValue: [
286
286
  {
@@ -306,7 +306,7 @@ function registerCheckbox(loader) {
306
306
  importName: "AntdCheckbox"
307
307
  });
308
308
  registerComponentHelper(loader, AntdCheckboxGroup, {
309
- name: "plasmic-antd5-checkbox-group",
309
+ name: checkboxGroupComponentName,
310
310
  displayName: "Checkbox Group",
311
311
  props: {
312
312
  value: {
@@ -357,37 +357,37 @@ function registerCheckbox(loader) {
357
357
  },
358
358
  importPath: "@plasmicpkgs/antd5/skinny/registerCheckbox",
359
359
  importName: "AntdCheckboxGroup",
360
- parentComponentName: "plasmic-antd5-checkbox"
360
+ parentComponentName: checkboxComponentName
361
361
  });
362
362
  }
363
363
 
364
- var __defProp$a = Object.defineProperty;
365
- var __defProps$7 = Object.defineProperties;
366
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
367
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
368
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
369
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
370
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
371
- var __spreadValues$a = (a, b) => {
364
+ var __defProp$b = Object.defineProperty;
365
+ var __defProps$8 = Object.defineProperties;
366
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
367
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
368
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
369
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
370
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
371
+ var __spreadValues$b = (a, b) => {
372
372
  for (var prop in b || (b = {}))
373
- if (__hasOwnProp$a.call(b, prop))
374
- __defNormalProp$a(a, prop, b[prop]);
375
- if (__getOwnPropSymbols$a)
376
- for (var prop of __getOwnPropSymbols$a(b)) {
377
- if (__propIsEnum$a.call(b, prop))
378
- __defNormalProp$a(a, prop, b[prop]);
373
+ if (__hasOwnProp$b.call(b, prop))
374
+ __defNormalProp$b(a, prop, b[prop]);
375
+ if (__getOwnPropSymbols$b)
376
+ for (var prop of __getOwnPropSymbols$b(b)) {
377
+ if (__propIsEnum$b.call(b, prop))
378
+ __defNormalProp$b(a, prop, b[prop]);
379
379
  }
380
380
  return a;
381
381
  };
382
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
382
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
383
383
  var __objRest$7 = (source, exclude) => {
384
384
  var target = {};
385
385
  for (var prop in source)
386
- if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
386
+ if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
387
387
  target[prop] = source[prop];
388
- if (source != null && __getOwnPropSymbols$a)
389
- for (var prop of __getOwnPropSymbols$a(source)) {
390
- if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
388
+ if (source != null && __getOwnPropSymbols$b)
389
+ for (var prop of __getOwnPropSymbols$b(source)) {
390
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
391
391
  target[prop] = source[prop];
392
392
  }
393
393
  return target;
@@ -438,9 +438,9 @@ function AntdConfigProvider(props) {
438
438
  const _a = props, { children, themeStyles } = _a, rest = __objRest$7(_a, ["children", "themeStyles"]);
439
439
  return /* @__PURE__ */ React__default.default.createElement(
440
440
  antd.ConfigProvider,
441
- __spreadValues$a({
441
+ __spreadValues$b({
442
442
  locale: defaultLocale
443
- }, themeToAntdConfig(__spreadProps$7(__spreadValues$a({}, rest), {
443
+ }, themeToAntdConfig(__spreadProps$8(__spreadValues$b({}, rest), {
444
444
  fontFamily: themeStyles.fontFamily,
445
445
  fontSize: themeStyles.fontSize ? parseInt(themeStyles.fontSize) : void 0,
446
446
  lineHeight: themeStyles.lineHeight ? parseInt(themeStyles.lineHeight) : void 0,
@@ -476,7 +476,7 @@ function InnerConfigProvider(props) {
476
476
  showNotification: (opts) => {
477
477
  var _b;
478
478
  const _a = opts, rest = __objRest$7(_a, ["type"]);
479
- app.notification[(_b = opts.type) != null ? _b : "info"](__spreadValues$a({}, rest));
479
+ app.notification[(_b = opts.type) != null ? _b : "info"](__spreadValues$b({}, rest));
480
480
  },
481
481
  hideNotifications: () => {
482
482
  app.notification.destroy();
@@ -773,7 +773,7 @@ function registerTokens(loader) {
773
773
  }
774
774
  const registerConfigProvider = makeRegisterGlobalContext(
775
775
  AntdConfigProvider,
776
- __spreadProps$7(__spreadValues$a({
776
+ __spreadProps$8(__spreadValues$b({
777
777
  name: "plasmic-antd5-config-provider",
778
778
  displayName: "Ant Design System Settings",
779
779
  props: {
@@ -875,22 +875,25 @@ const registerConfigProvider = makeRegisterGlobalContext(
875
875
  })
876
876
  );
877
877
 
878
- var __defProp$9 = Object.defineProperty;
879
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
880
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
881
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
882
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
883
- var __spreadValues$9 = (a, b) => {
878
+ var __defProp$a = Object.defineProperty;
879
+ var __defProps$7 = Object.defineProperties;
880
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
881
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
882
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
883
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
884
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
885
+ var __spreadValues$a = (a, b) => {
884
886
  for (var prop in b || (b = {}))
885
- if (__hasOwnProp$9.call(b, prop))
886
- __defNormalProp$9(a, prop, b[prop]);
887
- if (__getOwnPropSymbols$9)
888
- for (var prop of __getOwnPropSymbols$9(b)) {
889
- if (__propIsEnum$9.call(b, prop))
890
- __defNormalProp$9(a, prop, b[prop]);
887
+ if (__hasOwnProp$a.call(b, prop))
888
+ __defNormalProp$a(a, prop, b[prop]);
889
+ if (__getOwnPropSymbols$a)
890
+ for (var prop of __getOwnPropSymbols$a(b)) {
891
+ if (__propIsEnum$a.call(b, prop))
892
+ __defNormalProp$a(a, prop, b[prop]);
891
893
  }
892
894
  return a;
893
895
  };
896
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
894
897
  const AntdMenu = antd.Menu;
895
898
  const AntdMenuDivider = antd.Menu.Divider;
896
899
  const AntdMenuItem = antd.Menu.Item;
@@ -936,10 +939,23 @@ const MENU_ITEM_TYPE = {
936
939
  type: "array",
937
940
  displayName: "Menu items",
938
941
  hidden: (ps) => ps.type !== "submenu" && ps.type !== "group"
942
+ },
943
+ onClick: {
944
+ type: "eventHandler",
945
+ displayName: "Action",
946
+ description: "Action to perform when this item is selected",
947
+ argTypes: [{ name: "info", type: "object" }],
948
+ hidden: (ps) => ps.type !== "item"
939
949
  }
940
950
  }
941
951
  };
952
+ const UNKEYED_MENU_ITEM_TYPE = __spreadProps$7(__spreadValues$a({}, MENU_ITEM_TYPE), {
953
+ fields: Object.fromEntries(
954
+ Object.entries(MENU_ITEM_TYPE.fields).filter(([k]) => k !== "key")
955
+ )
956
+ });
942
957
  MENU_ITEM_TYPE.fields.children.itemType = MENU_ITEM_TYPE;
958
+ UNKEYED_MENU_ITEM_TYPE.fields.children.itemType = UNKEYED_MENU_ITEM_TYPE;
943
959
  function registerMenu(loader) {
944
960
  registerComponentHelper(loader, AntdMenu, {
945
961
  name: "plasmic-antd5-menu",
@@ -1019,7 +1035,7 @@ function registerMenu(loader) {
1019
1035
  type: "string",
1020
1036
  description: "Set display title for collapsed item"
1021
1037
  },
1022
- children: __spreadValues$9({
1038
+ children: __spreadValues$a({
1023
1039
  type: "slot",
1024
1040
  defaultValue: [
1025
1041
  {
@@ -1127,21 +1143,21 @@ function registerMenu(loader) {
1127
1143
  });
1128
1144
  }
1129
1145
 
1130
- var __defProp$8 = Object.defineProperty;
1146
+ var __defProp$9 = Object.defineProperty;
1131
1147
  var __defProps$6 = Object.defineProperties;
1132
1148
  var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
1133
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
1134
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
1135
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
1136
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1137
- var __spreadValues$8 = (a, b) => {
1149
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
1150
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
1151
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
1152
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1153
+ var __spreadValues$9 = (a, b) => {
1138
1154
  for (var prop in b || (b = {}))
1139
- if (__hasOwnProp$8.call(b, prop))
1140
- __defNormalProp$8(a, prop, b[prop]);
1141
- if (__getOwnPropSymbols$8)
1142
- for (var prop of __getOwnPropSymbols$8(b)) {
1143
- if (__propIsEnum$8.call(b, prop))
1144
- __defNormalProp$8(a, prop, b[prop]);
1155
+ if (__hasOwnProp$9.call(b, prop))
1156
+ __defNormalProp$9(a, prop, b[prop]);
1157
+ if (__getOwnPropSymbols$9)
1158
+ for (var prop of __getOwnPropSymbols$9(b)) {
1159
+ if (__propIsEnum$9.call(b, prop))
1160
+ __defNormalProp$9(a, prop, b[prop]);
1145
1161
  }
1146
1162
  return a;
1147
1163
  };
@@ -1149,11 +1165,11 @@ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
1149
1165
  var __objRest$6 = (source, exclude) => {
1150
1166
  var target = {};
1151
1167
  for (var prop in source)
1152
- if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
1168
+ if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
1153
1169
  target[prop] = source[prop];
1154
- if (source != null && __getOwnPropSymbols$8)
1155
- for (var prop of __getOwnPropSymbols$8(source)) {
1156
- if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
1170
+ if (source != null && __getOwnPropSymbols$9)
1171
+ for (var prop of __getOwnPropSymbols$9(source)) {
1172
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
1157
1173
  target[prop] = source[prop];
1158
1174
  }
1159
1175
  return target;
@@ -1176,7 +1192,7 @@ function AntdDropdown(props) {
1176
1192
  ]);
1177
1193
  return /* @__PURE__ */ React__default.default.createElement(
1178
1194
  antd.Dropdown,
1179
- __spreadProps$6(__spreadValues$8({}, rest), {
1195
+ __spreadProps$6(__spreadValues$9({}, rest), {
1180
1196
  trigger: [trigger],
1181
1197
  overlay: () => {
1182
1198
  var _a2;
@@ -1225,7 +1241,7 @@ function registerDropdown(loader) {
1225
1241
  type: "array",
1226
1242
  displayName: "Menu Items",
1227
1243
  hidden: (ps) => ps.useMenuItemsSlot,
1228
- itemType: MENU_ITEM_TYPE,
1244
+ itemType: UNKEYED_MENU_ITEM_TYPE,
1229
1245
  defaultValue: [
1230
1246
  {
1231
1247
  type: "item",
@@ -1281,7 +1297,7 @@ function registerDropdown(loader) {
1281
1297
  advanced: true,
1282
1298
  description: "Instead of configuring a list of menu items, build the menu items using MenuItem elements. This gives you greater control over item styling."
1283
1299
  },
1284
- children: __spreadValues$8({
1300
+ children: __spreadValues$9({
1285
1301
  type: "slot",
1286
1302
  defaultValue: [
1287
1303
  {
@@ -1312,19 +1328,19 @@ function registerDropdown(loader) {
1312
1328
  });
1313
1329
  }
1314
1330
 
1315
- var __defProp$7 = Object.defineProperty;
1316
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1317
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1318
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1319
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1320
- var __spreadValues$7 = (a, b) => {
1331
+ var __defProp$8 = Object.defineProperty;
1332
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
1333
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
1334
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
1335
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1336
+ var __spreadValues$8 = (a, b) => {
1321
1337
  for (var prop in b || (b = {}))
1322
- if (__hasOwnProp$7.call(b, prop))
1323
- __defNormalProp$7(a, prop, b[prop]);
1324
- if (__getOwnPropSymbols$7)
1325
- for (var prop of __getOwnPropSymbols$7(b)) {
1326
- if (__propIsEnum$7.call(b, prop))
1327
- __defNormalProp$7(a, prop, b[prop]);
1338
+ if (__hasOwnProp$8.call(b, prop))
1339
+ __defNormalProp$8(a, prop, b[prop]);
1340
+ if (__getOwnPropSymbols$8)
1341
+ for (var prop of __getOwnPropSymbols$8(b)) {
1342
+ if (__propIsEnum$8.call(b, prop))
1343
+ __defNormalProp$8(a, prop, b[prop]);
1328
1344
  }
1329
1345
  return a;
1330
1346
  };
@@ -1335,7 +1351,7 @@ function mergeProps(props, ...restProps) {
1335
1351
  if (restProps.every((rest) => Object.keys(rest).length === 0)) {
1336
1352
  return props;
1337
1353
  }
1338
- const result = __spreadValues$7({}, props);
1354
+ const result = __spreadValues$8({}, props);
1339
1355
  for (const rest of restProps) {
1340
1356
  for (const key of Object.keys(rest)) {
1341
1357
  result[key] = mergePropVals(key, result[key], rest[key]);
@@ -1372,7 +1388,7 @@ function mergePropVals(name, val1, val2) {
1372
1388
  } else if (name === "className") {
1373
1389
  return classNames__default.default(val1, val2);
1374
1390
  } else if (name === "style") {
1375
- return __spreadValues$7(__spreadValues$7({}, val1), val2);
1391
+ return __spreadValues$8(__spreadValues$8({}, val1), val2);
1376
1392
  } else if (name === "ref") {
1377
1393
  return mergeRefs(val1, val2);
1378
1394
  } else if (typeof val1 !== typeof val2) {
@@ -1393,1588 +1409,2009 @@ function mergePropVals(name, val1, val2) {
1393
1409
  }
1394
1410
  }
1395
1411
 
1396
- var __defProp$6 = Object.defineProperty;
1412
+ var __defProp$7 = Object.defineProperty;
1397
1413
  var __defProps$5 = Object.defineProperties;
1398
1414
  var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
1399
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1400
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1401
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1402
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1403
- var __spreadValues$6 = (a, b) => {
1415
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1416
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1417
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1418
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1419
+ var __spreadValues$7 = (a, b) => {
1404
1420
  for (var prop in b || (b = {}))
1405
- if (__hasOwnProp$6.call(b, prop))
1406
- __defNormalProp$6(a, prop, b[prop]);
1407
- if (__getOwnPropSymbols$6)
1408
- for (var prop of __getOwnPropSymbols$6(b)) {
1409
- if (__propIsEnum$6.call(b, prop))
1410
- __defNormalProp$6(a, prop, b[prop]);
1421
+ if (__hasOwnProp$7.call(b, prop))
1422
+ __defNormalProp$7(a, prop, b[prop]);
1423
+ if (__getOwnPropSymbols$7)
1424
+ for (var prop of __getOwnPropSymbols$7(b)) {
1425
+ if (__propIsEnum$7.call(b, prop))
1426
+ __defNormalProp$7(a, prop, b[prop]);
1411
1427
  }
1412
1428
  return a;
1413
1429
  };
1414
1430
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
1415
- var __objRest$5 = (source, exclude) => {
1416
- var target = {};
1417
- for (var prop in source)
1418
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1419
- target[prop] = source[prop];
1420
- if (source != null && __getOwnPropSymbols$6)
1421
- for (var prop of __getOwnPropSymbols$6(source)) {
1422
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1423
- target[prop] = source[prop];
1431
+ const AntdInput = antd.Input;
1432
+ const AntdTextArea = antd.Input.TextArea;
1433
+ const AntdPassword = antd.Input.Password;
1434
+ const AntdInputNumber = antd.InputNumber;
1435
+ const inputHelpers = {
1436
+ states: {
1437
+ value: {
1438
+ onChangeArgsToValue: (e) => {
1439
+ return e.target.value;
1440
+ }
1424
1441
  }
1425
- return target;
1442
+ }
1426
1443
  };
1427
- const reactNodeToString = function(reactNode) {
1428
- let string = "";
1429
- if (typeof reactNode === "string") {
1430
- string = reactNode;
1431
- } else if (typeof reactNode === "number") {
1432
- string = reactNode.toString();
1433
- } else if (reactNode instanceof Array) {
1434
- reactNode.forEach(function(child) {
1435
- string += reactNodeToString(child);
1436
- });
1437
- } else if (React.isValidElement(reactNode)) {
1438
- string += reactNodeToString(reactNode.props.children);
1444
+ const COMMON_HELPERS_CONFIG = {
1445
+ helpers: inputHelpers,
1446
+ importName: "inputHelpers",
1447
+ importPath: "@plasmicpkgs/antd5/skinny/registerInput"
1448
+ };
1449
+ const COMMON_STATES = {
1450
+ value: {
1451
+ type: "writable",
1452
+ valueProp: "value",
1453
+ variableType: "text",
1454
+ onChangeProp: "onChange"
1439
1455
  }
1440
- return string;
1441
1456
  };
1442
- function ensureArray(x) {
1443
- return Array.isArray(x) ? x : [x];
1444
- }
1445
- const FormItem = antd.Form.Item;
1446
- const FormList = antd.Form.List;
1447
- const PathContext = React__default.default.createContext({ relativePath: [], fullPath: [] });
1448
- const InternalFormInstanceContext = React__default.default.createContext(void 0);
1449
- const FormLayoutContext = React__default.default.createContext(void 0);
1450
- const Internal = (props) => {
1451
- var _b, _c, _d;
1452
- const [form] = antd.Form.useForm();
1453
- const values = form.getFieldsValue(true);
1454
- const lastValue = React__default.default.useRef(values);
1455
- const _a = props, { extendedOnValuesChange, setRemountKey } = _a, rest = __objRest$5(_a, ["extendedOnValuesChange", "setRemountKey"]);
1456
- const childrenNode = typeof props.children === "function" ? props.children(values, form) : props.children;
1457
- const fireOnValuesChange = React__default.default.useCallback(() => {
1458
- const values2 = form.getFieldsValue(true);
1459
- if (!equal__default.default(values2, lastValue.current)) {
1460
- extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(values2);
1461
- lastValue.current = values2;
1462
- }
1463
- }, [form, lastValue]);
1464
- React__default.default.useEffect(() => {
1465
- fireOnValuesChange();
1466
- }, []);
1467
- const formLayout = React__default.default.useMemo(
1468
- () => {
1469
- var _a2;
1470
- return {
1471
- layout: props.layout,
1472
- labelSpan: (_a2 = props.labelCol) == null ? void 0 : _a2.span
1473
- };
1474
- },
1475
- [props.layout, (_b = props.labelCol) == null ? void 0 : _b.span]
1476
- );
1477
- return /* @__PURE__ */ React__default.default.createElement(
1478
- InternalFormInstanceContext.Provider,
1479
- {
1457
+ const COMMON_DECORATOR_PROPS = {
1458
+ prefix: {
1459
+ type: "slot",
1460
+ hidePlaceholder: true
1461
+ },
1462
+ suffix: {
1463
+ type: "slot",
1464
+ hidePlaceholder: true
1465
+ },
1466
+ addonAfter: {
1467
+ type: "slot",
1468
+ hidePlaceholder: true
1469
+ },
1470
+ addonBefore: {
1471
+ type: "slot",
1472
+ hidePlaceholder: true
1473
+ }
1474
+ };
1475
+ const COMMON_ADVANCED_PROPS = {
1476
+ maxLength: {
1477
+ type: "number",
1478
+ advanced: true
1479
+ },
1480
+ bordered: {
1481
+ type: "boolean",
1482
+ advanced: true,
1483
+ defaultValueHint: true
1484
+ },
1485
+ allowClear: {
1486
+ type: "boolean",
1487
+ advanced: true
1488
+ },
1489
+ autoFocus: {
1490
+ type: "boolean",
1491
+ advanced: true
1492
+ },
1493
+ readOnly: {
1494
+ type: "boolean",
1495
+ advanced: true
1496
+ }
1497
+ };
1498
+ const COMMON_EVENT_HANDLERS = {
1499
+ onChange: {
1500
+ type: "eventHandler",
1501
+ argTypes: [
1502
+ {
1503
+ name: "event",
1504
+ type: "object"
1505
+ }
1506
+ ]
1507
+ },
1508
+ onPressEnter: {
1509
+ type: "eventHandler",
1510
+ argTypes: [
1511
+ {
1512
+ name: "event",
1513
+ type: "object"
1514
+ }
1515
+ ]
1516
+ }
1517
+ };
1518
+ const inputComponentName = "plasmic-antd5-input";
1519
+ function registerInput(loader) {
1520
+ registerComponentHelper(loader, AntdInput, __spreadProps$5(__spreadValues$7({
1521
+ name: inputComponentName,
1522
+ displayName: "Input",
1523
+ props: __spreadValues$7(__spreadValues$7(__spreadValues$7({
1480
1524
  value: {
1481
- layout: formLayout,
1482
- fireOnValuesChange,
1483
- forceRemount: () => setRemountKey((k) => k + 1)
1525
+ type: "string",
1526
+ hidden: (ps) => !!ps.__plasmicFormField
1527
+ },
1528
+ placeholder: {
1529
+ type: "string"
1530
+ },
1531
+ size: {
1532
+ type: "choice",
1533
+ options: ["large", "middle", "small"]
1534
+ },
1535
+ disabled: {
1536
+ type: "boolean"
1537
+ },
1538
+ type: {
1539
+ type: "choice",
1540
+ options: [
1541
+ "text",
1542
+ "password",
1543
+ "number",
1544
+ "date",
1545
+ "datetime-local",
1546
+ "time",
1547
+ "email",
1548
+ "tel",
1549
+ "hidden"
1550
+ ],
1551
+ defaultValueHint: "text"
1484
1552
  }
1485
- },
1486
- /* @__PURE__ */ React__default.default.createElement(FormLayoutContext.Provider, { value: formLayout }, /* @__PURE__ */ React__default.default.createElement(
1487
- antd.Form,
1488
- __spreadProps$5(__spreadValues$6({}, rest), {
1489
- key: props.initialValues ? JSON.stringify(props.initialValues) : void 0,
1490
- onValuesChange: (...args) => {
1491
- var _a2;
1492
- (_a2 = props.onValuesChange) == null ? void 0 : _a2.call(props, ...args);
1493
- extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(args[1]);
1494
- },
1495
- form,
1496
- labelCol: ((_c = props.labelCol) == null ? void 0 : _c.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
1497
- wrapperCol: ((_d = props.wrapperCol) == null ? void 0 : _d.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
1498
- }),
1499
- /* @__PURE__ */ React__default.default.createElement("style", null, `
1500
- .ant-form-item-explain + div, .ant-form-item-margin-offset {
1501
- display: none;
1553
+ }, COMMON_ADVANCED_PROPS), COMMON_DECORATOR_PROPS), COMMON_EVENT_HANDLERS),
1554
+ states: __spreadValues$7({}, COMMON_STATES)
1555
+ }, { trapsSelection: true }), {
1556
+ componentHelpers: COMMON_HELPERS_CONFIG,
1557
+ importPath: "@plasmicpkgs/antd5/skinny/registerInput",
1558
+ importName: "AntdInput"
1559
+ }));
1560
+ }
1561
+ const textAreaComponentName = "plasmic-antd5-textarea";
1562
+ function registerTextArea(loader) {
1563
+ registerComponentHelper(loader, AntdTextArea, {
1564
+ name: textAreaComponentName,
1565
+ parentComponentName: inputComponentName,
1566
+ displayName: "Text Area",
1567
+ props: __spreadValues$7({
1568
+ value: {
1569
+ type: "string",
1570
+ hidden: (ps) => !!ps.__plasmicFormField
1571
+ },
1572
+ placeholder: {
1573
+ type: "string"
1574
+ },
1575
+ disabled: {
1576
+ type: "boolean"
1577
+ },
1578
+ maxLength: {
1579
+ type: "number",
1580
+ advanced: true
1581
+ },
1582
+ bordered: {
1583
+ type: "boolean",
1584
+ advanced: true,
1585
+ defaultValueHint: true
1586
+ }
1587
+ }, COMMON_EVENT_HANDLERS),
1588
+ states: __spreadValues$7({}, COMMON_STATES),
1589
+ componentHelpers: COMMON_HELPERS_CONFIG,
1590
+ importPath: "@plasmicpkgs/antd5/skinny/registerInput",
1591
+ importName: "AntdTextArea"
1592
+ });
1593
+ }
1594
+ const passwordComponentName = "plasmic-antd5-input-password";
1595
+ function registerPasswordInput(loader) {
1596
+ registerComponentHelper(loader, AntdPassword, {
1597
+ name: passwordComponentName,
1598
+ parentComponentName: inputComponentName,
1599
+ displayName: "Password Input",
1600
+ props: __spreadValues$7({
1601
+ value: {
1602
+ type: "string",
1603
+ hidden: (ps) => !!ps.__plasmicFormField
1604
+ },
1605
+ placeholder: {
1606
+ type: "string"
1607
+ },
1608
+ disabled: {
1609
+ type: "boolean"
1610
+ },
1611
+ maxLength: {
1612
+ type: "number",
1613
+ advanced: true
1614
+ },
1615
+ bordered: {
1616
+ type: "boolean",
1617
+ advanced: true,
1618
+ defaultValueHint: true
1619
+ }
1620
+ }, COMMON_EVENT_HANDLERS),
1621
+ states: __spreadValues$7({}, COMMON_STATES),
1622
+ componentHelpers: COMMON_HELPERS_CONFIG,
1623
+ importPath: "@plasmicpkgs/antd5/skinny/registerInput",
1624
+ importName: "AntdPassword"
1625
+ });
1626
+ }
1627
+ const inputNumberComponentName = "plasmic-antd5-input-number";
1628
+ function registerNumberInput(loader) {
1629
+ registerComponentHelper(loader, AntdInputNumber, __spreadProps$5(__spreadValues$7({
1630
+ name: inputNumberComponentName,
1631
+ parentComponentName: inputComponentName,
1632
+ displayName: "Number Input",
1633
+ props: __spreadProps$5(__spreadValues$7(__spreadValues$7(__spreadValues$7({
1634
+ value: {
1635
+ type: "number",
1636
+ hidden: (ps) => !!ps.__plasmicFormField
1637
+ },
1638
+ placeholder: {
1639
+ type: "string"
1640
+ },
1641
+ disabled: {
1642
+ type: "boolean"
1643
+ },
1644
+ max: {
1645
+ type: "number"
1646
+ },
1647
+ min: {
1648
+ type: "number"
1649
+ },
1650
+ step: {
1651
+ type: "number",
1652
+ helpText: "Increment or decrement step"
1653
+ },
1654
+ controls: {
1655
+ type: "boolean",
1656
+ displayName: "Show add/minus controls?",
1657
+ advanced: true
1658
+ }
1659
+ }, COMMON_DECORATOR_PROPS), COMMON_ADVANCED_PROPS), COMMON_EVENT_HANDLERS), {
1660
+ // onChange directly called with the number
1661
+ onChange: {
1662
+ type: "eventHandler",
1663
+ argTypes: [
1664
+ {
1665
+ name: "value",
1666
+ type: "number"
1502
1667
  }
1503
- `),
1504
- childrenNode
1505
- ))
1506
- );
1507
- };
1508
- function FormWrapper(props) {
1509
- const [remountKey, setRemountKey] = React__default.default.useState(0);
1510
- const previousInitialValues = usePrevious(props.initialValues);
1511
- React__default.default.useEffect(() => {
1512
- if (previousInitialValues !== props.initialValues && JSON.stringify(previousInitialValues) !== JSON.stringify(props.initialValues)) {
1513
- setRemountKey((k) => k + 1);
1514
- }
1515
- }, [previousInitialValues, props.initialValues]);
1516
- return /* @__PURE__ */ React__default.default.createElement(Internal, __spreadProps$5(__spreadValues$6({ key: remountKey }, props), { setRemountKey }));
1668
+ ]
1669
+ }
1670
+ }),
1671
+ states: __spreadValues$7({}, COMMON_STATES)
1672
+ }, { trapsSelection: true }), {
1673
+ // don't need component helpers
1674
+ importPath: "@plasmicpkgs/antd5/skinny/registerInput",
1675
+ importName: "AntdInputNumber"
1676
+ }));
1517
1677
  }
1518
- const COMMON_ACTIONS = [
1519
- {
1520
- type: "button-action",
1521
- label: "Append new Form Item",
1522
- onClick: ({ studioOps }) => {
1523
- studioOps.appendToSlot(
1524
- {
1525
- type: "component",
1526
- name: "plasmic-antd5-form-item"
1527
- },
1528
- "children"
1529
- );
1678
+
1679
+ var __defProp$6 = Object.defineProperty;
1680
+ var __defProps$4 = Object.defineProperties;
1681
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1682
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1683
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1684
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1685
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1686
+ var __spreadValues$6 = (a, b) => {
1687
+ for (var prop in b || (b = {}))
1688
+ if (__hasOwnProp$6.call(b, prop))
1689
+ __defNormalProp$6(a, prop, b[prop]);
1690
+ if (__getOwnPropSymbols$6)
1691
+ for (var prop of __getOwnPropSymbols$6(b)) {
1692
+ if (__propIsEnum$6.call(b, prop))
1693
+ __defNormalProp$6(a, prop, b[prop]);
1530
1694
  }
1531
- }
1532
- // {
1533
- // type: "button-action" as const,
1534
- // label: "Append new Form Group",
1535
- // onClick: ({ studioOps }: ActionProps<any>) => {
1536
- // studioOps.appendToSlot(
1537
- // {
1538
- // type: "component",
1539
- // name: "plasmic-antd5-form-group",
1540
- // },
1541
- // "children"
1542
- // );
1543
- // },
1544
- // },
1545
- // {
1546
- // type: "button-action" as const,
1547
- // label: "Append new Form List",
1548
- // onClick: ({ studioOps }: ActionProps<any>) => {
1549
- // studioOps.appendToSlot(
1550
- // {
1551
- // type: "component",
1552
- // name: "plasmic-antd5-form-list",
1553
- // },
1554
- // "children"
1555
- // );
1556
- // },
1557
- // },
1558
- ];
1559
- const colProp = (displayName, defaultValue, description) => ({
1560
- type: "object",
1561
- displayName,
1562
- advanced: true,
1563
- fields: {
1564
- span: {
1565
- type: "number",
1566
- displayName: "Width",
1567
- description: "The number of grid columns to span in width (out of 24 columns total)",
1568
- min: 1,
1569
- max: 24
1570
- },
1571
- offset: {
1572
- type: "number",
1573
- displayName: "Offset",
1574
- description: "Number of grid columns to skip from the left (out of 24 columns total)",
1575
- min: 0,
1576
- max: 23
1577
- },
1578
- horizontalOnly: {
1579
- type: "boolean",
1580
- displayName: "Horizontal only",
1581
- description: "Only apply to horizontal layout"
1695
+ return a;
1696
+ };
1697
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1698
+ var __objRest$5 = (source, exclude) => {
1699
+ var target = {};
1700
+ for (var prop in source)
1701
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1702
+ target[prop] = source[prop];
1703
+ if (source != null && __getOwnPropSymbols$6)
1704
+ for (var prop of __getOwnPropSymbols$6(source)) {
1705
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1706
+ target[prop] = source[prop];
1582
1707
  }
1583
- },
1584
- description,
1585
- defaultValue
1586
- });
1587
- function registerForm(loader) {
1588
- registerComponentHelper(loader, FormWrapper, {
1589
- name: "plasmic-antd5-form",
1590
- displayName: "Form",
1591
- defaultStyles: {
1592
- layout: "vbox",
1593
- alignItems: "flex-start"
1594
- },
1708
+ return target;
1709
+ };
1710
+ const RadioGroup = antd.Radio.Group;
1711
+ const AntdRadio = antd.Radio;
1712
+ const AntdRadioButton = antd.Radio.Button;
1713
+ function AntdRadioGroup(props) {
1714
+ const _a = props, { onChange, useChildren } = _a, rest = __objRest$5(_a, ["onChange", "useChildren"]);
1715
+ const wrappedOnChange = React__default.default.useMemo(() => {
1716
+ if (onChange) {
1717
+ return (event) => onChange(event.target.value);
1718
+ } else {
1719
+ return void 0;
1720
+ }
1721
+ }, [onChange]);
1722
+ return /* @__PURE__ */ React__default.default.createElement(
1723
+ RadioGroup,
1724
+ __spreadProps$4(__spreadValues$6({}, rest), {
1725
+ onChange: wrappedOnChange,
1726
+ options: useChildren ? void 0 : rest.options
1727
+ })
1728
+ );
1729
+ }
1730
+ const radioComponentName = "plasmic-antd5-radio";
1731
+ const radioButtonComponentName = "plasmic-antd5-radio-button";
1732
+ const radioGroupComponentName = "plasmic-antd5-radio-group";
1733
+ function registerRadio(loader) {
1734
+ registerComponentHelper(loader, AntdRadio, {
1735
+ name: radioComponentName,
1736
+ displayName: "Radio",
1595
1737
  props: {
1596
- children: {
1738
+ value: {
1739
+ type: "string",
1740
+ description: "The radio option value"
1741
+ },
1742
+ disabled: {
1743
+ type: "boolean",
1744
+ defaultValueHint: false
1745
+ },
1746
+ autoFocus: {
1747
+ type: "boolean",
1748
+ description: "If focused when first shown",
1749
+ defaultValueHint: false,
1750
+ advanced: true
1751
+ },
1752
+ children: __spreadValues$6({
1597
1753
  type: "slot",
1598
1754
  defaultValue: [
1599
1755
  {
1600
- type: "component",
1601
- name: "plasmic-antd5-form-item",
1602
- props: {
1603
- label: {
1604
- type: "text",
1605
- value: "Name"
1606
- },
1607
- name: "name",
1608
- children: {
1609
- type: "component",
1610
- name: "plasmic-antd5-input"
1611
- }
1612
- }
1613
- },
1614
- {
1615
- type: "component",
1616
- name: "plasmic-antd5-form-item",
1617
- props: {
1618
- label: {
1619
- type: "text",
1620
- value: "Message"
1621
- },
1622
- name: "message",
1623
- children: {
1624
- type: "component",
1625
- name: "plasmic-antd5-textarea"
1626
- }
1627
- }
1628
- },
1629
- {
1630
- type: "component",
1631
- name: "plasmic-antd5-form-item",
1632
- props: {
1633
- noLabel: true,
1634
- children: {
1635
- type: "component",
1636
- name: "plasmic-antd5-button",
1637
- props: {
1638
- children: {
1639
- type: "text",
1640
- value: "Submit"
1641
- },
1642
- type: "primary",
1643
- submitsForm: true
1644
- }
1645
- }
1646
- }
1756
+ type: "text",
1757
+ value: "Radio"
1647
1758
  }
1648
1759
  ]
1760
+ }, { mergeWithParent: true })
1761
+ },
1762
+ importPath: "@plasmicpkgs/antd5/skinny/registerRadio",
1763
+ importName: "AntdRadio",
1764
+ parentComponentName: radioGroupComponentName
1765
+ });
1766
+ registerComponentHelper(loader, AntdRadioButton, {
1767
+ name: radioButtonComponentName,
1768
+ displayName: "Radio Button",
1769
+ props: {
1770
+ value: {
1771
+ type: "string",
1772
+ description: "The radio option value"
1649
1773
  },
1650
- initialValues: {
1651
- type: "object"
1652
- },
1653
- layout: {
1654
- type: "choice",
1655
- options: ["horizontal", "vertical", "inline"],
1656
- defaultValue: "vertical"
1657
- },
1658
- labelAlign: {
1659
- type: "choice",
1660
- options: ["left", "right"],
1661
- defaultValueHint: "right",
1662
- advanced: true,
1663
- hidden: (ps) => ps.layout !== "horizontal"
1774
+ disabled: {
1775
+ type: "boolean",
1776
+ defaultValueHint: false
1664
1777
  },
1665
- labelCol: colProp(
1666
- "Label layout",
1667
- {
1668
- span: 8,
1669
- horizontalOnly: true
1670
- },
1671
- "Set the width and offset of the labels"
1672
- ),
1673
- wrapperCol: colProp(
1674
- "Control layout",
1675
- {
1676
- span: 16,
1677
- horizontalOnly: true
1678
- },
1679
- "Set the width and offset of the form controls"
1680
- ),
1681
- colon: {
1778
+ autoFocus: {
1682
1779
  type: "boolean",
1683
- description: `Show a colon after labels by default (only for horizontal layout)`,
1684
- defaultValueHint: true,
1685
- advanced: true,
1686
- hidden: (props) => {
1687
- var _a;
1688
- return ((_a = props.layout) != null ? _a : "horizontal") !== "horizontal";
1689
- }
1780
+ description: "If focused when first shown",
1781
+ defaultValueHint: false,
1782
+ advanced: true
1690
1783
  },
1691
- requiredMark: {
1692
- displayName: "Required/optional mark",
1693
- type: "choice",
1694
- options: [
1784
+ children: __spreadValues$6({
1785
+ type: "slot",
1786
+ defaultValue: [
1695
1787
  {
1696
- value: "optional",
1697
- label: "Indicate optional fields"
1698
- },
1788
+ type: "text",
1789
+ value: "Radio"
1790
+ }
1791
+ ]
1792
+ }, { mergeWithParent: true })
1793
+ },
1794
+ importPath: "@plasmicpkgs/antd5/skinny/registerRadio",
1795
+ importName: "AntdRadioButton",
1796
+ parentComponentName: radioGroupComponentName
1797
+ });
1798
+ registerComponentHelper(loader, AntdRadioGroup, __spreadValues$6({
1799
+ name: radioGroupComponentName,
1800
+ displayName: "Radio Group",
1801
+ props: {
1802
+ options: {
1803
+ type: "array",
1804
+ hidden: (ps) => !!ps.useChildren,
1805
+ itemType: {
1806
+ type: "object",
1807
+ nameFunc: (item) => item.label || item.value,
1808
+ fields: {
1809
+ value: "string",
1810
+ label: "string"
1811
+ }
1812
+ },
1813
+ defaultValue: [
1699
1814
  {
1700
- value: true,
1701
- label: "Indicate required fields with asterisk"
1815
+ value: "option1",
1816
+ label: "Option 1"
1702
1817
  },
1703
1818
  {
1704
- value: false,
1705
- label: "Show no indicators"
1819
+ value: "option2",
1820
+ label: "Option 2"
1706
1821
  }
1822
+ ]
1823
+ },
1824
+ optionType: {
1825
+ type: "choice",
1826
+ options: [
1827
+ { value: "default", label: "Radio" },
1828
+ { value: "button", label: "Button" }
1707
1829
  ],
1830
+ hidden: (ps) => !!ps.useChildren,
1831
+ defaultValueHint: "default"
1832
+ },
1833
+ value: {
1834
+ type: "choice",
1835
+ editOnly: true,
1836
+ uncontrolledProp: "defaultValue",
1837
+ description: "Default selected value",
1838
+ options: (ps) => {
1839
+ var _a;
1840
+ if (ps.useChildren) {
1841
+ const options = /* @__PURE__ */ new Set();
1842
+ traverseReactEltTree(ps.children, (elt) => {
1843
+ var _a2;
1844
+ if (typeof ((_a2 = elt == null ? void 0 : elt.props) == null ? void 0 : _a2.value) === "string") {
1845
+ options.add(elt.props.value);
1846
+ }
1847
+ });
1848
+ return Array.from(options.keys());
1849
+ } else {
1850
+ return (_a = ps.options) != null ? _a : [];
1851
+ }
1852
+ },
1853
+ hidden: (ps) => !!ps.__plasmicFormField
1854
+ },
1855
+ disabled: {
1856
+ type: "boolean",
1857
+ description: "Disables all radios",
1858
+ defaultValueHint: false
1859
+ },
1860
+ useChildren: {
1861
+ displayName: "Use slot",
1862
+ type: "boolean",
1863
+ defaultValueHint: false,
1708
1864
  advanced: true,
1709
- defaultValueHint: true
1865
+ description: "Instead of configuring a list of options, customize the contents of the RadioGroup by dragging and dropping Radio in the outline/canvas, inside the 'children' slot. Lets you use any content or formatting within the Radio and RadioButton."
1710
1866
  },
1711
- extendedOnValuesChange: {
1712
- type: "eventHandler",
1713
- displayName: "On values change",
1714
- argTypes: [
1867
+ children: {
1868
+ type: "slot",
1869
+ allowedComponents: [
1870
+ "plasmic-antd5-radio",
1871
+ "plasmic-antd5-radio-button"
1872
+ ],
1873
+ defaultValue: [
1715
1874
  {
1716
- name: "changedValues",
1717
- type: "object"
1875
+ type: "component",
1876
+ name: "plasmic-antd5-radio",
1877
+ props: {
1878
+ value: "op1",
1879
+ children: {
1880
+ type: "text",
1881
+ value: "Option 1"
1882
+ }
1883
+ }
1718
1884
  },
1719
1885
  {
1720
- name: "allValues",
1721
- type: "object"
1722
- }
1723
- ]
1724
- },
1725
- onFinish: {
1726
- type: "eventHandler",
1727
- displayName: "On submit",
1728
- argTypes: [
1729
- {
1730
- name: "values",
1731
- type: "object"
1886
+ type: "component",
1887
+ name: "plasmic-antd5-radio",
1888
+ props: {
1889
+ value: "op2",
1890
+ children: {
1891
+ type: "text",
1892
+ value: "Option 2"
1893
+ }
1894
+ }
1732
1895
  }
1733
1896
  ]
1734
1897
  },
1735
- onFinishFailed: {
1736
- // function({ values, errorFields, outOfDate })
1898
+ onChange: {
1737
1899
  type: "eventHandler",
1738
- displayName: "On invalid submit",
1739
- argTypes: [
1740
- {
1741
- name: "data",
1742
- type: "object"
1743
- }
1744
- ]
1745
- },
1746
- validateTrigger: {
1747
- type: "choice",
1748
- options: ["onSubmit", "onChange", "onBlur"],
1749
- multiSelect: true,
1750
- defaultValueHint: ["onChange"],
1751
- advanced: true
1900
+ argTypes: [{ name: "value", type: "string" }]
1752
1901
  }
1753
1902
  },
1754
- actions: COMMON_ACTIONS,
1755
1903
  states: {
1756
1904
  value: {
1757
- type: "readonly",
1758
- variableType: "object",
1759
- onChangeProp: "extendedOnValuesChange"
1905
+ type: "writable",
1906
+ valueProp: "value",
1907
+ onChangeProp: "onChange",
1908
+ variableType: "text"
1760
1909
  }
1761
1910
  },
1762
- importPath: "@plasmicpkgs/antd5/skinny/registerForm",
1763
- importName: "FormWrapper"
1764
- });
1765
- }
1766
- function plasmicRulesToAntdRules(plasmicRules, label) {
1767
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1768
- const effectiveLabel = label || "This field";
1769
- const rules = [];
1770
- for (const plasmicRule of plasmicRules) {
1771
- switch (plasmicRule.ruleType) {
1772
- case "enum":
1773
- rules.push({
1774
- type: "enum",
1775
- enum: (_b = (_a = plasmicRule.options) == null ? void 0 : _a.map((opt) => opt.value)) != null ? _b : [],
1776
- message: (_c = plasmicRule.message) != null ? _c : `${effectiveLabel} must be a valid value`
1777
- });
1778
- break;
1779
- case "required":
1780
- rules.push({
1781
- required: true,
1782
- message: (_d = plasmicRule.message) != null ? _d : `${effectiveLabel} is required`
1783
- });
1784
- break;
1785
- case "regex":
1786
- rules.push({
1787
- pattern: new RegExp((_e = plasmicRule.pattern) != null ? _e : ""),
1788
- message: (_f = plasmicRule.message) != null ? _f : `${effectiveLabel} must be a valid value`
1789
- });
1790
- break;
1791
- case "whitespace":
1792
- rules.push({
1793
- whitespace: true,
1794
- message: (_g = plasmicRule.message) != null ? _g : `${effectiveLabel} is required`
1795
- });
1796
- break;
1797
- case "min":
1798
- rules.push({
1799
- [plasmicRule.ruleType]: plasmicRule.length,
1800
- message: (_h = plasmicRule.message) != null ? _h : `${effectiveLabel} must be at least ${plasmicRule.length} characters`
1801
- });
1802
- break;
1803
- case "max":
1804
- rules.push({
1805
- [plasmicRule.ruleType]: plasmicRule.length,
1806
- message: (_i = plasmicRule.message) != null ? _i : `${effectiveLabel} must be at most ${plasmicRule.length} characters`
1807
- });
1808
- break;
1809
- case "advanced":
1810
- rules.push({
1811
- validator: (...args) => {
1812
- var _a2;
1813
- return ((_a2 = plasmicRule.custom) == null ? void 0 : _a2.apply(null, args)) ? Promise.resolve() : Promise.reject();
1814
- },
1815
- message: plasmicRule.message
1816
- });
1911
+ importPath: "@plasmicpkgs/antd5/skinny/registerRadio",
1912
+ importName: "AntdRadioGroup",
1913
+ defaultStyles: {
1914
+ layout: "hbox"
1817
1915
  }
1818
- }
1819
- return rules;
1916
+ }, {
1917
+ trapsSelection: true
1918
+ }));
1820
1919
  }
1821
- const useFormItemRelativeName = (name) => {
1822
- const pathCtx = React__default.default.useContext(PathContext);
1823
- return typeof name === "object" ? [...pathCtx.relativePath, ...name] : typeof name === "string" ? [...pathCtx.relativePath, name] : void 0;
1920
+
1921
+ var __defProp$5 = Object.defineProperty;
1922
+ var __defProps$3 = Object.defineProperties;
1923
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1924
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1925
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1926
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1927
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1928
+ var __spreadValues$5 = (a, b) => {
1929
+ for (var prop in b || (b = {}))
1930
+ if (__hasOwnProp$5.call(b, prop))
1931
+ __defNormalProp$5(a, prop, b[prop]);
1932
+ if (__getOwnPropSymbols$5)
1933
+ for (var prop of __getOwnPropSymbols$5(b)) {
1934
+ if (__propIsEnum$5.call(b, prop))
1935
+ __defNormalProp$5(a, prop, b[prop]);
1936
+ }
1937
+ return a;
1824
1938
  };
1825
- const useFormItemFullName = (name) => {
1826
- const pathCtx = React__default.default.useContext(PathContext);
1827
- return typeof name === "object" ? [...pathCtx.fullPath, ...name] : typeof name === "string" ? [...pathCtx.fullPath, name] : void 0;
1939
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1940
+ var __objRest$4 = (source, exclude) => {
1941
+ var target = {};
1942
+ for (var prop in source)
1943
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1944
+ target[prop] = source[prop];
1945
+ if (source != null && __getOwnPropSymbols$5)
1946
+ for (var prop of __getOwnPropSymbols$5(source)) {
1947
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1948
+ target[prop] = source[prop];
1949
+ }
1950
+ return target;
1828
1951
  };
1829
- function useFormInstanceMaybe() {
1830
- return antd.Form.useFormInstance();
1831
- }
1832
- function FormItemWrapper(props) {
1833
- var _b;
1952
+ const AntdOption = antd.Select.Option;
1953
+ const AntdOptionGroup = antd.Select.OptGroup;
1954
+ function AntdSelect(props) {
1834
1955
  const _a = props, {
1835
- rules: plasmicRules,
1836
- description,
1837
- noLabel,
1838
- name,
1839
- hideValidationMessage,
1840
- customizeProps,
1841
- setControlContextData,
1842
- alignLabellessWithControls = true
1843
- } = _a, rest = __objRest$5(_a, [
1844
- "rules",
1845
- "description",
1846
- "noLabel",
1847
- "name",
1848
- "hideValidationMessage",
1849
- "customizeProps",
1850
- "setControlContextData",
1851
- "alignLabellessWithControls"
1956
+ popupClassName,
1957
+ popupScopeClassName,
1958
+ defaultStylesClassName,
1959
+ suffixIcon,
1960
+ mode,
1961
+ useChildren
1962
+ } = _a, rest = __objRest$4(_a, [
1963
+ "popupClassName",
1964
+ "popupScopeClassName",
1965
+ "defaultStylesClassName",
1966
+ "suffixIcon",
1967
+ "mode",
1968
+ "useChildren"
1852
1969
  ]);
1853
- const relativeFormItemName = useFormItemRelativeName(name);
1854
- const fullFormItemName = useFormItemFullName(name);
1855
- const bestEffortLabel = !noLabel && reactNodeToString(props.label) || ensureArray(props.name).slice(-1)[0];
1856
- const rules = plasmicRules ? plasmicRulesToAntdRules(
1857
- plasmicRules,
1858
- typeof bestEffortLabel === "number" ? "" + bestEffortLabel : bestEffortLabel
1859
- ) : void 0;
1860
- const layoutContext = React__default.default.useContext(FormLayoutContext);
1861
- const inCanvas = !!host.usePlasmicCanvasContext();
1862
- if (inCanvas) {
1863
- const form = useFormInstanceMaybe();
1864
- const prevPropValues = React__default.default.useRef({
1865
- initialValue: props.initialValue,
1866
- name: props.name
1867
- });
1868
- const internalFormCtx = React__default.default.useContext(InternalFormInstanceContext);
1869
- const { fireOnValuesChange, forceRemount } = internalFormCtx != null ? internalFormCtx : {};
1870
- (_b = props.setControlContextData) == null ? void 0 : _b.call(props, {
1871
- internalFormCtx
1872
- });
1873
- React__default.default.useEffect(() => {
1874
- if (prevPropValues.current.name !== props.name) {
1875
- forceRemount == null ? void 0 : forceRemount();
1876
- }
1877
- if (!fullFormItemName || (form == null ? void 0 : form.getFieldValue(fullFormItemName)) !== prevPropValues.current.initialValue) {
1878
- return;
1879
- }
1880
- form == null ? void 0 : form.setFieldValue(fullFormItemName, props.initialValue);
1881
- prevPropValues.current.initialValue = props.initialValue;
1882
- fireOnValuesChange == null ? void 0 : fireOnValuesChange();
1883
- }, [form, props.initialValue, fullFormItemName]);
1970
+ const curated = __spreadValues$5({}, rest);
1971
+ if (useChildren) {
1972
+ curated.options = void 0;
1884
1973
  }
1885
1974
  return /* @__PURE__ */ React__default.default.createElement(
1886
- FormItem,
1887
- __spreadProps$5(__spreadValues$6({}, rest), {
1888
- label: noLabel ? void 0 : props.label,
1889
- name: relativeFormItemName,
1890
- rules,
1891
- extra: description,
1892
- help: hideValidationMessage ? "" : props.help,
1893
- colon: noLabel ? false : void 0,
1894
- wrapperCol: (layoutContext == null ? void 0 : layoutContext.layout) === "horizontal" && noLabel && alignLabellessWithControls && layoutContext.labelSpan ? { offset: layoutContext.labelSpan } : void 0
1895
- }),
1896
- props.customizeProps ? /* @__PURE__ */ React__default.default.createElement(FormItemForwarder, { formItemProps: props }) : props.children
1975
+ antd.Select,
1976
+ __spreadValues$5(__spreadProps$3(__spreadValues$5({}, curated), {
1977
+ mode: !mode || mode === "single" ? void 0 : mode,
1978
+ popupClassName: `${defaultStylesClassName} ${popupScopeClassName} ${popupClassName}`
1979
+ }), suffixIcon && { suffixIcon })
1897
1980
  );
1898
1981
  }
1899
- function FormItemForwarder(_a) {
1900
- var _b = _a, { formItemProps } = _b, props = __objRest$5(_b, ["formItemProps"]);
1901
- var _a2;
1902
- const status = antd.Form.Item.useStatus();
1903
- const internalFormCtx = React__default.default.useContext(InternalFormInstanceContext);
1904
- const data = {
1905
- status: status.status
1906
- };
1907
- (_a2 = props.setControlContextData) == null ? void 0 : _a2.call(props, {
1908
- internalFormCtx,
1909
- status
1910
- });
1911
- return React__default.default.Children.map(formItemProps.children, (child, i) => {
1912
- var _a3;
1913
- const baseProps = __spreadValues$6(__spreadValues$6({}, (_a3 = child.props) != null ? _a3 : {}), props);
1914
- return i === 0 && React.isValidElement(child) ? React.cloneElement(
1915
- child,
1916
- mergeProps(baseProps, formItemProps.customizeProps(data, baseProps))
1917
- ) : child;
1918
- });
1919
- }
1920
- function registerFormItem(loader) {
1921
- registerComponentHelper(loader, FormItemWrapper, __spreadValues$6({
1922
- name: "plasmic-antd5-form-item",
1923
- displayName: "Form Item",
1924
- parentComponentName: "plasmic-antd5-form",
1925
- defaultStyles: {
1926
- marginBottom: "24px",
1927
- width: "stretch"
1928
- },
1982
+ const selectComponentName = "plasmic-antd5-select";
1983
+ const optionComponentName = "plasmic-antd5-option";
1984
+ const optionGroupComponentName = "plasmic-antd5-option-group";
1985
+ function registerSelect(loader) {
1986
+ registerComponentHelper(loader, AntdSelect, __spreadProps$3(__spreadValues$5({
1987
+ name: selectComponentName,
1988
+ displayName: "Select",
1929
1989
  props: {
1930
- label: __spreadValues$6({
1931
- type: "slot",
1932
- defaultValue: {
1933
- type: "text",
1934
- value: "Label"
1990
+ options: {
1991
+ type: "array",
1992
+ hidden: (ps) => !!ps.useChildren,
1993
+ itemType: {
1994
+ type: "object",
1995
+ nameFunc: (item) => item.label || item.value,
1996
+ fields: {
1997
+ type: {
1998
+ type: "choice",
1999
+ options: [
2000
+ { value: "option", label: "Option" },
2001
+ { value: "option-group", label: "Option Group" }
2002
+ ],
2003
+ defaultValue: "option"
2004
+ },
2005
+ value: {
2006
+ type: "string",
2007
+ hidden: (ps) => ps.type !== "option"
2008
+ },
2009
+ label: "string",
2010
+ options: {
2011
+ type: "array",
2012
+ hidden: (ps) => {
2013
+ return ps.type !== "option-group";
2014
+ },
2015
+ itemType: {
2016
+ type: "object",
2017
+ nameFunc: (item) => item.label || item.value,
2018
+ fields: {
2019
+ value: "string",
2020
+ label: "string"
2021
+ }
2022
+ }
2023
+ }
2024
+ }
1935
2025
  },
1936
- hidden: (ps) => !!ps.noLabel
1937
- }, { mergeWithParent: true }),
1938
- children: __spreadValues$6({
1939
- type: "slot",
1940
- defaultValue: {
1941
- type: "component",
1942
- name: "plasmic-antd5-input"
1943
- }
1944
- }, { mergeWithParent: true }),
1945
- name: {
1946
- type: "string"
2026
+ defaultValue: [
2027
+ {
2028
+ value: "option1",
2029
+ label: "Option 1"
2030
+ },
2031
+ {
2032
+ value: "option2",
2033
+ label: "Option 2"
2034
+ }
2035
+ ]
1947
2036
  },
1948
- initialValue: {
1949
- type: "string"
2037
+ useChildren: {
2038
+ displayName: "Use slot",
2039
+ type: "boolean",
2040
+ defaultValueHint: false,
2041
+ advanced: true,
2042
+ description: "Instead of configuring a list of options, customize the contents of the Select by dragging and dropping options in the outline/canvas, inside the 'children' slot. Lets you use any content or formatting within the Options, and also use Option Groups."
1950
2043
  },
1951
- rules: {
1952
- type: "formValidationRules"
2044
+ children: {
2045
+ type: "slot",
2046
+ allowedComponents: [
2047
+ optionComponentName,
2048
+ optionGroupComponentName
2049
+ ],
2050
+ hidden: (ps) => !ps.useChildren
1953
2051
  },
1954
- valuePropName: {
1955
- type: "string",
1956
- advanced: true,
1957
- defaultValueHint: "value",
1958
- description: "The prop name for specifying the value of the form control component"
2052
+ placeholder: {
2053
+ type: "slot",
2054
+ defaultValue: "Select..."
1959
2055
  },
1960
- noLabel: {
1961
- type: "boolean",
1962
- advanced: true
2056
+ suffixIcon: {
2057
+ type: "slot",
2058
+ hidePlaceholder: true
1963
2059
  },
1964
- alignLabellessWithControls: {
2060
+ open: {
1965
2061
  type: "boolean",
1966
- displayName: "Align with controls?",
1967
- description: "Aligns the content with form controls in the grid",
1968
- hidden: (ps, ctx) => {
2062
+ editOnly: true,
2063
+ uncontrolledProp: "defaultOpen"
2064
+ },
2065
+ value: {
2066
+ type: "choice",
2067
+ displayName: "Selected value",
2068
+ editOnly: true,
2069
+ uncontrolledProp: "defaultValue",
2070
+ description: "Initial selected option",
2071
+ multiSelect: (ps) => ps.mode === "multiple",
2072
+ options: (ps) => {
1969
2073
  var _a;
1970
- return !ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
2074
+ const options = /* @__PURE__ */ new Set();
2075
+ if (!ps.useChildren) {
2076
+ const rec = (op) => {
2077
+ var _a2;
2078
+ if (typeof op === "string") {
2079
+ return [{ value: op, label: op }];
2080
+ } else if ("options" in op) {
2081
+ return ((_a2 = op.options) != null ? _a2 : []).flatMap((sub) => rec(sub));
2082
+ } else {
2083
+ return [{ value: op.value, label: op.label || op.value }];
2084
+ }
2085
+ };
2086
+ return ((_a = ps.options) != null ? _a : []).flatMap((o) => rec(o));
2087
+ } else {
2088
+ traverseReactEltTree(ps.children, (elt) => {
2089
+ var _a2;
2090
+ if ((elt == null ? void 0 : elt.type) === antd.Select.Option && typeof ((_a2 = elt == null ? void 0 : elt.props) == null ? void 0 : _a2.value) === "string") {
2091
+ options.add(elt.props.value);
2092
+ }
2093
+ });
2094
+ }
2095
+ return Array.from(options.keys());
1971
2096
  },
1972
- defaultValueHint: true
2097
+ hidden: (ps) => !!ps.__plasmicFormField
1973
2098
  },
1974
- colon: {
1975
- type: "boolean",
1976
- defaultValueHint: true,
1977
- advanced: true,
1978
- hidden: () => true
2099
+ mode: {
2100
+ type: "choice",
2101
+ options: ["single", "multiple"],
2102
+ defaultValueHint: "single"
1979
2103
  },
1980
- labelAlign: {
2104
+ size: {
1981
2105
  type: "choice",
1982
- options: ["left", "right"],
1983
- advanced: true,
1984
- hidden: (ps, ctx) => {
1985
- var _a;
1986
- return !!ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
1987
- }
2106
+ options: ["small", "middle", "large"]
2107
+ },
2108
+ disabled: {
2109
+ type: "boolean",
2110
+ defaultValueHint: false
1988
2111
  },
1989
- hidden: {
2112
+ showSearch: {
1990
2113
  type: "boolean",
2114
+ defaultValueHint: false,
1991
2115
  advanced: true
1992
2116
  },
1993
- validateTrigger: {
2117
+ status: {
1994
2118
  type: "choice",
1995
- options: ["onSubmit", "onChange", "onBlur"],
1996
- multiSelect: true,
2119
+ options: ["error", "warning"],
1997
2120
  advanced: true
1998
2121
  },
1999
- shouldUpdate: {
2122
+ bordered: {
2000
2123
  type: "boolean",
2001
- advanced: true,
2002
- displayName: "Always re-render",
2003
- description: "Form items normally only re-render when the corresponding form value changes, for performance. This forces it to always re-render."
2004
- },
2005
- dependencies: {
2006
- type: "array",
2007
- advanced: true,
2008
- displayName: "Dependencies",
2009
- description: "Form items can depend on other form items. This forces it to reevaluate the validation rules when the other form item changes."
2124
+ defaultValueHint: true
2010
2125
  },
2011
- hideValidationMessage: {
2126
+ autoFocus: {
2012
2127
  type: "boolean",
2013
- displayName: "Hide validation message?",
2014
- description: "If true, will hide the validation error message",
2128
+ displayName: "Focus automatically",
2015
2129
  defaultValueHint: false,
2016
2130
  advanced: true
2017
2131
  },
2018
- description: {
2019
- type: "slot",
2020
- hidePlaceholder: true
2132
+ onChange: {
2133
+ type: "eventHandler",
2134
+ argTypes: [
2135
+ { name: "value", type: "string" },
2136
+ { name: "option", type: "object" }
2137
+ ]
2138
+ },
2139
+ dropdownMatchSelectWidth: {
2140
+ type: "boolean",
2141
+ displayName: "Should dropdown match trigger button width?",
2142
+ defaultValueHint: true,
2143
+ advanced: true
2144
+ },
2145
+ triggerClassName: {
2146
+ type: "class",
2147
+ displayName: "Trigger styles",
2148
+ noSelf: true,
2149
+ selectors: [
2150
+ {
2151
+ selector: ":component .ant-select-selector.ant-select-selector",
2152
+ label: "Base"
2153
+ },
2154
+ {
2155
+ selector: ":component .ant-select-selector:hover",
2156
+ label: "Hovered"
2157
+ }
2158
+ ],
2159
+ advanced: true
2160
+ },
2161
+ popupScopeClassName: {
2162
+ type: "styleScopeClass",
2163
+ scopeName: "popup"
2021
2164
  },
2022
- customizeProps: {
2023
- type: "function",
2024
- description: "Customize the props passed into the wrapped field component. Takes the current status ('success', 'warning', 'error', or 'validating').)",
2025
- argNames: ["fieldData"],
2026
- argValues: (_ps, ctx) => {
2027
- var _a;
2028
- return [
2029
- {
2030
- status: (_a = ctx == null ? void 0 : ctx.status) == null ? void 0 : _a.status
2031
- }
2032
- ];
2033
- },
2165
+ popupClassName: {
2166
+ type: "class",
2167
+ displayName: "Popup styles",
2168
+ selectors: [],
2034
2169
  advanced: true
2035
2170
  },
2036
- noStyle: {
2037
- type: "boolean",
2038
- displayName: "Field control only",
2039
- description: "Don't render anything but the field control - so no label, help text, validation error, etc.",
2040
- advanced: true
2041
- }
2042
- },
2043
- importPath: "@plasmicpkgs/antd5/skinny/registerForm",
2044
- importName: "FormItemWrapper",
2045
- templates: {
2046
- Text: {
2047
- props: {
2048
- children: {
2049
- type: "component",
2050
- name: "plasmic-antd5-input"
2171
+ optionClassName: {
2172
+ type: "class",
2173
+ displayName: "Option styles",
2174
+ noSelf: true,
2175
+ selectors: [
2176
+ {
2177
+ selector: ":popup.ant-select-dropdown .ant-select-item-option",
2178
+ label: "Base"
2179
+ },
2180
+ {
2181
+ selector: ":popup.ant-select-dropdown .ant-select-item-option-active",
2182
+ label: "Focused"
2183
+ },
2184
+ {
2185
+ selector: ":popup.ant-select-dropdown .ant-select-item-option-selected",
2186
+ label: "Selected"
2051
2187
  }
2052
- }
2188
+ ],
2189
+ advanced: true
2053
2190
  },
2054
- "Long Text": {
2055
- props: {
2056
- children: {
2057
- type: "component",
2058
- name: "plasmic-antd5-textarea"
2191
+ placeholderClassName: {
2192
+ type: "class",
2193
+ displayName: "Placeholder styles",
2194
+ selectors: [
2195
+ {
2196
+ selector: ":component .ant-select-selector .ant-select-selection-placeholder",
2197
+ label: "Base"
2059
2198
  }
2060
- }
2199
+ ],
2200
+ advanced: true
2061
2201
  },
2062
- "Select dropdown": {
2063
- props: {
2064
- children: {
2202
+ defaultStylesClassName: {
2203
+ type: "themeResetClass"
2204
+ }
2205
+ },
2206
+ states: {
2207
+ value: {
2208
+ type: "writable",
2209
+ valueProp: "value",
2210
+ onChangeProp: "onChange",
2211
+ variableType: "text"
2212
+ }
2213
+ }
2214
+ }, { trapsSelection: true }), {
2215
+ importPath: "@plasmicpkgs/antd5/skinny/registerSelect",
2216
+ importName: "AntdSelect"
2217
+ }));
2218
+ registerComponentHelper(loader, AntdOption, {
2219
+ name: optionComponentName,
2220
+ displayName: "Option",
2221
+ parentComponentName: selectComponentName,
2222
+ props: {
2223
+ children: __spreadValues$5({
2224
+ type: "slot",
2225
+ defaultValue: "Option"
2226
+ }, { mergeWithParent: true }),
2227
+ value: {
2228
+ type: "string"
2229
+ }
2230
+ },
2231
+ importPath: "@plasmicpkgs/antd5/skinny/registerSelect",
2232
+ importName: "AntdOption"
2233
+ });
2234
+ registerComponentHelper(loader, AntdOptionGroup, {
2235
+ name: optionGroupComponentName,
2236
+ displayName: "Option Group",
2237
+ parentComponentName: selectComponentName,
2238
+ props: {
2239
+ children: {
2240
+ type: "slot",
2241
+ defaultValue: [
2242
+ {
2065
2243
  type: "component",
2066
- name: "plasmic-antd5-select"
2067
- }
2068
- }
2069
- },
2070
- Number: {
2071
- props: {
2072
- children: {
2244
+ name: "plasmic-antd5-option",
2245
+ props: {
2246
+ value: "option1",
2247
+ children: {
2248
+ type: "text",
2249
+ value: "Option 1"
2250
+ }
2251
+ }
2252
+ },
2253
+ {
2073
2254
  type: "component",
2074
- name: "plasmic-antd5-input-number"
2255
+ name: "plasmic-antd5-option",
2256
+ props: {
2257
+ value: "option2",
2258
+ children: {
2259
+ type: "text",
2260
+ value: "Option 1"
2261
+ }
2262
+ }
2075
2263
  }
2076
- }
2264
+ ]
2077
2265
  },
2078
- Checkbox: {
2079
- props: {
2080
- children: {
2081
- type: "component",
2082
- name: "plasmic-antd5-checkbox"
2083
- },
2084
- valuePropName: "checked",
2085
- noLabel: true
2086
- }
2266
+ label: {
2267
+ type: "slot",
2268
+ defaultValue: "Group label"
2269
+ }
2270
+ },
2271
+ importPath: "@plasmicpkgs/antd5/skinny/registerSelect",
2272
+ importName: "AntdOptionGroup"
2273
+ });
2274
+ }
2275
+
2276
+ var __defProp$4 = Object.defineProperty;
2277
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
2278
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
2279
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
2280
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2281
+ var __spreadValues$4 = (a, b) => {
2282
+ for (var prop in b || (b = {}))
2283
+ if (__hasOwnProp$4.call(b, prop))
2284
+ __defNormalProp$4(a, prop, b[prop]);
2285
+ if (__getOwnPropSymbols$4)
2286
+ for (var prop of __getOwnPropSymbols$4(b)) {
2287
+ if (__propIsEnum$4.call(b, prop))
2288
+ __defNormalProp$4(a, prop, b[prop]);
2289
+ }
2290
+ return a;
2291
+ };
2292
+ function AntdSwitch(props) {
2293
+ return /* @__PURE__ */ React__default.default.createElement(antd.Switch, __spreadValues$4({}, props));
2294
+ }
2295
+ AntdSwitch.__plasmicFormFieldMeta = { valueProp: "checked" };
2296
+ const switchComponentName = "plasmic-antd5-switch";
2297
+ function registerSwitch(loader) {
2298
+ registerComponentHelper(loader, AntdSwitch, {
2299
+ name: switchComponentName,
2300
+ displayName: "Switch",
2301
+ props: {
2302
+ checked: {
2303
+ type: "boolean",
2304
+ editOnly: true,
2305
+ uncontrolledProp: "defaultChecked",
2306
+ description: "Whether the switch is toggled on",
2307
+ defaultValueHint: false,
2308
+ hidden: (ps) => !!ps.__plasmicFormField
2087
2309
  },
2088
- Radios: {
2089
- props: {
2090
- children: {
2091
- type: "component",
2092
- name: "plasmic-antd5-radio-group"
2093
- }
2094
- }
2310
+ disabled: {
2311
+ type: "boolean",
2312
+ description: "If switch is disabled",
2313
+ defaultValueHint: false
2095
2314
  },
2096
- Password: {
2097
- props: {
2098
- children: {
2099
- type: "component",
2100
- name: "plasmic-antd5-input-password"
2101
- }
2102
- }
2315
+ autoFocus: {
2316
+ type: "boolean",
2317
+ description: "If get focus when component mounted",
2318
+ defaultValueHint: false,
2319
+ advanced: true
2103
2320
  },
2104
- "Submit button": {
2105
- props: {
2106
- children: {
2107
- type: "component",
2108
- name: "plasmic-antd5-button",
2109
- props: {
2110
- type: "primary"
2111
- }
2112
- },
2113
- noLabel: true
2321
+ onChange: {
2322
+ type: "eventHandler",
2323
+ argTypes: [{ name: "checked", type: "boolean" }]
2324
+ }
2325
+ },
2326
+ states: {
2327
+ checked: {
2328
+ type: "writable",
2329
+ valueProp: "checked",
2330
+ onChangeProp: "onChange",
2331
+ variableType: "boolean"
2332
+ }
2333
+ },
2334
+ importPath: "@plasmicpkgs/antd5/skinny/registerSwitch",
2335
+ importName: "AntdSwitch"
2336
+ });
2337
+ }
2338
+
2339
+ var __defProp$3 = Object.defineProperty;
2340
+ var __defProps$2 = Object.defineProperties;
2341
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2342
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2343
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2344
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
2345
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2346
+ var __spreadValues$3 = (a, b) => {
2347
+ for (var prop in b || (b = {}))
2348
+ if (__hasOwnProp$3.call(b, prop))
2349
+ __defNormalProp$3(a, prop, b[prop]);
2350
+ if (__getOwnPropSymbols$3)
2351
+ for (var prop of __getOwnPropSymbols$3(b)) {
2352
+ if (__propIsEnum$3.call(b, prop))
2353
+ __defNormalProp$3(a, prop, b[prop]);
2354
+ }
2355
+ return a;
2356
+ };
2357
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
2358
+ var __objRest$3 = (source, exclude) => {
2359
+ var target = {};
2360
+ for (var prop in source)
2361
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
2362
+ target[prop] = source[prop];
2363
+ if (source != null && __getOwnPropSymbols$3)
2364
+ for (var prop of __getOwnPropSymbols$3(source)) {
2365
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
2366
+ target[prop] = source[prop];
2367
+ }
2368
+ return target;
2369
+ };
2370
+ const reactNodeToString = function(reactNode) {
2371
+ let string = "";
2372
+ if (typeof reactNode === "string") {
2373
+ string = reactNode;
2374
+ } else if (typeof reactNode === "number") {
2375
+ string = reactNode.toString();
2376
+ } else if (reactNode instanceof Array) {
2377
+ reactNode.forEach(function(child) {
2378
+ string += reactNodeToString(child);
2379
+ });
2380
+ } else if (React.isValidElement(reactNode)) {
2381
+ string += reactNodeToString(reactNode.props.children);
2382
+ }
2383
+ return string;
2384
+ };
2385
+ function ensureArray(x) {
2386
+ return Array.isArray(x) ? x : [x];
2387
+ }
2388
+ const FormItem = antd.Form.Item;
2389
+ const FormList = antd.Form.List;
2390
+ var InputType = /* @__PURE__ */ ((InputType2) => {
2391
+ InputType2["Text"] = "Text";
2392
+ InputType2["TextArea"] = "Text Area";
2393
+ InputType2["Password"] = "Password";
2394
+ InputType2["Number"] = "Number";
2395
+ InputType2["Select"] = "Select";
2396
+ InputType2["Option"] = "Option";
2397
+ InputType2["OptionGroup"] = "Option Group";
2398
+ InputType2["Radio"] = "Radio";
2399
+ InputType2["RadioGroup"] = "Radio Group";
2400
+ InputType2["Checkbox"] = "Checkbox";
2401
+ return InputType2;
2402
+ })(InputType || {});
2403
+ const PathContext = React__default.default.createContext({ relativePath: [], fullPath: [] });
2404
+ const InternalFormInstanceContext = React__default.default.createContext(void 0);
2405
+ const FormLayoutContext = React__default.default.createContext(void 0);
2406
+ const Internal = (props) => {
2407
+ var _b, _c, _d, _e;
2408
+ const [form] = antd.Form.useForm();
2409
+ const values = form.getFieldsValue(true);
2410
+ const lastValue = React__default.default.useRef(values);
2411
+ const _a = props, { extendedOnValuesChange, setRemountKey } = _a, rest = __objRest$3(_a, ["extendedOnValuesChange", "setRemountKey"]);
2412
+ let childrenNode;
2413
+ if (props.mode !== "simplified") {
2414
+ childrenNode = typeof props.children === "function" ? props.children(values, form) : props.children;
2415
+ } else {
2416
+ childrenNode = /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, ((_b = props.formItems) != null ? _b : []).map((formItem) => /* @__PURE__ */ React__default.default.createElement(
2417
+ FormItemWrapper,
2418
+ __spreadProps$2(__spreadValues$3({}, formItem), {
2419
+ noLabel: formItem.inputType === "Checkbox" /* Checkbox */ || formItem.noLabel,
2420
+ style: { width: "100%" }
2421
+ }),
2422
+ 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(antd.Checkbox, null, formItem.label) : formItem.inputType === "Select" /* Select */ ? /* @__PURE__ */ React__default.default.createElement(antd.Select, { options: formItem.options }) : formItem.inputType === "Radio" /* Radio */ ? /* @__PURE__ */ React__default.default.createElement(
2423
+ antd.Radio.Group,
2424
+ {
2425
+ options: formItem.options,
2426
+ optionType: formItem.optionType
2114
2427
  }
2115
- }
2428
+ ) : null
2429
+ )), props.submitSlot);
2430
+ }
2431
+ const fireOnValuesChange = React__default.default.useCallback(() => {
2432
+ const values2 = form.getFieldsValue(true);
2433
+ if (!equal__default.default(values2, lastValue.current)) {
2434
+ extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(values2);
2435
+ lastValue.current = values2;
2116
2436
  }
2117
- }, { trapsSelection: true }));
2118
- }
2119
- function FormGroup(props) {
2120
- const pathCtx = React__default.default.useContext(PathContext);
2437
+ }, [form, lastValue]);
2438
+ React__default.default.useEffect(() => {
2439
+ fireOnValuesChange();
2440
+ }, []);
2441
+ const formLayout = React__default.default.useMemo(
2442
+ () => {
2443
+ var _a2;
2444
+ return {
2445
+ layout: props.layout,
2446
+ labelSpan: (_a2 = props.labelCol) == null ? void 0 : _a2.span
2447
+ };
2448
+ },
2449
+ [props.layout, (_c = props.labelCol) == null ? void 0 : _c.span]
2450
+ );
2121
2451
  return /* @__PURE__ */ React__default.default.createElement(
2122
- PathContext.Provider,
2452
+ InternalFormInstanceContext.Provider,
2123
2453
  {
2124
2454
  value: {
2125
- relativePath: [...pathCtx.relativePath, props.name],
2126
- fullPath: [...pathCtx.fullPath, props.name]
2455
+ layout: formLayout,
2456
+ fireOnValuesChange,
2457
+ forceRemount: () => setRemountKey((k) => k + 1)
2127
2458
  }
2128
2459
  },
2129
- props.children
2460
+ /* @__PURE__ */ React__default.default.createElement(FormLayoutContext.Provider, { value: formLayout }, /* @__PURE__ */ React__default.default.createElement(
2461
+ antd.Form,
2462
+ __spreadProps$2(__spreadValues$3({}, rest), {
2463
+ key: props.initialValues ? JSON.stringify(props.initialValues) : void 0,
2464
+ onValuesChange: (...args) => {
2465
+ var _a2;
2466
+ (_a2 = props.onValuesChange) == null ? void 0 : _a2.call(props, ...args);
2467
+ extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(args[1]);
2468
+ },
2469
+ form,
2470
+ labelCol: ((_d = props.labelCol) == null ? void 0 : _d.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
2471
+ wrapperCol: ((_e = props.wrapperCol) == null ? void 0 : _e.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
2472
+ }),
2473
+ /* @__PURE__ */ React__default.default.createElement("style", null, `
2474
+ .ant-form-item-explain + div, .ant-form-item-margin-offset {
2475
+ display: none;
2476
+ }
2477
+ `),
2478
+ childrenNode
2479
+ ))
2130
2480
  );
2481
+ };
2482
+ function FormWrapper(props) {
2483
+ const [remountKey, setRemountKey] = React__default.default.useState(0);
2484
+ const previousInitialValues = usePrevious(props.initialValues);
2485
+ React__default.default.useEffect(() => {
2486
+ if (previousInitialValues !== props.initialValues && JSON.stringify(previousInitialValues) !== JSON.stringify(props.initialValues)) {
2487
+ setRemountKey((k) => k + 1);
2488
+ }
2489
+ }, [previousInitialValues, props.initialValues]);
2490
+ return /* @__PURE__ */ React__default.default.createElement(Internal, __spreadProps$2(__spreadValues$3({ key: remountKey }, props), { setRemountKey }));
2131
2491
  }
2132
- function registerFormGroup(loader) {
2133
- registerComponentHelper(loader, FormGroup, {
2134
- name: "plasmic-antd5-form-group",
2135
- displayName: "Form Group",
2136
- parentComponentName: "plasmic-antd5-form",
2137
- actions: COMMON_ACTIONS,
2138
- props: {
2139
- name: {
2140
- type: "string"
2141
- },
2142
- children: {
2143
- type: "slot"
2144
- }
2492
+ const COMMON_ACTIONS = [
2493
+ {
2494
+ type: "button-action",
2495
+ label: "Append new Form Field",
2496
+ onClick: ({ studioOps }) => {
2497
+ studioOps.appendToSlot(
2498
+ {
2499
+ type: "component",
2500
+ name: "plasmic-antd5-form-item"
2501
+ },
2502
+ "children"
2503
+ );
2145
2504
  },
2146
- importPath: "@plasmicpkgs/antd5/skinny/registerForm",
2147
- importName: "FormGroup"
2148
- });
2149
- }
2150
- const FormListWrapper = React__default.default.forwardRef(function FormListWrapper2(props, ref) {
2151
- var _a;
2152
- const relativeFormItemName = useFormItemRelativeName(props.name);
2153
- const fullFormItemName = useFormItemFullName(props.name);
2154
- const operationsRef = React__default.default.useRef(
2155
- void 0
2156
- );
2157
- React__default.default.useImperativeHandle(
2158
- ref,
2159
- () => ({
2160
- add(defaultValue, insertIndex) {
2161
- if (operationsRef.current) {
2162
- const { add } = operationsRef.current[1];
2163
- add(defaultValue, insertIndex);
2164
- }
2165
- },
2166
- remove(index) {
2167
- if (operationsRef.current) {
2168
- const { remove } = operationsRef.current[1];
2169
- remove(index);
2170
- }
2171
- },
2172
- move(from, to) {
2173
- if (operationsRef.current) {
2174
- const { move } = operationsRef.current[1];
2175
- move(from, to);
2176
- }
2177
- }
2178
- }),
2179
- [operationsRef]
2180
- );
2181
- const inCanvas = !!host.usePlasmicCanvasContext();
2182
- if (inCanvas) {
2183
- const form = useFormInstanceMaybe();
2184
- const prevPropValues = React__default.default.useRef({
2185
- initialValue: props.initialValue,
2186
- name: props.name
2187
- });
2188
- const { fireOnValuesChange, forceRemount } = (_a = React__default.default.useContext(InternalFormInstanceContext)) != null ? _a : {};
2189
- React__default.default.useEffect(() => {
2190
- if (prevPropValues.current.name !== props.name) {
2191
- forceRemount == null ? void 0 : forceRemount();
2192
- }
2193
- if (fullFormItemName) {
2194
- form == null ? void 0 : form.setFieldValue(fullFormItemName, props.initialValue);
2195
- prevPropValues.current.initialValue = props.initialValue;
2196
- fireOnValuesChange == null ? void 0 : fireOnValuesChange();
2197
- }
2198
- }, [props.initialValue, fullFormItemName]);
2505
+ hidden: (props) => props.mode !== "advanced"
2199
2506
  }
2200
- return /* @__PURE__ */ React__default.default.createElement(FormList, __spreadProps$5(__spreadValues$6({}, props), { name: relativeFormItemName != null ? relativeFormItemName : [] }), (...args) => {
2201
- operationsRef.current = args;
2202
- return args[0].map((field, index) => /* @__PURE__ */ React__default.default.createElement(
2203
- PathContext.Provider,
2204
- {
2205
- value: {
2206
- relativePath: [field.name],
2207
- fullPath: [...fullFormItemName != null ? fullFormItemName : [], field.name]
2208
- }
2209
- },
2210
- /* @__PURE__ */ React__default.default.createElement(host.DataProvider, { name: "currentField", data: field }, /* @__PURE__ */ React__default.default.createElement(host.DataProvider, { name: "currentFieldIndex", data: index }, host.repeatedElement(index, props.children)))
2211
- ));
2212
- });
2507
+ // {
2508
+ // type: "button-action" as const,
2509
+ // label: "Append new Form Field Group",
2510
+ // onClick: ({ studioOps }: ActionProps<any>) => {
2511
+ // studioOps.appendToSlot(
2512
+ // {
2513
+ // type: "component",
2514
+ // name: "plasmic-antd5-form-group",
2515
+ // },
2516
+ // "children"
2517
+ // );
2518
+ // },
2519
+ // },
2520
+ // {
2521
+ // type: "button-action" as const,
2522
+ // label: "Append new Form List",
2523
+ // onClick: ({ studioOps }: ActionProps<any>) => {
2524
+ // studioOps.appendToSlot(
2525
+ // {
2526
+ // type: "component",
2527
+ // name: "plasmic-antd5-form-list",
2528
+ // },
2529
+ // "children"
2530
+ // );
2531
+ // },
2532
+ // },
2533
+ ];
2534
+ const colProp = (displayName, defaultValue, description) => ({
2535
+ type: "object",
2536
+ displayName,
2537
+ advanced: true,
2538
+ fields: {
2539
+ span: {
2540
+ type: "number",
2541
+ displayName: "Width",
2542
+ description: "The number of grid columns to span in width (out of 24 columns total)",
2543
+ min: 1,
2544
+ max: 24
2545
+ },
2546
+ offset: {
2547
+ type: "number",
2548
+ displayName: "Offset",
2549
+ description: "Number of grid columns to skip from the left (out of 24 columns total)",
2550
+ min: 0,
2551
+ max: 23
2552
+ },
2553
+ horizontalOnly: {
2554
+ type: "boolean",
2555
+ displayName: "Horizontal only",
2556
+ description: "Only apply to horizontal layout"
2557
+ }
2558
+ },
2559
+ description,
2560
+ defaultValue
2213
2561
  });
2214
- function registerFormList(loader) {
2215
- registerComponentHelper(loader, FormListWrapper, {
2216
- name: "plasmic-antd5-form-list",
2217
- parentComponentName: "plasmic-antd5-form",
2218
- displayName: "Form List",
2219
- actions: COMMON_ACTIONS,
2562
+ const formComponentName = "plasmic-antd5-form";
2563
+ function registerForm(loader) {
2564
+ registerComponentHelper(loader, FormWrapper, {
2565
+ name: formComponentName,
2566
+ displayName: "Form",
2567
+ defaultStyles: {
2568
+ layout: "vbox",
2569
+ alignItems: "flex-start"
2570
+ },
2220
2571
  props: {
2221
- children: {
2222
- type: "slot",
2223
- defaultValue: [
2224
- {
2225
- type: "hbox",
2226
- children: [
2227
- {
2228
- type: "component",
2229
- name: "plasmic-antd5-form-item",
2230
- props: {
2231
- name: "firstName",
2232
- label: {
2233
- type: "text",
2234
- value: "First name"
2235
- },
2236
- children: {
2237
- type: "component",
2238
- name: "plasmic-antd5-input"
2239
- }
2240
- }
2241
- },
2242
- {
2243
- type: "component",
2244
- name: "plasmic-antd5-form-item",
2245
- props: {
2246
- name: "lastName",
2247
- label: {
2248
- type: "text",
2249
- value: "Last name"
2572
+ mode: "controlMode",
2573
+ formItems: {
2574
+ type: "array",
2575
+ itemType: {
2576
+ type: "object",
2577
+ fields: __spreadValues$3({
2578
+ label: "string",
2579
+ inputType: {
2580
+ type: "choice",
2581
+ options: Object.values(InputType),
2582
+ defaultValue: "Text" /* Text */
2583
+ },
2584
+ options: {
2585
+ type: "array",
2586
+ itemType: {
2587
+ type: "object",
2588
+ fields: {
2589
+ type: {
2590
+ type: "choice",
2591
+ options: [
2592
+ { value: "option", label: "Option" },
2593
+ { value: "option-group", label: "Option Group" }
2594
+ ],
2595
+ defaultValue: "option"
2250
2596
  },
2251
- children: {
2252
- type: "component",
2253
- name: "plasmic-antd5-input"
2597
+ label: "string",
2598
+ value: {
2599
+ type: "string",
2600
+ hidden: (ps) => ps.type !== "option-group"
2601
+ },
2602
+ options: {
2603
+ type: "array",
2604
+ itemType: {
2605
+ type: "object",
2606
+ nameFunc: (item) => item.label || item.value,
2607
+ fields: {
2608
+ value: "string",
2609
+ label: "string"
2610
+ }
2611
+ }
2254
2612
  }
2255
- }
2256
- }
2257
- ]
2258
- }
2259
- ]
2260
- },
2261
- name: {
2262
- type: "string",
2263
- defaultValue: "guests"
2613
+ },
2614
+ nameFunc: (item) => item == null ? void 0 : item.label
2615
+ },
2616
+ hidden: (ps) => !["Select" /* Select */, "Radio" /* Radio */].includes(ps.inputType)
2617
+ },
2618
+ optionType: {
2619
+ type: "choice",
2620
+ options: [
2621
+ { value: "default", label: "Radio" },
2622
+ { value: "button", label: "Button" }
2623
+ ],
2624
+ hidden: (ps) => "Radio" /* Radio */ !== ps.inputType,
2625
+ defaultValueHint: "Radio",
2626
+ displayName: "Option Type"
2627
+ }
2628
+ }, commonFormItemProps),
2629
+ nameFunc: (item) => item.label
2630
+ },
2631
+ hidden: (props) => props.mode === "advanced"
2264
2632
  },
2265
- initialValue: {
2266
- type: "array",
2267
- defaultValue: [
2268
- {
2269
- firstName: "Jane",
2270
- lastName: "Doe"
2271
- },
2272
- {
2273
- firstName: "John",
2274
- lastName: "Smith"
2633
+ submitSlot: __spreadValues$3({
2634
+ type: "slot",
2635
+ hidden: () => true,
2636
+ defaultValue: {
2637
+ type: "component",
2638
+ name: buttonComponentName,
2639
+ props: {
2640
+ type: "primary",
2641
+ submitsForm: true,
2642
+ children: {
2643
+ type: "text",
2644
+ value: "Submit"
2645
+ }
2275
2646
  }
2276
- ]
2277
- }
2278
- },
2279
- refActions: {
2280
- add: {
2281
- displayName: "Add an item",
2282
- argTypes: [
2647
+ }
2648
+ }, {
2649
+ mergeWithParent: () => true,
2650
+ hiddenMergedProps: (ps) => !ps.mode
2651
+ }),
2652
+ children: {
2653
+ type: "slot",
2654
+ defaultValue: [
2283
2655
  {
2284
- name: "defaultValue",
2285
- displayName: "Default value",
2286
- type: "object"
2656
+ type: "component",
2657
+ name: formItemComponentName,
2658
+ props: {
2659
+ label: {
2660
+ type: "text",
2661
+ value: "Name"
2662
+ },
2663
+ name: "name",
2664
+ children: {
2665
+ type: "component",
2666
+ name: inputComponentName
2667
+ }
2668
+ }
2287
2669
  },
2288
2670
  {
2289
- name: "insertIndex",
2290
- displayName: "Insert index",
2291
- type: "number"
2292
- }
2293
- ]
2294
- },
2295
- remove: {
2296
- displayName: "Remove an item",
2297
- argTypes: [
2298
- {
2299
- name: "index",
2300
- displayName: "Index",
2301
- type: "number"
2302
- }
2303
- ]
2304
- },
2305
- move: {
2306
- displayName: "Move field",
2307
- argTypes: [
2308
- {
2309
- name: "from",
2310
- displayName: "From",
2311
- type: "number"
2671
+ type: "component",
2672
+ name: formItemComponentName,
2673
+ props: {
2674
+ label: {
2675
+ type: "text",
2676
+ value: "Message"
2677
+ },
2678
+ name: "message",
2679
+ children: {
2680
+ type: "component",
2681
+ name: textAreaComponentName
2682
+ }
2683
+ }
2312
2684
  },
2313
2685
  {
2314
- name: "to",
2315
- displayName: "To",
2316
- type: "number"
2686
+ type: "component",
2687
+ name: buttonComponentName,
2688
+ props: {
2689
+ children: {
2690
+ type: "text",
2691
+ value: "Submit"
2692
+ },
2693
+ type: "primary",
2694
+ submitsForm: true
2695
+ }
2317
2696
  }
2318
- ]
2319
- }
2320
- },
2321
- importPath: "@plasmicpkgs/antd5/skinny/registerForm",
2322
- importName: "FormListWrapper"
2323
- });
2324
- }
2325
-
2326
- var __defProp$5 = Object.defineProperty;
2327
- var __defProps$4 = Object.defineProperties;
2328
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
2329
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
2330
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
2331
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
2332
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2333
- var __spreadValues$5 = (a, b) => {
2334
- for (var prop in b || (b = {}))
2335
- if (__hasOwnProp$5.call(b, prop))
2336
- __defNormalProp$5(a, prop, b[prop]);
2337
- if (__getOwnPropSymbols$5)
2338
- for (var prop of __getOwnPropSymbols$5(b)) {
2339
- if (__propIsEnum$5.call(b, prop))
2340
- __defNormalProp$5(a, prop, b[prop]);
2341
- }
2342
- return a;
2343
- };
2344
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
2345
- const AntdInput = antd.Input;
2346
- const AntdTextArea = antd.Input.TextArea;
2347
- const AntdPassword = antd.Input.Password;
2348
- const AntdInputNumber = antd.InputNumber;
2349
- const inputHelpers = {
2350
- states: {
2351
- value: {
2352
- onChangeArgsToValue: (e) => {
2353
- return e.target.value;
2354
- }
2355
- }
2356
- }
2357
- };
2358
- const COMMON_HELPERS_CONFIG = {
2359
- helpers: inputHelpers,
2360
- importName: "inputHelpers",
2361
- importPath: "@plasmicpkgs/antd5/skinny/registerInput"
2362
- };
2363
- const COMMON_STATES = {
2364
- value: {
2365
- type: "writable",
2366
- valueProp: "value",
2367
- variableType: "text",
2368
- onChangeProp: "onChange"
2369
- }
2370
- };
2371
- const COMMON_DECORATOR_PROPS = {
2372
- prefix: {
2373
- type: "slot",
2374
- hidePlaceholder: true
2375
- },
2376
- suffix: {
2377
- type: "slot",
2378
- hidePlaceholder: true
2379
- },
2380
- addonAfter: {
2381
- type: "slot",
2382
- hidePlaceholder: true
2383
- },
2384
- addonBefore: {
2385
- type: "slot",
2386
- hidePlaceholder: true
2387
- }
2388
- };
2389
- const COMMON_ADVANCED_PROPS = {
2390
- maxLength: {
2391
- type: "number",
2392
- advanced: true
2393
- },
2394
- bordered: {
2395
- type: "boolean",
2396
- advanced: true,
2397
- defaultValueHint: true
2398
- },
2399
- allowClear: {
2400
- type: "boolean",
2401
- advanced: true
2402
- },
2403
- autoFocus: {
2404
- type: "boolean",
2405
- advanced: true
2406
- },
2407
- readOnly: {
2408
- type: "boolean",
2409
- advanced: true
2410
- }
2411
- };
2412
- const COMMON_EVENT_HANDLERS = {
2413
- onChange: {
2414
- type: "eventHandler",
2415
- argTypes: [
2416
- {
2417
- name: "event",
2418
- type: "object"
2419
- }
2420
- ]
2421
- },
2422
- onPressEnter: {
2423
- type: "eventHandler",
2424
- argTypes: [
2425
- {
2426
- name: "event",
2427
- type: "object"
2428
- }
2429
- ]
2430
- }
2431
- };
2432
- function registerInput(loader) {
2433
- registerComponentHelper(loader, AntdInput, __spreadProps$4(__spreadValues$5({
2434
- name: "plasmic-antd5-input",
2435
- displayName: "Input",
2436
- props: __spreadValues$5(__spreadValues$5(__spreadValues$5({
2437
- value: {
2438
- type: "string"
2439
- },
2440
- placeholder: {
2441
- type: "string"
2442
- },
2443
- size: {
2444
- type: "choice",
2445
- options: ["large", "middle", "small"]
2446
- },
2447
- disabled: {
2448
- type: "boolean"
2449
- },
2450
- type: {
2451
- type: "choice",
2452
- options: [
2453
- "text",
2454
- "password",
2455
- "number",
2456
- "date",
2457
- "datetime-local",
2458
- "time",
2459
- "email",
2460
- "tel",
2461
- "hidden"
2462
2697
  ],
2463
- defaultValueHint: "text"
2464
- }
2465
- }, COMMON_ADVANCED_PROPS), COMMON_DECORATOR_PROPS), COMMON_EVENT_HANDLERS),
2466
- states: __spreadValues$5({}, COMMON_STATES)
2467
- }, { trapsSelection: true }), {
2468
- componentHelpers: COMMON_HELPERS_CONFIG,
2469
- importPath: "@plasmicpkgs/antd5/skinny/registerInput",
2470
- importName: "AntdInput"
2471
- }));
2472
- }
2473
- function registerTextArea(loader) {
2474
- registerComponentHelper(loader, AntdTextArea, {
2475
- name: "plasmic-antd5-textarea",
2476
- parentComponentName: "plasmic-antd5-input",
2477
- displayName: "Text Area",
2478
- props: __spreadValues$5({
2479
- value: {
2480
- type: "string"
2698
+ hidden: (props) => props.mode !== "advanced"
2481
2699
  },
2482
- placeholder: {
2483
- type: "string"
2700
+ initialValues: {
2701
+ type: "object"
2484
2702
  },
2485
- disabled: {
2486
- type: "boolean"
2703
+ layout: {
2704
+ type: "choice",
2705
+ options: ["horizontal", "vertical", "inline"],
2706
+ defaultValue: "vertical"
2487
2707
  },
2488
- maxLength: {
2489
- type: "number",
2490
- advanced: true
2708
+ labelAlign: {
2709
+ type: "choice",
2710
+ options: ["left", "right"],
2711
+ defaultValueHint: "right",
2712
+ advanced: true,
2713
+ hidden: (ps) => ps.layout !== "horizontal"
2491
2714
  },
2492
- bordered: {
2715
+ labelCol: colProp(
2716
+ "Label layout",
2717
+ {
2718
+ span: 8,
2719
+ horizontalOnly: true
2720
+ },
2721
+ "Set the width and offset of the labels"
2722
+ ),
2723
+ wrapperCol: colProp(
2724
+ "Control layout",
2725
+ {
2726
+ span: 16,
2727
+ horizontalOnly: true
2728
+ },
2729
+ "Set the width and offset of the form controls"
2730
+ ),
2731
+ colon: {
2493
2732
  type: "boolean",
2733
+ description: `Show a colon after labels by default (only for horizontal layout)`,
2734
+ defaultValueHint: true,
2494
2735
  advanced: true,
2495
- defaultValueHint: true
2496
- }
2497
- }, COMMON_EVENT_HANDLERS),
2498
- states: __spreadValues$5({}, COMMON_STATES),
2499
- componentHelpers: COMMON_HELPERS_CONFIG,
2500
- importPath: "@plasmicpkgs/antd5/skinny/registerInput",
2501
- importName: "AntdTextArea"
2502
- });
2503
- }
2504
- function registerPasswordInput(loader) {
2505
- registerComponentHelper(loader, AntdPassword, {
2506
- name: "plasmic-antd5-input-password",
2507
- parentComponentName: "plasmic-antd5-input",
2508
- displayName: "Password Input",
2509
- props: __spreadValues$5({
2510
- value: {
2511
- type: "string"
2512
- },
2513
- placeholder: {
2514
- type: "string"
2515
- },
2516
- disabled: {
2517
- type: "boolean"
2518
- },
2519
- maxLength: {
2520
- type: "number",
2521
- advanced: true
2736
+ hidden: (props) => {
2737
+ var _a;
2738
+ return ((_a = props.layout) != null ? _a : "horizontal") !== "horizontal";
2739
+ }
2522
2740
  },
2523
- bordered: {
2524
- type: "boolean",
2741
+ requiredMark: {
2742
+ displayName: "Required/optional mark",
2743
+ type: "choice",
2744
+ options: [
2745
+ {
2746
+ value: "optional",
2747
+ label: "Indicate optional fields"
2748
+ },
2749
+ {
2750
+ value: true,
2751
+ label: "Indicate required fields with asterisk"
2752
+ },
2753
+ {
2754
+ value: false,
2755
+ label: "Show no indicators"
2756
+ }
2757
+ ],
2525
2758
  advanced: true,
2526
2759
  defaultValueHint: true
2527
- }
2528
- }, COMMON_EVENT_HANDLERS),
2529
- states: __spreadValues$5({}, COMMON_STATES),
2530
- componentHelpers: COMMON_HELPERS_CONFIG,
2531
- importPath: "@plasmicpkgs/antd5/skinny/registerInput",
2532
- importName: "AntdPassword"
2533
- });
2534
- }
2535
- function registerNumberInput(loader) {
2536
- registerComponentHelper(loader, AntdInputNumber, __spreadProps$4(__spreadValues$5({
2537
- name: "plasmic-antd5-input-number",
2538
- parentComponentName: "plasmic-antd5-input",
2539
- displayName: "Number Input",
2540
- props: __spreadProps$4(__spreadValues$5(__spreadValues$5(__spreadValues$5({
2541
- value: {
2542
- type: "number"
2543
2760
  },
2544
- placeholder: {
2545
- type: "string"
2546
- },
2547
- disabled: {
2548
- type: "boolean"
2549
- },
2550
- max: {
2551
- type: "number"
2761
+ extendedOnValuesChange: {
2762
+ type: "eventHandler",
2763
+ displayName: "On values change",
2764
+ argTypes: [
2765
+ {
2766
+ name: "changedValues",
2767
+ type: "object"
2768
+ },
2769
+ {
2770
+ name: "allValues",
2771
+ type: "object"
2772
+ }
2773
+ ]
2552
2774
  },
2553
- min: {
2554
- type: "number"
2775
+ onFinish: {
2776
+ type: "eventHandler",
2777
+ displayName: "On submit",
2778
+ argTypes: [
2779
+ {
2780
+ name: "values",
2781
+ type: "object"
2782
+ }
2783
+ ]
2555
2784
  },
2556
- step: {
2557
- type: "number",
2558
- helpText: "Increment or decrement step"
2785
+ onFinishFailed: {
2786
+ // function({ values, errorFields, outOfDate })
2787
+ type: "eventHandler",
2788
+ displayName: "On invalid submit",
2789
+ argTypes: [
2790
+ {
2791
+ name: "data",
2792
+ type: "object"
2793
+ }
2794
+ ]
2559
2795
  },
2560
- controls: {
2561
- type: "boolean",
2562
- displayName: "Show add/minus controls?",
2796
+ validateTrigger: {
2797
+ type: "choice",
2798
+ options: ["onSubmit", "onChange", "onBlur"],
2799
+ multiSelect: true,
2800
+ defaultValueHint: ["onChange"],
2563
2801
  advanced: true
2564
2802
  }
2565
- }, COMMON_DECORATOR_PROPS), COMMON_ADVANCED_PROPS), COMMON_EVENT_HANDLERS), {
2566
- // onChange directly called with the number
2567
- onChange: {
2568
- type: "eventHandler",
2569
- argTypes: [
2570
- {
2571
- name: "value",
2572
- type: "number"
2573
- }
2574
- ]
2803
+ },
2804
+ actions: COMMON_ACTIONS,
2805
+ states: {
2806
+ value: {
2807
+ type: "readonly",
2808
+ variableType: "object",
2809
+ onChangeProp: "extendedOnValuesChange"
2810
+ }
2811
+ },
2812
+ importPath: "@plasmicpkgs/antd5/skinny/registerForm",
2813
+ importName: "FormWrapper"
2814
+ });
2815
+ }
2816
+ function plasmicRulesToAntdRules(plasmicRules, label) {
2817
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2818
+ const effectiveLabel = label || "This field";
2819
+ const rules = [];
2820
+ for (const plasmicRule of plasmicRules) {
2821
+ switch (plasmicRule.ruleType) {
2822
+ case "enum":
2823
+ rules.push({
2824
+ type: "enum",
2825
+ enum: (_b = (_a = plasmicRule.options) == null ? void 0 : _a.map((opt) => opt.value)) != null ? _b : [],
2826
+ message: (_c = plasmicRule.message) != null ? _c : `${effectiveLabel} must be a valid value`
2827
+ });
2828
+ break;
2829
+ case "required":
2830
+ rules.push({
2831
+ required: true,
2832
+ message: (_d = plasmicRule.message) != null ? _d : `${effectiveLabel} is required`
2833
+ });
2834
+ break;
2835
+ case "regex":
2836
+ rules.push({
2837
+ pattern: new RegExp((_e = plasmicRule.pattern) != null ? _e : ""),
2838
+ message: (_f = plasmicRule.message) != null ? _f : `${effectiveLabel} must be a valid value`
2839
+ });
2840
+ break;
2841
+ case "whitespace":
2842
+ rules.push({
2843
+ whitespace: true,
2844
+ message: (_g = plasmicRule.message) != null ? _g : `${effectiveLabel} is required`
2845
+ });
2846
+ break;
2847
+ case "min":
2848
+ rules.push({
2849
+ [plasmicRule.ruleType]: plasmicRule.length,
2850
+ message: (_h = plasmicRule.message) != null ? _h : `${effectiveLabel} must be at least ${plasmicRule.length} characters`
2851
+ });
2852
+ break;
2853
+ case "max":
2854
+ rules.push({
2855
+ [plasmicRule.ruleType]: plasmicRule.length,
2856
+ message: (_i = plasmicRule.message) != null ? _i : `${effectiveLabel} must be at most ${plasmicRule.length} characters`
2857
+ });
2858
+ break;
2859
+ case "advanced":
2860
+ rules.push({
2861
+ validator: (...args) => {
2862
+ var _a2;
2863
+ return ((_a2 = plasmicRule.custom) == null ? void 0 : _a2.apply(null, args)) ? Promise.resolve() : Promise.reject();
2864
+ },
2865
+ message: plasmicRule.message
2866
+ });
2867
+ }
2868
+ }
2869
+ return rules;
2870
+ }
2871
+ const useFormItemRelativeName = (name) => {
2872
+ const pathCtx = React__default.default.useContext(PathContext);
2873
+ return typeof name === "object" ? [...pathCtx.relativePath, ...name] : typeof name === "string" ? [...pathCtx.relativePath, name] : void 0;
2874
+ };
2875
+ const useFormItemFullName = (name) => {
2876
+ const pathCtx = React__default.default.useContext(PathContext);
2877
+ return typeof name === "object" ? [...pathCtx.fullPath, ...name] : typeof name === "string" ? [...pathCtx.fullPath, name] : void 0;
2878
+ };
2879
+ function useFormInstanceMaybe() {
2880
+ return antd.Form.useFormInstance();
2881
+ }
2882
+ function FormItemWrapper(props) {
2883
+ var _b;
2884
+ const _a = props, {
2885
+ rules: plasmicRules,
2886
+ description,
2887
+ noLabel,
2888
+ name,
2889
+ hideValidationMessage,
2890
+ customizeProps,
2891
+ setControlContextData,
2892
+ alignLabellessWithControls = true
2893
+ } = _a, rest = __objRest$3(_a, [
2894
+ "rules",
2895
+ "description",
2896
+ "noLabel",
2897
+ "name",
2898
+ "hideValidationMessage",
2899
+ "customizeProps",
2900
+ "setControlContextData",
2901
+ "alignLabellessWithControls"
2902
+ ]);
2903
+ const relativeFormItemName = useFormItemRelativeName(name);
2904
+ const fullFormItemName = useFormItemFullName(name);
2905
+ const bestEffortLabel = !noLabel && reactNodeToString(props.label) || ensureArray(props.name).slice(-1)[0];
2906
+ const rules = plasmicRules ? plasmicRulesToAntdRules(
2907
+ plasmicRules,
2908
+ typeof bestEffortLabel === "number" ? "" + bestEffortLabel : bestEffortLabel
2909
+ ) : void 0;
2910
+ const layoutContext = React__default.default.useContext(FormLayoutContext);
2911
+ const inCanvas = !!host.usePlasmicCanvasContext();
2912
+ if (inCanvas) {
2913
+ const form = useFormInstanceMaybe();
2914
+ const prevPropValues = React__default.default.useRef({
2915
+ initialValue: props.initialValue,
2916
+ name: props.name
2917
+ });
2918
+ const internalFormCtx = React__default.default.useContext(InternalFormInstanceContext);
2919
+ const { fireOnValuesChange, forceRemount } = internalFormCtx != null ? internalFormCtx : {};
2920
+ (_b = props.setControlContextData) == null ? void 0 : _b.call(props, {
2921
+ internalFormCtx
2922
+ });
2923
+ React__default.default.useEffect(() => {
2924
+ if (prevPropValues.current.name !== props.name) {
2925
+ forceRemount == null ? void 0 : forceRemount();
2926
+ }
2927
+ if (!fullFormItemName || (form == null ? void 0 : form.getFieldValue(fullFormItemName)) !== prevPropValues.current.initialValue) {
2928
+ return;
2575
2929
  }
2930
+ form == null ? void 0 : form.setFieldValue(fullFormItemName, props.initialValue);
2931
+ prevPropValues.current.initialValue = props.initialValue;
2932
+ fireOnValuesChange == null ? void 0 : fireOnValuesChange();
2933
+ }, [form, props.initialValue, fullFormItemName]);
2934
+ }
2935
+ return /* @__PURE__ */ React__default.default.createElement(
2936
+ FormItem,
2937
+ __spreadProps$2(__spreadValues$3({}, rest), {
2938
+ label: noLabel ? void 0 : props.label,
2939
+ name: relativeFormItemName,
2940
+ rules,
2941
+ extra: description,
2942
+ help: hideValidationMessage ? "" : props.help,
2943
+ colon: noLabel ? false : void 0,
2944
+ valuePropName: deriveValuePropName(props),
2945
+ wrapperCol: (layoutContext == null ? void 0 : layoutContext.layout) === "horizontal" && noLabel && alignLabellessWithControls && layoutContext.labelSpan ? { offset: layoutContext.labelSpan } : void 0
2576
2946
  }),
2577
- states: __spreadValues$5({}, COMMON_STATES)
2578
- }, { trapsSelection: true }), {
2579
- // don't need component helpers
2580
- importPath: "@plasmicpkgs/antd5/skinny/registerInput",
2581
- importName: "AntdInputNumber"
2582
- }));
2947
+ /* @__PURE__ */ React__default.default.createElement(FormItemForwarder, { formItemProps: props })
2948
+ );
2583
2949
  }
2584
-
2585
- var __defProp$4 = Object.defineProperty;
2586
- var __defProps$3 = Object.defineProperties;
2587
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
2588
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
2589
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
2590
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
2591
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2592
- var __spreadValues$4 = (a, b) => {
2593
- for (var prop in b || (b = {}))
2594
- if (__hasOwnProp$4.call(b, prop))
2595
- __defNormalProp$4(a, prop, b[prop]);
2596
- if (__getOwnPropSymbols$4)
2597
- for (var prop of __getOwnPropSymbols$4(b)) {
2598
- if (__propIsEnum$4.call(b, prop))
2599
- __defNormalProp$4(a, prop, b[prop]);
2600
- }
2601
- return a;
2602
- };
2603
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
2604
- var __objRest$4 = (source, exclude) => {
2605
- var target = {};
2606
- for (var prop in source)
2607
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
2608
- target[prop] = source[prop];
2609
- if (source != null && __getOwnPropSymbols$4)
2610
- for (var prop of __getOwnPropSymbols$4(source)) {
2611
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
2612
- target[prop] = source[prop];
2613
- }
2614
- return target;
2615
- };
2616
- function AntdModal(props) {
2617
- const _a = props, { onOpenChange, onOk, onCancel, open, footer } = _a, rest = __objRest$4(_a, ["onOpenChange", "onOk", "onCancel", "open", "footer"]);
2618
- const memoOnOk = React__default.default.useMemo(() => {
2619
- if (onOpenChange || onOk) {
2620
- return (e) => {
2621
- onOpenChange == null ? void 0 : onOpenChange(false);
2622
- onOk == null ? void 0 : onOk(e);
2623
- };
2624
- } else {
2625
- return void 0;
2950
+ function deriveValuePropName(props) {
2951
+ if (props.valuePropName) {
2952
+ return props.valuePropName;
2953
+ }
2954
+ const valueProps = React__default.default.Children.map(props.children, (child) => {
2955
+ var _a;
2956
+ if (React__default.default.isValidElement(child)) {
2957
+ const childType = child.type;
2958
+ if (childType) {
2959
+ const x = (_a = childType.__plasmicFormFieldMeta) == null ? void 0 : _a.valueProp;
2960
+ if (x) {
2961
+ return x;
2962
+ }
2963
+ const plumeType = childType.__plumeType;
2964
+ if (plumeType && (plumeType === "checkbox" || plumeType === "switch")) {
2965
+ return "isChecked";
2966
+ }
2967
+ }
2626
2968
  }
2627
- }, [onOpenChange, onOk]);
2628
- const memoOnCancel = React__default.default.useMemo(() => {
2629
- if (onOpenChange || onCancel) {
2630
- return (e) => {
2631
- onOpenChange == null ? void 0 : onOpenChange(false);
2632
- onCancel == null ? void 0 : onCancel(e);
2633
- };
2634
- } else {
2635
- return void 0;
2969
+ return void 0;
2970
+ }).filter((x) => !!x);
2971
+ if (valueProps.length > 0) {
2972
+ return valueProps[0];
2973
+ }
2974
+ return void 0;
2975
+ }
2976
+ function FormItemForwarder(_a) {
2977
+ var _b = _a, { formItemProps } = _b, props = __objRest$3(_b, ["formItemProps"]);
2978
+ var _a2;
2979
+ const status = antd.Form.Item.useStatus();
2980
+ const internalFormCtx = React__default.default.useContext(InternalFormInstanceContext);
2981
+ const data = {
2982
+ status: status.status
2983
+ };
2984
+ (_a2 = props.setControlContextData) == null ? void 0 : _a2.call(props, {
2985
+ internalFormCtx,
2986
+ status
2987
+ });
2988
+ return React__default.default.Children.map(formItemProps.children, (child, i) => {
2989
+ var _a3;
2990
+ let newProps = __spreadProps$2(__spreadValues$3(__spreadValues$3({}, (_a3 = child.props) != null ? _a3 : {}), props), {
2991
+ __plasmicFormField: true
2992
+ });
2993
+ if (formItemProps.customizeProps) {
2994
+ newProps = mergeProps(
2995
+ newProps,
2996
+ formItemProps.customizeProps(data, newProps)
2997
+ );
2636
2998
  }
2637
- }, [onOpenChange, onCancel]);
2638
- return /* @__PURE__ */ React__default.default.createElement(
2639
- antd.Modal,
2640
- __spreadProps$3(__spreadValues$4({}, rest), {
2641
- onOk: memoOnOk,
2642
- onCancel: memoOnCancel,
2643
- open,
2644
- footer: footer != null ? footer : void 0
2645
- })
2646
- );
2999
+ return i === 0 && React.isValidElement(child) ? React.cloneElement(child, newProps) : child;
3000
+ });
2647
3001
  }
2648
- function registerModal(loader) {
2649
- registerComponentHelper(loader, AntdModal, {
2650
- name: "plasmic-antd5-modal",
2651
- displayName: "Modal",
2652
- props: {
2653
- open: {
2654
- type: "boolean"
2655
- },
2656
- children: {
2657
- type: "slot",
2658
- defaultValue: {
2659
- type: "vbox",
2660
- children: ["Modal content"]
3002
+ const commonFormItemProps = {
3003
+ name: {
3004
+ type: "string"
3005
+ },
3006
+ initialValue: {
3007
+ type: "string"
3008
+ },
3009
+ rules: {
3010
+ type: "formValidationRules"
3011
+ },
3012
+ valuePropName: {
3013
+ type: "string",
3014
+ advanced: true,
3015
+ defaultValueHint: "value",
3016
+ description: "The prop name for specifying the value of the form control component"
3017
+ },
3018
+ noLabel: {
3019
+ type: "boolean",
3020
+ advanced: true
3021
+ },
3022
+ alignLabellessWithControls: {
3023
+ type: "boolean",
3024
+ displayName: "Align with controls?",
3025
+ description: "Aligns the content with form controls in the grid",
3026
+ hidden: (ps, ctx) => {
3027
+ var _a;
3028
+ return !ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
3029
+ },
3030
+ defaultValueHint: true
3031
+ },
3032
+ colon: {
3033
+ type: "boolean",
3034
+ defaultValueHint: true,
3035
+ advanced: true,
3036
+ hidden: () => true
3037
+ },
3038
+ labelAlign: {
3039
+ type: "choice",
3040
+ options: ["left", "right"],
3041
+ advanced: true,
3042
+ hidden: (ps, ctx) => {
3043
+ var _a;
3044
+ return !!ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
3045
+ }
3046
+ },
3047
+ hidden: {
3048
+ type: "boolean",
3049
+ advanced: true
3050
+ },
3051
+ validateTrigger: {
3052
+ type: "choice",
3053
+ options: ["onSubmit", "onChange", "onBlur"],
3054
+ multiSelect: true,
3055
+ advanced: true
3056
+ },
3057
+ shouldUpdate: {
3058
+ type: "boolean",
3059
+ advanced: true,
3060
+ displayName: "Always re-render",
3061
+ description: "Form items normally only re-render when the corresponding form value changes, for performance. This forces it to always re-render."
3062
+ },
3063
+ dependencies: {
3064
+ type: "array",
3065
+ advanced: true,
3066
+ displayName: "Dependencies",
3067
+ description: "Form items can depend on other form items. This forces it to reevaluate the validation rules when the other form item changes."
3068
+ },
3069
+ hideValidationMessage: {
3070
+ type: "boolean",
3071
+ displayName: "Hide validation message?",
3072
+ description: "If true, will hide the validation error message",
3073
+ defaultValueHint: false,
3074
+ advanced: true
3075
+ },
3076
+ customizeProps: {
3077
+ type: "function",
3078
+ description: "Customize the props passed into the wrapped field component. Takes the current status ('success', 'warning', 'error', or 'validating').)",
3079
+ argNames: ["fieldData"],
3080
+ argValues: (_ps, ctx) => {
3081
+ var _a;
3082
+ return [
3083
+ {
3084
+ status: (_a = ctx == null ? void 0 : ctx.status) == null ? void 0 : _a.status
2661
3085
  }
2662
- },
2663
- title: {
2664
- type: "slot",
2665
- defaultValue: "Modal title"
2666
- },
2667
- footer: {
3086
+ ];
3087
+ },
3088
+ advanced: true
3089
+ },
3090
+ noStyle: {
3091
+ type: "boolean",
3092
+ displayName: "Field control only",
3093
+ description: "Don't render anything but the field control - so no label, help text, validation error, etc.",
3094
+ advanced: true
3095
+ }
3096
+ };
3097
+ const formItemComponentName = "plasmic-antd5-form-item";
3098
+ function registerFormItem(loader) {
3099
+ registerComponentHelper(loader, FormItemWrapper, __spreadValues$3({
3100
+ name: formItemComponentName,
3101
+ displayName: "Form Field",
3102
+ parentComponentName: formComponentName,
3103
+ defaultStyles: {
3104
+ marginBottom: "24px",
3105
+ width: "stretch"
3106
+ },
3107
+ props: __spreadValues$3({
3108
+ label: __spreadValues$3({
2668
3109
  type: "slot",
2669
- hidePlaceholder: true
2670
- },
2671
- closeIcon: {
3110
+ defaultValue: {
3111
+ type: "text",
3112
+ value: "Label"
3113
+ },
3114
+ hidden: (ps) => !!ps.noLabel
3115
+ }, { mergeWithParent: true }),
3116
+ children: __spreadValues$3({
2672
3117
  type: "slot",
2673
- hidePlaceholder: true
2674
- },
2675
- onOk: {
2676
- type: "eventHandler",
2677
- argTypes: []
3118
+ defaultValue: {
3119
+ type: "component",
3120
+ name: inputComponentName
3121
+ }
3122
+ }, { mergeWithParent: true })
3123
+ }, commonFormItemProps),
3124
+ importPath: "@plasmicpkgs/antd5/skinny/registerForm",
3125
+ importName: "FormItemWrapper",
3126
+ templates: {
3127
+ Text: {
3128
+ props: {
3129
+ children: {
3130
+ type: "component",
3131
+ name: inputComponentName
3132
+ }
3133
+ }
2678
3134
  },
2679
- onCancel: {
2680
- type: "eventHandler",
2681
- argTypes: []
3135
+ "Long Text": {
3136
+ props: {
3137
+ children: {
3138
+ type: "component",
3139
+ name: textAreaComponentName
3140
+ }
3141
+ }
2682
3142
  },
2683
- okText: {
2684
- type: "string",
2685
- hidden: (ps) => !!ps.footer,
2686
- advanced: true
3143
+ "Select dropdown": {
3144
+ props: {
3145
+ children: {
3146
+ type: "component",
3147
+ name: selectComponentName
3148
+ }
3149
+ }
2687
3150
  },
2688
- cancelText: {
2689
- type: "string",
2690
- hidden: (ps) => !!ps.footer,
2691
- advanced: true
3151
+ Number: {
3152
+ props: {
3153
+ children: {
3154
+ type: "component",
3155
+ name: inputNumberComponentName
3156
+ }
3157
+ }
2692
3158
  },
2693
- onOpenChange: {
2694
- type: "eventHandler",
2695
- argTypes: [{ name: "open", type: "boolean" }]
3159
+ Checkbox: {
3160
+ props: {
3161
+ children: {
3162
+ type: "component",
3163
+ name: checkboxComponentName
3164
+ },
3165
+ noLabel: true
3166
+ }
2696
3167
  },
2697
- modalScopeClassName: {
2698
- type: "styleScopeClass",
2699
- scopeName: "modal"
3168
+ Switch: {
3169
+ props: {
3170
+ children: {
3171
+ type: "component",
3172
+ name: switchComponentName
3173
+ },
3174
+ noLabel: true
3175
+ }
2700
3176
  },
2701
- modalClassName: {
2702
- type: "class",
2703
- displayName: "Modal content styles",
2704
- noSelf: true,
2705
- selectors: [
2706
- {
2707
- selector: ":modal .ant-modal .ant-modal-content",
2708
- label: "Base"
3177
+ Radios: {
3178
+ props: {
3179
+ children: {
3180
+ type: "component",
3181
+ name: radioGroupComponentName
2709
3182
  }
2710
- ],
2711
- advanced: true
3183
+ }
2712
3184
  },
2713
- closeButtonClassName: {
2714
- type: "class",
2715
- displayName: "Close button styles",
2716
- noSelf: true,
2717
- selectors: [
2718
- {
2719
- selector: ":modal .ant-modal .ant-modal-close",
2720
- label: "Base"
3185
+ Password: {
3186
+ props: {
3187
+ children: {
3188
+ type: "component",
3189
+ name: passwordComponentName
2721
3190
  }
2722
- ],
2723
- advanced: true
3191
+ }
2724
3192
  },
2725
- defaultStylesClassName: {
2726
- type: "themeResetClass"
3193
+ "Submit button": {
3194
+ props: {
3195
+ children: {
3196
+ type: "component",
3197
+ name: buttonComponentName,
3198
+ props: {
3199
+ type: "primary"
3200
+ }
3201
+ },
3202
+ noLabel: true
3203
+ }
3204
+ }
3205
+ }
3206
+ }, { trapsSelection: true }));
3207
+ }
3208
+ function FormGroup(props) {
3209
+ const pathCtx = React__default.default.useContext(PathContext);
3210
+ return /* @__PURE__ */ React__default.default.createElement(
3211
+ PathContext.Provider,
3212
+ {
3213
+ value: {
3214
+ relativePath: [...pathCtx.relativePath, props.name],
3215
+ fullPath: [...pathCtx.fullPath, props.name]
2727
3216
  }
2728
3217
  },
2729
- states: {
2730
- open: {
2731
- type: "writable",
2732
- valueProp: "open",
2733
- onChangeProp: "onOpenChange",
2734
- variableType: "boolean"
3218
+ props.children
3219
+ );
3220
+ }
3221
+ const formGroupComponentName = "plasmic-antd5-form-group";
3222
+ function registerFormGroup(loader) {
3223
+ registerComponentHelper(loader, FormGroup, {
3224
+ name: formGroupComponentName,
3225
+ displayName: "Form Field Group",
3226
+ parentComponentName: formComponentName,
3227
+ actions: COMMON_ACTIONS,
3228
+ props: {
3229
+ name: {
3230
+ type: "string"
3231
+ },
3232
+ children: {
3233
+ type: "slot"
2735
3234
  }
2736
3235
  },
2737
- importPath: "@plasmicpkgs/antd5/skinny/registerModal",
2738
- importName: "AntdModal"
3236
+ importPath: "@plasmicpkgs/antd5/skinny/registerForm",
3237
+ importName: "FormGroup"
2739
3238
  });
2740
3239
  }
2741
-
2742
- var __defProp$3 = Object.defineProperty;
2743
- var __defProps$2 = Object.defineProperties;
2744
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2745
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2746
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2747
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
2748
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2749
- var __spreadValues$3 = (a, b) => {
2750
- for (var prop in b || (b = {}))
2751
- if (__hasOwnProp$3.call(b, prop))
2752
- __defNormalProp$3(a, prop, b[prop]);
2753
- if (__getOwnPropSymbols$3)
2754
- for (var prop of __getOwnPropSymbols$3(b)) {
2755
- if (__propIsEnum$3.call(b, prop))
2756
- __defNormalProp$3(a, prop, b[prop]);
2757
- }
2758
- return a;
2759
- };
2760
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
2761
- var __objRest$3 = (source, exclude) => {
2762
- var target = {};
2763
- for (var prop in source)
2764
- if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
2765
- target[prop] = source[prop];
2766
- if (source != null && __getOwnPropSymbols$3)
2767
- for (var prop of __getOwnPropSymbols$3(source)) {
2768
- if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
2769
- target[prop] = source[prop];
2770
- }
2771
- return target;
2772
- };
2773
- const RadioGroup = antd.Radio.Group;
2774
- const AntdRadio = antd.Radio;
2775
- antd.Radio.Button;
2776
- function AntdRadioGroup(props) {
2777
- const _a = props, { onChange, useChildren } = _a, rest = __objRest$3(_a, ["onChange", "useChildren"]);
2778
- const wrappedOnChange = React__default.default.useMemo(() => {
2779
- if (onChange) {
2780
- return (event) => onChange(event.target.value);
2781
- } else {
2782
- return void 0;
2783
- }
2784
- }, [onChange]);
2785
- return /* @__PURE__ */ React__default.default.createElement(
2786
- RadioGroup,
2787
- __spreadProps$2(__spreadValues$3({}, rest), {
2788
- onChange: wrappedOnChange,
2789
- options: useChildren ? void 0 : rest.options
2790
- })
3240
+ const FormListWrapper = React__default.default.forwardRef(function FormListWrapper2(props, ref) {
3241
+ var _a;
3242
+ const relativeFormItemName = useFormItemRelativeName(props.name);
3243
+ const fullFormItemName = useFormItemFullName(props.name);
3244
+ const operationsRef = React__default.default.useRef(
3245
+ void 0
2791
3246
  );
2792
- }
2793
- function registerRadio(loader) {
2794
- registerComponentHelper(loader, AntdRadio, {
2795
- name: "plasmic-antd5-radio",
2796
- displayName: "Radio",
2797
- props: {
2798
- value: {
2799
- type: "string",
2800
- description: "The radio option value"
3247
+ React__default.default.useImperativeHandle(
3248
+ ref,
3249
+ () => ({
3250
+ add(defaultValue, insertIndex) {
3251
+ if (operationsRef.current) {
3252
+ const { add } = operationsRef.current[1];
3253
+ add(defaultValue, insertIndex);
3254
+ }
2801
3255
  },
2802
- disabled: {
2803
- type: "boolean",
2804
- defaultValueHint: false
3256
+ remove(index) {
3257
+ if (operationsRef.current) {
3258
+ const { remove } = operationsRef.current[1];
3259
+ remove(index);
3260
+ }
2805
3261
  },
2806
- autoFocus: {
2807
- type: "boolean",
2808
- description: "If focused when first shown",
2809
- defaultValueHint: false,
2810
- advanced: true
3262
+ move(from, to) {
3263
+ if (operationsRef.current) {
3264
+ const { move } = operationsRef.current[1];
3265
+ move(from, to);
3266
+ }
3267
+ }
3268
+ }),
3269
+ [operationsRef]
3270
+ );
3271
+ const inCanvas = !!host.usePlasmicCanvasContext();
3272
+ if (inCanvas) {
3273
+ const form = useFormInstanceMaybe();
3274
+ const prevPropValues = React__default.default.useRef({
3275
+ initialValue: props.initialValue,
3276
+ name: props.name
3277
+ });
3278
+ const { fireOnValuesChange, forceRemount } = (_a = React__default.default.useContext(InternalFormInstanceContext)) != null ? _a : {};
3279
+ React__default.default.useEffect(() => {
3280
+ if (prevPropValues.current.name !== props.name) {
3281
+ forceRemount == null ? void 0 : forceRemount();
3282
+ }
3283
+ if (fullFormItemName) {
3284
+ form == null ? void 0 : form.setFieldValue(fullFormItemName, props.initialValue);
3285
+ prevPropValues.current.initialValue = props.initialValue;
3286
+ fireOnValuesChange == null ? void 0 : fireOnValuesChange();
3287
+ }
3288
+ }, [props.initialValue, fullFormItemName]);
3289
+ }
3290
+ return /* @__PURE__ */ React__default.default.createElement(FormList, __spreadProps$2(__spreadValues$3({}, props), { name: relativeFormItemName != null ? relativeFormItemName : [] }), (...args) => {
3291
+ operationsRef.current = args;
3292
+ return args[0].map((field, index) => /* @__PURE__ */ React__default.default.createElement(
3293
+ PathContext.Provider,
3294
+ {
3295
+ value: {
3296
+ relativePath: [field.name],
3297
+ fullPath: [...fullFormItemName != null ? fullFormItemName : [], field.name]
3298
+ }
2811
3299
  },
2812
- children: __spreadValues$3({
3300
+ /* @__PURE__ */ React__default.default.createElement(host.DataProvider, { name: "currentField", data: field }, /* @__PURE__ */ React__default.default.createElement(host.DataProvider, { name: "currentFieldIndex", data: index }, host.repeatedElement(index, props.children)))
3301
+ ));
3302
+ });
3303
+ });
3304
+ const formListComponentName = "plasmic-antd5-form-list";
3305
+ function registerFormList(loader) {
3306
+ registerComponentHelper(loader, FormListWrapper, {
3307
+ name: formListComponentName,
3308
+ parentComponentName: formComponentName,
3309
+ displayName: "Form List",
3310
+ actions: COMMON_ACTIONS,
3311
+ props: {
3312
+ children: {
2813
3313
  type: "slot",
2814
3314
  defaultValue: [
2815
3315
  {
2816
- type: "text",
2817
- value: "Radio"
2818
- }
2819
- ]
2820
- }, { mergeWithParent: true })
2821
- },
2822
- importPath: "@plasmicpkgs/antd5/skinny/registerRadio",
2823
- importName: "AntdRadio",
2824
- parentComponentName: "plasmic-antd5-radio-group"
2825
- });
2826
- registerComponentHelper(loader, AntdRadio, {
2827
- name: "plasmic-antd5-radio-button",
2828
- displayName: "Radio Button",
2829
- props: {
2830
- value: {
2831
- type: "string",
2832
- description: "The radio option value"
2833
- },
2834
- disabled: {
2835
- type: "boolean",
2836
- defaultValueHint: false
3316
+ type: "hbox",
3317
+ children: [
3318
+ {
3319
+ type: "component",
3320
+ name: formItemComponentName,
3321
+ props: {
3322
+ name: "firstName",
3323
+ label: {
3324
+ type: "text",
3325
+ value: "First name"
3326
+ },
3327
+ children: {
3328
+ type: "component",
3329
+ name: "plasmic-antd5-input"
3330
+ }
3331
+ }
3332
+ },
3333
+ {
3334
+ type: "component",
3335
+ name: formItemComponentName,
3336
+ props: {
3337
+ name: "lastName",
3338
+ label: {
3339
+ type: "text",
3340
+ value: "Last name"
3341
+ },
3342
+ children: {
3343
+ type: "component",
3344
+ name: "plasmic-antd5-input"
3345
+ }
3346
+ }
3347
+ }
3348
+ ]
3349
+ }
3350
+ ]
2837
3351
  },
2838
- autoFocus: {
2839
- type: "boolean",
2840
- description: "If focused when first shown",
2841
- defaultValueHint: false,
2842
- advanced: true
3352
+ name: {
3353
+ type: "string",
3354
+ defaultValue: "guests"
2843
3355
  },
2844
- children: __spreadValues$3({
2845
- type: "slot",
3356
+ initialValue: {
3357
+ type: "array",
2846
3358
  defaultValue: [
2847
3359
  {
2848
- type: "text",
2849
- value: "Radio"
3360
+ firstName: "Jane",
3361
+ lastName: "Doe"
3362
+ },
3363
+ {
3364
+ firstName: "John",
3365
+ lastName: "Smith"
2850
3366
  }
2851
3367
  ]
2852
- }, { mergeWithParent: true })
3368
+ }
2853
3369
  },
2854
- importPath: "@plasmicpkgs/antd5/skinny/registerRadio",
2855
- importName: "AntdRadioButton",
2856
- parentComponentName: "plasmic-antd5-radio-group"
2857
- });
2858
- registerComponentHelper(loader, AntdRadioGroup, __spreadValues$3({
2859
- name: "plasmic-antd5-radio-group",
2860
- displayName: "Radio Group",
2861
- props: {
2862
- options: {
2863
- type: "array",
2864
- hidden: (ps) => !!ps.useChildren,
2865
- itemType: {
2866
- type: "object",
2867
- nameFunc: (item) => item.label || item.value,
2868
- fields: {
2869
- value: "string",
2870
- label: "string"
2871
- }
2872
- },
2873
- defaultValue: [
3370
+ refActions: {
3371
+ add: {
3372
+ displayName: "Add an item",
3373
+ argTypes: [
2874
3374
  {
2875
- value: "option1",
2876
- label: "Option 1"
3375
+ name: "defaultValue",
3376
+ displayName: "Default value",
3377
+ type: "object"
2877
3378
  },
2878
3379
  {
2879
- value: "option2",
2880
- label: "Option 2"
3380
+ name: "insertIndex",
3381
+ displayName: "Insert index",
3382
+ type: "number"
2881
3383
  }
2882
3384
  ]
2883
3385
  },
2884
- optionType: {
2885
- type: "choice",
2886
- options: [
2887
- { value: "default", label: "Radio" },
2888
- { value: "button", label: "Button" }
2889
- ],
2890
- hidden: (ps) => !!ps.useChildren,
2891
- defaultValueHint: "default"
2892
- },
2893
- value: {
2894
- type: "choice",
2895
- editOnly: true,
2896
- uncontrolledProp: "defaultValue",
2897
- description: "Default selected value",
2898
- options: (ps) => {
2899
- var _a;
2900
- if (ps.useChildren) {
2901
- const options = /* @__PURE__ */ new Set();
2902
- traverseReactEltTree(ps.children, (elt) => {
2903
- var _a2;
2904
- if (typeof ((_a2 = elt == null ? void 0 : elt.props) == null ? void 0 : _a2.value) === "string") {
2905
- options.add(elt.props.value);
2906
- }
2907
- });
2908
- return Array.from(options.keys());
2909
- } else {
2910
- return (_a = ps.options) != null ? _a : [];
3386
+ remove: {
3387
+ displayName: "Remove an item",
3388
+ argTypes: [
3389
+ {
3390
+ name: "index",
3391
+ displayName: "Index",
3392
+ type: "number"
2911
3393
  }
2912
- }
2913
- },
2914
- disabled: {
2915
- type: "boolean",
2916
- description: "Disables all radios",
2917
- defaultValueHint: false
2918
- },
2919
- useChildren: {
2920
- displayName: "Use slot",
2921
- type: "boolean",
2922
- defaultValueHint: false,
2923
- advanced: true,
2924
- description: "Instead of configuring a list of options, customize the contents of the RadioGroup by dragging and dropping Radio in the outline/canvas, inside the 'children' slot. Lets you use any content or formatting within the Radio and RadioButton."
3394
+ ]
2925
3395
  },
2926
- children: {
2927
- type: "slot",
2928
- allowedComponents: [
2929
- "plasmic-antd5-radio",
2930
- "plasmic-antd5-radio-button"
2931
- ],
2932
- defaultValue: [
3396
+ move: {
3397
+ displayName: "Move field",
3398
+ argTypes: [
2933
3399
  {
2934
- type: "component",
2935
- name: "plasmic-antd5-radio",
2936
- props: {
2937
- value: "op1",
2938
- children: {
2939
- type: "text",
2940
- value: "Option 1"
2941
- }
2942
- }
3400
+ name: "from",
3401
+ displayName: "From",
3402
+ type: "number"
2943
3403
  },
2944
3404
  {
2945
- type: "component",
2946
- name: "plasmic-antd5-radio",
2947
- props: {
2948
- value: "op2",
2949
- children: {
2950
- type: "text",
2951
- value: "Option 2"
2952
- }
2953
- }
3405
+ name: "to",
3406
+ displayName: "To",
3407
+ type: "number"
2954
3408
  }
2955
3409
  ]
2956
- },
2957
- onChange: {
2958
- type: "eventHandler",
2959
- argTypes: [{ name: "value", type: "string" }]
2960
- }
2961
- },
2962
- states: {
2963
- value: {
2964
- type: "writable",
2965
- valueProp: "value",
2966
- onChangeProp: "onChange",
2967
- variableType: "text"
2968
3410
  }
2969
3411
  },
2970
- importPath: "@plasmicpkgs/antd5/skinny/registerRadio",
2971
- importName: "AntdRadioGroup",
2972
- defaultStyles: {
2973
- layout: "hbox"
2974
- }
2975
- }, {
2976
- trapsSelection: true
2977
- }));
3412
+ importPath: "@plasmicpkgs/antd5/skinny/registerForm",
3413
+ importName: "FormListWrapper"
3414
+ });
2978
3415
  }
2979
3416
 
2980
3417
  var __defProp$2 = Object.defineProperty;
@@ -3007,248 +3444,111 @@ var __objRest$2 = (source, exclude) => {
3007
3444
  target[prop] = source[prop];
3008
3445
  }
3009
3446
  return target;
3010
- };
3011
- const AntdOption = antd.Select.Option;
3012
- const AntdOptionGroup = antd.Select.OptGroup;
3013
- function AntdSelect(props) {
3014
- const _a = props, {
3015
- popupClassName,
3016
- popupScopeClassName,
3017
- defaultStylesClassName,
3018
- suffixIcon,
3019
- mode,
3020
- useChildren
3021
- } = _a, rest = __objRest$2(_a, [
3022
- "popupClassName",
3023
- "popupScopeClassName",
3024
- "defaultStylesClassName",
3025
- "suffixIcon",
3026
- "mode",
3027
- "useChildren"
3028
- ]);
3029
- const curated = __spreadValues$2({}, rest);
3030
- if (useChildren) {
3031
- curated.options = void 0;
3032
- }
3033
- return /* @__PURE__ */ React__default.default.createElement(
3034
- antd.Select,
3035
- __spreadValues$2(__spreadProps$1(__spreadValues$2({}, curated), {
3036
- mode: !mode || mode === "single" ? void 0 : mode,
3037
- popupClassName: `${defaultStylesClassName} ${popupScopeClassName} ${popupClassName}`
3038
- }), suffixIcon && { suffixIcon })
3039
- );
3040
- }
3041
- function registerSelect(loader) {
3042
- registerComponentHelper(loader, AntdSelect, __spreadProps$1(__spreadValues$2({
3043
- name: "plasmic-antd5-select",
3044
- displayName: "Select",
3045
- props: {
3046
- options: {
3047
- type: "array",
3048
- hidden: (ps) => !!ps.useChildren,
3049
- itemType: {
3050
- type: "object",
3051
- nameFunc: (item) => item.label || item.value,
3052
- fields: {
3053
- type: {
3054
- type: "choice",
3055
- options: [
3056
- { value: "option", label: "Option" },
3057
- { value: "option-group", label: "Option Group" }
3058
- ],
3059
- defaultValue: "option"
3060
- },
3061
- value: {
3062
- type: "string",
3063
- hidden: (ps) => ps.type !== "option"
3064
- },
3065
- label: "string",
3066
- options: {
3067
- type: "array",
3068
- hidden: (ps) => {
3069
- return ps.type !== "option-group";
3070
- },
3071
- itemType: {
3072
- type: "object",
3073
- nameFunc: (item) => item.label || item.value,
3074
- fields: {
3075
- value: "string",
3076
- label: "string"
3077
- }
3078
- }
3079
- }
3080
- }
3081
- },
3082
- defaultValue: [
3083
- {
3084
- value: "option1",
3085
- label: "Option 1"
3086
- },
3087
- {
3088
- value: "option2",
3089
- label: "Option 2"
3090
- }
3091
- ]
3092
- },
3093
- useChildren: {
3094
- displayName: "Use slot",
3095
- type: "boolean",
3096
- defaultValueHint: false,
3097
- advanced: true,
3098
- description: "Instead of configuring a list of options, customize the contents of the Select by dragging and dropping options in the outline/canvas, inside the 'children' slot. Lets you use any content or formatting within the Options, and also use Option Groups."
3447
+ };
3448
+ function AntdModal(props) {
3449
+ const _a = props, { onOpenChange, onOk, onCancel, open, footer } = _a, rest = __objRest$2(_a, ["onOpenChange", "onOk", "onCancel", "open", "footer"]);
3450
+ const memoOnOk = React__default.default.useMemo(() => {
3451
+ if (onOpenChange || onOk) {
3452
+ return (e) => {
3453
+ onOpenChange == null ? void 0 : onOpenChange(false);
3454
+ onOk == null ? void 0 : onOk(e);
3455
+ };
3456
+ } else {
3457
+ return void 0;
3458
+ }
3459
+ }, [onOpenChange, onOk]);
3460
+ const memoOnCancel = React__default.default.useMemo(() => {
3461
+ if (onOpenChange || onCancel) {
3462
+ return (e) => {
3463
+ onOpenChange == null ? void 0 : onOpenChange(false);
3464
+ onCancel == null ? void 0 : onCancel(e);
3465
+ };
3466
+ } else {
3467
+ return void 0;
3468
+ }
3469
+ }, [onOpenChange, onCancel]);
3470
+ return /* @__PURE__ */ React__default.default.createElement(
3471
+ antd.Modal,
3472
+ __spreadProps$1(__spreadValues$2({}, rest), {
3473
+ onOk: memoOnOk,
3474
+ onCancel: memoOnCancel,
3475
+ open,
3476
+ footer: footer != null ? footer : void 0
3477
+ })
3478
+ );
3479
+ }
3480
+ function registerModal(loader) {
3481
+ registerComponentHelper(loader, AntdModal, {
3482
+ name: "plasmic-antd5-modal",
3483
+ displayName: "Modal",
3484
+ props: {
3485
+ open: {
3486
+ type: "boolean"
3099
3487
  },
3100
3488
  children: {
3101
3489
  type: "slot",
3102
- allowedComponents: [
3103
- "plasmic-antd5-option",
3104
- "plasmic-antd5-option-group"
3105
- ],
3106
- hidden: (ps) => !ps.useChildren
3490
+ defaultValue: {
3491
+ type: "vbox",
3492
+ children: ["Modal content"]
3493
+ }
3107
3494
  },
3108
- placeholder: {
3495
+ title: {
3109
3496
  type: "slot",
3110
- defaultValue: "Select..."
3497
+ defaultValue: "Modal title"
3111
3498
  },
3112
- suffixIcon: {
3499
+ footer: {
3113
3500
  type: "slot",
3114
3501
  hidePlaceholder: true
3115
3502
  },
3116
- open: {
3117
- type: "boolean",
3118
- editOnly: true,
3119
- uncontrolledProp: "defaultOpen"
3120
- },
3121
- value: {
3122
- type: "choice",
3123
- displayName: "Selected value",
3124
- editOnly: true,
3125
- uncontrolledProp: "defaultValue",
3126
- description: "Initial selected option",
3127
- multiSelect: (ps) => ps.mode === "multiple",
3128
- options: (ps) => {
3129
- var _a;
3130
- const options = /* @__PURE__ */ new Set();
3131
- if (!ps.useChildren) {
3132
- const rec = (op) => {
3133
- var _a2;
3134
- if (typeof op === "string") {
3135
- return [{ value: op, label: op }];
3136
- } else if ("options" in op) {
3137
- return ((_a2 = op.options) != null ? _a2 : []).flatMap((sub) => rec(sub));
3138
- } else {
3139
- return [{ value: op.value, label: op.label || op.value }];
3140
- }
3141
- };
3142
- return ((_a = ps.options) != null ? _a : []).flatMap((o) => rec(o));
3143
- } else {
3144
- traverseReactEltTree(ps.children, (elt) => {
3145
- var _a2;
3146
- if ((elt == null ? void 0 : elt.type) === antd.Select.Option && typeof ((_a2 = elt == null ? void 0 : elt.props) == null ? void 0 : _a2.value) === "string") {
3147
- options.add(elt.props.value);
3148
- }
3149
- });
3150
- }
3151
- return Array.from(options.keys());
3152
- }
3153
- },
3154
- mode: {
3155
- type: "choice",
3156
- options: ["single", "multiple"],
3157
- defaultValueHint: "single"
3158
- },
3159
- size: {
3160
- type: "choice",
3161
- options: ["small", "middle", "large"]
3503
+ closeIcon: {
3504
+ type: "slot",
3505
+ hidePlaceholder: true
3162
3506
  },
3163
- disabled: {
3164
- type: "boolean",
3165
- defaultValueHint: false
3507
+ onOk: {
3508
+ type: "eventHandler",
3509
+ argTypes: []
3166
3510
  },
3167
- showSearch: {
3168
- type: "boolean",
3169
- defaultValueHint: false,
3170
- advanced: true
3511
+ onCancel: {
3512
+ type: "eventHandler",
3513
+ argTypes: []
3171
3514
  },
3172
- status: {
3173
- type: "choice",
3174
- options: ["error", "warning"],
3515
+ okText: {
3516
+ type: "string",
3517
+ hidden: (ps) => !!ps.footer,
3175
3518
  advanced: true
3176
3519
  },
3177
- bordered: {
3178
- type: "boolean",
3179
- defaultValueHint: true
3180
- },
3181
- autoFocus: {
3182
- type: "boolean",
3183
- displayName: "Focus automatically",
3184
- defaultValueHint: false,
3520
+ cancelText: {
3521
+ type: "string",
3522
+ hidden: (ps) => !!ps.footer,
3185
3523
  advanced: true
3186
3524
  },
3187
- onChange: {
3525
+ onOpenChange: {
3188
3526
  type: "eventHandler",
3189
- argTypes: [
3190
- { name: "value", type: "string" },
3191
- { name: "option", type: "object" }
3192
- ]
3193
- },
3194
- dropdownMatchSelectWidth: {
3195
- type: "boolean",
3196
- displayName: "Should dropdown match trigger button width?",
3197
- defaultValueHint: true,
3198
- advanced: true
3199
- },
3200
- triggerClassName: {
3201
- type: "class",
3202
- displayName: "Trigger styles",
3203
- noSelf: true,
3204
- selectors: [
3205
- {
3206
- selector: ":component .ant-select-selector.ant-select-selector",
3207
- label: "Base"
3208
- },
3209
- {
3210
- selector: ":component .ant-select-selector:hover",
3211
- label: "Hovered"
3212
- }
3213
- ],
3214
- advanced: true
3527
+ argTypes: [{ name: "open", type: "boolean" }]
3215
3528
  },
3216
- popupScopeClassName: {
3529
+ modalScopeClassName: {
3217
3530
  type: "styleScopeClass",
3218
- scopeName: "popup"
3219
- },
3220
- popupClassName: {
3221
- type: "class",
3222
- displayName: "Popup styles",
3223
- selectors: [],
3224
- advanced: true
3531
+ scopeName: "modal"
3225
3532
  },
3226
- optionClassName: {
3533
+ modalClassName: {
3227
3534
  type: "class",
3228
- displayName: "Option styles",
3535
+ displayName: "Modal content styles",
3229
3536
  noSelf: true,
3230
3537
  selectors: [
3231
3538
  {
3232
- selector: ":popup.ant-select-dropdown .ant-select-item-option",
3539
+ selector: ":modal .ant-modal .ant-modal-content",
3233
3540
  label: "Base"
3234
- },
3235
- {
3236
- selector: ":popup.ant-select-dropdown .ant-select-item-option-active",
3237
- label: "Focused"
3238
- },
3239
- {
3240
- selector: ":popup.ant-select-dropdown .ant-select-item-option-selected",
3241
- label: "Selected"
3242
3541
  }
3243
3542
  ],
3244
3543
  advanced: true
3245
3544
  },
3246
- placeholderClassName: {
3545
+ closeButtonClassName: {
3247
3546
  type: "class",
3248
- displayName: "Placeholder styles",
3547
+ displayName: "Close button styles",
3548
+ noSelf: true,
3249
3549
  selectors: [
3250
3550
  {
3251
- selector: ":component .ant-select-selector .ant-select-selection-placeholder",
3551
+ selector: ":modal .ant-modal .ant-modal-close",
3252
3552
  label: "Base"
3253
3553
  }
3254
3554
  ],
@@ -3259,72 +3559,15 @@ function registerSelect(loader) {
3259
3559
  }
3260
3560
  },
3261
3561
  states: {
3262
- value: {
3562
+ open: {
3263
3563
  type: "writable",
3264
- valueProp: "value",
3265
- onChangeProp: "onChange",
3266
- variableType: "text"
3267
- }
3268
- }
3269
- }, { trapsSelection: true }), {
3270
- importPath: "@plasmicpkgs/antd5/skinny/registerSelect",
3271
- importName: "AntdSelect"
3272
- }));
3273
- registerComponentHelper(loader, AntdOption, {
3274
- name: "plasmic-antd5-option",
3275
- displayName: "Option",
3276
- parentComponentName: "plasmic-antd5-select",
3277
- props: {
3278
- children: __spreadValues$2({
3279
- type: "slot",
3280
- defaultValue: "Option"
3281
- }, { mergeWithParent: true }),
3282
- value: {
3283
- type: "string"
3284
- }
3285
- },
3286
- importPath: "@plasmicpkgs/antd5/skinny/registerSelect",
3287
- importName: "AntdOption"
3288
- });
3289
- registerComponentHelper(loader, AntdOptionGroup, {
3290
- name: "plasmic-antd5-option-group",
3291
- displayName: "Option Group",
3292
- parentComponentName: "plasmic-antd5-select",
3293
- props: {
3294
- children: {
3295
- type: "slot",
3296
- defaultValue: [
3297
- {
3298
- type: "component",
3299
- name: "plasmic-antd5-option",
3300
- props: {
3301
- value: "option1",
3302
- children: {
3303
- type: "text",
3304
- value: "Option 1"
3305
- }
3306
- }
3307
- },
3308
- {
3309
- type: "component",
3310
- name: "plasmic-antd5-option",
3311
- props: {
3312
- value: "option2",
3313
- children: {
3314
- type: "text",
3315
- value: "Option 1"
3316
- }
3317
- }
3318
- }
3319
- ]
3320
- },
3321
- label: {
3322
- type: "slot",
3323
- defaultValue: "Group label"
3564
+ valueProp: "open",
3565
+ onChangeProp: "onOpenChange",
3566
+ variableType: "boolean"
3324
3567
  }
3325
3568
  },
3326
- importPath: "@plasmicpkgs/antd5/skinny/registerSelect",
3327
- importName: "AntdOptionGroup"
3569
+ importPath: "@plasmicpkgs/antd5/skinny/registerModal",
3570
+ importName: "AntdModal"
3328
3571
  });
3329
3572
  }
3330
3573
 
@@ -3786,6 +4029,7 @@ function registerAll(loader) {
3786
4029
  registerSelect(loader);
3787
4030
  registerTable(loader);
3788
4031
  registerCheckbox(loader);
4032
+ registerSwitch(loader);
3789
4033
  registerRadio(loader);
3790
4034
  registerModal(loader);
3791
4035
  registerButton(loader);
@@ -3801,6 +4045,29 @@ function registerAll(loader) {
3801
4045
  registerNumberInput(loader);
3802
4046
  registerUpload(loader);
3803
4047
  }
4048
+ const componentNameToInputType = {
4049
+ [inputComponentName]: InputType.Text,
4050
+ [textAreaComponentName]: InputType.TextArea,
4051
+ [passwordComponentName]: InputType.Password,
4052
+ [inputNumberComponentName]: InputType.Number,
4053
+ [selectComponentName]: InputType.Select,
4054
+ [optionComponentName]: InputType.Option,
4055
+ [optionGroupComponentName]: InputType.OptionGroup,
4056
+ [radioComponentName]: InputType.Radio,
4057
+ [radioGroupComponentName]: InputType.RadioGroup,
4058
+ [checkboxComponentName]: InputType.Checkbox
4059
+ };
4060
+ const inputTypeToComponentName = Object.fromEntries(
4061
+ Object.entries(componentNameToInputType).reverse()
4062
+ );
3804
4063
 
4064
+ exports.InputType = InputType;
4065
+ exports.buttonComponentName = buttonComponentName;
4066
+ exports.componentNameToInputType = componentNameToInputType;
4067
+ exports.formComponentName = formComponentName;
4068
+ exports.formGroupComponentName = formGroupComponentName;
4069
+ exports.formItemComponentName = formItemComponentName;
4070
+ exports.formListComponentName = formListComponentName;
4071
+ exports.inputTypeToComponentName = inputTypeToComponentName;
3805
4072
  exports.registerAll = registerAll;
3806
4073
  //# sourceMappingURL=index.js.map