@douyinfe/semi-foundation 2.32.0-beta.0 → 2.32.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 (58) hide show
  1. package/autoComplete/autoComplete.scss +2 -0
  2. package/datePicker/_utils/isValidTimeZone.ts +3 -0
  3. package/datePicker/foundation.ts +18 -13
  4. package/datePicker/inputFoundation.ts +1 -1
  5. package/datePicker/monthsGridFoundation.ts +3 -9
  6. package/lib/cjs/autoComplete/autoComplete.css +1 -0
  7. package/lib/cjs/autoComplete/autoComplete.scss +2 -0
  8. package/lib/cjs/datePicker/_utils/isValidTimeZone.d.ts +1 -0
  9. package/lib/cjs/datePicker/_utils/isValidTimeZone.js +10 -0
  10. package/lib/cjs/datePicker/foundation.d.ts +12 -1
  11. package/lib/cjs/datePicker/foundation.js +20 -12
  12. package/lib/cjs/datePicker/monthsGridFoundation.d.ts +0 -1
  13. package/lib/cjs/datePicker/monthsGridFoundation.js +4 -11
  14. package/lib/cjs/spin/spin.css +1 -0
  15. package/lib/cjs/spin/spin.scss +1 -0
  16. package/lib/cjs/table/table.css +4 -3
  17. package/lib/cjs/table/table.scss +6 -3
  18. package/lib/cjs/table/utils.d.ts +52 -3
  19. package/lib/cjs/table/utils.js +1 -48
  20. package/lib/cjs/table/variables.scss +2 -0
  21. package/lib/cjs/tree/tree.css +1 -0
  22. package/lib/cjs/tree/tree.scss +1 -0
  23. package/lib/cjs/treeSelect/foundation.d.ts +1 -1
  24. package/lib/cjs/upload/upload.css +3 -0
  25. package/lib/cjs/upload/upload.scss +1 -0
  26. package/lib/cjs/utils/date-fns-extra.d.ts +24 -17
  27. package/lib/cjs/utils/date-fns-extra.js +22 -16
  28. package/lib/es/autoComplete/autoComplete.css +1 -0
  29. package/lib/es/autoComplete/autoComplete.scss +2 -0
  30. package/lib/es/datePicker/_utils/isValidTimeZone.d.ts +1 -0
  31. package/lib/es/datePicker/_utils/isValidTimeZone.js +3 -0
  32. package/lib/es/datePicker/foundation.d.ts +12 -1
  33. package/lib/es/datePicker/foundation.js +19 -12
  34. package/lib/es/datePicker/monthsGridFoundation.d.ts +0 -1
  35. package/lib/es/datePicker/monthsGridFoundation.js +4 -11
  36. package/lib/es/spin/spin.css +1 -0
  37. package/lib/es/spin/spin.scss +1 -0
  38. package/lib/es/table/table.css +4 -3
  39. package/lib/es/table/table.scss +6 -3
  40. package/lib/es/table/utils.d.ts +52 -3
  41. package/lib/es/table/utils.js +1 -43
  42. package/lib/es/table/variables.scss +2 -0
  43. package/lib/es/tree/tree.css +1 -0
  44. package/lib/es/tree/tree.scss +1 -0
  45. package/lib/es/treeSelect/foundation.d.ts +1 -1
  46. package/lib/es/upload/upload.css +3 -0
  47. package/lib/es/upload/upload.scss +1 -0
  48. package/lib/es/utils/date-fns-extra.d.ts +24 -17
  49. package/lib/es/utils/date-fns-extra.js +22 -16
  50. package/package.json +4 -4
  51. package/spin/spin.scss +1 -0
  52. package/table/table.scss +6 -3
  53. package/table/utils.ts +1 -43
  54. package/table/variables.scss +2 -0
  55. package/tree/tree.scss +1 -0
  56. package/treeSelect/foundation.ts +1 -1
  57. package/upload/upload.scss +1 -0
  58. package/utils/date-fns-extra.ts +27 -20
@@ -62,14 +62,6 @@ const parse = (date, formatToken, options) => {
62
62
 
63
63
  return toDate(date, options);
64
64
  };
65
- /**
66
- *
67
- * @param {string | number | Date} date
68
- * @param {string} formatToken
69
- * @param {object} [options]
70
- * @param {string} [options.timeZone]
71
- */
72
-
73
65
  /* istanbul ignore next */
74
66
 
75
67
 
@@ -85,21 +77,35 @@ const format = (date, formatToken, options) => {
85
77
  return dateFnsFormat(date, formatToken, options);
86
78
  };
87
79
  /**
80
+ * Returns a Date which will format as the local time of any time zone from a specific UTC time
88
81
  *
89
- * @param {string | number | Date} date
90
- * @param {string} timeZone
91
- * @param {object} options
92
- * @returns {Date}
82
+ * @example
83
+ * ```javascript
84
+ * import { utcToZonedTime } from 'date-fns-tz'
85
+ * const { isoDate, timeZone } = fetchInitialValues() // 2014-06-25T10:00:00.000Z, America/New_York
86
+ * const date = utcToZonedTime(isoDate, timeZone) // In June 10am UTC is 6am in New York (-04:00)
87
+ * renderDatePicker(date) // 2014-06-25 06:00:00 (in the system time zone)
88
+ * renderTimeZoneSelect(timeZone) // America/New_York
89
+ * ```
90
+ *
91
+ * @see https://github.com/marnusw/date-fns-tz#utctozonedtime
93
92
  */
94
93
 
95
94
 
96
95
  const utcToZonedTime = (date, timeZone, options) => dateFnsUtcToZonedTime(date, toIANA(timeZone), options);
97
96
  /**
97
+ * Given a date and any time zone, returns a Date with the equivalent UTC time
98
98
  *
99
- * @param {string | number | Date} date
100
- * @param {string} timeZone
101
- * @param {object} options
102
- * @returns {Date}
99
+ * @example
100
+ * ```
101
+ * import { zonedTimeToUtc } from 'date-fns-tz'
102
+ * const date = getDatePickerValue() // e.g. 2014-06-25 10:00:00 (picked in any time zone)
103
+ * const timeZone = getTimeZoneValue() // e.g. America/Los_Angeles
104
+ * const utcDate = zonedTimeToUtc(date, timeZone) // In June 10am in Los Angeles is 5pm UTC
105
+ * postToServer(utcDate.toISOString(), timeZone) // post 2014-06-25T17:00:00.000Z, America/Los_Angeles
106
+ * ```
107
+ *
108
+ * @see https://github.com/marnusw/date-fns-tz#zonedtimetoutc
103
109
  */
104
110
 
105
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.32.0-beta.0",
3
+ "version": "2.32.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -10,8 +10,8 @@
10
10
  "@douyinfe/semi-animation": "2.12.0",
11
11
  "async-validator": "^3.5.0",
12
12
  "classnames": "^2.2.6",
13
- "date-fns": "^2.9.0",
14
- "date-fns-tz": "^1.0.10",
13
+ "date-fns": "^2.29.3",
14
+ "date-fns-tz": "^1.3.8",
15
15
  "lodash": "^4.17.21",
16
16
  "memoize-one": "^5.2.1",
17
17
  "scroll-into-view-if-needed": "^2.2.24"
@@ -23,7 +23,7 @@
23
23
  "*.scss",
24
24
  "*.css"
25
25
  ],
26
- "gitHead": "335f8c47c40373ee1464c841581130e62b62b1d5",
26
+ "gitHead": "6cf04209adcb1c3ab8d24ba7aec0025394d82d49",
27
27
  "devDependencies": {
28
28
  "@babel/plugin-transform-runtime": "^7.15.8",
29
29
  "@babel/preset-env": "^7.15.8",
package/spin/spin.scss CHANGED
@@ -29,6 +29,7 @@ $module: #{$prefix}-spin;
29
29
  & > svg {
30
30
  animation: $animation_duration-spin_wrapper-spin linear infinite #{$prefix}-animation-rotate;
31
31
  animation-fill-mode: forwards;
32
+ vertical-align: top;
32
33
  @include size($width-spin_middle);
33
34
  }
34
35
  }
package/table/table.scss CHANGED
@@ -209,15 +209,19 @@ $module: #{$prefix}-table;
209
209
  display: table-row-group;
210
210
  & > .#{$module}-row {
211
211
  display: table-row;
212
+ background-color: $color-table_body-bg-default;
212
213
 
213
214
  &:hover {
214
215
  & > .#{$module}-row-cell {
215
- background-color: $color-table_body-bg-hover;
216
+ // $color-table_body-bg-hover has transparency,will reveal the background color $color-table_body-bg-default\
217
+ // combine background-image and background-color to make the non-fixed column color does not show through the bottom color
218
+ background-image: linear-gradient(0deg, $color-table_body-bg-hover, $color-table_body-bg-hover);
219
+ background-color: $color-table_cell-bg-hover;
216
220
 
217
221
  &.#{$module}-cell-fixed {
218
222
  &-left,
219
223
  &-right {
220
- background-color: $color-table_body-bg-default;
224
+ background-image: linear-gradient(0deg, $color-table_body-bg-default, $color-table_body-bg-default);
221
225
 
222
226
  &::before {
223
227
  background-color: $color-table_body-bg-hover;
@@ -246,7 +250,6 @@ $module: #{$prefix}-table;
246
250
  box-sizing: border-box;
247
251
  position: relative;
248
252
  vertical-align: middle;
249
- background-color: $color-table_body-bg-default;
250
253
 
251
254
  &.resizing {
252
255
  border-right: $width-table_resizer_border solid $color-table_resizer-bg-default;
package/table/utils.ts CHANGED
@@ -2,7 +2,6 @@
2
2
  /* eslint-disable no-param-reassign */
3
3
  /* eslint-disable eqeqeq */
4
4
  import {
5
- cloneDeepWith,
6
5
  isEqualWith,
7
6
  get,
8
7
  filter,
@@ -21,17 +20,6 @@ import isNullOrUndefined from '../utils/isNullOrUndefined';
21
20
  import Logger from '../utils/Logger';
22
21
 
23
22
 
24
- export function cloneDeep(value: any, customizer?: (v: any) => any) {
25
- return cloneDeepWith(value, v => {
26
- if (typeof v === 'function') {
27
- return v;
28
- } else if (typeof customizer === 'function') {
29
- return customizer(v);
30
- }
31
- return undefined;
32
- });
33
- }
34
-
35
23
  export function equalWith(value: any, other: any, customizer?: (...args: any[]) => boolean) {
36
24
  return isEqualWith(value, other, (objVal, othVal, ...rest) => {
37
25
  if (typeof objVal === 'function' && typeof othVal === 'function') {
@@ -61,36 +49,6 @@ export function getColumnKey(column: any, keyPropNames: any[]): any {
61
49
  return key;
62
50
  }
63
51
 
64
- export function mergeColumns(oldColumns: any[] = [], newColumns: any[] = [], keyPropNames: any[] = null, deep = true) {
65
- const finalColumns: any[] = [];
66
- const clone = deep ? cloneDeep : lodashClone;
67
-
68
- if (deep) {
69
- const logger = new Logger('[@douyinfe/semi-ui Table]');
70
- logger.warn('Should not deep merge columns from foundation since columns may have react elements. Merge columns deep from semi-ui');
71
- }
72
-
73
- map(newColumns, newColumn => {
74
- newColumn = { ...newColumn };
75
- const key = getColumnKey(newColumn, keyPropNames);
76
-
77
- const oldColumn = key != null && find(oldColumns, item => getColumnKey(item, keyPropNames) === key);
78
-
79
- if (oldColumn) {
80
- finalColumns.push(
81
- clone({
82
- ...oldColumn,
83
- ...newColumn,
84
- })
85
- );
86
- } else {
87
- finalColumns.push(clone(newColumn));
88
- }
89
- });
90
-
91
- return finalColumns;
92
- }
93
-
94
52
  /**
95
53
  *
96
54
  * @param {Array<number>} arr
@@ -437,7 +395,7 @@ export function mergeQueries(query: Record<string, any>, queries: Record<string,
437
395
  * @param {Object[]} newColumns
438
396
  */
439
397
  export function withResizeWidth(columns: Record<string, any>[], newColumns: Record<string, any>[]) {
440
- const _newColumns = cloneDeep(newColumns);
398
+ const _newColumns = { ...newColumns };
441
399
  for (const column of columns) {
442
400
  if (!isNullOrUndefined(column.width)) {
443
401
  const currentColumn = column.key;
@@ -75,6 +75,8 @@ $color-table_resizer-bg-default: var(--semi-color-primary); // 表格拉伸标
75
75
  $color-table_selection-bg-default: rgba(var(--semi-grey-0), 1); // 表格分组背景色
76
76
  $color-table_placeholder-text-default: var(--semi-color-text-2); // 表格空数据文本颜色
77
77
 
78
+ $color-table_cell-bg-hover: var(--semi-color-bg-0); // 让表格在 hover 时正确显示 $color-table_body-bg-hover 颜色,如无必要不要修改
79
+
78
80
  // Other
79
81
  $font-table_base-fontSize: 14px; // 表格默认文本字号
80
82
  $border-table_base-borderStyle: solid; // 表格描边样式
package/tree/tree.scss CHANGED
@@ -302,6 +302,7 @@ $module: #{$prefix}-tree;
302
302
 
303
303
  &-spin-icon {
304
304
  display: flex;
305
+ line-height: 0; // make the spin icon in the center
305
306
  & svg {
306
307
  width: $width-tree_spinIcon;
307
308
  height: $width-tree_spinIcon;
@@ -49,7 +49,7 @@ export interface BasicTriggerRenderProps {
49
49
  value: BasicTreeNodeData[];
50
50
  onClear: (e: any) => void;
51
51
  onSearch: (inputValue: string) => void;
52
- onRemove: (value: string) => void
52
+ onRemove: (key: string) => void
53
53
  }
54
54
 
55
55
  export type BasicOnChangeWithObject = (node: BasicTreeNodeData[] | BasicTreeNodeData, e: any) => void;
@@ -258,6 +258,7 @@ $module: #{$prefix}-upload;
258
258
  }
259
259
 
260
260
  &-loading {
261
+ line-height: 0; // make the spin icon in the center
261
262
  .#{$prefix}-spin-wrapper svg {
262
263
  height: $width-upload_file_card-icon;
263
264
  width: $width-upload_file_card-icon;
@@ -100,15 +100,8 @@ const parse = (date: string | number | Date, formatToken: string, options?: any)
100
100
  return toDate(date, options);
101
101
  };
102
102
 
103
- /**
104
- *
105
- * @param {string | number | Date} date
106
- * @param {string} formatToken
107
- * @param {object} [options]
108
- * @param {string} [options.timeZone]
109
- */
110
103
  /* istanbul ignore next */
111
- const format = (date: string | number | Date, formatToken: string, options?: any) => {
104
+ const format = (date: number | Date, formatToken: string, options?: any) => {
112
105
  if (options && options.timeZone != null && options.timeZone !== '') {
113
106
  const timeZone = toIANA(options.timeZone);
114
107
  options = { ...options, timeZone };
@@ -120,22 +113,36 @@ const format = (date: string | number | Date, formatToken: string, options?: any
120
113
  };
121
114
 
122
115
  /**
123
- *
124
- * @param {string | number | Date} date
125
- * @param {string} timeZone
126
- * @param {object} options
127
- * @returns {Date}
116
+ * Returns a Date which will format as the local time of any time zone from a specific UTC time
117
+ *
118
+ * @example
119
+ * ```javascript
120
+ * import { utcToZonedTime } from 'date-fns-tz'
121
+ * const { isoDate, timeZone } = fetchInitialValues() // 2014-06-25T10:00:00.000Z, America/New_York
122
+ * const date = utcToZonedTime(isoDate, timeZone) // In June 10am UTC is 6am in New York (-04:00)
123
+ * renderDatePicker(date) // 2014-06-25 06:00:00 (in the system time zone)
124
+ * renderTimeZoneSelect(timeZone) // America/New_York
125
+ * ```
126
+ *
127
+ * @see https://github.com/marnusw/date-fns-tz#utctozonedtime
128
128
  */
129
- const utcToZonedTime = (date: string | number | Date, timeZone: string, options?: OptionsWithTZ) => dateFnsUtcToZonedTime(date, toIANA(timeZone), options);
129
+ const utcToZonedTime = (date: string | number | Date, timeZone: string | number, options?: OptionsWithTZ) => dateFnsUtcToZonedTime(date, toIANA(timeZone), options);
130
130
 
131
131
  /**
132
- *
133
- * @param {string | number | Date} date
134
- * @param {string} timeZone
135
- * @param {object} options
136
- * @returns {Date}
132
+ * Given a date and any time zone, returns a Date with the equivalent UTC time
133
+ *
134
+ * @example
135
+ * ```
136
+ * import { zonedTimeToUtc } from 'date-fns-tz'
137
+ * const date = getDatePickerValue() // e.g. 2014-06-25 10:00:00 (picked in any time zone)
138
+ * const timeZone = getTimeZoneValue() // e.g. America/Los_Angeles
139
+ * const utcDate = zonedTimeToUtc(date, timeZone) // In June 10am in Los Angeles is 5pm UTC
140
+ * postToServer(utcDate.toISOString(), timeZone) // post 2014-06-25T17:00:00.000Z, America/Los_Angeles
141
+ * ```
142
+ *
143
+ * @see https://github.com/marnusw/date-fns-tz#zonedtimetoutc
137
144
  */
138
- const zonedTimeToUtc = (date: string | number | Date, timeZone: string, options?: OptionsWithTZ) => dateFnsZonedTimeToUtc(date, toIANA(timeZone), options);
145
+ const zonedTimeToUtc = (date: string | number | Date, timeZone: string | number, options?: OptionsWithTZ) => dateFnsZonedTimeToUtc(date, toIANA(timeZone), options);
139
146
 
140
147
  /**
141
148
  * return current system hour offset based on utc: