@box-kite/react 1.0.0 → 2.0.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 (179) hide show
  1. package/.claude/rules/box-kite-rules.md +23 -1
  2. package/.claude/skills/box-kite/SKILL.md +134 -427
  3. package/.claude/skills/box-kite/references/components.md +235 -0
  4. package/.claude/skills/box-kite/references/extending.md +42 -0
  5. package/.claude/skills/box-kite/references/patterns.md +27 -0
  6. package/.claude/skills/box-kite/references/styling.md +222 -0
  7. package/.cursor/rules/box-kite.mdc +73 -0
  8. package/AGENTS.md +102 -0
  9. package/BOX_AI_CONTEXT.md +1124 -153
  10. package/BOX_KITE_AI_CONTEXT.md +1124 -153
  11. package/README.md +36 -2
  12. package/a11y.cjs +1 -1
  13. package/a11y.d.ts +1 -1
  14. package/a11y.mjs +3 -2
  15. package/anchor.cjs +1 -0
  16. package/anchor.d.ts +14 -0
  17. package/anchor.mjs +3 -0
  18. package/behavior.cjs +1 -1
  19. package/behavior.mjs +118 -136
  20. package/box.cjs +1 -1
  21. package/box.mjs +1 -1
  22. package/client.cjs +1 -1
  23. package/client.mjs +15 -14
  24. package/components/accordion.cjs +1 -0
  25. package/components/accordion.d.ts +114 -0
  26. package/components/accordion.mjs +251 -0
  27. package/components/button.cjs +1 -1
  28. package/components/button.d.ts +3 -0
  29. package/components/button.mjs +1 -1
  30. package/components/chart.cjs +1 -1
  31. package/components/chart.d.ts +2 -1
  32. package/components/chart.mjs +159 -184
  33. package/components/checkbox.cjs +1 -1
  34. package/components/checkbox.d.ts +8 -0
  35. package/components/checkbox.mjs +1 -1
  36. package/components/combobox/comboboxChips.d.ts +21 -0
  37. package/components/combobox/comboboxListbox.d.ts +47 -0
  38. package/components/combobox.cjs +1 -0
  39. package/components/combobox.d.ts +121 -0
  40. package/components/combobox.mjs +563 -0
  41. package/components/dataGrid/components/dataGridAggregateValue.d.ts +10 -0
  42. package/components/dataGrid/components/dataGridCell.d.ts +2 -1
  43. package/components/dataGrid/components/dataGridCellEditor.d.ts +15 -0
  44. package/components/dataGrid/components/dataGridCellPlaceholder.d.ts +14 -0
  45. package/components/dataGrid/components/dataGridCellTree.d.ts +16 -0
  46. package/components/dataGrid/components/dataGridDataSourceError.d.ts +12 -0
  47. package/components/dataGrid/components/dataGridExport.d.ts +10 -0
  48. package/components/dataGrid/components/dataGridFooter.d.ts +11 -0
  49. package/components/dataGrid/contracts/dataGridContract.d.ts +474 -16
  50. package/components/dataGrid/export/gridExport.d.ts +10 -0
  51. package/components/dataGrid/gridNavigationContext.d.ts +9 -1
  52. package/components/dataGrid/models/aggregateCellModel.d.ts +34 -0
  53. package/components/dataGrid/models/aggregationModel.d.ts +32 -0
  54. package/components/dataGrid/models/cellKeys.d.ts +11 -0
  55. package/components/dataGrid/models/cellModel.d.ts +27 -1
  56. package/components/dataGrid/models/columnModel.d.ts +12 -2
  57. package/components/dataGrid/models/dataSourceModel.d.ts +177 -0
  58. package/components/dataGrid/models/editModel.d.ts +77 -0
  59. package/components/dataGrid/models/exportModel.d.ts +51 -0
  60. package/components/dataGrid/models/gridModel.d.ts +108 -21
  61. package/components/dataGrid/models/groupRowCellModel.d.ts +11 -3
  62. package/components/dataGrid/models/groupRowModel.d.ts +22 -2
  63. package/components/dataGrid/models/rowModel.d.ts +13 -1
  64. package/components/dataGrid/models/sourceGroupRowModel.d.ts +45 -0
  65. package/components/dataGrid/models/sourceLevel.d.ts +71 -0
  66. package/components/dataGrid/models/sourceRowModel.d.ts +29 -0
  67. package/components/dataGrid/models/sourceTreeRowModel.d.ts +23 -0
  68. package/components/dataGrid/models/treeModel.d.ts +94 -0
  69. package/components/dataGrid/models/treeRow.d.ts +22 -0
  70. package/components/dataGrid/models/treeRowModel.d.ts +50 -0
  71. package/components/dataGrid.cjs +1 -1
  72. package/components/dataGrid.d.ts +4 -2
  73. package/components/dataGrid.mjs +4484 -2755
  74. package/components/dialog.cjs +1 -0
  75. package/components/dialog.d.ts +151 -0
  76. package/components/dialog.mjs +223 -0
  77. package/components/dropdown.cjs +1 -1
  78. package/components/dropdown.d.ts +30 -0
  79. package/components/dropdown.mjs +256 -244
  80. package/components/icon.cjs +1 -1
  81. package/components/icon.d.ts +2 -1
  82. package/components/icon.mjs +3 -3
  83. package/components/menu.cjs +1 -0
  84. package/components/menu.d.ts +234 -0
  85. package/components/menu.mjs +422 -0
  86. package/components/overlay.cjs +1 -1
  87. package/components/overlay.d.ts +30 -26
  88. package/components/overlay.mjs +45 -75
  89. package/components/popover.cjs +1 -0
  90. package/components/popover.d.ts +100 -0
  91. package/components/popover.mjs +69 -0
  92. package/components/presence.d.ts +6 -0
  93. package/components/progress.cjs +1 -0
  94. package/components/progress.d.ts +47 -0
  95. package/components/progress.mjs +28 -0
  96. package/components/radioButton.cjs +1 -1
  97. package/components/radioButton.d.ts +8 -0
  98. package/components/radioButton.mjs +1 -1
  99. package/components/radioGroup.cjs +1 -1
  100. package/components/radioGroup.d.ts +15 -2
  101. package/components/radioGroup.mjs +34 -30
  102. package/components/select.d.ts +9 -0
  103. package/components/semantics.cjs +1 -1
  104. package/components/semantics.d.ts +33 -28
  105. package/components/semantics.mjs +3 -3
  106. package/components/slider.cjs +1 -0
  107. package/components/slider.d.ts +98 -0
  108. package/components/slider.mjs +250 -0
  109. package/components/svg.cjs +1 -1
  110. package/components/svg.d.ts +25 -23
  111. package/components/svg.mjs +3 -3
  112. package/components/switch.cjs +1 -1
  113. package/components/switch.d.ts +9 -0
  114. package/components/switch.mjs +1 -1
  115. package/components/tabs.cjs +1 -0
  116. package/components/tabs.d.ts +87 -0
  117. package/components/tabs.mjs +324 -0
  118. package/components/textarea.cjs +1 -1
  119. package/components/textarea.d.ts +14 -0
  120. package/components/textarea.mjs +1 -1
  121. package/components/textbox.cjs +1 -1
  122. package/components/textbox.d.ts +12 -0
  123. package/components/textbox.mjs +1 -1
  124. package/components/toaster.cjs +1 -0
  125. package/components/toaster.d.ts +106 -0
  126. package/components/toaster.mjs +295 -0
  127. package/components/tooltip.cjs +1 -1
  128. package/components/tooltip.d.ts +39 -4
  129. package/components/tooltip.mjs +56 -54
  130. package/docs/a11y.md +199 -0
  131. package/docs/anchor.md +139 -0
  132. package/docs/components.md +48 -0
  133. package/docs/index.md +11 -0
  134. package/docs/props.md +1777 -0
  135. package/effects.cjs +1 -1
  136. package/effects.mjs +1 -1
  137. package/gridExport.cjs +2 -0
  138. package/gridExport.mjs +244 -0
  139. package/identity.cjs +1 -0
  140. package/identity.mjs +12 -0
  141. package/keyboard.cjs +1 -0
  142. package/keyboard.mjs +30 -0
  143. package/layer.cjs +1 -0
  144. package/layer.mjs +127 -0
  145. package/motion.cjs +1 -1
  146. package/motion.mjs +1 -1
  147. package/package.json +134 -10
  148. package/placement.cjs +1 -0
  149. package/placement.mjs +180 -0
  150. package/platform.cjs +1 -1
  151. package/platform.mjs +18 -5
  152. package/react/anchor/useAnchorPosition.d.ts +79 -0
  153. package/react/dialog/useScrollLock.d.ts +12 -0
  154. package/react/hooks/usePortalContainer.d.ts +6 -1
  155. package/react/hooks/useVirtualization.d.ts +24 -35
  156. package/react/popover/usePopoverLayer.d.ts +87 -0
  157. package/react-shared.cjs +1 -1
  158. package/react-shared.mjs +19 -2
  159. package/rsc.cjs +1 -1
  160. package/rsc.mjs +1 -1
  161. package/utils/accordion/accordionUtils.d.ts +48 -0
  162. package/utils/anchor/anchorUtils.d.ts +79 -0
  163. package/utils/array/lazyList.d.ts +10 -0
  164. package/utils/chart/chartPalette.d.ts +15 -0
  165. package/utils/chart/chartUtils.d.ts +2 -8
  166. package/utils/combobox/comboboxUtils.d.ts +89 -0
  167. package/utils/dom/domUtils.d.ts +6 -0
  168. package/utils/environment/environmentUtils.d.ts +10 -0
  169. package/utils/export/csvUtils.d.ts +23 -0
  170. package/utils/export/downloadUtils.d.ts +12 -0
  171. package/utils/export/xlsxUtils.d.ts +56 -0
  172. package/utils/export/zipUtils.d.ts +26 -0
  173. package/utils/keyboard/typeaheadUtils.d.ts +31 -0
  174. package/utils/menu/menuUtils.d.ts +25 -0
  175. package/utils/slider/sliderUtils.d.ts +67 -0
  176. package/utils/tabs/tabsUtils.d.ts +75 -0
  177. package/utils/toast/toastStore.d.ts +73 -0
  178. package/utils/virtual/virtualUtils.d.ts +47 -0
  179. /package/react/{a11y → identity}/useIdentifier.d.ts +0 -0
@@ -1,261 +1,236 @@
1
- import { Circle as e, Path as t, Svg as n } from "./svg.mjs";
2
- import { forwardRef as r } from "react";
3
- import { mergeDeep as i } from "@box-kite/core";
4
- import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
5
- import c from "@box-kite/react";
1
+ import { n as e, r as t, t as n } from "../react-shared.mjs";
2
+ import { Circle as r, Path as i, Svg as a } from "./svg.mjs";
3
+ import { forwardRef as o } from "react";
4
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
5
+ import u from "@box-kite/react";
6
6
  //#region src/utils/chart/chartUtils.ts
7
- var l;
8
- (function(e) {
9
- let t = e.VIEW = 100, n = e.CENTRE = t / 2, r = e.FRACTION_STEP = .005;
10
- function i(e) {
7
+ var d;
8
+ (function(r) {
9
+ let i = r.VIEW = 100, a = r.CENTRE = i / 2, o = r.FRACTION_STEP = .005;
10
+ function s(e) {
11
11
  return Math.round(e * 100) / 100;
12
12
  }
13
- function a(e) {
14
- return Math.round(Math.min(Math.max(e, 0), 1) / r) * r;
13
+ function c(e) {
14
+ return Math.round(Math.min(Math.max(e, 0), 1) / o) * o;
15
15
  }
16
- e.fraction = a;
17
- function o(e, r = {}) {
16
+ r.fraction = c;
17
+ function l(e, t = {}) {
18
18
  if (e.length === 0) return [];
19
- let a = r.min ?? Math.min(...e), o = (r.max ?? Math.max(...e)) - a, s = (e) => i(o === 0 ? n : t - (e - a) / o * t);
19
+ let n = t.min ?? Math.min(...e), r = (t.max ?? Math.max(...e)) - n, o = (e) => s(r === 0 ? a : i - (e - n) / r * i);
20
20
  if (e.length === 1) return [{
21
21
  x: 0,
22
- y: s(e[0])
22
+ y: o(e[0])
23
23
  }, {
24
- x: t,
25
- y: s(e[0])
24
+ x: i,
25
+ y: o(e[0])
26
26
  }];
27
- let c = t / (e.length - 1);
27
+ let c = i / (e.length - 1);
28
28
  return e.map((e, t) => ({
29
- x: i(t * c),
30
- y: s(e)
29
+ x: s(t * c),
30
+ y: o(e)
31
31
  }));
32
32
  }
33
- e.points = o;
34
- function s(e) {
33
+ r.points = l;
34
+ function u(e) {
35
35
  return e.length === 0 ? "" : e.map((e, t) => `${t === 0 ? "M" : "L"}${e.x} ${e.y}`).join("");
36
36
  }
37
- e.linePath = s;
38
- function c(e) {
37
+ r.linePath = u;
38
+ function d(e) {
39
39
  if (e.length === 0) return "";
40
- let n = e[e.length - 1];
41
- return `${s(e)}L${n.x} ${t}L${e[0].x} ${t}Z`;
40
+ let t = e[e.length - 1];
41
+ return `${u(e)}L${t.x} ${i}L${e[0].x} ${i}Z`;
42
42
  }
43
- e.areaPath = c;
44
- function l(e, n = {}, r = .25) {
43
+ r.areaPath = d;
44
+ function f(e, t = {}, n = .25) {
45
45
  if (e.length === 0) return "";
46
- let a = t / e.length, s = i(a * (1 - r)), c = i((a - s) / 2);
47
- return o(e, n).map((e, n) => {
48
- let r = Math.min(e.y, t - 1);
49
- return `M${i(n * a + c)} ${r}h${s}v${i(t - r)}h${-s}Z`;
46
+ let r = i / e.length, a = s(r * (1 - n)), o = s((r - a) / 2);
47
+ return l(e, t).map((e, t) => {
48
+ let n = Math.min(e.y, i - 1);
49
+ return `M${s(t * r + o)} ${n}h${a}v${s(i - n)}h${-a}Z`;
50
50
  }).join("");
51
51
  }
52
- e.barsPath = l;
53
- function u(e) {
54
- return i(n - e / 2);
52
+ r.barsPath = f;
53
+ function p(e) {
54
+ return s(a - e / 2);
55
55
  }
56
- e.radius = u;
57
- function d(e) {
58
- return i(2 * Math.PI * e);
56
+ r.radius = p;
57
+ function m(e) {
58
+ return s(2 * Math.PI * e);
59
59
  }
60
- e.circumference = d;
61
- function f(e, t) {
60
+ r.circumference = m;
61
+ function h(e, t) {
62
62
  return {
63
- strokeDasharray: i(e),
64
- strokeDashoffset: i(e * (1 - a(t)))
63
+ strokeDasharray: s(e),
64
+ strokeDashoffset: s(e * (1 - c(t)))
65
65
  };
66
66
  }
67
- e.dash = f;
68
- function p(e, t) {
69
- let r = (t - 90) * Math.PI / 180;
67
+ r.dash = h;
68
+ function g(e, t) {
69
+ let n = (t - 90) * Math.PI / 180;
70
70
  return {
71
- x: i(n + e * Math.cos(r)),
72
- y: i(n + e * Math.sin(r))
71
+ x: s(a + e * Math.cos(n)),
72
+ y: s(a + e * Math.sin(n))
73
73
  };
74
74
  }
75
- function m(e, t) {
76
- return i(d(e) * (Math.min(Math.abs(t), 360) / 360));
75
+ function _(e, t) {
76
+ return s(m(e) * (Math.min(Math.abs(t), 360) / 360));
77
77
  }
78
- e.arcLength = m;
79
- function h(e, t, n) {
78
+ r.arcLength = _;
79
+ function v(e, t, n) {
80
80
  if (Math.abs(n) >= 360) {
81
- let n = p(e, t), r = p(e, t + 180);
81
+ let n = g(e, t), r = g(e, t + 180);
82
82
  return `M${n.x} ${n.y}A${e} ${e} 0 0 1 ${r.x} ${r.y}A${e} ${e} 0 0 1 ${n.x} ${n.y}`;
83
83
  }
84
- let r = p(e, t), i = p(e, t + n), a = +(Math.abs(n) > 180), o = n < 0 ? 0 : 1;
84
+ let r = g(e, t), i = g(e, t + n), a = +(Math.abs(n) > 180), o = n < 0 ? 0 : 1;
85
85
  return `M${r.x} ${r.y}A${e} ${e} 0 ${a} ${o} ${i.x} ${i.y}`;
86
86
  }
87
- e.arcPath = h;
88
- function g(e, t) {
87
+ r.arcPath = v;
88
+ function y(e, t) {
89
89
  let n = e.reduce((e, t) => e + Math.max(t, 0), 0);
90
90
  if (n <= 0) return [];
91
91
  let r = 0;
92
- return e.map((e, o) => {
93
- let s = a(Math.max(e, 0) / n), c = i(t * s), l = i(r * 360);
94
- return r += s, {
95
- strokeDasharray: `${c} ${i(t - c)}`,
92
+ return e.map((e, i) => {
93
+ let a = c(Math.max(e, 0) / n), o = s(t * a), l = s(r * 360);
94
+ return r += a, {
95
+ strokeDasharray: `${o} ${s(t - o)}`,
96
96
  rotate: l,
97
97
  value: e,
98
- index: o
98
+ index: i
99
99
  };
100
100
  });
101
101
  }
102
- e.donutSegments = g;
103
- let _ = e.PALETTE = [
104
- "sky-500",
105
- "emerald-500",
106
- "amber-500",
107
- "violet-500",
108
- "rose-500",
109
- "cyan-500"
110
- ];
111
- e.DARK_PALETTE = [
112
- "sky-400",
113
- "emerald-400",
114
- "amber-400",
115
- "violet-400",
116
- "rose-400",
117
- "cyan-400"
118
- ];
119
- function v(e) {
120
- return e.reduce((e, t, n) => (e[`chart-${n + 1}`] = t, e), {});
121
- }
122
- e.paletteVariables = v;
123
- function y(e, t = _.length) {
102
+ r.donutSegments = y;
103
+ let b = r.PALETTE = e;
104
+ r.DARK_PALETTE = n, r.paletteVariables = t;
105
+ function x(e, t = b.length) {
124
106
  return (Array.isArray(e) ? e.map((e, n) => [e, `var(--chart-${n % t + 1})`]) : Object.entries(e)).reduce((e, [t, n]) => (e[`color-${t}`] = n, e), {});
125
107
  }
126
- e.seriesVariables = y;
127
- })(l ||= {});
128
- var u = l, d = `0 0 ${u.VIEW} ${u.VIEW}`, f = u.PALETTE;
129
- function p(e, r) {
130
- let { data: i, variant: c = "line", min: l, max: f, children: p, ...m } = e, h = {
131
- min: l,
132
- max: f
133
- }, g = u.points(i, h);
134
- return /* @__PURE__ */ s(n, {
135
- viewBox: d,
108
+ r.seriesVariables = x;
109
+ })(d ||= {});
110
+ var f = d, p = `0 0 ${f.VIEW} ${f.VIEW}`, m = f.PALETTE;
111
+ function h(e, t) {
112
+ let { data: n, variant: r = "line", min: o, max: u, children: d, ...m } = e, h = {
113
+ min: o,
114
+ max: u
115
+ }, g = f.points(n, h);
116
+ return /* @__PURE__ */ l(a, {
117
+ viewBox: p,
118
+ component: "sparkline",
136
119
  preserveAspectRatio: "none",
137
- vectorEffect: "non-scaling-stroke",
138
120
  width: "100%",
139
121
  height: "1.5rem",
140
- overflow: "visible",
141
- stroke: "currentColor",
142
- fill: "currentColor",
143
- strokeWidth: 1.5,
144
- strokeLinecap: "round",
145
- strokeLinejoin: "round",
146
- ref: r,
122
+ ref: t,
147
123
  ...m,
148
- children: [c === "bar" ? /* @__PURE__ */ o(t, {
149
- d: u.barsPath(i, h),
150
- stroke: "none"
151
- }) : /* @__PURE__ */ s(a, { children: [c === "area" && /* @__PURE__ */ o(t, {
152
- d: u.areaPath(g),
153
- stroke: "none",
154
- fillOpacity: .2
155
- }), /* @__PURE__ */ o(t, {
156
- d: u.linePath(g),
157
- fill: "none"
158
- })] }), p]
124
+ children: [r === "bar" ? /* @__PURE__ */ c(i, {
125
+ component: "sparkline.bar",
126
+ d: f.barsPath(n, h)
127
+ }) : /* @__PURE__ */ l(s, { children: [r === "area" && /* @__PURE__ */ c(i, {
128
+ component: "sparkline.area",
129
+ d: f.areaPath(g)
130
+ }), /* @__PURE__ */ c(i, {
131
+ component: "sparkline.line",
132
+ d: f.linePath(g)
133
+ })] }), d]
159
134
  });
160
135
  }
161
- var m = /* @__PURE__ */ r(p);
162
- m.displayName = "Sparkline";
163
- function h(t, r) {
164
- let { value: i, thickness: a = 10, trackOpacity: c = .2, children: l, ...f } = t, p = u.radius(a), m = u.circumference(p);
165
- return /* @__PURE__ */ s(n, {
166
- viewBox: d,
136
+ var g = /* @__PURE__ */ o(h);
137
+ g.displayName = "Sparkline";
138
+ function _(e, t) {
139
+ let { value: n, thickness: i = 10, trackOpacity: o, children: s, ...u } = e, d = f.radius(i), m = f.circumference(d);
140
+ return /* @__PURE__ */ l(a, {
141
+ viewBox: p,
142
+ component: "progressRing",
167
143
  width: "3rem",
168
144
  height: "3rem",
169
- stroke: "currentColor",
170
- fill: "none",
171
- strokeWidth: a,
172
- strokeLinecap: "round",
173
- ref: r,
174
- ...f,
145
+ strokeWidth: i,
146
+ ref: t,
147
+ ...u,
175
148
  children: [
176
- /* @__PURE__ */ o(e, {
177
- cx: u.CENTRE,
178
- cy: u.CENTRE,
179
- r: p,
180
- strokeOpacity: c
149
+ /* @__PURE__ */ c(r, {
150
+ component: "progressRing.track",
151
+ cx: f.CENTRE,
152
+ cy: f.CENTRE,
153
+ r: d,
154
+ strokeOpacity: o
181
155
  }),
182
- /* @__PURE__ */ o(e, {
183
- cx: u.CENTRE,
184
- cy: u.CENTRE,
185
- r: p,
186
- transform: `rotate(-90 ${u.CENTRE} ${u.CENTRE})`,
187
- ...u.dash(m, i)
156
+ /* @__PURE__ */ c(r, {
157
+ component: "progressRing.arc",
158
+ cx: f.CENTRE,
159
+ cy: f.CENTRE,
160
+ r: d,
161
+ transform: `rotate(-90 ${f.CENTRE} ${f.CENTRE})`,
162
+ ...f.dash(m, n)
188
163
  }),
189
- l
164
+ s
190
165
  ]
191
166
  });
192
167
  }
193
- var g = /* @__PURE__ */ r(h);
194
- g.displayName = "ProgressRing";
195
- function _(e, r) {
196
- let { value: i, thickness: a = 10, trackOpacity: c = .2, sweep: l = 270, start: f = 225, children: p, ...m } = e, h = u.radius(a), g = u.arcLength(h, l), _ = u.arcPath(h, f, l);
197
- return /* @__PURE__ */ s(n, {
198
- viewBox: d,
168
+ var v = /* @__PURE__ */ o(_);
169
+ v.displayName = "ProgressRing";
170
+ function y(e, t) {
171
+ let { value: n, thickness: r = 10, trackOpacity: o, sweep: s = 270, start: u = 225, children: d, ...m } = e, h = f.radius(r), g = f.arcLength(h, s), _ = f.arcPath(h, u, s);
172
+ return /* @__PURE__ */ l(a, {
173
+ viewBox: p,
174
+ component: "gauge",
199
175
  width: "4rem",
200
176
  height: "4rem",
201
- stroke: "currentColor",
202
- fill: "none",
203
- strokeWidth: a,
204
- strokeLinecap: "round",
205
- ref: r,
177
+ strokeWidth: r,
178
+ ref: t,
206
179
  ...m,
207
180
  children: [
208
- /* @__PURE__ */ o(t, {
181
+ /* @__PURE__ */ c(i, {
182
+ component: "gauge.track",
209
183
  d: _,
210
- strokeOpacity: c
184
+ strokeOpacity: o
211
185
  }),
212
- /* @__PURE__ */ o(t, {
186
+ /* @__PURE__ */ c(i, {
187
+ component: "gauge.arc",
213
188
  d: _,
214
- ...u.dash(g, i)
189
+ ...f.dash(g, n)
215
190
  }),
216
- p
191
+ d
217
192
  ]
218
193
  });
219
194
  }
220
- var v = /* @__PURE__ */ r(_);
221
- v.displayName = "Gauge";
222
- function y(t, r) {
223
- let { data: i, colors: a = f, thickness: c = 20, children: l, ...p } = t, m = u.radius(c), h = u.circumference(m);
224
- return /* @__PURE__ */ s(n, {
225
- viewBox: d,
195
+ var b = /* @__PURE__ */ o(y);
196
+ b.displayName = "Gauge";
197
+ function x(e, t) {
198
+ let { data: n, colors: i = m, thickness: o = 20, children: s, ...u } = e, d = f.radius(o), h = f.circumference(d);
199
+ return /* @__PURE__ */ l(a, {
200
+ viewBox: p,
201
+ component: "miniDonut",
226
202
  width: "3rem",
227
203
  height: "3rem",
228
- fill: "none",
229
- strokeWidth: c,
230
- ref: r,
231
- ...p,
232
- children: [u.donutSegments(i, h).map((t) => /* @__PURE__ */ o(e, {
233
- cx: u.CENTRE,
234
- cy: u.CENTRE,
235
- r: m,
236
- stroke: a[t.index % a.length],
237
- strokeDasharray: t.strokeDasharray,
238
- transform: `rotate(${t.rotate - 90} ${u.CENTRE} ${u.CENTRE})`
239
- }, t.index)), l]
204
+ strokeWidth: o,
205
+ ref: t,
206
+ ...u,
207
+ children: [f.donutSegments(n, h).map((e) => /* @__PURE__ */ c(r, {
208
+ component: "miniDonut.segment",
209
+ cx: f.CENTRE,
210
+ cy: f.CENTRE,
211
+ r: d,
212
+ stroke: i[e.index % i.length],
213
+ strokeDasharray: e.strokeDasharray,
214
+ transform: `rotate(${e.rotate - 90} ${f.CENTRE} ${f.CENTRE})`
215
+ }, e.index)), s]
240
216
  });
241
217
  }
242
- var b = /* @__PURE__ */ r(y);
243
- b.displayName = "MiniDonut";
244
- function x(e, t) {
245
- let { series: n, vars: r, theme: a, ...s } = e, l = {
246
- ...u.paletteVariables(u.PALETTE),
247
- ...n ? u.seriesVariables(n) : {},
218
+ var S = /* @__PURE__ */ o(x);
219
+ S.displayName = "MiniDonut";
220
+ function C(e, t) {
221
+ let { series: n, vars: r, ...i } = e, a = {
222
+ ...n ? f.seriesVariables(n) : {},
248
223
  ...r
249
- }, d = i({ dark: { vars: u.paletteVariables(u.DARK_PALETTE) } }, a ?? {});
250
- return /* @__PURE__ */ o(c, {
224
+ };
225
+ return /* @__PURE__ */ c(u, {
251
226
  ref: t,
252
- vars: l,
253
- theme: d,
254
- ...s
227
+ component: "chartContainer",
228
+ vars: a,
229
+ ...i
255
230
  });
256
231
  }
257
- var S = r(x);
258
- S.displayName = "ChartContainer";
259
- var C = S;
232
+ var w = o(C);
233
+ w.displayName = "ChartContainer";
234
+ var T = w;
260
235
  //#endregion
261
- export { C as ChartContainer, v as Gauge, b as MiniDonut, g as ProgressRing, m as Sparkline };
236
+ export { T as ChartContainer, b as Gauge, S as MiniDonut, v as ProgressRing, g as Sparkline };
@@ -1 +1 @@
1
- "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../box.cjs"),n=require("../forms.cjs");let r=require("react"),i=require("react/jsx-runtime");var a=[`name`,`onInput`,`onChange`,`autoFocus`,`readOnly`,`value`,`defaultChecked`];function o(o,s){let{label:c,labelProps:l,...u}=o,d=Array.isArray(o.indeterminate)?o.indeterminate[0]:o.indeterminate,f=typeof d==`boolean`&&d,p=e.t.buildProps(u,a,{type:`checkbox`,...f?{"aria-checked":`mixed`}:{}}),m=(0,r.useRef)(null);return(0,r.useImperativeHandle)(s,()=>m.current),(0,r.useEffect)(()=>{m.current&&(m.current.indeterminate=f)},[m,f]),(0,i.jsx)(n.n,{label:c,labelProps:l,children:(0,i.jsx)(t.default,{tag:`input`,ref:m,component:`checkbox`,...p})})}var s=(0,r.forwardRef)(o);s.displayName=`Checkbox`,exports.default=s;
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../box.cjs"),n=require("../forms.cjs");let r=require("react"),i=require("react/jsx-runtime");var a=[`name`,`onInput`,`onChange`,`autoFocus`,`readOnly`,`value`,`defaultChecked`];function o(o,s){let{label:c,labelProps:l,...u}=o,d=Array.isArray(o.indeterminate)?o.indeterminate[0]:o.indeterminate,f=typeof d==`boolean`&&d,p=e.i.buildProps(u,a,{type:`checkbox`,...f?{"aria-checked":`mixed`}:{}}),m=(0,r.useRef)(null);return(0,r.useImperativeHandle)(s,()=>m.current),(0,r.useEffect)(()=>{m.current&&(m.current.indeterminate=f)},[m,f]),(0,i.jsx)(n.n,{label:c,labelProps:l,children:(0,i.jsx)(t.default,{tag:`input`,ref:m,component:`checkbox`,...p})})}var s=(0,r.forwardRef)(o);s.displayName=`Checkbox`,exports.default=s;
@@ -7,13 +7,21 @@ type TagPropsType = (typeof tagProps)[number];
7
7
  type CheckboxProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'input', TKey>, 'tag' | 'props'>;
8
8
  type CheckboxTagProps = OmitTagProps<BoxTagProps<'input'>, TagPropsType | 'type'>;
9
9
  interface Props<TKey extends keyof ComponentsAndVariants> extends CheckboxProps<TKey> {
10
+ /** What the checkbox submits under. Needed for a form; a controlled checkbox can do without one. */
10
11
  name?: string;
12
+ /** Attributes for the `<input>` itself — `type` is the component's, and so is `aria-checked`. */
11
13
  props?: CheckboxTagProps;
14
+ /** Fires on every click or keystroke. On a checkbox this is the same moment as `onChange`. */
12
15
  onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
16
+ /** Fires when the box is ticked or cleared. `e.target.checked` is the new state. */
13
17
  onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
18
+ /** The value the form submits when it is checked. Defaults to `"on"`, as HTML does. */
14
19
  value?: string | number;
20
+ /** Focus it on mount. One per page at most — a stolen focus is a lost place in the document. */
15
21
  autoFocus?: boolean;
22
+ /** Rendered and read, but not toggleable. Unlike `disabled` it stays in the tab order and submits. */
16
23
  readOnly?: boolean;
24
+ /** The state it starts in when the checkbox is uncontrolled. Pass `checked` instead to control it. */
17
25
  defaultChecked?: boolean;
18
26
  /**
19
27
  * The text beside the checkbox — rendered inside a `<label>` that wraps the input, so the
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { t as e } from "../react-shared.mjs";
2
+ import { i as e } from "../react-shared.mjs";
3
3
  import t from "../box.mjs";
4
4
  import { n } from "../forms.mjs";
5
5
  import { forwardRef as r, useEffect as i, useImperativeHandle as a, useRef as o } from "react";
@@ -0,0 +1,21 @@
1
+ import { ClassNameType } from '@box-kite/core';
2
+ import { ComboboxRowDef } from '../../utils/combobox/comboboxUtils';
3
+ export interface ComboboxChipsProps<TRow> {
4
+ selection: TRow[];
5
+ def: ComboboxRowDef<TRow>;
6
+ /** Custom chip content. The label is still the accessible name of its remove button. */
7
+ display?: (row: TRow) => React.ReactNode;
8
+ /** The remove button's accessible name, given the row's label. */
9
+ removeLabel: (label: string) => string;
10
+ onRemove: (row: TRow, event: React.MouseEvent) => void;
11
+ disabled?: boolean;
12
+ variant: ClassNameType;
13
+ }
14
+ /**
15
+ * The selection, in front of the field, one chip each. The remove buttons are deliberately **not** tab
16
+ * stops: a control holding twenty selections would otherwise cost twenty presses to Tab past. Removal
17
+ * from the keyboard is Backspace on an empty field and toggling the row in the listbox, so the function
18
+ * is reachable without them — and each button still carries a name, so it can be found and pressed by
19
+ * anyone reading the control rather than tabbing through it.
20
+ */
21
+ export default function ComboboxChips<TRow>(props: ComboboxChipsProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1,47 @@
1
+ import { ClassNameType } from '@box-kite/core';
2
+ import { BoxStyleProps } from '@box-kite/core/types';
3
+ import { ComboboxRow, ComboboxRowDef } from '../../utils/combobox/comboboxUtils';
4
+ import { ElementLike } from '../../utils/dom/domUtils';
5
+ import { PresenceHandle } from '../presence';
6
+ /** How a long list is windowed, or `false` to render every row of it however many there are. */
7
+ export interface ComboboxVirtualize {
8
+ /** The pitch of a row, when it should be declared rather than measured off the rendered ones. */
9
+ itemHeight?: number;
10
+ /** Rows kept either side of what is visible. */
11
+ overscan?: number;
12
+ /** How many rows it takes before windowing starts. */
13
+ threshold?: number;
14
+ }
15
+ export interface ComboboxListboxProps<TRow> {
16
+ /** Which way the popup is going, from the `<Presence>` that owns its mount. */
17
+ presence: PresenceHandle;
18
+ /** Every row the listbox shows, already in keyboard order. */
19
+ rows: ComboboxRow<TRow>[];
20
+ def: ComboboxRowDef<TRow>;
21
+ /** Custom row rendering. The label is still what is searched and what the field shows. */
22
+ display?: (row: TRow) => React.ReactNode;
23
+ selection: TRow[];
24
+ multiple: boolean;
25
+ /** The row the keyboard is on, or `-1` when it is on none of them. */
26
+ activeIndex: number;
27
+ optionId: (index: number) => string;
28
+ rowRef: (index: number) => (element: HTMLElement | null) => void;
29
+ onSelect: (index: number, event: React.SyntheticEvent) => void;
30
+ /** The shell the popup hangs off: the field and its chips. */
31
+ anchorRef: ElementLike;
32
+ /** The layer element — what the dismissal hook treats as *inside* the popup. */
33
+ popupRef: React.Ref<HTMLDivElement>;
34
+ listboxId: string;
35
+ labelledBy: string;
36
+ /** Options are on their way. Says so rather than claiming the list is empty. */
37
+ loading?: boolean;
38
+ loadingText: React.ReactNode;
39
+ emptyText: React.ReactNode;
40
+ /** What the create row reads. Given the query, since the row it would make is not shown. */
41
+ createLabel: (query: string) => React.ReactNode;
42
+ /** Render only the rows on screen. On above the threshold by default; `false` never. */
43
+ virtualize?: boolean | ComboboxVirtualize;
44
+ variant: ClassNameType;
45
+ itemsProps?: BoxStyleProps;
46
+ }
47
+ export default function ComboboxListbox<TRow>(props: ComboboxListboxProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../effects.cjs"),t=require("../box.cjs"),n=require("../behavior.cjs"),r=require("../identity.cjs"),i=require("./svg.cjs"),a=require("./flex.cjs"),o=require("./overlay.cjs"),s=require("./presence.cjs");let c=require("react"),l=require("react/jsx-runtime");var u;(function(e){function t(e,t){return typeof e==`function`?e(t):t[e]}e.read=t;function n(e,n){let r=t(e.label,n);return r==null?``:String(r)}e.labelOf=n;function r(e,r){return e.key===void 0?n(e,r):t(e.key,r)}e.keyOf=r;function i(e,n){return e.disabled!==void 0&&t(e.disabled,n)===!0}e.isDisabled=i;let a=/\p{M}/gu;function o(e){return e.normalize(`NFD`).replace(a,``).toLowerCase()}e.normalize=o;function s(e,t){return o(e).includes(o(t))}e.matches=s;function c(e,t,n){return t===``?e:e.filter(e=>s(n(e),t))}e.filterRows=c;function l(e){return e==null?[]:Array.isArray(e)?e:[e]}e.toArray=l;function u(e,t,n){let r=n(t);return e.some(e=>n(e)===r)}e.isSelected=u;function d(e,t,n,r){return n?u(e,t,r)?e.filter(e=>r(e)!==r(t)):[...e,t]:[t]}e.toggle=d;function f(e){let{data:t,def:r,query:i,filter:a,typed:s,createRow:c}=e,l=e=>n(r,e),u=(!s||a===!1?t:a(t,i,l)).map(e=>({kind:`option`,row:e}));return c&&i!==``&&!t.some(e=>o(l(e))===o(i))&&c(i)!==null&&u.push({kind:`create`,query:i}),u}e.rowsFor=f;function p(e,t){return t.kind===`option`&&i(e,t.row)}e.isRowDisabled=p;function m(e,t,n,i=`first`){let a=e=>r(n,e),o=e.findIndex(e=>e.kind===`option`&&u(t,e.row,a));if(o!==-1&&!p(n,e[o]))return o;let s=e.map((e,t)=>p(n,e)?-1:t).filter(e=>e!==-1);return(i===`last`?s[s.length-1]:s[0])??-1}e.activeIndexFor=m})(u||={});var d=u;function f(e){let{selection:t,def:n,display:r,removeLabel:o,onRemove:s,disabled:c,variant:u}=e;return(0,l.jsx)(l.Fragment,{children:t.map(e=>{let t=d.labelOf(n,e);return(0,l.jsxs)(a.default,{component:`combobox.chip`,variant:u,ai:`center`,gap:1,children:[r?.(e)??t,!c&&(0,l.jsx)(a.default,{tag:`button`,component:`combobox.remove`,variant:u,ai:`center`,jc:`center`,props:{type:`button`,tabIndex:-1,"aria-label":o(t),onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),s(e,t)}},children:(0,l.jsx)(i.Svg,{viewBox:`0 0 24 24`,width:`0.625rem`,props:{fill:`none`},children:(0,l.jsx)(i.Path,{d:`M6 6 18 18M18 6 6 18`,stroke:`currentColor`,strokeWidth:3,strokeLinecap:`round`})})})]},d.keyOf(n,e))})})}var p;(function(e){let t=e.DEFAULT_OVERSCAN=4,n=e.DEFAULT_THRESHOLD=100;e.DEFAULT_ITEM_HEIGHT=36,e.DEFAULT_VIEW_HEIGHT=248;function r(e,t,n){return Math.min(Math.max(e,t),n)}function i(e,t,r=n){return t??e>r}e.shouldVirtualize=i;function a(e){let{count:n,itemHeight:i,viewHeight:a,scrollTop:o,overscan:s=t,activeIndex:c=-1}=e;if(n<=0||i<=0)return{startIndex:0,endIndex:Math.max(0,n),offsetY:0,totalHeight:0};let l=Math.max(1,Math.ceil(a/i)),u=Math.min(n,l+s*2),d=n-u,f=r(Math.floor(o/i)-s,0,d);return c>=0&&c<n&&(c<f?f=r(c-s,0,d):c>=f+u&&(f=r(c+1+s-u,0,d))),{startIndex:f,endIndex:f+u,offsetY:f*i,totalHeight:n*i}}e.windowFor=a})(p||={});var m=p;function h(t){let{count:r,scrollerRef:i,itemHeight:a,viewHeight:o,overscan:s,threshold:l,enabled:u,activeIndex:d}=t,[f,p]=(0,c.useState)({top:0,at:-1}),[h,g]=(0,c.useState)({itemHeight:0,viewHeight:0}),_=(0,c.useRef)(null),v=(0,c.useCallback)(e=>{_.current=e},[]),y=m.shouldVirtualize(r,u,l),b=n.a(()=>{let e=i.current,t=_.current;if(!e||!t)return;let n=t.children,r=n[0],a=n[1],o=a?a.offsetTop-r.offsetTop:r?.offsetHeight??0,s=e.clientHeight;g(e=>e.itemHeight===o&&e.viewHeight===s?e:{itemHeight:o,viewHeight:s})});e.n(()=>{if(!y||(b(),typeof ResizeObserver>`u`))return;let e=i.current;if(!e)return;let t=new ResizeObserver(b);return t.observe(e),()=>t.disconnect()},[y,r,b,i]);let x=n.a(e=>{p({top:e.currentTarget.scrollTop,at:d??-1})}),S=m.windowFor({count:r,itemHeight:a??(h.itemHeight>0?h.itemHeight:m.DEFAULT_ITEM_HEIGHT),viewHeight:o??(h.viewHeight>0?h.viewHeight:m.DEFAULT_VIEW_HEIGHT),scrollTop:f.top,overscan:s,activeIndex:d===f.at?-1:d});return y?{...S,virtualized:y,contentRef:v,onScroll:x}:{startIndex:0,endIndex:r,offsetY:0,totalHeight:0,virtualized:y,contentRef:v,onScroll:x}}function g(e,t,n,r){return e?{role:`listbox`,"aria-labelledby":r,...t?{"aria-multiselectable":!0}:{},...n?{"aria-busy":!0}:{}}:{role:`status`}}function _(e){let{presence:n,rows:r,def:i,display:s,selection:u,multiple:f,activeIndex:p,optionId:m,rowRef:_,onSelect:v}=e,{anchorRef:y,popupRef:b,listboxId:x,labelledBy:S,loading:C,loadingText:ee,emptyText:w,createLabel:te,variant:T,itemsProps:ne}=e,{virtualize:E}=e,{present:D,ref:O,props:re}=n,k=e=>d.keyOf(i,e),[A,ie]=(0,c.useState)(!1),ae=(0,c.useCallback)(e=>ie(e===`top`),[]),j=(0,c.useRef)(null),oe=(0,c.useCallback)(e=>{j.current=e,O(e)},[O]),M=typeof E==`object`?E:{},{virtualized:N,startIndex:P,endIndex:se,offsetY:F,totalHeight:I,contentRef:L,onScroll:R}=h({count:r.length,scrollerRef:j,enabled:typeof E==`boolean`?E:void 0,activeIndex:p,...M}),z=N?r.slice(P,se):r,B=(e,t)=>{let n=N?P+t:t,o=e.kind===`option`&&d.isSelected(u,e.row,k),c=d.isRowDisabled(i,e);return(0,l.jsx)(a.default,{ref:_(n),component:`combobox.item`,variant:[T,{create:e.kind===`create`,highlighted:n===p}],selected:o,ai:`center`,gap:2,id:m(n),props:{role:`option`,...N?{"aria-setsize":r.length,"aria-posinset":n+1}:{},...c?{"aria-disabled":!0}:{},onMouseDown:e=>e.preventDefault(),onClick:e=>!c&&v(n,e)},children:e.kind===`create`?te(e.query):s?.(e.row)??d.labelOf(i,e.row)},e.kind===`option`?k(e.row):`create`)};return(0,l.jsx)(o.default,{ref:b,anchor:y,side:`bottom`,align:`start`,offset:.5,matchWidth:!0,onSideChange:ae,children:(0,l.jsxs)(t.default,{ref:oe,component:`combobox.items`,...ne,variant:[T,{closed:!D&&!A,closedUp:!D&&A}],id:x,props:{...g(r.length>0,f,C===!0,S),...re,...N?{onScroll:R}:{}},children:[N?(0,l.jsx)(t.default,{ref:L,component:`combobox.window`,variant:T,style:{height:I,paddingTop:F},children:z.map(B)}):z.map(B),r.length===0&&(0,l.jsx)(t.default,{component:`combobox.message`,variant:T,children:C?ee:w})]})})}var v=new Set([` `,`Home`,`End`,`ArrowLeft`,`ArrowRight`]);function y(o,u){let{data:p,def:m,label:h,labelProps:g,placeholder:y,name:b,disabled:x,props:S,itemsProps:C,hideIcon:ee,filter:w=d.filterRows,loading:te,loadingText:T=`Loading...`,emptyText:ne=`No results`,createRow:E,createLabel:D=e=>`Create "${e}"`,removeLabel:O=e=>`Remove ${e}`,virtualize:re,query:k,defaultQuery:A,onQueryChange:ie,open:ae,defaultOpen:j,onOpenChange:oe,multiple:M=!1,value:N,defaultValue:P,onValueChange:se,...F}=o,I=r.t(`combobox`),L=F.id??`${I}-field`,R=`${I}-listbox`,z=`${I}-label`,B=h!=null&&h!==!1,ce=(0,c.useCallback)(e=>`${I}-option-${e}`,[I]),V=(0,c.useRef)(null),le=(0,c.useRef)(null),H=(0,c.useRef)(null),ue=(0,c.useCallback)(e=>{H.current=e,typeof u==`function`?u(e):u&&(u.current=e)},[u]),de=n.a((e,t)=>{se?.(M?e:e[0]??null,t)}),fe=(0,c.useMemo)(()=>N===void 0?void 0:d.toArray(N),[N]),[U,pe]=n.i({value:fe,defaultValue:()=>d.toArray(P),onChange:de}),[W,G]=n.i({value:ae,defaultValue:j??!1,onChange:oe}),[me,K]=n.i({value:k,defaultValue:A??``,onChange:ie}),[q,J]=(0,c.useState)(!1),Y=(0,c.useCallback)(e=>d.keyOf(m,e),[m]),he=M||U[0]===void 0?``:d.labelOf(m,U[0]),X=q||me!==``?me:he,Z=(0,c.useMemo)(()=>d.rowsFor({data:p,def:m,query:X,filter:w,typed:q,createRow:E}),[p,m,X,w,q,E]),ge=(0,c.useCallback)(e=>Z[e]?d.isRowDisabled(m,Z[e]):!1,[Z,m]),_e=n.a((e,t)=>{G(!1,{reason:e,event:t}),e!==`escape`&&(J(!1),K(``,{reason:`close`,event:t}))}),Q=n.a((e,t)=>{let n=Z[e];if(!n||ge(e))return;let r=n.kind===`create`?E?.(n.query):n.row;if(r==null)return;let i=d.isSelected(U,r,Y),a=n.kind===`create`?`create`:i&&M?`deselect`:`select`;pe(d.toggle(U,r,M,Y),{reason:a,event:t}),J(!1),K(``,{reason:`select`,event:t}),M||G(!1,{reason:`select`,event:t})}),ve=n.t({count:Z.length,focusItems:!1,defaultActiveIndex:-1,isDisabled:ge,onSelect:Q}),{activeIndex:$,setActiveIndex:ye,activeItem:be}=ve;n.r({enabled:W,inside:[V,le],onDismiss:(e,t)=>_e(e===`escape`?`escape`:`outside-pointer`,t)}),e.n(()=>{!W||$===-1||be()?.scrollIntoView?.({block:`nearest`})},[W,$,be]);let xe=(e,t,n)=>{G(!0,{reason:n,event:t});let r=e===`none`?-1:d.activeIndexFor(Z,U,m,e);ye(r,{reason:`programmatic`,event:t})},Se=n.a(e=>{J(!0),K(e.target.value,{reason:`input`,event:e}),W||G(!0,{reason:`input`,event:e}),ye(-1,{reason:`programmatic`,event:e})}),Ce=n.a((e,t)=>{pe(U.filter(t=>Y(t)!==Y(e)),{reason:`remove`,event:t})}),we=e=>{let{key:t}=e;if(t===`ArrowDown`||t===`ArrowUp`){e.preventDefault(),xe(t===`ArrowUp`?`last`:e.altKey?`none`:`first`,e,`trigger`);return}t===`Escape`&&X!==``&&(J(!0),K(``,{reason:`clear`,event:e}))},Te=n.a(e=>{if(S?.onKeyDown?.(e),!(e.defaultPrevented||x)){if(e.key===`Backspace`&&M&&X===``&&U.length>0){Ce(U[U.length-1],e);return}if(!W){we(e);return}if(e.key===`Tab`){$!==-1&&Q($,e),_e(`tab`,e);return}if(e.altKey&&e.key===`ArrowUp`){e.preventDefault(),$===-1?_e(`trigger`,e):Q($,e);return}if(v.has(e.key)){ye(-1,{reason:`programmatic`,event:e});return}ve.onKeyDown(e)}}),Ee=n.a(e=>{!x&&!W&&xe(`first`,e,`trigger`)}),De=n.a(e=>{x||e.target===H.current||(e.preventDefault(),H.current?.focus(),W||xe(`first`,e,`trigger`))}),Oe=Z.length>0||te===!0||ne!==null,ke=W&&$!==-1&&Z.length>0?ce($):void 0,Ae=(0,l.jsx)(t.default,{tag:`input`,component:`combobox.field`,ref:ue,id:L,disabled:x,props:{...S,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":W,"aria-controls":W&&Oe?R:void 0,"aria-activedescendant":ke,"aria-labelledby":B?z:S?.[`aria-labelledby`],autoComplete:`off`,spellCheck:!1,type:`text`,value:X,placeholder:y,onChange:Se,onKeyDown:Te,onClick:Ee}}),je=!ee&&(0,l.jsx)(a.default,{component:`combobox.icon`,rotate:W?180:0,props:{"aria-hidden":!0},children:(0,l.jsx)(i.Svg,{viewBox:`0 0 10 6`,width:`0.6rem`,props:{fill:`none`},children:(0,l.jsx)(i.Path,{d:`m1 1 4 4 4-4`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`})})}),Me=b===void 0?null:U.map(e=>(0,l.jsx)(t.default,{tag:`input`,props:{type:`hidden`,name:b,value:String(Y(e))}},Y(e))),Ne=Oe&&(0,l.jsx)(s.default,{present:W,children:e=>(0,l.jsx)(_,{presence:e,rows:Z,def:m,display:m.display,selection:U,multiple:M,activeIndex:$,optionId:ce,rowRef:e=>ve.itemProps(e).ref,onSelect:Q,anchorRef:V,popupRef:le,listboxId:R,labelledBy:B?z:L,loading:te,loadingText:T,emptyText:ne,createLabel:D,virtualize:re,variant:F.variant,itemsProps:C})}),Pe=(0,l.jsxs)(a.default,{ref:V,component:`combobox`,ai:`center`,gap:1,flexWrap:`wrap`,...F,props:{onPointerDown:De},children:[Me,M&&(0,l.jsx)(f,{selection:U,def:m,display:m.display,removeLabel:O,onRemove:Ce,disabled:x,variant:F.variant}),Ae,je]});return B?(0,l.jsxs)(a.default,{d:`column`,gap:1,width:`fit-content`,children:[(0,l.jsx)(t.default,{tag:`label`,component:`combobox.label`,id:z,...g,props:{htmlFor:L},children:h}),Pe,Ne]}):(0,l.jsxs)(l.Fragment,{children:[Pe,Ne]})}var b=(0,c.forwardRef)(y);b.displayName=`Combobox`,exports.ComboboxUtils=d,exports.default=b;