@actioneer/ads 1.0.8 → 1.0.9

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,7 +1,7 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
2
  import * as React from "react";
3
3
  declare const chipVariants: (props?: ({
4
- variant?: "outline" | "solid" | null | undefined;
4
+ variant?: "outline" | "solid" | "plain" | null | undefined;
5
5
  color?: "success" | "warning" | "danger" | "info" | "default" | "primary" | null | undefined;
6
6
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
7
  export type ChipInteraction = "actionable" | "non-actionable";
@@ -19,6 +19,7 @@ export interface ChipProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "
19
19
  onClose?: () => void;
20
20
  startContent?: React.ReactNode;
21
21
  avatar?: React.ReactNode;
22
+ /** Leading square tone dot. Always on for `variant="plain"`. */
22
23
  showDot?: boolean;
23
24
  }
24
25
  export declare const Chip: React.ForwardRefExoticComponent<ChipProps & React.RefAttributes<HTMLSpanElement>>;
@@ -1,16 +1,19 @@
1
1
  "use client";
2
- import { jsxs as x, Fragment as h, jsx as e } from "react/jsx-runtime";
2
+ import { jsxs as v, Fragment as h, jsx as e } from "react/jsx-runtime";
3
3
  import * as N from "react";
4
4
  import { cva as w } from "class-variance-authority";
5
5
  import { Close as y } from "../lib/icons.js";
6
- import { cn as t } from "../lib/cn.js";
6
+ import { cn as i } from "../lib/cn.js";
7
7
  const k = w(
8
8
  "inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-[4px] border px-2 py-0 text-s font-medium leading-[var(--text-s--line-height)]",
9
9
  {
10
10
  variants: {
11
11
  variant: {
12
12
  solid: "",
13
- outline: ""
13
+ outline: "",
14
+ // Status text for table cells and detail panels: no container, an 8px
15
+ // tone dot, and a 14px Regular primary label. The dot carries the tone.
16
+ plain: "h-auto gap-2 rounded-none border-0 bg-transparent px-0 text-m font-normal leading-[var(--text-m--line-height)] text-on-white-primary"
14
17
  },
15
18
  color: {
16
19
  default: "",
@@ -48,46 +51,46 @@ const k = w(
48
51
  info: "bg-info"
49
52
  }, j = N.forwardRef(
50
53
  ({
51
- className: g,
52
- variant: u = "solid",
53
- color: i = "default",
54
+ className: u,
55
+ variant: a = "solid",
56
+ color: o = "default",
54
57
  interaction: m,
55
58
  isPressable: f = !1,
56
59
  onClose: r,
57
- startContent: o,
58
- avatar: a,
60
+ startContent: s,
61
+ avatar: n,
59
62
  showDot: p = !1,
60
- children: v,
61
- ...s
62
- }, c) => {
63
- const n = r ? "actionable" : m ?? (f ? "actionable" : "non-actionable"), l = n === "actionable" && !r, d = t(
64
- k({ variant: u, color: i }),
65
- a && "pl-1",
63
+ children: x,
64
+ ...c
65
+ }, l) => {
66
+ const t = r ? "actionable" : m ?? (f ? "actionable" : "non-actionable"), d = t === "actionable" && !r, g = i(
67
+ k({ variant: a, color: o }),
68
+ n && "pl-1",
66
69
  r && "pr-1",
67
- l && "cursor-pointer select-none outline-none transition-[background,border,color,box-shadow,transform] duration-150 ease-out data-[interaction=actionable]:border-action-primary data-[interaction=actionable]:bg-card data-[interaction=actionable]:text-action-primary-text hover:-translate-y-px hover:bg-action-primary-soft active:translate-y-0 active:scale-[0.97] active:bg-action-primary-soft aria-pressed:border-brand! aria-pressed:bg-action-primary-soft! aria-pressed:text-brand-text! focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background motion-reduce:transition-none motion-reduce:hover:translate-y-0 motion-reduce:active:scale-100",
68
- g
69
- ), b = /* @__PURE__ */ x(h, { children: [
70
- a && /* @__PURE__ */ e("span", { className: "-ml-0.5 inline-flex shrink-0", children: a }),
71
- p && /* @__PURE__ */ e(
70
+ d && "cursor-pointer select-none outline-none transition-[background,border,color,box-shadow,transform] duration-150 ease-out data-[interaction=actionable]:border-action-primary data-[interaction=actionable]:bg-card data-[interaction=actionable]:text-action-primary-text hover:-translate-y-px hover:bg-action-primary-soft active:translate-y-0 active:scale-[0.97] active:bg-action-primary-soft aria-pressed:border-brand! aria-pressed:bg-action-primary-soft! aria-pressed:text-brand-text! focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background motion-reduce:transition-none motion-reduce:hover:translate-y-0 motion-reduce:active:scale-100",
71
+ u
72
+ ), b = /* @__PURE__ */ v(h, { children: [
73
+ n && /* @__PURE__ */ e("span", { className: "-ml-0.5 inline-flex shrink-0", children: n }),
74
+ (p || a === "plain") && /* @__PURE__ */ e(
72
75
  "span",
73
76
  {
74
77
  "aria-hidden": !0,
75
- className: t(
76
- "size-1.5",
78
+ className: i(
79
+ a === "plain" ? "size-2 shrink-0" : "size-1.5",
77
80
  "rounded-dot",
78
- z[i ?? "default"]
81
+ z[o ?? "default"]
79
82
  )
80
83
  }
81
84
  ),
82
- o && /* @__PURE__ */ e("span", { className: "inline-flex shrink-0 [&_svg]:size-3.5", children: o }),
83
- v,
85
+ s && /* @__PURE__ */ e("span", { className: "inline-flex shrink-0 [&_svg]:size-3.5", children: s }),
86
+ x,
84
87
  r && /* @__PURE__ */ e(
85
88
  "button",
86
89
  {
87
90
  type: "button",
88
91
  "aria-label": "Remove",
89
92
  onClick: r,
90
- className: t(
93
+ className: i(
91
94
  // A 16px container tinted from the chip's own ink so the remove
92
95
  // control reads as a button: 10% at rest, 20% on hover/press.
93
96
  "inline-flex size-4 shrink-0 items-center justify-center rounded-xs",
@@ -99,23 +102,23 @@ const k = w(
99
102
  }
100
103
  )
101
104
  ] });
102
- return l ? /* @__PURE__ */ e(
105
+ return d ? /* @__PURE__ */ e(
103
106
  "button",
104
107
  {
105
- ref: c,
108
+ ref: l,
106
109
  type: "button",
107
- "data-interaction": n,
108
- className: d,
109
- ...s,
110
+ "data-interaction": t,
111
+ className: g,
112
+ ...c,
110
113
  children: b
111
114
  }
112
115
  ) : /* @__PURE__ */ e(
113
116
  "span",
114
117
  {
115
- ref: c,
116
- "data-interaction": n,
117
- className: d,
118
- ...s,
118
+ ref: l,
119
+ "data-interaction": t,
120
+ className: g,
121
+ ...c,
119
122
  children: b
120
123
  }
121
124
  );
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ export interface FilterOption {
3
+ value: string;
4
+ label: string;
5
+ }
6
+ export interface FilterGroup {
7
+ /** Stable key passed back through `onChange`. */
8
+ id: string;
9
+ /** Accessible name for the group's Select (e.g. "Status"). */
10
+ label: string;
11
+ /** The first option is the group's "All …" default. */
12
+ options: FilterOption[];
13
+ /** The selected option value. */
14
+ value: string;
15
+ }
16
+ export interface FiltersProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" | "title"> {
17
+ groups: FilterGroup[];
18
+ /** Called with the group id and its newly selected option value. */
19
+ onChange: (id: string, value: string) => void;
20
+ /**
21
+ * Called by "Clear all". When omitted, Clear all resets every applied group
22
+ * to its first option through `onChange`.
23
+ */
24
+ onClearAll?: () => void;
25
+ /** Panel title. Defaults to "Filters". */
26
+ title?: string;
27
+ /** Accessible label for the icon-only trigger. Defaults to `title`. */
28
+ triggerLabel?: string;
29
+ /** Which trigger edge the panel aligns to. Defaults to `"end"`. */
30
+ align?: "start" | "end";
31
+ /** Controlled open state — pair with `onOpenChange`. */
32
+ open?: boolean;
33
+ /** Uncontrolled initial open state. */
34
+ defaultOpen?: boolean;
35
+ onOpenChange?: (open: boolean) => void;
36
+ }
37
+ export declare const Filters: React.ForwardRefExoticComponent<FiltersProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,129 @@
1
+ "use client";
2
+ import { jsx as t, jsxs as m } from "react/jsx-runtime";
3
+ import * as o from "react";
4
+ import { cn as u } from "../lib/cn.js";
5
+ import { Filter as T } from "../lib/icons.js";
6
+ import { Button as F } from "./button.js";
7
+ import { Popover as z, PopoverTrigger as D, PopoverContent as K } from "./popover.js";
8
+ import { Field as P } from "./field.js";
9
+ import { Select as U } from "./select.js";
10
+ const N = (i) => i.options.length > 0 && i.value !== i.options[0].value, C = o.forwardRef(
11
+ ({
12
+ groups: i,
13
+ onChange: p,
14
+ onClearAll: v,
15
+ title: d = "Filters",
16
+ triggerLabel: w,
17
+ align: $ = "end",
18
+ open: f,
19
+ defaultOpen: R = !1,
20
+ onOpenChange: s,
21
+ className: j,
22
+ ...k
23
+ }, c) => {
24
+ const [E, S] = o.useState(R), a = f ?? E, q = o.useCallback(
25
+ (e) => {
26
+ f === void 0 && S(e), s == null || s(e);
27
+ },
28
+ [f, s]
29
+ ), b = o.useRef(null), A = (e) => {
30
+ b.current = e, typeof c == "function" ? c(e) : c && (c.current = e);
31
+ }, n = o.useId(), r = i.filter(N).length, h = a || r > 0, x = w ?? d;
32
+ o.useEffect(() => {
33
+ if (!a) return;
34
+ const e = requestAnimationFrame(() => {
35
+ var l, y;
36
+ (y = (l = document.getElementById(n)) == null ? void 0 : l.querySelector("[role=combobox]")) == null || y.focus();
37
+ });
38
+ return () => cancelAnimationFrame(e);
39
+ }, [a, n]);
40
+ const I = () => {
41
+ var e, l;
42
+ return (l = (e = b.current) == null ? void 0 : e.querySelector("button")) == null ? void 0 : l.focus();
43
+ }, B = () => {
44
+ v ? v() : i.forEach((e) => {
45
+ N(e) && p(e.id, e.options[0].value);
46
+ });
47
+ };
48
+ return /* @__PURE__ */ t(
49
+ "div",
50
+ {
51
+ ref: A,
52
+ "data-slot": "filters",
53
+ "data-state": a ? "open" : "closed",
54
+ className: u("relative inline-flex", j),
55
+ ...k,
56
+ children: /* @__PURE__ */ m(z, { open: a, onOpenChange: q, children: [
57
+ /* @__PURE__ */ t(D, { children: /* @__PURE__ */ m(
58
+ F,
59
+ {
60
+ type: "button",
61
+ variant: "outline",
62
+ size: "icon-sm",
63
+ "aria-label": r > 0 ? `${x}, ${r} applied` : x,
64
+ "aria-controls": a ? n : void 0,
65
+ "data-active": h || void 0,
66
+ className: u(h && "border-action-primary text-action-primary"),
67
+ children: [
68
+ /* @__PURE__ */ t(T, { "aria-hidden": !0 }),
69
+ r > 0 && /* @__PURE__ */ t(
70
+ "span",
71
+ {
72
+ "aria-hidden": !0,
73
+ "data-slot": "filters-count",
74
+ className: u(
75
+ "pointer-events-none absolute -top-1.5 -right-1.5 inline-flex h-4 min-w-4 items-center justify-center",
76
+ "rounded-full bg-action-primary px-1 text-xs leading-none font-medium tabular-nums text-action-primary-foreground"
77
+ ),
78
+ children: r
79
+ }
80
+ )
81
+ ]
82
+ }
83
+ ) }),
84
+ /* @__PURE__ */ m(
85
+ K,
86
+ {
87
+ id: n,
88
+ align: $,
89
+ "aria-label": d,
90
+ onKeyDown: (e) => {
91
+ e.key === "Escape" && I();
92
+ },
93
+ className: "flex w-76 min-w-0 flex-col gap-4 p-4 text-m",
94
+ children: [
95
+ /* @__PURE__ */ m("div", { className: "flex min-h-5 items-center justify-between gap-4", children: [
96
+ /* @__PURE__ */ t("div", { className: "text-l font-medium text-on-white-primary", children: d }),
97
+ r > 0 && /* @__PURE__ */ t(
98
+ F,
99
+ {
100
+ type: "button",
101
+ variant: "link",
102
+ className: "h-auto px-0",
103
+ onClick: B,
104
+ children: "Clear all"
105
+ }
106
+ )
107
+ ] }),
108
+ i.map((e) => /* @__PURE__ */ t(P, { label: e.label, htmlFor: `${n}-${e.id}`, children: /* @__PURE__ */ t(
109
+ U,
110
+ {
111
+ id: `${n}-${e.id}`,
112
+ "aria-label": e.label,
113
+ items: e.options,
114
+ value: e.value,
115
+ onChange: (l) => p(e.id, l)
116
+ }
117
+ ) }, e.id))
118
+ ]
119
+ }
120
+ )
121
+ ] })
122
+ }
123
+ );
124
+ }
125
+ );
126
+ C.displayName = "Filters";
127
+ export {
128
+ C as Filters
129
+ };
@@ -32,6 +32,7 @@ export * from './date-range-picker';
32
32
  export * from './autocomplete';
33
33
  export * from './slider';
34
34
  export * from './segmented';
35
+ export * from './filters';
35
36
  export * from './modal';
36
37
  export * from './command-palette';
37
38
  export * from './drawer';