@heyramzi/ui 0.0.0-stage → 1.53.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 (564) hide show
  1. package/COMPONENTS.md +133 -0
  2. package/README.md +136 -2
  3. package/package.json +217 -3
  4. package/scripts/lib/sync-core.mjs +113 -0
  5. package/scripts/relative-imports.mjs +39 -0
  6. package/scripts/sf-symbol.mjs +93 -0
  7. package/scripts/sync-shadcn.mjs +354 -0
  8. package/scripts/sync-transitions.mjs +146 -0
  9. package/scripts/validate-apple-symbol-exports.mjs +45 -0
  10. package/src/agents/agent-avatar.svelte +592 -0
  11. package/src/agents/agent-cast.svelte +197 -0
  12. package/src/agents/demo.svelte +125 -0
  13. package/src/agents/helpers.ts +58 -0
  14. package/src/agents/index.ts +11 -0
  15. package/src/agents/page-state.ts +70 -0
  16. package/src/agents/types.ts +74 -0
  17. package/src/agents/vendor/LICENSE +21 -0
  18. package/src/agents/vendor/color.ts +155 -0
  19. package/src/agents/vendor/draw.ts +840 -0
  20. package/src/agents/vendor/engine.ts +845 -0
  21. package/src/agents/vendor/mesh.ts +838 -0
  22. package/src/agents/vendor/plastic.ts +4958 -0
  23. package/src/agents/vendor/presets.ts +103 -0
  24. package/src/agents/vendor/shapes.ts +41 -0
  25. package/src/agents/vendor/ticker.ts +67 -0
  26. package/src/agents/vendor/types.ts +261 -0
  27. package/src/agents/vendor/wear.ts +1699 -0
  28. package/src/ai/ai-button/AiButton.svelte +86 -0
  29. package/src/ai/ai-button/index.ts +4 -0
  30. package/src/ai/confirmation/Confirmation.svelte +54 -0
  31. package/src/ai/confirmation/ConfirmationAccepted.svelte +23 -0
  32. package/src/ai/confirmation/ConfirmationAction.svelte +53 -0
  33. package/src/ai/confirmation/ConfirmationActions.svelte +24 -0
  34. package/src/ai/confirmation/ConfirmationFailed.svelte +23 -0
  35. package/src/ai/confirmation/ConfirmationRejected.svelte +23 -0
  36. package/src/ai/confirmation/ConfirmationRequest.svelte +25 -0
  37. package/src/ai/confirmation/ConfirmationTitle.svelte +25 -0
  38. package/src/ai/confirmation/confirmation-context.svelte.ts +22 -0
  39. package/src/ai/confirmation/index.ts +50 -0
  40. package/src/ai/generation-progress/GenerationProgress.svelte +354 -0
  41. package/src/ai/generation-progress/index.ts +7 -0
  42. package/src/ai/index.ts +111 -0
  43. package/src/ai/loading-state/PixelLoader.svelte +138 -0
  44. package/src/ai/loading-state/index.ts +5 -0
  45. package/src/ai/prompt-input/PromptInput.svelte +56 -0
  46. package/src/ai/prompt-input/PromptInputBody.svelte +19 -0
  47. package/src/ai/prompt-input/PromptInputSubmit.svelte +79 -0
  48. package/src/ai/prompt-input/PromptInputTextarea.svelte +74 -0
  49. package/src/ai/prompt-input/PromptInputToolbar.svelte +19 -0
  50. package/src/ai/prompt-input/index.ts +34 -0
  51. package/src/ai/reasoning/Reasoning.svelte +50 -0
  52. package/src/ai/reasoning/ReasoningContent.svelte +27 -0
  53. package/src/ai/reasoning/ReasoningTrigger.svelte +48 -0
  54. package/src/ai/reasoning/index.ts +22 -0
  55. package/src/ai/reasoning/reasoning-context.svelte.ts +20 -0
  56. package/src/ai/response/Response.css +32 -0
  57. package/src/ai/response/Response.svelte +130 -0
  58. package/src/ai/response/index.ts +5 -0
  59. package/src/ai/suggestion/Suggestion.svelte +43 -0
  60. package/src/ai/suggestion/Suggestions.svelte +25 -0
  61. package/src/ai/suggestion/index.ts +14 -0
  62. package/src/ai/thinking-dots/ThinkingDots.svelte +42 -0
  63. package/src/ai/thinking-dots/index.ts +5 -0
  64. package/src/ai/typing-dots/TypingDots.css +39 -0
  65. package/src/ai/typing-dots/TypingDots.svelte +27 -0
  66. package/src/ai/typing-dots/index.ts +10 -0
  67. package/src/ai/voice-waveform/VoiceWaveform.css +40 -0
  68. package/src/ai/voice-waveform/VoiceWaveform.svelte +46 -0
  69. package/src/ai/voice-waveform/index.ts +5 -0
  70. package/src/ambient.d.ts +4 -0
  71. package/src/animations/README.md +84 -0
  72. package/src/animations/avatar-group-hover.css +47 -0
  73. package/src/animations/card-tilt.css +74 -0
  74. package/src/animations/digit-pop-in.css +78 -0
  75. package/src/animations/dropdown.css +121 -0
  76. package/src/animations/index.css +23 -0
  77. package/src/animations/input-clear-dissolve.css +86 -0
  78. package/src/animations/input-shake.css +114 -0
  79. package/src/animations/learn-more-hover.css +48 -0
  80. package/src/animations/like-button.css +93 -0
  81. package/src/animations/modal.css +75 -0
  82. package/src/animations/page-side-by-side.css +63 -0
  83. package/src/animations/plus-menu-morph.css +97 -0
  84. package/src/animations/resize.css +20 -0
  85. package/src/animations/shimmer-text.css +72 -0
  86. package/src/animations/spinning-counter.css +52 -0
  87. package/src/animations/success-check.css +120 -0
  88. package/src/animations/text-swap.css +40 -0
  89. package/src/animations/text-swap.ts +40 -0
  90. package/src/animations/thinking-states.css +65 -0
  91. package/src/animations/upstream-coverage.test.ts +65 -0
  92. package/src/components/copy/clipboard.test.ts +206 -0
  93. package/src/components/copy/clipboard.ts +49 -0
  94. package/src/components/copy/copied.svelte.ts +39 -0
  95. package/src/components/copy/copy-button.svelte +175 -0
  96. package/src/components/copy/copy-button.test.ts +110 -0
  97. package/src/components/copy/index.ts +3 -0
  98. package/src/components/data-table/data-table.test.ts +134 -0
  99. package/src/components/data-table/data-table.ts +77 -0
  100. package/src/components/data-table/index.ts +20 -0
  101. package/src/components/data-table/infinite-scroll.svelte +69 -0
  102. package/src/components/data-table/pagination.svelte +62 -0
  103. package/src/components/data-table/row-arrow.svelte +28 -0
  104. package/src/components/data-table/row-context-menu.svelte +106 -0
  105. package/src/components/data-table/row-context-menu.test.ts +18 -0
  106. package/src/components/data-table/sortable-head.svelte +56 -0
  107. package/src/components/data-table/table-skeleton.svelte +83 -0
  108. package/src/components/hold-to-confirm/hold-to-confirm.svelte +232 -0
  109. package/src/components/hold-to-confirm/index.ts +1 -0
  110. package/src/components/icon/icon.svelte +23 -0
  111. package/src/components/icon/index.ts +1 -0
  112. package/src/components/language-flag/index.ts +1 -0
  113. package/src/components/language-flag/language-flag.svelte +60 -0
  114. package/src/components/list-page/detail-empty.svelte +50 -0
  115. package/src/components/list-page/detail-header.svelte +107 -0
  116. package/src/components/list-page/detail-panel.svelte +90 -0
  117. package/src/components/list-page/detail-row.svelte +36 -0
  118. package/src/components/list-page/detail-stack.svelte +33 -0
  119. package/src/components/list-page/empty-state.svelte +91 -0
  120. package/src/components/list-page/filter-item.svelte +49 -0
  121. package/src/components/list-page/filter-popover.svelte +88 -0
  122. package/src/components/list-page/filter-section.ts +12 -0
  123. package/src/components/list-page/grouped-list.svelte +116 -0
  124. package/src/components/list-page/index.ts +28 -0
  125. package/src/components/list-page/list-page-shell.svelte +195 -0
  126. package/src/components/list-page/list-table.ts +19 -0
  127. package/src/components/list-page/master-detail.svelte +206 -0
  128. package/src/components/list-page/master-detail.test.ts +37 -0
  129. package/src/components/list-page/notice-bar.svelte +68 -0
  130. package/src/components/list-page/prev-next.svelte +104 -0
  131. package/src/components/list-page/queue-rail.ts +25 -0
  132. package/src/components/list-page/rail-body.svelte +29 -0
  133. package/src/components/list-page/rail-empty.svelte +51 -0
  134. package/src/components/list-page/rail-head.svelte +49 -0
  135. package/src/components/list-page/rail-row.svelte +163 -0
  136. package/src/components/list-page/section-host.ts +24 -0
  137. package/src/components/list-page/section-label.svelte +39 -0
  138. package/src/components/list-page/step.test.ts +21 -0
  139. package/src/components/list-page/step.ts +10 -0
  140. package/src/components/list-page/toolbar-search.svelte +63 -0
  141. package/src/components/list-page/toolbar-trigger.ts +23 -0
  142. package/src/components/list-page/types.ts +1 -0
  143. package/src/components/locale-switch/index.ts +1 -0
  144. package/src/components/locale-switch/locale-switch.svelte +59 -0
  145. package/src/components/mark/index.ts +1 -0
  146. package/src/components/mark/mark.svelte +70 -0
  147. package/src/components/open-in/index.ts +6 -0
  148. package/src/components/open-in/open-in.svelte +106 -0
  149. package/src/components/picker/index.ts +4 -0
  150. package/src/components/picker/mark-picker.svelte +84 -0
  151. package/src/components/picker/picker.svelte +143 -0
  152. package/src/components/picker/trigger.ts +42 -0
  153. package/src/components/picker/types.ts +26 -0
  154. package/src/components/segmented/animated-tabs.svelte +175 -0
  155. package/src/components/segmented/collapse.test.ts +49 -0
  156. package/src/components/segmented/collapse.ts +39 -0
  157. package/src/components/segmented/index.ts +41 -0
  158. package/src/components/segmented/section-runs.svelte +79 -0
  159. package/src/components/segmented/segment.svelte +106 -0
  160. package/src/components/segmented/segmented-filter.svelte +125 -0
  161. package/src/components/segmented/segmented-nav.svelte +82 -0
  162. package/src/components/segmented/segmented-overflow.svelte +85 -0
  163. package/src/components/segmented/segmented-track.svelte +181 -0
  164. package/src/components/segmented/segmented.test.ts +20 -0
  165. package/src/components/segmented/segmented.ts +80 -0
  166. package/src/components/star-rating-input/index.ts +9 -0
  167. package/src/components/star-rating-input/star-rating-input.svelte +256 -0
  168. package/src/components/svg/index.ts +1 -0
  169. package/src/components/svg/svg.svelte +9 -0
  170. package/src/design/index.css +270 -0
  171. package/src/design/polish.css +159 -0
  172. package/src/effects/animated-beam/AnimatedBeam.svelte +132 -0
  173. package/src/effects/animated-beam/diagrams/BeamSvg.svelte +91 -0
  174. package/src/effects/animated-beam/index.ts +2 -0
  175. package/src/effects/animated-beam/path-calculator.svelte.ts +70 -0
  176. package/src/effects/animated-beam/types.ts +23 -0
  177. package/src/effects/border-beam/BorderBeam.svelte +223 -0
  178. package/src/effects/border-beam/css.test.ts +46 -0
  179. package/src/effects/border-beam/css.ts +574 -0
  180. package/src/effects/border-beam/presets.ts +699 -0
  181. package/src/effects/border-beam/register-properties.test.ts +74 -0
  182. package/src/effects/border-beam/register-properties.ts +73 -0
  183. package/src/effects/border-beam/types.ts +38 -0
  184. package/src/effects/image-comparison/ImageComparison.css +100 -0
  185. package/src/effects/image-comparison/ImageComparison.svelte +209 -0
  186. package/src/effects/image-comparison/compare.test.ts +17 -0
  187. package/src/effects/image-comparison/compare.ts +5 -0
  188. package/src/effects/image-reveal/ImageReveal.css +10 -0
  189. package/src/effects/image-reveal/ImageReveal.svelte +357 -0
  190. package/src/effects/image-reveal/index.ts +2 -0
  191. package/src/effects/image-reveal/types.ts +35 -0
  192. package/src/effects/interactive-hover-button/InteractiveHoverButton.svelte +338 -0
  193. package/src/effects/magic-card/MagicCard.css +47 -0
  194. package/src/effects/magic-card/MagicCard.svelte +57 -0
  195. package/src/effects/magnetic/magnetic.ts +81 -0
  196. package/src/effects/marquee/Marquee.css +78 -0
  197. package/src/effects/marquee/Marquee.svelte +160 -0
  198. package/src/effects/progressive-blur/ProgressiveBlur.css +9 -0
  199. package/src/effects/progressive-blur/ProgressiveBlur.svelte +63 -0
  200. package/src/effects/reveal/AnimatedGroup.svelte +101 -0
  201. package/src/effects/reveal/InView.svelte +77 -0
  202. package/src/effects/reveal/TextEffect.svelte +142 -0
  203. package/src/effects/reveal/index.ts +11 -0
  204. package/src/effects/reveal/observe.test.ts +60 -0
  205. package/src/effects/reveal/observe.ts +65 -0
  206. package/src/effects/reveal/reveal.css +141 -0
  207. package/src/effects/reveal/types.ts +32 -0
  208. package/src/effects/shader-gradient/ShaderGradient.svelte +227 -0
  209. package/src/effects/shader-gradient/color.ts +44 -0
  210. package/src/effects/shader-gradient/index.ts +5 -0
  211. package/src/effects/shader-gradient/renderer.ts +456 -0
  212. package/src/effects/shader-gradient/shaders.ts +324 -0
  213. package/src/effects/shader-gradient/types.ts +68 -0
  214. package/src/effects/spotlight/Spotlight.css +14 -0
  215. package/src/effects/spotlight/Spotlight.svelte +61 -0
  216. package/src/effects/theme-toggle/ThemeToggle.css +214 -0
  217. package/src/effects/theme-toggle/ThemeToggle.svelte +126 -0
  218. package/src/gallery.test.ts +52 -0
  219. package/src/icons/TradeIcon.svelte +16 -0
  220. package/src/icons/apple-symbol-exports.ts +135 -0
  221. package/src/icons/sf-symbols.ts +527 -0
  222. package/src/icons/trades.ts +89 -0
  223. package/src/index.ts +53 -0
  224. package/src/lib/arrive.ts +26 -0
  225. package/src/lib/icon-types.ts +17 -0
  226. package/src/lib/layout.ts +8 -0
  227. package/src/lib/panel.ts +21 -0
  228. package/src/lib/sliding-pill.ts +68 -0
  229. package/src/lib/theme-transition.ts +79 -0
  230. package/src/lib/tone.ts +48 -0
  231. package/src/shadcn/accordion/accordion-content.svelte +22 -0
  232. package/src/shadcn/accordion/accordion-item.svelte +17 -0
  233. package/src/shadcn/accordion/accordion-trigger.svelte +44 -0
  234. package/src/shadcn/accordion/accordion.svelte +19 -0
  235. package/src/shadcn/accordion/index.ts +16 -0
  236. package/src/shadcn/alert/alert-description.svelte +23 -0
  237. package/src/shadcn/alert/alert-title.svelte +20 -0
  238. package/src/shadcn/alert/alert.svelte +46 -0
  239. package/src/shadcn/alert/index.ts +14 -0
  240. package/src/shadcn/alert-dialog/alert-dialog-action.svelte +18 -0
  241. package/src/shadcn/alert-dialog/alert-dialog-cancel.svelte +18 -0
  242. package/src/shadcn/alert-dialog/alert-dialog-content.svelte +29 -0
  243. package/src/shadcn/alert-dialog/alert-dialog-description.svelte +17 -0
  244. package/src/shadcn/alert-dialog/alert-dialog-footer.svelte +20 -0
  245. package/src/shadcn/alert-dialog/alert-dialog-header.svelte +20 -0
  246. package/src/shadcn/alert-dialog/alert-dialog-overlay.svelte +17 -0
  247. package/src/shadcn/alert-dialog/alert-dialog-portal.svelte +7 -0
  248. package/src/shadcn/alert-dialog/alert-dialog-title.svelte +17 -0
  249. package/src/shadcn/alert-dialog/alert-dialog-trigger.svelte +7 -0
  250. package/src/shadcn/alert-dialog/alert-dialog.svelte +7 -0
  251. package/src/shadcn/alert-dialog/index.ts +37 -0
  252. package/src/shadcn/attachment/attachment-action.svelte +23 -0
  253. package/src/shadcn/attachment/attachment-actions.svelte +23 -0
  254. package/src/shadcn/attachment/attachment-content.svelte +23 -0
  255. package/src/shadcn/attachment/attachment-description.svelte +23 -0
  256. package/src/shadcn/attachment/attachment-group.svelte +23 -0
  257. package/src/shadcn/attachment/attachment-media.svelte +44 -0
  258. package/src/shadcn/attachment/attachment-title.svelte +23 -0
  259. package/src/shadcn/attachment/attachment-trigger.svelte +29 -0
  260. package/src/shadcn/attachment/attachment.svelte +55 -0
  261. package/src/shadcn/attachment/index.ts +40 -0
  262. package/src/shadcn/avatar/avatar-badge.svelte +26 -0
  263. package/src/shadcn/avatar/avatar-fallback.svelte +20 -0
  264. package/src/shadcn/avatar/avatar-group-count.svelte +23 -0
  265. package/src/shadcn/avatar/avatar-group.svelte +23 -0
  266. package/src/shadcn/avatar/avatar-image.svelte +17 -0
  267. package/src/shadcn/avatar/avatar.svelte +26 -0
  268. package/src/shadcn/avatar/index.ts +22 -0
  269. package/src/shadcn/badge/badge.svelte +54 -0
  270. package/src/shadcn/badge/index.ts +2 -0
  271. package/src/shadcn/breadcrumb/breadcrumb-ellipsis.svelte +23 -0
  272. package/src/shadcn/breadcrumb/breadcrumb-item.svelte +20 -0
  273. package/src/shadcn/breadcrumb/breadcrumb-link.svelte +31 -0
  274. package/src/shadcn/breadcrumb/breadcrumb-list.svelte +23 -0
  275. package/src/shadcn/breadcrumb/breadcrumb-page.svelte +23 -0
  276. package/src/shadcn/breadcrumb/breadcrumb-separator.svelte +27 -0
  277. package/src/shadcn/breadcrumb/breadcrumb.svelte +21 -0
  278. package/src/shadcn/breadcrumb/index.ts +25 -0
  279. package/src/shadcn/bubble/bubble-content.svelte +31 -0
  280. package/src/shadcn/bubble/bubble-group.svelte +20 -0
  281. package/src/shadcn/bubble/bubble-reactions.svelte +52 -0
  282. package/src/shadcn/bubble/bubble.svelte +58 -0
  283. package/src/shadcn/bubble/index.ts +25 -0
  284. package/src/shadcn/button/button.svelte +121 -0
  285. package/src/shadcn/button/index.ts +17 -0
  286. package/src/shadcn/calendar/calendar-caption.svelte +76 -0
  287. package/src/shadcn/calendar/calendar-cell.svelte +19 -0
  288. package/src/shadcn/calendar/calendar-day.svelte +35 -0
  289. package/src/shadcn/calendar/calendar-grid-body.svelte +12 -0
  290. package/src/shadcn/calendar/calendar-grid-head.svelte +12 -0
  291. package/src/shadcn/calendar/calendar-grid-row.svelte +12 -0
  292. package/src/shadcn/calendar/calendar-grid.svelte +16 -0
  293. package/src/shadcn/calendar/calendar-head-cell.svelte +19 -0
  294. package/src/shadcn/calendar/calendar-header.svelte +19 -0
  295. package/src/shadcn/calendar/calendar-heading.svelte +16 -0
  296. package/src/shadcn/calendar/calendar-month-select.svelte +44 -0
  297. package/src/shadcn/calendar/calendar-month.svelte +15 -0
  298. package/src/shadcn/calendar/calendar-months.svelte +19 -0
  299. package/src/shadcn/calendar/calendar-nav.svelte +19 -0
  300. package/src/shadcn/calendar/calendar-next-button.svelte +31 -0
  301. package/src/shadcn/calendar/calendar-prev-button.svelte +31 -0
  302. package/src/shadcn/calendar/calendar-year-select.svelte +43 -0
  303. package/src/shadcn/calendar/calendar.svelte +124 -0
  304. package/src/shadcn/calendar/index.ts +40 -0
  305. package/src/shadcn/card/card-action.svelte +23 -0
  306. package/src/shadcn/card/card-content.svelte +20 -0
  307. package/src/shadcn/card/card-description.svelte +20 -0
  308. package/src/shadcn/card/card-footer.svelte +23 -0
  309. package/src/shadcn/card/card-header.svelte +23 -0
  310. package/src/shadcn/card/card-title.svelte +29 -0
  311. package/src/shadcn/card/card.svelte +25 -0
  312. package/src/shadcn/card/index.ts +25 -0
  313. package/src/shadcn/checkbox/checkbox.svelte +38 -0
  314. package/src/shadcn/checkbox/index.ts +6 -0
  315. package/src/shadcn/code-block/code-block-actions.svelte +23 -0
  316. package/src/shadcn/code-block/code-block-content.svelte +55 -0
  317. package/src/shadcn/code-block/code-block-copy-button.svelte +10 -0
  318. package/src/shadcn/code-block/code-block-footer.svelte +20 -0
  319. package/src/shadcn/code-block/code-block-header.svelte +23 -0
  320. package/src/shadcn/code-block/code-block-line.svelte +71 -0
  321. package/src/shadcn/code-block/code-block-title.svelte +23 -0
  322. package/src/shadcn/code-block/code-block.svelte +47 -0
  323. package/src/shadcn/code-block/index.ts +42 -0
  324. package/src/shadcn/collapsible/collapsible-content.svelte +7 -0
  325. package/src/shadcn/collapsible/collapsible-trigger.svelte +7 -0
  326. package/src/shadcn/collapsible/collapsible.svelte +11 -0
  327. package/src/shadcn/collapsible/index.ts +13 -0
  328. package/src/shadcn/command/command-dialog.svelte +66 -0
  329. package/src/shadcn/command/command-empty.svelte +17 -0
  330. package/src/shadcn/command/command-group.svelte +40 -0
  331. package/src/shadcn/command/command-input.svelte +64 -0
  332. package/src/shadcn/command/command-item.svelte +37 -0
  333. package/src/shadcn/command/command-link-item.svelte +20 -0
  334. package/src/shadcn/command/command-list.svelte +20 -0
  335. package/src/shadcn/command/command-loading.svelte +7 -0
  336. package/src/shadcn/command/command-separator.svelte +17 -0
  337. package/src/shadcn/command/command-shortcut.svelte +23 -0
  338. package/src/shadcn/command/command.svelte +28 -0
  339. package/src/shadcn/command/index.ts +40 -0
  340. package/src/shadcn/context-menu/context-menu-checkbox-item.svelte +41 -0
  341. package/src/shadcn/context-menu/context-menu-content.svelte +28 -0
  342. package/src/shadcn/context-menu/context-menu-group-heading.svelte +21 -0
  343. package/src/shadcn/context-menu/context-menu-group.svelte +7 -0
  344. package/src/shadcn/context-menu/context-menu-item.svelte +27 -0
  345. package/src/shadcn/context-menu/context-menu-label.svelte +27 -0
  346. package/src/shadcn/context-menu/context-menu-portal.svelte +7 -0
  347. package/src/shadcn/context-menu/context-menu-radio-group.svelte +16 -0
  348. package/src/shadcn/context-menu/context-menu-radio-item.svelte +35 -0
  349. package/src/shadcn/context-menu/context-menu-separator.svelte +17 -0
  350. package/src/shadcn/context-menu/context-menu-shortcut.svelte +23 -0
  351. package/src/shadcn/context-menu/context-menu-sub-content.svelte +25 -0
  352. package/src/shadcn/context-menu/context-menu-sub-trigger.svelte +29 -0
  353. package/src/shadcn/context-menu/context-menu-sub.svelte +7 -0
  354. package/src/shadcn/context-menu/context-menu-trigger.svelte +17 -0
  355. package/src/shadcn/context-menu/context-menu.svelte +7 -0
  356. package/src/shadcn/context-menu/index.ts +52 -0
  357. package/src/shadcn/dialog/dialog-close.svelte +11 -0
  358. package/src/shadcn/dialog/dialog-content.svelte +57 -0
  359. package/src/shadcn/dialog/dialog-description.svelte +20 -0
  360. package/src/shadcn/dialog/dialog-footer.svelte +32 -0
  361. package/src/shadcn/dialog/dialog-header.svelte +20 -0
  362. package/src/shadcn/dialog/dialog-overlay.svelte +20 -0
  363. package/src/shadcn/dialog/dialog-portal.svelte +7 -0
  364. package/src/shadcn/dialog/dialog-title.svelte +17 -0
  365. package/src/shadcn/dialog/dialog-trigger.svelte +11 -0
  366. package/src/shadcn/dialog/dialog.svelte +7 -0
  367. package/src/shadcn/dialog/index.ts +34 -0
  368. package/src/shadcn/dropdown-menu/dropdown-menu-checkbox-group.svelte +16 -0
  369. package/src/shadcn/dropdown-menu/dropdown-menu-checkbox-item.svelte +43 -0
  370. package/src/shadcn/dropdown-menu/dropdown-menu-content.svelte +31 -0
  371. package/src/shadcn/dropdown-menu/dropdown-menu-group-heading.svelte +22 -0
  372. package/src/shadcn/dropdown-menu/dropdown-menu-group.svelte +7 -0
  373. package/src/shadcn/dropdown-menu/dropdown-menu-item.svelte +29 -0
  374. package/src/shadcn/dropdown-menu/dropdown-menu-label.svelte +27 -0
  375. package/src/shadcn/dropdown-menu/dropdown-menu-portal.svelte +7 -0
  376. package/src/shadcn/dropdown-menu/dropdown-menu-radio-group.svelte +16 -0
  377. package/src/shadcn/dropdown-menu/dropdown-menu-radio-item.svelte +34 -0
  378. package/src/shadcn/dropdown-menu/dropdown-menu-separator.svelte +17 -0
  379. package/src/shadcn/dropdown-menu/dropdown-menu-shortcut.svelte +23 -0
  380. package/src/shadcn/dropdown-menu/dropdown-menu-sub-content.svelte +20 -0
  381. package/src/shadcn/dropdown-menu/dropdown-menu-sub-trigger.svelte +29 -0
  382. package/src/shadcn/dropdown-menu/dropdown-menu-sub.svelte +7 -0
  383. package/src/shadcn/dropdown-menu/dropdown-menu-trigger.svelte +7 -0
  384. package/src/shadcn/dropdown-menu/dropdown-menu.svelte +7 -0
  385. package/src/shadcn/dropdown-menu/index.ts +56 -0
  386. package/src/shadcn/dropdown-menu/menu-item.ts +43 -0
  387. package/src/shadcn/empty/empty-content.svelte +23 -0
  388. package/src/shadcn/empty/empty-description.svelte +23 -0
  389. package/src/shadcn/empty/empty-header.svelte +20 -0
  390. package/src/shadcn/empty/empty-media.svelte +41 -0
  391. package/src/shadcn/empty/empty-title.svelte +20 -0
  392. package/src/shadcn/empty/empty.svelte +23 -0
  393. package/src/shadcn/empty/index.ts +22 -0
  394. package/src/shadcn/field/field-content.svelte +20 -0
  395. package/src/shadcn/field/field-description.svelte +25 -0
  396. package/src/shadcn/field/field-error.svelte +58 -0
  397. package/src/shadcn/field/field-group.svelte +23 -0
  398. package/src/shadcn/field/field-label.svelte +26 -0
  399. package/src/shadcn/field/field-legend.svelte +29 -0
  400. package/src/shadcn/field/field-separator.svelte +35 -0
  401. package/src/shadcn/field/field-set.svelte +24 -0
  402. package/src/shadcn/field/field-title.svelte +23 -0
  403. package/src/shadcn/field/field.svelte +53 -0
  404. package/src/shadcn/field/index.ts +36 -0
  405. package/src/shadcn/field/simple-field.svelte +71 -0
  406. package/src/shadcn/field/simple-field.test.ts +47 -0
  407. package/src/shadcn/hooks/highlighter.ts +132 -0
  408. package/src/shadcn/hooks/is-mobile.svelte.ts +9 -0
  409. package/src/shadcn/hooks/use-highlighted-code.svelte.ts +98 -0
  410. package/src/shadcn/hover-card/hover-card-content.svelte +31 -0
  411. package/src/shadcn/hover-card/hover-card-portal.svelte +7 -0
  412. package/src/shadcn/hover-card/hover-card-trigger.svelte +7 -0
  413. package/src/shadcn/hover-card/hover-card.svelte +7 -0
  414. package/src/shadcn/hover-card/index.ts +15 -0
  415. package/src/shadcn/input/index.ts +9 -0
  416. package/src/shadcn/input/input.svelte +48 -0
  417. package/src/shadcn/input/secret-input.svelte +75 -0
  418. package/src/shadcn/input-otp/index.ts +15 -0
  419. package/src/shadcn/input-otp/input-otp-group.svelte +20 -0
  420. package/src/shadcn/input-otp/input-otp-separator.svelte +25 -0
  421. package/src/shadcn/input-otp/input-otp-slot.svelte +26 -0
  422. package/src/shadcn/input-otp/input-otp.svelte +22 -0
  423. package/src/shadcn/kbd/index.ts +10 -0
  424. package/src/shadcn/kbd/kbd-group.svelte +20 -0
  425. package/src/shadcn/kbd/kbd.svelte +23 -0
  426. package/src/shadcn/label/index.ts +7 -0
  427. package/src/shadcn/label/label.svelte +20 -0
  428. package/src/shadcn/marker/index.ts +15 -0
  429. package/src/shadcn/marker/marker-content.svelte +23 -0
  430. package/src/shadcn/marker/marker-icon.svelte +21 -0
  431. package/src/shadcn/marker/marker.svelte +52 -0
  432. package/src/shadcn/message/index.ts +22 -0
  433. package/src/shadcn/message/message-avatar.svelte +23 -0
  434. package/src/shadcn/message/message-content.svelte +23 -0
  435. package/src/shadcn/message/message-footer.svelte +23 -0
  436. package/src/shadcn/message/message-group.svelte +20 -0
  437. package/src/shadcn/message/message-header.svelte +23 -0
  438. package/src/shadcn/message/message.svelte +27 -0
  439. package/src/shadcn/message-scroller/index.ts +28 -0
  440. package/src/shadcn/message-scroller/message-scroller-button.svelte +52 -0
  441. package/src/shadcn/message-scroller/message-scroller-content.svelte +17 -0
  442. package/src/shadcn/message-scroller/message-scroller-item.svelte +22 -0
  443. package/src/shadcn/message-scroller/message-scroller-provider.svelte +7 -0
  444. package/src/shadcn/message-scroller/message-scroller-viewport.svelte +20 -0
  445. package/src/shadcn/message-scroller/message-scroller.svelte +20 -0
  446. package/src/shadcn/popover/index.ts +28 -0
  447. package/src/shadcn/popover/popover-close.svelte +7 -0
  448. package/src/shadcn/popover/popover-content.svelte +38 -0
  449. package/src/shadcn/popover/popover-description.svelte +20 -0
  450. package/src/shadcn/popover/popover-header.svelte +20 -0
  451. package/src/shadcn/popover/popover-portal.svelte +7 -0
  452. package/src/shadcn/popover/popover-title.svelte +15 -0
  453. package/src/shadcn/popover/popover-trigger.svelte +17 -0
  454. package/src/shadcn/popover/popover.svelte +7 -0
  455. package/src/shadcn/progress/index.ts +7 -0
  456. package/src/shadcn/progress/progress.svelte +30 -0
  457. package/src/shadcn/radio-group/index.ts +10 -0
  458. package/src/shadcn/radio-group/radio-group-item.svelte +32 -0
  459. package/src/shadcn/radio-group/radio-group.svelte +19 -0
  460. package/src/shadcn/scroll-area/index.ts +10 -0
  461. package/src/shadcn/scroll-area/scroll-area-scrollbar.svelte +30 -0
  462. package/src/shadcn/scroll-area/scroll-area.svelte +43 -0
  463. package/src/shadcn/select/index.ts +37 -0
  464. package/src/shadcn/select/select-content.svelte +45 -0
  465. package/src/shadcn/select/select-group-heading.svelte +21 -0
  466. package/src/shadcn/select/select-group.svelte +17 -0
  467. package/src/shadcn/select/select-item.svelte +38 -0
  468. package/src/shadcn/select/select-label.svelte +20 -0
  469. package/src/shadcn/select/select-portal.svelte +7 -0
  470. package/src/shadcn/select/select-scroll-down-button.svelte +23 -0
  471. package/src/shadcn/select/select-scroll-up-button.svelte +23 -0
  472. package/src/shadcn/select/select-separator.svelte +18 -0
  473. package/src/shadcn/select/select-trigger.svelte +33 -0
  474. package/src/shadcn/select/select.svelte +11 -0
  475. package/src/shadcn/separator/index.ts +7 -0
  476. package/src/shadcn/separator/separator.svelte +23 -0
  477. package/src/shadcn/sheet/index.ts +34 -0
  478. package/src/shadcn/sheet/sheet-close.svelte +7 -0
  479. package/src/shadcn/sheet/sheet-content.svelte +73 -0
  480. package/src/shadcn/sheet/sheet-description.svelte +17 -0
  481. package/src/shadcn/sheet/sheet-footer.svelte +20 -0
  482. package/src/shadcn/sheet/sheet-header.svelte +20 -0
  483. package/src/shadcn/sheet/sheet-overlay.svelte +20 -0
  484. package/src/shadcn/sheet/sheet-portal.svelte +7 -0
  485. package/src/shadcn/sheet/sheet-title.svelte +17 -0
  486. package/src/shadcn/sheet/sheet-trigger.svelte +7 -0
  487. package/src/shadcn/sheet/sheet.css +48 -0
  488. package/src/shadcn/sheet/sheet.svelte +7 -0
  489. package/src/shadcn/sidebar/constants.ts +6 -0
  490. package/src/shadcn/sidebar/context.svelte.ts +81 -0
  491. package/src/shadcn/sidebar/index.ts +75 -0
  492. package/src/shadcn/sidebar/sidebar-content.svelte +24 -0
  493. package/src/shadcn/sidebar/sidebar-footer.svelte +21 -0
  494. package/src/shadcn/sidebar/sidebar-group-action.svelte +33 -0
  495. package/src/shadcn/sidebar/sidebar-group-content.svelte +21 -0
  496. package/src/shadcn/sidebar/sidebar-group-label.svelte +33 -0
  497. package/src/shadcn/sidebar/sidebar-group.svelte +21 -0
  498. package/src/shadcn/sidebar/sidebar-header.svelte +21 -0
  499. package/src/shadcn/sidebar/sidebar-input.svelte +21 -0
  500. package/src/shadcn/sidebar/sidebar-inset.svelte +23 -0
  501. package/src/shadcn/sidebar/sidebar-menu-action.svelte +37 -0
  502. package/src/shadcn/sidebar/sidebar-menu-badge.svelte +24 -0
  503. package/src/shadcn/sidebar/sidebar-menu-button.svelte +103 -0
  504. package/src/shadcn/sidebar/sidebar-menu-item.svelte +21 -0
  505. package/src/shadcn/sidebar/sidebar-menu-skeleton.svelte +36 -0
  506. package/src/shadcn/sidebar/sidebar-menu-sub-button.svelte +39 -0
  507. package/src/shadcn/sidebar/sidebar-menu-sub-item.svelte +21 -0
  508. package/src/shadcn/sidebar/sidebar-menu-sub.svelte +24 -0
  509. package/src/shadcn/sidebar/sidebar-menu.svelte +21 -0
  510. package/src/shadcn/sidebar/sidebar-provider.svelte +62 -0
  511. package/src/shadcn/sidebar/sidebar-rail.svelte +36 -0
  512. package/src/shadcn/sidebar/sidebar-separator.svelte +19 -0
  513. package/src/shadcn/sidebar/sidebar-trigger.svelte +37 -0
  514. package/src/shadcn/sidebar/sidebar.svelte +109 -0
  515. package/src/shadcn/skeleton/index.ts +7 -0
  516. package/src/shadcn/skeleton/skeleton.svelte +17 -0
  517. package/src/shadcn/slider/index.ts +7 -0
  518. package/src/shadcn/slider/slider.svelte +52 -0
  519. package/src/shadcn/sonner/index.ts +1 -0
  520. package/src/shadcn/sonner/sonner.svelte +31 -0
  521. package/src/shadcn/spinner/index.ts +1 -0
  522. package/src/shadcn/spinner/spinner.svelte +26 -0
  523. package/src/shadcn/switch/index.ts +7 -0
  524. package/src/shadcn/switch/switch.svelte +31 -0
  525. package/src/shadcn/table/index.ts +28 -0
  526. package/src/shadcn/table/table-body.svelte +20 -0
  527. package/src/shadcn/table/table-caption.svelte +20 -0
  528. package/src/shadcn/table/table-cell.svelte +20 -0
  529. package/src/shadcn/table/table-footer.svelte +20 -0
  530. package/src/shadcn/table/table-head.svelte +23 -0
  531. package/src/shadcn/table/table-header.svelte +20 -0
  532. package/src/shadcn/table/table-row.svelte +23 -0
  533. package/src/shadcn/table/table.svelte +25 -0
  534. package/src/shadcn/tabs/index.ts +16 -0
  535. package/src/shadcn/tabs/tabs-content.svelte +17 -0
  536. package/src/shadcn/tabs/tabs-list.svelte +36 -0
  537. package/src/shadcn/tabs/tabs-trigger.svelte +20 -0
  538. package/src/shadcn/tabs/tabs.svelte +19 -0
  539. package/src/shadcn/textarea/index.ts +7 -0
  540. package/src/shadcn/textarea/textarea.svelte +23 -0
  541. package/src/shadcn/toggle/index.ts +13 -0
  542. package/src/shadcn/toggle/toggle.svelte +53 -0
  543. package/src/shadcn/toggle-group/index.ts +10 -0
  544. package/src/shadcn/toggle-group/toggle-group-item.svelte +35 -0
  545. package/src/shadcn/toggle-group/toggle-group.svelte +66 -0
  546. package/src/shadcn/tooltip/context.ts +16 -0
  547. package/src/shadcn/tooltip/index.ts +19 -0
  548. package/src/shadcn/tooltip/tooltip-content.svelte +38 -0
  549. package/src/shadcn/tooltip/tooltip-portal.svelte +7 -0
  550. package/src/shadcn/tooltip/tooltip-provider.svelte +16 -0
  551. package/src/shadcn/tooltip/tooltip-trigger.svelte +7 -0
  552. package/src/shadcn/tooltip/tooltip.svelte +19 -0
  553. package/src/shadcn/trace/index.ts +29 -0
  554. package/src/shadcn/trace/trace-collapsible-content.svelte +29 -0
  555. package/src/shadcn/trace/trace-collapsible-trigger.svelte +29 -0
  556. package/src/shadcn/trace/trace-collapsible.svelte +20 -0
  557. package/src/shadcn/trace/trace-description.svelte +20 -0
  558. package/src/shadcn/trace/trace-icon.svelte +24 -0
  559. package/src/shadcn/trace/trace-line.svelte +31 -0
  560. package/src/shadcn/trace/trace-title.svelte +20 -0
  561. package/src/shadcn/trace/trace.svelte +23 -0
  562. package/src/shadcn/utilities.css +549 -0
  563. package/src/test-setup.ts +34 -0
  564. package/src/tokens.css +993 -0
@@ -0,0 +1,160 @@
1
+ <script lang="ts">
2
+ // =========================
3
+ // IMPORTS
4
+ // =========================
5
+ import "./Marquee.css";
6
+ import { cn } from "@heyramzi/utils";
7
+ import type { Snippet } from "svelte";
8
+
9
+ // =========================
10
+ // TYPES
11
+ // =========================
12
+ interface MarqueeProps {
13
+ children: Snippet;
14
+ class?: string;
15
+ reverse?: boolean;
16
+ pauseOnHover?: boolean;
17
+ vertical?: boolean;
18
+ repeat?: number;
19
+ duration?: string;
20
+ gap?: string;
21
+ /** Scroll speed in px/s. Sets the loop time from the measured track, and wins over `duration`. */
22
+ speed?: number;
23
+ /** Fades both ends along the scroll axis. Any CSS length, such as `16px` or `13%`. */
24
+ fade?: string;
25
+ /** Waits this many ms before the first scroll starts. */
26
+ delay?: number;
27
+ /**
28
+ * Scrolls only while the content is longer than the box, for a line of text with a max width.
29
+ * The box shrinks to its content, drops its padding, and shows one still copy when it fits.
30
+ */
31
+ overflowOnly?: boolean;
32
+ style?: string;
33
+ }
34
+
35
+ // =========================
36
+ // PROPS
37
+ // =========================
38
+ let {
39
+ children,
40
+ class: className = "",
41
+ reverse = false,
42
+ pauseOnHover = false,
43
+ vertical = false,
44
+ repeat = 4,
45
+ duration,
46
+ gap,
47
+ speed,
48
+ fade,
49
+ delay,
50
+ overflowOnly = false,
51
+ style,
52
+ }: MarqueeProps = $props();
53
+
54
+ // =========================
55
+ // STATE
56
+ // =========================
57
+ let rootEl = $state<HTMLDivElement | null>(null);
58
+ let isVisible = $state(true);
59
+ let tabActive = $state(true);
60
+ let boxSize = $state(0);
61
+ let trackSize = $state(0);
62
+ let gapSize = $state(0);
63
+
64
+ // =========================
65
+ // DERIVED
66
+ // =========================
67
+ // WHY: pause the scroll whenever it can't be seen, so an offscreen or
68
+ // background-tab marquee stops burning paint/compositor budget.
69
+ let paused = $derived(!isVisible || !tabActive);
70
+
71
+ // WHY: the 0.5px slack absorbs the rounding between a fractional text width and its box.
72
+ let overflowing = $derived(trackSize > boxSize + 0.5);
73
+ let still = $derived(overflowOnly && !overflowing);
74
+ // WHY: two copies loop seamlessly once one copy is wider than the box.
75
+ let copies = $derived(overflowOnly ? (overflowing ? 2 : 1) : repeat);
76
+ let loopSeconds = $derived(
77
+ speed && trackSize > 0 ? (trackSize + gapSize) / speed : undefined,
78
+ );
79
+
80
+ // WHY: only emit the CSS vars that were passed as props, so a consumer can
81
+ // still override timing or spacing with a `[--duration:24s]` utility class.
82
+ let styleVars = $derived(
83
+ [
84
+ loopSeconds ? `--duration:${loopSeconds}s` : duration && `--duration:${duration}`,
85
+ gap && `--gap:${gap}`,
86
+ fade && `--marquee-fade:${fade}`,
87
+ delay && `--marquee-delay:${delay}ms`,
88
+ style,
89
+ ]
90
+ .filter(Boolean)
91
+ .join(";"),
92
+ );
93
+
94
+ // =========================
95
+ // EFFECTS
96
+ // =========================
97
+ $effect(() => {
98
+ if (!rootEl) return;
99
+ const observer = new IntersectionObserver(
100
+ ([entry]) => {
101
+ isVisible = entry.isIntersecting;
102
+ },
103
+ { threshold: 0 },
104
+ );
105
+ observer.observe(rootEl);
106
+ return () => observer.disconnect();
107
+ });
108
+
109
+ $effect(() => {
110
+ const firstTrack = rootEl?.firstElementChild;
111
+ if (!rootEl || !firstTrack || !(speed || overflowOnly)) return;
112
+ const root = rootEl;
113
+ const measure = () => {
114
+ const computed = getComputedStyle(root);
115
+ const box = root.getBoundingClientRect();
116
+ const track = firstTrack.getBoundingClientRect();
117
+ const padStart = parseFloat(vertical ? computed.paddingTop : computed.paddingLeft) || 0;
118
+ const padEnd = parseFloat(vertical ? computed.paddingBottom : computed.paddingRight) || 0;
119
+ boxSize = (vertical ? box.height : box.width) - padStart - padEnd;
120
+ trackSize = vertical ? track.height : track.width;
121
+ gapSize = parseFloat(vertical ? computed.rowGap : computed.columnGap) || 0;
122
+ };
123
+ measure();
124
+ const observer = new ResizeObserver(measure);
125
+ observer.observe(root);
126
+ observer.observe(firstTrack);
127
+ return () => observer.disconnect();
128
+ });
129
+
130
+ $effect(() => {
131
+ const onVisibility = () => {
132
+ tabActive = document.visibilityState === "visible";
133
+ };
134
+ document.addEventListener("visibilitychange", onVisibility);
135
+ return () => document.removeEventListener("visibilitychange", onVisibility);
136
+ });
137
+ </script>
138
+
139
+ <!-- =========================== -->
140
+ <!-- MARKUP -->
141
+ <!-- =========================== -->
142
+ <div
143
+ bind:this={rootEl}
144
+ class={cn("marquee", vertical && "marquee--vertical", className)}
145
+ style={styleVars}
146
+ data-pause-hover={pauseOnHover ? "" : undefined}
147
+ data-paused={paused ? "" : undefined}
148
+ data-overflow-only={overflowOnly ? "" : undefined}
149
+ data-still={still ? "" : undefined}
150
+ data-fade={fade && !still ? "" : undefined}
151
+ >
152
+ {#each Array(copies).fill(0) as _, i (i)}
153
+ <div
154
+ class={cn("marquee__track", reverse && "marquee__track--reverse")}
155
+ aria-hidden={i > 0 ? "true" : undefined}
156
+ >
157
+ {@render children?.()}
158
+ </div>
159
+ {/each}
160
+ </div>
@@ -0,0 +1,9 @@
1
+ .hr-progressive-blur {
2
+ position: relative;
3
+ pointer-events: none;
4
+ }
5
+ .hr-progressive-blur__layer {
6
+ position: absolute;
7
+ inset: 0;
8
+ border-radius: inherit;
9
+ }
@@ -0,0 +1,63 @@
1
+ <script lang="ts">
2
+ // =========================
3
+ // IMPORTS
4
+ // =========================
5
+ import "./ProgressiveBlur.css";
6
+ import { cn } from "@heyramzi/utils";
7
+
8
+ // =========================
9
+ // TYPES
10
+ // =========================
11
+ type Direction = "top" | "right" | "bottom" | "left";
12
+
13
+ interface ProgressiveBlurProps {
14
+ /** Edge the blur builds towards. Default `bottom`. */
15
+ direction?: Direction;
16
+ /** Stacked masked layers. More layers, smoother ramp, more compositing. */
17
+ layers?: number;
18
+ /** Blur added per layer, in px. */
19
+ intensity?: number;
20
+ class?: string;
21
+ }
22
+
23
+ // =========================
24
+ // CONSTANTS
25
+ // =========================
26
+ const ANGLES: Record<Direction, number> = { top: 0, right: 90, bottom: 180, left: 270 };
27
+
28
+ // =========================
29
+ // PROPS
30
+ // =========================
31
+ let {
32
+ direction = "bottom",
33
+ layers = 8,
34
+ intensity = 0.25,
35
+ class: className,
36
+ }: ProgressiveBlurProps = $props();
37
+
38
+ // =========================
39
+ // DERIVED
40
+ // =========================
41
+ // WHY: one uniform backdrop-filter banks up hard at its edge. Overlapping
42
+ // windowed masks, each blurred a little more, ramp it instead.
43
+ let steps = $derived(
44
+ Array.from({ length: Math.max(layers, 2) }, (_, i) => {
45
+ const size = 100 / (layers + 1);
46
+ const stops = [i, i + 1, i + 2, i + 3]
47
+ .map((n, at) => `rgb(255 255 255 / ${at === 1 || at === 2 ? 1 : 0}) ${n * size}%`)
48
+ .join(", ");
49
+ const mask = `linear-gradient(${ANGLES[direction]}deg, ${stops})`;
50
+ const blur = `blur(${i * intensity}px)`;
51
+ return `mask-image:${mask};-webkit-mask-image:${mask};backdrop-filter:${blur};-webkit-backdrop-filter:${blur}`;
52
+ }),
53
+ );
54
+ </script>
55
+
56
+ <!-- =========================== -->
57
+ <!-- MARKUP -->
58
+ <!-- =========================== -->
59
+ <div class={cn("hr-progressive-blur", className)} aria-hidden="true">
60
+ {#each steps as step, i (i)}
61
+ <div class="hr-progressive-blur__layer" style={step}></div>
62
+ {/each}
63
+ </div>
@@ -0,0 +1,101 @@
1
+ <script lang="ts">
2
+ // =========================
3
+ // IMPORTS
4
+ // =========================
5
+ import "./reveal.css";
6
+ import { cn } from "@heyramzi/utils";
7
+ import type { Snippet } from "svelte";
8
+ import { observeInView } from "./observe.js";
9
+ import type { RevealTiming, RevealViewOptions } from "./types.js";
10
+
11
+ // =========================
12
+ // TYPES
13
+ // =========================
14
+ interface AnimatedGroupProps extends RevealTiming, RevealViewOptions {
15
+ children: Snippet;
16
+ /** Tag to render. Default `div`. */
17
+ as?: string;
18
+ class?: string;
19
+ /** Play on mount instead of waiting for the group to scroll into view. */
20
+ onMount?: boolean;
21
+ }
22
+
23
+ // =========================
24
+ // PROPS
25
+ // =========================
26
+ let {
27
+ children,
28
+ as = "div",
29
+ class: className,
30
+ preset = "fade",
31
+ delay,
32
+ duration,
33
+ stagger,
34
+ once = true,
35
+ amount,
36
+ margin,
37
+ onMount = false,
38
+ }: AnimatedGroupProps = $props();
39
+
40
+ // =========================
41
+ // STATE
42
+ // =========================
43
+ let rootEl = $state<HTMLElement | null>(null);
44
+ let inView = $state(false);
45
+
46
+ // =========================
47
+ // DERIVED
48
+ // =========================
49
+ let styleVars = $derived(
50
+ [
51
+ delay !== undefined && `--hr-reveal-delay:${delay}ms`,
52
+ duration !== undefined && `--hr-reveal-duration:${duration}ms`,
53
+ stagger !== undefined && `--hr-reveal-stagger:${stagger}ms`,
54
+ ]
55
+ .filter(Boolean)
56
+ .join(";"),
57
+ );
58
+
59
+ // =========================
60
+ // EFFECTS
61
+ // =========================
62
+ // WHY: children arrive as an opaque snippet, so the stagger index is stamped on
63
+ // the rendered elements, and MutationObserver reindexes when `{#each}` changes.
64
+ $effect(() => {
65
+ if (!rootEl) return;
66
+ const el = rootEl;
67
+ const index = () => {
68
+ Array.from(el.children).forEach((child, i) => {
69
+ child.classList.add("hr-reveal__item");
70
+ (child as HTMLElement).style.setProperty("--i", String(i));
71
+ });
72
+ };
73
+ index();
74
+ const mutations = new MutationObserver(index);
75
+ mutations.observe(el, { childList: true });
76
+ return () => mutations.disconnect();
77
+ });
78
+
79
+ $effect(() => {
80
+ if (onMount) {
81
+ inView = true;
82
+ return;
83
+ }
84
+ if (!rootEl) return;
85
+ return observeInView(rootEl, { once, amount, margin }, (v) => (inView = v));
86
+ });
87
+ </script>
88
+
89
+ <!-- =========================== -->
90
+ <!-- MARKUP -->
91
+ <!-- =========================== -->
92
+ <svelte:element
93
+ this={as}
94
+ bind:this={rootEl}
95
+ class={cn("hr-reveal", className)}
96
+ style={styleVars}
97
+ data-preset={preset}
98
+ data-reveal={inView ? "in" : undefined}
99
+ >
100
+ {@render children()}
101
+ </svelte:element>
@@ -0,0 +1,77 @@
1
+ <script lang="ts">
2
+ // =========================
3
+ // IMPORTS
4
+ // =========================
5
+ import "./reveal.css";
6
+ import { cn } from "@heyramzi/utils";
7
+ import type { Snippet } from "svelte";
8
+ import { observeInView } from "./observe.js";
9
+ import type { RevealTiming, RevealViewOptions } from "./types.js";
10
+
11
+ // =========================
12
+ // TYPES
13
+ // =========================
14
+ interface InViewProps extends RevealTiming, RevealViewOptions {
15
+ children: Snippet<[boolean]>;
16
+ /** Tag to render. Default `div`. */
17
+ as?: string;
18
+ class?: string;
19
+ }
20
+
21
+ // =========================
22
+ // PROPS
23
+ // =========================
24
+ let {
25
+ children,
26
+ as = "div",
27
+ class: className,
28
+ preset = "fade",
29
+ delay,
30
+ duration,
31
+ once = true,
32
+ amount,
33
+ margin,
34
+ }: InViewProps = $props();
35
+
36
+ // =========================
37
+ // STATE
38
+ // =========================
39
+ let rootEl = $state<HTMLElement | null>(null);
40
+ let inView = $state(false);
41
+
42
+ // =========================
43
+ // DERIVED
44
+ // =========================
45
+ // WHY: emit only the props that were passed, so a `[--hr-reveal-blur:4px]`
46
+ // utility on the consumer's class still wins.
47
+ let styleVars = $derived(
48
+ [
49
+ delay !== undefined && `--hr-reveal-delay:${delay}ms`,
50
+ duration !== undefined && `--hr-reveal-duration:${duration}ms`,
51
+ ]
52
+ .filter(Boolean)
53
+ .join(";"),
54
+ );
55
+
56
+ // =========================
57
+ // EFFECTS
58
+ // =========================
59
+ $effect(() => {
60
+ if (!rootEl) return;
61
+ return observeInView(rootEl, { once, amount, margin }, (v) => (inView = v));
62
+ });
63
+ </script>
64
+
65
+ <!-- =========================== -->
66
+ <!-- MARKUP -->
67
+ <!-- =========================== -->
68
+ <svelte:element
69
+ this={as}
70
+ bind:this={rootEl}
71
+ class={cn("hr-reveal hr-reveal__item", className)}
72
+ style={styleVars}
73
+ data-preset={preset}
74
+ data-reveal={inView ? "in" : undefined}
75
+ >
76
+ {@render children(inView)}
77
+ </svelte:element>
@@ -0,0 +1,142 @@
1
+ <script lang="ts">
2
+ // =========================
3
+ // IMPORTS
4
+ // =========================
5
+ import "./reveal.css";
6
+ import { cn } from "@heyramzi/utils";
7
+ import { observeInView } from "./observe.js";
8
+ import type { RevealPer, RevealTiming, RevealViewOptions } from "./types.js";
9
+
10
+ // =========================
11
+ // TYPES
12
+ // =========================
13
+ interface TextEffectProps extends RevealTiming, RevealViewOptions {
14
+ /** The line to reveal. Plain text only; `\n` splits lines when `per="line"`. */
15
+ text: string;
16
+ /** What one staggered step is. Default `word`. */
17
+ per?: RevealPer;
18
+ /** Tag to render. Default `p`. */
19
+ as?: string;
20
+ class?: string;
21
+ /** Play on mount instead of waiting for the text to scroll into view. */
22
+ onMount?: boolean;
23
+ }
24
+
25
+ type Token =
26
+ | { kind: "plain"; text: string }
27
+ | { kind: "item"; text: string; i: number; block: boolean }
28
+ | { kind: "word"; chars: Array<{ text: string; i: number }> };
29
+
30
+ // =========================
31
+ // CONSTANTS
32
+ // =========================
33
+ const DEFAULT_STAGGER: Record<RevealPer, number> = { char: 25, word: 40, line: 80 };
34
+
35
+ // =========================
36
+ // PROPS
37
+ // =========================
38
+ let {
39
+ text,
40
+ per = "word",
41
+ as = "p",
42
+ class: className,
43
+ preset = "fade",
44
+ delay,
45
+ duration,
46
+ stagger,
47
+ once = true,
48
+ amount,
49
+ margin,
50
+ onMount = false,
51
+ }: TextEffectProps = $props();
52
+
53
+ // =========================
54
+ // STATE
55
+ // =========================
56
+ let rootEl = $state<HTMLElement | null>(null);
57
+ let inView = $state(false);
58
+
59
+ // =========================
60
+ // DERIVED
61
+ // =========================
62
+ let tokens = $derived(split(text, per));
63
+
64
+ let styleVars = $derived(
65
+ [
66
+ delay !== undefined && `--hr-reveal-delay:${delay}ms`,
67
+ duration !== undefined && `--hr-reveal-duration:${duration}ms`,
68
+ `--hr-reveal-stagger:${stagger ?? DEFAULT_STAGGER[per]}ms`,
69
+ ]
70
+ .filter(Boolean)
71
+ .join(";"),
72
+ );
73
+
74
+ // =========================
75
+ // FUNCTIONS
76
+ // =========================
77
+ function split(value: string, mode: RevealPer): Token[] {
78
+ if (mode === "line") {
79
+ return value.split("\n").map((line, i) => ({ kind: "item", text: line, i, block: true }));
80
+ }
81
+
82
+ // WHY: the capturing split keeps the whitespace runs as their own pieces, so
83
+ // spacing survives without any piece being animated.
84
+ let i = 0;
85
+ return value.split(/(\s+)/).flatMap<Token>((piece) => {
86
+ if (piece === "") return [];
87
+ if (/^\s+$/.test(piece)) return [{ kind: "plain", text: piece }];
88
+ if (mode === "word") return [{ kind: "item", text: piece, i: i++, block: false }];
89
+ return [{ kind: "word", chars: Array.from(piece).map((c) => ({ text: c, i: i++ })) }];
90
+ });
91
+ }
92
+
93
+ // =========================
94
+ // EFFECTS
95
+ // =========================
96
+ $effect(() => {
97
+ if (onMount) {
98
+ inView = true;
99
+ return;
100
+ }
101
+ if (!rootEl) return;
102
+ return observeInView(rootEl, { once, amount, margin }, (v) => (inView = v));
103
+ });
104
+ </script>
105
+
106
+ <!-- =========================== -->
107
+ <!-- MARKUP -->
108
+ <!-- =========================== -->
109
+ <svelte:element
110
+ this={as}
111
+ bind:this={rootEl}
112
+ class={cn("hr-reveal", className)}
113
+ style={styleVars}
114
+ data-preset={preset}
115
+ data-reveal={inView ? "in" : undefined}
116
+ >
117
+ {#if per !== "line"}
118
+ <!-- The split spans are decorative; a screen reader gets the whole line once. -->
119
+ <span class="hr-reveal__sr">{text}</span>
120
+ {/if}
121
+ {#each tokens as token, t (t)}
122
+ {#if token.kind === "plain"}
123
+ <span class="hr-reveal__segment">{token.text}</span>
124
+ {:else if token.kind === "item"}
125
+ <span
126
+ aria-hidden={per === "line" ? undefined : "true"}
127
+ class={cn(
128
+ "hr-reveal__segment",
129
+ token.block && "hr-reveal__segment--line",
130
+ "hr-reveal__item",
131
+ )}
132
+ style="--i:{token.i}">{token.text}</span
133
+ >
134
+ {:else}<span class="hr-reveal__segment" aria-hidden="true"
135
+ >{#each token.chars as char, c (c)}<span
136
+ class="hr-reveal__segment hr-reveal__item"
137
+ style="--i:{char.i}">{char.text}</span
138
+ >{/each}</span
139
+ >
140
+ {/if}
141
+ {/each}
142
+ </svelte:element>
@@ -0,0 +1,11 @@
1
+ export { default as InView } from "./InView.svelte";
2
+ export { default as AnimatedGroup } from "./AnimatedGroup.svelte";
3
+ export { default as TextEffect } from "./TextEffect.svelte";
4
+ export { observeInView, onInView } from "./observe.js";
5
+ export type {
6
+ RevealPreset,
7
+ RevealPer,
8
+ RevealTiming,
9
+ RevealViewOptions,
10
+ InViewActionOptions,
11
+ } from "./types.js";
@@ -0,0 +1,60 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
2
+ import { onInView } from "./observe.js";
3
+
4
+ type Callback = (entries: { isIntersecting: boolean }[]) => void;
5
+
6
+ let callbacks: Callback[] = [];
7
+
8
+ class FakeObserver {
9
+ constructor(callback: Callback) {
10
+ callbacks.push(callback);
11
+ }
12
+ observe() {}
13
+ disconnect() {}
14
+ }
15
+
16
+ function fire(isIntersecting: boolean) {
17
+ for (const callback of callbacks) callback([{ isIntersecting }]);
18
+ }
19
+
20
+ describe("onInView", () => {
21
+ beforeEach(() => {
22
+ callbacks = [];
23
+ vi.stubGlobal("IntersectionObserver", FakeObserver);
24
+ });
25
+
26
+ afterEach(() => {
27
+ vi.unstubAllGlobals();
28
+ });
29
+
30
+ it("calls onEnter once when the node first shows", () => {
31
+ const onEnter = vi.fn();
32
+ onInView(document.createElement("div"), { onEnter });
33
+ fire(true);
34
+ fire(true);
35
+ expect(onEnter).toHaveBeenCalledTimes(1);
36
+ });
37
+
38
+ it("calls onLeave only after an enter, and only when once is off", () => {
39
+ const onEnter = vi.fn();
40
+ const onLeave = vi.fn();
41
+ onInView(document.createElement("div"), { once: false, onEnter, onLeave });
42
+ fire(false);
43
+ expect(onLeave).not.toHaveBeenCalled();
44
+ fire(true);
45
+ fire(false);
46
+ fire(true);
47
+ expect(onEnter).toHaveBeenCalledTimes(2);
48
+ expect(onLeave).toHaveBeenCalledTimes(1);
49
+ });
50
+
51
+ it("reads the callbacks from the latest update", () => {
52
+ const first = vi.fn();
53
+ const second = vi.fn();
54
+ const action = onInView(document.createElement("div"), { onEnter: first });
55
+ action?.update?.({ onEnter: second });
56
+ fire(true);
57
+ expect(first).not.toHaveBeenCalled();
58
+ expect(second).toHaveBeenCalledTimes(1);
59
+ });
60
+ });
@@ -0,0 +1,65 @@
1
+ import type { Action } from "svelte/action";
2
+ import type { InViewActionOptions, RevealViewOptions } from "./types.js";
3
+
4
+ /**
5
+ * Runs `onChange` when `el` enters or leaves the viewport. Returns the teardown.
6
+ * Shared by InView, AnimatedGroup and TextEffect so there is one observer contract.
7
+ */
8
+ export function observeInView(
9
+ el: Element,
10
+ options: RevealViewOptions,
11
+ onChange: (inView: boolean) => void,
12
+ ): () => void {
13
+ // WHY: no IntersectionObserver means SSR or an ancient engine; reveal the
14
+ // content rather than leaving it stuck at the hidden keyframe.
15
+ if (typeof IntersectionObserver === "undefined") {
16
+ onChange(true);
17
+ return () => {};
18
+ }
19
+
20
+ const observer = new IntersectionObserver(
21
+ ([entry]) => {
22
+ if (entry.isIntersecting) {
23
+ onChange(true);
24
+ if (options.once !== false) observer.disconnect();
25
+ return;
26
+ }
27
+ if (options.once === false) onChange(false);
28
+ },
29
+ { threshold: options.amount ?? 0, rootMargin: options.margin ?? "0px" },
30
+ );
31
+
32
+ observer.observe(el);
33
+ return () => observer.disconnect();
34
+ }
35
+
36
+ /**
37
+ * Svelte action that calls back when the node enters or leaves the viewport.
38
+ * Options are read at call time, so a `use:onInView={...}` update swaps the callbacks.
39
+ *
40
+ * @example
41
+ * <section use:onInView={{ amount: 0.2, onEnter: () => (visible = true) }}>
42
+ */
43
+ export const onInView: Action<HTMLElement, InViewActionOptions | undefined> = (node, initial) => {
44
+ let options = initial ?? {};
45
+ let entered = false;
46
+
47
+ const { amount = 0.1, margin, once } = options;
48
+
49
+ const stop = observeInView(node, { amount, margin, once }, (inView) => {
50
+ if (inView && !entered) {
51
+ entered = true;
52
+ options.onEnter?.();
53
+ } else if (!inView && entered) {
54
+ entered = false;
55
+ options.onLeave?.();
56
+ }
57
+ });
58
+
59
+ return {
60
+ update(next) {
61
+ options = next ?? {};
62
+ },
63
+ destroy: stop,
64
+ };
65
+ };