@mediaradar/design-components 0.26.0 → 0.30.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.d.cts CHANGED
@@ -681,11 +681,19 @@ declare function DataScopeFilter({ value, onChange, align }: DataScopeFilterProp
681
681
  * `onChange` ever fires, so nothing would ever get selected. Selecting an
682
682
  * option commits immediately and closes -- there's no separate draft/Apply
683
683
  * step; Escape and outside-click just close without side effects.
684
+ * `renderIcon`, when given, puts a small image before each option's label and
685
+ * before the value in the trigger -- a country flag, say. Each icon sits in a
686
+ * fixed 16x12 slot between the check column and the label, so labels stay
687
+ * aligned even when an option's icon is missing (`renderIcon` returning null).
688
+ * Without `renderIcon` nothing changes: no slot, no extra space.
684
689
  * @a11y Trigger is a <button>; the popover is role="listbox" with role="option"
685
690
  * rows carrying aria-selected. The trigger owns the accessible name via
686
691
  * the caption. The popover is not a focus trap and does not move focus on
687
692
  * open, so keyboard users tab into it; a consumer rendering it inside
688
693
  * another dismissible layer has to sequence the two dismissals itself.
694
+ * Icons from `renderIcon` are wrapped aria-hidden, so each option's accessible
695
+ * name stays its label text -- don't put meaning in the icon that the label
696
+ * doesn't also say.
689
697
  * @use for picking one value from a short list in a filter row or a form --
690
698
  * the caption-over-value chip is the one dropdown trigger.
691
699
  * @use the caption everywhere except tight spots where the field is obvious.
@@ -695,6 +703,7 @@ declare function DataScopeFilter({ value, onChange, align }: DataScopeFilterProp
695
703
  * ```tsx
696
704
  * <SelectFilter caption="Rank" value={rankFilter} onChange={setRankFilter} options={['All', 'VP / Director', 'Manager', 'Coordinator']} />
697
705
  * <SelectFilter caption="Group by" value={groupBy} onChange={setGroupBy} options={['Parent', 'Advertiser', 'Brand']} fullWidth testIdPrefix="dropdown-group-by" />
706
+ * <SelectFilter caption="Country" value={country} onChange={setCountry} options={['United States', 'Canada', 'United Kingdom']} renderIcon={(c) => <img src={FLAGS[c]} alt="" />} />
698
707
  * ```
699
708
  */
700
709
  interface SelectFilterProps {
@@ -719,8 +728,16 @@ interface SelectFilterProps {
719
728
  * to this shared component's ids rather than losing its locators outright.
720
729
  */
721
730
  testIdPrefix?: string;
731
+ /**
732
+ * Optional leading icon for each option, called with the option's string.
733
+ * Shown before the label in the list and before the value in the trigger,
734
+ * in a fixed 16x12 slot sized for a country flag (larger images are scaled
735
+ * down to fit). Decorative only -- it's rendered aria-hidden. Return null
736
+ * for an option with no icon; its label still lines up with the others.
737
+ */
738
+ renderIcon?: (option: string) => ReactNode;
722
739
  }
723
- declare function SelectFilter({ caption, value, options, onChange, align, fullWidth, className, testIdPrefix, }: SelectFilterProps): react.JSX.Element;
740
+ declare function SelectFilter({ caption, value, options, onChange, align, fullWidth, className, testIdPrefix, renderIcon, }: SelectFilterProps): react.JSX.Element;
724
741
 
725
742
  /**
726
743
  * @pattern Card
@@ -1895,7 +1912,8 @@ interface PagerProps {
1895
1912
  * @pattern Pager
1896
1913
  * @description Compact prev/next pager with a windowed page-number list —
1897
1914
  * shows every page up to 7 total, otherwise 1 … current±1 … last with
1898
- * ellipsis gaps. Shared by My Exports and Account Matcher. `disabled`
1915
+ * ellipsis gaps, each number formatted for the locale ("14,433"). Shared by
1916
+ * My Exports and Account Matcher. `disabled`
1899
1917
  * disables every control while the list loads.
1900
1918
  * @use in a card or a compact list, with the range ("Showing 1–10 of 48") on
1901
1919
  * the left if the reader needs it.
@@ -2086,7 +2104,8 @@ declare function Tag({ children, className }: TagProps): react.JSX.Element;
2086
2104
  * page — disabled controls stay in the layout so the row never reflows.
2087
2105
  * Changing the per-page count reports it and leaves the host to reset to page
2088
2106
  * 1. With one page of results the pager still renders, so the bar's height
2089
- * and the range readout don't come and go as filters narrow. `disabled`
2107
+ * and the range readout don't come and go as filters narrow. Page numbers
2108
+ * are formatted for the locale ("14,433"), like the range readout. `disabled`
2090
2109
  * disables every control (select and page buttons) while the table loads,
2091
2110
  * so a click can't request a second page on top of the first; the range
2092
2111
  * readout stays.
package/dist/index.d.ts CHANGED
@@ -681,11 +681,19 @@ declare function DataScopeFilter({ value, onChange, align }: DataScopeFilterProp
681
681
  * `onChange` ever fires, so nothing would ever get selected. Selecting an
682
682
  * option commits immediately and closes -- there's no separate draft/Apply
683
683
  * step; Escape and outside-click just close without side effects.
684
+ * `renderIcon`, when given, puts a small image before each option's label and
685
+ * before the value in the trigger -- a country flag, say. Each icon sits in a
686
+ * fixed 16x12 slot between the check column and the label, so labels stay
687
+ * aligned even when an option's icon is missing (`renderIcon` returning null).
688
+ * Without `renderIcon` nothing changes: no slot, no extra space.
684
689
  * @a11y Trigger is a <button>; the popover is role="listbox" with role="option"
685
690
  * rows carrying aria-selected. The trigger owns the accessible name via
686
691
  * the caption. The popover is not a focus trap and does not move focus on
687
692
  * open, so keyboard users tab into it; a consumer rendering it inside
688
693
  * another dismissible layer has to sequence the two dismissals itself.
694
+ * Icons from `renderIcon` are wrapped aria-hidden, so each option's accessible
695
+ * name stays its label text -- don't put meaning in the icon that the label
696
+ * doesn't also say.
689
697
  * @use for picking one value from a short list in a filter row or a form --
690
698
  * the caption-over-value chip is the one dropdown trigger.
691
699
  * @use the caption everywhere except tight spots where the field is obvious.
@@ -695,6 +703,7 @@ declare function DataScopeFilter({ value, onChange, align }: DataScopeFilterProp
695
703
  * ```tsx
696
704
  * <SelectFilter caption="Rank" value={rankFilter} onChange={setRankFilter} options={['All', 'VP / Director', 'Manager', 'Coordinator']} />
697
705
  * <SelectFilter caption="Group by" value={groupBy} onChange={setGroupBy} options={['Parent', 'Advertiser', 'Brand']} fullWidth testIdPrefix="dropdown-group-by" />
706
+ * <SelectFilter caption="Country" value={country} onChange={setCountry} options={['United States', 'Canada', 'United Kingdom']} renderIcon={(c) => <img src={FLAGS[c]} alt="" />} />
698
707
  * ```
699
708
  */
700
709
  interface SelectFilterProps {
@@ -719,8 +728,16 @@ interface SelectFilterProps {
719
728
  * to this shared component's ids rather than losing its locators outright.
720
729
  */
721
730
  testIdPrefix?: string;
731
+ /**
732
+ * Optional leading icon for each option, called with the option's string.
733
+ * Shown before the label in the list and before the value in the trigger,
734
+ * in a fixed 16x12 slot sized for a country flag (larger images are scaled
735
+ * down to fit). Decorative only -- it's rendered aria-hidden. Return null
736
+ * for an option with no icon; its label still lines up with the others.
737
+ */
738
+ renderIcon?: (option: string) => ReactNode;
722
739
  }
723
- declare function SelectFilter({ caption, value, options, onChange, align, fullWidth, className, testIdPrefix, }: SelectFilterProps): react.JSX.Element;
740
+ declare function SelectFilter({ caption, value, options, onChange, align, fullWidth, className, testIdPrefix, renderIcon, }: SelectFilterProps): react.JSX.Element;
724
741
 
725
742
  /**
726
743
  * @pattern Card
@@ -1895,7 +1912,8 @@ interface PagerProps {
1895
1912
  * @pattern Pager
1896
1913
  * @description Compact prev/next pager with a windowed page-number list —
1897
1914
  * shows every page up to 7 total, otherwise 1 … current±1 … last with
1898
- * ellipsis gaps. Shared by My Exports and Account Matcher. `disabled`
1915
+ * ellipsis gaps, each number formatted for the locale ("14,433"). Shared by
1916
+ * My Exports and Account Matcher. `disabled`
1899
1917
  * disables every control while the list loads.
1900
1918
  * @use in a card or a compact list, with the range ("Showing 1–10 of 48") on
1901
1919
  * the left if the reader needs it.
@@ -2086,7 +2104,8 @@ declare function Tag({ children, className }: TagProps): react.JSX.Element;
2086
2104
  * page — disabled controls stay in the layout so the row never reflows.
2087
2105
  * Changing the per-page count reports it and leaves the host to reset to page
2088
2106
  * 1. With one page of results the pager still renders, so the bar's height
2089
- * and the range readout don't come and go as filters narrow. `disabled`
2107
+ * and the range readout don't come and go as filters narrow. Page numbers
2108
+ * are formatted for the locale ("14,433"), like the range readout. `disabled`
2090
2109
  * disables every control (select and page buttons) while the table loads,
2091
2110
  * so a click can't request a second page on top of the first; the range
2092
2111
  * readout stays.
package/dist/index.js CHANGED
@@ -1413,6 +1413,16 @@ function cx4(...classes) {
1413
1413
  function slug3(value) {
1414
1414
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
1415
1415
  }
1416
+ function OptionIcon({ children }) {
1417
+ return /* @__PURE__ */ jsx11(
1418
+ "span",
1419
+ {
1420
+ "aria-hidden": "true",
1421
+ className: "flex h-3 w-4 shrink-0 items-center justify-center overflow-hidden text-text-secondary *:max-h-full *:max-w-full",
1422
+ children
1423
+ }
1424
+ );
1425
+ }
1416
1426
  function SelectFilter({
1417
1427
  caption,
1418
1428
  value,
@@ -1421,7 +1431,8 @@ function SelectFilter({
1421
1431
  align = "left",
1422
1432
  fullWidth = false,
1423
1433
  className,
1424
- testIdPrefix
1434
+ testIdPrefix,
1435
+ renderIcon
1425
1436
  }) {
1426
1437
  const [open, setOpen] = useState6(false);
1427
1438
  const [pos, setPos] = useState6(null);
@@ -1456,6 +1467,7 @@ function SelectFilter({
1456
1467
  window.removeEventListener("scroll", reposition, true);
1457
1468
  };
1458
1469
  }, [open, close, reposition]);
1470
+ const valueText = /* @__PURE__ */ jsx11("span", { className: "text-[12px] font-medium text-text-primary", children: value });
1459
1471
  return /* @__PURE__ */ jsxs10("div", { className: cx4("relative", fullWidth && "w-full"), ref, children: [
1460
1472
  /* @__PURE__ */ jsxs10(
1461
1473
  "button",
@@ -1473,7 +1485,10 @@ function SelectFilter({
1473
1485
  children: [
1474
1486
  /* @__PURE__ */ jsxs10("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
1475
1487
  /* @__PURE__ */ jsx11("span", { className: "text-control-caption uppercase tracking-wide text-text-tertiary", children: caption }),
1476
- /* @__PURE__ */ jsx11("span", { className: "text-[12px] font-medium text-text-primary", children: value })
1488
+ renderIcon ? /* @__PURE__ */ jsxs10("span", { className: "flex items-center gap-1.5", children: [
1489
+ /* @__PURE__ */ jsx11(OptionIcon, { children: renderIcon(value) }),
1490
+ valueText
1491
+ ] }) : valueText
1477
1492
  ] }),
1478
1493
  /* @__PURE__ */ jsx11(
1479
1494
  ChevronDown5,
@@ -1515,6 +1530,7 @@ function SelectFilter({
1515
1530
  className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
1516
1531
  children: [
1517
1532
  /* @__PURE__ */ jsx11("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center text-brand-primaryAction", children: selected && /* @__PURE__ */ jsx11(Check5, { size: 15, strokeWidth: 3 }) }),
1533
+ renderIcon && /* @__PURE__ */ jsx11(OptionIcon, { children: renderIcon(o) }),
1518
1534
  /* @__PURE__ */ jsx11(
1519
1535
  "span",
1520
1536
  {
@@ -3243,7 +3259,7 @@ function Pager({ page, totalPages, onPage, disabled = false, label = "Pagination
3243
3259
  btn,
3244
3260
  p === page ? "bg-brand-primaryAction font-semibold text-brand-onprimary" : "text-text-secondary hover:bg-subtle hover:text-text-primary"
3245
3261
  ),
3246
- children: p
3262
+ children: p.toLocaleString()
3247
3263
  },
3248
3264
  p
3249
3265
  )
@@ -3487,7 +3503,7 @@ function TablePagination({
3487
3503
  off,
3488
3504
  p === current ? "bg-brand-primaryAction font-semibold text-brand-onprimary" : "text-text-secondary hover:bg-subtle hover:text-text-primary"
3489
3505
  ),
3490
- children: p
3506
+ children: p.toLocaleString()
3491
3507
  },
3492
3508
  p
3493
3509
  )