@fragiola/primitives 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +50 -2
- package/dist/async-list-Bv6ff5Oj.js +81 -0
- package/dist/async-list-Bv6ff5Oj.js.map +1 -0
- package/dist/async-list.d.ts +2 -0
- package/dist/async-list.js +1 -0
- package/dist/calendar-keys-DGYpjLwv.d.ts +12 -0
- package/dist/calendar-system-B5U5HcPQ.d.ts +415 -0
- package/dist/calendar-systems-Daa6Q_ca.js +659 -0
- package/dist/calendar-systems-Daa6Q_ca.js.map +1 -0
- package/dist/calendar-systems.d.ts +3 -0
- package/dist/calendar-systems.js +1 -0
- package/dist/carousel-LRbWqbAx.js +375 -0
- package/dist/carousel-LRbWqbAx.js.map +1 -0
- package/dist/carousel.d.ts +2 -0
- package/dist/carousel.js +1 -0
- package/dist/cascade-B155Xvvv.js +64 -0
- package/dist/cascade-B155Xvvv.js.map +1 -0
- package/dist/cascade.d.ts +2 -0
- package/dist/cascade.js +1 -0
- package/dist/clipboard-Cy2cbGEW.js +33 -0
- package/dist/clipboard-Cy2cbGEW.js.map +1 -0
- package/dist/clipboard.d.ts +2 -0
- package/dist/clipboard.js +1 -0
- package/dist/collection-Dbk-PB5S.js +609 -0
- package/dist/collection-Dbk-PB5S.js.map +1 -0
- package/dist/collection.d.ts +2 -0
- package/dist/collection.js +3 -0
- package/dist/color-sURV5Irg.js +699 -0
- package/dist/color-sURV5Irg.js.map +1 -0
- package/dist/color.d.ts +2 -0
- package/dist/color.js +1 -0
- package/dist/command-DueCXi65.js +104 -0
- package/dist/command-DueCXi65.js.map +1 -0
- package/dist/command.d.ts +2 -0
- package/dist/command.js +1 -0
- package/dist/date-CrbFSJKQ.js +215 -0
- package/dist/date-CrbFSJKQ.js.map +1 -0
- package/dist/date.d.ts +4 -0
- package/dist/date.js +1 -0
- package/dist/direction-CTnVLpmd.d.ts +8 -0
- package/dist/direction-DJDPvnxJ.js +13 -0
- package/dist/direction-DJDPvnxJ.js.map +1 -0
- package/dist/direction.d.ts +2 -0
- package/dist/direction.js +1 -0
- package/dist/drag-session-CSr06B5v.js +41 -0
- package/dist/drag-session-CSr06B5v.js.map +1 -0
- package/dist/file-DSLtfzbi.js +263 -0
- package/dist/file-DSLtfzbi.js.map +1 -0
- package/dist/file.d.ts +2 -0
- package/dist/file.js +1 -0
- package/dist/focus-BI-VvM0f.js +75 -0
- package/dist/focus-BI-VvM0f.js.map +1 -0
- package/dist/focus.d.ts +2 -0
- package/dist/focus.js +3 -0
- package/dist/form-DovwKtqz.js +501 -0
- package/dist/form-DovwKtqz.js.map +1 -0
- package/dist/form.d.ts +2 -0
- package/dist/form.js +1 -0
- package/dist/hover-BakyPYnC.js +62 -0
- package/dist/hover-BakyPYnC.js.map +1 -0
- package/dist/hover.d.ts +2 -0
- package/dist/hover.js +1 -0
- package/dist/id-B0Y8iZrc.js +13 -0
- package/dist/id-B0Y8iZrc.js.map +1 -0
- package/dist/id.d.ts +2 -0
- package/dist/id.js +1 -0
- package/dist/image-D4X_yRYw.js +44 -0
- package/dist/image-D4X_yRYw.js.map +1 -0
- package/dist/image.d.ts +2 -0
- package/dist/image.js +1 -0
- package/dist/index-B0rwIZw9.d.ts +51 -0
- package/dist/index-B4wF1isn.d.ts +128 -0
- package/dist/index-BHiBRE01.d.ts +20 -0
- package/dist/index-BNlMm-0u.d.ts +17 -0
- package/dist/index-BapNrjY9.d.ts +48 -0
- package/dist/index-Bd-tVb7C.d.ts +6 -0
- package/dist/index-BjE8nDiX.d.ts +125 -0
- package/dist/index-BpbT-FsX.d.ts +117 -0
- package/dist/index-CBgGcTeX.d.ts +37 -0
- package/dist/index-CGThV_Md.d.ts +100 -0
- package/dist/index-CMig3TXL.d.ts +28 -0
- package/dist/index-CWFRduRd.d.ts +212 -0
- package/dist/index-CkrHWyU_.d.ts +33 -0
- package/dist/index-Cwu6f7y1.d.ts +18 -0
- package/dist/index-D10LDdR6.d.ts +139 -0
- package/dist/index-D146vm21.d.ts +104 -0
- package/dist/index-DGKhEvNr.d.ts +107 -0
- package/dist/index-DbAu4s16.d.ts +48 -0
- package/dist/index-DdaCj6IO.d.ts +54 -0
- package/dist/index-DeHcNdjC.d.ts +68 -0
- package/dist/index-DeR4ncrW.d.ts +93 -0
- package/dist/index-HIksgK0e.d.ts +70 -0
- package/dist/index-IZB0mlZl.d.ts +71 -0
- package/dist/index-IfDZj87U.d.ts +28 -0
- package/dist/index-SrTuVBms.d.ts +75 -0
- package/dist/index-T9UcYvkf.d.ts +339 -0
- package/dist/index-fRTojAoR.d.ts +31 -0
- package/dist/index-fuLUke9n.d.ts +6 -0
- package/dist/index-l63esAck.d.ts +104 -0
- package/dist/index-raSUg9U7.d.ts +38 -0
- package/dist/index-twgzPKvZ.d.ts +278 -0
- package/dist/index-wBpjRykh.d.ts +125 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +42 -0
- package/dist/inert-DlGToy3q.js +80 -0
- package/dist/inert-DlGToy3q.js.map +1 -0
- package/dist/inert.d.ts +2 -0
- package/dist/inert.js +1 -0
- package/dist/layer-stack-BEtzaFC1.js +118 -0
- package/dist/layer-stack-BEtzaFC1.js.map +1 -0
- package/dist/layers-C-N4rrZX.js +24 -0
- package/dist/layers-C-N4rrZX.js.map +1 -0
- package/dist/layers.d.ts +2 -0
- package/dist/layers.js +3 -0
- package/dist/list-navigation-CbWv4DK5.js +40 -0
- package/dist/list-navigation-CbWv4DK5.js.map +1 -0
- package/dist/month-year-BG5imFUq.js +108 -0
- package/dist/month-year-BG5imFUq.js.map +1 -0
- package/dist/month-year.d.ts +3 -0
- package/dist/month-year.js +1 -0
- package/dist/number-BFUio97d.js +316 -0
- package/dist/number-BFUio97d.js.map +1 -0
- package/dist/number.d.ts +2 -0
- package/dist/number.js +1 -0
- package/dist/overlay-BwPyiM3T.js +78 -0
- package/dist/overlay-BwPyiM3T.js.map +1 -0
- package/dist/overlay.d.ts +2 -0
- package/dist/overlay.js +1 -0
- package/dist/pagination-BkVzaIGP.js +51 -0
- package/dist/pagination-BkVzaIGP.js.map +1 -0
- package/dist/pagination.d.ts +2 -0
- package/dist/pagination.js +1 -0
- package/dist/plain-date-idQH1P6X.d.ts +29 -0
- package/dist/plain-date-time-B8PGahhe.d.ts +99 -0
- package/dist/pointer-CuDtD9XA.js +189 -0
- package/dist/pointer-CuDtD9XA.js.map +1 -0
- package/dist/pointer.d.ts +2 -0
- package/dist/pointer.js +3 -0
- package/dist/positioning-DDUQ75mB.js +148 -0
- package/dist/positioning-DDUQ75mB.js.map +1 -0
- package/dist/positioning.d.ts +2 -0
- package/dist/positioning.js +1 -0
- package/dist/presence-BhKDOmII.js +86 -0
- package/dist/presence-BhKDOmII.js.map +1 -0
- package/dist/presence.d.ts +2 -0
- package/dist/presence.js +1 -0
- package/dist/range-o0_GBhyY.js +158 -0
- package/dist/range-o0_GBhyY.js.map +1 -0
- package/dist/range.d.ts +2 -0
- package/dist/range.js +1 -0
- package/dist/scroll-area-BYNhv36t.js +447 -0
- package/dist/scroll-area-BYNhv36t.js.map +1 -0
- package/dist/scroll-area.d.ts +2 -0
- package/dist/scroll-area.js +1 -0
- package/dist/scroll-lock-JzRNOA1O.js +42 -0
- package/dist/scroll-lock-JzRNOA1O.js.map +1 -0
- package/dist/scroll-lock.d.ts +2 -0
- package/dist/scroll-lock.js +1 -0
- package/dist/segments-eRu5G_Bd.js +587 -0
- package/dist/segments-eRu5G_Bd.js.map +1 -0
- package/dist/segments.d.ts +3 -0
- package/dist/segments.js +1 -0
- package/dist/selection-Cor67w_V.js +287 -0
- package/dist/selection-Cor67w_V.js.map +1 -0
- package/dist/selection.d.ts +2 -0
- package/dist/selection.js +1 -0
- package/dist/swipe.d.ts +2 -0
- package/dist/swipe.js +1 -0
- package/dist/tabbable-BPiLssIv.js +35 -0
- package/dist/tabbable-BPiLssIv.js.map +1 -0
- package/dist/time-Ct6oq9kt.js +208 -0
- package/dist/time-Ct6oq9kt.js.map +1 -0
- package/dist/time-zone-DegkzwST.js +305 -0
- package/dist/time-zone-DegkzwST.js.map +1 -0
- package/dist/time-zone.d.ts +2 -0
- package/dist/time-zone.js +1 -0
- package/dist/time.d.ts +2 -0
- package/dist/time.js +1 -0
- package/dist/toast-BjRpJalM.js +400 -0
- package/dist/toast-BjRpJalM.js.map +1 -0
- package/dist/toast.d.ts +2 -0
- package/dist/toast.js +1 -0
- package/dist/unit-grid-DJy8lb5D.d.ts +21 -0
- package/dist/virtual-BlX1RuHD.js +306 -0
- package/dist/virtual-BlX1RuHD.js.map +1 -0
- package/dist/virtual.d.ts +2 -0
- package/dist/virtual.js +1 -0
- package/dist/watch-swipe-BIucfr9O.js +301 -0
- package/dist/watch-swipe-BIucfr9O.js.map +1 -0
- package/package.json +234 -3
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A toast's natural height in px (spec/toast.md, "Stacking"): its border box with its inline
|
|
3
|
+
* `height` set to `auto` for the read, since a collapsed stack may give it the frontmost one's.
|
|
4
|
+
*/
|
|
5
|
+
declare function measureToastHeight(element: HTMLElement): number;
|
|
6
|
+
/** How urgently a toast is announced: `low` politely, `high` assertively (spec/toast.md). */
|
|
7
|
+
type ToastPriority = "low" | "high";
|
|
8
|
+
/** What a toast says and how long it stays (spec/toast.md, "The toast queue"). */
|
|
9
|
+
interface ToastOptions<Data = unknown> {
|
|
10
|
+
/** Adding a toast with the id of an open one updates it in place and restarts its timer. */
|
|
11
|
+
id?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
/** Free-form (`success`, `error`, ...); `loading` never closes by itself. */
|
|
15
|
+
type?: string;
|
|
16
|
+
/** ms before it closes by itself (default: the manager's); `0`: never. */
|
|
17
|
+
timeout?: number;
|
|
18
|
+
/** `low` (default): announced politely; `high`: assertively. */
|
|
19
|
+
priority?: ToastPriority;
|
|
20
|
+
/** The app's own data, for its rendering. */
|
|
21
|
+
data?: Data;
|
|
22
|
+
/** Called once when it closes (by its timer, a Close, a swipe, Escape or `close`). */
|
|
23
|
+
onClose?: () => void;
|
|
24
|
+
/** Called once it left the list, after its exit animation. */
|
|
25
|
+
onRemove?: () => void;
|
|
26
|
+
}
|
|
27
|
+
/** A change to an open toast (`update`): any option but its id. */
|
|
28
|
+
type ToastUpdate<Data = unknown> = Omit<ToastOptions<Data>, "id">;
|
|
29
|
+
/** A toast in the queue: its options, and what the queue derives for its rendering. */
|
|
30
|
+
interface ToastObject<Data = unknown> extends ToastUpdate<Data> {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly priority: ToastPriority;
|
|
33
|
+
/** Closed: its exit runs until the component calls `remove(id)`. */
|
|
34
|
+
readonly closing: boolean;
|
|
35
|
+
/** Past the `limit`: queued behind the newer ones, its timer waiting (spec/toast.md). */
|
|
36
|
+
readonly limited: boolean;
|
|
37
|
+
/** Its place in the stack, `0` the frontmost (newest); a closing toast keeps its list index. */
|
|
38
|
+
readonly index: number;
|
|
39
|
+
/** Its measured height in px (`setHeight`), `0` until measured and once closing. */
|
|
40
|
+
readonly height: number;
|
|
41
|
+
/** The sum of the heights of the toasts in front of it, in px. */
|
|
42
|
+
readonly offsetY: number;
|
|
43
|
+
/** Counts its updates (an upsert, `update`), so a component knows to measure it again. */
|
|
44
|
+
readonly updateKey: number;
|
|
45
|
+
}
|
|
46
|
+
/** A promise toast's three states: each a title, options, or a function of the result. */
|
|
47
|
+
interface ToastPromiseOptions<Value, Data = unknown> {
|
|
48
|
+
loading: string | ToastOptions<Data>;
|
|
49
|
+
success: string | ToastUpdate<Data> | ((value: Value) => string | ToastUpdate<Data>);
|
|
50
|
+
error: string | ToastUpdate<Data> | ((error: unknown) => string | ToastUpdate<Data>);
|
|
51
|
+
}
|
|
52
|
+
interface ToastManagerOptions {
|
|
53
|
+
/** How many toasts show at once; the older ones wait (default `3`). */
|
|
54
|
+
limit?: number;
|
|
55
|
+
/** The default ms before a toast closes by itself (default `5000`; `0`: never). */
|
|
56
|
+
timeout?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The toast queue (spec/toast.md, "The toast queue"): the app's notifications, which a plain
|
|
60
|
+
* module can import and fill, with no component. Toast's Provider renders from it and reports
|
|
61
|
+
* back what only the page knows (heights, the end of an exit, the hover and focus that pause it).
|
|
62
|
+
*/
|
|
63
|
+
interface ToastManager<Data = unknown> {
|
|
64
|
+
/** The toasts, newest first: the same array until something changes. */
|
|
65
|
+
toasts(): readonly ToastObject<Data>[];
|
|
66
|
+
/** Calls `listener` after every change; returns the unsubscribe. */
|
|
67
|
+
subscribe(listener: () => void): () => void;
|
|
68
|
+
/** Adds a toast (or updates the open one with its id); returns its id. */
|
|
69
|
+
add(options: ToastOptions<Data>): string;
|
|
70
|
+
/** Changes an open toast; ignored for a closing or unknown one. */
|
|
71
|
+
update(id: string, updates: ToastUpdate<Data> | ((toast: ToastObject<Data>) => ToastUpdate<Data>)): void;
|
|
72
|
+
/** Closes a toast, or every toast without an id. */
|
|
73
|
+
close(id?: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* A `loading` toast that becomes `success` or `error` when `promise` settles; returns the
|
|
76
|
+
* promise's own result (rejected with its error).
|
|
77
|
+
*/
|
|
78
|
+
promise<Value>(promise: Promise<Value>, options: ToastPromiseOptions<Value, Data>): Promise<Value>;
|
|
79
|
+
/** Takes a closed toast out of the list once its exit ended (the component calls it). */
|
|
80
|
+
remove(id: string): void;
|
|
81
|
+
/** Records a toast's measured height (the stacking offsets). */
|
|
82
|
+
setHeight(id: string, height: number): void;
|
|
83
|
+
/** Pauses every timer for `source` (`hover`, `focus`, `hidden`, ...) until resumed. */
|
|
84
|
+
pause(source: string): void;
|
|
85
|
+
/** Ends `source`'s pause; the timers run again once no source pauses them. */
|
|
86
|
+
resume(source: string): void;
|
|
87
|
+
/** Changes the limit or the default timeout (a Provider's props). */
|
|
88
|
+
configure(options: ToastManagerOptions): void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates a toast queue (spec/toast.md, "The toast queue"). Its timers run on the page's clock
|
|
92
|
+
* (`setTimeout`, `Date.now`); a toast's timer runs only while it shows (not queued past the
|
|
93
|
+
* limit, not closing, not `loading`) and nothing pauses the queue, and keeps what it had left
|
|
94
|
+
* across pauses.
|
|
95
|
+
*/
|
|
96
|
+
declare function createToastManager<Data = unknown>(options?: ToastManagerOptions): ToastManager<Data>;
|
|
97
|
+
/** What a Viewport's watch reports and needs (spec/toast.md, "Viewport"). */
|
|
98
|
+
interface ToastViewportWatch {
|
|
99
|
+
/** Moves focus off a toast that is closing (`root`): to the next toast, else the previous, else back. */
|
|
100
|
+
focusAfterClose(root: HTMLElement): void;
|
|
101
|
+
/** Removes every listener and the live regions. */
|
|
102
|
+
stop(): void;
|
|
103
|
+
}
|
|
104
|
+
interface ToastViewportWatchOptions {
|
|
105
|
+
/** The stack expands while the pointer is over it or the keyboard is in it. */
|
|
106
|
+
onExpandedChange: (expanded: boolean) => void;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Watches a toast Viewport (spec/toast.md, "Viewport", "Announcements", "Pausing"): the F6
|
|
110
|
+
* landmark (F6 focuses the viewport, F6 or Shift+Tab from it go back where focus was), the
|
|
111
|
+
* pauses (the pointer over it, the keyboard in it, a hidden page), and the announcements: two
|
|
112
|
+
* live regions inside it, polite and assertive, that hold the title and description of every
|
|
113
|
+
* shown toast by its priority, inserted in the order they show. It holds no component state:
|
|
114
|
+
* the queue (`manager`) holds the toasts, the component the expanded state it reports.
|
|
115
|
+
*/
|
|
116
|
+
declare function watchToastViewport<Data>(viewport: HTMLElement, manager: ToastManager<Data>, options: ToastViewportWatchOptions): ToastViewportWatch;
|
|
117
|
+
export { ToastManagerOptions as a, ToastPriority as c, createToastManager as d, measureToastHeight as f, ToastManager as i, ToastPromiseOptions as l, ToastViewportWatchOptions as n, ToastObject as o, watchToastViewport as r, ToastOptions as s, ToastViewportWatch as t, ToastUpdate as u };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface DelayGroup {
|
|
2
|
+
/** Whether a member opening now skips its delay: one is open, or one closed within `timeout`. */
|
|
3
|
+
isInstant(now?: number): boolean;
|
|
4
|
+
/** A member opened; the previously open one is asked to close (`close` is how). */
|
|
5
|
+
opened(close: () => void): void;
|
|
6
|
+
/** A member closed (`close` is the callback it registered). */
|
|
7
|
+
closed(close: () => void, now?: number): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The coordination of a tooltip delay group (spec/tooltip.md, "Delay group"): at most one member
|
|
11
|
+
* open, and the instant hand-off. It knows the open member's close callback and the time of the
|
|
12
|
+
* last close, never a member's open state: each member keeps its own and reports here.
|
|
13
|
+
*
|
|
14
|
+
* `timeout` may be a getter, read at each check: a provider whose timeout changes keeps one group
|
|
15
|
+
* (and its open member) instead of making a new one.
|
|
16
|
+
*/
|
|
17
|
+
declare function createDelayGroup(options: {
|
|
18
|
+
timeout: number | (() => number);
|
|
19
|
+
}): DelayGroup;
|
|
20
|
+
interface HoverIntent {
|
|
21
|
+
/** Calls `open` after `delay` ms (at once for 0), cancelling a pending close. */
|
|
22
|
+
enter(delay: number): void;
|
|
23
|
+
/** Calls `close` after `delay` ms (at once for 0), cancelling a pending open. */
|
|
24
|
+
leave(delay: number): void;
|
|
25
|
+
/** Cancels whatever is pending. */
|
|
26
|
+
cancel(): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The timers of hover intent (spec/tooltip.md, "Pointer"): an open after a delay that a leave
|
|
30
|
+
* cancels, and a close after a delay that a return cancels. It holds no open state: `open` and
|
|
31
|
+
* `close` report to the framework, which decides.
|
|
32
|
+
*/
|
|
33
|
+
declare function createHoverIntent(callbacks: {
|
|
34
|
+
open: () => void;
|
|
35
|
+
close: () => void;
|
|
36
|
+
}): HoverIntent;
|
|
37
|
+
export { createDelayGroup as i, createHoverIntent as n, DelayGroup as r, HoverIntent as t };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
interface AutoRepeatOptions {
|
|
2
|
+
/**
|
|
3
|
+
* One step: at the press, then again every `interval` once the press lasted `delay`; a click
|
|
4
|
+
* that no pointer press started (the keyboard, assistive technology) steps once. Return
|
|
5
|
+
* `false` to stop the repeat (a bound reached).
|
|
6
|
+
*/
|
|
7
|
+
onStep: (event: Event) => boolean | undefined;
|
|
8
|
+
/** How long a press lasts before the repeat starts, in ms (default 400, Base UI). */
|
|
9
|
+
delay?: number;
|
|
10
|
+
/** The time between two repeated steps, in ms (default 60, Base UI). */
|
|
11
|
+
interval?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Press and hold on `element` (spec/number-field.md, "Pointer": an Increment or Decrement button):
|
|
15
|
+
* a primary pointer's press steps at once, and keeps stepping while it is held, until it is
|
|
16
|
+
* released, canceled or leaves the element, or the window loses focus. A mouse press keeps the
|
|
17
|
+
* focus where it is (its `mousedown` default is prevented), so the field's input stays focused. The `click`
|
|
18
|
+
* that ends a pointer press steps no more; any other click steps once. Returns the cleanup.
|
|
19
|
+
*/
|
|
20
|
+
declare function watchAutoRepeat(element: Element, options: AutoRepeatOptions): () => void;
|
|
21
|
+
/** How a number field writes and reads its value (spec/number-field.md, "API"). */
|
|
22
|
+
interface NumberFormatOptions {
|
|
23
|
+
/** The locale (BCP 47; default: the runtime's). */
|
|
24
|
+
locale?: string | undefined;
|
|
25
|
+
/** `Intl.NumberFormat` options; without them, the plain number with every decimal it has. */
|
|
26
|
+
format?: Intl.NumberFormatOptions | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The `Intl.NumberFormat` options a field formats with: `format`, else every decimal kept. */
|
|
29
|
+
declare function numberFormatOptions(format: Intl.NumberFormatOptions | undefined): Intl.NumberFormatOptions;
|
|
30
|
+
/**
|
|
31
|
+
* `value` as the field writes it (spec/number-field.md): `Intl.NumberFormat` of the locale and
|
|
32
|
+
* the format; `""` for `null` (an empty field).
|
|
33
|
+
*/
|
|
34
|
+
declare function formatNumber(value: number | null, options?: NumberFormatOptions): string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether `text` holds only what a number of this locale and format is written with (the
|
|
37
|
+
* localized digits, the group and decimal separators, the signs, the format's own text), so a
|
|
38
|
+
* field accepts it while it is typed (spec/number-field.md, "Typing"): `"1.2"`, `"-"` and `""`
|
|
39
|
+
* pass, `"12a"` does not.
|
|
40
|
+
*/
|
|
41
|
+
declare function isNumberText(text: string, options?: NumberFormatOptions): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The number `text` writes in this locale and format (spec/number-field.md, "Typing"): the
|
|
44
|
+
* localized digits (Arabic-Indic, ...), the group and decimal separators, any minus sign, the
|
|
45
|
+
* currency, unit and percent text; a percent format reads `25%` as `0.25`. `null` for a text with
|
|
46
|
+
* no digit (empty, or a sign alone), `NaN` for one that is no number (`1.2.3`, `12a`).
|
|
47
|
+
*/
|
|
48
|
+
declare function parseNumber(text: string, options?: NumberFormatOptions): number | null;
|
|
49
|
+
/** The bounds and grid a number field steps within (spec/number-field.md, "API"). */
|
|
50
|
+
interface NumberStepOptions {
|
|
51
|
+
/** The lowest value; none when not given. */
|
|
52
|
+
min?: number | undefined;
|
|
53
|
+
/** The highest value; none when not given. */
|
|
54
|
+
max?: number | undefined;
|
|
55
|
+
/** Step to the grid of `|amount|` (counted from `min`, else from 0) instead of by `amount`. */
|
|
56
|
+
snapOnStep?: boolean | undefined;
|
|
57
|
+
}
|
|
58
|
+
/** `value` within `[min, max]` (either bound may be missing). */
|
|
59
|
+
declare function clampNumber(value: number, min: number | undefined, max: number | undefined): number;
|
|
60
|
+
/**
|
|
61
|
+
* The value one step of `amount` away (negative: down), clamped to `[min, max]`
|
|
62
|
+
* (spec/number-field.md, "Stepping"). An empty field (`null`) starts at 0, clamped, with no step
|
|
63
|
+
* (Base UI). With `snapOnStep`, a value off the grid of `|amount|` goes to the next grid point in
|
|
64
|
+
* the step's direction (`1.5` up by 1 gives `2`, down gives `1`).
|
|
65
|
+
*/
|
|
66
|
+
declare function stepNumber(value: number | null, amount: number, options?: NumberStepOptions): number;
|
|
67
|
+
/** A point in the viewport, in CSS pixels. */
|
|
68
|
+
interface ScrubPoint {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
}
|
|
72
|
+
interface ScrubOptions {
|
|
73
|
+
/** The axis the pointer scrubs along (default `"horizontal"`). */
|
|
74
|
+
direction?: "horizontal" | "vertical";
|
|
75
|
+
/** The distance one step takes, in px (default 2, Base UI). */
|
|
76
|
+
pixelSensitivity?: number;
|
|
77
|
+
/** A press starts a scrub unless this returns `false` (a disabled or read-only field). */
|
|
78
|
+
onStart: (event: PointerEvent) => boolean | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* The pointer moved by `steps` sensitivities along the axis: right or up is positive. Called
|
|
81
|
+
* once per move that crosses at least one.
|
|
82
|
+
*/
|
|
83
|
+
onScrub: (steps: number, event: PointerEvent) => void;
|
|
84
|
+
/** The scrub ended: the pointer was released or canceled. */
|
|
85
|
+
onEnd: (event: PointerEvent) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Where the virtual cursor is while the pointer is locked (the real one is hidden), wrapped
|
|
88
|
+
* around the viewport's edges; `null` once it is unlocked or the scrub ended.
|
|
89
|
+
*/
|
|
90
|
+
onCursor?: (point: ScrubPoint | null) => void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Scrubbing on `element` (spec/number-field.md, "Scrub"): a primary pointer's press starts it,
|
|
94
|
+
* and every `pixelSensitivity` pixels of movement along `direction` is a step, until the pointer
|
|
95
|
+
* is released. A mouse asks for the pointer lock (the movement then never meets the screen's
|
|
96
|
+
* edges, and `onCursor` follows a virtual cursor); a denied lock only leaves the real cursor.
|
|
97
|
+
* The press's default is prevented, so no text is selected. Returns the cleanup.
|
|
98
|
+
*/
|
|
99
|
+
declare function watchScrub(element: Element, options: ScrubOptions): () => void;
|
|
100
|
+
export { clampNumber as a, parseNumber as c, numberFormatOptions as d, AutoRepeatOptions as f, NumberStepOptions as i, NumberFormatOptions as l, ScrubPoint as n, stepNumber as o, watchAutoRepeat as p, watchScrub as r, isNumberText as s, ScrubOptions as t, formatNumber as u };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface FocusTrapOptions {
|
|
2
|
+
/**
|
|
3
|
+
* A press outside `container` and `allow()` keeps focus where it is: its default focus change
|
|
4
|
+
* is prevented (an alert dialog, which an outside press never dismisses: spec/alert-dialog.md,
|
|
5
|
+
* "Focus").
|
|
6
|
+
*/
|
|
7
|
+
holdOutsidePress?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Keeps Tab and Shift+Tab inside `container` (spec/dialog.md, "Focus"), wrapping at its ends, and
|
|
11
|
+
* pulls focus back when it escapes (to an element outside `container` and outside `allow()`, the
|
|
12
|
+
* child layers). Returns the cleanup.
|
|
13
|
+
*/
|
|
14
|
+
declare function trapFocus(container: HTMLElement, allow?: () => readonly (Element | null | undefined)[], options?: FocusTrapOptions): () => void;
|
|
15
|
+
/** Focuses `initial`, else the first tabbable element of `container`, else `container`. */
|
|
16
|
+
declare function focusInitial(container: HTMLElement, initial?: HTMLElement | null): void;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the last focus in `doc` came from the keyboard (for overlays that highlight on keyboard
|
|
19
|
+
* open only). Each document is tracked on its own (an iframe's, a test's), from its first call.
|
|
20
|
+
*/
|
|
21
|
+
declare function isKeyboardModality(doc: Document): boolean;
|
|
22
|
+
/** The elements of `container` that Tab reaches, in tab order (positive tabindex first). */
|
|
23
|
+
declare function getTabbables(container: Element): HTMLElement[];
|
|
24
|
+
/** The first tabbable element of the document after `element` in tab order, outside `skip`. */
|
|
25
|
+
declare function nextTabbableAfter(element: Element, skip?: readonly (Element | null | undefined)[]): HTMLElement | null;
|
|
26
|
+
/** The last tabbable element of the document before `element` in tab order, outside `skip`. */
|
|
27
|
+
declare function previousTabbableBefore(element: Element, skip?: readonly (Element | null | undefined)[]): HTMLElement | null;
|
|
28
|
+
export { FocusTrapOptions as a, isKeyboardModality as i, nextTabbableAfter as n, focusInitial as o, previousTabbableBefore as r, trapFocus as s, getTabbables as t };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/** The color spaces of the color model (spec/color.md, "The value"). */
|
|
2
|
+
type ColorSpace = "rgb" | "hsl" | "hsb";
|
|
3
|
+
/** A color's channels: three per space, and the alpha every space has. */
|
|
4
|
+
type ColorChannel = "red" | "green" | "blue" | "hue" | "saturation" | "lightness" | "brightness" | "alpha";
|
|
5
|
+
/** sRGB: `red`, `green`, `blue` from 0 to 255 (whole numbers), `alpha` from 0 to 1. */
|
|
6
|
+
interface RgbColor {
|
|
7
|
+
readonly space: "rgb";
|
|
8
|
+
readonly red: number;
|
|
9
|
+
readonly green: number;
|
|
10
|
+
readonly blue: number;
|
|
11
|
+
readonly alpha: number;
|
|
12
|
+
}
|
|
13
|
+
/** HSL: `hue` from 0 to 360 (degrees), `saturation` and `lightness` from 0 to 100 (percent). */
|
|
14
|
+
interface HslColor {
|
|
15
|
+
readonly space: "hsl";
|
|
16
|
+
readonly hue: number;
|
|
17
|
+
readonly saturation: number;
|
|
18
|
+
readonly lightness: number;
|
|
19
|
+
readonly alpha: number;
|
|
20
|
+
}
|
|
21
|
+
/** HSB (HSV): `hue` from 0 to 360, `saturation` and `brightness` from 0 to 100. */
|
|
22
|
+
interface HsbColor {
|
|
23
|
+
readonly space: "hsb";
|
|
24
|
+
readonly hue: number;
|
|
25
|
+
readonly saturation: number;
|
|
26
|
+
readonly brightness: number;
|
|
27
|
+
readonly alpha: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* An immutable color value (spec/color.md): a plain object in one space, which every function
|
|
31
|
+
* of the model returns anew and never changes.
|
|
32
|
+
*/
|
|
33
|
+
type Color = RgbColor | HslColor | HsbColor;
|
|
34
|
+
/** A channel's bounds and steps (spec/color.md, "Channels"). */
|
|
35
|
+
interface ColorChannelRange {
|
|
36
|
+
min: number;
|
|
37
|
+
max: number;
|
|
38
|
+
/** The arrows' step. */
|
|
39
|
+
step: number;
|
|
40
|
+
/** Page Up / Page Down and Shift with an arrow. */
|
|
41
|
+
largeStep: number;
|
|
42
|
+
}
|
|
43
|
+
/** A channel's bounds and steps. */
|
|
44
|
+
declare function colorChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
45
|
+
/** The three color channels of a space, in order (alpha, which every space has, aside). */
|
|
46
|
+
declare function colorChannels(space: ColorSpace): readonly [ColorChannel, ColorChannel, ColorChannel];
|
|
47
|
+
/** Whether `channel` is one of `space`'s (alpha is every space's). */
|
|
48
|
+
declare function hasColorChannel(space: ColorSpace, channel: ColorChannel): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The space a control edits `channel` in (spec/color.md, "Channels"): `preferred` (the control's
|
|
51
|
+
* `colorSpace`) when given, else the value's own space when it has the channel, else the
|
|
52
|
+
* channel's own space (`red`, `green`, `blue`: rgb; `lightness`: hsl; `hue`, `saturation`,
|
|
53
|
+
* `brightness`: hsb).
|
|
54
|
+
*/
|
|
55
|
+
declare function colorSpaceFor(channel: ColorChannel, color: Color, preferred?: ColorSpace): ColorSpace;
|
|
56
|
+
/** A channel's value. `channel` must be one of the color's space (else a `RangeError`). */
|
|
57
|
+
declare function getColorChannel(color: Color, channel: ColorChannel): number;
|
|
58
|
+
/** `value` clamped to the channel's bounds. */
|
|
59
|
+
declare function clampColorChannel(channel: ColorChannel, value: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* A new color with `channel` set to `value`, clamped to its bounds. `channel` must be one of the
|
|
62
|
+
* color's space (else a `RangeError`): convert the color first (`convertColor`).
|
|
63
|
+
*/
|
|
64
|
+
declare function setColorChannel(color: Color, channel: ColorChannel, value: number): Color;
|
|
65
|
+
/** Whether two colors are the same value: the same space and the same channels. */
|
|
66
|
+
declare function isSameColor(a: Color | null | undefined, b: Color | null | undefined): boolean;
|
|
67
|
+
/** The space and the two channels of a ColorArea (spec/color-area.md, "API"). */
|
|
68
|
+
interface ColorAreaChannels {
|
|
69
|
+
space: ColorSpace;
|
|
70
|
+
xChannel: ColorChannel;
|
|
71
|
+
yChannel: ColorChannel;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A ColorArea's space and channels: `colorSpace`, else the value's own space when it has both
|
|
75
|
+
* given channels, else the space of the more specific channel (lightness: hsl; brightness: hsb;
|
|
76
|
+
* red, green, blue: rgb; else hsb); the channels not given are the space's defaults (rgb: red and
|
|
77
|
+
* green; hsl: saturation and lightness; hsb: saturation and brightness).
|
|
78
|
+
*/
|
|
79
|
+
declare function colorAreaChannels(color: Color, options?: {
|
|
80
|
+
xChannel?: ColorChannel | undefined;
|
|
81
|
+
yChannel?: ColorChannel | undefined;
|
|
82
|
+
colorSpace?: ColorSpace | undefined;
|
|
83
|
+
}): ColorAreaChannels;
|
|
84
|
+
/** A CSS gradient direction: a slider's from its `min` to its `max`. */
|
|
85
|
+
type ColorGradientDirection = "to right" | "to left" | "to top" | "to bottom";
|
|
86
|
+
/**
|
|
87
|
+
* The CSS `linear-gradient` of a slider's track (spec/color.md, "Gradients"): `channel` from its
|
|
88
|
+
* `min` to its `max` along `direction`, the color's other channels kept, except the hue track,
|
|
89
|
+
* which shows every hue at full saturation (and, in hsb, full brightness; in hsl, 50% lightness).
|
|
90
|
+
* Every stop is a linear ramp in sRGB, so the gradient is exact. The alpha track keeps the
|
|
91
|
+
* color's other channels, opaque at its end.
|
|
92
|
+
*/
|
|
93
|
+
declare function colorChannelGradient(color: Color, channel: ColorChannel, direction?: ColorGradientDirection): string;
|
|
94
|
+
/** A ColorArea's background: its layers, and how they blend (`screen` for two rgb channels). */
|
|
95
|
+
interface ColorAreaBackground {
|
|
96
|
+
backgroundImage: string;
|
|
97
|
+
backgroundBlendMode: "normal" | "screen";
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A ColorArea's background (spec/color.md, "Gradients"): two gradient layers that give, at every
|
|
101
|
+
* point, the color with `xChannel` and `yChannel` at that point and its third channel kept, exactly
|
|
102
|
+
* (sRGB compositing): two rgb channels add up through `screen`; a lightness or brightness axis is
|
|
103
|
+
* a black (and white) layer over the other channel's ramp; a saturation axis beside a hue axis
|
|
104
|
+
* fades the hue ramp to gray. `x` runs from the inline start (`rtl`: from the right), `y` from
|
|
105
|
+
* the bottom. The channels are two different color channels of the color's space (no alpha).
|
|
106
|
+
*/
|
|
107
|
+
declare function colorAreaBackground(color: Color, xChannel: ColorChannel, yChannel: ColorChannel, rtl?: boolean): ColorAreaBackground;
|
|
108
|
+
/**
|
|
109
|
+
* A ColorWheel's track (spec/color.md, "Gradients"): every hue at full saturation, from 0° at the
|
|
110
|
+
* top, clockwise (the `conic-gradient`'s own start and direction).
|
|
111
|
+
*/
|
|
112
|
+
declare function colorWheelGradient(): string;
|
|
113
|
+
interface ColorAreaKeyOptions {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
xRange: ColorChannelRange;
|
|
117
|
+
yRange: ColorChannelRange;
|
|
118
|
+
rtl: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The axis and value a key moves a ColorArea's thumb to (spec/color-area.md, "Keyboard"), before
|
|
122
|
+
* snapping and clamping; `null` when the key does not move it. ArrowLeft and ArrowRight move `x`
|
|
123
|
+
* (swapped in RTL), ArrowUp and ArrowDown `y`, with Shift by the large step; Page Up and Page
|
|
124
|
+
* Down move `y` by its large step; Home and End set `x` to its `min` and `max`.
|
|
125
|
+
*/
|
|
126
|
+
declare function colorAreaKeyTarget(key: string, shiftKey: boolean, options: ColorAreaKeyOptions): {
|
|
127
|
+
axis: "x" | "y";
|
|
128
|
+
value: number;
|
|
129
|
+
} | null;
|
|
130
|
+
/** `hue` turned into `[0, 360)`, with the hue's step precision (whole degrees by default). */
|
|
131
|
+
declare function wrapHue(hue: number, step?: number): number;
|
|
132
|
+
/**
|
|
133
|
+
* The hue a key moves a ColorWheel to (spec/color-wheel.md, "Keyboard"), wrapped into `[0, 360)`;
|
|
134
|
+
* `null` when the key does not move it. ArrowRight and ArrowUp increase it by `step` (Shift: by
|
|
135
|
+
* `largeStep`), ArrowLeft and ArrowDown decrease it; Page Up and Page Down by `largeStep`; Home
|
|
136
|
+
* sets 0 and End the last step before 360.
|
|
137
|
+
*/
|
|
138
|
+
declare function colorWheelKeyTarget(key: string, shiftKey: boolean, hue: number, step?: number, largeStep?: number): number | null;
|
|
139
|
+
/** A box and a point, as `getBoundingClientRect()` and a pointer event give them. */
|
|
140
|
+
interface Box {
|
|
141
|
+
left: number;
|
|
142
|
+
top: number;
|
|
143
|
+
width: number;
|
|
144
|
+
height: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The hue at a point of a ColorWheel (spec/color-wheel.md, "Pointer"): its angle around the box's
|
|
148
|
+
* centre, 0° at the top, clockwise, in `[0, 360)`.
|
|
149
|
+
*/
|
|
150
|
+
declare function hueAtPoint(box: Box, point: {
|
|
151
|
+
x: number;
|
|
152
|
+
y: number;
|
|
153
|
+
}): number;
|
|
154
|
+
/** Whether a point lies on a ColorWheel's ring: between the inner and the outer radius (px). */
|
|
155
|
+
declare function isOnColorWheel(box: Box, point: {
|
|
156
|
+
x: number;
|
|
157
|
+
y: number;
|
|
158
|
+
}, innerRadius: number, outerRadius: number): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Where a ColorWheel's thumb sits for `hue`: its offset (px) from the wheel's centre, on the
|
|
161
|
+
* circle of `radius` (the ring's middle), 0° at the top, clockwise.
|
|
162
|
+
*/
|
|
163
|
+
declare function colorWheelThumbOffset(hue: number, radius: number): {
|
|
164
|
+
x: number;
|
|
165
|
+
y: number;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* `color` in `space` (spec/color.md, "Conversion"): the same object when it already is in it;
|
|
169
|
+
* hsl and hsb convert directly (the hue kept), the others through rgb. Each converted channel is
|
|
170
|
+
* rounded to its precision.
|
|
171
|
+
*/
|
|
172
|
+
declare function convertColor(color: Color, space: ColorSpace): Color;
|
|
173
|
+
/** Whether `element`'s window has the EyeDropper API (spec/color-picker.md, "EyeDropperTrigger"). */
|
|
174
|
+
declare function supportsEyeDropper(element: Element): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Opens the browser's eyedropper from `element`'s window and resolves with the color the user
|
|
177
|
+
* picked (an opaque rgb color), or `null` when the user cancelled it (Escape), the browser refused
|
|
178
|
+
* it or has no EyeDropper API. It never rejects: a cancelled pick is no error for a picker.
|
|
179
|
+
*/
|
|
180
|
+
declare function openEyeDropper(element: Element, signal?: AbortSignal): Promise<Color | null>;
|
|
181
|
+
/**
|
|
182
|
+
* How `formatColor` writes a color (spec/color.md, "Formatting"). `hex` writes `#rrggbb`, and
|
|
183
|
+
* `#rrggbbaa` when the alpha is below 1 (nothing is lost); `hexa` always the eight digits; `css`
|
|
184
|
+
* the color's own function (`rgb()`, `hsl()`; hsb, which CSS has not, as `hsl()`), with its alpha
|
|
185
|
+
* when below 1.
|
|
186
|
+
*/
|
|
187
|
+
type ColorFormat = "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "hsb" | "hsba" | "css";
|
|
188
|
+
/** `color` as text, lower-case hex or a CSS function with commas (`rgb(255, 0, 0)`). */
|
|
189
|
+
declare function formatColor(color: Color, format?: ColorFormat): string;
|
|
190
|
+
/**
|
|
191
|
+
* The `Intl.NumberFormat` options a channel's value is written with (spec/color.md, "Channel
|
|
192
|
+
* text"), and the scale its value is multiplied by first: hue in degrees (`unit: "degree"`),
|
|
193
|
+
* saturation, lightness, brightness and alpha as percents, red, green and blue as whole numbers.
|
|
194
|
+
* The digits follow the channel's step.
|
|
195
|
+
*/
|
|
196
|
+
declare function colorChannelFormat(channel: ColorChannel): {
|
|
197
|
+
format: Intl.NumberFormatOptions;
|
|
198
|
+
scale: number;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* A channel's value as text for `locale` (BCP 47; default: the runtime's), through `Intl`: `"120°"`,
|
|
202
|
+
* `"50%"` (`"50 %"` in de-DE), `"128"`. A value given wins over the color's.
|
|
203
|
+
*/
|
|
204
|
+
declare function formatColorChannel(color: Color, channel: ColorChannel, locale?: string, value?: number): string;
|
|
205
|
+
/**
|
|
206
|
+
* A color from its text (spec/color.md, "Parsing"): hex (`#rgb`, `#rgba`, `#rrggbb`,
|
|
207
|
+
* `#rrggbbaa`, the `#` optional), `rgb()` / `rgba()`, `hsl()` / `hsla()` and `hsb()` / `hsba()`
|
|
208
|
+
* with commas or spaces (`/` before the alpha); `null` when it is none of them. A color given is
|
|
209
|
+
* returned as it is, so a component can take a `Color` or a string.
|
|
210
|
+
*/
|
|
211
|
+
declare function parseColor(value: string | Color): Color | null;
|
|
212
|
+
export { colorAreaChannels as A, ColorChannel as C, HslColor as D, HsbColor as E, hasColorChannel as F, isSameColor as I, setColorChannel as L, colorChannels as M, colorSpaceFor as N, RgbColor as O, getColorChannel as P, ColorAreaChannels as S, ColorSpace as T, ColorGradientDirection as _, formatColorChannel as a, colorWheelGradient as b, convertColor as c, isOnColorWheel as d, ColorAreaKeyOptions as f, ColorAreaBackground as g, wrapHue as h, formatColor as i, colorChannelRange as j, clampColorChannel as k, colorWheelThumbOffset as l, colorWheelKeyTarget as m, ColorFormat as n, openEyeDropper as o, colorAreaKeyTarget as p, colorChannelFormat as r, supportsEyeDropper as s, parseColor as t, hueAtPoint as u, colorAreaBackground as v, ColorChannelRange as w, Color as x, colorChannelGradient as y };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The index of the item a key highlights among `count` shown items, from `current` (-1: none):
|
|
3
|
+
* ArrowDown / ArrowUp the next / previous (wrapping with `loop`), Home / End the first / last;
|
|
4
|
+
* `null` for any other key (and Home / End with Shift, which stay native).
|
|
5
|
+
*/
|
|
6
|
+
declare function commandKeyTarget(event: Pick<KeyboardEvent, "key" | "shiftKey" | "altKey" | "ctrlKey" | "metaKey">, current: number, count: number, loop?: boolean): number | null;
|
|
7
|
+
/** An item's score for the typed text: `0` hides it. */
|
|
8
|
+
type CommandFilter = (value: string, search: string, keywords: readonly string[]) => number;
|
|
9
|
+
/**
|
|
10
|
+
* The default scorer: the whole text `1`, a prefix `0.9`, a word's prefix `0.8`, every search
|
|
11
|
+
* word starting a word in order `0.7`, a substring `0.6`, else `0`; a keyword's score is
|
|
12
|
+
* `0.95` of the same match on the value. An empty search scores `1`.
|
|
13
|
+
*/
|
|
14
|
+
declare function commandScore(value: string, search: string, keywords?: readonly string[]): number;
|
|
15
|
+
/** An item's score as a Command shows it: forced items and an empty search or no filter, `1`. */
|
|
16
|
+
declare function commandItemScore(value: string, search: string, keywords: readonly string[], filter: CommandFilter | null, forceMount?: boolean): number;
|
|
17
|
+
/** An entry of a list the toolkit filters (a virtual Command list's `items`). */
|
|
18
|
+
interface CommandEntry {
|
|
19
|
+
value: string;
|
|
20
|
+
keywords?: readonly string[];
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface CommandMatches<Entry> {
|
|
24
|
+
/** The matching entries, in their order. */
|
|
25
|
+
entries: Entry[];
|
|
26
|
+
/** Each matching entry's score. */
|
|
27
|
+
scores: number[];
|
|
28
|
+
}
|
|
29
|
+
/** The entries matching the search, in order, with their scores. */
|
|
30
|
+
declare function commandMatches<Entry extends CommandEntry>(entries: readonly Entry[], search: string, filter: CommandFilter | null): CommandMatches<Entry>;
|
|
31
|
+
/** The index of the best-scoring enabled entry (the first among equals), or `-1`. */
|
|
32
|
+
declare function bestMatch(scores: readonly number[], disabled?: (index: number) => boolean): number;
|
|
33
|
+
export { commandItemScore as a, commandKeyTarget as c, bestMatch as i, CommandFilter as n, commandMatches as o, CommandMatches as r, commandScore as s, CommandEntry as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes `text` into a live region (`aria-live`, rendered empty with the page, so a screen reader
|
|
3
|
+
* follows it before anything is announced; spec/clipboard.md, "Announcements"). The region's
|
|
4
|
+
* content is replaced by a new text node every time, so the same text said twice is announced
|
|
5
|
+
* twice (Toast's live regions append a new node per toast, `/toast`); `""` empties it. The
|
|
6
|
+
* framework renders the region with no children, so it never reconciles this text.
|
|
7
|
+
*/
|
|
8
|
+
declare function announceText(region: HTMLElement, text: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Writes `text` to the system clipboard of `element`'s window (spec/clipboard.md, "Copying"):
|
|
11
|
+
* the asynchronous Clipboard API (`navigator.clipboard.writeText`), which needs a secure context
|
|
12
|
+
* and, in some browsers, the `clipboard-write` permission or a user activation. There is no
|
|
13
|
+
* `execCommand("copy")` fallback: where the API is missing (an insecure context, an old browser)
|
|
14
|
+
* the promise rejects, as it does when the browser refuses the write, and the component reports
|
|
15
|
+
* the failure (its `failed` status) and selects its Input's text, so the user can copy it by hand.
|
|
16
|
+
*/
|
|
17
|
+
declare function writeClipboard(element: Element, text: string): Promise<void>;
|
|
18
|
+
export { announceText as n, writeClipboard as t };
|