@kdcloudjs/kdesign 1.7.18 → 1.7.20

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/kdesign-complete.less +362 -244
  3. package/dist/kdesign.css +270 -239
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +716 -788
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +2 -2
  8. package/dist/kdesign.min.js +6 -6
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/button/style/token.less +1 -0
  11. package/es/carousel/style/index.css +4 -0
  12. package/es/carousel/style/index.less +31 -5
  13. package/es/cascader/cascader.js +4 -2
  14. package/es/checkbox/checkbox.js +5 -5
  15. package/es/checkbox/style/index.css +2 -0
  16. package/es/checkbox/style/index.less +2 -0
  17. package/es/checkbox/style/token.less +1 -1
  18. package/es/city-picker/city-picker.d.ts +3 -23
  19. package/es/city-picker/city-picker.js +351 -124
  20. package/es/city-picker/interface.d.ts +57 -0
  21. package/es/city-picker/interface.js +3 -0
  22. package/es/city-picker/option.d.ts +4 -0
  23. package/es/city-picker/option.js +42 -0
  24. package/es/city-picker/style/index.css +264 -239
  25. package/es/city-picker/style/index.less +262 -218
  26. package/es/city-picker/style/mixin.less +26 -3
  27. package/es/city-picker/style/token.less +42 -14
  28. package/es/collapse/collapse.d.ts +1 -1
  29. package/es/config-provider/compDefaultProps.d.ts +13 -0
  30. package/es/config-provider/compDefaultProps.js +13 -0
  31. package/es/dropdown/dropdown.d.ts +1 -0
  32. package/es/dropdown/dropdown.js +7 -2
  33. package/es/input/style/token.less +2 -8
  34. package/es/upload/upload.js +87 -63
  35. package/lib/button/style/token.less +1 -0
  36. package/lib/carousel/style/index.css +4 -0
  37. package/lib/carousel/style/index.less +31 -5
  38. package/lib/cascader/cascader.js +4 -2
  39. package/lib/checkbox/checkbox.js +4 -4
  40. package/lib/checkbox/style/index.css +2 -0
  41. package/lib/checkbox/style/index.less +2 -0
  42. package/lib/checkbox/style/token.less +1 -1
  43. package/lib/city-picker/city-picker.d.ts +3 -23
  44. package/lib/city-picker/city-picker.js +350 -123
  45. package/lib/city-picker/interface.d.ts +57 -0
  46. package/lib/city-picker/interface.js +11 -0
  47. package/lib/city-picker/option.d.ts +4 -0
  48. package/lib/city-picker/option.js +55 -0
  49. package/lib/city-picker/style/index.css +264 -239
  50. package/lib/city-picker/style/index.less +262 -218
  51. package/lib/city-picker/style/mixin.less +26 -3
  52. package/lib/city-picker/style/token.less +42 -14
  53. package/lib/collapse/collapse.d.ts +1 -1
  54. package/lib/config-provider/compDefaultProps.d.ts +13 -0
  55. package/lib/config-provider/compDefaultProps.js +13 -0
  56. package/lib/dropdown/dropdown.d.ts +1 -0
  57. package/lib/dropdown/dropdown.js +7 -2
  58. package/lib/input/style/token.less +2 -8
  59. package/lib/upload/upload.js +86 -62
  60. package/package.json +1 -1
  61. package/es/city-picker/city-group.d.ts +0 -8
  62. package/es/city-picker/city-group.js +0 -38
  63. package/es/city-picker/city-list.d.ts +0 -12
  64. package/es/city-picker/city-list.js +0 -55
  65. package/es/city-picker/city-panel-item.d.ts +0 -13
  66. package/es/city-picker/city-panel-item.js +0 -22
  67. package/es/city-picker/city-panel.d.ts +0 -17
  68. package/es/city-picker/city-panel.js +0 -153
  69. package/es/city-picker/city-search-panel.d.ts +0 -9
  70. package/es/city-picker/city-search-panel.js +0 -44
  71. package/es/city-picker/no-data.d.ts +0 -3
  72. package/es/city-picker/no-data.js +0 -18
  73. package/es/city-picker/utils/grouping.d.ts +0 -7
  74. package/es/city-picker/utils/grouping.js +0 -24
  75. package/lib/city-picker/city-group.d.ts +0 -8
  76. package/lib/city-picker/city-group.js +0 -51
  77. package/lib/city-picker/city-list.d.ts +0 -12
  78. package/lib/city-picker/city-list.js +0 -68
  79. package/lib/city-picker/city-panel-item.d.ts +0 -13
  80. package/lib/city-picker/city-panel-item.js +0 -35
  81. package/lib/city-picker/city-panel.d.ts +0 -17
  82. package/lib/city-picker/city-panel.js +0 -166
  83. package/lib/city-picker/city-search-panel.d.ts +0 -9
  84. package/lib/city-picker/city-search-panel.js +0 -57
  85. package/lib/city-picker/no-data.d.ts +0 -3
  86. package/lib/city-picker/no-data.js +0 -31
  87. package/lib/city-picker/utils/grouping.d.ts +0 -7
  88. package/lib/city-picker/utils/grouping.js +0 -30
@@ -475,6 +475,19 @@ var compDefaultProps = {
475
475
  });
476
476
  },
477
477
  expandOnClickNode: false
478
+ },
479
+ CityPicker: {
480
+ type: 'domestic',
481
+ loading: false,
482
+ size: 'small',
483
+ borderType: 'underline',
484
+ defaultOpen: false,
485
+ showArrow: true,
486
+ placeholder: '',
487
+ description: '城市',
488
+ showDescription: true,
489
+ optionHighlightProps: 'highlightText',
490
+ allowClear: true
478
491
  }
479
492
  };
480
493
  var _default = compDefaultProps;
@@ -19,6 +19,7 @@ export interface DropDownProps extends PopperProps {
19
19
  children?: React.ReactNode;
20
20
  onItemClick?: (key: string) => void;
21
21
  menu: React.ReactElement | Array<MenuItem>;
22
+ menuAnimation?: boolean;
22
23
  }
23
24
  interface DropdownType extends React.ForwardRefExoticComponent<DropDownProps & React.RefAttributes<HTMLElement>> {
24
25
  Menu: typeof Menu;
@@ -43,9 +43,11 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
43
43
  defaultVisible = allProps.defaultVisible,
44
44
  onVisibleChange = allProps.onVisibleChange,
45
45
  trigger = allProps.trigger,
46
- customPrefixcls = allProps.prefixCls;
47
- // className前缀
46
+ customPrefixcls = allProps.prefixCls,
47
+ menuAnimation = allProps.menuAnimation,
48
+ popperStyle = allProps.popperStyle;
48
49
  var prefixCls = getPrefixCls(pkgPrefixCls, 'dropdown', customPrefixcls);
50
+ var innerAnimation = typeof menuAnimation === 'boolean' ? menuAnimation : trigger !== 'contextMenu';
49
51
  var _React$useState = React.useState(!!props.visible || defaultVisible),
50
52
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
51
53
  visible = _React$useState2[0],
@@ -139,6 +141,9 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
139
141
  var popperProps = (0, _extends2.default)((0, _extends2.default)({}, allProps), {
140
142
  visible: visible,
141
143
  prefixCls: prefixCls,
144
+ popperStyle: innerAnimation ? popperStyle : (0, _extends2.default)({
145
+ animation: 'none'
146
+ }, popperStyle),
142
147
  onVisibleChange: handleVisibleChange
143
148
  });
144
149
  return (0, _usePopper.default)(child, menuElement, popperProps);
@@ -9,16 +9,10 @@
9
9
  @input-clear-color: var(~'@{input-prefix}-clear-color', #d9d9d9);
10
10
  @input-clear-color-hover: var(~'@{input-prefix}-clear-color-hover', #999);
11
11
  @input-background-color-inner: var(~'@{input-prefix}-color-background', @color-white);
12
- @input-background-color-disabled-inner: var(
13
- ~'@{input-prefix}-color-background-disabled',
14
- @color-background-contain-disabled
15
- );
12
+ @input-background-color-disabled-inner: var(~'@{input-prefix}-color-background-disabled', @color-background-contain-disabled);
16
13
  @input-border-color-focused: var(~'@{input-prefix}-color-border-focused', @color-theme);
17
14
  @input-border-color-disabled-inner: var(~'@{input-prefix}-color-border-disabled', @color-border-strong);
18
- @input-underline-border-color-disabled-inner: var(
19
- ~'@{input-prefix}-underline-color-border-disabled',
20
- @color-border-weak
21
- );
15
+ @input-underline-border-color-disabled-inner: var(~'@{input-prefix}-underline-color-border-disabled', @color-border-weak);
22
16
  @input-color-disabled-inner: var(~'@{input-prefix}-color-disabled', @color-disabled);
23
17
  @input-affix-color: var(~'@{input-prefix}-affix-color-text', #666);
24
18
  @input-error-color: var(~'@{input-prefix}-color-error', @color-error);
@@ -85,12 +85,11 @@ function abort(file) {
85
85
  }
86
86
  var InternalUpload = function InternalUpload(props, ref) {
87
87
  var _context5, _classNames, _context6, _context7;
88
- var _React$useContext = _react.default.useContext(_ConfigContext.default),
89
- getPrefixCls = _React$useContext.getPrefixCls,
90
- pkgPrefixCls = _React$useContext.prefixCls,
91
- userDefaultProps = _React$useContext.compDefaultProps;
92
- var innerRef = _react.default.useRef();
93
- var mergedRef = ref || innerRef;
88
+ var _useContext = (0, _react.useContext)(_ConfigContext.default),
89
+ getPrefixCls = _useContext.getPrefixCls,
90
+ pkgPrefixCls = _useContext.prefixCls,
91
+ userDefaultProps = _useContext.compDefaultProps;
92
+ var inputRef = (0, _react.useRef)(null);
94
93
  var allProps = (0, _utils.getCompProps)('Upload', userDefaultProps, props); // 属性需要合并一遍用户定义的默认属性
95
94
  var type = allProps.type,
96
95
  style = allProps.style,
@@ -106,15 +105,15 @@ var InternalUpload = function InternalUpload(props, ref) {
106
105
  showUploadList = allProps.showUploadList,
107
106
  customPrefixcls = allProps.prefixCls,
108
107
  onPreview = allProps.onPreview;
109
- var _React$useState = _react.default.useState(props.fileList || props.defaultFileList || []),
110
- _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
111
- fileList = _React$useState2[0],
112
- setFileList = _React$useState2[1];
108
+ var _useState = (0, _react.useState)(props.fileList || props.defaultFileList || []),
109
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
110
+ fileList = _useState2[0],
111
+ setFileList = _useState2[1];
113
112
  var hasChildren = children && _react.Children.toArray(children).length > 0;
114
- _react.default.useEffect(function () {
113
+ (0, _react.useEffect)(function () {
115
114
  props.fileList && setFileList(props.fileList);
116
115
  }, [props.fileList]);
117
- _react.default.useEffect(function () {
116
+ (0, _react.useEffect)(function () {
118
117
  return abort;
119
118
  }, []);
120
119
  var onClick = function onClick(e) {
@@ -134,20 +133,22 @@ var InternalUpload = function InternalUpload(props, ref) {
134
133
  });
135
134
  };
136
135
  var uploadFiles = function uploadFiles(files) {
137
- var _context2;
138
- files.forEach(function (file) {
139
- file.originFileObj = new File([file], file.name, {
140
- type: file.type
136
+ if (Array.isArray(files) && files.length) {
137
+ var _context2;
138
+ files.forEach(function (file) {
139
+ file.originFileObj = new File([file], file.name, {
140
+ type: file.type
141
+ });
142
+ file.uid = getUid();
143
+ file.status = 'notStart';
144
+ file.fileName = allProps.name || file.name;
141
145
  });
142
- file.uid = getUid();
143
- file.status = 'notStart';
144
- file.fileName = allProps.name || file.name;
145
- });
146
- var newFileList = (0, _concat.default)(_context2 = []).call(_context2, (0, _toConsumableArray2.default)(fileList), (0, _toConsumableArray2.default)(files));
147
- files.forEach(function (file) {
148
- props.fileList === undefined && setFileList(fileList);
149
- upload(file, newFileList);
150
- });
146
+ var newFileList = (0, _concat.default)(_context2 = []).call(_context2, (0, _toConsumableArray2.default)(fileList), (0, _toConsumableArray2.default)(files));
147
+ files.forEach(function (file) {
148
+ props.fileList === undefined && setFileList(fileList);
149
+ upload(file, newFileList);
150
+ });
151
+ }
151
152
  };
152
153
  var upload = function upload(file, fileList) {
153
154
  if (props.beforeUpload) {
@@ -276,40 +277,53 @@ var InternalUpload = function InternalUpload(props, ref) {
276
277
  });
277
278
  });
278
279
  };
279
- var handleRemove = function handleRemove(file, e) {
280
- e.preventDefault();
281
- var files = (0, _filter.default)(fileList).call(fileList, function (fileItem) {
282
- return fileItem.uid !== file.uid;
283
- });
284
- if (onRemove) {
285
- var remove = onRemove(file);
286
- if (remove && typeof remove !== 'boolean' && remove.then) {
287
- remove.then(function (flag) {
288
- if (flag) {
289
- onFileListChange(file, files);
290
- abort(file);
291
- }
292
- }).catch(function (e) {
293
- console.log(e);
294
- });
295
- } else if (remove !== false) {
280
+ var handleRemove = function handleRemove(originFile) {
281
+ var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
282
+ if (e) {
283
+ e.preventDefault();
284
+ }
285
+ if (originFile) {
286
+ var file = (0, _extends2.default)((0, _extends2.default)({}, originFile), {
287
+ status: 'removed'
288
+ });
289
+ var files = (0, _filter.default)(fileList).call(fileList, function (fileItem) {
290
+ return fileItem.uid !== file.uid;
291
+ });
292
+ if (onRemove) {
293
+ var remove = onRemove(file);
294
+ if (remove && typeof remove !== 'boolean' && remove.then) {
295
+ remove.then(function (flag) {
296
+ if (flag) {
297
+ onFileListChange(file, files);
298
+ abort(file);
299
+ }
300
+ }).catch(function (e) {
301
+ console.log(e);
302
+ });
303
+ } else if (remove !== false) {
304
+ onFileListChange(file, files);
305
+ abort(file);
306
+ }
307
+ } else {
296
308
  onFileListChange(file, files);
297
309
  abort(file);
298
310
  }
299
- } else {
300
- onFileListChange(file, files);
301
- abort(file);
302
311
  }
303
312
  };
304
- var handleReUpload = function handleReUpload(file, e) {
305
- e.preventDefault();
306
- file.percent = 0;
307
- file.status = 'uploading';
308
- var files = (0, _map.default)(fileList).call(fileList, function (fileItem) {
309
- return fileItem.uid === file.uid ? file : fileItem;
310
- });
311
- onFileListChange(file, files);
312
- upload(file, files);
313
+ var handleReUpload = function handleReUpload(file) {
314
+ var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
315
+ if (e) {
316
+ e.preventDefault();
317
+ }
318
+ if (file) {
319
+ file.percent = 0;
320
+ file.status = 'uploading';
321
+ var files = (0, _map.default)(fileList).call(fileList, function (fileItem) {
322
+ return fileItem.uid === file.uid ? file : fileItem;
323
+ });
324
+ onFileListChange(file, files);
325
+ upload(file, files);
326
+ }
313
327
  };
314
328
  var prefixCls = getPrefixCls(pkgPrefixCls, 'upload', customPrefixcls);
315
329
  var inputFileProps = {
@@ -322,10 +336,10 @@ var InternalUpload = function InternalUpload(props, ref) {
322
336
  webkitdirectory: directory ? 'webkitdirectory' : undefined
323
337
  };
324
338
  var dragEvents = {};
325
- var _React$useState3 = _react.default.useState(false),
326
- _React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
327
- hover = _React$useState4[0],
328
- setHover = _React$useState4[1];
339
+ var _useState3 = (0, _react.useState)(false),
340
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
341
+ hover = _useState4[0],
342
+ setHover = _useState4[1];
329
343
  if (type === 'drag') {
330
344
  var onFileDrop = function onFileDrop(e) {
331
345
  e.preventDefault();
@@ -361,7 +375,7 @@ var InternalUpload = function InternalUpload(props, ref) {
361
375
  dragEvents.onDragOver = onFileLeave;
362
376
  dragEvents.onDragLeave = onFileLeave;
363
377
  }
364
- _react.default.useEffect(function () {
378
+ (0, _react.useEffect)(function () {
365
379
  if (type === 'drag') {
366
380
  var stopDrop = function stopDrop(e) {
367
381
  return e.preventDefault();
@@ -374,6 +388,16 @@ var InternalUpload = function InternalUpload(props, ref) {
374
388
  };
375
389
  }
376
390
  }, [type]);
391
+ (0, _react.useImperativeHandle)(ref, function () {
392
+ return {
393
+ fileList: fileList,
394
+ uploadFiles: uploadFiles,
395
+ reUploadFile: handleReUpload,
396
+ removeFile: handleRemove,
397
+ abortFile: abort,
398
+ input: inputRef.current
399
+ };
400
+ });
377
401
  return /*#__PURE__*/_react.default.createElement("div", {
378
402
  className: (0, _classnames.default)(prefixCls, {
379
403
  disabled: disabled
@@ -389,7 +413,7 @@ var InternalUpload = function InternalUpload(props, ref) {
389
413
  title: "",
390
414
  type: "file"
391
415
  }, inputFileProps, {
392
- ref: mergedRef
416
+ ref: inputRef
393
417
  })))), (listType === 'picture' || !(listType === 'text' && (!showUploadList || !fileList.length))) && /*#__PURE__*/_react.default.createElement("ul", {
394
418
  className: (0, _concat.default)(_context6 = "".concat(prefixCls, "-")).call(_context6, listType, "-list")
395
419
  }, listType === 'picture' && hasChildren && /*#__PURE__*/_react.default.createElement("li", {
@@ -404,7 +428,7 @@ var InternalUpload = function InternalUpload(props, ref) {
404
428
  title: "",
405
429
  type: "file"
406
430
  }, inputFileProps, {
407
- ref: mergedRef
431
+ ref: inputRef
408
432
  }))))), showUploadList && (0, _map.default)(fileList).call(fileList, function (file) {
409
433
  return itemRender ? itemRender( /*#__PURE__*/_react.default.createElement(Item, (0, _extends2.default)({}, {
410
434
  file: file,
@@ -514,7 +538,7 @@ var Item = function Item(_ref3) {
514
538
  })]
515
539
  }));
516
540
  };
517
- var Upload = /*#__PURE__*/_react.default.forwardRef(InternalUpload);
541
+ var Upload = /*#__PURE__*/(0, _react.forwardRef)(InternalUpload);
518
542
  Upload.displayName = 'Upload';
519
543
  var _default = Upload;
520
544
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/kdesign",
3
- "version": "1.7.18",
3
+ "version": "1.7.20",
4
4
  "description": "KDesign 金蝶前端react 组件库",
5
5
  "title": "kdesign",
6
6
  "keywords": [
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- export interface CityGroupProps {
3
- groups: Array<string>;
4
- activedIndex?: number;
5
- changeIndex?: (index: number) => void;
6
- }
7
- declare const CityGroup: React.FC<CityGroupProps>;
8
- export default CityGroup;
@@ -1,38 +0,0 @@
1
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
2
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
- import React, { useContext } from 'react';
4
- import classNames from 'classnames';
5
- import ConfigContext from '../config-provider/ConfigContext';
6
- var CityGroup = function CityGroup(props) {
7
- var _useContext = useContext(ConfigContext),
8
- getPrefixCls = _useContext.getPrefixCls,
9
- prefixCls = _useContext.prefixCls;
10
- var groups = props.groups,
11
- _props$activedIndex = props.activedIndex,
12
- current = _props$activedIndex === void 0 ? 0 : _props$activedIndex,
13
- changeIndex = props.changeIndex;
14
- var cityPickerPrefixCls = getPrefixCls(prefixCls, 'city-picker');
15
- var containerCls = classNames("".concat(cityPickerPrefixCls, "-group-container"));
16
- var handleClick = function handleClick(groupIndex) {
17
- changeIndex && changeIndex(groupIndex);
18
- };
19
- return /*#__PURE__*/React.createElement("div", {
20
- className: containerCls
21
- }, _mapInstanceProperty(groups).call(groups, function (item, index) {
22
- var _context;
23
- var itemCls = classNames("".concat(cityPickerPrefixCls, "-group-item"), {
24
- active: current === index,
25
- last: index === groups.length - 1
26
- });
27
- var handleTitleClick = function handleTitleClick() {
28
- handleClick(index);
29
- };
30
- return /*#__PURE__*/React.createElement("div", {
31
- className: itemCls,
32
- title: item,
33
- key: _concatInstanceProperty(_context = "".concat(item, "_")).call(_context, index),
34
- onClick: handleTitleClick
35
- }, item);
36
- }));
37
- };
38
- export default CityGroup;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { City } from './city-panel-item';
3
- declare type CityList = {
4
- [key: string]: Array<City>;
5
- };
6
- export interface CityListProps {
7
- groupKeys?: Array<string> | null;
8
- cityList?: Array<Array<City>>;
9
- onSelect?: (city: City) => void;
10
- }
11
- declare const CityList: React.FC<CityListProps>;
12
- export default CityList;
@@ -1,55 +0,0 @@
1
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
2
- import React, { useContext } from 'react';
3
- import classNames from 'classnames';
4
- import ConfigContext from '../config-provider/ConfigContext';
5
- import CityPanelItem from './city-panel-item';
6
- import NoData from './no-data';
7
- var CityList = function CityList(props) {
8
- var _useContext = useContext(ConfigContext),
9
- getPrefixCls = _useContext.getPrefixCls,
10
- prefixCls = _useContext.prefixCls;
11
- var groupKeys = props.groupKeys,
12
- cityList = props.cityList,
13
- handleSelect = props.onSelect;
14
- var cityPickerPrefixCls = getPrefixCls(prefixCls, 'city-picker');
15
- var tableCls = classNames("".concat(cityPickerPrefixCls, "-city-table"));
16
- var tableGroupCls = classNames("".concat(cityPickerPrefixCls, "-city-table-group"));
17
- var keyCls = classNames("".concat(cityPickerPrefixCls, "-city-table-key"));
18
- var itemContainerCls = classNames("".concat(cityPickerPrefixCls, "-city-table-item-container"));
19
- var hasData = cityList && cityList.some(function (citys) {
20
- return citys.length > 0;
21
- });
22
- if (!hasData) {
23
- return /*#__PURE__*/React.createElement("div", {
24
- className: tableCls
25
- }, /*#__PURE__*/React.createElement(NoData, null));
26
- }
27
- return /*#__PURE__*/React.createElement("div", {
28
- className: tableCls
29
- }, groupKeys && groupKeys.length > 0 && _mapInstanceProperty(groupKeys).call(groupKeys, function (key, index) {
30
- var list = cityList[index] || [];
31
- return /*#__PURE__*/React.createElement("div", {
32
- className: tableGroupCls,
33
- key: key
34
- }, /*#__PURE__*/React.createElement("div", {
35
- className: keyCls
36
- }, key), /*#__PURE__*/React.createElement("div", {
37
- className: itemContainerCls
38
- }, _mapInstanceProperty(list).call(list, function (city) {
39
- return /*#__PURE__*/React.createElement(CityPanelItem, {
40
- key: city.id,
41
- city: city,
42
- onSelect: handleSelect
43
- });
44
- })));
45
- }), !groupKeys && cityList && _mapInstanceProperty(cityList).call(cityList, function (citys) {
46
- return _mapInstanceProperty(citys).call(citys, function (city) {
47
- return /*#__PURE__*/React.createElement(CityPanelItem, {
48
- key: city.id,
49
- city: city,
50
- onSelect: handleSelect
51
- });
52
- });
53
- }));
54
- };
55
- export default CityList;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- export declare type City = {
3
- id: string;
4
- country?: string;
5
- province?: string;
6
- name?: string;
7
- };
8
- export interface CityPanelItemProps {
9
- city: City;
10
- onSelect?: (city: City) => void;
11
- }
12
- declare const CityPanelItem: React.FC<CityPanelItemProps>;
13
- export default CityPanelItem;
@@ -1,22 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import classNames from 'classnames';
3
- import ConfigContext from '../config-provider/ConfigContext';
4
- var CityPanelItem = function CityPanelItem(props) {
5
- var _useContext = useContext(ConfigContext),
6
- getPrefixCls = _useContext.getPrefixCls,
7
- prefixCls = _useContext.prefixCls;
8
- var city = props.city,
9
- onSelect = props.onSelect;
10
- var cityPickerPrefixCls = getPrefixCls(prefixCls, 'city-picker');
11
- var cls = classNames("".concat(cityPickerPrefixCls, "-city-table-cell"));
12
- var handleCitySelect = function handleCitySelect() {
13
- onSelect === null || onSelect === void 0 ? void 0 : onSelect(city);
14
- };
15
- return /*#__PURE__*/React.createElement("div", {
16
- className: cls,
17
- key: city.id,
18
- title: city.name,
19
- onClick: handleCitySelect
20
- }, city.name);
21
- };
22
- export default CityPanelItem;
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { City } from './city-panel-item';
3
- export declare type CityGroups = 'domestic' | 'foreign';
4
- export declare type Common = Record<CityGroups, Array<City>>;
5
- export declare type Group = Record<CityGroups, Array<string>>;
6
- export declare type List = Record<CityGroups, Citys>;
7
- export declare type Citys = {
8
- [key: string]: Array<City>;
9
- };
10
- export interface CityPanelProps {
11
- commons?: Common;
12
- groups?: Group;
13
- cityList?: List;
14
- onSelect?: (city: City) => void;
15
- }
16
- declare const CityPanel: React.FC<CityPanelProps>;
17
- export default CityPanel;
@@ -1,153 +0,0 @@
1
- import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
2
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
- import React, { useContext, useState, useEffect } from 'react';
4
- import classNames from 'classnames';
5
- import ConfigContext from '../config-provider/ConfigContext';
6
- import CityGroup from './city-group';
7
- import CityList from './city-list';
8
- import grouping from './utils/grouping';
9
- var CityPanel = function CityPanel(_ref) {
10
- var _context, _context2;
11
- var groups = _ref.groups,
12
- commons = _ref.commons,
13
- cityList = _ref.cityList,
14
- onSelect = _ref.onSelect;
15
- var _useContext = useContext(ConfigContext),
16
- getPrefixCls = _useContext.getPrefixCls,
17
- prefixCls = _useContext.prefixCls,
18
- globalLocale = _useContext.locale;
19
- var cityPickerLang = globalLocale.getCompLangMsg({
20
- componentName: 'CityPicker'
21
- });
22
- var _useState = useState('domestic'),
23
- _useState2 = _slicedToArray(_useState, 2),
24
- activedIndex = _useState2[0],
25
- setActivedIndex = _useState2[1];
26
- var _useState3 = useState({
27
- domestic: [],
28
- foreign: []
29
- }),
30
- _useState4 = _slicedToArray(_useState3, 2),
31
- cityGroups = _useState4[0],
32
- setCityGroups = _useState4[1];
33
- var _useState5 = useState(null),
34
- _useState6 = _slicedToArray(_useState5, 2),
35
- groupKeys = _useState6[0],
36
- setGroupKeys = _useState6[1];
37
- var _useState7 = useState(0),
38
- _useState8 = _slicedToArray(_useState7, 2),
39
- activedGroupIndex = _useState8[0],
40
- setActivedGroupIndex = _useState8[1];
41
- var _useState9 = useState([commons ? commons.domestic : []]),
42
- _useState10 = _slicedToArray(_useState9, 2),
43
- list = _useState10[0],
44
- setList = _useState10[1];
45
- useEffect(function () {
46
- if (!groups) {
47
- return;
48
- }
49
- var domestic = groups.domestic,
50
- foreign = groups.foreign;
51
- domestic = grouping(domestic);
52
- foreign = grouping(foreign);
53
- if (commons === null || commons === void 0 ? void 0 : commons.domestic) {
54
- domestic.unshift(cityPickerLang.common);
55
- }
56
- if (commons === null || commons === void 0 ? void 0 : commons.foreign) {
57
- foreign.unshift(cityPickerLang.common);
58
- }
59
- setCityGroups({
60
- domestic: domestic,
61
- foreign: foreign
62
- });
63
- }, [groups, commons]);
64
- useEffect(function () {
65
- if (commons) {
66
- setList([commons[activedIndex]]);
67
- } else {
68
- var _groups = cityGroups[activedIndex];
69
- var currentGroup = _groups[0];
70
- var currentGroups = (currentGroup || '').split('');
71
- var newList = [];
72
- var currentList = cityList[activedIndex];
73
- currentGroups.forEach(function (character) {
74
- var temp = currentList[character] ? currentList[character] : [];
75
- newList.push(temp);
76
- });
77
- setList(newList);
78
- setGroupKeys(currentGroups);
79
- }
80
- setActivedGroupIndex(0);
81
- }, [activedIndex, cityGroups, groups, cityList]);
82
- var cityPickerPrefixCls = getPrefixCls(prefixCls, 'city-picker');
83
- var containerCls = classNames("".concat(cityPickerPrefixCls, "-panel-container"));
84
- var headerCls = classNames("".concat(cityPickerPrefixCls, "-header"));
85
- var contentContainerCls = classNames("".concat(cityPickerPrefixCls, "-content-container"));
86
- var domesticCls = classNames(_concatInstanceProperty(_context = "".concat(cityPickerPrefixCls, "-tab-item ")).call(_context, cityPickerPrefixCls, "-header-domestic"), {
87
- active: activedIndex === 'domestic'
88
- });
89
- var internationalCls = classNames(_concatInstanceProperty(_context2 = "".concat(cityPickerPrefixCls, "-tab-item ")).call(_context2, cityPickerPrefixCls, "-header-internation"), {
90
- active: activedIndex === 'foreign'
91
- });
92
- var handleDomesticClick = function handleDomesticClick() {
93
- if (activedIndex === 'domestic') return;
94
- setActivedIndex('domestic');
95
- };
96
- var handleInternationClick = function handleInternationClick() {
97
- if (activedIndex === 'foreign') return;
98
- setActivedIndex('foreign');
99
- };
100
- /**
101
- * 分组变换事件
102
- * @param index 分组索引
103
- */
104
- var handleGroupChange = function handleGroupChange(index) {
105
- if (!cityList) {
106
- return;
107
- }
108
- var groups = cityGroups[activedIndex];
109
- var currentGroup = groups[index];
110
- if (commons && currentGroup === cityPickerLang.common) {
111
- setList([commons[activedIndex] || []]);
112
- setGroupKeys(null);
113
- setActivedGroupIndex(index);
114
- return;
115
- }
116
- var currentGroups = (currentGroup || '').split('');
117
- var newList = [];
118
- var currentList = cityList[activedIndex];
119
- currentGroups.forEach(function (character) {
120
- var temp = currentList[character] ? currentList[character] : [];
121
- newList.push(temp);
122
- });
123
- setList(newList);
124
- setGroupKeys(currentGroups);
125
- setActivedGroupIndex(index);
126
- };
127
- var handleSelectCity = function handleSelectCity(city) {
128
- onSelect === null || onSelect === void 0 ? void 0 : onSelect(city);
129
- };
130
- var isClassified = commons && commons.domestic && commons.foreign;
131
- return /*#__PURE__*/React.createElement("div", {
132
- className: containerCls
133
- }, isClassified && /*#__PURE__*/React.createElement("div", {
134
- className: headerCls
135
- }, /*#__PURE__*/React.createElement("div", {
136
- className: domesticCls,
137
- onClick: handleDomesticClick
138
- }, cityPickerLang.domestic), /*#__PURE__*/React.createElement("div", {
139
- className: internationalCls,
140
- onClick: handleInternationClick
141
- }, cityPickerLang.internation)), /*#__PURE__*/React.createElement("div", {
142
- className: contentContainerCls
143
- }, /*#__PURE__*/React.createElement(CityGroup, {
144
- groups: cityGroups[activedIndex],
145
- activedIndex: activedGroupIndex,
146
- changeIndex: handleGroupChange
147
- }), /*#__PURE__*/React.createElement(CityList, {
148
- groupKeys: groupKeys,
149
- cityList: list,
150
- onSelect: handleSelectCity
151
- })));
152
- };
153
- export default CityPanel;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { City } from './city-panel-item';
3
- export interface SearchPanelProps {
4
- keyword: string;
5
- data: Array<City>;
6
- onSelect?: (city: City) => void;
7
- }
8
- declare const SearchPanel: React.FC<SearchPanelProps>;
9
- export default SearchPanel;