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,583 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Model Orbit, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (the --ui-* tokens), added once by `npx ochreui init`.
5
+ *
6
+ * <ui-model-orbit />
7
+ * <ui-model-orbit [models]="makers" [numbers]="false" [draggable]="false" />
8
+ * A "model gateway": up to twelve model makers on a tilted ring around a hub, wired to it by beams with sparks.
9
+ * Drag sideways (or press ← / → when focused) to turn the ring. 16 : 9, 760px wide at most.
10
+ *
11
+ * Public styling hooks (set them on the element or any ancestor):
12
+ * --ui-model-orbit-beam beams, rings and the hub mark
13
+ * --ui-model-orbit-spark sparks
14
+ * --ui-model-orbit-halo glow around the hub
15
+ * --ui-model-orbit-track the tilted track
16
+ * --ui-model-orbit-tile tile fill
17
+ * --ui-model-orbit-hub hub puck
18
+ */
19
+ import { NgTemplateOutlet } from '@angular/common';
20
+ import {
21
+ Component,
22
+ DOCUMENT,
23
+ DestroyRef,
24
+ Directive,
25
+ ElementRef,
26
+ TemplateRef,
27
+ afterNextRender,
28
+ afterRenderEffect,
29
+ booleanAttribute,
30
+ computed,
31
+ contentChild,
32
+ inject,
33
+ input,
34
+ isDevMode,
35
+ signal,
36
+ untracked,
37
+ viewChildren,
38
+ } from '@angular/core';
39
+
40
+ /** One model maker on the ring. `logo` is an optional image URL, drawn in a 24 × 24 box. */
41
+ export interface ModelOrbitItem {
42
+ name: string;
43
+ logo?: string;
44
+ }
45
+
46
+ export interface ModelOrbitLogoContext {
47
+ $implicit: ModelOrbitItem;
48
+ index: number;
49
+ }
50
+
51
+ /** Draws every tile's logo: put an `<svg viewBox="0 0 24 24">` inside. Context: the model and its index. */
52
+ @Directive({ selector: 'ng-template[uiModelOrbitLogo]' })
53
+ export class UiModelOrbitLogo {
54
+ readonly template = inject<TemplateRef<ModelOrbitLogoContext>>(TemplateRef);
55
+ static ngTemplateContextGuard(_d: UiModelOrbitLogo, ctx: unknown): ctx is ModelOrbitLogoContext {
56
+ return true;
57
+ }
58
+ }
59
+
60
+ /** The eight invented sample makers shown by default. */
61
+ export const MODEL_ORBIT_DEFAULTS: readonly ModelOrbitItem[] = ['Aurelia', 'Cobalt', 'Fennel', 'Harbour', 'Lumen', 'Moonbeam', 'Onyx', 'Pike'].map((name) => ({ name }));
62
+ const LABEL = 'A ring of AI model makers, each wired to a central hub – drag or use the arrow keys to spin it';
63
+ const CX = 480;
64
+ const CY = 242;
65
+ const POOL = 7;
66
+
67
+ type Pose = { x: number; y: number; s: number; k: number; o: number; bo: number; cx: number; cy: number; ex: number; ey: number; d: string };
68
+
69
+ const r2 = (n: number) => Math.round(n * 100) / 100;
70
+
71
+ function pose(i: number, n: number, angle: number): Pose {
72
+ const th = ((90 + (i * 360) / n + angle) * Math.PI) / 180;
73
+ const s = Math.sin(th);
74
+ const x = CX + 432 * Math.cos(th);
75
+ const y = CY + 216 * s;
76
+ const cx = (x + CX) / 2;
77
+ const cy = s <= 0 ? 187.3 + 190.9 * s : 187.3 - 24.9 * s;
78
+ const dx = cx - CX;
79
+ const dy = cy - CY;
80
+ const l = 1 / Math.hypot(dx / 32, dy / 19.84);
81
+ const ex = CX + l * dx;
82
+ const ey = CY + l * dy;
83
+ return { x, y, s, k: 0.86 + 0.24 * s, o: 0.675 + 0.325 * s, bo: 0.65 + 0.35 * s, cx, cy, ex, ey, d: `M${r2(x)} ${r2(y)}Q${r2(cx)} ${r2(cy)} ${r2(ex)} ${r2(ey)}` };
84
+ }
85
+
86
+ type Spark = { beam: number; born: number; life: number } | null;
87
+ type Tip = { key: number; i: number; name: string; x: number; y: number };
88
+
89
+ let nextId = 0;
90
+
91
+ @Component({
92
+ selector: 'ui-model-orbit',
93
+ imports: [NgTemplateOutlet],
94
+ host: {
95
+ '[attr.role]': "label() ? 'img' : null",
96
+ '[attr.aria-label]': 'label() || null',
97
+ '[attr.aria-hidden]': "label() ? null : 'true'",
98
+ '[attr.tabindex]': 'focusable() ? 0 : null',
99
+ '[attr.data-draggable]': "draggable() ? '' : null",
100
+ '(keydown)': 'key($event)',
101
+ },
102
+ template: `
103
+ <div class="q">
104
+ <svg viewBox="0 -26 960 540" aria-hidden="true" focusable="false">
105
+ <defs>
106
+ <radialGradient [attr.id]="gid + 'h'"><stop offset="0" class="hs" /><stop offset="1" class="hs" stop-opacity="0" /></radialGradient>
107
+ @for (m of items(); track $index) {
108
+ <linearGradient #bg [attr.id]="gid + 'b' + $index" gradientUnits="userSpaceOnUse"><stop offset="0" class="bc" stop-opacity=".2" /><stop offset="1" class="bc" stop-opacity=".62" /></linearGradient>
109
+ }
110
+ @for (s of pool; track s) {
111
+ <linearGradient #sg [attr.id]="gid + 's' + s" gradientUnits="userSpaceOnUse"><stop offset="0" class="sc" stop-opacity="0" /><stop offset="1" class="sc" /></linearGradient>
112
+ }
113
+ </defs>
114
+ <ellipse cx="480" cy="242" rx="237.6" ry="118.8" [attr.fill]="'url(#' + gid + 'h)'" />
115
+ <g class="ring" fill="none">
116
+ <ellipse cx="480" cy="242" rx="86.4" ry="43.2" />
117
+ <ellipse cx="480" cy="242" rx="155.5" ry="77.75" />
118
+ </g>
119
+ <path class="track" fill-rule="evenodd" d="M25.6 242a454.4 227.4 0 1 0 908.8 0a454.4 227.4 0 1 0-908.8 0ZM70.6 242a409.4 204.4 0 1 0 818.8 0a409.4 204.4 0 1 0-818.8 0Z" />
120
+ <g transform="translate(480 242) scale(1 .62)">
121
+ <circle class="ring" r="44" fill="none" />
122
+ <circle class="puck" r="32" />
123
+ <g class="mark">
124
+ <rect x="-9.5" y="-2.5" width="5" height="5" rx="1.2" />
125
+ <rect x="-2.5" y="-9.5" width="5" height="5" rx="1.2" />
126
+ <rect x="-2.5" y="-2.5" width="5" height="5" rx="1.2" />
127
+ <rect x="-2.5" y="4.5" width="5" height="5" rx="1.2" />
128
+ <rect x="4.5" y="-2.5" width="5" height="5" rx="1.2" />
129
+ </g>
130
+ </g>
131
+ <g fill="none">
132
+ @for (m of items(); track $index) {
133
+ <g #beam [attr.opacity]="rest()[$index].bo" [attr.stroke]="'url(#' + gid + 'b' + $index + ')'">
134
+ <path [attr.d]="rest()[$index].d" stroke-width="6" opacity=".12" />
135
+ <path [attr.d]="rest()[$index].d" stroke-width="1.4" stroke-linecap="round" />
136
+ </g>
137
+ }
138
+ </g>
139
+ <g fill="none" stroke-width="2" stroke-linecap="round">
140
+ @for (s of pool; track s) {
141
+ <path #spark opacity="0" [attr.stroke]="'url(#' + gid + 's' + s + ')'" />
142
+ }
143
+ </g>
144
+ <g>
145
+ @for (m of items(); track $index; let i = $index) {
146
+ <g #tile [attr.transform]="'translate(' + rest()[i].x + ' ' + rest()[i].y + ') scale(' + rest()[i].k + ')'" [attr.opacity]="rest()[i].o"
147
+ (pointerover)="over($event, i)" (pointerout)="out($event, i)">
148
+ <g class="tb" transform="scale(1 .62)">
149
+ <rect #body class="body" x="-30" y="-30" width="60" height="60" rx="18" />
150
+ <svg x="-13.8" y="-13.8" width="27.6" height="27.6" viewBox="0 0 24 24" overflow="hidden">
151
+ @if (m.logo) {
152
+ <image [attr.href]="m.logo" width="24" height="24" />
153
+ } @else if (logo(); as l) {
154
+ <ng-container [ngTemplateOutlet]="l.template" [ngTemplateOutletContext]="{ $implicit: m, index: i }" />
155
+ } @else {
156
+ <ng-container [ngTemplateOutlet]="glyph" [ngTemplateOutletContext]="{ $implicit: m.name }" />
157
+ }
158
+ </svg>
159
+ </g>
160
+ @if (numbers()) {
161
+ <text class="num" x="40" y="-22">{{ i < 9 ? '0' : '' }}{{ i + 1 }}</text>
162
+ }
163
+ </g>
164
+ }
165
+ </g>
166
+ <ng-template #glyph let-n>
167
+ @switch (n) {
168
+ @case ('Aurelia') {
169
+ <svg viewBox="2 2 20 20" style="fill: var(--ui-text)"><rect x="4" y="5" width="16" height="3.4" rx="1.7" /><rect x="7" y="10.3" width="13" height="3.4" rx="1.7" /><rect x="4" y="15.6" width="16" height="3.4" rx="1.7" /></svg>
170
+ }
171
+ @case ('Cobalt') {
172
+ <svg viewBox="2 2 20 20" style="color: color-mix(in srgb, var(--ui-hue-red) 60%, var(--ui-hue-orange))"><path d="M12 3.2l7.6 4.4v8.8L12 20.8l-7.6-4.4V7.6z" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linejoin="round" /><circle cx="12" cy="12" r="2.6" fill="currentColor" /></svg>
173
+ }
174
+ @case ('Fennel') {
175
+ <svg viewBox="2 2 20 20"><path d="M4.5 19.5C4.5 10.5 9.5 4.5 19.5 4.5c0 10-6 15-15 15z" style="fill: var(--ui-hue-blue)" /><path d="M5.5 18.5l9-9" fill="none" stroke-width="1.6" stroke-linecap="round" style="stroke: var(--_tile)" /></svg>
176
+ }
177
+ @case ('Harbour') {
178
+ <svg viewBox="2 2 20 20"><path d="M6.5 13a5.5 5.5 0 0 1 11 0z" style="fill: var(--ui-hue-amber)" /><path d="M3.5 16.5c2.2-1.6 3.6-1.6 5.6 0s3.6 1.6 5.8 0 3.6-1.6 5.6 0M3.5 20.5c2.2-1.6 3.6-1.6 5.6 0s3.6 1.6 5.8 0 3.6-1.6 5.6 0" fill="none" stroke-width="2" stroke-linecap="round" style="stroke: var(--ui-hue-orange)" /></svg>
179
+ }
180
+ @case ('Lumen') {
181
+ <svg viewBox="2 2 20 20" fill="none" stroke-width="1.8" stroke-linejoin="round" style="stroke: color-mix(in srgb, var(--ui-hue-blue) 70%, var(--ui-hue-cyan))"><path d="M12 4.5c3 3 3 9 0 13-3-4-3-10 0-13z" /><path d="M12 17.5c-4.2 0-7.8-3-8.6-7.6 4 0 7 2.4 8.6 7.6zM12 17.5c4.2 0 7.8-3 8.6-7.6-4 0-7 2.4-8.6 7.6z" /></svg>
182
+ }
183
+ @case ('Moonbeam') {
184
+ <svg viewBox="2 2 20 20" style="fill: color-mix(in srgb, var(--ui-hue-blue), var(--ui-hue-purple))"><path d="M13.6 3.4a8.8 8.8 0 1 0 7 13.4 7.2 7.2 0 0 1-7-13.4z" /><circle cx="18.6" cy="6" r="1.7" /></svg>
185
+ }
186
+ @case ('Onyx') {
187
+ <svg viewBox="2 2 20 20"><path d="M12 4l8.5 15H7l-2.2-2.8z" fill="none" stroke-width="2.2" stroke-linejoin="round" style="stroke: var(--ui-hue-purple)" /></svg>
188
+ }
189
+ @case ('Pike') {
190
+ <svg viewBox="2 2 20 20"><path d="M6 6l6 6-6 6M12.5 6l6 6-6 6" fill="none" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" transform="skewX(-14) translate(2.4 0)" style="stroke: var(--ui-text)" /></svg>
191
+ }
192
+ @default {
193
+ <svg viewBox="2 2 20 20"><circle cx="12" cy="12" r="9.5" style="fill: var(--ui-bg-muted)" /><text x="12" y="16" text-anchor="middle" font-size="11" font-weight="600" style="fill: var(--ui-text)">{{ n.charAt(0) }}</text></svg>
194
+ }
195
+ }
196
+ </ng-template>
197
+ </svg>
198
+ </div>
199
+ @for (t of tips(); track t.key) {
200
+ <span class="tip" aria-hidden="true" dir="auto" [style.left.px]="t.x" [style.top.px]="t.y">{{ t.name }}</span>
201
+ }
202
+ `,
203
+ styles: `
204
+ @layer ui {
205
+ :host { display: block; position: relative; inline-size: min(760px, 100%); aspect-ratio: 16 / 9; }
206
+ }
207
+ :host {
208
+ --_b: var(--ui-model-orbit-beam, var(--ui-blue-light));
209
+ --_s: var(--ui-model-orbit-spark, light-dark(var(--ui-blue-light), color-mix(in srgb, var(--ui-blue-light) 55%, var(--ui-blue-dark))));
210
+ --_h: var(--ui-model-orbit-halo, light-dark(color-mix(in srgb, var(--ui-blue-light) 15%, transparent), color-mix(in srgb, var(--ui-blue-light) 20%, transparent)));
211
+ --_tile: var(--ui-model-orbit-tile, light-dark(var(--ui-bg-surface), color-mix(in srgb, var(--ui-text) 8%, var(--ui-bg-canvas))));
212
+ --_z: 1;
213
+ box-sizing: border-box;
214
+ border-radius: 12px;
215
+ font-family: var(--ui-font-sans);
216
+ user-select: none;
217
+ -webkit-user-select: none;
218
+ -webkit-tap-highlight-color: transparent;
219
+ }
220
+ :host([data-draggable]) { cursor: grab; touch-action: pan-y; }
221
+ :host([data-drag]) { cursor: grabbing; }
222
+ :host(:focus) { outline: 0; }
223
+ :host(:focus-visible) { outline: var(--ui-focus-width) solid var(--ui-focus-ring); outline-offset: var(--ui-focus-offset); }
224
+ :host::before { content: 'x x x x x x x x' / ''; display: block; block-size: 0; overflow: hidden; font-size: 0; word-spacing: calc(760px / 7); }
225
+ .q { position: absolute; inset: 0; container-type: inline-size; }
226
+ .q > svg { position: absolute; inset: 0; display: block; inline-size: 100%; block-size: 100%; overflow: visible; direction: ltr; forced-color-adjust: none; }
227
+ .hs { stop-color: var(--_h); }
228
+ .bc { stop-color: var(--_b); }
229
+ .sc { stop-color: var(--_s); }
230
+ .ring { stroke: color-mix(in srgb, var(--_b) 30%, transparent); }
231
+ .track { fill: var(--ui-model-orbit-track, light-dark(color-mix(in srgb, var(--ui-text) 4%, transparent), color-mix(in srgb, var(--ui-text) 5%, transparent))); }
232
+ .puck {
233
+ fill: var(--ui-model-orbit-hub, light-dark(var(--ui-bg-surface), color-mix(in srgb, var(--ui-gray-1000) 55%, var(--ui-bg-canvas))));
234
+ filter: drop-shadow(0 3px 4px light-dark(color-mix(in srgb, var(--ui-gray-1000) 10%, transparent), color-mix(in srgb, var(--ui-gray-1000) 40%, transparent)));
235
+ }
236
+ .mark { fill: color-mix(in srgb, var(--_b) 88%, var(--ui-text)); }
237
+ .body {
238
+ fill: var(--_tile);
239
+ stroke: light-dark(color-mix(in srgb, var(--ui-text) 9%, transparent), color-mix(in srgb, var(--ui-text) 16%, transparent));
240
+ filter: drop-shadow(0 1px 1px color-mix(in srgb, var(--ui-gray-1000) 6%, transparent)) drop-shadow(0 5px 6px light-dark(color-mix(in srgb, var(--ui-gray-1000) 6%, transparent), color-mix(in srgb, var(--ui-gray-1000) 30%, transparent)));
241
+ }
242
+ .tb { transform: scale(var(--_z), calc(0.62 * var(--_z))); }
243
+ @container (max-width: 599px) { .tb { --_z: 1.15; } }
244
+ @container (max-width: 479px) { .tb { --_z: 1.3; } }
245
+ @container (max-width: 399px) { .tb { --_z: 1.55; } }
246
+ @container (max-width: 319px) { .tb { --_z: 1.75; } }
247
+ .num { fill: var(--ui-text-muted); font-size: 12px; font-weight: 500; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
248
+ .tip {
249
+ position: absolute;
250
+ z-index: 1;
251
+ box-sizing: border-box;
252
+ padding: 3px 8px;
253
+ border-radius: 6px;
254
+ background: var(--ui-bg-neutral-solid);
255
+ color: var(--ui-text-on-neutral);
256
+ font-size: 12px;
257
+ line-height: 16px;
258
+ font-weight: var(--ui-weight-medium);
259
+ white-space: nowrap;
260
+ pointer-events: none;
261
+ transform: translate(-50%, calc(-100% - 8px));
262
+ animation: ui-mo-tip calc(140ms * var(--ui-motion-scale, 1)) ease-out both;
263
+ }
264
+ @keyframes ui-mo-tip { from { opacity: 0; translate: 0 4px; } }
265
+ @media (prefers-reduced-motion: reduce) { .tip { animation: none; } }
266
+ @media (forced-colors: active) { .tip { border: 1px solid CanvasText; background: Canvas; color: CanvasText; } }
267
+ `,
268
+ })
269
+ export class UiModelOrbit {
270
+ /** Model makers around the ring, the first one nearest the viewer. Twelve at most. */
271
+ readonly models = input<readonly ModelOrbitItem[]>(MODEL_ORBIT_DEFAULTS);
272
+ /** Shows the small numbers ("01", "02"…) next to the tiles. */
273
+ readonly numbers = input(true, { transform: booleanAttribute });
274
+ /** Drag sideways, or use ← / → when focused, to turn the ring. Off: not focusable, and the ring stays put. */
275
+ readonly draggable = input(true, { transform: booleanAttribute });
276
+ /** What screen readers announce. Empty makes the illustration decorative (hidden, not focusable). */
277
+ readonly label = input(LABEL);
278
+
279
+ protected readonly logo = contentChild(UiModelOrbitLogo);
280
+ protected readonly items = computed(() => this.models().slice(0, 12));
281
+ protected readonly rest = computed(() => {
282
+ const n = this.items().length;
283
+ return this.items().map((_, i) => {
284
+ const p = pose(i, n, 0);
285
+ return { ...p, x: r2(p.x), y: r2(p.y), k: r2(p.k), o: r2(p.o), bo: r2(p.bo) };
286
+ });
287
+ });
288
+ protected readonly focusable = computed(() => this.draggable() && !!this.label());
289
+ protected readonly pool = Array.from({ length: POOL }, (_, i) => i);
290
+ protected readonly gid = `ui-mo-${nextId++}-`;
291
+ private readonly tip = signal<Tip | null>(null);
292
+ protected readonly tips = computed(() => {
293
+ const t = this.tip();
294
+ return t ? [t] : [];
295
+ });
296
+
297
+ private readonly tiles = viewChildren<ElementRef<SVGGElement>>('tile');
298
+ private readonly bodies = viewChildren<ElementRef<SVGRectElement>>('body');
299
+ private readonly beams = viewChildren<ElementRef<SVGGElement>>('beam');
300
+ private readonly beamGrads = viewChildren<ElementRef<SVGLinearGradientElement>>('bg');
301
+ private readonly sparks = viewChildren<ElementRef<SVGPathElement>>('spark');
302
+ private readonly sparkGrads = viewChildren<ElementRef<SVGLinearGradientElement>>('sg');
303
+
304
+ private readonly doc = inject(DOCUMENT);
305
+ private readonly win = this.doc.defaultView;
306
+ private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
307
+
308
+ private angle = 0;
309
+ private vel = 0;
310
+ private geo: Pose[] = [];
311
+ private order = '';
312
+ private raf = 0;
313
+ private last = -1;
314
+ private ready = false;
315
+ private seen = true;
316
+ private shown = true;
317
+ private still = false;
318
+ private on = false;
319
+ private pool$: Spark[] = Array(POOL).fill(null);
320
+ private nextAt = -1;
321
+ private checkAt = 0;
322
+ private drag = -1;
323
+ private lastX = 0;
324
+ private samples: { t: number; a: number }[] = [];
325
+ private tipKey = 0;
326
+ private readonly hoverMq = this.win?.matchMedia?.('(hover: hover)');
327
+
328
+ constructor() {
329
+ let io: IntersectionObserver | undefined;
330
+ const mq = this.win?.matchMedia?.('(prefers-reduced-motion: reduce)');
331
+ const onMotion = () => {
332
+ this.motion(mq);
333
+ this.sync();
334
+ };
335
+ const onVisibility = () => {
336
+ this.shown = this.doc.visibilityState !== 'hidden';
337
+ onMotion();
338
+ };
339
+ const listen: [string, (e: PointerEvent) => void][] = [
340
+ ['pointerdown', (e) => this.down(e)],
341
+ ['pointermove', (e) => this.move(e)],
342
+ ['pointerup', (e) => this.up(e)],
343
+ ['pointercancel', () => this.cancel()],
344
+ ['lostpointercapture', () => this.cancel()],
345
+ ];
346
+
347
+ afterNextRender(() => {
348
+ if (isDevMode() && this.draggable() && !this.label())
349
+ console.warn('ui-model-orbit: with an empty label it is decorative, so keyboard users cannot turn it. Give it a label or set [draggable]="false".', this.host);
350
+ listen.forEach(([t, f]) => this.host.addEventListener(t, f as EventListener));
351
+ this.doc.addEventListener('visibilitychange', onVisibility);
352
+ mq?.addEventListener?.('change', onMotion);
353
+ const IO = this.win?.IntersectionObserver;
354
+ if (IO) {
355
+ io = new IO((entries) => {
356
+ this.seen = entries[entries.length - 1].isIntersecting;
357
+ onMotion();
358
+ }, { threshold: [0] });
359
+ io.observe(this.host);
360
+ }
361
+ this.ready = true;
362
+ onVisibility();
363
+ });
364
+
365
+ afterRenderEffect(() => {
366
+ this.items();
367
+ untracked(() => {
368
+ this.order = '';
369
+ this.pool$.fill(null);
370
+ this.sparks().forEach((s) => s.nativeElement.setAttribute('opacity', '0'));
371
+ this.render();
372
+ this.sync();
373
+ });
374
+ });
375
+
376
+ inject(DestroyRef).onDestroy(() => {
377
+ if (this.raf) this.win?.cancelAnimationFrame(this.raf);
378
+ io?.disconnect();
379
+ listen.forEach(([t, f]) => this.host.removeEventListener(t, f as EventListener));
380
+ this.doc.removeEventListener('visibilitychange', onVisibility);
381
+ mq?.removeEventListener?.('change', onMotion);
382
+ });
383
+ }
384
+
385
+ protected over(e: PointerEvent, i: number) {
386
+ if (e.pointerType !== 'mouse' || this.drag >= 0 || this.vel || !this.hoverMq?.matches) return;
387
+ if (this.tip()?.i === i) return;
388
+ const b = this.bodies()[i]?.nativeElement.getBoundingClientRect();
389
+ const h = this.host.getBoundingClientRect();
390
+ const m = this.items()[i];
391
+ if (!b || !m) return;
392
+ const k = this.host.offsetWidth / h.width || 1;
393
+ this.tip.set({ key: ++this.tipKey, i, name: m.name, x: (b.left + b.width / 2 - h.left) * k, y: (b.top - h.top) * k });
394
+ }
395
+
396
+ protected out(e: PointerEvent, i: number) {
397
+ const to = e.relatedTarget as Node | null;
398
+ if (to && this.tiles()[i]?.nativeElement.contains(to)) return;
399
+ if (this.tip()?.i === i) this.tip.set(null);
400
+ }
401
+
402
+ protected key(e: KeyboardEvent) {
403
+ if (!this.focusable() || (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight')) return;
404
+ e.preventDefault();
405
+ const half = 180 / Math.max(this.items().length, 1);
406
+ this.vel = 0;
407
+ this.turn(e.key === 'ArrowLeft' ? half : -half);
408
+ }
409
+
410
+ private turn(by: number) {
411
+ this.angle = (this.angle + by) % 360;
412
+ if (this.tip()) this.tip.set(null);
413
+ this.render();
414
+ }
415
+
416
+ private down(e: PointerEvent) {
417
+ if (!this.draggable() || this.drag >= 0 || (e.pointerType === 'mouse' && e.button !== 0)) return;
418
+ this.vel = 0;
419
+ this.drag = e.pointerId;
420
+ this.lastX = e.clientX;
421
+ this.samples = [{ t: e.timeStamp, a: this.angle }];
422
+ try {
423
+ this.host.setPointerCapture(e.pointerId);
424
+ } catch {}
425
+ this.host.setAttribute('data-drag', '');
426
+ if (this.tip()) this.tip.set(null);
427
+ }
428
+
429
+ private move(e: PointerEvent) {
430
+ if (e.pointerId !== this.drag) return;
431
+ const w = this.host.getBoundingClientRect().width || 1;
432
+ const dx = e.clientX - this.lastX;
433
+ this.lastX = e.clientX;
434
+ if (!dx) return;
435
+ this.turn((-180 * dx) / w);
436
+ this.samples.push({ t: e.timeStamp, a: this.angle });
437
+ while (this.samples.length > 2 && e.timeStamp - this.samples[0].t > 100) this.samples.shift();
438
+ }
439
+
440
+ private up(e: PointerEvent) {
441
+ if (e.pointerId !== this.drag) return;
442
+ this.end();
443
+ const s = this.samples;
444
+ const a = s[0];
445
+ const b = s[s.length - 1];
446
+ const dt = b.t - a.t;
447
+ this.vel = !this.still && dt > 0 && e.timeStamp - b.t < 60 ? (b.a - a.a) / dt : 0;
448
+ if (this.vel) this.kick();
449
+ }
450
+
451
+ private cancel() {
452
+ if (this.drag < 0) return;
453
+ this.end();
454
+ this.vel = 0;
455
+ }
456
+
457
+ private end() {
458
+ this.drag = -1;
459
+ this.host.removeAttribute('data-drag');
460
+ }
461
+
462
+ private motion(mq: MediaQueryList | undefined) {
463
+ const v = parseFloat(this.win?.getComputedStyle(this.host).getPropertyValue('--ui-motion-scale') ?? '');
464
+ this.still = !!mq?.matches || v === 0;
465
+ }
466
+
467
+ private sync() {
468
+ const want = this.ready && this.seen && this.shown && !this.still && this.items().length > 0;
469
+ if (!this.seen || !this.shown || this.still) this.vel = 0;
470
+ if (want === this.on) return;
471
+ this.on = want;
472
+ this.pool$.fill(null);
473
+ this.sparks().forEach((s) => s.nativeElement.setAttribute('opacity', '0'));
474
+ this.nextAt = -1;
475
+ if (want) this.kick();
476
+ }
477
+
478
+ private kick() {
479
+ this.last = -1;
480
+ if (!this.raf && this.win) this.raf = this.win.requestAnimationFrame(this.frame);
481
+ }
482
+
483
+ private readonly frame = (now: number) => {
484
+ this.raf = 0;
485
+ const dt = this.last < 0 ? 16.7 : Math.min(now - this.last, 50);
486
+ this.last = now;
487
+ if (this.vel) {
488
+ this.turn(this.vel * dt);
489
+ this.vel *= Math.pow(0.906, dt / 16.7);
490
+ if (Math.abs(this.vel * 16.7) < 0.03) this.vel = 0;
491
+ }
492
+ if (this.on) {
493
+ if (now > this.checkAt) {
494
+ this.checkAt = now + 1000;
495
+ this.motion(this.win?.matchMedia?.('(prefers-reduced-motion: reduce)'));
496
+ if (this.still) this.sync();
497
+ }
498
+ if (this.on) this.step(now);
499
+ }
500
+ if ((this.on || this.vel) && this.win) {
501
+ this.raf = this.win.requestAnimationFrame(this.frame);
502
+ }
503
+ };
504
+
505
+ private step(now: number) {
506
+ const n = this.geo.length;
507
+ if (!n) return;
508
+ const gap = () => Math.pow(Math.random(), 1.5) * 950;
509
+ const spawn = (at: number) => {
510
+ const k = this.pool$.indexOf(null);
511
+ if (k >= 0) this.pool$[k] = { beam: Math.floor(Math.random() * n), born: at, life: 900 + Math.random() * 700 };
512
+ };
513
+ if (this.nextAt < 0) {
514
+ for (let j = 0; j < 3; j++) spawn(now);
515
+ this.nextAt = now + gap();
516
+ }
517
+ while (now >= this.nextAt) {
518
+ spawn(this.nextAt);
519
+ this.nextAt += gap();
520
+ }
521
+ const paths = this.sparks();
522
+ const grads = this.sparkGrads();
523
+ this.pool$.forEach((sp, k) => {
524
+ const el = paths[k]?.nativeElement;
525
+ if (!el) return;
526
+ const f = sp ? (now - sp.born) / sp.life : 1;
527
+ const g = sp && this.geo[sp.beam];
528
+ if (!sp || !g || f >= 1) {
529
+ this.pool$[k] = null;
530
+ el.setAttribute('opacity', '0');
531
+ return;
532
+ }
533
+ const env = f < 0.12 ? f / 0.12 : f > 0.82 ? (1 - f) / 0.18 : 1;
534
+ const b = Math.min(1, Math.max(0, f) / 0.82);
535
+ const a = Math.max(0, b - 0.28);
536
+ const at = (t: number, c: number, e: number, p: number) => (1 - t) * (1 - t) * p + 2 * t * (1 - t) * c + t * t * e;
537
+ const bl = (p: number, c: number, e: number) => (1 - a) * (1 - b) * p + ((1 - a) * b + a * (1 - b)) * c + a * b * e;
538
+ const x1 = at(a, g.cx, g.ex, g.x);
539
+ const y1 = at(a, g.cy, g.ey, g.y);
540
+ const x2 = at(b, g.cx, g.ex, g.x);
541
+ const y2 = at(b, g.cy, g.ey, g.y);
542
+ el.setAttribute('d', `M${r2(x1)} ${r2(y1)}Q${r2(bl(g.x, g.cx, g.ex))} ${r2(bl(g.y, g.cy, g.ey))} ${r2(x2)} ${r2(y2)}`);
543
+ el.setAttribute('opacity', String(r2(env * g.o)));
544
+ const gr = grads[k]?.nativeElement;
545
+ gr?.setAttribute('x1', String(r2(x1)));
546
+ gr?.setAttribute('y1', String(r2(y1)));
547
+ gr?.setAttribute('x2', String(r2(x2 === x1 && y2 === y1 ? x2 + 0.01 : x2)));
548
+ gr?.setAttribute('y2', String(r2(y2)));
549
+ });
550
+ }
551
+
552
+ private render() {
553
+ const n = this.items().length;
554
+ const tiles = this.tiles();
555
+ const beams = this.beams();
556
+ const grads = this.beamGrads();
557
+ if (tiles.length !== n || beams.length !== n) return;
558
+ this.geo = Array.from({ length: n }, (_, i) => pose(i, n, this.angle));
559
+ this.geo.forEach((p, i) => {
560
+ const t = tiles[i].nativeElement;
561
+ t.setAttribute('transform', `translate(${r2(p.x)} ${r2(p.y)}) scale(${r2(p.k)})`);
562
+ t.setAttribute('opacity', String(r2(p.o)));
563
+ const b = beams[i].nativeElement;
564
+ b.setAttribute('opacity', String(r2(p.bo)));
565
+ b.querySelectorAll('path').forEach((el) => el.setAttribute('d', p.d));
566
+ const g = grads[i]?.nativeElement;
567
+ g?.setAttribute('x1', String(r2(p.x)));
568
+ g?.setAttribute('y1', String(r2(p.y)));
569
+ g?.setAttribute('x2', String(r2(p.ex)));
570
+ g?.setAttribute('y2', String(r2(p.ey)));
571
+ });
572
+ const idx = this.geo.map((_, i) => i).sort((a, b) => this.geo[a].s - this.geo[b].s || a - b);
573
+ const key = idx.join();
574
+ if (key === this.order) return;
575
+ this.order = key;
576
+ idx.forEach((i) => {
577
+ const t = tiles[i].nativeElement;
578
+ const b = beams[i].nativeElement;
579
+ t.parentNode?.appendChild(t);
580
+ b.parentNode?.appendChild(b);
581
+ });
582
+ }
583
+ }