kaze-design-system 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 +143 -0
- package/components.css +3738 -0
- package/dist/components/Alert/Alert.js +25 -0
- package/dist/components/Avatar/Avatar.js +23 -0
- package/dist/components/Badge/Badge.js +29 -0
- package/dist/components/BarChart/BarChart.js +29 -0
- package/dist/components/BarList/BarList.js +51 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +12 -0
- package/dist/components/Button/Button.js +38 -0
- package/dist/components/CTABanner/CTABanner.js +16 -0
- package/dist/components/Card/Card.js +59 -0
- package/dist/components/Checkbox/Checkbox.js +26 -0
- package/dist/components/CommandPalette/CommandPalette.js +202 -0
- package/dist/components/DescriptionList/DescriptionList.js +29 -0
- package/dist/components/Dialog/Dialog.js +131 -0
- package/dist/components/Divider/Divider.js +30 -0
- package/dist/components/DonutChart/DonutChart.js +88 -0
- package/dist/components/Dropdown/Dropdown.js +253 -0
- package/dist/components/EmptyState/EmptyState.js +15 -0
- package/dist/components/FAB/FAB.js +40 -0
- package/dist/components/FAQ/FAQ.js +64 -0
- package/dist/components/FeatureGrid/FeatureGrid.js +35 -0
- package/dist/components/FormField/FormField.js +53 -0
- package/dist/components/Grid/Grid.js +52 -0
- package/dist/components/Heading/Heading.js +29 -0
- package/dist/components/Hero/Hero.js +40 -0
- package/dist/components/Icon/Icon.js +30 -0
- package/dist/components/Input/Input.js +20 -0
- package/dist/components/LPFooter/LPFooter.js +36 -0
- package/dist/components/Layout/Layout.js +18 -0
- package/dist/components/List/List.js +60 -0
- package/dist/components/Logo/Logo.js +70 -0
- package/dist/components/Meter/Meter.js +83 -0
- package/dist/components/Metric/Metric.js +31 -0
- package/dist/components/Navbar/Navbar.js +56 -0
- package/dist/components/NumberField/NumberField.js +173 -0
- package/dist/components/Pagination/Pagination.js +79 -0
- package/dist/components/Pricing/Pricing.js +78 -0
- package/dist/components/Progress/Progress.js +54 -0
- package/dist/components/Radio/Radio.js +60 -0
- package/dist/components/Search/Search.js +61 -0
- package/dist/components/Section/Section.js +43 -0
- package/dist/components/Select/Select.js +21 -0
- package/dist/components/Sidebar/Sidebar.js +44 -0
- package/dist/components/Skeleton/Skeleton.js +19 -0
- package/dist/components/Sparkline/Sparkline.js +47 -0
- package/dist/components/SplitSection/SplitSection.js +30 -0
- package/dist/components/Stats/Stats.js +22 -0
- package/dist/components/Stepper/Stepper.js +48 -0
- package/dist/components/Switch/Switch.js +28 -0
- package/dist/components/Table/Table.js +54 -0
- package/dist/components/Tabs/Tabs.js +119 -0
- package/dist/components/Testimonial/Testimonial.js +34 -0
- package/dist/components/Text/Text.js +37 -0
- package/dist/components/Textarea/Textarea.js +20 -0
- package/dist/components/Timeline/Timeline.js +28 -0
- package/dist/components/Toast/Toast.js +161 -0
- package/dist/components/Tooltip/Tooltip.js +131 -0
- package/dist/components/TopBar/TopBar.js +23 -0
- package/dist/components/Tracker/Tracker.js +29 -0
- package/dist/components/Watermark/Watermark.js +80 -0
- package/dist/hooks/useFocusTrap.js +58 -0
- package/dist/hooks/useTheme.js +84 -0
- package/dist/hooks.js +8 -0
- package/dist/index.js +159 -0
- package/dist/lib/chartColors.js +11 -0
- package/dist/lib/utils.js +6 -0
- package/dist/tokens.js +73 -0
- package/dist/types/components/Alert/Alert.d.ts +9 -0
- package/dist/types/components/Alert/index.d.ts +2 -0
- package/dist/types/components/Avatar/Avatar.d.ts +9 -0
- package/dist/types/components/Avatar/index.d.ts +2 -0
- package/dist/types/components/Badge/Badge.d.ts +11 -0
- package/dist/types/components/Badge/index.d.ts +2 -0
- package/dist/types/components/BarChart/BarChart.d.ts +14 -0
- package/dist/types/components/BarChart/index.d.ts +2 -0
- package/dist/types/components/BarList/BarList.d.ts +24 -0
- package/dist/types/components/BarList/index.d.ts +2 -0
- package/dist/types/components/Breadcrumb/Breadcrumb.d.ts +13 -0
- package/dist/types/components/Breadcrumb/index.d.ts +2 -0
- package/dist/types/components/Button/Button.d.ts +10 -0
- package/dist/types/components/Button/index.d.ts +2 -0
- package/dist/types/components/CTABanner/CTABanner.d.ts +6 -0
- package/dist/types/components/CTABanner/index.d.ts +2 -0
- package/dist/types/components/Card/Card.d.ts +21 -0
- package/dist/types/components/Card/index.d.ts +2 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +5 -0
- package/dist/types/components/Checkbox/index.d.ts +2 -0
- package/dist/types/components/CommandPalette/CommandPalette.d.ts +21 -0
- package/dist/types/components/CommandPalette/index.d.ts +2 -0
- package/dist/types/components/DescriptionList/DescriptionList.d.ts +12 -0
- package/dist/types/components/DescriptionList/index.d.ts +2 -0
- package/dist/types/components/Dialog/Dialog.d.ts +20 -0
- package/dist/types/components/Dialog/index.d.ts +2 -0
- package/dist/types/components/Divider/Divider.d.ts +6 -0
- package/dist/types/components/Divider/index.d.ts +2 -0
- package/dist/types/components/DonutChart/DonutChart.d.ts +16 -0
- package/dist/types/components/DonutChart/index.d.ts +2 -0
- package/dist/types/components/Dropdown/Dropdown.d.ts +24 -0
- package/dist/types/components/Dropdown/index.d.ts +2 -0
- package/dist/types/components/EmptyState/EmptyState.d.ts +8 -0
- package/dist/types/components/EmptyState/index.d.ts +2 -0
- package/dist/types/components/FAB/FAB.d.ts +14 -0
- package/dist/types/components/FAB/index.d.ts +2 -0
- package/dist/types/components/FAQ/FAQ.d.ts +9 -0
- package/dist/types/components/FAQ/index.d.ts +2 -0
- package/dist/types/components/FeatureGrid/FeatureGrid.d.ts +12 -0
- package/dist/types/components/FeatureGrid/index.d.ts +2 -0
- package/dist/types/components/FormField/FormField.d.ts +18 -0
- package/dist/types/components/FormField/index.d.ts +2 -0
- package/dist/types/components/Grid/Grid.d.ts +21 -0
- package/dist/types/components/Grid/index.d.ts +2 -0
- package/dist/types/components/Heading/Heading.d.ts +10 -0
- package/dist/types/components/Heading/index.d.ts +2 -0
- package/dist/types/components/Hero/Hero.d.ts +13 -0
- package/dist/types/components/Hero/index.d.ts +2 -0
- package/dist/types/components/Icon/Icon.d.ts +12 -0
- package/dist/types/components/Icon/index.d.ts +2 -0
- package/dist/types/components/Input/Input.d.ts +7 -0
- package/dist/types/components/Input/index.d.ts +2 -0
- package/dist/types/components/LPFooter/LPFooter.d.ts +16 -0
- package/dist/types/components/LPFooter/index.d.ts +2 -0
- package/dist/types/components/Layout/Layout.d.ts +7 -0
- package/dist/types/components/Layout/index.d.ts +2 -0
- package/dist/types/components/List/List.d.ts +18 -0
- package/dist/types/components/List/index.d.ts +2 -0
- package/dist/types/components/Logo/Logo.d.ts +6 -0
- package/dist/types/components/Logo/index.d.ts +2 -0
- package/dist/types/components/Meter/Meter.d.ts +23 -0
- package/dist/types/components/Meter/index.d.ts +2 -0
- package/dist/types/components/Metric/Metric.d.ts +12 -0
- package/dist/types/components/Metric/index.d.ts +2 -0
- package/dist/types/components/Navbar/Navbar.d.ts +16 -0
- package/dist/types/components/Navbar/index.d.ts +2 -0
- package/dist/types/components/NumberField/NumberField.d.ts +35 -0
- package/dist/types/components/NumberField/index.d.ts +2 -0
- package/dist/types/components/Pagination/Pagination.d.ts +14 -0
- package/dist/types/components/Pagination/index.d.ts +2 -0
- package/dist/types/components/Pricing/Pricing.d.ts +14 -0
- package/dist/types/components/Pricing/index.d.ts +2 -0
- package/dist/types/components/Progress/Progress.d.ts +12 -0
- package/dist/types/components/Progress/index.d.ts +2 -0
- package/dist/types/components/Radio/Radio.d.ts +13 -0
- package/dist/types/components/Radio/index.d.ts +2 -0
- package/dist/types/components/Search/Search.d.ts +13 -0
- package/dist/types/components/Search/index.d.ts +2 -0
- package/dist/types/components/Section/Section.d.ts +13 -0
- package/dist/types/components/Section/index.d.ts +2 -0
- package/dist/types/components/Select/Select.d.ts +5 -0
- package/dist/types/components/Select/index.d.ts +2 -0
- package/dist/types/components/Sidebar/Sidebar.d.ts +17 -0
- package/dist/types/components/Sidebar/index.d.ts +2 -0
- package/dist/types/components/Skeleton/Skeleton.d.ts +7 -0
- package/dist/types/components/Skeleton/index.d.ts +2 -0
- package/dist/types/components/Sparkline/Sparkline.d.ts +9 -0
- package/dist/types/components/Sparkline/index.d.ts +2 -0
- package/dist/types/components/SplitSection/SplitSection.d.ts +10 -0
- package/dist/types/components/SplitSection/index.d.ts +2 -0
- package/dist/types/components/Stats/Stats.d.ts +9 -0
- package/dist/types/components/Stats/index.d.ts +2 -0
- package/dist/types/components/Stepper/Stepper.d.ts +9 -0
- package/dist/types/components/Stepper/index.d.ts +2 -0
- package/dist/types/components/Switch/Switch.d.ts +5 -0
- package/dist/types/components/Switch/index.d.ts +2 -0
- package/dist/types/components/Table/Table.d.ts +20 -0
- package/dist/types/components/Table/index.d.ts +2 -0
- package/dist/types/components/Tabs/Tabs.d.ts +39 -0
- package/dist/types/components/Tabs/index.d.ts +2 -0
- package/dist/types/components/Testimonial/Testimonial.d.ts +13 -0
- package/dist/types/components/Testimonial/index.d.ts +2 -0
- package/dist/types/components/Text/Text.d.ts +16 -0
- package/dist/types/components/Text/index.d.ts +2 -0
- package/dist/types/components/Textarea/Textarea.d.ts +5 -0
- package/dist/types/components/Textarea/index.d.ts +2 -0
- package/dist/types/components/Timeline/Timeline.d.ts +13 -0
- package/dist/types/components/Timeline/index.d.ts +2 -0
- package/dist/types/components/Toast/Toast.d.ts +31 -0
- package/dist/types/components/Toast/index.d.ts +2 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +13 -0
- package/dist/types/components/Tooltip/index.d.ts +2 -0
- package/dist/types/components/TopBar/TopBar.d.ts +6 -0
- package/dist/types/components/TopBar/index.d.ts +2 -0
- package/dist/types/components/Tracker/Tracker.d.ts +15 -0
- package/dist/types/components/Tracker/index.d.ts +2 -0
- package/dist/types/components/Watermark/Watermark.d.ts +17 -0
- package/dist/types/components/Watermark/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +120 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/hooks/useFocusTrap.d.ts +8 -0
- package/dist/types/hooks/useTheme.d.ts +14 -0
- package/dist/types/lib/chartColors.d.ts +2 -0
- package/dist/types/lib/types.d.ts +1 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/tokens/tokens.d.ts +72 -0
- package/dist/types/utils/scrollLock.d.ts +13 -0
- package/dist/utils/scrollLock.js +22 -0
- package/kaze.css +20 -0
- package/package.json +109 -0
- package/reset.css +169 -0
- package/tokens.css +400 -0
- package/utilities.css +506 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const Divider = forwardRef(
|
|
5
|
+
({ text, subtle, className, ...rest }, ref) => {
|
|
6
|
+
if (text) {
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
ref,
|
|
11
|
+
className: cn("divider-text", className),
|
|
12
|
+
...rest,
|
|
13
|
+
children: text
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
"hr",
|
|
19
|
+
{
|
|
20
|
+
ref,
|
|
21
|
+
className: cn("divider", subtle && "divider--subtle", className),
|
|
22
|
+
...rest
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
Divider.displayName = "Divider";
|
|
28
|
+
export {
|
|
29
|
+
Divider
|
|
30
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
import { CHART_COLORS } from "../../lib/chartColors.js";
|
|
5
|
+
const DonutChart = forwardRef(
|
|
6
|
+
({
|
|
7
|
+
data,
|
|
8
|
+
size = 120,
|
|
9
|
+
strokeWidth = 16,
|
|
10
|
+
centerLabel,
|
|
11
|
+
showLegend = true,
|
|
12
|
+
"aria-label": ariaLabel,
|
|
13
|
+
className,
|
|
14
|
+
...rest
|
|
15
|
+
}, ref) => {
|
|
16
|
+
const total = data.reduce((sum, d) => sum + d.value, 0);
|
|
17
|
+
const radius = (size - strokeWidth) / 2;
|
|
18
|
+
const circumference = 2 * Math.PI * radius;
|
|
19
|
+
const center = size / 2;
|
|
20
|
+
let offset = 0;
|
|
21
|
+
const segments = data.map((d, i) => {
|
|
22
|
+
const pct = total > 0 ? d.value / total : 0;
|
|
23
|
+
const dashLength = circumference * pct;
|
|
24
|
+
const dashOffset = -offset;
|
|
25
|
+
offset += dashLength;
|
|
26
|
+
return {
|
|
27
|
+
...d,
|
|
28
|
+
color: d.color ?? CHART_COLORS[i % CHART_COLORS.length],
|
|
29
|
+
dashLength,
|
|
30
|
+
dashOffset
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsxs("div", { ref, role: "img", "aria-label": ariaLabel, className: cn("donut-chart", className), ...rest, children: [
|
|
34
|
+
/* @__PURE__ */ jsxs(
|
|
35
|
+
"svg",
|
|
36
|
+
{
|
|
37
|
+
className: "donut-chart__svg",
|
|
38
|
+
width: size,
|
|
39
|
+
height: size,
|
|
40
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
"circle",
|
|
45
|
+
{
|
|
46
|
+
className: "donut-chart__track",
|
|
47
|
+
cx: center,
|
|
48
|
+
cy: center,
|
|
49
|
+
r: radius,
|
|
50
|
+
strokeWidth
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
segments.map((seg) => /* @__PURE__ */ jsx(
|
|
54
|
+
"circle",
|
|
55
|
+
{
|
|
56
|
+
className: "donut-chart__segment",
|
|
57
|
+
cx: center,
|
|
58
|
+
cy: center,
|
|
59
|
+
r: radius,
|
|
60
|
+
strokeWidth,
|
|
61
|
+
stroke: seg.color,
|
|
62
|
+
strokeDasharray: `${seg.dashLength} ${circumference - seg.dashLength}`,
|
|
63
|
+
strokeDashoffset: seg.dashOffset
|
|
64
|
+
},
|
|
65
|
+
seg.label
|
|
66
|
+
)),
|
|
67
|
+
centerLabel && /* @__PURE__ */ jsx("text", { className: "donut-chart__center-label", x: center, y: center, children: centerLabel })
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
showLegend && /* @__PURE__ */ jsx("div", { className: "donut-chart__legend", children: segments.map((seg) => /* @__PURE__ */ jsxs("span", { className: "donut-chart__legend-item", children: [
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
"span",
|
|
74
|
+
{
|
|
75
|
+
className: "donut-chart__legend-dot",
|
|
76
|
+
style: { background: seg.color }
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsx("span", { className: "donut-chart__legend-label", children: seg.label }),
|
|
80
|
+
/* @__PURE__ */ jsx("span", { className: "donut-chart__legend-value", children: seg.value })
|
|
81
|
+
] }, seg.label)) })
|
|
82
|
+
] });
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
DonutChart.displayName = "DonutChart";
|
|
86
|
+
export {
|
|
87
|
+
DonutChart
|
|
88
|
+
};
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useState, useRef, useCallback, useEffect, createContext, useContext } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
const DropdownContext = createContext(null);
|
|
7
|
+
function useDropdownContext() {
|
|
8
|
+
const context = useContext(DropdownContext);
|
|
9
|
+
if (!context) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
"Dropdown compound components must be used within a <Dropdown>"
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
16
|
+
const Dropdown = forwardRef(
|
|
17
|
+
({ children, open: controlledOpen, onOpenChange }, ref) => {
|
|
18
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
19
|
+
const isControlled = controlledOpen !== void 0;
|
|
20
|
+
const open = isControlled ? controlledOpen : internalOpen;
|
|
21
|
+
const triggerRef = useRef(null);
|
|
22
|
+
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
23
|
+
const itemCountRef = useRef(0);
|
|
24
|
+
const setOpen = useCallback(
|
|
25
|
+
(value) => {
|
|
26
|
+
if (!isControlled) {
|
|
27
|
+
setInternalOpen(value);
|
|
28
|
+
}
|
|
29
|
+
onOpenChange?.(value);
|
|
30
|
+
if (!value) {
|
|
31
|
+
setHighlightedIndex(-1);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
[isControlled, onOpenChange]
|
|
35
|
+
);
|
|
36
|
+
const registerItem = useCallback(() => {
|
|
37
|
+
return itemCountRef.current++;
|
|
38
|
+
}, []);
|
|
39
|
+
const resetItems = useCallback(() => {
|
|
40
|
+
itemCountRef.current = 0;
|
|
41
|
+
}, []);
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
DropdownContext.Provider,
|
|
44
|
+
{
|
|
45
|
+
value: {
|
|
46
|
+
open,
|
|
47
|
+
setOpen,
|
|
48
|
+
triggerRef,
|
|
49
|
+
highlightedIndex,
|
|
50
|
+
setHighlightedIndex,
|
|
51
|
+
itemCount: itemCountRef.current,
|
|
52
|
+
registerItem,
|
|
53
|
+
resetItems
|
|
54
|
+
},
|
|
55
|
+
children: /* @__PURE__ */ jsx("div", { ref, style: { display: "contents" }, children })
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
Dropdown.displayName = "Dropdown";
|
|
61
|
+
const DropdownTrigger = forwardRef(
|
|
62
|
+
({ children }, ref) => {
|
|
63
|
+
const { open, setOpen, triggerRef } = useDropdownContext();
|
|
64
|
+
const handleClick = useCallback(() => {
|
|
65
|
+
setOpen(!open);
|
|
66
|
+
}, [open, setOpen]);
|
|
67
|
+
const handleKeyDown = useCallback(
|
|
68
|
+
(e) => {
|
|
69
|
+
if (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
setOpen(true);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[setOpen]
|
|
75
|
+
);
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
"span",
|
|
78
|
+
{
|
|
79
|
+
ref: (node) => {
|
|
80
|
+
triggerRef.current = node;
|
|
81
|
+
if (typeof ref === "function") ref(node);
|
|
82
|
+
else if (ref) ref.current = node;
|
|
83
|
+
},
|
|
84
|
+
role: "button",
|
|
85
|
+
tabIndex: 0,
|
|
86
|
+
"aria-expanded": open ? "true" : "false",
|
|
87
|
+
"aria-haspopup": "menu",
|
|
88
|
+
onClick: handleClick,
|
|
89
|
+
onKeyDown: handleKeyDown,
|
|
90
|
+
style: { display: "inline-flex" },
|
|
91
|
+
children
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
DropdownTrigger.displayName = "DropdownTrigger";
|
|
97
|
+
const DropdownMenu = forwardRef(
|
|
98
|
+
({ children, className, ...rest }, ref) => {
|
|
99
|
+
const {
|
|
100
|
+
open,
|
|
101
|
+
setOpen,
|
|
102
|
+
triggerRef,
|
|
103
|
+
highlightedIndex,
|
|
104
|
+
setHighlightedIndex,
|
|
105
|
+
resetItems
|
|
106
|
+
} = useDropdownContext();
|
|
107
|
+
const menuRef = useRef(null);
|
|
108
|
+
const [position, setPosition] = useState({
|
|
109
|
+
top: 0,
|
|
110
|
+
left: 0
|
|
111
|
+
});
|
|
112
|
+
const itemsRef = useRef([]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (open) {
|
|
115
|
+
resetItems();
|
|
116
|
+
itemsRef.current = [];
|
|
117
|
+
}
|
|
118
|
+
}, [open, resetItems]);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (!open || !triggerRef.current) return;
|
|
121
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
122
|
+
setPosition({
|
|
123
|
+
top: rect.bottom + 4 + window.scrollY,
|
|
124
|
+
left: rect.left + window.scrollX
|
|
125
|
+
});
|
|
126
|
+
}, [open, triggerRef]);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (open && menuRef.current) {
|
|
129
|
+
menuRef.current.focus();
|
|
130
|
+
}
|
|
131
|
+
}, [open]);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (!open) return;
|
|
134
|
+
const handleClickOutside = (e) => {
|
|
135
|
+
if (menuRef.current && !menuRef.current.contains(e.target) && triggerRef.current && !triggerRef.current.contains(e.target)) {
|
|
136
|
+
setOpen(false);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
140
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
141
|
+
}, [open, setOpen, triggerRef]);
|
|
142
|
+
const handleKeyDown = useCallback(
|
|
143
|
+
(e) => {
|
|
144
|
+
const items = menuRef.current?.querySelectorAll(
|
|
145
|
+
`[data-dropdown-item]:not([data-disabled="true"])`
|
|
146
|
+
);
|
|
147
|
+
if (!items || items.length === 0) return;
|
|
148
|
+
const count = items.length;
|
|
149
|
+
switch (e.key) {
|
|
150
|
+
case "ArrowDown": {
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
const next = highlightedIndex < count - 1 ? highlightedIndex + 1 : 0;
|
|
153
|
+
setHighlightedIndex(next);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case "ArrowUp": {
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
const prev = highlightedIndex > 0 ? highlightedIndex - 1 : count - 1;
|
|
159
|
+
setHighlightedIndex(prev);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "Enter":
|
|
163
|
+
case " ": {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
if (highlightedIndex >= 0 && highlightedIndex < count) {
|
|
166
|
+
items[highlightedIndex].click();
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
case "Escape": {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
setOpen(false);
|
|
173
|
+
triggerRef.current?.focus();
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
[highlightedIndex, setHighlightedIndex, setOpen, triggerRef]
|
|
179
|
+
);
|
|
180
|
+
if (!open) return null;
|
|
181
|
+
if (typeof document === "undefined") return null;
|
|
182
|
+
return createPortal(
|
|
183
|
+
/* @__PURE__ */ jsx(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
ref: (node) => {
|
|
187
|
+
menuRef.current = node;
|
|
188
|
+
if (typeof ref === "function") ref(node);
|
|
189
|
+
else if (ref) ref.current = node;
|
|
190
|
+
},
|
|
191
|
+
role: "menu",
|
|
192
|
+
tabIndex: -1,
|
|
193
|
+
className: cn("dropdown__menu", className),
|
|
194
|
+
style: { top: position.top, left: position.left },
|
|
195
|
+
onKeyDown: handleKeyDown,
|
|
196
|
+
...rest,
|
|
197
|
+
children
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
document.body
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
DropdownMenu.displayName = "DropdownMenu";
|
|
205
|
+
const DropdownItem = forwardRef(
|
|
206
|
+
({ onSelect, disabled, children, className, ...rest }, ref) => {
|
|
207
|
+
const { setOpen } = useDropdownContext();
|
|
208
|
+
const handleClick = useCallback(() => {
|
|
209
|
+
if (disabled) return;
|
|
210
|
+
onSelect?.();
|
|
211
|
+
setOpen(false);
|
|
212
|
+
}, [disabled, onSelect, setOpen]);
|
|
213
|
+
const handleKeyDown = useCallback(
|
|
214
|
+
(e) => {
|
|
215
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
handleClick();
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
[handleClick]
|
|
221
|
+
);
|
|
222
|
+
return /* @__PURE__ */ jsx(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
ref,
|
|
226
|
+
role: "menuitem",
|
|
227
|
+
tabIndex: disabled ? void 0 : -1,
|
|
228
|
+
"data-dropdown-item": "",
|
|
229
|
+
"data-disabled": disabled || void 0,
|
|
230
|
+
className: cn("dropdown__item", className),
|
|
231
|
+
onClick: handleClick,
|
|
232
|
+
onKeyDown: handleKeyDown,
|
|
233
|
+
"aria-disabled": disabled || void 0,
|
|
234
|
+
...rest,
|
|
235
|
+
children
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
DropdownItem.displayName = "DropdownItem";
|
|
241
|
+
const DropdownSeparator = forwardRef(
|
|
242
|
+
(_props, ref) => {
|
|
243
|
+
return /* @__PURE__ */ jsx("div", { ref, role: "separator", className: "dropdown__separator" });
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
DropdownSeparator.displayName = "DropdownSeparator";
|
|
247
|
+
export {
|
|
248
|
+
Dropdown,
|
|
249
|
+
DropdownItem,
|
|
250
|
+
DropdownMenu,
|
|
251
|
+
DropdownSeparator,
|
|
252
|
+
DropdownTrigger
|
|
253
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const EmptyState = forwardRef(
|
|
5
|
+
({ icon, title, description, actions, className, ...rest }, ref) => /* @__PURE__ */ jsxs("div", { ref, className: cn("empty-state", className), ...rest, children: [
|
|
6
|
+
icon && /* @__PURE__ */ jsx("span", { className: "empty-state__icon", children: icon }),
|
|
7
|
+
/* @__PURE__ */ jsx("h3", { className: "empty-state__title", children: title }),
|
|
8
|
+
description && /* @__PURE__ */ jsx("p", { className: "empty-state__description", children: description }),
|
|
9
|
+
actions && /* @__PURE__ */ jsx("div", { className: "empty-state__actions", children: actions })
|
|
10
|
+
] })
|
|
11
|
+
);
|
|
12
|
+
EmptyState.displayName = "EmptyState";
|
|
13
|
+
export {
|
|
14
|
+
EmptyState
|
|
15
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const FAB = forwardRef(
|
|
5
|
+
({
|
|
6
|
+
label,
|
|
7
|
+
variant = "primary",
|
|
8
|
+
size = "md",
|
|
9
|
+
position = "bottom-right",
|
|
10
|
+
extended,
|
|
11
|
+
className,
|
|
12
|
+
children,
|
|
13
|
+
...rest
|
|
14
|
+
}, ref) => {
|
|
15
|
+
return /* @__PURE__ */ jsxs(
|
|
16
|
+
"button",
|
|
17
|
+
{
|
|
18
|
+
ref,
|
|
19
|
+
"aria-label": extended ? void 0 : label,
|
|
20
|
+
className: cn(
|
|
21
|
+
"fab",
|
|
22
|
+
`fab--${variant}`,
|
|
23
|
+
`fab--${size}`,
|
|
24
|
+
`fab--${position}`,
|
|
25
|
+
extended && "fab--extended",
|
|
26
|
+
className
|
|
27
|
+
),
|
|
28
|
+
...rest,
|
|
29
|
+
children: [
|
|
30
|
+
children,
|
|
31
|
+
extended && /* @__PURE__ */ jsx("span", { className: "fab__label", children: label })
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
FAB.displayName = "FAB";
|
|
38
|
+
export {
|
|
39
|
+
FAB
|
|
40
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useState } from "react";
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
const FAQ = forwardRef(
|
|
6
|
+
({ className, children, ...rest }, ref) => {
|
|
7
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("faq", className), ...rest, children });
|
|
8
|
+
}
|
|
9
|
+
);
|
|
10
|
+
FAQ.displayName = "FAQ";
|
|
11
|
+
const FAQItem = forwardRef(
|
|
12
|
+
({ question, answer, className, children, ...rest }, ref) => {
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
ref,
|
|
18
|
+
className: cn("faq__item", open && "faq__item--open", className),
|
|
19
|
+
...rest,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsxs(
|
|
22
|
+
"button",
|
|
23
|
+
{
|
|
24
|
+
type: "button",
|
|
25
|
+
className: "faq__trigger",
|
|
26
|
+
"aria-expanded": open,
|
|
27
|
+
onClick: () => setOpen((prev) => !prev),
|
|
28
|
+
children: [
|
|
29
|
+
question,
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
"svg",
|
|
32
|
+
{
|
|
33
|
+
className: "faq__chevron",
|
|
34
|
+
width: "16",
|
|
35
|
+
height: "16",
|
|
36
|
+
viewBox: "0 0 16 16",
|
|
37
|
+
fill: "none",
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
children: /* @__PURE__ */ jsx(
|
|
40
|
+
"path",
|
|
41
|
+
{
|
|
42
|
+
d: "M4 6l4 4 4-4",
|
|
43
|
+
stroke: "currentColor",
|
|
44
|
+
strokeWidth: "2",
|
|
45
|
+
strokeLinecap: "round",
|
|
46
|
+
strokeLinejoin: "round"
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsx("div", { className: "faq__answer", children: /* @__PURE__ */ jsx("div", { className: "faq__answer-inner", children: answer ?? children }) })
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
FAQItem.displayName = "FAQItem";
|
|
61
|
+
export {
|
|
62
|
+
FAQ,
|
|
63
|
+
FAQItem
|
|
64
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const FeatureGrid = forwardRef(
|
|
5
|
+
({ columns = 3, className, children, ...rest }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"div",
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
className: cn(
|
|
11
|
+
"feature-grid",
|
|
12
|
+
columns !== 3 && `feature-grid--cols-${columns}`,
|
|
13
|
+
className
|
|
14
|
+
),
|
|
15
|
+
...rest,
|
|
16
|
+
children
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
FeatureGrid.displayName = "FeatureGrid";
|
|
22
|
+
const FeatureCard = forwardRef(
|
|
23
|
+
({ icon, title, description, className, ...rest }, ref) => {
|
|
24
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("feature-card", className), ...rest, children: [
|
|
25
|
+
icon && /* @__PURE__ */ jsx("div", { className: "feature-card__icon", children: icon }),
|
|
26
|
+
/* @__PURE__ */ jsx("h3", { className: "feature-card__title", children: title }),
|
|
27
|
+
/* @__PURE__ */ jsx("p", { className: "feature-card__description", children: description })
|
|
28
|
+
] });
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
FeatureCard.displayName = "FeatureCard";
|
|
32
|
+
export {
|
|
33
|
+
FeatureCard,
|
|
34
|
+
FeatureGrid
|
|
35
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId, isValidElement, cloneElement } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const FormField = forwardRef(
|
|
5
|
+
({
|
|
6
|
+
label,
|
|
7
|
+
description,
|
|
8
|
+
error,
|
|
9
|
+
required,
|
|
10
|
+
maxLength,
|
|
11
|
+
currentLength,
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
...rest
|
|
15
|
+
}, ref) => {
|
|
16
|
+
const generatedId = useId();
|
|
17
|
+
const inputId = `form-field-${generatedId}`;
|
|
18
|
+
const descriptionId = description ? `${inputId}-description` : void 0;
|
|
19
|
+
const errorId = error ? `${inputId}-error` : void 0;
|
|
20
|
+
const describedBy = [descriptionId, errorId].filter(Boolean).join(" ") || void 0;
|
|
21
|
+
const control = isValidElement(children) ? cloneElement(children, {
|
|
22
|
+
id: inputId,
|
|
23
|
+
"aria-invalid": error ? "true" : void 0,
|
|
24
|
+
"aria-describedby": describedBy,
|
|
25
|
+
...error ? { error: true } : {}
|
|
26
|
+
}) : children;
|
|
27
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("form-field", className), ...rest, children: [
|
|
28
|
+
label && /* @__PURE__ */ jsx(
|
|
29
|
+
"label",
|
|
30
|
+
{
|
|
31
|
+
htmlFor: inputId,
|
|
32
|
+
className: cn(
|
|
33
|
+
"form-field__label",
|
|
34
|
+
required && "form-field__label--required"
|
|
35
|
+
),
|
|
36
|
+
children: label
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
description && /* @__PURE__ */ jsx("p", { id: descriptionId, className: "form-field__description", children: description }),
|
|
40
|
+
control,
|
|
41
|
+
error && /* @__PURE__ */ jsx("p", { id: errorId, className: "form-field__error", role: "alert", children: error }),
|
|
42
|
+
maxLength != null && /* @__PURE__ */ jsxs("p", { className: "form-field__counter", children: [
|
|
43
|
+
currentLength ?? 0,
|
|
44
|
+
" / ",
|
|
45
|
+
maxLength
|
|
46
|
+
] })
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
FormField.displayName = "FormField";
|
|
51
|
+
export {
|
|
52
|
+
FormField
|
|
53
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
import { space } from "../../tokens.js";
|
|
5
|
+
const GAP_MAP = {
|
|
6
|
+
xs: "0.25rem",
|
|
7
|
+
sm: "0.5rem",
|
|
8
|
+
md: "1rem",
|
|
9
|
+
lg: "1.5rem",
|
|
10
|
+
xl: "2rem"
|
|
11
|
+
};
|
|
12
|
+
const resolveGap = (v) => {
|
|
13
|
+
if (typeof v === "number") {
|
|
14
|
+
return space[v] ?? `${v}px`;
|
|
15
|
+
}
|
|
16
|
+
if (v in GAP_MAP) {
|
|
17
|
+
return GAP_MAP[v];
|
|
18
|
+
}
|
|
19
|
+
if (v in space) {
|
|
20
|
+
return space[v];
|
|
21
|
+
}
|
|
22
|
+
return v;
|
|
23
|
+
};
|
|
24
|
+
const Grid = forwardRef(
|
|
25
|
+
({ columns, columnsMd, columnsSm, gap, gapMd, gapSm, className, style, ...rest }, ref) => {
|
|
26
|
+
const resolvedGap = gap != null ? resolveGap(gap) : void 0;
|
|
27
|
+
const resolvedGapMd = gapMd != null ? resolveGap(gapMd) : void 0;
|
|
28
|
+
const resolvedGapSm = gapSm != null ? resolveGap(gapSm) : void 0;
|
|
29
|
+
const vars = {
|
|
30
|
+
...style,
|
|
31
|
+
...columns != null ? { "--grid-cols": columns } : {},
|
|
32
|
+
...columnsMd != null ? { "--grid-cols-md": columnsMd } : {},
|
|
33
|
+
...columnsSm != null ? { "--grid-cols-sm": columnsSm } : {},
|
|
34
|
+
...resolvedGap != null ? { "--grid-gap": resolvedGap } : {},
|
|
35
|
+
...resolvedGapMd != null ? { "--grid-gap-md": resolvedGapMd } : {},
|
|
36
|
+
...resolvedGapSm != null ? { "--grid-gap-sm": resolvedGapSm } : {}
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
ref,
|
|
42
|
+
className: cn("grid", className),
|
|
43
|
+
style: vars,
|
|
44
|
+
...rest
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
Grid.displayName = "Grid";
|
|
50
|
+
export {
|
|
51
|
+
Grid
|
|
52
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, createElement } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const Heading = forwardRef(
|
|
5
|
+
({ level = 2, as, description, bordered, className, children, ...rest }, ref) => {
|
|
6
|
+
const tag = as ?? `h${level}`;
|
|
7
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8
|
+
createElement(
|
|
9
|
+
tag,
|
|
10
|
+
{
|
|
11
|
+
ref,
|
|
12
|
+
className: cn(
|
|
13
|
+
"heading",
|
|
14
|
+
`heading--${level}`,
|
|
15
|
+
bordered && "heading--bordered",
|
|
16
|
+
className
|
|
17
|
+
),
|
|
18
|
+
...rest
|
|
19
|
+
},
|
|
20
|
+
children
|
|
21
|
+
),
|
|
22
|
+
description && /* @__PURE__ */ jsx("p", { className: "heading__description", children: description })
|
|
23
|
+
] });
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
Heading.displayName = "Heading";
|
|
27
|
+
export {
|
|
28
|
+
Heading
|
|
29
|
+
};
|