@mediaradar/design-components 0.43.0 → 0.44.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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.43.0",
2
+ "version": "0.44.0",
3
3
  "components": [
4
4
  "AISpark",
5
5
  "AdvertiserNoResults",
package/dist/index.cjs CHANGED
@@ -1908,6 +1908,7 @@ function SelectFilter({
1908
1908
  error = false,
1909
1909
  onRetry,
1910
1910
  size = "md",
1911
+ inlineCaption = false,
1911
1912
  disabled = false,
1912
1913
  renderIcon
1913
1914
  }) {
@@ -1922,7 +1923,11 @@ function SelectFilter({
1922
1923
  const r = ref.current.getBoundingClientRect();
1923
1924
  const h = Math.min(options.length * 36 + 8, 288);
1924
1925
  const above = r.bottom + 8 + h > window.innerHeight && r.top - 8 - h > 0;
1925
- setPos({ top: above ? r.top - 8 - h : r.bottom + 8, left: align === "right" ? r.right - r.width : r.left, width: r.width });
1926
+ setPos({
1927
+ top: above ? r.top - 8 - h : r.bottom + 8,
1928
+ ...align === "right" ? { right: document.documentElement.clientWidth - r.right } : { left: r.left },
1929
+ width: r.width
1930
+ });
1926
1931
  }, [align, options.length]);
1927
1932
  (0, import_react7.useLayoutEffect)(() => {
1928
1933
  if (!open) return;
@@ -1947,10 +1952,18 @@ function SelectFilter({
1947
1952
  window.removeEventListener("scroll", reposition, true);
1948
1953
  };
1949
1954
  }, [open, close, reposition]);
1950
- const triggerValue = renderIcon ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "flex items-center gap-1.5", children: [
1955
+ const valueContent = renderIcon ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "flex items-center gap-1.5", children: [
1951
1956
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(OptionIcon, { children: renderIcon(value) }),
1952
1957
  value
1953
1958
  ] }) : value;
1959
+ const triggerValue = sm && inlineCaption ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
1960
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "font-normal text-text-secondary", children: [
1961
+ caption,
1962
+ ":"
1963
+ ] }),
1964
+ " ",
1965
+ valueContent
1966
+ ] }) : valueContent;
1954
1967
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cx4("relative", fullWidth && "w-full"), ref, children: [
1955
1968
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1956
1969
  "button",
@@ -1960,7 +1973,7 @@ function SelectFilter({
1960
1973
  onClick: () => setOpen((o) => !o),
1961
1974
  "aria-expanded": open,
1962
1975
  "aria-haspopup": "listbox",
1963
- "aria-label": sm ? caption : void 0,
1976
+ "aria-label": sm && !inlineCaption ? caption : void 0,
1964
1977
  disabled,
1965
1978
  className: cx4(
1966
1979
  sm ? "flex h-8 items-center gap-1.5 rounded-control border border-border-strong bg-input pl-2.5 pr-2 text-dense font-medium text-text-primary transition-colors hover:bg-subtle focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus" : chipTriggerClass(),
@@ -1987,10 +2000,10 @@ function SelectFilter({
1987
2000
  {
1988
2001
  ref: popoverRef,
1989
2002
  "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
1990
- style: { position: "fixed", top: pos.top, left: pos.left, width: fullWidth ? pos.width : void 0 },
2003
+ style: { position: "fixed", top: pos.top, left: pos.left, right: pos.right, width: fullWidth ? pos.width : void 0 },
1991
2004
  className: cx4(
1992
2005
  "z-[65] flex flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
1993
- !fullWidth && (sm ? "w-28" : "w-56")
2006
+ !fullWidth && (sm ? "w-max min-w-28 max-w-72" : "w-56")
1994
2007
  ),
1995
2008
  role: loading || error ? "group" : "listbox",
1996
2009
  "aria-label": caption,
@@ -4260,7 +4273,10 @@ function MultiSelectFilter({
4260
4273
  fullWidth = false,
4261
4274
  loading = false,
4262
4275
  error = false,
4263
- onRetry
4276
+ onRetry,
4277
+ valueLabel,
4278
+ hints,
4279
+ note
4264
4280
  }) {
4265
4281
  const groupLeaves = (g) => g.children.length ? g.children : [{ id: g.id, label: g.label }];
4266
4282
  const leafOptions = groups ? groups.flatMap(groupLeaves) : options;
@@ -4321,7 +4337,11 @@ function MultiSelectFilter({
4321
4337
  };
4322
4338
  const shown = open && !showFooter ? draft : selected;
4323
4339
  const isAll = shown.length === 0 || fullIsAll && shown.length === leafOptions.length;
4324
- const value = isAll ? allLabel : shown.length === 1 ? leafOptions.find((o) => o.id === shown[0])?.label ?? `${shown.length} selected` : `${shown.length} selected`;
4340
+ const value = valueLabel ?? (isAll ? allLabel : shown.length === 1 ? leafOptions.find((o) => o.id === shown[0])?.label ?? `${shown.length} selected` : `${shown.length} selected`);
4341
+ const labelled = (id, label) => hints?.[id] ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("span", { className: "flex flex-col", children: [
4342
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { children: label }),
4343
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "text-xs font-normal text-text-tertiary", children: hints[id] })
4344
+ ] }) : label;
4325
4345
  const ql = q.trim().toLowerCase();
4326
4346
  const items = options.filter((o) => isAvailable(o.id) && (!ql || o.label.toLowerCase().includes(ql)));
4327
4347
  const visibleGroups = groups ? groups.map((g) => {
@@ -4389,7 +4409,7 @@ function MultiSelectFilter({
4389
4409
  className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
4390
4410
  children: [
4391
4411
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked: state === "all", indeterminate: state === "some" }),
4392
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: cn("flex-1 text-[14px] text-text-primary", !plainParent && "font-semibold"), children: g.label }),
4412
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: cn("flex-1 text-[14px] text-text-primary", !plainParent && "font-semibold"), children: labelled(g.id, g.label) }),
4393
4413
  counts && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OptionCount, { n: countFor(g.id) })
4394
4414
  ]
4395
4415
  }
@@ -4404,7 +4424,7 @@ function MultiSelectFilter({
4404
4424
  className: "flex w-full items-center gap-2.5 rounded-control py-2 pl-9 pr-2 text-left transition-colors hover:bg-subtle",
4405
4425
  children: [
4406
4426
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked }),
4407
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "flex-1 text-[14px] text-text-primary", children: c.label }),
4427
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "flex-1 text-[14px] text-text-primary", children: labelled(c.id, c.label) }),
4408
4428
  counts && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OptionCount, { n: countFor(c.id) })
4409
4429
  ]
4410
4430
  },
@@ -4422,7 +4442,7 @@ function MultiSelectFilter({
4422
4442
  className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
4423
4443
  children: [
4424
4444
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked }),
4425
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "flex-1 text-[14px] text-text-primary", children: o.label }),
4445
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "flex-1 text-[14px] text-text-primary", children: labelled(o.id, o.label) }),
4426
4446
  counts && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OptionCount, { n: countFor(o.id) })
4427
4447
  ]
4428
4448
  },
@@ -4431,6 +4451,7 @@ function MultiSelectFilter({
4431
4451
  }),
4432
4452
  (groups && !visibleGroups.length || !groups && !items.length) && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "py-6 text-center text-[13px] text-text-tertiary", children: "No matches." })
4433
4453
  ] }),
4454
+ note && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "border-t border-border-default px-3 py-2 text-xs text-text-tertiary", children: note }),
4434
4455
  showFooter ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FilterDropdownFooter, { onClear: () => setDraft(clearValue), onApply: apply }) : min === 0 && draft.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "border-t border-border-default p-2", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
4435
4456
  "button",
4436
4457
  {