luan-ui 0.1.0
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/components/accordion/accordion.d.ts +34 -0
- package/dist/components/accordion/accordion.js +15 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/button/button.d.ts +60 -0
- package/dist/components/button/button.js +80 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/card/card.d.ts +172 -0
- package/dist/components/card/card.js +212 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +39 -0
- package/dist/components/checkbox/checkbox.js +66 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +10 -0
- package/dist/components/dialog/dialog.js +23 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/form-field/form-field-context.d.ts +13 -0
- package/dist/components/form-field/form-field-context.js +12 -0
- package/dist/components/form-field/form-field-context.js.map +1 -0
- package/dist/components/form-field/form-field.d.ts +25 -0
- package/dist/components/form-field/form-field.js +46 -0
- package/dist/components/form-field/form-field.js.map +1 -0
- package/dist/components/form-helper/form-helper.d.ts +21 -0
- package/dist/components/form-helper/form-helper.js +42 -0
- package/dist/components/form-helper/form-helper.js.map +1 -0
- package/dist/components/icon/icon.d.ts +54 -0
- package/dist/components/icon/icon.js +67 -0
- package/dist/components/icon/icon.js.map +1 -0
- package/dist/components/input/input.d.ts +15 -0
- package/dist/components/input/input.js +42 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/label/label.d.ts +16 -0
- package/dist/components/label/label.js +23 -0
- package/dist/components/label/label.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +86 -0
- package/dist/components/pagination/pagination.js +134 -0
- package/dist/components/pagination/pagination.js.map +1 -0
- package/dist/components/popover/popover.d.ts +64 -0
- package/dist/components/popover/popover.js +81 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/progress/progress.d.ts +17 -0
- package/dist/components/progress/progress.js +18 -0
- package/dist/components/progress/progress.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +33 -0
- package/dist/components/radio-group/radio-group.js +37 -0
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/select/select.d.ts +42 -0
- package/dist/components/select/select.js +58 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +5 -0
- package/dist/components/skeleton/skeleton.js +10 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/slider/slider.d.ts +39 -0
- package/dist/components/slider/slider.js +36 -0
- package/dist/components/slider/slider.js.map +1 -0
- package/dist/components/slot/slot.d.ts +13 -0
- package/dist/components/slot/slot.js +70 -0
- package/dist/components/slot/slot.js.map +1 -0
- package/dist/components/switch/switch.d.ts +41 -0
- package/dist/components/switch/switch.js +74 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/table/table.d.ts +33 -0
- package/dist/components/table/table.js +45 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +6 -0
- package/dist/components/tabs/tabs.js +13 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/toast/toast.d.ts +33 -0
- package/dist/components/toast/toast.js +33 -0
- package/dist/components/toast/toast.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +35 -0
- package/dist/components/tooltip/tooltip.js +48 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/utilities/cn/cn.d.ts +2 -0
- package/dist/utilities/cn/cn.js +6 -0
- package/dist/utilities/cn/cn.js.map +1 -0
- package/dist/utilities/get-variants/get-variants.d.ts +56 -0
- package/dist/utilities/get-variants/get-variants.js +79 -0
- package/dist/utilities/get-variants/get-variants.js.map +1 -0
- package/dist/utilities/merge-refs/merge-refs.d.ts +2 -0
- package/dist/utilities/merge-refs/merge-refs.js +13 -0
- package/dist/utilities/merge-refs/merge-refs.js.map +1 -0
- package/dist/utilities/pagination/get-truncated-elements.d.ts +7 -0
- package/dist/utilities/pagination/get-truncated-elements.js +101 -0
- package/dist/utilities/pagination/get-truncated-elements.js.map +1 -0
- package/dist/utilities/pagination/keyboard-navigation.d.ts +1 -0
- package/dist/utilities/pagination/keyboard-navigation.js +70 -0
- package/dist/utilities/pagination/keyboard-navigation.js.map +1 -0
- package/dist/utilities/responsive/responsive.d.ts +37 -0
- package/dist/utilities/responsive/responsive.js +40 -0
- package/dist/utilities/responsive/responsive.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from "@components/slot/slot";
|
|
3
|
+
import { cn } from "@utilities/cn/cn";
|
|
4
|
+
import { mergeRefs } from "@utilities/merge-refs/merge-refs";
|
|
5
|
+
import { getTruncatedElements } from "@utilities/pagination/get-truncated-elements";
|
|
6
|
+
import { handleKeyboardNavigation } from "@utilities/pagination/keyboard-navigation";
|
|
7
|
+
import clsx from "clsx";
|
|
8
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
9
|
+
const PaginationContext = createContext(undefined);
|
|
10
|
+
const usePaginationContext = () => {
|
|
11
|
+
const context = useContext(PaginationContext);
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new Error("Pagination components must be used within a Pagination");
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Pagination component that provides navigation controls for a set of pages.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} props.page - The current active page number
|
|
21
|
+
* @param {number} props.totalPages - The total number of pages
|
|
22
|
+
* @param {(page: number) => void} props.onPageChange - Callback function called when page changes
|
|
23
|
+
* @param {boolean} [props.asChild] - Whether to render the root element as a child component
|
|
24
|
+
* @param {React.ReactNode} [props.children] - The content to render within the pagination component
|
|
25
|
+
* @param {string} [props.className] - Additional CSS classes to apply
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <Pagination page={1} totalPages={10} onPageChange={(page) => console.log(page)}>
|
|
30
|
+
* <PaginationPrev>Previous</PaginationPrev>
|
|
31
|
+
* <PaginationItem index={1}>1</PaginationItem>
|
|
32
|
+
* <PaginationItem index={2}>2</PaginationItem>
|
|
33
|
+
* <PaginationNext>Next</PaginationNext>
|
|
34
|
+
* </Pagination>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
const Pagination = forwardRef(({ children, page: initialPage, totalPages: initialTotalPages, onPageChange, className, asChild, ...props }, ref) => {
|
|
38
|
+
const [page, setPage] = useState(initialPage);
|
|
39
|
+
const [totalPages, setTotalPages] = useState(initialTotalPages);
|
|
40
|
+
const [hasNextPage, setHasNextPage] = useState(page < totalPages);
|
|
41
|
+
const [hasPreviousPage, setHasPreviousPage] = useState(page > 1);
|
|
42
|
+
const refs = useRef(new Map());
|
|
43
|
+
const handleKeyDown = useCallback((e) => handleKeyboardNavigation(e, { current: refs.current }, totalPages), [totalPages]);
|
|
44
|
+
const registerRefWrapper = useCallback((index, element) => {
|
|
45
|
+
if (element) {
|
|
46
|
+
refs.current.set(index, element);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
refs.current.delete(index);
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
54
|
+
return () => {
|
|
55
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
56
|
+
};
|
|
57
|
+
}, [handleKeyDown]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setHasNextPage(page < totalPages);
|
|
60
|
+
setHasPreviousPage(page > 1);
|
|
61
|
+
}, [page, totalPages]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setPage(initialPage);
|
|
64
|
+
setTotalPages(initialTotalPages);
|
|
65
|
+
}, [initialPage, initialTotalPages]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (onPageChange) {
|
|
68
|
+
onPageChange(page);
|
|
69
|
+
}
|
|
70
|
+
}, [page, onPageChange]);
|
|
71
|
+
const memoContextValue = useMemo(() => ({
|
|
72
|
+
page,
|
|
73
|
+
setPage,
|
|
74
|
+
totalPages,
|
|
75
|
+
hasNextPage,
|
|
76
|
+
hasPreviousPage,
|
|
77
|
+
registerRef: registerRefWrapper,
|
|
78
|
+
}), [page, totalPages, hasNextPage, hasPreviousPage, registerRefWrapper]);
|
|
79
|
+
const Component = asChild ? Slot : "nav";
|
|
80
|
+
return (_jsx(Component, { "aria-label": "Pagination", className: clsx("flex items-center gap-1", className), ...props, ref: ref, children: _jsx(PaginationContext.Provider, { value: memoContextValue, children: getTruncatedElements({ page, children }) }) }));
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Individual page item within the Pagination component.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* <PaginationItem index={1}>1</PaginationItem>
|
|
88
|
+
*/
|
|
89
|
+
const PaginationItem = forwardRef(({ index, children, className, ...props }, ref) => {
|
|
90
|
+
const { registerRef, page, setPage } = usePaginationContext();
|
|
91
|
+
const isActive = page === index;
|
|
92
|
+
const handleClick = () => {
|
|
93
|
+
if (index !== undefined) {
|
|
94
|
+
setPage(index);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return (_jsx("button", { type: "button", onClick: handleClick, ref: mergeRefs(ref, (el) => registerRef(index ?? 0, el)), className: cn("flex h-10 w-10 items-center justify-center rounded-full hover:bg-gray-200", {
|
|
98
|
+
"bg-gray-700 text-white hover:bg-gray-800": isActive,
|
|
99
|
+
}, className), "aria-current": isActive ? "page" : undefined, ...props, children: children ?? index }));
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Pagination Prev
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* Previous page button component for the Pagination.
|
|
106
|
+
* Automatically disabled when on the first page.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* <PaginationPrev>Previous</PaginationPrev>
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
const PaginationPrev = forwardRef(({ children, className, ...props }, ref) => {
|
|
114
|
+
const { registerRef, page, setPage, hasPreviousPage } = usePaginationContext();
|
|
115
|
+
return (_jsx("button", { type: "button", onClick: () => setPage(page - 1), ref: mergeRefs(ref, (el) => registerRef(0, el)), disabled: !hasPreviousPage, className: cn("flex h-10 w-10 items-center justify-center rounded-full hover:bg-gray-200 disabled:opacity-25", className), ...props, children: children }));
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Pagination Next
|
|
119
|
+
*/
|
|
120
|
+
/**
|
|
121
|
+
* Next page button component for the Pagination.
|
|
122
|
+
* Automatically disabled when on the last page.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* <PaginationNext>Next</PaginationNext>
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
const PaginationNext = forwardRef(({ children, className, ...props }, ref) => {
|
|
130
|
+
const { page, setPage, hasNextPage, registerRef, totalPages } = usePaginationContext();
|
|
131
|
+
return (_jsx("button", { type: "button", className: cn("flex h-10 w-10 items-center justify-center rounded-full hover:bg-gray-200 disabled:opacity-25", className), onClick: () => setPage(page + 1), disabled: !hasNextPage, ref: mergeRefs(ref, (el) => registerRef(totalPages + 1, el)), ...props, children: children }));
|
|
132
|
+
});
|
|
133
|
+
export { Pagination, PaginationItem, PaginationPrev, PaginationNext };
|
|
134
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../../src/components/pagination/pagination.tsx"],"names":[],"mappings":";AA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oB,EAAE,CAAC;IACxB,OAAO,CACN,iBACC,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,EAAE,CACZ,+FAA+F,EAC/F,SAAS,CACT,EACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,EAChC,QAAQ,EAAE,CAAC,WAAW,EACtB,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,KACxD,KAAK,YAER,QAAQ,GACD,CACT,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Popover as RadixPopover } from "radix-ui";
|
|
2
|
+
/**
|
|
3
|
+
* Popover
|
|
4
|
+
*/
|
|
5
|
+
export type PopoverProps = {
|
|
6
|
+
showArrow?: boolean;
|
|
7
|
+
closeButtonAriaLabel?: string;
|
|
8
|
+
showCloseButton?: boolean;
|
|
9
|
+
} & RadixPopover.PopoverProps & Pick<RadixPopover.PopoverContentProps, "side">;
|
|
10
|
+
/**
|
|
11
|
+
* Popover component that provides a popover container with a trigger and content.
|
|
12
|
+
*
|
|
13
|
+
* @param {boolean} [props.showArrow=true] - Whether to show the arrow pointing to the trigger
|
|
14
|
+
* @param {string} [props.closeButtonAriaLabel="Close"] - Aria label for the close button
|
|
15
|
+
* @param {boolean} [props.showCloseButton=true] - Whether to show the close button
|
|
16
|
+
* @param {RadixPopover.PopoverContentProps["side"]} [props.side] - The preferred side to show the popover
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Popover>
|
|
21
|
+
* <PopoverTrigger>Open Popover</PopoverTrigger>
|
|
22
|
+
* <PopoverContent>
|
|
23
|
+
* <p>Popover content goes here</p>
|
|
24
|
+
* </PopoverContent>
|
|
25
|
+
* </Popover>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare const Popover: ({ children, showArrow, closeButtonAriaLabel, showCloseButton, side, ...props }: PopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
declare const PopoverTrigger: import("react").ForwardRefExoticComponent<RadixPopover.PopoverTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
30
|
+
export type PopoverContentProps = RadixPopover.PopoverContentProps & {
|
|
31
|
+
showArrow?: boolean;
|
|
32
|
+
closeButtonAriaLabel?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Popover Content
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Popover Content component that provides the content area for the Popover.
|
|
39
|
+
* Inherits size from parent Popover component.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <PopoverContent>
|
|
44
|
+
* <p>Popover content goes here</p>
|
|
45
|
+
* </PopoverContent>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare const PopoverContent: import("react").ForwardRefExoticComponent<RadixPopover.PopoverContentProps & {
|
|
49
|
+
showArrow?: boolean;
|
|
50
|
+
closeButtonAriaLabel?: string;
|
|
51
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
52
|
+
/**
|
|
53
|
+
* Popover Close
|
|
54
|
+
*/
|
|
55
|
+
declare const PopoverClose: import("react").ForwardRefExoticComponent<RadixPopover.PopoverCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
56
|
+
/**
|
|
57
|
+
* Popover Portal
|
|
58
|
+
*/
|
|
59
|
+
declare const PopoverPortal: import("react").FC<RadixPopover.PopoverPortalProps>;
|
|
60
|
+
/**
|
|
61
|
+
* Popover Anchor
|
|
62
|
+
*/
|
|
63
|
+
declare const PopoverAnchor: import("react").ForwardRefExoticComponent<RadixPopover.PopoverAnchorProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
64
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverClose, PopoverPortal, PopoverAnchor, };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@components/icon/icon";
|
|
3
|
+
import { Cross1Icon } from "@radix-ui/react-icons";
|
|
4
|
+
import { getVariants } from "@utilities/get-variants/get-variants";
|
|
5
|
+
import { Popover as RadixPopover } from "radix-ui";
|
|
6
|
+
import { createContext, forwardRef, useContext, useMemo, } from "react";
|
|
7
|
+
/**
|
|
8
|
+
* Popover Context
|
|
9
|
+
*/
|
|
10
|
+
const PopoverContext = createContext(undefined);
|
|
11
|
+
const usePopoverContext = () => {
|
|
12
|
+
const context = useContext(PopoverContext);
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error("Popover components must be used within a Popover");
|
|
15
|
+
}
|
|
16
|
+
return context;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Popover component that provides a popover container with a trigger and content.
|
|
20
|
+
*
|
|
21
|
+
* @param {boolean} [props.showArrow=true] - Whether to show the arrow pointing to the trigger
|
|
22
|
+
* @param {string} [props.closeButtonAriaLabel="Close"] - Aria label for the close button
|
|
23
|
+
* @param {boolean} [props.showCloseButton=true] - Whether to show the close button
|
|
24
|
+
* @param {RadixPopover.PopoverContentProps["side"]} [props.side] - The preferred side to show the popover
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <Popover>
|
|
29
|
+
* <PopoverTrigger>Open Popover</PopoverTrigger>
|
|
30
|
+
* <PopoverContent>
|
|
31
|
+
* <p>Popover content goes here</p>
|
|
32
|
+
* </PopoverContent>
|
|
33
|
+
* </Popover>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
const Popover = ({ children, showArrow = true, closeButtonAriaLabel = "Close", showCloseButton = true, side, ...props }) => {
|
|
37
|
+
const contextValue = useMemo(() => ({
|
|
38
|
+
showArrow,
|
|
39
|
+
closeButtonAriaLabel,
|
|
40
|
+
side,
|
|
41
|
+
showCloseButton,
|
|
42
|
+
}), [showArrow, closeButtonAriaLabel, side, showCloseButton]);
|
|
43
|
+
return (_jsx(PopoverContext.Provider, { value: contextValue, children: _jsx(RadixPopover.Root, { ...props, children: children }) }));
|
|
44
|
+
};
|
|
45
|
+
const PopoverTrigger = RadixPopover.Trigger;
|
|
46
|
+
const popoverContentStyles = getVariants({
|
|
47
|
+
base: "relative z-50 w-fit max-w-72 rounded-md bg-gray-700 p-4 text-sm text-white shadow-md",
|
|
48
|
+
variants: {},
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Popover Content
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Popover Content component that provides the content area for the Popover.
|
|
55
|
+
* Inherits size from parent Popover component.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <PopoverContent>
|
|
60
|
+
* <p>Popover content goes here</p>
|
|
61
|
+
* </PopoverContent>
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
const PopoverContent = forwardRef(({ children, className, sideOffset = 4, ...props }, ref) => {
|
|
65
|
+
const { showArrow, closeButtonAriaLabel, side, showCloseButton } = usePopoverContext();
|
|
66
|
+
return (_jsxs(RadixPopover.Content, { className: popoverContentStyles({ className }), sideOffset: sideOffset, side: side, ...props, ref: ref, children: [showCloseButton && (_jsx(PopoverClose, { className: "absolute top-4 right-4", "aria-label": closeButtonAriaLabel, children: _jsx(Icon, { asChild: true, size: "small", children: _jsx(Cross1Icon, {}) }) })), children, showArrow && _jsx(RadixPopover.Arrow, { className: "fill-gray-700" })] }));
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Popover Close
|
|
70
|
+
*/
|
|
71
|
+
const PopoverClose = RadixPopover.Close;
|
|
72
|
+
/**
|
|
73
|
+
* Popover Portal
|
|
74
|
+
*/
|
|
75
|
+
const PopoverPortal = RadixPopover.Portal;
|
|
76
|
+
/**
|
|
77
|
+
* Popover Anchor
|
|
78
|
+
*/
|
|
79
|
+
const PopoverAnchor = RadixPopover.Anchor;
|
|
80
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverClose, PopoverPortal, PopoverAnchor, };
|
|
81
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.js","sourceRoot":"","sources":["../../../src/components/popover/popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAEN,aAAa,EACb,UAAU,EACV,UAAU,EACV,OAAO,GACP,MAAM,OAAO,CAAC;AAEf;;GAEG;AAEH,MAAM,cAAc,GAAG,aAAa,CAA2B,SAAS,CAAC,CAAC;AAE1E,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAaF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,GAAG,CAAC,EAChB,QAAQ,EACR,SAAS,GAAG,IAAI,EAChB,oBAAoB,GAAG,OAAO,EAC9B,eAAe,GAAG,IAAI,EACtB,IAAI,EACJ,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,YAAY,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC;QACN,SAAS;QACT,oBAAoB;Q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AK,CAAC;AAExC;;GAEG;AAEH,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,CAAC;AAE1C;;GAEG;AAEH,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,CAAC;AAE1C,OAAO,EACN,OAAO,EACP,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,GACb,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Progress as ProgressPrimitive } from "radix-ui";
|
|
2
|
+
import { type ComponentPropsWithoutRef } from "react";
|
|
3
|
+
export type ProgressProps = ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> & {
|
|
4
|
+
showLabel?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A progress bar component that displays a progress indicator and a label.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} props - The component props.
|
|
10
|
+
* @param {string} props.className - The class name for the component.
|
|
11
|
+
* @param {number} props.value - The value of the progress bar.
|
|
12
|
+
* @param {boolean} props.showLabel - Whether to show the label.
|
|
13
|
+
*/
|
|
14
|
+
declare const Progress: import("react").ForwardRefExoticComponent<Omit<ProgressPrimitive.ProgressProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
15
|
+
showLabel?: boolean;
|
|
16
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export { Progress };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@utilities/cn/cn";
|
|
3
|
+
import { Progress as ProgressPrimitive } from "radix-ui";
|
|
4
|
+
import { forwardRef, } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* A progress bar component that displays a progress indicator and a label.
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} props - The component props.
|
|
9
|
+
* @param {string} props.className - The class name for the component.
|
|
10
|
+
* @param {number} props.value - The value of the progress bar.
|
|
11
|
+
* @param {boolean} props.showLabel - Whether to show the label.
|
|
12
|
+
*/
|
|
13
|
+
const Progress = forwardRef(({ className, value, showLabel = true, max = 100, ...props }, ref) => (_jsxs("div", { className: "flex items-center gap-4", children: [_jsx(ProgressPrimitive.Root, { className: cn("relative h-2 w-full overflow-hidden rounded-full bg-gray-200/80", className), max: max, ...props, ref: ref, children: _jsx(ProgressPrimitive.Indicator, { className: "h-full w-full flex-1 bg-gray-700/80 transition-all", style: {
|
|
14
|
+
transform: `translateX(-${100 - ((value || 0) / max) * 100}%)`,
|
|
15
|
+
} }) }), showLabel && _jsxs("div", { className: "text-gray-500 text-sm", children: [value, "%"] })] })));
|
|
16
|
+
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
17
|
+
export { Progress };
|
|
18
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../../src/components/progress/progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAGN,UAAU,GACV,MAAM,OAAO,CAAC;AAQf;;;;;;;GAOG;AAEH,MAAM,QAAQ,GAAG,UAAU,CAGzB,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CACvE,eAAK,SAAS,EAAC,yBAAyB,aACvC,KAAC,iBAAiB,CAAC,IAAI,IACtB,SAAS,EAAE,EAAE,CACZ,iEAAiE,EACjE,SAAS,CACT,EACD,GAAG,EAAE,GAAG,KACJ,KAAK,EACT,GAAG,EAAE,GAAG,YAER,KAAC,iBAAiB,CAAC,SAAS,IAC3B,SAAS,EAAC,oDAAoD,EAC9D,KAAK,EAAE;oBACN,SAAS,EAAE,eAAe,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI;iBAC9D,GACA,GACsB,EACxB,SAAS,IAAI,eAAK,SAAS,EAAC,uBAAuB,aAAE,KAAK,SAAQ,IAC9D,CACN,CAAC,CAAC;AACH,QAAQ,CAAC,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { RadioGroup as RadixRadioGroup } from "radix-ui";
|
|
2
|
+
/**
|
|
3
|
+
* A RadioGroup component that provides a set of radio buttons where only one can be selected at a time.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <RadioGroup defaultValue="option1">
|
|
8
|
+
* <div>
|
|
9
|
+
* <RadioGroupItem value="option1" id="option1" />
|
|
10
|
+
* <label htmlFor="option1">Option 1</label>
|
|
11
|
+
* </div>
|
|
12
|
+
* <div>
|
|
13
|
+
* <RadioGroupItem value="option2" id="option2" />
|
|
14
|
+
* <label htmlFor="option2">Option 2</label>
|
|
15
|
+
* </div>
|
|
16
|
+
* </RadioGroup>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param {string} [className] - Additional CSS classes to apply to the root element
|
|
20
|
+
* @param {string} [defaultValue] - The value of the radio item that should be checked when initially rendered
|
|
21
|
+
* @param {string} [value] - The controlled value of the radio item to check
|
|
22
|
+
* @param {function} [onValueChange] - Event handler called when the value changes
|
|
23
|
+
* @param {boolean} [disabled] - When true, prevents the user from interacting with the radio group
|
|
24
|
+
* @param {boolean} [required] - When true, indicates that the user must select a value before the owning form can be submitted
|
|
25
|
+
* @param {string} [name] - The name of the group. Submitted with its owning form as part of a name/value pair
|
|
26
|
+
* @param {string} [dir] - The reading direction of the radio group
|
|
27
|
+
* @param {string} [orientation] - The orientation of the radio group
|
|
28
|
+
* @param {boolean} [loop] - When true, keyboard navigation will loop from last item to first, and vice versa
|
|
29
|
+
* @returns {React.ForwardRefExoticComponent} A React component that renders a radio group
|
|
30
|
+
*/
|
|
31
|
+
declare const RadioGroup: import("react").ForwardRefExoticComponent<Omit<RadixRadioGroup.RadioGroupProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
|
+
declare const RadioGroupItem: import("react").ForwardRefExoticComponent<Omit<RadixRadioGroup.RadioGroupItemProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@utilities/cn/cn";
|
|
3
|
+
import { RadioGroup as RadixRadioGroup } from "radix-ui";
|
|
4
|
+
import { forwardRef, } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* A RadioGroup component that provides a set of radio buttons where only one can be selected at a time.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <RadioGroup defaultValue="option1">
|
|
11
|
+
* <div>
|
|
12
|
+
* <RadioGroupItem value="option1" id="option1" />
|
|
13
|
+
* <label htmlFor="option1">Option 1</label>
|
|
14
|
+
* </div>
|
|
15
|
+
* <div>
|
|
16
|
+
* <RadioGroupItem value="option2" id="option2" />
|
|
17
|
+
* <label htmlFor="option2">Option 2</label>
|
|
18
|
+
* </div>
|
|
19
|
+
* </RadioGroup>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param {string} [className] - Additional CSS classes to apply to the root element
|
|
23
|
+
* @param {string} [defaultValue] - The value of the radio item that should be checked when initially rendered
|
|
24
|
+
* @param {string} [value] - The controlled value of the radio item to check
|
|
25
|
+
* @param {function} [onValueChange] - Event handler called when the value changes
|
|
26
|
+
* @param {boolean} [disabled] - When true, prevents the user from interacting with the radio group
|
|
27
|
+
* @param {boolean} [required] - When true, indicates that the user must select a value before the owning form can be submitted
|
|
28
|
+
* @param {string} [name] - The name of the group. Submitted with its owning form as part of a name/value pair
|
|
29
|
+
* @param {string} [dir] - The reading direction of the radio group
|
|
30
|
+
* @param {string} [orientation] - The orientation of the radio group
|
|
31
|
+
* @param {boolean} [loop] - When true, keyboard navigation will loop from last item to first, and vice versa
|
|
32
|
+
* @returns {React.ForwardRefExoticComponent} A React component that renders a radio group
|
|
33
|
+
*/
|
|
34
|
+
const RadioGroup = forwardRef(({ className, ...props }, ref) => (_jsx(RadixRadioGroup.Root, { ref: ref, className: cn("flex flex-col gap-2", className), ...props })));
|
|
35
|
+
const RadioGroupItem = forwardRef(({ className, ...props }, ref) => (_jsx(RadixRadioGroup.Item, { ref: ref, className: cn("flex h-4 w-4 items-center justify-center rounded-full border border-gray-700 bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-700 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50", className), ...props, children: _jsx(RadixRadioGroup.Indicator, { className: "relative h-2 w-2 rounded-full bg-gray-500" }) })));
|
|
36
|
+
export { RadioGroup, RadioGroupItem };
|
|
37
|
+
//# sourceMappingURL=radio-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../../src/components/radio-group/radio-group.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAGN,UAAU,GACV,MAAM,OAAO,CAAC;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,GAAG,UAAU,CAG3B,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CACnC,KAAC,eAAe,CAAC,IAAI,IACpB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,KAC3C,KAAK,GACR,CACF,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,UAAU,CAG/B,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CACnC,KAAC,eAAe,CAAC,IAAI,IACpB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACZ,iOAAiO,EACjO,SAAS,CACT,KACG,KAAK,YAET,KAAC,eAAe,CAAC,SAAS,IAAC,SAAS,EAAC,2CAA2C,GAAG,GAC7D,CACvB,CAAC,CAAC;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Select as SelectPrimitive } from "radix-ui";
|
|
2
|
+
/**
|
|
3
|
+
* Select
|
|
4
|
+
*/
|
|
5
|
+
declare const Select: import("react").FC<SelectPrimitive.SelectProps>;
|
|
6
|
+
/**
|
|
7
|
+
* SelectGroup
|
|
8
|
+
*/
|
|
9
|
+
declare const SelectGroup: import("react").ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
10
|
+
/**
|
|
11
|
+
* SelectValue
|
|
12
|
+
*/
|
|
13
|
+
declare const SelectValue: import("react").ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
14
|
+
/**
|
|
15
|
+
* SelectTrigger
|
|
16
|
+
*/
|
|
17
|
+
declare const SelectTrigger: import("react").ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
/**
|
|
19
|
+
* SelectScrollUpButton
|
|
20
|
+
*/
|
|
21
|
+
declare const SelectScrollUpButton: import("react").ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
|
+
/**
|
|
23
|
+
* SelectScrollDownButton
|
|
24
|
+
*/
|
|
25
|
+
declare const SelectScrollDownButton: import("react").ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
26
|
+
/**
|
|
27
|
+
* SelectContent
|
|
28
|
+
*/
|
|
29
|
+
declare const SelectContent: import("react").ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
|
+
/**
|
|
31
|
+
* SelectLabel
|
|
32
|
+
*/
|
|
33
|
+
declare const SelectLabel: import("react").ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
|
+
/**
|
|
35
|
+
* SelectItem
|
|
36
|
+
*/
|
|
37
|
+
declare const SelectItem: import("react").ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
38
|
+
/**
|
|
39
|
+
* SelectSeparator
|
|
40
|
+
*/
|
|
41
|
+
declare const SelectSeparator: import("react").ForwardRefExoticComponent<Omit<SelectPrimitive.SelectSeparatorProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
42
|
+
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Select as SelectPrimitive } from "radix-ui";
|
|
3
|
+
import { Icon } from "@components/icon/icon";
|
|
4
|
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon, } from "@radix-ui/react-icons";
|
|
5
|
+
import { cn } from "@utilities/cn/cn";
|
|
6
|
+
import { forwardRef, } from "react";
|
|
7
|
+
/**
|
|
8
|
+
* Select
|
|
9
|
+
*/
|
|
10
|
+
const Select = SelectPrimitive.Root;
|
|
11
|
+
/**
|
|
12
|
+
* SelectGroup
|
|
13
|
+
*/
|
|
14
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
15
|
+
/**
|
|
16
|
+
* SelectValue
|
|
17
|
+
*/
|
|
18
|
+
const SelectValue = SelectPrimitive.Value;
|
|
19
|
+
/**
|
|
20
|
+
* SelectTrigger
|
|
21
|
+
*/
|
|
22
|
+
const SelectTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-gray-400 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-gray-500 [&>span]:line-clamp-1", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(Icon, { asChild: true, size: "small", className: "opacity-50", children: _jsx(ChevronDownIcon, {}) }) })] })));
|
|
23
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
24
|
+
/**
|
|
25
|
+
* SelectScrollUpButton
|
|
26
|
+
*/
|
|
27
|
+
const SelectScrollUpButton = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(Icon, { asChild: true, size: "small", className: "opacity-50", children: _jsx(ChevronUpIcon, {}) }) })));
|
|
28
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
29
|
+
/**
|
|
30
|
+
* SelectScrollDownButton
|
|
31
|
+
*/
|
|
32
|
+
const SelectScrollDownButton = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(Icon, { asChild: true, size: "small", className: "opacity-50", children: _jsx(ChevronDownIcon, {}) }) })));
|
|
33
|
+
SelectScrollDownButton.displayName =
|
|
34
|
+
SelectPrimitive.ScrollDownButton.displayName;
|
|
35
|
+
/**
|
|
36
|
+
* SelectContent
|
|
37
|
+
*/
|
|
38
|
+
const SelectContent = forwardRef(({ className, children, position = "popper", ...props }, ref) => (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, className: cn("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md border border-gray-400 bg-white text-gray-700 shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in", position === "popper" &&
|
|
39
|
+
"data-[side=left]:-translate-x-1 data-[side=top]:-translate-y-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1", className), position: position, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: cn("p-1", position === "popper" &&
|
|
40
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: children }), _jsx(SelectScrollDownButton, {})] }) })));
|
|
41
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
42
|
+
/**
|
|
43
|
+
* SelectLabel
|
|
44
|
+
*/
|
|
45
|
+
const SelectLabel = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Label, { ref: ref, className: cn("px-2 py-1.5 font-semibold text-sm", className), ...props })));
|
|
46
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
47
|
+
/**
|
|
48
|
+
* SelectItem
|
|
49
|
+
*/
|
|
50
|
+
const SelectItem = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, className: cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none focus-visible:bg-gray-700 focus-visible:text-white data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props, children: [_jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Icon, { asChild: true, size: "small", children: _jsx(CheckIcon, {}) }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
|
|
51
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
52
|
+
/**
|
|
53
|
+
* SelectSeparator
|
|
54
|
+
*/
|
|
55
|
+
const SelectSeparator = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn("my-2 h-px bg-gray-200", className), ...props })));
|
|
56
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
57
|
+
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
|
|
58
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/components/select/select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EACN,SAAS,EACT,eAAe,EACf,aAAa,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EA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AAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skeleton
|
|
3
|
+
*/
|
|
4
|
+
declare const Skeleton: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export { Skeleton };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@utilities/cn/cn";
|
|
3
|
+
import { forwardRef, } from "react";
|
|
4
|
+
/**
|
|
5
|
+
* Skeleton
|
|
6
|
+
*/
|
|
7
|
+
const Skeleton = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("animate-pulse rounded-md bg-gray-200", className), ...props })));
|
|
8
|
+
Skeleton.displayName = "Skeleton";
|
|
9
|
+
export { Skeleton };
|
|
10
|
+
//# sourceMappingURL=skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.js","sourceRoot":"","sources":["../../../src/components/skeleton/skeleton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAGN,UAAU,GACV,MAAM,OAAO,CAAC;AAEf;;GAEG;AAEH,MAAM,QAAQ,GAAG,UAAU,CAGzB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CACnC,cACC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,sCAAsC,EAAE,SAAS,CAAC,KAC5D,KAAK,GACR,CACF,CAAC,CAAC;AACH,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Slider as RadixSlider } from "radix-ui";
|
|
2
|
+
import { type ComponentPropsWithoutRef } from "react";
|
|
3
|
+
export type SliderProps = ComponentPropsWithoutRef<typeof RadixSlider.Root> & {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to show the minimum and maximum values below the slider
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
showMinMax?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A customizable slider component built on top of Radix UI's slider primitive.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Slider
|
|
16
|
+
* min={0}
|
|
17
|
+
* max={100}
|
|
18
|
+
* defaultValue={[50]}
|
|
19
|
+
* showMinMax={true}
|
|
20
|
+
* />
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} props - The props for the Slider component
|
|
24
|
+
* @param {number[]} [props.defaultValue] - The initial value of the slider
|
|
25
|
+
* @param {number} [props.min=0] - The minimum value of the slider
|
|
26
|
+
* @param {number} [props.max=100] - The maximum value of the slider
|
|
27
|
+
* @param {boolean} [props.showMinMax=true] - Whether to show min/max values below the slider
|
|
28
|
+
* @param {string} [props.className] - Additional CSS classes to apply to the slider
|
|
29
|
+
* @param {React.Ref<ComponentRef<typeof RadixSlider.Root>>} ref - Forwarded ref for the slider root element
|
|
30
|
+
* @returns {JSX.Element} A slider component with optional tooltips and min/max display
|
|
31
|
+
*/
|
|
32
|
+
declare const Slider: import("react").ForwardRefExoticComponent<Omit<RadixSlider.SliderProps & import("react").RefAttributes<HTMLSpanElement>, "ref"> & {
|
|
33
|
+
/**
|
|
34
|
+
* Whether to show the minimum and maximum values below the slider
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
showMinMax?: boolean;
|
|
38
|
+
} & import("react").RefAttributes<HTMLSpanElement>>;
|
|
39
|
+
export { Slider };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Slider as RadixSlider } from "radix-ui";
|
|
3
|
+
import { forwardRef, useState, } from "react";
|
|
4
|
+
import { Tooltip, TooltipContent, TooltipTrigger, } from "@components/tooltip/tooltip";
|
|
5
|
+
import { cn } from "@utilities/cn/cn";
|
|
6
|
+
/**
|
|
7
|
+
* A customizable slider component built on top of Radix UI's slider primitive.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <Slider
|
|
12
|
+
* min={0}
|
|
13
|
+
* max={100}
|
|
14
|
+
* defaultValue={[50]}
|
|
15
|
+
* showMinMax={true}
|
|
16
|
+
* />
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} props - The props for the Slider component
|
|
20
|
+
* @param {number[]} [props.defaultValue] - The initial value of the slider
|
|
21
|
+
* @param {number} [props.min=0] - The minimum value of the slider
|
|
22
|
+
* @param {number} [props.max=100] - The maximum value of the slider
|
|
23
|
+
* @param {boolean} [props.showMinMax=true] - Whether to show min/max values below the slider
|
|
24
|
+
* @param {string} [props.className] - Additional CSS classes to apply to the slider
|
|
25
|
+
* @param {React.Ref<ComponentRef<typeof RadixSlider.Root>>} ref - Forwarded ref for the slider root element
|
|
26
|
+
* @returns {JSX.Element} A slider component with optional tooltips and min/max display
|
|
27
|
+
*/
|
|
28
|
+
const Slider = forwardRef(({ className, defaultValue, min, max, showMinMax = true, ...props }, ref) => {
|
|
29
|
+
const [value, setValue] = useState(defaultValue ?? []);
|
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsxs(RadixSlider.Root, { ref: ref, value: value, onValueChange: setValue, className: cn("relative flex w-full touch-none select-none items-center", className), ...props, children: [_jsx(RadixSlider.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-gray-700/20 data-[disabled]:opacity-50", children: _jsx(RadixSlider.Range, { className: "absolute h-full bg-gray-700" }) }), value.map((thumbValue, index) => (
|
|
31
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: <only index is available>
|
|
32
|
+
_jsxs(Tooltip, { delayDuration: 0, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(RadixSlider.Thumb, { className: "block h-4 w-4 rounded-full border border-gray-700 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-700 data-[disabled]:pointer-events-none" }) }), _jsx(TooltipContent, { children: _jsx("p", { children: thumbValue }) })] }, index)))] }), showMinMax && (_jsxs("div", { className: "mt-2 flex w-full flex-row justify-between", children: [_jsx("p", { children: min }), _jsx("p", { children: max })] }))] }));
|
|
33
|
+
});
|
|
34
|
+
Slider.displayName = RadixSlider.Root.displayName;
|
|
35
|
+
export { Slider };
|
|
36
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../src/components/slider/slider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAGN,UAAU,EACV,QAAQ,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,EACN,OAAO,EACP,cAAc,EACd,cAAc,GACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAUtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,GAAG,UAAU,CACxB,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC3E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAW,YAAY,IAAI,EAAE,CAAC,CAAC;IAEjE,OAAO,CACN,8BACC,MAAC,WAAW,CAAC,IAAI,IAChB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,QAAQ,EACvB,SA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