@douyinfe/semi-ui 2.17.0-alpha.1 → 2.17.0-beta.0

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 (90) hide show
  1. package/_base/_story/a11y.jsx +2 -2
  2. package/avatar/__test__/avatar.test.js +3 -3
  3. package/avatar/interface.ts +1 -1
  4. package/collapse/__test__/collapse.test.js +22 -2
  5. package/collapse/_story/accordion.stories.js +2 -2
  6. package/collapse/item.tsx +20 -6
  7. package/collapsible/_story/collapsible.stories.js +6 -6
  8. package/configProvider/_story/RTLDirection/RTLForm.jsx +1 -1
  9. package/datePicker/__test__/datePicker.test.js +5 -5
  10. package/datePicker/_story/datePicker.stories.js +138 -22
  11. package/datePicker/datePicker.tsx +42 -7
  12. package/datePicker/monthsGrid.tsx +22 -10
  13. package/datePicker/quickControl.tsx +62 -16
  14. package/datePicker/yearAndMonth.tsx +31 -5
  15. package/dist/css/semi.css +327 -46
  16. package/dist/css/semi.min.css +1 -1
  17. package/dist/umd/semi-ui.js +45864 -45368
  18. package/dist/umd/semi-ui.js.map +1 -1
  19. package/dist/umd/semi-ui.min.js +1 -1
  20. package/dist/umd/semi-ui.min.js.map +1 -1
  21. package/lib/cjs/avatar/interface.d.ts +1 -1
  22. package/lib/cjs/collapse/item.d.ts +8 -0
  23. package/lib/cjs/collapse/item.js +19 -8
  24. package/lib/cjs/datePicker/datePicker.d.ts +3 -0
  25. package/lib/cjs/datePicker/datePicker.js +56 -9
  26. package/lib/cjs/datePicker/monthsGrid.d.ts +3 -0
  27. package/lib/cjs/datePicker/monthsGrid.js +14 -3
  28. package/lib/cjs/datePicker/quickControl.d.ts +6 -0
  29. package/lib/cjs/datePicker/quickControl.js +61 -14
  30. package/lib/cjs/datePicker/yearAndMonth.d.ts +3 -0
  31. package/lib/cjs/datePicker/yearAndMonth.js +15 -3
  32. package/lib/cjs/popover/index.d.ts +3 -0
  33. package/lib/cjs/popover/index.js +4 -2
  34. package/lib/cjs/select/index.d.ts +6 -1
  35. package/lib/cjs/select/index.js +130 -72
  36. package/lib/cjs/select/option.js +4 -2
  37. package/lib/cjs/tag/index.js +6 -4
  38. package/lib/cjs/tag/interface.d.ts +1 -0
  39. package/lib/cjs/tagInput/index.d.ts +13 -1
  40. package/lib/cjs/tagInput/index.js +217 -91
  41. package/lib/cjs/timePicker/TimePicker.js +1 -1
  42. package/lib/cjs/tooltip/index.d.ts +4 -0
  43. package/lib/cjs/tooltip/index.js +5 -3
  44. package/lib/cjs/typography/base.js +3 -15
  45. package/lib/cjs/typography/text.js +1 -11
  46. package/lib/es/avatar/interface.d.ts +1 -1
  47. package/lib/es/collapse/item.d.ts +8 -0
  48. package/lib/es/collapse/item.js +19 -8
  49. package/lib/es/datePicker/datePicker.d.ts +3 -0
  50. package/lib/es/datePicker/datePicker.js +56 -9
  51. package/lib/es/datePicker/monthsGrid.d.ts +3 -0
  52. package/lib/es/datePicker/monthsGrid.js +14 -3
  53. package/lib/es/datePicker/quickControl.d.ts +6 -0
  54. package/lib/es/datePicker/quickControl.js +61 -15
  55. package/lib/es/datePicker/yearAndMonth.d.ts +3 -0
  56. package/lib/es/datePicker/yearAndMonth.js +14 -3
  57. package/lib/es/popover/index.d.ts +3 -0
  58. package/lib/es/popover/index.js +4 -2
  59. package/lib/es/select/index.d.ts +6 -1
  60. package/lib/es/select/index.js +129 -71
  61. package/lib/es/select/option.js +4 -2
  62. package/lib/es/tag/index.js +6 -4
  63. package/lib/es/tag/interface.d.ts +1 -0
  64. package/lib/es/tagInput/index.d.ts +13 -1
  65. package/lib/es/tagInput/index.js +217 -93
  66. package/lib/es/timePicker/TimePicker.js +1 -1
  67. package/lib/es/tooltip/index.d.ts +4 -0
  68. package/lib/es/tooltip/index.js +5 -3
  69. package/lib/es/typography/base.js +3 -15
  70. package/lib/es/typography/text.js +1 -10
  71. package/package.json +7 -7
  72. package/popover/index.tsx +4 -1
  73. package/select/__test__/select.test.js +5 -3
  74. package/select/_story/select.stories.js +1 -1
  75. package/select/_story/select.stories.tsx +2 -2
  76. package/select/index.tsx +65 -30
  77. package/select/option.tsx +2 -0
  78. package/table/_story/Perf/Render/complex.jsx +1 -1
  79. package/table/_story/Perf/Render/resizableSelection.jsx +1 -1
  80. package/tag/index.tsx +3 -2
  81. package/tag/interface.ts +1 -0
  82. package/tagInput/_story/tagInput.stories.js +20 -2
  83. package/tagInput/index.tsx +126 -26
  84. package/timePicker/TimePicker.tsx +1 -1
  85. package/tooltip/index.tsx +5 -2
  86. package/typography/_story/typography.stories.js +3 -15
  87. package/typography/base.tsx +4 -9
  88. package/typography/text.tsx +1 -9
  89. package/upload/__test__/upload.test.js +9 -9
  90. package/upload/_story/upload.stories.js +5 -5
@@ -76,6 +76,9 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
76
76
  onPanelChange: PropTypes.func,
77
77
  focusRecordsRef: PropTypes.object,
78
78
  triggerRender: PropTypes.func,
79
+ presetPosition: PropTypes.oneOf(strings.PRESET_POSITION_SET),
80
+ renderQuickControls: PropTypes.node,
81
+ renderDateInput: PropTypes.node
79
82
  };
80
83
 
81
84
  static defaultProps = {
@@ -600,9 +603,10 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
600
603
  );
601
604
  }
602
605
 
606
+
603
607
  render() {
604
608
  const { monthLeft, monthRight } = this.state;
605
- const { type, insetInput } = this.props;
609
+ const { type, insetInput, presetPosition, renderQuickControls, renderDateInput } = this.props;
606
610
  const monthGridCls = classnames({
607
611
  [`${prefixCls }-month-grid`]: true,
608
612
  });
@@ -622,15 +626,23 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
622
626
  const yearOpenType = this.getYAMOpenType();
623
627
 
624
628
  return (
625
- <div
626
- className={monthGridCls}
627
- x-type={type}
628
- x-panel-yearandmonth-open-type={yearOpenType}
629
- // FIXME:
630
- x-insetinput={insetInput ? "true" : "false"}
631
- ref={current => this.cacheRefCurrent('monthGrid', current)}
632
- >
633
- {content}
629
+ <div style={{ display: 'flex' }}>
630
+ {presetPosition === "left" && renderQuickControls}
631
+ <div>
632
+ {renderDateInput}
633
+ <div
634
+ className={monthGridCls}
635
+ x-type={type}
636
+ x-panel-yearandmonth-open-type={yearOpenType}
637
+ // FIXME:
638
+ x-insetinput={insetInput ? "true" : "false"}
639
+ x-preset-position={renderQuickControls === null ? 'null' : presetPosition}
640
+ ref={current => this.cacheRefCurrent('monthGrid', current)}
641
+ >
642
+ {content}
643
+ </div>
644
+ </div>
645
+ {presetPosition === "right" && renderQuickControls}
634
646
  </div>
635
647
  );
636
648
  }
@@ -2,52 +2,98 @@
2
2
  import React, { PureComponent } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import PropTypes from 'prop-types';
5
- import { cssClasses } from '@douyinfe/semi-foundation/datePicker/constants';
5
+ import { cssClasses, strings } from '@douyinfe/semi-foundation/datePicker/constants';
6
6
  import Button from '../button/index';
7
+ import Typography from '../typography/index';
7
8
  import { noop } from '@douyinfe/semi-foundation/utils/function';
8
9
  import { PresetsType, PresetType } from '@douyinfe/semi-foundation/datePicker/foundation';
9
10
 
10
11
  const prefixCls = cssClasses.PREFIX;
12
+ const { Text } = Typography;
11
13
 
12
14
  export interface QuickControlProps {
13
15
  presets: PresetsType;
16
+ presetPosition: typeof strings.PRESET_POSITION_SET[number];
14
17
  onPresetClick: (preset: PresetType, e: React.MouseEvent) => void;
15
18
  type: string;
19
+ insetInput: boolean;
16
20
  }
17
21
 
18
22
  class QuickControl extends PureComponent<QuickControlProps> {
19
23
  static propTypes = {
20
24
  presets: PropTypes.array,
25
+ presetPosition: PropTypes.oneOf(strings.PRESET_POSITION_SET),
21
26
  onPresetClick: PropTypes.func,
22
- type: PropTypes.string
27
+ type: PropTypes.string,
28
+ insetInput: PropTypes.bool
23
29
  };
24
30
 
25
31
  static defaultProps = {
26
32
  presets: [] as PresetsType,
33
+ presetPosition: 'bottom',
27
34
  onPresetClick: noop,
28
35
  };
29
36
 
30
37
  render() {
31
- const { presets, onPresetClick, type } = this.props;
38
+ const { presets, onPresetClick, type, presetPosition, insetInput } = this.props;
39
+ const isTypeRange = type === 'dateRange' || type === 'dateTimeRange';
40
+ const isPanelTopAndBottom = presetPosition === 'top' || presetPosition === 'bottom';
41
+ const isMonth = type === 'month';
42
+ const isTopAndBottomRange = isPanelTopAndBottom && isTypeRange;
43
+ const isTopAndBottomMonth = isPanelTopAndBottom && isMonth;
44
+
32
45
  const wrapperCls = classNames(`${prefixCls}-quick-control`, {
33
- [`${prefixCls}-quick-control-${type}`]: type
46
+ [`${prefixCls}-quick-control-${type}`]: type,
47
+ [`${prefixCls}-quick-control-${presetPosition}`]: true,
48
+ });
49
+ const headerCls = classNames({
50
+ [`${prefixCls}-quick-control-header`]: true,
51
+ });
52
+ const contentWrapperCls = classNames({
53
+ [`${prefixCls}-quick-control-${presetPosition}-content-wrapper`]: true,
54
+ });
55
+ const contentCls = classNames({
56
+ [`${prefixCls}-quick-control-${presetPosition}-content`]: !isTopAndBottomRange && !isTopAndBottomMonth,
57
+ [`${prefixCls}-quick-control-${presetPosition}-range-content`]: isTopAndBottomRange,
58
+ [`${prefixCls}-quick-control-${presetPosition}-month-content`]: isTopAndBottomMonth,
34
59
  });
35
- const itemCls = classNames(`${prefixCls}-quick-control-item`);
60
+ const itemCls = classNames({
61
+ [`${prefixCls}-quick-control-${presetPosition}-content-item`]: !isTopAndBottomRange && !isTopAndBottomMonth,
62
+ [`${prefixCls}-quick-control-${presetPosition}-range-content-item`]: isTopAndBottomRange,
63
+ [`${prefixCls}-quick-control-${presetPosition}-month-content-item`]: isTopAndBottomMonth,
64
+ });
65
+ const ellipsisCls = classNames({
66
+ [`${prefixCls}-quick-control-${presetPosition}-content-item-ellipsis`]: !isTopAndBottomRange && !isTopAndBottomMonth,
67
+ [`${prefixCls}-quick-control-${presetPosition}-range-content-item-ellipsis`]: isTopAndBottomRange,
68
+ [`${prefixCls}-quick-control-${presetPosition}-month-content-item-ellipsis`]: isTopAndBottomMonth,
69
+ });
70
+
71
+
36
72
  if (!presets.length) {
37
73
  return null;
38
74
  }
39
75
  return (
40
- <div className={wrapperCls}>
41
- {presets.map((item, index) => {
42
- const _item: PresetType = typeof item === 'function' ? item() : item;
43
- return (
44
- <div className={itemCls} onClick={e => onPresetClick(_item, e)} key={index}>
45
- <Button size="small" theme="borderless" type="primary">
46
- <span>{_item.text}</span>
47
- </Button>
48
- </div>
49
- );
50
- })}
76
+ <div className={wrapperCls} x-insetinput={insetInput ? "true" : "false"}>
77
+ { !isPanelTopAndBottom && <div className={headerCls}>快捷选择</div>}
78
+ <div className={contentWrapperCls}>
79
+ <div className={contentCls}>
80
+ {presets.map((item, index) => {
81
+ const _item: PresetType = typeof item === 'function' ? item() : item;
82
+ return (
83
+ <Button size="small" type="primary" onClick={e => onPresetClick(_item, e)} key={index}>
84
+ <div className={itemCls}>
85
+ <Text
86
+ ellipsis={{ showTooltip: true }}
87
+ className={ellipsisCls}
88
+ >
89
+ {_item.text}
90
+ </Text>
91
+ </div>
92
+ </Button>
93
+ );
94
+ })}
95
+ </div>
96
+ </div>
51
97
  </div>
52
98
  );
53
99
  }
@@ -15,6 +15,8 @@ import { BASE_CLASS_PREFIX } from '@douyinfe/semi-foundation/base/constants';
15
15
  import { noop, stubFalse } from 'lodash';
16
16
  import { setYear, setMonth } from 'date-fns';
17
17
  import { Locale } from '../locale/interface';
18
+ import { strings } from '@douyinfe/semi-foundation/datePicker/constants';
19
+
18
20
 
19
21
  const prefixCls = `${BASE_CLASS_PREFIX}-datepicker`;
20
22
 
@@ -36,6 +38,9 @@ class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonthState> {
36
38
  noBackBtn: PropTypes.bool,
37
39
  disabledDate: PropTypes.func,
38
40
  density: PropTypes.string,
41
+ presetPosition: PropTypes.oneOf(strings.PRESET_POSITION_SET),
42
+ renderQuickControls: PropTypes.node,
43
+ renderDateInput: PropTypes.node
39
44
  };
40
45
 
41
46
  static defaultProps = {
@@ -195,7 +200,7 @@ class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonthState> {
195
200
  };
196
201
 
197
202
  render() {
198
- const { locale, noBackBtn, density } = this.props;
203
+ const { locale, noBackBtn, density, presetPosition, renderQuickControls, renderDateInput } = this.props;
199
204
  const prefix = `${prefixCls}-yearmonth-header`;
200
205
  // i18n
201
206
  const selectDateText = locale.selectDate;
@@ -216,10 +221,31 @@ class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonthState> {
216
221
  </IconButton>
217
222
  </div>
218
223
  )}
219
- <ScrollList>
220
- {this.renderColYear()}
221
- {this.renderColMonth()}
222
- </ScrollList>
224
+ {
225
+ presetPosition ? (
226
+ <div style={{ display: 'flex' }}>
227
+ {presetPosition === "left" && renderQuickControls}
228
+ <div>
229
+ {renderDateInput}
230
+ <ScrollList>
231
+ {this.renderColYear()}
232
+ {this.renderColMonth()}
233
+ </ScrollList>
234
+ </div>
235
+ {presetPosition === "right" && renderQuickControls}
236
+ </div>
237
+ ) :
238
+ <>
239
+ {renderDateInput}
240
+ <ScrollList>
241
+ {this.renderColYear()}
242
+ {this.renderColMonth()}
243
+ </ScrollList>
244
+ </>
245
+
246
+
247
+ }
248
+
223
249
  </React.Fragment>
224
250
  );
225
251
  }