@arshad-shah/cynosure 0.3.0 → 0.4.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 (290) hide show
  1. package/README.md +3 -3
  2. package/dist/adapters/astro/index.d.ts +52 -0
  3. package/dist/adapters/astro/index.js +27 -0
  4. package/dist/adapters/astro/index.js.map +1 -0
  5. package/dist/adapters/vite/index.d.ts +11 -0
  6. package/dist/adapters/vite/index.js +33 -12
  7. package/dist/adapters/vite/index.js.map +1 -1
  8. package/dist/brands/googleplay.d.ts +2 -0
  9. package/dist/brands/googleplay.js +17 -0
  10. package/dist/brands/googleplay.js.map +1 -0
  11. package/dist/brands/index.d.ts +1 -0
  12. package/dist/brands/index.js +132 -130
  13. package/dist/components/Announcer/Announcer.js +5 -5
  14. package/dist/components/Announcer/Announcer.js.map +1 -1
  15. package/dist/components/AppShell/AppShell.js +50 -53
  16. package/dist/components/AppShell/AppShell.js.map +1 -1
  17. package/dist/components/Avatar/Avatar.js +20 -20
  18. package/dist/components/Avatar/Avatar.js.map +1 -1
  19. package/dist/components/Button/Button.d.ts +17 -3
  20. package/dist/components/Button/Button.js +51 -44
  21. package/dist/components/Button/Button.js.map +1 -1
  22. package/dist/components/Calendar/Calendar.js +69 -69
  23. package/dist/components/Calendar/Calendar.js.map +1 -1
  24. package/dist/components/Card/Card.d.ts +8 -1
  25. package/dist/components/Card/Card.js.map +1 -1
  26. package/dist/components/Checkbox/Checkbox.d.ts +4 -4
  27. package/dist/components/Checkbox/Checkbox.js +33 -8
  28. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  29. package/dist/components/Checklist/Checklist.js +21 -21
  30. package/dist/components/Checklist/Checklist.js.map +1 -1
  31. package/dist/components/Choice/Choice.d.ts +73 -0
  32. package/dist/components/Choice/Choice.js +41 -0
  33. package/dist/components/Choice/Choice.js.map +1 -0
  34. package/dist/components/Choice/index.d.ts +1 -0
  35. package/dist/components/ColorField/ColorField.js +198 -207
  36. package/dist/components/ColorField/ColorField.js.map +1 -1
  37. package/dist/components/Combobox/Combobox.js +86 -115
  38. package/dist/components/Combobox/Combobox.js.map +1 -1
  39. package/dist/components/Container/Container.d.ts +2 -2
  40. package/dist/components/Container/Container.js +17 -13
  41. package/dist/components/Container/Container.js.map +1 -1
  42. package/dist/components/CopyButton/CopyButton.js +29 -28
  43. package/dist/components/CopyButton/CopyButton.js.map +1 -1
  44. package/dist/components/DeviceFrame/DeviceFrame.d.ts +63 -0
  45. package/dist/components/DeviceFrame/DeviceFrame.js +54 -0
  46. package/dist/components/DeviceFrame/DeviceFrame.js.map +1 -0
  47. package/dist/components/DeviceFrame/index.d.ts +1 -0
  48. package/dist/components/Dialog/Dialog.d.ts +10 -1
  49. package/dist/components/Dialog/Dialog.js +82 -77
  50. package/dist/components/Dialog/Dialog.js.map +1 -1
  51. package/dist/components/EmptyState/EmptyState.d.ts +5 -2
  52. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  53. package/dist/components/Field/Field.js +31 -33
  54. package/dist/components/Field/Field.js.map +1 -1
  55. package/dist/components/FileDrop/FileDrop.js +14 -14
  56. package/dist/components/FileDrop/FileDrop.js.map +1 -1
  57. package/dist/components/FloatingToolbar/FloatingToolbar.js +7 -6
  58. package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
  59. package/dist/components/Grid/Grid.d.ts +32 -11
  60. package/dist/components/Grid/Grid.js +68 -46
  61. package/dist/components/Grid/Grid.js.map +1 -1
  62. package/dist/components/Grid/index.d.ts +1 -1
  63. package/dist/components/Heading/Heading.d.ts +4 -2
  64. package/dist/components/Heading/Heading.js.map +1 -1
  65. package/dist/components/IconButton/IconButton.d.ts +16 -1
  66. package/dist/components/IconButton/IconButton.js +14 -10
  67. package/dist/components/IconButton/IconButton.js.map +1 -1
  68. package/dist/components/IconTile/IconTile.d.ts +45 -0
  69. package/dist/components/IconTile/IconTile.js +25 -0
  70. package/dist/components/IconTile/IconTile.js.map +1 -0
  71. package/dist/components/IconTile/index.d.ts +1 -0
  72. package/dist/components/Image/Image.js.map +1 -1
  73. package/dist/components/Inline/Inline.d.ts +3 -3
  74. package/dist/components/Inline/Inline.js +12 -22
  75. package/dist/components/Inline/Inline.js.map +1 -1
  76. package/dist/components/KeyValueEditor/KeyValueEditor.js +37 -36
  77. package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
  78. package/dist/components/Link/Link.d.ts +9 -1
  79. package/dist/components/Link/Link.js +20 -18
  80. package/dist/components/Link/Link.js.map +1 -1
  81. package/dist/components/List/List.d.ts +73 -0
  82. package/dist/components/List/List.js +64 -0
  83. package/dist/components/List/List.js.map +1 -0
  84. package/dist/components/List/index.d.ts +1 -0
  85. package/dist/components/Notice/Notice.js +12 -11
  86. package/dist/components/Notice/Notice.js.map +1 -1
  87. package/dist/components/OptionList/OptionList.d.ts +69 -0
  88. package/dist/components/OptionList/OptionList.js +75 -0
  89. package/dist/components/OptionList/OptionList.js.map +1 -0
  90. package/dist/components/OptionList/index.d.ts +1 -0
  91. package/dist/components/PageHeader/PageHeader.d.ts +6 -0
  92. package/dist/components/PageHeader/PageHeader.js +27 -27
  93. package/dist/components/PageHeader/PageHeader.js.map +1 -1
  94. package/dist/components/Pagination/Pagination.js +31 -30
  95. package/dist/components/Pagination/Pagination.js.map +1 -1
  96. package/dist/components/QRCode/QRCode.d.ts +56 -0
  97. package/dist/components/QRCode/QRCode.js +48 -0
  98. package/dist/components/QRCode/QRCode.js.map +1 -0
  99. package/dist/components/QRCode/index.d.ts +1 -0
  100. package/dist/components/RadioGroup/RadioGroup.js +32 -24
  101. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  102. package/dist/components/Section/Section.d.ts +57 -0
  103. package/dist/components/Section/Section.js +27 -0
  104. package/dist/components/Section/Section.js.map +1 -0
  105. package/dist/components/Section/index.d.ts +1 -0
  106. package/dist/components/SegmentedControl/SegmentedControl.js +12 -12
  107. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  108. package/dist/components/Select/Select.js +106 -133
  109. package/dist/components/Select/Select.js.map +1 -1
  110. package/dist/components/Sheet/Sheet.js +12 -7
  111. package/dist/components/Sheet/Sheet.js.map +1 -1
  112. package/dist/components/SideNav/SideNav.js +55 -53
  113. package/dist/components/SideNav/SideNav.js.map +1 -1
  114. package/dist/components/SiteFooter/SiteFooter.d.ts +66 -0
  115. package/dist/components/SiteFooter/SiteFooter.js +80 -0
  116. package/dist/components/SiteFooter/SiteFooter.js.map +1 -0
  117. package/dist/components/SiteFooter/index.d.ts +1 -0
  118. package/dist/components/SiteHeader/SiteHeader.d.ts +78 -0
  119. package/dist/components/SiteHeader/SiteHeader.js +114 -0
  120. package/dist/components/SiteHeader/SiteHeader.js.map +1 -0
  121. package/dist/components/SiteHeader/index.d.ts +1 -0
  122. package/dist/components/SkipLink/SkipLink.d.ts +42 -0
  123. package/dist/components/SkipLink/SkipLink.js +43 -0
  124. package/dist/components/SkipLink/SkipLink.js.map +1 -0
  125. package/dist/components/SkipLink/index.d.ts +1 -0
  126. package/dist/components/SortableList/SortableList.js +13 -13
  127. package/dist/components/SortableList/SortableList.js.map +1 -1
  128. package/dist/components/Stack/Stack.d.ts +16 -7
  129. package/dist/components/Stack/Stack.js +25 -18
  130. package/dist/components/Stack/Stack.js.map +1 -1
  131. package/dist/components/Stack/index.d.ts +1 -1
  132. package/dist/components/Stack/space.d.ts +29 -0
  133. package/dist/components/Stack/space.js +16 -5
  134. package/dist/components/Stack/space.js.map +1 -1
  135. package/dist/components/Stat/Stat.d.ts +88 -0
  136. package/dist/components/Stat/Stat.js +105 -0
  137. package/dist/components/Stat/Stat.js.map +1 -0
  138. package/dist/components/Stat/index.d.ts +1 -0
  139. package/dist/components/Steps/Steps.d.ts +10 -4
  140. package/dist/components/Steps/Steps.js +31 -30
  141. package/dist/components/Steps/Steps.js.map +1 -1
  142. package/dist/components/Switch/Switch.d.ts +4 -4
  143. package/dist/components/Switch/Switch.js +18 -7
  144. package/dist/components/Switch/Switch.js.map +1 -1
  145. package/dist/components/Table/Table.js +11 -12
  146. package/dist/components/Table/Table.js.map +1 -1
  147. package/dist/components/Tabs/Tabs.d.ts +4 -1
  148. package/dist/components/Tabs/Tabs.js +71 -70
  149. package/dist/components/Tabs/Tabs.js.map +1 -1
  150. package/dist/components/TagInput/TagInput.js +76 -97
  151. package/dist/components/TagInput/TagInput.js.map +1 -1
  152. package/dist/components/TextField/TextField.d.ts +4 -0
  153. package/dist/components/TextField/TextField.js +30 -29
  154. package/dist/components/TextField/TextField.js.map +1 -1
  155. package/dist/components/ThemeToggle/ThemeToggle.d.ts +7 -1
  156. package/dist/components/ThemeToggle/ThemeToggle.js +33 -30
  157. package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
  158. package/dist/components/Toast/Toast.js +22 -20
  159. package/dist/components/Toast/Toast.js.map +1 -1
  160. package/dist/components/Tooltip/Tooltip.d.ts +6 -1
  161. package/dist/components/Tooltip/Tooltip.js +19 -19
  162. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  163. package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
  164. package/dist/components/VisuallyHidden/VisuallyHidden.js +17 -0
  165. package/dist/components/VisuallyHidden/VisuallyHidden.js.map +1 -0
  166. package/dist/components/VisuallyHidden/index.d.ts +1 -0
  167. package/dist/foundations/ChoiceBase/ChoiceBase.js +8 -8
  168. package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
  169. package/dist/foundations/HiddenValue/HiddenValue.js +5 -5
  170. package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
  171. package/dist/foundations/Icon/Icon.d.ts +6 -1
  172. package/dist/foundations/Icon/Icon.js +15 -14
  173. package/dist/foundations/Icon/Icon.js.map +1 -1
  174. package/dist/foundations/image-outcome.d.ts +8 -3
  175. package/dist/foundations/image-outcome.js +12 -8
  176. package/dist/foundations/image-outcome.js.map +1 -1
  177. package/dist/foundations/printing.d.ts +6 -0
  178. package/dist/foundations/printing.js +17 -0
  179. package/dist/foundations/printing.js.map +1 -0
  180. package/dist/foundations/qr.d.ts +42 -0
  181. package/dist/foundations/qr.js +246 -0
  182. package/dist/foundations/qr.js.map +1 -0
  183. package/dist/icons/book-marked.d.ts +2 -0
  184. package/dist/icons/book-marked.js +14 -0
  185. package/dist/icons/book-marked.js.map +1 -0
  186. package/dist/icons/calendar-days.d.ts +2 -0
  187. package/dist/icons/calendar-days.js +24 -0
  188. package/dist/icons/calendar-days.js.map +1 -0
  189. package/dist/icons/check-square.d.ts +2 -0
  190. package/dist/icons/check-square.js +14 -0
  191. package/dist/icons/check-square.js.map +1 -0
  192. package/dist/icons/crescent.d.ts +2 -0
  193. package/dist/icons/crescent.js +14 -0
  194. package/dist/icons/crescent.js.map +1 -0
  195. package/dist/icons/index.d.ts +10 -0
  196. package/dist/icons/index.js +436 -416
  197. package/dist/icons/kaaba.d.ts +2 -0
  198. package/dist/icons/kaaba.js +14 -0
  199. package/dist/icons/kaaba.js.map +1 -0
  200. package/dist/icons/keywords.d.ts +11 -1
  201. package/dist/icons/keywords.js +89 -1
  202. package/dist/icons/keywords.js.map +1 -1
  203. package/dist/icons/list-tree.d.ts +2 -0
  204. package/dist/icons/list-tree.js +14 -0
  205. package/dist/icons/list-tree.js.map +1 -0
  206. package/dist/icons/mosque.d.ts +2 -0
  207. package/dist/icons/mosque.js +14 -0
  208. package/dist/icons/mosque.js.map +1 -0
  209. package/dist/icons/prayer-beads.d.ts +2 -0
  210. package/dist/icons/prayer-beads.js +67 -0
  211. package/dist/icons/prayer-beads.js.map +1 -0
  212. package/dist/icons/qr-code.d.ts +2 -0
  213. package/dist/icons/qr-code.js +38 -0
  214. package/dist/icons/qr-code.js.map +1 -0
  215. package/dist/icons/refresh-cw.d.ts +2 -0
  216. package/dist/icons/refresh-cw.js +14 -0
  217. package/dist/icons/refresh-cw.js.map +1 -0
  218. package/dist/icons/types.d.ts +1 -1
  219. package/dist/icons/types.js +2 -1
  220. package/dist/icons/types.js.map +1 -1
  221. package/dist/index.d.ts +16 -2
  222. package/dist/index.js +274 -241
  223. package/dist/styles/announcer.css +1 -1
  224. package/dist/styles/app-shell.css +1 -1
  225. package/dist/styles/avatar.css +1 -1
  226. package/dist/styles/base.css +1 -1
  227. package/dist/styles/button.css +1 -1
  228. package/dist/styles/calendar.css +1 -1
  229. package/dist/styles/card.css +1 -1
  230. package/dist/styles/checkbox.css +1 -1
  231. package/dist/styles/choice-base.css +1 -0
  232. package/dist/styles/choice.css +1 -1
  233. package/dist/styles/color-field.css +1 -1
  234. package/dist/styles/combobox.css +1 -1
  235. package/dist/styles/copy-button.css +1 -1
  236. package/dist/styles/date-field.css +1 -1
  237. package/dist/styles/device-frame.css +1 -0
  238. package/dist/styles/dialog.css +1 -1
  239. package/dist/styles/disclosure.css +1 -1
  240. package/dist/styles/field.css +1 -1
  241. package/dist/styles/file-drop.css +1 -1
  242. package/dist/styles/floating-toolbar.css +1 -1
  243. package/dist/styles/generated-css.d.ts +1 -1
  244. package/dist/styles/generated-css.js +1 -1
  245. package/dist/styles/generated-css.js.map +1 -1
  246. package/dist/styles/grid.css +1 -1
  247. package/dist/styles/heading.css +1 -1
  248. package/dist/styles/icon-tile.css +1 -0
  249. package/dist/styles/icon.css +1 -1
  250. package/dist/styles/inline.css +1 -0
  251. package/dist/styles/key-value-editor.css +1 -1
  252. package/dist/styles/link.css +1 -1
  253. package/dist/styles/list.css +1 -0
  254. package/dist/styles/manifest.json +715 -0
  255. package/dist/styles/notice.css +1 -1
  256. package/dist/styles/number-field.css +1 -1
  257. package/dist/styles/option-list.css +1 -0
  258. package/dist/styles/pagination.css +1 -1
  259. package/dist/styles/qr-code.css +1 -0
  260. package/dist/styles/radio-group.css +1 -1
  261. package/dist/styles/section.css +1 -0
  262. package/dist/styles/segmented-control.css +1 -1
  263. package/dist/styles/select.css +1 -1
  264. package/dist/styles/sheet.css +1 -1
  265. package/dist/styles/side-nav.css +1 -1
  266. package/dist/styles/site-footer.css +1 -0
  267. package/dist/styles/site-header.css +1 -0
  268. package/dist/styles/skip-link.css +1 -0
  269. package/dist/styles/sortable-list.css +1 -1
  270. package/dist/styles/stack.css +1 -1
  271. package/dist/styles/stat.css +1 -0
  272. package/dist/styles/steps.css +1 -1
  273. package/dist/styles/switch.css +1 -0
  274. package/dist/styles/table.css +1 -1
  275. package/dist/styles/tabs.css +1 -1
  276. package/dist/styles/tag-input.css +1 -1
  277. package/dist/styles/text-field.css +1 -1
  278. package/dist/styles/time-field.css +1 -1
  279. package/dist/styles/toast.css +1 -1
  280. package/dist/styles/visually-hidden.css +1 -0
  281. package/dist/styles.css +1 -1
  282. package/dist/tokens/create-theme.js +137 -108
  283. package/dist/tokens/create-theme.js.map +1 -1
  284. package/package.json +6 -1
  285. package/dist/components/Checkbox/ChoiceRow.d.ts +0 -39
  286. package/dist/components/Checkbox/ChoiceRow.js +0 -58
  287. package/dist/components/Checkbox/ChoiceRow.js.map +0 -1
  288. package/dist/styles/hidden-value.css +0 -1
  289. package/dist/styles/iconbutton.css +0 -1
  290. package/dist/styles/search-field.css +0 -1
@@ -0,0 +1,63 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ export interface DeviceFrameTokens {
3
+ /**
4
+ * Colour of a phone's or tablet's bezel. Default: the ink on a light page; on a dark page a dark grey lifted off the
5
+ * page, so the device stays dark but does not disappear.
6
+ */
7
+ bezel: string;
8
+ /** Rim around the frame: the line colour on a light page, a lighter rim (3:1 against the page) on a dark one. */
9
+ edge: string;
10
+ /** Shadow under the frame. */
11
+ shadow: string;
12
+ /** Fill of the screen behind the content. */
13
+ screen: string;
14
+ /** Width of a portrait phone; a landscape phone is as tall as this. */
15
+ phoneWidth: string;
16
+ /** Width of a portrait tablet; a landscape tablet is as tall as this. */
17
+ tabletWidth: string;
18
+ /** Corner radius of the browser window. */
19
+ browserRadius: string;
20
+ /** Fill of the browser's top bar. */
21
+ browserBar: string;
22
+ /** Colour of the three window dots in the browser bar. */
23
+ dot: string;
24
+ }
25
+ declare module "../../tokens/schema.js" {
26
+ interface ComponentTokens {
27
+ deviceFrame: DeviceFrameTokens;
28
+ }
29
+ }
30
+ /** The device drawn around the content. */
31
+ export type DeviceFrameDevice = "phone" | "tablet" | "browser";
32
+ export interface DeviceFrameProps {
33
+ /** The device drawn around the content. Default "phone". */
34
+ device?: DeviceFrameDevice;
35
+ /** Which way a phone or tablet is held. The browser ignores it. Default "portrait". */
36
+ orientation?: "portrait" | "landscape";
37
+ /**
38
+ * Width divided by height of the screen, as drawn in portrait (phone and tablet) or as is (browser). Landscape uses
39
+ * its inverse. Default: 9 / 19.5 for a phone, 3 / 4 for a tablet, 16 / 10 for a browser.
40
+ */
41
+ ratio?: number;
42
+ /** Address shown in the browser bar (decoration: it is not a link and is not announced). Browser only. */
43
+ url?: string;
44
+ /**
45
+ * Accessible name. With it the frame is a `figure` with this name; without it the frame is decoration and adds
46
+ * nothing to the accessibility tree, so the content keeps its own semantics.
47
+ */
48
+ label?: string;
49
+ /**
50
+ * Phone only: keep the content clear of the camera island (below it upright, beside it turned), as an app keeps
51
+ * clear of a real phone's. By default live content is kept clear and a screenshot, video or canvas fills the whole
52
+ * screen (it has its own status bar); `true` or `false` decides for any content.
53
+ */
54
+ safeArea?: boolean | undefined;
55
+ /** What the screen shows: a screenshot, a video or a live demo. Each child is stretched to the screen and clipped. */
56
+ children?: ReactNode;
57
+ /** Added to the root element, for layout. */
58
+ className?: string;
59
+ /** Layout only (width, margin, placement). The height follows from the width. Restyle through tokens. */
60
+ style?: CSSProperties;
61
+ }
62
+ /** A phone, tablet or browser window drawn around a screenshot or a live demo, at any width. */
63
+ export declare const DeviceFrame: import("react").ForwardRefExoticComponent<DeviceFrameProps & import("react").RefAttributes<HTMLElement>>;
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ import { AspectRatio as f } from "../AspectRatio/AspectRatio.js";
3
+ import { forwardRef as h } from "react";
4
+ import { jsx as e, jsxs as c } from "react/jsx-runtime";
5
+ var y = {
6
+ phone: 9 / 19.5,
7
+ tablet: 3 / 4,
8
+ browser: 16 / 10
9
+ }, x = h(function({ device: r = "phone", orientation: i = "portrait", ratio: a, url: s, label: d, safeArea: n, children: l, className: o, style: v }, p) {
10
+ const t = a !== void 0 && a > 0 && Number.isFinite(a) ? a : y[r], m = r !== "browser" && i === "landscape" ? 1 / t : t;
11
+ return /* @__PURE__ */ e(d ? "figure" : "div", {
12
+ ref: p,
13
+ "aria-label": d || void 0,
14
+ className: `cy-device-frame${o ? ` ${o}` : ""}`,
15
+ "data-device": r,
16
+ "data-orientation": r === "browser" ? void 0 : i,
17
+ "data-safe": n === void 0 ? "auto" : n ? "on" : void 0,
18
+ style: {
19
+ "--_screen-ratio": m,
20
+ ...v
21
+ },
22
+ children: /* @__PURE__ */ c("div", {
23
+ className: "cy-device-frame-body",
24
+ children: [r === "browser" && /* @__PURE__ */ c("div", {
25
+ className: "cy-device-frame-bar",
26
+ "aria-hidden": "true",
27
+ children: [/* @__PURE__ */ c("span", {
28
+ className: "cy-device-frame-dots",
29
+ children: [
30
+ /* @__PURE__ */ e("span", {}),
31
+ /* @__PURE__ */ e("span", {}),
32
+ /* @__PURE__ */ e("span", {})
33
+ ]
34
+ }), s && /* @__PURE__ */ e("span", {
35
+ className: "cy-device-frame-url",
36
+ dir: "ltr",
37
+ children: s
38
+ })]
39
+ }), /* @__PURE__ */ e(f, {
40
+ ratio: m,
41
+ className: "cy-device-frame-screen",
42
+ children: /* @__PURE__ */ e("div", {
43
+ className: "cy-device-frame-content cy-reset",
44
+ children: l
45
+ })
46
+ })]
47
+ })
48
+ });
49
+ });
50
+ export {
51
+ x as DeviceFrame
52
+ };
53
+
54
+ //# sourceMappingURL=DeviceFrame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeviceFrame.js","names":["AspectRatio","forwardRef","jsx","jsxs","RATIOS","DeviceFrame","device","orientation","ratio","url","label","safeArea","children","className","style","ref","upright","screen"],"sources":["../../../src/components/DeviceFrame/DeviceFrame.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode } from \"react\";\nimport { AspectRatio } from \"../AspectRatio/AspectRatio.js\";\n\nexport interface DeviceFrameTokens {\n /**\n * Colour of a phone's or tablet's bezel. Default: the ink on a light page; on a dark page a dark grey lifted off the\n * page, so the device stays dark but does not disappear.\n */\n bezel: string;\n /** Rim around the frame: the line colour on a light page, a lighter rim (3:1 against the page) on a dark one. */\n edge: string;\n /** Shadow under the frame. */\n shadow: string;\n /** Fill of the screen behind the content. */\n screen: string;\n /** Width of a portrait phone; a landscape phone is as tall as this. */\n phoneWidth: string;\n /** Width of a portrait tablet; a landscape tablet is as tall as this. */\n tabletWidth: string;\n /** Corner radius of the browser window. */\n browserRadius: string;\n /** Fill of the browser's top bar. */\n browserBar: string;\n /** Colour of the three window dots in the browser bar. */\n dot: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n deviceFrame: DeviceFrameTokens;\n }\n}\n\n/** The device drawn around the content. */\nexport type DeviceFrameDevice = \"phone\" | \"tablet\" | \"browser\";\n\nexport interface DeviceFrameProps {\n /** The device drawn around the content. Default \"phone\". */\n device?: DeviceFrameDevice;\n /** Which way a phone or tablet is held. The browser ignores it. Default \"portrait\". */\n orientation?: \"portrait\" | \"landscape\";\n /**\n * Width divided by height of the screen, as drawn in portrait (phone and tablet) or as is (browser). Landscape uses\n * its inverse. Default: 9 / 19.5 for a phone, 3 / 4 for a tablet, 16 / 10 for a browser.\n */\n ratio?: number;\n /** Address shown in the browser bar (decoration: it is not a link and is not announced). Browser only. */\n url?: string;\n /**\n * Accessible name. With it the frame is a `figure` with this name; without it the frame is decoration and adds\n * nothing to the accessibility tree, so the content keeps its own semantics.\n */\n label?: string;\n /**\n * Phone only: keep the content clear of the camera island (below it upright, beside it turned), as an app keeps\n * clear of a real phone's. By default live content is kept clear and a screenshot, video or canvas fills the whole\n * screen (it has its own status bar); `true` or `false` decides for any content.\n */\n safeArea?: boolean | undefined;\n /** What the screen shows: a screenshot, a video or a live demo. Each child is stretched to the screen and clipped. */\n children?: ReactNode;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only (width, margin, placement). The height follows from the width. Restyle through tokens. */\n style?: CSSProperties;\n}\n\nconst RATIOS: Record<DeviceFrameDevice, number> = { phone: 9 / 19.5, tablet: 3 / 4, browser: 16 / 10 };\n\n/** A phone, tablet or browser window drawn around a screenshot or a live demo, at any width. */\nexport const DeviceFrame = forwardRef<HTMLElement, DeviceFrameProps>(function DeviceFrame(\n { device = \"phone\", orientation = \"portrait\", ratio, url, label, safeArea, children, className, style },\n ref,\n) {\n const upright = ratio !== undefined && ratio > 0 && Number.isFinite(ratio) ? ratio : RATIOS[device];\n const turned = device !== \"browser\" && orientation === \"landscape\";\n const screen = turned ? 1 / upright : upright;\n const Root = label ? \"figure\" : \"div\";\n return (\n <Root\n ref={ref as never}\n aria-label={label || undefined}\n className={`cy-device-frame${className ? ` ${className}` : \"\"}`}\n data-device={device}\n data-orientation={device === \"browser\" ? undefined : orientation}\n data-safe={safeArea === undefined ? \"auto\" : safeArea ? \"on\" : undefined}\n style={{ \"--_screen-ratio\": screen, ...style } as CSSProperties}\n >\n <div className=\"cy-device-frame-body\">\n {device === \"browser\" && (\n <div className=\"cy-device-frame-bar\" aria-hidden=\"true\">\n <span className=\"cy-device-frame-dots\">\n <span />\n <span />\n <span />\n </span>\n {url && (\n <span className=\"cy-device-frame-url\" dir=\"ltr\">\n {url}\n </span>\n )}\n </div>\n )}\n <AspectRatio ratio={screen} className=\"cy-device-frame-screen\">\n <div className=\"cy-device-frame-content cy-reset\">{children}</div>\n </AspectRatio>\n </div>\n </Root>\n );\n});\n"],"mappings":";;;;AAmEA,IAAMI,IAA4C;AAAA,EAAE,OAAO,IAAI;AAAA,EAAM,QAAQ,IAAI;AAAA,EAAG,SAAS,KAAK;AAAG,GAGxFC,IAAcJ,EAA0C,SACnE,EAAE,QAAAK,IAAS,SAAS,aAAAC,IAAc,YAAY,OAAAC,GAAO,KAAAC,GAAK,OAAAC,GAAO,UAAAC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D,CAAA,CACV;AAAA,I;A,EACD,CAAA;AAEV,CAAC"}
@@ -0,0 +1 @@
1
+ export { DeviceFrame, type DeviceFrameDevice, type DeviceFrameProps, type DeviceFrameTokens, } from "./DeviceFrame.js";
@@ -53,8 +53,17 @@ export interface DialogProps {
53
53
  /** Internal: a Sheet is the same dialog docked to an edge. */
54
54
  export interface DialogFrameProps extends DialogProps {
55
55
  side?: "bottom" | "end" | "start";
56
+ /**
57
+ * Classes of the component built on the frame (Sheet), added to the dialog, the panel and the actions, so that
58
+ * component draws its own look in its own stylesheet.
59
+ */
60
+ parts?: {
61
+ root: string;
62
+ panel: string;
63
+ actions: string;
64
+ };
56
65
  }
57
- export declare function DialogFrame({ open, defaultOpen, onOpenChange, title, description, actions, size, dismissible, keepMounted, labels, side, className, style, children, }: DialogFrameProps): import("react").JSX.Element;
66
+ export declare function DialogFrame({ open, defaultOpen, onOpenChange, title, description, actions, size, dismissible, keepMounted, labels, side, parts, className, style, children, }: DialogFrameProps): import("react").JSX.Element;
58
67
  /**
59
68
  * Modal dialog in the top layer: focus moves in, stays in and comes back; Escape, the backdrop and the close button
60
69
  * dismiss it. In a container narrower than about 36rem it becomes a bottom sheet. Its content is mounted only while
@@ -1,123 +1,128 @@
1
1
  "use client";
2
- import { useControllableState as V } from "../../foundations/controllable.js";
3
- import { useClientLayoutEffect as g } from "../../foundations/client-layout-effect.js";
4
- import { useDismiss as M } from "../../overlay/dismiss.js";
5
- import { IconButton as _ } from "../IconButton/IconButton.js";
6
- import { DialogBase as G } from "../../foundations/DialogBase/DialogBase.js";
7
- import { close as J } from "../../icons/close.js";
8
- import { ToastHostContext as K } from "../../overlay/toast-host.js";
9
- import { useContext as Q, useEffect as W, useId as X, useRef as s, useState as Y } from "react";
10
- import { jsx as r, jsxs as h } from "react/jsx-runtime";
11
- var Z = { close: "Close" }, B = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]):not([aria-hidden="true"]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
12
- function ee() {
2
+ import { useControllableState as M } from "../../foundations/controllable.js";
3
+ import { useClientLayoutEffect as h } from "../../foundations/client-layout-effect.js";
4
+ import { useDismiss as _ } from "../../overlay/dismiss.js";
5
+ import { IconButton as G } from "../IconButton/IconButton.js";
6
+ import { DialogBase as J } from "../../foundations/DialogBase/DialogBase.js";
7
+ import { close as K } from "../../icons/close.js";
8
+ import { ToastHostContext as Q } from "../../overlay/toast-host.js";
9
+ import { useContext as W, useEffect as X, useId as Y, useRef as s, useState as Z } from "react";
10
+ import { jsx as n, jsxs as b } from "react/jsx-runtime";
11
+ var ee = { close: "Close" }, A = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]):not([aria-hidden="true"]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
12
+ function te() {
13
13
  if (typeof document > "u") return null;
14
14
  let e = document.activeElement;
15
15
  for (; e?.shadowRoot?.activeElement; ) e = e.shadowRoot.activeElement;
16
16
  return e;
17
17
  }
18
- function te(e) {
18
+ function oe(e) {
19
19
  if (!e) return null;
20
- const n = e.closest("[popover][id]");
21
- if (!(n ? !n.matches(":popover-open") : e.checkVisibility?.() === !1)) return e;
22
- const m = e.getRootNode();
23
- return (n && m.querySelector(`[aria-controls="${CSS.escape(n.id)}"]`)) ?? e;
20
+ const r = e.closest("[popover][id]");
21
+ if (!(r ? !r.matches(":popover-open") : e.checkVisibility?.() === !1)) return e;
22
+ const f = e.getRootNode();
23
+ return (r && f.querySelector(`[aria-controls="${CSS.escape(r.id)}"]`)) ?? e;
24
24
  }
25
- function oe({ open: e, defaultOpen: n = !1, onOpenChange: m, title: I, description: f, actions: b, size: O = "md", dismissible: C = !0, keepMounted: R = !1, labels: k, side: q, className: x, style: P, children: j }) {
26
- const a = X(), z = {
27
- ...Z,
28
- ...k
29
- }, [t, p] = V(e, n, m), i = s(null), c = Q(K), y = s(null), S = s(null), E = s(null), l = s(null), N = s(!1);
30
- t && !N.current && (l.current = ee()), N.current = t;
31
- const D = () => {
32
- C && p(!1);
33
- }, [u, L] = Y(t);
34
- t && !u && L(!0), W(() => {
25
+ function ne({ open: e, defaultOpen: r = !1, onOpenChange: f, title: I, description: p, actions: C, size: O = "md", dismissible: x = !0, keepMounted: R = !1, labels: j, side: k, parts: i, className: q, style: P, children: z }) {
26
+ const c = Y(), H = {
27
+ ...ee,
28
+ ...j
29
+ }, [t, y] = M(e, r, f), a = s(null), l = W(Q), g = s(null), N = s(null), S = s(null), d = s(null), E = s(!1);
30
+ t && !E.current && (d.current = te()), E.current = t;
31
+ const w = () => {
32
+ x && y(!1);
33
+ }, [u, D] = Z(t);
34
+ t && !u && D(!0), X(() => {
35
35
  if (t || !u) return;
36
- const o = i.current, w = () => L(!1), F = getComputedStyle(o), $ = (v) => Math.max(...v.split(",").map((U) => Number.parseFloat(U))), T = ($(F.transitionDuration) + $(F.transitionDelay)) * 1e3, A = (v) => {
37
- v.target === o && w();
36
+ const o = a.current, L = () => D(!1), $ = getComputedStyle(o), F = (v) => Math.max(...v.split(",").map((V) => Number.parseFloat(V))), B = (F($.transitionDuration) + F($.transitionDelay)) * 1e3, T = (v) => {
37
+ v.target === o && L();
38
38
  };
39
- o.addEventListener("transitionend", A);
40
- const H = setTimeout(w, T && T + 100);
39
+ o.addEventListener("transitionend", T);
40
+ const U = setTimeout(L, B && B + 100);
41
41
  return () => {
42
- o.removeEventListener("transitionend", A), clearTimeout(H);
42
+ o.removeEventListener("transitionend", T), clearTimeout(U);
43
43
  };
44
44
  }, [t, u]);
45
- const d = t || u || R;
46
- return g(() => {
47
- if (!(!t || !c || !y.current))
48
- return c.register(y.current);
49
- }, [t, c]), g(() => {
45
+ const m = t || u || R;
46
+ return h(() => {
47
+ if (!(!t || !l || !g.current))
48
+ return l.register(g.current);
49
+ }, [t, l]), h(() => {
50
50
  if (t)
51
51
  return () => {
52
- l.current = te(l.current);
52
+ d.current = oe(d.current);
53
53
  };
54
- }, [t]), g(() => {
55
- t && (S.current?.querySelector(B) ?? E.current?.querySelector(B) ?? i.current)?.focus({ preventScroll: !0 });
56
- }, [t]), M({
54
+ }, [t]), h(() => {
55
+ t && (N.current?.querySelector(A) ?? S.current?.querySelector(A) ?? a.current)?.focus({ preventScroll: !0 });
56
+ }, [t]), _({
57
57
  open: t,
58
- onClose: D,
59
- inside: [i],
60
- returnFocus: l,
61
- outside: (o) => o.composedPath()[0] === i.current
62
- }), /* @__PURE__ */ h(G, {
63
- ref: i,
58
+ onClose: w,
59
+ inside: [a],
60
+ returnFocus: d,
61
+ outside: (o) => o.composedPath()[0] === a.current
62
+ }), /* @__PURE__ */ b(J, {
63
+ ref: a,
64
64
  open: t,
65
- onCancel: D,
66
- onClose: () => p(!1),
67
- className: "cy-dialog",
65
+ onCancel: w,
66
+ onClose: () => y(!1),
67
+ className: i ? `cy-dialog ${i.root}` : "cy-dialog",
68
68
  tabIndex: -1,
69
69
  "data-size": O,
70
- "data-side": q,
71
- "aria-labelledby": d ? `${a}-title` : void 0,
72
- "aria-describedby": d && f ? `${a}-description` : void 0,
73
- children: [d && /* @__PURE__ */ h("div", {
74
- className: x ? `cy-dialog-panel cy-reset ${x}` : "cy-dialog-panel cy-reset",
70
+ "data-side": k,
71
+ "aria-labelledby": m ? `${c}-title` : void 0,
72
+ "aria-describedby": m && p ? `${c}-description` : void 0,
73
+ children: [m && /* @__PURE__ */ b("div", {
74
+ className: [
75
+ "cy-dialog-panel cy-reset",
76
+ i?.panel,
77
+ q
78
+ ].filter(Boolean).join(" "),
75
79
  style: P,
76
80
  children: [
77
- /* @__PURE__ */ h("div", {
81
+ /* @__PURE__ */ b("div", {
78
82
  className: "cy-dialog-header cy-reset",
79
- children: [/* @__PURE__ */ r("h2", {
80
- id: `${a}-title`,
83
+ children: [/* @__PURE__ */ n("h2", {
84
+ id: `${c}-title`,
81
85
  className: "cy-dialog-title cy-reset",
82
86
  children: I
83
- }), C && /* @__PURE__ */ r(_, {
84
- icon: J,
85
- label: z.close,
87
+ }), x && /* @__PURE__ */ n(G, {
88
+ icon: K,
89
+ label: H.close,
86
90
  variant: "ghost",
87
91
  size: "sm",
88
92
  tooltipPlacement: "bottom",
89
- onClick: () => p(!1)
93
+ wrapperClassName: "cy-dialog-close",
94
+ onClick: () => y(!1)
90
95
  })]
91
96
  }),
92
- f && /* @__PURE__ */ r("p", {
93
- id: `${a}-description`,
97
+ p && /* @__PURE__ */ n("p", {
98
+ id: `${c}-description`,
94
99
  className: "cy-dialog-description cy-reset",
95
- children: f
100
+ children: p
96
101
  }),
97
- /* @__PURE__ */ r("div", {
98
- ref: S,
102
+ /* @__PURE__ */ n("div", {
103
+ ref: N,
99
104
  className: "cy-dialog-body cy-reset",
100
105
  onFocus: (o) => o.target.scrollIntoView({ block: "nearest" }),
101
- children: j
106
+ children: z
102
107
  }),
103
- b && /* @__PURE__ */ r("div", {
104
- ref: E,
105
- className: "cy-dialog-actions cy-reset",
106
- children: b
108
+ C && /* @__PURE__ */ n("div", {
109
+ ref: S,
110
+ className: i ? `cy-dialog-actions cy-reset ${i.actions}` : "cy-dialog-actions cy-reset",
111
+ children: C
107
112
  })
108
113
  ]
109
- }), c && d && /* @__PURE__ */ r("div", {
110
- ref: y,
114
+ }), l && m && /* @__PURE__ */ n("div", {
115
+ ref: g,
111
116
  className: "cy-dialog-toasts"
112
117
  })]
113
118
  });
114
119
  }
115
- function me(e) {
116
- return /* @__PURE__ */ r(oe, { ...e });
120
+ function fe(e) {
121
+ return /* @__PURE__ */ n(ne, { ...e });
117
122
  }
118
123
  export {
119
- me as Dialog,
120
- oe as DialogFrame
124
+ fe as Dialog,
125
+ ne as DialogFrame
121
126
  };
122
127
 
123
128
  //# sourceMappingURL=Dialog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","names":["closeIcon","useControllableState","useClientLayoutEffect","useDismiss","IconButton","DialogBase","close","ToastHostContext","useContext","useEffect","useId","useRef","useState","jsx","jsxs","DEFAULT_LABELS","FOCUSABLE","deepActive","active","reachable","el","popover","root","DialogFrame","open","defaultOpen","onOpenChange","title","description","actions","size","dismissible","keepMounted","labels","side","className","style","children","id","text","isOpen","setOpen","dialog","toastHost","toasts","body","footer","returnTo","wasOpen","dismiss","present","setPresent","unmount","longest","times","time","wait","ended","event","timer","mounted","Dialog","props"],"sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useContext, useEffect, useId, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { DialogBase } from \"../../foundations/DialogBase/DialogBase.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { ToastHostContext } from \"../../overlay/toast-host.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface DialogTokens {\n radius: string;\n padding: string;\n widthSm: string;\n widthMd: string;\n widthLg: string;\n scrim: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n dialog: DialogTokens;\n }\n}\n\nexport interface DialogLabels {\n /** Accessible name of the close button. */\n close: string;\n}\n\nexport interface DialogProps {\n /** Whether the dialog is open, when you control it. */\n open?: boolean;\n /** Open on first render when uncontrolled. */\n defaultOpen?: boolean;\n /** Called with `false` when the dialog closes itself: Escape, the backdrop or the close button. */\n onOpenChange?: (open: boolean) => void;\n /** Heading of the dialog; also its accessible name. */\n title: ReactNode;\n /** One or two sentences under the title; also its accessible description. */\n description?: ReactNode;\n /** Buttons along the bottom, outside the scrolling content (Cancel first, then the main action). */\n actions?: ReactNode;\n /** Width preset (the panel never grows wider than its container). */\n size?: Size;\n /** Escape, the backdrop and the close button close it (default). `false` leaves only your actions. */\n dismissible?: boolean;\n /**\n * Keep the content in the DOM while the dialog is closed. By default a closed dialog renders nothing inside it: the\n * content mounts when it opens and unmounts once the closing transition has ended, so every opening starts fresh.\n * Set it for content whose state must survive closing (a half-filled form) or that is expensive to rebuild.\n * Default false.\n */\n keepMounted?: boolean;\n /** Replace the built-in English text: the close button's name. */\n labels?: Partial<DialogLabels>;\n /** Added to the panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. Restyle through --cy-dialog-* tokens. */\n style?: CSSProperties;\n /** The content; it scrolls when it is taller than the dialog. */\n children?: ReactNode;\n}\n\n/** Internal: a Sheet is the same dialog docked to an edge. */\nexport interface DialogFrameProps extends DialogProps {\n side?: \"bottom\" | \"end\" | \"start\";\n}\n\nconst DEFAULT_LABELS: DialogLabels = { close: \"Close\" };\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden=\"true\"]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** The focused element, looking inside shadow roots (document.activeElement stops at the host). */\nfunction deepActive(): HTMLElement | null {\n if (typeof document === \"undefined\") return null; // server render\n let active = document.activeElement;\n while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;\n return active as HTMLElement | null;\n}\n\n/**\n * Where focus can actually go back to. A Dialog opened from a Menu item remembers that item, but the menu has closed\n * (hidden, still in the DOM): fall back to the button that controls the hidden popover.\n */\nfunction reachable(el: HTMLElement | null): HTMLElement | null {\n if (!el) return null;\n // A closed popover can still be fading out (displayed), so ask the popover, not only the layout.\n const popover = el.closest<HTMLElement>(\"[popover][id]\");\n const closed = popover ? !popover.matches(\":popover-open\") : el.checkVisibility?.() === false;\n if (!closed) return el;\n const root = el.getRootNode() as Document | ShadowRoot;\n return (popover && root.querySelector<HTMLElement>(`[aria-controls=\"${CSS.escape(popover.id)}\"]`)) ?? el;\n}\n\nexport function DialogFrame({\n open,\n defaultOpen = false,\n onOpenChange,\n title,\n description,\n actions,\n size = \"md\",\n dismissible = true,\n keepMounted = false,\n labels,\n side,\n className,\n style,\n children,\n}: DialogFrameProps) {\n const id = useId();\n const text = { ...DEFAULT_LABELS, ...labels };\n const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange);\n const dialog = useRef<HTMLDialogElement>(null);\n const toastHost = useContext(ToastHostContext);\n const toasts = useRef<HTMLDivElement>(null);\n const body = useRef<HTMLDivElement>(null);\n const footer = useRef<HTMLDivElement>(null);\n const returnTo = useRef<HTMLElement | null>(null);\n const wasOpen = useRef(false);\n // Where focus was before opening: read while rendering, because DialogBase's showModal moves it first.\n if (isOpen && !wasOpen.current) returnTo.current = deepActive();\n wasOpen.current = isOpen;\n const dismiss = () => {\n if (dismissible) setOpen(false);\n };\n\n // The content is rendered while open, and after closing until the closing transition has ended. `present` goes true\n // in the render that opens the dialog, so the content is there before DialogBase shows it (no empty first frame).\n const [present, setPresent] = useState(isOpen);\n if (isOpen && !present) setPresent(true);\n useEffect(() => {\n if (isOpen || !present) return;\n const el = dialog.current as HTMLDialogElement;\n const unmount = () => setPresent(false);\n // Unmount when the dialog's own closing transition ends. The timer covers a transition that never reports back\n // (interrupted, or the dialog is not rendered) and is the whole wait when there is none: reduced motion, or no\n // stylesheet.\n const style = getComputedStyle(el);\n const longest = (times: string) => Math.max(...times.split(\",\").map((time) => Number.parseFloat(time)));\n const wait = (longest(style.transitionDuration) + longest(style.transitionDelay)) * 1000;\n const ended = (event: Event) => {\n if (event.target === el) unmount();\n };\n el.addEventListener(\"transitionend\", ended);\n const timer = setTimeout(unmount, wait && wait + 100);\n return () => {\n el.removeEventListener(\"transitionend\", ended);\n clearTimeout(timer);\n };\n }, [isOpen, present]);\n const mounted = isOpen || present || keepMounted;\n\n // On close, before useDismiss returns focus: make sure the remembered element can still take it.\n // Inside a Toaster, lend it a container while open: toasts raised now show above this dialog instead of under its\n // scrim, where the modal would make them inert. Runs after DialogBase has called showModal.\n useClientLayoutEffect(() => {\n if (!isOpen || !toastHost || !toasts.current) return;\n return toastHost.register(toasts.current);\n }, [isOpen, toastHost]);\n\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n return () => {\n returnTo.current = reachable(returnTo.current);\n };\n }, [isOpen]);\n\n // DialogBase has opened it; move focus to the first control in the content, else the first action, else the\n // dialog itself (so the close button's tooltip does not pop up on open).\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n const first =\n body.current?.querySelector<HTMLElement>(FOCUSABLE) ??\n footer.current?.querySelector<HTMLElement>(FOCUSABLE) ??\n dialog.current;\n first?.focus({ preventScroll: true });\n }, [isOpen]);\n\n useDismiss({\n open: isOpen,\n onClose: dismiss,\n inside: [dialog],\n returnFocus: returnTo,\n // The dialog fills its container; a pointer down on the dialog itself (not the panel) is on the backdrop.\n outside: (event) => event.composedPath()[0] === dialog.current,\n });\n\n return (\n <DialogBase\n ref={dialog}\n open={isOpen}\n onCancel={dismiss}\n onClose={() => setOpen(false)}\n className=\"cy-dialog\"\n tabIndex={-1}\n data-size={size}\n data-side={side}\n aria-labelledby={mounted ? `${id}-title` : undefined}\n aria-describedby={mounted && description ? `${id}-description` : undefined}\n >\n {mounted && (\n <div\n className={className ? `cy-dialog-panel cy-reset ${className}` : \"cy-dialog-panel cy-reset\"}\n style={style}\n >\n <div className=\"cy-dialog-header cy-reset\">\n <h2 id={`${id}-title`} className=\"cy-dialog-title cy-reset\">\n {title}\n </h2>\n {dismissible && (\n <IconButton\n icon={closeIcon}\n label={text.close}\n variant=\"ghost\"\n size=\"sm\"\n tooltipPlacement=\"bottom\"\n onClick={() => setOpen(false)}\n />\n )}\n </div>\n {description && (\n <p id={`${id}-description`} className=\"cy-dialog-description cy-reset\">\n {description}\n </p>\n )}\n {/* biome-ignore lint/a11y/noStaticElementInteractions: delegated focus listener for the controls inside */}\n <div\n ref={body}\n className=\"cy-dialog-body cy-reset\"\n // A focused field low in the content (Tab, or the on-screen keyboard opening) is brought fully into view.\n onFocus={(event) => event.target.scrollIntoView({ block: \"nearest\" })}\n >\n {children}\n </div>\n {actions && (\n <div ref={footer} className=\"cy-dialog-actions cy-reset\">\n {actions}\n </div>\n )}\n </div>\n )}\n {toastHost && mounted && <div ref={toasts} className=\"cy-dialog-toasts\" />}\n </DialogBase>\n );\n}\n\n/**\n * Modal dialog in the top layer: focus moves in, stays in and comes back; Escape, the backdrop and the close button\n * dismiss it. In a container narrower than about 36rem it becomes a bottom sheet. Its content is mounted only while\n * it is open (and while it closes), unless `keepMounted`.\n */\nexport function Dialog(props: DialogProps) {\n return <DialogFrame {...props} />;\n}\n"],"mappings":";;;;;;;;;;AAqEA,IAAMe,IAA+B,EAAE,OAAO,QAAQ,GAChDC,IACJ;AAGF,SAASC,KAAiC;AACxC,MAAI,OAAO,WAAa,IAAa,QAAO;AAC5C,MAAIC,IAAS,SAAS;AACtB,SAAOA,GAAQ,YAAY,gBAAe,CAAAA,IAASA,EAAO,WAAW;AACrE,SAAOA;AACT;AAMA,SAASC,GAAUC,GAA4C;AAC7D,MAAI,CAACA,EAAI,QAAO;AAEhB,QAAMC,IAAUD,EAAG,QAAqB,eAAe;AAEvD,MAAI,EADWC,IAAU,CAACA,EAAQ,QAAQ,eAAe,IAAID,EAAG,kBAAkB,MAAM,IAC3E,QAAOA;AACpB,QAAME,IAAOF,EAAG,YAAY;AAC5B,UAAQC,KAAWC,EAAK,cAA2B,mBAAmB,IAAI,OAAOD,EAAQ,EAAE,CAAA,IAAK,MAAMD;AACxG;AAEA,SAAgBG,GAAY,EAC1B,MAAAC,GACA,aAAAC,IAAc,IACd,cAAAC,GACA,OAAAC,GACA,aAAAC,GACA,SAAAC,GACA,MAAAC,IAAO,MACP,aAAAC,IAAc,IACd,aAAAC,IAAc,IACd,QAAAC,GACA,MAAAC,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACmB;AACnB,QAAMC,IAAK5B,EAAM,GACX6B,IAAO;AAAA,IAAE,GAAGxB;AAAA,IAAgB,GAAGkB;AAAA,EAAO,GACtC,CAACO,GAAQC,CAAA,IAAWxC,EAAqBuB,GAAMC,GAAaC,CAAY,GACxEgB,IAAS/B,EAA0B,IAAI,GACvCgC,IAAYnC,EAAWD,CAAgB,GACvCqC,IAASjC,EAAuB,IAAI,GACpCkC,IAAOlC,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AQ;AAAA,YACR,MAAK;AAAA,YACL,kBAAiB;AAAA,YACjB,SAAA,MAAeE,EAAQ,EAAK;AAAA,UAC7B,CAAA,CAEA;AAAA,Q;A,QACJb,KACC,gBAAAf,EAAC,KAAD;AAAA,UAAG,IAAI,GAAGyB,CAAA;AAAA,UAAkB,WAAU;AAAA,UACnC,UAAAV;AAAA,QACA,CAAA;AAAA,QAGL,gBAAAf,EAAC,OAAD;AAAA,UACE,KAAKgC;AAAA,UACL,WAAU;AAAA,UAEV,SAAA,CAAUa,MAAUA,EAAM,OAAO,eAAe,EAAE,OAAO,UAAU,CAAC;AAAA,UAEnE,UAAArB;AAAA,QACE,CAAA;AAAA,QACJR,KACC,gBAAAhB,EAAC,OAAD;AAAA,UAAK,KAAKiC;AAAA,UAAQ,WAAU;AAAA,UACzB,UAAAjB;AAAA,QACE,CAAA;AAAA,MAEJ;AAAA,IAEN,CAAA,GAAAc,KAAaiB,KAAW,gBAAA/C,EAAC,OAAD;AAAA,MAAK,KAAK+B;AAAA,MAAQ,WAAU;AAAA,IAAoB,CAAA,CAC/D;AAAA,E;AAEhB;AAOA,SAAgBiB,GAAOC,GAAoB;AACzC,SAAO,gBAAAjD,EAACU,IAAD,EAAa,GAAIuC,EAAQ,CAAA;AAClC"}
1
+ {"version":3,"file":"Dialog.js","names":["closeIcon","useControllableState","useClientLayoutEffect","useDismiss","IconButton","DialogBase","close","ToastHostContext","useContext","useEffect","useId","useRef","useState","jsx","jsxs","DEFAULT_LABELS","FOCUSABLE","deepActive","active","reachable","el","popover","root","DialogFrame","open","defaultOpen","onOpenChange","title","description","actions","size","dismissible","keepMounted","labels","side","parts","className","style","children","id","text","isOpen","setOpen","dialog","toastHost","toasts","body","footer","returnTo","wasOpen","dismiss","present","setPresent","unmount","longest","times","time","wait","ended","event","timer","mounted","Dialog","props"],"sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useContext, useEffect, useId, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { DialogBase } from \"../../foundations/DialogBase/DialogBase.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { ToastHostContext } from \"../../overlay/toast-host.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface DialogTokens {\n radius: string;\n padding: string;\n widthSm: string;\n widthMd: string;\n widthLg: string;\n scrim: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n dialog: DialogTokens;\n }\n}\n\nexport interface DialogLabels {\n /** Accessible name of the close button. */\n close: string;\n}\n\nexport interface DialogProps {\n /** Whether the dialog is open, when you control it. */\n open?: boolean;\n /** Open on first render when uncontrolled. */\n defaultOpen?: boolean;\n /** Called with `false` when the dialog closes itself: Escape, the backdrop or the close button. */\n onOpenChange?: (open: boolean) => void;\n /** Heading of the dialog; also its accessible name. */\n title: ReactNode;\n /** One or two sentences under the title; also its accessible description. */\n description?: ReactNode;\n /** Buttons along the bottom, outside the scrolling content (Cancel first, then the main action). */\n actions?: ReactNode;\n /** Width preset (the panel never grows wider than its container). */\n size?: Size;\n /** Escape, the backdrop and the close button close it (default). `false` leaves only your actions. */\n dismissible?: boolean;\n /**\n * Keep the content in the DOM while the dialog is closed. By default a closed dialog renders nothing inside it: the\n * content mounts when it opens and unmounts once the closing transition has ended, so every opening starts fresh.\n * Set it for content whose state must survive closing (a half-filled form) or that is expensive to rebuild.\n * Default false.\n */\n keepMounted?: boolean;\n /** Replace the built-in English text: the close button's name. */\n labels?: Partial<DialogLabels>;\n /** Added to the panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. Restyle through --cy-dialog-* tokens. */\n style?: CSSProperties;\n /** The content; it scrolls when it is taller than the dialog. */\n children?: ReactNode;\n}\n\n/** Internal: a Sheet is the same dialog docked to an edge. */\nexport interface DialogFrameProps extends DialogProps {\n side?: \"bottom\" | \"end\" | \"start\";\n /**\n * Classes of the component built on the frame (Sheet), added to the dialog, the panel and the actions, so that\n * component draws its own look in its own stylesheet.\n */\n parts?: { root: string; panel: string; actions: string };\n}\n\nconst DEFAULT_LABELS: DialogLabels = { close: \"Close\" };\nconst FOCUSABLE =\n 'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden=\"true\"]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** The focused element, looking inside shadow roots (document.activeElement stops at the host). */\nfunction deepActive(): HTMLElement | null {\n if (typeof document === \"undefined\") return null; // server render\n let active = document.activeElement;\n while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;\n return active as HTMLElement | null;\n}\n\n/**\n * Where focus can actually go back to. A Dialog opened from a Menu item remembers that item, but the menu has closed\n * (hidden, still in the DOM): fall back to the button that controls the hidden popover.\n */\nfunction reachable(el: HTMLElement | null): HTMLElement | null {\n if (!el) return null;\n // A closed popover can still be fading out (displayed), so ask the popover, not only the layout.\n const popover = el.closest<HTMLElement>(\"[popover][id]\");\n const closed = popover ? !popover.matches(\":popover-open\") : el.checkVisibility?.() === false;\n if (!closed) return el;\n const root = el.getRootNode() as Document | ShadowRoot;\n return (popover && root.querySelector<HTMLElement>(`[aria-controls=\"${CSS.escape(popover.id)}\"]`)) ?? el;\n}\n\nexport function DialogFrame({\n open,\n defaultOpen = false,\n onOpenChange,\n title,\n description,\n actions,\n size = \"md\",\n dismissible = true,\n keepMounted = false,\n labels,\n side,\n parts,\n className,\n style,\n children,\n}: DialogFrameProps) {\n const id = useId();\n const text = { ...DEFAULT_LABELS, ...labels };\n const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange);\n const dialog = useRef<HTMLDialogElement>(null);\n const toastHost = useContext(ToastHostContext);\n const toasts = useRef<HTMLDivElement>(null);\n const body = useRef<HTMLDivElement>(null);\n const footer = useRef<HTMLDivElement>(null);\n const returnTo = useRef<HTMLElement | null>(null);\n const wasOpen = useRef(false);\n // Where focus was before opening: read while rendering, because DialogBase's showModal moves it first.\n if (isOpen && !wasOpen.current) returnTo.current = deepActive();\n wasOpen.current = isOpen;\n const dismiss = () => {\n if (dismissible) setOpen(false);\n };\n\n // The content is rendered while open, and after closing until the closing transition has ended. `present` goes true\n // in the render that opens the dialog, so the content is there before DialogBase shows it (no empty first frame).\n const [present, setPresent] = useState(isOpen);\n if (isOpen && !present) setPresent(true);\n useEffect(() => {\n if (isOpen || !present) return;\n const el = dialog.current as HTMLDialogElement;\n const unmount = () => setPresent(false);\n // Unmount when the dialog's own closing transition ends. The timer covers a transition that never reports back\n // (interrupted, or the dialog is not rendered) and is the whole wait when there is none: reduced motion, or no\n // stylesheet.\n const style = getComputedStyle(el);\n const longest = (times: string) => Math.max(...times.split(\",\").map((time) => Number.parseFloat(time)));\n const wait = (longest(style.transitionDuration) + longest(style.transitionDelay)) * 1000;\n const ended = (event: Event) => {\n if (event.target === el) unmount();\n };\n el.addEventListener(\"transitionend\", ended);\n const timer = setTimeout(unmount, wait && wait + 100);\n return () => {\n el.removeEventListener(\"transitionend\", ended);\n clearTimeout(timer);\n };\n }, [isOpen, present]);\n const mounted = isOpen || present || keepMounted;\n\n // On close, before useDismiss returns focus: make sure the remembered element can still take it.\n // Inside a Toaster, lend it a container while open: toasts raised now show above this dialog instead of under its\n // scrim, where the modal would make them inert. Runs after DialogBase has called showModal.\n useClientLayoutEffect(() => {\n if (!isOpen || !toastHost || !toasts.current) return;\n return toastHost.register(toasts.current);\n }, [isOpen, toastHost]);\n\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n return () => {\n returnTo.current = reachable(returnTo.current);\n };\n }, [isOpen]);\n\n // DialogBase has opened it; move focus to the first control in the content, else the first action, else the\n // dialog itself (so the close button's tooltip does not pop up on open).\n useClientLayoutEffect(() => {\n if (!isOpen) return;\n const first =\n body.current?.querySelector<HTMLElement>(FOCUSABLE) ??\n footer.current?.querySelector<HTMLElement>(FOCUSABLE) ??\n dialog.current;\n first?.focus({ preventScroll: true });\n }, [isOpen]);\n\n useDismiss({\n open: isOpen,\n onClose: dismiss,\n inside: [dialog],\n returnFocus: returnTo,\n // The dialog fills its container; a pointer down on the dialog itself (not the panel) is on the backdrop.\n outside: (event) => event.composedPath()[0] === dialog.current,\n });\n\n return (\n <DialogBase\n ref={dialog}\n open={isOpen}\n onCancel={dismiss}\n onClose={() => setOpen(false)}\n className={parts ? `cy-dialog ${parts.root}` : \"cy-dialog\"}\n tabIndex={-1}\n data-size={size}\n data-side={side}\n aria-labelledby={mounted ? `${id}-title` : undefined}\n aria-describedby={mounted && description ? `${id}-description` : undefined}\n >\n {mounted && (\n <div\n className={[\"cy-dialog-panel cy-reset\", parts?.panel, className].filter(Boolean).join(\" \")}\n style={style}\n >\n <div className=\"cy-dialog-header cy-reset\">\n <h2 id={`${id}-title`} className=\"cy-dialog-title cy-reset\">\n {title}\n </h2>\n {dismissible && (\n <IconButton\n icon={closeIcon}\n label={text.close}\n variant=\"ghost\"\n size=\"sm\"\n tooltipPlacement=\"bottom\"\n wrapperClassName=\"cy-dialog-close\"\n onClick={() => setOpen(false)}\n />\n )}\n </div>\n {description && (\n <p id={`${id}-description`} className=\"cy-dialog-description cy-reset\">\n {description}\n </p>\n )}\n {/* biome-ignore lint/a11y/noStaticElementInteractions: delegated focus listener for the controls inside */}\n <div\n ref={body}\n className=\"cy-dialog-body cy-reset\"\n // A focused field low in the content (Tab, or the on-screen keyboard opening) is brought fully into view.\n onFocus={(event) => event.target.scrollIntoView({ block: \"nearest\" })}\n >\n {children}\n </div>\n {actions && (\n <div\n ref={footer}\n className={parts ? `cy-dialog-actions cy-reset ${parts.actions}` : \"cy-dialog-actions cy-reset\"}\n >\n {actions}\n </div>\n )}\n </div>\n )}\n {toastHost && mounted && <div ref={toasts} className=\"cy-dialog-toasts\" />}\n </DialogBase>\n );\n}\n\n/**\n * Modal dialog in the top layer: focus moves in, stays in and comes back; Escape, the backdrop and the close button\n * dismiss it. In a container narrower than about 36rem it becomes a bottom sheet. Its content is mounted only while\n * it is open (and while it closes), unless `keepMounted`.\n */\nexport function Dialog(props: DialogProps) {\n return <DialogFrame {...props} />;\n}\n"],"mappings":";;;;;;;;;;AA0EA,IAAMe,KAA+B,EAAE,OAAO,QAAQ,GAChDC,IACJ;AAGF,SAASC,KAAiC;AACxC,MAAI,OAAO,WAAa,IAAa,QAAO;AAC5C,MAAIC,IAAS,SAAS;AACtB,SAAOA,GAAQ,YAAY,gBAAe,CAAAA,IAASA,EAAO,WAAW;AACrE,SAAOA;AACT;AAMA,SAASC,GAAUC,GAA4C;AAC7D,MAAI,CAACA,EAAI,QAAO;AAEhB,QAAMC,IAAUD,EAAG,QAAqB,eAAe;AAEvD,MAAI,EADWC,IAAU,CAACA,EAAQ,QAAQ,eAAe,IAAID,EAAG,kBAAkB,MAAM,IAC3E,QAAOA;AACpB,QAAME,IAAOF,EAAG,YAAY;AAC5B,UAAQC,KAAWC,EAAK,cAA2B,mBAAmB,IAAI,OAAOD,EAAQ,EAAE,CAAA,IAAK,MAAMD;AACxG;AAEA,SAAgBG,GAAY,EAC1B,MAAAC,GACA,aAAAC,IAAc,IACd,cAAAC,GACA,OAAAC,GACA,aAAAC,GACA,SAAAC,GACA,MAAAC,IAAO,MACP,aAAAC,IAAc,IACd,aAAAC,IAAc,IACd,QAAAC,GACA,MAAAC,GACA,OAAAC,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACmB;AACnB,QAAMC,IAAK7B,EAAM,GACX8B,IAAO;AAAA,IAAE,GAAGzB;AAAA,IAAgB,GAAGkB;AAAA,EAAO,GACtC,CAACQ,GAAQC,CAAA,IAAWzC,EAAqBuB,GAAMC,GAAaC,CAAY,GACxEiB,IAAShC,EAA0B,IAAI,GACvCiC,IAAYpC,EAAWD,CAAgB,GACvCsC,IAASlC,EAAuB,IAAI,GACpCmC,IAAOnC,EAAuB,IAAI,GAClCoC,IAASpC,EAAuB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AAD;AAAA,YACE,MAAMJ;AAAAA,YACN,OAAOwC,EAAK;AAAA,YACZ,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,kBAAiB;AAAA,YACjB,kBAAiB;AAAA,YACjB,SAAA,MAAeE,EAAQ,EAAK;AAAA,UAC7B,CAAA,CAEA;AAAA,Q;A,QACJd,KACC,gBAAAf,EAAC,KAAD;AAAA,UAAG,IAAI,GAAG0B,CAAA;AAAA,UAAkB,WAAU;AAAA,UACnC,UAAAX;AAAA,QACA,CAAA;AAAA,QAGL,gBAAAf,EAAC,OAAD;AAAA,UACE,KAAKiC;AAAA,UACL,WAAU;AAAA,UAEV,SAAA,CAAUa,MAAUA,EAAM,OAAO,eAAe,EAAE,OAAO,UAAU,CAAC;AAAA,UAEnE,UAAArB;AAAA,QACE,CAAA;AAAA,QACJT,KACC,gBAAAhB,EAAC,OAAD;AAAA,UACE,KAAKkC;AAAA,UACL,WAAWZ,IAAQ,8BAA8BA,EAAM,OAAA,KAAY;AAAA,UAElE,UAAAN;AAAA,QACE,CAAA;AAAA,MAEJ;AAAA,IAEN,CAAA,GAAAe,KAAaiB,KAAW,gBAAAhD,EAAC,OAAD;AAAA,MAAK,KAAKgC;AAAA,MAAQ,WAAU;AAAA,IAAoB,CAAA,CAC/D;AAAA,E;AAEhB;AAOA,SAAgBiB,GAAOC,GAAoB;AACzC,SAAO,gBAAAlD,EAACU,IAAD,EAAa,GAAIwC,EAAQ,CAAA;AAClC"}
@@ -20,8 +20,11 @@ export interface EmptyStateProps {
20
20
  description?: ReactNode | undefined;
21
21
  /** Buttons for the next step ("Create a project", "Clear filters"). */
22
22
  actions?: ReactNode | undefined;
23
- /** Heading level of the title, to fit the page outline (default 3). */
24
- headingLevel?: 2 | 3 | 4 | 5 | 6;
23
+ /**
24
+ * Heading level of the title, to fit the page outline (default 3). 1 when the empty state is the page itself (a
25
+ * not-found page): the look stays the same.
26
+ */
27
+ headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
25
28
  /** `sm` for panels and popups, `md` for page areas. */
26
29
  size?: Extract<Size, "sm" | "md">;
27
30
  /** Added to the root element, for layout. */
@@ -1 +1 @@
1
- {"version":3,"file":"EmptyState.js","names":["Icon","createElement","jsx","jsxs","EmptyState","icon","title","description","actions","headingLevel","size","className","style"],"sources":["../../../src/components/EmptyState/EmptyState.tsx"],"sourcesContent":["import { type CSSProperties, createElement, type ReactNode } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface EmptyStateTokens {\n gap: string;\n padding: string;\n maxWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n emptyState: EmptyStateTokens;\n }\n}\n\nexport interface EmptyStateProps {\n /** A Facet icon shown above the title (decorative). */\n icon?: IconData | undefined;\n /** The heading: what is empty or missing. */\n title: ReactNode;\n /** A sentence under the title. */\n description?: ReactNode | undefined;\n /** Buttons for the next step (\"Create a project\", \"Clear filters\"). */\n actions?: ReactNode | undefined;\n /** Heading level of the title, to fit the page outline (default 3). */\n headingLevel?: 2 | 3 | 4 | 5 | 6;\n /** `sm` for panels and popups, `md` for page areas. */\n size?: Extract<Size, \"sm\" | \"md\">;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-empty-state-* tokens. */\n style?: CSSProperties;\n}\n\n/** What to show where content will be: no items yet, no search results, nothing selected. */\nexport function EmptyState({\n icon,\n title,\n description,\n actions,\n headingLevel = 3,\n size = \"md\",\n className,\n style,\n}: EmptyStateProps) {\n return (\n <div\n className={className ? `cy-empty-state ${className}` : \"cy-empty-state\"}\n data-size={size}\n style={style}\n >\n {icon && (\n <span className=\"cy-empty-state-icon cy-reset\">\n <Icon icon={icon} size=\"lg\" />\n </span>\n )}\n {createElement(`h${headingLevel}`, { className: \"cy-empty-state-title cy-reset\" }, title)}\n {description && <p className=\"cy-empty-state-description cy-reset\">{description}</p>}\n {actions && <div className=\"cy-empty-state-actions cy-reset\">{actions}</div>}\n </div>\n );\n}\n"],"mappings":";;;;AAqCA,SAAgBI,EAAW,EACzB,MAAAC,GACA,OAAAC,GACA,aAAAC,GACA,SAAAC,GACA,cAAAC,IAAe,GACf,MAAAC,IAAO,MACP,WAAAC,GACA,OAAAC,EAAA,GACkB;AAClB,SACE,gBAAAT,EAAC,OAAD;AAAA,IACE,WAAWQ,IAAY,kBAAkBA,CAAA,KAAc;AAAA,IACvD,aAAWD;AAAA,IACJ,OAAAE;AAAA,IAHT,UAAA;AAAA,MAKGP,KACC,gBAAAH,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QACd,UAAA,gBAAAA,EAACF,GAAD;AAAA,UAAY,MAAAK;AAAA,UAAM,MAAK;AAAA,QAAM,CAAA;AAAA,MACzB,CAAA;AAAA,MAEPJ,EAAc,IAAIQ,CAAA,IAAgB,EAAE,WAAW,gCAAgC,GAAGH,CAAK;AAAA,MACvFC,KAAe,gBAAAL,EAAC,KAAD;AAAA,QAAG,WAAU;AAAA,QAAuC,UAAAK;AAAA,MAAe,CAAA;AAAA,MAClFC,KAAW,gBAAAN,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAAmC,UAAAM;AAAA,MAAa,CAAA;AAAA,IACxE;AAAA,E;AAET"}
1
+ {"version":3,"file":"EmptyState.js","names":["Icon","createElement","jsx","jsxs","EmptyState","icon","title","description","actions","headingLevel","size","className","style"],"sources":["../../../src/components/EmptyState/EmptyState.tsx"],"sourcesContent":["import { type CSSProperties, createElement, type ReactNode } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface EmptyStateTokens {\n gap: string;\n padding: string;\n maxWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n emptyState: EmptyStateTokens;\n }\n}\n\nexport interface EmptyStateProps {\n /** A Facet icon shown above the title (decorative). */\n icon?: IconData | undefined;\n /** The heading: what is empty or missing. */\n title: ReactNode;\n /** A sentence under the title. */\n description?: ReactNode | undefined;\n /** Buttons for the next step (\"Create a project\", \"Clear filters\"). */\n actions?: ReactNode | undefined;\n /**\n * Heading level of the title, to fit the page outline (default 3). 1 when the empty state is the page itself (a\n * not-found page): the look stays the same.\n */\n headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /** `sm` for panels and popups, `md` for page areas. */\n size?: Extract<Size, \"sm\" | \"md\">;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-empty-state-* tokens. */\n style?: CSSProperties;\n}\n\n/** What to show where content will be: no items yet, no search results, nothing selected. */\nexport function EmptyState({\n icon,\n title,\n description,\n actions,\n headingLevel = 3,\n size = \"md\",\n className,\n style,\n}: EmptyStateProps) {\n return (\n <div\n className={className ? `cy-empty-state ${className}` : \"cy-empty-state\"}\n data-size={size}\n style={style}\n >\n {icon && (\n <span className=\"cy-empty-state-icon cy-reset\">\n <Icon icon={icon} size=\"lg\" />\n </span>\n )}\n {createElement(`h${headingLevel}`, { className: \"cy-empty-state-title cy-reset\" }, title)}\n {description && <p className=\"cy-empty-state-description cy-reset\">{description}</p>}\n {actions && <div className=\"cy-empty-state-actions cy-reset\">{actions}</div>}\n </div>\n );\n}\n"],"mappings":";;;;AAwCA,SAAgBI,EAAW,EACzB,MAAAC,GACA,OAAAC,GACA,aAAAC,GACA,SAAAC,GACA,cAAAC,IAAe,GACf,MAAAC,IAAO,MACP,WAAAC,GACA,OAAAC,EAAA,GACkB;AAClB,SACE,gBAAAT,EAAC,OAAD;AAAA,IACE,WAAWQ,IAAY,kBAAkBA,CAAA,KAAc;AAAA,IACvD,aAAWD;AAAA,IACJ,OAAAE;AAAA,IAHT,UAAA;AAAA,MAKGP,KACC,gBAAAH,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QACd,UAAA,gBAAAA,EAACF,GAAD;AAAA,UAAY,MAAAK;AAAA,UAAM,MAAK;AAAA,QAAM,CAAA;AAAA,MACzB,CAAA;AAAA,MAEPJ,EAAc,IAAIQ,CAAA,IAAgB,EAAE,WAAW,gCAAgC,GAAGH,CAAK;AAAA,MACvFC,KAAe,gBAAAL,EAAC,KAAD;AAAA,QAAG,WAAU;AAAA,QAAuC,UAAAK;AAAA,MAAe,CAAA;AAAA,MAClFC,KAAW,gBAAAN,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAAmC,UAAAM;AAAA,MAAa,CAAA;AAAA,IACxE;AAAA,E;AAET"}
@@ -1,55 +1,53 @@
1
1
  "use client";
2
- import { useField as y } from "../../foundations/field.js";
3
- import { Fragment as p, jsx as e, jsxs as v } from "react/jsx-runtime";
4
- function F({ label: l, description: i, error: a, required: r, size: m = "md", group: s, labelHidden: c, id: b, className: n, style: f, children: h }) {
5
- const d = y({
6
- id: b,
7
- description: i,
2
+ import { useField as p } from "../../foundations/field.js";
3
+ import { Fragment as u, jsx as d, jsxs as v } from "react/jsx-runtime";
4
+ function N({ label: i, description: l, error: a, required: s, size: b = "md", group: r, labelHidden: m, id: y, className: c, style: f, children: h }) {
5
+ const e = p({
6
+ id: y,
7
+ description: l,
8
8
  error: a
9
- }), t = /* @__PURE__ */ v(p, { children: [
10
- s ? /* @__PURE__ */ e("span", {
11
- id: d.labelId,
12
- className: "cy-field-label",
13
- "data-required": r ? "" : void 0,
14
- "data-hidden": c ? "" : void 0,
15
- children: l
16
- }) : /* @__PURE__ */ e("label", {
17
- id: d.labelId,
18
- htmlFor: d.id,
19
- className: "cy-field-label",
20
- "data-required": r ? "" : void 0,
21
- "data-hidden": c ? "" : void 0,
22
- children: l
9
+ }), n = m ? "cy-field-label cy-visually-hidden" : "cy-field-label", t = /* @__PURE__ */ v(u, { children: [
10
+ r ? /* @__PURE__ */ d("span", {
11
+ id: e.labelId,
12
+ className: n,
13
+ "data-required": s ? "" : void 0,
14
+ children: i
15
+ }) : /* @__PURE__ */ d("label", {
16
+ id: e.labelId,
17
+ htmlFor: e.id,
18
+ className: n,
19
+ "data-required": s ? "" : void 0,
20
+ children: i
23
21
  }),
24
- h(d),
25
- i && /* @__PURE__ */ e("span", {
26
- id: d.descriptionId,
22
+ h(e),
23
+ l && /* @__PURE__ */ d("span", {
24
+ id: e.descriptionId,
27
25
  className: "cy-field-description",
28
- children: i
26
+ children: l
29
27
  }),
30
- d.invalid && /* @__PURE__ */ e("span", {
31
- id: d.errorId,
28
+ e.invalid && /* @__PURE__ */ d("span", {
29
+ id: e.errorId,
32
30
  className: "cy-field-error",
33
31
  role: "alert",
34
32
  children: a
35
33
  })
36
34
  ] }), o = {
37
- className: `cy-field${n ? ` ${n}` : ""}`,
38
- "data-size": m,
35
+ className: `cy-field${c ? ` ${c}` : ""}`,
36
+ "data-size": b,
39
37
  style: f
40
38
  };
41
- return s ? /* @__PURE__ */ e("fieldset", {
39
+ return r ? /* @__PURE__ */ d("fieldset", {
42
40
  ...o,
43
- "aria-labelledby": d.labelId,
44
- "aria-describedby": d.describedBy,
41
+ "aria-labelledby": e.labelId,
42
+ "aria-describedby": e.describedBy,
45
43
  children: t
46
- }) : /* @__PURE__ */ e("div", {
44
+ }) : /* @__PURE__ */ d("div", {
47
45
  ...o,
48
46
  children: t
49
47
  });
50
48
  }
51
49
  export {
52
- F as Field
50
+ N as Field
53
51
  };
54
52
 
55
53
  //# sourceMappingURL=Field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","names":["_Fragment","useField","Fragment","jsx","jsxs","Field","label","description","error","required","size","group","labelHidden","id","className","style","children","field","body","props"],"sources":["../../../src/components/Field/Field.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { type FieldRender, useField } from \"../../foundations/field.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface FieldTokens {\n gap: string;\n labelWeight: string;\n labelColor: string;\n descriptionColor: string;\n errorColor: string;\n requiredColor: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n field: FieldTokens;\n }\n}\n\nexport interface FieldProps {\n /** Visible label; it names the control. */\n label: ReactNode;\n /** Help text shown below the control and read out with it. */\n description?: ReactNode | undefined;\n /** Shown below the control, announced, and marks the control invalid. */\n error?: ReactNode | undefined;\n /** Draws the required marker; pass `required` to the control too. */\n required?: boolean | undefined;\n /** Size of the label text. Default \"md\". */\n size?: Size | undefined;\n /** Keep the label for assistive tech but take no space (toolbars, dense rows). Prefer visible labels. */\n labelHidden?: boolean | undefined;\n /** Label a group of controls (radio groups) instead of one control. */\n group?: boolean | undefined;\n /** Id for the control; the label, description and error ids are built from it. Default: a generated id. */\n id?: string | undefined;\n /** Added to the root element, for layout. */\n className?: string | undefined;\n /** Layout only. */\n style?: CSSProperties | undefined;\n /** Renders the control from the ids and state in `field`. */\n children: (field: FieldRender) => ReactNode;\n}\n\n/** Label, description and error wiring for any control. Controls render through `children(field)`. */\nexport function Field({\n label,\n description,\n error,\n required,\n size = \"md\",\n group,\n labelHidden,\n id,\n className,\n style,\n children,\n}: FieldProps) {\n const field = useField({ id, description, error });\n const body = (\n <>\n {group ? (\n <span\n id={field.labelId}\n className=\"cy-field-label\"\n data-required={required ? \"\" : undefined}\n data-hidden={labelHidden ? \"\" : undefined}\n >\n {label}\n </span>\n ) : (\n <label\n id={field.labelId}\n htmlFor={field.id}\n className=\"cy-field-label\"\n data-required={required ? \"\" : undefined}\n data-hidden={labelHidden ? \"\" : undefined}\n >\n {label}\n </label>\n )}\n {children(field)}\n {description && (\n <span id={field.descriptionId} className=\"cy-field-description\">\n {description}\n </span>\n )}\n {field.invalid && (\n <span id={field.errorId} className=\"cy-field-error\" role=\"alert\">\n {error}\n </span>\n )}\n </>\n );\n const props = { className: `cy-field${className ? ` ${className}` : \"\"}`, \"data-size\": size, style };\n return group ? (\n <fieldset {...props} aria-labelledby={field.labelId} aria-describedby={field.describedBy}>\n {body}\n </fieldset>\n ) : (\n <div {...props}>{body}</div>\n );\n}\n"],"mappings":";;;AA6CA,SAAgBK,EAAM,EACpB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C;AAAA,EACO,CAAA,IAEV,gBAAAf,EAAC,OAAD;AAAA,IAAK,GAAIgB;AAAA,IAAQ,UAAAD;AAAA,EAAU,CAAA;AAE/B"}
1
+ {"version":3,"file":"Field.js","names":["_Fragment","useField","Fragment","jsx","jsxs","Field","label","description","error","required","size","group","labelHidden","id","className","style","children","field","labelClass","body","props"],"sources":["../../../src/components/Field/Field.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { type FieldRender, useField } from \"../../foundations/field.js\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface FieldTokens {\n gap: string;\n labelWeight: string;\n labelColor: string;\n descriptionColor: string;\n errorColor: string;\n requiredColor: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n field: FieldTokens;\n }\n}\n\nexport interface FieldProps {\n /** Visible label; it names the control. */\n label: ReactNode;\n /** Help text shown below the control and read out with it. */\n description?: ReactNode | undefined;\n /** Shown below the control, announced, and marks the control invalid. */\n error?: ReactNode | undefined;\n /** Draws the required marker; pass `required` to the control too. */\n required?: boolean | undefined;\n /** Size of the label text. Default \"md\". */\n size?: Size | undefined;\n /** Keep the label for assistive tech but take no space (toolbars, dense rows). Prefer visible labels. */\n labelHidden?: boolean | undefined;\n /** Label a group of controls (radio groups) instead of one control. */\n group?: boolean | undefined;\n /** Id for the control; the label, description and error ids are built from it. Default: a generated id. */\n id?: string | undefined;\n /** Added to the root element, for layout. */\n className?: string | undefined;\n /** Layout only. */\n style?: CSSProperties | undefined;\n /** Renders the control from the ids and state in `field`. */\n children: (field: FieldRender) => ReactNode;\n}\n\n/** Label, description and error wiring for any control. Controls render through `children(field)`. */\nexport function Field({\n label,\n description,\n error,\n required,\n size = \"md\",\n group,\n labelHidden,\n id,\n className,\n style,\n children,\n}: FieldProps) {\n const field = useField({ id, description, error });\n // A hidden label stays in the accessibility tree; out of the flow, the grid gap collapses with it.\n const labelClass = labelHidden ? \"cy-field-label cy-visually-hidden\" : \"cy-field-label\";\n const body = (\n <>\n {group ? (\n <span id={field.labelId} className={labelClass} data-required={required ? \"\" : undefined}>\n {label}\n </span>\n ) : (\n <label\n id={field.labelId}\n htmlFor={field.id}\n className={labelClass}\n data-required={required ? \"\" : undefined}\n >\n {label}\n </label>\n )}\n {children(field)}\n {description && (\n <span id={field.descriptionId} className=\"cy-field-description\">\n {description}\n </span>\n )}\n {field.invalid && (\n <span id={field.errorId} className=\"cy-field-error\" role=\"alert\">\n {error}\n </span>\n )}\n </>\n );\n const props = { className: `cy-field${className ? ` ${className}` : \"\"}`, \"data-size\": size, style };\n return group ? (\n <fieldset {...props} aria-labelledby={field.labelId} aria-describedby={field.describedBy}>\n {body}\n </fieldset>\n ) : (\n <div {...props}>{body}</div>\n );\n}\n"],"mappings":";;;AA6CA,SAAgBK,EAAM,EACpB,OAAAC,GACA,aAAAC,GACA,OAAAC,GACA,UAAAC,GACA,MAAAC,IAAO,MACP,OAAAC,GACA,aAAAC,GACA,IAAAC,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACa;AACb,QAAMC,IAAQhB,EAAS;AAAA,IAAE,IAAAY;AAAA,IAAI,aAAAN;AAAA,IAAa,OAAAC;AAAA,EAAM,CAAC,GAE3CU,IAAaN,IAAc,sCAAsC,kBACjEO,IACJ,gBAAAf,EAAAJ,GAAA,EAAA,UAAA;AAAA,IACGW,IACC,gBAAAR,EAAC,QAAD;AAAA,MAAM,IAAIc,EAAM;AAAA,MAAS,WAAWC;AAAA,MAAY,iBAAeT,IAAW,KAAK;AAAA,MAC5E,UAAAH;AAAA,IACG,CAAA,IAEN,gBAAAH,EAAC,SAAD;AAAA,MACE,IAAIc,EAAM;AAAA,MACV,SAASA,EAAM;AAAA,MACf,WAAWC;AAAA,MACX,iBAAeT,IAAW,KAAK;AAAA,MAE9B,UAAAH;AAAA,IACI,CAAA;AAAA,IAERU,EAASC,CAAK;AAAA,IACdV,KACC,gBAAAJ,EAAC,QAAD;AAAA,MAAM,IAAIc,E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