@wow-two-beta/ui 0.0.16 → 0.0.18
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/actions/backToTopButton/BackToTopButton.d.ts +19 -0
- package/dist/actions/backToTopButton/BackToTopButton.d.ts.map +1 -0
- package/dist/actions/backToTopButton/index.d.ts +2 -0
- package/dist/actions/backToTopButton/index.d.ts.map +1 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +2 -2
- package/dist/{chunk-XHGWBSIR.js → chunk-25CGSOXZ.js} +5 -87
- package/dist/chunk-25CGSOXZ.js.map +1 -0
- package/dist/{chunk-SM2TOB4U.js → chunk-3KPILWVX.js} +268 -4
- package/dist/chunk-3KPILWVX.js.map +1 -0
- package/dist/{chunk-ILYL6ROC.js → chunk-3P7DZCDS.js} +257 -5
- package/dist/chunk-3P7DZCDS.js.map +1 -0
- package/dist/{chunk-3IN5ULKY.js → chunk-45SFQEMP.js} +417 -37
- package/dist/chunk-45SFQEMP.js.map +1 -0
- package/dist/{chunk-W7LQZKTH.js → chunk-D7XIPKDJ.js} +109 -4
- package/dist/chunk-D7XIPKDJ.js.map +1 -0
- package/dist/{chunk-2VAZKEQD.js → chunk-DSA7L7PD.js} +256 -141
- package/dist/chunk-DSA7L7PD.js.map +1 -0
- package/dist/{chunk-NRAJPSEK.js → chunk-GRJBIGUD.js} +72 -6
- package/dist/chunk-GRJBIGUD.js.map +1 -0
- package/dist/chunk-NKADHZMX.js +39 -0
- package/dist/chunk-NKADHZMX.js.map +1 -0
- package/dist/chunk-NTW7SDAP.js +92 -0
- package/dist/chunk-NTW7SDAP.js.map +1 -0
- package/dist/chunk-O6UUYPTB.js +148 -0
- package/dist/chunk-O6UUYPTB.js.map +1 -0
- package/dist/{chunk-4ESR253U.js → chunk-XRTXK5Y4.js} +119 -7
- package/dist/chunk-XRTXK5Y4.js.map +1 -0
- package/dist/display/index.d.ts +1 -0
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +2 -2
- package/dist/display/swipeActions/SwipeActions.d.ts +17 -0
- package/dist/display/swipeActions/SwipeActions.d.ts.map +1 -0
- package/dist/display/swipeActions/index.d.ts +2 -0
- package/dist/display/swipeActions/index.d.ts.map +1 -0
- package/dist/feedback/index.d.ts +3 -0
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/feedback/index.js +3 -1
- package/dist/feedback/onboardingChecklist/OnboardingChecklist.d.ts +33 -0
- package/dist/feedback/onboardingChecklist/OnboardingChecklist.d.ts.map +1 -0
- package/dist/feedback/onboardingChecklist/index.d.ts +3 -0
- package/dist/feedback/onboardingChecklist/index.d.ts.map +1 -0
- package/dist/feedback/tour/Tour.d.ts +25 -0
- package/dist/feedback/tour/Tour.d.ts.map +1 -0
- package/dist/feedback/tour/index.d.ts +2 -0
- package/dist/feedback/tour/index.d.ts.map +1 -0
- package/dist/feedback/undoBar/UndoBar.d.ts +22 -0
- package/dist/feedback/undoBar/UndoBar.d.ts.map +1 -0
- package/dist/feedback/undoBar/index.d.ts +2 -0
- package/dist/feedback/undoBar/index.d.ts.map +1 -0
- package/dist/forms/index.d.ts +1 -0
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +6 -4
- package/dist/forms/wizard/Wizard.d.ts +58 -0
- package/dist/forms/wizard/Wizard.d.ts.map +1 -0
- package/dist/forms/wizard/index.d.ts +3 -0
- package/dist/forms/wizard/index.d.ts.map +1 -0
- package/dist/index.js +12 -9
- package/dist/layout/appShell/AppShell.d.ts +50 -0
- package/dist/layout/appShell/AppShell.d.ts.map +1 -0
- package/dist/layout/appShell/index.d.ts +3 -0
- package/dist/layout/appShell/index.d.ts.map +1 -0
- package/dist/layout/index.d.ts +2 -0
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +7 -2
- package/dist/layout/pullToRefresh/PullToRefresh.d.ts +15 -0
- package/dist/layout/pullToRefresh/PullToRefresh.d.ts.map +1 -0
- package/dist/layout/pullToRefresh/index.d.ts +2 -0
- package/dist/layout/pullToRefresh/index.d.ts.map +1 -0
- package/dist/nav/index.d.ts +2 -0
- package/dist/nav/index.d.ts.map +1 -1
- package/dist/nav/index.js +4 -3
- package/dist/nav/scrollSpy/ScrollSpy.d.ts +25 -0
- package/dist/nav/scrollSpy/ScrollSpy.d.ts.map +1 -0
- package/dist/nav/scrollSpy/index.d.ts +2 -0
- package/dist/nav/scrollSpy/index.d.ts.map +1 -0
- package/dist/nav/tableOfContents/TableOfContents.d.ts +24 -0
- package/dist/nav/tableOfContents/TableOfContents.d.ts.map +1 -0
- package/dist/nav/tableOfContents/index.d.ts +2 -0
- package/dist/nav/tableOfContents/index.d.ts.map +1 -0
- package/dist/overlays/actionSheet/ActionSheet.d.ts +29 -0
- package/dist/overlays/actionSheet/ActionSheet.d.ts.map +1 -0
- package/dist/overlays/actionSheet/index.d.ts +3 -0
- package/dist/overlays/actionSheet/index.d.ts.map +1 -0
- package/dist/overlays/bottomSheet/BottomSheet.d.ts +29 -0
- package/dist/overlays/bottomSheet/BottomSheet.d.ts.map +1 -0
- package/dist/overlays/bottomSheet/index.d.ts +2 -0
- package/dist/overlays/bottomSheet/index.d.ts.map +1 -0
- package/dist/overlays/index.d.ts +2 -0
- package/dist/overlays/index.d.ts.map +1 -1
- package/dist/overlays/index.js +5 -3
- package/package.json +1 -1
- package/dist/chunk-2VAZKEQD.js.map +0 -1
- package/dist/chunk-3IN5ULKY.js.map +0 -1
- package/dist/chunk-4ESR253U.js.map +0 -1
- package/dist/chunk-ILYL6ROC.js.map +0 -1
- package/dist/chunk-NRAJPSEK.js.map +0 -1
- package/dist/chunk-SM2TOB4U.js.map +0 -1
- package/dist/chunk-W7LQZKTH.js.map +0 -1
- package/dist/chunk-XHGWBSIR.js.map +0 -1
|
@@ -1,42 +1,13 @@
|
|
|
1
|
+
import { Spinner } from './chunk-NKADHZMX.js';
|
|
1
2
|
import { Backdrop } from './chunk-ASIHQQDQ.js';
|
|
2
3
|
import { tv } from './chunk-BMBIZLO4.js';
|
|
4
|
+
import { useControlled } from './chunk-4P2TFUVW.js';
|
|
3
5
|
import { Icon } from './chunk-TDX22OWF.js';
|
|
4
6
|
import { Portal, Announce } from './chunk-NC2CBGX2.js';
|
|
5
7
|
import { cn } from './chunk-KZ4VFY2T.js';
|
|
6
|
-
import { forwardRef,
|
|
7
|
-
import {
|
|
8
|
-
import { X, Check, TrendingUp, TrendingDown, Minus } from 'lucide-react';
|
|
9
|
-
|
|
10
|
-
// src/feedback/spinner/Spinner.variants.ts
|
|
11
|
-
var spinnerVariants = tv({
|
|
12
|
-
base: "inline-block animate-spin rounded-full border-current border-b-transparent",
|
|
13
|
-
variants: {
|
|
14
|
-
size: {
|
|
15
|
-
xs: "h-3 w-3 border",
|
|
16
|
-
sm: "h-4 w-4 border-2",
|
|
17
|
-
md: "h-5 w-5 border-2",
|
|
18
|
-
lg: "h-8 w-8 border-2",
|
|
19
|
-
xl: "h-12 w-12 border-[3px]"
|
|
20
|
-
},
|
|
21
|
-
tone: {
|
|
22
|
-
default: "text-muted-foreground",
|
|
23
|
-
brand: "text-primary",
|
|
24
|
-
muted: "text-border",
|
|
25
|
-
current: ""
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
defaultVariants: {
|
|
29
|
-
size: "md",
|
|
30
|
-
tone: "default"
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
var Spinner = forwardRef(
|
|
34
|
-
({ className, size, tone, label = "Loading", role = "status", ...props }, ref) => /* @__PURE__ */ jsxs("span", { ref, role, ...props, children: [
|
|
35
|
-
/* @__PURE__ */ jsx("span", { className: cn(spinnerVariants({ size, tone }), className) }),
|
|
36
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: label })
|
|
37
|
-
] })
|
|
38
|
-
);
|
|
39
|
-
Spinner.displayName = "Spinner";
|
|
8
|
+
import { forwardRef, createContext, useState, Children, isValidElement, useEffect, useMemo, useRef, useContext, useId, useCallback } from 'react';
|
|
9
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
|
+
import { X, Check, TrendingUp, TrendingDown, Minus, ChevronDown } from 'lucide-react';
|
|
40
11
|
|
|
41
12
|
// src/feedback/skeleton/Skeleton.variants.ts
|
|
42
13
|
var skeletonVariants = tv({
|
|
@@ -798,7 +769,416 @@ var LoadingOverlay = forwardRef(
|
|
|
798
769
|
}
|
|
799
770
|
);
|
|
800
771
|
LoadingOverlay.displayName = "LoadingOverlay";
|
|
772
|
+
var POSITION = {
|
|
773
|
+
"top-right": "top-4 right-4",
|
|
774
|
+
"top-left": "top-4 left-4",
|
|
775
|
+
"top-center": "top-4 left-1/2 -translate-x-1/2",
|
|
776
|
+
"bottom-right": "bottom-4 right-4",
|
|
777
|
+
"bottom-left": "bottom-4 left-4",
|
|
778
|
+
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2"
|
|
779
|
+
};
|
|
780
|
+
function UndoBar({
|
|
781
|
+
open,
|
|
782
|
+
onOpenChange,
|
|
783
|
+
message,
|
|
784
|
+
onUndo,
|
|
785
|
+
undoLabel = "Undo",
|
|
786
|
+
duration = 5e3,
|
|
787
|
+
pauseOnHover = true,
|
|
788
|
+
position = "bottom-center",
|
|
789
|
+
showCountdown = false,
|
|
790
|
+
className
|
|
791
|
+
}) {
|
|
792
|
+
const [progress, setProgress] = useState(1);
|
|
793
|
+
const [paused, setPaused] = useState(false);
|
|
794
|
+
const startRef = useRef(0);
|
|
795
|
+
const remainingRef = useRef(duration);
|
|
796
|
+
const rafRef = useRef(null);
|
|
797
|
+
useEffect(() => {
|
|
798
|
+
if (!open) {
|
|
799
|
+
remainingRef.current = duration;
|
|
800
|
+
setProgress(1);
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
if (duration === Infinity) {
|
|
804
|
+
setProgress(1);
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
if (paused) return;
|
|
808
|
+
startRef.current = performance.now();
|
|
809
|
+
const tick = (now) => {
|
|
810
|
+
const elapsed = now - startRef.current;
|
|
811
|
+
const remaining = Math.max(0, remainingRef.current - elapsed);
|
|
812
|
+
setProgress(remaining / duration);
|
|
813
|
+
if (remaining <= 0) {
|
|
814
|
+
onOpenChange?.(false);
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
rafRef.current = requestAnimationFrame(tick);
|
|
818
|
+
};
|
|
819
|
+
rafRef.current = requestAnimationFrame(tick);
|
|
820
|
+
return () => {
|
|
821
|
+
if (rafRef.current != null) cancelAnimationFrame(rafRef.current);
|
|
822
|
+
const elapsed = performance.now() - startRef.current;
|
|
823
|
+
remainingRef.current = Math.max(0, remainingRef.current - elapsed);
|
|
824
|
+
};
|
|
825
|
+
}, [open, duration, paused, onOpenChange]);
|
|
826
|
+
if (!open) return null;
|
|
827
|
+
return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsxs(
|
|
828
|
+
"div",
|
|
829
|
+
{
|
|
830
|
+
role: "status",
|
|
831
|
+
"aria-live": "polite",
|
|
832
|
+
onMouseEnter: () => pauseOnHover && setPaused(true),
|
|
833
|
+
onMouseLeave: () => pauseOnHover && setPaused(false),
|
|
834
|
+
onFocus: () => pauseOnHover && setPaused(true),
|
|
835
|
+
onBlur: () => pauseOnHover && setPaused(false),
|
|
836
|
+
className: cn(
|
|
837
|
+
"fixed z-50 flex items-center gap-3 overflow-hidden rounded-md border border-border bg-popover px-4 py-2.5 text-sm text-popover-foreground shadow-lg animate-in fade-in-0 slide-in-from-bottom-2",
|
|
838
|
+
POSITION[position],
|
|
839
|
+
className
|
|
840
|
+
),
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: message }),
|
|
843
|
+
onUndo && /* @__PURE__ */ jsx(
|
|
844
|
+
"button",
|
|
845
|
+
{
|
|
846
|
+
type: "button",
|
|
847
|
+
onClick: () => {
|
|
848
|
+
onUndo();
|
|
849
|
+
onOpenChange?.(false);
|
|
850
|
+
},
|
|
851
|
+
className: "font-medium text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm px-1",
|
|
852
|
+
children: undoLabel
|
|
853
|
+
}
|
|
854
|
+
),
|
|
855
|
+
showCountdown && duration !== Infinity && /* @__PURE__ */ jsx("div", { className: "absolute bottom-0 left-0 h-0.5 w-full bg-border", children: /* @__PURE__ */ jsx(
|
|
856
|
+
"div",
|
|
857
|
+
{
|
|
858
|
+
className: "h-full bg-primary transition-[width] duration-100 ease-linear",
|
|
859
|
+
style: { width: `${progress * 100}%` }
|
|
860
|
+
}
|
|
861
|
+
) })
|
|
862
|
+
]
|
|
863
|
+
}
|
|
864
|
+
) });
|
|
865
|
+
}
|
|
866
|
+
var OnboardingContext = createContext(null);
|
|
867
|
+
var OnboardingChecklist = forwardRef(
|
|
868
|
+
function OnboardingChecklist2({
|
|
869
|
+
title = "Get started",
|
|
870
|
+
defaultOpen = true,
|
|
871
|
+
dismissOnComplete = false,
|
|
872
|
+
dismissDelay = 2e3,
|
|
873
|
+
onDismiss,
|
|
874
|
+
className,
|
|
875
|
+
children,
|
|
876
|
+
...rest
|
|
877
|
+
}, ref) {
|
|
878
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
879
|
+
const [dismissed, setDismissed] = useState(false);
|
|
880
|
+
const tasks = Children.toArray(children).filter(
|
|
881
|
+
(c) => isValidElement(c) && c.type.displayName === "OnboardingChecklistTask"
|
|
882
|
+
);
|
|
883
|
+
const total = tasks.length;
|
|
884
|
+
const done = tasks.filter((t) => t.props.done).length;
|
|
885
|
+
const complete = total > 0 && done === total;
|
|
886
|
+
useEffect(() => {
|
|
887
|
+
if (!dismissOnComplete || !complete || dismissed) return;
|
|
888
|
+
const handle = window.setTimeout(() => {
|
|
889
|
+
setDismissed(true);
|
|
890
|
+
onDismiss?.();
|
|
891
|
+
}, dismissDelay);
|
|
892
|
+
return () => window.clearTimeout(handle);
|
|
893
|
+
}, [complete, dismissOnComplete, dismissDelay, dismissed, onDismiss]);
|
|
894
|
+
const ctx = useMemo(() => ({ open, setOpen }), [open]);
|
|
895
|
+
if (dismissed) return null;
|
|
896
|
+
return /* @__PURE__ */ jsx(OnboardingContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
|
|
897
|
+
"div",
|
|
898
|
+
{
|
|
899
|
+
ref,
|
|
900
|
+
className: cn(
|
|
901
|
+
"overflow-hidden rounded-lg border border-border bg-card shadow-sm",
|
|
902
|
+
className
|
|
903
|
+
),
|
|
904
|
+
...rest,
|
|
905
|
+
children: [
|
|
906
|
+
/* @__PURE__ */ jsxs(
|
|
907
|
+
"button",
|
|
908
|
+
{
|
|
909
|
+
type: "button",
|
|
910
|
+
"aria-expanded": open,
|
|
911
|
+
onClick: () => setOpen(!open),
|
|
912
|
+
className: "flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
|
913
|
+
children: [
|
|
914
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
915
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-foreground", children: title }),
|
|
916
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
917
|
+
done,
|
|
918
|
+
" of ",
|
|
919
|
+
total,
|
|
920
|
+
" tasks complete"
|
|
921
|
+
] }),
|
|
922
|
+
/* @__PURE__ */ jsx("div", { className: "mt-2 h-1.5 overflow-hidden rounded-full bg-border", children: /* @__PURE__ */ jsx(
|
|
923
|
+
"div",
|
|
924
|
+
{
|
|
925
|
+
className: cn(
|
|
926
|
+
"h-full bg-primary transition-[width] duration-300",
|
|
927
|
+
complete && "bg-success"
|
|
928
|
+
),
|
|
929
|
+
style: { width: total ? `${done / total * 100}%` : "0%" }
|
|
930
|
+
}
|
|
931
|
+
) })
|
|
932
|
+
] }),
|
|
933
|
+
/* @__PURE__ */ jsx(
|
|
934
|
+
Icon,
|
|
935
|
+
{
|
|
936
|
+
icon: ChevronDown,
|
|
937
|
+
size: 16,
|
|
938
|
+
className: cn("text-muted-foreground transition-transform", open && "rotate-180")
|
|
939
|
+
}
|
|
940
|
+
)
|
|
941
|
+
]
|
|
942
|
+
}
|
|
943
|
+
),
|
|
944
|
+
open && /* @__PURE__ */ jsx("ul", { role: "list", className: "border-t border-border", children })
|
|
945
|
+
]
|
|
946
|
+
}
|
|
947
|
+
) });
|
|
948
|
+
}
|
|
949
|
+
);
|
|
950
|
+
var OnboardingChecklistTask = forwardRef(function OnboardingChecklistTask2({ label, description, done = false, action, className, ...rest }, ref) {
|
|
951
|
+
return /* @__PURE__ */ jsxs(
|
|
952
|
+
"li",
|
|
953
|
+
{
|
|
954
|
+
ref,
|
|
955
|
+
"data-done": done || void 0,
|
|
956
|
+
className: cn(
|
|
957
|
+
"flex items-start gap-3 px-4 py-3 transition-colors",
|
|
958
|
+
done && "opacity-60",
|
|
959
|
+
className
|
|
960
|
+
),
|
|
961
|
+
...rest,
|
|
962
|
+
children: [
|
|
963
|
+
/* @__PURE__ */ jsx(
|
|
964
|
+
"span",
|
|
965
|
+
{
|
|
966
|
+
"aria-hidden": "true",
|
|
967
|
+
className: cn(
|
|
968
|
+
"mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-full border",
|
|
969
|
+
done ? "border-success bg-success text-success-foreground" : "border-border"
|
|
970
|
+
),
|
|
971
|
+
children: done && /* @__PURE__ */ jsx(Icon, { icon: Check, size: 12 })
|
|
972
|
+
}
|
|
973
|
+
),
|
|
974
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
975
|
+
/* @__PURE__ */ jsx("div", { className: cn("text-sm font-medium text-foreground", done && "line-through"), children: label }),
|
|
976
|
+
description && /* @__PURE__ */ jsx("div", { className: "mt-0.5 text-xs text-muted-foreground", children: description })
|
|
977
|
+
] }),
|
|
978
|
+
action && !done && /* @__PURE__ */ jsx("div", { className: "shrink-0", children: action })
|
|
979
|
+
]
|
|
980
|
+
}
|
|
981
|
+
);
|
|
982
|
+
});
|
|
983
|
+
OnboardingChecklistTask.displayName = "OnboardingChecklistTask";
|
|
984
|
+
OnboardingChecklist.Task = OnboardingChecklistTask;
|
|
985
|
+
function useOnboardingChecklist() {
|
|
986
|
+
const ctx = useContext(OnboardingContext);
|
|
987
|
+
if (!ctx) throw new Error("useOnboardingChecklist must be used inside <OnboardingChecklist>");
|
|
988
|
+
return ctx;
|
|
989
|
+
}
|
|
990
|
+
function rectFromTarget(target) {
|
|
991
|
+
let el = null;
|
|
992
|
+
if (typeof target === "string") {
|
|
993
|
+
el = document.querySelector(target);
|
|
994
|
+
} else {
|
|
995
|
+
el = target.current;
|
|
996
|
+
}
|
|
997
|
+
if (!el) return null;
|
|
998
|
+
const r = el.getBoundingClientRect();
|
|
999
|
+
return { top: r.top, left: r.left, width: r.width, height: r.height };
|
|
1000
|
+
}
|
|
1001
|
+
function placementCoords(rect, placement, gap = 12) {
|
|
1002
|
+
switch (placement) {
|
|
1003
|
+
case "top":
|
|
1004
|
+
return { top: rect.top - gap, left: rect.left + rect.width / 2, transform: "translate(-50%, -100%)" };
|
|
1005
|
+
case "right":
|
|
1006
|
+
return { top: rect.top + rect.height / 2, left: rect.left + rect.width + gap, transform: "translate(0, -50%)" };
|
|
1007
|
+
case "bottom":
|
|
1008
|
+
return { top: rect.top + rect.height + gap, left: rect.left + rect.width / 2, transform: "translate(-50%, 0)" };
|
|
1009
|
+
case "left":
|
|
1010
|
+
return { top: rect.top + rect.height / 2, left: rect.left - gap, transform: "translate(-100%, -50%)" };
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
function Tour({
|
|
1014
|
+
open: openProp,
|
|
1015
|
+
defaultOpen = false,
|
|
1016
|
+
onOpenChange,
|
|
1017
|
+
steps,
|
|
1018
|
+
currentStep: currentStepProp,
|
|
1019
|
+
defaultCurrentStep = 0,
|
|
1020
|
+
onStepChange,
|
|
1021
|
+
onComplete,
|
|
1022
|
+
onSkip,
|
|
1023
|
+
padding = 8
|
|
1024
|
+
}) {
|
|
1025
|
+
const [open, setOpen] = useControlled({
|
|
1026
|
+
controlled: openProp,
|
|
1027
|
+
default: defaultOpen,
|
|
1028
|
+
onChange: onOpenChange
|
|
1029
|
+
});
|
|
1030
|
+
const [currentStep, setCurrentStep] = useControlled({
|
|
1031
|
+
controlled: currentStepProp,
|
|
1032
|
+
default: defaultCurrentStep,
|
|
1033
|
+
onChange: onStepChange
|
|
1034
|
+
});
|
|
1035
|
+
const [rect, setRect] = useState(null);
|
|
1036
|
+
const titleId = useId();
|
|
1037
|
+
const descId = useId();
|
|
1038
|
+
const step = steps[currentStep];
|
|
1039
|
+
useEffect(() => {
|
|
1040
|
+
if (!open || !step) return;
|
|
1041
|
+
const update = () => {
|
|
1042
|
+
const r = rectFromTarget(step.target);
|
|
1043
|
+
setRect(r);
|
|
1044
|
+
};
|
|
1045
|
+
const handle = requestAnimationFrame(update);
|
|
1046
|
+
window.addEventListener("resize", update, { passive: true });
|
|
1047
|
+
window.addEventListener("scroll", update, { passive: true, capture: true });
|
|
1048
|
+
return () => {
|
|
1049
|
+
cancelAnimationFrame(handle);
|
|
1050
|
+
window.removeEventListener("resize", update);
|
|
1051
|
+
window.removeEventListener("scroll", update, true);
|
|
1052
|
+
};
|
|
1053
|
+
}, [open, step]);
|
|
1054
|
+
useEffect(() => {
|
|
1055
|
+
if (!open) return;
|
|
1056
|
+
const onKey = (e) => {
|
|
1057
|
+
if (e.key === "Escape") {
|
|
1058
|
+
e.preventDefault();
|
|
1059
|
+
setOpen(false);
|
|
1060
|
+
onSkip?.();
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
document.addEventListener("keydown", onKey);
|
|
1064
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
1065
|
+
}, [open, setOpen, onSkip]);
|
|
1066
|
+
const goNext = useCallback(() => {
|
|
1067
|
+
if (currentStep >= steps.length - 1) {
|
|
1068
|
+
setOpen(false);
|
|
1069
|
+
onComplete?.();
|
|
1070
|
+
} else {
|
|
1071
|
+
setCurrentStep(currentStep + 1);
|
|
1072
|
+
}
|
|
1073
|
+
}, [currentStep, steps.length, setOpen, setCurrentStep, onComplete]);
|
|
1074
|
+
const goPrev = useCallback(() => {
|
|
1075
|
+
if (currentStep > 0) setCurrentStep(currentStep - 1);
|
|
1076
|
+
}, [currentStep, setCurrentStep]);
|
|
1077
|
+
const skip = useCallback(() => {
|
|
1078
|
+
setOpen(false);
|
|
1079
|
+
onSkip?.();
|
|
1080
|
+
}, [setOpen, onSkip]);
|
|
1081
|
+
if (!open || !step) return null;
|
|
1082
|
+
const placement = step.placement ?? "bottom";
|
|
1083
|
+
const tooltipCoords = rect ? placementCoords(rect, placement) : null;
|
|
1084
|
+
const cutoutPadding = padding;
|
|
1085
|
+
return /* @__PURE__ */ jsxs(Portal, { children: [
|
|
1086
|
+
/* @__PURE__ */ jsxs(
|
|
1087
|
+
"svg",
|
|
1088
|
+
{
|
|
1089
|
+
"aria-hidden": "true",
|
|
1090
|
+
className: "pointer-events-auto fixed inset-0 z-50 h-full w-full",
|
|
1091
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1092
|
+
children: [
|
|
1093
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("mask", { id: "tour-mask", children: [
|
|
1094
|
+
/* @__PURE__ */ jsx("rect", { width: "100%", height: "100%", fill: "white" }),
|
|
1095
|
+
rect && /* @__PURE__ */ jsx(
|
|
1096
|
+
"rect",
|
|
1097
|
+
{
|
|
1098
|
+
x: rect.left - cutoutPadding,
|
|
1099
|
+
y: rect.top - cutoutPadding,
|
|
1100
|
+
width: rect.width + cutoutPadding * 2,
|
|
1101
|
+
height: rect.height + cutoutPadding * 2,
|
|
1102
|
+
rx: 6,
|
|
1103
|
+
fill: "black"
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
] }) }),
|
|
1107
|
+
/* @__PURE__ */ jsx(
|
|
1108
|
+
"rect",
|
|
1109
|
+
{
|
|
1110
|
+
width: "100%",
|
|
1111
|
+
height: "100%",
|
|
1112
|
+
fill: "rgba(0,0,0,0.55)",
|
|
1113
|
+
mask: "url(#tour-mask)"
|
|
1114
|
+
}
|
|
1115
|
+
)
|
|
1116
|
+
]
|
|
1117
|
+
}
|
|
1118
|
+
),
|
|
1119
|
+
tooltipCoords && /* @__PURE__ */ jsxs(
|
|
1120
|
+
"div",
|
|
1121
|
+
{
|
|
1122
|
+
role: "dialog",
|
|
1123
|
+
"aria-modal": "false",
|
|
1124
|
+
"aria-labelledby": titleId,
|
|
1125
|
+
"aria-describedby": descId,
|
|
1126
|
+
style: {
|
|
1127
|
+
position: "fixed",
|
|
1128
|
+
top: tooltipCoords.top,
|
|
1129
|
+
left: tooltipCoords.left,
|
|
1130
|
+
transform: tooltipCoords.transform,
|
|
1131
|
+
zIndex: 60
|
|
1132
|
+
},
|
|
1133
|
+
className: cn(
|
|
1134
|
+
"w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-lg outline-none animate-in fade-in-0 zoom-in-95"
|
|
1135
|
+
),
|
|
1136
|
+
children: [
|
|
1137
|
+
step.title && /* @__PURE__ */ jsx("div", { id: titleId, className: "text-sm font-semibold", children: step.title }),
|
|
1138
|
+
step.body && /* @__PURE__ */ jsx("div", { id: descId, className: cn("text-sm text-muted-foreground", step.title && "mt-1.5"), children: step.body }),
|
|
1139
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between gap-3", children: [
|
|
1140
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
1141
|
+
currentStep + 1,
|
|
1142
|
+
" / ",
|
|
1143
|
+
steps.length
|
|
1144
|
+
] }),
|
|
1145
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1146
|
+
/* @__PURE__ */ jsx(
|
|
1147
|
+
"button",
|
|
1148
|
+
{
|
|
1149
|
+
type: "button",
|
|
1150
|
+
onClick: skip,
|
|
1151
|
+
className: "text-xs text-muted-foreground hover:text-foreground",
|
|
1152
|
+
children: "Skip"
|
|
1153
|
+
}
|
|
1154
|
+
),
|
|
1155
|
+
currentStep > 0 && /* @__PURE__ */ jsx(
|
|
1156
|
+
"button",
|
|
1157
|
+
{
|
|
1158
|
+
type: "button",
|
|
1159
|
+
onClick: goPrev,
|
|
1160
|
+
className: "inline-flex h-7 items-center rounded-md border border-border bg-background px-2.5 text-xs font-medium hover:bg-muted",
|
|
1161
|
+
children: "Back"
|
|
1162
|
+
}
|
|
1163
|
+
),
|
|
1164
|
+
/* @__PURE__ */ jsx(
|
|
1165
|
+
"button",
|
|
1166
|
+
{
|
|
1167
|
+
type: "button",
|
|
1168
|
+
onClick: goNext,
|
|
1169
|
+
className: "inline-flex h-7 items-center rounded-md bg-primary px-2.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
1170
|
+
children: currentStep >= steps.length - 1 ? "Done" : "Next"
|
|
1171
|
+
}
|
|
1172
|
+
)
|
|
1173
|
+
] })
|
|
1174
|
+
] })
|
|
1175
|
+
]
|
|
1176
|
+
}
|
|
1177
|
+
),
|
|
1178
|
+
/* @__PURE__ */ jsx(Announce, { politeness: "polite", children: step.title ? `Step ${currentStep + 1} of ${steps.length}: ${typeof step.title === "string" ? step.title : ""}` : "" })
|
|
1179
|
+
] });
|
|
1180
|
+
}
|
|
801
1181
|
|
|
802
|
-
export { Alert, AlertSimple, Banner, BannerSimple, Callout, InlineSpinner, LoadingOverlay, LoadingState, MeterBar, ProgressBar, ProgressCircle, ProgressSteps, Skeleton,
|
|
803
|
-
//# sourceMappingURL=chunk-
|
|
804
|
-
//# sourceMappingURL=chunk-
|
|
1182
|
+
export { Alert, AlertSimple, Banner, BannerSimple, Callout, InlineSpinner, LoadingOverlay, LoadingState, MeterBar, OnboardingChecklist, OnboardingChecklistTask, ProgressBar, ProgressCircle, ProgressSteps, Skeleton, StatusIndicator, Toast, ToastSimple, Toaster, Tour, TrendIndicator, UndoBar, alertSimpleVariants, bannerSimpleVariants, progressFillVariants, progressTrackVariants, skeletonVariants, toastSimpleVariants, toaster, useOnboardingChecklist, useToaster };
|
|
1183
|
+
//# sourceMappingURL=chunk-45SFQEMP.js.map
|
|
1184
|
+
//# sourceMappingURL=chunk-45SFQEMP.js.map
|