@eodparks/ui 0.0.0-stage → 0.2.0

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 (176) hide show
  1. package/LICENSE +21 -0
  2. package/dist/accordion.d.ts +36 -0
  3. package/dist/accordion.js +57 -0
  4. package/dist/alert-dialog.d.ts +50 -0
  5. package/dist/alert-dialog.js +149 -0
  6. package/dist/alert.d.ts +23 -0
  7. package/dist/alert.js +87 -0
  8. package/dist/avatar.d.ts +35 -0
  9. package/dist/avatar.js +118 -0
  10. package/dist/badge.d.ts +27 -0
  11. package/dist/badge.js +148 -0
  12. package/dist/button-C2CCxHu1.d.ts +15 -0
  13. package/dist/button-DEsRlveL.js +86 -0
  14. package/dist/button.d.ts +2 -0
  15. package/dist/button.js +1 -0
  16. package/dist/calendar-DhsRPq2D.d.ts +23 -0
  17. package/dist/calendar-kbn4gZ1a.js +110 -0
  18. package/dist/calendar.d.ts +2 -0
  19. package/dist/calendar.js +1 -0
  20. package/dist/card-tkP52GwZ.js +77 -0
  21. package/dist/card.d.ts +18 -0
  22. package/dist/card.js +1 -0
  23. package/dist/chart.d.ts +52 -0
  24. package/dist/chart.js +163 -0
  25. package/dist/checkbox.d.ts +7 -0
  26. package/dist/checkbox.js +26 -0
  27. package/dist/cn-B-fHM4Ov.js +12 -0
  28. package/dist/collapsible.d.ts +10 -0
  29. package/dist/collapsible.js +23 -0
  30. package/dist/command.d.ts +38 -0
  31. package/dist/command.js +124 -0
  32. package/dist/date-picker.d.ts +46 -0
  33. package/dist/date-picker.js +159 -0
  34. package/dist/dialog-JjpMFEDR.js +117 -0
  35. package/dist/dialog.d.ts +2 -0
  36. package/dist/dialog.js +3 -0
  37. package/dist/dropdown-menu-B_VG1VXX.js +116 -0
  38. package/dist/dropdown-menu-CZ8xcq1d.d.ts +38 -0
  39. package/dist/dropdown-menu.d.ts +2 -0
  40. package/dist/dropdown-menu.js +1 -0
  41. package/dist/empty-state-B11Uq0U_.js +66 -0
  42. package/dist/empty-state.d.ts +15 -0
  43. package/dist/empty-state.js +1 -0
  44. package/dist/error-state.d.ts +48 -0
  45. package/dist/error-state.js +139 -0
  46. package/dist/field-Cwhz73-_.d.ts +15 -0
  47. package/dist/field-D-n7O1n6.js +63 -0
  48. package/dist/field.d.ts +2 -0
  49. package/dist/field.js +1 -0
  50. package/dist/focus-ring-BpxMbGAn.js +3 -0
  51. package/dist/form-actions.d.ts +21 -0
  52. package/dist/form-actions.js +41 -0
  53. package/dist/forms/formik.d.ts +20 -0
  54. package/dist/forms/formik.js +50 -0
  55. package/dist/forms/rhf.d.ts +32 -0
  56. package/dist/forms/rhf.js +114 -0
  57. package/dist/icon-button-XAjcFsZ2.js +14 -0
  58. package/dist/icon-button.d.ts +9 -0
  59. package/dist/icon-button.js +1 -0
  60. package/dist/icon.d.ts +15 -0
  61. package/dist/icon.js +21 -0
  62. package/dist/index-Ct4mPvuB.d.ts +29 -0
  63. package/dist/input-BxjcqQS1.js +49 -0
  64. package/dist/input-group.d.ts +12 -0
  65. package/dist/input-group.js +26 -0
  66. package/dist/input.d.ts +15 -0
  67. package/dist/input.js +1 -0
  68. package/dist/label-BrOAJU1p.js +31 -0
  69. package/dist/label-CUAiaBbm.d.ts +13 -0
  70. package/dist/label.d.ts +2 -0
  71. package/dist/label.js +1 -0
  72. package/dist/native-select.d.ts +8 -0
  73. package/dist/native-select.js +41 -0
  74. package/dist/page-header.d.ts +19 -0
  75. package/dist/page-header.js +51 -0
  76. package/dist/pagination.d.ts +47 -0
  77. package/dist/pagination.js +131 -0
  78. package/dist/password-input.d.ts +14 -0
  79. package/dist/password-input.js +41 -0
  80. package/dist/popover.d.ts +19 -0
  81. package/dist/popover.js +54 -0
  82. package/dist/popup-CLsuJ-AA.js +6 -0
  83. package/dist/progress.d.ts +8 -0
  84. package/dist/progress.js +36 -0
  85. package/dist/radio-group.d.ts +14 -0
  86. package/dist/radio-group.js +25 -0
  87. package/dist/scroll-area.d.ts +16 -0
  88. package/dist/scroll-area.js +52 -0
  89. package/dist/select-Cq_JDuYO.js +266 -0
  90. package/dist/select.d.ts +40 -0
  91. package/dist/select.js +1 -0
  92. package/dist/separator.d.ts +8 -0
  93. package/dist/separator.js +38 -0
  94. package/dist/sheet.d.ts +27 -0
  95. package/dist/sheet.js +95 -0
  96. package/dist/skeleton.d.ts +19 -0
  97. package/dist/skeleton.js +45 -0
  98. package/dist/spinner.d.ts +13 -0
  99. package/dist/spinner.js +44 -0
  100. package/dist/switch.d.ts +7 -0
  101. package/dist/switch.js +19 -0
  102. package/dist/table.d.ts +24 -0
  103. package/dist/table.js +75 -0
  104. package/dist/tabs.d.ts +24 -0
  105. package/dist/tabs.js +74 -0
  106. package/dist/textarea.d.ts +5 -0
  107. package/dist/textarea.js +15 -0
  108. package/dist/theme-toggle.d.ts +11 -0
  109. package/dist/theme-toggle.js +50 -0
  110. package/dist/toast.d.ts +12 -0
  111. package/dist/toast.js +105 -0
  112. package/dist/tooltip-BsVKZDXs.js +47 -0
  113. package/dist/tooltip.d.ts +18 -0
  114. package/dist/tooltip.js +1 -0
  115. package/dist/typography-Dy3PCTrL.js +34 -0
  116. package/dist/typography.d.ts +11 -0
  117. package/dist/typography.js +1 -0
  118. package/dist/visually-hidden-BrCs6ZEy.js +11 -0
  119. package/dist/visually-hidden.d.ts +3 -0
  120. package/dist/visually-hidden.js +1 -0
  121. package/docs/accessibility.md +95 -0
  122. package/docs/accordion.md +89 -0
  123. package/docs/alert-dialog.md +157 -0
  124. package/docs/alert.md +70 -0
  125. package/docs/avatar.md +57 -0
  126. package/docs/badge.md +51 -0
  127. package/docs/button.md +121 -0
  128. package/docs/calendar.md +116 -0
  129. package/docs/card.md +74 -0
  130. package/docs/chart.md +93 -0
  131. package/docs/checkbox.md +119 -0
  132. package/docs/collapsible.md +76 -0
  133. package/docs/command.md +114 -0
  134. package/docs/date-picker.md +177 -0
  135. package/docs/dialog.md +110 -0
  136. package/docs/dropdown-menu.md +126 -0
  137. package/docs/empty-state.md +65 -0
  138. package/docs/error-state.md +59 -0
  139. package/docs/field.md +54 -0
  140. package/docs/form-actions.md +55 -0
  141. package/docs/forms/formik.md +42 -0
  142. package/docs/forms/rhf.md +64 -0
  143. package/docs/icon-button.md +84 -0
  144. package/docs/icon.md +77 -0
  145. package/docs/input-group.md +47 -0
  146. package/docs/input.md +46 -0
  147. package/docs/label.md +33 -0
  148. package/docs/layout.md +102 -0
  149. package/docs/llms.txt +72 -0
  150. package/docs/native-select.md +87 -0
  151. package/docs/page-header.md +61 -0
  152. package/docs/pagination.md +107 -0
  153. package/docs/password-input.md +30 -0
  154. package/docs/popover.md +103 -0
  155. package/docs/progress.md +53 -0
  156. package/docs/radio-group.md +119 -0
  157. package/docs/scroll-area.md +85 -0
  158. package/docs/select.md +106 -0
  159. package/docs/separator.md +38 -0
  160. package/docs/sheet.md +118 -0
  161. package/docs/skeleton.md +50 -0
  162. package/docs/spinner.md +46 -0
  163. package/docs/switch.md +92 -0
  164. package/docs/table.md +87 -0
  165. package/docs/tabs.md +96 -0
  166. package/docs/textarea.md +38 -0
  167. package/docs/theme-toggle.md +76 -0
  168. package/docs/toast.md +95 -0
  169. package/docs/tooltip.md +101 -0
  170. package/docs/typography.md +96 -0
  171. package/docs/visually-hidden.md +44 -0
  172. package/layer.css +22 -0
  173. package/package.json +275 -3
  174. package/skills/eod-ui/SKILL.md +37 -0
  175. package/styles.css +2 -0
  176. package/README.md +0 -3
@@ -0,0 +1,89 @@
1
+ # Accordion
2
+
3
+ Shows and hides sections of content from their headings, one at a time or several at once.
4
+
5
+ `e2e/accordion.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import {
11
+ Accordion,
12
+ AccordionContent,
13
+ AccordionItem,
14
+ AccordionTrigger,
15
+ } from "@eodparks/ui/accordion";
16
+
17
+ <Accordion type="single" collapsible defaultValue="shipping">
18
+ <AccordionItem value="shipping">
19
+ <AccordionTrigger>Shipping</AccordionTrigger>
20
+ <AccordionContent>Standard takes five to seven days.</AccordionContent>
21
+ </AccordionItem>
22
+ <AccordionItem value="returns">
23
+ <AccordionTrigger>Returns</AccordionTrigger>
24
+ <AccordionContent>Return any unused item within 30 days.</AccordionContent>
25
+ </AccordionItem>
26
+ </Accordion>;
27
+ ```
28
+
29
+ ## Parts
30
+
31
+ | Export | Is |
32
+ | ------------------ | ---------------------------------------------------------------------------- |
33
+ | `Accordion` | the root; `type` states whether one section or several can be open |
34
+ | `AccordionItem` | one section; takes `value` and `disabled`; has a bottom border |
35
+ | `AccordionTrigger` | the heading and its button, with a chevron after the children; takes `level` |
36
+ | `AccordionContent` | the panel; `className` goes on the inner wrapper that holds the content |
37
+
38
+ shadcn names, unchanged. UI SDK's `AccordionHeader` and `AccordionPanel` are inside these parts.
39
+
40
+ ## Props
41
+
42
+ | Prop | Type | Default | Notes |
43
+ | --------------------------------- | -------------------------------------- | -------- | ------------------------------------------------------------------ |
44
+ | `type` | `"single" \| "multiple"` | required | stated on purpose: see Expanding logic |
45
+ | `value`, `defaultValue` | `string`, or `string[]` for `multiple` | | `""` or `[]` means none open, never `null` |
46
+ | `onValueChange` | `(value, details) => void` | | `details` is UI SDK's `{ reason, event, cancel() }` |
47
+ | `collapsible` | `boolean` | `false` | `single` only; `false` keeps one section always open |
48
+ | `disabled` | `boolean` | `false` | on `Accordion` or on one `AccordionItem`; triggers stay focusable |
49
+ | `keepMounted`, `hiddenUntilFound` | `boolean` | | closed panels stay in the page, or stay findable with find in page |
50
+ | `AccordionTrigger` `level` | `2 \| 3 \| 4 \| 5 \| 6` | `3` | the heading level; pick one that fits the page outline |
51
+
52
+ Every part takes `className` and `render`, and carries a `data-slot`.
53
+
54
+ ## Variants
55
+
56
+ | Variant | How |
57
+ | -------- | ------------------------------------------------------------------------------- |
58
+ | single | `type="single"`; opening one closes the others; add `collapsible` to allow none |
59
+ | multiple | `type="multiple"`; sections open and close independently |
60
+
61
+ ## Expanding logic
62
+
63
+ `type` has no default. A FAQ or a settings list that wants one open section says `single`; a form with optional groups says `multiple`. With `single` and no `collapsible`, one section always stays open and its trigger reports `aria-disabled`.
64
+
65
+ ## States
66
+
67
+ | State | Source |
68
+ | --------- | --------------------------------------------------------------- |
69
+ | collapsed | `data-closed`, `aria-expanded="false"`, chevron down |
70
+ | expanded | `data-open`, `aria-expanded="true"`, chevron turned up |
71
+ | hover | the label is underlined; not on a disabled trigger |
72
+ | focus | the library focus ring, on keyboard focus only |
73
+ | disabled | `data-disabled`, `aria-disabled`, half opacity, still focusable |
74
+
75
+ ## Keyboard
76
+
77
+ Tab moves through every trigger in order, disabled ones included. Enter and Space toggle the focused section. Arrow keys do nothing: the pattern leaves them out.
78
+
79
+ ## Accessibility
80
+
81
+ Each trigger is a button in a heading and controls a panel labelled by it. The chevron is hidden from screen readers. Target is WCAG 2.2 AA, checked by axe on the states page in both themes. Screen reader checks (VoiceOver with Safari, NVDA with Chrome) are manual.
82
+
83
+ ## Motion
84
+
85
+ The panel animates its height in 200 ms and the chevron turns with it. Under `prefers-reduced-motion` both are instant.
86
+
87
+ ## Copy
88
+
89
+ The library ships no prose. Titles and content are children.
@@ -0,0 +1,157 @@
1
+ # Alert dialog
2
+
3
+ Asks a question that must be answered before an action continues, such as confirming a delete, built on UI SDK `alert-dialog` with shadcn-compatible part names.
4
+
5
+ Import from `@eodparks/ui/alert-dialog`.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ <AlertDialog>
11
+ <AlertDialogTrigger render={<Button variant="destructive" />}>Delete project</AlertDialogTrigger>
12
+ <AlertDialogContent>
13
+ <AlertDialogHeader>
14
+ <AlertDialogTitle>Delete this project?</AlertDialogTitle>
15
+ <AlertDialogDescription>
16
+ The project and its files are deleted. This cannot be undone.
17
+ </AlertDialogDescription>
18
+ </AlertDialogHeader>
19
+ <AlertDialogFooter>
20
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
21
+ <AlertDialogAction variant="destructive" action={deleteProject}>
22
+ Delete
23
+ </AlertDialogAction>
24
+ </AlertDialogFooter>
25
+ </AlertDialogContent>
26
+ </AlertDialog>
27
+ ```
28
+
29
+ From an event handler, without markup:
30
+
31
+ ```tsx
32
+ if (await confirm({ title: "Remove this member?", confirmLabel: "Remove", destructive: true }))
33
+ remove();
34
+ ```
35
+
36
+ Mount `<ConfirmHost />` once near the root of the app; it renders every `confirm()` question, one at a time.
37
+
38
+ ## Parts
39
+
40
+ | Part | Renders | Role |
41
+ | ------------------------- | -------- | --------------------------------------------------------------------------------------- |
42
+ | `AlertDialog` | none | Root. Holds open state. Always modal; a press outside never closes it. |
43
+ | `AlertDialogTrigger` | `button` | Opens the dialog. Also usable outside `AlertDialog` with a `controller`. |
44
+ | `AlertDialogContent` | `div` | The backdrop and the panel, in the top layer. |
45
+ | `AlertDialogHeader` | `div` | Stacks the title and description. |
46
+ | `AlertDialogFooter` | `div` | The actions. Stacked under `sm` with the confirm action on top, a row at the end above. |
47
+ | `AlertDialogTitle` | `h2` | The question. Names the dialog. |
48
+ | `AlertDialogDescription` | `p` | What agreeing does. Describes the dialog. |
49
+ | `AlertDialogCancel` | `button` | Closes without the confirm value. Put it first: opening focuses it. |
50
+ | `AlertDialogAction` | `button` | Closes with `value="confirm"`. Takes `variant` and an async `action`. |
51
+ | `AlertDialogConfirmField` | `div` | A labelled field; the action stays disabled until its value equals `phrase`. |
52
+ | `ConfirmHost` | none | Renders `confirm()` questions. |
53
+
54
+ `AlertDialogPortal` and `AlertDialogOverlay` from shadcn are not exported: the content owns the backdrop and renders in the top layer. `createAlertDialogController` and its type are re-exported.
55
+
56
+ ## Props
57
+
58
+ All parts take `className` and `render`. There is no `asChild`.
59
+
60
+ ### AlertDialog
61
+
62
+ | Prop | Type | Default | Notes |
63
+ | ---------------------- | ----------------------------- | ------- | ------------------------------------------------------------ |
64
+ | `open` | `boolean` | | Controlled state. |
65
+ | `defaultOpen` | `boolean` | `false` | |
66
+ | `onOpenChange` | `(open, details) => void` | | `details.reason`, `details.returnValue`, `details.cancel()`. |
67
+ | `onOpenChangeComplete` | `(open) => void` | | After the exit animation. |
68
+ | `dismissible` | `boolean` | `true` | `false` also refuses Escape. |
69
+ | `onDismissAttempt` | `({ reason, event }) => void` | | A refused dismissal, such as Escape while an action runs. |
70
+ | `pendingAnnouncement` | `string` | | Screen reader text for a slow action. No default. |
71
+ | `controller` | `AlertDialogController` | | Open and close from code. |
72
+
73
+ ### AlertDialogContent
74
+
75
+ | Prop | Type | Default | Notes |
76
+ | -------------- | ------------------------------------------ | ------------ | ---------------------------------------------------------- |
77
+ | `size` | `"sm"` or `"md"` | `"md"` | Maximum width 384 or 512 px. Full screen under 640 px. |
78
+ | `initialFocus` | selector, element, function or `"content"` | first action | Where focus starts. |
79
+ | `finalFocus` | selector, element or function | trigger | Where focus goes on close. |
80
+ | `inline` | `boolean` | `false` | Place the dialog in its parent frame, for the states page. |
81
+
82
+ ### AlertDialogAction and AlertDialogCancel
83
+
84
+ `AlertDialogAction`: `variant` (`"default"` or `"destructive"`), `value` (default `"confirm"`, reported as `returnValue`), `action`, `disabled`. While `action`'s promise runs the dialog stays open, the action shows a spinner with `aria-busy="true"` and `data-pending`, Cancel is `aria-disabled`, and Escape is refused. A resolved promise closes the dialog with reason `action`; a rejected one keeps it open for another try.
85
+
86
+ `AlertDialogCancel`: the outline button look; closes with no value.
87
+
88
+ ### AlertDialogConfirmField
89
+
90
+ | Prop | Type | Default | Notes |
91
+ | -------- | ----------- | --------------------------------- | ------------------------------------- |
92
+ | `phrase` | `string` | | Required. Compared exactly, case too. |
93
+ | `label` | `ReactNode` | `` `Type ${phrase} to confirm` `` | The field's label. |
94
+
95
+ The field starts empty on every open.
96
+
97
+ ### confirm(options)
98
+
99
+ Resolves `true` when the person confirms, `false` on Cancel or Escape. Calls made together wait their turn.
100
+
101
+ | Option | Type | Default |
102
+ | -------------------- | --------- | ---------------------------------------- |
103
+ | `title` | `string` | |
104
+ | `description` | `string` | |
105
+ | `confirmLabel` | `string` | `"Confirm"` |
106
+ | `cancelLabel` | `string` | `"Cancel"` |
107
+ | `destructive` | `boolean` | `false` |
108
+ | `typeToConfirm` | `string` | |
109
+ | `typeToConfirmLabel` | `string` | `` `Type ${typeToConfirm} to confirm` `` |
110
+
111
+ ## Variants
112
+
113
+ | Variant | How |
114
+ | --------------- | ------------------------------------------------------------------------ |
115
+ | default | `AlertDialogAction` with no `variant`. |
116
+ | destructive | `AlertDialogAction variant="destructive"`. |
117
+ | type-to-confirm | `AlertDialogConfirmField phrase="..."`, or `confirm({ typeToConfirm })`. |
118
+
119
+ ## States
120
+
121
+ | State | Signal |
122
+ | ------------------ | ---------------------------------------------------------------------------- |
123
+ | open | `data-open` on content and backdrop. |
124
+ | closing | `data-ending-style` until the 150 ms exit finishes. |
125
+ | pending on confirm | `data-pending` and `aria-busy="true"` on the action; Cancel `aria-disabled`. |
126
+ | blocked | The action is `disabled` until the typed phrase matches. |
127
+
128
+ ## Behaviour
129
+
130
+ - Opening focuses the first action, so Cancel comes first in the footer.
131
+ - Escape cancels; a press outside does nothing.
132
+ - Focus returns to the trigger on close.
133
+ - A question opened inside another joins its stack; Escape closes the top one only.
134
+
135
+ ## Styling hooks
136
+
137
+ `data-slot` values: `alert-dialog-trigger`, `alert-dialog-overlay`, `alert-dialog-content`, `alert-dialog-header`, `alert-dialog-footer`, `alert-dialog-title`, `alert-dialog-description`, `alert-dialog-close` (both actions), `alert-dialog-confirm-field`. A trigger rendered as the library `Button` keeps the `button` slot.
138
+
139
+ The panel shares `Dialog`'s look; the actions use `Button`'s variants.
140
+
141
+ ## Accessibility
142
+
143
+ Target: WCAG 2.2 AA. UI SDK supplies the `alertdialog` role, `aria-modal`, the name and description,
144
+ the focus trap, focus return and Escape. Text and buttons meet 4.5:1 and the focus ring 3:1 in both
145
+ themes. The type-to-confirm field has a visible label.
146
+
147
+ ## Copy
148
+
149
+ The question and description are the caller's. Built-in strings: the field label, and `confirm()`'s
150
+ "Confirm" and "Cancel" defaults. State the consequence and whether it can be undone, and name the
151
+ action ("Delete"), never "Yes" or "OK".
152
+
153
+ ## Not included
154
+
155
+ - A close button in the corner: an alert dialog is answered, not dismissed.
156
+ - A task with fields beyond a typed phrase: use `Dialog`.
157
+ - Toasts above an open alert dialog need no wiring; the library `Toaster` keeps itself on top.
package/docs/alert.md ADDED
@@ -0,0 +1,70 @@
1
+ # Alert
2
+
3
+ Tells people what happened and what to do next, with an icon and a colour for the type.
4
+
5
+ `e2e/alert.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { Alert, AlertAction, AlertDescription, AlertTitle } from "@eodparks/ui/alert";
11
+
12
+ <Alert variant="warning" dismissible onDismiss={remember}>
13
+ <AlertTitle>Card expires soon</AlertTitle>
14
+ <AlertDescription>Update it before 1 April to keep bookings open.</AlertDescription>
15
+ <AlertAction>
16
+ <Button size="sm" variant="outline">
17
+ Update card
18
+ </Button>
19
+ </AlertAction>
20
+ </Alert>;
21
+ ```
22
+
23
+ ## Props
24
+
25
+ | Prop | Type | Default | Notes |
26
+ | -------------- | --------------------------------------------------- | ----------- | -------------------------------------------------------- |
27
+ | `variant` | `"info" \| "success" \| "warning" \| "destructive"` | `"info"` | each has its own icon, fill, border and text colour |
28
+ | `icon` | `ReactNode \| false` | by variant | `false` hides it; the icon is always decorative |
29
+ | `dismissible` | `boolean` | `false` | adds a close button that hides the alert |
30
+ | `onDismiss` | `() => void` | | runs after the alert hides, to remember it or move focus |
31
+ | `dismissLabel` | `string` | `"Dismiss"` | accessible name of the close button |
32
+
33
+ ## Descriptive message
34
+
35
+ The title says what happened ("Card expires soon"); the description says what to do next ("Update
36
+ it before 1 April"). A status word alone ("Error") is not a message.
37
+
38
+ ## Placement and stacking
39
+
40
+ Alerts sit at the top of the region they describe, full width of it, in a column with `gap-3`.
41
+ Newest first, most severe first when several arrive together. Never overlay content.
42
+
43
+ ## Semantic variants and role
44
+
45
+ | Variant | Role | Colours |
46
+ | ------------- | -------- | ----------------------------------------------- |
47
+ | `info` | `status` | `info-subtle` fill, `info-border` |
48
+ | `success` | `status` | `success-subtle` fill, `success-border` |
49
+ | `warning` | `alert` | `warning-subtle` fill, `warning-border` |
50
+ | `destructive` | `alert` | `destructive-subtle` fill, `destructive-border` |
51
+
52
+ A problem uses `alert` (assertive) and a note uses `status` (polite). Pass `role` to override.
53
+
54
+ ## Dismissible option
55
+
56
+ A close button (`icon-xs` ghost, 24px target) hides the alert. Only informational and success
57
+ alerts should be dismissible; keep a warning or an error until the cause is fixed. The button is
58
+ removed with the alert, so `onDismiss` is where the app returns focus; the states page sends it to
59
+ the next landmark.
60
+
61
+ ## Inline action
62
+
63
+ `AlertAction` holds one link or button for the next step, under the text. A button's edge takes the
64
+ text colour so it stays at 3:1 on the fill.
65
+
66
+ ## Accessibility
67
+
68
+ Target: WCAG 2.2 AA. Text meets 4.5:1 on its fill in both themes; the icon repeats the type so
69
+ colour is not the only signal. The close button is a native button with a name, reachable by Tab,
70
+ and pressed with Enter or Space. A 24 by 24 pixel target at least, with a visible focus ring.
package/docs/avatar.md ADDED
@@ -0,0 +1,57 @@
1
+ # Avatar
2
+
3
+ Shows a person or a team as an image, with initials or an icon while it loads or when it fails.
4
+
5
+ `e2e/avatar.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { Avatar, AvatarFallback, AvatarGroup, AvatarImage } from "@eodparks/ui/avatar";
11
+
12
+ <Avatar status="online">
13
+ <AvatarImage src={user.image} alt="" />
14
+ <AvatarFallback label={user.name}>AL</AvatarFallback>
15
+ </Avatar>
16
+
17
+ <AvatarGroup aria-label="Team" max={4}>{members.map(...)}</AvatarGroup>
18
+ ```
19
+
20
+ ## Parts
21
+
22
+ | Export | Is |
23
+ | ---------------- | ----------------------------------------------------------------------------------- |
24
+ | `Avatar` | wraps `Avatar` from `@ui-sdk/react/avatar`; sizes `sm` 32px, `md` 40px, `lg` 48px |
25
+ | `AvatarImage` | the image; circular, covers the avatar, replaces the fallback once it loads |
26
+ | `AvatarFallback` | initials as children, or the person icon with no children; `label` names the avatar |
27
+ | `AvatarGroup` | overlapping avatars; the rest collapse into a `+N` avatar above `max` |
28
+
29
+ ## Props
30
+
31
+ | Prop | Type | Default | Notes |
32
+ | --------------- | ------------------------------------------- | -------- | ------------------------------------------------------ |
33
+ | `size` | `"sm" \| "md" \| "lg"` | `"md"` | a group's `size` is the default for its avatars |
34
+ | `status` | `"online" \| "away" \| "busy" \| "offline"` | | a dot on the bottom end corner, named by `statusLabel` |
35
+ | `statusLabel` | `string` | status | English default is the capitalised status |
36
+ | `max` | `number` | `4` | group only |
37
+ | `overflowLabel` | `(hidden: number) => string` | `N more` | group only; the hidden name of the `+N` avatar |
38
+
39
+ ## Placeholder image
40
+
41
+ With no image, or a failed one, the fallback shows: initials, or the person icon. States:
42
+ loading (fallback visible), loaded (image visible, fallback gone), error (fallback stays).
43
+ `AvatarFallback` hides its initials from assistive technology and exposes `label` instead, so the
44
+ name is available in every state.
45
+
46
+ ## Alternatives
47
+
48
+ The person icon is the default illustration for people with no photo and no initials. Choosing,
49
+ uploading, cropping and confirming an avatar belong to a form, not to this display part.
50
+
51
+ ## Accessibility
52
+
53
+ Target: WCAG 2.2 AA. When a visible name is next to the avatar, use `alt=""` on the image and no
54
+ `label`. Otherwise give the fallback a `label` and the image an `alt`. The status dot is an
55
+ image with a name, and each status has its own mark (clock hands, a bar, a hollow centre) so
56
+ colour is not the only cue. Initials meet 4.5:1 and the dot 3:1 in both themes. The avatar is not
57
+ interactive; to make it a button pass `render={<button type="button" aria-label="..." />}`.
package/docs/badge.md ADDED
@@ -0,0 +1,51 @@
1
+ # Badge
2
+
3
+ Marks a status, a count or an unread dot, in the standard intent colours.
4
+
5
+ `e2e/badge.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { Badge, BadgeAnchor } from "@eodparks/ui/badge";
11
+
12
+ <Badge variant="success" subtle>Paid</Badge>
13
+ <Badge count={120} label="overdue" variant="destructive" />
14
+ <BadgeAnchor>
15
+ <Button size="icon" variant="outline" aria-label="Notifications"><BellIcon /></Button>
16
+ <Badge dot offset variant="destructive" label="New notifications" />
17
+ </BadgeAnchor>
18
+ ```
19
+
20
+ ## Props
21
+
22
+ | Prop | Type | Default | Notes |
23
+ | --------- | ------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------ |
24
+ | `variant` | `default \| secondary \| outline \| destructive \| success \| warning \| info \| highlight` | `"default"` | shadcn names plus the three intents and `highlight` |
25
+ | `subtle` | `boolean` | `false` | tinted fill and border of the intent; none for `secondary` and `outline` |
26
+ | `count` | `number` | | shows the number; `99+` above `max`; `0` renders nothing |
27
+ | `max` | `number` | `99` | |
28
+ | `dot` | `boolean` | `false` | a plain 8px dot with no text |
29
+ | `label` | `string` | | names a dot or a count; a count adds it as hidden text |
30
+ | `offset` | `boolean` | `false` | pins to the top end corner of a `BadgeAnchor`; mirrors in right to left |
31
+
32
+ ## Detail
33
+
34
+ A badge carries a short text, a number or a plain dot, never both. A dot with no `label` is
35
+ decorative and hidden from assistive technology; with a `label` it is an image with that name.
36
+
37
+ ## Colour
38
+
39
+ Colours map to the standard states: `destructive` for errors, `success`, `warning`, `info`. Every
40
+ pair is a token pair that meets 4.5:1 in both themes. The text always says the state as well, or
41
+ a `label` does, so colour is never the only signal.
42
+
43
+ ## Offset position
44
+
45
+ `BadgeAnchor` is a `relative inline-flex` wrapper; a badge with `offset` sits on its top end
46
+ corner. Position uses logical properties, so the badge moves to the left corner in right to left.
47
+
48
+ ## Accessibility
49
+
50
+ Target: WCAG 2.2 AA. A badge is not interactive, so it has no target size or focus ring. Text
51
+ meets 4.5:1, a dot meets 3:1, in both themes.
package/docs/button.md ADDED
@@ -0,0 +1,121 @@
1
+ # Button
2
+
3
+ Runs an action, shows that it is working, and stays reachable when disabled.
4
+
5
+ `e2e/button.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { Button } from "@eodparks/ui/button";
11
+
12
+ <Button onClick={save}>Save</Button>
13
+ <Button variant="outline" size="sm">Cancel</Button>
14
+ <Button type="submit" pending={mutation.isPending}>Create booking</Button>
15
+ <Button render={<Link to="/bookings" />}>Bookings</Button>
16
+ ```
17
+
18
+ ## Parts
19
+
20
+ | Export | Is |
21
+ | ---------------- | ------------------------------------------------------------------------------- |
22
+ | `Button` | wraps `Button` from `@ui-sdk/react/button`; renders a native `<button>` |
23
+ | `buttonVariants` | the `cva` function, for the CRM files that style a non-button as a button |
24
+ | `ButtonProps` | the prop type (native button props, UI SDK options and the variant props below) |
25
+
26
+ One part only. Icons are children. There is no `ButtonIcon` part and no `Slot`.
27
+
28
+ ## Props
29
+
30
+ | Prop | Type | Default | Notes |
31
+ | ----------------------- | ----------------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------- |
32
+ | `variant` | `"default" \| "secondary" \| "outline" \| "ghost" \| "link" \| "destructive"` | `"default"` | shadcn names, unchanged |
33
+ | `size` | `"xs" \| "sm" \| "default" \| "lg" \| "icon" \| "icon-sm" \| "icon-xs"` | `"default"` | shadcn names; `xs` and `icon-xs` come from OPS |
34
+ | `type` | `"button" \| "submit" \| "reset"` | `"button"` | UI SDK default. shadcn left it unset, which submits inside a form (see Migration) |
35
+ | `disabled` | `boolean` | `false` | blocks presses and form submission through the button |
36
+ | `focusableWhenDisabled` | `boolean` | `true` | disabled buttons keep their tab stop and use `aria-disabled` (section 6.2: "stays focusable") |
37
+ | `pending` | `boolean` | `false` | controlled pending, for form submits and mutations whose Promise `onClick` does not return |
38
+ | `pendingAnnouncement` | `string` | `"Loading"` | polite announcement after one second of pending, for both pending sources; `""` silences it |
39
+ | `onClick` | `(event, { source }) => void \| Promise<unknown>` | | a returned Promise keeps the button pending until it settles |
40
+ | `render` | `ReactElement \| (props, state) => ReactElement` | | change the element, for example `<a href>` or a router `Link`; the function form reads `state` |
41
+ | `className` | `string \| (state) => string` | | merged last with `cn` |
42
+ | `ref` | `Ref<HTMLButtonElement>` | | a plain React 19 prop; popup triggers rely on it |
43
+
44
+ Everything else passes to the element: `name`, `value`, `form`, `aria-*`, `data-*`.
45
+
46
+ No `asChild`. Every CRM and OPS `asChild` call site becomes `render`, and TypeScript flags each one.
47
+
48
+ ## Variants
49
+
50
+ | Variant | Look |
51
+ | ------------- | ---------------------------------------------------------- |
52
+ | `default` | fill: `bg-primary text-primary-foreground`; the base style |
53
+ | `secondary` | fill: `bg-secondary text-secondary-foreground` |
54
+ | `outline` | 1px `border-input`, `bg-background`, text `foreground` |
55
+ | `ghost` | no fill until hover (`bg-accent text-accent-foreground`) |
56
+ | `link` | text `primary`, underline on hover, no padding change |
57
+ | `destructive` | fill: `bg-destructive text-destructive-foreground` |
58
+
59
+ | Size | Height | Shape |
60
+ | --------- | -------------------------- | ----------------------- |
61
+ | `xs` | 1.5rem (fixed, no density) | text-xs, gap 1 |
62
+ | `sm` | `--control-h-sm` | text-sm |
63
+ | `default` | `--control-h` | text-sm |
64
+ | `lg` | `--control-h-lg` | text-sm |
65
+ | `icon` | square of `--control-h` | icon only, needs a name |
66
+ | `icon-sm` | square of `--control-h-sm` | icon only, needs a name |
67
+ | `icon-xs` | square of 1.5rem | icon only, needs a name |
68
+
69
+ Radius `rounded-control`, flat (no shadow beyond Tailwind defaults), no gradient. Icons are
70
+ 16px, `currentColor`, `aria-hidden`. Heights follow `data-density="compact"` through the
71
+ `--control-h*` tokens. Labels stay on one line; a label wider than its container truncates with
72
+ an ellipsis and keeps its full accessible name.
73
+
74
+ ## States
75
+
76
+ Styled from attributes only, never from JavaScript state.
77
+
78
+ | State | Source | Look |
79
+ | ------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
80
+ | hover | `:hover` | fill one step darker (`/90`; secondary `/80`), ghost gains `bg-accent`, link underlines |
81
+ | active | `:active` | same as hover; no transform |
82
+ | focus-visible | `:focus-visible` | `focusRing` from `internal/focus-ring`; no ring after a mouse click |
83
+ | disabled | `data-disabled` | `opacity-50`, `cursor-not-allowed`, no hover change; keeps pointer events so a tooltip can explain why |
84
+ | pending | `data-pending` (Promise or `pending` prop) | label kept and hidden visually, spinner (`data-slot="button-spinner"`) centred on top, width unchanged |
85
+
86
+ Attributes the button carries: `data-slot="button"`, `data-variant`, `data-size`, and UI SDK's
87
+ `data-disabled` and `data-pending`. Pending sets `aria-busy="true"` and `aria-disabled="true"`,
88
+ keeps focus and ignores presses until it ends.
89
+
90
+ ## Copy
91
+
92
+ The label says what happens: a verb, or verb and object ("Save changes", "Create booking"), not
93
+ "OK" or "Submit" unless the surrounding title names the action. Keep it short enough for one
94
+ line. While pending, keep the label and let the spinner and `pendingAnnouncement` say it is
95
+ working; do not swap the text. An icon-only button needs `aria-label`; use `IconButton`, which
96
+ requires it in its type.
97
+
98
+ ## Accessibility
99
+
100
+ Target: WCAG 2.2 AA. Native `<button>` semantics, so Enter and Space press it; rendered as a link
101
+ it keeps link semantics and Enter follows it. Disabled buttons stay in the tab order with
102
+ `aria-disabled` so they can be discovered and explained with `aria-describedby`. Every size has a
103
+ target of at least 24 by 24 CSS pixels (WCAG 2.5.8). Label text and the focus ring meet 4.5:1 and
104
+ 3:1 in both themes. No hand-written roles.
105
+
106
+ ## Migration
107
+
108
+ - Shim: `export * from "@eodparks/ui/button"` replaces CRM's `button.tsx` and
109
+ `button-variants.ts`, and OPS's `button.tsx`, when typecheck passes.
110
+ - `type` defaults to `"button"`. A shadcn `<Button>` with no `type` inside a `<form>` submitted it;
111
+ it no longer does. The Button migration PR lists every such call site and adds
112
+ `type="submit"` where the form relied on it. Typecheck cannot catch this.
113
+ - `disabled` keeps the tab stop by default. Pass `focusableWhenDisabled={false}` where a disabled
114
+ button must leave the tab order.
115
+ - `isLoading && <Loader2 className="animate-spin" />` inside a button becomes `pending`.
116
+ - `ShimmerButton` call sites (2, CRM) become `Button`.
117
+
118
+ ## Not in scope
119
+
120
+ Tooltip on disabled buttons (`IconButton`, `Tooltip`), button groups (`ButtonGroup`), toggle state
121
+ (`Toggle`), copy-to-clipboard (`CopyButton`).