@mediaradar/design-components 0.47.0 → 0.48.1

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
@@ -28,7 +28,7 @@ interface CommonProps {
28
28
  * @description Info tooltip — a small info glyph that opens a portalled,
29
29
  * viewport-clamped bubble. Mirrors the Publisher Intel header affordance so
30
30
  * page subtitles can collapse into the eyebrow.
31
- * @tokens text-text-tertiary, rounded-control, border-border-default, bg-surface,
31
+ * @tokens z-tooltip, text-text-tertiary, rounded-control, border-border-default, bg-surface,
32
32
  * shadow-overlay, text-text-secondary, focus-visible:outline-border-focus,
33
33
  * hover:text-text-primary, tracking-normal
34
34
  * @dependencies lucide-react
@@ -523,9 +523,15 @@ declare const CheckBoxBox: react.ForwardRefExoticComponent<CheckBoxBoxProps & re
523
523
  * e.g. to follow a person's date-format setting. What `onChange` and `onApply`
524
524
  * report keeps the canonical "Nov 14, 2026" form, since apps parse it.
525
525
  * Month-level labels ("Nov 2025") have no day to order and stay as they are.
526
- * @a11y Trigger is a <button> with aria-expanded and an aria-label from the
527
- * caption; the panel is role="dialog" and Escape closes it. Focus is not
528
- * moved into the panel, so it is reached by tabbing.
526
+ * @a11y Trigger is a <button> with aria-expanded, named by its caption and
527
+ * value; the panel is role="dialog". Escape, Cancel and Apply close it and
528
+ * put focus back on the trigger (an outside click leaves focus where it
529
+ * lands). Focus is not moved into the panel, so it is reached by tabbing.
530
+ * Each calendar day is a button named with its full date and place in the
531
+ * range ("Monday, November 3, 2026, start of range"), with aria-pressed on
532
+ * the chosen days; each month's days are a group labelled by its title, and
533
+ * the titles are polite live regions, so paging months is announced. Arrow
534
+ * keys don't move between days yet; Tab does.
529
535
  * @use for every date range in the product; `granularity="month"` for monthly data.
530
536
  * @avoid DateRangePicker, which is being retired.
531
537
  * @usage
@@ -883,7 +889,7 @@ declare function DataScopeFilter({ value, onChange, align, className, testIdPref
883
889
  * `document.body` so the popover is never clipped by a scrollable ancestor
884
890
  * (e.g. inside a modal) -- unlike this package's other chip popovers, none
885
891
  * of which are known to sit inside a clipping container today.
886
- * @tokens text-control-caption, rounded-control, rounded-card, border-border-default,
892
+ * @tokens z-dropdown, text-control-caption, rounded-control, rounded-card, border-border-default,
887
893
  * border-border-strong, bg-input, bg-surface, shadow-overlay,
888
894
  * text-text-primary, text-text-secondary,
889
895
  * text-text-tertiary, hover:bg-subtle, hover:text-text-primary,
@@ -1374,7 +1380,7 @@ declare function StackedColumnPlaceholder({ height, width, legendRows, axis, cla
1374
1380
  * bounding rect and rendered through a portal to `document.body`, so it
1375
1381
  * escapes both `overflow` clipping inside scrollable panels and the broken
1376
1382
  * `fixed` containing block a transformed ancestor creates.
1377
- * @tokens rounded-control, border-border-default, bg-surface, shadow-overlay,
1383
+ * @tokens z-tooltip, rounded-control, border-border-default, bg-surface, shadow-overlay,
1378
1384
  * text-text-primary, bg-text-primary, text-surface,
1379
1385
  * duration-(--mr-motion-duration-interactive)
1380
1386
  * @variant surface - Default. Themed surface/border bubble -- matches the
@@ -1689,6 +1695,7 @@ interface SelectionPickerProps<T extends PickerRow> extends CommonProps {
1689
1695
  }
1690
1696
  /**
1691
1697
  * @pattern SelectionPicker
1698
+ * @audited 2026-11-13
1692
1699
  * @status stable
1693
1700
  * @description Generic search-and-filter picker for building a selection out
1694
1701
  * of a larger catalog -- a search box plus filter dropdowns above a checkbox
@@ -1700,7 +1707,7 @@ interface SelectionPickerProps<T extends PickerRow> extends CommonProps {
1700
1707
  * filtered client-side (the default), or externally-computed `results` for a
1701
1708
  * caller whose search is server-side/async, with `loading`/`error`/
1702
1709
  * `hasMore`/`onLoadMore` covering that mode's states.
1703
- * @tokens text-micro, text-dense, border-border-strong, rounded-control, rounded-card, border-border-default, bg-input, focus-within:outline-border-focus,
1710
+ * @tokens tracking-wider, z-dropdown, text-micro, text-dense, border-border-strong, rounded-control, rounded-card, border-border-default, bg-input, focus-within:outline-border-focus,
1704
1711
  * bg-canvas, bg-surface, shadow-raised, shadow-overlay, text-text-primary,
1705
1712
  * text-text-secondary, text-text-tertiary, text-text-link,
1706
1713
  * text-brand-primaryAction, border-brand-primaryAction, bg-brand-primaryAction,
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ interface CommonProps {
28
28
  * @description Info tooltip — a small info glyph that opens a portalled,
29
29
  * viewport-clamped bubble. Mirrors the Publisher Intel header affordance so
30
30
  * page subtitles can collapse into the eyebrow.
31
- * @tokens text-text-tertiary, rounded-control, border-border-default, bg-surface,
31
+ * @tokens z-tooltip, text-text-tertiary, rounded-control, border-border-default, bg-surface,
32
32
  * shadow-overlay, text-text-secondary, focus-visible:outline-border-focus,
33
33
  * hover:text-text-primary, tracking-normal
34
34
  * @dependencies lucide-react
@@ -523,9 +523,15 @@ declare const CheckBoxBox: react.ForwardRefExoticComponent<CheckBoxBoxProps & re
523
523
  * e.g. to follow a person's date-format setting. What `onChange` and `onApply`
524
524
  * report keeps the canonical "Nov 14, 2026" form, since apps parse it.
525
525
  * Month-level labels ("Nov 2025") have no day to order and stay as they are.
526
- * @a11y Trigger is a <button> with aria-expanded and an aria-label from the
527
- * caption; the panel is role="dialog" and Escape closes it. Focus is not
528
- * moved into the panel, so it is reached by tabbing.
526
+ * @a11y Trigger is a <button> with aria-expanded, named by its caption and
527
+ * value; the panel is role="dialog". Escape, Cancel and Apply close it and
528
+ * put focus back on the trigger (an outside click leaves focus where it
529
+ * lands). Focus is not moved into the panel, so it is reached by tabbing.
530
+ * Each calendar day is a button named with its full date and place in the
531
+ * range ("Monday, November 3, 2026, start of range"), with aria-pressed on
532
+ * the chosen days; each month's days are a group labelled by its title, and
533
+ * the titles are polite live regions, so paging months is announced. Arrow
534
+ * keys don't move between days yet; Tab does.
529
535
  * @use for every date range in the product; `granularity="month"` for monthly data.
530
536
  * @avoid DateRangePicker, which is being retired.
531
537
  * @usage
@@ -883,7 +889,7 @@ declare function DataScopeFilter({ value, onChange, align, className, testIdPref
883
889
  * `document.body` so the popover is never clipped by a scrollable ancestor
884
890
  * (e.g. inside a modal) -- unlike this package's other chip popovers, none
885
891
  * of which are known to sit inside a clipping container today.
886
- * @tokens text-control-caption, rounded-control, rounded-card, border-border-default,
892
+ * @tokens z-dropdown, text-control-caption, rounded-control, rounded-card, border-border-default,
887
893
  * border-border-strong, bg-input, bg-surface, shadow-overlay,
888
894
  * text-text-primary, text-text-secondary,
889
895
  * text-text-tertiary, hover:bg-subtle, hover:text-text-primary,
@@ -1374,7 +1380,7 @@ declare function StackedColumnPlaceholder({ height, width, legendRows, axis, cla
1374
1380
  * bounding rect and rendered through a portal to `document.body`, so it
1375
1381
  * escapes both `overflow` clipping inside scrollable panels and the broken
1376
1382
  * `fixed` containing block a transformed ancestor creates.
1377
- * @tokens rounded-control, border-border-default, bg-surface, shadow-overlay,
1383
+ * @tokens z-tooltip, rounded-control, border-border-default, bg-surface, shadow-overlay,
1378
1384
  * text-text-primary, bg-text-primary, text-surface,
1379
1385
  * duration-(--mr-motion-duration-interactive)
1380
1386
  * @variant surface - Default. Themed surface/border bubble -- matches the
@@ -1689,6 +1695,7 @@ interface SelectionPickerProps<T extends PickerRow> extends CommonProps {
1689
1695
  }
1690
1696
  /**
1691
1697
  * @pattern SelectionPicker
1698
+ * @audited 2026-11-13
1692
1699
  * @status stable
1693
1700
  * @description Generic search-and-filter picker for building a selection out
1694
1701
  * of a larger catalog -- a search box plus filter dropdowns above a checkbox
@@ -1700,7 +1707,7 @@ interface SelectionPickerProps<T extends PickerRow> extends CommonProps {
1700
1707
  * filtered client-side (the default), or externally-computed `results` for a
1701
1708
  * caller whose search is server-side/async, with `loading`/`error`/
1702
1709
  * `hasMore`/`onLoadMore` covering that mode's states.
1703
- * @tokens text-micro, text-dense, border-border-strong, rounded-control, rounded-card, border-border-default, bg-input, focus-within:outline-border-focus,
1710
+ * @tokens tracking-wider, z-dropdown, text-micro, text-dense, border-border-strong, rounded-control, rounded-card, border-border-default, bg-input, focus-within:outline-border-focus,
1704
1711
  * bg-canvas, bg-surface, shadow-raised, shadow-overlay, text-text-primary,
1705
1712
  * text-text-secondary, text-text-tertiary, text-text-link,
1706
1713
  * text-brand-primaryAction, border-brand-primaryAction, bg-brand-primaryAction,
package/dist/index.js CHANGED
@@ -103,7 +103,7 @@ function InfoTip({ text, size = 11, label = "More information", trigger = "click
103
103
  onMouseEnter: trigger === "hover" ? cancelClose : void 0,
104
104
  onMouseLeave: trigger === "hover" ? closeSoon : void 0,
105
105
  style: { position: "fixed", top: pos.top, left: pos.left, width: pos.width },
106
- className: "z-[90] rounded-control border border-border-default bg-surface px-3 py-2 text-xs font-normal not-italic normal-case leading-relaxed tracking-normal text-text-secondary shadow-overlay",
106
+ className: "z-tooltip rounded-control border border-border-default bg-surface px-3 py-2 text-xs font-normal not-italic normal-case leading-relaxed tracking-normal text-text-secondary shadow-overlay",
107
107
  children: text
108
108
  }
109
109
  ),
@@ -704,6 +704,7 @@ var CREATIVE_INTEL_SHORTCUTS = [
704
704
  ];
705
705
  var HIDDEN_SHORTCUTS = ["Last 30 days"];
706
706
  var WEEKDAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
707
+ var WEEKDAY_NAMES = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
707
708
  var MONTHS = [
708
709
  "January",
709
710
  "February",
@@ -732,6 +733,14 @@ var fmtMonth = (d) => `${MONTHS[d.getMonth()].slice(0, 3)} ${d.getFullYear()}`;
732
733
  var fmt = (d) => `${MONTHS[d.getMonth()].slice(0, 3)} ${d.getDate()}, ${d.getFullYear()}`;
733
734
  var fmtFull = (d) => `${MONTHS[d.getMonth()]} ${d.getDate()}, ${d.getFullYear()}`;
734
735
  var fullRangeLabel = (s, e) => `${fmtFull(s)} - ${fmtFull(e)}`;
736
+ function dayLabel(d, place) {
737
+ const base = `${WEEKDAY_NAMES[d.getDay()]}, ${fmtFull(d)}`;
738
+ if (place === "single") return `${base}, start and end of range`;
739
+ if (place === "start") return `${base}, start of range`;
740
+ if (place === "end") return `${base}, end of range`;
741
+ if (place === "in") return `${base}, in range`;
742
+ return base;
743
+ }
735
744
  var presetLabel = (sc) => sc === "Custom" ? "Custom range" : sc;
736
745
  var MON = (d) => MONTHS[d.getMonth()].slice(0, 3);
737
746
  function spanLabel(s, e) {
@@ -876,6 +885,7 @@ function DateRangeFilter({
876
885
  const [end, setEnd] = useState3(initRange[1]);
877
886
  const [leftMonth, setLeftMonth] = useState3(new Date(initRange[0].getFullYear(), initRange[0].getMonth(), 1));
878
887
  const ref = useRef3(null);
888
+ const triggerRef = useRef3(null);
879
889
  useEffect3(() => {
880
890
  if (controlled || startsEmpty) return;
881
891
  onRangeChange?.(committed.current.start, committed.current.end);
@@ -891,7 +901,11 @@ function DateRangeFilter({
891
901
  setEnd(hasRange ? committedEnd : null);
892
902
  setLeftMonth(hasRange ? new Date(committedStart.getFullYear(), committedStart.getMonth(), 1) : addMonths(today, -1));
893
903
  setCmp(committedCmp.current);
894
- const onKey = (e) => e.key === "Escape" && setOpen(false);
904
+ const onKey = (e) => {
905
+ if (e.key !== "Escape") return;
906
+ setOpen(false);
907
+ triggerRef.current?.focus();
908
+ };
895
909
  const onClick = (e) => {
896
910
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
897
911
  };
@@ -941,8 +955,10 @@ function DateRangeFilter({
941
955
  onRangeChange?.(s, e);
942
956
  onApply?.(shortcut === "Custom" ? `${fmt(s)} \u2013 ${fmt(e)}` : shortcut, s, e, cmp);
943
957
  setOpen(false);
958
+ triggerRef.current?.focus();
944
959
  };
945
960
  const popRef = useRef3(null);
961
+ const monthIdBase = useId2();
946
962
  const [flipBelow, setFlipBelow] = useState3(false);
947
963
  useLayoutEffect(() => {
948
964
  if (!open || placement !== "above" || !ref.current || !popRef.current) return;
@@ -953,6 +969,7 @@ function DateRangeFilter({
953
969
  /* @__PURE__ */ jsxs7(
954
970
  "button",
955
971
  {
972
+ ref: triggerRef,
956
973
  type: "button",
957
974
  "data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
958
975
  onClick: () => setOpen((v) => !v),
@@ -1007,15 +1024,15 @@ function DateRangeFilter({
1007
1024
  return /* @__PURE__ */ jsxs7("div", { className: "w-[252px]", children: [
1008
1025
  /* @__PURE__ */ jsxs7("div", { className: "mb-2 flex items-center justify-between", children: [
1009
1026
  offset === 0 ? /* @__PURE__ */ jsx8(NavBtn, { onClick: () => setLeftMonth(addMonths(leftMonth, -1)), "aria-label": "Previous month", children: /* @__PURE__ */ jsx8(ChevronLeft, { size: 16 }) }) : /* @__PURE__ */ jsx8("span", { className: "h-7 w-7" }),
1010
- /* @__PURE__ */ jsxs7("span", { className: "text-panel-title font-semibold text-text-primary", children: [
1027
+ /* @__PURE__ */ jsxs7("span", { id: `${monthIdBase}-m${offset}`, "aria-live": "polite", className: "text-panel-title font-semibold text-text-primary", children: [
1011
1028
  MONTHS[m.getMonth()],
1012
1029
  " ",
1013
1030
  m.getFullYear()
1014
1031
  ] }),
1015
1032
  offset === 1 ? /* @__PURE__ */ jsx8(NavBtn, { onClick: () => setLeftMonth(addMonths(leftMonth, 1)), "aria-label": "Next month", children: /* @__PURE__ */ jsx8(ChevronRight, { size: 16 }) }) : /* @__PURE__ */ jsx8("span", { className: "h-7 w-7" })
1016
1033
  ] }),
1017
- /* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-7", children: [
1018
- WEEKDAYS.map((w) => /* @__PURE__ */ jsx8("div", { className: "flex h-8 items-center justify-center text-xs font-semibold text-text-secondary", children: w }, w)),
1034
+ /* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-7", role: "group", "aria-labelledby": `${monthIdBase}-m${offset}`, children: [
1035
+ WEEKDAYS.map((w) => /* @__PURE__ */ jsx8("div", { "aria-hidden": "true", className: "flex h-8 items-center justify-center text-xs font-semibold text-text-secondary", children: w }, w)),
1019
1036
  grid.map((d, i) => {
1020
1037
  const inMonth = d.getMonth() === m.getMonth();
1021
1038
  const hasRange = !!(start && end);
@@ -1030,16 +1047,27 @@ function DateRangeFilter({
1030
1047
  else if (end && isEnd) band = "left-0 right-1/2";
1031
1048
  else band = "left-0 right-0";
1032
1049
  }
1033
- return /* @__PURE__ */ jsxs7("button", { type: "button", onClick: () => pickDay(d), className: "relative flex h-9 items-center justify-center focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus", children: [
1034
- band && /* @__PURE__ */ jsx8("span", { className: `absolute inset-y-[3px] bg-ai-tint ${band}`, "aria-hidden": "true" }),
1035
- /* @__PURE__ */ jsx8(
1036
- "span",
1037
- {
1038
- className: `relative z-10 flex h-8 w-8 items-center justify-center rounded-full text-dense tabular-nums ${endpoint ? "bg-brand-primaryAction font-semibold text-brand-onprimary" : inMonth ? "text-text-primary hover:bg-subtle" : "text-text-tertiary"}`,
1039
- children: d.getDate()
1040
- }
1041
- )
1042
- ] }, i);
1050
+ return /* @__PURE__ */ jsxs7(
1051
+ "button",
1052
+ {
1053
+ type: "button",
1054
+ onClick: () => pickDay(d),
1055
+ "aria-label": dayLabel(d, single ? "single" : isStart ? "start" : end && isEnd ? "end" : inRange ? "in" : null),
1056
+ "aria-pressed": endpoint || inRange,
1057
+ className: "relative flex h-9 items-center justify-center focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
1058
+ children: [
1059
+ band && /* @__PURE__ */ jsx8("span", { className: `absolute inset-y-[3px] bg-ai-tint ${band}`, "aria-hidden": "true" }),
1060
+ /* @__PURE__ */ jsx8(
1061
+ "span",
1062
+ {
1063
+ className: `relative z-10 flex h-8 w-8 items-center justify-center rounded-full text-dense tabular-nums ${endpoint ? "bg-brand-primaryAction font-semibold text-brand-onprimary" : inMonth ? "text-text-primary hover:bg-subtle" : "text-text-tertiary"}`,
1064
+ children: d.getDate()
1065
+ }
1066
+ )
1067
+ ]
1068
+ },
1069
+ i
1070
+ );
1043
1071
  })
1044
1072
  ] })
1045
1073
  ] }, offset);
@@ -1075,7 +1103,10 @@ function DateRangeFilter({
1075
1103
  ] }),
1076
1104
  /* @__PURE__ */ jsxs7("div", { className: "mt-4 flex items-center justify-end gap-2", children: [
1077
1105
  monthly && /* @__PURE__ */ jsx8("span", { className: "mr-auto text-xs text-text-tertiary", children: "Data is monthly, so ranges cover whole months." }),
1078
- /* @__PURE__ */ jsx8("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-cancel`, onClick: () => setOpen(false), className: "rounded-control border border-border-default bg-surface px-5 py-2 text-dense font-semibold text-text-primary transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Cancel" }),
1106
+ /* @__PURE__ */ jsx8("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-cancel`, onClick: () => {
1107
+ setOpen(false);
1108
+ triggerRef.current?.focus();
1109
+ }, className: "rounded-control border border-border-default bg-surface px-5 py-2 text-dense font-semibold text-text-primary transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Cancel" }),
1079
1110
  /* @__PURE__ */ jsx8("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-apply`, onClick: apply, disabled: !canApply, className: "rounded-control bg-brand-primaryAction px-5 py-2 text-dense font-semibold text-brand-onprimary transition-[filter] hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Apply" })
1080
1111
  ] })
1081
1112
  ] })
@@ -1931,7 +1962,7 @@ function SelectFilter({
1931
1962
  "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
1932
1963
  style: { position: "fixed", top: pos.top, left: pos.left, right: pos.right, width: fullWidth ? pos.width : void 0 },
1933
1964
  className: cn(
1934
- "z-[65] flex flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
1965
+ "z-dropdown flex flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
1935
1966
  !fullWidth && (sm ? "w-max min-w-28 max-w-72" : "w-56")
1936
1967
  ),
1937
1968
  role: loading || error ? "group" : "listbox",
@@ -2557,7 +2588,7 @@ function Tooltip({
2557
2588
  onMouseLeave: interactive ? hide : void 0,
2558
2589
  onTransitionEnd: onBoxTransitionEnd,
2559
2590
  className: cn(
2560
- "fixed z-[90] w-max max-w-xs whitespace-normal break-words px-2.5 py-1.5 text-xs leading-snug",
2591
+ "fixed z-tooltip w-max max-w-xs whitespace-normal break-words px-2.5 py-1.5 text-xs leading-snug",
2561
2592
  // Fade in/out. The sys duration token rather than a ref one:
2562
2593
  // it is what Button's hover/press transition uses, and a
2563
2594
  // tooltip's fade is the same kind of interactive feedback.
@@ -2919,7 +2950,7 @@ function SelectionPicker({
2919
2950
  "div",
2920
2951
  {
2921
2952
  className: cn(
2922
- "grid items-center gap-2 border-b border-border-default bg-canvas px-3 py-2 text-micro font-semibold uppercase tracking-[0.06em] text-text-secondary",
2953
+ "grid items-center gap-2 border-b border-border-default bg-canvas px-3 py-2 text-micro font-semibold uppercase tracking-wider text-text-secondary",
2923
2954
  rowGridCols
2924
2955
  ),
2925
2956
  children: [
@@ -3207,7 +3238,7 @@ function FilterDropdown({
3207
3238
  role: "group",
3208
3239
  "aria-label": filter.label,
3209
3240
  style: { top: pos.top, left: pos.left },
3210
- className: "fixed z-[80] min-w-55 rounded-card border border-border-default bg-surface p-2 shadow-overlay",
3241
+ className: "fixed z-dropdown min-w-55 rounded-card border border-border-default bg-surface p-2 shadow-overlay",
3211
3242
  children: [
3212
3243
  searchable && /* @__PURE__ */ jsxs25("div", { className: "mb-1.5 flex h-8 items-center gap-2 rounded-control border border-border-strong bg-input px-2.5", children: [
3213
3244
  /* @__PURE__ */ jsx27(Search4, { size: 14, className: "shrink-0 text-text-secondary", "aria-hidden": "true" }),