@vllnt/ui 0.1.4 → 0.1.7-canary.2c4792f
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/accordion/accordion.js +172 -0
- package/dist/components/accordion/index.js +12 -0
- package/dist/components/alert/alert.js +53 -0
- package/dist/components/alert/index.js +7 -0
- package/dist/components/alert-dialog/alert-dialog.js +117 -0
- package/dist/components/alert-dialog/index.js +26 -0
- package/dist/components/aspect-ratio/aspect-ratio.js +6 -0
- package/dist/components/aspect-ratio/index.js +4 -0
- package/dist/components/avatar/avatar.js +43 -0
- package/dist/components/avatar/index.js +6 -0
- package/dist/components/badge/badge.js +26 -0
- package/dist/components/badge/index.js +5 -0
- package/dist/components/blog-card/blog-card.js +50 -0
- package/dist/components/blog-card/index.js +5 -0
- package/dist/components/breadcrumb/breadcrumb.js +61 -0
- package/dist/components/breadcrumb/index.js +4 -0
- package/dist/components/button/button.js +48 -0
- package/dist/components/button/index.js +5 -0
- package/dist/components/calendar/calendar.js +71 -0
- package/dist/components/calendar/index.js +4 -0
- package/dist/components/callout/callout.js +59 -0
- package/dist/components/callout/index.js +4 -0
- package/dist/components/card/card.js +64 -0
- package/dist/components/card/index.js +16 -0
- package/dist/components/carousel/carousel.js +239 -0
- package/dist/components/carousel/index.js +14 -0
- package/dist/components/category-filter/category-filter.js +34 -0
- package/dist/components/category-filter/index.js +4 -0
- package/dist/components/chart/area-chart.js +99 -0
- package/dist/components/chart/bar-chart.js +80 -0
- package/dist/components/chart/index.js +3 -0
- package/dist/components/chart/line-chart.js +97 -0
- package/dist/components/checkbox/checkbox.js +28 -0
- package/dist/components/checkbox/index.js +4 -0
- package/dist/components/checklist/checklist.js +181 -0
- package/dist/components/checklist/index.js +6 -0
- package/dist/components/code-block/code-block.js +126 -0
- package/dist/components/code-block/index.js +4 -0
- package/dist/components/code-playground/code-playground.js +86 -0
- package/dist/components/code-playground/index.js +8 -0
- package/dist/components/collapsible/collapsible.js +10 -0
- package/dist/components/collapsible/index.js +10 -0
- package/dist/components/command/command.js +123 -0
- package/dist/components/command/index.js +22 -0
- package/dist/components/comparison/comparison.js +121 -0
- package/dist/components/comparison/index.js +8 -0
- package/dist/components/completion-dialog/completion-dialog.js +173 -0
- package/dist/components/completion-dialog/index.js +6 -0
- package/dist/components/content-intro/content-intro.js +144 -0
- package/dist/components/content-intro/index.js +6 -0
- package/dist/components/context-menu/context-menu.js +154 -0
- package/dist/components/context-menu/index.js +34 -0
- package/dist/components/cookie-consent/cookie-consent.js +175 -0
- package/dist/components/cookie-consent/index.js +8 -0
- package/dist/components/dialog/dialog.js +105 -0
- package/dist/components/dialog/index.js +24 -0
- package/dist/components/drawer/drawer.js +102 -0
- package/dist/components/drawer/index.js +24 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +151 -0
- package/dist/components/dropdown-menu/index.js +34 -0
- package/dist/components/exercise/exercise.js +112 -0
- package/dist/components/exercise/index.js +4 -0
- package/dist/components/faq/faq.js +56 -0
- package/dist/components/faq/index.js +5 -0
- package/dist/components/filter-bar/filter-bar.js +244 -0
- package/dist/components/filter-bar/index.js +6 -0
- package/dist/components/floating-action-button/floating-action-button.js +35 -0
- package/dist/components/floating-action-button/index.js +6 -0
- package/dist/components/flow-diagram/flow-canvas.js +109 -0
- package/dist/components/flow-diagram/flow-controls.js +140 -0
- package/dist/components/flow-diagram/flow-diagram.js +114 -0
- package/dist/components/flow-diagram/flow-error-boundary.js +63 -0
- package/dist/components/flow-diagram/flow-fullscreen.js +58 -0
- package/dist/components/flow-diagram/index.js +12 -0
- package/dist/components/flow-diagram/types.js +0 -0
- package/dist/components/flow-diagram/use-flow-diagram.js +146 -0
- package/dist/components/horizontal-scroll-row/horizontal-scroll-row.js +66 -0
- package/dist/components/horizontal-scroll-row/index.js +6 -0
- package/dist/components/hover-card/hover-card.js +26 -0
- package/dist/components/hover-card/index.js +6 -0
- package/dist/components/index.js +641 -0
- package/dist/components/inline-input/index.js +4 -0
- package/dist/components/inline-input/inline-input.js +42 -0
- package/dist/components/input/index.js +4 -0
- package/dist/components/input/input.js +23 -0
- package/dist/components/input-otp/index.js +12 -0
- package/dist/components/input-otp/input-otp.js +54 -0
- package/dist/components/key-concept/index.js +8 -0
- package/dist/components/key-concept/key-concept.js +79 -0
- package/dist/components/keyboard-shortcuts-help/index.js +6 -0
- package/dist/components/keyboard-shortcuts-help/keyboard-shortcuts-help.js +121 -0
- package/dist/components/label/index.js +4 -0
- package/dist/components/label/label.js +21 -0
- package/dist/components/lang-provider/index.js +4 -0
- package/dist/components/lang-provider/lang-provider.js +18 -0
- package/dist/components/learning-objectives/index.js +10 -0
- package/dist/components/learning-objectives/learning-objectives.js +76 -0
- package/dist/components/mdx-content/index.js +4 -0
- package/dist/components/mdx-content/mdx-content.js +151 -0
- package/dist/components/menubar/index.js +36 -0
- package/dist/components/menubar/menubar.js +183 -0
- package/dist/components/model-selector/index.js +6 -0
- package/dist/components/model-selector/model-selector.js +374 -0
- package/dist/components/navbar-saas/index.js +6 -0
- package/dist/components/navbar-saas/navbar-saas.js +68 -0
- package/dist/components/navbar-saas/use-mobile.js +19 -0
- package/dist/components/navigation-menu/index.js +22 -0
- package/dist/components/navigation-menu/navigation-menu.js +108 -0
- package/dist/components/pagination/index.js +4 -0
- package/dist/components/pagination/pagination.js +44 -0
- package/dist/components/popover/index.js +12 -0
- package/dist/components/popover/popover.js +28 -0
- package/dist/components/pro-tip/index.js +8 -0
- package/dist/components/pro-tip/pro-tip.js +139 -0
- package/dist/components/profile-section/index.js +4 -0
- package/dist/components/profile-section/profile-section.js +45 -0
- package/dist/components/progress-bar/index.js +4 -0
- package/dist/components/progress-bar/progress-bar.js +56 -0
- package/dist/components/progress-card/index.js +6 -0
- package/dist/components/progress-card/progress-card.js +71 -0
- package/dist/components/quiz/index.js +4 -0
- package/dist/components/quiz/quiz.js +210 -0
- package/dist/components/radio-group/index.js +5 -0
- package/dist/components/radio-group/radio-group.js +36 -0
- package/dist/components/resizable/index.js +10 -0
- package/dist/components/resizable/resizable.js +39 -0
- package/dist/components/scroll-area/index.js +5 -0
- package/dist/components/scroll-area/scroll-area.js +39 -0
- package/dist/components/search-bar/index.js +4 -0
- package/dist/components/search-bar/search-bar.js +122 -0
- package/dist/components/search-dialog/index.js +4 -0
- package/dist/components/search-dialog/search-dialog.js +102 -0
- package/dist/components/select/index.js +24 -0
- package/dist/components/select/select.js +125 -0
- package/dist/components/separator/index.js +4 -0
- package/dist/components/separator/separator.js +25 -0
- package/dist/components/share-dialog/index.js +6 -0
- package/dist/components/share-dialog/share-dialog.js +121 -0
- package/dist/components/share-section/index.js +6 -0
- package/dist/components/share-section/share-section.js +57 -0
- package/dist/components/sheet/index.js +24 -0
- package/dist/components/sheet/sheet.js +116 -0
- package/dist/components/sidebar/index.js +4 -0
- package/dist/components/sidebar/sidebar.js +188 -0
- package/dist/components/sidebar-provider/index.js +5 -0
- package/dist/components/sidebar-provider/sidebar-provider.js +25 -0
- package/dist/components/sidebar-toggle/index.js +4 -0
- package/dist/components/sidebar-toggle/sidebar-toggle.js +36 -0
- package/dist/components/skeleton/index.js +4 -0
- package/dist/components/skeleton/skeleton.js +17 -0
- package/dist/components/slider/index.js +4 -0
- package/dist/components/slider/slider.js +24 -0
- package/dist/components/slideshow/index.js +6 -0
- package/dist/components/slideshow/slideshow.js +440 -0
- package/dist/components/social-fab/index.js +6 -0
- package/dist/components/social-fab/social-fab.js +211 -0
- package/dist/components/social-fab/use-social-fab.js +111 -0
- package/dist/components/spinner/index.js +4 -0
- package/dist/components/spinner/spinner.js +23 -0
- package/dist/components/step-by-step/index.js +8 -0
- package/dist/components/step-by-step/step-by-step.js +194 -0
- package/dist/components/step-navigation/index.js +4 -0
- package/dist/components/step-navigation/step-navigation.js +119 -0
- package/dist/components/switch/index.js +4 -0
- package/dist/components/switch/switch.js +28 -0
- package/dist/components/table/index.js +20 -0
- package/dist/components/table/table.js +87 -0
- package/dist/components/table-of-contents/index.js +4 -0
- package/dist/components/table-of-contents/table-of-contents.js +71 -0
- package/dist/components/table-of-contents-panel/index.js +6 -0
- package/dist/components/table-of-contents-panel/table-of-contents-panel.js +202 -0
- package/dist/components/tabs/index.js +12 -0
- package/dist/components/tabs/tabs.js +84 -0
- package/dist/components/terminal/index.js +8 -0
- package/dist/components/terminal/terminal.js +119 -0
- package/dist/components/textarea/index.js +4 -0
- package/dist/components/textarea/textarea.js +22 -0
- package/dist/components/theme-provider/index.js +4 -0
- package/dist/components/theme-provider/theme-provider.js +11 -0
- package/dist/components/theme-toggle/index.js +4 -0
- package/dist/components/theme-toggle/theme-toggle.js +170 -0
- package/dist/components/thinking-block/index.js +4 -0
- package/dist/components/thinking-block/thinking-block.js +56 -0
- package/dist/components/tldr-section/index.js +4 -0
- package/dist/components/tldr-section/tldr-section.js +101 -0
- package/dist/components/toast/index.js +18 -0
- package/dist/components/toast/toast.js +84 -0
- package/dist/components/toast/toaster.js +38 -0
- package/dist/components/toggle/index.js +5 -0
- package/dist/components/toggle/toggle.js +39 -0
- package/dist/components/toggle-group/index.js +5 -0
- package/dist/components/toggle-group/toggle-group.js +46 -0
- package/dist/components/tooltip/index.js +12 -0
- package/dist/components/tooltip/tooltip.js +27 -0
- package/dist/components/truncated-text/index.js +4 -0
- package/dist/components/truncated-text/truncated-text.js +25 -0
- package/dist/components/tutorial-card/index.js +6 -0
- package/dist/components/tutorial-card/tutorial-card.js +78 -0
- package/dist/components/tutorial-complete/index.js +6 -0
- package/dist/components/tutorial-complete/tutorial-complete.js +134 -0
- package/dist/components/tutorial-filters/index.js +6 -0
- package/dist/components/tutorial-filters/tutorial-filters.js +205 -0
- package/dist/components/tutorial-intro-content/index.js +6 -0
- package/dist/components/tutorial-intro-content/tutorial-intro-content.js +141 -0
- package/dist/components/tutorial-mdx/index.js +8 -0
- package/dist/components/tutorial-mdx/tutorial-mdx.js +219 -0
- package/dist/components/video-embed/index.js +4 -0
- package/dist/components/video-embed/video-embed.js +77 -0
- package/dist/components/view-switcher/index.js +6 -0
- package/dist/components/view-switcher/view-switcher.js +92 -0
- package/dist/index.d.ts +44 -2
- package/dist/index.js +14 -8556
- package/dist/lib/types.js +11 -0
- package/dist/lib/use-debounce.js +17 -0
- package/dist/lib/use-horizontal-scroll.js +60 -0
- package/dist/lib/use-mounted.js +17 -0
- package/dist/lib/utils.js +8 -0
- package/dist/tailwind-preset.d.ts +5 -0
- package/dist/tailwind-preset.js +9 -10
- package/dist/types/content.js +0 -0
- package/dist/types/index.js +0 -0
- package/package.json +42 -23
- package/LICENSE +0 -21
- package/dist/chunk-XRV5RSYH.js +0 -569
- package/dist/flow-diagram-N3EHM6VB.js +0 -2
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
import { useSocialFab } from "./use-social-fab";
|
|
6
|
+
function ShareMenu({
|
|
7
|
+
onPlatformSelect,
|
|
8
|
+
platforms
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5 rounded-md border border-gray-300 bg-background p-1.5 shadow-md dark:border-gray-600", children: platforms.map((p) => {
|
|
11
|
+
const handleClick = () => {
|
|
12
|
+
onPlatformSelect(p.key);
|
|
13
|
+
};
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
"button",
|
|
16
|
+
{
|
|
17
|
+
className: "rounded px-3 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
|
|
18
|
+
onClick: handleClick,
|
|
19
|
+
type: "button",
|
|
20
|
+
children: p.label
|
|
21
|
+
},
|
|
22
|
+
p.key
|
|
23
|
+
);
|
|
24
|
+
}) });
|
|
25
|
+
}
|
|
26
|
+
function ActionButton({ action }) {
|
|
27
|
+
const handleClick = action.onClick;
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
"button",
|
|
30
|
+
{
|
|
31
|
+
className: "rounded px-3 py-1.5 text-left text-sm transition-colors hover:bg-accent",
|
|
32
|
+
onClick: handleClick,
|
|
33
|
+
type: "button",
|
|
34
|
+
children: action.label
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function ActionPanel({
|
|
39
|
+
actions,
|
|
40
|
+
isMobile,
|
|
41
|
+
onShareHover,
|
|
42
|
+
onShareLeave,
|
|
43
|
+
shareLabel
|
|
44
|
+
}) {
|
|
45
|
+
const shareAction = actions.find((a) => a.id === "share");
|
|
46
|
+
const otherActions = actions.filter((a) => a.id !== "share");
|
|
47
|
+
const handleShareClick = shareAction?.onClick;
|
|
48
|
+
const handleShareMouseEnter = isMobile ? void 0 : onShareHover;
|
|
49
|
+
const handleShareMouseLeave = isMobile ? void 0 : onShareLeave;
|
|
50
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 rounded-md border border-gray-300 bg-background p-1.5 shadow-md dark:border-gray-600", children: [
|
|
51
|
+
shareAction ? /* @__PURE__ */ jsx(
|
|
52
|
+
"button",
|
|
53
|
+
{
|
|
54
|
+
className: "rounded px-3 py-1.5 text-left text-sm transition-colors hover:bg-accent",
|
|
55
|
+
onClick: handleShareClick,
|
|
56
|
+
onMouseEnter: handleShareMouseEnter,
|
|
57
|
+
onMouseLeave: handleShareMouseLeave,
|
|
58
|
+
type: "button",
|
|
59
|
+
children: shareLabel
|
|
60
|
+
}
|
|
61
|
+
) : null,
|
|
62
|
+
otherActions.map((action) => /* @__PURE__ */ jsx(ActionButton, { action }, action.id))
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
function MainFabButton({
|
|
66
|
+
isExpanded,
|
|
67
|
+
isMobile,
|
|
68
|
+
labels,
|
|
69
|
+
mainText,
|
|
70
|
+
onToggle
|
|
71
|
+
}) {
|
|
72
|
+
const handleClick = onToggle;
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
"button",
|
|
75
|
+
{
|
|
76
|
+
"aria-expanded": isExpanded,
|
|
77
|
+
"aria-label": isExpanded ? labels.close : labels.share,
|
|
78
|
+
className: cn(
|
|
79
|
+
"flex size-10 items-center justify-center rounded-md",
|
|
80
|
+
"border border-gray-300 bg-background dark:border-gray-600",
|
|
81
|
+
"transition-all duration-200 ease-out",
|
|
82
|
+
"hover:-translate-y-0.5 hover:border-gray-400 hover:shadow-md dark:hover:border-gray-500"
|
|
83
|
+
),
|
|
84
|
+
onClick: handleClick,
|
|
85
|
+
type: "button",
|
|
86
|
+
children: /* @__PURE__ */ jsx("span", { className: "text-sm font-mono", children: isMobile && isExpanded ? "\u2715" : mainText })
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
function Backdrop({ onClose }) {
|
|
91
|
+
return /* @__PURE__ */ jsx(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
"aria-hidden": "true",
|
|
95
|
+
className: "fixed inset-0 z-40 bg-black/10",
|
|
96
|
+
onClick: onClose
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function ExpandedPanel({
|
|
101
|
+
actions,
|
|
102
|
+
fab,
|
|
103
|
+
labels,
|
|
104
|
+
onPlatformSelect,
|
|
105
|
+
sharePlatforms
|
|
106
|
+
}) {
|
|
107
|
+
return /* @__PURE__ */ jsxs(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: cn(
|
|
111
|
+
"flex flex-col gap-2 transition-all duration-200 ease-out",
|
|
112
|
+
fab.state.isExpanded ? "translate-y-0 opacity-100" : "pointer-events-none translate-y-2 opacity-0"
|
|
113
|
+
),
|
|
114
|
+
children: [
|
|
115
|
+
fab.state.showShareMenu && sharePlatforms.length > 0 ? /* @__PURE__ */ jsx(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
onMouseEnter: fab.handleShareHover,
|
|
119
|
+
onMouseLeave: fab.handleShareLeave,
|
|
120
|
+
children: /* @__PURE__ */ jsx(
|
|
121
|
+
ShareMenu,
|
|
122
|
+
{
|
|
123
|
+
onPlatformSelect,
|
|
124
|
+
platforms: sharePlatforms
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
) : null,
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
ActionPanel,
|
|
131
|
+
{
|
|
132
|
+
actions,
|
|
133
|
+
isMobile: fab.state.isMobile,
|
|
134
|
+
onShareHover: fab.handleShareHover,
|
|
135
|
+
onShareLeave: fab.handleShareLeave,
|
|
136
|
+
shareLabel: labels.share
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
function SocialFAB({
|
|
144
|
+
actions,
|
|
145
|
+
bottomOffset = 24,
|
|
146
|
+
hidden = false,
|
|
147
|
+
labels,
|
|
148
|
+
mainText = "\u22EF",
|
|
149
|
+
onAction,
|
|
150
|
+
onClose,
|
|
151
|
+
onOpen,
|
|
152
|
+
rightOffset = 24,
|
|
153
|
+
sharePlatforms = []
|
|
154
|
+
}) {
|
|
155
|
+
const options = { onAction, onClose, onOpen };
|
|
156
|
+
const fab = useSocialFab(options);
|
|
157
|
+
const handleBackdrop = useCallback(() => {
|
|
158
|
+
fab.close("backdrop");
|
|
159
|
+
}, [fab]);
|
|
160
|
+
const handlePlatformSelect = useCallback(
|
|
161
|
+
(key) => {
|
|
162
|
+
const platform = sharePlatforms.find((p) => p.key === key);
|
|
163
|
+
if (platform) {
|
|
164
|
+
window.open(
|
|
165
|
+
platform.buildUrl(window.location.href, document.title),
|
|
166
|
+
"_blank",
|
|
167
|
+
"noopener,noreferrer"
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
[sharePlatforms]
|
|
172
|
+
);
|
|
173
|
+
if (hidden) return null;
|
|
174
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
175
|
+
fab.state.isMobile && fab.state.isExpanded ? /* @__PURE__ */ jsx(Backdrop, { onClose: handleBackdrop }) : null,
|
|
176
|
+
/* @__PURE__ */ jsxs(
|
|
177
|
+
"div",
|
|
178
|
+
{
|
|
179
|
+
className: "fixed z-50 flex flex-col items-end gap-2",
|
|
180
|
+
onMouseEnter: fab.handleMouseEnter,
|
|
181
|
+
onMouseLeave: fab.handleMouseLeave,
|
|
182
|
+
style: { bottom: `${bottomOffset}px`, right: `${rightOffset}px` },
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ jsx(
|
|
185
|
+
ExpandedPanel,
|
|
186
|
+
{
|
|
187
|
+
actions,
|
|
188
|
+
fab,
|
|
189
|
+
labels,
|
|
190
|
+
onPlatformSelect: handlePlatformSelect,
|
|
191
|
+
sharePlatforms
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ jsx(
|
|
195
|
+
MainFabButton,
|
|
196
|
+
{
|
|
197
|
+
isExpanded: fab.state.isExpanded,
|
|
198
|
+
isMobile: fab.state.isMobile,
|
|
199
|
+
labels,
|
|
200
|
+
mainText,
|
|
201
|
+
onToggle: fab.handleToggle
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] });
|
|
208
|
+
}
|
|
209
|
+
export {
|
|
210
|
+
SocialFAB
|
|
211
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
function useMobileDetect() {
|
|
4
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const check = () => {
|
|
7
|
+
setIsMobile(window.innerWidth < 768);
|
|
8
|
+
};
|
|
9
|
+
check();
|
|
10
|
+
window.addEventListener("resize", check);
|
|
11
|
+
return () => {
|
|
12
|
+
window.removeEventListener("resize", check);
|
|
13
|
+
};
|
|
14
|
+
}, []);
|
|
15
|
+
return isMobile;
|
|
16
|
+
}
|
|
17
|
+
function useExpansion(options, isMobile) {
|
|
18
|
+
const { onClose, onOpen } = options;
|
|
19
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
20
|
+
const close = useCallback(
|
|
21
|
+
(trigger) => {
|
|
22
|
+
setIsExpanded(false);
|
|
23
|
+
onClose?.(trigger);
|
|
24
|
+
},
|
|
25
|
+
[onClose]
|
|
26
|
+
);
|
|
27
|
+
const open = useCallback(
|
|
28
|
+
(trigger, device) => {
|
|
29
|
+
setIsExpanded(true);
|
|
30
|
+
onOpen?.(trigger, device);
|
|
31
|
+
},
|
|
32
|
+
[onOpen]
|
|
33
|
+
);
|
|
34
|
+
const handleToggle = useCallback(() => {
|
|
35
|
+
const device = isMobile ? "mobile" : "desktop";
|
|
36
|
+
if (isExpanded) close("tap_close");
|
|
37
|
+
else open("tap", device);
|
|
38
|
+
}, [isMobile, isExpanded, close, open]);
|
|
39
|
+
const handleMouseEnter = useCallback(() => {
|
|
40
|
+
if (!isMobile) open("hover", "desktop");
|
|
41
|
+
}, [isMobile, open]);
|
|
42
|
+
const handleMouseLeave = useCallback(() => {
|
|
43
|
+
if (!isMobile) close("hover_leave");
|
|
44
|
+
}, [isMobile, close]);
|
|
45
|
+
return {
|
|
46
|
+
close,
|
|
47
|
+
handleMouseEnter,
|
|
48
|
+
handleMouseLeave,
|
|
49
|
+
handleToggle,
|
|
50
|
+
isExpanded
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function useShareMenu(onAction, isMobile) {
|
|
54
|
+
const [showShareMenu, setShowShareMenu] = useState(false);
|
|
55
|
+
const handleShareToggle = useCallback(() => {
|
|
56
|
+
setShowShareMenu((previous) => {
|
|
57
|
+
if (!previous) onAction?.("share");
|
|
58
|
+
return !previous;
|
|
59
|
+
});
|
|
60
|
+
}, [onAction]);
|
|
61
|
+
const handleShareHover = useCallback(() => {
|
|
62
|
+
if (!isMobile) {
|
|
63
|
+
onAction?.("share");
|
|
64
|
+
setShowShareMenu(true);
|
|
65
|
+
}
|
|
66
|
+
}, [isMobile, onAction]);
|
|
67
|
+
const handleShareLeave = useCallback(() => {
|
|
68
|
+
if (!isMobile) {
|
|
69
|
+
setShowShareMenu(false);
|
|
70
|
+
}
|
|
71
|
+
}, [isMobile]);
|
|
72
|
+
const reset = useCallback(() => {
|
|
73
|
+
setShowShareMenu(false);
|
|
74
|
+
}, []);
|
|
75
|
+
return {
|
|
76
|
+
handleShareHover,
|
|
77
|
+
handleShareLeave,
|
|
78
|
+
handleShareToggle,
|
|
79
|
+
reset,
|
|
80
|
+
showShareMenu
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function useSocialFab(options = {}) {
|
|
84
|
+
const isMobile = useMobileDetect();
|
|
85
|
+
const expansion = useExpansion(options, isMobile);
|
|
86
|
+
const shareMenu = useShareMenu(options.onAction, isMobile);
|
|
87
|
+
const close = useCallback(
|
|
88
|
+
(trigger) => {
|
|
89
|
+
expansion.close(trigger);
|
|
90
|
+
shareMenu.reset();
|
|
91
|
+
},
|
|
92
|
+
[expansion, shareMenu]
|
|
93
|
+
);
|
|
94
|
+
return {
|
|
95
|
+
close,
|
|
96
|
+
handleMouseEnter: expansion.handleMouseEnter,
|
|
97
|
+
handleMouseLeave: expansion.handleMouseLeave,
|
|
98
|
+
handleShareHover: shareMenu.handleShareHover,
|
|
99
|
+
handleShareLeave: shareMenu.handleShareLeave,
|
|
100
|
+
handleShareToggle: shareMenu.handleShareToggle,
|
|
101
|
+
handleToggle: expansion.handleToggle,
|
|
102
|
+
state: {
|
|
103
|
+
isExpanded: expansion.isExpanded,
|
|
104
|
+
isMobile,
|
|
105
|
+
showShareMenu: shareMenu.showShareMenu
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
useSocialFab
|
|
111
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
function Spinner({ className, size = "md", ...props }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(
|
|
5
|
+
"div",
|
|
6
|
+
{
|
|
7
|
+
className: cn(
|
|
8
|
+
"animate-spin rounded-full border-2 border-current border-t-transparent",
|
|
9
|
+
{
|
|
10
|
+
"h-4 w-4": size === "sm",
|
|
11
|
+
"h-6 w-6": size === "md",
|
|
12
|
+
"h-8 w-8": size === "lg"
|
|
13
|
+
},
|
|
14
|
+
className
|
|
15
|
+
),
|
|
16
|
+
...props,
|
|
17
|
+
children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading..." })
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
Spinner
|
|
23
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
function Step({
|
|
6
|
+
children,
|
|
7
|
+
className,
|
|
8
|
+
number,
|
|
9
|
+
title
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex gap-4", className), children: [
|
|
12
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
13
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-bold", children: number }),
|
|
14
|
+
/* @__PURE__ */ jsx("div", { className: "w-px flex-1 bg-border mt-2" })
|
|
15
|
+
] }),
|
|
16
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 pb-8 last:pb-0", children: [
|
|
17
|
+
/* @__PURE__ */ jsx("h4", { className: "font-semibold text-foreground mb-2", children: title }),
|
|
18
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground [&>p]:mb-2 [&>pre]:my-2", children })
|
|
19
|
+
] })
|
|
20
|
+
] });
|
|
21
|
+
}
|
|
22
|
+
function InteractiveStep({
|
|
23
|
+
children,
|
|
24
|
+
isCompleted,
|
|
25
|
+
isLast,
|
|
26
|
+
onToggle,
|
|
27
|
+
stepNumber,
|
|
28
|
+
title
|
|
29
|
+
}) {
|
|
30
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
|
|
31
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
"button",
|
|
34
|
+
{
|
|
35
|
+
className: cn(
|
|
36
|
+
"flex h-8 w-8 items-center justify-center rounded-full text-sm font-bold transition-colors",
|
|
37
|
+
isCompleted ? "bg-green-500 text-white" : "bg-primary text-primary-foreground"
|
|
38
|
+
),
|
|
39
|
+
onClick: onToggle,
|
|
40
|
+
type: "button",
|
|
41
|
+
children: isCompleted ? /* @__PURE__ */ jsx(
|
|
42
|
+
"svg",
|
|
43
|
+
{
|
|
44
|
+
className: "h-4 w-4",
|
|
45
|
+
fill: "none",
|
|
46
|
+
stroke: "currentColor",
|
|
47
|
+
viewBox: "0 0 24 24",
|
|
48
|
+
children: /* @__PURE__ */ jsx(
|
|
49
|
+
"path",
|
|
50
|
+
{
|
|
51
|
+
d: "M5 13l4 4L19 7",
|
|
52
|
+
strokeLinecap: "round",
|
|
53
|
+
strokeLinejoin: "round",
|
|
54
|
+
strokeWidth: 2
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
) : stepNumber
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
!isLast && /* @__PURE__ */ jsx(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: cn(
|
|
65
|
+
"w-px flex-1 mt-2",
|
|
66
|
+
isCompleted ? "bg-green-500" : "bg-border"
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ jsxs(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: cn(
|
|
75
|
+
"flex-1 pb-8 transition-opacity",
|
|
76
|
+
isCompleted && "opacity-60"
|
|
77
|
+
),
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
"h4",
|
|
81
|
+
{
|
|
82
|
+
className: cn(
|
|
83
|
+
"font-semibold text-foreground mb-2",
|
|
84
|
+
isCompleted && "line-through"
|
|
85
|
+
),
|
|
86
|
+
children: title
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground [&>p]:mb-2 [&>pre]:my-2", children })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] });
|
|
94
|
+
}
|
|
95
|
+
function StepByStep({
|
|
96
|
+
children,
|
|
97
|
+
className,
|
|
98
|
+
interactive = false,
|
|
99
|
+
title
|
|
100
|
+
}) {
|
|
101
|
+
const [completedSteps, setCompletedSteps] = useState(/* @__PURE__ */ new Set());
|
|
102
|
+
const steps = Array.isArray(children) ? children : [children];
|
|
103
|
+
const toggleStep = (index) => {
|
|
104
|
+
const newCompleted = new Set(completedSteps);
|
|
105
|
+
if (newCompleted.has(index)) newCompleted.delete(index);
|
|
106
|
+
else newCompleted.add(index);
|
|
107
|
+
setCompletedSteps(newCompleted);
|
|
108
|
+
};
|
|
109
|
+
if (!interactive) {
|
|
110
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("my-6", className), children: [
|
|
111
|
+
title ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-4", children: [
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
"svg",
|
|
114
|
+
{
|
|
115
|
+
className: "h-5 w-5 text-primary",
|
|
116
|
+
fill: "none",
|
|
117
|
+
stroke: "currentColor",
|
|
118
|
+
viewBox: "0 0 24 24",
|
|
119
|
+
children: /* @__PURE__ */ jsx(
|
|
120
|
+
"path",
|
|
121
|
+
{
|
|
122
|
+
d: "m9 18 6-6-6-6",
|
|
123
|
+
strokeLinecap: "round",
|
|
124
|
+
strokeLinejoin: "round",
|
|
125
|
+
strokeWidth: 2
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg", children: title })
|
|
131
|
+
] }) : null,
|
|
132
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-0", children: steps.map((step, index) => {
|
|
133
|
+
const stepElement = step;
|
|
134
|
+
return /* @__PURE__ */ jsx(
|
|
135
|
+
Step,
|
|
136
|
+
{
|
|
137
|
+
number: index + 1,
|
|
138
|
+
title: stepElement.props.title,
|
|
139
|
+
children: stepElement.props.children
|
|
140
|
+
},
|
|
141
|
+
index
|
|
142
|
+
);
|
|
143
|
+
}) })
|
|
144
|
+
] });
|
|
145
|
+
}
|
|
146
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("my-6", className), children: [
|
|
147
|
+
title ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-4", children: [
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
"svg",
|
|
150
|
+
{
|
|
151
|
+
className: "h-5 w-5 text-primary",
|
|
152
|
+
fill: "none",
|
|
153
|
+
stroke: "currentColor",
|
|
154
|
+
viewBox: "0 0 24 24",
|
|
155
|
+
children: /* @__PURE__ */ jsx(
|
|
156
|
+
"path",
|
|
157
|
+
{
|
|
158
|
+
d: "m9 18 6-6-6-6",
|
|
159
|
+
strokeLinecap: "round",
|
|
160
|
+
strokeLinejoin: "round",
|
|
161
|
+
strokeWidth: 2
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg", children: title }),
|
|
167
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground ml-auto", children: [
|
|
168
|
+
completedSteps.size,
|
|
169
|
+
"/",
|
|
170
|
+
steps.length,
|
|
171
|
+
" completed"
|
|
172
|
+
] })
|
|
173
|
+
] }) : null,
|
|
174
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-0", children: steps.map((step, index) => /* @__PURE__ */ jsx(
|
|
175
|
+
InteractiveStep,
|
|
176
|
+
{
|
|
177
|
+
isCompleted: completedSteps.has(index),
|
|
178
|
+
isLast: index === steps.length - 1,
|
|
179
|
+
onToggle: () => {
|
|
180
|
+
toggleStep(index);
|
|
181
|
+
},
|
|
182
|
+
stepNumber: index + 1,
|
|
183
|
+
title: step.props.title,
|
|
184
|
+
children: step.props.children
|
|
185
|
+
},
|
|
186
|
+
index
|
|
187
|
+
)) })
|
|
188
|
+
] });
|
|
189
|
+
}
|
|
190
|
+
StepByStep.Step = Step;
|
|
191
|
+
export {
|
|
192
|
+
Step,
|
|
193
|
+
StepByStep
|
|
194
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo } from "react";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
function StepNavigationImpl({
|
|
6
|
+
canNext,
|
|
7
|
+
canPrev,
|
|
8
|
+
className,
|
|
9
|
+
currentStep,
|
|
10
|
+
nextIcon,
|
|
11
|
+
nextLabel = "Next",
|
|
12
|
+
onNext,
|
|
13
|
+
onPrev,
|
|
14
|
+
previousIcon,
|
|
15
|
+
previousLabel = "Prev",
|
|
16
|
+
stepLabel = "Section",
|
|
17
|
+
totalSteps
|
|
18
|
+
}) {
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
"nav",
|
|
21
|
+
{
|
|
22
|
+
"aria-label": "Step navigation",
|
|
23
|
+
className: cn(
|
|
24
|
+
"fixed bottom-0 left-0 right-0 z-50",
|
|
25
|
+
"border-t border-neutral-200 bg-white",
|
|
26
|
+
"dark:border-neutral-800 dark:bg-black",
|
|
27
|
+
className
|
|
28
|
+
),
|
|
29
|
+
children: /* @__PURE__ */ jsxs("div", { className: "mx-auto flex max-w-3xl items-center justify-between px-4 py-3", children: [
|
|
30
|
+
/* @__PURE__ */ jsxs(
|
|
31
|
+
"button",
|
|
32
|
+
{
|
|
33
|
+
"aria-label": "Previous step",
|
|
34
|
+
className: cn(
|
|
35
|
+
"flex min-h-[44px] min-w-[44px] items-center justify-center",
|
|
36
|
+
"rounded-md px-3 py-2 text-sm font-medium transition-colors",
|
|
37
|
+
"hover:bg-neutral-100 dark:hover:bg-neutral-900",
|
|
38
|
+
"disabled:pointer-events-none disabled:opacity-40"
|
|
39
|
+
),
|
|
40
|
+
disabled: !canPrev,
|
|
41
|
+
onClick: onPrev,
|
|
42
|
+
type: "button",
|
|
43
|
+
children: [
|
|
44
|
+
previousIcon ?? /* @__PURE__ */ jsx(
|
|
45
|
+
"svg",
|
|
46
|
+
{
|
|
47
|
+
"aria-hidden": "true",
|
|
48
|
+
className: "h-5 w-5",
|
|
49
|
+
fill: "none",
|
|
50
|
+
stroke: "currentColor",
|
|
51
|
+
viewBox: "0 0 24 24",
|
|
52
|
+
children: /* @__PURE__ */ jsx(
|
|
53
|
+
"path",
|
|
54
|
+
{
|
|
55
|
+
d: "m15 19-7-7 7-7",
|
|
56
|
+
strokeLinecap: "round",
|
|
57
|
+
strokeLinejoin: "round",
|
|
58
|
+
strokeWidth: 2
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ jsx("span", { className: "ml-1", children: previousLabel })
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { className: "text-sm tabular-nums text-neutral-600 dark:text-neutral-400", children: [
|
|
68
|
+
stepLabel,
|
|
69
|
+
" ",
|
|
70
|
+
currentStep,
|
|
71
|
+
" / ",
|
|
72
|
+
totalSteps
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ jsxs(
|
|
75
|
+
"button",
|
|
76
|
+
{
|
|
77
|
+
"aria-label": "Next step",
|
|
78
|
+
className: cn(
|
|
79
|
+
"flex min-h-[44px] min-w-[44px] items-center justify-center",
|
|
80
|
+
"rounded-md px-3 py-2 text-sm font-medium transition-colors",
|
|
81
|
+
"hover:bg-neutral-100 dark:hover:bg-neutral-900",
|
|
82
|
+
"disabled:pointer-events-none disabled:opacity-40"
|
|
83
|
+
),
|
|
84
|
+
disabled: !canNext,
|
|
85
|
+
onClick: onNext,
|
|
86
|
+
type: "button",
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsx("span", { className: "mr-1", children: nextLabel }),
|
|
89
|
+
nextIcon ?? /* @__PURE__ */ jsx(
|
|
90
|
+
"svg",
|
|
91
|
+
{
|
|
92
|
+
"aria-hidden": "true",
|
|
93
|
+
className: "h-5 w-5",
|
|
94
|
+
fill: "none",
|
|
95
|
+
stroke: "currentColor",
|
|
96
|
+
viewBox: "0 0 24 24",
|
|
97
|
+
children: /* @__PURE__ */ jsx(
|
|
98
|
+
"path",
|
|
99
|
+
{
|
|
100
|
+
d: "m9 5 7 7-7 7",
|
|
101
|
+
strokeLinecap: "round",
|
|
102
|
+
strokeLinejoin: "round",
|
|
103
|
+
strokeWidth: 2
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
] })
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const StepNavigation = memo(StepNavigationImpl);
|
|
116
|
+
StepNavigation.displayName = "StepNavigation";
|
|
117
|
+
export {
|
|
118
|
+
StepNavigation
|
|
119
|
+
};
|