@mediaradar/design-components 0.66.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 +66 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -13
- package/dist/index.d.ts +16 -13
- package/dist/index.js +66 -26
- 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`
|
|
@@ -3895,8 +3897,9 @@ 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
|
|
@@ -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
|
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`
|
|
@@ -3895,8 +3897,9 @@ 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
|
|
@@ -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
|
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);
|
|
@@ -6130,8 +6131,10 @@ function DataTable({
|
|
|
6130
6131
|
const [barH, setBarH] = useState20(0);
|
|
6131
6132
|
const [scrollPad, setScrollPad] = useState20({ top: 0, bottom: 0 });
|
|
6132
6133
|
const [footerStuck, setFooterStuck] = useState20(false);
|
|
6133
|
-
const [
|
|
6134
|
-
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);
|
|
6135
6138
|
useEffect19(() => {
|
|
6136
6139
|
const thead = theadRef.current;
|
|
6137
6140
|
if (!sticky || !thead || typeof ResizeObserver === "undefined") return void 0;
|
|
@@ -6154,9 +6157,9 @@ function DataTable({
|
|
|
6154
6157
|
const update = () => {
|
|
6155
6158
|
const thead = theadRef.current;
|
|
6156
6159
|
const clone = cloneRef.current;
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
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);
|
|
6160
6163
|
};
|
|
6161
6164
|
const measure = () => {
|
|
6162
6165
|
root = scrollParent(wrap);
|
|
@@ -6165,17 +6168,28 @@ function DataTable({
|
|
|
6165
6168
|
const next = scrollPadding(root);
|
|
6166
6169
|
return prev.top === next.top && prev.bottom === next.bottom ? prev : next;
|
|
6167
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
|
+
}
|
|
6168
6182
|
update();
|
|
6169
6183
|
};
|
|
6170
6184
|
measure();
|
|
6171
|
-
const raf = requestAnimationFrame(() => setAnimate(true));
|
|
6172
6185
|
document.addEventListener("scroll", update, { capture: true, passive: true });
|
|
6173
6186
|
window.addEventListener("resize", measure);
|
|
6174
6187
|
const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
6175
6188
|
if (bar2) ro?.observe(bar2);
|
|
6176
6189
|
ro?.observe(wrap);
|
|
6190
|
+
const table = scroller.current?.firstElementChild;
|
|
6191
|
+
if (table) ro?.observe(table);
|
|
6177
6192
|
return () => {
|
|
6178
|
-
cancelAnimationFrame(raf);
|
|
6179
6193
|
document.removeEventListener("scroll", update, { capture: true });
|
|
6180
6194
|
window.removeEventListener("resize", measure);
|
|
6181
6195
|
ro?.disconnect();
|
|
@@ -6311,8 +6325,15 @@ function DataTable({
|
|
|
6311
6325
|
onScroll: (e) => {
|
|
6312
6326
|
setScrolled(e.currentTarget.scrollLeft > 0);
|
|
6313
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;
|
|
6314
6329
|
},
|
|
6315
|
-
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
|
+
),
|
|
6316
6337
|
children: /* @__PURE__ */ jsxs51(
|
|
6317
6338
|
"table",
|
|
6318
6339
|
{
|
|
@@ -6450,12 +6471,17 @@ function DataTable({
|
|
|
6450
6471
|
"div",
|
|
6451
6472
|
{
|
|
6452
6473
|
className: cn(
|
|
6453
|
-
"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",
|
|
6454
6478
|
// clip, not hidden, on a sticky table: hidden would make the frame the
|
|
6455
6479
|
// box its header sticks in, instead of the page.
|
|
6456
6480
|
sticky ? "overflow-clip" : "overflow-hidden",
|
|
6457
6481
|
!sticky && bare && className
|
|
6458
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,
|
|
6459
6485
|
"data-testid": testIdPrefix,
|
|
6460
6486
|
children: [
|
|
6461
6487
|
title && inside && /* @__PURE__ */ jsxs51("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
|
|
@@ -6494,22 +6520,36 @@ function DataTable({
|
|
|
6494
6520
|
]
|
|
6495
6521
|
}
|
|
6496
6522
|
);
|
|
6497
|
-
const
|
|
6523
|
+
const bleed = stuck && (edges.left || edges.right);
|
|
6498
6524
|
const body = sticky ? /* @__PURE__ */ jsxs51("div", { ref: wrapRef, className: cn("flex w-full flex-col", bare && className), children: [
|
|
6499
6525
|
frame,
|
|
6500
|
-
footer && /* @__PURE__ */
|
|
6526
|
+
(footer || overflows) && /* @__PURE__ */ jsxs51(
|
|
6501
6527
|
"div",
|
|
6502
6528
|
{
|
|
6503
6529
|
"data-sticky-footer": "",
|
|
6504
|
-
style:
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
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
|
+
]
|
|
6513
6553
|
}
|
|
6514
6554
|
)
|
|
6515
6555
|
] }) : frame;
|