@arshad-shah/cynosure 0.2.0 → 0.3.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 (272) hide show
  1. package/README.md +3 -3
  2. package/dist/components/Accordion/Accordion.d.ts +14 -0
  3. package/dist/components/Accordion/Accordion.js.map +1 -1
  4. package/dist/components/Announcer/Announcer.d.ts +1 -0
  5. package/dist/components/Announcer/Announcer.js.map +1 -1
  6. package/dist/components/AppShell/AppShell.d.ts +22 -1
  7. package/dist/components/AppShell/AppShell.js +95 -83
  8. package/dist/components/AppShell/AppShell.js.map +1 -1
  9. package/dist/components/AppShell/index.d.ts +1 -1
  10. package/dist/components/AspectRatio/AspectRatio.d.ts +29 -0
  11. package/dist/components/AspectRatio/AspectRatio.js +21 -0
  12. package/dist/components/AspectRatio/AspectRatio.js.map +1 -0
  13. package/dist/components/AspectRatio/index.d.ts +1 -0
  14. package/dist/components/Avatar/Avatar.d.ts +96 -0
  15. package/dist/components/Avatar/Avatar.js +90 -0
  16. package/dist/components/Avatar/Avatar.js.map +1 -0
  17. package/dist/components/Avatar/index.d.ts +1 -0
  18. package/dist/components/Badge/Badge.d.ts +6 -0
  19. package/dist/components/Badge/Badge.js.map +1 -1
  20. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +55 -0
  21. package/dist/components/Breadcrumbs/Breadcrumbs.js +85 -0
  22. package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
  23. package/dist/components/Breadcrumbs/index.d.ts +1 -0
  24. package/dist/components/Button/Button.d.ts +13 -2
  25. package/dist/components/Button/Button.js +28 -26
  26. package/dist/components/Button/Button.js.map +1 -1
  27. package/dist/components/Calendar/Calendar.d.ts +65 -7
  28. package/dist/components/Calendar/Calendar.js +207 -95
  29. package/dist/components/Calendar/Calendar.js.map +1 -1
  30. package/dist/components/Calendar/dates.d.ts +4 -0
  31. package/dist/components/Calendar/dates.js +41 -27
  32. package/dist/components/Calendar/dates.js.map +1 -1
  33. package/dist/components/Calendar/index.d.ts +1 -1
  34. package/dist/components/Card/Card.d.ts +27 -0
  35. package/dist/components/Card/Card.js +48 -36
  36. package/dist/components/Card/Card.js.map +1 -1
  37. package/dist/components/Card/index.d.ts +1 -1
  38. package/dist/components/Checkbox/Checkbox.d.ts +8 -1
  39. package/dist/components/Checkbox/Checkbox.js +7 -6
  40. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  41. package/dist/components/Checkbox/ChoiceRow.d.ts +17 -1
  42. package/dist/components/Checkbox/ChoiceRow.js +19 -18
  43. package/dist/components/Checkbox/ChoiceRow.js.map +1 -1
  44. package/dist/components/Checklist/Checklist.d.ts +65 -0
  45. package/dist/components/Checklist/Checklist.js +163 -0
  46. package/dist/components/Checklist/Checklist.js.map +1 -0
  47. package/dist/components/Checklist/index.d.ts +1 -0
  48. package/dist/components/CodeBlock/CodeBlock.d.ts +5 -0
  49. package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
  50. package/dist/components/ColorField/ColorField.d.ts +12 -0
  51. package/dist/components/ColorField/ColorField.js +19 -19
  52. package/dist/components/ColorField/ColorField.js.map +1 -1
  53. package/dist/components/ColorSwatches/ColorSwatches.d.ts +5 -0
  54. package/dist/components/ColorSwatches/ColorSwatches.js +6 -6
  55. package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
  56. package/dist/components/Combobox/Combobox.d.ts +20 -1
  57. package/dist/components/Combobox/Combobox.js +38 -34
  58. package/dist/components/Combobox/Combobox.js.map +1 -1
  59. package/dist/components/CommandPalette/CommandPalette.d.ts +9 -0
  60. package/dist/components/CommandPalette/CommandPalette.js +10 -10
  61. package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
  62. package/dist/components/CompareSlider/CompareSlider.d.ts +4 -0
  63. package/dist/components/CompareSlider/CompareSlider.js +4 -4
  64. package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
  65. package/dist/components/Container/Container.d.ts +44 -0
  66. package/dist/components/Container/Container.js +24 -0
  67. package/dist/components/Container/Container.js.map +1 -0
  68. package/dist/components/Container/index.d.ts +1 -0
  69. package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
  70. package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
  71. package/dist/components/CopyButton/CopyButton.d.ts +8 -0
  72. package/dist/components/CopyButton/CopyButton.js.map +1 -1
  73. package/dist/components/DateField/DateField.d.ts +17 -0
  74. package/dist/components/DateField/DateField.js +6 -6
  75. package/dist/components/DateField/DateField.js.map +1 -1
  76. package/dist/components/DescriptionList/DescriptionList.d.ts +3 -0
  77. package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
  78. package/dist/components/Dialog/Dialog.d.ts +16 -2
  79. package/dist/components/Dialog/Dialog.js +82 -70
  80. package/dist/components/Dialog/Dialog.js.map +1 -1
  81. package/dist/components/Disclosure/Disclosure.d.ts +7 -0
  82. package/dist/components/Disclosure/Disclosure.js.map +1 -1
  83. package/dist/components/Divider/Divider.d.ts +59 -0
  84. package/dist/components/Divider/Divider.js +32 -0
  85. package/dist/components/Divider/Divider.js.map +1 -0
  86. package/dist/components/Divider/index.d.ts +1 -0
  87. package/dist/components/DocumentViewport/DocumentViewport.d.ts +8 -0
  88. package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
  89. package/dist/components/EmptyState/EmptyState.d.ts +3 -0
  90. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  91. package/dist/components/Field/Field.d.ts +6 -0
  92. package/dist/components/Field/Field.js.map +1 -1
  93. package/dist/components/FileDrop/FileDrop.d.ts +8 -0
  94. package/dist/components/FileDrop/FileDrop.js.map +1 -1
  95. package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +4 -0
  96. package/dist/components/FloatingToolbar/FloatingToolbar.js +4 -4
  97. package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
  98. package/dist/components/Grid/Grid.d.ts +33 -7
  99. package/dist/components/Grid/Grid.js +46 -25
  100. package/dist/components/Grid/Grid.js.map +1 -1
  101. package/dist/components/Grid/index.d.ts +1 -1
  102. package/dist/components/Heading/Heading.d.ts +57 -0
  103. package/dist/components/Heading/Heading.js +33 -0
  104. package/dist/components/Heading/Heading.js.map +1 -0
  105. package/dist/components/Heading/index.d.ts +1 -0
  106. package/dist/components/HoverCard/HoverCard.d.ts +1 -0
  107. package/dist/components/HoverCard/HoverCard.js.map +1 -1
  108. package/dist/components/IconButton/IconButton.d.ts +1 -0
  109. package/dist/components/IconButton/IconButton.js.map +1 -1
  110. package/dist/components/Image/Image.d.ts +62 -0
  111. package/dist/components/Image/Image.js +75 -0
  112. package/dist/components/Image/Image.js.map +1 -0
  113. package/dist/components/Image/index.d.ts +1 -0
  114. package/dist/components/Inline/Inline.d.ts +7 -3
  115. package/dist/components/Inline/Inline.js +19 -13
  116. package/dist/components/Inline/Inline.js.map +1 -1
  117. package/dist/components/Kbd/Kbd.d.ts +2 -0
  118. package/dist/components/Kbd/Kbd.js.map +1 -1
  119. package/dist/components/KeyValueEditor/KeyValueEditor.d.ts +7 -0
  120. package/dist/components/KeyValueEditor/KeyValueEditor.js +8 -8
  121. package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
  122. package/dist/components/Link/Link.d.ts +7 -0
  123. package/dist/components/Link/Link.js.map +1 -1
  124. package/dist/components/LoadingDots/LoadingDots.d.ts +2 -0
  125. package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
  126. package/dist/components/Menu/Menu.d.ts +13 -1
  127. package/dist/components/Menu/Menu.js +37 -35
  128. package/dist/components/Menu/Menu.js.map +1 -1
  129. package/dist/components/Notice/Notice.d.ts +5 -0
  130. package/dist/components/Notice/Notice.js.map +1 -1
  131. package/dist/components/NumberField/NumberField.d.ts +17 -0
  132. package/dist/components/NumberField/NumberField.js +8 -8
  133. package/dist/components/NumberField/NumberField.js.map +1 -1
  134. package/dist/components/PageHeader/PageHeader.d.ts +61 -0
  135. package/dist/components/PageHeader/PageHeader.js +63 -0
  136. package/dist/components/PageHeader/PageHeader.js.map +1 -0
  137. package/dist/components/PageHeader/index.d.ts +1 -0
  138. package/dist/components/Pagination/Pagination.d.ts +77 -0
  139. package/dist/components/Pagination/Pagination.js +120 -0
  140. package/dist/components/Pagination/Pagination.js.map +1 -0
  141. package/dist/components/Pagination/index.d.ts +1 -0
  142. package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +4 -0
  143. package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
  144. package/dist/components/Popover/Popover.d.ts +10 -0
  145. package/dist/components/Popover/Popover.js.map +1 -1
  146. package/dist/components/ProgressBar/ProgressBar.d.ts +5 -0
  147. package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
  148. package/dist/components/ProgressOverlay/ProgressOverlay.d.ts +3 -0
  149. package/dist/components/ProgressOverlay/ProgressOverlay.js.map +1 -1
  150. package/dist/components/Prose/Prose.d.ts +1 -0
  151. package/dist/components/Prose/Prose.js.map +1 -1
  152. package/dist/components/RadioGroup/RadioGroup.d.ts +13 -0
  153. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  154. package/dist/components/SegmentedControl/SegmentedControl.d.ts +9 -0
  155. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  156. package/dist/components/Select/Select.d.ts +18 -1
  157. package/dist/components/Select/Select.js +97 -88
  158. package/dist/components/Select/Select.js.map +1 -1
  159. package/dist/components/Select/index.d.ts +1 -0
  160. package/dist/components/SelectionFrame/SelectionFrame.d.ts +6 -0
  161. package/dist/components/SelectionFrame/SelectionFrame.js.map +1 -1
  162. package/dist/components/SideNav/SideNav.d.ts +37 -1
  163. package/dist/components/SideNav/SideNav.js +100 -73
  164. package/dist/components/SideNav/SideNav.js.map +1 -1
  165. package/dist/components/SideNav/index.d.ts +1 -1
  166. package/dist/components/SignaturePad/SignaturePad.d.ts +3 -0
  167. package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
  168. package/dist/components/Skeleton/Skeleton.d.ts +1 -0
  169. package/dist/components/Skeleton/Skeleton.js.map +1 -1
  170. package/dist/components/Slider/Slider.d.ts +11 -0
  171. package/dist/components/Slider/Slider.js +6 -6
  172. package/dist/components/Slider/Slider.js.map +1 -1
  173. package/dist/components/SortableList/SortableList.d.ts +6 -0
  174. package/dist/components/SortableList/SortableList.js.map +1 -1
  175. package/dist/components/SplitPane/SplitPane.d.ts +5 -0
  176. package/dist/components/SplitPane/SplitPane.js +4 -4
  177. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  178. package/dist/components/Stack/Stack.d.ts +7 -3
  179. package/dist/components/Stack/Stack.js +18 -12
  180. package/dist/components/Stack/Stack.js.map +1 -1
  181. package/dist/components/Stack/index.d.ts +1 -0
  182. package/dist/components/Stack/space.d.ts +18 -0
  183. package/dist/components/Stack/space.js +12 -0
  184. package/dist/components/Stack/space.js.map +1 -0
  185. package/dist/components/Steps/Steps.d.ts +4 -0
  186. package/dist/components/Steps/Steps.js.map +1 -1
  187. package/dist/components/Table/Table.d.ts +12 -0
  188. package/dist/components/Table/Table.js.map +1 -1
  189. package/dist/components/Tabs/Tabs.d.ts +14 -0
  190. package/dist/components/Tabs/Tabs.js +4 -4
  191. package/dist/components/Tabs/Tabs.js.map +1 -1
  192. package/dist/components/TagInput/TagInput.d.ts +18 -0
  193. package/dist/components/TagInput/TagInput.js +5 -5
  194. package/dist/components/TagInput/TagInput.js.map +1 -1
  195. package/dist/components/Text/Text.d.ts +72 -0
  196. package/dist/components/Text/Text.js +30 -0
  197. package/dist/components/Text/Text.js.map +1 -0
  198. package/dist/components/Text/index.d.ts +1 -0
  199. package/dist/components/TextArea/TextArea.d.ts +10 -0
  200. package/dist/components/TextArea/TextArea.js +4 -4
  201. package/dist/components/TextArea/TextArea.js.map +1 -1
  202. package/dist/components/TextField/TextField.d.ts +13 -0
  203. package/dist/components/TextField/TextField.js +4 -4
  204. package/dist/components/TextField/TextField.js.map +1 -1
  205. package/dist/components/ThemeToggle/ThemeToggle.d.ts +4 -0
  206. package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
  207. package/dist/components/TimeField/TimeField.d.ts +62 -8
  208. package/dist/components/TimeField/TimeField.js +308 -72
  209. package/dist/components/TimeField/TimeField.js.map +1 -1
  210. package/dist/components/Toast/Toast.d.ts +25 -1
  211. package/dist/components/Toast/Toast.js +134 -125
  212. package/dist/components/Toast/Toast.js.map +1 -1
  213. package/dist/components/Toast/index.d.ts +1 -1
  214. package/dist/components/Toolbar/Toolbar.d.ts +3 -0
  215. package/dist/components/Toolbar/Toolbar.js.map +1 -1
  216. package/dist/components/Tooltip/Tooltip.d.ts +1 -0
  217. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  218. package/dist/components/Tree/Tree.d.ts +8 -0
  219. package/dist/components/Tree/Tree.js.map +1 -1
  220. package/dist/components/VirtualList/VirtualList.d.ts +8 -0
  221. package/dist/components/VirtualList/VirtualList.js +4 -4
  222. package/dist/components/VirtualList/VirtualList.js.map +1 -1
  223. package/dist/components/ZoomControls/ZoomControls.d.ts +4 -0
  224. package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
  225. package/dist/foundations/ChoiceBase/ChoiceBase.d.ts +1 -0
  226. package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
  227. package/dist/foundations/HiddenValue/HiddenValue.d.ts +3 -0
  228. package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
  229. package/dist/foundations/Icon/Icon.d.ts +3 -0
  230. package/dist/foundations/Icon/Icon.js.map +1 -1
  231. package/dist/foundations/image-outcome.d.ts +15 -0
  232. package/dist/foundations/image-outcome.js +39 -0
  233. package/dist/foundations/image-outcome.js.map +1 -0
  234. package/dist/foundations/option-icon.d.ts +26 -0
  235. package/dist/foundations/option-icon.js +16 -0
  236. package/dist/foundations/option-icon.js.map +1 -0
  237. package/dist/icons/index.d.ts +1 -0
  238. package/dist/icons/index.js +476 -474
  239. package/dist/icons/keywords.d.ts +249 -0
  240. package/dist/icons/keywords.js +1728 -0
  241. package/dist/icons/keywords.js.map +1 -0
  242. package/dist/index.d.ts +20 -9
  243. package/dist/index.js +240 -213
  244. package/dist/styles/aspect-ratio.css +1 -0
  245. package/dist/styles/avatar.css +1 -0
  246. package/dist/styles/breadcrumbs.css +1 -0
  247. package/dist/styles/calendar.css +1 -1
  248. package/dist/styles/card.css +1 -1
  249. package/dist/styles/checkbox.css +1 -1
  250. package/dist/styles/checklist.css +1 -0
  251. package/dist/styles/container.css +1 -0
  252. package/dist/styles/divider.css +1 -0
  253. package/dist/styles/generated-css.d.ts +1 -1
  254. package/dist/styles/generated-css.js +1 -1
  255. package/dist/styles/generated-css.js.map +1 -1
  256. package/dist/styles/grid.css +1 -1
  257. package/dist/styles/heading.css +1 -0
  258. package/dist/styles/image.css +1 -0
  259. package/dist/styles/menu.css +1 -1
  260. package/dist/styles/page-header.css +1 -0
  261. package/dist/styles/pagination.css +1 -0
  262. package/dist/styles/side-nav.css +1 -1
  263. package/dist/styles/stack.css +1 -1
  264. package/dist/styles/text.css +1 -0
  265. package/dist/styles/time-field.css +1 -1
  266. package/dist/styles/toast.css +1 -1
  267. package/dist/styles.css +1 -1
  268. package/dist/theme/CynosureTheme.d.ts +4 -0
  269. package/dist/theme/CynosureTheme.js.map +1 -1
  270. package/dist/tokens/to-css.js +12 -12
  271. package/dist/tokens/to-css.js.map +1 -1
  272. package/package.json +3 -3
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { forwardRef as x } from "react";
3
+ import { jsx as h } from "react/jsx-runtime";
4
+ var p = [
5
+ "2xl",
6
+ "xl",
7
+ "lg",
8
+ "md",
9
+ "sm",
10
+ "xs"
11
+ ], _ = x(function({ level: i = 2, size: t, tone: r = "neutral", weight: d = "bold", align: l, truncate: a = !1, id: s, className: n, style: o, children: f }, g) {
12
+ const m = `h${i}`, e = typeof a == "number" && a > 0 ? Math.floor(a) : 0;
13
+ return /* @__PURE__ */ h(m, {
14
+ ref: g,
15
+ id: s,
16
+ className: `cy-heading${n ? ` ${n}` : ""}`,
17
+ "data-size": t ?? p[i - 1],
18
+ "data-tone": r,
19
+ "data-weight": d,
20
+ "data-align": l,
21
+ "data-truncate": e ? "lines" : a === !0 ? "line" : void 0,
22
+ style: e ? {
23
+ "--_lines": e,
24
+ ...o
25
+ } : o,
26
+ children: f
27
+ });
28
+ });
29
+ export {
30
+ _ as Heading
31
+ };
32
+
33
+ //# sourceMappingURL=Heading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Heading.js","names":["forwardRef","jsx","SIZE_BY_LEVEL","Heading","level","size","tone","weight","align","truncate","id","className","style","children","ref","Tag","lines"],"sources":["../../../src/components/Heading/Heading.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode } from \"react\";\n\nexport interface HeadingTokens {\n /** Font size of `size=\"xs\"` (the default for level 6). */\n sizeXs: string;\n /** Font size of `size=\"sm\"` (the default for level 5). */\n sizeSm: string;\n /** Font size of `size=\"md\"` (the default for level 4). */\n sizeMd: string;\n /** Font size of `size=\"lg\"` (the default for level 3). */\n sizeLg: string;\n /** Font size of `size=\"xl\"` (the default for level 2). */\n sizeXl: string;\n /** Font size of `size=\"2xl\"` (the default for level 1). */\n \"size-2xl\": string;\n /** Font size of `size=\"display\"`, a page's hero title. Grows with the viewport between 1.25 and 2 times 2xl. */\n sizeDisplay: string;\n /** Font family. Falls back to the display font. */\n fontFamily: string;\n /** Weight of bold headings (the default weight). */\n fontWeight: string;\n /** Line height, as a number. Tighter than body text. */\n lineHeight: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n heading: HeadingTokens;\n }\n}\n\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\nexport type HeadingSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\" | \"display\";\n\nexport interface HeadingProps {\n /** The element rendered (`h1` to `h6`) and so the heading's place in the page outline. Default 2. */\n level?: HeadingLevel;\n /**\n * How large it looks, whatever its level. Defaults to the level's size: 1 is \"2xl\", 2 is \"xl\", 3 is \"lg\",\n * 4 is \"md\", 5 is \"sm\" and 6 is \"xs\". \"display\" is larger than \"2xl\", for a page's hero title.\n */\n size?: HeadingSize;\n /** Text colour: the ink colour, muted, the accent, or whatever the parent uses. Default \"neutral\". */\n tone?: \"inherit\" | \"neutral\" | \"muted\" | \"accent\";\n /** Font weight. Default \"bold\". */\n weight?: \"medium\" | \"bold\";\n /** Text alignment, RTL aware. Left unset, it follows the parent. */\n align?: \"start\" | \"center\" | \"end\";\n /** `true` keeps it on one line and ends it with an ellipsis; a number cuts it after that many lines. Default false. */\n truncate?: boolean | number;\n /** Set on the heading element, for `aria-labelledby` and links to the section. */\n id?: string;\n /** Added to the heading element, for layout. */\n className?: string;\n /** Layout only. Restyle through `--cy-heading-*` tokens. */\n style?: CSSProperties;\n /** The heading's text. */\n children?: ReactNode;\n}\n\nconst SIZE_BY_LEVEL = [\"2xl\", \"xl\", \"lg\", \"md\", \"sm\", \"xs\"] as const;\n\n/** A section or page heading. `level` sets the element, `size` sets the look, so the outline stays correct. */\nexport const Heading = forwardRef<HTMLHeadingElement, HeadingProps>(function Heading(\n {\n level = 2,\n size,\n tone = \"neutral\",\n weight = \"bold\",\n align,\n truncate = false,\n id,\n className,\n style,\n children,\n },\n ref,\n) {\n const Tag = `h${level}` as \"h1\";\n const lines = typeof truncate === \"number\" && truncate > 0 ? Math.floor(truncate) : 0;\n return (\n <Tag\n ref={ref}\n id={id}\n className={`cy-heading${className ? ` ${className}` : \"\"}`}\n data-size={size ?? SIZE_BY_LEVEL[level - 1]}\n data-tone={tone}\n data-weight={weight}\n data-align={align}\n data-truncate={lines ? \"lines\" : truncate === true ? \"line\" : undefined}\n style={lines ? ({ \"--_lines\": lines, ...style } as CSSProperties) : style}\n >\n {children}\n </Tag>\n );\n});\n"],"mappings":";;;AA4DA,IAAME,IAAgB;AAAA,EAAC;AAAA,EAAO;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAI,GAG7CC,IAAUH,EAA6C,SAClE,EACE,OAAAI,IAAQ,GACR,MAAAC,GACA,MAAAC,IAAO,WACP,QAAAC,IAAS,QACT,OAAAC,GACA,UAAAC,IAAW,IACX,IAAAC,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GAEFC,GACA;AACA,QAAMC,IAAM,IAAIX,CAAA,IACVY,IAAQ,OAAOP,KAAa,YAAYA,IAAW,IAAI,KAAK,MAAMA,CAAQ,IAAI;AACpF,SACE,gBAAAR,EAACc,GAAD;AAAA,IACO,KAAAD;AAAA,IACD,IAAAJ;AAAA,IACJ,WAAW,aAAaC,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACtD,aAAWN,KAAQH,EAAcE,IAAQ,CAAA;AAAA,IACzC,aAAWE;AAAA,IACX,eAAaC;AAAA,IACb,cAAYC;AAAA,IACZ,iBAAeQ,IAAQ,UAAUP,MAAa,KAAO,SAAS;AAAA,IAC9D,OAAOO,IAAS;AAAA,MAAE,YAAYA;AAAA,MAAO,GAAGJ;AAAA,IAAM,IAAsBA;AAAA,IAEnE,UAAAC;AAAA,EACE,CAAA;AAET,CAAC"}
@@ -0,0 +1 @@
1
+ export { Heading, type HeadingLevel, type HeadingProps, type HeadingSize, type HeadingTokens, } from "./Heading.js";
@@ -25,6 +25,7 @@ export interface HoverCardProps {
25
25
  placement?: Placement;
26
26
  /** The preview (a larger thumbnail, a summary). Nothing in it can be clicked or focused. */
27
27
  children?: ReactNode;
28
+ /** Added to the root element, for layout. */
28
29
  className?: string;
29
30
  /** Layout only. Restyle through --cy-hover-card-* tokens. */
30
31
  style?: CSSProperties;
@@ -1 +1 @@
1
- {"version":3,"file":"HoverCard.js","names":["useFloatingAnchor","useFloatingOffset","usePopover","useAnchoredPosition","useRef","jsx","HoverCard","open","anchor","placement","children","className","style","card","target","shown","offset"],"sources":["../../../src/components/HoverCard/HoverCard.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useRef } from \"react\";\nimport {\n type FloatingAnchor,\n type PopoverEl,\n useFloatingAnchor,\n useFloatingOffset,\n usePopover,\n} from \"../../overlay/floating.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { useAnchoredPosition } from \"../../overlay/use-anchored-position.js\";\n\nexport interface HoverCardTokens {\n /** Background of the card. */\n background: string;\n /** Corner radius. */\n radius: string;\n /** Inner padding. */\n padding: string;\n /** Gap between the card and its anchor. */\n offset: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n hoverCard: HoverCardTokens;\n }\n}\n\nexport interface HoverCardProps {\n /** Show it. The owner decides when: a hovered row, a focused thumbnail. */\n open: boolean;\n /** What it previews: a ref to an element, or a virtual anchor. */\n anchor: FloatingAnchor;\n /** Preferred side; it flips when there is no room and slides to stay on screen. Default `end`. */\n placement?: Placement;\n /** The preview (a larger thumbnail, a summary). Nothing in it can be clicked or focused. */\n children?: ReactNode;\n className?: string;\n /** Layout only. Restyle through --cy-hover-card-* tokens. */\n style?: CSSProperties;\n}\n\n/**\n * A passive preview beside the thing it previews, such as a large thumbnail of a page on hover. It takes no pointer\n * input or focus and is hidden from assistive technology, because it only repeats what its anchor already names; for\n * text that describes a control use Tooltip, and for anything interactive use Popover.\n */\nexport function HoverCard({ open, anchor, placement = \"end\", children, className, style }: HoverCardProps) {\n const card = useRef<PopoverEl>(null);\n const target = useFloatingAnchor(anchor);\n const shown = open && target.present;\n usePopover(card, shown);\n const offset = useFloatingOffset(card);\n useAnchoredPosition(target.ref, card, shown, placement, offset);\n return (\n <div\n ref={card}\n className={className ? `cy-hover-card ${className}` : \"cy-hover-card\"}\n aria-hidden=\"true\"\n {...{ popover: \"manual\", inert: true }}\n style={style}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;AA+CA,SAAgBM,EAAU,EAAE,MAAAC,GAAM,QAAAC,GAAQ,WAAAC,IAAY,OAAO,UAAAC,GAAU,WAAAC,GAAW,OAAAC,EAAA,GAAyB;AACzG,QAAMC,IAAOT,EAAkB,IAAI,GAC7BU,IAASd,EAAkBQ,CAAM,GACjCO,IAAQR,KAAQO,EAAO;AAC7B,EAAAZ,EAAWW,GAAME,CAAK;AACtB,QAAMC,IAASf,EAAkBY,CAAI;AACrC,SAAAV,EAAoBW,EAAO,KAAKD,GAAME,GAAON,GAAWO,CAAM,GAE5D,gBAAAX,EAAC,OAAD;AAAA,IACE,KAAKQ;AAAA,IACL,WAAWF,IAAY,iBAAiBA,CAAA,KAAc;AAAA,IACtD,eAAY;AAAA,IACN,SAAS;AAAA,IAAU,OAAO;AAAA,IACzB,OAAAC;AAAA,IAEN,UAAAF;AAAA,EACE,CAAA;AAET"}
1
+ {"version":3,"file":"HoverCard.js","names":["useFloatingAnchor","useFloatingOffset","usePopover","useAnchoredPosition","useRef","jsx","HoverCard","open","anchor","placement","children","className","style","card","target","shown","offset"],"sources":["../../../src/components/HoverCard/HoverCard.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useRef } from \"react\";\nimport {\n type FloatingAnchor,\n type PopoverEl,\n useFloatingAnchor,\n useFloatingOffset,\n usePopover,\n} from \"../../overlay/floating.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { useAnchoredPosition } from \"../../overlay/use-anchored-position.js\";\n\nexport interface HoverCardTokens {\n /** Background of the card. */\n background: string;\n /** Corner radius. */\n radius: string;\n /** Inner padding. */\n padding: string;\n /** Gap between the card and its anchor. */\n offset: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n hoverCard: HoverCardTokens;\n }\n}\n\nexport interface HoverCardProps {\n /** Show it. The owner decides when: a hovered row, a focused thumbnail. */\n open: boolean;\n /** What it previews: a ref to an element, or a virtual anchor. */\n anchor: FloatingAnchor;\n /** Preferred side; it flips when there is no room and slides to stay on screen. Default `end`. */\n placement?: Placement;\n /** The preview (a larger thumbnail, a summary). Nothing in it can be clicked or focused. */\n children?: ReactNode;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-hover-card-* tokens. */\n style?: CSSProperties;\n}\n\n/**\n * A passive preview beside the thing it previews, such as a large thumbnail of a page on hover. It takes no pointer\n * input or focus and is hidden from assistive technology, because it only repeats what its anchor already names; for\n * text that describes a control use Tooltip, and for anything interactive use Popover.\n */\nexport function HoverCard({ open, anchor, placement = \"end\", children, className, style }: HoverCardProps) {\n const card = useRef<PopoverEl>(null);\n const target = useFloatingAnchor(anchor);\n const shown = open && target.present;\n usePopover(card, shown);\n const offset = useFloatingOffset(card);\n useAnchoredPosition(target.ref, card, shown, placement, offset);\n return (\n <div\n ref={card}\n className={className ? `cy-hover-card ${className}` : \"cy-hover-card\"}\n aria-hidden=\"true\"\n {...{ popover: \"manual\", inert: true }}\n style={style}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;AAgDA,SAAgBM,EAAU,EAAE,MAAAC,GAAM,QAAAC,GAAQ,WAAAC,IAAY,OAAO,UAAAC,GAAU,WAAAC,GAAW,OAAAC,EAAA,GAAyB;AACzG,QAAMC,IAAOT,EAAkB,IAAI,GAC7BU,IAASd,EAAkBQ,CAAM,GACjCO,IAAQR,KAAQO,EAAO;AAC7B,EAAAZ,EAAWW,GAAME,CAAK;AACtB,QAAMC,IAASf,EAAkBY,CAAI;AACrC,SAAAV,EAAoBW,EAAO,KAAKD,GAAME,GAAON,GAAWO,CAAM,GAE5D,gBAAAX,EAAC,OAAD;AAAA,IACE,KAAKQ;AAAA,IACL,WAAWF,IAAY,iBAAiBA,CAAA,KAAc;AAAA,IACtD,eAAY;AAAA,IACN,SAAS;AAAA,IAAU,OAAO;AAAA,IACzB,OAAAC;AAAA,IAEN,UAAAF;AAAA,EACE,CAAA;AAET"}
@@ -2,6 +2,7 @@ import type { IconData } from "../../icons/types.js";
2
2
  import type { Placement } from "../../overlay/position.js";
3
3
  import { type ButtonProps } from "../Button/Button.js";
4
4
  export interface IconButtonProps extends Omit<ButtonProps, "children" | "icon" | "iconEnd" | "fullWidth"> {
5
+ /** The Facet icon shown in the button. */
5
6
  icon: IconData;
6
7
  /** Required accessible name, also shown as the tooltip. */
7
8
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","names":["Icon","Button","Tooltip","forwardRef","jsx","IconButton","icon","label","className","tooltipPlacement","rest","ref"],"sources":["../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { Button, type ButtonProps } from \"../Button/Button.js\";\nimport { Tooltip } from \"../Tooltip/Tooltip.js\";\n\nexport interface IconButtonProps extends Omit<ButtonProps, \"children\" | \"icon\" | \"iconEnd\" | \"fullWidth\"> {\n icon: IconData;\n /** Required accessible name, also shown as the tooltip. */\n label: string;\n /** Where the label tooltip appears. */\n tooltipPlacement?: Placement;\n}\n\n/** A square Button with only an icon. Its label is the accessible name and a Tooltip (no native title). */\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n { icon, label, className, tooltipPlacement = \"top\", ...rest },\n ref,\n) {\n return (\n <Tooltip content={label} placement={tooltipPlacement}>\n <Button\n ref={ref}\n {...rest}\n aria-label={label}\n className={`cy-icon-button${className ? ` ${className}` : \"\"}`}\n >\n <Icon icon={icon} size={rest.size === \"lg\" ? \"lg\" : \"md\"} />\n </Button>\n </Tooltip>\n );\n});\n"],"mappings":";;;;;;AAgBA,IAAaK,IAAaF,EAA+C,SACvE,EAAE,MAAAG,GAAM,OAAAC,GAAO,WAAAC,GAAW,kBAAAC,IAAmB,OAAO,GAAGC,EAAA,GACvDC,GACA;AACA,SACE,gBAAAP,EAACF,GAAD;AAAA,IAAS,SAASK;AAAA,IAAO,WAAWE;AAAA,IAClC,UAAA,gBAAAL,EAACH,GAAD;AAAA,MACO,KAAAU;AAAA,MACL,GAAID;AAAA,MACJ,cAAYH;AAAA,MACZ,WAAW,iBAAiBC,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,MAE1D,UAAA,gBAAAJ,EAACJ,GAAD;AAAA,QAAY,MAAAM;AAAA,QAAM,MAAMI,EAAK,SAAS,OAAO,OAAO;AAAA,MAAO,CAAA;AAAA,IACrD,CAAA;AAAA,EACD,CAAA;AAEb,CAAC"}
1
+ {"version":3,"file":"IconButton.js","names":["Icon","Button","Tooltip","forwardRef","jsx","IconButton","icon","label","className","tooltipPlacement","rest","ref"],"sources":["../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { Button, type ButtonProps } from \"../Button/Button.js\";\nimport { Tooltip } from \"../Tooltip/Tooltip.js\";\n\nexport interface IconButtonProps extends Omit<ButtonProps, \"children\" | \"icon\" | \"iconEnd\" | \"fullWidth\"> {\n /** The Facet icon shown in the button. */\n icon: IconData;\n /** Required accessible name, also shown as the tooltip. */\n label: string;\n /** Where the label tooltip appears. */\n tooltipPlacement?: Placement;\n}\n\n/** A square Button with only an icon. Its label is the accessible name and a Tooltip (no native title). */\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n { icon, label, className, tooltipPlacement = \"top\", ...rest },\n ref,\n) {\n return (\n <Tooltip content={label} placement={tooltipPlacement}>\n <Button\n ref={ref}\n {...rest}\n aria-label={label}\n className={`cy-icon-button${className ? ` ${className}` : \"\"}`}\n >\n <Icon icon={icon} size={rest.size === \"lg\" ? \"lg\" : \"md\"} />\n </Button>\n </Tooltip>\n );\n});\n"],"mappings":";;;;;;AAiBA,IAAaK,IAAaF,EAA+C,SACvE,EAAE,MAAAG,GAAM,OAAAC,GAAO,WAAAC,GAAW,kBAAAC,IAAmB,OAAO,GAAGC,EAAA,GACvDC,GACA;AACA,SACE,gBAAAP,EAACF,GAAD;AAAA,IAAS,SAASK;AAAA,IAAO,WAAWE;AAAA,IAClC,UAAA,gBAAAL,EAACH,GAAD;AAAA,MACO,KAAAU;AAAA,MACL,GAAID;AAAA,MACJ,cAAYH;AAAA,MACZ,WAAW,iBAAiBC,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,MAE1D,UAAA,gBAAAJ,EAACJ,GAAD;AAAA,QAAY,MAAAM;AAAA,QAAM,MAAMI,EAAK,SAAS,OAAO,OAAO;AAAA,MAAO,CAAA;AAAA,IACrD,CAAA;AAAA,EACD,CAAA;AAEb,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { type CSSProperties, type ReactNode, type SyntheticEvent } from "react";
2
+ import { type AspectRatioRadius } from "../AspectRatio/AspectRatio.js";
3
+ export interface ImageTokens {
4
+ /** Corner radius of every Image, whatever its `radius` prop says. */
5
+ radius: string;
6
+ /** Fill of the box shown when the picture fails to load. */
7
+ fallbackBackground: string;
8
+ /** Icon and text colour of that box. */
9
+ fallbackColor: string;
10
+ /** Space between the picture and its caption. */
11
+ captionGap: string;
12
+ /** Text colour of the caption. */
13
+ captionColor: string;
14
+ }
15
+ declare module "../../tokens/schema.js" {
16
+ interface ComponentTokens {
17
+ image: ImageTokens;
18
+ }
19
+ }
20
+ export interface ImageProps {
21
+ /** Address of the picture. Changing it loads the new picture, also after a failure. */
22
+ src: string;
23
+ /** What the picture shows, for people who cannot see it. `""` marks it decorative and hides it from them. */
24
+ alt: string;
25
+ /** Candidate files for different screen densities or widths, as on `<img>`. */
26
+ srcSet?: string | undefined;
27
+ /** With `srcSet`: how wide the picture is shown, as on `<img>`. */
28
+ sizes?: string | undefined;
29
+ /** Natural width in pixels. With `height` and no `ratio`, it reserves the picture's space before it loads. */
30
+ width?: number | undefined;
31
+ /** Natural height in pixels. */
32
+ height?: number | undefined;
33
+ /**
34
+ * Width divided by height of the box the picture fills (`16 / 9`, `"4/3"`), kept at any width with AspectRatio.
35
+ * Without it the picture has its natural size, no wider than its container.
36
+ */
37
+ ratio?: number | string | undefined;
38
+ /** With `ratio`: `cover` fills the box and crops, `contain` shows the whole picture. Default "cover". */
39
+ fit?: "cover" | "contain";
40
+ /** With `ratio`: which part stays in view when cropped, as CSS `object-position` (`"top"`, `"20% 80%"`). */
41
+ position?: string | undefined;
42
+ /** Rounds the corners from the radius tokens. Default "none". */
43
+ radius?: AspectRatioRadius;
44
+ /** `lazy` waits until the picture is near the screen; `eager` loads it at once. Default "lazy". */
45
+ loading?: "lazy" | "eager";
46
+ /** Shown while the picture loads, in place of the Skeleton. */
47
+ placeholder?: ReactNode;
48
+ /** Shown when the picture fails, in place of the box with an icon and the `alt` text. */
49
+ fallback?: ReactNode;
50
+ /** A caption under the picture: wraps it in a `figure` named by the caption. */
51
+ caption?: ReactNode;
52
+ /** Called when the picture has loaded. */
53
+ onLoad?: ((event: SyntheticEvent<HTMLImageElement>) => void) | undefined;
54
+ /** Called when the picture fails to load. The fallback is shown as well. */
55
+ onError?: ((event: SyntheticEvent<HTMLImageElement>) => void) | undefined;
56
+ /** Added to the root element (the `figure` when there is a caption), for layout. */
57
+ className?: string;
58
+ /** Layout only (width, margin, placement), on the root element. Restyle through --cy-image-* tokens. */
59
+ style?: CSSProperties;
60
+ }
61
+ /** A picture that keeps its space while it loads, shows a placeholder until then and a fallback when it fails. */
62
+ export declare const Image: import("react").ForwardRefExoticComponent<ImageProps & import("react").RefAttributes<HTMLImageElement>>;
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { Icon as E } from "../../foundations/Icon/Icon.js";
3
+ import { AspectRatio as H } from "../AspectRatio/AspectRatio.js";
4
+ import { useImageOutcome as L } from "../../foundations/image-outcome.js";
5
+ import { image as O } from "../../icons/image.js";
6
+ import { Skeleton as P } from "../Skeleton/Skeleton.js";
7
+ import { forwardRef as S, useId as q, useImperativeHandle as B, useRef as C } from "react";
8
+ import { Fragment as N, jsx as e, jsxs as g } from "react/jsx-runtime";
9
+ var V = S(function({ src: f, alt: a, srcSet: u, sizes: R, width: o, height: n, ratio: i, fit: b = "cover", position: y, radius: j = "none", loading: x = "lazy", placeholder: k, fallback: d, caption: r, onLoad: z, onError: F, className: c, style: p }, A) {
10
+ const v = q(), t = C(null);
11
+ B(A, () => t.current);
12
+ const h = `${f} ${u ?? ""}`, m = L(t, h), s = m.outcome, I = /* @__PURE__ */ g(N, { children: [s === "error" ? /* @__PURE__ */ e("span", {
13
+ className: "cy-image-fallback",
14
+ "data-default": d === void 0 ? "" : void 0,
15
+ "aria-hidden": d === void 0 && a === "" ? !0 : void 0,
16
+ style: i === void 0 && o && n ? {
17
+ inlineSize: o,
18
+ aspectRatio: `${o} / ${n}`
19
+ } : void 0,
20
+ children: d ?? /* @__PURE__ */ g(N, { children: [/* @__PURE__ */ e(E, { icon: O }), a && /* @__PURE__ */ e("span", {
21
+ className: "cy-image-alt cy-reset",
22
+ children: a
23
+ })] })
24
+ }) : /* @__PURE__ */ e("img", {
25
+ ref: t,
26
+ className: "cy-image-img cy-reset",
27
+ src: f,
28
+ alt: a,
29
+ srcSet: u,
30
+ sizes: R,
31
+ width: o,
32
+ height: n,
33
+ loading: x,
34
+ decoding: "async",
35
+ style: y === void 0 ? void 0 : { objectPosition: y },
36
+ onLoad: (l) => {
37
+ m.loaded(), z?.(l);
38
+ },
39
+ onError: (l) => {
40
+ m.failed(), F?.(l);
41
+ }
42
+ }, h), s === "loading" && /* @__PURE__ */ e("span", {
43
+ className: "cy-image-placeholder cy-reset",
44
+ children: k ?? /* @__PURE__ */ e(P, {
45
+ shape: "block",
46
+ height: "100%"
47
+ })
48
+ })] }), $ = /* @__PURE__ */ e(i === void 0 ? "span" : "div", {
49
+ className: !r && c ? `cy-image ${c}` : "cy-image",
50
+ "data-state": s,
51
+ "data-fit": b,
52
+ "data-radius": j,
53
+ "data-ratio": i === void 0 ? void 0 : "",
54
+ style: r ? void 0 : p,
55
+ children: i === void 0 ? I : /* @__PURE__ */ e(H, {
56
+ ratio: i,
57
+ children: I
58
+ })
59
+ });
60
+ return r ? /* @__PURE__ */ g("figure", {
61
+ className: c ? `cy-image-figure ${c}` : "cy-image-figure",
62
+ "aria-labelledby": v,
63
+ style: p,
64
+ children: [$, /* @__PURE__ */ e("figcaption", {
65
+ id: v,
66
+ className: "cy-image-caption",
67
+ children: r
68
+ })]
69
+ }) : $;
70
+ });
71
+ export {
72
+ V as Image
73
+ };
74
+
75
+ //# sourceMappingURL=Image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Image.js","names":["_Fragment","Icon","AspectRatio","useImageOutcome","image","Skeleton","forwardRef","useId","useImperativeHandle","useRef","Fragment$1","jsx","jsxs","Image","src","alt","srcSet","sizes","width","height","ratio","fit","position","radius","loading","placeholder","fallback","caption","onLoad","onError","className","style","ref","captionId","el","key","picture","state","content","event","frame"],"sources":["../../../src/components/Image/Image.tsx"],"sourcesContent":["import {\n type CSSProperties,\n forwardRef,\n type ReactNode,\n type SyntheticEvent,\n useId,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { useImageOutcome } from \"../../foundations/image-outcome.js\";\nimport { image } from \"../../icons/image.js\";\nimport { AspectRatio, type AspectRatioRadius } from \"../AspectRatio/AspectRatio.js\";\nimport { Skeleton } from \"../Skeleton/Skeleton.js\";\n\nexport interface ImageTokens {\n /** Corner radius of every Image, whatever its `radius` prop says. */\n radius: string;\n /** Fill of the box shown when the picture fails to load. */\n fallbackBackground: string;\n /** Icon and text colour of that box. */\n fallbackColor: string;\n /** Space between the picture and its caption. */\n captionGap: string;\n /** Text colour of the caption. */\n captionColor: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n image: ImageTokens;\n }\n}\n\nexport interface ImageProps {\n /** Address of the picture. Changing it loads the new picture, also after a failure. */\n src: string;\n /** What the picture shows, for people who cannot see it. `\"\"` marks it decorative and hides it from them. */\n alt: string;\n /** Candidate files for different screen densities or widths, as on `<img>`. */\n srcSet?: string | undefined;\n /** With `srcSet`: how wide the picture is shown, as on `<img>`. */\n sizes?: string | undefined;\n /** Natural width in pixels. With `height` and no `ratio`, it reserves the picture's space before it loads. */\n width?: number | undefined;\n /** Natural height in pixels. */\n height?: number | undefined;\n /**\n * Width divided by height of the box the picture fills (`16 / 9`, `\"4/3\"`), kept at any width with AspectRatio.\n * Without it the picture has its natural size, no wider than its container.\n */\n ratio?: number | string | undefined;\n /** With `ratio`: `cover` fills the box and crops, `contain` shows the whole picture. Default \"cover\". */\n fit?: \"cover\" | \"contain\";\n /** With `ratio`: which part stays in view when cropped, as CSS `object-position` (`\"top\"`, `\"20% 80%\"`). */\n position?: string | undefined;\n /** Rounds the corners from the radius tokens. Default \"none\". */\n radius?: AspectRatioRadius;\n /** `lazy` waits until the picture is near the screen; `eager` loads it at once. Default \"lazy\". */\n loading?: \"lazy\" | \"eager\";\n /** Shown while the picture loads, in place of the Skeleton. */\n placeholder?: ReactNode;\n /** Shown when the picture fails, in place of the box with an icon and the `alt` text. */\n fallback?: ReactNode;\n /** A caption under the picture: wraps it in a `figure` named by the caption. */\n caption?: ReactNode;\n /** Called when the picture has loaded. */\n onLoad?: ((event: SyntheticEvent<HTMLImageElement>) => void) | undefined;\n /** Called when the picture fails to load. The fallback is shown as well. */\n onError?: ((event: SyntheticEvent<HTMLImageElement>) => void) | undefined;\n /** Added to the root element (the `figure` when there is a caption), for layout. */\n className?: string;\n /** Layout only (width, margin, placement), on the root element. Restyle through --cy-image-* tokens. */\n style?: CSSProperties;\n}\n\n/** A picture that keeps its space while it loads, shows a placeholder until then and a fallback when it fails. */\nexport const Image = forwardRef<HTMLImageElement, ImageProps>(function Image(\n {\n src,\n alt,\n srcSet,\n sizes,\n width,\n height,\n ratio,\n fit = \"cover\",\n position,\n radius = \"none\",\n loading = \"lazy\",\n placeholder,\n fallback,\n caption,\n onLoad,\n onError,\n className,\n style,\n },\n ref,\n) {\n const captionId = useId();\n const el = useRef<HTMLImageElement>(null);\n useImperativeHandle(ref, () => el.current as HTMLImageElement);\n // One outcome per picture: a new `src` starts again from \"loading\", whatever happened to the last one.\n const key = `${src} ${srcSet ?? \"\"}`;\n const picture = useImageOutcome(el, key);\n const state = picture.outcome;\n\n const content = (\n <>\n {state === \"error\" ? (\n <span\n className=\"cy-image-fallback\"\n data-default={fallback === undefined ? \"\" : undefined}\n aria-hidden={fallback === undefined && alt === \"\" ? true : undefined}\n style={\n ratio === undefined && width && height\n ? { inlineSize: width, aspectRatio: `${width} / ${height}` }\n : undefined\n }\n >\n {fallback ?? (\n <>\n <Icon icon={image} />\n {alt && <span className=\"cy-image-alt cy-reset\">{alt}</span>}\n </>\n )}\n </span>\n ) : (\n <img\n // A new element for each picture, so `complete` never describes the one before.\n key={key}\n ref={el}\n className=\"cy-image-img cy-reset\"\n src={src}\n alt={alt}\n srcSet={srcSet}\n sizes={sizes}\n width={width}\n height={height}\n loading={loading}\n decoding=\"async\"\n style={position === undefined ? undefined : { objectPosition: position }}\n onLoad={(event) => {\n picture.loaded();\n onLoad?.(event);\n }}\n onError={(event) => {\n picture.failed();\n onError?.(event);\n }}\n />\n )}\n {state === \"loading\" && (\n <span className=\"cy-image-placeholder cy-reset\">\n {placeholder ?? <Skeleton shape=\"block\" height=\"100%\" />}\n </span>\n )}\n </>\n );\n\n const Frame = ratio === undefined ? \"span\" : \"div\";\n const frame = (\n <Frame\n className={!caption && className ? `cy-image ${className}` : \"cy-image\"}\n data-state={state}\n data-fit={fit}\n data-radius={radius}\n data-ratio={ratio === undefined ? undefined : \"\"}\n style={caption ? undefined : style}\n >\n {ratio === undefined ? content : <AspectRatio ratio={ratio}>{content}</AspectRatio>}\n </Frame>\n );\n if (!caption) return frame;\n return (\n <figure\n className={className ? `cy-image-figure ${className}` : \"cy-image-figure\"}\n aria-labelledby={captionId}\n style={style}\n >\n {frame}\n <figcaption id={captionId} className=\"cy-image-caption\">\n {caption}\n </figcaption>\n </figure>\n );\n});\n"],"mappings":";;;;;;;;AA6EA,IAAaa,IAAQP,EAAyC,SAC5D,EACE,KAAAQ,GACA,KAAAC,GACA,QAAAC,GACA,OAAAC,GACA,OAAAC,GACA,QAAAC,GACA,OAAAC,GACA,KAAAC,IAAM,SACN,U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,MAAAH,EAAQ,OAAO,GACfR,IAASW,CAAK;AAAA,IAChB;AAAA,IACA,SAAA,CAAUA,MAAU;AAClB,MAAAH,EAAQ,OAAO,GACfP,IAAUU,CAAK;AAAA,IACjB;AAAA,EACD,GApBMJ,CAoBN,GAEFE,MAAU,aACT,gBAAA1B,EAAC,QAAD;AAAA,IAAM,WAAU;AAAA,IACb,UAAAc,KAAe,gBAAAd,EAACN,GAAD;AAAA,MAAU,OAAM;AAAA,MAAQ,QAAO;AAAA,IAAQ,CAAA;AAAA,EACnD,CAAA,CAER,EAAA,CAAA,GAIEmC,IACJ,gBAAA7B,EAFYS,MAAU,SAAY,SAAS,OAE3C;AAAA,IACE,WAAW,CAACO,KAAWG,IAAY,YAAYA,CAAA,KAAc;AAAA,IAC7D,cAAYO;AAAA,IACZ,YAAUhB;AAAA,IACV,eAAaE;AAAA,IACb,cAAYH,MAAU,SAAY,SAAY;AAAA,IAC9C,OAAOO,IAAU,SAAYI;AAAA,IAE5B,UAAAX,MAAU,SAAYkB,IAAU,gBAAA3B,EAACT,GAAD;AAAA,MAAoB,OAAAkB;AAAA,MAAQ,UAAAkB;AAAA,IAAqB,CAAA;AAAA,EAC7E,CAAA;AAET,SAAKX,IAEH,gBAAAf,EAAC,UAAD;AAAA,IACE,WAAWkB,IAAY,mBAAmBA,CAAA,KAAc;AAAA,IACxD,mBAAiBG;AAAA,IACV,OAAAF;AAAA,IAHT,UAAA,CAKGS,GACD,gBAAA7B,EAAC,cAAD;AAAA,MAAY,IAAIsB;AAAA,MAAW,WAAU;AAAA,MAClC,UAAAN;AAAA,IACS,CAAA,CACN;AAAA,E,KAXWa;AAavB,CAAC"}
@@ -0,0 +1 @@
1
+ export { Image, type ImageProps, type ImageTokens } from "./Image.js";
@@ -1,20 +1,24 @@
1
1
  import { type CSSProperties, type ReactNode } from "react";
2
- type Space = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10";
3
- export interface InlineProps {
2
+ import { type PaddingProps, type Space } from "../Stack/space.js";
3
+ export interface InlineProps extends PaddingProps {
4
4
  /** Space token between children. */
5
5
  gap?: Space;
6
+ /** Cross-axis alignment of children. They are centred when it is not set. */
6
7
  align?: "start" | "center" | "end" | "stretch" | "baseline";
8
+ /** How children are spread along the row. */
7
9
  justify?: "start" | "center" | "end" | "between";
8
10
  /** Wrap onto new lines when space runs out. */
9
11
  wrap?: boolean;
10
12
  /** Neutral layout element to render (never an interactive one). */
11
13
  as?: "div" | "section" | "ul" | "ol" | "nav" | "aside" | "header" | "footer" | "span";
14
+ /** Added to the root element, for layout. */
12
15
  className?: string;
13
16
  /** Layout only. */
14
17
  style?: CSSProperties;
18
+ /** The elements to lay out in a row. */
15
19
  children?: ReactNode;
20
+ /** Set on the root element, for tests. */
16
21
  "data-testid"?: string;
17
22
  }
18
23
  /** Horizontal layout with token gaps. */
19
24
  export declare const Inline: import("react").ForwardRefExoticComponent<InlineProps & import("react").RefAttributes<HTMLElement>>;
20
- export {};
@@ -1,23 +1,29 @@
1
1
  "use client";
2
- import { forwardRef as p } from "react";
3
- import { jsx as s } from "react/jsx-runtime";
4
- var v = p(function({ gap: i = "3", align: r, justify: e, wrap: n = !1, as: t = "div", className: a, style: o, children: f, ...l }, d) {
5
- return /* @__PURE__ */ s(t, {
6
- ref: d,
7
- ...l,
2
+ import { paddingVars as c, space as u } from "../Stack/space.js";
3
+ import { forwardRef as g } from "react";
4
+ import { jsx as v } from "react/jsx-runtime";
5
+ var I = g(function({ gap: i = "3", padding: r, paddingInline: n, paddingBlock: t, align: e, justify: o, wrap: d = !1, as: f = "div", className: a, style: p, children: l, ...s }, m) {
6
+ return /* @__PURE__ */ v(f, {
7
+ ref: m,
8
+ ...s,
8
9
  className: `cy-inline${a ? ` ${a}` : ""}`,
9
- "data-align": r,
10
- "data-justify": e,
11
- "data-wrap": n ? "" : void 0,
10
+ "data-align": e,
11
+ "data-justify": o,
12
+ "data-wrap": d ? "" : void 0,
12
13
  style: {
13
- "--_gap": `var(--cy-space-${i})`,
14
- ...o
14
+ "--_gap": u(i),
15
+ ...c({
16
+ padding: r,
17
+ paddingInline: n,
18
+ paddingBlock: t
19
+ }),
20
+ ...p
15
21
  },
16
- children: f
22
+ children: l
17
23
  });
18
24
  });
19
25
  export {
20
- v as Inline
26
+ I as Inline
21
27
  };
22
28
 
23
29
  //# sourceMappingURL=Inline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Inline.js","names":["Tag","forwardRef","jsx","Inline","gap","align","justify","wrap","as","className","style","children","rest","ref"],"sources":["../../../src/components/Inline/Inline.tsx"],"sourcesContent":["import { type CSSProperties, type ElementType, forwardRef, type ReactNode } from \"react\";\n\ntype Space = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\" | \"10\";\n\nexport interface InlineProps {\n /** Space token between children. */\n gap?: Space;\n align?: \"start\" | \"center\" | \"end\" | \"stretch\" | \"baseline\";\n justify?: \"start\" | \"center\" | \"end\" | \"between\";\n /** Wrap onto new lines when space runs out. */\n wrap?: boolean;\n /** Neutral layout element to render (never an interactive one). */\n as?: \"div\" | \"section\" | \"ul\" | \"ol\" | \"nav\" | \"aside\" | \"header\" | \"footer\" | \"span\";\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n children?: ReactNode;\n \"data-testid\"?: string;\n}\n\n/** Horizontal layout with token gaps. */\nexport const Inline = forwardRef<HTMLElement, InlineProps>(function Inline(\n { gap = \"3\", align, justify, wrap = false, as = \"div\", className, style, children, ...rest },\n ref,\n) {\n const Tag = as as ElementType;\n return (\n <Tag\n ref={ref}\n {...rest}\n className={`cy-inline${className ? ` ${className}` : \"\"}`}\n data-align={align}\n data-justify={justify}\n data-wrap={wrap ? \"\" : undefined}\n style={{ \"--_gap\": `var(--cy-space-${gap})`, ...style } as CSSProperties}\n >\n {children}\n </Tag>\n );\n});\n"],"mappings":";;;AAqBA,IAAaG,IAASF,EAAqC,SACzD,EAAE,KAAAG,IAAM,KAAK,OAAAC,GAAO,SAAAC,GAAS,MAAAC,IAAO,IAAO,IAAAC,IAAK,OAAO,WAAAC,GAAW,OAAAC,GAAO,UAAAC,GAAU,GAAGC,EAAA,GACtFC,GACA;AAEA,SACE,gBAAAX,EAACF,GAAD;AAAA,IACO,KAAAa;AAAA,IACL,GAAID;AAAA,IACJ,WAAW,YAAYH,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACrD,cAAYJ;AAAA,IACZ,gBAAcC;AAAA,IACd,aAAWC,IAAO,KAAK;AAAA,IACvB,OAAO;AAAA,MAAE,UAAU,kBAAkBH,CAAA;AAAA,MAAQ,GAAGM;AAAA,IAAM;AAAA,IAErD,UAAAC;AAAA,EACE,CAAA;AAET,CAAC"}
1
+ {"version":3,"file":"Inline.js","names":["Tag","paddingVars","space","forwardRef","jsx","Inline","gap","padding","paddingInline","paddingBlock","align","justify","wrap","as","className","style","children","rest","ref"],"sources":["../../../src/components/Inline/Inline.tsx"],"sourcesContent":["import { type CSSProperties, type ElementType, forwardRef, type ReactNode } from \"react\";\nimport { type PaddingProps, paddingVars, type Space, space } from \"../Stack/space.js\";\n\nexport interface InlineProps extends PaddingProps {\n /** Space token between children. */\n gap?: Space;\n /** Cross-axis alignment of children. They are centred when it is not set. */\n align?: \"start\" | \"center\" | \"end\" | \"stretch\" | \"baseline\";\n /** How children are spread along the row. */\n justify?: \"start\" | \"center\" | \"end\" | \"between\";\n /** Wrap onto new lines when space runs out. */\n wrap?: boolean;\n /** Neutral layout element to render (never an interactive one). */\n as?: \"div\" | \"section\" | \"ul\" | \"ol\" | \"nav\" | \"aside\" | \"header\" | \"footer\" | \"span\";\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n /** The elements to lay out in a row. */\n children?: ReactNode;\n /** Set on the root element, for tests. */\n \"data-testid\"?: string;\n}\n\n/** Horizontal layout with token gaps. */\nexport const Inline = forwardRef<HTMLElement, InlineProps>(function Inline(\n {\n gap = \"3\",\n padding,\n paddingInline,\n paddingBlock,\n align,\n justify,\n wrap = false,\n as = \"div\",\n className,\n style,\n children,\n ...rest\n },\n ref,\n) {\n const Tag = as as ElementType;\n return (\n <Tag\n ref={ref}\n {...rest}\n className={`cy-inline${className ? ` ${className}` : \"\"}`}\n data-align={align}\n data-justify={justify}\n data-wrap={wrap ? \"\" : undefined}\n style={\n {\n \"--_gap\": space(gap),\n ...paddingVars({ padding, paddingInline, paddingBlock }),\n ...style,\n } as CSSProperties\n }\n >\n {children}\n </Tag>\n );\n});\n"],"mappings":";;;;AAyBA,IAAaK,IAASF,EAAqC,SACzD,EACE,KAAAG,IAAM,KACN,SAAAC,GACA,eAAAC,GACA,cAAAC,GACA,OAAAC,GACA,SAAAC,GACA,MAAAC,IAAO,IACP,IAAAC,IAAK,OACL,WAAAC,GACA,OAAAC,GACA,UAAAC,GACA,GAAGC,EAAA,GAELC,GACA;AAEA,SACE,gBAAAd,EAACJ,GAAD;AAAA,IACO,KAAAkB;AAAA,IACL,GAAID;AAAA,IACJ,WAAW,YAAYH,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACrD,cAAYJ;AAAA,IACZ,gBAAcC;AAAA,IACd,aAAWC,IAAO,KAAK;AAAA,IACvB,OACE;AAAA,MACE,UAAUV,EAAMI,CAAG;AAAA,MACnB,GAAGL,EAAY;AAAA,QAAE,SAAAM;AAAA,QAAS,eAAAC;AAAA,QAAe,cAAAC;AAAA,MAAa,CAAC;AAAA,MACvD,GAAGM;AAAA,IACL;AAAA,IAGD,UAAAC;AAAA,EACE,CAAA;AAET,CAAC"}
@@ -16,9 +16,11 @@ export interface KbdProps {
16
16
  * names (Cmd on Apple, Ctrl elsewhere) and hidden on touch-only screens, where a shortcut means nothing.
17
17
  */
18
18
  keys: string[] | string;
19
+ /** Size of the key caps. Default "md". */
19
20
  size?: Size;
20
21
  /** Override the spoken text (default "Control plus K"). */
21
22
  label?: string;
23
+ /** Added to the root element, for layout. */
22
24
  className?: string;
23
25
  /** Layout only. */
24
26
  style?: CSSProperties;
@@ -1 +1 @@
1
- {"version":3,"file":"Kbd.js","names":["useClientLayoutEffect","isApple","shortcutKeys","Fragment","useState","jsx","jsxs","SPOKEN","Kbd","keys","size","label","className","style","apple","useApple","caps","spoken","k","key","i","setApple"],"sources":["../../../src/components/Kbd/Kbd.tsx"],"sourcesContent":["import { type CSSProperties, Fragment, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { isApple, shortcutKeys } from \"../../foundations/hotkey.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface KbdTokens {\n radius: string;\n bg: string;\n border: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n kbd: KbdTokens;\n }\n}\n\nconst SPOKEN: Record<string, string> = {\n ctrl: \"Control\",\n control: \"Control\",\n cmd: \"Command\",\n command: \"Command\",\n meta: \"Command\",\n win: \"Windows\",\n alt: \"Alt\",\n option: \"Option\",\n opt: \"Option\",\n shift: \"Shift\",\n enter: \"Enter\",\n return: \"Return\",\n esc: \"Escape\",\n escape: \"Escape\",\n tab: \"Tab\",\n space: \"Space\",\n backspace: \"Backspace\",\n delete: \"Delete\",\n up: \"Up arrow\",\n down: \"Down arrow\",\n left: \"Left arrow\",\n right: \"Right arrow\",\n};\n\nexport interface KbdProps {\n /**\n * Keys in order, e.g. [\"Ctrl\", \"K\"]; or a shortcut as `useHotkey` writes it (\"mod+k\"), shown with this platform's\n * names (Cmd on Apple, Ctrl elsewhere) and hidden on touch-only screens, where a shortcut means nothing.\n */\n keys: string[] | string;\n size?: Size;\n /** Override the spoken text (default \"Control plus K\"). */\n label?: string;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Keyboard shortcut: drawn key caps for sight, a spoken combination for screen readers. */\nexport function Kbd({ keys, size = \"md\", label, className, style }: KbdProps) {\n const apple = useApple();\n const caps = typeof keys === \"string\" ? shortcutKeys(keys, apple) : keys;\n const spoken = label ?? caps.map((k) => SPOKEN[k.toLowerCase()] ?? k).join(\" plus \");\n return (\n <kbd\n className={`cy-kbd${className ? ` ${className}` : \"\"}`}\n data-size={size}\n data-shortcut={typeof keys === \"string\" || undefined}\n style={style}\n >\n <span aria-hidden=\"true\" className=\"cy-reset cy-kbd-keys\">\n {caps.map((key, i) => (\n <Fragment key={`${key}-${i}`}>\n {i > 0 && <span className=\"cy-reset cy-kbd-join\" />}\n <kbd className=\"cy-kbd-key\">{key}</kbd>\n </Fragment>\n ))}\n </span>\n <span className=\"cy-visually-hidden\">{spoken}</span>\n </kbd>\n );\n}\n\n/** Apple or not, decided after hydration so the server and the first client render agree. */\nexport function useApple() {\n const [apple, setApple] = useState(false);\n useClientLayoutEffect(() => setApple(isApple()), []);\n return apple;\n}\n"],"mappings":";;;;;AAiBA,IAAMO,IAAiC;AAAA,EACrC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAiBA,SAAgBC,EAAI,EAAE,MAAAC,GAAM,MAAAC,IAAO,MAAM,OAAAC,GAAO,WAAAC,GAAW,OAAAC,EAAA,GAAmB;AAC5E,QAAMC,IAAQC,EAAS,GACjBC,IAAO,OAAOP,KAAS,WAAWP,EAAaO,GAAMK,CAAK,IAAIL,GAC9DQ,IAASN,KAASK,EAAK,IAAA,CAAKE,MAAMX,EAAOW,EAAE,YAAY,CAAA,KAAMA,CAAC,EAAE,KAAK,QAAQ;AACnF,SACE,gBAAAZ,EAAC,OAAD;AAAA,IACE,WAAW,SAASM,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IAClD,aAAWF;AAAA,IACX,iBAAe,OAAOD,KAAS,YAAY;AAAA,IACpC,OAAAI;AAAA,IAJT,UAAA,CAME,gBAAAR,EAAC,QAAD;AAAA,MAAM,eAAY;AAAA,MAAO,WAAU;AAAA,MAChC,UAAAW,EAAK,IAAA,CAAKG,GAAKC,MACd,gBAAAd,EAACH,GAAD,EAAA,UAAA,CACGiB,IAAI,KAAK,gBAAAf,EAAC,QAAD,EAAM,WAAU,uBAAwB,CAAA,GAClD,gBAAAA,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAAc,UAAAc;AAAA,MAAS,CAAA,CAC9B,EAAA,GAHK,GAAGA,CAAA,IAAOC,CAAA,EAGf,CACX;AAAA,IACG,CAAA,GACN,gBAAAf,EAAC,QAAD;AAAA,MAAM,WAAU;AAAA,MAAsB,UAAAY;AAAA,IAAa,CAAA,CAChD;AAAA,E;AAET;AAGA,SAAgBF,IAAW;AACzB,QAAM,CAACD,GAAOO,CAAA,IAAYjB,EAAS,EAAK;AACxC,SAAAJ,EAAA,MAA4BqB,EAASpB,EAAQ,CAAC,GAAG,CAAC,CAAC,GAC5Ca;AACT"}
1
+ {"version":3,"file":"Kbd.js","names":["useClientLayoutEffect","isApple","shortcutKeys","Fragment","useState","jsx","jsxs","SPOKEN","Kbd","keys","size","label","className","style","apple","useApple","caps","spoken","k","key","i","setApple"],"sources":["../../../src/components/Kbd/Kbd.tsx"],"sourcesContent":["import { type CSSProperties, Fragment, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { isApple, shortcutKeys } from \"../../foundations/hotkey.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface KbdTokens {\n radius: string;\n bg: string;\n border: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n kbd: KbdTokens;\n }\n}\n\nconst SPOKEN: Record<string, string> = {\n ctrl: \"Control\",\n control: \"Control\",\n cmd: \"Command\",\n command: \"Command\",\n meta: \"Command\",\n win: \"Windows\",\n alt: \"Alt\",\n option: \"Option\",\n opt: \"Option\",\n shift: \"Shift\",\n enter: \"Enter\",\n return: \"Return\",\n esc: \"Escape\",\n escape: \"Escape\",\n tab: \"Tab\",\n space: \"Space\",\n backspace: \"Backspace\",\n delete: \"Delete\",\n up: \"Up arrow\",\n down: \"Down arrow\",\n left: \"Left arrow\",\n right: \"Right arrow\",\n};\n\nexport interface KbdProps {\n /**\n * Keys in order, e.g. [\"Ctrl\", \"K\"]; or a shortcut as `useHotkey` writes it (\"mod+k\"), shown with this platform's\n * names (Cmd on Apple, Ctrl elsewhere) and hidden on touch-only screens, where a shortcut means nothing.\n */\n keys: string[] | string;\n /** Size of the key caps. Default \"md\". */\n size?: Size;\n /** Override the spoken text (default \"Control plus K\"). */\n label?: string;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Keyboard shortcut: drawn key caps for sight, a spoken combination for screen readers. */\nexport function Kbd({ keys, size = \"md\", label, className, style }: KbdProps) {\n const apple = useApple();\n const caps = typeof keys === \"string\" ? shortcutKeys(keys, apple) : keys;\n const spoken = label ?? caps.map((k) => SPOKEN[k.toLowerCase()] ?? k).join(\" plus \");\n return (\n <kbd\n className={`cy-kbd${className ? ` ${className}` : \"\"}`}\n data-size={size}\n data-shortcut={typeof keys === \"string\" || undefined}\n style={style}\n >\n <span aria-hidden=\"true\" className=\"cy-reset cy-kbd-keys\">\n {caps.map((key, i) => (\n <Fragment key={`${key}-${i}`}>\n {i > 0 && <span className=\"cy-reset cy-kbd-join\" />}\n <kbd className=\"cy-kbd-key\">{key}</kbd>\n </Fragment>\n ))}\n </span>\n <span className=\"cy-visually-hidden\">{spoken}</span>\n </kbd>\n );\n}\n\n/** Apple or not, decided after hydration so the server and the first client render agree. */\nexport function useApple() {\n const [apple, setApple] = useState(false);\n useClientLayoutEffect(() => setApple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HK,GAAGA,CAAA,IAAOC,CAAA,EAGf,CACX;AAAA,IACG,CAAA,GACN,gBAAAf,EAAC,QAAD;AAAA,MAAM,WAAU;AAAA,MAAsB,UAAAY;AAAA,IAAa,CAAA,CAChD;AAAA,E;AAET;AAGA,SAAgBF,IAAW;AACzB,QAAM,CAACD,GAAOO,CAAA,IAAYjB,EAAS,EAAK;AACxC,SAAAJ,EAAA,MAA4BqB,EAASpB,EAAQ,CAAC,GAAG,CAAC,CAAC,GAC5Ca;AACT"}
@@ -36,8 +36,11 @@ export interface KeyValueEditorLabels {
36
36
  export interface KeyValueEditorProps {
37
37
  /** What the pairs are ("Headers", "Query parameters"). Names the list and the text view. */
38
38
  label: string;
39
+ /** The pairs, when you control them. */
39
40
  pairs?: KeyValuePair[] | undefined;
41
+ /** Starting pairs when uncontrolled. */
40
42
  defaultPairs?: KeyValuePair[];
43
+ /** Called with the full list after each change: an edit, a row added, removed, moved or switched off. */
41
44
  onChange?: ((pairs: KeyValuePair[]) => void) | undefined;
42
45
  /** A checkbox per row to switch it off without deleting it. Default true. */
43
46
  toggleable?: boolean;
@@ -47,9 +50,13 @@ export interface KeyValueEditorProps {
47
50
  allowFiles?: boolean;
48
51
  /** File types for `allowFiles`, as for `<input accept>`. */
49
52
  accept?: string | undefined;
53
+ /** Turns off every field and button. */
50
54
  disabled?: boolean;
55
+ /** Size of the fields and buttons. Default "md". */
51
56
  size?: Size;
57
+ /** Replace the built-in English text. */
52
58
  labels?: Partial<KeyValueEditorLabels>;
59
+ /** Added to the root element, for layout. */
53
60
  className?: string;
54
61
  /** Layout only. Restyle through --cy-key-value-editor-* tokens. */
55
62
  style?: CSSProperties;
@@ -5,12 +5,12 @@ import { Button as w } from "../Button/Button.js";
5
5
  import { IconButton as p } from "../IconButton/IconButton.js";
6
6
  import { close as V } from "../../icons/close.js";
7
7
  import { Checkbox as D } from "../Checkbox/Checkbox.js";
8
+ import { plus as M } from "../../icons/plus.js";
9
+ import { trash as O } from "../../icons/trash.js";
10
+ import { SortableList as P } from "../SortableList/SortableList.js";
8
11
  import { TextField as b } from "../TextField/TextField.js";
9
- import { FileInputBase as M } from "../../foundations/FileInputBase/FileInputBase.js";
12
+ import { FileInputBase as _ } from "../../foundations/FileInputBase/FileInputBase.js";
10
13
  import { paperclip as B } from "../../icons/paperclip.js";
11
- import { plus as O } from "../../icons/plus.js";
12
- import { trash as P } from "../../icons/trash.js";
13
- import { SortableList as _ } from "../SortableList/SortableList.js";
14
14
  import { TextArea as G } from "../TextArea/TextArea.js";
15
15
  import { fromBulkText as J, newPairId as Q, pairName as W, toBulkText as X } from "./bulk.js";
16
16
  import { useRef as f, useState as Y } from "react";
@@ -117,7 +117,7 @@ function ye({ label: l, pairs: N, defaultPairs: R = [], onChange: A, toggleable:
117
117
  }
118
118
  })),
119
119
  /* @__PURE__ */ o(p, {
120
- icon: P,
120
+ icon: O,
121
121
  label: r.remove(t),
122
122
  variant: "ghost",
123
123
  size: a,
@@ -134,7 +134,7 @@ function ye({ label: l, pairs: N, defaultPairs: R = [], onChange: A, toggleable:
134
134
  "data-size": a,
135
135
  style: T,
136
136
  children: [
137
- s === null ? c.length > 0 && /* @__PURE__ */ o(_, {
137
+ s === null ? c.length > 0 && /* @__PURE__ */ o(P, {
138
138
  label: l,
139
139
  items: j,
140
140
  onReorder: (e) => d(e.map((u) => c.find((t) => t.id === u.id))),
@@ -150,7 +150,7 @@ function ye({ label: l, pairs: N, defaultPairs: R = [], onChange: A, toggleable:
150
150
  g(e), d(J(e, c, S.current));
151
151
  }
152
152
  }),
153
- $ && /* @__PURE__ */ o(M, {
153
+ $ && /* @__PURE__ */ o(_, {
154
154
  ref: y,
155
155
  className: "cy-key-value-editor-picker",
156
156
  tabIndex: -1,
@@ -168,7 +168,7 @@ function ye({ label: l, pairs: N, defaultPairs: R = [], onChange: A, toggleable:
168
168
  /* @__PURE__ */ x("div", {
169
169
  className: "cy-key-value-editor-actions cy-reset",
170
170
  children: [s === null && /* @__PURE__ */ o(w, {
171
- icon: O,
171
+ icon: M,
172
172
  variant: "ghost",
173
173
  size: a,
174
174
  disabled: n,
@@ -1 +1 @@
1
- {"version":3,"file":"KeyValueEditor.js","names":["useControllableState","useClientLayoutEffect","Button","IconButton","close","Checkbox","TextField","FileInputBase","paperclip","plus","trash","SortableList","TextArea","fromBulkText","newPairId","pairName","toBulkText","useRef","useState","jsx","jsxs","DEFAULT_LABELS","n","name","label","KeyValueEditor","pairs","defaultPairs","onChange","toggleable","bulkEdit","allowFiles","accept","disabled","size","labels","className","style","text","rows","setRows","bulk","setBulk","secretKeys","root","focusNext","picking","picker","id","update","patch","r","add","pair","remove","at","rest","items","i","on","key","value","next","item","file"],"sources":["../../../src/components/KeyValueEditor/KeyValueEditor.tsx"],"sourcesContent":["import { type CSSProperties, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { FileInputBase } from \"../../foundations/FileInputBase/FileInputBase.js\";\nimport { close } from \"../../icons/close.js\";\nimport { paperclip } from \"../../icons/paperclip.js\";\nimport { plus } from \"../../icons/plus.js\";\nimport { trash } from \"../../icons/trash.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { Button } from \"../Button/Button.js\";\nimport { Checkbox } from \"../Checkbox/Checkbox.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { SortableList } from \"../SortableList/SortableList.js\";\nimport { TextArea } from \"../TextArea/TextArea.js\";\nimport { TextField } from \"../TextField/TextField.js\";\nimport { fromBulkText, type KeyValuePair, newPairId, pairName, toBulkText } from \"./bulk.js\";\n\nexport type { KeyValuePair };\n\nexport interface KeyValueEditorTokens {\n /** Space between the fields of a row. */\n gap: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n keyValueEditor: KeyValueEditorTokens;\n }\n}\n\nexport interface KeyValueEditorLabels {\n /** Key field. Default \"Key\". */\n key: string;\n /** Value field. Default \"Value\". */\n value: string;\n /** How an unnamed row is called. Default \"Row 3\". */\n row: (position: number) => string;\n /** Add button. Default \"Add\". */\n add: string;\n /** Remove button. Default \"Remove Authorization\". */\n remove: (name: string) => string;\n /** On/off checkbox. Default \"Use Authorization\". */\n enable: (name: string) => string;\n /** With `allowFiles`: the button that picks a file for a row. Default \"Attach a file to avatar\". */\n attach: (name: string) => string;\n /** With `allowFiles`: the button that takes a row's file away. Default \"Remove the file from avatar\". */\n detach: (name: string) => string;\n /** Toggle to the text view. Default \"Edit as text\". */\n bulk: string;\n /** The text view's field. Default \"Headers as text: one key: value per line, # turns a line off\". */\n bulkField: (label: string) => string;\n}\n\nexport interface KeyValueEditorProps {\n /** What the pairs are (\"Headers\", \"Query parameters\"). Names the list and the text view. */\n label: string;\n pairs?: KeyValuePair[] | undefined;\n defaultPairs?: KeyValuePair[];\n onChange?: ((pairs: KeyValuePair[]) => void) | undefined;\n /** A checkbox per row to switch it off without deleting it. Default true. */\n toggleable?: boolean;\n /** A toggle to edit every pair as `key: value` lines (paste a block of headers). Default true. */\n bulkEdit?: boolean;\n /** A button per row to make its value a file instead of text (multipart form fields). `accept` limits the types. */\n allowFiles?: boolean;\n /** File types for `allowFiles`, as for `<input accept>`. */\n accept?: string | undefined;\n disabled?: boolean;\n size?: Size;\n labels?: Partial<KeyValueEditorLabels>;\n className?: string;\n /** Layout only. Restyle through --cy-key-value-editor-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: KeyValueEditorLabels = {\n key: \"Key\",\n value: \"Value\",\n row: (n) => `Row ${n}`,\n add: \"Add\",\n remove: (name) => `Remove ${name}`,\n enable: (name) => `Use ${name}`,\n attach: (name) => `Attach a file to ${name}`,\n detach: (name) => `Remove the file from ${name}`,\n bulk: \"Edit as text\",\n bulkField: (label) => `${label} as text: one key: value per line, # turns a line off`,\n};\n\n/**\n * Editable key and value pairs: HTTP headers, query parameters, environment variables, metadata. Rows reorder like a\n * SortableList (grip, or Space and arrows on it), switch off without being deleted, and can be edited all at once as\n * `key: value` text. Secret values (`secret: true`) are masked.\n */\nexport function KeyValueEditor({\n label,\n pairs,\n defaultPairs = [],\n onChange,\n toggleable = true,\n bulkEdit = true,\n allowFiles = false,\n accept,\n disabled = false,\n size = \"md\",\n labels,\n className,\n style,\n}: KeyValueEditorProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [rows, setRows] = useControllableState(pairs, defaultPairs, onChange);\n const [bulk, setBulk] = useState<string | null>(null);\n /** Keys that were secret when the text view opened: they stay masked however the text is retyped. */\n const secretKeys = useRef(new Set<string>());\n const root = useRef<HTMLDivElement>(null);\n /** Where focus goes after the rows change: a row's key field, or the Add button. */\n const focusNext = useRef<string | null>(null);\n /** The row a file is being picked for. One hidden file input serves every row. */\n const picking = useRef<string | null>(null);\n const picker = useRef<HTMLInputElement>(null);\n\n useClientLayoutEffect(() => {\n const id = focusNext.current;\n if (id === null) return;\n focusNext.current = null;\n const target = id\n ? root.current?.querySelector<HTMLElement>(`[data-pair=\"${CSS.escape(id)}\"] .cy-text-field-input`)\n : root.current?.querySelector<HTMLElement>(\".cy-key-value-editor-add\");\n target?.focus();\n });\n\n const update = (id: string, patch: Partial<KeyValuePair>) =>\n setRows(rows.map((r) => (r.id === id ? { ...r, ...patch } : r)));\n const add = () => {\n const pair = { id: newPairId(), key: \"\", value: \"\" };\n focusNext.current = pair.id;\n setRows([...rows, pair]);\n };\n const remove = (id: string) => {\n const at = rows.findIndex((r) => r.id === id);\n const rest = rows.filter((r) => r.id !== id);\n // Focus the row that took its place (or the one before it), else Add.\n focusNext.current = (rest[at] ?? rest[at - 1])?.id ?? \"\";\n setRows(rest);\n };\n\n const items = rows.map((pair, i) => {\n const name = pairName(pair, i, text.row);\n return {\n id: pair.id,\n label: name,\n content: (\n <div\n className=\"cy-key-value-editor-row cy-reset\"\n data-pair={pair.id}\n data-off={pair.enabled === false ? \"\" : undefined}\n >\n {toggleable && (\n <Checkbox\n label={<span className=\"cy-visually-hidden\">{text.enable(name)}</span>}\n checked={pair.enabled !== false}\n disabled={disabled}\n size={size}\n onChange={(on) => update(pair.id, { enabled: on })}\n />\n )}\n <TextField\n label={`${text.key} (${name})`}\n labelHidden\n placeholder={text.key}\n value={pair.key}\n disabled={disabled}\n size={size}\n onChange={(key) => update(pair.id, { key })}\n />\n {pair.file ? (\n <TextField\n label={`${text.value} (${name})`}\n labelHidden\n readOnly\n iconStart={paperclip}\n value={pair.file.name}\n disabled={disabled}\n size={size}\n />\n ) : (\n <TextField\n label={`${text.value} (${name})`}\n labelHidden\n placeholder={text.value}\n type={pair.secret ? \"password\" : \"text\"}\n value={pair.value}\n disabled={disabled}\n size={size}\n onChange={(value) => update(pair.id, { value })}\n />\n )}\n {allowFiles &&\n (pair.file ? (\n <IconButton\n icon={close}\n label={text.detach(name)}\n variant=\"ghost\"\n size={size}\n disabled={disabled}\n onClick={() => update(pair.id, { file: undefined, value: \"\" })}\n />\n ) : (\n <IconButton\n icon={paperclip}\n label={text.attach(name)}\n variant=\"ghost\"\n size={size}\n disabled={disabled}\n onClick={() => {\n picking.current = pair.id;\n picker.current?.click();\n }}\n />\n ))}\n <IconButton\n icon={trash}\n label={text.remove(name)}\n variant=\"ghost\"\n size={size}\n disabled={disabled}\n onClick={() => remove(pair.id)}\n />\n </div>\n ),\n };\n });\n\n return (\n <div\n ref={root}\n className={className ? `cy-key-value-editor ${className}` : \"cy-key-value-editor\"}\n data-size={size}\n style={style}\n >\n {bulk === null ? (\n rows.length > 0 && (\n <SortableList\n label={label}\n items={items}\n onReorder={(next) =>\n setRows(next.map((item) => rows.find((r) => r.id === item.id) as KeyValuePair))\n }\n disabled={disabled}\n size={size}\n />\n )\n ) : (\n <TextArea\n label={text.bulkField(label)}\n labelHidden\n value={bulk}\n rows={Math.max(4, rows.length + 1)}\n disabled={disabled}\n onChange={(next) => {\n setBulk(next);\n setRows(fromBulkText(next, rows, secretKeys.current));\n }}\n />\n )}\n {allowFiles && (\n <FileInputBase\n ref={picker}\n className=\"cy-key-value-editor-picker\"\n tabIndex={-1}\n aria-hidden=\"true\"\n accept={accept}\n onFiles={([file]) => {\n const id = picking.current;\n picking.current = null;\n if (id && file) update(id, { file, value: file.name, secret: false });\n if (picker.current) picker.current.value = \"\";\n }}\n />\n )}\n <div className=\"cy-key-value-editor-actions cy-reset\">\n {bulk === null && (\n <Button\n icon={plus}\n variant=\"ghost\"\n size={size}\n disabled={disabled}\n className=\"cy-key-value-editor-add\"\n onClick={add}\n >\n {text.add}\n </Button>\n )}\n {bulkEdit && (\n <Button\n variant=\"ghost\"\n size={size}\n pressed={bulk !== null}\n disabled={disabled}\n onClick={() => {\n secretKeys.current = new Set(rows.filter((r) => r.secret).map((r) => r.key));\n setBulk(bulk === null ? toBulkText(rows) : null);\n }}\n >\n {text.bulk}\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA2EA,IAAMqB,IAAuC;AAAA,EAC3C,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAA,CAAMC,MAAM,OAAOA,CAAA;AAAA,EACnB,KAAK;AAAA,EACL,QAAA,CAASC,MAAS,UAAUA,CAAA;AAAA,EAC5B,QAAA,CAASA,MAAS,OAAOA,CAAA;AAAA,EACzB,QAAA,CAASA,MAAS,oBAAoBA,CAAA;AAAA,EACtC,QAAA,CAASA,MAAS,wBAAwBA,CAAA;AAAA,EAC1C,MAAM;AAAA,EACN,WAAA,CAAYC,MAAU,GAAGA,CAAA;AAC3B;AAOA,SAAgBC,GAAe,EAC7B,OAAAD,GACA,OAAAE,GACA,cAAAC,IAAe,CAAC,GAChB,UAAAC,GACA,YAAAC,IAAa,IACb,UAAAC,IAAW,IACX,YAAAC,IAAa,IACb,QAAAC,GACA,UAAAC,IAAW,IACX,MAAAC,IAAO,MACP,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACsB;AACtB,QAAMC,IAAO;AAAA,IAAE,GAAGjB;AAAA,IAAgB,GAAGc;AAAA,EAAO,GACtC,CAACI,GA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ACR,UAAAR;AAAA,UACV,SAAA,MAAe;AACb,YAAAU,EAAW,UAAU,IAAI,IAAIJ,EAAK,OAAA,CAAQY,MAAMA,EAAE,MAAM,EAAE,IAAA,CAAKA,MAAMA,EAAE,GAAG,CAAC,GAC3ET,EAAQD,MAAS,OAAOzB,EAAWuB,CAAI,IAAI,IAAI;AAAA,UACjD;AAAA,UAEC,UAAAD,EAAK;AAAA,QACA,CAAA,CAEP;AAAA,M;A,IACF;AAAA,E;AAET"}
1
+ {"version":3,"file":"KeyValueEditor.js","names":["useControllableState","useClientLayoutEffect","Button","IconButton","close","Checkbox","plus","trash","SortableList","TextField","FileInputBase","paperclip","TextArea","fromBulkText","newPairId","pairName","toBulkText","useRef","useState","jsx","jsxs","DEFAULT_LABELS","n","name","label","KeyValueEditor","pairs","defaultPairs","onChange","toggleable","bulkEdit","allowFiles","accept","disabled","size","labels","className","style","text","rows","setRows","bulk","setBulk","secretKeys","root","focusNext","picking","picker","id","update","patch","r","add","pair","remove","at","rest","items","i","on","key","value","next","item","file"],"sources":["../../../src/components/KeyValueEditor/KeyValueEditor.tsx"],"sourcesContent":["import { type CSSProperties, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { FileInputBase } from \"../../foundations/FileInputBase/FileInputBase.js\";\nimport { close } from \"../../icons/close.js\";\nimport { paperclip } from \"../../icons/paperclip.js\";\nimport { plus } from \"../../icons/plus.js\";\nimport { trash } from \"../../icons/trash.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { Button } from \"../Button/Button.js\";\nimport { Checkbox } from \"../Checkbox/Checkbox.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { SortableList } from \"../SortableList/SortableList.js\";\nimport { TextArea } from \"../TextArea/TextArea.js\";\nimport { TextField } from \"../TextField/TextField.js\";\nimport { fromBulkText, type KeyValuePair, newPairId, pairName, toBulkText } from \"./bulk.js\";\n\nexport type { KeyValuePair };\n\nexport interface KeyValueEditorTokens {\n /** Space between the fields of a row. */\n gap: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n keyValueEditor: KeyValueEditorTokens;\n }\n}\n\nexport interface KeyValueEditorLabels {\n /** Key field. Default \"Key\". */\n key: string;\n /** Value field. Default \"Value\". */\n value: string;\n /** How an unnamed row is called. Default \"Row 3\". */\n row: (position: number) => string;\n /** Add button. Default \"Add\". */\n add: string;\n /** Remove button. Default \"Remove Authorization\". */\n remove: (name: string) => string;\n /** On/off checkbox. Default \"Use Authorization\". */\n enable: (name: string) => string;\n /** With `allowFiles`: the button that picks a file for a row. Default \"Attach a file to avatar\". */\n attach: (name: string) => string;\n /** With `allowFiles`: the button that takes a row's file away. Default \"Remove the file from avatar\". */\n detach: (name: string) => string;\n /** Toggle to the text view. Default \"Edit as text\". */\n bulk: string;\n /** The text view's field. Default \"Headers as text: one key: value per line, # turns a line off\". */\n bulkField: (label: string) => string;\n}\n\nexport interface KeyValueEditorProps {\n /** What the pairs are (\"Headers\", \"Query parameters\"). Names the list and the text view. */\n label: string;\n /** The pairs, when you control them. */\n pairs?: KeyValuePair[] | undefined;\n /** Starting pairs when uncontrolled. */\n defaultPairs?: KeyValuePair[];\n /** Called with the full list after each change: an edit, a row added, removed, moved or switched off. */\n onChange?: ((pairs: KeyValuePair[]) => void) | undefined;\n /** A checkbox per row to switch it off without deleting it. Default true. */\n toggleable?: boolean;\n /** A toggle to edit every pair as `key: value` lines (paste a block of headers). Default true. */\n bulkEdit?: boolean;\n /** A button per row to make its value a file instead of text (multipart form fields). `accept` limits the types. */\n allowFiles?: boolean;\n /** File types for `allowFiles`, as for `<input accept>`. */\n accept?: string | undefined;\n /** Turns off every field and button. */\n disabled?: boolean;\n /** Size of the fields and buttons. Default \"md\". */\n size?: Size;\n /** Replace the built-in English text. */\n labels?: Partial<KeyValueEditorLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-key-value-editor-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: KeyValueEditorLabels = {\n key: \"Key\",\n value: \"Value\",\n row: (n) => `Row ${n}`,\n add: \"Add\",\n remove: (name) => `Remove ${name}`,\n enable: (name) => `Use ${name}`,\n attach: (name) => `Attach a file to ${name}`,\n detach: (name) => `Remove the file from ${name}`,\n bulk: \"Edit as text\",\n bulkField: (label) => `${label} as text: one key: value per line, # turns a line off`,\n};\n\n/**\n * Editable key and value pairs: HTTP headers, query parameters, environment variables, metadata. Rows reorder like a\n * SortableList (grip, or Space and arrows on it), switch off without being deleted, and can be edited all at once as\n * `key: value` text. Secret values (`secret: true`) are masked.\n */\nexport function KeyValueEditor({\n label,\n pairs,\n defaultPairs = [],\n onChange,\n toggleable = true,\n bulkEdit = true,\n allowFiles = false,\n accept,\n disabled = false,\n size = \"md\",\n labels,\n className,\n style,\n}: KeyValueEditorProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [rows, setRows] = useControllableState(pairs, defaultPairs, onChange);\n const [bulk, setBulk] = useState<string | null>(null);\n /** Keys that were secret when the text view opened: they stay masked however the text is retyped. */\n const secretKeys = useRef(new Set<string>());\n const root = useRef<HTMLDivElement>(null);\n /** Where focus goes after the rows change: a row's key field, or the Add button. */\n const focusNext = useRef<string | null>(null);\n /** The row a file is being picked for. One hidden file input serves every row. */\n const picking = useRef<string | null>(null);\n const picker = useRef<HTMLInputElement>(null);\n\n useClientLayoutEffect(() => {\n const id = focusNext.current;\n if (id === null) return;\n focusNext.current = null;\n const target = id\n ? root.current?.querySelector<HTMLElement>(`[data-pair=\"${CSS.escape(id)}\"] .cy-text-field-input`)\n : root.current?.querySelector<HTMLElement>(\".cy-key-value-editor-add\");\n target?.focus();\n });\n\n const update = (id: string, patch: Partial<KeyValuePair>) =>\n setRows(rows.map((r) => (r.id === id ? { ...r, ...patch } : r)));\n const add = () => {\n const pair = { id: newPairId(), key: \"\", value: \"\" };\n focusNext.current = pair.id;\n setRows([...rows, pair]);\n };\n const remove = (id: string) => {\n const at = rows.findIndex((r) => r.id === id);\n const rest = rows.filter((r) => r.id !== id);\n // Focus the row that took its place (or the one before it), else Add.\n focusNext.current = (rest[at] ?? rest[at - 1])?.id ?? \"\";\n setRows(rest);\n };\n\n const items = rows.map((pair, i) => {\n const name = pairName(pair, i, text.row);\n return {\n id: pair.id,\n label: name,\n content: (\n <div\n className=\"cy-key-value-editor-row cy-reset\"\n data-pair={pair.id}\n data-off={pair.enabled === false ? \"\" : undefined}\n >\n {toggleable && (\n <Checkbox\n label={<span className=\"cy-visually-hidden\">{text.enable(name)}</span>}\n checked={pair.enabled !== false}\n disabled={disabled}\n size={size}\n onChange={(on) => update(pair.id, { enabled: on })}\n />\n )}\n <TextField\n label={`${text.key} (${name})`}\n labelHidden\n placeholder={text.key}\n value={pair.key}\n disabled={disabled}\n size={size}\n onChange={(key) => update(pair.id, { key })}\n />\n {pair.file ? (\n <TextField\n label={`${text.value} (${name})`}\n labelHidden\n readOnly\n iconStart={paperclip}\n value={pair.file.name}\n disabled={disabled}\n size={size}\n />\n ) : (\n <TextField\n label={`${text.value} (${name})`}\n labelHidden\n placeholder={text.value}\n type={pair.secret ? \"password\" : \"text\"}\n value={pair.value}\n disabled={disabled}\n size={size}\n onChange={(value) => update(pair.id, { value })}\n />\n )}\n {allowFiles &&\n (pair.file ? (\n <IconButton\n icon={close}\n label={text.detach(name)}\n variant=\"ghost\"\n size={size}\n disabled={disabled}\n onClick={() => update(pair.id, { file: undefined, value: \"\" })}\n />\n ) : (\n <IconButton\n icon={paperclip}\n label={text.attach(name)}\n variant=\"ghost\"\n size={size}\n disabled={disabled}\n onClick={() => {\n picking.current = pair.id;\n picker.current?.click();\n }}\n />\n ))}\n <IconButton\n icon={trash}\n label={text.remove(name)}\n variant=\"ghost\"\n size={size}\n disabled={disabled}\n onClick={() => remove(pair.id)}\n />\n </div>\n ),\n };\n });\n\n return (\n <div\n ref={root}\n className={className ? `cy-key-value-editor ${className}` : \"cy-key-value-editor\"}\n data-size={size}\n style={style}\n >\n {bulk === null ? (\n rows.length > 0 && (\n <SortableList\n label={label}\n items={items}\n onReorder={(next) =>\n setRows(next.map((item) => rows.find((r) => r.id === item.id) as KeyValuePair))\n }\n disabled={disabled}\n size={size}\n />\n )\n ) : (\n <TextArea\n label={text.bulkField(label)}\n labelHidden\n value={bulk}\n rows={Math.max(4, rows.length + 1)}\n disabled={disabled}\n onChange={(next) => {\n setBulk(next);\n setRows(fromBulkText(next, rows, secretKeys.current));\n }}\n />\n )}\n {allowFiles && (\n <FileInputBase\n ref={picker}\n className=\"cy-key-value-editor-picker\"\n tabIndex={-1}\n aria-hidden=\"true\"\n accept={accept}\n onFiles={([file]) => {\n const id = picking.current;\n picking.current = null;\n if (id && file) update(id, { file, value: file.name, secret: false });\n if (picker.current) picker.current.value = \"\";\n }}\n />\n )}\n <div className=\"cy-key-value-editor-actions cy-reset\">\n {bulk === null && (\n <Button\n icon={plus}\n variant=\"ghost\"\n size={size}\n disabled={disabled}\n className=\"cy-key-value-editor-add\"\n onClick={add}\n >\n {text.add}\n </Button>\n )}\n {bulkEdit && (\n <Button\n variant=\"ghost\"\n size={size}\n pressed={bulk !== null}\n disabled={disabled}\n onClick={() => {\n secretKeys.current = new Set(rows.filter((r) => r.secret).map((r) => r.key));\n setBulk(bulk === null ? toBulkText(rows) : null);\n }}\n >\n {text.bulk}\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkFA,IAAMqB,IAAuC;AAAA,EAC3C,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAA,CAAMC,MAAM,OAAOA,CAAA;AAAA,EACnB,KAAK;AAAA,EACL,QAAA,CAASC,MAAS,UAAUA,CAAA;AAAA,EAC5B,QAAA,CAASA,MAAS,OAAOA,CAAA;AAAA,EACzB,QAAA,CAASA,MAAS,oBAAoBA,CAAA;AAAA,EACtC,QAAA,CAASA,MAAS,wBAAwBA,CAAA;AAAA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AAA,QAC7C;AAAA,MACD,CAAA;AAAA,MAEH,gBAAA3B,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAAf,UAAA,CACGqB,MAAS,QACR,gBAAAtB,EAACjB,GAAD;AAAA,UACE,MAAMI;AAAA,UACN,SAAQ;AAAA,UACF,MAAA4B;AAAA,UACI,UAAAD;AAAA,UACV,WAAU;AAAA,UACV,SAASmB;AAAA,UAER,UAAAd,EAAK;AAAA,QACA,CAAA,GAETR,KACC,gBAAAX,EAACjB,GAAD;AAAA,UACE,SAAQ;AAAA,UACF,MAAAgC;AAAA,UACN,SAASO,MAAS;AAAA,UACR,UAAAR;AAAA,UACV,SAAA,MAAe;AACb,YAAAU,EAAW,UAAU,IAAI,IAAIJ,EAAK,OAAA,CAAQY,MAAMA,EAAE,MAAM,EAAE,IAAA,CAAKA,MAAMA,EAAE,GAAG,CAAC,GAC3ET,EAAQD,MAAS,OAAOzB,EAAWuB,CAAI,IAAI,IAAI;AAAA,UACjD;AAAA,UAEC,UAAAD,EAAK;AAAA,QACA,CAAA,CAEP;AAAA,M;A,IACF;AAAA,E;AAET"}
@@ -10,16 +10,23 @@ declare module "../../tokens/schema.js" {
10
10
  }
11
11
  }
12
12
  export interface LinkProps {
13
+ /** Where the link goes. */
13
14
  href: string;
15
+ /** The link text. */
14
16
  children: ReactNode;
17
+ /** Colour of the text. Default "accent". */
15
18
  tone?: Tone;
19
+ /** Text size; `inherit` follows the surrounding text. Default "inherit". */
16
20
  size?: Size | "inherit";
17
21
  /** Opens in a new tab with a safe rel, an external icon and announced text. */
18
22
  external?: boolean;
23
+ /** Called when the link is activated. */
19
24
  onClick?: MouseEventHandler<HTMLAnchorElement>;
25
+ /** Replace the built-in English text: `external` is read out after a link that opens in a new tab. */
20
26
  labels?: {
21
27
  external?: string;
22
28
  };
29
+ /** Added to the root element, for layout. */
23
30
  className?: string;
24
31
  /** Layout only. */
25
32
  style?: CSSProperties;