@ac-kit/ui-common 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +244 -0
- package/LICENSE +28 -0
- package/README.md +633 -2
- package/dist/anchored/anchored.d.ts +19 -0
- package/dist/anchored/anchored.d.ts.map +1 -0
- package/dist/anchored/anchored.js +2 -0
- package/dist/anchored/anchored.js.map +1 -0
- package/dist/button/button.d.ts +35 -0
- package/dist/button/button.d.ts.map +1 -0
- package/dist/button/button.js +22 -0
- package/dist/button/button.js.map +1 -0
- package/dist/dialog/dialog.d.ts +33 -0
- package/dist/dialog/dialog.d.ts.map +1 -0
- package/dist/dialog/dialog.js +23 -0
- package/dist/dialog/dialog.js.map +1 -0
- package/dist/focus/owns-arrow-keys.d.ts +31 -0
- package/dist/focus/owns-arrow-keys.d.ts.map +1 -0
- package/dist/focus/owns-arrow-keys.js +64 -0
- package/dist/focus/owns-arrow-keys.js.map +1 -0
- package/dist/focus/roving-focus.d.ts +34 -0
- package/dist/focus/roving-focus.d.ts.map +1 -0
- package/dist/focus/roving-focus.js +72 -0
- package/dist/focus/roving-focus.js.map +1 -0
- package/dist/focus/typeahead.d.ts +112 -0
- package/dist/focus/typeahead.d.ts.map +1 -0
- package/dist/focus/typeahead.js +178 -0
- package/dist/focus/typeahead.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/knob/knob.d.ts +106 -0
- package/dist/knob/knob.d.ts.map +1 -0
- package/dist/knob/knob.js +116 -0
- package/dist/knob/knob.js.map +1 -0
- package/dist/menu/menu.d.ts +157 -0
- package/dist/menu/menu.d.ts.map +1 -0
- package/dist/menu/menu.js +162 -0
- package/dist/menu/menu.js.map +1 -0
- package/dist/meter/meter.d.ts +63 -0
- package/dist/meter/meter.d.ts.map +1 -0
- package/dist/meter/meter.js +57 -0
- package/dist/meter/meter.js.map +1 -0
- package/dist/preact/_anchor.d.ts +13 -0
- package/dist/preact/_anchor.d.ts.map +1 -0
- package/dist/preact/_anchor.js +39 -0
- package/dist/preact/_anchor.js.map +1 -0
- package/dist/preact/_dom.d.ts +14 -0
- package/dist/preact/_dom.d.ts.map +1 -0
- package/dist/preact/_dom.js +31 -0
- package/dist/preact/_dom.js.map +1 -0
- package/dist/preact/_live-announcer.d.ts +26 -0
- package/dist/preact/_live-announcer.d.ts.map +1 -0
- package/dist/preact/_live-announcer.js +101 -0
- package/dist/preact/_live-announcer.js.map +1 -0
- package/dist/preact/button.d.ts +40 -0
- package/dist/preact/button.d.ts.map +1 -0
- package/dist/preact/button.js +22 -0
- package/dist/preact/button.js.map +1 -0
- package/dist/preact/dialog.d.ts +43 -0
- package/dist/preact/dialog.d.ts.map +1 -0
- package/dist/preact/dialog.js +89 -0
- package/dist/preact/dialog.js.map +1 -0
- package/dist/preact/index.d.ts +20 -0
- package/dist/preact/index.d.ts.map +1 -0
- package/dist/preact/index.js +20 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/preact/join-classes.d.ts +10 -0
- package/dist/preact/join-classes.d.ts.map +1 -0
- package/dist/preact/join-classes.js +12 -0
- package/dist/preact/join-classes.js.map +1 -0
- package/dist/preact/knob.d.ts +51 -0
- package/dist/preact/knob.d.ts.map +1 -0
- package/dist/preact/knob.js +144 -0
- package/dist/preact/knob.js.map +1 -0
- package/dist/preact/menu-button.d.ts +117 -0
- package/dist/preact/menu-button.d.ts.map +1 -0
- package/dist/preact/menu-button.js +330 -0
- package/dist/preact/menu-button.js.map +1 -0
- package/dist/preact/meter.d.ts +34 -0
- package/dist/preact/meter.d.ts.map +1 -0
- package/dist/preact/meter.js +21 -0
- package/dist/preact/meter.js.map +1 -0
- package/dist/preact/progress-ring.d.ts +42 -0
- package/dist/preact/progress-ring.d.ts.map +1 -0
- package/dist/preact/progress-ring.js +26 -0
- package/dist/preact/progress-ring.js.map +1 -0
- package/dist/preact/radio-group.d.ts +50 -0
- package/dist/preact/radio-group.d.ts.map +1 -0
- package/dist/preact/radio-group.js +42 -0
- package/dist/preact/radio-group.js.map +1 -0
- package/dist/preact/readout.d.ts +22 -0
- package/dist/preact/readout.d.ts.map +1 -0
- package/dist/preact/readout.js +13 -0
- package/dist/preact/readout.js.map +1 -0
- package/dist/preact/slider.d.ts +40 -0
- package/dist/preact/slider.d.ts.map +1 -0
- package/dist/preact/slider.js +164 -0
- package/dist/preact/slider.js.map +1 -0
- package/dist/preact/spin-button.d.ts +67 -0
- package/dist/preact/spin-button.d.ts.map +1 -0
- package/dist/preact/spin-button.js +132 -0
- package/dist/preact/spin-button.js.map +1 -0
- package/dist/preact/switch.d.ts +25 -0
- package/dist/preact/switch.d.ts.map +1 -0
- package/dist/preact/switch.js +19 -0
- package/dist/preact/switch.js.map +1 -0
- package/dist/preact/tabs.d.ts +97 -0
- package/dist/preact/tabs.d.ts.map +1 -0
- package/dist/preact/tabs.js +264 -0
- package/dist/preact/tabs.js.map +1 -0
- package/dist/preact/toaster.d.ts +43 -0
- package/dist/preact/toaster.d.ts.map +1 -0
- package/dist/preact/toaster.js +356 -0
- package/dist/preact/toaster.js.map +1 -0
- package/dist/preact/toggle-button.d.ts +26 -0
- package/dist/preact/toggle-button.d.ts.map +1 -0
- package/dist/preact/toggle-button.js +16 -0
- package/dist/preact/toggle-button.js.map +1 -0
- package/dist/preact/toolbar.d.ts +24 -0
- package/dist/preact/toolbar.d.ts.map +1 -0
- package/dist/preact/toolbar.js +142 -0
- package/dist/preact/toolbar.js.map +1 -0
- package/dist/preact/tooltip.d.ts +67 -0
- package/dist/preact/tooltip.d.ts.map +1 -0
- package/dist/preact/tooltip.js +165 -0
- package/dist/preact/tooltip.js.map +1 -0
- package/dist/preact/tree.d.ts +93 -0
- package/dist/preact/tree.d.ts.map +1 -0
- package/dist/preact/tree.js +399 -0
- package/dist/preact/tree.js.map +1 -0
- package/dist/preact/use-element-binding.d.ts +32 -0
- package/dist/preact/use-element-binding.d.ts.map +1 -0
- package/dist/preact/use-element-binding.js +51 -0
- package/dist/preact/use-element-binding.js.map +1 -0
- package/dist/progress/progress.d.ts +51 -0
- package/dist/progress/progress.d.ts.map +1 -0
- package/dist/progress/progress.js +43 -0
- package/dist/progress/progress.js.map +1 -0
- package/dist/readout/readout.d.ts +41 -0
- package/dist/readout/readout.d.ts.map +1 -0
- package/dist/readout/readout.js +26 -0
- package/dist/readout/readout.js.map +1 -0
- package/dist/slider/_clamped-value.d.ts +7 -0
- package/dist/slider/_clamped-value.d.ts.map +1 -0
- package/dist/slider/_clamped-value.js +9 -0
- package/dist/slider/_clamped-value.js.map +1 -0
- package/dist/slider/slider-attributes.d.ts +50 -0
- package/dist/slider/slider-attributes.d.ts.map +1 -0
- package/dist/slider/slider-attributes.js +38 -0
- package/dist/slider/slider-attributes.js.map +1 -0
- package/dist/slider/slider-range.d.ts +59 -0
- package/dist/slider/slider-range.d.ts.map +1 -0
- package/dist/slider/slider-range.js +73 -0
- package/dist/slider/slider-range.js.map +1 -0
- package/dist/slider/slider-track.d.ts +37 -0
- package/dist/slider/slider-track.d.ts.map +1 -0
- package/dist/slider/slider-track.js +35 -0
- package/dist/slider/slider-track.js.map +1 -0
- package/dist/slider/stepped-value.d.ts +31 -0
- package/dist/slider/stepped-value.d.ts.map +1 -0
- package/dist/slider/stepped-value.js +55 -0
- package/dist/slider/stepped-value.js.map +1 -0
- package/dist/spin-button/spin-button.d.ts +110 -0
- package/dist/spin-button/spin-button.d.ts.map +1 -0
- package/dist/spin-button/spin-button.js +179 -0
- package/dist/spin-button/spin-button.js.map +1 -0
- package/dist/switch/switch.d.ts +30 -0
- package/dist/switch/switch.d.ts.map +1 -0
- package/dist/switch/switch.js +26 -0
- package/dist/switch/switch.js.map +1 -0
- package/dist/tabs/tabs.d.ts +157 -0
- package/dist/tabs/tabs.d.ts.map +1 -0
- package/dist/tabs/tabs.js +120 -0
- package/dist/tabs/tabs.js.map +1 -0
- package/dist/toast/toast-queue.d.ts +212 -0
- package/dist/toast/toast-queue.d.ts.map +1 -0
- package/dist/toast/toast-queue.js +290 -0
- package/dist/toast/toast-queue.js.map +1 -0
- package/dist/toast/toasts-obscure.d.ts +25 -0
- package/dist/toast/toasts-obscure.d.ts.map +1 -0
- package/dist/toast/toasts-obscure.js +30 -0
- package/dist/toast/toasts-obscure.js.map +1 -0
- package/dist/toggle-button/toggle-button.d.ts +44 -0
- package/dist/toggle-button/toggle-button.d.ts.map +1 -0
- package/dist/toggle-button/toggle-button.js +31 -0
- package/dist/toggle-button/toggle-button.js.map +1 -0
- package/dist/tone.d.ts +8 -0
- package/dist/tone.d.ts.map +1 -0
- package/dist/tone.js +2 -0
- package/dist/tone.js.map +1 -0
- package/dist/toolbar/toolbar.d.ts +35 -0
- package/dist/toolbar/toolbar.d.ts.map +1 -0
- package/dist/toolbar/toolbar.js +23 -0
- package/dist/toolbar/toolbar.js.map +1 -0
- package/dist/tooltip/tooltip.d.ts +183 -0
- package/dist/tooltip/tooltip.d.ts.map +1 -0
- package/dist/tooltip/tooltip.js +185 -0
- package/dist/tooltip/tooltip.js.map +1 -0
- package/dist/tree/tree.d.ts +302 -0
- package/dist/tree/tree.d.ts.map +1 -0
- package/dist/tree/tree.js +439 -0
- package/dist/tree/tree.js.map +1 -0
- package/package.json +110 -3
- package/styles.css +1883 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The side of its anchor a popover sits on, in logical terms: `block-end` is
|
|
3
|
+
* below in a horizontal writing mode, `inline-end` after it in the reading
|
|
4
|
+
* direction (right in a left-to-right page). It moves to the opposite side when
|
|
5
|
+
* the viewport has no room for it.
|
|
6
|
+
*/
|
|
7
|
+
export type AnchoredSide = "block-start" | "block-end" | "inline-start" | "inline-end";
|
|
8
|
+
/**
|
|
9
|
+
* How a popover lines up with its anchor along that side: its start edges
|
|
10
|
+
* together, centred, or its end edges together. It shifts into the viewport
|
|
11
|
+
* when it would overflow it.
|
|
12
|
+
*/
|
|
13
|
+
export type AnchoredAlign = "start" | "center" | "end";
|
|
14
|
+
/** The attributes the stylesheet places an anchored popover by. */
|
|
15
|
+
export type AnchoredAttributes = {
|
|
16
|
+
"data-side": AnchoredSide;
|
|
17
|
+
"data-align": AnchoredAlign;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=anchored.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchored.d.ts","sourceRoot":"","sources":["../../src/anchored/anchored.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACrB,aAAa,GACb,WAAW,GACX,cAAc,GACd,YAAY,CAAC;AAEhB;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEvD,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG;IAChC,WAAW,EAAE,YAAY,CAAC;IAC1B,YAAY,EAAE,aAAa,CAAC;CAC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchored.js","sourceRoot":"","sources":["../../src/anchored/anchored.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ControlTone } from "../tone.js";
|
|
2
|
+
/** How prominent a button is: the main action, a secondary one, or a bare one. */
|
|
3
|
+
export type ButtonVariant = "primary" | "secondary" | "ghost";
|
|
4
|
+
/** A button's size: `large` for a main action on a touch screen. */
|
|
5
|
+
export type ButtonSize = "regular" | "large";
|
|
6
|
+
/**
|
|
7
|
+
* The attributes of a button, keyed by their HTML attribute names: the variant,
|
|
8
|
+
* size and tone the stylesheet draws it by. `data-size` is present for `large`
|
|
9
|
+
* only.
|
|
10
|
+
*/
|
|
11
|
+
export type ButtonAttributes = {
|
|
12
|
+
"data-variant": ButtonVariant;
|
|
13
|
+
"data-size"?: "large";
|
|
14
|
+
"data-tone"?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Input of {@link buttonAttributes}. */
|
|
17
|
+
export type ButtonAttributesInput = {
|
|
18
|
+
/** Defaults to `secondary`. */
|
|
19
|
+
variant?: ButtonVariant;
|
|
20
|
+
/** Defaults to `regular`. */
|
|
21
|
+
size?: ButtonSize;
|
|
22
|
+
tone?: ControlTone;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The attributes of a push button (WAI-ARIA button pattern), for a native
|
|
26
|
+
* `<button>` whose role, focus and activation the browser provides.
|
|
27
|
+
*
|
|
28
|
+
* Time complexity: O(1). Memory: O(1).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* buttonAttributes({ variant: "primary", size: "large" });
|
|
32
|
+
* // { "data-variant": "primary", "data-size": "large" }
|
|
33
|
+
*/
|
|
34
|
+
export declare function buttonAttributes(input?: ButtonAttributesInput): ButtonAttributes;
|
|
35
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,kFAAkF;AAClF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAE7C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,cAAc,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,yCAAyC;AACzC,MAAM,MAAM,qBAAqB,GAAG;IACnC,+BAA+B;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,GAAE,qBAA0B,GAC/B,gBAAgB,CAWlB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attributes of a push button (WAI-ARIA button pattern), for a native
|
|
3
|
+
* `<button>` whose role, focus and activation the browser provides.
|
|
4
|
+
*
|
|
5
|
+
* Time complexity: O(1). Memory: O(1).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* buttonAttributes({ variant: "primary", size: "large" });
|
|
9
|
+
* // { "data-variant": "primary", "data-size": "large" }
|
|
10
|
+
*/
|
|
11
|
+
export function buttonAttributes(input = {}) {
|
|
12
|
+
const { variant = "secondary", size = "regular", tone } = input;
|
|
13
|
+
const attributes = { "data-variant": variant };
|
|
14
|
+
if (size === "large") {
|
|
15
|
+
attributes["data-size"] = "large";
|
|
16
|
+
}
|
|
17
|
+
if (tone !== undefined) {
|
|
18
|
+
attributes["data-tone"] = tone;
|
|
19
|
+
}
|
|
20
|
+
return attributes;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/button/button.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAK,GAA0B,EAAE;IAEjC,MAAM,EAAE,OAAO,GAAG,WAAW,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAChE,MAAM,UAAU,GAAqB,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;IACjE,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACtB,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;IACnC,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a dialog sits: centred, along the bottom edge, along the inline end, or
|
|
3
|
+
* a sheet (the bottom when narrow, the side when wide).
|
|
4
|
+
*/
|
|
5
|
+
export type DialogPlacement = "center" | "bottom" | "side" | "sheet";
|
|
6
|
+
/** The attributes of a dialog, keyed by their HTML attribute names. */
|
|
7
|
+
export type DialogAttributes = {
|
|
8
|
+
"aria-labelledby": string;
|
|
9
|
+
"aria-describedby"?: string;
|
|
10
|
+
"data-placement": DialogPlacement;
|
|
11
|
+
};
|
|
12
|
+
/** Input of {@link dialogAttributes}. */
|
|
13
|
+
export type DialogAttributesInput = {
|
|
14
|
+
/** The id of the element holding the title. */
|
|
15
|
+
titleId: string;
|
|
16
|
+
/** The id of the element holding the description, when there is one. */
|
|
17
|
+
descriptionId?: string;
|
|
18
|
+
/** Defaults to `center`. */
|
|
19
|
+
placement?: DialogPlacement;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The attributes of a modal dialog (WAI-ARIA dialog pattern), for a native
|
|
23
|
+
* `<dialog>` opened with `showModal()`, whose role, inert page, Escape key and
|
|
24
|
+
* focus return the browser provides.
|
|
25
|
+
*
|
|
26
|
+
* Time complexity: O(1). Memory: O(1).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* dialogAttributes({ titleId: "t", placement: "sheet" });
|
|
30
|
+
* // { "aria-labelledby": "t", "data-placement": "sheet" }
|
|
31
|
+
*/
|
|
32
|
+
export declare function dialogAttributes(input: DialogAttributesInput): DialogAttributes;
|
|
33
|
+
//# sourceMappingURL=dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAErE,uEAAuE;AACvE,MAAM,MAAM,gBAAgB,GAAG;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,eAAe,CAAC;CAClC,CAAC;AAEF,yCAAyC;AACzC,MAAM,MAAM,qBAAqB,GAAG;IACnC,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,eAAe,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,qBAAqB,GAC1B,gBAAgB,CAWlB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attributes of a modal dialog (WAI-ARIA dialog pattern), for a native
|
|
3
|
+
* `<dialog>` opened with `showModal()`, whose role, inert page, Escape key and
|
|
4
|
+
* focus return the browser provides.
|
|
5
|
+
*
|
|
6
|
+
* Time complexity: O(1). Memory: O(1).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* dialogAttributes({ titleId: "t", placement: "sheet" });
|
|
10
|
+
* // { "aria-labelledby": "t", "data-placement": "sheet" }
|
|
11
|
+
*/
|
|
12
|
+
export function dialogAttributes(input) {
|
|
13
|
+
const { titleId, descriptionId, placement = "center" } = input;
|
|
14
|
+
const attributes = {
|
|
15
|
+
"aria-labelledby": titleId,
|
|
16
|
+
"data-placement": placement,
|
|
17
|
+
};
|
|
18
|
+
if (descriptionId !== undefined) {
|
|
19
|
+
attributes["aria-describedby"] = descriptionId;
|
|
20
|
+
}
|
|
21
|
+
return attributes;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAA4B;IAE5B,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC/D,MAAM,UAAU,GAAqB;QACpC,iBAAiB,EAAE,OAAO;QAC1B,gBAAgB,EAAE,SAAS;KAC3B,CAAC;IACF,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QACjC,UAAU,CAAC,kBAAkB,CAAC,GAAG,aAAa,CAAC;IAChD,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What {@link ownsArrowKeys} reads of an element: plain data, so the core needs
|
|
3
|
+
* no DOM.
|
|
4
|
+
*/
|
|
5
|
+
export type ArrowKeyOwnerInput = {
|
|
6
|
+
/** Lower-case tag name: `input`, `textarea`, `select`, `div`, … */
|
|
7
|
+
readonly tagName: string;
|
|
8
|
+
/** An `<input>`'s `type`. */
|
|
9
|
+
readonly type?: string;
|
|
10
|
+
/** The explicit `role` attribute. */
|
|
11
|
+
readonly role?: string;
|
|
12
|
+
readonly isContentEditable?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Whether an element uses the arrow keys itself, so a container's roving focus
|
|
16
|
+
* must leave them to it: text-entry inputs (`text`, `search`, `email`, `url`,
|
|
17
|
+
* `tel`, `password`, `number`, the date and time types), `range`, `radio`,
|
|
18
|
+
* `<textarea>`, `<select>`, editable content, and the roles `slider`,
|
|
19
|
+
* `spinbutton`, `radio`, `radiogroup`, `combobox`, `listbox`, `menu`,
|
|
20
|
+
* `menubar`, `tablist`, `tree`, `treegrid`, `grid`, `textbox`. An `<input>`
|
|
21
|
+
* with no `type` is a text input.
|
|
22
|
+
*
|
|
23
|
+
* Time complexity: O(1). Memory: O(1).
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ownsArrowKeys({ tagName: "input", type: "range" }); // true
|
|
27
|
+
* ownsArrowKeys({ tagName: "button" }); // false
|
|
28
|
+
* ownsArrowKeys({ tagName: "div", role: "slider" }); // true
|
|
29
|
+
*/
|
|
30
|
+
export declare function ownsArrowKeys(input: ArrowKeyOwnerInput): boolean;
|
|
31
|
+
//# sourceMappingURL=owns-arrow-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owns-arrow-keys.d.ts","sourceRoot":"","sources":["../../src/focus/owns-arrow-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAmCF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAkBhE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const ARROW_INPUT_TYPES_ = new Set([
|
|
2
|
+
"text",
|
|
3
|
+
"search",
|
|
4
|
+
"email",
|
|
5
|
+
"url",
|
|
6
|
+
"tel",
|
|
7
|
+
"password",
|
|
8
|
+
"number",
|
|
9
|
+
"date",
|
|
10
|
+
"datetime-local",
|
|
11
|
+
"month",
|
|
12
|
+
"time",
|
|
13
|
+
"week",
|
|
14
|
+
"range",
|
|
15
|
+
"radio",
|
|
16
|
+
]);
|
|
17
|
+
const ARROW_ROLES_ = new Set([
|
|
18
|
+
"slider",
|
|
19
|
+
"spinbutton",
|
|
20
|
+
"radio",
|
|
21
|
+
"radiogroup",
|
|
22
|
+
"combobox",
|
|
23
|
+
"listbox",
|
|
24
|
+
"menu",
|
|
25
|
+
"menubar",
|
|
26
|
+
"tablist",
|
|
27
|
+
"tree",
|
|
28
|
+
"treegrid",
|
|
29
|
+
"grid",
|
|
30
|
+
"textbox",
|
|
31
|
+
]);
|
|
32
|
+
/**
|
|
33
|
+
* Whether an element uses the arrow keys itself, so a container's roving focus
|
|
34
|
+
* must leave them to it: text-entry inputs (`text`, `search`, `email`, `url`,
|
|
35
|
+
* `tel`, `password`, `number`, the date and time types), `range`, `radio`,
|
|
36
|
+
* `<textarea>`, `<select>`, editable content, and the roles `slider`,
|
|
37
|
+
* `spinbutton`, `radio`, `radiogroup`, `combobox`, `listbox`, `menu`,
|
|
38
|
+
* `menubar`, `tablist`, `tree`, `treegrid`, `grid`, `textbox`. An `<input>`
|
|
39
|
+
* with no `type` is a text input.
|
|
40
|
+
*
|
|
41
|
+
* Time complexity: O(1). Memory: O(1).
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ownsArrowKeys({ tagName: "input", type: "range" }); // true
|
|
45
|
+
* ownsArrowKeys({ tagName: "button" }); // false
|
|
46
|
+
* ownsArrowKeys({ tagName: "div", role: "slider" }); // true
|
|
47
|
+
*/
|
|
48
|
+
export function ownsArrowKeys(input) {
|
|
49
|
+
if (input.isContentEditable === true) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (input.role !== undefined && ARROW_ROLES_.has(input.role.toLowerCase())) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
const tagName = input.tagName.toLowerCase();
|
|
56
|
+
if (tagName === "textarea" || tagName === "select") {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return (tagName === "input" &&
|
|
60
|
+
(input.type === undefined ||
|
|
61
|
+
input.type === "" ||
|
|
62
|
+
ARROW_INPUT_TYPES_.has(input.type.toLowerCase())));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=owns-arrow-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owns-arrow-keys.js","sourceRoot":"","sources":["../../src/focus/owns-arrow-keys.ts"],"names":[],"mappings":"AAcA,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACvD,MAAM;IACN,QAAQ;IACR,OAAO;IACP,KAAK;IACL,KAAK;IACL,UAAU;IACV,QAAQ;IACR,MAAM;IACN,gBAAgB;IAChB,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;CACP,CAAC,CAAC;AAEH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IACjD,QAAQ;IACR,YAAY;IACZ,OAAO;IACP,YAAY;IACZ,UAAU;IACV,SAAS;IACT,MAAM;IACN,SAAS;IACT,SAAS;IACT,MAAM;IACN,UAAU;IACV,MAAM;IACN,SAAS;CACT,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACtD,IAAI,KAAK,CAAC,iBAAiB,KAAK,IAAI,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QAC5E,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,CACN,OAAO,KAAK,OAAO;QACnB,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;YACxB,KAAK,CAAC,IAAI,KAAK,EAAE;YACjB,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAClD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Predicate } from "@ac-kit/core";
|
|
2
|
+
/** Options of {@link rovingFocusIndex}. */
|
|
3
|
+
export type RovingFocusOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Which arrows move: Left and Right, Up and Down, or all four. Defaults to
|
|
6
|
+
* `horizontal`.
|
|
7
|
+
*/
|
|
8
|
+
readonly orientation?: "horizontal" | "vertical" | "both";
|
|
9
|
+
/** Past an end, go round. Defaults to true. */
|
|
10
|
+
readonly wrap?: boolean;
|
|
11
|
+
/** `rtl` swaps Left and Right. Defaults to `ltr`. */
|
|
12
|
+
readonly direction?: "ltr" | "rtl";
|
|
13
|
+
/** Items focus skips. Defaults to none. */
|
|
14
|
+
readonly isDisabled?: Predicate<[index: number]>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The item a key moves focus to among `count` items, per the WAI-ARIA
|
|
18
|
+
* roving-tabindex practice: arrows to the previous or next enabled item, Home
|
|
19
|
+
* and End to the first and last enabled one. `undefined` for another key, when
|
|
20
|
+
* no item is enabled, or when `wrap` is false and no enabled item lies that
|
|
21
|
+
* way.
|
|
22
|
+
*
|
|
23
|
+
* Time complexity: O(count) at worst, skipping disabled items. Memory: O(1).
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* rovingFocusIndex(2, "ArrowRight", 3); // 0
|
|
27
|
+
* rovingFocusIndex(0, "End", 3); // 2
|
|
28
|
+
* rovingFocusIndex(0, "ArrowDown", 3); // undefined: not a horizontal key
|
|
29
|
+
*
|
|
30
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
31
|
+
* `current` is outside [0, count).
|
|
32
|
+
*/
|
|
33
|
+
export declare function rovingFocusIndex(current: number, key: string, count: number, options?: RovingFocusOptions): number | undefined;
|
|
34
|
+
//# sourceMappingURL=roving-focus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roving-focus.d.ts","sourceRoot":"","sources":["../../src/focus/roving-focus.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,cAAc,CAAC;AAEtB,2CAA2C;AAC3C,MAAM,MAAM,kBAAkB,GAAG;IAChC;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;IAC1D,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACnC,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,kBAAuB,GAC9B,MAAM,GAAG,SAAS,CAgEpB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { describeValue, isIntegerInRange, modEuclid, } from "@ac-kit/core";
|
|
2
|
+
/**
|
|
3
|
+
* The item a key moves focus to among `count` items, per the WAI-ARIA
|
|
4
|
+
* roving-tabindex practice: arrows to the previous or next enabled item, Home
|
|
5
|
+
* and End to the first and last enabled one. `undefined` for another key, when
|
|
6
|
+
* no item is enabled, or when `wrap` is false and no enabled item lies that
|
|
7
|
+
* way.
|
|
8
|
+
*
|
|
9
|
+
* Time complexity: O(count) at worst, skipping disabled items. Memory: O(1).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* rovingFocusIndex(2, "ArrowRight", 3); // 0
|
|
13
|
+
* rovingFocusIndex(0, "End", 3); // 2
|
|
14
|
+
* rovingFocusIndex(0, "ArrowDown", 3); // undefined: not a horizontal key
|
|
15
|
+
*
|
|
16
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
17
|
+
* `current` is outside [0, count).
|
|
18
|
+
*/
|
|
19
|
+
export function rovingFocusIndex(current, key, count, options = {}) {
|
|
20
|
+
if (!isIntegerInRange(count, 0, Number.MAX_SAFE_INTEGER + 1)) {
|
|
21
|
+
throw new RangeError(`count must be a non-negative safe integer, got ${describeValue(count)}`);
|
|
22
|
+
}
|
|
23
|
+
if (!isIntegerInRange(current, 0, count)) {
|
|
24
|
+
throw new RangeError(`current must be an integer in [0, ${String(count)}), got ${describeValue(current)}`);
|
|
25
|
+
}
|
|
26
|
+
const { orientation = "horizontal", wrap = true, direction = "ltr", isDisabled, } = options;
|
|
27
|
+
let step;
|
|
28
|
+
let from;
|
|
29
|
+
switch (key) {
|
|
30
|
+
case "Home":
|
|
31
|
+
step = 1;
|
|
32
|
+
from = -1;
|
|
33
|
+
break;
|
|
34
|
+
case "End":
|
|
35
|
+
step = -1;
|
|
36
|
+
from = count;
|
|
37
|
+
break;
|
|
38
|
+
case "ArrowLeft":
|
|
39
|
+
case "ArrowRight": {
|
|
40
|
+
if (orientation === "vertical") {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const isForward = (key === "ArrowRight") === (direction === "ltr");
|
|
44
|
+
step = isForward ? 1 : -1;
|
|
45
|
+
from = current;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "ArrowUp":
|
|
49
|
+
case "ArrowDown":
|
|
50
|
+
if (orientation === "horizontal") {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
step = key === "ArrowDown" ? 1 : -1;
|
|
54
|
+
from = current;
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const isEdgeKey = key === "Home" || key === "End";
|
|
60
|
+
for (let visited = 0; visited < count; visited += 1) {
|
|
61
|
+
const next = modEuclid(from + step, count);
|
|
62
|
+
if (!wrap && !isEdgeKey && (from + step < 0 || from + step >= count)) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
if (isDisabled?.(next) !== true) {
|
|
66
|
+
return next;
|
|
67
|
+
}
|
|
68
|
+
from = next;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=roving-focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roving-focus.js","sourceRoot":"","sources":["../../src/focus/roving-focus.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,gBAAgB,EAChB,SAAS,GAET,MAAM,cAAc,CAAC;AAiBtB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC/B,OAAe,EACf,GAAW,EACX,KAAa,EACb,OAAO,GAAuB,EAAE;IAEhC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,UAAU,CACnB,kDAAkD,aAAa,CAAC,KAAK,CAAC,EAAE,CACxE,CAAC;IACH,CAAC;IACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,UAAU,CACnB,qCAAqC,MAAM,CAAC,KAAK,CAAC,UAAU,aAAa,CAAC,OAAO,CAAC,EAAE,CACpF,CAAC;IACH,CAAC;IACD,MAAM,EACL,WAAW,GAAG,YAAY,EAC1B,IAAI,GAAG,IAAI,EACX,SAAS,GAAG,KAAK,EACjB,UAAU,GACV,GAAG,OAAO,CAAC;IAEZ,IAAI,IAAY,CAAC;IACjB,IAAI,IAAY,CAAC;IACjB,QAAQ,GAAG,EAAE,CAAC;QACb,KAAK,MAAM;YACV,IAAI,GAAG,CAAC,CAAC;YACT,IAAI,GAAG,CAAC,CAAC,CAAC;YACV,MAAM;QACP,KAAK,KAAK;YACT,IAAI,GAAG,CAAC,CAAC,CAAC;YACV,IAAI,GAAG,KAAK,CAAC;YACb,MAAM;QACP,KAAK,WAAW,CAAC;QACjB,KAAK,YAAY,EAAE,CAAC;YACnB,IAAI,WAAW,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,SAAS,GAAG,CAAC,GAAG,KAAK,YAAY,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC;YACnE,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,GAAG,OAAO,CAAC;YACf,MAAM;QACP,CAAC;QACD,KAAK,SAAS,CAAC;QACf,KAAK,WAAW;YACf,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;gBAClC,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,IAAI,GAAG,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,GAAG,OAAO,CAAC;YACf,MAAM;QACP;YACC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,KAAK,CAAC;IAClD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,KAAK,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACtE,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,GAAG,IAAI,CAAC;IACb,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type Predicate } from "@ac-kit/core";
|
|
2
|
+
import type { KeyInput } from "@ac-kit/ui-gesture";
|
|
3
|
+
/** Options of {@link Typeahead}. */
|
|
4
|
+
export type TypeaheadOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* How long after a character the next one still extends the query, in ms.
|
|
7
|
+
* Defaults to 500, as the WAI-ARIA practices suggest.
|
|
8
|
+
*/
|
|
9
|
+
readonly timeoutMs?: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The query a person types into a list to reach an item by its name (the
|
|
13
|
+
* WAI-ARIA typeahead of menus, listboxes and trees): the characters typed
|
|
14
|
+
* within `timeoutMs` of each other. Every time is passed in, in ms.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const typeahead = new Typeahead();
|
|
18
|
+
* typeahead.type("c", 0); // "c"
|
|
19
|
+
* typeahead.type("h", 200); // "ch"
|
|
20
|
+
* typeahead.type("a", 900); // "a": the query timed out
|
|
21
|
+
*/
|
|
22
|
+
export declare class Typeahead {
|
|
23
|
+
private readonly timeoutMs_;
|
|
24
|
+
private query_;
|
|
25
|
+
private lastTime_;
|
|
26
|
+
/** @throws {RangeError} When `timeoutMs` is negative or not finite. */
|
|
27
|
+
constructor(options?: TypeaheadOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Whether a query is in progress at `time`: a character was typed less than
|
|
30
|
+
* `timeoutMs` before. A list lets Space extend the query then, rather than
|
|
31
|
+
* activate an item.
|
|
32
|
+
*/
|
|
33
|
+
isActive(time: number): boolean;
|
|
34
|
+
/** Adds `character`, typed at `time`, and returns the query to look up. */
|
|
35
|
+
type(character: string, time: number): string;
|
|
36
|
+
/** Forgets the query: the list closed, or an item was chosen. */
|
|
37
|
+
reset(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Adds `character`, typed at `time`, and returns the item the query reaches
|
|
40
|
+
* among `labels` from `current` ({@link typeaheadIndex}): what a list does
|
|
41
|
+
* with each character typed.
|
|
42
|
+
*
|
|
43
|
+
* Time complexity: O(n · q), n labels and q graphemes in the query. Memory:
|
|
44
|
+
* O(q).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const typeahead = new Typeahead();
|
|
48
|
+
* typeahead.find("b", 0, ["Apple", "Banana", "Blueberry"], 0); // 1
|
|
49
|
+
* typeahead.find("l", 100, ["Apple", "Banana", "Blueberry"], 1); // 2
|
|
50
|
+
*
|
|
51
|
+
* @throws {RangeError} When `current` is not an index of `labels`.
|
|
52
|
+
*/
|
|
53
|
+
find(character: string, time: number, labels: readonly string[], current: number | undefined, options?: TypeaheadIndexOptions): number | undefined;
|
|
54
|
+
}
|
|
55
|
+
/** Options of {@link typeaheadIndex}. */
|
|
56
|
+
export type TypeaheadIndexOptions = {
|
|
57
|
+
/** The locales whose collation compares names. Defaults to the runtime's. */
|
|
58
|
+
readonly locales?: Intl.LocalesArgument;
|
|
59
|
+
/** Items the query skips. Defaults to none. */
|
|
60
|
+
readonly isDisabled?: Predicate<[index: number]>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The item a typeahead query moves to among `labels`, per the WAI-ARIA
|
|
64
|
+
* practices: the next item after `current` whose name starts with a single
|
|
65
|
+
* character, going round, so typing it again cycles through those items (a
|
|
66
|
+
* repeated character, `"aaa"`, cycles likewise); for a longer query, the first
|
|
67
|
+
* from `current` on whose name starts with it, so the item stays while it
|
|
68
|
+
* matches. Without `current`, the search starts at the first item.
|
|
69
|
+
*
|
|
70
|
+
* Names are compared grapheme by grapheme, ignoring case and accents as the
|
|
71
|
+
* locale's collation does (`sensitivity: "base"`) and leading white space.
|
|
72
|
+
* `undefined` for an empty query or when no enabled item matches.
|
|
73
|
+
*
|
|
74
|
+
* Time complexity: O(n · q), n labels and q graphemes in the query. Memory:
|
|
75
|
+
* O(q).
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* typeaheadIndex(["Apple", "Apricot", "Banana"], 0, "a"); // 1
|
|
79
|
+
* typeaheadIndex(["Apple", "Apricot", "Banana"], 0, "apr"); // 1
|
|
80
|
+
* typeaheadIndex(["Éclair", "Fig"], 1, "e"); // 0
|
|
81
|
+
*
|
|
82
|
+
* @throws {RangeError} When `current` is not an index of `labels`.
|
|
83
|
+
*/
|
|
84
|
+
export declare function typeaheadIndex(labels: readonly string[], current: number | undefined, query: string, options?: TypeaheadIndexOptions): number | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Whether a key types a character a typeahead takes: one grapheme, not a
|
|
87
|
+
* control character, without Ctrl, Alt or Meta (the browser's and the system's
|
|
88
|
+
* shortcuts). Shift passes, for capitals; so does Space, which a list takes as
|
|
89
|
+
* part of a query in progress only (see {@link Typeahead.isActive}).
|
|
90
|
+
*
|
|
91
|
+
* Time complexity: O(1) for a key name of bounded length. Memory: O(1).
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* isTypeaheadKey({ key: "a" }); // true
|
|
95
|
+
* isTypeaheadKey({ key: "Enter" }); // false: a named key
|
|
96
|
+
* isTypeaheadKey({ key: "s", ctrlKey: true }); // false: a shortcut
|
|
97
|
+
*/
|
|
98
|
+
export declare function isTypeaheadKey(input: KeyInput): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* The character a key adds to a list's typeahead query: a typed character
|
|
101
|
+
* ({@link isTypeaheadKey}), Space only while a query is in progress (otherwise
|
|
102
|
+
* Space selects or activates an item). `undefined` for any other key.
|
|
103
|
+
*
|
|
104
|
+
* Time complexity: O(1) for a key name of bounded length. Memory: O(1).
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* typeaheadCharacter({ key: "a" }, false); // "a"
|
|
108
|
+
* typeaheadCharacter({ key: " " }, false); // undefined: Space selects
|
|
109
|
+
* typeaheadCharacter({ key: " " }, true); // " ": "new y" goes on
|
|
110
|
+
*/
|
|
111
|
+
export declare function typeaheadCharacter(input: KeyInput, isTypingAhead: boolean): string | undefined;
|
|
112
|
+
//# sourceMappingURL=typeahead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeahead.d.ts","sourceRoot":"","sources":["../../src/focus/typeahead.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,oCAAoC;AACpC,MAAM,MAAM,gBAAgB,GAAG;IAC9B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,SAAS,CAA4B;IAE7C,uEAAuE;IACvE,YAAY,OAAO,GAAE,gBAAqB,EAIzC;IAED;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9B;IAED,2EAA2E;IAC3E,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAK5C;IAED,iEAAiE;IACjE,KAAK,IAAI,IAAI,CAGZ;IAED;;;;;;;;;;;;;;OAcG;IACH,IAAI,CACH,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,CAAC,EAAE,qBAAqB,GAC7B,MAAM,GAAG,SAAS,CAEpB;CACD;AAED,yCAAyC;AACzC,MAAM,MAAM,qBAAqB,GAAG;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC;IACxC,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,qBAA0B,GACjC,MAAM,GAAG,SAAS,CA4CpB;AAsBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAiBvD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,QAAQ,EACf,aAAa,EAAE,OAAO,GACpB,MAAM,GAAG,SAAS,CAMpB"}
|