@slurp-ui/react 1.1.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/AvatarGroup/AvatarGroup.d.ts +26 -0
  3. package/dist/AvatarGroup/AvatarGroup.js +46 -0
  4. package/dist/AvatarGroup/AvatarGroup.js.map +1 -0
  5. package/dist/AvatarGroup/index.d.ts +3 -0
  6. package/dist/AvatarGroup/index.js +2 -0
  7. package/dist/Bloom/Bloom.js +3 -2
  8. package/dist/Bloom/Bloom.js.map +1 -1
  9. package/dist/Calendar/Calendar.d.ts +42 -0
  10. package/dist/Calendar/Calendar.js +178 -0
  11. package/dist/Calendar/Calendar.js.map +1 -0
  12. package/dist/Calendar/dates.d.ts +3 -0
  13. package/dist/Calendar/dates.js +46 -0
  14. package/dist/Calendar/dates.js.map +1 -0
  15. package/dist/Calendar/index.d.ts +3 -0
  16. package/dist/Calendar/index.js +2 -0
  17. package/dist/Carousel/Carousel.js +2 -0
  18. package/dist/Carousel/Carousel.js.map +1 -1
  19. package/dist/Choice/Choice.js +2 -0
  20. package/dist/Choice/Choice.js.map +1 -1
  21. package/dist/Code/Code.d.ts +38 -0
  22. package/dist/Code/Code.js +82 -0
  23. package/dist/Code/Code.js.map +1 -0
  24. package/dist/Code/index.d.ts +3 -0
  25. package/dist/Code/index.js +2 -0
  26. package/dist/Compare/Compare.d.ts +23 -0
  27. package/dist/Compare/Compare.js +61 -0
  28. package/dist/Compare/Compare.js.map +1 -0
  29. package/dist/Compare/index.d.ts +3 -0
  30. package/dist/Compare/index.js +2 -0
  31. package/dist/Consent/Consent.d.ts +30 -0
  32. package/dist/Consent/Consent.js +70 -0
  33. package/dist/Consent/Consent.js.map +1 -0
  34. package/dist/Consent/index.d.ts +3 -0
  35. package/dist/Consent/index.js +2 -0
  36. package/dist/Contents/Contents.d.ts +35 -0
  37. package/dist/Contents/Contents.js +63 -0
  38. package/dist/Contents/Contents.js.map +1 -0
  39. package/dist/Contents/index.d.ts +3 -0
  40. package/dist/Contents/index.js +2 -0
  41. package/dist/DateField/DateField.d.ts +29 -0
  42. package/dist/DateField/DateField.js +118 -0
  43. package/dist/DateField/DateField.js.map +1 -0
  44. package/dist/DateField/index.d.ts +3 -0
  45. package/dist/DateField/index.js +2 -0
  46. package/dist/Dialog/Dialog.d.ts +2 -0
  47. package/dist/Dialog/Dialog.js +89 -30
  48. package/dist/Dialog/Dialog.js.map +1 -1
  49. package/dist/Dock/Dock.d.ts +5 -0
  50. package/dist/Dock/Dock.js +13 -2
  51. package/dist/Dock/Dock.js.map +1 -1
  52. package/dist/ErrorSummary/ErrorSummary.d.ts +26 -0
  53. package/dist/ErrorSummary/ErrorSummary.js +68 -0
  54. package/dist/ErrorSummary/ErrorSummary.js.map +1 -0
  55. package/dist/ErrorSummary/index.d.ts +3 -0
  56. package/dist/ErrorSummary/index.js +2 -0
  57. package/dist/FileDrop/FileDrop.d.ts +34 -0
  58. package/dist/FileDrop/FileDrop.js +145 -0
  59. package/dist/FileDrop/FileDrop.js.map +1 -0
  60. package/dist/FileDrop/index.d.ts +3 -0
  61. package/dist/FileDrop/index.js +2 -0
  62. package/dist/Filters/Filters.js +2 -0
  63. package/dist/Filters/Filters.js.map +1 -1
  64. package/dist/Footer/Footer.d.ts +37 -0
  65. package/dist/Footer/Footer.js +63 -0
  66. package/dist/Footer/Footer.js.map +1 -0
  67. package/dist/Footer/index.d.ts +3 -0
  68. package/dist/Footer/index.js +2 -0
  69. package/dist/Hairline/Hairline.d.ts +16 -0
  70. package/dist/Hairline/Hairline.js +23 -0
  71. package/dist/Hairline/Hairline.js.map +1 -0
  72. package/dist/Hairline/index.d.ts +3 -0
  73. package/dist/Hairline/index.js +2 -0
  74. package/dist/Hint/Hint.js +20 -1
  75. package/dist/Hint/Hint.js.map +1 -1
  76. package/dist/Kbd/Kbd.d.ts +7 -0
  77. package/dist/Kbd/Kbd.js +20 -0
  78. package/dist/Kbd/Kbd.js.map +1 -0
  79. package/dist/Kbd/index.d.ts +3 -0
  80. package/dist/Kbd/index.js +2 -0
  81. package/dist/Lightbox/Lightbox.d.ts +30 -0
  82. package/dist/Lightbox/Lightbox.js +74 -0
  83. package/dist/Lightbox/Lightbox.js.map +1 -0
  84. package/dist/Lightbox/index.d.ts +3 -0
  85. package/dist/Lightbox/index.js +2 -0
  86. package/dist/ListRow/ListRow.d.ts +5 -1
  87. package/dist/ListRow/ListRow.js +5 -1
  88. package/dist/ListRow/ListRow.js.map +1 -1
  89. package/dist/Media/Media.d.ts +28 -0
  90. package/dist/Media/Media.js +65 -0
  91. package/dist/Media/Media.js.map +1 -0
  92. package/dist/Media/index.d.ts +3 -0
  93. package/dist/Media/index.js +2 -0
  94. package/dist/Menu/Menu.d.ts +13 -0
  95. package/dist/Menu/Menu.js +43 -11
  96. package/dist/Menu/Menu.js.map +1 -1
  97. package/dist/Menu/index.d.ts +2 -2
  98. package/dist/Menu/index.js +1 -1
  99. package/dist/MultiSuggest/MultiSuggest.d.ts +39 -0
  100. package/dist/MultiSuggest/MultiSuggest.js +267 -0
  101. package/dist/MultiSuggest/MultiSuggest.js.map +1 -0
  102. package/dist/MultiSuggest/index.d.ts +3 -0
  103. package/dist/MultiSuggest/index.js +2 -0
  104. package/dist/Notice/Notice.js +2 -0
  105. package/dist/Notice/Notice.js.map +1 -1
  106. package/dist/NumberField/NumberField.d.ts +32 -0
  107. package/dist/NumberField/NumberField.js +126 -0
  108. package/dist/NumberField/NumberField.js.map +1 -0
  109. package/dist/NumberField/index.d.ts +3 -0
  110. package/dist/NumberField/index.js +2 -0
  111. package/dist/PageNav/PageNav.d.ts +25 -0
  112. package/dist/PageNav/PageNav.js +57 -0
  113. package/dist/PageNav/PageNav.js.map +1 -0
  114. package/dist/PageNav/index.d.ts +3 -0
  115. package/dist/PageNav/index.js +2 -0
  116. package/dist/Pages/Pages.js +2 -0
  117. package/dist/Pages/Pages.js.map +1 -1
  118. package/dist/PinField/PinField.d.ts +26 -0
  119. package/dist/PinField/PinField.js +73 -0
  120. package/dist/PinField/PinField.js.map +1 -0
  121. package/dist/PinField/index.d.ts +3 -0
  122. package/dist/PinField/index.js +2 -0
  123. package/dist/Prose/Prose.d.ts +15 -0
  124. package/dist/Prose/Prose.js +25 -0
  125. package/dist/Prose/Prose.js.map +1 -0
  126. package/dist/Prose/index.d.ts +3 -0
  127. package/dist/Prose/index.js +2 -0
  128. package/dist/Quote/Quote.d.ts +19 -0
  129. package/dist/Quote/Quote.js +52 -0
  130. package/dist/Quote/Quote.js.map +1 -0
  131. package/dist/Quote/index.d.ts +3 -0
  132. package/dist/Quote/index.js +2 -0
  133. package/dist/Rail/Rail.d.ts +37 -0
  134. package/dist/Rail/Rail.js +61 -0
  135. package/dist/Rail/Rail.js.map +1 -0
  136. package/dist/Rail/index.d.ts +3 -0
  137. package/dist/Rail/index.js +2 -0
  138. package/dist/Rating/Rating.js +2 -0
  139. package/dist/Rating/Rating.js.map +1 -1
  140. package/dist/Search/Search.js +2 -0
  141. package/dist/Search/Search.js.map +1 -1
  142. package/dist/SecretField/SecretField.d.ts +17 -0
  143. package/dist/SecretField/SecretField.js +59 -0
  144. package/dist/SecretField/SecretField.js.map +1 -0
  145. package/dist/SecretField/index.d.ts +3 -0
  146. package/dist/SecretField/index.js +2 -0
  147. package/dist/Settings/Settings.js +2 -0
  148. package/dist/Settings/Settings.js.map +1 -1
  149. package/dist/Sheet/Sheet.d.ts +8 -3
  150. package/dist/Sheet/Sheet.js +1 -1
  151. package/dist/Sheet/Sheet.js.map +1 -1
  152. package/dist/Sheet/index.d.ts +2 -2
  153. package/dist/SkipLink/SkipLink.d.ts +22 -0
  154. package/dist/SkipLink/SkipLink.js +32 -0
  155. package/dist/SkipLink/SkipLink.js.map +1 -0
  156. package/dist/SkipLink/index.d.ts +3 -0
  157. package/dist/SkipLink/index.js +2 -0
  158. package/dist/SlurpProvider/SlurpProvider.d.ts +7 -1
  159. package/dist/SlurpProvider/SlurpProvider.js +14 -6
  160. package/dist/SlurpProvider/SlurpProvider.js.map +1 -1
  161. package/dist/Steps/Steps.js +2 -0
  162. package/dist/Steps/Steps.js.map +1 -1
  163. package/dist/Suggest/Suggest.js +2 -0
  164. package/dist/Suggest/Suggest.js.map +1 -1
  165. package/dist/Table/Table.d.ts +12 -0
  166. package/dist/Table/Table.js +56 -10
  167. package/dist/Table/Table.js.map +1 -1
  168. package/dist/Tag/Tag.d.ts +14 -0
  169. package/dist/Tag/Tag.js +26 -0
  170. package/dist/Tag/Tag.js.map +1 -0
  171. package/dist/Tag/index.d.ts +3 -0
  172. package/dist/Tag/index.js +2 -0
  173. package/dist/Timeline/Timeline.d.ts +23 -0
  174. package/dist/Timeline/Timeline.js +49 -0
  175. package/dist/Timeline/Timeline.js.map +1 -0
  176. package/dist/Timeline/index.d.ts +3 -0
  177. package/dist/Timeline/index.js +2 -0
  178. package/dist/Toast/Toast.js +31 -7
  179. package/dist/Toast/Toast.js.map +1 -1
  180. package/dist/Tree/Tree.d.ts +24 -0
  181. package/dist/Tree/Tree.js +113 -0
  182. package/dist/Tree/Tree.js.map +1 -0
  183. package/dist/Tree/index.d.ts +3 -0
  184. package/dist/Tree/index.js +2 -0
  185. package/dist/index.d.ts +63 -8
  186. package/dist/index.js +31 -2
  187. package/dist/internal/labels.js +12 -0
  188. package/dist/internal/labels.js.map +1 -0
  189. package/dist/lib/labels.d.ts +210 -0
  190. package/dist/lib/labels.js +139 -0
  191. package/dist/lib/labels.js.map +1 -0
  192. package/dist/lib/theme.d.ts +134 -4
  193. package/dist/lib/theme.js.map +1 -1
  194. package/dist/styles.css +1912 -138
  195. package/dist/tokens.css +9 -0
  196. package/dist/utils/focus.d.ts +1 -1
  197. package/dist/utils/focus.js +2 -2
  198. package/dist/utils/focus.js.map +1 -1
  199. package/dist/utils/index.d.ts +3 -1
  200. package/dist/utils/index.js +3 -1
  201. package/dist/utils/useClipboard.d.ts +14 -0
  202. package/dist/utils/useClipboard.js +30 -0
  203. package/dist/utils/useClipboard.js.map +1 -0
  204. package/dist/utils/useScrollSpy.d.ts +14 -0
  205. package/dist/utils/useScrollSpy.js +27 -0
  206. package/dist/utils/useScrollSpy.js.map +1 -0
  207. package/package.json +5 -5
@@ -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":"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"}
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":"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"}
@@ -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";
@@ -0,0 +1,30 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType } from "react";
4
+ export interface LightboxImage {
5
+ src: string;
6
+ alt: string;
7
+ caption?: string;
8
+ }
9
+ export interface LightboxLabels {
10
+ previous: string;
11
+ next: string;
12
+ /** "2 di 5", read when the picture changes. */
13
+ position: (index: number, count: number) => string;
14
+ }
15
+ export declare const LIGHTBOX_LABELS: LightboxLabels;
16
+ export interface LightboxOwnProps {
17
+ images: LightboxImage[];
18
+ open?: boolean;
19
+ defaultOpen?: boolean;
20
+ onOpenChange?: (open: boolean) => void;
21
+ /** The picture shown. */
22
+ index?: number;
23
+ defaultIndex?: number;
24
+ onIndexChange?: (index: number) => void;
25
+ labels?: Partial<LightboxLabels>;
26
+ }
27
+ export type LightboxProps<E extends ElementType = 'dialog'> = PolymorphicProps<E, LightboxOwnProps>;
28
+ /** A picture at full size in a modal (Dialog underneath): arrows or the buttons move through the set, Escape closes. */
29
+ export declare function Lightbox<E extends ElementType = 'dialog'>(props: LightboxProps<E>): import("react").JSX.Element | null;
30
+ //# sourceMappingURL=Lightbox.d.ts.map
@@ -0,0 +1,74 @@
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 { useControlled } from "../utils/useControlled.js";
7
+ import { Dialog } from "../Dialog/Dialog.js";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { ChevronLeftIcon, ChevronRightIcon } from "@slurp-ui/icons";
10
+ // src/Lightbox/Lightbox.tsx
11
+ const LIGHTBOX_LABELS = {
12
+ previous: "Immagine precedente",
13
+ next: "Immagine successiva",
14
+ position: (i, n) => `${i} di ${n}`
15
+ };
16
+ /** A picture at full size in a modal (Dialog underneath): arrows or the buttons move through the set, Escape closes. */
17
+ function Lightbox(props) {
18
+ const { className, images, index: indexProp, defaultIndex = 0, onIndexChange, labels: labelsProp, ...rest } = useThemeProps("Lightbox", props);
19
+ const labels = {
20
+ ...LIGHTBOX_LABELS,
21
+ ...useLabels("Lightbox"),
22
+ ...labelsProp
23
+ };
24
+ const [index, setIndex] = useControlled({
25
+ value: indexProp,
26
+ defaultValue: defaultIndex,
27
+ onChange: onIndexChange
28
+ });
29
+ const n = images.length;
30
+ const at = Math.min(Math.max(index, 0), Math.max(n - 1, 0));
31
+ const image = images[at];
32
+ const go = (step) => setIndex((at + step + n) % n);
33
+ const keys = (e) => {
34
+ if (n < 2) return;
35
+ const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
36
+ if (e.key === "ArrowRight") go(rtl ? -1 : 1);
37
+ else if (e.key === "ArrowLeft") go(rtl ? 1 : -1);
38
+ else return;
39
+ e.preventDefault();
40
+ };
41
+ if (!image) return null;
42
+ return /* @__PURE__ */ jsx(Dialog, {
43
+ ...rest,
44
+ className: cx("slurp-lightbox", className),
45
+ title: image.caption ?? image.alt,
46
+ description: n > 1 ? labels.position(at + 1, n) : void 0,
47
+ onKeyDown: keys,
48
+ children: /* @__PURE__ */ jsxs("div", {
49
+ className: "slurp-lightbox-stage",
50
+ children: [
51
+ n > 1 && /* @__PURE__ */ jsx(Bubble, {
52
+ label: labels.previous,
53
+ onClick: () => go(-1),
54
+ className: "slurp-lightbox-prev",
55
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
56
+ }),
57
+ /* @__PURE__ */ jsx("img", {
58
+ src: image.src,
59
+ alt: image.alt,
60
+ className: "slurp-lightbox-image"
61
+ }),
62
+ n > 1 && /* @__PURE__ */ jsx(Bubble, {
63
+ label: labels.next,
64
+ onClick: () => go(1),
65
+ className: "slurp-lightbox-next",
66
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
67
+ })
68
+ ]
69
+ })
70
+ });
71
+ }
72
+ export { LIGHTBOX_LABELS, Lightbox };
73
+
74
+ //# sourceMappingURL=Lightbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Lightbox.js","names":[],"sources":["../../src/Lightbox/Lightbox.tsx"],"sourcesContent":["import { ChevronLeftIcon, ChevronRightIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport type { ElementType, KeyboardEvent } from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { Dialog } from '../Dialog/Dialog';\nimport { useLabels } from '../internal/labels';\nimport { useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface LightboxImage {\n src: string;\n alt: string;\n caption?: string;\n}\n\nexport interface LightboxLabels {\n previous: string;\n next: string;\n /** \"2 di 5\", read when the picture changes. */\n position: (index: number, count: number) => string;\n}\n\nexport const LIGHTBOX_LABELS: LightboxLabels = {\n previous: 'Immagine precedente',\n next: 'Immagine successiva',\n position: (i, n) => `${i} di ${n}`,\n};\n\nexport interface LightboxOwnProps {\n images: LightboxImage[];\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** The picture shown. */\n index?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n labels?: Partial<LightboxLabels>;\n}\n\nexport type LightboxProps<E extends ElementType = 'dialog'> = PolymorphicProps<E, LightboxOwnProps>;\n\n/** A picture at full size in a modal (Dialog underneath): arrows or the buttons move through the set, Escape closes. */\nexport function Lightbox<E extends ElementType = 'dialog'>(props: LightboxProps<E>) {\n const {\n className,\n images,\n index: indexProp,\n defaultIndex = 0,\n onIndexChange,\n labels: labelsProp,\n ...rest\n } = useThemeProps('Lightbox', props as LightboxProps);\n const labels = { ...LIGHTBOX_LABELS, ...useLabels('Lightbox'), ...labelsProp };\n const [index, setIndex] = useControlled({\n value: indexProp,\n defaultValue: defaultIndex,\n onChange: onIndexChange,\n });\n const n = images.length;\n const at = Math.min(Math.max(index, 0), Math.max(n - 1, 0));\n const image = images[at];\n const go = (step: number) => setIndex((at + step + n) % n);\n const keys = (e: KeyboardEvent) => {\n if (n < 2) return;\n const rtl = getComputedStyle(e.currentTarget).direction === 'rtl';\n if (e.key === 'ArrowRight') go(rtl ? -1 : 1);\n else if (e.key === 'ArrowLeft') go(rtl ? 1 : -1);\n else return;\n e.preventDefault();\n };\n if (!image) return null;\n return (\n <Dialog\n {...(rest as object)}\n className={cx('slurp-lightbox', className)}\n title={image.caption ?? image.alt}\n description={n > 1 ? labels.position(at + 1, n) : undefined}\n onKeyDown={keys}\n >\n <div className=\"slurp-lightbox-stage\">\n {n > 1 && (\n <Bubble label={labels.previous} onClick={() => go(-1)} className=\"slurp-lightbox-prev\">\n <ChevronLeftIcon />\n </Bubble>\n )}\n <img src={image.src} alt={image.alt} className=\"slurp-lightbox-image\" />\n {n > 1 && (\n <Bubble label={labels.next} onClick={() => go(1)} className=\"slurp-lightbox-next\">\n <ChevronRightIcon />\n </Bubble>\n )}\n </div>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,kBAAkC;CAC7C,UAAU;CACV,MAAM;CACN,WAAW,GAAG,MAAM,GAAG,EAAE,MAAM;AACjC;;AAiBA,SAAgB,SAA2C,OAAyB;CAClF,MAAM,EACJ,WACA,QACA,OAAO,WACP,eAAe,GACf,eACA,QAAQ,YACR,GAAG,SACD,cAAc,YAAY,KAAsB;CACpD,MAAM,SAAS;EAAE,GAAG;EAAiB,GAAG,UAAU,UAAU;EAAG,GAAG;CAAW;CAC7E,MAAM,CAAC,OAAO,YAAY,cAAc;EACtC,OAAO;EACP,cAAc;EACd,UAAU;CACZ,CAAC;CACD,MAAM,IAAI,OAAO;CACjB,MAAM,KAAK,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,CAAC;CAC1D,MAAM,QAAQ,OAAO;CACrB,MAAM,MAAM,SAAiB,UAAU,KAAK,OAAO,KAAK,CAAC;CACzD,MAAM,QAAQ,MAAqB;EACjC,IAAI,IAAI,GAAG;EACX,MAAM,MAAM,iBAAiB,EAAE,aAAa,CAAC,CAAC,cAAc;EAC5D,IAAI,EAAE,QAAQ,cAAc,GAAG,MAAM,KAAK,CAAC;OACtC,IAAI,EAAE,QAAQ,aAAa,GAAG,MAAM,IAAI,EAAE;OAC1C;EACL,EAAE,eAAe;CACnB;CACA,IAAI,CAAC,OAAO,OAAO;CACnB,OACE,oBAAC,QAAD;EACE,GAAK;EACL,WAAW,GAAG,kBAAkB,SAAS;EACzC,OAAO,MAAM,WAAW,MAAM;EAC9B,aAAa,IAAI,IAAI,OAAO,SAAS,KAAK,GAAG,CAAC,IAAI,KAAA;EAClD,WAAW;EAEX,UAAA,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACG,IAAI,KACH,oBAAC,QAAD;KAAQ,OAAO,OAAO;KAAU,eAAe,GAAG,EAAE;KAAG,WAAU;KAC/D,UAAA,oBAAC,iBAAD,CAAkB,CAAA;IACZ,CAAA;IAEV,oBAAC,OAAD;KAAK,KAAK,MAAM;KAAK,KAAK,MAAM;KAAK,WAAU;IAAwB,CAAA;IACtE,IAAI,KACH,oBAAC,QAAD;KAAQ,OAAO,OAAO;KAAM,eAAe,GAAG,CAAC;KAAG,WAAU;KAC1D,UAAA,oBAAC,kBAAD,CAAmB,CAAA;IACb,CAAA;GAEP;;CACC,CAAA;AAEZ"}
@@ -0,0 +1,3 @@
1
+
2
+ import { LIGHTBOX_LABELS, Lightbox, LightboxImage, LightboxLabels, LightboxProps } from "./Lightbox.js";
3
+ export { LIGHTBOX_LABELS, Lightbox, type LightboxImage, type LightboxLabels, type LightboxProps, Lightbox as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { LIGHTBOX_LABELS, Lightbox, Lightbox as default } from "./Lightbox.js";
@@ -4,7 +4,7 @@ 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;
@@ -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\", \"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 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,SAAS;EAAG,GAAI;EAClE,UAAA,oBAAC,QAAD;GAAQ,OAAO,SAAS,QAAQ,SAAS;GAAO;EAAiB,CAAA;CAC7D,CAAA,CACN,EAAA,CAAA;AAEN;;AA2BA,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,QAAQ,QAAQ,eAAe,OAC5B,KAAK,QAAQ,KAAK;OAAE,WAAW;OAAuB;OAAM,UAAU;MAAM,CAAC,IAC7E,OACH,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"}
@@ -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";
@@ -13,11 +13,15 @@ export type MenuProps<E extends ElementType = 'div'> = PolymorphicProps<E, Omit<
13
13
  export declare function Menu<E extends ElementType = 'div'>(props: MenuProps<E>): import("react").JSX.Element;
14
14
  export declare namespace Menu {
15
15
  var Item: typeof MenuItem;
16
+ var Group: typeof MenuGroup;
17
+ var Separator: typeof MenuSeparator;
16
18
  }
17
19
  export interface MenuItemOwnProps {
18
20
  /** Runs the action; the menu closes afterwards (unless the handler calls preventDefault). */
19
21
  onSelect?: (event: MouseEvent<HTMLButtonElement>) => void;
20
22
  icon?: ReactNode;
23
+ /** The key combination that runs it elsewhere, shown at the end (`⌘K`): a hint, not a binding. */
24
+ shortcut?: string;
21
25
  disabled?: boolean;
22
26
  /** `danger` for destructive actions (the text says so too). */
23
27
  tone?: 'neutral' | 'danger';
@@ -26,4 +30,13 @@ export interface MenuItemOwnProps {
26
30
  export type MenuItemProps<E extends ElementType = 'button'> = PolymorphicProps<E, MenuItemOwnProps>;
27
31
  /** One action of a Menu. */
28
32
  export declare function MenuItem<E extends ElementType = 'button'>(props: MenuItemProps<E>): import("react").JSX.Element;
33
+ export interface MenuGroupProps {
34
+ /** Names the group (shown above it and read by screen readers). */
35
+ label: string;
36
+ children?: ReactNode;
37
+ }
38
+ /** A named set of items inside a Menu. */
39
+ export declare function MenuGroup({ label, children }: MenuGroupProps): import("react").JSX.Element;
40
+ /** A line between two sets of items. */
41
+ export declare function MenuSeparator(): import("react").JSX.Element;
29
42
  //# sourceMappingURL=Menu.d.ts.map
package/dist/Menu/Menu.js CHANGED
@@ -3,7 +3,7 @@ import { cx } from "../utils/src/index.js";
3
3
  import { useThemeProps } from "../internal/styled.js";
4
4
  import { moveFocus } from "../utils/focus.js";
5
5
  import { Bloom } from "../Bloom/Bloom.js";
6
- import { createContext, useContext, useRef } from "react";
6
+ import { createContext, useContext, useId, useRef } from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  // src/Menu/Menu.tsx
9
9
  const MenuContext = createContext(null);
@@ -32,7 +32,7 @@ function Menu(props) {
32
32
  }
33
33
  /** One action of a Menu. */
34
34
  function MenuItem(props) {
35
- const { as, css: _css, className, onSelect, icon, disabled, tone = "neutral", children, ...rest } = props;
35
+ const { as, css: _css, className, onSelect, icon, shortcut, disabled, tone = "neutral", children, ...rest } = props;
36
36
  const close = useContext(MenuContext);
37
37
  const Root = as ?? "button";
38
38
  return /* @__PURE__ */ jsxs(Root, {
@@ -48,17 +48,49 @@ function MenuItem(props) {
48
48
  if (!e.defaultPrevented) close?.(true);
49
49
  },
50
50
  ...rest,
51
- children: [icon != null && /* @__PURE__ */ jsx("span", {
52
- className: "slurp-bloom-item-icon",
53
- "aria-hidden": "true",
54
- children: icon
55
- }), /* @__PURE__ */ jsx("span", {
56
- className: "slurp-bloom-item-label",
57
- children
58
- })]
51
+ children: [
52
+ icon != null && /* @__PURE__ */ jsx("span", {
53
+ className: "slurp-bloom-item-icon",
54
+ "aria-hidden": "true",
55
+ children: icon
56
+ }),
57
+ /* @__PURE__ */ jsx("span", {
58
+ className: "slurp-bloom-item-label",
59
+ children
60
+ }),
61
+ shortcut != null && /* @__PURE__ */ jsx("kbd", {
62
+ className: "slurp-menu-shortcut",
63
+ "aria-keyshortcuts": shortcut,
64
+ children: shortcut
65
+ })
66
+ ]
67
+ });
68
+ }
69
+ /** A named set of items inside a Menu. */
70
+ function MenuGroup({ label, children }) {
71
+ const id = useId();
72
+ return /* @__PURE__ */ jsxs("div", {
73
+ role: "group",
74
+ "aria-labelledby": id,
75
+ className: "slurp-menu-group",
76
+ children: [/* @__PURE__ */ jsx("div", {
77
+ id,
78
+ className: "slurp-menu-group-label",
79
+ role: "presentation",
80
+ children: label
81
+ }), children]
82
+ });
83
+ }
84
+ /** A line between two sets of items. */
85
+ function MenuSeparator() {
86
+ return /* @__PURE__ */ jsx("div", {
87
+ role: "separator",
88
+ className: "slurp-menu-separator"
59
89
  });
60
90
  }
61
91
  Menu.Item = MenuItem;
62
- export { Menu, MenuItem };
92
+ Menu.Group = MenuGroup;
93
+ Menu.Separator = MenuSeparator;
94
+ export { Menu, MenuGroup, MenuItem, MenuSeparator };
63
95
 
64
96
  //# sourceMappingURL=Menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","names":[],"sources":["../../src/Menu/Menu.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n createContext,\n useContext,\n useRef,\n type ElementType,\n type MouseEvent,\n type ReactNode,\n} from 'react';\n\nimport { Bloom, type BloomOwnProps } from '../Bloom/Bloom';\nimport { useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { moveFocus } from '../utils/focus';\n\nconst MenuContext = createContext<((restoreFocus?: boolean) => void) | null>(null);\n\nexport type MenuProps<E extends ElementType = 'div'> = PolymorphicProps<\n E,\n Omit<BloomOwnProps, 'role' | 'children'> & {\n /** MenuItem elements (other content, like a heading, is allowed too). */\n children?: ReactNode;\n }\n>;\n\n/**\n * A list of actions on Bloom: the trigger becomes the menu. Arrow keys move (looping), Home / End go to the ends,\n * Enter or Space run the item, which closes the menu and gives focus back to the trigger.\n */\nexport function Menu<E extends ElementType = 'div'>(props: MenuProps<E>) {\n const { children, width = 260, className, ...rest } = useThemeProps('Menu', props as MenuProps);\n const list = useRef<HTMLDivElement>(null);\n return (\n <Bloom {...rest} role=\"menu\" width={width} className={cx('slurp-menu', className)}>\n {(close) => (\n <MenuContext value={close}>\n <div\n ref={list}\n className=\"slurp-menu-list\"\n onKeyDown={(e) => moveFocus(e, list.current, '[role=\"menuitem\"]', { loop: true })}\n >\n {children}\n </div>\n </MenuContext>\n )}\n </Bloom>\n );\n}\n\nexport interface MenuItemOwnProps {\n /** Runs the action; the menu closes afterwards (unless the handler calls preventDefault). */\n onSelect?: (event: MouseEvent<HTMLButtonElement>) => void;\n icon?: ReactNode;\n disabled?: boolean;\n /** `danger` for destructive actions (the text says so too). */\n tone?: 'neutral' | 'danger';\n children?: ReactNode;\n}\n\nexport type MenuItemProps<E extends ElementType = 'button'> = PolymorphicProps<E, MenuItemOwnProps>;\n\n/** One action of a Menu. */\nexport function MenuItem<E extends ElementType = 'button'>(props: MenuItemProps<E>) {\n const {\n as,\n css: _css,\n className,\n onSelect,\n icon,\n disabled,\n tone = 'neutral',\n children,\n ...rest\n } = props as MenuItemProps;\n const close = useContext(MenuContext);\n const Root = (as ?? 'button') as ElementType;\n return (\n <Root\n role=\"menuitem\"\n tabIndex={-1}\n className={cx('slurp-bloom-item', className)}\n aria-disabled={disabled || undefined}\n data-tone={tone}\n {...(Root === 'button' ? { type: 'button' } : null)}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) return;\n onSelect?.(e);\n if (!e.defaultPrevented) close?.(true);\n }}\n {...rest}\n >\n {icon != null && (\n <span className=\"slurp-bloom-item-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n <span className=\"slurp-bloom-item-label\">{children}</span>\n </Root>\n );\n}\n\nMenu.Item = MenuItem;\n"],"mappings":";;;;;;;;AAeA,MAAM,cAAc,cAAyD,IAAI;;;;;AAcjF,SAAgB,KAAoC,OAAqB;CACvE,MAAM,EAAE,UAAU,QAAQ,KAAK,WAAW,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC9F,MAAM,OAAO,OAAuB,IAAI;CACxC,OACE,oBAAC,OAAD;EAAO,GAAI;EAAM,MAAK;EAAc;EAAO,WAAW,GAAG,cAAc,SAAS;EAC5E,WAAA,UACA,oBAAC,aAAD;GAAa,OAAO;GAClB,UAAA,oBAAC,OAAD;IACE,KAAK;IACL,WAAU;IACV,YAAY,MAAM,UAAU,GAAG,KAAK,SAAS,uBAAqB,EAAE,MAAM,KAAK,CAAC;IAE/E;GACE,CAAA;EACM,CAAA;CAEV,CAAA;AAEX;;AAeA,SAAgB,SAA2C,OAAyB;CAClF,MAAM,EACJ,IACA,KAAK,MACL,WACA,UACA,MACA,UACA,OAAO,WACP,UACA,GAAG,SACD;CACJ,MAAM,QAAQ,WAAW,WAAW;CACpC,MAAM,OAAQ,MAAM;CACpB,OACE,qBAAC,MAAD;EACE,MAAK;EACL,UAAU;EACV,WAAW,GAAG,oBAAoB,SAAS;EAC3C,iBAAe,YAAY,KAAA;EAC3B,aAAW;EACX,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;EAC9C,UAAU,MAAqC;GAC7C,IAAI,UAAU;GACd,WAAW,CAAC;GACZ,IAAI,CAAC,EAAE,kBAAkB,QAAQ,IAAI;EACvC;EACA,GAAI;EAZN,UAAA,CAcG,QAAQ,QACP,oBAAC,QAAD;GAAM,WAAU;GAAwB,eAAY;GACjD,UAAA;EACG,CAAA,GAER,oBAAC,QAAD;GAAM,WAAU;GAA0B;EAAe,CAAA,CACrD;;AAEV;AAEA,KAAK,OAAO"}
1
+ {"version":3,"file":"Menu.js","names":[],"sources":["../../src/Menu/Menu.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n createContext,\n useContext,\n useId,\n useRef,\n type ElementType,\n type MouseEvent,\n type ReactNode,\n} from 'react';\n\nimport { Bloom, type BloomOwnProps } from '../Bloom/Bloom';\nimport { useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { moveFocus } from '../utils/focus';\n\nconst MenuContext = createContext<((restoreFocus?: boolean) => void) | null>(null);\n\nexport type MenuProps<E extends ElementType = 'div'> = PolymorphicProps<\n E,\n Omit<BloomOwnProps, 'role' | 'children'> & {\n /** MenuItem elements (other content, like a heading, is allowed too). */\n children?: ReactNode;\n }\n>;\n\n/**\n * A list of actions on Bloom: the trigger becomes the menu. Arrow keys move (looping), Home / End go to the ends,\n * Enter or Space run the item, which closes the menu and gives focus back to the trigger.\n */\nexport function Menu<E extends ElementType = 'div'>(props: MenuProps<E>) {\n const { children, width = 260, className, ...rest } = useThemeProps('Menu', props as MenuProps);\n const list = useRef<HTMLDivElement>(null);\n return (\n <Bloom {...rest} role=\"menu\" width={width} className={cx('slurp-menu', className)}>\n {(close) => (\n <MenuContext value={close}>\n <div\n ref={list}\n className=\"slurp-menu-list\"\n onKeyDown={(e) => moveFocus(e, list.current, '[role=\"menuitem\"]', { loop: true })}\n >\n {children}\n </div>\n </MenuContext>\n )}\n </Bloom>\n );\n}\n\nexport interface MenuItemOwnProps {\n /** Runs the action; the menu closes afterwards (unless the handler calls preventDefault). */\n onSelect?: (event: MouseEvent<HTMLButtonElement>) => void;\n icon?: ReactNode;\n /** The key combination that runs it elsewhere, shown at the end (`⌘K`): a hint, not a binding. */\n shortcut?: string;\n disabled?: boolean;\n /** `danger` for destructive actions (the text says so too). */\n tone?: 'neutral' | 'danger';\n children?: ReactNode;\n}\n\nexport type MenuItemProps<E extends ElementType = 'button'> = PolymorphicProps<E, MenuItemOwnProps>;\n\n/** One action of a Menu. */\nexport function MenuItem<E extends ElementType = 'button'>(props: MenuItemProps<E>) {\n const {\n as,\n css: _css,\n className,\n onSelect,\n icon,\n shortcut,\n disabled,\n tone = 'neutral',\n children,\n ...rest\n } = props as MenuItemProps;\n const close = useContext(MenuContext);\n const Root = (as ?? 'button') as ElementType;\n return (\n <Root\n role=\"menuitem\"\n tabIndex={-1}\n className={cx('slurp-bloom-item', className)}\n aria-disabled={disabled || undefined}\n data-tone={tone}\n {...(Root === 'button' ? { type: 'button' } : null)}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) return;\n onSelect?.(e);\n if (!e.defaultPrevented) close?.(true);\n }}\n {...rest}\n >\n {icon != null && (\n <span className=\"slurp-bloom-item-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n <span className=\"slurp-bloom-item-label\">{children}</span>\n {shortcut != null && (\n <kbd className=\"slurp-menu-shortcut\" aria-keyshortcuts={shortcut}>\n {shortcut}\n </kbd>\n )}\n </Root>\n );\n}\n\nexport interface MenuGroupProps {\n /** Names the group (shown above it and read by screen readers). */\n label: string;\n children?: ReactNode;\n}\n\n/** A named set of items inside a Menu. */\nexport function MenuGroup({ label, children }: MenuGroupProps) {\n const id = useId();\n return (\n <div role=\"group\" aria-labelledby={id} className=\"slurp-menu-group\">\n <div id={id} className=\"slurp-menu-group-label\" role=\"presentation\">\n {label}\n </div>\n {children}\n </div>\n );\n}\n\n/** A line between two sets of items. */\nexport function MenuSeparator() {\n return <div role=\"separator\" className=\"slurp-menu-separator\" />;\n}\n\nMenu.Item = MenuItem;\nMenu.Group = MenuGroup;\nMenu.Separator = MenuSeparator;\n"],"mappings":";;;;;;;;AAgBA,MAAM,cAAc,cAAyD,IAAI;;;;;AAcjF,SAAgB,KAAoC,OAAqB;CACvE,MAAM,EAAE,UAAU,QAAQ,KAAK,WAAW,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC9F,MAAM,OAAO,OAAuB,IAAI;CACxC,OACE,oBAAC,OAAD;EAAO,GAAI;EAAM,MAAK;EAAc;EAAO,WAAW,GAAG,cAAc,SAAS;EAC5E,WAAA,UACA,oBAAC,aAAD;GAAa,OAAO;GAClB,UAAA,oBAAC,OAAD;IACE,KAAK;IACL,WAAU;IACV,YAAY,MAAM,UAAU,GAAG,KAAK,SAAS,uBAAqB,EAAE,MAAM,KAAK,CAAC;IAE/E;GACE,CAAA;EACM,CAAA;CAEV,CAAA;AAEX;;AAiBA,SAAgB,SAA2C,OAAyB;CAClF,MAAM,EACJ,IACA,KAAK,MACL,WACA,UACA,MACA,UACA,UACA,OAAO,WACP,UACA,GAAG,SACD;CACJ,MAAM,QAAQ,WAAW,WAAW;CACpC,MAAM,OAAQ,MAAM;CACpB,OACE,qBAAC,MAAD;EACE,MAAK;EACL,UAAU;EACV,WAAW,GAAG,oBAAoB,SAAS;EAC3C,iBAAe,YAAY,KAAA;EAC3B,aAAW;EACX,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;EAC9C,UAAU,MAAqC;GAC7C,IAAI,UAAU;GACd,WAAW,CAAC;GACZ,IAAI,CAAC,EAAE,kBAAkB,QAAQ,IAAI;EACvC;EACA,GAAI;EAZN,UAAA;GAcG,QAAQ,QACP,oBAAC,QAAD;IAAM,WAAU;IAAwB,eAAY;IACjD,UAAA;GACG,CAAA;GAER,oBAAC,QAAD;IAAM,WAAU;IAA0B;GAAe,CAAA;GACxD,YAAY,QACX,oBAAC,OAAD;IAAK,WAAU;IAAsB,qBAAmB;IACrD,UAAA;GACE,CAAA;EAEH;;AAEV;;AASA,SAAgB,UAAU,EAAE,OAAO,YAA4B;CAC7D,MAAM,KAAK,MAAM;CACjB,OACE,qBAAC,OAAD;EAAK,MAAK;EAAQ,mBAAiB;EAAI,WAAU;EAAjD,UAAA,CACE,oBAAC,OAAD;GAAS;GAAI,WAAU;GAAyB,MAAK;GAClD,UAAA;EACE,CAAA,GACJ,QACE;;AAET;;AAGA,SAAgB,gBAAgB;CAC9B,OAAO,oBAAC,OAAD;EAAK,MAAK;EAAY,WAAU;CAAwB,CAAA;AACjE;AAEA,KAAK,OAAO;AACZ,KAAK,QAAQ;AACb,KAAK,YAAY"}
@@ -1,3 +1,3 @@
1
1
 
2
- import { Menu, MenuItem, MenuItemProps, MenuProps } from "./Menu.js";
3
- export { Menu, MenuItem, type MenuItemProps, type MenuProps, Menu as default };
2
+ import { Menu, MenuGroup, MenuGroupProps, MenuItem, MenuItemProps, MenuProps, MenuSeparator } from "./Menu.js";
3
+ export { Menu, MenuGroup, type MenuGroupProps, MenuItem, type MenuItemProps, type MenuProps, MenuSeparator, Menu as default };
@@ -1,2 +1,2 @@
1
1
 
2
- export { Menu, MenuItem, Menu as default } from "./Menu.js";
2
+ export { Menu, MenuGroup, MenuItem, MenuSeparator, Menu as default } from "./Menu.js";
@@ -0,0 +1,39 @@
1
+
2
+ import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { InputAttributes } from "../Field/Field.js";
4
+ import { SuggestOption } from "../Suggest/Suggest.js";
5
+ import { ElementType, ReactNode } from "react";
6
+ export interface MultiSuggestLabels {
7
+ /** Number of suggestions, announced politely while typing. */
8
+ results: (count: number) => string;
9
+ /** Shown in the list, and announced, when nothing matches. */
10
+ empty: string;
11
+ /** Names the button that removes a chosen option: `remove('Rosso')`. */
12
+ remove: (label: string) => string;
13
+ /** Names the list of chosen options. */
14
+ chosen: string;
15
+ }
16
+ export declare const MULTI_SUGGEST_LABELS: MultiSuggestLabels;
17
+ export interface MultiSuggestOwnProps<V extends string = string> extends Omit<InputAttributes, 'type'>, PartsProps<'label' | 'control' | 'list' | 'option' | 'tags' | 'tag' | 'hint' | 'error'> {
18
+ label: ReactNode;
19
+ hint?: ReactNode;
20
+ /** Error message: marks the field invalid. */
21
+ error?: ReactNode;
22
+ options: SuggestOption<V>[];
23
+ /** The chosen values, in the order they were chosen. */
24
+ value?: V[];
25
+ defaultValue?: V[];
26
+ onValueChange?: (value: V[]) => void;
27
+ /** Which options match the text (default: every word, any order, ignoring case and accents). */
28
+ filter?: ((option: SuggestOption<V>, text: string) => boolean) | false;
29
+ /** Most suggestions listed. Default 8. */
30
+ limit?: number;
31
+ labels?: Partial<MultiSuggestLabels>;
32
+ }
33
+ export type MultiSuggestProps<V extends string = string, E extends ElementType = 'div'> = PolymorphicProps<E, MultiSuggestOwnProps<V>>;
34
+ /**
35
+ * Suggest for several choices: the list stays open while you pick, each pick becomes a removable tag under the field,
36
+ * Backspace in an empty field removes the last one. Submits one hidden input per value when it has a `name`.
37
+ */
38
+ export declare function MultiSuggest<V extends string = string, E extends ElementType = 'div'>(props: MultiSuggestProps<V, E>): import("react").JSX.Element;
39
+ //# sourceMappingURL=MultiSuggest.d.ts.map