@gjsify/adwaita-web 0.31.0 → 0.33.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 (183) hide show
  1. package/dist/adwaita-web.css +835 -299
  2. package/dist/adwaita-web.css.map +1 -1
  3. package/lib/types/adw-about-dialog.spec.d.ts +1 -0
  4. package/lib/types/adw-action-rows.spec.d.ts +1 -0
  5. package/lib/types/adw-avatar.spec.d.ts +1 -0
  6. package/lib/types/adw-banner.spec.d.ts +1 -0
  7. package/lib/types/adw-button-content.spec.d.ts +1 -0
  8. package/lib/types/adw-carousel.spec.d.ts +1 -0
  9. package/lib/types/adw-checks.spec.d.ts +1 -0
  10. package/lib/types/adw-header-bar.spec.d.ts +1 -0
  11. package/lib/types/adw-icon.spec.d.ts +1 -0
  12. package/lib/types/adw-progress-bar.spec.d.ts +1 -0
  13. package/lib/types/adw-sidebar.spec.d.ts +1 -0
  14. package/lib/types/adw-switch.spec.d.ts +1 -0
  15. package/lib/types/adw-wrap-box.spec.d.ts +1 -0
  16. package/lib/types/bottom-sheet.spec.d.ts +1 -0
  17. package/lib/types/breakpoints.d.ts +22 -0
  18. package/lib/types/breakpoints.spec.d.ts +1 -0
  19. package/lib/types/chrome.spec.d.ts +1 -0
  20. package/lib/types/elements/adw-about-dialog.d.ts +47 -8
  21. package/lib/types/elements/adw-action-row.d.ts +35 -0
  22. package/lib/types/elements/adw-avatar.d.ts +11 -0
  23. package/lib/types/elements/adw-bottom-sheet.d.ts +33 -4
  24. package/lib/types/elements/adw-button-content.d.ts +12 -0
  25. package/lib/types/elements/adw-button-row.d.ts +10 -1
  26. package/lib/types/elements/adw-carousel.d.ts +111 -8
  27. package/lib/types/elements/adw-checks.d.ts +57 -0
  28. package/lib/types/elements/adw-clamp.d.ts +4 -1
  29. package/lib/types/elements/adw-combo-row.d.ts +10 -0
  30. package/lib/types/elements/adw-data-grid.d.ts +11 -31
  31. package/lib/types/elements/adw-drop-down.d.ts +17 -20
  32. package/lib/types/elements/adw-entry-row.d.ts +93 -3
  33. package/lib/types/elements/adw-expander-row.d.ts +7 -1
  34. package/lib/types/elements/adw-header-bar.d.ts +15 -0
  35. package/lib/types/elements/adw-icon.d.ts +25 -0
  36. package/lib/types/elements/adw-inline-view-switcher.d.ts +73 -11
  37. package/lib/types/elements/adw-menu-button.d.ts +6 -6
  38. package/lib/types/elements/adw-navigation-split-view.d.ts +48 -0
  39. package/lib/types/elements/adw-navigation-view.d.ts +63 -20
  40. package/lib/types/elements/adw-overlay-split-view.d.ts +94 -0
  41. package/lib/types/elements/adw-password-entry-row.d.ts +19 -10
  42. package/lib/types/elements/adw-popover.d.ts +58 -0
  43. package/lib/types/elements/adw-preferences-dialog.d.ts +57 -2
  44. package/lib/types/elements/adw-preferences-group.d.ts +31 -0
  45. package/lib/types/elements/adw-progress-bar.d.ts +38 -0
  46. package/lib/types/elements/adw-sidebar.d.ts +37 -5
  47. package/lib/types/elements/adw-spinner.d.ts +23 -0
  48. package/lib/types/elements/adw-split-button.d.ts +53 -7
  49. package/lib/types/elements/adw-switch-row.d.ts +11 -2
  50. package/lib/types/elements/adw-switch.d.ts +15 -0
  51. package/lib/types/elements/adw-tab-view.d.ts +129 -12
  52. package/lib/types/elements/adw-toolbar-view.d.ts +5 -0
  53. package/lib/types/elements/adw-view-stack.d.ts +39 -19
  54. package/lib/types/elements/adw-view-switcher-bar.d.ts +25 -7
  55. package/lib/types/elements/adw-view-switcher.d.ts +76 -13
  56. package/lib/types/elements/adw-window-title.d.ts +3 -1
  57. package/lib/types/elements/adw-wrap-box.d.ts +58 -3
  58. package/lib/types/elements/view-switcher-dom.d.ts +44 -0
  59. package/lib/types/entry-rows.spec.d.ts +1 -0
  60. package/lib/types/index.d.ts +7 -0
  61. package/lib/types/navigation-view.spec.d.ts +1 -0
  62. package/lib/types/preferences-search.d.ts +20 -0
  63. package/lib/types/preferences.spec.d.ts +1 -0
  64. package/lib/types/split-button.spec.d.ts +1 -0
  65. package/lib/types/split-views.spec.d.ts +1 -0
  66. package/lib/types/styles.generated.d.ts +1 -1
  67. package/lib/types/tab-view.spec.d.ts +1 -0
  68. package/lib/types/view-stack.spec.d.ts +1 -0
  69. package/lib/types/view-switcher.spec.d.ts +1 -0
  70. package/package.json +6 -6
  71. package/scss/_banner.scss +13 -0
  72. package/scss/_bottom_sheet.scss +5 -6
  73. package/scss/_button.scss +3 -26
  74. package/scss/_button_content.scss +28 -0
  75. package/scss/_checks.scss +228 -0
  76. package/scss/_clamp.scss +9 -3
  77. package/scss/_combo_row.scss +19 -0
  78. package/scss/_data_grid.scss +15 -7
  79. package/scss/_drop_down.scss +12 -55
  80. package/scss/_expander_row.scss +5 -50
  81. package/scss/_icon.scss +51 -0
  82. package/scss/_icons.generated.scss +6 -0
  83. package/scss/_inline_view_switcher.scss +34 -0
  84. package/scss/_labels.scss +135 -0
  85. package/scss/_menu_button.scss +10 -70
  86. package/scss/_navigation_split_view.scss +47 -8
  87. package/scss/_overlay_split_view.scss +117 -32
  88. package/scss/_popover.scss +186 -0
  89. package/scss/_preferences.scss +29 -0
  90. package/scss/_preferences_dialog.scss +17 -0
  91. package/scss/_progress_bar.scss +161 -0
  92. package/scss/_reset.scss +18 -7
  93. package/scss/_spinner.scss +37 -19
  94. package/scss/_split_button.scss +6 -50
  95. package/scss/_switch.scss +90 -0
  96. package/scss/_switch_row.scss +6 -52
  97. package/scss/_tab_view.scss +63 -0
  98. package/scss/_theme.scss +10 -0
  99. package/scss/_toolbar_view.scss +74 -0
  100. package/scss/_variables.scss +34 -0
  101. package/scss/_view_switcher.scss +40 -0
  102. package/scss/_view_switcher_bar.scss +37 -0
  103. package/scss/_wrap_box.scss +65 -6
  104. package/scss/adwaita-skin.scss +23 -0
  105. package/src/adw-about-dialog.spec.ts +350 -0
  106. package/src/adw-action-rows.spec.ts +342 -0
  107. package/src/adw-avatar.spec.ts +176 -0
  108. package/src/adw-banner.spec.ts +152 -0
  109. package/src/adw-button-content.spec.ts +207 -0
  110. package/src/adw-button-row.spec.ts +12 -6
  111. package/src/adw-carousel.spec.ts +389 -0
  112. package/src/adw-checks.spec.ts +368 -0
  113. package/src/adw-drop-down.spec.ts +123 -0
  114. package/src/adw-header-bar.spec.ts +83 -0
  115. package/src/adw-icon.spec.ts +167 -0
  116. package/src/adw-progress-bar.spec.ts +173 -0
  117. package/src/adw-row-state.spec.ts +49 -0
  118. package/src/adw-sidebar.spec.ts +332 -0
  119. package/src/adw-switch.spec.ts +242 -0
  120. package/src/adw-tab-view.spec.ts +12 -3
  121. package/src/adw-view-switcher-bar.spec.ts +61 -13
  122. package/src/adw-wrap-box.spec.ts +341 -0
  123. package/src/bottom-sheet.spec.ts +325 -0
  124. package/src/breakpoints.spec.ts +147 -0
  125. package/src/breakpoints.ts +67 -0
  126. package/src/chrome.spec.ts +400 -0
  127. package/src/elements/adw-about-dialog.ts +223 -163
  128. package/src/elements/adw-action-row.ts +131 -11
  129. package/src/elements/adw-avatar.ts +48 -54
  130. package/src/elements/adw-banner.ts +46 -10
  131. package/src/elements/adw-bottom-sheet.ts +145 -60
  132. package/src/elements/adw-button-content.ts +107 -33
  133. package/src/elements/adw-button-row.ts +61 -37
  134. package/src/elements/adw-button.ts +5 -7
  135. package/src/elements/adw-carousel.ts +467 -105
  136. package/src/elements/adw-checks.ts +299 -0
  137. package/src/elements/adw-clamp.ts +80 -10
  138. package/src/elements/adw-combo-row.ts +32 -7
  139. package/src/elements/adw-data-grid.ts +43 -91
  140. package/src/elements/adw-drop-down.ts +117 -128
  141. package/src/elements/adw-entry-row.ts +404 -36
  142. package/src/elements/adw-expander-row.ts +61 -29
  143. package/src/elements/adw-header-bar.ts +31 -6
  144. package/src/elements/adw-icon.ts +148 -0
  145. package/src/elements/adw-inline-view-switcher.ts +325 -131
  146. package/src/elements/adw-menu-button.ts +93 -70
  147. package/src/elements/adw-navigation-split-view.ts +220 -14
  148. package/src/elements/adw-navigation-view.ts +286 -148
  149. package/src/elements/adw-overlay-split-view.ts +536 -28
  150. package/src/elements/adw-password-entry-row.ts +111 -89
  151. package/src/elements/adw-popover.ts +283 -0
  152. package/src/elements/adw-preferences-dialog.ts +120 -21
  153. package/src/elements/adw-preferences-group.ts +128 -22
  154. package/src/elements/adw-progress-bar.ts +189 -0
  155. package/src/elements/adw-sidebar.ts +301 -142
  156. package/src/elements/adw-spin-row.ts +11 -5
  157. package/src/elements/adw-spinner.ts +168 -9
  158. package/src/elements/adw-split-button.ts +371 -92
  159. package/src/elements/adw-status-page.ts +9 -9
  160. package/src/elements/adw-switch-row.ts +100 -30
  161. package/src/elements/adw-switch.ts +129 -0
  162. package/src/elements/adw-tab-view.ts +700 -129
  163. package/src/elements/adw-toggle-group.ts +5 -7
  164. package/src/elements/adw-toolbar-view.ts +84 -21
  165. package/src/elements/adw-view-stack.ts +183 -85
  166. package/src/elements/adw-view-switcher-bar.ts +171 -81
  167. package/src/elements/adw-view-switcher.ts +328 -117
  168. package/src/elements/adw-window-title.ts +44 -11
  169. package/src/elements/adw-wrap-box.ts +329 -78
  170. package/src/elements/view-switcher-dom.ts +108 -0
  171. package/src/entry-rows.spec.ts +391 -0
  172. package/src/index.ts +23 -0
  173. package/src/navigation-view.spec.ts +435 -0
  174. package/src/preferences-search.ts +135 -0
  175. package/src/preferences.spec.ts +250 -0
  176. package/src/source-view/adw-source-view.ts +2 -5
  177. package/src/split-button.spec.ts +470 -0
  178. package/src/split-views.spec.ts +893 -0
  179. package/src/styles.generated.ts +1 -1
  180. package/src/tab-view.spec.ts +451 -0
  181. package/src/test.browser.mts +49 -0
  182. package/src/view-stack.spec.ts +272 -0
  183. package/src/view-switcher.spec.ts +665 -0
@@ -1,31 +1,79 @@
1
1
  // adw-view-switcher-bar visibility regression (browser axis). Guards that the
2
- // `revealed` flag actually shows/hides the bar. The bar's base scss sets
2
+ // derived reveal state actually shows/hides the bar. The bar's base scss sets
3
3
  // `display: block`, an AUTHOR rule that would defeat the UA `[hidden]{display:none}`
4
4
  // the component relies on (cascade origin beats specificity) — so an unrevealed
5
5
  // bar rendered visible until scss/_view_switcher_bar.scss re-asserted
6
6
  // `&[hidden] { display: none }`. This test pins that fix.
7
+ //
8
+ // It now stages the bar against a real two-page <adw-view-stack>, because the
9
+ // request alone is no longer enough: `update_bar_revealed` reveals the bar only
10
+ // when `reveal` is set AND MORE THAN ONE page is visible
11
+ // (refs/libadwaita/src/adw-view-switcher-bar.c:104-126), a rule the port used to
12
+ // skip entirely. The one-page case is asserted here too — it is the state the old
13
+ // bar rendered as an empty strip. The full derivation is driven from the shared
14
+ // conformance vectors in `view-switcher.spec.ts`.
7
15
  import { describe, expect, it } from '@gjsify/unit';
8
16
 
17
+ import type { AdwViewStack } from './elements/adw-view-stack.js';
18
+ import type { AdwViewSwitcherBar } from './elements/adw-view-switcher-bar.js';
19
+
20
+ /** A bar bound to a stack of `count` visible pages, both mounted. */
21
+ function mountBar(count: number): { bar: AdwViewSwitcherBar; host: HTMLElement } {
22
+ const host = document.createElement('div');
23
+ document.body.appendChild(host);
24
+
25
+ const stack = document.createElement('adw-view-stack') as AdwViewStack;
26
+ for (let index = 0; index < count; index++) {
27
+ const page = document.createElement('adw-view-stack-page');
28
+ page.setAttribute('name', `p${index}`);
29
+ page.setAttribute('title', `P${index}`);
30
+ stack.appendChild(page);
31
+ }
32
+ host.appendChild(stack);
33
+
34
+ const bar = document.createElement('adw-view-switcher-bar') as AdwViewSwitcherBar;
35
+ host.appendChild(bar);
36
+ bar.setStack(stack);
37
+ return { bar, host };
38
+ }
39
+
9
40
  export const AdwViewSwitcherBarTest = async () => {
10
- await describe('adw-view-switcher-bar revealed → visibility', async () => {
11
- await it('is display:none by default (not revealed) and block once revealed', async () => {
12
- const bar = document.createElement('adw-view-switcher-bar');
13
- document.body.appendChild(bar);
14
-
15
- // Default: `revealed` absent → the component sets `hidden`, and the
16
- // scss `[hidden]` author rule must win over the base `display: block`.
17
- expect(bar.hasAttribute('revealed')).toBe(false);
41
+ await describe('adw-view-switcher-bar reveal → visibility', async () => {
42
+ await it('is display:none by default and block once revealed', () => {
43
+ const { bar, host } = mountBar(2);
44
+
45
+ // Default: `reveal` off → the component sets `hidden`, and the scss
46
+ // `[hidden]` author rule must win over the base `display: block`.
47
+ expect(bar.reveal).toBe(false);
18
48
  expect(getComputedStyle(bar).display).toBe('none');
19
49
 
20
- // Reveal it → shown.
21
- bar.setAttribute('revealed', '');
50
+ bar.setAttribute('reveal', '');
22
51
  expect(getComputedStyle(bar).display).toBe('block');
23
52
 
24
53
  // Hide it again → back to none (the round-trip, not a one-way latch).
25
- bar.removeAttribute('revealed');
54
+ bar.removeAttribute('reveal');
26
55
  expect(getComputedStyle(bar).display).toBe('none');
27
56
 
28
- bar.remove();
57
+ host.remove();
58
+ });
59
+
60
+ await it('still accepts the legacy `revealed` attribute as the request', () => {
61
+ const { bar, host } = mountBar(2);
62
+ bar.setAttribute('revealed', '');
63
+ expect(bar.reveal).toBe(true);
64
+ expect(getComputedStyle(bar).display).toBe('block');
65
+ host.remove();
66
+ });
67
+
68
+ await it('stays collapsed for a ONE-page stack, however loudly the layout asks', () => {
69
+ // `count > 1` (adw-view-switcher-bar.c:125). The old bar showed an
70
+ // empty strip here because it never consulted the page count.
71
+ const { bar, host } = mountBar(1);
72
+ bar.reveal = true;
73
+ expect(bar.reveal).toBe(true);
74
+ expect(bar.revealed).toBe(false);
75
+ expect(getComputedStyle(bar).display).toBe('none');
76
+ host.remove();
29
77
  });
30
78
  });
31
79
  };
@@ -0,0 +1,341 @@
1
+ // DOM-level conformance tests for <adw-wrap-box>, driven by the SAME tables the
2
+ // NativeScript renderer asserts against (`@gjsify/adwaita-core/conformance`).
3
+ //
4
+ // There were no wrap-box specs at all, which is how sixteen divergences from
5
+ // `Adw.WrapBox` sat untouched (issue #1048). Three of them were wrong answers to
6
+ // the one question that IS portable — where a line's leftover space goes:
7
+ //
8
+ // - `align` was written to `align-items`, the CROSS axis, where libadwaita
9
+ // applies it as a MAIN-axis offset of the whole line block
10
+ // (adw-wrap-layout.c:717-725), so `align="1"` pushed children DOWN;
11
+ // - `JUSTIFY_MAP` mapped `fill` and `spread` to the same `space-between`,
12
+ // where C grows the CHILDREN for one and the GAPS for the other
13
+ // (adw-wrap-layout.c:317-341);
14
+ // - `justify-last-line` was observed and never read, so the final line was
15
+ // always justified — the opposite of the C default (adw-wrap-box.c:379-381).
16
+ //
17
+ // The element publishes its resolved decision as `data-line-justify` (what
18
+ // governs a complete line) and `data-last-line-justify` (what governs the final
19
+ // one), which is both what the stylesheet keys off and what these vectors read:
20
+ // the rendered `justify-content` / `flex-grow` are asserted alongside, so a
21
+ // correct data attribute with a stylesheet that ignores it still fails.
22
+
23
+ import { describe, expect, it } from '@gjsify/unit';
24
+
25
+ import {
26
+ WRAP_BOX_CHILD_ORDER_VECTORS,
27
+ WRAP_BOX_LENGTH_VECTORS,
28
+ WRAP_BOX_LINE_VECTORS,
29
+ WRAP_BOX_NATURAL_LENGTH_VECTORS,
30
+ WRAP_BOX_NOTIFY_PROPERTIES,
31
+ WRAP_BOX_POLICY_VECTORS,
32
+ WRAP_BOX_SPACING_NOTIFY_VECTORS,
33
+ WRAP_BOX_SPACING_VECTORS,
34
+ } from '@gjsify/adwaita-core/conformance';
35
+
36
+ /** Mount a wrap box with `n` block children and the given attributes. */
37
+ function mountWrapBox(attrs: Record<string, string>, n = 3): { box: HTMLElement; children: HTMLElement[] } {
38
+ const box = document.createElement('adw-wrap-box');
39
+ for (const [name, value] of Object.entries(attrs)) box.setAttribute(name, value);
40
+ const children: HTMLElement[] = [];
41
+ for (let i = 0; i < n; i++) {
42
+ const child = document.createElement('div');
43
+ child.textContent = `item ${i}`;
44
+ box.appendChild(child);
45
+ children.push(child);
46
+ }
47
+ document.body.appendChild(box);
48
+ return { box, children };
49
+ }
50
+
51
+ /** Remove every wrap box a test mounted. */
52
+ function unmountAll(): void {
53
+ for (const box of Array.from(document.querySelectorAll('adw-wrap-box'))) box.remove();
54
+ }
55
+
56
+ /** A vector value as it reads in a test name (`JSON.stringify` flattens NaN to null). */
57
+ function label(value: unknown): string {
58
+ return typeof value === 'string' ? JSON.stringify(value) : String(value);
59
+ }
60
+
61
+ /**
62
+ * `justify-content` for an un-justified line at `align`.
63
+ *
64
+ * C offsets the line block by `roundf (length_delta * align)`, a continuum;
65
+ * flexbox has three positions, so the port takes the nearest one. That
66
+ * approximation lives here rather than in the vectors because it is the browser
67
+ * renderer's, not libadwaita's.
68
+ */
69
+ function expectedJustifyContent(align: number): string {
70
+ if (align < 0.25) return 'flex-start';
71
+ if (align < 0.75) return 'center';
72
+ return 'flex-end';
73
+ }
74
+
75
+ export const AdwWrapBoxTest = async () => {
76
+ await describe('<adw-wrap-box> line layout (Adw.WrapBox justify / align / justify-last-line)', async () => {
77
+ for (const vector of WRAP_BOX_LINE_VECTORS) {
78
+ const title =
79
+ `justify=${vector.justify} last-line=${vector.justifyLastLine} align=${vector.align} ` +
80
+ `${vector.lastLine ? 'final' : 'complete'} line of ${vector.childrenInLine}`;
81
+
82
+ await it(`${title}: ${vector.rule}`, () => {
83
+ const attrs: Record<string, string> = { justify: vector.justify, align: String(vector.align) };
84
+ if (vector.justifyLastLine) attrs['justify-last-line'] = '';
85
+ // A box with ONE child has exactly one line, and that line is the
86
+ // final one — the only line membership CSS can know without a
87
+ // layout pass, and the reason the stylesheet has an `:only-child`
88
+ // rule at all.
89
+ const childCount = vector.childrenInLine === 1 ? 1 : 3;
90
+ const { box, children } = mountWrapBox(attrs, childCount);
91
+
92
+ const resolved = vector.lastLine ? box.dataset.lastLineJustify : box.dataset.lineJustify;
93
+ expect(resolved).toBe(vector.layout.justify);
94
+
95
+ if (!vector.lastLine && vector.childrenInLine > 1) {
96
+ // `justify-content` is the container knob, and a flex
97
+ // container applies it to every line — so it carries the
98
+ // COMPLETE-line rule.
99
+ expect(getComputedStyle(box).justifyContent).toBe(
100
+ vector.layout.growGaps ? 'space-between' : expectedJustifyContent(vector.layout.align),
101
+ );
102
+ }
103
+
104
+ if (vector.lastLine && vector.childrenInLine === 1) {
105
+ expect(getComputedStyle(children[0]).flexGrow).toBe(vector.layout.growChildren ? '1' : '0');
106
+ }
107
+
108
+ unmountAll();
109
+ });
110
+ }
111
+
112
+ await it('align is a MAIN-axis offset, never a cross-axis one', () => {
113
+ const { box } = mountWrapBox({ align: '1' });
114
+ const style = getComputedStyle(box);
115
+ expect(style.justifyContent).toBe('flex-end');
116
+ // The cross axis is libadwaita's `h = line_size` — every child takes
117
+ // the full line extent (adw-wrap-layout.c:746-751).
118
+ expect(style.alignItems).toBe('stretch');
119
+ unmountAll();
120
+ });
121
+
122
+ await it('fill grows the children and keeps the gaps; spread does the opposite', () => {
123
+ const filled = mountWrapBox({ justify: 'fill', 'justify-last-line': '', 'child-spacing': '10' });
124
+ expect(getComputedStyle(filled.children[0]).flexGrow).toBe('1');
125
+ expect(getComputedStyle(filled.box).justifyContent).toBe('flex-start');
126
+ expect(getComputedStyle(filled.box).columnGap).toBe('10px');
127
+ unmountAll();
128
+
129
+ const spread = mountWrapBox({ justify: 'spread', 'justify-last-line': '', 'child-spacing': '10' });
130
+ expect(getComputedStyle(spread.children[0]).flexGrow).toBe('0');
131
+ expect(getComputedStyle(spread.box).justifyContent).toBe('space-between');
132
+ unmountAll();
133
+ });
134
+
135
+ await it('a spread box whose last line is not justified gets the filler that packs it', () => {
136
+ const { box } = mountWrapBox({ justify: 'spread' });
137
+ // The only per-line hook flexbox offers: a generated flex item on the
138
+ // final line that absorbs its leftover, so the line packs at the start
139
+ // the way an un-justified line does.
140
+ expect(getComputedStyle(box, '::after').flexGrow).toBe('1');
141
+ unmountAll();
142
+
143
+ const justified = mountWrapBox({ justify: 'spread', 'justify-last-line': '' });
144
+ expect(getComputedStyle(justified.box, '::after').flexGrow).toBe('0');
145
+ unmountAll();
146
+ });
147
+
148
+ await it('an unknown justify value falls back to the default, as an invalid enum does', () => {
149
+ const { box } = mountWrapBox({ justify: 'stretch-everything' });
150
+ expect(box.dataset.lineJustify).toBe('none');
151
+ unmountAll();
152
+ });
153
+ });
154
+
155
+ await describe('<adw-wrap-box> spacing (adw_wrap_box_set_child_spacing)', async () => {
156
+ for (const vector of WRAP_BOX_SPACING_VECTORS) {
157
+ await it(`child-spacing ${label(vector.value)} → ${vector.spacing}: ${vector.rule}`, () => {
158
+ const attrs: Record<string, string> = {};
159
+ if (vector.value !== null) attrs['child-spacing'] = String(vector.value);
160
+ const { box } = mountWrapBox(attrs);
161
+
162
+ expect((box as HTMLElement & { childSpacing: number }).childSpacing).toBe(vector.spacing);
163
+ expect(getComputedStyle(box).columnGap).toBe(`${vector.spacing}px`);
164
+ unmountAll();
165
+ });
166
+
167
+ await it(`line-spacing ${label(vector.value)} → ${vector.spacing}: ${vector.rule}`, () => {
168
+ const attrs: Record<string, string> = {};
169
+ if (vector.value !== null) attrs['line-spacing'] = String(vector.value);
170
+ const { box } = mountWrapBox(attrs);
171
+
172
+ expect((box as HTMLElement & { lineSpacing: number }).lineSpacing).toBe(vector.spacing);
173
+ expect(getComputedStyle(box).rowGap).toBe(`${vector.spacing}px`);
174
+ unmountAll();
175
+ });
176
+ }
177
+
178
+ await it('a vertical box swaps which gap the two spacings drive', () => {
179
+ const { box } = mountWrapBox({ orientation: 'vertical', 'child-spacing': '8', 'line-spacing': '4' });
180
+ const style = getComputedStyle(box);
181
+ expect(style.rowGap).toBe('8px');
182
+ expect(style.columnGap).toBe('4px');
183
+ unmountAll();
184
+ });
185
+
186
+ for (const vector of WRAP_BOX_SPACING_NOTIFY_VECTORS) {
187
+ await it(`notify::child-spacing ${vector.from} → ${label(vector.value)} = ${vector.notifies}: ${vector.rule}`, () => {
188
+ const { box } = mountWrapBox({ 'child-spacing': String(vector.from) });
189
+ let notified = 0;
190
+ box.addEventListener('notify::child-spacing', () => {
191
+ notified++;
192
+ });
193
+ box.setAttribute('child-spacing', String(vector.value));
194
+ expect(notified).toBe(vector.notifies ? 1 : 0);
195
+ unmountAll();
196
+ });
197
+ }
198
+ });
199
+
200
+ await describe('<adw-wrap-box> the properties neither port had (#1048)', async () => {
201
+ for (const { value, policy, flexShrink, rule } of WRAP_BOX_POLICY_VECTORS) {
202
+ await it(`wrap-policy ${label(value)} → ${policy}: ${rule}`, () => {
203
+ const attrs: Record<string, string> = {};
204
+ if (value !== null) attrs['wrap-policy'] = String(value);
205
+ const { box, children } = mountWrapBox(attrs);
206
+ expect((box as HTMLElement & { wrapPolicy: string }).wrapPolicy).toBe(policy);
207
+ expect(getComputedStyle(children[0]).flexShrink).toBe(String(flexShrink));
208
+ unmountAll();
209
+ });
210
+ }
211
+
212
+ await it('a box with no wrap-policy forbids shrinking — CSS defaults to the OTHER one', () => {
213
+ const { children } = mountWrapBox({});
214
+ expect(getComputedStyle(children[0]).flexShrink).toBe('0');
215
+ unmountAll();
216
+ });
217
+
218
+ for (const { value, unit, dpi, px, rule } of WRAP_BOX_LENGTH_VECTORS) {
219
+ // The element resolves at the default dpi; the scaled rows are the
220
+ // core suite's, since a browser has no `gtk-xft-dpi` to report.
221
+ if (dpi !== 96 || value < 0) continue;
222
+ await it(`child-spacing ${value}${String(unit)} → ${px}px: ${rule}`, () => {
223
+ const attrs: Record<string, string> = { 'child-spacing': String(value) };
224
+ if (unit !== null) attrs['child-spacing-unit'] = String(unit);
225
+ const { box } = mountWrapBox(attrs);
226
+ expect(getComputedStyle(box).columnGap).toBe(`${px}px`);
227
+ unmountAll();
228
+ });
229
+ }
230
+
231
+ for (const { value, length, rule } of WRAP_BOX_NATURAL_LENGTH_VECTORS) {
232
+ await it(`natural-line-length ${label(value)} → ${length}: ${rule}`, () => {
233
+ const attrs: Record<string, string> = {};
234
+ if (value !== null) attrs['natural-line-length'] = String(value);
235
+ const { box } = mountWrapBox(attrs);
236
+ expect((box as HTMLElement & { naturalLineLength: number }).naturalLineLength).toBe(length);
237
+ // -1 is UNSET, not a length: it must not reach the style at all.
238
+ expect(box.style.maxWidth).toBe(length < 0 ? '' : `${length}px`);
239
+ unmountAll();
240
+ });
241
+ }
242
+
243
+ await it('a VERTICAL box caps the block axis, because that is where its lines run', () => {
244
+ const { box } = mountWrapBox({ orientation: 'vertical', 'natural-line-length': '400' });
245
+ expect(box.style.maxHeight).toBe('400px');
246
+ expect(box.style.maxWidth).toBe('');
247
+ unmountAll();
248
+ });
249
+
250
+ await it('pack-direction and wrap-reverse reverse the axes they own', () => {
251
+ const packed = mountWrapBox({ 'pack-direction': 'end-to-start' });
252
+ expect(getComputedStyle(packed.box).flexDirection).toBe('row-reverse');
253
+ unmountAll();
254
+
255
+ const reversed = mountWrapBox({ 'wrap-reverse': '' });
256
+ expect(getComputedStyle(reversed.box).flexWrap).toBe('wrap-reverse');
257
+ unmountAll();
258
+ });
259
+
260
+ await it('notifies for EVERY property, not just the two spacings', () => {
261
+ const { box } = mountWrapBox({});
262
+ const seen: string[] = [];
263
+ for (const property of WRAP_BOX_NOTIFY_PROPERTIES) {
264
+ box.addEventListener(`notify::${property}`, () => seen.push(property));
265
+ }
266
+ // One real change per property, each different from the default.
267
+ box.setAttribute('child-spacing', '6');
268
+ box.setAttribute('child-spacing-unit', 'sp');
269
+ box.setAttribute('pack-direction', 'end-to-start');
270
+ box.setAttribute('align', '1');
271
+ box.setAttribute('justify', 'fill');
272
+ box.toggleAttribute('justify-last-line', true);
273
+ box.setAttribute('line-spacing', '4');
274
+ box.setAttribute('line-spacing-unit', 'pt');
275
+ box.toggleAttribute('line-homogeneous', true);
276
+ box.setAttribute('natural-line-length', '400');
277
+ box.setAttribute('natural-line-length-unit', 'sp');
278
+ box.toggleAttribute('wrap-reverse', true);
279
+ box.setAttribute('wrap-policy', 'minimum');
280
+ box.setAttribute('orientation', 'vertical');
281
+
282
+ expect([...seen].sort()).toStrictEqual([...WRAP_BOX_NOTIFY_PROPERTIES].sort());
283
+ unmountAll();
284
+ });
285
+
286
+ await it('and stays silent for a value that normalises to what it already holds', () => {
287
+ const { box } = mountWrapBox({ 'wrap-policy': 'minimum' });
288
+ let notified = 0;
289
+ box.addEventListener('notify::wrap-policy', () => {
290
+ notified++;
291
+ });
292
+ box.setAttribute('wrap-policy', 'not-a-policy'); // → the default, a change
293
+ expect(notified).toBe(1);
294
+ box.setAttribute('wrap-policy', 'also-not-a-policy'); // → the default again
295
+ expect(notified).toBe(1);
296
+ unmountAll();
297
+ });
298
+ });
299
+
300
+ await describe('<adw-wrap-box> child list (insert/reorder after, remove_all)', async () => {
301
+ for (const { op, children, child, sibling, result, rule } of WRAP_BOX_CHILD_ORDER_VECTORS) {
302
+ const name = `${op} ${child} after ${sibling ?? 'NULL'} in [${children.join(',')}]`;
303
+ await it(`${name}: ${rule}`, () => {
304
+ const box = document.createElement('adw-wrap-box') as HTMLElement & {
305
+ insertChildAfter(c: Element, s?: Element | null): boolean;
306
+ reorderChildAfter(c: Element, s?: Element | null): boolean;
307
+ };
308
+ document.body.appendChild(box);
309
+ const byId = new Map<string, HTMLElement>();
310
+ const make = (id: string) => {
311
+ const view = document.createElement('div');
312
+ view.dataset.id = id;
313
+ byId.set(id, view);
314
+ return view;
315
+ };
316
+ for (const id of children) box.appendChild(make(id));
317
+ // The child being placed may be one of the mounted ones (a
318
+ // reorder, or the "already parented" refusal) or a fresh one.
319
+ const target = byId.get(child) ?? make(child);
320
+ // A sibling the box does not have still has to be a real element.
321
+ const after = sibling === null ? null : (byId.get(sibling) ?? make(sibling));
322
+
323
+ const ok =
324
+ op === 'insert-after' ? box.insertChildAfter(target, after) : box.reorderChildAfter(target, after);
325
+ expect(ok).toBe(result !== null);
326
+ const order = [...box.children].map((view) => (view as HTMLElement).dataset.id);
327
+ expect(order).toStrictEqual(result === null ? [...children] : [...result]);
328
+ unmountAll();
329
+ });
330
+ }
331
+
332
+ await it('removeAll empties the box, leaving the box itself mounted', () => {
333
+ const { box } = mountWrapBox({}, 4);
334
+ expect(box.children.length).toBe(4);
335
+ (box as HTMLElement & { removeAll(): void }).removeAll();
336
+ expect(box.children.length).toBe(0);
337
+ expect(box.isConnected).toBe(true);
338
+ unmountAll();
339
+ });
340
+ });
341
+ };