@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.
@@ -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",
@@ -517,8 +582,14 @@ var inputMeta = {
517
582
  name: "AntdInput",
518
583
  displayName: "Antd Input",
519
584
  props: {
520
- addonAfter: "slot",
521
- addonBefore: "slot",
585
+ addonAfter: {
586
+ type: "slot",
587
+ hidePlaceholder: true
588
+ },
589
+ addonBefore: {
590
+ type: "slot",
591
+ hidePlaceholder: true
592
+ },
522
593
  allowClear: {
523
594
  type: "boolean",
524
595
  description: "If allow to remove input content with clear icon"
@@ -543,13 +614,19 @@ var inputMeta = {
543
614
  type: "string",
544
615
  description: "Placeholder for the input"
545
616
  },
546
- prefix: "slot",
617
+ prefix: {
618
+ type: "slot",
619
+ hidePlaceholder: true
620
+ },
547
621
  size: {
548
622
  type: "choice",
549
623
  options: ["small", "middle", "large"],
550
624
  description: "The size of the input box"
551
625
  },
552
- suffix: "slot",
626
+ suffix: {
627
+ type: "slot",
628
+ hidePlaceholder: true
629
+ },
553
630
  type: {
554
631
  type: "string",
555
632
  description: "The type of input"
@@ -627,7 +704,10 @@ var inputSearchMeta = {
627
704
  name: "AntdInputSearch",
628
705
  displayName: "Antd Input Search",
629
706
  props: {
630
- addonBefore: "slot",
707
+ addonBefore: {
708
+ type: "slot",
709
+ hidePlaceholder: true
710
+ },
631
711
  allowClear: {
632
712
  type: "boolean",
633
713
  description: "If allow to remove input content with clear icon"
@@ -640,7 +720,10 @@ var inputSearchMeta = {
640
720
  type: "boolean",
641
721
  description: "Whether the input is disabled"
642
722
  },
643
- enterButton: "slot",
723
+ enterButton: {
724
+ type: "slot",
725
+ hidePlaceholder: true
726
+ },
644
727
  id: {
645
728
  type: "string",
646
729
  description: "The ID for input"
@@ -657,13 +740,19 @@ var inputSearchMeta = {
657
740
  type: "string",
658
741
  description: "Placeholder for the input"
659
742
  },
660
- prefix: "slot",
743
+ prefix: {
744
+ type: "slot",
745
+ hidePlaceholder: true
746
+ },
661
747
  size: {
662
748
  type: "choice",
663
749
  options: ["small", "middle", "large"],
664
750
  description: "The size of the input box"
665
751
  },
666
- suffix: "slot",
752
+ suffix: {
753
+ type: "slot",
754
+ hidePlaceholder: true
755
+ },
667
756
  type: {
668
757
  type: "string",
669
758
  description: "The type of input"
@@ -689,8 +778,14 @@ var inputPasswordMeta = {
689
778
  name: "AntdInputPassword",
690
779
  displayName: "Antd Input Password",
691
780
  props: {
692
- addonAfter: "slot",
693
- addonBefore: "slot",
781
+ addonAfter: {
782
+ type: "slot",
783
+ hidePlaceholder: true
784
+ },
785
+ addonBefore: {
786
+ type: "slot",
787
+ hidePlaceholder: true
788
+ },
694
789
  allowClear: {
695
790
  type: "boolean",
696
791
  description: "If allow to remove input content with clear icon"
@@ -715,13 +810,15 @@ var inputPasswordMeta = {
715
810
  type: "string",
716
811
  description: "Placeholder for the input"
717
812
  },
718
- prefix: "slot",
813
+ prefix: {
814
+ type: "slot",
815
+ hidePlaceholder: true
816
+ },
719
817
  size: {
720
818
  type: "choice",
721
819
  options: ["small", "middle", "large"],
722
820
  description: "The size of the input box"
723
821
  },
724
- suffix: "slot",
725
822
  type: {
726
823
  type: "string",
727
824
  description: "The type of input"
@@ -936,10 +1033,20 @@ var menuMeta = {
936
1033
  description: "Allows selection of multiple items"
937
1034
  },
938
1035
  openKeys: {
939
- type: "object",
1036
+ type: "choice",
940
1037
  editOnly: true,
941
1038
  uncontrolledProp: "defaultOpenKeys",
942
- description: "Array with the keys of default opened sub menus"
1039
+ description: "Array with the keys of default opened sub menus",
1040
+ multiSelect: true,
1041
+ options: function options(componentProps) {
1042
+ var options = new Set();
1043
+ traverseReactEltTree(componentProps.children, function (elt) {
1044
+ if ([SubMenu, MenuItem].includes(elt == null ? void 0 : elt.type) && typeof (elt == null ? void 0 : elt.key) === "string") {
1045
+ options.add(elt.key);
1046
+ }
1047
+ });
1048
+ return Array.from(options.keys());
1049
+ }
943
1050
  },
944
1051
  overflowedIndicator: {
945
1052
  type: "slot"
@@ -949,10 +1056,20 @@ var menuMeta = {
949
1056
  description: "Allows selecting menu items"
950
1057
  },
951
1058
  selectedKeys: {
952
- type: "object",
1059
+ type: "choice",
953
1060
  editOnly: true,
954
1061
  uncontrolledProp: "defaultSelectedKeys",
955
- description: "Array with the keys of default selected menu items"
1062
+ description: "Array with the keys of default selected menu items",
1063
+ multiSelect: true,
1064
+ options: function options(componentProps) {
1065
+ var options = new Set();
1066
+ traverseReactEltTree(componentProps.children, function (elt) {
1067
+ if ([SubMenu, MenuItem].includes(elt == null ? void 0 : elt.type) && typeof (elt == null ? void 0 : elt.key) === "string") {
1068
+ options.add(elt.key);
1069
+ }
1070
+ });
1071
+ return Array.from(options.keys());
1072
+ }
956
1073
  },
957
1074
  subMenuCloseDelay: {
958
1075
  type: "number",
@@ -1122,10 +1239,21 @@ var selectMeta = {
1122
1239
  description: "Set mode of Select"
1123
1240
  },
1124
1241
  value: {
1125
- type: "object",
1242
+ type: "choice",
1126
1243
  editOnly: true,
1127
1244
  uncontrolledProp: "defaultValue",
1128
- description: "Initial selected option"
1245
+ description: "Initial selected option",
1246
+ options: function options(componentProps) {
1247
+ var options = new Set();
1248
+ traverseReactEltTree(componentProps.children, function (elt) {
1249
+ var _elt$props;
1250
+
1251
+ 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") {
1252
+ options.add(elt.props.value);
1253
+ }
1254
+ });
1255
+ return Array.from(options.keys());
1256
+ }
1129
1257
  },
1130
1258
  virtual: {
1131
1259
  type: "boolean",
@@ -1158,6 +1286,32 @@ function registerSelect(loader, customSelectMeta) {
1158
1286
  doRegisterComponent(antd.Select, customSelectMeta != null ? customSelectMeta : selectMeta);
1159
1287
  }
1160
1288
 
1289
+ var Slider = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1290
+ var value = _ref.value,
1291
+ defaultValue = _ref.defaultValue,
1292
+ value2 = _ref.value2,
1293
+ defaultValue2 = _ref.defaultValue2,
1294
+ props = _objectWithoutPropertiesLoose(_ref, ["value", "defaultValue", "value2", "defaultValue2"]);
1295
+
1296
+ var newProps = _extends({}, props);
1297
+
1298
+ if (props.range) {
1299
+ if (typeof value === "number" || typeof value2 === "number") {
1300
+ newProps.value = [value != null ? value : 0, value2 != null ? value2 : 0];
1301
+ }
1302
+
1303
+ if (typeof defaultValue === "number" || typeof defaultValue2 === "number") {
1304
+ newProps.defaultValue = [defaultValue != null ? defaultValue : 0, defaultValue2 != null ? defaultValue2 : 0];
1305
+ }
1306
+ } else {
1307
+ newProps.value = value;
1308
+ newProps.defaultValue = defaultValue;
1309
+ }
1310
+
1311
+ return React.createElement(antd.Slider, Object.assign({}, newProps, {
1312
+ ref: ref
1313
+ }));
1314
+ });
1161
1315
  var sliderMeta = {
1162
1316
  name: "AntdSlider",
1163
1317
  displayName: "Antd Slider",
@@ -1178,6 +1332,10 @@ var sliderMeta = {
1178
1332
  type: "boolean",
1179
1333
  description: "If true, the slider will not be interactable"
1180
1334
  },
1335
+ range: {
1336
+ type: "boolean",
1337
+ description: "Dual thumb mode"
1338
+ },
1181
1339
  reverse: {
1182
1340
  type: "boolean",
1183
1341
  description: "Reverse the component"
@@ -1192,17 +1350,30 @@ var sliderMeta = {
1192
1350
  uncontrolledProp: "defaultValue",
1193
1351
  description: "The default value of slider"
1194
1352
  },
1353
+ value2: {
1354
+ type: "number",
1355
+ displayName: "value 2",
1356
+ editOnly: true,
1357
+ uncontrolledProp: "defaultValue2",
1358
+ description: "The default value for the second value of the slider",
1359
+ hidden: function hidden(props) {
1360
+ return !props.range;
1361
+ }
1362
+ },
1195
1363
  step: {
1196
- type: "object",
1197
- 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
1364
+ type: "number",
1365
+ 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"
1199
1366
  },
1200
1367
  marks: {
1201
1368
  type: "object",
1202
1369
  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
1370
  }
1204
1371
  },
1205
- importPath: "antd",
1372
+ defaultStyles: {
1373
+ width: "200px",
1374
+ maxWidth: "100%"
1375
+ },
1376
+ importPath: "@plasmicpkgs/antd",
1206
1377
  importName: "Slider"
1207
1378
  };
1208
1379
  function registerSlider(loader, customSliderMeta) {
@@ -1210,7 +1381,7 @@ function registerSlider(loader, customSliderMeta) {
1210
1381
  return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1211
1382
  };
1212
1383
 
1213
- doRegisterComponent(antd.Slider, customSliderMeta != null ? customSliderMeta : sliderMeta);
1384
+ doRegisterComponent(Slider, customSliderMeta != null ? customSliderMeta : sliderMeta);
1214
1385
  }
1215
1386
 
1216
1387
  var switchMeta = {
@@ -1237,17 +1408,13 @@ var switchMeta = {
1237
1408
  },
1238
1409
  checkedChildren: {
1239
1410
  type: "slot",
1240
- defaultValue: [{
1241
- type: "text",
1242
- value: "1"
1243
- }]
1411
+ defaultValue: [],
1412
+ hidePlaceholder: true
1244
1413
  },
1245
1414
  unCheckedChildren: {
1246
1415
  type: "slot",
1247
- defaultValue: [{
1248
- type: "text",
1249
- value: "0"
1250
- }]
1416
+ defaultValue: [],
1417
+ hidePlaceholder: true
1251
1418
  },
1252
1419
  size: {
1253
1420
  type: "choice",
@@ -1293,6 +1460,7 @@ function registerAll(loader) {
1293
1460
  }
1294
1461
 
1295
1462
  exports.Dropdown = Dropdown;
1463
+ exports.Slider = Slider;
1296
1464
  exports.buttonMeta = buttonMeta;
1297
1465
  exports.carouselMeta = carouselMeta;
1298
1466
  exports.checkboxGroupMeta = checkboxGroupMeta;