@eodparks/ui 0.0.0-stage → 0.2.1

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-Bu72BGjv.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-C-tNDS8C.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,38 @@
1
+ # Textarea
2
+
3
+ A multi-line text field that is fixed, grows with its text, or shows a character count.
4
+
5
+ Wraps `@ui-sdk/react/textarea`. `e2e/textarea.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { Field, FieldDescription, FieldLabel } from "@eodparks/ui/field";
11
+ import { Textarea } from "@eodparks/ui/textarea";
12
+
13
+ <Textarea aria-label="Notes" />
14
+ <Textarea aria-label="Reply" autoResize />
15
+
16
+ <Field>
17
+ <FieldLabel>Bio</FieldLabel>
18
+ <Textarea maxLength={280} value={bio} onValueChange={setBio} />
19
+ <FieldDescription>{bio.length} / 280</FieldDescription>
20
+ </Field>
21
+ ```
22
+
23
+ ## Props
24
+
25
+ | Prop | Type | Default | Notes |
26
+ | ---------------------------------------- | --------- | ------- | --------------------------------------------------------------- |
27
+ | `autoResize` | `boolean` | `false` | grows and shrinks with the text, up to `max-h-64`, then scrolls |
28
+ | `value`, `defaultValue`, `onValueChange` | | | UI SDK's value contract; native `onChange` also works |
29
+
30
+ Everything else passes to the native `<textarea>`: `rows`, `maxLength`, `name`, `required`, `disabled`, `readOnly`, `aria-*`. Give a fixed height with `className="h-24"`; the minimum is 5rem.
31
+
32
+ ## Character count
33
+
34
+ Keep the value in state and show its length in a `FieldDescription`, with `maxLength` on the textarea so a longer value cannot be entered. The description is part of the control's description, not a live region, so it is not read on every key.
35
+
36
+ ## Accessibility
37
+
38
+ Target: WCAG 2.2 AA. A native textarea named by its Field label or an `aria-label`. Same two-layer focus ring, invalid border and contrast as Input. A long unbroken word wraps inside the box.
@@ -0,0 +1,76 @@
1
+ # ThemeToggle
2
+
3
+ An icon button that opens a menu to choose the light, dark or system theme, controlled by the app.
4
+
5
+ `e2e/theme-toggle.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ The app owns the theme. With `next-themes` 0.4.6 (`attribute="class"`):
10
+
11
+ ```tsx
12
+ import { ThemeToggle } from "@eodparks/ui/theme-toggle";
13
+ import { useTheme } from "next-themes";
14
+
15
+ function AppThemeToggle() {
16
+ const { theme, setTheme } = useTheme();
17
+ return <ThemeToggle value={theme} onValueChange={setTheme} />;
18
+ }
19
+ ```
20
+
21
+ The library has no `next-themes` dependency; any state that holds `"light"`, `"dark"` or
22
+ `"system"` works.
23
+
24
+ ## Parts
25
+
26
+ | Export | Is |
27
+ | ------------------ | ------------------------------------------------------------------------------------- |
28
+ | `ThemeToggle` | a ghost `IconButton` that is a `DropdownMenuTrigger`, and a menu of three radio items |
29
+ | `ThemeToggleValue` | `"light" \| "dark" \| "system"` |
30
+ | `ThemeToggleProps` | the props below |
31
+
32
+ ## Props
33
+
34
+ | Prop | Type | Default | Notes |
35
+ | ------------------------------------- | ------------------------------------ | --------------------- | -------------------------------------------------------------- |
36
+ | `value` | `string \| undefined` | required | the chosen theme; anything else, or `undefined`, checks none |
37
+ | `onValueChange` | `(value: ThemeToggleValue) => void` | required | called with the item chosen; the toggle does not change itself |
38
+ | `label` | `string` | `"Choose appearance"` | the trigger's name and tooltip |
39
+ | `labels` | `{ light?, dark?, system?: string }` | Light, Dark, System | item text, for translations |
40
+ | `open`, `defaultOpen`, `onOpenChange` | from `DropdownMenu` | | the menu's open state |
41
+
42
+ ## Variants
43
+
44
+ One look. The trigger icon is a sun in light mode and a moon in dark mode, read from the `dark`
45
+ class on the page, so `system` shows the theme it resolved to.
46
+
47
+ ## States
48
+
49
+ | State | Look |
50
+ | ------------- | ---------------------------------------------------------------------------- |
51
+ | hover | the ghost hover fill, and the tooltip after the delay |
52
+ | focus-visible | the focus ring, and the tooltip at once |
53
+ | open | the menu below the trigger, aligned to its end; the current theme is checked |
54
+
55
+ Choosing an item closes the menu and returns focus to the trigger.
56
+
57
+ ## Keyboard
58
+
59
+ | Key | Result |
60
+ | ----------------------- | --------------------------------------------- |
61
+ | Enter, Space, ArrowDown | opens the menu on its first item |
62
+ | ArrowUp, ArrowDown | moves between Light, Dark and System |
63
+ | Enter, Space | chooses the item and closes the menu |
64
+ | Escape | closes the menu; focus returns to the trigger |
65
+
66
+ ## Accessibility
67
+
68
+ Target: WCAG 2.2 AA. The trigger is a named button that says it opens a menu; the items are
69
+ `menuitemradio` with `aria-checked`, and their icons are hidden. Every colour comes from a semantic
70
+ token with a light and a dark value. Screen reader checks (VoiceOver with Safari, NVDA with Chrome)
71
+ are manual.
72
+
73
+ ## Not in scope
74
+
75
+ Applying the theme, storing it and avoiding a flash on load belong to the app's `next-themes`
76
+ provider.
package/docs/toast.md ADDED
@@ -0,0 +1,95 @@
1
+ # Toast
2
+
3
+ A short message at a corner of the window that confirms an action or reports an event, with sonner's call shape and the library's look.
4
+
5
+ Import from `@eodparks/ui/toast`. `sonner` 2 is a peer dependency, so the app and the library share one toast store.
6
+
7
+ ## Usage
8
+
9
+ Mount one `Toaster` near the root of the app, then call `toast` from anywhere:
10
+
11
+ ```tsx
12
+ <Toaster theme={theme} />;
13
+
14
+ toast.success("Changes saved", { description: "The event page is updated." });
15
+ toast.error("Payment failed", { action: { label: "Retry", onClick: retry } });
16
+ toast.promise(save(), { loading: "Saving", success: "Saved", error: "Could not save" });
17
+ ```
18
+
19
+ Migrating from sonner is an import change only: `import { toast } from "sonner"` becomes `import { toast } from "@eodparks/ui/toast"`.
20
+
21
+ ## Parts
22
+
23
+ | Export | Is |
24
+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------ |
25
+ | `Toaster` | sonner's `Toaster` in a top-layer wrapper, styled with tokens. |
26
+ | `toast` | sonner's `toast` with the same methods: `success`, `error`, `warning`, `info`, `loading`, `promise`, `message`, `custom`, `dismiss`. |
27
+
28
+ ## Props
29
+
30
+ ### Toaster
31
+
32
+ Every sonner `Toaster` prop passes through, except `icons` and `toastOptions.unstyled`, which the library owns.
33
+
34
+ | Prop | Type | Default | Notes |
35
+ | ------------- | --------------------------------- | ----------------- | ------------------------------------- |
36
+ | `theme` | `"light"`, `"dark"` or `"system"` | | Pass the app's theme. |
37
+ | `position` | sonner position | `"bottom-right"` | |
38
+ | `closeButton` | `boolean` | `true` | |
39
+ | `closeLabel` | `string` | `"Close"` | Accessible name of each close button. |
40
+ | `label` | `string` | `"Notifications"` | Accessible name of the region. |
41
+
42
+ ### toast
43
+
44
+ sonner's options. Defaults differ in one way: errors stay 8 seconds, every other type 4 seconds. Pass `duration` to change one toast, `duration: Infinity` to keep it until dismissed.
45
+
46
+ ## Variants
47
+
48
+ | Variant | Call | Look |
49
+ | ----------- | ---------------------------------- | ------------------------------------------------ |
50
+ | default | `toast(title)` | Popover surface, no icon. |
51
+ | success | `toast.success(title)` | `success-subtle` surface and border, check icon. |
52
+ | error | `toast.error(title)` | `destructive-subtle`, cross icon. |
53
+ | warning | `toast.warning(title)` | `warning-subtle`, triangle icon. |
54
+ | info | `toast.info(title)` | `info-subtle`, info icon. |
55
+ | loading | `toast.loading(title)` | Popover surface, spinner. |
56
+ | promise | `toast.promise(promise, messages)` | Loading, then success or error. |
57
+ | with action | `{ action: { label, onClick } }` | A small primary button at the end. |
58
+
59
+ ## States
60
+
61
+ | State | Signal |
62
+ | ---------- | ------------------------------------------------ |
63
+ | entering | `data-mounted="false"` until the first frame. |
64
+ | visible | `data-mounted="true"` and `data-visible="true"`. |
65
+ | dismissing | `data-removed="true"` until it leaves. |
66
+
67
+ The spinner stops under `prefers-reduced-motion`.
68
+
69
+ ## Behaviour
70
+
71
+ - Toasts stack at the corner; hovering or focusing the stack expands it and pauses the timers.
72
+ - Alt+T moves focus to the toasts. Tab then reaches each action and close button.
73
+ - The close button and the action dismiss a toast; `toast.dismiss(id)` dismisses from code.
74
+ - An error raised while a `Dialog`, `AlertDialog`, `Sheet` or any UI SDK popup is open shows above it and takes clicks without closing it. The `Toaster` sits in a zero-size `popover="manual"` element bound with `bindPersistentLayer`, which UI SDK moves back above each popup that opens later. Overlays need no wiring for it.
75
+
76
+ ## Styling hooks
77
+
78
+ `data-slot="toaster-layer"` on the wrapper; sonner's `data-sonner-toast`, `data-type` (absent for the default type), `data-title`, `data-description`, `data-icon`, `data-content` and `data-button` inside. Per-toast classes go through `classNames`.
79
+
80
+ ## Accessibility
81
+
82
+ Target: WCAG 2.2 AA. sonner announces toasts through a polite live region named by `label`. Type
83
+ icons are hidden; the type is in the text and colour is never the only signal. Text and the action meet
84
+ 4.5:1 on every surface and the focus ring 3:1 in both themes. Errors stay twice as long as other
85
+ types; pass `duration: Infinity` for a message the person must act on.
86
+
87
+ ## Copy
88
+
89
+ No prose ships. Built-in strings: `closeLabel` ("Close") and `label` ("Notifications"). Keep a title
90
+ to a few words and put details in `description`.
91
+
92
+ ## Not included
93
+
94
+ - UI SDK `Toast`: the facade moves to it, without an API change, once upstream issue 1076 is fixed.
95
+ - Toasts that need a decision: use `AlertDialog`.
@@ -0,0 +1,101 @@
1
+ # Tooltip
2
+
3
+ Names a control or adds a short hint when the pointer rests on it or keyboard focus reaches it, with the shadcn part names and a UI SDK Tooltip underneath.
4
+
5
+ `e2e/tooltip.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
+ Tooltip,
13
+ TooltipContent,
14
+ TooltipProvider,
15
+ TooltipShortcut,
16
+ TooltipTrigger,
17
+ } from "@eodparks/ui/tooltip";
18
+
19
+ <TooltipProvider delayDuration={300}>
20
+ <Tooltip>
21
+ <TooltipTrigger className={buttonVariants({ variant: "outline", size: "icon" })}>
22
+ <BookmarkIcon aria-hidden />
23
+ </TooltipTrigger>
24
+ <TooltipContent>Add to library</TooltipContent>
25
+ </Tooltip>
26
+ <Tooltip shortcut="mod+s">
27
+ <TooltipTrigger className={buttonVariants()}>Save</TooltipTrigger>
28
+ <TooltipContent>
29
+ Save changes
30
+ <TooltipShortcut />
31
+ </TooltipContent>
32
+ </Tooltip>
33
+ </TooltipProvider>;
34
+ ```
35
+
36
+ ## Parts
37
+
38
+ | Part | Role | Notes |
39
+ | ----------------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
40
+ | `TooltipProvider` | optional; shares `delayDuration` | no DOM; UI SDK groups tooltips without it, so it only sets the default delay |
41
+ | `Tooltip` | root, no DOM of its own | `delay` falls back to the provider's `delayDuration`, then to UI SDK's 600ms |
42
+ | `TooltipTrigger` | the element it names or describes | unstyled; give it `buttonVariants` or `render={<Button />}` |
43
+ | `TooltipContent` | the hint, a `tooltip` | inverse colours (`bg-foreground`, `text-background`), the `caption` text style, at most 320px wide |
44
+ | `TooltipArrow` | optional arrow pointing at the trigger | first child of the content |
45
+ | `TooltipShortcut` | the keys of the root's `shortcut`, `⌘S` or `Ctrl+S` | hidden from screen readers; the trigger gets `aria-keyshortcuts` instead |
46
+
47
+ Not provided: `asChild` (use `render`) and `TooltipPortal` (the hint renders in the top layer).
48
+
49
+ ## Props
50
+
51
+ `TooltipProvider`: `delayDuration` (milliseconds).
52
+
53
+ `Tooltip`: `delay`, `closeDelay` (0), `open`, `defaultOpen`, `onOpenChange`, `disabled`, `toggleable`, `closeOnPress` (`true`), `type` (`"label"` or `"description"`; guessed from the trigger), `shortcut`, `controller`. All from UI SDK.
54
+
55
+ `TooltipContent`: `side` (`"top"`), `align` (`"center"`), `sideOffset` (4; use 8 with an arrow), `alignOffset`, `collisionPadding`, `className`, `render`.
56
+
57
+ Every part carries a `data-slot` (`tooltip-trigger`, `tooltip-content`, `tooltip-arrow`, `tooltip-shortcut`).
58
+
59
+ ## Variants
60
+
61
+ | Variant | How |
62
+ | ------------- | ---------------------------------------------------------------- |
63
+ | sides | `side` on `TooltipContent`; it flips when there is no room |
64
+ | with shortcut | `shortcut` on `Tooltip` and `<TooltipShortcut />` in the content |
65
+ | with arrow | `<TooltipArrow />` in the content and `sideOffset={8}` |
66
+
67
+ ## States
68
+
69
+ | State | Source |
70
+ | ------- | -------------------------------------------------------------------------------------------------- |
71
+ | open | `data-open` on the content, after the delay on hover, at once on keyboard focus |
72
+ | instant | `data-instant` when it opened at once because another tooltip was open a moment ago; no transition |
73
+ | side | `data-side` and `data-align` on the content and the arrow |
74
+
75
+ ## Keyboard
76
+
77
+ | Key | Result |
78
+ | ------------ | ------------------------------------------------------------------------------ |
79
+ | Tab | focus on the trigger opens it at once; focus leaving closes it |
80
+ | Escape | closes it, focus stays on the trigger, and no dialog or menu around it closes |
81
+ | Enter, Space | presses the trigger and closes it; on a `toggleable` trigger, opens and closes |
82
+
83
+ ## Accessibility
84
+
85
+ The content has the `tooltip` role and is in the page while hidden. It names a trigger that has no name of its own, like an icon button, and describes any other. UI SDK sets this; the library adds no roles.
86
+
87
+ A tooltip cannot be focused, so it holds plain text only; use a Popover for links or buttons. A natively disabled button gets no focus and, in some browsers, no hover: to explain why an action is unavailable, use `aria-disabled="true"` on the trigger and ignore its presses. On touch screens a plain tooltip never shows; give an info button `toggleable`.
88
+
89
+ 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.
90
+
91
+ ## Copy
92
+
93
+ A few words of plain text that add to what is visible. The library ships no prose.
94
+
95
+ ## Motion
96
+
97
+ The hint fades and scales in 150ms. One that opens at once skips the transition, and under `prefers-reduced-motion` the scale is removed and the transition is near zero.
98
+
99
+ ## Stacking
100
+
101
+ The hint opens in the top layer, so no ancestor `overflow` clips it. Only one tooltip is open at a time.
@@ -0,0 +1,96 @@
1
+ # Typography
2
+
3
+ Seven text styles named for their role, as a `Text` component and as class recipes for other components.
4
+
5
+ `e2e/typography.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { Text, textVariants } from "@eodparks/ui/typography";
11
+
12
+ <Text variant="page-title">Bookings</Text>
13
+ <Text variant="small">Forty-two bookings this week.</Text>
14
+ <Text variant="section-title" render={<h3 />}>Guests</Text>
15
+ <label className={textVariants({ variant: "label" })}>Email</label>
16
+ ```
17
+
18
+ ## Parts
19
+
20
+ | Export | Is |
21
+ | -------------- | ---------------------------------------------------------------- |
22
+ | `Text` | markup only; renders the element in the table below, or `render` |
23
+ | `textVariants` | the `cva` function, for a part that already has its own element |
24
+ | `TextProps` | the prop type |
25
+ | `TextVariant` | the union of style names |
26
+
27
+ ## Props
28
+
29
+ | Prop | Type | Default | Notes |
30
+ | ----------- | ------------------------------------------------ | -------- | --------------------------------------------------- |
31
+ | `variant` | `TextVariant` | `"body"` | the style |
32
+ | `render` | `ReactElement \| (props, state) => ReactElement` | | change the element and keep the style |
33
+ | `className` | `string` | | merged last with `cn`; colour and width belong here |
34
+
35
+ The element carries `data-slot="text"` and `data-variant`.
36
+
37
+ ## Styles
38
+
39
+ | Variant | Element | Size | Line height | Weight | Use |
40
+ | --------------- | ------- | --------------- | ----------- | ------ | -------------------------------------------------- |
41
+ | `page-title` | `h1` | 1.5rem (24px) | 2rem | 600 | the one title of a page |
42
+ | `section-title` | `h2` | 1.125rem (18px) | 1.75rem | 600 | a section, card, dialog or drawer title |
43
+ | `body` | `p` | 1rem (16px) | 1.5rem | 400 | prose and paragraphs |
44
+ | `small` | `p` | 0.875rem (14px) | 1.25rem | 400 | interface text: controls, tables, lists; the usual |
45
+ | `caption` | `p` | 0.75rem (12px) | 1rem | 400 | secondary notes, timestamps; `muted-foreground` |
46
+ | `label` | `span` | 0.875rem (14px) | 1.25rem | 500 | field labels and the text of controls |
47
+ | `code` | `code` | 0.875rem (14px) | 1.25rem | 400 | identifiers and values; monospace |
48
+
49
+ The style is the meaning. Pick by role, then change the element with `render` so the heading
50
+ levels of the page stay in order: a page has one `h1`, and a `section-title` inside a card may
51
+ be an `h3`.
52
+
53
+ ## Scale
54
+
55
+ Five sizes: 12, 14, 16, 18 and 24 pixels at the default browser font size. No other size is
56
+ used in the library. Display sizes for marketing pages are not part of it.
57
+
58
+ ## Typeface
59
+
60
+ Manrope, one variable file with weights 200 to 800, self-hosted in `@eodparks/tokens`
61
+ (`fonts.css`, `font-display: swap`). The library uses 400, 500 and 600. The fallback is the
62
+ system sans-serif. `code` uses the system monospace stack; no monospace font is loaded.
63
+
64
+ ## Line height
65
+
66
+ Every style sets its own line height, written with the size (`text-sm/5`). Each is a multiple
67
+ of 4px, so stacked text lands on the spacing scale.
68
+
69
+ ## Letter spacing
70
+
71
+ The theme sets `--tracking-body` (-0.025em) on `body`. It resolves there, so every style
72
+ inherits the same fixed length (-0.4px at the default font size) and none restates it. The two
73
+ titles set `tracking-tight`, which is the same ratio at their own size. `code` resets to 0,
74
+ because monospace columns must stay aligned.
75
+
76
+ ## Responsive behaviour
77
+
78
+ Sizes are fixed at every viewport width; the layout adapts, not the type. Titles wrap and are
79
+ balanced across lines (`text-balance`). Nothing truncates by default.
80
+
81
+ ## Minimum size
82
+
83
+ The smallest text is 12px (`caption`, and the `xs` button). Nothing in the library goes below
84
+ it. It is checked in the browser, with Manrope loaded, on the states page.
85
+
86
+ ## Zoom and colour
87
+
88
+ Every size and line height is in `rem`, so text follows the browser font size and holds up at
89
+ 200% zoom without sideways scrolling. No style carries meaning by colour alone: `caption` is
90
+ muted for hierarchy only and still meets 4.5:1 on the page, card and muted surfaces. A status
91
+ is written in words or paired with an icon.
92
+
93
+ ## Not in scope
94
+
95
+ Markdown and long-form content (`Prose`), links (`Link`), keyboard hints (`Kbd`), truncation
96
+ with a tooltip.
@@ -0,0 +1,44 @@
1
+ # VisuallyHidden
2
+
3
+ Keeps text out of sight and in the accessibility tree, for a name or a heading that only assistive technology needs.
4
+
5
+ `e2e/visually-hidden.spec.ts` is the executable form of this page.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { VisuallyHidden } from "@eodparks/ui/visually-hidden";
11
+
12
+ <Button size="icon">
13
+ <PlusIcon />
14
+ <VisuallyHidden>Add guest</VisuallyHidden>
15
+ </Button>
16
+
17
+ <VisuallyHidden render={<h2 />}>Filters</VisuallyHidden>
18
+ ```
19
+
20
+ ## Props
21
+
22
+ | Prop | Type | Default | Notes |
23
+ | ----------- | ------------------------------------------------ | ------- | ------------------------------------------------- |
24
+ | `render` | `ReactElement \| (props, state) => ReactElement` | | change the element; the default is a `<span>` |
25
+ | `className` | `string` | | merged with `cn`; it cannot make the text visible |
26
+
27
+ Everything else passes to the element. It carries `data-slot="visually-hidden"`.
28
+
29
+ ## When to use it
30
+
31
+ - A name for a control whose only visible content is an icon, when `aria-label` does not fit
32
+ (the text must be translated with the page, or holds more than a short name).
33
+ - A heading that structures a region for screen readers where the design shows none.
34
+ - Words that complete a visible fragment: "3" on screen, "3 unread messages" when read aloud.
35
+
36
+ Use `aria-label` for a short name on a control. Do not hide text that sighted keyboard users
37
+ need, and do not put a focusable control inside: focus would land on something invisible. A
38
+ skip link that appears on focus is `SkipLink`.
39
+
40
+ ## Accessibility
41
+
42
+ Target: WCAG 2.2 AA. The text stays in the accessibility tree and in the reading order where it
43
+ is written. It adds no role and no ARIA attribute. The element takes no room: it is one pixel,
44
+ clipped, and out of the flow, so it never causes a scrollbar, in either writing direction.
package/layer.css ADDED
@@ -0,0 +1,22 @@
1
+ /* Import first in the app's global stylesheet. It declares the ui-sdk layer
2
+ before every other layer, so any style wins over it, and adds the rules
3
+ server-rendered markup needs before the page hydrates. */
4
+ @layer ui-sdk;
5
+
6
+ @layer ui-sdk {
7
+ :where([data-slot][hidden]:not([hidden="until-found"])) {
8
+ display: none !important;
9
+ }
10
+
11
+ :where([data-mirror][aria-hidden]) {
12
+ display: inline-block;
13
+ }
14
+
15
+ :where([data-mirror][aria-hidden]:dir(rtl)) {
16
+ scale: -1 1;
17
+ }
18
+
19
+ :where([data-slot="slider-thumb"]:dir(rtl)) {
20
+ --slider-thumb-sign: 1;
21
+ }
22
+ }