@slipstream-ui/core 0.11.7 → 0.11.9
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/index.d.mts +68 -10
- package/dist/index.d.ts +68 -10
- package/dist/index.js +609 -472
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +608 -472
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +1 -1
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +1 -1
- package/dist/manifests/app-shell.manifest.json +1 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +1 -1
- package/dist/manifests/auth-layout.manifest.json +1 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +1 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +1 -1
- package/dist/manifests/breadcrumb.manifest.json +1 -1
- package/dist/manifests/button-group.manifest.json +1 -1
- package/dist/manifests/button.manifest.json +4 -2
- package/dist/manifests/calendar.manifest.json +1 -1
- package/dist/manifests/card.manifest.json +1 -1
- package/dist/manifests/checkbox.manifest.json +1 -1
- package/dist/manifests/comparison-table.manifest.json +1 -1
- package/dist/manifests/confirm-dialog.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cover-image.manifest.json +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +22 -1
- package/dist/manifests/date-picker-popover.manifest.json +1 -1
- package/dist/manifests/date-picker.manifest.json +1 -1
- package/dist/manifests/date-range-picker.manifest.json +1 -1
- package/dist/manifests/deal-card.manifest.json +1 -1
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +1 -1
- package/dist/manifests/drawer.manifest.json +1 -1
- package/dist/manifests/empty-state.manifest.json +1 -1
- package/dist/manifests/entity-card.manifest.json +1 -1
- package/dist/manifests/feature-grid.manifest.json +1 -1
- package/dist/manifests/feature-row.manifest.json +1 -1
- package/dist/manifests/fieldset.manifest.json +1 -1
- package/dist/manifests/file-upload.manifest.json +1 -1
- package/dist/manifests/filter-bar.manifest.json +1 -1
- package/dist/manifests/filter-chips.manifest.json +1 -1
- package/dist/manifests/filter-panel.manifest.json +1 -1
- package/dist/manifests/flex.manifest.json +1 -1
- package/dist/manifests/form-field.manifest.json +1 -1
- package/dist/manifests/form-layout.manifest.json +1 -1
- package/dist/manifests/form.manifest.json +1 -1
- package/dist/manifests/grid.manifest.json +1 -1
- package/dist/manifests/heading.manifest.json +1 -1
- package/dist/manifests/hero.manifest.json +1 -1
- package/dist/manifests/image.manifest.json +1 -1
- package/dist/manifests/input-group.manifest.json +1 -1
- package/dist/manifests/input.manifest.json +1 -1
- package/dist/manifests/label.manifest.json +1 -1
- package/dist/manifests/link-tabs.manifest.json +1 -1
- package/dist/manifests/link.manifest.json +1 -1
- package/dist/manifests/list-toolbar.manifest.json +120 -0
- package/dist/manifests/list.manifest.json +1 -1
- package/dist/manifests/load-more.manifest.json +1 -1
- package/dist/manifests/logo-cloud.manifest.json +1 -1
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +13 -2
- package/dist/manifests/pagination.manifest.json +1 -1
- package/dist/manifests/password-input.manifest.json +1 -1
- package/dist/manifests/popover.manifest.json +1 -1
- package/dist/manifests/process-steps.manifest.json +1 -1
- package/dist/manifests/progress.manifest.json +1 -1
- package/dist/manifests/prose.manifest.json +1 -1
- package/dist/manifests/radio.manifest.json +1 -1
- package/dist/manifests/range-slider.manifest.json +1 -1
- package/dist/manifests/search.manifest.json +1 -1
- package/dist/manifests/section-heading.manifest.json +1 -1
- package/dist/manifests/section.manifest.json +1 -1
- package/dist/manifests/segmented-control.manifest.json +4 -4
- package/dist/manifests/select-menu.manifest.json +1 -1
- package/dist/manifests/select.manifest.json +1 -1
- package/dist/manifests/separator.manifest.json +1 -1
- package/dist/manifests/site-footer.manifest.json +7 -1
- package/dist/manifests/site-header.manifest.json +1 -1
- package/dist/manifests/skeleton.manifest.json +1 -1
- package/dist/manifests/spinner.manifest.json +1 -1
- package/dist/manifests/stat-band.manifest.json +1 -1
- package/dist/manifests/stepper.manifest.json +1 -1
- package/dist/manifests/switch.manifest.json +1 -1
- package/dist/manifests/table-card.manifest.json +1 -1
- package/dist/manifests/table-of-contents.manifest.json +1 -1
- package/dist/manifests/table.manifest.json +1 -1
- package/dist/manifests/tabs.manifest.json +1 -1
- package/dist/manifests/testimonial.manifest.json +1 -1
- package/dist/manifests/text.manifest.json +1 -1
- package/dist/manifests/textarea.manifest.json +1 -1
- package/dist/manifests/theme-toggle.manifest.json +1 -1
- package/dist/manifests/time-picker.manifest.json +1 -1
- package/dist/manifests/timeline.manifest.json +1 -1
- package/dist/manifests/toast.manifest.json +1 -1
- package/dist/manifests/tombstone-card.manifest.json +1 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/button/Button.d.ts +2 -2
- package/dist/src/components/button/Button.js +1 -0
- package/dist/src/components/button/Button.js.map +1 -1
- package/dist/src/components/button/Button.mjs +1 -0
- package/dist/src/components/button/Button.mjs.map +1 -1
- package/dist/src/components/data-table/DataTable.d.ts +12 -1
- package/dist/src/components/data-table/DataTable.js +189 -112
- package/dist/src/components/data-table/DataTable.js.map +1 -1
- package/dist/src/components/data-table/DataTable.mjs +189 -112
- package/dist/src/components/data-table/DataTable.mjs.map +1 -1
- package/dist/src/components/list-toolbar/ListToolbar.d.ts +25 -0
- package/dist/src/components/list-toolbar/ListToolbar.js +68 -0
- package/dist/src/components/list-toolbar/ListToolbar.js.map +1 -0
- package/dist/src/components/list-toolbar/ListToolbar.mjs +44 -0
- package/dist/src/components/list-toolbar/ListToolbar.mjs.map +1 -0
- package/dist/src/components/list-toolbar/index.d.ts +1 -0
- package/dist/src/components/list-toolbar/index.js +23 -0
- package/dist/src/components/list-toolbar/index.js.map +1 -0
- package/dist/src/components/list-toolbar/index.mjs +2 -0
- package/dist/src/components/list-toolbar/index.mjs.map +1 -0
- package/dist/src/components/page-header/PageHeader.d.ts +4 -0
- package/dist/src/components/page-header/PageHeader.js +2 -2
- package/dist/src/components/page-header/PageHeader.js.map +1 -1
- package/dist/src/components/page-header/PageHeader.mjs +2 -2
- package/dist/src/components/page-header/PageHeader.mjs.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.d.ts +20 -4
- package/dist/src/components/segmented-control/SegmentedControl.js +17 -3
- package/dist/src/components/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.mjs +17 -3
- package/dist/src/components/segmented-control/SegmentedControl.mjs.map +1 -1
- package/dist/src/components/site-footer/SiteFooter.d.ts +3 -1
- package/dist/src/components/site-footer/SiteFooter.js +3 -1
- package/dist/src/components/site-footer/SiteFooter.js.map +1 -1
- package/dist/src/components/site-footer/SiteFooter.mjs +3 -1
- package/dist/src/components/site-footer/SiteFooter.mjs.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/button/Button.ssr.test.tsx +1 -1
- package/src/components/button/Button.test.tsx +6 -0
- package/src/components/button/Button.tsx +1 -0
- package/src/components/data-table/DataTable.test.tsx +99 -0
- package/src/components/data-table/DataTable.tsx +115 -1
- package/src/components/list-toolbar/ListToolbar.test.tsx +50 -0
- package/src/components/list-toolbar/ListToolbar.tsx +64 -0
- package/src/components/list-toolbar/index.ts +1 -0
- package/src/components/page-header/PageHeader.test.tsx +13 -0
- package/src/components/page-header/PageHeader.tsx +4 -2
- package/src/components/segmented-control/SegmentedControl.test.tsx +51 -0
- package/src/components/segmented-control/SegmentedControl.tsx +36 -4
- package/src/components/site-footer/SiteFooter.test.tsx +12 -0
- package/src/components/site-footer/SiteFooter.tsx +4 -0
- package/src/index.ts +1 -0
- package/src/manifests/accordion.manifest.json +1 -1
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +1 -1
- package/src/manifests/app-shell.manifest.json +1 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +1 -1
- package/src/manifests/auth-layout.manifest.json +1 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +1 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +1 -1
- package/src/manifests/breadcrumb.manifest.json +1 -1
- package/src/manifests/button-group.manifest.json +1 -1
- package/src/manifests/button.manifest.json +4 -2
- package/src/manifests/calendar.manifest.json +1 -1
- package/src/manifests/card.manifest.json +1 -1
- package/src/manifests/checkbox.manifest.json +1 -1
- package/src/manifests/comparison-table.manifest.json +1 -1
- package/src/manifests/confirm-dialog.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cover-image.manifest.json +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +22 -1
- package/src/manifests/date-picker-popover.manifest.json +1 -1
- package/src/manifests/date-picker.manifest.json +1 -1
- package/src/manifests/date-range-picker.manifest.json +1 -1
- package/src/manifests/deal-card.manifest.json +1 -1
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +1 -1
- package/src/manifests/drawer.manifest.json +1 -1
- package/src/manifests/empty-state.manifest.json +1 -1
- package/src/manifests/entity-card.manifest.json +1 -1
- package/src/manifests/feature-grid.manifest.json +1 -1
- package/src/manifests/feature-row.manifest.json +1 -1
- package/src/manifests/fieldset.manifest.json +1 -1
- package/src/manifests/file-upload.manifest.json +1 -1
- package/src/manifests/filter-bar.manifest.json +1 -1
- package/src/manifests/filter-chips.manifest.json +1 -1
- package/src/manifests/filter-panel.manifest.json +1 -1
- package/src/manifests/flex.manifest.json +1 -1
- package/src/manifests/form-field.manifest.json +1 -1
- package/src/manifests/form-layout.manifest.json +1 -1
- package/src/manifests/form.manifest.json +1 -1
- package/src/manifests/grid.manifest.json +1 -1
- package/src/manifests/heading.manifest.json +1 -1
- package/src/manifests/hero.manifest.json +1 -1
- package/src/manifests/image.manifest.json +1 -1
- package/src/manifests/input-group.manifest.json +1 -1
- package/src/manifests/input.manifest.json +1 -1
- package/src/manifests/label.manifest.json +1 -1
- package/src/manifests/link-tabs.manifest.json +1 -1
- package/src/manifests/link.manifest.json +1 -1
- package/src/manifests/list-toolbar.manifest.json +120 -0
- package/src/manifests/list.manifest.json +1 -1
- package/src/manifests/load-more.manifest.json +1 -1
- package/src/manifests/logo-cloud.manifest.json +1 -1
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +13 -2
- package/src/manifests/pagination.manifest.json +1 -1
- package/src/manifests/password-input.manifest.json +1 -1
- package/src/manifests/popover.manifest.json +1 -1
- package/src/manifests/process-steps.manifest.json +1 -1
- package/src/manifests/progress.manifest.json +1 -1
- package/src/manifests/prose.manifest.json +1 -1
- package/src/manifests/radio.manifest.json +1 -1
- package/src/manifests/range-slider.manifest.json +1 -1
- package/src/manifests/search.manifest.json +1 -1
- package/src/manifests/section-heading.manifest.json +1 -1
- package/src/manifests/section.manifest.json +1 -1
- package/src/manifests/segmented-control.manifest.json +4 -4
- package/src/manifests/select-menu.manifest.json +1 -1
- package/src/manifests/select.manifest.json +1 -1
- package/src/manifests/separator.manifest.json +1 -1
- package/src/manifests/site-footer.manifest.json +7 -1
- package/src/manifests/site-header.manifest.json +1 -1
- package/src/manifests/skeleton.manifest.json +1 -1
- package/src/manifests/spinner.manifest.json +1 -1
- package/src/manifests/stat-band.manifest.json +1 -1
- package/src/manifests/stepper.manifest.json +1 -1
- package/src/manifests/switch.manifest.json +1 -1
- package/src/manifests/table-card.manifest.json +1 -1
- package/src/manifests/table-of-contents.manifest.json +1 -1
- package/src/manifests/table.manifest.json +1 -1
- package/src/manifests/tabs.manifest.json +1 -1
- package/src/manifests/testimonial.manifest.json +1 -1
- package/src/manifests/text.manifest.json +1 -1
- package/src/manifests/textarea.manifest.json +1 -1
- package/src/manifests/theme-toggle.manifest.json +1 -1
- package/src/manifests/time-picker.manifest.json +1 -1
- package/src/manifests/timeline.manifest.json +1 -1
- package/src/manifests/toast.manifest.json +1 -1
- package/src/manifests/tombstone-card.manifest.json +1 -1
- package/src/manifests/tooltip.manifest.json +1 -1
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
4
|
variant?: "link" | "default" | "primary" | "destructive" | "danger" | "success" | "warning" | "info" | "outline" | "outline-destructive" | "outline-success" | "outline-warning" | "outline-info" | "secondary" | "ghost" | "contrast" | "onDark" | null | undefined;
|
|
5
|
-
size?: "sm" | "lg" | "default" | "icon" | null | undefined;
|
|
5
|
+
size?: "sm" | "lg" | "default" | "xs" | "icon" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {
|
|
8
8
|
asChild?: boolean;
|
|
@@ -13,7 +13,7 @@ export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & Varian
|
|
|
13
13
|
};
|
|
14
14
|
declare const Button: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<(props?: ({
|
|
15
15
|
variant?: "link" | "default" | "primary" | "destructive" | "danger" | "success" | "warning" | "info" | "outline" | "outline-destructive" | "outline-success" | "outline-warning" | "outline-info" | "secondary" | "ghost" | "contrast" | "onDark" | null | undefined;
|
|
16
|
-
size?: "sm" | "lg" | "default" | "icon" | null | undefined;
|
|
16
|
+
size?: "sm" | "lg" | "default" | "xs" | "icon" | null | undefined;
|
|
17
17
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & {
|
|
18
18
|
asChild?: boolean;
|
|
19
19
|
/** Shows a spinner, disables the button and sets aria-busy while an action runs. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '../../utils/cn';\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n primary: 'bg-primary text-primary-foreground hover:bg-primary/90',\n destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n danger: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n // Semantic status variants — foregrounds are the paired AA tokens\n // (white on dark green, ink on amber/cyan) in both themes.\n success: 'bg-success text-success-foreground hover:bg-success/90',\n warning: 'bg-warning text-warning-foreground hover:bg-warning/90',\n info: 'bg-info text-info-foreground hover:bg-info/90',\n outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',\n // Colored outlines: semantic border + AA ink label on the page\n // surface, with a faint tint on hover - mirrors the Alert recipe.\n 'outline-destructive':\n 'border border-destructive/50 bg-background text-destructive hover:border-destructive hover:bg-destructive/10',\n 'outline-success':\n 'border border-success/50 bg-background text-success hover:border-success hover:bg-success/10',\n 'outline-warning':\n 'border border-warning/50 bg-background text-warning-ink hover:border-warning hover:bg-warning/10',\n 'outline-info':\n 'border border-info/50 bg-background text-info-ink hover:border-info hover:bg-info/10',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary-ink underline-offset-4 hover:underline',\n // High-contrast fills for hero and other always-dark surfaces. These\n // do not read the theme surface, so they stay legible in both modes.\n // Fixed ink, not --primary: in dark mode --primary lightens and would\n // sit at low contrast on the white surface.\n contrast: 'bg-white text-slate-900 shadow-sm hover:bg-slate-100',\n onDark:\n 'border border-white/45 bg-transparent text-white hover:border-white/70 hover:bg-white/10',\n },\n size: {\n default: 'h-10 px-4 py-2',\n sm: 'h-9 rounded-md px-3',\n lg: 'h-11 rounded-md px-8',\n icon: 'h-10 w-10',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nexport type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {\n asChild?: boolean;\n /** Shows a spinner, disables the button and sets aria-busy while an action runs. */\n loading?: boolean;\n /** Screen-reader text while loading (default \"Loading\"). */\n loadingLabel?: string;\n};\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, loading = false, loadingLabel = 'Loading', disabled, children, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n if (asChild) {\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props}>\n {children}\n </Comp>\n );\n }\n return (\n <button\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n {...props}\n >\n {loading && (\n <span\n aria-hidden=\"true\"\n className=\"h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent\"\n />\n )}\n {loading && <span className=\"sr-only\">{loadingLabel}</span>}\n {children}\n </button>\n );\n }\n);\nButton.displayName = 'Button';\n\nexport { Button, buttonVariants };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '../../utils/cn';\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n primary: 'bg-primary text-primary-foreground hover:bg-primary/90',\n destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n danger: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n // Semantic status variants — foregrounds are the paired AA tokens\n // (white on dark green, ink on amber/cyan) in both themes.\n success: 'bg-success text-success-foreground hover:bg-success/90',\n warning: 'bg-warning text-warning-foreground hover:bg-warning/90',\n info: 'bg-info text-info-foreground hover:bg-info/90',\n outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',\n // Colored outlines: semantic border + AA ink label on the page\n // surface, with a faint tint on hover - mirrors the Alert recipe.\n 'outline-destructive':\n 'border border-destructive/50 bg-background text-destructive hover:border-destructive hover:bg-destructive/10',\n 'outline-success':\n 'border border-success/50 bg-background text-success hover:border-success hover:bg-success/10',\n 'outline-warning':\n 'border border-warning/50 bg-background text-warning-ink hover:border-warning hover:bg-warning/10',\n 'outline-info':\n 'border border-info/50 bg-background text-info-ink hover:border-info hover:bg-info/10',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary-ink underline-offset-4 hover:underline',\n // High-contrast fills for hero and other always-dark surfaces. These\n // do not read the theme surface, so they stay legible in both modes.\n // Fixed ink, not --primary: in dark mode --primary lightens and would\n // sit at low contrast on the white surface.\n contrast: 'bg-white text-slate-900 shadow-sm hover:bg-slate-100',\n onDark:\n 'border border-white/45 bg-transparent text-white hover:border-white/70 hover:bg-white/10',\n },\n size: {\n default: 'h-10 px-4 py-2',\n sm: 'h-9 rounded-md px-3',\n xs: 'h-8 rounded-md px-2.5 text-xs',\n lg: 'h-11 rounded-md px-8',\n icon: 'h-10 w-10',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nexport type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {\n asChild?: boolean;\n /** Shows a spinner, disables the button and sets aria-busy while an action runs. */\n loading?: boolean;\n /** Screen-reader text while loading (default \"Loading\"). */\n loadingLabel?: string;\n};\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, loading = false, loadingLabel = 'Loading', disabled, children, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n if (asChild) {\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props}>\n {children}\n </Comp>\n );\n }\n return (\n <button\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n {...props}\n >\n {loading && (\n <span\n aria-hidden=\"true\"\n className=\"h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent\"\n />\n )}\n {loading && <span className=\"sr-only\">{loadingLabel}</span>}\n {children}\n </button>\n );\n }\n);\nButton.displayName = 'Button';\n\nexport { Button, buttonVariants };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqEQ;AArER,YAAuB;AACvB,wBAAqB;AACrB,sCAAuC;AACvC,gBAAmB;AAEnB,MAAM,qBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,SAAS;AAAA,QACT,aAAa;AAAA,QACb,QAAQ;AAAA;AAAA;AAAA,QAGR,SAAS;AAAA,QACT,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA;AAAA;AAAA,QAGT,uBACE;AAAA,QACF,mBACE;AAAA,QACF,mBACE;AAAA,QACF,gBACE;AAAA,QACF,WAAW;AAAA,QACX,OAAO;AAAA,QACP,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,QAKN,UAAU;AAAA,QACV,QACE;AAAA,MACJ;AAAA,MACA,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAUA,MAAM,SAAS,MAAM;AAAA,EACnB,CAAC,EAAE,WAAW,SAAS,MAAM,UAAU,OAAO,UAAU,OAAO,eAAe,WAAW,UAAU,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/H,UAAM,OAAO,UAAU,yBAAO;AAC9B,QAAI,SAAS;AACX,aACE,4CAAC,QAAK,eAAW,cAAG,eAAe,EAAE,SAAS,MAAM,UAAU,CAAC,CAAC,GAAG,KAAW,GAAG,OAC9E,UACH;AAAA,IAEJ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,cAAG,eAAe,EAAE,SAAS,MAAM,UAAU,CAAC,CAAC;AAAA,QAC1D;AAAA,QACA,UAAU,YAAY;AAAA,QACtB,aAAW,WAAW;AAAA,QACrB,GAAG;AAAA,QAEH;AAAA,qBACC;AAAA,YAAC;AAAA;AAAA,cACC,eAAY;AAAA,cACZ,WAAU;AAAA;AAAA,UACZ;AAAA,UAED,WAAW,4CAAC,UAAK,WAAU,WAAW,wBAAa;AAAA,UACnD;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '../../utils/cn';\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n primary: 'bg-primary text-primary-foreground hover:bg-primary/90',\n destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n danger: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n // Semantic status variants — foregrounds are the paired AA tokens\n // (white on dark green, ink on amber/cyan) in both themes.\n success: 'bg-success text-success-foreground hover:bg-success/90',\n warning: 'bg-warning text-warning-foreground hover:bg-warning/90',\n info: 'bg-info text-info-foreground hover:bg-info/90',\n outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',\n // Colored outlines: semantic border + AA ink label on the page\n // surface, with a faint tint on hover - mirrors the Alert recipe.\n 'outline-destructive':\n 'border border-destructive/50 bg-background text-destructive hover:border-destructive hover:bg-destructive/10',\n 'outline-success':\n 'border border-success/50 bg-background text-success hover:border-success hover:bg-success/10',\n 'outline-warning':\n 'border border-warning/50 bg-background text-warning-ink hover:border-warning hover:bg-warning/10',\n 'outline-info':\n 'border border-info/50 bg-background text-info-ink hover:border-info hover:bg-info/10',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary-ink underline-offset-4 hover:underline',\n // High-contrast fills for hero and other always-dark surfaces. These\n // do not read the theme surface, so they stay legible in both modes.\n // Fixed ink, not --primary: in dark mode --primary lightens and would\n // sit at low contrast on the white surface.\n contrast: 'bg-white text-slate-900 shadow-sm hover:bg-slate-100',\n onDark:\n 'border border-white/45 bg-transparent text-white hover:border-white/70 hover:bg-white/10',\n },\n size: {\n default: 'h-10 px-4 py-2',\n sm: 'h-9 rounded-md px-3',\n lg: 'h-11 rounded-md px-8',\n icon: 'h-10 w-10',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nexport type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {\n asChild?: boolean;\n /** Shows a spinner, disables the button and sets aria-busy while an action runs. */\n loading?: boolean;\n /** Screen-reader text while loading (default \"Loading\"). */\n loadingLabel?: string;\n};\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, loading = false, loadingLabel = 'Loading', disabled, children, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n if (asChild) {\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props}>\n {children}\n </Comp>\n );\n }\n return (\n <button\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n {...props}\n >\n {loading && (\n <span\n aria-hidden=\"true\"\n className=\"h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent\"\n />\n )}\n {loading && <span className=\"sr-only\">{loadingLabel}</span>}\n {children}\n </button>\n );\n }\n);\nButton.displayName = 'Button';\n\nexport { Button, buttonVariants };\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '../../utils/cn';\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n primary: 'bg-primary text-primary-foreground hover:bg-primary/90',\n destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n danger: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n // Semantic status variants — foregrounds are the paired AA tokens\n // (white on dark green, ink on amber/cyan) in both themes.\n success: 'bg-success text-success-foreground hover:bg-success/90',\n warning: 'bg-warning text-warning-foreground hover:bg-warning/90',\n info: 'bg-info text-info-foreground hover:bg-info/90',\n outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',\n // Colored outlines: semantic border + AA ink label on the page\n // surface, with a faint tint on hover - mirrors the Alert recipe.\n 'outline-destructive':\n 'border border-destructive/50 bg-background text-destructive hover:border-destructive hover:bg-destructive/10',\n 'outline-success':\n 'border border-success/50 bg-background text-success hover:border-success hover:bg-success/10',\n 'outline-warning':\n 'border border-warning/50 bg-background text-warning-ink hover:border-warning hover:bg-warning/10',\n 'outline-info':\n 'border border-info/50 bg-background text-info-ink hover:border-info hover:bg-info/10',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary-ink underline-offset-4 hover:underline',\n // High-contrast fills for hero and other always-dark surfaces. These\n // do not read the theme surface, so they stay legible in both modes.\n // Fixed ink, not --primary: in dark mode --primary lightens and would\n // sit at low contrast on the white surface.\n contrast: 'bg-white text-slate-900 shadow-sm hover:bg-slate-100',\n onDark:\n 'border border-white/45 bg-transparent text-white hover:border-white/70 hover:bg-white/10',\n },\n size: {\n default: 'h-10 px-4 py-2',\n sm: 'h-9 rounded-md px-3',\n xs: 'h-8 rounded-md px-2.5 text-xs',\n lg: 'h-11 rounded-md px-8',\n icon: 'h-10 w-10',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nexport type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {\n asChild?: boolean;\n /** Shows a spinner, disables the button and sets aria-busy while an action runs. */\n loading?: boolean;\n /** Screen-reader text while loading (default \"Loading\"). */\n loadingLabel?: string;\n};\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, loading = false, loadingLabel = 'Loading', disabled, children, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n if (asChild) {\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props}>\n {children}\n </Comp>\n );\n }\n return (\n <button\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n {...props}\n >\n {loading && (\n <span\n aria-hidden=\"true\"\n className=\"h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent\"\n />\n )}\n {loading && <span className=\"sr-only\">{loadingLabel}</span>}\n {children}\n </button>\n );\n }\n);\nButton.displayName = 'Button';\n\nexport { Button, buttonVariants };\n"],"mappings":"AAqEQ,cAMF,YANE;AArER,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,WAA8B;AACvC,SAAS,UAAU;AAEnB,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,SAAS;AAAA,QACT,aAAa;AAAA,QACb,QAAQ;AAAA;AAAA;AAAA,QAGR,SAAS;AAAA,QACT,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA;AAAA;AAAA,QAGT,uBACE;AAAA,QACF,mBACE;AAAA,QACF,mBACE;AAAA,QACF,gBACE;AAAA,QACF,WAAW;AAAA,QACX,OAAO;AAAA,QACP,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,QAKN,UAAU;AAAA,QACV,QACE;AAAA,MACJ;AAAA,MACA,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAUA,MAAM,SAAS,MAAM;AAAA,EACnB,CAAC,EAAE,WAAW,SAAS,MAAM,UAAU,OAAO,UAAU,OAAO,eAAe,WAAW,UAAU,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/H,UAAM,OAAO,UAAU,OAAO;AAC9B,QAAI,SAAS;AACX,aACE,oBAAC,QAAK,WAAW,GAAG,eAAe,EAAE,SAAS,MAAM,UAAU,CAAC,CAAC,GAAG,KAAW,GAAG,OAC9E,UACH;AAAA,IAEJ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,GAAG,eAAe,EAAE,SAAS,MAAM,UAAU,CAAC,CAAC;AAAA,QAC1D;AAAA,QACA,UAAU,YAAY;AAAA,QACtB,aAAW,WAAW;AAAA,QACrB,GAAG;AAAA,QAEH;AAAA,qBACC;AAAA,YAAC;AAAA;AAAA,cACC,eAAY;AAAA,cACZ,WAAU;AAAA;AAAA,UACZ;AAAA,UAED,WAAW,oBAAC,UAAK,WAAU,WAAW,wBAAa;AAAA,UACnD;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;","names":[]}
|
|
@@ -18,6 +18,8 @@ export type DataTableColumn<T> = {
|
|
|
18
18
|
onClick?: (row: T) => void;
|
|
19
19
|
};
|
|
20
20
|
export type SortIconState = 'none' | 'asc' | 'desc';
|
|
21
|
+
/** Viewport breakpoint below which card layout takes over. */
|
|
22
|
+
export type DataTableCardBreakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
21
23
|
export type DataTableProps<T> = {
|
|
22
24
|
/** Column configuration — everything about the table's shape. */
|
|
23
25
|
columns: DataTableColumn<T>[];
|
|
@@ -76,6 +78,15 @@ export type DataTableProps<T> = {
|
|
|
76
78
|
density?: 'default' | 'compact';
|
|
77
79
|
/** Zebra-striped rows. */
|
|
78
80
|
zebra?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Responsive card fallback: below the given breakpoint each row renders as
|
|
83
|
+
* a definition-list card (column headers become field labels) instead of a
|
|
84
|
+
* table row — the fix for unreadable horizontal scroll on narrow viewports.
|
|
85
|
+
* `true` enables it below `md` (768px); a string picks the breakpoint.
|
|
86
|
+
* Both layouts are rendered and swapped with CSS only, so sorting,
|
|
87
|
+
* selection, pagination, and row callbacks behave identically in each.
|
|
88
|
+
*/
|
|
89
|
+
cardLayout?: boolean | DataTableCardBreakpoint;
|
|
79
90
|
/** Render skeleton placeholder rows (announced via aria-busy). */
|
|
80
91
|
loading?: boolean;
|
|
81
92
|
/**
|
|
@@ -92,4 +103,4 @@ export type DataTableProps<T> = {
|
|
|
92
103
|
* aria-sort, cursor pagination when `pageSize` is set, and a friendly empty
|
|
93
104
|
* state — so most tables never need hand-rolled table code.
|
|
94
105
|
*/
|
|
95
|
-
export declare function DataTable<T>({ columns, data, rowId, caption, defaultSort, sortKey, sortDir, onSortChange, renderSortIcon, pageSize, page, onPageChange, pageCount: pageCountProp, total, manualPagination, selectedRowIds, onSelectedRowIdsChange, isRowSelectable, bulkActions, onRowClick, emptyMessage, selectAllLabel, selectedLabel, stickyHeader, density, zebra, loading, loadingRows, className, }: DataTableProps<T>): React.JSX.Element;
|
|
106
|
+
export declare function DataTable<T>({ columns, data, rowId, caption, defaultSort, sortKey, sortDir, onSortChange, renderSortIcon, pageSize, page, onPageChange, pageCount: pageCountProp, total, manualPagination, selectedRowIds, onSelectedRowIdsChange, isRowSelectable, bulkActions, onRowClick, emptyMessage, selectAllLabel, selectedLabel, stickyHeader, density, zebra, cardLayout, loading, loadingRows, className, }: DataTableProps<T>): React.JSX.Element;
|
|
@@ -38,6 +38,13 @@ var import_cn = require("../../utils/cn.js");
|
|
|
38
38
|
var import_Pagination = require("../pagination/Pagination.js");
|
|
39
39
|
var import_Skeleton = require("../skeleton/Skeleton.js");
|
|
40
40
|
var import_Checkbox = require("../checkbox/Checkbox.js");
|
|
41
|
+
const cardBreakpointClasses = {
|
|
42
|
+
sm: { table: "max-sm:hidden", cards: "sm:hidden" },
|
|
43
|
+
md: { table: "max-md:hidden", cards: "md:hidden" },
|
|
44
|
+
lg: { table: "max-lg:hidden", cards: "lg:hidden" },
|
|
45
|
+
xl: { table: "max-xl:hidden", cards: "xl:hidden" },
|
|
46
|
+
"2xl": { table: "max-2xl:hidden", cards: "2xl:hidden" }
|
|
47
|
+
};
|
|
41
48
|
function compareValues(a, b) {
|
|
42
49
|
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
43
50
|
if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
|
|
@@ -72,6 +79,7 @@ function DataTable({
|
|
|
72
79
|
stickyHeader,
|
|
73
80
|
density = "default",
|
|
74
81
|
zebra,
|
|
82
|
+
cardLayout,
|
|
75
83
|
loading,
|
|
76
84
|
loadingRows,
|
|
77
85
|
className
|
|
@@ -145,134 +153,203 @@ function DataTable({
|
|
|
145
153
|
if (typeof raw === "string" || typeof raw === "number") return raw;
|
|
146
154
|
return String(raw);
|
|
147
155
|
};
|
|
156
|
+
const cardBreakpoint = typeof cardLayout === "string" ? cardLayout : cardLayout ? "md" : null;
|
|
157
|
+
const cardClasses = cardBreakpoint ? cardBreakpointClasses[cardBreakpoint] : null;
|
|
148
158
|
const alignClass = (align) => align === "right" ? "text-right" : align === "center" ? "text-center" : "text-left";
|
|
159
|
+
const cardCell = (row, column, index) => {
|
|
160
|
+
const value = cellValue(row, column, index);
|
|
161
|
+
if (column.onClick) {
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
163
|
+
"button",
|
|
164
|
+
{
|
|
165
|
+
type: "button",
|
|
166
|
+
onClick: () => column.onClick(row),
|
|
167
|
+
className: "block w-full rounded px-1.5 py-0.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
168
|
+
children: value
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
return value;
|
|
173
|
+
};
|
|
149
174
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_cn.cn)("w-full space-y-3", className), children: [
|
|
150
175
|
selectionEnabled && selectedIds.length > 0 && bulkActions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-sm", children: [
|
|
151
176
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "font-medium", children: selectedLabel.replace("{count}", String(selectedIds.length)) }),
|
|
152
177
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-wrap items-center gap-2", children: bulkActions })
|
|
153
178
|
] }),
|
|
154
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
-
"
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
180
|
+
"div",
|
|
156
181
|
{
|
|
157
|
-
className: (0, import_cn.cn)("w-full
|
|
158
|
-
children:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
182
|
+
className: (0, import_cn.cn)("w-full overflow-x-auto rounded-lg border border-border", cardClasses?.table),
|
|
183
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
184
|
+
"table",
|
|
185
|
+
{
|
|
186
|
+
className: (0, import_cn.cn)("w-full caption-bottom", density === "compact" ? "text-xs" : "text-sm"),
|
|
187
|
+
children: [
|
|
188
|
+
caption && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("caption", { className: "px-3 py-2 text-left text-xs text-muted-foreground", children: caption }),
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { className: (0, import_cn.cn)("bg-muted/50", stickyHeader && "sticky top-0 z-10 bg-background"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
190
|
+
selectionEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { scope: "col", className: "w-10 border-b border-border px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
191
|
+
import_Checkbox.Checkbox,
|
|
192
|
+
{
|
|
193
|
+
"aria-label": selectAllLabel,
|
|
194
|
+
checked: allSelected,
|
|
195
|
+
ref: (node) => {
|
|
196
|
+
if (node) node.indeterminate = someSelected && !allSelected;
|
|
197
|
+
},
|
|
198
|
+
onCheckedChange: toggleAll
|
|
199
|
+
}
|
|
200
|
+
) }),
|
|
201
|
+
columns.map((column) => {
|
|
202
|
+
const isSorted = sort?.key === column.key;
|
|
203
|
+
const ariaSort = !column.sortable ? void 0 : isSorted ? sort.dir === "asc" ? "ascending" : "descending" : "none";
|
|
204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
205
|
+
"th",
|
|
206
|
+
{
|
|
207
|
+
scope: "col",
|
|
208
|
+
"aria-sort": ariaSort,
|
|
209
|
+
className: (0, import_cn.cn)(
|
|
210
|
+
"border-b border-border px-3 py-2 font-medium",
|
|
211
|
+
alignClass(column.align),
|
|
212
|
+
column.className
|
|
213
|
+
),
|
|
214
|
+
children: column.sortable ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
215
|
+
"button",
|
|
216
|
+
{
|
|
217
|
+
type: "button",
|
|
218
|
+
onClick: () => applySort(column.key),
|
|
219
|
+
className: "inline-flex items-center gap-1 rounded px-1 py-0.5 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
220
|
+
children: [
|
|
221
|
+
column.header,
|
|
222
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", className: "text-[10px] text-muted-foreground", children: renderSortIcon ? renderSortIcon(isSorted ? sort.dir === "asc" ? "asc" : "desc" : "none") : isSorted ? sort.dir === "asc" ? "\u25B2" : "\u25BC" : "\u2195" })
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
) : column.header
|
|
226
|
+
},
|
|
227
|
+
column.key
|
|
228
|
+
);
|
|
229
|
+
})
|
|
230
|
+
] }) }),
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { "aria-busy": loading || void 0, children: loading ? Array.from(
|
|
232
|
+
{ length: (loadingRows ?? pageSize ?? Math.min(visible.length, 5)) || 5 },
|
|
233
|
+
(_, skeletonRow) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
234
|
+
selectionEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: (0, import_cn.cn)("px-3 py-2", density === "compact" && "px-2 py-1"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Skeleton.Skeleton, { className: "h-4 w-4" }) }),
|
|
235
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: (0, import_cn.cn)("px-3 py-2", density === "compact" && "px-2 py-1"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Skeleton.Skeleton, { className: density === "compact" ? "h-3 w-full" : "h-4 w-full" }) }, column.key))
|
|
236
|
+
] }, `skeleton-${skeletonRow}`)
|
|
237
|
+
) : visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
238
|
+
"td",
|
|
239
|
+
{
|
|
240
|
+
colSpan: columns.length + (selectionEnabled ? 1 : 0),
|
|
241
|
+
className: "px-3 py-8 text-center text-sm text-muted-foreground",
|
|
242
|
+
children: emptyMessage
|
|
243
|
+
}
|
|
244
|
+
) }) : visible.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
245
|
+
"tr",
|
|
177
246
|
{
|
|
178
|
-
|
|
179
|
-
|
|
247
|
+
tabIndex: onRowClick ? 0 : void 0,
|
|
248
|
+
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
249
|
+
onKeyDown: onRowClick ? (event) => {
|
|
250
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
onRowClick(row);
|
|
253
|
+
}
|
|
254
|
+
} : void 0,
|
|
180
255
|
className: (0, import_cn.cn)(
|
|
181
|
-
"border-b border-border
|
|
182
|
-
|
|
183
|
-
|
|
256
|
+
"border-b border-border last:border-0",
|
|
257
|
+
zebra && "[&:nth-child(odd)]:bg-muted/30",
|
|
258
|
+
onRowClick && "cursor-pointer transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
|
|
184
259
|
),
|
|
185
|
-
children:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
type: "button",
|
|
189
|
-
onClick: () => applySort(column.key),
|
|
190
|
-
className: "inline-flex items-center gap-1 rounded px-1 py-0.5 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
191
|
-
children: [
|
|
192
|
-
column.header,
|
|
193
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", className: "text-[10px] text-muted-foreground", children: renderSortIcon ? renderSortIcon(isSorted ? sort.dir === "asc" ? "asc" : "desc" : "none") : isSorted ? sort.dir === "asc" ? "\u25B2" : "\u25BC" : "\u2195" })
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
) : column.header
|
|
197
|
-
},
|
|
198
|
-
column.key
|
|
199
|
-
);
|
|
200
|
-
})
|
|
201
|
-
] }) }),
|
|
202
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { "aria-busy": loading || void 0, children: loading ? Array.from(
|
|
203
|
-
{ length: (loadingRows ?? pageSize ?? Math.min(visible.length, 5)) || 5 },
|
|
204
|
-
(_, skeletonRow) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
205
|
-
selectionEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: (0, import_cn.cn)("px-3 py-2", density === "compact" && "px-2 py-1"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Skeleton.Skeleton, { className: "h-4 w-4" }) }),
|
|
206
|
-
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: (0, import_cn.cn)("px-3 py-2", density === "compact" && "px-2 py-1"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Skeleton.Skeleton, { className: density === "compact" ? "h-3 w-full" : "h-4 w-full" }) }, column.key))
|
|
207
|
-
] }, `skeleton-${skeletonRow}`)
|
|
208
|
-
) : visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
209
|
-
"td",
|
|
210
|
-
{
|
|
211
|
-
colSpan: columns.length + (selectionEnabled ? 1 : 0),
|
|
212
|
-
className: "px-3 py-8 text-center text-sm text-muted-foreground",
|
|
213
|
-
children: emptyMessage
|
|
214
|
-
}
|
|
215
|
-
) }) : visible.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
216
|
-
"tr",
|
|
217
|
-
{
|
|
218
|
-
tabIndex: onRowClick ? 0 : void 0,
|
|
219
|
-
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
220
|
-
onKeyDown: onRowClick ? (event) => {
|
|
221
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
222
|
-
event.preventDefault();
|
|
223
|
-
onRowClick(row);
|
|
224
|
-
}
|
|
225
|
-
} : void 0,
|
|
226
|
-
className: (0, import_cn.cn)(
|
|
227
|
-
"border-b border-border last:border-0",
|
|
228
|
-
zebra && "[&:nth-child(odd)]:bg-muted/30",
|
|
229
|
-
onRowClick && "cursor-pointer transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
|
|
230
|
-
),
|
|
231
|
-
children: [
|
|
232
|
-
selectionEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
233
|
-
"td",
|
|
234
|
-
{
|
|
235
|
-
className: (0, import_cn.cn)("align-middle", density === "compact" ? "px-2 py-1" : "px-3 py-2"),
|
|
236
|
-
onClick: (event) => event.stopPropagation(),
|
|
237
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
238
|
-
import_Checkbox.Checkbox,
|
|
260
|
+
children: [
|
|
261
|
+
selectionEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
262
|
+
"td",
|
|
239
263
|
{
|
|
240
|
-
"
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
264
|
+
className: (0, import_cn.cn)("align-middle", density === "compact" ? "px-2 py-1" : "px-3 py-2"),
|
|
265
|
+
onClick: (event) => event.stopPropagation(),
|
|
266
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
267
|
+
import_Checkbox.Checkbox,
|
|
268
|
+
{
|
|
269
|
+
"aria-label": `Select row ${rowId(row)}`,
|
|
270
|
+
checked: selectedSet.has(rowId(row)),
|
|
271
|
+
disabled: isRowSelectable ? !isRowSelectable(row) : void 0,
|
|
272
|
+
onCheckedChange: () => toggleRow(rowId(row))
|
|
273
|
+
}
|
|
274
|
+
)
|
|
244
275
|
}
|
|
245
|
-
)
|
|
246
|
-
}
|
|
247
|
-
),
|
|
248
|
-
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
249
|
-
"td",
|
|
250
|
-
{
|
|
251
|
-
className: (0, import_cn.cn)(
|
|
252
|
-
"align-middle",
|
|
253
|
-
density === "compact" ? "px-2 py-1" : "px-3 py-2",
|
|
254
|
-
alignClass(column.align),
|
|
255
|
-
column.className
|
|
256
276
|
),
|
|
257
|
-
|
|
258
|
-
"
|
|
277
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
278
|
+
"td",
|
|
259
279
|
{
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
280
|
+
className: (0, import_cn.cn)(
|
|
281
|
+
"align-middle",
|
|
282
|
+
density === "compact" ? "px-2 py-1" : "px-3 py-2",
|
|
283
|
+
alignClass(column.align),
|
|
284
|
+
column.className
|
|
285
|
+
),
|
|
286
|
+
children: column.onClick ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
287
|
+
"button",
|
|
288
|
+
{
|
|
289
|
+
type: "button",
|
|
290
|
+
onClick: () => column.onClick(row),
|
|
291
|
+
className: "block w-full rounded px-1.5 py-0.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
292
|
+
children: cellValue(row, column, index)
|
|
293
|
+
}
|
|
294
|
+
) : cellValue(row, column, index)
|
|
295
|
+
},
|
|
296
|
+
column.key
|
|
297
|
+
))
|
|
298
|
+
]
|
|
299
|
+
},
|
|
300
|
+
rowId(row)
|
|
301
|
+
)) })
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
cardClasses && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { "aria-label": caption, "aria-busy": loading || void 0, className: (0, import_cn.cn)("space-y-3", cardClasses.cards), children: loading ? Array.from(
|
|
308
|
+
{ length: (loadingRows ?? pageSize ?? Math.min(visible.length, 5)) || 5 },
|
|
309
|
+
(_, skeletonRow) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "rounded-lg border border-border p-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
|
|
310
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Skeleton.Skeleton, { className: "h-4 w-1/3" }),
|
|
311
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Skeleton.Skeleton, { className: "h-4 w-full" }),
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Skeleton.Skeleton, { className: "h-4 w-2/3" })
|
|
313
|
+
] }) }, `skeleton-${skeletonRow}`)
|
|
314
|
+
) : visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "rounded-lg border border-border px-3 py-8 text-center text-sm text-muted-foreground", children: emptyMessage }) : visible.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
315
|
+
"div",
|
|
316
|
+
{
|
|
317
|
+
tabIndex: onRowClick ? 0 : void 0,
|
|
318
|
+
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
319
|
+
onKeyDown: onRowClick ? (event) => {
|
|
320
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
321
|
+
event.preventDefault();
|
|
322
|
+
onRowClick(row);
|
|
323
|
+
}
|
|
324
|
+
} : void 0,
|
|
325
|
+
className: (0, import_cn.cn)(
|
|
326
|
+
"rounded-lg border border-border",
|
|
327
|
+
onRowClick && "cursor-pointer transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
328
|
+
),
|
|
329
|
+
children: [
|
|
330
|
+
selectionEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
331
|
+
"div",
|
|
332
|
+
{
|
|
333
|
+
className: "flex items-center justify-end px-3 pt-2",
|
|
334
|
+
onClick: (event) => event.stopPropagation(),
|
|
335
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
336
|
+
import_Checkbox.Checkbox,
|
|
337
|
+
{
|
|
338
|
+
"aria-label": `Select row ${rowId(row)}`,
|
|
339
|
+
checked: selectedSet.has(rowId(row)),
|
|
340
|
+
disabled: isRowSelectable ? !isRowSelectable(row) : void 0,
|
|
341
|
+
onCheckedChange: () => toggleRow(rowId(row))
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
}
|
|
345
|
+
),
|
|
346
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dl", { className: "divide-y divide-border", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "px-3 py-2", children: [
|
|
347
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { className: "text-xs font-medium text-muted-foreground", children: column.header }),
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { className: (0, import_cn.cn)("mt-0.5 text-sm", alignClass(column.align)), children: cardCell(row, column, index) })
|
|
349
|
+
] }, column.key)) })
|
|
273
350
|
]
|
|
274
351
|
}
|
|
275
|
-
) }),
|
|
352
|
+
) }, rowId(row))) }),
|
|
276
353
|
pageSize && pageCount > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [
|
|
277
354
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
278
355
|
"p",
|