@pibit.ai/cure-design-system 0.6.19 → 0.6.21

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,41 +1,39 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import b, { useState as h } from "react";
3
- import { Breadcrumbs as g } from "react-aria-components";
4
- import { cx as o } from "../../utils/cn.js";
5
- import { BreadcrumbItem as n } from "./breadcrumb-item.js";
6
- import { BreadcrumbsContext as x } from "./context.js";
7
- const B = {
2
+ import h, { useState as g } from "react";
3
+ import { Breadcrumbs as x } from "react-aria-components";
4
+ import { cx as n } from "../../utils/cn.js";
5
+ import { BreadcrumbItem as l } from "./breadcrumb-item.js";
6
+ import { BreadcrumbsContext as B } from "./context.js";
7
+ const v = {
8
8
  text: "gap-0.5 md:gap-0.5",
9
9
  "text-line": "pl-2 gap-1.25 md:gap-1.25 py-2 after:pointer-events-none after:absolute after:inset-0 after:border-b after:border-t after:border-secondary",
10
10
  button: "gap-0.5 md:gap-0.5"
11
- }, v = ({
12
- children: l,
11
+ }, C = ({
12
+ children: c,
13
13
  divider: a = "slash",
14
14
  type: s = "text",
15
- className: c,
15
+ className: i,
16
16
  maxVisibleItems: r = 4
17
17
  }) => {
18
- const [i, m] = h(!1), d = (() => {
19
- const e = b.Children.toArray(l);
20
- if (!r || e.length <= r || i)
18
+ const [m, d] = g(!1), p = (() => {
19
+ const e = h.Children.toArray(c);
20
+ if (!r || e.length <= r || m)
21
21
  return e;
22
- const p = e.slice(0, Math.ceil(r / 2)), f = e.slice(
23
- -Math.floor((r - 1) / 2)
24
- ), u = /* @__PURE__ */ t(
25
- n,
22
+ const f = e.slice(0, Math.ceil(r / 2)), o = Math.floor((r - 1) / 2), u = o > 0 ? e.slice(-o) : [], b = /* @__PURE__ */ t(
23
+ l,
26
24
  {
27
25
  isEllipsis: !0,
28
26
  divider: a,
29
27
  type: s,
30
- onClick: () => m(!0)
28
+ onClick: () => d(!0)
31
29
  },
32
30
  "ellipsis"
33
31
  );
34
- return [...p, u, ...f];
32
+ return [...f, b, ...u];
35
33
  })();
36
- return /* @__PURE__ */ t("nav", { "aria-label": "Breadcrumbs", className: o("min-w-0", c), children: /* @__PURE__ */ t(x.Provider, { value: { divider: a, type: s }, children: /* @__PURE__ */ t(g, { className: o("relative flex", B[s]), children: d }) }) });
34
+ return /* @__PURE__ */ t("nav", { "aria-label": "Breadcrumbs", className: n("min-w-0", i), children: /* @__PURE__ */ t(B.Provider, { value: { divider: a, type: s }, children: /* @__PURE__ */ t(x, { className: n("relative flex", v[s]), children: p }) }) });
37
35
  };
38
- v.Item = n;
36
+ C.Item = l;
39
37
  export {
40
- v as Breadcrumbs
38
+ C as Breadcrumbs
41
39
  };
@@ -0,0 +1,22 @@
1
+ export interface ChecklistSelectOption {
2
+ key: string;
3
+ /** The label shown next to the checkbox. */
4
+ value: string;
5
+ }
6
+ export interface ChecklistSelectProps {
7
+ /** Options to display. Each must have `key` and `value` (display label). */
8
+ options: ChecklistSelectOption[];
9
+ /** Currently selected option keys (e.g. for API filter value list). */
10
+ selectedKeys: string[];
11
+ /** Called when selection changes (e.g. after toggle). */
12
+ onChange?: (keys: string[]) => void;
13
+ /** Called when user clicks Apply. Pass current selected keys. */
14
+ onApply?: (keys: string[]) => void;
15
+ /** Called when user clicks Reset. Parent typically selects all. */
16
+ onReset?: () => void;
17
+ /** Called when panel should close (e.g. after Apply). */
18
+ onClose?: () => void;
19
+ className?: string;
20
+ }
21
+ export declare function ChecklistSelect({ options, selectedKeys, onChange, onApply, onReset, onClose, className, }: ChecklistSelectProps): import("react/jsx-runtime").JSX.Element;
22
+ //# sourceMappingURL=checklist-select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checklist-select.d.ts","sourceRoot":"","sources":["../../../src/patterns/filters/checklist-select.tsx"],"names":[],"mappings":"AAWA,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,uEAAuE;IACvE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpC,iEAAiE;IACjE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACnC,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,SAAS,GACV,EAAE,oBAAoB,2CAoHtB"}
@@ -0,0 +1,117 @@
1
+ import { jsxs as s, jsx as r } from "react/jsx-runtime";
2
+ import { MinusSquare as v } from "@untitledui/icons";
3
+ import { cx as o } from "../../utils/cn.js";
4
+ import { Checkbox as u } from "../../primitives/checkbox/checkbox.js";
5
+ import { Button as y } from "../../primitives/button/button.js";
6
+ function _({
7
+ options: p,
8
+ selectedKeys: a,
9
+ onChange: l,
10
+ onApply: d,
11
+ onReset: m,
12
+ onClose: n,
13
+ className: b
14
+ }) {
15
+ const t = p.map((e) => e.key).filter(Boolean), i = new Set(a), x = t.length > 0 && i.size === t.length, f = i.size > 0 && i.size < t.length, h = () => {
16
+ x || f ? l == null || l([]) : l == null || l(t);
17
+ }, S = (e) => {
18
+ const c = new Set(a);
19
+ c.has(e) ? c.delete(e) : c.add(e), l == null || l(Array.from(c));
20
+ }, N = () => {
21
+ d == null || d(a), n == null || n();
22
+ }, k = () => {
23
+ m == null || m();
24
+ };
25
+ return /* @__PURE__ */ s(
26
+ "div",
27
+ {
28
+ className: o(
29
+ "flex flex-col rounded-xl bg-primary shadow-sm ring-1 ring-primary",
30
+ b
31
+ ),
32
+ "data-slot": "checklist-select",
33
+ children: [
34
+ /* @__PURE__ */ s("div", { className: "flex flex-col gap-0 p-3", children: [
35
+ /* @__PURE__ */ s(
36
+ "label",
37
+ {
38
+ className: o(
39
+ "flex cursor-pointer items-center gap-3 rounded-md py-2 pr-2 pl-0 outline-hidden",
40
+ "hover:bg-primary_hover"
41
+ ),
42
+ children: [
43
+ f ? /* @__PURE__ */ r(
44
+ v,
45
+ {
46
+ size: 18,
47
+ className: "text-utility-brand-600",
48
+ onClick: h,
49
+ cursor: "pointer"
50
+ }
51
+ ) : /* @__PURE__ */ r(
52
+ u,
53
+ {
54
+ id: "all",
55
+ isSelected: x,
56
+ onChange: h,
57
+ size: "sm",
58
+ "aria-label": "Select all options"
59
+ }
60
+ ),
61
+ /* @__PURE__ */ r("span", { className: "text-sm font-medium text-primary select-none", children: "All" })
62
+ ]
63
+ }
64
+ ),
65
+ p.map((e) => /* @__PURE__ */ s(
66
+ "label",
67
+ {
68
+ className: o(
69
+ "flex cursor-pointer items-center gap-3 rounded-md py-2 pr-2 pl-0 outline-hidden",
70
+ "hover:bg-primary_hover"
71
+ ),
72
+ children: [
73
+ /* @__PURE__ */ r(
74
+ u,
75
+ {
76
+ id: e.key,
77
+ isSelected: i.has(e.key),
78
+ onChange: () => S(e.key),
79
+ size: "sm",
80
+ "aria-label": e.value
81
+ }
82
+ ),
83
+ /* @__PURE__ */ r("span", { className: "text-sm text-secondary select-none", children: e.value })
84
+ ]
85
+ },
86
+ e.key
87
+ ))
88
+ ] }),
89
+ /* @__PURE__ */ s("div", { className: "flex gap-2 border-primary p-3", children: [
90
+ /* @__PURE__ */ r(
91
+ y,
92
+ {
93
+ size: "xs",
94
+ color: "secondary",
95
+ className: "flex-1 bg-secondary border-none text-primary",
96
+ onClick: k,
97
+ children: "Reset"
98
+ }
99
+ ),
100
+ /* @__PURE__ */ r(
101
+ y,
102
+ {
103
+ size: "xs",
104
+ color: "primary",
105
+ className: "flex-1",
106
+ onClick: N,
107
+ children: "Apply"
108
+ }
109
+ )
110
+ ] })
111
+ ]
112
+ }
113
+ );
114
+ }
115
+ export {
116
+ _ as ChecklistSelect
117
+ };
@@ -0,0 +1,22 @@
1
+ export type FilterListItem = {
2
+ id: string;
3
+ label: string;
4
+ value: string;
5
+ };
6
+ export interface FilterListSectionProps<T extends FilterListItem> {
7
+ title: string;
8
+ items: T[];
9
+ selectedValues: string[];
10
+ selectAll: boolean;
11
+ search: string;
12
+ placeholder?: string;
13
+ showAvatar?: boolean;
14
+ getItemLabel?: (item: T) => string;
15
+ getItemValue?: (item: T) => string;
16
+ getItemKey?: (item: T) => string;
17
+ onSearchChange: (value: string) => void;
18
+ onToggleSelectAll: () => void;
19
+ onToggleItem: (value: string) => void;
20
+ }
21
+ export declare function FilterListSection<T extends FilterListItem>({ title, items, selectedValues, selectAll, search, placeholder, showAvatar, getItemLabel, getItemValue, getItemKey, onSearchChange, onToggleSelectAll, onToggleItem, }: FilterListSectionProps<T>): import("react/jsx-runtime").JSX.Element;
22
+ //# sourceMappingURL=filter-list-section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-list-section.d.ts","sourceRoot":"","sources":["../../../src/patterns/filters/filter-list-section.tsx"],"names":[],"mappings":"AAYA,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,cAAc;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAEnC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAEnC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAEjC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAE9B,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAcD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAAE,EAC1D,KAAK,EACL,KAAK,EACL,cAAc,EACd,SAAS,EACT,MAAM,EACN,WAAsB,EACtB,UAAU,EACV,YAAkC,EAClC,YAAkC,EAClC,UAA8B,EAC9B,cAAc,EACd,iBAAiB,EACjB,YAAY,GACb,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CA8E3B"}
@@ -0,0 +1,107 @@
1
+ import { jsxs as n, jsx as r } from "react/jsx-runtime";
2
+ import { MinusSquare as g } from "@untitledui/icons";
3
+ import y from "../../primitives/select/SearchInput.js";
4
+ import { Checkbox as u } from "../../primitives/checkbox/checkbox.js";
5
+ import { Avatar as S } from "../../primitives/avatar/avatar.js";
6
+ function C(e) {
7
+ return e.label ?? String(e.value ?? "");
8
+ }
9
+ function b(e) {
10
+ return e.value ?? String(e.id ?? "");
11
+ }
12
+ function w(e) {
13
+ return e.id ?? e.value;
14
+ }
15
+ function q({
16
+ title: e,
17
+ items: s,
18
+ selectedValues: i,
19
+ selectAll: c,
20
+ search: l,
21
+ placeholder: m = "Search",
22
+ showAvatar: h,
23
+ getItemLabel: t = C,
24
+ getItemValue: f = b,
25
+ getItemKey: p = w,
26
+ onSearchChange: x,
27
+ onToggleSelectAll: o,
28
+ onToggleItem: v
29
+ }) {
30
+ const N = s.filter(
31
+ (a) => t(a).toLowerCase().includes(l.toLowerCase())
32
+ );
33
+ return /* @__PURE__ */ n("div", { children: [
34
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2 mb-4", children: [
35
+ /* @__PURE__ */ r("h3", { className: "text-sm font-medium text-gray-900", children: e }),
36
+ i.length > 0 && /* @__PURE__ */ n("span", { className: "text-xs", children: [
37
+ i.length,
38
+ " selected"
39
+ ] })
40
+ ] }),
41
+ /* @__PURE__ */ n("div", { className: "space-y-1", children: [
42
+ (s.length > 10 || l) && /* @__PURE__ */ r(
43
+ y,
44
+ {
45
+ className: "bg-secondary_subtle ring-0 rounded-md",
46
+ size: "sm",
47
+ placeholder: m,
48
+ value: l,
49
+ onChange: x
50
+ }
51
+ ),
52
+ /* @__PURE__ */ n("div", { className: "max-h-48 overflow-y-auto", children: [
53
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-3 p-2", children: [
54
+ c ? /* @__PURE__ */ r(
55
+ u,
56
+ {
57
+ className: "cursor-pointer",
58
+ "aria-label": "Select all",
59
+ isSelected: c,
60
+ onChange: o
61
+ }
62
+ ) : /* @__PURE__ */ r(
63
+ "div",
64
+ {
65
+ onClick: o,
66
+ className: "h-4 w-4 flex items-center justify-center overflow-hidden cursor-pointer",
67
+ children: /* @__PURE__ */ r(g, { size: 18, className: "text-utility-brand-600" })
68
+ }
69
+ ),
70
+ /* @__PURE__ */ r("span", { className: "text-sm font-medium text-gray-900", children: "Select All" })
71
+ ] }),
72
+ N.map((a) => {
73
+ const d = f(a);
74
+ return /* @__PURE__ */ n(
75
+ "div",
76
+ {
77
+ className: "flex items-center gap-3 hover:bg-primary_hover rounded-md p-2",
78
+ children: [
79
+ /* @__PURE__ */ r(
80
+ u,
81
+ {
82
+ "aria-label": t(a),
83
+ isSelected: i.includes(d),
84
+ onChange: () => v(d)
85
+ }
86
+ ),
87
+ h ? /* @__PURE__ */ r(
88
+ S,
89
+ {
90
+ size: "xs",
91
+ initials: t(a).charAt(0),
92
+ alt: t(a)
93
+ }
94
+ ) : null,
95
+ /* @__PURE__ */ r("span", { className: "text-sm text-gray-700", children: t(a) })
96
+ ]
97
+ },
98
+ p(a)
99
+ );
100
+ })
101
+ ] })
102
+ ] })
103
+ ] });
104
+ }
105
+ export {
106
+ q as FilterListSection
107
+ };
@@ -0,0 +1,4 @@
1
+ export { StatusFilterDropdown, type StatusFilterDropdownProps, type StatusFilterOption, type StatusFilters, } from './status-filter-dropdown';
2
+ export { ChecklistSelect, type ChecklistSelectProps, type ChecklistSelectOption, } from './checklist-select';
3
+ export { FilterListSection, type FilterListSectionProps, type FilterListItem, } from './filter-list-section';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/filters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,GACpB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { FC } from 'react';
2
+ export interface StatusFilterOption {
3
+ key: string;
4
+ label: string;
5
+ }
6
+ export interface StatusFilters {
7
+ all: boolean;
8
+ [key: string]: boolean;
9
+ }
10
+ type BaseFilterDropdownProps = {
11
+ isOpen: boolean;
12
+ onOpenChange: (isOpen: boolean) => void;
13
+ onApply: () => void;
14
+ onReset: () => void;
15
+ className?: string;
16
+ buttonLabel?: string;
17
+ isDisabled?: boolean;
18
+ /** When set, controls Apply button disabled state. Omit to keep Apply always enabled. */
19
+ isApplyDisabled?: boolean;
20
+ /** When set, controls Reset button disabled state. Omit to keep Reset always enabled. */
21
+ isResetDisabled?: boolean;
22
+ };
23
+ type MultipleSelectFilterDropdownProps = BaseFilterDropdownProps & {
24
+ selectionMode?: "multiple";
25
+ statusFilters: StatusFilters;
26
+ appliedStatusFilters: StatusFilters;
27
+ onStatusChange: (status: string) => void;
28
+ statusOptions: StatusFilterOption[];
29
+ /** When true, every option selected is the unfiltered default (active styling when not fully selected). */
30
+ defaultSelectAll?: boolean;
31
+ };
32
+ type SingleSelectFilterDropdownProps = BaseFilterDropdownProps & {
33
+ selectionMode: "single";
34
+ options: StatusFilterOption[];
35
+ value: string;
36
+ pendingValue: string;
37
+ onValueChange: (key: string) => void;
38
+ /** Value treated as unfiltered — used for active button styling and reset. Defaults to `all`. */
39
+ defaultValue?: string;
40
+ };
41
+ export type StatusFilterDropdownProps = MultipleSelectFilterDropdownProps | SingleSelectFilterDropdownProps;
42
+ export declare const StatusFilterDropdown: FC<StatusFilterDropdownProps>;
43
+ export {};
44
+ //# sourceMappingURL=status-filter-dropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-filter-dropdown.d.ts","sourceRoot":"","sources":["../../../src/patterns/filters/status-filter-dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAgB5E,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,OAAO,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yFAAyF;IACzF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yFAAyF;IACzF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,KAAK,iCAAiC,GAAG,uBAAuB,GAAG;IACjE,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,oBAAoB,EAAE,aAAa,CAAC;IACpC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,kBAAkB,EAAE,CAAC;IACpC,2GAA2G;IAC3G,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,+BAA+B,GAAG,uBAAuB,GAAG;IAC/D,aAAa,EAAE,QAAQ,CAAC;IACxB,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,iGAAiG;IACjG,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACjC,iCAAiC,GACjC,+BAA+B,CAAC;AAQpC,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CAsQ9D,CAAC"}
@@ -0,0 +1,212 @@
1
+ import { jsx as l, jsxs as c, Fragment as L } from "react/jsx-runtime";
2
+ import { useMemo as h, useRef as k, useState as O, useLayoutEffect as w } from "react";
3
+ import { ChevronDown as T, MinusSquare as B } from "@untitledui/icons";
4
+ import { cx as K } from "../../utils/cn.js";
5
+ import { Dropdown as C } from "../../primitives/dropdown/dropdown.js";
6
+ import { Button as y } from "../../primitives/button/button.js";
7
+ import { RadioButtonBase as _ } from "../../primitives/radio/radio.js";
8
+ import { CheckboxBase as I } from "../../primitives/checkbox/checkbox.js";
9
+ const S = ({ isSelected: t }) => /* @__PURE__ */ l("div", { className: "pointer-events-none", "aria-hidden": !0, children: /* @__PURE__ */ l(I, { isSelected: t }) }), X = (t) => {
10
+ const {
11
+ isOpen: u,
12
+ onOpenChange: D,
13
+ onApply: N,
14
+ onReset: F,
15
+ className: M,
16
+ buttonLabel: d = "Status",
17
+ isDisabled: R = !1,
18
+ isApplyDisabled: A,
19
+ isResetDisabled: p
20
+ } = t, r = t.selectionMode === "single", s = r ? t.options : t.statusOptions, a = (s == null ? void 0 : s.length) ?? 0, o = h(() => r ? 0 : Object.entries(t.appliedStatusFilters).filter(
21
+ ([e, n]) => e !== "all" && n
22
+ ).length, [r, t]), g = !r && t.defaultSelectAll === !0, z = h(() => {
23
+ if (r) {
24
+ const e = t.defaultValue ?? "all";
25
+ return t.value !== e;
26
+ }
27
+ return a === 0 ? !1 : g ? o < a : o > 0;
28
+ }, [
29
+ g,
30
+ r,
31
+ t,
32
+ o,
33
+ a
34
+ ]), m = h(() => r ? 0 : Object.entries(t.statusFilters).filter(
35
+ ([e, n]) => e !== "all" && n
36
+ ).length, [r, t]), x = m === a && a > 0, v = m > 0 && m < a, V = h(() => {
37
+ var n;
38
+ if (!r)
39
+ return !(o === a && a > 0) && o > 0 ? `${d} ${o} selected` : d;
40
+ const e = t.defaultValue ?? "all";
41
+ return t.value === e ? d : ((n = s.find((i) => i.key === t.value)) == null ? void 0 : n.label) ?? d;
42
+ }, [
43
+ r,
44
+ o,
45
+ a,
46
+ d,
47
+ t,
48
+ s
49
+ ]), f = k(null), b = k(0), [E, H] = O(
50
+ () => typeof window > "u" ? 400 : Math.round(window.innerHeight * 0.5)
51
+ ), j = r ? t.pendingValue : t.statusFilters;
52
+ return w(() => {
53
+ if (!u) return;
54
+ const e = () => {
55
+ H(Math.round(window.innerHeight * 0.5));
56
+ };
57
+ return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
58
+ }, [u]), w(() => {
59
+ const e = () => {
60
+ f.current && (f.current.scrollTop = b.current);
61
+ };
62
+ e();
63
+ const n = requestAnimationFrame(e);
64
+ return () => cancelAnimationFrame(n);
65
+ }, [j]), /* @__PURE__ */ l("div", { className: "relative", children: /* @__PURE__ */ c(C.Root, { isOpen: u, onOpenChange: D, children: [
66
+ /* @__PURE__ */ l(
67
+ y,
68
+ {
69
+ size: "xs",
70
+ color: "secondary",
71
+ iconTrailing: /* @__PURE__ */ l(T, { size: 12 }),
72
+ className: K(
73
+ "relative",
74
+ z && !u && "ring-1 ring-brand-600 bg-brand-primary text-brand-600 hover:bg-brand-primary hover:text-brand-600",
75
+ M,
76
+ u && "shadow-[0_0_0_4px_rgba(102,112,133,0.14)]"
77
+ ),
78
+ isDisabled: R,
79
+ children: V
80
+ }
81
+ ),
82
+ /* @__PURE__ */ l(
83
+ C.Popover,
84
+ {
85
+ className: "overflow-hidden",
86
+ style: { overflow: "hidden" },
87
+ maxHeight: E,
88
+ scrollRef: f,
89
+ children: /* @__PURE__ */ c("div", { className: "flex max-h-[50vh] flex-col overflow-hidden text-secondary text-xs", children: [
90
+ /* @__PURE__ */ l(
91
+ "div",
92
+ {
93
+ ref: f,
94
+ className: "min-h-0 flex-1 space-y-3 overflow-y-auto p-3",
95
+ role: r ? "radiogroup" : void 0,
96
+ "aria-label": r ? d : void 0,
97
+ onScroll: (e) => {
98
+ b.current = e.currentTarget.scrollTop;
99
+ },
100
+ children: r ? s.map((e) => {
101
+ const n = t.pendingValue === e.key;
102
+ return /* @__PURE__ */ c(
103
+ "div",
104
+ {
105
+ role: "radio",
106
+ "aria-checked": n,
107
+ tabIndex: 0,
108
+ className: "flex cursor-pointer items-center gap-3",
109
+ onMouseDownCapture: (i) => i.preventDefault(),
110
+ onClick: () => t.onValueChange(e.key),
111
+ onKeyDown: (i) => {
112
+ (i.key === "Enter" || i.key === " ") && (i.preventDefault(), t.onValueChange(e.key));
113
+ },
114
+ children: [
115
+ /* @__PURE__ */ l("div", { className: "pointer-events-none", children: /* @__PURE__ */ l(
116
+ _,
117
+ {
118
+ size: "sm",
119
+ isSelected: n,
120
+ "aria-hidden": !0
121
+ }
122
+ ) }),
123
+ /* @__PURE__ */ l("span", { children: e.label })
124
+ ]
125
+ },
126
+ e.key
127
+ );
128
+ }) : /* @__PURE__ */ c(L, { children: [
129
+ /* @__PURE__ */ c(
130
+ "div",
131
+ {
132
+ role: "checkbox",
133
+ "aria-checked": v ? "mixed" : x,
134
+ tabIndex: 0,
135
+ className: "flex cursor-pointer items-center gap-3",
136
+ onMouseDownCapture: (e) => e.preventDefault(),
137
+ onClick: () => t.onStatusChange("all"),
138
+ onKeyDown: (e) => {
139
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), t.onStatusChange("all"));
140
+ },
141
+ children: [
142
+ v ? /* @__PURE__ */ l(
143
+ B,
144
+ {
145
+ size: 18,
146
+ className: "text-utility-brand-600",
147
+ "aria-hidden": !0
148
+ }
149
+ ) : /* @__PURE__ */ l(S, { isSelected: x }),
150
+ /* @__PURE__ */ l("span", { children: "All" })
151
+ ]
152
+ }
153
+ ),
154
+ s.map((e) => /* @__PURE__ */ c(
155
+ "div",
156
+ {
157
+ role: "checkbox",
158
+ "aria-checked": t.statusFilters[e.key],
159
+ tabIndex: 0,
160
+ className: "flex cursor-pointer items-center gap-3",
161
+ onMouseDownCapture: (n) => n.preventDefault(),
162
+ onClick: () => t.onStatusChange(e.key),
163
+ onKeyDown: (n) => {
164
+ (n.key === "Enter" || n.key === " ") && (n.preventDefault(), t.onStatusChange(e.key));
165
+ },
166
+ children: [
167
+ /* @__PURE__ */ l(
168
+ S,
169
+ {
170
+ isSelected: t.statusFilters[e.key]
171
+ }
172
+ ),
173
+ /* @__PURE__ */ l("span", { children: e.label })
174
+ ]
175
+ },
176
+ e.key
177
+ ))
178
+ ] })
179
+ }
180
+ ),
181
+ /* @__PURE__ */ c("div", { className: "flex shrink-0 justify-end gap-2 bg-primary p-3", children: [
182
+ /* @__PURE__ */ l(
183
+ y,
184
+ {
185
+ size: "xs",
186
+ color: "secondary",
187
+ className: "flex-1 p-2",
188
+ onClick: F,
189
+ isDisabled: p,
190
+ children: "Reset"
191
+ }
192
+ ),
193
+ /* @__PURE__ */ l(
194
+ y,
195
+ {
196
+ size: "xs",
197
+ color: "primary",
198
+ className: "flex-1 p-2",
199
+ onClick: N,
200
+ isDisabled: A,
201
+ children: "Apply"
202
+ }
203
+ )
204
+ ] })
205
+ ] })
206
+ }
207
+ )
208
+ ] }) });
209
+ };
210
+ export {
211
+ X as StatusFilterDropdown
212
+ };
@@ -1,6 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { SubSidebarConfig, SubSidebarGuard, SubSidebarLinkProps } from './types';
3
3
  export interface SubSidebarProps {
4
+ /**
5
+ * Keep it stable (memoize it): a group holding the active link re-opens whenever `config.sections` changes
6
+ * identity, so an inline config re-opens it on every parent render.
7
+ */
4
8
  config: SubSidebarConfig;
5
9
  /** The current location's path, e.g. `useLocation().pathname`. */
6
10
  currentPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"sub-sidebar.d.ts","sourceRoot":"","sources":["../../../src/patterns/sub-sidebar/sub-sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAEf,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAajB,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,CAAC;IACzB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,sDAAsD;IACtD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,SAAS,CAAC;IACvD,yFAAyF;IACzF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAcD,eAAO,MAAM,UAAU,GAAI,wFAQxB,eAAe,4CA8YjB,CAAC"}
1
+ {"version":3,"file":"sub-sidebar.d.ts","sourceRoot":"","sources":["../../../src/patterns/sub-sidebar/sub-sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAEf,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAajB,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,MAAM,EAAE,gBAAgB,CAAC;IACzB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,sDAAsD;IACtD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,SAAS,CAAC;IACvD,yFAAyF;IACzF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAcD,eAAO,MAAM,UAAU,GAAI,wFAQxB,eAAe,4CAmZjB,CAAC"}