@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
@@ -36,7 +36,7 @@ export default class TransferFoundation<P = Record<string, any>, S = Record<stri
36
36
  _generateGroupedData(dataSource: any[]): any[];
37
37
  _generateTreeData(dataSource: any[]): any[];
38
38
  _generatePath(item: BasicResolvedDataItem): any;
39
- handleInputChange(inputVal: string): void;
39
+ handleInputChange(inputVal: string, notify: boolean): void;
40
40
  handleAll(wantAllChecked: boolean): void;
41
41
  handleClear(): void;
42
42
  handleSelectOrRemove(item: BasicResolvedDataItem): void;
@@ -38,7 +38,7 @@ class TransferFoundation extends _foundation.default {
38
38
  return path.map(p => p.label).join(' > ');
39
39
  }
40
40
 
41
- handleInputChange(inputVal) {
41
+ handleInputChange(inputVal, notify) {
42
42
  const {
43
43
  data
44
44
  } = this.getStates();
@@ -52,7 +52,7 @@ class TransferFoundation extends _foundation.default {
52
52
 
53
53
  this._adapter.searchTree(inputVal);
54
54
 
55
- this._adapter.notifySearch(inputVal);
55
+ notify && this._adapter.notifySearch(inputVal);
56
56
 
57
57
  this._adapter.updateInput(inputVal);
58
58
 
@@ -64,8 +64,7 @@ class TransferFoundation extends _foundation.default {
64
64
  const filterFunc = typeof filter === 'function' ? item => filter(inputVal, item) : item => typeof item.label === 'string' && item.label.includes(inputVal);
65
65
  const searchData = data.filter(filterFunc);
66
66
  const searchResult = new Set(searchData.map(item => item.key));
67
-
68
- this._adapter.notifySearch(inputVal);
67
+ notify && this._adapter.notifySearch(inputVal);
69
68
 
70
69
  this._adapter.updateInput(inputVal);
71
70
 
@@ -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>;
@@ -60,7 +60,7 @@ export default class ImageFoundation extends BaseFoundation {
60
60
  } = preview;
61
61
  onVisibleChange && onVisibleChange(newVisible);
62
62
 
63
- if (!("visible" in this.getProps())) {
63
+ if (!("visible" in preview)) {
64
64
  this.setState({
65
65
  previewVisible: newVisible
66
66
  });
@@ -29,9 +29,9 @@ export default class PreviewFooterFoundation extends BaseFoundation {
29
29
  } = this.getProps();
30
30
 
31
31
  if (value > zoom) {
32
- onZoomIn(value / 100);
32
+ onZoomIn(Number((value / 100).toFixed(2)));
33
33
  } else {
34
- onZoomOut(value / 100);
34
+ onZoomOut(Number((value / 100).toFixed(2)));
35
35
  }
36
36
 
37
37
  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;
@@ -120,7 +120,7 @@ export default class PreviewInnerFoundation extends BaseFoundation {
120
120
  });
121
121
  }
122
122
 
123
- this._adapter.notifyChange(newIndex);
123
+ this._adapter.notifyChange(newIndex, direction);
124
124
 
125
125
  this.setState({
126
126
  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 };
@@ -56,7 +56,8 @@ const DEFAULT_CELL_MIDDLE_PADDING_TOP = 12;
56
56
  const DEFAULT_CELL_MIDDLE_PADDING_BOTTOM = 12;
57
57
  const DEFAULT_CELL_SMALL_PADDING_TOP = 8;
58
58
  const DEFAULT_CELL_SMALL_PADDING_BOTTOM = 8;
59
- const DEFAULT_CELL_LINE_HEIGHT = 20; // normal size
59
+ const DEFAULT_CELL_LINE_HEIGHT = 20;
60
+ const DEFAULT_EMPTYSLOT_HEIGHT = 52; // normal size
60
61
 
61
62
  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;
62
63
  const DEFAULT_VIRTUALIZED_ROW_MIN_HEIGHT = DEFAULT_CELL_PADDING_TOP + DEFAULT_CELL_PADDING_BOTTOM + DEFAULT_CELL_BORDER_WITH_BOTTOM; // middle size
@@ -92,6 +93,7 @@ const numbers = {
92
93
  DEFAULT_VIRTUALIZED_ROW_MIDDLE_MIN_HEIGHT,
93
94
  DEFAULT_VIRTUALIZED_SECTION_ROW_SMALL_HEIGHT: DEFAULT_VIRTUALIZED_ROW_SMALL_HEIGHT,
94
95
  DEFAULT_VIRTUALIZED_ROW_SMALL_HEIGHT,
95
- DEFAULT_VIRTUALIZED_ROW_SMALL_MIN_HEIGHT
96
+ DEFAULT_VIRTUALIZED_ROW_SMALL_MIN_HEIGHT,
97
+ DEFAULT_EMPTYSLOT_HEIGHT
96
98
  };
97
99
  export { cssClasses, strings, 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 };
@@ -18,7 +18,7 @@ const numbers = {
18
18
  DEFAULT_Z_INDEX: 1060,
19
19
  MOUSE_ENTER_DELAY: 50,
20
20
  MOUSE_LEAVE_DELAY: 50,
21
- SPACING: 8 // Values are consistent with spacing-tight in scss
22
-
21
+ SPACING: 8,
22
+ MARGIN: 0
23
23
  };
24
24
  export { cssClasses, strings, 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;