@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,177 @@
1
+ # DatePicker
2
+
3
+ Type a date or pick one from a calendar popup, for one date or a range, with presets and ISO string values.
4
+
5
+ Wraps `@ui-sdk/react/date-picker` and draws its calendar with the `Calendar` parts. For a
6
+ calendar that stays on the page, use `Calendar`. `e2e/date-picker.spec.ts` is the executable
7
+ form of this page.
8
+
9
+ ## Usage
10
+
11
+ ```tsx
12
+ import {
13
+ DatePicker,
14
+ DatePickerCalendar,
15
+ DatePickerClear,
16
+ DatePickerContent,
17
+ DatePickerField,
18
+ DatePickerHint,
19
+ DatePickerInput,
20
+ DatePickerPreset,
21
+ DatePickerPresets,
22
+ DatePickerSeparator,
23
+ DatePickerToday,
24
+ DatePickerTrigger,
25
+ presetRanges,
26
+ todayDate,
27
+ } from "@eodparks/ui/date-picker";
28
+
29
+ <label htmlFor="due">Due date</label>
30
+ <DatePicker name="due" value={due} onValueChange={setDue}>
31
+ <DatePickerField>
32
+ <DatePickerInput id="due" />
33
+ <DatePickerClear />
34
+ <DatePickerTrigger />
35
+ </DatePickerField>
36
+ <DatePickerHint />
37
+ <DatePickerContent />
38
+ </DatePicker>
39
+
40
+ const ranges = presetRanges(todayDate());
41
+ <DatePicker mode="range" months={2} startName="from" endName="to">
42
+ <DatePickerField>
43
+ <DatePickerInput aria-label="From" />
44
+ <DatePickerSeparator />
45
+ <DatePickerInput end aria-label="To" />
46
+ <DatePickerTrigger />
47
+ </DatePickerField>
48
+ <DatePickerContent>
49
+ <DatePickerCalendar />
50
+ <DatePickerPresets>
51
+ <DatePickerToday />
52
+ <DatePickerPreset value={ranges.last7Days}>Last 7 days</DatePickerPreset>
53
+ <DatePickerPreset value={ranges.last30Days}>Last 30 days</DatePickerPreset>
54
+ <DatePickerPreset value={ranges.thisMonth}>This month</DatePickerPreset>
55
+ </DatePickerPresets>
56
+ </DatePickerContent>
57
+ </DatePicker>
58
+ ```
59
+
60
+ Values are ISO `YYYY-MM-DD` strings, or `[start, end]` in range mode, and `null` when empty.
61
+ The form submits the same ISO strings. `todayDate`, `addDays`, `toISODate` (a `Date` to ISO) and
62
+ `fromISODate` (ISO to a local-midnight `Date`) come from this entry and `@eodparks/ui/calendar`;
63
+ apps never import `@ui-sdk/*`.
64
+
65
+ ## Parts
66
+
67
+ | Part | Is |
68
+ | --------------------- | ----------------------------------------------------------------------------------- |
69
+ | `DatePicker` | the root: value, open state, form names; renders a default layout with no children |
70
+ | `DatePickerField` | the row that holds the inputs, Clear and the trigger |
71
+ | `DatePickerInput` | a text input that reads a typed date on Enter or blur; `end` makes it a range's end |
72
+ | `DatePickerSeparator` | the dash between a range's inputs, hidden from screen readers |
73
+ | `DatePickerTrigger` | the calendar button, named "Choose date" and the date chosen |
74
+ | `DatePickerClear` | empties the value and focuses the input; hidden while empty |
75
+ | `DatePickerHint` | the format to type, like "MM/DD/YYYY", or the typing error; it describes the inputs |
76
+ | `DatePickerContent` | the popup; renders `DatePickerCalendar` when it has no children |
77
+ | `DatePickerCalendar` | the calendar header and grids, from the root's `months` and `captionLayout` |
78
+ | `DatePickerPresets` | a row of presets under the calendar |
79
+ | `DatePickerPreset` | selects its `value` and closes; pressed while its value is selected |
80
+ | `DatePickerToday` | a preset for today, or today to today in range mode |
81
+ | `presetRanges(today)` | `{ today, last7Days, last30Days, thisMonth }` ranges, both ends included |
82
+
83
+ Custom popup layouts use the `Calendar` parts from `@eodparks/ui/calendar` inside
84
+ `DatePickerContent`. Not provided: `Date` objects, `asChild` (use `render`) and a `dir` prop.
85
+
86
+ ## Props
87
+
88
+ With no children, `DatePicker` renders inputs named "Date", or "Start date" and "End date",
89
+ the trigger, the hint and the popup. To name the input after a visible label, compose the parts.
90
+
91
+ `DatePicker` takes every UI SDK Date Picker option. The ones apps use most:
92
+
93
+ | Prop | Type | Default | Note |
94
+ | -------------------------------------------------- | ------------------------------------------------------ | ------------------------- | -------------------------------------------------------- |
95
+ | `mode` | `"single" \| "range"` | `"single"` | range has an input for each end |
96
+ | `value`, `defaultValue`, `onValueChange` | ISO date, `[start, end]`, or `null` | | a range reports once both ends are set |
97
+ | `open`, `defaultOpen`, `onOpenChange` | `boolean` | closed | |
98
+ | `name`, `startName`, `endName`, `form`, `required` | | | submits ISO dates; text that is not a date blocks submit |
99
+ | `min`, `max`, `unavailable` | ISO dates, matchers | | apply to typing, the calendar and presets |
100
+ | `disabled`, `readOnly` | `boolean` | `false` | read-only opens the calendar but keeps the value |
101
+ | `locale` | `string` | page `lang` | input format, hint, week start and names |
102
+ | `months`, `pageBy`, `captionLayout` | `number`, `"month" \| "page"`, `"label" \| "dropdown"` | `1`, `"month"`, `"label"` | the popup calendar's layout |
103
+ | `closeOnSelect`, `dismissible` | `boolean` | `true` | |
104
+ | `today`, `timeZone` | | browser's | which day is today; never converts the value |
105
+
106
+ `DatePickerInput` and `DatePickerTrigger` take `size` (`"default"` or `"sm"`). `DatePickerInput`
107
+ takes `invalid` for app validation, such as a Formik error; typed text that is not a date is
108
+ marked invalid already, and `DatePickerHint` then shows `invalidMessage` ("Enter a valid date.")
109
+ in place of the format. `DatePickerClear` defaults its name to "Clear date". `DatePickerContent`
110
+ takes `side` (`"bottom"`), `align` (`"start"`), `sideOffset` (4), `anchor` and `container`.
111
+ Every part takes `className` and `render`, and carries a `data-slot`.
112
+
113
+ ## Variants
114
+
115
+ | Variant | How |
116
+ | ------------ | ------------------------------------------------------------------------------------- |
117
+ | single | default |
118
+ | range | `mode="range"` with two `DatePickerInput`s, the second with `end` |
119
+ | presets | `DatePickerPresets` of `DatePickerPreset`, values from `presetRanges` |
120
+ | today | `DatePickerToday` |
121
+ | clearable | `DatePickerClear` in the field |
122
+ | typed input | always on; the locale's order, ISO, digits without separators and month names parse |
123
+ | locale en-IN | `locale="en-IN"`, or `<html lang="en-IN">`: day first (DD/MM/YYYY), weeks from Sunday |
124
+ | size | `size="sm"` on the input and trigger; heights follow `data-density="compact"` |
125
+
126
+ ## States
127
+
128
+ | State | Source | Look |
129
+ | ----------- | ------------------------------------------------ | ------------------------------------ |
130
+ | open | `data-open` on the root, trigger and popup | popup surface with border and shadow |
131
+ | invalid | `aria-invalid` and `data-invalid` on the input | `border-destructive`; hint says why |
132
+ | disabled | `data-disabled`; the input is `disabled` | half opacity, not-allowed cursor |
133
+ | placeholder | the input's `placeholder` while empty | `text-muted-foreground` |
134
+ | preset on | `data-selected` and `aria-pressed` on the preset | `bg-primary-subtle` |
135
+ | empty | `data-empty` on Clear | Clear hidden |
136
+
137
+ Days in the popup carry the `Calendar` states.
138
+
139
+ ## Keyboard
140
+
141
+ | Where | Key | Result |
142
+ | ------- | ------------- | ------------------------------------------------------------ |
143
+ | input | Enter | commit the typed date |
144
+ | input | Alt+ArrowDown | open the calendar |
145
+ | trigger | Enter, Space | open or close the calendar |
146
+ | popup | calendar keys | as in `Calendar`; Enter picks and closes |
147
+ | popup | Escape | cancel an unfinished range, else close; focus to the trigger |
148
+ | popup | Tab out | close and move on |
149
+
150
+ Opening focuses the selected date, else today, else the first available date.
151
+
152
+ ## Accessibility
153
+
154
+ Target: WCAG 2.2 AA. It follows the APG date picker dialog: a plain text input, a button with
155
+ `aria-haspopup="dialog"` and `aria-expanded` named by the chosen date, and a `dialog` named
156
+ "Choose date" holding the calendar grid. The hint describes each input. UI SDK sets all of
157
+ this; the library adds no roles. Text that is not a date turns the hint into "Enter a valid
158
+ date.", so the error is in words, not only the red border. Without a `DatePickerHint`, show that
159
+ error yourself, and give an error the app sets with `invalid` its own text next to the field. Text meets 4.5:1 and edges 3:1 in both themes, checked with
160
+ axe on the states page with the popup open and closed. Screen reader checks are manual.
161
+
162
+ ## Copy
163
+
164
+ The library ships only English accessible names and one label: "Choose date", "Choose dates",
165
+ "Clear date", the calendar's "Previous month" and "Next month", `DatePickerToday`'s "Today",
166
+ the hint's "Enter a valid date." and the default layout's "Date", "Start date" and "End date".
167
+ Each is a prop or children. Preset labels and placeholders come from the app.
168
+
169
+ ## Motion
170
+
171
+ The popup fades and scales in 150ms from `internal/popup`. Under `prefers-reduced-motion` it
172
+ does not scale and the transition is near zero.
173
+
174
+ ## Stacking
175
+
176
+ The popup opens in the top layer, so no ancestor `overflow` clips it and a `space-y-*` parent
177
+ does not move it. It flips to stay on screen near an edge.
package/docs/dialog.md ADDED
@@ -0,0 +1,110 @@
1
+ # Dialog
2
+
3
+ A modal window that holds one focused task over the page, built on UI SDK `dialog` with shadcn-compatible part names.
4
+
5
+ Import from `@eodparks/ui/dialog`.
6
+
7
+ ## Parts
8
+
9
+ | Part | Renders | Role |
10
+ | ------------------- | -------- | ------------------------------------------------------------------------------------------- |
11
+ | `Dialog` | none | Root. Holds open state and behaviour. |
12
+ | `DialogTrigger` | `button` | Opens the dialog. Also usable outside `Dialog` with a `controller`. |
13
+ | `DialogContent` | `div` | The backdrop and the panel, in the top layer. Adds the close button. |
14
+ | `DialogHeader` | `div` | Stacks the title and description. |
15
+ | `DialogBody` | `div` | The scrolling region. Keyboard focusable. To name it, render a `section` with `aria-label`. |
16
+ | `DialogFooter` | `div` | The actions. Stacked and reversed under `sm`, a row with the end side above. |
17
+ | `DialogTitle` | `h2` | Names the dialog. |
18
+ | `DialogDescription` | `p` | Describes the dialog. |
19
+ | `DialogClose` | `button` | Closes the dialog. Takes `value` and an async `action`. |
20
+
21
+ `DialogPortal` and `DialogOverlay` from shadcn are not exported: `DialogContent` owns the backdrop and UI SDK renders in the top layer, so there is nothing to portal. `createDialogController` and its type are re-exported.
22
+
23
+ ## Props
24
+
25
+ All parts take `className` and `render`. There is no `asChild`: write `render={<a href="/x" />}` to change the element.
26
+
27
+ ### Dialog
28
+
29
+ | Prop | Type | Default | Notes |
30
+ | ---------------------- | --------------------------------- | ------- | --------------------------------------------------------------- |
31
+ | `open` | `boolean` | | Controlled state. |
32
+ | `defaultOpen` | `boolean` | `false` | Uncontrolled initial state. |
33
+ | `onOpenChange` | `(open, details) => void` | | `details.reason`, `details.returnValue`, `details.cancel()`. |
34
+ | `onOpenChangeComplete` | `(open) => void` | | After the exit animation. |
35
+ | `dismissible` | `boolean` | `true` | `false` refuses Escape and outside press. |
36
+ | `onDismissAttempt` | `({ reason, event }) => void` | | A refused dismissal. |
37
+ | `modal` | `true`, `"trap-focus"` or `false` | `true` | |
38
+ | `closeOnOutsidePress` | `boolean` | `true` | |
39
+ | `pendingAnnouncement` | `string` | | Screen reader text for a slow `DialogClose` action. No default. |
40
+ | `controller` | `DialogController` | | Open and close from code. |
41
+
42
+ ### DialogContent
43
+
44
+ | Prop | Type | Default | Notes |
45
+ | ----------------- | ------------------------------------------ | --------------- | -------------------------------------------------------------------------------------------------- |
46
+ | `size` | `"sm"`, `"md"`, `"lg"` or `"xl"` | `"md"` | Maximum width 384, 512, 672 and 896 px. Under `sm` (640 px) always full screen. |
47
+ | `showCloseButton` | `boolean` | `true` | The corner close button. A `false` dialog needs its own `DialogClose`. |
48
+ | `closeLabel` | `string` | `"Close"` | Accessible name of the corner close button. |
49
+ | `initialFocus` | selector, element, function or `"content"` | first focusable | Where focus starts. |
50
+ | `finalFocus` | selector, element or function | trigger | Where focus goes on close. |
51
+ | `keepMounted` | `boolean` | `false` | Keep the closed dialog and its state in the page. |
52
+ | `inline` | `boolean` | `false` | Place the dialog in its parent frame, for the gallery states page. Pair with `modal="trap-focus"`. |
53
+
54
+ ### DialogTrigger and DialogClose
55
+
56
+ `DialogTrigger`: `disabled`, `focusableWhenDisabled`, `payload`, `controller`.
57
+ `DialogClose`: `value` (reported as `returnValue`) and `action`, an async function. While the promise runs the dialog stays open, the button has `aria-busy="true"` and `data-pending`, and dismissals are refused. The dialog then closes with reason `action`.
58
+
59
+ ## Variants
60
+
61
+ | Variant | How |
62
+ | ---------------------- | --------------------------------------------------------------------------------------------------- |
63
+ | size sm, md, lg, xl | `DialogContent size`. |
64
+ | full screen under `sm` | Automatic below 640 px: the panel fills the viewport, no radius, no border. |
65
+ | scrollable body | Put long content in `DialogBody`. Header and footer stay in view. |
66
+ | non-dismissible | `Dialog dismissible={false}`, usually with `showCloseButton={false}` and an explicit `DialogClose`. |
67
+
68
+ ## States
69
+
70
+ | State | Signal |
71
+ | -------------- | -------------------------------------------------------------------------------- |
72
+ | open | `data-open` on content and backdrop. |
73
+ | closing | `data-ending-style` until the exit finishes. Motion is 150 ms opacity and scale. |
74
+ | focus trapped | Modal: Tab wraps inside, the page is inert and does not scroll. |
75
+ | pending action | `data-pending` and `aria-busy="true"` on the `DialogClose` that is running. |
76
+ | nested | A dialog opened inside another joins its stack. Escape closes the top one only. |
77
+
78
+ Under `prefers-reduced-motion` the scale is removed and transitions are effectively instant.
79
+
80
+ ## Behaviour
81
+
82
+ - Escape, a press outside and the close button close it; each is reported by `details.reason`.
83
+ - A press that starts inside and is released outside does not close it.
84
+ - Focus moves to the first focusable element inside, and returns to the trigger on close.
85
+ - A form with `method="dialog"` closes the dialog on valid submit, and the submit button `value` becomes `returnValue`.
86
+ - The panel renders in the top layer where it is declared, so parent layout classes never touch it.
87
+ - Content taller than the window scrolls: inside `DialogBody` when there is one, otherwise the whole panel.
88
+ - The second click of a double-click on the trigger does not dismiss the dialog it just opened.
89
+
90
+ ## Styling hooks
91
+
92
+ `data-slot` values: `dialog-trigger`, `dialog-overlay` (the backdrop), `dialog-content`, `dialog-header`, `dialog-body`, `dialog-footer`, `dialog-title`, `dialog-description`, `dialog-close`.
93
+
94
+ Look: `bg-background`, `text-foreground`, 1px `border`, `rounded-surface`, `shadow-lg`, 24 px padding. Backdrop `bg-overlay/80`, as CRM renders it. Layout uses logical properties so the close button sits at the inline end in right to left.
95
+
96
+ ## Accessibility
97
+
98
+ Target: WCAG 2.2 AA. UI SDK supplies the `dialog` role, `aria-modal`, the name from the title and
99
+ the description, the focus trap, focus return and Escape. The close button is named by
100
+ `closeLabel`. Text meets 4.5:1 and the focus ring 3:1 in both themes. No hand-written roles.
101
+
102
+ ## Copy
103
+
104
+ No prose ships. The only built-in string is `closeLabel`, defaulting to "Close".
105
+
106
+ ## Not included
107
+
108
+ - Destructive or type-to-confirm questions: use `AlertDialog`.
109
+ - Edge-anchored panels: use `Sheet`.
110
+ - Toast visibility above an open dialog: the library `Toaster` keeps itself above every popup, so `Dialog` needs no wiring for it.
@@ -0,0 +1,126 @@
1
+ # DropdownMenu
2
+
3
+ Lists actions and settings in a popup menu that opens from a button, with the shadcn part names and a UI SDK Menu underneath.
4
+
5
+ `e2e/dropdown-menu.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { buttonVariants } from "@eodparks/ui/button";
11
+ import {
12
+ DropdownMenu,
13
+ DropdownMenuContent,
14
+ DropdownMenuGroup,
15
+ DropdownMenuItem,
16
+ DropdownMenuLabel,
17
+ DropdownMenuSeparator,
18
+ DropdownMenuTrigger,
19
+ } from "@eodparks/ui/dropdown-menu";
20
+
21
+ <DropdownMenu onAction={(value) => run(value)}>
22
+ <DropdownMenuTrigger
23
+ aria-label="Row actions"
24
+ className={buttonVariants({ variant: "ghost", size: "icon" })}
25
+ >
26
+ <EllipsisIcon aria-hidden />
27
+ </DropdownMenuTrigger>
28
+ <DropdownMenuContent align="end">
29
+ <DropdownMenuGroup>
30
+ <DropdownMenuLabel>Booking</DropdownMenuLabel>
31
+ <DropdownMenuItem value="edit" shortcut="mod+e">
32
+ <PencilIcon aria-hidden />
33
+ Edit
34
+ </DropdownMenuItem>
35
+ </DropdownMenuGroup>
36
+ <DropdownMenuSeparator />
37
+ <DropdownMenuItem value="delete" variant="destructive">
38
+ <TrashIcon aria-hidden />
39
+ Delete
40
+ </DropdownMenuItem>
41
+ </DropdownMenuContent>
42
+ </DropdownMenu>;
43
+ ```
44
+
45
+ ## Parts
46
+
47
+ | Part | Role | Notes |
48
+ | -------------------------- | ------------------------------ | --------------------------------------------------------------------------------------- |
49
+ | `DropdownMenu` | root, no DOM of its own | `onAction(value)` runs for every plain item, submenus included |
50
+ | `DropdownMenuTrigger` | the menu button | unstyled; give it `buttonVariants`; an icon-only trigger needs `aria-label` |
51
+ | `DropdownMenuContent` | the `menu` popup | at least 128px wide, scrolls inside the viewport, surface classes from `internal/popup` |
52
+ | `DropdownMenuItem` | a `menuitem` | `value`, `shortcut`, `disabled`, `variant="destructive"`, `inset`; icons are children |
53
+ | `DropdownMenuCheckboxItem` | a `menuitemcheckbox` | check at the start edge; stays open when toggled |
54
+ | `DropdownMenuRadioGroup` | a group of radio items | `value`, `defaultValue`, `onValueChange` |
55
+ | `DropdownMenuRadioItem` | a `menuitemradio` | dot at the start edge; stays open when chosen |
56
+ | `DropdownMenuGroup` | a `group` | named by a `DropdownMenuLabel` inside it |
57
+ | `DropdownMenuLabel` | names its group | outside a group it is plain text and names nothing |
58
+ | `DropdownMenuSeparator` | a `separator` between sections | never a focus stop |
59
+ | `DropdownMenuSub` | root of a submenu | |
60
+ | `DropdownMenuSubTrigger` | the item that opens a submenu | trailing chevron, mirrored in right to left |
61
+ | `DropdownMenuSubContent` | the submenu popup | same surface as the content |
62
+
63
+ Not provided: `asChild` (use `render`), `DropdownMenuPortal` (popups render in the top layer) and `DropdownMenuShortcut` (an item's `shortcut` shows its keys, `⌘E` or `Ctrl+E`, at the trailing edge and sets `aria-keyshortcuts`; the app binds the keys).
64
+
65
+ ## Props
66
+
67
+ `DropdownMenu`: `open`, `defaultOpen`, `onOpenChange`, `onAction(value, { event })`, `onCheckedChange(checked, { value })`, `onValueChange(value, { group })`, `modal` (`"pointer"`), `loop` (`true`), `delay` (submenu hover, 100ms), `controller`, `presentation`. All from UI SDK. A Promise returned from `onAction` keeps the item pending and the menu open until it settles.
68
+
69
+ `DropdownMenuContent`: `side` (`"bottom"`), `align` (`"center"`), `sideOffset` (4), `alignOffset`, `collisionPadding`, `finalFocus`, `keepMounted`, `className`, `render`.
70
+
71
+ `DropdownMenuItem`: `value`, `label` (typeahead text when the content is not plain text), `disabled`, `variant` (`"default"` or `"destructive"`), `inset` (lines the label up with checkbox and radio items), `shortcut`, `closeOnSelect`, `onSelect(event)`.
72
+
73
+ `DropdownMenuCheckboxItem`: `value` (an id when omitted), `checked`, `defaultChecked`, `onCheckedChange`, `disabled`, `closeOnSelect`.
74
+
75
+ Every part carries a `data-slot` (`menu-trigger`, `menu-content`, `menu-item`, ...).
76
+
77
+ ## Variants
78
+
79
+ | Variant | How |
80
+ | ----------------- | ----------------------------------------------------------------------------- |
81
+ | items with icon | a lucide icon, `aria-hidden`, before the label |
82
+ | shortcut | `shortcut` on the item |
83
+ | groups and labels | `DropdownMenuGroup` with a `DropdownMenuLabel`, or a radio group label |
84
+ | separators | `DropdownMenuSeparator` |
85
+ | checkbox items | `DropdownMenuCheckboxItem` |
86
+ | radio items | `DropdownMenuRadioGroup` with `DropdownMenuRadioItem` |
87
+ | submenu | `DropdownMenuSub`, `DropdownMenuSubTrigger`, `DropdownMenuSubContent` |
88
+ | destructive item | `variant="destructive"`, in the danger colour, highlighted in its subtle fill |
89
+
90
+ ## States
91
+
92
+ | State | Source |
93
+ | ------------- | -------------------------------------------------------------------------------------------- |
94
+ | open | `data-open` on the trigger and the content; a sub trigger keeps it while its submenu is open |
95
+ | highlighted | `data-highlighted` on the item with focus or under the pointer; fill plus an inset ring |
96
+ | checked | `data-checked` on checkbox and radio items, with `aria-checked` |
97
+ | disabled item | `data-disabled` and `aria-disabled`; still focusable, never runs |
98
+ | pending | `data-pending` and `aria-busy` while an `onAction` Promise runs |
99
+
100
+ ## Keyboard
101
+
102
+ | Where | Key | Result |
103
+ | ------- | -------------------------- | --------------------------------------------------------------- |
104
+ | trigger | Enter, Space, ArrowDown | opens on the first item |
105
+ | trigger | ArrowUp | opens on the last item |
106
+ | menu | ArrowDown, ArrowUp | next or previous item, wrapping; disabled items are reachable |
107
+ | menu | Home, End, letters | first, last, next item starting with the letters |
108
+ | menu | Enter, Space | runs the item and closes; toggles a checkbox or radio and stays |
109
+ | menu | ArrowRight (ArrowLeft rtl) | opens the submenu on its first item |
110
+ | submenu | ArrowLeft (ArrowRight rtl) | closes the submenu, focus to its trigger |
111
+ | menu | Escape | closes, focus to the trigger |
112
+ | menu | Tab | closes |
113
+
114
+ ## Accessibility
115
+
116
+ The trigger has `aria-haspopup="menu"` and `aria-expanded`. The content is a `menu` of `menuitem`, `menuitemcheckbox` and `menuitemradio`, groups are named by their labels and separators are `separator`. UI SDK sets all of this; the library adds no roles. Icons are `aria-hidden`.
117
+
118
+ 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.
119
+
120
+ ## Motion
121
+
122
+ The menu fades and scales in 150ms. Under `prefers-reduced-motion` the scale is removed and the transition is near zero.
123
+
124
+ ## Stacking
125
+
126
+ Menus open in the top layer, so no ancestor `overflow` clips them and `space-y-*` or `divide-y` parents must not match them.
@@ -0,0 +1,65 @@
1
+ # EmptyState
2
+
3
+ An icon, a title, a description and one action for a screen, card or table that has nothing to show, in three variants.
4
+
5
+ Markup only, built on `renderElement`, so every part takes `render` and `className` and carries a `data-slot`. The component ships no words: the title and description are yours, and the variant decides only the default icon.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import {
11
+ EmptyState,
12
+ EmptyStateActions,
13
+ EmptyStateDescription,
14
+ EmptyStateIcon,
15
+ EmptyStateTitle,
16
+ } from "@eodparks/ui/empty-state";
17
+
18
+ <EmptyState variant="no-results">
19
+ <EmptyStateIcon />
20
+ <EmptyStateTitle>No matching bookings</EmptyStateTitle>
21
+ <EmptyStateDescription>Try a different search or remove a filter.</EmptyStateDescription>
22
+ <EmptyStateActions>
23
+ <Button variant="outline" onClick={clearFilters}>
24
+ Clear filters
25
+ </Button>
26
+ </EmptyStateActions>
27
+ </EmptyState>;
28
+ ```
29
+
30
+ ## Parts
31
+
32
+ | Part | Element | Notes |
33
+ | ----------------------- | ------- | ---------------------------------------------------------- |
34
+ | `EmptyState` | `div` | centres its children; holds `variant` and `compact` |
35
+ | `EmptyStateIcon` | `div` | decorative disc; shows the variant's icon, or its children |
36
+ | `EmptyStateTitle` | `h2` | `render={<h3 />}` to match the page outline |
37
+ | `EmptyStateDescription` | `p` | muted, at most the prose width |
38
+ | `EmptyStateActions` | `div` | one primary action, and at most one secondary |
39
+
40
+ ## Props
41
+
42
+ | Prop | On | Type | Default | Note |
43
+ | --------- | ------------ | ----------------------------------- | -------- | -------------------------------------------- |
44
+ | `variant` | `EmptyState` | `"zero" \| "no-results" \| "error"` | `"zero"` | sets `data-variant` and the default icon |
45
+ | `compact` | `EmptyState` | `boolean` | `false` | 16px padding, smaller icon, label-size title |
46
+
47
+ ## Variants
48
+
49
+ | Variant | Meaning | Action |
50
+ | ------------ | ------------------------------------------------------ | --------------------- |
51
+ | `zero` | nothing has been created yet | create the first item |
52
+ | `no-results` | a search or filter found nothing | clear the filters |
53
+ | `error` | content failed to load | retry |
54
+ | compact | `compact`, in a card, popover or a row | optional |
55
+ | in table | one `TableCell` with `colSpan` holding a compact state | clear or retry |
56
+
57
+ For an error that replaces a page or a section, with an error id and a boundary, use ErrorState.
58
+
59
+ ## Accessibility
60
+
61
+ The title is a heading, so the empty screen has an entry in the outline; keep the level in order with the page. The icon is decorative and hidden from assistive technology. The action is a Button, so it is a tab stop with the library ring. The three variants differ by icon and by your words, never by colour alone. Title and description meet 4.5:1 in both themes.
62
+
63
+ ## Right to left
64
+
65
+ Content is centred, and actions follow the direction.
@@ -0,0 +1,59 @@
1
+ # ErrorState
2
+
3
+ An announced error for a page, a section or a form, with an optional error id and retry, and an ErrorBoundary fallback.
4
+
5
+ Built on EmptyState's error variant for the page and section variants. Like EmptyState it ships no words: you pass the title and description; only the labels of the retry button ("Try again") and the id ("Error ID") have English defaults.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { ErrorBoundary, ErrorState } from "@eodparks/ui/error-state";
11
+
12
+ <ErrorState
13
+ title="Bookings did not load"
14
+ description="Check your connection and try again."
15
+ errorId={requestId}
16
+ onRetry={refetch}
17
+ />;
18
+
19
+ <ErrorBoundary
20
+ onError={report}
21
+ fallback={({ error, reset }) => (
22
+ <ErrorState variant="page" title="This page did not load" onRetry={reset} />
23
+ )}
24
+ >
25
+ <Page />
26
+ </ErrorBoundary>;
27
+ ```
28
+
29
+ ## Props
30
+
31
+ `ErrorState`
32
+
33
+ | Prop | Type | Default | Note |
34
+ | ------------------------- | --------------------------------- | ----------------- | ------------------------------------ |
35
+ | `variant` | `"page" \| "section" \| "inline"` | `"section"` | see Variants |
36
+ | `title` | `ReactNode` | required | |
37
+ | `description` | `ReactNode` | none | |
38
+ | `errorId`, `errorIdLabel` | `string` | none, "Error ID" | the id is selectable with one click |
39
+ | `onRetry`, `retryLabel` | `() => void`, `string` | none, "Try again" | the button shows only with `onRetry` |
40
+ | `children` | `ReactNode` | none | more actions beside retry |
41
+
42
+ `ErrorBoundary`: `fallback` (a node, or `({ error, reset }) => node`), `onError(error, info)`, `resetKeys` (when a value changes the boundary tries its children again).
43
+
44
+ ## Variants
45
+
46
+ | Variant | Use | Title element |
47
+ | ------------- | ---------------------------------------- | ------------- |
48
+ | `page` | replaces a screen; at least 384px high | `h1` |
49
+ | `section` | replaces a region, with an edge | `h2` |
50
+ | `inline` | a failed save in a form or card, one row | a paragraph |
51
+ | with error id | `errorId` on any variant | unchanged |
52
+
53
+ ## Accessibility
54
+
55
+ Every variant has `role="alert"`, so a screen reader announces it when it appears. The page variant holds the page's `h1`, because it replaces the page. The icon is decorative. Retry is a Button, a tab stop with the library ring. Text has 4.5:1 in both themes, on the card and on the inline destructive fill. An error id is plain text, so people can select and copy it.
56
+
57
+ ## Boundary
58
+
59
+ `ErrorBoundary` catches errors thrown while rendering its children, not errors in event handlers or async code; handle those where they happen and show an `ErrorState`. `onError` is called once per caught error. `reset` clears the error and renders the children again. When focus was on the retry button of an `ErrorState` fallback, it moves to the element that takes the fallback's place, so keyboard and screen reader users are not sent to the top of the page. A change of `resetKeys` in the same update that threw does not retry; the next change does.
package/docs/field.md ADDED
@@ -0,0 +1,54 @@
1
+ # Field
2
+
3
+ Connects a control to its label, description and error, vertical or horizontal.
4
+
5
+ Wraps `@ui-sdk/react/field`, which wires `id`, `for`, `aria-describedby` and `aria-invalid` for the control inside it. `e2e/field.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { Field, FieldDescription, FieldError, FieldLabel } from "@eodparks/ui/field";
11
+ import { Input } from "@eodparks/ui/input";
12
+
13
+ <Field name="email">
14
+ <FieldLabel>Email</FieldLabel>
15
+ <Input type="email" required />
16
+ <FieldDescription>We only use it for receipts.</FieldDescription>
17
+ <FieldError match="valueMissing">Enter your email address.</FieldError>
18
+ </Field>;
19
+ ```
20
+
21
+ For a form library, pass `invalid` and a matching `<FieldError match>`; see the two form bridges.
22
+
23
+ ## Parts
24
+
25
+ | Export | Is |
26
+ | ------------------ | -------------------------------------------------------------------------------- |
27
+ | `Field` | the wrapper; `orientation` is `"vertical"` (default) or `"horizontal"` |
28
+ | `FieldLabel` | names the control; shows a `*` when the control is `required` |
29
+ | `FieldDescription` | help text, part of the control's description |
30
+ | `FieldError` | the message; `match` picks which problem shows it, `match` alone shows it always |
31
+ | `FieldSet` | a native `<fieldset>`; `disabled` disables every control inside |
32
+ | `FieldLegend` | names the set |
33
+ | `FieldGroup` | stacks the fields of a set |
34
+
35
+ ## Layout
36
+
37
+ Vertical stacks label, control, description and error with `gap-1.5`. Horizontal puts the label in a 12rem column from 640px and the rest in the second column, and stacks under 640px. The label row is as tall as the control, so it stays level in compact density.
38
+
39
+ ## States
40
+
41
+ | State | Source | Look |
42
+ | --------- | ------------------------------------------- | ---------------------------------------------------- |
43
+ | required | the control's `required` or `aria-required` | `*` after the label, empty alternative text |
44
+ | invalid | `invalid`, or a native submit that failed | the control border and the error, `text-destructive` |
45
+ | disabled | `disabled` | label and control at half opacity |
46
+ | read-only | the control's `readOnly` | `bg-muted`, focusable |
47
+
48
+ ## Copy
49
+
50
+ A label names the value, not the action. A description helps before the mistake; an error says what is wrong and how to fix it ("Enter an address like name@example.com"). Errors appear after the field was left or a submit failed, never while the person types the first time.
51
+
52
+ ## Accessibility
53
+
54
+ Target: WCAG 2.2 AA. The label names the control and pressing it focuses the control. The description and a visible error are in `aria-describedby`; an invalid control has `aria-invalid`. The required mark is generated content with an empty alternative text, so a screen reader reads the label alone. Label, description and error meet 4.5:1 in both themes.