@fibrae/semi-foundation 0.2.0 → 0.3.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.
- package/LICENSE +0 -62
- package/README.md +36 -34
- package/README.zh-CN.md +79 -0
- package/dist/anchor/foundation.d.ts +0 -3
- package/dist/anchor/foundation.js +0 -1
- package/dist/audio-player/foundation.d.ts +0 -3
- package/dist/audio-player/foundation.js +0 -1
- package/dist/auto-complete/foundation.d.ts +0 -2
- package/dist/auto-complete/foundation.js +0 -1
- package/dist/avatar/foundation.d.ts +0 -1
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +0 -3
- package/dist/backtop/foundation.js +0 -1
- package/dist/base/auto-close-foundation.d.ts +0 -1
- package/dist/base/foundation.d.ts +0 -1
- package/dist/base/list-store.d.ts +0 -1
- package/dist/calendar/event-util.d.ts +0 -10
- package/dist/calendar/event-util.js +0 -10
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +1 -5
- package/dist/calendar/month-foundation.d.ts +0 -1
- package/dist/calendar/month-foundation.js +0 -1
- package/dist/carousel/foundation.d.ts +0 -2
- package/dist/cascader/foundation.d.ts +2 -6
- package/dist/cascader/foundation.js +2 -11
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +1 -5
- package/dist/checkbox/checkbox-foundation.js +0 -2
- package/dist/checkbox/checkbox-group-foundation.d.ts +0 -1
- package/dist/code-highlight/index.d.ts +0 -1
- package/dist/color-picker/color-picker.scss +0 -2
- package/dist/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +0 -1
- package/dist/cropper/foundation.js +0 -1
- package/dist/date-picker/_utils/get-default-picker-date.d.ts +0 -3
- package/dist/date-picker/_utils/get-default-picker-date.js +0 -3
- package/dist/date-picker/_utils/get-inset-input-format-token.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-format-token.js +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.js +0 -2
- package/dist/date-picker/_utils/parser.d.ts +0 -3
- package/dist/date-picker/_utils/parser.js +0 -7
- package/dist/date-picker/_utils/picker-type.d.ts +1 -3
- package/dist/date-picker/_utils/picker-type.js +0 -2
- package/dist/date-picker/_utils/to-callback-args.d.ts +0 -1
- package/dist/date-picker/_utils/to-callback-args.js +0 -1
- package/dist/date-picker/date-picker.scss +0 -3
- package/dist/date-picker/foundation.d.ts +3 -22
- package/dist/date-picker/foundation.js +1 -24
- package/dist/date-picker/input-foundation.d.ts +1 -7
- package/dist/date-picker/input-foundation.js +0 -2
- package/dist/date-picker/month-foundation.d.ts +0 -3
- package/dist/date-picker/month-foundation.js +0 -2
- package/dist/date-picker/months-grid-foundation.d.ts +1 -10
- package/dist/date-picker/months-grid-foundation.js +1 -10
- package/dist/drag-move/foundation.d.ts +0 -1
- package/dist/dropdown/foundation.d.ts +0 -2
- package/dist/dropdown/menu-foundation.d.ts +1 -2
- package/dist/feedback/foundation.d.ts +0 -1
- package/dist/feedback/variables.scss +1 -5
- package/dist/float-button/float-button.css +0 -1
- package/dist/float-button/float-button.scss +0 -2
- package/dist/form/form.scss +0 -12
- package/dist/form/foundation.js +0 -15
- package/dist/form/interface.d.ts +2 -15
- package/dist/form/utils.d.ts +0 -8
- package/dist/form/utils.js +0 -7
- package/dist/form/variables.scss +1 -4
- package/dist/grid/variables.scss +0 -10
- package/dist/highlight/foundation.d.ts +0 -2
- package/dist/highlight/foundation.js +0 -2
- package/dist/hot-keys/foundation.d.ts +0 -1
- package/dist/image/image-foundation.d.ts +0 -2
- package/dist/image/preview-footer-foundation.d.ts +0 -1
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-image-foundation.d.ts +0 -1
- package/dist/image/preview-inner-foundation.d.ts +0 -1
- package/dist/input/foundation.d.ts +0 -1
- package/dist/input/text-entry-foundation.d.ts +0 -2
- package/dist/input/text-entry-foundation.js +0 -1
- package/dist/input/textarea-foundation.d.ts +0 -1
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +0 -5
- package/dist/input-number/foundation.js +0 -5
- package/dist/json-viewer/foundation.d.ts +0 -2
- package/dist/json-viewer/foundation.js +0 -1
- package/dist/locale/interface.d.ts +0 -3
- package/dist/markdown-render/foundation.d.ts +1 -6
- package/dist/markdown-render/foundation.js +1 -5
- package/dist/navigation/foundation.d.ts +0 -7
- package/dist/navigation/foundation.js +0 -6
- package/dist/navigation/sub-nav-foundation.d.ts +0 -1
- package/dist/notification/notification-list-foundation.d.ts +2 -3
- package/dist/notification/notification-list-foundation.js +0 -1
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +0 -2
- package/dist/overflow-list/foundation.js +0 -1
- package/dist/pagination/foundation.d.ts +0 -2
- package/dist/pincode/foundation.d.ts +1 -4
- package/dist/pincode/foundation.js +1 -4
- package/dist/popconfirm/popconfirm-foundation.d.ts +0 -2
- package/dist/progress/generates.d.ts +1 -4
- package/dist/progress/generates.js +1 -4
- package/dist/progress/utils.d.ts +1 -1
- package/dist/progress/utils.js +1 -1
- package/dist/radio/radio-foundation.d.ts +0 -4
- package/dist/radio/radio-foundation.js +0 -1
- package/dist/radio/radio-group-foundation.d.ts +0 -1
- package/dist/rating/foundation.d.ts +0 -5
- package/dist/rating/foundation.js +0 -3
- package/dist/resizable/group/index.d.ts +0 -4
- package/dist/resizable/group/index.js +0 -4
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +1 -5
- package/dist/resizable/single/index.js +1 -4
- package/dist/scroll-list/item-foundation.d.ts +0 -2
- package/dist/scroll-list/item-foundation.js +0 -1
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +0 -1
- package/dist/select/option-foundation.d.ts +2 -3
- package/dist/select/option-foundation.js +0 -1
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +1 -6
- package/dist/side-sheet/side-sheet-foundation.js +1 -5
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +1 -12
- package/dist/slider/foundation.js +1 -13
- package/dist/slider/variables.scss +1 -5
- package/dist/spin/foundation.d.ts +0 -2
- package/dist/spin/foundation.js +0 -1
- package/dist/spin/variables.scss +1 -3
- package/dist/switch/foundation.d.ts +0 -1
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +12 -21
- package/dist/table/foundation.js +51 -15
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +0 -8
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +0 -9
- package/dist/tabs/foundation.js +0 -4
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +0 -2
- package/dist/tag-input/foundation.js +0 -1
- package/dist/tag-input/tag-input.scss +0 -1
- package/dist/tag-input/utils/tag-focus.d.ts +0 -1
- package/dist/tag-input/utils/tag-focus.js +0 -1
- package/dist/time-picker/combox-foundation.d.ts +3 -11
- package/dist/time-picker/combox-foundation.js +3 -10
- package/dist/time-picker/foundation.d.ts +0 -10
- package/dist/time-picker/foundation.js +0 -9
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- package/dist/tooltip/adjust-position.d.ts +1 -2
- package/dist/tooltip/constants.d.ts +0 -3
- package/dist/tooltip/constants.js +0 -3
- package/dist/tooltip/foundation.d.ts +0 -3
- package/dist/tooltip/foundation.js +0 -2
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +0 -4
- package/dist/transfer/foundation.js +0 -1
- package/dist/tree/foundation.d.ts +0 -2
- package/dist/tree/foundation.js +0 -1
- package/dist/tree/shared.d.ts +1 -3
- package/dist/tree/shared.js +0 -2
- package/dist/tree/tree-util.d.ts +0 -5
- package/dist/tree/tree-util.js +0 -5
- package/dist/tree-select/foundation.d.ts +0 -2
- package/dist/tree-select/foundation.js +0 -3
- package/dist/typography/ellipsis.d.ts +1 -3
- package/dist/typography/ellipsis.js +0 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +0 -6
- package/dist/upload/foundation.js +1 -11
- package/dist/upload/utils.d.ts +0 -5
- package/dist/upload/utils.js +0 -5
- package/dist/user-guide/foundation.d.ts +0 -2
- package/dist/utils/a11y.d.ts +1 -5
- package/dist/utils/a11y.js +1 -4
- package/dist/utils/array.d.ts +0 -6
- package/dist/utils/array.js +0 -6
- package/dist/utils/date-fns-extra.js +1 -5
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/dom.js +0 -1
- package/dist/utils/escape-html.js +0 -3
- package/dist/utils/field-sizing.d.ts +0 -2
- package/dist/utils/field-sizing.js +0 -2
- package/dist/utils/focus-handle.d.ts +0 -1
- package/dist/utils/focus-handle.js +0 -1
- package/dist/utils/focus-scope.d.ts +0 -1
- package/dist/utils/focus-scope.js +0 -1
- package/dist/utils/scroll-lock.d.ts +3 -4
- package/dist/utils/scroll-lock.js +3 -4
- package/dist/utils/tween.d.ts +0 -1
- package/dist/utils/tween.js +0 -1
- package/dist/utils/uuid.d.ts +0 -1
- package/dist/utils/uuid.js +0 -1
- package/dist/utils/warning.d.ts +0 -1
- package/dist/utils/warning.js +0 -1
- package/dist/video-player/progress-foundation.d.ts +0 -1
- package/dist/video-player/progress-foundation.js +0 -1
- package/dist/video-player/variables.scss +1 -1
- package/package.json +2 -2
|
@@ -7,11 +7,7 @@ var SideSheetFoundation = class extends BaseFoundation {
|
|
|
7
7
|
this.handleCancel(e);
|
|
8
8
|
return true;
|
|
9
9
|
};
|
|
10
|
-
/**
|
|
11
|
-
* A top or bottom sheet spans the width unless `canVerticalSetWidth`, and takes `height` (448 by default); a left or
|
|
12
|
-
* right sheet spans the height. Without a mask the width goes on the outer element and the dialog fills it: a
|
|
13
|
-
* percentage repeated on the dialog would compound.
|
|
14
|
-
*/
|
|
10
|
+
/** Without a mask the width goes on the outer element and the dialog fills it: a percentage repeated on the dialog would compound. */
|
|
15
11
|
static getSheetSize({ placement, canVerticalSetWidth, width, height, mask }) {
|
|
16
12
|
const horizontal = placement === "top" || placement === "bottom";
|
|
17
13
|
const sheetWidth = horizontal && !canVerticalSetWidth ? "100%" : width;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$color-sideSheet_mask-bg: var(--semi-color-overlay-bg); // 侧边栏打开后蒙层颜色
|
|
4
4
|
$color-sideSheet-bg: var(--semi-color-bg-2); // 侧边栏背景颜色
|
|
5
5
|
$color-sideSheet_main-text: var(--semi-color-text-0); // 侧边栏默认文本颜色
|
|
6
6
|
$color-sideSheet_header-borderBottom: var(--semi-color-border); // 侧边栏 header 底部边框颜色
|
|
7
7
|
|
|
8
|
-
// Spacing
|
|
9
8
|
$spacing-sideSheet-margin: 0; // 侧边栏整体外边距
|
|
10
9
|
$spacing-sideSheet_title-margin: 0; // 侧边栏标题外边距
|
|
11
10
|
$spacing-sideSheet_header-padding: $spacing-loose; // 侧边栏 header 内边距
|
|
@@ -19,7 +18,6 @@ $width-sideSheet_size-small: 448px; // 小尺寸侧边栏宽度
|
|
|
19
18
|
$width-sideSheet_size-medium: 684px; // 中尺寸侧边栏宽度
|
|
20
19
|
$width-sideSheet_size-large: 920px; // 大尺寸侧边栏宽度
|
|
21
20
|
|
|
22
|
-
// Font
|
|
23
21
|
$font-sideSheet_title-fontWeight: $font-weight-bold; // 侧边栏标题文本字重
|
|
24
22
|
$font-sideSheet_title-fontSize: $font-size-header-5; // 侧边栏标题文本字号
|
|
25
23
|
|
|
@@ -66,9 +66,6 @@ export default class SliderFoundation<P extends SliderProps = SliderProps, S ext
|
|
|
66
66
|
x: number;
|
|
67
67
|
y: number;
|
|
68
68
|
};
|
|
69
|
-
/**
|
|
70
|
-
* Clamps a pointer position to the slider's start and end
|
|
71
|
-
*/
|
|
72
69
|
protected checkMeetMinMax(position: number): number;
|
|
73
70
|
/** Position to value snapped to step; false when nothing changes or the slider has no layout */
|
|
74
71
|
protected transPosToValue(mousePos: number, isMin: boolean): any;
|
|
@@ -77,16 +74,11 @@ export default class SliderFoundation<P extends SliderProps = SliderProps, S ext
|
|
|
77
74
|
protected calculateOutputValue(position: number, isMin: boolean): undefined | number | number[];
|
|
78
75
|
protected checkWhichHandle(pagePos: number): boolean;
|
|
79
76
|
static getInitialState(props: SliderProps): SliderState;
|
|
80
|
-
/**
|
|
81
|
-
* Percentages of the current value; they increase with value whatever the visual direction.
|
|
82
|
-
*/
|
|
77
|
+
/** The percentages increase with value whatever the visual direction. */
|
|
83
78
|
static getMinAndMaxPercent({ range, min, max }: SliderProps, value: SliderState['currentValue']): {
|
|
84
79
|
min: number;
|
|
85
80
|
max: number;
|
|
86
81
|
};
|
|
87
|
-
/**
|
|
88
|
-
* Whether each handle shows its tooltip, and the tooltip contents
|
|
89
|
-
*/
|
|
90
82
|
static computeHandleVisibleVal({ tooltipVisible, tipFormatter: formatter, range, step, min }: SliderProps, { activeHandle, currentValue, isInRenderTree }: SliderState): {
|
|
91
83
|
tipVisible: {
|
|
92
84
|
min: boolean;
|
|
@@ -128,9 +120,6 @@ export default class SliderFoundation<P extends SliderProps = SliderProps, S ext
|
|
|
128
120
|
destroy(): void;
|
|
129
121
|
/** An event handler, so the tooltips follow a container that was hidden */
|
|
130
122
|
syncIsInRenderTree: () => void;
|
|
131
|
-
/**
|
|
132
|
-
* Syncs a changed value prop, clamped to min and max
|
|
133
|
-
*/
|
|
134
123
|
handleValueChange: (nextValue: SliderProps["value"]) => void;
|
|
135
124
|
/** A value prop back to undefined (a Form reset) returns to the default position */
|
|
136
125
|
resetValue: () => void;
|
|
@@ -77,7 +77,6 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
77
77
|
#notifyAfterChange() {
|
|
78
78
|
this.adapter.notifyAfterChange(this.normalizeValue(this.getState("currentValue")));
|
|
79
79
|
}
|
|
80
|
-
/** A controlled value only moves through the value prop */
|
|
81
80
|
#moveHandle(nextValue, callback) {
|
|
82
81
|
this.syncIsInRenderTree();
|
|
83
82
|
if (!this.getState("isInRenderTree")) return;
|
|
@@ -134,9 +133,6 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
134
133
|
y: clientY - parentY
|
|
135
134
|
};
|
|
136
135
|
}
|
|
137
|
-
/**
|
|
138
|
-
* Clamps a pointer position to the slider's start and end
|
|
139
|
-
*/
|
|
140
136
|
checkMeetMinMax(position) {
|
|
141
137
|
const { vertical, verticalReverse } = this.adapter.getProps();
|
|
142
138
|
const isRTL = this.adapter.getContext("direction") === "rtl" && !vertical;
|
|
@@ -220,9 +216,7 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
220
216
|
focusVisibleHandle: ""
|
|
221
217
|
};
|
|
222
218
|
}
|
|
223
|
-
/**
|
|
224
|
-
* Percentages of the current value; they increase with value whatever the visual direction.
|
|
225
|
-
*/
|
|
219
|
+
/** The percentages increase with value whatever the visual direction. */
|
|
226
220
|
static getMinAndMaxPercent({ range, min, max }, value) {
|
|
227
221
|
const minPercent = range ? (value[0] - min) / (max - min) : (value - min) / (max - min);
|
|
228
222
|
const maxPercent = range ? (value[1] - min) / (max - min) : 1;
|
|
@@ -231,9 +225,6 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
231
225
|
max: clamp(maxPercent, 0, 1)
|
|
232
226
|
};
|
|
233
227
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Whether each handle shows its tooltip, and the tooltip contents
|
|
236
|
-
*/
|
|
237
228
|
static computeHandleVisibleVal({ tooltipVisible, tipFormatter: formatter, range, step, min }, { activeHandle, currentValue, isInRenderTree }) {
|
|
238
229
|
const visible = tooltipVisible && isInRenderTree;
|
|
239
230
|
const output = (value) => SliderFoundation.normalizeValue(step, min, activeHandle, value);
|
|
@@ -318,9 +309,6 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
318
309
|
const isInRenderTree = Boolean(slider && (slider.offsetWidth || slider.offsetHeight || slider.getClientRects().length));
|
|
319
310
|
if (isInRenderTree !== this.getState("isInRenderTree")) this.setState({ isInRenderTree });
|
|
320
311
|
};
|
|
321
|
-
/**
|
|
322
|
-
* Syncs a changed value prop, clamped to min and max
|
|
323
|
-
*/
|
|
324
312
|
handleValueChange = (nextValue) => {
|
|
325
313
|
if (!this.valueFormatIsCorrect(nextValue)) return;
|
|
326
314
|
this.setState({ currentValue: this.#clampToRange(nextValue) });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
2
|
@use '../base/mixin' as *;
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
$color-slider-text-default: var(--semi-color-text-0); // 滑动条文本颜色 - 默认
|
|
5
5
|
$color-slider_dot-bg-default: var(--semi-color-white); // 滑动条圆形刻度点颜色 - 默认态
|
|
6
6
|
$color-slider_dot-border-active: var(--semi-color-white); // 滑动条圆形刻度点描边颜色 - 按下态
|
|
@@ -18,7 +18,6 @@ $color-slider_track_disabled-bg: var(--semi-color-primary-disabled); // 禁用
|
|
|
18
18
|
$color-slider_handle-focus: $color-focus-ring; // 圆形按钮轮廓 - 聚焦
|
|
19
19
|
$color-slider_handle_dot: var(--semi-color-primary); // 圆形按钮内部圆点颜色
|
|
20
20
|
|
|
21
|
-
// Spacing
|
|
22
21
|
$spacing-slider-paddingX: 13px; // 滑动条整体水平内边距
|
|
23
22
|
$spacing-slider-paddingY: 0px; // 滑动条整体垂直内边距
|
|
24
23
|
$spacing-slider-margin: 0px; // 滑动条整体外边距
|
|
@@ -45,11 +44,9 @@ $spacing-slider_vertical_handle-translateX: 0px; // 垂直滑动条原型按钮
|
|
|
45
44
|
$spacing-slider_dot-translateX: 0px; // 水平滑动条圆形刻度点水平偏移量
|
|
46
45
|
$spacing-slider_vertical_dot-translateY: 0px; // 垂直滑动条圆形刻度点垂直偏移量
|
|
47
46
|
|
|
48
|
-
// Radius
|
|
49
47
|
$radius-slider_rail: var(--semi-border-radius-small); // 滚动条未填充轨道圆角
|
|
50
48
|
$radius-slider_track: var(--semi-border-radius-small); // 滚动条已填充轨道圆角
|
|
51
49
|
|
|
52
|
-
// Width/Height
|
|
53
50
|
$height-slider_wrapper: 32px; // 滚动条容器整体高度
|
|
54
51
|
$height-slider_vertical_wrapper: 4px; // 垂直滚动条整体宽度
|
|
55
52
|
$height-slider_rail: 4px; // 滚动条未填充轨道高度
|
|
@@ -61,7 +58,6 @@ $width-slider_handle_border_disabled: 1px; // 禁用滚动条圆形按钮按下
|
|
|
61
58
|
$width-slider_handle-focus: $width-focus-ring; // 圆形按钮轮廓 - 聚焦
|
|
62
59
|
$width-slider_handle_dot: 4px; // 圆形按钮内部圆点宽度
|
|
63
60
|
|
|
64
|
-
// Font
|
|
65
61
|
$font-slider_rail-fontSize: 14px; // 滚动条轨道文本字号
|
|
66
62
|
$font-slider_marks-fontSize: 14px; // 滚动条刻度标签字号
|
|
67
63
|
$font-slider_rail-lineHeight: 1.5; // 滚动条轨道文本行高倍数
|
|
@@ -2,13 +2,11 @@ import BaseFoundation, { DefaultAdapter } from "../base/foundation.js";
|
|
|
2
2
|
export interface SpinAdapter<P extends SpinBaseProps = SpinBaseProps, S extends object = object> extends DefaultAdapter<P, S> {
|
|
3
3
|
setLoading: (val: boolean) => void;
|
|
4
4
|
}
|
|
5
|
-
/** The props the foundation reads with getProps */
|
|
6
5
|
export interface SpinBaseProps {
|
|
7
6
|
delay?: number;
|
|
8
7
|
}
|
|
9
8
|
export default class SpinFoundation<P extends SpinBaseProps = SpinBaseProps, S extends object = object> extends BaseFoundation<SpinAdapter<P, S>, P, S> {
|
|
10
9
|
#private;
|
|
11
|
-
/** Shows the spinner after `delay`; stopping hides it at once and drops a pending show */
|
|
12
10
|
handleSpinningChange: (spinning: boolean) => void;
|
|
13
11
|
/**
|
|
14
12
|
* Called when the content under `root` becomes inert (`blocked`) or interactive again. inert drops focus to <body> on
|
package/dist/spin/foundation.js
CHANGED
|
@@ -8,7 +8,6 @@ var SpinFoundation = class extends BaseFoundation {
|
|
|
8
8
|
clearTimeout(this.#timer);
|
|
9
9
|
this.#timer = null;
|
|
10
10
|
}
|
|
11
|
-
/** Shows the spinner after `delay`; stopping hides it at once and drops a pending show */
|
|
12
11
|
handleSpinningChange = (spinning) => {
|
|
13
12
|
this.#clearTimer();
|
|
14
13
|
const { delay } = this.getProps();
|
package/dist/spin/variables.scss
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$color-spin-bg: var(--semi-color-primary); // 加载图标背景颜色
|
|
4
4
|
|
|
5
|
-
// Width
|
|
6
5
|
$width-spin_large: 32px; // 加载图标尺寸 - 大
|
|
7
6
|
$width-spin_middle: 20px; // 加载图标尺寸 - 中
|
|
8
7
|
$width-spin_small: 14px; // 加载图标尺寸 - 小
|
|
9
8
|
|
|
10
|
-
// Other
|
|
11
9
|
$opacity-spin_children: 0.5; // 加载图标透明度
|
package/dist/switch/switch.scss
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
2
|
@use '../base/mixin' as *;
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
$spacing-switch_unchecked-translateX: 2px; // 未选中态开关滑块位移距离
|
|
5
5
|
$spacing-switch_spin_unchecked-translateX: 2px; // 未选中态加载图标位移距离
|
|
6
6
|
$spacing-switch_checked-translateX: 18px; // 选中态开关滑块位移距离
|
|
@@ -17,7 +17,6 @@ $spacing-switch_checked_small-translateX: 11px; // 小尺寸选中态开关滑
|
|
|
17
17
|
$spacing-switch_spin_checked_small-translateX: 10px; // 小尺寸选中态加载图标位移距离
|
|
18
18
|
$motion-switch-transitionDuration: 200ms; // 开关动画时长
|
|
19
19
|
|
|
20
|
-
// Color
|
|
21
20
|
$color-switch_default-bg-default: var(--semi-color-fill-0); // 关闭态(未选中)开关背景色 - 默认
|
|
22
21
|
$color-switch_default-bg-hover: var(--semi-color-fill-1); // 关闭态开关背景色 - 悬浮
|
|
23
22
|
$color-switch_default-bg-active: var(--semi-color-fill-2); // 关闭态开关背景色 - 按下
|
|
@@ -42,7 +41,6 @@ $color-switch_spin_checked-bg-default: var(--semi-color-success-hover); // 已
|
|
|
42
41
|
$color-switch_spin_unchecked-bg-default: var(--semi-color-fill-1); // 已关闭开关加载态loading背景颜色
|
|
43
42
|
$color-switch_primary-outline-focus: $color-focus-ring; // 开关轮廓 - 聚焦
|
|
44
43
|
|
|
45
|
-
// Width/Height
|
|
46
44
|
$width-switch: 40px; // 开关宽度
|
|
47
45
|
$height-switch: 24px; // 开关高度
|
|
48
46
|
$width-switch_knob_expand: 6px; // 开关滑块按压时延展宽度
|
|
@@ -63,13 +61,11 @@ $width-switch_spin-default: 18px; // 默认尺寸开关加载 spin 宽度
|
|
|
63
61
|
$width-switch_spin-large: 28px; // 大尺寸开关加载 spin 宽度
|
|
64
62
|
$width-switch-outline: $width-focus-ring; // 开关轮廓宽度
|
|
65
63
|
|
|
66
|
-
// Spacing
|
|
67
64
|
$spacing-switch_knob-padding: 2px; // 开关滑块顶部边距
|
|
68
65
|
$spacing-switch_knob_large-padding: 3px; // 大尺寸开关滑块顶部边距
|
|
69
66
|
$spacing-switch_knob_small-padding: 1px; // 小尺寸开关滑块顶部边距
|
|
70
67
|
$spacing-switch_knob-left: 0px; // 开关滑块左侧偏移距离
|
|
71
68
|
|
|
72
|
-
// Radius
|
|
73
69
|
$radius-switch: $height-switch * 0.5; // 开关圆角
|
|
74
70
|
$radius-switch_large: $height-switch_large * 0.5; // 大尺寸开关圆角
|
|
75
71
|
$radius-switch_small: $height-switch_small * 0.5; // 小尺寸开关圆角
|
|
@@ -100,7 +100,6 @@ export interface BaseTableDataProps<RecordType> {
|
|
|
100
100
|
getCheckboxProps?: GetCheckboxProps<RecordType>;
|
|
101
101
|
} | boolean;
|
|
102
102
|
}
|
|
103
|
-
/** The rowSelection options the foundation reads */
|
|
104
103
|
export interface TableBaseRowSelection<RecordType> {
|
|
105
104
|
selectedRowKeys?: BaseRowKeyType[];
|
|
106
105
|
defaultSelectedRowKeys?: BaseRowKeyType[];
|
|
@@ -138,22 +137,17 @@ export interface TableBaseState<RecordType> {
|
|
|
138
137
|
/** Group key (what groupBy returns) -> the row keys in that group */
|
|
139
138
|
groups?: Map<string | number, Set<BaseRowKeyType>>;
|
|
140
139
|
allRowKeys?: BaseRowKeyType[];
|
|
141
|
-
/** Disabled row keys of the current page */
|
|
142
140
|
pageDisabledRowKeys?: BaseRowKeyType[];
|
|
143
141
|
pageDisabledRowKeysSet?: Set<BaseRowKeyType>;
|
|
144
142
|
headWidths?: BaseHeadWidth[][];
|
|
145
143
|
bodyHasScrollBar?: boolean;
|
|
146
|
-
/** The props the derived state was last computed from */
|
|
147
144
|
prePropRowSelection?: TableBaseProps<RecordType>['rowSelection'];
|
|
148
145
|
prePagination?: TableBaseProps<RecordType>['pagination'];
|
|
149
146
|
preExpandedRowKeys?: BaseRowKeyType[];
|
|
150
|
-
/** Disabled row keys in sorted and filtered data */
|
|
151
147
|
filteredDisabledRowKeys?: BaseRowKeyType[];
|
|
152
148
|
filteredDisabledRowKeysSet?: Set<BaseRowKeyType>;
|
|
153
|
-
/** Half-checked row keys for tree selection (checkRelation='related') */
|
|
154
149
|
halfCheckedRowKeys?: BaseRowKeyType[];
|
|
155
150
|
halfCheckedRowKeysSet?: Set<BaseRowKeyType>;
|
|
156
|
-
/** Key entities map for tree data structure */
|
|
157
151
|
keyEntities?: BaseEntitys;
|
|
158
152
|
filteredSortedDataSource?: RecordType[];
|
|
159
153
|
filteredSortedRowKeys?: BaseRowKeyType[];
|
|
@@ -185,9 +179,6 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
185
179
|
static initFilteredValue<R>(column: BaseColumnProps<R>): void;
|
|
186
180
|
static initSorterOrder<R>(column: BaseColumnProps<R>): void;
|
|
187
181
|
static getFilteredSortedDataSource<R>(props: BaseTableDataProps<R>, dataSource: R[], queries: BaseColumnProps<R>[]): R[];
|
|
188
|
-
/**
|
|
189
|
-
* Group, paginate and collect the row keys of filtered and sorted data
|
|
190
|
-
*/
|
|
191
182
|
static getPageData<R>(props: BaseTableDataProps<R>, dataSource: R[], pagination: BasePagination, queries: BaseColumnProps<R>[]): BasePageData<R>;
|
|
192
183
|
static groupDataSource<R>(props: BaseTableDataProps<R>, dataSource: R[]): {
|
|
193
184
|
groups: Map<string | number, Set<BaseRowKeyType>>;
|
|
@@ -213,7 +204,6 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
213
204
|
total?: number;
|
|
214
205
|
}) => any)): string;
|
|
215
206
|
static isSortOrderValid(sortOrder: BaseSortOrder): boolean;
|
|
216
|
-
/** The sort and filter state a header cell shows: the column's query by dataIndex, its sort order and filtered values */
|
|
217
207
|
static getColumnQueryState<Q extends {
|
|
218
208
|
dataIndex?: unknown;
|
|
219
209
|
sortOrder?: unknown;
|
|
@@ -233,7 +223,6 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
233
223
|
*/
|
|
234
224
|
static deriveState<R, C extends BaseColumnProps<R> = BaseColumnProps<R>>(props: TableBaseProps<R>, state: TableColumnsState<R, C>, flattenColumns: C[]): Partial<TableColumnsState<R, C>> | null;
|
|
235
225
|
/**
|
|
236
|
-
* @param flattenColumns the leaf columns of the props
|
|
237
226
|
* @param queries copies of flattenColumns with initColumnsFilteredValueAndSorterOrder applied; the framework copies
|
|
238
227
|
* them, since a deep clone would break framework values held by a column
|
|
239
228
|
*/
|
|
@@ -241,10 +230,6 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
241
230
|
/** Hosts call it after mount, on body scroll and when the table or its content resizes */
|
|
242
231
|
syncScrollEdges: () => void;
|
|
243
232
|
init(): void;
|
|
244
|
-
/**
|
|
245
|
-
* @param prevProps the props of the previous commit
|
|
246
|
-
* @param prevFlattenColumns the flattenColumns state of the previous commit
|
|
247
|
-
*/
|
|
248
233
|
handleUpdate: (prevProps: TableBaseProps<RecordType>, prevFlattenColumns: TableBaseState<RecordType>["flattenColumns"]) => void;
|
|
249
234
|
initExpandedRowKeys({ groups }?: {
|
|
250
235
|
groups?: Map<string | number, Set<BaseRowKeyType>>;
|
|
@@ -253,7 +238,8 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
253
238
|
/** Scrolls back to the first row; a pagination.onChange that takes over paging still gets the scroll */
|
|
254
239
|
resetScrollY: () => void;
|
|
255
240
|
setPage: (currentPage: number, currentPageSize: number) => void;
|
|
256
|
-
|
|
241
|
+
handleSelectionKeyUp: (e: Pick<KeyboardEvent, "key" | "shiftKey">) => void;
|
|
242
|
+
handleSelectRow: (realKey: BaseRowKeyType, selected: boolean, e?: BaseSelectRowEvent) => void;
|
|
257
243
|
handleSelectAllRow: (selected: boolean, e?: Pick<Event, "stopPropagation">) => void;
|
|
258
244
|
handleRowExpanded: (expanded: boolean, realKey: BaseRowKeyType, domEvent: any) => void;
|
|
259
245
|
toggleShowFilter: (dataIndex: string, visible: boolean) => void;
|
|
@@ -264,12 +250,18 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
|
|
|
264
250
|
dataIndex?: string;
|
|
265
251
|
sortOrder?: BaseSortOrder;
|
|
266
252
|
}) => void;
|
|
267
|
-
|
|
268
|
-
* Select or deselect a row by clicking it when rowSelection.clickRow is set
|
|
269
|
-
*/
|
|
270
|
-
handleRowClickSelection: (rowKey: BaseRowKeyType, selected: boolean, e: Pick<Event, "stopPropagation">) => void;
|
|
253
|
+
handleRowClickSelection: (rowKey: BaseRowKeyType, selected: boolean, e: BaseSelectRowEvent) => void;
|
|
271
254
|
}
|
|
272
255
|
export type BaseRowKeyType = string | number;
|
|
256
|
+
/** A row click passes its mouse event; a checkbox change passes its change event, with the click in nativeEvent */
|
|
257
|
+
export interface BaseSelectRowEvent {
|
|
258
|
+
stopPropagation: () => void;
|
|
259
|
+
shiftKey?: boolean;
|
|
260
|
+
nativeEvent?: {
|
|
261
|
+
shiftKey?: boolean;
|
|
262
|
+
detail?: number;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
273
265
|
export type BaseRowKey<RecordType> = BaseRowKeyType | ((record: RecordType) => BaseRowKeyType);
|
|
274
266
|
export interface BasePagination {
|
|
275
267
|
total?: number;
|
|
@@ -285,7 +277,6 @@ export interface BaseHeadWidth {
|
|
|
285
277
|
}
|
|
286
278
|
export interface BasePageData<RecordType> {
|
|
287
279
|
dataSource?: RecordType[];
|
|
288
|
-
/** Group key (what groupBy returns) -> the row keys in that group */
|
|
289
280
|
groups?: Map<string | number, Set<BaseRowKeyType>>;
|
|
290
281
|
pagination?: BasePagination;
|
|
291
282
|
disabledRowKeys?: BaseRowKeyType[];
|
package/dist/table/foundation.js
CHANGED
|
@@ -4,13 +4,17 @@ import isObject from "../utils/is-object.js";
|
|
|
4
4
|
import { calcCheckedKeysForChecked, calcCheckedKeysForCheckedKeys, calcCheckedKeysForUnchecked, convertDataToEntities } from "../tree/tree-util.js";
|
|
5
5
|
import { numbers, strings } from "./constants.js";
|
|
6
6
|
import { differenceUnique, withOrderSort } from "../utils/array.js";
|
|
7
|
-
import { getChangedRowKeys, mergeColumns } from "./utils.js";
|
|
7
|
+
import { buildRecordsByKey, flattenBodyRows, getChangedRowKeys, mergeColumns } from "./utils.js";
|
|
8
8
|
import { merge, pick } from "es-toolkit";
|
|
9
9
|
import { get } from "es-toolkit/compat";
|
|
10
10
|
// src/table/foundation.ts
|
|
11
11
|
var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
12
12
|
#defaultKeysApplied = false;
|
|
13
13
|
#trackScrollEdges;
|
|
14
|
+
#rangeAnchor = null;
|
|
15
|
+
#rangeBase = null;
|
|
16
|
+
#rangeResult = null;
|
|
17
|
+
#spaceShiftKey = false;
|
|
14
18
|
static #pagerIsControlled(props) {
|
|
15
19
|
return props.pagination?.currentPage != null;
|
|
16
20
|
}
|
|
@@ -18,7 +22,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
18
22
|
const knownMap = new Map(known.map((key) => [String(key), key]));
|
|
19
23
|
return [...keys].map((key) => keyEntities?.[key]?.data?.rowKey ?? knownMap.get(key) ?? key);
|
|
20
24
|
}
|
|
21
|
-
/** The checked and half-checked keys that `rowKeys` imply in a related tree selection, as the rowKey values of the data */
|
|
22
25
|
static #getRelatedCheckedRowKeys(rowKeys = [], keyEntities = {}) {
|
|
23
26
|
const { checkedKeys, halfCheckedKeys } = calcCheckedKeysForCheckedKeys(rowKeys.map(String), keyEntities, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set());
|
|
24
27
|
return {
|
|
@@ -26,6 +29,9 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
26
29
|
halfCheckedRowKeys: TableFoundation.#restoreRowKeys(halfCheckedKeys, rowKeys, keyEntities)
|
|
27
30
|
};
|
|
28
31
|
}
|
|
32
|
+
static #sameKeys(a, b) {
|
|
33
|
+
return a.size === b.size && [...a].every((key) => b.has(key));
|
|
34
|
+
}
|
|
29
35
|
#addNoDuplicatedItemsToArr(srcArr = [], ...objArrs) {
|
|
30
36
|
for (const objArr of objArrs) if (Array.isArray(objArr)) {
|
|
31
37
|
for (const item of objArr) if (!srcArr.includes(item)) srcArr.push(item);
|
|
@@ -65,6 +71,40 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
65
71
|
#getSelectedRowKeysSet() {
|
|
66
72
|
return this.getState("rowSelection")?.selectedRowKeysSet ?? /* @__PURE__ */ new Set();
|
|
67
73
|
}
|
|
74
|
+
#getVisibleRowKeys() {
|
|
75
|
+
const { rowKey, childrenRecordName } = this.getProps();
|
|
76
|
+
const dataSource = this.getState("dataSource");
|
|
77
|
+
const options = {
|
|
78
|
+
rowKey,
|
|
79
|
+
childrenRecordName,
|
|
80
|
+
expandedRowKeys: this.getState("expandedRowKeys"),
|
|
81
|
+
hasExpandedRow: false
|
|
82
|
+
};
|
|
83
|
+
return flattenBodyRows(options, dataSource, this.getState("groups"), buildRecordsByKey(dataSource, rowKey)).flatMap((row) => row.kind === "base" ? [row.key] : []);
|
|
84
|
+
}
|
|
85
|
+
/** Gives every enabled row from the anchor to `rowKey` the anchor's state; false when either row is not shown */
|
|
86
|
+
#selectRange(rowKey) {
|
|
87
|
+
const visibleRowKeys = this.#getVisibleRowKeys();
|
|
88
|
+
const anchorIndex = visibleRowKeys.indexOf(this.#rangeAnchor);
|
|
89
|
+
const index = visibleRowKeys.indexOf(rowKey);
|
|
90
|
+
if (anchorIndex === -1 || index === -1) return false;
|
|
91
|
+
const currentKeys = this.#getSelectedRowKeysSet();
|
|
92
|
+
if (!this.#rangeBase || !this.#rangeResult || !TableFoundation.#sameKeys(this.#rangeResult, currentKeys)) this.#rangeBase = new Set(this.#getSelectedRowKeys());
|
|
93
|
+
const selected = this.#rangeBase.has(this.#rangeAnchor);
|
|
94
|
+
const disabledRowKeys = this.adapter.getFilteredDisabledRowKeysSet();
|
|
95
|
+
const nextKeys = new Set(this.#rangeBase);
|
|
96
|
+
for (const key of visibleRowKeys.slice(Math.min(anchorIndex, index), Math.max(anchorIndex, index) + 1)) if (!disabledRowKeys.has(key)) {
|
|
97
|
+
if (selected) nextKeys.add(key);
|
|
98
|
+
else nextKeys.delete(key);
|
|
99
|
+
}
|
|
100
|
+
window.getSelection()?.removeAllRanges();
|
|
101
|
+
this.#rangeResult = nextKeys;
|
|
102
|
+
if (TableFoundation.#sameKeys(nextKeys, currentKeys)) return true;
|
|
103
|
+
const selectedRowKeys = [...nextKeys];
|
|
104
|
+
if (!this.#selectionIsControlled()) this.adapter.setSelectedRowKeys(selectedRowKeys);
|
|
105
|
+
this.adapter.notifySelectionChange(selectedRowKeys, this.getRecordsByKeys(null, selectedRowKeys));
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
68
108
|
#getDataSource() {
|
|
69
109
|
return this.getProp("dataSource") || [];
|
|
70
110
|
}
|
|
@@ -158,7 +198,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
158
198
|
const pageData = this.getCurrentPageData(sortedDataSource);
|
|
159
199
|
this.#setAdapterPageData(pageData);
|
|
160
200
|
}
|
|
161
|
-
/** Rebuilds the tree of a related selection; the half-checked rows follow from it and the selected keys */
|
|
162
201
|
#updateKeyEntities() {
|
|
163
202
|
const keyEntities = this.buildKeyEntities(this.getProp("dataSource"));
|
|
164
203
|
this.adapter.setKeyEntities(keyEntities);
|
|
@@ -298,9 +337,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
298
337
|
}));
|
|
299
338
|
return TableFoundation.sortDataSource(props, filteredDataSource, queries.filter((query) => query && typeof query.sorter === "function"));
|
|
300
339
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Group, paginate and collect the row keys of filtered and sorted data
|
|
303
|
-
*/
|
|
304
340
|
static getPageData(props, dataSource, pagination, queries) {
|
|
305
341
|
let groups;
|
|
306
342
|
if (props.groupBy != null) {
|
|
@@ -520,7 +556,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
520
556
|
static isSortOrderValid(sortOrder) {
|
|
521
557
|
return typeof sortOrder === "string" && strings.SORT_DIRECTIONS.includes(sortOrder) || sortOrder === false;
|
|
522
558
|
}
|
|
523
|
-
/** The sort and filter state a header cell shows: the column's query by dataIndex, its sort order and filtered values */
|
|
524
559
|
static getColumnQueryState(column, queries) {
|
|
525
560
|
const query = column.dataIndex != null ? queries?.find((item) => item.dataIndex === column.dataIndex) : void 0;
|
|
526
561
|
const stateSortOrder = query?.sortOrder;
|
|
@@ -588,7 +623,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
588
623
|
return Object.keys(changes).length ? changes : null;
|
|
589
624
|
}
|
|
590
625
|
/**
|
|
591
|
-
* @param flattenColumns the leaf columns of the props
|
|
592
626
|
* @param queries copies of flattenColumns with initColumnsFilteredValueAndSorterOrder applied; the framework copies
|
|
593
627
|
* them, since a deep clone would break framework values held by a column
|
|
594
628
|
*/
|
|
@@ -651,10 +685,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
651
685
|
this.#setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
652
686
|
this.#setFilteredDisabledRowKeys(allDataDisabledRowKeys);
|
|
653
687
|
}
|
|
654
|
-
/**
|
|
655
|
-
* @param prevProps the props of the previous commit
|
|
656
|
-
* @param prevFlattenColumns the flattenColumns state of the previous commit
|
|
657
|
-
*/
|
|
658
688
|
handleUpdate = (prevProps, prevFlattenColumns) => {
|
|
659
689
|
const props = this.getProps();
|
|
660
690
|
const flattenColumns = this.getState("flattenColumns");
|
|
@@ -703,10 +733,19 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
703
733
|
}
|
|
704
734
|
this.#notifyChange(pagination, void 0, void 0, { changeType: "pagination" });
|
|
705
735
|
};
|
|
736
|
+
handleSelectionKeyUp = (e) => {
|
|
737
|
+
if (e.key === " ") this.#spaceShiftKey = e.shiftKey;
|
|
738
|
+
};
|
|
706
739
|
handleSelectRow = (realKey, selected, e) => {
|
|
707
740
|
e?.stopPropagation();
|
|
708
741
|
if (typeof selected === "boolean" && realKey != null) {
|
|
709
742
|
const checkRelation = this.adapter.getCheckRelation();
|
|
743
|
+
const native = e?.nativeEvent;
|
|
744
|
+
const shiftKey = e?.shiftKey ?? (native?.shiftKey || native?.detail === 0 && this.#spaceShiftKey);
|
|
745
|
+
this.#spaceShiftKey = false;
|
|
746
|
+
if (shiftKey && checkRelation !== "related" && this.#rangeAnchor != null && this.#selectRange(realKey)) return;
|
|
747
|
+
this.#rangeAnchor = realKey;
|
|
748
|
+
this.#rangeResult = null;
|
|
710
749
|
const selectedRowKeys = this.#getSelectedRowKeys();
|
|
711
750
|
const halfCheckedRowKeys = [...this.adapter.getHalfCheckedRowKeys() || []];
|
|
712
751
|
let foundIdx = -1;
|
|
@@ -854,9 +893,6 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
|
|
|
854
893
|
}
|
|
855
894
|
this.#notifyChange(pagination, filters, curQuery, { changeType: "sorter" });
|
|
856
895
|
};
|
|
857
|
-
/**
|
|
858
|
-
* Select or deselect a row by clicking it when rowSelection.clickRow is set
|
|
859
|
-
*/
|
|
860
896
|
handleRowClickSelection = (rowKey, selected, e) => {
|
|
861
897
|
const rowSelection = this.getState("rowSelection");
|
|
862
898
|
if (rowSelection?.clickRow && !rowSelection.disabled) {
|
package/dist/table/table.scss
CHANGED
package/dist/table/utils.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export interface VirtualizedRowKind {
|
|
|
32
32
|
expandedRow: boolean;
|
|
33
33
|
sectionRow: boolean;
|
|
34
34
|
}
|
|
35
|
-
/** The height of a virtualized row from the itemSize option; the size preset's default stands in when it gives none */
|
|
36
35
|
export declare function resolveVirtualizedItemSize(itemSize: number | ((index: number, row: VirtualizedRowKind) => number) | undefined, size: string | undefined, index: number, row: VirtualizedRowKind): {
|
|
37
36
|
size: number;
|
|
38
37
|
minHeight: number;
|
|
@@ -78,7 +77,6 @@ export declare function getRTLFlexAlign(align: (typeof strings.ALIGNS)[number],
|
|
|
78
77
|
export declare function shouldShowEllipsisTitle(ellipsis: BaseEllipsis): boolean;
|
|
79
78
|
/** Merges new columns over old ones with the same key or dataIndex, so state kept on a column survives */
|
|
80
79
|
export declare function mergeColumns<C extends Record<string, any>>(oldColumns?: C[], newColumns?: C[]): C[];
|
|
81
|
-
/** The number of header rows: the depth of the column tree */
|
|
82
80
|
export declare function getHeaderRowCount(columns: Record<string, any>[]): number;
|
|
83
81
|
/** The next sort order, named as the locale texts of the sort tooltip */
|
|
84
82
|
export declare function getNextSortOrder(sortOrder: string | boolean): "ascend" | "descend" | "cancelSort";
|
|
@@ -87,7 +85,6 @@ export declare function toggleFilteredValue<V>(filteredValue: V[], value: V, fil
|
|
|
87
85
|
export interface TableHeaderCell<Column extends Record<string, any> = Record<string, any>> {
|
|
88
86
|
key: string | number;
|
|
89
87
|
className: string;
|
|
90
|
-
/** The column title, or what a title function returns */
|
|
91
88
|
children: any;
|
|
92
89
|
column: Column;
|
|
93
90
|
colStart: number;
|
|
@@ -101,11 +98,7 @@ export interface TableHeaderCell<Column extends Record<string, any> = Record<str
|
|
|
101
98
|
last?: boolean;
|
|
102
99
|
title?: string;
|
|
103
100
|
}
|
|
104
|
-
/**
|
|
105
|
-
* The header cells by row, with the colSpan and rowSpan that merge the cells of grouped columns
|
|
106
|
-
*/
|
|
107
101
|
export declare function parseHeaderRows<Column extends Record<string, any>>(columns: Column[]): TableHeaderCell<Column>[][];
|
|
108
|
-
/** The keys whose selection state differs between two selections */
|
|
109
102
|
export declare function getChangedRowKeys(before: Array<string | number>, after: Array<string | number>): (string | number)[];
|
|
110
103
|
export interface FlattenDataProps {
|
|
111
104
|
rowKey?: string | number | ((record: any) => string | number);
|
|
@@ -138,7 +131,6 @@ export interface FlattenData {
|
|
|
138
131
|
expanded?: boolean;
|
|
139
132
|
sectionRow?: boolean;
|
|
140
133
|
}
|
|
141
|
-
/** The first record of each row key; an empty or missing key cannot be looked up */
|
|
142
134
|
export declare function buildRecordsByKey(dataSource: Record<string, any>[] | undefined, rowKey: FlattenDataProps['rowKey']): Map<BaseRowKeyType, Record<string, any>>;
|
|
143
135
|
export interface BodyRowsOptions {
|
|
144
136
|
rowKey?: FlattenDataProps['rowKey'];
|
package/dist/table/utils.js
CHANGED
|
@@ -97,7 +97,6 @@ function getDefaultVirtualizedRowConfig(size = "", sectionRow = false) {
|
|
|
97
97
|
}
|
|
98
98
|
return config;
|
|
99
99
|
}
|
|
100
|
-
/** The height of a virtualized row from the itemSize option; the size preset's default stands in when it gives none */
|
|
101
100
|
function resolveVirtualizedItemSize(itemSize, size, index, row) {
|
|
102
101
|
const config = getDefaultVirtualizedRowConfig(size, row.sectionRow);
|
|
103
102
|
return {
|
|
@@ -232,7 +231,6 @@ function mergeColumns(oldColumns = [], newColumns = []) {
|
|
|
232
231
|
return column;
|
|
233
232
|
});
|
|
234
233
|
}
|
|
235
|
-
/** The number of header rows: the depth of the column tree */
|
|
236
234
|
function getHeaderRowCount(columns) {
|
|
237
235
|
return Math.max(0, ...columns.map((column) => column.children?.length ? 1 + getHeaderRowCount(column.children) : 1));
|
|
238
236
|
}
|
|
@@ -254,9 +252,6 @@ function toggleFilteredValue(filteredValue, value, filterMultiple) {
|
|
|
254
252
|
}
|
|
255
253
|
return filterMultiple ? [...values, value] : [value];
|
|
256
254
|
}
|
|
257
|
-
/**
|
|
258
|
-
* The header cells by row, with the colSpan and rowSpan that merge the cells of grouped columns
|
|
259
|
-
*/
|
|
260
255
|
function parseHeaderRows(columns) {
|
|
261
256
|
const rows = [];
|
|
262
257
|
const fillRowCells = (columns, colIndex, parents = [], rowIndex = 0, level = 0) => {
|
|
@@ -273,9 +268,6 @@ function parseHeaderRows(columns) {
|
|
|
273
268
|
parents
|
|
274
269
|
};
|
|
275
270
|
let colSpan = 1;
|
|
276
|
-
/**
|
|
277
|
-
* colSpan: the sum of the children's colSpan, or 1 without children
|
|
278
|
-
*/
|
|
279
271
|
const subColumns = column.children;
|
|
280
272
|
if (subColumns && subColumns.length > 0) {
|
|
281
273
|
colSpan = fillRowCells(subColumns, currentColIndex, [...parents, cell], rowIndex + 1, level + 1).reduce((total, count) => total + count, 0);
|
|
@@ -291,9 +283,6 @@ function parseHeaderRows(columns) {
|
|
|
291
283
|
});
|
|
292
284
|
};
|
|
293
285
|
const columnCount = fillRowCells(columns, 0).reduce((total, count) => total + count, 0);
|
|
294
|
-
/**
|
|
295
|
-
* rowSpan: a cell without children spans the remaining rows; a cell with children needs none
|
|
296
|
-
*/
|
|
297
286
|
const rowCount = rows.length;
|
|
298
287
|
for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) rows[rowIndex].forEach((cell) => {
|
|
299
288
|
if (!cell.hasSubColumns) cell.rowSpan = rowCount - rowIndex;
|
|
@@ -301,7 +290,6 @@ function parseHeaderRows(columns) {
|
|
|
301
290
|
});
|
|
302
291
|
return rows;
|
|
303
292
|
}
|
|
304
|
-
/** The keys whose selection state differs between two selections */
|
|
305
293
|
function getChangedRowKeys(before, after) {
|
|
306
294
|
return xor(before, after);
|
|
307
295
|
}
|
|
@@ -355,7 +343,6 @@ function flattenRecords(props, expandedKeys, dataSource, level) {
|
|
|
355
343
|
return rows;
|
|
356
344
|
});
|
|
357
345
|
}
|
|
358
|
-
/** The first record of each row key; an empty or missing key cannot be looked up */
|
|
359
346
|
function buildRecordsByKey(dataSource, rowKey) {
|
|
360
347
|
const recordsByKey = /* @__PURE__ */ new Map();
|
|
361
348
|
dataSource?.forEach((record) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$spacing-table-paddingY: $spacing-base; // 表格空数据占位及虚拟列表分组垂直内边距
|
|
4
4
|
$spacing-table-paddingX: $spacing-base-tight; // 表格空数据占位及虚拟列表分组水平内边距
|
|
5
5
|
$spacing-table_middle-paddingY: $spacing-base-tight; // 中尺寸表格单元格垂直内边距
|
|
@@ -26,11 +26,9 @@ $spacing-table_expand_icon-marginRight: 8px; // 行展开按钮右侧外边距
|
|
|
26
26
|
$spacing-table_panel_operation-paddingX: $spacing-base; // 表格操作栏水平内边距
|
|
27
27
|
$spacing-table_panel_operation-paddingY: $spacing-tight; // 表格操作栏垂直内边距
|
|
28
28
|
|
|
29
|
-
// Size
|
|
30
29
|
$width-table_base_border: 1px; // 表格单元格分割线宽度
|
|
31
30
|
$width-table_header_border: 1px; // 表格表头分割线宽度
|
|
32
31
|
$width-table_resizer_border: 2px; // 表格拉伸列标示线宽度
|
|
33
|
-
// $radius-table_base: 4px;
|
|
34
32
|
$width-table_column_selection: 48px; // 表格选择列及展开列宽度
|
|
35
33
|
$width-table_column_sorter-icon: 16px; // 表格排序按钮宽度
|
|
36
34
|
$height-table_column_sorter-icon: 16px; // 表格排序按钮高度
|
|
@@ -42,7 +40,6 @@ $width-table_react_resizable_handle: 9px; // 表格伸缩列调节热区宽度
|
|
|
42
40
|
$height-table_pagination_outer_min: 60px; // 表格分页器高度
|
|
43
41
|
$height-table_column_filter_dropdown: 290px; // 表格过滤筛选列表最大高度
|
|
44
42
|
|
|
45
|
-
// Color no need to change
|
|
46
43
|
$color-table_panel-bg-default: var(--semi-color-primary); // 操作区域样式默认背景颜色
|
|
47
44
|
$color-table_panel-text-default: var(--semi-color-primary-light-active); // 表格操作栏选中项文本颜色
|
|
48
45
|
$color-table-bg-default: var(--semi-color-bg-1); // 表格固定列及吸顶表头背景颜色
|
|
@@ -77,7 +74,6 @@ $color-table_placeholder-text-default: var(--semi-color-text-2); // 表格空数
|
|
|
77
74
|
|
|
78
75
|
$color-table_cell-bg-hover: var(--semi-color-bg-0); // 让表格在 hover 时正确显示 $color-table_body-bg-hover 颜色,如无必要不要修改
|
|
79
76
|
|
|
80
|
-
// Other
|
|
81
77
|
$font-table_base-fontSize: 14px; // 表格默认文本字号
|
|
82
78
|
$border-table_base-borderStyle: solid; // 表格描边样式
|
|
83
79
|
$width-table_fixed_shadow: 6px; // 表格固定列滚动阴影宽度
|