@slurp-ui/react 0.0.0-stage → 1.0.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 (334) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -2
  3. package/dist/AccentScope/AccentScope.d.ts +15 -0
  4. package/dist/AccentScope/AccentScope.js +31 -0
  5. package/dist/AccentScope/AccentScope.js.map +1 -0
  6. package/dist/AccentScope/index.d.ts +3 -0
  7. package/dist/AccentScope/index.js +2 -0
  8. package/dist/Avatar/Avatar.d.ts +17 -0
  9. package/dist/Avatar/Avatar.js +42 -0
  10. package/dist/Avatar/Avatar.js.map +1 -0
  11. package/dist/Avatar/index.d.ts +3 -0
  12. package/dist/Avatar/index.js +2 -0
  13. package/dist/Bento/Bento.d.ts +14 -0
  14. package/dist/Bento/Bento.js +42 -0
  15. package/dist/Bento/Bento.js.map +1 -0
  16. package/dist/Bento/index.d.ts +3 -0
  17. package/dist/Bento/index.js +2 -0
  18. package/dist/Bloom/Bloom.d.ts +42 -0
  19. package/dist/Bloom/Bloom.js +183 -0
  20. package/dist/Bloom/Bloom.js.map +1 -0
  21. package/dist/Bloom/index.d.ts +3 -0
  22. package/dist/Bloom/index.js +2 -0
  23. package/dist/Bubble/Bubble.d.ts +20 -0
  24. package/dist/Bubble/Bubble.js +30 -0
  25. package/dist/Bubble/Bubble.js.map +1 -0
  26. package/dist/Bubble/index.d.ts +3 -0
  27. package/dist/Bubble/index.js +2 -0
  28. package/dist/Button/Button.d.ts +26 -0
  29. package/dist/Button/Button.js +50 -0
  30. package/dist/Button/Button.js.map +1 -0
  31. package/dist/Button/index.d.ts +3 -0
  32. package/dist/Button/index.js +2 -0
  33. package/dist/Card/Card.d.ts +26 -0
  34. package/dist/Card/Card.js +70 -0
  35. package/dist/Card/Card.js.map +1 -0
  36. package/dist/Card/index.d.ts +3 -0
  37. package/dist/Card/index.js +2 -0
  38. package/dist/Cell/Cell.d.ts +7 -0
  39. package/dist/Cell/Cell.js +20 -0
  40. package/dist/Cell/Cell.js.map +1 -0
  41. package/dist/Cell/index.d.ts +3 -0
  42. package/dist/Cell/index.js +2 -0
  43. package/dist/Checkbox/Checkbox.d.ts +27 -0
  44. package/dist/Checkbox/Checkbox.js +82 -0
  45. package/dist/Checkbox/Checkbox.js.map +1 -0
  46. package/dist/Checkbox/index.d.ts +3 -0
  47. package/dist/Checkbox/index.js +2 -0
  48. package/dist/Chip/Chip.d.ts +15 -0
  49. package/dist/Chip/Chip.js +40 -0
  50. package/dist/Chip/Chip.js.map +1 -0
  51. package/dist/Chip/index.d.ts +3 -0
  52. package/dist/Chip/index.js +2 -0
  53. package/dist/Choice/Choice.d.ts +37 -0
  54. package/dist/Choice/Choice.js +134 -0
  55. package/dist/Choice/Choice.js.map +1 -0
  56. package/dist/Choice/index.d.ts +3 -0
  57. package/dist/Choice/index.js +2 -0
  58. package/dist/Count/Count.d.ts +19 -0
  59. package/dist/Count/Count.js +30 -0
  60. package/dist/Count/Count.js.map +1 -0
  61. package/dist/Count/index.d.ts +3 -0
  62. package/dist/Count/index.js +2 -0
  63. package/dist/Dialog/Dialog.d.ts +26 -0
  64. package/dist/Dialog/Dialog.js +152 -0
  65. package/dist/Dialog/Dialog.js.map +1 -0
  66. package/dist/Dialog/index.d.ts +3 -0
  67. package/dist/Dialog/index.js +2 -0
  68. package/dist/Dock/Dock.d.ts +124 -0
  69. package/dist/Dock/Dock.js +359 -0
  70. package/dist/Dock/Dock.js.map +1 -0
  71. package/dist/Dock/index.d.ts +3 -0
  72. package/dist/Dock/index.js +2 -0
  73. package/dist/Empty/Empty.d.ts +17 -0
  74. package/dist/Empty/Empty.js +40 -0
  75. package/dist/Empty/Empty.js.map +1 -0
  76. package/dist/Empty/index.d.ts +3 -0
  77. package/dist/Empty/index.js +2 -0
  78. package/dist/Fact/Fact.d.ts +11 -0
  79. package/dist/Fact/Fact.js +27 -0
  80. package/dist/Fact/Fact.js.map +1 -0
  81. package/dist/Fact/index.d.ts +3 -0
  82. package/dist/Fact/index.js +2 -0
  83. package/dist/Field/Field.d.ts +44 -0
  84. package/dist/Field/Field.js +105 -0
  85. package/dist/Field/Field.js.map +1 -0
  86. package/dist/Field/index.d.ts +3 -0
  87. package/dist/Field/index.js +2 -0
  88. package/dist/Filters/Filters.d.ts +37 -0
  89. package/dist/Filters/Filters.js +64 -0
  90. package/dist/Filters/Filters.js.map +1 -0
  91. package/dist/Filters/index.d.ts +3 -0
  92. package/dist/Filters/index.js +2 -0
  93. package/dist/Flow/Flow.d.ts +17 -0
  94. package/dist/Flow/Flow.js +26 -0
  95. package/dist/Flow/Flow.js.map +1 -0
  96. package/dist/Flow/index.d.ts +3 -0
  97. package/dist/Flow/index.js +2 -0
  98. package/dist/Fold/Fold.d.ts +17 -0
  99. package/dist/Fold/Fold.js +64 -0
  100. package/dist/Fold/Fold.js.map +1 -0
  101. package/dist/Fold/index.d.ts +3 -0
  102. package/dist/Fold/index.js +2 -0
  103. package/dist/Frame/Frame.d.ts +7 -0
  104. package/dist/Frame/Frame.js +20 -0
  105. package/dist/Frame/Frame.js.map +1 -0
  106. package/dist/Frame/index.d.ts +3 -0
  107. package/dist/Frame/index.js +2 -0
  108. package/dist/Ground/Ground.d.ts +7 -0
  109. package/dist/Ground/Ground.js +19 -0
  110. package/dist/Ground/Ground.js.map +1 -0
  111. package/dist/Ground/index.d.ts +3 -0
  112. package/dist/Ground/index.js +2 -0
  113. package/dist/Hint/Hint.d.ts +21 -0
  114. package/dist/Hint/Hint.js +104 -0
  115. package/dist/Hint/Hint.js.map +1 -0
  116. package/dist/Hint/index.d.ts +3 -0
  117. package/dist/Hint/index.js +2 -0
  118. package/dist/Link/Link.d.ts +7 -0
  119. package/dist/Link/Link.js +20 -0
  120. package/dist/Link/Link.js.map +1 -0
  121. package/dist/Link/index.d.ts +3 -0
  122. package/dist/Link/index.js +2 -0
  123. package/dist/ListRow/ListRow.d.ts +25 -0
  124. package/dist/ListRow/ListRow.js +80 -0
  125. package/dist/ListRow/ListRow.js.map +1 -0
  126. package/dist/ListRow/index.d.ts +3 -0
  127. package/dist/ListRow/index.js +2 -0
  128. package/dist/Mark/Mark.d.ts +14 -0
  129. package/dist/Mark/Mark.js +28 -0
  130. package/dist/Mark/Mark.js.map +1 -0
  131. package/dist/Mark/index.d.ts +3 -0
  132. package/dist/Mark/index.js +2 -0
  133. package/dist/Menu/Menu.d.ts +29 -0
  134. package/dist/Menu/Menu.js +64 -0
  135. package/dist/Menu/Menu.js.map +1 -0
  136. package/dist/Menu/index.d.ts +3 -0
  137. package/dist/Menu/index.js +2 -0
  138. package/dist/Notice/Notice.d.ts +31 -0
  139. package/dist/Notice/Notice.js +82 -0
  140. package/dist/Notice/Notice.js.map +1 -0
  141. package/dist/Notice/index.d.ts +3 -0
  142. package/dist/Notice/index.js +2 -0
  143. package/dist/Placeholder/Placeholder.d.ts +15 -0
  144. package/dist/Placeholder/Placeholder.js +28 -0
  145. package/dist/Placeholder/Placeholder.js.map +1 -0
  146. package/dist/Placeholder/index.d.ts +3 -0
  147. package/dist/Placeholder/index.js +2 -0
  148. package/dist/Portal/Portal.d.ts +10 -0
  149. package/dist/Portal/Portal.js +13 -0
  150. package/dist/Portal/Portal.js.map +1 -0
  151. package/dist/Portal/index.d.ts +3 -0
  152. package/dist/Portal/index.js +2 -0
  153. package/dist/Progress/Progress.d.ts +22 -0
  154. package/dist/Progress/Progress.js +65 -0
  155. package/dist/Progress/Progress.js.map +1 -0
  156. package/dist/Progress/index.d.ts +3 -0
  157. package/dist/Progress/index.js +2 -0
  158. package/dist/Radio/Radio.d.ts +39 -0
  159. package/dist/Radio/Radio.js +118 -0
  160. package/dist/Radio/Radio.js.map +1 -0
  161. package/dist/Radio/index.d.ts +3 -0
  162. package/dist/Radio/index.js +2 -0
  163. package/dist/Range/Range.d.ts +26 -0
  164. package/dist/Range/Range.js +68 -0
  165. package/dist/Range/Range.js.map +1 -0
  166. package/dist/Range/index.d.ts +3 -0
  167. package/dist/Range/index.js +2 -0
  168. package/dist/ResultRow/ResultRow.d.ts +17 -0
  169. package/dist/ResultRow/ResultRow.js +46 -0
  170. package/dist/ResultRow/ResultRow.js.map +1 -0
  171. package/dist/ResultRow/index.d.ts +3 -0
  172. package/dist/ResultRow/index.js +2 -0
  173. package/dist/Score/Score.d.ts +16 -0
  174. package/dist/Score/Score.js +55 -0
  175. package/dist/Score/Score.js.map +1 -0
  176. package/dist/Score/index.d.ts +3 -0
  177. package/dist/Score/index.js +2 -0
  178. package/dist/Search/Search.d.ts +29 -0
  179. package/dist/Search/Search.js +94 -0
  180. package/dist/Search/Search.js.map +1 -0
  181. package/dist/Search/index.d.ts +3 -0
  182. package/dist/Search/index.js +2 -0
  183. package/dist/Segmented/Segmented.d.ts +24 -0
  184. package/dist/Segmented/Segmented.js +69 -0
  185. package/dist/Segmented/Segmented.js.map +1 -0
  186. package/dist/Segmented/index.d.ts +3 -0
  187. package/dist/Segmented/index.js +2 -0
  188. package/dist/Settings/Settings.d.ts +49 -0
  189. package/dist/Settings/Settings.js +93 -0
  190. package/dist/Settings/Settings.js.map +1 -0
  191. package/dist/Settings/index.d.ts +3 -0
  192. package/dist/Settings/index.js +2 -0
  193. package/dist/Sheet/Sheet.d.ts +7 -0
  194. package/dist/Sheet/Sheet.js +11 -0
  195. package/dist/Sheet/Sheet.js.map +1 -0
  196. package/dist/Sheet/index.d.ts +3 -0
  197. package/dist/Sheet/index.js +2 -0
  198. package/dist/Shelf/Shelf.d.ts +7 -0
  199. package/dist/Shelf/Shelf.js +23 -0
  200. package/dist/Shelf/Shelf.js.map +1 -0
  201. package/dist/Shelf/index.d.ts +3 -0
  202. package/dist/Shelf/index.js +2 -0
  203. package/dist/SlurpProvider/ColorSchemeScript.d.ts +15 -0
  204. package/dist/SlurpProvider/ColorSchemeScript.js +18 -0
  205. package/dist/SlurpProvider/ColorSchemeScript.js.map +1 -0
  206. package/dist/SlurpProvider/SlurpProvider.d.ts +18 -0
  207. package/dist/SlurpProvider/SlurpProvider.js +106 -0
  208. package/dist/SlurpProvider/SlurpProvider.js.map +1 -0
  209. package/dist/SlurpProvider/index.d.ts +5 -0
  210. package/dist/SlurpProvider/index.js +5 -0
  211. package/dist/Stage/Stage.d.ts +14 -0
  212. package/dist/Stage/Stage.js +38 -0
  213. package/dist/Stage/Stage.js.map +1 -0
  214. package/dist/Stage/index.d.ts +3 -0
  215. package/dist/Stage/index.js +2 -0
  216. package/dist/Surface/Surface.d.ts +16 -0
  217. package/dist/Surface/Surface.js +25 -0
  218. package/dist/Surface/Surface.js.map +1 -0
  219. package/dist/Surface/index.d.ts +3 -0
  220. package/dist/Surface/index.js +2 -0
  221. package/dist/Swatch/Swatch.d.ts +31 -0
  222. package/dist/Swatch/Swatch.js +72 -0
  223. package/dist/Swatch/Swatch.js.map +1 -0
  224. package/dist/Swatch/index.d.ts +3 -0
  225. package/dist/Swatch/index.js +2 -0
  226. package/dist/Switch/Switch.d.ts +15 -0
  227. package/dist/Switch/Switch.js +62 -0
  228. package/dist/Switch/Switch.js.map +1 -0
  229. package/dist/Switch/index.d.ts +3 -0
  230. package/dist/Switch/index.js +2 -0
  231. package/dist/Tabs/Tabs.d.ts +21 -0
  232. package/dist/Tabs/Tabs.js +105 -0
  233. package/dist/Tabs/Tabs.js.map +1 -0
  234. package/dist/Tabs/index.d.ts +3 -0
  235. package/dist/Tabs/index.js +2 -0
  236. package/dist/Text/Text.d.ts +17 -0
  237. package/dist/Text/Text.js +33 -0
  238. package/dist/Text/Text.js.map +1 -0
  239. package/dist/Text/index.d.ts +3 -0
  240. package/dist/Text/index.js +2 -0
  241. package/dist/Tile/Tile.d.ts +25 -0
  242. package/dist/Tile/Tile.js +67 -0
  243. package/dist/Tile/Tile.js.map +1 -0
  244. package/dist/Tile/index.d.ts +3 -0
  245. package/dist/Tile/index.js +2 -0
  246. package/dist/Toast/Toast.d.ts +43 -0
  247. package/dist/Toast/Toast.js +132 -0
  248. package/dist/Toast/Toast.js.map +1 -0
  249. package/dist/Toast/index.d.ts +3 -0
  250. package/dist/Toast/index.js +2 -0
  251. package/dist/VisuallyHidden/VisuallyHidden.d.ts +7 -0
  252. package/dist/VisuallyHidden/VisuallyHidden.js +15 -0
  253. package/dist/VisuallyHidden/VisuallyHidden.js.map +1 -0
  254. package/dist/VisuallyHidden/index.d.ts +3 -0
  255. package/dist/VisuallyHidden/index.js +2 -0
  256. package/dist/fonts/poppins-latin-400-normal.woff2 +0 -0
  257. package/dist/fonts/poppins-latin-500-normal.woff2 +0 -0
  258. package/dist/fonts/poppins-latin-600-normal.woff2 +0 -0
  259. package/dist/fonts/poppins-latin-700-normal.woff2 +0 -0
  260. package/dist/icons/index.d.ts +2 -0
  261. package/dist/icons/index.js +2 -0
  262. package/dist/index.d.ts +121 -0
  263. package/dist/index.js +69 -0
  264. package/dist/internal/animation.js +26 -0
  265. package/dist/internal/animation.js.map +1 -0
  266. package/dist/internal/context.d.ts +14 -0
  267. package/dist/internal/context.js +21 -0
  268. package/dist/internal/context.js.map +1 -0
  269. package/dist/internal/styled.js +79 -0
  270. package/dist/internal/styled.js.map +1 -0
  271. package/dist/lib/color.d.ts +21 -0
  272. package/dist/lib/color.js +151 -0
  273. package/dist/lib/color.js.map +1 -0
  274. package/dist/lib/crumb.d.ts +9 -0
  275. package/dist/lib/crumb.js +69 -0
  276. package/dist/lib/crumb.js.map +1 -0
  277. package/dist/lib/css.d.ts +53 -0
  278. package/dist/lib/css.js +142 -0
  279. package/dist/lib/css.js.map +1 -0
  280. package/dist/lib/ground.js +15 -0
  281. package/dist/lib/ground.js.map +1 -0
  282. package/dist/lib/layout.d.ts +24 -0
  283. package/dist/lib/layout.js +88 -0
  284. package/dist/lib/layout.js.map +1 -0
  285. package/dist/lib/polymorphic.d.ts +28 -0
  286. package/dist/lib/theme.d.ts +292 -0
  287. package/dist/lib/theme.js +90 -0
  288. package/dist/lib/theme.js.map +1 -0
  289. package/dist/motion/AnimationGroup.d.ts +10 -0
  290. package/dist/motion/AnimationGroup.js +14 -0
  291. package/dist/motion/AnimationGroup.js.map +1 -0
  292. package/dist/motion/context.js +8 -0
  293. package/dist/motion/context.js.map +1 -0
  294. package/dist/motion/index.d.ts +7 -0
  295. package/dist/motion/index.js +7 -0
  296. package/dist/motion/navigation.d.ts +51 -0
  297. package/dist/motion/navigation.js +122 -0
  298. package/dist/motion/navigation.js.map +1 -0
  299. package/dist/motion/useAnimationTarget.d.ts +22 -0
  300. package/dist/motion/useAnimationTarget.js +34 -0
  301. package/dist/motion/useAnimationTarget.js.map +1 -0
  302. package/dist/motion/useSlurp.d.ts +18 -0
  303. package/dist/motion/useSlurp.js +48 -0
  304. package/dist/motion/useSlurp.js.map +1 -0
  305. package/dist/styles.css +3439 -0
  306. package/dist/tokens/index.d.ts +2 -0
  307. package/dist/tokens/index.js +2 -0
  308. package/dist/tokens.css +178 -0
  309. package/dist/utils/focus.d.ts +20 -0
  310. package/dist/utils/focus.js +50 -0
  311. package/dist/utils/focus.js.map +1 -0
  312. package/dist/utils/index.d.ts +10 -0
  313. package/dist/utils/index.js +10 -0
  314. package/dist/utils/src/index.js +9 -0
  315. package/dist/utils/src/index.js.map +1 -0
  316. package/dist/utils/useControlled.d.ts +14 -0
  317. package/dist/utils/useControlled.js +23 -0
  318. package/dist/utils/useControlled.js.map +1 -0
  319. package/dist/utils/useDismiss.d.ts +24 -0
  320. package/dist/utils/useDismiss.js +60 -0
  321. package/dist/utils/useDismiss.js.map +1 -0
  322. package/dist/utils/useFindInPage.d.ts +18 -0
  323. package/dist/utils/useFindInPage.js +51 -0
  324. package/dist/utils/useFindInPage.js.map +1 -0
  325. package/dist/utils/useForkRef.d.ts +5 -0
  326. package/dist/utils/useForkRef.js +33 -0
  327. package/dist/utils/useForkRef.js.map +1 -0
  328. package/dist/utils/useMediaQuery.d.ts +11 -0
  329. package/dist/utils/useMediaQuery.js +21 -0
  330. package/dist/utils/useMediaQuery.js.map +1 -0
  331. package/dist/utils/useRovingFocus.d.ts +17 -0
  332. package/dist/utils/useRovingFocus.js +26 -0
  333. package/dist/utils/useRovingFocus.js.map +1 -0
  334. package/package.json +107 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hint.js","names":[],"sources":["../../src/Hint/Hint.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n Children,\n cloneElement,\n isValidElement,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type FocusEvent,\n type PointerEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { SlurpCss } from '../lib/css';\nimport { useForkRef } from '../utils/useForkRef';\n\nexport interface HintProps {\n /** The text: short, never essential (the trigger must make sense without it). */\n content: ReactNode;\n /** One element that takes focus (a button, a link). */\n children: ReactElement;\n /** Preferred side; it flips when there is no room. Default `top`. */\n placement?: 'top' | 'bottom';\n /** Hover delay in ms before it shows (focus shows it at once). Default 400. */\n delay?: number;\n className?: string;\n css?: SlurpCss;\n}\n\ntype TriggerProps = {\n ref?: Ref<HTMLElement>;\n 'aria-describedby'?: string;\n onPointerEnter?: (e: PointerEvent<HTMLElement>) => void;\n onPointerLeave?: (e: PointerEvent<HTMLElement>) => void;\n onFocus?: (e: FocusEvent<HTMLElement>) => void;\n onBlur?: (e: FocusEvent<HTMLElement>) => void;\n};\n\nconst GAP = 8;\nconst EDGE = 8;\n\n/**\n * Tooltip: shows on hover (after `delay`) and on focus, hides on Escape, blur or leave; it stays while the pointer is\n * over it (WCAG 1.4.13). Linked to the trigger with aria-describedby. Rendered in the top layer (popover).\n */\nexport function Hint(props: HintProps) {\n const {\n content,\n children,\n placement = 'top',\n delay = 400,\n className,\n css,\n } = useThemeProps('Hint', props);\n const id = useId();\n const [open, setOpen] = useState(false);\n const [side, setSide] = useState(placement);\n const trigger = useRef<HTMLElement>(null);\n const tip = useRef<HTMLSpanElement>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined);\n const styled = useCss('Hint', 'root', css);\n\n const child = Children.only(children);\n const childProps = (isValidElement(child) ? child.props : {}) as TriggerProps;\n const ref = useForkRef(childProps.ref, trigger);\n\n const later = (fn: () => void, ms: number) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(fn, ms);\n };\n const show = (now: boolean) => later(() => setOpen(true), now ? 0 : delay);\n const hide = () => later(() => setOpen(false), 100);\n\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useLayoutEffect(() => {\n const el = tip.current;\n const anchor = trigger.current;\n if (!open || !el || !anchor) return;\n el.showPopover?.();\n const place = () => {\n const a = anchor.getBoundingClientRect();\n const t = el.getBoundingClientRect();\n const above = a.top - GAP - t.height;\n const below = a.bottom + GAP;\n const fitsAbove = above >= EDGE;\n const fitsBelow = below + t.height <= innerHeight - EDGE;\n const top =\n placement === 'top'\n ? fitsAbove || !fitsBelow\n ? 'top'\n : 'bottom'\n : fitsBelow || !fitsAbove\n ? 'bottom'\n : 'top';\n const left = Math.min(\n Math.max(EDGE, a.left + a.width / 2 - t.width / 2),\n innerWidth - EDGE - t.width,\n );\n el.style.left = `${left}px`;\n el.style.top = `${top === 'top' ? above : below}px`;\n setSide(top);\n };\n place();\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') setOpen(false);\n };\n document.addEventListener('keydown', onKey);\n addEventListener('scroll', place, true);\n addEventListener('resize', place);\n return () => {\n document.removeEventListener('keydown', onKey);\n removeEventListener('scroll', place, true);\n removeEventListener('resize', place);\n el.hidePopover?.();\n };\n }, [open, placement]);\n\n const triggerElement = isValidElement(child)\n ? // eslint-disable-next-line react-hooks/refs -- the timer ref is read by event handlers, not during render\n cloneElement(child as ReactElement<TriggerProps>, {\n ref,\n 'aria-describedby': cx(childProps['aria-describedby'], id),\n onPointerEnter: (e) => {\n childProps.onPointerEnter?.(e);\n if (e.pointerType !== 'touch') show(false);\n },\n onPointerLeave: (e) => {\n childProps.onPointerLeave?.(e);\n hide();\n },\n onFocus: (e) => {\n childProps.onFocus?.(e);\n show(true);\n },\n onBlur: (e) => {\n childProps.onBlur?.(e);\n later(() => setOpen(false), 0);\n },\n })\n : child;\n\n return (\n <>\n {styled.style}\n {triggerElement}\n <span\n ref={tip}\n id={id}\n role=\"tooltip\"\n popover=\"manual\"\n className={cx('slurp-hint', styled.className, className)}\n data-open={open || undefined}\n data-side={side}\n onPointerEnter={() => clearTimeout(timer.current)}\n onPointerLeave={hide}\n >\n {content}\n </span>\n </>\n );\n}\n"],"mappings":";;;;;;;AA2CA,MAAM,MAAM;AACZ,MAAM,OAAO;;;;;AAMb,SAAgB,KAAK,OAAkB;CACrC,MAAM,EACJ,SACA,UACA,YAAY,OACZ,QAAQ,KACR,WACA,QACE,cAAc,QAAQ,KAAK;CAC/B,MAAM,KAAK,MAAM;CACjB,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,CAAC,MAAM,WAAW,SAAS,SAAS;CAC1C,MAAM,UAAU,OAAoB,IAAI;CACxC,MAAM,MAAM,OAAwB,IAAI;CACxC,MAAM,QAAQ,OAAsC,KAAA,CAAS;CAC7D,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CAEzC,MAAM,QAAQ,SAAS,KAAK,QAAQ;CACpC,MAAM,aAAc,eAAe,KAAK,IAAI,MAAM,QAAQ,CAAC;CAC3D,MAAM,MAAM,WAAW,WAAW,KAAK,OAAO;CAE9C,MAAM,SAAS,IAAgB,OAAe;EAC5C,aAAa,MAAM,OAAO;EAC1B,MAAM,UAAU,WAAW,IAAI,EAAE;CACnC;CACA,MAAM,QAAQ,QAAiB,YAAY,QAAQ,IAAI,GAAG,MAAM,IAAI,KAAK;CACzE,MAAM,aAAa,YAAY,QAAQ,KAAK,GAAG,GAAG;CAElD,sBAAsB,aAAa,MAAM,OAAO,GAAG,CAAC,CAAC;CAErD,sBAAsB;EACpB,MAAM,KAAK,IAAI;EACf,MAAM,SAAS,QAAQ;EACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ;EAC7B,GAAG,cAAc;EACjB,MAAM,cAAc;GAClB,MAAM,IAAI,OAAO,sBAAsB;GACvC,MAAM,IAAI,GAAG,sBAAsB;GACnC,MAAM,QAAQ,EAAE,MAAM,MAAM,EAAE;GAC9B,MAAM,QAAQ,EAAE,SAAS;GACzB,MAAM,YAAY,SAAS;GAC3B,MAAM,YAAY,QAAQ,EAAE,UAAU,cAAc;GACpD,MAAM,MACJ,cAAc,QACV,aAAa,CAAC,YACZ,QACA,WACF,aAAa,CAAC,YACZ,WACA;GACR,MAAM,OAAO,KAAK,IAChB,KAAK,IAAI,MAAM,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE,QAAQ,CAAC,GACjD,aAAa,OAAO,EAAE,KACxB;GACA,GAAG,MAAM,OAAO,GAAG,KAAK;GACxB,GAAG,MAAM,MAAM,GAAG,QAAQ,QAAQ,QAAQ,MAAM;GAChD,QAAQ,GAAG;EACb;EACA,MAAM;EACN,MAAM,SAAS,MAAqB;GAClC,IAAI,EAAE,QAAQ,UAAU,QAAQ,KAAK;EACvC;EACA,SAAS,iBAAiB,WAAW,KAAK;EAC1C,iBAAiB,UAAU,OAAO,IAAI;EACtC,iBAAiB,UAAU,KAAK;EAChC,aAAa;GACX,SAAS,oBAAoB,WAAW,KAAK;GAC7C,oBAAoB,UAAU,OAAO,IAAI;GACzC,oBAAoB,UAAU,KAAK;GACnC,GAAG,cAAc;EACnB;CACF,GAAG,CAAC,MAAM,SAAS,CAAC;CAEpB,MAAM,iBAAiB,eAAe,KAAK,IAEvC,aAAa,OAAqC;EAChD;EACA,oBAAoB,GAAG,WAAW,qBAAqB,EAAE;EACzD,iBAAiB,MAAM;GACrB,WAAW,iBAAiB,CAAC;GAC7B,IAAI,EAAE,gBAAgB,SAAS,KAAK,KAAK;EAC3C;EACA,iBAAiB,MAAM;GACrB,WAAW,iBAAiB,CAAC;GAC7B,KAAK;EACP;EACA,UAAU,MAAM;GACd,WAAW,UAAU,CAAC;GACtB,KAAK,IAAI;EACX;EACA,SAAS,MAAM;GACb,WAAW,SAAS,CAAC;GACrB,YAAY,QAAQ,KAAK,GAAG,CAAC;EAC/B;CACF,CAAC,IACD;CAEJ,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,oBAAC,QAAD;GACE,KAAK;GACD;GACJ,MAAK;GACL,SAAQ;GACR,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;GACvD,aAAW,QAAQ,KAAA;GACnB,aAAW;GACX,sBAAsB,aAAa,MAAM,OAAO;GAChD,gBAAgB;GAEf,UAAA;EACG,CAAA;CACN,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Hint, HintProps } from "./Hint.js";
3
+ export { Hint, type HintProps, Hint as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Hint, Hint as default } from "./Hint.js";
@@ -0,0 +1,7 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType } from "react";
4
+ export type LinkProps<E extends ElementType = 'a'> = PolymorphicProps<E>;
5
+ /** Text link: accent-ink and underlined (not colour alone). `as` renders a router link. */
6
+ export declare function Link<E extends ElementType = 'a'>(props: LinkProps<E>): import("react").JSX.Element;
7
+ //# sourceMappingURL=Link.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/Link/Link.tsx
7
+ /** Text link: accent-ink and underlined (not colour alone). `as` renders a router link. */
8
+ function Link(props) {
9
+ const { as, css, className, ...rest } = useThemeProps("Link", props);
10
+ const Root = as ?? "a";
11
+ const styled = useCss("Link", "root", css);
12
+ const root = useAnimationRoot(rest);
13
+ return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
14
+ className: cx("slurp-link", styled.className, className),
15
+ ...root
16
+ })] });
17
+ }
18
+ export { Link };
19
+
20
+ //# sourceMappingURL=Link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.js","names":[],"sources":["../../src/Link/Link.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 LinkProps<E extends ElementType = 'a'> = PolymorphicProps<E>;\n\n/** Text link: accent-ink and underlined (not colour alone). `as` renders a router link. */\nexport function Link<E extends ElementType = 'a'>(props: LinkProps<E>) {\n const { as, css, className, ...rest } = useThemeProps('Link', props as LinkProps);\n const Root = (as ?? 'a') as ElementType;\n const styled = useCss('Link', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-link', styled.className, className)} {...root} />\n </>\n );\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,KAAkC,OAAqB;CACrE,MAAM,EAAE,IAAI,KAAK,WAAW,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAChF,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;CAAO,CAAA,CAC3E,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Link, LinkProps } from "./Link.js";
3
+ export { Link, type LinkProps, Link as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Link, Link as default } from "./Link.js";
@@ -0,0 +1,25 @@
1
+
2
+ import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType, ReactNode } from "react";
4
+ export type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;
5
+ /** A list of ListRows (rows become list items). */
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'> {
8
+ title: ReactNode;
9
+ /** Leading mark (an icon, a logo); default the first letter of the title. */
10
+ mark?: ReactNode;
11
+ meta?: ReactNode;
12
+ /** Trailing value ("9.1", "1.239 €"). */
13
+ value?: ReactNode;
14
+ /** Highlight tag next to the title ("Consigliato"): with a check, never colour alone. */
15
+ tag?: ReactNode;
16
+ /** The row is highlighted: accent-soft with an accent-ink outline, and the tag. */
17
+ highlighted?: boolean;
18
+ /** Text of the trailing link; the row's title is added for assistive tech. */
19
+ actionLabel?: ReactNode;
20
+ href?: string;
21
+ }
22
+ export type ListRowProps<E extends ElementType = 'div'> = PolymorphicProps<E, ListRowOwnProps>;
23
+ /** Row of a list: mark, title (with an optional highlight tag), meta, a trailing value and one action link. */
24
+ export declare function ListRow<E extends ElementType = 'div'>(props: ListRowProps<E>): import("react").JSX.Element;
25
+ //# sourceMappingURL=ListRow.d.ts.map
@@ -0,0 +1,80 @@
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 { createContext, useContext } from "react";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ import { CheckIcon } from "@slurp-ui/icons";
8
+ // src/ListRow/ListRow.tsx
9
+ const InList = createContext(false);
10
+ /** A list of ListRows (rows become list items). */
11
+ function List(props) {
12
+ const { as, css, className, children, ...rest } = useThemeProps("List", props);
13
+ const Root = as ?? "ul";
14
+ const styled = useCss("List", "root", css);
15
+ const root = useAnimationRoot(rest);
16
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
17
+ className: cx("slurp-list", styled.className, className),
18
+ ...root,
19
+ children: /* @__PURE__ */ jsx(InList, {
20
+ value: Root === "ul" || Root === "ol",
21
+ children
22
+ })
23
+ })] });
24
+ }
25
+ /** Row of a list: mark, title (with an optional highlight tag), meta, a trailing value and one action link. */
26
+ function ListRow(props) {
27
+ const { as, css, className, title, mark, meta, value, tag, highlighted = false, actionLabel, href, parts, partProps, classNames, ...rest } = useThemeProps("ListRow", props);
28
+ const inList = useContext(InList);
29
+ const Root = as ?? (inList ? "li" : "div");
30
+ const styled = useCss("ListRow", "root", css);
31
+ const { part, style } = useParts("ListRow", {
32
+ parts,
33
+ partProps,
34
+ classNames
35
+ });
36
+ const root = useAnimationRoot(rest);
37
+ const initial = typeof title === "string" ? title.charAt(0) : null;
38
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
39
+ styled.style,
40
+ style,
41
+ /* @__PURE__ */ jsxs(Root, {
42
+ className: cx("slurp-list-row", styled.className, className),
43
+ "data-highlighted": highlighted || void 0,
44
+ ...root,
45
+ children: [
46
+ part("mark", "span", {
47
+ className: "slurp-list-row-mark",
48
+ "aria-hidden": true,
49
+ children: mark ?? initial
50
+ }),
51
+ /* @__PURE__ */ jsxs("span", {
52
+ className: "slurp-list-row-info",
53
+ children: [part("title", "span", {
54
+ className: "slurp-list-row-title",
55
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [title, tag != null && part("tag", "span", {
56
+ className: "slurp-list-row-tag",
57
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CheckIcon, { size: 12 }), tag] })
58
+ })] })
59
+ }), meta != null && part("meta", "span", {
60
+ className: "slurp-list-row-meta",
61
+ children: meta
62
+ })]
63
+ }),
64
+ value != null && part("value", "span", {
65
+ className: "slurp-list-row-value",
66
+ children: value
67
+ }),
68
+ actionLabel != null && part("action", "a", {
69
+ className: "slurp-list-row-action",
70
+ href: href ?? "#",
71
+ "aria-label": typeof actionLabel === "string" && typeof title === "string" ? `${actionLabel} ${title}` : void 0,
72
+ children: actionLabel
73
+ })
74
+ ]
75
+ })
76
+ ] });
77
+ }
78
+ export { List, ListRow };
79
+
80
+ //# sourceMappingURL=ListRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListRow.js","names":[],"sources":["../../src/ListRow/ListRow.tsx"],"sourcesContent":["import { CheckIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { createContext, useContext, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nconst InList = createContext(false);\n\nexport type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;\n\n/** A list of ListRows (rows become list items). */\nexport function List<E extends ElementType = 'ul'>(props: ListProps<E>) {\n const { as, css, className, children, ...rest } = useThemeProps('List', props as ListProps);\n const Root = (as ?? 'ul') as ElementType;\n const styled = useCss('List', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-list', styled.className, className)} {...root}>\n <InList value={Root === 'ul' || Root === 'ol'}>{children}</InList>\n </Root>\n </>\n );\n}\n\nexport interface ListRowOwnProps extends PartsProps<\n 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action'\n> {\n title: ReactNode;\n /** Leading mark (an icon, a logo); default the first letter of the title. */\n mark?: ReactNode;\n meta?: ReactNode;\n /** Trailing value (\"9.1\", \"1.239 €\"). */\n value?: ReactNode;\n /** Highlight tag next to the title (\"Consigliato\"): with a check, never colour alone. */\n tag?: ReactNode;\n /** The row is highlighted: accent-soft with an accent-ink outline, and the tag. */\n highlighted?: boolean;\n /** Text of the trailing link; the row's title is added for assistive tech. */\n actionLabel?: ReactNode;\n href?: string;\n}\n\nexport type ListRowProps<E extends ElementType = 'div'> = PolymorphicProps<E, ListRowOwnProps>;\n\n/** Row of a list: mark, title (with an optional highlight tag), meta, a trailing value and one action link. */\nexport function ListRow<E extends ElementType = 'div'>(props: ListRowProps<E>) {\n const {\n as,\n css,\n className,\n title,\n mark,\n meta,\n value,\n tag,\n highlighted = false,\n actionLabel,\n href,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('ListRow', props as ListRowProps);\n const inList = useContext(InList);\n const Root = (as ?? (inList ? 'li' : 'div')) as ElementType;\n const styled = useCss('ListRow', 'root', css);\n const { part, style } = useParts('ListRow', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const initial = typeof title === 'string' ? title.charAt(0) : null;\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-list-row', styled.className, className)}\n data-highlighted={highlighted || undefined}\n {...root}\n >\n {part('mark', 'span', {\n className: 'slurp-list-row-mark',\n 'aria-hidden': true,\n children: mark ?? initial,\n })}\n <span className=\"slurp-list-row-info\">\n {part('title', 'span', {\n className: 'slurp-list-row-title',\n children: (\n <>\n {title}\n {tag != null &&\n part('tag', 'span', {\n className: 'slurp-list-row-tag',\n children: (\n <>\n <CheckIcon size={12} />\n {tag}\n </>\n ),\n })}\n </>\n ),\n })}\n {meta != null &&\n part('meta', 'span', { className: 'slurp-list-row-meta', children: meta })}\n </span>\n {value != null &&\n part('value', 'span', { className: 'slurp-list-row-value', children: value })}\n {actionLabel != null &&\n part('action', 'a', {\n className: 'slurp-list-row-action',\n href: href ?? '#',\n // \"Vedi\" alone repeats on every row: the row's title completes the link's name.\n 'aria-label':\n typeof actionLabel === 'string' && typeof title === 'string'\n ? `${actionLabel} ${title}`\n : undefined,\n children: actionLabel,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,SAAS,cAAc,KAAK;;AAKlC,SAAgB,KAAmC,OAAqB;CACtE,MAAM,EAAE,IAAI,KAAK,WAAW,UAAU,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC1F,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;EAClE,UAAA,oBAAC,QAAD;GAAQ,OAAO,SAAS,QAAQ,SAAS;GAAO;EAAiB,CAAA;CAC7D,CAAA,CACN,EAAA,CAAA;AAEN;;AAuBA,SAAgB,QAAuC,OAAwB;CAC7E,MAAM,EACJ,IACA,KACA,WACA,OACA,MACA,MACA,OACA,KACA,cAAc,OACd,aACA,MACA,OACA,WACA,YACA,GAAG,SACD,cAAc,WAAW,KAAqB;CAClD,MAAM,SAAS,WAAW,MAAM;CAChC,MAAM,OAAQ,OAAO,SAAS,OAAO;CACrC,MAAM,SAAS,OAAO,WAAW,QAAQ,GAAG;CAC5C,MAAM,EAAE,MAAM,UAAU,SAAS,WAAW;EAAE;EAAO;EAAW;CAAW,CAAC;CAC5E,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,UAAU,OAAO,UAAU,WAAW,MAAM,OAAO,CAAC,IAAI;CAC9D,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,kBAAkB,OAAO,WAAW,SAAS;GAC3D,oBAAkB,eAAe,KAAA;GACjC,GAAI;GAHN,UAAA;IAKG,KAAK,QAAQ,QAAQ;KACpB,WAAW;KACX,eAAe;KACf,UAAU,QAAQ;IACpB,CAAC;IACD,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACG,KAAK,SAAS,QAAQ;MACrB,WAAW;MACX,UACE,qBAAA,YAAA,EAAA,UAAA,CACG,OACA,OAAO,QACN,KAAK,OAAO,QAAQ;OAClB,WAAW;OACX,UACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,GACrB,GACD,EAAA,CAAA;MAEN,CAAC,CACH,EAAA,CAAA;KAEN,CAAC,GACA,QAAQ,QACP,KAAK,QAAQ,QAAQ;MAAE,WAAW;MAAuB,UAAU;KAAK,CAAC,CACvE;;IACL,SAAS,QACR,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAwB,UAAU;IAAM,CAAC;IAC7E,eAAe,QACd,KAAK,UAAU,KAAK;KAClB,WAAW;KACX,MAAM,QAAQ;KAEd,cACE,OAAO,gBAAgB,YAAY,OAAO,UAAU,WAChD,GAAG,YAAY,GAAG,UAClB,KAAA;KACN,UAAU;IACZ,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { List, ListProps, ListRow, ListRowProps } from "./ListRow.js";
3
+ export { List, type ListProps, ListRow, type ListRowProps, ListRow as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { List, ListRow, ListRow as default } from "./ListRow.js";
@@ -0,0 +1,14 @@
1
+
2
+ import { ReactNode } from "react";
3
+ export interface MarkProps {
4
+ /** The text to show. */
5
+ text: string;
6
+ /** The in-page query: every match (case- and accent-insensitive) is wrapped in a mark. */
7
+ query?: string;
8
+ }
9
+ /**
10
+ * Text with the matches of the in-page search marked (`accent-soft` tint + accent underline; the active one is filled,
11
+ * see useFindInPage). Without a query it renders the plain text.
12
+ */
13
+ export declare function Mark({ text, query }: MarkProps): ReactNode;
14
+ //# sourceMappingURL=Mark.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { matchRanges } from "../lib/layout.js";
3
+ import { Fragment } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/Mark/Mark.tsx
6
+ /**
7
+ * Text with the matches of the in-page search marked (`accent-soft` tint + accent underline; the active one is filled,
8
+ * see useFindInPage). Without a query it renders the plain text.
9
+ */
10
+ function Mark({ text, query = "" }) {
11
+ const ranges = matchRanges(text, query);
12
+ if (!ranges.length) return text;
13
+ const parts = [];
14
+ let at = 0;
15
+ for (const [start, end] of ranges) {
16
+ if (start > at) parts.push(text.slice(at, start));
17
+ parts.push(/* @__PURE__ */ jsx("mark", {
18
+ className: "slurp-mark",
19
+ children: text.slice(start, end)
20
+ }, start));
21
+ at = end;
22
+ }
23
+ if (at < text.length) parts.push(text.slice(at));
24
+ return /* @__PURE__ */ jsx(Fragment, { children: parts });
25
+ }
26
+ export { Mark };
27
+
28
+ //# sourceMappingURL=Mark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mark.js","names":[],"sources":["../../src/Mark/Mark.tsx"],"sourcesContent":["import { Fragment, type ReactNode } from 'react';\n\nimport { matchRanges } from '../lib/layout';\n\nexport interface MarkProps {\n /** The text to show. */\n text: string;\n /** The in-page query: every match (case- and accent-insensitive) is wrapped in a mark. */\n query?: string;\n}\n\n/**\n * Text with the matches of the in-page search marked (`accent-soft` tint + accent underline; the active one is filled,\n * see useFindInPage). Without a query it renders the plain text.\n */\nexport function Mark({ text, query = '' }: MarkProps): ReactNode {\n const ranges = matchRanges(text, query);\n if (!ranges.length) return text;\n const parts: ReactNode[] = [];\n let at = 0;\n for (const [start, end] of ranges) {\n if (start > at) parts.push(text.slice(at, start));\n parts.push(\n <mark key={start} className=\"slurp-mark\">\n {text.slice(start, end)}\n </mark>,\n );\n at = end;\n }\n if (at < text.length) parts.push(text.slice(at));\n return <Fragment>{parts}</Fragment>;\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,KAAK,EAAE,MAAM,QAAQ,MAA4B;CAC/D,MAAM,SAAS,YAAY,MAAM,KAAK;CACtC,IAAI,CAAC,OAAO,QAAQ,OAAO;CAC3B,MAAM,QAAqB,CAAC;CAC5B,IAAI,KAAK;CACT,KAAK,MAAM,CAAC,OAAO,QAAQ,QAAQ;EACjC,IAAI,QAAQ,IAAI,MAAM,KAAK,KAAK,MAAM,IAAI,KAAK,CAAC;EAChD,MAAM,KACJ,oBAAC,QAAD;GAAkB,WAAU;GACzB,UAAA,KAAK,MAAM,OAAO,GAAG;EAClB,GAFK,KAEL,CACR;EACA,KAAK;CACP;CACA,IAAI,KAAK,KAAK,QAAQ,MAAM,KAAK,KAAK,MAAM,EAAE,CAAC;CAC/C,OAAO,oBAAC,UAAD,EAAA,UAAW,MAAgB,CAAA;AACpC"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Mark, MarkProps } from "./Mark.js";
3
+ export { Mark, type MarkProps, Mark as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Mark, Mark as default } from "./Mark.js";
@@ -0,0 +1,29 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { BloomOwnProps } from "../Bloom/Bloom.js";
4
+ import { ElementType, MouseEvent, ReactNode } from "react";
5
+ export type MenuProps<E extends ElementType = 'div'> = PolymorphicProps<E, Omit<BloomOwnProps, 'role' | 'children'> & {
6
+ /** MenuItem elements (other content, like a heading, is allowed too). */
7
+ children?: ReactNode;
8
+ }>;
9
+ /**
10
+ * A list of actions on Bloom: the trigger becomes the menu. Arrow keys move (looping), Home / End go to the ends,
11
+ * Enter or Space run the item, which closes the menu and gives focus back to the trigger.
12
+ */
13
+ export declare function Menu<E extends ElementType = 'div'>(props: MenuProps<E>): import("react").JSX.Element;
14
+ export declare namespace Menu {
15
+ var Item: typeof MenuItem;
16
+ }
17
+ export interface MenuItemOwnProps {
18
+ /** Runs the action; the menu closes afterwards (unless the handler calls preventDefault). */
19
+ onSelect?: (event: MouseEvent<HTMLButtonElement>) => void;
20
+ icon?: ReactNode;
21
+ disabled?: boolean;
22
+ /** `danger` for destructive actions (the text says so too). */
23
+ tone?: 'neutral' | 'danger';
24
+ children?: ReactNode;
25
+ }
26
+ export type MenuItemProps<E extends ElementType = 'button'> = PolymorphicProps<E, MenuItemOwnProps>;
27
+ /** One action of a Menu. */
28
+ export declare function MenuItem<E extends ElementType = 'button'>(props: MenuItemProps<E>): import("react").JSX.Element;
29
+ //# sourceMappingURL=Menu.d.ts.map
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { cx } from "../utils/src/index.js";
3
+ import { useThemeProps } from "../internal/styled.js";
4
+ import { moveFocus } from "../utils/focus.js";
5
+ import { Bloom } from "../Bloom/Bloom.js";
6
+ import { createContext, useContext, useRef } from "react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ // src/Menu/Menu.tsx
9
+ const MenuContext = createContext(null);
10
+ /**
11
+ * A list of actions on Bloom: the trigger becomes the menu. Arrow keys move (looping), Home / End go to the ends,
12
+ * Enter or Space run the item, which closes the menu and gives focus back to the trigger.
13
+ */
14
+ function Menu(props) {
15
+ const { children, width = 260, className, ...rest } = useThemeProps("Menu", props);
16
+ const list = useRef(null);
17
+ return /* @__PURE__ */ jsx(Bloom, {
18
+ ...rest,
19
+ role: "menu",
20
+ width,
21
+ className: cx("slurp-menu", className),
22
+ children: (close) => /* @__PURE__ */ jsx(MenuContext, {
23
+ value: close,
24
+ children: /* @__PURE__ */ jsx("div", {
25
+ ref: list,
26
+ className: "slurp-menu-list",
27
+ onKeyDown: (e) => moveFocus(e, list.current, "[role=\"menuitem\"]", { loop: true }),
28
+ children
29
+ })
30
+ })
31
+ });
32
+ }
33
+ /** One action of a Menu. */
34
+ function MenuItem(props) {
35
+ const { as, css: _css, className, onSelect, icon, disabled, tone = "neutral", children, ...rest } = props;
36
+ const close = useContext(MenuContext);
37
+ const Root = as ?? "button";
38
+ return /* @__PURE__ */ jsxs(Root, {
39
+ role: "menuitem",
40
+ tabIndex: -1,
41
+ className: cx("slurp-bloom-item", className),
42
+ "aria-disabled": disabled || void 0,
43
+ "data-tone": tone,
44
+ ...Root === "button" ? { type: "button" } : null,
45
+ onClick: (e) => {
46
+ if (disabled) return;
47
+ onSelect?.(e);
48
+ if (!e.defaultPrevented) close?.(true);
49
+ },
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
+ })]
59
+ });
60
+ }
61
+ Menu.Item = MenuItem;
62
+ export { Menu, MenuItem };
63
+
64
+ //# sourceMappingURL=Menu.js.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Menu, MenuItem, MenuItemProps, MenuProps } from "./Menu.js";
3
+ export { Menu, MenuItem, type MenuItemProps, type MenuProps, Menu as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Menu, MenuItem, Menu as default } from "./Menu.js";
@@ -0,0 +1,31 @@
1
+
2
+ import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType, ReactNode } from "react";
4
+ export type StatusTone = 'neutral' | 'success' | 'warning' | 'danger';
5
+ export interface NoticeLabels {
6
+ /** The word that names each tone (shown as the title when there is none). */
7
+ neutral: string;
8
+ success: string;
9
+ warning: string;
10
+ danger: string;
11
+ /** Name of the close button. */
12
+ dismiss: string;
13
+ }
14
+ export declare const NOTICE_LABELS: NoticeLabels;
15
+ export interface NoticeOwnProps extends PartsProps<'icon' | 'title' | 'body' | 'dismiss'> {
16
+ /** Default `neutral`. The state is an icon plus a word, never colour alone. */
17
+ tone?: StatusTone;
18
+ /** Short title; default the tone's word (`labels`). */
19
+ title?: ReactNode;
20
+ children?: ReactNode;
21
+ /** Shows a close button. */
22
+ onDismiss?: () => void;
23
+ labels?: Partial<NoticeLabels>;
24
+ }
25
+ export type NoticeProps<E extends ElementType = 'div'> = PolymorphicProps<E, NoticeOwnProps>;
26
+ /**
27
+ * A message in the page (alert): icon + word + text. `role="status"` by default (announced politely when it appears);
28
+ * pass `role="alert"` for errors that must interrupt.
29
+ */
30
+ export declare function Notice<E extends ElementType = 'div'>(props: NoticeProps<E>): import("react").JSX.Element;
31
+ //# sourceMappingURL=Notice.d.ts.map
@@ -0,0 +1,82 @@
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 { Bubble } from "../Bubble/Bubble.js";
6
+ import { useId } from "react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "@slurp-ui/icons";
9
+ // src/Notice/Notice.tsx
10
+ const NOTICE_LABELS = {
11
+ neutral: "Nota",
12
+ success: "Fatto",
13
+ warning: "Attenzione",
14
+ danger: "Errore",
15
+ dismiss: "Chiudi avviso"
16
+ };
17
+ const ICONS = {
18
+ neutral: InfoIcon,
19
+ success: SuccessIcon,
20
+ warning: WarningIcon,
21
+ danger: ErrorIcon
22
+ };
23
+ /**
24
+ * A message in the page (alert): icon + word + text. `role="status"` by default (announced politely when it appears);
25
+ * pass `role="alert"` for errors that must interrupt.
26
+ */
27
+ function Notice(props) {
28
+ const { as, css, className, tone = "neutral", title, children, onDismiss, labels: labelsProp, parts, partProps, classNames, ...rest } = useThemeProps("Notice", props);
29
+ const labels = {
30
+ ...NOTICE_LABELS,
31
+ ...labelsProp
32
+ };
33
+ const Root = as ?? "div";
34
+ const styled = useCss("Notice", "root", css);
35
+ const { part, style } = useParts("Notice", {
36
+ parts,
37
+ partProps,
38
+ classNames
39
+ });
40
+ const root = useAnimationRoot(rest);
41
+ const titleId = useId();
42
+ const Icon = ICONS[tone];
43
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
44
+ styled.style,
45
+ style,
46
+ /* @__PURE__ */ jsxs(Root, {
47
+ className: cx("slurp-notice", styled.className, className),
48
+ role: "status",
49
+ "aria-labelledby": titleId,
50
+ "data-tone": tone,
51
+ ...root,
52
+ children: [
53
+ part("icon", "span", {
54
+ className: "slurp-notice-icon",
55
+ "aria-hidden": true,
56
+ children: /* @__PURE__ */ jsx(Icon, { size: 22 })
57
+ }),
58
+ /* @__PURE__ */ jsxs("div", {
59
+ className: "slurp-notice-text",
60
+ children: [part("title", "p", {
61
+ id: titleId,
62
+ className: "slurp-notice-title",
63
+ children: title ?? labels[tone]
64
+ }), children != null && part("body", "div", {
65
+ className: "slurp-notice-body",
66
+ children
67
+ })]
68
+ }),
69
+ onDismiss && part("dismiss", Bubble, {
70
+ className: "slurp-notice-dismiss",
71
+ label: labels.dismiss,
72
+ size: "sm",
73
+ onClick: onDismiss,
74
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
75
+ })
76
+ ]
77
+ })
78
+ ] });
79
+ }
80
+ export { NOTICE_LABELS, Notice };
81
+
82
+ //# sourceMappingURL=Notice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notice.js","names":[],"sources":["../../src/Notice/Notice.tsx"],"sourcesContent":["import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ElementType, type ReactNode } from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport type StatusTone = 'neutral' | 'success' | 'warning' | 'danger';\n\nexport interface NoticeLabels {\n /** The word that names each tone (shown as the title when there is none). */\n neutral: string;\n success: string;\n warning: string;\n danger: string;\n /** Name of the close button. */\n dismiss: string;\n}\n\nexport const NOTICE_LABELS: NoticeLabels = {\n neutral: 'Nota',\n success: 'Fatto',\n warning: 'Attenzione',\n danger: 'Errore',\n dismiss: 'Chiudi avviso',\n};\n\nexport interface NoticeOwnProps extends PartsProps<'icon' | 'title' | 'body' | 'dismiss'> {\n /** Default `neutral`. The state is an icon plus a word, never colour alone. */\n tone?: StatusTone;\n /** Short title; default the tone's word (`labels`). */\n title?: ReactNode;\n children?: ReactNode;\n /** Shows a close button. */\n onDismiss?: () => void;\n labels?: Partial<NoticeLabels>;\n}\n\nexport type NoticeProps<E extends ElementType = 'div'> = PolymorphicProps<E, NoticeOwnProps>;\n\nconst ICONS = { neutral: InfoIcon, success: SuccessIcon, warning: WarningIcon, danger: ErrorIcon };\n\n/**\n * A message in the page (alert): icon + word + text. `role=\"status\"` by default (announced politely when it appears);\n * pass `role=\"alert\"` for errors that must interrupt.\n */\nexport function Notice<E extends ElementType = 'div'>(props: NoticeProps<E>) {\n const {\n as,\n css,\n className,\n tone = 'neutral',\n title,\n children,\n onDismiss,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Notice', props as NoticeProps);\n const labels = { ...NOTICE_LABELS, ...labelsProp };\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Notice', 'root', css);\n const { part, style } = useParts('Notice', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const titleId = useId();\n const Icon = ICONS[tone];\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-notice', styled.className, className)}\n role=\"status\"\n aria-labelledby={titleId}\n data-tone={tone}\n {...root}\n >\n {part('icon', 'span', {\n className: 'slurp-notice-icon',\n 'aria-hidden': true,\n children: <Icon size={22} />,\n })}\n <div className=\"slurp-notice-text\">\n {part('title', 'p', {\n id: titleId,\n className: 'slurp-notice-title',\n children: title ?? labels[tone],\n })}\n {children != null && part('body', 'div', { className: 'slurp-notice-body', children })}\n </div>\n {onDismiss &&\n part('dismiss', Bubble, {\n className: 'slurp-notice-dismiss',\n label: labels.dismiss,\n size: 'sm',\n onClick: onDismiss,\n children: <CloseIcon />,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAa,gBAA8B;CACzC,SAAS;CACT,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;AACX;AAeA,MAAM,QAAQ;CAAE,SAAS;CAAU,SAAS;CAAa,SAAS;CAAa,QAAQ;AAAU;;;;;AAMjG,SAAgB,OAAsC,OAAuB;CAC3E,MAAM,EACJ,IACA,KACA,WACA,OAAO,WACP,OACA,UACA,WACA,QAAQ,YACR,OACA,WACA,YACA,GAAG,SACD,cAAc,UAAU,KAAoB;CAChD,MAAM,SAAS;EAAE,GAAG;EAAe,GAAG;CAAW;CACjD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG;CAC3C,MAAM,EAAE,MAAM,UAAU,SAAS,UAAU;EAAE;EAAO;EAAW;CAAW,CAAC;CAC3E,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,UAAU,MAAM;CACtB,MAAM,OAAO,MAAM;CACnB,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,gBAAgB,OAAO,WAAW,SAAS;GACzD,MAAK;GACL,mBAAiB;GACjB,aAAW;GACX,GAAI;GALN,UAAA;IAOG,KAAK,QAAQ,QAAQ;KACpB,WAAW;KACX,eAAe;KACf,UAAU,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;IAC7B,CAAC;IACD,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,KAAK,SAAS,KAAK;MAClB,IAAI;MACJ,WAAW;MACX,UAAU,SAAS,OAAO;KAC5B,CAAC,GACA,YAAY,QAAQ,KAAK,QAAQ,OAAO;MAAE,WAAW;MAAqB;KAAS,CAAC,CAClF;;IACJ,aACC,KAAK,WAAW,QAAQ;KACtB,WAAW;KACX,OAAO,OAAO;KACd,MAAM;KACN,SAAS;KACT,UAAU,oBAAC,WAAD,CAAY,CAAA;IACxB,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { NOTICE_LABELS, Notice, NoticeLabels, NoticeProps, StatusTone } from "./Notice.js";
3
+ export { NOTICE_LABELS, Notice, type NoticeLabels, type NoticeProps, type StatusTone, Notice as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { NOTICE_LABELS, Notice, Notice as default } from "./Notice.js";
@@ -0,0 +1,15 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ElementType } from "react";
4
+ export interface PlaceholderOwnProps {
5
+ /** Rounded shapes only: `circle`, `capsule` (default) or `square` (soft corners). */
6
+ shape?: 'circle' | 'capsule' | 'square';
7
+ /** Number (px) or any CSS length. Default 100%. */
8
+ width?: number | string;
9
+ /** Number (px) or any CSS length. Default 16px (the circle and the square follow the width). */
10
+ height?: number | string;
11
+ }
12
+ export type PlaceholderProps<E extends ElementType = 'span'> = PolymorphicProps<E, PlaceholderOwnProps>;
13
+ /** Loading shape (skeleton): decorative, hidden from assistive tech; mark the loading region with aria-busy. */
14
+ export declare function Placeholder<E extends ElementType = 'span'>(props: PlaceholderProps<E>): import("react").JSX.Element;
15
+ //# sourceMappingURL=Placeholder.d.ts.map
@@ -0,0 +1,28 @@
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/Placeholder/Placeholder.tsx
7
+ const len = (v) => typeof v === "number" ? `${v}px` : v;
8
+ /** Loading shape (skeleton): decorative, hidden from assistive tech; mark the loading region with aria-busy. */
9
+ function Placeholder(props) {
10
+ const { as, css, className, shape = "capsule", width, height, style, ...rest } = useThemeProps("Placeholder", props);
11
+ const Root = as ?? "span";
12
+ const styled = useCss("Placeholder", "root", css);
13
+ const root = useAnimationRoot(rest);
14
+ return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
15
+ className: cx("slurp-placeholder", styled.className, className),
16
+ "aria-hidden": "true",
17
+ "data-shape": shape,
18
+ style: {
19
+ width: len(width),
20
+ height: len(height),
21
+ ...style
22
+ },
23
+ ...root
24
+ })] });
25
+ }
26
+ export { Placeholder };
27
+
28
+ //# sourceMappingURL=Placeholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Placeholder.js","names":[],"sources":["../../src/Placeholder/Placeholder.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { CSSProperties, ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface PlaceholderOwnProps {\n /** Rounded shapes only: `circle`, `capsule` (default) or `square` (soft corners). */\n shape?: 'circle' | 'capsule' | 'square';\n /** Number (px) or any CSS length. Default 100%. */\n width?: number | string;\n /** Number (px) or any CSS length. Default 16px (the circle and the square follow the width). */\n height?: number | string;\n}\n\nexport type PlaceholderProps<E extends ElementType = 'span'> = PolymorphicProps<\n E,\n PlaceholderOwnProps\n>;\n\nconst len = (v: number | string | undefined) => (typeof v === 'number' ? `${v}px` : v);\n\n/** Loading shape (skeleton): decorative, hidden from assistive tech; mark the loading region with aria-busy. */\nexport function Placeholder<E extends ElementType = 'span'>(props: PlaceholderProps<E>) {\n const {\n as,\n css,\n className,\n shape = 'capsule',\n width,\n height,\n style,\n ...rest\n } = useThemeProps('Placeholder', props as PlaceholderProps);\n const Root = (as ?? 'span') as ElementType;\n const styled = useCss('Placeholder', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-placeholder', styled.className, className)}\n aria-hidden=\"true\"\n data-shape={shape}\n style={{ width: len(width), height: len(height), ...style } as CSSProperties}\n {...root}\n />\n </>\n );\n}\n"],"mappings":";;;;;;AAqBA,MAAM,OAAO,MAAoC,OAAO,MAAM,WAAW,GAAG,EAAE,MAAM;;AAGpF,SAAgB,YAA4C,OAA4B;CACtF,MAAM,EACJ,IACA,KACA,WACA,QAAQ,WACR,OACA,QACA,OACA,GAAG,SACD,cAAc,eAAe,KAAyB;CAC1D,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,eAAe,QAAQ,GAAG;CAChD,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EACE,WAAW,GAAG,qBAAqB,OAAO,WAAW,SAAS;EAC9D,eAAY;EACZ,cAAY;EACZ,OAAO;GAAE,OAAO,IAAI,KAAK;GAAG,QAAQ,IAAI,MAAM;GAAG,GAAG;EAAM;EAC1D,GAAI;CACL,CAAA,CACD,EAAA,CAAA;AAEN"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Placeholder, PlaceholderProps } from "./Placeholder.js";
3
+ export { Placeholder, type PlaceholderProps, Placeholder as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Placeholder, Placeholder as default } from "./Placeholder.js";
@@ -0,0 +1,10 @@
1
+
2
+ import { ReactNode } from "react";
3
+ export interface PortalProps {
4
+ children?: ReactNode;
5
+ /** Where to render (default `document.body`). */
6
+ container?: Element | null;
7
+ }
8
+ /** Renders children elsewhere in the document (on the client only: nothing during server rendering). */
9
+ export declare function Portal({ children, container }: PortalProps): import("react").ReactPortal | null;
10
+ //# sourceMappingURL=Portal.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { useSyncExternalStore } from "react";
3
+ import { createPortal } from "react-dom";
4
+ // src/Portal/Portal.tsx
5
+ const noop = () => () => void 0;
6
+ /** Renders children elsewhere in the document (on the client only: nothing during server rendering). */
7
+ function Portal({ children, container }) {
8
+ if (!useSyncExternalStore(noop, () => true, () => false)) return null;
9
+ return createPortal(children, container ?? document.body);
10
+ }
11
+ export { Portal };
12
+
13
+ //# sourceMappingURL=Portal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Portal.js","names":[],"sources":["../../src/Portal/Portal.tsx"],"sourcesContent":["import { useSyncExternalStore, type ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\n\nexport interface PortalProps {\n children?: ReactNode;\n /** Where to render (default `document.body`). */\n container?: Element | null;\n}\n\nconst noop = () => () => undefined;\n\n/** Renders children elsewhere in the document (on the client only: nothing during server rendering). */\nexport function Portal({ children, container }: PortalProps) {\n const client = useSyncExternalStore(\n noop,\n () => true,\n () => false,\n );\n if (!client) return null;\n return createPortal(children, container ?? document.body);\n}\n"],"mappings":";;;;AASA,MAAM,mBAAmB,KAAA;;AAGzB,SAAgB,OAAO,EAAE,UAAU,aAA0B;CAM3D,IAAI,CALW,qBACb,YACM,YACA,KAEE,GAAG,OAAO;CACpB,OAAO,aAAa,UAAU,aAAa,SAAS,IAAI;AAC1D"}
@@ -0,0 +1,3 @@
1
+
2
+ import { Portal, PortalProps } from "./Portal.js";
3
+ export { Portal, type PortalProps, Portal as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { Portal, Portal as default } from "./Portal.js";