@plasmicpkgs/antd 0.0.65 → 0.0.68

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.
@@ -28,6 +28,7 @@ var rcSelect = require('rc-select');
28
28
  var Select = _interopDefault(require('antd/lib/select'));
29
29
  var AntdSlider = _interopDefault(require('antd/lib/slider'));
30
30
  var Switch = _interopDefault(require('antd/lib/switch'));
31
+ var antd = require('antd');
31
32
  var AntdTabs = _interopDefault(require('antd/lib/tabs'));
32
33
  var rcTabs = require('rc-tabs');
33
34
 
@@ -1707,6 +1708,48 @@ function Tabs(props) {
1707
1708
  }
1708
1709
  }));
1709
1710
  }
1711
+
1712
+ function AddTab(_ref) {
1713
+ var studioOps = _ref.studioOps;
1714
+
1715
+ var _React$useState = React.useState(""),
1716
+ tabKey = _React$useState[0],
1717
+ setTabKey = _React$useState[1];
1718
+
1719
+ var appendNewTab = function appendNewTab(tabKey) {
1720
+ if (tabKey !== "") {
1721
+ studioOps.appendToChildren({
1722
+ type: "component",
1723
+ name: "AntdTabPane",
1724
+ props: {
1725
+ key: tabKey
1726
+ }
1727
+ });
1728
+ }
1729
+ };
1730
+
1731
+ return React.createElement("div", {
1732
+ style: {
1733
+ width: "100%",
1734
+ display: "flex",
1735
+ flexDirection: "row",
1736
+ gap: "10px",
1737
+ justifyContent: "space-between"
1738
+ }
1739
+ }, React.createElement(antd.Input, {
1740
+ placeholder: "Tab key",
1741
+ onChange: function onChange(e) {
1742
+ return setTabKey(e.target.value);
1743
+ },
1744
+ value: tabKey
1745
+ }), React.createElement(antd.Button, {
1746
+ onClick: function onClick() {
1747
+ appendNewTab(tabKey);
1748
+ setTabKey("");
1749
+ }
1750
+ }, "Add tab"));
1751
+ }
1752
+
1710
1753
  var tabsMeta = {
1711
1754
  name: "AntdTabs",
1712
1755
  displayName: "Antd Tabs",
@@ -1810,6 +1853,33 @@ var tabsMeta = {
1810
1853
  }]
1811
1854
  }
1812
1855
  },
1856
+ actions: [{
1857
+ type: "custom-action",
1858
+ comp: AddTab
1859
+ }, {
1860
+ type: "button-action",
1861
+ label: "Delete current tab",
1862
+ onClick: function onClick(_ref2) {
1863
+ var componentProps = _ref2.componentProps,
1864
+ studioOps = _ref2.studioOps;
1865
+
1866
+ if (componentProps.activeKey) {
1867
+ var tabPanes = [];
1868
+ traverseReactEltTree(componentProps.children, function (elt) {
1869
+ if ((elt == null ? void 0 : elt.type) === rcTabs.TabPane && typeof (elt == null ? void 0 : elt.key) === "string") {
1870
+ tabPanes.push(elt.key);
1871
+ }
1872
+ });
1873
+ var currentTabPos = tabPanes.findIndex(function (tabKey) {
1874
+ return tabKey === componentProps.activeKey;
1875
+ });
1876
+
1877
+ if (currentTabPos !== -1) {
1878
+ studioOps.removeChildAt(currentTabPos);
1879
+ }
1880
+ }
1881
+ }
1882
+ }],
1813
1883
  importPath: "@plasmicpkgs/antd",
1814
1884
  importName: "Tabs"
1815
1885
  };