@xwadex/fesd-next 0.3.4-4.1 → 0.3.4-7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/TestComponent.d.ts +4 -0
- package/dist/components/TestComponent.js +10 -0
- package/dist/components/index.d.ts +2 -5
- package/dist/components/index.js +2 -7
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/useAnchors.d.ts +51 -0
- package/dist/hooks/useAnchors.js +121 -0
- package/dist/hooks/useAsyncFetcher.d.ts +4 -3
- package/dist/hooks/useCookies.d.ts +1 -1
- package/dist/hooks/useCookies.js +9 -14
- package/dist/hooks/useDragResize.d.ts +6 -3
- package/dist/hooks/useDragResize.js +20 -8
- package/dist/hooks/useEffectLeave.d.ts +1 -0
- package/dist/hooks/useEffectLeave.js +12 -0
- package/dist/hooks/useEffectOne.d.ts +1 -0
- package/dist/hooks/useEffectOne.js +12 -0
- package/dist/hooks/useIsMobile.d.ts +1 -0
- package/dist/hooks/useIsMobile.js +16 -0
- package/dist/hooks/useLocations.d.ts +13 -0
- package/dist/hooks/useLocations.js +25 -0
- package/package.json +2 -8
- package/dist/components/accordions/accordion.d.ts +0 -10
- package/dist/components/accordions/accordion.js +0 -10
- package/dist/components/accordions/accordionContent.d.ts +0 -11
- package/dist/components/accordions/accordionContent.js +0 -20
- package/dist/components/accordions/accordionItem.d.ts +0 -11
- package/dist/components/accordions/accordionItem.js +0 -14
- package/dist/components/accordions/accordionTrigger.d.ts +0 -11
- package/dist/components/accordions/accordionTrigger.js +0 -88
- package/dist/components/accordions/index.d.ts +0 -35
- package/dist/components/accordions/index.js +0 -11
- package/dist/components/button.d.ts +0 -10
- package/dist/components/button.js +0 -31
- package/dist/components/dragResize/dragResize.d.ts +0 -19
- package/dist/components/dragResize/dragResize.js +0 -77
- package/dist/components/dragResize/dragResize.module.scss +0 -42
- package/dist/components/dragResize/dragResizeContext.d.ts +0 -10
- package/dist/components/dragResize/dragResizeContext.js +0 -9
- package/dist/components/dragResize/index.d.ts +0 -2
- package/dist/components/dragResize/index.js +0 -2
- package/dist/components/dragSortable/dragSortable.d.ts +0 -19
- package/dist/components/dragSortable/dragSortable.js +0 -11
- package/dist/components/dragSortable/dragSortable.module.scss +0 -7
- package/dist/components/dragSortable/index.d.ts +0 -1
- package/dist/components/dragSortable/index.js +0 -1
- package/dist/components/resizables/index.d.ts +0 -66
- package/dist/components/resizables/index.js +0 -8
- package/dist/components/resizables/resizableHandle.d.ts +0 -11
- package/dist/components/resizables/resizableHandle.js +0 -48
- package/dist/components/resizables/resizablePanel.d.ts +0 -10
- package/dist/components/resizables/resizablePanel.js +0 -9
- package/dist/components/resizables/resizablePanelGroup.d.ts +0 -10
- package/dist/components/resizables/resizablePanelGroup.js +0 -14
- package/dist/components/scrollAreas/index.d.ts +0 -1
- package/dist/components/scrollAreas/index.js +0 -1
- package/dist/components/scrollAreas/scroll-area.d.ts +0 -5
- package/dist/components/scrollAreas/scroll-area.js +0 -11
- package/dist/hooks/useCollapse.d.ts +0 -15
- package/dist/hooks/useCollapse.js +0 -52
- package/dist/styles/defaults.css +0 -155
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCookies } from "../hooks/index.js";
|
|
4
|
+
const TestComponent = () => {
|
|
5
|
+
const cookie = useCookies();
|
|
6
|
+
console.log(cookie);
|
|
7
|
+
return (_jsx(_Fragment, { children: "TestComponent content" }));
|
|
8
|
+
};
|
|
9
|
+
TestComponent.displayName = "TestComponent";
|
|
10
|
+
export default TestComponent;
|
package/dist/components/index.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export * from "./dragSortable";
|
|
4
|
-
// shadcn Components
|
|
5
|
-
export * from "./accordions";
|
|
6
|
-
export * from "./resizables";
|
|
7
|
-
export * from "./scrollAreas";
|
|
1
|
+
export const test = "wade";
|
|
2
|
+
export { default as TestComponent } from "./TestComponent";
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export * from "./useDebounceValue";
|
|
|
3
3
|
export * from "./useCookies";
|
|
4
4
|
export * from "./useDragResize";
|
|
5
5
|
export * from "./useAsyncFetcher";
|
|
6
|
-
export * from "./useCollapse";
|
|
7
6
|
export * from "./useMounted";
|
|
7
|
+
export * from "./useEffectOne";
|
|
8
|
+
export * from "./useEffectLeave";
|
package/dist/hooks/index.js
CHANGED
|
@@ -3,5 +3,6 @@ export * from "./useDebounceValue";
|
|
|
3
3
|
export * from "./useCookies";
|
|
4
4
|
export * from "./useDragResize";
|
|
5
5
|
export * from "./useAsyncFetcher";
|
|
6
|
-
export * from "./useCollapse";
|
|
7
6
|
export * from "./useMounted";
|
|
7
|
+
export * from "./useEffectOne";
|
|
8
|
+
export * from "./useEffectLeave";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Easing } from "motion/react";
|
|
2
|
+
export interface PropsTypes {
|
|
3
|
+
}
|
|
4
|
+
export interface AnchorActionsOptions {
|
|
5
|
+
anchor?: string;
|
|
6
|
+
container: string;
|
|
7
|
+
offseters?: string | string[];
|
|
8
|
+
direction?: "horizontal" | "vertical";
|
|
9
|
+
duration?: number;
|
|
10
|
+
offset?: number;
|
|
11
|
+
delay?: number;
|
|
12
|
+
ease?: Easing | Easing[] | undefined;
|
|
13
|
+
onScroll?: () => void;
|
|
14
|
+
onScrolling?: (value: number) => void;
|
|
15
|
+
onScrolled?: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function useAnchors(): {
|
|
18
|
+
registerAnchors: typeof registerAnchors;
|
|
19
|
+
registerContainers: typeof registerContainers;
|
|
20
|
+
registerOffseters: typeof registerOffseters;
|
|
21
|
+
getStores: () => AnchorsStores;
|
|
22
|
+
removeAnchor: (name: string) => void;
|
|
23
|
+
removeOffseter: (name: string) => void;
|
|
24
|
+
removeContainer: (name: string) => void;
|
|
25
|
+
scrollToAnchor: ({ anchor: anchorName, container: containerName, ...options }: AnchorActionsOptions) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare function registerAnchors(name: string): {
|
|
28
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
29
|
+
"data-anchor": string;
|
|
30
|
+
};
|
|
31
|
+
export declare function registerOffseters(name: string): {
|
|
32
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
33
|
+
"data-anchor-offseter": string;
|
|
34
|
+
};
|
|
35
|
+
export declare function registerContainers(name: string): {
|
|
36
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
37
|
+
"data-anchor-container": string;
|
|
38
|
+
};
|
|
39
|
+
export type AnchorsStores = {
|
|
40
|
+
anchors: Map<string, HTMLElement | null>;
|
|
41
|
+
containers: Map<string, HTMLElement | null>;
|
|
42
|
+
offseters: Map<string, HTMLElement | null>;
|
|
43
|
+
};
|
|
44
|
+
export declare const useAnchorsStores: import("zustand").UseBoundStore<import("zustand").StoreApi<AnchorsStores>>;
|
|
45
|
+
export declare const getAnchorsStores: () => AnchorsStores;
|
|
46
|
+
export declare const addAnchor: (name: string, anchorNode: HTMLElement | null) => void;
|
|
47
|
+
export declare const removeAnchor: (name: string) => void;
|
|
48
|
+
export declare const addContainer: (name: string, containerNode: HTMLElement | null) => void;
|
|
49
|
+
export declare const removeContainer: (name: string) => void;
|
|
50
|
+
export declare const addOffseter: (name: string, containerNode: HTMLElement | null) => void;
|
|
51
|
+
export declare const removeOffseter: (name: string) => void;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
3
|
+
import { animate, useMotionValue } from "motion/react";
|
|
4
|
+
import { create } from "zustand";
|
|
5
|
+
export function useAnchors() {
|
|
6
|
+
const motionValue = useMotionValue(0);
|
|
7
|
+
const controlsRef = useRef(null);
|
|
8
|
+
const scrollToAnchor = useCallback(({ anchor: anchorName, container: containerName, ...options }) => {
|
|
9
|
+
const { offseters, direction = "vertical", duration = 0.5, offset = 0, delay = 0, ease = [0.215, 0.61, 0.355, 1.0], onScroll, onScrolling, onScrolled, } = options;
|
|
10
|
+
if (!anchorName || !containerName)
|
|
11
|
+
return;
|
|
12
|
+
const stores = getAnchorsStores();
|
|
13
|
+
if (!stores?.anchors || !stores?.containers)
|
|
14
|
+
return;
|
|
15
|
+
const anchorDom = stores.anchors.get(anchorName);
|
|
16
|
+
const containerDom = stores.containers.get(containerName);
|
|
17
|
+
if (!anchorDom || !containerDom)
|
|
18
|
+
return;
|
|
19
|
+
const { top: targetTop } = anchorDom.getBoundingClientRect();
|
|
20
|
+
const { top: containerTop } = containerDom.getBoundingClientRect();
|
|
21
|
+
const containerScrollTop = Math.round(containerDom.scrollTop);
|
|
22
|
+
const scrollOffset = Math.round(targetTop - containerTop + containerScrollTop);
|
|
23
|
+
if (scrollOffset == containerScrollTop)
|
|
24
|
+
return;
|
|
25
|
+
if (controlsRef.current)
|
|
26
|
+
controlsRef.current?.stop();
|
|
27
|
+
// console.log("scrollOffset", scrollOffset);
|
|
28
|
+
// console.log("containerScrollTop", containerScrollTop);
|
|
29
|
+
// console.log(scrollOffset == containerScrollTop);
|
|
30
|
+
motionValue.set(containerScrollTop);
|
|
31
|
+
controlsRef.current = animate(motionValue, scrollOffset, {
|
|
32
|
+
duration: 0.5,
|
|
33
|
+
delay: 5,
|
|
34
|
+
ease: [0.215, 0.61, 0.355, 1.0],
|
|
35
|
+
onPlay: onScroll,
|
|
36
|
+
onComplete: onScrolled,
|
|
37
|
+
onUpdate: (value) => {
|
|
38
|
+
containerDom.scrollTop = value;
|
|
39
|
+
onScrolling?.(value);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}, [motionValue]);
|
|
43
|
+
const returnsMemo = useMemo(() => ({
|
|
44
|
+
registerAnchors,
|
|
45
|
+
registerContainers,
|
|
46
|
+
registerOffseters,
|
|
47
|
+
getStores: getAnchorsStores,
|
|
48
|
+
removeAnchor: removeAnchor,
|
|
49
|
+
removeOffseter: removeOffseter,
|
|
50
|
+
removeContainer: removeContainer,
|
|
51
|
+
scrollToAnchor
|
|
52
|
+
}), [scrollToAnchor]);
|
|
53
|
+
return returnsMemo;
|
|
54
|
+
}
|
|
55
|
+
export function registerAnchors(name) {
|
|
56
|
+
const register = (node) => {
|
|
57
|
+
if (node)
|
|
58
|
+
addAnchor(name, node);
|
|
59
|
+
else
|
|
60
|
+
removeAnchor(name);
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
ref: register,
|
|
64
|
+
"data-anchor": name
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function registerOffseters(name) {
|
|
68
|
+
const register = (node) => {
|
|
69
|
+
if (node)
|
|
70
|
+
addOffseter(name, node);
|
|
71
|
+
else
|
|
72
|
+
removeOffseter(name);
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
ref: register,
|
|
76
|
+
"data-anchor-offseter": name
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function registerContainers(name) {
|
|
80
|
+
const register = (node) => {
|
|
81
|
+
if (node)
|
|
82
|
+
addContainer(name, node);
|
|
83
|
+
else
|
|
84
|
+
removeContainer(name);
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
ref: register,
|
|
88
|
+
"data-anchor-container": name
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const anchorsStores = {
|
|
92
|
+
anchors: new Map(),
|
|
93
|
+
containers: new Map(),
|
|
94
|
+
offseters: new Map(),
|
|
95
|
+
};
|
|
96
|
+
export const useAnchorsStores = create()(() => anchorsStores);
|
|
97
|
+
export const getAnchorsStores = () => useAnchorsStores.getState();
|
|
98
|
+
export const addAnchor = (name, anchorNode) => useAnchorsStores.setState(stores => {
|
|
99
|
+
stores.anchors?.set(name, anchorNode);
|
|
100
|
+
return { anchors: stores.anchors };
|
|
101
|
+
});
|
|
102
|
+
export const removeAnchor = (name) => useAnchorsStores.setState(stores => {
|
|
103
|
+
stores.anchors?.delete(name);
|
|
104
|
+
return { anchors: stores.anchors };
|
|
105
|
+
});
|
|
106
|
+
export const addContainer = (name, containerNode) => useAnchorsStores.setState(stores => {
|
|
107
|
+
stores.containers?.set(name, containerNode);
|
|
108
|
+
return { containers: stores.containers };
|
|
109
|
+
});
|
|
110
|
+
export const removeContainer = (name) => useAnchorsStores.setState(stores => {
|
|
111
|
+
stores.containers?.delete(name);
|
|
112
|
+
return { containers: stores.containers };
|
|
113
|
+
});
|
|
114
|
+
export const addOffseter = (name, containerNode) => useAnchorsStores.setState(stores => {
|
|
115
|
+
stores.offseters?.set(name, containerNode);
|
|
116
|
+
return { offseters: stores.offseters };
|
|
117
|
+
});
|
|
118
|
+
export const removeOffseter = (name) => useAnchorsStores.setState(stores => {
|
|
119
|
+
stores.offseters?.delete(name);
|
|
120
|
+
return { offseters: stores.offseters };
|
|
121
|
+
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
type ReturnDatasTypes = {
|
|
2
2
|
fetcher: (payload: PayloadTypes) => Promise<any>;
|
|
3
3
|
cancel: () => void;
|
|
4
4
|
pending: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
5
|
+
};
|
|
6
|
+
interface PayloadTypes {
|
|
7
7
|
url: string | URL | globalThis.Request;
|
|
8
8
|
options?: RequestInit;
|
|
9
9
|
}
|
|
10
10
|
export declare function useAsyncFetcher(): ReturnDatasTypes;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function useCookies(): {
|
|
2
2
|
setCookies: (name: string, value: string, days?: number) => void;
|
|
3
3
|
getCookies: (name: string) => string | null;
|
|
4
|
-
updateCookies: (name: string, value: string, days?: number) =>
|
|
4
|
+
updateCookies: (name: string, value: string, days?: number) => void;
|
|
5
5
|
deleteCookies: (name: string) => void;
|
|
6
6
|
};
|
package/dist/hooks/useCookies.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
import Cookies from 'js-cookie';
|
|
3
|
+
// wade 2024.12.06 (js-cookie 版本)
|
|
3
4
|
export function useCookies() {
|
|
4
5
|
const setCookies = (name, value, days = 7) => {
|
|
5
|
-
|
|
6
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
7
|
-
const expires = `expires=${date.toUTCString()}`;
|
|
8
|
-
document.cookie = `${name}=${encodeURIComponent(value)}; ${expires}; path=/`;
|
|
6
|
+
Cookies.set(name, value, { expires: days, path: "/" });
|
|
9
7
|
};
|
|
10
8
|
const getCookies = (name) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return null; // 如果找不到,返回 null
|
|
9
|
+
return Cookies.get(name) ?? null;
|
|
10
|
+
};
|
|
11
|
+
const updateCookies = (name, value, days = 7) => {
|
|
12
|
+
if (getCookies(name) !== null)
|
|
13
|
+
setCookies(name, value, days);
|
|
18
14
|
};
|
|
19
|
-
const updateCookies = (name, value, days = 7) => getCookies(name) !== null && setCookies(name, value, days);
|
|
20
15
|
const deleteCookies = (name) => {
|
|
21
|
-
|
|
16
|
+
Cookies.remove(name, { path: "/" });
|
|
22
17
|
};
|
|
23
18
|
return { setCookies, getCookies, updateCookies, deleteCookies };
|
|
24
19
|
}
|
|
@@ -2,11 +2,13 @@ export interface ResizeTypes {
|
|
|
2
2
|
width?: number | string;
|
|
3
3
|
height?: number | string;
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
5
|
+
export interface DragResizeProps {
|
|
6
6
|
active?: boolean;
|
|
7
|
-
direction?: "
|
|
7
|
+
direction?: "horizontal" | "vertical";
|
|
8
8
|
minWidth?: number;
|
|
9
9
|
maxWidth?: number;
|
|
10
|
+
minHeight?: number;
|
|
11
|
+
maxHeight?: number;
|
|
10
12
|
onInit?: (size: ResizeTypes) => void;
|
|
11
13
|
onResizeStart?: (size: ResizeTypes) => void;
|
|
12
14
|
onResizing?: (size: ResizeTypes) => void;
|
|
@@ -15,5 +17,6 @@ export interface DragResizePropsTypes {
|
|
|
15
17
|
export type DragResizeTypes = {
|
|
16
18
|
dragRef: React.RefObject<HTMLDivElement | null>;
|
|
17
19
|
resizeRef: React.RefObject<HTMLDivElement | null>;
|
|
20
|
+
resize?: ResizeTypes;
|
|
18
21
|
};
|
|
19
|
-
export declare function useDragResize({ active, direction, minWidth, maxWidth, onInit, onResizeStart, onResizing, onResizeEnd }:
|
|
22
|
+
export declare function useDragResize({ active, direction, minWidth, maxWidth, minHeight, maxHeight, onInit, onResizeStart, onResizing, onResizeEnd }: DragResizeProps): DragResizeTypes;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//wade 2024.12.06
|
|
3
|
-
import { useEffect, useRef } from "react";
|
|
4
|
-
export function useDragResize({ active = true, direction = "
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
export function useDragResize({ active = true, direction = "horizontal", minWidth, maxWidth, minHeight, maxHeight, onInit, onResizeStart, onResizing, onResizeEnd }) {
|
|
5
5
|
const dragRef = useRef(null);
|
|
6
6
|
const resizeRef = useRef(null);
|
|
7
|
+
const [resize, setResize] = useState({ width: 0, height: 0 });
|
|
7
8
|
const getResizeSizeValue = () => {
|
|
8
9
|
if (!resizeRef.current)
|
|
9
10
|
return;
|
|
@@ -18,10 +19,18 @@ export function useDragResize({ active = true, direction = "width", minWidth = 3
|
|
|
18
19
|
const rect = resizeRef.current.getBoundingClientRect();
|
|
19
20
|
const resizeWidth = clientX - rect.left;
|
|
20
21
|
const resizeHeight = clientY - rect.top;
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
if (direction == "horizontal"
|
|
23
|
+
&& (minWidth && resizeWidth >= minWidth)
|
|
24
|
+
&& (maxWidth && resizeWidth <= maxWidth)) {
|
|
25
|
+
resizeRef.current.style.width = resizeWidth + "px";
|
|
26
|
+
return { width: resizeWidth, height: undefined };
|
|
27
|
+
}
|
|
28
|
+
if (direction == "vertical"
|
|
29
|
+
&& (minHeight && resizeWidth >= minHeight)
|
|
30
|
+
&& (maxHeight && resizeWidth <= maxHeight)) {
|
|
31
|
+
resizeRef.current.style.height = resizeHeight + "px";
|
|
32
|
+
return { width: undefined, height: resizeHeight };
|
|
33
|
+
}
|
|
25
34
|
};
|
|
26
35
|
const onInitCallback = () => {
|
|
27
36
|
const resizeValue = getResizeSizeValue();
|
|
@@ -33,7 +42,10 @@ export function useDragResize({ active = true, direction = "width", minWidth = 3
|
|
|
33
42
|
};
|
|
34
43
|
const onMouseMove = (e) => {
|
|
35
44
|
const resizeValue = setResizeValue(e.clientX, e.clientY);
|
|
36
|
-
|
|
45
|
+
if (!resizeValue)
|
|
46
|
+
return;
|
|
47
|
+
setResize(() => ({ ...resizeValue }));
|
|
48
|
+
onResizing?.(resizeValue);
|
|
37
49
|
};
|
|
38
50
|
const onMouseUp = () => {
|
|
39
51
|
const resizeValue = getResizeSizeValue();
|
|
@@ -59,5 +71,5 @@ export function useDragResize({ active = true, direction = "width", minWidth = 3
|
|
|
59
71
|
removeEventListeners();
|
|
60
72
|
};
|
|
61
73
|
}, [active]);
|
|
62
|
-
return { dragRef, resizeRef };
|
|
74
|
+
return { dragRef, resizeRef, resize };
|
|
63
75
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useEffectLeave(callback: () => void): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
export function useEffectLeave(callback) {
|
|
4
|
+
const callbackRef = useRef(callback);
|
|
5
|
+
callbackRef.current = callback;
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
return () => {
|
|
8
|
+
callbackRef.current?.();
|
|
9
|
+
callbackRef.current = null;
|
|
10
|
+
};
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useEffectOne(callback: () => void): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
export function useEffectOne(callback) {
|
|
4
|
+
const callbackRef = useRef(callback);
|
|
5
|
+
callbackRef.current = callback;
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
callbackRef.current?.();
|
|
8
|
+
return () => {
|
|
9
|
+
callbackRef.current = null;
|
|
10
|
+
};
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsMobile(): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
const MOBILE_BREAKPOINT = 768;
|
|
4
|
+
export function useIsMobile() {
|
|
5
|
+
const [isMobile, setIsMobile] = useState(undefined);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
8
|
+
const onChange = () => {
|
|
9
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
10
|
+
};
|
|
11
|
+
mql.addEventListener("change", onChange);
|
|
12
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
13
|
+
return () => mql.removeEventListener("change", onChange);
|
|
14
|
+
}, []);
|
|
15
|
+
return !!isMobile;
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface LocationState {
|
|
2
|
+
hash: string;
|
|
3
|
+
host: string;
|
|
4
|
+
hostname: string;
|
|
5
|
+
href: string;
|
|
6
|
+
origin: string;
|
|
7
|
+
pathname: string;
|
|
8
|
+
port: string;
|
|
9
|
+
protocol: string;
|
|
10
|
+
search: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function useLocations(): LocationState;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
;
|
|
4
|
+
export function useLocations() {
|
|
5
|
+
const [locations, setLocations] = useState({
|
|
6
|
+
hash: "",
|
|
7
|
+
host: "",
|
|
8
|
+
hostname: "",
|
|
9
|
+
href: "",
|
|
10
|
+
origin: "",
|
|
11
|
+
pathname: "",
|
|
12
|
+
port: "",
|
|
13
|
+
protocol: "",
|
|
14
|
+
search: "",
|
|
15
|
+
});
|
|
16
|
+
const getLocationValue = () => {
|
|
17
|
+
setLocations({ ...window.location });
|
|
18
|
+
};
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (typeof window === "undefined")
|
|
21
|
+
return;
|
|
22
|
+
getLocationValue();
|
|
23
|
+
}, []);
|
|
24
|
+
return locations;
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwadex/fesd-next",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.47.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,12 +24,6 @@
|
|
|
24
24
|
"./types": {
|
|
25
25
|
"import": "./dist/types/index.js",
|
|
26
26
|
"types": "./dist/types/index.d.ts"
|
|
27
|
-
},
|
|
28
|
-
"./styles": {
|
|
29
|
-
"default": "./dist/styles/defaults.css"
|
|
30
|
-
},
|
|
31
|
-
"./styles/*": {
|
|
32
|
-
"default": "./dist/styles/*"
|
|
33
27
|
}
|
|
34
28
|
},
|
|
35
29
|
"files": [
|
|
@@ -37,7 +31,7 @@
|
|
|
37
31
|
],
|
|
38
32
|
"scripts": {
|
|
39
33
|
"clean": "rm -rf dist",
|
|
40
|
-
"build": "npm run clean && tsc --project tsconfig.json && tsc-alias
|
|
34
|
+
"build": "npm run clean && tsc --project tsconfig.json && tsc-alias"
|
|
41
35
|
},
|
|
42
36
|
"peerDependencies": {
|
|
43
37
|
"react": ">=18",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
-
import type { ShadcnBaseProps } from "../../types/index.js";
|
|
3
|
-
type PropsType = ShadcnBaseProps<typeof AccordionPrimitive.Root> & {
|
|
4
|
-
as?: React.ElementType;
|
|
5
|
-
};
|
|
6
|
-
declare const Accordion: {
|
|
7
|
-
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
displayName: string;
|
|
9
|
-
};
|
|
10
|
-
export default Accordion;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
4
|
-
const Accordion = (props) => {
|
|
5
|
-
const { as, children, ...restProps } = props;
|
|
6
|
-
const Component = as || "div";
|
|
7
|
-
return (_jsx(AccordionPrimitive.Root, { asChild: true, "data-slot": "accordion", ...restProps, children: _jsx(Component, { children: children }) }));
|
|
8
|
-
};
|
|
9
|
-
Accordion.displayName = "Accordion";
|
|
10
|
-
export default Accordion;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
-
import type { ShadcnBaseProps } from "../../types/index.js";
|
|
3
|
-
type PropsType = ShadcnBaseProps<typeof AccordionPrimitive.Content> & {
|
|
4
|
-
as?: React.ElementType;
|
|
5
|
-
ref?: React.Ref<Element>;
|
|
6
|
-
};
|
|
7
|
-
declare const AccordionContent: {
|
|
8
|
-
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
displayName: string;
|
|
10
|
-
};
|
|
11
|
-
export default AccordionContent;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
4
|
-
import { useMounted } from "../../hooks/index.js";
|
|
5
|
-
import { cn } from "../../utils/index.js";
|
|
6
|
-
import { useImperativeHandle, useRef } from "react";
|
|
7
|
-
const AccordionContent = (props) => {
|
|
8
|
-
const { as, ref, className, children, ...restProps } = props;
|
|
9
|
-
const Component = as || "div";
|
|
10
|
-
const insideRef = useRef(null);
|
|
11
|
-
useImperativeHandle(ref, () => insideRef.current);
|
|
12
|
-
const { isMounded } = useMounted();
|
|
13
|
-
return (_jsx(AccordionPrimitive.Content, { asChild: true, "data-slot": "accordion-content", ...restProps, children: _jsx(Component, { ref: insideRef, className: cn(`
|
|
14
|
-
overflow-hidden
|
|
15
|
-
text-sm`, isMounded && `
|
|
16
|
-
data-[state=closed]:animate-accordion-up2
|
|
17
|
-
data-[state=open]:animate-accordion-down2`, className), children: children }) }));
|
|
18
|
-
};
|
|
19
|
-
AccordionContent.displayName = "AccordionContent";
|
|
20
|
-
export default AccordionContent;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
-
import type { ShadcnBaseProps } from "../../types/index.js";
|
|
3
|
-
type PropsType = ShadcnBaseProps<typeof AccordionPrimitive.Item> & {
|
|
4
|
-
as?: React.ElementType;
|
|
5
|
-
ref?: React.Ref<Element>;
|
|
6
|
-
};
|
|
7
|
-
declare const AccordionItem: {
|
|
8
|
-
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
displayName: string;
|
|
10
|
-
};
|
|
11
|
-
export default AccordionItem;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
4
|
-
import { cn } from "../../utils/index.js";
|
|
5
|
-
import { useImperativeHandle, useRef } from "react";
|
|
6
|
-
const AccordionItem = (props) => {
|
|
7
|
-
const { as, ref, className, children, ...restProps } = props;
|
|
8
|
-
const Component = as || "div";
|
|
9
|
-
const insideRef = useRef(null);
|
|
10
|
-
useImperativeHandle(ref, () => insideRef.current);
|
|
11
|
-
return (_jsx(AccordionPrimitive.Item, { asChild: true, "data-slot": "accordion-item", ...restProps, children: _jsx(Component, { ref: insideRef, className: cn(className), children: children }) }));
|
|
12
|
-
};
|
|
13
|
-
AccordionItem.displayName = "AccordionItem";
|
|
14
|
-
export default AccordionItem;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
-
import type { ShadcnBaseProps } from "../../types/index.js";
|
|
3
|
-
type PropsType = ShadcnBaseProps<typeof AccordionPrimitive.Trigger> & {
|
|
4
|
-
as?: React.ElementType;
|
|
5
|
-
ref?: React.Ref<Element>;
|
|
6
|
-
};
|
|
7
|
-
declare const AccordionTrigger: {
|
|
8
|
-
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
displayName: string;
|
|
10
|
-
};
|
|
11
|
-
export default AccordionTrigger;
|