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,312 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Tips Panel, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (the --ui-* tokens and .ui-sr), which `npx ochreui init` adds once.
5
+ *
6
+ * <ui-tips-panel title="Get started" closable (closed)="hide()">
7
+ * <ui-tip title="Invite teammates" action="Invite" doneLabel="Invite sent" (taken)="invite()">Reviews and comments in one place.</ui-tip>
8
+ * <ui-tip title="Upgrade" action="See plans" doneLabel="Opened" primary>Unlimited projects and guests.</ui-tip>
9
+ * </ui-tips-panel>
10
+ * A card with a grid of short tips, one action each; taking a tip shows a done line and the header counts them.
11
+ *
12
+ * Public styling hooks (set them on the element or any ancestor):
13
+ * --ui-tips-panel-max-height the most the list grows before it scrolls (default 420px)
14
+ * --ui-tips-panel-radius outer corners (default 10px; Classic a 22px tray)
15
+ * --ui-tips-panel-done the done line (default green; Classic blue)
16
+ * --ui-tips-panel-done-bg the tint of a taken tip (default a faint grey wash)
17
+ */
18
+ import {
19
+ Component,
20
+ DOCUMENT,
21
+ DestroyRef,
22
+ ElementRef,
23
+ Injector,
24
+ afterNextRender,
25
+ booleanAttribute,
26
+ computed,
27
+ contentChildren,
28
+ inject,
29
+ input,
30
+ isDevMode,
31
+ model,
32
+ numberAttribute,
33
+ output,
34
+ signal,
35
+ viewChild,
36
+ } from '@angular/core';
37
+
38
+ export interface TipsPanelLabels {
39
+ /** After the count: "2/9 done". */
40
+ done: string;
41
+ /** What screen readers hear when the count changes. */
42
+ count: (done: number, total: number) => string;
43
+ /** The done line of a tip without its own `doneLabel`. */
44
+ defaultDone: string;
45
+ /** The button in the last row, when `closable`. */
46
+ close: string;
47
+ }
48
+
49
+ const LABELS: TipsPanelLabels = {
50
+ done: 'done',
51
+ count: (n, total) => `${n} of ${total} done`,
52
+ defaultDone: 'Done',
53
+ close: 'Close',
54
+ };
55
+
56
+ const BTN =
57
+ 'box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; block-size: auto; min-block-size: var(--_bh); margin: 0; padding: calc(3px + 1px * var(--_t)) calc(9px + 2px * var(--_t)); border: 1px solid var(--_bc, transparent); border-radius: calc(6px + 3px * var(--_t)); background: var(--_g, none) var(--_b, color-mix(in srgb, var(--_w, var(--_bf)) calc(100% * var(--_t)), var(--_bf))); box-shadow: var(--_sh, 0 0 0 calc(.5px + .5px * var(--_t)) color-mix(in srgb, var(--ui-border) calc(100% * var(--_t)), var(--_rc, var(--_e))), 0 var(--_y) var(--_y) calc(-1 * var(--_y)) var(--_s), 0 1px var(--_bl, 2px) var(--_s)); color: var(--_fg, var(--ui-text)); font: inherit; font-weight: calc(500 - 100 * var(--_t)); text-align: center; overflow-wrap: anywhere; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color var(--_d), box-shadow var(--_d), transform calc(160ms * var(--_ms)) var(--ui-ease-out)';
58
+
59
+ let nextId = 0;
60
+
61
+ /** One tip inside a `<ui-tips-panel>`. Its content is the description, so it may hold a `<kbd>` or a link. */
62
+ @Component({
63
+ selector: 'ui-tip',
64
+ host: {
65
+ role: 'listitem',
66
+ '[attr.title]': 'null',
67
+ '[attr.data-done]': 'done() ? "" : null',
68
+ '[style.--_i]': 'index()',
69
+ },
70
+ template: `
71
+ <p class="t" dir="auto">{{ title() }}</p>
72
+ <p class="d" dir="auto"><ng-content /></p>
73
+ @if (done()) {
74
+ <span #ok class="ok" role="status" tabindex="-1" [class.live]="live()">
75
+ <svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="7.5" /><path d="M5 8.3l2 2 4-4.3" /></svg>
76
+ <span dir="auto">{{ doneText() }}</span>
77
+ </span>
78
+ } @else {
79
+ <button type="button" class="btn" [class.pri]="primary()" dir="auto" style="${BTN}" (click)="take()">{{ action() }}</button>
80
+ }
81
+ `,
82
+ styles: `
83
+ :host {
84
+ --_ok: var(--ui-tips-panel-done, color-mix(in srgb, light-dark(oklch(from var(--ui-hue-blue) calc(l - .06) calc(c - .06) calc(h - 14)), oklch(from var(--ui-hue-blue) calc(l - .02) c calc(h - 14))) calc(100% * var(--_t)), color-mix(in srgb, var(--ui-success) 80%, var(--ui-hue-green))));
85
+ --_te: color-mix(in srgb, color-mix(in srgb, var(--ui-border) 80%, var(--ui-bg-surface)) calc(100% * var(--_t)), var(--_e));
86
+ display: flex;
87
+ flex-direction: column;
88
+ align-items: flex-start;
89
+ min-inline-size: 0;
90
+ box-sizing: border-box;
91
+ padding: calc(12px + 4px * var(--_t)) calc(12px + 4px * var(--_t)) calc(12px + 2px * var(--_t));
92
+ border: calc(1px * var(--_t)) solid var(--_te);
93
+ border-radius: calc(8px + 6px * var(--_t));
94
+ background: var(--ui-bg-surface);
95
+ box-shadow: inset 0 0 0 calc(.5px * var(--_f)) var(--_te);
96
+ transition: background-color var(--_tt), border-color var(--_tt), box-shadow var(--_tt);
97
+ animation: tip-in calc(480ms * var(--_ms)) var(--ui-ease-out) calc((80ms + 50ms * var(--_i, 0)) * var(--_ms)) both;
98
+ --_tt: calc(260ms * var(--_ms)) var(--ui-ease-out);
99
+ }
100
+ :host([data-done]) {
101
+ --_te: color-mix(in srgb, color-mix(in srgb, var(--ui-border) 80%, var(--ui-bg-surface)) calc(100% * var(--_t)), var(--ui-border));
102
+ background: var(--ui-tips-panel-done-bg, light-dark(color-mix(in srgb, var(--ui-text) 2.5%, var(--ui-bg-surface)), color-mix(in srgb, var(--ui-text) 4%, var(--ui-bg-surface))));
103
+ }
104
+ @keyframes tip-in { from { opacity: 0; translate: 0 4px; } }
105
+ @keyframes pop { from { opacity: 0; scale: .94; } }
106
+ p { margin: 0; max-inline-size: 100%; overflow-wrap: anywhere; }
107
+ .t { font-size: calc(13px + 1px * var(--_t)); font-weight: var(--ui-weight-medium); }
108
+ .d { flex: 1 0 auto; margin: calc(2px + 4px * var(--_t)) 0 calc(12px + 2px * var(--_t)); color: var(--ui-text-muted); }
109
+ .ok { display: inline-flex; align-items: center; gap: var(--ui-space-1-5); min-block-size: var(--_bh); color: var(--_ok); font-weight: var(--ui-weight-medium); overflow-wrap: anywhere; outline: none; }
110
+ .live { animation: pop calc(360ms * var(--_ms)) var(--ui-ease-out); }
111
+ svg { flex: none; inline-size: 16px; block-size: 16px; fill: currentColor; }
112
+ path { fill: none; stroke: var(--ui-bg-surface); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
113
+ .pri {
114
+ --_fg: var(--ui-text-on-neutral);
115
+ --_b: color-mix(in srgb, var(--ui-bg-neutral-solid) calc(var(--_a, 95%) + (100% - var(--_a, 95%)) * var(--_t)), var(--ui-bg-surface));
116
+ --_g: linear-gradient(color-mix(in srgb, var(--ui-gray-0) calc(12% * var(--_t)), transparent), color-mix(in srgb, var(--ui-gray-1000) calc(5% * var(--_t)), transparent));
117
+ --_sh: 0 0 0 calc(1px * var(--_t)) var(--ui-gray-1000), 0 calc(2px * var(--_t)) calc(4px * var(--_t)) color-mix(in srgb, var(--ui-gray-1000) calc(16% * var(--_t)), transparent), inset 0 calc(1px * var(--_t)) color-mix(in srgb, var(--ui-gray-0) calc(14% * var(--_t)), transparent);
118
+ }
119
+ @media (hover: hover) {
120
+ .btn:hover { --_bl: 3px; --_rc: var(--ui-border); --_w: light-dark(color-mix(in srgb, var(--ui-text) 3%, var(--ui-bg-surface)), color-mix(in srgb, var(--ui-text) 9%, var(--ui-bg-surface))); }
121
+ .pri:hover { --_a: 80%; }
122
+ .btn:active { transform: scale(.98); }
123
+ }
124
+ .btn:focus-visible { outline: var(--ui-focus-width) solid var(--ui-focus-ring); outline-offset: var(--ui-focus-offset); }
125
+ @media (prefers-reduced-motion: reduce) {
126
+ :host, .live { animation: none; }
127
+ }
128
+ @media (forced-colors: active) {
129
+ :host { border: 1px solid CanvasText; }
130
+ .btn { --_bc: ButtonText; }
131
+ }
132
+ `,
133
+ })
134
+ export class UiTip {
135
+ /** The tip in a few words. */
136
+ readonly title = input.required<string>();
137
+ /** The button's text: a verb, such as "Invite" or "Turn on". */
138
+ readonly action = input.required<string>();
139
+ /** What the done line says once the tip is taken, in the past tense: "Invite sent". */
140
+ readonly doneLabel = input<string>();
141
+ /** A solid button, for the one tip you want people to notice. */
142
+ readonly primary = input(false, { transform: booleanAttribute });
143
+ /** Whether the tip has been taken. Bind `[(done)]` to keep it across visits. */
144
+ readonly done = model(false);
145
+ /** Fires when someone takes the tip: run the action here. */
146
+ readonly taken = output<void>();
147
+
148
+ private readonly panel = inject(UiTipsPanel, { optional: true });
149
+ private readonly el = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
150
+ private readonly doc = inject(DOCUMENT);
151
+ private readonly injector = inject(Injector);
152
+ private readonly okEl = viewChild<ElementRef<HTMLElement>>('ok');
153
+ protected readonly live = signal(false);
154
+ protected readonly index = computed(() => Math.max(0, this.panel?.tips().indexOf(this) ?? 0));
155
+ protected readonly doneText = computed(() => this.doneLabel() || this.panel?.text().defaultDone || LABELS.defaultDone);
156
+
157
+ constructor() {
158
+ if (isDevMode()) {
159
+ afterNextRender(() => {
160
+ if (!this.title()?.trim() || !this.action()?.trim()) console.warn('ui-tip: give every tip a title and an action, or screen readers have nothing to say.', this.el);
161
+ });
162
+ }
163
+ }
164
+
165
+ protected take() {
166
+ if (this.done()) return;
167
+ const focused = this.el.contains(this.doc.activeElement);
168
+ this.live.set(true);
169
+ this.done.set(true);
170
+ this.taken.emit();
171
+ if (focused) afterNextRender(() => this.okEl()?.nativeElement.focus({ preventScroll: true }), { injector: this.injector });
172
+ }
173
+ }
174
+
175
+ /** The card around the tips: a header with the count, the scrolling grid and an optional Close row. */
176
+ @Component({
177
+ selector: 'ui-tips-panel',
178
+ host: {
179
+ role: 'region',
180
+ '[attr.aria-labelledby]': 'uid',
181
+ '[attr.title]': 'null',
182
+ '[attr.data-closing]': 'closing() ? "" : null',
183
+ '[attr.hidden]': 'open() ? null : ""',
184
+ '[inert]': 'closing()',
185
+ },
186
+ template: `
187
+ <header class="head">
188
+ <div class="h" role="heading" dir="auto" [attr.aria-level]="headingLevel()" [id]="uid">{{ title() }}</div>
189
+ <span class="n" dir="auto" aria-hidden="true">{{ doneCount() }}/{{ tips().length }} {{ text().done }}</span>
190
+ <span class="ui-sr" aria-live="polite" aria-atomic="true">{{ text().count(doneCount(), tips().length) }}</span>
191
+ </header>
192
+ <div class="sc">
193
+ <div class="grid" role="list"><ng-content select="ui-tip" /></div>
194
+ </div>
195
+ @if (closable()) {
196
+ <footer class="foot">
197
+ <button type="button" class="btn" dir="auto" style="${BTN}" (click)="close()">{{ text().close }}</button>
198
+ </footer>
199
+ }
200
+ `,
201
+ styles: `
202
+ :host::before { content: 'x x x x x x x x' / ''; display: block; block-size: 0; overflow: hidden; font-size: 0; word-spacing: calc(720px / 7); }
203
+ :host {
204
+ --_t: var(--ui-look-tray, 0);
205
+ --_f: calc(1 - var(--_t));
206
+ --_y: calc(1px * var(--_f));
207
+ --_ms: var(--ui-motion-scale);
208
+ --_s: color-mix(in srgb, var(--ui-gray-1000) 6%, transparent);
209
+ --_e: color-mix(in srgb, var(--ui-bg-muted) 88%, var(--ui-bg-surface));
210
+ --_bf: light-dark(var(--ui-bg-surface), color-mix(in srgb, var(--ui-text) 5%, var(--ui-bg-surface)));
211
+ --_bh: calc(28px + 2px * var(--_t));
212
+ --_d: calc((140ms + 20ms * var(--_t)) * var(--_ms)) var(--ui-ease-out);
213
+ --_a: initial; --_b: initial; --_bc: initial; --_bl: initial; --_fg: initial; --_g: initial; --_rc: initial; --_sh: initial; --_w: initial;
214
+ display: flex;
215
+ flex-direction: column;
216
+ inline-size: min(720px, 100%);
217
+ box-sizing: border-box;
218
+ padding: calc(6px * var(--_t));
219
+ border-radius: var(--ui-tips-panel-radius, calc(10px + 12px * var(--_t)));
220
+ background: color-mix(in srgb, var(--ui-tray-bg) calc(100% * var(--_t)), var(--ui-bg-surface));
221
+ box-shadow: 0 0 0 calc(.5px * var(--_f)) var(--_e), 0 var(--_y) var(--_y) calc(-1 * var(--_y)) var(--_s), 0 var(--_y) calc(2 * var(--_y)) var(--_s);
222
+ color: var(--ui-text);
223
+ font: var(--ui-text-base) / var(--ui-leading-base) var(--ui-font-sans);
224
+ transition: opacity calc(260ms * var(--_ms)) ease, scale calc(320ms * var(--_ms)) var(--ui-ease-out);
225
+ }
226
+ :host([hidden]) { display: none; }
227
+ :host([data-closing]) { opacity: 0; scale: .98; }
228
+ .head {
229
+ display: flex;
230
+ align-items: center;
231
+ justify-content: space-between;
232
+ gap: var(--ui-space-3);
233
+ padding: calc(12px + 1px * var(--_t)) calc(16px + 4px * var(--_t)) 12px;
234
+ border-block-end: calc(1px * var(--_f)) solid var(--ui-border);
235
+ }
236
+ .h { min-inline-size: 0; font-size: calc(15px + 1px * var(--_t)); line-height: calc(24px - 2px * var(--_t)); font-weight: calc(500 + 100 * var(--_t)); letter-spacing: calc(-.01em * var(--_t)); overflow-wrap: anywhere; }
237
+ .n { flex: none; color: var(--ui-text-muted); font-size: calc(12px + 1px * var(--_t)); line-height: calc(16px + 2px * var(--_t)); font-variant-numeric: tabular-nums; }
238
+ .sc {
239
+ container-type: inline-size;
240
+ box-sizing: border-box;
241
+ max-block-size: var(--ui-tips-panel-max-height, 420px);
242
+ overflow-y: auto;
243
+ scrollbar-width: thin;
244
+ border: calc(1px * var(--_t)) solid var(--ui-border);
245
+ border-radius: calc(16px * var(--_t));
246
+ background: var(--ui-bg-surface);
247
+ box-shadow: 0 calc(1px * var(--_t)) calc(2px * var(--_t)) color-mix(in srgb, var(--_s) calc(100% * var(--_t)), transparent);
248
+ }
249
+ .grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: calc(8px + 4px * var(--_t)); padding: calc(12px + 2px * var(--_t)); }
250
+ @container (width <= 560px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
251
+ @container (width <= 380px) { .grid { grid-template-columns: minmax(0, 1fr); } }
252
+ .foot { display: flex; justify-content: flex-end; padding: 8px; border-block-start: 1px solid var(--ui-border); }
253
+ @container style(--ui-look-tray: 1) {
254
+ .foot { justify-content: flex-start; padding: 8px 10px 10px; border: 0; }
255
+ }
256
+ @media (hover: hover) {
257
+ .btn:hover { --_bl: 3px; --_rc: var(--ui-border); --_w: light-dark(color-mix(in srgb, var(--ui-text) 3%, var(--ui-bg-surface)), color-mix(in srgb, var(--ui-text) 9%, var(--ui-bg-surface))); }
258
+ .btn:active { transform: scale(.98); }
259
+ }
260
+ .btn:focus-visible { outline: var(--ui-focus-width) solid var(--ui-focus-ring); outline-offset: var(--ui-focus-offset); }
261
+ @media (pointer: coarse) { :host { --_bh: 34px; } }
262
+ @media (forced-colors: active) {
263
+ :host { border: 1px solid CanvasText; }
264
+ .btn { --_bc: ButtonText; }
265
+ }
266
+ `,
267
+ })
268
+ export class UiTipsPanel {
269
+ /** The heading at the top of the card. */
270
+ readonly title = input('Tips');
271
+ /** The heading level, so the card fits your page's outline. */
272
+ readonly headingLevel = input(3, { transform: numberAttribute });
273
+ /** Shows a Close button in the last row. */
274
+ readonly closable = input(false, { transform: booleanAttribute });
275
+ /** Whether the card is shown. Close sets it to false after the exit; bind `[(open)]` to bring it back. */
276
+ readonly open = model(true);
277
+ /** Every visible and spoken string, for translation. */
278
+ readonly labels = input<Partial<TipsPanelLabels>>({});
279
+ /** Fires once the card has faded out after Close. */
280
+ readonly closed = output<void>();
281
+
282
+ readonly tips = contentChildren(UiTip);
283
+ readonly text = computed(() => ({ ...LABELS, ...this.labels() }));
284
+ protected readonly doneCount = computed(() => this.tips().filter((t) => t.done()).length);
285
+ protected readonly closing = signal(false);
286
+ protected readonly uid = `ui-tips-panel-${nextId++}`;
287
+
288
+ private readonly el = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
289
+ private readonly doc = inject(DOCUMENT);
290
+ private timer?: ReturnType<typeof setTimeout>;
291
+
292
+ constructor() {
293
+ inject(DestroyRef).onDestroy(() => clearTimeout(this.timer));
294
+ if (isDevMode()) {
295
+ afterNextRender(() => {
296
+ if (!this.title().trim()) console.warn('ui-tips-panel: give it a title; it names the region for screen readers.', this.el);
297
+ });
298
+ }
299
+ }
300
+
301
+ /** Fades the card out, then sets `open` to false and emits `closed`. */
302
+ close() {
303
+ if (this.closing() || !this.open()) return;
304
+ this.closing.set(true);
305
+ const scale = parseFloat(this.doc.defaultView?.getComputedStyle(this.el).getPropertyValue('--ui-motion-scale') ?? '');
306
+ this.timer = setTimeout(() => {
307
+ this.closing.set(false);
308
+ this.open.set(false);
309
+ this.closed.emit();
310
+ }, 320 * (Number.isFinite(scale) ? scale : 1));
311
+ }
312
+ }
@@ -0,0 +1,357 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Toggle Group, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (the --ui-* tokens), added once by `npx ochreui init`.
5
+ *
6
+ * <ui-toggle-group aria-label="Show runs" [(value)]="status"><button uiToggle value="running">Running</button>…</ui-toggle-group>
7
+ * A row of toggle buttons with one tab stop. `multiple` keeps a list in item order; `single` keeps one value
8
+ * or null. Works with [formField], formControl and ngModel.
9
+ *
10
+ * Public styling hooks (set them on the element or any ancestor):
11
+ * --ui-toggle-group-radius item corners (default 6px; Classic 9px chips, 7px track items)
12
+ * --ui-toggle-group-track track fill (default: the subtle background)
13
+ * --ui-toggle-group-on pressed fill of a chip (default: ink at 8%)
14
+ * --ui-toggle-group-press scale while held (default 0.96)
15
+ */
16
+ import {
17
+ Component,
18
+ Directive,
19
+ ElementRef,
20
+ OnInit,
21
+ afterNextRender,
22
+ booleanAttribute,
23
+ computed,
24
+ contentChildren,
25
+ forwardRef,
26
+ inject,
27
+ input,
28
+ isDevMode,
29
+ linkedSignal,
30
+ model,
31
+ output,
32
+ signal,
33
+ } from '@angular/core';
34
+ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
35
+
36
+ export type ToggleGroupType = 'multiple' | 'single';
37
+ export type ToggleGroupVariant = 'chips' | 'track';
38
+ export type ToggleGroupSize = 'sm' | 'md' | 'lg';
39
+ /** A list of values for `multiple`, one value or `null` for `single`. */
40
+ export type ToggleGroupValue = readonly string[] | string | null;
41
+
42
+ const space = (n: string) => `var(--ui-space-${n})`;
43
+ /** Per size: height, padding, type and icon in Clean. Classic adds 2px of height and padding and half a pixel of type. */
44
+ const SIZES: Record<ToggleGroupSize, Record<string, string>> = {
45
+ sm: { '--_h': space('6'), '--_p': space('2'), '--_fs': 'var(--ui-text-sm)', '--_lh': `calc(${space('4')} + ${space('1')} * var(--_t))`, '--_i': 'var(--ui-icon-sm)' },
46
+ md: { '--_h': `calc(${space('6')} + ${space('1')})`, '--_p': space('2-5'), '--_fs': 'var(--ui-text-base)', '--_lh': 'var(--ui-leading-base)', '--_i': 'var(--ui-icon-md)' },
47
+ lg: { '--_h': space('8'), '--_p': space('3'), '--_fs': 'var(--ui-text-base)', '--_lh': 'var(--ui-leading-base)', '--_i': 'var(--ui-icon-md)' },
48
+ };
49
+
50
+ /** One item: put it on a native `<button>` inside `<ui-toggle-group>`. */
51
+ @Component({
52
+ selector: 'button[uiToggle]',
53
+ host: {
54
+ type: 'button',
55
+ '[attr.aria-pressed]': 'pressed()',
56
+ '[tabindex]': 'group.tabStop() === this ? 0 : -1',
57
+ '[disabled]': 'off()',
58
+ '[attr.aria-label]': 'label() ?? null',
59
+ '[attr.title]': 'label() ?? null',
60
+ '[attr.data-icon-only]': 'iconOnly() || null',
61
+ '[attr.data-variant]': 'group.variant()',
62
+ '[attr.data-size]': 'group.size()',
63
+ '[style]': 'sizes[group.size()]',
64
+ '(click)': 'group.toggle(this)',
65
+ '(focus)': 'group.active.set(this)',
66
+ },
67
+ template: '<ng-content select="[uiToggleIcon]" /><span #text class="t" dir="auto"><ng-content /></span>',
68
+ styles: `
69
+ :host {
70
+ --_t: var(--ui-look-tray, 0);
71
+ --_k: calc(1 + .6 * var(--_t));
72
+ --_d: calc(var(--ui-duration-1) * var(--_k));
73
+ --_hh: calc(var(--_h) + 2px * var(--_t));
74
+ --_w: calc(.5px + .5px * var(--_t));
75
+ --_e1: color-mix(in srgb, var(--ui-text) calc(5% + 9% * var(--_t)), transparent);
76
+ --_e: color-mix(in srgb, var(--ui-border) calc(var(--_t) * 100%), var(--_e1));
77
+ --_drop: 0 1px 2px color-mix(in srgb, var(--ui-gray-1000) calc(6% * var(--_t)), transparent);
78
+ --_on: var(--ui-toggle-group-on, color-mix(in srgb, var(--ui-text) 8%, transparent));
79
+ --_b: transparent;
80
+ --_f: var(--ui-text-muted);
81
+ position: relative;
82
+ isolation: isolate;
83
+ display: inline-flex;
84
+ align-items: center;
85
+ justify-content: center;
86
+ gap: var(--ui-space-1-5);
87
+ flex: none;
88
+ box-sizing: border-box;
89
+ block-size: var(--_hh);
90
+ min-inline-size: var(--_hh);
91
+ max-inline-size: 100%;
92
+ margin: 0;
93
+ padding: 0 calc(var(--_p) + 2px * var(--_t));
94
+ border: 0;
95
+ border-radius: var(--ui-toggle-group-radius, calc(var(--ui-radius-sm) + 3px * var(--_t)));
96
+ background: var(--_b);
97
+ box-shadow: inset 0 0 0 var(--_w) var(--_e), var(--_drop);
98
+ color: var(--_f);
99
+ font: var(--ui-weight-medium) calc(var(--_fs) + .5px * var(--_t)) / var(--_lh) var(--ui-font-sans);
100
+ white-space: nowrap;
101
+ cursor: pointer;
102
+ scroll-snap-align: start;
103
+ transition: color var(--_d), background-color var(--_d), box-shadow var(--_d), transform calc(var(--ui-duration-2) * var(--_k));
104
+ transition-timing-function: var(--ui-ease-out);
105
+ }
106
+ :host::before {
107
+ content: '';
108
+ position: absolute;
109
+ inset: 0;
110
+ z-index: -1;
111
+ border-radius: inherit;
112
+ background: var(--_on);
113
+ box-shadow: var(--_onsh);
114
+ opacity: 0;
115
+ scale: calc(.88 - .02 * var(--_t));
116
+ transition: opacity var(--_d) var(--ui-ease-out), scale calc(var(--ui-duration-3) * var(--_k)) var(--ui-ease-out);
117
+ }
118
+ :host([aria-pressed=true]) { --_f: var(--ui-text); --_e: var(--_e1); --_drop: 0 0 transparent; }
119
+ :host([aria-pressed=true])::before { opacity: 1; scale: 1; }
120
+ :host([data-variant=track]) {
121
+ --_hh: calc(var(--_h) + 2px * var(--_t) - 4px * (1 - var(--_t)));
122
+ --_w: 0px;
123
+ --_drop: 0 0 transparent;
124
+ --_on: light-dark(var(--ui-bg-surface), color-mix(in srgb, var(--ui-text) 7%, var(--ui-bg-subtle)));
125
+ --_onsh: 0 0 0 .5px var(--ui-hairline), 0 1px 2px color-mix(in srgb, var(--ui-gray-1000) 8%, transparent), 0 2px 8px -2px color-mix(in srgb, var(--ui-gray-1000) calc(10% * var(--_t)), transparent);
126
+ border-radius: var(--ui-toggle-group-radius, calc(var(--ui-radius-sm) + 1px * var(--_t)));
127
+ }
128
+ :host([data-icon-only]) { padding: 0; }
129
+ .t { display: block; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
130
+ .t:empty { display: none; }
131
+ @media (hover: hover) {
132
+ :host(:hover:not(:disabled)) { --_f: var(--ui-text); }
133
+ :host([data-variant=chips]:hover:not(:disabled, [aria-pressed=true])) { --_b: color-mix(in srgb, var(--ui-text) 4%, transparent); --_e: var(--_e1); }
134
+ :host([data-variant=chips][aria-pressed=true]:hover:not(:disabled)) { --_on: color-mix(in srgb, var(--ui-text) 11%, transparent); }
135
+ }
136
+ @media (prefers-reduced-motion: no-preference) {
137
+ :host(:active:not(:disabled)) { transform: scale(var(--ui-toggle-group-press, .96)); }
138
+ }
139
+ @container style(--ui-motion-scale: 0) {
140
+ :host(:active) { transform: none; }
141
+ }
142
+ @media (pointer: coarse) {
143
+ :host { block-size: max(var(--_hh), var(--ui-space-8) + var(--ui-space-1)); min-inline-size: max(var(--_hh), var(--ui-space-8) + var(--ui-space-1)); }
144
+ :host::after { content: ''; position: absolute; inset: calc(var(--ui-space-1) * -1) 0; }
145
+ }
146
+ :host(:focus-visible) { outline: var(--ui-focus-width) solid var(--ui-focus-ring); outline-offset: var(--ui-focus-offset); }
147
+ :host([data-variant=track]:focus-visible) { outline-offset: var(--ui-focus-offset-inset); }
148
+ :host(:disabled) { opacity: var(--ui-disabled-opacity); cursor: not-allowed; }
149
+ @media (forced-colors: active) {
150
+ :host { border: 1px solid; }
151
+ :host::before { content: none; }
152
+ :host([aria-pressed=true]:not(:disabled)) { forced-color-adjust: none; background: Highlight; color: HighlightText; }
153
+ :host(:disabled) { color: GrayText; }
154
+ }
155
+ `,
156
+ })
157
+ export class UiToggle implements OnInit {
158
+ /** What this item stands for in the group's value. */
159
+ readonly value = input.required<string>();
160
+ /** Its accessible name and tooltip. Required when the item is only an icon. */
161
+ readonly label = input<string>();
162
+ /** Turns this item off; arrow keys skip it. */
163
+ readonly disabled = input(false, { transform: booleanAttribute });
164
+ /** False until the inputs are in: `@for` sets each item's value after the previous item has rendered. */
165
+ readonly ready = signal(false);
166
+
167
+ protected readonly group: UiToggleGroup = inject(UiToggleGroup);
168
+ protected readonly sizes = SIZES;
169
+ readonly el = inject<ElementRef<HTMLButtonElement>>(ElementRef).nativeElement;
170
+ readonly pressed = computed(() => this.group.selected().has(this.value()));
171
+ readonly off = computed(() => this.disabled() || this.group.isDisabled());
172
+ protected readonly iconOnly = signal(false);
173
+
174
+ ngOnInit() {
175
+ this.ready.set(true);
176
+ }
177
+
178
+ constructor() {
179
+ afterNextRender(() => {
180
+ const empty = !this.el.querySelector('.t')?.textContent?.trim();
181
+ this.iconOnly.set(empty);
182
+ if (isDevMode() && empty && !this.label() && !this.el.hasAttribute('aria-label')) {
183
+ console.warn('uiToggle: an item that is only an icon needs a label.', this.el);
184
+ }
185
+ });
186
+ }
187
+ }
188
+
189
+ /** Marks the icon inside a toggle: `<svg uiToggleIcon>`. Sized to the item and hidden from screen readers. */
190
+ @Directive({
191
+ selector: '[uiToggleIcon]',
192
+ host: {
193
+ 'aria-hidden': 'true',
194
+ style: 'flex: none',
195
+ '[style.width]': '"var(--_i)"',
196
+ '[style.height]': '"var(--_i)"',
197
+ },
198
+ })
199
+ export class UiToggleIcon {}
200
+
201
+ @Component({
202
+ selector: 'ui-toggle-group',
203
+ providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiToggleGroup), multi: true }],
204
+ host: {
205
+ role: 'group',
206
+ '[attr.data-type]': 'type()',
207
+ '[attr.data-variant]': 'variant()',
208
+ '[attr.data-size]': 'size()',
209
+ '[attr.aria-disabled]': 'isDisabled() || null',
210
+ '(keydown)': 'key($event)',
211
+ '(focusout)': 'left($event)',
212
+ },
213
+ template: '<ng-content />',
214
+ styles: `
215
+ :host {
216
+ --_t: var(--ui-look-tray, 0);
217
+ display: flex;
218
+ flex-wrap: wrap;
219
+ gap: var(--ui-space-2);
220
+ box-sizing: border-box;
221
+ inline-size: fit-content;
222
+ max-inline-size: 100%;
223
+ min-inline-size: 0;
224
+ }
225
+ :host([data-size='sm']) { gap: var(--ui-space-1-5); }
226
+ :host([data-variant='track']) {
227
+ flex-wrap: nowrap;
228
+ gap: 0;
229
+ padding: var(--ui-space-0-5);
230
+ border-radius: calc(var(--ui-toggle-group-radius, calc(var(--ui-radius-sm) + 1px * var(--_t))) + var(--ui-space-0-5));
231
+ background: var(--ui-toggle-group-track, var(--ui-bg-subtle));
232
+ overflow-x: auto;
233
+ overscroll-behavior-x: contain;
234
+ scrollbar-width: none;
235
+ scroll-snap-type: x proximity;
236
+ }
237
+ @media (forced-colors: active) {
238
+ :host([data-variant='track']) { border: 1px solid; }
239
+ }
240
+ `,
241
+ })
242
+ export class UiToggleGroup<V extends ToggleGroupValue = ToggleGroupValue> implements ControlValueAccessor {
243
+ /** `multiple`: any number on, the value is a list in item order. `single`: one or none, the value is a string or `null`. */
244
+ readonly type = input<ToggleGroupType>('multiple');
245
+ /** The pressed items. Bind `[(value)]`, `[formField]`, `formControlName` or `ngModel`. */
246
+ readonly value = model<V>(null as V);
247
+ /** The pressed items now. Form writes land here without emitting `valueChange`. */
248
+ readonly current = linkedSignal(() => this.value());
249
+ /** Separate chips that wrap, or a compact track that scrolls sideways. */
250
+ readonly variant = input<ToggleGroupVariant>('chips');
251
+ /** 24, 28 or 32px tall; Classic 2px taller. At least 36px on touch screens. */
252
+ readonly size = input<ToggleGroupSize>('md');
253
+ /** Turns every item off and takes the group out of the tab order. */
254
+ readonly disabled = input(false, { transform: booleanAttribute });
255
+ /** Emitted when focus leaves the group, which marks a form field as touched. */
256
+ readonly touch = output<void>();
257
+
258
+ private readonly options = contentChildren(UiToggle, { descendants: true });
259
+ readonly items = computed(() => this.options().filter((i) => i.ready()));
260
+ readonly active = signal<UiToggle | null>(null);
261
+ private readonly formDisabled = signal(false);
262
+ readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
263
+ private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
264
+ private onChange: (v: V) => void = () => {};
265
+ private onTouched: () => void = () => {};
266
+
267
+ readonly selected = computed(() => {
268
+ const v = this.current();
269
+ const list = v == null ? [] : typeof v === 'string' ? [v] : v;
270
+ return new Set(this.type() === 'single' ? list.slice(0, 1) : list);
271
+ });
272
+
273
+ readonly tabStop = computed(() => {
274
+ if (this.isDisabled()) return null;
275
+ const items = this.items().filter((i) => !i.off());
276
+ const active = this.active();
277
+ return (active && items.includes(active) ? active : null) ?? items.find((i) => i.pressed()) ?? items[0] ?? null;
278
+ });
279
+
280
+ constructor() {
281
+ afterNextRender(() => {
282
+ const h = this.host;
283
+ if (isDevMode() && !h.hasAttribute('aria-label') && !h.hasAttribute('aria-labelledby')) {
284
+ console.warn('ui-toggle-group: name the group with aria-label or aria-labelledby.', h);
285
+ }
286
+ });
287
+ }
288
+
289
+ /** Turns one item on or off, as a click does. */
290
+ toggle(item: UiToggle) {
291
+ if (item.off()) return;
292
+ this.active.set(item);
293
+ const v = item.value();
294
+ const set = this.selected();
295
+ let next: ToggleGroupValue;
296
+ if (this.type() === 'single') next = set.has(v) ? null : v;
297
+ else {
298
+ const on = new Set(set);
299
+ if (!on.delete(v)) on.add(v);
300
+ const known = this.items().map((i) => i.value());
301
+ next = [...known.filter((k) => on.has(k)), ...[...on].filter((k) => !known.includes(k))];
302
+ }
303
+ this.current.set(next as V);
304
+ this.value.set(next as V);
305
+ this.onChange(next as V);
306
+ }
307
+
308
+ /** Moves focus to the tab stop: the last used item, else the first pressed one, else the first. */
309
+ focus(options?: FocusOptions) {
310
+ this.tabStop()?.el.focus(options);
311
+ }
312
+
313
+ protected key(e: KeyboardEvent) {
314
+ const items = this.items().filter((i) => !i.off());
315
+ const at = items.findIndex((i) => i.el === e.target);
316
+ if (at < 0 || e.altKey || e.ctrlKey || e.metaKey) return;
317
+ const rtl = this.host.ownerDocument.defaultView?.getComputedStyle(this.host).direction === 'rtl';
318
+ const n = items.length;
319
+ const to = (
320
+ {
321
+ ArrowDown: at + 1,
322
+ ArrowUp: at - 1,
323
+ ArrowRight: rtl ? at - 1 : at + 1,
324
+ ArrowLeft: rtl ? at + 1 : at - 1,
325
+ Home: 0,
326
+ End: n - 1,
327
+ } as Record<string, number>
328
+ )[e.key];
329
+ if (to === undefined) return;
330
+ e.preventDefault();
331
+ const item = items[(to + n) % n];
332
+ this.active.set(item);
333
+ item.el.focus();
334
+ }
335
+
336
+ protected left(e: FocusEvent) {
337
+ if (this.host.contains(e.relatedTarget as Node | null)) return;
338
+ this.touch.emit();
339
+ this.onTouched();
340
+ }
341
+
342
+ writeValue(v: V) {
343
+ this.current.set(v ?? (null as V));
344
+ }
345
+
346
+ registerOnChange(fn: (v: V) => void) {
347
+ this.onChange = fn;
348
+ }
349
+
350
+ registerOnTouched(fn: () => void) {
351
+ this.onTouched = fn;
352
+ }
353
+
354
+ setDisabledState(disabled: boolean) {
355
+ this.formDisabled.set(disabled);
356
+ }
357
+ }