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,415 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Text Field, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (tokens and shared keyframes), added once by `npx ochreui init`.
5
+ *
6
+ * <ui-text-field label="Name" hint="…" [error]="…"><input uiInput [formField]="form.name" /></ui-text-field>
7
+ * Your own <input> goes inside, so every kind of form, autofill and password managers work on it directly.
8
+ * The field adds the label, hint or error, prefix and suffix, and the clear, show-password and copy buttons.
9
+ *
10
+ * Public styling hooks (set them on the element or any ancestor):
11
+ * --ui-text-field-edge resting edge (default: the hairline)
12
+ * --ui-text-field-edge-hover edge on hover
13
+ * --ui-text-field-edge-focus edge while focused (default: the input border)
14
+ * --ui-text-field-radius corners (default 7px; Classic 10px)
15
+ */
16
+ import {
17
+ Component,
18
+ DOCUMENT,
19
+ DestroyRef,
20
+ Directive,
21
+ ElementRef,
22
+ afterRenderEffect,
23
+ afterNextRender,
24
+ booleanAttribute,
25
+ computed,
26
+ contentChild,
27
+ effect,
28
+ inject,
29
+ input,
30
+ isDevMode,
31
+ LOCALE_ID,
32
+ output,
33
+ signal,
34
+ viewChild,
35
+ } from '@angular/core';
36
+
37
+ export type TextFieldSize = 'sm' | 'md' | 'lg';
38
+
39
+ export interface TextFieldLabels {
40
+ optional: string;
41
+ clear: string;
42
+ show: string;
43
+ hide: string;
44
+ copy: string;
45
+ copied: string;
46
+ pressToCopy: string;
47
+ }
48
+
49
+ const LABELS: TextFieldLabels = {
50
+ optional: 'Optional',
51
+ clear: 'Clear',
52
+ show: 'Show password',
53
+ hide: 'Hide password',
54
+ copy: 'Copy',
55
+ copied: 'Copied',
56
+ pressToCopy: 'Selected. Press Ctrl+C or ⌘C to copy.',
57
+ };
58
+
59
+ let nextId = 0;
60
+
61
+ /** Put it on the `<input>` inside a `<ui-text-field>`. It takes the field's label, description and error state. */
62
+ @Directive({
63
+ selector: 'input[uiInput]',
64
+ host: {
65
+ class: 'ui-input',
66
+ dir: 'auto',
67
+ style: 'outline: 0',
68
+ '[id]': 'id()',
69
+ '[attr.aria-describedby]': 'describedBy()',
70
+ '[attr.aria-invalid]': 'field.invalid() || null',
71
+ '(input)': 'read()',
72
+ '(keydown.escape)': 'field.escape($event)',
73
+ '(document:reset)': 'reset($event)',
74
+ },
75
+ })
76
+ export class UiInput {
77
+ readonly id = input(`ui-text-field-${nextId++}`);
78
+ /** Your own descriptions, kept alongside the field's. Set it as `aria-describedby="…"`, not `[attr.aria-describedby]`. */
79
+ readonly ariaDescribedby = input<string>(undefined, { alias: 'aria-describedby' });
80
+
81
+ readonly el = inject<ElementRef<HTMLInputElement>>(ElementRef).nativeElement;
82
+ protected readonly field = inject(UiTextField);
83
+ private readonly destroy = inject(DestroyRef);
84
+ readonly value = signal('');
85
+ readonly disabled = signal(false);
86
+ readonly readOnly = signal(false);
87
+ readonly maxLength = signal(-1);
88
+ readonly secret = signal(false);
89
+
90
+ protected readonly describedBy = computed(
91
+ () => [this.ariaDescribedby(), ...this.field.describers()].filter(Boolean).join(' ') || null,
92
+ );
93
+
94
+ constructor() {
95
+ const el = this.el;
96
+ const native = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), 'value');
97
+ if (native?.set && native.get) {
98
+ Object.defineProperty(el, 'value', {
99
+ configurable: true,
100
+ get: () => native.get!.call(el),
101
+ set: (v: string) => {
102
+ native.set!.call(el, v);
103
+ queueMicrotask(() => this.read());
104
+ },
105
+ });
106
+ }
107
+ afterNextRender(() => {
108
+ this.read();
109
+ const view = el.ownerDocument.defaultView;
110
+ if (!view?.MutationObserver) return;
111
+ const watch = new view.MutationObserver(() => this.read());
112
+ watch.observe(el, { attributes: true, attributeFilter: ['disabled', 'readonly', 'maxlength', 'type'] });
113
+ this.destroy.onDestroy(() => watch.disconnect());
114
+ });
115
+ }
116
+
117
+ read() {
118
+ const el = this.el;
119
+ this.value.set(el.value);
120
+ this.disabled.set(el.disabled);
121
+ this.readOnly.set(el.readOnly);
122
+ this.maxLength.set(el.maxLength);
123
+ this.secret.set(el.type === 'password' || this.field.revealed());
124
+ }
125
+
126
+ protected reset(e: Event) {
127
+ if (e.target === this.el.form) setTimeout(() => this.read());
128
+ }
129
+ }
130
+
131
+ /** Marks an icon or text placed before the value: `<svg uiTextFieldPrefix>`. */
132
+ @Directive({ selector: '[uiTextFieldPrefix]', host: { class: 'ui-tf-affix', 'aria-hidden': 'true' } })
133
+ export class UiTextFieldPrefix {}
134
+
135
+ /** Marks an icon or text placed after the value: `<span uiTextFieldSuffix>`. */
136
+ @Directive({ selector: '[uiTextFieldSuffix]', host: { class: 'ui-tf-affix', 'aria-hidden': 'true' } })
137
+ export class UiTextFieldSuffix {}
138
+
139
+ const space = (n: string) => `var(--ui-space-${n})`;
140
+ const SIZES: Record<TextFieldSize, Record<string, string>> = {
141
+ sm: { '--_h0': 'var(--ui-control-h-sm)', '--_ht': `calc(${space('8')} + ${space('0-5')})` },
142
+ md: { '--_h0': 'var(--ui-control-h-md)', '--_ht': `calc(${space('8')} + ${space('1-5')})` },
143
+ lg: { '--_h0': `calc(var(--ui-control-h-md) + ${space('1')})`, '--_ht': `calc(${space('10')} + ${space('0-5')})` },
144
+ };
145
+
146
+ @Component({
147
+ selector: 'ui-text-field',
148
+ host: {
149
+ '[attr.data-size]': 'size()',
150
+ '[attr.data-invalid]': 'invalid() || null',
151
+ '[attr.data-readonly]': 'control()?.readOnly() || null',
152
+ '[attr.data-disabled]': 'control()?.disabled() || null',
153
+ '[style]': 'sizes[size()]',
154
+ },
155
+ template: `
156
+ @if (label()) {
157
+ <div class="top">
158
+ <label [for]="control()?.id()">{{ label() }}@if (optional()) {<span class="ui-sr"> ({{ t().optional }})</span>}</label>
159
+ @if (optional()) {<span class="opt" aria-hidden="true">{{ t().optional }}</span>}
160
+ </div>
161
+ }
162
+ <div class="box" [attr.data-nudge]="nudge() || null" (pointerdown)="focusInput($event)" (animationend)="$event.target === $event.currentTarget && nudge.set(false)" (animationcancel)="$event.target === $event.currentTarget && nudge.set(false)">
163
+ @if (prefix()) {<span class="ui-tf-affix pre" aria-hidden="true"><span><bdi>{{ prefix() }}</bdi></span></span>}
164
+ <ng-content select="[uiTextFieldPrefix]" />
165
+ <ng-content select="input" />
166
+ @if (suffix()) {<span class="ui-tf-affix" aria-hidden="true">{{ suffix() }}</span>}
167
+ <ng-content select="[uiTextFieldSuffix]" />
168
+ @if (clearable() && control()?.value() && editable()) {
169
+ <button type="button" class="ui-btn-icon" tabindex="-1" [attr.aria-label]="t().clear" (click)="clear()">
170
+ <svg class="ui-icon" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="currentColor" stroke="none" opacity=".85" /><path class="x" d="M6 6l4 4M10 6l-4 4" /></svg>
171
+ </button>
172
+ }
173
+ @if (control()?.secret()) {
174
+ <button type="button" class="ui-btn-icon" [attr.aria-label]="revealed() ? t().hide : t().show" [disabled]="control()?.disabled()" (click)="reveal()">
175
+ @if (revealed()) {
176
+ <svg class="ui-icon" [class.ui-enter]="swapped" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 2.5l11 11M6.6 3.7A6.8 6.8 0 0 1 8 3.5c3.5 0 6 3.4 6.5 4.5-.3.6-1 1.7-2 2.6M4.3 4.9C2.9 5.9 1.9 7.3 1.5 8c.5 1.1 3 4.5 6.5 4.5 1 0 1.9-.3 2.7-.7M6.6 6.6a2 2 0 0 0 2.8 2.8" /></svg>
177
+ } @else {
178
+ <svg class="ui-icon" [class.ui-enter]="swapped" viewBox="0 0 16 16" aria-hidden="true"><path d="M1.5 8c.5-1.1 3-4.5 6.5-4.5s6 3.4 6.5 4.5c-.5 1.1-3 4.5-6.5 4.5S2 9.1 1.5 8z" /><circle cx="8" cy="8" r="2" /></svg>
179
+ }
180
+ </button>
181
+ }
182
+ @if (copyable()) {
183
+ <button type="button" class="ui-btn-icon" [class.ok]="copied()" [attr.aria-label]="copied() ? t().copied : t().copy" [disabled]="control()?.disabled()" (click)="copy()">
184
+ @if (copied()) {
185
+ <svg class="ui-icon" [class.ui-enter]="swapped" viewBox="0 0 16 16" aria-hidden="true"><path class="ui-draw" pathLength="1" d="M3.5 8.5l3 3 6-7" /></svg>
186
+ } @else {
187
+ <svg class="ui-icon" [class.ui-enter]="swapped" viewBox="0 0 16 16" aria-hidden="true"><rect x="5.5" y="5.5" width="8" height="8" rx="1.5" /><path d="M10.5 3.5V3a.5.5 0 0 0-.5-.5H3a.5.5 0 0 0-.5.5v7a.5.5 0 0 0 .5.5h.5" /></svg>
188
+ }
189
+ </button>
190
+ <span class="ui-sr" role="status">{{ copied() ? t().copied : note() }}</span>
191
+ }
192
+ </div>
193
+ <div class="foot" [class.ui-sr]="!message() && !counter()">
194
+ <p #msg [id]="messageId" dir="auto" aria-live="polite">{{ message() }}</p>
195
+ @if (counter() && limit() >= 0) {<span class="count" [id]="countId" [attr.data-state]="countState()">{{ num.format(length()) }}/{{ num.format(limit()) }}</span>}
196
+ </div>
197
+ `,
198
+ styles: `
199
+ :host {
200
+ --_t: var(--ui-look-tray, 0);
201
+ --_h: calc(var(--_h0) + var(--ui-space-1) * var(--_t));
202
+ --_e: var(--ui-text-field-edge, var(--ui-hairline));
203
+ --_w: calc(0.5px + 0.5px * var(--_t));
204
+ --_fill: var(--ui-bg-surface);
205
+ display: flex;
206
+ flex-direction: column;
207
+ gap: calc(var(--ui-space-1-5) + 1px * var(--_t));
208
+ min-inline-size: 0;
209
+ color: var(--ui-text);
210
+ font: var(--ui-text-base) / var(--ui-leading-base) var(--ui-font-sans);
211
+ }
212
+ .top { display: flex; align-items: baseline; gap: var(--ui-space-1-5); padding-inline: calc(2px * var(--_t)); }
213
+ label { font-weight: var(--ui-weight-medium); }
214
+ .opt, .foot { color: var(--ui-text-muted); font-size: calc(var(--ui-text-sm) + 0.5px * var(--_t)); line-height: calc(var(--ui-leading-xs) + 1px * var(--_t)); }
215
+ .box {
216
+ display: flex;
217
+ align-items: center;
218
+ gap: var(--ui-space-1-5);
219
+ box-sizing: border-box;
220
+ block-size: var(--_h);
221
+ padding-inline: calc(var(--ui-space-2-5) + 2px * var(--_t) - 1px) calc(var(--ui-space-1-5) - 1px);
222
+ border: 1px solid transparent;
223
+ border-radius: var(--ui-text-field-radius, calc(var(--ui-radius-sm) + 1px + 3px * var(--_t)));
224
+ background: var(--_fill);
225
+ box-shadow: 0 0 0 var(--_w) var(--_e), 0 1px 2px color-mix(in srgb, var(--ui-gray-1000) 6%, transparent);
226
+ font-size: calc(var(--ui-text-base) + 0.5px * var(--_t));
227
+ cursor: text;
228
+ transition: var(--ui-duration-2) var(--ui-ease-out);
229
+ transition-property: box-shadow, background;
230
+ }
231
+ .box:not(:has(.ui-btn-icon)) { padding-inline-end: calc(var(--ui-space-2-5) + 2px * var(--_t) - 1px); }
232
+ @media (hover: hover) { .box:hover { --_e: var(--ui-text-field-edge-hover, color-mix(in srgb, var(--ui-text) 18%, transparent)); } }
233
+ .box:focus-within { --_w: 1px; --_e: var(--ui-text-field-edge-focus, var(--ui-border-input)); }
234
+ :host([data-invalid]) .box {
235
+ --_w: 1px;
236
+ --_e: color-mix(in srgb, var(--ui-danger) 55%, transparent);
237
+ --_fill: color-mix(in srgb, var(--ui-danger-soft) calc(50% * var(--_t)), var(--ui-bg-surface));
238
+ }
239
+ :host([data-invalid]) .box:focus-within { --_e: var(--ui-danger); }
240
+ :host([data-readonly]) .box { --_fill: var(--ui-bg-subtle); }
241
+ :host([data-disabled]) { opacity: var(--ui-disabled-opacity); }
242
+ :host([data-disabled]) .box { cursor: not-allowed; --_e: var(--ui-hairline); }
243
+ .box[data-nudge] { animation: ui-nudge calc(320ms * var(--ui-motion-scale)) var(--ui-ease-out); }
244
+ .pre { display: flex; max-inline-size: 70%; margin-inline-end: calc(var(--ui-space-1-5) * -1); }
245
+ .pre > span { overflow: hidden; direction: rtl; text-overflow: ellipsis; white-space: nowrap; }
246
+ .ok { color: var(--ui-success); }
247
+ .x { stroke: var(--_fill); }
248
+ .foot { display: flex; gap: var(--ui-space-3); padding-inline: calc(2px * var(--_t)); }
249
+ p { flex: 1; margin: 0; }
250
+ :host([data-invalid]) p { color: var(--ui-danger); }
251
+ .count { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
252
+ .count[data-state='full'] { color: var(--ui-text); }
253
+ .count[data-state='over'] { color: var(--ui-danger); }
254
+ @media (pointer: coarse) {
255
+ :host { --_h: calc(var(--_ht) + var(--ui-space-1) * var(--_t)); }
256
+ .box { font-size: var(--ui-text-field-touch); }
257
+ }
258
+ @media (prefers-reduced-motion: reduce) {
259
+ .box[data-nudge] { animation: none; }
260
+ }
261
+ @media (forced-colors: active) {
262
+ .box { border-color: CanvasText; }
263
+ .box:focus-within { outline: 2px solid Highlight; }
264
+ :host([data-invalid]) .box { outline: 1px solid CanvasText; }
265
+ }
266
+ `,
267
+ })
268
+ export class UiTextField {
269
+ /** Shown above the input. Clicking it focuses the input. */
270
+ readonly label = input<string>();
271
+ /** A quiet line under the input. The error takes its place while there is one. */
272
+ readonly hint = input<string>();
273
+ /** Marks the field invalid and shows this message where the hint was. */
274
+ readonly error = input<string | null | undefined>();
275
+ /** Short text inside the box before the value, such as "https://". For an icon, use `uiTextFieldPrefix`. */
276
+ readonly prefix = input<string>();
277
+ /** Short text after the value, such as "USD" or "%". For an icon, use `uiTextFieldSuffix`. */
278
+ readonly suffix = input<string>();
279
+ /** 28, 32 or 36px tall; Classic 32, 36 or 40px. Taller, with 16px text, on touch screens. */
280
+ readonly size = input<TextFieldSize>('md');
281
+ /** Adds "Optional" after the label. */
282
+ readonly optional = input(false, { transform: booleanAttribute });
283
+ /** A small × (and Escape) that empties the field while it has a value. */
284
+ readonly clearable = input(false, { transform: booleanAttribute });
285
+ /** A button that copies the value. Pair it with `readonly`. */
286
+ readonly copyable = input(false, { transform: booleanAttribute });
287
+ /** Shows "12/40" under the input. Needs `maxlength` on the input. */
288
+ readonly counter = input(false, { transform: booleanAttribute });
289
+ /** Words for the tag and the buttons, to translate them. */
290
+ readonly labels = input<Partial<TextFieldLabels>>({});
291
+ /** After the × or Escape emptied the field. */
292
+ readonly cleared = output<void>();
293
+
294
+ protected readonly control = contentChild(UiInput);
295
+ protected readonly sizes = SIZES;
296
+ protected readonly t = computed(() => ({ ...LABELS, ...this.labels() }));
297
+ protected readonly num = new Intl.NumberFormat(inject(LOCALE_ID));
298
+ protected readonly messageId = `ui-text-field-msg-${nextId++}`;
299
+ protected readonly countId = `${this.messageId}-count`;
300
+
301
+ readonly invalid = computed(() => !!this.error());
302
+ protected readonly message = computed(() => this.error() || this.hint() || '');
303
+ protected readonly limit = computed(() => this.control()?.maxLength() ?? -1);
304
+ protected readonly length = computed(() => this.control()?.value().length ?? 0);
305
+ protected readonly countState = computed(() => {
306
+ const [n, max] = [this.length(), this.limit()];
307
+ return n > max ? 'over' : n === max ? 'full' : null;
308
+ });
309
+ protected readonly editable = computed(() => !this.control()?.readOnly() && !this.control()?.disabled());
310
+ readonly describers = computed(() => [
311
+ this.message() ? this.messageId : '',
312
+ this.counter() && this.limit() >= 0 ? this.countId : '',
313
+ ]);
314
+
315
+ readonly revealed = signal(false);
316
+ protected readonly copied = signal(false);
317
+ protected readonly nudge = signal(false);
318
+ protected readonly note = signal('');
319
+ protected swapped = false;
320
+ private readonly msg = viewChild<ElementRef<HTMLElement>>('msg');
321
+
322
+ private readonly doc = inject(DOCUMENT);
323
+ private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
324
+ private timer?: ReturnType<typeof setTimeout>;
325
+
326
+ constructor() {
327
+ let was: boolean | undefined;
328
+ effect(() => {
329
+ const now = this.invalid();
330
+ if (now && was === false && this.motion()) this.nudge.set(true);
331
+ was = now;
332
+ });
333
+ let shown: string | undefined;
334
+ afterRenderEffect(() => {
335
+ const text = this.message();
336
+ const p = this.msg()?.nativeElement;
337
+ if (shown !== undefined && text !== shown && p?.animate && this.motion()) {
338
+ p.animate([{ opacity: 0, filter: 'blur(2px)', transform: 'translateY(-2px)' }, {}], { duration: 260 * this.motion(), easing: 'ease-out' });
339
+ }
340
+ shown = text;
341
+ });
342
+ afterNextRender(() => {
343
+ const c = this.control();
344
+ if (isDevMode() && c && !this.label() && !c.el.ariaLabel && !c.el.hasAttribute('aria-labelledby')) {
345
+ console.warn('ui-text-field: give it a label, or an aria-label on the input.', c.el);
346
+ }
347
+ });
348
+ inject(DestroyRef).onDestroy(() => clearTimeout(this.timer));
349
+ }
350
+
351
+ /** Empties the input the way typing would, so every kind of form sees the change. */
352
+ clear() {
353
+ const c = this.control();
354
+ if (!c) return;
355
+ c.el.value = '';
356
+ c.el.dispatchEvent(new Event('input', { bubbles: true }));
357
+ c.read();
358
+ c.el.focus();
359
+ this.cleared.emit();
360
+ }
361
+
362
+ escape(event: Event) {
363
+ if ((event as KeyboardEvent).isComposing || !this.clearable() || !this.control()?.value() || !this.editable()) return;
364
+ event.preventDefault();
365
+ event.stopPropagation();
366
+ this.clear();
367
+ }
368
+
369
+ protected focusInput(event: PointerEvent) {
370
+ const el = this.control()?.el;
371
+ if (!el || event.target === el || (event.target as Element).closest('button, a, input, select, textarea')) return;
372
+ event.preventDefault();
373
+ el.focus();
374
+ }
375
+
376
+ protected reveal(show = !this.revealed()) {
377
+ const el = this.control()?.el;
378
+ if (!el) return;
379
+ this.swapped = true;
380
+ const [start, end] = [el.selectionStart, el.selectionEnd];
381
+ el.type = show ? 'text' : 'password';
382
+ el.setSelectionRange(start, end);
383
+ this.revealed.set(show);
384
+ if (show) el.form?.addEventListener('submit', () => this.reveal(false), { once: true });
385
+ if (el.animate && this.motion()) el.animate([{ filter: 'blur(3px)', opacity: 0.4 }, {}], { duration: 260 * this.motion(), easing: 'ease-out' });
386
+ }
387
+
388
+ /** 0 under reduced motion, otherwise the app's motion scale (1 by default). */
389
+ private motion() {
390
+ const view = this.doc.defaultView;
391
+ if (!view?.matchMedia || view.matchMedia('(prefers-reduced-motion: reduce)').matches) return 0;
392
+ const scale = parseFloat(view.getComputedStyle(this.host).getPropertyValue('--ui-motion-scale'));
393
+ return Number.isNaN(scale) ? 1 : scale;
394
+ }
395
+
396
+ protected async copy() {
397
+ const el = this.control()?.el;
398
+ const clipboard = this.doc.defaultView?.navigator.clipboard;
399
+ if (!el) return;
400
+ this.swapped = true;
401
+ try {
402
+ if (!clipboard) throw new Error('No clipboard');
403
+ await clipboard.writeText(el.value);
404
+ } catch {
405
+ el.focus();
406
+ el.select();
407
+ this.note.set(this.t().pressToCopy);
408
+ return;
409
+ }
410
+ this.note.set('');
411
+ this.copied.set(true);
412
+ clearTimeout(this.timer);
413
+ this.timer = setTimeout(() => this.copied.set(false), 1600);
414
+ }
415
+ }
@@ -0,0 +1,175 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Text Reveal, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (the --ui-* tokens and the .ui-sr class), which `npx ochreui init` adds once.
5
+ *
6
+ * <h2 uiTextReveal text="Ship interfaces that feel calm."></h2>
7
+ * Put it on your own empty element. When it scrolls into view, each word (or letter, with by="char") rises
8
+ * out of a soft blur, one after another. Screen readers hear the sentence once.
9
+ *
10
+ * Public styling hooks (set them on the element or any ancestor):
11
+ * --ui-text-reveal-rise how far below its place each piece starts (default 0.35em)
12
+ * --ui-text-reveal-blur how blurred each piece starts (default 8px)
13
+ * --ui-text-reveal-ease the curve shared by fade, blur and rise (default: a strong ease-out)
14
+ */
15
+ import {
16
+ Component,
17
+ DOCUMENT,
18
+ DestroyRef,
19
+ ElementRef,
20
+ afterNextRender,
21
+ booleanAttribute,
22
+ computed,
23
+ effect,
24
+ inject,
25
+ input,
26
+ isDevMode,
27
+ numberAttribute,
28
+ signal,
29
+ untracked,
30
+ } from '@angular/core';
31
+
32
+ export type TextRevealBy = 'word' | 'char';
33
+
34
+ interface Piece {
35
+ text: string;
36
+ i: number;
37
+ }
38
+
39
+ interface Word extends Piece {
40
+ key: string;
41
+ chars: Piece[];
42
+ }
43
+
44
+ type Phase = 'static' | 'wait' | 'shown' | 'done';
45
+
46
+ function graphemes(word: string): string[] {
47
+ const Seg = (Intl as { Segmenter?: typeof Intl.Segmenter }).Segmenter;
48
+ return Seg ? [...new Seg(undefined, { granularity: 'grapheme' }).segment(word)].map((s) => s.segment) : Array.from(word);
49
+ }
50
+
51
+ @Component({
52
+ selector: '[uiTextReveal]',
53
+ exportAs: 'uiTextReveal',
54
+ host: {
55
+ '[attr.data-wait]': "phase() === 'wait' ? '' : null",
56
+ '[attr.data-shown]': "phase() === 'shown' || phase() === 'done' ? '' : null",
57
+ '[attr.data-done]': "phase() === 'done' ? '' : null",
58
+ '[style.--_d]': "duration() + 'ms'",
59
+ '[style.--_w]': "delay() + 'ms'",
60
+ '[style.--_s]': "stagger() + 'ms'",
61
+ },
62
+ template: `<span class="ui-sr" dir="auto">{{ text() }}</span><span aria-hidden="true" dir="auto" (animationend)="ended($event)" (animationcancel)="ended($event)">@for (w of words(); track w.key; let last = $last) {@if (by() === 'char') {<span class="w">@for (c of w.chars; track c.i) {<span class="p" [style.--i]="c.i">{{ c.text }}</span>}</span>} @else {<span class="p" [style.--i]="w.i">{{ w.text }}</span>}{{ last ? '' : ' ' }}}</span>`,
63
+ styles: `
64
+ .ui-sr { user-select: none; }
65
+ .p, .w { display: inline-block; }
66
+ .w { white-space: nowrap; }
67
+ :host {
68
+ --_r: var(--ui-text-reveal-rise, 0.35em);
69
+ --_b: blur(var(--ui-text-reveal-blur, 8px));
70
+ }
71
+ @media (prefers-reduced-motion: no-preference) {
72
+ :host([data-wait]) .p { opacity: 0; filter: var(--_b); translate: 0 var(--_r); }
73
+ :host([data-shown]:not([data-done])) .p {
74
+ will-change: opacity, filter, translate;
75
+ animation: reveal calc(var(--_d) * var(--ui-motion-scale)) var(--ui-text-reveal-ease, cubic-bezier(0.2, 0.7, 0.2, 1))
76
+ calc((var(--_w) + var(--i) * var(--_s)) * var(--ui-motion-scale)) backwards;
77
+ }
78
+ }
79
+ @keyframes reveal { from { opacity: 0; filter: var(--_b); translate: 0 var(--_r); } }
80
+ `,
81
+ })
82
+ export class UiTextReveal {
83
+ /** The text to reveal. Runs of spaces and line breaks collapse to one space. */
84
+ readonly text = input.required<string>();
85
+ /** Reveal word by word, or letter by letter (letters of a word never wrap apart). */
86
+ readonly by = input<TextRevealBy>('word');
87
+ /** Milliseconds between two pieces. */
88
+ readonly stagger = input(40, { transform: numberAttribute });
89
+ /** Milliseconds before the first piece. */
90
+ readonly delay = input(0, { transform: numberAttribute });
91
+ /** Milliseconds each piece takes to arrive. */
92
+ readonly duration = input(700, { transform: numberAttribute });
93
+ /** Reveal only the first time it comes into view. When false, it hides on leaving and replays on return. */
94
+ readonly once = input(true, { transform: booleanAttribute });
95
+
96
+ protected readonly phase = signal<Phase>('static');
97
+ private readonly gen = signal(0);
98
+
99
+ protected readonly words = computed<Word[]>(() => {
100
+ const gen = this.gen();
101
+ const chars = this.by() === 'char';
102
+ let n = 0;
103
+ return (this.text() ?? '').split(/\s+/).filter(Boolean).map((text, k) => ({
104
+ key: `${gen}.${k}`,
105
+ text,
106
+ i: chars ? n : n++,
107
+ chars: chars ? graphemes(text).map((c) => ({ text: c, i: n++ })) : [],
108
+ }));
109
+ });
110
+
111
+ private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
112
+ private readonly doc = inject(DOCUMENT);
113
+ private seen = false;
114
+ private io?: IntersectionObserver;
115
+
116
+ constructor() {
117
+ const view = this.doc.defaultView;
118
+ const sync = () => {
119
+ const p = this.phase();
120
+ if (p === 'static') return;
121
+ if (this.seen && this.doc.visibilityState !== 'hidden') {
122
+ if (p === 'wait') this.play();
123
+ if (this.once()) stop();
124
+ } else if (!this.seen && !this.once() && p !== 'wait') {
125
+ this.phase.set('wait');
126
+ }
127
+ };
128
+ const stop = () => {
129
+ this.io?.disconnect();
130
+ this.io = undefined;
131
+ this.doc.removeEventListener('visibilitychange', sync);
132
+ };
133
+
134
+ afterNextRender(() => {
135
+ if (isDevMode() && !this.text()?.trim()) {
136
+ console.warn('uiTextReveal: the text is empty, so nothing is shown or read. Set text="…".', this.host);
137
+ }
138
+ if (!view?.IntersectionObserver || view.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return;
139
+ if (parseFloat(view.getComputedStyle(this.host).getPropertyValue('--ui-motion-scale')) === 0) return;
140
+ this.phase.set('wait');
141
+ this.doc.addEventListener('visibilitychange', sync);
142
+ this.io = new view.IntersectionObserver((entries) => {
143
+ this.seen = entries[entries.length - 1].isIntersecting;
144
+ sync();
145
+ });
146
+ this.io.observe(this.host);
147
+ });
148
+
149
+ effect(() => {
150
+ this.text();
151
+ this.by();
152
+ untracked(() => this.phase() === 'shown' && this.phase.set('done'));
153
+ });
154
+
155
+ inject(DestroyRef).onDestroy(stop);
156
+ }
157
+
158
+ /** Plays the reveal again from the start. Does nothing under reduced motion. */
159
+ replay(): void {
160
+ if (this.phase() === 'static' || this.phase() === 'wait') return;
161
+ this.gen.update((g) => g + 1);
162
+ this.play();
163
+ }
164
+
165
+ /** Non-finite timings would make the animation never end, so show the text at rest instead. */
166
+ private play(): void {
167
+ const playable = [this.duration(), this.delay(), this.stagger()].every(Number.isFinite);
168
+ this.phase.set(playable ? 'shown' : 'done');
169
+ }
170
+
171
+ protected ended(e: AnimationEvent): void {
172
+ const all = (e.currentTarget as Element).querySelectorAll('.p');
173
+ if (e.target === all[all.length - 1]) this.phase.set('done');
174
+ }
175
+ }
@@ -0,0 +1,68 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ import { DOCUMENT, PLATFORM_ID, Service, effect, inject, signal } from '@angular/core';
3
+ import { isPlatformBrowser } from '@angular/common';
4
+
5
+ export type UiThemeMode = 'light' | 'dark' | 'system';
6
+ export type UiDensity = 'comfortable' | 'compact';
7
+ export type UiLook = 'flat' | 'tray';
8
+
9
+ const STORAGE_KEY = 'ochre-theme';
10
+
11
+ interface Stored {
12
+ mode: UiThemeMode;
13
+ density: UiDensity;
14
+ look: UiLook;
15
+ }
16
+
17
+ /**
18
+ * Applies the three Ochre scopes to <html>: data-ui-theme, data-ui-density and data-ui-look.
19
+ * Remembers the choice in localStorage. Safe to inject on the server (it does nothing there).
20
+ *
21
+ * readonly theme = inject(UiTheme);
22
+ * theme.mode.set('dark');
23
+ */
24
+ @Service()
25
+ export class UiTheme {
26
+ private readonly doc = inject(DOCUMENT);
27
+ private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));
28
+ private readonly saved = this.load();
29
+
30
+ /** 'system' follows the operating system setting. */
31
+ readonly mode = signal<UiThemeMode>(this.saved.mode);
32
+ readonly density = signal<UiDensity>(this.saved.density);
33
+ readonly look = signal<UiLook>(this.saved.look);
34
+
35
+ constructor() {
36
+ effect(() => {
37
+ const root = this.doc.documentElement;
38
+ const mode = this.mode();
39
+ // Attributes, not dataset: the server-side DOM has no dataset.
40
+ if (mode === 'system') root.removeAttribute('data-ui-theme');
41
+ else root.setAttribute('data-ui-theme', mode);
42
+ root.setAttribute('data-ui-density', this.density());
43
+ root.setAttribute('data-ui-look', this.look());
44
+ if (this.browser) {
45
+ const value: Stored = { mode, density: this.density(), look: this.look() };
46
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(value));
47
+ }
48
+ });
49
+ }
50
+
51
+ /** Flips between light and dark. From 'system' it picks the opposite of what is showing now. */
52
+ toggle(): void {
53
+ const showingDark =
54
+ this.mode() === 'dark' ||
55
+ (this.mode() === 'system' && this.browser && matchMedia('(prefers-color-scheme: dark)').matches);
56
+ this.mode.set(showingDark ? 'light' : 'dark');
57
+ }
58
+
59
+ private load(): Stored {
60
+ const fallback: Stored = { mode: 'system', density: 'comfortable', look: 'flat' };
61
+ if (!this.browser) return fallback;
62
+ try {
63
+ return { ...fallback, ...(JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}') as Partial<Stored>) };
64
+ } catch {
65
+ return fallback;
66
+ }
67
+ }
68
+ }