@kadoui/react 1.0.0 → 1.0.1
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/README.md +1 -0
- package/dist/components/AccessNavigation/AccessNavigation.d.ts.map +1 -1
- package/dist/components/AccessNavigation/AccessNavigation.jsx +1 -1
- package/dist/components/Accordion/AccordionBody.jsx +1 -1
- package/dist/components/Affix/Affix.jsx +1 -1
- package/dist/components/Breadcrumbs/BreadcrumbsItem.jsx +1 -1
- package/dist/components/Breadcrumbs/BreadcrumbsRoot.jsx +1 -1
- package/dist/components/Carousel/CarouselContainer.jsx +1 -1
- package/dist/components/Carousel/CarouselRoot.jsx +1 -1
- package/dist/components/ContextMenu/ContextMenuContent.d.ts.map +1 -1
- package/dist/components/ContextMenu/ContextMenuContent.jsx +2 -1
- package/dist/components/ContextMenu/ContextMenuRoot.d.ts.map +1 -1
- package/dist/components/ContextMenu/ContextMenuRoot.jsx +1 -1
- package/dist/components/Drawer/DrawerBody.jsx +1 -1
- package/dist/components/Drawer/DrawerPortal.jsx +1 -1
- package/dist/components/Drawer/DrawerRoot.jsx +1 -1
- package/dist/components/Dropdown/DropdownMenu.d.ts.map +1 -1
- package/dist/components/Dropdown/DropdownMenu.jsx +1 -1
- package/dist/components/Dropdown/DropdownRoot.d.ts.map +1 -1
- package/dist/components/Dropdown/DropdownRoot.jsx +2 -1
- package/dist/components/LinkLoader/LinkLoader.jsx +1 -1
- package/dist/components/Modal/ModalBody.jsx +1 -1
- package/dist/components/Modal/ModalContent.jsx +1 -1
- package/dist/components/Modal/ModalHeader.jsx +1 -1
- package/dist/components/Modal/ModalPortal.jsx +1 -1
- package/dist/components/Modal/ModalRoot.d.ts.map +1 -1
- package/dist/components/Modal/ModalRoot.jsx +1 -1
- package/dist/components/Otp/OtpInputs.jsx +1 -1
- package/dist/components/Otp/OtpRoot.jsx +1 -1
- package/dist/components/Progress/ProgressBar.jsx +1 -1
- package/dist/components/Progress/ProgressRoot.jsx +1 -1
- package/dist/components/Rating/RatingItems.jsx +1 -1
- package/dist/components/Rating/RatingRoot.jsx +1 -1
- package/dist/components/Sheet/SheetBody.jsx +1 -1
- package/dist/components/Sheet/SheetContent.jsx +1 -1
- package/dist/components/Sheet/SheetHeader.jsx +1 -1
- package/dist/components/Sheet/SheetPortal.jsx +1 -1
- package/dist/components/ShowMore/ShowMoreContent.jsx +1 -1
- package/dist/components/ShowMore/ShowMoreFade.jsx +1 -1
- package/dist/components/ShowMore/ShowMoreRoot.jsx +1 -1
- package/dist/components/ShowMore/ShowMoreTrigger.jsx +1 -1
- package/dist/components/Slide/SlideContent.jsx +1 -1
- package/dist/components/Slide/SlideHeader.jsx +1 -1
- package/dist/components/Slide/SlidePortal.jsx +1 -1
- package/dist/components/Spoiler/Spoiler.jsx +1 -1
- package/dist/components/Steps/StepsControls.jsx +1 -1
- package/dist/components/Tabs/TabsList.jsx +1 -1
- package/dist/components/Tabs/TabsPanel.jsx +1 -1
- package/dist/components/Toast/ToastBox.jsx +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/utils/browser.d.ts +3 -0
- package/dist/utils/browser.d.ts.map +1 -0
- package/dist/utils/browser.js +21 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +3 -0
- package/dist/utils/form.d.ts +2 -0
- package/dist/utils/form.d.ts.map +1 -0
- package/dist/utils/form.js +8 -0
- package/package.json +4 -3
- package/src/components/AccessNavigation/AccessNavigation.tsx +0 -46
- package/src/components/Accordion/Accordion.ts +0 -8
- package/src/components/Accordion/AccordionBody.tsx +0 -31
- package/src/components/Accordion/AccordionContext.ts +0 -8
- package/src/components/Accordion/AccordionRoot.tsx +0 -17
- package/src/components/Accordion/AccordionToggle.tsx +0 -29
- package/src/components/Affix/Affix.tsx +0 -59
- package/src/components/Breadcrumbs/Breadcrumbs.ts +0 -6
- package/src/components/Breadcrumbs/BreadcrumbsContext.ts +0 -7
- package/src/components/Breadcrumbs/BreadcrumbsItem.tsx +0 -24
- package/src/components/Breadcrumbs/BreadcrumbsRoot.tsx +0 -21
- package/src/components/Carousel/Carousel.ts +0 -6
- package/src/components/Carousel/CarouselContainer.tsx +0 -18
- package/src/components/Carousel/CarouselContext.ts +0 -7
- package/src/components/Carousel/CarouselRoot.tsx +0 -75
- package/src/components/ClientOnly/ClientOnly.tsx +0 -12
- package/src/components/Clipboard/Clipboard.tsx +0 -36
- package/src/components/ContextMenu/ContextMenu.ts +0 -6
- package/src/components/ContextMenu/ContextMenuContent.tsx +0 -51
- package/src/components/ContextMenu/ContextMenuContext.ts +0 -9
- package/src/components/ContextMenu/ContextMenuRoot.tsx +0 -79
- package/src/components/Drawer/Drawer.ts +0 -10
- package/src/components/Drawer/DrawerBody.tsx +0 -67
- package/src/components/Drawer/DrawerContext.ts +0 -8
- package/src/components/Drawer/DrawerPortal.tsx +0 -40
- package/src/components/Drawer/DrawerRoot.tsx +0 -45
- package/src/components/Drawer/DrawerToggle.tsx +0 -21
- package/src/components/Dropdown/Dropdown.ts +0 -8
- package/src/components/Dropdown/DropdownContext.ts +0 -10
- package/src/components/Dropdown/DropdownMenu.tsx +0 -34
- package/src/components/Dropdown/DropdownRoot.tsx +0 -90
- package/src/components/Dropdown/DropdownToggle.tsx +0 -23
- package/src/components/LinkLoader/LinkLoader.tsx +0 -16
- package/src/components/Modal/Modal.ts +0 -14
- package/src/components/Modal/ModalBody.tsx +0 -12
- package/src/components/Modal/ModalContent.tsx +0 -44
- package/src/components/Modal/ModalContext.ts +0 -8
- package/src/components/Modal/ModalHeader.tsx +0 -10
- package/src/components/Modal/ModalPortal.tsx +0 -40
- package/src/components/Modal/ModalRoot.tsx +0 -47
- package/src/components/Modal/ModalTrigger.tsx +0 -21
- package/src/components/Otp/Otp.ts +0 -8
- package/src/components/Otp/OtpContext.ts +0 -10
- package/src/components/Otp/OtpHiddenInput.tsx +0 -15
- package/src/components/Otp/OtpInputs.tsx +0 -86
- package/src/components/Otp/OtpRoot.tsx +0 -26
- package/src/components/Pagination/Pagination.ts +0 -15
- package/src/components/Pagination/PaginationContext.tsx +0 -10
- package/src/components/Pagination/PaginationCounts.tsx +0 -17
- package/src/components/Pagination/PaginationNextBtn.tsx +0 -27
- package/src/components/Pagination/PaginationPrevBtn.tsx +0 -27
- package/src/components/Pagination/PaginationSearchParamsRoot.tsx +0 -45
- package/src/components/Pagination/PaginationStateRoot.tsx +0 -23
- package/src/components/PasswordInput/PasswordInput.ts +0 -8
- package/src/components/PasswordInput/PasswordInputContext.tsx +0 -8
- package/src/components/PasswordInput/PasswordInputField.tsx +0 -15
- package/src/components/PasswordInput/PasswordInputRoot.tsx +0 -17
- package/src/components/PasswordInput/PasswordInputToggle.tsx +0 -52
- package/src/components/Portal/Portal.tsx +0 -17
- package/src/components/Progress/Progress.ts +0 -6
- package/src/components/Progress/ProgressBar.tsx +0 -29
- package/src/components/Progress/ProgressContext.ts +0 -8
- package/src/components/Progress/ProgressRoot.tsx +0 -22
- package/src/components/QrCode/QrCode.tsx +0 -22
- package/src/components/Rating/Rating.ts +0 -6
- package/src/components/Rating/RatingContext.ts +0 -8
- package/src/components/Rating/RatingItems.tsx +0 -50
- package/src/components/Rating/RatingRoot.tsx +0 -22
- package/src/components/Sheet/Sheet.tsx +0 -14
- package/src/components/Sheet/SheetBody.tsx +0 -49
- package/src/components/Sheet/SheetContent.tsx +0 -8
- package/src/components/Sheet/SheetContext.ts +0 -14
- package/src/components/Sheet/SheetHeader.tsx +0 -24
- package/src/components/Sheet/SheetPortal.tsx +0 -35
- package/src/components/Sheet/SheetRoot.tsx +0 -56
- package/src/components/Sheet/SheetToggle.tsx +0 -21
- package/src/components/ShowMore/ShowMore.ts +0 -10
- package/src/components/ShowMore/ShowMoreContent.tsx +0 -31
- package/src/components/ShowMore/ShowMoreContext.ts +0 -11
- package/src/components/ShowMore/ShowMoreFade.tsx +0 -18
- package/src/components/ShowMore/ShowMoreRoot.tsx +0 -37
- package/src/components/ShowMore/ShowMoreTrigger.tsx +0 -23
- package/src/components/Slide/Slide.ts +0 -12
- package/src/components/Slide/SlideContent.tsx +0 -8
- package/src/components/Slide/SlideContext.ts +0 -11
- package/src/components/Slide/SlideHeader.tsx +0 -10
- package/src/components/Slide/SlidePortal.tsx +0 -26
- package/src/components/Slide/SlideRoot.tsx +0 -39
- package/src/components/Slide/SlideToggle.tsx +0 -21
- package/src/components/Spoiler/Spoiler.tsx +0 -28
- package/src/components/Steps/Steps.ts +0 -15
- package/src/components/Steps/StepsContext.tsx +0 -16
- package/src/components/Steps/StepsControls.tsx +0 -56
- package/src/components/Steps/StepsNextBtn.tsx +0 -27
- package/src/components/Steps/StepsPrevBtn.tsx +0 -27
- package/src/components/Steps/StepsSearchParamsRoot.tsx +0 -45
- package/src/components/Steps/StepsStateRoot.tsx +0 -23
- package/src/components/Swap/Swap.ts +0 -8
- package/src/components/Swap/SwapContext.ts +0 -9
- package/src/components/Swap/SwapItem.tsx +0 -16
- package/src/components/Swap/SwapRoot.tsx +0 -29
- package/src/components/Swap/SwapTrigger.tsx +0 -31
- package/src/components/Tabs/Tabs.ts +0 -10
- package/src/components/Tabs/TabsContext.ts +0 -11
- package/src/components/Tabs/TabsList.tsx +0 -12
- package/src/components/Tabs/TabsPanel.tsx +0 -23
- package/src/components/Tabs/TabsRoot.tsx +0 -18
- package/src/components/Tabs/TabsTab.tsx +0 -23
- package/src/components/Toast/Toast.ts +0 -3
- package/src/components/Toast/ToastBox.tsx +0 -50
- package/src/components/Toast/ToastRoot.tsx +0 -71
- package/src/components/Toast/toastStore.ts +0 -22
- package/src/components/Toggle/Toggle.ts +0 -6
- package/src/components/Toggle/ToggleContext.ts +0 -9
- package/src/components/Toggle/ToggleRoot.tsx +0 -26
- package/src/components/Toggle/ToggleSwitch.tsx +0 -41
- package/src/index.ts +0 -28
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@kadoui/utils";
|
|
4
|
-
import { HTMLAttributes, use } from "react";
|
|
5
|
-
|
|
6
|
-
import { ShowMoreContext } from "./ShowMoreContext";
|
|
7
|
-
|
|
8
|
-
export type ShowMoreFadePropsT = HTMLAttributes<HTMLDivElement>;
|
|
9
|
-
|
|
10
|
-
export function ShowMoreFade({ className, ...p }: ShowMoreFadePropsT) {
|
|
11
|
-
const { shouldShowMore, isShowMore } = use(ShowMoreContext);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
shouldShowMore && !isShowMore ? (
|
|
15
|
-
<div className={cn("absolute inset-0 bg-gradient-to-t from-background from-35% to-transparent", className)} {...p} />
|
|
16
|
-
) : null
|
|
17
|
-
)
|
|
18
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { cn } from "@kadoui/utils";
|
|
4
|
-
import { HTMLAttributes, useEffect, useRef, useState } from "react";
|
|
5
|
-
|
|
6
|
-
import { ShowMoreContext } from "./ShowMoreContext";
|
|
7
|
-
|
|
8
|
-
export type ShowMoreRootPropsT = HTMLAttributes<HTMLDivElement> & {
|
|
9
|
-
maxLines: number;
|
|
10
|
-
defaultExpanded?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function ShowMoreRoot({ maxLines, defaultExpanded = false, className, ...p }: ShowMoreRootPropsT) {
|
|
14
|
-
const [shouldShowMore, setShouldShowMore] = useState(false);
|
|
15
|
-
const [isShowMore, setIsShowMore] = useState(defaultExpanded);
|
|
16
|
-
const [maxHeight, setMaxHeight] = useState(0);
|
|
17
|
-
|
|
18
|
-
const contentRef = useRef<HTMLDivElement>(null);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (contentRef.current) {
|
|
22
|
-
const element = contentRef.current;
|
|
23
|
-
const lineHeight = Number.parseInt(window.getComputedStyle(element).lineHeight);
|
|
24
|
-
const maxHeight = lineHeight * (maxLines || 3);
|
|
25
|
-
const actualHeight = element.scrollHeight;
|
|
26
|
-
|
|
27
|
-
setMaxHeight(maxHeight);
|
|
28
|
-
setShouldShowMore(actualHeight > maxHeight);
|
|
29
|
-
}
|
|
30
|
-
}, [maxLines])
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<ShowMoreContext value={{ contentRef, isShowMore, setIsShowMore, maxHeight, shouldShowMore }}>
|
|
34
|
-
<div className={cn("relative", className)} {...p}></div>
|
|
35
|
-
</ShowMoreContext>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@kadoui/utils";
|
|
4
|
-
import { ButtonHTMLAttributes, use } from "react";
|
|
5
|
-
|
|
6
|
-
import { ShowMoreContext } from "./ShowMoreContext";
|
|
7
|
-
|
|
8
|
-
export type ShowMoreTriggerPropsT = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
9
|
-
|
|
10
|
-
export function ShowMoreTrigger({ onClick, className, ...p }: ShowMoreTriggerPropsT) {
|
|
11
|
-
const { setIsShowMore } = use(ShowMoreContext);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<button
|
|
15
|
-
className={cn("relative", className)}
|
|
16
|
-
onClick={ev => {
|
|
17
|
-
onClick?.(ev);
|
|
18
|
-
setIsShowMore(prev => !prev);
|
|
19
|
-
}}
|
|
20
|
-
{...p}
|
|
21
|
-
/>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { SlideRoot } from "./SlideRoot";
|
|
2
|
-
import { SlideHeader } from "./SlideHeader";
|
|
3
|
-
import { SlidePortal } from "./SlidePortal";
|
|
4
|
-
import { SlideToggle } from "./SlideToggle";
|
|
5
|
-
import { SlideContent } from "./SlideContent";
|
|
6
|
-
|
|
7
|
-
export const Slide = Object.assign(SlideRoot, {
|
|
8
|
-
Portal: SlidePortal,
|
|
9
|
-
Toggle: SlideToggle,
|
|
10
|
-
Header: SlideHeader,
|
|
11
|
-
Content: SlideContent
|
|
12
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { cn } from "@kadoui/utils";
|
|
2
|
-
import { HTMLAttributes } from "react";
|
|
3
|
-
|
|
4
|
-
export type SlideContentPropsT = HTMLAttributes<HTMLDivElement>;
|
|
5
|
-
|
|
6
|
-
export function SlideContent({ className, ...props }: SlideContentPropsT) {
|
|
7
|
-
return <div className={cn("h-[calc(100dvh-5rem)] py-3 overflow-y-auto", className)} {...props} />;
|
|
8
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createContext, Dispatch, SetStateAction } from "react";
|
|
2
|
-
|
|
3
|
-
export type SlideContextT = {
|
|
4
|
-
isOpen: boolean;
|
|
5
|
-
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const SlideContext = createContext<SlideContextT>({
|
|
9
|
-
isOpen: false,
|
|
10
|
-
setOpen: () => { }
|
|
11
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { cn } from "@kadoui/utils";
|
|
2
|
-
import { HTMLAttributes } from "react";
|
|
3
|
-
|
|
4
|
-
export type SlideHeaderPropsT = HTMLAttributes<HTMLHeadingElement>
|
|
5
|
-
|
|
6
|
-
export function SlideHeader({ className, ...props }: SlideHeaderPropsT) {
|
|
7
|
-
return (
|
|
8
|
-
<header className={cn("h-20 f-align border-b border-foreground/10", className)} {...props} />
|
|
9
|
-
);
|
|
10
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@kadoui/utils";
|
|
4
|
-
import { HTMLAttributes, use } from "react";
|
|
5
|
-
|
|
6
|
-
import { Portal } from "../Portal/Portal";
|
|
7
|
-
import { SlideContext } from "./SlideContext";
|
|
8
|
-
|
|
9
|
-
export type SlidePortalPropsT = HTMLAttributes<HTMLDivElement>;
|
|
10
|
-
|
|
11
|
-
export function SlidePortal({ className, ...props }: SlidePortalPropsT) {
|
|
12
|
-
const { isOpen } = use(SlideContext);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<Portal>
|
|
16
|
-
<div
|
|
17
|
-
className={cn(
|
|
18
|
-
"w-screen h-dvh bg-background fixed top-0 left-0 transition-all duration-700",
|
|
19
|
-
isOpen ? "" : "faint -translate-x-full",
|
|
20
|
-
className
|
|
21
|
-
)}
|
|
22
|
-
{...props}
|
|
23
|
-
/>
|
|
24
|
-
</Portal>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { PropsWithChildren, useEffect, useState } from "react";
|
|
4
|
-
|
|
5
|
-
import { SlideContext } from "./SlideContext";
|
|
6
|
-
|
|
7
|
-
export type SlideRootPropsT = PropsWithChildren;
|
|
8
|
-
|
|
9
|
-
export function SlideRoot({ children }: SlideRootPropsT) {
|
|
10
|
-
const [isOpen, setOpen] = useState(false);
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const rootElem = document.getElementById("root");
|
|
14
|
-
if (!rootElem) {
|
|
15
|
-
return;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const bodyElem = document.body;
|
|
19
|
-
|
|
20
|
-
if (isOpen) {
|
|
21
|
-
bodyElem.classList.add("overflow-hidden");
|
|
22
|
-
rootElem.classList.add("translate-x-full");
|
|
23
|
-
} else {
|
|
24
|
-
bodyElem.classList.remove("overflow-hidden");
|
|
25
|
-
rootElem.classList.remove("translate-x-full");
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return () => {
|
|
29
|
-
bodyElem.classList.remove("overflow-hidden");
|
|
30
|
-
rootElem.classList.remove("translate-x-full");
|
|
31
|
-
};
|
|
32
|
-
}, [isOpen]);
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<SlideContext value={{ isOpen, setOpen }}>
|
|
36
|
-
{children}
|
|
37
|
-
</SlideContext>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, { HTMLAttributes, use } from "react";
|
|
4
|
-
|
|
5
|
-
import { SlideContext } from "./SlideContext";
|
|
6
|
-
|
|
7
|
-
export type SlideTogglePropsT = HTMLAttributes<HTMLButtonElement>;
|
|
8
|
-
|
|
9
|
-
export function SlideToggle({ onClick, ...props }: SlideTogglePropsT) {
|
|
10
|
-
const { setOpen } = use(SlideContext);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<button
|
|
14
|
-
onClick={ev => {
|
|
15
|
-
onClick?.(ev);
|
|
16
|
-
setOpen(prev => !prev);
|
|
17
|
-
}}
|
|
18
|
-
{...props}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@kadoui/utils";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
|
|
6
|
-
export type SpoilerProps = {
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
className?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function Spoiler({ children, className }: SpoilerProps) {
|
|
12
|
-
const [revealed, setRevealed] = useState(false);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<span
|
|
16
|
-
onClick={() => setRevealed(true)}
|
|
17
|
-
className={cn(
|
|
18
|
-
"transition-all",
|
|
19
|
-
revealed ? "" : "inline cursor-pointer rounded overflow-hidden px-1",
|
|
20
|
-
className
|
|
21
|
-
)}
|
|
22
|
-
>
|
|
23
|
-
<span className={`transition-all ${revealed ? "" : "select-none blur-[3px]"}`}>
|
|
24
|
-
{children}
|
|
25
|
-
</span>
|
|
26
|
-
</span>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { StepsPrevBtn } from "./StepsPrevBtn";
|
|
2
|
-
import { StepsNextBtn } from "./StepsNextBtn";
|
|
3
|
-
import { StepsControls } from "./StepsControls";
|
|
4
|
-
import { StepsStateRoot } from "./StepsStateRoot";
|
|
5
|
-
import { StepsSearchParamsRoot } from "./StepsSearchParamsRoot";
|
|
6
|
-
|
|
7
|
-
const baseComponents = {
|
|
8
|
-
Controls: StepsControls,
|
|
9
|
-
PrevBtn: StepsPrevBtn,
|
|
10
|
-
NextBtn: StepsNextBtn
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const StepsWithState = Object.assign(StepsStateRoot, baseComponents);
|
|
14
|
-
|
|
15
|
-
export const StepsWithSearchParams = Object.assign(StepsSearchParamsRoot, baseComponents);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createContext, Dispatch, ReactNode, SetStateAction } from "react";
|
|
2
|
-
|
|
3
|
-
export type StepsT = {
|
|
4
|
-
name: string;
|
|
5
|
-
component: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type StepsContextT = {
|
|
9
|
-
step: number;
|
|
10
|
-
steps: StepsT[];
|
|
11
|
-
setStep: Dispatch<SetStateAction<number>>;
|
|
12
|
-
nextStep: () => void;
|
|
13
|
-
prevStep: () => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const StepsContext = createContext<StepsContextT>({} as StepsContextT);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@kadoui/utils";
|
|
4
|
-
import { HTMLAttributes, use } from "react";
|
|
5
|
-
|
|
6
|
-
import { StepsContext } from "./StepsContext";
|
|
7
|
-
|
|
8
|
-
export type StepsControlsPropsT = HTMLAttributes<HTMLDivElement>;
|
|
9
|
-
|
|
10
|
-
export function StepsControls({ className, ...props }: StepsControlsPropsT) {
|
|
11
|
-
const { step, steps, setStep } = use(StepsContext);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<div className={cn("f-align mb-[calc(1.5rem+0.75rem+0.375rem)]", className)} {...props}>
|
|
16
|
-
{steps.map((item, index) => (
|
|
17
|
-
<div
|
|
18
|
-
key={index}
|
|
19
|
-
className={`${index + 1 < steps.length ? "w-full" : "w-max"} f-align justify-between`}
|
|
20
|
-
>
|
|
21
|
-
<div className="f-center relative flex-col">
|
|
22
|
-
<button
|
|
23
|
-
onClick={() => step > index + 1 && setStep(index + 1)}
|
|
24
|
-
className={`${step >= index + 1 ? "btn-fill" : "btn-ghost"} btn-square rounded-full`}
|
|
25
|
-
>
|
|
26
|
-
<span className="text-sm">{(index + 1)}</span>
|
|
27
|
-
</button>
|
|
28
|
-
<span
|
|
29
|
-
className={`
|
|
30
|
-
f-align mt-1.5 h-3 w-max text-center text-xs absolute top-full
|
|
31
|
-
${step === index + 1 ? "font-bold" : ""}
|
|
32
|
-
${index === 0 ? "ltr:left-0 rtl:right-0" : index + 1 === steps.length ? "ltr:right-0 rtl:left-0" : ""}
|
|
33
|
-
`}
|
|
34
|
-
>
|
|
35
|
-
{item.name}
|
|
36
|
-
</span>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
{index + 1 < steps.length ? (
|
|
40
|
-
<div key={index} className="bg-foreground/10 flex h-1.5 flex-1 shrink-0">
|
|
41
|
-
<div
|
|
42
|
-
className={`
|
|
43
|
-
bg-primary w-full ltr:origin-left rtl:origin-right h-full
|
|
44
|
-
${step > index + 1 ? "scale-x-100" : step === index + 1 ? "scale-x-[50%]" : "scale-x-0"}
|
|
45
|
-
`}
|
|
46
|
-
/>
|
|
47
|
-
</div>
|
|
48
|
-
) : null}
|
|
49
|
-
</div>
|
|
50
|
-
))}
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
{steps.find((_, index) => index + 1 === step)?.component}
|
|
54
|
-
</>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { HTMLAttributes, use } from "react";
|
|
4
|
-
import { ChevronRightIcon } from "lucide-react";
|
|
5
|
-
|
|
6
|
-
import { StepsContext } from "./StepsContext";
|
|
7
|
-
|
|
8
|
-
export type StepsNextBtnPropsT = HTMLAttributes<HTMLButtonElement> & {
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function StepsNextBtn({ onClick, disabled, children, ...props }: StepsNextBtnPropsT) {
|
|
13
|
-
const { step, steps, nextStep } = use(StepsContext);
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<button
|
|
17
|
-
disabled={disabled || step === steps.length}
|
|
18
|
-
onClick={ev => {
|
|
19
|
-
onClick?.(ev);
|
|
20
|
-
nextStep();
|
|
21
|
-
}}
|
|
22
|
-
{...props}
|
|
23
|
-
>
|
|
24
|
-
{children || <ChevronRightIcon className="compatible-icon" />}
|
|
25
|
-
</button>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { HTMLAttributes, use } from "react";
|
|
4
|
-
import { ChevronLeftIcon } from "lucide-react";
|
|
5
|
-
|
|
6
|
-
import { StepsContext } from "./StepsContext";
|
|
7
|
-
|
|
8
|
-
export type StepsPrevBtnPropsT = HTMLAttributes<HTMLButtonElement> & {
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function StepsPrevBtn({ onClick, disabled, children, ...props }: StepsPrevBtnPropsT) {
|
|
13
|
-
const { step, prevStep } = use(StepsContext);
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<button
|
|
17
|
-
disabled={disabled || step === 1}
|
|
18
|
-
onClick={ev => {
|
|
19
|
-
onClick?.(ev);
|
|
20
|
-
prevStep();
|
|
21
|
-
}}
|
|
22
|
-
{...props}
|
|
23
|
-
>
|
|
24
|
-
{children || <ChevronLeftIcon className="compatible-icon" />}
|
|
25
|
-
</button>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useRouter, useSearchParams } from "next/navigation";
|
|
4
|
-
import { PropsWithChildren, useEffect, useState } from "react";
|
|
5
|
-
|
|
6
|
-
import { StepsContext, StepsT } from "./StepsContext";
|
|
7
|
-
|
|
8
|
-
export type StepsSearchParamsRootPropsT = PropsWithChildren & {
|
|
9
|
-
stepKey?: string;
|
|
10
|
-
steps: StepsT[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function StepsSearchParamsRoot({ children, steps, stepKey }: StepsSearchParamsRootPropsT) {
|
|
14
|
-
const router = useRouter();
|
|
15
|
-
const searchParams = useSearchParams();
|
|
16
|
-
const [currentStep, setCurrentStep] = useState(1);
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
setCurrentStep(+(searchParams.get(stepKey || "step") || "1"));
|
|
20
|
-
}, [stepKey, searchParams]);
|
|
21
|
-
|
|
22
|
-
const pushRouter = (page: number) => {
|
|
23
|
-
const params = new URLSearchParams(searchParams.toString());
|
|
24
|
-
params.set(stepKey || "step", page.toString());
|
|
25
|
-
router.push("?" + params.toString())
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const nextStep = () => {
|
|
29
|
-
if (currentStep < steps.length) {
|
|
30
|
-
pushRouter(currentStep + 1);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const prevStep = () => {
|
|
35
|
-
if (currentStep > 1) {
|
|
36
|
-
pushRouter(currentStep - 1);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<StepsContext.Provider value={{ step: currentStep, setStep: setCurrentStep, steps, nextStep, prevStep }}>
|
|
42
|
-
{children}
|
|
43
|
-
</StepsContext.Provider>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { PropsWithChildren, useState } from "react";
|
|
4
|
-
|
|
5
|
-
import { StepsT, StepsContext } from "./StepsContext";
|
|
6
|
-
|
|
7
|
-
export type StepsStateRootPropsT = PropsWithChildren & {
|
|
8
|
-
steps: StepsT[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function StepsStateRoot({ children, steps }: StepsStateRootPropsT) {
|
|
12
|
-
const [step, setStep] = useState(1);
|
|
13
|
-
|
|
14
|
-
const nextStep = () => setStep(prev => prev + 1);
|
|
15
|
-
|
|
16
|
-
const prevStep = () => setStep(prev => prev - 1);
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<StepsContext.Provider value={{ step, setStep, steps, nextStep, prevStep }}>
|
|
20
|
-
{children}
|
|
21
|
-
</StepsContext.Provider>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { motion, HTMLMotionProps } from "framer-motion";
|
|
4
|
-
|
|
5
|
-
export type SwapItemPropsT = HTMLMotionProps<"span">;
|
|
6
|
-
|
|
7
|
-
export function SwapItem(p: SwapItemPropsT) {
|
|
8
|
-
return (
|
|
9
|
-
<motion.span
|
|
10
|
-
initial={{ rotate: 90, opacity: 0 }}
|
|
11
|
-
animate={{ rotate: 0, opacity: 1 }}
|
|
12
|
-
exit={{ rotate: 90, opacity: 0 }}
|
|
13
|
-
{...p}
|
|
14
|
-
/>
|
|
15
|
-
)
|
|
16
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { AnimatePresence } from "framer-motion";
|
|
4
|
-
import { HTMLAttributes, useState } from "react";
|
|
5
|
-
|
|
6
|
-
import { SwapContext } from "./SwapContext";
|
|
7
|
-
|
|
8
|
-
export type SwapRootPropsT = HTMLAttributes<HTMLDivElement> & {
|
|
9
|
-
items: string[];
|
|
10
|
-
defaultItem?: string;
|
|
11
|
-
onSwap?: (item: string) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function SwapRoot({ items, defaultItem, onSwap, ...p }: SwapRootPropsT) {
|
|
15
|
-
const [activeItem, setActiveItem] = useState(defaultItem || items[1]);
|
|
16
|
-
|
|
17
|
-
const handleSwap = (newItem: string) => {
|
|
18
|
-
setActiveItem(newItem);
|
|
19
|
-
onSwap?.(newItem);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<SwapContext value={{ items, activeItem, handleSwap }} >
|
|
24
|
-
<AnimatePresence mode="wait">
|
|
25
|
-
<div {...p} />
|
|
26
|
-
</AnimatePresence>
|
|
27
|
-
</SwapContext>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { HTMLAttributes, use } from "react";
|
|
4
|
-
|
|
5
|
-
import { SwapContext } from "./SwapContext";
|
|
6
|
-
|
|
7
|
-
export type SwapTriggerPropsT = HTMLAttributes<HTMLButtonElement> & {
|
|
8
|
-
item: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function SwapTrigger({ item, onClick, ...p }: SwapTriggerPropsT) {
|
|
12
|
-
const { items, activeItem, handleSwap } = use(SwapContext);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
activeItem === item ? (
|
|
16
|
-
<button
|
|
17
|
-
onClick={ev => {
|
|
18
|
-
onClick?.(ev);
|
|
19
|
-
{
|
|
20
|
-
const nextIndex = items.indexOf(item) + 1 >= items.length ? 0 : items.indexOf(item) + 1;
|
|
21
|
-
const nextItem = items[nextIndex];
|
|
22
|
-
if (nextItem !== undefined) {
|
|
23
|
-
handleSwap(nextItem);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}}
|
|
27
|
-
{...p}
|
|
28
|
-
/>
|
|
29
|
-
) : null
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TabsTab } from "./TabsTab";
|
|
2
|
-
import { TabsList } from "./TabsList";
|
|
3
|
-
import { TabsRoot } from "./TabsRoot";
|
|
4
|
-
import { TabsPanel } from "./TabsPanel";
|
|
5
|
-
|
|
6
|
-
export const Tabs = Object.assign(TabsRoot, {
|
|
7
|
-
List: TabsList,
|
|
8
|
-
Tab: TabsTab,
|
|
9
|
-
Panel: TabsPanel
|
|
10
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createContext, Dispatch, SetStateAction } from "react";
|
|
2
|
-
|
|
3
|
-
export type TabsContextT = {
|
|
4
|
-
activeTab: string;
|
|
5
|
-
setActiveTab: Dispatch<SetStateAction<string>>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const TabsContext = createContext<TabsContextT>({
|
|
9
|
-
activeTab: "",
|
|
10
|
-
setActiveTab: () => { },
|
|
11
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { cn } from "@kadoui/utils";
|
|
4
|
-
import { HTMLAttributes } from "react";
|
|
5
|
-
|
|
6
|
-
export type TabsListPropsT = HTMLAttributes<HTMLDivElement>;
|
|
7
|
-
|
|
8
|
-
export function TabsList({ className, ...props }: TabsListPropsT) {
|
|
9
|
-
return (
|
|
10
|
-
<div className={cn("join-border", className)} {...props} />
|
|
11
|
-
);
|
|
12
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@kadoui/utils";
|
|
4
|
-
import { HTMLAttributes, use } from "react";
|
|
5
|
-
|
|
6
|
-
import { TabsContext } from "./TabsContext";
|
|
7
|
-
|
|
8
|
-
export type TabsPanelPropsT = HTMLAttributes<HTMLDivElement> & {
|
|
9
|
-
value: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function TabsPanel({ value, className, ...props }: TabsPanelPropsT) {
|
|
13
|
-
const { activeTab } = use(TabsContext);
|
|
14
|
-
|
|
15
|
-
const isActive = activeTab === value;
|
|
16
|
-
|
|
17
|
-
return isActive ? (
|
|
18
|
-
<div
|
|
19
|
-
className={cn("p-3 rounded-kado bg-foreground/10 mt-1.5", className)}
|
|
20
|
-
{...props}
|
|
21
|
-
/>
|
|
22
|
-
) : null
|
|
23
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { Dispatch, PropsWithChildren, SetStateAction } from "react";
|
|
4
|
-
|
|
5
|
-
import { TabsContext } from "./TabsContext";
|
|
6
|
-
|
|
7
|
-
export type TabsRootPropsT = PropsWithChildren & {
|
|
8
|
-
activeTab: string;
|
|
9
|
-
setActiveTab: Dispatch<SetStateAction<string>>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function TabsRoot({ activeTab, setActiveTab, children }: TabsRootPropsT) {
|
|
13
|
-
return (
|
|
14
|
-
<TabsContext value={{ activeTab, setActiveTab }}>
|
|
15
|
-
{children}
|
|
16
|
-
</TabsContext>
|
|
17
|
-
)
|
|
18
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { type HTMLAttributes, use } from "react";
|
|
4
|
-
|
|
5
|
-
import { TabsContext } from "./TabsContext";
|
|
6
|
-
|
|
7
|
-
export type TabsTabPropsT = HTMLAttributes<HTMLButtonElement> & {
|
|
8
|
-
value: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function TabsTab({ value, onClick, ...props }: TabsTabPropsT) {
|
|
12
|
-
const { setActiveTab } = use(TabsContext);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<button
|
|
16
|
-
onClick={(ev) => {
|
|
17
|
-
onClick?.(ev);
|
|
18
|
-
setActiveTab(value);
|
|
19
|
-
}}
|
|
20
|
-
{...props}
|
|
21
|
-
/>
|
|
22
|
-
)
|
|
23
|
-
}
|