@douyinfe/semi-foundation 2.22.3 → 2.23.0-beta.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 (54) hide show
  1. package/cascader/cascader.scss +15 -0
  2. package/cascader/variables.scss +1 -0
  3. package/form/interface.ts +8 -4
  4. package/image/imageFoundation.ts +1 -1
  5. package/image/previewFooterFoundation.ts +2 -2
  6. package/image/previewImageFoundation.ts +0 -1
  7. package/image/previewInnerFoundation.ts +2 -2
  8. package/lib/cjs/cascader/cascader.css +12 -0
  9. package/lib/cjs/cascader/cascader.scss +15 -0
  10. package/lib/cjs/cascader/variables.scss +1 -0
  11. package/lib/cjs/form/interface.d.ts +8 -6
  12. package/lib/cjs/image/imageFoundation.js +1 -1
  13. package/lib/cjs/image/previewFooterFoundation.js +2 -2
  14. package/lib/cjs/image/previewInnerFoundation.d.ts +1 -1
  15. package/lib/cjs/image/previewInnerFoundation.js +1 -1
  16. package/lib/cjs/navigation/navigation.css +6 -0
  17. package/lib/cjs/navigation/navigation.scss +9 -0
  18. package/lib/cjs/table/constants.d.ts +1 -0
  19. package/lib/cjs/table/constants.js +4 -2
  20. package/lib/cjs/table/table.css +2 -1
  21. package/lib/cjs/table/table.scss +2 -1
  22. package/lib/cjs/tooltip/constants.d.ts +1 -0
  23. package/lib/cjs/tooltip/constants.js +2 -2
  24. package/lib/cjs/tooltip/foundation.d.ts +21 -2
  25. package/lib/cjs/tooltip/foundation.js +352 -77
  26. package/lib/cjs/transfer/foundation.d.ts +1 -1
  27. package/lib/cjs/transfer/foundation.js +3 -4
  28. package/lib/es/cascader/cascader.css +12 -0
  29. package/lib/es/cascader/cascader.scss +15 -0
  30. package/lib/es/cascader/variables.scss +1 -0
  31. package/lib/es/form/interface.d.ts +8 -6
  32. package/lib/es/image/imageFoundation.js +1 -1
  33. package/lib/es/image/previewFooterFoundation.js +2 -2
  34. package/lib/es/image/previewInnerFoundation.d.ts +1 -1
  35. package/lib/es/image/previewInnerFoundation.js +1 -1
  36. package/lib/es/navigation/navigation.css +6 -0
  37. package/lib/es/navigation/navigation.scss +9 -0
  38. package/lib/es/table/constants.d.ts +1 -0
  39. package/lib/es/table/constants.js +4 -2
  40. package/lib/es/table/table.css +2 -1
  41. package/lib/es/table/table.scss +2 -1
  42. package/lib/es/tooltip/constants.d.ts +1 -0
  43. package/lib/es/tooltip/constants.js +2 -2
  44. package/lib/es/tooltip/foundation.d.ts +21 -2
  45. package/lib/es/tooltip/foundation.js +352 -77
  46. package/lib/es/transfer/foundation.d.ts +1 -1
  47. package/lib/es/transfer/foundation.js +3 -4
  48. package/navigation/navigation.scss +9 -0
  49. package/package.json +2 -2
  50. package/table/constants.ts +2 -0
  51. package/table/table.scss +2 -1
  52. package/tooltip/constants.ts +1 -0
  53. package/tooltip/foundation.ts +318 -78
  54. package/transfer/foundation.ts +3 -3
@@ -408,6 +408,21 @@ $module: #{$prefix}-cascader;
408
408
  &-empty {
409
409
  margin-right: $spacing-cascader_empty_icon-marginRight;
410
410
  }
411
+
412
+ &-left {
413
+ margin-left: $spacing-cascader_option-icon-marginLeft;
414
+ }
415
+ }
416
+
417
+ &-spin-icon {
418
+ width: $width-cascader-icon;
419
+ height: $width-cascader-icon;
420
+ line-height: 0;
421
+
422
+ & svg {
423
+ width: $width-cascader-icon;
424
+ height: $width-cascader-icon;
425
+ }
411
426
  }
412
427
 
413
428
  &-label {
@@ -51,6 +51,7 @@ $spacing-cascader_selection_tagInput-marginLeft: - $spacing-extra-tight; // 级
51
51
  $spacing-cascader_selection_input-marginLeft: $spacing-extra-tight; // 级联选择触发器多选搜索时输入框的左外边距
52
52
  $spacing-cascader_selection_n-marginRight: $spacing-extra-tight; // 超出 maxTagCount 后,+n 的右外边距
53
53
  $spacing-cascader_clearBtn-marginRight: 12px; // 级联选择触发器清空按钮右侧外边距
54
+ $spacing-cascader_option-icon-marginLeft: 8px; // 级联选择菜单项图标左侧外边距
54
55
 
55
56
  $color-cascader_selection_n-text-default: var(--semi-color-text-0); // 超出 maxTagCount 后,+n 的文字默认颜色
56
57
  $color-cascader_selection_n-text-disabled: var(--semi-color-disabled-text); // 超出 maxTagCount 后,+n 的文字disabled颜色
package/form/interface.ts CHANGED
@@ -9,24 +9,28 @@ export type FieldValidateTriggerType = BasicTriggerType | Array<BasicTriggerType
9
9
 
10
10
  export type CommonFieldError = boolean | string | Array<any> | undefined | unknown;
11
11
 
12
- export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
12
+ export type BasicFieldError = Array<any>;
13
+
14
+ export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any>, Values extends object = any> extends DefaultAdapter<P, S> {
13
15
  cloneDeep: (val: any, ...rest: any[]) => any;
14
16
  notifySubmit: (values: any) => void;
15
- notifySubmitFail: (errors: Record<string, any>, values: any) => void;
17
+ notifySubmitFail: (errors: Record<keyof Values, BasicFieldError>, values: Partial<Values>) => void;
16
18
  forceUpdate: (callback?: () => void) => void;
17
19
  notifyChange: (formState: FormState) => void;
18
20
  notifyValueChange: (values: any, changedValues: any) => void;
19
21
  notifyReset: () => void;
20
- getInitValues: () => Record<string, any>;
22
+ getInitValues: () => Partial<Values>;
21
23
  getFormProps: (keys: undefined | string | Array<string>) => any;
22
24
  getAllErrorDOM: () => NodeList;
23
25
  getFieldDOM: (field: string) => Node;
24
26
  initFormId: () => void
25
27
  }
26
28
 
29
+ export type AllErrors<T> = T extends Record<string, any> ? { [K in keyof T]?: string } : Record<string, any>;
30
+
27
31
  export interface FormState<T extends Record<string, any> = any> {
28
32
  values?: T extends Record<string, any> ? T : Record<string, any>;
29
- errors?: T extends Record<string, any> ? { [K in keyof T]?: string } : Record<string, any>;
33
+ errors?: AllErrors<T>;
30
34
  touched?: T extends Record<string, any> ? { [K in keyof T]?: boolean } : Record<string, any>
31
35
  }
32
36
  export interface setValuesConfig {
@@ -50,7 +50,7 @@ export default class ImageFoundation<P = Record<string, any>, S = Record<string,
50
50
  if (isObject(preview)) {
51
51
  const { onVisibleChange } = preview as any;
52
52
  onVisibleChange && onVisibleChange(newVisible);
53
- if (!("visible" in this.getProps())) {
53
+ if (!("visible" in preview)) {
54
54
  this.setState({
55
55
  previewVisible: newVisible,
56
56
  } as any);
@@ -20,9 +20,9 @@ export default class PreviewFooterFoundation<P = Record<string, any>, S = Record
20
20
  handleValueChange = (value: number): void => {
21
21
  const { onZoomIn, onZoomOut, zoom } = this.getProps();
22
22
  if (value > zoom) {
23
- onZoomIn(value / 100);
23
+ onZoomIn(Number((value / 100).toFixed(2)));
24
24
  } else {
25
- onZoomOut(value / 100);
25
+ onZoomOut(Number((value / 100).toFixed(2)));
26
26
  }
27
27
  this._adapter.setStartMouseOffset(value);
28
28
  };
@@ -257,7 +257,6 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
257
257
  }
258
258
  if (canDragVertical) {
259
259
  newY = newY > 0 ? 0 : newY < extremeTop ? extremeTop : newY;
260
-
261
260
  }
262
261
  const _offset = {
263
262
  x: newX,
@@ -4,7 +4,7 @@ import { getPreloadImagArr, downloadImage, isTargetEmit } from "./utils";
4
4
 
5
5
  export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
6
6
  getIsInGroup: () => boolean;
7
- notifyChange: (index: number) => void;
7
+ notifyChange: (index: number, direction: string) => void;
8
8
  notifyZoom: (zoom: number, increase: boolean) => void;
9
9
  notifyClose: () => void;
10
10
  notifyVisibleChange: (visible: boolean) => void;
@@ -119,7 +119,7 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
119
119
  currentIndex: newIndex,
120
120
  } as any);
121
121
  }
122
- this._adapter.notifyChange(newIndex);
122
+ this._adapter.notifyChange(newIndex, direction);
123
123
  this.setState({
124
124
  direction,
125
125
  rotation: 0,
@@ -337,6 +337,18 @@
337
337
  .semi-cascader-option-lists .semi-cascader-option-icon-active, .semi-cascader-option-lists .semi-cascader-option-icon-empty {
338
338
  margin-right: 8px;
339
339
  }
340
+ .semi-cascader-option-lists .semi-cascader-option-icon-left {
341
+ margin-left: 8px;
342
+ }
343
+ .semi-cascader-option-lists .semi-cascader-option-spin-icon {
344
+ width: 16px;
345
+ height: 16px;
346
+ line-height: 0;
347
+ }
348
+ .semi-cascader-option-lists .semi-cascader-option-spin-icon svg {
349
+ width: 16px;
350
+ height: 16px;
351
+ }
340
352
  .semi-cascader-option-lists .semi-cascader-option-label {
341
353
  display: flex;
342
354
  align-items: center;
@@ -408,6 +408,21 @@ $module: #{$prefix}-cascader;
408
408
  &-empty {
409
409
  margin-right: $spacing-cascader_empty_icon-marginRight;
410
410
  }
411
+
412
+ &-left {
413
+ margin-left: $spacing-cascader_option-icon-marginLeft;
414
+ }
415
+ }
416
+
417
+ &-spin-icon {
418
+ width: $width-cascader-icon;
419
+ height: $width-cascader-icon;
420
+ line-height: 0;
421
+
422
+ & svg {
423
+ width: $width-cascader-icon;
424
+ height: $width-cascader-icon;
425
+ }
411
426
  }
412
427
 
413
428
  &-label {
@@ -51,6 +51,7 @@ $spacing-cascader_selection_tagInput-marginLeft: - $spacing-extra-tight; // 级
51
51
  $spacing-cascader_selection_input-marginLeft: $spacing-extra-tight; // 级联选择触发器多选搜索时输入框的左外边距
52
52
  $spacing-cascader_selection_n-marginRight: $spacing-extra-tight; // 超出 maxTagCount 后,+n 的右外边距
53
53
  $spacing-cascader_clearBtn-marginRight: 12px; // 级联选择触发器清空按钮右侧外边距
54
+ $spacing-cascader_option-icon-marginLeft: 8px; // 级联选择菜单项图标左侧外边距
54
55
 
55
56
  $color-cascader_selection_n-text-default: var(--semi-color-text-0); // 超出 maxTagCount 后,+n 的文字默认颜色
56
57
  $color-cascader_selection_n-text-disabled: var(--semi-color-disabled-text); // 超出 maxTagCount 后,+n 的文字disabled颜色
@@ -3,25 +3,27 @@ import { Options as scrollIntoViewOptions } from 'scroll-into-view-if-needed';
3
3
  export declare type BasicTriggerType = 'blur' | 'change' | 'custom' | 'mount';
4
4
  export declare type FieldValidateTriggerType = BasicTriggerType | Array<BasicTriggerType>;
5
5
  export declare type CommonFieldError = boolean | string | Array<any> | undefined | unknown;
6
- export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
6
+ export declare type BasicFieldError = Array<any>;
7
+ export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any>, Values extends object = any> extends DefaultAdapter<P, S> {
7
8
  cloneDeep: (val: any, ...rest: any[]) => any;
8
9
  notifySubmit: (values: any) => void;
9
- notifySubmitFail: (errors: Record<string, any>, values: any) => void;
10
+ notifySubmitFail: (errors: Record<keyof Values, BasicFieldError>, values: Partial<Values>) => void;
10
11
  forceUpdate: (callback?: () => void) => void;
11
12
  notifyChange: (formState: FormState) => void;
12
13
  notifyValueChange: (values: any, changedValues: any) => void;
13
14
  notifyReset: () => void;
14
- getInitValues: () => Record<string, any>;
15
+ getInitValues: () => Partial<Values>;
15
16
  getFormProps: (keys: undefined | string | Array<string>) => any;
16
17
  getAllErrorDOM: () => NodeList;
17
18
  getFieldDOM: (field: string) => Node;
18
19
  initFormId: () => void;
19
20
  }
21
+ export declare type AllErrors<T> = T extends Record<string, any> ? {
22
+ [K in keyof T]?: string;
23
+ } : Record<string, any>;
20
24
  export interface FormState<T extends Record<string, any> = any> {
21
25
  values?: T extends Record<string, any> ? T : Record<string, any>;
22
- errors?: T extends Record<string, any> ? {
23
- [K in keyof T]?: string;
24
- } : Record<string, any>;
26
+ errors?: AllErrors<T>;
25
27
  touched?: T extends Record<string, any> ? {
26
28
  [K in keyof T]?: boolean;
27
29
  } : Record<string, any>;
@@ -71,7 +71,7 @@ class ImageFoundation extends _foundation.default {
71
71
  } = preview;
72
72
  onVisibleChange && onVisibleChange(newVisible);
73
73
 
74
- if (!("visible" in this.getProps())) {
74
+ if (!("visible" in preview)) {
75
75
  this.setState({
76
76
  previewVisible: newVisible
77
77
  });
@@ -39,9 +39,9 @@ class PreviewFooterFoundation extends _foundation.default {
39
39
  } = this.getProps();
40
40
 
41
41
  if (value > zoom) {
42
- onZoomIn(value / 100);
42
+ onZoomIn(Number((value / 100).toFixed(2)));
43
43
  } else {
44
- onZoomOut(value / 100);
44
+ onZoomOut(Number((value / 100).toFixed(2)));
45
45
  }
46
46
 
47
47
  this._adapter.setStartMouseOffset(value);
@@ -1,7 +1,7 @@
1
1
  import BaseFoundation, { DefaultAdapter } from "../base/foundation";
2
2
  export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
3
3
  getIsInGroup: () => boolean;
4
- notifyChange: (index: number) => void;
4
+ notifyChange: (index: number, direction: string) => void;
5
5
  notifyZoom: (zoom: number, increase: boolean) => void;
6
6
  notifyClose: () => void;
7
7
  notifyVisibleChange: (visible: boolean) => void;
@@ -133,7 +133,7 @@ class PreviewInnerFoundation extends _foundation.default {
133
133
  });
134
134
  }
135
135
 
136
- this._adapter.notifyChange(newIndex);
136
+ this._adapter.notifyChange(newIndex, direction);
137
137
 
138
138
  this.setState({
139
139
  direction,
@@ -87,6 +87,12 @@
87
87
  align-items: center;
88
88
  justify-content: flex-start;
89
89
  }
90
+ .semi-navigation-item-has-link {
91
+ padding: 0;
92
+ }
93
+ .semi-navigation-item-has-link .semi-navigation-item-link {
94
+ padding: 8px 12px;
95
+ }
90
96
  .semi-navigation-item-sub {
91
97
  padding: 0;
92
98
  }
@@ -113,6 +113,15 @@ $module: #{$prefix}-navigation;
113
113
  justify-content: flex-start;
114
114
  }
115
115
 
116
+ // when item has link, add the padding to link instead of item
117
+ &-item-has-link {
118
+ padding: 0;
119
+
120
+ .#{$module}-item-link {
121
+ padding: $spacing-navigation_item-paddingY $spacing-navigation_item-paddingX;
122
+ }
123
+ }
124
+
116
125
  &-item-sub {
117
126
  padding: $spacing-navigation_item_sub-padding;
118
127
  }
@@ -73,5 +73,6 @@ declare const numbers: {
73
73
  readonly DEFAULT_VIRTUALIZED_SECTION_ROW_SMALL_HEIGHT: number;
74
74
  readonly DEFAULT_VIRTUALIZED_ROW_SMALL_HEIGHT: number;
75
75
  readonly DEFAULT_VIRTUALIZED_ROW_SMALL_MIN_HEIGHT: number;
76
+ readonly DEFAULT_EMPTYSLOT_HEIGHT: 52;
76
77
  };
77
78
  export { cssClasses, strings, numbers };
@@ -66,7 +66,8 @@ const DEFAULT_CELL_MIDDLE_PADDING_TOP = 12;
66
66
  const DEFAULT_CELL_MIDDLE_PADDING_BOTTOM = 12;
67
67
  const DEFAULT_CELL_SMALL_PADDING_TOP = 8;
68
68
  const DEFAULT_CELL_SMALL_PADDING_BOTTOM = 8;
69
- const DEFAULT_CELL_LINE_HEIGHT = 20; // normal size
69
+ const DEFAULT_CELL_LINE_HEIGHT = 20;
70
+ const DEFAULT_EMPTYSLOT_HEIGHT = 52; // normal size
70
71
 
71
72
  const DEFAULT_VIRTUALIZED_ROW_HEIGHT = DEFAULT_CELL_LINE_HEIGHT + DEFAULT_CELL_BORDER_WITH_BOTTOM + DEFAULT_CELL_BORDER_WITH_TOP + DEFAULT_CELL_PADDING_TOP + DEFAULT_CELL_PADDING_BOTTOM;
72
73
  const DEFAULT_VIRTUALIZED_ROW_MIN_HEIGHT = DEFAULT_CELL_PADDING_TOP + DEFAULT_CELL_PADDING_BOTTOM + DEFAULT_CELL_BORDER_WITH_BOTTOM; // middle size
@@ -102,6 +103,7 @@ const numbers = {
102
103
  DEFAULT_VIRTUALIZED_ROW_MIDDLE_MIN_HEIGHT,
103
104
  DEFAULT_VIRTUALIZED_SECTION_ROW_SMALL_HEIGHT: DEFAULT_VIRTUALIZED_ROW_SMALL_HEIGHT,
104
105
  DEFAULT_VIRTUALIZED_ROW_SMALL_HEIGHT,
105
- DEFAULT_VIRTUALIZED_ROW_SMALL_MIN_HEIGHT
106
+ DEFAULT_VIRTUALIZED_ROW_SMALL_MIN_HEIGHT,
107
+ DEFAULT_EMPTYSLOT_HEIGHT
106
108
  };
107
109
  exports.numbers = numbers;
@@ -394,7 +394,8 @@
394
394
  border-right: 1px solid var(--semi-color-border);
395
395
  }
396
396
  .semi-table-placeholder {
397
- position: relative;
397
+ position: sticky;
398
+ left: 0px;
398
399
  z-index: 1;
399
400
  padding: 16px 12px;
400
401
  color: var(--semi-color-text-2);
@@ -481,7 +481,8 @@ $module: #{$prefix}-table;
481
481
  }
482
482
 
483
483
  &-placeholder {
484
- position: relative;
484
+ position: sticky;
485
+ left: 0px;
485
486
  z-index: 1;
486
487
  padding: #{$spacing-table-paddingY} #{$spacing-table-paddingX};
487
488
  color: $color-table_placeholder-text-default;
@@ -18,5 +18,6 @@ declare const numbers: {
18
18
  readonly MOUSE_ENTER_DELAY: 50;
19
19
  readonly MOUSE_LEAVE_DELAY: 50;
20
20
  readonly SPACING: 8;
21
+ readonly MARGIN: 0;
21
22
  };
22
23
  export { cssClasses, strings, numbers };
@@ -28,7 +28,7 @@ const numbers = {
28
28
  DEFAULT_Z_INDEX: 1060,
29
29
  MOUSE_ENTER_DELAY: 50,
30
30
  MOUSE_LEAVE_DELAY: 50,
31
- SPACING: 8 // Values are consistent with spacing-tight in scss
32
-
31
+ SPACING: 8,
32
+ MARGIN: 0
33
33
  };
34
34
  exports.numbers = numbers;
@@ -65,7 +65,10 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
65
65
  _bindResizeEvent(): void;
66
66
  unBindResizeEvent(): void;
67
67
  removePortal: () => void;
68
+ _adjustPos(position?: string, isVertical?: boolean, adjustType?: string, concatPos?: any): string;
68
69
  _reversePos(position?: string, isVertical?: boolean): string;
70
+ _expandPos(position: string, concatPos: string): string;
71
+ _reducePos(position?: string): string;
69
72
  clearDelayTimer(): void;
70
73
  _generateEvent(types: ArrayElement<typeof strings.TRIGGER_SET>): {
71
74
  triggerEventSet: {
@@ -80,7 +83,14 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
80
83
  _togglePortalVisible(isVisible: boolean): void;
81
84
  _roundPixel(pixel: number): number;
82
85
  calcTransformOrigin(position: Position, triggerRect: DOMRect, translateX: number, translateY: number): string;
83
- calcPosStyle(triggerRect: DOMRect, wrapperRect: DOMRect, containerRect: PopupContainerDOMRect, position?: Position, spacing?: number): Record<string, string | number>;
86
+ calcPosStyle(props: {
87
+ triggerRect: DOMRect;
88
+ wrapperRect: DOMRect;
89
+ containerRect: PopupContainerDOMRect;
90
+ position?: Position;
91
+ spacing?: number;
92
+ isOverFlow?: [boolean, boolean];
93
+ }): Record<string, string | number>;
84
94
  /**
85
95
  * 耦合的东西比较多,稍微罗列一下:
86
96
  *
@@ -97,7 +107,16 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
97
107
  calcPosition: (triggerRect?: DOMRect, wrapperRect?: DOMRect, containerRect?: PopupContainerDOMRect, shouldUpdatePos?: boolean) => Record<string, string | number>;
98
108
  isLR(position?: string): boolean;
99
109
  isTB(position?: string): boolean;
100
- adjustPosIfNeed(position: Position | string, style: Record<string, any>, triggerRect: DOMRect, wrapperRect: DOMRect, containerRect: PopupContainerDOMRect): string;
110
+ isReverse(rowSpace: number, reverseSpace: number, size: number): boolean;
111
+ isOverFlow(rowSpace: number, reverseSpace: number, size: number): boolean;
112
+ isHalfOverFlow(posSpace: number, negSpace: number, size: number): boolean;
113
+ isHalfAllEnough(posSpace: number, negSpace: number, size: number): boolean;
114
+ getReverse(viewOverFlow: boolean, containerOverFlow: boolean, shouldReverseView: boolean, shouldReverseContainer: boolean): boolean;
115
+ adjustPosIfNeed(position: Position | string, style: Record<string, any>, triggerRect: DOMRect, wrapperRect: DOMRect, containerRect: PopupContainerDOMRect): {
116
+ position: string;
117
+ isHeightOverFlow: boolean;
118
+ isWidthOverFlow: boolean;
119
+ };
101
120
  delayHide: () => void;
102
121
  hide: () => void;
103
122
  _bindScrollEvent(): void;