@xwadex/fesd-next 0.3.4-7.2 → 0.3.4-7.21
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/anchors/anchors.d.ts +14 -0
- package/dist/components/anchors/anchors.js +24 -0
- package/dist/components/anchors/index.d.ts +1 -0
- package/dist/components/anchors/index.js +1 -0
- package/dist/components/embla-carousels/embla-carousels-hooks.d.ts +36 -0
- package/dist/components/embla-carousels/embla-carousels-hooks.js +84 -0
- package/dist/components/embla-carousels/embla-carousels.d.ts +23 -0
- package/dist/components/embla-carousels/embla-carousels.js +59 -0
- package/dist/components/embla-carousels/index.d.ts +2 -0
- package/dist/components/embla-carousels/index.js +2 -0
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +5 -2
- package/dist/components/puck-contents/-heading-block.d.ts +13 -0
- package/dist/components/puck-contents/-heading-block.js +77 -0
- package/dist/components/puck-contents/-media-content.d.ts +7 -0
- package/dist/components/puck-contents/-media-content.js +22 -0
- package/dist/components/puck-contents/-text-content.d.ts +13 -0
- package/dist/components/puck-contents/-text-content.js +148 -0
- package/dist/components/puck-contents/index.d.ts +2 -0
- package/dist/components/puck-contents/index.js +2 -0
- package/dist/components/puck-contents/puck-configs.d.ts +14 -0
- package/dist/components/puck-contents/puck-configs.js +65 -0
- package/dist/components/puck-contents/puck-contents-editor.d.ts +5 -0
- package/dist/components/puck-contents/puck-contents-editor.js +27 -0
- package/dist/components/puck-contents/puck-contents-rander.d.ts +5 -0
- package/dist/components/puck-contents/puck-contents-rander.js +14 -0
- package/dist/components/puck-contents/puck-inital-datas.d.ts +46 -0
- package/dist/components/puck-contents/puck-inital-datas.js +92 -0
- package/dist/components/scroll-containers/index.d.ts +3 -0
- package/dist/components/scroll-containers/index.js +3 -0
- package/dist/components/scroll-containers/lenis-scroll.d.ts +20 -0
- package/dist/components/scroll-containers/lenis-scroll.js +66 -0
- package/dist/components/scroll-containers/native-scroll.d.ts +6 -0
- package/dist/components/scroll-containers/native-scroll.js +24 -0
- package/dist/components/scroll-containers/scroll-containers.d.ts +25 -0
- package/dist/components/scroll-containers/scroll-containers.js +47 -0
- package/dist/components/tests/index.d.ts +1 -0
- package/dist/components/tests/index.js +1 -0
- package/dist/components/tests/tests.d.ts +4 -0
- package/dist/components/tests/tests.js +10 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useAnchors.d.ts +48 -33
- package/dist/hooks/useAnchors.js +181 -98
- package/dist/hooks/useHash.d.ts +1 -0
- package/dist/hooks/useHash.js +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/shadcns/components/ui/accordion.d.ts +7 -0
- package/dist/shadcns/components/ui/accordion.js +18 -0
- package/dist/shadcns/components/ui/alert-dialog.d.ts +14 -0
- package/dist/shadcns/components/ui/alert-dialog.js +38 -0
- package/dist/shadcns/components/ui/alert.d.ts +9 -0
- package/dist/shadcns/components/ui/alert.js +25 -0
- package/dist/shadcns/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/shadcns/components/ui/aspect-ratio.js +7 -0
- package/dist/shadcns/components/ui/avatar.d.ts +6 -0
- package/dist/shadcns/components/ui/avatar.js +14 -0
- package/dist/shadcns/components/ui/badge.d.ts +9 -0
- package/dist/shadcns/components/ui/badge.js +23 -0
- package/dist/shadcns/components/ui/breadcrumb.d.ts +11 -0
- package/dist/shadcns/components/ui/breadcrumb.js +27 -0
- package/dist/shadcns/components/ui/button-group.d.ts +11 -0
- package/dist/shadcns/components/ui/button-group.js +26 -0
- package/dist/shadcns/components/ui/button.d.ts +10 -0
- package/dist/shadcns/components/ui/button.js +32 -0
- package/dist/shadcns/components/ui/calendar.d.ts +8 -0
- package/dist/shadcns/components/ui/calendar.js +73 -0
- package/dist/shadcns/components/ui/card.d.ts +9 -0
- package/dist/shadcns/components/ui/card.js +25 -0
- package/dist/shadcns/components/ui/carousel.d.ts +19 -0
- package/dist/shadcns/components/ui/carousel.js +91 -0
- package/dist/shadcns/components/ui/chart.d.ts +40 -0
- package/dist/shadcns/components/ui/chart.js +114 -0
- package/dist/shadcns/components/ui/checkbox.d.ts +4 -0
- package/dist/shadcns/components/ui/checkbox.js +9 -0
- package/dist/shadcns/components/ui/collapsible.d.ts +5 -0
- package/dist/shadcns/components/ui/collapsible.js +13 -0
- package/dist/shadcns/components/ui/command.d.ts +18 -0
- package/dist/shadcns/components/ui/command.js +33 -0
- package/dist/shadcns/components/ui/context-menu.d.ts +25 -0
- package/dist/shadcns/components/ui/context-menu.js +51 -0
- package/dist/shadcns/components/ui/dialog.d.ts +15 -0
- package/dist/shadcns/components/ui/dialog.js +36 -0
- package/dist/shadcns/components/ui/drawer.d.ts +13 -0
- package/dist/shadcns/components/ui/drawer.js +35 -0
- package/dist/shadcns/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/shadcns/components/ui/dropdown-menu.js +51 -0
- package/dist/shadcns/components/ui/field.d.ts +24 -0
- package/dist/shadcns/components/ui/field.js +76 -0
- package/dist/shadcns/components/ui/form.d.ts +24 -0
- package/dist/shadcns/components/ui/form.js +56 -0
- package/dist/shadcns/components/ui/hover-card.d.ts +6 -0
- package/dist/shadcns/components/ui/hover-card.js +14 -0
- package/dist/shadcns/components/ui/input-otp.d.ts +11 -0
- package/dist/shadcns/components/ui/input-otp.js +21 -0
- package/dist/shadcns/components/ui/input.d.ts +3 -0
- package/dist/shadcns/components/ui/input.js +6 -0
- package/dist/shadcns/components/ui/item.d.ts +23 -0
- package/dist/shadcns/components/ui/item.js +65 -0
- package/dist/shadcns/components/ui/label.d.ts +4 -0
- package/dist/shadcns/components/ui/label.js +8 -0
- package/dist/shadcns/components/ui/menubar.d.ts +26 -0
- package/dist/shadcns/components/ui/menubar.js +54 -0
- package/dist/shadcns/components/ui/native-select.d.ts +7 -0
- package/dist/shadcns/components/ui/native-select.js +13 -0
- package/dist/shadcns/components/ui/navigation-menu.d.ts +14 -0
- package/dist/shadcns/components/ui/navigation-menu.js +32 -0
- package/dist/shadcns/components/ui/pagination.d.ts +13 -0
- package/dist/shadcns/components/ui/pagination.js +28 -0
- package/dist/shadcns/components/ui/popover.d.ts +7 -0
- package/dist/shadcns/components/ui/popover.js +17 -0
- package/dist/shadcns/components/ui/progress.d.ts +4 -0
- package/dist/shadcns/components/ui/progress.js +8 -0
- package/dist/shadcns/components/ui/radio-group.d.ts +5 -0
- package/dist/shadcns/components/ui/radio-group.js +12 -0
- package/dist/shadcns/components/ui/resizable.d.ts +8 -0
- package/dist/shadcns/components/ui/resizable.js +15 -0
- package/dist/shadcns/components/ui/scroll-area.d.ts +5 -0
- package/dist/shadcns/components/ui/scroll-area.js +11 -0
- package/dist/shadcns/components/ui/select.d.ts +15 -0
- package/dist/shadcns/components/ui/select.js +38 -0
- package/dist/shadcns/components/ui/separator.d.ts +4 -0
- package/dist/shadcns/components/ui/separator.js +8 -0
- package/dist/shadcns/components/ui/sheet.d.ts +13 -0
- package/dist/shadcns/components/ui/sheet.js +40 -0
- package/dist/shadcns/components/ui/sidebar.d.ts +66 -0
- package/dist/shadcns/components/ui/sidebar.js +204 -0
- package/dist/shadcns/components/ui/skeleton.d.ts +2 -0
- package/dist/shadcns/components/ui/skeleton.js +6 -0
- package/dist/shadcns/components/ui/slider.d.ts +4 -0
- package/dist/shadcns/components/ui/slider.js +10 -0
- package/dist/shadcns/components/ui/sonner.d.ts +3 -0
- package/dist/shadcns/components/ui/sonner.js +13 -0
- package/dist/shadcns/components/ui/switch.d.ts +4 -0
- package/dist/shadcns/components/ui/switch.js +8 -0
- package/dist/shadcns/components/ui/table.d.ts +10 -0
- package/dist/shadcns/components/ui/table.js +28 -0
- package/dist/shadcns/components/ui/tabs.d.ts +7 -0
- package/dist/shadcns/components/ui/tabs.js +17 -0
- package/dist/shadcns/components/ui/textarea.d.ts +3 -0
- package/dist/shadcns/components/ui/textarea.js +7 -0
- package/dist/shadcns/components/ui/toggle-group.d.ts +7 -0
- package/dist/shadcns/components/ui/toggle-group.js +20 -0
- package/dist/shadcns/components/ui/toggle.d.ts +9 -0
- package/dist/shadcns/components/ui/toggle.js +26 -0
- package/dist/shadcns/components/ui/tooltip.d.ts +7 -0
- package/dist/shadcns/components/ui/tooltip.js +17 -0
- package/dist/{hooks/useIsMobile.js → shadcns/hooks/use-mobile.js} +5 -6
- package/dist/shadcns/index.d.ts +48 -0
- package/dist/shadcns/index.js +48 -0
- package/dist/shadcns/lib/utils.d.ts +2 -0
- package/dist/shadcns/lib/utils.js +5 -0
- package/dist/types/shadcns.type.d.ts +0 -1
- package/dist/types/shadcns.type.js +1 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -5
- package/package.json +6 -2
- package/dist/components/TestComponent.d.ts +0 -4
- package/dist/components/TestComponent.js +0 -10
- /package/dist/{hooks/useIsMobile.d.ts → shadcns/hooks/use-mobile.d.ts} +0 -0
package/dist/hooks/useAnchors.js
CHANGED
|
@@ -1,121 +1,204 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// update: 2025.11.12
|
|
3
|
+
// version: 0.0.3.bate
|
|
4
|
+
// dev: wade
|
|
5
|
+
import { useCallback, useLayoutEffect, useMemo, useRef } from "react";
|
|
6
|
+
import { useAnimate, motionValue } from "motion/react";
|
|
4
7
|
import { create } from "zustand";
|
|
8
|
+
import { getScrollContainerStores, getRootLenis } from "../components/index.js";
|
|
9
|
+
import Lenis from "lenis";
|
|
10
|
+
const ANCHOR_ATTRIBUTE = "data-anchor";
|
|
11
|
+
const OFFSETER_ATTRIBUTE = "data-anchor-offseter";
|
|
5
12
|
export function useAnchors() {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const [_, animate] = useAnimate();
|
|
14
|
+
const controllerRef = useRef(new Map());
|
|
15
|
+
const scrollAnimations = useCallback(({ controllerKey, containerDom, anchorScrollValue, containerScrollValue, direction = "y", duration = 1, delay = 0, ease = [0, 1, .5, .99], onScroll: onPlay, onScrolled, onScrolling, ...props }) => {
|
|
16
|
+
if (direction !== "y" && direction !== "x") {
|
|
17
|
+
console.error(`Scroll Direction isn't 'x' or 'y' `);
|
|
11
18
|
return;
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
}
|
|
20
|
+
const { left: scrollLeft, top: scrollTop } = containerScrollValue;
|
|
21
|
+
const { left: anchorLeft, top: anchorTop } = anchorScrollValue;
|
|
22
|
+
const isScrollX = direction === "x";
|
|
23
|
+
const isScrollY = direction === "y";
|
|
24
|
+
const startValue = isScrollX ? scrollLeft : scrollTop;
|
|
25
|
+
const endValue = isScrollX ? anchorLeft : anchorTop;
|
|
26
|
+
if (startValue == endValue) {
|
|
27
|
+
controllerRef.current.delete(controllerKey);
|
|
14
28
|
return;
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
29
|
+
}
|
|
30
|
+
const motionStartValue = motionValue(startValue);
|
|
31
|
+
const onUpdate = (value) => {
|
|
32
|
+
const left = isScrollX ? value : undefined;
|
|
33
|
+
const top = isScrollY ? value : undefined;
|
|
34
|
+
containerDom.scrollTo({ left, top });
|
|
35
|
+
onScrolling?.(value);
|
|
36
|
+
};
|
|
37
|
+
const onComplete = () => {
|
|
38
|
+
controllerRef.current.delete(controllerKey);
|
|
39
|
+
onScrolled?.();
|
|
40
|
+
};
|
|
41
|
+
const options = {
|
|
42
|
+
duration,
|
|
43
|
+
ease,
|
|
44
|
+
delay,
|
|
45
|
+
onPlay,
|
|
46
|
+
onUpdate,
|
|
47
|
+
onComplete,
|
|
48
|
+
...props
|
|
49
|
+
};
|
|
50
|
+
controllerRef.current.set(controllerKey, animate(motionStartValue, endValue, options));
|
|
51
|
+
}, []);
|
|
52
|
+
const scrollToAnchor = useCallback((anchorOptions) => {
|
|
53
|
+
const { anchor: anchorName, container: containerName, offseters, align, offset = 0, direction = "y", ...options } = anchorOptions;
|
|
54
|
+
const anchorsStores = getAnchorsStores();
|
|
55
|
+
const scrollContainersStores = getScrollContainerStores();
|
|
56
|
+
const isScrolltoAnchor = anchorName !== "#";
|
|
57
|
+
const isScrollContainer = containerName && containerName !== "window";
|
|
58
|
+
const controllerKey = containerName ?? "window";
|
|
59
|
+
if (controllerRef.current.has(controllerKey)) {
|
|
60
|
+
controllerRef.current.get(controllerKey)?.stop();
|
|
61
|
+
controllerRef.current.delete(controllerKey);
|
|
62
|
+
}
|
|
63
|
+
const anchorDom = isScrolltoAnchor
|
|
64
|
+
? anchorsStores.anchors.get(anchorName)
|
|
65
|
+
: undefined;
|
|
66
|
+
if (isScrolltoAnchor && !(anchorDom instanceof HTMLElement))
|
|
18
67
|
return;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (scrollOffset == containerScrollTop)
|
|
68
|
+
const containerDom = isScrollContainer
|
|
69
|
+
? scrollContainersStores.containers.get(containerName)
|
|
70
|
+
: window;
|
|
71
|
+
if (!containerDom)
|
|
24
72
|
return;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
73
|
+
const getOffseterDomClient = (offseters) => {
|
|
74
|
+
const offseterDom = anchorsStores.offseters.get(offseters);
|
|
75
|
+
const { clientWidth, clientHeight } = offseterDom || {};
|
|
76
|
+
return { width: clientWidth ?? 0, height: clientHeight ?? 0 };
|
|
77
|
+
};
|
|
78
|
+
const offsets = Array.isArray(offseters)
|
|
79
|
+
? offseters.reduce((init, offseter) => {
|
|
80
|
+
const { width, height } = getOffseterDomClient(offseter);
|
|
81
|
+
return {
|
|
82
|
+
width: (init.width ?? 0) + width,
|
|
83
|
+
height: (init.height ?? 0) + height
|
|
84
|
+
};
|
|
85
|
+
}, {})
|
|
86
|
+
: typeof offseters == "string"
|
|
87
|
+
? getOffseterDomClient(offseters)
|
|
88
|
+
: { width: 0, height: 0 };
|
|
89
|
+
const offsetValue = {
|
|
90
|
+
width: direction === "x" ? offsets.width + offset : 0,
|
|
91
|
+
height: direction === "y" ? offsets.height + offset : 0,
|
|
92
|
+
};
|
|
93
|
+
const isLenisScroll = containerDom == window
|
|
94
|
+
&& window.document.documentElement.classList.contains("lenis")
|
|
95
|
+
|| containerDom instanceof Lenis;
|
|
96
|
+
if (isLenisScroll) {
|
|
97
|
+
const lenis = (isScrollContainer ? containerDom : getRootLenis()?.root);
|
|
98
|
+
// TODO 尚未找到可以判斷已經移動到錨點位置的方式
|
|
99
|
+
if (!lenis)
|
|
100
|
+
return;
|
|
101
|
+
const directionOffset = direction === "x"
|
|
102
|
+
? offsetValue.width + offset
|
|
103
|
+
: offsetValue.height + offset;
|
|
104
|
+
// TODO 尚未建立lenis options完整設定
|
|
105
|
+
lenis.scrollTo(anchorDom ?? 0, {
|
|
106
|
+
offset: (directionOffset * -1),
|
|
107
|
+
onStart: (lenis) => options?.onScroll?.(lenis),
|
|
108
|
+
onComplete: (lenis) => options?.onScrolled?.(lenis)
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const containerScrollValue = {
|
|
113
|
+
top: Math.round(isScrollContainer
|
|
114
|
+
? containerDom.scrollTop
|
|
115
|
+
: containerDom.pageYOffset),
|
|
116
|
+
left: Math.round(isScrollContainer
|
|
117
|
+
? containerDom.scrollLeft
|
|
118
|
+
: pageXOffset)
|
|
119
|
+
};
|
|
120
|
+
const containerRect = isScrollContainer
|
|
121
|
+
? containerDom.getBoundingClientRect()
|
|
122
|
+
: { top: 0, left: 0 };
|
|
123
|
+
const containerOffsetValue = {
|
|
124
|
+
left: containerScrollValue.left - (isScrollContainer ? containerRect.left : 0),
|
|
125
|
+
top: containerScrollValue.top - (isScrollContainer ? containerRect.top : 0)
|
|
126
|
+
};
|
|
127
|
+
const anchorRect = anchorDom ? anchorDom.getBoundingClientRect() : { left: 0, top: 0 };
|
|
128
|
+
const anchorScrollValue = {
|
|
129
|
+
left: isScrolltoAnchor
|
|
130
|
+
? Math.round(anchorRect.left + containerOffsetValue.left - offsetValue.width)
|
|
131
|
+
: offsetValue.width,
|
|
132
|
+
top: isScrolltoAnchor
|
|
133
|
+
? Math.round(anchorRect.top + containerOffsetValue.top - offsetValue.height)
|
|
134
|
+
: offsetValue.height
|
|
135
|
+
};
|
|
136
|
+
scrollAnimations({
|
|
137
|
+
controllerKey,
|
|
138
|
+
containerDom,
|
|
139
|
+
containerScrollValue,
|
|
140
|
+
anchorScrollValue,
|
|
141
|
+
direction,
|
|
142
|
+
...options
|
|
41
143
|
});
|
|
42
|
-
}, [
|
|
144
|
+
}, []);
|
|
43
145
|
const returnsMemo = useMemo(() => ({
|
|
44
146
|
registerAnchors,
|
|
45
|
-
registerContainers,
|
|
46
147
|
registerOffseters,
|
|
148
|
+
setStores: setAnchorsStore,
|
|
47
149
|
getStores: getAnchorsStores,
|
|
48
|
-
removeAnchor: removeAnchor,
|
|
49
|
-
removeOffseter: removeOffseter,
|
|
50
|
-
removeContainer: removeContainer,
|
|
51
150
|
scrollToAnchor
|
|
52
151
|
}), [scrollToAnchor]);
|
|
53
152
|
return returnsMemo;
|
|
54
153
|
}
|
|
154
|
+
export function useRegistration({ key, name }) {
|
|
155
|
+
const ref = useRef(null);
|
|
156
|
+
const attribute = key == "anchors" ? ANCHOR_ATTRIBUTE : OFFSETER_ATTRIBUTE;
|
|
157
|
+
useLayoutEffect(() => {
|
|
158
|
+
setAnchorsStore({ key, action: "add", node: ref.current, name });
|
|
159
|
+
return () => { setAnchorsStore({ key, action: "remove", node: ref.current, name }); };
|
|
160
|
+
}, []);
|
|
161
|
+
return { ref, [attribute]: name };
|
|
162
|
+
}
|
|
55
163
|
export function registerAnchors(name) {
|
|
56
|
-
|
|
57
|
-
if (node)
|
|
58
|
-
addAnchor(name, node);
|
|
59
|
-
else
|
|
60
|
-
removeAnchor(name);
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
ref: register,
|
|
64
|
-
"data-anchor": name
|
|
65
|
-
};
|
|
164
|
+
return useRegistration({ key: "anchors", name });
|
|
66
165
|
}
|
|
67
166
|
export function registerOffseters(name) {
|
|
68
|
-
|
|
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
|
-
};
|
|
167
|
+
return useRegistration({ key: "offseters", name });
|
|
90
168
|
}
|
|
91
|
-
const
|
|
169
|
+
export const useAnchorsStores = create()(() => ({
|
|
92
170
|
anchors: new Map(),
|
|
93
|
-
containers: new Map(),
|
|
94
171
|
offseters: new Map(),
|
|
95
|
-
};
|
|
96
|
-
export const useAnchorsStores = create()(() => anchorsStores);
|
|
172
|
+
}));
|
|
97
173
|
export const getAnchorsStores = () => useAnchorsStores.getState();
|
|
98
|
-
export const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
174
|
+
export const setAnchorsStore = (options) => {
|
|
175
|
+
const { key, action, name, node } = options;
|
|
176
|
+
useAnchorsStores.setState(stores => {
|
|
177
|
+
switch (key) {
|
|
178
|
+
case "anchors":
|
|
179
|
+
const anchorDom = stores.anchors?.get(name);
|
|
180
|
+
if (action == "add" && node instanceof HTMLElement) {
|
|
181
|
+
if (anchorDom == node)
|
|
182
|
+
return stores;
|
|
183
|
+
stores.anchors?.set(name, node);
|
|
184
|
+
}
|
|
185
|
+
else if (action == "remove" && anchorDom) {
|
|
186
|
+
stores.anchors?.delete(name);
|
|
187
|
+
}
|
|
188
|
+
return { anchors: stores.anchors };
|
|
189
|
+
case "offseters":
|
|
190
|
+
const offseterDom = stores.offseters?.get(name);
|
|
191
|
+
if (action == "add" && node instanceof HTMLElement) {
|
|
192
|
+
if (offseterDom == node)
|
|
193
|
+
return stores;
|
|
194
|
+
stores.offseters?.set(name, node);
|
|
195
|
+
}
|
|
196
|
+
else if (action == "remove" && offseterDom) {
|
|
197
|
+
stores.offseters?.delete(name);
|
|
198
|
+
}
|
|
199
|
+
return { offseters: stores.offseters };
|
|
200
|
+
default:
|
|
201
|
+
return stores;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useHash(): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
export function useHash() {
|
|
4
|
+
const [hash, setHash] = useState("");
|
|
5
|
+
const updateHash = () => setHash(window.location.hash);
|
|
6
|
+
const hashchangeEvent = (e) => {
|
|
7
|
+
e.preventDefault?.();
|
|
8
|
+
updateHash();
|
|
9
|
+
};
|
|
10
|
+
// 初始化
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
updateHash();
|
|
13
|
+
window.addEventListener("hashchange", hashchangeEvent);
|
|
14
|
+
return () => {
|
|
15
|
+
window.removeEventListener("hashchange", hashchangeEvent);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
return hash;
|
|
19
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
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 };
|
|
@@ -0,0 +1,18 @@
|
|
|
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 };
|
|
@@ -0,0 +1,14 @@
|
|
|
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, };
|
|
@@ -0,0 +1,38 @@
|
|
|
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, };
|
|
@@ -0,0 +1,9 @@
|
|
|
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 };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { cn } from '../../index.js';
|
|
5
|
+
const alertVariants = cva('relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current', {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: 'bg-card text-card-foreground',
|
|
9
|
+
destructive: 'text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
defaultVariants: {
|
|
13
|
+
variant: 'default',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
function Alert({ className, variant, ...props }) {
|
|
17
|
+
return (_jsx("div", { "data-slot": "alert", role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
|
|
18
|
+
}
|
|
19
|
+
function AlertTitle({ className, ...props }) {
|
|
20
|
+
return (_jsx("div", { "data-slot": "alert-title", className: cn('col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight', className), ...props }));
|
|
21
|
+
}
|
|
22
|
+
function AlertDescription({ className, ...props }) {
|
|
23
|
+
return (_jsx("div", { "data-slot": "alert-description", className: cn('text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed', className), ...props }));
|
|
24
|
+
}
|
|
25
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio';
|
|
4
|
+
function AspectRatio({ ...props }) {
|
|
5
|
+
return _jsx(AspectRatioPrimitive.Root, { "data-slot": "aspect-ratio", ...props });
|
|
6
|
+
}
|
|
7
|
+
export { AspectRatio };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
3
|
+
declare function Avatar({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function AvatarFallback({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Fallback>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export { Avatar, AvatarImage, AvatarFallback };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
4
|
+
import { cn } from '../../index.js';
|
|
5
|
+
function Avatar({ className, ...props }) {
|
|
6
|
+
return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", className: cn('relative flex size-8 shrink-0 overflow-hidden rounded-full', className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
function AvatarImage({ className, ...props }) {
|
|
9
|
+
return (_jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", className: cn('aspect-square size-full', className), ...props }));
|
|
10
|
+
}
|
|
11
|
+
function AvatarFallback({ className, ...props }) {
|
|
12
|
+
return (_jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", className: cn('bg-muted flex size-full items-center justify-center rounded-full', className), ...props }));
|
|
13
|
+
}
|
|
14
|
+
export { Avatar, AvatarImage, AvatarFallback };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
declare const badgeVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "outline" | "destructive" | "secondary" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { cn } from '../../index.js';
|
|
6
|
+
const badgeVariants = cva('inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden', {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: 'border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90',
|
|
10
|
+
secondary: 'border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90',
|
|
11
|
+
destructive: 'border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
12
|
+
outline: 'text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
variant: 'default',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
function Badge({ className, variant, asChild = false, ...props }) {
|
|
20
|
+
const Comp = asChild ? Slot : 'span';
|
|
21
|
+
return (_jsx(Comp, { "data-slot": "badge", className: cn(badgeVariants({ variant }), className), ...props }));
|
|
22
|
+
}
|
|
23
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare function Breadcrumb({ ...props }: React.ComponentProps<'nav'>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function BreadcrumbLink({ asChild, className, ...props }: React.ComponentProps<'a'> & {
|
|
6
|
+
asChild?: boolean;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
|
4
|
+
import { cn } from '../../index.js';
|
|
5
|
+
function Breadcrumb({ ...props }) {
|
|
6
|
+
return _jsx("nav", { "aria-label": "breadcrumb", "data-slot": "breadcrumb", ...props });
|
|
7
|
+
}
|
|
8
|
+
function BreadcrumbList({ className, ...props }) {
|
|
9
|
+
return (_jsx("ol", { "data-slot": "breadcrumb-list", className: cn('text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5', className), ...props }));
|
|
10
|
+
}
|
|
11
|
+
function BreadcrumbItem({ className, ...props }) {
|
|
12
|
+
return (_jsx("li", { "data-slot": "breadcrumb-item", className: cn('inline-flex items-center gap-1.5', className), ...props }));
|
|
13
|
+
}
|
|
14
|
+
function BreadcrumbLink({ asChild, className, ...props }) {
|
|
15
|
+
const Comp = asChild ? Slot : 'a';
|
|
16
|
+
return (_jsx(Comp, { "data-slot": "breadcrumb-link", className: cn('hover:text-foreground transition-colors', className), ...props }));
|
|
17
|
+
}
|
|
18
|
+
function BreadcrumbPage({ className, ...props }) {
|
|
19
|
+
return (_jsx("span", { "data-slot": "breadcrumb-page", role: "link", "aria-disabled": "true", "aria-current": "page", className: cn('text-foreground font-normal', className), ...props }));
|
|
20
|
+
}
|
|
21
|
+
function BreadcrumbSeparator({ children, className, ...props }) {
|
|
22
|
+
return (_jsx("li", { "data-slot": "breadcrumb-separator", role: "presentation", "aria-hidden": "true", className: cn('[&>svg]:size-3.5', className), ...props, children: children ?? _jsx(ChevronRight, {}) }));
|
|
23
|
+
}
|
|
24
|
+
function BreadcrumbEllipsis({ className, ...props }) {
|
|
25
|
+
return (_jsxs("span", { "data-slot": "breadcrumb-ellipsis", role: "presentation", "aria-hidden": "true", className: cn('flex size-9 items-center justify-center', className), ...props, children: [_jsx(MoreHorizontal, { className: "size-4" }), _jsx("span", { className: "sr-only", children: "More" })] }));
|
|
26
|
+
}
|
|
27
|
+
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import { Separator } from "../../index.js";
|
|
3
|
+
declare const buttonGroupVariants: (props?: ({
|
|
4
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
declare function ButtonGroup({ className, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function ButtonGroupText({ className, asChild, ...props }: React.ComponentProps<"div"> & {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function ButtonGroupSeparator({ className, orientation, ...props }: React.ComponentProps<typeof Separator>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants, };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn, Separator } from "../../index.js";
|
|
5
|
+
const buttonGroupVariants = cva("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2", {
|
|
6
|
+
variants: {
|
|
7
|
+
orientation: {
|
|
8
|
+
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
9
|
+
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
defaultVariants: {
|
|
13
|
+
orientation: "horizontal",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
function ButtonGroup({ className, orientation, ...props }) {
|
|
17
|
+
return (_jsx("div", { role: "group", "data-slot": "button-group", "data-orientation": orientation, className: cn(buttonGroupVariants({ orientation }), className), ...props }));
|
|
18
|
+
}
|
|
19
|
+
function ButtonGroupText({ className, asChild = false, ...props }) {
|
|
20
|
+
const Comp = asChild ? Slot : "div";
|
|
21
|
+
return (_jsx(Comp, { className: cn("bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", className), ...props }));
|
|
22
|
+
}
|
|
23
|
+
function ButtonGroupSeparator({ className, orientation = "vertical", ...props }) {
|
|
24
|
+
return (_jsx(Separator, { "data-slot": "button-group-separator", orientation: orientation, className: cn("bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto", className), ...props }));
|
|
25
|
+
}
|
|
26
|
+
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants, };
|