@fibrae/semi-foundation 0.6.0 → 0.7.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/base/index.d.ts +2 -1
- package/dist/base/index.js +2 -1
- package/dist/base/overlay-session.d.ts +16 -0
- package/dist/base/overlay-session.js +36 -0
- package/dist/components/audio-player/foundation.js +1 -1
- package/dist/components/auto-complete/constants.d.ts +3 -1
- package/dist/components/auto-complete/foundation.d.ts +1 -1
- package/dist/components/auto-complete/foundation.js +15 -16
- package/dist/components/badge/constants.d.ts +3 -1
- package/dist/components/button/constants.d.ts +3 -1
- package/dist/components/card/constants.d.ts +3 -1
- package/dist/components/cascader/constants.d.ts +2 -0
- package/dist/components/cascader/foundation.d.ts +2 -4
- package/dist/components/cascader/foundation.js +4 -1
- package/dist/components/color-picker/foundation.d.ts +2 -0
- package/dist/components/color-picker/foundation.js +5 -0
- package/dist/components/cropper/constants.d.ts +2 -0
- package/dist/components/date-picker/_utils/index.d.ts +1 -2
- package/dist/components/date-picker/_utils/index.js +1 -2
- package/dist/components/date-picker/_utils/is-timestamp.js +1 -1
- package/dist/components/date-picker/_utils/parse-value.js +1 -1
- package/dist/components/date-picker/_utils/picker-type.js +1 -1
- package/dist/components/date-picker/constants.d.ts +2 -0
- package/dist/components/date-picker/foundation.d.ts +3 -4
- package/dist/components/date-picker/foundation.js +8 -3
- package/dist/components/date-picker/input-foundation.d.ts +1 -0
- package/dist/components/date-picker/input-foundation.js +1 -1
- package/dist/components/date-picker/month-foundation.d.ts +1 -1
- package/dist/components/date-picker/month-foundation.js +1 -0
- package/dist/components/date-picker/months-grid-foundation.d.ts +1 -1
- package/dist/components/date-picker/months-grid-foundation.js +1 -1
- package/dist/components/descriptions/constants.d.ts +3 -1
- package/dist/components/dropdown/constants.d.ts +2 -0
- package/dist/components/dropdown/menu-foundation.d.ts +1 -1
- package/dist/components/empty/constants.d.ts +3 -1
- package/dist/components/feedback/constants.d.ts +3 -1
- package/dist/components/highlight/constants.d.ts +3 -1
- package/dist/components/image/constants.d.ts +5 -1
- package/dist/components/image/preview-inner-foundation.js +6 -15
- package/dist/components/input/constants.d.ts +5 -1
- package/dist/components/input-number/constants.d.ts +3 -1
- package/dist/components/modal/constants.d.ts +3 -1
- package/dist/components/modal/modal-content-foundation.d.ts +3 -3
- package/dist/components/modal/modal-content-foundation.js +5 -3
- package/dist/components/modal/modal-foundation.d.ts +0 -2
- package/dist/components/modal/modal-foundation.js +6 -16
- package/dist/components/navigation/constants.d.ts +4 -0
- package/dist/components/overflow-list/constants.d.ts +2 -0
- package/dist/components/pagination/foundation.d.ts +1 -1
- package/dist/components/popconfirm/constants.d.ts +3 -1
- package/dist/components/popover/constants.d.ts +2 -0
- package/dist/components/radio/constants.d.ts +3 -1
- package/dist/components/scroll-list/item-foundation.js +1 -0
- package/dist/components/select/constants.d.ts +2 -0
- package/dist/components/select/foundation.d.ts +1 -4
- package/dist/components/select/foundation.js +31 -56
- package/dist/components/select/select.css +3 -3
- package/dist/components/select/select.scss +8 -3
- package/dist/components/side-sheet/constants.d.ts +2 -0
- package/dist/components/side-sheet/side-sheet-foundation.d.ts +6 -4
- package/dist/components/side-sheet/side-sheet-foundation.js +33 -23
- package/dist/components/slider/constants.d.ts +3 -1
- package/dist/components/slider/foundation.d.ts +7 -7
- package/dist/components/slider/foundation.js +9 -6
- package/dist/components/spin/constants.d.ts +3 -1
- package/dist/components/table/constants.d.ts +2 -0
- package/dist/components/tabs/constants.d.ts +2 -0
- package/dist/components/tabs/foundation.js +19 -60
- package/dist/components/time-picker/combobox-options.js +1 -1
- package/dist/components/time-picker/constants.d.ts +2 -0
- package/dist/components/time-picker/foundation.d.ts +3 -1
- package/dist/components/time-picker/foundation.js +7 -1
- package/dist/components/tooltip/constants.d.ts +2 -0
- package/dist/components/tooltip/foundation.d.ts +13 -15
- package/dist/components/tooltip/foundation.js +54 -15
- package/dist/components/tree/constants.d.ts +2 -0
- package/dist/components/tree/foundation.d.ts +17 -3
- package/dist/components/tree/foundation.js +37 -2
- package/dist/components/tree/shared.d.ts +37 -0
- package/dist/components/tree/shared.js +42 -1
- package/dist/components/tree-select/constants.d.ts +2 -0
- package/dist/components/tree-select/foundation.d.ts +15 -10
- package/dist/components/tree-select/foundation.js +44 -7
- package/dist/components/upload/constants.d.ts +4 -2
- package/dist/components/upload/utils.d.ts +5 -0
- package/dist/components/upload/utils.js +8 -2
- package/dist/components/video-player/foundation.js +1 -1
- package/dist/components/video-player/utils.d.ts +0 -2
- package/dist/components/video-player/utils.js +1 -14
- package/dist/locale/interface.d.ts +2 -0
- package/dist/locale/source/en_US.js +1 -0
- package/dist/locale/source/zh_CN.js +1 -0
- package/dist/utils/a11y.d.ts +9 -0
- package/dist/utils/a11y.js +19 -1
- package/dist/utils/date-fns-extra.d.ts +1 -0
- package/dist/utils/date-fns-extra.js +4 -1
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +3 -2
- package/dist/utils/media.d.ts +2 -0
- package/dist/utils/media.js +15 -0
- package/package.json +2 -2
- package/dist/components/date-picker/_utils/is-valid-date.d.ts +0 -1
- package/dist/components/date-picker/_utils/is-valid-date.js +0 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import FocusTrapHandle from "../../base/focus-handle.js";
|
|
2
2
|
import BaseFoundation from "../../base/foundation.js";
|
|
3
3
|
import ModalResources from "../../base/modal-resources.js";
|
|
4
|
+
import OverlaySession from "../../base/overlay-session.js";
|
|
4
5
|
import { handlePrevent } from "../../utils/a11y.js";
|
|
5
6
|
import { coversPage, resolvePopupContainer } from "../../utils/dom.js";
|
|
6
7
|
import "../../utils/key-code.js";
|
|
@@ -21,8 +22,7 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
21
22
|
y: 0
|
|
22
23
|
};
|
|
23
24
|
#resources = new ModalResources();
|
|
24
|
-
#
|
|
25
|
-
#resume = false;
|
|
25
|
+
#session = new OverlaySession();
|
|
26
26
|
static propKeys = ["src", "currentIndex"];
|
|
27
27
|
static propEquals = { src: isEqual };
|
|
28
28
|
#getImgSrc() {
|
|
@@ -52,7 +52,6 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
52
52
|
return true;
|
|
53
53
|
};
|
|
54
54
|
#release() {
|
|
55
|
-
this.#shown = false;
|
|
56
55
|
window.removeEventListener("keydown", this.handleKeyDown);
|
|
57
56
|
this.#resources.release();
|
|
58
57
|
this.#clearTimer();
|
|
@@ -129,8 +128,7 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
129
128
|
}
|
|
130
129
|
/** Hosts call this once the dialog is in the document and displayed, after `recordFocus` */
|
|
131
130
|
beforeShow = () => {
|
|
132
|
-
if (this.#
|
|
133
|
-
this.#shown = true;
|
|
131
|
+
if (!this.#session.begin()) return;
|
|
134
132
|
window.addEventListener("keydown", this.handleKeyDown);
|
|
135
133
|
const wrap = this.adapter.getWrap();
|
|
136
134
|
if (wrap && !wrap.contains(FocusTrapHandle.getActiveElement(wrap))) FocusTrapHandle.findAutofocus(wrap)?.focus({ preventScroll: true });
|
|
@@ -146,8 +144,7 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
146
144
|
this.updateTimer();
|
|
147
145
|
};
|
|
148
146
|
afterHide = () => {
|
|
149
|
-
this.#
|
|
150
|
-
if (!this.#shown) return;
|
|
147
|
+
if (!this.#session.end()) return;
|
|
151
148
|
this.#release();
|
|
152
149
|
this.setState({
|
|
153
150
|
controlsVisible: true,
|
|
@@ -168,17 +165,11 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
168
165
|
if (!isEqual(prev.src, this.getProp("src"))) this.updateTimer();
|
|
169
166
|
}
|
|
170
167
|
init() {
|
|
171
|
-
if (this.#resume)
|
|
172
|
-
this.#resume = false;
|
|
173
|
-
this.beforeShow();
|
|
174
|
-
}
|
|
168
|
+
if (this.#session.resume()) this.beforeShow();
|
|
175
169
|
}
|
|
176
170
|
destroy() {
|
|
177
171
|
this.#mouseMoveHandler.cancel();
|
|
178
|
-
if (this.#
|
|
179
|
-
this.#release();
|
|
180
|
-
this.#resume = true;
|
|
181
|
-
}
|
|
172
|
+
if (this.#session.suspend()) this.#release();
|
|
182
173
|
}
|
|
183
174
|
handleMouseMove = (e) => {
|
|
184
175
|
this.#mouseMoveHandler(e);
|
|
@@ -5,4 +5,8 @@ export declare const strings: {
|
|
|
5
5
|
readonly SIZE: readonly ["small", "large", "default"];
|
|
6
6
|
readonly DEFAULT_SIZE: "default";
|
|
7
7
|
};
|
|
8
|
-
export declare const numbers: {};
|
|
8
|
+
export declare const numbers: {};
|
|
9
|
+
/** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
|
|
10
|
+
export type InputPart = 'input';
|
|
11
|
+
/** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
|
|
12
|
+
export type TextAreaPart = 'textarea' | 'lineNumber';
|
|
@@ -11,4 +11,6 @@ export declare const numbers: {
|
|
|
11
11
|
export declare const strings: {
|
|
12
12
|
SIZE: readonly ["small", "large", "default"];
|
|
13
13
|
DEFAULT_SIZE: "default";
|
|
14
|
-
};
|
|
14
|
+
};
|
|
15
|
+
/** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
|
|
16
|
+
export type InputNumberPart = 'input';
|
|
@@ -26,9 +26,9 @@ export default class ModalContentFoundation<P extends ModalContentProps = ModalC
|
|
|
26
26
|
/** Remembers the element to return focus to; hosts call it on opening, before anything inside the dialog takes focus */
|
|
27
27
|
recordFocus: () => void;
|
|
28
28
|
/** Called when the dialog is shown: joins the overlay stack and moves focus into the dialog (Modal holds the scroll lock) */
|
|
29
|
-
|
|
30
|
-
/** The reverse of `
|
|
31
|
-
|
|
29
|
+
beforeShow: () => void;
|
|
30
|
+
/** The reverse of `beforeShow`; the focus returns to the element recorded on opening */
|
|
31
|
+
afterHide: () => void;
|
|
32
32
|
/** Returns focus again, for a host whose framework refocuses the previously focused element after the close */
|
|
33
33
|
restoreFocus: () => void;
|
|
34
34
|
handleDialogMouseDown: () => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import FocusTrapHandle from "../../base/focus-handle.js";
|
|
2
2
|
import BaseFoundation from "../../base/foundation.js";
|
|
3
3
|
import ModalResources from "../../base/modal-resources.js";
|
|
4
|
+
import { warnIfDialogUnnamed } from "../../utils/a11y.js";
|
|
4
5
|
import { cssClasses } from "./constants.js";
|
|
5
6
|
// src/components/modal/modal-content-foundation.ts
|
|
6
7
|
function isModal({ mask, maskFixed, inBody }) {
|
|
@@ -21,7 +22,7 @@ var ModalContentFoundation = class extends BaseFoundation {
|
|
|
21
22
|
this.#resources.record();
|
|
22
23
|
};
|
|
23
24
|
/** Called when the dialog is shown: joins the overlay stack and moves focus into the dialog (Modal holds the scroll lock) */
|
|
24
|
-
|
|
25
|
+
beforeShow = () => {
|
|
25
26
|
const dialog = this.adapter.getDialog();
|
|
26
27
|
if (!dialog) return;
|
|
27
28
|
const { preventScroll, initialFocus } = this.getProps();
|
|
@@ -43,9 +44,10 @@ var ModalContentFoundation = class extends BaseFoundation {
|
|
|
43
44
|
focus: dialog,
|
|
44
45
|
preventScroll
|
|
45
46
|
});
|
|
47
|
+
warnIfDialogUnnamed(dialog, "Modal");
|
|
46
48
|
};
|
|
47
|
-
/** The reverse of `
|
|
48
|
-
|
|
49
|
+
/** The reverse of `beforeShow`; the focus returns to the element recorded on opening */
|
|
50
|
+
afterHide = () => {
|
|
49
51
|
clearTimeout(this.#mouseUpTimer);
|
|
50
52
|
this.#dialogMouseDown = false;
|
|
51
53
|
this.adapter.getDialog()?.blur();
|
|
@@ -16,7 +16,6 @@ export interface ModalAdapter<P extends ModalProps = ModalProps, CE = unknown, O
|
|
|
16
16
|
}
|
|
17
17
|
export interface ModalProps {
|
|
18
18
|
afterClose?: () => void;
|
|
19
|
-
bodyStyle?: Record<string, any>;
|
|
20
19
|
cancelButtonProps?: any;
|
|
21
20
|
cancelText?: string;
|
|
22
21
|
centered?: boolean;
|
|
@@ -32,7 +31,6 @@ export interface ModalProps {
|
|
|
32
31
|
height?: string | number;
|
|
33
32
|
mask?: boolean;
|
|
34
33
|
maskClosable?: boolean;
|
|
35
|
-
maskStyle?: Record<string, any>;
|
|
36
34
|
maskFixed?: boolean;
|
|
37
35
|
motion?: boolean;
|
|
38
36
|
okButtonProps?: any;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BaseFoundation from "../../base/foundation.js";
|
|
2
2
|
import ModalResources from "../../base/modal-resources.js";
|
|
3
|
+
import OverlaySession from "../../base/overlay-session.js";
|
|
3
4
|
import PopupLifecycle from "../../base/popup-lifecycle.js";
|
|
4
5
|
import { coversPage, resolvePopupContainer } from "../../utils/dom.js";
|
|
5
6
|
import isPromise from "../../utils/is-promise.js";
|
|
@@ -9,8 +10,7 @@ import { debounce } from "es-toolkit";
|
|
|
9
10
|
var ModalFoundation = class extends BaseFoundation {
|
|
10
11
|
#lastCancelTarget = null;
|
|
11
12
|
#lastOkTarget = null;
|
|
12
|
-
#
|
|
13
|
-
#resume = false;
|
|
13
|
+
#session = new OverlaySession();
|
|
14
14
|
#lifecycle = new PopupLifecycle();
|
|
15
15
|
#resources = new ModalResources();
|
|
16
16
|
constructor(adapter) {
|
|
@@ -60,18 +60,12 @@ var ModalFoundation = class extends BaseFoundation {
|
|
|
60
60
|
return hasCancel && cancelButtonProps?.autoFocus !== false ? "cancel" : void 0;
|
|
61
61
|
}
|
|
62
62
|
init() {
|
|
63
|
-
if (this.#resume)
|
|
64
|
-
this.#resume = false;
|
|
65
|
-
this.beforeShow();
|
|
66
|
-
}
|
|
63
|
+
if (this.#session.resume()) this.beforeShow();
|
|
67
64
|
}
|
|
68
65
|
destroy() {
|
|
69
66
|
this.#debouncedOk.cancel();
|
|
70
67
|
this.#debouncedCancel.cancel();
|
|
71
|
-
if (this.#
|
|
72
|
-
this.afterHide();
|
|
73
|
-
this.#resume = true;
|
|
74
|
-
}
|
|
68
|
+
if (this.#session.suspend()) this.#resources.release();
|
|
75
69
|
}
|
|
76
70
|
handleCancel = (e) => {
|
|
77
71
|
if (!this.getProp("visible")) return;
|
|
@@ -87,8 +81,7 @@ var ModalFoundation = class extends BaseFoundation {
|
|
|
87
81
|
this.#debouncedOk(e);
|
|
88
82
|
};
|
|
89
83
|
beforeShow = () => {
|
|
90
|
-
if (this.#
|
|
91
|
-
this.#shown = true;
|
|
84
|
+
if (!this.#session.begin()) return;
|
|
92
85
|
this.#lifecycle.show();
|
|
93
86
|
const { mask, maskFixed, getPopupContainer } = this.getProps();
|
|
94
87
|
const container = resolvePopupContainer(getPopupContainer ?? this.getContext("getPopupContainer"));
|
|
@@ -100,10 +93,7 @@ var ModalFoundation = class extends BaseFoundation {
|
|
|
100
93
|
}) });
|
|
101
94
|
};
|
|
102
95
|
afterHide = () => {
|
|
103
|
-
this.#
|
|
104
|
-
if (!this.#shown) return;
|
|
105
|
-
this.#shown = false;
|
|
106
|
-
this.#resources.release();
|
|
96
|
+
if (this.#session.end()) this.#resources.release();
|
|
107
97
|
};
|
|
108
98
|
/**
|
|
109
99
|
* Hosts call this when the wrap is hidden (the leave animation ended) and when the modal unmounts for good:
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare const cssClasses: {
|
|
2
2
|
PREFIX: string;
|
|
3
3
|
};
|
|
4
|
+
/** Keys of `classNames` and `styles` of Nav; the root element takes `className` and `style` */
|
|
5
|
+
export type NavPart = 'body';
|
|
6
|
+
/** Keys of `classNames` and `styles` of SubNav; the root element takes `className` and `style` */
|
|
7
|
+
export type SubNavPart = 'dropdown';
|
|
4
8
|
export declare const strings: {
|
|
5
9
|
MODE_VERTICAL: string;
|
|
6
10
|
MODE_HORIZONTAL: string;
|
|
@@ -3,6 +3,8 @@ export declare const cssClasses: {
|
|
|
3
3
|
/** The element that holds the items in scroll mode, which scrolls instead of the list root */
|
|
4
4
|
SCROLL_WRAPPER: string;
|
|
5
5
|
};
|
|
6
|
+
/** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
|
|
7
|
+
export type OverflowListPart = 'wrapper';
|
|
6
8
|
/** Attribute on the first element of each scroll-mode item that carries the item's key: the observer and Tabs find items by it */
|
|
7
9
|
export declare const SCROLL_KEY_ATTRIBUTE = "data-scrollkey";
|
|
8
10
|
export declare const strings: {
|
|
@@ -53,7 +53,7 @@ export default class PaginationFoundation<P extends PaginationBaseProps = Pagina
|
|
|
53
53
|
sizeChangerShown: boolean;
|
|
54
54
|
hidden: boolean;
|
|
55
55
|
quickJumpDisabled: boolean;
|
|
56
|
-
switchPosition: "bottomLeft" | "
|
|
56
|
+
switchPosition: "bottomLeft" | "bottom" | "top" | "bottomRight" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
|
|
57
57
|
};
|
|
58
58
|
static getDisabled(currentPage: number, total: number, pageSize: number): {
|
|
59
59
|
prevDisabled: boolean;
|
|
@@ -2,6 +2,8 @@ export declare const cssClasses: {
|
|
|
2
2
|
PREFIX: string;
|
|
3
3
|
ARROW: string;
|
|
4
4
|
};
|
|
5
|
+
/** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
|
|
6
|
+
export type PopoverPart = 'content' | 'arrow';
|
|
5
7
|
export declare const strings: {
|
|
6
8
|
readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver"];
|
|
7
9
|
readonly TRIGGER_SET: readonly ["hover", "focus", "click", "custom", "contextMenu"];
|
|
@@ -13,4 +13,6 @@ export declare const strings: {
|
|
|
13
13
|
readonly TYPE_CARD: "card";
|
|
14
14
|
readonly TYPE_PURECARD: "pureCard";
|
|
15
15
|
readonly BUTTON_SIZE: readonly ["middle", "small", "large"];
|
|
16
|
-
};
|
|
16
|
+
};
|
|
17
|
+
/** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
|
|
18
|
+
export type RadioPart = 'addon';
|
|
@@ -294,6 +294,7 @@ var ItemFoundation = class ItemFoundation extends BaseFoundation {
|
|
|
294
294
|
* APG single-select listbox keyboard, selection follows focus; the column scrolls once `selectedIndex` returns
|
|
295
295
|
*/
|
|
296
296
|
handleKeyDown = (event) => {
|
|
297
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
297
298
|
const { list, selectedIndex, cycled } = this.getProps();
|
|
298
299
|
let target = getListTargetIndex(event.key, selectedIndex, list.length, (index) => Boolean(list[index].disabled), { loop: cycled });
|
|
299
300
|
if (target === null && this.#typeahead.accepts(event)) {
|
|
@@ -3,6 +3,8 @@ export declare const cssClasses: {
|
|
|
3
3
|
PREFIX_OPTION: string;
|
|
4
4
|
PREFIX_GROUP: string;
|
|
5
5
|
};
|
|
6
|
+
/** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
|
|
7
|
+
export type SelectPart = 'dropdown';
|
|
6
8
|
export declare const strings: {
|
|
7
9
|
readonly SIZE_SET: readonly ["small", "large", "default"];
|
|
8
10
|
readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver", "leftBottomOver", "rightBottomOver"];
|
|
@@ -3,8 +3,6 @@ import "../../base/index.js";
|
|
|
3
3
|
import { isComposing } from "../../utils/key-code.js";
|
|
4
4
|
import { BasicOptionProps, OptionRecord } from "./option-foundation.js";
|
|
5
5
|
import { isEqual } from "es-toolkit";
|
|
6
|
-
/** The id of the option at `index`, which `aria-activedescendant` points at and the scroll lookup finds; `listId` is the host's id for the list */
|
|
7
|
-
export declare function getOptionId(listId: string, index: number): string;
|
|
8
6
|
export interface SelectBaseProps {
|
|
9
7
|
allowCreate?: boolean;
|
|
10
8
|
autoClearSearchValue?: boolean;
|
|
@@ -35,7 +33,6 @@ export interface SelectBaseState {
|
|
|
35
33
|
focusIndex: number;
|
|
36
34
|
inputValue: string;
|
|
37
35
|
isFocus: boolean;
|
|
38
|
-
isFocusInContainer: boolean;
|
|
39
36
|
isFullTags: boolean;
|
|
40
37
|
isOpen: boolean;
|
|
41
38
|
options: OptionRecord[];
|
|
@@ -80,7 +77,7 @@ export default class SelectFoundation<P extends SelectBaseProps = SelectBaseProp
|
|
|
80
77
|
};
|
|
81
78
|
protected initOnce(): void;
|
|
82
79
|
/** The rtl default of `position`; `direction` is read from the host's config */
|
|
83
|
-
static getPosition<P extends string>(position?: P, direction?: string): "bottomLeft" | "bottomRight"
|
|
80
|
+
static getPosition<P extends string>(position?: P, direction?: string): "bottomLeft" | P | "bottomRight";
|
|
84
81
|
static getVisibleOptions<O extends Pick<OptionRecord, 'show'>>(options: O[]): O[];
|
|
85
82
|
/** The index the combobox points at with `aria-activedescendant`, or undefined when no option is highlighted */
|
|
86
83
|
static getActiveOptionIndex({ isOpen, loading, focusIndex, visibleCount }: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import FocusTrapHandle from "../../base/focus-handle.js";
|
|
2
2
|
import BaseFoundation from "../../base/foundation.js";
|
|
3
|
-
import { Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, handlePrevent, isInnerControlActivation, isInnerControlKey, isTextEditor } from "../../utils/a11y.js";
|
|
3
|
+
import { Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, getOptionId, handlePrevent, isBrowserChord, isInnerControlActivation, isInnerControlKey, isTextEditor, revealOption } from "../../utils/a11y.js";
|
|
4
4
|
import { centerInScroller } from "../../utils/dom.js";
|
|
5
5
|
import Event from "../../utils/event.js";
|
|
6
6
|
import { ENTER_KEY, isComposing } from "../../utils/key-code.js";
|
|
@@ -9,10 +9,6 @@ import warning from "../../utils/warning.js";
|
|
|
9
9
|
import { cssClasses, strings } from "./constants.js";
|
|
10
10
|
import { isEqual } from "es-toolkit";
|
|
11
11
|
// src/components/select/foundation.ts
|
|
12
|
-
/** The id of the option at `index`, which `aria-activedescendant` points at and the scroll lookup finds; `listId` is the host's id for the list */
|
|
13
|
-
function getOptionId(listId, index) {
|
|
14
|
-
return `${listId}-option-${index}`;
|
|
15
|
-
}
|
|
16
12
|
var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
17
13
|
#blurPending = false;
|
|
18
14
|
#popupFocusTrigger = null;
|
|
@@ -233,8 +229,12 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
233
229
|
this.adapter.scrollVirtualTo(index);
|
|
234
230
|
return;
|
|
235
231
|
}
|
|
236
|
-
const
|
|
237
|
-
|
|
232
|
+
const optionList = this.adapter.getOptionList();
|
|
233
|
+
if (index !== void 0) {
|
|
234
|
+
revealOption(optionList, getOptionId(this.adapter.getListId(), index));
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const destNode = optionList?.querySelector(`.${cssClasses.PREFIX_OPTION}-selected, .${cssClasses.PREFIX_OPTION}-custom-selected`);
|
|
238
238
|
const listbox = destNode?.closest("[role=\"listbox\"]");
|
|
239
239
|
if (destNode && listbox) centerInScroller(destNode, listbox);
|
|
240
240
|
}
|
|
@@ -292,40 +292,26 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
292
292
|
else this.open();
|
|
293
293
|
}
|
|
294
294
|
#handleTabKeyDown(event) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
#getActiveElement() {
|
|
305
|
-
return FocusTrapHandle.getActiveElement(this.adapter.getOptionList());
|
|
306
|
-
}
|
|
307
|
-
#handlePanelOpenTabKeyDown(focusableElements, event) {
|
|
308
|
-
const activeElement = this.#getActiveElement();
|
|
309
|
-
const { isFocusInContainer } = this.getStates();
|
|
310
|
-
if (!isFocusInContainer) {
|
|
311
|
-
focusableElements[0].focus();
|
|
312
|
-
this.setState({ isFocusInContainer: true });
|
|
313
|
-
handlePrevent(event);
|
|
314
|
-
} else if (activeElement === focusableElements.at(-1)) {
|
|
315
|
-
this.#focusTrigger();
|
|
316
|
-
this.close({ event });
|
|
317
|
-
handlePrevent(event);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
#handlePanelOpenShiftTabKeyDown(focusableElements, event) {
|
|
321
|
-
const activeElement = this.#getActiveElement();
|
|
322
|
-
const { isFocusInContainer } = this.getStates();
|
|
323
|
-
if (!isFocusInContainer) this.close({ event });
|
|
324
|
-
else if (activeElement === focusableElements[0]) {
|
|
325
|
-
this.#focusTrigger();
|
|
326
|
-
this.setState({ isFocusInContainer: false });
|
|
327
|
-
handlePrevent(event);
|
|
295
|
+
if (!this.getState("isOpen")) return;
|
|
296
|
+
const optionList = this.adapter.getOptionList();
|
|
297
|
+
if (!optionList?.contains(FocusTrapHandle.getActiveElement(optionList))) {
|
|
298
|
+
this.close({
|
|
299
|
+
event,
|
|
300
|
+
returnFocus: event.shiftKey
|
|
301
|
+
});
|
|
302
|
+
return;
|
|
328
303
|
}
|
|
304
|
+
handlePrevent(event);
|
|
305
|
+
this.#focusTrigger();
|
|
306
|
+
const trigger = FocusTrapHandle.getActiveElement(optionList);
|
|
307
|
+
const root = trigger?.getRootNode();
|
|
308
|
+
const scopes = root instanceof ShadowRoot ? [...root.children] : [trigger?.ownerDocument.body];
|
|
309
|
+
const next = event.shiftKey || !trigger ? null : scopes.flatMap((scope) => FocusTrapHandle.getFocusableElements(scope)).find((node) => !trigger.contains(node) && !optionList.contains(node) && trigger.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING);
|
|
310
|
+
this.close({
|
|
311
|
+
event,
|
|
312
|
+
returnFocus: false
|
|
313
|
+
});
|
|
314
|
+
next?.focus();
|
|
329
315
|
}
|
|
330
316
|
#handleEnterKeyDown(event) {
|
|
331
317
|
const { isOpen, options, focusIndex } = this.getStates();
|
|
@@ -395,7 +381,6 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
395
381
|
}
|
|
396
382
|
}
|
|
397
383
|
#handleTriggerFocus(e) {
|
|
398
|
-
this.setState({ isFocusInContainer: false });
|
|
399
384
|
this.#notifyFocus(e);
|
|
400
385
|
}
|
|
401
386
|
#handleTriggerBlur(e) {
|
|
@@ -437,10 +422,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
437
422
|
}
|
|
438
423
|
#focusInput() {
|
|
439
424
|
this.adapter.focusInput();
|
|
440
|
-
this.setState({
|
|
441
|
-
isFocus: true,
|
|
442
|
-
isFocusInContainer: false
|
|
443
|
-
});
|
|
425
|
+
this.setState({ isFocus: true });
|
|
444
426
|
}
|
|
445
427
|
#filterByKeyword(options) {
|
|
446
428
|
const { inputValue } = this.getStates();
|
|
@@ -522,7 +504,6 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
522
504
|
return {
|
|
523
505
|
isOpen: false,
|
|
524
506
|
isFocus: false,
|
|
525
|
-
isFocusInContainer: false,
|
|
526
507
|
isFullTags: false,
|
|
527
508
|
inputValue: "",
|
|
528
509
|
showInput: false,
|
|
@@ -541,10 +522,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
541
522
|
const { isOpen } = this.getStates();
|
|
542
523
|
const { searchPosition } = this.getProps();
|
|
543
524
|
const shouldOpenDropdown = openDropdown !== false;
|
|
544
|
-
this.setState({
|
|
545
|
-
isFocus: true,
|
|
546
|
-
isFocusInContainer: false
|
|
547
|
-
});
|
|
525
|
+
this.setState({ isFocus: true });
|
|
548
526
|
if (isFilterable) {
|
|
549
527
|
/**
|
|
550
528
|
* openDropdown false only refocuses the Select. With searchPosition='dropdown' the search input lives in
|
|
@@ -612,10 +590,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
612
590
|
if (!isOpen) return;
|
|
613
591
|
const { event, closeCb, notToggleInput, returnFocus = true } = closeConfig || {};
|
|
614
592
|
if (isFocus && returnFocus) this.#focusTrigger();
|
|
615
|
-
this.setState({
|
|
616
|
-
isOpen: false,
|
|
617
|
-
isFocusInContainer: false
|
|
618
|
-
});
|
|
593
|
+
this.setState({ isOpen: false });
|
|
619
594
|
this.adapter.notifyDropdownVisibleChange(false);
|
|
620
595
|
const isFilterable = this.#isFilterable();
|
|
621
596
|
if (isFilterable && !notToggleInput) this.#toggle2SearchInput(false);
|
|
@@ -683,7 +658,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
683
658
|
handleKeyDown = (event) => {
|
|
684
659
|
const { loading, filter, multiple, disabled, searchPosition } = this.getProps();
|
|
685
660
|
const { isOpen, showInput } = this.getStates();
|
|
686
|
-
if (loading || disabled || isComposing(event) || isInnerControlKey(event)) return;
|
|
661
|
+
if (loading || disabled || isComposing(event) || isInnerControlKey(event) || isBrowserChord(event)) return;
|
|
687
662
|
if (!(isTextEditor(event.target) || filter && searchPosition === strings.SEARCH_POSITION_TRIGGER && showInput) && this.#handleSelectOnlyKeyDown(event)) return;
|
|
688
663
|
switch (event.key) {
|
|
689
664
|
case "ArrowUp":
|
|
@@ -815,4 +790,4 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
|
|
|
815
790
|
this.setState({ focusIndex: -1 });
|
|
816
791
|
};
|
|
817
792
|
};
|
|
818
|
-
export { SelectFoundation as default
|
|
793
|
+
export { SelectFoundation as default };
|
|
@@ -242,8 +242,8 @@
|
|
|
242
242
|
}
|
|
243
243
|
.semi-select-content-wrapper-collapse {
|
|
244
244
|
display: inline-flex;
|
|
245
|
-
flex
|
|
246
|
-
width:
|
|
245
|
+
flex: 0 1 auto;
|
|
246
|
+
min-width: 0;
|
|
247
247
|
}
|
|
248
248
|
.semi-select-content-wrapper-collapse .semi-overflow-list-overflow {
|
|
249
249
|
min-width: 50px;
|
|
@@ -276,7 +276,7 @@
|
|
|
276
276
|
display: flex;
|
|
277
277
|
align-items: center;
|
|
278
278
|
}
|
|
279
|
-
.semi-select-multiple .semi-select-content-wrapper-one-line {
|
|
279
|
+
.semi-select-multiple .semi-select-content-wrapper-one-line, .semi-select-multiple .semi-select-content-wrapper:has(> .semi-select-content-wrapper-collapse) {
|
|
280
280
|
flex-wrap: nowrap;
|
|
281
281
|
}
|
|
282
282
|
.semi-select-multiple .semi-select-content-wrapper-one-line .semi-tag-group {
|
|
@@ -206,10 +206,11 @@ $overflowList: #{$prefix}-overflow-list;
|
|
|
206
206
|
overflow: hidden;
|
|
207
207
|
white-space: nowrap;
|
|
208
208
|
|
|
209
|
+
// takes the row beside the search input, so the input stays on the tags' row and OverflowList folds into what is left
|
|
209
210
|
&-collapse {
|
|
210
211
|
display: inline-flex;
|
|
211
|
-
flex
|
|
212
|
-
width:
|
|
212
|
+
flex: 0 1 auto;
|
|
213
|
+
min-width: 0;
|
|
213
214
|
|
|
214
215
|
.#{$overflowList}-overflow {
|
|
215
216
|
min-width: 50px;
|
|
@@ -250,9 +251,13 @@ $overflowList: #{$prefix}-overflow-list;
|
|
|
250
251
|
align-items: center;
|
|
251
252
|
}
|
|
252
253
|
|
|
253
|
-
|
|
254
|
+
// wrapping comes before shrinking, so the folded tags would push the search input onto a second row
|
|
255
|
+
&-one-line,
|
|
256
|
+
&:has(> .#{$module}-content-wrapper-collapse) {
|
|
254
257
|
flex-wrap: nowrap;
|
|
258
|
+
}
|
|
255
259
|
|
|
260
|
+
&-one-line {
|
|
256
261
|
.#{$prefix}-tag-group {
|
|
257
262
|
flex-shrink: 0;
|
|
258
263
|
flex-wrap: nowrap;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const cssClasses: {
|
|
2
2
|
PREFIX: string;
|
|
3
3
|
};
|
|
4
|
+
/** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
|
|
5
|
+
export type SideSheetPart = 'mask' | 'content' | 'header' | 'body' | 'footer';
|
|
4
6
|
export declare const strings: {
|
|
5
7
|
HEIGHT: number;
|
|
6
8
|
};
|
|
@@ -3,7 +3,6 @@ import "../../base/index.js";
|
|
|
3
3
|
export type Placement = 'top' | 'bottom' | 'left' | 'right';
|
|
4
4
|
export interface SideSheetProps {
|
|
5
5
|
afterVisibleChange?: (isVisible: boolean) => void;
|
|
6
|
-
bodyStyle?: Record<string, any>;
|
|
7
6
|
className?: string;
|
|
8
7
|
closable?: boolean;
|
|
9
8
|
closeIcon?: any;
|
|
@@ -11,12 +10,10 @@ export interface SideSheetProps {
|
|
|
11
10
|
disableScroll?: boolean;
|
|
12
11
|
footer?: any;
|
|
13
12
|
getPopupContainer?: () => HTMLElement;
|
|
14
|
-
headerStyle?: Record<string, any>;
|
|
15
13
|
height?: number | string;
|
|
16
14
|
keepDOM?: boolean;
|
|
17
15
|
mask?: boolean;
|
|
18
16
|
maskClosable?: boolean;
|
|
19
|
-
maskStyle?: Record<string, any>;
|
|
20
17
|
motion?: boolean;
|
|
21
18
|
onCancel?: (e: any) => void;
|
|
22
19
|
placement?: Placement;
|
|
@@ -71,9 +68,14 @@ export default class SideSheetFoundation<P extends SideSheetProps = SideSheetPro
|
|
|
71
68
|
/** Remembers the element to return focus to; hosts call it on opening, before anything inside the sheet takes focus */
|
|
72
69
|
recordFocus: () => void;
|
|
73
70
|
handleCancel: (e: unknown) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Hosts call this when the dialog's animation ends, and at once when a run without motion starts: the end of an
|
|
73
|
+
* enter reports afterVisibleChange(true), once per showing.
|
|
74
|
+
*/
|
|
75
|
+
handleAnimationEnd: () => void;
|
|
74
76
|
/**
|
|
75
77
|
* Hosts call this when the sheet stops or starts being hidden (once the animations ended), not on mount, and with
|
|
76
|
-
* `true` when it unmounts for good: afterVisibleChange(false) is reported once per showing
|
|
78
|
+
* `true` when it unmounts for good: afterVisibleChange(false) is reported once per showing, after its `true`.
|
|
77
79
|
*/
|
|
78
80
|
handleHiddenChange: (isHidden: boolean) => void;
|
|
79
81
|
beforeShow: () => void;
|