@blotch/dolan 22.2.2 → 22.2.4

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 (259) hide show
  1. package/dist/commands/add.d.ts +6 -2
  2. package/dist/commands/add.js +41 -11
  3. package/dist/commands/add.js.map +1 -1
  4. package/dist/commands/add.test.js +162 -9
  5. package/dist/commands/add.test.js.map +1 -1
  6. package/dist/commands/diff.d.ts +2 -1
  7. package/dist/commands/diff.js +38 -25
  8. package/dist/commands/diff.js.map +1 -1
  9. package/dist/commands/diff.test.js +72 -11
  10. package/dist/commands/diff.test.js.map +1 -1
  11. package/dist/commands/doctor.js +228 -34
  12. package/dist/commands/doctor.js.map +1 -1
  13. package/dist/commands/doctor.test.js +367 -10
  14. package/dist/commands/doctor.test.js.map +1 -1
  15. package/dist/commands/eject.js +7 -0
  16. package/dist/commands/eject.js.map +1 -1
  17. package/dist/commands/eject.test.js +39 -0
  18. package/dist/commands/eject.test.js.map +1 -1
  19. package/dist/commands/info.js +3 -2
  20. package/dist/commands/info.js.map +1 -1
  21. package/dist/commands/init.d.ts +37 -1
  22. package/dist/commands/init.js +169 -40
  23. package/dist/commands/init.js.map +1 -1
  24. package/dist/commands/init.test.js +392 -27
  25. package/dist/commands/init.test.js.map +1 -1
  26. package/dist/commands/install-packages.d.ts +6 -0
  27. package/dist/commands/install-packages.js +20 -0
  28. package/dist/commands/install-packages.js.map +1 -0
  29. package/dist/commands/install-packages.test.d.ts +1 -0
  30. package/dist/commands/install-packages.test.js +55 -0
  31. package/dist/commands/install-packages.test.js.map +1 -0
  32. package/dist/commands/list.js +21 -14
  33. package/dist/commands/list.js.map +1 -1
  34. package/dist/commands/list.test.js +62 -5
  35. package/dist/commands/list.test.js.map +1 -1
  36. package/dist/commands/outdated.js +11 -10
  37. package/dist/commands/outdated.js.map +1 -1
  38. package/dist/commands/outdated.test.js +20 -5
  39. package/dist/commands/outdated.test.js.map +1 -1
  40. package/dist/commands/remove.d.ts +4 -0
  41. package/dist/commands/remove.js +17 -4
  42. package/dist/commands/remove.js.map +1 -1
  43. package/dist/commands/remove.test.js +53 -2
  44. package/dist/commands/remove.test.js.map +1 -1
  45. package/dist/commands/theme.js +1 -1
  46. package/dist/commands/theme.js.map +1 -1
  47. package/dist/commands/update.d.ts +11 -0
  48. package/dist/commands/update.js +174 -58
  49. package/dist/commands/update.js.map +1 -1
  50. package/dist/commands/update.test.js +587 -33
  51. package/dist/commands/update.test.js.map +1 -1
  52. package/dist/index.js +7 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/lockfile.d.ts +7 -0
  55. package/dist/lockfile.js +36 -0
  56. package/dist/lockfile.js.map +1 -1
  57. package/dist/lockfile.test.d.ts +1 -0
  58. package/dist/lockfile.test.js +25 -0
  59. package/dist/lockfile.test.js.map +1 -0
  60. package/dist/registry.d.ts +14 -0
  61. package/dist/registry.js +78 -24
  62. package/dist/registry.js.map +1 -1
  63. package/dist/registry.test.js +119 -38
  64. package/dist/registry.test.js.map +1 -1
  65. package/dist/test-utils.d.ts +5 -0
  66. package/dist/test-utils.js +6 -1
  67. package/dist/test-utils.js.map +1 -1
  68. package/dist/testing/fire-lynx-event.d.ts +14 -0
  69. package/dist/testing/fire-lynx-event.js +19 -0
  70. package/dist/testing/fire-lynx-event.js.map +1 -0
  71. package/dist/testing/fire-lynx-event.test.d.ts +1 -0
  72. package/dist/testing/fire-lynx-event.test.js +44 -0
  73. package/dist/testing/fire-lynx-event.test.js.map +1 -0
  74. package/dist/testing/lynx-main-thread.d.ts +22 -0
  75. package/dist/testing/lynx-main-thread.js +11 -0
  76. package/dist/testing/lynx-main-thread.js.map +1 -0
  77. package/dist/testing/lynx-main-thread.test.d.ts +1 -0
  78. package/dist/testing/lynx-main-thread.test.js +24 -0
  79. package/dist/testing/lynx-main-thread.test.js.map +1 -0
  80. package/dist/testing/set-input-signal.d.ts +14 -0
  81. package/dist/testing/set-input-signal.js +21 -0
  82. package/dist/testing/set-input-signal.js.map +1 -0
  83. package/dist/testing/set-input-signal.test.d.ts +1 -0
  84. package/dist/testing/set-input-signal.test.js +20 -0
  85. package/dist/testing/set-input-signal.test.js.map +1 -0
  86. package/dist/ui/components/accordion/accordion.test.ts +158 -144
  87. package/dist/ui/components/accordion/accordion.ts +19 -14
  88. package/dist/ui/components/action-sheet/action-sheet.test.ts +283 -151
  89. package/dist/ui/components/action-sheet/action-sheet.ts +77 -43
  90. package/dist/ui/components/alert/alert.test.ts +67 -19
  91. package/dist/ui/components/alert/alert.ts +14 -16
  92. package/dist/ui/components/alert-dialog/alert-dialog.test.ts +208 -94
  93. package/dist/ui/components/alert-dialog/alert-dialog.ts +75 -38
  94. package/dist/ui/components/area-chart/area-chart.test.ts +134 -119
  95. package/dist/ui/components/area-chart/area-chart.ts +100 -315
  96. package/dist/ui/components/area-chart/index.ts +2 -3
  97. package/dist/ui/components/avatar/avatar.test.ts +89 -45
  98. package/dist/ui/components/badge/badge.test.ts +57 -23
  99. package/dist/ui/components/badge/badge.ts +12 -14
  100. package/dist/ui/components/bar-chart/bar-chart.test.ts +172 -45
  101. package/dist/ui/components/bar-chart/bar-chart.ts +140 -294
  102. package/dist/ui/components/bar-chart/index.ts +3 -3
  103. package/dist/ui/components/bottom-sheet/bottom-sheet.test.ts +386 -128
  104. package/dist/ui/components/bottom-sheet/bottom-sheet.ts +170 -53
  105. package/dist/ui/components/button/button.test.ts +611 -2
  106. package/dist/ui/components/button/button.ts +434 -49
  107. package/dist/ui/components/button/index.ts +2 -0
  108. package/dist/ui/components/button-group/button-group.test.ts +484 -2
  109. package/dist/ui/components/button-group/button-group.ts +380 -68
  110. package/dist/ui/components/button-group/index.ts +3 -0
  111. package/dist/ui/components/candlestick-chart/candlestick-chart.test.ts +183 -58
  112. package/dist/ui/components/candlestick-chart/candlestick-chart.ts +150 -323
  113. package/dist/ui/components/candlestick-chart/index.ts +3 -4
  114. package/dist/ui/components/card/card.test.ts +82 -62
  115. package/dist/ui/components/chart/chart-focus.test.ts +132 -0
  116. package/dist/ui/components/chart/chart-focus.ts +115 -0
  117. package/dist/ui/components/chart/chart-presets.test.ts +335 -0
  118. package/dist/ui/components/chart/chart-presets.ts +278 -0
  119. package/dist/ui/components/chart/chart-scene.test.ts +589 -0
  120. package/dist/ui/components/chart/chart-scene.ts +483 -0
  121. package/dist/ui/components/chart/chart-theme.test.ts +85 -0
  122. package/dist/ui/components/chart/chart-theme.ts +210 -0
  123. package/dist/ui/components/chart/chart-zoom.test.ts +159 -0
  124. package/dist/ui/components/chart/chart-zoom.ts +162 -0
  125. package/dist/ui/components/chart/chart.test.ts +1017 -0
  126. package/dist/ui/components/chart/chart.ts +934 -0
  127. package/dist/ui/components/chart/index.ts +24 -0
  128. package/dist/ui/components/checkbox/checkbox.test.ts +124 -42
  129. package/dist/ui/components/checkbox/checkbox.ts +23 -23
  130. package/dist/ui/components/collapsible/collapsible.test.ts +158 -81
  131. package/dist/ui/components/collapsible/collapsible.ts +19 -14
  132. package/dist/ui/components/context-menu/context-menu.test.ts +224 -0
  133. package/dist/ui/components/context-menu/context-menu.ts +110 -0
  134. package/dist/ui/components/context-menu/index.ts +1 -0
  135. package/dist/ui/components/dialog/dialog.test.ts +213 -108
  136. package/dist/ui/components/dialog/dialog.ts +72 -35
  137. package/dist/ui/components/dock/dock-scroll.test.ts +130 -0
  138. package/dist/ui/components/dock/dock-scroll.ts +133 -0
  139. package/dist/ui/components/dock/dock.test.ts +749 -0
  140. package/dist/ui/components/dock/dock.ts +960 -0
  141. package/dist/ui/components/dock/index.ts +2 -0
  142. package/dist/ui/components/empty-state/empty-state.test.ts +28 -39
  143. package/dist/ui/components/glass/concentric-radius.test.ts +13 -0
  144. package/dist/ui/components/glass/concentric-radius.ts +17 -0
  145. package/dist/ui/components/glass/glass-design.test.ts +78 -0
  146. package/dist/ui/components/glass/glass-design.ts +119 -0
  147. package/dist/ui/components/glass/glass.test.ts +338 -0
  148. package/dist/ui/components/glass/glass.ts +360 -0
  149. package/dist/ui/components/glass/index.ts +18 -0
  150. package/dist/ui/components/icon/icon-theme.test.ts +169 -0
  151. package/dist/ui/components/icon/icon-theme.ts +227 -0
  152. package/dist/ui/components/icon/icon.test.ts +85 -25
  153. package/dist/ui/components/icon/icon.ts +38 -21
  154. package/dist/ui/components/input/input.test.ts +178 -101
  155. package/dist/ui/components/input/input.ts +15 -12
  156. package/dist/ui/components/label/label.test.ts +11 -24
  157. package/dist/ui/components/line-chart/index.ts +2 -3
  158. package/dist/ui/components/line-chart/line-chart.test.ts +149 -56
  159. package/dist/ui/components/line-chart/line-chart.ts +83 -241
  160. package/dist/ui/components/list/list.test.ts +119 -21
  161. package/dist/ui/components/list/list.ts +21 -15
  162. package/dist/ui/components/menu/index.ts +25 -0
  163. package/dist/ui/components/menu/menu-placement.test.ts +153 -0
  164. package/dist/ui/components/menu/menu-placement.ts +159 -0
  165. package/dist/ui/components/menu/menu-popup.test.ts +632 -0
  166. package/dist/ui/components/menu/menu-popup.ts +544 -0
  167. package/dist/ui/components/menu/menu.test.ts +429 -0
  168. package/dist/ui/components/menu/menu.ts +415 -0
  169. package/dist/ui/components/nav-drawer/nav-drawer.test.ts +435 -191
  170. package/dist/ui/components/nav-drawer/nav-drawer.ts +127 -56
  171. package/dist/ui/components/pagination/pagination.test.ts +177 -65
  172. package/dist/ui/components/pagination/pagination.ts +55 -8
  173. package/dist/ui/components/progress/progress.test.ts +102 -46
  174. package/dist/ui/components/progress/progress.ts +52 -54
  175. package/dist/ui/components/radio-group/radio-group.test.ts +128 -83
  176. package/dist/ui/components/radio-group/radio-group.ts +24 -24
  177. package/dist/ui/components/scatter-chart/index.ts +2 -3
  178. package/dist/ui/components/scatter-chart/scatter-chart.test.ts +131 -26
  179. package/dist/ui/components/scatter-chart/scatter-chart.ts +104 -250
  180. package/dist/ui/components/scroll-area/scroll-area.test.ts +95 -24
  181. package/dist/ui/components/scroll-area/scroll-area.ts +8 -8
  182. package/dist/ui/components/select/select.test.ts +138 -78
  183. package/dist/ui/components/select/select.ts +17 -11
  184. package/dist/ui/components/separator/separator.test.ts +18 -17
  185. package/dist/ui/components/sheet/sheet.test.ts +64 -11
  186. package/dist/ui/components/sheet/sheet.ts +9 -1
  187. package/dist/ui/components/skeleton/skeleton.test.ts +24 -7
  188. package/dist/ui/components/skeleton/skeleton.ts +10 -16
  189. package/dist/ui/components/spinner/spinner.test.ts +67 -22
  190. package/dist/ui/components/spinner/spinner.ts +48 -41
  191. package/dist/ui/components/switch/switch.test.ts +116 -46
  192. package/dist/ui/components/switch/switch.ts +8 -13
  193. package/dist/ui/components/tab-bar/index.ts +1 -0
  194. package/dist/ui/components/tab-bar/tab-bar.test.ts +280 -0
  195. package/dist/ui/components/tab-bar/tab-bar.ts +230 -0
  196. package/dist/ui/components/tabs/tabs.test.ts +215 -157
  197. package/dist/ui/components/tabs/tabs.ts +110 -118
  198. package/dist/ui/components/textarea/textarea.test.ts +206 -100
  199. package/dist/ui/components/textarea/textarea.ts +14 -12
  200. package/dist/ui/components/toast/toast.test.ts +436 -315
  201. package/dist/ui/components/toast/toast.ts +62 -55
  202. package/dist/ui/components/toggle/toggle.test.ts +247 -140
  203. package/dist/ui/theme/chart-colors.test.ts +35 -0
  204. package/dist/ui/theme/dark.css +46 -2
  205. package/dist/ui/theme/default.css +63 -7
  206. package/dist/ui/theme/icon-colors.test.ts +35 -0
  207. package/dist/ui/theme/rgb-channels.test.ts +84 -0
  208. package/dist/ui/theme/tailwind-build.test.ts +114 -0
  209. package/dist/ui/theme/tailwind-css.test.ts +83 -0
  210. package/dist/ui/theme/tailwind-plugin.test.ts +42 -2
  211. package/dist/ui/theme/tailwind-plugin.ts +98 -25
  212. package/dist/ui/theme/tailwind.css +113 -0
  213. package/dist/ui/utils/animate.test.ts +13 -1
  214. package/dist/utils/analyze.d.ts +14 -0
  215. package/dist/utils/analyze.js +15 -0
  216. package/dist/utils/analyze.js.map +1 -1
  217. package/dist/utils/analyze.test.js +14 -1
  218. package/dist/utils/analyze.test.js.map +1 -1
  219. package/dist/utils/installed.d.ts +29 -0
  220. package/dist/utils/installed.js +43 -0
  221. package/dist/utils/installed.js.map +1 -0
  222. package/dist/utils/installed.test.d.ts +1 -0
  223. package/dist/utils/installed.test.js +57 -0
  224. package/dist/utils/installed.test.js.map +1 -0
  225. package/dist/utils/interactive.d.ts +9 -0
  226. package/dist/utils/interactive.js +10 -0
  227. package/dist/utils/interactive.js.map +1 -0
  228. package/dist/utils/interactive.test.d.ts +1 -0
  229. package/dist/utils/interactive.test.js +24 -0
  230. package/dist/utils/interactive.test.js.map +1 -0
  231. package/dist/utils/packages.d.ts +36 -0
  232. package/dist/utils/packages.js +70 -0
  233. package/dist/utils/packages.js.map +1 -0
  234. package/dist/utils/packages.test.d.ts +1 -0
  235. package/dist/utils/packages.test.js +89 -0
  236. package/dist/utils/packages.test.js.map +1 -0
  237. package/dist/utils/resolve-paths.d.ts +17 -1
  238. package/dist/utils/resolve-paths.js +21 -3
  239. package/dist/utils/resolve-paths.js.map +1 -1
  240. package/dist/utils/resolve-paths.test.js +38 -2
  241. package/dist/utils/resolve-paths.test.js.map +1 -1
  242. package/dist/utils/tailwind.d.ts +25 -0
  243. package/dist/utils/tailwind.js +51 -0
  244. package/dist/utils/tailwind.js.map +1 -0
  245. package/dist/utils/tailwind.test.d.ts +1 -0
  246. package/dist/utils/tailwind.test.js +71 -0
  247. package/dist/utils/tailwind.test.js.map +1 -0
  248. package/package.json +13 -1
  249. package/dist/ui/components/area-chart/area-chart-render.test.ts +0 -121
  250. package/dist/ui/components/bar-chart/bar-chart-render.test.ts +0 -174
  251. package/dist/ui/components/button/button-render.test.ts +0 -113
  252. package/dist/ui/components/button-group/button-group-render.test.ts +0 -146
  253. package/dist/ui/components/candlestick-chart/candlestick-chart-render.test.ts +0 -174
  254. package/dist/ui/components/cartesian-chart/cartesian-chart-render.test.ts +0 -188
  255. package/dist/ui/components/cartesian-chart/cartesian-chart.test.ts +0 -525
  256. package/dist/ui/components/cartesian-chart/cartesian-chart.ts +0 -1140
  257. package/dist/ui/components/cartesian-chart/index.ts +0 -18
  258. package/dist/ui/components/line-chart/line-chart-render.test.ts +0 -121
  259. package/dist/ui/components/scatter-chart/scatter-chart-render.test.ts +0 -157
@@ -0,0 +1,360 @@
1
+ import {
2
+ booleanAttribute,
3
+ Component,
4
+ computed,
5
+ effect,
6
+ ElementRef,
7
+ inject,
8
+ input,
9
+ numberAttribute,
10
+ ViewEncapsulation,
11
+ } from '@angular/core';
12
+ import { LYNX_ELEMENTS, LynxAccessibilitySettings } from '@blotch/angular-lynx';
13
+
14
+ import { cn } from '../../utils/cn';
15
+ import {
16
+ injectColorScheme,
17
+ resolveIconColor,
18
+ UI_ICON_COLOR,
19
+ UI_ICON_THEME,
20
+ } from '../icon/icon-theme';
21
+ import { injectGlassDesign, injectSystemDrawsGlass } from './glass-design';
22
+
23
+ /**
24
+ * `'regular'` glass, the default, frosts what's behind it and suits most
25
+ * controls. `'clear'` glass barely frosts it, for controls over photos and
26
+ * video; put a dimming layer under it when what's behind is bright (see
27
+ * `bg-glass-dim`). Don't mix the two on one screen.
28
+ */
29
+ export type GlassVariant = 'regular' | 'clear';
30
+
31
+ /**
32
+ * A capsule (fully rounded ends, the default for controls), a circle (give
33
+ * it equal width and height) or a rectangle with `radius` corners.
34
+ */
35
+ export type GlassShape = 'capsule' | 'circle' | 'rounded';
36
+
37
+ /**
38
+ * What a glass element draws:
39
+ *
40
+ * - `'glass'`: Liquid Glass.
41
+ * - `'frosted'`: a blur material, on iOS 15 to 25.
42
+ * - `'solid'`: an opaque surface. That's Material on Android, unless the app
43
+ * opted into glass there, and glass under Reduce Transparency on Android
44
+ * and the web, which can't adapt the glass they draw. iOS adapts its own.
45
+ */
46
+ export type GlassSurface = 'glass' | 'frosted' | 'solid';
47
+
48
+ /**
49
+ * How much the glass blurs where the blur is drawn by the runtime: Android's
50
+ * approximation, and the web before WebGL takes over. iOS's glass ignores it.
51
+ * Clear glass barely blurs.
52
+ */
53
+ const GLASS_BLUR: Readonly<Record<GlassVariant, string>> = {
54
+ regular: '16px',
55
+ clear: '6px',
56
+ };
57
+
58
+ /** The blur of the frosted materials before iOS 26. */
59
+ const FROSTED_BLUR = '20px';
60
+
61
+ /**
62
+ * A solid surface floats over the content as glass does, so it gets
63
+ * Material's elevation shadow (level 2). An inline style, because Tailwind's
64
+ * shadow classes draw nothing on Lynx.
65
+ */
66
+ const SOLID_ELEVATION =
67
+ '0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.15)';
68
+
69
+ /** AngularLynx's wrapper of the native `blur-view` the component sits on. */
70
+ type BlurViewElement = { setAttribute(name: string, value: unknown): void };
71
+
72
+ /**
73
+ * The color an icon projected into the glass draws with when it's given
74
+ * none: the glass's foreground (see UI_ICON_COLOR), the way text there reads
75
+ * `text-glass-foreground`. A named function, not an inline factory: the
76
+ * component's metadata keeps its own copy of an inline one, which nothing
77
+ * calls, so an app's coverage report would show it as uncovered.
78
+ */
79
+ const glassIconColor = () => {
80
+ const glass = inject(UiGlass);
81
+ return computed(() => glass.foreground());
82
+ };
83
+
84
+ /**
85
+ * Liquid Glass, for the controls and bars that float above an app's content:
86
+ * a `<blur-view>` that draws the right material on each platform.
87
+ *
88
+ * ```html
89
+ * <blur-view ui-glass class="flex-row items-center gap-2 px-4 py-2">
90
+ * <text class="text-glass-foreground">Now playing</text>
91
+ * </blur-view>
92
+ * ```
93
+ *
94
+ * It sits on the `<blur-view>` itself rather than wrapping one, so the
95
+ * element you lay out and style is the glass, and what you put in it is
96
+ * inside the glass. That matters on iOS: interactive glass reacts only to
97
+ * touches on itself and what's in it, not on views stacked over it.
98
+ *
99
+ * What it draws follows the platform (see GlassDesign): UIKit's Liquid Glass
100
+ * on iOS 26 and later, a frosted blur material on iOS 15 to 25, an opaque
101
+ * Material surface on Android unless the app opts into glass with
102
+ * `provideGlass({ android: 'glass' })`, and the runtime's WebGL glass in the
103
+ * web preview. It also follows the user's accessibility settings where the
104
+ * platform doesn't: see {@link surface}.
105
+ *
106
+ * Text and icons inside read `text-glass-foreground` (and
107
+ * `text-glass-muted-foreground`), which the glass points at the right color
108
+ * for its variant and the user's contrast setting. Glass belongs to the
109
+ * layer above content, and shouldn't be layered on glass.
110
+ */
111
+ @Component({
112
+ selector: 'blur-view[ui-glass]',
113
+ imports: [LYNX_ELEMENTS],
114
+ encapsulation: ViewEncapsulation.None,
115
+ // Icons projected into the glass inject this through its element injector,
116
+ // which content projection keeps them under.
117
+ providers: [{ provide: UI_ICON_COLOR, useFactory: glassIconColor }],
118
+ host: {
119
+ '[class]': 'surfaceClass()',
120
+ '[style.border-radius.px]': 'cornerRadius()',
121
+ '[style.background-color]': 'solidTint()',
122
+ '[style.box-shadow]': 'elevation()',
123
+ },
124
+ // iOS draws no background on a blur view, so a frosted material takes its
125
+ // tint from a fill under the content, the shape of the glass: the filled
126
+ // button of the design before Liquid Glass.
127
+ template: `
128
+ @if (frostedTint(); as color) {
129
+ <view
130
+ [class]="fillClass()"
131
+ [style.background-color]="color"
132
+ [style.border-radius.px]="cornerRadius()"
133
+ ></view>
134
+ }
135
+ <ng-content />
136
+ `,
137
+ })
138
+ export class UiGlass {
139
+ /** `'regular'` or `'clear'`; see GlassVariant. */
140
+ readonly variant = input<GlassVariant>('regular');
141
+ /** `'capsule'`, `'circle'` or `'rounded'`; see GlassShape. */
142
+ readonly shape = input<GlassShape>('capsule');
143
+ /**
144
+ * The corner radius of a `'rounded'` shape, in px. For a shape nested in
145
+ * it, see `concentricRadius()`.
146
+ */
147
+ readonly radius = input(20, { transform: numberAttribute });
148
+ /**
149
+ * A color the glass takes on, such as `var(--glass-tint)` for the theme's
150
+ * tint or `#2563eb`: a theme token or any CSS color. Use it sparingly, for
151
+ * the screen's main action. It fills a solid surface or a frosted
152
+ * material, as Material, and iOS before Liquid Glass, fill a button.
153
+ */
154
+ readonly tint = input<string | undefined>(undefined);
155
+ /**
156
+ * The glass reacts to touch, swelling and brightening under the finger as
157
+ * a Liquid Glass control does: on iOS 26 and later, and in the web preview.
158
+ */
159
+ readonly interactive = input(false, { transform: booleanAttribute });
160
+
161
+ readonly #settings = inject(LynxAccessibilitySettings);
162
+ readonly #systemDrawsGlass = injectSystemDrawsGlass();
163
+ readonly #scheme = injectColorScheme();
164
+ readonly #theme = inject(UI_ICON_THEME);
165
+ readonly #host = inject<ElementRef<BlurViewElement>>(ElementRef);
166
+
167
+ /**
168
+ * The design on this platform, which components built on the glass follow
169
+ * for their own form (see GlassDesign).
170
+ */
171
+ readonly design = injectGlassDesign();
172
+
173
+ /**
174
+ * What the glass draws (see GlassSurface): the design's material, or an
175
+ * opaque surface. Where the runtime draws the glass (Android's opt-in and
176
+ * the web), Reduce Transparency turns it opaque, as UIKit turns its own.
177
+ */
178
+ readonly surface = computed<GlassSurface>(() => {
179
+ const design = this.design();
180
+ if (design === 'material') return 'solid';
181
+ if (!this.#systemDrawsGlass && this.#settings.reduceTransparency()) {
182
+ return 'solid';
183
+ }
184
+ return design;
185
+ });
186
+
187
+ /** Whether what's behind shows through clear glass. */
188
+ readonly #seeThrough = computed(
189
+ () => this.variant() === 'clear' && this.surface() !== 'solid',
190
+ );
191
+
192
+ /**
193
+ * The color of text and icons on this glass, as a `var()`: the clear
194
+ * foreground on see-through clear glass, which sits over photos and video,
195
+ * and the glass foreground otherwise. Projected `<ui-icon>`s get it, and an
196
+ * SVG of your own can resolve it the way icons do (see icon-theme.ts).
197
+ */
198
+ readonly foreground = computed(() =>
199
+ this.#seeThrough()
200
+ ? 'var(--glass-clear-foreground)'
201
+ : 'var(--glass-foreground)',
202
+ );
203
+
204
+ /**
205
+ * The tint as a color the native element can parse: an attribute can't
206
+ * read CSS variables, so a theme token is swapped for its value in the
207
+ * active scheme, as icons do.
208
+ */
209
+ readonly #tintColor = computed(() => {
210
+ const tint = this.tint();
211
+ return tint ? resolveIconColor(tint, this.#theme[this.#scheme()]) : null;
212
+ });
213
+
214
+ /**
215
+ * A tinted solid surface is filled with the tint, as Material's filled
216
+ * buttons are, and as iOS draws tinted glass under Reduce Transparency.
217
+ */
218
+ protected readonly solidTint = computed(() =>
219
+ this.surface() === 'solid' ? this.#tintColor() : null,
220
+ );
221
+
222
+ protected readonly frostedTint = computed(() =>
223
+ this.surface() === 'frosted' ? this.#tintColor() : null,
224
+ );
225
+
226
+ protected readonly fillClass = computed(() =>
227
+ cn(
228
+ 'h-full w-full absolute left-0 top-0',
229
+ this.shape() !== 'rounded' && 'rounded-full',
230
+ ),
231
+ );
232
+
233
+ protected readonly elevation = computed(() =>
234
+ this.surface() === 'solid' ? SOLID_ELEVATION : null,
235
+ );
236
+
237
+ protected readonly cornerRadius = computed(() =>
238
+ this.shape() === 'rounded' ? this.radius() : null,
239
+ );
240
+
241
+ protected readonly surfaceClass = computed(() => {
242
+ const increaseContrast = this.#settings.increaseContrast();
243
+ return cn(
244
+ this.shape() !== 'rounded' && 'rounded-full',
245
+ // Material's tonal surface, and the opaque glass of Reduce
246
+ // Transparency, unless a tint fills it (see solidTint). iOS ignores a
247
+ // blur-view's background, but never draws a solid surface.
248
+ this.surface() === 'solid' && !this.tint() && 'bg-secondary',
249
+ // Increase Contrast gives the glass a visible edge, as UIKit gives its
250
+ // own glass one.
251
+ increaseContrast &&
252
+ !this.#systemDrawsGlass &&
253
+ 'border border-glass-foreground',
254
+ // The glass points the foreground tokens its content reads at the
255
+ // right color (a variable redefined here reaches the projected text,
256
+ // since variables inherit and `color` doesn't): white on see-through
257
+ // clear glass, and full strength for muted text under Increase
258
+ // Contrast.
259
+ this.#seeThrough()
260
+ ? '[--glass-foreground:var(--glass-clear-foreground)] [--glass-muted-foreground:var(--glass-clear-foreground)]'
261
+ : increaseContrast &&
262
+ '[--glass-muted-foreground:var(--glass-foreground)]',
263
+ );
264
+ });
265
+
266
+ /**
267
+ * The blur-view's attributes for the surface. Glass is forced to the app's
268
+ * color scheme (`ios-user-interface-style`), which iOS would otherwise take
269
+ * from the device: an app in its light theme on a phone in dark mode would
270
+ * get dark glass under dark text. The frosted materials before iOS 26 don't
271
+ * adapt to dark mode, so the scheme picks one. A solid surface turns the
272
+ * blur off, and on Android stops the blur-view redrawing the page behind it
273
+ * on every frame (`enable-auto-blur`), which it does even with no radius.
274
+ */
275
+ readonly #attributes = computed(() => {
276
+ const surface = this.surface();
277
+ const variant = this.variant();
278
+ const dark = this.#scheme() === 'dark';
279
+ let effect = 'light';
280
+ let radius = '0px';
281
+ if (surface === 'glass') {
282
+ effect = 'glass';
283
+ radius = GLASS_BLUR[variant];
284
+ } else if (surface === 'frosted') {
285
+ // Apple's controls over media used the dark material in either theme.
286
+ effect = dark || variant === 'clear' ? 'dark' : 'extra-light';
287
+ radius = FROSTED_BLUR;
288
+ }
289
+ return {
290
+ 'blur-effect': effect,
291
+ 'blur-radius': radius,
292
+ 'enable-auto-blur': surface !== 'solid',
293
+ 'glass-style': variant,
294
+ 'glass-tint-color': this.#tintColor(),
295
+ 'glass-interactive': this.interactive() || null,
296
+ 'ios-user-interface-style': dark ? 'dark' : 'light',
297
+ };
298
+ });
299
+
300
+ // Set on the element as they are, rather than through host attribute
301
+ // bindings, which turn every value into a string: Lynx reads
302
+ // `glass-interactive` and `enable-auto-blur` as booleans. `null` removes an
303
+ // attribute, which restores Lynx's default.
304
+ protected readonly material = effect(() => {
305
+ const element = this.#host.nativeElement;
306
+ for (const [name, value] of Object.entries(this.#attributes())) {
307
+ element.setAttribute(name, value);
308
+ }
309
+ });
310
+ }
311
+
312
+ /**
313
+ * Merges the glass elements inside it, as iOS 26 draws a group of glass
314
+ * controls: shapes closer than `spacing` flow into each other like droplets,
315
+ * and the group draws them in one pass. Put a `<blur-view ui-glass>` directly
316
+ * inside it for each shape: iOS merges the glass in the group's own content,
317
+ * and a wrapper that draws anything of its own comes between them.
318
+ *
319
+ * ```html
320
+ * <blur-view ui-glass-group [spacing]="16" class="flex-row gap-2">
321
+ * <blur-view ui-glass shape="circle" class="h-12 w-12">…</blur-view>
322
+ * <blur-view ui-glass shape="circle" class="h-12 w-12">…</blur-view>
323
+ * </blur-view>
324
+ * ```
325
+ *
326
+ * The group draws nothing itself. Shapes merge on iOS 26 and later and in
327
+ * the web preview. Android's glass doesn't merge, and the frosted and
328
+ * Material designs have no glass to merge.
329
+ *
330
+ * Moving or resizing a shape, with a CSS transition for example, morphs the
331
+ * merged glass with it. A shape that's added or removed appears or
332
+ * disappears at once: iOS's glass doesn't animate that in Lynx.
333
+ */
334
+ @Component({
335
+ selector: 'blur-view[ui-glass-group]',
336
+ encapsulation: ViewEncapsulation.None,
337
+ template: `<ng-content />`,
338
+ })
339
+ export class UiGlassGroup {
340
+ /** How close two glass shapes come before they merge, in px. */
341
+ readonly spacing = input(0, { transform: numberAttribute });
342
+
343
+ readonly #design = injectGlassDesign();
344
+ readonly #host = inject<ElementRef<BlurViewElement>>(ElementRef);
345
+
346
+ // As UiGlass sets its own (see there). A container that isn't merging
347
+ // glass is a plain transparent view: `light` with no radius draws nothing,
348
+ // where `glass-container` would log an error before iOS 26. It never blurs,
349
+ // so on Android it never redraws the page behind it either.
350
+ protected readonly material = effect(() => {
351
+ const element = this.#host.nativeElement;
352
+ element.setAttribute(
353
+ 'blur-effect',
354
+ this.#design() === 'glass' ? 'glass-container' : 'light',
355
+ );
356
+ element.setAttribute('blur-radius', '0px');
357
+ element.setAttribute('enable-auto-blur', false);
358
+ element.setAttribute('spacing', this.spacing());
359
+ });
360
+ }
@@ -0,0 +1,18 @@
1
+ export {
2
+ UiGlass,
3
+ UiGlassGroup,
4
+ type GlassShape,
5
+ type GlassSurface,
6
+ type GlassVariant,
7
+ } from './glass';
8
+ export {
9
+ FIRST_GLASS_IOS,
10
+ UI_GLASS_OPTIONS,
11
+ glassDesignFor,
12
+ injectGlassDesign,
13
+ injectSystemDrawsGlass,
14
+ provideGlass,
15
+ type GlassDesign,
16
+ type GlassOptions,
17
+ } from './glass-design';
18
+ export { concentricRadius } from './concentric-radius';
@@ -0,0 +1,169 @@
1
+ import {
2
+ Injector,
3
+ type Provider,
4
+ runInInjectionContext,
5
+ signal,
6
+ } from '@angular/core';
7
+ import { LynxTheme } from '@blotch/angular-lynx';
8
+ import { describe, expect, it } from 'vitest';
9
+ import {
10
+ ICON_DARK_COLORS,
11
+ ICON_LIGHT_COLORS,
12
+ UI_ICON_COLOR,
13
+ UI_ICON_THEME,
14
+ injectColorScheme,
15
+ injectIconColor,
16
+ provideIconTheme,
17
+ resolveIconColor,
18
+ } from './icon-theme';
19
+
20
+ const LIGHT_FOREGROUND = ICON_LIGHT_COLORS['foreground'];
21
+ const DARK_FOREGROUND = ICON_DARK_COLORS['foreground'];
22
+
23
+ /**
24
+ * Runs injectIconColor() against a device appearance and extra providers. A
25
+ * plain Injector has no root scope, so it gets the default theme explicitly;
26
+ * the token's own factory is covered by the component tests.
27
+ */
28
+ const setup = (providers: Provider[] = [], dark = signal(false)) => {
29
+ const injector = Injector.create({
30
+ providers: [
31
+ { provide: LynxTheme, useValue: { isDarkMode: dark } },
32
+ {
33
+ provide: UI_ICON_THEME,
34
+ useValue: { light: ICON_LIGHT_COLORS, dark: ICON_DARK_COLORS },
35
+ },
36
+ ...providers,
37
+ ],
38
+ });
39
+ return runInInjectionContext(injector, () => injectIconColor());
40
+ };
41
+
42
+ describe('resolveIconColor', () => {
43
+ it('passes a literal color through', () => {
44
+ expect(resolveIconColor('#2563eb', ICON_LIGHT_COLORS)).toBe('#2563eb');
45
+ expect(resolveIconColor(' rgba(1, 2, 3, 1) ', ICON_LIGHT_COLORS)).toBe(
46
+ 'rgba(1, 2, 3, 1)',
47
+ );
48
+ });
49
+
50
+ it('swaps a theme token for its value', () => {
51
+ expect(resolveIconColor('var(--primary)', ICON_LIGHT_COLORS)).toBe(
52
+ ICON_LIGHT_COLORS['primary'],
53
+ );
54
+ expect(resolveIconColor('var( --destructive )', ICON_DARK_COLORS)).toBe(
55
+ ICON_DARK_COLORS['destructive'],
56
+ );
57
+ });
58
+
59
+ it("falls back to the var()'s fallback for an unknown token", () => {
60
+ expect(resolveIconColor('var(--brand, #ff0000)', ICON_LIGHT_COLORS)).toBe(
61
+ '#ff0000',
62
+ );
63
+ // The fallback may itself be a token.
64
+ expect(
65
+ resolveIconColor('var(--brand, var(--primary))', ICON_LIGHT_COLORS),
66
+ ).toBe(ICON_LIGHT_COLORS['primary']);
67
+ });
68
+
69
+ it('falls back to the foreground for an unknown token with no fallback', () => {
70
+ expect(resolveIconColor('var(--brand)', ICON_LIGHT_COLORS)).toBe(
71
+ LIGHT_FOREGROUND,
72
+ );
73
+ });
74
+
75
+ it('leaves an unknown token as it is when the table has no foreground', () => {
76
+ expect(resolveIconColor('var(--brand)', {})).toBe('var(--brand)');
77
+ });
78
+ });
79
+
80
+ describe('provideIconTheme', () => {
81
+ it('merges the overrides over the default tables', () => {
82
+ const provider = provideIconTheme({
83
+ light: { primary: '#123456' },
84
+ colorScheme: 'dark',
85
+ }) as { provide: unknown; useValue: Record<string, unknown> };
86
+ expect(provider.provide).toBe(UI_ICON_THEME);
87
+ expect(provider.useValue['light']).toEqual({
88
+ ...ICON_LIGHT_COLORS,
89
+ primary: '#123456',
90
+ });
91
+ expect(provider.useValue['dark']).toEqual(ICON_DARK_COLORS);
92
+ expect(provider.useValue['colorScheme']).toBe('dark');
93
+ });
94
+ });
95
+
96
+ describe('injectColorScheme', () => {
97
+ const scheme = (providers: Provider[], dark = signal(false)) =>
98
+ runInInjectionContext(
99
+ Injector.create({
100
+ providers: [
101
+ { provide: LynxTheme, useValue: { isDarkMode: dark } },
102
+ {
103
+ provide: UI_ICON_THEME,
104
+ useValue: { light: ICON_LIGHT_COLORS, dark: ICON_DARK_COLORS },
105
+ },
106
+ ...providers,
107
+ ],
108
+ }),
109
+ () => injectColorScheme(),
110
+ );
111
+
112
+ it("is light unless the theme says otherwise, whatever the device's appearance", () => {
113
+ expect(scheme([], signal(true))()).toBe('light');
114
+ expect(scheme([provideIconTheme({ colorScheme: 'dark' })])()).toBe('dark');
115
+ });
116
+
117
+ it("follows the device with 'system', or the app's own state", () => {
118
+ const dark = signal(false);
119
+ const system = scheme([provideIconTheme({ colorScheme: 'system' })], dark);
120
+ expect(system()).toBe('light');
121
+ dark.set(true);
122
+ expect(system()).toBe('dark');
123
+
124
+ const own = signal<'light' | 'dark'>('dark');
125
+ expect(scheme([provideIconTheme({ colorScheme: () => own() })])()).toBe(
126
+ 'dark',
127
+ );
128
+ });
129
+ });
130
+
131
+ describe('injectIconColor', () => {
132
+ it('draws with the light foreground by default, even on a dark device', () => {
133
+ const resolve = setup([], signal(true));
134
+ expect(resolve(undefined)).toBe(LIGHT_FOREGROUND);
135
+ });
136
+
137
+ it('resolves an explicit color against the active table', () => {
138
+ const resolve = setup([provideIconTheme({ colorScheme: 'dark' })]);
139
+ expect(resolve('var(--primary)')).toBe(ICON_DARK_COLORS['primary']);
140
+ expect(resolve('#00ff00')).toBe('#00ff00');
141
+ });
142
+
143
+ it("follows the device appearance with 'system'", () => {
144
+ const dark = signal(false);
145
+ const resolve = setup([provideIconTheme({ colorScheme: 'system' })], dark);
146
+ expect(resolve(undefined)).toBe(LIGHT_FOREGROUND);
147
+ dark.set(true);
148
+ expect(resolve(undefined)).toBe(DARK_FOREGROUND);
149
+ });
150
+
151
+ it("reads the app's own theme state from a function", () => {
152
+ const scheme = signal<'light' | 'dark'>('dark');
153
+ const resolve = setup([provideIconTheme({ colorScheme: () => scheme() })]);
154
+ expect(resolve(undefined)).toBe(DARK_FOREGROUND);
155
+ scheme.set('light');
156
+ expect(resolve(undefined)).toBe(LIGHT_FOREGROUND);
157
+ });
158
+
159
+ it("uses the container's color when the icon sets none", () => {
160
+ const inherited = signal<string | undefined>('var(--destructive)');
161
+ const resolve = setup([{ provide: UI_ICON_COLOR, useValue: inherited }]);
162
+ expect(resolve(undefined)).toBe(ICON_LIGHT_COLORS['destructive']);
163
+ // The icon's own color still wins.
164
+ expect(resolve('var(--primary)')).toBe(ICON_LIGHT_COLORS['primary']);
165
+ // A container that sets no color leaves the foreground.
166
+ inherited.set(undefined);
167
+ expect(resolve(undefined)).toBe(LIGHT_FOREGROUND);
168
+ });
169
+ });