@xwadex/fesd-next 0.3.4-7.9 → 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.
- package/dist/components/index.d.ts +186 -2
- package/dist/components/index.js +9561 -2
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.d.ts +68 -10
- package/dist/hooks/index.js +9243 -10
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +55 -5
- package/dist/index.js +36374 -5
- package/dist/index.js.map +1 -0
- package/dist/shadcns/index.d.ts +490 -48
- package/dist/shadcns/index.js +32495 -48
- package/dist/shadcns/index.js.map +1 -0
- package/dist/types/index.d.ts +17 -2
- package/dist/types/index.js +3 -2
- package/dist/types/index.js.map +1 -0
- package/dist/useAnchors-BzgJT2J9.d.ts +78 -0
- package/dist/utils/index.d.ts +12 -10
- package/dist/utils/index.js +56 -63
- package/dist/utils/index.js.map +1 -0
- package/package.json +11 -5
- package/dist/components/anchors/anchors.d.ts +0 -16
- package/dist/components/anchors/anchors.js +0 -26
- package/dist/components/anchors/index.d.ts +0 -1
- package/dist/components/anchors/index.js +0 -1
- package/dist/components/tests/index.d.ts +0 -1
- package/dist/components/tests/index.js +0 -1
- package/dist/components/tests/tests.d.ts +0 -4
- package/dist/components/tests/tests.js +0 -10
- package/dist/hooks/useAnchors.d.ts +0 -65
- package/dist/hooks/useAnchors.js +0 -170
- package/dist/hooks/useAsyncFetcher.d.ts +0 -11
- package/dist/hooks/useAsyncFetcher.js +0 -40
- package/dist/hooks/useCookies.d.ts +0 -6
- package/dist/hooks/useCookies.js +0 -19
- package/dist/hooks/useDebounce.d.ts +0 -7
- package/dist/hooks/useDebounce.js +0 -16
- package/dist/hooks/useDebounceValue.d.ts +0 -1
- package/dist/hooks/useDebounceValue.js +0 -17
- package/dist/hooks/useDragResize.d.ts +0 -22
- package/dist/hooks/useDragResize.js +0 -75
- package/dist/hooks/useEffectLeave.d.ts +0 -1
- package/dist/hooks/useEffectLeave.js +0 -12
- package/dist/hooks/useEffectOne.d.ts +0 -1
- package/dist/hooks/useEffectOne.js +0 -12
- package/dist/hooks/useHash.d.ts +0 -1
- package/dist/hooks/useHash.js +0 -19
- package/dist/hooks/useLocations.d.ts +0 -13
- package/dist/hooks/useLocations.js +0 -25
- package/dist/hooks/useMounted.d.ts +0 -3
- package/dist/hooks/useMounted.js +0 -7
- package/dist/hooks/useScrollContainers.d.ts +0 -27
- package/dist/hooks/useScrollContainers.js +0 -53
- package/dist/shadcns/components/ui/accordion.d.ts +0 -7
- package/dist/shadcns/components/ui/accordion.js +0 -18
- package/dist/shadcns/components/ui/alert-dialog.d.ts +0 -14
- package/dist/shadcns/components/ui/alert-dialog.js +0 -38
- package/dist/shadcns/components/ui/alert.d.ts +0 -9
- package/dist/shadcns/components/ui/alert.js +0 -25
- package/dist/shadcns/components/ui/aspect-ratio.d.ts +0 -3
- package/dist/shadcns/components/ui/aspect-ratio.js +0 -7
- package/dist/shadcns/components/ui/avatar.d.ts +0 -6
- package/dist/shadcns/components/ui/avatar.js +0 -14
- package/dist/shadcns/components/ui/badge.d.ts +0 -9
- package/dist/shadcns/components/ui/badge.js +0 -23
- package/dist/shadcns/components/ui/breadcrumb.d.ts +0 -11
- package/dist/shadcns/components/ui/breadcrumb.js +0 -27
- package/dist/shadcns/components/ui/button.d.ts +0 -10
- package/dist/shadcns/components/ui/button.js +0 -32
- package/dist/shadcns/components/ui/calendar.d.ts +0 -8
- package/dist/shadcns/components/ui/calendar.js +0 -73
- package/dist/shadcns/components/ui/card.d.ts +0 -9
- package/dist/shadcns/components/ui/card.js +0 -25
- package/dist/shadcns/components/ui/carousel.d.ts +0 -19
- package/dist/shadcns/components/ui/carousel.js +0 -91
- package/dist/shadcns/components/ui/chart.d.ts +0 -40
- package/dist/shadcns/components/ui/chart.js +0 -114
- package/dist/shadcns/components/ui/checkbox.d.ts +0 -4
- package/dist/shadcns/components/ui/checkbox.js +0 -9
- package/dist/shadcns/components/ui/collapsible.d.ts +0 -5
- package/dist/shadcns/components/ui/collapsible.js +0 -13
- package/dist/shadcns/components/ui/command.d.ts +0 -18
- package/dist/shadcns/components/ui/command.js +0 -33
- package/dist/shadcns/components/ui/context-menu.d.ts +0 -25
- package/dist/shadcns/components/ui/context-menu.js +0 -51
- package/dist/shadcns/components/ui/dialog.d.ts +0 -15
- package/dist/shadcns/components/ui/dialog.js +0 -36
- package/dist/shadcns/components/ui/drawer.d.ts +0 -13
- package/dist/shadcns/components/ui/drawer.js +0 -35
- package/dist/shadcns/components/ui/dropdown-menu.d.ts +0 -25
- package/dist/shadcns/components/ui/dropdown-menu.js +0 -51
- package/dist/shadcns/components/ui/form.d.ts +0 -24
- package/dist/shadcns/components/ui/form.js +0 -56
- package/dist/shadcns/components/ui/hover-card.d.ts +0 -6
- package/dist/shadcns/components/ui/hover-card.js +0 -14
- package/dist/shadcns/components/ui/input-otp.d.ts +0 -11
- package/dist/shadcns/components/ui/input-otp.js +0 -21
- package/dist/shadcns/components/ui/input.d.ts +0 -3
- package/dist/shadcns/components/ui/input.js +0 -6
- package/dist/shadcns/components/ui/label.d.ts +0 -4
- package/dist/shadcns/components/ui/label.js +0 -8
- package/dist/shadcns/components/ui/menubar.d.ts +0 -26
- package/dist/shadcns/components/ui/menubar.js +0 -54
- package/dist/shadcns/components/ui/navigation-menu.d.ts +0 -14
- package/dist/shadcns/components/ui/navigation-menu.js +0 -32
- package/dist/shadcns/components/ui/pagination.d.ts +0 -13
- package/dist/shadcns/components/ui/pagination.js +0 -28
- package/dist/shadcns/components/ui/popover.d.ts +0 -7
- package/dist/shadcns/components/ui/popover.js +0 -17
- package/dist/shadcns/components/ui/progress.d.ts +0 -4
- package/dist/shadcns/components/ui/progress.js +0 -8
- package/dist/shadcns/components/ui/radio-group.d.ts +0 -5
- package/dist/shadcns/components/ui/radio-group.js +0 -12
- package/dist/shadcns/components/ui/resizable.d.ts +0 -8
- package/dist/shadcns/components/ui/resizable.js +0 -15
- package/dist/shadcns/components/ui/scroll-area.d.ts +0 -5
- package/dist/shadcns/components/ui/scroll-area.js +0 -11
- package/dist/shadcns/components/ui/select.d.ts +0 -15
- package/dist/shadcns/components/ui/select.js +0 -38
- package/dist/shadcns/components/ui/separator.d.ts +0 -4
- package/dist/shadcns/components/ui/separator.js +0 -8
- package/dist/shadcns/components/ui/sheet.d.ts +0 -13
- package/dist/shadcns/components/ui/sheet.js +0 -40
- package/dist/shadcns/components/ui/sidebar.d.ts +0 -66
- package/dist/shadcns/components/ui/sidebar.js +0 -204
- package/dist/shadcns/components/ui/skeleton.d.ts +0 -2
- package/dist/shadcns/components/ui/skeleton.js +0 -6
- package/dist/shadcns/components/ui/slider.d.ts +0 -4
- package/dist/shadcns/components/ui/slider.js +0 -10
- package/dist/shadcns/components/ui/sonner.d.ts +0 -3
- package/dist/shadcns/components/ui/sonner.js +0 -13
- package/dist/shadcns/components/ui/switch.d.ts +0 -4
- package/dist/shadcns/components/ui/switch.js +0 -8
- package/dist/shadcns/components/ui/table.d.ts +0 -10
- package/dist/shadcns/components/ui/table.js +0 -28
- package/dist/shadcns/components/ui/tabs.d.ts +0 -7
- package/dist/shadcns/components/ui/tabs.js +0 -17
- package/dist/shadcns/components/ui/textarea.d.ts +0 -3
- package/dist/shadcns/components/ui/textarea.js +0 -7
- package/dist/shadcns/components/ui/toggle-group.d.ts +0 -7
- package/dist/shadcns/components/ui/toggle-group.js +0 -20
- package/dist/shadcns/components/ui/toggle.d.ts +0 -9
- package/dist/shadcns/components/ui/toggle.js +0 -26
- package/dist/shadcns/components/ui/tooltip.d.ts +0 -7
- package/dist/shadcns/components/ui/tooltip.js +0 -17
- package/dist/shadcns/hooks/use-mobile.d.ts +0 -1
- package/dist/shadcns/hooks/use-mobile.js +0 -15
- package/dist/shadcns/lib/utils.d.ts +0 -2
- package/dist/shadcns/lib/utils.js +0 -5
- package/dist/types/components.type.d.ts +0 -9
- package/dist/types/components.type.js +0 -1
- package/dist/types/shadcns.type.d.ts +0 -6
- package/dist/types/shadcns.type.js +0 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type ShadcnBaseProps<P extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>> = {
|
|
2
|
+
as?: React.ElementType;
|
|
3
|
+
} & React.ComponentProps<P>;
|
|
4
|
+
type BaseProps<T extends React.ElementType, P extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>> = {
|
|
5
|
+
as?: T;
|
|
6
|
+
} & React.ComponentProps<P>;
|
|
7
|
+
|
|
8
|
+
type AsTypes<T extends React.ElementType = "div"> = {
|
|
9
|
+
as?: T;
|
|
10
|
+
};
|
|
11
|
+
type AsPropsToOmit<T extends React.ElementType, P> = keyof (AsTypes<T> & P);
|
|
12
|
+
type AsPropsTypes<T extends React.ElementType, P = {}> = P & AsTypes<T> & Omit<React.ComponentPropsWithoutRef<T>, AsPropsToOmit<T, P>>;
|
|
13
|
+
type SlotsPropsTypes = {
|
|
14
|
+
[key: number]: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { AsPropsTypes, BaseProps, ShadcnBaseProps, SlotsPropsTypes };
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import { Easing, AnimationPlaybackControlsWithThen } from 'motion/react';
|
|
4
|
+
import Lenis from 'lenis';
|
|
5
|
+
|
|
6
|
+
interface AnimateOptions {
|
|
7
|
+
duration?: number;
|
|
8
|
+
delay?: number;
|
|
9
|
+
ease?: Easing | Easing[] | undefined;
|
|
10
|
+
onScroll?: (lenis?: Lenis) => void;
|
|
11
|
+
onScrolling?: (value: number) => void;
|
|
12
|
+
onScrolled?: (lenis?: Lenis) => void;
|
|
13
|
+
}
|
|
14
|
+
interface AnchorOptions extends AnimateOptions {
|
|
15
|
+
anchor: string;
|
|
16
|
+
container?: string;
|
|
17
|
+
offseters?: string | string[];
|
|
18
|
+
direction?: "x" | "y";
|
|
19
|
+
align?: "start" | "center" | "end";
|
|
20
|
+
offset?: number;
|
|
21
|
+
}
|
|
22
|
+
interface ScrollOptions extends AnimateOptions {
|
|
23
|
+
controllerKey: string;
|
|
24
|
+
containerDom: HTMLElement | Window;
|
|
25
|
+
anchorScrollValue: {
|
|
26
|
+
left: number;
|
|
27
|
+
top: number;
|
|
28
|
+
};
|
|
29
|
+
containerScrollValue: {
|
|
30
|
+
left: number;
|
|
31
|
+
top: number;
|
|
32
|
+
};
|
|
33
|
+
direction?: AnchorOptions["direction"];
|
|
34
|
+
}
|
|
35
|
+
type AnimateController = AnimationPlaybackControlsWithThen;
|
|
36
|
+
interface AnchorsMethods {
|
|
37
|
+
registerAnchors: (name: string) => {
|
|
38
|
+
[key: string]: string | React.RefObject<null>;
|
|
39
|
+
ref: React.RefObject<null>;
|
|
40
|
+
};
|
|
41
|
+
registerOffseters: (name: string) => {
|
|
42
|
+
[key: string]: string | React.RefObject<null>;
|
|
43
|
+
ref: React.RefObject<null>;
|
|
44
|
+
};
|
|
45
|
+
setStores: (options: AnchorStoreOptions) => void;
|
|
46
|
+
getStores: () => AnchorsStores;
|
|
47
|
+
scrollToAnchor: (anchorOptions: AnchorOptions) => void;
|
|
48
|
+
}
|
|
49
|
+
declare function useAnchors(): AnchorsMethods;
|
|
50
|
+
interface RegistrationDatas {
|
|
51
|
+
key: keyof AnchorsStores;
|
|
52
|
+
name: string;
|
|
53
|
+
}
|
|
54
|
+
declare function useRegistration({ key, name }: RegistrationDatas): {
|
|
55
|
+
[x: string]: string | React$1.RefObject<null>;
|
|
56
|
+
ref: React$1.RefObject<null>;
|
|
57
|
+
};
|
|
58
|
+
declare function registerAnchors(name: string): {
|
|
59
|
+
[x: string]: string | React$1.RefObject<null>;
|
|
60
|
+
ref: React$1.RefObject<null>;
|
|
61
|
+
};
|
|
62
|
+
declare function registerOffseters(name: string): {
|
|
63
|
+
[x: string]: string | React$1.RefObject<null>;
|
|
64
|
+
ref: React$1.RefObject<null>;
|
|
65
|
+
};
|
|
66
|
+
interface AnchorsStores {
|
|
67
|
+
anchors: Map<string, HTMLElement | null>;
|
|
68
|
+
offseters: Map<string, HTMLElement | null>;
|
|
69
|
+
}
|
|
70
|
+
declare const useAnchorsStores: zustand.UseBoundStore<zustand.StoreApi<AnchorsStores>>;
|
|
71
|
+
declare const getAnchorsStores: () => AnchorsStores;
|
|
72
|
+
interface AnchorStoreOptions extends RegistrationDatas {
|
|
73
|
+
node: HTMLDivElement | null;
|
|
74
|
+
action: "add" | "remove";
|
|
75
|
+
}
|
|
76
|
+
declare const setAnchorsStore: (options: AnchorStoreOptions) => void;
|
|
77
|
+
|
|
78
|
+
export { type AnchorOptions as A, type RegistrationDatas as R, type ScrollOptions as S, type AnchorStoreOptions as a, type AnchorsMethods as b, type AnchorsStores as c, type AnimateController as d, type AnimateOptions as e, registerOffseters as f, getAnchorsStores as g, useAnchorsStores as h, useRegistration as i, registerAnchors as r, setAnchorsStore as s, useAnchors as u };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const regexParse: (regexString: string, flags?: string) => RegExp | String;
|
|
2
|
+
declare const regexReplaceEach: (currentValue: string, replace: {
|
|
3
3
|
pattern: string;
|
|
4
4
|
flags?: string;
|
|
5
5
|
}[]) => string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
declare const mediaRatio: (width: number, height: number) => string;
|
|
7
|
+
declare const sleep: (time: number) => Promise<void>;
|
|
8
|
+
declare const querySearchWord: (str: string) => string;
|
|
9
|
+
declare const lockBody: (active: boolean, stillScrollHTMLElement?: HTMLElement | HTMLElement[] | null | undefined) => void;
|
|
10
|
+
declare const mergeClassName: (...argements: (string | number | boolean)[]) => string;
|
|
11
|
+
declare const getSearchParams: (searchParams: URLSearchParams) => any;
|
|
12
|
+
declare const getDomTransTime: (target: HTMLElement) => number;
|
|
13
|
+
declare const getURLSearchParams: (searchParams: URLSearchParams) => URLSearchParams;
|
|
14
|
+
|
|
15
|
+
export { getDomTransTime, getSearchParams, getURLSearchParams, lockBody, mediaRatio, mergeClassName, querySearchWord, regexParse, regexReplaceEach, sleep };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,70 +1,63 @@
|
|
|
1
|
-
import { lock, clearBodyLocks } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { lock, clearBodyLocks } from 'tua-body-scroll-lock';
|
|
2
|
+
|
|
3
|
+
// src/utils/index.ts
|
|
4
|
+
var regexParse = (regexString, flags) => {
|
|
5
|
+
const regex = regexString.replace(/\\\\/g, "\\");
|
|
6
|
+
try {
|
|
7
|
+
return new RegExp(regex);
|
|
8
|
+
} catch (e) {
|
|
9
|
+
console.error("Invalid regular expression:", regexString, e);
|
|
10
|
+
return regexString;
|
|
11
|
+
}
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
? current.replace(regexPattern, "")
|
|
16
|
-
: current;
|
|
13
|
+
var regexReplaceEach = (currentValue, replace) => replace.reduce((current, regexs) => {
|
|
14
|
+
const regexPattern = regexParse(regexs.pattern, regexs.flags);
|
|
15
|
+
return regexPattern instanceof RegExp ? current.replace(regexPattern, "") : current;
|
|
17
16
|
}, currentValue);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return resolve();
|
|
25
|
-
}, time);
|
|
17
|
+
var mediaRatio = (width, height) => Number(width) && Number(height) ? Math.round(height / width * 1e4) / 100 + "%" : "100%";
|
|
18
|
+
var sleep = (time) => new Promise((resolve) => {
|
|
19
|
+
let timer = setTimeout(() => {
|
|
20
|
+
clearTimeout(timer);
|
|
21
|
+
return resolve();
|
|
22
|
+
}, time);
|
|
26
23
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
var querySearchWord = (str) => str.trim().toLowerCase();
|
|
25
|
+
var lockBody = (active, stillScrollHTMLElement) => {
|
|
26
|
+
document.body.style.overflow = active ? "visible" : "";
|
|
27
|
+
active ? lock(stillScrollHTMLElement) : clearBodyLocks();
|
|
31
28
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
var mergeClassName = (...argements) => argements.toString().replace(/,/g, " ").replace(/\s+/g, " ").trim();
|
|
30
|
+
var getSearchParams = (searchParams) => {
|
|
31
|
+
const params = {};
|
|
32
|
+
searchParams.forEach((value, key) => {
|
|
33
|
+
params[key] = value;
|
|
34
|
+
});
|
|
35
|
+
return params;
|
|
37
36
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const parseTime = (timeStr) => {
|
|
54
|
-
timeStr = timeStr.trim();
|
|
55
|
-
if (timeStr.endsWith("ms"))
|
|
56
|
-
return parseFloat(timeStr);
|
|
57
|
-
if (timeStr.endsWith("s"))
|
|
58
|
-
return parseFloat(timeStr) * 1000;
|
|
59
|
-
return 0;
|
|
60
|
-
};
|
|
61
|
-
const durations = computedStyle.transitionDuration.split(",").map(parseTime);
|
|
62
|
-
const delays = computedStyle.transitionDelay.split(",").map(parseTime);
|
|
63
|
-
const maxLength = Math.max(durations.length, delays.length);
|
|
64
|
-
return Math.max(...Array.from({ length: maxLength }, (_, i) => (durations[i] || 0) + (delays[i] || 0)));
|
|
37
|
+
var getDomTransTime = (target) => {
|
|
38
|
+
if (!target) return 0;
|
|
39
|
+
const computedStyle = window.getComputedStyle(target);
|
|
40
|
+
const parseTime = (timeStr) => {
|
|
41
|
+
timeStr = timeStr.trim();
|
|
42
|
+
if (timeStr.endsWith("ms")) return parseFloat(timeStr);
|
|
43
|
+
if (timeStr.endsWith("s")) return parseFloat(timeStr) * 1e3;
|
|
44
|
+
return 0;
|
|
45
|
+
};
|
|
46
|
+
const durations = computedStyle.transitionDuration.split(",").map(parseTime);
|
|
47
|
+
const delays = computedStyle.transitionDelay.split(",").map(parseTime);
|
|
48
|
+
const maxLength = Math.max(durations.length, delays.length);
|
|
49
|
+
return Math.max(
|
|
50
|
+
...Array.from({ length: maxLength }, (_, i) => (durations[i] || 0) + (delays[i] || 0))
|
|
51
|
+
);
|
|
65
52
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
var getURLSearchParams = (searchParams) => {
|
|
54
|
+
const params = {};
|
|
55
|
+
searchParams.forEach((value, key) => {
|
|
56
|
+
params[key] = value;
|
|
57
|
+
});
|
|
58
|
+
return new URLSearchParams({ ...params });
|
|
70
59
|
};
|
|
60
|
+
|
|
61
|
+
export { getDomTransTime, getSearchParams, getURLSearchParams, lockBody, mediaRatio, mergeClassName, querySearchWord, regexParse, regexReplaceEach, sleep };
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":"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","file":"index.js","sourcesContent":["import { lock, clearBodyLocks } from \"tua-body-scroll-lock\"\nexport const regexParse = (regexString: string, flags?: string): RegExp | String => {\n\tconst regex = regexString.replace(/\\\\\\\\/g, \"\\\\\")\n\ttry {\n\t\treturn new RegExp(regex)\n\t} catch (e) {\n\t\tconsole.error(\"Invalid regular expression:\", regexString, e)\n\t\treturn regexString\n\t}\n}\n\nexport const regexReplaceEach = (\n\tcurrentValue: string,\n\treplace: { pattern: string, flags?: string }[]\n): string =>\n\treplace.reduce((current, regexs) => {\n\t\tconst regexPattern = regexParse(regexs.pattern, regexs.flags)\n\t\treturn regexPattern instanceof RegExp\n\t\t\t? current.replace(regexPattern, \"\")\n\t\t\t: current\n\t}, currentValue)\n\nexport const mediaRatio = (width: number, height: number) =>\n\tNumber(width) && Number(height)\n\t\t? Math.round(height / width * 10000) / 100 + \"%\"\n\t\t: \"100%\"\n\nexport const sleep = (time: number) => new Promise<void>((resolve) => {\n\tlet timer = setTimeout(() => {\n\t\tclearTimeout(timer)\n\t\treturn resolve()\n\t}, time)\n})\n\nexport const querySearchWord = (str: string) => str.trim().toLowerCase()\n\nexport const lockBody = (\n\tactive: boolean,\n\tstillScrollHTMLElement?: HTMLElement | HTMLElement[] | null | undefined\n): void => {\n\tdocument.body.style.overflow = active ? \"visible\" : \"\"\n\tactive ? lock(stillScrollHTMLElement) : clearBodyLocks()\n}\n\nexport const mergeClassName = (...argements: (string | number | boolean)[]): string =>\n\targements.toString().replace(/,/g, \" \").replace(/\\s+/g, \" \").trim()\n\nexport const getSearchParams = (searchParams: URLSearchParams) => {\n\tconst params: any = {}\n\tsearchParams.forEach((value: any, key: any) => { params[key] = value })\n\treturn params\n}\n\n// export const getDomTransTime = (target: HTMLElement): number => {\n// const computedStyle = window.getComputedStyle(target)\n// const transNumber = (time: string) => {\n// if (time.endsWith(\"ms\")) return parseFloat(time)\n// if (time.endsWith(\"s\")) return parseFloat(time) * 1000\n// return 0\n// }\n// const durations = computedStyle.transitionDuration.split(',').map(transNumber)\n// const delays = computedStyle.transitionDelay.split(',').map(transNumber)\n// return Math.max(...durations.map((d, i) => d + (delays[i] || 0)))\n// }\n\nexport const getDomTransTime = (target: HTMLElement): number => {\n\tif (!target) return 0\n\n\tconst computedStyle = window.getComputedStyle(target)\n\n\tconst parseTime = (timeStr: string): number => {\n\t\ttimeStr = timeStr.trim()\n\t\tif (timeStr.endsWith(\"ms\")) return parseFloat(timeStr)\n\t\tif (timeStr.endsWith(\"s\")) return parseFloat(timeStr) * 1000\n\t\treturn 0\n\t}\n\n\tconst durations = computedStyle.transitionDuration.split(\",\").map(parseTime)\n\tconst delays = computedStyle.transitionDelay.split(\",\").map(parseTime)\n\tconst maxLength = Math.max(durations.length, delays.length)\n\n\treturn Math.max(\n\t\t...Array.from({ length: maxLength }, (_, i) => (durations[i] || 0) + (delays[i] || 0))\n\t)\n}\n\nexport const getURLSearchParams = (searchParams: URLSearchParams) => {\n\tconst params: any = {}\n\tsearchParams.forEach((value: any, key: any) => { params[key] = value })\n\treturn new URLSearchParams({ ...params })\n}\n\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwadex/fesd-next",
|
|
3
|
-
"version": "0.3.4-
|
|
3
|
+
"version": "0.3.4-9",
|
|
4
4
|
"private": false,
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"import": "./dist/index.js",
|
|
@@ -35,12 +36,13 @@
|
|
|
35
36
|
],
|
|
36
37
|
"scripts": {
|
|
37
38
|
"clean": "rm -rf dist",
|
|
38
|
-
"build": "
|
|
39
|
+
"build:js": "tsup",
|
|
40
|
+
"build": "npm run clean && npm run build:js"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
41
43
|
"react": ">=18",
|
|
42
44
|
"react-dom": ">=18",
|
|
43
|
-
"next": ">=
|
|
45
|
+
"next": ">=16",
|
|
44
46
|
"@radix-ui/react-accordion": "^1.2.11",
|
|
45
47
|
"@radix-ui/react-slot": "^1.2.3",
|
|
46
48
|
"tailwindcss": ">=3",
|
|
@@ -52,5 +54,9 @@
|
|
|
52
54
|
"react-sortablejs": "^6.1.4",
|
|
53
55
|
"motion": "^12.18.1",
|
|
54
56
|
"tw-animate-css": "^1.3.4"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"tsup": "^8.5.1",
|
|
60
|
+
"typescript": "^5.9.3"
|
|
55
61
|
}
|
|
56
62
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { AnchorOptions } from "../../hooks/index.js";
|
|
2
|
-
interface PropsType extends React.ComponentProps<"div"> {
|
|
3
|
-
name: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const AnchorTarget: React.FC<PropsType>;
|
|
6
|
-
export declare const AnchorContainer: React.FC<PropsType>;
|
|
7
|
-
export declare const AnchorOffseter: React.FC<PropsType>;
|
|
8
|
-
type TriggerProps = AnchorOptions & React.ComponentProps<"div"> & {};
|
|
9
|
-
export declare const AnchorTrigger: React.FC<TriggerProps>;
|
|
10
|
-
export declare const Anchors: {
|
|
11
|
-
Trigger: import("react").FC<TriggerProps>;
|
|
12
|
-
Target: import("react").FC<PropsType>;
|
|
13
|
-
Container: import("react").FC<PropsType>;
|
|
14
|
-
Offseter: import("react").FC<PropsType>;
|
|
15
|
-
};
|
|
16
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useAnchors } from "../../hooks/index.js";
|
|
4
|
-
import { cn } from "../../shadcns/index.js";
|
|
5
|
-
export const AnchorTarget = ({ children, className, name }) => {
|
|
6
|
-
const { registerAnchors } = useAnchors();
|
|
7
|
-
return (_jsx("div", { className: cn(className), ...registerAnchors(name), children: children }));
|
|
8
|
-
};
|
|
9
|
-
export const AnchorContainer = ({ children, className, name }) => {
|
|
10
|
-
const { registerContainers } = useAnchors();
|
|
11
|
-
return (_jsx("div", { className: cn(className), ...registerContainers(name), children: children }));
|
|
12
|
-
};
|
|
13
|
-
export const AnchorOffseter = ({ children, className, name }) => {
|
|
14
|
-
const { registerOffseters } = useAnchors();
|
|
15
|
-
return (_jsx("div", { className: cn(className), ...registerOffseters(name), children: children }));
|
|
16
|
-
};
|
|
17
|
-
export const AnchorTrigger = ({ children, className, ...options }) => {
|
|
18
|
-
const { scrollToAnchor } = useAnchors();
|
|
19
|
-
return (_jsx("div", { className: cn(className), onClick: () => scrollToAnchor(options), children: children }));
|
|
20
|
-
};
|
|
21
|
-
export const Anchors = {
|
|
22
|
-
Trigger: AnchorTrigger,
|
|
23
|
-
Target: AnchorTarget,
|
|
24
|
-
Container: AnchorContainer,
|
|
25
|
-
Offseter: AnchorOffseter
|
|
26
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./anchors";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./anchors";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Tests } from "./tests";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Tests } from "./tests";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button } from "../../shadcns/index.js";
|
|
4
|
-
import { CarouselPrevious } from "../../shadcns/index.js";
|
|
5
|
-
import { Carousel } from "../../shadcns/index.js";
|
|
6
|
-
const Tests = () => {
|
|
7
|
-
return (_jsxs(_Fragment, { children: [_jsx(Carousel, { children: _jsx(CarouselPrevious, {}) }), _jsx(Button, { children: "test123133232" })] }));
|
|
8
|
-
};
|
|
9
|
-
Tests.displayName = "Tests";
|
|
10
|
-
export default Tests;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { animate } from "motion/react";
|
|
2
|
-
import type { Easing } from "motion/react";
|
|
3
|
-
import { registerContainers } from "./useScrollContainers";
|
|
4
|
-
export interface AnimateOptions {
|
|
5
|
-
duration?: number;
|
|
6
|
-
delay?: number;
|
|
7
|
-
ease?: Easing | Easing[] | undefined;
|
|
8
|
-
onScroll?: () => void;
|
|
9
|
-
onScrolling?: (value: number) => void;
|
|
10
|
-
onScrolled?: () => void;
|
|
11
|
-
}
|
|
12
|
-
export interface AnchorOptions extends AnimateOptions {
|
|
13
|
-
anchor: string;
|
|
14
|
-
container?: string;
|
|
15
|
-
offseters?: string | string[];
|
|
16
|
-
direction?: "x" | "y";
|
|
17
|
-
align?: "start" | "center" | "end";
|
|
18
|
-
offset?: number;
|
|
19
|
-
}
|
|
20
|
-
export interface ScrollOptions extends AnimateOptions {
|
|
21
|
-
controllerKey: string;
|
|
22
|
-
containerDom: HTMLElement | Window;
|
|
23
|
-
anchorScrollValue: {
|
|
24
|
-
left: number;
|
|
25
|
-
top: number;
|
|
26
|
-
};
|
|
27
|
-
containerScrollValue: {
|
|
28
|
-
left: number;
|
|
29
|
-
top: number;
|
|
30
|
-
};
|
|
31
|
-
direction?: AnchorOptions["direction"];
|
|
32
|
-
}
|
|
33
|
-
export type AnimateController = ReturnType<typeof animate>;
|
|
34
|
-
export declare function useAnchors(): {
|
|
35
|
-
registerAnchors: typeof registerAnchors;
|
|
36
|
-
registerOffseters: typeof registerOffseters;
|
|
37
|
-
registerContainers: typeof registerContainers;
|
|
38
|
-
setStores: (options: AnchorStoreOptions) => void;
|
|
39
|
-
getStores: () => AnchorsStores;
|
|
40
|
-
scrollToAnchor: (anchorOptions: AnchorOptions) => void;
|
|
41
|
-
};
|
|
42
|
-
export interface RegistrationDatas {
|
|
43
|
-
key: keyof AnchorsStores;
|
|
44
|
-
name: string;
|
|
45
|
-
node: HTMLDivElement | null;
|
|
46
|
-
}
|
|
47
|
-
export declare function registration({ name, key, node }: RegistrationDatas): void;
|
|
48
|
-
export declare function registerAnchors(name: string): {
|
|
49
|
-
ref: (node: HTMLDivElement | null) => void;
|
|
50
|
-
"data-anchor": string;
|
|
51
|
-
};
|
|
52
|
-
export declare function registerOffseters(name: string): {
|
|
53
|
-
ref: (node: HTMLDivElement | null) => void;
|
|
54
|
-
"data-anchor-offseter": string;
|
|
55
|
-
};
|
|
56
|
-
export interface AnchorsStores {
|
|
57
|
-
anchors: Map<string, HTMLElement | null>;
|
|
58
|
-
offseters: Map<string, HTMLElement | null>;
|
|
59
|
-
}
|
|
60
|
-
export declare const useAnchorsStores: import("zustand").UseBoundStore<import("zustand").StoreApi<AnchorsStores>>;
|
|
61
|
-
export declare const getAnchorsStores: () => AnchorsStores;
|
|
62
|
-
export interface AnchorStoreOptions extends RegistrationDatas {
|
|
63
|
-
action: "add" | "remove";
|
|
64
|
-
}
|
|
65
|
-
export declare const setAnchorsStore: (options: AnchorStoreOptions) => void;
|
package/dist/hooks/useAnchors.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
// update: 2025.11.07
|
|
3
|
-
// version: 0.0.2.bate
|
|
4
|
-
// dev: wade
|
|
5
|
-
import { useCallback, useMemo, useRef } from "react";
|
|
6
|
-
import { animate, motionValue } from "motion/react";
|
|
7
|
-
import { create } from "zustand";
|
|
8
|
-
import { getScrollContainersStores, registerContainers } from "./useScrollContainers";
|
|
9
|
-
const ANCHOR_ATTRIBUTE = "data-anchor";
|
|
10
|
-
const OFFSETER_ATTRIBUTE = "data-anchor-offseter";
|
|
11
|
-
export function useAnchors() {
|
|
12
|
-
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
|
-
if (direction !== "y" && direction !== "x") {
|
|
15
|
-
console.error(`Scroll Direction isn't 'x' or 'y' `);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const { left: scrollLeft, top: scrollTop } = containerScrollValue;
|
|
19
|
-
const { left: anchorLeft, top: anchorTop } = anchorScrollValue;
|
|
20
|
-
const isScrollX = direction === "x";
|
|
21
|
-
const isScrollY = direction === "y";
|
|
22
|
-
const startValue = isScrollX ? scrollLeft : scrollTop;
|
|
23
|
-
const endValue = isScrollX ? anchorLeft : anchorTop;
|
|
24
|
-
if (startValue == endValue) {
|
|
25
|
-
controllerRef.current.delete(controllerKey);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const motionStartValue = motionValue(startValue);
|
|
29
|
-
const onUpdate = (value) => {
|
|
30
|
-
const left = isScrollX ? value : undefined;
|
|
31
|
-
const top = isScrollY ? value : undefined;
|
|
32
|
-
containerDom.scrollTo({ left, top });
|
|
33
|
-
onScrolling?.(value);
|
|
34
|
-
};
|
|
35
|
-
const onComplete = () => {
|
|
36
|
-
controllerRef.current.delete(controllerKey);
|
|
37
|
-
onScrolled?.();
|
|
38
|
-
};
|
|
39
|
-
const options = { duration, ease, delay, onPlay, onUpdate, onComplete };
|
|
40
|
-
controllerRef.current.set(controllerKey, animate(motionStartValue, endValue, options));
|
|
41
|
-
}, []);
|
|
42
|
-
const scrollToAnchor = useCallback((anchorOptions) => {
|
|
43
|
-
const { anchor: anchorName, container: containerName, offseters, align, offset = 0, ...options } = anchorOptions;
|
|
44
|
-
const anchorsStores = getAnchorsStores();
|
|
45
|
-
const scrollContainersStores = getScrollContainersStores();
|
|
46
|
-
const isScrolltoAnchor = anchorName !== "#";
|
|
47
|
-
const isScrollContainer = containerName && containerName !== "window";
|
|
48
|
-
const controllerKey = containerName ?? "window";
|
|
49
|
-
if (controllerRef.current.has(controllerKey)) {
|
|
50
|
-
controllerRef.current.get(controllerKey)?.stop();
|
|
51
|
-
controllerRef.current.delete(controllerKey);
|
|
52
|
-
}
|
|
53
|
-
const anchorDom = isScrolltoAnchor
|
|
54
|
-
? anchorsStores.anchors.get(anchorName)
|
|
55
|
-
: undefined;
|
|
56
|
-
if (isScrolltoAnchor && !(anchorDom instanceof HTMLElement))
|
|
57
|
-
return;
|
|
58
|
-
const containerDom = isScrollContainer
|
|
59
|
-
? scrollContainersStores.containers.get(containerName)
|
|
60
|
-
: window;
|
|
61
|
-
if (!containerDom)
|
|
62
|
-
return;
|
|
63
|
-
const containerScrollValue = {
|
|
64
|
-
top: Math.round(isScrollContainer
|
|
65
|
-
? containerDom.scrollTop
|
|
66
|
-
: containerDom.pageYOffset),
|
|
67
|
-
left: Math.round(isScrollContainer
|
|
68
|
-
? containerDom.scrollLeft
|
|
69
|
-
: pageXOffset)
|
|
70
|
-
};
|
|
71
|
-
const containerRect = isScrollContainer
|
|
72
|
-
? containerDom.getBoundingClientRect()
|
|
73
|
-
: { top: 0, left: 0 };
|
|
74
|
-
const containerOffsetValue = {
|
|
75
|
-
left: containerScrollValue.left - (isScrollContainer ? containerRect.left : 0),
|
|
76
|
-
top: containerScrollValue.top - (isScrollContainer ? containerRect.top : 0)
|
|
77
|
-
};
|
|
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
|
-
const anchorRect = anchorDom ? anchorDom.getBoundingClientRect() : { left: 0, top: 0 };
|
|
91
|
-
const anchorScrollValue = {
|
|
92
|
-
left: isScrolltoAnchor
|
|
93
|
-
? Math.round(anchorRect.left + containerOffsetValue.left - offsetsSumValue.width)
|
|
94
|
-
: offsetsSumValue.width,
|
|
95
|
-
top: isScrolltoAnchor
|
|
96
|
-
? Math.round(anchorRect.top + containerOffsetValue.top - offsetsSumValue.height)
|
|
97
|
-
: offsetsSumValue.height
|
|
98
|
-
};
|
|
99
|
-
scrollAnimations({
|
|
100
|
-
controllerKey,
|
|
101
|
-
containerDom,
|
|
102
|
-
containerScrollValue,
|
|
103
|
-
anchorScrollValue,
|
|
104
|
-
...options
|
|
105
|
-
});
|
|
106
|
-
}, []);
|
|
107
|
-
const returnsMemo = useMemo(() => ({
|
|
108
|
-
registerAnchors,
|
|
109
|
-
registerOffseters,
|
|
110
|
-
registerContainers: registerContainers,
|
|
111
|
-
setStores: setAnchorsStore,
|
|
112
|
-
getStores: getAnchorsStores,
|
|
113
|
-
scrollToAnchor
|
|
114
|
-
}), [scrollToAnchor]);
|
|
115
|
-
return returnsMemo;
|
|
116
|
-
}
|
|
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" });
|
|
125
|
-
}
|
|
126
|
-
export function registerAnchors(name) {
|
|
127
|
-
const register = useCallback((node) => registration({ key: "anchors", name, node }), [name]);
|
|
128
|
-
return { ref: register, [ANCHOR_ATTRIBUTE]: name };
|
|
129
|
-
}
|
|
130
|
-
export function registerOffseters(name) {
|
|
131
|
-
const register = useCallback((node) => registration({ key: "offseters", name, node }), [name]);
|
|
132
|
-
return { ref: register, [OFFSETER_ATTRIBUTE]: name };
|
|
133
|
-
}
|
|
134
|
-
export const useAnchorsStores = create()(() => ({
|
|
135
|
-
anchors: new Map(),
|
|
136
|
-
// containers: new Map(),
|
|
137
|
-
offseters: new Map(),
|
|
138
|
-
}));
|
|
139
|
-
export const getAnchorsStores = () => useAnchorsStores.getState();
|
|
140
|
-
export const setAnchorsStore = (options) => {
|
|
141
|
-
const { key, action, name, node } = options;
|
|
142
|
-
useAnchorsStores.setState(stores => {
|
|
143
|
-
switch (key) {
|
|
144
|
-
case "anchors":
|
|
145
|
-
const anchorDom = stores.anchors?.get(name);
|
|
146
|
-
if (action == "add" && node instanceof HTMLElement) {
|
|
147
|
-
if (anchorDom == node)
|
|
148
|
-
return stores;
|
|
149
|
-
stores.anchors?.set(name, node);
|
|
150
|
-
}
|
|
151
|
-
else if (action == "remove" && anchorDom) {
|
|
152
|
-
stores.anchors?.delete(name);
|
|
153
|
-
}
|
|
154
|
-
return { anchors: stores.anchors };
|
|
155
|
-
case "offseters":
|
|
156
|
-
const offseterDom = stores.offseters?.get(name);
|
|
157
|
-
if (action == "add" && node instanceof HTMLElement) {
|
|
158
|
-
if (offseterDom == node)
|
|
159
|
-
return stores;
|
|
160
|
-
stores.offseters?.set(name, node);
|
|
161
|
-
}
|
|
162
|
-
else if (action == "remove" && offseterDom) {
|
|
163
|
-
stores.offseters?.delete(name);
|
|
164
|
-
}
|
|
165
|
-
return { offseters: stores.offseters };
|
|
166
|
-
default:
|
|
167
|
-
return stores;
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type ReturnDatasTypes = {
|
|
2
|
-
fetcher: (payload: PayloadTypes) => Promise<any>;
|
|
3
|
-
cancel: () => void;
|
|
4
|
-
pending: boolean;
|
|
5
|
-
};
|
|
6
|
-
interface PayloadTypes {
|
|
7
|
-
url: string | URL | globalThis.Request;
|
|
8
|
-
options?: RequestInit;
|
|
9
|
-
}
|
|
10
|
-
export declare function useAsyncFetcher(): ReturnDatasTypes;
|
|
11
|
-
export {};
|