@fibrae/semi-foundation 0.6.0 → 0.8.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/form/form.css +47 -2
- package/dist/components/form/form.scss +44 -2
- package/dist/components/form/foundation.d.ts +2 -1
- package/dist/components/form/foundation.js +63 -3
- package/dist/components/form/interface.d.ts +9 -1
- package/dist/components/form/json-schema.d.ts +35 -2
- package/dist/components/form/json-schema.js +75 -8
- package/dist/components/form/variables.scss +4 -0
- 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 +0 -3
- 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 +6 -6
- 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/table/foundation.d.ts +8 -0
- package/dist/components/table/foundation.js +12 -0
- package/dist/components/table/rtl.scss +5 -0
- package/dist/components/table/table.css +123 -0
- package/dist/components/table/table.scss +174 -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/toast/toast.css +1 -1
- package/dist/components/toast/toast.scss +2 -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/tooltip/tooltip.css +1 -1
- package/dist/components/tooltip/tooltip.scss +4 -2
- 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 +3 -1
- 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 +6 -0
- package/dist/locale/source/en_US.js +4 -1
- package/dist/locale/source/zh_CN.js +4 -1
- 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 +4 -3
- package/dist/utils/index.js +4 -3
- package/dist/utils/media.d.ts +2 -0
- package/dist/utils/media.js +15 -0
- package/dist/utils/scroll-lock.d.ts +4 -3
- package/dist/utils/scroll-lock.js +15 -11
- package/dist/utils/supports.d.ts +2 -0
- package/dist/utils/supports.js +7 -1
- 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,14 +1,15 @@
|
|
|
1
1
|
import BaseFoundation from "../../base/foundation.js";
|
|
2
|
-
import { isInnerControlActivation, isTextEditor } from "../../utils/a11y.js";
|
|
2
|
+
import { Typeahead, isBrowserChord, isInnerControlActivation, isTextEditor } from "../../utils/a11y.js";
|
|
3
3
|
import isEnterPress from "../../utils/is-enter-press.js";
|
|
4
4
|
import "../../utils/key-code.js";
|
|
5
|
-
import { calcRelatedCheckedKeys, deriveTreeState, getClearedSelection, getMultipleChange, getMultipleSelectResult, getNodeData, getSearchState, isTreeNodeLeaf, loadTreeNode } from "../tree/shared.js";
|
|
5
|
+
import { buildRowProps, calcRelatedCheckedKeys, deriveTreeState, getClearedSelection, getMultipleChange, getMultipleSelectResult, getNodeData, getSearchState, getTreeActiveIndex, handleTreeKeyDown, isTreeNodeLeaf, loadTreeNode } from "../tree/shared.js";
|
|
6
6
|
import { findAncestorKeys, flattenTreeData, getMotionKeys, getValueOrKey, normalizeKeyList } from "../tree/tree-util.js";
|
|
7
7
|
import { strings } from "./constants.js";
|
|
8
8
|
import { get } from "es-toolkit/compat";
|
|
9
9
|
// src/components/tree-select/foundation.ts
|
|
10
10
|
var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
11
11
|
#blurPending = false;
|
|
12
|
+
#typeahead = new Typeahead();
|
|
12
13
|
/**
|
|
13
14
|
* Every prop `deriveState` reads, which it keeps as `prevProps`. They change state during render, so there is no
|
|
14
15
|
* `handlePropsChange`; a prop deriveState starts reading goes on this list too.
|
|
@@ -222,13 +223,18 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
222
223
|
prevProps: null,
|
|
223
224
|
cachedKeyValuePairs: {},
|
|
224
225
|
loadedKeys: /* @__PURE__ */ new Set(),
|
|
225
|
-
loadingKeys: /* @__PURE__ */ new Set()
|
|
226
|
+
loadingKeys: /* @__PURE__ */ new Set(),
|
|
227
|
+
keyboardKey: null
|
|
226
228
|
};
|
|
227
229
|
return {
|
|
228
230
|
...state,
|
|
229
231
|
...TreeSelectFoundation.deriveState(props, state)
|
|
230
232
|
};
|
|
231
233
|
}
|
|
234
|
+
/** The row the keys act on, -1 for none: an APG combobox opens without an active option */
|
|
235
|
+
static getActiveIndex({ flattenNodes, keyboardKey }) {
|
|
236
|
+
return getTreeActiveIndex(flattenNodes, keyboardKey, -1);
|
|
237
|
+
}
|
|
232
238
|
/** The keys the trigger shows: the selection, or in multiple mode the checked keys merged as onChange reports them */
|
|
233
239
|
static getTriggerKeys(props, { checkedKeys, realCheckedKeys, keyEntities, selectedKeys }) {
|
|
234
240
|
if (!props.multiple) return selectedKeys;
|
|
@@ -300,7 +306,10 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
300
306
|
this.#focusInput();
|
|
301
307
|
};
|
|
302
308
|
close = () => {
|
|
303
|
-
this.setState({
|
|
309
|
+
this.setState({
|
|
310
|
+
isOpen: false,
|
|
311
|
+
keyboardKey: null
|
|
312
|
+
});
|
|
304
313
|
this.adapter.notifyVisibleChange(false);
|
|
305
314
|
if (this.getProp("motionExpand")) this.setState({ motionKeys: /* @__PURE__ */ new Set([]) });
|
|
306
315
|
};
|
|
@@ -321,10 +330,10 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
321
330
|
/**
|
|
322
331
|
* Enter toggles the popup like a click; Down and Up open a closed one (APG combobox). Outside a text field (the
|
|
323
332
|
* select-only combobox) Space toggles it like Enter, and Home and End open a closed one: the view moves to the
|
|
324
|
-
* first or the last row
|
|
325
|
-
* view there.
|
|
333
|
+
* first or the last row.
|
|
326
334
|
*/
|
|
327
335
|
handleSelectionKeyDown = (e) => {
|
|
336
|
+
if (isBrowserChord(e)) return;
|
|
328
337
|
const editing = isTextEditor(e.target);
|
|
329
338
|
const isClosed = !this.getState("isOpen");
|
|
330
339
|
const opensOnEdgeKey = isClosed && !editing && (e.key === "Home" || e.key === "End");
|
|
@@ -332,7 +341,30 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
332
341
|
e.preventDefault();
|
|
333
342
|
this.handleClick(e);
|
|
334
343
|
}
|
|
335
|
-
|
|
344
|
+
if (opensOnEdgeKey) this.handleRowKeyDown(e);
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Tree keys of the open popup (APG combobox with a tree popup), acting on the active row while the focus stays on
|
|
348
|
+
* the combobox. In a text field only Up, Down and Enter act on the tree. Returns whether the key was handled.
|
|
349
|
+
*/
|
|
350
|
+
handleRowKeyDown = (e) => {
|
|
351
|
+
const state = this.getStates();
|
|
352
|
+
if (!state.isOpen) return false;
|
|
353
|
+
return handleTreeKeyDown(e, {
|
|
354
|
+
rows: state.flattenNodes,
|
|
355
|
+
activeIndex: TreeSelectFoundation.getActiveIndex(state),
|
|
356
|
+
editing: isTextEditor(e.target),
|
|
357
|
+
rtl: this.getContext("direction") === "rtl",
|
|
358
|
+
hasLoadData: Boolean(this.getProp("loadData")),
|
|
359
|
+
rowProps: (row) => buildRowProps(row, state, this.getProps()),
|
|
360
|
+
typeahead: this.#typeahead,
|
|
361
|
+
moveTo: (index, key) => {
|
|
362
|
+
this.setState({ keyboardKey: key });
|
|
363
|
+
this.adapter.revealRow(index, key);
|
|
364
|
+
},
|
|
365
|
+
select: this.handleNodeSelect,
|
|
366
|
+
expand: this.handleNodeExpand
|
|
367
|
+
});
|
|
336
368
|
};
|
|
337
369
|
handleClear = (e) => {
|
|
338
370
|
const { searchPosition, filterTreeNode } = this.getProps();
|
|
@@ -373,11 +405,13 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
373
405
|
this.adapter.notifySelect(eventKey, false, item);
|
|
374
406
|
};
|
|
375
407
|
handleNodeSelect = (e, treeNode) => {
|
|
408
|
+
this.setState({ keyboardKey: treeNode.eventKey });
|
|
376
409
|
if (this.#isDisabled(treeNode)) return;
|
|
377
410
|
if (!this.#isMultiple()) this.#handleSingleSelect(e, treeNode);
|
|
378
411
|
else this.#handleMultipleSelect(e, treeNode);
|
|
379
412
|
};
|
|
380
413
|
handleNodeExpand = (e, treeNode) => {
|
|
414
|
+
this.setState({ keyboardKey: treeNode.eventKey });
|
|
381
415
|
const { loadData, keyMaps } = this.getProps();
|
|
382
416
|
const { inputValue, keyEntities } = this.getStates();
|
|
383
417
|
const isSearching = Boolean(inputValue);
|
|
@@ -426,6 +460,9 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
426
460
|
handlePopoverOpen = () => {
|
|
427
461
|
const { filterTreeNode, searchAutoFocus, searchPosition } = this.getProps();
|
|
428
462
|
if (filterTreeNode && searchPosition === strings.SEARCH_POSITION_DROPDOWN && searchAutoFocus) this.#focusInput();
|
|
463
|
+
const state = this.getStates();
|
|
464
|
+
const index = TreeSelectFoundation.getActiveIndex(state);
|
|
465
|
+
if (index !== -1) this.adapter.revealRow(index, state.flattenNodes[index].key);
|
|
429
466
|
};
|
|
430
467
|
handleAfterClose = () => {
|
|
431
468
|
const { filterTreeNode } = this.getProps();
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export declare const byteKB = 1024;
|
|
2
2
|
export declare const byteMB = 1048576;
|
|
3
|
+
export declare function isUploadProgressVisible({ percent, status }: {
|
|
4
|
+
percent?: number;
|
|
5
|
+
status?: string;
|
|
6
|
+
}): boolean;
|
|
7
|
+
export declare function isUploadFailed(status?: string): boolean;
|
|
3
8
|
/** The attributes `containsControl` and `containsName` read, which the add area observes to recheck them */
|
|
4
9
|
export declare const addAreaObservedAttributes: string[];
|
|
5
10
|
export declare function containsControl(node: HTMLElement): boolean;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import FocusTrapHandle from "../../base/focus-handle.js";
|
|
2
2
|
import { handoverFocus } from "../../utils/focus-handover.js";
|
|
3
|
-
import { cssClasses } from "./constants.js";
|
|
3
|
+
import { cssClasses, strings } from "./constants.js";
|
|
4
4
|
// src/components/upload/utils.ts
|
|
5
5
|
const byteKB = 1024;
|
|
6
6
|
const byteMB = 1048576;
|
|
7
|
+
function isUploadProgressVisible({ percent, status }) {
|
|
8
|
+
return percent !== void 0 && percent !== 100 && status === strings.FILE_STATUS_UPLOADING;
|
|
9
|
+
}
|
|
10
|
+
function isUploadFailed(status) {
|
|
11
|
+
return status === strings.FILE_STATUS_UPLOAD_FAIL || status === strings.FILE_STATUS_VALID_FAIL;
|
|
12
|
+
}
|
|
7
13
|
/** The attributes `containsControl` and `containsName` read, which the add area observes to recheck them */
|
|
8
14
|
const addAreaObservedAttributes = [
|
|
9
15
|
"disabled",
|
|
@@ -103,4 +109,4 @@ async function mapFileTree(items) {
|
|
|
103
109
|
for (const result of [...traversals, ...reads]) if (result.status === "rejected") console.error(result.reason);
|
|
104
110
|
return reads.filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
105
111
|
}
|
|
106
|
-
export { ListFocusTracker, addAreaObservedAttributes, byteKB, byteMB, containsControl, containsName, getFileSize, getFocusHandoverTarget, indexOfCard, loopFiles, mapFileTree, removeUnlessPrevented };
|
|
112
|
+
export { ListFocusTracker, addAreaObservedAttributes, byteKB, byteMB, containsControl, containsName, getFileSize, getFocusHandoverTarget, indexOfCard, isUploadFailed, isUploadProgressVisible, loopFiles, mapFileTree, removeUnlessPrevented };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import FocusTrapHandle from "../../base/focus-handle.js";
|
|
2
2
|
import BaseFoundation from "../../base/foundation.js";
|
|
3
3
|
import { formatLocale } from "../../locale/format.js";
|
|
4
|
-
import { ignoreExpectedMediaErrors } from "
|
|
4
|
+
import { ignoreExpectedMediaErrors } from "../../utils/media.js";
|
|
5
5
|
import { clamp, throttle } from "es-toolkit";
|
|
6
6
|
// src/components/video-player/foundation.ts
|
|
7
7
|
var VideoPlayerFoundation = class extends BaseFoundation {
|
|
@@ -7,8 +7,6 @@ export interface TimeTexts {
|
|
|
7
7
|
}
|
|
8
8
|
/** The spoken form of a time, since a screen reader reads "1:05" as a ratio rather than a duration. */
|
|
9
9
|
export declare function formatTimeText(time: number, texts: TimeTexts): string;
|
|
10
|
-
/** Drops the rejections a media request is expected to meet in normal use; any other rejection stays a rejection. */
|
|
11
|
-
export declare function ignoreExpectedMediaErrors(request: Promise<unknown>): Promise<void>;
|
|
12
10
|
/**
|
|
13
11
|
* Where a pointer is along a slider track: `offset` from the track's start (the left edge, or the bottom edge when
|
|
14
12
|
* vertical) in px and the `ratio` of the track's `total` length, both clamped to the track: a captured pointer keeps
|
|
@@ -28,19 +28,6 @@ function formatTimeText(time, texts) {
|
|
|
28
28
|
});
|
|
29
29
|
return formatLocale(texts.timeS, { seconds });
|
|
30
30
|
}
|
|
31
|
-
const EXPECTED_MEDIA_ERRORS = /* @__PURE__ */ new Set([
|
|
32
|
-
"AbortError",
|
|
33
|
-
"NotAllowedError",
|
|
34
|
-
"InvalidStateError",
|
|
35
|
-
"NotSupportedError"
|
|
36
|
-
]);
|
|
37
|
-
/** Drops the rejections a media request is expected to meet in normal use; any other rejection stays a rejection. */
|
|
38
|
-
function ignoreExpectedMediaErrors(request) {
|
|
39
|
-
return request.then(() => void 0, (error) => {
|
|
40
|
-
if (error instanceof DOMException && EXPECTED_MEDIA_ERRORS.has(error.name)) return;
|
|
41
|
-
throw error;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
31
|
/**
|
|
45
32
|
* Where a pointer is along a slider track: `offset` from the track's start (the left edge, or the bottom edge when
|
|
46
33
|
* vertical) in px and the `ratio` of the track's `total` length, both clamped to the track: a captured pointer keeps
|
|
@@ -55,4 +42,4 @@ function getPointerRatio(rect, point, vertical) {
|
|
|
55
42
|
ratio: offset / total
|
|
56
43
|
};
|
|
57
44
|
}
|
|
58
|
-
export { formatTime, formatTimeText, getPointerRatio
|
|
45
|
+
export { formatTime, formatTimeText, getPointerRatio };
|
|
@@ -12,6 +12,8 @@ export interface Locale {
|
|
|
12
12
|
/** ISO 4217 code, passed to Intl.NumberFormat by InputNumber */
|
|
13
13
|
currency: string;
|
|
14
14
|
Pagination: {
|
|
15
|
+
/** name of the navigation landmark that wraps the page list */
|
|
16
|
+
label: string;
|
|
15
17
|
pageSize: string;
|
|
16
18
|
total: string;
|
|
17
19
|
jumpTo: string;
|
|
@@ -360,6 +362,8 @@ export interface Locale {
|
|
|
360
362
|
};
|
|
361
363
|
Form: {
|
|
362
364
|
optional: string;
|
|
365
|
+
/** name of the button that shows the tooltip of a label */
|
|
366
|
+
labelTooltip: string;
|
|
363
367
|
/** Default rule messages; `${len}`, `${min}`, `${max}` are the rule's bounds */
|
|
364
368
|
required: string;
|
|
365
369
|
invalid: string;
|
|
@@ -378,6 +382,8 @@ export interface Locale {
|
|
|
378
382
|
moveUpItem: string;
|
|
379
383
|
moveDownItem: string;
|
|
380
384
|
item: string;
|
|
385
|
+
/** Name of a single-value row, which shows no label; `${title}` is the array's title */
|
|
386
|
+
arrayItem: string;
|
|
381
387
|
};
|
|
382
388
|
Image: {
|
|
383
389
|
preview: string;
|
|
@@ -64,6 +64,7 @@ const local = {
|
|
|
64
64
|
stars: "stars"
|
|
65
65
|
},
|
|
66
66
|
Pagination: {
|
|
67
|
+
label: "Pagination",
|
|
67
68
|
more: "More",
|
|
68
69
|
pageN: "Page ${page}",
|
|
69
70
|
prev: "Previous",
|
|
@@ -288,6 +289,7 @@ const local = {
|
|
|
288
289
|
},
|
|
289
290
|
Form: {
|
|
290
291
|
optional: "(optional)",
|
|
292
|
+
labelTooltip: "More information",
|
|
291
293
|
required: "This field is required",
|
|
292
294
|
invalid: "Invalid value",
|
|
293
295
|
stringLen: "Must be exactly ${len} characters",
|
|
@@ -303,7 +305,8 @@ const local = {
|
|
|
303
305
|
removeItem: "Remove item ${index}",
|
|
304
306
|
moveUpItem: "Move item ${index} up",
|
|
305
307
|
moveDownItem: "Move item ${index} down",
|
|
306
|
-
item: "Item ${index}"
|
|
308
|
+
item: "Item ${index}",
|
|
309
|
+
arrayItem: "${title} item ${index}"
|
|
307
310
|
},
|
|
308
311
|
Image: {
|
|
309
312
|
fallback: "fallback",
|
|
@@ -64,6 +64,7 @@ const local = {
|
|
|
64
64
|
stars: "星"
|
|
65
65
|
},
|
|
66
66
|
Pagination: {
|
|
67
|
+
label: "分页",
|
|
67
68
|
more: "更多",
|
|
68
69
|
pageN: "第 ${page} 页",
|
|
69
70
|
prev: "上一页",
|
|
@@ -288,6 +289,7 @@ const local = {
|
|
|
288
289
|
},
|
|
289
290
|
Form: {
|
|
290
291
|
optional: "(可选)",
|
|
292
|
+
labelTooltip: "更多说明",
|
|
291
293
|
required: "此项为必填项",
|
|
292
294
|
invalid: "格式不正确",
|
|
293
295
|
stringLen: "长度须为 ${len} 个字符",
|
|
@@ -303,7 +305,8 @@ const local = {
|
|
|
303
305
|
removeItem: "删除第 ${index} 项",
|
|
304
306
|
moveUpItem: "上移第 ${index} 项",
|
|
305
307
|
moveDownItem: "下移第 ${index} 项",
|
|
306
|
-
item: "第 ${index} 项"
|
|
308
|
+
item: "第 ${index} 项",
|
|
309
|
+
arrayItem: "${title} 第 ${index} 项"
|
|
307
310
|
},
|
|
308
311
|
Image: {
|
|
309
312
|
fallback: "占位图",
|
package/dist/utils/a11y.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
/** The id of the option at `index`, which `aria-activedescendant` points at and `revealOption` finds; `listId` is the host's id for the list */
|
|
2
|
+
export declare function getOptionId(listId: string, index: number): string;
|
|
3
|
+
/**
|
|
4
|
+
* Scrolls the option with `id` inside `root` to the centre of its listbox; a no-op when it is not rendered (virtual
|
|
5
|
+
* list). The listbox is found from the option, not by position, because group titles are siblings of the options.
|
|
6
|
+
*/
|
|
7
|
+
export declare function revealOption(root: HTMLElement | null | undefined, id: string): void;
|
|
1
8
|
export declare function handlePrevent(event: Pick<Event, 'stopPropagation' | 'preventDefault'>): void;
|
|
9
|
+
/** Chords belong to the browser and the system; Alt+Down and Alt+Up still open a popup (APG combobox), and Option+Tab is Safari's Tab to every control */
|
|
10
|
+
export declare function isBrowserChord({ key, ctrlKey, metaKey, altKey }: Pick<KeyboardEvent, 'key'> & Partial<Pick<KeyboardEvent, 'ctrlKey' | 'metaKey' | 'altKey'>>): boolean;
|
|
2
11
|
/**
|
|
3
12
|
* Space-separated ids for aria-labelledby and aria-describedby, undefined when there are none; the caller's ids go
|
|
4
13
|
* first, so the Form's ids are added to them instead of replacing them
|
package/dist/utils/a11y.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
import { centerInScroller } from "./dom.js";
|
|
1
2
|
import { isDev } from "./warning.js";
|
|
2
3
|
// src/utils/a11y.ts
|
|
4
|
+
/** The id of the option at `index`, which `aria-activedescendant` points at and `revealOption` finds; `listId` is the host's id for the list */
|
|
5
|
+
function getOptionId(listId, index) {
|
|
6
|
+
return `${listId}-option-${index}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Scrolls the option with `id` inside `root` to the centre of its listbox; a no-op when it is not rendered (virtual
|
|
10
|
+
* list). The listbox is found from the option, not by position, because group titles are siblings of the options.
|
|
11
|
+
*/
|
|
12
|
+
function revealOption(root, id) {
|
|
13
|
+
const option = root?.querySelector(`#${CSS.escape(id)}`);
|
|
14
|
+
const listbox = option?.closest("[role=\"listbox\"]");
|
|
15
|
+
if (option && listbox) centerInScroller(option, listbox);
|
|
16
|
+
}
|
|
3
17
|
function handlePrevent(event) {
|
|
4
18
|
event.stopPropagation();
|
|
5
19
|
event.preventDefault();
|
|
6
20
|
}
|
|
21
|
+
/** Chords belong to the browser and the system; Alt+Down and Alt+Up still open a popup (APG combobox), and Option+Tab is Safari's Tab to every control */
|
|
22
|
+
function isBrowserChord({ key, ctrlKey, metaKey, altKey }) {
|
|
23
|
+
return Boolean(ctrlKey || metaKey || altKey && key !== "ArrowDown" && key !== "ArrowUp" && key !== "Tab");
|
|
24
|
+
}
|
|
7
25
|
/**
|
|
8
26
|
* Space-separated ids for aria-labelledby and aria-describedby, undefined when there are none; the caller's ids go
|
|
9
27
|
* first, so the Form's ids are added to them instead of replacing them
|
|
@@ -179,4 +197,4 @@ function warnIfDialogUnnamed(dialog, component) {
|
|
|
179
197
|
const hasLabelElement = labelledBy?.split(/\s+/).some((id) => root.getElementById(id)?.textContent.trim());
|
|
180
198
|
if (!dialog.getAttribute("aria-label")?.trim() && !hasLabelElement) console.warn(`Warning: [Semi ${component}] the dialog has no accessible name. Pass \`title\`, \`aria-label\` or \`aria-labelledby\`.`);
|
|
181
199
|
}
|
|
182
|
-
export { Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, handlePrevent, isAriaKey, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isTextEditor, joinIds, namedRole, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, stopButtonActivationKeys, warnIfDialogUnnamed };
|
|
200
|
+
export { Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, getOptionId, handlePrevent, isAriaKey, isBrowserChord, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isTextEditor, joinIds, namedRole, revealOption, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, stopButtonActivationKeys, warnIfDialogUnnamed };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function isValidDate(date: any): boolean;
|
|
1
2
|
/**
|
|
2
3
|
* The Intl time zone for a Semi time zone value: an offset in hours or a GMT±HH:MM string becomes the fixed ±HH:MM
|
|
3
4
|
* offset Intl accepts, which never shifts for DST; any other string is used as is, normally an IANA name
|
|
@@ -2,6 +2,9 @@ import { TZDate, tzOffset } from "@date-fns/tz";
|
|
|
2
2
|
import { parseISO, toDate } from "date-fns";
|
|
3
3
|
// src/utils/date-fns-extra.ts
|
|
4
4
|
const GMTStringReg = /[-+]\d{2}:\d{2}/;
|
|
5
|
+
function isValidDate(date) {
|
|
6
|
+
return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date);
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
9
|
* The Intl time zone for a Semi time zone value: an offset in hours or a GMT±HH:MM string becomes the fixed ±HH:MM
|
|
7
10
|
* offset Intl accepts, which never shifts for DST; any other string is used as is, normally an IANA name
|
|
@@ -103,4 +106,4 @@ function zonedTimeToUtc(date, timeZone) {
|
|
|
103
106
|
if (!ianaTimeZone && typeof date === "string" && !/(Z|[+-]\d{2}(:?\d{2})?)$/.test(date)) return dateValue;
|
|
104
107
|
return new Date(wallTimeToInstant(wallTimeAsUtc(dateValue), ianaTimeZone));
|
|
105
108
|
}
|
|
106
|
-
export { isValidTimezoneIANAString, toIANA, utcToZonedTime, zonedTimeToUtc };
|
|
109
|
+
export { isValidDate, isValidTimezoneIANAString, toIANA, utcToZonedTime, zonedTimeToUtc };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListNavigationOptions, Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, handlePrevent, isAriaKey, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isTextEditor, joinIds, namedRole, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, stopButtonActivationKeys, warnIfDialogUnnamed } from "./a11y.js";
|
|
1
|
+
import { ListNavigationOptions, Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, getOptionId, handlePrevent, isAriaKey, isBrowserChord, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isTextEditor, joinIds, namedRole, revealOption, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, stopButtonActivationKeys, warnIfDialogUnnamed } from "./a11y.js";
|
|
2
2
|
import { pinAnimatedHeight } from "./animated-height.js";
|
|
3
3
|
import Announcer, { ANNOUNCE_DELAY, ANNOUNCE_HOLD } from "./announcer.js";
|
|
4
4
|
import arrayMove from "./array-move.js";
|
|
@@ -19,13 +19,14 @@ import isPromise from "./is-promise.js";
|
|
|
19
19
|
import isValidTimeZone from "./is-valid-time-zone.js";
|
|
20
20
|
import { ENTER_KEY, ESC_KEY, isComposing } from "./key-code.js";
|
|
21
21
|
import { KEEP_INTERACTIVE_ATTRIBUTE, Layer, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, containsWithPopups, getPopupTrigger, openLayer, popupTriggerSelector, popupTriggers } from "./layer.js";
|
|
22
|
+
import { ignoreExpectedMediaErrors } from "./media.js";
|
|
22
23
|
import { get, has, isEmpty, remove, set } from "./object.js";
|
|
23
24
|
import { isSecondaryPress } from "./pointer.js";
|
|
24
25
|
import { lockBodyScroll } from "./scroll-lock.js";
|
|
25
26
|
import shallowEqualObjects from "./shallow-equal-objects.js";
|
|
26
|
-
import { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption } from "./supports.js";
|
|
27
|
+
import { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter } from "./supports.js";
|
|
27
28
|
import { Easing, TweenOptions, easeInOutCubic, linear, tween } from "./tween.js";
|
|
28
29
|
import { ArrayElement, Size } from "./type.js";
|
|
29
30
|
import { createId } from "./uuid.js";
|
|
30
31
|
import warning, { isDev } from "./warning.js";
|
|
31
|
-
export { ANNOUNCE_DELAY, ANNOUNCE_HOLD, Announcer, ArrayElement, CopiedTimer, ENTER_KEY, ESC_KEY, Easing, Event as EventEmitter, KEEP_INTERACTIVE_ATTRIBUTE, Layer, ListNavigationOptions, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, RegisterMediaQueryOption, Size, TweenOptions, Typeahead, addClass, arrayMove, assertClient, centerInScroller, containsWithPopups, copyText, coversPage, createId, crossesFocusBoundary, defaultPopupContainer, differenceUnique, easeInOutCubic, escapeHtmlInMarkdown, findFocusAfter, fitInputWidth, fitTextareaHeight, focusWithoutRing, get, getDataAttr, getEnabledStepIndex, getListTargetIndex, getPopupTrigger, handlePrevent, handoverFocus, has, isAriaKey, isComposing, isDev, isEmpty, isEnterPress, isEventInside, isHTMLElement, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isObject, isPromise, isSecondaryPress, isTextEditor, isValidTimeZone, joinIds, linear, lockBodyScroll, namedRole, noop, onFontsLoaded, openLayer, pinAnimatedHeight, popupTriggerSelector, popupTriggers, registerMediaQuery, remove, removeClass, resolvePopupContainer, scrollIntoViewWithin, set, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, shallowEqualObjects, stopButtonActivationKeys, supportsFieldSizing, supportsFocusVisibleOption, supportsScrollContainerOption, toCssLength, tween, warnIfDialogUnnamed, warning, withOrderSort };
|
|
32
|
+
export { ANNOUNCE_DELAY, ANNOUNCE_HOLD, Announcer, ArrayElement, CopiedTimer, ENTER_KEY, ESC_KEY, Easing, Event as EventEmitter, KEEP_INTERACTIVE_ATTRIBUTE, Layer, ListNavigationOptions, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, RegisterMediaQueryOption, Size, TweenOptions, Typeahead, addClass, arrayMove, assertClient, centerInScroller, containsWithPopups, copyText, coversPage, createId, crossesFocusBoundary, defaultPopupContainer, differenceUnique, easeInOutCubic, escapeHtmlInMarkdown, findFocusAfter, fitInputWidth, fitTextareaHeight, focusWithoutRing, get, getDataAttr, getEnabledStepIndex, getListTargetIndex, getOptionId, getPopupTrigger, handlePrevent, handoverFocus, has, ignoreExpectedMediaErrors, isAriaKey, isBrowserChord, isComposing, isDev, isEmpty, isEnterPress, isEventInside, isHTMLElement, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isObject, isPromise, isSecondaryPress, isTextEditor, isValidTimeZone, joinIds, linear, lockBodyScroll, namedRole, noop, onFontsLoaded, openLayer, pinAnimatedHeight, popupTriggerSelector, popupTriggers, registerMediaQuery, remove, removeClass, resolvePopupContainer, revealOption, scrollIntoViewWithin, set, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, shallowEqualObjects, stopButtonActivationKeys, supportsFieldSizing, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter, toCssLength, tween, warnIfDialogUnnamed, warning, withOrderSort };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, handlePrevent, isAriaKey, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isTextEditor, joinIds, namedRole, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, stopButtonActivationKeys, warnIfDialogUnnamed } from "./a11y.js";
|
|
1
|
+
import { Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, getOptionId, handlePrevent, isAriaKey, isBrowserChord, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isTextEditor, joinIds, namedRole, revealOption, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, stopButtonActivationKeys, warnIfDialogUnnamed } from "./a11y.js";
|
|
2
2
|
import { pinAnimatedHeight } from "./animated-height.js";
|
|
3
3
|
import Announcer, { ANNOUNCE_DELAY, ANNOUNCE_HOLD } from "./announcer.js";
|
|
4
4
|
import arrayMove from "./array-move.js";
|
|
@@ -19,12 +19,13 @@ import isPromise from "./is-promise.js";
|
|
|
19
19
|
import isValidTimeZone from "./is-valid-time-zone.js";
|
|
20
20
|
import { ENTER_KEY, ESC_KEY, isComposing } from "./key-code.js";
|
|
21
21
|
import { KEEP_INTERACTIVE_ATTRIBUTE, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, containsWithPopups, getPopupTrigger, openLayer, popupTriggerSelector, popupTriggers } from "./layer.js";
|
|
22
|
+
import { ignoreExpectedMediaErrors } from "./media.js";
|
|
22
23
|
import { get, has, isEmpty, remove, set } from "./object.js";
|
|
23
24
|
import { isSecondaryPress } from "./pointer.js";
|
|
24
25
|
import { lockBodyScroll } from "./scroll-lock.js";
|
|
25
26
|
import shallowEqualObjects from "./shallow-equal-objects.js";
|
|
26
|
-
import { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption } from "./supports.js";
|
|
27
|
+
import { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter } from "./supports.js";
|
|
27
28
|
import { easeInOutCubic, linear, tween } from "./tween.js";
|
|
28
29
|
import { createId } from "./uuid.js";
|
|
29
30
|
import warning, { isDev } from "./warning.js";
|
|
30
|
-
export { ANNOUNCE_DELAY, ANNOUNCE_HOLD, Announcer, CopiedTimer, ENTER_KEY, ESC_KEY, Event as EventEmitter, KEEP_INTERACTIVE_ATTRIBUTE, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, Typeahead, addClass, arrayMove, assertClient, centerInScroller, containsWithPopups, copyText, coversPage, createId, crossesFocusBoundary, defaultPopupContainer, differenceUnique, easeInOutCubic, escapeHtmlInMarkdown, findFocusAfter, fitInputWidth, fitTextareaHeight, focusWithoutRing, get, getDataAttr, getEnabledStepIndex, getListTargetIndex, getPopupTrigger, handlePrevent, handoverFocus, has, isAriaKey, isComposing, isDev, isEmpty, isEnterPress, isEventInside, isHTMLElement, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isObject, isPromise, isSecondaryPress, isTextEditor, isValidTimeZone, joinIds, linear, lockBodyScroll, namedRole, noop, onFontsLoaded, openLayer, pinAnimatedHeight, popupTriggerSelector, popupTriggers, registerMediaQuery, remove, removeClass, resolvePopupContainer, scrollIntoViewWithin, set, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, shallowEqualObjects, stopButtonActivationKeys, supportsFieldSizing, supportsFocusVisibleOption, supportsScrollContainerOption, toCssLength, tween, warnIfDialogUnnamed, warning, withOrderSort };
|
|
31
|
+
export { ANNOUNCE_DELAY, ANNOUNCE_HOLD, Announcer, CopiedTimer, ENTER_KEY, ESC_KEY, Event as EventEmitter, KEEP_INTERACTIVE_ATTRIBUTE, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, Typeahead, addClass, arrayMove, assertClient, centerInScroller, containsWithPopups, copyText, coversPage, createId, crossesFocusBoundary, defaultPopupContainer, differenceUnique, easeInOutCubic, escapeHtmlInMarkdown, findFocusAfter, fitInputWidth, fitTextareaHeight, focusWithoutRing, get, getDataAttr, getEnabledStepIndex, getListTargetIndex, getOptionId, getPopupTrigger, handlePrevent, handoverFocus, has, ignoreExpectedMediaErrors, isAriaKey, isBrowserChord, isComposing, isDev, isEmpty, isEnterPress, isEventInside, isHTMLElement, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isObject, isPromise, isSecondaryPress, isTextEditor, isValidTimeZone, joinIds, linear, lockBodyScroll, namedRole, noop, onFontsLoaded, openLayer, pinAnimatedHeight, popupTriggerSelector, popupTriggers, registerMediaQuery, remove, removeClass, resolvePopupContainer, revealOption, scrollIntoViewWithin, set, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, shallowEqualObjects, stopButtonActivationKeys, supportsFieldSizing, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter, toCssLength, tween, warnIfDialogUnnamed, warning, withOrderSort };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/utils/media.ts
|
|
2
|
+
const EXPECTED_MEDIA_ERRORS = /* @__PURE__ */ new Set([
|
|
3
|
+
"AbortError",
|
|
4
|
+
"NotAllowedError",
|
|
5
|
+
"InvalidStateError",
|
|
6
|
+
"NotSupportedError"
|
|
7
|
+
]);
|
|
8
|
+
/** Drops the rejections a media request is expected to meet in normal use; any other rejection stays a rejection. */
|
|
9
|
+
function ignoreExpectedMediaErrors(request) {
|
|
10
|
+
return request.then(() => void 0, (error) => {
|
|
11
|
+
if (error instanceof DOMException && EXPECTED_MEDIA_ERRORS.has(error.name)) return;
|
|
12
|
+
throw error;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export { ignoreExpectedMediaErrors };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Locks are counted, so stacked overlays release the page only when the last one closes.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Locks are counted, so stacked overlays release the page only when the last one closes. While the page shows a
|
|
3
|
+
* scrollbar, the root keeps its gutter, so nothing shifts sideways when the scrollbar disappears, fixed elements
|
|
4
|
+
* included. Without scrollbar-gutter the body's end padding grows by the scrollbar width instead, which fixed elements
|
|
5
|
+
* do not follow; padding rather than width keeps the body's own margin and any width set by the page's stylesheet.
|
|
5
6
|
*/
|
|
6
7
|
export declare function lockBodyScroll(): () => void;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
import { supportsScrollbarGutter } from "./supports.js";
|
|
1
2
|
// src/utils/scroll-lock.ts
|
|
2
3
|
let lockCount = 0;
|
|
3
4
|
let restore = null;
|
|
4
5
|
/**
|
|
5
|
-
* Locks are counted, so stacked overlays release the page only when the last one closes.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Locks are counted, so stacked overlays release the page only when the last one closes. While the page shows a
|
|
7
|
+
* scrollbar, the root keeps its gutter, so nothing shifts sideways when the scrollbar disappears, fixed elements
|
|
8
|
+
* included. Without scrollbar-gutter the body's end padding grows by the scrollbar width instead, which fixed elements
|
|
9
|
+
* do not follow; padding rather than width keeps the body's own margin and any width set by the page's stylesheet.
|
|
8
10
|
*/
|
|
9
11
|
function lockBodyScroll() {
|
|
10
12
|
if (lockCount === 0) {
|
|
11
|
-
const {
|
|
12
|
-
if (style.overflow === "hidden") restore = null;
|
|
13
|
+
const { body, documentElement: root } = document;
|
|
14
|
+
if (body.style.overflow === "hidden") restore = null;
|
|
13
15
|
else {
|
|
14
|
-
const scrollbarWidth = window.innerWidth -
|
|
15
|
-
const padding = getComputedStyle(document.body).paddingInlineEnd;
|
|
16
|
+
const scrollbarWidth = window.innerWidth - root.clientWidth;
|
|
16
17
|
restore = {
|
|
17
|
-
overflow: style.overflow,
|
|
18
|
-
paddingInlineEnd: style.paddingInlineEnd
|
|
18
|
+
overflow: body.style.overflow,
|
|
19
|
+
paddingInlineEnd: body.style.paddingInlineEnd,
|
|
20
|
+
scrollbarGutter: root.style.scrollbarGutter
|
|
19
21
|
};
|
|
20
|
-
style.overflow = "hidden";
|
|
21
|
-
style.
|
|
22
|
+
body.style.overflow = "hidden";
|
|
23
|
+
if (scrollbarWidth > 0 && supportsScrollbarGutter()) root.style.scrollbarGutter = "stable";
|
|
24
|
+
else if (scrollbarWidth > 0) body.style.paddingInlineEnd = `calc(${getComputedStyle(body).paddingInlineEnd} + ${scrollbarWidth}px)`;
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
lockCount++;
|
|
@@ -30,6 +33,7 @@ function lockBodyScroll() {
|
|
|
30
33
|
if (lockCount === 0 && restore) {
|
|
31
34
|
document.body.style.overflow = restore.overflow;
|
|
32
35
|
document.body.style.paddingInlineEnd = restore.paddingInlineEnd;
|
|
36
|
+
document.documentElement.style.scrollbarGutter = restore.scrollbarGutter;
|
|
33
37
|
restore = null;
|
|
34
38
|
}
|
|
35
39
|
};
|
package/dist/utils/supports.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** CSS `scrollbar-gutter`. Removable once the oldest supported Safari is 18.2. */
|
|
2
|
+
export declare function supportsScrollbarGutter(): boolean;
|
|
1
3
|
/**
|
|
2
4
|
* `scrollIntoView({ container: 'nearest' })` limits scrolling to the nearest scroller.
|
|
3
5
|
* Removable once the oldest supported browsers are Chrome 140, Firefox and Safari (neither supports it yet).
|
package/dist/utils/supports.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// src/utils/supports.ts
|
|
2
2
|
let containerOption;
|
|
3
3
|
let focusVisibleOption;
|
|
4
|
+
let scrollbarGutter;
|
|
5
|
+
/** CSS `scrollbar-gutter`. Removable once the oldest supported Safari is 18.2. */
|
|
6
|
+
function supportsScrollbarGutter() {
|
|
7
|
+
scrollbarGutter ??= CSS.supports("scrollbar-gutter", "stable");
|
|
8
|
+
return scrollbarGutter;
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
11
|
* `scrollIntoView({ container: 'nearest' })` limits scrolling to the nearest scroller.
|
|
6
12
|
* Removable once the oldest supported browsers are Chrome 140, Firefox and Safari (neither supports it yet).
|
|
@@ -90,4 +96,4 @@ function focusWithoutRing(el, options = {}) {
|
|
|
90
96
|
el.focus(options);
|
|
91
97
|
if (el.ownerDocument.activeElement !== el) clear();
|
|
92
98
|
}
|
|
93
|
-
export { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption };
|
|
99
|
+
export { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibrae/semi-foundation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://semi-design-next.pages.dev",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@date-fns/tz": "^1.5.0",
|
|
30
30
|
"@dnd-kit/dom": "~0.5.3",
|
|
31
|
-
"@fibrae/semi-json-viewer-core": "0.
|
|
31
|
+
"@fibrae/semi-json-viewer-core": "0.8.0",
|
|
32
32
|
"@mdx-js/mdx": "^3.1.1",
|
|
33
33
|
"@shikijs/core": "^4.6.0",
|
|
34
34
|
"clsx": "^2.1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function isValidDate(date: any): boolean;
|