@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,159 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
import { type HoverOptions } from './pointer.ts';
|
|
3
|
+
import { SheetHarness } from './sheet.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Drives a menu's button or link in a `<SidebarProvider>` (`sidebar.MenuButton`, or your own
|
|
6
|
+
* element with `{{sidebar.menuButton}}`). It is a component root of its own, so it can be a
|
|
7
|
+
* Collapsible's or a Dropdown Menu's trigger too.
|
|
8
|
+
*
|
|
9
|
+
* const inbox = new SidebarMenuButtonHarness('inbox') // <sidebar.MenuButton @name="inbox">
|
|
10
|
+
* await inbox.click()
|
|
11
|
+
* assert.true(inbox.isActive)
|
|
12
|
+
*/
|
|
13
|
+
export declare class SidebarMenuButtonHarness extends Harness {
|
|
14
|
+
static component: string | readonly string[];
|
|
15
|
+
/** Its accessible name: `aria-label`, `aria-labelledby`'s text, or its own text. */
|
|
16
|
+
get label(): string;
|
|
17
|
+
/** The text it shows, whitespace collapsed. */
|
|
18
|
+
get text(): string;
|
|
19
|
+
/** Whether it is highlighted as the current page's (`@isActive`, its `data-active`). */
|
|
20
|
+
get isActive(): boolean;
|
|
21
|
+
/** Its `@size`: `default`, `sm` or `lg` (a submenu's: `sm` or `md`). */
|
|
22
|
+
get size(): string | null;
|
|
23
|
+
/** Its `@variant`, `default` or `outline`, from its class (upstream renders no attribute). */
|
|
24
|
+
get variant(): string | null;
|
|
25
|
+
/** Its `href`, for a link. */
|
|
26
|
+
get href(): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* For one that opens something (a Collapsible's or a Dropdown Menu's trigger), whether that
|
|
29
|
+
* is open (`aria-expanded`); otherwise `undefined`.
|
|
30
|
+
*/
|
|
31
|
+
get isExpanded(): boolean | undefined;
|
|
32
|
+
/** Whether it can't be used: `disabled`, or `aria-disabled="true"`. */
|
|
33
|
+
get isDisabled(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Its tooltip (`@tooltip`) while it is open, as a screen reader hears it: the text its
|
|
36
|
+
* `aria-describedby` names. `''` while closed.
|
|
37
|
+
*/
|
|
38
|
+
get tooltip(): string;
|
|
39
|
+
/** The tooltip's element while it is open, or `null`. */
|
|
40
|
+
get tooltipElement(): HTMLElement | null;
|
|
41
|
+
/** Whether its tooltip shows: open, and not `hidden` (it hides while the sidebar is expanded). */
|
|
42
|
+
get isTooltipShown(): boolean;
|
|
43
|
+
/** Whether it has focus. */
|
|
44
|
+
get isFocused(): boolean;
|
|
45
|
+
click(): Promise<void>;
|
|
46
|
+
focus(): Promise<void>;
|
|
47
|
+
blur(): Promise<void>;
|
|
48
|
+
/** Rests the pointer on it, as a mouse does, and waits out its tooltip's delay. */
|
|
49
|
+
hover(options?: HoverOptions): Promise<void>;
|
|
50
|
+
/** Moves the pointer off it. */
|
|
51
|
+
unhover(options?: HoverOptions): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Drives a submenu's link in a `<SidebarProvider>` (`sidebar.MenuSubButton`, or your own
|
|
55
|
+
* element with `{{sidebar.menuSubButton}}`): a `SidebarMenuButtonHarness` for
|
|
56
|
+
* `data-test-jn="sidebar-menu-sub-button"`.
|
|
57
|
+
*/
|
|
58
|
+
export declare class SidebarMenuSubButtonHarness extends SidebarMenuButtonHarness {
|
|
59
|
+
static component: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Drives a `<SidebarProvider>` from `@ember-joinery/ember` and the sidebar in it. It reads
|
|
63
|
+
* whether the sidebar is open through ARIA, from its trigger's `aria-expanded` (without a
|
|
64
|
+
* trigger, from the panel's `data-state`, or on mobile the sheet's), and acts as a user does:
|
|
65
|
+
* the trigger, the rail, ⌘B (Ctrl+B), and on mobile, Escape or a press outside the sheet.
|
|
66
|
+
*
|
|
67
|
+
* const sidebar = new SidebarHarness('app') // <SidebarProvider @name="app">
|
|
68
|
+
* await sidebar.toggle()
|
|
69
|
+
* assert.strictEqual(sidebar.state, 'collapsed')
|
|
70
|
+
* await sidebar.pressShortcut()
|
|
71
|
+
* assert.true(sidebar.isOpen)
|
|
72
|
+
* assert.deepEqual(sidebar.menuButtonLabels, ['Home', 'Inbox'])
|
|
73
|
+
*/
|
|
74
|
+
export declare class SidebarHarness extends Harness {
|
|
75
|
+
static component: string;
|
|
76
|
+
/**
|
|
77
|
+
* The sidebar's panel (`data-slot="sidebar"`): the desktop panel, the plain one with
|
|
78
|
+
* `@collapsible="none"`, or, on mobile, the sheet's content while it is open. `null` when
|
|
79
|
+
* the mobile sheet is closed.
|
|
80
|
+
*/
|
|
81
|
+
get panel(): HTMLElement | null;
|
|
82
|
+
/** The panel inside the desktop sidebar, which your attributes go on (`sidebar-container`). */
|
|
83
|
+
get container(): HTMLElement | null;
|
|
84
|
+
/** The mobile sheet, for a sidebar below its mobile breakpoint. */
|
|
85
|
+
get sheet(): SheetHarness;
|
|
86
|
+
/** Whether the viewport is narrower than the mobile breakpoint, so the sidebar is a sheet. */
|
|
87
|
+
get isMobile(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* `expanded` or `collapsed`: the desktop panel's `data-state`. On mobile, `expanded` while the
|
|
90
|
+
* sheet is open. `null` for a sidebar that doesn't collapse.
|
|
91
|
+
*/
|
|
92
|
+
get state(): 'expanded' | 'collapsed' | null;
|
|
93
|
+
/**
|
|
94
|
+
* Whether it is open: the desktop panel expanded, or the mobile sheet open. A screen reader
|
|
95
|
+
* hears it from the trigger's `aria-expanded`, so that is what it reads; with no trigger, the
|
|
96
|
+
* panel's `data-state` (on mobile, the sheet's).
|
|
97
|
+
*/
|
|
98
|
+
get isOpen(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* How it collapsed, while it is collapsed: `offcanvas` or `icon` (the panel's
|
|
101
|
+
* `data-collapsible`, which upstream leaves empty while it is expanded). `none` for one that
|
|
102
|
+
* doesn't collapse; `null` while expanded, and on mobile.
|
|
103
|
+
*/
|
|
104
|
+
get collapsible(): string | null;
|
|
105
|
+
/** `sidebar`, `floating` or `inset` (`@variant`), on the desktop panel. */
|
|
106
|
+
get variant(): string | null;
|
|
107
|
+
/** `left` or `right` (`@side`): the desktop panel's `data-side`, or the sheet's on mobile. */
|
|
108
|
+
get side(): string | null;
|
|
109
|
+
/** The trigger: `sidebar.Trigger`, or your own element with `{{sidebar.trigger}}`. */
|
|
110
|
+
get trigger(): HTMLElement;
|
|
111
|
+
/** The rail along the sidebar's edge, or `null`. */
|
|
112
|
+
get rail(): HTMLElement | null;
|
|
113
|
+
/** The page beside the sidebar (`sidebar.Inset`), or `null`. */
|
|
114
|
+
get inset(): HTMLElement | null;
|
|
115
|
+
/**
|
|
116
|
+
* The sidebar's elements of one kind, by upstream's `data-sidebar` (`group`, `group-label`,
|
|
117
|
+
* `menu`, `menu-item`, `menu-sub`, `menu-badge`…), in document order. Unlike `parts()`, it
|
|
118
|
+
* looks through any component between, such as a Collapsible around a group or the mobile
|
|
119
|
+
* Sheet, whose own parts a sidebar's often are; not into a sidebar inside this one.
|
|
120
|
+
*/
|
|
121
|
+
elements(name: string): HTMLElement[];
|
|
122
|
+
/** The text of each group's label, in order. */
|
|
123
|
+
get groupLabels(): string[];
|
|
124
|
+
/** Every menu button in the sidebar (not the submenus'), in order. */
|
|
125
|
+
get menuButtons(): SidebarMenuButtonHarness[];
|
|
126
|
+
/** Every submenu button in the sidebar, in order: those in closed collapsibles aren't there. */
|
|
127
|
+
get menuSubButtons(): SidebarMenuSubButtonHarness[];
|
|
128
|
+
/** Each menu button's label, in order. */
|
|
129
|
+
get menuButtonLabels(): string[];
|
|
130
|
+
/** Each submenu button's label, in order. */
|
|
131
|
+
get menuSubButtonLabels(): string[];
|
|
132
|
+
/** The menu button labelled `label`. Throws when there is none. */
|
|
133
|
+
menuButton(label: string): SidebarMenuButtonHarness;
|
|
134
|
+
/** The submenu button labelled `label`. Throws when there is none. */
|
|
135
|
+
menuSubButton(label: string): SidebarMenuSubButtonHarness;
|
|
136
|
+
/** The text of each menu badge, in order. */
|
|
137
|
+
get badges(): string[];
|
|
138
|
+
/** Clicks the trigger, as a user does: it opens or closes the sidebar (the sheet, on mobile). */
|
|
139
|
+
toggle(): Promise<void>;
|
|
140
|
+
/** Opens it with the trigger, unless it is open. */
|
|
141
|
+
open(): Promise<void>;
|
|
142
|
+
/** Closes it with the trigger (on mobile, Escape), unless it is closed. */
|
|
143
|
+
close(): Promise<void>;
|
|
144
|
+
/** Clicks the rail. */
|
|
145
|
+
toggleWithRail(): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Presses the keyboard shortcut, ⌘ (`metaKey`) or Ctrl (`ctrlKey`) with `key` (default
|
|
148
|
+
* `b`), on the focused element.
|
|
149
|
+
*/
|
|
150
|
+
pressShortcut({ key, metaKey, }?: {
|
|
151
|
+
key?: string;
|
|
152
|
+
metaKey?: boolean;
|
|
153
|
+
}): Promise<boolean>;
|
|
154
|
+
/** On mobile, presses outside the open sheet (on its overlay), which closes it. */
|
|
155
|
+
pressOutside(): Promise<void>;
|
|
156
|
+
/** Moves focus to the trigger. */
|
|
157
|
+
focusTrigger(): Promise<void>;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=sidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../src/sidebar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAIzC;;;;;;;;GAQG;AACH,qBAAa,wBAAyB,SAAQ,OAAO;IACnD,OAAgB,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAwB;IAE7E,oFAAoF;IACpF,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,+CAA+C;IAC/C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,wFAAwF;IACxF,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,wEAAwE;IACxE,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,8FAA8F;IAC9F,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAG3B;IAED,8BAA8B;IAC9B,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED;;;OAGG;IACH,IAAI,UAAU,IAAI,OAAO,GAAG,SAAS,CAGpC;IAED,uEAAuE;IACvE,IAAI,UAAU,IAAI,OAAO,CAIxB;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,yDAAyD;IACzD,IAAI,cAAc,IAAI,WAAW,GAAG,IAAI,CAGvC;IAED,kGAAkG;IAClG,IAAI,cAAc,IAAI,OAAO,CAG5B;IAED,4BAA4B;IAC5B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,mFAAmF;IAC7E,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,gCAAgC;IAC1B,OAAO,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrD;AAED;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,wBAAwB;IACvE,OAAgB,SAAS,SAA4B;CACtD;AAUD;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACzC,OAAgB,SAAS,SAAY;IAErC;;;;OAIG;IACH,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED,+FAA+F;IAC/F,IAAI,SAAS,IAAI,WAAW,GAAG,IAAI,CAIlC;IAED,mEAAmE;IACnE,IAAI,KAAK,IAAI,YAAY,CAExB;IAED,8FAA8F;IAC9F,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,UAAU,GAAG,WAAW,GAAG,IAAI,CAK3C;IAED;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAKpB;IAED;;;;OAIG;IACH,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAK/B;IAED,2EAA2E;IAC3E,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,8FAA8F;IAC9F,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAIxB;IAED,sFAAsF;IACtF,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,oDAAoD;IACpD,IAAI,IAAI,IAAI,WAAW,GAAG,IAAI,CAE7B;IAED,gEAAgE;IAChE,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE;IAOrC,gDAAgD;IAChD,IAAI,WAAW,IAAI,MAAM,EAAE,CAE1B;IAED,sEAAsE;IACtE,IAAI,WAAW,IAAI,wBAAwB,EAAE,CAE5C;IAED,gGAAgG;IAChG,IAAI,cAAc,IAAI,2BAA2B,EAAE,CAElD;IAED,0CAA0C;IAC1C,IAAI,gBAAgB,IAAI,MAAM,EAAE,CAE/B;IAED,6CAA6C;IAC7C,IAAI,mBAAmB,IAAI,MAAM,EAAE,CAElC;IAED,mEAAmE;IACnE,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB;IAUnD,sEAAsE;IACtE,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,2BAA2B;IAUzD,6CAA6C;IAC7C,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,iGAAiG;IAC3F,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,oDAAoD;IAC9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,2EAA2E;IACrE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B,uBAAuB;IACjB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrC;;;OAGG;IACG,aAAa,CAAC,EAClB,GAAS,EACT,OAAe,GAChB,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9D,mFAAmF;IAC7E,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,kCAAkC;IAC5B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
|
package/dist/sidebar.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { blur, click, focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { pressKey } from "./focus.js";
|
|
4
|
+
import { pressEscape } from "./layers.js";
|
|
5
|
+
import { hover, unhover } from "./pointer.js";
|
|
6
|
+
import { SheetHarness } from "./sheet.js";
|
|
7
|
+
import { accessibleDescription, accessibleName, text } from "./-private/overlay.js";
|
|
8
|
+
import { findWithin, logicalParent } from "./-private/tree.js";
|
|
9
|
+
/**
|
|
10
|
+
* Drives a menu's button or link in a `<SidebarProvider>` (`sidebar.MenuButton`, or your own
|
|
11
|
+
* element with `{{sidebar.menuButton}}`). It is a component root of its own, so it can be a
|
|
12
|
+
* Collapsible's or a Dropdown Menu's trigger too.
|
|
13
|
+
*
|
|
14
|
+
* const inbox = new SidebarMenuButtonHarness('inbox') // <sidebar.MenuButton @name="inbox">
|
|
15
|
+
* await inbox.click()
|
|
16
|
+
* assert.true(inbox.isActive)
|
|
17
|
+
*/
|
|
18
|
+
export class SidebarMenuButtonHarness extends Harness {
|
|
19
|
+
static component = 'sidebar-menu-button';
|
|
20
|
+
/** Its accessible name: `aria-label`, `aria-labelledby`'s text, or its own text. */
|
|
21
|
+
get label() {
|
|
22
|
+
return accessibleName(this.element);
|
|
23
|
+
}
|
|
24
|
+
/** The text it shows, whitespace collapsed. */
|
|
25
|
+
get text() {
|
|
26
|
+
return text(this.element);
|
|
27
|
+
}
|
|
28
|
+
/** Whether it is highlighted as the current page's (`@isActive`, its `data-active`). */
|
|
29
|
+
get isActive() {
|
|
30
|
+
return this.element.getAttribute('data-active') === 'true';
|
|
31
|
+
}
|
|
32
|
+
/** Its `@size`: `default`, `sm` or `lg` (a submenu's: `sm` or `md`). */
|
|
33
|
+
get size() {
|
|
34
|
+
return this.element.getAttribute('data-size');
|
|
35
|
+
}
|
|
36
|
+
/** Its `@variant`, `default` or `outline`, from its class (upstream renders no attribute). */
|
|
37
|
+
get variant() {
|
|
38
|
+
const match = /jn-sidebar-menu-button-variant-(\w+)/.exec(this.element.className);
|
|
39
|
+
return match?.[1] ?? null;
|
|
40
|
+
}
|
|
41
|
+
/** Its `href`, for a link. */
|
|
42
|
+
get href() {
|
|
43
|
+
return this.element.getAttribute('href');
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* For one that opens something (a Collapsible's or a Dropdown Menu's trigger), whether that
|
|
47
|
+
* is open (`aria-expanded`); otherwise `undefined`.
|
|
48
|
+
*/
|
|
49
|
+
get isExpanded() {
|
|
50
|
+
const expanded = this.element.getAttribute('aria-expanded');
|
|
51
|
+
return expanded === null ? undefined : expanded === 'true';
|
|
52
|
+
}
|
|
53
|
+
/** Whether it can't be used: `disabled`, or `aria-disabled="true"`. */
|
|
54
|
+
get isDisabled() {
|
|
55
|
+
const element = this.element;
|
|
56
|
+
if ('disabled' in element && element.disabled)
|
|
57
|
+
return true;
|
|
58
|
+
return element.getAttribute('aria-disabled') === 'true';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Its tooltip (`@tooltip`) while it is open, as a screen reader hears it: the text its
|
|
62
|
+
* `aria-describedby` names. `''` while closed.
|
|
63
|
+
*/
|
|
64
|
+
get tooltip() {
|
|
65
|
+
return accessibleDescription(this.element);
|
|
66
|
+
}
|
|
67
|
+
/** The tooltip's element while it is open, or `null`. */
|
|
68
|
+
get tooltipElement() {
|
|
69
|
+
const id = this.element.getAttribute('aria-describedby');
|
|
70
|
+
return id ? this.element.ownerDocument.getElementById(id) : null;
|
|
71
|
+
}
|
|
72
|
+
/** Whether its tooltip shows: open, and not `hidden` (it hides while the sidebar is expanded). */
|
|
73
|
+
get isTooltipShown() {
|
|
74
|
+
const tooltip = this.tooltipElement;
|
|
75
|
+
return Boolean(tooltip && !tooltip.hidden && tooltip.matches(':popover-open'));
|
|
76
|
+
}
|
|
77
|
+
/** Whether it has focus. */
|
|
78
|
+
get isFocused() {
|
|
79
|
+
return this.element.ownerDocument.activeElement === this.element;
|
|
80
|
+
}
|
|
81
|
+
async click() {
|
|
82
|
+
await click(this.element);
|
|
83
|
+
}
|
|
84
|
+
async focus() {
|
|
85
|
+
await focus(this.element);
|
|
86
|
+
}
|
|
87
|
+
async blur() {
|
|
88
|
+
await blur(this.element);
|
|
89
|
+
}
|
|
90
|
+
/** Rests the pointer on it, as a mouse does, and waits out its tooltip's delay. */
|
|
91
|
+
async hover(options) {
|
|
92
|
+
await hover(this.element, options);
|
|
93
|
+
}
|
|
94
|
+
/** Moves the pointer off it. */
|
|
95
|
+
async unhover(options) {
|
|
96
|
+
await unhover(this.element, { ...options, away: this.tooltipElement });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Drives a submenu's link in a `<SidebarProvider>` (`sidebar.MenuSubButton`, or your own
|
|
101
|
+
* element with `{{sidebar.menuSubButton}}`): a `SidebarMenuButtonHarness` for
|
|
102
|
+
* `data-test-jn="sidebar-menu-sub-button"`.
|
|
103
|
+
*/
|
|
104
|
+
export class SidebarMenuSubButtonHarness extends SidebarMenuButtonHarness {
|
|
105
|
+
static component = 'sidebar-menu-sub-button';
|
|
106
|
+
}
|
|
107
|
+
/** The sidebar an element is in: its nearest `data-test-jn="sidebar"` ancestor in the component tree. */
|
|
108
|
+
function sidebarOf(element) {
|
|
109
|
+
for (let node = logicalParent(element); node; node = logicalParent(node)) {
|
|
110
|
+
if (node.getAttribute('data-test-jn') === 'sidebar')
|
|
111
|
+
return node;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Drives a `<SidebarProvider>` from `@ember-joinery/ember` and the sidebar in it. It reads
|
|
117
|
+
* whether the sidebar is open through ARIA, from its trigger's `aria-expanded` (without a
|
|
118
|
+
* trigger, from the panel's `data-state`, or on mobile the sheet's), and acts as a user does:
|
|
119
|
+
* the trigger, the rail, ⌘B (Ctrl+B), and on mobile, Escape or a press outside the sheet.
|
|
120
|
+
*
|
|
121
|
+
* const sidebar = new SidebarHarness('app') // <SidebarProvider @name="app">
|
|
122
|
+
* await sidebar.toggle()
|
|
123
|
+
* assert.strictEqual(sidebar.state, 'collapsed')
|
|
124
|
+
* await sidebar.pressShortcut()
|
|
125
|
+
* assert.true(sidebar.isOpen)
|
|
126
|
+
* assert.deepEqual(sidebar.menuButtonLabels, ['Home', 'Inbox'])
|
|
127
|
+
*/
|
|
128
|
+
export class SidebarHarness extends Harness {
|
|
129
|
+
static component = 'sidebar';
|
|
130
|
+
/**
|
|
131
|
+
* The sidebar's panel (`data-slot="sidebar"`): the desktop panel, the plain one with
|
|
132
|
+
* `@collapsible="none"`, or, on mobile, the sheet's content while it is open. `null` when
|
|
133
|
+
* the mobile sheet is closed.
|
|
134
|
+
*/
|
|
135
|
+
get panel() {
|
|
136
|
+
return this.queryPart('sidebar') ?? (this.isMobile ? this.sheet.content : null);
|
|
137
|
+
}
|
|
138
|
+
/** The panel inside the desktop sidebar, which your attributes go on (`sidebar-container`). */
|
|
139
|
+
get container() {
|
|
140
|
+
return (this.panel?.querySelector(':scope > [data-slot="sidebar-container"]') ?? null);
|
|
141
|
+
}
|
|
142
|
+
/** The mobile sheet, for a sidebar below its mobile breakpoint. */
|
|
143
|
+
get sheet() {
|
|
144
|
+
return this.child(SheetHarness);
|
|
145
|
+
}
|
|
146
|
+
/** Whether the viewport is narrower than the mobile breakpoint, so the sidebar is a sheet. */
|
|
147
|
+
get isMobile() {
|
|
148
|
+
return !this.queryPart('sidebar') && this.sheet.exists;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* `expanded` or `collapsed`: the desktop panel's `data-state`. On mobile, `expanded` while the
|
|
152
|
+
* sheet is open. `null` for a sidebar that doesn't collapse.
|
|
153
|
+
*/
|
|
154
|
+
get state() {
|
|
155
|
+
if (this.isMobile)
|
|
156
|
+
return this.sheet.content?.getAttribute('data-state') === 'open' ? 'expanded' : 'collapsed';
|
|
157
|
+
const state = this.queryPart('sidebar')?.getAttribute('data-state');
|
|
158
|
+
return state === 'expanded' || state === 'collapsed' ? state : null;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Whether it is open: the desktop panel expanded, or the mobile sheet open. A screen reader
|
|
162
|
+
* hears it from the trigger's `aria-expanded`, so that is what it reads; with no trigger, the
|
|
163
|
+
* panel's `data-state` (on mobile, the sheet's).
|
|
164
|
+
*/
|
|
165
|
+
get isOpen() {
|
|
166
|
+
const expanded = this.queryPart('trigger')?.getAttribute('aria-expanded');
|
|
167
|
+
if (expanded === 'true' || expanded === 'false')
|
|
168
|
+
return expanded === 'true';
|
|
169
|
+
if (this.isMobile)
|
|
170
|
+
return this.sheet.content?.getAttribute('data-state') === 'open';
|
|
171
|
+
return this.queryPart('sidebar')?.getAttribute('data-state') === 'expanded';
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* How it collapsed, while it is collapsed: `offcanvas` or `icon` (the panel's
|
|
175
|
+
* `data-collapsible`, which upstream leaves empty while it is expanded). `none` for one that
|
|
176
|
+
* doesn't collapse; `null` while expanded, and on mobile.
|
|
177
|
+
*/
|
|
178
|
+
get collapsible() {
|
|
179
|
+
const panel = this.queryPart('sidebar');
|
|
180
|
+
if (!panel)
|
|
181
|
+
return null;
|
|
182
|
+
if (!panel.hasAttribute('data-state'))
|
|
183
|
+
return 'none';
|
|
184
|
+
return panel.getAttribute('data-collapsible') || null;
|
|
185
|
+
}
|
|
186
|
+
/** `sidebar`, `floating` or `inset` (`@variant`), on the desktop panel. */
|
|
187
|
+
get variant() {
|
|
188
|
+
return this.queryPart('sidebar')?.getAttribute('data-variant') ?? null;
|
|
189
|
+
}
|
|
190
|
+
/** `left` or `right` (`@side`): the desktop panel's `data-side`, or the sheet's on mobile. */
|
|
191
|
+
get side() {
|
|
192
|
+
const panel = this.queryPart('sidebar');
|
|
193
|
+
if (panel)
|
|
194
|
+
return panel.getAttribute('data-side');
|
|
195
|
+
return this.isMobile ? this.sheet.side : null;
|
|
196
|
+
}
|
|
197
|
+
/** The trigger: `sidebar.Trigger`, or your own element with `{{sidebar.trigger}}`. */
|
|
198
|
+
get trigger() {
|
|
199
|
+
return this.part('trigger');
|
|
200
|
+
}
|
|
201
|
+
/** The rail along the sidebar's edge, or `null`. */
|
|
202
|
+
get rail() {
|
|
203
|
+
return this.queryPart('rail');
|
|
204
|
+
}
|
|
205
|
+
/** The page beside the sidebar (`sidebar.Inset`), or `null`. */
|
|
206
|
+
get inset() {
|
|
207
|
+
return this.queryPart('inset');
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The sidebar's elements of one kind, by upstream's `data-sidebar` (`group`, `group-label`,
|
|
211
|
+
* `menu`, `menu-item`, `menu-sub`, `menu-badge`…), in document order. Unlike `parts()`, it
|
|
212
|
+
* looks through any component between, such as a Collapsible around a group or the mobile
|
|
213
|
+
* Sheet, whose own parts a sidebar's often are; not into a sidebar inside this one.
|
|
214
|
+
*/
|
|
215
|
+
elements(name) {
|
|
216
|
+
const root = this.element;
|
|
217
|
+
return findWithin(root, `[data-sidebar="${CSS.escape(name)}"]`).filter(element => sidebarOf(element) === root);
|
|
218
|
+
}
|
|
219
|
+
/** The text of each group's label, in order. */
|
|
220
|
+
get groupLabels() {
|
|
221
|
+
return this.elements('group-label').map(element => text(element));
|
|
222
|
+
}
|
|
223
|
+
/** Every menu button in the sidebar (not the submenus'), in order. */
|
|
224
|
+
get menuButtons() {
|
|
225
|
+
return this.findAll(SidebarMenuButtonHarness);
|
|
226
|
+
}
|
|
227
|
+
/** Every submenu button in the sidebar, in order: those in closed collapsibles aren't there. */
|
|
228
|
+
get menuSubButtons() {
|
|
229
|
+
return this.findAll(SidebarMenuSubButtonHarness);
|
|
230
|
+
}
|
|
231
|
+
/** Each menu button's label, in order. */
|
|
232
|
+
get menuButtonLabels() {
|
|
233
|
+
return this.menuButtons.map(button => button.label);
|
|
234
|
+
}
|
|
235
|
+
/** Each submenu button's label, in order. */
|
|
236
|
+
get menuSubButtonLabels() {
|
|
237
|
+
return this.menuSubButtons.map(button => button.label);
|
|
238
|
+
}
|
|
239
|
+
/** The menu button labelled `label`. Throws when there is none. */
|
|
240
|
+
menuButton(label) {
|
|
241
|
+
const found = this.menuButtons.find(button => button.label === label);
|
|
242
|
+
if (!found) {
|
|
243
|
+
throw new Error(`Joinery harness: no menu button "${label}" in ${this} (there are ${JSON.stringify(this.menuButtonLabels)})`);
|
|
244
|
+
}
|
|
245
|
+
return found;
|
|
246
|
+
}
|
|
247
|
+
/** The submenu button labelled `label`. Throws when there is none. */
|
|
248
|
+
menuSubButton(label) {
|
|
249
|
+
const found = this.menuSubButtons.find(button => button.label === label);
|
|
250
|
+
if (!found) {
|
|
251
|
+
throw new Error(`Joinery harness: no submenu button "${label}" in ${this} (there are ${JSON.stringify(this.menuSubButtonLabels)})`);
|
|
252
|
+
}
|
|
253
|
+
return found;
|
|
254
|
+
}
|
|
255
|
+
/** The text of each menu badge, in order. */
|
|
256
|
+
get badges() {
|
|
257
|
+
return this.elements('menu-badge').map(element => text(element));
|
|
258
|
+
}
|
|
259
|
+
/** Clicks the trigger, as a user does: it opens or closes the sidebar (the sheet, on mobile). */
|
|
260
|
+
async toggle() {
|
|
261
|
+
await click(this.trigger);
|
|
262
|
+
}
|
|
263
|
+
/** Opens it with the trigger, unless it is open. */
|
|
264
|
+
async open() {
|
|
265
|
+
if (!this.isOpen)
|
|
266
|
+
await this.toggle();
|
|
267
|
+
}
|
|
268
|
+
/** Closes it with the trigger (on mobile, Escape), unless it is closed. */
|
|
269
|
+
async close() {
|
|
270
|
+
if (!this.isOpen)
|
|
271
|
+
return;
|
|
272
|
+
if (this.isMobile)
|
|
273
|
+
await pressEscape();
|
|
274
|
+
else
|
|
275
|
+
await this.toggle();
|
|
276
|
+
}
|
|
277
|
+
/** Clicks the rail. */
|
|
278
|
+
async toggleWithRail() {
|
|
279
|
+
const rail = this.rail;
|
|
280
|
+
if (!rail)
|
|
281
|
+
throw new Error(`Joinery harness: ${this} has no rail`);
|
|
282
|
+
await click(rail);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Presses the keyboard shortcut, ⌘ (`metaKey`) or Ctrl (`ctrlKey`) with `key` (default
|
|
286
|
+
* `b`), on the focused element.
|
|
287
|
+
*/
|
|
288
|
+
async pressShortcut({ key = 'b', metaKey = false, } = {}) {
|
|
289
|
+
return pressKey(key, metaKey ? { metaKey: true } : { ctrlKey: true });
|
|
290
|
+
}
|
|
291
|
+
/** On mobile, presses outside the open sheet (on its overlay), which closes it. */
|
|
292
|
+
async pressOutside() {
|
|
293
|
+
await this.sheet.pressOutside();
|
|
294
|
+
}
|
|
295
|
+
/** Moves focus to the trigger. */
|
|
296
|
+
async focusTrigger() {
|
|
297
|
+
await focus(this.trigger);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Skeleton>` from `@ember-joinery/ember`: a placeholder shown while content loads.
|
|
4
|
+
* It has no ARIA of its own (mark the region that is loading with `aria-busy`), so a test
|
|
5
|
+
* counts and measures them.
|
|
6
|
+
*
|
|
7
|
+
* assert.strictEqual(SkeletonHarness.findAll().length, 3)
|
|
8
|
+
*/
|
|
9
|
+
export declare class SkeletonHarness extends Harness {
|
|
10
|
+
static component: string;
|
|
11
|
+
/** Its laid-out width, border included, in CSS pixels (a transform on the page doesn't change it). */
|
|
12
|
+
get width(): number;
|
|
13
|
+
/** Its laid-out height, border included, in CSS pixels. */
|
|
14
|
+
get height(): number;
|
|
15
|
+
/** Whether it pulses: its animation runs (a `prefers-reduced-motion` rule of yours can stop it). */
|
|
16
|
+
get isPulsing(): boolean;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=skeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../src/skeleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAa;IAEtC,sGAAsG;IACtG,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,2DAA2D;IAC3D,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,oGAAoG;IACpG,IAAI,SAAS,IAAI,OAAO,CAGvB;CACF"}
|
package/dist/skeleton.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Harness } from "./harness.js";
|
|
2
|
+
import { borderBox } from "./-private/size.js";
|
|
3
|
+
/**
|
|
4
|
+
* Drives a `<Skeleton>` from `@ember-joinery/ember`: a placeholder shown while content loads.
|
|
5
|
+
* It has no ARIA of its own (mark the region that is loading with `aria-busy`), so a test
|
|
6
|
+
* counts and measures them.
|
|
7
|
+
*
|
|
8
|
+
* assert.strictEqual(SkeletonHarness.findAll().length, 3)
|
|
9
|
+
*/
|
|
10
|
+
export class SkeletonHarness extends Harness {
|
|
11
|
+
static component = 'skeleton';
|
|
12
|
+
/** Its laid-out width, border included, in CSS pixels (a transform on the page doesn't change it). */
|
|
13
|
+
get width() {
|
|
14
|
+
return borderBox(this.element).width;
|
|
15
|
+
}
|
|
16
|
+
/** Its laid-out height, border included, in CSS pixels. */
|
|
17
|
+
get height() {
|
|
18
|
+
return borderBox(this.element).height;
|
|
19
|
+
}
|
|
20
|
+
/** Whether it pulses: its animation runs (a `prefers-reduced-motion` rule of yours can stop it). */
|
|
21
|
+
get isPulsing() {
|
|
22
|
+
const style = getComputedStyle(this.element);
|
|
23
|
+
return style.animationName !== 'none' && style.animationDuration !== '0s';
|
|
24
|
+
}
|
|
25
|
+
}
|
package/dist/slider.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
import { type KeyModifiers } from './focus.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Drives a `<Slider>` from `@ember-joinery/ember`, or the primitives' `Slider`. Each thumb is a
|
|
5
|
+
* `role="slider"`, read through its ARIA; the keys and the pointer move them as a user does.
|
|
6
|
+
*
|
|
7
|
+
* const volume = new SliderHarness('volume') // <Slider @name="volume">
|
|
8
|
+
* await volume.focus()
|
|
9
|
+
* await volume.press('ArrowRight')
|
|
10
|
+
* assert.deepEqual(volume.value, [76])
|
|
11
|
+
* await volume.slideTo(25) // a press at 25% along the track
|
|
12
|
+
*/
|
|
13
|
+
export declare class SliderHarness extends Harness {
|
|
14
|
+
static component: string;
|
|
15
|
+
/** Each thumb's element (its `role="slider"`), in order. */
|
|
16
|
+
get thumbs(): HTMLElement[];
|
|
17
|
+
/** The thumb that moves the value at `index` (default 0). Throws when there is none. */
|
|
18
|
+
thumb(index?: number): HTMLElement;
|
|
19
|
+
/**
|
|
20
|
+
* Its value, as Radix's: each thumb's (`aria-valuenow`), in order. A one-thumb slider's is
|
|
21
|
+
* `value[0]`.
|
|
22
|
+
*/
|
|
23
|
+
get value(): number[];
|
|
24
|
+
/** Its lowest value (`aria-valuemin`). */
|
|
25
|
+
get min(): number | undefined;
|
|
26
|
+
/** Its highest value (`aria-valuemax`). */
|
|
27
|
+
get max(): number | undefined;
|
|
28
|
+
/** Each thumb's accessible name, in order. */
|
|
29
|
+
get labels(): string[];
|
|
30
|
+
/** `horizontal` or `vertical`. */
|
|
31
|
+
get orientation(): string | null;
|
|
32
|
+
/** Whether it can't be moved: `data-disabled`, and its thumbs out of the tab order. */
|
|
33
|
+
get isDisabled(): boolean;
|
|
34
|
+
/** The index of the thumb that has focus, or `null` when focus is elsewhere. */
|
|
35
|
+
get focused(): number | null;
|
|
36
|
+
/** Focuses a thumb (default the first), as tabbing to it would. */
|
|
37
|
+
focus(index?: number): Promise<void>;
|
|
38
|
+
/** Moves focus away from it. */
|
|
39
|
+
blur(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Presses a key on the focused thumb: `ArrowRight`, `PageUp`, `Home`… Focus a thumb first
|
|
42
|
+
* (`focus()`), or give its index here.
|
|
43
|
+
*/
|
|
44
|
+
press(key: string, modifiers?: KeyModifiers & {
|
|
45
|
+
thumb?: number;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Where along the slider a share of its length is, from where its values start: the left
|
|
49
|
+
* (the right, right to left) or the bottom. For an inverted slider, that is the far end.
|
|
50
|
+
*/
|
|
51
|
+
pointAt(percent: number): {
|
|
52
|
+
clientX: number;
|
|
53
|
+
clientY: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Presses the slider at `percent` of its length (see `pointAt`) and lets go, as a click on
|
|
57
|
+
* the track: the nearest thumb moves there.
|
|
58
|
+
*/
|
|
59
|
+
slideTo(percent: number): Promise<void>;
|
|
60
|
+
/** Drags a thumb (default the first) to `percent` of the slider's length, and lets go. */
|
|
61
|
+
drag(to: number, { thumb, from }?: {
|
|
62
|
+
thumb?: number;
|
|
63
|
+
from?: number;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../src/slider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AA4BxD;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,OAAgB,SAAS,SAAW;IAEpC,4DAA4D;IAC5D,IAAI,MAAM,IAAI,WAAW,EAAE,CAE1B;IAED,wFAAwF;IACxF,KAAK,CAAC,KAAK,SAAI,GAAG,WAAW;IAI7B;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,EAAE,CAIpB;IAED,0CAA0C;IAC1C,IAAI,GAAG,IAAI,MAAM,GAAG,SAAS,CAG5B;IAED,2CAA2C;IAC3C,IAAI,GAAG,IAAI,MAAM,GAAG,SAAS,CAG5B;IAED,8CAA8C;IAC9C,IAAI,MAAM,IAAI,MAAM,EAAE,CAWrB;IAED,kCAAkC;IAClC,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAE/B;IAED,uFAAuF;IACvF,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,gFAAgF;IAChF,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAG3B;IAED,mEAAmE;IAC7D,KAAK,CAAC,KAAK,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,gCAAgC;IAC1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B;;;OAGG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtF;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAY9D;;;OAGG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C,0FAA0F;IACpF,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,KAAS,EAAE,IAAI,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO;CAenF"}
|