@douyinfe/semi-ui 2.1.6-alpha.0 → 2.2.1

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 (97) hide show
  1. package/_base/_story/a11y.jsx +1302 -0
  2. package/_base/_story/a11y.scss +49 -0
  3. package/_base/_story/index.stories.js +3 -1
  4. package/_utils/index.ts +9 -4
  5. package/cascader/__test__/cascader.test.js +221 -0
  6. package/cascader/_story/cascader.stories.js +138 -0
  7. package/cascader/index.tsx +37 -21
  8. package/cascader/item.tsx +4 -2
  9. package/datePicker/__test__/datePicker.test.js +100 -2
  10. package/datePicker/_story/datePicker.stories.js +90 -1
  11. package/datePicker/_story/v2/YearButton.jsx +17 -0
  12. package/datePicker/_story/v2/index.js +1 -0
  13. package/datePicker/datePicker.tsx +3 -0
  14. package/datePicker/monthsGrid.tsx +12 -1
  15. package/datePicker/navigation.tsx +55 -29
  16. package/descriptions/__test__/descriptions.test.js +27 -1
  17. package/descriptions/_story/descriptions.stories.js +52 -2
  18. package/descriptions/item.tsx +1 -1
  19. package/dist/css/semi.css +72 -28
  20. package/dist/css/semi.min.css +1 -1
  21. package/dist/umd/semi-ui.js +1086 -468
  22. package/dist/umd/semi-ui.js.map +1 -1
  23. package/dist/umd/semi-ui.min.js +1 -1
  24. package/dist/umd/semi-ui.min.js.map +1 -1
  25. package/empty/index.tsx +2 -2
  26. package/gulpfile.js +2 -1
  27. package/lib/cjs/_utils/index.d.ts +1 -0
  28. package/lib/cjs/_utils/index.js +12 -5
  29. package/lib/cjs/cascader/index.d.ts +7 -0
  30. package/lib/cjs/cascader/index.js +35 -22
  31. package/lib/cjs/cascader/item.d.ts +2 -0
  32. package/lib/cjs/cascader/item.js +4 -2
  33. package/lib/cjs/datePicker/datePicker.js +4 -0
  34. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -0
  35. package/lib/cjs/datePicker/monthsGrid.js +6 -0
  36. package/lib/cjs/datePicker/navigation.js +47 -7
  37. package/lib/cjs/descriptions/item.js +1 -1
  38. package/lib/cjs/empty/index.d.ts +2 -2
  39. package/lib/cjs/empty/index.js +19 -18
  40. package/lib/cjs/form/baseForm.d.ts +6 -1
  41. package/lib/cjs/form/field.d.ts +6 -1
  42. package/lib/cjs/locale/source/es.d.ts +7 -0
  43. package/lib/cjs/locale/source/es.js +168 -0
  44. package/lib/cjs/rating/item.js +1 -1
  45. package/lib/cjs/select/index.d.ts +9 -0
  46. package/lib/cjs/select/index.js +10 -8
  47. package/lib/cjs/tabs/index.js +3 -7
  48. package/lib/cjs/timeline/item.d.ts +3 -0
  49. package/lib/cjs/timeline/item.js +10 -4
  50. package/lib/cjs/typography/title.d.ts +1 -1
  51. package/lib/cjs/upload/fileCard.d.ts +2 -0
  52. package/lib/cjs/upload/fileCard.js +70 -45
  53. package/lib/cjs/upload/index.d.ts +23 -2
  54. package/lib/cjs/upload/index.js +133 -25
  55. package/lib/cjs/upload/interface.d.ts +3 -0
  56. package/lib/es/_utils/index.d.ts +1 -0
  57. package/lib/es/_utils/index.js +12 -5
  58. package/lib/es/cascader/index.d.ts +7 -0
  59. package/lib/es/cascader/index.js +34 -25
  60. package/lib/es/cascader/item.d.ts +2 -0
  61. package/lib/es/cascader/item.js +4 -2
  62. package/lib/es/datePicker/datePicker.js +4 -0
  63. package/lib/es/datePicker/monthsGrid.d.ts +1 -0
  64. package/lib/es/datePicker/monthsGrid.js +6 -0
  65. package/lib/es/datePicker/navigation.js +48 -8
  66. package/lib/es/descriptions/item.js +1 -1
  67. package/lib/es/empty/index.d.ts +2 -2
  68. package/lib/es/empty/index.js +19 -18
  69. package/lib/es/form/baseForm.d.ts +6 -1
  70. package/lib/es/form/field.d.ts +6 -1
  71. package/lib/es/locale/source/es.d.ts +7 -0
  72. package/lib/es/locale/source/es.js +157 -0
  73. package/lib/es/rating/item.js +1 -1
  74. package/lib/es/select/index.d.ts +9 -0
  75. package/lib/es/select/index.js +14 -8
  76. package/lib/es/tabs/index.js +1 -5
  77. package/lib/es/timeline/item.d.ts +3 -0
  78. package/lib/es/timeline/item.js +9 -4
  79. package/lib/es/typography/title.d.ts +1 -1
  80. package/lib/es/upload/fileCard.d.ts +2 -0
  81. package/lib/es/upload/fileCard.js +69 -44
  82. package/lib/es/upload/index.d.ts +23 -2
  83. package/lib/es/upload/index.js +133 -24
  84. package/lib/es/upload/interface.d.ts +3 -0
  85. package/locale/source/es.ts +160 -0
  86. package/package.json +9 -9
  87. package/popover/Arrow.tsx +1 -1
  88. package/rating/item.tsx +1 -1
  89. package/select/_story/select.stories.js +25 -0
  90. package/select/index.tsx +17 -6
  91. package/tabs/index.tsx +1 -1
  92. package/timeline/_story/timeline.stories.js +50 -0
  93. package/timeline/item.tsx +7 -2
  94. package/upload/__test__/upload.test.js +50 -1
  95. package/upload/fileCard.tsx +110 -95
  96. package/upload/index.tsx +147 -53
  97. package/upload/interface.ts +3 -0
@@ -97,6 +97,23 @@ class Upload extends _baseComponent.default {
97
97
  this.remove = fileItem => {
98
98
  this.foundation.handleRemove(fileItem);
99
99
  };
100
+ /**
101
+ * ref method
102
+ * insert files at index
103
+ * @param files Array<CustomFile>
104
+ * @param index number
105
+ * @returns
106
+ */
107
+
108
+
109
+ this.insert = (files, index) => {
110
+ return this.foundation.insertFileToList(files, index);
111
+ };
112
+ /**
113
+ * ref method
114
+ * manual upload by user
115
+ */
116
+
100
117
 
101
118
  this.upload = () => {
102
119
  const {
@@ -112,14 +129,18 @@ class Upload extends _baseComponent.default {
112
129
  name,
113
130
  status,
114
131
  validateMessage,
115
- _sizeInvalid
132
+ _sizeInvalid,
133
+ uid
116
134
  } = file;
117
135
  const {
118
136
  previewFile,
119
137
  listType,
120
138
  itemStyle,
121
139
  showRetry,
140
+ showPicInfo,
141
+ renderPicInfo,
122
142
  renderFileItem,
143
+ renderThumbnail,
123
144
  disabled,
124
145
  onPreviewClick,
125
146
  showReplace
@@ -140,10 +161,14 @@ class Upload extends _baseComponent.default {
140
161
  listType,
141
162
  onRemove,
142
163
  onRetry,
143
- key: (0, _concat.default)(_context = "".concat(name)).call(_context, index),
164
+ index,
165
+ key: uid || (0, _concat.default)(_context = "".concat(name)).call(_context, index),
144
166
  showRetry: typeof file.showRetry !== 'undefined' ? file.showRetry : showRetry,
145
167
  style: itemStyle,
146
168
  disabled,
169
+ showPicInfo,
170
+ renderPicInfo,
171
+ renderThumbnail,
147
172
  showReplace: typeof file.showReplace !== 'undefined' ? file.showReplace : showReplace,
148
173
  onReplace,
149
174
  onPreviewClick: typeof onPreviewClick !== 'undefined' ? () => this.foundation.handlePreviewClick(file) : undefined
@@ -165,28 +190,69 @@ class Upload extends _baseComponent.default {
165
190
  };
166
191
 
167
192
  this.renderFileList = () => {
193
+ const {
194
+ listType
195
+ } = this.props;
196
+
197
+ if (listType === _constants.strings.FILE_LIST_PIC) {
198
+ return this.renderFileListPic();
199
+ }
200
+
201
+ if (listType === _constants.strings.FILE_LIST_DEFAULT) {
202
+ return this.renderFileListDefault();
203
+ }
204
+
205
+ return null;
206
+ };
207
+
208
+ this.renderFileListPic = () => {
168
209
  const {
169
210
  showUploadList,
170
- listType,
171
211
  limit,
172
212
  disabled,
173
- children
213
+ children,
214
+ draggable
174
215
  } = this.props;
175
216
  const {
176
- fileList: stateFileList
217
+ fileList: stateFileList,
218
+ dragAreaStatus
177
219
  } = this.state;
178
220
  const fileList = this.props.fileList || stateFileList;
179
- const isPicType = listType === _constants.strings.FILE_LIST_PIC;
180
- const showAddTriggerInList = isPicType && (limit ? limit > fileList.length : true);
221
+ const showAddTriggerInList = limit ? limit > fileList.length : true;
222
+ const dragAreaBaseCls = "".concat(prefixCls, "-drag-area");
181
223
  const uploadAddCls = (0, _classnames.default)("".concat(prefixCls, "-add"), {
182
- ["".concat(prefixCls, "-picture-add")]: isPicType,
224
+ ["".concat(prefixCls, "-picture-add")]: true,
183
225
  ["".concat(prefixCls, "-picture-add-disabled")]: disabled
184
226
  });
185
-
186
- const addContent = /*#__PURE__*/_react.default.createElement("div", {
227
+ const fileListCls = (0, _classnames.default)("".concat(prefixCls, "-file-list"), {
228
+ ["".concat(prefixCls, "-picture-file-list")]: true
229
+ });
230
+ const dragAreaCls = (0, _classnames.default)({
231
+ ["".concat(dragAreaBaseCls, "-legal")]: dragAreaStatus === _constants.strings.DRAG_AREA_LEGAL,
232
+ ["".concat(dragAreaBaseCls, "-illegal")]: dragAreaStatus === _constants.strings.DRAG_AREA_ILLEGAL
233
+ });
234
+ const mainCls = "".concat(prefixCls, "-file-list-main");
235
+ const addContentProps = {
187
236
  className: uploadAddCls,
188
237
  onClick: this.onClick
189
- }, children);
238
+ };
239
+ const containerProps = {
240
+ className: fileListCls
241
+ };
242
+ const draggableProps = {
243
+ onDrop: this.onDrop,
244
+ onDragOver: this.onDragOver,
245
+ onDragLeave: this.onDragLeave,
246
+ onDragEnter: this.onDragEnter
247
+ };
248
+
249
+ if (draggable) {
250
+ (0, _assign.default)(addContentProps, draggableProps, {
251
+ className: (0, _classnames.default)(uploadAddCls, dragAreaCls)
252
+ });
253
+ }
254
+
255
+ const addContent = /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({}, addContentProps), children);
190
256
 
191
257
  if (!showUploadList || !fileList.length) {
192
258
  if (showAddTriggerInList) {
@@ -196,18 +262,39 @@ class Upload extends _baseComponent.default {
196
262
  return null;
197
263
  }
198
264
 
199
- const fileListCls = (0, _classnames.default)("".concat(prefixCls, "-file-list"), {
200
- ["".concat(prefixCls, "-picture-file-list")]: isPicType
201
- });
265
+ return /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
266
+ componentName: "Upload"
267
+ }, locale => /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({}, containerProps), /*#__PURE__*/_react.default.createElement("div", {
268
+ className: mainCls
269
+ }, (0, _map.default)(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList ? addContent : null)));
270
+ };
271
+
272
+ this.renderFileListDefault = () => {
273
+ const {
274
+ showUploadList,
275
+ limit,
276
+ disabled
277
+ } = this.props;
278
+ const {
279
+ fileList: stateFileList
280
+ } = this.state;
281
+ const fileList = this.props.fileList || stateFileList;
282
+ const fileListCls = (0, _classnames.default)("".concat(prefixCls, "-file-list"));
202
283
  const titleCls = "".concat(prefixCls, "-file-list-title");
203
284
  const mainCls = "".concat(prefixCls, "-file-list-main");
204
- const showTitle = limit !== 1 && fileList.length && listType !== _constants.strings.FILE_LIST_PIC;
285
+ const showTitle = limit !== 1 && fileList.length;
205
286
  const showClear = this.props.showClear && !disabled;
287
+ const containerProps = {
288
+ className: fileListCls
289
+ };
290
+
291
+ if (!showUploadList || !fileList.length) {
292
+ return null;
293
+ }
294
+
206
295
  return /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
207
296
  componentName: "Upload"
208
- }, locale => /*#__PURE__*/_react.default.createElement("div", {
209
- className: fileListCls
210
- }, showTitle ? /*#__PURE__*/_react.default.createElement("div", {
297
+ }, locale => /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({}, containerProps), showTitle ? /*#__PURE__*/_react.default.createElement("div", {
211
298
  className: titleCls
212
299
  }, /*#__PURE__*/_react.default.createElement("span", {
213
300
  className: "".concat(titleCls, "-choosen")
@@ -216,7 +303,7 @@ class Upload extends _baseComponent.default {
216
303
  className: "".concat(titleCls, "-clear")
217
304
  }, locale.clear) : null) : null, /*#__PURE__*/_react.default.createElement("div", {
218
305
  className: mainCls
219
- }, (0, _map.default)(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList ? addContent : null)));
306
+ }, (0, _map.default)(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)))));
220
307
  };
221
308
 
222
309
  this.onDrop = e => {
@@ -236,6 +323,28 @@ class Upload extends _baseComponent.default {
236
323
  this.foundation.handleDragEnter(e);
237
324
  };
238
325
 
326
+ this.renderAddContent = () => {
327
+ const {
328
+ draggable,
329
+ children,
330
+ listType
331
+ } = this.props;
332
+ const uploadAddCls = (0, _classnames.default)("".concat(prefixCls, "-add"));
333
+
334
+ if (listType === _constants.strings.FILE_LIST_PIC) {
335
+ return null;
336
+ }
337
+
338
+ if (draggable) {
339
+ return this.renderDragArea();
340
+ }
341
+
342
+ return /*#__PURE__*/_react.default.createElement("div", {
343
+ className: uploadAddCls,
344
+ onClick: this.onClick
345
+ }, children);
346
+ };
347
+
239
348
  this.renderDragArea = () => {
240
349
  const {
241
350
  dragAreaStatus
@@ -422,7 +531,6 @@ class Upload extends _baseComponent.default {
422
531
  ["".concat(prefixCls, "-warning")]: validateStatus === 'warning',
423
532
  ["".concat(prefixCls, "-success")]: validateStatus === 'success'
424
533
  }, className);
425
- const uploadAddCls = (0, _classnames.default)("".concat(prefixCls, "-add"));
426
534
  const inputCls = (0, _classnames.default)("".concat(prefixCls, "-hidden-input"));
427
535
  const inputReplaceCls = (0, _classnames.default)("".concat(prefixCls, "-hidden-input-replace"));
428
536
  const promptCls = (0, _classnames.default)("".concat(prefixCls, "-prompt"));
@@ -431,10 +539,6 @@ class Upload extends _baseComponent.default {
431
539
  directory: 'directory',
432
540
  webkitdirectory: 'webkitdirectory'
433
541
  } : {};
434
- const addContent = listType !== _constants.strings.FILE_LIST_PIC ? /*#__PURE__*/_react.default.createElement("div", {
435
- className: uploadAddCls,
436
- onClick: this.onClick
437
- }, children) : null;
438
542
  return /*#__PURE__*/_react.default.createElement("div", {
439
543
  className: uploadCls,
440
544
  style: style,
@@ -460,7 +564,7 @@ class Upload extends _baseComponent.default {
460
564
  tabIndex: -1,
461
565
  className: inputReplaceCls,
462
566
  ref: this.replaceInputRef
463
- }), draggable ? this.renderDragArea() : addContent, prompt ? /*#__PURE__*/_react.default.createElement("div", {
567
+ }), this.renderAddContent(), prompt ? /*#__PURE__*/_react.default.createElement("div", {
464
568
  className: promptCls
465
569
  }, prompt) : null, validateMessage ? /*#__PURE__*/_react.default.createElement("div", {
466
570
  className: validateMsgCls
@@ -515,7 +619,10 @@ Upload.propTypes = {
515
619
  prompt: _propTypes.default.node,
516
620
  promptPosition: _propTypes.default.oneOf(_constants.strings.PROMPT_POSITION),
517
621
  renderFileItem: _propTypes.default.func,
622
+ renderPicInfo: _propTypes.default.func,
623
+ renderThumbnail: _propTypes.default.func,
518
624
  showClear: _propTypes.default.bool,
625
+ showPicInfo: _propTypes.default.bool,
519
626
  showReplace: _propTypes.default.bool,
520
627
  showRetry: _propTypes.default.bool,
521
628
  showUploadList: _propTypes.default.bool,
@@ -549,6 +656,7 @@ Upload.defaultProps = {
549
656
  onSuccess: _noop2.default,
550
657
  promptPosition: 'right',
551
658
  showClear: true,
659
+ showPicInfo: false,
552
660
  showReplace: false,
553
661
  showRetry: true,
554
662
  showUploadList: true,
@@ -42,12 +42,15 @@ export interface FileItem extends BaseFileItem {
42
42
  validateMessage?: ReactNode;
43
43
  }
44
44
  export interface RenderFileItemProps extends FileItem {
45
+ index?: number;
45
46
  previewFile?: (fileItem: RenderFileItemProps) => ReactNode;
46
47
  listType: UploadListType;
47
48
  onRemove: (props: RenderFileItemProps, e: MouseEvent) => void;
48
49
  onRetry: (props: RenderFileItemProps, e: MouseEvent) => void;
49
50
  onReplace: (props: RenderFileItemProps, e: MouseEvent) => void;
50
51
  key: string;
52
+ showPicInfo?: boolean;
53
+ renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
51
54
  showRetry: boolean;
52
55
  showReplace: boolean;
53
56
  style?: CSSProperties;
@@ -30,6 +30,7 @@ export declare function cloneDeep(value: any, customizer?: (value: any) => void)
30
30
  export declare const getHighLightTextHTML: ({ sourceString, searchWords, option }: GetHighLightTextHTMLProps) => (string | React.ReactElement<{
31
31
  style: Record<string, any>;
32
32
  className: string;
33
+ key: string;
33
34
  }, string | React.JSXElementConstructor<any>>)[];
34
35
  export interface RegisterMediaQueryOption {
35
36
  match?: (e: MediaQueryList | MediaQueryListEvent) => void;
@@ -102,7 +102,7 @@ export const getHighLightTextHTML = _ref => {
102
102
  const markEle = option.highlightTag || 'mark';
103
103
  const highlightClassName = option.highlightClassName || '';
104
104
  const highlightStyle = option.highlightStyle || {};
105
- return _mapInstanceProperty(chunks).call(chunks, chunk => {
105
+ return _mapInstanceProperty(chunks).call(chunks, (chunk, index) => {
106
106
  const {
107
107
  end,
108
108
  start,
@@ -113,7 +113,8 @@ export const getHighLightTextHTML = _ref => {
113
113
  if (highlight) {
114
114
  return /*#__PURE__*/React.createElement(markEle, {
115
115
  style: highlightStyle,
116
- className: highlightClassName
116
+ className: highlightClassName,
117
+ key: text + index
117
118
  }, text);
118
119
  } else {
119
120
  return text;
@@ -146,11 +147,17 @@ export const registerMediaQuery = (media, _ref2) => {
146
147
  }
147
148
 
148
149
  callInInit && handlerMediaChange(mediaQueryList);
149
- mediaQueryList.addEventListener('change', handlerMediaChange);
150
- return () => mediaQueryList.removeEventListener('change', handlerMediaChange);
150
+
151
+ if (Object.prototype.hasOwnProperty.call(mediaQueryList, 'addEventListener')) {
152
+ mediaQueryList.addEventListener('change', handlerMediaChange);
153
+ return () => mediaQueryList.removeEventListener('change', handlerMediaChange);
154
+ }
155
+
156
+ mediaQueryList.addListener(handlerMediaChange);
157
+ return () => mediaQueryList.removeListener(handlerMediaChange);
151
158
  }
152
159
 
153
- return null;
160
+ return () => undefined;
154
161
  };
155
162
  /**
156
163
  * Determine whether the incoming element is a built-in icon
@@ -105,14 +105,18 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
105
105
  showRestTagsPopover: PropTypes.Requireable<boolean>;
106
106
  restTagsPopoverProps: PropTypes.Requireable<object>;
107
107
  max: PropTypes.Requireable<number>;
108
+ separator: PropTypes.Requireable<string>;
108
109
  onExceed: PropTypes.Requireable<(...args: any[]) => any>;
109
110
  onClear: PropTypes.Requireable<(...args: any[]) => any>;
110
111
  loadData: PropTypes.Requireable<(...args: any[]) => any>;
111
112
  onLoad: PropTypes.Requireable<(...args: any[]) => any>;
112
113
  loadedKeys: PropTypes.Requireable<any[]>;
113
114
  disableStrictly: PropTypes.Requireable<boolean>;
115
+ leafOnly: PropTypes.Requireable<boolean>;
116
+ enableLeafClick: PropTypes.Requireable<boolean>;
114
117
  };
115
118
  static defaultProps: {
119
+ leafOnly: boolean;
116
120
  arrowIcon: JSX.Element;
117
121
  stopPropagation: boolean;
118
122
  motion: boolean;
@@ -129,6 +133,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
129
133
  filterLeafOnly: boolean;
130
134
  showRestTagsPopover: boolean;
131
135
  restTagsPopoverProps: {};
136
+ separator: string;
132
137
  size: "default";
133
138
  treeNodeFilterProp: "label";
134
139
  displayProp: "label";
@@ -138,6 +143,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
138
143
  onClear: (...args: any[]) => void;
139
144
  onDropdownVisibleChange: (...args: any[]) => void;
140
145
  onListScroll: (...args: any[]) => void;
146
+ enableLeafClick: boolean;
141
147
  };
142
148
  options: any;
143
149
  isEmpty: boolean;
@@ -145,6 +151,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
145
151
  triggerRef: React.RefObject<HTMLDivElement>;
146
152
  optionsRef: React.RefObject<any>;
147
153
  clickOutsideHandler: any;
154
+ mergeType: string;
148
155
  constructor(props: CascaderProps);
149
156
  get adapter(): CascaderAdapter;
150
157
  static getDerivedStateFromProps(props: CascaderProps, prevState: CascaderState): Partial<CascaderState>;
@@ -1,3 +1,4 @@
1
+ import _flatten from "lodash/flatten";
1
2
  import _noop from "lodash/noop";
2
3
  import _isNumber from "lodash/isNumber";
3
4
  import _isFunction from "lodash/isFunction";
@@ -20,7 +21,7 @@ import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/cascader/c
20
21
  import { numbers as popoverNumbers } from '@douyinfe/semi-foundation/lib/es/popover/constants';
21
22
  import '@douyinfe/semi-foundation/lib/es/cascader/cascader.css';
22
23
  import { IconClear, IconChevronDown } from '@douyinfe/semi-icons';
23
- import { findKeysForValues, convertDataToEntities } from '@douyinfe/semi-foundation/lib/es/cascader/util';
24
+ import { findKeysForValues, convertDataToEntities, calcMergeType } from '@douyinfe/semi-foundation/lib/es/cascader/util';
24
25
  import { calcCheckedKeys, normalizeKeyList, calcDisabledKeys } from '@douyinfe/semi-foundation/lib/es/tree/treeUtil';
25
26
  import ConfigContext from '../configProvider/context';
26
27
  import BaseComponent from '../_base/baseComponent';
@@ -122,6 +123,7 @@ class Cascader extends BaseComponent {
122
123
  dropdownStyle,
123
124
  loadData,
124
125
  emptyContent,
126
+ separator,
125
127
  topSlot,
126
128
  bottomSlot,
127
129
  showNext,
@@ -137,6 +139,7 @@ class Cascader extends BaseComponent {
137
139
  }, topSlot, /*#__PURE__*/React.createElement(Item, {
138
140
  activeKeys: activeKeys,
139
141
  selectedKeys: selectedKeys,
142
+ separator: separator,
140
143
  loadedKeys: loadedKeys,
141
144
  loadingKeys: loadingKeys,
142
145
  onItemClick: this.handleItemClick,
@@ -186,9 +189,9 @@ class Cascader extends BaseComponent {
186
189
  } = this.props;
187
190
  const {
188
191
  checkedKeys,
189
- mergedCheckedKeys
192
+ resolvedCheckedKeys
190
193
  } = this.state;
191
- const realKeys = autoMergeValue ? mergedCheckedKeys : checkedKeys;
194
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
192
195
  const displayTag = [];
193
196
  const hiddenTag = [];
194
197
 
@@ -278,20 +281,23 @@ class Cascader extends BaseComponent {
278
281
  const {
279
282
  disabled,
280
283
  triggerRender,
281
- multiple,
282
- autoMergeValue
284
+ multiple
283
285
  } = this.props;
284
286
  const {
285
287
  selectedKeys,
286
288
  inputValue,
287
289
  inputPlaceHolder,
288
- mergedCheckedKeys,
290
+ resolvedCheckedKeys,
289
291
  checkedKeys
290
292
  } = this.state;
291
293
  let realValue;
292
294
 
293
295
  if (multiple) {
294
- realValue = autoMergeValue ? mergedCheckedKeys : checkedKeys;
296
+ if (this.mergeType === strings.NONE_MERGE_TYPE) {
297
+ realValue = checkedKeys;
298
+ } else {
299
+ realValue = resolvedCheckedKeys;
300
+ }
295
301
  } else {
296
302
  realValue = [...selectedKeys][0];
297
303
  }
@@ -471,8 +477,8 @@ class Cascader extends BaseComponent {
471
477
  /* Key of half checked node, when multiple */
472
478
  halfCheckedKeys: new _Set([]),
473
479
 
474
- /* Auto merged checkedKeys, when multiple */
475
- mergedCheckedKeys: new _Set([]),
480
+ /* Auto merged checkedKeys or leaf checkedKeys, when multiple */
481
+ resolvedCheckedKeys: new _Set([]),
476
482
 
477
483
  /* Keys of loaded item */
478
484
  loadedKeys: new _Set(),
@@ -485,6 +491,7 @@ class Cascader extends BaseComponent {
485
491
  };
486
492
  this.options = {};
487
493
  this.isEmpty = false;
494
+ this.mergeType = calcMergeType(props.autoMergeValue, props.leafOnly);
488
495
  this.inputRef = /*#__PURE__*/React.createRef();
489
496
  this.triggerRef = /*#__PURE__*/React.createRef();
490
497
  this.optionsRef = /*#__PURE__*/React.createRef();
@@ -627,7 +634,9 @@ class Cascader extends BaseComponent {
627
634
  multiple,
628
635
  value,
629
636
  defaultValue,
630
- onChangeWithObject
637
+ onChangeWithObject,
638
+ leafOnly,
639
+ autoMergeValue
631
640
  } = props;
632
641
  const {
633
642
  prevProps
@@ -692,24 +701,19 @@ class Cascader extends BaseComponent {
692
701
  realKeys = formatKeys;
693
702
  }
694
703
 
695
- let checkedKeys = new _Set([]);
696
- let halfCheckedKeys = new _Set([]);
697
-
698
- _forEachInstanceProperty(realKeys).call(realKeys, v => {
699
- const calRes = calcCheckedKeys(v, keyEntities);
700
- checkedKeys = new _Set([...checkedKeys, ...calRes.checkedKeys]);
701
- halfCheckedKeys = new _Set([...halfCheckedKeys, ...calRes.halfCheckedKeys]);
702
- }); // disableStrictly
703
-
704
+ const calRes = calcCheckedKeys(_flatten(realKeys), keyEntities);
705
+ const checkedKeys = new _Set(calRes.checkedKeys);
706
+ const halfCheckedKeys = new _Set(calRes.halfCheckedKeys); // disableStrictly
704
707
 
705
708
  if (props.disableStrictly) {
706
709
  newState.disabledKeys = calcDisabledKeys(keyEntities);
707
710
  }
708
711
 
712
+ const isLeafOnlyMerge = calcMergeType(autoMergeValue, leafOnly) === strings.LEAF_ONLY_MERGE_TYPE;
709
713
  newState.prevProps = props;
710
714
  newState.checkedKeys = checkedKeys;
711
715
  newState.halfCheckedKeys = halfCheckedKeys;
712
- newState.mergedCheckedKeys = new _Set(normalizeKeyList(checkedKeys, keyEntities));
716
+ newState.resolvedCheckedKeys = new _Set(normalizeKeyList(checkedKeys, keyEntities, isLeafOnlyMerge));
713
717
  }
714
718
  }
715
719
 
@@ -743,7 +747,6 @@ class Cascader extends BaseComponent {
743
747
  const {
744
748
  size,
745
749
  disabled,
746
- autoMergeValue,
747
750
  placeholder,
748
751
  maxTagCount,
749
752
  showRestTagsPopover,
@@ -753,11 +756,11 @@ class Cascader extends BaseComponent {
753
756
  inputValue,
754
757
  checkedKeys,
755
758
  keyEntities,
756
- mergedCheckedKeys
759
+ resolvedCheckedKeys
757
760
  } = this.state;
758
761
  const tagInputcls = cls("".concat(prefixcls, "-tagInput-wrapper"));
759
762
  const tagValue = [];
760
- const realKeys = autoMergeValue ? mergedCheckedKeys : checkedKeys;
763
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
761
764
 
762
765
  _forEachInstanceProperty(_context3 = [...realKeys]).call(_context3, checkedKey => {
763
766
  if (!_isEmpty(keyEntities[checkedKey])) {
@@ -907,14 +910,18 @@ Cascader.propTypes = {
907
910
  showRestTagsPopover: PropTypes.bool,
908
911
  restTagsPopoverProps: PropTypes.object,
909
912
  max: PropTypes.number,
913
+ separator: PropTypes.string,
910
914
  onExceed: PropTypes.func,
911
915
  onClear: PropTypes.func,
912
916
  loadData: PropTypes.func,
913
917
  onLoad: PropTypes.func,
914
918
  loadedKeys: PropTypes.array,
915
- disableStrictly: PropTypes.bool
919
+ disableStrictly: PropTypes.bool,
920
+ leafOnly: PropTypes.bool,
921
+ enableLeafClick: PropTypes.bool
916
922
  };
917
923
  Cascader.defaultProps = {
924
+ leafOnly: false,
918
925
  arrowIcon: /*#__PURE__*/React.createElement(IconChevronDown, null),
919
926
  stopPropagation: true,
920
927
  motion: true,
@@ -931,6 +938,7 @@ Cascader.defaultProps = {
931
938
  filterLeafOnly: true,
932
939
  showRestTagsPopover: false,
933
940
  restTagsPopoverProps: {},
941
+ separator: ' / ',
934
942
  size: 'default',
935
943
  treeNodeFilterProp: 'label',
936
944
  displayProp: 'label',
@@ -939,6 +947,7 @@ Cascader.defaultProps = {
939
947
  onExceed: _noop,
940
948
  onClear: _noop,
941
949
  onDropdownVisibleChange: _noop,
942
- onListScroll: _noop
950
+ onListScroll: _noop,
951
+ enableLeafClick: false
943
952
  };
944
953
  export default Cascader;
@@ -33,6 +33,7 @@ export interface CascaderItemProps {
33
33
  emptyContent: React.ReactNode;
34
34
  loadData: (selectOptions: CascaderData[]) => Promise<void>;
35
35
  data: Array<Data | Entity>;
36
+ separator: string;
36
37
  multiple: boolean;
37
38
  checkedKeys: Set<string>;
38
39
  halfCheckedKeys: Set<string>;
@@ -50,6 +51,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
50
51
  checkedKeys: PropTypes.Requireable<object>;
51
52
  halfCheckedKeys: PropTypes.Requireable<object>;
52
53
  onItemCheckboxClick: PropTypes.Requireable<(...args: any[]) => any>;
54
+ separator: PropTypes.Requireable<string>;
53
55
  keyword: PropTypes.Requireable<string>;
54
56
  };
55
57
  static defaultProps: {
@@ -117,7 +117,8 @@ export default class Item extends PureComponent {
117
117
  this.highlight = searchText => {
118
118
  const content = [];
119
119
  const {
120
- keyword
120
+ keyword,
121
+ separator
121
122
  } = this.props;
122
123
 
123
124
  _forEachInstanceProperty(searchText).call(searchText, (item, idx) => {
@@ -141,7 +142,7 @@ export default class Item extends PureComponent {
141
142
  }
142
143
 
143
144
  if (idx !== searchText.length - 1) {
144
- content.push(' / ');
145
+ content.push(separator);
145
146
  }
146
147
  });
147
148
 
@@ -313,6 +314,7 @@ Item.propTypes = {
313
314
  checkedKeys: PropTypes.object,
314
315
  halfCheckedKeys: PropTypes.object,
315
316
  onItemCheckboxClick: PropTypes.func,
317
+ separator: PropTypes.string,
316
318
  keyword: PropTypes.string
317
319
  };
318
320
  Item.defaultProps = {
@@ -241,6 +241,10 @@ export default class DatePicker extends BaseComponent {
241
241
  }
242
242
 
243
243
  this.clickOutSideHandler = e => {
244
+ if (this.adapter.needConfirm()) {
245
+ return;
246
+ }
247
+
244
248
  const triggerEl = this.triggerElRef && this.triggerElRef.current;
245
249
  const panelEl = this.panelRef && this.panelRef.current;
246
250
  const isInTrigger = triggerEl && triggerEl.contains(e.target);
@@ -81,6 +81,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
81
81
  renderMonth(month: Date, panelType: PanelType): JSX.Element;
82
82
  handleWeeksRowNumChange: (weeksRowNum: number, panelType: PanelType) => void;
83
83
  reselect: () => void;
84
+ getYAMOpenType: () => "left" | "right" | "none" | "both";
84
85
  renderTimePicker(panelType: PanelType, panelDetail: MonthInfo): JSX.Element;
85
86
  renderYearAndMonth(panelType: PanelType, panelDetail: MonthInfo): JSX.Element;
86
87
  renderSwitch(panelType: PanelType): JSX.Element;
@@ -124,6 +124,10 @@ export default class MonthsGrid extends BaseComponent {
124
124
  });
125
125
  };
126
126
 
127
+ this.getYAMOpenType = () => {
128
+ return this.foundation.getYAMOpenType();
129
+ };
130
+
127
131
  let nowDate = _Array$isArray(props.defaultPickerValue) ? props.defaultPickerValue[0] : props.defaultPickerValue;
128
132
  const validFormat = props.format || getDefaultFormatTokenByType(props.type);
129
133
 
@@ -615,9 +619,11 @@ export default class MonthsGrid extends BaseComponent {
615
619
  content = 'year month';
616
620
  }
617
621
 
622
+ const yearOpenType = this.getYAMOpenType();
618
623
  return /*#__PURE__*/React.createElement("div", {
619
624
  className: monthGridCls,
620
625
  "x-type": type,
626
+ "x-panel-yearandmonth-open-type": yearOpenType,
621
627
  ref: current => this.cacheRefCurrent('monthGrid', current)
622
628
  }, content);
623
629
  }