@plasmicpkgs/antd5 0.0.149 → 0.0.150

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5727,29 +5727,48 @@ var __objRest$9 = (source, exclude) => {
5727
5727
  }
5728
5728
  return target;
5729
5729
  };
5730
+ const styleSections = [
5731
+ "visibility",
5732
+ "typography",
5733
+ "spacing",
5734
+ "background",
5735
+ "transform",
5736
+ "transitions",
5737
+ "layout",
5738
+ "overflow",
5739
+ "border",
5740
+ "shadows",
5741
+ "effects"
5742
+ ];
5730
5743
  function AntdModal(props) {
5744
+ const [isOpen, setIsOpen] = React.useState(false);
5731
5745
  const _a = props, {
5732
5746
  onOpenChange,
5733
5747
  onOk,
5734
5748
  onCancel,
5735
5749
  open,
5750
+ width,
5736
5751
  footer,
5737
5752
  hideFooter,
5738
5753
  modalScopeClassName,
5739
- wrapClassName
5754
+ wrapClassName,
5755
+ trigger
5740
5756
  } = _a, rest = __objRest$9(_a, [
5741
5757
  "onOpenChange",
5742
5758
  "onOk",
5743
5759
  "onCancel",
5744
5760
  "open",
5761
+ "width",
5745
5762
  "footer",
5746
5763
  "hideFooter",
5747
5764
  "modalScopeClassName",
5748
- "wrapClassName"
5765
+ "wrapClassName",
5766
+ "trigger"
5749
5767
  ]);
5750
5768
  const memoOnOk = React__default.default.useMemo(() => {
5751
5769
  if (onOpenChange || onOk) {
5752
5770
  return (e) => {
5771
+ setIsOpen(false);
5753
5772
  onOpenChange == null ? void 0 : onOpenChange(false);
5754
5773
  onOk == null ? void 0 : onOk(e);
5755
5774
  };
@@ -5760,6 +5779,7 @@ function AntdModal(props) {
5760
5779
  const memoOnCancel = React__default.default.useMemo(() => {
5761
5780
  if (onOpenChange || onCancel) {
5762
5781
  return (e) => {
5782
+ setIsOpen(false);
5763
5783
  onOpenChange == null ? void 0 : onOpenChange(false);
5764
5784
  onCancel == null ? void 0 : onCancel(e);
5765
5785
  };
@@ -5767,27 +5787,47 @@ function AntdModal(props) {
5767
5787
  return void 0;
5768
5788
  }
5769
5789
  }, [onOpenChange, onCancel]);
5770
- return /* @__PURE__ */ React__default.default.createElement(
5790
+ const widthProp = React.useMemo(() => {
5791
+ if (!width)
5792
+ return void 0;
5793
+ if (typeof width === "number")
5794
+ return width;
5795
+ if (typeof width !== "string")
5796
+ return void 0;
5797
+ if (/^\d+$/.test(width)) {
5798
+ return +width;
5799
+ }
5800
+ return width;
5801
+ }, [width]);
5802
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
5771
5803
  antd.Modal,
5772
5804
  __spreadProps$5(__spreadValues$c({}, rest), {
5773
5805
  onOk: memoOnOk,
5806
+ width: widthProp,
5774
5807
  onCancel: memoOnCancel,
5775
- open,
5808
+ open: isOpen || open,
5776
5809
  footer: hideFooter ? null : footer != null ? footer : void 0,
5777
5810
  wrapClassName,
5778
5811
  className: `${props.className} ${props.defaultStylesClassName} ${modalScopeClassName}`
5779
5812
  })
5780
- );
5813
+ ), trigger ? /* @__PURE__ */ React__default.default.createElement("div", { onClick: () => setIsOpen(true) }, trigger) : null);
5781
5814
  }
5782
5815
  function registerModal(loader) {
5783
5816
  registerComponentHelper(loader, AntdModal, {
5784
5817
  name: "plasmic-antd5-modal",
5785
5818
  displayName: "Modal",
5819
+ styleSections,
5786
5820
  description: "[See tutorial video](https://www.youtube.com/watch?v=TkjxNJIFun8)",
5787
5821
  props: {
5788
5822
  open: {
5789
5823
  type: "boolean"
5790
5824
  },
5825
+ width: {
5826
+ type: "string",
5827
+ defaultValueHint: "520px",
5828
+ description: "Change the width of the modal",
5829
+ helpText: "Default unit is px. You can also use % or other units for width."
5830
+ },
5791
5831
  children: {
5792
5832
  type: "slot",
5793
5833
  defaultValue: {
@@ -5807,6 +5847,22 @@ function registerModal(loader) {
5807
5847
  return (_a = ps.hideFooter) != null ? _a : false;
5808
5848
  }
5809
5849
  },
5850
+ trigger: __spreadValues$c({
5851
+ type: "slot",
5852
+ hidePlaceholder: true,
5853
+ defaultValue: {
5854
+ type: "component",
5855
+ name: "plasmic-antd5-button",
5856
+ props: {
5857
+ children: {
5858
+ type: "text",
5859
+ value: "Show modal"
5860
+ }
5861
+ }
5862
+ }
5863
+ }, {
5864
+ mergeWithParent: true
5865
+ }),
5810
5866
  closeIcon: {
5811
5867
  type: "slot",
5812
5868
  hidePlaceholder: true
@@ -5840,7 +5896,7 @@ function registerModal(loader) {
5840
5896
  },
5841
5897
  wrapClassName: {
5842
5898
  type: "class",
5843
- displayName: "Modal container",
5899
+ displayName: "Modal overlay",
5844
5900
  styleSections: ["background"]
5845
5901
  },
5846
5902
  modalScopeClassName: {
@@ -5851,6 +5907,7 @@ function registerModal(loader) {
5851
5907
  type: "class",
5852
5908
  displayName: "Modal content",
5853
5909
  noSelf: true,
5910
+ styleSections,
5854
5911
  selectors: [
5855
5912
  {
5856
5913
  selector: ":modal .ant-modal-content",