asma-ui-core 3.119.0 → 3.120.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,32 +1,33 @@
1
- import { StyledBadge as m } from "../../data-display/badge/StyledBadge.js";
2
- import { FilterIcon as c } from "../../icons/filter-icon/FilterIcon.js";
3
- import { StyledButton as s } from "../../inputs/button/StyledButton.js";
4
- import { useDynamicToolbarLayout as p } from "../../custom/module/header-layout/DynamicToolbarLayoutContext.js";
5
- import f from "clsx";
6
- import { Fragment as u, jsx as r, jsxs as g } from "react/jsx-runtime";
7
- var B = ({ filterIsActive: i, label: o, hideLabel: l, size: t = "large", variant: a = "outlined", ...n }) => {
8
- const { filterIconOnly: d } = p(), e = l ?? d;
9
- return /* @__PURE__ */ r(u, { children: /* @__PURE__ */ g("div", {
1
+ import { StyledBadge as f } from "../../data-display/badge/StyledBadge.js";
2
+ import { FilterIcon as p } from "../../icons/filter-icon/FilterIcon.js";
3
+ import { StyledButton as h } from "../../inputs/button/StyledButton.js";
4
+ import { useDynamicToolbarLayout as u } from "../../custom/module/header-layout/DynamicToolbarLayoutContext.js";
5
+ import { filterButtonText as g, isFilterDotShown as y } from "./filterButtonText.js";
6
+ import b from "clsx";
7
+ import { Fragment as x, jsx as o, jsxs as v } from "react/jsx-runtime";
8
+ var j = ({ filterIsActive: l, activeCount: r, label: a, hideLabel: n, size: t = "large", variant: m = "outlined", ...s }) => {
9
+ const { filterIconOnly: d } = u(), e = n ?? d, i = g(a, r), c = y(l, r);
10
+ return /* @__PURE__ */ o(x, { children: /* @__PURE__ */ v("div", {
10
11
  className: "relative h-fit w-fit",
11
- children: [/* @__PURE__ */ r(s, {
12
- ...n,
12
+ children: [/* @__PURE__ */ o(h, {
13
+ ...s,
13
14
  type: "button",
14
- "aria-label": e ? o ?? "Filter" : void 0,
15
- startIcon: /* @__PURE__ */ r(c, {
15
+ "aria-label": e ? i : void 0,
16
+ startIcon: /* @__PURE__ */ o(p, {
16
17
  width: t === "large" ? 24 : 20,
17
18
  height: t === "large" ? 24 : 20
18
19
  }),
19
- variant: a,
20
+ variant: m,
20
21
  size: t,
21
- children: !e && (o ?? "Filter")
22
- }), i && /* @__PURE__ */ r(m, {
22
+ children: !e && i
23
+ }), c && /* @__PURE__ */ o(f, {
23
24
  dataTest: "filter-button-active-dot",
24
25
  variant: "dot",
25
26
  purpose: "filter",
26
- className: f("absolute", t === "large" ? "right-2 top-2" : "right-1 top-1")
27
+ className: b("absolute", t === "large" ? "right-2 top-2" : "right-1 top-1")
27
28
  })]
28
29
  }) });
29
30
  };
30
31
  export {
31
- B as StyledFilterButton
32
+ j as StyledFilterButton
32
33
  };
@@ -1,75 +1,76 @@
1
- import { StyledBadge as O } from "../../data-display/badge/StyledBadge.js";
2
- import { FilterIcon as b } from "../../icons/filter-icon/FilterIcon.js";
3
- import { StyledButton as E } from "../../inputs/button/StyledButton.js";
1
+ import { StyledBadge as S } from "../../data-display/badge/StyledBadge.js";
2
+ import { FilterIcon as E } from "../../icons/filter-icon/FilterIcon.js";
3
+ import { StyledButton as k } from "../../inputs/button/StyledButton.js";
4
4
  import { StyledPopover as F } from "../popover/StyledPopover.js";
5
- import { useDynamicToolbarLayout as k } from "../../custom/module/header-layout/DynamicToolbarLayoutContext.js";
6
- import x from "clsx";
7
- import s, { useState as C } from "react";
8
- import { Fragment as I, jsx as c, jsxs as y } from "react/jsx-runtime";
9
- var S = () => {
10
- const [r, t] = C(null), e = (a) => {
11
- const o = a.currentTarget;
12
- t(o);
13
- }, l = () => {
14
- t(null);
5
+ import { useDynamicToolbarLayout as I } from "../../custom/module/header-layout/DynamicToolbarLayoutContext.js";
6
+ import { filterButtonText as w, isFilterDotShown as C } from "./filterButtonText.js";
7
+ import N from "clsx";
8
+ import c, { useState as B } from "react";
9
+ import { Fragment as D, jsx as l, jsxs as A } from "react/jsx-runtime";
10
+ var T = () => {
11
+ const [r, n] = B(null), i = (t) => {
12
+ const s = t.currentTarget;
13
+ n(s);
14
+ }, a = () => {
15
+ n(null);
15
16
  };
16
17
  return {
17
18
  anchorEl: r,
18
- onClose: l,
19
- onAnchorClick: (a) => {
20
- r ? l() : e(a);
19
+ onClose: a,
20
+ onAnchorClick: (t) => {
21
+ r ? a() : i(t);
21
22
  }
22
23
  };
23
- }, N = (r) => s.isValidElement(r) || typeof r == "string" || typeof r == "number" || r === null || Array.isArray(r), D = ({ filterIsActive: r, popoverContent: t, dataTest: e, disabled: l, size: n = "large", variant: a = "outlined", popoverProps: o, anchorNode: d, label: h, hideLabel: v }) => {
24
- const { onAnchorClick: u, onClose: m, anchorEl: i } = S(), { filterIconOnly: A } = k(), g = v ?? A, f = d?.({
25
- isOpen: !!i,
24
+ }, $ = (r) => c.isValidElement(r) || typeof r == "string" || typeof r == "number" || r === null || Array.isArray(r), K = ({ filterIsActive: r, activeCount: n, popoverContent: i, dataTest: a, disabled: h, size: t = "large", variant: s = "outlined", popoverProps: e, anchorNode: d, label: O, hideLabel: b }) => {
25
+ const { onAnchorClick: u, onClose: m, anchorEl: o } = T(), { filterIconOnly: v } = I(), f = b ?? v, g = w(O, n), x = C(r, n), p = d?.({
26
+ isOpen: !!o,
26
27
  onClose: m
27
- }), p = s.useId();
28
- return /* @__PURE__ */ y(I, { children: [/* @__PURE__ */ y("div", {
28
+ }), y = c.useId();
29
+ return /* @__PURE__ */ A(D, { children: [/* @__PURE__ */ A("div", {
29
30
  className: "relative h-fit w-fit",
30
- children: [d && s.isValidElement(f) ? s.cloneElement(f, { onClick: u }) : /* @__PURE__ */ c(E, {
31
+ children: [d && c.isValidElement(p) ? c.cloneElement(p, { onClick: u }) : /* @__PURE__ */ l(k, {
31
32
  type: "button",
32
- disabled: l,
33
- variant: a,
34
- startIcon: /* @__PURE__ */ c(b, {
35
- width: n === "large" ? 24 : 20,
36
- height: n === "large" ? 24 : 20
33
+ disabled: h,
34
+ variant: s,
35
+ startIcon: /* @__PURE__ */ l(E, {
36
+ width: t === "large" ? 24 : 20,
37
+ height: t === "large" ? 24 : 20
37
38
  }),
38
39
  onClick: u,
39
- size: n,
40
- dataTest: e,
41
- "aria-label": g ? h ?? "Filter" : void 0,
40
+ size: t,
41
+ dataTest: a,
42
+ "aria-label": f ? g : void 0,
42
43
  "aria-haspopup": "true",
43
- "aria-expanded": !!i,
44
- "aria-controls": i ? p : void 0,
45
- children: !g && (h ?? "Filter")
46
- }), r && /* @__PURE__ */ c(O, {
47
- dataTest: `${e}-active-dot`,
44
+ "aria-expanded": !!o,
45
+ "aria-controls": o ? y : void 0,
46
+ children: !f && g
47
+ }), x && /* @__PURE__ */ l(S, {
48
+ dataTest: `${a}-active-dot`,
48
49
  variant: "dot",
49
50
  purpose: "filter",
50
- className: x("absolute", n === "large" ? "right-2 top-2" : "right-1 top-1")
51
+ className: N("absolute", t === "large" ? "right-2 top-2" : "right-1 top-1")
51
52
  })]
52
- }), /* @__PURE__ */ c(F, {
53
- ...o,
54
- id: p,
55
- open: !!i,
56
- anchorEl: i,
53
+ }), /* @__PURE__ */ l(F, {
54
+ ...e,
55
+ id: y,
56
+ open: !!o,
57
+ anchorEl: o,
57
58
  onClose: m,
58
- anchorOrigin: o?.anchorOrigin ?? {
59
+ anchorOrigin: e?.anchorOrigin ?? {
59
60
  vertical: "bottom",
60
61
  horizontal: "right"
61
62
  },
62
- transformOrigin: o?.transformOrigin ?? {
63
+ transformOrigin: e?.transformOrigin ?? {
63
64
  vertical: "top",
64
65
  horizontal: "right"
65
66
  },
66
- className: o?.className ?? "my-1",
67
- children: N(t) ? t : t({
68
- isOpen: !!i,
67
+ className: e?.className ?? "my-1",
68
+ children: $(i) ? i : i({
69
+ isOpen: !!o,
69
70
  onClose: m
70
71
  })
71
72
  })] });
72
73
  };
73
74
  export {
74
- D as StyledFilterMenu
75
+ K as StyledFilterMenu
75
76
  };
@@ -0,0 +1,8 @@
1
+ var o = (t, r) => {
2
+ const e = t ?? "Filter";
3
+ return r ? `${e} (${r})` : e;
4
+ }, i = (t, r) => r === void 0 ? !!t : r > 0;
5
+ export {
6
+ o as filterButtonText,
7
+ i as isFilterDotShown
8
+ };
@@ -5,11 +5,14 @@ import { StyledButtonProps } from '../../inputs/button';
5
5
  * Figma's `Parent=Filter` dot at top-right when `filterIsActive`.
6
6
  *
7
7
  * Custom props:
8
- * @param filterIsActive - needed to determine whether or not to show the dot in the top right corner indicating some changes were made
8
+ * @param filterIsActive - shows the dot in the top right corner indicating some changes were made
9
+ * @param activeCount - the number of filter controls that differ from the page default (the page computes it); shown as `Filter (N)`, dot when N > 0
9
10
  * @param hideLabel - icon-only mode. When omitted, follows the surrounding DynamicToolbar layout (filterIconOnly).
10
11
  */
11
12
  interface StyledFilterMenuProps {
12
- filterIsActive: boolean;
13
+ /** Ignored when `activeCount` is given. */
14
+ filterIsActive?: boolean;
15
+ activeCount?: number;
13
16
  label?: string;
14
17
  hideLabel?: boolean;
15
18
  }
@@ -8,13 +8,16 @@ import { StyledPopoverProps } from '../popover';
8
8
  * dot at top-right. No own styling beyond that dot; all visuals come from the aligned primitives.
9
9
  *
10
10
  * Custom props:
11
- * @param filterIsActive - needed to determine whether or not to show the dot in the top right corner indicating some changes were made
11
+ * @param filterIsActive - shows the dot in the top right corner indicating some changes were made
12
+ * @param activeCount - the number of filter controls that differ from the page default (the page computes it); shown as `Filter (N)`, dot when N > 0
12
13
  * @param popoverContent
13
14
  * @param hideLabel - icon-only mode. When omitted, follows the surrounding DynamicToolbar layout (filterIconOnly).
14
15
  */
15
16
  interface StyledFilterMenuProps {
16
17
  dataTest: string;
17
- filterIsActive: boolean;
18
+ /** Ignored when `activeCount` is given. */
19
+ filterIsActive?: boolean;
20
+ activeCount?: number;
18
21
  popoverContent: ((props: {
19
22
  isOpen: boolean;
20
23
  onClose: () => void;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The Filter trigger's text, which is also its accessible name when the label is hidden.
3
+ *
4
+ * `activeCount`: the number of filter controls that differ from the page default (the page computes it).
5
+ *
6
+ * @see asma-modules/_docs/ux/specs/spec-design-system-popover.md:100 — Filter trigger label
7
+ * @see asma-modules/_docs/ux/patterns/pattern-filter-default-state.md:70 — what counts as changed
8
+ */
9
+ export declare const filterButtonText: (label: string | undefined, activeCount: number | undefined) => string;
10
+ /** `activeCount`, when given, alone decides the dot; `filterIsActive` serves callers without a count. */
11
+ export declare const isFilterDotShown: (filterIsActive: boolean | undefined, activeCount: number | undefined) => boolean;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.119.0",
6
+ "version": "3.120.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",