@plasmicpkgs/antd5 0.0.54 → 0.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/antd.esm.js +250 -115
  3. package/dist/antd.esm.js.map +1 -1
  4. package/dist/index.js +250 -115
  5. package/dist/index.js.map +1 -1
  6. package/dist/registerForm.d.ts +9 -1
  7. package/package.json +2 -2
  8. package/skinny/registerButton.cjs.js +1 -1
  9. package/skinny/registerButton.esm.js +1 -1
  10. package/skinny/registerCheckbox.cjs.js +1 -1
  11. package/skinny/registerCheckbox.esm.js +1 -1
  12. package/skinny/registerConfigProvider.cjs.js +1 -1
  13. package/skinny/registerConfigProvider.esm.js +1 -1
  14. package/skinny/registerDropdown.cjs.js +1 -1
  15. package/skinny/registerDropdown.esm.js +1 -1
  16. package/skinny/registerForm.cjs.js +227 -97
  17. package/skinny/registerForm.cjs.js.map +1 -1
  18. package/skinny/registerForm.d.ts +9 -1
  19. package/skinny/registerForm.esm.js +227 -97
  20. package/skinny/registerForm.esm.js.map +1 -1
  21. package/skinny/registerInput.cjs.js +1 -1
  22. package/skinny/registerInput.esm.js +1 -1
  23. package/skinny/registerMenu.cjs.js +1 -1
  24. package/skinny/registerMenu.esm.js +1 -1
  25. package/skinny/registerModal.cjs.js +1 -1
  26. package/skinny/registerModal.esm.js +1 -1
  27. package/skinny/registerRadio.cjs.js +25 -8
  28. package/skinny/registerRadio.cjs.js.map +1 -1
  29. package/skinny/registerRadio.esm.js +25 -8
  30. package/skinny/registerRadio.esm.js.map +1 -1
  31. package/skinny/registerSelect.cjs.js +1 -1
  32. package/skinny/registerSelect.esm.js +1 -1
  33. package/skinny/registerTable.cjs.js +1 -1
  34. package/skinny/registerTable.esm.js +1 -1
  35. package/skinny/registerUpload.cjs.js +1 -1
  36. package/skinny/registerUpload.esm.js +1 -1
  37. package/skinny/{utils-dff55ae0.cjs.js → utils-2d964db8.cjs.js} +1 -14
  38. package/skinny/{utils-dff55ae0.cjs.js.map → utils-2d964db8.cjs.js.map} +1 -1
  39. package/skinny/{utils-94b1c934.esm.js → utils-d0e80a56.esm.js} +2 -14
  40. package/skinny/{utils-94b1c934.esm.js.map → utils-d0e80a56.esm.js.map} +1 -1
package/dist/antd.esm.js CHANGED
@@ -51,18 +51,6 @@ function asArray(x) {
51
51
  return [x];
52
52
  }
53
53
  }
54
- function omit(obj, ...keys) {
55
- if (Object.keys(obj).length === 0) {
56
- return obj;
57
- }
58
- const res = {};
59
- for (const key of Object.keys(obj)) {
60
- if (!keys.includes(key)) {
61
- res[key] = obj[key];
62
- }
63
- }
64
- return res;
65
- }
66
54
  function usePrevious(value) {
67
55
  const prevValue = React.useRef(void 0);
68
56
  React.useEffect(() => {
@@ -1148,8 +1136,9 @@ const FormItem = Form.Item;
1148
1136
  const FormList = Form.List;
1149
1137
  const PathContext = React.createContext({ relativePath: [], fullPath: [] });
1150
1138
  const InternalFormInstanceContext = React.createContext(void 0);
1139
+ const FormLayoutContext = React.createContext(void 0);
1151
1140
  const Internal = (props) => {
1152
- var _b, _c;
1141
+ var _b, _c, _d;
1153
1142
  const [form] = Form.useForm();
1154
1143
  const values = form.getFieldsValue(true);
1155
1144
  const lastValue = React.useRef(values);
@@ -1165,15 +1154,26 @@ const Internal = (props) => {
1165
1154
  React.useEffect(() => {
1166
1155
  fireOnValuesChange();
1167
1156
  }, []);
1157
+ const formLayout = React.useMemo(
1158
+ () => {
1159
+ var _a2;
1160
+ return {
1161
+ layout: props.layout,
1162
+ labelSpan: (_a2 = props.labelCol) == null ? void 0 : _a2.span
1163
+ };
1164
+ },
1165
+ [props.layout, (_b = props.labelCol) == null ? void 0 : _b.span]
1166
+ );
1168
1167
  return /* @__PURE__ */ React.createElement(
1169
1168
  InternalFormInstanceContext.Provider,
1170
1169
  {
1171
1170
  value: {
1171
+ layout: formLayout,
1172
1172
  fireOnValuesChange,
1173
1173
  forceRemount: () => setRemountKey((k) => k + 1)
1174
1174
  }
1175
1175
  },
1176
- /* @__PURE__ */ React.createElement(
1176
+ /* @__PURE__ */ React.createElement(FormLayoutContext.Provider, { value: formLayout }, /* @__PURE__ */ React.createElement(
1177
1177
  Form,
1178
1178
  __spreadProps$5(__spreadValues$6({}, rest), {
1179
1179
  key: props.initialValues ? JSON.stringify(props.initialValues) : void 0,
@@ -1183,16 +1183,16 @@ const Internal = (props) => {
1183
1183
  extendedOnValuesChange == null ? void 0 : extendedOnValuesChange(args[1]);
1184
1184
  },
1185
1185
  form,
1186
- labelCol: ((_b = props.labelCol) == null ? void 0 : _b.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
1187
- wrapperCol: ((_c = props.wrapperCol) == null ? void 0 : _c.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
1186
+ labelCol: ((_c = props.labelCol) == null ? void 0 : _c.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.labelCol,
1187
+ wrapperCol: ((_d = props.wrapperCol) == null ? void 0 : _d.horizontalOnly) && props.layout !== "horizontal" ? void 0 : props.wrapperCol
1188
1188
  }),
1189
1189
  /* @__PURE__ */ React.createElement("style", null, `
1190
- .ant-form-item-explain + div, .ant-form-item-margin-offset {
1191
- display: none;
1192
- }
1193
- `),
1190
+ .ant-form-item-explain + div, .ant-form-item-margin-offset {
1191
+ display: none;
1192
+ }
1193
+ `),
1194
1194
  childrenNode
1195
- )
1195
+ ))
1196
1196
  );
1197
1197
  };
1198
1198
  function FormWrapper(props) {
@@ -1246,40 +1246,41 @@ const COMMON_ACTIONS = [
1246
1246
  // },
1247
1247
  // },
1248
1248
  ];
1249
- function registerForm(loader) {
1250
- const colProp = (displayName, defaultValue) => ({
1251
- type: "object",
1252
- displayName,
1253
- advanced: true,
1254
- fields: {
1255
- span: {
1256
- type: "number",
1257
- displayName: "Grid columns",
1258
- description: "The number of grid columns to span (24 columns available)",
1259
- min: 1,
1260
- max: 24
1261
- },
1262
- offset: {
1263
- type: "number",
1264
- displayName: "Offset columns",
1265
- description: "Number of grid columns to skip from the left",
1266
- min: 0,
1267
- max: 23
1268
- },
1269
- horizontalOnly: {
1270
- type: "boolean",
1271
- displayName: "Horizontal only",
1272
- description: "Only apply to horizontal layout"
1273
- }
1249
+ const colProp = (displayName, defaultValue, description) => ({
1250
+ type: "object",
1251
+ displayName,
1252
+ advanced: true,
1253
+ fields: {
1254
+ span: {
1255
+ type: "number",
1256
+ displayName: "Width",
1257
+ description: "The number of grid columns to span in width (out of 24 columns total)",
1258
+ min: 1,
1259
+ max: 24
1274
1260
  },
1275
- defaultValue
1276
- });
1261
+ offset: {
1262
+ type: "number",
1263
+ displayName: "Offset",
1264
+ description: "Number of grid columns to skip from the left (out of 24 columns total)",
1265
+ min: 0,
1266
+ max: 23
1267
+ },
1268
+ horizontalOnly: {
1269
+ type: "boolean",
1270
+ displayName: "Horizontal only",
1271
+ description: "Only apply to horizontal layout"
1272
+ }
1273
+ },
1274
+ description,
1275
+ defaultValue
1276
+ });
1277
+ function registerForm(loader) {
1277
1278
  registerComponentHelper(loader, FormWrapper, {
1278
1279
  name: "plasmic-antd5-form",
1279
1280
  displayName: "Form",
1280
1281
  defaultStyles: {
1281
- display: "plasmic-content-layout",
1282
- gridRowGap: "10px"
1282
+ layout: "vbox",
1283
+ alignItems: "flex-start"
1283
1284
  },
1284
1285
  props: {
1285
1286
  children: {
@@ -1317,13 +1318,21 @@ function registerForm(loader) {
1317
1318
  },
1318
1319
  {
1319
1320
  type: "component",
1320
- name: "plasmic-antd5-button",
1321
+ name: "plasmic-antd5-form-item",
1321
1322
  props: {
1323
+ noLabel: true,
1322
1324
  children: {
1323
- type: "text",
1324
- value: "Submit"
1325
- },
1326
- submitsForm: true
1325
+ type: "component",
1326
+ name: "plasmic-antd5-button",
1327
+ props: {
1328
+ children: {
1329
+ type: "text",
1330
+ value: "Submit"
1331
+ },
1332
+ type: "primary",
1333
+ submitsForm: true
1334
+ }
1335
+ }
1327
1336
  }
1328
1337
  }
1329
1338
  ]
@@ -1340,16 +1349,25 @@ function registerForm(loader) {
1340
1349
  type: "choice",
1341
1350
  options: ["left", "right"],
1342
1351
  defaultValueHint: "right",
1343
- advanced: true
1352
+ advanced: true,
1353
+ hidden: (ps) => ps.layout !== "horizontal"
1344
1354
  },
1345
- labelCol: colProp("Label layout", {
1346
- span: 8,
1347
- horizontalOnly: true
1348
- }),
1349
- wrapperCol: colProp("Field layout", {
1350
- span: 16,
1351
- horizontalOnly: true
1352
- }),
1355
+ labelCol: colProp(
1356
+ "Label layout",
1357
+ {
1358
+ span: 8,
1359
+ horizontalOnly: true
1360
+ },
1361
+ "Set the width and offset of the labels"
1362
+ ),
1363
+ wrapperCol: colProp(
1364
+ "Control layout",
1365
+ {
1366
+ span: 16,
1367
+ horizontalOnly: true
1368
+ },
1369
+ "Set the width and offset of the form controls"
1370
+ ),
1353
1371
  colon: {
1354
1372
  type: "boolean",
1355
1373
  description: `Show a colon after labels by default (only for horizontal layout)`,
@@ -1502,14 +1520,34 @@ function useFormInstanceMaybe() {
1502
1520
  return Form.useFormInstance();
1503
1521
  }
1504
1522
  function FormItemWrapper(props) {
1505
- var _a, _b;
1506
- const relativeFormItemName = useFormItemRelativeName(props.name);
1507
- const fullFormItemName = useFormItemFullName(props.name);
1508
- const bestEffortLabel = !props.noLabel && reactNodeToString(props.label) || ensureArray(props.name).slice(-1)[0];
1509
- const rules = props.rules ? plasmicRulesToAntdRules(
1510
- props.rules,
1523
+ var _b;
1524
+ const _a = props, {
1525
+ rules: plasmicRules,
1526
+ description,
1527
+ noLabel,
1528
+ name,
1529
+ hideValidationMessage,
1530
+ customizeProps,
1531
+ setControlContextData,
1532
+ alignLabellessWithControls = true
1533
+ } = _a, rest = __objRest$5(_a, [
1534
+ "rules",
1535
+ "description",
1536
+ "noLabel",
1537
+ "name",
1538
+ "hideValidationMessage",
1539
+ "customizeProps",
1540
+ "setControlContextData",
1541
+ "alignLabellessWithControls"
1542
+ ]);
1543
+ const relativeFormItemName = useFormItemRelativeName(name);
1544
+ const fullFormItemName = useFormItemFullName(name);
1545
+ const bestEffortLabel = !noLabel && reactNodeToString(props.label) || ensureArray(props.name).slice(-1)[0];
1546
+ const rules = plasmicRules ? plasmicRulesToAntdRules(
1547
+ plasmicRules,
1511
1548
  typeof bestEffortLabel === "number" ? "" + bestEffortLabel : bestEffortLabel
1512
1549
  ) : void 0;
1550
+ const layoutContext = React.useContext(FormLayoutContext);
1513
1551
  const inCanvas = !!usePlasmicCanvasContext();
1514
1552
  if (inCanvas) {
1515
1553
  const form = useFormInstanceMaybe();
@@ -1519,7 +1557,7 @@ function FormItemWrapper(props) {
1519
1557
  });
1520
1558
  const internalFormCtx = React.useContext(InternalFormInstanceContext);
1521
1559
  const { fireOnValuesChange, forceRemount } = internalFormCtx != null ? internalFormCtx : {};
1522
- (_a = props.setControlContextData) == null ? void 0 : _a.call(props, {
1560
+ (_b = props.setControlContextData) == null ? void 0 : _b.call(props, {
1523
1561
  internalFormCtx
1524
1562
  });
1525
1563
  React.useEffect(() => {
@@ -1536,14 +1574,15 @@ function FormItemWrapper(props) {
1536
1574
  }
1537
1575
  return /* @__PURE__ */ React.createElement(
1538
1576
  FormItem,
1539
- __spreadValues$6(__spreadProps$5(__spreadValues$6({}, omit(props, "rules")), {
1540
- label: props.noLabel ? void 0 : props.label,
1577
+ __spreadProps$5(__spreadValues$6({}, rest), {
1578
+ label: noLabel ? void 0 : props.label,
1541
1579
  name: relativeFormItemName,
1542
- rules
1543
- }), props.helpTextMode === "extra" ? { extra: props.help } : props.helpTextMode === "help" ? (
1544
- // Never show validation errors in this mode, even if user didn't specify help
1545
- { help: (_b = props.help) != null ? _b : "" }
1546
- ) : {}),
1580
+ rules,
1581
+ extra: description,
1582
+ help: hideValidationMessage ? "" : props.help,
1583
+ colon: noLabel ? false : void 0,
1584
+ wrapperCol: (layoutContext == null ? void 0 : layoutContext.layout) === "horizontal" && noLabel && alignLabellessWithControls && layoutContext.labelSpan ? { offset: layoutContext.labelSpan } : void 0
1585
+ }),
1547
1586
  props.customizeProps ? /* @__PURE__ */ React.createElement(FormItemForwarder, { formItemProps: props }) : props.children
1548
1587
  );
1549
1588
  }
@@ -1573,13 +1612,18 @@ function registerFormItem(loader) {
1573
1612
  name: "plasmic-antd5-form-item",
1574
1613
  displayName: "Form Item",
1575
1614
  parentComponentName: "plasmic-antd5-form",
1615
+ defaultStyles: {
1616
+ marginBottom: "24px",
1617
+ width: "stretch"
1618
+ },
1576
1619
  props: {
1577
1620
  label: {
1578
1621
  type: "slot",
1579
1622
  defaultValue: {
1580
1623
  type: "text",
1581
1624
  value: "Label"
1582
- }
1625
+ },
1626
+ hidden: (ps) => !!ps.noLabel
1583
1627
  },
1584
1628
  children: {
1585
1629
  type: "slot",
@@ -1597,10 +1641,26 @@ function registerFormItem(loader) {
1597
1641
  rules: {
1598
1642
  type: "formValidationRules"
1599
1643
  },
1644
+ valuePropName: {
1645
+ type: "string",
1646
+ advanced: true,
1647
+ defaultValueHint: "value",
1648
+ description: "The prop name for specifying the value of the form control component"
1649
+ },
1600
1650
  noLabel: {
1601
1651
  type: "boolean",
1602
1652
  advanced: true
1603
1653
  },
1654
+ alignLabellessWithControls: {
1655
+ type: "boolean",
1656
+ displayName: "Align with controls?",
1657
+ description: "Aligns the content with form controls in the grid",
1658
+ hidden: (ps, ctx) => {
1659
+ var _a;
1660
+ return !ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
1661
+ },
1662
+ defaultValueHint: true
1663
+ },
1604
1664
  colon: {
1605
1665
  type: "boolean",
1606
1666
  defaultValueHint: true,
@@ -1610,7 +1670,11 @@ function registerFormItem(loader) {
1610
1670
  labelAlign: {
1611
1671
  type: "choice",
1612
1672
  options: ["left", "right"],
1613
- advanced: true
1673
+ advanced: true,
1674
+ hidden: (ps, ctx) => {
1675
+ var _a;
1676
+ return !!ps.noLabel || ((_a = ctx == null ? void 0 : ctx.internalFormCtx) == null ? void 0 : _a.layout.layout) !== "horizontal";
1677
+ }
1614
1678
  },
1615
1679
  hidden: {
1616
1680
  type: "boolean",
@@ -1634,34 +1698,16 @@ function registerFormItem(loader) {
1634
1698
  displayName: "Dependencies",
1635
1699
  description: "Form items can depend on other form items. This forces it to reevaluate the validation rules when the other form item changes."
1636
1700
  },
1637
- helpTextMode: {
1638
- type: "choice",
1639
- displayName: "Help text",
1640
- options: [
1641
- {
1642
- value: "errors",
1643
- label: "Validation errors"
1644
- },
1645
- {
1646
- value: "extra",
1647
- label: "Custom help text and validation errors"
1648
- },
1649
- {
1650
- value: "help",
1651
- label: "Custom help text, no validation errors"
1652
- }
1653
- ],
1654
- defaultValueHint: "Show validation errors",
1655
- description: "What to show in the help text. Edit help text by editing the 'help' slot in the outline."
1701
+ hideValidationMessage: {
1702
+ type: "boolean",
1703
+ displayName: "Hide validation message?",
1704
+ description: "If true, will hide the validation error message",
1705
+ defaultValueHint: false,
1706
+ advanced: true
1656
1707
  },
1657
- help: {
1708
+ description: {
1658
1709
  type: "slot",
1659
- hidden: (ps) => {
1660
- var _a;
1661
- return !["extra", "help"].includes((_a = ps.helpTextMode) != null ? _a : "");
1662
- },
1663
1710
  hidePlaceholder: true
1664
- // advanced: true,
1665
1711
  },
1666
1712
  customizeProps: {
1667
1713
  type: "function",
@@ -1679,13 +1725,85 @@ function registerFormItem(loader) {
1679
1725
  },
1680
1726
  noStyle: {
1681
1727
  type: "boolean",
1682
- displayName: "Field only",
1683
- description: "Don't render anything but the wrapped field component - so no label, help text, validation error, etc.",
1728
+ displayName: "Field control only",
1729
+ description: "Don't render anything but the field control - so no label, help text, validation error, etc.",
1684
1730
  advanced: true
1685
1731
  }
1686
1732
  },
1687
1733
  importPath: "@plasmicpkgs/antd5/skinny/registerForm",
1688
- importName: "FormItemWrapper"
1734
+ importName: "FormItemWrapper",
1735
+ templates: {
1736
+ Text: {
1737
+ props: {
1738
+ children: {
1739
+ type: "component",
1740
+ name: "plasmic-antd5-input"
1741
+ }
1742
+ }
1743
+ },
1744
+ "Long Text": {
1745
+ props: {
1746
+ children: {
1747
+ type: "component",
1748
+ name: "plasmic-antd5-textarea"
1749
+ }
1750
+ }
1751
+ },
1752
+ "Select dropdown": {
1753
+ props: {
1754
+ children: {
1755
+ type: "component",
1756
+ name: "plasmic-antd5-select"
1757
+ }
1758
+ }
1759
+ },
1760
+ Number: {
1761
+ props: {
1762
+ children: {
1763
+ type: "component",
1764
+ name: "plasmic-antd5-input-number"
1765
+ }
1766
+ }
1767
+ },
1768
+ Checkbox: {
1769
+ props: {
1770
+ children: {
1771
+ type: "component",
1772
+ name: "plasmic-antd5-checkbox"
1773
+ },
1774
+ valuePropName: "checked",
1775
+ noLabel: true
1776
+ }
1777
+ },
1778
+ Radios: {
1779
+ props: {
1780
+ children: {
1781
+ type: "component",
1782
+ name: "plasmic-antd5-radio-group"
1783
+ }
1784
+ }
1785
+ },
1786
+ Password: {
1787
+ props: {
1788
+ children: {
1789
+ type: "component",
1790
+ name: "plasmic-antd5-input-password"
1791
+ }
1792
+ }
1793
+ },
1794
+ "Submit button": {
1795
+ props: {
1796
+ children: {
1797
+ type: "component",
1798
+ name: "plasmic-antd5-button",
1799
+ props: {
1800
+ type: "primary"
1801
+ }
1802
+ },
1803
+ noLabel: true
1804
+ }
1805
+ }
1806
+ }
1689
1807
  });
1690
1808
  }
1691
1809
  function FormGroup(props) {
@@ -2647,14 +2765,31 @@ function registerRadio(loader) {
2647
2765
  allowedComponents: [
2648
2766
  "plasmic-antd5-radio",
2649
2767
  "plasmic-antd5-radio-button"
2768
+ ],
2769
+ defaultValue: [
2770
+ {
2771
+ type: "component",
2772
+ name: "plasmic-antd5-radio",
2773
+ props: {
2774
+ value: "op1",
2775
+ children: {
2776
+ type: "text",
2777
+ value: "Option 1"
2778
+ }
2779
+ }
2780
+ },
2781
+ {
2782
+ type: "component",
2783
+ name: "plasmic-antd5-radio",
2784
+ props: {
2785
+ value: "op2",
2786
+ children: {
2787
+ type: "text",
2788
+ value: "Option 2"
2789
+ }
2790
+ }
2791
+ }
2650
2792
  ]
2651
- // Error right now when using default slot content with stateful instances
2652
- // defaultValue: [
2653
- // {
2654
- // type: "component",
2655
- // name: "plasmic-antd5-radio",
2656
- // },
2657
- // ],
2658
2793
  },
2659
2794
  onChange: {
2660
2795
  type: "eventHandler",