fancy-ui-vue 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/PORTING.md +123 -2
  2. package/README.md +40 -13
  3. package/dist/components/accordion/Accordion.vue.d.ts +44 -0
  4. package/dist/components/accordion/Accordion.vue.js +88 -0
  5. package/dist/components/accordion/Accordion.vue2.js +4 -0
  6. package/dist/components/accordion/AccordionContent.vue.d.ts +25 -0
  7. package/dist/components/accordion/AccordionContent.vue.js +42 -0
  8. package/dist/components/accordion/AccordionContent.vue2.js +4 -0
  9. package/dist/components/accordion/AccordionItem.vue.d.ts +21 -0
  10. package/dist/components/accordion/AccordionItem.vue.js +66 -0
  11. package/dist/components/accordion/AccordionItem.vue2.js +4 -0
  12. package/dist/components/accordion/AccordionTrigger.vue.d.ts +24 -0
  13. package/dist/components/accordion/AccordionTrigger.vue.js +83 -0
  14. package/dist/components/accordion/AccordionTrigger.vue2.js +4 -0
  15. package/dist/components/accordion/accordion-core.d.ts +35 -0
  16. package/dist/components/accordion/accordion-core.js +44 -0
  17. package/dist/components/accordion/index.d.ts +11 -0
  18. package/dist/components/accordion/types.d.ts +45 -0
  19. package/dist/components/accordion/types.js +7 -0
  20. package/dist/components/alert-dialog/AlertDialog.vue.js +22 -3
  21. package/dist/components/animated-testimonials/AnimatedTestimonials.vue.js +3 -3
  22. package/dist/components/apple-card-carousel/AppleCard.vue.js +1 -1
  23. package/dist/components/autocomplete/Autocomplete.vue.js +1 -1
  24. package/dist/components/autocomplete/Autocomplete.vue2.js +22 -15
  25. package/dist/components/avatar/Avatar.vue.d.ts +27 -0
  26. package/dist/components/avatar/Avatar.vue.js +119 -0
  27. package/dist/components/avatar/Avatar.vue2.js +4 -0
  28. package/dist/components/avatar/avatar-core.d.ts +40 -0
  29. package/dist/components/avatar/avatar-core.js +57 -0
  30. package/dist/components/avatar/index.d.ts +2 -0
  31. package/dist/components/badge/Badge.vue.d.ts +21 -0
  32. package/dist/components/badge/Badge.vue.js +46 -0
  33. package/dist/components/badge/Badge.vue2.js +4 -0
  34. package/dist/components/badge/index.d.ts +2 -0
  35. package/dist/components/bento-grid/BentoFrame.vue.js +1 -1
  36. package/dist/components/bento-grid/BentoFrame.vue2.js +6 -5
  37. package/dist/components/bento-grid/BentoGrid.vue.js +1 -1
  38. package/dist/components/bento-grid/BentoGrid.vue2.js +12 -12
  39. package/dist/components/bento-grid/BentoGridCard.vue.js +6 -5
  40. package/dist/components/bento-grid/BentoGridItem.vue.js +6 -5
  41. package/dist/components/bg-falling-stars/FallingStarsBg.vue.d.ts +1 -1
  42. package/dist/components/bg-falling-stars/FallingStarsBg.vue.js +1 -1
  43. package/dist/components/bg-falling-stars/bg-falling-stars-core.d.ts +1 -1
  44. package/dist/components/bg-falling-stars/bg-falling-stars-core.js +47 -12
  45. package/dist/components/book/Book.vue.js +8 -9
  46. package/dist/components/book/BookDescription.vue.js +6 -5
  47. package/dist/components/book/BookHeader.vue.js +6 -5
  48. package/dist/components/book/BookTitle.vue.js +6 -5
  49. package/dist/components/box-reveal/BoxReveal.vue.js +6 -5
  50. package/dist/components/button/Button.vue.d.ts +6 -4
  51. package/dist/components/button/Button.vue.js +1 -1
  52. package/dist/components/button/Button.vue2.js +50 -22
  53. package/dist/components/card-3d/CardContainer.vue.js +1 -1
  54. package/dist/components/card-3d/CardItem.vue.js +1 -1
  55. package/dist/components/card-spotlight/CardSpotlight.vue.js +1 -1
  56. package/dist/components/chat-message/ChatMessageAction.vue.d.ts +4 -2
  57. package/dist/components/chat-message/ChatMessageAction.vue.js +4 -2
  58. package/dist/components/checkbox/Checkbox.vue.d.ts +2 -0
  59. package/dist/components/checkbox/Checkbox.vue.js +1 -1
  60. package/dist/components/checkbox/Checkbox.vue2.js +17 -7
  61. package/dist/components/collapsible/Collapsible.vue.d.ts +31 -0
  62. package/dist/components/collapsible/Collapsible.vue.js +60 -0
  63. package/dist/components/collapsible/Collapsible.vue2.js +4 -0
  64. package/dist/components/collapsible/CollapsibleContent.vue.d.ts +26 -0
  65. package/dist/components/collapsible/CollapsibleContent.vue.js +81 -0
  66. package/dist/components/collapsible/CollapsibleContent.vue2.js +4 -0
  67. package/dist/components/collapsible/CollapsibleTrigger.vue.d.ts +21 -0
  68. package/dist/components/collapsible/CollapsibleTrigger.vue.js +57 -0
  69. package/dist/components/collapsible/CollapsibleTrigger.vue2.js +4 -0
  70. package/dist/components/collapsible/collapsible-core.d.ts +47 -0
  71. package/dist/components/collapsible/collapsible-core.js +40 -0
  72. package/dist/components/collapsible/index.d.ts +8 -0
  73. package/dist/components/collapsible/types.d.ts +24 -0
  74. package/dist/components/collapsible/types.js +5 -0
  75. package/dist/components/combobox/Combobox.vue.js +1 -1
  76. package/dist/components/combobox/Combobox.vue2.js +24 -16
  77. package/dist/components/command-menu/CommandMenu.vue.d.ts +5 -0
  78. package/dist/components/command-menu/CommandMenu.vue.js +1 -1
  79. package/dist/components/command-menu/CommandMenu.vue2.js +5 -2
  80. package/dist/components/compare/Compare.vue.d.ts +15 -5
  81. package/dist/components/compare/Compare.vue.js +1 -1
  82. package/dist/components/compare/Compare.vue2.js +28 -13
  83. package/dist/components/composer/ComposerInput.vue.js +1 -1
  84. package/dist/components/composer/ComposerInput.vue2.js +11 -11
  85. package/dist/components/composer/ComposerModelPicker.vue.d.ts +4 -0
  86. package/dist/components/composer/ComposerModelPicker.vue.js +1 -1
  87. package/dist/components/composer/ComposerModelPicker.vue2.js +29 -15
  88. package/dist/components/composer/ComposerSubmit.vue.d.ts +2 -0
  89. package/dist/components/composer/ComposerSubmit.vue.js +16 -15
  90. package/dist/components/confetti/ConfettiButton.vue.d.ts +9 -2
  91. package/dist/components/confetti/ConfettiButton.vue.js +24 -6
  92. package/dist/components/container-text-flip/ContainerTextFlip.vue.js +1 -1
  93. package/dist/components/container-text-flip/ContainerTextFlip.vue2.js +12 -13
  94. package/dist/components/copy-button/CopyButton.vue.d.ts +5 -0
  95. package/dist/components/copy-button/CopyButton.vue.js +1 -1
  96. package/dist/components/copy-button/CopyButton.vue2.js +72 -11
  97. package/dist/components/datamosh-transition/DatamoshTransition.vue.d.ts +6 -2
  98. package/dist/components/datamosh-transition/DatamoshTransition.vue.js +7 -4
  99. package/dist/components/date-picker/DatePicker.vue.js +1 -1
  100. package/dist/components/date-picker/DatePicker.vue2.js +27 -21
  101. package/dist/components/dialog/Dialog.vue.js +20 -1
  102. package/dist/components/dialog/DialogSurface.vue.js +1 -1
  103. package/dist/components/dialog/DialogSurface.vue2.js +5 -2
  104. package/dist/components/dialog/types.d.ts +2 -0
  105. package/dist/components/direction-aware-hover/DirectionAwareHover.vue.js +1 -1
  106. package/dist/components/direction-aware-hover/DirectionAwareHover.vue2.js +9 -7
  107. package/dist/components/displacement-text/DisplacementText.vue.d.ts +4 -1
  108. package/dist/components/displacement-text/DisplacementText.vue.js +38 -11
  109. package/dist/components/displacement-text/displacement-text-core.d.ts +94 -4
  110. package/dist/components/displacement-text/displacement-text-core.js +287 -97
  111. package/dist/components/drawer/Drawer.vue.d.ts +5 -0
  112. package/dist/components/drawer/Drawer.vue.js +1 -1
  113. package/dist/components/drawer/Drawer.vue2.js +5 -2
  114. package/dist/components/dropdown-menu/DropdownMenuContent.vue.js +2 -1
  115. package/dist/components/dropdown-menu/DropdownMenuItem.vue.d.ts +4 -0
  116. package/dist/components/dropdown-menu/DropdownMenuItem.vue.js +17 -10
  117. package/dist/components/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +8 -0
  118. package/dist/components/dropdown-menu/DropdownMenuSubTrigger.vue.js +28 -13
  119. package/dist/components/dropdown-menu/DropdownMenuTrigger.vue.d.ts +4 -0
  120. package/dist/components/dropdown-menu/DropdownMenuTrigger.vue.js +1 -1
  121. package/dist/components/dropdown-menu/DropdownMenuTrigger.vue2.js +20 -10
  122. package/dist/components/editorial-engine/EditorialEngine.vue.js +1 -1
  123. package/dist/components/editorial-engine/engine.js +13 -0
  124. package/dist/components/file-upload/FileUpload.vue.d.ts +2 -0
  125. package/dist/components/file-upload/FileUpload.vue.js +1 -1
  126. package/dist/components/file-upload/FileUpload.vue2.js +20 -10
  127. package/dist/components/fireworks-hdr/FireworksHdr.vue.js +2 -2
  128. package/dist/components/flickering-grid/FlickeringGrid.vue.d.ts +1 -1
  129. package/dist/components/flickering-grid/FlickeringGrid.vue.js +1 -1
  130. package/dist/components/flickering-grid/flickering-grid-core.d.ts +1 -1
  131. package/dist/components/flickering-grid/flickering-grid-core.js +51 -9
  132. package/dist/components/flip-card/FlipCard.vue.d.ts +3 -1
  133. package/dist/components/flip-card/FlipCard.vue.js +1 -1
  134. package/dist/components/flip-card/FlipCard.vue2.js +5 -3
  135. package/dist/components/fluid-cursor/FluidCursor.vue.js +37 -9
  136. package/dist/components/fluid-cursor/fluid-cursor-core.js +3 -3
  137. package/dist/components/fluid-cursor/webgpu-engine.js +3 -3
  138. package/dist/components/focus/Focus.vue.js +1 -1
  139. package/dist/components/focus/Focus.vue2.js +2 -2
  140. package/dist/components/follow-button/FollowButton.vue.d.ts +69 -0
  141. package/dist/components/follow-button/FollowButton.vue.js +7 -0
  142. package/dist/components/follow-button/FollowButton.vue2.js +239 -0
  143. package/dist/components/follow-button/follow-core.d.ts +83 -0
  144. package/dist/components/follow-button/follow-core.js +92 -0
  145. package/dist/components/follow-button/index.d.ts +2 -0
  146. package/dist/components/frosted-glass/FrostedGlass.vue.js +1 -1
  147. package/dist/components/glare-card/GlareCard.vue.js +1 -1
  148. package/dist/components/glare-card/GlareCard.vue2.js +4 -4
  149. package/dist/components/glowing-effect/GlowingEffect.vue.js +3 -3
  150. package/dist/components/glowing-effect/glowing-effect-core.js +4 -1
  151. package/dist/components/gradient-button/GradientButton.vue.d.ts +6 -4
  152. package/dist/components/gradient-button/GradientButton.vue.js +1 -1
  153. package/dist/components/gradient-button/GradientButton.vue2.js +13 -3
  154. package/dist/components/icon-button/IconButton.vue.d.ts +6 -4
  155. package/dist/components/icon-button/IconButton.vue.js +11 -8
  156. package/dist/components/image-trail-cursor/ImageTrailCursor.vue.js +17 -7
  157. package/dist/components/image-trail-cursor/trail-variants.js +3 -6
  158. package/dist/components/inline-citation/InlineCitation.vue.js +1 -1
  159. package/dist/components/inline-citation/InlineCitation.vue2.js +20 -14
  160. package/dist/components/input/Input.vue.js +1 -1
  161. package/dist/components/input/Input.vue2.js +18 -8
  162. package/dist/components/interactive-grid-pattern/InteractiveGridPattern.vue.js +1 -1
  163. package/dist/components/interactive-grid-pattern/InteractiveGridPattern.vue2.js +1 -1
  164. package/dist/components/interactive-hover-button/InteractiveHoverButton.vue.d.ts +6 -3
  165. package/dist/components/interactive-hover-button/InteractiveHoverButton.vue.js +1 -1
  166. package/dist/components/interactive-hover-button/InteractiveHoverButton.vue2.js +12 -2
  167. package/dist/components/letter-pullup/LetterPullup.vue.js +4 -4
  168. package/dist/components/line-hover-link/LineHoverLink.vue.js +1 -1
  169. package/dist/components/line-hover-link/LineHoverLink.vue2.js +5 -6
  170. package/dist/components/link/Link.vue.d.ts +4 -2
  171. package/dist/components/link/Link.vue.js +1 -1
  172. package/dist/components/link/Link.vue2.js +11 -8
  173. package/dist/components/mosaic-glow/MosaicGlow.vue.d.ts +6 -0
  174. package/dist/components/mosaic-glow/MosaicGlow.vue.js +53 -9
  175. package/dist/components/mosaic-glow/mosaic-glow-core.d.ts +30 -0
  176. package/dist/components/mosaic-glow/mosaic-glow-core.js +27 -0
  177. package/dist/components/mosaic-glow/mosaic-glow-hdr.d.ts +24 -0
  178. package/dist/components/mosaic-glow/mosaic-glow-hdr.js +200 -0
  179. package/dist/components/navbar/NavbarLink.vue.d.ts +4 -2
  180. package/dist/components/navbar/NavbarLink.vue.js +1 -1
  181. package/dist/components/navbar/NavbarLink.vue2.js +16 -13
  182. package/dist/components/navigation-menu/NavigationMenu.vue.js +6 -3
  183. package/dist/components/navigation-menu/NavigationMenuLink.vue.js +1 -1
  184. package/dist/components/navigation-menu/NavigationMenuLink.vue2.js +8 -8
  185. package/dist/components/navigation-menu/NavigationMenuTrigger.vue.d.ts +15 -0
  186. package/dist/components/navigation-menu/NavigationMenuTrigger.vue.js +1 -1
  187. package/dist/components/navigation-menu/NavigationMenuTrigger.vue2.js +36 -15
  188. package/dist/components/neon-border/NeonBorder.vue.js +1 -1
  189. package/dist/components/neon-border/NeonBorder.vue2.js +10 -11
  190. package/dist/components/number-input/NumberInput.vue.js +1 -1
  191. package/dist/components/number-input/NumberInput.vue2.js +22 -12
  192. package/dist/components/password-input/PasswordInput.vue.js +1 -1
  193. package/dist/components/password-input/PasswordInput.vue2.js +18 -11
  194. package/dist/components/pixel-loader/PixelLoader.vue.js +1 -1
  195. package/dist/components/pixel-loader/PixelLoader.vue2.js +6 -6
  196. package/dist/components/popover/Popover.vue.d.ts +4 -0
  197. package/dist/components/popover/Popover.vue.js +1 -1
  198. package/dist/components/popover/Popover.vue2.js +8 -6
  199. package/dist/components/popover/PopoverContent.vue.js +6 -2
  200. package/dist/components/pulse-beam/PulseBeam.vue.d.ts +6 -2
  201. package/dist/components/pulse-beam/PulseBeam.vue.js +1 -1
  202. package/dist/components/pulse-beam/PulseBeam.vue2.js +7 -4
  203. package/dist/components/radio-group/RadioGroup.vue.js +12 -11
  204. package/dist/components/radio-group/RadioGroupItem.vue.d.ts +2 -0
  205. package/dist/components/radio-group/RadioGroupItem.vue.js +1 -1
  206. package/dist/components/radio-group/RadioGroupItem.vue2.js +20 -7
  207. package/dist/components/rainbow-button/RainbowButton.vue.d.ts +11 -2
  208. package/dist/components/rainbow-button/RainbowButton.vue.js +1 -1
  209. package/dist/components/rainbow-button/RainbowButton.vue2.js +35 -18
  210. package/dist/components/ripple-button/RippleButton.vue.d.ts +6 -4
  211. package/dist/components/ripple-button/RippleButton.vue.js +1 -1
  212. package/dist/components/ripple-button/RippleButton.vue2.js +10 -5
  213. package/dist/components/search-input/SearchInput.vue.js +1 -1
  214. package/dist/components/search-input/SearchInput.vue2.js +19 -9
  215. package/dist/components/select/Select.vue.d.ts +1 -1
  216. package/dist/components/select/Select.vue.js +1 -1
  217. package/dist/components/select/Select.vue2.js +25 -17
  218. package/dist/components/sheet/Sheet.vue.d.ts +5 -0
  219. package/dist/components/sheet/Sheet.vue.js +5 -2
  220. package/dist/components/shimmer-button/ShimmerButton.vue.d.ts +2 -2
  221. package/dist/components/shimmer-button/ShimmerButton.vue.js +1 -1
  222. package/dist/components/shimmer-button/ShimmerButton.vue2.js +14 -6
  223. package/dist/components/sidebar/SidebarItem.vue.d.ts +4 -2
  224. package/dist/components/sidebar/SidebarItem.vue.js +1 -1
  225. package/dist/components/sidebar/SidebarItem.vue2.js +4 -2
  226. package/dist/components/slider/Slider.vue.d.ts +4 -0
  227. package/dist/components/slider/Slider.vue.js +1 -1
  228. package/dist/components/slider/Slider.vue2.js +20 -8
  229. package/dist/components/sources/SourcesTrigger.vue.js +1 -1
  230. package/dist/components/sources/SourcesTrigger.vue2.js +11 -11
  231. package/dist/components/sparkles/sparkles-core.d.ts +1 -1
  232. package/dist/components/sparkles/sparkles-core.js +36 -2
  233. package/dist/components/switch/Switch.vue.d.ts +2 -0
  234. package/dist/components/switch/Switch.vue.js +1 -1
  235. package/dist/components/switch/Switch.vue2.js +16 -6
  236. package/dist/components/tabs/TabsTrigger.vue.d.ts +6 -0
  237. package/dist/components/tabs/TabsTrigger.vue.js +1 -1
  238. package/dist/components/tabs/TabsTrigger.vue2.js +28 -15
  239. package/dist/components/terminal-block/TerminalBlock.vue.js +1 -1
  240. package/dist/components/terminal-block/TerminalBlock.vue2.js +10 -9
  241. package/dist/components/text-reveal-card/TextRevealCard.vue.js +1 -2
  242. package/dist/components/textarea/Textarea.vue.js +1 -1
  243. package/dist/components/textarea/Textarea.vue2.js +19 -12
  244. package/dist/components/tick-nav/TickNav.vue.d.ts +71 -0
  245. package/dist/components/tick-nav/TickNav.vue.js +7 -0
  246. package/dist/components/tick-nav/TickNav.vue2.js +285 -0
  247. package/dist/components/tick-nav/index.d.ts +3 -0
  248. package/dist/components/tick-nav/tick-nav-core.d.ts +102 -0
  249. package/dist/components/tick-nav/tick-nav-core.js +398 -0
  250. package/dist/components/tick-nav/tick-nav-hdr.d.ts +60 -0
  251. package/dist/components/tick-nav/tick-nav-hdr.js +284 -0
  252. package/dist/components/tick-nav/types.d.ts +13 -0
  253. package/dist/components/time-picker/TimePicker.vue.js +1 -1
  254. package/dist/components/time-picker/TimePicker.vue2.js +25 -17
  255. package/dist/components/toast/Toast.vue.js +1 -1
  256. package/dist/components/toast/Toast.vue2.js +16 -4
  257. package/dist/components/toast/index.d.ts +1 -1
  258. package/dist/components/toast/store.d.ts +23 -0
  259. package/dist/components/toast/store.js +35 -7
  260. package/dist/components/toggle/Toggle.vue.d.ts +12 -0
  261. package/dist/components/toggle/Toggle.vue.js +1 -1
  262. package/dist/components/toggle/Toggle.vue2.js +27 -11
  263. package/dist/components/toggle-group/ToggleGroup.vue.d.ts +11 -0
  264. package/dist/components/toggle-group/ToggleGroup.vue.js +1 -1
  265. package/dist/components/toggle-group/ToggleGroup.vue2.js +16 -3
  266. package/dist/components/toggle-group/ToggleGroupItem.vue.d.ts +6 -0
  267. package/dist/components/toggle-group/ToggleGroupItem.vue.js +1 -1
  268. package/dist/components/toggle-group/ToggleGroupItem.vue2.js +27 -14
  269. package/dist/components/tooltip/Tooltip.vue.js +13 -0
  270. package/dist/components/typing-indicator/TypingIndicator.vue.js +1 -1
  271. package/dist/components/typing-indicator/TypingIndicator.vue2.js +7 -6
  272. package/dist/index.d.ts +6 -0
  273. package/dist/index.js +440 -413
  274. package/dist/internals/anchor-position.js +3 -0
  275. package/dist/internals/call-listener.d.ts +11 -0
  276. package/dist/internals/call-listener.js +31 -0
  277. package/dist/internals/dismissable.d.ts +17 -0
  278. package/dist/internals/dismissable.js +44 -1
  279. package/dist/internals/env.d.ts +1 -0
  280. package/dist/internals/env.js +11 -0
  281. package/dist/internals/focus-trap.js +29 -4
  282. package/dist/internals/merge-ids.d.ts +6 -0
  283. package/dist/internals/merge-ids.js +11 -0
  284. package/dist/internals/motion/presence-core.d.ts +1 -1
  285. package/dist/sound/engine.js +23 -9
  286. package/dist/sound/themes.d.ts +4 -3
  287. package/dist/sound/themes.js +49 -211
  288. package/dist/sound/types.d.ts +9 -1
  289. package/dist/sound/types.js +2 -2
  290. package/dist/styles.css +974 -571
  291. package/package.json +2 -2
  292. package/tailwind.css +9 -9
@@ -2,7 +2,7 @@ import _sfc_main from "./FlipCard.vue2.js";
2
2
  import { flipDirection, showsBack } from "./FlipCard.vue2.js";
3
3
  /* empty css */
4
4
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
5
- const FlipCard = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2aa473c3"]]);
5
+ const FlipCard = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-72cdc6c1"]]);
6
6
  export {
7
7
  FlipCard as default,
8
8
  flipDirection,
@@ -1,4 +1,5 @@
1
1
  import { defineComponent, mergeModels, useModel, ref, computed, useTemplateRef, watch, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createElementVNode, renderSlot, createCommentVNode } from "vue";
2
+ import { callListener } from "../../internals/call-listener.js";
2
3
  import { cn } from "../../utils.js";
3
4
  import { useReducedMotion } from "../../internals/motion/use-media-query.js";
4
5
  const _hoisted_1 = ["data-axis", "data-flipped", "data-trigger", "role", "aria-pressed", "aria-label"];
@@ -31,7 +32,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
31
32
  rotate: { default: "y" },
32
33
  trigger: { default: "hover" },
33
34
  flipped: { type: Boolean },
34
- onflip: { type: Function },
35
+ onFlip: { type: [Function, Array] },
36
+ onflip: { type: [Function, Array] },
35
37
  duration: { default: 700 },
36
38
  glare: { type: Boolean, default: true },
37
39
  label: {},
@@ -53,7 +55,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
53
55
  angle.value += 180 * direction;
54
56
  const next = showsBack(angle.value);
55
57
  flipped.value = next;
56
- __props.onflip?.(next);
58
+ callListener(__props.onFlip ?? __props.onflip, next);
57
59
  lift();
58
60
  }
59
61
  function lift() {
@@ -86,7 +88,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
86
88
  (want) => {
87
89
  if (want !== showsBack(angle.value)) {
88
90
  angle.value += 180;
89
- __props.onflip?.(want);
91
+ callListener(__props.onFlip ?? __props.onflip, want);
90
92
  lift();
91
93
  }
92
94
  },
@@ -1,5 +1,7 @@
1
- import { defineComponent, useTemplateRef, onMounted, onBeforeUnmount, watch, createElementBlock, openBlock, normalizeClass, unref, createElementVNode } from "vue";
1
+ import { defineComponent, useTemplateRef, onMounted, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref } from "vue";
2
+ import { createReducedMotion } from "../../internals/motion/media-query.js";
2
3
  import { cn } from "../../utils.js";
4
+ import { isDev } from "../../internals/env.js";
3
5
  import { createFluidCursor } from "./fluid-cursor-core.js";
4
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
7
  ...{ name: "FluidCursor", inheritAttrs: false },
@@ -38,12 +40,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
38
40
  onReady: { type: Function }
39
41
  },
40
42
  setup(__props) {
41
- const DEV = false;
42
43
  const canvasRef = useTemplateRef("canvas");
43
44
  let engine = null;
44
- onMounted(() => {
45
+ const reducedMotion = createReducedMotion();
46
+ let stopReducedMotion = null;
47
+ let engineCanvas = null;
48
+ function stopEngine() {
49
+ engine?.destroy();
50
+ engine = null;
51
+ engineCanvas = null;
52
+ }
53
+ function syncEngine() {
45
54
  const canvas = canvasRef.value;
46
- if (!canvas) return;
55
+ if (reducedMotion.current || !canvas) {
56
+ stopEngine();
57
+ return;
58
+ }
59
+ if (engine && engineCanvas === canvas) return;
60
+ stopEngine();
61
+ engineCanvas = canvas;
47
62
  engine = createFluidCursor(
48
63
  { canvas },
49
64
  {
@@ -77,13 +92,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
77
92
  ditherPixelSize: __props.ditherPixelSize,
78
93
  ditherLevels: __props.ditherLevels,
79
94
  onReady: __props.onReady,
80
- dev: DEV
95
+ dev: isDev
81
96
  }
82
97
  );
98
+ }
99
+ onMounted(() => {
100
+ stopReducedMotion = reducedMotion.start();
101
+ syncEngine();
83
102
  });
103
+ watch(
104
+ [() => reducedMotion.current, canvasRef],
105
+ () => {
106
+ syncEngine();
107
+ },
108
+ { flush: "post" }
109
+ );
84
110
  onBeforeUnmount(() => {
85
- engine?.destroy();
86
- engine = null;
111
+ stopReducedMotion?.();
112
+ stopReducedMotion = null;
113
+ stopEngine();
87
114
  });
88
115
  watch(
89
116
  () => ({ fluidColor: __props.fluidColor, fluidColors: __props.fluidColors, contained: __props.contained, interactive: __props.interactive, allowMultiple: __props.allowMultiple, onReady: __props.onReady }),
@@ -101,10 +128,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
101
128
  )
102
129
  )
103
130
  }, [
104
- createElementVNode("canvas", {
131
+ (openBlock(), createElementBlock("canvas", {
132
+ key: unref(reducedMotion).current ? "static" : "live",
105
133
  ref: "canvas",
106
134
  class: normalizeClass(__props.contained ? "block h-full w-full" : "block h-screen w-screen")
107
- }, null, 2)
135
+ }, null, 2))
108
136
  ], 2);
109
137
  };
110
138
  }
@@ -1386,9 +1386,9 @@ function createFluidCursor(el, options, random = Math.random) {
1386
1386
  window.addEventListener("mouseup", handlePointerUp);
1387
1387
  document.body.addEventListener("mousemove", handleFirstMouseMove);
1388
1388
  window.addEventListener("mousemove", handleMouseMove);
1389
- document.body.addEventListener("touchstart", handleFirstTouchStart);
1390
- window.addEventListener("touchstart", handleTouchStart, false);
1391
- window.addEventListener("touchmove", handleTouchMove, false);
1389
+ document.body.addEventListener("touchstart", handleFirstTouchStart, { passive: true });
1390
+ window.addEventListener("touchstart", handleTouchStart, { passive: true });
1391
+ window.addEventListener("touchmove", handleTouchMove, { passive: true });
1392
1392
  window.addEventListener("touchend", handlePointerUp);
1393
1393
  window.addEventListener("touchcancel", handlePointerUp);
1394
1394
  }
@@ -821,9 +821,9 @@ async function startWebGpuFluid(canvas, opts) {
821
821
  window.addEventListener("mouseup", handlePointerUp);
822
822
  document.body.addEventListener("mousemove", handleFirstMouseMove);
823
823
  window.addEventListener("mousemove", handleMouseMove);
824
- document.body.addEventListener("touchstart", handleFirstTouchStart);
825
- window.addEventListener("touchstart", handleTouchStart, false);
826
- window.addEventListener("touchmove", handleTouchMove, false);
824
+ document.body.addEventListener("touchstart", handleFirstTouchStart, { passive: true });
825
+ window.addEventListener("touchstart", handleTouchStart, { passive: true });
826
+ window.addEventListener("touchmove", handleTouchMove, { passive: true });
827
827
  window.addEventListener("touchend", handlePointerUp);
828
828
  window.addEventListener("touchcancel", handlePointerUp);
829
829
  }
@@ -1,7 +1,7 @@
1
1
  import _sfc_main from "./Focus.vue2.js";
2
2
  /* empty css */
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
- const Focus = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8ccba637"]]);
4
+ const Focus = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6f187539"]]);
5
5
  export {
6
6
  Focus as default
7
7
  };
@@ -94,7 +94,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
94
94
  class: normalizeClass(["focus-word", { manual: __props.manualMode, active: index === currentIndex.value && !__props.manualMode }]),
95
95
  style: normalizeStyle({
96
96
  filter: index === currentIndex.value ? "blur(0px)" : `blur(${__props.blurAmount}px)`,
97
- transition: `filter ${__props.animationDuration}s ease`,
97
+ "--focus-duration": `${__props.animationDuration}s`,
98
98
  "--border-color": __props.borderColor
99
99
  }),
100
100
  onMouseenter: ($event) => handleMouseEnter(index),
@@ -108,7 +108,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
108
108
  width: `${focusRect.value.width}px`,
109
109
  height: `${focusRect.value.height}px`,
110
110
  opacity: currentIndex.value >= 0 ? 1 : 0,
111
- transition: `all ${__props.animationDuration}s ease`,
111
+ "--focus-duration": `${__props.animationDuration}s`,
112
112
  "--border-color": __props.borderColor
113
113
  })
114
114
  }, [..._cache[0] || (_cache[0] = [
@@ -0,0 +1,69 @@
1
+ import type { HTMLAttributes } from "vue";
2
+ import type { ButtonVariant, ButtonSize } from "../button/types.js";
3
+ import type { FollowLabels } from "./follow-core.js";
4
+ export type { FollowLabels };
5
+ export interface FollowButtonProps {
6
+ /**
7
+ * Called with the committed value, once per successful attempt. Not called
8
+ * for a rolled-back or superseded one. The value itself is
9
+ * `v-model:following`.
10
+ */
11
+ onFollowingChange?: (following: boolean) => void;
12
+ /**
13
+ * Called with the value the click asks for. Return nothing to commit at
14
+ * once, or a promise: resolve commits, reject (or throw) rolls back, shows
15
+ * the error and announces it. Clicking again after a failure retries.
16
+ */
17
+ onToggle?: (next: boolean) => void | Promise<unknown>;
18
+ /** Stable accessible name, e.g. "Follow Rama". Defaults to the idle label. */
19
+ label?: string;
20
+ /** Visible text per state; unset keys keep the defaults. */
21
+ labels?: Partial<FollowLabels>;
22
+ /** Visible text and announcement after a failed attempt */
23
+ errorLabel?: string;
24
+ /** How long the error state holds before reverting, in milliseconds */
25
+ resetMs?: number;
26
+ /** Button variant. By default the idle state is `primary` and the following state `outline`. */
27
+ variant?: ButtonVariant;
28
+ /** Passed straight through to the underlying Button */
29
+ size?: ButtonSize;
30
+ /** Disables the button and blocks the toggle */
31
+ disabled?: boolean;
32
+ /** Drops the visible text, keeping the accessible name */
33
+ iconOnly?: boolean;
34
+ /**
35
+ * Plays the matching interface cue (toggle-on, toggle-off, error) and the
36
+ * error vibration. Off by default; only audible once the user has enabled sound.
37
+ */
38
+ sound?: boolean;
39
+ /**
40
+ * Fires on activation, after the toggle has started. Never called while
41
+ * `disabled` or pending. `@click` reaches it.
42
+ */
43
+ onClick?: ((event: MouseEvent) => void) | ((event: MouseEvent) => void)[];
44
+ /** Additional CSS classes */
45
+ class?: HTMLAttributes["class"];
46
+ }
47
+ declare const _default: typeof __VLS_export;
48
+ export default _default;
49
+ declare const __VLS_export: import("vue").DefineComponent<FollowButtonProps & {
50
+ /**
51
+ * Whether the viewer follows, `v-model:following`. The committed value is
52
+ * written back when `onToggle` resolves, never before. A write from the parent
53
+ * while an attempt is pending wins and drops that attempt.
54
+ */
55
+ following?: boolean;
56
+ }, {
57
+ ref: import("vue").ComputedRef<HTMLButtonElement | HTMLAnchorElement | null>;
58
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
59
+ "update:following": (value: boolean) => any;
60
+ }, string, import("vue").PublicProps, Readonly<FollowButtonProps & {
61
+ /**
62
+ * Whether the viewer follows, `v-model:following`. The committed value is
63
+ * written back when `onToggle` resolves, never before. A write from the parent
64
+ * while an attempt is pending wins and drops that attempt.
65
+ */
66
+ following?: boolean;
67
+ }> & Readonly<{
68
+ "onUpdate:following"?: ((value: boolean) => any) | undefined;
69
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./FollowButton.vue2.js";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
+ const FollowButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-89e2104a"]]);
5
+ export {
6
+ FollowButton as default
7
+ };
@@ -0,0 +1,239 @@
1
+ import { defineComponent, mergeModels, useModel, useAttrs, useTemplateRef, computed, shallowRef, watch, onBeforeUnmount, watchEffect, ref, createBlock, openBlock, unref, mergeProps, withCtx, createElementBlock, createCommentVNode, createElementVNode, toDisplayString, createVNode } from "vue";
2
+ import { callListener } from "../../internals/call-listener.js";
3
+ import { cn } from "../../utils.js";
4
+ import { sound } from "../../sound/sound.js";
5
+ import { prefersReducedMotion } from "../../internals/motion/anchored.js";
6
+ import { createFollowState, adopt, cancel, resolveLabels, shownFollowing, visibleLabel, clearError, announcement, morphState, press, isThenable, settle } from "./follow-core.js";
7
+ import Button from "../button/Button.vue.js";
8
+ import StatusMorph from "../status-morph/StatusMorph.vue.js";
9
+ const _hoisted_1 = {
10
+ class: "size-full",
11
+ viewBox: "0 0 24 24",
12
+ fill: "none",
13
+ stroke: "currentColor",
14
+ "stroke-width": "2",
15
+ "stroke-linecap": "round",
16
+ "stroke-linejoin": "round",
17
+ "aria-hidden": "true"
18
+ };
19
+ const _hoisted_2 = {
20
+ key: 0,
21
+ d: "M20 6 9 17l-5-5"
22
+ };
23
+ const _hoisted_3 = {
24
+ key: 1,
25
+ d: "M12 5v14M5 12h14"
26
+ };
27
+ const _hoisted_4 = {
28
+ key: 0,
29
+ class: "ft-follow__label"
30
+ };
31
+ const _hoisted_5 = {
32
+ class: "ft-follow__ghost",
33
+ "aria-hidden": "true"
34
+ };
35
+ const _hoisted_6 = {
36
+ class: "ft-follow__ghost",
37
+ "aria-hidden": "true"
38
+ };
39
+ const _hoisted_7 = {
40
+ class: "ft-follow__ghost",
41
+ "aria-hidden": "true"
42
+ };
43
+ const _hoisted_8 = {
44
+ class: "ft-follow__ghost",
45
+ "aria-hidden": "true"
46
+ };
47
+ const _hoisted_9 = {
48
+ key: 0,
49
+ class: "ft-follow__leave",
50
+ "aria-hidden": "true"
51
+ };
52
+ const _hoisted_10 = ["data-swapped", "data-preview"];
53
+ const _hoisted_11 = { class: "ft-follow__rest" };
54
+ const _hoisted_12 = {
55
+ key: 0,
56
+ class: "ft-follow__preview",
57
+ "aria-hidden": "true"
58
+ };
59
+ const LEAVE_MS = 80;
60
+ const MORPH_STYLE = {
61
+ width: "1rem",
62
+ height: "1rem",
63
+ fontSize: "calc(1rem - 1px)",
64
+ "--ft-statusmorph-error": "var(--ft-status-error, light-dark(oklch(0.577 0.245 27.325), oklch(0.704 0.191 22.216)))"
65
+ };
66
+ const _sfc_main = /* @__PURE__ */ defineComponent({
67
+ ...{ name: "FollowButton", inheritAttrs: false },
68
+ __name: "FollowButton",
69
+ props: /* @__PURE__ */ mergeModels({
70
+ onFollowingChange: { type: Function },
71
+ onToggle: { type: Function },
72
+ label: {},
73
+ labels: {},
74
+ errorLabel: { default: "Try again" },
75
+ resetMs: { default: 2e3 },
76
+ variant: {},
77
+ size: { default: "md" },
78
+ disabled: { type: Boolean, default: false },
79
+ iconOnly: { type: Boolean, default: false },
80
+ sound: { type: Boolean, default: false },
81
+ onClick: { type: [Function, Array] },
82
+ class: { type: [Boolean, null, String, Object, Array] }
83
+ }, {
84
+ "following": { type: Boolean, ...{ default: false } },
85
+ "followingModifiers": {}
86
+ }),
87
+ emits: ["update:following"],
88
+ setup(__props, { expose: __expose }) {
89
+ const following = useModel(__props, "following");
90
+ const attrs = useAttrs();
91
+ const btn = useTemplateRef("btn");
92
+ __expose({ ref: computed(() => btn.value?.ref ?? null) });
93
+ const core = shallowRef(createFollowState(following.value));
94
+ watch(following, (value) => {
95
+ if (value !== core.value.following) core.value = adopt(core.value, value);
96
+ });
97
+ onBeforeUnmount(() => {
98
+ core.value = cancel(core.value);
99
+ });
100
+ const resolvedLabels = computed(() => resolveLabels(__props.labels));
101
+ const shown = computed(() => shownFollowing(core.value));
102
+ const currentLabel = computed(() => visibleLabel(core.value, resolvedLabels.value, __props.errorLabel));
103
+ const showsPreview = computed(() => core.value.phase === "idle" && core.value.following);
104
+ const failed = computed(() => core.value.phase === "error");
105
+ const classes = computed(() => {
106
+ const reserveBorder = __props.variant === void 0;
107
+ return cn(
108
+ "ft-follow",
109
+ (failed.value || reserveBorder) && "border",
110
+ reserveBorder && !shown.value && !failed.value && "border-transparent",
111
+ failed.value && "ft-follow--failed",
112
+ __props.class
113
+ );
114
+ });
115
+ function accessibleName() {
116
+ return __props.label ?? attrs["aria-label"] ?? resolvedLabels.value.follow;
117
+ }
118
+ watchEffect((onCleanup) => {
119
+ if (core.value.phase !== "error") return;
120
+ const armed = core.value.ticket;
121
+ const timer = setTimeout(
122
+ () => {
123
+ core.value = clearError(core.value, armed);
124
+ },
125
+ __props.resetMs > 0 ? __props.resetMs : 1
126
+ );
127
+ onCleanup(() => clearTimeout(timer));
128
+ });
129
+ function finish(ticket, ok) {
130
+ const result = settle(core.value, ticket, ok);
131
+ if (result.outcome === "stale") return;
132
+ core.value = result.state;
133
+ if (ok) {
134
+ following.value = result.state.following;
135
+ if (__props.sound) sound.play(result.state.following ? "toggle-on" : "toggle-off");
136
+ __props.onFollowingChange?.(result.state.following);
137
+ } else if (__props.sound) {
138
+ sound.play("error");
139
+ }
140
+ }
141
+ function handleClick(event) {
142
+ const started = press(core.value);
143
+ if (!started) return;
144
+ if (__props.sound && sound.enabled) void sound.unlock();
145
+ core.value = started.state;
146
+ const ticket = started.ticket;
147
+ let result;
148
+ let threw = false;
149
+ try {
150
+ result = __props.onToggle?.(started.next);
151
+ } catch {
152
+ threw = true;
153
+ }
154
+ if (threw) finish(ticket, false);
155
+ else if (isThenable(result)) {
156
+ result.then(
157
+ () => finish(ticket, true),
158
+ () => finish(ticket, false)
159
+ );
160
+ } else finish(ticket, true);
161
+ callListener(__props.onClick, event);
162
+ }
163
+ const swapped = ref(false);
164
+ const leaving = ref(null);
165
+ let leaveTimer;
166
+ watch(currentLabel, (next, previous) => {
167
+ if (next === previous) return;
168
+ swapped.value = true;
169
+ if (leaving.value !== null) return;
170
+ clearTimeout(leaveTimer);
171
+ if (prefersReducedMotion()) {
172
+ leaving.value = null;
173
+ return;
174
+ }
175
+ leaving.value = previous;
176
+ leaveTimer = setTimeout(() => {
177
+ leaving.value = null;
178
+ }, LEAVE_MS);
179
+ });
180
+ onBeforeUnmount(() => clearTimeout(leaveTimer));
181
+ return (_ctx, _cache) => {
182
+ return openBlock(), createBlock(unref(Button), mergeProps({
183
+ ref_key: "btn",
184
+ ref: btn
185
+ }, unref(attrs), {
186
+ type: "button",
187
+ variant: __props.variant ?? (shown.value ? "outline" : "primary"),
188
+ size: __props.size,
189
+ disabled: __props.disabled,
190
+ label: accessibleName(),
191
+ class: classes.value,
192
+ "aria-pressed": shown.value,
193
+ "aria-busy": core.value.phase === "pending" ? "true" : void 0,
194
+ "data-state": core.value.phase,
195
+ onClick: handleClick
196
+ }), {
197
+ iconStart: withCtx(() => [
198
+ createVNode(unref(StatusMorph), {
199
+ state: unref(morphState)(core.value),
200
+ tone: "semantic",
201
+ "reset-after": 0,
202
+ haptic: __props.sound,
203
+ labels: { loading: "", success: "", error: unref(announcement)(accessibleName(), __props.errorLabel) },
204
+ style: MORPH_STYLE
205
+ }, {
206
+ idle: withCtx(() => [
207
+ (openBlock(), createElementBlock("svg", _hoisted_1, [
208
+ shown.value ? (openBlock(), createElementBlock("path", _hoisted_2)) : (openBlock(), createElementBlock("path", _hoisted_3))
209
+ ]))
210
+ ]),
211
+ _: 1
212
+ }, 8, ["state", "haptic", "labels"])
213
+ ]),
214
+ default: withCtx(() => [
215
+ !__props.iconOnly ? (openBlock(), createElementBlock("span", _hoisted_4, [
216
+ createElementVNode("span", _hoisted_5, toDisplayString(resolvedLabels.value.follow), 1),
217
+ createElementVNode("span", _hoisted_6, toDisplayString(resolvedLabels.value.following), 1),
218
+ createElementVNode("span", _hoisted_7, toDisplayString(resolvedLabels.value.unfollow), 1),
219
+ createElementVNode("span", _hoisted_8, toDisplayString(__props.errorLabel), 1),
220
+ leaving.value !== null ? (openBlock(), createElementBlock("span", _hoisted_9, toDisplayString(leaving.value), 1)) : createCommentVNode("", true),
221
+ (openBlock(), createElementBlock("span", {
222
+ key: currentLabel.value,
223
+ class: "ft-follow__live",
224
+ "data-swapped": swapped.value ? "" : void 0,
225
+ "data-preview": showsPreview.value ? "" : void 0
226
+ }, [
227
+ createElementVNode("span", _hoisted_11, toDisplayString(currentLabel.value), 1),
228
+ showsPreview.value ? (openBlock(), createElementBlock("span", _hoisted_12, toDisplayString(resolvedLabels.value.unfollow), 1)) : createCommentVNode("", true)
229
+ ], 8, _hoisted_10))
230
+ ])) : createCommentVNode("", true)
231
+ ]),
232
+ _: 1
233
+ }, 16, ["variant", "size", "disabled", "label", "class", "aria-pressed", "aria-busy", "data-state"]);
234
+ };
235
+ }
236
+ });
237
+ export {
238
+ _sfc_main as default
239
+ };
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Pure state machine behind FollowButton, shared byte for byte by the Svelte,
3
+ * React and Vue ports. No framework, no timers, no DOM: every function takes a
4
+ * snapshot and returns the next one, so the three components only translate
5
+ * "a click", "a promise settled" and "the parent wrote a value" into calls and
6
+ * paint the result.
7
+ *
8
+ * Three things live here because getting any of them subtly different in one
9
+ * port would be a bug no single port's tests could see:
10
+ *
11
+ * - The attempt ticket. Every press, every parent write and every cancel bumps
12
+ * `ticket`; a promise that settles under an older ticket changes nothing.
13
+ * That one rule covers a parent that answers faster than the server, a retry
14
+ * after a failure, and an unmount with a request still in flight.
15
+ * - The optimistic read. While an attempt is pending the button SHOWS the
16
+ * value it asked for, while `following` still holds the last value anybody
17
+ * committed, which is what a rollback returns to.
18
+ * - The label vocabulary (what is shown, what is announced), so a port cannot
19
+ * drift on which text goes with which state.
20
+ */
21
+ /** Where the control is in one attempt. `error` holds until a timer, a retry or the parent clears it. */
22
+ export type FollowPhase = "idle" | "pending" | "error";
23
+ export interface FollowState {
24
+ /** The last committed value: what a rollback returns to. */
25
+ readonly following: boolean;
26
+ readonly phase: FollowPhase;
27
+ /** The value the in-flight attempt asked for. Meaningful only while `phase` is `pending`. */
28
+ readonly target: boolean;
29
+ /** Identifies the current attempt; bumped by every press, parent write and cancel. */
30
+ readonly ticket: number;
31
+ }
32
+ export interface FollowLabels {
33
+ /** Visible and default accessible text while not following. */
34
+ follow: string;
35
+ /** Visible text while following. */
36
+ following: string;
37
+ /** Text previewed while following, on hover or keyboard focus of a fine pointer. */
38
+ unfollow: string;
39
+ }
40
+ export declare const DEFAULT_FOLLOW_LABELS: Readonly<FollowLabels>;
41
+ /** The glyph state StatusMorph is driven with. */
42
+ export type FollowMorphState = "idle" | "loading" | "error";
43
+ export type FollowOutcome = "commit" | "rollback" | "stale";
44
+ export declare function createFollowState(following: boolean): FollowState;
45
+ /** The value the control paints: the requested one while pending, the committed one otherwise. */
46
+ export declare function shownFollowing(state: FollowState): boolean;
47
+ /**
48
+ * A user activation. Returns the pending state plus the value to hand to
49
+ * `onToggle`, or `null` while an attempt is already in flight (the click is
50
+ * swallowed, never queued). A press out of `error` is the retry.
51
+ */
52
+ export declare function press(state: FollowState): {
53
+ state: FollowState;
54
+ ticket: number;
55
+ next: boolean;
56
+ } | null;
57
+ /**
58
+ * The attempt `ticket` finished. `ok` commits the requested value; failure
59
+ * keeps the committed one and parks the control in `error`. A ticket that is no
60
+ * longer current changes nothing and reports `stale`.
61
+ */
62
+ export declare function settle(state: FollowState, ticket: number, ok: boolean): {
63
+ state: FollowState;
64
+ outcome: FollowOutcome;
65
+ };
66
+ /**
67
+ * The parent wrote a value. It always wins: a pending attempt or a standing
68
+ * error is dropped and its ticket invalidated. Re-asserting what is already
69
+ * shown while idle is a no-op, so an echo of our own commit costs nothing.
70
+ */
71
+ export declare function adopt(state: FollowState, following: boolean): FollowState;
72
+ /** The error window ended. Only clears the error `ticket` armed it for, never a newer attempt. */
73
+ export declare function clearError(state: FollowState, ticket: number): FollowState;
74
+ /** Unmount: nothing in flight may write anything afterwards. */
75
+ export declare function cancel(state: FollowState): FollowState;
76
+ export declare function morphState(state: FollowState): FollowMorphState;
77
+ export declare function resolveLabels(labels?: Partial<FollowLabels> | null): FollowLabels;
78
+ /** The visible text for a state. The unfollow preview is a hover/focus overlay, not a state. */
79
+ export declare function visibleLabel(state: FollowState, labels: FollowLabels, errorLabel: string): string;
80
+ /** `name: outcome`, the single assertive announcement of a failed attempt. */
81
+ export declare function announcement(name: string, outcome: string): string;
82
+ /** A value `await` would wait for. A plain return commits synchronously instead. */
83
+ export declare function isThenable(value: unknown): value is PromiseLike<unknown>;
@@ -0,0 +1,92 @@
1
+ const DEFAULT_FOLLOW_LABELS = {
2
+ follow: "Follow",
3
+ following: "Following",
4
+ unfollow: "Unfollow"
5
+ };
6
+ function createFollowState(following) {
7
+ return { following, phase: "idle", target: following, ticket: 0 };
8
+ }
9
+ function shownFollowing(state) {
10
+ return state.phase === "pending" ? state.target : state.following;
11
+ }
12
+ function press(state) {
13
+ if (state.phase === "pending") return null;
14
+ const next = !state.following;
15
+ const ticket = state.ticket + 1;
16
+ return {
17
+ state: { following: state.following, phase: "pending", target: next, ticket },
18
+ ticket,
19
+ next
20
+ };
21
+ }
22
+ function settle(state, ticket, ok) {
23
+ if (state.phase !== "pending" || ticket !== state.ticket) return { state, outcome: "stale" };
24
+ if (ok) {
25
+ return {
26
+ state: { following: state.target, phase: "idle", target: state.target, ticket: state.ticket },
27
+ outcome: "commit"
28
+ };
29
+ }
30
+ return {
31
+ state: {
32
+ following: state.following,
33
+ phase: "error",
34
+ target: state.following,
35
+ ticket: state.ticket
36
+ },
37
+ outcome: "rollback"
38
+ };
39
+ }
40
+ function adopt(state, following) {
41
+ if (state.phase === "idle" && state.following === following) return state;
42
+ return { following, phase: "idle", target: following, ticket: state.ticket + 1 };
43
+ }
44
+ function clearError(state, ticket) {
45
+ if (state.phase !== "error" || state.ticket !== ticket) return state;
46
+ return { ...state, phase: "idle" };
47
+ }
48
+ function cancel(state) {
49
+ return {
50
+ following: state.following,
51
+ phase: "idle",
52
+ target: state.following,
53
+ ticket: state.ticket + 1
54
+ };
55
+ }
56
+ function morphState(state) {
57
+ return state.phase === "pending" ? "loading" : state.phase === "error" ? "error" : "idle";
58
+ }
59
+ function resolveLabels(labels) {
60
+ const resolved = { ...DEFAULT_FOLLOW_LABELS };
61
+ if (!labels) return resolved;
62
+ for (const key of Object.keys(DEFAULT_FOLLOW_LABELS)) {
63
+ const value = labels[key];
64
+ if (value !== void 0) resolved[key] = value;
65
+ }
66
+ return resolved;
67
+ }
68
+ function visibleLabel(state, labels, errorLabel) {
69
+ if (state.phase === "error") return errorLabel;
70
+ return shownFollowing(state) ? labels.following : labels.follow;
71
+ }
72
+ function announcement(name, outcome) {
73
+ return `${name}: ${outcome}`;
74
+ }
75
+ function isThenable(value) {
76
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
77
+ }
78
+ export {
79
+ DEFAULT_FOLLOW_LABELS,
80
+ adopt,
81
+ announcement,
82
+ cancel,
83
+ clearError,
84
+ createFollowState,
85
+ isThenable,
86
+ morphState,
87
+ press,
88
+ resolveLabels,
89
+ settle,
90
+ shownFollowing,
91
+ visibleLabel
92
+ };