@ember-joinery/test-support 0.0.0-stage → 1.0.1
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 +550 -0
- package/LICENSE.md +9 -0
- package/NOTICE +532 -0
- package/README.md +356 -2
- package/addon-main.cjs +4 -0
- package/dist/-private/checkable.d.ts +21 -0
- package/dist/-private/checkable.d.ts.map +1 -0
- package/dist/-private/checkable.js +80 -0
- package/dist/-private/control.d.ts +18 -0
- package/dist/-private/control.d.ts.map +1 -0
- package/dist/-private/control.js +55 -0
- package/dist/-private/menu.d.ts +145 -0
- package/dist/-private/menu.d.ts.map +1 -0
- package/dist/-private/menu.js +322 -0
- package/dist/-private/overlay.d.ts +9 -0
- package/dist/-private/overlay.d.ts.map +1 -0
- package/dist/-private/overlay.js +39 -0
- package/dist/-private/showing.d.ts +7 -0
- package/dist/-private/showing.d.ts.map +1 -0
- package/dist/-private/showing.js +10 -0
- package/dist/-private/size.d.ts +10 -0
- package/dist/-private/size.d.ts.map +1 -0
- package/dist/-private/size.js +24 -0
- package/dist/-private/tree.d.ts +34 -0
- package/dist/-private/tree.d.ts.map +1 -0
- package/dist/-private/tree.js +80 -0
- package/dist/accordion.d.ts +62 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +112 -0
- package/dist/alert-dialog.d.ts +24 -0
- package/dist/alert-dialog.d.ts.map +1 -0
- package/dist/alert-dialog.js +37 -0
- package/dist/alert.d.ts +27 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +43 -0
- package/dist/aspect-ratio.d.ts +21 -0
- package/dist/aspect-ratio.d.ts.map +1 -0
- package/dist/aspect-ratio.js +30 -0
- package/dist/attachment.d.ts +86 -0
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +156 -0
- package/dist/avatar.d.ts +65 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +106 -0
- package/dist/badge.d.ts +29 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +49 -0
- package/dist/breadcrumb.d.ts +36 -0
- package/dist/breadcrumb.d.ts.map +1 -0
- package/dist/breadcrumb.js +80 -0
- package/dist/bubble.d.ts +56 -0
- package/dist/bubble.d.ts.map +1 -0
- package/dist/bubble.js +94 -0
- package/dist/button-group.d.ts +34 -0
- package/dist/button-group.d.ts.map +1 -0
- package/dist/button-group.js +62 -0
- package/dist/button.d.ts +37 -0
- package/dist/button.d.ts.map +1 -0
- package/dist/button.js +77 -0
- package/dist/calendar.d.ts +115 -0
- package/dist/calendar.d.ts.map +1 -0
- package/dist/calendar.js +276 -0
- package/dist/card.d.ts +31 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +49 -0
- package/dist/checkbox.d.ts +46 -0
- package/dist/checkbox.d.ts.map +1 -0
- package/dist/checkbox.js +84 -0
- package/dist/child.d.ts +29 -0
- package/dist/child.d.ts.map +1 -0
- package/dist/child.js +27 -0
- package/dist/collapsible.d.ts +44 -0
- package/dist/collapsible.d.ts.map +1 -0
- package/dist/collapsible.js +83 -0
- package/dist/color-scheme.d.ts +44 -0
- package/dist/color-scheme.d.ts.map +1 -0
- package/dist/color-scheme.js +123 -0
- package/dist/combobox.d.ts +114 -0
- package/dist/combobox.d.ts.map +1 -0
- package/dist/combobox.js +293 -0
- package/dist/command.d.ts +92 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +183 -0
- package/dist/context-menu.d.ts +37 -0
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/context-menu.js +59 -0
- package/dist/date-picker.d.ts +48 -0
- package/dist/date-picker.d.ts.map +1 -0
- package/dist/date-picker.js +136 -0
- package/dist/dialog.d.ts +64 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +142 -0
- package/dist/drawer.d.ts +63 -0
- package/dist/drawer.d.ts.map +1 -0
- package/dist/drawer.js +136 -0
- package/dist/dropdown-menu.d.ts +35 -0
- package/dist/dropdown-menu.d.ts.map +1 -0
- package/dist/dropdown-menu.js +49 -0
- package/dist/empty.d.ts +29 -0
- package/dist/empty.d.ts.map +1 -0
- package/dist/empty.js +47 -0
- package/dist/field.d.ts +86 -0
- package/dist/field.d.ts.map +1 -0
- package/dist/field.js +150 -0
- package/dist/file-drop.d.ts +74 -0
- package/dist/file-drop.d.ts.map +1 -0
- package/dist/file-drop.js +137 -0
- package/dist/focus.d.ts +54 -0
- package/dist/focus.d.ts.map +1 -0
- package/dist/focus.js +174 -0
- package/dist/harness.d.ts +90 -0
- package/dist/harness.d.ts.map +1 -0
- package/dist/harness.js +189 -0
- package/dist/heading.d.ts +16 -0
- package/dist/heading.d.ts.map +1 -0
- package/dist/heading.js +19 -0
- package/dist/hero.d.ts +21 -0
- package/dist/hero.d.ts.map +1 -0
- package/dist/hero.js +28 -0
- package/dist/hover-card.d.ts +46 -0
- package/dist/hover-card.d.ts.map +1 -0
- package/dist/hover-card.js +85 -0
- package/dist/icon.d.ts +10 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +13 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/dist/input-group.d.ts +55 -0
- package/dist/input-group.d.ts.map +1 -0
- package/dist/input-group.js +103 -0
- package/dist/input-otp.d.ts +103 -0
- package/dist/input-otp.d.ts.map +1 -0
- package/dist/input-otp.js +293 -0
- package/dist/input.d.ts +53 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +90 -0
- package/dist/item.d.ts +63 -0
- package/dist/item.d.ts.map +1 -0
- package/dist/item.js +104 -0
- package/dist/kbd.d.ts +28 -0
- package/dist/kbd.d.ts.map +1 -0
- package/dist/kbd.js +36 -0
- package/dist/keys.d.ts +20 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +32 -0
- package/dist/label.d.ts +24 -0
- package/dist/label.d.ts.map +1 -0
- package/dist/label.js +39 -0
- package/dist/layers.d.ts +42 -0
- package/dist/layers.d.ts.map +1 -0
- package/dist/layers.js +70 -0
- package/dist/link.d.ts +44 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +60 -0
- package/dist/marker.d.ts +42 -0
- package/dist/marker.d.ts.map +1 -0
- package/dist/marker.js +73 -0
- package/dist/menubar.d.ts +76 -0
- package/dist/menubar.d.ts.map +1 -0
- package/dist/menubar.js +139 -0
- package/dist/message-scroller.d.ts +101 -0
- package/dist/message-scroller.d.ts.map +1 -0
- package/dist/message-scroller.js +215 -0
- package/dist/message.d.ts +48 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +72 -0
- package/dist/native-form.d.ts +44 -0
- package/dist/native-form.d.ts.map +1 -0
- package/dist/native-form.js +111 -0
- package/dist/native-select.d.ts +56 -0
- package/dist/native-select.d.ts.map +1 -0
- package/dist/native-select.js +100 -0
- package/dist/navigation-menu.d.ts +97 -0
- package/dist/navigation-menu.d.ts.map +1 -0
- package/dist/navigation-menu.js +207 -0
- package/dist/observers.d.ts +21 -0
- package/dist/observers.d.ts.map +1 -0
- package/dist/observers.js +34 -0
- package/dist/pagination.d.ts +39 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +71 -0
- package/dist/pointer.d.ts +38 -0
- package/dist/pointer.d.ts.map +1 -0
- package/dist/pointer.js +82 -0
- package/dist/popover.d.ts +50 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +90 -0
- package/dist/progress.d.ts +38 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +81 -0
- package/dist/questionnaire.d.ts +117 -0
- package/dist/questionnaire.d.ts.map +1 -0
- package/dist/questionnaire.js +240 -0
- package/dist/radio-group.d.ts +53 -0
- package/dist/radio-group.d.ts.map +1 -0
- package/dist/radio-group.js +95 -0
- package/dist/rating.d.ts +67 -0
- package/dist/rating.d.ts.map +1 -0
- package/dist/rating.js +160 -0
- package/dist/resizable.d.ts +76 -0
- package/dist/resizable.d.ts.map +1 -0
- package/dist/resizable.js +138 -0
- package/dist/routing.d.ts +36 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +50 -0
- package/dist/roving-focus.d.ts +38 -0
- package/dist/roving-focus.d.ts.map +1 -0
- package/dist/roving-focus.js +60 -0
- package/dist/scroll-area.d.ts +58 -0
- package/dist/scroll-area.d.ts.map +1 -0
- package/dist/scroll-area.js +153 -0
- package/dist/scroller.d.ts +41 -0
- package/dist/scroller.d.ts.map +1 -0
- package/dist/scroller.js +65 -0
- package/dist/select.d.ts +98 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +203 -0
- package/dist/selectors.d.ts +44 -0
- package/dist/selectors.d.ts.map +1 -0
- package/dist/selectors.js +63 -0
- package/dist/send-pointer.d.ts +17 -0
- package/dist/send-pointer.d.ts.map +1 -0
- package/dist/send-pointer.js +35 -0
- package/dist/separator.d.ts +26 -0
- package/dist/separator.d.ts.map +1 -0
- package/dist/separator.js +40 -0
- package/dist/shadowed.d.ts +55 -0
- package/dist/shadowed.d.ts.map +1 -0
- package/dist/shadowed.js +97 -0
- package/dist/sheet.d.ts +14 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sheet.js +15 -0
- package/dist/sidebar.d.ts +159 -0
- package/dist/sidebar.d.ts.map +1 -0
- package/dist/sidebar.js +299 -0
- package/dist/skeleton.d.ts +18 -0
- package/dist/skeleton.d.ts.map +1 -0
- package/dist/skeleton.js +25 -0
- package/dist/slider.d.ts +66 -0
- package/dist/slider.d.ts.map +1 -0
- package/dist/slider.js +155 -0
- package/dist/spinner.d.ts +10 -0
- package/dist/spinner.d.ts.map +1 -0
- package/dist/spinner.js +13 -0
- package/dist/sticky-footer.d.ts +33 -0
- package/dist/sticky-footer.d.ts.map +1 -0
- package/dist/sticky-footer.js +65 -0
- package/dist/switch.d.ts +44 -0
- package/dist/switch.d.ts.map +1 -0
- package/dist/switch.js +77 -0
- package/dist/table.d.ts +41 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +100 -0
- package/dist/tabs.d.ts +66 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +149 -0
- package/dist/test-hooks.d.ts +9 -0
- package/dist/test-hooks.d.ts.map +1 -0
- package/dist/test-hooks.js +1 -0
- package/dist/textarea.d.ts +47 -0
- package/dist/textarea.d.ts.map +1 -0
- package/dist/textarea.js +78 -0
- package/dist/toaster.d.ts +172 -0
- package/dist/toaster.d.ts.map +1 -0
- package/dist/toaster.js +307 -0
- package/dist/toggle-group.d.ts +51 -0
- package/dist/toggle-group.d.ts.map +1 -0
- package/dist/toggle-group.js +97 -0
- package/dist/toggle.d.ts +21 -0
- package/dist/toggle.d.ts.map +1 -0
- package/dist/toggle.js +26 -0
- package/dist/tooltip.d.ts +48 -0
- package/dist/tooltip.d.ts.map +1 -0
- package/dist/tooltip.js +91 -0
- package/dist/trace.d.ts +118 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +196 -0
- package/dist/translator.d.ts +34 -0
- package/dist/translator.d.ts.map +1 -0
- package/dist/translator.js +75 -0
- package/dist/zoetrope.d.ts +51 -0
- package/dist/zoetrope.d.ts.map +1 -0
- package/dist/zoetrope.js +94 -0
- package/package.json +68 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
import { type KeyModifiers } from './focus.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Drives a `<RovingFocusGroup>` from `@ember-joinery/primitives/roving-focus`: items that share
|
|
5
|
+
* one tab stop, with the arrow keys, Home and End moving between them. Items are found by their
|
|
6
|
+
* `data-test-jn-value` (their `@tabStopId`).
|
|
7
|
+
*
|
|
8
|
+
* const toolbar = new RovingFocusGroupHarness('format')
|
|
9
|
+
* await toolbar.focus('bold')
|
|
10
|
+
* await toolbar.press('ArrowRight')
|
|
11
|
+
* assert.strictEqual(toolbar.focused, 'italic')
|
|
12
|
+
* assert.strictEqual(toolbar.tabStop, 'italic') // where Tab comes back to
|
|
13
|
+
*/
|
|
14
|
+
export declare class RovingFocusGroupHarness extends Harness {
|
|
15
|
+
static component: string;
|
|
16
|
+
/** Each item's element, in order. */
|
|
17
|
+
get items(): HTMLElement[];
|
|
18
|
+
/** Each item's id, in order. */
|
|
19
|
+
get ids(): string[];
|
|
20
|
+
/** The item with this id. Throws when there is none. */
|
|
21
|
+
item(id: string): HTMLElement;
|
|
22
|
+
/** `horizontal`, `vertical`, or `undefined` when every arrow key moves focus. */
|
|
23
|
+
get orientation(): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The id of the item in the tab order (`tabindex="0"`), which Tab lands on, or `null` when no
|
|
26
|
+
* item is: then the group itself takes the Tab and sends focus on to an item.
|
|
27
|
+
*/
|
|
28
|
+
get tabStop(): string | null;
|
|
29
|
+
/** Whether Tab stops on the group itself (`tabindex="0"`), on its way to an item. */
|
|
30
|
+
get isGroupTabbable(): boolean;
|
|
31
|
+
/** The id of the item that has focus, or `null` when focus is elsewhere. */
|
|
32
|
+
get focused(): string | null;
|
|
33
|
+
/** Focuses an item, as a click or a script would. */
|
|
34
|
+
focus(id: string): Promise<void>;
|
|
35
|
+
/** Presses a key on the focused item: `'ArrowRight'`, `'Home'`, `'End'`. */
|
|
36
|
+
press(key: string, modifiers?: KeyModifiers): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=roving-focus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roving-focus.d.ts","sourceRoot":"","sources":["../src/roving-focus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AAExD;;;;;;;;;;GAUG;AACH,qBAAa,uBAAwB,SAAQ,OAAO;IAClD,OAAgB,SAAS,SAAuB;IAEhD,qCAAqC;IACrC,IAAI,KAAK,IAAI,WAAW,EAAE,CAEzB;IAED,gCAAgC;IAChC,IAAI,GAAG,IAAI,MAAM,EAAE,CAElB;IAED,wDAAwD;IACxD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW;IAI7B,iFAAiF;IACjF,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAG3B;IAED,qFAAqF;IACrF,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,4EAA4E;IAC5E,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAI3B;IAED,qDAAqD;IAC/C,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC,4EAA4E;IACtE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { attributes } from "./selectors.js";
|
|
4
|
+
import { pressKey } from "./focus.js";
|
|
5
|
+
/**
|
|
6
|
+
* Drives a `<RovingFocusGroup>` from `@ember-joinery/primitives/roving-focus`: items that share
|
|
7
|
+
* one tab stop, with the arrow keys, Home and End moving between them. Items are found by their
|
|
8
|
+
* `data-test-jn-value` (their `@tabStopId`).
|
|
9
|
+
*
|
|
10
|
+
* const toolbar = new RovingFocusGroupHarness('format')
|
|
11
|
+
* await toolbar.focus('bold')
|
|
12
|
+
* await toolbar.press('ArrowRight')
|
|
13
|
+
* assert.strictEqual(toolbar.focused, 'italic')
|
|
14
|
+
* assert.strictEqual(toolbar.tabStop, 'italic') // where Tab comes back to
|
|
15
|
+
*/
|
|
16
|
+
export class RovingFocusGroupHarness extends Harness {
|
|
17
|
+
static component = 'roving-focus-group';
|
|
18
|
+
/** Each item's element, in order. */
|
|
19
|
+
get items() {
|
|
20
|
+
return this.parts('item');
|
|
21
|
+
}
|
|
22
|
+
/** Each item's id, in order. */
|
|
23
|
+
get ids() {
|
|
24
|
+
return this.values('item');
|
|
25
|
+
}
|
|
26
|
+
/** The item with this id. Throws when there is none. */
|
|
27
|
+
item(id) {
|
|
28
|
+
return this.part('item', id);
|
|
29
|
+
}
|
|
30
|
+
/** `horizontal`, `vertical`, or `undefined` when every arrow key moves focus. */
|
|
31
|
+
get orientation() {
|
|
32
|
+
return this.element.getAttribute('data-orientation') ?? undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The id of the item in the tab order (`tabindex="0"`), which Tab lands on, or `null` when no
|
|
36
|
+
* item is: then the group itself takes the Tab and sends focus on to an item.
|
|
37
|
+
*/
|
|
38
|
+
get tabStop() {
|
|
39
|
+
const item = this.items.find(element => element.getAttribute('tabindex') === '0');
|
|
40
|
+
return item?.getAttribute(attributes.value) ?? null;
|
|
41
|
+
}
|
|
42
|
+
/** Whether Tab stops on the group itself (`tabindex="0"`), on its way to an item. */
|
|
43
|
+
get isGroupTabbable() {
|
|
44
|
+
return this.element.getAttribute('tabindex') === '0';
|
|
45
|
+
}
|
|
46
|
+
/** The id of the item that has focus, or `null` when focus is elsewhere. */
|
|
47
|
+
get focused() {
|
|
48
|
+
const active = document.activeElement;
|
|
49
|
+
const item = this.items.find(element => element === active || element.contains(active));
|
|
50
|
+
return item?.getAttribute(attributes.value) ?? null;
|
|
51
|
+
}
|
|
52
|
+
/** Focuses an item, as a click or a script would. */
|
|
53
|
+
async focus(id) {
|
|
54
|
+
await focus(this.item(id));
|
|
55
|
+
}
|
|
56
|
+
/** Presses a key on the focused item: `'ArrowRight'`, `'Home'`, `'End'`. */
|
|
57
|
+
async press(key, modifiers) {
|
|
58
|
+
await pressKey(key, modifiers);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/** Which scrollbar: `vertical` (the default) or `horizontal`. */
|
|
3
|
+
export type ScrollbarOrientation = 'vertical' | 'horizontal';
|
|
4
|
+
/**
|
|
5
|
+
* Drives a scroll area: `<ScrollArea>` from `@ember-joinery/primitives/scroll-area`, or from
|
|
6
|
+
* `@ember-joinery/ember`. Its viewport scrolls natively; its scrollbars are parts that show for
|
|
7
|
+
* its `@type` (by default while the pointer is over it, so `hover()` first).
|
|
8
|
+
*
|
|
9
|
+
* const tags = new ScrollAreaHarness('tags')
|
|
10
|
+
* await tags.hover()
|
|
11
|
+
* assert.true(tags.isScrollbarVisible())
|
|
12
|
+
* await tags.scrollTo({ top: 200 })
|
|
13
|
+
* await tags.dragThumb('vertical', 40)
|
|
14
|
+
*/
|
|
15
|
+
export declare class ScrollAreaHarness extends Harness {
|
|
16
|
+
static component: string;
|
|
17
|
+
/** The element that scrolls. */
|
|
18
|
+
get viewport(): HTMLElement;
|
|
19
|
+
/** A scrollbar's element, or `null` while it isn't shown. */
|
|
20
|
+
scrollbar(orientation?: ScrollbarOrientation): HTMLElement | null;
|
|
21
|
+
/** A scrollbar's thumb, or `null` while it isn't shown. */
|
|
22
|
+
thumb(orientation?: ScrollbarOrientation): HTMLElement | null;
|
|
23
|
+
/** The corner between the scrollbars, or `null`. */
|
|
24
|
+
get corner(): HTMLElement | null;
|
|
25
|
+
/** Whether a scrollbar is shown now (rendered, with `data-state="visible"`). */
|
|
26
|
+
isScrollbarVisible(orientation?: ScrollbarOrientation): boolean;
|
|
27
|
+
/** How far the viewport is scrolled down, in pixels. */
|
|
28
|
+
get scrollTop(): number;
|
|
29
|
+
/** How far it is scrolled across, in pixels: negative right to left, as browsers give it. */
|
|
30
|
+
get scrollLeft(): number;
|
|
31
|
+
/** How far down it can scroll. */
|
|
32
|
+
get maxScrollTop(): number;
|
|
33
|
+
/** How far across it can scroll. */
|
|
34
|
+
get maxScrollLeft(): number;
|
|
35
|
+
/**
|
|
36
|
+
* How far the thumb is along its track, in CSS pixels, from the track's start: the top, or
|
|
37
|
+
* the left (also right to left, where scrolling starts at the right).
|
|
38
|
+
*/
|
|
39
|
+
thumbOffset(orientation?: ScrollbarOrientation): number;
|
|
40
|
+
/** The thumb's length along its track, in CSS pixels. */
|
|
41
|
+
thumbLength(orientation?: ScrollbarOrientation): number;
|
|
42
|
+
/** Puts the pointer over the area, as a user about to scroll does. */
|
|
43
|
+
hover(): Promise<void>;
|
|
44
|
+
/** Takes the pointer away; a `hover` scrollbar goes once the hide delay is up. */
|
|
45
|
+
unhover(): Promise<void>;
|
|
46
|
+
/** Scrolls the viewport, as the wheel or the keyboard would, and waits for its `scroll` event. */
|
|
47
|
+
scrollTo({ top, left }: {
|
|
48
|
+
top?: number;
|
|
49
|
+
left?: number;
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
/** Drags a scrollbar's thumb `distance` CSS pixels along its track (down or right). */
|
|
52
|
+
dragThumb(orientation: ScrollbarOrientation, distance: number): Promise<void>;
|
|
53
|
+
/** Presses a scrollbar's track at `fraction` of its length (0 the start, 1 the end). */
|
|
54
|
+
pressTrack(orientation: ScrollbarOrientation, fraction: number): Promise<void>;
|
|
55
|
+
/** Turns the wheel over a scrollbar by `delta` pixels, which scrolls the viewport. */
|
|
56
|
+
wheel(orientation: ScrollbarOrientation, delta: number): Promise<boolean>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=scroll-area.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../src/scroll-area.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,iEAAiE;AACjE,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,YAAY,CAAA;AAiB5D;;;;;;;;;;GAUG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,OAAgB,SAAS,SAAgB;IAEzC,gCAAgC;IAChC,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED,6DAA6D;IAC7D,SAAS,CAAC,WAAW,GAAE,oBAAiC,GAAG,WAAW,GAAG,IAAI;IAI7E,2DAA2D;IAC3D,KAAK,CAAC,WAAW,GAAE,oBAAiC,GAAG,WAAW,GAAG,IAAI;IAIzE,oDAAoD;IACpD,IAAI,MAAM,IAAI,WAAW,GAAG,IAAI,CAE/B;IAED,gFAAgF;IAChF,kBAAkB,CAAC,WAAW,GAAE,oBAAiC,GAAG,OAAO;IAI3E,wDAAwD;IACxD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,6FAA6F;IAC7F,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,kCAAkC;IAClC,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,oCAAoC;IACpC,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;;OAGG;IACH,WAAW,CAAC,WAAW,GAAE,oBAAiC,GAAG,MAAM;IAanE,yDAAyD;IACzD,WAAW,CAAC,WAAW,GAAE,oBAAiC,GAAG,MAAM;IAMnE,sEAAsE;IAChE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,kFAAkF;IAC5E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,kGAAkG;IAC5F,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAO7E,uFAAuF;IACjF,SAAS,CAAC,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBnF,wFAAwF;IAClF,UAAU,CAAC,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAapF,sFAAsF;IAChF,KAAK,CAAC,WAAW,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAahF"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { settled } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { sendPointer } from "./send-pointer.js";
|
|
4
|
+
/**
|
|
5
|
+
* Screen pixels per CSS pixel at an element: other than 1 under a transform, such as the test
|
|
6
|
+
* container's scale.
|
|
7
|
+
*/
|
|
8
|
+
function scaleOf(element) {
|
|
9
|
+
const width = element.offsetWidth;
|
|
10
|
+
return width ? element.getBoundingClientRect().width / width : 1;
|
|
11
|
+
}
|
|
12
|
+
/** One animation frame, and the app settled after it: when a scroll's `scroll` event has come. */
|
|
13
|
+
async function frame() {
|
|
14
|
+
await new Promise(resolve => requestAnimationFrame(() => resolve()));
|
|
15
|
+
await settled();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Drives a scroll area: `<ScrollArea>` from `@ember-joinery/primitives/scroll-area`, or from
|
|
19
|
+
* `@ember-joinery/ember`. Its viewport scrolls natively; its scrollbars are parts that show for
|
|
20
|
+
* its `@type` (by default while the pointer is over it, so `hover()` first).
|
|
21
|
+
*
|
|
22
|
+
* const tags = new ScrollAreaHarness('tags')
|
|
23
|
+
* await tags.hover()
|
|
24
|
+
* assert.true(tags.isScrollbarVisible())
|
|
25
|
+
* await tags.scrollTo({ top: 200 })
|
|
26
|
+
* await tags.dragThumb('vertical', 40)
|
|
27
|
+
*/
|
|
28
|
+
export class ScrollAreaHarness extends Harness {
|
|
29
|
+
static component = 'scroll-area';
|
|
30
|
+
/** The element that scrolls. */
|
|
31
|
+
get viewport() {
|
|
32
|
+
return this.part('viewport');
|
|
33
|
+
}
|
|
34
|
+
/** A scrollbar's element, or `null` while it isn't shown. */
|
|
35
|
+
scrollbar(orientation = 'vertical') {
|
|
36
|
+
return this.queryPart('scrollbar', orientation);
|
|
37
|
+
}
|
|
38
|
+
/** A scrollbar's thumb, or `null` while it isn't shown. */
|
|
39
|
+
thumb(orientation = 'vertical') {
|
|
40
|
+
return this.queryPart('thumb', orientation);
|
|
41
|
+
}
|
|
42
|
+
/** The corner between the scrollbars, or `null`. */
|
|
43
|
+
get corner() {
|
|
44
|
+
return this.queryPart('corner');
|
|
45
|
+
}
|
|
46
|
+
/** Whether a scrollbar is shown now (rendered, with `data-state="visible"`). */
|
|
47
|
+
isScrollbarVisible(orientation = 'vertical') {
|
|
48
|
+
return this.scrollbar(orientation)?.getAttribute('data-state') === 'visible';
|
|
49
|
+
}
|
|
50
|
+
/** How far the viewport is scrolled down, in pixels. */
|
|
51
|
+
get scrollTop() {
|
|
52
|
+
return this.viewport.scrollTop;
|
|
53
|
+
}
|
|
54
|
+
/** How far it is scrolled across, in pixels: negative right to left, as browsers give it. */
|
|
55
|
+
get scrollLeft() {
|
|
56
|
+
return this.viewport.scrollLeft;
|
|
57
|
+
}
|
|
58
|
+
/** How far down it can scroll. */
|
|
59
|
+
get maxScrollTop() {
|
|
60
|
+
return this.viewport.scrollHeight - this.viewport.clientHeight;
|
|
61
|
+
}
|
|
62
|
+
/** How far across it can scroll. */
|
|
63
|
+
get maxScrollLeft() {
|
|
64
|
+
return this.viewport.scrollWidth - this.viewport.clientWidth;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* How far the thumb is along its track, in CSS pixels, from the track's start: the top, or
|
|
68
|
+
* the left (also right to left, where scrolling starts at the right).
|
|
69
|
+
*/
|
|
70
|
+
thumbOffset(orientation = 'vertical') {
|
|
71
|
+
const thumb = this.thumb(orientation);
|
|
72
|
+
const bar = this.scrollbar(orientation);
|
|
73
|
+
if (!thumb || !bar)
|
|
74
|
+
return 0;
|
|
75
|
+
const t = thumb.getBoundingClientRect();
|
|
76
|
+
const b = bar.getBoundingClientRect();
|
|
77
|
+
const padding = getComputedStyle(bar);
|
|
78
|
+
const scale = scaleOf(bar);
|
|
79
|
+
return orientation === 'vertical'
|
|
80
|
+
? (t.top - b.top) / scale - parseFloat(padding.paddingTop)
|
|
81
|
+
: (t.left - b.left) / scale - parseFloat(padding.paddingLeft);
|
|
82
|
+
}
|
|
83
|
+
/** The thumb's length along its track, in CSS pixels. */
|
|
84
|
+
thumbLength(orientation = 'vertical') {
|
|
85
|
+
const thumb = this.thumb(orientation);
|
|
86
|
+
if (!thumb)
|
|
87
|
+
return 0;
|
|
88
|
+
return orientation === 'vertical' ? thumb.offsetHeight : thumb.offsetWidth;
|
|
89
|
+
}
|
|
90
|
+
/** Puts the pointer over the area, as a user about to scroll does. */
|
|
91
|
+
async hover() {
|
|
92
|
+
await sendPointer(this.element, 'pointerenter');
|
|
93
|
+
}
|
|
94
|
+
/** Takes the pointer away; a `hover` scrollbar goes once the hide delay is up. */
|
|
95
|
+
async unhover() {
|
|
96
|
+
await sendPointer(this.element, 'pointerleave');
|
|
97
|
+
}
|
|
98
|
+
/** Scrolls the viewport, as the wheel or the keyboard would, and waits for its `scroll` event. */
|
|
99
|
+
async scrollTo({ top, left }) {
|
|
100
|
+
const viewport = this.viewport;
|
|
101
|
+
if (top !== undefined)
|
|
102
|
+
viewport.scrollTop = top;
|
|
103
|
+
if (left !== undefined)
|
|
104
|
+
viewport.scrollLeft = left;
|
|
105
|
+
await frame();
|
|
106
|
+
}
|
|
107
|
+
/** Drags a scrollbar's thumb `distance` CSS pixels along its track (down or right). */
|
|
108
|
+
async dragThumb(orientation, distance) {
|
|
109
|
+
const thumb = this.thumb(orientation);
|
|
110
|
+
if (!thumb)
|
|
111
|
+
throw new Error(`no ${orientation} thumb shown in ${this}`);
|
|
112
|
+
const box = thumb.getBoundingClientRect();
|
|
113
|
+
const x = box.left + box.width / 2;
|
|
114
|
+
const y = box.top + box.height / 2;
|
|
115
|
+
const scale = scaleOf(thumb);
|
|
116
|
+
const at = (d) => orientation === 'vertical'
|
|
117
|
+
? { clientX: x, clientY: y + d * scale }
|
|
118
|
+
: { clientX: x + d * scale, clientY: y };
|
|
119
|
+
await sendPointer(thumb, 'pointerdown', at(0));
|
|
120
|
+
await sendPointer(thumb, 'pointermove', at(distance / 2));
|
|
121
|
+
await sendPointer(thumb, 'pointermove', at(distance));
|
|
122
|
+
await sendPointer(thumb, 'pointerup', { ...at(distance), buttons: 0 });
|
|
123
|
+
await frame();
|
|
124
|
+
}
|
|
125
|
+
/** Presses a scrollbar's track at `fraction` of its length (0 the start, 1 the end). */
|
|
126
|
+
async pressTrack(orientation, fraction) {
|
|
127
|
+
const bar = this.scrollbar(orientation);
|
|
128
|
+
if (!bar)
|
|
129
|
+
throw new Error(`no ${orientation} scrollbar shown in ${this}`);
|
|
130
|
+
const box = bar.getBoundingClientRect();
|
|
131
|
+
const at = orientation === 'vertical'
|
|
132
|
+
? { clientX: box.left + box.width / 2, clientY: box.top + box.height * fraction }
|
|
133
|
+
: { clientX: box.left + box.width * fraction, clientY: box.top + box.height / 2 };
|
|
134
|
+
await sendPointer(bar, 'pointerdown', at);
|
|
135
|
+
await sendPointer(bar, 'pointerup', { ...at, buttons: 0 });
|
|
136
|
+
await frame();
|
|
137
|
+
}
|
|
138
|
+
/** Turns the wheel over a scrollbar by `delta` pixels, which scrolls the viewport. */
|
|
139
|
+
async wheel(orientation, delta) {
|
|
140
|
+
const bar = this.scrollbar(orientation);
|
|
141
|
+
if (!bar)
|
|
142
|
+
throw new Error(`no ${orientation} scrollbar shown in ${this}`);
|
|
143
|
+
const event = new WheelEvent('wheel', {
|
|
144
|
+
bubbles: true,
|
|
145
|
+
cancelable: true,
|
|
146
|
+
deltaX: orientation === 'horizontal' ? delta : 0,
|
|
147
|
+
deltaY: orientation === 'vertical' ? delta : 0,
|
|
148
|
+
});
|
|
149
|
+
bar.dispatchEvent(event);
|
|
150
|
+
await frame();
|
|
151
|
+
return event.defaultPrevented;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/** Where a scrolling element is scrolled to, in pixels from its top and its left. */
|
|
3
|
+
export interface ScrollPosition {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Drives a `<Scroller>` from `@ember-joinery/primitives/scroller`: where it is scrolled to,
|
|
9
|
+
* which edges it is at, and scrolling it as a user would. A Scroller wraps content, so the
|
|
10
|
+
* parts inside it still belong to the component around it.
|
|
11
|
+
*
|
|
12
|
+
* const log = new ScrollerHarness('log') // <Scroller @name="log">
|
|
13
|
+
* assert.true(log.isAtBottom)
|
|
14
|
+
* await log.scrollTo({ top: 0 })
|
|
15
|
+
*/
|
|
16
|
+
export declare class ScrollerHarness extends Harness {
|
|
17
|
+
#private;
|
|
18
|
+
static component: string;
|
|
19
|
+
/**
|
|
20
|
+
* Where it is scrolled to. `left` is `scrollLeft`: in right-to-left text it runs from 0 at
|
|
21
|
+
* the right edge down to a negative number at the left.
|
|
22
|
+
*/
|
|
23
|
+
get position(): ScrollPosition;
|
|
24
|
+
/** How far it can scroll down and across, in pixels. */
|
|
25
|
+
get range(): ScrollPosition;
|
|
26
|
+
/** Whether it is scrolled to the top, to within a pixel. */
|
|
27
|
+
get isAtTop(): boolean;
|
|
28
|
+
/** Whether it is scrolled to the bottom, to within a pixel. */
|
|
29
|
+
get isAtBottom(): boolean;
|
|
30
|
+
/** Whether it is scrolled to its left edge, to within a pixel, whichever the direction. */
|
|
31
|
+
get isAtLeft(): boolean;
|
|
32
|
+
/** Whether it is scrolled to its right edge, to within a pixel, whichever the direction. */
|
|
33
|
+
get isAtRight(): boolean;
|
|
34
|
+
/** Whether a keyboard can reach it (it is in the tab order), so arrow keys can scroll it. */
|
|
35
|
+
get isFocusable(): boolean;
|
|
36
|
+
/** Scrolls it to a position at once, as a user dragging its scrollbar would. */
|
|
37
|
+
scrollTo(position: Partial<ScrollPosition>): Promise<void>;
|
|
38
|
+
/** Moves focus to it, as tabbing to it would. */
|
|
39
|
+
focus(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=scroller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroller.d.ts","sourceRoot":"","sources":["../src/scroller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,qFAAqF;AACrF,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,OAAO;;IAC1C,OAAgB,SAAS,SAAa;IAEtC;;;OAGG;IACH,IAAI,QAAQ,IAAI,cAAc,CAG7B;IAED,wDAAwD;IACxD,IAAI,KAAK,IAAI,cAAc,CAM1B;IAED,4DAA4D;IAC5D,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,+DAA+D;IAC/D,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,2FAA2F;IAC3F,IAAI,QAAQ,IAAI,OAAO,CAGtB;IAED,4FAA4F;IAC5F,IAAI,SAAS,IAAI,OAAO,CAGvB;IAED,6FAA6F;IAC7F,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,gFAAgF;IAC1E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhE,iDAAiD;IAC3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
package/dist/scroller.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { waitForObservers } from "./observers.js";
|
|
4
|
+
/**
|
|
5
|
+
* Drives a `<Scroller>` from `@ember-joinery/primitives/scroller`: where it is scrolled to,
|
|
6
|
+
* which edges it is at, and scrolling it as a user would. A Scroller wraps content, so the
|
|
7
|
+
* parts inside it still belong to the component around it.
|
|
8
|
+
*
|
|
9
|
+
* const log = new ScrollerHarness('log') // <Scroller @name="log">
|
|
10
|
+
* assert.true(log.isAtBottom)
|
|
11
|
+
* await log.scrollTo({ top: 0 })
|
|
12
|
+
*/
|
|
13
|
+
export class ScrollerHarness extends Harness {
|
|
14
|
+
static component = 'scroller';
|
|
15
|
+
/**
|
|
16
|
+
* Where it is scrolled to. `left` is `scrollLeft`: in right-to-left text it runs from 0 at
|
|
17
|
+
* the right edge down to a negative number at the left.
|
|
18
|
+
*/
|
|
19
|
+
get position() {
|
|
20
|
+
const { scrollTop, scrollLeft } = this.element;
|
|
21
|
+
return { top: scrollTop, left: scrollLeft };
|
|
22
|
+
}
|
|
23
|
+
/** How far it can scroll down and across, in pixels. */
|
|
24
|
+
get range() {
|
|
25
|
+
const element = this.element;
|
|
26
|
+
return {
|
|
27
|
+
top: element.scrollHeight - element.clientHeight,
|
|
28
|
+
left: element.scrollWidth - element.clientWidth,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Whether it is scrolled to the top, to within a pixel. */
|
|
32
|
+
get isAtTop() {
|
|
33
|
+
return this.element.scrollTop <= 1;
|
|
34
|
+
}
|
|
35
|
+
/** Whether it is scrolled to the bottom, to within a pixel. */
|
|
36
|
+
get isAtBottom() {
|
|
37
|
+
return this.element.scrollTop >= this.range.top - 1;
|
|
38
|
+
}
|
|
39
|
+
/** Whether it is scrolled to its left edge, to within a pixel, whichever the direction. */
|
|
40
|
+
get isAtLeft() {
|
|
41
|
+
const { scrollLeft } = this.element;
|
|
42
|
+
return this.#rtl ? scrollLeft <= -this.range.left + 1 : scrollLeft <= 1;
|
|
43
|
+
}
|
|
44
|
+
/** Whether it is scrolled to its right edge, to within a pixel, whichever the direction. */
|
|
45
|
+
get isAtRight() {
|
|
46
|
+
const { scrollLeft } = this.element;
|
|
47
|
+
return this.#rtl ? scrollLeft >= -1 : scrollLeft >= this.range.left - 1;
|
|
48
|
+
}
|
|
49
|
+
/** Whether a keyboard can reach it (it is in the tab order), so arrow keys can scroll it. */
|
|
50
|
+
get isFocusable() {
|
|
51
|
+
return this.element.tabIndex >= 0;
|
|
52
|
+
}
|
|
53
|
+
/** Scrolls it to a position at once, as a user dragging its scrollbar would. */
|
|
54
|
+
async scrollTo(position) {
|
|
55
|
+
this.element.scrollTo({ ...position, behavior: 'instant' });
|
|
56
|
+
await waitForObservers();
|
|
57
|
+
}
|
|
58
|
+
/** Moves focus to it, as tabbing to it would. */
|
|
59
|
+
async focus() {
|
|
60
|
+
await focus(this.element);
|
|
61
|
+
}
|
|
62
|
+
get #rtl() {
|
|
63
|
+
return getComputedStyle(this.element).direction === 'rtl';
|
|
64
|
+
}
|
|
65
|
+
}
|
package/dist/select.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Select>` from `@ember-joinery/ember` or `@ember-joinery/primitives/select`: a
|
|
4
|
+
* button (`role="combobox"`) that opens a listbox of options. It reads the state from the
|
|
5
|
+
* trigger's ARIA and the options' (`aria-expanded`, `aria-disabled`, `data-state`), and acts as
|
|
6
|
+
* a user does: a press on the trigger, a press on an option, keys and typeahead.
|
|
7
|
+
*
|
|
8
|
+
* const fruit = new SelectHarness('fruit') // <Select @name="fruit">
|
|
9
|
+
* await fruit.select('banana')
|
|
10
|
+
* assert.strictEqual(fruit.value, 'banana')
|
|
11
|
+
* assert.strictEqual(fruit.valueText, 'Banana')
|
|
12
|
+
*
|
|
13
|
+
* While it is closed its options aren't in the page (as Radix's aren't): read them after
|
|
14
|
+
* `open()`.
|
|
15
|
+
*/
|
|
16
|
+
export declare class SelectHarness extends Harness {
|
|
17
|
+
#private;
|
|
18
|
+
static component: string;
|
|
19
|
+
/** The trigger: the `Trigger` part, or your own element with the `trigger` modifier. */
|
|
20
|
+
get trigger(): HTMLElement;
|
|
21
|
+
/** The listbox, or `null` while it is closed. */
|
|
22
|
+
get content(): HTMLElement | null;
|
|
23
|
+
/** Whether it is open, from the trigger's `aria-expanded`. */
|
|
24
|
+
get isOpen(): boolean;
|
|
25
|
+
/** Whether the listbox is showing in the browser's top layer (itself, or its item-aligned wrapper). */
|
|
26
|
+
get isShown(): boolean;
|
|
27
|
+
/** Where the listbox went: `item-aligned` over the trigger, or `popper` below it. */
|
|
28
|
+
get position(): 'item-aligned' | 'popper' | null;
|
|
29
|
+
/** The side the `popper` listbox was placed on, after any flip (`data-side`). */
|
|
30
|
+
get side(): string | null;
|
|
31
|
+
/** The chosen value, or `''` while none is chosen. */
|
|
32
|
+
get value(): string;
|
|
33
|
+
/** What the trigger's value shows: the chosen option's text, or the placeholder. */
|
|
34
|
+
get valueText(): string;
|
|
35
|
+
/** Whether the value shows its placeholder (the trigger's `data-placeholder`). */
|
|
36
|
+
get isPlaceholder(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The trigger's accessible name: `aria-labelledby`'s text, else `aria-label`, else its
|
|
39
|
+
* `<label>`'s text (a combobox isn't named by its own text).
|
|
40
|
+
*/
|
|
41
|
+
get label(): string;
|
|
42
|
+
/** The text of what the trigger's `aria-describedby` names (a field's description and errors). */
|
|
43
|
+
get description(): string;
|
|
44
|
+
/** The listbox's accessible name (its trigger, unless you named it). */
|
|
45
|
+
get contentLabel(): string;
|
|
46
|
+
/** Whether it is disabled: the trigger's `disabled`, or `aria-disabled="true"` on your own element. */
|
|
47
|
+
get isDisabled(): boolean;
|
|
48
|
+
/** Whether the trigger is marked invalid with `aria-invalid`. */
|
|
49
|
+
get isInvalid(): boolean;
|
|
50
|
+
/** Whether it is marked required (`aria-required`). */
|
|
51
|
+
get isRequired(): boolean;
|
|
52
|
+
/** Whether the trigger has focus. */
|
|
53
|
+
get isFocused(): boolean;
|
|
54
|
+
/** The options' elements, in order (while open). */
|
|
55
|
+
get optionElements(): HTMLElement[];
|
|
56
|
+
/** Every option's value, in order (while open). */
|
|
57
|
+
get options(): string[];
|
|
58
|
+
/** Every option's text, in order (while open). */
|
|
59
|
+
get optionTexts(): string[];
|
|
60
|
+
/** The option with this value. Throws when there is none. */
|
|
61
|
+
option(value: string): HTMLElement;
|
|
62
|
+
/** The value of the option that has focus (`data-highlighted`), or `null`. */
|
|
63
|
+
get highlighted(): string | null;
|
|
64
|
+
/** Whether the option with this value is the chosen one (`data-state="checked"`). */
|
|
65
|
+
isOptionSelected(value: string): boolean;
|
|
66
|
+
/** Whether the option with this value can't be chosen (`aria-disabled`). */
|
|
67
|
+
isOptionDisabled(value: string): boolean;
|
|
68
|
+
/** Each group's label, in order (while open). */
|
|
69
|
+
get groups(): string[];
|
|
70
|
+
/** The values of the options in the group with this label. */
|
|
71
|
+
optionsIn(group: string): string[];
|
|
72
|
+
/** Whether the "scroll up" and "scroll down" buttons are showing. */
|
|
73
|
+
get canScrollUp(): boolean;
|
|
74
|
+
get canScrollDown(): boolean;
|
|
75
|
+
/** The hidden native `<select>` that carries the value in a form, or `null` outside one. */
|
|
76
|
+
get nativeSelect(): HTMLSelectElement | null;
|
|
77
|
+
/** Opens it with a press on the trigger, as a mouse does, unless it is open. */
|
|
78
|
+
open(): Promise<void>;
|
|
79
|
+
/** Opens it from the keyboard: focuses the trigger and presses `key` (Enter, Space, or an arrow). */
|
|
80
|
+
openWithKeyboard(key?: 'Enter' | ' ' | 'ArrowDown' | 'ArrowUp'): Promise<void>;
|
|
81
|
+
/** Closes it with Escape, unless it is closed. */
|
|
82
|
+
close(): Promise<void>;
|
|
83
|
+
/** Presses Escape where focus is. */
|
|
84
|
+
pressEscape(): Promise<void>;
|
|
85
|
+
/** A press outside the listbox, as a user dismissing it makes. */
|
|
86
|
+
pressOutside(): Promise<void>;
|
|
87
|
+
/** Chooses the option with this value: opens it, then presses the option, as a mouse does. */
|
|
88
|
+
select(value: string): Promise<void>;
|
|
89
|
+
/** Presses the option with this value (it must be open). */
|
|
90
|
+
pressOption(value: string): Promise<void>;
|
|
91
|
+
/** Presses a key where focus is: an arrow, Home, End, Enter, Space or Escape. */
|
|
92
|
+
pressKey(key: string): Promise<void>;
|
|
93
|
+
/** Types `text` where focus is: on the closed trigger it chooses, in the open list it moves focus. */
|
|
94
|
+
typeahead(text: string): Promise<void>;
|
|
95
|
+
/** Moves focus to the trigger. */
|
|
96
|
+
focus(): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../src/select.ts"],"names":[],"mappings":"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"}
|