@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
package/dist/page.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Page>` from `@ember-joinery/ember`: reads its title and description, and reaches
|
|
4
|
+
* its parts.
|
|
5
|
+
*
|
|
6
|
+
* const page = new PageHarness('contacts') // <Page @name="contacts">
|
|
7
|
+
* assert.strictEqual(page.title, 'Contacts')
|
|
8
|
+
* await page.find(ButtonHarness, 'add').click()
|
|
9
|
+
*
|
|
10
|
+
* A page wraps a screen's content, so the parts inside it still belong to the components around
|
|
11
|
+
* them; its own parts are found by their `data-jn-page-*` attributes. A page object can extend
|
|
12
|
+
* this class and declare the screen's components with `@child`.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PageHarness extends Harness {
|
|
15
|
+
#private;
|
|
16
|
+
static component: string;
|
|
17
|
+
/** Its `@variant`: `panel` or `settings`. */
|
|
18
|
+
get variant(): string | null;
|
|
19
|
+
/** Its title's text, or `''` without one. */
|
|
20
|
+
get title(): string;
|
|
21
|
+
/** Its description's text, or `''` without one. */
|
|
22
|
+
get description(): string;
|
|
23
|
+
/** Whether its header stays at the top while the body scrolls. */
|
|
24
|
+
get isHeaderSticky(): boolean;
|
|
25
|
+
/** The header. Throws when it has none. */
|
|
26
|
+
get header(): HTMLElement;
|
|
27
|
+
/** The nav, before the title. Throws when it has none. */
|
|
28
|
+
get nav(): HTMLElement;
|
|
29
|
+
/** The title's element. Throws when it has none. */
|
|
30
|
+
get titleElement(): HTMLElement;
|
|
31
|
+
/** The actions' container. Throws when it has none. */
|
|
32
|
+
get actions(): HTMLElement;
|
|
33
|
+
/** The row under the header's text. Throws when it has none. */
|
|
34
|
+
get headerFooter(): HTMLElement;
|
|
35
|
+
/** The body. Throws when it has none. */
|
|
36
|
+
get body(): HTMLElement;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC;;;;;;;;;;;GAWG;AACH,qBAAa,WAAY,SAAQ,OAAO;;IACtC,OAAgB,SAAS,SAAS;IAclC,6CAA6C;IAC7C,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,6CAA6C;IAC7C,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,mDAAmD;IACnD,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,kEAAkE;IAClE,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,2CAA2C;IAC3C,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,0DAA0D;IAC1D,IAAI,GAAG,IAAI,WAAW,CAErB;IAED,oDAAoD;IACpD,IAAI,YAAY,IAAI,WAAW,CAE9B;IAED,uDAAuD;IACvD,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,gEAAgE;IAChE,IAAI,YAAY,IAAI,WAAW,CAE9B;IAED,yCAAyC;IACzC,IAAI,IAAI,IAAI,WAAW,CAEtB;CACF"}
|
package/dist/page.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Harness } from "./harness.js";
|
|
2
|
+
function text(element) {
|
|
3
|
+
return (element?.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Drives a `<Page>` from `@ember-joinery/ember`: reads its title and description, and reaches
|
|
7
|
+
* its parts.
|
|
8
|
+
*
|
|
9
|
+
* const page = new PageHarness('contacts') // <Page @name="contacts">
|
|
10
|
+
* assert.strictEqual(page.title, 'Contacts')
|
|
11
|
+
* await page.find(ButtonHarness, 'add').click()
|
|
12
|
+
*
|
|
13
|
+
* A page wraps a screen's content, so the parts inside it still belong to the components around
|
|
14
|
+
* them; its own parts are found by their `data-jn-page-*` attributes. A page object can extend
|
|
15
|
+
* this class and declare the screen's components with `@child`.
|
|
16
|
+
*/
|
|
17
|
+
export class PageHarness extends Harness {
|
|
18
|
+
static component = 'page';
|
|
19
|
+
#query(part) {
|
|
20
|
+
return this.element.querySelector(`:scope > [data-jn-page-${part}], :scope > [data-jn-page-header] > [data-jn-page-${part}]`);
|
|
21
|
+
}
|
|
22
|
+
#part(part) {
|
|
23
|
+
const element = this.#query(part);
|
|
24
|
+
if (!element)
|
|
25
|
+
throw new Error(`Joinery harness: no ${part} in ${this}`);
|
|
26
|
+
return element;
|
|
27
|
+
}
|
|
28
|
+
/** Its `@variant`: `panel` or `settings`. */
|
|
29
|
+
get variant() {
|
|
30
|
+
return this.element.getAttribute('data-variant');
|
|
31
|
+
}
|
|
32
|
+
/** Its title's text, or `''` without one. */
|
|
33
|
+
get title() {
|
|
34
|
+
return text(this.#query('title'));
|
|
35
|
+
}
|
|
36
|
+
/** Its description's text, or `''` without one. */
|
|
37
|
+
get description() {
|
|
38
|
+
return text(this.#query('description'));
|
|
39
|
+
}
|
|
40
|
+
/** Whether its header stays at the top while the body scrolls. */
|
|
41
|
+
get isHeaderSticky() {
|
|
42
|
+
return this.#query('header')?.hasAttribute('data-sticky') ?? false;
|
|
43
|
+
}
|
|
44
|
+
/** The header. Throws when it has none. */
|
|
45
|
+
get header() {
|
|
46
|
+
return this.#part('header');
|
|
47
|
+
}
|
|
48
|
+
/** The nav, before the title. Throws when it has none. */
|
|
49
|
+
get nav() {
|
|
50
|
+
return this.#part('nav');
|
|
51
|
+
}
|
|
52
|
+
/** The title's element. Throws when it has none. */
|
|
53
|
+
get titleElement() {
|
|
54
|
+
return this.#part('title');
|
|
55
|
+
}
|
|
56
|
+
/** The actions' container. Throws when it has none. */
|
|
57
|
+
get actions() {
|
|
58
|
+
return this.#part('actions');
|
|
59
|
+
}
|
|
60
|
+
/** The row under the header's text. Throws when it has none. */
|
|
61
|
+
get headerFooter() {
|
|
62
|
+
return this.#part('header-footer');
|
|
63
|
+
}
|
|
64
|
+
/** The body. Throws when it has none. */
|
|
65
|
+
get body() {
|
|
66
|
+
return this.#part('body');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Pagination>` from `@ember-joinery/ember`: its page links, the previous and next
|
|
4
|
+
* links, and the current page, read through `aria-current` as a screen reader reads it.
|
|
5
|
+
*
|
|
6
|
+
* const pages = new PaginationHarness()
|
|
7
|
+
* assert.deepEqual(pages.pages, ['1', '2', '3'])
|
|
8
|
+
* assert.strictEqual(pages.current, '2')
|
|
9
|
+
* await pages.goTo('3')
|
|
10
|
+
* await pages.goToNext()
|
|
11
|
+
*/
|
|
12
|
+
export declare class PaginationHarness extends Harness {
|
|
13
|
+
static component: string;
|
|
14
|
+
/** Its accessible name, the `nav`'s `aria-label`. */
|
|
15
|
+
get label(): string;
|
|
16
|
+
/** The page links, in order (not the previous and next links). */
|
|
17
|
+
get pageElements(): HTMLElement[];
|
|
18
|
+
/** The text of each page link, in order: the page numbers. */
|
|
19
|
+
get pages(): string[];
|
|
20
|
+
/** The current page's text (the link with `aria-current="page"`), or `null` with none. */
|
|
21
|
+
get current(): string | null;
|
|
22
|
+
/** The previous page's link. Throws when there is none. */
|
|
23
|
+
get previous(): HTMLElement;
|
|
24
|
+
/** The next page's link. Throws when there is none. */
|
|
25
|
+
get next(): HTMLElement;
|
|
26
|
+
/** Whether some pages are left out, shown as an ellipsis. */
|
|
27
|
+
get hasEllipsis(): boolean;
|
|
28
|
+
/** The link to the page whose text is `page`. Throws when there is none. */
|
|
29
|
+
page(page: string): HTMLElement;
|
|
30
|
+
/** Whether the page whose text is `page` is the current one. */
|
|
31
|
+
isCurrent(page: string): boolean;
|
|
32
|
+
/** Clicks the link to the page whose text is `page`, as a user would. */
|
|
33
|
+
goTo(page: string): Promise<void>;
|
|
34
|
+
/** Clicks the previous page's link. */
|
|
35
|
+
goToPrevious(): Promise<void>;
|
|
36
|
+
/** Clicks the next page's link. */
|
|
37
|
+
goToNext(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAOtC;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,OAAgB,SAAS,SAAe;IAExC,qDAAqD;IACrD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,kEAAkE;IAClE,IAAI,YAAY,IAAI,WAAW,EAAE,CAEhC;IAED,8DAA8D;IAC9D,IAAI,KAAK,IAAI,MAAM,EAAE,CAEpB;IAED,0FAA0F;IAC1F,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAG3B;IAED,2DAA2D;IAC3D,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED,uDAAuD;IACvD,IAAI,IAAI,IAAI,WAAW,CAEtB;IAED,6DAA6D;IAC7D,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,4EAA4E;IAC5E,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;IAO/B,gEAAgE;IAChE,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIhC,yEAAyE;IACnE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,uCAAuC;IACjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,mCAAmC;IAC7B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { click } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { NotFoundError } from "./-private/tree.js";
|
|
4
|
+
function text(element) {
|
|
5
|
+
return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Drives a `<Pagination>` from `@ember-joinery/ember`: its page links, the previous and next
|
|
9
|
+
* links, and the current page, read through `aria-current` as a screen reader reads it.
|
|
10
|
+
*
|
|
11
|
+
* const pages = new PaginationHarness()
|
|
12
|
+
* assert.deepEqual(pages.pages, ['1', '2', '3'])
|
|
13
|
+
* assert.strictEqual(pages.current, '2')
|
|
14
|
+
* await pages.goTo('3')
|
|
15
|
+
* await pages.goToNext()
|
|
16
|
+
*/
|
|
17
|
+
export class PaginationHarness extends Harness {
|
|
18
|
+
static component = 'pagination';
|
|
19
|
+
/** Its accessible name, the `nav`'s `aria-label`. */
|
|
20
|
+
get label() {
|
|
21
|
+
return this.element.getAttribute('aria-label') ?? '';
|
|
22
|
+
}
|
|
23
|
+
/** The page links, in order (not the previous and next links). */
|
|
24
|
+
get pageElements() {
|
|
25
|
+
return this.parts('link');
|
|
26
|
+
}
|
|
27
|
+
/** The text of each page link, in order: the page numbers. */
|
|
28
|
+
get pages() {
|
|
29
|
+
return this.pageElements.map(text);
|
|
30
|
+
}
|
|
31
|
+
/** The current page's text (the link with `aria-current="page"`), or `null` with none. */
|
|
32
|
+
get current() {
|
|
33
|
+
const current = this.pageElements.find(link => link.getAttribute('aria-current') === 'page');
|
|
34
|
+
return current ? text(current) : null;
|
|
35
|
+
}
|
|
36
|
+
/** The previous page's link. Throws when there is none. */
|
|
37
|
+
get previous() {
|
|
38
|
+
return this.part('previous');
|
|
39
|
+
}
|
|
40
|
+
/** The next page's link. Throws when there is none. */
|
|
41
|
+
get next() {
|
|
42
|
+
return this.part('next');
|
|
43
|
+
}
|
|
44
|
+
/** Whether some pages are left out, shown as an ellipsis. */
|
|
45
|
+
get hasEllipsis() {
|
|
46
|
+
return this.queryPart('ellipsis') !== null;
|
|
47
|
+
}
|
|
48
|
+
/** The link to the page whose text is `page`. Throws when there is none. */
|
|
49
|
+
page(page) {
|
|
50
|
+
const found = this.pageElements.find(link => text(link) === page);
|
|
51
|
+
if (!found)
|
|
52
|
+
throw new NotFoundError(`no page "${page}" in ${this} (it has ${this.pages.join(', ')})`);
|
|
53
|
+
return found;
|
|
54
|
+
}
|
|
55
|
+
/** Whether the page whose text is `page` is the current one. */
|
|
56
|
+
isCurrent(page) {
|
|
57
|
+
return this.page(page).getAttribute('aria-current') === 'page';
|
|
58
|
+
}
|
|
59
|
+
/** Clicks the link to the page whose text is `page`, as a user would. */
|
|
60
|
+
async goTo(page) {
|
|
61
|
+
await click(this.page(page));
|
|
62
|
+
}
|
|
63
|
+
/** Clicks the previous page's link. */
|
|
64
|
+
async goToPrevious() {
|
|
65
|
+
await click(this.previous);
|
|
66
|
+
}
|
|
67
|
+
/** Clicks the next page's link. */
|
|
68
|
+
async goToNext() {
|
|
69
|
+
await click(this.next);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Which kind of pointer moves. */
|
|
2
|
+
export interface HoverOptions {
|
|
3
|
+
/** `mouse` (the default), `pen` or `touch`. Tooltips and hover cards ignore a touch. */
|
|
4
|
+
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
5
|
+
}
|
|
6
|
+
/** Which way the pointer leaves an element, and how far it goes. */
|
|
7
|
+
export interface UnhoverOptions extends HoverOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The side it leaves through. Default: the side away from where `away` is, or else `top`.
|
|
10
|
+
*/
|
|
11
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
12
|
+
/**
|
|
13
|
+
* An element it moves away from, such as a tooltip: it leaves through the side facing away
|
|
14
|
+
* from it, and so out of the grace area between the two.
|
|
15
|
+
*/
|
|
16
|
+
away?: Element | null;
|
|
17
|
+
/** How far past the edge it ends up, in pixels. Default 40. */
|
|
18
|
+
distance?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Moves the pointer onto an element and rests it there, as a mouse does: `pointerover`,
|
|
22
|
+
* `pointerenter`, `mouseover` and `mouseenter`, then `pointermove` and `mousemove`, at its
|
|
23
|
+
* centre. `click()` sends none of them. It waits for what that sets off, such as a tooltip's
|
|
24
|
+
* open delay.
|
|
25
|
+
*
|
|
26
|
+
* await hover(tooltip.trigger)
|
|
27
|
+
*/
|
|
28
|
+
export declare function hover(target: Element, options?: HoverOptions): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Moves the pointer off an element, as a mouse does: `pointerout`, `pointerleave`, `mouseout`
|
|
31
|
+
* and `mouseleave` where it crosses the edge, then a `pointermove` and `mousemove` on whatever
|
|
32
|
+
* is under it further on. Give `away` (a tooltip, say) to leave through the side facing away
|
|
33
|
+
* from it. It waits for what that sets off, such as a hover card's close delay.
|
|
34
|
+
*
|
|
35
|
+
* await unhover(tooltip.trigger, { away: tooltip.content })
|
|
36
|
+
*/
|
|
37
|
+
export declare function unhover(target: Element, options?: UnhoverOptions): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../src/pointer.ts"],"names":[],"mappings":"AAEA,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,wFAAwF;IACxF,WAAW,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,CAAA;CACxC;AAED,oEAAoE;AACpE,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IAC1C;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AA4BD;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAStF;AAUD;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B1F"}
|
package/dist/pointer.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { settled } from '@ember/test-helpers';
|
|
2
|
+
function pointer(type, target, point, { pointerType = 'mouse' }, bubbles = true) {
|
|
3
|
+
const init = {
|
|
4
|
+
bubbles,
|
|
5
|
+
cancelable: true,
|
|
6
|
+
composed: true,
|
|
7
|
+
view: window,
|
|
8
|
+
clientX: point.x,
|
|
9
|
+
clientY: point.y,
|
|
10
|
+
};
|
|
11
|
+
const event = type.startsWith('pointer')
|
|
12
|
+
? new PointerEvent(type, { ...init, pointerType, isPrimary: true, pointerId: 1 })
|
|
13
|
+
: new MouseEvent(type, init);
|
|
14
|
+
target.dispatchEvent(event);
|
|
15
|
+
}
|
|
16
|
+
function centre(element) {
|
|
17
|
+
const rect = element.getBoundingClientRect();
|
|
18
|
+
return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Moves the pointer onto an element and rests it there, as a mouse does: `pointerover`,
|
|
22
|
+
* `pointerenter`, `mouseover` and `mouseenter`, then `pointermove` and `mousemove`, at its
|
|
23
|
+
* centre. `click()` sends none of them. It waits for what that sets off, such as a tooltip's
|
|
24
|
+
* open delay.
|
|
25
|
+
*
|
|
26
|
+
* await hover(tooltip.trigger)
|
|
27
|
+
*/
|
|
28
|
+
export async function hover(target, options = {}) {
|
|
29
|
+
const point = centre(target);
|
|
30
|
+
pointer('pointerover', target, point, options);
|
|
31
|
+
pointer('pointerenter', target, point, options, false);
|
|
32
|
+
pointer('mouseover', target, point, options);
|
|
33
|
+
pointer('mouseenter', target, point, options, false);
|
|
34
|
+
pointer('pointermove', target, point, options);
|
|
35
|
+
pointer('mousemove', target, point, options);
|
|
36
|
+
await settled();
|
|
37
|
+
}
|
|
38
|
+
/** The side of `from` that faces away from `away`. */
|
|
39
|
+
function sideAwayFrom(from, away) {
|
|
40
|
+
const dx = away.left + away.width / 2 - (from.left + from.width / 2);
|
|
41
|
+
const dy = away.top + away.height / 2 - (from.top + from.height / 2);
|
|
42
|
+
if (Math.abs(dy) >= Math.abs(dx))
|
|
43
|
+
return dy > 0 ? 'top' : 'bottom';
|
|
44
|
+
return dx > 0 ? 'left' : 'right';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Moves the pointer off an element, as a mouse does: `pointerout`, `pointerleave`, `mouseout`
|
|
48
|
+
* and `mouseleave` where it crosses the edge, then a `pointermove` and `mousemove` on whatever
|
|
49
|
+
* is under it further on. Give `away` (a tooltip, say) to leave through the side facing away
|
|
50
|
+
* from it. It waits for what that sets off, such as a hover card's close delay.
|
|
51
|
+
*
|
|
52
|
+
* await unhover(tooltip.trigger, { away: tooltip.content })
|
|
53
|
+
*/
|
|
54
|
+
export async function unhover(target, options = {}) {
|
|
55
|
+
const rect = target.getBoundingClientRect();
|
|
56
|
+
const side = options.side ??
|
|
57
|
+
(options.away ? sideAwayFrom(rect, options.away.getBoundingClientRect()) : 'top');
|
|
58
|
+
const distance = options.distance ?? 40;
|
|
59
|
+
const { x, y } = centre(target);
|
|
60
|
+
const edge = {
|
|
61
|
+
top: { x, y: rect.top },
|
|
62
|
+
bottom: { x, y: rect.bottom },
|
|
63
|
+
left: { x: rect.left, y },
|
|
64
|
+
right: { x: rect.right, y },
|
|
65
|
+
}[side];
|
|
66
|
+
const step = {
|
|
67
|
+
top: { x: 0, y: -1 },
|
|
68
|
+
bottom: { x: 0, y: 1 },
|
|
69
|
+
left: { x: -1, y: 0 },
|
|
70
|
+
right: { x: 1, y: 0 },
|
|
71
|
+
}[side];
|
|
72
|
+
const exit = { x: edge.x + step.x, y: edge.y + step.y };
|
|
73
|
+
const beyond = { x: edge.x + step.x * distance, y: edge.y + step.y * distance };
|
|
74
|
+
pointer('pointerout', target, exit, options);
|
|
75
|
+
pointer('pointerleave', target, exit, options, false);
|
|
76
|
+
pointer('mouseout', target, exit, options);
|
|
77
|
+
pointer('mouseleave', target, exit, options, false);
|
|
78
|
+
const under = document.elementFromPoint(beyond.x, beyond.y) ?? document.body;
|
|
79
|
+
pointer('pointermove', under, beyond, options);
|
|
80
|
+
pointer('mousemove', under, beyond, options);
|
|
81
|
+
await settled();
|
|
82
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Popover>` from `@ember-joinery/ember` or `@ember-joinery/primitives/popover`. It
|
|
4
|
+
* reads the state from the trigger's ARIA (`aria-expanded`) and the content's, and acts as a
|
|
5
|
+
* user does: a click on the trigger, Escape, a press outside.
|
|
6
|
+
*
|
|
7
|
+
* const popover = new PopoverHarness('dimensions') // <Popover @name="dimensions">
|
|
8
|
+
* await popover.open()
|
|
9
|
+
* assert.strictEqual(popover.label, 'Dimensions')
|
|
10
|
+
* await popover.pressEscape()
|
|
11
|
+
* assert.false(popover.isOpen)
|
|
12
|
+
*/
|
|
13
|
+
export declare class PopoverHarness extends Harness {
|
|
14
|
+
static component: string;
|
|
15
|
+
/** The trigger: the `Trigger` part, or your own element with the `trigger` modifier. */
|
|
16
|
+
get trigger(): HTMLElement;
|
|
17
|
+
/** The content, or `null` while it isn't rendered. */
|
|
18
|
+
get content(): HTMLElement | null;
|
|
19
|
+
/** Whether it is open, from the trigger's `aria-expanded`. */
|
|
20
|
+
get isOpen(): boolean;
|
|
21
|
+
/** Whether the content is showing in the browser's top layer. */
|
|
22
|
+
get isShown(): boolean;
|
|
23
|
+
/** The content's accessible name: its Title, or else its trigger, or your `aria-label`. */
|
|
24
|
+
get label(): string;
|
|
25
|
+
/** The content's accessible description: its Description's text, or `''`. */
|
|
26
|
+
get description(): string;
|
|
27
|
+
/** The Title's text, or `''`. */
|
|
28
|
+
get title(): string;
|
|
29
|
+
/** The content's text, whitespace collapsed. */
|
|
30
|
+
get text(): string;
|
|
31
|
+
/** The side the content was placed on, after any flip (`data-side`). */
|
|
32
|
+
get side(): string | null;
|
|
33
|
+
/** The content's alignment along that side (`data-align`). */
|
|
34
|
+
get align(): string | null;
|
|
35
|
+
/** The arrow's element (Radix's arrow is a `<span>` around an `<svg>`), or `null`. */
|
|
36
|
+
get arrow(): HTMLElement | null;
|
|
37
|
+
/** Clicks the trigger. */
|
|
38
|
+
toggle(): Promise<void>;
|
|
39
|
+
/** Opens it with a click on the trigger, unless it is open. */
|
|
40
|
+
open(): Promise<void>;
|
|
41
|
+
/** Closes it with a click on the trigger, unless it is closed. */
|
|
42
|
+
close(): Promise<void>;
|
|
43
|
+
/** Clicks its Close part (the first, if there are several). */
|
|
44
|
+
clickClose(): Promise<void>;
|
|
45
|
+
/** Presses Escape where focus is. */
|
|
46
|
+
pressEscape(): Promise<void>;
|
|
47
|
+
/** A press outside the popover, as a user dismissing it makes. */
|
|
48
|
+
pressOutside(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../src/popover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAItC;;;;;;;;;;GAUG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACzC,OAAgB,SAAS,SAAY;IAErC,wFAAwF;IACxF,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,sDAAsD;IACtD,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,8DAA8D;IAC9D,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,iEAAiE;IACjE,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,2FAA2F;IAC3F,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,6EAA6E;IAC7E,IAAI,WAAW,IAAI,MAAM,CAGxB;IAED,iCAAiC;IACjC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,gDAAgD;IAChD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,wEAAwE;IACxE,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,8DAA8D;IAC9D,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,sFAAsF;IACtF,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED,0BAA0B;IACpB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,+DAA+D;IACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,kEAAkE;IAC5D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,+DAA+D;IACzD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,qCAAqC;IAC/B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC,kEAAkE;IAC5D,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
|
package/dist/popover.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { click } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { pressEscape, pressOutside } from "./layers.js";
|
|
4
|
+
import { accessibleDescription, accessibleName, shownInTopLayer, text } from "./-private/overlay.js";
|
|
5
|
+
/**
|
|
6
|
+
* Drives a `<Popover>` from `@ember-joinery/ember` or `@ember-joinery/primitives/popover`. It
|
|
7
|
+
* reads the state from the trigger's ARIA (`aria-expanded`) and the content's, and acts as a
|
|
8
|
+
* user does: a click on the trigger, Escape, a press outside.
|
|
9
|
+
*
|
|
10
|
+
* const popover = new PopoverHarness('dimensions') // <Popover @name="dimensions">
|
|
11
|
+
* await popover.open()
|
|
12
|
+
* assert.strictEqual(popover.label, 'Dimensions')
|
|
13
|
+
* await popover.pressEscape()
|
|
14
|
+
* assert.false(popover.isOpen)
|
|
15
|
+
*/
|
|
16
|
+
export class PopoverHarness extends Harness {
|
|
17
|
+
static component = 'popover';
|
|
18
|
+
/** The trigger: the `Trigger` part, or your own element with the `trigger` modifier. */
|
|
19
|
+
get trigger() {
|
|
20
|
+
return this.part('trigger');
|
|
21
|
+
}
|
|
22
|
+
/** The content, or `null` while it isn't rendered. */
|
|
23
|
+
get content() {
|
|
24
|
+
return this.queryPart('content');
|
|
25
|
+
}
|
|
26
|
+
/** Whether it is open, from the trigger's `aria-expanded`. */
|
|
27
|
+
get isOpen() {
|
|
28
|
+
return this.trigger.getAttribute('aria-expanded') === 'true';
|
|
29
|
+
}
|
|
30
|
+
/** Whether the content is showing in the browser's top layer. */
|
|
31
|
+
get isShown() {
|
|
32
|
+
return shownInTopLayer(this.content);
|
|
33
|
+
}
|
|
34
|
+
/** The content's accessible name: its Title, or else its trigger, or your `aria-label`. */
|
|
35
|
+
get label() {
|
|
36
|
+
const content = this.content;
|
|
37
|
+
return content ? accessibleName(content) : '';
|
|
38
|
+
}
|
|
39
|
+
/** The content's accessible description: its Description's text, or `''`. */
|
|
40
|
+
get description() {
|
|
41
|
+
const content = this.content;
|
|
42
|
+
return content ? accessibleDescription(content) : '';
|
|
43
|
+
}
|
|
44
|
+
/** The Title's text, or `''`. */
|
|
45
|
+
get title() {
|
|
46
|
+
return text(this.queryPart('title'));
|
|
47
|
+
}
|
|
48
|
+
/** The content's text, whitespace collapsed. */
|
|
49
|
+
get text() {
|
|
50
|
+
return text(this.content);
|
|
51
|
+
}
|
|
52
|
+
/** The side the content was placed on, after any flip (`data-side`). */
|
|
53
|
+
get side() {
|
|
54
|
+
return this.content?.getAttribute('data-side') ?? null;
|
|
55
|
+
}
|
|
56
|
+
/** The content's alignment along that side (`data-align`). */
|
|
57
|
+
get align() {
|
|
58
|
+
return this.content?.getAttribute('data-align') ?? null;
|
|
59
|
+
}
|
|
60
|
+
/** The arrow's element (Radix's arrow is a `<span>` around an `<svg>`), or `null`. */
|
|
61
|
+
get arrow() {
|
|
62
|
+
return this.queryPart('arrow');
|
|
63
|
+
}
|
|
64
|
+
/** Clicks the trigger. */
|
|
65
|
+
async toggle() {
|
|
66
|
+
await click(this.trigger);
|
|
67
|
+
}
|
|
68
|
+
/** Opens it with a click on the trigger, unless it is open. */
|
|
69
|
+
async open() {
|
|
70
|
+
if (!this.isOpen)
|
|
71
|
+
await this.toggle();
|
|
72
|
+
}
|
|
73
|
+
/** Closes it with a click on the trigger, unless it is closed. */
|
|
74
|
+
async close() {
|
|
75
|
+
if (this.isOpen)
|
|
76
|
+
await this.toggle();
|
|
77
|
+
}
|
|
78
|
+
/** Clicks its Close part (the first, if there are several). */
|
|
79
|
+
async clickClose() {
|
|
80
|
+
await click(this.part('close'));
|
|
81
|
+
}
|
|
82
|
+
/** Presses Escape where focus is. */
|
|
83
|
+
async pressEscape() {
|
|
84
|
+
await pressEscape();
|
|
85
|
+
}
|
|
86
|
+
/** A press outside the popover, as a user dismissing it makes. */
|
|
87
|
+
async pressOutside() {
|
|
88
|
+
await pressOutside();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Progress>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/progress`.
|
|
4
|
+
* Everything comes from its `progressbar` ARIA, as assistive technology reads it, and its
|
|
5
|
+
* `data-state`.
|
|
6
|
+
*
|
|
7
|
+
* const upload = new ProgressHarness('upload') // <Progress @name="upload">
|
|
8
|
+
* assert.strictEqual(upload.value, 66)
|
|
9
|
+
* assert.strictEqual(upload.valueText, '66%')
|
|
10
|
+
*/
|
|
11
|
+
export declare class ProgressHarness extends Harness {
|
|
12
|
+
static component: string;
|
|
13
|
+
/** The bar that shows how far along it is (`data-test-jn-part="indicator"`). */
|
|
14
|
+
get indicator(): HTMLElement;
|
|
15
|
+
/** Its value (`aria-valuenow`), or `null` while it is indeterminate. */
|
|
16
|
+
get value(): number | null;
|
|
17
|
+
/** Its maximum (`aria-valuemax`): 100 unless given `@max`. */
|
|
18
|
+
get max(): number;
|
|
19
|
+
/** Its minimum (`aria-valuemin`), always 0. */
|
|
20
|
+
get min(): number;
|
|
21
|
+
/** What assistive technology announces for the value (`aria-valuetext`): `66%` by default. */
|
|
22
|
+
get valueText(): string | null;
|
|
23
|
+
/** How far along it is, from 0 to 100, or `null` while it is indeterminate. */
|
|
24
|
+
get percent(): number | null;
|
|
25
|
+
/** Radix's `data-state`: `indeterminate` (no value), `loading`, or `complete` (at its max). */
|
|
26
|
+
get state(): string | null;
|
|
27
|
+
/** Whether it has no value, so it shows no particular progress. */
|
|
28
|
+
get isIndeterminate(): boolean;
|
|
29
|
+
/** Whether its value is its max. */
|
|
30
|
+
get isComplete(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Its accessible name: `aria-label`, else the text of the elements `aria-labelledby` names.
|
|
33
|
+
* A `<label for>` doesn't name a progress bar (it isn't a form control), so give it one of
|
|
34
|
+
* those.
|
|
35
|
+
*/
|
|
36
|
+
get label(): string;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAYtC;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAa;IAEtC,gFAAgF;IAChF,IAAI,SAAS,IAAI,WAAW,CAE3B;IAED,wEAAwE;IACxE,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,8DAA8D;IAC9D,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,+CAA+C;IAC/C,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,8FAA8F;IAC9F,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;IAED,+EAA+E;IAC/E,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAI3B;IAED,+FAA+F;IAC/F,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,mEAAmE;IACnE,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,oCAAoC;IACpC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;;;OAIG;IACH,IAAI,KAAK,IAAI,MAAM,CAYlB;CACF"}
|
package/dist/progress.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Harness } from "./harness.js";
|
|
2
|
+
function text(element) {
|
|
3
|
+
return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
4
|
+
}
|
|
5
|
+
function numberOf(value) {
|
|
6
|
+
if (value === null || value.trim() === '')
|
|
7
|
+
return null;
|
|
8
|
+
const number = Number(value);
|
|
9
|
+
return Number.isNaN(number) ? null : number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Drives a `<Progress>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/progress`.
|
|
13
|
+
* Everything comes from its `progressbar` ARIA, as assistive technology reads it, and its
|
|
14
|
+
* `data-state`.
|
|
15
|
+
*
|
|
16
|
+
* const upload = new ProgressHarness('upload') // <Progress @name="upload">
|
|
17
|
+
* assert.strictEqual(upload.value, 66)
|
|
18
|
+
* assert.strictEqual(upload.valueText, '66%')
|
|
19
|
+
*/
|
|
20
|
+
export class ProgressHarness extends Harness {
|
|
21
|
+
static component = 'progress';
|
|
22
|
+
/** The bar that shows how far along it is (`data-test-jn-part="indicator"`). */
|
|
23
|
+
get indicator() {
|
|
24
|
+
return this.part('indicator');
|
|
25
|
+
}
|
|
26
|
+
/** Its value (`aria-valuenow`), or `null` while it is indeterminate. */
|
|
27
|
+
get value() {
|
|
28
|
+
return numberOf(this.element.getAttribute('aria-valuenow'));
|
|
29
|
+
}
|
|
30
|
+
/** Its maximum (`aria-valuemax`): 100 unless given `@max`. */
|
|
31
|
+
get max() {
|
|
32
|
+
return numberOf(this.element.getAttribute('aria-valuemax')) ?? 100;
|
|
33
|
+
}
|
|
34
|
+
/** Its minimum (`aria-valuemin`), always 0. */
|
|
35
|
+
get min() {
|
|
36
|
+
return numberOf(this.element.getAttribute('aria-valuemin')) ?? 0;
|
|
37
|
+
}
|
|
38
|
+
/** What assistive technology announces for the value (`aria-valuetext`): `66%` by default. */
|
|
39
|
+
get valueText() {
|
|
40
|
+
return this.element.getAttribute('aria-valuetext');
|
|
41
|
+
}
|
|
42
|
+
/** How far along it is, from 0 to 100, or `null` while it is indeterminate. */
|
|
43
|
+
get percent() {
|
|
44
|
+
const value = this.value;
|
|
45
|
+
if (value === null)
|
|
46
|
+
return null;
|
|
47
|
+
return Math.round(((value - this.min) / (this.max - this.min)) * 100 * 100) / 100;
|
|
48
|
+
}
|
|
49
|
+
/** Radix's `data-state`: `indeterminate` (no value), `loading`, or `complete` (at its max). */
|
|
50
|
+
get state() {
|
|
51
|
+
return this.element.getAttribute('data-state');
|
|
52
|
+
}
|
|
53
|
+
/** Whether it has no value, so it shows no particular progress. */
|
|
54
|
+
get isIndeterminate() {
|
|
55
|
+
return this.value === null;
|
|
56
|
+
}
|
|
57
|
+
/** Whether its value is its max. */
|
|
58
|
+
get isComplete() {
|
|
59
|
+
return this.value !== null && this.value === this.max;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Its accessible name: `aria-label`, else the text of the elements `aria-labelledby` names.
|
|
63
|
+
* A `<label for>` doesn't name a progress bar (it isn't a form control), so give it one of
|
|
64
|
+
* those.
|
|
65
|
+
*/
|
|
66
|
+
get label() {
|
|
67
|
+
const element = this.element;
|
|
68
|
+
const label = element.getAttribute('aria-label');
|
|
69
|
+
if (label)
|
|
70
|
+
return label.trim();
|
|
71
|
+
const labelledBy = element.getAttribute('aria-labelledby');
|
|
72
|
+
if (!labelledBy)
|
|
73
|
+
return '';
|
|
74
|
+
return labelledBy
|
|
75
|
+
.split(/\s+/)
|
|
76
|
+
.map(id => element.ownerDocument.getElementById(id))
|
|
77
|
+
.filter((found) => Boolean(found))
|
|
78
|
+
.map(text)
|
|
79
|
+
.join(' ');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/** How a pull goes. */
|
|
3
|
+
export interface PullOptions {
|
|
4
|
+
/** `touch` (the default), `pen` or `mouse`. A mouse does not pull. */
|
|
5
|
+
pointerType?: 'touch' | 'pen' | 'mouse';
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Drives a `<PullToRefresh>` from `@ember-joinery/ember`: reads its state and what it announces,
|
|
9
|
+
* and pulls it as a finger does.
|
|
10
|
+
*
|
|
11
|
+
* const feed = new PullToRefreshHarness('feed') // <PullToRefresh @name="feed">
|
|
12
|
+
* await feed.refresh()
|
|
13
|
+
* assert.true(feed.isRefreshing)
|
|
14
|
+
* assert.strictEqual(feed.announcement, 'Refreshing')
|
|
15
|
+
*
|
|
16
|
+
* It wraps the content, so the parts inside it still belong to the components around them; its
|
|
17
|
+
* own elements are found by their `data-jn-pull-to-refresh-*` attributes.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PullToRefreshHarness extends Harness {
|
|
20
|
+
#private;
|
|
21
|
+
static component: string;
|
|
22
|
+
/** Its state: `idle`, `pulling`, `armed` or `refreshing`. */
|
|
23
|
+
get state(): string | null;
|
|
24
|
+
/** Whether a refresh is in progress. */
|
|
25
|
+
get isRefreshing(): boolean;
|
|
26
|
+
/** What its live region says: `Refreshing`, then `Updated`, or `''`. */
|
|
27
|
+
get announcement(): string;
|
|
28
|
+
/** The indicator at the top. */
|
|
29
|
+
get indicator(): HTMLElement;
|
|
30
|
+
/** The live region. */
|
|
31
|
+
get status(): HTMLElement;
|
|
32
|
+
/**
|
|
33
|
+
* Pulls it down by `distance` pixels of finger movement, then releases. The indicator moves
|
|
34
|
+
* half as far, so a pull refreshes when `distance` is twice the threshold or more.
|
|
35
|
+
*/
|
|
36
|
+
pull(distance: number, { pointerType }?: PullOptions): Promise<void>;
|
|
37
|
+
/** Pulls it far enough to refresh. */
|
|
38
|
+
refresh(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=pull-to-refresh.d.ts.map
|