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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/dist/components/index.d.ts +186 -5
  2. package/dist/components/index.js +9561 -5
  3. package/dist/components/index.js.map +1 -0
  4. package/dist/hooks/index.d.ts +68 -10
  5. package/dist/hooks/index.js +9243 -10
  6. package/dist/hooks/index.js.map +1 -0
  7. package/dist/index.d.ts +55 -5
  8. package/dist/index.js +36374 -5
  9. package/dist/index.js.map +1 -0
  10. package/dist/shadcns/index.d.ts +490 -48
  11. package/dist/shadcns/index.js +32495 -48
  12. package/dist/shadcns/index.js.map +1 -0
  13. package/dist/types/index.d.ts +17 -2
  14. package/dist/types/index.js +3 -2
  15. package/dist/types/index.js.map +1 -0
  16. package/dist/useAnchors-BzgJT2J9.d.ts +78 -0
  17. package/dist/utils/index.d.ts +12 -10
  18. package/dist/utils/index.js +56 -63
  19. package/dist/utils/index.js.map +1 -0
  20. package/package.json +9 -7
  21. package/dist/components/anchors/anchors.d.ts +0 -14
  22. package/dist/components/anchors/anchors.js +0 -23
  23. package/dist/components/anchors/index.d.ts +0 -1
  24. package/dist/components/anchors/index.js +0 -1
  25. package/dist/components/embla-carousels/embla-carousels-hooks.d.ts +0 -36
  26. package/dist/components/embla-carousels/embla-carousels-hooks.js +0 -83
  27. package/dist/components/embla-carousels/embla-carousels.d.ts +0 -23
  28. package/dist/components/embla-carousels/embla-carousels.js +0 -58
  29. package/dist/components/embla-carousels/index.d.ts +0 -2
  30. package/dist/components/embla-carousels/index.js +0 -2
  31. package/dist/components/emblas/embla-container.d.ts +0 -8
  32. package/dist/components/emblas/embla-container.js +0 -12
  33. package/dist/components/emblas/embla-context.d.ts +0 -21
  34. package/dist/components/emblas/embla-context.js +0 -12
  35. package/dist/components/emblas/embla.d.ts +0 -20
  36. package/dist/components/emblas/embla.js +0 -124
  37. package/dist/components/emblas/emblas-pagination.d.ts +0 -11
  38. package/dist/components/emblas/emblas-pagination.js +0 -89
  39. package/dist/components/emblas/index.d.ts +0 -4
  40. package/dist/components/emblas/index.js +0 -4
  41. package/dist/components/scroll-containers/index.d.ts +0 -3
  42. package/dist/components/scroll-containers/index.js +0 -3
  43. package/dist/components/scroll-containers/lenis-scroll.d.ts +0 -20
  44. package/dist/components/scroll-containers/lenis-scroll.js +0 -65
  45. package/dist/components/scroll-containers/native-scroll.d.ts +0 -6
  46. package/dist/components/scroll-containers/native-scroll.js +0 -23
  47. package/dist/components/scroll-containers/scroll-containers.d.ts +0 -25
  48. package/dist/components/scroll-containers/scroll-containers.js +0 -46
  49. package/dist/components/tests/index.d.ts +0 -1
  50. package/dist/components/tests/index.js +0 -1
  51. package/dist/components/tests/tests.d.ts +0 -4
  52. package/dist/components/tests/tests.js +0 -9
  53. package/dist/hooks/useAnchors.d.ts +0 -73
  54. package/dist/hooks/useAnchors.js +0 -203
  55. package/dist/hooks/useAsyncFetcher.d.ts +0 -11
  56. package/dist/hooks/useAsyncFetcher.js +0 -39
  57. package/dist/hooks/useCookies.d.ts +0 -6
  58. package/dist/hooks/useCookies.js +0 -42
  59. package/dist/hooks/useDebounce.d.ts +0 -7
  60. package/dist/hooks/useDebounce.js +0 -15
  61. package/dist/hooks/useDebounceValue.d.ts +0 -1
  62. package/dist/hooks/useDebounceValue.js +0 -16
  63. package/dist/hooks/useDragResize.d.ts +0 -22
  64. package/dist/hooks/useDragResize.js +0 -74
  65. package/dist/hooks/useEffectLeave.d.ts +0 -1
  66. package/dist/hooks/useEffectLeave.js +0 -11
  67. package/dist/hooks/useEffectOne.d.ts +0 -1
  68. package/dist/hooks/useEffectOne.js +0 -11
  69. package/dist/hooks/useHash.d.ts +0 -1
  70. package/dist/hooks/useHash.js +0 -18
  71. package/dist/hooks/useLocations.d.ts +0 -13
  72. package/dist/hooks/useLocations.js +0 -24
  73. package/dist/hooks/useMounted.d.ts +0 -3
  74. package/dist/hooks/useMounted.js +0 -6
  75. package/dist/shadcns/components/ui/accordion.d.ts +0 -7
  76. package/dist/shadcns/components/ui/accordion.js +0 -18
  77. package/dist/shadcns/components/ui/alert-dialog.d.ts +0 -14
  78. package/dist/shadcns/components/ui/alert-dialog.js +0 -38
  79. package/dist/shadcns/components/ui/alert.d.ts +0 -9
  80. package/dist/shadcns/components/ui/alert.js +0 -25
  81. package/dist/shadcns/components/ui/aspect-ratio.d.ts +0 -3
  82. package/dist/shadcns/components/ui/aspect-ratio.js +0 -7
  83. package/dist/shadcns/components/ui/avatar.d.ts +0 -6
  84. package/dist/shadcns/components/ui/avatar.js +0 -14
  85. package/dist/shadcns/components/ui/badge.d.ts +0 -9
  86. package/dist/shadcns/components/ui/badge.js +0 -23
  87. package/dist/shadcns/components/ui/breadcrumb.d.ts +0 -11
  88. package/dist/shadcns/components/ui/breadcrumb.js +0 -27
  89. package/dist/shadcns/components/ui/button-group.d.ts +0 -11
  90. package/dist/shadcns/components/ui/button-group.js +0 -26
  91. package/dist/shadcns/components/ui/button.d.ts +0 -10
  92. package/dist/shadcns/components/ui/button.js +0 -31
  93. package/dist/shadcns/components/ui/calendar.d.ts +0 -8
  94. package/dist/shadcns/components/ui/calendar.js +0 -73
  95. package/dist/shadcns/components/ui/card.d.ts +0 -9
  96. package/dist/shadcns/components/ui/card.js +0 -25
  97. package/dist/shadcns/components/ui/carousel.d.ts +0 -19
  98. package/dist/shadcns/components/ui/carousel.js +0 -91
  99. package/dist/shadcns/components/ui/chart.d.ts +0 -40
  100. package/dist/shadcns/components/ui/chart.js +0 -114
  101. package/dist/shadcns/components/ui/checkbox.d.ts +0 -4
  102. package/dist/shadcns/components/ui/checkbox.js +0 -9
  103. package/dist/shadcns/components/ui/collapsible.d.ts +0 -5
  104. package/dist/shadcns/components/ui/collapsible.js +0 -13
  105. package/dist/shadcns/components/ui/command.d.ts +0 -18
  106. package/dist/shadcns/components/ui/command.js +0 -33
  107. package/dist/shadcns/components/ui/context-menu.d.ts +0 -25
  108. package/dist/shadcns/components/ui/context-menu.js +0 -51
  109. package/dist/shadcns/components/ui/dialog.d.ts +0 -15
  110. package/dist/shadcns/components/ui/dialog.js +0 -36
  111. package/dist/shadcns/components/ui/drawer.d.ts +0 -13
  112. package/dist/shadcns/components/ui/drawer.js +0 -35
  113. package/dist/shadcns/components/ui/dropdown-menu.d.ts +0 -25
  114. package/dist/shadcns/components/ui/dropdown-menu.js +0 -51
  115. package/dist/shadcns/components/ui/field.d.ts +0 -24
  116. package/dist/shadcns/components/ui/field.js +0 -75
  117. package/dist/shadcns/components/ui/form.d.ts +0 -24
  118. package/dist/shadcns/components/ui/form.js +0 -56
  119. package/dist/shadcns/components/ui/hover-card.d.ts +0 -6
  120. package/dist/shadcns/components/ui/hover-card.js +0 -14
  121. package/dist/shadcns/components/ui/input-otp.d.ts +0 -11
  122. package/dist/shadcns/components/ui/input-otp.js +0 -21
  123. package/dist/shadcns/components/ui/input.d.ts +0 -3
  124. package/dist/shadcns/components/ui/input.js +0 -6
  125. package/dist/shadcns/components/ui/item.d.ts +0 -23
  126. package/dist/shadcns/components/ui/item.js +0 -65
  127. package/dist/shadcns/components/ui/label.d.ts +0 -4
  128. package/dist/shadcns/components/ui/label.js +0 -8
  129. package/dist/shadcns/components/ui/menubar.d.ts +0 -26
  130. package/dist/shadcns/components/ui/menubar.js +0 -54
  131. package/dist/shadcns/components/ui/native-select.d.ts +0 -7
  132. package/dist/shadcns/components/ui/native-select.js +0 -13
  133. package/dist/shadcns/components/ui/navigation-menu.d.ts +0 -14
  134. package/dist/shadcns/components/ui/navigation-menu.js +0 -31
  135. package/dist/shadcns/components/ui/pagination.d.ts +0 -13
  136. package/dist/shadcns/components/ui/pagination.js +0 -28
  137. package/dist/shadcns/components/ui/popover.d.ts +0 -7
  138. package/dist/shadcns/components/ui/popover.js +0 -17
  139. package/dist/shadcns/components/ui/progress.d.ts +0 -4
  140. package/dist/shadcns/components/ui/progress.js +0 -8
  141. package/dist/shadcns/components/ui/radio-group.d.ts +0 -5
  142. package/dist/shadcns/components/ui/radio-group.js +0 -12
  143. package/dist/shadcns/components/ui/resizable.d.ts +0 -8
  144. package/dist/shadcns/components/ui/resizable.js +0 -15
  145. package/dist/shadcns/components/ui/scroll-area.d.ts +0 -5
  146. package/dist/shadcns/components/ui/scroll-area.js +0 -11
  147. package/dist/shadcns/components/ui/select.d.ts +0 -15
  148. package/dist/shadcns/components/ui/select.js +0 -38
  149. package/dist/shadcns/components/ui/separator.d.ts +0 -4
  150. package/dist/shadcns/components/ui/separator.js +0 -8
  151. package/dist/shadcns/components/ui/sheet.d.ts +0 -13
  152. package/dist/shadcns/components/ui/sheet.js +0 -40
  153. package/dist/shadcns/components/ui/sidebar.d.ts +0 -66
  154. package/dist/shadcns/components/ui/sidebar.js +0 -204
  155. package/dist/shadcns/components/ui/skeleton.d.ts +0 -2
  156. package/dist/shadcns/components/ui/skeleton.js +0 -6
  157. package/dist/shadcns/components/ui/slider.d.ts +0 -4
  158. package/dist/shadcns/components/ui/slider.js +0 -10
  159. package/dist/shadcns/components/ui/sonner.d.ts +0 -3
  160. package/dist/shadcns/components/ui/sonner.js +0 -13
  161. package/dist/shadcns/components/ui/switch.d.ts +0 -4
  162. package/dist/shadcns/components/ui/switch.js +0 -8
  163. package/dist/shadcns/components/ui/table.d.ts +0 -10
  164. package/dist/shadcns/components/ui/table.js +0 -28
  165. package/dist/shadcns/components/ui/tabs.d.ts +0 -7
  166. package/dist/shadcns/components/ui/tabs.js +0 -17
  167. package/dist/shadcns/components/ui/textarea.d.ts +0 -3
  168. package/dist/shadcns/components/ui/textarea.js +0 -6
  169. package/dist/shadcns/components/ui/toggle-group.d.ts +0 -7
  170. package/dist/shadcns/components/ui/toggle-group.js +0 -20
  171. package/dist/shadcns/components/ui/toggle.d.ts +0 -9
  172. package/dist/shadcns/components/ui/toggle.js +0 -26
  173. package/dist/shadcns/components/ui/tooltip.d.ts +0 -7
  174. package/dist/shadcns/components/ui/tooltip.js +0 -17
  175. package/dist/shadcns/hooks/use-mobile.d.ts +0 -1
  176. package/dist/shadcns/hooks/use-mobile.js +0 -15
  177. package/dist/shadcns/lib/utils.d.ts +0 -2
  178. package/dist/shadcns/lib/utils.js +0 -5
  179. package/dist/types/components.type.d.ts +0 -9
  180. package/dist/types/components.type.js +0 -1
  181. package/dist/types/shadcns.type.d.ts +0 -6
  182. package/dist/types/shadcns.type.js +0 -2
@@ -1,203 +0,0 @@
1
- // update: 2025.11.12
2
- // version: 0.0.3.bate
3
- // dev: wade
4
- import { useCallback, useLayoutEffect, useMemo, useRef } from "react";
5
- import { useAnimate, motionValue } from "motion/react";
6
- import { create } from "zustand";
7
- import { getScrollContainerStores, getRootLenis } from "../components/index.js";
8
- import Lenis from "lenis";
9
- const ANCHOR_ATTRIBUTE = "data-anchor";
10
- const OFFSETER_ATTRIBUTE = "data-anchor-offseter";
11
- export function useAnchors() {
12
- const [_, animate] = useAnimate();
13
- const controllerRef = useRef(new Map());
14
- const scrollAnimations = useCallback(({ controllerKey, containerDom, anchorScrollValue, containerScrollValue, direction = "y", duration = 1, delay = 0, ease = [0, 1, .5, .99], onScroll: onPlay, onScrolled, onScrolling, ...props }) => {
15
- if (direction !== "y" && direction !== "x") {
16
- console.error(`Scroll Direction isn't 'x' or 'y' `);
17
- return;
18
- }
19
- const { left: scrollLeft, top: scrollTop } = containerScrollValue;
20
- const { left: anchorLeft, top: anchorTop } = anchorScrollValue;
21
- const isScrollX = direction === "x";
22
- const isScrollY = direction === "y";
23
- const startValue = isScrollX ? scrollLeft : scrollTop;
24
- const endValue = isScrollX ? anchorLeft : anchorTop;
25
- if (startValue == endValue) {
26
- controllerRef.current.delete(controllerKey);
27
- return;
28
- }
29
- const motionStartValue = motionValue(startValue);
30
- const onUpdate = (value) => {
31
- const left = isScrollX ? value : undefined;
32
- const top = isScrollY ? value : undefined;
33
- containerDom.scrollTo({ left, top });
34
- onScrolling?.(value);
35
- };
36
- const onComplete = () => {
37
- controllerRef.current.delete(controllerKey);
38
- onScrolled?.();
39
- };
40
- const options = {
41
- duration,
42
- ease,
43
- delay,
44
- onPlay,
45
- onUpdate,
46
- onComplete,
47
- ...props
48
- };
49
- controllerRef.current.set(controllerKey, animate(motionStartValue, endValue, options));
50
- }, []);
51
- const scrollToAnchor = useCallback((anchorOptions) => {
52
- const { anchor: anchorName, container: containerName, offseters, align, offset = 0, direction = "y", ...options } = anchorOptions;
53
- const anchorsStores = getAnchorsStores();
54
- const scrollContainersStores = getScrollContainerStores();
55
- const isScrolltoAnchor = anchorName !== "#";
56
- const isScrollContainer = containerName && containerName !== "window";
57
- const controllerKey = containerName ?? "window";
58
- if (controllerRef.current.has(controllerKey)) {
59
- controllerRef.current.get(controllerKey)?.stop();
60
- controllerRef.current.delete(controllerKey);
61
- }
62
- const anchorDom = isScrolltoAnchor
63
- ? anchorsStores.anchors.get(anchorName)
64
- : undefined;
65
- if (isScrolltoAnchor && !(anchorDom instanceof HTMLElement))
66
- return;
67
- const containerDom = isScrollContainer
68
- ? scrollContainersStores.containers.get(containerName)
69
- : window;
70
- if (!containerDom)
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
- }
111
- const containerScrollValue = {
112
- top: Math.round(isScrollContainer
113
- ? containerDom.scrollTop
114
- : containerDom.pageYOffset),
115
- left: Math.round(isScrollContainer
116
- ? containerDom.scrollLeft
117
- : pageXOffset)
118
- };
119
- const containerRect = isScrollContainer
120
- ? containerDom.getBoundingClientRect()
121
- : { top: 0, left: 0 };
122
- const containerOffsetValue = {
123
- left: containerScrollValue.left - (isScrollContainer ? containerRect.left : 0),
124
- top: containerScrollValue.top - (isScrollContainer ? containerRect.top : 0)
125
- };
126
- const anchorRect = anchorDom ? anchorDom.getBoundingClientRect() : { left: 0, top: 0 };
127
- const anchorScrollValue = {
128
- left: isScrolltoAnchor
129
- ? Math.round(anchorRect.left + containerOffsetValue.left - offsetValue.width)
130
- : offsetValue.width,
131
- top: isScrolltoAnchor
132
- ? Math.round(anchorRect.top + containerOffsetValue.top - offsetValue.height)
133
- : offsetValue.height
134
- };
135
- scrollAnimations({
136
- controllerKey,
137
- containerDom,
138
- containerScrollValue,
139
- anchorScrollValue,
140
- direction,
141
- ...options
142
- });
143
- }, []);
144
- const returnsMemo = useMemo(() => ({
145
- registerAnchors,
146
- registerOffseters,
147
- setStores: setAnchorsStore,
148
- getStores: getAnchorsStores,
149
- scrollToAnchor
150
- }), [scrollToAnchor]);
151
- return returnsMemo;
152
- }
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 };
161
- }
162
- export function registerAnchors(name) {
163
- return useRegistration({ key: "anchors", name });
164
- }
165
- export function registerOffseters(name) {
166
- return useRegistration({ key: "offseters", name });
167
- }
168
- export const useAnchorsStores = create()(() => ({
169
- anchors: new Map(),
170
- offseters: new Map(),
171
- }));
172
- export const getAnchorsStores = () => useAnchorsStores.getState();
173
- export const setAnchorsStore = (options) => {
174
- const { key, action, name, node } = options;
175
- useAnchorsStores.setState(stores => {
176
- switch (key) {
177
- case "anchors":
178
- const anchorDom = stores.anchors?.get(name);
179
- if (action == "add" && node instanceof HTMLElement) {
180
- if (anchorDom == node)
181
- return stores;
182
- stores.anchors?.set(name, node);
183
- }
184
- else if (action == "remove" && anchorDom) {
185
- stores.anchors?.delete(name);
186
- }
187
- return { anchors: stores.anchors };
188
- case "offseters":
189
- const offseterDom = stores.offseters?.get(name);
190
- if (action == "add" && node instanceof HTMLElement) {
191
- if (offseterDom == node)
192
- return stores;
193
- stores.offseters?.set(name, node);
194
- }
195
- else if (action == "remove" && offseterDom) {
196
- stores.offseters?.delete(name);
197
- }
198
- return { offseters: stores.offseters };
199
- default:
200
- return stores;
201
- }
202
- });
203
- };
@@ -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 {};
@@ -1,39 +0,0 @@
1
- import { useRef, useState, useEffect, useCallback } from "react";
2
- export function useAsyncFetcher() {
3
- const [isPending, setPending] = useState(false);
4
- const controllerRef = useRef(null);
5
- const startFetch = useCallback(async ({ url, options }) => {
6
- if (isPending || !url)
7
- return;
8
- const controller = new AbortController();
9
- controllerRef.current = controller;
10
- setPending(true);
11
- try {
12
- const response = await fetch(url, {
13
- signal: controller.signal,
14
- ...options,
15
- });
16
- const datas = await response.json();
17
- return datas;
18
- }
19
- catch (error) {
20
- console.error("useAsyncFetche startFetch error:", error);
21
- return { status: false, error: error };
22
- }
23
- finally {
24
- setPending(false);
25
- }
26
- }, [isPending]);
27
- const cancelFetch = () => {
28
- controllerRef.current?.abort();
29
- setPending(false);
30
- };
31
- useEffect(() => {
32
- return () => controllerRef.current?.abort();
33
- }, []);
34
- return {
35
- pending: isPending,
36
- cancel: cancelFetch,
37
- fetcher: startFetch
38
- };
39
- }
@@ -1,6 +0,0 @@
1
- export declare function useCookies(): {
2
- setCookies: (name: string, value: string, days?: number) => void;
3
- getCookies: (name: string) => string | null;
4
- updateCookies: (name: string, value: string, days?: number) => void;
5
- deleteCookies: (name: string) => void;
6
- };
@@ -1,42 +0,0 @@
1
- import Cookies from 'js-cookie';
2
- // wade 2024.12.06 (js-cookie 版本)
3
- export function useCookies() {
4
- const setCookies = (name, value, days = 7) => {
5
- Cookies.set(name, value, { expires: days, path: "/" });
6
- };
7
- const getCookies = (name) => {
8
- return Cookies.get(name) ?? null;
9
- };
10
- const updateCookies = (name, value, days = 7) => {
11
- if (getCookies(name) !== null)
12
- setCookies(name, value, days);
13
- };
14
- const deleteCookies = (name) => {
15
- Cookies.remove(name, { path: "/" });
16
- };
17
- return { setCookies, getCookies, updateCookies, deleteCookies };
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,7 +0,0 @@
1
- export interface DebounceTypes {
2
- callback: () => any;
3
- dependency: any[];
4
- delay?: number;
5
- active?: boolean;
6
- }
7
- export declare function useDebounce({ callback, dependency, delay, active, }: DebounceTypes): void;
@@ -1,15 +0,0 @@
1
- import { useEffect, useRef } from "react";
2
- export function useDebounce({ callback, dependency = [], delay = 500, active = true, }) {
3
- if (!active || !callback)
4
- return;
5
- const timerRef = useRef(null);
6
- useEffect(() => {
7
- if (timerRef.current)
8
- clearTimeout(timerRef.current);
9
- timerRef.current = setTimeout(callback, delay);
10
- return () => {
11
- if (timerRef.current)
12
- clearTimeout(timerRef.current);
13
- };
14
- }, [...dependency]);
15
- }
@@ -1 +0,0 @@
1
- export declare function useDebounceValue<T>(value: T, delay?: number): T;
@@ -1,16 +0,0 @@
1
- import { useEffect, useRef, useState } from "react";
2
- export function useDebounceValue(value, delay = 500) {
3
- const [debounceValue, setDebounceValue] = useState(value);
4
- const timerRef = useRef(undefined);
5
- useEffect(() => {
6
- if (timerRef.current)
7
- clearTimeout(timerRef.current);
8
- timerRef.current = setTimeout(() => setDebounceValue(value), delay);
9
- return () => {
10
- if (timerRef.current)
11
- clearTimeout(timerRef.current);
12
- };
13
- }, [value, delay]);
14
- return debounceValue;
15
- }
16
- ;
@@ -1,22 +0,0 @@
1
- export interface ResizeTypes {
2
- width?: number | string;
3
- height?: number | string;
4
- }
5
- export interface DragResizeProps {
6
- active?: boolean;
7
- direction?: "horizontal" | "vertical";
8
- minWidth?: number;
9
- maxWidth?: number;
10
- minHeight?: number;
11
- maxHeight?: number;
12
- onInit?: (size: ResizeTypes) => void;
13
- onResizeStart?: (size: ResizeTypes) => void;
14
- onResizing?: (size: ResizeTypes) => void;
15
- onResizeEnd?: (size: ResizeTypes) => void;
16
- }
17
- export type DragResizeTypes = {
18
- dragRef: React.RefObject<HTMLDivElement | null>;
19
- resizeRef: React.RefObject<HTMLDivElement | null>;
20
- resize?: ResizeTypes;
21
- };
22
- export declare function useDragResize({ active, direction, minWidth, maxWidth, minHeight, maxHeight, onInit, onResizeStart, onResizing, onResizeEnd }: DragResizeProps): DragResizeTypes;
@@ -1,74 +0,0 @@
1
- //wade 2024.12.06
2
- import { useEffect, useRef, useState } from "react";
3
- export function useDragResize({ active = true, direction = "horizontal", minWidth, maxWidth, minHeight, maxHeight, onInit, onResizeStart, onResizing, onResizeEnd }) {
4
- const dragRef = useRef(null);
5
- const resizeRef = useRef(null);
6
- const [resize, setResize] = useState({ width: 0, height: 0 });
7
- const getResizeSizeValue = () => {
8
- if (!resizeRef.current)
9
- return;
10
- const { width: w, height: h } = resizeRef.current.style;
11
- const width = Number(w.replace("px", "")) ?? "inherit";
12
- const height = Number(h.replace("px", "")) ?? "inherit";
13
- return { width };
14
- };
15
- const setResizeValue = (clientX, clientY) => {
16
- if (!resizeRef.current)
17
- return;
18
- const rect = resizeRef.current.getBoundingClientRect();
19
- const resizeWidth = clientX - rect.left;
20
- const resizeHeight = clientY - rect.top;
21
- if (direction == "horizontal"
22
- && (minWidth && resizeWidth >= minWidth)
23
- && (maxWidth && resizeWidth <= maxWidth)) {
24
- resizeRef.current.style.width = resizeWidth + "px";
25
- return { width: resizeWidth, height: undefined };
26
- }
27
- if (direction == "vertical"
28
- && (minHeight && resizeWidth >= minHeight)
29
- && (maxHeight && resizeWidth <= maxHeight)) {
30
- resizeRef.current.style.height = resizeHeight + "px";
31
- return { width: undefined, height: resizeHeight };
32
- }
33
- };
34
- const onInitCallback = () => {
35
- const resizeValue = getResizeSizeValue();
36
- resizeValue && onInit?.(resizeValue);
37
- };
38
- const removeEventListeners = () => {
39
- document.removeEventListener("mousemove", onMouseMove);
40
- document.removeEventListener("mouseup", onMouseUp);
41
- };
42
- const onMouseMove = (e) => {
43
- const resizeValue = setResizeValue(e.clientX, e.clientY);
44
- if (!resizeValue)
45
- return;
46
- setResize(() => ({ ...resizeValue }));
47
- onResizing?.(resizeValue);
48
- };
49
- const onMouseUp = () => {
50
- const resizeValue = getResizeSizeValue();
51
- resizeValue && onResizeEnd?.(resizeValue);
52
- removeEventListeners();
53
- };
54
- const onDragRefMouseDown = (e) => {
55
- e.preventDefault();
56
- const resizeValue = getResizeSizeValue();
57
- resizeValue && onResizeStart?.(resizeValue);
58
- document.addEventListener("mousemove", onMouseMove);
59
- document.addEventListener("mouseup", onMouseUp);
60
- };
61
- useEffect(() => {
62
- if (active && dragRef.current && resizeRef.current) {
63
- dragRef.current.onmousedown = onDragRefMouseDown;
64
- onInit && onInitCallback();
65
- }
66
- return () => {
67
- if (!dragRef?.current)
68
- return;
69
- dragRef.current.onmousedown = null;
70
- removeEventListeners();
71
- };
72
- }, [active]);
73
- return { dragRef, resizeRef, resize };
74
- }
@@ -1 +0,0 @@
1
- export declare function useEffectLeave(callback: () => void): void;
@@ -1,11 +0,0 @@
1
- import { useEffect, useRef } from "react";
2
- export function useEffectLeave(callback) {
3
- const callbackRef = useRef(callback);
4
- callbackRef.current = callback;
5
- useEffect(() => {
6
- return () => {
7
- callbackRef.current?.();
8
- callbackRef.current = null;
9
- };
10
- }, []);
11
- }
@@ -1 +0,0 @@
1
- export declare function useEffectOne(callback: () => void): void;
@@ -1,11 +0,0 @@
1
- import { useEffect, useRef } from "react";
2
- export function useEffectOne(callback) {
3
- const callbackRef = useRef(callback);
4
- callbackRef.current = callback;
5
- useEffect(() => {
6
- callbackRef.current?.();
7
- return () => {
8
- callbackRef.current = null;
9
- };
10
- }, []);
11
- }
@@ -1 +0,0 @@
1
- export declare function useHash(): string;
@@ -1,18 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- export function useHash() {
3
- const [hash, setHash] = useState("");
4
- const updateHash = () => setHash(window.location.hash);
5
- const hashchangeEvent = (e) => {
6
- e.preventDefault?.();
7
- updateHash();
8
- };
9
- // 初始化
10
- useEffect(() => {
11
- updateHash();
12
- window.addEventListener("hashchange", hashchangeEvent);
13
- return () => {
14
- window.removeEventListener("hashchange", hashchangeEvent);
15
- };
16
- }, []);
17
- return hash;
18
- }
@@ -1,13 +0,0 @@
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 {};
@@ -1,24 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- ;
3
- export function useLocations() {
4
- const [locations, setLocations] = useState({
5
- hash: "",
6
- host: "",
7
- hostname: "",
8
- href: "",
9
- origin: "",
10
- pathname: "",
11
- port: "",
12
- protocol: "",
13
- search: "",
14
- });
15
- const getLocationValue = () => {
16
- setLocations({ ...window.location });
17
- };
18
- useEffect(() => {
19
- if (typeof window === "undefined")
20
- return;
21
- getLocationValue();
22
- }, []);
23
- return locations;
24
- }
@@ -1,3 +0,0 @@
1
- export declare function useMounted(): {
2
- isMounded: boolean;
3
- };
@@ -1,6 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- export function useMounted() {
3
- const [isMounded, setMounded] = useState(false);
4
- useEffect(() => { setMounded(true); }, []);
5
- return { isMounded };
6
- }
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- import * as AccordionPrimitive from '@radix-ui/react-accordion';
3
- declare function Accordion({ ...props }: React.ComponentProps<typeof AccordionPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
- declare function AccordionItem({ className, ...props }: React.ComponentProps<typeof AccordionPrimitive.Item>): import("react/jsx-runtime").JSX.Element;
5
- declare function AccordionTrigger({ className, children, ...props }: React.ComponentProps<typeof AccordionPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
6
- declare function AccordionContent({ className, children, ...props }: React.ComponentProps<typeof AccordionPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
7
- export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
@@ -1,18 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as AccordionPrimitive from '@radix-ui/react-accordion';
4
- import { ChevronDownIcon } from 'lucide-react';
5
- import { cn } from '../../index.js';
6
- function Accordion({ ...props }) {
7
- return _jsx(AccordionPrimitive.Root, { "data-slot": "accordion", ...props });
8
- }
9
- function AccordionItem({ className, ...props }) {
10
- return (_jsx(AccordionPrimitive.Item, { "data-slot": "accordion-item", className: cn('border-b last:border-b-0', className), ...props }));
11
- }
12
- function AccordionTrigger({ className, children, ...props }) {
13
- return (_jsx(AccordionPrimitive.Header, { className: "flex", children: _jsxs(AccordionPrimitive.Trigger, { "data-slot": "accordion-trigger", className: cn('focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180', className), ...props, children: [children, _jsx(ChevronDownIcon, { className: "text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" })] }) }));
14
- }
15
- function AccordionContent({ className, children, ...props }) {
16
- return (_jsx(AccordionPrimitive.Content, { "data-slot": "accordion-content", className: "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm", ...props, children: _jsx("div", { className: cn('pt-0 pb-4', className), children: children }) }));
17
- }
18
- export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
3
- declare function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
- declare function AlertDialogTrigger({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
5
- declare function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
6
- declare function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>): import("react/jsx-runtime").JSX.Element;
7
- declare function AlertDialogContent({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
8
- declare function AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
9
- declare function AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
10
- declare function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
11
- declare function AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
12
- declare function AlertDialogAction({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Action>): import("react/jsx-runtime").JSX.Element;
13
- declare function AlertDialogCancel({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>): import("react/jsx-runtime").JSX.Element;
14
- export { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, };
@@ -1,38 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
4
- import { cn, buttonVariants } from '../../index.js';
5
- function AlertDialog({ ...props }) {
6
- return _jsx(AlertDialogPrimitive.Root, { "data-slot": "alert-dialog", ...props });
7
- }
8
- function AlertDialogTrigger({ ...props }) {
9
- return _jsx(AlertDialogPrimitive.Trigger, { "data-slot": "alert-dialog-trigger", ...props });
10
- }
11
- function AlertDialogPortal({ ...props }) {
12
- return _jsx(AlertDialogPrimitive.Portal, { "data-slot": "alert-dialog-portal", ...props });
13
- }
14
- function AlertDialogOverlay({ className, ...props }) {
15
- return (_jsx(AlertDialogPrimitive.Overlay, { "data-slot": "alert-dialog-overlay", className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50', className), ...props }));
16
- }
17
- function AlertDialogContent({ className, ...props }) {
18
- return (_jsxs(AlertDialogPortal, { children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Content, { "data-slot": "alert-dialog-content", className: cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg', className), ...props })] }));
19
- }
20
- function AlertDialogHeader({ className, ...props }) {
21
- return (_jsx("div", { "data-slot": "alert-dialog-header", className: cn('flex flex-col gap-2 text-center sm:text-left', className), ...props }));
22
- }
23
- function AlertDialogFooter({ className, ...props }) {
24
- return (_jsx("div", { "data-slot": "alert-dialog-footer", className: cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className), ...props }));
25
- }
26
- function AlertDialogTitle({ className, ...props }) {
27
- return (_jsx(AlertDialogPrimitive.Title, { "data-slot": "alert-dialog-title", className: cn('text-lg font-semibold', className), ...props }));
28
- }
29
- function AlertDialogDescription({ className, ...props }) {
30
- return (_jsx(AlertDialogPrimitive.Description, { "data-slot": "alert-dialog-description", className: cn('text-muted-foreground text-sm', className), ...props }));
31
- }
32
- function AlertDialogAction({ className, ...props }) {
33
- return _jsx(AlertDialogPrimitive.Action, { className: cn(buttonVariants(), className), ...props });
34
- }
35
- function AlertDialogCancel({ className, ...props }) {
36
- return (_jsx(AlertDialogPrimitive.Cancel, { className: cn(buttonVariants({ variant: 'outline' }), className), ...props }));
37
- }
38
- export { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, };
@@ -1,9 +0,0 @@
1
- import * as React from 'react';
2
- import { type VariantProps } from 'class-variance-authority';
3
- declare const alertVariants: (props?: ({
4
- variant?: "default" | "destructive" | null | undefined;
5
- } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
- declare function Alert({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>): import("react/jsx-runtime").JSX.Element;
7
- declare function AlertTitle({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
8
- declare function AlertDescription({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
9
- export { Alert, AlertTitle, AlertDescription };