ochreui 0.0.0-stage → 0.0.2

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 (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -2
  3. package/cli/ochreui.mjs +601 -0
  4. package/mcp/core.mjs +126 -0
  5. package/mcp/docs.json +906 -0
  6. package/mcp/server.mjs +23 -0
  7. package/package.json +393 -3
  8. package/registry/agent-team.ts +350 -0
  9. package/registry/avatar.ts +300 -0
  10. package/registry/badge.ts +207 -0
  11. package/registry/breadcrumb.ts +435 -0
  12. package/registry/button.ts +238 -0
  13. package/registry/card.ts +221 -0
  14. package/registry/change-summary.ts +200 -0
  15. package/registry/checkbox.ts +204 -0
  16. package/registry/code-block.ts +332 -0
  17. package/registry/color-picker.ts +720 -0
  18. package/registry/comment-thread.ts +503 -0
  19. package/registry/context-menu.ts +281 -0
  20. package/registry/cover-flow.ts +623 -0
  21. package/registry/date-picker.ts +799 -0
  22. package/registry/decision-inbox.ts +340 -0
  23. package/registry/dialog.ts +577 -0
  24. package/registry/dropdown-menu.ts +864 -0
  25. package/registry/email-draft.ts +916 -0
  26. package/registry/empty-calendar.ts +199 -0
  27. package/registry/empty-state.ts +164 -0
  28. package/registry/enrichment-orbit.ts +164 -0
  29. package/registry/filter-menu.ts +541 -0
  30. package/registry/form-field.ts +308 -0
  31. package/registry/frost-cloud.ts +381 -0
  32. package/registry/ghosted-chat.ts +210 -0
  33. package/registry/glow-cloud.ts +402 -0
  34. package/registry/grid-background.ts +164 -0
  35. package/registry/hover-card.ts +401 -0
  36. package/registry/icon-button.ts +133 -0
  37. package/registry/index.json +2124 -0
  38. package/registry/integration-beam.ts +588 -0
  39. package/registry/integration-grid.ts +209 -0
  40. package/registry/kbd.ts +176 -0
  41. package/registry/layer-stack.ts +351 -0
  42. package/registry/lead-sourcing.ts +285 -0
  43. package/registry/logo-cluster.ts +239 -0
  44. package/registry/logo-marquee.ts +505 -0
  45. package/registry/message-actions.ts +833 -0
  46. package/registry/model-orbit.ts +583 -0
  47. package/registry/model-wheel.ts +372 -0
  48. package/registry/notification-stack.ts +301 -0
  49. package/registry/number-input.ts +552 -0
  50. package/registry/number-ticker.ts +261 -0
  51. package/registry/ochre.css +917 -0
  52. package/registry/otp-input.ts +704 -0
  53. package/registry/overlay.ts +312 -0
  54. package/registry/pagination.ts +362 -0
  55. package/registry/popover.ts +296 -0
  56. package/registry/profile-menu.ts +332 -0
  57. package/registry/progress-tracker.ts +291 -0
  58. package/registry/rating.ts +461 -0
  59. package/registry/reaction-bar.ts +322 -0
  60. package/registry/region-map.ts +537 -0
  61. package/registry/resizable.ts +489 -0
  62. package/registry/scroll-area.ts +271 -0
  63. package/registry/segmented-control.ts +433 -0
  64. package/registry/select.ts +769 -0
  65. package/registry/separator.ts +97 -0
  66. package/registry/shimmer-loader.ts +211 -0
  67. package/registry/side-folder.ts +152 -0
  68. package/registry/skeleton.ts +136 -0
  69. package/registry/skill/INSTRUCTIONS.md +11 -0
  70. package/registry/skill/SKILL.md +65 -0
  71. package/registry/skill/checklist.md +45 -0
  72. package/registry/skill/references/agent-team.md +105 -0
  73. package/registry/skill/references/avatar.md +88 -0
  74. package/registry/skill/references/badge.md +92 -0
  75. package/registry/skill/references/breadcrumb.md +99 -0
  76. package/registry/skill/references/button.md +82 -0
  77. package/registry/skill/references/card.md +111 -0
  78. package/registry/skill/references/catalog.md +114 -0
  79. package/registry/skill/references/change-summary.md +103 -0
  80. package/registry/skill/references/checkbox.md +105 -0
  81. package/registry/skill/references/code-block.md +109 -0
  82. package/registry/skill/references/color-picker.md +138 -0
  83. package/registry/skill/references/comment-thread.md +164 -0
  84. package/registry/skill/references/context-menu.md +205 -0
  85. package/registry/skill/references/cover-flow.md +128 -0
  86. package/registry/skill/references/date-picker.md +154 -0
  87. package/registry/skill/references/decision-inbox.md +126 -0
  88. package/registry/skill/references/dialog.md +155 -0
  89. package/registry/skill/references/dropdown-menu.md +144 -0
  90. package/registry/skill/references/email-draft.md +182 -0
  91. package/registry/skill/references/empty-calendar.md +74 -0
  92. package/registry/skill/references/empty-state.md +118 -0
  93. package/registry/skill/references/enrichment-orbit.md +71 -0
  94. package/registry/skill/references/filter-menu.md +143 -0
  95. package/registry/skill/references/form-field.md +118 -0
  96. package/registry/skill/references/frost-cloud.md +80 -0
  97. package/registry/skill/references/ghosted-chat.md +75 -0
  98. package/registry/skill/references/glow-cloud.md +84 -0
  99. package/registry/skill/references/grid-background.md +76 -0
  100. package/registry/skill/references/hover-card.md +125 -0
  101. package/registry/skill/references/icon-button.md +99 -0
  102. package/registry/skill/references/integration-beam.md +107 -0
  103. package/registry/skill/references/integration-grid.md +100 -0
  104. package/registry/skill/references/kbd.md +65 -0
  105. package/registry/skill/references/layer-stack.md +115 -0
  106. package/registry/skill/references/lead-sourcing.md +92 -0
  107. package/registry/skill/references/logo-cluster.md +92 -0
  108. package/registry/skill/references/logo-marquee.md +123 -0
  109. package/registry/skill/references/message-actions.md +146 -0
  110. package/registry/skill/references/model-orbit.md +106 -0
  111. package/registry/skill/references/model-wheel.md +84 -0
  112. package/registry/skill/references/notification-stack.md +138 -0
  113. package/registry/skill/references/number-input.md +117 -0
  114. package/registry/skill/references/number-ticker.md +73 -0
  115. package/registry/skill/references/otp-input.md +142 -0
  116. package/registry/skill/references/pagination.md +112 -0
  117. package/registry/skill/references/popover.md +143 -0
  118. package/registry/skill/references/profile-menu.md +123 -0
  119. package/registry/skill/references/progress-tracker.md +122 -0
  120. package/registry/skill/references/rating.md +111 -0
  121. package/registry/skill/references/reaction-bar.md +128 -0
  122. package/registry/skill/references/region-map.md +109 -0
  123. package/registry/skill/references/resizable.md +127 -0
  124. package/registry/skill/references/scroll-area.md +113 -0
  125. package/registry/skill/references/segmented-control.md +96 -0
  126. package/registry/skill/references/select.md +122 -0
  127. package/registry/skill/references/separator.md +69 -0
  128. package/registry/skill/references/shimmer-loader.md +83 -0
  129. package/registry/skill/references/side-folder.md +75 -0
  130. package/registry/skill/references/skeleton.md +95 -0
  131. package/registry/skill/references/smart-recommendation.md +132 -0
  132. package/registry/skill/references/spinner.md +84 -0
  133. package/registry/skill/references/switch.md +79 -0
  134. package/registry/skill/references/tab-overload.md +70 -0
  135. package/registry/skill/references/tag-input.md +126 -0
  136. package/registry/skill/references/team-invite.md +94 -0
  137. package/registry/skill/references/testimonial-wall.md +110 -0
  138. package/registry/skill/references/text-area.md +115 -0
  139. package/registry/skill/references/text-field.md +126 -0
  140. package/registry/skill/references/text-reveal.md +71 -0
  141. package/registry/skill/references/thinking-loader.md +87 -0
  142. package/registry/skill/references/time-picker.md +122 -0
  143. package/registry/skill/references/tips-panel.md +115 -0
  144. package/registry/skill/references/toggle-group.md +98 -0
  145. package/registry/skill/references/tool-call-card.md +151 -0
  146. package/registry/skill/references/tooltip.md +94 -0
  147. package/registry/skill/references/tree-view.md +172 -0
  148. package/registry/skill/theming.md +57 -0
  149. package/registry/smart-recommendation.ts +415 -0
  150. package/registry/spinner.ts +67 -0
  151. package/registry/switch.ts +146 -0
  152. package/registry/tab-overload.ts +211 -0
  153. package/registry/tag-input.ts +620 -0
  154. package/registry/team-invite.ts +248 -0
  155. package/registry/testimonial-wall.ts +521 -0
  156. package/registry/text-area.ts +432 -0
  157. package/registry/text-field.ts +415 -0
  158. package/registry/text-reveal.ts +175 -0
  159. package/registry/theme.ts +68 -0
  160. package/registry/thinking-loader.ts +302 -0
  161. package/registry/time-picker.ts +828 -0
  162. package/registry/tips-panel.ts +312 -0
  163. package/registry/toggle-group.ts +357 -0
  164. package/registry/tool-call-card.ts +578 -0
  165. package/registry/tooltip.ts +486 -0
  166. package/registry/tree-view.ts +454 -0
  167. package/styles/base.css +500 -0
  168. package/styles/tokens.css +415 -0
@@ -0,0 +1,372 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Model Wheel, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (the --ui-* tokens), which `npx ochreui init` adds once.
5
+ *
6
+ * <ui-model-wheel /> or <ui-model-wheel [models]="mine" [hold]="2400" label="Models you can switch between" />
7
+ * A slot-machine drum of model names that turns one row every `hold` ms. Drag or flick to spin; hover holds it.
8
+ * A picture, not a picker: it reports nothing.
9
+ *
10
+ * Public styling hooks (set them on the element or any ancestor):
11
+ * --ui-model-wheel-fill the fill behind the middle row (default: a soft grey a step off the page)
12
+ * --ui-model-wheel-radius its corners (default: the large radius)
13
+ */
14
+ import { Component, DOCUMENT, DestroyRef, ElementRef, afterNextRender, afterRenderEffect, computed, inject, input, isDevMode, numberAttribute, signal, untracked } from '@angular/core';
15
+
16
+ /** One row: a name and a filled mark. The mark follows the row's text colour unless it has a `color`. */
17
+ export interface ModelWheelItem {
18
+ name: string;
19
+ /** One SVG path for the mark, drawn in `viewBox`. */
20
+ path: string;
21
+ /** Any CSS colour for the mark; left out, it follows the text. */
22
+ color?: string;
23
+ /** The mark's colour in dark mode. Default: `color`. */
24
+ darkColor?: string;
25
+ /** The mark's SVG viewBox. Default: `'0 0 24 24'`. */
26
+ viewBox?: string;
27
+ }
28
+
29
+ /** Sample names and marks. They are invented placeholders: pass your own `models`. */
30
+ export const MODEL_WHEEL_DEFAULTS: readonly ModelWheelItem[] = [
31
+ {
32
+ name: 'Sorrel',
33
+ path: 'M12 .8l1.3 8.06 6.62-4.78-4.78 6.62 8.06 1.3-8.06 1.3 4.78 6.62-6.62-4.78L12 23.2l-1.3-8.06-6.62 4.78 4.78-6.62L.8 12l8.06-1.3-4.78-6.62 6.62 4.78Z',
34
+ color: 'color-mix(in srgb, color-mix(in srgb, var(--ui-hue-orange) 70%, var(--ui-hue-red)) 80%, var(--ui-gray-1000))',
35
+ darkColor: 'color-mix(in srgb, var(--ui-hue-orange) 80%, var(--ui-hue-red))',
36
+ },
37
+ { name: 'Kestrel', path: 'M2.5 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0-13 0ZM5 9.5a4 4 0 1 1 8 0a4 4 0 1 1-8 0ZM8.5 14.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0-13 0ZM11 14.5a4 4 0 1 1 8 0a4 4 0 1 1-8 0Z' },
38
+ {
39
+ name: 'Willow',
40
+ path: 'M12 1C12 7 17 12 23 12C17 12 12 17 12 23C12 17 7 12 1 12C7 12 12 7 12 1Z',
41
+ color: 'color-mix(in srgb, var(--ui-hue-purple) 80%, var(--ui-hue-blue))',
42
+ darkColor: 'color-mix(in srgb, color-mix(in srgb, var(--ui-hue-purple) 80%, var(--ui-hue-blue)) 90%, var(--ui-gray-0))',
43
+ },
44
+ {
45
+ name: 'Lanternfly',
46
+ path: 'M6 2h12a1.5 1.5 0 0 1 1.5 1.5V22L12 17l-7.5 5V3.5A1.5 1.5 0 0 1 6 2Z',
47
+ color: 'color-mix(in srgb, var(--ui-hue-teal) 75%, var(--ui-gray-1000))',
48
+ darkColor: 'color-mix(in srgb, var(--ui-hue-teal) 92%, var(--ui-gray-1000))',
49
+ },
50
+ {
51
+ name: 'Bluebell',
52
+ path: 'M1.5 12C5.5 5.5 13.5 4.5 18 10l4.5-4.5v13L18 14c-4.5 5.5-12.5 4.5-16.5-2ZM7 10.2a1.3 1.3 0 1 0 0 .01Z',
53
+ color: 'color-mix(in srgb, var(--ui-hue-blue) 90%, var(--ui-gray-1000))',
54
+ darkColor: 'var(--ui-hue-blue)',
55
+ },
56
+ {
57
+ name: 'Saffron',
58
+ path: 'M1.5 21V15h4v-4h4V5h5v6h4v4h4v6h-6.5v-4.5h-8V21Z',
59
+ color: 'color-mix(in srgb, var(--ui-hue-orange) 77%, var(--ui-gray-1000))',
60
+ darkColor: 'color-mix(in srgb, var(--ui-hue-amber) 60%, var(--ui-hue-orange))',
61
+ },
62
+ {
63
+ name: 'Fern',
64
+ path: 'M12 2.5c.6 0 1.1.3 1.4.8l8.3 14.9c.6 1.1-.2 2.3-1.4 2.3H3.7c-1.2 0-2-1.2-1.4-2.3l8.3-14.9c.3-.5.8-.8 1.4-.8ZM12 9.5l-4.2 7.5h8.4Z',
65
+ color: 'color-mix(in srgb, color-mix(in srgb, var(--ui-hue-purple) 55%, var(--ui-hue-pink)) 90%, var(--ui-gray-1000))',
66
+ darkColor: 'color-mix(in srgb, color-mix(in srgb, var(--ui-hue-pink) 55%, var(--ui-hue-purple)) 90%, var(--ui-gray-0))',
67
+ },
68
+ {
69
+ name: 'Cedar',
70
+ path: 'M1 12a5.8 5.8 0 1 0 11.6 0a5.8 5.8 0 1 0-11.6 0ZM3.9 12a2.9 2.9 0 1 1 5.8 0a2.9 2.9 0 1 1-5.8 0ZM11.4 12a5.8 5.8 0 1 0 11.6 0a5.8 5.8 0 1 0-11.6 0ZM14.3 12a2.9 2.9 0 1 1 5.8 0a2.9 2.9 0 1 1-5.8 0Z',
71
+ color: 'var(--ui-indigo-light)',
72
+ darkColor: 'var(--ui-indigo-dark)',
73
+ },
74
+ ];
75
+
76
+ const ROW = 44;
77
+ const STEP = 20;
78
+ const RADIUS = ROW / 2 / Math.tan(Math.PI / 18);
79
+ const DETENT = 0.43;
80
+ const TAU = Math.PI * 2;
81
+
82
+ type Mode = 'hold' | 'turn' | 'drag' | 'snap';
83
+
84
+ function pose(d: number, n: number): { t: string; o: string } {
85
+ const deg = STEP * d;
86
+ const a = Math.abs(deg);
87
+ const rad = (deg * Math.PI) / 180;
88
+ const fade = Math.min(Math.max((Math.min(n * 10, 90) - a) / 10, 0), 1);
89
+ const o = a >= 90 ? 0 : Math.cos(rad) ** 1.6 * fade;
90
+ const y = RADIUS * Math.sin(rad);
91
+ const z = RADIUS * (Math.cos(rad) - 1);
92
+ return { t: `translate3d(0, ${y.toFixed(2)}px, ${z.toFixed(2)}px) rotateX(${(-deg).toFixed(3)}deg)`, o: o.toFixed(3) };
93
+ }
94
+
95
+ const wrap = (d: number, n: number) => ((((d + n / 2) % n) + n) % n) - n / 2;
96
+ const detent = (l: number) => l - (DETENT * Math.sin(TAU * l)) / TAU;
97
+
98
+ @Component({
99
+ selector: 'ui-model-wheel',
100
+ host: {
101
+ '[attr.role]': "label() ? 'img' : null",
102
+ '[attr.aria-label]': 'label() || null',
103
+ '[attr.aria-hidden]': "label() ? null : 'true'",
104
+ },
105
+ template: `
106
+ <div class="fill" aria-hidden="true"></div>
107
+ <div class="drum" aria-hidden="true">
108
+ @for (m of models(); track $index) {
109
+ <div class="row" [attr.data-active]="active() === $index ? '' : null" [style.transform]="rest()[$index].t" [style.opacity]="rest()[$index].o">
110
+ <span><svg [attr.viewBox]="m.viewBox ?? '0 0 24 24'" width="18" height="18" aria-hidden="true" focusable="false"><path [attr.d]="m.path" [style.--c]="m.color ?? null" [style.--cd]="m.darkColor ?? null" /></svg>{{ m.name }}</span>
111
+ </div>
112
+ }
113
+ </div>
114
+ `,
115
+ styles: `
116
+ @layer ui {
117
+ :host { position: relative; display: grid; inline-size: min(360px, 100%); block-size: 308px; }
118
+ }
119
+ :host {
120
+ box-sizing: border-box;
121
+ cursor: grab;
122
+ touch-action: none;
123
+ user-select: none;
124
+ -webkit-user-select: none;
125
+ color: var(--ui-text-muted);
126
+ font: calc(var(--ui-weight-medium) - 50) var(--ui-text-lg) / 1.16 var(--ui-font-sans);
127
+ letter-spacing: -0.01em;
128
+ }
129
+ :host([data-grab]) { cursor: grabbing; }
130
+ :host::before { content: 'x x x x x x x x' / ''; display: block; block-size: 0; overflow: hidden; font-size: 0; letter-spacing: 0; word-spacing: calc(360px / 7); }
131
+ .fill {
132
+ position: absolute;
133
+ place-self: center;
134
+ box-sizing: border-box;
135
+ block-size: 38px;
136
+ border-radius: var(--ui-model-wheel-radius, var(--ui-radius-lg));
137
+ background: var(--ui-model-wheel-fill, light-dark(var(--ui-bg-muted), color-mix(in srgb, var(--ui-bg-muted) 62%, var(--ui-bg-canvas))));
138
+ }
139
+ :host([data-m]) .fill { transition: inline-size calc(420ms * var(--ui-motion-scale)) var(--ui-ease-out); }
140
+ .drum { position: absolute; inset: 0; perspective: 560px; }
141
+ .row {
142
+ position: absolute;
143
+ inset-inline: 0;
144
+ inset-block-start: calc(50% - 22px);
145
+ box-sizing: border-box;
146
+ display: flex;
147
+ align-items: center;
148
+ justify-content: center;
149
+ block-size: 44px;
150
+ backface-visibility: hidden;
151
+ }
152
+ span { display: flex; align-items: center; gap: var(--ui-space-2-5); white-space: nowrap; }
153
+ svg { display: block; flex: none; }
154
+ path { fill: light-dark(var(--c, currentColor), var(--cd, var(--c, currentColor))); }
155
+ [data-active] { color: var(--ui-text); font-weight: var(--ui-weight-medium); }
156
+ @media (forced-colors: active) {
157
+ .fill { border: 1px solid CanvasText; }
158
+ }
159
+ `,
160
+ })
161
+ export class UiModelWheel {
162
+ /** The rows, from the top: a name and a one-path mark each. Use at least seven so the drum stays full. */
163
+ readonly models = input<readonly ModelWheelItem[]>(MODEL_WHEEL_DEFAULTS);
164
+ /** Milliseconds a model rests in the middle before the next one turns in. */
165
+ readonly hold = input(1500, { transform: numberAttribute });
166
+ /** What screen readers hear for the whole picture. An empty string hides it as decoration. */
167
+ readonly label = input('Model names rolling past on a drum, each one landing in the middle');
168
+
169
+ protected readonly active = signal(0);
170
+ protected readonly rest = computed(() => {
171
+ const n = this.models().length;
172
+ return this.models().map((_, i) => pose(wrap(i, n), n));
173
+ });
174
+
175
+ private readonly doc = inject(DOCUMENT);
176
+ private readonly win = this.doc.defaultView;
177
+ private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
178
+ private readonly motion = this.win?.matchMedia?.('(prefers-reduced-motion: reduce)');
179
+ private rows: HTMLElement[] = [];
180
+ private pos = 0;
181
+ private vel = 0;
182
+ private target = 0;
183
+ private mode: Mode = 'hold';
184
+ private seen = true;
185
+ private shown = true;
186
+ private live = false;
187
+ private hovered = false;
188
+ private raf = 0;
189
+ private last = 0;
190
+ private timer?: ReturnType<typeof setTimeout>;
191
+ private grab = { id: -1, y: 0, l: 0 };
192
+ private trail: { t: number; p: number }[] = [];
193
+
194
+ constructor() {
195
+ afterRenderEffect(() => {
196
+ this.models();
197
+ untracked(() => {
198
+ this.rows = [...this.host.querySelectorAll<HTMLElement>('.row')];
199
+ this.pos = this.vel = 0;
200
+ if (this.live) this.settle();
201
+ });
202
+ });
203
+
204
+ afterRenderEffect(() => {
205
+ this.active();
206
+ this.measure();
207
+ });
208
+
209
+ let io: IntersectionObserver | undefined;
210
+ const onVisibility = () => this.wake(this.seen, this.doc.visibilityState !== 'hidden');
211
+ const onMotion = () => this.wait();
212
+ const on = (type: string, fn: (e: PointerEvent) => void) => this.host.addEventListener(type, fn as EventListener);
213
+ afterNextRender(() => {
214
+ this.live = true;
215
+ this.shown = this.doc.visibilityState !== 'hidden';
216
+ this.doc.addEventListener('visibilitychange', onVisibility);
217
+ this.motion?.addEventListener?.('change', onMotion);
218
+ if (this.win?.IntersectionObserver) {
219
+ io = new this.win.IntersectionObserver((entries) => this.wake(entries[entries.length - 1].isIntersecting, this.shown));
220
+ io.observe(this.host);
221
+ }
222
+ on('pointerdown', (e) => this.down(e));
223
+ on('pointermove', (e) => this.move(e));
224
+ on('pointerup', (e) => this.up(e));
225
+ on('pointercancel', (e) => this.up(e));
226
+ on('lostpointercapture', (e) => this.up(e));
227
+ on('pointerenter', (e) => e.pointerType === 'mouse' && this.hover(true));
228
+ on('pointerleave', (e) => e.pointerType === 'mouse' && this.hover(false));
229
+ this.doc.fonts?.ready.then(() => this.measure());
230
+ this.settle();
231
+ const n = this.models().length;
232
+ if (isDevMode() && n > 0 && n < 7) {
233
+ console.warn(`ui-model-wheel: ${n} models leave gaps in the drum. Pass at least seven.`, this.host);
234
+ }
235
+ });
236
+
237
+ inject(DestroyRef).onDestroy(() => {
238
+ this.stop();
239
+ io?.disconnect();
240
+ this.doc.removeEventListener('visibilitychange', onVisibility);
241
+ this.motion?.removeEventListener?.('change', onMotion);
242
+ });
243
+ }
244
+
245
+ private get awake(): boolean {
246
+ return this.live && this.seen && this.shown;
247
+ }
248
+
249
+ private still(): boolean {
250
+ return !!this.motion?.matches || parseFloat(this.win?.getComputedStyle(this.host).getPropertyValue('--ui-motion-scale') ?? '') === 0;
251
+ }
252
+
253
+ private wake(seen: boolean, shown: boolean): void {
254
+ const was = this.awake;
255
+ this.seen = seen;
256
+ this.shown = shown;
257
+ if (this.awake === was || this.mode === 'drag') return;
258
+ if (this.awake) this.settle();
259
+ else this.stop();
260
+ }
261
+
262
+ private stop(): void {
263
+ clearTimeout(this.timer);
264
+ if (this.raf) this.win?.cancelAnimationFrame?.(this.raf);
265
+ this.raf = 0;
266
+ }
267
+
268
+ /** Lands on the nearest row and starts a fresh hold. */
269
+ private settle(): void {
270
+ this.stop();
271
+ const n = this.models().length;
272
+ this.pos = n ? Math.round(this.pos) % n : 0;
273
+ this.vel = 0;
274
+ this.mode = 'hold';
275
+ this.paint();
276
+ this.wait();
277
+ }
278
+
279
+ private wait(): void {
280
+ clearTimeout(this.timer);
281
+ if (!this.awake || this.hovered || this.mode !== 'hold' || this.models().length < 2 || this.motion?.matches) return;
282
+ this.timer = setTimeout(() => {
283
+ if (this.still()) return this.wait();
284
+ this.mode = 'turn';
285
+ this.target = Math.round(this.pos) + 1;
286
+ this.vel = 0;
287
+ this.tick();
288
+ }, this.hold());
289
+ }
290
+
291
+ private tick(): void {
292
+ if (this.raf || !this.awake || !this.win) return;
293
+ this.last = 0;
294
+ this.raf = this.win.requestAnimationFrame(this.frame);
295
+ }
296
+
297
+ private readonly frame = (now: number): void => {
298
+ this.raf = 0;
299
+ const dt = this.last ? Math.min((now - this.last) / 1000, 0.05) : 1 / 60;
300
+ this.last = now;
301
+ const [w, z] = this.mode === 'turn' ? [8, 0.69] : [13, 0.7];
302
+ for (let t = 0; t < dt; t += 0.004) {
303
+ const h = Math.min(0.004, dt - t);
304
+ this.vel += (-w * w * (this.pos - this.target) - 2 * z * w * this.vel) * h;
305
+ this.pos += this.vel * h;
306
+ }
307
+ if (Math.abs(this.pos - this.target) < 0.001 && Math.abs(this.vel) < 0.01) return this.settle();
308
+ this.paint();
309
+ this.raf = this.win!.requestAnimationFrame(this.frame);
310
+ };
311
+
312
+ private paint(): void {
313
+ const n = this.rows.length;
314
+ for (let i = 0; i < n; i++) {
315
+ const p = pose(wrap(i + this.pos, n), n);
316
+ this.rows[i].style.transform = p.t;
317
+ this.rows[i].style.opacity = p.o;
318
+ }
319
+ if (n) this.active.set(((Math.round(-this.pos) % n) + n) % n);
320
+ }
321
+
322
+ private measure(): void {
323
+ const span = this.rows[this.active()]?.firstElementChild as HTMLElement | null;
324
+ const fill = this.host.firstElementChild as HTMLElement | null;
325
+ if (!span || !fill) return;
326
+ fill.style.inlineSize = `${span.offsetWidth + 28}px`;
327
+ if (span.offsetWidth) this.host.toggleAttribute('data-m', true);
328
+ }
329
+
330
+ private hover(on: boolean): void {
331
+ this.hovered = on;
332
+ if (on) clearTimeout(this.timer);
333
+ else this.wait();
334
+ }
335
+
336
+ private down(e: PointerEvent): void {
337
+ if (this.mode === 'drag' || (e.pointerType === 'mouse' && e.button !== 0) || !this.rows.length) return;
338
+ this.stop();
339
+ try {
340
+ this.host.setPointerCapture(e.pointerId);
341
+ } catch {}
342
+ this.host.toggleAttribute('data-grab', true);
343
+ let l = this.pos;
344
+ for (let i = 0; i < 6; i++) l -= (detent(l) - this.pos) / (1 - DETENT * Math.cos(TAU * l));
345
+ this.grab = { id: e.pointerId, y: e.clientY, l };
346
+ this.trail = [{ t: e.timeStamp, p: this.pos }];
347
+ this.mode = 'drag';
348
+ }
349
+
350
+ private move(e: PointerEvent): void {
351
+ if (this.mode !== 'drag' || e.pointerId !== this.grab.id) return;
352
+ this.pos = detent(this.grab.l + (e.clientY - this.grab.y) / ROW);
353
+ this.trail.push({ t: e.timeStamp, p: this.pos });
354
+ const end = e.timeStamp - 100;
355
+ while (this.trail.length > 2 && this.trail[1].t <= end) this.trail.shift();
356
+ this.paint();
357
+ }
358
+
359
+ private up(e: PointerEvent): void {
360
+ if (this.mode !== 'drag' || e.pointerId !== this.grab.id) return;
361
+ this.host.removeAttribute('data-grab');
362
+ if (this.host.hasPointerCapture?.(e.pointerId)) this.host.releasePointerCapture(e.pointerId);
363
+ const a = this.trail[0];
364
+ const b = this.trail[this.trail.length - 1];
365
+ const v = b.t > a.t ? ((b.p - a.p) * 1000) / (b.t - a.t) : 0;
366
+ if (this.still() || !this.awake) return this.settle();
367
+ this.mode = 'snap';
368
+ this.target = Math.round(this.pos + v * 0.14);
369
+ this.vel = v;
370
+ this.tick();
371
+ }
372
+ }
@@ -0,0 +1,301 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Notification Stack, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (tokens and .ui-btn-icon / .ui-sr), added once by `npx ochreui init`.
5
+ *
6
+ * <ui-notification-stack [(notices)]="notices" (dismissed)="markRead($event)" (action)="open($event)" />
7
+ * A small deck of notice cards; only the front one is readable, the next two peek out below it.
8
+ * Dismissing writes the list back without it. Nothing times out: place the stack where it should live.
9
+ *
10
+ * Public styling hooks (set them on the element or any ancestor):
11
+ * --ui-notification-stack-width widest the stack gets (default 380px; it shrinks to its container)
12
+ * --ui-notification-stack-radius card corners (default 10px; Classic 20px)
13
+ * --ui-notification-stack-peek how far each back card shows below the one in front (default 12px)
14
+ * --ui-notification-stack-scale how much narrower each back card is (default 0.05)
15
+ */
16
+ import {
17
+ Component,
18
+ DOCUMENT,
19
+ DestroyRef,
20
+ ElementRef,
21
+ afterNextRender,
22
+ afterRenderEffect,
23
+ computed,
24
+ effect,
25
+ inject,
26
+ Injector,
27
+ input,
28
+ isDevMode,
29
+ model,
30
+ output,
31
+ signal,
32
+ } from '@angular/core';
33
+
34
+ export type NoticePattern = 'rings' | 'grid' | 'rays' | 'none';
35
+
36
+ export interface UiNoticeAction {
37
+ label: string;
38
+ /** Renders a link; without it the action is a button that emits `(action)`. */
39
+ href?: string;
40
+ /** Opens the link in a new tab, with an arrow after the label. */
41
+ external?: boolean;
42
+ }
43
+
44
+ export interface UiNotice {
45
+ /** Unique within the stack. */
46
+ id: string;
47
+ badge?: string;
48
+ title: string;
49
+ text?: string;
50
+ action?: UiNoticeAction;
51
+ pattern?: NoticePattern;
52
+ }
53
+
54
+ export interface NotificationStackLabels {
55
+ /** The region's name, with the number of notices. */
56
+ region: (count: number) => string;
57
+ /** The × button's name. */
58
+ dismiss: (title: string) => string;
59
+ /** Read after an external link's label. */
60
+ newTab: string;
61
+ /** Announced when the last notice is dismissed. */
62
+ empty: string;
63
+ }
64
+
65
+ const LABELS: NotificationStackLabels = {
66
+ region: (n) => `Notifications, ${n}`,
67
+ dismiss: (title) => `Dismiss ${title}`,
68
+ newTab: '(opens in a new tab)',
69
+ empty: 'No more notifications',
70
+ };
71
+
72
+ const VISIBLE = 3;
73
+
74
+ let nextId = 0;
75
+
76
+ @Component({
77
+ selector: 'ui-notification-stack',
78
+ host: {
79
+ class: 'ui-notification-stack',
80
+ tabindex: '-1',
81
+ style: 'display: block; inline-size: min(var(--ui-notification-stack-width, 380px), 100%); outline: none; color: var(--ui-text); font: var(--ui-text-base) / var(--ui-leading-base) var(--ui-font-sans)',
82
+ '[attr.data-empty]': 'count() ? null : ""',
83
+ '[attr.data-ready]': 'ready() || null',
84
+ },
85
+ template: `
86
+ <section class="deck" [attr.aria-label]="l().region(count())" [style.--_n]="peeks()" [style.--_fh]="frontH() + 'px'"
87
+ style="position: relative; block-size: calc(var(--_fh) + var(--_p) * var(--_n)); container-type: inline-size">
88
+ @for (c of cards(); track c.n.id) {
89
+ <article [attr.aria-labelledby]="uid + c.n.id" [attr.data-depth]="c.d" [attr.data-leaving]="c.out || null"
90
+ [attr.aria-hidden]="c.d || c.out ? 'true' : null" [attr.inert]="c.d || c.out ? '' : null" [style.--_d]="c.d"
91
+ style="position: absolute; inset: 0 0 auto; z-index: var(--_z); box-sizing: border-box; overflow: hidden; border: calc(1px * var(--_t)) solid var(--ui-border); border-radius: var(--ui-notification-stack-radius, calc(var(--ui-radius-md) + 2px + 10px * var(--_t))); background: var(--ui-bg-surface); box-shadow: 0 0 0 calc(.5px * var(--_f)) color-mix(in srgb, var(--ui-bg-muted) 88%, var(--ui-bg-surface)), 0 calc(1px * var(--_f)) calc(1px * var(--_f)) calc(-1px * var(--_f)) var(--_s), 0 1px 2px var(--_s), 0 calc(8px * var(--_t)) calc(24px * var(--_t)) var(--_s); opacity: var(--_o); transform: var(--_tf); transform-origin: 50% 100%; transition: transform var(--_tt) var(--ui-ease-out), opacity calc(240ms * var(--_ms)) ease">
92
+ @if (c.n.pattern && c.n.pattern !== 'none') {
93
+ <svg class="pattern" viewBox="0 0 220 160" aria-hidden="true"
94
+ style="position: absolute; inset-block-start: 0; inset-inline-end: 0; inline-size: 220px; block-size: 160px; fill: none; stroke: color-mix(in srgb, var(--ui-border) 80%, transparent); mask: radial-gradient(farthest-corner at 100% 0, black 15%, transparent 75%); --_dot: color-mix(in srgb, color-mix(in srgb, var(--ui-hue-blue) 54%, transparent) calc(100% * var(--_f)), var(--ui-border-strong))">
95
+ @switch (c.n.pattern) {
96
+ @case ('rings') {
97
+ <circle cx="192" cy="18" r="38" /><circle cx="192" cy="18" r="80" /><circle cx="192" cy="18" r="118" />
98
+ <path d="M88 58H220M150 0V112M220-12 96 112" /><circle cx="150" cy="58" r="4" style="fill: var(--_dot); stroke: none" />
99
+ }
100
+ @case ('grid') {
101
+ <rect x="114" y="44" width="30" height="30" style="fill: color-mix(in srgb, var(--_dot) 10%, transparent); stroke: none" />
102
+ <path d="M24 0V160M54 0V160M84 0V160M114 0V160M144 0V160M174 0V160M204 0V160M0 14H220M0 44H220M0 74H220M0 104H220M0 134H220" />
103
+ <circle cx="144" cy="44" r="4" style="fill: var(--_dot); stroke: none" />
104
+ }
105
+ @case ('rays') {
106
+ <path d="M214 6 193 245M214 6 132 232M214 6 76 203M214 6 30 160M214 6-4 107M214 6-22 48M214 6-25-15" />
107
+ <circle cx="214" cy="6" r="128" /><circle cx="143.5" cy="65" r="4" style="fill: var(--_dot); stroke: none" />
108
+ }
109
+ }
110
+ </svg>
111
+ }
112
+ <div class="body" style="position: relative; padding-block: calc(var(--ui-space-3) + 6px * var(--_t) - var(--_k)) calc(var(--ui-space-4) + 4px * var(--_t) - var(--_k)); padding-inline: calc(var(--ui-space-4) + 4px * var(--_t) - var(--_k)) calc(var(--ui-space-3) + 8px * var(--_t) - var(--_k))">
113
+ <div [style.margin-block-end]="c.n.badge ? 'calc(var(--ui-space-2) + 6px * var(--_t))' : 'calc(1px * var(--_t) - 26px)'"
114
+ style="display: flex; align-items: center; gap: var(--ui-space-2); min-block-size: calc(28px - 2px * var(--_t))">
115
+ @if (c.n.badge) {
116
+ <span class="badge" dir="auto" style="overflow: hidden; padding: 2px calc(6px + 3px * var(--_t)); border-radius: calc(5px + 20px * var(--_t)); background: color-mix(in srgb, var(--ui-bg-muted) calc(75% * var(--_f)), transparent); box-shadow: inset 0 0 0 calc(1px * var(--_t)) var(--ui-border); color: color-mix(in srgb, var(--ui-text) calc(25% * var(--_t)), var(--ui-text-muted)); font: var(--ui-weight-medium) calc(var(--ui-text-xs) - 1px * var(--_f)) / calc(var(--ui-leading-xs) + 2px * var(--_t)) var(--ui-font-sans); letter-spacing: calc(.05em + .01em * var(--_t)); text-transform: uppercase; text-overflow: ellipsis; white-space: nowrap">{{ c.n.badge }}</span>
117
+ }
118
+ <button type="button" class="ui-btn-icon x" [attr.aria-label]="l().dismiss(c.n.title)" (click)="dismiss(c.n, $event)"
119
+ style="--_s: var(--_xs); position: relative; margin-block: calc(var(--_xm, 0px) - 2px * var(--_t)) var(--_xm, 0px); margin-inline: auto calc(var(--_xm, 0px) - 6px * var(--_t)); border-radius: calc(var(--ui-radius-sm) + 2px * var(--_t)); transition-duration: calc(140ms * var(--_ms))">
120
+ <svg class="ui-icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" /></svg>
121
+ </button>
122
+ </div>
123
+ <h3 [id]="uid + c.n.id" dir="auto" [style.padding-inline-end]="c.n.badge ? null : '36px'"
124
+ style="margin: 0; padding-inline-end: calc(4px * var(--_f)); font: var(--ui-weight-medium) calc(var(--ui-text-md) + 1px + 1px * var(--_t)) / calc(var(--ui-leading-lg) - 2px * var(--_t)) var(--ui-font-sans); letter-spacing: calc(-.01em * var(--_t)); overflow-wrap: anywhere">{{ c.n.title }}</h3>
125
+ @if (c.n.text) {
126
+ <p dir="auto" style="max-inline-size: calc(24em - 2.55em * var(--_t)); margin: calc(2px + 4px * var(--_t)) 0 0; color: color-mix(in srgb, var(--_pt) calc(100% * var(--_t)), var(--ui-text-muted)); font-size: calc(var(--ui-text-base) + 1px * var(--_t)); line-height: calc(var(--ui-leading-base) + 1px * var(--_t)); white-space: pre-line">{{ c.n.text }}</p>
127
+ }
128
+ @if (c.n.action; as a) {
129
+ @if (a.href) {
130
+ <a class="act" [href]="a.href" [attr.target]="a.external ? '_blank' : null" [attr.rel]="a.external ? 'noopener noreferrer' : null"
131
+ [style.padding-inline-end]="a.external ? 'calc(7px + 4px * var(--_t))' : null" dir="auto" (click)="action.emit(c.n)">{{ a.label }}@if (a.external) {<span class="ui-sr"> {{ l().newTab }}</span>
132
+ <svg class="ui-icon" viewBox="0 0 16 16" aria-hidden="true" style="inline-size: calc(16px - 2px * var(--_t)); block-size: calc(16px - 2px * var(--_t)); color: color-mix(in srgb, var(--ui-icon) calc(100% * var(--_f)), currentColor)"><path d="M5 11l6-6M6 5h5v5" /></svg>}</a>
133
+ } @else {
134
+ <button type="button" class="act" dir="auto" (click)="action.emit(c.n)">{{ a.label }}</button>
135
+ }
136
+ }
137
+ </div>
138
+ </article>
139
+ }
140
+ </section>
141
+ <span class="ui-sr" aria-live="polite">{{ said() }}</span>
142
+ `,
143
+ styles: `
144
+ :host::before { content: 'x x x x x x x x' / ''; display: block; block-size: 0; overflow: hidden; font-size: 0; word-spacing: calc(var(--ui-notification-stack-width, 380px) / 7); }
145
+ :host {
146
+ --_t: var(--ui-look-tray, 0);
147
+ --_f: calc(1 - var(--_t));
148
+ --_p: var(--ui-notification-stack-peek, 12px);
149
+ --_ms: var(--ui-motion-scale);
150
+ --_s: color-mix(in srgb, var(--ui-gray-1000) 6%, transparent);
151
+ --_k: 0px;
152
+ --_dir: 1;
153
+ --_xs: 28px;
154
+ --_pt: var(--ui-text-placeholder);
155
+ }
156
+ @media (prefers-contrast: more) { :host { --_pt: var(--ui-text); } }
157
+ :host([data-ready]) .deck { transition: block-size calc(460ms * var(--_ms)) var(--ui-ease-out); }
158
+ article { --_z: calc(10 - var(--_d)); --_o: 1; --_tf: translateY(calc(var(--_d) * var(--_p))) scale(calc(1 - var(--_d) * var(--ui-notification-stack-scale, .05))); --_tt: calc(460ms * var(--_ms)); }
159
+ [data-leaving] { --_z: 7; --_o: 0; --_tf: translateX(calc(40px * var(--_dir))) scale(.98); --_tt: calc(320ms * var(--_ms)); pointer-events: none; }
160
+ :host(:dir(rtl)) { --_dir: -1; }
161
+ :host(:dir(rtl)) .pattern { scale: -1 1; }
162
+ .body, .pattern { transition: opacity calc(260ms * var(--_ms)) ease; }
163
+ :is([data-leaving], [data-depth]:not([data-depth='0'])) :is(.body, .pattern) { opacity: 0; }
164
+ [data-depth]:not([data-depth='0']) { block-size: var(--_fh); }
165
+ @container (max-width: 340px) { .body { --_k: calc(2px * var(--_f)); } }
166
+ @media (hover: hover) { .x:hover { background: color-mix(in srgb, var(--ui-text) calc(4.5% + 2.5% * var(--_t)), transparent); } }
167
+ .x:focus-visible, .act:focus-visible { outline: var(--ui-focus-width) solid var(--ui-focus-ring); outline-offset: var(--ui-focus-offset); }
168
+ .act {
169
+ --_ab: light-dark(var(--ui-bg-surface), var(--ui-bg-subtle));
170
+ --_ad: calc((140ms + 20ms * var(--_t)) * var(--_ms));
171
+ display: inline-flex;
172
+ align-items: center;
173
+ gap: calc(6px + 2px * var(--_t));
174
+ box-sizing: border-box;
175
+ max-inline-size: 100%;
176
+ block-size: calc(28px + 4px * var(--_t));
177
+ margin-block-start: calc(var(--ui-space-3) + 4px * var(--_t));
178
+ padding: 0 calc(9px + 2px * var(--_t));
179
+ border: 1px solid color-mix(in srgb, var(--ui-border) calc(100% * var(--_t)), transparent);
180
+ border-radius: calc(var(--ui-radius-sm) + 3px * var(--_t));
181
+ background: var(--_ab);
182
+ box-shadow: 0 0 0 calc(1px * var(--_f)) color-mix(in srgb, var(--ui-text) 7%, transparent), 0 1px var(--_ab2, 2px) var(--_s);
183
+ color: var(--ui-text);
184
+ font: var(--ui-weight-medium) var(--ui-text-base) / var(--ui-leading-base) var(--ui-font-sans);
185
+ text-decoration: none;
186
+ white-space: nowrap;
187
+ cursor: pointer;
188
+ -webkit-tap-highlight-color: transparent;
189
+ transition: background-color var(--_ad), box-shadow var(--_ad), color var(--_ad), transform calc(160ms * var(--_ms));
190
+ transition-timing-function: var(--ui-ease-out);
191
+ }
192
+ @media (hover: hover) {
193
+ .act:hover {
194
+ background: color-mix(in srgb, var(--ui-text) calc(4% * var(--_t)), var(--_ab));
195
+ --_ab2: calc(2px + 1px * var(--_f));
196
+ color: color-mix(in srgb, var(--ui-text) calc(100% - 8% * var(--_t)), transparent);
197
+ }
198
+ }
199
+ .act:active { transform: scale(calc(.97 + .01 * var(--_t))); }
200
+ @media (pointer: coarse) {
201
+ .x { --_xs: calc(36px - 8px * var(--_t)); --_xm: calc(-4px * var(--_f)); }
202
+ .x::after { content: ''; position: absolute; inset: calc(-4px * var(--_t)); }
203
+ .act { block-size: calc(36px - 4px * var(--_t)); }
204
+ }
205
+ @media (forced-colors: active) {
206
+ article, .badge { outline: 1px solid CanvasText; outline-offset: -1px; }
207
+ .pattern { display: none; }
208
+ }
209
+ `,
210
+ })
211
+ export class UiNotificationStack {
212
+ /** The cards, front first. Bind `[(notices)]` and dismissed notices leave your list after their exit. */
213
+ readonly notices = model<readonly UiNotice[]>([]);
214
+ /** Your own words for the region, the × button, the new-tab hint and the empty announcement. */
215
+ readonly labels = input<Partial<NotificationStackLabels>>({});
216
+
217
+ /** A notice's × was used. Emitted at once; the card is removed from `notices` when its exit ends. */
218
+ readonly dismissed = output<UiNotice>();
219
+ /** A notice's action was clicked or tapped. Links also navigate. It does not dismiss the card. */
220
+ readonly action = output<UiNotice>();
221
+
222
+ protected readonly uid = `ui-notice-${nextId++}-`;
223
+ protected readonly l = computed(() => ({ ...LABELS, ...this.labels() }));
224
+ private readonly leaving = signal<ReadonlySet<string>>(new Set());
225
+ protected readonly cards = computed(() => {
226
+ const out: { n: UiNotice; d: number; out: boolean }[] = [];
227
+ let d = 0;
228
+ for (const n of this.notices()) {
229
+ const gone = this.leaving().has(n.id);
230
+ if (gone) out.push({ n, d: 0, out: true });
231
+ else if (d < VISIBLE) out.push({ n, d: d++, out: false });
232
+ }
233
+ return out;
234
+ });
235
+ protected readonly count = computed(() => this.notices().filter((n) => !this.leaving().has(n.id)).length);
236
+ protected readonly peeks = computed(() => Math.max(0, Math.min(this.count(), VISIBLE) - 1));
237
+ protected readonly frontH = signal(0);
238
+ protected readonly ready = signal(false);
239
+ protected readonly said = signal('');
240
+
241
+ private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
242
+ private readonly injector = inject(Injector);
243
+ private readonly view = inject(DOCUMENT).defaultView;
244
+ private readonly timers = new Set<ReturnType<typeof setTimeout>>();
245
+
246
+ constructor() {
247
+ const resize = this.view?.ResizeObserver ? new this.view.ResizeObserver(() => this.measure()) : null;
248
+ afterRenderEffect(() => {
249
+ this.cards();
250
+ resize?.disconnect();
251
+ const front = this.front();
252
+ if (front) resize?.observe(front);
253
+ this.measure();
254
+ });
255
+ effect(() => {
256
+ if (this.count()) this.said.set('');
257
+ });
258
+ inject(DestroyRef).onDestroy(() => {
259
+ resize?.disconnect();
260
+ this.timers.forEach(clearTimeout);
261
+ });
262
+ if (isDevMode()) {
263
+ effect(() => {
264
+ const ids = this.notices().map((n) => n.id);
265
+ if (new Set(ids).size !== ids.length) console.warn('ui-notification-stack: notice ids must be unique.', ids);
266
+ if (this.notices().some((n) => !n.title?.trim())) console.warn('ui-notification-stack: every notice needs a title; it names the card and its × button.', this.host);
267
+ });
268
+ }
269
+ }
270
+
271
+ protected dismiss(n: UiNotice, event: Event) {
272
+ const card = (event.currentTarget as HTMLElement).closest('article');
273
+ const focused = !!card?.contains(this.host.ownerDocument.activeElement);
274
+ this.leaving.update((s) => new Set(s).add(n.id));
275
+ this.dismissed.emit(n);
276
+ if (focused) {
277
+ afterNextRender(() => (this.front()?.querySelector<HTMLElement>('.x') ?? this.host).focus(), { injector: this.injector });
278
+ }
279
+ const scale = parseFloat(this.view?.getComputedStyle(this.host).getPropertyValue('--ui-motion-scale') ?? '');
280
+ const timer = setTimeout(() => {
281
+ this.timers.delete(timer);
282
+ this.leaving.update((s) => {
283
+ const next = new Set(s);
284
+ next.delete(n.id);
285
+ return next;
286
+ });
287
+ this.notices.update((list) => list.filter((x) => x.id !== n.id));
288
+ if (!this.count()) this.said.set(this.l().empty);
289
+ }, 350 * (isNaN(scale) ? 1 : scale));
290
+ this.timers.add(timer);
291
+ }
292
+
293
+ private front() {
294
+ return this.host.querySelector<HTMLElement>('article[data-depth="0"]:not([data-leaving])');
295
+ }
296
+
297
+ private measure() {
298
+ this.frontH.set(this.front()?.offsetHeight ?? 0);
299
+ if (!this.ready() && this.frontH()) setTimeout(() => this.ready.set(true));
300
+ }
301
+ }