@mediaradar/design-components 0.65.0 → 0.67.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/approved-components.json +1 -1
- package/dist/index.cjs +87 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -31
- package/dist/index.d.ts +33 -31
- package/dist/index.js +87 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -584,7 +584,9 @@ declare const CheckBoxBox: react.ForwardRefExoticComponent<CheckBoxBoxProps & re
|
|
|
584
584
|
* today.
|
|
585
585
|
* `granularity="month"` rounds every range out to whole months (presets,
|
|
586
586
|
* clicked days and Apply alike), shows months on the trigger, and adds a
|
|
587
|
-
* "Data is monthly" note beside Cancel/Apply.
|
|
587
|
+
* "Data is monthly" note beside Cancel/Apply. Its "Rolling N months" presets
|
|
588
|
+
* are the last N complete months, ending with last month (on Dec 3, 2026,
|
|
589
|
+
* "Rolling 12 months" is Dec 2025 – Nov 2026), so no month is partial.
|
|
588
590
|
* `formatDate` / `formatRange` write every day-level date the component shows
|
|
589
591
|
* (dates line, a custom span on the chip, Start/End fields, compare-to dates),
|
|
590
592
|
* e.g. to follow a person's date-format setting. What `onChange` and `onApply`
|
|
@@ -3634,8 +3636,8 @@ interface DataTableHeaderMenuChoice<V = string> {
|
|
|
3634
3636
|
}
|
|
3635
3637
|
/**
|
|
3636
3638
|
* Turns the name column's header into a dropdown for how the rows are built:
|
|
3637
|
-
* what they're grouped by
|
|
3638
|
-
*
|
|
3639
|
+
* what they're grouped by and what each group breaks out into, side by side
|
|
3640
|
+
* in two columns. The header reads the choices ("Subsidiary › League").
|
|
3639
3641
|
*/
|
|
3640
3642
|
interface DataTableHeaderMenu {
|
|
3641
3643
|
/** What each row is: "Subsidiary", "Brand". One pick, required. */
|
|
@@ -3698,10 +3700,10 @@ interface DataTableColumn<T, K extends string = string> {
|
|
|
3698
3700
|
highlight?: boolean;
|
|
3699
3701
|
/**
|
|
3700
3702
|
* The name column only: its header becomes a dropdown ("Subsidiary ›
|
|
3701
|
-
* League") for what the rows are grouped by
|
|
3702
|
-
*
|
|
3703
|
-
* Apply, which calls each changed choice's `onChange
|
|
3704
|
-
*
|
|
3703
|
+
* League") for what the rows are grouped by and what they break out into,
|
|
3704
|
+
* in two columns. A click opens it, never sorts. Picks are staged until
|
|
3705
|
+
* Apply, which calls each changed choice's `onChange`; every other close
|
|
3706
|
+
* drops them. The
|
|
3705
3707
|
* header shows the choices instead of `label`, which names the panel for
|
|
3706
3708
|
* screen readers.
|
|
3707
3709
|
*/
|
|
@@ -3895,12 +3897,13 @@ declare function TableLink({ className, ...props }: AnchorHTMLAttributes<HTMLAnc
|
|
|
3895
3897
|
* panel on click; the name links to the entity's overview (UXD-196). A
|
|
3896
3898
|
* totals row can sit first, and the reader's own brand can be marked with a
|
|
3897
3899
|
* light brand fill on its row or column. A full-page table (`sticky`) keeps
|
|
3898
|
-
* its header row in view under the page's StickyBar
|
|
3899
|
-
*
|
|
3900
|
+
* its header row in view under the page's StickyBar; once it's stuck the table
|
|
3901
|
+
* goes full screen, edge to edge, with its scroll bar and pager pinned to
|
|
3902
|
+
* the bottom of the screen. A table wider than its space
|
|
3900
3903
|
* always shows a thin scroll bar. A figure column's sort arrow sits before
|
|
3901
3904
|
* its label, so the label ends where the figures do. The name column's
|
|
3902
3905
|
* header can be a dropdown (`headerMenu`) for how the rows are grouped and
|
|
3903
|
-
* broken out,
|
|
3906
|
+
* broken out, in two columns.
|
|
3904
3907
|
* @variant default - Default. Tables people read and act on.
|
|
3905
3908
|
* @variant compact - Reference data and long lists.
|
|
3906
3909
|
* @tokens rounded-card, rounded-small, border, border-border-default, bg-surface,
|
|
@@ -3984,14 +3987,14 @@ declare function TableLink({ className, ...props }: AnchorHTMLAttributes<HTMLAnc
|
|
|
3984
3987
|
* `headerMenu` on the name column turns its header into a quiet dropdown
|
|
3985
3988
|
* trigger reading the current choices ("Subsidiary › League", a chevron
|
|
3986
3989
|
* after), with a darker fill on hover and while open. A click opens a panel
|
|
3987
|
-
* (never sorts) with
|
|
3990
|
+
* (never sorts) with two pick-one groups side by side, as Advertising
|
|
3991
|
+
* Trends' Group by (420px, a hairline between them): "Group rows by" and
|
|
3988
3992
|
* "Then break out by" ("None" first, then the options; the one equal to the
|
|
3989
|
-
* staged group-by is unavailable), and
|
|
3990
|
-
*
|
|
3991
|
-
*
|
|
3992
|
-
*
|
|
3993
|
-
*
|
|
3994
|
-
* changed it just closes. Cancel, Escape, a click outside and tabbing out
|
|
3993
|
+
* staged group-by is unavailable), and a FilterDropdownFooter with Apply
|
|
3994
|
+
* only. No sort in it: the column isn't sorted from its header. Picks are
|
|
3995
|
+
* staged: the ticks move, the table doesn't. Apply calls `onChange` only
|
|
3996
|
+
* for what changed and closes; with nothing changed it just closes. Escape,
|
|
3997
|
+
* a click outside and tabbing out
|
|
3995
3998
|
* close it and drop the staged picks, without asking; it reopens on the
|
|
3996
3999
|
* applied values. Picking a group-by equal to the break-out stages the
|
|
3997
4000
|
* break-out back to None. The panel is portalled, so the frame never clips
|
|
@@ -4000,16 +4003,16 @@ declare function TableLink({ className, ...props }: AnchorHTMLAttributes<HTMLAnc
|
|
|
4000
4003
|
* page's StickyBar (or `stickyTop` pixels from the top), a copy of it stays
|
|
4001
4004
|
* there, right under the bar, until the last row goes by. The copy scrolls
|
|
4002
4005
|
* sideways with the frame, keeps the pinned columns and their edge, and its
|
|
4003
|
-
* sort buttons work with the mouse.
|
|
4004
|
-
*
|
|
4005
|
-
*
|
|
4006
|
-
*
|
|
4007
|
-
*
|
|
4008
|
-
*
|
|
4009
|
-
*
|
|
4010
|
-
*
|
|
4011
|
-
*
|
|
4012
|
-
* is ignored with `sticky`.
|
|
4006
|
+
* sort buttons work with the mouse. While the header is stuck the table is in
|
|
4007
|
+
* full screen mode: it reaches out to the edges of what scrolls, as
|
|
4008
|
+
* StickyBar's band does (square corners, no side borders), and its columns
|
|
4009
|
+
* use the extra width. The sideways scroll bar (drawn, always visible when
|
|
4010
|
+
* the table is wider than its space) and `footer` (the page's
|
|
4011
|
+
* TablePagination) sit under the frame on the page background. In full
|
|
4012
|
+
* screen mode they pin to the bottom of the screen, edge to edge with a line
|
|
4013
|
+
* above, until the last row goes by, where they settle under it without a
|
|
4014
|
+
* jump; before that, and back at the top, they sit under the last row like
|
|
4015
|
+
* any table's. `maxHeight` is ignored with `sticky`.
|
|
4013
4016
|
* @a11y A real <table>. Named by `title` (aria-labelledby) or `aria-label`.
|
|
4014
4017
|
* Sorted columns carry aria-sort on the header cell; the sort control is a
|
|
4015
4018
|
* button inside it. A header's `info` shows on hover and keyboard focus and
|
|
@@ -4032,14 +4035,13 @@ declare function TableLink({ className, ...props }: AnchorHTMLAttributes<HTMLAnc
|
|
|
4032
4035
|
* row or column header beside it, and colour alone says nothing to someone
|
|
4033
4036
|
* who can't see it. `NoValue` reads its reason, not "dash". `loading` sets aria-busy.
|
|
4034
4037
|
* The `headerMenu` trigger is a button with aria-haspopup="dialog" and
|
|
4035
|
-
* aria-expanded (the panel holds
|
|
4038
|
+
* aria-expanded (the panel holds Apply, so it's a dialog, as
|
|
4036
4039
|
* MultiSelectFilter's, not a menu); Enter, Space or the down arrow opens it
|
|
4037
4040
|
* and focus moves to the first group's picked row. Each group is a
|
|
4038
4041
|
* radiogroup named by its heading, its rows role="radio" with aria-checked
|
|
4039
4042
|
* and one tab stop; the arrows, Home and End move the pick within a group,
|
|
4040
|
-
* Tab goes to the next group, then
|
|
4041
|
-
*
|
|
4042
|
-
* <th> keeps aria-sort. The "›" is
|
|
4043
|
+
* Tab goes to the next group, then Apply. Escape, Apply and tabbing past
|
|
4044
|
+
* either end close it and return focus to the trigger. The "›" is
|
|
4043
4045
|
* hidden from screen readers, which hear "Subsidiary then League"; the panel
|
|
4044
4046
|
* is named by the column's `label`.
|
|
4045
4047
|
* With `sticky`, the header copy is aria-hidden and out of the tab order
|
package/dist/index.d.ts
CHANGED
|
@@ -584,7 +584,9 @@ declare const CheckBoxBox: react.ForwardRefExoticComponent<CheckBoxBoxProps & re
|
|
|
584
584
|
* today.
|
|
585
585
|
* `granularity="month"` rounds every range out to whole months (presets,
|
|
586
586
|
* clicked days and Apply alike), shows months on the trigger, and adds a
|
|
587
|
-
* "Data is monthly" note beside Cancel/Apply.
|
|
587
|
+
* "Data is monthly" note beside Cancel/Apply. Its "Rolling N months" presets
|
|
588
|
+
* are the last N complete months, ending with last month (on Dec 3, 2026,
|
|
589
|
+
* "Rolling 12 months" is Dec 2025 – Nov 2026), so no month is partial.
|
|
588
590
|
* `formatDate` / `formatRange` write every day-level date the component shows
|
|
589
591
|
* (dates line, a custom span on the chip, Start/End fields, compare-to dates),
|
|
590
592
|
* e.g. to follow a person's date-format setting. What `onChange` and `onApply`
|
|
@@ -3634,8 +3636,8 @@ interface DataTableHeaderMenuChoice<V = string> {
|
|
|
3634
3636
|
}
|
|
3635
3637
|
/**
|
|
3636
3638
|
* Turns the name column's header into a dropdown for how the rows are built:
|
|
3637
|
-
* what they're grouped by
|
|
3638
|
-
*
|
|
3639
|
+
* what they're grouped by and what each group breaks out into, side by side
|
|
3640
|
+
* in two columns. The header reads the choices ("Subsidiary › League").
|
|
3639
3641
|
*/
|
|
3640
3642
|
interface DataTableHeaderMenu {
|
|
3641
3643
|
/** What each row is: "Subsidiary", "Brand". One pick, required. */
|
|
@@ -3698,10 +3700,10 @@ interface DataTableColumn<T, K extends string = string> {
|
|
|
3698
3700
|
highlight?: boolean;
|
|
3699
3701
|
/**
|
|
3700
3702
|
* The name column only: its header becomes a dropdown ("Subsidiary ›
|
|
3701
|
-
* League") for what the rows are grouped by
|
|
3702
|
-
*
|
|
3703
|
-
* Apply, which calls each changed choice's `onChange
|
|
3704
|
-
*
|
|
3703
|
+
* League") for what the rows are grouped by and what they break out into,
|
|
3704
|
+
* in two columns. A click opens it, never sorts. Picks are staged until
|
|
3705
|
+
* Apply, which calls each changed choice's `onChange`; every other close
|
|
3706
|
+
* drops them. The
|
|
3705
3707
|
* header shows the choices instead of `label`, which names the panel for
|
|
3706
3708
|
* screen readers.
|
|
3707
3709
|
*/
|
|
@@ -3895,12 +3897,13 @@ declare function TableLink({ className, ...props }: AnchorHTMLAttributes<HTMLAnc
|
|
|
3895
3897
|
* panel on click; the name links to the entity's overview (UXD-196). A
|
|
3896
3898
|
* totals row can sit first, and the reader's own brand can be marked with a
|
|
3897
3899
|
* light brand fill on its row or column. A full-page table (`sticky`) keeps
|
|
3898
|
-
* its header row in view under the page's StickyBar
|
|
3899
|
-
*
|
|
3900
|
+
* its header row in view under the page's StickyBar; once it's stuck the table
|
|
3901
|
+
* goes full screen, edge to edge, with its scroll bar and pager pinned to
|
|
3902
|
+
* the bottom of the screen. A table wider than its space
|
|
3900
3903
|
* always shows a thin scroll bar. A figure column's sort arrow sits before
|
|
3901
3904
|
* its label, so the label ends where the figures do. The name column's
|
|
3902
3905
|
* header can be a dropdown (`headerMenu`) for how the rows are grouped and
|
|
3903
|
-
* broken out,
|
|
3906
|
+
* broken out, in two columns.
|
|
3904
3907
|
* @variant default - Default. Tables people read and act on.
|
|
3905
3908
|
* @variant compact - Reference data and long lists.
|
|
3906
3909
|
* @tokens rounded-card, rounded-small, border, border-border-default, bg-surface,
|
|
@@ -3984,14 +3987,14 @@ declare function TableLink({ className, ...props }: AnchorHTMLAttributes<HTMLAnc
|
|
|
3984
3987
|
* `headerMenu` on the name column turns its header into a quiet dropdown
|
|
3985
3988
|
* trigger reading the current choices ("Subsidiary › League", a chevron
|
|
3986
3989
|
* after), with a darker fill on hover and while open. A click opens a panel
|
|
3987
|
-
* (never sorts) with
|
|
3990
|
+
* (never sorts) with two pick-one groups side by side, as Advertising
|
|
3991
|
+
* Trends' Group by (420px, a hairline between them): "Group rows by" and
|
|
3988
3992
|
* "Then break out by" ("None" first, then the options; the one equal to the
|
|
3989
|
-
* staged group-by is unavailable), and
|
|
3990
|
-
*
|
|
3991
|
-
*
|
|
3992
|
-
*
|
|
3993
|
-
*
|
|
3994
|
-
* changed it just closes. Cancel, Escape, a click outside and tabbing out
|
|
3993
|
+
* staged group-by is unavailable), and a FilterDropdownFooter with Apply
|
|
3994
|
+
* only. No sort in it: the column isn't sorted from its header. Picks are
|
|
3995
|
+
* staged: the ticks move, the table doesn't. Apply calls `onChange` only
|
|
3996
|
+
* for what changed and closes; with nothing changed it just closes. Escape,
|
|
3997
|
+
* a click outside and tabbing out
|
|
3995
3998
|
* close it and drop the staged picks, without asking; it reopens on the
|
|
3996
3999
|
* applied values. Picking a group-by equal to the break-out stages the
|
|
3997
4000
|
* break-out back to None. The panel is portalled, so the frame never clips
|
|
@@ -4000,16 +4003,16 @@ declare function TableLink({ className, ...props }: AnchorHTMLAttributes<HTMLAnc
|
|
|
4000
4003
|
* page's StickyBar (or `stickyTop` pixels from the top), a copy of it stays
|
|
4001
4004
|
* there, right under the bar, until the last row goes by. The copy scrolls
|
|
4002
4005
|
* sideways with the frame, keeps the pinned columns and their edge, and its
|
|
4003
|
-
* sort buttons work with the mouse.
|
|
4004
|
-
*
|
|
4005
|
-
*
|
|
4006
|
-
*
|
|
4007
|
-
*
|
|
4008
|
-
*
|
|
4009
|
-
*
|
|
4010
|
-
*
|
|
4011
|
-
*
|
|
4012
|
-
* is ignored with `sticky`.
|
|
4006
|
+
* sort buttons work with the mouse. While the header is stuck the table is in
|
|
4007
|
+
* full screen mode: it reaches out to the edges of what scrolls, as
|
|
4008
|
+
* StickyBar's band does (square corners, no side borders), and its columns
|
|
4009
|
+
* use the extra width. The sideways scroll bar (drawn, always visible when
|
|
4010
|
+
* the table is wider than its space) and `footer` (the page's
|
|
4011
|
+
* TablePagination) sit under the frame on the page background. In full
|
|
4012
|
+
* screen mode they pin to the bottom of the screen, edge to edge with a line
|
|
4013
|
+
* above, until the last row goes by, where they settle under it without a
|
|
4014
|
+
* jump; before that, and back at the top, they sit under the last row like
|
|
4015
|
+
* any table's. `maxHeight` is ignored with `sticky`.
|
|
4013
4016
|
* @a11y A real <table>. Named by `title` (aria-labelledby) or `aria-label`.
|
|
4014
4017
|
* Sorted columns carry aria-sort on the header cell; the sort control is a
|
|
4015
4018
|
* button inside it. A header's `info` shows on hover and keyboard focus and
|
|
@@ -4032,14 +4035,13 @@ declare function TableLink({ className, ...props }: AnchorHTMLAttributes<HTMLAnc
|
|
|
4032
4035
|
* row or column header beside it, and colour alone says nothing to someone
|
|
4033
4036
|
* who can't see it. `NoValue` reads its reason, not "dash". `loading` sets aria-busy.
|
|
4034
4037
|
* The `headerMenu` trigger is a button with aria-haspopup="dialog" and
|
|
4035
|
-
* aria-expanded (the panel holds
|
|
4038
|
+
* aria-expanded (the panel holds Apply, so it's a dialog, as
|
|
4036
4039
|
* MultiSelectFilter's, not a menu); Enter, Space or the down arrow opens it
|
|
4037
4040
|
* and focus moves to the first group's picked row. Each group is a
|
|
4038
4041
|
* radiogroup named by its heading, its rows role="radio" with aria-checked
|
|
4039
4042
|
* and one tab stop; the arrows, Home and End move the pick within a group,
|
|
4040
|
-
* Tab goes to the next group, then
|
|
4041
|
-
*
|
|
4042
|
-
* <th> keeps aria-sort. The "›" is
|
|
4043
|
+
* Tab goes to the next group, then Apply. Escape, Apply and tabbing past
|
|
4044
|
+
* either end close it and return focus to the trigger. The "›" is
|
|
4043
4045
|
* hidden from screen readers, which hear "Subsidiary then League"; the panel
|
|
4044
4046
|
* is named by the column's `label`.
|
|
4045
4047
|
* With `sticky`, the header copy is aria-hidden and out of the tab order
|
package/dist/index.js
CHANGED
|
@@ -1036,18 +1036,19 @@ function compareSpan(s, e, mode) {
|
|
|
1036
1036
|
const days = Math.round((startOfDay(e).getTime() - startOfDay(s).getTime()) / 864e5) + 1;
|
|
1037
1037
|
return [addDays(s, -days), addDays(s, -1)];
|
|
1038
1038
|
}
|
|
1039
|
-
function presetRange(key, today) {
|
|
1039
|
+
function presetRange(key, today, monthly = false) {
|
|
1040
1040
|
const t = startOfDay(today);
|
|
1041
1041
|
const qMonth = Math.floor(t.getMonth() / 3) * 3;
|
|
1042
|
+
const rolling = (n) => monthly ? [new Date(t.getFullYear(), t.getMonth() - n, 1), new Date(t.getFullYear(), t.getMonth(), 0)] : [addMonths(t, -n), t];
|
|
1042
1043
|
switch (key) {
|
|
1043
1044
|
case "Year to date":
|
|
1044
1045
|
return [new Date(t.getFullYear(), 0, 1), t];
|
|
1045
1046
|
case "Rolling 3 months":
|
|
1046
|
-
return
|
|
1047
|
+
return rolling(3);
|
|
1047
1048
|
case "Rolling 6 months":
|
|
1048
|
-
return
|
|
1049
|
+
return rolling(6);
|
|
1049
1050
|
case "Rolling 12 months":
|
|
1050
|
-
return
|
|
1051
|
+
return rolling(12);
|
|
1051
1052
|
case "Previous quarter": {
|
|
1052
1053
|
const s = new Date(t.getFullYear(), qMonth - 3, 1);
|
|
1053
1054
|
const e = new Date(t.getFullYear(), qMonth, 0);
|
|
@@ -1139,7 +1140,7 @@ function DateRangeFilter({
|
|
|
1139
1140
|
);
|
|
1140
1141
|
const today = useMemo2(() => todayProp ?? /* @__PURE__ */ new Date(), []);
|
|
1141
1142
|
const initShortcut = matchShortcut(SHORTCUTS, controlled ? controlledValue : defaultValue);
|
|
1142
|
-
const initRange = controlled ? controlledRange : initShortcut === "Custom" && initialRange ? snap(...initialRange) : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today));
|
|
1143
|
+
const initRange = controlled ? controlledRange : initShortcut === "Custom" && initialRange ? snap(...initialRange) : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today, monthly));
|
|
1143
1144
|
const compareLabel = (id) => compare?.options.find((o) => o.id === id)?.label;
|
|
1144
1145
|
const dateLine = (s, e) => monthly ? `${fmtMonth(s)} \u2013 ${fmtMonth(e)}` : formatted ? showRange(s, e) : shortDates ? `${fmt(s)} \u2013 ${fmt(e)}` : fullRangeLabel(s, e);
|
|
1145
1146
|
const [open, setOpen] = useState4(false);
|
|
@@ -1199,7 +1200,7 @@ function DateRangeFilter({
|
|
|
1199
1200
|
const choosePreset = (key) => {
|
|
1200
1201
|
setShortcut(key);
|
|
1201
1202
|
if (key === "Custom") return;
|
|
1202
|
-
const r = presetRange(key, today);
|
|
1203
|
+
const r = presetRange(key, today, monthly);
|
|
1203
1204
|
if (r) {
|
|
1204
1205
|
const [s, e] = snap(r[0], r[1]);
|
|
1205
1206
|
setStart(s);
|
|
@@ -5711,6 +5712,7 @@ function RadioSection({
|
|
|
5711
5712
|
value,
|
|
5712
5713
|
onPick,
|
|
5713
5714
|
first,
|
|
5715
|
+
className,
|
|
5714
5716
|
testId
|
|
5715
5717
|
}) {
|
|
5716
5718
|
const id = useId10();
|
|
@@ -5726,7 +5728,7 @@ function RadioSection({
|
|
|
5726
5728
|
const el = e.currentTarget.querySelectorAll('[role="radio"]:not([aria-disabled="true"])')[next];
|
|
5727
5729
|
el?.focus();
|
|
5728
5730
|
};
|
|
5729
|
-
return /* @__PURE__ */ jsxs50(
|
|
5731
|
+
return /* @__PURE__ */ jsxs50("div", { className: cn("flex min-w-0 flex-col p-1", className), children: [
|
|
5730
5732
|
/* @__PURE__ */ jsx57(MenuLabel, { id, children: label }),
|
|
5731
5733
|
/* @__PURE__ */ jsx57("div", { role: "radiogroup", "aria-labelledby": id, onKeyDown: onKey, "data-testid": testId, "data-first-group": first ? "" : void 0, className: "flex flex-col", children: rows.map((r) => {
|
|
5732
5734
|
const checked = r.id === value;
|
|
@@ -5758,8 +5760,6 @@ function RadioSection({
|
|
|
5758
5760
|
function HeaderMenuTrigger({
|
|
5759
5761
|
menu,
|
|
5760
5762
|
columnLabel,
|
|
5761
|
-
sortDir,
|
|
5762
|
-
onSort,
|
|
5763
5763
|
testId
|
|
5764
5764
|
}) {
|
|
5765
5765
|
const [open, setOpen] = useState19(false);
|
|
@@ -5771,11 +5771,9 @@ function HeaderMenuTrigger({
|
|
|
5771
5771
|
const breakLabel = breakOutBy?.value != null ? breakOutBy.options.find((o) => o.id === breakOutBy.value)?.label : void 0;
|
|
5772
5772
|
const [draftGroup, setDraftGroup] = useState19(groupBy.value);
|
|
5773
5773
|
const [draftBreak, setDraftBreak] = useState19(breakOutBy?.value ?? null);
|
|
5774
|
-
const [draftSort, setDraftSort] = useState19(sortDir);
|
|
5775
5774
|
const openPanel = () => {
|
|
5776
5775
|
setDraftGroup(groupBy.value);
|
|
5777
5776
|
setDraftBreak(breakOutBy?.value ?? null);
|
|
5778
|
-
setDraftSort(sortDir);
|
|
5779
5777
|
setOpen(true);
|
|
5780
5778
|
};
|
|
5781
5779
|
const close = useCallback5((refocus) => {
|
|
@@ -5785,7 +5783,6 @@ function HeaderMenuTrigger({
|
|
|
5785
5783
|
const apply = () => {
|
|
5786
5784
|
if (draftGroup !== groupBy.value) groupBy.onChange(draftGroup);
|
|
5787
5785
|
if (breakOutBy && draftBreak !== breakOutBy.value) breakOutBy.onChange(draftBreak);
|
|
5788
|
-
if (onSort && draftSort && draftSort !== sortDir) onSort(draftSort);
|
|
5789
5786
|
close(true);
|
|
5790
5787
|
};
|
|
5791
5788
|
const place = useCallback5(() => {
|
|
@@ -5889,9 +5886,13 @@ function HeaderMenuTrigger({
|
|
|
5889
5886
|
"data-testid": testId && `${testId}-menu`,
|
|
5890
5887
|
onKeyDown: onPanelKey,
|
|
5891
5888
|
style: { position: "fixed", top: pos?.top ?? 0, left: pos?.left ?? 0, visibility: pos ? void 0 : "hidden" },
|
|
5892
|
-
className:
|
|
5889
|
+
className: cn(
|
|
5890
|
+
"z-dropdown flex max-h-120 flex-col overflow-hidden rounded-card border border-border-default bg-surface text-left normal-case tracking-normal shadow-overlay",
|
|
5891
|
+
// Two columns side by side, as Advertising Trends' Group by.
|
|
5892
|
+
breakOutBy ? "w-105" : "w-60"
|
|
5893
|
+
),
|
|
5893
5894
|
children: [
|
|
5894
|
-
/* @__PURE__ */ jsxs50("div", { className: "
|
|
5895
|
+
/* @__PURE__ */ jsxs50("div", { className: cn("grid min-h-0 overflow-y-auto", breakOutBy && "grid-cols-2"), children: [
|
|
5895
5896
|
/* @__PURE__ */ jsx57(
|
|
5896
5897
|
RadioSection,
|
|
5897
5898
|
{
|
|
@@ -5899,38 +5900,21 @@ function HeaderMenuTrigger({
|
|
|
5899
5900
|
label: groupBy.label ?? "Group rows by",
|
|
5900
5901
|
rows: groupBy.options,
|
|
5901
5902
|
value: draftGroup,
|
|
5902
|
-
onPick: pickGroup
|
|
5903
|
+
onPick: pickGroup,
|
|
5904
|
+
className: breakOutBy ? "border-r border-border-default" : void 0
|
|
5903
5905
|
}
|
|
5904
5906
|
),
|
|
5905
|
-
breakOutBy && /* @__PURE__ */
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
{
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
}
|
|
5915
|
-
)
|
|
5916
|
-
] }),
|
|
5917
|
-
onSort && /* @__PURE__ */ jsxs50(Fragment7, { children: [
|
|
5918
|
-
/* @__PURE__ */ jsx57(MenuSeparator, {}),
|
|
5919
|
-
/* @__PURE__ */ jsx57(
|
|
5920
|
-
RadioSection,
|
|
5921
|
-
{
|
|
5922
|
-
label: "Sort",
|
|
5923
|
-
rows: [
|
|
5924
|
-
{ id: "asc", label: "A to Z" },
|
|
5925
|
-
{ id: "desc", label: "Z to A" }
|
|
5926
|
-
],
|
|
5927
|
-
value: draftSort ?? void 0,
|
|
5928
|
-
onPick: setDraftSort
|
|
5929
|
-
}
|
|
5930
|
-
)
|
|
5931
|
-
] })
|
|
5907
|
+
breakOutBy && /* @__PURE__ */ jsx57(
|
|
5908
|
+
RadioSection,
|
|
5909
|
+
{
|
|
5910
|
+
label: breakOutBy.label ?? "Then break out by",
|
|
5911
|
+
rows: [{ id: null, label: "None" }, ...breakOutBy.options.map((o) => ({ ...o, disabled: o.id === draftGroup }))],
|
|
5912
|
+
value: draftBreak,
|
|
5913
|
+
onPick: setDraftBreak
|
|
5914
|
+
}
|
|
5915
|
+
)
|
|
5932
5916
|
] }),
|
|
5933
|
-
/* @__PURE__ */ jsx57(FilterDropdownFooter, {
|
|
5917
|
+
/* @__PURE__ */ jsx57(FilterDropdownFooter, { onApply: apply })
|
|
5934
5918
|
]
|
|
5935
5919
|
}
|
|
5936
5920
|
),
|
|
@@ -6147,8 +6131,10 @@ function DataTable({
|
|
|
6147
6131
|
const [barH, setBarH] = useState20(0);
|
|
6148
6132
|
const [scrollPad, setScrollPad] = useState20({ top: 0, bottom: 0 });
|
|
6149
6133
|
const [footerStuck, setFooterStuck] = useState20(false);
|
|
6150
|
-
const [
|
|
6151
|
-
const
|
|
6134
|
+
const [edges, setEdges] = useState20({ left: 0, right: 0 });
|
|
6135
|
+
const railRef = useRef21(null);
|
|
6136
|
+
const [scrollW, setScrollW] = useState20(0);
|
|
6137
|
+
const [overflows, setOverflows] = useState20(false);
|
|
6152
6138
|
useEffect19(() => {
|
|
6153
6139
|
const thead = theadRef.current;
|
|
6154
6140
|
if (!sticky || !thead || typeof ResizeObserver === "undefined") return void 0;
|
|
@@ -6171,9 +6157,9 @@ function DataTable({
|
|
|
6171
6157
|
const update = () => {
|
|
6172
6158
|
const thead = theadRef.current;
|
|
6173
6159
|
const clone = cloneRef.current;
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6160
|
+
const isStuck = !!thead && !!clone && clone.getBoundingClientRect().top > thead.getBoundingClientRect().top + 0.5;
|
|
6161
|
+
setStuck(isStuck);
|
|
6162
|
+
setFooterStuck(isStuck && wrap.getBoundingClientRect().bottom > viewportOf(root).bottom + 1);
|
|
6177
6163
|
};
|
|
6178
6164
|
const measure = () => {
|
|
6179
6165
|
root = scrollParent(wrap);
|
|
@@ -6182,17 +6168,28 @@ function DataTable({
|
|
|
6182
6168
|
const next = scrollPadding(root);
|
|
6183
6169
|
return prev.top === next.top && prev.bottom === next.bottom ? prev : next;
|
|
6184
6170
|
});
|
|
6171
|
+
const pr = wrap.getBoundingClientRect();
|
|
6172
|
+
const rr = root?.getBoundingClientRect();
|
|
6173
|
+
const boxLeft = root && rr ? rr.left + root.clientLeft : 0;
|
|
6174
|
+
const boxRight = root && rr ? rr.left + root.clientLeft + root.clientWidth : document.documentElement.clientWidth;
|
|
6175
|
+
const nextEdges = { left: Math.max(0, Math.round(pr.left - boxLeft)), right: Math.max(0, Math.round(boxRight - pr.right)) };
|
|
6176
|
+
setEdges((prev) => prev.left === nextEdges.left && prev.right === nextEdges.right ? prev : nextEdges);
|
|
6177
|
+
const sc = scroller.current;
|
|
6178
|
+
if (sc) {
|
|
6179
|
+
setScrollW(sc.scrollWidth);
|
|
6180
|
+
setOverflows(sc.scrollWidth > sc.clientWidth + 1);
|
|
6181
|
+
}
|
|
6185
6182
|
update();
|
|
6186
6183
|
};
|
|
6187
6184
|
measure();
|
|
6188
|
-
const raf = requestAnimationFrame(() => setAnimate(true));
|
|
6189
6185
|
document.addEventListener("scroll", update, { capture: true, passive: true });
|
|
6190
6186
|
window.addEventListener("resize", measure);
|
|
6191
6187
|
const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
6192
6188
|
if (bar2) ro?.observe(bar2);
|
|
6193
6189
|
ro?.observe(wrap);
|
|
6190
|
+
const table = scroller.current?.firstElementChild;
|
|
6191
|
+
if (table) ro?.observe(table);
|
|
6194
6192
|
return () => {
|
|
6195
|
-
cancelAnimationFrame(raf);
|
|
6196
6193
|
document.removeEventListener("scroll", update, { capture: true });
|
|
6197
6194
|
window.removeEventListener("resize", measure);
|
|
6198
6195
|
ro?.disconnect();
|
|
@@ -6271,7 +6268,7 @@ function DataTable({
|
|
|
6271
6268
|
{
|
|
6272
6269
|
ref: !clone && ci <= nameIdx ? headRef(ci) : void 0,
|
|
6273
6270
|
scope: "col",
|
|
6274
|
-
"aria-sort": c.sortable
|
|
6271
|
+
"aria-sort": c.sortable && !c.headerMenu ? ariaSortFor(shown, c.key) : void 0,
|
|
6275
6272
|
className: cn(
|
|
6276
6273
|
"group/head whitespace-nowrap border-b border-border-default font-semibold",
|
|
6277
6274
|
head,
|
|
@@ -6287,8 +6284,6 @@ function DataTable({
|
|
|
6287
6284
|
{
|
|
6288
6285
|
menu: c.headerMenu,
|
|
6289
6286
|
columnLabel: c.label,
|
|
6290
|
-
sortDir: shown?.key === c.key ? shown.dir : null,
|
|
6291
|
-
onSort: onSortChange ? (dir) => onSortChange({ key: c.key, dir }) : void 0,
|
|
6292
6287
|
testId: clone || !testIdPrefix ? void 0 : `${testIdPrefix}-header-menu-${c.key}`
|
|
6293
6288
|
}
|
|
6294
6289
|
) : c.sortable && onSortChange ? /* @__PURE__ */ jsx58(
|
|
@@ -6330,8 +6325,15 @@ function DataTable({
|
|
|
6330
6325
|
onScroll: (e) => {
|
|
6331
6326
|
setScrolled(e.currentTarget.scrollLeft > 0);
|
|
6332
6327
|
if (cloneRef.current) cloneRef.current.scrollLeft = e.currentTarget.scrollLeft;
|
|
6328
|
+
if (railRef.current && railRef.current.scrollLeft !== e.currentTarget.scrollLeft) railRef.current.scrollLeft = e.currentTarget.scrollLeft;
|
|
6333
6329
|
},
|
|
6334
|
-
className: cn(
|
|
6330
|
+
className: cn(
|
|
6331
|
+
"overflow-x-auto",
|
|
6332
|
+
// Sticky: its own bar is hidden; the one under the table stands in
|
|
6333
|
+
// for it, so it can pin to the bottom of the screen.
|
|
6334
|
+
sticky ? "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden" : SCROLLBAR,
|
|
6335
|
+
maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])
|
|
6336
|
+
),
|
|
6335
6337
|
children: /* @__PURE__ */ jsxs51(
|
|
6336
6338
|
"table",
|
|
6337
6339
|
{
|
|
@@ -6469,12 +6471,17 @@ function DataTable({
|
|
|
6469
6471
|
"div",
|
|
6470
6472
|
{
|
|
6471
6473
|
className: cn(
|
|
6472
|
-
"relative flex w-full flex-col
|
|
6474
|
+
"relative flex w-full flex-col border border-border-default bg-surface",
|
|
6475
|
+
// Full screen mode (sticky, header stuck): edge to edge, square
|
|
6476
|
+
// corners, no side borders, like StickyBar's band.
|
|
6477
|
+
sticky && stuck ? "rounded-none border-x-transparent" : "rounded-card",
|
|
6473
6478
|
// clip, not hidden, on a sticky table: hidden would make the frame the
|
|
6474
6479
|
// box its header sticks in, instead of the page.
|
|
6475
6480
|
sticky ? "overflow-clip" : "overflow-hidden",
|
|
6476
6481
|
!sticky && bare && className
|
|
6477
6482
|
),
|
|
6483
|
+
style: sticky && stuck && (edges.left || edges.right) ? { marginLeft: -edges.left, marginRight: -edges.right, width: "auto" } : void 0,
|
|
6484
|
+
"data-full-screen": sticky && stuck ? "" : void 0,
|
|
6478
6485
|
"data-testid": testIdPrefix,
|
|
6479
6486
|
children: [
|
|
6480
6487
|
title && inside && /* @__PURE__ */ jsxs51("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
|
|
@@ -6513,22 +6520,36 @@ function DataTable({
|
|
|
6513
6520
|
]
|
|
6514
6521
|
}
|
|
6515
6522
|
);
|
|
6516
|
-
const
|
|
6523
|
+
const bleed = stuck && (edges.left || edges.right);
|
|
6517
6524
|
const body = sticky ? /* @__PURE__ */ jsxs51("div", { ref: wrapRef, className: cn("flex w-full flex-col", bare && className), children: [
|
|
6518
6525
|
frame,
|
|
6519
|
-
footer && /* @__PURE__ */
|
|
6526
|
+
(footer || overflows) && /* @__PURE__ */ jsxs51(
|
|
6520
6527
|
"div",
|
|
6521
6528
|
{
|
|
6522
6529
|
"data-sticky-footer": "",
|
|
6523
|
-
style:
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6530
|
+
style: {
|
|
6531
|
+
...stuck && scrollPad.bottom ? { bottom: -scrollPad.bottom } : null,
|
|
6532
|
+
...bleed ? { marginLeft: -edges.left, marginRight: -edges.right, paddingLeft: edges.left, paddingRight: edges.right } : null
|
|
6533
|
+
},
|
|
6534
|
+
className: cn("z-3 border-t bg-canvas", stuck && "sticky bottom-0", footerStuck ? "border-border-default" : "border-transparent"),
|
|
6535
|
+
children: [
|
|
6536
|
+
overflows && /* @__PURE__ */ jsx58(
|
|
6537
|
+
"div",
|
|
6538
|
+
{
|
|
6539
|
+
ref: railRef,
|
|
6540
|
+
"aria-hidden": "true",
|
|
6541
|
+
"data-sticky-scrollbar": "",
|
|
6542
|
+
onScroll: (e) => {
|
|
6543
|
+
const x = e.currentTarget.scrollLeft;
|
|
6544
|
+
if (scroller.current && scroller.current.scrollLeft !== x) scroller.current.scrollLeft = x;
|
|
6545
|
+
},
|
|
6546
|
+
className: cn("overflow-x-auto", SCROLLBAR),
|
|
6547
|
+
style: bleed ? { marginLeft: -edges.left, marginRight: -edges.right } : void 0,
|
|
6548
|
+
children: /* @__PURE__ */ jsx58("div", { className: "h-px", style: { width: scrollW } })
|
|
6549
|
+
}
|
|
6550
|
+
),
|
|
6551
|
+
footer && /* @__PURE__ */ jsx58("div", { className: "py-3", children: footer })
|
|
6552
|
+
]
|
|
6532
6553
|
}
|
|
6533
6554
|
)
|
|
6534
6555
|
] }) : frame;
|