@plasmicpkgs/antd 0.0.1 → 0.0.2

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
@@ -1,20 +1,20 @@
1
1
  import registerComponent from '@plasmicapp/host/registerComponent';
2
- import { Button, Carousel, Input, Select, Slider, Switch } from 'antd';
3
- import React from 'react';
2
+ import { Button, Carousel, Input, Select, Slider as Slider$1, Switch } from 'antd';
4
3
  import Checkbox from 'antd/lib/checkbox/Checkbox';
5
4
  import CheckboxGroup from 'antd/lib/checkbox/Group';
6
- import CollapsePanel from 'antd/lib/collapse/CollapsePanel';
5
+ import React from 'react';
7
6
  import Collapse from 'antd/lib/collapse/Collapse';
7
+ import CollapsePanel from 'antd/lib/collapse/CollapsePanel';
8
8
  import AntdDropdown from 'antd/lib/dropdown';
9
9
  import DropdownButton from 'antd/lib/dropdown/dropdown-button';
10
- import TextArea from 'antd/lib/input/TextArea';
11
- import Search from 'antd/lib/input/Search';
12
- import Password from 'antd/lib/input/Password';
13
10
  import InputGroup from 'antd/lib/input/Group';
11
+ import Password from 'antd/lib/input/Password';
12
+ import Search from 'antd/lib/input/Search';
13
+ import TextArea from 'antd/lib/input/TextArea';
14
+ import Menu from 'antd/lib/menu/index';
14
15
  import MenuDivider from 'antd/lib/menu/MenuDivider';
15
16
  import MenuItem from 'antd/lib/menu/MenuItem';
16
17
  import SubMenu from 'antd/lib/menu/SubMenu';
17
- import Menu from 'antd/lib/menu/index';
18
18
  import { ItemGroup } from 'rc-menu';
19
19
  import { Option, OptGroup } from 'rc-select';
20
20
 
@@ -119,6 +119,48 @@ function _setPrototypeOf(o, p) {
119
119
  return _setPrototypeOf(o, p);
120
120
  }
121
121
 
122
+ function _objectWithoutPropertiesLoose(source, excluded) {
123
+ if (source == null) return {};
124
+ var target = {};
125
+ var sourceKeys = Object.keys(source);
126
+ var key, i;
127
+
128
+ for (i = 0; i < sourceKeys.length; i++) {
129
+ key = sourceKeys[i];
130
+ if (excluded.indexOf(key) >= 0) continue;
131
+ target[key] = source[key];
132
+ }
133
+
134
+ return target;
135
+ }
136
+
137
+ /**
138
+ * Traverses the tree of elements from a `React.createElement`. Notice we can't
139
+ * traverse elements created within the children's render function since this is
140
+ * the tree before rendering.
141
+ */
142
+ function traverseReactEltTree(children, callback) {
143
+ var rec = function rec(elts) {
144
+ (Array.isArray(elts) ? elts : [elts]).forEach(function (elt) {
145
+ if (elt) {
146
+ var _elt$props;
147
+
148
+ callback(elt);
149
+
150
+ if (elt.children) {
151
+ rec(elt.children);
152
+ }
153
+
154
+ if ((_elt$props = elt.props) != null && _elt$props.children && elt.props.children !== elt.children) {
155
+ rec(elt.props.children);
156
+ }
157
+ }
158
+ });
159
+ };
160
+
161
+ rec(children);
162
+ }
163
+
122
164
  var CheckboxWrapper = /*#__PURE__*/function (_React$Component) {
123
165
  _inheritsLoose(CheckboxWrapper, _React$Component);
124
166
 
@@ -192,10 +234,22 @@ var checkboxGroupMeta = {
192
234
  description: "If disable all checkboxes"
193
235
  },
194
236
  value: {
195
- type: "object",
237
+ type: "choice",
196
238
  editOnly: true,
197
239
  uncontrolledProp: "defaultValue",
198
- description: "Default selected value"
240
+ description: "Default selected value",
241
+ multiSelect: true,
242
+ options: function options(componentProps) {
243
+ var options = new Set();
244
+ traverseReactEltTree(componentProps.children, function (elt) {
245
+ var _elt$props;
246
+
247
+ if ((elt == null ? void 0 : elt.type) === CheckboxWrapper && typeof (elt == null ? void 0 : (_elt$props = elt.props) == null ? void 0 : _elt$props.value) === "string") {
248
+ options.add(elt.props.value);
249
+ }
250
+ });
251
+ return Array.from(options.keys());
252
+ }
199
253
  },
200
254
  children: {
201
255
  type: "slot",
@@ -332,10 +386,21 @@ var collapsteMeta = {
332
386
  description: "If true, Collapse renders as Accordion"
333
387
  },
334
388
  activeKey: {
335
- type: "object",
389
+ type: "choice",
336
390
  editOnly: true,
337
391
  uncontrolledProp: "defaultActiveKey",
338
- description: "Key of the active panel"
392
+ description: "Key of the active panel",
393
+ multiSelect: true,
394
+ options: function options(componentProps) {
395
+ var options = new Set(); // `children` is not defined in the Collapse props
396
+
397
+ traverseReactEltTree(componentProps.children, function (elt) {
398
+ if ((elt == null ? void 0 : elt.type) === CollapsePanel && typeof (elt == null ? void 0 : elt.key) === "string") {
399
+ options.add(elt.key);
400
+ }
401
+ });
402
+ return Array.from(options.keys());
403
+ }
339
404
  },
340
405
  bordered: {
341
406
  type: "boolean",
@@ -511,8 +576,14 @@ var inputMeta = {
511
576
  name: "AntdInput",
512
577
  displayName: "Antd Input",
513
578
  props: {
514
- addonAfter: "slot",
515
- addonBefore: "slot",
579
+ addonAfter: {
580
+ type: "slot",
581
+ hidePlaceholder: true
582
+ },
583
+ addonBefore: {
584
+ type: "slot",
585
+ hidePlaceholder: true
586
+ },
516
587
  allowClear: {
517
588
  type: "boolean",
518
589
  description: "If allow to remove input content with clear icon"
@@ -537,13 +608,19 @@ var inputMeta = {
537
608
  type: "string",
538
609
  description: "Placeholder for the input"
539
610
  },
540
- prefix: "slot",
611
+ prefix: {
612
+ type: "slot",
613
+ hidePlaceholder: true
614
+ },
541
615
  size: {
542
616
  type: "choice",
543
617
  options: ["small", "middle", "large"],
544
618
  description: "The size of the input box"
545
619
  },
546
- suffix: "slot",
620
+ suffix: {
621
+ type: "slot",
622
+ hidePlaceholder: true
623
+ },
547
624
  type: {
548
625
  type: "string",
549
626
  description: "The type of input"
@@ -621,7 +698,10 @@ var inputSearchMeta = {
621
698
  name: "AntdInputSearch",
622
699
  displayName: "Antd Input Search",
623
700
  props: {
624
- addonBefore: "slot",
701
+ addonBefore: {
702
+ type: "slot",
703
+ hidePlaceholder: true
704
+ },
625
705
  allowClear: {
626
706
  type: "boolean",
627
707
  description: "If allow to remove input content with clear icon"
@@ -634,7 +714,10 @@ var inputSearchMeta = {
634
714
  type: "boolean",
635
715
  description: "Whether the input is disabled"
636
716
  },
637
- enterButton: "slot",
717
+ enterButton: {
718
+ type: "slot",
719
+ hidePlaceholder: true
720
+ },
638
721
  id: {
639
722
  type: "string",
640
723
  description: "The ID for input"
@@ -651,13 +734,19 @@ var inputSearchMeta = {
651
734
  type: "string",
652
735
  description: "Placeholder for the input"
653
736
  },
654
- prefix: "slot",
737
+ prefix: {
738
+ type: "slot",
739
+ hidePlaceholder: true
740
+ },
655
741
  size: {
656
742
  type: "choice",
657
743
  options: ["small", "middle", "large"],
658
744
  description: "The size of the input box"
659
745
  },
660
- suffix: "slot",
746
+ suffix: {
747
+ type: "slot",
748
+ hidePlaceholder: true
749
+ },
661
750
  type: {
662
751
  type: "string",
663
752
  description: "The type of input"
@@ -683,8 +772,14 @@ var inputPasswordMeta = {
683
772
  name: "AntdInputPassword",
684
773
  displayName: "Antd Input Password",
685
774
  props: {
686
- addonAfter: "slot",
687
- addonBefore: "slot",
775
+ addonAfter: {
776
+ type: "slot",
777
+ hidePlaceholder: true
778
+ },
779
+ addonBefore: {
780
+ type: "slot",
781
+ hidePlaceholder: true
782
+ },
688
783
  allowClear: {
689
784
  type: "boolean",
690
785
  description: "If allow to remove input content with clear icon"
@@ -709,13 +804,15 @@ var inputPasswordMeta = {
709
804
  type: "string",
710
805
  description: "Placeholder for the input"
711
806
  },
712
- prefix: "slot",
807
+ prefix: {
808
+ type: "slot",
809
+ hidePlaceholder: true
810
+ },
713
811
  size: {
714
812
  type: "choice",
715
813
  options: ["small", "middle", "large"],
716
814
  description: "The size of the input box"
717
815
  },
718
- suffix: "slot",
719
816
  type: {
720
817
  type: "string",
721
818
  description: "The type of input"
@@ -930,10 +1027,20 @@ var menuMeta = {
930
1027
  description: "Allows selection of multiple items"
931
1028
  },
932
1029
  openKeys: {
933
- type: "object",
1030
+ type: "choice",
934
1031
  editOnly: true,
935
1032
  uncontrolledProp: "defaultOpenKeys",
936
- description: "Array with the keys of default opened sub menus"
1033
+ description: "Array with the keys of default opened sub menus",
1034
+ multiSelect: true,
1035
+ options: function options(componentProps) {
1036
+ var options = new Set();
1037
+ traverseReactEltTree(componentProps.children, function (elt) {
1038
+ if ([SubMenu, MenuItem].includes(elt == null ? void 0 : elt.type) && typeof (elt == null ? void 0 : elt.key) === "string") {
1039
+ options.add(elt.key);
1040
+ }
1041
+ });
1042
+ return Array.from(options.keys());
1043
+ }
937
1044
  },
938
1045
  overflowedIndicator: {
939
1046
  type: "slot"
@@ -943,10 +1050,20 @@ var menuMeta = {
943
1050
  description: "Allows selecting menu items"
944
1051
  },
945
1052
  selectedKeys: {
946
- type: "object",
1053
+ type: "choice",
947
1054
  editOnly: true,
948
1055
  uncontrolledProp: "defaultSelectedKeys",
949
- description: "Array with the keys of default selected menu items"
1056
+ description: "Array with the keys of default selected menu items",
1057
+ multiSelect: true,
1058
+ options: function options(componentProps) {
1059
+ var options = new Set();
1060
+ traverseReactEltTree(componentProps.children, function (elt) {
1061
+ if ([SubMenu, MenuItem].includes(elt == null ? void 0 : elt.type) && typeof (elt == null ? void 0 : elt.key) === "string") {
1062
+ options.add(elt.key);
1063
+ }
1064
+ });
1065
+ return Array.from(options.keys());
1066
+ }
950
1067
  },
951
1068
  subMenuCloseDelay: {
952
1069
  type: "number",
@@ -1116,10 +1233,21 @@ var selectMeta = {
1116
1233
  description: "Set mode of Select"
1117
1234
  },
1118
1235
  value: {
1119
- type: "object",
1236
+ type: "choice",
1120
1237
  editOnly: true,
1121
1238
  uncontrolledProp: "defaultValue",
1122
- description: "Initial selected option"
1239
+ description: "Initial selected option",
1240
+ options: function options(componentProps) {
1241
+ var options = new Set();
1242
+ traverseReactEltTree(componentProps.children, function (elt) {
1243
+ var _elt$props;
1244
+
1245
+ if ((elt == null ? void 0 : elt.type) === Option && typeof (elt == null ? void 0 : (_elt$props = elt.props) == null ? void 0 : _elt$props.value) === "string") {
1246
+ options.add(elt.props.value);
1247
+ }
1248
+ });
1249
+ return Array.from(options.keys());
1250
+ }
1123
1251
  },
1124
1252
  virtual: {
1125
1253
  type: "boolean",
@@ -1152,6 +1280,32 @@ function registerSelect(loader, customSelectMeta) {
1152
1280
  doRegisterComponent(Select, customSelectMeta != null ? customSelectMeta : selectMeta);
1153
1281
  }
1154
1282
 
1283
+ var Slider = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1284
+ var value = _ref.value,
1285
+ defaultValue = _ref.defaultValue,
1286
+ value2 = _ref.value2,
1287
+ defaultValue2 = _ref.defaultValue2,
1288
+ props = _objectWithoutPropertiesLoose(_ref, ["value", "defaultValue", "value2", "defaultValue2"]);
1289
+
1290
+ var newProps = _extends({}, props);
1291
+
1292
+ if (props.range) {
1293
+ if (typeof value === "number" || typeof value2 === "number") {
1294
+ newProps.value = [value != null ? value : 0, value2 != null ? value2 : 0];
1295
+ }
1296
+
1297
+ if (typeof defaultValue === "number" || typeof defaultValue2 === "number") {
1298
+ newProps.defaultValue = [defaultValue != null ? defaultValue : 0, defaultValue2 != null ? defaultValue2 : 0];
1299
+ }
1300
+ } else {
1301
+ newProps.value = value;
1302
+ newProps.defaultValue = defaultValue;
1303
+ }
1304
+
1305
+ return React.createElement(Slider$1, Object.assign({}, newProps, {
1306
+ ref: ref
1307
+ }));
1308
+ });
1155
1309
  var sliderMeta = {
1156
1310
  name: "AntdSlider",
1157
1311
  displayName: "Antd Slider",
@@ -1172,6 +1326,10 @@ var sliderMeta = {
1172
1326
  type: "boolean",
1173
1327
  description: "If true, the slider will not be interactable"
1174
1328
  },
1329
+ range: {
1330
+ type: "boolean",
1331
+ description: "Dual thumb mode"
1332
+ },
1175
1333
  reverse: {
1176
1334
  type: "boolean",
1177
1335
  description: "Reverse the component"
@@ -1186,17 +1344,30 @@ var sliderMeta = {
1186
1344
  uncontrolledProp: "defaultValue",
1187
1345
  description: "The default value of slider"
1188
1346
  },
1347
+ value2: {
1348
+ type: "number",
1349
+ displayName: "value 2",
1350
+ editOnly: true,
1351
+ uncontrolledProp: "defaultValue2",
1352
+ description: "The default value for the second value of the slider",
1353
+ hidden: function hidden(props) {
1354
+ return !props.range;
1355
+ }
1356
+ },
1189
1357
  step: {
1190
- type: "object",
1191
- description: "The granularity the slider can step through values. Must greater than 0, and be divided by (max - min)." + " When marks no null, step can be null",
1192
- defaultValue: 1
1358
+ type: "number",
1359
+ description: "The granularity the slider can step through values. Must greater than 0, and be divided by (max - min)." + " When marks no null, step can be null"
1193
1360
  },
1194
1361
  marks: {
1195
1362
  type: "object",
1196
1363
  description: "Tick mark of Slider, type of key must be number, and must in closed interval [min, max]," + " each mark can declare its own style"
1197
1364
  }
1198
1365
  },
1199
- importPath: "antd",
1366
+ defaultStyles: {
1367
+ width: "200px",
1368
+ maxWidth: "100%"
1369
+ },
1370
+ importPath: "@plasmicpkgs/antd",
1200
1371
  importName: "Slider"
1201
1372
  };
1202
1373
  function registerSlider(loader, customSliderMeta) {
@@ -1231,17 +1402,13 @@ var switchMeta = {
1231
1402
  },
1232
1403
  checkedChildren: {
1233
1404
  type: "slot",
1234
- defaultValue: [{
1235
- type: "text",
1236
- value: "1"
1237
- }]
1405
+ defaultValue: [],
1406
+ hidePlaceholder: true
1238
1407
  },
1239
1408
  unCheckedChildren: {
1240
1409
  type: "slot",
1241
- defaultValue: [{
1242
- type: "text",
1243
- value: "0"
1244
- }]
1410
+ defaultValue: [],
1411
+ hidePlaceholder: true
1245
1412
  },
1246
1413
  size: {
1247
1414
  type: "choice",
@@ -1286,5 +1453,5 @@ function registerAll(loader) {
1286
1453
  registerInputGroup(loader);
1287
1454
  }
1288
1455
 
1289
- export { Dropdown, buttonMeta, carouselMeta, checkboxGroupMeta, checkboxMeta, collapsteMeta, collapstePanelMeta, dropdownButtonMeta, dropdownMeta, inputGroupMeta, inputMeta, inputPasswordMeta, inputSearchMeta, inputTextAreaMeta, menuDividerMeta, menuItemGroupMeta, menuItemMeta, menuMeta, optGroupMeta, optionMeta, registerAll, registerButton, registerCarousel, registerCheckbox, registerCheckboxGroup, registerCollapse, registerCollapsePanel, registerDropdown, registerDropdownButton, registerInput, registerInputGroup, registerInputPassword, registerInputSearch, registerInputTextArea, registerMenu, registerMenuDivider, registerMenuItem, registerMenuItemGroup, registerOptGroup, registerOption, registerSelect, registerSlider, registerSubMenu, registerSwitch, selectMeta, sliderMeta, subMenuMeta, switchMeta };
1456
+ export { Dropdown, Slider, buttonMeta, carouselMeta, checkboxGroupMeta, checkboxMeta, collapsteMeta, collapstePanelMeta, dropdownButtonMeta, dropdownMeta, inputGroupMeta, inputMeta, inputPasswordMeta, inputSearchMeta, inputTextAreaMeta, menuDividerMeta, menuItemGroupMeta, menuItemMeta, menuMeta, optGroupMeta, optionMeta, registerAll, registerButton, registerCarousel, registerCheckbox, registerCheckboxGroup, registerCollapse, registerCollapsePanel, registerDropdown, registerDropdownButton, registerInput, registerInputGroup, registerInputPassword, registerInputSearch, registerInputTextArea, registerMenu, registerMenuDivider, registerMenuItem, registerMenuItemGroup, registerOptGroup, registerOption, registerSelect, registerSlider, registerSubMenu, registerSwitch, selectMeta, sliderMeta, subMenuMeta, switchMeta };
1290
1457
  //# sourceMappingURL=antd.esm.js.map