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,25 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const Alert = forwardRef(
|
|
5
|
+
({ variant = "info", icon, title, className, children, ...rest }, ref) => /* @__PURE__ */ jsxs(
|
|
6
|
+
"div",
|
|
7
|
+
{
|
|
8
|
+
ref,
|
|
9
|
+
role: "alert",
|
|
10
|
+
className: cn("alert", `alert--${variant}`, className),
|
|
11
|
+
...rest,
|
|
12
|
+
children: [
|
|
13
|
+
icon && /* @__PURE__ */ jsx("span", { className: "alert__icon", children: icon }),
|
|
14
|
+
/* @__PURE__ */ jsxs("div", { className: "alert__content", children: [
|
|
15
|
+
title && /* @__PURE__ */ jsx("p", { className: "alert__title", children: title }),
|
|
16
|
+
/* @__PURE__ */ jsx("div", { className: "alert__description", children })
|
|
17
|
+
] })
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
Alert.displayName = "Alert";
|
|
23
|
+
export {
|
|
24
|
+
Alert
|
|
25
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const Avatar = forwardRef(
|
|
5
|
+
({ size = "md", src, alt, fallback, className, ...rest }, ref) => {
|
|
6
|
+
const showFallback = !src && fallback;
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"span",
|
|
9
|
+
{
|
|
10
|
+
ref,
|
|
11
|
+
role: showFallback ? "img" : void 0,
|
|
12
|
+
"aria-label": showFallback ? fallback : void 0,
|
|
13
|
+
className: cn("avatar", `avatar--${size}`, className),
|
|
14
|
+
...rest,
|
|
15
|
+
children: src ? /* @__PURE__ */ jsx("img", { src, alt: alt ?? "" }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: fallback })
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
Avatar.displayName = "Avatar";
|
|
21
|
+
export {
|
|
22
|
+
Avatar
|
|
23
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const Badge = forwardRef(
|
|
5
|
+
({ variant = "default", dot, solid, live, className, children, ...rest }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ jsxs(
|
|
7
|
+
"span",
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
...live ? { role: "status" } : {},
|
|
11
|
+
className: cn(
|
|
12
|
+
"badge",
|
|
13
|
+
`badge--${variant}`,
|
|
14
|
+
solid && "badge--solid",
|
|
15
|
+
className
|
|
16
|
+
),
|
|
17
|
+
...rest,
|
|
18
|
+
children: [
|
|
19
|
+
dot && /* @__PURE__ */ jsx("span", { className: "badge__dot", "aria-hidden": "true" }),
|
|
20
|
+
children
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
Badge.displayName = "Badge";
|
|
27
|
+
export {
|
|
28
|
+
Badge
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx, jsxs } 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 BarChart = forwardRef(
|
|
6
|
+
({ data, max, formatValue, "aria-label": ariaLabel, className, ...rest }, ref) => {
|
|
7
|
+
const maxVal = max ?? Math.max(...data.map((d) => d.value));
|
|
8
|
+
const fmt = formatValue ?? ((v) => String(v));
|
|
9
|
+
return /* @__PURE__ */ jsx("div", { ref, role: "img", "aria-label": ariaLabel, className: cn("bar-chart", className), ...rest, children: data.map((item, i) => {
|
|
10
|
+
const pct = maxVal > 0 ? item.value / maxVal * 100 : 0;
|
|
11
|
+
const color = item.color ?? CHART_COLORS[i % CHART_COLORS.length];
|
|
12
|
+
return /* @__PURE__ */ jsxs("div", { className: "bar-chart__item", children: [
|
|
13
|
+
/* @__PURE__ */ jsx("span", { className: "bar-chart__label", children: item.label }),
|
|
14
|
+
/* @__PURE__ */ jsx("span", { className: "bar-chart__track", children: /* @__PURE__ */ jsx(
|
|
15
|
+
"span",
|
|
16
|
+
{
|
|
17
|
+
className: "bar-chart__fill",
|
|
18
|
+
style: { width: `${pct}%`, background: color }
|
|
19
|
+
}
|
|
20
|
+
) }),
|
|
21
|
+
/* @__PURE__ */ jsx("span", { className: "bar-chart__value", children: fmt(item.value) })
|
|
22
|
+
] }, item.label);
|
|
23
|
+
}) });
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
BarChart.displayName = "BarChart";
|
|
27
|
+
export {
|
|
28
|
+
BarChart
|
|
29
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const BarList = forwardRef(
|
|
5
|
+
({
|
|
6
|
+
data,
|
|
7
|
+
sortOrder = "descending",
|
|
8
|
+
valueFormatter,
|
|
9
|
+
className,
|
|
10
|
+
...rest
|
|
11
|
+
}, ref) => {
|
|
12
|
+
const sorted = sortOrder === "none" ? data : [...data].sort(
|
|
13
|
+
(a, b) => sortOrder === "ascending" ? a.value - b.value : b.value - a.value
|
|
14
|
+
);
|
|
15
|
+
const maxValue = Math.max(...sorted.map((d) => d.value), 1);
|
|
16
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("barlist", className), ...rest, children: sorted.map((item, i) => {
|
|
17
|
+
const pct = item.value / maxValue * 100;
|
|
18
|
+
const display = item.displayValue ?? (valueFormatter ? valueFormatter(item.value) : String(item.value));
|
|
19
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
|
+
/* @__PURE__ */ jsxs("div", { className: "barlist__bar-wrapper", children: [
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
className: "barlist__bar",
|
|
25
|
+
style: {
|
|
26
|
+
width: `${pct}%`,
|
|
27
|
+
...item.color ? { backgroundColor: item.color } : {}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ jsx("span", { className: "barlist__label", children: item.label })
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ jsx("span", { className: "barlist__value", children: display })
|
|
34
|
+
] });
|
|
35
|
+
const LinkComponent = item.as ?? "a";
|
|
36
|
+
return item.href ? /* @__PURE__ */ jsx(
|
|
37
|
+
LinkComponent,
|
|
38
|
+
{
|
|
39
|
+
href: item.href,
|
|
40
|
+
className: "barlist__row barlist__row--link",
|
|
41
|
+
children: content
|
|
42
|
+
},
|
|
43
|
+
i
|
|
44
|
+
) : /* @__PURE__ */ jsx("div", { className: "barlist__row", children: content }, i);
|
|
45
|
+
}) });
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
BarList.displayName = "BarList";
|
|
49
|
+
export {
|
|
50
|
+
BarList
|
|
51
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const Breadcrumb = forwardRef(
|
|
4
|
+
({ items, label = "パンくず", className, ...rest }, ref) => /* @__PURE__ */ jsx("nav", { ref, "aria-label": label, className, ...rest, children: /* @__PURE__ */ jsx("ol", { className: "breadcrumb", children: items.map((item, i) => {
|
|
5
|
+
const LinkComponent = item.as ?? "a";
|
|
6
|
+
return /* @__PURE__ */ jsx("li", { className: "breadcrumb__item", children: i < items.length - 1 && item.href ? /* @__PURE__ */ jsx(LinkComponent, { href: item.href, className: "breadcrumb__link", children: item.label }) : /* @__PURE__ */ jsx("span", { className: "breadcrumb__current", "aria-current": "page", children: item.label }) }, item.href ?? item.label);
|
|
7
|
+
}) }) })
|
|
8
|
+
);
|
|
9
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
10
|
+
export {
|
|
11
|
+
Breadcrumb
|
|
12
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const Button = forwardRef(
|
|
5
|
+
({
|
|
6
|
+
variant = "primary",
|
|
7
|
+
size = "md",
|
|
8
|
+
fullWidth,
|
|
9
|
+
iconOnly,
|
|
10
|
+
disabled,
|
|
11
|
+
className,
|
|
12
|
+
children,
|
|
13
|
+
...rest
|
|
14
|
+
}, ref) => {
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
"button",
|
|
17
|
+
{
|
|
18
|
+
ref,
|
|
19
|
+
disabled,
|
|
20
|
+
...disabled ? { "aria-disabled": true } : {},
|
|
21
|
+
className: cn(
|
|
22
|
+
"btn",
|
|
23
|
+
`btn--${variant}`,
|
|
24
|
+
`btn--${size}`,
|
|
25
|
+
fullWidth && "btn--full",
|
|
26
|
+
iconOnly && "btn--icon",
|
|
27
|
+
className
|
|
28
|
+
),
|
|
29
|
+
...rest,
|
|
30
|
+
children
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
Button.displayName = "Button";
|
|
36
|
+
export {
|
|
37
|
+
Button
|
|
38
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const CTABanner = forwardRef(
|
|
5
|
+
({ title, description, className, children, ...rest }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("cta-banner", className), ...rest, children: [
|
|
7
|
+
/* @__PURE__ */ jsx("h2", { className: "cta-banner__title", children: title }),
|
|
8
|
+
description && /* @__PURE__ */ jsx("p", { className: "cta-banner__description", children: description }),
|
|
9
|
+
children && /* @__PURE__ */ jsx("div", { className: "cta-banner__actions", children })
|
|
10
|
+
] });
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
CTABanner.displayName = "CTABanner";
|
|
14
|
+
export {
|
|
15
|
+
CTABanner
|
|
16
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const Card = forwardRef(
|
|
5
|
+
({ variant = "default", className, children, ...rest }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"div",
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
className: cn(
|
|
11
|
+
"card",
|
|
12
|
+
variant === "interactive" && "card--interactive",
|
|
13
|
+
variant === "compact" && "card--compact",
|
|
14
|
+
variant === "fill" && "card--fill",
|
|
15
|
+
className
|
|
16
|
+
),
|
|
17
|
+
...rest,
|
|
18
|
+
children
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
Card.displayName = "Card";
|
|
24
|
+
const CardHeader = forwardRef(
|
|
25
|
+
({ className, children, ...rest }, ref) => {
|
|
26
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("card__header", className), ...rest, children });
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
CardHeader.displayName = "CardHeader";
|
|
30
|
+
const CardTitle = forwardRef(
|
|
31
|
+
({ className, children, ...rest }, ref) => {
|
|
32
|
+
return /* @__PURE__ */ jsx("h3", { ref, className: cn("card__title", className), ...rest, children });
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
CardTitle.displayName = "CardTitle";
|
|
36
|
+
const CardDescription = forwardRef(({ className, children, ...rest }, ref) => {
|
|
37
|
+
return /* @__PURE__ */ jsx("p", { ref, className: cn("card__description", className), ...rest, children });
|
|
38
|
+
});
|
|
39
|
+
CardDescription.displayName = "CardDescription";
|
|
40
|
+
const CardBody = forwardRef(
|
|
41
|
+
({ className, children, ...rest }, ref) => {
|
|
42
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("card__body", className), ...rest, children });
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
CardBody.displayName = "CardBody";
|
|
46
|
+
const CardFooter = forwardRef(
|
|
47
|
+
({ className, children, ...rest }, ref) => {
|
|
48
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("card__footer", className), ...rest, children });
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
CardFooter.displayName = "CardFooter";
|
|
52
|
+
export {
|
|
53
|
+
Card,
|
|
54
|
+
CardBody,
|
|
55
|
+
CardDescription,
|
|
56
|
+
CardFooter,
|
|
57
|
+
CardHeader,
|
|
58
|
+
CardTitle
|
|
59
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const Checkbox = forwardRef(
|
|
5
|
+
({ label, className, id: idProp, ...rest }, ref) => {
|
|
6
|
+
const generatedId = useId();
|
|
7
|
+
const id = idProp ?? generatedId;
|
|
8
|
+
return /* @__PURE__ */ jsxs("label", { htmlFor: id, className: cn("checkbox", className), children: [
|
|
9
|
+
/* @__PURE__ */ jsx(
|
|
10
|
+
"input",
|
|
11
|
+
{
|
|
12
|
+
ref,
|
|
13
|
+
id,
|
|
14
|
+
type: "checkbox",
|
|
15
|
+
className: "checkbox__input",
|
|
16
|
+
...rest
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
label && /* @__PURE__ */ jsx("span", { children: label })
|
|
20
|
+
] });
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
Checkbox.displayName = "Checkbox";
|
|
24
|
+
export {
|
|
25
|
+
Checkbox
|
|
26
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useState, useRef, useEffect, useMemo, useCallback } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { useFocusTrap } from "../../hooks/useFocusTrap.js";
|
|
7
|
+
import { lockScroll } from "../../utils/scrollLock.js";
|
|
8
|
+
const CommandPalette = forwardRef(
|
|
9
|
+
({
|
|
10
|
+
open,
|
|
11
|
+
onOpenChange,
|
|
12
|
+
commands,
|
|
13
|
+
placeholder = "コマンドを検索...",
|
|
14
|
+
searchLabel = "コマンド検索",
|
|
15
|
+
label,
|
|
16
|
+
emptyMessage = "該当するコマンドが見つかりません",
|
|
17
|
+
className,
|
|
18
|
+
...rest
|
|
19
|
+
}, ref) => {
|
|
20
|
+
const [query, setQuery] = useState("");
|
|
21
|
+
const [highlightedIndex, setHighlightedIndex] = useState(0);
|
|
22
|
+
const inputRef = useRef(null);
|
|
23
|
+
const listRef = useRef(null);
|
|
24
|
+
const dialogRef = useRef(null);
|
|
25
|
+
useFocusTrap(dialogRef, open);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!open) return;
|
|
28
|
+
const unlock = lockScroll();
|
|
29
|
+
return unlock;
|
|
30
|
+
}, [open]);
|
|
31
|
+
const filtered = useMemo(() => {
|
|
32
|
+
if (!query.trim()) return commands;
|
|
33
|
+
const lower = query.toLowerCase();
|
|
34
|
+
return commands.filter((cmd) => cmd.label.toLowerCase().includes(lower));
|
|
35
|
+
}, [commands, query]);
|
|
36
|
+
const grouped = useMemo(() => {
|
|
37
|
+
const groups = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const cmd of filtered) {
|
|
39
|
+
const group = cmd.group ?? "";
|
|
40
|
+
if (!groups.has(group)) {
|
|
41
|
+
groups.set(group, []);
|
|
42
|
+
}
|
|
43
|
+
groups.get(group).push(cmd);
|
|
44
|
+
}
|
|
45
|
+
return groups;
|
|
46
|
+
}, [filtered]);
|
|
47
|
+
const flatList = useMemo(() => {
|
|
48
|
+
const items = [];
|
|
49
|
+
for (const cmds of grouped.values()) {
|
|
50
|
+
items.push(...cmds);
|
|
51
|
+
}
|
|
52
|
+
return items;
|
|
53
|
+
}, [grouped]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (open) {
|
|
56
|
+
setQuery("");
|
|
57
|
+
setHighlightedIndex(0);
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
inputRef.current?.focus();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [open]);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!listRef.current) return;
|
|
65
|
+
const items = listRef.current.querySelectorAll(
|
|
66
|
+
"[data-command-item]"
|
|
67
|
+
);
|
|
68
|
+
const highlighted = items[highlightedIndex];
|
|
69
|
+
highlighted?.scrollIntoView({ block: "nearest" });
|
|
70
|
+
}, [highlightedIndex]);
|
|
71
|
+
const handleInputChange = useCallback((e) => {
|
|
72
|
+
setQuery(e.target.value);
|
|
73
|
+
setHighlightedIndex(0);
|
|
74
|
+
}, []);
|
|
75
|
+
const handleSelect = useCallback(
|
|
76
|
+
(cmd) => {
|
|
77
|
+
cmd.onSelect();
|
|
78
|
+
onOpenChange(false);
|
|
79
|
+
},
|
|
80
|
+
[onOpenChange]
|
|
81
|
+
);
|
|
82
|
+
const handleKeyDown = useCallback(
|
|
83
|
+
(e) => {
|
|
84
|
+
switch (e.key) {
|
|
85
|
+
case "ArrowDown": {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
setHighlightedIndex(
|
|
88
|
+
(prev) => prev < flatList.length - 1 ? prev + 1 : 0
|
|
89
|
+
);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "ArrowUp": {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
setHighlightedIndex(
|
|
95
|
+
(prev) => prev > 0 ? prev - 1 : flatList.length - 1
|
|
96
|
+
);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case "Enter": {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
if (flatList[highlightedIndex]) {
|
|
102
|
+
handleSelect(flatList[highlightedIndex]);
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "Escape": {
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
onOpenChange(false);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
[flatList, highlightedIndex, handleSelect, onOpenChange]
|
|
114
|
+
);
|
|
115
|
+
const handleOverlayClick = useCallback(
|
|
116
|
+
(e) => {
|
|
117
|
+
if (e.target === e.currentTarget) {
|
|
118
|
+
onOpenChange(false);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
[onOpenChange]
|
|
122
|
+
);
|
|
123
|
+
if (!open) return null;
|
|
124
|
+
if (typeof document === "undefined") return null;
|
|
125
|
+
let flatIndex = 0;
|
|
126
|
+
return createPortal(
|
|
127
|
+
/* @__PURE__ */ jsx("div", { className: "overlay", onClick: handleOverlayClick, children: /* @__PURE__ */ jsxs(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
ref: (node) => {
|
|
131
|
+
dialogRef.current = node;
|
|
132
|
+
if (typeof ref === "function") ref(node);
|
|
133
|
+
else if (ref) ref.current = node;
|
|
134
|
+
},
|
|
135
|
+
role: "dialog",
|
|
136
|
+
"aria-modal": "true",
|
|
137
|
+
"aria-label": label ?? "コマンドパレット",
|
|
138
|
+
className: cn("command-palette", className),
|
|
139
|
+
onKeyDown: handleKeyDown,
|
|
140
|
+
...rest,
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ jsx(
|
|
143
|
+
"input",
|
|
144
|
+
{
|
|
145
|
+
ref: inputRef,
|
|
146
|
+
type: "text",
|
|
147
|
+
className: "command-palette__input",
|
|
148
|
+
placeholder,
|
|
149
|
+
value: query,
|
|
150
|
+
onChange: handleInputChange,
|
|
151
|
+
"aria-label": searchLabel,
|
|
152
|
+
autoComplete: "off"
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ jsxs("div", { ref: listRef, className: "command-palette__list", role: "listbox", children: [
|
|
156
|
+
flatList.length === 0 && /* @__PURE__ */ jsx("div", { className: "command-palette__empty", children: emptyMessage }),
|
|
157
|
+
Array.from(grouped.entries()).map(([group, cmds]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
158
|
+
group && /* @__PURE__ */ jsx("div", { className: "command-palette__group", children: group }),
|
|
159
|
+
cmds.map((cmd) => {
|
|
160
|
+
const index = flatIndex++;
|
|
161
|
+
return /* @__PURE__ */ jsxs(
|
|
162
|
+
"div",
|
|
163
|
+
{
|
|
164
|
+
role: "option",
|
|
165
|
+
"data-command-item": "",
|
|
166
|
+
"aria-selected": index === highlightedIndex,
|
|
167
|
+
className: cn(
|
|
168
|
+
"command-palette__item",
|
|
169
|
+
index === highlightedIndex && "command-palette__item--active"
|
|
170
|
+
),
|
|
171
|
+
onClick: () => handleSelect(cmd),
|
|
172
|
+
onMouseEnter: () => setHighlightedIndex(index),
|
|
173
|
+
children: [
|
|
174
|
+
cmd.icon && /* @__PURE__ */ jsx(
|
|
175
|
+
"span",
|
|
176
|
+
{
|
|
177
|
+
style: {
|
|
178
|
+
display: "inline-flex",
|
|
179
|
+
flexShrink: 0
|
|
180
|
+
},
|
|
181
|
+
children: cmd.icon
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
cmd.label
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
cmd.id
|
|
188
|
+
);
|
|
189
|
+
})
|
|
190
|
+
] }, group || "__default"))
|
|
191
|
+
] })
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
) }),
|
|
195
|
+
document.body
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
CommandPalette.displayName = "CommandPalette";
|
|
200
|
+
export {
|
|
201
|
+
CommandPalette
|
|
202
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const DescriptionList = forwardRef(({ horizontal, bordered, className, children, ...rest }, ref) => /* @__PURE__ */ jsx(
|
|
5
|
+
"dl",
|
|
6
|
+
{
|
|
7
|
+
ref,
|
|
8
|
+
className: cn(
|
|
9
|
+
"dl",
|
|
10
|
+
horizontal && "dl--horizontal",
|
|
11
|
+
bordered && "dl--bordered",
|
|
12
|
+
className
|
|
13
|
+
),
|
|
14
|
+
...rest,
|
|
15
|
+
children
|
|
16
|
+
}
|
|
17
|
+
));
|
|
18
|
+
DescriptionList.displayName = "DescriptionList";
|
|
19
|
+
const DescriptionItem = forwardRef(
|
|
20
|
+
({ term, className, children, ...rest }, ref) => /* @__PURE__ */ jsxs("div", { ref, className: cn("dl__group", className), ...rest, children: [
|
|
21
|
+
/* @__PURE__ */ jsx("dt", { className: "dl__term", children: term }),
|
|
22
|
+
/* @__PURE__ */ jsx("dd", { className: "dl__detail", children })
|
|
23
|
+
] })
|
|
24
|
+
);
|
|
25
|
+
DescriptionItem.displayName = "DescriptionItem";
|
|
26
|
+
export {
|
|
27
|
+
DescriptionItem,
|
|
28
|
+
DescriptionList
|
|
29
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useId, useRef, useState, useCallback, useEffect, useContext, createContext } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { useFocusTrap } from "../../hooks/useFocusTrap.js";
|
|
7
|
+
import { lockScroll } from "../../utils/scrollLock.js";
|
|
8
|
+
const CLOSE_ANIMATION_MS = 200;
|
|
9
|
+
const Dialog = forwardRef(
|
|
10
|
+
({ open, onClose, returnFocusRef: _returnFocusRef, className, children, ...rest }, ref) => {
|
|
11
|
+
const titleId = useId();
|
|
12
|
+
const internalRef = useRef(null);
|
|
13
|
+
const [visible, setVisible] = useState(false);
|
|
14
|
+
const [closing, setClosing] = useState(false);
|
|
15
|
+
const mergedRef = useCallback(
|
|
16
|
+
(node) => {
|
|
17
|
+
internalRef.current = node;
|
|
18
|
+
if (typeof ref === "function") {
|
|
19
|
+
ref(node);
|
|
20
|
+
} else if (ref) {
|
|
21
|
+
ref.current = node;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
[ref]
|
|
25
|
+
);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (open) {
|
|
28
|
+
setVisible(true);
|
|
29
|
+
setClosing(false);
|
|
30
|
+
} else if (visible) {
|
|
31
|
+
setClosing(true);
|
|
32
|
+
const timer = setTimeout(() => {
|
|
33
|
+
setClosing(false);
|
|
34
|
+
setVisible(false);
|
|
35
|
+
}, CLOSE_ANIMATION_MS);
|
|
36
|
+
return () => clearTimeout(timer);
|
|
37
|
+
}
|
|
38
|
+
}, [open]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!open) return;
|
|
41
|
+
const unlock = lockScroll();
|
|
42
|
+
return unlock;
|
|
43
|
+
}, [open]);
|
|
44
|
+
useFocusTrap(internalRef, open);
|
|
45
|
+
const handleOverlayClick = useCallback(
|
|
46
|
+
(e) => {
|
|
47
|
+
if (e.target === e.currentTarget) {
|
|
48
|
+
onClose();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[onClose]
|
|
52
|
+
);
|
|
53
|
+
const handleOverlayKeyDown = useCallback(
|
|
54
|
+
(e) => {
|
|
55
|
+
if (e.key === "Escape") {
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
onClose();
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[onClose]
|
|
61
|
+
);
|
|
62
|
+
if (!visible) return null;
|
|
63
|
+
if (typeof document === "undefined") return null;
|
|
64
|
+
return createPortal(
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
className: cn("overlay", closing && "overlay--closing"),
|
|
69
|
+
onClick: handleOverlayClick,
|
|
70
|
+
onKeyDown: handleOverlayKeyDown,
|
|
71
|
+
children: /* @__PURE__ */ jsx(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
ref: mergedRef,
|
|
75
|
+
role: "dialog",
|
|
76
|
+
"aria-modal": "true",
|
|
77
|
+
"aria-labelledby": titleId,
|
|
78
|
+
className: cn("dialog", className),
|
|
79
|
+
...rest,
|
|
80
|
+
children: /* @__PURE__ */ jsx(DialogTitleIdContext.Provider, { value: titleId, children })
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
document.body
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
Dialog.displayName = "Dialog";
|
|
90
|
+
const DialogTitleIdContext = createContext(void 0);
|
|
91
|
+
const DialogHeader = forwardRef(
|
|
92
|
+
({ className, children, ...rest }, ref) => {
|
|
93
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("dialog__header", className), ...rest, children });
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
DialogHeader.displayName = "DialogHeader";
|
|
97
|
+
const DialogTitle = forwardRef(
|
|
98
|
+
({ className, children, id, ...rest }, ref) => {
|
|
99
|
+
const contextId = useContext(DialogTitleIdContext);
|
|
100
|
+
return /* @__PURE__ */ jsx(
|
|
101
|
+
"h2",
|
|
102
|
+
{
|
|
103
|
+
ref,
|
|
104
|
+
id: id ?? contextId,
|
|
105
|
+
className: cn("dialog__title", className),
|
|
106
|
+
...rest,
|
|
107
|
+
children
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
DialogTitle.displayName = "DialogTitle";
|
|
113
|
+
const DialogBody = forwardRef(
|
|
114
|
+
({ className, children, ...rest }, ref) => {
|
|
115
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("dialog__body", className), ...rest, children });
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
DialogBody.displayName = "DialogBody";
|
|
119
|
+
const DialogFooter = forwardRef(
|
|
120
|
+
({ className, children, ...rest }, ref) => {
|
|
121
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("dialog__footer", className), ...rest, children });
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
DialogFooter.displayName = "DialogFooter";
|
|
125
|
+
export {
|
|
126
|
+
Dialog,
|
|
127
|
+
DialogBody,
|
|
128
|
+
DialogFooter,
|
|
129
|
+
DialogHeader,
|
|
130
|
+
DialogTitle
|
|
131
|
+
};
|