@plasmicpkgs/antd 0.0.1 → 0.0.5

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.
@@ -6,21 +6,21 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
6
6
 
7
7
  var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
8
8
  var antd = require('antd');
9
- var React = _interopDefault(require('react'));
10
9
  var Checkbox = _interopDefault(require('antd/lib/checkbox/Checkbox'));
11
10
  var CheckboxGroup = _interopDefault(require('antd/lib/checkbox/Group'));
12
- var CollapsePanel = _interopDefault(require('antd/lib/collapse/CollapsePanel'));
11
+ var React = _interopDefault(require('react'));
13
12
  var Collapse = _interopDefault(require('antd/lib/collapse/Collapse'));
13
+ var CollapsePanel = _interopDefault(require('antd/lib/collapse/CollapsePanel'));
14
14
  var AntdDropdown = _interopDefault(require('antd/lib/dropdown'));
15
15
  var DropdownButton = _interopDefault(require('antd/lib/dropdown/dropdown-button'));
16
- var TextArea = _interopDefault(require('antd/lib/input/TextArea'));
17
- var Search = _interopDefault(require('antd/lib/input/Search'));
18
- var Password = _interopDefault(require('antd/lib/input/Password'));
19
16
  var InputGroup = _interopDefault(require('antd/lib/input/Group'));
17
+ var Password = _interopDefault(require('antd/lib/input/Password'));
18
+ var Search = _interopDefault(require('antd/lib/input/Search'));
19
+ var TextArea = _interopDefault(require('antd/lib/input/TextArea'));
20
+ var Menu = _interopDefault(require('antd/lib/menu/index'));
20
21
  var MenuDivider = _interopDefault(require('antd/lib/menu/MenuDivider'));
21
22
  var MenuItem = _interopDefault(require('antd/lib/menu/MenuItem'));
22
23
  var SubMenu = _interopDefault(require('antd/lib/menu/SubMenu'));
23
- var Menu = _interopDefault(require('antd/lib/menu/index'));
24
24
  var rcMenu = require('rc-menu');
25
25
  var rcSelect = require('rc-select');
26
26
 
@@ -125,6 +125,48 @@ function _setPrototypeOf(o, p) {
125
125
  return _setPrototypeOf(o, p);
126
126
  }
127
127
 
128
+ function _objectWithoutPropertiesLoose(source, excluded) {
129
+ if (source == null) return {};
130
+ var target = {};
131
+ var sourceKeys = Object.keys(source);
132
+ var key, i;
133
+
134
+ for (i = 0; i < sourceKeys.length; i++) {
135
+ key = sourceKeys[i];
136
+ if (excluded.indexOf(key) >= 0) continue;
137
+ target[key] = source[key];
138
+ }
139
+
140
+ return target;
141
+ }
142
+
143
+ /**
144
+ * Traverses the tree of elements from a `React.createElement`. Notice we can't
145
+ * traverse elements created within the children's render function since this is
146
+ * the tree before rendering.
147
+ */
148
+ function traverseReactEltTree(children, callback) {
149
+ var rec = function rec(elts) {
150
+ (Array.isArray(elts) ? elts : [elts]).forEach(function (elt) {
151
+ if (elt) {
152
+ var _elt$props;
153
+
154
+ callback(elt);
155
+
156
+ if (elt.children) {
157
+ rec(elt.children);
158
+ }
159
+
160
+ if ((_elt$props = elt.props) != null && _elt$props.children && elt.props.children !== elt.children) {
161
+ rec(elt.props.children);
162
+ }
163
+ }
164
+ });
165
+ };
166
+
167
+ rec(children);
168
+ }
169
+
128
170
  var CheckboxWrapper = /*#__PURE__*/function (_React$Component) {
129
171
  _inheritsLoose(CheckboxWrapper, _React$Component);
130
172
 
@@ -198,10 +240,22 @@ var checkboxGroupMeta = {
198
240
  description: "If disable all checkboxes"
199
241
  },
200
242
  value: {
201
- type: "object",
243
+ type: "choice",
202
244
  editOnly: true,
203
245
  uncontrolledProp: "defaultValue",
204
- description: "Default selected value"
246
+ description: "Default selected value",
247
+ multiSelect: true,
248
+ options: function options(componentProps) {
249
+ var options = new Set();
250
+ traverseReactEltTree(componentProps.children, function (elt) {
251
+ var _elt$props;
252
+
253
+ if ((elt == null ? void 0 : elt.type) === CheckboxWrapper && typeof (elt == null ? void 0 : (_elt$props = elt.props) == null ? void 0 : _elt$props.value) === "string") {
254
+ options.add(elt.props.value);
255
+ }
256
+ });
257
+ return Array.from(options.keys());
258
+ }
205
259
  },
206
260
  children: {
207
261
  type: "slot",
@@ -338,10 +392,21 @@ var collapsteMeta = {
338
392
  description: "If true, Collapse renders as Accordion"
339
393
  },
340
394
  activeKey: {
341
- type: "object",
395
+ type: "choice",
342
396
  editOnly: true,
343
397
  uncontrolledProp: "defaultActiveKey",
344
- description: "Key of the active panel"
398
+ description: "Key of the active panel",
399
+ multiSelect: true,
400
+ options: function options(componentProps) {
401
+ var options = new Set(); // `children` is not defined in the Collapse props
402
+
403
+ traverseReactEltTree(componentProps.children, function (elt) {
404
+ if ((elt == null ? void 0 : elt.type) === CollapsePanel && typeof (elt == null ? void 0 : elt.key) === "string") {
405
+ options.add(elt.key);
406
+ }
407
+ });
408
+ return Array.from(options.keys());
409
+ }
345
410
  },
346
411
  bordered: {
347
412
  type: "boolean",
@@ -460,7 +525,10 @@ var dropdownButtonMeta = {
460
525
  type: "boolean",
461
526
  description: "Whether the dropdown menu is disabled"
462
527
  },
463
- icon: "slot",
528
+ icon: {
529
+ type: "slot",
530
+ hidePlaceholder: true
531
+ },
464
532
  overlay: {
465
533
  type: "slot",
466
534
  allowedComponents: ["AntdMenu"],
@@ -517,8 +585,14 @@ var inputMeta = {
517
585
  name: "AntdInput",
518
586
  displayName: "Antd Input",
519
587
  props: {
520
- addonAfter: "slot",
521
- addonBefore: "slot",
588
+ addonAfter: {
589
+ type: "slot",
590
+ hidePlaceholder: true
591
+ },
592
+ addonBefore: {
593
+ type: "slot",
594
+ hidePlaceholder: true
595
+ },
522
596
  allowClear: {
523
597
  type: "boolean",
524
598
  description: "If allow to remove input content with clear icon"
@@ -543,13 +617,19 @@ var inputMeta = {
543
617
  type: "string",
544
618
  description: "Placeholder for the input"
545
619
  },
546
- prefix: "slot",
620
+ prefix: {
621
+ type: "slot",
622
+ hidePlaceholder: true
623
+ },
547
624
  size: {
548
625
  type: "choice",
549
626
  options: ["small", "middle", "large"],
550
627
  description: "The size of the input box"
551
628
  },
552
- suffix: "slot",
629
+ suffix: {
630
+ type: "slot",
631
+ hidePlaceholder: true
632
+ },
553
633
  type: {
554
634
  type: "string",
555
635
  description: "The type of input"
@@ -627,7 +707,10 @@ var inputSearchMeta = {
627
707
  name: "AntdInputSearch",
628
708
  displayName: "Antd Input Search",
629
709
  props: {
630
- addonBefore: "slot",
710
+ addonBefore: {
711
+ type: "slot",
712
+ hidePlaceholder: true
713
+ },
631
714
  allowClear: {
632
715
  type: "boolean",
633
716
  description: "If allow to remove input content with clear icon"
@@ -640,7 +723,10 @@ var inputSearchMeta = {
640
723
  type: "boolean",
641
724
  description: "Whether the input is disabled"
642
725
  },
643
- enterButton: "slot",
726
+ enterButton: {
727
+ type: "slot",
728
+ hidePlaceholder: true
729
+ },
644
730
  id: {
645
731
  type: "string",
646
732
  description: "The ID for input"
@@ -657,13 +743,19 @@ var inputSearchMeta = {
657
743
  type: "string",
658
744
  description: "Placeholder for the input"
659
745
  },
660
- prefix: "slot",
746
+ prefix: {
747
+ type: "slot",
748
+ hidePlaceholder: true
749
+ },
661
750
  size: {
662
751
  type: "choice",
663
752
  options: ["small", "middle", "large"],
664
753
  description: "The size of the input box"
665
754
  },
666
- suffix: "slot",
755
+ suffix: {
756
+ type: "slot",
757
+ hidePlaceholder: true
758
+ },
667
759
  type: {
668
760
  type: "string",
669
761
  description: "The type of input"
@@ -689,8 +781,14 @@ var inputPasswordMeta = {
689
781
  name: "AntdInputPassword",
690
782
  displayName: "Antd Input Password",
691
783
  props: {
692
- addonAfter: "slot",
693
- addonBefore: "slot",
784
+ addonAfter: {
785
+ type: "slot",
786
+ hidePlaceholder: true
787
+ },
788
+ addonBefore: {
789
+ type: "slot",
790
+ hidePlaceholder: true
791
+ },
694
792
  allowClear: {
695
793
  type: "boolean",
696
794
  description: "If allow to remove input content with clear icon"
@@ -715,13 +813,15 @@ var inputPasswordMeta = {
715
813
  type: "string",
716
814
  description: "Placeholder for the input"
717
815
  },
718
- prefix: "slot",
816
+ prefix: {
817
+ type: "slot",
818
+ hidePlaceholder: true
819
+ },
719
820
  size: {
720
821
  type: "choice",
721
822
  options: ["small", "middle", "large"],
722
823
  description: "The size of the input box"
723
824
  },
724
- suffix: "slot",
725
825
  type: {
726
826
  type: "string",
727
827
  description: "The type of input"
@@ -817,7 +917,8 @@ var menuItemMeta = {
817
917
  },
818
918
  key: {
819
919
  type: "string",
820
- description: "Unique ID of the menu item"
920
+ description: "Unique ID of the menu item",
921
+ defaultValue: "menuItemKey"
821
922
  },
822
923
  title: {
823
924
  type: "string",
@@ -882,7 +983,8 @@ var subMenuMeta = {
882
983
  },
883
984
  key: {
884
985
  type: "string",
885
- description: "Unique ID of the sub-menu"
986
+ description: "Unique ID of the sub-menu",
987
+ defaultValue: "subMenuKey"
886
988
  },
887
989
  title: {
888
990
  type: "slot",
@@ -896,7 +998,10 @@ var subMenuMeta = {
896
998
  allowedComponents: ["AntdMenuItem", "AntdMenuDivider", "AntdMenuItemGroup", "AntdSubMenu"],
897
999
  defaultValue: [{
898
1000
  type: "component",
899
- name: "AntdMenuItem"
1001
+ name: "AntdMenuItem",
1002
+ props: {
1003
+ key: "subMenuItemKey"
1004
+ }
900
1005
  }]
901
1006
  }
902
1007
  },
@@ -916,7 +1021,8 @@ var menuMeta = {
916
1021
  displayName: "Antd Menu",
917
1022
  props: {
918
1023
  expandIcon: {
919
- type: "slot"
1024
+ type: "slot",
1025
+ hidePlaceholder: true
920
1026
  },
921
1027
  forceSubMenuRender: {
922
1028
  type: "boolean",
@@ -936,23 +1042,44 @@ var menuMeta = {
936
1042
  description: "Allows selection of multiple items"
937
1043
  },
938
1044
  openKeys: {
939
- type: "object",
1045
+ type: "choice",
940
1046
  editOnly: true,
941
1047
  uncontrolledProp: "defaultOpenKeys",
942
- description: "Array with the keys of default opened sub menus"
1048
+ description: "Array with the keys of default opened sub menus",
1049
+ multiSelect: true,
1050
+ options: function options(componentProps) {
1051
+ var options = new Set();
1052
+ traverseReactEltTree(componentProps.children, function (elt) {
1053
+ if ((elt == null ? void 0 : elt.type) === SubMenu && typeof (elt == null ? void 0 : elt.key) === "string") {
1054
+ options.add(elt.key);
1055
+ }
1056
+ });
1057
+ return Array.from(options.keys());
1058
+ }
943
1059
  },
944
1060
  overflowedIndicator: {
945
- type: "slot"
1061
+ type: "slot",
1062
+ hidePlaceholder: true
946
1063
  },
947
1064
  selectable: {
948
1065
  type: "boolean",
949
1066
  description: "Allows selecting menu items"
950
1067
  },
951
1068
  selectedKeys: {
952
- type: "object",
1069
+ type: "choice",
953
1070
  editOnly: true,
954
1071
  uncontrolledProp: "defaultSelectedKeys",
955
- description: "Array with the keys of default selected menu items"
1072
+ description: "Array with the keys of default selected menu items",
1073
+ multiSelect: true,
1074
+ options: function options(componentProps) {
1075
+ var options = new Set();
1076
+ traverseReactEltTree(componentProps.children, function (elt) {
1077
+ if ([SubMenu, MenuItem].includes(elt == null ? void 0 : elt.type) && typeof (elt == null ? void 0 : elt.key) === "string") {
1078
+ options.add(elt.key);
1079
+ }
1080
+ });
1081
+ return Array.from(options.keys());
1082
+ }
956
1083
  },
957
1084
  subMenuCloseDelay: {
958
1085
  type: "number",
@@ -1122,10 +1249,21 @@ var selectMeta = {
1122
1249
  description: "Set mode of Select"
1123
1250
  },
1124
1251
  value: {
1125
- type: "object",
1252
+ type: "choice",
1126
1253
  editOnly: true,
1127
1254
  uncontrolledProp: "defaultValue",
1128
- description: "Initial selected option"
1255
+ description: "Initial selected option",
1256
+ options: function options(componentProps) {
1257
+ var options = new Set();
1258
+ traverseReactEltTree(componentProps.children, function (elt) {
1259
+ var _elt$props;
1260
+
1261
+ if ((elt == null ? void 0 : elt.type) === rcSelect.Option && typeof (elt == null ? void 0 : (_elt$props = elt.props) == null ? void 0 : _elt$props.value) === "string") {
1262
+ options.add(elt.props.value);
1263
+ }
1264
+ });
1265
+ return Array.from(options.keys());
1266
+ }
1129
1267
  },
1130
1268
  virtual: {
1131
1269
  type: "boolean",
@@ -1158,6 +1296,32 @@ function registerSelect(loader, customSelectMeta) {
1158
1296
  doRegisterComponent(antd.Select, customSelectMeta != null ? customSelectMeta : selectMeta);
1159
1297
  }
1160
1298
 
1299
+ var Slider = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1300
+ var value = _ref.value,
1301
+ defaultValue = _ref.defaultValue,
1302
+ value2 = _ref.value2,
1303
+ defaultValue2 = _ref.defaultValue2,
1304
+ props = _objectWithoutPropertiesLoose(_ref, ["value", "defaultValue", "value2", "defaultValue2"]);
1305
+
1306
+ var newProps = _extends({}, props);
1307
+
1308
+ if (props.range) {
1309
+ if (typeof value === "number" || typeof value2 === "number") {
1310
+ newProps.value = [value != null ? value : 0, value2 != null ? value2 : 0];
1311
+ }
1312
+
1313
+ if (typeof defaultValue === "number" || typeof defaultValue2 === "number") {
1314
+ newProps.defaultValue = [defaultValue != null ? defaultValue : 0, defaultValue2 != null ? defaultValue2 : 0];
1315
+ }
1316
+ } else {
1317
+ newProps.value = value;
1318
+ newProps.defaultValue = defaultValue;
1319
+ }
1320
+
1321
+ return React.createElement(antd.Slider, Object.assign({}, newProps, {
1322
+ ref: ref
1323
+ }));
1324
+ });
1161
1325
  var sliderMeta = {
1162
1326
  name: "AntdSlider",
1163
1327
  displayName: "Antd Slider",
@@ -1178,6 +1342,10 @@ var sliderMeta = {
1178
1342
  type: "boolean",
1179
1343
  description: "If true, the slider will not be interactable"
1180
1344
  },
1345
+ range: {
1346
+ type: "boolean",
1347
+ description: "Dual thumb mode"
1348
+ },
1181
1349
  reverse: {
1182
1350
  type: "boolean",
1183
1351
  description: "Reverse the component"
@@ -1192,17 +1360,31 @@ var sliderMeta = {
1192
1360
  uncontrolledProp: "defaultValue",
1193
1361
  description: "The default value of slider"
1194
1362
  },
1363
+ value2: {
1364
+ type: "number",
1365
+ displayName: "value 2",
1366
+ editOnly: true,
1367
+ uncontrolledProp: "defaultValue2",
1368
+ description: "The default value for the second value of the slider",
1369
+ hidden: function hidden(props) {
1370
+ return !props.range;
1371
+ }
1372
+ },
1195
1373
  step: {
1196
- type: "object",
1374
+ type: "number",
1197
1375
  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",
1198
- defaultValue: 1
1376
+ defaultValueHint: 1
1199
1377
  },
1200
1378
  marks: {
1201
1379
  type: "object",
1202
1380
  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"
1203
1381
  }
1204
1382
  },
1205
- importPath: "antd",
1383
+ defaultStyles: {
1384
+ width: "200px",
1385
+ maxWidth: "100%"
1386
+ },
1387
+ importPath: "@plasmicpkgs/antd",
1206
1388
  importName: "Slider"
1207
1389
  };
1208
1390
  function registerSlider(loader, customSliderMeta) {
@@ -1210,7 +1392,7 @@ function registerSlider(loader, customSliderMeta) {
1210
1392
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1211
1393
  };
1212
1394
 
1213
- doRegisterComponent(antd.Slider, customSliderMeta != null ? customSliderMeta : sliderMeta);
1395
+ doRegisterComponent(Slider, customSliderMeta != null ? customSliderMeta : sliderMeta);
1214
1396
  }
1215
1397
 
1216
1398
  var switchMeta = {
@@ -1237,17 +1419,13 @@ var switchMeta = {
1237
1419
  },
1238
1420
  checkedChildren: {
1239
1421
  type: "slot",
1240
- defaultValue: [{
1241
- type: "text",
1242
- value: "1"
1243
- }]
1422
+ defaultValue: [],
1423
+ hidePlaceholder: true
1244
1424
  },
1245
1425
  unCheckedChildren: {
1246
1426
  type: "slot",
1247
- defaultValue: [{
1248
- type: "text",
1249
- value: "0"
1250
- }]
1427
+ defaultValue: [],
1428
+ hidePlaceholder: true
1251
1429
  },
1252
1430
  size: {
1253
1431
  type: "choice",
@@ -1293,6 +1471,7 @@ function registerAll(loader) {
1293
1471
  }
1294
1472
 
1295
1473
  exports.Dropdown = Dropdown;
1474
+ exports.Slider = Slider;
1296
1475
  exports.buttonMeta = buttonMeta;
1297
1476
  exports.carouselMeta = carouselMeta;
1298
1477
  exports.checkboxGroupMeta = checkboxGroupMeta;