@ember-joinery/test-support 0.0.0-stage → 1.1.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 +574 -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/app-shell.d.ts +43 -0
- package/dist/app-shell.d.ts.map +1 -0
- package/dist/app-shell.js +78 -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 +98 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +99 -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/inspector.d.ts +47 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/inspector.js +97 -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-bar.d.ts +30 -0
- package/dist/navigation-bar.d.ts.map +1 -0
- package/dist/navigation-bar.js +52 -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/navigation-stack.d.ts +36 -0
- package/dist/navigation-stack.d.ts.map +1 -0
- package/dist/navigation-stack.js +67 -0
- package/dist/observers.d.ts +21 -0
- package/dist/observers.d.ts.map +1 -0
- package/dist/observers.js +34 -0
- package/dist/page.d.ts +38 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +68 -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/pull-to-refresh.d.ts +40 -0
- package/dist/pull-to-refresh.d.ts.map +1 -0
- package/dist/pull-to-refresh.js +65 -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/split-view.d.ts +77 -0
- package/dist/split-view.d.ts.map +1 -0
- package/dist/split-view.js +145 -0
- package/dist/status-bar.d.ts +25 -0
- package/dist/status-bar.d.ts.map +1 -0
- package/dist/status-bar.js +42 -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/tab-bar.d.ts +38 -0
- package/dist/tab-bar.d.ts.map +1 -0
- package/dist/tab-bar.js +78 -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/title-bar.d.ts +43 -0
- package/dist/title-bar.d.ts.map +1 -0
- package/dist/title-bar.js +74 -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/toolbar.d.ts +40 -0
- package/dist/toolbar.d.ts.map +1 -0
- package/dist/toolbar.js +67 -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/window-frame.d.ts +40 -0
- package/dist/window-frame.d.ts.map +1 -0
- package/dist/window-frame.js +66 -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,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `data-test-jn-*` attributes every Joinery component renders. They are public API: the
|
|
3
|
+
* harnesses find and scope components with them, and your own tests can too.
|
|
4
|
+
*
|
|
5
|
+
* data-test-jn="<component>" the root of a component instance (`dialog`, `button`…)
|
|
6
|
+
* data-test-jn-name="<@name>" on the root, when the component was given `@name`
|
|
7
|
+
* data-test-jn-part="<part>" a part of the component (`trigger`, `content`, `item`…)
|
|
8
|
+
* data-test-jn-owner="<id>" on a portalled or top-layer part, or one a caller may wrap in
|
|
9
|
+
* another component (a radio item in a Field): its root's `id`
|
|
10
|
+
* data-test-jn-value="<key>" an option, item, tab or toggle, by its key
|
|
11
|
+
* data-test-jn-wrapper on a root that wraps the caller's content (a scroller, a
|
|
12
|
+
* layout): the parts inside it belong to the component around it
|
|
13
|
+
*/
|
|
14
|
+
export const attributes = {
|
|
15
|
+
component: 'data-test-jn',
|
|
16
|
+
name: 'data-test-jn-name',
|
|
17
|
+
part: 'data-test-jn-part',
|
|
18
|
+
owner: 'data-test-jn-owner',
|
|
19
|
+
value: 'data-test-jn-value',
|
|
20
|
+
wrapper: 'data-test-jn-wrapper',
|
|
21
|
+
};
|
|
22
|
+
/** A value made safe to put inside a double-quoted CSS attribute selector. */
|
|
23
|
+
function quote(value) {
|
|
24
|
+
return `"${value.replace(/["\\]/g, '\\$&').replace(/\n/g, '\\a ')}"`;
|
|
25
|
+
}
|
|
26
|
+
function attribute(name, value) {
|
|
27
|
+
return value === undefined ? `[${name}]` : `[${name}=${quote(value)}]`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* CSS selectors for the `data-test-jn-*` attributes. Each takes an optional value; without one
|
|
31
|
+
* it matches any element that has the attribute.
|
|
32
|
+
*
|
|
33
|
+
* selectors.component('dialog', 'edit-profile')
|
|
34
|
+
* // '[data-test-jn="dialog"][data-test-jn-name="edit-profile"]'
|
|
35
|
+
* selectors.part('trigger') // '[data-test-jn-part="trigger"]'
|
|
36
|
+
*/
|
|
37
|
+
export const selectors = {
|
|
38
|
+
/** A component's root, by its kind (`data-test-jn`) and, optionally, its `@name`. */
|
|
39
|
+
component(component, name) {
|
|
40
|
+
return (attribute(attributes.component, component) +
|
|
41
|
+
(name === undefined ? '' : attribute(attributes.name, name)));
|
|
42
|
+
},
|
|
43
|
+
/** A component's root, by its `@name` (`data-test-jn-name`), whatever its kind. */
|
|
44
|
+
name(name) {
|
|
45
|
+
return attribute(attributes.name, name);
|
|
46
|
+
},
|
|
47
|
+
/** A part (`data-test-jn-part`). */
|
|
48
|
+
part(part) {
|
|
49
|
+
return attribute(attributes.part, part);
|
|
50
|
+
},
|
|
51
|
+
/** The portalled and top-layer parts of the root whose `id` this is (`data-test-jn-owner`). */
|
|
52
|
+
owner(id) {
|
|
53
|
+
return attribute(attributes.owner, id);
|
|
54
|
+
},
|
|
55
|
+
/** An option, item, tab or toggle, by its key (`data-test-jn-value`). */
|
|
56
|
+
value(key) {
|
|
57
|
+
return attribute(attributes.value, key);
|
|
58
|
+
},
|
|
59
|
+
/** The root of a component that wraps the caller's content (`data-test-jn-wrapper`). */
|
|
60
|
+
wrapper() {
|
|
61
|
+
return attribute(attributes.wrapper);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The pointer events a mouse sends, which `sendPointer()` dispatches. */
|
|
2
|
+
export type PointerEventType = 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel' | 'pointerenter' | 'pointerleave' | 'pointerover' | 'pointerout';
|
|
3
|
+
/**
|
|
4
|
+
* Dispatches one pointer event on `target` as a mouse sends it (a real `PointerEvent`, the
|
|
5
|
+
* primary pointer, the main button), then waits for the app to settle. `pointerenter` and
|
|
6
|
+
* `pointerleave` don't bubble, as in a browser; the rest do. Pass where it is (`clientX`,
|
|
7
|
+
* `clientY`) and anything else to change.
|
|
8
|
+
*
|
|
9
|
+
* await sendPointer(handle, 'pointerdown', { clientX: 100, clientY: 20 })
|
|
10
|
+
* await sendPointer(handle, 'pointermove', { clientX: 140, clientY: 20 })
|
|
11
|
+
* await sendPointer(handle, 'pointerup', { clientX: 140, clientY: 20, buttons: 0 })
|
|
12
|
+
*
|
|
13
|
+
* `@ember/test-helpers`' `triggerEvent` makes a plain `Event` for these, without the
|
|
14
|
+
* `PointerEvent` interface; components that check for one need this.
|
|
15
|
+
*/
|
|
16
|
+
export declare function sendPointer(target: Element | Document, type: PointerEventType, init?: PointerEventInit): Promise<PointerEvent>;
|
|
17
|
+
//# sourceMappingURL=send-pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-pointer.d.ts","sourceRoot":"","sources":["../src/send-pointer.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,aAAa,GACb,WAAW,GACX,eAAe,GACf,cAAc,GACd,cAAc,GACd,aAAa,GACb,YAAY,CAAA;AAKhB;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,OAAO,GAAG,QAAQ,EAC1B,IAAI,EAAE,gBAAgB,EACtB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAkBvB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { settled } from '@ember/test-helpers';
|
|
2
|
+
/** The pointer `sendPointer()` uses: the mouse's. */
|
|
3
|
+
const MOUSE_POINTER_ID = 1;
|
|
4
|
+
/**
|
|
5
|
+
* Dispatches one pointer event on `target` as a mouse sends it (a real `PointerEvent`, the
|
|
6
|
+
* primary pointer, the main button), then waits for the app to settle. `pointerenter` and
|
|
7
|
+
* `pointerleave` don't bubble, as in a browser; the rest do. Pass where it is (`clientX`,
|
|
8
|
+
* `clientY`) and anything else to change.
|
|
9
|
+
*
|
|
10
|
+
* await sendPointer(handle, 'pointerdown', { clientX: 100, clientY: 20 })
|
|
11
|
+
* await sendPointer(handle, 'pointermove', { clientX: 140, clientY: 20 })
|
|
12
|
+
* await sendPointer(handle, 'pointerup', { clientX: 140, clientY: 20, buttons: 0 })
|
|
13
|
+
*
|
|
14
|
+
* `@ember/test-helpers`' `triggerEvent` makes a plain `Event` for these, without the
|
|
15
|
+
* `PointerEvent` interface; components that check for one need this.
|
|
16
|
+
*/
|
|
17
|
+
export async function sendPointer(target, type, init = {}) {
|
|
18
|
+
const bubbles = type !== 'pointerenter' && type !== 'pointerleave';
|
|
19
|
+
const pressed = type === 'pointerdown' || type === 'pointermove';
|
|
20
|
+
const event = new PointerEvent(type, {
|
|
21
|
+
bubbles,
|
|
22
|
+
cancelable: true,
|
|
23
|
+
composed: true,
|
|
24
|
+
view: window,
|
|
25
|
+
pointerId: MOUSE_POINTER_ID,
|
|
26
|
+
pointerType: 'mouse',
|
|
27
|
+
isPrimary: true,
|
|
28
|
+
button: type === 'pointermove' ? -1 : 0,
|
|
29
|
+
buttons: pressed ? 1 : 0,
|
|
30
|
+
...init,
|
|
31
|
+
});
|
|
32
|
+
target.dispatchEvent(event);
|
|
33
|
+
await settled();
|
|
34
|
+
return event;
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Separator>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/separator`.
|
|
4
|
+
* Everything comes from its ARIA, and `data-orientation` for a decorative one, which has none.
|
|
5
|
+
*
|
|
6
|
+
* const separator = new SeparatorHarness()
|
|
7
|
+
* assert.strictEqual(separator.orientation, 'vertical')
|
|
8
|
+
* assert.true(separator.isDecorative)
|
|
9
|
+
*/
|
|
10
|
+
export declare class SeparatorHarness extends Harness {
|
|
11
|
+
static component: string;
|
|
12
|
+
/**
|
|
13
|
+
* Its role as assistive technology sees it: `separator` (an `<hr>`'s own, or `role`), or
|
|
14
|
+
* `none` for a decorative one.
|
|
15
|
+
*/
|
|
16
|
+
get role(): string | null;
|
|
17
|
+
/** Whether assistive technology skips it: `role="none"`, or `aria-hidden="true"`. */
|
|
18
|
+
get isDecorative(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Which way it runs: `horizontal` or `vertical`. A semantic separator's `aria-orientation`
|
|
21
|
+
* (horizontal when it has none, as the role's default), or a decorative one's
|
|
22
|
+
* `data-orientation`.
|
|
23
|
+
*/
|
|
24
|
+
get orientation(): 'horizontal' | 'vertical';
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=separator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separator.d.ts","sourceRoot":"","sources":["../src/separator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,OAAO;IAC3C,OAAgB,SAAS,SAAc;IAEvC;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAKxB;IAED,qFAAqF;IACrF,IAAI,YAAY,IAAI,OAAO,CAM1B;IAED;;;;OAIG;IACH,IAAI,WAAW,IAAI,YAAY,GAAG,UAAU,CAM3C;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Harness } from "./harness.js";
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Separator>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/separator`.
|
|
4
|
+
* Everything comes from its ARIA, and `data-orientation` for a decorative one, which has none.
|
|
5
|
+
*
|
|
6
|
+
* const separator = new SeparatorHarness()
|
|
7
|
+
* assert.strictEqual(separator.orientation, 'vertical')
|
|
8
|
+
* assert.true(separator.isDecorative)
|
|
9
|
+
*/
|
|
10
|
+
export class SeparatorHarness extends Harness {
|
|
11
|
+
static component = 'separator';
|
|
12
|
+
/**
|
|
13
|
+
* Its role as assistive technology sees it: `separator` (an `<hr>`'s own, or `role`), or
|
|
14
|
+
* `none` for a decorative one.
|
|
15
|
+
*/
|
|
16
|
+
get role() {
|
|
17
|
+
const element = this.element;
|
|
18
|
+
const role = element.getAttribute('role');
|
|
19
|
+
if (role)
|
|
20
|
+
return role;
|
|
21
|
+
return element.localName === 'hr' ? 'separator' : null;
|
|
22
|
+
}
|
|
23
|
+
/** Whether assistive technology skips it: `role="none"`, or `aria-hidden="true"`. */
|
|
24
|
+
get isDecorative() {
|
|
25
|
+
const element = this.element;
|
|
26
|
+
const role = element.getAttribute('role');
|
|
27
|
+
return (role === 'none' || role === 'presentation' || element.getAttribute('aria-hidden') === 'true');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Which way it runs: `horizontal` or `vertical`. A semantic separator's `aria-orientation`
|
|
31
|
+
* (horizontal when it has none, as the role's default), or a decorative one's
|
|
32
|
+
* `data-orientation`.
|
|
33
|
+
*/
|
|
34
|
+
get orientation() {
|
|
35
|
+
const element = this.element;
|
|
36
|
+
const value = (this.isDecorative ? null : element.getAttribute('aria-orientation')) ??
|
|
37
|
+
element.getAttribute('data-orientation');
|
|
38
|
+
return value === 'vertical' ? 'vertical' : 'horizontal';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/** An element, or a selector for one in the test's root. */
|
|
3
|
+
type Findable = Element | string;
|
|
4
|
+
/**
|
|
5
|
+
* The first element matching `query` in the shadow root of `root` (an element, or a selector),
|
|
6
|
+
* or `null` when there is no such root or element. It is ember-primitives' `findInShadow`.
|
|
7
|
+
*
|
|
8
|
+
* assert.dom(findInShadow('[data-preview]', 'h1')).hasText('Welcome')
|
|
9
|
+
*/
|
|
10
|
+
export declare function findInShadow(root: Findable, query: string): Element | null;
|
|
11
|
+
/** Whether an element has a shadow root (an open one). It is ember-primitives' `hasShadowRoot`. */
|
|
12
|
+
export declare function hasShadowRoot(element: Element): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The first element with a shadow root inside `root` (an element or a selector), or inside the
|
|
15
|
+
* test's root without one. It is ember-primitives' `findShadow`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findShadow(root?: Findable): Element | null;
|
|
18
|
+
/**
|
|
19
|
+
* The first element matching `query` in the first shadow root in the test. Use `findInShadow`
|
|
20
|
+
* when there are several. It is ember-primitives' `findInFirstShadow`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function findInFirstShadow(query: string): Element | null;
|
|
23
|
+
/**
|
|
24
|
+
* Drives a `<Shadowed>` from `@ember-joinery/primitives/shadowed`: its shadow root, and what is
|
|
25
|
+
* rendered there. Harnesses don't look into shadow roots, so find what's inside through this.
|
|
26
|
+
*
|
|
27
|
+
* const preview = new ShadowedHarness('preview') // <Shadowed @name="preview">
|
|
28
|
+
* assert.dom(preview.query('h1')).hasText('Welcome')
|
|
29
|
+
*/
|
|
30
|
+
export declare class ShadowedHarness extends Harness {
|
|
31
|
+
static component: string;
|
|
32
|
+
/** The element the shadow root is attached to: the `<div>` inside the component's own. */
|
|
33
|
+
get host(): HTMLElement;
|
|
34
|
+
/** The shadow root. */
|
|
35
|
+
get shadowRoot(): ShadowRoot;
|
|
36
|
+
/**
|
|
37
|
+
* The element the content renders in, inside the shadow root. With `@includeStyles`, it
|
|
38
|
+
* starts with the copies of the page's `<style>` and `<link>` elements.
|
|
39
|
+
*/
|
|
40
|
+
get content(): HTMLElement;
|
|
41
|
+
/** The first element in the shadow root matching `selector`, or `null`. */
|
|
42
|
+
query<E extends Element = HTMLElement>(selector: string): E | null;
|
|
43
|
+
/** Every element in the shadow root matching `selector`. */
|
|
44
|
+
queryAll<E extends Element = HTMLElement>(selector: string): E[];
|
|
45
|
+
/**
|
|
46
|
+
* The text of what renders in the shadow root, whitespace collapsed. The CSS in a `<style>`
|
|
47
|
+
* (such as the copies `@includeStyles` brings in) and the code in a `<script>` aren't text a
|
|
48
|
+
* reader sees, so they're left out.
|
|
49
|
+
*/
|
|
50
|
+
get text(): string;
|
|
51
|
+
/** The style sheets that apply in the shadow root: its own and the ones it adopted. */
|
|
52
|
+
get styleSheetCount(): number;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=shadowed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadowed.d.ts","sourceRoot":"","sources":["../src/shadowed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,4DAA4D;AAC5D,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;AAMhC;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAE1E;AAED,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAO1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAI/D;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAa;IAEtC,0FAA0F;IAC1F,IAAI,IAAI,IAAI,WAAW,CAItB;IAED,uBAAuB;IACvB,IAAI,UAAU,IAAI,UAAU,CAE3B;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,2EAA2E;IAC3E,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAIlE,4DAA4D;IAC5D,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,EAAE;IAIhE;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAUjB;IAED,uFAAuF;IACvF,IAAI,eAAe,IAAI,MAAM,CAE5B;CACF"}
|
package/dist/shadowed.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { isString } from '@sindresorhus/is';
|
|
2
|
+
import { find, getRootElement } from '@ember/test-helpers';
|
|
3
|
+
import { Harness } from "./harness.js";
|
|
4
|
+
function resolve(target) {
|
|
5
|
+
return isString(target) ? find(target) : target;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The first element matching `query` in the shadow root of `root` (an element, or a selector),
|
|
9
|
+
* or `null` when there is no such root or element. It is ember-primitives' `findInShadow`.
|
|
10
|
+
*
|
|
11
|
+
* assert.dom(findInShadow('[data-preview]', 'h1')).hasText('Welcome')
|
|
12
|
+
*/
|
|
13
|
+
export function findInShadow(root, query) {
|
|
14
|
+
return resolve(root)?.shadowRoot?.querySelector(query) ?? null;
|
|
15
|
+
}
|
|
16
|
+
/** Whether an element has a shadow root (an open one). It is ember-primitives' `hasShadowRoot`. */
|
|
17
|
+
export function hasShadowRoot(element) {
|
|
18
|
+
return Boolean(element.shadowRoot);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The first element with a shadow root inside `root` (an element or a selector), or inside the
|
|
22
|
+
* test's root without one. It is ember-primitives' `findShadow`.
|
|
23
|
+
*/
|
|
24
|
+
export function findShadow(root) {
|
|
25
|
+
const scope = root === undefined ? getRootElement() : resolve(root);
|
|
26
|
+
if (!scope)
|
|
27
|
+
return null;
|
|
28
|
+
for (const element of scope.querySelectorAll('*')) {
|
|
29
|
+
if (element.shadowRoot)
|
|
30
|
+
return element;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The first element matching `query` in the first shadow root in the test. Use `findInShadow`
|
|
36
|
+
* when there are several. It is ember-primitives' `findInFirstShadow`.
|
|
37
|
+
*/
|
|
38
|
+
export function findInFirstShadow(query) {
|
|
39
|
+
const host = findShadow();
|
|
40
|
+
if (!host)
|
|
41
|
+
throw new Error('Joinery: findInFirstShadow found no element with a shadow root');
|
|
42
|
+
return findInShadow(host, query);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Drives a `<Shadowed>` from `@ember-joinery/primitives/shadowed`: its shadow root, and what is
|
|
46
|
+
* rendered there. Harnesses don't look into shadow roots, so find what's inside through this.
|
|
47
|
+
*
|
|
48
|
+
* const preview = new ShadowedHarness('preview') // <Shadowed @name="preview">
|
|
49
|
+
* assert.dom(preview.query('h1')).hasText('Welcome')
|
|
50
|
+
*/
|
|
51
|
+
export class ShadowedHarness extends Harness {
|
|
52
|
+
static component = 'shadowed';
|
|
53
|
+
/** The element the shadow root is attached to: the `<div>` inside the component's own. */
|
|
54
|
+
get host() {
|
|
55
|
+
const host = [...this.element.children].find(child => child.shadowRoot);
|
|
56
|
+
if (!host)
|
|
57
|
+
throw new Error(`Joinery harness: ${this} has no shadow root`);
|
|
58
|
+
return host;
|
|
59
|
+
}
|
|
60
|
+
/** The shadow root. */
|
|
61
|
+
get shadowRoot() {
|
|
62
|
+
return this.host.shadowRoot;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The element the content renders in, inside the shadow root. With `@includeStyles`, it
|
|
66
|
+
* starts with the copies of the page's `<style>` and `<link>` elements.
|
|
67
|
+
*/
|
|
68
|
+
get content() {
|
|
69
|
+
return this.shadowRoot.lastElementChild;
|
|
70
|
+
}
|
|
71
|
+
/** The first element in the shadow root matching `selector`, or `null`. */
|
|
72
|
+
query(selector) {
|
|
73
|
+
return this.shadowRoot.querySelector(selector);
|
|
74
|
+
}
|
|
75
|
+
/** Every element in the shadow root matching `selector`. */
|
|
76
|
+
queryAll(selector) {
|
|
77
|
+
return [...this.shadowRoot.querySelectorAll(selector)];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The text of what renders in the shadow root, whitespace collapsed. The CSS in a `<style>`
|
|
81
|
+
* (such as the copies `@includeStyles` brings in) and the code in a `<script>` aren't text a
|
|
82
|
+
* reader sees, so they're left out.
|
|
83
|
+
*/
|
|
84
|
+
get text() {
|
|
85
|
+
const walker = this.shadowRoot.ownerDocument.createTreeWalker(this.content, NodeFilter.SHOW_TEXT);
|
|
86
|
+
let text = '';
|
|
87
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
88
|
+
if (!node.parentElement?.closest('style, script'))
|
|
89
|
+
text += node.nodeValue;
|
|
90
|
+
}
|
|
91
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
92
|
+
}
|
|
93
|
+
/** The style sheets that apply in the shadow root: its own and the ones it adopted. */
|
|
94
|
+
get styleSheetCount() {
|
|
95
|
+
return this.shadowRoot.styleSheets.length + this.shadowRoot.adoptedStyleSheets.length;
|
|
96
|
+
}
|
|
97
|
+
}
|
package/dist/sheet.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DialogHarness } from './dialog.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Sheet>`: a dialog that slides in from an edge of the screen.
|
|
4
|
+
*
|
|
5
|
+
* const sheet = new SheetHarness()
|
|
6
|
+
* await sheet.open()
|
|
7
|
+
* assert.strictEqual(sheet.side, 'right')
|
|
8
|
+
*/
|
|
9
|
+
export declare class SheetHarness extends DialogHarness {
|
|
10
|
+
static component: string;
|
|
11
|
+
/** The edge it comes in from: `top`, `right`, `bottom` or `left` (`data-side`). */
|
|
12
|
+
get side(): string | null;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../src/sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,aAAa;IAC7C,OAAgB,SAAS,SAAU;IAEnC,mFAAmF;IACnF,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;CACF"}
|
package/dist/sheet.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DialogHarness } from "./dialog.js";
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Sheet>`: a dialog that slides in from an edge of the screen.
|
|
4
|
+
*
|
|
5
|
+
* const sheet = new SheetHarness()
|
|
6
|
+
* await sheet.open()
|
|
7
|
+
* assert.strictEqual(sheet.side, 'right')
|
|
8
|
+
*/
|
|
9
|
+
export class SheetHarness extends DialogHarness {
|
|
10
|
+
static component = 'sheet';
|
|
11
|
+
/** The edge it comes in from: `top`, `right`, `bottom` or `left` (`data-side`). */
|
|
12
|
+
get side() {
|
|
13
|
+
return this.content?.getAttribute('data-side') ?? null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -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":"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"}
|