@slurp-ui/react 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/Bloom/Bloom.js +3 -2
  3. package/dist/Bloom/Bloom.js.map +1 -1
  4. package/dist/Calendar/Calendar.d.ts +42 -0
  5. package/dist/Calendar/Calendar.js +178 -0
  6. package/dist/Calendar/Calendar.js.map +1 -0
  7. package/dist/Calendar/dates.d.ts +3 -0
  8. package/dist/Calendar/dates.js +46 -0
  9. package/dist/Calendar/dates.js.map +1 -0
  10. package/dist/Calendar/index.d.ts +3 -0
  11. package/dist/Calendar/index.js +2 -0
  12. package/dist/Card/Card.d.ts +1 -1
  13. package/dist/Card/Card.js.map +1 -1
  14. package/dist/Carousel/Carousel.js +2 -0
  15. package/dist/Carousel/Carousel.js.map +1 -1
  16. package/dist/Choice/Choice.js +2 -0
  17. package/dist/Choice/Choice.js.map +1 -1
  18. package/dist/Code/Code.d.ts +38 -0
  19. package/dist/Code/Code.js +82 -0
  20. package/dist/Code/Code.js.map +1 -0
  21. package/dist/Code/index.d.ts +3 -0
  22. package/dist/Code/index.js +2 -0
  23. package/dist/Contents/Contents.d.ts +35 -0
  24. package/dist/Contents/Contents.js +63 -0
  25. package/dist/Contents/Contents.js.map +1 -0
  26. package/dist/Contents/index.d.ts +3 -0
  27. package/dist/Contents/index.js +2 -0
  28. package/dist/DateField/DateField.d.ts +29 -0
  29. package/dist/DateField/DateField.js +118 -0
  30. package/dist/DateField/DateField.js.map +1 -0
  31. package/dist/DateField/index.d.ts +3 -0
  32. package/dist/DateField/index.js +2 -0
  33. package/dist/Dialog/Dialog.js +73 -25
  34. package/dist/Dialog/Dialog.js.map +1 -1
  35. package/dist/Dock/Dock.d.ts +6 -1
  36. package/dist/Dock/Dock.js +13 -2
  37. package/dist/Dock/Dock.js.map +1 -1
  38. package/dist/ErrorSummary/ErrorSummary.d.ts +26 -0
  39. package/dist/ErrorSummary/ErrorSummary.js +68 -0
  40. package/dist/ErrorSummary/ErrorSummary.js.map +1 -0
  41. package/dist/ErrorSummary/index.d.ts +3 -0
  42. package/dist/ErrorSummary/index.js +2 -0
  43. package/dist/FileDrop/FileDrop.d.ts +34 -0
  44. package/dist/FileDrop/FileDrop.js +145 -0
  45. package/dist/FileDrop/FileDrop.js.map +1 -0
  46. package/dist/FileDrop/index.d.ts +3 -0
  47. package/dist/FileDrop/index.js +2 -0
  48. package/dist/Filters/Filters.js +2 -0
  49. package/dist/Filters/Filters.js.map +1 -1
  50. package/dist/Footer/Footer.d.ts +37 -0
  51. package/dist/Footer/Footer.js +63 -0
  52. package/dist/Footer/Footer.js.map +1 -0
  53. package/dist/Footer/index.d.ts +3 -0
  54. package/dist/Footer/index.js +2 -0
  55. package/dist/Hairline/Hairline.d.ts +16 -0
  56. package/dist/Hairline/Hairline.js +23 -0
  57. package/dist/Hairline/Hairline.js.map +1 -0
  58. package/dist/Hairline/index.d.ts +3 -0
  59. package/dist/Hairline/index.js +2 -0
  60. package/dist/Hint/Hint.js +20 -1
  61. package/dist/Hint/Hint.js.map +1 -1
  62. package/dist/Kbd/Kbd.d.ts +7 -0
  63. package/dist/Kbd/Kbd.js +20 -0
  64. package/dist/Kbd/Kbd.js.map +1 -0
  65. package/dist/Kbd/index.d.ts +3 -0
  66. package/dist/Kbd/index.js +2 -0
  67. package/dist/ListRow/ListRow.d.ts +6 -2
  68. package/dist/ListRow/ListRow.js +5 -1
  69. package/dist/ListRow/ListRow.js.map +1 -1
  70. package/dist/Media/Media.d.ts +28 -0
  71. package/dist/Media/Media.js +65 -0
  72. package/dist/Media/Media.js.map +1 -0
  73. package/dist/Media/index.d.ts +3 -0
  74. package/dist/Media/index.js +2 -0
  75. package/dist/Notice/Notice.js +2 -0
  76. package/dist/Notice/Notice.js.map +1 -1
  77. package/dist/NumberField/NumberField.d.ts +32 -0
  78. package/dist/NumberField/NumberField.js +126 -0
  79. package/dist/NumberField/NumberField.js.map +1 -0
  80. package/dist/NumberField/index.d.ts +3 -0
  81. package/dist/NumberField/index.js +2 -0
  82. package/dist/PageNav/PageNav.d.ts +25 -0
  83. package/dist/PageNav/PageNav.js +57 -0
  84. package/dist/PageNav/PageNav.js.map +1 -0
  85. package/dist/PageNav/index.d.ts +3 -0
  86. package/dist/PageNav/index.js +2 -0
  87. package/dist/Pages/Pages.js +2 -0
  88. package/dist/Pages/Pages.js.map +1 -1
  89. package/dist/PinField/PinField.d.ts +26 -0
  90. package/dist/PinField/PinField.js +73 -0
  91. package/dist/PinField/PinField.js.map +1 -0
  92. package/dist/PinField/index.d.ts +3 -0
  93. package/dist/PinField/index.js +2 -0
  94. package/dist/Prose/Prose.d.ts +15 -0
  95. package/dist/Prose/Prose.js +25 -0
  96. package/dist/Prose/Prose.js.map +1 -0
  97. package/dist/Prose/index.d.ts +3 -0
  98. package/dist/Prose/index.js +2 -0
  99. package/dist/Quote/Quote.d.ts +19 -0
  100. package/dist/Quote/Quote.js +52 -0
  101. package/dist/Quote/Quote.js.map +1 -0
  102. package/dist/Quote/index.d.ts +3 -0
  103. package/dist/Quote/index.js +2 -0
  104. package/dist/Rail/Rail.d.ts +37 -0
  105. package/dist/Rail/Rail.js +61 -0
  106. package/dist/Rail/Rail.js.map +1 -0
  107. package/dist/Rail/index.d.ts +3 -0
  108. package/dist/Rail/index.js +2 -0
  109. package/dist/Range/Range.d.ts +1 -1
  110. package/dist/Range/Range.js.map +1 -1
  111. package/dist/Rating/Rating.js +2 -0
  112. package/dist/Rating/Rating.js.map +1 -1
  113. package/dist/Search/Search.d.ts +1 -1
  114. package/dist/Search/Search.js +2 -0
  115. package/dist/Search/Search.js.map +1 -1
  116. package/dist/SecretField/SecretField.d.ts +17 -0
  117. package/dist/SecretField/SecretField.js +59 -0
  118. package/dist/SecretField/SecretField.js.map +1 -0
  119. package/dist/SecretField/index.d.ts +3 -0
  120. package/dist/SecretField/index.js +2 -0
  121. package/dist/Settings/Settings.js +2 -0
  122. package/dist/Settings/Settings.js.map +1 -1
  123. package/dist/SkipLink/SkipLink.d.ts +22 -0
  124. package/dist/SkipLink/SkipLink.js +32 -0
  125. package/dist/SkipLink/SkipLink.js.map +1 -0
  126. package/dist/SkipLink/index.d.ts +3 -0
  127. package/dist/SkipLink/index.js +2 -0
  128. package/dist/SlurpProvider/SlurpProvider.d.ts +7 -1
  129. package/dist/SlurpProvider/SlurpProvider.js +14 -6
  130. package/dist/SlurpProvider/SlurpProvider.js.map +1 -1
  131. package/dist/Steps/Steps.js +2 -0
  132. package/dist/Steps/Steps.js.map +1 -1
  133. package/dist/Suggest/Suggest.js +2 -0
  134. package/dist/Suggest/Suggest.js.map +1 -1
  135. package/dist/Table/Table.js +2 -0
  136. package/dist/Table/Table.js.map +1 -1
  137. package/dist/Tag/Tag.d.ts +14 -0
  138. package/dist/Tag/Tag.js +26 -0
  139. package/dist/Tag/Tag.js.map +1 -0
  140. package/dist/Tag/index.d.ts +3 -0
  141. package/dist/Tag/index.js +2 -0
  142. package/dist/Toast/Toast.js +31 -7
  143. package/dist/Toast/Toast.js.map +1 -1
  144. package/dist/index.d.ts +45 -4
  145. package/dist/index.js +23 -1
  146. package/dist/internal/labels.js +12 -0
  147. package/dist/internal/labels.js.map +1 -0
  148. package/dist/lib/labels.d.ts +175 -0
  149. package/dist/lib/labels.js +116 -0
  150. package/dist/lib/labels.js.map +1 -0
  151. package/dist/lib/theme.d.ts +98 -3
  152. package/dist/lib/theme.js.map +1 -1
  153. package/dist/styles.css +1435 -127
  154. package/dist/tokens.css +10 -0
  155. package/dist/utils/focus.d.ts +1 -1
  156. package/dist/utils/focus.js +2 -2
  157. package/dist/utils/focus.js.map +1 -1
  158. package/dist/utils/index.d.ts +3 -1
  159. package/dist/utils/index.js +3 -1
  160. package/dist/utils/useClipboard.d.ts +14 -0
  161. package/dist/utils/useClipboard.js +30 -0
  162. package/dist/utils/useClipboard.js.map +1 -0
  163. package/dist/utils/useScrollSpy.d.ts +14 -0
  164. package/dist/utils/useScrollSpy.js +27 -0
  165. package/dist/utils/useScrollSpy.js.map +1 -0
  166. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"Filters.js","names":[],"sources":["../../src/Filters/Filters.tsx"],"sourcesContent":["import { ResetIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface FiltersLabels {\n title: string;\n reset: string;\n}\n\nexport const FILTERS_LABELS: FiltersLabels = { title: 'Filtri', reset: 'Azzera filtri' };\n\nexport interface FiltersOwnProps {\n /** Clears every filter. Off (muted outline) when nothing is active. */\n onReset?: () => void;\n /** How many filters are active: the reset is disabled at 0. */\n active?: number;\n labels?: Partial<FiltersLabels>;\n /** Filters.Group elements. */\n children?: ReactNode;\n}\n\nexport type FiltersProps<E extends ElementType = 'div'> = PolymorphicProps<E, FiltersOwnProps>;\n\n/**\n * Filter panel content (in the Dock's panel or a Sheet): a title, \"Azzera filtri\" at the top right, then groups of\n * chips.\n */\nfunction FiltersRoot<E extends ElementType = 'div'>(props: FiltersProps<E>) {\n const {\n as,\n css,\n className,\n onReset,\n active = 0,\n labels: labelsProp,\n children,\n ...rest\n } = useThemeProps('Filters', props as FiltersProps);\n const labels = { ...FILTERS_LABELS, ...labelsProp };\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Filters', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-filters', styled.className, className)} {...root}>\n <div className=\"slurp-filters-head\">\n <h2 className=\"slurp-filters-title\">{labels.title}</h2>\n {onReset && (\n <button\n type=\"button\"\n className=\"slurp-filters-reset\"\n disabled={active === 0}\n onClick={onReset}\n >\n <ResetIcon size={16} />\n {labels.reset}\n </button>\n )}\n </div>\n {children}\n </Root>\n </>\n );\n}\n\nexport interface FiltersGroupProps {\n /** Name of the group (\"Condizione\"). */\n label: ReactNode;\n /** Chips. */\n children?: ReactNode;\n className?: string;\n}\n\n/** A group of filter chips with its name (a fieldset and legend). */\nfunction FiltersGroup({ label, children, className }: FiltersGroupProps) {\n const id = useId();\n return (\n <div role=\"group\" aria-labelledby={id} className={cx('slurp-filters-group', className)}>\n <span id={id} className=\"slurp-filters-legend\">\n {label}\n </span>\n <div className=\"slurp-filters-chips\">{children}</div>\n </div>\n );\n}\n\nexport const Filters = Object.assign(FiltersRoot, { Group: FiltersGroup });\nexport { FiltersGroup };\n"],"mappings":";;;;;;;;AAaA,MAAa,iBAAgC;CAAE,OAAO;CAAU,OAAO;AAAgB;;;;;AAkBvF,SAAS,YAA2C,OAAwB;CAC1E,MAAM,EACJ,IACA,KACA,WACA,SACA,SAAS,GACT,QAAQ,YACR,UACA,GAAG,SACD,cAAc,WAAW,KAAqB;CAClD,MAAM,SAAS;EAAE,GAAG;EAAgB,GAAG;CAAW;CAClD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,WAAW,QAAQ,GAAG;CAC5C,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,qBAAC,MAAD;EAAM,WAAW,GAAG,iBAAiB,OAAO,WAAW,SAAS;EAAG,GAAI;EAAvE,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,MAAD;IAAI,WAAU;IAAuB,UAAA,OAAO;GAAU,CAAA,GACrD,WACC,qBAAC,UAAD;IACE,MAAK;IACL,WAAU;IACV,UAAU,WAAW;IACrB,SAAS;IAJX,UAAA,CAME,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,GACrB,OAAO,KACF;GAEP,CAAA,CAAA;EACJ,CAAA,GAAA,QACG;CACN,CAAA,CAAA,EAAA,CAAA;AAEN;;AAWA,SAAS,aAAa,EAAE,OAAO,UAAU,aAAgC;CACvE,MAAM,KAAK,MAAM;CACjB,OACE,qBAAC,OAAD;EAAK,MAAK;EAAQ,mBAAiB;EAAI,WAAW,GAAG,uBAAuB,SAAS;EAArF,UAAA,CACE,oBAAC,QAAD;GAAU;GAAI,WAAU;GACrB,UAAA;EACG,CAAA,GACN,oBAAC,OAAD;GAAK,WAAU;GAAuB;EAAc,CAAA,CACjD;;AAET;AAEA,MAAa,UAAU,OAAO,OAAO,aAAa,EAAE,OAAO,aAAa,CAAC"}
1
+ {"version":3,"file":"Filters.js","names":[],"sources":["../../src/Filters/Filters.tsx"],"sourcesContent":["import { ResetIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ElementType, type ReactNode } from 'react';\n\nimport { useLabels } from '../internal/labels';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface FiltersLabels {\n title: string;\n reset: string;\n}\n\nexport const FILTERS_LABELS: FiltersLabels = { title: 'Filtri', reset: 'Azzera filtri' };\n\nexport interface FiltersOwnProps {\n /** Clears every filter. Off (muted outline) when nothing is active. */\n onReset?: () => void;\n /** How many filters are active: the reset is disabled at 0. */\n active?: number;\n labels?: Partial<FiltersLabels>;\n /** Filters.Group elements. */\n children?: ReactNode;\n}\n\nexport type FiltersProps<E extends ElementType = 'div'> = PolymorphicProps<E, FiltersOwnProps>;\n\n/**\n * Filter panel content (in the Dock's panel or a Sheet): a title, \"Azzera filtri\" at the top right, then groups of\n * chips.\n */\nfunction FiltersRoot<E extends ElementType = 'div'>(props: FiltersProps<E>) {\n const {\n as,\n css,\n className,\n onReset,\n active = 0,\n labels: labelsProp,\n children,\n ...rest\n } = useThemeProps('Filters', props as FiltersProps);\n const labels = { ...FILTERS_LABELS, ...useLabels('Filters'), ...labelsProp };\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Filters', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-filters', styled.className, className)} {...root}>\n <div className=\"slurp-filters-head\">\n <h2 className=\"slurp-filters-title\">{labels.title}</h2>\n {onReset && (\n <button\n type=\"button\"\n className=\"slurp-filters-reset\"\n disabled={active === 0}\n onClick={onReset}\n >\n <ResetIcon size={16} />\n {labels.reset}\n </button>\n )}\n </div>\n {children}\n </Root>\n </>\n );\n}\n\nexport interface FiltersGroupProps {\n /** Name of the group (\"Condizione\"). */\n label: ReactNode;\n /** Chips. */\n children?: ReactNode;\n className?: string;\n}\n\n/** A group of filter chips with its name (a fieldset and legend). */\nfunction FiltersGroup({ label, children, className }: FiltersGroupProps) {\n const id = useId();\n return (\n <div role=\"group\" aria-labelledby={id} className={cx('slurp-filters-group', className)}>\n <span id={id} className=\"slurp-filters-legend\">\n {label}\n </span>\n <div className=\"slurp-filters-chips\">{children}</div>\n </div>\n );\n}\n\nexport const Filters = Object.assign(FiltersRoot, { Group: FiltersGroup });\nexport { FiltersGroup };\n"],"mappings":";;;;;;;;;AAcA,MAAa,iBAAgC;CAAE,OAAO;CAAU,OAAO;AAAgB;;;;;AAkBvF,SAAS,YAA2C,OAAwB;CAC1E,MAAM,EACJ,IACA,KACA,WACA,SACA,SAAS,GACT,QAAQ,YACR,UACA,GAAG,SACD,cAAc,WAAW,KAAqB;CAClD,MAAM,SAAS;EAAE,GAAG;EAAgB,GAAG,UAAU,SAAS;EAAG,GAAG;CAAW;CAC3E,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,WAAW,QAAQ,GAAG;CAC5C,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,qBAAC,MAAD;EAAM,WAAW,GAAG,iBAAiB,OAAO,WAAW,SAAS;EAAG,GAAI;EAAvE,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,MAAD;IAAI,WAAU;IAAuB,UAAA,OAAO;GAAU,CAAA,GACrD,WACC,qBAAC,UAAD;IACE,MAAK;IACL,WAAU;IACV,UAAU,WAAW;IACrB,SAAS;IAJX,UAAA,CAME,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,GACrB,OAAO,KACF;GAEP,CAAA,CAAA;EACJ,CAAA,GAAA,QACG;CACN,CAAA,CAAA,EAAA,CAAA;AAEN;;AAWA,SAAS,aAAa,EAAE,OAAO,UAAU,aAAgC;CACvE,MAAM,KAAK,MAAM;CACjB,OACE,qBAAC,OAAD;EAAK,MAAK;EAAQ,mBAAiB;EAAI,WAAW,GAAG,uBAAuB,SAAS;EAArF,UAAA,CACE,oBAAC,QAAD;GAAU;GAAI,WAAU;GACrB,UAAA;EACG,CAAA,GACN,oBAAC,OAAD;GAAK,WAAU;GAAuB;EAAc,CAAA,CACjD;;AAET;AAEA,MAAa,UAAU,OAAO,OAAO,aAAa,EAAE,OAAO,aAAa,CAAC"}
@@ -0,0 +1,37 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType, ReactNode } from "react";
4
+ export interface FooterOwnProps {
5
+ /** Groups of links (`Footer.Group`), then `Footer.Bottom`. */
6
+ children?: ReactNode;
7
+ }
8
+ export type FooterProps<E extends ElementType = 'footer'> = PolymorphicProps<E, FooterOwnProps>;
9
+ /**
10
+ * The foot of a site: groups of links in columns and a bottom line (legal, version, language). The Dock replaces the
11
+ * header, not the footer.
12
+ */
13
+ declare function FooterRoot<E extends ElementType = 'footer'>(props: FooterProps<E>): import("react").JSX.Element;
14
+ export interface FooterGroupProps {
15
+ /** Shown as an eyebrow above the links, and names the list. */
16
+ title: ReactNode;
17
+ children?: ReactNode;
18
+ className?: string;
19
+ }
20
+ /** A column of links under a title. */
21
+ declare function FooterGroup({ title, children, className }: FooterGroupProps): import("react").JSX.Element;
22
+ export type FooterLinkProps<E extends ElementType = 'a'> = PolymorphicProps<E>;
23
+ /** A link of a group; `as` renders your router's link. */
24
+ declare function FooterLink<E extends ElementType = 'a'>(props: FooterLinkProps<E>): import("react").JSX.Element;
25
+ /** The bottom line: small print, version, language. */
26
+ declare function FooterBottom({ children, className }: {
27
+ children?: ReactNode;
28
+ className?: string;
29
+ }): import("react").JSX.Element;
30
+ type FooterComponent = typeof FooterRoot & {
31
+ Group: typeof FooterGroup;
32
+ Link: typeof FooterLink;
33
+ Bottom: typeof FooterBottom;
34
+ };
35
+ export declare const Footer: FooterComponent;
36
+ export { FooterBottom, FooterGroup, FooterLink };
37
+ //# sourceMappingURL=Footer.d.ts.map
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import { cx } from "../utils/src/index.js";
3
+ import { useAnimationRoot } from "../internal/animation.js";
4
+ import { useCss, useThemeProps } from "../internal/styled.js";
5
+ import { useId } from "react";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ // src/Footer/Footer.tsx
8
+ /**
9
+ * The foot of a site: groups of links in columns and a bottom line (legal, version, language). The Dock replaces the
10
+ * header, not the footer.
11
+ */
12
+ function FooterRoot(props) {
13
+ const { as, css, className, children, ...rest } = useThemeProps("Footer", props);
14
+ const Root = as ?? "footer";
15
+ const styled = useCss("Footer", "root", css);
16
+ const root = useAnimationRoot(rest);
17
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
18
+ className: cx("slurp-footer", styled.className, className),
19
+ ...root,
20
+ children
21
+ })] });
22
+ }
23
+ /** A column of links under a title. */
24
+ function FooterGroup({ title, children, className }) {
25
+ const id = useId();
26
+ return /* @__PURE__ */ jsxs("div", {
27
+ className: cx("slurp-footer-group", className),
28
+ children: [/* @__PURE__ */ jsx("p", {
29
+ className: "slurp-footer-title",
30
+ id,
31
+ children: title
32
+ }), /* @__PURE__ */ jsx("ul", {
33
+ className: "slurp-footer-list",
34
+ "aria-labelledby": id,
35
+ children
36
+ })]
37
+ });
38
+ }
39
+ /** A link of a group; `as` renders your router's link. */
40
+ function FooterLink(props) {
41
+ const { as, css: _css, className, ...rest } = props;
42
+ const Root = as ?? "a";
43
+ const root = useAnimationRoot(rest);
44
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Root, {
45
+ className: cx("slurp-footer-link", className),
46
+ ...root
47
+ }) });
48
+ }
49
+ /** The bottom line: small print, version, language. */
50
+ function FooterBottom({ children, className }) {
51
+ return /* @__PURE__ */ jsx("div", {
52
+ className: cx("slurp-footer-bottom", className),
53
+ children
54
+ });
55
+ }
56
+ const Footer = Object.assign(FooterRoot, {
57
+ Group: FooterGroup,
58
+ Link: FooterLink,
59
+ Bottom: FooterBottom
60
+ });
61
+ export { Footer, FooterBottom, FooterGroup, FooterLink };
62
+
63
+ //# sourceMappingURL=Footer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Footer.js","names":[],"sources":["../../src/Footer/Footer.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport { useId, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface FooterOwnProps {\n /** Groups of links (`Footer.Group`), then `Footer.Bottom`. */\n children?: ReactNode;\n}\n\nexport type FooterProps<E extends ElementType = 'footer'> = PolymorphicProps<E, FooterOwnProps>;\n\n/**\n * The foot of a site: groups of links in columns and a bottom line (legal, version, language). The Dock replaces the\n * header, not the footer.\n */\nfunction FooterRoot<E extends ElementType = 'footer'>(props: FooterProps<E>) {\n const { as, css, className, children, ...rest } = useThemeProps('Footer', props as FooterProps);\n const Root = (as ?? 'footer') as ElementType;\n const styled = useCss('Footer', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-footer', styled.className, className)} {...root}>\n {children}\n </Root>\n </>\n );\n}\n\nexport interface FooterGroupProps {\n /** Shown as an eyebrow above the links, and names the list. */\n title: ReactNode;\n children?: ReactNode;\n className?: string;\n}\n\n/** A column of links under a title. */\nfunction FooterGroup({ title, children, className }: FooterGroupProps) {\n const id = useId();\n return (\n <div className={cx('slurp-footer-group', className)}>\n <p className=\"slurp-footer-title\" id={id}>\n {title}\n </p>\n <ul className=\"slurp-footer-list\" aria-labelledby={id}>\n {children}\n </ul>\n </div>\n );\n}\n\nexport type FooterLinkProps<E extends ElementType = 'a'> = PolymorphicProps<E>;\n\n/** A link of a group; `as` renders your router's link. */\nfunction FooterLink<E extends ElementType = 'a'>(props: FooterLinkProps<E>) {\n const { as, css: _css, className, ...rest } = props as FooterLinkProps;\n const Root = (as ?? 'a') as ElementType;\n const root = useAnimationRoot(rest);\n return (\n <li>\n <Root className={cx('slurp-footer-link', className)} {...root} />\n </li>\n );\n}\n\n/** The bottom line: small print, version, language. */\nfunction FooterBottom({ children, className }: { children?: ReactNode; className?: string }) {\n return <div className={cx('slurp-footer-bottom', className)}>{children}</div>;\n}\n\ntype FooterComponent = typeof FooterRoot & {\n Group: typeof FooterGroup;\n Link: typeof FooterLink;\n Bottom: typeof FooterBottom;\n};\n\nexport const Footer = Object.assign(FooterRoot, {\n Group: FooterGroup,\n Link: FooterLink,\n Bottom: FooterBottom,\n}) as FooterComponent;\nexport { FooterBottom, FooterGroup, FooterLink };\n"],"mappings":";;;;;;;;;;;AAkBA,SAAS,WAA6C,OAAuB;CAC3E,MAAM,EAAE,IAAI,KAAK,WAAW,UAAU,GAAG,SAAS,cAAc,UAAU,KAAoB;CAC9F,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG;CAC3C,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,gBAAgB,OAAO,WAAW,SAAS;EAAG,GAAI;EACnE;CACG,CAAA,CACN,EAAA,CAAA;AAEN;;AAUA,SAAS,YAAY,EAAE,OAAO,UAAU,aAA+B;CACrE,MAAM,KAAK,MAAM;CACjB,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,sBAAsB,SAAS;EAAlD,UAAA,CACE,oBAAC,KAAD;GAAG,WAAU;GAAyB;GACnC,UAAA;EACA,CAAA,GACH,oBAAC,MAAD;GAAI,WAAU;GAAoB,mBAAiB;GAChD;EACC,CAAA,CACD;;AAET;;AAKA,SAAS,WAAwC,OAA2B;CAC1E,MAAM,EAAE,IAAI,KAAK,MAAM,WAAW,GAAG,SAAS;CAC9C,MAAM,OAAQ,MAAM;CACpB,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,oBAAC,MAAD,EAAA,UACE,oBAAC,MAAD;EAAM,WAAW,GAAG,qBAAqB,SAAS;EAAG,GAAI;CAAO,CAAA,EAC9D,CAAA;AAER;;AAGA,SAAS,aAAa,EAAE,UAAU,aAA2D;CAC3F,OAAO,oBAAC,OAAD;EAAK,WAAW,GAAG,uBAAuB,SAAS;EAAI;CAAc,CAAA;AAC9E;AAQA,MAAa,SAAS,OAAO,OAAO,YAAY;CAC9C,OAAO;CACP,MAAM;CACN,QAAQ;AACV,CAAC"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Footer, FooterBottom, FooterGroup, FooterGroupProps, FooterLink, FooterLinkProps, FooterProps } from "./Footer.js";
3
+ export { Footer, FooterBottom, FooterGroup, type FooterGroupProps, FooterLink, type FooterLinkProps, type FooterProps, Footer as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Footer, FooterBottom, FooterGroup, FooterLink, Footer as default } from "./Footer.js";
@@ -0,0 +1,16 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType } from "react";
4
+ export interface HairlineOwnProps {
5
+ /** Default `horizontal`. A vertical hairline takes the height of its row. */
6
+ orientation?: 'horizontal' | 'vertical';
7
+ /**
8
+ * Default true: a visual rhythm only, hidden from assistive tech. Set false when it separates two sections in
9
+ * meaning (then it is announced as a separator).
10
+ */
11
+ decorative?: boolean;
12
+ }
13
+ export type HairlineProps<E extends ElementType = 'hr'> = PolymorphicProps<E, HairlineOwnProps>;
14
+ /** A 1px line in the `line` colour, to separate groups where space alone is not enough. */
15
+ export declare function Hairline<E extends ElementType = 'hr'>(props: HairlineProps<E>): import("react").JSX.Element;
16
+ //# sourceMappingURL=Hairline.d.ts.map
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { cx } from "../utils/src/index.js";
3
+ import { useAnimationRoot } from "../internal/animation.js";
4
+ import { useCss, useThemeProps } from "../internal/styled.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ // src/Hairline/Hairline.tsx
7
+ /** A 1px line in the `line` colour, to separate groups where space alone is not enough. */
8
+ function Hairline(props) {
9
+ const { as, css, className, orientation = "horizontal", decorative = true, ...rest } = useThemeProps("Hairline", props);
10
+ const Root = as ?? "hr";
11
+ const styled = useCss("Hairline", "root", css);
12
+ const root = useAnimationRoot(rest);
13
+ return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
14
+ className: cx("slurp-hairline", styled.className, className),
15
+ "data-orientation": orientation,
16
+ "aria-hidden": decorative || void 0,
17
+ "aria-orientation": !decorative && orientation === "vertical" ? "vertical" : void 0,
18
+ ...root
19
+ })] });
20
+ }
21
+ export { Hairline };
22
+
23
+ //# sourceMappingURL=Hairline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hairline.js","names":[],"sources":["../../src/Hairline/Hairline.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface HairlineOwnProps {\n /** Default `horizontal`. A vertical hairline takes the height of its row. */\n orientation?: 'horizontal' | 'vertical';\n /**\n * Default true: a visual rhythm only, hidden from assistive tech. Set false when it separates two sections in\n * meaning (then it is announced as a separator).\n */\n decorative?: boolean;\n}\n\nexport type HairlineProps<E extends ElementType = 'hr'> = PolymorphicProps<E, HairlineOwnProps>;\n\n/** A 1px line in the `line` colour, to separate groups where space alone is not enough. */\nexport function Hairline<E extends ElementType = 'hr'>(props: HairlineProps<E>) {\n const {\n as,\n css,\n className,\n orientation = 'horizontal',\n decorative = true,\n ...rest\n } = useThemeProps('Hairline', props as HairlineProps);\n const Root = (as ?? 'hr') as ElementType;\n const styled = useCss('Hairline', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-hairline', styled.className, className)}\n data-orientation={orientation}\n aria-hidden={decorative || undefined}\n aria-orientation={!decorative && orientation === 'vertical' ? 'vertical' : undefined}\n {...root}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;AAoBA,SAAgB,SAAuC,OAAyB;CAC9E,MAAM,EACJ,IACA,KACA,WACA,cAAc,cACd,aAAa,MACb,GAAG,SACD,cAAc,YAAY,KAAsB;CACpD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,YAAY,QAAQ,GAAG;CAC7C,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EACE,WAAW,GAAG,kBAAkB,OAAO,WAAW,SAAS;EAC3D,oBAAkB;EAClB,eAAa,cAAc,KAAA;EAC3B,oBAAkB,CAAC,cAAc,gBAAgB,aAAa,aAAa,KAAA;EAC3E,GAAI;CACL,CAAA,CACD,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Hairline, HairlineProps } from "./Hairline.js";
3
+ export { Hairline, type HairlineProps, Hairline as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Hairline, Hairline as default } from "./Hairline.js";
package/dist/Hint/Hint.js CHANGED
@@ -7,6 +7,14 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  // src/Hint/Hint.tsx
8
8
  const GAP = 8;
9
9
  const EDGE = 8;
10
+ /** After a hint closes, the next one within this window (ms) shows at once and without its entrance. */
11
+ const WARM_MS = 300;
12
+ /** Shared by every Hint: moving along a row of icons, only the first hint waits. */
13
+ const warm = {
14
+ open: 0,
15
+ until: 0
16
+ };
17
+ const isWarm = () => warm.open > 0 || Date.now() < warm.until;
10
18
  /**
11
19
  * Tooltip: shows on hover (after `delay`) and on focus, hides on Escape, blur or leave; it stays while the pointer is
12
20
  * over it (WCAG 1.4.13). Linked to the trigger with aria-describedby. Rendered in the top layer (popover).
@@ -15,6 +23,7 @@ function Hint(props) {
15
23
  const { content, children, placement = "top", delay = 400, className, css } = useThemeProps("Hint", props);
16
24
  const id = useId();
17
25
  const [open, setOpen] = useState(false);
26
+ const [instant, setInstant] = useState(false);
18
27
  const [side, setSide] = useState(placement);
19
28
  const trigger = useRef(null);
20
29
  const tip = useRef(null);
@@ -27,13 +36,20 @@ function Hint(props) {
27
36
  clearTimeout(timer.current);
28
37
  timer.current = setTimeout(fn, ms);
29
38
  };
30
- const show = (now) => later(() => setOpen(true), now ? 0 : delay);
39
+ const show = (now) => {
40
+ const skip = isWarm();
41
+ later(() => {
42
+ setInstant(skip);
43
+ setOpen(true);
44
+ }, now || skip ? 0 : delay);
45
+ };
31
46
  const hide = () => later(() => setOpen(false), 100);
32
47
  useEffect(() => () => clearTimeout(timer.current), []);
33
48
  useLayoutEffect(() => {
34
49
  const el = tip.current;
35
50
  const anchor = trigger.current;
36
51
  if (!open || !el || !anchor) return;
52
+ warm.open++;
37
53
  el.showPopover?.();
38
54
  const place = () => {
39
55
  const a = anchor.getBoundingClientRect();
@@ -60,6 +76,8 @@ function Hint(props) {
60
76
  removeEventListener("scroll", place, true);
61
77
  removeEventListener("resize", place);
62
78
  el.hidePopover?.();
79
+ warm.open--;
80
+ warm.until = Date.now() + WARM_MS;
63
81
  };
64
82
  }, [open, placement]);
65
83
  const triggerElement = isValidElement(child) ? cloneElement(child, {
@@ -92,6 +110,7 @@ function Hint(props) {
92
110
  popover: "manual",
93
111
  className: cx("slurp-hint", styled.className, className),
94
112
  "data-open": open || void 0,
113
+ "data-instant": open && instant || void 0,
95
114
  "data-side": side,
96
115
  onPointerEnter: () => clearTimeout(timer.current),
97
116
  onPointerLeave: hide,
@@ -1 +1 @@
1
- {"version":3,"file":"Hint.js","names":[],"sources":["../../src/Hint/Hint.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n Children,\n cloneElement,\n isValidElement,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type FocusEvent,\n type PointerEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { SlurpCss } from '../lib/css';\nimport { useForkRef } from '../utils/useForkRef';\n\nexport interface HintProps {\n /** The text: short, never essential (the trigger must make sense without it). */\n content: ReactNode;\n /** One element that takes focus (a button, a link). */\n children: ReactElement;\n /** Preferred side; it flips when there is no room. Default `top`. */\n placement?: 'top' | 'bottom';\n /** Hover delay in ms before it shows (focus shows it at once). Default 400. */\n delay?: number;\n className?: string;\n css?: SlurpCss;\n}\n\ntype TriggerProps = {\n ref?: Ref<HTMLElement>;\n 'aria-describedby'?: string;\n onPointerEnter?: (e: PointerEvent<HTMLElement>) => void;\n onPointerLeave?: (e: PointerEvent<HTMLElement>) => void;\n onFocus?: (e: FocusEvent<HTMLElement>) => void;\n onBlur?: (e: FocusEvent<HTMLElement>) => void;\n};\n\nconst GAP = 8;\nconst EDGE = 8;\n\n/**\n * Tooltip: shows on hover (after `delay`) and on focus, hides on Escape, blur or leave; it stays while the pointer is\n * over it (WCAG 1.4.13). Linked to the trigger with aria-describedby. Rendered in the top layer (popover).\n */\nexport function Hint(props: HintProps) {\n const {\n content,\n children,\n placement = 'top',\n delay = 400,\n className,\n css,\n } = useThemeProps('Hint', props);\n const id = useId();\n const [open, setOpen] = useState(false);\n const [side, setSide] = useState(placement);\n const trigger = useRef<HTMLElement>(null);\n const tip = useRef<HTMLSpanElement>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined);\n const styled = useCss('Hint', 'root', css);\n\n const child = Children.only(children);\n const childProps = (isValidElement(child) ? child.props : {}) as TriggerProps;\n const ref = useForkRef(childProps.ref, trigger);\n\n const later = (fn: () => void, ms: number) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(fn, ms);\n };\n const show = (now: boolean) => later(() => setOpen(true), now ? 0 : delay);\n const hide = () => later(() => setOpen(false), 100);\n\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useLayoutEffect(() => {\n const el = tip.current;\n const anchor = trigger.current;\n if (!open || !el || !anchor) return;\n el.showPopover?.();\n const place = () => {\n const a = anchor.getBoundingClientRect();\n const t = el.getBoundingClientRect();\n const above = a.top - GAP - t.height;\n const below = a.bottom + GAP;\n const fitsAbove = above >= EDGE;\n const fitsBelow = below + t.height <= innerHeight - EDGE;\n const top =\n placement === 'top'\n ? fitsAbove || !fitsBelow\n ? 'top'\n : 'bottom'\n : fitsBelow || !fitsAbove\n ? 'bottom'\n : 'top';\n const left = Math.min(\n Math.max(EDGE, a.left + a.width / 2 - t.width / 2),\n innerWidth - EDGE - t.width,\n );\n el.style.left = `${left}px`;\n el.style.top = `${top === 'top' ? above : below}px`;\n setSide(top);\n };\n place();\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') setOpen(false);\n };\n document.addEventListener('keydown', onKey);\n addEventListener('scroll', place, true);\n addEventListener('resize', place);\n return () => {\n document.removeEventListener('keydown', onKey);\n removeEventListener('scroll', place, true);\n removeEventListener('resize', place);\n el.hidePopover?.();\n };\n }, [open, placement]);\n\n const triggerElement = isValidElement(child)\n ? // eslint-disable-next-line react-hooks/refs -- the timer ref is read by event handlers, not during render\n cloneElement(child as ReactElement<TriggerProps>, {\n ref,\n 'aria-describedby': cx(childProps['aria-describedby'], id),\n onPointerEnter: (e) => {\n childProps.onPointerEnter?.(e);\n if (e.pointerType !== 'touch') show(false);\n },\n onPointerLeave: (e) => {\n childProps.onPointerLeave?.(e);\n hide();\n },\n onFocus: (e) => {\n childProps.onFocus?.(e);\n show(true);\n },\n onBlur: (e) => {\n childProps.onBlur?.(e);\n later(() => setOpen(false), 0);\n },\n })\n : child;\n\n return (\n <>\n {styled.style}\n {triggerElement}\n <span\n ref={tip}\n id={id}\n role=\"tooltip\"\n popover=\"manual\"\n className={cx('slurp-hint', styled.className, className)}\n data-open={open || undefined}\n data-side={side}\n onPointerEnter={() => clearTimeout(timer.current)}\n onPointerLeave={hide}\n >\n {content}\n </span>\n </>\n );\n}\n"],"mappings":";;;;;;;AA2CA,MAAM,MAAM;AACZ,MAAM,OAAO;;;;;AAMb,SAAgB,KAAK,OAAkB;CACrC,MAAM,EACJ,SACA,UACA,YAAY,OACZ,QAAQ,KACR,WACA,QACE,cAAc,QAAQ,KAAK;CAC/B,MAAM,KAAK,MAAM;CACjB,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,CAAC,MAAM,WAAW,SAAS,SAAS;CAC1C,MAAM,UAAU,OAAoB,IAAI;CACxC,MAAM,MAAM,OAAwB,IAAI;CACxC,MAAM,QAAQ,OAAsC,KAAA,CAAS;CAC7D,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CAEzC,MAAM,QAAQ,SAAS,KAAK,QAAQ;CACpC,MAAM,aAAc,eAAe,KAAK,IAAI,MAAM,QAAQ,CAAC;CAC3D,MAAM,MAAM,WAAW,WAAW,KAAK,OAAO;CAE9C,MAAM,SAAS,IAAgB,OAAe;EAC5C,aAAa,MAAM,OAAO;EAC1B,MAAM,UAAU,WAAW,IAAI,EAAE;CACnC;CACA,MAAM,QAAQ,QAAiB,YAAY,QAAQ,IAAI,GAAG,MAAM,IAAI,KAAK;CACzE,MAAM,aAAa,YAAY,QAAQ,KAAK,GAAG,GAAG;CAElD,sBAAsB,aAAa,MAAM,OAAO,GAAG,CAAC,CAAC;CAErD,sBAAsB;EACpB,MAAM,KAAK,IAAI;EACf,MAAM,SAAS,QAAQ;EACvB,IAAI,CAAC,QAAQ,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CAAC;GACtB,KAAK,IAAI;EACX;EACA,SAAS,MAAM;GACb,WAAW,SAAS,CAAC;GACrB,YAAY,QAAQ,KAAK,GAAG,CAAC;EAC/B;CACF,CAAC,IACD;CAEJ,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,oBAAC,QAAD;GACE,KAAK;GACD;GACJ,MAAK;GACL,SAAQ;GACR,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;GACvD,aAAW,QAAQ,KAAA;GACnB,aAAW;GACX,sBAAsB,aAAa,MAAM,OAAO;GAChD,gBAAgB;GAEf,UAAA;EACG,CAAA;CACN,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"Hint.js","names":[],"sources":["../../src/Hint/Hint.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n Children,\n cloneElement,\n isValidElement,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type FocusEvent,\n type PointerEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { SlurpCss } from '../lib/css';\nimport { useForkRef } from '../utils/useForkRef';\n\nexport interface HintProps {\n /** The text: short, never essential (the trigger must make sense without it). */\n content: ReactNode;\n /** One element that takes focus (a button, a link). */\n children: ReactElement;\n /** Preferred side; it flips when there is no room. Default `top`. */\n placement?: 'top' | 'bottom';\n /** Hover delay in ms before it shows (focus shows it at once). Default 400. */\n delay?: number;\n className?: string;\n css?: SlurpCss;\n}\n\ntype TriggerProps = {\n ref?: Ref<HTMLElement>;\n 'aria-describedby'?: string;\n onPointerEnter?: (e: PointerEvent<HTMLElement>) => void;\n onPointerLeave?: (e: PointerEvent<HTMLElement>) => void;\n onFocus?: (e: FocusEvent<HTMLElement>) => void;\n onBlur?: (e: FocusEvent<HTMLElement>) => void;\n};\n\nconst GAP = 8;\nconst EDGE = 8;\n/** After a hint closes, the next one within this window (ms) shows at once and without its entrance. */\nconst WARM_MS = 300;\n\n/** Shared by every Hint: moving along a row of icons, only the first hint waits. */\nconst warm = { open: 0, until: 0 };\nconst isWarm = () => warm.open > 0 || Date.now() < warm.until;\n\n/**\n * Tooltip: shows on hover (after `delay`) and on focus, hides on Escape, blur or leave; it stays while the pointer is\n * over it (WCAG 1.4.13). Linked to the trigger with aria-describedby. Rendered in the top layer (popover).\n */\nexport function Hint(props: HintProps) {\n const {\n content,\n children,\n placement = 'top',\n delay = 400,\n className,\n css,\n } = useThemeProps('Hint', props);\n const id = useId();\n const [open, setOpen] = useState(false);\n const [instant, setInstant] = useState(false);\n const [side, setSide] = useState(placement);\n const trigger = useRef<HTMLElement>(null);\n const tip = useRef<HTMLSpanElement>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined);\n const styled = useCss('Hint', 'root', css);\n\n const child = Children.only(children);\n const childProps = (isValidElement(child) ? child.props : {}) as TriggerProps;\n const ref = useForkRef(childProps.ref, trigger);\n\n const later = (fn: () => void, ms: number) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(fn, ms);\n };\n const show = (now: boolean) => {\n const skip = isWarm();\n later(\n () => {\n setInstant(skip);\n setOpen(true);\n },\n now || skip ? 0 : delay,\n );\n };\n const hide = () => later(() => setOpen(false), 100);\n\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useLayoutEffect(() => {\n const el = tip.current;\n const anchor = trigger.current;\n if (!open || !el || !anchor) return;\n warm.open++;\n el.showPopover?.();\n const place = () => {\n const a = anchor.getBoundingClientRect();\n const t = el.getBoundingClientRect();\n const above = a.top - GAP - t.height;\n const below = a.bottom + GAP;\n const fitsAbove = above >= EDGE;\n const fitsBelow = below + t.height <= innerHeight - EDGE;\n const top =\n placement === 'top'\n ? fitsAbove || !fitsBelow\n ? 'top'\n : 'bottom'\n : fitsBelow || !fitsAbove\n ? 'bottom'\n : 'top';\n const left = Math.min(\n Math.max(EDGE, a.left + a.width / 2 - t.width / 2),\n innerWidth - EDGE - t.width,\n );\n el.style.left = `${left}px`;\n el.style.top = `${top === 'top' ? above : below}px`;\n setSide(top);\n };\n place();\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') setOpen(false);\n };\n document.addEventListener('keydown', onKey);\n addEventListener('scroll', place, true);\n addEventListener('resize', place);\n return () => {\n document.removeEventListener('keydown', onKey);\n removeEventListener('scroll', place, true);\n removeEventListener('resize', place);\n el.hidePopover?.();\n warm.open--;\n warm.until = Date.now() + WARM_MS;\n };\n }, [open, placement]);\n\n const triggerElement = isValidElement(child)\n ? // eslint-disable-next-line react-hooks/refs -- the timer ref is read by event handlers, not during render\n cloneElement(child as ReactElement<TriggerProps>, {\n ref,\n 'aria-describedby': cx(childProps['aria-describedby'], id),\n onPointerEnter: (e) => {\n childProps.onPointerEnter?.(e);\n if (e.pointerType !== 'touch') show(false);\n },\n onPointerLeave: (e) => {\n childProps.onPointerLeave?.(e);\n hide();\n },\n onFocus: (e) => {\n childProps.onFocus?.(e);\n show(true);\n },\n onBlur: (e) => {\n childProps.onBlur?.(e);\n later(() => setOpen(false), 0);\n },\n })\n : child;\n\n return (\n <>\n {styled.style}\n {triggerElement}\n <span\n ref={tip}\n id={id}\n role=\"tooltip\"\n popover=\"manual\"\n className={cx('slurp-hint', styled.className, className)}\n data-open={open || undefined}\n data-instant={(open && instant) || undefined}\n data-side={side}\n onPointerEnter={() => clearTimeout(timer.current)}\n onPointerLeave={hide}\n >\n {content}\n </span>\n </>\n );\n}\n"],"mappings":";;;;;;;AA2CA,MAAM,MAAM;AACZ,MAAM,OAAO;;AAEb,MAAM,UAAU;;AAGhB,MAAM,OAAO;CAAE,MAAM;CAAG,OAAO;AAAE;AACjC,MAAM,eAAe,KAAK,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK;;;;;AAMxD,SAAgB,KAAK,OAAkB;CACrC,MAAM,EACJ,SACA,UACA,YAAY,OACZ,QAAQ,KACR,WACA,QACE,cAAc,QAAQ,KAAK;CAC/B,MAAM,KAAK,MAAM;CACjB,MAAM,CAAC,MAAM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BAAsB,aAAa,MAAM,OAAO;GAChD,gBAAgB;GAEf,UAAA;EACG,CAAA;CACN,EAAA,CAAA;AAEN"}
@@ -0,0 +1,7 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType } from "react";
4
+ export type KbdProps<E extends ElementType = 'kbd'> = PolymorphicProps<E>;
5
+ /** A key of the keyboard ("⌘", "K", "Esc"), for shortcuts in text and menus. */
6
+ export declare function Kbd<E extends ElementType = 'kbd'>(props: KbdProps<E>): import("react").JSX.Element;
7
+ //# sourceMappingURL=Kbd.d.ts.map
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { cx } from "../utils/src/index.js";
3
+ import { useAnimationRoot } from "../internal/animation.js";
4
+ import { useCss, useThemeProps } from "../internal/styled.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ // src/Kbd/Kbd.tsx
7
+ /** A key of the keyboard ("⌘", "K", "Esc"), for shortcuts in text and menus. */
8
+ function Kbd(props) {
9
+ const { as, css, className, ...rest } = useThemeProps("Kbd", props);
10
+ const Root = as ?? "kbd";
11
+ const styled = useCss("Kbd", "root", css);
12
+ const root = useAnimationRoot(rest);
13
+ return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
14
+ className: cx("slurp-kbd", styled.className, className),
15
+ ...root
16
+ })] });
17
+ }
18
+ export { Kbd };
19
+
20
+ //# sourceMappingURL=Kbd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Kbd.js","names":[],"sources":["../../src/Kbd/Kbd.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport type KbdProps<E extends ElementType = 'kbd'> = PolymorphicProps<E>;\n\n/** A key of the keyboard (\"⌘\", \"K\", \"Esc\"), for shortcuts in text and menus. */\nexport function Kbd<E extends ElementType = 'kbd'>(props: KbdProps<E>) {\n const { as, css, className, ...rest } = useThemeProps('Kbd', props as KbdProps);\n const Root = (as ?? 'kbd') as ElementType;\n const styled = useCss('Kbd', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-kbd', styled.className, className)} {...root} />\n </>\n );\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,IAAmC,OAAoB;CACrE,MAAM,EAAE,IAAI,KAAK,WAAW,GAAG,SAAS,cAAc,OAAO,KAAiB;CAC9E,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,OAAO,QAAQ,GAAG;CACxC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,aAAa,OAAO,WAAW,SAAS;EAAG,GAAI;CAAO,CAAA,CAC1E,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Kbd, KbdProps } from "./Kbd.js";
3
+ export { Kbd, type KbdProps, Kbd as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Kbd, Kbd as default } from "./Kbd.js";
@@ -4,12 +4,12 @@ import { ElementType, ReactNode } from "react";
4
4
  export type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;
5
5
  /** A list of ListRows (rows become list items). */
6
6
  export declare function List<E extends ElementType = 'ul'>(props: ListProps<E>): import("react").JSX.Element;
7
- export interface ListRowOwnProps extends PartsProps<'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action'> {
7
+ export interface ListRowOwnProps extends PartsProps<'mark' | 'title' | 'link' | 'tag' | 'meta' | 'value' | 'action'> {
8
8
  title: ReactNode;
9
9
  /** Leading mark (an icon, a logo); default the first letter of the title. */
10
10
  mark?: ReactNode;
11
11
  meta?: ReactNode;
12
- /** Trailing value ("9.1", "1.239 €"). */
12
+ /** Trailing value ("9.1", "24"). */
13
13
  value?: ReactNode;
14
14
  /** Highlight tag next to the title ("Consigliato"): with a check, never colour alone. */
15
15
  tag?: ReactNode;
@@ -17,6 +17,10 @@ export interface ListRowOwnProps extends PartsProps<'mark' | 'title' | 'tag' | '
17
17
  highlighted?: boolean;
18
18
  /** Text of the trailing link; the row's title is added for assistive tech. */
19
19
  actionLabel?: ReactNode;
20
+ /**
21
+ * Where the row leads. With `actionLabel`, the trailing link goes there; without it the title becomes the link and
22
+ * the whole row is its target (one link per row, no extra "Open" button). Router: `parts={{ link: RouterLink }}`.
23
+ */
20
24
  href?: string;
21
25
  }
22
26
  export type ListRowProps<E extends ElementType = 'div'> = PolymorphicProps<E, ListRowOwnProps>;
@@ -52,7 +52,11 @@ function ListRow(props) {
52
52
  className: "slurp-list-row-info",
53
53
  children: [part("title", "span", {
54
54
  className: "slurp-list-row-title",
55
- children: /* @__PURE__ */ jsxs(Fragment$1, { children: [title, tag != null && part("tag", "span", {
55
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [href != null && actionLabel == null ? part("link", "a", {
56
+ className: "slurp-list-row-link",
57
+ href,
58
+ children: title
59
+ }) : title, tag != null && part("tag", "span", {
56
60
  className: "slurp-list-row-tag",
57
61
  children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CheckIcon, { size: 12 }), tag] })
58
62
  })] })
@@ -1 +1 @@
1
- {"version":3,"file":"ListRow.js","names":[],"sources":["../../src/ListRow/ListRow.tsx"],"sourcesContent":["import { CheckIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { createContext, useContext, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nconst InList = createContext(false);\n\nexport type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;\n\n/** A list of ListRows (rows become list items). */\nexport function List<E extends ElementType = 'ul'>(props: ListProps<E>) {\n const { as, css, className, children, ...rest } = useThemeProps('List', props as ListProps);\n const Root = (as ?? 'ul') as ElementType;\n const styled = useCss('List', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-list', styled.className, className)} {...root}>\n <InList value={Root === 'ul' || Root === 'ol'}>{children}</InList>\n </Root>\n </>\n );\n}\n\nexport interface ListRowOwnProps extends PartsProps<\n 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action'\n> {\n title: ReactNode;\n /** Leading mark (an icon, a logo); default the first letter of the title. */\n mark?: ReactNode;\n meta?: ReactNode;\n /** Trailing value (\"9.1\", \"1.239 €\"). */\n value?: ReactNode;\n /** Highlight tag next to the title (\"Consigliato\"): with a check, never colour alone. */\n tag?: ReactNode;\n /** The row is highlighted: accent-soft with an accent-ink outline, and the tag. */\n highlighted?: boolean;\n /** Text of the trailing link; the row's title is added for assistive tech. */\n actionLabel?: ReactNode;\n href?: string;\n}\n\nexport type ListRowProps<E extends ElementType = 'div'> = PolymorphicProps<E, ListRowOwnProps>;\n\n/** Row of a list: mark, title (with an optional highlight tag), meta, a trailing value and one action link. */\nexport function ListRow<E extends ElementType = 'div'>(props: ListRowProps<E>) {\n const {\n as,\n css,\n className,\n title,\n mark,\n meta,\n value,\n tag,\n highlighted = false,\n actionLabel,\n href,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('ListRow', props as ListRowProps);\n const inList = useContext(InList);\n const Root = (as ?? (inList ? 'li' : 'div')) as ElementType;\n const styled = useCss('ListRow', 'root', css);\n const { part, style } = useParts('ListRow', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const initial = typeof title === 'string' ? title.charAt(0) : null;\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-list-row', styled.className, className)}\n data-highlighted={highlighted || undefined}\n {...root}\n >\n {part('mark', 'span', {\n className: 'slurp-list-row-mark',\n 'aria-hidden': true,\n children: mark ?? initial,\n })}\n <span className=\"slurp-list-row-info\">\n {part('title', 'span', {\n className: 'slurp-list-row-title',\n children: (\n <>\n {title}\n {tag != null &&\n part('tag', 'span', {\n className: 'slurp-list-row-tag',\n children: (\n <>\n <CheckIcon size={12} />\n {tag}\n </>\n ),\n })}\n </>\n ),\n })}\n {meta != null &&\n part('meta', 'span', { className: 'slurp-list-row-meta', children: meta })}\n </span>\n {value != null &&\n part('value', 'span', { className: 'slurp-list-row-value', children: value })}\n {actionLabel != null &&\n part('action', 'a', {\n className: 'slurp-list-row-action',\n href: href ?? '#',\n // \"Vedi\" alone repeats on every row: the row's title completes the link's name.\n 'aria-label':\n typeof actionLabel === 'string' && typeof title === 'string'\n ? `${actionLabel} ${title}`\n : undefined,\n children: actionLabel,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,SAAS,cAAc,KAAK;;AAKlC,SAAgB,KAAmC,OAAqB;CACtE,MAAM,EAAE,IAAI,KAAK,WAAW,UAAU,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC1F,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;EAClE,UAAA,oBAAC,QAAD;GAAQ,OAAO,SAAS,QAAQ,SAAS;GAAO;EAAiB,CAAA;CAC7D,CAAA,CACN,EAAA,CAAA;AAEN;;AAuBA,SAAgB,QAAuC,OAAwB;CAC7E,MAAM,EACJ,IACA,KACA,WACA,OACA,MACA,MACA,OACA,KACA,cAAc,OACd,aACA,MACA,OACA,WACA,YACA,GAAG,SACD,cAAc,WAAW,KAAqB;CAClD,MAAM,SAAS,WAAW,MAAM;CAChC,MAAM,OAAQ,OAAO,SAAS,OAAO;CACrC,MAAM,SAAS,OAAO,WAAW,QAAQ,GAAG;CAC5C,MAAM,EAAE,MAAM,UAAU,SAAS,WAAW;EAAE;EAAO;EAAW;CAAW,CAAC;CAC5E,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,UAAU,OAAO,UAAU,WAAW,MAAM,OAAO,CAAC,IAAI;CAC9D,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,kBAAkB,OAAO,WAAW,SAAS;GAC3D,oBAAkB,eAAe,KAAA;GACjC,GAAI;GAHN,UAAA;IAKG,KAAK,QAAQ,QAAQ;KACpB,WAAW;KACX,eAAe;KACf,UAAU,QAAQ;IACpB,CAAC;IACD,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACG,KAAK,SAAS,QAAQ;MACrB,WAAW;MACX,UACE,qBAAA,YAAA,EAAA,UAAA,CACG,OACA,OAAO,QACN,KAAK,OAAO,QAAQ;OAClB,WAAW;OACX,UACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,GACrB,GACD,EAAA,CAAA;MAEN,CAAC,CACH,EAAA,CAAA;KAEN,CAAC,GACA,QAAQ,QACP,KAAK,QAAQ,QAAQ;MAAE,WAAW;MAAuB,UAAU;KAAK,CAAC,CACvE;;IACL,SAAS,QACR,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAwB,UAAU;IAAM,CAAC;IAC7E,eAAe,QACd,KAAK,UAAU,KAAK;KAClB,WAAW;KACX,MAAM,QAAQ;KAEd,cACE,OAAO,gBAAgB,YAAY,OAAO,UAAU,WAChD,GAAG,YAAY,GAAG,UAClB,KAAA;KACN,UAAU;IACZ,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"ListRow.js","names":[],"sources":["../../src/ListRow/ListRow.tsx"],"sourcesContent":["import { CheckIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { createContext, useContext, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nconst InList = createContext(false);\n\nexport type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;\n\n/** A list of ListRows (rows become list items). */\nexport function List<E extends ElementType = 'ul'>(props: ListProps<E>) {\n const { as, css, className, children, ...rest } = useThemeProps('List', props as ListProps);\n const Root = (as ?? 'ul') as ElementType;\n const styled = useCss('List', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-list', styled.className, className)} {...root}>\n <InList value={Root === 'ul' || Root === 'ol'}>{children}</InList>\n </Root>\n </>\n );\n}\n\nexport interface ListRowOwnProps extends PartsProps<\n 'mark' | 'title' | 'link' | 'tag' | 'meta' | 'value' | 'action'\n> {\n title: ReactNode;\n /** Leading mark (an icon, a logo); default the first letter of the title. */\n mark?: ReactNode;\n meta?: ReactNode;\n /** Trailing value (\"9.1\", \"24\"). */\n value?: ReactNode;\n /** Highlight tag next to the title (\"Consigliato\"): with a check, never colour alone. */\n tag?: ReactNode;\n /** The row is highlighted: accent-soft with an accent-ink outline, and the tag. */\n highlighted?: boolean;\n /** Text of the trailing link; the row's title is added for assistive tech. */\n actionLabel?: ReactNode;\n /**\n * Where the row leads. With `actionLabel`, the trailing link goes there; without it the title becomes the link and\n * the whole row is its target (one link per row, no extra \"Open\" button). Router: `parts={{ link: RouterLink }}`.\n */\n href?: string;\n}\n\nexport type ListRowProps<E extends ElementType = 'div'> = PolymorphicProps<E, ListRowOwnProps>;\n\n/** Row of a list: mark, title (with an optional highlight tag), meta, a trailing value and one action link. */\nexport function ListRow<E extends ElementType = 'div'>(props: ListRowProps<E>) {\n const {\n as,\n css,\n className,\n title,\n mark,\n meta,\n value,\n tag,\n highlighted = false,\n actionLabel,\n href,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('ListRow', props as ListRowProps);\n const inList = useContext(InList);\n const Root = (as ?? (inList ? 'li' : 'div')) as ElementType;\n const styled = useCss('ListRow', 'root', css);\n const { part, style } = useParts('ListRow', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const initial = typeof title === 'string' ? title.charAt(0) : null;\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-list-row', styled.className, className)}\n data-highlighted={highlighted || undefined}\n {...root}\n >\n {part('mark', 'span', {\n className: 'slurp-list-row-mark',\n 'aria-hidden': true,\n children: mark ?? initial,\n })}\n <span className=\"slurp-list-row-info\">\n {part('title', 'span', {\n className: 'slurp-list-row-title',\n children: (\n <>\n {href != null && actionLabel == null\n ? part('link', 'a', { className: 'slurp-list-row-link', href, children: title })\n : title}\n {tag != null &&\n part('tag', 'span', {\n className: 'slurp-list-row-tag',\n children: (\n <>\n <CheckIcon size={12} />\n {tag}\n </>\n ),\n })}\n </>\n ),\n })}\n {meta != null &&\n part('meta', 'span', { className: 'slurp-list-row-meta', children: meta })}\n </span>\n {value != null &&\n part('value', 'span', { className: 'slurp-list-row-value', children: value })}\n {actionLabel != null &&\n part('action', 'a', {\n className: 'slurp-list-row-action',\n href: href ?? '#',\n // \"Vedi\" alone repeats on every row: the row's title completes the link's name.\n 'aria-label':\n typeof actionLabel === 'string' && typeof title === 'string'\n ? `${actionLabel} ${title}`\n : undefined,\n children: actionLabel,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,SAAS,cAAc,KAAK;;AAKlC,SAAgB,KAAmC,OAAqB;CACtE,MAAM,EAAE,IAAI,KAAK,WAAW,UAAU,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC1F,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SA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QAAQ,QAAQ;MAAE,WAAW;MAAuB,UAAU;KAAK,CAAC,CACvE;;IACL,SAAS,QACR,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAwB,UAAU;IAAM,CAAC;IAC7E,eAAe,QACd,KAAK,UAAU,KAAK;KAClB,WAAW;KACX,MAAM,QAAQ;KAEd,cACE,OAAO,gBAAgB,YAAY,OAAO,UAAU,WAChD,GAAG,YAAY,GAAG,UAClB,KAAA;KACN,UAAU;IACZ,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
@@ -0,0 +1,28 @@
1
+
2
+ import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType, ReactNode } from "react";
4
+ export interface MediaOwnProps extends PartsProps<'frame' | 'media' | 'caption'> {
5
+ /** Image (or video with `video`) URL. */
6
+ src: string;
7
+ /** What the picture shows; `""` for a purely decorative one. Ignored for a video (name it with a caption). */
8
+ alt?: string;
9
+ /** Width / height: `'16/9'` (default), `'4/3'`, `'1/1'`, any CSS ratio or a number. */
10
+ ratio?: string | number;
11
+ /** `cover` (default) crops to fill the frame; `contain` shows it all. */
12
+ fit?: 'cover' | 'contain';
13
+ /** A video with native controls instead of an image. */
14
+ video?: boolean;
15
+ /** Still shown before a video plays. */
16
+ poster?: string;
17
+ /** Below the frame. */
18
+ caption?: ReactNode;
19
+ /** `lazy` (default) waits until it is near the viewport; `eager` for the first picture of a page. */
20
+ loading?: 'lazy' | 'eager';
21
+ }
22
+ export type MediaProps<E extends ElementType = 'figure'> = PolymorphicProps<E, MediaOwnProps>;
23
+ /**
24
+ * A picture or a video in a frame with fixed proportions and the design system's radius: the space is kept while it
25
+ * loads (no layout shift), with a soft placeholder until the first frame shows.
26
+ */
27
+ export declare function Media<E extends ElementType = 'figure'>(props: MediaProps<E>): import("react").JSX.Element;
28
+ //# sourceMappingURL=Media.d.ts.map
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { cx } from "../utils/src/index.js";
3
+ import { useAnimationRoot } from "../internal/animation.js";
4
+ import { useCss, useParts, useThemeProps } from "../internal/styled.js";
5
+ import { useState } from "react";
6
+ import { Fragment as Fragment$1, jsxs } from "react/jsx-runtime";
7
+ // src/Media/Media.tsx
8
+ /**
9
+ * A picture or a video in a frame with fixed proportions and the design system's radius: the space is kept while it
10
+ * loads (no layout shift), with a soft placeholder until the first frame shows.
11
+ */
12
+ function Media(props) {
13
+ const { as, css, className, src, alt = "", ratio = "16/9", fit = "cover", video = false, poster, caption, loading = "lazy", parts, partProps, classNames, style: styleProp, ...rest } = useThemeProps("Media", props);
14
+ const [loaded, setLoaded] = useState(false);
15
+ const Root = as ?? "figure";
16
+ const styled = useCss("Media", "root", css);
17
+ const { part, style } = useParts("Media", {
18
+ parts,
19
+ partProps,
20
+ classNames
21
+ });
22
+ const root = useAnimationRoot(rest);
23
+ const aspect = typeof ratio === "number" ? String(ratio) : ratio.replace(/\s*\/\s*/, " / ");
24
+ const done = () => setLoaded(true);
25
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
26
+ styled.style,
27
+ style,
28
+ /* @__PURE__ */ jsxs(Root, {
29
+ className: cx("slurp-media", styled.className, className),
30
+ style: styleProp,
31
+ ...root,
32
+ children: [part("frame", "div", {
33
+ className: "slurp-media-frame",
34
+ "data-loaded": loaded || void 0,
35
+ style: { aspectRatio: aspect },
36
+ children: video ? part("media", "video", {
37
+ className: "slurp-media-el",
38
+ src,
39
+ poster,
40
+ controls: true,
41
+ preload: "metadata",
42
+ playsInline: true,
43
+ "data-fit": fit,
44
+ onLoadedData: done,
45
+ onError: done
46
+ }) : part("media", "img", {
47
+ className: "slurp-media-el",
48
+ src,
49
+ alt,
50
+ loading,
51
+ decoding: "async",
52
+ "data-fit": fit,
53
+ onLoad: done,
54
+ onError: done
55
+ })
56
+ }), caption != null && part("caption", "figcaption", {
57
+ className: "slurp-media-caption",
58
+ children: caption
59
+ })]
60
+ })
61
+ ] });
62
+ }
63
+ export { Media };
64
+
65
+ //# sourceMappingURL=Media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Media.js","names":[],"sources":["../../src/Media/Media.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport { useState, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport interface MediaOwnProps extends PartsProps<'frame' | 'media' | 'caption'> {\n /** Image (or video with `video`) URL. */\n src: string;\n /** What the picture shows; `\"\"` for a purely decorative one. Ignored for a video (name it with a caption). */\n alt?: string;\n /** Width / height: `'16/9'` (default), `'4/3'`, `'1/1'`, any CSS ratio or a number. */\n ratio?: string | number;\n /** `cover` (default) crops to fill the frame; `contain` shows it all. */\n fit?: 'cover' | 'contain';\n /** A video with native controls instead of an image. */\n video?: boolean;\n /** Still shown before a video plays. */\n poster?: string;\n /** Below the frame. */\n caption?: ReactNode;\n /** `lazy` (default) waits until it is near the viewport; `eager` for the first picture of a page. */\n loading?: 'lazy' | 'eager';\n}\n\nexport type MediaProps<E extends ElementType = 'figure'> = PolymorphicProps<E, MediaOwnProps>;\n\n/**\n * A picture or a video in a frame with fixed proportions and the design system's radius: the space is kept while it\n * loads (no layout shift), with a soft placeholder until the first frame shows.\n */\nexport function Media<E extends ElementType = 'figure'>(props: MediaProps<E>) {\n const {\n as,\n css,\n className,\n src,\n alt = '',\n ratio = '16/9',\n fit = 'cover',\n video = false,\n poster,\n caption,\n loading = 'lazy',\n parts,\n partProps,\n classNames,\n style: styleProp,\n ...rest\n } = useThemeProps('Media', props as MediaProps);\n const [loaded, setLoaded] = useState(false);\n const Root = (as ?? 'figure') as ElementType;\n const styled = useCss('Media', 'root', css);\n const { part, style } = useParts('Media', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const aspect = typeof ratio === 'number' ? String(ratio) : ratio.replace(/\\s*\\/\\s*/, ' / ');\n const done = () => setLoaded(true);\n return (\n <>\n {styled.style}\n {style}\n <Root className={cx('slurp-media', styled.className, className)} style={styleProp} {...root}>\n {part('frame', 'div', {\n className: 'slurp-media-frame',\n 'data-loaded': loaded || undefined,\n style: { aspectRatio: aspect },\n children: video\n ? part('media', 'video', {\n className: 'slurp-media-el',\n src,\n poster,\n controls: true,\n preload: 'metadata',\n playsInline: true,\n 'data-fit': fit,\n onLoadedData: done,\n onError: done,\n })\n : part('media', 'img', {\n className: 'slurp-media-el',\n src,\n alt,\n loading,\n decoding: 'async',\n 'data-fit': fit,\n onLoad: done,\n onError: done,\n }),\n })}\n {caption != null &&\n part('caption', 'figcaption', { className: 'slurp-media-caption', children: caption })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAgB,MAAwC,OAAsB;CAC5E,MAAM,EACJ,IACA,KACA,WACA,KACA,MAAM,IACN,QAAQ,QACR,MAAM,SACN,QAAQ,OACR,QACA,SACA,UAAU,QACV,OACA,WACA,YACA,OAAO,WACP,GAAG,SACD,cAAc,SAAS,KAAmB;CAC9C,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,EAAE,MAAM,UAAU,SAAS,SAAS;EAAE;EAAO;EAAW;CAAW,CAAC;CAC1E,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,SAAS,OAAO,UAAU,WAAW,OAAO,KAAK,IAAI,MAAM,QAAQ,YAAY,KAAK;CAC1F,MAAM,aAAa,UAAU,IAAI;CACjC,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GAAM,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;GAAG,OAAO;GAAW,GAAI;GAAvF,UAAA,CACG,KAAK,SAAS,OAAO;IACpB,WAAW;IACX,eAAe,UAAU,KAAA;IACzB,OAAO,EAAE,aAAa,OAAO;IAC7B,UAAU,QACN,KAAK,SAAS,SAAS;KACrB,WAAW;KACX;KACA;KACA,UAAU;KACV,SAAS;KACT,aAAa;KACb,YAAY;KACZ,cAAc;KACd,SAAS;IACX,CAAC,IACD,KAAK,SAAS,OAAO;KACnB,WAAW;KACX;KACA;KACA;KACA,UAAU;KACV,YAAY;KACZ,QAAQ;KACR,SAAS;IACX,CAAC;GACP,CAAC,GACA,WAAW,QACV,KAAK,WAAW,cAAc;IAAE,WAAW;IAAuB,UAAU;GAAQ,CAAC,CACnF;;CACN,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Media, MediaProps } from "./Media.js";
3
+ export { Media, type MediaProps, Media as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Media, Media as default } from "./Media.js";
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { useLabels } from "../internal/labels.js";
2
3
  import { cx } from "../utils/src/index.js";
3
4
  import { useAnimationRoot } from "../internal/animation.js";
4
5
  import { useCss, useParts, useThemeProps } from "../internal/styled.js";
@@ -28,6 +29,7 @@ function Notice(props) {
28
29
  const { as, css, className, tone = "neutral", title, children, onDismiss, labels: labelsProp, parts, partProps, classNames, ...rest } = useThemeProps("Notice", props);
29
30
  const labels = {
30
31
  ...NOTICE_LABELS,
32
+ ...useLabels("Notice"),
31
33
  ...labelsProp
32
34
  };
33
35
  const Root = as ?? "div";
@@ -1 +1 @@
1
- {"version":3,"file":"Notice.js","names":[],"sources":["../../src/Notice/Notice.tsx"],"sourcesContent":["import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ElementType, type ReactNode } from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport type StatusTone = 'neutral' | 'success' | 'warning' | 'danger';\n\nexport interface NoticeLabels {\n /** The word that names each tone (shown as the title when there is none). */\n neutral: string;\n success: string;\n warning: string;\n danger: string;\n /** Name of the close button. */\n dismiss: string;\n}\n\nexport const NOTICE_LABELS: NoticeLabels = {\n neutral: 'Nota',\n success: 'Fatto',\n warning: 'Attenzione',\n danger: 'Errore',\n dismiss: 'Chiudi avviso',\n};\n\nexport interface NoticeOwnProps extends PartsProps<'icon' | 'title' | 'body' | 'dismiss'> {\n /** Default `neutral`. The state is an icon plus a word, never colour alone. */\n tone?: StatusTone;\n /** Short title; default the tone's word (`labels`). */\n title?: ReactNode;\n children?: ReactNode;\n /** Shows a close button. */\n onDismiss?: () => void;\n labels?: Partial<NoticeLabels>;\n}\n\nexport type NoticeProps<E extends ElementType = 'div'> = PolymorphicProps<E, NoticeOwnProps>;\n\nconst ICONS = { neutral: InfoIcon, success: SuccessIcon, warning: WarningIcon, danger: ErrorIcon };\n\n/**\n * A message in the page (alert): icon + word + text. `role=\"status\"` by default (announced politely when it appears);\n * pass `role=\"alert\"` for errors that must interrupt.\n */\nexport function Notice<E extends ElementType = 'div'>(props: NoticeProps<E>) {\n const {\n as,\n css,\n className,\n tone = 'neutral',\n title,\n children,\n onDismiss,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Notice', props as NoticeProps);\n const labels = { ...NOTICE_LABELS, ...labelsProp };\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Notice', 'root', css);\n const { part, style } = useParts('Notice', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const titleId = useId();\n const Icon = ICONS[tone];\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-notice', styled.className, className)}\n role=\"status\"\n aria-labelledby={titleId}\n data-tone={tone}\n {...root}\n >\n {part('icon', 'span', {\n className: 'slurp-notice-icon',\n 'aria-hidden': true,\n children: <Icon size={22} />,\n })}\n <div className=\"slurp-notice-text\">\n {part('title', 'p', {\n id: titleId,\n className: 'slurp-notice-title',\n children: title ?? labels[tone],\n })}\n {children != null && part('body', 'div', { className: 'slurp-notice-body', children })}\n </div>\n {onDismiss &&\n part('dismiss', Bubble, {\n className: 'slurp-notice-dismiss',\n label: labels.dismiss,\n size: 'sm',\n onClick: onDismiss,\n children: <CloseIcon />,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAa,gBAA8B;CACzC,SAAS;CACT,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;AACX;AAeA,MAAM,QAAQ;CAAE,SAAS;CAAU,SAAS;CAAa,SAAS;CAAa,QAAQ;AAAU;;;;;AAMjG,SAAgB,OAAsC,OAAuB;CAC3E,MAAM,EACJ,IACA,KACA,WACA,OAAO,WACP,OACA,UACA,WACA,QAAQ,YACR,OACA,WACA,YACA,GAAG,SACD,cAAc,UAAU,KAAoB;CAChD,MAAM,SAAS;EAAE,GAAG;EAAe,GAAG;CAAW;CACjD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG;CAC3C,MAAM,EAAE,MAAM,UAAU,SAAS,UAAU;EAAE;EAAO;EAAW;CAAW,CAAC;CAC3E,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,UAAU,MAAM;CACtB,MAAM,OAAO,MAAM;CACnB,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,gBAAgB,OAAO,WAAW,SAAS;GACzD,MAAK;GACL,mBAAiB;GACjB,aAAW;GACX,GAAI;GALN,UAAA;IAOG,KAAK,QAAQ,QAAQ;KACpB,WAAW;KACX,eAAe;KACf,UAAU,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;IAC7B,CAAC;IACD,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,KAAK,SAAS,KAAK;MAClB,IAAI;MACJ,WAAW;MACX,UAAU,SAAS,OAAO;KAC5B,CAAC,GACA,YAAY,QAAQ,KAAK,QAAQ,OAAO;MAAE,WAAW;MAAqB;KAAS,CAAC,CAClF;;IACJ,aACC,KAAK,WAAW,QAAQ;KACtB,WAAW;KACX,OAAO,OAAO;KACd,MAAM;KACN,SAAS;KACT,UAAU,oBAAC,WAAD,CAAY,CAAA;IACxB,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"Notice.js","names":[],"sources":["../../src/Notice/Notice.tsx"],"sourcesContent":["import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ElementType, type ReactNode } from 'react';\n\nimport { useLabels } from '../internal/labels';\nimport { Bubble } from '../Bubble/Bubble';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport type StatusTone = 'neutral' | 'success' | 'warning' | 'danger';\n\nexport interface NoticeLabels {\n /** The word that names each tone (shown as the title when there is none). */\n neutral: string;\n success: string;\n warning: string;\n danger: string;\n /** Name of the close button. */\n dismiss: string;\n}\n\nexport const NOTICE_LABELS: NoticeLabels = {\n neutral: 'Nota',\n success: 'Fatto',\n warning: 'Attenzione',\n danger: 'Errore',\n dismiss: 'Chiudi avviso',\n};\n\nexport interface NoticeOwnProps extends PartsProps<'icon' | 'title' | 'body' | 'dismiss'> {\n /** Default `neutral`. The state is an icon plus a word, never colour alone. */\n tone?: StatusTone;\n /** Short title; default the tone's word (`labels`). */\n title?: ReactNode;\n children?: ReactNode;\n /** Shows a close button. */\n onDismiss?: () => void;\n labels?: Partial<NoticeLabels>;\n}\n\nexport type NoticeProps<E extends ElementType = 'div'> = PolymorphicProps<E, NoticeOwnProps>;\n\nconst ICONS = { neutral: InfoIcon, success: SuccessIcon, warning: WarningIcon, danger: ErrorIcon };\n\n/**\n * A message in the page (alert): icon + word + text. `role=\"status\"` by default (announced politely when it appears);\n * pass `role=\"alert\"` for errors that must interrupt.\n */\nexport function Notice<E extends ElementType = 'div'>(props: NoticeProps<E>) {\n const {\n as,\n css,\n className,\n tone = 'neutral',\n title,\n children,\n onDismiss,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Notice', props as NoticeProps);\n const labels = { ...NOTICE_LABELS, ...useLabels('Notice'), ...labelsProp };\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Notice', 'root', css);\n const { part, style } = useParts('Notice', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const titleId = useId();\n const Icon = ICONS[tone];\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-notice', styled.className, className)}\n role=\"status\"\n aria-labelledby={titleId}\n data-tone={tone}\n {...root}\n >\n {part('icon', 'span', {\n className: 'slurp-notice-icon',\n 'aria-hidden': true,\n children: <Icon size={22} />,\n })}\n <div className=\"slurp-notice-text\">\n {part('title', 'p', {\n id: titleId,\n className: 'slurp-notice-title',\n children: title ?? labels[tone],\n })}\n {children != null && part('body', 'div', { className: 'slurp-notice-body', children })}\n </div>\n {onDismiss &&\n part('dismiss', Bubble, {\n className: 'slurp-notice-dismiss',\n label: labels.dismiss,\n size: 'sm',\n onClick: onDismiss,\n children: <CloseIcon />,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAsBA,MAAa,gBAA8B;CACzC,SAAS;CACT,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;AACX;AAeA,MAAM,QAAQ;CAAE,SAAS;CAAU,SAAS;CAAa,SAAS;CAAa,QAAQ;AAAU;;;;;AAMjG,SAAgB,OAAsC,OAAuB;CAC3E,MAAM,EACJ,IACA,KACA,WACA,OAAO,WACP,OACA,UACA,WACA,QAAQ,YACR,OACA,WACA,YACA,GAAG,SACD,cAAc,UAAU,KAAoB;CAChD,MAAM,SAAS;EAAE,GAAG;EAAe,GAAG,UAAU,QAAQ;EAAG,GAAG;CAAW;CACzE,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OA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