@douyinfe/semi-ui 2.1.5 → 2.2.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 (104) 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 +85 -2
  10. package/datePicker/_story/datePicker.stories.js +29 -1
  11. package/datePicker/_story/v2/YearButton.jsx +17 -0
  12. package/datePicker/_story/v2/index.js +1 -0
  13. package/datePicker/monthsGrid.tsx +12 -1
  14. package/datePicker/navigation.tsx +55 -29
  15. package/descriptions/__test__/descriptions.test.js +27 -1
  16. package/descriptions/_story/descriptions.stories.js +52 -2
  17. package/descriptions/item.tsx +1 -1
  18. package/dist/css/semi.css +49 -25
  19. package/dist/css/semi.min.css +1 -1
  20. package/dist/umd/semi-ui.js +839 -253
  21. package/dist/umd/semi-ui.js.map +1 -1
  22. package/dist/umd/semi-ui.min.js +1 -1
  23. package/dist/umd/semi-ui.min.js.map +1 -1
  24. package/empty/index.tsx +2 -2
  25. package/form/_story/form.stories.js +0 -67
  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/monthsGrid.d.ts +1 -0
  34. package/lib/cjs/datePicker/monthsGrid.js +6 -0
  35. package/lib/cjs/datePicker/navigation.js +47 -7
  36. package/lib/cjs/descriptions/item.js +1 -1
  37. package/lib/cjs/empty/index.d.ts +2 -2
  38. package/lib/cjs/empty/index.js +19 -18
  39. package/lib/cjs/form/baseForm.d.ts +5 -0
  40. package/lib/cjs/form/field.d.ts +5 -0
  41. package/lib/cjs/locale/source/es.d.ts +7 -0
  42. package/lib/cjs/locale/source/es.js +168 -0
  43. package/lib/cjs/pagination/index.js +9 -4
  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 +13 -9
  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/upload/fileCard.d.ts +2 -0
  51. package/lib/cjs/upload/fileCard.js +70 -45
  52. package/lib/cjs/upload/index.d.ts +23 -2
  53. package/lib/cjs/upload/index.js +133 -25
  54. package/lib/cjs/upload/interface.d.ts +3 -0
  55. package/lib/es/_utils/index.d.ts +1 -0
  56. package/lib/es/_utils/index.js +12 -5
  57. package/lib/es/cascader/index.d.ts +7 -0
  58. package/lib/es/cascader/index.js +34 -25
  59. package/lib/es/cascader/item.d.ts +2 -0
  60. package/lib/es/cascader/item.js +4 -2
  61. package/lib/es/datePicker/monthsGrid.d.ts +1 -0
  62. package/lib/es/datePicker/monthsGrid.js +6 -0
  63. package/lib/es/datePicker/navigation.js +48 -8
  64. package/lib/es/descriptions/item.js +1 -1
  65. package/lib/es/empty/index.d.ts +2 -2
  66. package/lib/es/empty/index.js +19 -18
  67. package/lib/es/form/baseForm.d.ts +5 -0
  68. package/lib/es/form/field.d.ts +5 -0
  69. package/lib/es/locale/source/es.d.ts +7 -0
  70. package/lib/es/locale/source/es.js +157 -0
  71. package/lib/es/pagination/index.js +8 -4
  72. package/lib/es/rating/item.js +1 -1
  73. package/lib/es/select/index.d.ts +9 -0
  74. package/lib/es/select/index.js +17 -9
  75. package/lib/es/tabs/index.js +1 -5
  76. package/lib/es/timeline/item.d.ts +3 -0
  77. package/lib/es/timeline/item.js +9 -4
  78. package/lib/es/upload/fileCard.d.ts +2 -0
  79. package/lib/es/upload/fileCard.js +69 -44
  80. package/lib/es/upload/index.d.ts +23 -2
  81. package/lib/es/upload/index.js +133 -24
  82. package/lib/es/upload/interface.d.ts +3 -0
  83. package/locale/source/es.ts +160 -0
  84. package/navigation/__test__/navigation.test.js +4 -4
  85. package/navigation/_story/AutoOpen/index.js +1 -1
  86. package/navigation/_story/WithChildren/index.js +1 -1
  87. package/navigation/_story/navigation.stories.js +1 -1
  88. package/navigation/_story/navigation.stories.tsx +4 -4
  89. package/package.json +17 -9
  90. package/pagination/_story/pagination.stories.js +11 -0
  91. package/pagination/index.tsx +9 -4
  92. package/popover/Arrow.tsx +1 -1
  93. package/rating/item.tsx +1 -1
  94. package/select/_story/select.stories.js +39 -14
  95. package/select/index.tsx +18 -7
  96. package/table/_story/DynamicFilters/index.js +13 -16
  97. package/tabs/index.tsx +1 -1
  98. package/timeline/_story/timeline.stories.js +70 -6
  99. package/timeline/item.tsx +7 -2
  100. package/tooltip/_story/tooltip.stories.js +1 -1
  101. package/upload/__test__/upload.test.js +50 -1
  102. package/upload/fileCard.tsx +110 -95
  103. package/upload/index.tsx +147 -53
  104. package/upload/interface.ts +3 -0
package/cascader/item.tsx CHANGED
@@ -54,6 +54,7 @@ export interface CascaderItemProps {
54
54
  emptyContent: React.ReactNode;
55
55
  loadData: (selectOptions: CascaderData[]) => Promise<void>;
56
56
  data: Array<Data | Entity>;
57
+ separator: string;
57
58
  multiple: boolean;
58
59
  checkedKeys: Set<string>;
59
60
  halfCheckedKeys: Set<string>;
@@ -75,6 +76,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
75
76
  checkedKeys: PropTypes.object,
76
77
  halfCheckedKeys: PropTypes.object,
77
78
  onItemCheckboxClick: PropTypes.func,
79
+ separator: PropTypes.string,
78
80
  keyword: PropTypes.string
79
81
  };
80
82
 
@@ -142,7 +144,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
142
144
 
143
145
  highlight = (searchText: React.ReactNode[]) => {
144
146
  const content: React.ReactNode[] = [];
145
- const { keyword } = this.props;
147
+ const { keyword, separator } = this.props;
146
148
  searchText.forEach((item, idx) => {
147
149
  if (typeof item === 'string' && includes(item, keyword)) {
148
150
  item.split(keyword).forEach((node, index) => {
@@ -159,7 +161,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
159
161
  content.push(item);
160
162
  }
161
163
  if (idx !== searchText.length - 1) {
162
- content.push(' / ');
164
+ content.push(separator);
163
165
  }
164
166
  });
165
167
  return content;
@@ -280,10 +280,12 @@ describe(`DatePicker`, () => {
280
280
  const rightPanel = document.querySelector(`.${BASE_CLASS_PREFIX}-datepicker-month-grid-right`);
281
281
  const rightNavBtns = rightPanel.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-navigation .${BASE_CLASS_PREFIX}-button`);
282
282
 
283
- _.get(rightNavBtns, 1).click();
283
+ // 点击右边面板下一月
284
+ _.get(rightNavBtns, 2).click();
284
285
  await sleep();
285
286
 
286
- _.times(leftPrevClickTimes).forEach(() => _.first(leftNavBtns).click());
287
+ // 点击左边面板上一月
288
+ _.times(leftPrevClickTimes).forEach(() => _.get(leftNavBtns, 1).click());
287
289
 
288
290
  const leftSecondWeek = leftPanel.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-week`)[1];
289
291
  const leftSecondWeekDays = leftSecondWeek.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-day`);
@@ -870,4 +872,85 @@ describe(`DatePicker`, () => {
870
872
  expect(allSeparators[0].textContent.trim()).toBe(rangeSeparator);
871
873
  expect(allSeparators[1].textContent.trim()).toBe(rangeSeparator);
872
874
  });
875
+
876
+ /**
877
+ * fix https://github.com/DouyinFE/semi-design/issues/422
878
+ */
879
+ it('test input year length larger than 4', async () => {
880
+ const props = {
881
+ motion: false,
882
+ defaultOpen: true,
883
+ defaultValue: '2021-12-21',
884
+ };
885
+ const handleChange = sinon.spy();
886
+ const elem = mount(
887
+ <DatePicker {...props} onChange={handleChange} />
888
+ );
889
+
890
+ elem.find('input').simulate('change', { target: { value: '20221-12-21' }});
891
+ expect(handleChange.called).toBeFalsy();
892
+ });
893
+
894
+ it('test click next/prev year buttons', () => {
895
+ let props = {
896
+ type: 'dateRange',
897
+ motion: false,
898
+ style: { width: 300 },
899
+ defaultPickerValue: new Date('2021-12-01'),
900
+ defaultOpen: true,
901
+ };
902
+ const elem = mount(<DatePicker {...props} />);
903
+
904
+ const leftPanel = document.querySelector(`.semi-datepicker-month-grid-left`);
905
+ const leftNavBtns = leftPanel.querySelector(`.semi-datepicker-navigation`).children;
906
+ const rightPanel = document.querySelector(`.semi-datepicker-month-grid-right`);
907
+ const rightNavBtns = rightPanel.querySelector(`.semi-datepicker-navigation`).children;
908
+
909
+ // 点击左边面板上一年
910
+ _.get(leftNavBtns, 0).click();
911
+ expect(document.querySelector(`.semi-datepicker-month-grid-left .semi-datepicker-navigation-month`).textContent).toBe('2020年 12月');
912
+ // 点击左边面板下一年
913
+ _.get(leftNavBtns, 4).click();
914
+ expect(document.querySelector(`.semi-datepicker-month-grid-left .semi-datepicker-navigation-month`).textContent).toBe('2021年 12月');
915
+
916
+ // 点击右边面板下一年
917
+ _.get(rightNavBtns, 4).click();
918
+ expect(document.querySelector(`.semi-datepicker-month-grid-right .semi-datepicker-navigation-month`).textContent).toBe('2023年 1月');
919
+ // 点击右边面板上一年
920
+ _.get(rightNavBtns, 0).click();
921
+ expect(document.querySelector(`.semi-datepicker-month-grid-right .semi-datepicker-navigation-month`).textContent).toBe('2022年 1月');
922
+ });
923
+
924
+ const testMonthSyncChange = type => {
925
+ let props = {
926
+ type,
927
+ motion: false,
928
+ style: { width: 300 },
929
+ defaultPickerValue: new Date('2021-12-01'),
930
+ defaultOpen: true,
931
+ };
932
+ const elem = mount(<DatePicker {...props} />);
933
+
934
+ const leftPanel = document.querySelector(`.semi-datepicker-month-grid-left`);
935
+ const leftNavBtns = leftPanel.querySelector(`.semi-datepicker-navigation`).children;
936
+ const rightPanel = document.querySelector(`.semi-datepicker-month-grid-right`);
937
+ const rightNavBtns = rightPanel.querySelector(`.semi-datepicker-navigation`).children;
938
+
939
+ // 点击左边面板下一月,自动切换右面板
940
+ _.get(leftNavBtns, 3).click();
941
+ expect(document.querySelector(`.semi-datepicker-month-grid-left .semi-datepicker-navigation-month`).textContent).toBe('2022年 1月');
942
+ expect(document.querySelector(`.semi-datepicker-month-grid-right .semi-datepicker-navigation-month`).textContent).toBe('2022年 2月');
943
+ // 点击右边面板上一月,自动切换左面板
944
+ _.get(rightNavBtns, 1).click();
945
+ expect(document.querySelector(`.semi-datepicker-month-grid-left .semi-datepicker-navigation-month`).textContent).toBe('2021年 12月');
946
+ expect(document.querySelector(`.semi-datepicker-month-grid-right .semi-datepicker-navigation-month`).textContent).toBe('2022年 1月');
947
+
948
+ // 点击左边面板上一月,不需要自动切换右面板
949
+ _.get(leftNavBtns, 1).click();
950
+ expect(document.querySelector(`.semi-datepicker-month-grid-left .semi-datepicker-navigation-month`).textContent).toBe('2021年 11月');
951
+ elem.unmount();
952
+ }
953
+
954
+ it('test month sync change dateRange type', () => { testMonthSyncChange('dateRange') });
955
+ it('test month sync change dateTimeRange type', () => { testMonthSyncChange('dateTimeRange')});
873
956
  });
@@ -36,6 +36,7 @@ import DatePickerSlot from './DatePickerSlot';
36
36
  import DatePickerTimeZone from './DatePickerTimeZone';
37
37
  import BetterRangePicker from './BetterRangePicker';
38
38
  import SyncSwitchMonth from './SyncSwitchMonth';
39
+ import { YearButton } from './v2';
39
40
 
40
41
  export default {
41
42
  title: 'DatePicker',
@@ -65,7 +66,8 @@ export {
65
66
  DatePickerSlot,
66
67
  DatePickerTimeZone,
67
68
  BetterRangePicker,
68
- SyncSwitchMonth
69
+ SyncSwitchMonth,
70
+ YearButton
69
71
  }
70
72
 
71
73
  const demoDiv = {
@@ -634,3 +636,29 @@ export const RangeSeparator = () => (
634
636
  </div>
635
637
  </Space>
636
638
  );
639
+
640
+ /**
641
+ * 修复输入 '20221-12-20' 类似这种年份的日期会崩溃问题
642
+ * https://github.com/DouyinFE/semi-design/issues/422
643
+ *
644
+ * 非法日期的来源
645
+ * - 用户输入
646
+ * - 受控传入
647
+ * @returns
648
+ */
649
+ export const FixParseISOBug = () => (
650
+ <div>
651
+ <label>
652
+ <div>选择一个合法值,然后输入一个非法年份</div>
653
+ <DatePicker defaultValue={'2021-12-20'} onChange={v => console.log('onChange', v)} />
654
+ </label>
655
+ <label>
656
+ <div>defaultValue='20221-12-20'</div>
657
+ <DatePicker defaultValue={'20221-12-20'} defaultOpen={true} motion={false} onChange={v => console.log('onChange', v)} />
658
+ </label>
659
+ </div>
660
+ );
661
+ FixParseISOBug.storyName = '修复 parseISO bug';
662
+ FixParseISOBug.parameters = {
663
+ chromatic: { disableSnapshot: false },
664
+ };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { DatePicker } from '../../../index';
3
+
4
+ export default function App() {
5
+ return (
6
+ <div>
7
+ <h4>type=date</h4>
8
+ <DatePicker />
9
+ <h4>type=dateRange</h4>
10
+ <DatePicker type="dateRange" defaultPickerValue="2021-12" />
11
+ <h4>type=dateTimeRange</h4>
12
+ <DatePicker type="dateTimeRange" />
13
+ <h4>type=dateRange + compact</h4>
14
+ <DatePicker type="dateRange" density="compact" />
15
+ </div>
16
+ );
17
+ }
@@ -0,0 +1 @@
1
+ export { default as YearButton } from './YearButton';
@@ -446,6 +446,10 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
446
446
  });
447
447
  };
448
448
 
449
+ getYAMOpenType = () => {
450
+ return this.foundation.getYAMOpenType();
451
+ }
452
+
449
453
  renderTimePicker(panelType: PanelType, panelDetail: MonthInfo) {
450
454
  const { type, locale, format, hideDisabledOptions, timePickerOpts, dateFnsLocale } = this.props;
451
455
  const { pickerDate } = panelDetail;
@@ -606,8 +610,15 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
606
610
  } else if (type === 'year' || type === 'month') {
607
611
  content = 'year month';
608
612
  }
613
+ const yearOpenType = this.getYAMOpenType();
614
+
609
615
  return (
610
- <div className={monthGridCls} x-type={type} ref={current => this.cacheRefCurrent('monthGrid', current)}>
616
+ <div
617
+ className={monthGridCls}
618
+ x-type={type}
619
+ x-panel-yearandmonth-open-type={yearOpenType}
620
+ ref={current => this.cacheRefCurrent('monthGrid', current)}
621
+ >
611
622
  {content}
612
623
  </div>
613
624
  );
@@ -6,7 +6,7 @@ import { noop } from 'lodash';
6
6
  import IconButton from '../iconButton';
7
7
  import Button from '../button';
8
8
  import { cssClasses, strings } from '@douyinfe/semi-foundation/datePicker/constants';
9
- import { IconChevronLeft, IconChevronRight } from '@douyinfe/semi-icons';
9
+ import { IconChevronLeft, IconChevronRight, IconDoubleChevronLeft, IconDoubleChevronRight } from '@douyinfe/semi-icons';
10
10
  import { PanelType } from '@douyinfe/semi-foundation/datePicker/monthsGridFoundation';
11
11
 
12
12
  const prefixCls = cssClasses.NAVIGATION;
@@ -68,6 +68,8 @@ export default class Navigation extends PureComponent<NavigationProps> {
68
68
  onMonthClick,
69
69
  onNextMonth,
70
70
  onPrevMonth,
71
+ onPrevYear,
72
+ onNextYear,
71
73
  density,
72
74
  shouldBimonthSwitch,
73
75
  panelType
@@ -77,43 +79,67 @@ export default class Navigation extends PureComponent<NavigationProps> {
77
79
  const iconBtnSize = density === 'compact' ? 'default' : 'large';
78
80
  const btnNoHorizontalPadding = true;
79
81
  const buttonSize = density === 'compact' ? 'small' : 'default';
80
- // Enable dual-panel synchronous switching, and the current panel is the left panel
81
- const bimonthSwitchWithLeftPanel = shouldBimonthSwitch && panelType === strings.PANEL_TYPE_LEFT;
82
- // Enable dual-panel synchronous switching, and the current panel is the right panel
83
- const bimonthSwitchWithRightPanel = shouldBimonthSwitch && panelType === strings.PANEL_TYPE_RIGHT;
82
+ const isLeftPanel = panelType === strings.PANEL_TYPE_LEFT;
83
+ const isRightPanel = panelType === strings.PANEL_TYPE_RIGHT;
84
+
85
+ // syncSwitchMonth and the current panel is the left
86
+ const hiddenLeftPanelRightButtons = shouldBimonthSwitch && isLeftPanel;
87
+ // syncSwitchMonth and the current panel is the right
88
+ const hiddenRightPanelLeftButtons = shouldBimonthSwitch && isRightPanel;
89
+ // `visibility: hidden` will keep the icon in position
90
+ const leftButtonStyle: React.CSSProperties = {};
91
+ const rightButtonStyle: React.CSSProperties = {};
92
+ if (hiddenRightPanelLeftButtons) {
93
+ leftButtonStyle.visibility = 'hidden';
94
+ }
95
+ if (hiddenLeftPanelRightButtons) {
96
+ rightButtonStyle.visibility = 'hidden';
97
+ }
84
98
 
85
99
  const ref = forwardRef || this.navRef;
86
100
  return (
87
101
  <div className={prefixCls} ref={ref}>
88
- {
89
- !bimonthSwitchWithRightPanel &&
90
- (
91
- <IconButton
92
- icon={<IconChevronLeft size={iconBtnSize} />}
93
- size={buttonSize}
94
- onClick={onPrevMonth}
95
- theme={btnTheme}
96
- noHorizontalPadding={btnNoHorizontalPadding}
97
- />
98
- )
99
- }
102
+ <IconButton
103
+ key="double-chevron-left"
104
+ icon={<IconDoubleChevronLeft size={iconBtnSize}/>}
105
+ size={buttonSize}
106
+ theme={btnTheme}
107
+ noHorizontalPadding={btnNoHorizontalPadding}
108
+ onClick={onPrevYear}
109
+ style={leftButtonStyle}
110
+ />
111
+ <IconButton
112
+ key="chevron-left"
113
+ icon={<IconChevronLeft size={iconBtnSize} />}
114
+ size={buttonSize}
115
+ onClick={onPrevMonth}
116
+ theme={btnTheme}
117
+ noHorizontalPadding={btnNoHorizontalPadding}
118
+ style={leftButtonStyle}
119
+ />
100
120
  <div className={`${prefixCls}-month`}>
101
121
  <Button onClick={onMonthClick} theme={btnTheme} size={buttonSize}>
102
122
  <span>{monthText}</span>
103
123
  </Button>
104
124
  </div>
105
- {
106
- !bimonthSwitchWithLeftPanel &&
107
- (
108
- <IconButton
109
- icon={<IconChevronRight size={iconBtnSize} />}
110
- size={buttonSize}
111
- onClick={onNextMonth}
112
- theme={btnTheme}
113
- noHorizontalPadding={btnNoHorizontalPadding}
114
- />
115
- )
116
- }
125
+ <IconButton
126
+ key="chevron-right"
127
+ icon={<IconChevronRight size={iconBtnSize} />}
128
+ size={buttonSize}
129
+ onClick={onNextMonth}
130
+ theme={btnTheme}
131
+ noHorizontalPadding={btnNoHorizontalPadding}
132
+ style={rightButtonStyle}
133
+ />
134
+ <IconButton
135
+ key="double-chevron-right"
136
+ icon={<IconDoubleChevronRight size={iconBtnSize}/>}
137
+ size={buttonSize}
138
+ theme={btnTheme}
139
+ noHorizontalPadding={btnNoHorizontalPadding}
140
+ onClick={onNextYear}
141
+ style={rightButtonStyle}
142
+ />
117
143
  </div>
118
144
  );
119
145
  }
@@ -17,6 +17,14 @@ const dataWithHide = [
17
17
  { key: '认证状态', value: '未认证' },
18
18
  ];
19
19
 
20
+ const dataWithKeyIsNode = [
21
+ { key: <strong>实际用户数量</strong>, value: '1,480,000' },
22
+ { key: '7天留存', value: '98%' },
23
+ { key: '安全等级', value: '3级' },
24
+ { key: '垂类标签', value: <Tag>电商</Tag> },
25
+ { key: '认证状态', value: '未认证' },
26
+ ];
27
+
20
28
  function renderDescriptions(props) {
21
29
  const realProps = {
22
30
  data,
@@ -134,7 +142,6 @@ describe('Descriptions', () => {
134
142
  largeDesc.unmount();
135
143
  });
136
144
 
137
-
138
145
  it('Descriptions with jsx', () => {
139
146
  const desc = mount(
140
147
  <Descriptions>
@@ -164,4 +171,23 @@ describe('Descriptions', () => {
164
171
  ).toEqual('1,480,000');
165
172
  desc.unmount();
166
173
  });
174
+
175
+ it('Descriptions with key is node', () => {
176
+ const desc = renderDescriptions({ data: dataWithKeyIsNode });
177
+ expect(
178
+ desc
179
+ .find(`.${BASE_CLASS_PREFIX}-descriptions-key strong`)
180
+ .at(0)
181
+ .getDOMNode()
182
+ .textContent
183
+ ).toEqual('实际用户数量');
184
+ expect(
185
+ desc
186
+ .find(`.${BASE_CLASS_PREFIX}-descriptions-key`)
187
+ .at(1)
188
+ .getDOMNode()
189
+ .textContent
190
+ ).toEqual('7天留存');
191
+ desc.unmount();
192
+ });
167
193
  })
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- // import { withKnobs, text, boolean } from '@storybook/addon-knobs';
3
-
4
2
  import Descriptions from '../index';
3
+ import Tag from '../../tag';
5
4
 
6
5
  export default {
7
6
  title: 'Descriptions',
@@ -93,3 +92,54 @@ export const DescriptionsItem = () => (
93
92
  </div>
94
93
  );
95
94
 
95
+ export const DescriptionsKeyIsNode = () => {
96
+ const data = [
97
+ { key: <strong style={{color: 'red'}}>实际用户数量</strong>, value: '1,480,000' },
98
+ { key: '7天留存', value: '98%' },
99
+ { key: '安全等级', value: '3级' },
100
+ { key: '垂类标签', value: <Tag style={{ margin: 0 }}>电商</Tag> },
101
+ { key: '认证状态', value: '未认证' },
102
+ ];
103
+ const style = {
104
+ boxShadow: 'var(--shadow-elevated)',
105
+ backgroundColor: 'var(--color-bg-2)',
106
+ borderRadius: '4px',
107
+ padding: '10px',
108
+ margin: '10px',
109
+ width: '200px',
110
+ };
111
+ return (
112
+ <>
113
+ <div>data 传入的写法</div>
114
+ <div style={{ display: 'flex', flexWrap: 'wrap' }}>
115
+ <Descriptions align="center" data={data} style={style} />
116
+ <Descriptions align="justify" data={data} style={style} />
117
+ <Descriptions align="left" data={data} style={style} />
118
+ <Descriptions align="plain" data={data} style={style} />
119
+ </div>
120
+ <div>JSX 写法</div>
121
+ <div style={{ display: 'flex', flexWrap: 'wrap' }}>
122
+ <Descriptions style={style} align="center" >
123
+ <Descriptions.Item itemKey={<strong style={{ color: 'red' }}>实际用户数量</strong>}>1,480,000</Descriptions.Item>
124
+ <Descriptions.Item itemKey="7天留存">98%</Descriptions.Item>
125
+ <Descriptions.Item itemKey="认证状态">未认证</Descriptions.Item>
126
+ </Descriptions>
127
+ <Descriptions style={style} align="justify">
128
+ <Descriptions.Item itemKey={<strong style={{ color: 'red' }}>实际用户数量</strong>}>1,480,000</Descriptions.Item>
129
+ <Descriptions.Item itemKey="7天留存">98%</Descriptions.Item>
130
+ <Descriptions.Item itemKey="认证状态">未认证</Descriptions.Item>
131
+ </Descriptions>
132
+ <Descriptions style={style} align="left">
133
+ <Descriptions.Item itemKey={<strong style={{ color: 'red' }}>实际用户数量</strong>}>1,480,000</Descriptions.Item>
134
+ <Descriptions.Item itemKey="7天留存">98%</Descriptions.Item>
135
+ <Descriptions.Item itemKey="认证状态">未认证</Descriptions.Item>
136
+ </Descriptions>
137
+ <Descriptions style={style} align="plain">
138
+ <Descriptions.Item itemKey={<strong style={{ color: 'red' }}>实际用户数量</strong>}>1,480,000</Descriptions.Item>
139
+ <Descriptions.Item itemKey="7天留存">98%</Descriptions.Item>
140
+ <Descriptions.Item itemKey="认证状态">未认证</Descriptions.Item>
141
+ </Descriptions>
142
+ </div>
143
+ </>
144
+ );
145
+ };
@@ -36,7 +36,7 @@ export default class Item extends PureComponent<DescriptionsItemProps> {
36
36
  <tr className={className} style={style}>
37
37
  <td className={`${prefixCls}-item`}>
38
38
  <span className={keyCls}>
39
- {`${itemKey}:`}
39
+ {itemKey}:
40
40
  </span>
41
41
  <span className={valCls}>
42
42
  {typeof children === 'function' ? children() : children}
package/dist/css/semi.css CHANGED
@@ -1,4 +1,3 @@
1
- @charset "UTF-8";
2
1
  /* shadow */
3
2
  /* sizing */
4
3
  /* spacing */
@@ -2686,11 +2685,11 @@ body[theme-mode=dark], body .semi-always-dark {
2686
2685
  .semi-cascader-selection-tag:first-child {
2687
2686
  margin-left: 0;
2688
2687
  }
2689
- .semi-cascader-selection-tag-disabled {
2688
+ .semi-cascader-selection-tag-disabled.semi-tag {
2690
2689
  color: var(--semi-color-disabled-text);
2691
2690
  cursor: not-allowed;
2692
2691
  }
2693
- .semi-cascader-selection-tag-disabled .semi-tag-close {
2692
+ .semi-cascader-selection-tag-disabled.semi-tag .semi-tag-close {
2694
2693
  color: var(--semi-color-disabled-text);
2695
2694
  cursor: not-allowed;
2696
2695
  pointer-events: none;
@@ -3498,6 +3497,9 @@ body[theme-mode=dark], body .semi-always-dark {
3498
3497
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
3499
3498
  min-height: 24px;
3500
3499
  }
3500
+ .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=left] .semi-datepicker-weeks, .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=right] .semi-datepicker-weeks {
3501
+ min-height: 216px;
3502
+ }
3501
3503
  .semi-datepicker-panel-yam {
3502
3504
  max-width: 284px;
3503
3505
  }
@@ -3987,6 +3989,9 @@ body[theme-mode=dark], body .semi-always-dark {
3987
3989
  .semi-datepicker-compact .semi-datepicker-month-grid .semi-scrolllist-item-wheel .semi-scrolllist-shade-post {
3988
3990
  margin-top: 17px;
3989
3991
  }
3992
+ .semi-datepicker-compact .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=left] .semi-datepicker-weeks, .semi-datepicker-compact .semi-datepicker-month-grid[x-panel-yearandmonth-open-type=right] .semi-datepicker-weeks {
3993
+ min-height: 168px;
3994
+ }
3990
3995
  .semi-datepicker-compact.semi-datepicker-panel-yam .semi-scrolllist {
3991
3996
  font-size: 12px;
3992
3997
  line-height: 16px;
@@ -13026,19 +13031,23 @@ body[theme-mode=dark], body .semi-always-dark {
13026
13031
  color: var(--semi-color-success);
13027
13032
  }
13028
13033
  .semi-notification-notice-light.semi-notification-notice-warning {
13029
- background-color: var(--semi-color-warning-light-default);
13034
+ background-image: linear-gradient(0deg, var(--semi-color-warning-light-default), var(--semi-color-warning-light-default));
13035
+ background-color: var(--semi-color-bg-0);
13030
13036
  border: 1px solid var(--semi-color-warning);
13031
13037
  }
13032
13038
  .semi-notification-notice-light.semi-notification-notice-success {
13033
- background-color: var(--semi-color-success-light-default);
13039
+ background-image: linear-gradient(0deg, var(--semi-color-success-light-default), var(--semi-color-success-light-default));
13040
+ background-color: var(--semi-color-bg-0);
13034
13041
  border: 1px solid var(--semi-color-success);
13035
13042
  }
13036
13043
  .semi-notification-notice-light.semi-notification-notice-info, .semi-notification-notice-light.semi-notification-notice-default {
13037
- background-color: var(--semi-color-info-light-default);
13044
+ background-image: linear-gradient(0deg, var(--semi-color-info-light-default), var(--semi-color-info-light-default));
13045
+ background-color: var(--semi-color-bg-0);
13038
13046
  border: 1px solid var(--semi-color-info);
13039
13047
  }
13040
13048
  .semi-notification-notice-light.semi-notification-notice-error {
13041
- background-color: var(--semi-color-danger-light-default);
13049
+ background-image: linear-gradient(0deg, var(--semi-color-danger-light-default), var(--semi-color-danger-light-default));
13050
+ background-color: var(--semi-color-bg-0);
13042
13051
  border: 1px solid var(--semi-color-danger);
13043
13052
  }
13044
13053
  .semi-notification-notice-title {
@@ -17753,6 +17762,9 @@ body[theme-mode=dark], body .semi-always-dark {
17753
17762
  .semi-timeline-alternate .semi-timeline-item-tail, .semi-timeline-alternate .semi-timeline-item-head, .semi-timeline-alternate .semi-timeline-item-head-custom, .semi-timeline-right .semi-timeline-item-tail, .semi-timeline-right .semi-timeline-item-head, .semi-timeline-right .semi-timeline-item-head-custom, .semi-timeline-center .semi-timeline-item-tail, .semi-timeline-center .semi-timeline-item-head, .semi-timeline-center .semi-timeline-item-head-custom {
17754
17763
  left: 50%;
17755
17764
  }
17765
+ .semi-timeline-alternate .semi-timeline-item-head.semi-timeline-item-head-custom, .semi-timeline-right .semi-timeline-item-head.semi-timeline-item-head-custom, .semi-timeline-center .semi-timeline-item-head.semi-timeline-item-head-custom {
17766
+ margin-left: 0;
17767
+ }
17756
17768
  .semi-timeline-alternate .semi-timeline-item-head, .semi-timeline-right .semi-timeline-item-head, .semi-timeline-center .semi-timeline-item-head {
17757
17769
  margin-left: -4px;
17758
17770
  }
@@ -19400,6 +19412,8 @@ p.semi-typography-extended,
19400
19412
  display: flex;
19401
19413
  flex-wrap: wrap;
19402
19414
  flex-shrink: 0;
19415
+ gap: 8px;
19416
+ margin-bottom: 8px;
19403
19417
  }
19404
19418
  .semi-upload-file-list-main p {
19405
19419
  display: flex;
@@ -19426,8 +19440,6 @@ p.semi-typography-extended,
19426
19440
  justify-content: space-between;
19427
19441
  height: 52px;
19428
19442
  width: 250px;
19429
- margin-right: 8px;
19430
- margin-bottom: 8px;
19431
19443
  background-color: var(--semi-color-fill-0);
19432
19444
  cursor: pointer;
19433
19445
  }
@@ -19562,16 +19574,16 @@ p.semi-typography-extended,
19562
19574
  flex-direction: column;
19563
19575
  }
19564
19576
  .semi-upload-picture[x-prompt-pos=bottom] .semi-upload-prompt {
19565
- order: 2;
19577
+ order: 1;
19566
19578
  }
19567
19579
  .semi-upload-picture[x-prompt-pos=bottom] .semi-upload-add {
19568
- order: 1;
19580
+ order: 0;
19569
19581
  }
19570
19582
  .semi-upload-picture[x-prompt-pos=right] .semi-upload-prompt {
19571
- order: 2;
19583
+ order: 1;
19572
19584
  }
19573
19585
  .semi-upload-picture[x-prompt-pos=right] .semi-upload-add {
19574
- order: 1;
19586
+ order: 0;
19575
19587
  }
19576
19588
  .semi-upload-picture-add {
19577
19589
  background-color: var(--semi-color-fill-0);
@@ -19608,11 +19620,14 @@ p.semi-typography-extended,
19608
19620
  margin-bottom: 0;
19609
19621
  }
19610
19622
  .semi-upload-picture-file-card {
19623
+ display: flex;
19624
+ align-items: center;
19625
+ justify-content: center;
19611
19626
  height: 96px;
19612
19627
  width: 96px;
19628
+ border-radius: var(--semi-border-radius-small);
19613
19629
  position: relative;
19614
- margin-right: 8px;
19615
- margin-bottom: 8px;
19630
+ overflow: hidden;
19616
19631
  }
19617
19632
  .semi-upload-picture-file-card img {
19618
19633
  height: 96px;
@@ -19677,6 +19692,22 @@ p.semi-typography-extended,
19677
19692
  color: var(--semi-color-white);
19678
19693
  transform: translate3D(-50%, -50%, 0);
19679
19694
  }
19695
+ .semi-upload-picture-file-card-pic-info {
19696
+ display: inline-flex;
19697
+ box-sizing: border-box;
19698
+ justify-content: space-between;
19699
+ align-items: center;
19700
+ position: absolute;
19701
+ width: 100%;
19702
+ height: 24px;
19703
+ padding: 0 10px;
19704
+ bottom: 0;
19705
+ left: 0;
19706
+ color: var(--semi-color-white);
19707
+ font-size: 12px;
19708
+ font-weight: 600;
19709
+ background: linear-gradient(0deg, rgba(22, 22, 26, 0.3) 0%, rgba(22, 22, 26, 0) 77.08%);
19710
+ }
19680
19711
  .semi-upload-picture-file-card-icon-loading, .semi-upload-picture-file-card-icon-error {
19681
19712
  position: absolute;
19682
19713
  bottom: 6px;
@@ -19689,6 +19720,9 @@ p.semi-typography-extended,
19689
19720
  .semi-upload-picture-file-card-show-pointer {
19690
19721
  cursor: pointer;
19691
19722
  }
19723
+ .semi-upload-picture-file-card-error {
19724
+ outline: 1px solid var(--semi-color-danger);
19725
+ }
19692
19726
  .semi-upload-drag-area {
19693
19727
  border-radius: var(--semi-border-radius-small);
19694
19728
  border: 2px dashed var(--semi-color-border);
@@ -19769,11 +19803,6 @@ p.semi-typography-extended,
19769
19803
  .semi-portal-rtl .semi-upload-file-list-title-clear {
19770
19804
  display: inline-block;
19771
19805
  }
19772
- .semi-rtl .semi-upload-file-card,
19773
- .semi-portal-rtl .semi-upload-file-card {
19774
- margin-right: 0;
19775
- margin-left: 8px;
19776
- }
19777
19806
  .semi-rtl .semi-upload-file-card-info-size,
19778
19807
  .semi-portal-rtl .semi-upload-file-card-info-size {
19779
19808
  margin-left: 0;
@@ -19790,11 +19819,6 @@ p.semi-typography-extended,
19790
19819
  margin-right: 0;
19791
19820
  margin-left: 2px;
19792
19821
  }
19793
- .semi-rtl .semi-upload-picture-file-card,
19794
- .semi-portal-rtl .semi-upload-picture-file-card {
19795
- margin-right: 0;
19796
- margin-left: 8px;
19797
- }
19798
19822
  .semi-rtl .semi-upload-picture-file-card-close,
19799
19823
  .semi-portal-rtl .semi-upload-picture-file-card-close {
19800
19824
  right: auto;