@mediaradar/design-components 0.22.0 → 0.24.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.cjs +98 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -4
- package/dist/index.d.ts +113 -4
- package/dist/index.js +97 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -439,7 +439,7 @@ declare function CheckBoxBox({ checked, indeterminate, disabled, className }: Ch
|
|
|
439
439
|
* moved into the panel, so it is reached by tabbing.
|
|
440
440
|
* @usage
|
|
441
441
|
* ```tsx
|
|
442
|
-
* <DateRangeFilter caption="Date
|
|
442
|
+
* <DateRangeFilter caption="Date range" defaultValue="Rolling 6 months" onChange={setRange} />
|
|
443
443
|
* <DateRangeFilter caption="Dates" showDates shortDates placement="right" />
|
|
444
444
|
* <DateRangeFilter presetSet="creativeIntel" defaultValue="Last 7 days" onChange={setRange} />
|
|
445
445
|
* <DateRangeFilter presetSet="creativeIntel" value={preset} range={[start, end]} onChange={setPreset} onRangeChange={(s, e) => setRange({ start: s, end: e })} />
|
|
@@ -1749,7 +1749,7 @@ interface ChipContentProps {
|
|
|
1749
1749
|
* @usage
|
|
1750
1750
|
* ```tsx
|
|
1751
1751
|
* <button className={chipTriggerClass("box")}>
|
|
1752
|
-
* <ChipContent caption="Media
|
|
1752
|
+
* <ChipContent caption="Media type" value="All" />
|
|
1753
1753
|
* </button>
|
|
1754
1754
|
* ```
|
|
1755
1755
|
*/
|
|
@@ -2161,7 +2161,7 @@ interface MultiSelectGroup {
|
|
|
2161
2161
|
* @pattern MultiSelectFilter
|
|
2162
2162
|
* @description Quick-access multi-select chip — mirrors the DateRangeFilter
|
|
2163
2163
|
* button shape (two-line caption + value with a chevron) and opens a
|
|
2164
|
-
* searchable checkbox popover. Used for the page-level Media
|
|
2164
|
+
* searchable checkbox popover. Used for the page-level Media type /
|
|
2165
2165
|
* Advertiser filters that share state with the filter tray.
|
|
2166
2166
|
* @tokens border-border-strong, rounded-control, rounded-card, border-border-default, bg-surface, shadow-overlay, text-text-primary, text-text-secondary, text-text-tertiary, text-text-link, border-border-interactive, bg-brand-primaryAction, bg-input, hover:bg-subtle, hover:text-text-primary, placeholder:text-text-tertiary, text-brand-onprimary, focus-within:outline-border-focus
|
|
2167
2167
|
* @dependencies lucide-react
|
|
@@ -2689,4 +2689,113 @@ interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "si
|
|
|
2689
2689
|
*/
|
|
2690
2690
|
declare const TextField: react.ForwardRefExoticComponent<TextFieldProps & react.RefAttributes<HTMLInputElement>>;
|
|
2691
2691
|
|
|
2692
|
-
|
|
2692
|
+
type DataTableColumnWidth = "fill" | "sm" | "md" | "lg";
|
|
2693
|
+
type DataTableDensity = "default" | "compact";
|
|
2694
|
+
interface DataTableColumn<T, K extends string = string> {
|
|
2695
|
+
/** Identifies the column, and is the sort key when `sortable`. */
|
|
2696
|
+
key: K;
|
|
2697
|
+
/** The header label. Sentence case: "Ad spend". */
|
|
2698
|
+
label: string;
|
|
2699
|
+
/** What one row shows in this column. Free content: text, a logo, a Tag, a Delta. */
|
|
2700
|
+
cell: (row: T) => ReactNode;
|
|
2701
|
+
/** Amounts, counts, percentages, dates: right-aligned, lining figures, a fixed width. */
|
|
2702
|
+
numeric?: boolean;
|
|
2703
|
+
/**
|
|
2704
|
+
* `fill` takes what's left (the default for text columns); `sm` 96, `md` 144
|
|
2705
|
+
* (the default for numeric columns) and `lg` 192 are fixed.
|
|
2706
|
+
*/
|
|
2707
|
+
width?: DataTableColumnWidth;
|
|
2708
|
+
/** Puts a sort control in the header. Needs `sort` and `onSortChange` on the table. */
|
|
2709
|
+
sortable?: boolean;
|
|
2710
|
+
/** The first click's direction: names A→Z (`asc`), numbers largest first (`desc`, the numeric default). */
|
|
2711
|
+
firstDir?: SortDir;
|
|
2712
|
+
}
|
|
2713
|
+
interface DataTableProps<T, K extends string = string> {
|
|
2714
|
+
columns: DataTableColumn<T, K>[];
|
|
2715
|
+
rows: T[];
|
|
2716
|
+
/** A stable key per row -- an id, not the index. */
|
|
2717
|
+
rowKey: (row: T) => string;
|
|
2718
|
+
/** Card title above the table, "Top publishers". Leave out for a bare framed table. */
|
|
2719
|
+
title?: ReactNode;
|
|
2720
|
+
/** One muted line under the title. */
|
|
2721
|
+
subtitle?: ReactNode;
|
|
2722
|
+
/** Right side of the title row: a "View all" link, an export Button. */
|
|
2723
|
+
action?: ReactNode;
|
|
2724
|
+
/** Names the table for screen readers when there's no `title`. */
|
|
2725
|
+
"aria-label"?: string;
|
|
2726
|
+
sort?: SortState<K>;
|
|
2727
|
+
onSortChange?: (sort: SortState<K>) => void;
|
|
2728
|
+
/** `default` for tables people read and act on; `compact` for reference data and long lists. */
|
|
2729
|
+
density?: DataTableDensity;
|
|
2730
|
+
/** Shows skeleton rows in the real columns, at the real row height. */
|
|
2731
|
+
loading?: boolean;
|
|
2732
|
+
/** How many skeleton rows while `loading`. Match the page size. */
|
|
2733
|
+
loadingRows?: number;
|
|
2734
|
+
/** What the body shows when `rows` is empty. Defaults to NoResultsEmptyState. */
|
|
2735
|
+
empty?: ReactNode;
|
|
2736
|
+
/** Caps the height so the body scrolls under a pinned header: sm 320, md 480, lg 640. */
|
|
2737
|
+
maxHeight?: "sm" | "md" | "lg";
|
|
2738
|
+
/** Inside the frame, under the rows -- a `Pager`. A full-page table puts `TablePagination` after the table instead. */
|
|
2739
|
+
footer?: ReactNode;
|
|
2740
|
+
className?: string;
|
|
2741
|
+
}
|
|
2742
|
+
/**
|
|
2743
|
+
* @pattern DataTable
|
|
2744
|
+
* @description The shared table: a card frame, an optional title row, the
|
|
2745
|
+
* header band, rows with hairline dividers and a hover wash, and the empty
|
|
2746
|
+
* and loading states. Each screen describes its columns -- label, cell,
|
|
2747
|
+
* numeric, width, sortable -- and the shell draws them, so a column can't be
|
|
2748
|
+
* mis-aligned or mis-padded. Body 13px, header 11px uppercase and
|
|
2749
|
+
* letterspaced in secondary ink on the subtle band. Text columns fill the
|
|
2750
|
+
* width; numeric columns are fixed, right-aligned and use lining figures, so
|
|
2751
|
+
* figures sit together at the right edge.
|
|
2752
|
+
* @variant default - Default. Tables people read and act on.
|
|
2753
|
+
* @variant compact - Reference data and long lists.
|
|
2754
|
+
* @tokens rounded-card, border, border-border-default, bg-surface,
|
|
2755
|
+
* p-card-padding, text-style-card-title, text-xs, text-text-tertiary,
|
|
2756
|
+
* text-left, border-collapse, bg-subtle, text-micro, font-semibold, uppercase,
|
|
2757
|
+
* tracking-wider, text-text-secondary, text-right, text-dense,
|
|
2758
|
+
* text-text-primary, hover:bg-subtle, tabular-nums, rounded-full,
|
|
2759
|
+
* animate-pulse, border-t
|
|
2760
|
+
* @behavior Sorting: a `sortable` column's header gets a SortButton; clicks
|
|
2761
|
+
* cycle the column's `firstDir`, then the reverse, then unsorted
|
|
2762
|
+
* (`cycleSort`), and call `onSortChange`. The table doesn't sort the rows
|
|
2763
|
+
* itself: sort them before passing `rows`. `loading` keeps the header and
|
|
2764
|
+
* draws `loadingRows` skeleton rows. An empty `rows` keeps the header and
|
|
2765
|
+
* shows `empty` in one cell across every column. `maxHeight` makes the body
|
|
2766
|
+
* scroll under a pinned header; wide tables always scroll sideways rather than
|
|
2767
|
+
* squeeze.
|
|
2768
|
+
* @a11y A real <table>. Named by `title` (aria-labelledby) or `aria-label`.
|
|
2769
|
+
* Sorted columns carry aria-sort on the header cell; the sort control is a
|
|
2770
|
+
* button inside it. `loading` sets aria-busy.
|
|
2771
|
+
* @use for every table of rows and columns, in a page or in a card.
|
|
2772
|
+
* @use `title` to make the table its own card. The table runs edge to edge;
|
|
2773
|
+
* never put it inside a padded Card.
|
|
2774
|
+
* @use `numeric` for amounts, counts, percentages and dates, and `Delta` in
|
|
2775
|
+
* the cell of a change column.
|
|
2776
|
+
* @use `footer={<Pager />}` in a card; `TablePagination` after a full-page table.
|
|
2777
|
+
* @avoid a hand-built <table> -- the padding and header drift is what this
|
|
2778
|
+
* replaces.
|
|
2779
|
+
* @avoid zebra stripes or a whole-row click target; a row that opens
|
|
2780
|
+
* something carries a real control.
|
|
2781
|
+
* @avoid a layout of label/value pairs -- that's a description list, not a table.
|
|
2782
|
+
* @usage
|
|
2783
|
+
* ```tsx
|
|
2784
|
+
* <DataTable
|
|
2785
|
+
* title="Top publishers"
|
|
2786
|
+
* rowKey={(r) => r.id}
|
|
2787
|
+
* rows={rows}
|
|
2788
|
+
* sort={sort}
|
|
2789
|
+
* onSortChange={setSort}
|
|
2790
|
+
* columns={[
|
|
2791
|
+
* { key: "name", label: "Publisher", cell: (r) => r.name, sortable: true },
|
|
2792
|
+
* { key: "spend", label: "Ad spend", numeric: true, sortable: true, cell: (r) => money(r.spend) },
|
|
2793
|
+
* { key: "change", label: "Change", numeric: true, cell: (r) => <Delta value={r.change} suffix="%" /> },
|
|
2794
|
+
* ]}
|
|
2795
|
+
* footer={<Pager page={page} totalPages={5} onPage={setPage} />}
|
|
2796
|
+
* />
|
|
2797
|
+
* ```
|
|
2798
|
+
*/
|
|
2799
|
+
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;
|
|
2800
|
+
|
|
2801
|
+
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
|
@@ -439,7 +439,7 @@ declare function CheckBoxBox({ checked, indeterminate, disabled, className }: Ch
|
|
|
439
439
|
* moved into the panel, so it is reached by tabbing.
|
|
440
440
|
* @usage
|
|
441
441
|
* ```tsx
|
|
442
|
-
* <DateRangeFilter caption="Date
|
|
442
|
+
* <DateRangeFilter caption="Date range" defaultValue="Rolling 6 months" onChange={setRange} />
|
|
443
443
|
* <DateRangeFilter caption="Dates" showDates shortDates placement="right" />
|
|
444
444
|
* <DateRangeFilter presetSet="creativeIntel" defaultValue="Last 7 days" onChange={setRange} />
|
|
445
445
|
* <DateRangeFilter presetSet="creativeIntel" value={preset} range={[start, end]} onChange={setPreset} onRangeChange={(s, e) => setRange({ start: s, end: e })} />
|
|
@@ -1749,7 +1749,7 @@ interface ChipContentProps {
|
|
|
1749
1749
|
* @usage
|
|
1750
1750
|
* ```tsx
|
|
1751
1751
|
* <button className={chipTriggerClass("box")}>
|
|
1752
|
-
* <ChipContent caption="Media
|
|
1752
|
+
* <ChipContent caption="Media type" value="All" />
|
|
1753
1753
|
* </button>
|
|
1754
1754
|
* ```
|
|
1755
1755
|
*/
|
|
@@ -2161,7 +2161,7 @@ interface MultiSelectGroup {
|
|
|
2161
2161
|
* @pattern MultiSelectFilter
|
|
2162
2162
|
* @description Quick-access multi-select chip — mirrors the DateRangeFilter
|
|
2163
2163
|
* button shape (two-line caption + value with a chevron) and opens a
|
|
2164
|
-
* searchable checkbox popover. Used for the page-level Media
|
|
2164
|
+
* searchable checkbox popover. Used for the page-level Media type /
|
|
2165
2165
|
* Advertiser filters that share state with the filter tray.
|
|
2166
2166
|
* @tokens border-border-strong, rounded-control, rounded-card, border-border-default, bg-surface, shadow-overlay, text-text-primary, text-text-secondary, text-text-tertiary, text-text-link, border-border-interactive, bg-brand-primaryAction, bg-input, hover:bg-subtle, hover:text-text-primary, placeholder:text-text-tertiary, text-brand-onprimary, focus-within:outline-border-focus
|
|
2167
2167
|
* @dependencies lucide-react
|
|
@@ -2689,4 +2689,113 @@ interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "si
|
|
|
2689
2689
|
*/
|
|
2690
2690
|
declare const TextField: react.ForwardRefExoticComponent<TextFieldProps & react.RefAttributes<HTMLInputElement>>;
|
|
2691
2691
|
|
|
2692
|
-
|
|
2692
|
+
type DataTableColumnWidth = "fill" | "sm" | "md" | "lg";
|
|
2693
|
+
type DataTableDensity = "default" | "compact";
|
|
2694
|
+
interface DataTableColumn<T, K extends string = string> {
|
|
2695
|
+
/** Identifies the column, and is the sort key when `sortable`. */
|
|
2696
|
+
key: K;
|
|
2697
|
+
/** The header label. Sentence case: "Ad spend". */
|
|
2698
|
+
label: string;
|
|
2699
|
+
/** What one row shows in this column. Free content: text, a logo, a Tag, a Delta. */
|
|
2700
|
+
cell: (row: T) => ReactNode;
|
|
2701
|
+
/** Amounts, counts, percentages, dates: right-aligned, lining figures, a fixed width. */
|
|
2702
|
+
numeric?: boolean;
|
|
2703
|
+
/**
|
|
2704
|
+
* `fill` takes what's left (the default for text columns); `sm` 96, `md` 144
|
|
2705
|
+
* (the default for numeric columns) and `lg` 192 are fixed.
|
|
2706
|
+
*/
|
|
2707
|
+
width?: DataTableColumnWidth;
|
|
2708
|
+
/** Puts a sort control in the header. Needs `sort` and `onSortChange` on the table. */
|
|
2709
|
+
sortable?: boolean;
|
|
2710
|
+
/** The first click's direction: names A→Z (`asc`), numbers largest first (`desc`, the numeric default). */
|
|
2711
|
+
firstDir?: SortDir;
|
|
2712
|
+
}
|
|
2713
|
+
interface DataTableProps<T, K extends string = string> {
|
|
2714
|
+
columns: DataTableColumn<T, K>[];
|
|
2715
|
+
rows: T[];
|
|
2716
|
+
/** A stable key per row -- an id, not the index. */
|
|
2717
|
+
rowKey: (row: T) => string;
|
|
2718
|
+
/** Card title above the table, "Top publishers". Leave out for a bare framed table. */
|
|
2719
|
+
title?: ReactNode;
|
|
2720
|
+
/** One muted line under the title. */
|
|
2721
|
+
subtitle?: ReactNode;
|
|
2722
|
+
/** Right side of the title row: a "View all" link, an export Button. */
|
|
2723
|
+
action?: ReactNode;
|
|
2724
|
+
/** Names the table for screen readers when there's no `title`. */
|
|
2725
|
+
"aria-label"?: string;
|
|
2726
|
+
sort?: SortState<K>;
|
|
2727
|
+
onSortChange?: (sort: SortState<K>) => void;
|
|
2728
|
+
/** `default` for tables people read and act on; `compact` for reference data and long lists. */
|
|
2729
|
+
density?: DataTableDensity;
|
|
2730
|
+
/** Shows skeleton rows in the real columns, at the real row height. */
|
|
2731
|
+
loading?: boolean;
|
|
2732
|
+
/** How many skeleton rows while `loading`. Match the page size. */
|
|
2733
|
+
loadingRows?: number;
|
|
2734
|
+
/** What the body shows when `rows` is empty. Defaults to NoResultsEmptyState. */
|
|
2735
|
+
empty?: ReactNode;
|
|
2736
|
+
/** Caps the height so the body scrolls under a pinned header: sm 320, md 480, lg 640. */
|
|
2737
|
+
maxHeight?: "sm" | "md" | "lg";
|
|
2738
|
+
/** Inside the frame, under the rows -- a `Pager`. A full-page table puts `TablePagination` after the table instead. */
|
|
2739
|
+
footer?: ReactNode;
|
|
2740
|
+
className?: string;
|
|
2741
|
+
}
|
|
2742
|
+
/**
|
|
2743
|
+
* @pattern DataTable
|
|
2744
|
+
* @description The shared table: a card frame, an optional title row, the
|
|
2745
|
+
* header band, rows with hairline dividers and a hover wash, and the empty
|
|
2746
|
+
* and loading states. Each screen describes its columns -- label, cell,
|
|
2747
|
+
* numeric, width, sortable -- and the shell draws them, so a column can't be
|
|
2748
|
+
* mis-aligned or mis-padded. Body 13px, header 11px uppercase and
|
|
2749
|
+
* letterspaced in secondary ink on the subtle band. Text columns fill the
|
|
2750
|
+
* width; numeric columns are fixed, right-aligned and use lining figures, so
|
|
2751
|
+
* figures sit together at the right edge.
|
|
2752
|
+
* @variant default - Default. Tables people read and act on.
|
|
2753
|
+
* @variant compact - Reference data and long lists.
|
|
2754
|
+
* @tokens rounded-card, border, border-border-default, bg-surface,
|
|
2755
|
+
* p-card-padding, text-style-card-title, text-xs, text-text-tertiary,
|
|
2756
|
+
* text-left, border-collapse, bg-subtle, text-micro, font-semibold, uppercase,
|
|
2757
|
+
* tracking-wider, text-text-secondary, text-right, text-dense,
|
|
2758
|
+
* text-text-primary, hover:bg-subtle, tabular-nums, rounded-full,
|
|
2759
|
+
* animate-pulse, border-t
|
|
2760
|
+
* @behavior Sorting: a `sortable` column's header gets a SortButton; clicks
|
|
2761
|
+
* cycle the column's `firstDir`, then the reverse, then unsorted
|
|
2762
|
+
* (`cycleSort`), and call `onSortChange`. The table doesn't sort the rows
|
|
2763
|
+
* itself: sort them before passing `rows`. `loading` keeps the header and
|
|
2764
|
+
* draws `loadingRows` skeleton rows. An empty `rows` keeps the header and
|
|
2765
|
+
* shows `empty` in one cell across every column. `maxHeight` makes the body
|
|
2766
|
+
* scroll under a pinned header; wide tables always scroll sideways rather than
|
|
2767
|
+
* squeeze.
|
|
2768
|
+
* @a11y A real <table>. Named by `title` (aria-labelledby) or `aria-label`.
|
|
2769
|
+
* Sorted columns carry aria-sort on the header cell; the sort control is a
|
|
2770
|
+
* button inside it. `loading` sets aria-busy.
|
|
2771
|
+
* @use for every table of rows and columns, in a page or in a card.
|
|
2772
|
+
* @use `title` to make the table its own card. The table runs edge to edge;
|
|
2773
|
+
* never put it inside a padded Card.
|
|
2774
|
+
* @use `numeric` for amounts, counts, percentages and dates, and `Delta` in
|
|
2775
|
+
* the cell of a change column.
|
|
2776
|
+
* @use `footer={<Pager />}` in a card; `TablePagination` after a full-page table.
|
|
2777
|
+
* @avoid a hand-built <table> -- the padding and header drift is what this
|
|
2778
|
+
* replaces.
|
|
2779
|
+
* @avoid zebra stripes or a whole-row click target; a row that opens
|
|
2780
|
+
* something carries a real control.
|
|
2781
|
+
* @avoid a layout of label/value pairs -- that's a description list, not a table.
|
|
2782
|
+
* @usage
|
|
2783
|
+
* ```tsx
|
|
2784
|
+
* <DataTable
|
|
2785
|
+
* title="Top publishers"
|
|
2786
|
+
* rowKey={(r) => r.id}
|
|
2787
|
+
* rows={rows}
|
|
2788
|
+
* sort={sort}
|
|
2789
|
+
* onSortChange={setSort}
|
|
2790
|
+
* columns={[
|
|
2791
|
+
* { key: "name", label: "Publisher", cell: (r) => r.name, sortable: true },
|
|
2792
|
+
* { key: "spend", label: "Ad spend", numeric: true, sortable: true, cell: (r) => money(r.spend) },
|
|
2793
|
+
* { key: "change", label: "Change", numeric: true, cell: (r) => <Delta value={r.change} suffix="%" /> },
|
|
2794
|
+
* ]}
|
|
2795
|
+
* footer={<Pager page={page} totalPages={5} onPage={setPage} />}
|
|
2796
|
+
* />
|
|
2797
|
+
* ```
|
|
2798
|
+
*/
|
|
2799
|
+
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;
|
|
2800
|
+
|
|
2801
|
+
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
|
@@ -702,7 +702,7 @@ function slug2(value) {
|
|
|
702
702
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
703
703
|
}
|
|
704
704
|
function DateRangeFilter({
|
|
705
|
-
caption = "Date
|
|
705
|
+
caption = "Date range",
|
|
706
706
|
defaultValue,
|
|
707
707
|
value: controlledValue,
|
|
708
708
|
range: controlledRange,
|
|
@@ -840,9 +840,9 @@ function DateRangeFilter({
|
|
|
840
840
|
)) }),
|
|
841
841
|
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col p-4", children: [
|
|
842
842
|
/* @__PURE__ */ jsxs6("div", { className: "flex items-end gap-3", children: [
|
|
843
|
-
/* @__PURE__ */ jsx7(Field, { label: "Start
|
|
843
|
+
/* @__PURE__ */ jsx7(Field, { label: "Start date", value: start ? fmt(start) : "\u2014" }),
|
|
844
844
|
/* @__PURE__ */ jsx7("span", { className: "pb-2.5 text-text-tertiary", children: "\u2014" }),
|
|
845
|
-
/* @__PURE__ */ jsx7(Field, { label: "End
|
|
845
|
+
/* @__PURE__ */ jsx7(Field, { label: "End date", value: end ? fmt(end) : start ? fmt(start) : "\u2014" })
|
|
846
846
|
] }),
|
|
847
847
|
/* @__PURE__ */ jsx7("div", { className: "my-4 border-t border-border-default" }),
|
|
848
848
|
/* @__PURE__ */ jsx7("div", { className: "flex gap-8", children: [0, 1].map((offset) => {
|
|
@@ -3660,7 +3660,7 @@ function DateRangePicker({
|
|
|
3660
3660
|
p
|
|
3661
3661
|
)),
|
|
3662
3662
|
/* @__PURE__ */ jsxs33("div", { className: "mt-1 border-t border-border-default px-3 pb-2 pt-2", children: [
|
|
3663
|
-
/* @__PURE__ */ jsx37("div", { className: "text-[13px] font-semibold text-text-primary", children: "Custom
|
|
3663
|
+
/* @__PURE__ */ jsx37("div", { className: "text-[13px] font-semibold text-text-primary", children: "Custom range" }),
|
|
3664
3664
|
/* @__PURE__ */ jsxs33("div", { className: "mt-2 flex flex-col gap-2", children: [
|
|
3665
3665
|
/* @__PURE__ */ jsxs33("label", { className: "flex items-center justify-between gap-2 text-[12px] text-text-secondary", children: [
|
|
3666
3666
|
"From",
|
|
@@ -4319,6 +4319,98 @@ var TextField = forwardRef3(
|
|
|
4319
4319
|
}
|
|
4320
4320
|
);
|
|
4321
4321
|
TextField.displayName = "TextField";
|
|
4322
|
+
|
|
4323
|
+
// src/DataTable.tsx
|
|
4324
|
+
import { useId as useId8 } from "react";
|
|
4325
|
+
import { jsx as jsx48, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
4326
|
+
var WIDTH2 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
|
|
4327
|
+
var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
|
|
4328
|
+
var HEAD_PAD = { default: "px-4 py-3", compact: "px-3 py-2" };
|
|
4329
|
+
var CELL_PAD = { default: "px-4 py-3.5", compact: "px-3 py-2" };
|
|
4330
|
+
function DataTable({
|
|
4331
|
+
columns,
|
|
4332
|
+
rows,
|
|
4333
|
+
rowKey,
|
|
4334
|
+
title,
|
|
4335
|
+
subtitle,
|
|
4336
|
+
action,
|
|
4337
|
+
sort = null,
|
|
4338
|
+
onSortChange,
|
|
4339
|
+
density = "default",
|
|
4340
|
+
loading = false,
|
|
4341
|
+
loadingRows = 5,
|
|
4342
|
+
empty,
|
|
4343
|
+
maxHeight,
|
|
4344
|
+
footer,
|
|
4345
|
+
className,
|
|
4346
|
+
...rest
|
|
4347
|
+
}) {
|
|
4348
|
+
const titleId = useId8();
|
|
4349
|
+
const head = HEAD_PAD[density];
|
|
4350
|
+
const pad = CELL_PAD[density];
|
|
4351
|
+
const align = (c) => c.numeric ? "text-right" : "text-left";
|
|
4352
|
+
const width = (c) => WIDTH2[c.width ?? (c.numeric ? "md" : "fill")];
|
|
4353
|
+
const onSort = (key) => {
|
|
4354
|
+
const col = columns.find((c) => c.key === key);
|
|
4355
|
+
onSortChange?.(cycleSort(sort, key, col?.firstDir ?? (col?.numeric ? "desc" : "asc")));
|
|
4356
|
+
};
|
|
4357
|
+
return /* @__PURE__ */ jsxs42("div", { className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className), children: [
|
|
4358
|
+
title && /* @__PURE__ */ jsxs42("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
|
|
4359
|
+
/* @__PURE__ */ jsxs42("div", { className: "min-w-0", children: [
|
|
4360
|
+
/* @__PURE__ */ jsx48("h3", { id: titleId, className: "text-style-card-title", children: title }),
|
|
4361
|
+
subtitle && /* @__PURE__ */ jsx48("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
|
|
4362
|
+
] }),
|
|
4363
|
+
action && /* @__PURE__ */ jsx48("div", { className: "shrink-0", children: action })
|
|
4364
|
+
] }),
|
|
4365
|
+
/* @__PURE__ */ jsx48("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ jsxs42(
|
|
4366
|
+
"table",
|
|
4367
|
+
{
|
|
4368
|
+
"aria-labelledby": title ? titleId : void 0,
|
|
4369
|
+
"aria-label": title ? void 0 : rest["aria-label"],
|
|
4370
|
+
"aria-busy": loading || void 0,
|
|
4371
|
+
className: "w-full border-collapse text-left",
|
|
4372
|
+
children: [
|
|
4373
|
+
/* @__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(
|
|
4374
|
+
"th",
|
|
4375
|
+
{
|
|
4376
|
+
scope: "col",
|
|
4377
|
+
"aria-sort": c.sortable ? ariaSortFor(sort, c.key) : void 0,
|
|
4378
|
+
className: cn("border-b border-border-default font-semibold", head, align(c), width(c)),
|
|
4379
|
+
children: c.sortable && onSortChange ? /* @__PURE__ */ jsx48(
|
|
4380
|
+
SortButton,
|
|
4381
|
+
{
|
|
4382
|
+
label: c.label,
|
|
4383
|
+
sortKey: c.key,
|
|
4384
|
+
align: c.numeric ? "right" : "left",
|
|
4385
|
+
sort: sortProp(sort),
|
|
4386
|
+
onSort
|
|
4387
|
+
}
|
|
4388
|
+
) : c.label
|
|
4389
|
+
},
|
|
4390
|
+
c.key
|
|
4391
|
+
)) }) }),
|
|
4392
|
+
/* @__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(
|
|
4393
|
+
"span",
|
|
4394
|
+
{
|
|
4395
|
+
className: cn(
|
|
4396
|
+
"inline-block h-3 animate-pulse rounded-full bg-subtle",
|
|
4397
|
+
c.numeric ? "w-12" : "w-2/3"
|
|
4398
|
+
)
|
|
4399
|
+
}
|
|
4400
|
+
) }, 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(
|
|
4401
|
+
"td",
|
|
4402
|
+
{
|
|
4403
|
+
className: cn("border-b border-border-default", pad, align(c), c.numeric && "tabular-nums"),
|
|
4404
|
+
children: c.cell(row)
|
|
4405
|
+
},
|
|
4406
|
+
c.key
|
|
4407
|
+
)) }, rowKey(row))) })
|
|
4408
|
+
]
|
|
4409
|
+
}
|
|
4410
|
+
) }),
|
|
4411
|
+
footer && /* @__PURE__ */ jsx48("div", { className: "border-t border-border-default px-4 py-3", children: footer })
|
|
4412
|
+
] });
|
|
4413
|
+
}
|
|
4322
4414
|
export {
|
|
4323
4415
|
AISpark,
|
|
4324
4416
|
AdvertiserNoResults,
|
|
@@ -4333,6 +4425,7 @@ export {
|
|
|
4333
4425
|
ChipContent,
|
|
4334
4426
|
DEFAULT_SEARCH_MATCH,
|
|
4335
4427
|
DataScopeFilter,
|
|
4428
|
+
DataTable,
|
|
4336
4429
|
DateRangeFilter,
|
|
4337
4430
|
DateRangePicker,
|
|
4338
4431
|
Delta,
|