@slashsuite/ui-react 0.12.1 → 0.13.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 (367) hide show
  1. package/MIGRATING.md +386 -8
  2. package/README.md +89 -44
  3. package/agent-docs/components/app-shell.md +9 -6
  4. package/agent-docs/components/article-layout.md +140 -0
  5. package/agent-docs/components/audio.md +42 -0
  6. package/agent-docs/components/badge.md +2 -1
  7. package/agent-docs/components/body-text.md +26 -15
  8. package/agent-docs/components/bottom-sheet.md +27 -17
  9. package/agent-docs/components/breadcrumbs.md +10 -6
  10. package/agent-docs/components/button.md +2 -2
  11. package/agent-docs/components/call-to-action.md +59 -0
  12. package/agent-docs/components/callout.md +4 -3
  13. package/agent-docs/components/card-grid.md +15 -7
  14. package/agent-docs/components/card.md +33 -18
  15. package/agent-docs/components/cart-button.md +63 -0
  16. package/agent-docs/components/chat-composer.md +4 -3
  17. package/agent-docs/components/checkbox.md +11 -5
  18. package/agent-docs/components/cluster.md +10 -8
  19. package/agent-docs/components/code-example.md +2 -2
  20. package/agent-docs/components/code.md +7 -5
  21. package/agent-docs/components/colour-scheme-toggle.md +12 -6
  22. package/agent-docs/components/colour-swatch.md +41 -0
  23. package/agent-docs/components/combobox.md +88 -0
  24. package/agent-docs/components/confirm-dialog.md +98 -0
  25. package/agent-docs/components/container.md +2 -1
  26. package/agent-docs/components/copy-button.md +7 -5
  27. package/agent-docs/components/copy-line.md +6 -5
  28. package/agent-docs/components/date-field.md +14 -11
  29. package/agent-docs/components/date-range-picker.md +16 -9
  30. package/agent-docs/components/date-time-field.md +73 -0
  31. package/agent-docs/components/dialog.md +22 -68
  32. package/agent-docs/components/disclosure.md +4 -0
  33. package/agent-docs/components/docs-layout.md +10 -6
  34. package/agent-docs/components/drawer.md +13 -4
  35. package/agent-docs/components/embed-frame.md +48 -0
  36. package/agent-docs/components/empty-state.md +4 -1
  37. package/agent-docs/components/field-dialog.md +6 -5
  38. package/agent-docs/components/field.md +10 -7
  39. package/agent-docs/components/fieldset.md +4 -4
  40. package/agent-docs/components/flow-diagram.md +87 -0
  41. package/agent-docs/components/form-layout.md +4 -1
  42. package/agent-docs/components/form-row.md +7 -7
  43. package/agent-docs/components/full-bleed-layout.md +0 -2
  44. package/agent-docs/components/headings.md +13 -7
  45. package/agent-docs/components/hero.md +11 -2
  46. package/agent-docs/components/icon-button.md +1 -3
  47. package/agent-docs/components/icon.md +6 -13
  48. package/agent-docs/components/image.md +24 -14
  49. package/agent-docs/components/input.md +8 -7
  50. package/agent-docs/components/key-value-list.md +4 -1
  51. package/agent-docs/components/lightbox.md +1 -1
  52. package/agent-docs/components/list-layout.md +5 -7
  53. package/agent-docs/components/list-row.md +37 -34
  54. package/agent-docs/components/loading.md +2 -2
  55. package/agent-docs/components/markdown.md +13 -13
  56. package/agent-docs/components/media-tile.md +8 -4
  57. package/agent-docs/components/menu.md +19 -12
  58. package/agent-docs/components/meta-list.md +2 -2
  59. package/agent-docs/components/morph.md +11 -5
  60. package/agent-docs/components/navigation-progress.md +2 -2
  61. package/agent-docs/components/number-field.md +75 -0
  62. package/agent-docs/components/outline-region.md +19 -8
  63. package/agent-docs/components/page-fade.md +2 -1
  64. package/agent-docs/components/pill.md +7 -6
  65. package/agent-docs/components/popover.md +63 -0
  66. package/agent-docs/components/price.md +49 -0
  67. package/agent-docs/components/product-tile.md +78 -0
  68. package/agent-docs/components/promo-banner.md +46 -0
  69. package/agent-docs/components/prose-layout.md +1 -1
  70. package/agent-docs/components/radio-group.md +9 -6
  71. package/agent-docs/components/scroll-strip.md +3 -3
  72. package/agent-docs/components/segmented-control.md +4 -2
  73. package/agent-docs/components/select.md +8 -3
  74. package/agent-docs/components/show.md +2 -2
  75. package/agent-docs/components/side-column.md +13 -9
  76. package/agent-docs/components/sidebar-layout.md +1 -1
  77. package/agent-docs/components/site-footer.md +4 -4
  78. package/agent-docs/components/site-search.md +21 -9
  79. package/agent-docs/components/slider.md +59 -0
  80. package/agent-docs/components/sortable-list.md +15 -10
  81. package/agent-docs/components/stack.md +3 -3
  82. package/agent-docs/components/stacked-bar.md +7 -4
  83. package/agent-docs/components/state-machine.md +95 -0
  84. package/agent-docs/components/status-pages.md +13 -6
  85. package/agent-docs/components/stepper.md +54 -0
  86. package/agent-docs/components/switch.md +4 -4
  87. package/agent-docs/components/table-of-contents.md +78 -0
  88. package/agent-docs/components/table.md +35 -24
  89. package/agent-docs/components/tabs.md +24 -26
  90. package/agent-docs/components/text-link.md +12 -7
  91. package/agent-docs/components/textarea.md +4 -2
  92. package/agent-docs/components/toast.md +19 -14
  93. package/agent-docs/components/video.md +7 -2
  94. package/agent-docs/llms.txt +22 -3
  95. package/dist/AppShell.d.ts +25 -9
  96. package/dist/AppShell.js +67 -33
  97. package/dist/AppShellMenu.d.ts +31 -18
  98. package/dist/AppShellMenu.js +72 -45
  99. package/dist/ArticleLayout.d.ts +36 -0
  100. package/dist/ArticleLayout.js +27 -0
  101. package/dist/Audio.d.ts +16 -0
  102. package/dist/Audio.js +11 -0
  103. package/dist/Badge.d.ts +2 -1
  104. package/dist/Badge.js +3 -2
  105. package/dist/BottomSheet.d.ts +17 -6
  106. package/dist/BottomSheet.js +62 -11
  107. package/dist/Breadcrumbs.d.ts +8 -6
  108. package/dist/Breadcrumbs.js +17 -7
  109. package/dist/Button.d.ts +1 -0
  110. package/dist/Button.js +4 -3
  111. package/dist/CallToAction.d.ts +25 -0
  112. package/dist/CallToAction.js +17 -0
  113. package/dist/Callout.d.ts +2 -2
  114. package/dist/Callout.js +2 -2
  115. package/dist/Card.d.ts +88 -31
  116. package/dist/Card.js +55 -92
  117. package/dist/CardBody.d.ts +2 -0
  118. package/dist/CardBody.js +33 -3
  119. package/dist/CardGrid.d.ts +32 -4
  120. package/dist/CardGrid.js +42 -8
  121. package/dist/CardParts.d.ts +7 -1
  122. package/dist/CardParts.js +7 -2
  123. package/dist/CartButton.d.ts +33 -0
  124. package/dist/CartButton.js +18 -0
  125. package/dist/ChatComposer.d.ts +10 -4
  126. package/dist/ChatComposer.js +35 -13
  127. package/dist/Checkbox.d.ts +21 -3
  128. package/dist/Checkbox.js +66 -20
  129. package/dist/Chevron.js +1 -1
  130. package/dist/Cluster.d.ts +28 -15
  131. package/dist/Cluster.js +21 -4
  132. package/dist/Code.d.ts +15 -3
  133. package/dist/Code.js +23 -3
  134. package/dist/CodeBlock.d.ts +4 -4
  135. package/dist/CodeBlock.js +2 -2
  136. package/dist/CodeBody.d.ts +1 -1
  137. package/dist/CodeBody.js +4 -10
  138. package/dist/CodeExample.d.ts +1 -1
  139. package/dist/CodeExample.js +3 -2
  140. package/dist/ColourSchemeToggle.d.ts +21 -5
  141. package/dist/ColourSchemeToggle.js +15 -9
  142. package/dist/ColourSwatch.d.ts +15 -0
  143. package/dist/ColourSwatch.js +14 -0
  144. package/dist/Combobox.d.ts +42 -0
  145. package/dist/Combobox.js +43 -0
  146. package/dist/ConfirmDialog.d.ts +40 -0
  147. package/dist/ConfirmDialog.js +36 -0
  148. package/dist/Container.d.ts +3 -3
  149. package/dist/Container.js +1 -1
  150. package/dist/CopyButton.d.ts +8 -2
  151. package/dist/CopyButton.js +38 -28
  152. package/dist/CopyLine.d.ts +4 -2
  153. package/dist/CopyLine.js +4 -4
  154. package/dist/DateCalendar.d.ts +2 -0
  155. package/dist/DateCalendar.js +11 -9
  156. package/dist/DateField.d.ts +52 -21
  157. package/dist/DateField.js +73 -37
  158. package/dist/DateFieldCalendar.d.ts +12 -8
  159. package/dist/DateFieldCalendar.js +37 -18
  160. package/dist/DateRangePicker.d.ts +23 -3
  161. package/dist/DateRangePicker.js +10 -8
  162. package/dist/DateTimeField.d.ts +31 -0
  163. package/dist/DateTimeField.js +19 -0
  164. package/dist/Dialog.d.ts +42 -6
  165. package/dist/Dialog.js +50 -12
  166. package/dist/Disclosure.js +9 -1
  167. package/dist/DocsLayout.d.ts +13 -5
  168. package/dist/DocsLayout.js +11 -9
  169. package/dist/Drawer.d.ts +22 -7
  170. package/dist/Drawer.js +89 -8
  171. package/dist/EmbedFrame.d.ts +36 -0
  172. package/dist/EmbedFrame.js +18 -0
  173. package/dist/Field.d.ts +41 -4
  174. package/dist/Field.js +61 -25
  175. package/dist/FieldDialog.d.ts +8 -3
  176. package/dist/FieldDialog.js +19 -9
  177. package/dist/Fieldset.d.ts +3 -3
  178. package/dist/Fieldset.js +7 -9
  179. package/dist/FileDrop.js +2 -1
  180. package/dist/FlowDiagram.d.ts +92 -0
  181. package/dist/FlowDiagram.js +100 -0
  182. package/dist/FormRow.d.ts +6 -4
  183. package/dist/FormRow.js +11 -9
  184. package/dist/Hero.d.ts +30 -7
  185. package/dist/Hero.js +23 -9
  186. package/dist/Icon.d.ts +1 -1
  187. package/dist/Icon.js +1 -1
  188. package/dist/IconButton.js +1 -1
  189. package/dist/Image.d.ts +33 -9
  190. package/dist/Image.js +61 -16
  191. package/dist/Input.d.ts +1 -1
  192. package/dist/Input.js +4 -4
  193. package/dist/InputShell.d.ts +7 -0
  194. package/dist/InputShell.js +18 -3
  195. package/dist/KeyValueList.d.ts +2 -2
  196. package/dist/Lightbox.js +5 -3
  197. package/dist/ListRow.d.ts +4 -5
  198. package/dist/ListRow.js +36 -26
  199. package/dist/Mark.d.ts +10 -0
  200. package/dist/Mark.js +9 -0
  201. package/dist/Markdown.d.ts +18 -4
  202. package/dist/Markdown.js +176 -37
  203. package/dist/MediaTile.d.ts +9 -3
  204. package/dist/MediaTile.js +8 -4
  205. package/dist/Menu.d.ts +19 -8
  206. package/dist/Menu.js +13 -11
  207. package/dist/MetaList.d.ts +4 -3
  208. package/dist/MetaList.js +12 -4
  209. package/dist/Morph.d.ts +15 -1
  210. package/dist/Morph.js +70 -22
  211. package/dist/NavigationProgress.d.ts +2 -2
  212. package/dist/NavigationProgress.js +7 -5
  213. package/dist/NumberField.d.ts +66 -0
  214. package/dist/NumberField.js +68 -0
  215. package/dist/OutlineRegion.d.ts +41 -10
  216. package/dist/OutlineRegion.js +31 -6
  217. package/dist/PageFade.d.ts +9 -5
  218. package/dist/PageFade.js +39 -8
  219. package/dist/PageLayouts.d.ts +15 -5
  220. package/dist/PageLayouts.js +3 -3
  221. package/dist/Pill.d.ts +9 -4
  222. package/dist/Pill.js +15 -6
  223. package/dist/Popover.d.ts +31 -0
  224. package/dist/Popover.js +43 -0
  225. package/dist/Price.d.ts +21 -0
  226. package/dist/Price.js +34 -0
  227. package/dist/ProductTile.d.ts +36 -0
  228. package/dist/ProductTile.js +31 -0
  229. package/dist/ProgressBar.js +4 -2
  230. package/dist/PromoBanner.d.ts +25 -0
  231. package/dist/PromoBanner.js +16 -0
  232. package/dist/RadioGroup.d.ts +18 -8
  233. package/dist/RadioGroup.js +42 -18
  234. package/dist/ScrollStrip.d.ts +1 -1
  235. package/dist/ScrollStrip.js +1 -1
  236. package/dist/SearchInput.d.ts +17 -2
  237. package/dist/SearchInput.js +72 -13
  238. package/dist/SegmentedField.d.ts +15 -0
  239. package/dist/SegmentedField.js +15 -0
  240. package/dist/Select.js +5 -4
  241. package/dist/Show.d.ts +1 -1
  242. package/dist/Show.js +1 -1
  243. package/dist/SideColumn.d.ts +42 -15
  244. package/dist/SideColumn.js +45 -19
  245. package/dist/SiteFooter.d.ts +3 -3
  246. package/dist/SiteFooter.js +4 -3
  247. package/dist/SiteSearch.d.ts +57 -27
  248. package/dist/SiteSearch.js +13 -93
  249. package/dist/Slider.d.ts +27 -0
  250. package/dist/Slider.js +58 -0
  251. package/dist/SortableList.d.ts +19 -35
  252. package/dist/SortableList.js +36 -88
  253. package/dist/Stack.d.ts +4 -4
  254. package/dist/StackedBar.d.ts +13 -4
  255. package/dist/StackedBar.js +12 -7
  256. package/dist/StateMachine.d.ts +65 -0
  257. package/dist/StateMachine.js +113 -0
  258. package/dist/StatusPages.d.ts +28 -10
  259. package/dist/StatusPages.js +10 -10
  260. package/dist/Stepper.d.ts +21 -0
  261. package/dist/Stepper.js +33 -0
  262. package/dist/Steps.js +4 -3
  263. package/dist/Switch.d.ts +3 -3
  264. package/dist/Switch.js +18 -14
  265. package/dist/Table.d.ts +32 -9
  266. package/dist/Table.js +50 -20
  267. package/dist/TableCells.d.ts +24 -21
  268. package/dist/TableCells.js +68 -27
  269. package/dist/TableEditCell.d.ts +1 -1
  270. package/dist/TableOfContents.d.ts +34 -0
  271. package/dist/TableOfContents.js +23 -0
  272. package/dist/Tabs.d.ts +31 -16
  273. package/dist/Tabs.js +97 -22
  274. package/dist/TextLink.d.ts +18 -5
  275. package/dist/TextLink.js +19 -6
  276. package/dist/Textarea.d.ts +12 -1
  277. package/dist/Textarea.js +15 -2
  278. package/dist/ToastRegion.d.ts +17 -9
  279. package/dist/ToastRegion.js +70 -13
  280. package/dist/Tooltip.d.ts +10 -2
  281. package/dist/Tooltip.js +32 -11
  282. package/dist/Video.d.ts +19 -4
  283. package/dist/Video.js +15 -5
  284. package/dist/cardContext.d.ts +7 -0
  285. package/dist/cardContext.js +14 -0
  286. package/dist/cardControl.d.ts +15 -0
  287. package/dist/cardControl.js +32 -0
  288. package/dist/cardForm.d.ts +39 -0
  289. package/dist/cardForm.js +81 -0
  290. package/dist/cardWait.js +2 -1
  291. package/dist/colourScheme.d.ts +12 -2
  292. package/dist/colourScheme.js +32 -6
  293. package/dist/control.d.ts +30 -8
  294. package/dist/control.js +74 -7
  295. package/dist/copyScript.d.ts +7 -8
  296. package/dist/copyScript.js +8 -9
  297. package/dist/cx.d.ts +22 -3
  298. package/dist/cx.js +22 -3
  299. package/dist/dateLocale.d.ts +17 -0
  300. package/dist/dateLocale.js +30 -0
  301. package/dist/density.d.ts +15 -1
  302. package/dist/density.js +27 -8
  303. package/dist/emptySlot.d.ts +1 -0
  304. package/dist/fieldAnnounce.d.ts +11 -0
  305. package/dist/fieldAnnounce.js +36 -0
  306. package/dist/fieldControl.d.ts +7 -2
  307. package/dist/fieldControl.js +6 -2
  308. package/dist/fieldWait.d.ts +3 -3
  309. package/dist/fieldWait.js +3 -4
  310. package/dist/flowLayout.d.ts +68 -0
  311. package/dist/flowLayout.js +105 -0
  312. package/dist/fromXState.d.ts +73 -0
  313. package/dist/fromXState.js +110 -0
  314. package/dist/icons.d.ts +1 -1
  315. package/dist/icons.js +15 -0
  316. package/dist/index.d.ts +37 -11
  317. package/dist/index.js +24 -2
  318. package/dist/isoDate.d.ts +8 -1
  319. package/dist/isoDate.js +20 -1
  320. package/dist/labelWords.d.ts +16 -7
  321. package/dist/labelWords.js +14 -12
  322. package/dist/listRowProps.d.ts +17 -15
  323. package/dist/modal.d.ts +5 -0
  324. package/dist/modal.js +21 -1
  325. package/dist/navFold.js +6 -3
  326. package/dist/optionCard.d.ts +18 -0
  327. package/dist/optionCard.js +16 -0
  328. package/dist/scrollBody.d.ts +16 -0
  329. package/dist/scrollBody.js +15 -0
  330. package/dist/scrollEdges.d.ts +7 -0
  331. package/dist/scrollEdges.js +39 -5
  332. package/dist/scrollStop.d.ts +6 -2
  333. package/dist/scrollStop.js +24 -8
  334. package/dist/shownDate.d.ts +28 -10
  335. package/dist/shownDate.js +41 -22
  336. package/dist/siteSearchBody.d.ts +34 -0
  337. package/dist/siteSearchBody.js +117 -0
  338. package/dist/size.d.ts +7 -1
  339. package/dist/sortableDrop.d.ts +44 -0
  340. package/dist/sortableDrop.js +78 -0
  341. package/dist/sortableSlide.d.ts +9 -0
  342. package/dist/sortableSlide.js +70 -0
  343. package/dist/sortableTitle.d.ts +10 -0
  344. package/dist/sortableTitle.js +48 -0
  345. package/dist/stateMachineDots.d.ts +45 -0
  346. package/dist/stateMachineDots.js +162 -0
  347. package/dist/stickyColumn.d.ts +2 -2
  348. package/dist/stickyColumn.js +2 -2
  349. package/dist/switcher.d.ts +10 -5
  350. package/dist/switcher.js +7 -5
  351. package/dist/tableColumns.d.ts +17 -0
  352. package/dist/tableColumns.js +30 -2
  353. package/dist/tableEmpty.js +5 -5
  354. package/dist/tableRow.d.ts +26 -2
  355. package/dist/tableRow.js +23 -1
  356. package/dist/tableSort.d.ts +10 -5
  357. package/dist/tableSort.js +15 -4
  358. package/dist/target.d.ts +12 -0
  359. package/dist/target.js +12 -0
  360. package/dist/textBox.js +1 -1
  361. package/dist/truncated.d.ts +31 -0
  362. package/dist/truncated.js +51 -0
  363. package/dist/typography.d.ts +19 -11
  364. package/dist/typography.js +11 -13
  365. package/dist/useFlowLayout.d.ts +27 -0
  366. package/dist/useFlowLayout.js +119 -0
  367. package/package.json +3 -2
package/dist/Video.js CHANGED
@@ -1,9 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from "./cx.js";
3
+ import { ASPECT } from "./Image.js";
2
4
  /**
3
- * A `<video>` with controls, full width and rounded; it loads metadata only, so the page does not
4
- * pull the file until it is played. `src` is the app's own video; `captions` is a WebVTT file,
5
- * offered as the default track. `children` is the fallback for a browser that cannot play it.
5
+ * `loading="lazy"` on a media element: the browser holds back even the metadata of one far below
6
+ * the fold. React passes the attribute through, but its types know it only on `<img>` and
7
+ * `<iframe>`, so it is spread from here; a browser without it ignores it and loads as before.
6
8
  */
7
- export function Video({ src, captions, children, ...rest }) {
8
- return (_jsxs("video", { controls: true, preload: "metadata", src: src, ...rest, className: "w-full rounded-lg", children: [captions && _jsx("track", { kind: "captions", src: captions, default: true }), children] }));
9
+ export const LAZY_MEDIA = { loading: "lazy" };
10
+ /**
11
+ * A `<video>` with controls, full width and rounded, in a fixed shape: `aspect` reserves its space
12
+ * before it loads, so the page does not jump, and the video fits inside it whole. It loads metadata
13
+ * only, and lazily where the browser can, so the page does not pull the file until it is played.
14
+ * `src` is the app's own video; `captions` is a WebVTT file, offered as the default track.
15
+ * `children` is the fallback for a browser that cannot play it.
16
+ */
17
+ export function Video({ src, captions, aspect = "16:9", children, ...rest }) {
18
+ return (_jsxs("video", { controls: true, preload: "metadata", ...LAZY_MEDIA, src: src, ...rest, className: cx("block w-full rounded-lg bg-black/90 object-contain", ASPECT[aspect]), children: [captions && _jsx("track", { kind: "captions", src: captions, default: true }), children] }));
9
19
  }
@@ -6,3 +6,10 @@ export declare function InCard({ value, children, }: {
6
6
  }): ReactElement;
7
7
  /** `true` inside a `Card`. */
8
8
  export declare function useInCard(): boolean;
9
+ /** Sets whether the cards in `children` line up their regions with their neighbours'. */
10
+ export declare function InRegions({ value, children, }: {
11
+ value: boolean;
12
+ children: ReactNode;
13
+ }): ReactElement;
14
+ /** `true` for a card directly in a `CardGrid align="regions"`. */
15
+ export declare function useRegions(): boolean;
@@ -12,3 +12,17 @@ export function InCard({ value = true, children, }) {
12
12
  export function useInCard() {
13
13
  return useContext(CardContext);
14
14
  }
15
+ /**
16
+ * Whether a card sits directly in a `CardGrid align="regions"`: it is then a subgrid of the cell's
17
+ * three rows. A card resets it to `false` for what it holds, so a nested card keeps its own layout.
18
+ * Internal: not exported from the package.
19
+ */
20
+ const RegionsContext = createContext(false);
21
+ /** Sets whether the cards in `children` line up their regions with their neighbours'. */
22
+ export function InRegions({ value, children, }) {
23
+ return createElement(RegionsContext.Provider, { value }, children);
24
+ }
25
+ /** `true` for a card directly in a `CardGrid align="regions"`. */
26
+ export function useRegions() {
27
+ return useContext(RegionsContext);
28
+ }
@@ -0,0 +1,15 @@
1
+ import type { ReactElement } from "react";
2
+ /** Splits a link or button card's props into the attributes for the root and the rest, for the control. Internal. */
3
+ export declare function splitRootAttrs(props: object): [Record<string, unknown>, Record<string, unknown>];
4
+ /** What the control does: a button's press, or a link's address. */
5
+ export type CardAction = {
6
+ onPress: () => void;
7
+ href?: undefined;
8
+ external?: undefined;
9
+ } | {
10
+ onPress?: undefined;
11
+ href: string;
12
+ external?: boolean | undefined;
13
+ };
14
+ /** The link or button stretched over the card, named by `nameId` unless the caller named it. Internal. */
15
+ export declare function cardControl(action: CardAction, control: Record<string, unknown>, nameId: string): ReactElement;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx, insetFocusRing } from "./cx.js";
3
+ import { renderLink } from "./link.js";
4
+ /** What names or marks the control itself: these stay on the overlay; `id`, `data-*` and every other `aria-*` go on the card. */
5
+ const CONTROL_OWN = new Set(["aria-label", "aria-labelledby", "aria-current", "aria-pressed"]);
6
+ /** Splits a link or button card's props into the attributes for the root and the rest, for the control. Internal. */
7
+ export function splitRootAttrs(props) {
8
+ const root = {};
9
+ const control = {};
10
+ for (const [key, value] of Object.entries(props)) {
11
+ const onRoot = key === "id" || key.startsWith("data-") || (key.startsWith("aria-") && !CONTROL_OWN.has(key));
12
+ (onRoot ? root : control)[key] = value;
13
+ }
14
+ return [root, control];
15
+ }
16
+ /** The overlay that makes the whole card one control: empty, stretched over the card, its ring drawn inside, since a clipped card cuts anything outside it. */
17
+ const STRETCH = cx("link-stretch absolute inset-0 rounded-xl", insetFocusRing);
18
+ /** The link or button stretched over the card, named by `nameId` unless the caller named it. Internal. */
19
+ export function cardControl(action, control, nameId) {
20
+ const name = control["aria-label"] === undefined ? { "aria-labelledby": nameId } : {};
21
+ if (action.onPress !== undefined) {
22
+ return (_jsx("button", { type: "button", ...name, ...control, onClick: action.onPress, className: cx(STRETCH, "cursor-pointer") }));
23
+ }
24
+ return renderLink({
25
+ ...name,
26
+ ...control,
27
+ href: action.href,
28
+ external: action.external ?? false,
29
+ className: STRETCH,
30
+ children: null,
31
+ });
32
+ }
@@ -0,0 +1,39 @@
1
+ import type { ReactNode } from "react";
2
+ import type { IconName } from "./icons.js";
3
+ import type { Size } from "./size.js";
4
+ import type { Tone } from "./tone.js";
5
+ /** The peer hues a set of cards can take, one each: green is the palette's emerald and yellow its amber. */
6
+ export type CardHue = "orange" | "violet" | "sky" | "green" | "yellow" | "blue";
7
+ /** What a caller asks of a card's look. Internal. */
8
+ export type CardAsk = {
9
+ flush?: boolean | undefined;
10
+ bar?: boolean | undefined;
11
+ dashed?: boolean | undefined;
12
+ tone?: Tone | undefined;
13
+ hue?: CardHue | undefined;
14
+ attention?: boolean | undefined;
15
+ icon?: IconName | undefined;
16
+ fill?: boolean | undefined;
17
+ width?: "sm" | undefined;
18
+ size: Size;
19
+ };
20
+ /** `bar` needs a title or actions to fill it. Internal. */
21
+ export declare function cardForm(asked: CardAsk, hasHeader: boolean, regions: boolean): {
22
+ dashed: boolean;
23
+ tone: Tone | undefined;
24
+ hue: CardHue | undefined;
25
+ flush: boolean;
26
+ bar: boolean;
27
+ attention: boolean;
28
+ icon: "alert" | "baseline" | "bell" | "branch" | "briefcase" | "capture" | "card" | "cart" | "check" | "chevron-down" | "chevron-right" | "ci" | "close" | "compass" | "diff" | "external-link" | "field" | "grid" | "minus" | "more" | "page" | "pause" | "play" | "plus" | "pointer" | "privacy" | "review" | "search" | "self-host" | "settings" | "speed" | "table" | "theme" | "type" | "window" | undefined;
29
+ fill: boolean;
30
+ width: "sm" | undefined;
31
+ regions: boolean;
32
+ size: Size;
33
+ footer: boolean;
34
+ };
35
+ export type CardForm = ReturnType<typeof cardForm>;
36
+ /** A card with a `footer`. Internal. */
37
+ export declare function withFooter(form: CardForm, footer: ReactNode): CardForm;
38
+ /** The card root's classes. Internal. */
39
+ export declare function cardClass(form: CardForm): string;
@@ -0,0 +1,81 @@
1
+ import { TONE_SURFACE } from "./Callout.js";
2
+ import { BODY_PAD } from "./CardBody.js";
3
+ import { cx, liftInteractive } from "./cx.js";
4
+ /** A peer hue's fill and edge, remapped by every theme (the `peer` role in `palette.json`). */
5
+ const HUE_SURFACE = {
6
+ orange: "border-orange-300 bg-orange-100",
7
+ violet: "border-violet-300 bg-violet-100",
8
+ sky: "border-sky-300 bg-sky-100",
9
+ green: "border-emerald-300 bg-emerald-100",
10
+ yellow: "border-amber-300 bg-amber-100",
11
+ blue: "border-blue-300 bg-blue-100",
12
+ };
13
+ /** A mark needs the padded body above a heading, so it has no place in a strip or a flush card. */
14
+ function paddedIcon(asked, bar) {
15
+ return bar || asked.flush ? undefined : asked.icon;
16
+ }
17
+ /** The card's surface: `bar` has no tone, and a hue gives way to `tone`, `bar` and `dashed`. */
18
+ function cardSurface(asked, bar) {
19
+ const dashed = asked.dashed ?? false;
20
+ const tone = bar ? undefined : asked.tone;
21
+ return { dashed, tone, hue: bar || dashed || tone ? undefined : asked.hue };
22
+ }
23
+ /** `bar` needs a title or actions to fill it. Internal. */
24
+ export function cardForm(asked, hasHeader, regions) {
25
+ const bar = (asked.bar ?? false) && hasHeader;
26
+ const fill = asked.fill ?? false;
27
+ return {
28
+ flush: asked.flush ?? false,
29
+ bar,
30
+ ...cardSurface(asked, bar),
31
+ attention: asked.attention ?? false,
32
+ icon: paddedIcon(asked, bar),
33
+ fill,
34
+ width: asked.width,
35
+ // A filled card takes its parent's height, so it has no rows to share.
36
+ regions: regions && !fill,
37
+ size: asked.size,
38
+ footer: false,
39
+ };
40
+ }
41
+ /** A card with a `footer`. Internal. */
42
+ export function withFooter(form, footer) {
43
+ return { ...form, footer: Boolean(footer) };
44
+ }
45
+ function surfaceOf(form) {
46
+ if (form.tone)
47
+ return TONE_SURFACE[form.tone];
48
+ if (form.hue)
49
+ return HUE_SURFACE[form.hue];
50
+ return "border-slate-200/70 bg-white";
51
+ }
52
+ function cardBorder(form) {
53
+ const surface = surfaceOf(form);
54
+ if (!form.attention)
55
+ return surface;
56
+ // The warn tone's strong edge in place of the border colour; the fill stays.
57
+ const fill = surface.split(" ").filter((c) => c.startsWith("bg-"));
58
+ return cx("border-amber-600", ...fill);
59
+ }
60
+ function cardPadding(form) {
61
+ return (!form.flush && !form.bar && !form.footer && !form.fill && !form.regions && BODY_PAD[form.size]);
62
+ }
63
+ /** In a `CardGrid align="regions"` the card is a subgrid of three rows (header, body, footer), so each lines up with its neighbours'. */
64
+ const REGION_ROWS = "row-span-3 grid grid-rows-subgrid gap-0";
65
+ function cardLayout(form) {
66
+ if (form.regions)
67
+ return REGION_ROWS;
68
+ return form.fill ? "flex h-full min-h-0 flex-col" : form.footer && "flex flex-col";
69
+ }
70
+ /** A dashed edge, and a shadow only on the plain white card. */
71
+ function cardEdge(form) {
72
+ return cx(form.dashed && "border-dashed", !form.tone && !form.hue && !form.dashed && "shadow-sm");
73
+ }
74
+ /** A card whose parts run to its edge clips them to its radius. */
75
+ function cardClip(form) {
76
+ return (form.flush || form.bar || form.footer || form.fill || form.regions) && "overflow-hidden";
77
+ }
78
+ /** The card root's classes. Internal. */
79
+ export function cardClass(form) {
80
+ return cx("relative scroll-mt-[calc(var(--app-header,0px)+1rem)] rounded-xl border target:outline-2 target:outline-violet-600", liftInteractive, cardBorder(form), cardEdge(form), cardPadding(form), cardClip(form), cardLayout(form), form.width === "sm" && "w-full max-w-sm");
81
+ }
package/dist/cardWait.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ListRow } from "./ListRow.js";
3
+ import { Stack } from "./Stack.js";
3
4
  import { BoneLines, BusyLabel, isEmptySlot } from "./skeleton.js";
4
5
  /**
5
6
  * What a card holds while it may be waiting: its children, or, loading with none yet, three lines
@@ -12,5 +13,5 @@ export function CardWait({ loading, owner, label, flush, children, }) {
12
13
  function CardBones({ flush }) {
13
14
  if (!flush)
14
15
  return _jsx(BoneLines, {});
15
- return (_jsx(_Fragment, { children: [0, 1, 2].map((i) => (_jsx(ListRow, { divided: i > 0, children: null }, i))) }));
16
+ return (_jsx(Stack, { divided: true, children: [0, 1, 2].map((i) => (_jsx(ListRow, { children: null }, i))) }));
16
17
  }
@@ -11,12 +11,22 @@ export declare function schemeClass(scheme: ColourScheme, schemes?: ColourScheme
11
11
  export declare function appliedColourScheme(root?: HTMLElement, schemes?: ColourSchemeClasses): ColourScheme;
12
12
  /** Put `scheme` on `root` (the `<html>` element by default): its class from `schemes` (default `dark` for dark and none for light), the other scheme's class taken off, and `color-scheme` so native controls and scrollbars follow. */
13
13
  export declare function applyColourScheme(scheme: ColourScheme, root?: HTMLElement, schemes?: ColourSchemeClasses): void;
14
+ /** The system's scheme, or `undefined` where there is no `matchMedia` (server rendering). */
15
+ export declare function systemColourScheme(): ColourScheme | undefined;
14
16
  /** The stored choice, else the system preference. `fallback` (default `"light"`) is for when neither is available: server rendering, or storage that throws with no `matchMedia`. */
15
17
  export declare function readColourScheme(fallback?: ColourScheme): ColourScheme;
16
- /** Remember `scheme` for the next visit. A storage error is swallowed, so private mode does not crash. */
17
- export declare function storeColourScheme(scheme: ColourScheme): void;
18
+ /** Remember `scheme` for the next visit, or with `"system"` forget the choice so the page follows the system again. A storage error is swallowed, so private mode does not crash. */
19
+ export declare function storeColourScheme(scheme: ColourScheme | "system"): void;
20
+ /**
21
+ * Keep `root` on the stored scheme, else the system's, as either changes: a choice made or cleared in
22
+ * another tab (the `storage` event), and the system switching while nothing is stored (the dark
23
+ * query's `change` event). Returns the function that stops listening.
24
+ */
25
+ export declare function followColourScheme(root?: HTMLElement, schemes?: ColourSchemeClasses): () => void;
18
26
  /**
19
27
  * JavaScript to inline in `<head>`, before first paint: applies the stored scheme, else the
20
28
  * system one, to `<html>` as `applyColourScheme` does. Without it a light user sees a dark flash.
29
+ * It then keeps following, as `followColourScheme` does: a choice made in another tab, and the system
30
+ * switching while nothing is stored.
21
31
  */
22
32
  export declare const colourSchemeScript: string;
@@ -19,7 +19,8 @@ export function applyColourScheme(scheme, root = document.documentElement, schem
19
19
  root.classList.add(schemes[scheme]);
20
20
  root.style.colorScheme = scheme;
21
21
  }
22
- function storedScheme() {
22
+ /** The stored choice, or `undefined` when nothing is stored (the page follows the system) or storage throws. */
23
+ function storedColourScheme() {
23
24
  try {
24
25
  const stored = localStorage.getItem(STORAGE_KEY);
25
26
  return isScheme(stored) ? stored : undefined;
@@ -28,26 +29,51 @@ function storedScheme() {
28
29
  return undefined; // storage blocked: private mode, or no window at all
29
30
  }
30
31
  }
31
- function systemScheme() {
32
+ /** The system's scheme, or `undefined` where there is no `matchMedia` (server rendering). */
33
+ export function systemColourScheme() {
32
34
  if (typeof matchMedia !== "function")
33
35
  return undefined;
34
36
  return matchMedia(DARK_QUERY).matches ? "dark" : "light";
35
37
  }
36
38
  /** The stored choice, else the system preference. `fallback` (default `"light"`) is for when neither is available: server rendering, or storage that throws with no `matchMedia`. */
37
39
  export function readColourScheme(fallback = "light") {
38
- return storedScheme() ?? systemScheme() ?? fallback;
40
+ return storedColourScheme() ?? systemColourScheme() ?? fallback;
39
41
  }
40
- /** Remember `scheme` for the next visit. A storage error is swallowed, so private mode does not crash. */
42
+ /** Remember `scheme` for the next visit, or with `"system"` forget the choice so the page follows the system again. A storage error is swallowed, so private mode does not crash. */
41
43
  export function storeColourScheme(scheme) {
42
44
  try {
43
- localStorage.setItem(STORAGE_KEY, scheme);
45
+ if (scheme === "system")
46
+ localStorage.removeItem(STORAGE_KEY);
47
+ else
48
+ localStorage.setItem(STORAGE_KEY, scheme);
44
49
  }
45
50
  catch {
46
51
  // Not remembered; the page still switches for this visit.
47
52
  }
48
53
  }
54
+ /**
55
+ * Keep `root` on the stored scheme, else the system's, as either changes: a choice made or cleared in
56
+ * another tab (the `storage` event), and the system switching while nothing is stored (the dark
57
+ * query's `change` event). Returns the function that stops listening.
58
+ */
59
+ export function followColourScheme(root = document.documentElement, schemes = DEFAULT_CLASSES) {
60
+ const sync = () => applyColourScheme(readColourScheme(appliedColourScheme(root, schemes)), root, schemes);
61
+ const onStorage = (event) => {
62
+ if (event.key === STORAGE_KEY || event.key === null)
63
+ sync();
64
+ };
65
+ const query = typeof matchMedia === "function" ? matchMedia(DARK_QUERY) : undefined;
66
+ addEventListener("storage", onStorage);
67
+ query?.addEventListener("change", sync);
68
+ return () => {
69
+ removeEventListener("storage", onStorage);
70
+ query?.removeEventListener("change", sync);
71
+ };
72
+ }
49
73
  /**
50
74
  * JavaScript to inline in `<head>`, before first paint: applies the stored scheme, else the
51
75
  * system one, to `<html>` as `applyColourScheme` does. Without it a light user sees a dark flash.
76
+ * It then keeps following, as `followColourScheme` does: a choice made in another tab, and the system
77
+ * switching while nothing is stored.
52
78
  */
53
- export const colourSchemeScript = `(function(){var r=document.documentElement,s;try{s=localStorage.getItem(${JSON.stringify(STORAGE_KEY)})}catch(e){}if(s!=="light"&&s!=="dark")s=typeof matchMedia==="function"?matchMedia(${JSON.stringify(DARK_QUERY)}).matches?"dark":"light":null;if(s){r.classList.toggle("dark",s==="dark");r.style.colorScheme=s}})()`;
79
+ export const colourSchemeScript = `(function(){var r=document.documentElement,k=${JSON.stringify(STORAGE_KEY)},q=typeof matchMedia==="function"?matchMedia(${JSON.stringify(DARK_QUERY)}):null;function a(){var s;try{s=localStorage.getItem(k)}catch(e){}if(s!=="light"&&s!=="dark")s=q?q.matches?"dark":"light":null;if(s){r.classList.toggle("dark",s==="dark");r.style.colorScheme=s}}a();if(q&&q.addEventListener)q.addEventListener("change",a);addEventListener("storage",function(e){if(e.key===k||e.key===null)a()})})()`;
package/dist/control.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type TypeStep } from "./density.js";
2
- import type { Size } from "./size.js";
2
+ import { type ResponsiveSize, type Size } from "./size.js";
3
3
  /** A control's size: the library's one `Size` scale. */
4
4
  export type ControlSize = Size;
5
5
  /** `full` fills the parent (the default); `fill` grows to the space left in a flex row; `auto` adds no width class, so the control is as wide as the browser makes it; the rest are fixed. */
@@ -10,9 +10,11 @@ export type ControlProps = {
10
10
  * `sm` is compact, `text-sm` with less padding, for dense forms and table rows; `md` is `text-base`;
11
11
  * `lg` is `text-lg` with more padding, for a hero form. Under an `AppShell density="compact"` each
12
12
  * is one type step down, and on a touch screen a field is never under 16px.
13
+ * `{ base: "md", md: "lg" }` changes size at the `md` breakpoint (48rem), in CSS, as a `Button`'s
14
+ * does: give the field and the buttons in its row the same value, so the row stays aligned.
13
15
  * @default md
14
16
  */
15
- size?: ControlSize | undefined;
17
+ size?: ControlSize | ResponsiveSize | undefined;
16
18
  /** `full` (default) fills the parent; `fill` grows to fill the room left in a row beside other items (it can shrink to nothing, so buttons stay on the line); `xs`, `sm`, `md`, `lg` are fixed; `auto` adds no width class, so the control is as wide as the browser makes it. */
17
19
  width?: ControlWidth | undefined;
18
20
  };
@@ -20,10 +22,30 @@ export type ControlProps = {
20
22
  export declare const CONTROL_WIDTH: Record<ControlWidth, string | undefined>;
21
23
  /** A `numeric` `Input`'s figures: right-aligned and tabular, as a `numeric` table cell's. */
22
24
  export declare const NUMERIC_VALUE = "text-right tabular-nums";
23
- /** The horizontal padding of a control, and of an `Input`'s icon gutter. */
24
- export declare const CONTROL_PAD: Record<ControlSize, {
25
- x: string;
26
- icon: string;
27
- }>;
25
+ /** The height of a text control at `size`, set outright: for a `Select` and a field's loading bone. */
26
+ export declare function controlHeight(size: ControlSize | ResponsiveSize): string;
27
+ /** The control size tables and their `md:` twins, for the data test. */
28
+ export declare const controlSizeTables: {
29
+ padY: Record<Size, string>;
30
+ padYMd: Record<Size, string>;
31
+ padX: Record<Size, string>;
32
+ padXMd: Record<Size, string>;
33
+ padIcon: Record<Size, string>;
34
+ padIconMd: Record<Size, string>;
35
+ height: Record<Size, string>;
36
+ heightMd: Record<Size, string>;
37
+ };
38
+ /** The horizontal padding of a control at `size`: plain, or with the gutter of a leading icon. */
39
+ export declare function controlPad(size: ControlSize | ResponsiveSize, icon?: boolean): string;
40
+ /**
41
+ * The one invalid look of every control, a red edge: on a control that is `aria-invalid` (its
42
+ * `error` is set) and on one the browser itself finds invalid once the person has left it
43
+ * (`:user-invalid`: a `required` one left empty, an `email` with no @). It holds under the pointer:
44
+ * Tailwind orders `user-invalid:` before `hover:`, so the `hover:` pair keeps the red over the hover
45
+ * edge. `Checkbox`, `Switch`, `RadioGroup`, `DateField` and the text fields all draw it.
46
+ */
47
+ export declare const INVALID_EDGE = "aria-invalid:border-red-200 user-invalid:border-red-200 hover:aria-invalid:border-red-200 hover:user-invalid:border-red-200";
48
+ /** `INVALID_EDGE` on a frame round the control (an `Input` with an icon or a prefix, a `FileDrop`). */
49
+ export declare const INVALID_EDGE_WITHIN = "has-aria-invalid:border-red-200 has-user-invalid:border-red-200 hover:has-aria-invalid:border-red-200 hover:has-user-invalid:border-red-200";
28
50
  /** Shared look of text controls; `size` and the type `step` set the height and type, `width` the one width class. */
29
- export declare function controlClass(size?: ControlSize, width?: ControlWidth, step?: TypeStep): string;
51
+ export declare function controlClass(size?: ControlSize | ResponsiveSize, width?: ControlWidth, step?: TypeStep): string;
package/dist/control.js CHANGED
@@ -1,11 +1,18 @@
1
1
  import { focusRing } from "./cx.js";
2
2
  import { controlText } from "./density.js";
3
+ import { sizeClass } from "./size.js";
3
4
  /** The vertical padding of a control; its type size is `controlText`'s, from the size and the type step. */
4
5
  const CONTROL_PAD_Y = {
5
6
  sm: "py-1",
6
7
  md: "py-2",
7
8
  lg: "py-2.5",
8
9
  };
10
+ /** `CONTROL_PAD_Y` from the `md` breakpoint up, for a responsive size, every class written out in full. */
11
+ const CONTROL_PAD_Y_MD = {
12
+ sm: "md:py-1",
13
+ md: "md:py-2",
14
+ lg: "md:py-2.5",
15
+ };
9
16
  /** One width class per control, so a fixed width never fights `w-full`. `auto` has none. */
10
17
  export const CONTROL_WIDTH = {
11
18
  full: "w-full",
@@ -18,19 +25,79 @@ export const CONTROL_WIDTH = {
18
25
  };
19
26
  /** A `numeric` `Input`'s figures: right-aligned and tabular, as a `numeric` table cell's. */
20
27
  export const NUMERIC_VALUE = "text-right tabular-nums";
21
- /** The horizontal padding of a control, and of an `Input`'s icon gutter. */
22
- export const CONTROL_PAD = {
23
- sm: { x: "px-2", icon: "pr-2 pl-7" },
24
- md: { x: "px-3", icon: "pr-3 pl-9" },
25
- lg: { x: "px-4", icon: "pr-4 pl-11" },
28
+ /** The horizontal padding of a control. */
29
+ const CONTROL_PAD_X = { sm: "px-2", md: "px-3", lg: "px-4" };
30
+ /** `CONTROL_PAD_X` from the `md` breakpoint up. */
31
+ const CONTROL_PAD_X_MD = {
32
+ sm: "md:px-2",
33
+ md: "md:px-3",
34
+ lg: "md:px-4",
35
+ };
36
+ /** The horizontal padding of an `Input` with a leading icon: the icon's gutter. */
37
+ const CONTROL_PAD_ICON = {
38
+ sm: "pr-2 pl-7",
39
+ md: "pr-3 pl-9",
40
+ lg: "pr-4 pl-11",
41
+ };
42
+ /** `CONTROL_PAD_ICON` from the `md` breakpoint up. */
43
+ const CONTROL_PAD_ICON_MD = {
44
+ sm: "md:pr-2 md:pl-7",
45
+ md: "md:pr-3 md:pl-9",
46
+ lg: "md:pr-4 md:pl-11",
47
+ };
48
+ /** A text control's height by `size`: its padding, line height and border, 26, 38 and 46px. */
49
+ const CONTROL_HEIGHT = { sm: "h-6.5", md: "h-9.5", lg: "h-11.5" };
50
+ /** `CONTROL_HEIGHT` from the `md` breakpoint up. */
51
+ const CONTROL_HEIGHT_MD = {
52
+ sm: "md:h-6.5",
53
+ md: "md:h-9.5",
54
+ lg: "md:h-11.5",
26
55
  };
56
+ /** The height of a text control at `size`, set outright: for a `Select` and a field's loading bone. */
57
+ export function controlHeight(size) {
58
+ return sizeClass(CONTROL_HEIGHT, CONTROL_HEIGHT_MD, size);
59
+ }
60
+ /** The control size tables and their `md:` twins, for the data test. */
61
+ export const controlSizeTables = {
62
+ padY: CONTROL_PAD_Y,
63
+ padYMd: CONTROL_PAD_Y_MD,
64
+ padX: CONTROL_PAD_X,
65
+ padXMd: CONTROL_PAD_X_MD,
66
+ padIcon: CONTROL_PAD_ICON,
67
+ padIconMd: CONTROL_PAD_ICON_MD,
68
+ height: CONTROL_HEIGHT,
69
+ heightMd: CONTROL_HEIGHT_MD,
70
+ };
71
+ /** The horizontal padding of a control at `size`: plain, or with the gutter of a leading icon. */
72
+ export function controlPad(size, icon = false) {
73
+ return icon
74
+ ? sizeClass(CONTROL_PAD_ICON, CONTROL_PAD_ICON_MD, size)
75
+ : sizeClass(CONTROL_PAD_X, CONTROL_PAD_X_MD, size);
76
+ }
77
+ /**
78
+ * The one invalid look of every control, a red edge: on a control that is `aria-invalid` (its
79
+ * `error` is set) and on one the browser itself finds invalid once the person has left it
80
+ * (`:user-invalid`: a `required` one left empty, an `email` with no @). It holds under the pointer:
81
+ * Tailwind orders `user-invalid:` before `hover:`, so the `hover:` pair keeps the red over the hover
82
+ * edge. `Checkbox`, `Switch`, `RadioGroup`, `DateField` and the text fields all draw it.
83
+ */
84
+ export const INVALID_EDGE = "aria-invalid:border-red-200 user-invalid:border-red-200 hover:aria-invalid:border-red-200 hover:user-invalid:border-red-200";
85
+ /** `INVALID_EDGE` on a frame round the control (an `Input` with an icon or a prefix, a `FileDrop`). */
86
+ export const INVALID_EDGE_WITHIN = "has-aria-invalid:border-red-200 has-user-invalid:border-red-200 hover:has-aria-invalid:border-red-200 hover:has-user-invalid:border-red-200";
87
+ /**
88
+ * The mark of a value the browser autofilled: a bar of the text colour inside the start edge, so
89
+ * autofill is told by a shape and not only by the browser's own tint.
90
+ */
91
+ const AUTOFILL = "autofill:shadow-[inset_3px_0_0_0_currentColor]";
27
92
  /** Shared look of text controls; `size` and the type `step` set the height and type, `width` the one width class. */
28
93
  export function controlClass(size = "md", width = "full", step) {
29
94
  return [
30
95
  CONTROL_WIDTH[width],
31
- CONTROL_PAD_Y[size],
96
+ sizeClass(CONTROL_PAD_Y, CONTROL_PAD_Y_MD, size),
32
97
  controlText(size, step, true),
33
- `rounded-lg border border-slate-300 bg-white text-slate-900 placeholder:text-slate-400 text-ellipsis transition hover:border-violet-400 aria-invalid:border-red-200 disabled:opacity-50 ${focusRing}`,
98
+ `rounded-lg border border-slate-300 bg-white text-slate-900 placeholder:text-slate-400 text-ellipsis transition hover:border-violet-400 disabled:opacity-50 ${focusRing}`,
99
+ INVALID_EDGE,
100
+ AUTOFILL,
34
101
  ]
35
102
  .filter(Boolean)
36
103
  .join(" ");
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * JavaScript to inline once on a page that is rendered to static HTML and never hydrated, so every
3
3
  * `CopyButton` (and the `CopyLine`, `CodeBlock` and `CodeExample` copy buttons) works there too.
4
- * One click listener on `document` reads what to copy from the button's data attributes, writes the
5
- * clipboard, then does what `CopyButton` does: sets `data-copied` again after a reflow, so the CSS
6
- * that shows the copied label for two seconds starts over, and puts a new node holding the copied
7
- * label in the status region beside the button, so a screen reader hears each copy. No timer: the
8
- * label goes back when the animation ends, and its end clears `data-copied` (a second listener), so a
9
- * button hidden and shown again does not replay it. A refused or missing clipboard leaves it alone.
10
- * Whichever of the script and a hydrated button's own handler hears a click first copies and flags
11
- * the event (`copyHandled`), and the other skips it: one copy per click.
4
+ * One click listener on `document` reads what to copy from the button's `data-copy-text`, writes the
5
+ * clipboard, then does what `CopyButton` does: cancels a run in progress, holds the copied (or, on a
6
+ * refused or missing clipboard, the failed) label in view for two seconds with two Web Animations,
7
+ * and puts a new node holding that label in the status region beside the button, so a screen reader
8
+ * hears each press; the run's end empties the region. No timer and no stylesheet. Whichever of the
9
+ * script and a hydrated button's own handler hears a click first copies and flags the event
10
+ * (`copyHandled`), and the other skips it: one copy per click.
12
11
  */
13
12
  export declare const copyScript: string;
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * JavaScript to inline once on a page that is rendered to static HTML and never hydrated, so every
3
3
  * `CopyButton` (and the `CopyLine`, `CodeBlock` and `CodeExample` copy buttons) works there too.
4
- * One click listener on `document` reads what to copy from the button's data attributes, writes the
5
- * clipboard, then does what `CopyButton` does: sets `data-copied` again after a reflow, so the CSS
6
- * that shows the copied label for two seconds starts over, and puts a new node holding the copied
7
- * label in the status region beside the button, so a screen reader hears each copy. No timer: the
8
- * label goes back when the animation ends, and its end clears `data-copied` (a second listener), so a
9
- * button hidden and shown again does not replay it. A refused or missing clipboard leaves it alone.
10
- * Whichever of the script and a hydrated button's own handler hears a click first copies and flags
11
- * the event (`copyHandled`), and the other skips it: one copy per click.
4
+ * One click listener on `document` reads what to copy from the button's `data-copy-text`, writes the
5
+ * clipboard, then does what `CopyButton` does: cancels a run in progress, holds the copied (or, on a
6
+ * refused or missing clipboard, the failed) label in view for two seconds with two Web Animations,
7
+ * and puts a new node holding that label in the status region beside the button, so a screen reader
8
+ * hears each press; the run's end empties the region. No timer and no stylesheet. Whichever of the
9
+ * script and a hydrated button's own handler hears a click first copies and flags the event
10
+ * (`copyHandled`), and the other skips it: one copy per click.
12
11
  */
13
- export const copyScript = `document.addEventListener("click",function(e){var b=e.target.closest&&e.target.closest("[data-copy-text]"),c=navigator.clipboard;if(!b||!c||e.copyHandled||b.disabled)return;e.copyHandled=1;c.writeText(b.dataset.copyText).then(function(){var r=b.nextElementSibling;b.removeAttribute("data-copied");void b.offsetWidth;b.setAttribute("data-copied","");if(r&&r.matches("[data-copy-status]"))r.replaceChildren(b.dataset.copyCopied)},function(){})});document.addEventListener("animationend",function(e){var b=e.target.closest&&e.target.closest("[data-copied]");if(b)b.removeAttribute("data-copied")})`;
12
+ export const copyScript = `document.addEventListener("click",function(e){var b=e.target.closest&&e.target.closest("[data-copy-text]"),c=navigator.clipboard;if(!b||e.copyHandled||b.disabled)return;e.copyHandled=1;function f(k){var s=b.querySelector("[data-copy-"+k+"]"),i=b.querySelector("[data-copy-idle]"),r=b.nextElementSibling;if(!r||!r.matches("[data-copy-status]"))r=null;if(r)r.replaceChildren(s?s.textContent:"");if(!s||!s.animate||!i)return;b.getAnimations({subtree:true}).forEach(function(a){a.cancel()});i.animate({visibility:["hidden","hidden"]},2e3);s.animate({visibility:["visible","visible"]},2e3).onfinish=function(){if(r)r.replaceChildren()}}if(!c)return f("failed");c.writeText(b.dataset.copyText).then(function(){f("done")},function(){f("failed")})})`;
package/dist/cx.d.ts CHANGED
@@ -2,6 +2,25 @@
2
2
  export declare function cx(...parts: Array<string | false | null | undefined>): string;
3
3
  /** The keyboard focus ring every interactive control shares. */
4
4
  export declare const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600";
5
+ /**
6
+ * A heading's lines are balanced, so a two-line title does not end on one orphaned word; prose is
7
+ * wrapped `pretty`, which keeps a short last line off a paragraph. Only the wrap style is set, so a
8
+ * `lines` clamp (one line with an ellipsis) still wins; a browser that has neither wraps as before.
9
+ */
10
+ export declare const balanced = "[text-wrap-style:balance]";
11
+ export declare const pretty = "[text-wrap-style:pretty]";
12
+ /**
13
+ * A fill that carries meaning (a bar's progress, the drop line, the current pill) in forced
14
+ * colours: there every background is painted the page's Canvas, so the fill would vanish. A system
15
+ * colour the page names is kept, so the fill takes the system's Highlight; `!` beats a theme's scoped remap of the stock fill.
16
+ */
17
+ export declare const forcedFill = "forced-colors:bg-[color:Highlight]!";
18
+ /**
19
+ * The same ring drawn inside the control, for one that fills a box which clips anything outside
20
+ * it (a table's sortable title, a scroller). `focusRing` with `-outline-offset-2` added would not
21
+ * do, since `outline-offset-2` comes later in the CSS and wins.
22
+ */
23
+ export declare const insetFocusRing = "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-violet-600";
5
24
  /**
6
25
  * On a row or card that holds a stretched link (`link-stretch`): every interactive descendant sits
7
26
  * above that link and is clickable on its own. `z-10` needs a position, so each gets `relative`,
@@ -11,9 +30,9 @@ export declare const focusRing = "focus-visible:outline-2 focus-visible:outline-
11
30
  */
12
31
  export declare const liftInteractive = "isolate [&_:is(a,button,label,select,textarea,input,summary):not(.link-stretch):not(.absolute)]:relative [&_:is(a,button,label,select,textarea,input,summary):not(.link-stretch)]:z-10";
13
32
  /**
14
- * A thin scrollbar in the theme's muted ink instead of the heavy native one, for a box that
15
- * scrolls sideways (code). `scrollbar-color` takes no Tailwind colour utility, so the thumb is the
33
+ * A scrollbar in the theme's muted ink instead of the native grey one, at the native width so it
34
+ * stays easy to grab, for a box that scrolls sideways (code). `scrollbar-color` takes no Tailwind colour utility, so the thumb is the
16
35
  * element's own text colour (`currentColor`, a palette utility every theme remaps) and the track is
17
36
  * transparent. The element must not hold text of its own: put the readable colour on an inner box.
18
37
  */
19
- export declare const themedScrollbar = "text-slate-400 [scrollbar-width:thin] [scrollbar-color:currentColor_transparent]";
38
+ export declare const themedScrollbar = "text-slate-400 [scrollbar-color:currentColor_transparent]";