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

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 (55) hide show
  1. package/dist/components/anchors/anchors.d.ts +0 -2
  2. package/dist/components/anchors/anchors.js +7 -10
  3. package/dist/components/embla-carousels/embla-carousels-hooks.d.ts +36 -0
  4. package/dist/components/embla-carousels/embla-carousels-hooks.js +83 -0
  5. package/dist/components/embla-carousels/embla-carousels.d.ts +23 -0
  6. package/dist/components/embla-carousels/embla-carousels.js +58 -0
  7. package/dist/components/embla-carousels/index.d.ts +2 -0
  8. package/dist/components/embla-carousels/index.js +2 -0
  9. package/dist/components/emblas/embla-container.d.ts +8 -0
  10. package/dist/components/emblas/embla-container.js +12 -0
  11. package/dist/components/emblas/embla-context.d.ts +21 -0
  12. package/dist/components/emblas/embla-context.js +12 -0
  13. package/dist/components/emblas/embla.d.ts +20 -0
  14. package/dist/components/emblas/embla.js +124 -0
  15. package/dist/components/emblas/emblas-pagination.d.ts +11 -0
  16. package/dist/components/emblas/emblas-pagination.js +89 -0
  17. package/dist/components/emblas/index.d.ts +4 -0
  18. package/dist/components/emblas/index.js +4 -0
  19. package/dist/components/index.d.ts +3 -0
  20. package/dist/components/index.js +3 -0
  21. package/dist/components/scroll-containers/index.d.ts +3 -0
  22. package/dist/components/scroll-containers/index.js +3 -0
  23. package/dist/components/scroll-containers/lenis-scroll.d.ts +20 -0
  24. package/dist/components/scroll-containers/lenis-scroll.js +65 -0
  25. package/dist/components/scroll-containers/native-scroll.d.ts +6 -0
  26. package/dist/components/scroll-containers/native-scroll.js +23 -0
  27. package/dist/components/scroll-containers/scroll-containers.d.ts +25 -0
  28. package/dist/components/scroll-containers/scroll-containers.js +46 -0
  29. package/dist/components/tests/tests.js +0 -1
  30. package/dist/hooks/useAnchors.d.ts +25 -17
  31. package/dist/hooks/useAnchors.js +73 -40
  32. package/dist/hooks/useAsyncFetcher.js +0 -1
  33. package/dist/hooks/useCookies.js +24 -1
  34. package/dist/hooks/useDebounce.js +0 -1
  35. package/dist/hooks/useDebounceValue.js +0 -1
  36. package/dist/hooks/useDragResize.js +0 -1
  37. package/dist/hooks/useEffectLeave.js +0 -1
  38. package/dist/hooks/useEffectOne.js +0 -1
  39. package/dist/hooks/useHash.js +0 -1
  40. package/dist/hooks/useLocations.js +0 -1
  41. package/dist/hooks/useMounted.js +0 -1
  42. package/dist/shadcns/components/ui/button-group.d.ts +11 -0
  43. package/dist/shadcns/components/ui/button-group.js +26 -0
  44. package/dist/shadcns/components/ui/button.js +0 -1
  45. package/dist/shadcns/components/ui/field.d.ts +24 -0
  46. package/dist/shadcns/components/ui/field.js +75 -0
  47. package/dist/shadcns/components/ui/item.d.ts +23 -0
  48. package/dist/shadcns/components/ui/item.js +65 -0
  49. package/dist/shadcns/components/ui/native-select.d.ts +7 -0
  50. package/dist/shadcns/components/ui/native-select.js +13 -0
  51. package/dist/shadcns/components/ui/navigation-menu.js +0 -1
  52. package/dist/shadcns/components/ui/textarea.js +0 -1
  53. package/package.json +6 -2
  54. package/dist/hooks/useScrollContainers.d.ts +0 -27
  55. package/dist/hooks/useScrollContainers.js +0 -53
@@ -0,0 +1,65 @@
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();
@@ -0,0 +1,6 @@
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 {};
@@ -0,0 +1,23 @@
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
+ });
@@ -0,0 +1,25 @@
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 {};
@@ -0,0 +1,46 @@
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,4 +1,3 @@
1
- "use client";
2
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { Button } from "../../shadcns/index.js";
4
3
  import { CarouselPrevious } from "../../shadcns/index.js";
@@ -1,13 +1,12 @@
1
- import { animate } from "motion/react";
2
- import type { Easing } from "motion/react";
3
- import { registerContainers } from "./useScrollContainers";
1
+ import type { AnimationPlaybackControlsWithThen, Easing } from "motion/react";
2
+ import Lenis from "lenis";
4
3
  export interface AnimateOptions {
5
4
  duration?: number;
6
5
  delay?: number;
7
6
  ease?: Easing | Easing[] | undefined;
8
- onScroll?: () => void;
7
+ onScroll?: (lenis?: Lenis) => void;
9
8
  onScrolling?: (value: number) => void;
10
- onScrolled?: () => void;
9
+ onScrolled?: (lenis?: Lenis) => void;
11
10
  }
12
11
  export interface AnchorOptions extends AnimateOptions {
13
12
  anchor: string;
@@ -30,28 +29,36 @@ export interface ScrollOptions extends AnimateOptions {
30
29
  };
31
30
  direction?: AnchorOptions["direction"];
32
31
  }
33
- export type AnimateController = ReturnType<typeof animate>;
34
- export declare function useAnchors(): {
35
- registerAnchors: typeof registerAnchors;
36
- registerOffseters: typeof registerOffseters;
37
- registerContainers: typeof registerContainers;
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
+ };
38
42
  setStores: (options: AnchorStoreOptions) => void;
39
43
  getStores: () => AnchorsStores;
40
44
  scrollToAnchor: (anchorOptions: AnchorOptions) => void;
41
- };
45
+ }
46
+ export declare function useAnchors(): AnchorsMethods;
42
47
  export interface RegistrationDatas {
43
48
  key: keyof AnchorsStores;
44
49
  name: string;
45
- node: HTMLDivElement | null;
46
50
  }
47
- export declare function registration({ name, key, node }: RegistrationDatas): void;
51
+ export declare function useRegistration({ key, name }: RegistrationDatas): {
52
+ [x: string]: string | import("react").RefObject<null>;
53
+ ref: import("react").RefObject<null>;
54
+ };
48
55
  export declare function registerAnchors(name: string): {
49
- ref: (node: HTMLDivElement | null) => void;
50
- "data-anchor": string;
56
+ [x: string]: string | import("react").RefObject<null>;
57
+ ref: import("react").RefObject<null>;
51
58
  };
52
59
  export declare function registerOffseters(name: string): {
53
- ref: (node: HTMLDivElement | null) => void;
54
- "data-anchor-offseter": string;
60
+ [x: string]: string | import("react").RefObject<null>;
61
+ ref: import("react").RefObject<null>;
55
62
  };
56
63
  export interface AnchorsStores {
57
64
  anchors: Map<string, HTMLElement | null>;
@@ -60,6 +67,7 @@ export interface AnchorsStores {
60
67
  export declare const useAnchorsStores: import("zustand").UseBoundStore<import("zustand").StoreApi<AnchorsStores>>;
61
68
  export declare const getAnchorsStores: () => AnchorsStores;
62
69
  export interface AnchorStoreOptions extends RegistrationDatas {
70
+ node: HTMLDivElement | null;
63
71
  action: "add" | "remove";
64
72
  }
65
73
  export declare const setAnchorsStore: (options: AnchorStoreOptions) => void;
@@ -1,16 +1,17 @@
1
- "use client";
2
- // update: 2025.11.07
3
- // version: 0.0.2.bate
1
+ // update: 2025.11.12
2
+ // version: 0.0.3.bate
4
3
  // dev: wade
5
- import { useCallback, useMemo, useRef } from "react";
6
- import { animate, motionValue } from "motion/react";
4
+ import { useCallback, useLayoutEffect, useMemo, useRef } from "react";
5
+ import { useAnimate, motionValue } from "motion/react";
7
6
  import { create } from "zustand";
8
- import { getScrollContainersStores, registerContainers } from "./useScrollContainers";
7
+ import { getScrollContainerStores, getRootLenis } from "../components/index.js";
8
+ import Lenis from "lenis";
9
9
  const ANCHOR_ATTRIBUTE = "data-anchor";
10
10
  const OFFSETER_ATTRIBUTE = "data-anchor-offseter";
11
11
  export function useAnchors() {
12
+ const [_, animate] = useAnimate();
12
13
  const controllerRef = useRef(new Map());
13
- const scrollAnimations = useCallback(({ controllerKey, containerDom, anchorScrollValue, containerScrollValue, direction = "y", duration = 0.5, delay = 0, ease = [0.215, 0.61, 0.355, 1.0], onScroll: onPlay, onScrolled, onScrolling }) => {
14
+ const scrollAnimations = useCallback(({ controllerKey, containerDom, anchorScrollValue, containerScrollValue, direction = "y", duration = 1, delay = 0, ease = [0, 1, .5, .99], onScroll: onPlay, onScrolled, onScrolling, ...props }) => {
14
15
  if (direction !== "y" && direction !== "x") {
15
16
  console.error(`Scroll Direction isn't 'x' or 'y' `);
16
17
  return;
@@ -36,13 +37,21 @@ export function useAnchors() {
36
37
  controllerRef.current.delete(controllerKey);
37
38
  onScrolled?.();
38
39
  };
39
- const options = { duration, ease, delay, onPlay, onUpdate, onComplete };
40
+ const options = {
41
+ duration,
42
+ ease,
43
+ delay,
44
+ onPlay,
45
+ onUpdate,
46
+ onComplete,
47
+ ...props
48
+ };
40
49
  controllerRef.current.set(controllerKey, animate(motionStartValue, endValue, options));
41
50
  }, []);
42
51
  const scrollToAnchor = useCallback((anchorOptions) => {
43
- const { anchor: anchorName, container: containerName, offseters, align, offset = 0, ...options } = anchorOptions;
52
+ const { anchor: anchorName, container: containerName, offseters, align, offset = 0, direction = "y", ...options } = anchorOptions;
44
53
  const anchorsStores = getAnchorsStores();
45
- const scrollContainersStores = getScrollContainersStores();
54
+ const scrollContainersStores = getScrollContainerStores();
46
55
  const isScrolltoAnchor = anchorName !== "#";
47
56
  const isScrollContainer = containerName && containerName !== "window";
48
57
  const controllerKey = containerName ?? "window";
@@ -60,6 +69,45 @@ export function useAnchors() {
60
69
  : window;
61
70
  if (!containerDom)
62
71
  return;
72
+ const getOffseterDomClient = (offseters) => {
73
+ const offseterDom = anchorsStores.offseters.get(offseters);
74
+ const { clientWidth, clientHeight } = offseterDom || {};
75
+ return { width: clientWidth ?? 0, height: clientHeight ?? 0 };
76
+ };
77
+ const offsets = Array.isArray(offseters)
78
+ ? offseters.reduce((init, offseter) => {
79
+ const { width, height } = getOffseterDomClient(offseter);
80
+ return {
81
+ width: (init.width ?? 0) + width,
82
+ height: (init.height ?? 0) + height
83
+ };
84
+ }, {})
85
+ : typeof offseters == "string"
86
+ ? getOffseterDomClient(offseters)
87
+ : { width: 0, height: 0 };
88
+ const offsetValue = {
89
+ width: direction === "x" ? offsets.width + offset : 0,
90
+ height: direction === "y" ? offsets.height + offset : 0,
91
+ };
92
+ const isLenisScroll = containerDom == window
93
+ && window.document.documentElement.classList.contains("lenis")
94
+ || containerDom instanceof Lenis;
95
+ if (isLenisScroll) {
96
+ const lenis = (isScrollContainer ? containerDom : getRootLenis()?.root);
97
+ // TODO 尚未找到可以判斷已經移動到錨點位置的方式
98
+ if (!lenis)
99
+ return;
100
+ const directionOffset = direction === "x"
101
+ ? offsetValue.width + offset
102
+ : offsetValue.height + offset;
103
+ // TODO 尚未建立lenis options完整設定
104
+ lenis.scrollTo(anchorDom ?? 0, {
105
+ offset: (directionOffset * -1),
106
+ onStart: (lenis) => options?.onScroll?.(lenis),
107
+ onComplete: (lenis) => options?.onScrolled?.(lenis)
108
+ });
109
+ return;
110
+ }
63
111
  const containerScrollValue = {
64
112
  top: Math.round(isScrollContainer
65
113
  ? containerDom.scrollTop
@@ -75,65 +123,50 @@ export function useAnchors() {
75
123
  left: containerScrollValue.left - (isScrollContainer ? containerRect.left : 0),
76
124
  top: containerScrollValue.top - (isScrollContainer ? containerRect.top : 0)
77
125
  };
78
- const offsetsValue = Array.isArray(offseters)
79
- ? offseters.reduce((init, offseter) => {
80
- const offseterDom = anchorsStores.offseters.get(offseter);
81
- const width = (init.width ?? 0) + (offseterDom ? offseterDom.clientWidth : 0);
82
- const height = (init.height ?? 0) + (offseterDom ? offseterDom.clientHeight : 0);
83
- return { width, height };
84
- }, {})
85
- : { width: 0, height: 0 };
86
- const offsetsSumValue = {
87
- width: options.direction === "x" ? offsetsValue.width + offset : 0,
88
- height: options.direction === "y" ? offsetsValue.height + offset : 0,
89
- };
90
126
  const anchorRect = anchorDom ? anchorDom.getBoundingClientRect() : { left: 0, top: 0 };
91
127
  const anchorScrollValue = {
92
128
  left: isScrolltoAnchor
93
- ? Math.round(anchorRect.left + containerOffsetValue.left - offsetsSumValue.width)
94
- : offsetsSumValue.width,
129
+ ? Math.round(anchorRect.left + containerOffsetValue.left - offsetValue.width)
130
+ : offsetValue.width,
95
131
  top: isScrolltoAnchor
96
- ? Math.round(anchorRect.top + containerOffsetValue.top - offsetsSumValue.height)
97
- : offsetsSumValue.height
132
+ ? Math.round(anchorRect.top + containerOffsetValue.top - offsetValue.height)
133
+ : offsetValue.height
98
134
  };
99
135
  scrollAnimations({
100
136
  controllerKey,
101
137
  containerDom,
102
138
  containerScrollValue,
103
139
  anchorScrollValue,
140
+ direction,
104
141
  ...options
105
142
  });
106
143
  }, []);
107
144
  const returnsMemo = useMemo(() => ({
108
145
  registerAnchors,
109
146
  registerOffseters,
110
- registerContainers: registerContainers,
111
147
  setStores: setAnchorsStore,
112
148
  getStores: getAnchorsStores,
113
149
  scrollToAnchor
114
150
  }), [scrollToAnchor]);
115
151
  return returnsMemo;
116
152
  }
117
- export function registration({ name, key, node }) {
118
- if (!node)
119
- return;
120
- if (name == "#") {
121
- console.error(`Cannot register ${key} name '#'`);
122
- return;
123
- }
124
- setAnchorsStore({ key, name, node, action: node ? "add" : "remove" });
153
+ export function useRegistration({ key, name }) {
154
+ const ref = useRef(null);
155
+ const attribute = key == "anchors" ? ANCHOR_ATTRIBUTE : OFFSETER_ATTRIBUTE;
156
+ useLayoutEffect(() => {
157
+ setAnchorsStore({ key, action: "add", node: ref.current, name });
158
+ return () => { setAnchorsStore({ key, action: "remove", node: ref.current, name }); };
159
+ }, []);
160
+ return { ref, [attribute]: name };
125
161
  }
126
162
  export function registerAnchors(name) {
127
- const register = useCallback((node) => registration({ key: "anchors", name, node }), [name]);
128
- return { ref: register, [ANCHOR_ATTRIBUTE]: name };
163
+ return useRegistration({ key: "anchors", name });
129
164
  }
130
165
  export function registerOffseters(name) {
131
- const register = useCallback((node) => registration({ key: "offseters", name, node }), [name]);
132
- return { ref: register, [OFFSETER_ATTRIBUTE]: name };
166
+ return useRegistration({ key: "offseters", name });
133
167
  }
134
168
  export const useAnchorsStores = create()(() => ({
135
169
  anchors: new Map(),
136
- // containers: new Map(),
137
170
  offseters: new Map(),
138
171
  }));
139
172
  export const getAnchorsStores = () => useAnchorsStores.getState();
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { useRef, useState, useEffect, useCallback } from "react";
3
2
  export function useAsyncFetcher() {
4
3
  const [isPending, setPending] = useState(false);
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import Cookies from 'js-cookie';
3
2
  // wade 2024.12.06 (js-cookie 版本)
4
3
  export function useCookies() {
@@ -17,3 +16,27 @@ export function useCookies() {
17
16
  };
18
17
  return { setCookies, getCookies, updateCookies, deleteCookies };
19
18
  }
19
+ //
20
+ // //wade 2024.12.06
21
+ // export function useCookies() {
22
+ // const setCookies = (name: string, value: string, days = 7) => {
23
+ // const date = new Date();
24
+ // date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
25
+ // const expires = `expires=${date.toUTCString()}`;
26
+ // document.cookie = `${name}=${encodeURIComponent(value)}; ${expires}; path=/`;
27
+ // }
28
+ // const getCookies = (name: string) => {
29
+ // const cookies = document.cookie.split("; ");
30
+ // for (const cookie of cookies) {
31
+ // const [key, value] = cookie.split("=");
32
+ // if (key === name) return decodeURIComponent(value);
33
+ // }
34
+ // return null; // 如果找不到,返回 null
35
+ // }
36
+ // const updateCookies = (name: string, value: string, days = 7) =>
37
+ // getCookies(name) !== null && setCookies(name, value, days);
38
+ // const deleteCookies = (name: string) => {
39
+ // document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;
40
+ // }
41
+ // return { setCookies, getCookies, updateCookies, deleteCookies }
42
+ // }
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { useEffect, useRef } from "react";
3
2
  export function useDebounce({ callback, dependency = [], delay = 500, active = true, }) {
4
3
  if (!active || !callback)
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { useEffect, useRef, useState } from "react";
3
2
  export function useDebounceValue(value, delay = 500) {
4
3
  const [debounceValue, setDebounceValue] = useState(value);
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  //wade 2024.12.06
3
2
  import { useEffect, useRef, useState } from "react";
4
3
  export function useDragResize({ active = true, direction = "horizontal", minWidth, maxWidth, minHeight, maxHeight, onInit, onResizeStart, onResizing, onResizeEnd }) {
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { useEffect, useRef } from "react";
3
2
  export function useEffectLeave(callback) {
4
3
  const callbackRef = useRef(callback);
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { useEffect, useRef } from "react";
3
2
  export function useEffectOne(callback) {
4
3
  const callbackRef = useRef(callback);
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { useEffect, useState } from "react";
3
2
  export function useHash() {
4
3
  const [hash, setHash] = useState("");
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { useEffect, useState } from "react";
3
2
  ;
4
3
  export function useLocations() {
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { useEffect, useState } from "react";
3
2
  export function useMounted() {
4
3
  const [isMounded, setMounded] = useState(false);
@@ -0,0 +1,11 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import { Separator } from "../../index.js";
3
+ declare const buttonGroupVariants: (props?: ({
4
+ orientation?: "horizontal" | "vertical" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ declare function ButtonGroup({ className, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>): import("react/jsx-runtime").JSX.Element;
7
+ declare function ButtonGroupText({ className, asChild, ...props }: React.ComponentProps<"div"> & {
8
+ asChild?: boolean;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ declare function ButtonGroupSeparator({ className, orientation, ...props }: React.ComponentProps<typeof Separator>): import("react/jsx-runtime").JSX.Element;
11
+ export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants, };
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import { cva } from "class-variance-authority";
4
+ import { cn, Separator } from "../../index.js";
5
+ const buttonGroupVariants = cva("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2", {
6
+ variants: {
7
+ orientation: {
8
+ horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
9
+ vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",
10
+ },
11
+ },
12
+ defaultVariants: {
13
+ orientation: "horizontal",
14
+ },
15
+ });
16
+ function ButtonGroup({ className, orientation, ...props }) {
17
+ return (_jsx("div", { role: "group", "data-slot": "button-group", "data-orientation": orientation, className: cn(buttonGroupVariants({ orientation }), className), ...props }));
18
+ }
19
+ function ButtonGroupText({ className, asChild = false, ...props }) {
20
+ const Comp = asChild ? Slot : "div";
21
+ return (_jsx(Comp, { className: cn("bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", className), ...props }));
22
+ }
23
+ function ButtonGroupSeparator({ className, orientation = "vertical", ...props }) {
24
+ return (_jsx(Separator, { "data-slot": "button-group-separator", orientation: orientation, className: cn("bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto", className), ...props }));
25
+ }
26
+ export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants, };
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { jsx as _jsx } from "react/jsx-runtime";
3
2
  import { Slot } from '@radix-ui/react-slot';
4
3
  import { cva } from 'class-variance-authority';
@@ -0,0 +1,24 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import { Label } from "../../index.js";
3
+ declare function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">): import("react/jsx-runtime").JSX.Element;
4
+ declare function FieldLegend({ className, variant, ...props }: React.ComponentProps<"legend"> & {
5
+ variant?: "legend" | "label";
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ declare function FieldGroup({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
8
+ declare const fieldVariants: (props?: ({
9
+ orientation?: "horizontal" | "vertical" | "responsive" | null | undefined;
10
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
+ declare function Field({ className, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>): import("react/jsx-runtime").JSX.Element;
12
+ declare function FieldContent({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
13
+ declare function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>): import("react/jsx-runtime").JSX.Element;
14
+ declare function FieldTitle({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
15
+ declare function FieldDescription({ className, ...props }: React.ComponentProps<"p">): import("react/jsx-runtime").JSX.Element;
16
+ declare function FieldSeparator({ children, className, ...props }: React.ComponentProps<"div"> & {
17
+ children?: React.ReactNode;
18
+ }): import("react/jsx-runtime").JSX.Element;
19
+ declare function FieldError({ className, children, errors, ...props }: React.ComponentProps<"div"> & {
20
+ errors?: Array<{
21
+ message?: string;
22
+ } | undefined>;
23
+ }): import("react/jsx-runtime").JSX.Element | null;
24
+ export { Field, FieldLabel, FieldDescription, FieldError, FieldGroup, FieldLegend, FieldSeparator, FieldSet, FieldContent, FieldTitle, };