@fibrae/semi-foundation 0.1.1 → 0.3.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.
- package/dist/anchor/foundation.d.ts +1 -4
- package/dist/anchor/foundation.js +21 -22
- package/dist/audio-player/foundation.d.ts +10 -13
- package/dist/audio-player/foundation.js +19 -20
- package/dist/auto-complete/foundation.d.ts +12 -14
- package/dist/auto-complete/foundation.js +51 -52
- package/dist/avatar/foundation.d.ts +5 -6
- package/dist/avatar/foundation.js +16 -16
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +2 -5
- package/dist/backtop/foundation.js +7 -8
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -9
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -4
- package/dist/base/foundation.js +12 -11
- package/dist/base/list-store.d.ts +0 -1
- package/dist/breadcrumb/foundation.d.ts +5 -5
- package/dist/breadcrumb/foundation.js +9 -10
- package/dist/breadcrumb/item-foundation.d.ts +3 -3
- package/dist/breadcrumb/item-foundation.js +6 -6
- package/dist/calendar/event-util.d.ts +0 -10
- package/dist/calendar/event-util.js +1 -11
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +5 -9
- package/dist/calendar/month-foundation.d.ts +2 -3
- package/dist/calendar/month-foundation.js +6 -7
- package/dist/carousel/foundation.d.ts +17 -19
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +36 -32
- package/dist/cascader/foundation.js +145 -132
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +3 -7
- package/dist/checkbox/checkbox-foundation.js +15 -17
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -3
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -2
- package/dist/code-highlight/index.js +3 -3
- package/dist/collapse/foundation.d.ts +2 -2
- package/dist/collapse/foundation.js +7 -7
- package/dist/collapsible/foundation.d.ts +3 -3
- package/dist/collapsible/foundation.js +8 -8
- package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
- package/dist/color-picker/alpha-slider-foundation.js +10 -10
- package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
- package/dist/color-picker/color-choose-area-foundation.js +14 -14
- package/dist/color-picker/color-picker.scss +0 -2
- package/dist/color-picker/color-slider-foundation.d.ts +2 -4
- package/dist/color-picker/color-slider-foundation.js +10 -10
- package/dist/color-picker/data-part-foundation.d.ts +5 -5
- package/dist/color-picker/data-part-foundation.js +11 -11
- package/dist/color-picker/foundation.d.ts +4 -4
- package/dist/color-picker/foundation.js +10 -10
- package/dist/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +15 -16
- package/dist/cropper/foundation.js +26 -24
- 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 +39 -58
- package/dist/date-picker/foundation.js +126 -153
- package/dist/date-picker/input-foundation.d.ts +10 -16
- package/dist/date-picker/input-foundation.js +28 -30
- 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 +17 -26
- package/dist/date-picker/months-grid-foundation.js +65 -75
- package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
- package/dist/date-picker/year-and-month-foundation.js +11 -11
- package/dist/drag-move/foundation.d.ts +2 -3
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -7
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -2
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -10
- package/dist/feedback/foundation.js +33 -33
- 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-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/form.scss +0 -12
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -76
- 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 +1 -3
- package/dist/hot-keys/foundation.d.ts +2 -3
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -6
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -4
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -9
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -10
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -11
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -5
- package/dist/input/text-entry-foundation.js +14 -15
- package/dist/input/textarea-foundation.d.ts +7 -8
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +16 -19
- package/dist/input-number/foundation.js +54 -58
- package/dist/json-viewer/foundation.d.ts +8 -10
- package/dist/json-viewer/foundation.js +23 -24
- package/dist/locale/interface.d.ts +0 -3
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +2 -7
- package/dist/markdown-render/foundation.js +5 -9
- package/dist/modal/modal-content-foundation.d.ts +7 -7
- package/dist/modal/modal-content-foundation.js +20 -20
- package/dist/modal/modal-foundation.d.ts +6 -6
- package/dist/modal/modal-foundation.js +24 -24
- package/dist/navigation/foundation.d.ts +1 -8
- package/dist/navigation/foundation.js +14 -20
- package/dist/navigation/item-foundation.d.ts +1 -1
- package/dist/navigation/item-foundation.js +8 -8
- package/dist/navigation/sub-nav-foundation.d.ts +3 -4
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -8
- package/dist/notification/notification-list-foundation.js +12 -13
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +4 -6
- package/dist/overflow-list/foundation.js +18 -19
- package/dist/pagination/foundation.d.ts +8 -10
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +6 -9
- package/dist/pincode/foundation.js +23 -26
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -9
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- 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 +5 -9
- package/dist/radio/radio-foundation.js +15 -16
- package/dist/radio/radio-group-foundation.d.ts +2 -3
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -15
- package/dist/rating/foundation.js +35 -38
- package/dist/resizable/group/index.d.ts +6 -10
- package/dist/resizable/group/index.js +40 -44
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +3 -7
- package/dist/resizable/single/index.js +10 -13
- package/dist/scroll-list/item-foundation.d.ts +7 -9
- package/dist/scroll-list/item-foundation.js +35 -36
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +42 -57
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -28
- package/dist/select/option-foundation.js +10 -19
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +7 -12
- package/dist/side-sheet/side-sheet-foundation.js +23 -27
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +17 -28
- package/dist/slider/foundation.js +47 -59
- package/dist/slider/variables.scss +1 -5
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -4
- package/dist/spin/foundation.js +6 -7
- package/dist/spin/variables.scss +1 -3
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -3
- package/dist/switch/foundation.js +7 -7
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +24 -33
- package/dist/table/foundation.js +144 -108
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +2 -10
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +5 -14
- package/dist/tabs/foundation.js +17 -21
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +11 -13
- package/dist/tag-input/foundation.js +52 -53
- 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 +13 -23
- package/dist/time-picker/foundation.js +39 -48
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- 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 +9 -12
- package/dist/tooltip/foundation.js +67 -63
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +22 -13
- package/dist/transfer/foundation.js +38 -24
- package/dist/tree/foundation.d.ts +14 -16
- package/dist/tree/foundation.js +61 -62
- package/dist/tree/shared.d.ts +2 -4
- 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 +26 -22
- package/dist/tree-select/foundation.js +91 -86
- package/dist/typography/ellipsis.d.ts +5 -7
- package/dist/typography/ellipsis.js +8 -10
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -23
- package/dist/upload/foundation.js +93 -103
- package/dist/upload/utils.d.ts +3 -8
- package/dist/upload/utils.js +6 -11
- package/dist/user-guide/foundation.d.ts +3 -5
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +2 -6
- package/dist/utils/a11y.js +1 -4
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -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 +1 -2
- package/dist/utils/focus-handle.js +1 -3
- package/dist/utils/focus-scope.d.ts +5 -6
- package/dist/utils/focus-scope.js +10 -11
- package/dist/utils/is-promise.d.ts +1 -1
- package/dist/utils/release-holder.d.ts +2 -2
- package/dist/utils/release-holder.js +4 -4
- 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/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -3
- package/dist/video-player/progress-foundation.js +12 -13
- package/dist/video-player/variables.scss +1 -1
- package/package.json +2 -2
|
@@ -8,44 +8,39 @@ export interface BasicOptionProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
style?: Record<string, any>;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/**
|
|
12
|
+
* `data` is what the host read from an optionList item or an option child, and is all that callbacks and the
|
|
13
|
+
* selections receive; the rest is Select's own state, kept off the user's object.
|
|
14
|
+
*/
|
|
15
|
+
export interface OptionRecord<D = BasicOptionProps, G = {
|
|
15
16
|
label?: unknown;
|
|
16
17
|
}> {
|
|
17
|
-
|
|
18
|
-
_selected?: boolean;
|
|
18
|
+
data: D;
|
|
19
19
|
/** Position among all collected options, which keeps a row's key while filtering moves it */
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
index: number;
|
|
21
|
+
group?: G;
|
|
22
|
+
/** Only an option child has one: its key prefixed with the group's, so options in different groups stay apart */
|
|
23
|
+
childKey?: string;
|
|
24
|
+
show: boolean;
|
|
25
|
+
selected: boolean;
|
|
26
|
+
/** The option the search text would create under allowCreate, until it is selected */
|
|
27
|
+
create?: boolean;
|
|
25
28
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* optionList item passes neither and keeps its own keys.
|
|
30
|
-
*/
|
|
31
|
-
export declare function toOptionRecord<D extends object, G extends {
|
|
32
|
-
label?: unknown;
|
|
33
|
-
}>(data: D, index: number, group?: G, keyInJsx?: string): D & OptionRecordKeys<G>;
|
|
34
|
-
export interface OptionRun<O extends {
|
|
35
|
-
_parentGroup?: unknown;
|
|
29
|
+
export declare function toOptionRecord<D, G>(data: D, index: number, group?: G, childKey?: string): OptionRecord<D, G>;
|
|
30
|
+
export interface OptionRun<R extends {
|
|
31
|
+
group?: unknown;
|
|
36
32
|
}> {
|
|
37
|
-
group:
|
|
33
|
+
group: R['group'];
|
|
38
34
|
first: number;
|
|
39
35
|
rows: {
|
|
40
|
-
option:
|
|
36
|
+
option: R;
|
|
41
37
|
index: number;
|
|
42
38
|
}[];
|
|
43
39
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_parentGroup?: {
|
|
40
|
+
export declare function getOptionRuns<R extends {
|
|
41
|
+
group?: {
|
|
47
42
|
key?: unknown;
|
|
48
43
|
};
|
|
49
|
-
}>(options: readonly
|
|
44
|
+
}>(options: readonly R[]): OptionRun<R>[];
|
|
50
45
|
/** The records of a non-empty `optionList`; undefined when the hosts must read their option children instead */
|
|
51
|
-
export declare function optionListToRecords<D
|
|
46
|
+
export declare function optionListToRecords<D>(optionList?: readonly D[]): OptionRecord<D>[] | undefined;
|
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
// src/select/option-foundation.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
_selected: false,
|
|
11
|
-
_scrollIndex: index,
|
|
12
|
-
...data
|
|
13
|
-
};
|
|
14
|
-
return keyInJsx === void 0 ? record : {
|
|
15
|
-
...record,
|
|
16
|
-
_parentGroup: group,
|
|
17
|
-
_keyInJsx: keyInJsx
|
|
2
|
+
function toOptionRecord(data, index, group, childKey) {
|
|
3
|
+
return {
|
|
4
|
+
data,
|
|
5
|
+
index,
|
|
6
|
+
group,
|
|
7
|
+
childKey,
|
|
8
|
+
show: true,
|
|
9
|
+
selected: false
|
|
18
10
|
};
|
|
19
11
|
}
|
|
20
|
-
/** Splits the visible options into runs of adjacent options of the same group, keeping each option's visible index */
|
|
21
12
|
function getOptionRuns(options) {
|
|
22
13
|
const runs = [];
|
|
23
14
|
options.forEach((option, index) => {
|
|
24
15
|
const last = runs.at(-1);
|
|
25
|
-
if (last && last.group?.key === option.
|
|
16
|
+
if (last && last.group?.key === option.group?.key) last.rows.push({
|
|
26
17
|
option,
|
|
27
18
|
index
|
|
28
19
|
});
|
|
29
20
|
else runs.push({
|
|
30
|
-
group: option.
|
|
21
|
+
group: option.group,
|
|
31
22
|
first: index,
|
|
32
23
|
rows: [{
|
|
33
24
|
option,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$color-select-bg-default: var(--semi-color-fill-0); // 选择器输入框背景色 - 默认态
|
|
4
4
|
$color-select-bg-hover: var(--semi-color-fill-1); // 选择器输入框背景色 - 悬停态
|
|
5
5
|
$color-select-bg-active: var(--semi-color-fill-2); // 选择器输入框背景色 - 按下态
|
|
@@ -35,7 +35,6 @@ $color-select_main-text-default: var(--semi-color-text-0); // 选择器输入框
|
|
|
35
35
|
$color-select-icon-default: var(--semi-color-text-2); // 选择器输入框图标颜色
|
|
36
36
|
$color-select_clearBtn-text-default: var(--semi-color-text-2); // 选择器输入框清空按钮颜色 - 默认态
|
|
37
37
|
$color-select_clearBtn-text-hover: var(--semi-color-primary); // 选择器输入框清空按钮颜色 - 悬停态
|
|
38
|
-
// $color-select_input-bg-default: transparent; // 选择器输入框清空按钮颜色 - 悬停态
|
|
39
38
|
$color-select_input_disabled-bg: var(--semi-color-disabled-fill); // 禁用选择器输入框背景色
|
|
40
39
|
$color-select_input_disabled-border-focus: transparent; // 禁用选择器输入框描边颜色 - 聚焦态
|
|
41
40
|
$color-select_input_disabled-text: var(--semi-color-disabled-text); // 禁用选择器输入框回填内容文字颜色
|
|
@@ -50,7 +49,6 @@ $color-select_option-icon-default: transparent; // 选择器下拉菜单选项
|
|
|
50
49
|
$color-select_option-bg-hover: var(--semi-color-fill-0); // 选择器下拉菜单选项背景颜色 - 悬停态
|
|
51
50
|
$color-select_option-bg-active: var(--semi-color-fill-1); // 选择器下拉菜单选项背景颜色 - 按下态
|
|
52
51
|
$color-select_option_disabled-text: var(--semi-color-disabled-text); // 禁用选择器下拉菜单选项文字颜色
|
|
53
|
-
// $color-select_option_disabled-bg: transparent; // 禁用选择器下拉菜单选项背景颜色
|
|
54
52
|
$color-select_option-icon-active: var(--semi-color-text-2); // 选择器下拉菜单选项图标颜色 - 选中态
|
|
55
53
|
$color-select_option-border-default: var(--semi-color-border); // 选择器下拉菜单分组标题分割线颜色
|
|
56
54
|
$color-select-option-bg-selected: transparent; // 选择器下拉菜单选项背景颜色 - 选中态
|
|
@@ -59,7 +57,6 @@ $color-select_group-text: var(--semi-color-text-2); // 选择器下拉菜单分
|
|
|
59
57
|
|
|
60
58
|
$color-select_prefix_suffix_text-default: var(--semi-color-text-2); // 选择器输入框前后缀文本颜色
|
|
61
59
|
|
|
62
|
-
// Width/Height
|
|
63
60
|
$height-select_large: $height-control-large; // 选择器输入框高度 - 大尺寸
|
|
64
61
|
$height-select_small: $height-control-small; // 选择器输入框高度 - 小尺寸
|
|
65
62
|
$height-select_default: $height-control-default; // 选择器输入框高度 - 默认尺寸
|
|
@@ -77,7 +74,6 @@ $height-select_multiple_input_large: 24px; // 大尺寸多项选择器输入框I
|
|
|
77
74
|
$width-select-border-hover: $width-select-border; // 选择器输入框描边宽度 - 悬浮
|
|
78
75
|
$width-select-border-focus: $width-select-border-hover; // 选择器输入框描边宽度 - 按下
|
|
79
76
|
$width-select-border-active: $width-select-border-focus; // 选择器输入框描边宽度 - 选中
|
|
80
|
-
// Spacing
|
|
81
77
|
$spacing-select_option_tick-marginRight: $spacing-tight; // 选择器下拉菜单选中对勾右侧外边距
|
|
82
78
|
$spacing-select_prefix_suffix_text-marginX: $spacing-base-tight; // 选择器输入框前后缀文本水平内边距
|
|
83
79
|
$spacing-select_prefix_suffix_text-marginY: 0px; // 选择器输入框前后缀文本垂直内边距
|
|
@@ -115,14 +111,11 @@ $spacing-select_dropdown_input_paddingBottom: 8px; // 下拉搜索框底部内
|
|
|
115
111
|
$spacing-select_dropdown_input_paddingRight: 12px; // 下拉搜索框右侧内边距
|
|
116
112
|
$spacing-select_dropdown_input_paddingLeft: 12px; // 下拉搜索框左侧内边距
|
|
117
113
|
|
|
118
|
-
// Radius
|
|
119
114
|
$radius-select: var(--semi-border-radius-small); // 选择器输入框圆角
|
|
120
115
|
$radius-select_option: 0px; // 选择器待选项圆角
|
|
121
116
|
|
|
122
|
-
// Font
|
|
123
117
|
$font-select-fontWeight: $font-weight-regular; // 选择器文本字重
|
|
124
118
|
$font-select_keyword-fontWeight: 600; // 选择器搜索结果命关键词中文本字重
|
|
125
119
|
$font-select_prefix_suffix-fontWeight: $font-weight-bold; // 选择器输入框前后缀文本字重
|
|
126
120
|
|
|
127
|
-
// Other
|
|
128
121
|
$opacity-select_selection_text_inactive: 0.4;
|
|
@@ -46,24 +46,19 @@ export interface SideSheetAdapter<P extends SideSheetProps = SideSheetProps, S e
|
|
|
46
46
|
/** Traps focus in the sheet; a no-op without mask, which is not modal */
|
|
47
47
|
trapFocus: () => void;
|
|
48
48
|
releaseFocus: () => void;
|
|
49
|
-
/** Focuses the element focused before the sheet opened */
|
|
50
49
|
restoreFocus: () => void;
|
|
51
50
|
toggleDisplayNone: (displayNone: boolean) => void;
|
|
52
51
|
}
|
|
53
52
|
export default class SideSheetFoundation<P extends SideSheetProps = SideSheetProps, S extends SideSheetState = SideSheetState> extends BaseFoundation<SideSheetAdapter<P, S>, P, S> {
|
|
54
53
|
#private;
|
|
55
|
-
/**
|
|
56
|
-
* A top or bottom sheet spans the width unless `canVerticalSetWidth`, and takes `height` (448 by default); a left or
|
|
57
|
-
* right sheet spans the height. Without a mask the width goes on the outer element and the dialog fills it: a
|
|
58
|
-
* percentage repeated on the dialog would compound.
|
|
59
|
-
*/
|
|
54
|
+
/** Without a mask the width goes on the outer element and the dialog fills it: a percentage repeated on the dialog would compound. */
|
|
60
55
|
static getSheetSize({ placement, canVerticalSetWidth, width, height, mask }: Pick<SideSheetProps, 'placement' | 'width' | 'height' | 'mask'> & {
|
|
61
56
|
canVerticalSetWidth?: boolean;
|
|
62
57
|
}): SheetSize;
|
|
63
|
-
handleCancel(e:
|
|
64
|
-
beforeShow()
|
|
65
|
-
afterHide()
|
|
66
|
-
restoreFocus()
|
|
67
|
-
onVisibleChange(visible: boolean)
|
|
68
|
-
toggleDisplayNone(displayNone: boolean)
|
|
58
|
+
handleCancel: (e: unknown) => void;
|
|
59
|
+
beforeShow: () => void;
|
|
60
|
+
afterHide: () => void;
|
|
61
|
+
restoreFocus: () => void;
|
|
62
|
+
onVisibleChange: (visible: boolean) => void;
|
|
63
|
+
toggleDisplayNone: (displayNone: boolean) => void;
|
|
69
64
|
}
|
|
@@ -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;
|
|
@@ -26,29 +22,29 @@ var SideSheetFoundation = class extends BaseFoundation {
|
|
|
26
22
|
dialogHeight
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
|
-
handleCancel(e) {
|
|
25
|
+
handleCancel = (e) => {
|
|
30
26
|
if (!this.getProp("visible")) return;
|
|
31
|
-
this.
|
|
32
|
-
}
|
|
33
|
-
beforeShow() {
|
|
34
|
-
if (this.getProp("disableScroll")) this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
}
|
|
38
|
-
afterHide() {
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
27
|
+
this.adapter.notifyCancel(e);
|
|
28
|
+
};
|
|
29
|
+
beforeShow = () => {
|
|
30
|
+
if (this.getProp("disableScroll")) this.adapter.disabledBodyScroll();
|
|
31
|
+
this.adapter.openLayer(this.#handleEscape);
|
|
32
|
+
this.adapter.trapFocus();
|
|
33
|
+
};
|
|
34
|
+
afterHide = () => {
|
|
35
|
+
this.adapter.enabledBodyScroll();
|
|
36
|
+
this.adapter.closeLayer();
|
|
37
|
+
this.adapter.releaseFocus();
|
|
42
38
|
this.restoreFocus();
|
|
43
|
-
}
|
|
44
|
-
restoreFocus() {
|
|
45
|
-
this.
|
|
46
|
-
}
|
|
47
|
-
onVisibleChange(visible) {
|
|
48
|
-
this.
|
|
49
|
-
}
|
|
50
|
-
toggleDisplayNone(displayNone) {
|
|
51
|
-
this.
|
|
52
|
-
}
|
|
39
|
+
};
|
|
40
|
+
restoreFocus = () => {
|
|
41
|
+
this.adapter.restoreFocus();
|
|
42
|
+
};
|
|
43
|
+
onVisibleChange = (visible) => {
|
|
44
|
+
this.adapter.notifyVisibleChange(visible);
|
|
45
|
+
};
|
|
46
|
+
toggleDisplayNone = (displayNone) => {
|
|
47
|
+
this.adapter.toggleDisplayNone(displayNone);
|
|
48
|
+
};
|
|
53
49
|
};
|
|
54
50
|
export { SideSheetFoundation as default };
|
|
@@ -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,40 +120,37 @@ 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
|
-
handleValueChange(nextValue: SliderProps['value']): void;
|
|
123
|
+
handleValueChange: (nextValue: SliderProps["value"]) => void;
|
|
135
124
|
/** A value prop back to undefined (a Form reset) returns to the default position */
|
|
136
|
-
resetValue()
|
|
137
|
-
onHandleDown(e: Pick<PointerEvent,
|
|
125
|
+
resetValue: () => void;
|
|
126
|
+
onHandleDown: (e: Pick<PointerEvent, "pointerId" | "pointerType" | "button" | "clientX" | "clientY"> & {
|
|
138
127
|
currentTarget: HTMLElement;
|
|
139
|
-
}, pos:
|
|
140
|
-
onHandleEnter(pos: SliderState[
|
|
141
|
-
onHandleLeave()
|
|
128
|
+
}, pos: "min" | "max") => boolean;
|
|
129
|
+
onHandleEnter: (pos: SliderState["activeHandle"]) => void;
|
|
130
|
+
onHandleLeave: () => void;
|
|
142
131
|
/**
|
|
143
132
|
* Both native inputs span min to max, so a range handle is stopped at the other one here
|
|
144
133
|
*/
|
|
145
|
-
handleInputChange(value: number, pos:
|
|
134
|
+
handleInputChange: (value: number, pos: "min" | "max") => void;
|
|
146
135
|
/**
|
|
147
136
|
* A value key stays with the slider unless the consumer's handler already prevented it. Page, Home and End keep
|
|
148
137
|
* the native range's change; arrows step here, since engines map them differently over a vertical or RTL range
|
|
149
138
|
* (Chrome follows the visual direction, Firefox not when vertical, Safari in neither case). The arrow pointing
|
|
150
139
|
* towards max increases; the cross-axis arrow follows Up and Right.
|
|
151
140
|
*/
|
|
152
|
-
handleKeyDown(event: Pick<KeyboardEvent,
|
|
141
|
+
handleKeyDown: (event: Pick<KeyboardEvent, "key" | "defaultPrevented" | "stopPropagation" | "preventDefault" | KeyModifiers>, pos: "min" | "max") => void;
|
|
153
142
|
/**
|
|
154
143
|
* Releasing a value key ends the change, like releasing the mouse
|
|
155
144
|
*/
|
|
156
|
-
handleKeyUp(event: Pick<KeyboardEvent,
|
|
157
|
-
onFocus(e: {
|
|
145
|
+
handleKeyUp: (event: Pick<KeyboardEvent, "key" | KeyModifiers | "stopPropagation" | "preventDefault">) => void;
|
|
146
|
+
onFocus: (e: {
|
|
158
147
|
target: Element;
|
|
159
|
-
}, pos:
|
|
160
|
-
onBlur(pos:
|
|
161
|
-
handleWrapClick: (e:
|
|
148
|
+
}, pos: "min" | "max") => void;
|
|
149
|
+
onBlur: (pos: "min" | "max") => void;
|
|
150
|
+
handleWrapClick: (e: Pick<MouseEvent, "clientX" | "clientY">) => void;
|
|
162
151
|
/** A mark label is a wide target: it selects the mark's own value, not the value under the pointer */
|
|
163
|
-
handleMarkClick(markValue: number)
|
|
164
|
-
handleWrapperEnter()
|
|
165
|
-
handleWrapperLeave()
|
|
152
|
+
handleMarkClick: (markValue: number) => void;
|
|
153
|
+
handleWrapperEnter: () => void;
|
|
154
|
+
handleWrapperLeave: () => void;
|
|
166
155
|
}
|
|
167
156
|
export {};
|
|
@@ -55,10 +55,10 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
55
55
|
return typeof e.pointerId === "number" && e.pointerId !== this.#pointerId;
|
|
56
56
|
}
|
|
57
57
|
#getParentRect() {
|
|
58
|
-
return this.
|
|
58
|
+
return this.adapter.getSliderNode()?.offsetParent?.getBoundingClientRect();
|
|
59
59
|
}
|
|
60
60
|
#getSliderLengths() {
|
|
61
|
-
const slider = this.
|
|
61
|
+
const slider = this.adapter.getSliderNode();
|
|
62
62
|
if (!slider) return {
|
|
63
63
|
sliderX: 0,
|
|
64
64
|
sliderY: 0,
|
|
@@ -75,19 +75,18 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
#notifyAfterChange() {
|
|
78
|
-
this.
|
|
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;
|
|
84
83
|
if (isEqual(this.normalizeValue(this.getState("currentValue")), nextValue)) return;
|
|
85
|
-
if (this.
|
|
84
|
+
if (this.isControlledComponent()) return;
|
|
86
85
|
this.setState({ currentValue: nextValue }, callback);
|
|
87
86
|
}
|
|
88
87
|
#commitClick(nextValue) {
|
|
89
|
-
this.
|
|
90
|
-
if (this.
|
|
88
|
+
this.adapter.notifyChange(nextValue);
|
|
89
|
+
if (this.isControlledComponent()) return;
|
|
91
90
|
this.#moveHandle(nextValue, () => this.#notifyAfterChange());
|
|
92
91
|
}
|
|
93
92
|
#onHandleMove = (e) => {
|
|
@@ -102,14 +101,14 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
102
101
|
if (this.getState("isDrag")) {
|
|
103
102
|
const nextValue = this.calculateOutputValue(pagePos, chooseMovePos === "min");
|
|
104
103
|
if (nextValue === void 0) return false;
|
|
105
|
-
this.
|
|
104
|
+
this.adapter.notifyChange(nextValue);
|
|
106
105
|
this.#moveHandle(nextValue);
|
|
107
106
|
}
|
|
108
107
|
return true;
|
|
109
108
|
};
|
|
110
109
|
#onHandleUp = (e) => {
|
|
111
110
|
if (this.#isOtherPointer(e)) return false;
|
|
112
|
-
this.
|
|
111
|
+
this.adapter.notifyMouseUp(e);
|
|
113
112
|
handlePrevent(e);
|
|
114
113
|
this.#unbindDragEvents();
|
|
115
114
|
const wasDragging = this.getState("isDrag");
|
|
@@ -134,12 +133,9 @@ 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
|
-
const { vertical, verticalReverse } = this.
|
|
142
|
-
const isRTL = this.
|
|
137
|
+
const { vertical, verticalReverse } = this.adapter.getProps();
|
|
138
|
+
const isRTL = this.adapter.getContext("direction") === "rtl" && !vertical;
|
|
143
139
|
const { sliderX, sliderY, sliderWidth, sliderHeight } = this.#getSliderLengths();
|
|
144
140
|
const len = vertical ? sliderHeight : sliderWidth;
|
|
145
141
|
let startPos;
|
|
@@ -160,9 +156,9 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
160
156
|
/** Position to value snapped to step; false when nothing changes or the slider has no layout */
|
|
161
157
|
transPosToValue(mousePos, isMin) {
|
|
162
158
|
const pos = this.checkMeetMinMax(mousePos);
|
|
163
|
-
const { currentValue } = this.
|
|
164
|
-
const { range, vertical, step, verticalReverse, min, max } = this.
|
|
165
|
-
const isRTL = this.
|
|
159
|
+
const { currentValue } = this.adapter.getStates();
|
|
160
|
+
const { range, vertical, step, verticalReverse, min, max } = this.adapter.getProps();
|
|
161
|
+
const isRTL = this.adapter.getContext("direction") === "rtl" && !vertical;
|
|
166
162
|
const { sliderX, sliderY, sliderWidth, sliderHeight } = this.#getSliderLengths();
|
|
167
163
|
const startPos = vertical ? sliderY : sliderX;
|
|
168
164
|
const len = vertical ? sliderHeight : sliderWidth;
|
|
@@ -181,8 +177,8 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
181
177
|
else return false;
|
|
182
178
|
}
|
|
183
179
|
transValueToPos(value) {
|
|
184
|
-
const { vertical, range, verticalReverse, min, max } = this.
|
|
185
|
-
const isRTL = this.
|
|
180
|
+
const { vertical, range, verticalReverse, min, max } = this.adapter.getProps();
|
|
181
|
+
const isRTL = this.adapter.getContext("direction") === "rtl" && !vertical;
|
|
186
182
|
const { sliderX, sliderY, sliderWidth, sliderHeight } = this.#getSliderLengths();
|
|
187
183
|
const startPos = vertical ? sliderY : sliderX;
|
|
188
184
|
const len = vertical ? sliderHeight : sliderWidth;
|
|
@@ -204,7 +200,7 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
204
200
|
return this.normalizeValue(moveValue);
|
|
205
201
|
}
|
|
206
202
|
checkWhichHandle(pagePos) {
|
|
207
|
-
const { currentValue } = this.
|
|
203
|
+
const { currentValue } = this.adapter.getStates();
|
|
208
204
|
const currentPos = this.transValueToPos(currentValue);
|
|
209
205
|
if (!Array.isArray(currentPos)) return true;
|
|
210
206
|
return Math.abs(pagePos - currentPos[0]) <= Math.abs(pagePos - currentPos[1]);
|
|
@@ -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);
|
|
@@ -314,25 +305,22 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
314
305
|
}
|
|
315
306
|
/** An event handler, so the tooltips follow a container that was hidden */
|
|
316
307
|
syncIsInRenderTree = () => {
|
|
317
|
-
const slider = this.
|
|
308
|
+
const slider = this.adapter.getSliderNode();
|
|
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
|
-
handleValueChange(nextValue) {
|
|
312
|
+
handleValueChange = (nextValue) => {
|
|
325
313
|
if (!this.valueFormatIsCorrect(nextValue)) return;
|
|
326
314
|
this.setState({ currentValue: this.#clampToRange(nextValue) });
|
|
327
|
-
}
|
|
315
|
+
};
|
|
328
316
|
/** A value prop back to undefined (a Form reset) returns to the default position */
|
|
329
|
-
resetValue() {
|
|
317
|
+
resetValue = () => {
|
|
330
318
|
const { defaultValue, range, min } = this.getProps();
|
|
331
319
|
const fallback = range ? [min, min] : min;
|
|
332
320
|
this.setState({ currentValue: this.valueFormatIsCorrect(defaultValue) ? defaultValue : fallback });
|
|
333
321
|
this.#checkCurrentValue();
|
|
334
|
-
}
|
|
335
|
-
onHandleDown(e, pos) {
|
|
322
|
+
};
|
|
323
|
+
onHandleDown = (e, pos) => {
|
|
336
324
|
if (isSecondaryPress(e)) return false;
|
|
337
325
|
this.#bindDragEvents(e.pointerId);
|
|
338
326
|
try {
|
|
@@ -348,38 +336,38 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
348
336
|
const pointerPos = vertical ? mousePos.y : mousePos.x;
|
|
349
337
|
this.#dragOffset = pointerPos - this.#getHandleCenterPosition(vertical, e.currentTarget);
|
|
350
338
|
return true;
|
|
351
|
-
}
|
|
352
|
-
onHandleEnter(pos) {
|
|
339
|
+
};
|
|
340
|
+
onHandleEnter = (pos) => {
|
|
353
341
|
const { activeHandle } = this.getStates();
|
|
354
342
|
if (!this.getProp("disabled") && !activeHandle && pos !== activeHandle) this.setState({ activeHandle: pos });
|
|
355
|
-
}
|
|
356
|
-
onHandleLeave() {
|
|
343
|
+
};
|
|
344
|
+
onHandleLeave = () => {
|
|
357
345
|
if (!this.getState("isDrag")) this.setState({ activeHandle: "" });
|
|
358
|
-
}
|
|
346
|
+
};
|
|
359
347
|
/**
|
|
360
348
|
* Both native inputs span min to max, so a range handle is stopped at the other one here
|
|
361
349
|
*/
|
|
362
|
-
handleInputChange(value, pos) {
|
|
350
|
+
handleInputChange = (value, pos) => {
|
|
363
351
|
if (this.getProp("disabled")) return;
|
|
364
352
|
const { currentValue } = this.getStates();
|
|
365
353
|
let outputValue = value;
|
|
366
354
|
if (Array.isArray(currentValue)) outputValue = pos === "min" ? [Math.min(value, currentValue[1]), currentValue[1]] : [currentValue[0], Math.max(value, currentValue[0])];
|
|
367
355
|
if (!isEqual(currentValue, outputValue)) {
|
|
368
|
-
if (!this.
|
|
369
|
-
this.
|
|
356
|
+
if (!this.isControlledComponent()) this.setState({ currentValue: outputValue });
|
|
357
|
+
this.adapter.notifyChange(outputValue);
|
|
370
358
|
}
|
|
371
|
-
}
|
|
359
|
+
};
|
|
372
360
|
/**
|
|
373
361
|
* A value key stays with the slider unless the consumer's handler already prevented it. Page, Home and End keep
|
|
374
362
|
* the native range's change; arrows step here, since engines map them differently over a vertical or RTL range
|
|
375
363
|
* (Chrome follows the visual direction, Firefox not when vertical, Safari in neither case). The arrow pointing
|
|
376
364
|
* towards max increases; the cross-axis arrow follows Up and Right.
|
|
377
365
|
*/
|
|
378
|
-
handleKeyDown(event, pos) {
|
|
366
|
+
handleKeyDown = (event, pos) => {
|
|
379
367
|
if (event.defaultPrevented || !VALUE_KEYS.includes(event.key) || hasModifier(event)) return;
|
|
380
368
|
event.stopPropagation();
|
|
381
369
|
const { vertical, verticalReverse, step, min, max } = this.getProps();
|
|
382
|
-
const increase = [vertical ? verticalReverse ? "ArrowUp" : "ArrowDown" : this.
|
|
370
|
+
const increase = [vertical ? verticalReverse ? "ArrowUp" : "ArrowDown" : this.adapter.getContext("direction") === "rtl" ? "ArrowLeft" : "ArrowRight", vertical ? "ArrowRight" : "ArrowUp"];
|
|
383
371
|
const opposite = {
|
|
384
372
|
ArrowUp: "ArrowDown",
|
|
385
373
|
ArrowDown: "ArrowUp",
|
|
@@ -393,20 +381,20 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
393
381
|
const value = Array.isArray(currentValue) ? currentValue[pos === "min" ? 0 : 1] : currentValue;
|
|
394
382
|
const next = this.normalizeValue(value + delta * (step > 0 ? step : 1));
|
|
395
383
|
if (next >= min && next <= max) this.handleInputChange(next, pos);
|
|
396
|
-
}
|
|
384
|
+
};
|
|
397
385
|
/**
|
|
398
386
|
* Releasing a value key ends the change, like releasing the mouse
|
|
399
387
|
*/
|
|
400
|
-
handleKeyUp(event) {
|
|
388
|
+
handleKeyUp = (event) => {
|
|
401
389
|
if (VALUE_KEYS.includes(event.key) && !hasModifier(event)) this.#onHandleUp(event);
|
|
402
|
-
}
|
|
403
|
-
onFocus(e, pos) {
|
|
390
|
+
};
|
|
391
|
+
onFocus = (e, pos) => {
|
|
404
392
|
if (this.#noTooltip()) return;
|
|
405
393
|
if (e.target.matches(":focus-visible")) this.setState({ focusVisibleHandle: pos });
|
|
406
|
-
}
|
|
407
|
-
onBlur(pos) {
|
|
394
|
+
};
|
|
395
|
+
onBlur = (pos) => {
|
|
408
396
|
if (!this.#noTooltip() && this.getState("focusVisibleHandle") === pos) this.setState({ focusVisibleHandle: "" });
|
|
409
|
-
}
|
|
397
|
+
};
|
|
410
398
|
handleWrapClick = (e) => {
|
|
411
399
|
if (this.getState("isDrag") || this.getProp("disabled")) return;
|
|
412
400
|
const { vertical } = this.getProps();
|
|
@@ -418,7 +406,7 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
418
406
|
this.#commitClick(nextValue);
|
|
419
407
|
};
|
|
420
408
|
/** A mark label is a wide target: it selects the mark's own value, not the value under the pointer */
|
|
421
|
-
handleMarkClick(markValue) {
|
|
409
|
+
handleMarkClick = (markValue) => {
|
|
422
410
|
if (this.getState("isDrag") || this.getProp("disabled")) return;
|
|
423
411
|
const { range } = this.getProps();
|
|
424
412
|
const currentValue = this.getState("currentValue");
|
|
@@ -430,12 +418,12 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
430
418
|
}
|
|
431
419
|
if (isEqual(this.normalizeValue(currentValue), nextValue)) return;
|
|
432
420
|
this.#commitClick(nextValue);
|
|
433
|
-
}
|
|
434
|
-
handleWrapperEnter() {
|
|
421
|
+
};
|
|
422
|
+
handleWrapperEnter = () => {
|
|
435
423
|
this.setState({ showBoundary: true });
|
|
436
|
-
}
|
|
437
|
-
handleWrapperLeave() {
|
|
424
|
+
};
|
|
425
|
+
handleWrapperLeave = () => {
|
|
438
426
|
this.setState({ showBoundary: false });
|
|
439
|
-
}
|
|
427
|
+
};
|
|
440
428
|
};
|
|
441
429
|
export { SliderFoundation as default };
|