@overdoser/react-toolkit 0.21.0 → 0.22.1

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 (161) hide show
  1. package/AGENTS.md +1 -0
  2. package/CHANGELOG.md +35 -0
  3. package/components/Accordion/Accordion.js +48 -48
  4. package/components/ActionButton/ActionButton.js +23 -23
  5. package/components/ActionButton/CopyButton.js +5 -5
  6. package/components/Alert/Alert.js +13 -13
  7. package/components/Avatar/Avatar.js +12 -12
  8. package/components/Badge/Badge.js +6 -6
  9. package/components/Breadcrumbs/Breadcrumbs.js +15 -15
  10. package/components/Button/Button.js +14 -14
  11. package/components/Card/Card.js +26 -26
  12. package/components/Chart/AreaChart.js +103 -103
  13. package/components/Chart/Axis.js +7 -7
  14. package/components/Chart/BarChart.js +62 -62
  15. package/components/Chart/ChartContainer.js +11 -11
  16. package/components/Chart/ChartLegend.js +7 -7
  17. package/components/Chart/ChartTooltip.js +13 -13
  18. package/components/Chart/LineChart.js +88 -88
  19. package/components/Chart/PieChart.js +25 -25
  20. package/components/Chart/RadarChart.js +42 -42
  21. package/components/Chart/Sparkline.js +11 -11
  22. package/components/Chart/TradingChart.js +126 -126
  23. package/components/Chart/trading/period.js +3 -3
  24. package/components/Chip/Chip.js +24 -24
  25. package/components/CodeBlock/CodeBlock.js +31 -31
  26. package/components/CommandPalette/CommandPalette.js +166 -166
  27. package/components/ConfirmDialog/ConfirmDialog.js +60 -60
  28. package/components/Divider/Divider.js +10 -10
  29. package/components/Draggable/Draggable.js +29 -29
  30. package/components/Drawer/Drawer.js +53 -53
  31. package/components/Dropdown/Dropdown.js +66 -66
  32. package/components/Dropdown/DropdownItem.js +13 -13
  33. package/components/Dropdown/DropdownLabel.js +5 -5
  34. package/components/Dropdown/DropdownSeparator.js +5 -5
  35. package/components/Dropzone/Dropzone.js +15 -15
  36. package/components/EmptyState/EmptyState.js +11 -11
  37. package/components/Form/Form.js +17 -17
  38. package/components/Form/FormField.js +21 -21
  39. package/components/Form/FormRow.js +3 -3
  40. package/components/ImageViewer/ImageViewer.js +118 -118
  41. package/components/Kbd/Kbd.js +11 -11
  42. package/components/KeyValueList/KeyValueList.js +32 -32
  43. package/components/Link/Link.js +7 -7
  44. package/components/List/List.js +7 -7
  45. package/components/Loader/Loader.js +39 -39
  46. package/components/Modal/Modal.js +48 -48
  47. package/components/PageHeader/PageHeader.js +18 -18
  48. package/components/Pagination/Pagination.js +23 -23
  49. package/components/Popover/Popover.js +25 -25
  50. package/components/ProgressBar/ProgressBar.js +17 -17
  51. package/components/RelativeTime/RelativeTime.js +10 -10
  52. package/components/SegmentedControl/SegmentedControl.js +38 -38
  53. package/components/Skeleton/Skeleton.js +10 -10
  54. package/components/Spinner/Spinner.js +7 -7
  55. package/components/SplitButton/SplitButton.js +63 -63
  56. package/components/SplitPane/SplitPane.js +50 -50
  57. package/components/StatCard/StatCard.js +32 -32
  58. package/components/StatusDot/StatusDot.js +7 -7
  59. package/components/Table/Table.js +174 -174
  60. package/components/Tabs/Tabs.js +47 -47
  61. package/components/ThemeToggle/ThemeToggle.js +31 -31
  62. package/components/Timeline/GanttTimeline.js +213 -213
  63. package/components/Timeline/HistoryTimeline.js +306 -306
  64. package/components/Timeline/TimelineShared.js +103 -103
  65. package/components/Timeline/TraceEventDetails.js +103 -103
  66. package/components/Timeline/TraceTimeline.js +546 -546
  67. package/components/Timeline/historyLayout.js +2 -2
  68. package/components/Timer/Timer.js +39 -39
  69. package/components/Toast/Toast.js +59 -59
  70. package/components/ToggleIconButton/ToggleIconButton.js +9 -9
  71. package/components/Tooltip/Tooltip.js +16 -16
  72. package/components/Typography/Typography.js +5 -5
  73. package/components/inputs/Checkbox/Checkbox.js +11 -11
  74. package/components/inputs/Checkbox/CheckboxGroup.js +21 -21
  75. package/components/inputs/DatePicker/CalendarPanel.js +113 -113
  76. package/components/inputs/DatePicker/DatePicker.js +39 -39
  77. package/components/inputs/DateTimePicker/DateTimePicker.js +119 -119
  78. package/components/inputs/DateTimePicker/DateTimeSegments.js +40 -40
  79. package/components/inputs/DateTimePicker/TimeField.js +34 -34
  80. package/components/inputs/Input/Input.js +13 -13
  81. package/components/inputs/NumberInput/NumberInput.js +16 -16
  82. package/components/inputs/Radio/Radio.js +17 -17
  83. package/components/inputs/SearchInput/SearchInput.js +25 -25
  84. package/components/inputs/Select/Select.d.ts +55 -3
  85. package/components/inputs/Select/Select.js +485 -344
  86. package/components/inputs/Select/{Select.module.js → Select.module.scss.js} +15 -3
  87. package/components/inputs/Slider/Slider.js +21 -21
  88. package/components/inputs/Switch/Switch.js +4 -4
  89. package/components/inputs/Textarea/Textarea.js +8 -8
  90. package/hooks/usePortalPosition.d.ts +2 -1
  91. package/hooks/usePortalPosition.js +6 -3
  92. package/hooks/useResizable.js +1 -1
  93. package/hooks/useTheme.js +7 -7
  94. package/index.css +1 -1
  95. package/index.js +1 -1
  96. package/index.layered.css +1 -1
  97. package/llms.txt +25 -4
  98. package/manifest.json +33 -4
  99. package/package.json +1 -1
  100. /package/components/Accordion/{Accordion.module.js → Accordion.module.scss.js} +0 -0
  101. /package/components/ActionButton/{ActionButton.module.js → ActionButton.module.scss.js} +0 -0
  102. /package/components/Alert/{Alert.module.js → Alert.module.scss.js} +0 -0
  103. /package/components/Avatar/{Avatar.module.js → Avatar.module.scss.js} +0 -0
  104. /package/components/Badge/{Badge.module.js → Badge.module.scss.js} +0 -0
  105. /package/components/Breadcrumbs/{Breadcrumbs.module.js → Breadcrumbs.module.scss.js} +0 -0
  106. /package/components/Button/{Button.module.js → Button.module.scss.js} +0 -0
  107. /package/components/Card/{Card.module.js → Card.module.scss.js} +0 -0
  108. /package/components/Chart/{Chart.module.js → Chart.module.scss.js} +0 -0
  109. /package/components/Chip/{Chip.module.js → Chip.module.scss.js} +0 -0
  110. /package/components/CodeBlock/{CodeBlock.module.js → CodeBlock.module.scss.js} +0 -0
  111. /package/components/CommandPalette/{CommandPalette.module.js → CommandPalette.module.scss.js} +0 -0
  112. /package/components/ConfirmDialog/{ConfirmDialog.module.js → ConfirmDialog.module.scss.js} +0 -0
  113. /package/components/Divider/{Divider.module.js → Divider.module.scss.js} +0 -0
  114. /package/components/Draggable/{Draggable.module.js → Draggable.module.scss.js} +0 -0
  115. /package/components/Drawer/{Drawer.module.js → Drawer.module.scss.js} +0 -0
  116. /package/components/Dropdown/{Dropdown.module.js → Dropdown.module.scss.js} +0 -0
  117. /package/components/Dropzone/{Dropzone.module.js → Dropzone.module.scss.js} +0 -0
  118. /package/components/EmptyState/{EmptyState.module.js → EmptyState.module.scss.js} +0 -0
  119. /package/components/Form/{Form.module.js → Form.module.scss.js} +0 -0
  120. /package/components/ImageViewer/{ImageViewer.module.js → ImageViewer.module.scss.js} +0 -0
  121. /package/components/Kbd/{Kbd.module.js → Kbd.module.scss.js} +0 -0
  122. /package/components/KeyValueList/{KeyValueList.module.js → KeyValueList.module.scss.js} +0 -0
  123. /package/components/Link/{Link.module.js → Link.module.scss.js} +0 -0
  124. /package/components/List/{List.module.js → List.module.scss.js} +0 -0
  125. /package/components/Loader/{Loader.module.js → Loader.module.scss.js} +0 -0
  126. /package/components/Modal/{Modal.module.js → Modal.module.scss.js} +0 -0
  127. /package/components/PageHeader/{PageHeader.module.js → PageHeader.module.scss.js} +0 -0
  128. /package/components/Pagination/{Pagination.module.js → Pagination.module.scss.js} +0 -0
  129. /package/components/Popover/{Popover.module.js → Popover.module.scss.js} +0 -0
  130. /package/components/ProgressBar/{ProgressBar.module.js → ProgressBar.module.scss.js} +0 -0
  131. /package/components/RelativeTime/{RelativeTime.module.js → RelativeTime.module.scss.js} +0 -0
  132. /package/components/SegmentedControl/{SegmentedControl.module.js → SegmentedControl.module.scss.js} +0 -0
  133. /package/components/Skeleton/{Skeleton.module.js → Skeleton.module.scss.js} +0 -0
  134. /package/components/Spinner/{Spinner.module.js → Spinner.module.scss.js} +0 -0
  135. /package/components/SplitButton/{SplitButton.module.js → SplitButton.module.scss.js} +0 -0
  136. /package/components/SplitPane/{SplitPane.module.js → SplitPane.module.scss.js} +0 -0
  137. /package/components/StatCard/{StatCard.module.js → StatCard.module.scss.js} +0 -0
  138. /package/components/StatusDot/{StatusDot.module.js → StatusDot.module.scss.js} +0 -0
  139. /package/components/Table/{Table.module.js → Table.module.scss.js} +0 -0
  140. /package/components/Tabs/{Tabs.module.js → Tabs.module.scss.js} +0 -0
  141. /package/components/ThemeToggle/{ThemeToggle.module.js → ThemeToggle.module.scss.js} +0 -0
  142. /package/components/Timeline/{GanttTimeline.module.js → GanttTimeline.module.scss.js} +0 -0
  143. /package/components/Timeline/{HistoryTimeline.module.js → HistoryTimeline.module.scss.js} +0 -0
  144. /package/components/Timeline/{Timeline.module.js → Timeline.module.scss.js} +0 -0
  145. /package/components/Timeline/{TraceTimeline.module.js → TraceTimeline.module.scss.js} +0 -0
  146. /package/components/Timer/{Timer.module.js → Timer.module.scss.js} +0 -0
  147. /package/components/Toast/{Toast.module.js → Toast.module.scss.js} +0 -0
  148. /package/components/ToggleIconButton/{ToggleIconButton.module.js → ToggleIconButton.module.scss.js} +0 -0
  149. /package/components/Tooltip/{Tooltip.module.js → Tooltip.module.scss.js} +0 -0
  150. /package/components/Typography/{Typography.module.js → Typography.module.scss.js} +0 -0
  151. /package/components/inputs/Checkbox/{Checkbox.module.js → Checkbox.module.scss.js} +0 -0
  152. /package/components/inputs/Checkbox/{CheckboxGroup.module.js → CheckboxGroup.module.scss.js} +0 -0
  153. /package/components/inputs/DatePicker/{CalendarPanel.module.js → CalendarPanel.module.scss.js} +0 -0
  154. /package/components/inputs/DatePicker/{DatePicker.module.js → DatePicker.module.scss.js} +0 -0
  155. /package/components/inputs/DateTimePicker/{DateTimePicker.module.js → DateTimePicker.module.scss.js} +0 -0
  156. /package/components/inputs/Input/{Input.module.js → Input.module.scss.js} +0 -0
  157. /package/components/inputs/NumberInput/{NumberInput.module.js → NumberInput.module.scss.js} +0 -0
  158. /package/components/inputs/Radio/{Radio.module.js → Radio.module.scss.js} +0 -0
  159. /package/components/inputs/SearchInput/{SearchInput.module.js → SearchInput.module.scss.js} +0 -0
  160. /package/components/inputs/Slider/{Slider.module.js → Slider.module.scss.js} +0 -0
  161. /package/components/inputs/Textarea/{Textarea.module.js → Textarea.module.scss.js} +0 -0
@@ -1,37 +1,37 @@
1
- import e from "./Select.module.js";
2
- import { usePortalPosition as t } from "../../../hooks/usePortalPosition.js";
3
- import { Spinner as n } from "../../Spinner/Spinner.js";
4
- import { forwardRef as r, useCallback as i, useEffect as a, useId as o, useMemo as s, useRef as c, useState as l } from "react";
5
- import u from "clsx";
6
- import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
7
- import { createPortal as ee } from "react-dom";
1
+ import { forwardRef as e, useCallback as t, useEffect as n, useId as r, useMemo as i, useRef as a, useState as o } from "react";
2
+ import { createPortal as s } from "react-dom";
3
+ import c from "clsx";
4
+ import l from "./Select.module.scss.js";
5
+ import { usePortalPosition as ee } from "../../../hooks/usePortalPosition.js";
6
+ import { Spinner as te } from "../../Spinner/Spinner.js";
7
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
8
8
  // src/components/inputs/Select/Select.tsx
9
- var m = r(({ inputSize: t = "md", error: n = !1, options: r, placeholder: i, classes: a, className: o, style: s, children: c, searchable: l, searchPlaceholder: d, onValuesChange: ee, clearSearchOnSelect: m, closeOnSelect: te, allowCreate: ne, onCreate: re, createLabel: ie, portal: ae, onSearch: oe, searchDebounce: h, minSearchLength: g, searchPrompt: se, loading: _, loadingMessage: v, noResultsMessage: y, highlightMatches: ce, selectedLabels: le, onChange: b, onValueChange: x, ...S }, ue) => {
10
- let C = b || x ? (e) => {
11
- b?.(e), x?.(e.target.value);
9
+ var p = e(({ inputSize: e = "md", error: t = !1, options: n, placeholder: r, classes: i, className: a, style: o, children: s, searchable: ee, searchPlaceholder: te, onValuesChange: u, clearSearchOnSelect: p, closeOnSelect: ne, allowCreate: re, onCreate: ie, createLabel: ae, portal: oe, onSearch: se, searchDebounce: ce, minSearchLength: m, searchPrompt: le, loading: ue, loadingMessage: h, noResultsMessage: g, highlightMatches: _, selectedLabels: v, checklist: de, selectAllLabel: fe, deselectAllLabel: y, maxVisibleChips: b, moreChipsLabel: pe, onChange: x, onValueChange: S, ...C }, me) => {
10
+ let he = x || S ? (e) => {
11
+ x?.(e), S?.(e.target.value);
12
12
  } : void 0;
13
- return /* @__PURE__ */ p("div", {
14
- className: u(e.wrapper, e[t], n && e.error, a?.wrapper, o),
15
- style: s,
16
- children: [/* @__PURE__ */ p("select", {
17
- ref: ue,
18
- className: u(e.root, e[t], n && e.error, a?.root),
19
- onChange: C,
20
- ...S,
21
- children: [i && /* @__PURE__ */ f("option", {
13
+ return /* @__PURE__ */ f("div", {
14
+ className: c(l.wrapper, l[e], t && l.error, i?.wrapper, a),
15
+ style: o,
16
+ children: [/* @__PURE__ */ f("select", {
17
+ ref: me,
18
+ className: c(l.root, l[e], t && l.error, i?.root),
19
+ onChange: he,
20
+ ...C,
21
+ children: [r && /* @__PURE__ */ d("option", {
22
22
  value: "",
23
23
  disabled: !0,
24
- children: i
25
- }), r ? r.map((e) => /* @__PURE__ */ f("option", {
24
+ children: r
25
+ }), n ? n.map((e) => /* @__PURE__ */ d("option", {
26
26
  value: e.value,
27
27
  disabled: e.disabled,
28
28
  children: e.label
29
- }, e.value)) : c]
30
- }), /* @__PURE__ */ f("span", { className: u(e.arrow, a?.arrow) })]
29
+ }, e.value)) : s]
30
+ }), /* @__PURE__ */ d("span", { className: c(l.arrow, i?.arrow) })]
31
31
  });
32
32
  });
33
- m.displayName = "NativeSelect";
34
- function te(e) {
33
+ p.displayName = "NativeSelect";
34
+ function ne(e) {
35
35
  let { name: t, form: n, required: r, title: i, autoFocus: a, tabIndex: o } = e, s = {
36
36
  title: i,
37
37
  autoFocus: a,
@@ -50,8 +50,8 @@ function te(e) {
50
50
  aria: c
51
51
  };
52
52
  }
53
- function ne(e, t, n) {
54
- let r = c(!1);
53
+ function re(e, t, n) {
54
+ let r = a(!1);
55
55
  return {
56
56
  onFocus: (t) => {
57
57
  r.current || (r.current = !0, e?.(t));
@@ -62,31 +62,31 @@ function ne(e, t, n) {
62
62
  }
63
63
  };
64
64
  }
65
- function re(e, t, n, r, i) {
66
- let o = c(e);
67
- o.current = e;
68
- let s = c(null), l = !!e;
69
- a(() => {
70
- if (!l || !n || t.length < i) return;
65
+ function ie(e, t, r, i, o) {
66
+ let s = a(e);
67
+ s.current = e;
68
+ let c = a(null), l = !!e;
69
+ n(() => {
70
+ if (!l || !r || t.length < o) return;
71
71
  let e = () => {
72
- s.current !== t && (s.current = t, o.current?.(t));
72
+ c.current !== t && (c.current = t, s.current?.(t));
73
73
  };
74
- if (r <= 0 || t === "") {
74
+ if (i <= 0 || t === "") {
75
75
  e();
76
76
  return;
77
77
  }
78
- let a = setTimeout(e, r);
79
- return () => clearTimeout(a);
78
+ let n = setTimeout(e, i);
79
+ return () => clearTimeout(n);
80
80
  }, [
81
81
  l,
82
- n,
83
- t,
84
82
  r,
85
- i
83
+ t,
84
+ i,
85
+ o
86
86
  ]);
87
87
  }
88
- function ie(e, t, n) {
89
- return s(() => {
88
+ function ae(e, t, n) {
89
+ return i(() => {
90
90
  if (n || !t) return e;
91
91
  let r = t.toLowerCase();
92
92
  return e.filter((e) => e.label.toLowerCase().includes(r));
@@ -96,466 +96,607 @@ function ie(e, t, n) {
96
96
  n
97
97
  ]);
98
98
  }
99
- function ae(t, n, r, i) {
100
- if (t.content !== void 0) return t.content;
101
- if (!r || !n) return t.label;
102
- let a = t.label.toLowerCase().indexOf(n.toLowerCase());
103
- return a < 0 ? t.label : /* @__PURE__ */ p(d, { children: [
104
- t.label.slice(0, a),
105
- /* @__PURE__ */ f("mark", {
106
- className: u(e.match, i),
107
- children: t.label.slice(a, a + n.length)
99
+ function oe(e, t) {
100
+ return `${e}-opt-${t}`;
101
+ }
102
+ function se(e, t, n, r) {
103
+ if (e.content !== void 0) return e.content;
104
+ if (!n || !t) return e.label;
105
+ let i = e.label.toLowerCase().indexOf(t.toLowerCase());
106
+ return i < 0 ? e.label : /* @__PURE__ */ f(u, { children: [
107
+ e.label.slice(0, i),
108
+ /* @__PURE__ */ d("mark", {
109
+ className: c(l.match, r),
110
+ children: e.label.slice(i, i + t.length)
108
111
  }),
109
- t.label.slice(a + n.length)
112
+ e.label.slice(i + t.length)
110
113
  ] });
111
114
  }
112
- function oe(e) {
115
+ function ce(e) {
113
116
  return e.loading ? e.loadingMessage : e.remote && e.query.length < e.minSearchLength ? e.searchPrompt : e.empty ? e.noResultsMessage : null;
114
117
  }
115
- var h = r(({ inputSize: r = "md", error: s = !1, options: d = [], placeholder: m = "Select...", classes: h, className: g, style: se, value: _, disabled: v, id: y, searchPlaceholder: ce = "Search...", onChange: le, onValueChange: b, portal: x = !0, onFocus: S, onBlur: ue, onSearch: C, searchDebounce: de = 250, minSearchLength: w = 0, searchPrompt: fe = "Type to search", loading: T = !1, loadingMessage: pe = "Loading…", noResultsMessage: me = "No results", highlightMatches: E = !1, selectedLabels: he, multiple: ge, onValuesChange: _e, clearSearchOnSelect: ve, closeOnSelect: ye, allowCreate: be, onCreate: xe, createLabel: Se, ...Ce }, D) => {
116
- let O = !!C, [k, A] = l(!1), [j, M] = l(""), N = T || O && j.length < w, [P, F] = l(0), I = c(null), L = c(null), R = c(null), z = c(null), B = c(null), V = o(), H = t(I, k && x), { hidden: we, control: Te, aria: U } = te(Ce), Ee = ne(S, ue, [I, z]), W = c(null), De = (e) => {
117
- W.current = e, typeof D == "function" ? D(e) : D && (D.current = e);
118
- }, Oe = c(!1);
119
- a(() => {
120
- Oe.current && !k && R.current?.focus(), Oe.current = k;
121
- }, [k]);
122
- let G = i(() => {
123
- A(!1), M(""), F(0);
124
- }, []), K = i(() => {
125
- v || (A(!0), M(""), F(0), setTimeout(() => L.current?.focus(), 0));
126
- }, [v]), q = i((e) => {
127
- if (b?.(e), W.current) {
128
- (Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")?.set)?.call(W.current, e);
118
+ var m = e(({ inputSize: e = "md", error: i = !1, options: u = [], placeholder: p = "Select...", classes: m, className: le, style: ue, value: h, disabled: g, id: _, searchPlaceholder: v = "Search...", onChange: de, onValueChange: fe, portal: y = !0, onFocus: b, onBlur: pe, onSearch: x, searchDebounce: S = 250, minSearchLength: C = 0, searchPrompt: me = "Type to search", loading: he = !1, loadingMessage: ge = "Loading…", noResultsMessage: _e = "No results", highlightMatches: ve = !1, selectedLabels: ye, multiple: be, onValuesChange: xe, clearSearchOnSelect: Se, closeOnSelect: Ce, allowCreate: we, onCreate: Te, createLabel: Ee, checklist: De, selectAllLabel: Oe, deselectAllLabel: ke, maxVisibleChips: w, moreChipsLabel: Ae, ...je }, T) => {
119
+ let E = !!x, [D, Me] = o(!1), [O, Ne] = o(""), Pe = he || E && O.length < C, [k, A] = o(0), j = a(null), M = a(null), N = a(null), P = a(null), F = a(null), I = r(), L = ee(j, D && y), { hidden: Fe, control: R, aria: z } = ne(je), Ie = re(b, pe, [j, P]), B = a(null), V = (e) => {
120
+ B.current = e, typeof T == "function" ? T(e) : T && (T.current = e);
121
+ }, Le = a(!1);
122
+ n(() => {
123
+ Le.current && !D && N.current?.focus(), Le.current = D;
124
+ }, [D]);
125
+ let H = t(() => {
126
+ Me(!1), Ne(""), A(0);
127
+ }, []), Re = t(() => {
128
+ g || (Me(!0), Ne(""), A(0), setTimeout(() => M.current?.focus(), 0));
129
+ }, [g]), U = t((e) => {
130
+ if (fe?.(e), B.current) {
131
+ (Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")?.set)?.call(B.current, e);
129
132
  let t = new Event("change", { bubbles: !0 });
130
- W.current.dispatchEvent(t), le?.(t);
133
+ B.current.dispatchEvent(t), de?.(t);
131
134
  }
132
- G();
135
+ H();
133
136
  }, [
134
- b,
135
- le,
136
- W,
137
- G
138
- ]), J = ie(d, j, O);
139
- re(C, j, k, de, w), a(() => {
140
- let e = J.findIndex((e) => !e.disabled);
141
- F(e >= 0 ? e : 0);
142
- }, [J]), a(() => {
143
- if (!k) return;
144
- let e = B.current;
145
- e && e.querySelectorAll("[role=\"option\"]")[P]?.scrollIntoView?.({ block: "nearest" });
146
- }, [P, k]);
147
- let ke = i((e) => {
148
- let t = J.map((e, t) => e.disabled ? -1 : t).filter((e) => e >= 0);
149
- if (e.key === "Escape") e.preventDefault(), G();
137
+ fe,
138
+ de,
139
+ B,
140
+ H
141
+ ]), W = ae(u, O, E);
142
+ ie(x, O, D, S, C), n(() => {
143
+ let e = W.findIndex((e) => !e.disabled);
144
+ A(e >= 0 ? e : 0);
145
+ }, [W]), n(() => {
146
+ if (!D) return;
147
+ let e = F.current;
148
+ e && e.querySelectorAll("[role=\"option\"]")[k]?.scrollIntoView?.({ block: "nearest" });
149
+ }, [k, D]);
150
+ let ze = t((e) => {
151
+ let t = W.map((e, t) => e.disabled ? -1 : t).filter((e) => e >= 0);
152
+ if (e.key === "Escape") e.preventDefault(), H();
150
153
  else if (t.length !== 0) {
151
- if (e.key === "ArrowDown") e.preventDefault(), F((e) => {
154
+ if (e.key === "ArrowDown") e.preventDefault(), A((e) => {
152
155
  let n = t.indexOf(e);
153
156
  return n < t.length - 1 ? t[n + 1] : t[0];
154
157
  });
155
- else if (e.key === "ArrowUp") e.preventDefault(), F((e) => {
158
+ else if (e.key === "ArrowUp") e.preventDefault(), A((e) => {
156
159
  let n = t.indexOf(e);
157
160
  return n > 0 ? t[n - 1] : t[t.length - 1];
158
161
  });
159
162
  else if (e.key === "Enter") {
160
- if (e.preventDefault(), N) return;
161
- let t = J[P];
162
- t && !t.disabled && q(t.value);
163
+ if (e.preventDefault(), Pe) return;
164
+ let t = W[k];
165
+ t && !t.disabled && U(t.value);
163
166
  }
164
167
  }
165
168
  }, [
166
- J,
167
- P,
168
- q,
169
- G,
170
- N
169
+ W,
170
+ k,
171
+ U,
172
+ H,
173
+ Pe
171
174
  ]);
172
- a(() => {
173
- if (!k) return;
175
+ n(() => {
176
+ if (!D) return;
174
177
  let e = (e) => {
175
178
  let t = e.target;
176
- I.current?.contains(t) || z.current?.contains(t) || G();
179
+ j.current?.contains(t) || P.current?.contains(t) || H();
177
180
  };
178
181
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
179
- }, [k, G]);
180
- let Y = d.find((e) => e.value === _), X = Y?.label ?? (_ ? he?.[_] ?? (O ? _ : void 0) : void 0), Z = typeof X == "string" ? X : void 0, Q = J.filter((e) => !e.disabled), $ = oe({
181
- loading: T,
182
- loadingMessage: pe,
183
- remote: O,
184
- query: j,
185
- minSearchLength: w,
186
- searchPrompt: fe,
187
- empty: J.length === 0,
188
- noResultsMessage: me
182
+ }, [D, H]);
183
+ let G = u.find((e) => e.value === h), Be = G?.label ?? (h ? ye?.[h] ?? (E ? h : void 0) : void 0), Ve = typeof Be == "string" ? Be : void 0, He = W.filter((e) => !e.disabled), K = ce({
184
+ loading: he,
185
+ loadingMessage: ge,
186
+ remote: E,
187
+ query: O,
188
+ minSearchLength: C,
189
+ searchPrompt: me,
190
+ empty: W.length === 0,
191
+ noResultsMessage: _e
189
192
  });
190
- return /* @__PURE__ */ p("div", {
191
- ref: I,
192
- className: u(e.wrapper, e.searchableWrapper, e[r], s && e.error, v && e.disabled, h?.wrapper, g),
193
- style: se,
194
- ...Ee,
193
+ return /* @__PURE__ */ f("div", {
194
+ ref: j,
195
+ className: c(l.wrapper, l.searchableWrapper, l[e], i && l.error, g && l.disabled, m?.wrapper, le),
196
+ style: ue,
197
+ ...Ie,
195
198
  children: [
196
- /* @__PURE__ */ p("select", {
197
- ref: De,
198
- className: e.hiddenSelect,
199
- value: _ ?? "",
200
- disabled: v,
199
+ /* @__PURE__ */ f("select", {
200
+ ref: V,
201
+ className: l.hiddenSelect,
202
+ value: h ?? "",
203
+ disabled: g,
201
204
  tabIndex: -1,
202
205
  "aria-hidden": "true",
203
206
  onChange: () => {},
204
- ...we,
207
+ ...Fe,
205
208
  children: [
206
- /* @__PURE__ */ f("option", { value: "" }),
207
- d.map((e) => /* @__PURE__ */ f("option", {
209
+ /* @__PURE__ */ d("option", { value: "" }),
210
+ u.map((e) => /* @__PURE__ */ d("option", {
208
211
  value: e.value,
209
212
  children: e.label
210
213
  }, e.value)),
211
- _ && !Y && /* @__PURE__ */ f("option", {
212
- value: _,
213
- children: Z ?? _
214
+ h && !G && /* @__PURE__ */ d("option", {
215
+ value: h,
216
+ children: Ve ?? h
214
217
  })
215
218
  ]
216
219
  }),
217
- /* @__PURE__ */ p("button", {
218
- ref: R,
219
- id: k ? void 0 : y,
220
+ /* @__PURE__ */ f("button", {
221
+ ref: N,
222
+ id: D ? void 0 : _,
220
223
  type: "button",
221
- className: u(e.root, e.searchableTrigger, e[r], k && e.triggerOpen, s && e.error, k && e.visuallyHidden, h?.root),
222
- onClick: K,
223
- disabled: v,
224
- "aria-expanded": k,
224
+ className: c(l.root, l.searchableTrigger, l[e], D && l.triggerOpen, i && l.error, D && l.visuallyHidden, m?.root),
225
+ onClick: Re,
226
+ disabled: g,
227
+ "aria-expanded": D,
225
228
  "aria-haspopup": "listbox",
226
- "aria-controls": k ? V : void 0,
227
- ...Te,
229
+ "aria-controls": D ? I : void 0,
230
+ ...R,
228
231
  children: [
229
- /* @__PURE__ */ f("span", {
230
- className: u(e.triggerLabel, !X && e.placeholder),
231
- children: X || m
232
+ /* @__PURE__ */ d("span", {
233
+ className: c(l.triggerLabel, !Be && l.placeholder),
234
+ children: Be || p
232
235
  }),
233
- T && /* @__PURE__ */ f(n, {
236
+ he && /* @__PURE__ */ d(te, {
234
237
  size: "sm",
235
238
  label: "",
236
239
  "aria-hidden": "true",
237
- className: u(e.spinner, h?.spinner)
240
+ className: c(l.spinner, m?.spinner)
238
241
  }),
239
- /* @__PURE__ */ f("span", { className: u(e.arrow, e.arrowInline, h?.arrow) })
242
+ /* @__PURE__ */ d("span", { className: c(l.arrow, l.arrowInline, m?.arrow) })
240
243
  ]
241
244
  }),
242
- k && /* @__PURE__ */ f("input", {
243
- ref: L,
244
- id: y,
245
+ D && /* @__PURE__ */ d("input", {
246
+ ref: M,
247
+ id: _,
245
248
  type: "text",
246
249
  role: "combobox",
247
- className: u(e.root, e.searchableTrigger, e[r], e.triggerOpen, s && e.error, h?.root, h?.search),
248
- placeholder: Z || (typeof m == "string" ? m : void 0),
249
- value: j,
250
- onChange: (e) => M(e.target.value),
251
- onKeyDown: ke,
250
+ className: c(l.root, l.searchableTrigger, l[e], l.triggerOpen, i && l.error, m?.root, m?.search),
251
+ placeholder: Ve || (typeof p == "string" ? p : void 0),
252
+ value: O,
253
+ onChange: (e) => Ne(e.target.value),
254
+ onKeyDown: ze,
252
255
  "aria-expanded": !0,
253
256
  "aria-haspopup": "listbox",
254
- "aria-controls": V,
255
- "aria-activedescendant": Q.length > 0 ? `select-option-${J[P]?.value}` : void 0,
256
- "aria-label": U["aria-labelledby"] || y ? void 0 : ce,
257
- ...U
257
+ "aria-controls": I,
258
+ "aria-activedescendant": He.length > 0 && W[k] ? oe(I, k) : void 0,
259
+ "aria-label": z["aria-labelledby"] || _ ? void 0 : v,
260
+ ...z
258
261
  }),
259
- k && (() => {
260
- let t = x ? {
262
+ D && (() => {
263
+ let e = y ? {
261
264
  position: "fixed",
262
- top: H.top + 4,
263
- left: H.left,
265
+ top: L.top + 4,
266
+ left: L.left,
264
267
  right: "auto",
265
- width: H.width,
268
+ width: L.width,
266
269
  zIndex: "var(--crk-z-floating)"
267
- } : void 0, n = /* @__PURE__ */ f("div", {
268
- id: V,
269
- ref: z,
270
- className: u(e.menu, h?.menu),
271
- style: t,
270
+ } : void 0, t = /* @__PURE__ */ d("div", {
271
+ id: I,
272
+ ref: P,
273
+ className: c(l.menu, m?.menu),
274
+ style: e,
272
275
  role: "listbox",
273
- children: /* @__PURE__ */ f("div", {
274
- className: e.menuItems,
275
- ref: B,
276
- children: $ === null ? J.map((t, n) => /* @__PURE__ */ f("button", {
277
- id: `select-option-${t.value}`,
276
+ children: /* @__PURE__ */ d("div", {
277
+ className: l.menuItems,
278
+ ref: F,
279
+ children: K === null ? W.map((e, t) => /* @__PURE__ */ d("button", {
280
+ id: oe(I, t),
278
281
  type: "button",
279
282
  role: "option",
280
- "aria-selected": t.value === _,
281
- className: u(e.item, t.disabled && e.itemDisabled, t.value === _ && e.itemSelected, n === P && e.itemHighlighted, h?.item),
282
- disabled: t.disabled,
283
- onClick: () => q(t.value),
284
- onMouseEnter: () => F(n),
285
- children: ae(t, j, E && !O, h?.match)
286
- }, t.value)) : /* @__PURE__ */ f("div", {
287
- className: u(e.noResults, h?.message),
283
+ "aria-selected": e.value === h,
284
+ className: c(l.item, e.disabled && l.itemDisabled, e.value === h && l.itemSelected, t === k && l.itemHighlighted, m?.item),
285
+ disabled: e.disabled,
286
+ onClick: () => U(e.value),
287
+ onMouseEnter: () => A(t),
288
+ children: se(e, O, ve && !E, m?.match)
289
+ }, e.value)) : /* @__PURE__ */ d("div", {
290
+ className: c(l.noResults, m?.message),
288
291
  role: "status",
289
- children: $
292
+ children: K
290
293
  })
291
294
  })
292
295
  });
293
- return x && typeof document < "u" ? ee(n, document.body) : n;
296
+ return y && typeof document < "u" ? s(t, document.body) : t;
294
297
  })()
295
298
  ]
296
299
  });
297
300
  });
298
- h.displayName = "SearchableSelect";
299
- var g = r(({ inputSize: r = "md", error: s = !1, options: m = [], placeholder: h = "Select...", classes: g, className: se, style: _, value: v, disabled: y, id: ce, searchPlaceholder: le, onValuesChange: b, clearSearchOnSelect: x = !0, closeOnSelect: S = !0, allowCreate: ue = !1, onCreate: C, createLabel: de, portal: w = !0, onFocus: fe, onBlur: T, onSearch: pe, searchDebounce: me = 250, minSearchLength: E = 0, searchPrompt: he = "Type to search", loading: ge = !1, loadingMessage: _e = "Loading…", noResultsMessage: ve = "No results", highlightMatches: ye = !1, selectedLabels: be, multiple: xe, searchable: Se, onChange: Ce, onValueChange: D, ...O }, k) => {
300
- let A = !!pe, j = Array.isArray(v) ? v : v ? [v] : [], [M, N] = l(!1), [P, F] = l(""), I = ge || A && P.length < E, [L, R] = l(0), z = c(null), B = c(null), V = c(null), H = c(null), we = c(null), Te = o(), U = t(we, M && w), { hidden: Ee, control: W } = te(O), De = ne(fe, T, [z, V]), Oe = c(null), G = (e) => {
301
- Oe.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
302
- }, K = i(() => {
303
- N(!1), F(""), R(0);
304
- }, []), q = i(() => {
305
- y || (N(!0), F(""), R(0), setTimeout(() => B.current?.focus(), 0));
306
- }, [y]), J = i((e) => {
307
- let t = j.includes(e) ? j.filter((t) => t !== e) : [...j, e];
308
- b?.(t), S ? K() : x && F("");
301
+ m.displayName = "SearchableSelect";
302
+ var le = /* @__PURE__ */ new Set(), ue = (e) => `+${e} more`, h = ({ className: e }) => /* @__PURE__ */ f("svg", {
303
+ className: e,
304
+ viewBox: "0 0 20 20",
305
+ fill: "none",
306
+ stroke: "currentColor",
307
+ strokeWidth: "1.8",
308
+ "aria-hidden": "true",
309
+ children: [/* @__PURE__ */ d("circle", {
310
+ cx: "8.5",
311
+ cy: "8.5",
312
+ r: "5.5"
313
+ }), /* @__PURE__ */ d("path", {
314
+ d: "M12.8 12.8L17 17",
315
+ strokeLinecap: "round"
316
+ })]
317
+ });
318
+ function g(e, t) {
319
+ let n = t?.[e];
320
+ return typeof n == "string" ? {
321
+ value: e,
322
+ label: n
323
+ } : {
324
+ value: e,
325
+ label: e,
326
+ content: n
327
+ };
328
+ }
329
+ var _ = e(({ inputSize: e = "md", error: p = !1, options: m = [], placeholder: _ = "Select...", classes: v, className: de, style: fe, value: y, disabled: b, id: pe, searchPlaceholder: x = "Search...", onValuesChange: S, clearSearchOnSelect: C, closeOnSelect: me, allowCreate: he = !1, onCreate: ge, createLabel: _e, portal: ve = !0, onFocus: ye, onBlur: be, onSearch: xe, searchDebounce: Se = 250, minSearchLength: Ce = 0, searchPrompt: we = "Type to search", loading: Te = !1, loadingMessage: Ee = "Loading…", noResultsMessage: De = "No results", highlightMatches: Oe = !1, selectedLabels: ke, checklist: w = !1, selectAllLabel: Ae, deselectAllLabel: je = "Deselect all", maxVisibleChips: T, moreChipsLabel: E = ue, multiple: D, searchable: Me, onChange: O, onValueChange: Ne, ...Pe }, k) => {
330
+ let A = !!xe, j = me ?? !w, M = C ?? !w, N = Array.isArray(y) ? y : y ? [y] : [], [P, F] = o(!1), [I, L] = o(""), Fe = Te || A && I.length < Ce, [R, z] = o(0), Ie = a(null), B = a(null), V = a(null), Le = a(null), H = a(null), Re = a(null), U = r(), W = ee(H, P && ve), { hidden: ze, control: G } = ne(Pe), Be = re(ye, be, [Ie, V]), Ve = a(null), He = (e) => {
331
+ Ve.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
332
+ }, K = t((e = !1) => {
333
+ F(!1), L(""), z(0), e && Re.current?.focus();
334
+ }, []), Ue = t(() => {
335
+ b || (F(!0), L(""), z(0), setTimeout(() => B.current?.focus(), 0));
336
+ }, [b]), We = t((e) => {
337
+ let t = N.includes(e) ? N.filter((t) => t !== e) : [...N, e];
338
+ S?.(t), j ? K(w) : M && L("");
309
339
  }, [
310
- j,
311
- b,
340
+ N,
312
341
  S,
342
+ j,
313
343
  K,
314
- x
315
- ]), ke = i((e, t) => {
316
- t.stopPropagation(), b?.(j.filter((t) => t !== e));
317
- }, [j, b]), Y = ie(m, P, A);
318
- re(pe, P, M, me, E);
319
- let X = P.trim(), Z = ue && X.length > 0 && !m.some((e) => e.label.toLowerCase() === X.toLowerCase() || e.value === X) && !j.includes(X), Q = i(() => {
320
- X && (j.includes(X) || (C?.(X), b?.([...j, X]), S ? K() : x && F("")));
344
+ M,
345
+ w
346
+ ]), Ge = t((e, t) => {
347
+ t.stopPropagation(), S?.(N.filter((t) => t !== e));
348
+ }, [N, S]), q = ae(m, I, A);
349
+ ie(xe, I, P, Se, Ce);
350
+ let Ke = i(() => new Map(m.map((e) => [e.value, e])), [m]), qe = w && P ? I : null, [Je, Ye] = o({
351
+ key: null,
352
+ values: le
353
+ }), J = Je.values;
354
+ Je.key !== qe && (J = qe === null ? le : new Set(N), Ye({
355
+ key: qe,
356
+ values: J
357
+ }));
358
+ let Y = i(() => {
359
+ if (J.size === 0) return q;
360
+ let e = new Set(q.map((e) => e.value)), t = A ? q : m.filter((t) => e.has(t.value) || J.has(t.value)), n = [...J].filter((e) => !Ke.has(e)).map((e) => g(e, ke));
361
+ return n.length > 0 ? [...t, ...n] : t;
362
+ }, [
363
+ q,
364
+ J,
365
+ A,
366
+ m,
367
+ Ke,
368
+ ke
369
+ ]), X = I.trim(), Z = he && X.length > 0 && !m.some((e) => e.label.toLowerCase() === X.toLowerCase() || e.value === X) && !N.includes(X), Xe = t(() => {
370
+ X && (N.includes(X) || (ge?.(X), S?.([...N, X]), j ? K(w) : M && L("")));
321
371
  }, [
322
372
  X,
323
- j,
324
- C,
325
- b,
373
+ N,
374
+ ge,
326
375
  S,
376
+ j,
327
377
  K,
328
- x
378
+ M,
379
+ w
329
380
  ]);
330
- a(() => {
381
+ n(() => {
331
382
  let e = Y.findIndex((e) => !e.disabled);
332
- R(e >= 0 ? e : 0);
333
- }, [Y]), a(() => {
334
- if (!M) return;
335
- let e = H.current;
336
- e && e.querySelectorAll("[role=\"option\"]")[L]?.scrollIntoView?.({ block: "nearest" });
337
- }, [L, M]);
338
- let $ = Y.length, Ae = i((e) => {
383
+ z(e >= 0 ? e : 0);
384
+ }, [q, J]), n(() => {
385
+ if (!P) return;
386
+ let e = Le.current;
387
+ e && e.querySelectorAll("[role=\"option\"]")[R]?.scrollIntoView?.({ block: "nearest" });
388
+ }, [R, P]);
389
+ let Q = Y.length, Ze = t((e) => {
339
390
  let t = Y.map((e, t) => e.disabled ? -1 : t).filter((e) => e >= 0);
340
- if (Z && t.push($), e.key === "Backspace" && P === "" && j.length > 0) e.preventDefault(), b?.(j.slice(0, -1));
391
+ if (Z && t.push(Q), !w && e.key === "Backspace" && I === "" && N.length > 0) e.preventDefault(), S?.(N.slice(0, -1));
341
392
  else if (e.key === "Escape") {
342
- if (!M) return;
343
- e.preventDefault(), K();
393
+ if (!P) return;
394
+ e.preventDefault(), K(w);
344
395
  } else if (t.length !== 0) {
345
396
  if (e.key === "ArrowDown") {
346
- if (e.preventDefault(), !M) {
347
- q();
397
+ if (e.preventDefault(), !P) {
398
+ Ue();
348
399
  return;
349
400
  }
350
- R((e) => {
401
+ z((e) => {
351
402
  let n = t.indexOf(e);
352
403
  return n < t.length - 1 ? t[n + 1] : t[0];
353
404
  });
354
- } else if (e.key === "ArrowUp") e.preventDefault(), R((e) => {
405
+ } else if (e.key === "ArrowUp") e.preventDefault(), z((e) => {
355
406
  let n = t.indexOf(e);
356
407
  return n > 0 ? t[n - 1] : t[t.length - 1];
357
408
  });
358
409
  else if (e.key === "Enter") {
359
- if (e.preventDefault(), I) return;
360
- if (Z && L === $) {
361
- Q();
410
+ if (e.preventDefault(), Fe) return;
411
+ if (Z && R === Q) {
412
+ Xe();
362
413
  return;
363
414
  }
364
- let t = Y[L];
365
- t && !t.disabled ? J(t.value) : Z && Q();
415
+ let t = Y[R];
416
+ t && !t.disabled ? We(t.value) : Z && Xe();
366
417
  }
367
418
  }
368
419
  }, [
369
420
  Y,
370
- L,
371
- J,
421
+ R,
422
+ We,
372
423
  K,
424
+ I,
425
+ N,
426
+ S,
373
427
  P,
374
- j,
375
- b,
376
- M,
377
- q,
428
+ Ue,
378
429
  Z,
430
+ Xe,
379
431
  Q,
380
- $,
381
- I
382
- ]);
383
- a(() => {
384
- if (!M) return;
432
+ Fe,
433
+ w
434
+ ]), Qe = (e) => {
435
+ e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), Ue()) : e.key === "Backspace" && N.length > 0 && (e.preventDefault(), S?.(N.slice(0, -1)));
436
+ }, $e = (e) => {
437
+ if (e.defaultPrevented) return;
438
+ if (e.key === "Escape") {
439
+ e.preventDefault(), K(!0);
440
+ return;
441
+ }
442
+ if (e.key !== "Tab") return;
443
+ let t = Array.from(V.current?.querySelectorAll("input, button:not(:disabled):not([tabindex=\"-1\"])") ?? []);
444
+ e.shiftKey && e.target === t[0] ? (e.preventDefault(), K(!0)) : !e.shiftKey && e.target === t[t.length - 1] && K(!0);
445
+ };
446
+ n(() => {
447
+ if (!P) return;
385
448
  let e = (e) => {
386
449
  let t = e.target;
387
- z.current?.contains(t) || V.current?.contains(t) || K();
450
+ if (Ie.current?.contains(t) || V.current?.contains(t)) return;
451
+ let n = document.activeElement;
452
+ n instanceof HTMLElement && V.current?.contains(n) && n.blur(), K();
388
453
  };
389
454
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
390
- }, [M, K]);
391
- let je = j.map((e) => {
392
- let t = m.find((t) => t.value === e);
393
- if (t) return t;
394
- let n = be?.[e];
395
- return typeof n == "string" ? {
396
- value: e,
397
- label: n
398
- } : {
399
- value: e,
400
- label: e,
401
- content: n
402
- };
403
- }), Me = oe({
404
- loading: ge,
405
- loadingMessage: _e,
455
+ }, [P, K]);
456
+ let $ = N.map((e) => Ke.get(e) ?? g(e, ke)), et = T !== void 0 && $.length > T ? Math.max(0, T) : $.length, tt = $.slice(0, et), nt = $.slice(et), rt = ce({
457
+ loading: Te,
458
+ loadingMessage: Ee,
406
459
  remote: A,
407
- query: P,
408
- minSearchLength: E,
409
- searchPrompt: he,
460
+ query: I,
461
+ minSearchLength: Ce,
462
+ searchPrompt: we,
410
463
  empty: Y.length === 0 && !Z,
411
- noResultsMessage: ve
412
- }), Ne = Me === null;
413
- return /* @__PURE__ */ p("div", {
414
- ref: z,
415
- className: u(e.wrapper, e.searchableWrapper, e[r], s && e.error, y && e.disabled, g?.wrapper, se),
416
- style: _,
417
- ...De,
464
+ noResultsMessage: De
465
+ }), it = rt === null, at = new Set(N), ot = it ? q.filter((e) => !e.disabled && !at.has(e.value)).map((e) => e.value) : [], st = new Set(m.filter((e) => e.disabled).map((e) => e.value)), ct = (e) => w && Ke.has(e.value) ? e.label : e.content ?? e.label, lt = N.filter((e) => !st.has(e)), ut = it ? Z && R === Q ? `${U}-create` : Y[R] ? oe(U, R) : void 0 : void 0, dt = /* @__PURE__ */ f(u, { children: [tt.map((e) => /* @__PURE__ */ f("span", {
466
+ className: c(l.chip, v?.chip),
467
+ children: [/* @__PURE__ */ d("span", {
468
+ className: l.chipLabel,
469
+ children: ct(e)
470
+ }), /* @__PURE__ */ d("button", {
471
+ type: "button",
472
+ className: c(l.chipRemove, v?.chipRemove),
473
+ onClick: (t) => Ge(e.value, t),
474
+ "aria-label": `Remove ${e.label}`,
475
+ tabIndex: -1,
476
+ children: "×"
477
+ })]
478
+ }, e.value)), nt.length > 0 && /* @__PURE__ */ d("span", {
479
+ className: c(l.chip, l.moreChip, v?.chip, v?.moreChip),
480
+ title: nt.map((e) => e.label).join(", "),
481
+ children: E(nt.length)
482
+ })] });
483
+ return /* @__PURE__ */ f("div", {
484
+ ref: Ie,
485
+ className: c(l.wrapper, l.searchableWrapper, l[e], p && l.error, b && l.disabled, v?.wrapper, de),
486
+ style: fe,
487
+ ...Be,
418
488
  children: [
419
- /* @__PURE__ */ p("select", {
420
- ref: G,
421
- className: e.hiddenSelect,
489
+ /* @__PURE__ */ f("select", {
490
+ ref: He,
491
+ className: l.hiddenSelect,
422
492
  multiple: !0,
423
- value: j,
424
- disabled: y,
493
+ value: N,
494
+ disabled: b,
425
495
  tabIndex: -1,
426
496
  "aria-hidden": "true",
427
497
  onChange: () => {},
428
- ...Ee,
429
- children: [m.map((e) => /* @__PURE__ */ f("option", {
498
+ ...ze,
499
+ children: [m.map((e) => /* @__PURE__ */ d("option", {
430
500
  value: e.value,
431
501
  children: e.label
432
- }, e.value)), je.filter((e) => !m.some((t) => t.value === e.value)).map((e) => /* @__PURE__ */ f("option", {
502
+ }, e.value)), $.filter((e) => !Ke.has(e.value)).map((e) => /* @__PURE__ */ d("option", {
433
503
  value: e.value,
434
504
  children: e.label
435
505
  }, e.value))]
436
506
  }),
437
- /* @__PURE__ */ p("div", {
438
- ref: we,
439
- className: u(e.multiTrigger, e[r], M && e.triggerOpen, s && e.error, y && e.multiTriggerDisabled, g?.root),
507
+ w ? /* @__PURE__ */ f("div", {
508
+ ref: H,
509
+ className: c(l.multiTrigger, l.checklistTrigger, l[e], P && l.triggerOpen, p && l.error, b && l.multiTriggerDisabled, v?.root),
440
510
  onClick: () => {
441
- M ? B.current?.focus() : q();
511
+ P ? B.current?.focus() : Ue();
512
+ },
513
+ onMouseDown: P ? (e) => e.preventDefault() : void 0,
514
+ children: [
515
+ dt,
516
+ /* @__PURE__ */ d("button", {
517
+ ref: Re,
518
+ id: pe,
519
+ type: "button",
520
+ role: "combobox",
521
+ className: c(l.checklistButton, N.length === 0 && l.placeholder),
522
+ disabled: b,
523
+ onKeyDown: Qe,
524
+ "aria-expanded": P,
525
+ "aria-haspopup": "listbox",
526
+ "aria-controls": P ? U : void 0,
527
+ "aria-label": G["aria-labelledby"] || pe ? void 0 : _,
528
+ ...G,
529
+ children: N.length === 0 ? _ : /* @__PURE__ */ d("span", {
530
+ className: l.visuallyHidden,
531
+ children: $.map((e) => e.label).join(", ")
532
+ })
533
+ }),
534
+ Te && /* @__PURE__ */ d(te, {
535
+ size: "sm",
536
+ label: "",
537
+ "aria-hidden": "true",
538
+ className: c(l.spinner, v?.spinner)
539
+ }),
540
+ /* @__PURE__ */ d("span", { className: c(l.arrow, l.arrowMulti, v?.arrow) })
541
+ ]
542
+ }) : /* @__PURE__ */ f("div", {
543
+ ref: H,
544
+ className: c(l.multiTrigger, l[e], P && l.triggerOpen, p && l.error, b && l.multiTriggerDisabled, v?.root),
545
+ onClick: () => {
546
+ P ? B.current?.focus() : Ue();
442
547
  },
443
548
  role: "combobox",
444
- "aria-expanded": M,
549
+ "aria-expanded": P,
445
550
  "aria-haspopup": "listbox",
446
- "aria-controls": M ? Te : void 0,
551
+ "aria-controls": P ? U : void 0,
447
552
  children: [
448
- je.map((t) => /* @__PURE__ */ p("span", {
449
- className: u(e.chip, g?.chip),
450
- children: [/* @__PURE__ */ f("span", {
451
- className: e.chipLabel,
452
- children: t.content ?? t.label
453
- }), /* @__PURE__ */ f("button", {
454
- type: "button",
455
- className: u(e.chipRemove, g?.chipRemove),
456
- onClick: (e) => ke(t.value, e),
457
- "aria-label": `Remove ${t.label}`,
458
- tabIndex: -1,
459
- children: "×"
460
- })]
461
- }, t.value)),
462
- /* @__PURE__ */ f("input", {
553
+ dt,
554
+ /* @__PURE__ */ d("input", {
463
555
  ref: B,
464
- id: ce,
556
+ id: pe,
465
557
  type: "text",
466
- className: e.multiSearch,
467
- placeholder: j.length === 0 ? h : "",
468
- value: P,
558
+ className: l.multiSearch,
559
+ placeholder: N.length === 0 ? _ : "",
560
+ value: I,
469
561
  onChange: (e) => {
470
- F(e.target.value), M || N(!0);
562
+ L(e.target.value), P || F(!0);
471
563
  },
472
- onKeyDown: Ae,
473
- disabled: y,
474
- "aria-label": W["aria-labelledby"] ? void 0 : "Search options",
475
- ...W
564
+ onKeyDown: Ze,
565
+ disabled: b,
566
+ "aria-label": G["aria-labelledby"] ? void 0 : "Search options",
567
+ ...G
476
568
  }),
477
- ge && /* @__PURE__ */ f(n, {
569
+ Te && /* @__PURE__ */ d(te, {
478
570
  size: "sm",
479
571
  label: "",
480
572
  "aria-hidden": "true",
481
- className: u(e.spinner, g?.spinner)
573
+ className: c(l.spinner, v?.spinner)
482
574
  }),
483
- /* @__PURE__ */ f("span", { className: u(e.arrow, e.arrowMulti, g?.arrow) })
575
+ /* @__PURE__ */ d("span", { className: c(l.arrow, l.arrowMulti, v?.arrow) })
484
576
  ]
485
577
  }),
486
- M && (() => {
487
- let t = w ? {
578
+ P && (() => {
579
+ let e = ve ? {
488
580
  position: "fixed",
489
- top: U.top + 4,
490
- left: U.left,
581
+ top: W.top + 4,
582
+ left: W.left,
491
583
  right: "auto",
492
- width: U.width,
584
+ width: W.width,
493
585
  zIndex: "var(--crk-z-floating)"
494
- } : void 0, n = /* @__PURE__ */ f("div", {
495
- id: Te,
496
- ref: V,
497
- className: u(e.menu, g?.menu),
498
- style: t,
586
+ } : void 0, t = {
587
+ id: U,
499
588
  role: "listbox",
500
- "aria-multiselectable": "true",
501
- onMouseDown: (e) => e.preventDefault(),
502
- children: /* @__PURE__ */ p("div", {
503
- className: e.menuItems,
504
- ref: H,
589
+ "aria-multiselectable": !0
590
+ }, n = /* @__PURE__ */ f("div", {
591
+ ref: V,
592
+ className: c(l.menu, w && l.menuChecklist, v?.menu),
593
+ style: e,
594
+ ...w ? {} : t,
595
+ onMouseDown: (e) => {
596
+ e.target !== B.current && e.preventDefault();
597
+ },
598
+ onKeyDown: w ? $e : void 0,
599
+ children: [w && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f("div", {
600
+ className: l.menuSearchRow,
601
+ children: [/* @__PURE__ */ d(h, { className: l.menuSearchIcon }), /* @__PURE__ */ d("input", {
602
+ ref: B,
603
+ type: "text",
604
+ className: c(l.menuSearch, v?.search),
605
+ placeholder: x,
606
+ value: I,
607
+ onChange: (e) => L(e.target.value),
608
+ onKeyDown: Ze,
609
+ "aria-label": x,
610
+ "aria-controls": U,
611
+ "aria-autocomplete": "list",
612
+ "aria-activedescendant": ut
613
+ })]
614
+ }), /* @__PURE__ */ f("div", {
615
+ className: c(l.menuHeader, v?.menuHeader),
616
+ children: [/* @__PURE__ */ d("button", {
617
+ type: "button",
618
+ className: c(l.menuAction, v?.menuAction),
619
+ disabled: ot.length === 0,
620
+ onClick: () => {
621
+ S?.([...N, ...ot]), B.current?.focus();
622
+ },
623
+ children: Ae ?? (I ? "Select all matching" : "Select all")
624
+ }), /* @__PURE__ */ d("button", {
625
+ type: "button",
626
+ className: c(l.menuAction, v?.menuAction),
627
+ disabled: lt.length === 0,
628
+ onClick: () => {
629
+ S?.(N.filter((e) => st.has(e))), B.current?.focus();
630
+ },
631
+ children: je
632
+ })]
633
+ })] }), /* @__PURE__ */ f("div", {
634
+ className: l.menuItems,
635
+ ref: Le,
636
+ ...w ? t : {},
505
637
  children: [
506
- Me !== null && /* @__PURE__ */ f("div", {
507
- className: u(e.noResults, g?.message),
638
+ rt !== null && /* @__PURE__ */ d("div", {
639
+ className: c(l.noResults, v?.message),
508
640
  role: "status",
509
- children: Me
641
+ children: rt
510
642
  }),
511
- Ne && Y.map((t, n) => {
512
- let r = j.includes(t.value);
513
- return /* @__PURE__ */ p("button", {
514
- id: `select-option-${t.value}`,
643
+ it && Y.map((e, t) => {
644
+ let n = at.has(e.value);
645
+ return /* @__PURE__ */ d("button", {
646
+ id: oe(U, t),
515
647
  type: "button",
516
648
  role: "option",
517
- "aria-selected": r,
518
- className: u(e.item, t.disabled && e.itemDisabled, r && e.itemSelected, n === L && e.itemHighlighted, g?.item),
519
- disabled: t.disabled,
520
- onClick: () => J(t.value),
521
- onMouseEnter: () => R(n),
522
- children: [r && /* @__PURE__ */ f("span", {
523
- className: e.itemCheck,
649
+ "aria-selected": n,
650
+ className: c(l.item, e.disabled && l.itemDisabled, n && l.itemSelected, t === R && l.itemHighlighted, v?.item),
651
+ disabled: e.disabled,
652
+ tabIndex: w ? -1 : void 0,
653
+ onClick: () => We(e.value),
654
+ onMouseEnter: () => z(t),
655
+ children: w ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("span", {
656
+ className: c(l.checkbox, n && l.checkboxChecked, v?.checkbox),
657
+ "aria-hidden": "true"
658
+ }), /* @__PURE__ */ d("span", {
659
+ className: l.itemBody,
660
+ children: se(e, I, Oe && !A, v?.match)
661
+ })] }) : /* @__PURE__ */ f(u, { children: [n && /* @__PURE__ */ d("span", {
662
+ className: l.itemCheck,
524
663
  "aria-hidden": "true"
525
- }), ae(t, P, ye && !A, g?.match)]
526
- }, t.value);
664
+ }), se(e, I, Oe && !A, v?.match)] })
665
+ }, e.value);
527
666
  }),
528
- Ne && Z && /* @__PURE__ */ f("button", {
667
+ it && Z && /* @__PURE__ */ d("button", {
668
+ id: `${U}-create`,
529
669
  type: "button",
530
670
  role: "option",
531
671
  "aria-selected": !1,
532
- className: u(e.item, L === $ && e.itemHighlighted, g?.item),
533
- onClick: Q,
534
- onMouseEnter: () => R($),
535
- children: de ? de(X) : /* @__PURE__ */ p(d, { children: [
672
+ className: c(l.item, R === Q && l.itemHighlighted, v?.item),
673
+ tabIndex: w ? -1 : void 0,
674
+ onClick: Xe,
675
+ onMouseEnter: () => z(Q),
676
+ children: _e ? _e(X) : /* @__PURE__ */ f(u, { children: [
536
677
  "Create “",
537
- /* @__PURE__ */ f("strong", { children: X }),
678
+ /* @__PURE__ */ d("strong", { children: X }),
538
679
  "”"
539
680
  ] })
540
681
  }, "__create__")
541
682
  ]
542
- })
683
+ })]
543
684
  });
544
- return w && typeof document < "u" ? ee(n, document.body) : n;
685
+ return ve && typeof document < "u" ? s(n, document.body) : n;
545
686
  })()
546
687
  ]
547
688
  });
548
689
  });
549
- g.displayName = "MultiSelect";
550
- var se = r((e, t) => e.multiple ? /* @__PURE__ */ f(g, {
690
+ _.displayName = "MultiSelect";
691
+ var v = e((e, t) => e.multiple ? /* @__PURE__ */ d(_, {
551
692
  ref: t,
552
693
  ...e
553
- }) : e.searchable ? /* @__PURE__ */ f(h, {
694
+ }) : e.searchable ? /* @__PURE__ */ d(m, {
554
695
  ref: t,
555
696
  ...e
556
- }) : /* @__PURE__ */ f(m, {
697
+ }) : /* @__PURE__ */ d(p, {
557
698
  ref: t,
558
699
  ...e
559
700
  }));
560
- se.displayName = "Select";
561
- export { se as Select };
701
+ v.displayName = "Select";
702
+ export { v as Select };