@fibrae/semi-foundation 0.1.0 → 0.2.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 -1
- package/dist/anchor/foundation.js +21 -21
- package/dist/audio-player/foundation.d.ts +10 -10
- package/dist/audio-player/foundation.js +19 -19
- package/dist/auto-complete/foundation.d.ts +12 -12
- package/dist/auto-complete/foundation.js +51 -51
- package/dist/avatar/foundation.d.ts +5 -5
- package/dist/avatar/foundation.js +16 -16
- package/dist/backtop/foundation.d.ts +2 -2
- package/dist/backtop/foundation.js +7 -7
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -8
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -3
- package/dist/base/foundation.js +12 -11
- 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.js +1 -1
- package/dist/calendar/foundation.js +4 -4
- package/dist/calendar/month-foundation.d.ts +2 -2
- package/dist/calendar/month-foundation.js +6 -6
- package/dist/carousel/foundation.d.ts +17 -17
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +34 -26
- package/dist/cascader/foundation.js +143 -121
- package/dist/checkbox/checkbox-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-foundation.js +15 -15
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -1
- 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-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/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/cropper/foundation.d.ts +15 -15
- package/dist/cropper/foundation.js +26 -23
- package/dist/date-picker/_utils/picker-type.d.ts +1 -1
- package/dist/date-picker/foundation.d.ts +36 -36
- package/dist/date-picker/foundation.js +125 -129
- package/dist/date-picker/input-foundation.d.ts +9 -9
- package/dist/date-picker/input-foundation.js +28 -28
- package/dist/date-picker/months-grid-foundation.d.ts +17 -17
- package/dist/date-picker/months-grid-foundation.js +64 -65
- 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 -2
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -5
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -1
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -9
- package/dist/feedback/foundation.js +33 -33
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -61
- package/dist/highlight/foundation.js +1 -1
- package/dist/hot-keys/foundation.d.ts +2 -2
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -4
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -3
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -8
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -9
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -10
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -3
- package/dist/input/text-entry-foundation.js +14 -14
- package/dist/input/textarea-foundation.d.ts +7 -7
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/foundation.d.ts +16 -14
- package/dist/input-number/foundation.js +54 -53
- package/dist/json-viewer/foundation.d.ts +8 -8
- package/dist/json-viewer/foundation.js +23 -23
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +1 -1
- package/dist/markdown-render/foundation.js +4 -4
- 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 -1
- package/dist/navigation/foundation.js +14 -14
- 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 -3
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -7
- package/dist/notification/notification-list-foundation.js +12 -12
- package/dist/overflow-list/foundation.d.ts +4 -4
- package/dist/overflow-list/foundation.js +18 -18
- package/dist/pagination/foundation.d.ts +8 -8
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +5 -5
- package/dist/pincode/foundation.js +22 -22
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/radio/radio-foundation.d.ts +5 -5
- package/dist/radio/radio-foundation.js +15 -15
- package/dist/radio/radio-group-foundation.d.ts +2 -2
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -10
- package/dist/rating/foundation.js +35 -35
- package/dist/resizable/group/index.d.ts +6 -6
- package/dist/resizable/group/index.js +40 -40
- package/dist/resizable/single/index.d.ts +2 -2
- package/dist/resizable/single/index.js +9 -9
- package/dist/scroll-list/item-foundation.d.ts +7 -7
- package/dist/scroll-list/item-foundation.js +35 -35
- package/dist/select/foundation.d.ts +42 -56
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -27
- package/dist/select/option-foundation.js +10 -18
- package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
- package/dist/side-sheet/side-sheet-foundation.js +22 -22
- package/dist/slider/foundation.d.ts +16 -16
- package/dist/slider/foundation.js +46 -46
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -2
- package/dist/spin/foundation.js +6 -6
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -2
- package/dist/switch/foundation.js +7 -7
- package/dist/table/foundation.d.ts +14 -14
- package/dist/table/foundation.js +93 -93
- package/dist/table/utils.d.ts +2 -2
- package/dist/tabs/foundation.d.ts +5 -5
- package/dist/tabs/foundation.js +17 -17
- package/dist/tag-input/foundation.d.ts +11 -11
- package/dist/tag-input/foundation.js +52 -52
- package/dist/time-picker/foundation.d.ts +13 -13
- package/dist/time-picker/foundation.js +39 -39
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/foundation.d.ts +9 -9
- package/dist/tooltip/foundation.js +67 -61
- package/dist/transfer/foundation.d.ts +22 -9
- package/dist/transfer/foundation.js +38 -23
- package/dist/tree/foundation.d.ts +14 -14
- package/dist/tree/foundation.js +61 -61
- package/dist/tree/shared.d.ts +1 -1
- package/dist/tree-select/foundation.d.ts +26 -20
- package/dist/tree-select/foundation.js +91 -83
- package/dist/typography/ellipsis.d.ts +4 -4
- package/dist/typography/ellipsis.js +8 -8
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -17
- package/dist/upload/foundation.js +92 -92
- package/dist/upload/utils.d.ts +3 -3
- package/dist/upload/utils.js +6 -6
- package/dist/user-guide/foundation.d.ts +3 -3
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +1 -1
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/focus-handle.d.ts +1 -1
- package/dist/utils/focus-handle.js +1 -2
- package/dist/utils/focus-scope.d.ts +5 -5
- package/dist/utils/focus-scope.js +10 -10
- 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/video-player/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -2
- package/dist/video-player/progress-foundation.js +12 -12
- package/package.json +2 -2
|
@@ -8,44 +8,40 @@ export interface BasicOptionProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
style?: Record<string, any>;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/**
|
|
12
|
+
* What Select keeps for an option. `data` is what the host read from an optionList item or an option child, and is
|
|
13
|
+
* all that callbacks and the 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
40
|
/** Splits the visible options into runs of adjacent options of the same group, keeping each option's visible index */
|
|
45
|
-
export declare function getOptionRuns<
|
|
46
|
-
|
|
41
|
+
export declare function getOptionRuns<R extends {
|
|
42
|
+
group?: {
|
|
47
43
|
key?: unknown;
|
|
48
44
|
};
|
|
49
|
-
}>(options: readonly
|
|
45
|
+
}>(options: readonly R[]): OptionRun<R>[];
|
|
50
46
|
/** The records of a non-empty `optionList`; undefined when the hosts must read their option children instead */
|
|
51
|
-
export declare function optionListToRecords<D
|
|
47
|
+
export declare function optionListToRecords<D>(optionList?: readonly D[]): OptionRecord<D>[] | undefined;
|
|
@@ -1,20 +1,12 @@
|
|
|
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
12
|
/** Splits the visible options into runs of adjacent options of the same group, keeping each option's visible index */
|
|
@@ -22,12 +14,12 @@ function getOptionRuns(options) {
|
|
|
22
14
|
const runs = [];
|
|
23
15
|
options.forEach((option, index) => {
|
|
24
16
|
const last = runs.at(-1);
|
|
25
|
-
if (last && last.group?.key === option.
|
|
17
|
+
if (last && last.group?.key === option.group?.key) last.rows.push({
|
|
26
18
|
option,
|
|
27
19
|
index
|
|
28
20
|
});
|
|
29
21
|
else runs.push({
|
|
30
|
-
group: option.
|
|
22
|
+
group: option.group,
|
|
31
23
|
first: index,
|
|
32
24
|
rows: [{
|
|
33
25
|
option,
|
|
@@ -60,10 +60,10 @@ export default class SideSheetFoundation<P extends SideSheetProps = SideSheetPro
|
|
|
60
60
|
static getSheetSize({ placement, canVerticalSetWidth, width, height, mask }: Pick<SideSheetProps, 'placement' | 'width' | 'height' | 'mask'> & {
|
|
61
61
|
canVerticalSetWidth?: boolean;
|
|
62
62
|
}): SheetSize;
|
|
63
|
-
handleCancel(e:
|
|
64
|
-
beforeShow()
|
|
65
|
-
afterHide()
|
|
66
|
-
restoreFocus()
|
|
67
|
-
onVisibleChange(visible: boolean)
|
|
68
|
-
toggleDisplayNone(displayNone: boolean)
|
|
63
|
+
handleCancel: (e: unknown) => void;
|
|
64
|
+
beforeShow: () => void;
|
|
65
|
+
afterHide: () => void;
|
|
66
|
+
restoreFocus: () => void;
|
|
67
|
+
onVisibleChange: (visible: boolean) => void;
|
|
68
|
+
toggleDisplayNone: (displayNone: boolean) => void;
|
|
69
69
|
}
|
|
@@ -26,29 +26,29 @@ var SideSheetFoundation = class extends BaseFoundation {
|
|
|
26
26
|
dialogHeight
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
handleCancel(e) {
|
|
29
|
+
handleCancel = (e) => {
|
|
30
30
|
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.
|
|
31
|
+
this.adapter.notifyCancel(e);
|
|
32
|
+
};
|
|
33
|
+
beforeShow = () => {
|
|
34
|
+
if (this.getProp("disableScroll")) this.adapter.disabledBodyScroll();
|
|
35
|
+
this.adapter.openLayer(this.#handleEscape);
|
|
36
|
+
this.adapter.trapFocus();
|
|
37
|
+
};
|
|
38
|
+
afterHide = () => {
|
|
39
|
+
this.adapter.enabledBodyScroll();
|
|
40
|
+
this.adapter.closeLayer();
|
|
41
|
+
this.adapter.releaseFocus();
|
|
42
42
|
this.restoreFocus();
|
|
43
|
-
}
|
|
44
|
-
restoreFocus() {
|
|
45
|
-
this.
|
|
46
|
-
}
|
|
47
|
-
onVisibleChange(visible) {
|
|
48
|
-
this.
|
|
49
|
-
}
|
|
50
|
-
toggleDisplayNone(displayNone) {
|
|
51
|
-
this.
|
|
52
|
-
}
|
|
43
|
+
};
|
|
44
|
+
restoreFocus = () => {
|
|
45
|
+
this.adapter.restoreFocus();
|
|
46
|
+
};
|
|
47
|
+
onVisibleChange = (visible) => {
|
|
48
|
+
this.adapter.notifyVisibleChange(visible);
|
|
49
|
+
};
|
|
50
|
+
toggleDisplayNone = (displayNone) => {
|
|
51
|
+
this.adapter.toggleDisplayNone(displayNone);
|
|
52
|
+
};
|
|
53
53
|
};
|
|
54
54
|
export { SideSheetFoundation as default };
|
|
@@ -131,37 +131,37 @@ export default class SliderFoundation<P extends SliderProps = SliderProps, S ext
|
|
|
131
131
|
/**
|
|
132
132
|
* Syncs a changed value prop, clamped to min and max
|
|
133
133
|
*/
|
|
134
|
-
handleValueChange(nextValue: SliderProps[
|
|
134
|
+
handleValueChange: (nextValue: SliderProps["value"]) => void;
|
|
135
135
|
/** A value prop back to undefined (a Form reset) returns to the default position */
|
|
136
|
-
resetValue()
|
|
137
|
-
onHandleDown(e: Pick<PointerEvent,
|
|
136
|
+
resetValue: () => void;
|
|
137
|
+
onHandleDown: (e: Pick<PointerEvent, "pointerId" | "pointerType" | "button" | "clientX" | "clientY"> & {
|
|
138
138
|
currentTarget: HTMLElement;
|
|
139
|
-
}, pos:
|
|
140
|
-
onHandleEnter(pos: SliderState[
|
|
141
|
-
onHandleLeave()
|
|
139
|
+
}, pos: "min" | "max") => boolean;
|
|
140
|
+
onHandleEnter: (pos: SliderState["activeHandle"]) => void;
|
|
141
|
+
onHandleLeave: () => void;
|
|
142
142
|
/**
|
|
143
143
|
* Both native inputs span min to max, so a range handle is stopped at the other one here
|
|
144
144
|
*/
|
|
145
|
-
handleInputChange(value: number, pos:
|
|
145
|
+
handleInputChange: (value: number, pos: "min" | "max") => void;
|
|
146
146
|
/**
|
|
147
147
|
* A value key stays with the slider unless the consumer's handler already prevented it. Page, Home and End keep
|
|
148
148
|
* the native range's change; arrows step here, since engines map them differently over a vertical or RTL range
|
|
149
149
|
* (Chrome follows the visual direction, Firefox not when vertical, Safari in neither case). The arrow pointing
|
|
150
150
|
* towards max increases; the cross-axis arrow follows Up and Right.
|
|
151
151
|
*/
|
|
152
|
-
handleKeyDown(event: Pick<KeyboardEvent,
|
|
152
|
+
handleKeyDown: (event: Pick<KeyboardEvent, "key" | "defaultPrevented" | "stopPropagation" | "preventDefault" | KeyModifiers>, pos: "min" | "max") => void;
|
|
153
153
|
/**
|
|
154
154
|
* Releasing a value key ends the change, like releasing the mouse
|
|
155
155
|
*/
|
|
156
|
-
handleKeyUp(event: Pick<KeyboardEvent,
|
|
157
|
-
onFocus(e: {
|
|
156
|
+
handleKeyUp: (event: Pick<KeyboardEvent, "key" | KeyModifiers | "stopPropagation" | "preventDefault">) => void;
|
|
157
|
+
onFocus: (e: {
|
|
158
158
|
target: Element;
|
|
159
|
-
}, pos:
|
|
160
|
-
onBlur(pos:
|
|
161
|
-
handleWrapClick: (e:
|
|
159
|
+
}, pos: "min" | "max") => void;
|
|
160
|
+
onBlur: (pos: "min" | "max") => void;
|
|
161
|
+
handleWrapClick: (e: Pick<MouseEvent, "clientX" | "clientY">) => void;
|
|
162
162
|
/** 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()
|
|
163
|
+
handleMarkClick: (markValue: number) => void;
|
|
164
|
+
handleWrapperEnter: () => void;
|
|
165
|
+
handleWrapperLeave: () => void;
|
|
166
166
|
}
|
|
167
167
|
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,19 @@ 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
80
|
/** A controlled value only moves through the value prop */
|
|
81
81
|
#moveHandle(nextValue, callback) {
|
|
82
82
|
this.syncIsInRenderTree();
|
|
83
83
|
if (!this.getState("isInRenderTree")) return;
|
|
84
84
|
if (isEqual(this.normalizeValue(this.getState("currentValue")), nextValue)) return;
|
|
85
|
-
if (this.
|
|
85
|
+
if (this.isControlledComponent()) return;
|
|
86
86
|
this.setState({ currentValue: nextValue }, callback);
|
|
87
87
|
}
|
|
88
88
|
#commitClick(nextValue) {
|
|
89
|
-
this.
|
|
90
|
-
if (this.
|
|
89
|
+
this.adapter.notifyChange(nextValue);
|
|
90
|
+
if (this.isControlledComponent()) return;
|
|
91
91
|
this.#moveHandle(nextValue, () => this.#notifyAfterChange());
|
|
92
92
|
}
|
|
93
93
|
#onHandleMove = (e) => {
|
|
@@ -102,14 +102,14 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
102
102
|
if (this.getState("isDrag")) {
|
|
103
103
|
const nextValue = this.calculateOutputValue(pagePos, chooseMovePos === "min");
|
|
104
104
|
if (nextValue === void 0) return false;
|
|
105
|
-
this.
|
|
105
|
+
this.adapter.notifyChange(nextValue);
|
|
106
106
|
this.#moveHandle(nextValue);
|
|
107
107
|
}
|
|
108
108
|
return true;
|
|
109
109
|
};
|
|
110
110
|
#onHandleUp = (e) => {
|
|
111
111
|
if (this.#isOtherPointer(e)) return false;
|
|
112
|
-
this.
|
|
112
|
+
this.adapter.notifyMouseUp(e);
|
|
113
113
|
handlePrevent(e);
|
|
114
114
|
this.#unbindDragEvents();
|
|
115
115
|
const wasDragging = this.getState("isDrag");
|
|
@@ -138,8 +138,8 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
138
138
|
* Clamps a pointer position to the slider's start and end
|
|
139
139
|
*/
|
|
140
140
|
checkMeetMinMax(position) {
|
|
141
|
-
const { vertical, verticalReverse } = this.
|
|
142
|
-
const isRTL = this.
|
|
141
|
+
const { vertical, verticalReverse } = this.adapter.getProps();
|
|
142
|
+
const isRTL = this.adapter.getContext("direction") === "rtl" && !vertical;
|
|
143
143
|
const { sliderX, sliderY, sliderWidth, sliderHeight } = this.#getSliderLengths();
|
|
144
144
|
const len = vertical ? sliderHeight : sliderWidth;
|
|
145
145
|
let startPos;
|
|
@@ -160,9 +160,9 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
160
160
|
/** Position to value snapped to step; false when nothing changes or the slider has no layout */
|
|
161
161
|
transPosToValue(mousePos, isMin) {
|
|
162
162
|
const pos = this.checkMeetMinMax(mousePos);
|
|
163
|
-
const { currentValue } = this.
|
|
164
|
-
const { range, vertical, step, verticalReverse, min, max } = this.
|
|
165
|
-
const isRTL = this.
|
|
163
|
+
const { currentValue } = this.adapter.getStates();
|
|
164
|
+
const { range, vertical, step, verticalReverse, min, max } = this.adapter.getProps();
|
|
165
|
+
const isRTL = this.adapter.getContext("direction") === "rtl" && !vertical;
|
|
166
166
|
const { sliderX, sliderY, sliderWidth, sliderHeight } = this.#getSliderLengths();
|
|
167
167
|
const startPos = vertical ? sliderY : sliderX;
|
|
168
168
|
const len = vertical ? sliderHeight : sliderWidth;
|
|
@@ -181,8 +181,8 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
181
181
|
else return false;
|
|
182
182
|
}
|
|
183
183
|
transValueToPos(value) {
|
|
184
|
-
const { vertical, range, verticalReverse, min, max } = this.
|
|
185
|
-
const isRTL = this.
|
|
184
|
+
const { vertical, range, verticalReverse, min, max } = this.adapter.getProps();
|
|
185
|
+
const isRTL = this.adapter.getContext("direction") === "rtl" && !vertical;
|
|
186
186
|
const { sliderX, sliderY, sliderWidth, sliderHeight } = this.#getSliderLengths();
|
|
187
187
|
const startPos = vertical ? sliderY : sliderX;
|
|
188
188
|
const len = vertical ? sliderHeight : sliderWidth;
|
|
@@ -204,7 +204,7 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
204
204
|
return this.normalizeValue(moveValue);
|
|
205
205
|
}
|
|
206
206
|
checkWhichHandle(pagePos) {
|
|
207
|
-
const { currentValue } = this.
|
|
207
|
+
const { currentValue } = this.adapter.getStates();
|
|
208
208
|
const currentPos = this.transValueToPos(currentValue);
|
|
209
209
|
if (!Array.isArray(currentPos)) return true;
|
|
210
210
|
return Math.abs(pagePos - currentPos[0]) <= Math.abs(pagePos - currentPos[1]);
|
|
@@ -314,25 +314,25 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
314
314
|
}
|
|
315
315
|
/** An event handler, so the tooltips follow a container that was hidden */
|
|
316
316
|
syncIsInRenderTree = () => {
|
|
317
|
-
const slider = this.
|
|
317
|
+
const slider = this.adapter.getSliderNode();
|
|
318
318
|
const isInRenderTree = Boolean(slider && (slider.offsetWidth || slider.offsetHeight || slider.getClientRects().length));
|
|
319
319
|
if (isInRenderTree !== this.getState("isInRenderTree")) this.setState({ isInRenderTree });
|
|
320
320
|
};
|
|
321
321
|
/**
|
|
322
322
|
* Syncs a changed value prop, clamped to min and max
|
|
323
323
|
*/
|
|
324
|
-
handleValueChange(nextValue) {
|
|
324
|
+
handleValueChange = (nextValue) => {
|
|
325
325
|
if (!this.valueFormatIsCorrect(nextValue)) return;
|
|
326
326
|
this.setState({ currentValue: this.#clampToRange(nextValue) });
|
|
327
|
-
}
|
|
327
|
+
};
|
|
328
328
|
/** A value prop back to undefined (a Form reset) returns to the default position */
|
|
329
|
-
resetValue() {
|
|
329
|
+
resetValue = () => {
|
|
330
330
|
const { defaultValue, range, min } = this.getProps();
|
|
331
331
|
const fallback = range ? [min, min] : min;
|
|
332
332
|
this.setState({ currentValue: this.valueFormatIsCorrect(defaultValue) ? defaultValue : fallback });
|
|
333
333
|
this.#checkCurrentValue();
|
|
334
|
-
}
|
|
335
|
-
onHandleDown(e, pos) {
|
|
334
|
+
};
|
|
335
|
+
onHandleDown = (e, pos) => {
|
|
336
336
|
if (isSecondaryPress(e)) return false;
|
|
337
337
|
this.#bindDragEvents(e.pointerId);
|
|
338
338
|
try {
|
|
@@ -348,38 +348,38 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
348
348
|
const pointerPos = vertical ? mousePos.y : mousePos.x;
|
|
349
349
|
this.#dragOffset = pointerPos - this.#getHandleCenterPosition(vertical, e.currentTarget);
|
|
350
350
|
return true;
|
|
351
|
-
}
|
|
352
|
-
onHandleEnter(pos) {
|
|
351
|
+
};
|
|
352
|
+
onHandleEnter = (pos) => {
|
|
353
353
|
const { activeHandle } = this.getStates();
|
|
354
354
|
if (!this.getProp("disabled") && !activeHandle && pos !== activeHandle) this.setState({ activeHandle: pos });
|
|
355
|
-
}
|
|
356
|
-
onHandleLeave() {
|
|
355
|
+
};
|
|
356
|
+
onHandleLeave = () => {
|
|
357
357
|
if (!this.getState("isDrag")) this.setState({ activeHandle: "" });
|
|
358
|
-
}
|
|
358
|
+
};
|
|
359
359
|
/**
|
|
360
360
|
* Both native inputs span min to max, so a range handle is stopped at the other one here
|
|
361
361
|
*/
|
|
362
|
-
handleInputChange(value, pos) {
|
|
362
|
+
handleInputChange = (value, pos) => {
|
|
363
363
|
if (this.getProp("disabled")) return;
|
|
364
364
|
const { currentValue } = this.getStates();
|
|
365
365
|
let outputValue = value;
|
|
366
366
|
if (Array.isArray(currentValue)) outputValue = pos === "min" ? [Math.min(value, currentValue[1]), currentValue[1]] : [currentValue[0], Math.max(value, currentValue[0])];
|
|
367
367
|
if (!isEqual(currentValue, outputValue)) {
|
|
368
|
-
if (!this.
|
|
369
|
-
this.
|
|
368
|
+
if (!this.isControlledComponent()) this.setState({ currentValue: outputValue });
|
|
369
|
+
this.adapter.notifyChange(outputValue);
|
|
370
370
|
}
|
|
371
|
-
}
|
|
371
|
+
};
|
|
372
372
|
/**
|
|
373
373
|
* A value key stays with the slider unless the consumer's handler already prevented it. Page, Home and End keep
|
|
374
374
|
* the native range's change; arrows step here, since engines map them differently over a vertical or RTL range
|
|
375
375
|
* (Chrome follows the visual direction, Firefox not when vertical, Safari in neither case). The arrow pointing
|
|
376
376
|
* towards max increases; the cross-axis arrow follows Up and Right.
|
|
377
377
|
*/
|
|
378
|
-
handleKeyDown(event, pos) {
|
|
378
|
+
handleKeyDown = (event, pos) => {
|
|
379
379
|
if (event.defaultPrevented || !VALUE_KEYS.includes(event.key) || hasModifier(event)) return;
|
|
380
380
|
event.stopPropagation();
|
|
381
381
|
const { vertical, verticalReverse, step, min, max } = this.getProps();
|
|
382
|
-
const increase = [vertical ? verticalReverse ? "ArrowUp" : "ArrowDown" : this.
|
|
382
|
+
const increase = [vertical ? verticalReverse ? "ArrowUp" : "ArrowDown" : this.adapter.getContext("direction") === "rtl" ? "ArrowLeft" : "ArrowRight", vertical ? "ArrowRight" : "ArrowUp"];
|
|
383
383
|
const opposite = {
|
|
384
384
|
ArrowUp: "ArrowDown",
|
|
385
385
|
ArrowDown: "ArrowUp",
|
|
@@ -393,20 +393,20 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
393
393
|
const value = Array.isArray(currentValue) ? currentValue[pos === "min" ? 0 : 1] : currentValue;
|
|
394
394
|
const next = this.normalizeValue(value + delta * (step > 0 ? step : 1));
|
|
395
395
|
if (next >= min && next <= max) this.handleInputChange(next, pos);
|
|
396
|
-
}
|
|
396
|
+
};
|
|
397
397
|
/**
|
|
398
398
|
* Releasing a value key ends the change, like releasing the mouse
|
|
399
399
|
*/
|
|
400
|
-
handleKeyUp(event) {
|
|
400
|
+
handleKeyUp = (event) => {
|
|
401
401
|
if (VALUE_KEYS.includes(event.key) && !hasModifier(event)) this.#onHandleUp(event);
|
|
402
|
-
}
|
|
403
|
-
onFocus(e, pos) {
|
|
402
|
+
};
|
|
403
|
+
onFocus = (e, pos) => {
|
|
404
404
|
if (this.#noTooltip()) return;
|
|
405
405
|
if (e.target.matches(":focus-visible")) this.setState({ focusVisibleHandle: pos });
|
|
406
|
-
}
|
|
407
|
-
onBlur(pos) {
|
|
406
|
+
};
|
|
407
|
+
onBlur = (pos) => {
|
|
408
408
|
if (!this.#noTooltip() && this.getState("focusVisibleHandle") === pos) this.setState({ focusVisibleHandle: "" });
|
|
409
|
-
}
|
|
409
|
+
};
|
|
410
410
|
handleWrapClick = (e) => {
|
|
411
411
|
if (this.getState("isDrag") || this.getProp("disabled")) return;
|
|
412
412
|
const { vertical } = this.getProps();
|
|
@@ -418,7 +418,7 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
418
418
|
this.#commitClick(nextValue);
|
|
419
419
|
};
|
|
420
420
|
/** A mark label is a wide target: it selects the mark's own value, not the value under the pointer */
|
|
421
|
-
handleMarkClick(markValue) {
|
|
421
|
+
handleMarkClick = (markValue) => {
|
|
422
422
|
if (this.getState("isDrag") || this.getProp("disabled")) return;
|
|
423
423
|
const { range } = this.getProps();
|
|
424
424
|
const currentValue = this.getState("currentValue");
|
|
@@ -430,12 +430,12 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
|
|
|
430
430
|
}
|
|
431
431
|
if (isEqual(this.normalizeValue(currentValue), nextValue)) return;
|
|
432
432
|
this.#commitClick(nextValue);
|
|
433
|
-
}
|
|
434
|
-
handleWrapperEnter() {
|
|
433
|
+
};
|
|
434
|
+
handleWrapperEnter = () => {
|
|
435
435
|
this.setState({ showBoundary: true });
|
|
436
|
-
}
|
|
437
|
-
handleWrapperLeave() {
|
|
436
|
+
};
|
|
437
|
+
handleWrapperLeave = () => {
|
|
438
438
|
this.setState({ showBoundary: false });
|
|
439
|
-
}
|
|
439
|
+
};
|
|
440
440
|
};
|
|
441
441
|
export { SliderFoundation as default };
|
|
@@ -9,6 +9,6 @@ export declare class SortableAnnouncer {
|
|
|
9
9
|
#private;
|
|
10
10
|
readonly plugin: ReturnType<typeof Accessibility.configure>;
|
|
11
11
|
constructor(locale: SortableLocale, total: number);
|
|
12
|
-
update(locale: SortableLocale, total: number)
|
|
12
|
+
update: (locale: SortableLocale, total: number) => void;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -32,7 +32,7 @@ var SortableAnnouncer = class {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
update(locale, total) {
|
|
35
|
+
update = (locale, total) => {
|
|
36
36
|
if (locale.instructions !== this.#instructions.draggable) {
|
|
37
37
|
this.#instructions.draggable = locale.instructions;
|
|
38
38
|
const description = document.getElementById(`${descriptionPrefix}-${this.#id}`);
|
|
@@ -40,6 +40,6 @@ var SortableAnnouncer = class {
|
|
|
40
40
|
}
|
|
41
41
|
this.#locale = locale;
|
|
42
42
|
this.#total = total;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
};
|
|
45
45
|
export { SortableAnnouncer };
|
|
@@ -9,12 +9,12 @@ export interface SpinBaseProps {
|
|
|
9
9
|
export default class SpinFoundation<P extends SpinBaseProps = SpinBaseProps, S extends object = object> extends BaseFoundation<SpinAdapter<P, S>, P, S> {
|
|
10
10
|
#private;
|
|
11
11
|
/** Shows the spinner after `delay`; stopping hides it at once and drops a pending show */
|
|
12
|
-
handleSpinningChange(spinning: boolean)
|
|
12
|
+
handleSpinningChange: (spinning: boolean) => void;
|
|
13
13
|
/**
|
|
14
14
|
* Called when the content under `root` becomes inert (`blocked`) or interactive again. inert drops focus to <body> on
|
|
15
15
|
* the next frame, which would restart keyboard users from the top of the page; the root holds it meanwhile and hands
|
|
16
16
|
* it back afterwards.
|
|
17
17
|
*/
|
|
18
|
-
handleBlockedChange(root: HTMLElement, blocked: boolean)
|
|
18
|
+
handleBlockedChange: (root: HTMLElement, blocked: boolean) => void;
|
|
19
19
|
destroy(): void;
|
|
20
20
|
}
|
package/dist/spin/foundation.js
CHANGED
|
@@ -9,21 +9,21 @@ var SpinFoundation = class extends BaseFoundation {
|
|
|
9
9
|
this.#timer = null;
|
|
10
10
|
}
|
|
11
11
|
/** Shows the spinner after `delay`; stopping hides it at once and drops a pending show */
|
|
12
|
-
handleSpinningChange(spinning) {
|
|
12
|
+
handleSpinningChange = (spinning) => {
|
|
13
13
|
this.#clearTimer();
|
|
14
14
|
const { delay } = this.getProps();
|
|
15
15
|
if (spinning && delay) this.#timer = setTimeout(() => {
|
|
16
16
|
this.#timer = null;
|
|
17
|
-
this.
|
|
17
|
+
this.adapter.setLoading(true);
|
|
18
18
|
}, delay);
|
|
19
|
-
else this.
|
|
20
|
-
}
|
|
19
|
+
else this.adapter.setLoading(spinning);
|
|
20
|
+
};
|
|
21
21
|
/**
|
|
22
22
|
* Called when the content under `root` becomes inert (`blocked`) or interactive again. inert drops focus to <body> on
|
|
23
23
|
* the next frame, which would restart keyboard users from the top of the page; the root holds it meanwhile and hands
|
|
24
24
|
* it back afterwards.
|
|
25
25
|
*/
|
|
26
|
-
handleBlockedChange(root, blocked) {
|
|
26
|
+
handleBlockedChange = (root, blocked) => {
|
|
27
27
|
if (blocked) {
|
|
28
28
|
const active = FocusTrapHandle.getActiveElement(root);
|
|
29
29
|
if (active instanceof HTMLElement && active !== root && root.contains(active)) {
|
|
@@ -35,7 +35,7 @@ var SpinFoundation = class extends BaseFoundation {
|
|
|
35
35
|
this.#heldFocus = null;
|
|
36
36
|
if (held.isConnected && (FocusTrapHandle.getActiveElement(root) === root || document.activeElement === document.body)) held.focus();
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
};
|
|
39
39
|
destroy() {
|
|
40
40
|
this.#clearTimer();
|
|
41
41
|
}
|
package/dist/steps/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type StepStatus = 'wait' | 'process' | 'finish' | 'error' | 'warning';
|
|
2
2
|
export interface StepState {
|
|
3
3
|
/** Undefined when the step has its own status */
|
|
4
|
-
status
|
|
4
|
+
status?: StepStatus;
|
|
5
5
|
active: boolean;
|
|
6
6
|
done: boolean;
|
|
7
7
|
/** The step before the current one while the flow is in error */
|
|
@@ -18,7 +18,7 @@ export interface SwitchBaseProps extends SwitchCheckedProps {
|
|
|
18
18
|
export default class SwitchFoundation<P extends SwitchBaseProps = SwitchBaseProps, S extends SwitchState = SwitchState, E = unknown> extends BaseFoundation<SwitchAdapter<P, S, E>, P, S> {
|
|
19
19
|
static getInitialState(props: SwitchCheckedProps): SwitchState;
|
|
20
20
|
static deriveChecked(props: SwitchCheckedProps, state: Pick<SwitchState, 'checked'>): boolean;
|
|
21
|
-
setChecked(checked?: boolean)
|
|
22
|
-
handleChange(checked: boolean, e: E)
|
|
21
|
+
setChecked: (checked?: boolean) => void;
|
|
22
|
+
handleChange: (checked: boolean, e: E) => void;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -7,13 +7,13 @@ var SwitchFoundation = class extends BaseFoundation {
|
|
|
7
7
|
static deriveChecked(props, state) {
|
|
8
8
|
return Boolean(props.checked !== void 0 ? props.checked : state.checked);
|
|
9
9
|
}
|
|
10
|
-
setChecked(checked) {
|
|
11
|
-
this.
|
|
12
|
-
}
|
|
13
|
-
handleChange(checked, e) {
|
|
10
|
+
setChecked = (checked) => {
|
|
11
|
+
this.adapter.setChecked(checked);
|
|
12
|
+
};
|
|
13
|
+
handleChange = (checked, e) => {
|
|
14
14
|
if (this.getProp("loading")) return;
|
|
15
|
-
if (!this.
|
|
16
|
-
this.
|
|
17
|
-
}
|
|
15
|
+
if (!this.isControlledComponent("checked")) this.setChecked(checked);
|
|
16
|
+
this.adapter.notifyChange(checked, e);
|
|
17
|
+
};
|
|
18
18
|
};
|
|
19
19
|
export { SwitchFoundation as default };
|