@pibit.ai/cure-design-system 0.5.12 → 0.6.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.
Files changed (61) hide show
  1. package/dist/applications/date-picker/calendar-value.d.ts +4 -0
  2. package/dist/applications/date-picker/calendar-value.d.ts.map +1 -0
  3. package/dist/applications/date-picker/calendar-value.js +6 -0
  4. package/dist/applications/date-picker/calendar.d.ts.map +1 -1
  5. package/dist/applications/date-picker/calendar.js +130 -124
  6. package/dist/applications/date-picker/date-time-calendar.d.ts.map +1 -1
  7. package/dist/applications/date-picker/date-time-calendar.js +56 -55
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +161 -157
  11. package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +6 -6
  12. package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +5 -5
  13. package/dist/node_modules/framer-motion/dist/es/utils/use-composed-ref.js +3 -3
  14. package/dist/node_modules/{@react-stately/data/dist → react-stately/dist/private/data}/useListData.js +61 -64
  15. package/dist/primitives/avatar/avatar.d.ts +46 -28
  16. package/dist/primitives/avatar/avatar.d.ts.map +1 -1
  17. package/dist/primitives/avatar/avatar.js +114 -39
  18. package/dist/primitives/avatar/base-components/avatar-online-indicator.d.ts +8 -0
  19. package/dist/primitives/avatar/base-components/avatar-online-indicator.d.ts.map +1 -0
  20. package/dist/primitives/avatar/base-components/avatar-online-indicator.js +29 -0
  21. package/dist/primitives/avatar/base-components/index.d.ts +3 -0
  22. package/dist/primitives/avatar/base-components/index.d.ts.map +1 -0
  23. package/dist/primitives/avatar/base-components/verified-tick.d.ts +7 -0
  24. package/dist/primitives/avatar/base-components/verified-tick.d.ts.map +1 -0
  25. package/dist/primitives/avatar/base-components/verified-tick.js +41 -0
  26. package/dist/primitives/dropdown/dropdown.d.ts +2 -2
  27. package/dist/primitives/input/input.d.ts.map +1 -1
  28. package/dist/primitives/input/input.js +9 -1
  29. package/dist/primitives/select/SearchInput.d.ts +7 -7
  30. package/dist/primitives/select/SearchInput.d.ts.map +1 -1
  31. package/dist/primitives/select/__tests__/multi-select-utils.test.d.ts +2 -0
  32. package/dist/primitives/select/__tests__/multi-select-utils.test.d.ts.map +1 -0
  33. package/dist/primitives/select/combobox.d.ts +1 -2
  34. package/dist/primitives/select/combobox.d.ts.map +1 -1
  35. package/dist/primitives/select/index.d.ts +3 -1
  36. package/dist/primitives/select/index.d.ts.map +1 -1
  37. package/dist/primitives/select/multi-select-utils.d.ts +7 -0
  38. package/dist/primitives/select/multi-select-utils.d.ts.map +1 -0
  39. package/dist/primitives/select/multi-select-utils.js +17 -0
  40. package/dist/primitives/select/multi-select.d.ts +17 -4
  41. package/dist/primitives/select/multi-select.d.ts.map +1 -1
  42. package/dist/primitives/select/multi-select.js +631 -237
  43. package/dist/primitives/select/searchable-select.d.ts +26 -4
  44. package/dist/primitives/select/searchable-select.d.ts.map +1 -1
  45. package/dist/primitives/select/searchable-select.js +292 -189
  46. package/dist/primitives/select/select-checkbox.d.ts +6 -0
  47. package/dist/primitives/select/select-checkbox.d.ts.map +1 -0
  48. package/dist/primitives/select/select-checkbox.js +62 -0
  49. package/dist/primitives/select/select-item.d.ts +3 -1
  50. package/dist/primitives/select/select-item.d.ts.map +1 -1
  51. package/dist/primitives/select/select-item.js +95 -77
  52. package/dist/primitives/select/select-native.d.ts +21 -2
  53. package/dist/primitives/select/select-native.d.ts.map +1 -1
  54. package/dist/primitives/select/select-native.js +88 -0
  55. package/dist/primitives/select/select-shared.d.ts +1 -0
  56. package/dist/primitives/select/select-shared.d.ts.map +1 -1
  57. package/dist/primitives/select/select.d.ts +12 -2
  58. package/dist/primitives/select/select.d.ts.map +1 -1
  59. package/dist/primitives/select/select.js +207 -152
  60. package/dist/styles/components.css +1 -1
  61. package/package.json +4 -4
@@ -2,10 +2,17 @@ import { FC, ReactNode } from 'react';
2
2
  import { SelectProps as AriaSelectProps } from 'react-aria-components';
3
3
  import { SelectItemType } from './select-shared';
4
4
  export interface SearchableSelectProps extends Omit<AriaSelectProps<SelectItemType>, "children" | "items" | "onSelectionChange"> {
5
- /** Items to display (should be filtered externally by parent) */
5
+ /** Items to display. Filtered client-side by the search input when `shouldFilterItems` is true. */
6
6
  items: SelectItemType[];
7
- /** Callback when search value changes - parent handles filtering */
8
- onSearchChange: (searchValue: string) => void;
7
+ /**
8
+ * When false, the search field does not filter `items`; the parent should update `items`
9
+ * (e.g. from an API) in `onSearchChange`. Default true.
10
+ */
11
+ shouldFilterItems?: boolean;
12
+ /** Custom client-side filter when `shouldFilterItems` is true. */
13
+ filterItem?: (item: SelectItemType, query: string) => boolean;
14
+ /** Optional callback when search value changes. */
15
+ onSearchChange?: (searchValue: string) => void;
9
16
  /** Loading state for async API calls */
10
17
  isLoading?: boolean;
11
18
  /** Hint text below the select */
@@ -26,12 +33,27 @@ export interface SearchableSelectProps extends Omit<AriaSelectProps<SelectItemTy
26
33
  textStyles?: string;
27
34
  /** Callback when selection changes; `null` when cleared */
28
35
  onSelectionChange?: (key: string | null) => void;
36
+ /** When true, shows a clear control when a value is selected. Clearing calls `onSelectionChange(null)`. */
37
+ isClearable?: boolean;
38
+ /**
39
+ * When true, clicking the clear (X) button reopens the dropdown after clearing.
40
+ * Does not apply to other clear paths (e.g. `isDeselectable`). Default false.
41
+ */
42
+ openOnClear?: boolean;
29
43
  /** When true, clicking the already-selected option in the dropdown clears the selection. Default false. */
30
44
  isDeselectable?: boolean;
31
45
  /** Placeholder for search input */
32
46
  searchPlaceholder?: string;
33
47
  /** Display text to show when selected item is not in items array */
34
48
  selectedDisplayValue?: string;
49
+ /** Footer content to display at the bottom of the select */
50
+ footer?: ReactNode;
51
+ /** Custom render function for select items */
52
+ renderItem?: (item: SelectItemType) => ReactNode;
53
+ /** Rendered to the left of the clear control and chevron. */
54
+ endAdornment?: ReactNode;
55
+ /** Rendered before the selected label in the trigger. */
56
+ leadingAdornment?: ReactNode;
35
57
  }
36
- export declare const SearchableSelect: ({ placeholder, placeholderIcon, size, items, label, hint, tooltip, className, textStyles, popoverClassName, onSearchChange, onSelectionChange, isLoading, isDeselectable, searchPlaceholder, selectedDisplayValue, ...rest }: SearchableSelectProps) => import("react/jsx-runtime").JSX.Element;
58
+ export declare const SearchableSelect: ({ placeholder, placeholderIcon, size, items, label, hint, tooltip, className, footer, textStyles, popoverClassName, onSearchChange, onSelectionChange, isLoading, isClearable, openOnClear, isDeselectable, searchPlaceholder, selectedDisplayValue, renderItem, endAdornment, leadingAdornment, shouldFilterItems, filterItem, ...rest }: SearchableSelectProps) => import("react/jsx-runtime").JSX.Element;
37
59
  //# sourceMappingURL=searchable-select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"searchable-select.d.ts","sourceRoot":"","sources":["../../../src/primitives/select/searchable-select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAO,MAAM,OAAO,CAAC;AAGhD,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAY5E,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAsBzB,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,eAAe,CAAC,cAAc,CAAC,EAC/B,UAAU,GAAG,OAAO,GAAG,mBAAmB,CAC3C;IACC,iEAAiE;IACjE,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,oEAAoE;IACpE,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,I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jsxs as f, Fragment as q } from "react/jsx-runtime";
2
- import { useState as M, useRef as _, useCallback as w, isValidElement as A } from "react";
3
- import { ChevronDown as C } from "@untitledui/icons";
4
- import { Select as E, ListBox as F, Button as H, SelectValue as L } from "react-aria-components";
5
- import { Avatar as D } from "../avatar/avatar.js";
6
- import { HintText as G } from "../input/hint-text.js";
7
- import { Label as J } from "../input/label.js";
8
- import { Popover as Q } from "./popover.js";
9
- import { SelectItem as W } from "./select-item.js";
10
- import { SelectContext as X, fontSizes as S, sizes as Y } from "./select-shared.js";
11
- import { cx as s } from "../../utils/cn.js";
12
- import { isReactComponent as Z } from "../../utils/is-react-component.js";
13
- import $ from "./SearchInput.js";
14
- import { LoadingIndicator as ee } from "../../applications/loading-indicator/loading-indicator.js";
15
- const te = {
1
+ import { jsx as r, jsxs as w, Fragment as H } from "react/jsx-runtime";
2
+ import { useState as J, useRef as Q, useCallback as B, useMemo as Y, isValidElement as fe } from "react";
3
+ import { ChevronDown as Z, XClose as pe } from "@untitledui/icons";
4
+ import { Select as me, ListBox as xe, Button as he, SelectValue as be, ButtonContext as ge } from "react-aria-components";
5
+ import { Avatar as ve } from "../avatar/avatar.js";
6
+ import { Popover as we } from "./popover.js";
7
+ import { SelectItem as Ne } from "./select-item.js";
8
+ import { SelectContext as ye, fontSizes as U, sizes as ke } from "./select-shared.js";
9
+ import { HintText as Pe } from "../input/hint-text.js";
10
+ import { Label as Te } from "../input/label.js";
11
+ import { cx as a } from "../../utils/cn.js";
12
+ import { isReactComponent as qe } from "../../utils/is-react-component.js";
13
+ import { LoadingIndicator as Se } from "../../applications/loading-indicator/loading-indicator.js";
14
+ import Be from "./SearchInput.js";
15
+ const Ke = {
16
16
  sm: "rounded-md",
17
17
  md: "rounded-md",
18
18
  lg: "rounded-lg"
19
- }, re = {
19
+ }, Re = {
20
20
  sm: "text-xs",
21
- md: "text-xs",
22
- lg: "text-sm"
23
- }, le = "relative flex w-full cursor-pointer items-center bg-primary ring-1 ring-secondary outline-hidden transition duration-100 ease-linear ring-inset", ne = ({
24
- isOpen: P,
25
- isFocused: R,
26
- isDisabled: i,
27
- size: l,
28
- placeholder: x,
29
- placeholderIcon: h,
30
- textStyles: g,
31
- selectedDisplayValue: d
32
- }) => /* @__PURE__ */ t(
33
- H,
34
- {
35
- className: s(
36
- le,
37
- te[l],
38
- (R || P) && "ring-1 ring-brand",
39
- i && "cursor-not-allowed bg-disabled_subtle text-disabled"
40
- ),
41
- children: /* @__PURE__ */ t(
42
- L,
43
- {
44
- className: s(
45
- "flex h-max w-full items-center justify-start gap-2 truncate text-left align-middle",
46
- "*:data-icon:size-5 *:data-icon:shrink-0 *:data-icon:text-fg-quaternary in-disabled:*:data-icon:text-fg-disabled",
47
- Y[l].root
48
- ),
49
- children: (n) => {
50
- var u, o, y, v, I;
51
- const m = ((u = n.selectedItem) == null ? void 0 : u.icon) || h, c = !!n.selectedItem, a = !c && !!d;
52
- return /* @__PURE__ */ f(q, { children: [
53
- (o = n.selectedItem) != null && o.avatarUrl ? /* @__PURE__ */ t(
54
- D,
55
- {
56
- size: "sm",
57
- src: n.selectedItem.avatarUrl,
58
- alt: n.selectedItem.label
59
- }
60
- ) : Z(m) ? /* @__PURE__ */ t(m, { "data-icon": !0, "aria-hidden": "true" }) : A(m) ? m : null,
61
- c ? /* @__PURE__ */ f("section", { className: "flex w-full gap-2 truncate", children: [
62
- /* @__PURE__ */ t(
21
+ md: "text-sm",
22
+ lg: "text-md"
23
+ }, De = "relative flex w-full cursor-pointer items-center bg-primary ring-1 outline-hidden transition duration-100 ease-linear ring-inset", je = (p, N) => {
24
+ const s = N.trim().toLowerCase();
25
+ if (!s) return !0;
26
+ const u = String(p.label ?? "").toLowerCase(), x = String(p.supportingText ?? "").toLowerCase(), o = String(p.id ?? "").toLowerCase();
27
+ return u.includes(s) || x.includes(s) || o.includes(s);
28
+ }, ze = {
29
+ sm: "size-4",
30
+ md: "size-4",
31
+ lg: "size-5"
32
+ }, Oe = ({
33
+ isOpen: p,
34
+ isFocused: N,
35
+ isDisabled: s,
36
+ isInvalid: u,
37
+ isLoading: x,
38
+ size: o = "sm",
39
+ placeholder: F,
40
+ placeholderIcon: y,
41
+ textStyles: k,
42
+ selectedDisplayValue: P,
43
+ isClearable: L = !1,
44
+ onClear: i,
45
+ hasSelection: l = !1,
46
+ endAdornment: d,
47
+ triggerSelectedItem: K = null,
48
+ hasSupportingText: T = !1,
49
+ leadingAdornment: m
50
+ }) => {
51
+ const V = L && l && !s && i;
52
+ return /* @__PURE__ */ r(
53
+ he,
54
+ {
55
+ className: a(
56
+ De,
57
+ Ke[o],
58
+ u ? "ring-error" : N || p ? "ring-brand" : "ring-secondary",
59
+ s && "cursor-not-allowed bg-disabled_subtle text-disabled"
60
+ ),
61
+ children: /* @__PURE__ */ r(
62
+ be,
63
+ {
64
+ className: a(
65
+ "flex h-max w-full items-center justify-start gap-2 text-left align-middle",
66
+ T ? "px-2 pt-3 pb-3" : a("truncate", ke[o].root),
67
+ "*:data-icon:size-5 *:data-icon:shrink-0 *:data-icon:text-fg-quaternary in-disabled:*:data-icon:text-fg-disabled"
68
+ ),
69
+ children: (R) => {
70
+ const n = K ?? R.selectedItem, h = (n == null ? void 0 : n.icon) || y, b = !!n, g = !b && !!P;
71
+ return x && !b && !g ? /* @__PURE__ */ w(H, { children: [
72
+ /* @__PURE__ */ r("div", { className: "h-3.5 min-w-0 flex-1 animate-pulse rounded bg-secondary" }),
73
+ /* @__PURE__ */ r(
74
+ Z,
75
+ {
76
+ "aria-hidden": "true",
77
+ className: a(
78
+ "shrink-0 text-fg-quaternary",
79
+ o === "sm" ? "size-4 stroke-[2.5px]" : "size-5"
80
+ )
81
+ }
82
+ )
83
+ ] }) : /* @__PURE__ */ w(H, { children: [
84
+ n != null && n.avatarUrl ? /* @__PURE__ */ r(
85
+ ve,
86
+ {
87
+ size: "xs",
88
+ src: n.avatarUrl,
89
+ alt: n.label
90
+ }
91
+ ) : qe(h) ? /* @__PURE__ */ r(h, { "data-icon": !0, "aria-hidden": "true" }) : fe(h) ? h : null,
92
+ m && (b || g) ? /* @__PURE__ */ r("div", { className: "flex shrink-0 items-center self-center", children: m }) : null,
93
+ b ? /* @__PURE__ */ w("section", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
94
+ /* @__PURE__ */ r(
95
+ "p",
96
+ {
97
+ className: a(
98
+ "truncate font-medium text-primary",
99
+ U[o],
100
+ k
101
+ ),
102
+ children: n == null ? void 0 : n.label
103
+ }
104
+ ),
105
+ (n == null ? void 0 : n.supportingText) && /* @__PURE__ */ r(
106
+ "p",
107
+ {
108
+ className: a(
109
+ "truncate text-xs",
110
+ (n == null ? void 0 : n.supportingTextClassName) ?? "text-[#818792]"
111
+ ),
112
+ children: n == null ? void 0 : n.supportingText
113
+ }
114
+ )
115
+ ] }) : g ? /* @__PURE__ */ r("section", { className: "flex min-w-0 flex-1 gap-2 truncate", children: /* @__PURE__ */ r(
63
116
  "p",
64
117
  {
65
- className: s(
118
+ className: a(
66
119
  "truncate font-medium text-primary",
67
- S[l],
68
- g
120
+ U[o],
121
+ k
122
+ ),
123
+ children: P
124
+ }
125
+ ) }) : /* @__PURE__ */ r(
126
+ "p",
127
+ {
128
+ className: a(
129
+ "min-w-0 flex-1 text-placeholder_subtle",
130
+ U[o],
131
+ s && "text-disabled"
69
132
  ),
70
- children: (y = n.selectedItem) == null ? void 0 : y.label
133
+ children: F
71
134
  }
72
135
  ),
73
- ((v = n.selectedItem) == null ? void 0 : v.supportingText) && /* @__PURE__ */ t("p", { className: s("text-tertiary", S[l]), children: (I = n.selectedItem) == null ? void 0 : I.supportingText })
74
- ] }) : a ? /* @__PURE__ */ t("section", { className: "flex w-full gap-2 truncate", children: /* @__PURE__ */ t(
75
- "p",
76
- {
77
- className: s(
78
- "truncate font-medium text-primary",
79
- S[l],
80
- g
81
- ),
82
- children: d
83
- }
84
- ) }) : /* @__PURE__ */ t(
85
- "p",
86
- {
87
- className: s(
88
- "text-placeholder_subtle",
89
- S[l],
90
- i && "text-disabled"
91
- ),
92
- children: x
93
- }
94
- ),
95
- /* @__PURE__ */ t(
96
- C,
97
- {
98
- "aria-hidden": "true",
99
- className: s(
100
- "ml-auto shrink-0 text-fg-quaternary",
101
- l === "sm" ? "size-4 stroke-[2.5px]" : "size-5"
102
- )
103
- }
104
- )
105
- ] });
136
+ d ? /* @__PURE__ */ r(ge.Provider, { value: null, children: /* @__PURE__ */ r("div", { className: "flex shrink-0 items-center self-center", children: d }) }) : null,
137
+ V ? /* @__PURE__ */ r(
138
+ "button",
139
+ {
140
+ type: "button",
141
+ tabIndex: -1,
142
+ "aria-label": "Clear selection",
143
+ onPointerDown: (v) => {
144
+ v.stopPropagation();
145
+ },
146
+ onClick: (v) => {
147
+ v.preventDefault(), v.stopPropagation(), i == null || i();
148
+ },
149
+ className: "flex shrink-0 cursor-pointer items-center justify-center rounded-md p-1 text-fg-quaternary outline-hidden transition hover:bg-primary_hover focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-focus-ring",
150
+ children: /* @__PURE__ */ r(pe, { "aria-hidden": !0, className: ze[o] })
151
+ }
152
+ ) : null,
153
+ /* @__PURE__ */ r(
154
+ Z,
155
+ {
156
+ "aria-hidden": "true",
157
+ className: a(
158
+ "shrink-0 text-fg-quaternary",
159
+ o === "sm" ? "size-4 stroke-[2.5px]" : "size-5"
160
+ )
161
+ }
162
+ )
163
+ ] });
164
+ }
106
165
  }
107
- }
108
- )
109
- }
110
- ), ve = ({
111
- placeholder: P = "Select",
112
- placeholderIcon: R,
113
- size: i = "sm",
114
- items: l,
166
+ )
167
+ }
168
+ );
169
+ }, Qe = ({
170
+ placeholder: p = "Select",
171
+ placeholderIcon: N,
172
+ size: s = "sm",
173
+ items: u,
115
174
  label: x,
116
- hint: h,
117
- tooltip: g,
118
- className: d,
119
- textStyles: n,
120
- popoverClassName: m,
121
- onSearchChange: c,
122
- onSelectionChange: a,
123
- isLoading: u = !1,
124
- isDeselectable: o = !1,
125
- searchPlaceholder: y = "Search...",
126
- selectedDisplayValue: v,
127
- ...I
175
+ hint: o,
176
+ tooltip: F,
177
+ className: y,
178
+ footer: k,
179
+ textStyles: P,
180
+ popoverClassName: L,
181
+ onSearchChange: i,
182
+ onSelectionChange: l,
183
+ isLoading: d = !1,
184
+ isClearable: K = !1,
185
+ openOnClear: T = !1,
186
+ isDeselectable: m = !1,
187
+ searchPlaceholder: V = "Search...",
188
+ selectedDisplayValue: R,
189
+ renderItem: n,
190
+ endAdornment: h,
191
+ leadingAdornment: b,
192
+ shouldFilterItems: g = !0,
193
+ filterItem: v,
194
+ ...$
128
195
  }) => {
129
- const [K, k] = M(""), T = _(!1), { selectedKey: N, ...p } = I, b = N === void 0 ? void 0 : N == null || String(N) === "" ? null : N, V = w(
130
- (r) => {
131
- k(r), c(r);
196
+ const [M, _] = J(""), [C, ee] = J(!1), A = Q(!1), I = Q(null), {
197
+ selectedKey: E,
198
+ isOpen: W,
199
+ onOpenChange: D,
200
+ ...re
201
+ } = $, c = E == null || String(E) === "" ? null : E, j = W !== void 0, z = T || j, te = j ? W : z ? C : void 0, ne = B(
202
+ (t) => {
203
+ _(t), i == null || i(t);
132
204
  },
133
- [c]
134
- ), j = w(
135
- (r) => {
136
- var e;
137
- r || (k(""), c("")), (e = p.onOpenChange) == null || e.call(p, r);
205
+ [i]
206
+ ), X = v ?? je, q = Y(() => {
207
+ if (!g) return u;
208
+ const t = M.trim();
209
+ return t ? u.filter((e) => X(e, t)) : u;
210
+ }, [X, M, u, g]), le = (t) => {
211
+ var G;
212
+ if (t.key !== "ArrowDown" && t.key !== "ArrowUp" || t.nativeEvent.isComposing || !(t.target instanceof HTMLInputElement) || (t.preventDefault(), t.stopPropagation(), d || q.length === 0)) return;
213
+ const e = (G = I.current) == null ? void 0 : G.querySelectorAll(
214
+ '[role="option"]:not([aria-disabled="true"])'
215
+ ), f = t.key === "ArrowDown" ? e == null ? void 0 : e[0] : e == null ? void 0 : e[e.length - 1];
216
+ f == null || f.focus({ preventScroll: !0 }), f == null || f.scrollIntoView({ block: "nearest" });
217
+ }, S = B(
218
+ (t) => {
219
+ !j && z && ee(t), t || (_(""), i == null || i("")), D == null || D(t);
138
220
  },
139
- [p.onOpenChange, c]
140
- ), U = w(() => {
141
- !o || b == null || (T.current = !0, a == null || a(null), j(!1), queueMicrotask(() => {
142
- T.current = !1;
221
+ [j, z, D, i]
222
+ ), se = B(() => {
223
+ l == null || l(null), T && S(!0);
224
+ }, [T, l, S]), oe = B(() => {
225
+ !m || c == null || (A.current = !0, l == null || l(null), S(!1), queueMicrotask(() => {
226
+ A.current = !1;
143
227
  }));
144
- }, [j, o, a, b]), z = w(
145
- (r) => {
146
- if (T.current) return;
147
- const e = r == null || String(r) === "" ? null : String(r);
148
- e === null && !o || a == null || a(e);
228
+ }, [S, m, l, c]), ie = B(
229
+ (t) => {
230
+ if (A.current) return;
231
+ const e = t == null || String(t) === "" ? null : String(t), f = c == null || String(c) === "" ? null : String(c);
232
+ e !== f && (l == null || l(e));
149
233
  },
150
- [o, a]
151
- ), B = [{ id: "none", label: "none" }], O = l.length > 0 ? l : B;
152
- return /* @__PURE__ */ t(
153
- X.Provider,
234
+ [l, c]
235
+ ), ae = c != null || !!R, O = Y(
236
+ () => c == null ? null : u.find((t) => String(t.id) === String(c)) ?? null,
237
+ [u, c]
238
+ ), ce = !!(O != null && O.supportingText), ue = [{ id: "none", label: "none" }], de = q.length > 0 ? q : ue;
239
+ return /* @__PURE__ */ r(
240
+ ye.Provider,
154
241
  {
155
242
  value: {
156
- size: i,
157
- isDeselectable: o,
158
- selectedKey: b,
159
- onReselectCurrent: o ? U : void 0
243
+ size: s,
244
+ isDeselectable: m,
245
+ selectedKey: c,
246
+ onReselectCurrent: m ? oe : void 0
160
247
  },
161
- children: /* @__PURE__ */ t(
162
- E,
248
+ children: /* @__PURE__ */ r(
249
+ me,
163
250
  {
164
- ...p,
165
- selectedKey: b,
166
- onOpenChange: j,
167
- onSelectionChange: z,
168
- className: (r) => s(
251
+ ...re,
252
+ selectedKey: c,
253
+ ...z ? { isOpen: te } : {},
254
+ onOpenChange: S,
255
+ onSelectionChange: ie,
256
+ className: (t) => a(
169
257
  "flex flex-col gap-1.5",
170
- typeof d == "function" ? d(r) : d
258
+ typeof y == "function" ? y(t) : y
171
259
  ),
172
- children: (r) => /* @__PURE__ */ f(q, { children: [
173
- x && /* @__PURE__ */ t(
174
- J,
260
+ children: (t) => /* @__PURE__ */ w(H, { children: [
261
+ x && /* @__PURE__ */ r(
262
+ Te,
175
263
  {
176
- isRequired: r.isRequired,
177
- tooltip: g,
178
- className: re[i],
264
+ isRequired: t.isRequired,
265
+ tooltip: F,
266
+ className: Re[s],
179
267
  children: x
180
268
  }
181
269
  ),
182
- /* @__PURE__ */ t(
183
- ne,
270
+ /* @__PURE__ */ r(
271
+ Oe,
184
272
  {
185
- ...r,
186
- size: i,
187
- placeholder: P,
188
- placeholderIcon: R,
189
- textStyles: n,
190
- selectedDisplayValue: v
273
+ ...t,
274
+ size: s,
275
+ isLoading: d,
276
+ placeholder: p,
277
+ placeholderIcon: N,
278
+ textStyles: P,
279
+ selectedDisplayValue: R,
280
+ isClearable: K,
281
+ hasSelection: ae,
282
+ hasSupportingText: ce,
283
+ triggerSelectedItem: O,
284
+ leadingAdornment: b,
285
+ onClear: K && l ? se : void 0,
286
+ endAdornment: h
191
287
  }
192
288
  ),
193
- /* @__PURE__ */ f(
194
- Q,
289
+ /* @__PURE__ */ w(
290
+ we,
195
291
  {
196
- size: i,
197
- className: s("flex flex-col", m),
292
+ size: s,
293
+ className: a("flex flex-col overflow-hidden", L),
198
294
  children: [
199
- /* @__PURE__ */ t(
295
+ /* @__PURE__ */ r(
200
296
  "div",
201
297
  {
202
- className: "sticky top-0 z-10 bg-primary p-1.5",
298
+ className: "z-10 shrink-0 border-b border-tertiary bg-primary p-1.5",
203
299
  onMouseDown: (e) => e.stopPropagation(),
204
300
  onPointerDown: (e) => e.stopPropagation(),
205
301
  onClick: (e) => e.stopPropagation(),
206
- children: /* @__PURE__ */ t(
207
- $,
302
+ onKeyDownCapture: le,
303
+ children: /* @__PURE__ */ r(
304
+ Be,
208
305
  {
209
306
  size: "sm",
210
- placeholder: y,
211
- value: K,
212
- onChange: (e) => V(e),
307
+ placeholder: V,
308
+ value: M,
309
+ onChange: (e) => ne(e),
213
310
  onKeyDown: (e) => e.stopPropagation(),
214
- className: "w-full ring-0 outline-hidden bg-secondary rounded-lg"
311
+ className: "w-full ring-0 outline-hidden bg-secondary rounded-lg",
312
+ autoFocus: !0
215
313
  }
216
314
  )
217
315
  }
218
316
  ),
219
- /* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto", children: [
220
- u && /* @__PURE__ */ t("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ t(ee, { size: "xs", type: "line-simple" }) }),
221
- !u && l.length === 0 && /* @__PURE__ */ t("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ t("p", { className: "text-sm text-tertiary", children: "No results" }) }),
222
- /* @__PURE__ */ t(
223
- F,
317
+ /* @__PURE__ */ w("div", { className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: [
318
+ d && /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ r(Se, { size: "xs", type: "line-simple" }) }),
319
+ !d && q.length === 0 && /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ r("p", { className: a("text-tertiary", U[s]), children: "No results" }) }),
320
+ /* @__PURE__ */ r(
321
+ xe,
224
322
  {
225
- items: O,
226
- className: s(
227
- "size-full outline-hidden px-1",
228
- (u || l.length === 0) && "hidden"
323
+ ref: I,
324
+ items: de,
325
+ shouldFocusOnHover: !1,
326
+ shouldFocusWrap: !0,
327
+ className: a(
328
+ "min-h-0 overflow-y-auto outline-hidden px-1",
329
+ (d || q.length === 0) && "hidden"
229
330
  ),
230
- children: (e) => /* @__PURE__ */ t(
231
- W,
331
+ children: (e) => n ? n(e) : /* @__PURE__ */ r(
332
+ Ne,
232
333
  {
233
334
  id: e.id,
234
335
  label: e.label,
235
336
  avatarUrl: e.avatarUrl,
236
337
  supportingText: e.supportingText,
338
+ supportingTextClassName: e.supportingTextClassName,
237
339
  isDisabled: e.isDisabled,
238
340
  icon: e.icon,
239
- textStyles: n
341
+ textStyles: P
240
342
  },
241
343
  e.id
242
344
  )
243
345
  }
244
346
  )
245
- ] })
347
+ ] }),
348
+ k && /* @__PURE__ */ r("div", { className: "shrink-0 border-t border-tertiary bg-primary p-1.5", children: k })
246
349
  ]
247
350
  }
248
351
  ),
249
- h && /* @__PURE__ */ t(G, { isInvalid: r.isInvalid, children: h })
352
+ o && /* @__PURE__ */ r(Pe, { isInvalid: t.isInvalid, children: o })
250
353
  ] })
251
354
  }
252
355
  )
@@ -254,5 +357,5 @@ const te = {
254
357
  );
255
358
  };
256
359
  export {
257
- ve as SearchableSelect
360
+ Qe as SearchableSelect
258
361
  };
@@ -0,0 +1,6 @@
1
+ import { ComponentProps } from 'react';
2
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
3
+ export declare function SelectCheckbox({ size, className, ...props }: ComponentProps<typeof CheckboxPrimitive.Root> & {
4
+ size?: "xs" | "sm" | "md" | "lg";
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=select-checkbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-checkbox.d.ts","sourceRoot":"","sources":["../../../src/primitives/select/select-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAQ9D,wBAAgB,cAAc,CAAC,EAC7B,IAAW,EACX,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG;IACjD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAClC,2CAyCA"}