@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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.47.0",
2
+ "version": "0.48.1",
3
3
  "components": [
4
4
  "AISpark",
5
5
  "AdvertiserNoResults",
package/dist/index.cjs CHANGED
@@ -194,7 +194,7 @@ function InfoTip({ text, size = 11, label = "More information", trigger = "click
194
194
  onMouseEnter: trigger === "hover" ? cancelClose : void 0,
195
195
  onMouseLeave: trigger === "hover" ? closeSoon : void 0,
196
196
  style: { position: "fixed", top: pos.top, left: pos.left, width: pos.width },
197
- 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",
197
+ 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",
198
198
  children: text
199
199
  }
200
200
  ),
@@ -795,6 +795,7 @@ var CREATIVE_INTEL_SHORTCUTS = [
795
795
  ];
796
796
  var HIDDEN_SHORTCUTS = ["Last 30 days"];
797
797
  var WEEKDAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
798
+ var WEEKDAY_NAMES = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
798
799
  var MONTHS = [
799
800
  "January",
800
801
  "February",
@@ -823,6 +824,14 @@ var fmtMonth = (d) => `${MONTHS[d.getMonth()].slice(0, 3)} ${d.getFullYear()}`;
823
824
  var fmt = (d) => `${MONTHS[d.getMonth()].slice(0, 3)} ${d.getDate()}, ${d.getFullYear()}`;
824
825
  var fmtFull = (d) => `${MONTHS[d.getMonth()]} ${d.getDate()}, ${d.getFullYear()}`;
825
826
  var fullRangeLabel = (s, e) => `${fmtFull(s)} - ${fmtFull(e)}`;
827
+ function dayLabel(d, place) {
828
+ const base = `${WEEKDAY_NAMES[d.getDay()]}, ${fmtFull(d)}`;
829
+ if (place === "single") return `${base}, start and end of range`;
830
+ if (place === "start") return `${base}, start of range`;
831
+ if (place === "end") return `${base}, end of range`;
832
+ if (place === "in") return `${base}, in range`;
833
+ return base;
834
+ }
826
835
  var presetLabel = (sc) => sc === "Custom" ? "Custom range" : sc;
827
836
  var MON = (d) => MONTHS[d.getMonth()].slice(0, 3);
828
837
  function spanLabel(s, e) {
@@ -967,6 +976,7 @@ function DateRangeFilter({
967
976
  const [end, setEnd] = (0, import_react4.useState)(initRange[1]);
968
977
  const [leftMonth, setLeftMonth] = (0, import_react4.useState)(new Date(initRange[0].getFullYear(), initRange[0].getMonth(), 1));
969
978
  const ref = (0, import_react4.useRef)(null);
979
+ const triggerRef = (0, import_react4.useRef)(null);
970
980
  (0, import_react4.useEffect)(() => {
971
981
  if (controlled || startsEmpty) return;
972
982
  onRangeChange?.(committed.current.start, committed.current.end);
@@ -982,7 +992,11 @@ function DateRangeFilter({
982
992
  setEnd(hasRange ? committedEnd : null);
983
993
  setLeftMonth(hasRange ? new Date(committedStart.getFullYear(), committedStart.getMonth(), 1) : addMonths(today, -1));
984
994
  setCmp(committedCmp.current);
985
- const onKey = (e) => e.key === "Escape" && setOpen(false);
995
+ const onKey = (e) => {
996
+ if (e.key !== "Escape") return;
997
+ setOpen(false);
998
+ triggerRef.current?.focus();
999
+ };
986
1000
  const onClick = (e) => {
987
1001
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
988
1002
  };
@@ -1032,8 +1046,10 @@ function DateRangeFilter({
1032
1046
  onRangeChange?.(s, e);
1033
1047
  onApply?.(shortcut === "Custom" ? `${fmt(s)} \u2013 ${fmt(e)}` : shortcut, s, e, cmp);
1034
1048
  setOpen(false);
1049
+ triggerRef.current?.focus();
1035
1050
  };
1036
1051
  const popRef = (0, import_react4.useRef)(null);
1052
+ const monthIdBase = (0, import_react4.useId)();
1037
1053
  const [flipBelow, setFlipBelow] = (0, import_react4.useState)(false);
1038
1054
  (0, import_react4.useLayoutEffect)(() => {
1039
1055
  if (!open || placement !== "above" || !ref.current || !popRef.current) return;
@@ -1044,6 +1060,7 @@ function DateRangeFilter({
1044
1060
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1045
1061
  "button",
1046
1062
  {
1063
+ ref: triggerRef,
1047
1064
  type: "button",
1048
1065
  "data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
1049
1066
  onClick: () => setOpen((v) => !v),
@@ -1098,15 +1115,15 @@ function DateRangeFilter({
1098
1115
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "w-[252px]", children: [
1099
1116
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
1100
1117
  offset === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NavBtn, { onClick: () => setLeftMonth(addMonths(leftMonth, -1)), "aria-label": "Previous month", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react6.ChevronLeft, { size: 16 }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "h-7 w-7" }),
1101
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "text-panel-title font-semibold text-text-primary", children: [
1118
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { id: `${monthIdBase}-m${offset}`, "aria-live": "polite", className: "text-panel-title font-semibold text-text-primary", children: [
1102
1119
  MONTHS[m.getMonth()],
1103
1120
  " ",
1104
1121
  m.getFullYear()
1105
1122
  ] }),
1106
1123
  offset === 1 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NavBtn, { onClick: () => setLeftMonth(addMonths(leftMonth, 1)), "aria-label": "Next month", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react6.ChevronRight, { size: 16 }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "h-7 w-7" })
1107
1124
  ] }),
1108
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-7", children: [
1109
- WEEKDAYS.map((w) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex h-8 items-center justify-center text-xs font-semibold text-text-secondary", children: w }, w)),
1125
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-7", role: "group", "aria-labelledby": `${monthIdBase}-m${offset}`, children: [
1126
+ WEEKDAYS.map((w) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "aria-hidden": "true", className: "flex h-8 items-center justify-center text-xs font-semibold text-text-secondary", children: w }, w)),
1110
1127
  grid.map((d, i) => {
1111
1128
  const inMonth = d.getMonth() === m.getMonth();
1112
1129
  const hasRange = !!(start && end);
@@ -1121,16 +1138,27 @@ function DateRangeFilter({
1121
1138
  else if (end && isEnd) band = "left-0 right-1/2";
1122
1139
  else band = "left-0 right-0";
1123
1140
  }
1124
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("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: [
1125
- band && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `absolute inset-y-[3px] bg-ai-tint ${band}`, "aria-hidden": "true" }),
1126
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1127
- "span",
1128
- {
1129
- 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"}`,
1130
- children: d.getDate()
1131
- }
1132
- )
1133
- ] }, i);
1141
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1142
+ "button",
1143
+ {
1144
+ type: "button",
1145
+ onClick: () => pickDay(d),
1146
+ "aria-label": dayLabel(d, single ? "single" : isStart ? "start" : end && isEnd ? "end" : inRange ? "in" : null),
1147
+ "aria-pressed": endpoint || inRange,
1148
+ className: "relative flex h-9 items-center justify-center focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
1149
+ children: [
1150
+ band && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `absolute inset-y-[3px] bg-ai-tint ${band}`, "aria-hidden": "true" }),
1151
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1152
+ "span",
1153
+ {
1154
+ 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"}`,
1155
+ children: d.getDate()
1156
+ }
1157
+ )
1158
+ ]
1159
+ },
1160
+ i
1161
+ );
1134
1162
  })
1135
1163
  ] })
1136
1164
  ] }, offset);
@@ -1166,7 +1194,10 @@ function DateRangeFilter({
1166
1194
  ] }),
1167
1195
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-4 flex items-center justify-end gap-2", children: [
1168
1196
  monthly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "mr-auto text-xs text-text-tertiary", children: "Data is monthly, so ranges cover whole months." }),
1169
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("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" }),
1197
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-cancel`, onClick: () => {
1198
+ setOpen(false);
1199
+ triggerRef.current?.focus();
1200
+ }, 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" }),
1170
1201
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("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" })
1171
1202
  ] })
1172
1203
  ] })
@@ -2022,7 +2053,7 @@ function SelectFilter({
2022
2053
  "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
2023
2054
  style: { position: "fixed", top: pos.top, left: pos.left, right: pos.right, width: fullWidth ? pos.width : void 0 },
2024
2055
  className: cn(
2025
- "z-[65] flex flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
2056
+ "z-dropdown flex flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
2026
2057
  !fullWidth && (sm ? "w-max min-w-28 max-w-72" : "w-56")
2027
2058
  ),
2028
2059
  role: loading || error ? "group" : "listbox",
@@ -2648,7 +2679,7 @@ function Tooltip({
2648
2679
  onMouseLeave: interactive ? hide : void 0,
2649
2680
  onTransitionEnd: onBoxTransitionEnd,
2650
2681
  className: cn(
2651
- "fixed z-[90] w-max max-w-xs whitespace-normal break-words px-2.5 py-1.5 text-xs leading-snug",
2682
+ "fixed z-tooltip w-max max-w-xs whitespace-normal break-words px-2.5 py-1.5 text-xs leading-snug",
2652
2683
  // Fade in/out. The sys duration token rather than a ref one:
2653
2684
  // it is what Button's hover/press transition uses, and a
2654
2685
  // tooltip's fade is the same kind of interactive feedback.
@@ -3010,7 +3041,7 @@ function SelectionPicker({
3010
3041
  "div",
3011
3042
  {
3012
3043
  className: cn(
3013
- "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",
3044
+ "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",
3014
3045
  rowGridCols
3015
3046
  ),
3016
3047
  children: [
@@ -3298,7 +3329,7 @@ function FilterDropdown({
3298
3329
  role: "group",
3299
3330
  "aria-label": filter.label,
3300
3331
  style: { top: pos.top, left: pos.left },
3301
- className: "fixed z-[80] min-w-55 rounded-card border border-border-default bg-surface p-2 shadow-overlay",
3332
+ className: "fixed z-dropdown min-w-55 rounded-card border border-border-default bg-surface p-2 shadow-overlay",
3302
3333
  children: [
3303
3334
  searchable && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "mb-1.5 flex h-8 items-center gap-2 rounded-control border border-border-strong bg-input px-2.5", children: [
3304
3335
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.Search, { size: 14, className: "shrink-0 text-text-secondary", "aria-hidden": "true" }),