@mediaradar/design-components 0.22.1 → 0.25.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/index.d.cts CHANGED
@@ -2444,7 +2444,7 @@ interface PageHeaderProps {
2444
2444
  */
2445
2445
  declare function PageHeader({ title, description, actions, back, className }: PageHeaderProps): react.JSX.Element;
2446
2446
 
2447
- type ModalSize = "sm" | "md" | "lg";
2447
+ type ModalSize = "sm" | "md" | "lg" | "xl";
2448
2448
  interface ModalProps {
2449
2449
  /** Whether the dialog is showing. */
2450
2450
  open: boolean;
@@ -2454,7 +2454,7 @@ interface ModalProps {
2454
2454
  title: ReactNode;
2455
2455
  /** One line under the title, when the title alone doesn't say enough. */
2456
2456
  description?: ReactNode;
2457
- /** sm 440 for a confirm, md 640 for a form, lg 880 for a table or a list. */
2457
+ /** sm 440 for a confirm, md 640 for a form, lg 880 for a table or a list, xl 1200 for a full workspace. */
2458
2458
  size?: ModalSize;
2459
2459
  /** The buttons along the bottom, right-aligned -- primary last. */
2460
2460
  footer?: ReactNode;
@@ -2464,12 +2464,14 @@ interface ModalProps {
2464
2464
  /**
2465
2465
  * @pattern Modal
2466
2466
  * @description A dialog over a dimmed page: title, optional one-line
2467
- * description, content, and a footer of buttons. Three widths -- sm 440 for a
2468
- * confirm, md 640 for a form, lg 880 for a table or a list -- over the warm
2469
- * scrim, which flips with dark mode.
2467
+ * description, content, and a footer of buttons. Four widths -- sm 440 for a
2468
+ * confirm, md 640 for a form, lg 880 for a table or a list, xl 1200 for a
2469
+ * full workspace -- over the warm scrim, which flips with dark mode.
2470
2470
  * @variant sm - 440px. A confirm: one question, two buttons.
2471
2471
  * @variant md - 640px. Default. A form.
2472
2472
  * @variant lg - 880px. A table, a long list, a preview.
2473
+ * @variant xl - 1200px. A full workspace: a column picker, a detail view with
2474
+ * its own tabs or panes, a grid.
2473
2475
  * @tokens bg-scrim, z-modal, rounded-card, border-border-default, bg-surface,
2474
2476
  * shadow-overlay, text-base, font-semibold, text-text-primary, text-sm,
2475
2477
  * text-text-secondary, text-text-tertiary, hover:bg-subtle,
@@ -2485,12 +2487,12 @@ interface ModalProps {
2485
2487
  * `description`. The close button is labelled "Close".
2486
2488
  * @use for a task the user has to finish or cancel before going back to the
2487
2489
  * page: confirm a delete, name a list, pick export options.
2488
- * @use `sm` for confirms, `md` for forms, `lg` for tables -- pick by content,
2489
- * never a custom width.
2490
+ * @use `sm` for confirms, `md` for forms, `lg` for tables, `xl` only for a
2491
+ * full workspace -- pick by content, never a custom width.
2490
2492
  * @use one primary Button, last in `footer`, with a secondary "Cancel" before it.
2491
2493
  * @avoid a modal for a message that needs no answer -- use Toast.
2492
2494
  * @avoid a modal opened from another modal.
2493
- * @avoid a `className` width override; if none of the three fit, raise it as
2495
+ * @avoid a `className` width override; if none of the four fit, raise it as
2494
2496
  * a design question.
2495
2497
  * @usage
2496
2498
  * ```tsx
@@ -2689,4 +2691,113 @@ interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "si
2689
2691
  */
2690
2692
  declare const TextField: react.ForwardRefExoticComponent<TextFieldProps & react.RefAttributes<HTMLInputElement>>;
2691
2693
 
2692
- export { AISpark, type AISparkProps, AdvertiserNoResults, type AdvertiserNoResultsProps, AdvertiserQuickFilter, type AdvertiserQuickFilterProps, AdvertiserSearchPrompt, type AdvertiserSearchPromptProps, Badge, type BadgeKind, type BadgeProps, type BadgeTone, BarChartPlaceholder, type BarChartPlaceholderProps, Button, type ButtonProps, Card, type CardProps, CheckBox, CheckBoxBox, type CheckBoxBoxProps, type CheckBoxProps, ChipContent, type ChipContentProps, type ChipVariant, DEFAULT_SEARCH_MATCH, DataScopeFilter, type DataScopeFilterProps, type DateGranularity, DateRangeFilter, type DateRangeFilterProps, DateRangePicker, type DateRangePickerProps, Delta, type DeltaProps, EmptyState, type EmptyStateProps, type EmptyStateSize, FilterChipBar, type FilterChipBarProps, FilterDropdownFooter, type FilterDropdownFooterProps, Freshness, type FreshnessLevel, type FreshnessProps, InfoTip, type InfoTipProps, LineChartPlaceholder, type LineChartPlaceholderProps, Modal, type ModalProps, type ModalSize, MultiSelectFilter, type MultiSelectFilterProps, type MultiSelectGroup, NO_RESULTS_BODY, NO_RESULTS_TITLE, NameListModal, type NameListModalProps, type NoResultsAction, NoResultsEmptyState, type NoResultsEmptyStateProps, PRIMARY_ACTION_CLASS, PageHeader, type PageHeaderProps, Pager, type PagerProps, type PickerColumn, type PickerFilter, type PickerRow, PieChartPlaceholder, type PieChartPlaceholderProps, type PubBreak, PublisherBreakdownList, type PublisherBreakdownListProps, QUIET_ACTION_CLASS, SearchBar, type SearchBarProps, type SearchBarSize, type SearchBarVariant, type SearchMatchMode, type SearchMatchValue, SectionHeading, type SectionHeadingProps, SectionRail, type SectionRailProps, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, type SegmentedOption, SelectAllVisible, type SelectAllVisibleProps, SelectFilter, type SelectFilterProps, SelectedSection, type SelectedSectionProps, SelectionPicker, type SelectionPickerAccountList, type SelectionPickerProps, SortButton, type SortButtonProps, type SortDir, type SortState, StackedColumnPlaceholder, type StackedColumnPlaceholderProps, type SummaryGroup, type SummaryGroupItemValue, type TabItem, TablePagination, type TablePaginationProps, Tabs, type TabsProps, Tag, type TagProps, TextField, type TextFieldProps, type TextFieldSize, Toast, type ToastProps, type ToastTone, Toggle, type ToggleProps, Tooltip, type TooltipProps, WorkspaceAvatar, type WorkspaceAvatarProps, WorkspaceSelectedCard, type WorkspaceSelectedCardProps, ariaSortFor, buttonVariants, chipTriggerClass, cycleSort, noResultsBody, resolveRange, sortProp };
2694
+ type DataTableColumnWidth = "fill" | "sm" | "md" | "lg";
2695
+ type DataTableDensity = "default" | "compact";
2696
+ interface DataTableColumn<T, K extends string = string> {
2697
+ /** Identifies the column, and is the sort key when `sortable`. */
2698
+ key: K;
2699
+ /** The header label. Sentence case: "Ad spend". */
2700
+ label: string;
2701
+ /** What one row shows in this column. Free content: text, a logo, a Tag, a Delta. */
2702
+ cell: (row: T) => ReactNode;
2703
+ /** Amounts, counts, percentages, dates: right-aligned, lining figures, a fixed width. */
2704
+ numeric?: boolean;
2705
+ /**
2706
+ * `fill` takes what's left (the default for text columns); `sm` 96, `md` 144
2707
+ * (the default for numeric columns) and `lg` 192 are fixed.
2708
+ */
2709
+ width?: DataTableColumnWidth;
2710
+ /** Puts a sort control in the header. Needs `sort` and `onSortChange` on the table. */
2711
+ sortable?: boolean;
2712
+ /** The first click's direction: names A→Z (`asc`), numbers largest first (`desc`, the numeric default). */
2713
+ firstDir?: SortDir;
2714
+ }
2715
+ interface DataTableProps<T, K extends string = string> {
2716
+ columns: DataTableColumn<T, K>[];
2717
+ rows: T[];
2718
+ /** A stable key per row -- an id, not the index. */
2719
+ rowKey: (row: T) => string;
2720
+ /** Card title above the table, "Top publishers". Leave out for a bare framed table. */
2721
+ title?: ReactNode;
2722
+ /** One muted line under the title. */
2723
+ subtitle?: ReactNode;
2724
+ /** Right side of the title row: a "View all" link, an export Button. */
2725
+ action?: ReactNode;
2726
+ /** Names the table for screen readers when there's no `title`. */
2727
+ "aria-label"?: string;
2728
+ sort?: SortState<K>;
2729
+ onSortChange?: (sort: SortState<K>) => void;
2730
+ /** `default` for tables people read and act on; `compact` for reference data and long lists. */
2731
+ density?: DataTableDensity;
2732
+ /** Shows skeleton rows in the real columns, at the real row height. */
2733
+ loading?: boolean;
2734
+ /** How many skeleton rows while `loading`. Match the page size. */
2735
+ loadingRows?: number;
2736
+ /** What the body shows when `rows` is empty. Defaults to NoResultsEmptyState. */
2737
+ empty?: ReactNode;
2738
+ /** Caps the height so the body scrolls under a pinned header: sm 320, md 480, lg 640. */
2739
+ maxHeight?: "sm" | "md" | "lg";
2740
+ /** Inside the frame, under the rows -- a `Pager`. A full-page table puts `TablePagination` after the table instead. */
2741
+ footer?: ReactNode;
2742
+ className?: string;
2743
+ }
2744
+ /**
2745
+ * @pattern DataTable
2746
+ * @description The shared table: a card frame, an optional title row, the
2747
+ * header band, rows with hairline dividers and a hover wash, and the empty
2748
+ * and loading states. Each screen describes its columns -- label, cell,
2749
+ * numeric, width, sortable -- and the shell draws them, so a column can't be
2750
+ * mis-aligned or mis-padded. Body 13px, header 11px uppercase and
2751
+ * letterspaced in secondary ink on the subtle band. Text columns fill the
2752
+ * width; numeric columns are fixed, right-aligned and use lining figures, so
2753
+ * figures sit together at the right edge.
2754
+ * @variant default - Default. Tables people read and act on.
2755
+ * @variant compact - Reference data and long lists.
2756
+ * @tokens rounded-card, border, border-border-default, bg-surface,
2757
+ * p-card-padding, text-style-card-title, text-xs, text-text-tertiary,
2758
+ * text-left, border-collapse, bg-subtle, text-micro, font-semibold, uppercase,
2759
+ * tracking-wider, text-text-secondary, text-right, text-dense,
2760
+ * text-text-primary, hover:bg-subtle, tabular-nums, rounded-full,
2761
+ * animate-pulse, border-t
2762
+ * @behavior Sorting: a `sortable` column's header gets a SortButton; clicks
2763
+ * cycle the column's `firstDir`, then the reverse, then unsorted
2764
+ * (`cycleSort`), and call `onSortChange`. The table doesn't sort the rows
2765
+ * itself: sort them before passing `rows`. `loading` keeps the header and
2766
+ * draws `loadingRows` skeleton rows. An empty `rows` keeps the header and
2767
+ * shows `empty` in one cell across every column. `maxHeight` makes the body
2768
+ * scroll under a pinned header; wide tables always scroll sideways rather than
2769
+ * squeeze.
2770
+ * @a11y A real <table>. Named by `title` (aria-labelledby) or `aria-label`.
2771
+ * Sorted columns carry aria-sort on the header cell; the sort control is a
2772
+ * button inside it. `loading` sets aria-busy.
2773
+ * @use for every table of rows and columns, in a page or in a card.
2774
+ * @use `title` to make the table its own card. The table runs edge to edge;
2775
+ * never put it inside a padded Card.
2776
+ * @use `numeric` for amounts, counts, percentages and dates, and `Delta` in
2777
+ * the cell of a change column.
2778
+ * @use `footer={<Pager />}` in a card; `TablePagination` after a full-page table.
2779
+ * @avoid a hand-built <table> -- the padding and header drift is what this
2780
+ * replaces.
2781
+ * @avoid zebra stripes or a whole-row click target; a row that opens
2782
+ * something carries a real control.
2783
+ * @avoid a layout of label/value pairs -- that's a description list, not a table.
2784
+ * @usage
2785
+ * ```tsx
2786
+ * <DataTable
2787
+ * title="Top publishers"
2788
+ * rowKey={(r) => r.id}
2789
+ * rows={rows}
2790
+ * sort={sort}
2791
+ * onSortChange={setSort}
2792
+ * columns={[
2793
+ * { key: "name", label: "Publisher", cell: (r) => r.name, sortable: true },
2794
+ * { key: "spend", label: "Ad spend", numeric: true, sortable: true, cell: (r) => money(r.spend) },
2795
+ * { key: "change", label: "Change", numeric: true, cell: (r) => <Delta value={r.change} suffix="%" /> },
2796
+ * ]}
2797
+ * footer={<Pager page={page} totalPages={5} onPage={setPage} />}
2798
+ * />
2799
+ * ```
2800
+ */
2801
+ declare function DataTable<T, K extends string = string>({ columns, rows, rowKey, title, subtitle, action, sort, onSortChange, density, loading, loadingRows, empty, maxHeight, footer, className, ...rest }: DataTableProps<T, K>): react.JSX.Element;
2802
+
2803
+ export { AISpark, type AISparkProps, AdvertiserNoResults, type AdvertiserNoResultsProps, AdvertiserQuickFilter, type AdvertiserQuickFilterProps, AdvertiserSearchPrompt, type AdvertiserSearchPromptProps, Badge, type BadgeKind, type BadgeProps, type BadgeTone, BarChartPlaceholder, type BarChartPlaceholderProps, Button, type ButtonProps, Card, type CardProps, CheckBox, CheckBoxBox, type CheckBoxBoxProps, type CheckBoxProps, ChipContent, type ChipContentProps, type ChipVariant, DEFAULT_SEARCH_MATCH, DataScopeFilter, type DataScopeFilterProps, DataTable, type DataTableColumn, type DataTableColumnWidth, type DataTableDensity, type DataTableProps, type DateGranularity, DateRangeFilter, type DateRangeFilterProps, DateRangePicker, type DateRangePickerProps, Delta, type DeltaProps, EmptyState, type EmptyStateProps, type EmptyStateSize, FilterChipBar, type FilterChipBarProps, FilterDropdownFooter, type FilterDropdownFooterProps, Freshness, type FreshnessLevel, type FreshnessProps, InfoTip, type InfoTipProps, LineChartPlaceholder, type LineChartPlaceholderProps, Modal, type ModalProps, type ModalSize, MultiSelectFilter, type MultiSelectFilterProps, type MultiSelectGroup, NO_RESULTS_BODY, NO_RESULTS_TITLE, NameListModal, type NameListModalProps, type NoResultsAction, NoResultsEmptyState, type NoResultsEmptyStateProps, PRIMARY_ACTION_CLASS, PageHeader, type PageHeaderProps, Pager, type PagerProps, type PickerColumn, type PickerFilter, type PickerRow, PieChartPlaceholder, type PieChartPlaceholderProps, type PubBreak, PublisherBreakdownList, type PublisherBreakdownListProps, QUIET_ACTION_CLASS, SearchBar, type SearchBarProps, type SearchBarSize, type SearchBarVariant, type SearchMatchMode, type SearchMatchValue, SectionHeading, type SectionHeadingProps, SectionRail, type SectionRailProps, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, type SegmentedOption, SelectAllVisible, type SelectAllVisibleProps, SelectFilter, type SelectFilterProps, SelectedSection, type SelectedSectionProps, SelectionPicker, type SelectionPickerAccountList, type SelectionPickerProps, SortButton, type SortButtonProps, type SortDir, type SortState, StackedColumnPlaceholder, type StackedColumnPlaceholderProps, type SummaryGroup, type SummaryGroupItemValue, type TabItem, TablePagination, type TablePaginationProps, Tabs, type TabsProps, Tag, type TagProps, TextField, type TextFieldProps, type TextFieldSize, Toast, type ToastProps, type ToastTone, Toggle, type ToggleProps, Tooltip, type TooltipProps, WorkspaceAvatar, type WorkspaceAvatarProps, WorkspaceSelectedCard, type WorkspaceSelectedCardProps, ariaSortFor, buttonVariants, chipTriggerClass, cycleSort, noResultsBody, resolveRange, sortProp };
package/dist/index.d.ts CHANGED
@@ -2444,7 +2444,7 @@ interface PageHeaderProps {
2444
2444
  */
2445
2445
  declare function PageHeader({ title, description, actions, back, className }: PageHeaderProps): react.JSX.Element;
2446
2446
 
2447
- type ModalSize = "sm" | "md" | "lg";
2447
+ type ModalSize = "sm" | "md" | "lg" | "xl";
2448
2448
  interface ModalProps {
2449
2449
  /** Whether the dialog is showing. */
2450
2450
  open: boolean;
@@ -2454,7 +2454,7 @@ interface ModalProps {
2454
2454
  title: ReactNode;
2455
2455
  /** One line under the title, when the title alone doesn't say enough. */
2456
2456
  description?: ReactNode;
2457
- /** sm 440 for a confirm, md 640 for a form, lg 880 for a table or a list. */
2457
+ /** sm 440 for a confirm, md 640 for a form, lg 880 for a table or a list, xl 1200 for a full workspace. */
2458
2458
  size?: ModalSize;
2459
2459
  /** The buttons along the bottom, right-aligned -- primary last. */
2460
2460
  footer?: ReactNode;
@@ -2464,12 +2464,14 @@ interface ModalProps {
2464
2464
  /**
2465
2465
  * @pattern Modal
2466
2466
  * @description A dialog over a dimmed page: title, optional one-line
2467
- * description, content, and a footer of buttons. Three widths -- sm 440 for a
2468
- * confirm, md 640 for a form, lg 880 for a table or a list -- over the warm
2469
- * scrim, which flips with dark mode.
2467
+ * description, content, and a footer of buttons. Four widths -- sm 440 for a
2468
+ * confirm, md 640 for a form, lg 880 for a table or a list, xl 1200 for a
2469
+ * full workspace -- over the warm scrim, which flips with dark mode.
2470
2470
  * @variant sm - 440px. A confirm: one question, two buttons.
2471
2471
  * @variant md - 640px. Default. A form.
2472
2472
  * @variant lg - 880px. A table, a long list, a preview.
2473
+ * @variant xl - 1200px. A full workspace: a column picker, a detail view with
2474
+ * its own tabs or panes, a grid.
2473
2475
  * @tokens bg-scrim, z-modal, rounded-card, border-border-default, bg-surface,
2474
2476
  * shadow-overlay, text-base, font-semibold, text-text-primary, text-sm,
2475
2477
  * text-text-secondary, text-text-tertiary, hover:bg-subtle,
@@ -2485,12 +2487,12 @@ interface ModalProps {
2485
2487
  * `description`. The close button is labelled "Close".
2486
2488
  * @use for a task the user has to finish or cancel before going back to the
2487
2489
  * page: confirm a delete, name a list, pick export options.
2488
- * @use `sm` for confirms, `md` for forms, `lg` for tables -- pick by content,
2489
- * never a custom width.
2490
+ * @use `sm` for confirms, `md` for forms, `lg` for tables, `xl` only for a
2491
+ * full workspace -- pick by content, never a custom width.
2490
2492
  * @use one primary Button, last in `footer`, with a secondary "Cancel" before it.
2491
2493
  * @avoid a modal for a message that needs no answer -- use Toast.
2492
2494
  * @avoid a modal opened from another modal.
2493
- * @avoid a `className` width override; if none of the three fit, raise it as
2495
+ * @avoid a `className` width override; if none of the four fit, raise it as
2494
2496
  * a design question.
2495
2497
  * @usage
2496
2498
  * ```tsx
@@ -2689,4 +2691,113 @@ interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "si
2689
2691
  */
2690
2692
  declare const TextField: react.ForwardRefExoticComponent<TextFieldProps & react.RefAttributes<HTMLInputElement>>;
2691
2693
 
2692
- export { AISpark, type AISparkProps, AdvertiserNoResults, type AdvertiserNoResultsProps, AdvertiserQuickFilter, type AdvertiserQuickFilterProps, AdvertiserSearchPrompt, type AdvertiserSearchPromptProps, Badge, type BadgeKind, type BadgeProps, type BadgeTone, BarChartPlaceholder, type BarChartPlaceholderProps, Button, type ButtonProps, Card, type CardProps, CheckBox, CheckBoxBox, type CheckBoxBoxProps, type CheckBoxProps, ChipContent, type ChipContentProps, type ChipVariant, DEFAULT_SEARCH_MATCH, DataScopeFilter, type DataScopeFilterProps, type DateGranularity, DateRangeFilter, type DateRangeFilterProps, DateRangePicker, type DateRangePickerProps, Delta, type DeltaProps, EmptyState, type EmptyStateProps, type EmptyStateSize, FilterChipBar, type FilterChipBarProps, FilterDropdownFooter, type FilterDropdownFooterProps, Freshness, type FreshnessLevel, type FreshnessProps, InfoTip, type InfoTipProps, LineChartPlaceholder, type LineChartPlaceholderProps, Modal, type ModalProps, type ModalSize, MultiSelectFilter, type MultiSelectFilterProps, type MultiSelectGroup, NO_RESULTS_BODY, NO_RESULTS_TITLE, NameListModal, type NameListModalProps, type NoResultsAction, NoResultsEmptyState, type NoResultsEmptyStateProps, PRIMARY_ACTION_CLASS, PageHeader, type PageHeaderProps, Pager, type PagerProps, type PickerColumn, type PickerFilter, type PickerRow, PieChartPlaceholder, type PieChartPlaceholderProps, type PubBreak, PublisherBreakdownList, type PublisherBreakdownListProps, QUIET_ACTION_CLASS, SearchBar, type SearchBarProps, type SearchBarSize, type SearchBarVariant, type SearchMatchMode, type SearchMatchValue, SectionHeading, type SectionHeadingProps, SectionRail, type SectionRailProps, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, type SegmentedOption, SelectAllVisible, type SelectAllVisibleProps, SelectFilter, type SelectFilterProps, SelectedSection, type SelectedSectionProps, SelectionPicker, type SelectionPickerAccountList, type SelectionPickerProps, SortButton, type SortButtonProps, type SortDir, type SortState, StackedColumnPlaceholder, type StackedColumnPlaceholderProps, type SummaryGroup, type SummaryGroupItemValue, type TabItem, TablePagination, type TablePaginationProps, Tabs, type TabsProps, Tag, type TagProps, TextField, type TextFieldProps, type TextFieldSize, Toast, type ToastProps, type ToastTone, Toggle, type ToggleProps, Tooltip, type TooltipProps, WorkspaceAvatar, type WorkspaceAvatarProps, WorkspaceSelectedCard, type WorkspaceSelectedCardProps, ariaSortFor, buttonVariants, chipTriggerClass, cycleSort, noResultsBody, resolveRange, sortProp };
2694
+ type DataTableColumnWidth = "fill" | "sm" | "md" | "lg";
2695
+ type DataTableDensity = "default" | "compact";
2696
+ interface DataTableColumn<T, K extends string = string> {
2697
+ /** Identifies the column, and is the sort key when `sortable`. */
2698
+ key: K;
2699
+ /** The header label. Sentence case: "Ad spend". */
2700
+ label: string;
2701
+ /** What one row shows in this column. Free content: text, a logo, a Tag, a Delta. */
2702
+ cell: (row: T) => ReactNode;
2703
+ /** Amounts, counts, percentages, dates: right-aligned, lining figures, a fixed width. */
2704
+ numeric?: boolean;
2705
+ /**
2706
+ * `fill` takes what's left (the default for text columns); `sm` 96, `md` 144
2707
+ * (the default for numeric columns) and `lg` 192 are fixed.
2708
+ */
2709
+ width?: DataTableColumnWidth;
2710
+ /** Puts a sort control in the header. Needs `sort` and `onSortChange` on the table. */
2711
+ sortable?: boolean;
2712
+ /** The first click's direction: names A→Z (`asc`), numbers largest first (`desc`, the numeric default). */
2713
+ firstDir?: SortDir;
2714
+ }
2715
+ interface DataTableProps<T, K extends string = string> {
2716
+ columns: DataTableColumn<T, K>[];
2717
+ rows: T[];
2718
+ /** A stable key per row -- an id, not the index. */
2719
+ rowKey: (row: T) => string;
2720
+ /** Card title above the table, "Top publishers". Leave out for a bare framed table. */
2721
+ title?: ReactNode;
2722
+ /** One muted line under the title. */
2723
+ subtitle?: ReactNode;
2724
+ /** Right side of the title row: a "View all" link, an export Button. */
2725
+ action?: ReactNode;
2726
+ /** Names the table for screen readers when there's no `title`. */
2727
+ "aria-label"?: string;
2728
+ sort?: SortState<K>;
2729
+ onSortChange?: (sort: SortState<K>) => void;
2730
+ /** `default` for tables people read and act on; `compact` for reference data and long lists. */
2731
+ density?: DataTableDensity;
2732
+ /** Shows skeleton rows in the real columns, at the real row height. */
2733
+ loading?: boolean;
2734
+ /** How many skeleton rows while `loading`. Match the page size. */
2735
+ loadingRows?: number;
2736
+ /** What the body shows when `rows` is empty. Defaults to NoResultsEmptyState. */
2737
+ empty?: ReactNode;
2738
+ /** Caps the height so the body scrolls under a pinned header: sm 320, md 480, lg 640. */
2739
+ maxHeight?: "sm" | "md" | "lg";
2740
+ /** Inside the frame, under the rows -- a `Pager`. A full-page table puts `TablePagination` after the table instead. */
2741
+ footer?: ReactNode;
2742
+ className?: string;
2743
+ }
2744
+ /**
2745
+ * @pattern DataTable
2746
+ * @description The shared table: a card frame, an optional title row, the
2747
+ * header band, rows with hairline dividers and a hover wash, and the empty
2748
+ * and loading states. Each screen describes its columns -- label, cell,
2749
+ * numeric, width, sortable -- and the shell draws them, so a column can't be
2750
+ * mis-aligned or mis-padded. Body 13px, header 11px uppercase and
2751
+ * letterspaced in secondary ink on the subtle band. Text columns fill the
2752
+ * width; numeric columns are fixed, right-aligned and use lining figures, so
2753
+ * figures sit together at the right edge.
2754
+ * @variant default - Default. Tables people read and act on.
2755
+ * @variant compact - Reference data and long lists.
2756
+ * @tokens rounded-card, border, border-border-default, bg-surface,
2757
+ * p-card-padding, text-style-card-title, text-xs, text-text-tertiary,
2758
+ * text-left, border-collapse, bg-subtle, text-micro, font-semibold, uppercase,
2759
+ * tracking-wider, text-text-secondary, text-right, text-dense,
2760
+ * text-text-primary, hover:bg-subtle, tabular-nums, rounded-full,
2761
+ * animate-pulse, border-t
2762
+ * @behavior Sorting: a `sortable` column's header gets a SortButton; clicks
2763
+ * cycle the column's `firstDir`, then the reverse, then unsorted
2764
+ * (`cycleSort`), and call `onSortChange`. The table doesn't sort the rows
2765
+ * itself: sort them before passing `rows`. `loading` keeps the header and
2766
+ * draws `loadingRows` skeleton rows. An empty `rows` keeps the header and
2767
+ * shows `empty` in one cell across every column. `maxHeight` makes the body
2768
+ * scroll under a pinned header; wide tables always scroll sideways rather than
2769
+ * squeeze.
2770
+ * @a11y A real <table>. Named by `title` (aria-labelledby) or `aria-label`.
2771
+ * Sorted columns carry aria-sort on the header cell; the sort control is a
2772
+ * button inside it. `loading` sets aria-busy.
2773
+ * @use for every table of rows and columns, in a page or in a card.
2774
+ * @use `title` to make the table its own card. The table runs edge to edge;
2775
+ * never put it inside a padded Card.
2776
+ * @use `numeric` for amounts, counts, percentages and dates, and `Delta` in
2777
+ * the cell of a change column.
2778
+ * @use `footer={<Pager />}` in a card; `TablePagination` after a full-page table.
2779
+ * @avoid a hand-built <table> -- the padding and header drift is what this
2780
+ * replaces.
2781
+ * @avoid zebra stripes or a whole-row click target; a row that opens
2782
+ * something carries a real control.
2783
+ * @avoid a layout of label/value pairs -- that's a description list, not a table.
2784
+ * @usage
2785
+ * ```tsx
2786
+ * <DataTable
2787
+ * title="Top publishers"
2788
+ * rowKey={(r) => r.id}
2789
+ * rows={rows}
2790
+ * sort={sort}
2791
+ * onSortChange={setSort}
2792
+ * columns={[
2793
+ * { key: "name", label: "Publisher", cell: (r) => r.name, sortable: true },
2794
+ * { key: "spend", label: "Ad spend", numeric: true, sortable: true, cell: (r) => money(r.spend) },
2795
+ * { key: "change", label: "Change", numeric: true, cell: (r) => <Delta value={r.change} suffix="%" /> },
2796
+ * ]}
2797
+ * footer={<Pager page={page} totalPages={5} onPage={setPage} />}
2798
+ * />
2799
+ * ```
2800
+ */
2801
+ declare function DataTable<T, K extends string = string>({ columns, rows, rowKey, title, subtitle, action, sort, onSortChange, density, loading, loadingRows, empty, maxHeight, footer, className, ...rest }: DataTableProps<T, K>): react.JSX.Element;
2802
+
2803
+ export { AISpark, type AISparkProps, AdvertiserNoResults, type AdvertiserNoResultsProps, AdvertiserQuickFilter, type AdvertiserQuickFilterProps, AdvertiserSearchPrompt, type AdvertiserSearchPromptProps, Badge, type BadgeKind, type BadgeProps, type BadgeTone, BarChartPlaceholder, type BarChartPlaceholderProps, Button, type ButtonProps, Card, type CardProps, CheckBox, CheckBoxBox, type CheckBoxBoxProps, type CheckBoxProps, ChipContent, type ChipContentProps, type ChipVariant, DEFAULT_SEARCH_MATCH, DataScopeFilter, type DataScopeFilterProps, DataTable, type DataTableColumn, type DataTableColumnWidth, type DataTableDensity, type DataTableProps, type DateGranularity, DateRangeFilter, type DateRangeFilterProps, DateRangePicker, type DateRangePickerProps, Delta, type DeltaProps, EmptyState, type EmptyStateProps, type EmptyStateSize, FilterChipBar, type FilterChipBarProps, FilterDropdownFooter, type FilterDropdownFooterProps, Freshness, type FreshnessLevel, type FreshnessProps, InfoTip, type InfoTipProps, LineChartPlaceholder, type LineChartPlaceholderProps, Modal, type ModalProps, type ModalSize, MultiSelectFilter, type MultiSelectFilterProps, type MultiSelectGroup, NO_RESULTS_BODY, NO_RESULTS_TITLE, NameListModal, type NameListModalProps, type NoResultsAction, NoResultsEmptyState, type NoResultsEmptyStateProps, PRIMARY_ACTION_CLASS, PageHeader, type PageHeaderProps, Pager, type PagerProps, type PickerColumn, type PickerFilter, type PickerRow, PieChartPlaceholder, type PieChartPlaceholderProps, type PubBreak, PublisherBreakdownList, type PublisherBreakdownListProps, QUIET_ACTION_CLASS, SearchBar, type SearchBarProps, type SearchBarSize, type SearchBarVariant, type SearchMatchMode, type SearchMatchValue, SectionHeading, type SectionHeadingProps, SectionRail, type SectionRailProps, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, type SegmentedOption, SelectAllVisible, type SelectAllVisibleProps, SelectFilter, type SelectFilterProps, SelectedSection, type SelectedSectionProps, SelectionPicker, type SelectionPickerAccountList, type SelectionPickerProps, SortButton, type SortButtonProps, type SortDir, type SortState, StackedColumnPlaceholder, type StackedColumnPlaceholderProps, type SummaryGroup, type SummaryGroupItemValue, type TabItem, TablePagination, type TablePaginationProps, Tabs, type TabsProps, Tag, type TagProps, TextField, type TextFieldProps, type TextFieldSize, Toast, type ToastProps, type ToastTone, Toggle, type ToggleProps, Tooltip, type TooltipProps, WorkspaceAvatar, type WorkspaceAvatarProps, WorkspaceSelectedCard, type WorkspaceSelectedCardProps, ariaSortFor, buttonVariants, chipTriggerClass, cycleSort, noResultsBody, resolveRange, sortProp };
package/dist/index.js CHANGED
@@ -4063,7 +4063,10 @@ import { jsx as jsx44, jsxs as jsxs38 } from "react/jsx-runtime";
4063
4063
  var WIDTH = {
4064
4064
  sm: "max-w-110",
4065
4065
  md: "max-w-160",
4066
- lg: "max-w-220"
4066
+ lg: "max-w-220",
4067
+ // A whole workspace in a dialog: a column picker, a detail view with its
4068
+ // own tabs, a grid of events. 880 squeezed their tables into scrolling.
4069
+ xl: "max-w-300"
4067
4070
  };
4068
4071
  var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
4069
4072
  function Modal({ open, onClose, title, description, size = "md", footer, children, className }) {
@@ -4319,6 +4322,98 @@ var TextField = forwardRef3(
4319
4322
  }
4320
4323
  );
4321
4324
  TextField.displayName = "TextField";
4325
+
4326
+ // src/DataTable.tsx
4327
+ import { useId as useId8 } from "react";
4328
+ import { jsx as jsx48, jsxs as jsxs42 } from "react/jsx-runtime";
4329
+ var WIDTH2 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
4330
+ var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
4331
+ var HEAD_PAD = { default: "px-4 py-3", compact: "px-3 py-2" };
4332
+ var CELL_PAD = { default: "px-4 py-3.5", compact: "px-3 py-2" };
4333
+ function DataTable({
4334
+ columns,
4335
+ rows,
4336
+ rowKey,
4337
+ title,
4338
+ subtitle,
4339
+ action,
4340
+ sort = null,
4341
+ onSortChange,
4342
+ density = "default",
4343
+ loading = false,
4344
+ loadingRows = 5,
4345
+ empty,
4346
+ maxHeight,
4347
+ footer,
4348
+ className,
4349
+ ...rest
4350
+ }) {
4351
+ const titleId = useId8();
4352
+ const head = HEAD_PAD[density];
4353
+ const pad = CELL_PAD[density];
4354
+ const align = (c) => c.numeric ? "text-right" : "text-left";
4355
+ const width = (c) => WIDTH2[c.width ?? (c.numeric ? "md" : "fill")];
4356
+ const onSort = (key) => {
4357
+ const col = columns.find((c) => c.key === key);
4358
+ onSortChange?.(cycleSort(sort, key, col?.firstDir ?? (col?.numeric ? "desc" : "asc")));
4359
+ };
4360
+ return /* @__PURE__ */ jsxs42("div", { className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className), children: [
4361
+ title && /* @__PURE__ */ jsxs42("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
4362
+ /* @__PURE__ */ jsxs42("div", { className: "min-w-0", children: [
4363
+ /* @__PURE__ */ jsx48("h3", { id: titleId, className: "text-style-card-title", children: title }),
4364
+ subtitle && /* @__PURE__ */ jsx48("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
4365
+ ] }),
4366
+ action && /* @__PURE__ */ jsx48("div", { className: "shrink-0", children: action })
4367
+ ] }),
4368
+ /* @__PURE__ */ jsx48("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ jsxs42(
4369
+ "table",
4370
+ {
4371
+ "aria-labelledby": title ? titleId : void 0,
4372
+ "aria-label": title ? void 0 : rest["aria-label"],
4373
+ "aria-busy": loading || void 0,
4374
+ className: "w-full border-collapse text-left",
4375
+ children: [
4376
+ /* @__PURE__ */ jsx48("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ jsx48("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: columns.map((c) => /* @__PURE__ */ jsx48(
4377
+ "th",
4378
+ {
4379
+ scope: "col",
4380
+ "aria-sort": c.sortable ? ariaSortFor(sort, c.key) : void 0,
4381
+ className: cn("border-b border-border-default font-semibold", head, align(c), width(c)),
4382
+ children: c.sortable && onSortChange ? /* @__PURE__ */ jsx48(
4383
+ SortButton,
4384
+ {
4385
+ label: c.label,
4386
+ sortKey: c.key,
4387
+ align: c.numeric ? "right" : "left",
4388
+ sort: sortProp(sort),
4389
+ onSort
4390
+ }
4391
+ ) : c.label
4392
+ },
4393
+ c.key
4394
+ )) }) }),
4395
+ /* @__PURE__ */ jsx48("tbody", { className: "text-dense text-text-primary", children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ jsx48("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ jsx48("td", { className: cn("border-b border-border-default", pad, align(c)), children: /* @__PURE__ */ jsx48(
4396
+ "span",
4397
+ {
4398
+ className: cn(
4399
+ "inline-block h-3 animate-pulse rounded-full bg-subtle",
4400
+ c.numeric ? "w-12" : "w-2/3"
4401
+ )
4402
+ }
4403
+ ) }, c.key)) }, i)) : rows.length === 0 ? /* @__PURE__ */ jsx48("tr", { children: /* @__PURE__ */ jsx48("td", { colSpan: columns.length, children: empty ?? /* @__PURE__ */ jsx48(NoResultsEmptyState, {}) }) }) : rows.map((row) => /* @__PURE__ */ jsx48("tr", { className: "hover:bg-subtle [&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ jsx48(
4404
+ "td",
4405
+ {
4406
+ className: cn("border-b border-border-default", pad, align(c), c.numeric && "tabular-nums"),
4407
+ children: c.cell(row)
4408
+ },
4409
+ c.key
4410
+ )) }, rowKey(row))) })
4411
+ ]
4412
+ }
4413
+ ) }),
4414
+ footer && /* @__PURE__ */ jsx48("div", { className: "border-t border-border-default px-4 py-3", children: footer })
4415
+ ] });
4416
+ }
4322
4417
  export {
4323
4418
  AISpark,
4324
4419
  AdvertiserNoResults,
@@ -4333,6 +4428,7 @@ export {
4333
4428
  ChipContent,
4334
4429
  DEFAULT_SEARCH_MATCH,
4335
4430
  DataScopeFilter,
4431
+ DataTable,
4336
4432
  DateRangeFilter,
4337
4433
  DateRangePicker,
4338
4434
  Delta,