@ansh-ui/react 0.2.0 → 0.3.1

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 (92) hide show
  1. package/dist/{chunk-C5JG6TMM.cjs → chunk-2U7BHYIQ.cjs} +143 -143
  2. package/dist/chunk-2U7BHYIQ.cjs.map +1 -0
  3. package/dist/{chunk-HO2YSF5O.js → chunk-742E5FQS.js} +3 -3
  4. package/dist/chunk-742E5FQS.js.map +1 -0
  5. package/dist/{chunk-QO3E7TJS.js → chunk-7QGB2X7R.js} +36 -28
  6. package/dist/chunk-7QGB2X7R.js.map +1 -0
  7. package/dist/{chunk-EGG4CP7C.js → chunk-BQJ6H3HC.js} +3 -2
  8. package/dist/chunk-BQJ6H3HC.js.map +1 -0
  9. package/dist/{chunk-OLTS6G5M.js → chunk-GNA33V2J.js} +11 -6
  10. package/dist/chunk-GNA33V2J.js.map +1 -0
  11. package/dist/{chunk-C32LKF23.cjs → chunk-KTLTYHAT.cjs} +3 -3
  12. package/dist/chunk-KTLTYHAT.cjs.map +1 -0
  13. package/dist/{chunk-AVPEA5PB.cjs → chunk-MPX7QT4R.cjs} +4 -4
  14. package/dist/chunk-MPX7QT4R.cjs.map +1 -0
  15. package/dist/{chunk-T4AK2KLM.js → chunk-NJUVVMJV.js} +3 -3
  16. package/dist/chunk-NJUVVMJV.js.map +1 -0
  17. package/dist/{chunk-IBXLC5IE.js → chunk-P5MRISBP.js} +19 -3
  18. package/dist/chunk-P5MRISBP.js.map +1 -0
  19. package/dist/{chunk-WGYNCSTP.cjs → chunk-PUW6BTPQ.cjs} +3 -2
  20. package/dist/chunk-PUW6BTPQ.cjs.map +1 -0
  21. package/dist/{chunk-LDCZQP3R.js → chunk-RGGNLAAA.js} +122 -122
  22. package/dist/chunk-RGGNLAAA.js.map +1 -0
  23. package/dist/{chunk-6VRF7X5C.cjs → chunk-TEPQGFR4.cjs} +19 -2
  24. package/dist/chunk-TEPQGFR4.cjs.map +1 -0
  25. package/dist/{chunk-OJN5JBNP.cjs → chunk-VJI6V27F.cjs} +99 -99
  26. package/dist/chunk-VJI6V27F.cjs.map +1 -0
  27. package/dist/{chunk-HPGCILO4.js → chunk-XRKZPLUT.js} +99 -99
  28. package/dist/chunk-XRKZPLUT.js.map +1 -0
  29. package/dist/{chunk-DATBU46V.cjs → chunk-XYT6OXKP.cjs} +10 -4
  30. package/dist/chunk-XYT6OXKP.cjs.map +1 -0
  31. package/dist/{chunk-RHTLNSVW.cjs → chunk-YVJB7AAZ.cjs} +39 -31
  32. package/dist/chunk-YVJB7AAZ.cjs.map +1 -0
  33. package/dist/data.cjs +16 -16
  34. package/dist/data.d.cts +25 -23
  35. package/dist/data.d.ts +25 -23
  36. package/dist/data.js +1 -1
  37. package/dist/form.cjs +37 -37
  38. package/dist/form.d.cts +4 -1
  39. package/dist/form.d.ts +4 -1
  40. package/dist/form.js +2 -2
  41. package/dist/index.cjs +666 -135
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +220 -7
  44. package/dist/index.d.ts +220 -7
  45. package/dist/index.js +530 -14
  46. package/dist/index.js.map +1 -1
  47. package/dist/layout.cjs +13 -13
  48. package/dist/layout.d.cts +11 -2
  49. package/dist/layout.d.ts +11 -2
  50. package/dist/layout.js +1 -1
  51. package/dist/{motion-CQmCq6_k.d.ts → motion-C6WfBFES.d.cts} +23 -19
  52. package/dist/{motion-CSX4g2N8.d.cts → motion-ugXmf505.d.ts} +23 -19
  53. package/dist/motion.cjs +19 -19
  54. package/dist/motion.d.cts +2 -2
  55. package/dist/motion.d.ts +2 -2
  56. package/dist/motion.js +2 -2
  57. package/dist/navigation.cjs +8 -8
  58. package/dist/navigation.d.cts +3 -2
  59. package/dist/navigation.d.ts +3 -2
  60. package/dist/navigation.js +1 -1
  61. package/dist/overlay.cjs +16 -16
  62. package/dist/overlay.d.cts +17 -14
  63. package/dist/overlay.d.ts +17 -14
  64. package/dist/overlay.js +2 -2
  65. package/dist/{position-DVScKcaa.d.cts → position-CW6cGpSF.d.cts} +2 -1
  66. package/dist/{position-DVScKcaa.d.ts → position-CW6cGpSF.d.ts} +2 -1
  67. package/dist/primitives.cjs +25 -21
  68. package/dist/primitives.d.cts +5 -4
  69. package/dist/primitives.d.ts +5 -4
  70. package/dist/primitives.js +2 -2
  71. package/dist/{sidebar-D-PafAXw.d.cts → sidebar-Dyt67t2z.d.cts} +2 -1
  72. package/dist/{sidebar-D-PafAXw.d.ts → sidebar-Dyt67t2z.d.ts} +2 -1
  73. package/dist/styles.css +464 -0
  74. package/dist/{use-observers-B9qtimrk.d.cts → use-observers-DvA7hSz4.d.cts} +10 -1
  75. package/dist/{use-observers-B9qtimrk.d.ts → use-observers-DvA7hSz4.d.ts} +10 -1
  76. package/package.json +3 -3
  77. package/dist/chunk-6VRF7X5C.cjs.map +0 -1
  78. package/dist/chunk-AVPEA5PB.cjs.map +0 -1
  79. package/dist/chunk-C32LKF23.cjs.map +0 -1
  80. package/dist/chunk-C5JG6TMM.cjs.map +0 -1
  81. package/dist/chunk-DATBU46V.cjs.map +0 -1
  82. package/dist/chunk-EGG4CP7C.js.map +0 -1
  83. package/dist/chunk-HO2YSF5O.js.map +0 -1
  84. package/dist/chunk-HPGCILO4.js.map +0 -1
  85. package/dist/chunk-IBXLC5IE.js.map +0 -1
  86. package/dist/chunk-LDCZQP3R.js.map +0 -1
  87. package/dist/chunk-OJN5JBNP.cjs.map +0 -1
  88. package/dist/chunk-OLTS6G5M.js.map +0 -1
  89. package/dist/chunk-QO3E7TJS.js.map +0 -1
  90. package/dist/chunk-RHTLNSVW.cjs.map +0 -1
  91. package/dist/chunk-T4AK2KLM.js.map +0 -1
  92. package/dist/chunk-WGYNCSTP.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,24 +1,26 @@
1
1
  'use client';
2
2
  export { useAnimate, useIsMounted, useMotionStyle, useMotionValue, useMotionValueState, useSpringValue } from './chunk-O2PX54KX.js';
3
- export { AspectRatio, Center, Container, Divider, Grid, GridItem, HStack, Resizable, ScrollArea, Spacer, Stack, VStack } from './chunk-EGG4CP7C.js';
4
- export { Calendar, Checkbox, ChoiceCard, ColorPicker, Combobox, DatePicker, DateRangePicker, Dropzone, Field, Fieldset, Input, NumberInput, OptionList, PinInput, Radio, RadioGroup, RangeSlider, Rating, Select, Slider, Switch, TagsInput, Textarea, VisuallyHidden, addDays, addMonths, filterOptions, firstEnabled, isSameDay, scoreOption, startOfDay, stepActive, useFieldContext, useFieldControl, useTypeahead } from './chunk-QO3E7TJS.js';
5
- export { AlertDialog, CommandPalette, ContextMenu, Dialog, DialogFooter, Drawer, DropdownMenu, HoverCard, Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipProvider, useCommandShortcut } from './chunk-LDCZQP3R.js';
6
- export { Presence, Slot, getTabbable, slotted, useAutoFocus, useFocusRestore, useFocusTrap, usePresence, useRovingFocus } from './chunk-HO2YSF5O.js';
3
+ export { AspectRatio, Center, Container, Divider, Grid, GridItem, HStack, Resizable, ScrollArea, Spacer, Stack, VStack } from './chunk-BQJ6H3HC.js';
4
+ export { Calendar, Checkbox, ChoiceCard, ColorPicker, Combobox, DatePicker, DateRangePicker, Dropzone, Field, Fieldset, Input, NumberInput, OptionList, PinInput, Radio, RadioGroup, RangeSlider, Rating, Select, Slider, Switch, TagsInput, Textarea, VisuallyHidden, addDays, addMonths, filterOptions, firstEnabled, isSameDay, scoreOption, startOfDay, stepActive, useFieldContext, useFieldControl, useTypeahead } from './chunk-7QGB2X7R.js';
5
+ export { AlertDialog, CommandPalette, ContextMenu, Dialog, DialogFooter, Drawer, DropdownMenu, HoverCard, Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipProvider, useCommandShortcut } from './chunk-RGGNLAAA.js';
6
+ export { Presence, Slot, getTabbable, slotted, useAutoFocus, useFocusRestore, useFocusTrap, usePresence, useRovingFocus } from './chunk-742E5FQS.js';
7
7
  export { Portal, computePosition, useAnchoredPosition, useDismiss, useScrollLock } from './chunk-XEP6P7E6.js';
8
- export { Avatar, AvatarGroup, Badge, CircularProgress, CodeBlock, DataTable, DescriptionList, EmptyState, Kbd, Meter, Pagination, Progress, Stat, Table, Timeline } from './chunk-HPGCILO4.js';
9
- export { Accordion, Breadcrumbs, Collapsible, DisclosureList, NavigationMenu, Stepper, Tabs } from './chunk-OLTS6G5M.js';
8
+ export { Avatar, AvatarGroup, Badge, CircularProgress, CodeBlock, DataTable, DescriptionList, EmptyState, Kbd, Meter, Pagination, Progress, Stat, Table, Timeline } from './chunk-XRKZPLUT.js';
9
+ import { inertProps } from './chunk-GNA33V2J.js';
10
+ export { Accordion, Breadcrumbs, Collapsible, DisclosureList, NavigationMenu, Stepper, Tabs } from './chunk-GNA33V2J.js';
10
11
  export { AppShell, Sidebar } from './chunk-5CFQFMP5.js';
12
+ import { useControllableState } from './chunk-LXCIXR5T.js';
11
13
  export { useControllableState } from './chunk-LXCIXR5T.js';
12
- import { useBehaviour } from './chunk-T4AK2KLM.js';
13
- export { AnimatePresence, AnimatedText, Draggable, GradientText, MagneticButton, Marquee, Motion, MotionConfig, Parallax, Ripple, ScrollReveal, ThemeProvider, TiltCard, createBehaviourComponent, themeScript, useBehaviour, useMotionConfig, useTheme } from './chunk-T4AK2KLM.js';
14
- import { useMergedRef, useInView } from './chunk-IBXLC5IE.js';
15
- export { useElementSize, useFrameBudget, useInView, useMergedRef, usePointer, useReducedMotion, useScrollProgress, useTicker, useWindowScroll } from './chunk-IBXLC5IE.js';
14
+ import { useBehaviour } from './chunk-NJUVVMJV.js';
15
+ export { AnimatePresence, AnimatedText, Draggable, GradientText, MagneticButton, Marquee, Motion, MotionConfig, Parallax, Ripple, ScrollReveal, ThemeProvider, TiltCard, createBehaviourComponent, themeScript, useBehaviour, useMotionConfig, useTheme } from './chunk-NJUVVMJV.js';
16
+ import { useMergedRef, useInView } from './chunk-P5MRISBP.js';
17
+ export { useElementSize, useFrameBudget, useInView, useMergedRef, usePointer, useReducedMotion, useScrollProgress, useTicker, useTickerSubscriberCount, useWindowScroll } from './chunk-P5MRISBP.js';
16
18
  import { cx } from './chunk-H34OXXJU.js';
17
19
  export { composeEventHandlers, cx, mergeProps, mergeRefs } from './chunk-H34OXXJU.js';
18
20
  import { forwardRef, useRef, useEffect, createContext, useMemo, useState, useCallback, useContext, useId } from 'react';
19
- import { magnetic, ripple, getTicker, mountEffect, aurora, meshGradient, animatedGradient, particleField, constellation, meteors, rain, snow, fireflies, waves, blob, noiseLayer, spotlight, prefersReducedMotion } from '@ansh-ui/core';
21
+ import { magnetic, ripple, getTicker, mountEffect, aurora, meshGradient, animatedGradient, particleField, constellation, meteors, rain, snow, fireflies, waves, blob, noiseLayer, spotlight, lightRays, smoke, powderExplosion, floatingGeometry, orbit, strangeAttractor, swarm, prefersReducedMotion, mountBehaviour, textScramble, clamp } from '@ansh-ui/core';
20
22
  export { MotionValue, animate, checkContrast, createGradient, createNoise, createScale, createTimeline, cubicBezier, easings, ensureContrast, generatePalette, getRegistry, getTicker, mixColors, motionValue, palettes, parseColor, pickReadable, prefersReducedMotion, registerEasing, setReducedMotionMode, signature as signatureEasings, springs, stagger, toHex, toOklchString } from '@ansh-ui/core';
21
- import { jsx, jsxs } from 'react/jsx-runtime';
23
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
22
24
 
23
25
  var HOST_STYLE = {
24
26
  position: "relative",
@@ -101,6 +103,13 @@ var Waves = createEffectComponent(waves, "Waves");
101
103
  var LiquidBlob = createEffectComponent(blob, "LiquidBlob");
102
104
  var NoiseLayer = createEffectComponent(noiseLayer, "NoiseLayer");
103
105
  var Spotlight = createEffectComponent(spotlight, "Spotlight");
106
+ var LightRays = createEffectComponent(lightRays, "LightRays");
107
+ var Smoke = createEffectComponent(smoke, "Smoke");
108
+ var PowderExplosion = createEffectComponent(powderExplosion, "PowderExplosion");
109
+ var FloatingGeometry = createEffectComponent(floatingGeometry, "FloatingGeometry");
110
+ var Orbit = createEffectComponent(orbit, "Orbit");
111
+ var StrangeAttractor = createEffectComponent(strangeAttractor, "StrangeAttractor");
112
+ var Swarm = createEffectComponent(swarm, "Swarm");
104
113
  var Button = forwardRef(function Button2({
105
114
  variant = "solid",
106
115
  size = "md",
@@ -798,13 +807,520 @@ function FAQAccordion({
798
807
  "aria-labelledby": triggerId,
799
808
  className: "ansh-accordion__panel",
800
809
  "data-open": isOpen,
801
- ...isOpen ? {} : { inert: true },
810
+ ...inertProps(!isOpen),
802
811
  children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "ansh-accordion__body", children: item.answer }) })
803
812
  }
804
813
  )
805
814
  ] }, item.question);
806
815
  }) });
807
816
  }
817
+ var VISUALLY_HIDDEN = {
818
+ position: "absolute",
819
+ width: 1,
820
+ height: 1,
821
+ padding: 0,
822
+ margin: -1,
823
+ overflow: "hidden",
824
+ clip: "rect(0 0 0 0)",
825
+ whiteSpace: "nowrap",
826
+ border: 0
827
+ };
828
+ function ScrambleText({ children, as, className, style, ...options }) {
829
+ const Tag = as ?? "span";
830
+ const ref = useRef(null);
831
+ const {
832
+ chars,
833
+ duration,
834
+ stagger: stagger2,
835
+ cycleSpeed,
836
+ trigger,
837
+ repeat,
838
+ threshold,
839
+ seed,
840
+ intensity,
841
+ reducedMotion,
842
+ disabled
843
+ } = options;
844
+ useEffect(() => {
845
+ const node = ref.current;
846
+ if (!node) return;
847
+ const handle = mountBehaviour(textScramble, node, {
848
+ chars,
849
+ duration,
850
+ stagger: stagger2,
851
+ cycleSpeed,
852
+ trigger,
853
+ repeat,
854
+ threshold,
855
+ seed,
856
+ intensity,
857
+ reducedMotion,
858
+ disabled
859
+ });
860
+ return () => handle.destroy();
861
+ }, [
862
+ children,
863
+ chars,
864
+ duration,
865
+ stagger2,
866
+ cycleSpeed,
867
+ trigger,
868
+ repeat,
869
+ threshold,
870
+ seed,
871
+ intensity,
872
+ reducedMotion,
873
+ disabled
874
+ ]);
875
+ return /* @__PURE__ */ jsxs(Tag, { className, style, children: [
876
+ /* @__PURE__ */ jsx("span", { style: VISUALLY_HIDDEN, children }),
877
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", ref, children })
878
+ ] });
879
+ }
880
+ function TextRotate({
881
+ words,
882
+ interval = 2.2,
883
+ animation = "slide",
884
+ className,
885
+ style
886
+ }) {
887
+ const [index, setIndex] = useState(0);
888
+ const reduced = useRef(false);
889
+ const [ready, setReady] = useState(false);
890
+ useEffect(() => {
891
+ reduced.current = prefersReducedMotion();
892
+ setReady(true);
893
+ }, []);
894
+ const safeWords = words.length > 0 ? words : [""];
895
+ const count = safeWords.length;
896
+ useEffect(() => {
897
+ if (!ready || reduced.current) return;
898
+ if (count < 2) return;
899
+ const ms = Math.max(200, interval * 1e3);
900
+ const timer = window.setInterval(() => {
901
+ setIndex((previous) => (previous + 1) % count);
902
+ }, ms);
903
+ return () => window.clearInterval(timer);
904
+ }, [ready, interval, count]);
905
+ const current = safeWords[index % count];
906
+ return /* @__PURE__ */ jsxs(
907
+ "span",
908
+ {
909
+ className: ["ansh-rotate", className].filter(Boolean).join(" "),
910
+ style,
911
+ "data-animation": animation,
912
+ children: [
913
+ /* @__PURE__ */ jsx("span", { className: "ansh-rotate__sizer", "aria-hidden": "true", children: safeWords.map((word, i) => /* @__PURE__ */ jsx("span", { className: "ansh-rotate__ghost", children: word }, `${word}-${i}`)) }),
914
+ /* @__PURE__ */ jsx("span", { className: "ansh-rotate__clip", children: /* @__PURE__ */ jsx("span", { className: "ansh-rotate__word", children: current }, index) })
915
+ ]
916
+ }
917
+ );
918
+ }
919
+ function BeforeAfter({
920
+ before,
921
+ after,
922
+ value,
923
+ defaultValue = 50,
924
+ onValueChange,
925
+ step = 4,
926
+ label = "Comparison position",
927
+ className,
928
+ style
929
+ }) {
930
+ const [position, setPosition] = useControllableState({
931
+ value,
932
+ defaultValue,
933
+ onChange: onValueChange
934
+ });
935
+ const rootRef = useRef(null);
936
+ const [dragging, setDragging] = useState(false);
937
+ const positionFromClientX = useCallback((clientX) => {
938
+ const node = rootRef.current;
939
+ if (!node) return 50;
940
+ const rect = node.getBoundingClientRect();
941
+ if (rect.width <= 0) return 50;
942
+ return clamp((clientX - rect.left) / rect.width * 100, 0, 100);
943
+ }, []);
944
+ const onPointerDown = (event) => {
945
+ event.currentTarget.setPointerCapture(event.pointerId);
946
+ setDragging(true);
947
+ setPosition(positionFromClientX(event.clientX));
948
+ };
949
+ const onPointerMove = (event) => {
950
+ if (!dragging) return;
951
+ setPosition(positionFromClientX(event.clientX));
952
+ };
953
+ const endDrag = (event) => {
954
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {
955
+ event.currentTarget.releasePointerCapture(event.pointerId);
956
+ }
957
+ setDragging(false);
958
+ };
959
+ const onKeyDown = (event) => {
960
+ const jump = event.key === "ArrowLeft" || event.key === "ArrowDown" ? -step : event.key === "ArrowRight" || event.key === "ArrowUp" ? step : event.key === "Home" ? -100 : event.key === "End" ? 100 : 0;
961
+ if (jump === 0) return;
962
+ event.preventDefault();
963
+ setPosition((current) => clamp(current + jump, 0, 100));
964
+ };
965
+ const clipped = clamp(position, 0, 100);
966
+ return /* @__PURE__ */ jsxs(
967
+ "div",
968
+ {
969
+ ref: rootRef,
970
+ className: ["ansh-compare", className].filter(Boolean).join(" "),
971
+ style,
972
+ "data-dragging": dragging || void 0,
973
+ onPointerDown: (event) => {
974
+ if (event.target === event.currentTarget || !dragging) {
975
+ setPosition(positionFromClientX(event.clientX));
976
+ }
977
+ },
978
+ children: [
979
+ /* @__PURE__ */ jsx("div", { className: "ansh-compare__layer", children: after }),
980
+ /* @__PURE__ */ jsx(
981
+ "div",
982
+ {
983
+ className: "ansh-compare__layer ansh-compare__layer--before",
984
+ style: { clipPath: `inset(0 ${100 - clipped}% 0 0)` },
985
+ children: before
986
+ }
987
+ ),
988
+ /* @__PURE__ */ jsx(
989
+ "div",
990
+ {
991
+ className: "ansh-compare__handle",
992
+ style: { left: `${clipped}%` },
993
+ role: "slider",
994
+ tabIndex: 0,
995
+ "aria-label": label,
996
+ "aria-valuemin": 0,
997
+ "aria-valuemax": 100,
998
+ "aria-valuenow": Math.round(clipped),
999
+ "aria-orientation": "horizontal",
1000
+ onPointerDown,
1001
+ onPointerMove,
1002
+ onPointerUp: endDrag,
1003
+ onPointerCancel: endDrag,
1004
+ onKeyDown,
1005
+ children: /* @__PURE__ */ jsx("span", { className: "ansh-compare__grip", "aria-hidden": "true" })
1006
+ }
1007
+ )
1008
+ ]
1009
+ }
1010
+ );
1011
+ }
1012
+ function DeviceMockup({
1013
+ variant = "browser",
1014
+ url,
1015
+ title,
1016
+ label,
1017
+ className,
1018
+ style,
1019
+ children
1020
+ }) {
1021
+ return /* @__PURE__ */ jsxs(
1022
+ "div",
1023
+ {
1024
+ className: ["ansh-mock", `ansh-mock--${variant}`, className].filter(Boolean).join(" "),
1025
+ style,
1026
+ role: label ? "group" : void 0,
1027
+ "aria-label": label,
1028
+ children: [
1029
+ variant === "phone" ? /* @__PURE__ */ jsx("span", { className: "ansh-mock__notch", "aria-hidden": "true" }) : /* @__PURE__ */ jsxs("div", { className: "ansh-mock__chrome", "aria-hidden": "true", children: [
1030
+ /* @__PURE__ */ jsxs("span", { className: "ansh-mock__dots", children: [
1031
+ /* @__PURE__ */ jsx("i", {}),
1032
+ /* @__PURE__ */ jsx("i", {}),
1033
+ /* @__PURE__ */ jsx("i", {})
1034
+ ] }),
1035
+ variant === "browser" && url ? /* @__PURE__ */ jsx("span", { className: "ansh-mock__url", children: url }) : title ? /* @__PURE__ */ jsx("span", { className: "ansh-mock__title", children: title }) : null
1036
+ ] }),
1037
+ /* @__PURE__ */ jsx("div", { className: "ansh-mock__screen", children })
1038
+ ]
1039
+ }
1040
+ );
1041
+ }
1042
+ var OFFSET_Y = 14;
1043
+ var SCALE_STEP = 0.05;
1044
+ var ROTATE_STEP = 1.6;
1045
+ function CardStack({
1046
+ items,
1047
+ autoPlay = true,
1048
+ interval = 3.5,
1049
+ peek = 2,
1050
+ controls = true,
1051
+ label = "Card stack",
1052
+ className,
1053
+ style
1054
+ }) {
1055
+ const [top, setTop] = useState(0);
1056
+ const [paused, setPaused] = useState(false);
1057
+ const reduced = useRef(false);
1058
+ const [ready, setReady] = useState(false);
1059
+ useEffect(() => {
1060
+ reduced.current = prefersReducedMotion();
1061
+ setReady(true);
1062
+ }, []);
1063
+ const count = items.length;
1064
+ useEffect(() => {
1065
+ if (!ready || reduced.current || !autoPlay || paused) return;
1066
+ if (count < 2) return;
1067
+ const ms = Math.max(600, interval * 1e3);
1068
+ const timer = window.setInterval(() => setTop((current2) => (current2 + 1) % count), ms);
1069
+ return () => window.clearInterval(timer);
1070
+ }, [ready, autoPlay, paused, interval, count]);
1071
+ if (count === 0) return null;
1072
+ const current = top % count;
1073
+ const advance = (direction) => setTop((previous) => (previous + direction + count) % count);
1074
+ return /* @__PURE__ */ jsxs(
1075
+ "div",
1076
+ {
1077
+ className: ["ansh-stack", className].filter(Boolean).join(" "),
1078
+ style,
1079
+ role: "group",
1080
+ "aria-label": label,
1081
+ "aria-roledescription": "card stack",
1082
+ onPointerEnter: () => setPaused(true),
1083
+ onPointerLeave: () => setPaused(false),
1084
+ onFocusCapture: () => setPaused(true),
1085
+ onBlurCapture: () => setPaused(false),
1086
+ children: [
1087
+ /* @__PURE__ */ jsx("div", { className: "ansh-stack__deck", children: items.map((item, i) => {
1088
+ const rung = (i - current + count) % count;
1089
+ const hidden = rung > peek;
1090
+ return /* @__PURE__ */ jsx(
1091
+ "div",
1092
+ {
1093
+ className: "ansh-stack__card",
1094
+ "data-rung": rung,
1095
+ "aria-hidden": rung === 0 ? void 0 : "true",
1096
+ ...inertProps(rung !== 0),
1097
+ style: {
1098
+ transform: `translateY(${rung * OFFSET_Y}px) scale(${1 - rung * SCALE_STEP}) rotate(${rung === 0 ? 0 : (rung % 2 === 0 ? 1 : -1) * ROTATE_STEP}deg)`,
1099
+ opacity: hidden ? 0 : 1,
1100
+ zIndex: count - rung,
1101
+ pointerEvents: rung === 0 ? void 0 : "none"
1102
+ },
1103
+ children: item
1104
+ },
1105
+ i
1106
+ );
1107
+ }) }),
1108
+ controls && count > 1 ? /* @__PURE__ */ jsxs("div", { className: "ansh-stack__controls", children: [
1109
+ /* @__PURE__ */ jsx(
1110
+ "button",
1111
+ {
1112
+ type: "button",
1113
+ className: "ansh-stack__button",
1114
+ onClick: () => advance(-1),
1115
+ "aria-label": "Previous card",
1116
+ children: "\u2039"
1117
+ }
1118
+ ),
1119
+ /* @__PURE__ */ jsxs("span", { className: "ansh-stack__count", "aria-hidden": "true", children: [
1120
+ current + 1,
1121
+ " / ",
1122
+ count
1123
+ ] }),
1124
+ /* @__PURE__ */ jsx(
1125
+ "button",
1126
+ {
1127
+ type: "button",
1128
+ className: "ansh-stack__button",
1129
+ onClick: () => advance(1),
1130
+ "aria-label": "Next card",
1131
+ children: "\u203A"
1132
+ }
1133
+ )
1134
+ ] }) : null
1135
+ ]
1136
+ }
1137
+ );
1138
+ }
1139
+ function Carousel({
1140
+ items,
1141
+ value,
1142
+ defaultValue = 0,
1143
+ onChange,
1144
+ loop = true,
1145
+ autoPlay = false,
1146
+ interval = 5,
1147
+ showDots = true,
1148
+ showArrows = true,
1149
+ draggable = true,
1150
+ label,
1151
+ className,
1152
+ style
1153
+ }) {
1154
+ const count = items.length;
1155
+ const [index, setIndex] = useControllableState({
1156
+ value,
1157
+ defaultValue: clamp(defaultValue, 0, Math.max(0, count - 1)),
1158
+ onChange
1159
+ });
1160
+ const [paused, setPaused] = useState(false);
1161
+ const [playing, setPlaying] = useState(autoPlay);
1162
+ const [drag, setDrag] = useState(0);
1163
+ const baseId = useId();
1164
+ const viewportRef = useRef(null);
1165
+ const dragStart = useRef(null);
1166
+ const active = count > 0 ? clamp(index, 0, count - 1) : 0;
1167
+ const goTo = (next) => {
1168
+ if (count === 0) return;
1169
+ const wrapped = loop ? (next + count) % count : clamp(next, 0, count - 1);
1170
+ setIndex(wrapped);
1171
+ };
1172
+ useEffect(() => {
1173
+ if (!playing || paused || count < 2) return;
1174
+ const ms = Math.max(1e3, interval * 1e3);
1175
+ const timer = window.setInterval(() => {
1176
+ setIndex((previous) => {
1177
+ const next = previous + 1;
1178
+ return loop ? next % count : Math.min(next, count - 1);
1179
+ });
1180
+ }, ms);
1181
+ return () => window.clearInterval(timer);
1182
+ }, [playing, paused, interval, count, loop, setIndex]);
1183
+ if (count === 0) return null;
1184
+ const atStart = !loop && active === 0;
1185
+ const atEnd = !loop && active === count - 1;
1186
+ const onKeyDown = (event) => {
1187
+ if (event.key === "ArrowLeft") {
1188
+ event.preventDefault();
1189
+ goTo(active - 1);
1190
+ } else if (event.key === "ArrowRight") {
1191
+ event.preventDefault();
1192
+ goTo(active + 1);
1193
+ } else if (event.key === "Home") {
1194
+ event.preventDefault();
1195
+ goTo(0);
1196
+ } else if (event.key === "End") {
1197
+ event.preventDefault();
1198
+ goTo(count - 1);
1199
+ }
1200
+ };
1201
+ const onPointerDown = (event) => {
1202
+ if (!draggable || count < 2) return;
1203
+ dragStart.current = event.clientX;
1204
+ event.currentTarget.setPointerCapture(event.pointerId);
1205
+ };
1206
+ const onPointerMove = (event) => {
1207
+ if (dragStart.current === null) return;
1208
+ setDrag(event.clientX - dragStart.current);
1209
+ };
1210
+ const endDrag = (event) => {
1211
+ if (dragStart.current === null) return;
1212
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {
1213
+ event.currentTarget.releasePointerCapture(event.pointerId);
1214
+ }
1215
+ const width = viewportRef.current?.clientWidth ?? 1;
1216
+ const travelled = drag;
1217
+ dragStart.current = null;
1218
+ setDrag(0);
1219
+ if (Math.abs(travelled) > width * 0.25) goTo(active + (travelled < 0 ? 1 : -1));
1220
+ };
1221
+ const dragPercent = drag !== 0 ? drag / (viewportRef.current?.clientWidth || 1) * 100 : 0;
1222
+ return /* @__PURE__ */ jsxs(
1223
+ "section",
1224
+ {
1225
+ className: cx("ansh-carousel", className),
1226
+ style,
1227
+ "aria-roledescription": "carousel",
1228
+ "aria-label": label,
1229
+ onKeyDown,
1230
+ onPointerEnter: () => setPaused(true),
1231
+ onPointerLeave: () => setPaused(false),
1232
+ onFocusCapture: () => setPaused(true),
1233
+ onBlurCapture: () => setPaused(false),
1234
+ children: [
1235
+ /* @__PURE__ */ jsx(
1236
+ "div",
1237
+ {
1238
+ className: "ansh-carousel__viewport",
1239
+ ref: viewportRef,
1240
+ "aria-live": playing ? "off" : "polite",
1241
+ onPointerDown,
1242
+ onPointerMove,
1243
+ onPointerUp: endDrag,
1244
+ onPointerCancel: endDrag,
1245
+ "data-dragging": dragStart.current !== null || void 0,
1246
+ children: /* @__PURE__ */ jsx(
1247
+ "div",
1248
+ {
1249
+ className: "ansh-carousel__track",
1250
+ style: {
1251
+ transform: `translate3d(${-active * 100 + dragPercent}%, 0, 0)`,
1252
+ // Suppress the transition mid-drag so the track tracks the finger exactly.
1253
+ transition: dragStart.current !== null ? "none" : void 0
1254
+ },
1255
+ children: items.map((item, i) => /* @__PURE__ */ jsx(
1256
+ "div",
1257
+ {
1258
+ className: "ansh-carousel__slide",
1259
+ id: `${baseId}-slide-${i}`,
1260
+ role: "group",
1261
+ "aria-roledescription": "slide",
1262
+ "aria-label": `${i + 1} of ${count}`,
1263
+ "aria-hidden": i === active ? void 0 : "true",
1264
+ ...inertProps(i !== active),
1265
+ children: item
1266
+ },
1267
+ i
1268
+ ))
1269
+ }
1270
+ )
1271
+ }
1272
+ ),
1273
+ showArrows && count > 1 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1274
+ /* @__PURE__ */ jsx(
1275
+ "button",
1276
+ {
1277
+ type: "button",
1278
+ className: "ansh-carousel__arrow ansh-carousel__arrow--prev",
1279
+ onClick: () => goTo(active - 1),
1280
+ disabled: atStart,
1281
+ "aria-label": "Previous slide",
1282
+ children: "\u2039"
1283
+ }
1284
+ ),
1285
+ /* @__PURE__ */ jsx(
1286
+ "button",
1287
+ {
1288
+ type: "button",
1289
+ className: "ansh-carousel__arrow ansh-carousel__arrow--next",
1290
+ onClick: () => goTo(active + 1),
1291
+ disabled: atEnd,
1292
+ "aria-label": "Next slide",
1293
+ children: "\u203A"
1294
+ }
1295
+ )
1296
+ ] }) : null,
1297
+ showDots && count > 1 || autoPlay ? /* @__PURE__ */ jsxs("div", { className: "ansh-carousel__controls", children: [
1298
+ autoPlay ? /* @__PURE__ */ jsx(
1299
+ "button",
1300
+ {
1301
+ type: "button",
1302
+ className: "ansh-carousel__pause",
1303
+ onClick: () => setPlaying((on) => !on),
1304
+ "aria-label": playing ? "Pause carousel" : "Play carousel",
1305
+ children: playing ? "\u275A\u275A" : "\u25B6"
1306
+ }
1307
+ ) : null,
1308
+ showDots && count > 1 ? /* @__PURE__ */ jsx("div", { className: "ansh-carousel__dots", children: items.map((_, i) => /* @__PURE__ */ jsx(
1309
+ "button",
1310
+ {
1311
+ type: "button",
1312
+ className: "ansh-carousel__dot",
1313
+ "aria-label": `Go to slide ${i + 1}`,
1314
+ "aria-current": i === active ? "true" : void 0,
1315
+ onClick: () => goTo(i)
1316
+ },
1317
+ i
1318
+ )) }) : null
1319
+ ] }) : null
1320
+ ]
1321
+ }
1322
+ );
1323
+ }
808
1324
  var ICONS = {
809
1325
  info: /* @__PURE__ */ jsxs(
810
1326
  "svg",
@@ -951,6 +1467,6 @@ function Callout({ label, tone = "info", icon, className, children }) {
951
1467
  }
952
1468
  var VERSION = "0.1.0";
953
1469
 
954
- export { Alert, AnimatedGradient, AuroraBackground, Banner, BentoGrid, BentoItem, Button, Callout, Constellation, Dock, FAQAccordion, Fireflies, GlowCard, IconButton, LiquidBlob, LoadingDots, MeshGradient, MeteorShower, NoiseLayer, NumberTicker, ParticleField, PricingTable, Rain, ShinyText, Skeleton, Snow, Spinner, Spotlight, SpotlightCard, TiltCard3D, ToastProvider, Typewriter, VERSION, Waves, createEffectComponent, useToast };
1470
+ export { Alert, AnimatedGradient, AuroraBackground, Banner, BeforeAfter, BentoGrid, BentoItem, Button, Callout, CardStack, Carousel, Constellation, DeviceMockup, Dock, FAQAccordion, Fireflies, FloatingGeometry, GlowCard, IconButton, LightRays, LiquidBlob, LoadingDots, MeshGradient, MeteorShower, NoiseLayer, NumberTicker, Orbit, ParticleField, PowderExplosion, PricingTable, Rain, ScrambleText, ShinyText, Skeleton, Smoke, Snow, Spinner, Spotlight, SpotlightCard, StrangeAttractor, Swarm, TextRotate, TiltCard3D, ToastProvider, Typewriter, VERSION, Waves, createEffectComponent, useToast };
955
1471
  //# sourceMappingURL=index.js.map
956
1472
  //# sourceMappingURL=index.js.map