@plasmicpkgs/antd5 0.0.148 → 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/antd.esm.js CHANGED
@@ -5712,29 +5712,48 @@ var __objRest$9 = (source, exclude) => {
5712
5712
  }
5713
5713
  return target;
5714
5714
  };
5715
+ const styleSections = [
5716
+ "visibility",
5717
+ "typography",
5718
+ "spacing",
5719
+ "background",
5720
+ "transform",
5721
+ "transitions",
5722
+ "layout",
5723
+ "overflow",
5724
+ "border",
5725
+ "shadows",
5726
+ "effects"
5727
+ ];
5715
5728
  function AntdModal(props) {
5729
+ const [isOpen, setIsOpen] = useState(false);
5716
5730
  const _a = props, {
5717
5731
  onOpenChange,
5718
5732
  onOk,
5719
5733
  onCancel,
5720
5734
  open,
5735
+ width,
5721
5736
  footer,
5722
5737
  hideFooter,
5723
5738
  modalScopeClassName,
5724
- wrapClassName
5739
+ wrapClassName,
5740
+ trigger
5725
5741
  } = _a, rest = __objRest$9(_a, [
5726
5742
  "onOpenChange",
5727
5743
  "onOk",
5728
5744
  "onCancel",
5729
5745
  "open",
5746
+ "width",
5730
5747
  "footer",
5731
5748
  "hideFooter",
5732
5749
  "modalScopeClassName",
5733
- "wrapClassName"
5750
+ "wrapClassName",
5751
+ "trigger"
5734
5752
  ]);
5735
5753
  const memoOnOk = React.useMemo(() => {
5736
5754
  if (onOpenChange || onOk) {
5737
5755
  return (e) => {
5756
+ setIsOpen(false);
5738
5757
  onOpenChange == null ? void 0 : onOpenChange(false);
5739
5758
  onOk == null ? void 0 : onOk(e);
5740
5759
  };
@@ -5745,6 +5764,7 @@ function AntdModal(props) {
5745
5764
  const memoOnCancel = React.useMemo(() => {
5746
5765
  if (onOpenChange || onCancel) {
5747
5766
  return (e) => {
5767
+ setIsOpen(false);
5748
5768
  onOpenChange == null ? void 0 : onOpenChange(false);
5749
5769
  onCancel == null ? void 0 : onCancel(e);
5750
5770
  };
@@ -5752,27 +5772,47 @@ function AntdModal(props) {
5752
5772
  return void 0;
5753
5773
  }
5754
5774
  }, [onOpenChange, onCancel]);
5755
- return /* @__PURE__ */ React.createElement(
5775
+ const widthProp = useMemo(() => {
5776
+ if (!width)
5777
+ return void 0;
5778
+ if (typeof width === "number")
5779
+ return width;
5780
+ if (typeof width !== "string")
5781
+ return void 0;
5782
+ if (/^\d+$/.test(width)) {
5783
+ return +width;
5784
+ }
5785
+ return width;
5786
+ }, [width]);
5787
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
5756
5788
  Modal,
5757
5789
  __spreadProps$5(__spreadValues$c({}, rest), {
5758
5790
  onOk: memoOnOk,
5791
+ width: widthProp,
5759
5792
  onCancel: memoOnCancel,
5760
- open,
5793
+ open: isOpen || open,
5761
5794
  footer: hideFooter ? null : footer != null ? footer : void 0,
5762
5795
  wrapClassName,
5763
5796
  className: `${props.className} ${props.defaultStylesClassName} ${modalScopeClassName}`
5764
5797
  })
5765
- );
5798
+ ), trigger ? /* @__PURE__ */ React.createElement("div", { onClick: () => setIsOpen(true) }, trigger) : null);
5766
5799
  }
5767
5800
  function registerModal(loader) {
5768
5801
  registerComponentHelper(loader, AntdModal, {
5769
5802
  name: "plasmic-antd5-modal",
5770
5803
  displayName: "Modal",
5804
+ styleSections,
5771
5805
  description: "[See tutorial video](https://www.youtube.com/watch?v=TkjxNJIFun8)",
5772
5806
  props: {
5773
5807
  open: {
5774
5808
  type: "boolean"
5775
5809
  },
5810
+ width: {
5811
+ type: "string",
5812
+ defaultValueHint: "520px",
5813
+ description: "Change the width of the modal",
5814
+ helpText: "Default unit is px. You can also use % or other units for width."
5815
+ },
5776
5816
  children: {
5777
5817
  type: "slot",
5778
5818
  defaultValue: {
@@ -5792,6 +5832,22 @@ function registerModal(loader) {
5792
5832
  return (_a = ps.hideFooter) != null ? _a : false;
5793
5833
  }
5794
5834
  },
5835
+ trigger: __spreadValues$c({
5836
+ type: "slot",
5837
+ hidePlaceholder: true,
5838
+ defaultValue: {
5839
+ type: "component",
5840
+ name: "plasmic-antd5-button",
5841
+ props: {
5842
+ children: {
5843
+ type: "text",
5844
+ value: "Show modal"
5845
+ }
5846
+ }
5847
+ }
5848
+ }, {
5849
+ mergeWithParent: true
5850
+ }),
5795
5851
  closeIcon: {
5796
5852
  type: "slot",
5797
5853
  hidePlaceholder: true
@@ -5825,7 +5881,7 @@ function registerModal(loader) {
5825
5881
  },
5826
5882
  wrapClassName: {
5827
5883
  type: "class",
5828
- displayName: "Modal container",
5884
+ displayName: "Modal overlay",
5829
5885
  styleSections: ["background"]
5830
5886
  },
5831
5887
  modalScopeClassName: {
@@ -5836,6 +5892,7 @@ function registerModal(loader) {
5836
5892
  type: "class",
5837
5893
  displayName: "Modal content",
5838
5894
  noSelf: true,
5895
+ styleSections,
5839
5896
  selectors: [
5840
5897
  {
5841
5898
  selector: ":modal .ant-modal-content",