@raydenui/ui 0.9.7 → 0.10.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/dist/Table-DCNSxua1.d.cts +31 -0
- package/dist/Table-DCNSxua1.d.ts +31 -0
- package/dist/blocks/ApplicationShellBlock.cjs +157 -0
- package/dist/blocks/ApplicationShellBlock.js +154 -0
- package/dist/blocks/CheckoutReviewBlock.cjs +16 -0
- package/dist/blocks/CheckoutReviewBlock.js +13 -0
- package/dist/blocks/CommandPaletteBlock.cjs +334 -0
- package/dist/blocks/CommandPaletteBlock.js +331 -0
- package/dist/blocks/CreateAccountBlock.cjs +147 -0
- package/dist/blocks/CreateAccountBlock.js +143 -0
- package/dist/blocks/EmptyStateBlock.cjs +19 -0
- package/dist/blocks/EmptyStateBlock.js +16 -0
- package/dist/blocks/FeatureOverviewBlock.cjs +54 -0
- package/dist/blocks/FeatureOverviewBlock.js +51 -0
- package/dist/blocks/HeaderBlock.cjs +230 -0
- package/dist/blocks/HeaderBlock.js +227 -0
- package/dist/blocks/KpiOverviewBlock.cjs +63 -0
- package/dist/blocks/KpiOverviewBlock.js +60 -0
- package/dist/blocks/LoginBlock.cjs +66 -0
- package/dist/blocks/LoginBlock.js +63 -0
- package/dist/blocks/NotificationsBlock.cjs +17 -0
- package/dist/blocks/NotificationsBlock.js +14 -0
- package/dist/blocks/PageHeaderBlock.cjs +121 -0
- package/dist/blocks/PageHeaderBlock.js +118 -0
- package/dist/blocks/PricingPlansBlock.cjs +146 -0
- package/dist/blocks/PricingPlansBlock.js +143 -0
- package/dist/blocks/ProductCollectionBlock.cjs +37 -0
- package/dist/blocks/ProductCollectionBlock.js +34 -0
- package/dist/blocks/ProductDetailBlock.cjs +30 -0
- package/dist/blocks/ProductDetailBlock.js +27 -0
- package/dist/blocks/ProductHeroBlock.cjs +83 -0
- package/dist/blocks/ProductHeroBlock.js +80 -0
- package/dist/blocks/ProfileSettingsBlock.cjs +130 -0
- package/dist/blocks/ProfileSettingsBlock.js +126 -0
- package/dist/blocks/QuickSendBlock.cjs +11 -0
- package/dist/blocks/QuickSendBlock.js +8 -0
- package/dist/blocks/RecentTransactionsBlock.cjs +13 -0
- package/dist/blocks/RecentTransactionsBlock.js +10 -0
- package/dist/blocks/SearchableTableBlock.cjs +91 -0
- package/dist/blocks/SearchableTableBlock.js +88 -0
- package/dist/blocks/ShoppingCartBlock.cjs +16 -0
- package/dist/blocks/ShoppingCartBlock.js +13 -0
- package/dist/blocks/SiteFooterBlock.cjs +69 -0
- package/dist/blocks/SiteFooterBlock.js +66 -0
- package/dist/blocks/TableBlock.cjs +20 -0
- package/dist/blocks/TableBlock.js +17 -0
- package/dist/blocks/TaskListBlock.cjs +198 -0
- package/dist/blocks/TaskListBlock.js +195 -0
- package/dist/blocks/WorkspaceSwitcherBlock.cjs +291 -0
- package/dist/blocks/WorkspaceSwitcherBlock.js +288 -0
- package/dist/blocks/commerce.cjs +44 -0
- package/dist/blocks/commerce.js +35 -0
- package/dist/blocks/index.cjs +53 -0
- package/dist/blocks/index.js +24 -0
- package/dist/blocks.d.cts +1820 -0
- package/dist/blocks.d.ts +1820 -0
- package/dist/chart.cjs +13 -0
- package/dist/chart.d.cts +59 -0
- package/dist/chart.d.ts +59 -0
- package/dist/chart.js +5 -0
- package/dist/components/Accordion/Accordion.cjs +94 -0
- package/dist/components/Accordion/Accordion.js +91 -0
- package/dist/components/Accordion/index.cjs +8 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/ActivityFeed/ActivityContent.cjs +40 -0
- package/dist/components/ActivityFeed/ActivityContent.js +37 -0
- package/dist/components/ActivityFeed/ActivityItem.cjs +19 -0
- package/dist/components/ActivityFeed/ActivityItem.js +16 -0
- package/dist/components/ActivityFeed/index.cjs +7 -0
- package/dist/components/ActivityFeed/index.js +2 -0
- package/dist/components/Alert/Alert.cjs +42 -0
- package/dist/components/Alert/Alert.js +39 -0
- package/dist/components/Alert/index.cjs +5 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/Avatar/Avatar.cjs +101 -0
- package/dist/components/Avatar/Avatar.js +98 -0
- package/dist/components/Avatar/index.cjs +6 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Badge/Badge.cjs +53 -0
- package/dist/components/Badge/Badge.js +50 -0
- package/dist/components/Badge/index.cjs +5 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Banner/Banner.cjs +83 -0
- package/dist/components/Banner/Banner.js +80 -0
- package/dist/components/Banner/index.cjs +5 -0
- package/dist/components/Banner/index.js +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.cjs +31 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +28 -0
- package/dist/components/Breadcrumb/index.cjs +5 -0
- package/dist/components/Breadcrumb/index.js +1 -0
- package/dist/components/Button/Button.cjs +88 -0
- package/dist/components/Button/Button.js +85 -0
- package/dist/components/Button/index.cjs +5 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.cjs +8 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +5 -0
- package/dist/components/ButtonGroup/ButtonGroupItem.cjs +15 -0
- package/dist/components/ButtonGroup/ButtonGroupItem.js +12 -0
- package/dist/components/ButtonGroup/index.cjs +7 -0
- package/dist/components/ButtonGroup/index.js +2 -0
- package/dist/components/Card/Card.cjs +94 -0
- package/dist/components/Card/Card.js +91 -0
- package/dist/components/Card/index.cjs +9 -0
- package/dist/components/Card/index.js +1 -0
- package/dist/components/Chart/Chart.cjs +160 -0
- package/dist/components/Chart/Chart.js +153 -0
- package/dist/components/Chart/index.cjs +10 -0
- package/dist/components/Chart/index.js +2 -0
- package/dist/components/Chart/theme.cjs +67 -0
- package/dist/components/Chart/theme.js +62 -0
- package/dist/components/Chip/Chip.cjs +18 -0
- package/dist/components/Chip/Chip.js +15 -0
- package/dist/components/Chip/index.cjs +5 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Counter/Counter.cjs +74 -0
- package/dist/components/Counter/Counter.js +71 -0
- package/dist/components/Counter/index.cjs +6 -0
- package/dist/components/Counter/index.js +1 -0
- package/dist/components/DatePicker/DatePicker.cjs +343 -0
- package/dist/components/DatePicker/DatePicker.js +340 -0
- package/dist/components/DatePicker/index.cjs +5 -0
- package/dist/components/DatePicker/index.js +1 -0
- package/dist/components/Divider/Divider.cjs +31 -0
- package/dist/components/Divider/Divider.js +28 -0
- package/dist/components/Divider/index.cjs +5 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.cjs +108 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +105 -0
- package/dist/components/DropdownMenu/index.cjs +11 -0
- package/dist/components/DropdownMenu/index.js +1 -0
- package/dist/components/EmptyStateIllustration/EmptyStateIllustration.cjs +42 -0
- package/dist/components/EmptyStateIllustration/EmptyStateIllustration.js +39 -0
- package/dist/components/EmptyStateIllustration/illustrations.cjs +3322 -0
- package/dist/components/EmptyStateIllustration/illustrations.js +3319 -0
- package/dist/components/EmptyStateIllustration/index.cjs +7 -0
- package/dist/components/EmptyStateIllustration/index.js +2 -0
- package/dist/components/FileUpload/FileUpload.cjs +116 -0
- package/dist/components/FileUpload/FileUpload.js +113 -0
- package/dist/components/FileUpload/FileUploadDropZone.cjs +58 -0
- package/dist/components/FileUpload/FileUploadDropZone.js +55 -0
- package/dist/components/FileUpload/FileUploadIcons.cjs +55 -0
- package/dist/components/FileUpload/FileUploadIcons.js +50 -0
- package/dist/components/FileUpload/FileUploadItem.cjs +34 -0
- package/dist/components/FileUpload/FileUploadItem.js +31 -0
- package/dist/components/FileUpload/index.cjs +9 -0
- package/dist/components/FileUpload/index.js +3 -0
- package/dist/components/FormControl/Checkbox.cjs +27 -0
- package/dist/components/FormControl/Checkbox.js +24 -0
- package/dist/components/FormControl/Radio.cjs +15 -0
- package/dist/components/FormControl/Radio.js +12 -0
- package/dist/components/FormControl/Toggle.cjs +15 -0
- package/dist/components/FormControl/Toggle.js +12 -0
- package/dist/components/FormControl/index.cjs +9 -0
- package/dist/components/FormControl/index.js +3 -0
- package/dist/components/Icon/Icon.cjs +70 -0
- package/dist/components/Icon/Icon.js +34 -0
- package/dist/components/Icon/catalog.cjs +1672 -0
- package/dist/components/Icon/catalog.js +1669 -0
- package/dist/components/Icon/icons.cjs +5621 -0
- package/dist/components/Icon/icons.js +5610 -0
- package/dist/components/Icon/index.cjs +8 -0
- package/dist/components/Icon/index.js +2 -0
- package/dist/components/Input/Input.cjs +64 -0
- package/dist/components/Input/Input.js +61 -0
- package/dist/components/Input/index.cjs +5 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/MetricsCard/MetricsCard.cjs +107 -0
- package/dist/components/MetricsCard/MetricsCard.js +104 -0
- package/dist/components/MetricsCard/index.cjs +5 -0
- package/dist/components/MetricsCard/index.js +1 -0
- package/dist/components/Modal/Modal.cjs +126 -0
- package/dist/components/Modal/Modal.js +123 -0
- package/dist/components/Modal/index.cjs +5 -0
- package/dist/components/Modal/index.js +1 -0
- package/dist/components/Pagination/Pagination.cjs +42 -0
- package/dist/components/Pagination/Pagination.js +39 -0
- package/dist/components/Pagination/index.cjs +5 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/ProgressBar/ProgressBar.cjs +34 -0
- package/dist/components/ProgressBar/ProgressBar.js +31 -0
- package/dist/components/ProgressBar/index.cjs +5 -0
- package/dist/components/ProgressBar/index.js +1 -0
- package/dist/components/ProgressCircle/ProgressCircle.cjs +34 -0
- package/dist/components/ProgressCircle/ProgressCircle.js +31 -0
- package/dist/components/ProgressCircle/index.cjs +5 -0
- package/dist/components/ProgressCircle/index.js +1 -0
- package/dist/components/Select/Select.cjs +84 -0
- package/dist/components/Select/Select.js +80 -0
- package/dist/components/Select/SelectOption.cjs +26 -0
- package/dist/components/Select/SelectOption.js +23 -0
- package/dist/components/Select/index.cjs +7 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/SidebarMenu/SidebarMenu.cjs +85 -0
- package/dist/components/SidebarMenu/SidebarMenu.js +81 -0
- package/dist/components/SidebarMenu/SidebarMenuItem.cjs +126 -0
- package/dist/components/SidebarMenu/SidebarMenuItem.js +122 -0
- package/dist/components/SidebarMenu/SidebarMenuSection.cjs +14 -0
- package/dist/components/SidebarMenu/SidebarMenuSection.js +11 -0
- package/dist/components/SidebarMenu/index.cjs +12 -0
- package/dist/components/SidebarMenu/index.js +4 -0
- package/dist/components/Slider/Slider.cjs +161 -0
- package/dist/components/Slider/Slider.js +158 -0
- package/dist/components/Slider/index.cjs +6 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Spinner/Spinner.cjs +93 -0
- package/dist/components/Spinner/Spinner.js +90 -0
- package/dist/components/Spinner/index.cjs +5 -0
- package/dist/components/Spinner/index.js +1 -0
- package/dist/components/Stepper/Stepper.cjs +82 -0
- package/dist/components/Stepper/Stepper.js +79 -0
- package/dist/components/Stepper/index.cjs +7 -0
- package/dist/components/Stepper/index.js +1 -0
- package/dist/components/Table/Table.cjs +25 -0
- package/dist/components/Table/Table.js +22 -0
- package/dist/components/Table/index.cjs +10 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Table/useTableSelection.cjs +60 -0
- package/dist/components/Table/useTableSelection.js +57 -0
- package/dist/components/Tabs/Tab.cjs +70 -0
- package/dist/components/Tabs/Tab.js +67 -0
- package/dist/components/Tabs/Tabs.cjs +133 -0
- package/dist/components/Tabs/Tabs.js +129 -0
- package/dist/components/Tabs/index.cjs +7 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +101 -0
- package/dist/components/Tooltip/Tooltip.js +98 -0
- package/dist/components/Tooltip/index.cjs +5 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/context/ThemeContext.cjs +97 -0
- package/dist/context/ThemeContext.js +92 -0
- package/dist/fonts/README.md +13 -0
- package/dist/fonts/hanken-grotesk-cyrillic-ext-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-cyrillic-ext-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-ext-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-ext-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-vietnamese-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-vietnamese-normal.woff2 +0 -0
- package/dist/fonts/hankengrotesk-LICENSE.txt +94 -0
- package/dist/fonts/manrope-LICENSE.txt +93 -0
- package/dist/fonts/manrope-cyrillic-ext-normal.woff2 +0 -0
- package/dist/fonts/manrope-cyrillic-normal.woff2 +0 -0
- package/dist/fonts/manrope-greek-normal.woff2 +0 -0
- package/dist/fonts/manrope-latin-ext-normal.woff2 +0 -0
- package/dist/fonts/manrope-latin-normal.woff2 +0 -0
- package/dist/fonts/manrope-vietnamese-normal.woff2 +0 -0
- package/dist/fonts.css +148 -0
- package/dist/hooks/form/index.cjs +11 -0
- package/dist/hooks/form/index.js +3 -0
- package/dist/hooks/form/useRaydenFormControl.cjs +81 -0
- package/dist/hooks/form/useRaydenFormControl.js +76 -0
- package/dist/hooks/form/useRaydenInput.cjs +38 -0
- package/dist/hooks/form/useRaydenInput.js +35 -0
- package/dist/hooks/form/useRaydenSelect.cjs +45 -0
- package/dist/hooks/form/useRaydenSelect.js +42 -0
- package/dist/hooks/index.cjs +17 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useBodyScrollLock.cjs +24 -0
- package/dist/hooks/useBodyScrollLock.js +21 -0
- package/dist/hooks/useCollisionAwareSide.cjs +72 -0
- package/dist/hooks/useCollisionAwareSide.js +69 -0
- package/dist/hooks/useControllableValue.cjs +16 -0
- package/dist/hooks/useControllableValue.js +13 -0
- package/dist/hooks/useDismissableLayer.cjs +100 -0
- package/dist/hooks/useDismissableLayer.js +97 -0
- package/dist/hooks/usePopupList.cjs +101 -0
- package/dist/hooks/usePopupList.js +98 -0
- package/dist/icons-8yD7I5jO.d.cts +430 -0
- package/dist/icons-8yD7I5jO.d.ts +430 -0
- package/dist/icons.cjs +2111 -418
- package/dist/icons.d.cts +1256 -429
- package/dist/icons.d.ts +1256 -429
- package/dist/icons.js +2089 -1
- package/dist/index.cjs +128 -15046
- package/dist/index.d.cts +697 -662
- package/dist/index.d.ts +697 -662
- package/dist/index.js +43 -14962
- package/dist/motion/Collapse.cjs +28 -0
- package/dist/motion/Collapse.js +25 -0
- package/dist/motion/MotionProvider.cjs +43 -0
- package/dist/motion/MotionProvider.js +38 -0
- package/dist/motion/Pressable.cjs +46 -0
- package/dist/motion/Pressable.js +43 -0
- package/dist/motion/Reveal.cjs +19 -0
- package/dist/motion/Reveal.js +16 -0
- package/dist/motion/SharedLayout.cjs +46 -0
- package/dist/motion/SharedLayout.js +43 -0
- package/dist/motion/index.cjs +19 -0
- package/dist/motion/index.js +6 -0
- package/dist/motion/presence.cjs +58 -0
- package/dist/motion/presence.js +55 -0
- package/dist/motion/presets.cjs +88 -0
- package/dist/motion/presets.js +84 -0
- package/dist/motion.d.cts +51 -0
- package/dist/motion.d.ts +51 -0
- package/dist/preset.cjs +356 -195
- package/dist/preset.d.cts +111 -32
- package/dist/preset.d.ts +111 -32
- package/dist/preset.js +353 -187
- package/dist/presets-Ba5QndHg.d.cts +144 -0
- package/dist/presets-Ba5QndHg.d.ts +144 -0
- package/dist/styles.css +1 -1
- package/dist/utils/cn.cjs +38 -0
- package/dist/utils/cn.js +35 -0
- package/dist/utils/resolveIcon.cjs +18 -0
- package/dist/utils/resolveIcon.js +15 -0
- package/package.json +79 -21
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Button = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
7
|
+
const resolveIcon_1 = require("../../utils/resolveIcon.cjs");
|
|
8
|
+
const solidVariants = {
|
|
9
|
+
primary: "bg-action-primary text-white hover:bg-action-primary-hover",
|
|
10
|
+
secondary: "bg-transparent text-action-primary-text border-[1.5px] border-current hover:bg-primary-50",
|
|
11
|
+
grey: "bg-action-grey text-white hover:bg-action-grey-hover",
|
|
12
|
+
destructive: "bg-action-danger text-white hover:bg-action-danger-hover",
|
|
13
|
+
text: "bg-transparent text-action-primary-text hover:underline underline-offset-4",
|
|
14
|
+
success: "bg-action-success text-white hover:bg-action-success-hover",
|
|
15
|
+
warning: "bg-action-warning text-white hover:bg-action-warning-hover",
|
|
16
|
+
info: "bg-action-info text-white hover:bg-action-info-hover",
|
|
17
|
+
};
|
|
18
|
+
const outlinedVariants = {
|
|
19
|
+
primary: solidVariants.secondary,
|
|
20
|
+
secondary: solidVariants.secondary,
|
|
21
|
+
grey: "bg-transparent text-grey-700 border-[1.5px] border-grey-500 hover:bg-grey-100",
|
|
22
|
+
destructive: "bg-transparent text-action-danger-text border-[1.5px] border-current hover:bg-error-50",
|
|
23
|
+
text: solidVariants.text,
|
|
24
|
+
success: solidVariants.success,
|
|
25
|
+
warning: solidVariants.warning,
|
|
26
|
+
info: solidVariants.info,
|
|
27
|
+
};
|
|
28
|
+
const sizeClasses = {
|
|
29
|
+
sm: {
|
|
30
|
+
base: "h-9 text-sm rounded-lg",
|
|
31
|
+
none: "px-4 py-2",
|
|
32
|
+
icon: "px-3 py-2",
|
|
33
|
+
"icon-only": "p-2",
|
|
34
|
+
},
|
|
35
|
+
lg: {
|
|
36
|
+
base: "h-14 text-base rounded-lg",
|
|
37
|
+
none: "px-6 py-4",
|
|
38
|
+
icon: "p-4",
|
|
39
|
+
"icon-only": "p-4",
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
exports.Button = (0, react_1.forwardRef)(({ variant = "primary", appearance = "solid", size = "sm", icon, iconPosition = "none", className, children, disabled, type = "button", as, asChild = false, href, onClick, ...rest }, ref) => {
|
|
43
|
+
const variantClasses = appearance === "outlined" ? outlinedVariants[variant] : solidVariants[variant];
|
|
44
|
+
const sizeConfig = sizeClasses[size];
|
|
45
|
+
const paddingKey = iconPosition === "icon-only" ? "icon-only" : iconPosition !== "none" ? "icon" : "none";
|
|
46
|
+
const iconSizeClass = size === "sm" ? "size-5" : "size-6";
|
|
47
|
+
const resolvedIcon = (0, resolveIcon_1.resolveIcon)(icon, size === "sm" ? "md" : "lg");
|
|
48
|
+
const rootClassName = (0, cn_1.cn)("inline-flex items-center justify-center gap-2 font-semibold transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-action-primary-text cursor-pointer",
|
|
49
|
+
// `disabled:` only matches a form control. An anchor or a slotted child carries
|
|
50
|
+
// aria-disabled instead, so both spellings are present and the visual treatment
|
|
51
|
+
// is identical either way.
|
|
52
|
+
"disabled:cursor-not-allowed disabled:opacity-50", "aria-disabled:cursor-not-allowed aria-disabled:opacity-50", sizeConfig.base, sizeConfig[paddingKey], variantClasses, className);
|
|
53
|
+
const decorate = (label) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [iconPosition === "leading" && resolvedIcon && ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("shrink-0", iconSizeClass), children: resolvedIcon })), iconPosition === "icon-only" && resolvedIcon ? ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("shrink-0", iconSizeClass), children: resolvedIcon })) : (iconPosition !== "icon-only" && label), iconPosition === "trailing" && resolvedIcon && ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("shrink-0", iconSizeClass), children: resolvedIcon }))] }));
|
|
54
|
+
/**
|
|
55
|
+
* A disabled anchor does not exist in HTML: `disabled` is a form-control
|
|
56
|
+
* attribute and an anchor keeps navigating with it. Rather than render a link
|
|
57
|
+
* that still works, Button drops `href` (so nothing can navigate, including
|
|
58
|
+
* middle-click and "open in new tab"), keeps the element discoverable and
|
|
59
|
+
* focusable with `role="link"` + `aria-disabled="true"` + `tabIndex={0}`, and
|
|
60
|
+
* swallows activation. This is the aria-disabled pattern: still perceivable,
|
|
61
|
+
* not actionable. The visual treatment matches a disabled `<button>`.
|
|
62
|
+
*/
|
|
63
|
+
const swallow = (event) => {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
event.stopPropagation();
|
|
66
|
+
};
|
|
67
|
+
if (asChild) {
|
|
68
|
+
const child = react_1.Children.only(children);
|
|
69
|
+
if (!(0, react_1.isValidElement)(child))
|
|
70
|
+
return null;
|
|
71
|
+
const childProps = child.props;
|
|
72
|
+
return (0, react_1.cloneElement)(child, {
|
|
73
|
+
...rest,
|
|
74
|
+
...(href !== undefined && !disabled ? { href } : {}),
|
|
75
|
+
...(disabled ? { "aria-disabled": true, onClick: swallow, tabIndex: 0 } : { onClick }),
|
|
76
|
+
ref,
|
|
77
|
+
className: (0, cn_1.cn)(rootClassName, childProps.className),
|
|
78
|
+
}, decorate(childProps.children));
|
|
79
|
+
}
|
|
80
|
+
if (as === "a") {
|
|
81
|
+
const anchorState = (disabled
|
|
82
|
+
? { role: "link", "aria-disabled": true, tabIndex: 0, onClick: swallow }
|
|
83
|
+
: { href, onClick });
|
|
84
|
+
return ((0, jsx_runtime_1.jsx)("a", { ref: ref, ...anchorState, className: rootClassName, ...rest, children: decorate(children) }));
|
|
85
|
+
}
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)("button", { ref: ref, type: type, disabled: disabled, onClick: onClick, className: rootClassName, ...rest, children: decorate(children) }));
|
|
87
|
+
});
|
|
88
|
+
exports.Button.displayName = "Button";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, forwardRef, isValidElement, } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { resolveIcon } from "../../utils/resolveIcon.js";
|
|
5
|
+
const solidVariants = {
|
|
6
|
+
primary: "bg-action-primary text-white hover:bg-action-primary-hover",
|
|
7
|
+
secondary: "bg-transparent text-action-primary-text border-[1.5px] border-current hover:bg-primary-50",
|
|
8
|
+
grey: "bg-action-grey text-white hover:bg-action-grey-hover",
|
|
9
|
+
destructive: "bg-action-danger text-white hover:bg-action-danger-hover",
|
|
10
|
+
text: "bg-transparent text-action-primary-text hover:underline underline-offset-4",
|
|
11
|
+
success: "bg-action-success text-white hover:bg-action-success-hover",
|
|
12
|
+
warning: "bg-action-warning text-white hover:bg-action-warning-hover",
|
|
13
|
+
info: "bg-action-info text-white hover:bg-action-info-hover",
|
|
14
|
+
};
|
|
15
|
+
const outlinedVariants = {
|
|
16
|
+
primary: solidVariants.secondary,
|
|
17
|
+
secondary: solidVariants.secondary,
|
|
18
|
+
grey: "bg-transparent text-grey-700 border-[1.5px] border-grey-500 hover:bg-grey-100",
|
|
19
|
+
destructive: "bg-transparent text-action-danger-text border-[1.5px] border-current hover:bg-error-50",
|
|
20
|
+
text: solidVariants.text,
|
|
21
|
+
success: solidVariants.success,
|
|
22
|
+
warning: solidVariants.warning,
|
|
23
|
+
info: solidVariants.info,
|
|
24
|
+
};
|
|
25
|
+
const sizeClasses = {
|
|
26
|
+
sm: {
|
|
27
|
+
base: "h-9 text-sm rounded-lg",
|
|
28
|
+
none: "px-4 py-2",
|
|
29
|
+
icon: "px-3 py-2",
|
|
30
|
+
"icon-only": "p-2",
|
|
31
|
+
},
|
|
32
|
+
lg: {
|
|
33
|
+
base: "h-14 text-base rounded-lg",
|
|
34
|
+
none: "px-6 py-4",
|
|
35
|
+
icon: "p-4",
|
|
36
|
+
"icon-only": "p-4",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const Button = forwardRef(({ variant = "primary", appearance = "solid", size = "sm", icon, iconPosition = "none", className, children, disabled, type = "button", as, asChild = false, href, onClick, ...rest }, ref) => {
|
|
40
|
+
const variantClasses = appearance === "outlined" ? outlinedVariants[variant] : solidVariants[variant];
|
|
41
|
+
const sizeConfig = sizeClasses[size];
|
|
42
|
+
const paddingKey = iconPosition === "icon-only" ? "icon-only" : iconPosition !== "none" ? "icon" : "none";
|
|
43
|
+
const iconSizeClass = size === "sm" ? "size-5" : "size-6";
|
|
44
|
+
const resolvedIcon = resolveIcon(icon, size === "sm" ? "md" : "lg");
|
|
45
|
+
const rootClassName = cn("inline-flex items-center justify-center gap-2 font-semibold transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-action-primary-text cursor-pointer",
|
|
46
|
+
// `disabled:` only matches a form control. An anchor or a slotted child carries
|
|
47
|
+
// aria-disabled instead, so both spellings are present and the visual treatment
|
|
48
|
+
// is identical either way.
|
|
49
|
+
"disabled:cursor-not-allowed disabled:opacity-50", "aria-disabled:cursor-not-allowed aria-disabled:opacity-50", sizeConfig.base, sizeConfig[paddingKey], variantClasses, className);
|
|
50
|
+
const decorate = (label) => (_jsxs(_Fragment, { children: [iconPosition === "leading" && resolvedIcon && (_jsx("span", { className: cn("shrink-0", iconSizeClass), children: resolvedIcon })), iconPosition === "icon-only" && resolvedIcon ? (_jsx("span", { className: cn("shrink-0", iconSizeClass), children: resolvedIcon })) : (iconPosition !== "icon-only" && label), iconPosition === "trailing" && resolvedIcon && (_jsx("span", { className: cn("shrink-0", iconSizeClass), children: resolvedIcon }))] }));
|
|
51
|
+
/**
|
|
52
|
+
* A disabled anchor does not exist in HTML: `disabled` is a form-control
|
|
53
|
+
* attribute and an anchor keeps navigating with it. Rather than render a link
|
|
54
|
+
* that still works, Button drops `href` (so nothing can navigate, including
|
|
55
|
+
* middle-click and "open in new tab"), keeps the element discoverable and
|
|
56
|
+
* focusable with `role="link"` + `aria-disabled="true"` + `tabIndex={0}`, and
|
|
57
|
+
* swallows activation. This is the aria-disabled pattern: still perceivable,
|
|
58
|
+
* not actionable. The visual treatment matches a disabled `<button>`.
|
|
59
|
+
*/
|
|
60
|
+
const swallow = (event) => {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
};
|
|
64
|
+
if (asChild) {
|
|
65
|
+
const child = Children.only(children);
|
|
66
|
+
if (!isValidElement(child))
|
|
67
|
+
return null;
|
|
68
|
+
const childProps = child.props;
|
|
69
|
+
return cloneElement(child, {
|
|
70
|
+
...rest,
|
|
71
|
+
...(href !== undefined && !disabled ? { href } : {}),
|
|
72
|
+
...(disabled ? { "aria-disabled": true, onClick: swallow, tabIndex: 0 } : { onClick }),
|
|
73
|
+
ref,
|
|
74
|
+
className: cn(rootClassName, childProps.className),
|
|
75
|
+
}, decorate(childProps.children));
|
|
76
|
+
}
|
|
77
|
+
if (as === "a") {
|
|
78
|
+
const anchorState = (disabled
|
|
79
|
+
? { role: "link", "aria-disabled": true, tabIndex: 0, onClick: swallow }
|
|
80
|
+
: { href, onClick });
|
|
81
|
+
return (_jsx("a", { ref: ref, ...anchorState, className: rootClassName, ...rest, children: decorate(children) }));
|
|
82
|
+
}
|
|
83
|
+
return (_jsx("button", { ref: ref, type: type, disabled: disabled, onClick: onClick, className: rootClassName, ...rest, children: decorate(children) }));
|
|
84
|
+
});
|
|
85
|
+
Button.displayName = "Button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button } from "./Button.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ButtonGroup = ButtonGroup;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
6
|
+
function ButtonGroup({ children, className }) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("inline-flex", className), role: "group", children: children }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ButtonGroupItem = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
7
|
+
const resolveIcon_1 = require("../../utils/resolveIcon.cjs");
|
|
8
|
+
exports.ButtonGroupItem = (0, react_1.forwardRef)(({ leadingIcon, trailingIcon, active = false, disabled = false, className, children, type = "button", ...rest }, ref) => {
|
|
9
|
+
return ((0, jsx_runtime_1.jsxs)("button", { ref: ref, type: type, disabled: disabled, "aria-pressed": active, className: (0, cn_1.cn)("inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors", "border-y border-r border-control-border", "first:rounded-l-lg first:border-l", "last:rounded-r-lg", active
|
|
10
|
+
? "bg-action-primary text-white border-action-primary"
|
|
11
|
+
: disabled
|
|
12
|
+
? "bg-surface text-grey-300 cursor-not-allowed"
|
|
13
|
+
: "bg-surface text-on-surface-secondary hover:bg-grey-100 cursor-pointer", className), ...rest, children: [leadingIcon && (0, jsx_runtime_1.jsx)("span", { className: "shrink-0 size-5", children: (0, resolveIcon_1.resolveIcon)(leadingIcon, "md") }), children, trailingIcon && (0, jsx_runtime_1.jsx)("span", { className: "shrink-0 size-5", children: (0, resolveIcon_1.resolveIcon)(trailingIcon, "md") })] }));
|
|
14
|
+
});
|
|
15
|
+
exports.ButtonGroupItem.displayName = "ButtonGroupItem";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { resolveIcon } from "../../utils/resolveIcon.js";
|
|
5
|
+
export const ButtonGroupItem = forwardRef(({ leadingIcon, trailingIcon, active = false, disabled = false, className, children, type = "button", ...rest }, ref) => {
|
|
6
|
+
return (_jsxs("button", { ref: ref, type: type, disabled: disabled, "aria-pressed": active, className: cn("inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors", "border-y border-r border-control-border", "first:rounded-l-lg first:border-l", "last:rounded-r-lg", active
|
|
7
|
+
? "bg-action-primary text-white border-action-primary"
|
|
8
|
+
: disabled
|
|
9
|
+
? "bg-surface text-grey-300 cursor-not-allowed"
|
|
10
|
+
: "bg-surface text-on-surface-secondary hover:bg-grey-100 cursor-pointer", className), ...rest, children: [leadingIcon && _jsx("span", { className: "shrink-0 size-5", children: resolveIcon(leadingIcon, "md") }), children, trailingIcon && _jsx("span", { className: "shrink-0 size-5", children: resolveIcon(trailingIcon, "md") })] }));
|
|
11
|
+
});
|
|
12
|
+
ButtonGroupItem.displayName = "ButtonGroupItem";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ButtonGroupItem = exports.ButtonGroup = void 0;
|
|
4
|
+
var ButtonGroup_1 = require("./ButtonGroup.cjs");
|
|
5
|
+
Object.defineProperty(exports, "ButtonGroup", { enumerable: true, get: function () { return ButtonGroup_1.ButtonGroup; } });
|
|
6
|
+
var ButtonGroupItem_1 = require("./ButtonGroupItem.cjs");
|
|
7
|
+
Object.defineProperty(exports, "ButtonGroupItem", { enumerable: true, get: function () { return ButtonGroupItem_1.ButtonGroupItem; } });
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CardImage = exports.CardFooter = exports.CardBody = exports.CardHeader = exports.Card = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
7
|
+
const CardContext = (0, react_1.createContext)(null);
|
|
8
|
+
function useCardContext() {
|
|
9
|
+
const ctx = (0, react_1.useContext)(CardContext);
|
|
10
|
+
// Return defaults if used outside Card (allows standalone usage)
|
|
11
|
+
return ctx ?? { size: "md" };
|
|
12
|
+
}
|
|
13
|
+
/* ─── Style Lookups ────────────────────────────────────────────────────── */
|
|
14
|
+
const variantStyles = {
|
|
15
|
+
default: "border border-grey-200 bg-surface",
|
|
16
|
+
outlined: "border-2 border-surface-border-strong bg-transparent",
|
|
17
|
+
elevated: "border border-grey-100 bg-surface shadow-soft-md",
|
|
18
|
+
ghost: "border-none bg-transparent",
|
|
19
|
+
};
|
|
20
|
+
const sizeStyles = {
|
|
21
|
+
sm: {
|
|
22
|
+
header: "px-4 py-3",
|
|
23
|
+
body: "px-4 py-3",
|
|
24
|
+
footer: "px-4 py-3",
|
|
25
|
+
},
|
|
26
|
+
md: {
|
|
27
|
+
header: "px-5 py-4",
|
|
28
|
+
body: "px-5 py-4",
|
|
29
|
+
footer: "px-5 py-4",
|
|
30
|
+
},
|
|
31
|
+
lg: {
|
|
32
|
+
header: "px-6 py-5",
|
|
33
|
+
body: "px-6 py-5",
|
|
34
|
+
footer: "px-6 py-5",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const roundedStyles = {
|
|
38
|
+
sm: "rounded-lg",
|
|
39
|
+
md: "rounded-[10px]",
|
|
40
|
+
lg: "rounded-xl",
|
|
41
|
+
xl: "rounded-2xl",
|
|
42
|
+
full: "rounded-3xl",
|
|
43
|
+
};
|
|
44
|
+
const shadowStyles = {
|
|
45
|
+
none: "",
|
|
46
|
+
sm: "shadow-soft-xxs",
|
|
47
|
+
md: "shadow-soft-xs",
|
|
48
|
+
lg: "shadow-soft-sm",
|
|
49
|
+
};
|
|
50
|
+
const footerAlignStyles = {
|
|
51
|
+
left: "justify-start",
|
|
52
|
+
center: "justify-center",
|
|
53
|
+
right: "justify-end",
|
|
54
|
+
between: "justify-between",
|
|
55
|
+
};
|
|
56
|
+
const aspectRatioStyles = {
|
|
57
|
+
auto: "",
|
|
58
|
+
video: "aspect-video",
|
|
59
|
+
square: "aspect-square",
|
|
60
|
+
portrait: "aspect-[3/4]",
|
|
61
|
+
};
|
|
62
|
+
/* ─── Card ─────────────────────────────────────────────────────────────── */
|
|
63
|
+
exports.Card = (0, react_1.forwardRef)(({ variant = "default", size = "md", rounded = "lg", shadow = "sm", hoverable = false, className, children, ...rest }, ref) => {
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)(CardContext.Provider, { value: { size }, children: (0, jsx_runtime_1.jsx)("div", { ref: ref, className: (0, cn_1.cn)("flex flex-col overflow-hidden", variantStyles[variant], roundedStyles[rounded], variant !== "elevated" && shadowStyles[shadow], hoverable && "transition-shadow duration-200 hover:shadow-soft-md", className), ...rest, children: children }) }));
|
|
65
|
+
});
|
|
66
|
+
exports.Card.displayName = "Card";
|
|
67
|
+
/* ─── CardHeader ───────────────────────────────────────────────────────── */
|
|
68
|
+
exports.CardHeader = (0, react_1.forwardRef)(({ title, subtitle, actions, bordered = false, className, children, ...rest }, ref) => {
|
|
69
|
+
const { size } = useCardContext();
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, cn_1.cn)("flex items-start justify-between gap-4", sizeStyles[size].header, bordered && "border-b border-grey-200", className), ...rest, children: [(title || subtitle || children) && ((0, jsx_runtime_1.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [title && ((0, jsx_runtime_1.jsx)("h3", { className: "text-lg font-semibold leading-[1.45] text-on-surface", children: title })), subtitle && (0, jsx_runtime_1.jsx)("p", { className: "text-sm leading-[1.45] text-on-surface-muted", children: subtitle }), children] })), actions && (0, jsx_runtime_1.jsx)("div", { className: "flex shrink-0 items-center gap-2", children: actions })] }));
|
|
71
|
+
});
|
|
72
|
+
exports.CardHeader.displayName = "CardHeader";
|
|
73
|
+
/* ─── CardBody ─────────────────────────────────────────────────────────── */
|
|
74
|
+
exports.CardBody = (0, react_1.forwardRef)(({ noPadding = false, className, children, ...rest }, ref) => {
|
|
75
|
+
const { size } = useCardContext();
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: (0, cn_1.cn)("flex-1", !noPadding && sizeStyles[size].body, className), ...rest, children: children }));
|
|
77
|
+
});
|
|
78
|
+
exports.CardBody.displayName = "CardBody";
|
|
79
|
+
/* ─── CardFooter ───────────────────────────────────────────────────────── */
|
|
80
|
+
exports.CardFooter = (0, react_1.forwardRef)(({ align = "right", bordered = false, className, children, ...rest }, ref) => {
|
|
81
|
+
const { size } = useCardContext();
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: (0, cn_1.cn)("flex items-center gap-3", sizeStyles[size].footer, footerAlignStyles[align], bordered && "border-t border-grey-200", className), ...rest, children: children }));
|
|
83
|
+
});
|
|
84
|
+
exports.CardFooter.displayName = "CardFooter";
|
|
85
|
+
/* ─── CardImage ────────────────────────────────────────────────────────── */
|
|
86
|
+
exports.CardImage = (0, react_1.forwardRef)(({ position = "top", aspectRatio = "auto", objectFit = "cover", alt, className, ...rest }, ref) => {
|
|
87
|
+
const objectFitClasses = {
|
|
88
|
+
cover: "object-cover",
|
|
89
|
+
contain: "object-contain",
|
|
90
|
+
fill: "object-fill",
|
|
91
|
+
};
|
|
92
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("w-full overflow-hidden", position === "top" && "first:rounded-t-[inherit]", position === "bottom" && "last:rounded-b-[inherit]", position === "full" && "first:rounded-t-[inherit] last:rounded-b-[inherit]"), children: (0, jsx_runtime_1.jsx)("img", { ref: ref, alt: alt, className: (0, cn_1.cn)("w-full", aspectRatioStyles[aspectRatio], objectFitClasses[objectFit], className), ...rest }) }));
|
|
93
|
+
});
|
|
94
|
+
exports.CardImage.displayName = "CardImage";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, forwardRef, useContext, } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
const CardContext = createContext(null);
|
|
5
|
+
function useCardContext() {
|
|
6
|
+
const ctx = useContext(CardContext);
|
|
7
|
+
// Return defaults if used outside Card (allows standalone usage)
|
|
8
|
+
return ctx ?? { size: "md" };
|
|
9
|
+
}
|
|
10
|
+
/* ─── Style Lookups ────────────────────────────────────────────────────── */
|
|
11
|
+
const variantStyles = {
|
|
12
|
+
default: "border border-grey-200 bg-surface",
|
|
13
|
+
outlined: "border-2 border-surface-border-strong bg-transparent",
|
|
14
|
+
elevated: "border border-grey-100 bg-surface shadow-soft-md",
|
|
15
|
+
ghost: "border-none bg-transparent",
|
|
16
|
+
};
|
|
17
|
+
const sizeStyles = {
|
|
18
|
+
sm: {
|
|
19
|
+
header: "px-4 py-3",
|
|
20
|
+
body: "px-4 py-3",
|
|
21
|
+
footer: "px-4 py-3",
|
|
22
|
+
},
|
|
23
|
+
md: {
|
|
24
|
+
header: "px-5 py-4",
|
|
25
|
+
body: "px-5 py-4",
|
|
26
|
+
footer: "px-5 py-4",
|
|
27
|
+
},
|
|
28
|
+
lg: {
|
|
29
|
+
header: "px-6 py-5",
|
|
30
|
+
body: "px-6 py-5",
|
|
31
|
+
footer: "px-6 py-5",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const roundedStyles = {
|
|
35
|
+
sm: "rounded-lg",
|
|
36
|
+
md: "rounded-[10px]",
|
|
37
|
+
lg: "rounded-xl",
|
|
38
|
+
xl: "rounded-2xl",
|
|
39
|
+
full: "rounded-3xl",
|
|
40
|
+
};
|
|
41
|
+
const shadowStyles = {
|
|
42
|
+
none: "",
|
|
43
|
+
sm: "shadow-soft-xxs",
|
|
44
|
+
md: "shadow-soft-xs",
|
|
45
|
+
lg: "shadow-soft-sm",
|
|
46
|
+
};
|
|
47
|
+
const footerAlignStyles = {
|
|
48
|
+
left: "justify-start",
|
|
49
|
+
center: "justify-center",
|
|
50
|
+
right: "justify-end",
|
|
51
|
+
between: "justify-between",
|
|
52
|
+
};
|
|
53
|
+
const aspectRatioStyles = {
|
|
54
|
+
auto: "",
|
|
55
|
+
video: "aspect-video",
|
|
56
|
+
square: "aspect-square",
|
|
57
|
+
portrait: "aspect-[3/4]",
|
|
58
|
+
};
|
|
59
|
+
/* ─── Card ─────────────────────────────────────────────────────────────── */
|
|
60
|
+
export const Card = forwardRef(({ variant = "default", size = "md", rounded = "lg", shadow = "sm", hoverable = false, className, children, ...rest }, ref) => {
|
|
61
|
+
return (_jsx(CardContext.Provider, { value: { size }, children: _jsx("div", { ref: ref, className: cn("flex flex-col overflow-hidden", variantStyles[variant], roundedStyles[rounded], variant !== "elevated" && shadowStyles[shadow], hoverable && "transition-shadow duration-200 hover:shadow-soft-md", className), ...rest, children: children }) }));
|
|
62
|
+
});
|
|
63
|
+
Card.displayName = "Card";
|
|
64
|
+
/* ─── CardHeader ───────────────────────────────────────────────────────── */
|
|
65
|
+
export const CardHeader = forwardRef(({ title, subtitle, actions, bordered = false, className, children, ...rest }, ref) => {
|
|
66
|
+
const { size } = useCardContext();
|
|
67
|
+
return (_jsxs("div", { ref: ref, className: cn("flex items-start justify-between gap-4", sizeStyles[size].header, bordered && "border-b border-grey-200", className), ...rest, children: [(title || subtitle || children) && (_jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [title && (_jsx("h3", { className: "text-lg font-semibold leading-[1.45] text-on-surface", children: title })), subtitle && _jsx("p", { className: "text-sm leading-[1.45] text-on-surface-muted", children: subtitle }), children] })), actions && _jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions })] }));
|
|
68
|
+
});
|
|
69
|
+
CardHeader.displayName = "CardHeader";
|
|
70
|
+
/* ─── CardBody ─────────────────────────────────────────────────────────── */
|
|
71
|
+
export const CardBody = forwardRef(({ noPadding = false, className, children, ...rest }, ref) => {
|
|
72
|
+
const { size } = useCardContext();
|
|
73
|
+
return (_jsx("div", { ref: ref, className: cn("flex-1", !noPadding && sizeStyles[size].body, className), ...rest, children: children }));
|
|
74
|
+
});
|
|
75
|
+
CardBody.displayName = "CardBody";
|
|
76
|
+
/* ─── CardFooter ───────────────────────────────────────────────────────── */
|
|
77
|
+
export const CardFooter = forwardRef(({ align = "right", bordered = false, className, children, ...rest }, ref) => {
|
|
78
|
+
const { size } = useCardContext();
|
|
79
|
+
return (_jsx("div", { ref: ref, className: cn("flex items-center gap-3", sizeStyles[size].footer, footerAlignStyles[align], bordered && "border-t border-grey-200", className), ...rest, children: children }));
|
|
80
|
+
});
|
|
81
|
+
CardFooter.displayName = "CardFooter";
|
|
82
|
+
/* ─── CardImage ────────────────────────────────────────────────────────── */
|
|
83
|
+
export const CardImage = forwardRef(({ position = "top", aspectRatio = "auto", objectFit = "cover", alt, className, ...rest }, ref) => {
|
|
84
|
+
const objectFitClasses = {
|
|
85
|
+
cover: "object-cover",
|
|
86
|
+
contain: "object-contain",
|
|
87
|
+
fill: "object-fill",
|
|
88
|
+
};
|
|
89
|
+
return (_jsx("div", { className: cn("w-full overflow-hidden", position === "top" && "first:rounded-t-[inherit]", position === "bottom" && "last:rounded-b-[inherit]", position === "full" && "first:rounded-t-[inherit] last:rounded-b-[inherit]"), children: _jsx("img", { ref: ref, alt: alt, className: cn("w-full", aspectRatioStyles[aspectRatio], objectFitClasses[objectFit], className), ...rest }) }));
|
|
90
|
+
});
|
|
91
|
+
CardImage.displayName = "CardImage";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CardImage = exports.CardFooter = exports.CardBody = exports.CardHeader = exports.Card = void 0;
|
|
4
|
+
var Card_1 = require("./Card.cjs");
|
|
5
|
+
Object.defineProperty(exports, "Card", { enumerable: true, get: function () { return Card_1.Card; } });
|
|
6
|
+
Object.defineProperty(exports, "CardHeader", { enumerable: true, get: function () { return Card_1.CardHeader; } });
|
|
7
|
+
Object.defineProperty(exports, "CardBody", { enumerable: true, get: function () { return Card_1.CardBody; } });
|
|
8
|
+
Object.defineProperty(exports, "CardFooter", { enumerable: true, get: function () { return Card_1.CardFooter; } });
|
|
9
|
+
Object.defineProperty(exports, "CardImage", { enumerable: true, get: function () { return Card_1.CardImage; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Card, CardHeader, CardBody, CardFooter, CardImage } from "./Card.js";
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGradientFill = exports.hexToRgba = exports.chartFont = exports.chartColors = exports.RaydenChart = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const chart_js_1 = require("chart.js");
|
|
7
|
+
const react_chartjs_2_1 = require("react-chartjs-2");
|
|
8
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
9
|
+
const theme_1 = require("./theme.cjs");
|
|
10
|
+
// Register Chart.js components
|
|
11
|
+
chart_js_1.Chart.register(chart_js_1.CategoryScale, chart_js_1.LinearScale, chart_js_1.PointElement, chart_js_1.LineElement, chart_js_1.BarElement, chart_js_1.ArcElement, chart_js_1.RadialLinearScale, chart_js_1.Filler, chart_js_1.Tooltip, chart_js_1.Legend);
|
|
12
|
+
/* ─── Default Options ──────────────────────────────────────────────────── */
|
|
13
|
+
function getDefaultOptions(type) {
|
|
14
|
+
const base = {
|
|
15
|
+
responsive: true,
|
|
16
|
+
maintainAspectRatio: false,
|
|
17
|
+
plugins: {
|
|
18
|
+
legend: {
|
|
19
|
+
display: true,
|
|
20
|
+
position: "bottom",
|
|
21
|
+
labels: {
|
|
22
|
+
font: { ...theme_1.chartFont, size: 12 },
|
|
23
|
+
color: theme_1.chartColors.grey[500],
|
|
24
|
+
padding: 16,
|
|
25
|
+
usePointStyle: true,
|
|
26
|
+
pointStyle: "circle",
|
|
27
|
+
boxWidth: 8,
|
|
28
|
+
boxHeight: 8,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
tooltip: {
|
|
32
|
+
backgroundColor: theme_1.chartColors.grey[900],
|
|
33
|
+
titleFont: { ...theme_1.chartFont, weight: "bold", size: 13 },
|
|
34
|
+
bodyFont: { ...theme_1.chartFont, size: 12 },
|
|
35
|
+
cornerRadius: 8,
|
|
36
|
+
padding: 12,
|
|
37
|
+
boxPadding: 6,
|
|
38
|
+
usePointStyle: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
if (type === "line" || type === "bar" || type === "scatter" || type === "bubble") {
|
|
43
|
+
base.scales = {
|
|
44
|
+
x: {
|
|
45
|
+
grid: { color: theme_1.chartColors.grey[100], drawTicks: false },
|
|
46
|
+
ticks: { font: theme_1.chartFont, color: theme_1.chartColors.grey[400], padding: 8 },
|
|
47
|
+
border: { display: false },
|
|
48
|
+
},
|
|
49
|
+
y: {
|
|
50
|
+
grid: { color: theme_1.chartColors.grey[100], drawTicks: false },
|
|
51
|
+
ticks: { font: theme_1.chartFont, color: theme_1.chartColors.grey[400], padding: 8 },
|
|
52
|
+
border: { display: false },
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (type === "line") {
|
|
57
|
+
base.elements = {
|
|
58
|
+
line: { tension: 0.4, borderWidth: 2 },
|
|
59
|
+
point: { radius: 0, hoverRadius: 5, hitRadius: 20 },
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (type === "bar") {
|
|
63
|
+
base.elements = {
|
|
64
|
+
bar: { borderRadius: 4 },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (type === "radar") {
|
|
68
|
+
base.scales = {
|
|
69
|
+
r: {
|
|
70
|
+
grid: { color: theme_1.chartColors.grey[200] },
|
|
71
|
+
angleLines: { color: theme_1.chartColors.grey[200] },
|
|
72
|
+
pointLabels: { font: { ...theme_1.chartFont, size: 11 }, color: theme_1.chartColors.grey[500] },
|
|
73
|
+
ticks: { display: false },
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (type === "polar-area") {
|
|
78
|
+
base.scales = {
|
|
79
|
+
r: {
|
|
80
|
+
grid: { color: theme_1.chartColors.grey[200] },
|
|
81
|
+
ticks: { display: false },
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return base;
|
|
86
|
+
}
|
|
87
|
+
/* ─── Merge Options ────────────────────────────────────────────────────── */
|
|
88
|
+
function deepMerge(target, source) {
|
|
89
|
+
const output = { ...target };
|
|
90
|
+
for (const key of Object.keys(source)) {
|
|
91
|
+
if (source[key] &&
|
|
92
|
+
typeof source[key] === "object" &&
|
|
93
|
+
!Array.isArray(source[key]) &&
|
|
94
|
+
target[key] &&
|
|
95
|
+
typeof target[key] === "object") {
|
|
96
|
+
output[key] = deepMerge(target[key], source[key]);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
output[key] = source[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return output;
|
|
103
|
+
}
|
|
104
|
+
/* ─── Chart Component ──────────────────────────────────────────────────── */
|
|
105
|
+
/** Render one dataset value as text for the accessible table. */
|
|
106
|
+
function formatCell(value) {
|
|
107
|
+
if (value == null)
|
|
108
|
+
return "—";
|
|
109
|
+
if (typeof value === "number" || typeof value === "string")
|
|
110
|
+
return String(value);
|
|
111
|
+
if (typeof value === "object") {
|
|
112
|
+
const point = value;
|
|
113
|
+
if ("y" in point) {
|
|
114
|
+
const xy = `${String(point.x ?? "")}, ${String(point.y ?? "")}`;
|
|
115
|
+
return "r" in point ? `${xy}, ${String(point.r)}` : xy;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return String(value);
|
|
119
|
+
}
|
|
120
|
+
const chartComponentMap = {
|
|
121
|
+
line: react_chartjs_2_1.Line,
|
|
122
|
+
bar: react_chartjs_2_1.Bar,
|
|
123
|
+
pie: react_chartjs_2_1.Pie,
|
|
124
|
+
doughnut: react_chartjs_2_1.Doughnut,
|
|
125
|
+
radar: react_chartjs_2_1.Radar,
|
|
126
|
+
scatter: react_chartjs_2_1.Scatter,
|
|
127
|
+
bubble: react_chartjs_2_1.Bubble,
|
|
128
|
+
"polar-area": react_chartjs_2_1.PolarArea,
|
|
129
|
+
};
|
|
130
|
+
exports.RaydenChart = (0, react_1.forwardRef)(({ type, data, options, height = 300, width, className, title, summary, dataTable = true, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...rest }, ref) => {
|
|
131
|
+
const mergedOptions = (0, react_1.useMemo)(() => deepMerge(getDefaultOptions(type), options ?? {}), [type, options]);
|
|
132
|
+
const ChartComponent = chartComponentMap[type];
|
|
133
|
+
const generatedId = (0, react_1.useId)();
|
|
134
|
+
const summaryId = summary ? `${generatedId}-summary` : undefined;
|
|
135
|
+
const tableId = `${generatedId}-table`;
|
|
136
|
+
// react-chartjs-2 hardcodes role="img" on the canvas. Without a name that is an
|
|
137
|
+
// unlabelled image; without a tabular equivalent the values are canvas-only.
|
|
138
|
+
const labels = (data?.labels ?? []);
|
|
139
|
+
const datasets = (data?.datasets ?? []);
|
|
140
|
+
// Scatter and bubble data carries no `labels` — its points are {x, y} / {x, y, r}
|
|
141
|
+
// objects. Keying the table off labels alone left those charts with no alternative
|
|
142
|
+
// at all, so fall back to one row per point index.
|
|
143
|
+
const rowCount = labels.length || Math.max(0, ...datasets.map((d) => d.data?.length ?? 0));
|
|
144
|
+
const pointBased = labels.length === 0;
|
|
145
|
+
const showTable = dataTable && rowCount > 0 && datasets.length > 0;
|
|
146
|
+
// Last-resort name so the canvas is never an unnamed role="img". Callers should
|
|
147
|
+
// pass a meaningful `title`; this only keeps the default case from being nameless.
|
|
148
|
+
const fallbackName = `${type.replace("-", " ")} chart`;
|
|
149
|
+
const resolvedName = title ?? ariaLabel ?? fallbackName;
|
|
150
|
+
const describedBy = [ariaDescribedBy, summaryId, showTable ? tableId : undefined].filter(Boolean).join(" ") ||
|
|
151
|
+
undefined;
|
|
152
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, cn_1.cn)("relative", className), style: { height, width }, ...rest, children: [(0, jsx_runtime_1.jsx)(ChartComponent, { data: data, options: mergedOptions, "aria-label": ariaLabelledBy ? undefined : resolvedName, "aria-labelledby": ariaLabelledBy, "aria-describedby": describedBy, fallbackContent: (0, jsx_runtime_1.jsx)("p", { children: resolvedName }) }), summary && ((0, jsx_runtime_1.jsx)("p", { id: summaryId, className: "sr-only", children: summary })), showTable && ((0, jsx_runtime_1.jsxs)("table", { id: tableId, className: "sr-only", children: [(0, jsx_runtime_1.jsx)("caption", { children: `${resolvedName} — data table` }), (0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { scope: "col", children: pointBased ? "Point" : "Category" }), datasets.map((set, i) => ((0, jsx_runtime_1.jsx)("th", { scope: "col", children: set.label ?? `Series ${i + 1}` }, i)))] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: Array.from({ length: rowCount }, (_, row) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { scope: "row", children: pointBased ? row + 1 : String(labels[row]) }), datasets.map((set, i) => ((0, jsx_runtime_1.jsx)("td", { children: formatCell(set.data?.[row]) }, i)))] }, row))) })] }))] }));
|
|
153
|
+
});
|
|
154
|
+
exports.RaydenChart.displayName = "RaydenChart";
|
|
155
|
+
/* ─── Re-export theme utilities ────────────────────────────────────────── */
|
|
156
|
+
var theme_2 = require("./theme.cjs");
|
|
157
|
+
Object.defineProperty(exports, "chartColors", { enumerable: true, get: function () { return theme_2.chartColors; } });
|
|
158
|
+
Object.defineProperty(exports, "chartFont", { enumerable: true, get: function () { return theme_2.chartFont; } });
|
|
159
|
+
Object.defineProperty(exports, "hexToRgba", { enumerable: true, get: function () { return theme_2.hexToRgba; } });
|
|
160
|
+
Object.defineProperty(exports, "createGradientFill", { enumerable: true, get: function () { return theme_2.createGradientFill; } });
|