@blotch/dolan 22.2.3 → 22.2.5

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 (227) hide show
  1. package/dist/commands/add.js +9 -1
  2. package/dist/commands/add.js.map +1 -1
  3. package/dist/commands/add.test.js +38 -3
  4. package/dist/commands/add.test.js.map +1 -1
  5. package/dist/commands/doctor.js +258 -21
  6. package/dist/commands/doctor.js.map +1 -1
  7. package/dist/commands/doctor.test.js +425 -11
  8. package/dist/commands/doctor.test.js.map +1 -1
  9. package/dist/commands/init.d.ts +2 -2
  10. package/dist/commands/init.js +38 -18
  11. package/dist/commands/init.js.map +1 -1
  12. package/dist/commands/init.test.js +105 -2
  13. package/dist/commands/init.test.js.map +1 -1
  14. package/dist/commands/theme.js +1 -1
  15. package/dist/commands/theme.js.map +1 -1
  16. package/dist/commands/update.d.ts +7 -0
  17. package/dist/commands/update.js +194 -50
  18. package/dist/commands/update.js.map +1 -1
  19. package/dist/commands/update.test.js +570 -3
  20. package/dist/commands/update.test.js.map +1 -1
  21. package/dist/lockfile.d.ts +17 -0
  22. package/dist/lockfile.js +56 -1
  23. package/dist/lockfile.js.map +1 -1
  24. package/dist/lockfile.test.d.ts +1 -0
  25. package/dist/lockfile.test.js +65 -0
  26. package/dist/lockfile.test.js.map +1 -0
  27. package/dist/registry.d.ts +6 -0
  28. package/dist/registry.js +119 -11
  29. package/dist/registry.js.map +1 -1
  30. package/dist/registry.test.js +61 -6
  31. package/dist/registry.test.js.map +1 -1
  32. package/dist/test-utils.d.ts +27 -0
  33. package/dist/test-utils.js +45 -1
  34. package/dist/test-utils.js.map +1 -1
  35. package/dist/testing/fire-lynx-event.d.ts +14 -0
  36. package/dist/testing/fire-lynx-event.js +19 -0
  37. package/dist/testing/fire-lynx-event.js.map +1 -0
  38. package/dist/testing/fire-lynx-event.test.d.ts +1 -0
  39. package/dist/testing/fire-lynx-event.test.js +44 -0
  40. package/dist/testing/fire-lynx-event.test.js.map +1 -0
  41. package/dist/testing/lynx-main-thread.d.ts +22 -0
  42. package/dist/testing/lynx-main-thread.js +11 -0
  43. package/dist/testing/lynx-main-thread.js.map +1 -0
  44. package/dist/testing/lynx-main-thread.test.d.ts +1 -0
  45. package/dist/testing/lynx-main-thread.test.js +24 -0
  46. package/dist/testing/lynx-main-thread.test.js.map +1 -0
  47. package/dist/testing/set-input-signal.d.ts +5 -4
  48. package/dist/testing/set-input-signal.js +5 -4
  49. package/dist/testing/set-input-signal.js.map +1 -1
  50. package/dist/ui/boolean-inputs.test.ts +76 -0
  51. package/dist/ui/components/accordion/accordion.test.ts +158 -144
  52. package/dist/ui/components/accordion/accordion.ts +19 -14
  53. package/dist/ui/components/action-sheet/action-sheet.test.ts +637 -183
  54. package/dist/ui/components/action-sheet/action-sheet.ts +339 -55
  55. package/dist/ui/components/action-sheet/index.ts +1 -0
  56. package/dist/ui/components/alert/alert.test.ts +67 -19
  57. package/dist/ui/components/alert/alert.ts +14 -16
  58. package/dist/ui/components/alert-dialog/alert-dialog.test.ts +740 -129
  59. package/dist/ui/components/alert-dialog/alert-dialog.ts +672 -58
  60. package/dist/ui/components/alert-dialog/index.ts +5 -0
  61. package/dist/ui/components/area-chart/area-chart.test.ts +81 -1
  62. package/dist/ui/components/area-chart/area-chart.ts +3 -2
  63. package/dist/ui/components/avatar/avatar.test.ts +89 -45
  64. package/dist/ui/components/badge/badge.test.ts +57 -23
  65. package/dist/ui/components/badge/badge.ts +14 -15
  66. package/dist/ui/components/bar-chart/bar-chart.test.ts +82 -1
  67. package/dist/ui/components/bottom-sheet/bottom-sheet.test.ts +1314 -273
  68. package/dist/ui/components/bottom-sheet/bottom-sheet.ts +1046 -119
  69. package/dist/ui/components/bottom-sheet/index.ts +7 -1
  70. package/dist/ui/components/button/button.test.ts +646 -2
  71. package/dist/ui/components/button/button.ts +443 -64
  72. package/dist/ui/components/button/index.ts +2 -0
  73. package/dist/ui/components/button-group/button-group.test.ts +528 -2
  74. package/dist/ui/components/button-group/button-group.ts +428 -70
  75. package/dist/ui/components/button-group/index.ts +3 -0
  76. package/dist/ui/components/candlestick-chart/candlestick-chart.test.ts +82 -1
  77. package/dist/ui/components/card/card.test.ts +97 -61
  78. package/dist/ui/components/card/card.ts +2 -1
  79. package/dist/ui/components/chart/chart-presets.test.ts +197 -1
  80. package/dist/ui/components/chart/chart-presets.ts +14 -7
  81. package/dist/ui/components/chart/chart-theme.ts +12 -0
  82. package/dist/ui/components/chart/chart.test.ts +1031 -0
  83. package/dist/ui/components/chart/chart.ts +66 -46
  84. package/dist/ui/components/checkbox/checkbox.test.ts +124 -42
  85. package/dist/ui/components/checkbox/checkbox.ts +25 -24
  86. package/dist/ui/components/collapsible/collapsible.test.ts +158 -81
  87. package/dist/ui/components/collapsible/collapsible.ts +21 -15
  88. package/dist/ui/components/context-menu/context-menu.test.ts +224 -0
  89. package/dist/ui/components/context-menu/context-menu.ts +110 -0
  90. package/dist/ui/components/context-menu/index.ts +1 -0
  91. package/dist/ui/components/dialog/dialog.test.ts +210 -152
  92. package/dist/ui/components/dialog/dialog.ts +35 -29
  93. package/dist/ui/components/dock/dock-scroll.test.ts +130 -0
  94. package/dist/ui/components/dock/dock-scroll.ts +142 -0
  95. package/dist/ui/components/dock/dock-search.test.ts +594 -0
  96. package/dist/ui/components/dock/dock.test.ts +752 -0
  97. package/dist/ui/components/dock/dock.ts +1438 -0
  98. package/dist/ui/components/dock/index.ts +2 -0
  99. package/dist/ui/components/dynamic-color/dynamic-color.test.ts +144 -0
  100. package/dist/ui/components/dynamic-color/dynamic-color.ts +146 -0
  101. package/dist/ui/components/dynamic-color/index.ts +5 -0
  102. package/dist/ui/components/empty-state/empty-state.test.ts +28 -39
  103. package/dist/ui/components/glass/concentric-radius.test.ts +13 -0
  104. package/dist/ui/components/glass/concentric-radius.ts +17 -0
  105. package/dist/ui/components/glass/glass-design.test.ts +78 -0
  106. package/dist/ui/components/glass/glass-design.ts +119 -0
  107. package/dist/ui/components/glass/glass.test.ts +376 -0
  108. package/dist/ui/components/glass/glass.ts +430 -0
  109. package/dist/ui/components/glass/index.ts +19 -0
  110. package/dist/ui/components/icon/icon-theme.test.ts +64 -0
  111. package/dist/ui/components/icon/icon-theme.ts +70 -16
  112. package/dist/ui/components/icon/icon.test.ts +52 -41
  113. package/dist/ui/components/input/input.test.ts +178 -101
  114. package/dist/ui/components/input/input.ts +17 -13
  115. package/dist/ui/components/label/label.test.ts +11 -24
  116. package/dist/ui/components/label/label.ts +8 -2
  117. package/dist/ui/components/line-chart/line-chart.test.ts +76 -1
  118. package/dist/ui/components/line-chart/line-chart.ts +3 -2
  119. package/dist/ui/components/list/list.test.ts +80 -49
  120. package/dist/ui/components/list/list.ts +5 -4
  121. package/dist/ui/components/menu/index.ts +25 -0
  122. package/dist/ui/components/menu/menu-placement.test.ts +153 -0
  123. package/dist/ui/components/menu/menu-placement.ts +159 -0
  124. package/dist/ui/components/menu/menu-popup.test.ts +636 -0
  125. package/dist/ui/components/menu/menu-popup.ts +565 -0
  126. package/dist/ui/components/menu/menu.test.ts +523 -0
  127. package/dist/ui/components/menu/menu.ts +455 -0
  128. package/dist/ui/components/nav-drawer/nav-drawer.test.ts +425 -260
  129. package/dist/ui/components/nav-drawer/nav-drawer.ts +75 -58
  130. package/dist/ui/components/navigation-bar/index.ts +1 -0
  131. package/dist/ui/components/navigation-bar/navigation-bar.test.ts +425 -0
  132. package/dist/ui/components/navigation-bar/navigation-bar.ts +411 -0
  133. package/dist/ui/components/pagination/pagination.test.ts +136 -86
  134. package/dist/ui/components/popover/index.ts +9 -0
  135. package/dist/ui/components/popover/popover-panel.test.ts +735 -0
  136. package/dist/ui/components/popover/popover-panel.ts +603 -0
  137. package/dist/ui/components/popover/popover.test.ts +286 -0
  138. package/dist/ui/components/popover/popover.ts +207 -0
  139. package/dist/ui/components/progress/progress.test.ts +102 -46
  140. package/dist/ui/components/progress/progress.ts +54 -55
  141. package/dist/ui/components/radio-group/radio-group.test.ts +128 -83
  142. package/dist/ui/components/radio-group/radio-group.ts +26 -25
  143. package/dist/ui/components/scatter-chart/scatter-chart.test.ts +74 -1
  144. package/dist/ui/components/scroll-area/scroll-area.test.ts +72 -36
  145. package/dist/ui/components/scroll-area/scroll-area.ts +4 -3
  146. package/dist/ui/components/search-field/index.ts +15 -0
  147. package/dist/ui/components/search-field/keyboard.test.ts +147 -0
  148. package/dist/ui/components/search-field/keyboard.ts +123 -0
  149. package/dist/ui/components/search-field/search-field.test.ts +549 -0
  150. package/dist/ui/components/search-field/search-field.ts +628 -0
  151. package/dist/ui/components/segmented-control/index.ts +8 -0
  152. package/dist/ui/components/segmented-control/segmented-control.test.ts +861 -0
  153. package/dist/ui/components/segmented-control/segmented-control.ts +884 -0
  154. package/dist/ui/components/select/select.test.ts +138 -78
  155. package/dist/ui/components/select/select.ts +19 -12
  156. package/dist/ui/components/separator/separator.test.ts +18 -17
  157. package/dist/ui/components/sheet/sheet.test.ts +151 -11
  158. package/dist/ui/components/sheet/sheet.ts +68 -5
  159. package/dist/ui/components/skeleton/skeleton.test.ts +24 -7
  160. package/dist/ui/components/skeleton/skeleton.ts +10 -16
  161. package/dist/ui/components/slider/index.ts +1 -0
  162. package/dist/ui/components/slider/slider.test.ts +695 -0
  163. package/dist/ui/components/slider/slider.ts +901 -0
  164. package/dist/ui/components/spinner/spinner.test.ts +64 -46
  165. package/dist/ui/components/spinner/spinner.ts +16 -19
  166. package/dist/ui/components/switch/index.ts +1 -1
  167. package/dist/ui/components/switch/switch.test.ts +534 -48
  168. package/dist/ui/components/switch/switch.ts +613 -48
  169. package/dist/ui/components/tab-bar/index.ts +1 -0
  170. package/dist/ui/components/tab-bar/tab-bar.test.ts +280 -0
  171. package/dist/ui/components/tab-bar/tab-bar.ts +230 -0
  172. package/dist/ui/components/tabs/index.ts +7 -1
  173. package/dist/ui/components/tabs/tabs.test.ts +484 -150
  174. package/dist/ui/components/tabs/tabs.ts +344 -149
  175. package/dist/ui/components/textarea/textarea.test.ts +206 -100
  176. package/dist/ui/components/textarea/textarea.ts +16 -13
  177. package/dist/ui/components/toast/toast.test.ts +434 -350
  178. package/dist/ui/components/toast/toast.ts +42 -51
  179. package/dist/ui/components/toggle/index.ts +1 -0
  180. package/dist/ui/components/toggle/toggle.test.ts +559 -146
  181. package/dist/ui/components/toggle/toggle.ts +241 -26
  182. package/dist/ui/components/toolbar/bar-scroll.test.ts +310 -0
  183. package/dist/ui/components/toolbar/bar-scroll.ts +372 -0
  184. package/dist/ui/components/toolbar/index.ts +12 -0
  185. package/dist/ui/components/toolbar/toolbar.test.ts +438 -0
  186. package/dist/ui/components/toolbar/toolbar.ts +535 -0
  187. package/dist/ui/theme/chart-colors.test.ts +8 -3
  188. package/dist/ui/theme/dark.css +38 -2
  189. package/dist/ui/theme/default.css +55 -7
  190. package/dist/ui/theme/icon-colors.test.ts +8 -3
  191. package/dist/ui/theme/rgb-channels.test.ts +84 -0
  192. package/dist/ui/theme/tailwind-build.test.ts +114 -0
  193. package/dist/ui/theme/tailwind-css.test.ts +83 -0
  194. package/dist/ui/theme/tailwind-plugin.test.ts +42 -2
  195. package/dist/ui/theme/tailwind-plugin.ts +93 -29
  196. package/dist/ui/theme/tailwind.css +113 -0
  197. package/dist/ui/utils/animate.test.ts +13 -1
  198. package/dist/utils/analyze.d.ts +19 -0
  199. package/dist/utils/analyze.js +16 -0
  200. package/dist/utils/analyze.js.map +1 -1
  201. package/dist/utils/analyze.test.js +14 -1
  202. package/dist/utils/analyze.test.js.map +1 -1
  203. package/dist/utils/installed.d.ts +25 -1
  204. package/dist/utils/installed.js +33 -0
  205. package/dist/utils/installed.js.map +1 -1
  206. package/dist/utils/installed.test.js +55 -1
  207. package/dist/utils/installed.test.js.map +1 -1
  208. package/dist/utils/resolve-paths.d.ts +4 -4
  209. package/dist/utils/resolve-paths.js +5 -7
  210. package/dist/utils/resolve-paths.js.map +1 -1
  211. package/dist/utils/resolve-paths.test.js +9 -5
  212. package/dist/utils/resolve-paths.test.js.map +1 -1
  213. package/dist/utils/tailwind.d.ts +45 -0
  214. package/dist/utils/tailwind.js +90 -0
  215. package/dist/utils/tailwind.js.map +1 -0
  216. package/dist/utils/tailwind.test.d.ts +1 -0
  217. package/dist/utils/tailwind.test.js +134 -0
  218. package/dist/utils/tailwind.test.js.map +1 -0
  219. package/package.json +9 -1
  220. package/dist/ui/components/area-chart/area-chart-render.test.ts +0 -63
  221. package/dist/ui/components/bar-chart/bar-chart-render.test.ts +0 -58
  222. package/dist/ui/components/button/button-render.test.ts +0 -132
  223. package/dist/ui/components/button-group/button-group-render.test.ts +0 -146
  224. package/dist/ui/components/candlestick-chart/candlestick-chart-render.test.ts +0 -59
  225. package/dist/ui/components/chart/chart-render.test.ts +0 -730
  226. package/dist/ui/components/line-chart/line-chart-render.test.ts +0 -83
  227. package/dist/ui/components/scatter-chart/scatter-chart-render.test.ts +0 -64
@@ -1,107 +1,167 @@
1
- import { render, waitForUpdate } from '@blotch/angular-lynx-testing-library';
2
- import { describe, expect, it } from 'vitest';
3
- import { setInputSignal } from '../../../test-utils/set-input-signal';
1
+ import { Component, signal } from '@angular/core';
2
+ import {
3
+ fireEvent,
4
+ render,
5
+ waitForUpdate,
6
+ within,
7
+ } from '@blotch/angular-lynx-testing-library';
8
+ import { LYNX_ELEMENTS } from '@blotch/angular-lynx';
9
+ import { describe, expect, it, vi } from 'vitest';
4
10
  import { UiSelect, UiSelectItem } from './select';
5
11
 
12
+ @Component({
13
+ imports: [UiSelect, UiSelectItem, LYNX_ELEMENTS],
14
+ template: `
15
+ <ui-select
16
+ #select
17
+ [(value)]="value"
18
+ [placeholder]="placeholder()"
19
+ [disabled]="disabled()"
20
+ class="w-48"
21
+ (changed)="changed($event)"
22
+ >
23
+ <ui-select-item value="apple" label="Apple" />
24
+ <ui-select-item value="pear" label="Pear" class="font-bold" />
25
+ </ui-select>
26
+ <text class="open-from-code" (bindtap)="select.open()">Choose</text>
27
+ `,
28
+ })
29
+ class SelectHost {
30
+ readonly value = signal('');
31
+ readonly placeholder = signal('Pick a fruit');
32
+ readonly disabled = signal(false);
33
+ readonly changed = vi.fn((_value: string) => {});
34
+ }
35
+
36
+ const renderSelect = async () => {
37
+ const result = await render(SelectHost);
38
+ const { container } = result;
39
+ const overlay = container.querySelector<HTMLElement>('overlay')!;
40
+ return {
41
+ ...result,
42
+ host: result.componentRef.instance as SelectHost,
43
+ overlay,
44
+ trigger: container.querySelector('.border-input')!,
45
+ triggerText: () => container.querySelector('.border-input text')!,
46
+ // An item's tappable row, found by its label in the sheet.
47
+ item: (label: string) => within(overlay).getByText(label).parentElement!,
48
+ };
49
+ };
50
+
51
+ /**
52
+ * Waits out the sheet's open sequence: the overlay shows on one tick, and the
53
+ * panel slides in on the next.
54
+ */
55
+ const waitForOpen = async () => {
56
+ for (let i = 0; i < 3; i++) await waitForUpdate();
57
+ };
58
+
59
+ /**
60
+ * Waits for the sheet's close sequence to finish: the panel slides out, then
61
+ * the overlay hides. Polled rather than timed, since the sequence only starts
62
+ * on the update after the sheet is told to close.
63
+ */
64
+ const waitForClose = (overlay: Element) =>
65
+ vi.waitFor(() => expect(overlay.getAttribute('visible')).toBe('false'));
66
+
6
67
  describe('UiSelect', () => {
7
- it('renders the trigger for the current selection', async () => {
8
- const { container } = await render(UiSelect);
9
- expect(container).toBeTruthy();
68
+ it('shows the placeholder, muted, until a value is chosen', async () => {
69
+ const { triggerText, trigger } = await renderSelect();
70
+ expect(triggerText().textContent).toBe('Pick a fruit');
71
+ expect(triggerText().classList).toContain('text-muted-foreground');
72
+ expect(trigger.classList).toContain('w-48');
10
73
  });
11
74
 
12
- it('displays the placeholder when no value is selected', async () => {
13
- const { componentRef, container } = await render(UiSelect);
14
- const inst = componentRef.instance as UiSelect;
15
- setInputSignal(inst.placeholder, 'Choose...');
75
+ it("shows the chosen item's label", async () => {
76
+ const { host, triggerText } = await renderSelect();
77
+ host.value.set('pear');
16
78
  await waitForUpdate();
17
- expect(container.textContent).toContain('Choose...');
79
+ expect(triggerText().textContent).toBe('Pear');
80
+ expect(triggerText().classList).toContain('text-foreground');
18
81
  });
19
82
 
20
- it('displays the raw value when no matching item is projected', async () => {
21
- // Covers the `item?.label() ?? val` fallback path.
22
- const { componentRef, container } = await render(UiSelect);
23
- const inst = componentRef.instance as UiSelect;
24
- inst.value.set('unknown');
83
+ it('shows a value that no item has as it is', async () => {
84
+ const { host, triggerText } = await renderSelect();
85
+ host.value.set('kiwi');
25
86
  await waitForUpdate();
26
- expect(container.textContent).toContain('unknown');
87
+ expect(triggerText().textContent).toBe('kiwi');
27
88
  });
28
89
 
29
- it('select() updates the model, emits `changed`, and closes the sheet', async () => {
30
- const { componentRef } = await render(UiSelect);
31
- const inst = componentRef.instance as UiSelect;
32
- inst.open();
33
- const emitted: string[] = [];
34
- inst.changed.subscribe((v) => emitted.push(v));
35
- inst.select('b');
36
- expect(inst.value()).toBe('b');
37
- expect(emitted).toEqual(['b']);
90
+ it('opens its list when the trigger is tapped, and closes it from the sheet', async () => {
91
+ const { overlay, trigger } = await renderSelect();
92
+ expect(overlay.getAttribute('visible')).toBe('false');
93
+
94
+ fireEvent.tap(trigger);
95
+ await waitForOpen();
96
+ expect(overlay.getAttribute('visible')).toBe('true');
97
+
98
+ // Tapping the backdrop closes the sheet, which the select keeps track of:
99
+ // the next tap on the trigger opens it again.
100
+ fireEvent.tap(overlay.querySelector('view')!);
101
+ await waitForClose(overlay);
102
+ expect(overlay.getAttribute('visible')).toBe('false');
103
+ fireEvent.tap(trigger);
104
+ await waitForOpen();
105
+ expect(overlay.getAttribute('visible')).toBe('true');
38
106
  });
39
107
 
40
- it('toggle() flips the sheet open/closed', async () => {
41
- const { componentRef } = await render(UiSelect);
42
- const inst = componentRef.instance as UiSelect;
43
- inst.toggle();
44
- inst.toggle();
45
- // No throw; the internal `sheetOpen` signal is protected — verify indirectly
46
- // by ensuring subsequent open()/close() calls still work.
47
- inst.open();
48
- inst.close();
49
- expect(inst.value()).toBe('');
108
+ it('closes its list when the trigger is tapped again', async () => {
109
+ const { overlay, trigger } = await renderSelect();
110
+ fireEvent.tap(trigger);
111
+ await waitForOpen();
112
+ fireEvent.tap(trigger);
113
+ await waitForClose(overlay);
114
+ expect(overlay.getAttribute('visible')).toBe('false');
50
115
  });
51
116
 
52
- it('toggle() / open() are no-ops when disabled', async () => {
53
- const { componentRef } = await render(UiSelect);
54
- const inst = componentRef.instance as UiSelect;
55
- setInputSignal(inst.disabled, true);
56
- await waitForUpdate();
57
- // No throw and no exception paths — early-return branch is exercised.
58
- inst.toggle();
59
- inst.open();
60
- inst.close();
61
- expect(inst.value()).toBe('');
117
+ it('opens from code with open()', async () => {
118
+ const { overlay, getByText } = await renderSelect();
119
+ fireEvent.tap(getByText('Choose'));
120
+ await waitForOpen();
121
+ expect(overlay.getAttribute('visible')).toBe('true');
62
122
  });
63
123
 
64
- it('trigger dims when the select is disabled', async () => {
65
- const { componentRef, container } = await render(UiSelect);
66
- const inst = componentRef.instance as UiSelect;
67
- setInputSignal(inst.disabled, true);
124
+ it("dims and doesn't open while disabled", async () => {
125
+ const { host, overlay, trigger, getByText } = await renderSelect();
126
+ host.disabled.set(true);
68
127
  await waitForUpdate();
69
- const trigger = container.querySelector('view');
70
- expect(trigger?.getAttribute('class')).toContain('opacity-50');
128
+ expect(trigger.classList).toContain('opacity-50');
129
+
130
+ fireEvent.tap(trigger);
131
+ fireEvent.tap(getByText('Choose'));
132
+ await waitForOpen();
133
+ expect(overlay.getAttribute('visible')).toBe('false');
71
134
  });
72
135
  });
73
136
 
74
137
  describe('UiSelectItem', () => {
75
- it('onTap delegates to the parent select', async () => {
76
- const parentResult = await render(UiSelect);
77
- const parent = parentResult.componentRef.instance as UiSelect;
78
-
79
- const itemResult = await render(UiSelectItem, {
80
- providers: [{ provide: UiSelect, useValue: parent }],
81
- });
82
- const item = itemResult.componentRef.instance as UiSelectItem;
83
- setInputSignal(item.itemValue, 'x');
84
- setInputSignal(item.label, 'X');
85
- await waitForUpdate();
138
+ it('chooses its value when tapped, and closes the list', async () => {
139
+ const { host, overlay, trigger, triggerText, item } = await renderSelect();
140
+ fireEvent.tap(trigger);
141
+ await waitForOpen();
86
142
 
87
- (item as unknown as { onTap: () => void }).onTap();
88
- expect(parent.value()).toBe('x');
143
+ fireEvent.tap(item('Apple'));
144
+ expect(host.value()).toBe('apple');
145
+ expect(host.changed).toHaveBeenCalledWith('apple');
146
+ await waitForUpdate();
147
+ expect(triggerText().textContent).toBe('Apple');
148
+ await waitForClose(overlay);
149
+ expect(overlay.getAttribute('visible')).toBe('false');
89
150
  });
90
151
 
91
- it('highlights the selected item via bg-accent', async () => {
92
- const parentResult = await render(UiSelect);
93
- const parent = parentResult.componentRef.instance as UiSelect;
94
- parent.value.set('x');
95
-
96
- const itemResult = await render(UiSelectItem, {
97
- providers: [{ provide: UiSelect, useValue: parent }],
98
- });
99
- const item = itemResult.componentRef.instance as UiSelectItem;
100
- setInputSignal(item.itemValue, 'x');
101
- setInputSignal(item.label, 'X');
152
+ it('marks the chosen item with a highlight and a check', async () => {
153
+ const { host, item } = await renderSelect();
154
+ host.value.set('pear');
102
155
  await waitForUpdate();
156
+ expect(item('Pear').classList).toContain('bg-accent');
157
+ expect(item('Pear').querySelector('svg')).not.toBeNull();
158
+ expect(item('Apple').classList).not.toContain('bg-accent');
159
+ expect(item('Apple').querySelector('svg')).toBeNull();
160
+ });
103
161
 
104
- const view = itemResult.container.querySelector('view');
105
- expect(view?.getAttribute('class')).toContain('bg-accent');
162
+ it("adds the class to the item's own", async () => {
163
+ const { item } = await renderSelect();
164
+ expect(item('Pear').classList).toContain('font-bold');
165
+ expect(item('Pear').classList).toContain('px-4');
106
166
  });
107
167
  });
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Component,
3
3
  ViewEncapsulation,
4
+ booleanAttribute,
4
5
  computed,
5
6
  contentChildren,
6
- forwardRef,
7
7
  inject,
8
8
  input,
9
9
  model,
@@ -18,17 +18,28 @@ import { cn } from '../../utils/cn';
18
18
  const CHEVRON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>`;
19
19
  const CHECK_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>`;
20
20
 
21
+ /**
22
+ * `UiSelectItem`, for `contentChildren()`. A call rather than the class
23
+ * itself: for a class, Angular's test build keeps an arrow function that
24
+ * nothing calls, which an app's coverage report would show as uncovered.
25
+ */
26
+ const selectItem = () => UiSelectItem;
27
+
21
28
  @Component({
22
29
  selector: 'ui-select',
23
30
  standalone: true,
24
31
  imports: [LYNX_ELEMENTS, UiBottomSheet],
25
32
  encapsulation: ViewEncapsulation.None,
33
+ // `sheetOpen` is bound both ways by hand rather than with `[(open)]`: for a
34
+ // two-way binding Angular also compiles a fallback that assigns the field,
35
+ // which never runs for a signal and so shows as an uncovered branch in an
36
+ // app's coverage report.
26
37
  template: `
27
38
  <view [class]="triggerClass()" (bindtap)="toggle()">
28
39
  <text [class]="valueTextClass()">{{ displayText() }}</text>
29
40
  <svg [attr.content]="chevronSvg" style="width: 16px; height: 16px;" />
30
41
  </view>
31
- <ui-bottom-sheet [(open)]="sheetOpen">
42
+ <ui-bottom-sheet [open]="sheetOpen()" (openChange)="sheetOpen.set($event)">
32
43
  <scroll-view scroll-orientation="vertical" style="max-height: 300px;">
33
44
  <view class="flex-col pb-4 flex">
34
45
  <ng-content />
@@ -40,28 +51,24 @@ const CHECK_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" f
40
51
  export class UiSelect {
41
52
  readonly value = model<string>('');
42
53
  readonly placeholder = input('Select...');
43
- readonly disabled = input(false);
54
+ readonly disabled = input(false, { transform: booleanAttribute });
44
55
  readonly userClass = input<string>('', { alias: 'class' });
45
56
 
46
57
  readonly changed = output<string>();
47
58
 
48
59
  protected readonly chevronSvg = CHEVRON_SVG;
49
60
 
50
- // Drives the shared bottom-sheet's `open` model via `[(open)]`. All the
51
- // overlay/animation/drag behavior lives in ui-bottom-sheet; select only
52
- // decides when the sheet is open.
61
+ // Drives the shared bottom-sheet's `open` model. All the overlay/animation/
62
+ // drag behavior lives in ui-bottom-sheet; select only decides when the sheet
63
+ // is open.
53
64
  protected readonly sheetOpen = signal(false);
54
65
 
55
- // `forwardRef` is required because UiSelectItem is defined later in this
56
- // file — without it, the reference would be `undefined` at class-definition
57
- // time and contentChildren would silently query nothing.
58
- /* v8 ignore next 1 -- forwardRef lambda; JIT+jsdom doesn't wire required child inputs */
59
- readonly itemRefs = contentChildren(forwardRef(() => UiSelectItem));
66
+ // The projected items, so the trigger can show the chosen one's label.
67
+ readonly itemRefs = contentChildren(selectItem());
60
68
 
61
69
  protected readonly displayText = computed(() => {
62
70
  const val = this.value();
63
71
  if (!val) return this.placeholder();
64
- /* v8 ignore next 1 -- .find predicate: unreachable when no content-projected items */
65
72
  const item = this.itemRefs().find((i) => i.itemValue() === val);
66
73
  return item?.label() ?? val;
67
74
  });
@@ -1,26 +1,27 @@
1
+ import { Component, signal } from '@angular/core';
1
2
  import { render, waitForUpdate } from '@blotch/angular-lynx-testing-library';
2
3
  import { describe, expect, it } from 'vitest';
3
- import { setInputSignal } from '../../../test-utils/set-input-signal';
4
4
  import { UiSeparator } from './separator';
5
5
 
6
+ @Component({
7
+ imports: [UiSeparator],
8
+ template: `<ui-separator [orientation]="orientation()" class="my-2" />`,
9
+ })
10
+ class SeparatorHost {
11
+ readonly orientation = signal<'horizontal' | 'vertical'>('horizontal');
12
+ }
13
+
6
14
  describe('UiSeparator', () => {
7
- it('renders horizontally (default)', async () => {
8
- const { componentRef } = await render(UiSeparator);
9
- // The class binding lands on the host element, which is the component's
10
- // location.nativeElement (a real DOM node representing the ui-separator
11
- // host). Read the class directly from that node.
12
- const host = componentRef.location.nativeElement as HTMLElement;
13
- expect(host.getAttribute('class')).toContain('h-px');
14
- });
15
+ it('draws a horizontal line by default, and a vertical one when asked', async () => {
16
+ const { componentRef, container } = await render(SeparatorHost);
17
+ // The classes are on the host element, the separator's only element.
18
+ const line = container.querySelector('.bg-border')!;
19
+ expect(line.classList).toContain('h-px');
20
+ expect(line.classList).toContain('my-2');
15
21
 
16
- it('renders vertically when the orientation input is flipped', async () => {
17
- const { componentRef } = await render(UiSeparator);
18
- setInputSignal(
19
- (componentRef.instance as UiSeparator).orientation,
20
- 'vertical',
21
- );
22
+ (componentRef.instance as SeparatorHost).orientation.set('vertical');
22
23
  await waitForUpdate();
23
- const host = componentRef.location.nativeElement as HTMLElement;
24
- expect(host.getAttribute('class')).toContain('w-px');
24
+ expect(line.classList).toContain('w-px');
25
+ expect(line.classList).not.toContain('h-px');
25
26
  });
26
27
  });
@@ -1,7 +1,13 @@
1
- import { Component } from '@angular/core';
2
- import { render } from '@blotch/angular-lynx-testing-library';
1
+ import { Component, type WritableSignal, signal } from '@angular/core';
2
+ import {
3
+ fireEvent,
4
+ render,
5
+ waitForUpdate,
6
+ } from '@blotch/angular-lynx-testing-library';
3
7
  import { LYNX_ELEMENTS } from '@blotch/angular-lynx';
4
- import { describe, expect, it } from 'vitest';
8
+ import { afterEach, describe, expect, it, vi } from 'vitest';
9
+ import { type SheetDetent, UiSheetSource } from '../bottom-sheet/bottom-sheet';
10
+ import { UiGlass } from '../glass/glass';
5
11
  import {
6
12
  UiSheet,
7
13
  UiSheetDescription,
@@ -11,7 +17,6 @@ import {
11
17
  } from './sheet';
12
18
 
13
19
  @Component({
14
- standalone: true,
15
20
  imports: [
16
21
  UiSheet,
17
22
  UiSheetHeader,
@@ -21,24 +26,159 @@ import {
21
26
  LYNX_ELEMENTS,
22
27
  ],
23
28
  template: `
24
- <ui-sheet [(open)]="open">
25
- <ui-sheet-header>
26
- <ui-sheet-title>Title</ui-sheet-title>
27
- <ui-sheet-description>Body</ui-sheet-description>
29
+ <ui-sheet [(open)]="open" class="gap-4" (closed)="closed()">
30
+ <ui-sheet-header class="items-center">
31
+ <ui-sheet-title class="text-xl">Title</ui-sheet-title>
32
+ <ui-sheet-description class="italic">Body</ui-sheet-description>
28
33
  </ui-sheet-header>
29
- <ui-sheet-footer><text>Buttons</text></ui-sheet-footer>
34
+ <ui-sheet-footer class="flex-row"><text>Buttons</text></ui-sheet-footer>
30
35
  </ui-sheet>
31
36
  `,
32
37
  })
33
38
  class SheetHost {
34
- open = true;
39
+ readonly open = signal(false);
40
+ readonly closed = vi.fn();
35
41
  }
36
42
 
43
+ /**
44
+ * A glass sheet presented by a glass button, which comes first, as a button
45
+ * above the sheet does.
46
+ */
47
+ @Component({
48
+ imports: [UiSheet, UiSheetSource, UiGlass, LYNX_ELEMENTS],
49
+ template: `
50
+ <blur-view ui-glass class="source" [uiSheetSource]="sheet">
51
+ <text>Add</text>
52
+ </blur-view>
53
+ <ui-sheet #sheet variant="glass" [(open)]="open">
54
+ <text>Body</text>
55
+ </ui-sheet>
56
+ `,
57
+ })
58
+ class SourceHost {
59
+ readonly open = signal(false);
60
+ }
61
+
62
+ const renderSheet = async () => {
63
+ const result = await render(SheetHost);
64
+ return {
65
+ ...result,
66
+ host: result.componentRef.instance as SheetHost,
67
+ overlay: result.container.querySelector('overlay')!,
68
+ backdrop: result.container.querySelector('overlay > view')!,
69
+ };
70
+ };
71
+
72
+ /**
73
+ * Opens the sheet and waits out its open sequence: the overlay shows on one
74
+ * tick, and the panel slides in on the next.
75
+ */
76
+ const openSheet = async (host: { readonly open: WritableSignal<boolean> }) => {
77
+ host.open.set(true);
78
+ for (let i = 0; i < 3; i++) await waitForUpdate();
79
+ };
80
+
37
81
  describe('UiSheet', () => {
38
82
  it('renders header, title, description, and footer', async () => {
39
- const { getByText } = await render(SheetHost);
83
+ const { getByText } = await renderSheet();
40
84
  expect(getByText('Title')).toBeTruthy();
41
85
  expect(getByText('Body')).toBeTruthy();
42
86
  expect(getByText('Buttons')).toBeTruthy();
43
87
  });
88
+
89
+ it("merges each part's class with its own", async () => {
90
+ const { container, getByText } = await renderSheet();
91
+ // The sheet's class goes on the padded content wrapper, not the panel.
92
+ expect(container.querySelector('.px-6')?.classList).toContain('gap-4');
93
+ expect(container.querySelector('.mb-4')?.classList).toContain(
94
+ 'items-center',
95
+ );
96
+ expect(getByText('Title').classList).toContain('text-xl');
97
+ expect(getByText('Title').classList).toContain('font-semibold');
98
+ expect(getByText('Body').classList).toContain('italic');
99
+ expect(getByText('Body').classList).toContain('text-muted-foreground');
100
+ expect(container.querySelector('.pt-4')?.classList).toContain('flex-row');
101
+ });
102
+
103
+ it('opens with `open`, and reports a dismissal through it and `closed`', async () => {
104
+ const { host, overlay, backdrop } = await renderSheet();
105
+ expect(overlay.getAttribute('visible')).toBe('false');
106
+
107
+ await openSheet(host);
108
+ expect(overlay.getAttribute('visible')).toBe('true');
109
+
110
+ fireEvent.tap(backdrop);
111
+ expect(host.open()).toBe(false);
112
+ // Once the panel has slid out, the overlay hides and `closed` fires.
113
+ await vi.waitFor(() => expect(host.closed).toHaveBeenCalled());
114
+ await waitForUpdate();
115
+ expect(overlay.getAttribute('visible')).toBe('false');
116
+ expect(host.closed).toHaveBeenCalledOnce();
117
+ });
118
+ });
119
+
120
+ @Component({
121
+ imports: [UiSheet, LYNX_ELEMENTS],
122
+ template: `
123
+ <ui-sheet
124
+ [(open)]="open"
125
+ variant="glass"
126
+ [detents]="['medium', 'large']"
127
+ [(detent)]="detent"
128
+ >
129
+ <text>Body</text>
130
+ </ui-sheet>
131
+ `,
132
+ })
133
+ class GlassSheetHost {
134
+ readonly open = signal(false);
135
+ readonly detent = signal<SheetDetent | undefined>(undefined);
136
+ }
137
+
138
+ describe('UiSheet glass variant', () => {
139
+ afterEach(() => vi.unstubAllGlobals());
140
+
141
+ it('passes the variant and the detents to its bottom sheet', async () => {
142
+ vi.stubGlobal('SystemInfo', { platform: 'iOS', osVersion: '26.0' });
143
+ const { componentRef, container, getByText } = await render(GlassSheetHost);
144
+ const host = componentRef.instance as GlassSheetHost;
145
+ // A sheet with heights of its own lets its content fill it.
146
+ expect(getByText('Body').parentElement?.classList).toContain('flex-1');
147
+
148
+ // Laid out as on a phone, which the medium and large detents need.
149
+ const backdrop = container.querySelector('overlay > view')!;
150
+ fireEvent.layoutchange(backdrop, { detail: { height: 874 } });
151
+ fireEvent.layoutchange(backdrop.firstElementChild!, {
152
+ detail: { height: 812 },
153
+ });
154
+ await openSheet(host);
155
+ expect(
156
+ container.querySelector('blur-view')?.getAttribute('blur-effect'),
157
+ ).toBe('glass');
158
+ expect(host.detent()).toBe('medium');
159
+
160
+ // The grabber moves it to the next detent, and the host hears of it.
161
+ const grabber = container.querySelector('overlay .rounded-full')!;
162
+ fireEvent.tap(grabber.parentElement!, { eventType: 'catchEvent' });
163
+ await waitForUpdate();
164
+ expect(host.detent()).toBe('large');
165
+ });
166
+ });
167
+
168
+ describe('UiSheet grown out of its control', () => {
169
+ afterEach(() => vi.unstubAllGlobals());
170
+
171
+ it('hands the control on to its bottom sheet, which pairs their glass', async () => {
172
+ vi.stubGlobal('SystemInfo', { platform: 'iOS', osVersion: '26.0' });
173
+ const { container } = await render(SourceHost);
174
+ const source = container.querySelector('.source')!;
175
+ const glass = container.querySelector('overlay blur-view[ui-glass]')!;
176
+
177
+ expect(source.getAttribute('glass-effect-id')).toMatch(/^ui-sheet-\d+$/);
178
+ expect(glass.getAttribute('glass-effect-id')).toBe(
179
+ source.getAttribute('glass-effect-id'),
180
+ );
181
+ // Shown until the sheet covers it.
182
+ expect((source as HTMLElement).style.visibility).toBe('');
183
+ });
44
184
  });
@@ -5,43 +5,106 @@ import {
5
5
  input,
6
6
  model,
7
7
  output,
8
+ viewChild,
8
9
  } from '@angular/core';
9
10
  import { LYNX_ELEMENTS } from '@blotch/angular-lynx';
10
11
 
11
- import { UiBottomSheet } from '../bottom-sheet/bottom-sheet';
12
+ import {
13
+ type BottomSheetVariant,
14
+ type SheetDetent,
15
+ type SheetSourceTarget,
16
+ UiBottomSheet,
17
+ } from '../bottom-sheet/bottom-sheet';
12
18
  import { cn } from '../../utils/cn';
13
19
 
20
+ /**
21
+ * `UiBottomSheet`, for the sheet's view query. A call rather than the class
22
+ * itself: for a class, Angular's test build keeps an arrow function that
23
+ * nothing calls, which an app's coverage report would show as uncovered.
24
+ */
25
+ const bottomSheetType = () => UiBottomSheet;
26
+
14
27
  /**
15
28
  * Styled bottom sheet: a thin wrapper over the shared `ui-bottom-sheet`
16
29
  * primitive that adds content padding and pairs with the header/title/
17
30
  * description/footer layout helpers below. All the overlay, animation, and
18
- * drag-to-dismiss behavior lives in `ui-bottom-sheet`.
31
+ * drag-to-dismiss behavior lives in `ui-bottom-sheet`, and so do the glass
32
+ * variant and the detents, which pass straight through.
19
33
  *
20
34
  * The consumer's `class` and the built-in padding are applied to an inner
21
35
  * content wrapper (not the panel) — the panel chrome (rounded corners, border,
22
36
  * background) comes from the primitive.
37
+ *
38
+ * Mark the control that presents it with `[uiSheetSource]="sheet"`, and the
39
+ * glass sheet grows out of it (see UiSheetSource).
23
40
  */
24
41
  @Component({
25
42
  selector: 'ui-sheet',
26
43
  standalone: true,
27
44
  imports: [LYNX_ELEMENTS, UiBottomSheet],
28
45
  encapsulation: ViewEncapsulation.None,
46
+ // `open` is bound both ways by hand rather than with `[(open)]`: for a
47
+ // two-way binding Angular also compiles a fallback that assigns the field,
48
+ // which never runs for a signal and so shows as an uncovered branch in an
49
+ // app's coverage report.
29
50
  template: `
30
- <ui-bottom-sheet [(open)]="open" (closed)="closed.emit()">
51
+ <ui-bottom-sheet
52
+ [open]="open()"
53
+ (openChange)="open.set($event)"
54
+ [variant]="variant()"
55
+ [detents]="detents()"
56
+ [detent]="detent()"
57
+ (detentChange)="detent.set($event)"
58
+ (closed)="closed.emit()"
59
+ >
31
60
  <view [class]="contentClass()">
32
61
  <ng-content />
33
62
  </view>
34
63
  </ui-bottom-sheet>
35
64
  `,
36
65
  })
37
- export class UiSheet {
66
+ export class UiSheet implements SheetSourceTarget {
38
67
  readonly open = model(false);
39
68
  readonly userClass = input<string>('', { alias: 'class' });
69
+ /** `'default'` or `'glass'`; see BottomSheetVariant. */
70
+ readonly variant = input<BottomSheetVariant>('default');
71
+ /** The heights the sheet rests at; see UiBottomSheet's `detents`. */
72
+ readonly detents = input<readonly SheetDetent[]>(['fit']);
73
+ /** The detent the sheet rests at; see UiBottomSheet's `detent`. */
74
+ readonly detent = model<SheetDetent>();
40
75
 
41
76
  readonly closed = output<void>();
42
77
 
78
+ // Required: always in the template.
79
+ readonly bottomSheet = viewChild.required(bottomSheetType());
80
+
81
+ /**
82
+ * Whether the sheet covers the control that presents it; see
83
+ * UiSheetSource.
84
+ */
85
+ coversSource(): boolean {
86
+ return this.bottomSheet().coversSource();
87
+ }
88
+
89
+ /**
90
+ * @internal Called by the `uiSheetSource` directive, for the sheet this
91
+ * one draws on.
92
+ */
93
+ setSource(...source: Parameters<SheetSourceTarget['setSource']>): void {
94
+ this.bottomSheet().setSource(...source);
95
+ }
96
+
97
+ /**
98
+ * At a detent with a height of its own, the content fills the sheet as a
99
+ * column, so a `flex-1` scroll view in it gets the height that's left.
100
+ */
43
101
  protected readonly contentClass = computed(() =>
44
- cn('px-6 pb-6', this.userClass()),
102
+ cn(
103
+ 'px-6 pb-6',
104
+ this.detents().some((detent) => detent !== 'fit') &&
105
+ 'flex-1 flex-col flex',
106
+ this.userClass(),
107
+ ),
45
108
  );
46
109
  }
47
110