haze-ui 1.27.0 → 1.28.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 (163) hide show
  1. package/dist/components/Calendar/Calendar.js +222 -151
  2. package/dist/components/Cascader/Cascader.js +180 -146
  3. package/dist/components/Chart/Chart.js +12 -9
  4. package/dist/components/Chart/chart-elements.js +118 -42
  5. package/dist/components/CodeBlock/CodeBlock.js +39 -9
  6. package/dist/components/Combobox/Combobox.js +107 -99
  7. package/dist/components/DataTable/DataTable.js +224 -221
  8. package/dist/components/DataTable/csv.js +29 -0
  9. package/dist/components/DataTable/index.js +3 -2
  10. package/dist/components/DateRangePicker/DateRangePicker.js +31 -16
  11. package/dist/components/DateRangePicker/presets.js +43 -0
  12. package/dist/components/Datepicker/Datepicker.js +12 -11
  13. package/dist/components/Datepicker/DatepickerCore.js +72 -51
  14. package/dist/components/Datepicker/datetime.js +23 -0
  15. package/dist/components/Descriptions/Descriptions.js +46 -0
  16. package/dist/components/Descriptions/index.js +3 -0
  17. package/dist/components/DiffViewer/DiffViewer.js +31 -30
  18. package/dist/components/FilePreview/FilePreview.js +135 -0
  19. package/dist/components/FilePreview/file-preview-format.js +23 -0
  20. package/dist/components/FilePreview/index.js +3 -0
  21. package/dist/components/FloatButton/FloatButton.js +42 -0
  22. package/dist/components/FloatButton/FloatButtonGroup.js +58 -0
  23. package/dist/components/FloatButton/float-button-context.js +9 -0
  24. package/dist/components/FloatButton/float-button-glyphs.js +26 -0
  25. package/dist/components/FloatButton/float-button-styles.js +14 -0
  26. package/dist/components/FloatButton/index.js +4 -0
  27. package/dist/components/InlineCompletion/InlineCompletion.js +81 -0
  28. package/dist/components/InlineCompletion/index.js +3 -0
  29. package/dist/components/JsonView/JsonView.js +209 -0
  30. package/dist/components/JsonView/index.js +3 -0
  31. package/dist/components/JsonView/json-view-utils.js +24 -0
  32. package/dist/components/LocaleProvider/index.js +5 -4
  33. package/dist/components/LocaleProvider/ja-jp.js +222 -0
  34. package/dist/components/LocaleProvider/locale.js +42 -4
  35. package/dist/components/LocaleProvider/useStrings.js +13 -11
  36. package/dist/components/LocaleProvider/zh-cn.js +42 -4
  37. package/dist/components/Masonry/Masonry.js +29 -0
  38. package/dist/components/Masonry/index.js +3 -0
  39. package/dist/components/Masonry/masonry-distribute.js +15 -0
  40. package/dist/components/Select/Select.js +14 -13
  41. package/dist/components/Select/SelectCore.js +27 -26
  42. package/dist/components/Select/SelectFloating.js +76 -68
  43. package/dist/components/Signature/Signature.js +165 -0
  44. package/dist/components/Signature/index.js +3 -0
  45. package/dist/components/Signature/signature-points.js +28 -0
  46. package/dist/components/Sources/Sources.js +109 -0
  47. package/dist/components/Sources/index.js +3 -0
  48. package/dist/components/TagGroup/SortableTagGroup.js +26 -0
  49. package/dist/components/TagGroup/TagGroup.js +7 -21
  50. package/dist/components/TagGroup/TagGroupItem.js +1 -1
  51. package/dist/components/TagGroup/index.js +2 -1
  52. package/dist/components/TagGroup/tag-group-styles.js +7 -0
  53. package/dist/components/TagInput/SortableTagInput.js +24 -0
  54. package/dist/components/TagInput/SortableTagInputCore.js +52 -0
  55. package/dist/components/TagInput/TagInput.js +9 -10
  56. package/dist/components/TagInput/TagInputCore.js +61 -84
  57. package/dist/components/TagInput/index.js +3 -1
  58. package/dist/components/TagInput/tag-input-styles.js +7 -0
  59. package/dist/components/Toast/Toast.js +44 -43
  60. package/dist/components/Tree/Tree.js +184 -121
  61. package/dist/components/Tree/TreeItem.js +91 -57
  62. package/dist/components/Tree/utils.js +57 -1
  63. package/dist/components/Upload/Upload.js +12 -9
  64. package/dist/components/Upload/UploadCore.js +130 -124
  65. package/dist/components/Upload/UploadList.js +164 -36
  66. package/dist/css/bottom-sheet.css +1 -1
  67. package/dist/css/cascader.css +1 -1
  68. package/dist/css/datepicker.css +1 -1
  69. package/dist/css/descriptions.css +2 -0
  70. package/dist/css/dialog.css +1 -1
  71. package/dist/css/drawer.css +1 -1
  72. package/dist/css/file-preview.css +2 -0
  73. package/dist/css/float-button.css +2 -0
  74. package/dist/css/inline-completion.css +2 -0
  75. package/dist/css/json-view.css +2 -0
  76. package/dist/css/masonry.css +2 -0
  77. package/dist/css/signature.css +2 -0
  78. package/dist/css/sources.css +2 -0
  79. package/dist/css/tag-group.css +2 -2
  80. package/dist/css/tag-input.css +2 -3
  81. package/dist/css/tree.css +2 -2
  82. package/dist/css/upload.css +1 -1
  83. package/dist/css-manifest.json +15 -0
  84. package/dist/haze-ui.css +20 -13
  85. package/dist/headless/index.js +18 -6
  86. package/dist/hooks/useDarkMode.js +27 -0
  87. package/dist/index.js +207 -192
  88. package/dist/registry.json +210 -34
  89. package/dist/types/components/Cascader/Cascader.d.ts +20 -1
  90. package/dist/types/components/Chart/Chart.d.ts +27 -13
  91. package/dist/types/components/Chart/chart-elements.d.ts +62 -10
  92. package/dist/types/components/Chart/index.d.ts +1 -1
  93. package/dist/types/components/CodeBlock/CodeBlock.d.ts +19 -2
  94. package/dist/types/components/CodeBlock/index.d.ts +1 -1
  95. package/dist/types/components/Combobox/Combobox.d.ts +11 -1
  96. package/dist/types/components/DataTable/DataTable.d.ts +36 -1
  97. package/dist/types/components/DataTable/csv.d.ts +36 -0
  98. package/dist/types/components/DataTable/features.d.ts +6 -0
  99. package/dist/types/components/DataTable/index.d.ts +2 -0
  100. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +15 -3
  101. package/dist/types/components/DateRangePicker/index.d.ts +1 -1
  102. package/dist/types/components/DateRangePicker/presets.d.ts +23 -0
  103. package/dist/types/components/Datepicker/Datepicker.d.ts +5 -1
  104. package/dist/types/components/Datepicker/DatepickerCore.d.ts +6 -1
  105. package/dist/types/components/Datepicker/datetime.d.ts +27 -0
  106. package/dist/types/components/Descriptions/Descriptions.d.ts +30 -0
  107. package/dist/types/components/Descriptions/index.d.ts +2 -0
  108. package/dist/types/components/FilePreview/FilePreview.d.ts +35 -0
  109. package/dist/types/components/FilePreview/file-preview-format.d.ts +20 -0
  110. package/dist/types/components/FilePreview/index.d.ts +2 -0
  111. package/dist/types/components/FloatButton/FloatButton.d.ts +43 -0
  112. package/dist/types/components/FloatButton/FloatButtonGroup.d.ts +33 -0
  113. package/dist/types/components/FloatButton/float-button-context.d.ts +11 -0
  114. package/dist/types/components/FloatButton/float-button-glyphs.d.ts +3 -0
  115. package/dist/types/components/FloatButton/float-button-styles.d.ts +58 -0
  116. package/dist/types/components/FloatButton/index.d.ts +4 -0
  117. package/dist/types/components/InlineCompletion/InlineCompletion.d.ts +29 -0
  118. package/dist/types/components/InlineCompletion/index.d.ts +2 -0
  119. package/dist/types/components/JsonView/JsonView.d.ts +26 -0
  120. package/dist/types/components/JsonView/index.d.ts +2 -0
  121. package/dist/types/components/JsonView/json-view-utils.d.ts +22 -0
  122. package/dist/types/components/LocaleProvider/index.d.ts +1 -0
  123. package/dist/types/components/LocaleProvider/ja-jp.d.ts +13 -0
  124. package/dist/types/components/LocaleProvider/locale.d.ts +44 -0
  125. package/dist/types/components/Masonry/Masonry.d.ts +34 -0
  126. package/dist/types/components/Masonry/index.d.ts +2 -0
  127. package/dist/types/components/Masonry/masonry-distribute.d.ts +16 -0
  128. package/dist/types/components/Select/Select.d.ts +13 -1
  129. package/dist/types/components/Select/SelectCore.d.ts +10 -1
  130. package/dist/types/components/Select/SelectFloating.d.ts +12 -1
  131. package/dist/types/components/Signature/Signature.d.ts +51 -0
  132. package/dist/types/components/Signature/index.d.ts +2 -0
  133. package/dist/types/components/Signature/signature-points.d.ts +31 -0
  134. package/dist/types/components/Sources/Sources.d.ts +37 -0
  135. package/dist/types/components/Sources/index.d.ts +2 -0
  136. package/dist/types/components/TagGroup/SortableTagGroup.d.ts +20 -0
  137. package/dist/types/components/TagGroup/TagGroup.d.ts +4 -13
  138. package/dist/types/components/TagGroup/index.d.ts +2 -0
  139. package/dist/types/components/TagGroup/tag-group-styles.d.ts +7 -0
  140. package/dist/types/components/TagInput/SortableTagInput.d.ts +34 -0
  141. package/dist/types/components/TagInput/SortableTagInputCore.d.ts +18 -0
  142. package/dist/types/components/TagInput/TagInput.d.ts +1 -8
  143. package/dist/types/components/TagInput/TagInputCore.d.ts +4 -10
  144. package/dist/types/components/TagInput/index.d.ts +4 -0
  145. package/dist/types/components/TagInput/tag-input-styles.d.ts +12 -0
  146. package/dist/types/components/Tree/Tree.d.ts +1 -1
  147. package/dist/types/components/Tree/TreeItem.d.ts +11 -1
  148. package/dist/types/components/Tree/types.d.ts +25 -0
  149. package/dist/types/components/Tree/utils.d.ts +41 -0
  150. package/dist/types/components/Upload/Upload.d.ts +10 -1
  151. package/dist/types/components/Upload/UploadCore.d.ts +21 -1
  152. package/dist/types/components/Upload/UploadList.d.ts +8 -2
  153. package/dist/types/headless/index.d.ts +221 -4
  154. package/dist/types/hooks/index.d.ts +2 -0
  155. package/dist/types/hooks/useDarkMode.d.ts +40 -0
  156. package/dist/types/index.d.ts +28 -11
  157. package/dist/types/utils/sortable-handle.d.ts +25 -0
  158. package/dist/types/utils/sortable-shared.d.ts +12 -24
  159. package/dist/utils/sortable-handle.js +12 -0
  160. package/dist/utils/sortable-shared.js +8 -16
  161. package/dist/utils/sortable.js +2 -1
  162. package/dist/utils/submenu.js +7 -5
  163. package/package.json +65 -5
@@ -1,88 +1,164 @@
1
1
  "use client";
2
2
  import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
3
- import { Area as r, AreaChart as i, Bar as a, BarChart as o, CartesianGrid as s, Legend as c, Line as l, LineChart as u, ResponsiveContainer as d, Tooltip as f, XAxis as p, YAxis as m } from "recharts";
3
+ import { Area as r, AreaChart as i, Bar as a, BarChart as o, CartesianGrid as s, Legend as c, Line as l, LineChart as u, Pie as d, PieChart as f, ResponsiveContainer as p, Tooltip as m, XAxis as h, YAxis as g } from "recharts";
4
4
  //#region src/lib/components/Chart/chart-elements.tsx
5
- var h = [
5
+ var _ = [
6
6
  "var(--haze-color-primary)",
7
7
  "var(--haze-color-info)",
8
8
  "var(--haze-color-success)",
9
9
  "var(--haze-color-warning)",
10
10
  "var(--haze-color-danger)"
11
- ], g = "var(--haze-color-border)", _ = {
11
+ ], v = "var(--haze-color-border)", y = {
12
12
  fontSize: "var(--haze-text-sm)",
13
13
  fill: "var(--haze-color-text-secondary)"
14
- }, v = {
14
+ }, b = {
15
15
  fontSize: "var(--haze-text-sm)",
16
16
  color: "var(--haze-color-text)"
17
- }, y = { fontSize: "var(--haze-text-sm)" };
18
- function b(e) {
19
- return e.map((e, t) => ({
17
+ }, x = { fontSize: "var(--haze-text-sm)" };
18
+ function S(e) {
19
+ return _[e % _.length];
20
+ }
21
+ function C(e) {
22
+ return e.map((e) => ({
20
23
  key: e.key,
21
24
  label: e.label ?? e.key,
22
- color: e.color ?? h[t % h.length]
25
+ color: e.color
23
26
  }));
24
27
  }
25
- function x(e, n) {
26
- let { key: i, label: o, color: s } = n;
28
+ function w(e, n, i = 0) {
29
+ let { key: o, label: s } = n, c = n.color ?? S(i);
27
30
  switch (e) {
28
31
  case "area": return /* @__PURE__ */ t(r, {
29
- dataKey: i,
30
- name: o,
31
- stroke: s,
32
- fill: s
33
- }, i);
32
+ dataKey: o,
33
+ name: s,
34
+ stroke: c,
35
+ fill: c
36
+ }, o);
34
37
  case "bar": return /* @__PURE__ */ t(a, {
35
- dataKey: i,
36
- name: o,
37
- fill: s
38
- }, i);
38
+ dataKey: o,
39
+ name: s,
40
+ fill: c
41
+ }, o);
39
42
  case "line": return /* @__PURE__ */ t(l, {
40
- dataKey: i,
41
- name: o,
42
- stroke: s
43
- }, i);
43
+ dataKey: o,
44
+ name: s,
45
+ stroke: c
46
+ }, o);
44
47
  }
45
48
  }
46
- function S(e, n, r) {
49
+ function T(e, t, n) {
50
+ if (t <= 1) return {
51
+ innerRadius: n,
52
+ outerRadius: "80%"
53
+ };
54
+ let r = typeof n == "string" ? Number.parseFloat(n) : 0, i = Number.isFinite(r) ? Math.max(r, 0) : 0, a = (80 - i) / t;
55
+ return {
56
+ innerRadius: `${i + e * a}%`,
57
+ outerRadius: `${i + (e + 1) * a}%`
58
+ };
59
+ }
60
+ function E(e) {
61
+ let { entry: n, data: r, nameKey: i, ringIndex: a, ringCount: o, innerRadius: s } = e, c = T(a, o, s), l = r.map((e, t) => ({
62
+ ...e,
63
+ fill: n.color ?? S(t)
64
+ }));
65
+ return /* @__PURE__ */ t(d, {
66
+ data: l,
67
+ dataKey: n.key,
68
+ nameKey: i,
69
+ innerRadius: c.innerRadius,
70
+ outerRadius: c.outerRadius,
71
+ stroke: "var(--haze-color-bg)"
72
+ }, n.key);
73
+ }
74
+ function D(e, n, r, a = "horizontal") {
47
75
  switch (e) {
48
76
  case "area": return /* @__PURE__ */ t(i, {
49
77
  data: n,
78
+ layout: a,
50
79
  children: r
51
80
  });
52
81
  case "bar": return /* @__PURE__ */ t(o, {
53
82
  data: n,
83
+ layout: a,
54
84
  children: r
55
85
  });
56
86
  case "line": return /* @__PURE__ */ t(u, {
87
+ data: n,
88
+ layout: a,
89
+ children: r
90
+ });
91
+ case "pie": return /* @__PURE__ */ t(f, {
57
92
  data: n,
58
93
  children: r
59
94
  });
60
95
  }
61
96
  }
62
- function C(r) {
63
- let { type: i, data: a, xKey: o, showGrid: l, showTooltip: u, showLegend: h, series: b } = r;
64
- return /* @__PURE__ */ t(d, {
97
+ function O(e) {
98
+ return (t) => {
99
+ let { payload: n, label: r } = t;
100
+ return e({
101
+ label: r,
102
+ entries: (n ?? []).map((e) => ({
103
+ name: String(e.name ?? e.dataKey ?? ""),
104
+ value: e.value ?? "",
105
+ color: e.color ?? "",
106
+ dataEntry: e.payload
107
+ }))
108
+ });
109
+ };
110
+ }
111
+ function k(r) {
112
+ let { type: i, data: a, xKey: o, showGrid: l, showTooltip: u, showLegend: d, series: f, layout: _ = "horizontal", innerRadius: S = 0, renderTooltip: C } = r, T = C ? O(C) : void 0;
113
+ return i === "pie" ? /* @__PURE__ */ t(p, {
114
+ width: "100%",
115
+ height: "100%",
116
+ children: D(i, a, /* @__PURE__ */ n(e, { children: [
117
+ u && /* @__PURE__ */ t(m, {
118
+ contentStyle: b,
119
+ content: T
120
+ }),
121
+ d && /* @__PURE__ */ t(c, { wrapperStyle: x }),
122
+ f.map((e, t) => E({
123
+ entry: e,
124
+ data: a,
125
+ nameKey: o,
126
+ ringIndex: t,
127
+ ringCount: f.length,
128
+ innerRadius: S
129
+ }))
130
+ ] }))
131
+ }) : /* @__PURE__ */ t(p, {
65
132
  width: "100%",
66
133
  height: "100%",
67
- children: S(i, a, /* @__PURE__ */ n(e, { children: [
134
+ children: D(i, a, /* @__PURE__ */ n(e, { children: [
68
135
  l && /* @__PURE__ */ t(s, { stroke: "var(--haze-color-border)" }),
69
- /* @__PURE__ */ t(p, {
136
+ _ === "vertical" ? /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(h, {
137
+ type: "number",
138
+ stroke: v,
139
+ tick: y
140
+ }), /* @__PURE__ */ t(g, {
141
+ type: "category",
70
142
  dataKey: o,
71
- stroke: g,
72
- tick: _
73
- }),
74
- /* @__PURE__ */ t(m, {
75
- stroke: g,
76
- tick: _
77
- }),
78
- u && /* @__PURE__ */ t(f, {
143
+ stroke: v,
144
+ tick: y
145
+ })] }) : /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(h, {
146
+ dataKey: o,
147
+ stroke: v,
148
+ tick: y
149
+ }), /* @__PURE__ */ t(g, {
150
+ stroke: v,
151
+ tick: y
152
+ })] }),
153
+ u && /* @__PURE__ */ t(m, {
79
154
  cursor: { stroke: "var(--haze-color-border)" },
80
- contentStyle: v
155
+ contentStyle: b,
156
+ content: T
81
157
  }),
82
- h && /* @__PURE__ */ t(c, { wrapperStyle: y }),
83
- b.map((e) => x(i, e))
84
- ] }))
158
+ d && /* @__PURE__ */ t(c, { wrapperStyle: x }),
159
+ f.map((e, t) => w(i, e, t))
160
+ ] }), _)
85
161
  });
86
162
  }
87
163
  //#endregion
88
- export { g as AXIS_STROKE, _ as AXIS_TICK, y as LEGEND_STYLE, v as TOOLTIP_STYLE, S as chartElement, C as chartTree, b as resolveChartSeries, x as seriesElement };
164
+ export { v as AXIS_STROKE, y as AXIS_TICK, x as LEGEND_STYLE, b as TOOLTIP_STYLE, O as buildTooltipContent, D as chartElement, k as chartTree, E as pieElement, T as pieRingRadii, C as resolveChartSeries, w as seriesElement };
@@ -2,19 +2,49 @@
2
2
  import { classnames as e } from "../../utils/classnames.js";
3
3
  /* empty css */
4
4
  import { jsx as t, jsxs as n } from "react/jsx-runtime";
5
+ import { useEffect as r, useMemo as i, useState as a } from "react";
5
6
  //#region src/lib/components/CodeBlock/CodeBlock.tsx
6
- var r = "haze-CodeBlock__block", i = "haze-CodeBlock__pre", a = "haze-CodeBlock__lang";
7
- function o({ children: o, language: s, className: c }) {
7
+ var o = "haze-CodeBlock__block", s = "haze-CodeBlock__pre", c = "haze-CodeBlock__lang";
8
+ function l({ children: l, language: u, highlight: d, className: f }) {
9
+ let p = typeof l == "string" ? l : void 0, m = i(() => {
10
+ if (d !== void 0 && p !== void 0) try {
11
+ return d(p, u ?? "");
12
+ } catch {
13
+ return;
14
+ }
15
+ }, [
16
+ d,
17
+ p,
18
+ u
19
+ ]), h = m instanceof Promise ? m : void 0, [g, _] = a(null);
20
+ r(() => {
21
+ if (h === void 0) return;
22
+ let e = !0;
23
+ return h.then((t) => {
24
+ e && _({
25
+ pending: h,
26
+ html: t
27
+ });
28
+ }, () => {
29
+ e && _({
30
+ pending: h,
31
+ html: null
32
+ });
33
+ }), () => {
34
+ e = !1;
35
+ };
36
+ }, [h]);
37
+ let v = typeof m == "string" ? m : g !== null && g.pending === h ? g.html : null;
8
38
  return /* @__PURE__ */ n("div", {
9
- className: e([r, c]),
10
- children: [s && /* @__PURE__ */ t("span", {
11
- className: e([a]),
12
- children: s
39
+ className: e([o, f]),
40
+ children: [u && /* @__PURE__ */ t("span", {
41
+ className: e([c]),
42
+ children: u
13
43
  }), /* @__PURE__ */ t("pre", {
14
- className: e([i]),
15
- children: /* @__PURE__ */ t("code", { children: o })
44
+ className: e([s]),
45
+ children: v === null ? /* @__PURE__ */ t("code", { children: l }) : /* @__PURE__ */ t("code", { dangerouslySetInnerHTML: { __html: v } })
16
46
  })]
17
47
  });
18
48
  }
19
49
  //#endregion
20
- export { o as default };
50
+ export { l as default };
@@ -9,47 +9,47 @@ import ne from "../Chip/Chip.js";
9
9
  import re from "../Spinner/Spinner.js";
10
10
  import ie from "../VirtualList/VirtualList.js";
11
11
  import ae from "./ComboboxGroup.js";
12
- import i from "./ComboboxOption.js";
12
+ import oe from "./ComboboxOption.js";
13
13
  /* empty css */
14
- import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
15
- import { useCallback as oe, useEffect as se, useId as ce, useMemo as le, useRef as c, useState as l } from "react";
14
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
15
+ import { useCallback as se, useEffect as s, useId as ce, useMemo as le, useRef as c, useState as l } from "react";
16
16
  import { useControl as u } from "react-use-control";
17
17
  //#region src/lib/components/Combobox/Combobox.tsx
18
18
  var ue = "haze-Combobox__wrapper", de = "haze-Combobox__input", fe = "haze-Combobox__multiBox", pe = "haze-Combobox__multiInput", d = "haze-Combobox__matchMark", f = "haze-Combobox__stateRow", me = "haze-Combobox__groupHeadingText", he = "haze-Combobox__listbox", ge = "haze-Combobox__listboxVirtual", _e = 200, ve = 37, ye = "haze-Combobox__virtualRow";
19
19
  function be(t, n) {
20
20
  if (n === "") return t;
21
21
  let r = t.toLowerCase().indexOf(n.toLowerCase());
22
- return r < 0 ? t : /* @__PURE__ */ s(a, { children: [
22
+ return r < 0 ? t : /* @__PURE__ */ o(i, { children: [
23
23
  t.slice(0, r),
24
- /* @__PURE__ */ o("mark", {
24
+ /* @__PURE__ */ a("mark", {
25
25
  className: e([d]),
26
26
  children: t.slice(r, r + n.length)
27
27
  }),
28
28
  t.slice(r + n.length)
29
29
  ] });
30
30
  }
31
- function p({ value: a, open: d, options: p, multiple: m = !1, onValuesChange: h, creatable: xe = !1, onCreate: Se, loading: g = !1, empty: Ce, highlightMatches: we = !1, maxHeight: _, placeholder: Te, virtualThreshold: v = 100, virtualized: y, className: Ee, ref: b }) {
32
- let x = r("combobox"), [S, C] = u(a, m ? [] : ""), [w, De] = l([]), [T, E] = l(""), [D, O] = u(d, !1), [k, A] = l(-1), [Oe, ke] = l(T), j = ce(), M = c(null), Ae = oe((e) => t(M, b)(e), [M, b]), N = c(null), P = c(null), F = c(null), I = c(null), L = te({
33
- open: D,
34
- setOpen: O,
35
- triggerRef: m ? N : M,
36
- panelRef: P,
31
+ function p({ value: i, open: d, options: p, multiple: m = !1, onValuesChange: h, creatable: xe = !1, onCreate: Se, onSearch: g, loading: _ = !1, empty: Ce, highlightMatches: we = !1, maxHeight: v, placeholder: Te, virtualThreshold: y = 100, virtualized: b, className: Ee, ref: x }) {
32
+ let S = r("combobox"), [C, w] = u(i, m ? [] : ""), [T, De] = l([]), [E, D] = l(""), [O, k] = u(d, !1), [A, j] = l(-1), [Oe, ke] = l(E), M = ce(), N = c(null), Ae = se((e) => t(N, x)(e), [N, x]), P = c(null), F = c(null), I = c(null), L = c(null), R = te({
33
+ open: O,
34
+ setOpen: k,
35
+ triggerRef: m ? P : N,
36
+ panelRef: F,
37
37
  animated: !0
38
- }), R = Array.isArray(S) ? S : [], z = le(() => {
39
- if (w.length === 0) return p;
40
- let e = new Set(p.map((e) => e.value)), t = w.filter((t) => !e.has(t)).map((e) => ({
38
+ }), z = Array.isArray(C) ? C : [], B = le(() => {
39
+ if (T.length === 0) return p;
40
+ let e = new Set(p.map((e) => e.value)), t = T.filter((t) => !e.has(t)).map((e) => ({
41
41
  value: e,
42
42
  label: e
43
43
  }));
44
44
  return t.length > 0 ? [...p, ...t] : p;
45
- }, [p, w]), B = z.filter((e) => e.label.toLowerCase().includes(T.toLowerCase())), V = xe && !g && T.trim() !== "" && B.length === 0, H = T.trim(), je = n(x.create, { query: H }), U = V ? [{
46
- value: H,
47
- label: H
48
- }, ...B] : B, W = typeof y == "object" ? y : void 0, G = (y === void 0 ? void 0 : !!y) ?? (v > 0 && U.length > v), K = W?.itemHeight ?? ve, Me = W?.overscan, q = (e) => `${j}-option-${e}`, Ne = D && U[k] ? q(k) : void 0, J = [];
49
- for (let e = 0; e < U.length; e++) {
50
- let t = U[e];
45
+ }, [p, T]), V = g ? B : B.filter((e) => e.label.toLowerCase().includes(E.toLowerCase())), H = xe && !_ && E.trim() !== "" && V.length === 0, U = E.trim(), je = n(S.create, { query: U }), W = H ? [{
46
+ value: U,
47
+ label: U
48
+ }, ...V] : V, G = typeof b == "object" ? b : void 0, K = (b === void 0 ? void 0 : !!b) ?? (y > 0 && W.length > y), q = G?.itemHeight ?? ve, Me = G?.overscan, J = (e) => `${M}-option-${e}`, Ne = O && W[A] ? J(A) : void 0, Y = [];
49
+ for (let e = 0; e < W.length; e++) {
50
+ let t = W[e];
51
51
  if (t === void 0) continue;
52
- let n = J[J.length - 1];
52
+ let n = Y[Y.length - 1];
53
53
  if (t.group !== void 0 && n?.label === t.group) {
54
54
  n.rows.push({
55
55
  option: t,
@@ -57,7 +57,7 @@ function p({ value: a, open: d, options: p, multiple: m = !1, onValuesChange: h,
57
57
  });
58
58
  continue;
59
59
  }
60
- J.push(t.group === void 0 ? {
60
+ Y.push(t.group === void 0 ? {
61
61
  key: `row-${t.value}`,
62
62
  label: void 0,
63
63
  rows: [{
@@ -73,134 +73,142 @@ function p({ value: a, open: d, options: p, multiple: m = !1, onValuesChange: h,
73
73
  }]
74
74
  });
75
75
  }
76
- let Pe = J.some((e) => e.label !== void 0);
77
- se(() => {
78
- if (!L.shown || k < 0) return;
79
- if (G) {
80
- F.current?.scrollToIndex(k, "auto");
76
+ let Pe = Y.some((e) => e.label !== void 0);
77
+ s(() => {
78
+ if (!R.shown || A < 0) return;
79
+ if (K) {
80
+ I.current?.scrollToIndex(A, "auto");
81
81
  return;
82
82
  }
83
- let e = I.current;
83
+ let e = L.current;
84
84
  e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
85
85
  }, [
86
- G,
87
- L.shown,
88
- k
89
- ]), T !== Oe && (ke(T), A(-1));
90
- let Y = (e) => m ? R.includes(e) : S === e, Fe = (e) => z.find((t) => t.value === e)?.label ?? e, X = (e, t) => {
91
- let n = t ?? z.find((t) => t.value === e)?.label ?? e;
86
+ K,
87
+ R.shown,
88
+ A
89
+ ]);
90
+ let X = c(g);
91
+ s(() => {
92
+ X.current = g;
93
+ }, [g]);
94
+ let Z = c(E);
95
+ s(() => {
96
+ Z.current !== E && (Z.current = E, X.current?.(E));
97
+ }, [E]), E !== Oe && (ke(E), j(-1));
98
+ let Fe = (e) => m ? z.includes(e) : C === e, Ie = (e) => B.find((t) => t.value === e)?.label ?? e, Le = (e, t) => {
99
+ let n = t ?? B.find((t) => t.value === e)?.label ?? e;
92
100
  if (m) {
93
- let t = R.includes(e) ? R.filter((t) => t !== e) : [...R, e];
94
- C(t), h?.(t), E("");
95
- } else C(e), h?.(e), E(n), O(!1);
96
- M.current?.focus();
97
- }, Ie = () => {
98
- Se?.(H), De((e) => e.includes(H) ? e : [...e, H]), X(H, H);
99
- }, Z = (e) => {
100
- if (V && e === H) {
101
- Ie();
101
+ let t = z.includes(e) ? z.filter((t) => t !== e) : [...z, e];
102
+ w(t), h?.(t), D("");
103
+ } else w(e), h?.(e), D(n), k(!1);
104
+ N.current?.focus();
105
+ }, Re = () => {
106
+ Se?.(U), De((e) => e.includes(U) ? e : [...e, U]), Le(U, U);
107
+ }, ze = (e) => {
108
+ if (H && e === U) {
109
+ Re();
102
110
  return;
103
111
  }
104
- X(e);
105
- }, Le = (e) => {
106
- if (e.key === "ArrowDown") e.preventDefault(), O(!0), A((e) => Math.min(e + 1, U.length - 1));
107
- else if (e.key === "ArrowUp") e.preventDefault(), O(!0), A((e) => Math.max(e - 1, 0));
108
- else if (e.key === "Enter" && k >= 0 && U[k]) e.preventDefault(), Z(U[k].value);
109
- else if (e.key === "Escape") O(!1);
110
- else if (e.key === "Backspace" && m && T === "" && R.length > 0) {
112
+ Le(e);
113
+ }, Be = (e) => {
114
+ if (e.key === "ArrowDown") e.preventDefault(), k(!0), j((e) => Math.min(e + 1, W.length - 1));
115
+ else if (e.key === "ArrowUp") e.preventDefault(), k(!0), j((e) => Math.max(e - 1, 0));
116
+ else if (e.key === "Enter" && A >= 0 && W[A]) e.preventDefault(), ze(W[A].value);
117
+ else if (e.key === "Escape") k(!1);
118
+ else if (e.key === "Backspace" && m && E === "" && z.length > 0) {
111
119
  e.preventDefault();
112
- let t = R.slice(0, -1);
113
- C(t), h?.(t);
120
+ let t = z.slice(0, -1);
121
+ w(t), h?.(t);
114
122
  }
115
- }, Q = (e, t, n) => /* @__PURE__ */ o(i, {
116
- ref: !n && t === k ? I : void 0,
123
+ }, Q = (e, t, n) => /* @__PURE__ */ a(oe, {
124
+ ref: !n && t === A ? L : void 0,
117
125
  value: e.value,
118
- id: q(t),
119
- setSize: U.length,
126
+ id: J(t),
127
+ setSize: W.length,
120
128
  posInSet: t + 1,
121
- highlighted: t === k,
122
- selected: Y(e.value),
123
- onSelect: Z,
129
+ highlighted: t === A,
130
+ selected: Fe(e.value),
131
+ onSelect: ze,
124
132
  className: n ? ye : void 0,
125
- children: V && t === 0 ? je : we ? be(e.label, T) : e.label
126
- }, e.value), $ = /* @__PURE__ */ o("input", {
133
+ children: H && t === 0 ? je : we ? be(e.label, E) : e.label
134
+ }, e.value), $ = /* @__PURE__ */ a("input", {
127
135
  ref: Ae,
128
136
  role: "combobox",
129
- style: m ? void 0 : L.triggerStyle,
130
- "aria-expanded": D,
131
- "aria-controls": j,
137
+ style: m ? void 0 : R.triggerStyle,
138
+ "aria-expanded": O,
139
+ "aria-controls": M,
132
140
  "aria-autocomplete": "list",
133
141
  "aria-activedescendant": Ne,
134
- "aria-busy": g || void 0,
142
+ "aria-busy": _ || void 0,
135
143
  className: m ? pe : de,
136
- value: T,
144
+ value: E,
137
145
  placeholder: Te,
138
146
  onChange: (e) => {
139
- E(e.target.value), O(!0);
147
+ D(e.target.value), k(!0);
140
148
  },
141
- onPointerDown: m ? void 0 : L.onTriggerPointerDown,
142
- onClick: m ? void 0 : L.onTriggerClick,
143
- onKeyDown: Le
149
+ onPointerDown: m ? void 0 : R.onTriggerPointerDown,
150
+ onClick: m ? void 0 : R.onTriggerClick,
151
+ onKeyDown: Be
144
152
  });
145
- return /* @__PURE__ */ s("div", {
153
+ return /* @__PURE__ */ o("div", {
146
154
  className: e([ue, Ee]),
147
- children: [m ? /* @__PURE__ */ s("div", {
148
- ref: N,
149
- style: L.triggerStyle,
150
- onPointerDown: L.onTriggerPointerDown,
155
+ children: [m ? /* @__PURE__ */ o("div", {
156
+ ref: P,
157
+ style: R.triggerStyle,
158
+ onPointerDown: R.onTriggerPointerDown,
151
159
  onClick: () => {
152
- L.onTriggerClick(), M.current?.focus();
160
+ R.onTriggerClick(), N.current?.focus();
153
161
  },
154
162
  className: e(fe),
155
- children: [R.map((e) => /* @__PURE__ */ o("span", {
163
+ children: [z.map((e) => /* @__PURE__ */ a("span", {
156
164
  onClick: (e) => e.stopPropagation(),
157
- children: /* @__PURE__ */ o(ne, {
165
+ children: /* @__PURE__ */ a(ne, {
158
166
  color: "primary",
159
167
  onClose: () => {
160
- let t = R.filter((t) => t !== e);
161
- C(t), h?.(t);
168
+ let t = z.filter((t) => t !== e);
169
+ w(t), h?.(t);
162
170
  },
163
- children: Fe(e)
171
+ children: Ie(e)
164
172
  })
165
173
  }, e)), $]
166
- }) : $, /* @__PURE__ */ o(ee, {
167
- ref: P,
168
- behavior: L,
174
+ }) : $, /* @__PURE__ */ a(ee, {
175
+ ref: F,
176
+ behavior: R,
169
177
  placement: "bottom-span",
170
- id: j,
178
+ id: M,
171
179
  role: "listbox",
172
180
  "aria-multiselectable": m ? "true" : void 0,
173
- visualClass: G ? ge : he,
174
- style: _ !== void 0 && !G ? { maxHeight: `${_}px` } : void 0,
175
- children: g ? /* @__PURE__ */ o("div", {
181
+ visualClass: K ? ge : he,
182
+ style: v !== void 0 && !K ? { maxHeight: `${v}px` } : void 0,
183
+ children: _ ? /* @__PURE__ */ a("div", {
176
184
  role: "option",
177
185
  "aria-selected": !1,
178
186
  "aria-disabled": "true",
179
187
  className: e([f]),
180
- children: /* @__PURE__ */ o(re, { size: "sm" })
181
- }) : U.length === 0 ? /* @__PURE__ */ o("div", {
188
+ children: /* @__PURE__ */ a(re, { size: "sm" })
189
+ }) : W.length === 0 ? /* @__PURE__ */ a("div", {
182
190
  role: "option",
183
191
  "aria-selected": !1,
184
192
  "aria-disabled": "true",
185
193
  className: e([f]),
186
- children: Ce ?? x.noResults
187
- }) : G ? /* @__PURE__ */ o(ie, {
188
- ref: F,
194
+ children: Ce ?? S.noResults
195
+ }) : K ? /* @__PURE__ */ a(ie, {
196
+ ref: I,
189
197
  "data-virtualized": !0,
190
- items: U,
191
- height: Math.min(_ ?? _e, U.length * K),
192
- itemHeight: K,
198
+ items: W,
199
+ height: Math.min(v ?? _e, W.length * q),
200
+ itemHeight: q,
193
201
  overscan: Me,
194
- groups: Pe ? J.filter((e) => e.label !== void 0).map((t) => ({
202
+ groups: Pe ? Y.filter((e) => e.label !== void 0).map((t) => ({
195
203
  startIndex: t.rows[0]?.index ?? 0,
196
204
  key: t.key,
197
- render: () => /* @__PURE__ */ o("div", {
205
+ render: () => /* @__PURE__ */ a("div", {
198
206
  className: e([me]),
199
207
  children: t.label
200
208
  })
201
209
  })) : void 0,
202
210
  renderItem: (e, t) => Q(e, t, !0)
203
- }) : J.flatMap((e) => e.label === void 0 ? e.rows.map(({ option: e, index: t }) => Q(e, t, !1)) : [/* @__PURE__ */ o(ae, {
211
+ }) : Y.flatMap((e) => e.label === void 0 ? e.rows.map(({ option: e, index: t }) => Q(e, t, !1)) : [/* @__PURE__ */ a(ae, {
204
212
  label: e.label,
205
213
  children: e.rows.map(({ option: e, index: t }) => Q(e, t, !1))
206
214
  }, e.key)])