@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.
Files changed (321) hide show
  1. package/CHANGELOG.md +574 -0
  2. package/LICENSE.md +9 -0
  3. package/NOTICE +532 -0
  4. package/README.md +356 -2
  5. package/addon-main.cjs +4 -0
  6. package/dist/-private/checkable.d.ts +21 -0
  7. package/dist/-private/checkable.d.ts.map +1 -0
  8. package/dist/-private/checkable.js +80 -0
  9. package/dist/-private/control.d.ts +18 -0
  10. package/dist/-private/control.d.ts.map +1 -0
  11. package/dist/-private/control.js +55 -0
  12. package/dist/-private/menu.d.ts +145 -0
  13. package/dist/-private/menu.d.ts.map +1 -0
  14. package/dist/-private/menu.js +322 -0
  15. package/dist/-private/overlay.d.ts +9 -0
  16. package/dist/-private/overlay.d.ts.map +1 -0
  17. package/dist/-private/overlay.js +39 -0
  18. package/dist/-private/showing.d.ts +7 -0
  19. package/dist/-private/showing.d.ts.map +1 -0
  20. package/dist/-private/showing.js +10 -0
  21. package/dist/-private/size.d.ts +10 -0
  22. package/dist/-private/size.d.ts.map +1 -0
  23. package/dist/-private/size.js +24 -0
  24. package/dist/-private/tree.d.ts +34 -0
  25. package/dist/-private/tree.d.ts.map +1 -0
  26. package/dist/-private/tree.js +80 -0
  27. package/dist/accordion.d.ts +62 -0
  28. package/dist/accordion.d.ts.map +1 -0
  29. package/dist/accordion.js +112 -0
  30. package/dist/alert-dialog.d.ts +24 -0
  31. package/dist/alert-dialog.d.ts.map +1 -0
  32. package/dist/alert-dialog.js +37 -0
  33. package/dist/alert.d.ts +27 -0
  34. package/dist/alert.d.ts.map +1 -0
  35. package/dist/alert.js +43 -0
  36. package/dist/app-shell.d.ts +43 -0
  37. package/dist/app-shell.d.ts.map +1 -0
  38. package/dist/app-shell.js +78 -0
  39. package/dist/aspect-ratio.d.ts +21 -0
  40. package/dist/aspect-ratio.d.ts.map +1 -0
  41. package/dist/aspect-ratio.js +30 -0
  42. package/dist/attachment.d.ts +86 -0
  43. package/dist/attachment.d.ts.map +1 -0
  44. package/dist/attachment.js +156 -0
  45. package/dist/avatar.d.ts +65 -0
  46. package/dist/avatar.d.ts.map +1 -0
  47. package/dist/avatar.js +106 -0
  48. package/dist/badge.d.ts +29 -0
  49. package/dist/badge.d.ts.map +1 -0
  50. package/dist/badge.js +49 -0
  51. package/dist/breadcrumb.d.ts +36 -0
  52. package/dist/breadcrumb.d.ts.map +1 -0
  53. package/dist/breadcrumb.js +80 -0
  54. package/dist/bubble.d.ts +56 -0
  55. package/dist/bubble.d.ts.map +1 -0
  56. package/dist/bubble.js +94 -0
  57. package/dist/button-group.d.ts +34 -0
  58. package/dist/button-group.d.ts.map +1 -0
  59. package/dist/button-group.js +62 -0
  60. package/dist/button.d.ts +37 -0
  61. package/dist/button.d.ts.map +1 -0
  62. package/dist/button.js +77 -0
  63. package/dist/calendar.d.ts +115 -0
  64. package/dist/calendar.d.ts.map +1 -0
  65. package/dist/calendar.js +276 -0
  66. package/dist/card.d.ts +31 -0
  67. package/dist/card.d.ts.map +1 -0
  68. package/dist/card.js +49 -0
  69. package/dist/checkbox.d.ts +46 -0
  70. package/dist/checkbox.d.ts.map +1 -0
  71. package/dist/checkbox.js +84 -0
  72. package/dist/child.d.ts +29 -0
  73. package/dist/child.d.ts.map +1 -0
  74. package/dist/child.js +27 -0
  75. package/dist/collapsible.d.ts +44 -0
  76. package/dist/collapsible.d.ts.map +1 -0
  77. package/dist/collapsible.js +83 -0
  78. package/dist/color-scheme.d.ts +44 -0
  79. package/dist/color-scheme.d.ts.map +1 -0
  80. package/dist/color-scheme.js +123 -0
  81. package/dist/combobox.d.ts +114 -0
  82. package/dist/combobox.d.ts.map +1 -0
  83. package/dist/combobox.js +293 -0
  84. package/dist/command.d.ts +92 -0
  85. package/dist/command.d.ts.map +1 -0
  86. package/dist/command.js +183 -0
  87. package/dist/context-menu.d.ts +37 -0
  88. package/dist/context-menu.d.ts.map +1 -0
  89. package/dist/context-menu.js +59 -0
  90. package/dist/date-picker.d.ts +48 -0
  91. package/dist/date-picker.d.ts.map +1 -0
  92. package/dist/date-picker.js +136 -0
  93. package/dist/dialog.d.ts +64 -0
  94. package/dist/dialog.d.ts.map +1 -0
  95. package/dist/dialog.js +142 -0
  96. package/dist/drawer.d.ts +63 -0
  97. package/dist/drawer.d.ts.map +1 -0
  98. package/dist/drawer.js +136 -0
  99. package/dist/dropdown-menu.d.ts +35 -0
  100. package/dist/dropdown-menu.d.ts.map +1 -0
  101. package/dist/dropdown-menu.js +49 -0
  102. package/dist/empty.d.ts +29 -0
  103. package/dist/empty.d.ts.map +1 -0
  104. package/dist/empty.js +47 -0
  105. package/dist/field.d.ts +86 -0
  106. package/dist/field.d.ts.map +1 -0
  107. package/dist/field.js +150 -0
  108. package/dist/file-drop.d.ts +74 -0
  109. package/dist/file-drop.d.ts.map +1 -0
  110. package/dist/file-drop.js +137 -0
  111. package/dist/focus.d.ts +54 -0
  112. package/dist/focus.d.ts.map +1 -0
  113. package/dist/focus.js +174 -0
  114. package/dist/harness.d.ts +90 -0
  115. package/dist/harness.d.ts.map +1 -0
  116. package/dist/harness.js +189 -0
  117. package/dist/heading.d.ts +16 -0
  118. package/dist/heading.d.ts.map +1 -0
  119. package/dist/heading.js +19 -0
  120. package/dist/hero.d.ts +21 -0
  121. package/dist/hero.d.ts.map +1 -0
  122. package/dist/hero.js +28 -0
  123. package/dist/hover-card.d.ts +46 -0
  124. package/dist/hover-card.d.ts.map +1 -0
  125. package/dist/hover-card.js +85 -0
  126. package/dist/icon.d.ts +10 -0
  127. package/dist/icon.d.ts.map +1 -0
  128. package/dist/icon.js +13 -0
  129. package/dist/index.d.ts +98 -0
  130. package/dist/index.d.ts.map +1 -0
  131. package/dist/index.js +99 -0
  132. package/dist/input-group.d.ts +55 -0
  133. package/dist/input-group.d.ts.map +1 -0
  134. package/dist/input-group.js +103 -0
  135. package/dist/input-otp.d.ts +103 -0
  136. package/dist/input-otp.d.ts.map +1 -0
  137. package/dist/input-otp.js +293 -0
  138. package/dist/input.d.ts +53 -0
  139. package/dist/input.d.ts.map +1 -0
  140. package/dist/input.js +90 -0
  141. package/dist/inspector.d.ts +47 -0
  142. package/dist/inspector.d.ts.map +1 -0
  143. package/dist/inspector.js +97 -0
  144. package/dist/item.d.ts +63 -0
  145. package/dist/item.d.ts.map +1 -0
  146. package/dist/item.js +104 -0
  147. package/dist/kbd.d.ts +28 -0
  148. package/dist/kbd.d.ts.map +1 -0
  149. package/dist/kbd.js +36 -0
  150. package/dist/keys.d.ts +20 -0
  151. package/dist/keys.d.ts.map +1 -0
  152. package/dist/keys.js +32 -0
  153. package/dist/label.d.ts +24 -0
  154. package/dist/label.d.ts.map +1 -0
  155. package/dist/label.js +39 -0
  156. package/dist/layers.d.ts +42 -0
  157. package/dist/layers.d.ts.map +1 -0
  158. package/dist/layers.js +70 -0
  159. package/dist/link.d.ts +44 -0
  160. package/dist/link.d.ts.map +1 -0
  161. package/dist/link.js +60 -0
  162. package/dist/marker.d.ts +42 -0
  163. package/dist/marker.d.ts.map +1 -0
  164. package/dist/marker.js +73 -0
  165. package/dist/menubar.d.ts +76 -0
  166. package/dist/menubar.d.ts.map +1 -0
  167. package/dist/menubar.js +139 -0
  168. package/dist/message-scroller.d.ts +101 -0
  169. package/dist/message-scroller.d.ts.map +1 -0
  170. package/dist/message-scroller.js +215 -0
  171. package/dist/message.d.ts +48 -0
  172. package/dist/message.d.ts.map +1 -0
  173. package/dist/message.js +72 -0
  174. package/dist/native-form.d.ts +44 -0
  175. package/dist/native-form.d.ts.map +1 -0
  176. package/dist/native-form.js +111 -0
  177. package/dist/native-select.d.ts +56 -0
  178. package/dist/native-select.d.ts.map +1 -0
  179. package/dist/native-select.js +100 -0
  180. package/dist/navigation-bar.d.ts +30 -0
  181. package/dist/navigation-bar.d.ts.map +1 -0
  182. package/dist/navigation-bar.js +52 -0
  183. package/dist/navigation-menu.d.ts +97 -0
  184. package/dist/navigation-menu.d.ts.map +1 -0
  185. package/dist/navigation-menu.js +207 -0
  186. package/dist/navigation-stack.d.ts +36 -0
  187. package/dist/navigation-stack.d.ts.map +1 -0
  188. package/dist/navigation-stack.js +67 -0
  189. package/dist/observers.d.ts +21 -0
  190. package/dist/observers.d.ts.map +1 -0
  191. package/dist/observers.js +34 -0
  192. package/dist/page.d.ts +38 -0
  193. package/dist/page.d.ts.map +1 -0
  194. package/dist/page.js +68 -0
  195. package/dist/pagination.d.ts +39 -0
  196. package/dist/pagination.d.ts.map +1 -0
  197. package/dist/pagination.js +71 -0
  198. package/dist/pointer.d.ts +38 -0
  199. package/dist/pointer.d.ts.map +1 -0
  200. package/dist/pointer.js +82 -0
  201. package/dist/popover.d.ts +50 -0
  202. package/dist/popover.d.ts.map +1 -0
  203. package/dist/popover.js +90 -0
  204. package/dist/progress.d.ts +38 -0
  205. package/dist/progress.d.ts.map +1 -0
  206. package/dist/progress.js +81 -0
  207. package/dist/pull-to-refresh.d.ts +40 -0
  208. package/dist/pull-to-refresh.d.ts.map +1 -0
  209. package/dist/pull-to-refresh.js +65 -0
  210. package/dist/questionnaire.d.ts +117 -0
  211. package/dist/questionnaire.d.ts.map +1 -0
  212. package/dist/questionnaire.js +240 -0
  213. package/dist/radio-group.d.ts +53 -0
  214. package/dist/radio-group.d.ts.map +1 -0
  215. package/dist/radio-group.js +95 -0
  216. package/dist/rating.d.ts +67 -0
  217. package/dist/rating.d.ts.map +1 -0
  218. package/dist/rating.js +160 -0
  219. package/dist/resizable.d.ts +76 -0
  220. package/dist/resizable.d.ts.map +1 -0
  221. package/dist/resizable.js +138 -0
  222. package/dist/routing.d.ts +36 -0
  223. package/dist/routing.d.ts.map +1 -0
  224. package/dist/routing.js +50 -0
  225. package/dist/roving-focus.d.ts +38 -0
  226. package/dist/roving-focus.d.ts.map +1 -0
  227. package/dist/roving-focus.js +60 -0
  228. package/dist/scroll-area.d.ts +58 -0
  229. package/dist/scroll-area.d.ts.map +1 -0
  230. package/dist/scroll-area.js +153 -0
  231. package/dist/scroller.d.ts +41 -0
  232. package/dist/scroller.d.ts.map +1 -0
  233. package/dist/scroller.js +65 -0
  234. package/dist/select.d.ts +98 -0
  235. package/dist/select.d.ts.map +1 -0
  236. package/dist/select.js +203 -0
  237. package/dist/selectors.d.ts +44 -0
  238. package/dist/selectors.d.ts.map +1 -0
  239. package/dist/selectors.js +63 -0
  240. package/dist/send-pointer.d.ts +17 -0
  241. package/dist/send-pointer.d.ts.map +1 -0
  242. package/dist/send-pointer.js +35 -0
  243. package/dist/separator.d.ts +26 -0
  244. package/dist/separator.d.ts.map +1 -0
  245. package/dist/separator.js +40 -0
  246. package/dist/shadowed.d.ts +55 -0
  247. package/dist/shadowed.d.ts.map +1 -0
  248. package/dist/shadowed.js +97 -0
  249. package/dist/sheet.d.ts +14 -0
  250. package/dist/sheet.d.ts.map +1 -0
  251. package/dist/sheet.js +15 -0
  252. package/dist/sidebar.d.ts +159 -0
  253. package/dist/sidebar.d.ts.map +1 -0
  254. package/dist/sidebar.js +299 -0
  255. package/dist/skeleton.d.ts +18 -0
  256. package/dist/skeleton.d.ts.map +1 -0
  257. package/dist/skeleton.js +25 -0
  258. package/dist/slider.d.ts +66 -0
  259. package/dist/slider.d.ts.map +1 -0
  260. package/dist/slider.js +155 -0
  261. package/dist/spinner.d.ts +10 -0
  262. package/dist/spinner.d.ts.map +1 -0
  263. package/dist/spinner.js +13 -0
  264. package/dist/split-view.d.ts +77 -0
  265. package/dist/split-view.d.ts.map +1 -0
  266. package/dist/split-view.js +145 -0
  267. package/dist/status-bar.d.ts +25 -0
  268. package/dist/status-bar.d.ts.map +1 -0
  269. package/dist/status-bar.js +42 -0
  270. package/dist/sticky-footer.d.ts +33 -0
  271. package/dist/sticky-footer.d.ts.map +1 -0
  272. package/dist/sticky-footer.js +65 -0
  273. package/dist/switch.d.ts +44 -0
  274. package/dist/switch.d.ts.map +1 -0
  275. package/dist/switch.js +77 -0
  276. package/dist/tab-bar.d.ts +38 -0
  277. package/dist/tab-bar.d.ts.map +1 -0
  278. package/dist/tab-bar.js +78 -0
  279. package/dist/table.d.ts +41 -0
  280. package/dist/table.d.ts.map +1 -0
  281. package/dist/table.js +100 -0
  282. package/dist/tabs.d.ts +66 -0
  283. package/dist/tabs.d.ts.map +1 -0
  284. package/dist/tabs.js +149 -0
  285. package/dist/test-hooks.d.ts +9 -0
  286. package/dist/test-hooks.d.ts.map +1 -0
  287. package/dist/test-hooks.js +1 -0
  288. package/dist/textarea.d.ts +47 -0
  289. package/dist/textarea.d.ts.map +1 -0
  290. package/dist/textarea.js +78 -0
  291. package/dist/title-bar.d.ts +43 -0
  292. package/dist/title-bar.d.ts.map +1 -0
  293. package/dist/title-bar.js +74 -0
  294. package/dist/toaster.d.ts +172 -0
  295. package/dist/toaster.d.ts.map +1 -0
  296. package/dist/toaster.js +307 -0
  297. package/dist/toggle-group.d.ts +51 -0
  298. package/dist/toggle-group.d.ts.map +1 -0
  299. package/dist/toggle-group.js +97 -0
  300. package/dist/toggle.d.ts +21 -0
  301. package/dist/toggle.d.ts.map +1 -0
  302. package/dist/toggle.js +26 -0
  303. package/dist/toolbar.d.ts +40 -0
  304. package/dist/toolbar.d.ts.map +1 -0
  305. package/dist/toolbar.js +67 -0
  306. package/dist/tooltip.d.ts +48 -0
  307. package/dist/tooltip.d.ts.map +1 -0
  308. package/dist/tooltip.js +91 -0
  309. package/dist/trace.d.ts +118 -0
  310. package/dist/trace.d.ts.map +1 -0
  311. package/dist/trace.js +196 -0
  312. package/dist/translator.d.ts +34 -0
  313. package/dist/translator.d.ts.map +1 -0
  314. package/dist/translator.js +75 -0
  315. package/dist/window-frame.d.ts +40 -0
  316. package/dist/window-frame.d.ts.map +1 -0
  317. package/dist/window-frame.js +66 -0
  318. package/dist/zoetrope.d.ts +51 -0
  319. package/dist/zoetrope.d.ts.map +1 -0
  320. package/dist/zoetrope.js +94 -0
  321. package/package.json +68 -3
@@ -0,0 +1,41 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Table>` from `@ember-joinery/ember`. It reads the table as a screen reader does,
4
+ * through its native structure: the caption, the header row's cells, and each row of the body
5
+ * and the footer.
6
+ *
7
+ * const invoices = new TableHarness('invoices') // <Table @name="invoices">
8
+ * assert.deepEqual(invoices.columns, ['Invoice', 'Status', 'Method', 'Amount'])
9
+ * assert.strictEqual(invoices.cell(0, 'Amount').textContent, '$250.00')
10
+ * assert.deepEqual(invoices.column('Status'), ['Paid', 'Pending', 'Unpaid'])
11
+ */
12
+ export declare class TableHarness extends Harness {
13
+ #private;
14
+ static component: string;
15
+ /** The table element itself: `element`, typed. */
16
+ get table(): HTMLTableElement;
17
+ /** The element around the table that scrolls it sideways when it is too wide (`table-container`). */
18
+ get container(): HTMLElement;
19
+ /** The caption's text, or `null` without one. */
20
+ get caption(): string | null;
21
+ /** The text of each cell in the header's last row: the columns' names. */
22
+ get columns(): string[];
23
+ /** The body's rows (`tr`), in order. */
24
+ get rowElements(): HTMLTableRowElement[];
25
+ /** The text of each body row's cells, row by row. */
26
+ get rows(): string[][];
27
+ /** How many rows the body has. */
28
+ get rowCount(): number;
29
+ /** The text of each footer row's cells, row by row (`[]` without a footer). */
30
+ get footer(): string[][];
31
+ /** The body's row at `index`, counting from 0. Throws when there is none. */
32
+ row(index: number): HTMLTableRowElement;
33
+ /**
34
+ * The cell of the body's row `index` in a column, given by its position or its name (a header
35
+ * cell's text). It counts cells, so a cell spanning columns (`colspan`) counts once.
36
+ */
37
+ cell(index: number, column: number | string): HTMLTableCellElement;
38
+ /** The text of every body row's cell in a column, given by its position or its name. */
39
+ column(column: number | string): string[];
40
+ }
41
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAYtC;;;;;;;;;GASG;AACH,qBAAa,YAAa,SAAQ,OAAO;;IACvC,OAAgB,SAAS,SAAU;IAEnC,kDAAkD;IAClD,IAAI,KAAK,IAAI,gBAAgB,CAE5B;IAED,qGAAqG;IACrG,IAAI,SAAS,IAAI,WAAW,CAM3B;IAED,iDAAiD;IACjD,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAG3B;IAED,0EAA0E;IAC1E,IAAI,OAAO,IAAI,MAAM,EAAE,CAItB;IAED,wCAAwC;IACxC,IAAI,WAAW,IAAI,mBAAmB,EAAE,CAEvC;IAED,qDAAqD;IACrD,IAAI,IAAI,IAAI,MAAM,EAAE,EAAE,CAErB;IAED,kCAAkC;IAClC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,+EAA+E;IAC/E,IAAI,MAAM,IAAI,MAAM,EAAE,EAAE,CAEvB;IAED,6EAA6E;IAC7E,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB;IAMvC;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,oBAAoB;IAOlE,wFAAwF;IACxF,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE;CAmB1C"}
package/dist/table.js ADDED
@@ -0,0 +1,100 @@
1
+ import { isNumber } from '@sindresorhus/is';
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
+ /** A row's cells, `th` and `td`, in order. */
8
+ function cellsOf(row) {
9
+ return [...row.cells];
10
+ }
11
+ /**
12
+ * Drives a `<Table>` from `@ember-joinery/ember`. It reads the table as a screen reader does,
13
+ * through its native structure: the caption, the header row's cells, and each row of the body
14
+ * and the footer.
15
+ *
16
+ * const invoices = new TableHarness('invoices') // <Table @name="invoices">
17
+ * assert.deepEqual(invoices.columns, ['Invoice', 'Status', 'Method', 'Amount'])
18
+ * assert.strictEqual(invoices.cell(0, 'Amount').textContent, '$250.00')
19
+ * assert.deepEqual(invoices.column('Status'), ['Paid', 'Pending', 'Unpaid'])
20
+ */
21
+ export class TableHarness extends Harness {
22
+ static component = 'table';
23
+ /** The table element itself: `element`, typed. */
24
+ get table() {
25
+ return this.element;
26
+ }
27
+ /** The element around the table that scrolls it sideways when it is too wide (`table-container`). */
28
+ get container() {
29
+ const container = this.element.parentElement;
30
+ if (!container || container.getAttribute('data-slot') !== 'table-container') {
31
+ throw new NotFoundError(`no table container around ${this}`);
32
+ }
33
+ return container;
34
+ }
35
+ /** The caption's text, or `null` without one. */
36
+ get caption() {
37
+ const caption = this.table.caption;
38
+ return caption ? text(caption) : null;
39
+ }
40
+ /** The text of each cell in the header's last row: the columns' names. */
41
+ get columns() {
42
+ const rows = this.#rowsOf(this.table.tHead);
43
+ const last = rows.at(-1);
44
+ return last ? cellsOf(last).map(text) : [];
45
+ }
46
+ /** The body's rows (`tr`), in order. */
47
+ get rowElements() {
48
+ return [...this.table.tBodies].flatMap(body => this.#rowsOf(body));
49
+ }
50
+ /** The text of each body row's cells, row by row. */
51
+ get rows() {
52
+ return this.rowElements.map(row => cellsOf(row).map(text));
53
+ }
54
+ /** How many rows the body has. */
55
+ get rowCount() {
56
+ return this.rowElements.length;
57
+ }
58
+ /** The text of each footer row's cells, row by row (`[]` without a footer). */
59
+ get footer() {
60
+ return this.#rowsOf(this.table.tFoot).map(row => cellsOf(row).map(text));
61
+ }
62
+ /** The body's row at `index`, counting from 0. Throws when there is none. */
63
+ row(index) {
64
+ const row = this.rowElements[index];
65
+ if (!row)
66
+ throw new NotFoundError(`no row ${index} in ${this} (it has ${this.rowCount})`);
67
+ return row;
68
+ }
69
+ /**
70
+ * The cell of the body's row `index` in a column, given by its position or its name (a header
71
+ * cell's text). It counts cells, so a cell spanning columns (`colspan`) counts once.
72
+ */
73
+ cell(index, column) {
74
+ const position = this.#columnIndex(column);
75
+ const cell = cellsOf(this.row(index))[position];
76
+ if (!cell)
77
+ throw new NotFoundError(`no cell ${position} in row ${index} of ${this}`);
78
+ return cell;
79
+ }
80
+ /** The text of every body row's cell in a column, given by its position or its name. */
81
+ column(column) {
82
+ const position = this.#columnIndex(column);
83
+ return this.rowElements.map(row => {
84
+ const cell = cellsOf(row)[position];
85
+ return cell ? text(cell) : '';
86
+ });
87
+ }
88
+ #columnIndex(column) {
89
+ if (isNumber(column))
90
+ return column;
91
+ const index = this.columns.indexOf(column);
92
+ if (index === -1)
93
+ throw new NotFoundError(`no column "${column}" in ${this}`);
94
+ return index;
95
+ }
96
+ /** A section's own rows: not a nested table's. */
97
+ #rowsOf(section) {
98
+ return section ? [...section.rows] : [];
99
+ }
100
+ }
package/dist/tabs.d.ts ADDED
@@ -0,0 +1,66 @@
1
+ import { Harness } from './harness.ts';
2
+ import { type KeyModifiers } from './focus.ts';
3
+ /**
4
+ * Drives a `<Tabs>` from `@ember-joinery/ember`, or the primitives' `Tabs`. Its tabs and panels
5
+ * are found by their `@value` (`data-test-jn-value`), and read through ARIA: the selected tab by
6
+ * `aria-selected`, its panel by the tab's `aria-controls`.
7
+ *
8
+ * const settings = new TabsHarness('settings') // <Tabs @name="settings">
9
+ * await settings.select('password')
10
+ * assert.strictEqual(settings.selected, 'password')
11
+ * assert.strictEqual(settings.panelText, 'Change your password here.')
12
+ * await settings.press('ArrowLeft')
13
+ * assert.strictEqual(settings.focused, 'account')
14
+ */
15
+ export declare class TabsHarness extends Harness {
16
+ static component: string;
17
+ /** The tab list (`role="tablist"`). */
18
+ get list(): HTMLElement;
19
+ /** Each tab's element, in order. */
20
+ get triggers(): HTMLElement[];
21
+ /** Each tab's value, in order. */
22
+ get tabValues(): string[];
23
+ /** The tab whose `@value` this is. Throws when there is none. */
24
+ trigger(value: string): HTMLElement;
25
+ /** The panel whose `@value` this is, shown or not. Throws when there is none. */
26
+ content(value: string): HTMLElement;
27
+ /** The value of the selected tab (`aria-selected="true"`), or `null` when none is. */
28
+ get selected(): string | null;
29
+ /** Whether the tab with this value is selected (`aria-selected`). */
30
+ isSelected(value: string): boolean;
31
+ /**
32
+ * The panel shown now: the one the selected tab's `aria-controls` names, unless it is
33
+ * `hidden` (or isn't rendered), else `null`.
34
+ */
35
+ get panel(): HTMLElement | null;
36
+ /** The text of the panel shown now, whitespace collapsed, or `''` when none is. */
37
+ get panelText(): string;
38
+ /** Whether the panel for this value is rendered and not `hidden`. */
39
+ isShown(value: string): boolean;
40
+ /** Whether the tab can't be selected: `disabled`, or `aria-disabled="true"` on a link. */
41
+ isDisabled(value: string): boolean;
42
+ /** Whether the tab is a link tab (an `<a href>`, such as a `LinkTo`). */
43
+ isLink(value: string): boolean;
44
+ /** A tab's accessible name: its `aria-label`, else `aria-labelledby`'s text, else its text. */
45
+ label(value: string): string;
46
+ /** The tab list's accessible name: its `aria-label` or `aria-labelledby`, else `''`. */
47
+ get listLabel(): string;
48
+ /** `horizontal` or `vertical`: the tab list's `aria-orientation`. */
49
+ get orientation(): string | null;
50
+ /** The styled tab list's `@variant` (`default` or `line`), or `null` on the primitive. */
51
+ get variant(): string | null;
52
+ /** The value of the tab Tab lands on (`tabindex="0"`), or `null` while the list itself does. */
53
+ get tabStop(): string | null;
54
+ /** The value of the tab that has focus, or `null` when focus is elsewhere. */
55
+ get focused(): string | null;
56
+ /**
57
+ * Clicks a tab, as a user selects it. A disabled `<button>` ignores the click, as in a
58
+ * browser (`click()` from `@ember/test-helpers` would throw on one).
59
+ */
60
+ select(value: string): Promise<void>;
61
+ /** Focuses a tab, as a click or the arrow keys would (in `automatic` mode, that selects it). */
62
+ focus(value: string): Promise<void>;
63
+ /** Presses a key on the focused element: `'ArrowRight'`, `'Home'`, `'Enter'`, `' '`. */
64
+ press(key: string, modifiers?: KeyModifiers): Promise<void>;
65
+ }
66
+ //# sourceMappingURL=tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../src/tabs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AAsBxD;;;;;;;;;;;GAWG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACtC,OAAgB,SAAS,SAAS;IAElC,uCAAuC;IACvC,IAAI,IAAI,IAAI,WAAW,CAEtB;IAED,oCAAoC;IACpC,IAAI,QAAQ,IAAI,WAAW,EAAE,CAE5B;IAED,kCAAkC;IAClC,IAAI,SAAS,IAAI,MAAM,EAAE,CAExB;IAED,iEAAiE;IACjE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAInC,iFAAiF;IACjF,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAInC,sFAAsF;IACtF,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAG5B;IAED,qEAAqE;IACrE,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIlC;;;OAGG;IACH,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAM9B;IAED,mFAAmF;IACnF,IAAI,SAAS,IAAI,MAAM,CAGtB;IAED,qEAAqE;IACrE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAK/B,0FAA0F;IAC1F,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAMlC,yEAAyE;IACzE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAK9B,+FAA+F;IAC/F,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI5B,wFAAwF;IACxF,IAAI,SAAS,IAAI,MAAM,CAItB;IAED,qEAAqE;IACrE,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAE/B;IAED,0FAA0F;IAC1F,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,gGAAgG;IAChG,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAG3B;IAED,8EAA8E;IAC9E,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAI3B;IAED;;;OAGG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1C,gGAAgG;IAC1F,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,wFAAwF;IAClF,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlE"}
package/dist/tabs.js ADDED
@@ -0,0 +1,149 @@
1
+ import { click, focus, settled } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { attributes } from "./selectors.js";
4
+ import { pressKey } from "./focus.js";
5
+ function text(element) {
6
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
7
+ }
8
+ /** An element's accessible name: `aria-label`, else `aria-labelledby`'s text, else its text. */
9
+ function nameOf(element) {
10
+ const label = element.getAttribute('aria-label');
11
+ if (label)
12
+ return label.trim();
13
+ const labelledBy = element.getAttribute('aria-labelledby');
14
+ if (labelledBy) {
15
+ return labelledBy
16
+ .split(/\s+/)
17
+ .map(id => element.ownerDocument.getElementById(id))
18
+ .filter((found) => Boolean(found))
19
+ .map(text)
20
+ .join(' ');
21
+ }
22
+ return text(element);
23
+ }
24
+ /**
25
+ * Drives a `<Tabs>` from `@ember-joinery/ember`, or the primitives' `Tabs`. Its tabs and panels
26
+ * are found by their `@value` (`data-test-jn-value`), and read through ARIA: the selected tab by
27
+ * `aria-selected`, its panel by the tab's `aria-controls`.
28
+ *
29
+ * const settings = new TabsHarness('settings') // <Tabs @name="settings">
30
+ * await settings.select('password')
31
+ * assert.strictEqual(settings.selected, 'password')
32
+ * assert.strictEqual(settings.panelText, 'Change your password here.')
33
+ * await settings.press('ArrowLeft')
34
+ * assert.strictEqual(settings.focused, 'account')
35
+ */
36
+ export class TabsHarness extends Harness {
37
+ static component = 'tabs';
38
+ /** The tab list (`role="tablist"`). */
39
+ get list() {
40
+ return this.part('list');
41
+ }
42
+ /** Each tab's element, in order. */
43
+ get triggers() {
44
+ return this.parts('trigger');
45
+ }
46
+ /** Each tab's value, in order. */
47
+ get tabValues() {
48
+ return this.values('trigger');
49
+ }
50
+ /** The tab whose `@value` this is. Throws when there is none. */
51
+ trigger(value) {
52
+ return this.part('trigger', value);
53
+ }
54
+ /** The panel whose `@value` this is, shown or not. Throws when there is none. */
55
+ content(value) {
56
+ return this.part('content', value);
57
+ }
58
+ /** The value of the selected tab (`aria-selected="true"`), or `null` when none is. */
59
+ get selected() {
60
+ const tab = this.triggers.find(element => element.getAttribute('aria-selected') === 'true');
61
+ return tab?.getAttribute(attributes.value) ?? null;
62
+ }
63
+ /** Whether the tab with this value is selected (`aria-selected`). */
64
+ isSelected(value) {
65
+ return this.trigger(value).getAttribute('aria-selected') === 'true';
66
+ }
67
+ /**
68
+ * The panel shown now: the one the selected tab's `aria-controls` names, unless it is
69
+ * `hidden` (or isn't rendered), else `null`.
70
+ */
71
+ get panel() {
72
+ const selected = this.selected;
73
+ if (selected === null)
74
+ return null;
75
+ const id = this.trigger(selected).getAttribute('aria-controls');
76
+ const panel = id ? this.element.ownerDocument.getElementById(id) : null;
77
+ return panel && !panel.hidden ? panel : null;
78
+ }
79
+ /** The text of the panel shown now, whitespace collapsed, or `''` when none is. */
80
+ get panelText() {
81
+ const panel = this.panel;
82
+ return panel ? text(panel) : '';
83
+ }
84
+ /** Whether the panel for this value is rendered and not `hidden`. */
85
+ isShown(value) {
86
+ const panel = this.queryPart('content', value);
87
+ return Boolean(panel && !panel.hidden);
88
+ }
89
+ /** Whether the tab can't be selected: `disabled`, or `aria-disabled="true"` on a link. */
90
+ isDisabled(value) {
91
+ const tab = this.trigger(value);
92
+ if (tab instanceof HTMLButtonElement && tab.disabled)
93
+ return true;
94
+ return tab.getAttribute('aria-disabled') === 'true';
95
+ }
96
+ /** Whether the tab is a link tab (an `<a href>`, such as a `LinkTo`). */
97
+ isLink(value) {
98
+ const tab = this.trigger(value);
99
+ return tab instanceof HTMLAnchorElement && tab.hasAttribute('href');
100
+ }
101
+ /** A tab's accessible name: its `aria-label`, else `aria-labelledby`'s text, else its text. */
102
+ label(value) {
103
+ return nameOf(this.trigger(value));
104
+ }
105
+ /** The tab list's accessible name: its `aria-label` or `aria-labelledby`, else `''`. */
106
+ get listLabel() {
107
+ const list = this.list;
108
+ if (!list.hasAttribute('aria-label') && !list.hasAttribute('aria-labelledby'))
109
+ return '';
110
+ return nameOf(list);
111
+ }
112
+ /** `horizontal` or `vertical`: the tab list's `aria-orientation`. */
113
+ get orientation() {
114
+ return this.list.getAttribute('aria-orientation');
115
+ }
116
+ /** The styled tab list's `@variant` (`default` or `line`), or `null` on the primitive. */
117
+ get variant() {
118
+ return this.list.getAttribute('data-variant');
119
+ }
120
+ /** The value of the tab Tab lands on (`tabindex="0"`), or `null` while the list itself does. */
121
+ get tabStop() {
122
+ const tab = this.triggers.find(element => element.getAttribute('tabindex') === '0');
123
+ return tab?.getAttribute(attributes.value) ?? null;
124
+ }
125
+ /** The value of the tab that has focus, or `null` when focus is elsewhere. */
126
+ get focused() {
127
+ const active = this.element.ownerDocument.activeElement;
128
+ const tab = this.triggers.find(element => element === active || element.contains(active));
129
+ return tab?.getAttribute(attributes.value) ?? null;
130
+ }
131
+ /**
132
+ * Clicks a tab, as a user selects it. A disabled `<button>` ignores the click, as in a
133
+ * browser (`click()` from `@ember/test-helpers` would throw on one).
134
+ */
135
+ async select(value) {
136
+ const tab = this.trigger(value);
137
+ if (tab instanceof HTMLButtonElement && tab.disabled)
138
+ return settled();
139
+ await click(tab);
140
+ }
141
+ /** Focuses a tab, as a click or the arrow keys would (in `automatic` mode, that selects it). */
142
+ async focus(value) {
143
+ await focus(this.trigger(value));
144
+ }
145
+ /** Presses a key on the focused element: `'ArrowRight'`, `'Home'`, `'Enter'`, `' '`. */
146
+ async press(key, modifiers) {
147
+ await pressKey(key, modifiers);
148
+ }
149
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The test hooks a `setup…(hooks)` helper registers on: QUnit's `hooks`, or the same shape
3
+ * around Vitest's `beforeEach` and `afterEach`.
4
+ */
5
+ export interface TestHooks {
6
+ beforeEach(callback: () => void | Promise<void>): void;
7
+ afterEach(callback: () => void | Promise<void>): void;
8
+ }
9
+ //# sourceMappingURL=test-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-hooks.d.ts","sourceRoot":"","sources":["../src/test-hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACtD,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CACtD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Textarea>` from `@ember-joinery/ember`, or a `<textarea>` made one with its
4
+ * `asTextarea` modifier. State comes from the element and its ARIA; it types the way a user
5
+ * does.
6
+ *
7
+ * const message = new TextareaHarness('message') // <Textarea @name="message">
8
+ * await message.fillIn('Hello')
9
+ * assert.strictEqual(message.value, 'Hello')
10
+ */
11
+ export declare class TextareaHarness extends Harness {
12
+ static component: string;
13
+ /** The `<textarea>` itself. */
14
+ get control(): HTMLTextAreaElement;
15
+ /** What it holds now. */
16
+ get value(): string;
17
+ /** Its `placeholder`, or `''`. */
18
+ get placeholder(): string;
19
+ /**
20
+ * Its accessible name, as assistive technology reads it: `aria-labelledby`'s text, else
21
+ * `aria-label`, else its `<label>`'s text, else `title`, else `placeholder`.
22
+ */
23
+ get label(): string;
24
+ /** The text of what its `aria-describedby` names (a field's description and errors), or `''`. */
25
+ get description(): string;
26
+ /** Whether it is `disabled`. */
27
+ get isDisabled(): boolean;
28
+ /** Whether it is `readonly`. */
29
+ get isReadOnly(): boolean;
30
+ /** Whether it is `required`. */
31
+ get isRequired(): boolean;
32
+ /** Whether it is marked invalid with `aria-invalid`. */
33
+ get isInvalid(): boolean;
34
+ /** Whether it has focus. */
35
+ get isFocused(): boolean;
36
+ /** Replaces what it holds with `text`, as pasting does: one `input` event, then `change`. */
37
+ fillIn(text: string): Promise<void>;
38
+ /** Types `text` one key at a time after what it holds, as a user does. */
39
+ typeIn(text: string): Promise<void>;
40
+ /** Empties it. */
41
+ clear(): Promise<void>;
42
+ /** Moves focus to it, as tabbing to it would. Fails if it can't take focus. */
43
+ focus(): Promise<void>;
44
+ /** Moves focus away from it. */
45
+ blur(): Promise<void>;
46
+ }
47
+ //# sourceMappingURL=textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../src/textarea.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAa;IAEtC,+BAA+B;IAC/B,IAAI,OAAO,IAAI,mBAAmB,CAEjC;IAED,yBAAyB;IACzB,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,kCAAkC;IAClC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,iGAAiG;IACjG,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,wDAAwD;IACxD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,4BAA4B;IAC5B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,6FAA6F;IACvF,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,0EAA0E;IACpE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,kBAAkB;IACZ,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,gCAAgC;IAC1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
@@ -0,0 +1,78 @@
1
+ import { blur, fillIn, focus, typeIn } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { controlDescription, controlLabel, isMarkedInvalid } from "./-private/control.js";
4
+ /**
5
+ * Drives a `<Textarea>` from `@ember-joinery/ember`, or a `<textarea>` made one with its
6
+ * `asTextarea` modifier. State comes from the element and its ARIA; it types the way a user
7
+ * does.
8
+ *
9
+ * const message = new TextareaHarness('message') // <Textarea @name="message">
10
+ * await message.fillIn('Hello')
11
+ * assert.strictEqual(message.value, 'Hello')
12
+ */
13
+ export class TextareaHarness extends Harness {
14
+ static component = 'textarea';
15
+ /** The `<textarea>` itself. */
16
+ get control() {
17
+ return this.element;
18
+ }
19
+ /** What it holds now. */
20
+ get value() {
21
+ return this.control.value;
22
+ }
23
+ /** Its `placeholder`, or `''`. */
24
+ get placeholder() {
25
+ return this.control.placeholder;
26
+ }
27
+ /**
28
+ * Its accessible name, as assistive technology reads it: `aria-labelledby`'s text, else
29
+ * `aria-label`, else its `<label>`'s text, else `title`, else `placeholder`.
30
+ */
31
+ get label() {
32
+ return controlLabel(this.control);
33
+ }
34
+ /** The text of what its `aria-describedby` names (a field's description and errors), or `''`. */
35
+ get description() {
36
+ return controlDescription(this.control);
37
+ }
38
+ /** Whether it is `disabled`. */
39
+ get isDisabled() {
40
+ return this.control.disabled;
41
+ }
42
+ /** Whether it is `readonly`. */
43
+ get isReadOnly() {
44
+ return this.control.readOnly;
45
+ }
46
+ /** Whether it is `required`. */
47
+ get isRequired() {
48
+ return this.control.required;
49
+ }
50
+ /** Whether it is marked invalid with `aria-invalid`. */
51
+ get isInvalid() {
52
+ return isMarkedInvalid(this.control);
53
+ }
54
+ /** Whether it has focus. */
55
+ get isFocused() {
56
+ return this.control.ownerDocument.activeElement === this.control;
57
+ }
58
+ /** Replaces what it holds with `text`, as pasting does: one `input` event, then `change`. */
59
+ async fillIn(text) {
60
+ await fillIn(this.control, text);
61
+ }
62
+ /** Types `text` one key at a time after what it holds, as a user does. */
63
+ async typeIn(text) {
64
+ await typeIn(this.control, text);
65
+ }
66
+ /** Empties it. */
67
+ async clear() {
68
+ await fillIn(this.control, '');
69
+ }
70
+ /** Moves focus to it, as tabbing to it would. Fails if it can't take focus. */
71
+ async focus() {
72
+ await focus(this.control);
73
+ }
74
+ /** Moves focus away from it. */
75
+ async blur() {
76
+ await blur(this.control);
77
+ }
78
+ }
@@ -0,0 +1,43 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Reads a `<TitleBar>` from `@ember-joinery/ember`: its title, how it is laid out, and its
4
+ * parts.
5
+ *
6
+ * const bar = new TitleBarHarness('main') // <TitleBar @name="main">
7
+ * assert.strictEqual(bar.title, 'Inbox')
8
+ * assert.strictEqual(bar.variant, 'unified')
9
+ * assert.false(bar.isInactive)
10
+ *
11
+ * The bar wraps the app's controls, so its own parts are found by their `data-jn-title-bar-*`
12
+ * attributes. A component in one of its parts has a harness of its own:
13
+ * `bar.find(ToolbarHarness)`.
14
+ */
15
+ export declare class TitleBarHarness extends Harness {
16
+ #private;
17
+ static component: string;
18
+ /** The title's text, or `''` when it has none. */
19
+ get title(): string;
20
+ /** The subtitle's text, or `''` when it has none. */
21
+ get subtitle(): string;
22
+ /** Its `@variant`: `unified`, `unified-compact` or `expanded`. */
23
+ get variant(): string | null;
24
+ /** Its `@controls`: `none`, `start` or `overlay`. */
25
+ get controls(): string | null;
26
+ /** Whether it has the inactive look: the window has no focus, or `@inactive`. */
27
+ get isInactive(): boolean;
28
+ /** Whether it is a drag region. */
29
+ get isDraggable(): boolean;
30
+ /** The title's element. Throws when it has none. */
31
+ get titleElement(): HTMLElement;
32
+ /** The `Leading` part, or `null`. */
33
+ get leading(): HTMLElement | null;
34
+ /** The `Center` part, or `null`. */
35
+ get center(): HTMLElement | null;
36
+ /** The `Trailing` part, or `null`. */
37
+ get trailing(): HTMLElement | null;
38
+ /** The `Toolbar` row part, or `null`. */
39
+ get toolbar(): HTMLElement | null;
40
+ /** The `TrafficLights` part, or `null`. */
41
+ get trafficLights(): HTMLElement | null;
42
+ }
43
+ //# sourceMappingURL=title-bar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title-bar.d.ts","sourceRoot":"","sources":["../src/title-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAgB,SAAQ,OAAO;;IAC1C,OAAgB,SAAS,SAAc;IAMvC,kDAAkD;IAClD,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,qDAAqD;IACrD,IAAI,QAAQ,IAAI,MAAM,CAGrB;IAED,kEAAkE;IAClE,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,qDAAqD;IACrD,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;IAED,iFAAiF;IACjF,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,mCAAmC;IACnC,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,oDAAoD;IACpD,IAAI,YAAY,IAAI,WAAW,CAI9B;IAED,qCAAqC;IACrC,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,oCAAoC;IACpC,IAAI,MAAM,IAAI,WAAW,GAAG,IAAI,CAE/B;IAED,sCAAsC;IACtC,IAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,CAEjC;IAED,yCAAyC;IACzC,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,2CAA2C;IAC3C,IAAI,aAAa,IAAI,WAAW,GAAG,IAAI,CAEtC;CACF"}
@@ -0,0 +1,74 @@
1
+ import { Harness } from "./harness.js";
2
+ import { textOf } from "./-private/checkable.js";
3
+ /**
4
+ * Reads a `<TitleBar>` from `@ember-joinery/ember`: its title, how it is laid out, and its
5
+ * parts.
6
+ *
7
+ * const bar = new TitleBarHarness('main') // <TitleBar @name="main">
8
+ * assert.strictEqual(bar.title, 'Inbox')
9
+ * assert.strictEqual(bar.variant, 'unified')
10
+ * assert.false(bar.isInactive)
11
+ *
12
+ * The bar wraps the app's controls, so its own parts are found by their `data-jn-title-bar-*`
13
+ * attributes. A component in one of its parts has a harness of its own:
14
+ * `bar.find(ToolbarHarness)`.
15
+ */
16
+ export class TitleBarHarness extends Harness {
17
+ static component = 'title-bar';
18
+ #query(part) {
19
+ return this.element.querySelector(`[data-jn-title-bar-${part}]`);
20
+ }
21
+ /** The title's text, or `''` when it has none. */
22
+ get title() {
23
+ const title = this.#query('title');
24
+ return title ? textOf(title) : '';
25
+ }
26
+ /** The subtitle's text, or `''` when it has none. */
27
+ get subtitle() {
28
+ const subtitle = this.#query('subtitle');
29
+ return subtitle ? textOf(subtitle) : '';
30
+ }
31
+ /** Its `@variant`: `unified`, `unified-compact` or `expanded`. */
32
+ get variant() {
33
+ return this.element.getAttribute('data-variant');
34
+ }
35
+ /** Its `@controls`: `none`, `start` or `overlay`. */
36
+ get controls() {
37
+ return this.element.getAttribute('data-controls');
38
+ }
39
+ /** Whether it has the inactive look: the window has no focus, or `@inactive`. */
40
+ get isInactive() {
41
+ return this.element.hasAttribute('data-inactive');
42
+ }
43
+ /** Whether it is a drag region. */
44
+ get isDraggable() {
45
+ return this.element.hasAttribute('data-draggable');
46
+ }
47
+ /** The title's element. Throws when it has none. */
48
+ get titleElement() {
49
+ const title = this.#query('title');
50
+ if (!title)
51
+ throw new Error(`Joinery harness: no title in ${this}`);
52
+ return title;
53
+ }
54
+ /** The `Leading` part, or `null`. */
55
+ get leading() {
56
+ return this.#query('leading');
57
+ }
58
+ /** The `Center` part, or `null`. */
59
+ get center() {
60
+ return this.#query('center');
61
+ }
62
+ /** The `Trailing` part, or `null`. */
63
+ get trailing() {
64
+ return this.#query('trailing');
65
+ }
66
+ /** The `Toolbar` row part, or `null`. */
67
+ get toolbar() {
68
+ return this.#query('toolbar');
69
+ }
70
+ /** The `TrafficLights` part, or `null`. */
71
+ get trafficLights() {
72
+ return this.#query('traffic-lights');
73
+ }
74
+ }