@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
@@ -0,0 +1,37 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType, ReactNode } from "react";
4
+ export interface RailOwnProps {
5
+ /** Name of the navigation ("Documentazione", "Impostazioni"). */
6
+ label: string;
7
+ children?: ReactNode;
8
+ }
9
+ export type RailProps<E extends ElementType = 'nav'> = PolymorphicProps<E, RailOwnProps>;
10
+ /**
11
+ * Vertical navigation in groups, beside the content on wide screens (the Dock stays the navigation on phones). The
12
+ * current page is highlighted like a ListRow and marked `aria-current="page"`. Put it in a floating Surface.
13
+ */
14
+ declare function RailRoot<E extends ElementType = 'nav'>(props: RailProps<E>): import("react").JSX.Element;
15
+ export interface RailGroupProps {
16
+ /** Shown as an eyebrow above the links, and names the list. */
17
+ title?: ReactNode;
18
+ children?: ReactNode;
19
+ className?: string;
20
+ }
21
+ /** A group of links under an optional eyebrow title. */
22
+ declare function RailGroup({ title, children, className }: RailGroupProps): import("react").JSX.Element;
23
+ export interface RailLinkOwnProps {
24
+ /** The page you are on (a router's NavLink sets `aria-current` itself). */
25
+ current?: boolean;
26
+ children?: ReactNode;
27
+ }
28
+ export type RailLinkProps<E extends ElementType = 'a'> = PolymorphicProps<E, RailLinkOwnProps>;
29
+ /** One link of the rail; `as` renders your router's link. */
30
+ declare function RailLink<E extends ElementType = 'a'>(props: RailLinkProps<E>): import("react").JSX.Element;
31
+ type RailComponent = typeof RailRoot & {
32
+ Group: typeof RailGroup;
33
+ Link: typeof RailLink;
34
+ };
35
+ export declare const Rail: RailComponent;
36
+ export { RailGroup, RailLink };
37
+ //# sourceMappingURL=Rail.d.ts.map
@@ -0,0 +1,61 @@
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/Rail/Rail.tsx
8
+ /**
9
+ * Vertical navigation in groups, beside the content on wide screens (the Dock stays the navigation on phones). The
10
+ * current page is highlighted like a ListRow and marked `aria-current="page"`. Put it in a floating Surface.
11
+ */
12
+ function RailRoot(props) {
13
+ const { as, css, className, label, children, ...rest } = useThemeProps("Rail", props);
14
+ const Root = as ?? "nav";
15
+ const styled = useCss("Rail", "root", css);
16
+ const root = useAnimationRoot(rest);
17
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
18
+ className: cx("slurp-rail", styled.className, className),
19
+ "aria-label": label,
20
+ ...root,
21
+ children
22
+ })] });
23
+ }
24
+ /** A group of links under an optional eyebrow title. */
25
+ function RailGroup({ title, children, className }) {
26
+ const id = useId();
27
+ return /* @__PURE__ */ jsxs("div", {
28
+ className: cx("slurp-rail-group", className),
29
+ children: [title != null && /* @__PURE__ */ jsx("p", {
30
+ className: "slurp-rail-group-title",
31
+ id,
32
+ children: title
33
+ }), /* @__PURE__ */ jsx("ul", {
34
+ className: "slurp-rail-list",
35
+ "aria-labelledby": title != null ? id : void 0,
36
+ children
37
+ })]
38
+ });
39
+ }
40
+ /** One link of the rail; `as` renders your router's link. */
41
+ function RailLink(props) {
42
+ const { as, css: _css, className, current, children, ...rest } = props;
43
+ const Root = as ?? "a";
44
+ const root = useAnimationRoot(rest);
45
+ return /* @__PURE__ */ jsx("li", {
46
+ className: "slurp-rail-item",
47
+ children: /* @__PURE__ */ jsx(Root, {
48
+ className: cx("slurp-rail-link", className),
49
+ "aria-current": current ? "page" : void 0,
50
+ ...root,
51
+ children
52
+ })
53
+ });
54
+ }
55
+ const Rail = Object.assign(RailRoot, {
56
+ Group: RailGroup,
57
+ Link: RailLink
58
+ });
59
+ export { Rail, RailGroup, RailLink };
60
+
61
+ //# sourceMappingURL=Rail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Rail.js","names":[],"sources":["../../src/Rail/Rail.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 RailOwnProps {\n /** Name of the navigation (\"Documentazione\", \"Impostazioni\"). */\n label: string;\n children?: ReactNode;\n}\n\nexport type RailProps<E extends ElementType = 'nav'> = PolymorphicProps<E, RailOwnProps>;\n\n/**\n * Vertical navigation in groups, beside the content on wide screens (the Dock stays the navigation on phones). The\n * current page is highlighted like a ListRow and marked `aria-current=\"page\"`. Put it in a floating Surface.\n */\nfunction RailRoot<E extends ElementType = 'nav'>(props: RailProps<E>) {\n const { as, css, className, label, children, ...rest } = useThemeProps(\n 'Rail',\n props as RailProps,\n );\n const Root = (as ?? 'nav') as ElementType;\n const styled = useCss('Rail', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-rail', styled.className, className)} aria-label={label} {...root}>\n {children}\n </Root>\n </>\n );\n}\n\nexport interface RailGroupProps {\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 group of links under an optional eyebrow title. */\nfunction RailGroup({ title, children, className }: RailGroupProps) {\n const id = useId();\n return (\n <div className={cx('slurp-rail-group', className)}>\n {title != null && (\n <p className=\"slurp-rail-group-title\" id={id}>\n {title}\n </p>\n )}\n <ul className=\"slurp-rail-list\" aria-labelledby={title != null ? id : undefined}>\n {children}\n </ul>\n </div>\n );\n}\n\nexport interface RailLinkOwnProps {\n /** The page you are on (a router's NavLink sets `aria-current` itself). */\n current?: boolean;\n children?: ReactNode;\n}\n\nexport type RailLinkProps<E extends ElementType = 'a'> = PolymorphicProps<E, RailLinkOwnProps>;\n\n/** One link of the rail; `as` renders your router's link. */\nfunction RailLink<E extends ElementType = 'a'>(props: RailLinkProps<E>) {\n const { as, css: _css, className, current, children, ...rest } = props as RailLinkProps;\n const Root = (as ?? 'a') as ElementType;\n const root = useAnimationRoot(rest);\n return (\n <li className=\"slurp-rail-item\">\n <Root\n className={cx('slurp-rail-link', className)}\n aria-current={current ? 'page' : undefined}\n {...root}\n >\n {children}\n </Root>\n </li>\n );\n}\n\ntype RailComponent = typeof RailRoot & { Group: typeof RailGroup; Link: typeof RailLink };\n\nexport const Rail = Object.assign(RailRoot, { Group: RailGroup, Link: RailLink }) as RailComponent;\nexport { RailGroup, RailLink };\n"],"mappings":";;;;;;;;;;;AAmBA,SAAS,SAAwC,OAAqB;CACpE,MAAM,EAAE,IAAI,KAAK,WAAW,OAAO,UAAU,GAAG,SAAS,cACvD,QACA,KACF;CACA,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,cAAY;EAAO,GAAI;EACpF;CACG,CAAA,CACN,EAAA,CAAA;AAEN;;AAUA,SAAS,UAAU,EAAE,OAAO,UAAU,aAA6B;CACjE,MAAM,KAAK,MAAM;CACjB,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,oBAAoB,SAAS;EAAhD,UAAA,CACG,SAAS,QACR,oBAAC,KAAD;GAAG,WAAU;GAA6B;GACvC,UAAA;EACA,CAAA,GAEL,oBAAC,MAAD;GAAI,WAAU;GAAkB,mBAAiB,SAAS,OAAO,KAAK,KAAA;GACnE;EACC,CAAA,CACD;;AAET;;AAWA,SAAS,SAAsC,OAAyB;CACtE,MAAM,EAAE,IAAI,KAAK,MAAM,WAAW,SAAS,UAAU,GAAG,SAAS;CACjE,MAAM,OAAQ,MAAM;CACpB,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,oBAAC,MAAD;EAAI,WAAU;EACZ,UAAA,oBAAC,MAAD;GACE,WAAW,GAAG,mBAAmB,SAAS;GAC1C,gBAAc,UAAU,SAAS,KAAA;GACjC,GAAI;GAEH;EACG,CAAA;CACJ,CAAA;AAER;AAIA,MAAa,OAAO,OAAO,OAAO,UAAU;CAAE,OAAO;CAAW,MAAM;AAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Rail, RailGroup, RailGroupProps, RailLink, RailLinkProps, RailProps } from "./Rail.js";
3
+ export { Rail, RailGroup, type RailGroupProps, RailLink, type RailLinkProps, type RailProps, Rail as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Rail, RailGroup, RailLink, Rail as default } from "./Rail.js";
@@ -13,7 +13,7 @@ export interface RangeOwnProps extends PartsProps<'label' | 'value' | 'control'>
13
13
  max?: number;
14
14
  /** Default 1. */
15
15
  step?: number;
16
- /** Text of the value, shown next to the label and read by screen readers ("1.200 €"). */
16
+ /** Text of the value, shown next to the label and read by screen readers ("75%", "3 di 5"). */
17
17
  formatValue?: (value: number) => string;
18
18
  /** Shows the value next to the label. Default true. */
19
19
  showValue?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Range.js","names":[],"sources":["../../src/Range/Range.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type CSSProperties,\n type ElementType,\n type ReactNode,\n} from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface RangeOwnProps extends PartsProps<'label' | 'value' | 'control'> {\n /** Visible label. */\n label: ReactNode;\n value?: number;\n defaultValue?: number;\n onValueChange?: (value: number) => void;\n /** Default 0. */\n min?: number;\n /** Default 100. */\n max?: number;\n /** Default 1. */\n step?: number;\n /** Text of the value, shown next to the label and read by screen readers (\"1.200 €\"). */\n formatValue?: (value: number) => string;\n /** Shows the value next to the label. Default true. */\n showValue?: boolean;\n name?: string;\n disabled?: boolean;\n}\n\nexport type RangeProps<E extends ElementType = 'div'> = PolymorphicProps<E, RangeOwnProps>;\n\n/** Slider on a native range input: 44px thumb target, accent-ink fill, arrow keys / Page keys / Home / End. */\nexport function Range<E extends ElementType = 'div'>(props: RangeProps<E>) {\n const {\n as,\n css,\n className,\n label,\n value: valueProp,\n defaultValue,\n onValueChange,\n min = 0,\n max = 100,\n step = 1,\n formatValue = String,\n showValue = true,\n name,\n disabled,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Range', props as RangeProps);\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue: defaultValue ?? min,\n onChange: onValueChange,\n });\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Range', 'root', css);\n const { part, style: partsStyle } = useParts('Range', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const ratio = max > min ? (Math.min(max, Math.max(min, value)) - min) / (max - min) : 0;\n const text = formatValue(value);\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-range', styled.className, className)}\n data-disabled={disabled ? '' : undefined}\n style={{ '--slurp-range-ratio': ratio, ...style } as CSSProperties}\n {...root}\n >\n <div className=\"slurp-range-head\">\n {part('label', 'label', { htmlFor: id, className: 'slurp-range-label', children: label })}\n {showValue &&\n part('value', 'output', {\n htmlFor: id,\n className: 'slurp-range-value',\n children: text,\n })}\n </div>\n {part('control', 'input', {\n id,\n type: 'range',\n className: 'slurp-range-control',\n name,\n min,\n max,\n step,\n disabled,\n value,\n 'aria-valuetext': text,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setValue(Number(e.target.value)),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAqCA,SAAgB,MAAqC,OAAsB;CACzE,MAAM,EACJ,IACA,KACA,WACA,OACA,OAAO,WACP,cACA,eACA,MAAM,GACN,MAAM,KACN,OAAO,GACP,cAAc,QACd,YAAY,MACZ,MACA,UACA,OACA,OACA,WACA,YACA,GAAG,SACD,cAAc,SAAS,KAAmB;CAC9C,MAAM,CAAC,OAAO,YAAY,cAAc;EACtC,OAAO;EACP,cAAc,gBAAgB;EAC9B,UAAU;CACZ,CAAC;CACD,MAAM,KAAK,MAAM;CACjB,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,EAAE,MAAM,OAAO,eAAe,SAAS,SAAS;EAAE;EAAO;EAAW;CAAW,CAAC;CACtF,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,MAAM,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,IAAI,QAAQ,MAAM,OAAO;CACtF,MAAM,OAAO,YAAY,KAAK;CAC9B,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;GACxD,iBAAe,WAAW,KAAK,KAAA;GAC/B,OAAO;IAAE,uBAAuB;IAAO,GAAG;GAAM;GAChD,GAAI;GAJN,UAAA,CAME,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,KAAK,SAAS,SAAS;KAAE,SAAS;KAAI,WAAW;KAAqB,UAAU;IAAM,CAAC,GACvF,aACC,KAAK,SAAS,UAAU;KACtB,SAAS;KACT,WAAW;KACX,UAAU;IACZ,CAAC,CACA;GACJ,CAAA,GAAA,KAAK,WAAW,SAAS;IACxB;IACA,MAAM;IACN,WAAW;IACX;IACA;IACA;IACA;IACA;IACA;IACA,kBAAkB;IAClB,WAAW,MAAqC,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC;GACjF,CAAC,CACG;;CACN,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"Range.js","names":[],"sources":["../../src/Range/Range.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type CSSProperties,\n type ElementType,\n type ReactNode,\n} from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface RangeOwnProps extends PartsProps<'label' | 'value' | 'control'> {\n /** Visible label. */\n label: ReactNode;\n value?: number;\n defaultValue?: number;\n onValueChange?: (value: number) => void;\n /** Default 0. */\n min?: number;\n /** Default 100. */\n max?: number;\n /** Default 1. */\n step?: number;\n /** Text of the value, shown next to the label and read by screen readers (\"75%\", \"3 di 5\"). */\n formatValue?: (value: number) => string;\n /** Shows the value next to the label. Default true. */\n showValue?: boolean;\n name?: string;\n disabled?: boolean;\n}\n\nexport type RangeProps<E extends ElementType = 'div'> = PolymorphicProps<E, RangeOwnProps>;\n\n/** Slider on a native range input: 44px thumb target, accent-ink fill, arrow keys / Page keys / Home / End. */\nexport function Range<E extends ElementType = 'div'>(props: RangeProps<E>) {\n const {\n as,\n css,\n className,\n label,\n value: valueProp,\n defaultValue,\n onValueChange,\n min = 0,\n max = 100,\n step = 1,\n formatValue = String,\n showValue = true,\n name,\n disabled,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Range', props as RangeProps);\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue: defaultValue ?? min,\n onChange: onValueChange,\n });\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Range', 'root', css);\n const { part, style: partsStyle } = useParts('Range', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const ratio = max > min ? (Math.min(max, Math.max(min, value)) - min) / (max - min) : 0;\n const text = formatValue(value);\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-range', styled.className, className)}\n data-disabled={disabled ? '' : undefined}\n style={{ '--slurp-range-ratio': ratio, ...style } as CSSProperties}\n {...root}\n >\n <div className=\"slurp-range-head\">\n {part('label', 'label', { htmlFor: id, className: 'slurp-range-label', children: label })}\n {showValue &&\n part('value', 'output', {\n htmlFor: id,\n className: 'slurp-range-value',\n children: text,\n })}\n </div>\n {part('control', 'input', {\n id,\n type: 'range',\n className: 'slurp-range-control',\n name,\n min,\n max,\n step,\n disabled,\n value,\n 'aria-valuetext': text,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setValue(Number(e.target.value)),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAqCA,SAAgB,MAAqC,OAAsB;CACzE,MAAM,EACJ,IACA,KACA,WACA,OACA,OAAO,WACP,cACA,eACA,MAAM,GACN,MAAM,KACN,OAAO,GACP,cAAc,QACd,YAAY,MACZ,MACA,UACA,OACA,OACA,WACA,YACA,GAAG,SACD,cAAc,SAAS,KAAmB;CAC9C,MAAM,CAAC,OAAO,YAAY,cAAc;EACtC,OAAO;EACP,cAAc,gBAAgB;EAC9B,UAAU;CACZ,CAAC;CACD,MAAM,KAAK,MAAM;CACjB,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,EAAE,MAAM,OAAO,eAAe,SAAS,SAAS;EAAE;EAAO;EAAW;CAAW,CAAC;CACtF,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,MAAM,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,IAAI,QAAQ,MAAM,OAAO;CACtF,MAAM,OAAO,YAAY,KAAK;CAC9B,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;GACxD,iBAAe,WAAW,KAAK,KAAA;GAC/B,OAAO;IAAE,uBAAuB;IAAO,GAAG;GAAM;GAChD,GAAI;GAJN,UAAA,CAME,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,KAAK,SAAS,SAAS;KAAE,SAAS;KAAI,WAAW;KAAqB,UAAU;IAAM,CAAC,GACvF,aACC,KAAK,SAAS,UAAU;KACtB,SAAS;KACT,WAAW;KACX,UAAU;IACZ,CAAC,CACA;GACJ,CAAA,GAAA,KAAK,WAAW,SAAS;IACxB;IACA,MAAM;IACN,WAAW;IACX;IACA;IACA;IACA;IACA;IACA;IACA,kBAAkB;IAClB,WAAW,MAAqC,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC;GACjF,CAAC,CACG;;CACN,EAAA,CAAA;AAEN"}
@@ -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, useThemeProps } from "../internal/styled.js";
@@ -26,6 +27,7 @@ function Rating(props) {
26
27
  const { as, css, className, label, value: valueProp, defaultValue = null, onValueChange, max: maxProp = 5, readOnly = false, name: nameProp, disabled = false, size = "md", labels: labelsProp, style, ...rest } = useThemeProps("Rating", props);
27
28
  const labels = {
28
29
  ...RATING_LABELS,
30
+ ...useLabels("Rating"),
29
31
  ...labelsProp
30
32
  };
31
33
  const max = Math.max(1, Math.round(maxProp));
@@ -1 +1 @@
1
- {"version":3,"file":"Rating.js","names":[],"sources":["../../src/Rating/Rating.tsx"],"sourcesContent":["import { StarIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type CSSProperties, type ElementType } from 'react';\n\nimport type { ControlSize } from '../Button/Button';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface RatingLabels {\n /** The value as words (\"4.5 su 5\"): the name of a read-only rating, after its label. */\n value: (value: string, max: number) => string;\n /** Name of one star of the input (\"3 stelle\"). */\n star: (stars: number) => string;\n}\n\nexport const RATING_LABELS: RatingLabels = {\n value: (v, max) => `${v} su ${max}`,\n star: (n) => (n === 1 ? '1 stella' : `${n} stelle`),\n};\n\nexport interface RatingOwnProps {\n /** What is rated (\"Il tuo voto\", \"Valutazione media\"): the legend of the input, the name of a read-only rating. */\n label: string;\n /** Stars chosen; null for none yet. A read-only rating may be fractional (4.5). */\n value?: number | null;\n defaultValue?: number | null;\n onValueChange?: (value: number) => void;\n /** Number of stars. Default 5. */\n max?: number;\n /** Shows a value instead of asking for one: one image named \"Valutazione media: 4.5 su 5\". */\n readOnly?: boolean;\n /** Form field name (radio inputs). */\n name?: string;\n disabled?: boolean;\n /** Star size: `sm` 20, `md` 28 (default), `lg` 36. Each star of the input stays a 44px target. */\n size?: ControlSize;\n labels?: Partial<RatingLabels>;\n}\n\nexport type RatingProps<E extends ElementType = 'fieldset'> = PolymorphicProps<E, RatingOwnProps>;\n\nconst ICON: Record<ControlSize, number> = { sm: 20, md: 28, lg: 36 };\n\n/** One decimal, like scores; whole numbers stay whole (\"4\", \"4.5\"). */\nconst shown = (v: number) => (Number.isInteger(v) ? String(v) : v.toFixed(1));\n\n/**\n * Stars. As an input it is a group of native radios (arrow keys move and choose, the legend names it): chosen stars\n * are filled, the others outlined (shape, not only colour). Read-only it is one image with the value in words.\n */\nexport function Rating<E extends ElementType = 'fieldset'>(props: RatingProps<E>) {\n const {\n as,\n css,\n className,\n label,\n value: valueProp,\n defaultValue = null,\n onValueChange,\n max: maxProp = 5,\n readOnly = false,\n name: nameProp,\n disabled = false,\n size = 'md',\n labels: labelsProp,\n style,\n ...rest\n } = useThemeProps('Rating', props as RatingProps);\n const labels = { ...RATING_LABELS, ...labelsProp };\n const max = Math.max(1, Math.round(maxProp));\n const [value, setValue] = useControlled<number | null>({\n value: valueProp,\n defaultValue,\n onChange: onValueChange as ((v: number | null) => void) | undefined,\n });\n const auto = useId();\n const name = nameProp ?? auto;\n const styled = useCss('Rating', 'root', css);\n const root = useAnimationRoot(rest);\n const stars = Array.from({ length: max }, (_, i) => i + 1);\n const icon = ICON[size];\n const clamped = Math.min(max, Math.max(0, value ?? 0));\n\n if (readOnly) {\n const Root = (as ?? 'span') as ElementType;\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-rating', styled.className, className)}\n role=\"img\"\n aria-label={`${label}: ${labels.value(shown(clamped), max)}`}\n data-readonly=\"\"\n data-size={size}\n style={{ '--slurp-rating-ratio': clamped / max, ...style } as CSSProperties}\n {...root}\n >\n <span className=\"slurp-rating-track\" aria-hidden=\"true\">\n {stars.map((n) => (\n <StarIcon key={n} size={icon} className=\"slurp-rating-icon\" />\n ))}\n <span className=\"slurp-rating-fill\">\n {stars.map((n) => (\n <StarIcon key={n} size={icon} className=\"slurp-rating-icon\" fill=\"currentColor\" />\n ))}\n </span>\n </span>\n </Root>\n </>\n );\n }\n\n const Root = (as ?? 'fieldset') as ElementType;\n const fieldset = Root === 'fieldset';\n const Legend = fieldset ? 'legend' : 'span';\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-rating', styled.className, className)}\n data-size={size}\n data-disabled={disabled ? '' : undefined}\n disabled={fieldset ? disabled : undefined}\n role={fieldset ? undefined : 'radiogroup'}\n aria-labelledby={fieldset ? undefined : `${auto}-label`}\n style={style}\n {...root}\n >\n <Legend id={`${auto}-label`} className=\"slurp-rating-label\">\n {label}\n </Legend>\n <span className=\"slurp-rating-stars\">\n {stars.map((n) => {\n const on = n <= clamped;\n return (\n <label key={n} className=\"slurp-rating-star\" data-on={on ? '' : undefined}>\n <input\n type=\"radio\"\n className=\"slurp-rating-input\"\n name={name}\n value={n}\n checked={value === n}\n disabled={disabled}\n aria-label={labels.star(n)}\n onChange={() => setValue(n)}\n />\n <StarIcon\n size={icon}\n className=\"slurp-rating-icon\"\n fill={on ? 'currentColor' : 'none'}\n />\n </label>\n );\n })}\n </span>\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAiBA,MAAa,gBAA8B;CACzC,QAAQ,GAAG,QAAQ,GAAG,EAAE,MAAM;CAC9B,OAAO,MAAO,MAAM,IAAI,aAAa,GAAG,EAAE;AAC5C;AAuBA,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tsx"],"sourcesContent":["import { StarIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type CSSProperties, type ElementType } from 'react';\n\nimport { useLabels } from '../internal/labels';\nimport type { ControlSize } from '../Button/Button';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface RatingLabels {\n /** The value as words (\"4.5 su 5\"): the name of a read-only rating, after its label. */\n value: (value: string, max: number) => string;\n /** Name of one star of the input (\"3 stelle\"). */\n star: (stars: number) => string;\n}\n\nexport const RATING_LABELS: RatingLabels = {\n value: (v, max) => `${v} su ${max}`,\n star: (n) => (n === 1 ? '1 stella' : `${n} stelle`),\n};\n\nexport interface RatingOwnProps {\n /** What is rated (\"Il tuo voto\", \"Valutazione media\"): the legend of the input, the name of a read-only rating. */\n label: string;\n /** Stars chosen; null for none yet. A read-only rating may be fractional (4.5). */\n value?: number | null;\n defaultValue?: number | null;\n onValueChange?: (value: number) => void;\n /** Number of stars. Default 5. */\n max?: number;\n /** Shows a value instead of asking for one: one image named \"Valutazione media: 4.5 su 5\". */\n readOnly?: boolean;\n /** Form field name (radio inputs). */\n name?: string;\n disabled?: boolean;\n /** Star size: `sm` 20, `md` 28 (default), `lg` 36. Each star of the input stays a 44px target. */\n size?: ControlSize;\n labels?: Partial<RatingLabels>;\n}\n\nexport type RatingProps<E extends ElementType = 'fieldset'> = PolymorphicProps<E, RatingOwnProps>;\n\nconst ICON: Record<ControlSize, number> = { sm: 20, md: 28, lg: 36 };\n\n/** One decimal, like scores; whole numbers stay whole (\"4\", \"4.5\"). */\nconst shown = (v: number) => (Number.isInteger(v) ? String(v) : v.toFixed(1));\n\n/**\n * Stars. As an input it is a group of native radios (arrow keys move and choose, the legend names it): chosen stars\n * are filled, the others outlined (shape, not only colour). Read-only it is one image with the value in words.\n */\nexport function Rating<E extends ElementType = 'fieldset'>(props: RatingProps<E>) {\n const {\n as,\n css,\n className,\n label,\n value: valueProp,\n defaultValue = null,\n onValueChange,\n max: maxProp = 5,\n readOnly = false,\n name: nameProp,\n disabled = false,\n size = 'md',\n labels: labelsProp,\n style,\n ...rest\n } = useThemeProps('Rating', props as RatingProps);\n const labels = { ...RATING_LABELS, ...useLabels('Rating'), ...labelsProp };\n const max = Math.max(1, Math.round(maxProp));\n const [value, setValue] = useControlled<number | null>({\n value: valueProp,\n defaultValue,\n onChange: onValueChange as ((v: number | null) => void) | undefined,\n });\n const auto = useId();\n const name = nameProp ?? auto;\n const styled = useCss('Rating', 'root', css);\n const root = useAnimationRoot(rest);\n const stars = Array.from({ length: max }, (_, i) => i + 1);\n const icon = ICON[size];\n const clamped = Math.min(max, Math.max(0, value ?? 0));\n\n if (readOnly) {\n const Root = (as ?? 'span') as ElementType;\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-rating', styled.className, className)}\n role=\"img\"\n aria-label={`${label}: ${labels.value(shown(clamped), max)}`}\n data-readonly=\"\"\n data-size={size}\n style={{ '--slurp-rating-ratio': clamped / max, ...style } as CSSProperties}\n {...root}\n >\n <span className=\"slurp-rating-track\" aria-hidden=\"true\">\n {stars.map((n) => (\n <StarIcon key={n} size={icon} className=\"slurp-rating-icon\" />\n ))}\n <span className=\"slurp-rating-fill\">\n {stars.map((n) => (\n <StarIcon key={n} size={icon} className=\"slurp-rating-icon\" fill=\"currentColor\" />\n ))}\n </span>\n </span>\n </Root>\n </>\n );\n }\n\n const Root = (as ?? 'fieldset') as ElementType;\n const fieldset = Root === 'fieldset';\n const Legend = fieldset ? 'legend' : 'span';\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-rating', styled.className, className)}\n data-size={size}\n data-disabled={disabled ? '' : undefined}\n disabled={fieldset ? disabled : undefined}\n role={fieldset ? undefined : 'radiogroup'}\n aria-labelledby={fieldset ? undefined : `${auto}-label`}\n style={style}\n {...root}\n >\n <Legend id={`${auto}-label`} className=\"slurp-rating-label\">\n {label}\n </Legend>\n <span className=\"slurp-rating-stars\">\n {stars.map((n) => {\n const on = n <= clamped;\n return (\n <label key={n} className=\"slurp-rating-star\" data-on={on ? '' : undefined}>\n <input\n type=\"radio\"\n className=\"slurp-rating-input\"\n name={name}\n value={n}\n checked={value === n}\n disabled={disabled}\n aria-label={labels.star(n)}\n onChange={() => setValue(n)}\n />\n <StarIcon\n size={icon}\n className=\"slurp-rating-icon\"\n fill={on ? 'currentColor' : 'none'}\n />\n </label>\n );\n })}\n </span>\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,gBAA8B;CACzC,QAAQ,GAAG,QAAQ,GAAG,EAAE,MAAM;CAC9B,OAAO,MAAO,MAAM,IAAI,aAAa,GAAG,EAAE;AAC5C;AAuBA,MAAM,OAAoC;CAAE,IAAI;CAAI,IAAI;CAAI,IAAI;AAAG;;AAGnE,MAAM,SAAS,MAAe,OAAO,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;;;;;AAM3E,SAAgB,OAA2C,OAAuB;CAChF,MAAM,EACJ,IACA,KACA,WACA,OACA,OAAO,WACP,eAAe,MACf,eACA,KAAK,UAAU,GACf,WAAW,OACX,MAAM,UACN,WAAW,OACX,OAAO,MACP,QAAQ,YACR,OACA,GAAG,SACD,cAAc,UAAU,KAAoB;CAChD,MAAM,SAAS;EAAE,GAAG;EAAe,GAAG,UAAU,QAAQ;EAAG,GAAG;CAAW;CACzE,MAAM,MAAM,KAAK,IAAI,GAAG,KAAK,MAAM,OAAO,CAAC;CAC3C,MAAM,CAAC,OAAO,YAAY,cAA6B;EACrD,OAAO;EACP;EACA,UAAU;CACZ,CAAC;CACD,MAAM,OAAO,MAAM;CACnB,MAAM,OAAO,YAAY;CACzB,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG;CAC3C,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,MAAM,KAAK,EAAE,QAAQ,IAAI,IAAI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C,QAAD;GAAM,WAAU;GACb,UAAA,MAAM,KAAK,MAAM;IAChB,MAAM,KAAK,KAAK;IAChB,OACE,qBAAC,SAAD;KAAe,WAAU;KAAoB,WAAS,KAAK,KAAK,KAAA;KAAhE,UAAA,CACE,oBAAC,SAAD;MACE,MAAK;MACL,WAAU;MACJ;MACN,OAAO;MACP,SAAS,UAAU;MACT;MACV,cAAY,OAAO,KAAK,CAAC;MACzB,gBAAgB,SAAS,CAAC;KAC3B,CAAA,GACD,oBAAC,UAAD;MACE,MAAM;MACN,WAAU;MACV,MAAM,KAAK,iBAAiB;KAC7B,CAAA,CACI;IAhBK,GAAA,CAgBL;GAEX,CAAC;EACG,CAAA,CACF;CACN,CAAA,CAAA,EAAA,CAAA;AAEN"}
@@ -5,7 +5,7 @@ import { ElementType } from "react";
5
5
  export interface SearchLabels {
6
6
  /** Name of the field (read by screen readers; hidden). */
7
7
  label: string;
8
- /** Says where it looks: "Cerca in Smartphone…". */
8
+ /** Says where it looks: "Cerca in Archivio…". */
9
9
  placeholder: string;
10
10
  /** Name of the clear button. */
11
11
  clear: string;
@@ -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";
@@ -20,6 +21,7 @@ function Search(props) {
20
21
  const { as, css, className, value: valueProp, defaultValue = "", onValueChange, onSearch, count, labels: labelsProp, parts, partProps, classNames, ...others } = useThemeProps("Search", props);
21
22
  const labels = {
22
23
  ...SEARCH_LABELS,
24
+ ...useLabels("Search"),
23
25
  ...labelsProp
24
26
  };
25
27
  const { input, root: rest } = splitInputProps(others);
@@ -1 +1 @@
1
- {"version":3,"file":"Search.js","names":[],"sources":["../../src/Search/Search.tsx"],"sourcesContent":["import { CloseIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n} from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { splitInputProps, type InputAttributes } from '../Field/Field';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface SearchLabels {\n /** Name of the field (read by screen readers; hidden). */\n label: string;\n /** Says where it looks: \"Cerca in Smartphone…\". */\n placeholder: string;\n /** Name of the clear button. */\n clear: string;\n /** Result count, announced politely while typing. */\n results: (count: number) => string;\n}\n\nexport const SEARCH_LABELS: SearchLabels = {\n label: 'Cerca',\n placeholder: 'Cerca…',\n clear: 'Cancella la ricerca',\n results: (n) => (n === 0 ? 'Nessun risultato' : n === 1 ? '1 risultato' : `${n} risultati`),\n};\n\nexport interface SearchOwnProps\n extends Omit<InputAttributes, 'type'>, PartsProps<'icon' | 'control' | 'clear' | 'status'> {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Enter. */\n onSearch?: (value: string) => void;\n /** Number of results: shown at the end of the field and announced (polite live region). */\n count?: number;\n labels?: Partial<SearchLabels>;\n}\n\nexport type SearchProps<E extends ElementType = 'div'> = PolymorphicProps<E, SearchOwnProps>;\n\n/** Search field: icon, contextual placeholder, result count, clear button. */\nexport function Search<E extends ElementType = 'div'>(props: SearchProps<E>) {\n const {\n as,\n css,\n className,\n value: valueProp,\n defaultValue = '',\n onValueChange,\n onSearch,\n count,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...others\n } = useThemeProps('Search', props as SearchProps);\n const labels = { ...SEARCH_LABELS, ...labelsProp };\n const { input, root: rest } = splitInputProps(others);\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const statusId = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Search', 'root', css);\n const { part, style } = useParts('Search', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const typed = value.trim() !== '';\n const userKeyDown = input.onKeyDown as ((e: KeyboardEvent<HTMLInputElement>) => void) | undefined;\n return (\n <>\n {styled.style}\n {style}\n <Root\n role=\"search\"\n className={cx('slurp-search', styled.className, className)}\n data-typed={typed ? '' : undefined}\n {...root}\n >\n {part('icon', 'span', {\n className: 'slurp-search-icon',\n 'aria-hidden': true,\n children: <SearchIcon size={18} />,\n })}\n {part('control', 'input', {\n ...input,\n type: 'search',\n className: 'slurp-search-control',\n 'aria-label': labels.label,\n 'aria-describedby': count != null && typed ? statusId : undefined,\n placeholder: input.placeholder ?? labels.placeholder,\n enterKeyHint: input.enterKeyHint ?? 'search',\n autoComplete: input.autoComplete ?? 'off',\n value,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value),\n onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => {\n userKeyDown?.(e);\n if (e.key === 'Enter' && !e.defaultPrevented) onSearch?.(value);\n },\n })}\n {part('status', 'span', {\n id: statusId,\n className: 'slurp-search-count',\n role: 'status',\n children: count != null && typed ? labels.results(count) : '',\n })}\n {typed &&\n part('clear', Bubble, {\n className: 'slurp-search-clear',\n label: labels.clear,\n size: 'sm',\n onClick: (e: MouseEvent<HTMLElement>) => {\n setValue('');\n e.currentTarget.parentElement?.querySelector('input')?.focus();\n },\n children: <CloseIcon size={18} />,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AA4BA,MAAa,gBAA8B;CACzC,OAAO;CACP,aAAa;CACb,OAAO;CACP,UAAU,MAAO,MAAM,IAAI,qBAAqB,MAAM,IAAI,gBAAgB,GAAG,EAAE;AACjF;;AAiBA,SAAgB,OAAsC,OAAuB;CAC3E,MAAM,EACJ,IACA,KACA,WACA,OAAO,WACP,eAAe,IACf,eACA,UACA,OACA,QAAQ,YACR,OACA,WACA,YACA,GAAG,WACD,cAAc,UAAU,KAAoB;CAChD,MAAM,SAAS;EAAE,GAAG;E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KACX,OAAO,OAAO;KACd,MAAM;KACN,UAAU,MAA+B;MACvC,SAAS,EAAE;MACX,EAAE,cAAc,eAAe,cAAc,OAAO,CAAC,EAAE,MAAM;KAC/D;KACA,UAAU,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;IAClC,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"Search.js","names":[],"sources":["../../src/Search/Search.tsx"],"sourcesContent":["import { CloseIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n} from 'react';\n\nimport { useLabels } from '../internal/labels';\nimport { Bubble } from '../Bubble/Bubble';\nimport { splitInputProps, type InputAttributes } from '../Field/Field';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface SearchLabels {\n /** Name of the field (read by screen readers; hidden). */\n label: string;\n /** Says where it looks: \"Cerca in Archivio…\". */\n placeholder: string;\n /** Name of the clear button. */\n clear: string;\n /** Result count, announced politely while typing. */\n results: (count: number) => string;\n}\n\nexport const SEARCH_LABELS: SearchLabels = {\n label: 'Cerca',\n placeholder: 'Cerca…',\n clear: 'Cancella la ricerca',\n results: (n) => (n === 0 ? 'Nessun risultato' : n === 1 ? '1 risultato' : `${n} risultati`),\n};\n\nexport interface SearchOwnProps\n extends Omit<InputAttributes, 'type'>, PartsProps<'icon' | 'control' | 'clear' | 'status'> {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Enter. */\n onSearch?: (value: string) => void;\n /** Number of results: shown at the end of the field and announced (polite live region). */\n count?: number;\n labels?: Partial<SearchLabels>;\n}\n\nexport type SearchProps<E extends ElementType = 'div'> = PolymorphicProps<E, SearchOwnProps>;\n\n/** Search field: icon, contextual placeholder, result count, clear button. */\nexport function Search<E extends ElementType = 'div'>(props: SearchProps<E>) {\n const {\n as,\n css,\n className,\n value: valueProp,\n defaultValue = '',\n onValueChange,\n onSearch,\n count,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...others\n } = useThemeProps('Search', props as SearchProps);\n const labels = { ...SEARCH_LABELS, ...useLabels('Search'), ...labelsProp };\n const { input, root: rest } = splitInputProps(others);\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const statusId = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Search', 'root', css);\n const { part, style } = useParts('Search', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const typed = value.trim() !== '';\n const userKeyDown = input.onKeyDown as ((e: KeyboardEvent<HTMLInputElement>) => void) | undefined;\n return (\n <>\n {styled.style}\n {style}\n <Root\n role=\"search\"\n className={cx('slurp-search', styled.className, className)}\n data-typed={typed ? '' : undefined}\n {...root}\n >\n {part('icon', 'span', {\n className: 'slurp-search-icon',\n 'aria-hidden': true,\n children: <SearchIcon size={18} />,\n })}\n {part('control', 'input', {\n ...input,\n type: 'search',\n className: 'slurp-search-control',\n 'aria-label': labels.label,\n 'aria-describedby': count != null && typed ? statusId : undefined,\n placeholder: input.placeholder ?? labels.placeholder,\n enterKeyHint: input.enterKeyHint ?? 'search',\n autoComplete: input.autoComplete ?? 'off',\n value,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value),\n onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => {\n userKeyDown?.(e);\n if (e.key === 'Enter' && !e.defaultPrevented) onSearch?.(value);\n },\n })}\n {part('status', 'span', {\n id: statusId,\n className: 'slurp-search-count',\n role: 'status',\n children: count != null && typed ? labels.results(count) : '',\n })}\n {typed &&\n part('clear', Bubble, {\n className: 'slurp-search-clear',\n label: labels.clear,\n size: 'sm',\n onClick: (e: MouseEvent<HTMLElement>) => {\n setValue('');\n e.currentTarget.parentElement?.querySelector('input')?.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AA;KACxD,aAAa,MAAM,eAAe,OAAO;KACzC,cAAc,MAAM,gBAAgB;KACpC,cAAc,MAAM,gBAAgB;KACpC;KACA,WAAW,MAAqC,SAAS,EAAE,OAAO,KAAK;KACvE,YAAY,MAAuC;MACjD,cAAc,CAAC;MACf,IAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,kBAAkB,WAAW,KAAK;KAChE;IACF,CAAC;IACA,KAAK,UAAU,QAAQ;KACtB,IAAI;KACJ,WAAW;KACX,MAAM;KACN,UAAU,SAAS,QAAQ,QAAQ,OAAO,QAAQ,KAAK,IAAI;IAC7D,CAAC;IACA,SACC,KAAK,SAAS,QAAQ;KACpB,WAAW;KACX,OAAO,OAAO;KACd,MAAM;KACN,UAAU,MAA+B;MACvC,SAAS,EAAE;MACX,EAAE,cAAc,eAAe,cAAc,OAAO,CAAC,EAAE,MAAM;KAC/D;KACA,UAAU,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;IAClC,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
@@ -0,0 +1,17 @@
1
+
2
+ import { FieldProps } from "../Field/Field.js";
3
+ import { ElementType } from "react";
4
+ export interface SecretFieldLabels {
5
+ /** Name of the toggle (a pressed button shows the secret). */
6
+ show: string;
7
+ }
8
+ export declare const SECRETFIELD_LABELS: SecretFieldLabels;
9
+ export type SecretFieldProps<E extends ElementType = 'div'> = Omit<FieldProps<E>, 'type' | 'multiline' | 'rows'> & {
10
+ labels?: Partial<SecretFieldLabels>;
11
+ };
12
+ /**
13
+ * A password field: a Field (label, hint, error) whose secret can be shown with a pressed toggle. Password managers
14
+ * keep working: it stays a real `type="password"` input until shown.
15
+ */
16
+ export declare function SecretField<E extends ElementType = 'div'>(props: SecretFieldProps<E>): import("react").JSX.Element;
17
+ //# sourceMappingURL=SecretField.d.ts.map
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import { useLabels } from "../internal/labels.js";
3
+ import { cx } from "../utils/src/index.js";
4
+ import { useThemeProps } from "../internal/styled.js";
5
+ import { Bubble } from "../Bubble/Bubble.js";
6
+ import { Field } from "../Field/Field.js";
7
+ import { useState } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { EyeIcon, EyeOffIcon } from "@slurp-ui/icons";
10
+ // src/SecretField/SecretField.tsx
11
+ const SECRETFIELD_LABELS = { show: "Mostra la password" };
12
+ /** The input plus the toggle, in place of Field's control. */
13
+ function SecretControl({ shown, onToggle, toggleLabel, className, ...input }) {
14
+ return /* @__PURE__ */ jsxs("span", {
15
+ className: "slurp-secret-field-control",
16
+ children: [/* @__PURE__ */ jsx("input", {
17
+ className,
18
+ ...input
19
+ }), /* @__PURE__ */ jsx(Bubble, {
20
+ className: "slurp-secret-field-toggle",
21
+ appearance: "plain",
22
+ tone: "neutral",
23
+ size: "sm",
24
+ label: toggleLabel,
25
+ "aria-pressed": shown,
26
+ onClick: onToggle,
27
+ children: shown ? /* @__PURE__ */ jsx(EyeOffIcon, { size: 18 }) : /* @__PURE__ */ jsx(EyeIcon, { size: 18 })
28
+ })]
29
+ });
30
+ }
31
+ /**
32
+ * A password field: a Field (label, hint, error) whose secret can be shown with a pressed toggle. Password managers
33
+ * keep working: it stays a real `type="password"` input until shown.
34
+ */
35
+ function SecretField(props) {
36
+ const { labels: labelsProp, className, autoComplete = "current-password", ...rest } = useThemeProps("SecretField", props);
37
+ const labels = {
38
+ ...SECRETFIELD_LABELS,
39
+ ...useLabels("SecretField"),
40
+ ...labelsProp
41
+ };
42
+ const [shown, setShown] = useState(false);
43
+ return /* @__PURE__ */ jsx(Field, {
44
+ ...rest,
45
+ className: cx("slurp-secret-field", className),
46
+ type: shown ? "text" : "password",
47
+ autoComplete,
48
+ spellCheck: false,
49
+ parts: { control: SecretControl },
50
+ partProps: { control: {
51
+ shown,
52
+ onToggle: () => setShown((s) => !s),
53
+ toggleLabel: labels.show
54
+ } }
55
+ });
56
+ }
57
+ export { SECRETFIELD_LABELS, SecretField };
58
+
59
+ //# sourceMappingURL=SecretField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecretField.js","names":[],"sources":["../../src/SecretField/SecretField.tsx"],"sourcesContent":["import { EyeIcon, EyeOffIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useState, type ElementType } from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { Field, type FieldProps } from '../Field/Field';\nimport { useLabels } from '../internal/labels';\nimport { useThemeProps } from '../internal/styled';\n\nexport interface SecretFieldLabels {\n /** Name of the toggle (a pressed button shows the secret). */\n show: string;\n}\n\nexport const SECRETFIELD_LABELS: SecretFieldLabels = { show: 'Mostra la password' };\n\nexport type SecretFieldProps<E extends ElementType = 'div'> = Omit<\n FieldProps<E>,\n 'type' | 'multiline' | 'rows'\n> & {\n labels?: Partial<SecretFieldLabels>;\n};\n\ninterface ControlProps extends Record<string, unknown> {\n shown: boolean;\n onToggle: () => void;\n toggleLabel: string;\n className?: string;\n}\n\n/** The input plus the toggle, in place of Field's control. */\nfunction SecretControl({ shown, onToggle, toggleLabel, className, ...input }: ControlProps) {\n return (\n <span className=\"slurp-secret-field-control\">\n <input className={className} {...input} />\n <Bubble\n className=\"slurp-secret-field-toggle\"\n appearance=\"plain\"\n tone=\"neutral\"\n size=\"sm\"\n label={toggleLabel}\n aria-pressed={shown}\n onClick={onToggle}\n >\n {shown ? <EyeOffIcon size={18} /> : <EyeIcon size={18} />}\n </Bubble>\n </span>\n );\n}\n\n/**\n * A password field: a Field (label, hint, error) whose secret can be shown with a pressed toggle. Password managers\n * keep working: it stays a real `type=\"password\"` input until shown.\n */\nexport function SecretField<E extends ElementType = 'div'>(props: SecretFieldProps<E>) {\n const {\n labels: labelsProp,\n className,\n autoComplete = 'current-password',\n ...rest\n } = useThemeProps('SecretField', props as SecretFieldProps);\n const labels = { ...SECRETFIELD_LABELS, ...useLabels('SecretField'), ...labelsProp };\n const [shown, setShown] = useState(false);\n return (\n <Field\n {...(rest as FieldProps)}\n className={cx('slurp-secret-field', className)}\n type={shown ? 'text' : 'password'}\n autoComplete={autoComplete}\n spellCheck={false}\n parts={{ control: SecretControl }}\n partProps={{\n control: { shown, onToggle: () => setShown((s) => !s), toggleLabel: labels.show },\n }}\n />\n );\n}\n"],"mappings":";;;;;;;;;;AAcA,MAAa,qBAAwC,EAAE,MAAM,qBAAqB;;AAiBlF,SAAS,cAAc,EAAE,OAAO,UAAU,aAAa,WAAW,GAAG,SAAuB;CAC1F,OACE,qBAAC,QAAD;EAAM,WAAU;EAAhB,UAAA,CACE,oBAAC,SAAD;GAAkB;GAAW,GAAI;EAAQ,CAAA,GACzC,oBAAC,QAAD;GACE,WAAU;GACV,YAAW;GACX,MAAK;GACL,MAAK;GACL,OAAO;GACP,gBAAc;GACd,SAAS;GAER,UAAA,QAAQ,oBAAC,YAAD,EAAY,MAAM,GAAK,CAAA,IAAI,oBAAC,SAAD,EAAS,MAAM,GAAK,CAAA;EAClD,CAAA,CACJ;;AAEV;;;;;AAMA,SAAgB,YAA2C,OAA4B;CACrF,MAAM,EACJ,QAAQ,YACR,WACA,eAAe,oBACf,GAAG,SACD,cAAc,eAAe,KAAyB;CAC1D,MAAM,SAAS;EAAE,GAAG;EAAoB,GAAG,UAAU,aAAa;EAAG,GAAG;CAAW;CACnF,MAAM,CAAC,OAAO,YAAY,SAAS,KAAK;CACxC,OACE,oBAAC,OAAD;EACE,GAAK;EACL,WAAW,GAAG,sBAAsB,SAAS;EAC7C,MAAM,QAAQ,SAAS;EACT;EACd,YAAY;EACZ,OAAO,EAAE,SAAS,cAAc;EAChC,WAAW,EACT,SAAS;GAAE;GAAO,gBAAgB,UAAU,MAAM,CAAC,CAAC;GAAG,aAAa,OAAO;EAAK,EAClF;CACD,CAAA;AAEL"}
@@ -0,0 +1,3 @@
1
+
2
+ import { SECRETFIELD_LABELS, SecretField, SecretFieldLabels, SecretFieldProps } from "./SecretField.js";
3
+ export { SECRETFIELD_LABELS, SecretField, type SecretFieldLabels, type SecretFieldProps, SecretField as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { SECRETFIELD_LABELS, SecretField, SecretField as default } from "./SecretField.js";
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { useColorScheme } from "../internal/context.js";
3
+ import { useLabels } from "../internal/labels.js";
3
4
  import { cx } from "../utils/src/index.js";
4
5
  import { useThemeProps } from "../internal/styled.js";
5
6
  import { Radio, RadioGroup } from "../Radio/Radio.js";
@@ -27,6 +28,7 @@ function Settings(props) {
27
28
  const { languages, language, onLanguageChange, children, width = 300, inline = false, labels: labelsProp, className, css } = useThemeProps("Settings", props);
28
29
  const labels = {
29
30
  ...SETTINGS_LABELS,
31
+ ...useLabels("Settings"),
30
32
  ...labelsProp
31
33
  };
32
34
  const { mode, setMode } = useColorScheme();
@@ -1 +1 @@
1
- {"version":3,"file":"Settings.js","names":[],"sources":["../../src/Settings/Settings.tsx"],"sourcesContent":["import { AutoIcon, CloseIcon, GearIcon, MoonIcon, SunIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ReactNode } from 'react';\n\nimport { Bloom } from '../Bloom/Bloom';\nimport { useColorScheme } from '../internal/context';\nimport { useThemeProps } from '../internal/styled';\nimport type { SlurpCss } from '../lib/css';\nimport type { ColorSchemeMode } from '../lib/theme';\nimport { Radio, RadioGroup } from '../Radio/Radio';\n\nexport interface SettingsLabels {\n /** Name of the button. */\n open: string;\n /** Name of the button while open. */\n close: string;\n /** Title of the panel. */\n title: string;\n theme: string;\n system: string;\n light: string;\n dark: string;\n language: string;\n}\n\nexport const SETTINGS_LABELS: SettingsLabels = {\n open: 'Impostazioni',\n close: 'Chiudi impostazioni',\n title: 'Impostazioni',\n theme: 'Tema',\n system: 'Automatico',\n light: 'Chiaro',\n dark: 'Scuro',\n language: 'Lingua',\n};\n\nexport interface SettingsLanguage {\n value: string;\n /** Written in itself (\"Italiano\", \"English\"). */\n label: string;\n /** BCP 47 tag of the label (\"it\", \"en\"). */\n lang: string;\n}\n\nexport interface SettingsProps {\n /**\n * Languages: the Lingua choice appears only when they are given (the library has no i18n of its own: apply the\n * choice yourself).\n */\n languages?: SettingsLanguage[];\n language?: string;\n onLanguageChange?: (value: string) => void;\n /** More preferences (RadioGroup with `appearance=\"rows\"`), or a short note. */\n children?: ReactNode;\n /** Panel width. Default 300. */\n width?: number;\n /** In the flow instead of fixed at the top right. */\n inline?: boolean;\n labels?: Partial<SettingsLabels>;\n className?: string;\n css?: SlurpCss;\n}\n\n/**\n * Site settings: a round button at the top right that grows into its own panel (Bloom) and shrinks back. Tema is\n * always there (Automatico / Chiaro / Scuro, through useColorScheme); Lingua only when `languages` is set.\n * Needs a SlurpProvider.\n */\nexport function Settings(props: SettingsProps) {\n const {\n languages,\n language,\n onLanguageChange,\n children,\n width = 300,\n inline = false,\n labels: labelsProp,\n className,\n css,\n } = useThemeProps('Settings', props);\n const labels = { ...SETTINGS_LABELS, ...labelsProp };\n const { mode, setMode } = useColorScheme();\n const titleId = useId();\n return (\n <div className={cx('slurp-settings', className)} data-inline={inline || undefined}>\n <Bloom\n trigger={<GearIcon size={22} />}\n openTrigger={<CloseIcon size={22} />}\n label={labels.open}\n closeLabel={labels.close}\n placement=\"bottom-end\"\n width={width}\n css={css}\n partProps={{ panel: { 'aria-labelledby': titleId } }}\n >\n <h2 id={titleId} className=\"slurp-settings-title\">\n {labels.title}\n </h2>\n <RadioGroup\n label={labels.theme}\n appearance=\"rows\"\n value={mode}\n onValueChange={(v) => setMode(v as ColorSchemeMode)}\n >\n <Radio value=\"system\" icon={<AutoIcon />}>\n {labels.system}\n </Radio>\n <Radio value=\"light\" icon={<SunIcon />}>\n {labels.light}\n </Radio>\n <Radio value=\"dark\" icon={<MoonIcon />}>\n {labels.dark}\n </Radio>\n </RadioGroup>\n {languages?.length ? (\n <RadioGroup\n label={labels.language}\n appearance=\"rows\"\n value={language ?? null}\n onValueChange={onLanguageChange}\n >\n {languages.map((l) => (\n <Radio key={l.value} value={l.value} lang={l.lang}>\n {l.label}\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,CAAA;KACG;;IACX,WAAW,SACV,oBAAC,YAAD;KACE,OAAO,OAAO;KACd,YAAW;KACX,OAAO,YAAY;KACnB,eAAe;KAEd,UAAA,UAAU,KAAK,MACd,oBAAC,OAAD;MAAqB,OAAO,EAAE;MAAO,MAAM,EAAE;MAC1C,UAAA,EAAE;KACE,GAFK,EAAE,KAEP,CACR;IACS,CAAA,IACV;IACH;GACI;;CACJ,CAAA;AAET"}
1
+ {"version":3,"file":"Settings.js","names":[],"sources":["../../src/Settings/Settings.tsx"],"sourcesContent":["import { AutoIcon, CloseIcon, GearIcon, MoonIcon, SunIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ReactNode } from 'react';\n\nimport { useLabels } from '../internal/labels';\nimport { Bloom } from '../Bloom/Bloom';\nimport { useColorScheme } from '../internal/context';\nimport { useThemeProps } from '../internal/styled';\nimport type { SlurpCss } from '../lib/css';\nimport type { ColorSchemeMode } from '../lib/theme';\nimport { Radio, RadioGroup } from '../Radio/Radio';\n\nexport interface SettingsLabels {\n /** Name of the button. */\n open: string;\n /** Name of the button while open. */\n close: string;\n /** Title of the panel. */\n title: string;\n theme: string;\n system: string;\n light: string;\n dark: string;\n language: string;\n}\n\nexport const SETTINGS_LABELS: SettingsLabels = {\n open: 'Impostazioni',\n close: 'Chiudi impostazioni',\n title: 'Impostazioni',\n theme: 'Tema',\n system: 'Automatico',\n light: 'Chiaro',\n dark: 'Scuro',\n language: 'Lingua',\n};\n\nexport interface SettingsLanguage {\n value: string;\n /** Written in itself (\"Italiano\", \"English\"). */\n label: string;\n /** BCP 47 tag of the label (\"it\", \"en\"). */\n lang: string;\n}\n\nexport interface SettingsProps {\n /**\n * Languages: the Lingua choice appears only when they are given (the library has no i18n of its own: apply the\n * choice yourself).\n */\n languages?: SettingsLanguage[];\n language?: string;\n onLanguageChange?: (value: string) => void;\n /** More preferences (RadioGroup with `appearance=\"rows\"`), or a short note. */\n children?: ReactNode;\n /** Panel width. Default 300. */\n width?: number;\n /** In the flow instead of fixed at the top right. */\n inline?: boolean;\n labels?: Partial<SettingsLabels>;\n className?: string;\n css?: SlurpCss;\n}\n\n/**\n * Site settings: a round button at the top right that grows into its own panel (Bloom) and shrinks back. Tema is\n * always there (Automatico / Chiaro / Scuro, through useColorScheme); Lingua only when `languages` is set.\n * Needs a SlurpProvider.\n */\nexport function Settings(props: SettingsProps) {\n const {\n languages,\n language,\n onLanguageChange,\n children,\n width = 300,\n inline = false,\n labels: labelsProp,\n className,\n css,\n } = useThemeProps('Settings', props);\n const labels = { ...SETTINGS_LABELS, ...useLabels('Settings'), ...labelsProp };\n const { mode, setMode } = useColorScheme();\n const titleId = useId();\n return (\n <div className={cx('slurp-settings', className)} data-inline={inline || undefined}>\n <Bloom\n trigger={<GearIcon size={22} />}\n openTrigger={<CloseIcon size={22} />}\n label={labels.open}\n closeLabel={labels.close}\n placement=\"bottom-end\"\n width={width}\n css={css}\n partProps={{ panel: { 'aria-labelledby': titleId } }}\n >\n <h2 id={titleId} className=\"slurp-settings-title\">\n {labels.title}\n </h2>\n <RadioGroup\n label={labels.theme}\n appearance=\"rows\"\n value={mode}\n onValueChange={(v) => setMode(v as ColorSchemeMode)}\n >\n <Radio value=\"system\" icon={<AutoIcon />}>\n {labels.system}\n </Radio>\n <Radio value=\"light\" icon={<SunIcon />}>\n {labels.light}\n </Radio>\n <Radio value=\"dark\" icon={<MoonIcon />}>\n {labels.dark}\n </Radio>\n </RadioGroup>\n {languages?.length ? (\n <RadioGroup\n label={labels.language}\n appearance=\"rows\"\n value={language ?? null}\n onValueChange={onLanguageChange}\n >\n {languages.map((l) => (\n <Radio key={l.value} value={l.value} lang={l.lang}>\n {l.label}\n </Radio>\n ))}\n </RadioGroup>\n ) : null}\n {children}\n </Bloom>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AA0BA,MAAa,kBAAkC;CAC7C,MAAM;CACN,OAAO;CACP,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;CACP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EAAE;MAAO,MAAM,EAAE;MAC1C,UAAA,EAAE;KACE,GAFK,EAAE,KAEP,CACR;IACS,CAAA,IACV;IACH;GACI;;CACJ,CAAA;AAET"}
@@ -0,0 +1,22 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType, ReactNode } from "react";
4
+ export interface SkipLinkLabels {
5
+ /** The link's text. */
6
+ label: string;
7
+ }
8
+ export declare const SKIPLINK_LABELS: SkipLinkLabels;
9
+ export interface SkipLinkOwnProps {
10
+ /** Where it jumps: the id of the main content, with `#`. Default `#content`. */
11
+ href?: string;
12
+ /** Default `labels.label`. */
13
+ children?: ReactNode;
14
+ labels?: Partial<SkipLinkLabels>;
15
+ }
16
+ export type SkipLinkProps<E extends ElementType = 'a'> = PolymorphicProps<E, SkipLinkOwnProps>;
17
+ /**
18
+ * "Skip to content": the first thing Tab reaches on a page. Out of sight until focused, then a pill at the top left.
19
+ * Give the target an id and `tabIndex={-1}` so focus lands on it.
20
+ */
21
+ export declare function SkipLink<E extends ElementType = 'a'>(props: SkipLinkProps<E>): import("react").JSX.Element;
22
+ //# sourceMappingURL=SkipLink.d.ts.map
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { useLabels } from "../internal/labels.js";
3
+ import { cx } from "../utils/src/index.js";
4
+ import { useAnimationRoot } from "../internal/animation.js";
5
+ import { useCss, useThemeProps } from "../internal/styled.js";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ // src/SkipLink/SkipLink.tsx
8
+ const SKIPLINK_LABELS = { label: "Vai al contenuto" };
9
+ /**
10
+ * "Skip to content": the first thing Tab reaches on a page. Out of sight until focused, then a pill at the top left.
11
+ * Give the target an id and `tabIndex={-1}` so focus lands on it.
12
+ */
13
+ function SkipLink(props) {
14
+ const { as, css, className, href = "#content", children, labels: labelsProp, ...rest } = useThemeProps("SkipLink", props);
15
+ const labels = {
16
+ ...SKIPLINK_LABELS,
17
+ ...useLabels("SkipLink"),
18
+ ...labelsProp
19
+ };
20
+ const Root = as ?? "a";
21
+ const styled = useCss("SkipLink", "root", css);
22
+ const root = useAnimationRoot(rest);
23
+ return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
24
+ className: cx("slurp-skip-link", styled.className, className),
25
+ href,
26
+ ...root,
27
+ children: children ?? labels.label
28
+ })] });
29
+ }
30
+ export { SKIPLINK_LABELS, SkipLink };
31
+
32
+ //# sourceMappingURL=SkipLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkipLink.js","names":[],"sources":["../../src/SkipLink/SkipLink.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useLabels } from '../internal/labels';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface SkipLinkLabels {\n /** The link's text. */\n label: string;\n}\n\nexport const SKIPLINK_LABELS: SkipLinkLabels = { label: 'Vai al contenuto' };\n\nexport interface SkipLinkOwnProps {\n /** Where it jumps: the id of the main content, with `#`. Default `#content`. */\n href?: string;\n /** Default `labels.label`. */\n children?: ReactNode;\n labels?: Partial<SkipLinkLabels>;\n}\n\nexport type SkipLinkProps<E extends ElementType = 'a'> = PolymorphicProps<E, SkipLinkOwnProps>;\n\n/**\n * \"Skip to content\": the first thing Tab reaches on a page. Out of sight until focused, then a pill at the top left.\n * Give the target an id and `tabIndex={-1}` so focus lands on it.\n */\nexport function SkipLink<E extends ElementType = 'a'>(props: SkipLinkProps<E>) {\n const {\n as,\n css,\n className,\n href = '#content',\n children,\n labels: labelsProp,\n ...rest\n } = useThemeProps('SkipLink', props as SkipLinkProps);\n const labels = { ...SKIPLINK_LABELS, ...useLabels('SkipLink'), ...labelsProp };\n const Root = (as ?? 'a') as ElementType;\n const styled = useCss('SkipLink', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-skip-link', styled.className, className)} href={href} {...root}>\n {children ?? labels.label}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;AAaA,MAAa,kBAAkC,EAAE,OAAO,mBAAmB;;;;;AAgB3E,SAAgB,SAAsC,OAAyB;CAC7E,MAAM,EACJ,IACA,KACA,WACA,OAAO,YACP,UACA,QAAQ,YACR,GAAG,SACD,cAAc,YAAY,KAAsB;CACpD,MAAM,SAAS;EAAE,GAAG;EAAiB,GAAG,UAAU,UAAU;EAAG,GAAG;CAAW;CAC7E,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;EAAM,WAAW,GAAG,mBAAmB,OAAO,WAAW,SAAS;EAAS;EAAM,GAAI;EAClF,UAAA,YAAY,OAAO;CAChB,CAAA,CACN,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { SKIPLINK_LABELS, SkipLink, SkipLinkLabels, SkipLinkProps } from "./SkipLink.js";
3
+ export { SKIPLINK_LABELS, SkipLink, type SkipLinkLabels, type SkipLinkProps, SkipLink as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { SKIPLINK_LABELS, SkipLink, SkipLink as default } from "./SkipLink.js";
@@ -1,4 +1,5 @@
1
1
 
2
+ import { LabelsInput } from "../lib/labels.js";
2
3
  import { Theme } from "../lib/theme.js";
3
4
  import { ReactNode } from "react";
4
5
  export interface SlurpProviderProps {
@@ -6,6 +7,11 @@ export interface SlurpProviderProps {
6
7
  theme?: Theme;
7
8
  /** localStorage key that remembers the chosen scheme; `null` disables persistence. Default `slurp-theme`. */
8
9
  storageKey?: string | null;
10
+ /**
11
+ * Texts of every component inside: `'en'`, `'it'` (the default) or your own texts by component, e.g.
12
+ * `{ Dialog: { close: 'Dismiss' } }`. A component's own `labels` prop still wins.
13
+ */
14
+ labels?: LabelsInput;
9
15
  children?: ReactNode;
10
16
  }
11
17
  /**
@@ -14,5 +20,5 @@ export interface SlurpProviderProps {
14
20
  * hoisted <style>. Nested, it themes only its subtree (through a `display: contents` wrapper) and shares the
15
21
  * colour scheme of the outer provider.
16
22
  */
17
- export declare function SlurpProvider({ theme, storageKey, children }: SlurpProviderProps): import("react").JSX.Element;
23
+ export declare function SlurpProvider({ theme, storageKey, labels: labelsProp, children }: SlurpProviderProps): import("react").JSX.Element;
18
24
  //# sourceMappingURL=SlurpProvider.d.ts.map
@@ -1,6 +1,8 @@
1
1
  "use client";
2
2
  import { DEFAULT_STORAGE_KEY, defaultTheme, styleId, themeCss } from "../lib/theme.js";
3
3
  import { SlurpContext } from "../internal/context.js";
4
+ import { LabelsContext } from "../internal/labels.js";
5
+ import { resolveLabels } from "../lib/labels.js";
4
6
  import { useCallback, useContext, useEffect, useId, useMemo, useState, useSyncExternalStore } from "react";
5
7
  import { jsx, jsxs } from "react/jsx-runtime";
6
8
  // src/SlurpProvider/SlurpProvider.tsx
@@ -42,7 +44,8 @@ function applyMode(mode) {
42
44
  * hoisted <style>. Nested, it themes only its subtree (through a `display: contents` wrapper) and shares the
43
45
  * colour scheme of the outer provider.
44
46
  */
45
- function SlurpProvider({ theme = defaultTheme, storageKey = DEFAULT_STORAGE_KEY, children }) {
47
+ function SlurpProvider({ theme = defaultTheme, storageKey = DEFAULT_STORAGE_KEY, labels: labelsProp, children }) {
48
+ const outerLabels = useContext(LabelsContext);
46
49
  const outer = useContext(SlurpContext).colorScheme;
47
50
  const scope = useId();
48
51
  const stored = useSyncExternalStore(subscribeStorage, () => readStored(storageKey), () => null);
@@ -92,13 +95,18 @@ function SlurpProvider({ theme = defaultTheme, storageKey = DEFAULT_STORAGE_KEY,
92
95
  precedence: "slurp",
93
96
  children: css
94
97
  });
98
+ const labels = useMemo(() => resolveLabels(labelsProp), [labelsProp]);
99
+ const content = outer ? /* @__PURE__ */ jsx("div", {
100
+ "data-slurp-theme": scope,
101
+ style: { display: "contents" },
102
+ children
103
+ }) : children;
95
104
  return /* @__PURE__ */ jsxs(SlurpContext, {
96
105
  value,
97
- children: [style, outer ? /* @__PURE__ */ jsx("div", {
98
- "data-slurp-theme": scope,
99
- style: { display: "contents" },
100
- children
101
- }) : children]
106
+ children: [style, labels && labels !== outerLabels ? /* @__PURE__ */ jsx(LabelsContext, {
107
+ value: labels,
108
+ children: content
109
+ }) : content]
102
110
  });
103
111
  }
104
112
  export { SlurpProvider };
@@ -1 +1 @@
1
- {"version":3,"file":"SlurpProvider.js","names":[],"sources":["../../src/SlurpProvider/SlurpProvider.tsx"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\n\nimport { SlurpContext, type ColorSchemeState } from '../internal/context';\nimport {\n DEFAULT_STORAGE_KEY,\n defaultTheme,\n styleId,\n themeCss,\n type ColorSchemeMode,\n type Theme,\n} from '../lib/theme';\n\nconst DARK_QUERY = '(prefers-color-scheme: dark)';\n\nexport interface SlurpProviderProps {\n /** From `createTheme()`. */\n theme?: Theme;\n /** localStorage key that remembers the chosen scheme; `null` disables persistence. Default `slurp-theme`. */\n storageKey?: string | null;\n children?: ReactNode;\n}\n\nconst isMode = (v: unknown): v is ColorSchemeMode =>\n v === 'light' || v === 'dark' || v === 'system';\n\n// Storage can throw (private mode, blocked site data): every access is guarded and simply falls back.\nfunction readStored(key: string | null): ColorSchemeMode | null {\n if (!key) return null;\n try {\n const v = window.localStorage.getItem(key);\n return isMode(v) ? v : null;\n } catch {\n return null;\n }\n}\n\nconst listeners = new Set<() => void>();\nfunction subscribeStorage(onChange: () => void) {\n listeners.add(onChange);\n window.addEventListener('storage', onChange);\n return () => {\n listeners.delete(onChange);\n window.removeEventListener('storage', onChange);\n };\n}\n\nfunction subscribeSystem(onChange: () => void) {\n const query = window.matchMedia?.(DARK_QUERY);\n query?.addEventListener('change', onChange);\n return () => query?.removeEventListener('change', onChange);\n}\nconst systemSnapshot = () => (window.matchMedia?.(DARK_QUERY).matches ? 'dark' : 'light');\n\n/** Writes `data-theme` on <html>: `light` / `dark`, or no attribute for `system` (prefers-color-scheme decides). */\nfunction applyMode(mode: ColorSchemeMode) {\n const root = document.documentElement;\n if (mode === 'system') root.removeAttribute('data-theme');\n else root.setAttribute('data-theme', mode);\n}\n\n/**\n * Theme, colour scheme and runtime styles for everything inside.\n * At the app root it renders no element: the colour scheme goes on <html data-theme>, theme overrides into one\n * hoisted <style>. Nested, it themes only its subtree (through a `display: contents` wrapper) and shares the\n * colour scheme of the outer provider.\n */\nexport function SlurpProvider({\n theme = defaultTheme,\n storageKey = DEFAULT_STORAGE_KEY,\n children,\n}: SlurpProviderProps) {\n const outer = useContext(SlurpContext).colorScheme;\n const scope = useId();\n const stored = useSyncExternalStore(\n subscribeStorage,\n () => readStored(storageKey),\n () => null,\n );\n // A choice that could not be stored (or storage disabled) lives in state and wins over the stored one.\n const [local, setLocal] = useState<ColorSchemeMode | null>(null);\n const mode = local ?? stored ?? theme.colorScheme;\n const system = useSyncExternalStore(subscribeSystem, systemSnapshot, () => 'light' as const);\n\n // Reads storage again: during hydration `stored` is still the server snapshot (null) for one render.\n useEffect(() => {\n if (!outer) applyMode(local ?? readStored(storageKey) ?? theme.colorScheme);\n }, [outer, mode, local, storageKey, theme.colorScheme]);\n\n const setMode = useCallback(\n (next: ColorSchemeMode) => {\n if (!storageKey) return setLocal(next);\n try {\n window.localStorage.setItem(storageKey, next);\n setLocal(null);\n } catch {\n setLocal(next);\n }\n for (const notify of listeners) notify();\n },\n [storageKey],\n );\n\n const own = useMemo<ColorSchemeState>(\n () => ({ mode, setMode, resolved: mode === 'system' ? system : mode }),\n [mode, setMode, system],\n );\n const colorScheme = outer ?? own;\n const value = useMemo(() => ({ theme, colorScheme }), [theme, colorScheme]);\n const css = useMemo(() => themeCss(theme, outer ? scope : undefined), [theme, outer, scope]);\n\n const style = css && (\n <style href={styleId('theme', css)} precedence=\"slurp\">\n {css}\n </style>\n );\n return (\n <SlurpContext value={value}>\n {style}\n {outer ? (\n <div data-slurp-theme={scope} style={{ display: 'contents' }}>\n {children}\n </div>\n ) : (\n children\n )}\n </SlurpContext>\n );\n}\n"],"mappings":";;;;;;AAqBA,MAAM,aAAa;AAUnB,MAAM,UAAU,MACd,MAAM,WAAW,MAAM,UAAU,MAAM;AAGzC,SAAS,WAAW,KAA4C;CAC9D,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,IAAI,OAAO,aAAa,QAAQ,GAAG;EACzC,OAAO,OAAO,CAAC,IAAI,IAAI;CACzB,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAM,4BAAY,IAAI,IAAgB;AACtC,SAAS,iBAAiB,UAAsB;CAC9C,UAAU,IAAI,QAAQ;CACtB,OAAO,iBAAiB,WAAW,QAAQ;CAC3C,aAAa;EACX,UAAU,OAAO,QAAQ;EACzB,OAAO,oBAAoB,WAAW,QAAQ;CAChD;AACF;AAEA,SAAS,gBAAgB,UAAsB;CAC7C,MAAM,QAAQ,OAAO,aAAa,UAAU;CAC5C,OAAO,iBAAiB,UAAU,QAAQ;CAC1C,aAAa,OAAO,oBAAoB,UAAU,QAAQ;AAC5D;AACA,MAAM,uBAAwB,OAAO,aAAa,UAAU,CAAC,CAAC,UAAU,SAAS;;AAGjF,SAAS,UAAU,MAAuB;CACxC,MAAM,OAAO,SAAS;CACtB,IAAI,SAAS,UAAU,KAAK,gBAAgB,YAAY;MACnD,KAAK,aAAa,cAAc,IAAI;AAC3C;;;;;;;AAQA,SAAgB,cAAc,EAC5B,QAAQ,cACR,aAAa,qBACb,YACqB;CACrB,MAAM,QAAQ,WAAW,YAAY,CAAC,CAAC;CACvC,MAAM,QAAQ,MAAM;CACpB,MAAM,SAAS,qBACb,wBACM,WAAW,UAAU,SACrB,IACR;CAEA,MAAM,CAAC,OAAO,YAAY,SAAiC,IAAI;CAC/D,MAAM,OAAO,SAAS,UAAU,MAAM;CACtC,MAAM,SAAS,qBAAqB,iBAAiB,sBAAsB,OAAgB;CAG3F,gBAAgB;EACd,IAAI,CAAC,OAAO,UAAU,SAAS,WAAW,UAAU,KAAK,MAAM,WAAW;CAC5E,GAAG;EAAC;EAAO;EAAM;EAAO;EAAY,MAAM;CAAW,CAAC;CAEtD,MAAM,UAAU,aACb,SAA0B;EACzB,IAAI,CAAC,YAAY,OAAO,SAAS,IAAI;EACrC,IAAI;GACF,OAAO,aAAa,QAAQ,YAAY,IAAI;GAC5C,SAAS,IAAI;EACf,QAAQ;GACN,SAAS,IAAI;EACf;EACA,KAAK,MAAM,UAAU,WAAW,OAAO;CACzC,GACA,CAAC,UAAU,CACb;CAEA,MAAM,MAAM,eACH;EAAE;EAAM;EAAS,UAAU,SAAS,WAAW,SAAS;CAAK,IACpE;EAAC;EAAM;EAAS;CAAM,CACxB;CACA,MAAM,cAAc,SAAS;CAC7B,MAAM,QAAQ,eAAe;EAAE;EAAO;CAAY,IAAI,CAAC,OAAO,WAAW,CAAC;CAC1E,MAAM,MAAM,cAAc,SAAS,OAAO,QAAQ,QAAQ,KAAA,CAAS,GAAG;EAAC;EAAO;EAAO;CAAK,CAAC;CAE3F,MAAM,QAAQ,OACZ,oBAAC,SAAD;EAAO,MAAM,QAAQ,SAAS,GAAG;EAAG,YAAW;EAC5C,UAAA;CACI,CAAA;CAET,OACE,qBAAC,cAAD;EAAqB;EAArB,UAAA,CACG,OACA,QACC,oBAAC,OAAD;GAAK,oBAAkB;GAAO,OAAO,EAAE,SAAS,WAAW;GACxD;EACE,CAAA,IAEL,QAEU;;AAElB"}
1
+ {"version":3,"file":"SlurpProvider.js","names":[],"sources":["../../src/SlurpProvider/SlurpProvider.tsx"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\n\nimport { SlurpContext, type ColorSchemeState } from '../internal/context';\nimport { LabelsContext } from '../internal/labels';\nimport { resolveLabels, type LabelsInput } from '../lib/labels';\nimport {\n DEFAULT_STORAGE_KEY,\n defaultTheme,\n styleId,\n themeCss,\n type ColorSchemeMode,\n type Theme,\n} from '../lib/theme';\n\nconst DARK_QUERY = '(prefers-color-scheme: dark)';\n\nexport interface SlurpProviderProps {\n /** From `createTheme()`. */\n theme?: Theme;\n /** localStorage key that remembers the chosen scheme; `null` disables persistence. Default `slurp-theme`. */\n storageKey?: string | null;\n /**\n * Texts of every component inside: `'en'`, `'it'` (the default) or your own texts by component, e.g.\n * `{ Dialog: { close: 'Dismiss' } }`. A component's own `labels` prop still wins.\n */\n labels?: LabelsInput;\n children?: ReactNode;\n}\n\nconst isMode = (v: unknown): v is ColorSchemeMode =>\n v === 'light' || v === 'dark' || v === 'system';\n\n// Storage can throw (private mode, blocked site data): every access is guarded and simply falls back.\nfunction readStored(key: string | null): ColorSchemeMode | null {\n if (!key) return null;\n try {\n const v = window.localStorage.getItem(key);\n return isMode(v) ? v : null;\n } catch {\n return null;\n }\n}\n\nconst listeners = new Set<() => void>();\nfunction subscribeStorage(onChange: () => void) {\n listeners.add(onChange);\n window.addEventListener('storage', onChange);\n return () => {\n listeners.delete(onChange);\n window.removeEventListener('storage', onChange);\n };\n}\n\nfunction subscribeSystem(onChange: () => void) {\n const query = window.matchMedia?.(DARK_QUERY);\n query?.addEventListener('change', onChange);\n return () => query?.removeEventListener('change', onChange);\n}\nconst systemSnapshot = () => (window.matchMedia?.(DARK_QUERY).matches ? 'dark' : 'light');\n\n/** Writes `data-theme` on <html>: `light` / `dark`, or no attribute for `system` (prefers-color-scheme decides). */\nfunction applyMode(mode: ColorSchemeMode) {\n const root = document.documentElement;\n if (mode === 'system') root.removeAttribute('data-theme');\n else root.setAttribute('data-theme', mode);\n}\n\n/**\n * Theme, colour scheme and runtime styles for everything inside.\n * At the app root it renders no element: the colour scheme goes on <html data-theme>, theme overrides into one\n * hoisted <style>. Nested, it themes only its subtree (through a `display: contents` wrapper) and shares the\n * colour scheme of the outer provider.\n */\nexport function SlurpProvider({\n theme = defaultTheme,\n storageKey = DEFAULT_STORAGE_KEY,\n labels: labelsProp,\n children,\n}: SlurpProviderProps) {\n const outerLabels = useContext(LabelsContext);\n const outer = useContext(SlurpContext).colorScheme;\n const scope = useId();\n const stored = useSyncExternalStore(\n subscribeStorage,\n () => readStored(storageKey),\n () => null,\n );\n // A choice that could not be stored (or storage disabled) lives in state and wins over the stored one.\n const [local, setLocal] = useState<ColorSchemeMode | null>(null);\n const mode = local ?? stored ?? theme.colorScheme;\n const system = useSyncExternalStore(subscribeSystem, systemSnapshot, () => 'light' as const);\n\n // Reads storage again: during hydration `stored` is still the server snapshot (null) for one render.\n useEffect(() => {\n if (!outer) applyMode(local ?? readStored(storageKey) ?? theme.colorScheme);\n }, [outer, mode, local, storageKey, theme.colorScheme]);\n\n const setMode = useCallback(\n (next: ColorSchemeMode) => {\n if (!storageKey) return setLocal(next);\n try {\n window.localStorage.setItem(storageKey, next);\n setLocal(null);\n } catch {\n setLocal(next);\n }\n for (const notify of listeners) notify();\n },\n [storageKey],\n );\n\n const own = useMemo<ColorSchemeState>(\n () => ({ mode, setMode, resolved: mode === 'system' ? system : mode }),\n [mode, setMode, system],\n );\n const colorScheme = outer ?? own;\n const value = useMemo(() => ({ theme, colorScheme }), [theme, colorScheme]);\n const css = useMemo(() => themeCss(theme, outer ? scope : undefined), [theme, outer, scope]);\n\n const style = css && (\n <style href={styleId('theme', css)} precedence=\"slurp\">\n {css}\n </style>\n );\n const labels = useMemo(() => resolveLabels(labelsProp), [labelsProp]);\n const content = outer ? (\n <div data-slurp-theme={scope} style={{ display: 'contents' }}>\n {children}\n </div>\n ) : (\n children\n );\n return (\n <SlurpContext value={value}>\n {style}\n {labels && labels !== outerLabels ? (\n <LabelsContext value={labels}>{content}</LabelsContext>\n ) : (\n content\n )}\n </SlurpContext>\n );\n}\n"],"mappings":";;;;;;;;AAuBA,MAAM,aAAa;AAenB,MAAM,UAAU,MACd,MAAM,WAA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MAAM;CAAW,CAAC;CAEtD,MAAM,UAAU,aACb,SAA0B;EACzB,IAAI,CAAC,YAAY,OAAO,SAAS,IAAI;EACrC,IAAI;GACF,OAAO,aAAa,QAAQ,YAAY,IAAI;GAC5C,SAAS,IAAI;EACf,QAAQ;GACN,SAAS,IAAI;EACf;EACA,KAAK,MAAM,UAAU,WAAW,OAAO;CACzC,GACA,CAAC,UAAU,CACb;CAEA,MAAM,MAAM,eACH;EAAE;EAAM;EAAS,UAAU,SAAS,WAAW,SAAS;CAAK,IACpE;EAAC;EAAM;EAAS;CAAM,CACxB;CACA,MAAM,cAAc,SAAS;CAC7B,MAAM,QAAQ,eAAe;EAAE;EAAO;CAAY,IAAI,CAAC,OAAO,WAAW,CAAC;CAC1E,MAAM,MAAM,cAAc,SAAS,OAAO,QAAQ,QAAQ,KAAA,CAAS,GAAG;EAAC;EAAO;EAAO;CAAK,CAAC;CAE3F,MAAM,QAAQ,OACZ,oBAAC,SAAD;EAAO,MAAM,QAAQ,SAAS,GAAG;EAAG,YAAW;EAC5C,UAAA;CACI,CAAA;CAET,MAAM,SAAS,cAAc,cAAc,UAAU,GAAG,CAAC,UAAU,CAAC;CACpE,MAAM,UAAU,QACd,oBAAC,OAAD;EAAK,oBAAkB;EAAO,OAAO,EAAE,SAAS,WAAW;EACxD;CACE,CAAA,IAEL;CAEF,OACE,qBAAC,cAAD;EAAqB;EAArB,UAAA,CACG,OACA,UAAU,WAAW,cACpB,oBAAC,eAAD;GAAe,OAAO;GAAS,UAAA;EAAuB,CAAA,IAEtD,OAEU;;AAElB"}
@@ -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";
@@ -19,6 +20,7 @@ function Steps(props) {
19
20
  const { as, css, className, steps, value: valueProp, defaultValue, onValueChange, navigable = "done", orientation = "horizontal", labels: labelsProp, parts, partProps, classNames, ...rest } = useThemeProps("Steps", props);
20
21
  const labels = {
21
22
  ...STEPS_LABELS,
23
+ ...useLabels("Steps"),
22
24
  ...labelsProp
23
25
  };
24
26
  const [value, setValue] = useControlled({