@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
package/dist/dialog.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { click, settled } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { isInTopLayer, pressEscape, pressOutside } from "./layers.js";
|
|
4
|
+
function text(element) {
|
|
5
|
+
return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
6
|
+
}
|
|
7
|
+
/** The text of the elements an `aria-labelledby` or `aria-describedby` names, joined. */
|
|
8
|
+
function textOf(element, attribute) {
|
|
9
|
+
const ids = element.getAttribute(attribute);
|
|
10
|
+
if (!ids)
|
|
11
|
+
return '';
|
|
12
|
+
return ids
|
|
13
|
+
.split(/\s+/)
|
|
14
|
+
.map(id => element.ownerDocument.getElementById(id))
|
|
15
|
+
.filter((found) => Boolean(found))
|
|
16
|
+
.map(text)
|
|
17
|
+
.join(' ');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Drives a `<Dialog>` from `@ember-joinery/ember` (or the headless one from
|
|
21
|
+
* `@ember-joinery/primitives/dialog`). It reads state through the trigger's `aria-expanded`
|
|
22
|
+
* and the content's role and ARIA, follows the content into the top layer, and acts as a user
|
|
23
|
+
* does: a click on the trigger, Escape, a press on the overlay.
|
|
24
|
+
*
|
|
25
|
+
* class EditProfile extends DialogHarness {
|
|
26
|
+
* static named = 'edit-profile'
|
|
27
|
+
* @child(ButtonHarness, 'save') declare save: ButtonHarness
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* const dialog = new EditProfile()
|
|
31
|
+
* await dialog.open()
|
|
32
|
+
* assert.strictEqual(dialog.label, 'Edit profile')
|
|
33
|
+
* await dialog.close()
|
|
34
|
+
* assert.dom(dialog.trigger).isFocused()
|
|
35
|
+
*/
|
|
36
|
+
export class DialogHarness extends Harness {
|
|
37
|
+
static component = 'dialog';
|
|
38
|
+
/** The trigger. Throws when the dialog has none (one you open yourself, with `@open`). */
|
|
39
|
+
get trigger() {
|
|
40
|
+
return this.part('trigger');
|
|
41
|
+
}
|
|
42
|
+
/** The content, or `null` while it is closed (it stays while it animates out). */
|
|
43
|
+
get content() {
|
|
44
|
+
return this.queryPart('content');
|
|
45
|
+
}
|
|
46
|
+
/** The overlay behind a modal dialog's content, or `null`. */
|
|
47
|
+
get overlay() {
|
|
48
|
+
return this.queryPart('overlay');
|
|
49
|
+
}
|
|
50
|
+
/** The title, or `null`. */
|
|
51
|
+
get title() {
|
|
52
|
+
return this.queryPart('title');
|
|
53
|
+
}
|
|
54
|
+
/** The description, or `null`. */
|
|
55
|
+
get description() {
|
|
56
|
+
return this.queryPart('description');
|
|
57
|
+
}
|
|
58
|
+
/** The close button in the corner (`@showCloseButton`), or `null`. */
|
|
59
|
+
get closeButton() {
|
|
60
|
+
return this.queryPart('close-button');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether it is open: the trigger's `aria-expanded`, or, without a trigger, the content's
|
|
64
|
+
* `data-state`. It is `false` as soon as it starts closing, while the content animates out.
|
|
65
|
+
*/
|
|
66
|
+
get isOpen() {
|
|
67
|
+
const trigger = this.queryPart('trigger');
|
|
68
|
+
if (trigger)
|
|
69
|
+
return trigger.getAttribute('aria-expanded') === 'true';
|
|
70
|
+
return this.content?.getAttribute('data-state') === 'open';
|
|
71
|
+
}
|
|
72
|
+
/** Whether it is modal: its content has `aria-modal="true"`. */
|
|
73
|
+
get isModal() {
|
|
74
|
+
return this.content?.getAttribute('aria-modal') === 'true';
|
|
75
|
+
}
|
|
76
|
+
/** The content's role: `dialog`, or `alertdialog`. */
|
|
77
|
+
get role() {
|
|
78
|
+
return this.content?.getAttribute('role') ?? null;
|
|
79
|
+
}
|
|
80
|
+
/** Its accessible name: the content's `aria-label`, else the text its `aria-labelledby` names. */
|
|
81
|
+
get label() {
|
|
82
|
+
const content = this.content;
|
|
83
|
+
if (!content)
|
|
84
|
+
return '';
|
|
85
|
+
return content.getAttribute('aria-label')?.trim() || textOf(content, 'aria-labelledby');
|
|
86
|
+
}
|
|
87
|
+
/** Its accessible description: the text its content's `aria-describedby` names. */
|
|
88
|
+
get descriptionText() {
|
|
89
|
+
const content = this.content;
|
|
90
|
+
return content ? textOf(content, 'aria-describedby') : '';
|
|
91
|
+
}
|
|
92
|
+
/** Whether the content is in the browser's top layer. */
|
|
93
|
+
get isInTopLayer() {
|
|
94
|
+
return isInTopLayer(this.content);
|
|
95
|
+
}
|
|
96
|
+
/** Whether focus is inside the content. */
|
|
97
|
+
get hasFocus() {
|
|
98
|
+
const content = this.content;
|
|
99
|
+
return Boolean(content?.contains(content.ownerDocument.activeElement));
|
|
100
|
+
}
|
|
101
|
+
/** Opens it with a click on its trigger, unless it is open. */
|
|
102
|
+
async open() {
|
|
103
|
+
if (!this.isOpen)
|
|
104
|
+
await click(this.trigger);
|
|
105
|
+
}
|
|
106
|
+
/** Closes it as a user would: with its close button, or else Escape. */
|
|
107
|
+
async close() {
|
|
108
|
+
const button = this.closeButton;
|
|
109
|
+
if (button)
|
|
110
|
+
await click(button);
|
|
111
|
+
else
|
|
112
|
+
await this.pressEscape();
|
|
113
|
+
}
|
|
114
|
+
/** Presses Escape inside it. */
|
|
115
|
+
async pressEscape() {
|
|
116
|
+
const content = this.content;
|
|
117
|
+
const active = content?.ownerDocument.activeElement;
|
|
118
|
+
await pressEscape(active && content?.contains(active) ? active : (content ?? undefined));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Presses outside the content: on the overlay of a modal dialog, else outside every layer.
|
|
122
|
+
* On the overlay, the press goes as a browser sends it: `pointerdown` (which closes the
|
|
123
|
+
* dialog), then the mouse events, with focus leaving for nothing (the overlay can't take it),
|
|
124
|
+
* all before the dialog has finished closing and given focus back.
|
|
125
|
+
*/
|
|
126
|
+
async pressOutside() {
|
|
127
|
+
const overlay = this.overlay;
|
|
128
|
+
if (!overlay)
|
|
129
|
+
return pressOutside();
|
|
130
|
+
const init = { bubbles: true, cancelable: true, button: 0, isPrimary: true };
|
|
131
|
+
overlay.dispatchEvent(new PointerEvent('pointerdown', { ...init, pointerType: 'mouse' }));
|
|
132
|
+
const target = overlay.isConnected ? overlay : overlay.ownerDocument.body;
|
|
133
|
+
target.dispatchEvent(new MouseEvent('mousedown', init));
|
|
134
|
+
const active = overlay.ownerDocument.activeElement;
|
|
135
|
+
if (active instanceof HTMLElement && active !== overlay.ownerDocument.body)
|
|
136
|
+
active.blur();
|
|
137
|
+
target.dispatchEvent(new MouseEvent('mouseup', init));
|
|
138
|
+
target.dispatchEvent(new MouseEvent('click', init));
|
|
139
|
+
target.dispatchEvent(new PointerEvent('pointerup', { ...init, pointerType: 'mouse' }));
|
|
140
|
+
await settled();
|
|
141
|
+
}
|
|
142
|
+
}
|
package/dist/drawer.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DialogHarness } from './dialog.ts';
|
|
2
|
+
/** How a drag goes: how long it takes, in how many moves, and with what. */
|
|
3
|
+
export interface DragOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Milliseconds from press to release. Default `600`: slow enough (under vaul's 0.4px a
|
|
6
|
+
* millisecond, for a drag under 240px) that the distance decides, not the speed.
|
|
7
|
+
*/
|
|
8
|
+
duration?: number;
|
|
9
|
+
/** How many `pointermove`s it takes. Default `6`. */
|
|
10
|
+
steps?: number;
|
|
11
|
+
/** Where it starts: an element in the drawer. Default the drawer itself. */
|
|
12
|
+
from?: Element;
|
|
13
|
+
/** `mouse` (the default), `pen` or `touch`. */
|
|
14
|
+
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Drives a `<Drawer>` from `@ember-joinery/ember` (or the headless one from
|
|
18
|
+
* `@ember-joinery/primitives/drawer`). It is a `DialogHarness`, so it opens, closes and reads
|
|
19
|
+
* the drawer's ARIA as one, and it drags the drawer as a finger or mouse does: a press, moves
|
|
20
|
+
* along its axis, and a release.
|
|
21
|
+
*
|
|
22
|
+
* const drawer = new DrawerHarness('goal')
|
|
23
|
+
* await drawer.open()
|
|
24
|
+
* await drawer.afterOpening()
|
|
25
|
+
* await drawer.drag(200) // toward closed: down, for a drawer from the bottom
|
|
26
|
+
* assert.false(drawer.isOpen)
|
|
27
|
+
*/
|
|
28
|
+
export declare class DrawerHarness extends DialogHarness {
|
|
29
|
+
static component: string;
|
|
30
|
+
/** The edge it comes in from: `top`, `right`, `bottom` or `left` (`data-vaul-drawer-direction`). */
|
|
31
|
+
get direction(): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* The physical edge it is on: its direction, but right to left a `left` drawer is on the
|
|
34
|
+
* right (left and right are the inline start and end).
|
|
35
|
+
*/
|
|
36
|
+
get side(): string | null;
|
|
37
|
+
/** The handle, or `null`. */
|
|
38
|
+
get handle(): HTMLElement | null;
|
|
39
|
+
/** Whether it is being dragged now (vaul's `vaul-dragging` class). */
|
|
40
|
+
get isDragging(): boolean;
|
|
41
|
+
/** The snap point it rests at, as its `data-snap-point` says (`"0.5"`, `"148px"`), or `null`. */
|
|
42
|
+
get activeSnapPoint(): string | null;
|
|
43
|
+
/** How far it is moved along its axis now, in pixels, from its computed transform. */
|
|
44
|
+
get offset(): number;
|
|
45
|
+
/** Ends its animations and transitions now, so it is measured where it rests. */
|
|
46
|
+
finishAnimations(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Waits out a drawer's opening: its slide in, and the half second after it opens in which a
|
|
49
|
+
* drawer from the top or bottom lets its content scroll rather than drag, as vaul's does.
|
|
50
|
+
*/
|
|
51
|
+
afterOpening(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Drags it along its axis by `distance` pixels toward closed (down, for a drawer from the
|
|
54
|
+
* bottom; left, for one from the left), or toward open with a negative distance, and lets
|
|
55
|
+
* go. Fast drags (a short `duration`) close it as a flick does.
|
|
56
|
+
*/
|
|
57
|
+
drag(distance: number, options?: DragOptions): Promise<void>;
|
|
58
|
+
/** A quick flick toward closed: `distance` pixels in 40ms. */
|
|
59
|
+
swipe(distance?: number, options?: Omit<DragOptions, 'duration'>): Promise<void>;
|
|
60
|
+
/** Taps its handle (vaul's Handle): the next snap point, or closed after the last. */
|
|
61
|
+
tapHandle(): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../src/drawer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,4EAA4E;AAC5E,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4EAA4E;IAC5E,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,CAAA;CACxC;AA4BD;;;;;;;;;;;GAWG;AACH,qBAAa,aAAc,SAAQ,aAAa;IAC9C,OAAgB,SAAS,SAAW;IAEpC,oGAAoG;IACpG,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAMxB;IAED,6BAA6B;IAC7B,IAAI,MAAM,IAAI,WAAW,GAAG,IAAI,CAE/B;IAED,sEAAsE;IACtE,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,iGAAiG;IACjG,IAAI,eAAe,IAAI,MAAM,GAAG,IAAI,CAEnC;IAED,sFAAsF;IACtF,IAAI,MAAM,IAAI,MAAM,CAQnB;IAED,iFAAiF;IACjF,gBAAgB,IAAI,IAAI;IAMxB;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC;;;;OAIG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BtE,8DAA8D;IACxD,KAAK,CAAC,QAAQ,SAAK,EAAE,OAAO,GAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItF,sFAAsF;IAChF,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAKjC"}
|
package/dist/drawer.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { click, settled } from '@ember/test-helpers';
|
|
2
|
+
import { DialogHarness } from "./dialog.js";
|
|
3
|
+
const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
4
|
+
/** Sends one pointer event at a point on the page, as a pointer does. */
|
|
5
|
+
function pointer(target, type, x, y, pointerType) {
|
|
6
|
+
const event = new PointerEvent(type, {
|
|
7
|
+
bubbles: true,
|
|
8
|
+
cancelable: true,
|
|
9
|
+
composed: true,
|
|
10
|
+
clientX: x,
|
|
11
|
+
clientY: y,
|
|
12
|
+
pointerId: 1,
|
|
13
|
+
pointerType,
|
|
14
|
+
isPrimary: true,
|
|
15
|
+
button: 0,
|
|
16
|
+
buttons: type === 'pointerup' ? 0 : 1,
|
|
17
|
+
});
|
|
18
|
+
target.dispatchEvent(event);
|
|
19
|
+
return event;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Drives a `<Drawer>` from `@ember-joinery/ember` (or the headless one from
|
|
23
|
+
* `@ember-joinery/primitives/drawer`). It is a `DialogHarness`, so it opens, closes and reads
|
|
24
|
+
* the drawer's ARIA as one, and it drags the drawer as a finger or mouse does: a press, moves
|
|
25
|
+
* along its axis, and a release.
|
|
26
|
+
*
|
|
27
|
+
* const drawer = new DrawerHarness('goal')
|
|
28
|
+
* await drawer.open()
|
|
29
|
+
* await drawer.afterOpening()
|
|
30
|
+
* await drawer.drag(200) // toward closed: down, for a drawer from the bottom
|
|
31
|
+
* assert.false(drawer.isOpen)
|
|
32
|
+
*/
|
|
33
|
+
export class DrawerHarness extends DialogHarness {
|
|
34
|
+
static component = 'drawer';
|
|
35
|
+
/** The edge it comes in from: `top`, `right`, `bottom` or `left` (`data-vaul-drawer-direction`). */
|
|
36
|
+
get direction() {
|
|
37
|
+
return this.content?.getAttribute('data-vaul-drawer-direction') ?? null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The physical edge it is on: its direction, but right to left a `left` drawer is on the
|
|
41
|
+
* right (left and right are the inline start and end).
|
|
42
|
+
*/
|
|
43
|
+
get side() {
|
|
44
|
+
const direction = this.direction;
|
|
45
|
+
const content = this.content;
|
|
46
|
+
if (!content || (direction !== 'left' && direction !== 'right'))
|
|
47
|
+
return direction;
|
|
48
|
+
if (getComputedStyle(content).direction !== 'rtl')
|
|
49
|
+
return direction;
|
|
50
|
+
return direction === 'left' ? 'right' : 'left';
|
|
51
|
+
}
|
|
52
|
+
/** The handle, or `null`. */
|
|
53
|
+
get handle() {
|
|
54
|
+
return this.queryPart('handle');
|
|
55
|
+
}
|
|
56
|
+
/** Whether it is being dragged now (vaul's `vaul-dragging` class). */
|
|
57
|
+
get isDragging() {
|
|
58
|
+
return Boolean(this.content?.classList.contains('vaul-dragging'));
|
|
59
|
+
}
|
|
60
|
+
/** The snap point it rests at, as its `data-snap-point` says (`"0.5"`, `"148px"`), or `null`. */
|
|
61
|
+
get activeSnapPoint() {
|
|
62
|
+
return this.content?.getAttribute('data-snap-point') ?? null;
|
|
63
|
+
}
|
|
64
|
+
/** How far it is moved along its axis now, in pixels, from its computed transform. */
|
|
65
|
+
get offset() {
|
|
66
|
+
const content = this.content;
|
|
67
|
+
if (!content)
|
|
68
|
+
return 0;
|
|
69
|
+
const transform = getComputedStyle(content).transform;
|
|
70
|
+
if (!transform || transform === 'none')
|
|
71
|
+
return 0;
|
|
72
|
+
const matrix = new DOMMatrixReadOnly(transform);
|
|
73
|
+
const side = this.side;
|
|
74
|
+
return side === 'top' || side === 'bottom' ? matrix.m42 : matrix.m41;
|
|
75
|
+
}
|
|
76
|
+
/** Ends its animations and transitions now, so it is measured where it rests. */
|
|
77
|
+
finishAnimations() {
|
|
78
|
+
for (const element of [this.content, this.overlay]) {
|
|
79
|
+
for (const animation of element?.getAnimations() ?? [])
|
|
80
|
+
animation.finish();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Waits out a drawer's opening: its slide in, and the half second after it opens in which a
|
|
85
|
+
* drawer from the top or bottom lets its content scroll rather than drag, as vaul's does.
|
|
86
|
+
*/
|
|
87
|
+
async afterOpening() {
|
|
88
|
+
this.finishAnimations();
|
|
89
|
+
await wait(510);
|
|
90
|
+
await settled();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Drags it along its axis by `distance` pixels toward closed (down, for a drawer from the
|
|
94
|
+
* bottom; left, for one from the left), or toward open with a negative distance, and lets
|
|
95
|
+
* go. Fast drags (a short `duration`) close it as a flick does.
|
|
96
|
+
*/
|
|
97
|
+
async drag(distance, options = {}) {
|
|
98
|
+
const content = this.content;
|
|
99
|
+
if (!content)
|
|
100
|
+
throw new Error(`${this} is closed: there is nothing to drag`);
|
|
101
|
+
const { duration = 600, steps = 6, pointerType = 'mouse' } = options;
|
|
102
|
+
const from = options.from ?? content;
|
|
103
|
+
const rect = from.getBoundingClientRect();
|
|
104
|
+
const x = rect.left + rect.width / 2;
|
|
105
|
+
const y = rect.top + Math.min(rect.height / 2, 24);
|
|
106
|
+
const side = this.side;
|
|
107
|
+
const vertical = side === 'top' || side === 'bottom';
|
|
108
|
+
const sign = side === 'bottom' || side === 'right' ? 1 : -1;
|
|
109
|
+
const at = (fraction) => {
|
|
110
|
+
const moved = distance * fraction * sign;
|
|
111
|
+
return vertical ? [x, y + moved] : [x + moved, y];
|
|
112
|
+
};
|
|
113
|
+
// The pointer is captured where it went down, so every event goes there.
|
|
114
|
+
pointer(from, 'pointerdown', x, y, pointerType);
|
|
115
|
+
for (let step = 1; step <= steps; step++) {
|
|
116
|
+
await wait(duration / (steps + 1));
|
|
117
|
+
const [px, py] = at(step / steps);
|
|
118
|
+
pointer(from, 'pointermove', px, py, pointerType);
|
|
119
|
+
}
|
|
120
|
+
await wait(duration / (steps + 1));
|
|
121
|
+
const [ex, ey] = at(1);
|
|
122
|
+
pointer(from, 'pointerup', ex, ey, pointerType);
|
|
123
|
+
await settled();
|
|
124
|
+
}
|
|
125
|
+
/** A quick flick toward closed: `distance` pixels in 40ms. */
|
|
126
|
+
async swipe(distance = 80, options = {}) {
|
|
127
|
+
await this.drag(distance, { ...options, duration: 40, steps: 3 });
|
|
128
|
+
}
|
|
129
|
+
/** Taps its handle (vaul's Handle): the next snap point, or closed after the last. */
|
|
130
|
+
async tapHandle() {
|
|
131
|
+
const handle = this.handle;
|
|
132
|
+
if (!handle)
|
|
133
|
+
throw new Error(`${this} has no handle`);
|
|
134
|
+
await click(handle);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MenuHarness } from './-private/menu.ts';
|
|
2
|
+
export { MenuLevel, SubMenu } from './-private/menu.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Drives a `<DropdownMenu>` from `@ember-joinery/ember` or
|
|
5
|
+
* `@ember-joinery/primitives/dropdown-menu`. It reads the state from the trigger's ARIA
|
|
6
|
+
* (`aria-expanded`) and the items' (`aria-checked`, `aria-disabled`), finds items by their
|
|
7
|
+
* text, and acts as a user does: a press on the trigger, keys, a click on an item.
|
|
8
|
+
*
|
|
9
|
+
* const menu = new DropdownMenuHarness('account') // <DropdownMenu @name="account">
|
|
10
|
+
* await menu.open()
|
|
11
|
+
* assert.deepEqual(menu.items, ['Profile', 'Billing', 'Log out'])
|
|
12
|
+
* await menu.sub('Invite users').open()
|
|
13
|
+
* await menu.select('Profile')
|
|
14
|
+
* assert.false(menu.isOpen)
|
|
15
|
+
*/
|
|
16
|
+
export declare class DropdownMenuHarness extends MenuHarness {
|
|
17
|
+
static component: string;
|
|
18
|
+
/** Whether it is open, from the trigger's `aria-expanded`. */
|
|
19
|
+
get isOpen(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Presses the trigger as a pointer does, which opens the menu when it is closed and closes it
|
|
22
|
+
* when it is open. Focus goes to the content, not an item.
|
|
23
|
+
*/
|
|
24
|
+
toggle(): Promise<void>;
|
|
25
|
+
/** Opens it with a press on the trigger, unless it is open. */
|
|
26
|
+
open(): Promise<void>;
|
|
27
|
+
/** Closes it with a press on the trigger, unless it is closed. */
|
|
28
|
+
close(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Opens it from the keyboard: focus on the trigger, then `key` (Enter, Space or ArrowDown).
|
|
31
|
+
* Focus goes to the first item.
|
|
32
|
+
*/
|
|
33
|
+
openWithKeyboard(key?: 'Enter' | ' ' | 'ArrowDown'): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=dropdown-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-menu.d.ts","sourceRoot":"","sources":["../src/dropdown-menu.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;;;;;;GAYG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,OAAgB,SAAS,SAAkB;IAE3C,8DAA8D;IAC9D,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;OAGG;IACG,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;;;OAGG;IACG,gBAAgB,CAAC,GAAG,GAAE,OAAO,GAAG,GAAG,GAAG,WAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CAIlF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { focus } from '@ember/test-helpers';
|
|
2
|
+
import { pressKey } from "./focus.js";
|
|
3
|
+
import { MenuHarness, pressAsBrowser } from "./-private/menu.js";
|
|
4
|
+
export { MenuLevel, SubMenu } from "./-private/menu.js";
|
|
5
|
+
/**
|
|
6
|
+
* Drives a `<DropdownMenu>` from `@ember-joinery/ember` or
|
|
7
|
+
* `@ember-joinery/primitives/dropdown-menu`. It reads the state from the trigger's ARIA
|
|
8
|
+
* (`aria-expanded`) and the items' (`aria-checked`, `aria-disabled`), finds items by their
|
|
9
|
+
* text, and acts as a user does: a press on the trigger, keys, a click on an item.
|
|
10
|
+
*
|
|
11
|
+
* const menu = new DropdownMenuHarness('account') // <DropdownMenu @name="account">
|
|
12
|
+
* await menu.open()
|
|
13
|
+
* assert.deepEqual(menu.items, ['Profile', 'Billing', 'Log out'])
|
|
14
|
+
* await menu.sub('Invite users').open()
|
|
15
|
+
* await menu.select('Profile')
|
|
16
|
+
* assert.false(menu.isOpen)
|
|
17
|
+
*/
|
|
18
|
+
export class DropdownMenuHarness extends MenuHarness {
|
|
19
|
+
static component = 'dropdown-menu';
|
|
20
|
+
/** Whether it is open, from the trigger's `aria-expanded`. */
|
|
21
|
+
get isOpen() {
|
|
22
|
+
return this.trigger.getAttribute('aria-expanded') === 'true';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Presses the trigger as a pointer does, which opens the menu when it is closed and closes it
|
|
26
|
+
* when it is open. Focus goes to the content, not an item.
|
|
27
|
+
*/
|
|
28
|
+
async toggle() {
|
|
29
|
+
await pressAsBrowser(this.trigger);
|
|
30
|
+
}
|
|
31
|
+
/** Opens it with a press on the trigger, unless it is open. */
|
|
32
|
+
async open() {
|
|
33
|
+
if (!this.isOpen)
|
|
34
|
+
await this.toggle();
|
|
35
|
+
}
|
|
36
|
+
/** Closes it with a press on the trigger, unless it is closed. */
|
|
37
|
+
async close() {
|
|
38
|
+
if (this.isOpen)
|
|
39
|
+
await this.toggle();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Opens it from the keyboard: focus on the trigger, then `key` (Enter, Space or ArrowDown).
|
|
43
|
+
* Focus goes to the first item.
|
|
44
|
+
*/
|
|
45
|
+
async openWithKeyboard(key = 'Enter') {
|
|
46
|
+
await focus(this.trigger);
|
|
47
|
+
await pressKey(key);
|
|
48
|
+
}
|
|
49
|
+
}
|
package/dist/empty.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives an `<Empty>` from `@ember-joinery/ember`: an empty state. It reads the title and
|
|
4
|
+
* descriptions, reaches the media and content, and finds what is inside with `find()`:
|
|
5
|
+
*
|
|
6
|
+
* const empty = new EmptyHarness('projects') // <Empty @name="projects">
|
|
7
|
+
* assert.strictEqual(empty.title, 'No Projects Yet')
|
|
8
|
+
* await empty.find(ButtonHarness).click()
|
|
9
|
+
*/
|
|
10
|
+
export declare class EmptyHarness extends Harness {
|
|
11
|
+
static component: string;
|
|
12
|
+
/** All the text it shows, whitespace collapsed. */
|
|
13
|
+
get text(): string;
|
|
14
|
+
/** Its title's text, or `''` without one. */
|
|
15
|
+
get title(): string;
|
|
16
|
+
/** Its first description's text, or `''` without one. */
|
|
17
|
+
get description(): string;
|
|
18
|
+
/** The text of every description, in order: one may sit in the header, another in the content. */
|
|
19
|
+
get descriptions(): string[];
|
|
20
|
+
/** The media's `@variant` (`default` or `icon`), or `null` without media. */
|
|
21
|
+
get mediaVariant(): string | null;
|
|
22
|
+
/** The header. Throws when it has none. */
|
|
23
|
+
get header(): HTMLElement;
|
|
24
|
+
/** The media: an icon, an image or an avatar. Throws when it has none. */
|
|
25
|
+
get media(): HTMLElement;
|
|
26
|
+
/** The content, under the header. Throws when it has none. */
|
|
27
|
+
get content(): HTMLElement;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=empty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../src/empty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC;;;;;;;GAOG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACvC,OAAgB,SAAS,SAAU;IAEnC,mDAAmD;IACnD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,6CAA6C;IAC7C,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,yDAAyD;IACzD,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,kGAAkG;IAClG,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED,6EAA6E;IAC7E,IAAI,YAAY,IAAI,MAAM,GAAG,IAAI,CAEhC;IAED,2CAA2C;IAC3C,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,0EAA0E;IAC1E,IAAI,KAAK,IAAI,WAAW,CAEvB;IAED,8DAA8D;IAC9D,IAAI,OAAO,IAAI,WAAW,CAEzB;CACF"}
|
package/dist/empty.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Harness } from "./harness.js";
|
|
2
|
+
function text(element) {
|
|
3
|
+
return (element?.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Drives an `<Empty>` from `@ember-joinery/ember`: an empty state. It reads the title and
|
|
7
|
+
* descriptions, reaches the media and content, and finds what is inside with `find()`:
|
|
8
|
+
*
|
|
9
|
+
* const empty = new EmptyHarness('projects') // <Empty @name="projects">
|
|
10
|
+
* assert.strictEqual(empty.title, 'No Projects Yet')
|
|
11
|
+
* await empty.find(ButtonHarness).click()
|
|
12
|
+
*/
|
|
13
|
+
export class EmptyHarness extends Harness {
|
|
14
|
+
static component = 'empty';
|
|
15
|
+
/** All the text it shows, whitespace collapsed. */
|
|
16
|
+
get text() {
|
|
17
|
+
return text(this.element);
|
|
18
|
+
}
|
|
19
|
+
/** Its title's text, or `''` without one. */
|
|
20
|
+
get title() {
|
|
21
|
+
return text(this.queryPart('title'));
|
|
22
|
+
}
|
|
23
|
+
/** Its first description's text, or `''` without one. */
|
|
24
|
+
get description() {
|
|
25
|
+
return text(this.queryPart('description'));
|
|
26
|
+
}
|
|
27
|
+
/** The text of every description, in order: one may sit in the header, another in the content. */
|
|
28
|
+
get descriptions() {
|
|
29
|
+
return this.parts('description').map(text);
|
|
30
|
+
}
|
|
31
|
+
/** The media's `@variant` (`default` or `icon`), or `null` without media. */
|
|
32
|
+
get mediaVariant() {
|
|
33
|
+
return this.queryPart('media')?.getAttribute('data-variant') ?? null;
|
|
34
|
+
}
|
|
35
|
+
/** The header. Throws when it has none. */
|
|
36
|
+
get header() {
|
|
37
|
+
return this.part('header');
|
|
38
|
+
}
|
|
39
|
+
/** The media: an icon, an image or an avatar. Throws when it has none. */
|
|
40
|
+
get media() {
|
|
41
|
+
return this.part('media');
|
|
42
|
+
}
|
|
43
|
+
/** The content, under the header. Throws when it has none. */
|
|
44
|
+
get content() {
|
|
45
|
+
return this.part('content');
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/field.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Field>` from `@ember-joinery/ember`: reads its label, description and error, and
|
|
4
|
+
* its state, and finds the control inside it with `find()`.
|
|
5
|
+
*
|
|
6
|
+
* const email = new FieldHarness('email') // <Field @name="email">
|
|
7
|
+
* assert.strictEqual(email.label, 'Email')
|
|
8
|
+
* assert.strictEqual(email.error, 'Enter a valid email address.')
|
|
9
|
+
* assert.true(email.isInvalid)
|
|
10
|
+
* await email.find(InputHarness).fillIn('ada@example.com')
|
|
11
|
+
*/
|
|
12
|
+
export declare class FieldHarness extends Harness {
|
|
13
|
+
static component: string;
|
|
14
|
+
/** All the text it shows, whitespace collapsed. */
|
|
15
|
+
get text(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Its label: the `<FieldLabel>` or `<FieldTitle>` in it (both are `data-slot="field-label"`),
|
|
18
|
+
* not one in a field inside it; else a plain `<Label>` or `<label>` in it; else the
|
|
19
|
+
* `<FieldLabel>` around it, as in a choice card. `null` when it has none.
|
|
20
|
+
*/
|
|
21
|
+
get labelElement(): HTMLElement | null;
|
|
22
|
+
/** Its label's text, or `''` without one. */
|
|
23
|
+
get label(): string;
|
|
24
|
+
/** The control its `<FieldLabel>` labels, as the browser works it out, or `null`. */
|
|
25
|
+
get control(): HTMLElement | null;
|
|
26
|
+
/** Each `<FieldDescription>`'s text, in order. */
|
|
27
|
+
get descriptions(): string[];
|
|
28
|
+
/** Its descriptions' text, joined with a space, or `''` without one. */
|
|
29
|
+
get description(): string;
|
|
30
|
+
/** Its `<FieldError>`, while one shows, or `null`. */
|
|
31
|
+
get errorElement(): HTMLElement | null;
|
|
32
|
+
/** The error it shows, or `''` without one: a list of errors' text, joined with a space. */
|
|
33
|
+
get error(): string;
|
|
34
|
+
/** Each error it shows: one, or each item of the list `@errors` renders for several. */
|
|
35
|
+
get errors(): string[];
|
|
36
|
+
/** Whether it is in its error state (`data-invalid="true"`). */
|
|
37
|
+
get isInvalid(): boolean;
|
|
38
|
+
/** Whether it shows as disabled (`data-disabled="true"`). */
|
|
39
|
+
get isDisabled(): boolean;
|
|
40
|
+
/** `vertical`, `horizontal` or `responsive` (`data-orientation`). */
|
|
41
|
+
get orientation(): string | null;
|
|
42
|
+
/** Its `<FieldContent>`, or `null`. */
|
|
43
|
+
get content(): HTMLElement | null;
|
|
44
|
+
/** Its `<FieldTitle>`'s text, or `''` without one. */
|
|
45
|
+
get title(): string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Drives a `<FieldSet>` from `@ember-joinery/ember`: its legend and description, and the
|
|
49
|
+
* fields in it.
|
|
50
|
+
*
|
|
51
|
+
* const address = new FieldSetHarness('address') // <FieldSet @name="address">
|
|
52
|
+
* assert.strictEqual(address.legend, 'Address Information')
|
|
53
|
+
* assert.deepEqual(address.fields.map(field => field.label), ['Street Address', 'City'])
|
|
54
|
+
*/
|
|
55
|
+
export declare class FieldSetHarness extends Harness {
|
|
56
|
+
static component: string;
|
|
57
|
+
/** All the text it shows, whitespace collapsed. */
|
|
58
|
+
get text(): string;
|
|
59
|
+
/** Its `<FieldLegend>`'s text, or `''` without one. */
|
|
60
|
+
get legend(): string;
|
|
61
|
+
/** Its legend's `@variant`: `legend` or `label`, or `null` without a legend. */
|
|
62
|
+
get legendVariant(): string | null;
|
|
63
|
+
/** Its own `<FieldDescription>`s' text, joined with a space (not its fields'). */
|
|
64
|
+
get description(): string;
|
|
65
|
+
/** A harness for each field in it, in order, nested ones included. */
|
|
66
|
+
get fields(): FieldHarness[];
|
|
67
|
+
/** Whether it is disabled, which disables every control in it (`<fieldset disabled>`). */
|
|
68
|
+
get isDisabled(): boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Drives a `<FieldGroup>` from `@ember-joinery/ember`: the fields in it and the text of its
|
|
72
|
+
* separators.
|
|
73
|
+
*
|
|
74
|
+
* const group = new FieldGroupHarness()
|
|
75
|
+
* assert.deepEqual(group.separators, ['Or continue with'])
|
|
76
|
+
*/
|
|
77
|
+
export declare class FieldGroupHarness extends Harness {
|
|
78
|
+
static component: string;
|
|
79
|
+
/** A harness for each field in it, in order, nested ones included. */
|
|
80
|
+
get fields(): FieldHarness[];
|
|
81
|
+
/** A harness for each field set in it, in order. */
|
|
82
|
+
get fieldSets(): FieldSetHarness[];
|
|
83
|
+
/** Each `<FieldSeparator>`'s text, in order: `''` for a plain line. */
|
|
84
|
+
get separators(): string[];
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAQtC;;;;;;;;;GASG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACvC,OAAgB,SAAS,SAAU;IAEnC,mDAAmD;IACnD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,IAAI,YAAY,IAAI,WAAW,GAAG,IAAI,CAUrC;IAED,6CAA6C;IAC7C,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,qFAAqF;IACrF,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAGhC;IAED,kDAAkD;IAClD,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED,wEAAwE;IACxE,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,sDAAsD;IACtD,IAAI,YAAY,IAAI,WAAW,GAAG,IAAI,CAErC;IAED,4FAA4F;IAC5F,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,wFAAwF;IACxF,IAAI,MAAM,IAAI,MAAM,EAAE,CAKrB;IAED,gEAAgE;IAChE,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,6DAA6D;IAC7D,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,qEAAqE;IACrE,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAE/B;IAED,uCAAuC;IACvC,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,sDAAsD;IACtD,IAAI,KAAK,IAAI,MAAM,CAGlB;CACF;AAED;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAc;IAEvC,mDAAmD;IACnD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,uDAAuD;IACvD,IAAI,MAAM,IAAI,MAAM,CAGnB;IAED,gFAAgF;IAChF,IAAI,aAAa,IAAI,MAAM,GAAG,IAAI,CAEjC;IAED,kFAAkF;IAClF,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,sEAAsE;IACtE,IAAI,MAAM,IAAI,YAAY,EAAE,CAE3B;IAED,0FAA0F;IAC1F,IAAI,UAAU,IAAI,OAAO,CAExB;CACF;AAED;;;;;;GAMG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,OAAgB,SAAS,SAAgB;IAEzC,sEAAsE;IACtE,IAAI,MAAM,IAAI,YAAY,EAAE,CAE3B;IAED,oDAAoD;IACpD,IAAI,SAAS,IAAI,eAAe,EAAE,CAEjC;IAED,uEAAuE;IACvE,IAAI,UAAU,IAAI,MAAM,EAAE,CAEzB;CACF"}
|