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,126 @@
1
+ # Decision Inbox
2
+
3
+ Open decisions in a small card, each with two quick answers. The chosen answer turns green, holds for a moment, then the row folds away until the card is all caught up.
4
+
5
+ Add: `npx ochreui@latest add decision-inbox`
6
+ Import: `import { UiDecisionInbox } from './ui/decision-inbox';`
7
+ Selector: `<ui-decision-inbox>`
8
+ Docs: /components/decision-inbox
9
+
10
+ ## When to use
11
+ - A dashboard or agent run that needs a quick yes or no from a person.
12
+ - Approvals, renewals and alerts that one click settles.
13
+
14
+ ## When not to use
15
+ - Decisions that need a form or a longer explanation: link to a page.
16
+ - Notices without an answer: use a toast or an activity list.
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ import { Component, signal } from '@angular/core';
22
+ import { Decision, DecisionEvent, UiDecisionInbox } from './ui/decision-inbox';
23
+
24
+ @Component({
25
+ selector: 'app-approvals',
26
+ imports: [UiDecisionInbox],
27
+ template: `
28
+ <ui-decision-inbox [decisions]="decisions()" (decided)="save($event)" />
29
+ `,
30
+ styles: `
31
+ :host { display: block; max-width: 440px; }
32
+ `,
33
+ })
34
+ export class Approvals {
35
+ protected readonly decisions = signal<Decision[]>([
36
+ {
37
+ id: 'renewal',
38
+ title: 'Renew the analytics plan for the growth team?',
39
+ detail: '8 seats · $2,400 per year · renews in 6 days',
40
+ primary: 'Renew',
41
+ secondary: 'Change seats',
42
+ },
43
+ ]);
44
+
45
+ protected save({ decision, answer }: DecisionEvent) {
46
+ console.log(decision.id, answer);
47
+ this.decisions.update((list) => list.filter((d) => d.id !== decision.id));
48
+ }
49
+ }
50
+ ```
51
+
52
+ ## Rules
53
+ - Give every decision a unique id, a title and both answer labels.
54
+ - Save the answer in (decided). You may remove the decision from your array there; the card still confirms and folds it.
55
+ - The card fills its container: give it a width or put it in a block layout.
56
+ - Host styling (padding, corners, fill, edge) is inline: restyle through the --ui-decision-inbox-* variables, not CSS on the element.
57
+
58
+ ## Inputs
59
+
60
+ | Name | Type | Default | Description |
61
+ | --- | --- | --- | --- |
62
+ | `decisions` | `readonly Decision[]` | required | Open decisions, in order. Pass a new array when it changes. |
63
+ | `labels` | `Partial<DecisionInboxLabels>` | English | Header count, done text, empty line and the spoken prefix, for translation. |
64
+ | `headingLevel` | `number` | 3 | aria-level of the header heading. |
65
+ | `hold` | `number` | 1100 | Milliseconds the confirmation stays before the row folds. Kept with reduced motion. |
66
+
67
+ ## Outputs
68
+
69
+ | Name | Payload | Description |
70
+ | --- | --- | --- |
71
+ | `decided` | `DecisionEvent` | { decision, answer } with answer 'primary' or 'secondary'. Fires once per decision, at the click. |
72
+
73
+ ## Decision
74
+
75
+ | Field | Type | Description |
76
+ | --- | --- | --- |
77
+ | `id` | `string` | Unique within the list. |
78
+ | `title` | `string` | The question. |
79
+ | `detail` | `string?` | One quiet line: evidence or cost. |
80
+ | `primary` | `string` | Label of the solid answer. |
81
+ | `secondary` | `string` | Label of the outlined answer. |
82
+ | `collapsed` | `boolean?` | Starts folded to its question; opens on click or after the decision before it folds. |
83
+
84
+ ## DecisionAnswer
85
+
86
+ | Field | Type | Description |
87
+ | --- | --- | --- |
88
+ | `(union)` | `'primary' \| 'secondary'` | Which answer was picked. |
89
+
90
+ ## DecisionEvent
91
+
92
+ | Field | Type | Description |
93
+ | --- | --- | --- |
94
+ | `decision` | `Decision` | The answered decision. |
95
+ | `answer` | `DecisionAnswer` | Which answer was picked. |
96
+
97
+ ## DecisionInboxLabels
98
+
99
+ | Field | Type | Description |
100
+ | --- | --- | --- |
101
+ | `pending` | `(count: number) => string` | Header while decisions wait. Default "1 needs your input" / "n need your input". |
102
+ | `done` | `string` | Header when none are left. Default "All caught up". |
103
+ | `empty` | `string` | Quiet line under it. |
104
+ | `answered` | `string` | Spoken before the chosen answer. Default "Answered:". |
105
+
106
+ ## CSS variables
107
+
108
+ | Variable | Default | Description |
109
+ | --- | --- | --- |
110
+ | `--ui-decision-inbox-radius` | `10px; Classic 16px` | Corners; in Classic the panel, with the tray 6px around it. |
111
+ | `--ui-decision-inbox-pending` | `var(--ui-hue-amber); Classic orange darkened to 4.5:1` | Header icon while decisions wait; Classic header text too. |
112
+ | `--ui-decision-inbox-confirm-fg` | `green darkened to 4.5:1 (light), var(--ui-hue-green) (dark)` | Chosen answer and the done check. |
113
+ | `--ui-decision-inbox-confirm-bg` | `var(--ui-success-soft)` | Tint behind the chosen answer; none in Classic. |
114
+
115
+ ## Keyboard
116
+
117
+ | Keys | Action |
118
+ | --- | --- |
119
+ | Tab | Moves between answers and folded decisions. |
120
+ | Enter Space | Picks the focused answer, or opens and closes a folded decision. |
121
+
122
+ ## Accessibility
123
+ - A region named by its header, which is a heading (headingLevel). Each answer pair is a group named by its question.
124
+ - One polite, atomic announcement per answer: "Answered: <label>. <header>".
125
+ - Focus moves to the confirmation, then to the next waiting decision when the row folds, then to the empty line.
126
+ - Folding rows are inert. Coloured text is darkened to 4.5:1; forced colors give the answers a ButtonText edge.
@@ -0,0 +1,155 @@
1
+ # Dialog
2
+
3
+ A modal window on a dimmed backdrop: a fixed header and footer around content that scrolls, focus kept inside, a sheet on phones, and an alert dialog that confirms before something can't be undone.
4
+
5
+ Add: `npx ochreui@latest add dialog`
6
+ Import: `import { UiDialog, UiAlertDialog, UiDialogTrigger, UiDialogClose } from './ui/dialog';`
7
+ Selector: `<ui-dialog>`
8
+ Docs: /components/dialog
9
+
10
+ ## When to use
11
+ - A task that needs full attention first: editing, inviting people, connecting an account.
12
+ - A confirmation before something irreversible: use ui-alert-dialog.
13
+ - Content that opens over the page and returns to the same place on close.
14
+
15
+ ## When not to use
16
+ - A short form next to its button: use Popover.
17
+ - A list of actions: use Dropdown Menu.
18
+ - Searching and running commands: use Command Menu.
19
+ - A status after an action: use a toast (an undo is often kinder than a confirm).
20
+ - Nothing to show yet: use Empty State.
21
+
22
+ ## Usage
23
+
24
+ ```ts
25
+ import { Component, signal } from '@angular/core';
26
+ import { FormField, form, required } from '@angular/forms/signals';
27
+ import { UiButton } from './ui/button';
28
+ import { UiDialog, UiDialogClose, UiDialogTrigger } from './ui/dialog';
29
+ import { UiInput, UiTextField } from './ui/text-field';
30
+
31
+ @Component({
32
+ selector: 'app-edit-report',
33
+ imports: [UiButton, UiDialog, UiDialogClose, UiDialogTrigger, UiTextField, UiInput, FormField],
34
+ template: `
35
+ <button type="button" uiButton variant="secondary" [uiDialogTrigger]="edit">Edit</button>
36
+ <ui-dialog #edit [(open)]="editing" heading="Edit report" description="Changes apply from the next send.">
37
+ <form id="edit-report" (submit)="save($event)">
38
+ <ui-text-field label="Name">
39
+ <input uiInput [formField]="f.name" />
40
+ </ui-text-field>
41
+ </form>
42
+ <div uiDialogFooter>
43
+ <button type="button" uiButton variant="secondary" uiDialogClose>Cancel</button>
44
+ <button type="submit" form="edit-report" uiButton [disabled]="f().invalid()">Save</button>
45
+ </div>
46
+ </ui-dialog>
47
+ `,
48
+ })
49
+ export class EditReport {
50
+ protected readonly editing = signal(false);
51
+ private readonly model = signal({ name: 'Weekly revenue summary' });
52
+ protected readonly f = form(this.model, (p) => {
53
+ required(p.name);
54
+ });
55
+
56
+ protected save(event: Event) {
57
+ event.preventDefault();
58
+ this.editing.set(false);
59
+ }
60
+ }
61
+ ```
62
+
63
+ ## Rules
64
+ - Use heading, not title, for the dialog title.
65
+ - Put footer buttons in an element marked uiDialogFooter; use uiDialogClose for Cancel.
66
+ - contained needs a parent with position: relative.
67
+ - If the trigger is removed (e.g. after deleting), move focus in (closed).
68
+ - Requires button.ts (ui-alert-dialog uses uiButton) and overlay.ts (the Escape and outside-press layer shared with popovers and menus) next to dialog.ts; the CLI adds both.
69
+
70
+ ## Inputs
71
+
72
+ | Name | Type | Default | Description |
73
+ | --- | --- | --- | --- |
74
+ | `open` | `boolean` | false | Shows it. Two-way [(open)]; turns false when the person closes it. |
75
+ | `heading` | `string` | none | Title and accessible name. Or project [uiDialogHeading]. |
76
+ | `description` | `string` | none | Quiet line under the title (aria-describedby). Or project [uiDialogDescription]. |
77
+ | `size` | `'sm' \| 'md' \| 'lg'` | 'md' | 400, 480 or 720px wide, never wider than the window. |
78
+ | `width` | `number \| string` | none | Any width instead of a size (number = px). |
79
+ | `closeOnBackdrop` | `boolean` | true | A press on the dim closes it; when off the card pulses. |
80
+ | `closeButton` | `boolean` | true | The × in the corner. |
81
+ | `contained` | `boolean` | false | Covers its nearest positioned parent instead of the window. |
82
+ | `initialFocus` | `HTMLElement \| ElementRef<HTMLElement> \| null` | none | Gets focus on open. Default: [autofocus], first control in content, then footer, else the card. Never the ×. |
83
+ | `busy` | `boolean` | false | Escape, the dim, the × and uiDialogClose do nothing; aria-busy set; labels.busy announced. |
84
+ | `role` | `'dialog' \| 'alertdialog'` | 'dialog' | ui-alert-dialog sets alertdialog. |
85
+ | `id` | `string` | generated | The native dialog's id (aria-controls). |
86
+ | `labels` | `Partial<DialogLabels>` | { close: 'Close', busy: 'Working…' } | The ×'s name and the busy announcement. |
87
+ | `uiDialogTrigger (UiDialogTrigger)` | `UiDialog \| UiAlertDialog` | required | On the button: opens it, sets aria-haspopup, aria-expanded and aria-controls, gets focus back. |
88
+ | `cancelLabel (UiAlertDialog)` | `string` | 'Cancel' | The safe button, focused on open. |
89
+ | `confirmLabel (UiAlertDialog)` | `string` | 'Confirm' | The button that goes ahead. |
90
+ | `danger (UiAlertDialog)` | `boolean` | false | Confirm turns destructive. |
91
+ | `action (UiAlertDialog)` | `() => unknown` | none | Called on confirm. A returned promise keeps it open and busy; resolve closes, reject stays open and emits failed. |
92
+
93
+ ## Outputs
94
+
95
+ | Name | Payload | Description |
96
+ | --- | --- | --- |
97
+ | `openChange` | `boolean` | Every change of open. |
98
+ | `closed` | `'escape' \| 'backdrop' \| 'close-button' \| 'action' \| 'cancel' \| 'confirm'` | After it closed and focus went back. Move focus here if the trigger is gone. |
99
+ | `confirmed (UiAlertDialog)` | `void` | Confirm pressed, before a returned promise settles. |
100
+ | `failed (UiAlertDialog)` | `unknown` | The action's promise rejected or it threw; stays open. |
101
+
102
+ ## DialogSize
103
+
104
+ `type DialogSize = 'sm' | 'md' | 'lg'`
105
+
106
+ ## DialogCloseReason
107
+
108
+ `type DialogCloseReason = 'escape' | 'backdrop' | 'close-button' | 'action' | 'cancel' | 'confirm'`
109
+
110
+ ## DialogLabels
111
+
112
+ `type DialogLabels = { close: string; busy: string }`
113
+
114
+ ## Template: uiDialogFooter
115
+
116
+ Marks the footer: a wrapper whose buttons line up at the end, or a single button. Context: `none`.
117
+
118
+ ```html
119
+ <div uiDialogFooter>
120
+ <button uiButton variant="secondary" uiDialogClose>Cancel</button>
121
+ <button uiButton>Save</button>
122
+ </div>
123
+ ```
124
+
125
+ ## Template: uiDialogHeading / uiDialogDescription
126
+
127
+ Rich heading or description instead of the string inputs. Context: `none`.
128
+
129
+ ```html
130
+ <span uiDialogHeading>Delete <b>3 reports</b>?</span>
131
+ ```
132
+
133
+ ## CSS variables
134
+
135
+ | Variable | Default | Description |
136
+ | --- | --- | --- |
137
+ | `--ui-dialog-scrim` | `color-mix(in srgb, var(--ui-bg-scrim) 40%, transparent)` | The dim behind the card. |
138
+ | `--ui-dialog-radius` | `14px (Classic 20px, inner panel 16px)` | Card corners. |
139
+ | `--ui-dialog-shadow` | `var(--ui-shadow-lg)` | Card ring and drop shadow. |
140
+
141
+ ## Keyboard
142
+
143
+ | Keys | Action |
144
+ | --- | --- |
145
+ | Tab / Shift+Tab | Moves through the controls inside and goes round. |
146
+ | Escape | Closes (alert: cancels). A popover or menu inside closes first. Ignored while busy. |
147
+ | Enter | Activates the focused button (the safe one first in an alert); in a field, submits your form. |
148
+
149
+ ## Accessibility
150
+ - Native <dialog> with showModal(): page inert, top layer; contained mode adds aria-modal and its own Tab loop.
151
+ - Named by the heading (aria-labelledby), described by the description; ui-alert-dialog has role=alertdialog.
152
+ - Focus goes to [autofocus] or the first control, never the ×, and returns to the trigger on close.
153
+ - Busy: confirm keeps focus with aria-busy, cancel is aria-disabled (not disabled), dialog has aria-busy and a polite live region.
154
+ - A refused press on the dim keeps focus; the × has one name (aria-label, no title).
155
+ - Forced colors: 2px card edge.
@@ -0,0 +1,144 @@
1
+ # Dropdown Menu
2
+
3
+ Actions and choices behind any button: icons, shortcuts, checks, red rows and submenus, with a gliding highlight, typeahead and the full menu keyboard. Your own buttons and links are the rows.
4
+
5
+ Add: `npx ochreui@latest add dropdown-menu`
6
+ Import: `import { UiMenu, UiMenuTrigger, UiMenuItem, UiMenuItemCheckbox, UiMenuItemRadio, UiMenuGroup, UiMenuSeparator, UiMenuLabel, UiMenuIcon } from './ui/dropdown-menu';`
7
+ Selector: `<ui-menu>`
8
+ Docs: /components/dropdown-menu
9
+
10
+ ## When to use
11
+ - Actions on one thing behind a ⋯ button: open, duplicate, move, delete.
12
+ - A short choice that changes the view at once (sort, density), shown with a check.
13
+ - Account and workspace menus with a header and submenus.
14
+
15
+ ## When not to use
16
+ - Picking a value for a form field: use Select.
17
+ - Searching many commands or pages: use a command menu.
18
+ - A short form or explanation next to a button: use Popover.
19
+ - Filters with several groups and counts: use Filter Menu.
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { Component, signal } from '@angular/core';
25
+ import { UiButton } from './ui/button';
26
+ import { UiMenu, UiMenuGroup, UiMenuIcon, UiMenuItem, UiMenuItemRadio, UiMenuSeparator, UiMenuTrigger } from './ui/dropdown-menu';
27
+
28
+ @Component({
29
+ selector: 'app-report-actions',
30
+ imports: [UiButton, UiMenu, UiMenuTrigger, UiMenuItem, UiMenuItemRadio, UiMenuGroup, UiMenuSeparator, UiMenuIcon],
31
+ template: `
32
+ <button type="button" uiButton variant="secondary" [uiMenuTrigger]="actions">Actions</button>
33
+ <ui-menu #actions align="end">
34
+ <button uiMenuItem shortcut="⌘D" keys="Meta+D" (selected)="duplicate()">
35
+ <svg uiMenuIcon viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M8.5 8.5h11v11h-11zM15.5 8.5v-4h-11v11h4" /></svg>
36
+ Duplicate
37
+ </button>
38
+ <button uiMenuItem [uiSubmenu]="folders">Move to</button>
39
+ <ui-menu-separator />
40
+ <button uiMenuItem danger (selected)="remove()">Delete report</button>
41
+ </ui-menu>
42
+ <ui-menu #folders>
43
+ <ui-menu-group [(value)]="folder">
44
+ <button uiMenuItemRadio value="finance">Finance</button>
45
+ <button uiMenuItemRadio value="sales">Sales</button>
46
+ <button uiMenuItemRadio value="archive">Archive</button>
47
+ </ui-menu-group>
48
+ </ui-menu>
49
+ `,
50
+ })
51
+ export class ReportActions {
52
+ protected readonly folder = signal('finance');
53
+
54
+ protected duplicate() {}
55
+ protected remove() {}
56
+ }
57
+ ```
58
+
59
+ ## Rules
60
+ - Write <ui-menu> right after its trigger; a submenu is another <ui-menu> referenced with [uiSubmenu].
61
+ - Rows are your own <button> or <a> with uiMenuItem; checkbox and radio rows are <button> only.
62
+ - Put radio rows in <ui-menu-group [(value)]>; mark row icons with uiMenuIcon.
63
+ - Give the trigger a name (text or aria-label), or give the menu a title or aria-label.
64
+ - Shortcuts are display only: wire the keys yourself and pass keys="Meta+D" for screen readers.
65
+ - Needs overlay.ts next to dropdown-menu.ts (the CLI adds it): the placement, Escape and outside-press layer shared by the floating components.
66
+
67
+ ## Inputs
68
+
69
+ | Name | Type | Default | Description |
70
+ | --- | --- | --- | --- |
71
+ | `open` | `boolean` | false | Shows it. Two-way [(open)]; the trigger also opens and closes it. |
72
+ | `side` | `'bottom' \| 'top'` | 'bottom' | Preferred side; flips to the side with more room. |
73
+ | `align` | `'start' \| 'end'` | 'start' | Edges that line up (logical in RTL); switches when it would stick out. |
74
+ | `offset` | `number` | 6 | Gap to the trigger in px. |
75
+ | `title` | `string` | none | Small grey heading above the rows; the menu’s name. |
76
+ | `width` | `number \| string` | none | Panel width (number = px). Default fits the rows, 168px (Classic 180px) to 320px. |
77
+ | `aria-label` | `string` | none | Menu name when there is no title; else the trigger names it. |
78
+ | `labels` | `Partial<MenuLabels>` | { empty: 'Nothing here yet' } | Visible strings. |
79
+ | `id` | `string` | generated | Panel id; the role=menu element is {id}-list. |
80
+ | `uiMenuTrigger (UiMenuTrigger)` | `UiMenu` | required | On the button: toggles on click, opens with Enter, Space, ↓ (checked row, else first) and ↑ (last); sets aria-haspopup, aria-expanded, aria-controls and an id. |
81
+ | `disabled (rows)` | `boolean` | false | aria-disabled; faint, skipped by arrows and typeahead, inert on click. |
82
+ | `danger (rows)` | `boolean` | false | Red label, icon and highlight. |
83
+ | `keepOpen (rows)` | `boolean` | false | The menu stays open after the pick. |
84
+ | `shortcut (rows)` | `string` | none | Shown at the end, hidden from screen readers. Display only. |
85
+ | `keys (rows)` | `string` | none | aria-keyshortcuts, such as Meta+D. |
86
+ | `description (rows)` | `string` | none | Quiet second line; the row’s description. |
87
+ | `textValue (rows)` | `string` | the row text | What typeahead matches. |
88
+ | `uiSubmenu (rows)` | `UiMenu` | none | Opens that menu beside the row; adds the chevron. |
89
+ | `checked (UiMenuItemCheckbox)` | `boolean` | false | Two-way [(checked)]; also [formField], formControl, ngModel. |
90
+ | `value (UiMenuItemRadio)` | `unknown` | required | Checked when it equals the group value. |
91
+ | `value (UiMenuGroup)` | `T` | undefined | The picked radio value. [(value)], [formField], formControl, ngModel. |
92
+ | `label (UiMenuGroup)` | `string` | none | Small heading and the group’s name. |
93
+ | `disabled (UiMenuGroup)` | `boolean` | false | Disables every row in the group. |
94
+
95
+ ## Outputs
96
+
97
+ | Name | Payload | Description |
98
+ | --- | --- | --- |
99
+ | `openChange` | `boolean` | Every change of open. |
100
+ | `closed` | `'select' \| 'escape' \| 'outside' \| 'focus-out' \| 'tab' \| 'trigger'` | Why it closed, before open turns false. |
101
+ | `selected (rows)` | `void` | Row clicked or picked with Enter or Space (not submenu rows). |
102
+ | `checkedChange (UiMenuItemCheckbox)` | `boolean` | Every change of checked. |
103
+ | `valueChange (UiMenuGroup)` | `T` | Every change of value. |
104
+
105
+ ## MenuLabels
106
+
107
+ | Field | Type | Description |
108
+ | --- | --- | --- |
109
+ | `empty` | `string` | Shown when the menu has no rows. |
110
+
111
+ ## CSS variables
112
+
113
+ | Variable | Default | Description |
114
+ | --- | --- | --- |
115
+ | `--ui-menu-bg` | `var(--ui-bg-overlay)` | Panel fill. |
116
+ | `--ui-menu-shadow` | `0.5px ring + soft drop (Classic: 1px ring + two drops)` | Ring and shadow. |
117
+ | `--ui-menu-radius` | `12px (Classic 14px)` | Panel corners; rows stay concentric. |
118
+ | `--ui-menu-pad` | `4px (Classic 5px)` | Space around the rows. |
119
+ | `--ui-menu-min-width` | `168px (Classic 180px)` | Narrowest panel. |
120
+ | `--ui-menu-max-width` | `320px` | Widest panel; labels truncate. |
121
+ | `--ui-menu-trigger-w` | `set while open` | The trigger’s width, for width="var(--ui-menu-trigger-w)". |
122
+
123
+ ## Keyboard
124
+
125
+ | Keys | Action |
126
+ | --- | --- |
127
+ | Enter / Space / ArrowDown | On the trigger: open on the checked row (radio or checkbox), else the first row. |
128
+ | ArrowUp | On the trigger: open on the last row. |
129
+ | ArrowDown / ArrowUp | Next / previous row, wrapping; disabled skipped. |
130
+ | Home / End | First / last row. |
131
+ | Letters | Typeahead; the same letter again cycles. |
132
+ | Enter / Space | Pick and close (unless keepOpen); on a submenu row, open it. |
133
+ | ArrowRight / ArrowLeft | Open a submenu / go back; swapped in RTL. |
134
+ | Escape | Close the innermost menu; focus to its row or the trigger. |
135
+ | Tab | Close all; focus moves on from the trigger. |
136
+
137
+ ## Accessibility
138
+ - Menu-button pattern: aria-haspopup, aria-expanded, aria-controls; menuitem, menuitemcheckbox and menuitemradio with aria-checked.
139
+ - Roving real focus over tabindex=-1 rows; ring on :focus-visible only.
140
+ - Shortcuts aria-hidden, given as aria-keyshortcuts; the row name is the label only.
141
+ - Pointer open focuses the menu element with no active row; keyboard open focuses the checked row (radio or checkbox) or the first.
142
+ - Title ≥ 4.5:1; danger ≥ 4.5:1 at rest and on its highlight and red in every state; shortcuts and chevron ≈ 3:1 (shortcuts are also aria-keyshortcuts).
143
+ - Forced colors: panel edge, visible separators, Highlight on the active row.
144
+ - Dev-mode warning for a nameless menu and icon-only rows.
@@ -0,0 +1,182 @@
1
+ # Email Draft
2
+
3
+ An email an agent wrote, for a person to check before it goes out: pick the recipient and the tone, edit the text in place, drop or re-add the attachment, then send or discard it, with Undo.
4
+
5
+ Add: `npx ochreui@latest add email-draft`
6
+ Import: `import { UiEmailDraft, UiEmailDraftButton, UiEmailDraftTo } from './ui/email-draft';`
7
+ Selector: `<ui-email-draft>`
8
+ Docs: /components/email-draft
9
+
10
+ ## When to use
11
+ - An agent wrote an email and a person approves it: payment reminders, renewals, follow-ups.
12
+ - A review queue of outreach, one card per invoice, deal or ticket.
13
+
14
+ ## When not to use
15
+ - Writing a long email from scratch: use a full editor.
16
+ - Messages sent without review: an activity row is enough.
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ import { Component, signal } from '@angular/core';
22
+ import { DraftContact, DraftTone, EmailDraftPayload, EmailDraftState, UiEmailDraft } from './ui/email-draft';
23
+
24
+ const hi = (c: DraftContact) => c.greeting ?? c.name.split(' ')[0];
25
+
26
+ @Component({
27
+ selector: 'app-invoice-reminder',
28
+ imports: [UiEmailDraft],
29
+ template: `
30
+ <ui-email-draft
31
+ reference="INV-2041"
32
+ status="Due in 3 days"
33
+ amount="€1,240"
34
+ account="Harbor & Co"
35
+ agent="Billing agent"
36
+ [contacts]="contacts"
37
+ [tones]="tones"
38
+ [(attachment)]="file"
39
+ [link]="{ label: 'View invoice', href: '/invoices/2041' }"
40
+ [(state)]="state"
41
+ [error]="error()"
42
+ (send)="deliver($event)"
43
+ />
44
+ `,
45
+ })
46
+ export class InvoiceReminder {
47
+ protected readonly contacts: DraftContact[] = [
48
+ { name: 'Maya Chen', email: 'maya@harborco.com' },
49
+ { name: 'Accounts payable', email: 'ap@harborco.com', greeting: 'team', initials: 'AP' },
50
+ ];
51
+ protected readonly tones: DraftTone[] = [
52
+ { id: 'friendly', label: 'Friendly', body: (c) => `Hi ${hi(c)}, a quick note that invoice 2041 for €1,240 is due this Friday:` },
53
+ { id: 'brief', label: 'Brief', body: (c) => `Hi ${hi(c)}, invoice 2041 is due on Friday:` },
54
+ { id: 'formal', label: 'Formal', body: (c) => `Dear ${c.name}, payment of €1,240 for invoice 2041 is due on Friday:` },
55
+ ];
56
+ protected readonly file = signal<string | null>('Invoice-2041.pdf');
57
+ protected readonly state = signal<EmailDraftState>('draft');
58
+ protected readonly error = signal<string | null>(null);
59
+
60
+ protected async deliver(email: EmailDraftPayload) {
61
+ this.error.set(null);
62
+ const res = await fetch('/api/emails', { method: 'POST', body: JSON.stringify(email) }).catch(() => null);
63
+ if (res?.ok) {
64
+ this.state.set('sent');
65
+ } else {
66
+ this.state.set('draft');
67
+ this.error.set('The email could not be sent. Check your connection and try again.');
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ ## Rules
74
+ - Send sets state to 'sending' and emits; you set 'sent' after delivery, or 'draft' plus error on failure.
75
+ - Bind [(state)] (or update state yourself), otherwise the card stays on 'sending'.
76
+ - Undo is never time-limited; delay real delivery and cancel on (undo) if Undo must stop the email.
77
+ - Ship your own tone texts; there are no defaults.
78
+ - Not a form control: read the payload from (send) or bind [(body)], [(to)] and [(attachment)].
79
+
80
+ ## Inputs
81
+
82
+ | Name | Type | Default | Description |
83
+ | --- | --- | --- | --- |
84
+ | `reference` | `string` | none | What the email is about; also names the card. |
85
+ | `account` | `string` | none | Account or company under the reference. |
86
+ | `amount` | `string` | none | Formatted amount at the end of the header. |
87
+ | `status` | `string` | none | Chip after the reference. |
88
+ | `statusTone` | `'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger'` | 'warning' | Chip colour. |
89
+ | `agent` | `string` | none | Who wrote the draft, in the last row. |
90
+ | `contacts` | `DraftContact[]` | required | People the email can go to. |
91
+ | `to` | `DraftContact \| null` | null | Two-way. The recipient; null means the first contact. |
92
+ | `tones` | `DraftTone[]` | [] | Text versions; the tone buttons hide when empty. |
93
+ | `tone` | `string \| null` | null | Two-way. Pressed tone; the first when there is no body; null after a hand edit. |
94
+ | `body` | `string` | '' | Two-way. The email text; a pressed tone rewrites it when the recipient changes. |
95
+ | `attachment` | `string \| null` | null | Two-way. Attached file name; removing keeps the name to add it back. |
96
+ | `attachable` | `string \| null` | null | A file that can be attached when the draft starts without one. |
97
+ | `link` | `DraftLink \| null` | null | Link after the text; sent in the payload, not in body. |
98
+ | `state` | `'draft' \| 'sending' \| 'sent' \| 'discarded'` | 'draft' | Two-way. Send sets 'sending'; set 'sent' on success or 'draft' with error on failure. |
99
+ | `error` | `string \| null` | null | Failed-send message with Retry; cleared by the next edit or send. |
100
+ | `submitShortcut` | `boolean` | true | ⌘ Enter / Ctrl Enter in the text sends. |
101
+ | `labels` | `Partial<EmailDraftLabels>` | English | Every visible and spoken string. |
102
+ | `aria-label` | `string` | none | Card name when there is no reference. |
103
+
104
+ ## Outputs
105
+
106
+ | Name | Payload | Description |
107
+ | --- | --- | --- |
108
+ | `send` | `EmailDraftPayload` | Send, Retry or the shortcut. state is now 'sending'. |
109
+ | `discard` | `void` | Discard pressed; the card shows the discarded receipt with Undo. |
110
+ | `undo` | `'sent' \| 'discarded'` | Undo pressed; recipient, text, tone and attachment are restored. |
111
+
112
+ ## DraftContact
113
+
114
+ | Field | Type | Description |
115
+ | --- | --- | --- |
116
+ | `name` | `string` | Shown in the recipient button and list. |
117
+ | `email` | `string` | Address. |
118
+ | `initials` | `string?` | Avatar letters; default from the name. |
119
+ | `greeting` | `string?` | How tone bodies address them ("team"). Not read by the component. |
120
+
121
+ ## DraftTone
122
+
123
+ | Field | Type | Description |
124
+ | --- | --- | --- |
125
+ | `id` | `string` | Unique id. |
126
+ | `label` | `string` | Button text. |
127
+ | `body` | `(to: DraftContact) => string` | The text written for that recipient. |
128
+
129
+ ## DraftLink
130
+
131
+ | Field | Type | Description |
132
+ | --- | --- | --- |
133
+ | `label` | `string` | Link text. |
134
+ | `href` | `string` | Target. |
135
+
136
+ ## EmailDraftPayload
137
+
138
+ | Field | Type | Description |
139
+ | --- | --- | --- |
140
+ | `to` | `DraftContact` | Recipient. |
141
+ | `body` | `string` | Final text. |
142
+ | `attachment` | `string \| null` | Attached file, if any. |
143
+ | `tone` | `string \| null` | Pressed tone; null when edited by hand. |
144
+ | `link` | `DraftLink \| null` | The link input. |
145
+
146
+ ## EmailDraftLabels
147
+
148
+ | Field | Type | Description |
149
+ | --- | --- | --- |
150
+ | `to, recipient, tone, edit, body, clickToEdit` | `string` | "To", list name, tone group name, Edit button, field name, text tooltip. |
151
+ | `attach, remove` | `(file: string) => string` | "Attach {file}", "Remove {file}". |
152
+ | `shortcut` | `(key: string) => string` | Hint; key is ⌘ on Apple devices, Ctrl elsewhere. |
153
+ | `emptyHint` | `string` | Replaces the hint while the text is empty: "Write the email to send it". |
154
+ | `discard, send, sending, undo, retry` | `string` | Button texts. |
155
+ | `sentTo, with, discarded, restored` | `string` | Receipt and announcement pieces. |
156
+ | `ready, sentChip, discardedChip` | `string` | State chip texts. |
157
+
158
+ ## CSS variables
159
+
160
+ | Variable | Default | Description |
161
+ | --- | --- | --- |
162
+ | `--ui-email-draft-max` | `calc(480px + 40px * var(--ui-look-tray))` | Widest the card grows (Classic 520px). |
163
+
164
+ ## Keyboard
165
+
166
+ | Keys | Action |
167
+ | --- | --- |
168
+ | Enter Space ↓ ↑ | On the recipient: opens the list on the current person (↑ starts at the last). |
169
+ | ↓ ↑ Home End, letters | In the list: move; typing jumps to a name. |
170
+ | Enter Space | In the list: pick and return to the recipient button. |
171
+ | Esc | Closes the list, or leaves the text and focuses Edit. |
172
+ | ⌘ Enter / Ctrl Enter | In the text: sends. |
173
+ | Tab | Recipient, attachment, link, tones, Edit, Discard, Send; Undo after sending. |
174
+
175
+ ## Accessibility
176
+ - role=group named by reference and account; the recipient button is named "To" plus the person.
177
+ - Recipient: aria-haspopup=listbox button and a listbox with aria-activedescendant, arrows, Home/End and typeahead.
178
+ - Tones are aria-pressed toggles in a named group; Edit is a separate aria-pressed toggle; the field has aria-keyshortcuts.
179
+ - Focus moves deliberately on every swap: list close, edit exit, attachment remove/add, send, discard, undo.
180
+ - While the text is empty, Send is aria-disabled and described by the hint, which says why.
181
+ - One persistent role=status region announces sending, sent, discarded, restored and errors.
182
+ - Forced colors: buttons keep edges; pressed tone and highlighted person use Highlight.