@xwadex/fesd-next 0.3.4-8 → 0.3.4-9

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 (182) hide show
  1. package/dist/components/index.d.ts +186 -5
  2. package/dist/components/index.js +9561 -5
  3. package/dist/components/index.js.map +1 -0
  4. package/dist/hooks/index.d.ts +68 -10
  5. package/dist/hooks/index.js +9243 -10
  6. package/dist/hooks/index.js.map +1 -0
  7. package/dist/index.d.ts +55 -5
  8. package/dist/index.js +36374 -5
  9. package/dist/index.js.map +1 -0
  10. package/dist/shadcns/index.d.ts +490 -48
  11. package/dist/shadcns/index.js +32495 -48
  12. package/dist/shadcns/index.js.map +1 -0
  13. package/dist/types/index.d.ts +17 -2
  14. package/dist/types/index.js +3 -2
  15. package/dist/types/index.js.map +1 -0
  16. package/dist/useAnchors-BzgJT2J9.d.ts +78 -0
  17. package/dist/utils/index.d.ts +12 -10
  18. package/dist/utils/index.js +56 -63
  19. package/dist/utils/index.js.map +1 -0
  20. package/package.json +9 -7
  21. package/dist/components/anchors/anchors.d.ts +0 -14
  22. package/dist/components/anchors/anchors.js +0 -23
  23. package/dist/components/anchors/index.d.ts +0 -1
  24. package/dist/components/anchors/index.js +0 -1
  25. package/dist/components/embla-carousels/embla-carousels-hooks.d.ts +0 -36
  26. package/dist/components/embla-carousels/embla-carousels-hooks.js +0 -83
  27. package/dist/components/embla-carousels/embla-carousels.d.ts +0 -23
  28. package/dist/components/embla-carousels/embla-carousels.js +0 -58
  29. package/dist/components/embla-carousels/index.d.ts +0 -2
  30. package/dist/components/embla-carousels/index.js +0 -2
  31. package/dist/components/emblas/embla-container.d.ts +0 -8
  32. package/dist/components/emblas/embla-container.js +0 -12
  33. package/dist/components/emblas/embla-context.d.ts +0 -21
  34. package/dist/components/emblas/embla-context.js +0 -12
  35. package/dist/components/emblas/embla.d.ts +0 -20
  36. package/dist/components/emblas/embla.js +0 -124
  37. package/dist/components/emblas/emblas-pagination.d.ts +0 -11
  38. package/dist/components/emblas/emblas-pagination.js +0 -89
  39. package/dist/components/emblas/index.d.ts +0 -4
  40. package/dist/components/emblas/index.js +0 -4
  41. package/dist/components/scroll-containers/index.d.ts +0 -3
  42. package/dist/components/scroll-containers/index.js +0 -3
  43. package/dist/components/scroll-containers/lenis-scroll.d.ts +0 -20
  44. package/dist/components/scroll-containers/lenis-scroll.js +0 -65
  45. package/dist/components/scroll-containers/native-scroll.d.ts +0 -6
  46. package/dist/components/scroll-containers/native-scroll.js +0 -23
  47. package/dist/components/scroll-containers/scroll-containers.d.ts +0 -25
  48. package/dist/components/scroll-containers/scroll-containers.js +0 -46
  49. package/dist/components/tests/index.d.ts +0 -1
  50. package/dist/components/tests/index.js +0 -1
  51. package/dist/components/tests/tests.d.ts +0 -4
  52. package/dist/components/tests/tests.js +0 -9
  53. package/dist/hooks/useAnchors.d.ts +0 -73
  54. package/dist/hooks/useAnchors.js +0 -203
  55. package/dist/hooks/useAsyncFetcher.d.ts +0 -11
  56. package/dist/hooks/useAsyncFetcher.js +0 -39
  57. package/dist/hooks/useCookies.d.ts +0 -6
  58. package/dist/hooks/useCookies.js +0 -42
  59. package/dist/hooks/useDebounce.d.ts +0 -7
  60. package/dist/hooks/useDebounce.js +0 -15
  61. package/dist/hooks/useDebounceValue.d.ts +0 -1
  62. package/dist/hooks/useDebounceValue.js +0 -16
  63. package/dist/hooks/useDragResize.d.ts +0 -22
  64. package/dist/hooks/useDragResize.js +0 -74
  65. package/dist/hooks/useEffectLeave.d.ts +0 -1
  66. package/dist/hooks/useEffectLeave.js +0 -11
  67. package/dist/hooks/useEffectOne.d.ts +0 -1
  68. package/dist/hooks/useEffectOne.js +0 -11
  69. package/dist/hooks/useHash.d.ts +0 -1
  70. package/dist/hooks/useHash.js +0 -18
  71. package/dist/hooks/useLocations.d.ts +0 -13
  72. package/dist/hooks/useLocations.js +0 -24
  73. package/dist/hooks/useMounted.d.ts +0 -3
  74. package/dist/hooks/useMounted.js +0 -6
  75. package/dist/shadcns/components/ui/accordion.d.ts +0 -7
  76. package/dist/shadcns/components/ui/accordion.js +0 -18
  77. package/dist/shadcns/components/ui/alert-dialog.d.ts +0 -14
  78. package/dist/shadcns/components/ui/alert-dialog.js +0 -38
  79. package/dist/shadcns/components/ui/alert.d.ts +0 -9
  80. package/dist/shadcns/components/ui/alert.js +0 -25
  81. package/dist/shadcns/components/ui/aspect-ratio.d.ts +0 -3
  82. package/dist/shadcns/components/ui/aspect-ratio.js +0 -7
  83. package/dist/shadcns/components/ui/avatar.d.ts +0 -6
  84. package/dist/shadcns/components/ui/avatar.js +0 -14
  85. package/dist/shadcns/components/ui/badge.d.ts +0 -9
  86. package/dist/shadcns/components/ui/badge.js +0 -23
  87. package/dist/shadcns/components/ui/breadcrumb.d.ts +0 -11
  88. package/dist/shadcns/components/ui/breadcrumb.js +0 -27
  89. package/dist/shadcns/components/ui/button-group.d.ts +0 -11
  90. package/dist/shadcns/components/ui/button-group.js +0 -26
  91. package/dist/shadcns/components/ui/button.d.ts +0 -10
  92. package/dist/shadcns/components/ui/button.js +0 -31
  93. package/dist/shadcns/components/ui/calendar.d.ts +0 -8
  94. package/dist/shadcns/components/ui/calendar.js +0 -73
  95. package/dist/shadcns/components/ui/card.d.ts +0 -9
  96. package/dist/shadcns/components/ui/card.js +0 -25
  97. package/dist/shadcns/components/ui/carousel.d.ts +0 -19
  98. package/dist/shadcns/components/ui/carousel.js +0 -91
  99. package/dist/shadcns/components/ui/chart.d.ts +0 -40
  100. package/dist/shadcns/components/ui/chart.js +0 -114
  101. package/dist/shadcns/components/ui/checkbox.d.ts +0 -4
  102. package/dist/shadcns/components/ui/checkbox.js +0 -9
  103. package/dist/shadcns/components/ui/collapsible.d.ts +0 -5
  104. package/dist/shadcns/components/ui/collapsible.js +0 -13
  105. package/dist/shadcns/components/ui/command.d.ts +0 -18
  106. package/dist/shadcns/components/ui/command.js +0 -33
  107. package/dist/shadcns/components/ui/context-menu.d.ts +0 -25
  108. package/dist/shadcns/components/ui/context-menu.js +0 -51
  109. package/dist/shadcns/components/ui/dialog.d.ts +0 -15
  110. package/dist/shadcns/components/ui/dialog.js +0 -36
  111. package/dist/shadcns/components/ui/drawer.d.ts +0 -13
  112. package/dist/shadcns/components/ui/drawer.js +0 -35
  113. package/dist/shadcns/components/ui/dropdown-menu.d.ts +0 -25
  114. package/dist/shadcns/components/ui/dropdown-menu.js +0 -51
  115. package/dist/shadcns/components/ui/field.d.ts +0 -24
  116. package/dist/shadcns/components/ui/field.js +0 -75
  117. package/dist/shadcns/components/ui/form.d.ts +0 -24
  118. package/dist/shadcns/components/ui/form.js +0 -56
  119. package/dist/shadcns/components/ui/hover-card.d.ts +0 -6
  120. package/dist/shadcns/components/ui/hover-card.js +0 -14
  121. package/dist/shadcns/components/ui/input-otp.d.ts +0 -11
  122. package/dist/shadcns/components/ui/input-otp.js +0 -21
  123. package/dist/shadcns/components/ui/input.d.ts +0 -3
  124. package/dist/shadcns/components/ui/input.js +0 -6
  125. package/dist/shadcns/components/ui/item.d.ts +0 -23
  126. package/dist/shadcns/components/ui/item.js +0 -65
  127. package/dist/shadcns/components/ui/label.d.ts +0 -4
  128. package/dist/shadcns/components/ui/label.js +0 -8
  129. package/dist/shadcns/components/ui/menubar.d.ts +0 -26
  130. package/dist/shadcns/components/ui/menubar.js +0 -54
  131. package/dist/shadcns/components/ui/native-select.d.ts +0 -7
  132. package/dist/shadcns/components/ui/native-select.js +0 -13
  133. package/dist/shadcns/components/ui/navigation-menu.d.ts +0 -14
  134. package/dist/shadcns/components/ui/navigation-menu.js +0 -31
  135. package/dist/shadcns/components/ui/pagination.d.ts +0 -13
  136. package/dist/shadcns/components/ui/pagination.js +0 -28
  137. package/dist/shadcns/components/ui/popover.d.ts +0 -7
  138. package/dist/shadcns/components/ui/popover.js +0 -17
  139. package/dist/shadcns/components/ui/progress.d.ts +0 -4
  140. package/dist/shadcns/components/ui/progress.js +0 -8
  141. package/dist/shadcns/components/ui/radio-group.d.ts +0 -5
  142. package/dist/shadcns/components/ui/radio-group.js +0 -12
  143. package/dist/shadcns/components/ui/resizable.d.ts +0 -8
  144. package/dist/shadcns/components/ui/resizable.js +0 -15
  145. package/dist/shadcns/components/ui/scroll-area.d.ts +0 -5
  146. package/dist/shadcns/components/ui/scroll-area.js +0 -11
  147. package/dist/shadcns/components/ui/select.d.ts +0 -15
  148. package/dist/shadcns/components/ui/select.js +0 -38
  149. package/dist/shadcns/components/ui/separator.d.ts +0 -4
  150. package/dist/shadcns/components/ui/separator.js +0 -8
  151. package/dist/shadcns/components/ui/sheet.d.ts +0 -13
  152. package/dist/shadcns/components/ui/sheet.js +0 -40
  153. package/dist/shadcns/components/ui/sidebar.d.ts +0 -66
  154. package/dist/shadcns/components/ui/sidebar.js +0 -204
  155. package/dist/shadcns/components/ui/skeleton.d.ts +0 -2
  156. package/dist/shadcns/components/ui/skeleton.js +0 -6
  157. package/dist/shadcns/components/ui/slider.d.ts +0 -4
  158. package/dist/shadcns/components/ui/slider.js +0 -10
  159. package/dist/shadcns/components/ui/sonner.d.ts +0 -3
  160. package/dist/shadcns/components/ui/sonner.js +0 -13
  161. package/dist/shadcns/components/ui/switch.d.ts +0 -4
  162. package/dist/shadcns/components/ui/switch.js +0 -8
  163. package/dist/shadcns/components/ui/table.d.ts +0 -10
  164. package/dist/shadcns/components/ui/table.js +0 -28
  165. package/dist/shadcns/components/ui/tabs.d.ts +0 -7
  166. package/dist/shadcns/components/ui/tabs.js +0 -17
  167. package/dist/shadcns/components/ui/textarea.d.ts +0 -3
  168. package/dist/shadcns/components/ui/textarea.js +0 -6
  169. package/dist/shadcns/components/ui/toggle-group.d.ts +0 -7
  170. package/dist/shadcns/components/ui/toggle-group.js +0 -20
  171. package/dist/shadcns/components/ui/toggle.d.ts +0 -9
  172. package/dist/shadcns/components/ui/toggle.js +0 -26
  173. package/dist/shadcns/components/ui/tooltip.d.ts +0 -7
  174. package/dist/shadcns/components/ui/tooltip.js +0 -17
  175. package/dist/shadcns/hooks/use-mobile.d.ts +0 -1
  176. package/dist/shadcns/hooks/use-mobile.js +0 -15
  177. package/dist/shadcns/lib/utils.d.ts +0 -2
  178. package/dist/shadcns/lib/utils.js +0 -5
  179. package/dist/types/components.type.d.ts +0 -9
  180. package/dist/types/components.type.js +0 -1
  181. package/dist/types/shadcns.type.d.ts +0 -6
  182. package/dist/types/shadcns.type.js +0 -2
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import { EmblaOptionsType } from "embla-carousel";
3
- import type { AutoplayOptionsType } from "embla-carousel-autoplay";
4
- export interface PropsTypes extends EmblaOptionsType {
5
- children?: React.ReactNode;
6
- className?: string;
7
- options?: EmblaOptionsType;
8
- datas?: any;
9
- autoplayEnabled?: boolean;
10
- autoplayOptions?: AutoplayOptionsType;
11
- setApi?: any;
12
- setMethods?: any;
13
- setRef?: any;
14
- style?: any;
15
- controls?: any;
16
- plugins?: any;
17
- onScrolled?: (index: number) => void;
18
- }
19
- declare const Embla: React.FC<PropsTypes>;
20
- export default Embla;
@@ -1,124 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useCallback, useEffect, useMemo, useState } from "react";
3
- import useEmblaCarousel from "embla-carousel-react";
4
- import { cn } from "../../shadcns/index.js";
5
- import { CarouselContextProvider } from "./embla-context";
6
- import Autoplay from "embla-carousel-autoplay";
7
- const Embla = ({ children, className, options, datas, autoplayEnabled = true, autoplayOptions, setApi, setMethods, setRef, style, controls, onScrolled }) => {
8
- const { loop, duration = 40 } = options || {};
9
- const autoplaySetting = useMemo(() => {
10
- if (!autoplayEnabled)
11
- return;
12
- return [Autoplay({ playOnInit: true, delay: 5000, stopOnInteraction: false, ...autoplayOptions })];
13
- }, [autoplayEnabled, autoplayOptions]);
14
- const [emblaRef, emblaApi] = useEmblaCarousel({ ...options, loop, duration }, autoplaySetting);
15
- const [selectIndex, setSelectIndex] = useState(0);
16
- const [scrollSnaps, setScrollSnaps] = useState([]);
17
- const nextScroll = useCallback(() => {
18
- if (!emblaApi)
19
- return;
20
- const { canScrollNext, scrollNext } = emblaApi;
21
- canScrollNext() && scrollNext() && autoPlayReset();
22
- }, [emblaApi]);
23
- const prevScroll = useCallback(() => {
24
- if (!emblaApi)
25
- return;
26
- const { canScrollPrev, scrollPrev } = emblaApi;
27
- canScrollPrev() && scrollPrev() && autoPlayReset();
28
- }, [emblaApi]);
29
- const scrollToIndex = useCallback((index) => {
30
- if (!emblaApi || typeof index !== "number")
31
- return;
32
- emblaApi.scrollTo(index);
33
- }, [emblaApi]);
34
- // 自動輪播啟動
35
- const autoPlayReset = useCallback(() => {
36
- if (!emblaApi)
37
- return;
38
- // console.log("autoplay.reset");
39
- const autoplay = emblaApi?.plugins()?.autoplay;
40
- autoplay && autoplay.reset();
41
- }, [emblaApi]);
42
- const autoPlayPlay = useCallback(() => {
43
- if (!emblaApi)
44
- return;
45
- // console.log("autoplay.play");
46
- if (!emblaApi.canScrollNext())
47
- return; // 防呆
48
- const autoplay = emblaApi?.plugins()?.autoplay;
49
- autoplay && autoplay.play();
50
- }, [emblaApi]);
51
- // 自動輪播暫停
52
- const autoPlayStop = useCallback(() => {
53
- if (!emblaApi)
54
- return;
55
- // console.log("autoplay.stop");
56
- const autoplay = emblaApi?.plugins()?.autoplay;
57
- autoplay && autoplay.stop();
58
- }, [emblaApi]);
59
- const contextValue = useMemo(() => ({
60
- datas,
61
- emblaRef,
62
- emblaApi,
63
- selectIndex,
64
- scrollSnaps,
65
- nextScroll,
66
- prevScroll,
67
- scrollToIndex,
68
- autoPlayReset,
69
- autoPlayStop,
70
- autoPlayPlay
71
- }), [
72
- datas,
73
- emblaRef,
74
- emblaApi,
75
- selectIndex,
76
- scrollSnaps,
77
- nextScroll,
78
- prevScroll,
79
- scrollToIndex,
80
- autoPlayReset,
81
- autoPlayStop,
82
- autoPlayPlay
83
- ]);
84
- const onInit = useCallback((emblaApi) => {
85
- const snapList = emblaApi.scrollSnapList();
86
- setScrollSnaps(snapList);
87
- }, []);
88
- const onSelectEvent = (emblaApi) => {
89
- emblaApi.on("select", () => {
90
- onScrolled?.(emblaApi.selectedScrollSnap());
91
- setSelectIndex(emblaApi.selectedScrollSnap());
92
- });
93
- };
94
- useEffect(() => {
95
- if (!emblaApi)
96
- return;
97
- setRef?.(emblaRef);
98
- setApi?.(emblaApi);
99
- setMethods?.({});
100
- onInit(emblaApi);
101
- onSelectEvent(emblaApi);
102
- }, [emblaApi]);
103
- return (_jsx(CarouselContextProvider, { value: contextValue, children: _jsxs("div", { "data-component": "embla-root", className: cn("relative w-full"), children: [_jsx("div", { className: cn("overflow-hidden", "w-full", className), ref: emblaRef, style: style, children: children }), Array.isArray(controls) ? controls.map((ctrl, i) => (_jsx(React.Fragment, { children: ctrl }, i))) : controls] }) })
104
- // <CarouselContextProvider
105
- // value={contextValue}
106
- // >
107
- // <div
108
- // data-component="embla-root"
109
- // className={cn(
110
- // "overflow-hidden",
111
- // "relative",
112
- // "w-full",
113
- // className
114
- // )}
115
- // ref={emblaRef}
116
- // style={style}
117
- // >
118
- // {children}
119
- // </div>
120
- // </CarouselContextProvider>
121
- );
122
- };
123
- Embla.displayName = "Embla";
124
- export default Embla;
@@ -1,11 +0,0 @@
1
- type EmblaPaginationPropsTypes = {
2
- color?: "black" | "white" | string;
3
- align?: "start" | "center" | "end";
4
- className?: string;
5
- maxDots?: number;
6
- dynamic?: boolean;
7
- swiperNumber?: boolean;
8
- style?: string;
9
- };
10
- export declare const EmblaPagination: React.FC<EmblaPaginationPropsTypes>;
11
- export default EmblaPagination;
@@ -1,89 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { cn } from "../../shadcns/index.js";
3
- import { useCarouselContext } from "./embla-context";
4
- import { useEffect, useState } from "react";
5
- export const EmblaPagination = ({ color = "black", align, className, maxDots = 5, dynamic = true, swiperNumber = true, }) => {
6
- const { selectIndex, scrollToIndex, scrollSnaps, autoPlayReset, emblaApi } = useCarouselContext();
7
- // 點點計算
8
- const total = scrollSnaps?.length ?? 0;
9
- const active = Math.max(0, Math.min(selectIndex ?? 0, Math.max(0, total - 1)));
10
- // 顯示數字
11
- const paginationNumber = `${Number(active + 1) < 10 ? "0" + Number(active + 1) : Number(active + 1)}`;
12
- const isWhite = color === "white";
13
- // 點擊事件
14
- const clickEvent = (index) => {
15
- scrollToIndex(index); // 移動到當澤輪播
16
- autoPlayReset(); // 如果有開啟自動輪播要重置輪播時間
17
- };
18
- // 點點是否為當前
19
- const isSelected = (index) => {
20
- return index === selectIndex;
21
- };
22
- // -- 動態點點 Start --
23
- const [selectedIndex, setSelectedIndex] = useState(0);
24
- const [slideCount, setSlideCount] = useState(0);
25
- useEffect(() => {
26
- if (!emblaApi || !dynamic)
27
- return;
28
- const update = () => {
29
- setSelectedIndex(emblaApi.selectedScrollSnap());
30
- setSlideCount(emblaApi.scrollSnapList().length);
31
- };
32
- emblaApi.on('select', update);
33
- emblaApi.on('reInit', update); // 重新初始化時也更新
34
- update();
35
- return () => {
36
- emblaApi.off('select', update);
37
- emblaApi.off('reInit', update);
38
- };
39
- }, [emblaApi, dynamic]);
40
- const getVisibleBullets = () => {
41
- const total = slideCount ?? 0;
42
- if (total === 0)
43
- return [];
44
- const limit = Math.max(1, Number(maxDots));
45
- const windowSize = Math.min(total, limit);
46
- const left = Math.floor((windowSize - 1) / 2);
47
- const right = windowSize - left - 1;
48
- let start = selectedIndex - left;
49
- let end = selectedIndex + right;
50
- if (start < 0) {
51
- end = Math.min(end - start, total - 1);
52
- start = 0;
53
- }
54
- if (end > total - 1) {
55
- start = Math.max(0, start - (end - (total - 1)));
56
- end = total - 1;
57
- }
58
- return Array.from({ length: end - start + 1 }, (_, i) => start + i);
59
- };
60
- const visibleRange = getVisibleBullets();
61
- // -- 動態點點 End --
62
- // 是否開啟動態點點決定點點跑陣列的方式
63
- const dots = dynamic ? visibleRange : scrollSnaps?.map((_, i) => i) ?? [];
64
- // WE - 頁碼
65
- const swiperSnap = [
66
- "text-[16px]",
67
- "font-semibold",
68
- " leading-[1.4]",
69
- ];
70
- const paginationColorStyle = {
71
- "black": "#000",
72
- "white": "#fff",
73
- }[color] || `${color}`;
74
- const paginationColorStyle2 = {
75
- "--pagination-color": paginationColorStyle,
76
- };
77
- return (_jsxs("div", { "data-compoents": "emblas-pagination", className: cn("flex", "items-center", "gap-7.25", align === "center" && [
78
- "justify-center",
79
- ], className), style: paginationColorStyle2, children: [swiperNumber &&
80
- _jsx("div", { className: cn(swiperSnap, "relative", "after:absolute", "after:top-1/2", "after:right-[-15px]", "after:-translate-y-1/2", "after:block",
81
- // "after:bg-black",
82
- "after:bg-(--pagination-color)", "after:w-0.5", "after:h-3.75", "after:opacity-20", isWhite && [
83
- "after:bg-white",
84
- ]), children: paginationNumber }), _jsx("div", { className: cn("flex", "flex-wrap", "justify-end", "items-center", "gap-y-0", "gap-x-2.5", "**:data-[component='emblas-pagination-dots']:bg-(--pagination-color)", isWhite && [
85
- "**:data-[component='emblas-pagination-dots']:bg-white",
86
- ]), children: dots.map((index) => (_jsx("div", { "data-component": "emblas-pagination-dots", onClick: () => clickEvent(index), className: cn("w-1.5", "h-1.5", "rounded-full", "cursor-pointer", "opacity-30", isSelected(index) && ("opacity-100")) }, index))) })] }));
87
- };
88
- EmblaPagination.displayName = "EmblaPagination";
89
- export default EmblaPagination;
@@ -1,4 +0,0 @@
1
- export * from "./embla-context";
2
- export { default as Embla } from "./embla";
3
- export { default as EmblaContainer } from "./embla-container";
4
- export { default as EmblaPagination } from "./emblas-pagination";
@@ -1,4 +0,0 @@
1
- export * from "./embla-context";
2
- export { default as Embla } from "./embla";
3
- export { default as EmblaContainer } from "./embla-container";
4
- export { default as EmblaPagination } from "./emblas-pagination";
@@ -1,3 +0,0 @@
1
- export * from "./native-scroll";
2
- export * from "./lenis-scroll";
3
- export * from "./scroll-containers";
@@ -1,3 +0,0 @@
1
- export * from "./native-scroll";
2
- export * from "./lenis-scroll";
3
- export * from "./scroll-containers";
@@ -1,20 +0,0 @@
1
- import Lenis from 'lenis';
2
- import type { LenisOptions } from "lenis";
3
- export interface LenisScrollProps {
4
- root?: boolean | "asChild";
5
- name?: string;
6
- options?: LenisOptions;
7
- children?: React.ReactNode;
8
- className?: string;
9
- }
10
- export declare const LenisScroll: React.FC<LenisScrollProps>;
11
- export declare const LenisRootScroll: React.FC<LenisScrollProps>;
12
- type LenisScrollContainerProps = Omit<LenisScrollProps, "root">;
13
- export declare const LenisContainerScroll: React.FC<LenisScrollContainerProps>;
14
- interface LenisStores {
15
- root?: Lenis | null;
16
- }
17
- export declare const useLenisStores: import("zustand").UseBoundStore<import("zustand").StoreApi<LenisStores>>;
18
- export declare const setRootLenis: (lenis: Lenis) => void;
19
- export declare const getRootLenis: () => LenisStores;
20
- export {};
@@ -1,65 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- // update: 2025.11.12
3
- // version: 0.0.1.bate
4
- // dev: wade
5
- import { memo, useEffect, useEffectEvent, useLayoutEffect, useRef, useState } from "react";
6
- import { ReactLenis, useLenis, } from "lenis/react";
7
- import Lenis from 'lenis';
8
- import { create } from "zustand";
9
- import { ScrollContainerContext, setScrollContainerStore } from "./scroll-containers";
10
- import { cn } from "../../shadcns/index.js";
11
- export const LenisScroll = memo((props) => {
12
- return (_jsxs(_Fragment, { children: [props?.root == true
13
- ? _jsx(LenisRootScroll, { ...props })
14
- : _jsx(LenisContainerScroll, { ...props }), "\t"] }));
15
- });
16
- export const LenisRootScroll = memo(({ root, options }) => {
17
- const lenis = useLenis();
18
- const lenisRef = useRef(null);
19
- const registerRootLenis = useEffectEvent(() => {
20
- if (!root == true || !lenis)
21
- return;
22
- setRootLenis(lenis);
23
- });
24
- useEffect(() => { registerRootLenis(); }, [lenis]);
25
- return (_jsx(ReactLenis, { ref: lenisRef, root: root, options: {
26
- autoRaf: true,
27
- lerp: 0.0005,
28
- duration: 1.5,
29
- smoothWheel: true,
30
- ...options
31
- } }));
32
- });
33
- export const LenisContainerScroll = memo(({ name, className, children, options, ...restProps }) => {
34
- const [containerRef, setContainerRef] = useState();
35
- const wrapperRef = useRef(null);
36
- const contentRef = useRef(null);
37
- const initLenis = useEffectEvent(() => {
38
- if (!wrapperRef.current || !contentRef.current || !name)
39
- return;
40
- const lenis = new Lenis({
41
- wrapper: wrapperRef.current,
42
- content: contentRef.current,
43
- autoRaf: true,
44
- ...options
45
- });
46
- setContainerRef(contentRef);
47
- setScrollContainerStore({ name, action: "add", node: lenis });
48
- return () => {
49
- setScrollContainerStore({ name, action: "remove" });
50
- lenis?.destroy?.();
51
- };
52
- });
53
- useLayoutEffect(() => {
54
- const effect = initLenis();
55
- return effect;
56
- }, [name, options]);
57
- return (_jsx("div", { ref: wrapperRef, "data-lenis-scroll": name, className: cn("group overflow-hidden", className), ...restProps, children: _jsx("div", { ref: contentRef, className: cn("h-full", "relative", "will-change-transform overscroll-contain"), children: _jsx(ScrollContainerContext, { value: { containerRef }, children: children }) }) }));
58
- });
59
- export const useLenisStores = create()(() => ({
60
- root: null,
61
- }));
62
- export const setRootLenis = (lenis) => useLenisStores.setState(() => {
63
- return { root: lenis };
64
- });
65
- export const getRootLenis = () => useLenisStores.getState();
@@ -1,6 +0,0 @@
1
- type PropsType<T extends React.ElementType = "div"> = React.ComponentProps<T> & {
2
- name: string;
3
- tag?: T;
4
- };
5
- export declare const NativeScroll: import("react").MemoExoticComponent<(<T extends React.ElementType = "div">({ tag: Component, name, className, ...restProps }: PropsType<T>) => import("react/jsx-runtime").JSX.Element)>;
6
- export {};
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- // update: 2025.11.12
3
- // version: 0.0.1.bate
4
- // dev: wade
5
- import { memo, useEffectEvent, useEffect, useRef, useState } from "react";
6
- import { ScrollContainerContext, setScrollContainerStore } from "./scroll-containers";
7
- import { cn } from "../../shadcns/index.js";
8
- export const NativeScroll = memo(({ tag: Component = "div", name, className, ...restProps }) => {
9
- const componentRef = useRef(null);
10
- const [containerRef, setContainerRef] = useState();
11
- const nativeEffect = useEffectEvent(() => {
12
- if (!componentRef.current)
13
- return;
14
- setContainerRef(componentRef);
15
- setScrollContainerStore({ name, action: "add", node: componentRef.current });
16
- return () => { setScrollContainerStore({ name, action: "remove" }); };
17
- });
18
- useEffect(() => {
19
- const effect = nativeEffect();
20
- return effect;
21
- }, [componentRef?.current]);
22
- return (_jsx(ScrollContainerContext, { value: { containerRef }, children: _jsx(Component, { ref: componentRef, "data-native-scroll": name, className: cn("overflow-auto", "will-change-transform", className), ...restProps }) }));
23
- });
@@ -1,25 +0,0 @@
1
- import Lenis from "lenis";
2
- import { LenisScrollProps } from "./lenis-scroll";
3
- type PropsType<T extends React.ElementType = "div"> = React.ComponentProps<T> & LenisScrollProps & {
4
- name: string;
5
- lenis?: boolean;
6
- };
7
- export declare const ScrollContainer: <T extends React.ElementType = "div">({ name, lenis, ...props }: PropsType<T>) => import("react/jsx-runtime").JSX.Element;
8
- export interface ScrollContainerContext {
9
- containerRef: React.RefObject<HTMLDivElement | null> | undefined;
10
- }
11
- export declare const ScrollContainerContext: import("react").Context<ScrollContainerContext | null>;
12
- export declare const useScrollContainerContext: () => ScrollContainerContext;
13
- export interface ScrollContainersStores {
14
- containers: Map<string, Lenis | HTMLDivElement | null>;
15
- }
16
- export declare const useScrollContainersStores: import("zustand").UseBoundStore<import("zustand").StoreApi<ScrollContainersStores>>;
17
- export declare const getScrollContainer: (name: string) => HTMLDivElement | Lenis | null | undefined;
18
- export declare const getScrollContainerStores: () => ScrollContainersStores;
19
- export interface SetStoreOptions {
20
- name: string;
21
- node?: Lenis | HTMLDivElement | null;
22
- action: "add" | "remove";
23
- }
24
- export declare const setScrollContainerStore: (options: SetStoreOptions) => void;
25
- export {};
@@ -1,46 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- // update: 2025.11.12
3
- // version: 0.0.1.bate
4
- // dev: wade
5
- import { createContext, use } from "react";
6
- import Lenis from "lenis";
7
- import { create } from "zustand";
8
- import { NativeScroll } from "./native-scroll";
9
- import { LenisScroll } from "./lenis-scroll";
10
- export const ScrollContainer = ({ name, lenis = false, ...props }) => {
11
- return (_jsx(_Fragment, { children: lenis
12
- ? _jsx(LenisScroll, { name: name, ...props })
13
- : _jsx(NativeScroll, { name: name, ...props }) }));
14
- };
15
- export const ScrollContainerContext = createContext(null);
16
- export const useScrollContainerContext = () => {
17
- const context = use(ScrollContainerContext);
18
- if (!context)
19
- throw new Error("useScrollContainerContext must be used inside ScrollContainerProvider");
20
- return context;
21
- };
22
- export const useScrollContainersStores = create()(() => ({
23
- containers: new Map(),
24
- }));
25
- export const getScrollContainer = (name) => {
26
- const stores = useScrollContainersStores.getState();
27
- return stores.containers?.get(name);
28
- };
29
- export const getScrollContainerStores = () => useScrollContainersStores.getState();
30
- export const setScrollContainerStore = (options) => {
31
- const { action, name, node } = options;
32
- useScrollContainersStores.setState(stores => {
33
- const containerDom = stores.containers?.get(name);
34
- const isContainerNode = node instanceof Lenis || node instanceof HTMLDivElement;
35
- if (action == "add" && isContainerNode) {
36
- if (containerDom == node)
37
- return stores;
38
- // console.log("node", node, name);
39
- stores.containers?.set(name, node);
40
- }
41
- else if (action == "remove" && containerDom) {
42
- stores.containers?.delete(name);
43
- }
44
- return { containers: stores.containers };
45
- });
46
- };
@@ -1 +0,0 @@
1
- export { default as Tests } from "./tests";
@@ -1 +0,0 @@
1
- export { default as Tests } from "./tests";
@@ -1,4 +0,0 @@
1
- export interface PropsTypes {
2
- }
3
- declare const Tests: React.FC<PropsTypes>;
4
- export default Tests;
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button } from "../../shadcns/index.js";
3
- import { CarouselPrevious } from "../../shadcns/index.js";
4
- import { Carousel } from "../../shadcns/index.js";
5
- const Tests = () => {
6
- return (_jsxs(_Fragment, { children: [_jsx(Carousel, { children: _jsx(CarouselPrevious, {}) }), _jsx(Button, { children: "test123133232" })] }));
7
- };
8
- Tests.displayName = "Tests";
9
- export default Tests;
@@ -1,73 +0,0 @@
1
- import type { AnimationPlaybackControlsWithThen, Easing } from "motion/react";
2
- import Lenis from "lenis";
3
- export interface AnimateOptions {
4
- duration?: number;
5
- delay?: number;
6
- ease?: Easing | Easing[] | undefined;
7
- onScroll?: (lenis?: Lenis) => void;
8
- onScrolling?: (value: number) => void;
9
- onScrolled?: (lenis?: Lenis) => void;
10
- }
11
- export interface AnchorOptions extends AnimateOptions {
12
- anchor: string;
13
- container?: string;
14
- offseters?: string | string[];
15
- direction?: "x" | "y";
16
- align?: "start" | "center" | "end";
17
- offset?: number;
18
- }
19
- export interface ScrollOptions extends AnimateOptions {
20
- controllerKey: string;
21
- containerDom: HTMLElement | Window;
22
- anchorScrollValue: {
23
- left: number;
24
- top: number;
25
- };
26
- containerScrollValue: {
27
- left: number;
28
- top: number;
29
- };
30
- direction?: AnchorOptions["direction"];
31
- }
32
- export type AnimateController = AnimationPlaybackControlsWithThen;
33
- export interface AnchorsMethods {
34
- registerAnchors: (name: string) => {
35
- [key: string]: string | React.RefObject<null>;
36
- ref: React.RefObject<null>;
37
- };
38
- registerOffseters: (name: string) => {
39
- [key: string]: string | React.RefObject<null>;
40
- ref: React.RefObject<null>;
41
- };
42
- setStores: (options: AnchorStoreOptions) => void;
43
- getStores: () => AnchorsStores;
44
- scrollToAnchor: (anchorOptions: AnchorOptions) => void;
45
- }
46
- export declare function useAnchors(): AnchorsMethods;
47
- export interface RegistrationDatas {
48
- key: keyof AnchorsStores;
49
- name: string;
50
- }
51
- export declare function useRegistration({ key, name }: RegistrationDatas): {
52
- [x: string]: string | import("react").RefObject<null>;
53
- ref: import("react").RefObject<null>;
54
- };
55
- export declare function registerAnchors(name: string): {
56
- [x: string]: string | import("react").RefObject<null>;
57
- ref: import("react").RefObject<null>;
58
- };
59
- export declare function registerOffseters(name: string): {
60
- [x: string]: string | import("react").RefObject<null>;
61
- ref: import("react").RefObject<null>;
62
- };
63
- export interface AnchorsStores {
64
- anchors: Map<string, HTMLElement | null>;
65
- offseters: Map<string, HTMLElement | null>;
66
- }
67
- export declare const useAnchorsStores: import("zustand").UseBoundStore<import("zustand").StoreApi<AnchorsStores>>;
68
- export declare const getAnchorsStores: () => AnchorsStores;
69
- export interface AnchorStoreOptions extends RegistrationDatas {
70
- node: HTMLDivElement | null;
71
- action: "add" | "remove";
72
- }
73
- export declare const setAnchorsStore: (options: AnchorStoreOptions) => void;