@box-kite/react 1.0.0 → 2.0.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 (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
@@ -0,0 +1,121 @@
1
+ import { RefAttributes } from 'react';
2
+ import { BoxProps } from '../box';
3
+ import { ChangeHandler } from '../react/a11y/useControllableState';
4
+ import { BoxStyleProps, ComponentsAndVariants } from '@box-kite/core/types';
5
+ import { ComboboxFilter, ComboboxRow, ComboboxRowDef } from '../utils/combobox/comboboxUtils';
6
+ import { ComboboxVirtualize } from './combobox/comboboxListbox';
7
+ /** Why the listbox opened or closed. `select` is the transition worth telling apart from a dismissal. */
8
+ export type ComboboxOpenReason = 'trigger' | 'input' | 'select' | 'escape' | 'outside-pointer' | 'tab' | 'imperative';
9
+ /** Why the selection changed. `remove` is a chip's own button; `deselect` is toggling a row back off. */
10
+ export type ComboboxValueReason = 'select' | 'deselect' | 'create' | 'remove';
11
+ /** Why the typed text changed. Only `input` came from a keystroke; the rest are the component tidying up. */
12
+ export type ComboboxQueryReason = 'input' | 'select' | 'clear' | 'close';
13
+ /** How a row is read and how it is drawn. Only `label` is required — it is the text and the name. */
14
+ export interface ComboboxDef<TRow> extends ComboboxRowDef<TRow> {
15
+ /** Custom row rendering. The label is still what is searched, what the field shows and what is read out. */
16
+ display?: (row: TRow) => React.ReactNode;
17
+ }
18
+ interface BaseProps<TRow, TKey extends keyof ComponentsAndVariants = 'combobox'> extends Omit<BoxProps<'div', TKey>, 'ref' | 'tag' | 'children' | 'defaultValue' | 'onChange' | 'disabled' | 'placeholder' | 'open'> {
19
+ /** Every row the combobox can offer. Filtered by the query unless `filter` is `false`. */
20
+ data: TRow[];
21
+ /**
22
+ * How to read a row: its `label` (the text, which is searched and read out), its `key` (what makes two
23
+ * rows the same row), and optionally `disabled` and `display`. A key of the row, or a function.
24
+ */
25
+ def: ComboboxDef<TRow>;
26
+ /**
27
+ * The combobox's name, rendered above it in a real `<label>`. A combobox is not named by what it
28
+ * contains, so without this (or an `aria-label` of your own in `props`) it has no accessible name.
29
+ */
30
+ label?: React.ReactNode;
31
+ /** Styles for the `<label>` itself — it sits above the control rather than wrapping it. */
32
+ labelProps?: BoxProps<'label'>;
33
+ /** The field's placeholder. Not a name — it is gone on the first keystroke. See `label`. */
34
+ placeholder?: string;
35
+ /** What the selection submits under: one hidden input per selected row, carrying its key. */
36
+ name?: string;
37
+ /** Not editable and not openable, but still read out. The real attribute, on the field itself. */
38
+ disabled?: boolean;
39
+ /** Attributes for the `<input>` that *is* the combobox — an `aria-label`, an `inputMode`, an `id`. */
40
+ props?: Record<string, unknown>;
41
+ /** Styles for the popup (`combobox.items`). */
42
+ itemsProps?: BoxStyleProps;
43
+ /** Drop the chevron. It is decoration either way: `aria-hidden` and never focusable. */
44
+ hideIcon?: boolean;
45
+ /**
46
+ * Which rows a query leaves, and in what order — it takes the whole list so it can rank as well as
47
+ * reject, and is handed the label reader so composing it with the built-in one costs nothing.
48
+ * `false` means the data is already filtered, which is what a server that searched needs.
49
+ */
50
+ filter?: ComboboxFilter<TRow> | false;
51
+ /** Rows are on their way. The popup says so rather than claiming there are none. */
52
+ loading?: boolean;
53
+ /** What the popup shows while `loading` and there is nothing to show yet. */
54
+ loadingText?: React.ReactNode;
55
+ /** What the popup shows when the query matched nothing. */
56
+ emptyText?: React.ReactNode;
57
+ /**
58
+ * Turns the query into the row it would create, or `null` to refuse it. Its presence is what offers a
59
+ * create row at all, and one is never offered for a query a row already answers by name.
60
+ */
61
+ createRow?: (query: string) => TRow | null;
62
+ /** What the create row reads. Given the query, since the row it would make is not the one shown. */
63
+ createLabel?: (query: string) => React.ReactNode;
64
+ /**
65
+ * Render only the rows on screen, which is what a list of thousands needs to open in one frame. On by
66
+ * default above a hundred rows; an object tunes it (`threshold` is what turns it on earlier),
67
+ * `false` never windows and `true` always does. Rows have to be a uniform height for it, which is
68
+ * measured rather than declared — a `display` that varies one wants `false`.
69
+ */
70
+ virtualize?: boolean | ComboboxVirtualize;
71
+ /** A chip's remove button's accessible name, given the row's label. */
72
+ removeLabel?: (label: string) => string;
73
+ /** The typed text. Controlled — pair it with `onQueryChange`, which is also the hook an async search uses. */
74
+ query?: string;
75
+ /** The text the field starts with when the combobox owns its own query. */
76
+ defaultQuery?: string;
77
+ /** Fires with the text and why it changed. Only `input` came from a keystroke. */
78
+ onQueryChange?: ChangeHandler<string, ComboboxQueryReason>;
79
+ /** Whether the listbox is showing. Controlled — pair it with `onOpenChange`. */
80
+ open?: boolean;
81
+ /** Whether it starts open, when the combobox owns that itself. */
82
+ defaultOpen?: boolean;
83
+ /** Fires with the new state and why: a press, a keystroke, a choice, Escape, or a press outside. */
84
+ onOpenChange?: ChangeHandler<boolean, ComboboxOpenReason>;
85
+ }
86
+ /**
87
+ * One row at a time, which is the default: the value is a row or `null`, and the field shows the selected
88
+ * row's label whenever nothing is being typed.
89
+ */
90
+ interface SingleProps<TRow> {
91
+ /** Leave it off, or `false`. See the multiple half for the other shape. */
92
+ multiple?: false;
93
+ /** The selected row, or `null`. Controlled — pair it with `onValueChange`. */
94
+ value?: TRow | null;
95
+ /** What is selected to begin with, when the combobox owns its own value. */
96
+ defaultValue?: TRow | null;
97
+ /** Fires with the row itself — the object out of `data`, not a key dug out of it — and why. */
98
+ onValueChange?: ChangeHandler<TRow | null, ComboboxValueReason>;
99
+ }
100
+ /**
101
+ * Several rows, shown as chips in front of the field, and the value is an array. Choosing a row that is
102
+ * already chosen takes it off again, which is the keyboard's way to a chip its own button cannot reach.
103
+ */
104
+ interface MultipleProps<TRow> {
105
+ /** `true` is what turns the value into an array — the one shape a combobox cannot read off its value. */
106
+ multiple: true;
107
+ /** The selected rows. Controlled — pair it with `onValueChange`. */
108
+ value?: TRow[];
109
+ /** What is selected to begin with, when the combobox owns its own value. */
110
+ defaultValue?: TRow[];
111
+ /** Fires with the whole selection, as rows, and why it changed. */
112
+ onValueChange?: ChangeHandler<TRow[], ComboboxValueReason>;
113
+ }
114
+ type Props<TRow, TKey extends keyof ComponentsAndVariants = 'combobox'> = BaseProps<TRow, TKey> & (SingleProps<TRow> | MultipleProps<TRow>);
115
+ interface ComboboxType {
116
+ <TRow, TKey extends keyof ComponentsAndVariants = 'combobox'>(props: Props<TRow, TKey> & RefAttributes<HTMLInputElement>): React.ReactNode;
117
+ }
118
+ declare const Combobox: ComboboxType;
119
+ export default Combobox;
120
+ export { default as ComboboxUtils } from '../utils/combobox/comboboxUtils';
121
+ export type { ComboboxFilter, ComboboxRow, ComboboxRowDef, ComboboxVirtualize };
@@ -0,0 +1,563 @@
1
+ "use client";
2
+ import { n as e } from "../effects.mjs";
3
+ import t from "../box.mjs";
4
+ import { a as n, i as r, r as i, t as a } from "../behavior.mjs";
5
+ import { t as o } from "../identity.mjs";
6
+ import { Path as s, Svg as c } from "./svg.mjs";
7
+ import l from "./flex.mjs";
8
+ import u from "./overlay.mjs";
9
+ import d from "./presence.mjs";
10
+ import { forwardRef as f, useCallback as p, useMemo as m, useRef as h, useState as g } from "react";
11
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
12
+ //#region src/utils/combobox/comboboxUtils.ts
13
+ var b;
14
+ (function(e) {
15
+ function t(e, t) {
16
+ return typeof e == "function" ? e(t) : t[e];
17
+ }
18
+ e.read = t;
19
+ function n(e, n) {
20
+ let r = t(e.label, n);
21
+ return r == null ? "" : String(r);
22
+ }
23
+ e.labelOf = n;
24
+ function r(e, r) {
25
+ return e.key === void 0 ? n(e, r) : t(e.key, r);
26
+ }
27
+ e.keyOf = r;
28
+ function i(e, n) {
29
+ return e.disabled !== void 0 && t(e.disabled, n) === !0;
30
+ }
31
+ e.isDisabled = i;
32
+ let a = /\p{M}/gu;
33
+ function o(e) {
34
+ return e.normalize("NFD").replace(a, "").toLowerCase();
35
+ }
36
+ e.normalize = o;
37
+ function s(e, t) {
38
+ return o(e).includes(o(t));
39
+ }
40
+ e.matches = s;
41
+ function c(e, t, n) {
42
+ return t === "" ? e : e.filter((e) => s(n(e), t));
43
+ }
44
+ e.filterRows = c;
45
+ function l(e) {
46
+ return e == null ? [] : Array.isArray(e) ? e : [e];
47
+ }
48
+ e.toArray = l;
49
+ function u(e, t, n) {
50
+ let r = n(t);
51
+ return e.some((e) => n(e) === r);
52
+ }
53
+ e.isSelected = u;
54
+ function d(e, t, n, r) {
55
+ return n ? u(e, t, r) ? e.filter((e) => r(e) !== r(t)) : [...e, t] : [t];
56
+ }
57
+ e.toggle = d;
58
+ function f(e) {
59
+ 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) => ({
60
+ kind: "option",
61
+ row: e
62
+ }));
63
+ return c && i !== "" && !t.some((e) => o(l(e)) === o(i)) && c(i) !== null && u.push({
64
+ kind: "create",
65
+ query: i
66
+ }), u;
67
+ }
68
+ e.rowsFor = f;
69
+ function p(e, t) {
70
+ return t.kind === "option" && i(e, t.row);
71
+ }
72
+ e.isRowDisabled = p;
73
+ function m(e, t, n, i = "first") {
74
+ let a = (e) => r(n, e), o = e.findIndex((e) => e.kind === "option" && u(t, e.row, a));
75
+ if (o !== -1 && !p(n, e[o])) return o;
76
+ let s = e.map((e, t) => p(n, e) ? -1 : t).filter((e) => e !== -1);
77
+ return (i === "last" ? s[s.length - 1] : s[0]) ?? -1;
78
+ }
79
+ e.activeIndexFor = m;
80
+ })(b ||= {});
81
+ var x = b;
82
+ //#endregion
83
+ //#region src/components/combobox/comboboxChips.tsx
84
+ function S(e) {
85
+ let { selection: t, def: n, display: r, removeLabel: i, onRemove: a, disabled: o, variant: u } = e;
86
+ return /* @__PURE__ */ v(_, { children: t.map((e) => {
87
+ let t = x.labelOf(n, e);
88
+ return /* @__PURE__ */ y(l, {
89
+ component: "combobox.chip",
90
+ variant: u,
91
+ ai: "center",
92
+ gap: 1,
93
+ children: [r?.(e) ?? t, !o && /* @__PURE__ */ v(l, {
94
+ tag: "button",
95
+ component: "combobox.remove",
96
+ variant: u,
97
+ ai: "center",
98
+ jc: "center",
99
+ props: {
100
+ type: "button",
101
+ tabIndex: -1,
102
+ "aria-label": i(t),
103
+ onMouseDown: (e) => e.preventDefault(),
104
+ onClick: (t) => {
105
+ t.stopPropagation(), a(e, t);
106
+ }
107
+ },
108
+ children: /* @__PURE__ */ v(c, {
109
+ viewBox: "0 0 24 24",
110
+ width: "0.625rem",
111
+ props: { fill: "none" },
112
+ children: /* @__PURE__ */ v(s, {
113
+ d: "M6 6 18 18M18 6 6 18",
114
+ stroke: "currentColor",
115
+ strokeWidth: 3,
116
+ strokeLinecap: "round"
117
+ })
118
+ })
119
+ })]
120
+ }, x.keyOf(n, e));
121
+ }) });
122
+ }
123
+ //#endregion
124
+ //#region src/utils/virtual/virtualUtils.ts
125
+ var C;
126
+ (function(e) {
127
+ let t = e.DEFAULT_OVERSCAN = 4, n = e.DEFAULT_THRESHOLD = 100;
128
+ e.DEFAULT_ITEM_HEIGHT = 36, e.DEFAULT_VIEW_HEIGHT = 248;
129
+ function r(e, t, n) {
130
+ return Math.min(Math.max(e, t), n);
131
+ }
132
+ function i(e, t, r = n) {
133
+ return t ?? e > r;
134
+ }
135
+ e.shouldVirtualize = i;
136
+ function a(e) {
137
+ let { count: n, itemHeight: i, viewHeight: a, scrollTop: o, overscan: s = t, activeIndex: c = -1 } = e;
138
+ if (n <= 0 || i <= 0) return {
139
+ startIndex: 0,
140
+ endIndex: Math.max(0, n),
141
+ offsetY: 0,
142
+ totalHeight: 0
143
+ };
144
+ 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);
145
+ return c >= 0 && c < n && (c < f ? f = r(c - s, 0, d) : c >= f + u && (f = r(c + 1 + s - u, 0, d))), {
146
+ startIndex: f,
147
+ endIndex: f + u,
148
+ offsetY: f * i,
149
+ totalHeight: n * i
150
+ };
151
+ }
152
+ e.windowFor = a;
153
+ })(C ||= {});
154
+ var w = C;
155
+ //#endregion
156
+ //#region src/react/hooks/useVirtualization.ts
157
+ function ee(t) {
158
+ let { count: r, scrollerRef: i, itemHeight: a, viewHeight: o, overscan: s, threshold: c, enabled: l, activeIndex: u } = t, [d, f] = g({
159
+ top: 0,
160
+ at: -1
161
+ }), [m, _] = g({
162
+ itemHeight: 0,
163
+ viewHeight: 0
164
+ }), v = h(null), y = p((e) => {
165
+ v.current = e;
166
+ }, []), b = w.shouldVirtualize(r, l, c), x = n(() => {
167
+ let e = i.current, t = v.current;
168
+ if (!e || !t) return;
169
+ let n = t.children, r = n[0], a = n[1], o = a ? a.offsetTop - r.offsetTop : r?.offsetHeight ?? 0, s = e.clientHeight;
170
+ _((e) => e.itemHeight === o && e.viewHeight === s ? e : {
171
+ itemHeight: o,
172
+ viewHeight: s
173
+ });
174
+ });
175
+ e(() => {
176
+ if (!b || (x(), typeof ResizeObserver > "u")) return;
177
+ let e = i.current;
178
+ if (!e) return;
179
+ let t = new ResizeObserver(x);
180
+ return t.observe(e), () => t.disconnect();
181
+ }, [
182
+ b,
183
+ r,
184
+ x,
185
+ i
186
+ ]);
187
+ let S = n((e) => {
188
+ f({
189
+ top: e.currentTarget.scrollTop,
190
+ at: u ?? -1
191
+ });
192
+ }), C = w.windowFor({
193
+ count: r,
194
+ itemHeight: a ?? (m.itemHeight > 0 ? m.itemHeight : w.DEFAULT_ITEM_HEIGHT),
195
+ viewHeight: o ?? (m.viewHeight > 0 ? m.viewHeight : w.DEFAULT_VIEW_HEIGHT),
196
+ scrollTop: d.top,
197
+ overscan: s,
198
+ activeIndex: u === d.at ? -1 : u
199
+ });
200
+ return b ? {
201
+ ...C,
202
+ virtualized: b,
203
+ contentRef: y,
204
+ onScroll: S
205
+ } : {
206
+ startIndex: 0,
207
+ endIndex: r,
208
+ offsetY: 0,
209
+ totalHeight: 0,
210
+ virtualized: b,
211
+ contentRef: y,
212
+ onScroll: S
213
+ };
214
+ }
215
+ //#endregion
216
+ //#region src/components/combobox/comboboxListbox.tsx
217
+ function te(e, t, n, r) {
218
+ return e ? {
219
+ role: "listbox",
220
+ "aria-labelledby": r,
221
+ ...t ? { "aria-multiselectable": !0 } : {},
222
+ ...n ? { "aria-busy": !0 } : {}
223
+ } : { role: "status" };
224
+ }
225
+ function ne(e) {
226
+ let { presence: n, rows: r, def: i, display: a, selection: o, multiple: s, activeIndex: c, optionId: d, rowRef: f, onSelect: m } = e, { anchorRef: _, popupRef: b, listboxId: S, labelledBy: C, loading: w, loadingText: ne, emptyText: re, createLabel: T, variant: E, itemsProps: D } = e, { virtualize: O } = e, { present: ie, ref: k, props: A } = n, ae = (e) => x.keyOf(i, e), [j, M] = g(!1), oe = p((e) => M(e === "top"), []), se = h(null), ce = p((e) => {
227
+ se.current = e, k(e);
228
+ }, [k]), le = typeof O == "object" ? O : {}, { virtualized: N, startIndex: ue, endIndex: de, offsetY: fe, totalHeight: pe, contentRef: P, onScroll: F } = ee({
229
+ count: r.length,
230
+ scrollerRef: se,
231
+ enabled: typeof O == "boolean" ? O : void 0,
232
+ activeIndex: c,
233
+ ...le
234
+ }), I = N ? r.slice(ue, de) : r, L = (e, t) => {
235
+ let n = N ? ue + t : t, s = e.kind === "option" && x.isSelected(o, e.row, ae), u = x.isRowDisabled(i, e);
236
+ return /* @__PURE__ */ v(l, {
237
+ ref: f(n),
238
+ component: "combobox.item",
239
+ variant: [E, {
240
+ create: e.kind === "create",
241
+ highlighted: n === c
242
+ }],
243
+ selected: s,
244
+ ai: "center",
245
+ gap: 2,
246
+ id: d(n),
247
+ props: {
248
+ role: "option",
249
+ ...N ? {
250
+ "aria-setsize": r.length,
251
+ "aria-posinset": n + 1
252
+ } : {},
253
+ ...u ? { "aria-disabled": !0 } : {},
254
+ onMouseDown: (e) => e.preventDefault(),
255
+ onClick: (e) => !u && m(n, e)
256
+ },
257
+ children: e.kind === "create" ? T(e.query) : a?.(e.row) ?? x.labelOf(i, e.row)
258
+ }, e.kind === "option" ? ae(e.row) : "create");
259
+ };
260
+ return /* @__PURE__ */ v(u, {
261
+ ref: b,
262
+ anchor: _,
263
+ side: "bottom",
264
+ align: "start",
265
+ offset: .5,
266
+ matchWidth: !0,
267
+ onSideChange: oe,
268
+ children: /* @__PURE__ */ y(t, {
269
+ ref: ce,
270
+ component: "combobox.items",
271
+ ...D,
272
+ variant: [E, {
273
+ closed: !ie && !j,
274
+ closedUp: !ie && j
275
+ }],
276
+ id: S,
277
+ props: {
278
+ ...te(r.length > 0, s, w === !0, C),
279
+ ...A,
280
+ ...N ? { onScroll: F } : {}
281
+ },
282
+ children: [N ? /* @__PURE__ */ v(t, {
283
+ ref: P,
284
+ component: "combobox.window",
285
+ variant: E,
286
+ style: {
287
+ height: pe,
288
+ paddingTop: fe
289
+ },
290
+ children: I.map(L)
291
+ }) : I.map(L), r.length === 0 && /* @__PURE__ */ v(t, {
292
+ component: "combobox.message",
293
+ variant: E,
294
+ children: w ? ne : re
295
+ })]
296
+ })
297
+ });
298
+ }
299
+ //#endregion
300
+ //#region src/components/combobox.tsx
301
+ var re = /* @__PURE__ */ new Set([
302
+ " ",
303
+ "Home",
304
+ "End",
305
+ "ArrowLeft",
306
+ "ArrowRight"
307
+ ]);
308
+ function T(u, f) {
309
+ let { data: b, def: C, label: w, labelProps: ee, placeholder: te, name: T, disabled: E, props: D, itemsProps: O, hideIcon: ie, filter: k = x.filterRows, loading: A, loadingText: ae = "Loading...", emptyText: j = "No results", createRow: M, createLabel: oe = (e) => `Create "${e}"`, removeLabel: se = (e) => `Remove ${e}`, virtualize: ce, query: le, defaultQuery: N, onQueryChange: ue, open: de, defaultOpen: fe, onOpenChange: pe, multiple: P = !1, value: F, defaultValue: I, onValueChange: L, ...R } = u, z = o("combobox"), B = R.id ?? `${z}-field`, me = `${z}-listbox`, V = `${z}-label`, H = w != null && w !== !1, he = p((e) => `${z}-option-${e}`, [z]), ge = h(null), _e = h(null), ve = h(null), ye = p((e) => {
310
+ ve.current = e, typeof f == "function" ? f(e) : f && (f.current = e);
311
+ }, [f]), be = n((e, t) => {
312
+ L?.(P ? e : e[0] ?? null, t);
313
+ }), xe = m(() => F === void 0 ? void 0 : x.toArray(F), [F]), [U, Se] = r({
314
+ value: xe,
315
+ defaultValue: () => x.toArray(I),
316
+ onChange: be
317
+ }), [W, G] = r({
318
+ value: de,
319
+ defaultValue: fe ?? !1,
320
+ onChange: pe
321
+ }), [Ce, K] = r({
322
+ value: le,
323
+ defaultValue: N ?? "",
324
+ onChange: ue
325
+ }), [we, q] = g(!1), J = p((e) => x.keyOf(C, e), [C]), Te = P || U[0] === void 0 ? "" : x.labelOf(C, U[0]), Y = we || Ce !== "" ? Ce : Te, X = m(() => x.rowsFor({
326
+ data: b,
327
+ def: C,
328
+ query: Y,
329
+ filter: k,
330
+ typed: we,
331
+ createRow: M
332
+ }), [
333
+ b,
334
+ C,
335
+ Y,
336
+ k,
337
+ we,
338
+ M
339
+ ]), Ee = p((e) => X[e] ? x.isRowDisabled(C, X[e]) : !1, [X, C]), De = n((e, t) => {
340
+ G(!1, {
341
+ reason: e,
342
+ event: t
343
+ }), e !== "escape" && (q(!1), K("", {
344
+ reason: "close",
345
+ event: t
346
+ }));
347
+ }), Z = n((e, t) => {
348
+ let n = X[e];
349
+ if (!n || Ee(e)) return;
350
+ let r = n.kind === "create" ? M?.(n.query) : n.row;
351
+ if (r == null) return;
352
+ let i = x.isSelected(U, r, J), a = n.kind === "create" ? "create" : i && P ? "deselect" : "select";
353
+ Se(x.toggle(U, r, P, J), {
354
+ reason: a,
355
+ event: t
356
+ }), q(!1), K("", {
357
+ reason: "select",
358
+ event: t
359
+ }), P || G(!1, {
360
+ reason: "select",
361
+ event: t
362
+ });
363
+ }), Oe = a({
364
+ count: X.length,
365
+ focusItems: !1,
366
+ defaultActiveIndex: -1,
367
+ isDisabled: Ee,
368
+ onSelect: Z
369
+ }), { activeIndex: Q, setActiveIndex: ke, activeItem: Ae } = Oe;
370
+ i({
371
+ enabled: W,
372
+ inside: [ge, _e],
373
+ onDismiss: (e, t) => De(e === "escape" ? "escape" : "outside-pointer", t)
374
+ }), e(() => {
375
+ !W || Q === -1 || Ae()?.scrollIntoView?.({ block: "nearest" });
376
+ }, [
377
+ W,
378
+ Q,
379
+ Ae
380
+ ]);
381
+ let $ = (e, t, n) => {
382
+ G(!0, {
383
+ reason: n,
384
+ event: t
385
+ });
386
+ let r = e === "none" ? -1 : x.activeIndexFor(X, U, C, e);
387
+ ke(r, {
388
+ reason: "programmatic",
389
+ event: t
390
+ });
391
+ }, je = n((e) => {
392
+ q(!0), K(e.target.value, {
393
+ reason: "input",
394
+ event: e
395
+ }), W || G(!0, {
396
+ reason: "input",
397
+ event: e
398
+ }), ke(-1, {
399
+ reason: "programmatic",
400
+ event: e
401
+ });
402
+ }), Me = n((e, t) => {
403
+ Se(U.filter((t) => J(t) !== J(e)), {
404
+ reason: "remove",
405
+ event: t
406
+ });
407
+ }), Ne = (e) => {
408
+ let { key: t } = e;
409
+ if (t === "ArrowDown" || t === "ArrowUp") {
410
+ e.preventDefault(), $(t === "ArrowUp" ? "last" : e.altKey ? "none" : "first", e, "trigger");
411
+ return;
412
+ }
413
+ t === "Escape" && Y !== "" && (q(!0), K("", {
414
+ reason: "clear",
415
+ event: e
416
+ }));
417
+ }, Pe = n((e) => {
418
+ if (D?.onKeyDown?.(e), !(e.defaultPrevented || E)) {
419
+ if (e.key === "Backspace" && P && Y === "" && U.length > 0) {
420
+ Me(U[U.length - 1], e);
421
+ return;
422
+ }
423
+ if (!W) {
424
+ Ne(e);
425
+ return;
426
+ }
427
+ if (e.key === "Tab") {
428
+ Q !== -1 && Z(Q, e), De("tab", e);
429
+ return;
430
+ }
431
+ if (e.altKey && e.key === "ArrowUp") {
432
+ e.preventDefault(), Q === -1 ? De("trigger", e) : Z(Q, e);
433
+ return;
434
+ }
435
+ if (re.has(e.key)) {
436
+ ke(-1, {
437
+ reason: "programmatic",
438
+ event: e
439
+ });
440
+ return;
441
+ }
442
+ Oe.onKeyDown(e);
443
+ }
444
+ }), Fe = n((e) => {
445
+ !E && !W && $("first", e, "trigger");
446
+ }), Ie = n((e) => {
447
+ E || e.target === ve.current || (e.preventDefault(), ve.current?.focus(), W || $("first", e, "trigger"));
448
+ }), Le = X.length > 0 || A === !0 || j !== null, Re = W && Q !== -1 && X.length > 0 ? he(Q) : void 0, ze = /* @__PURE__ */ v(t, {
449
+ tag: "input",
450
+ component: "combobox.field",
451
+ ref: ye,
452
+ id: B,
453
+ disabled: E,
454
+ props: {
455
+ ...D,
456
+ role: "combobox",
457
+ "aria-autocomplete": "list",
458
+ "aria-expanded": W,
459
+ "aria-controls": W && Le ? me : void 0,
460
+ "aria-activedescendant": Re,
461
+ "aria-labelledby": H ? V : D?.["aria-labelledby"],
462
+ autoComplete: "off",
463
+ spellCheck: !1,
464
+ type: "text",
465
+ value: Y,
466
+ placeholder: te,
467
+ onChange: je,
468
+ onKeyDown: Pe,
469
+ onClick: Fe
470
+ }
471
+ }), Be = !ie && /* @__PURE__ */ v(l, {
472
+ component: "combobox.icon",
473
+ rotate: W ? 180 : 0,
474
+ props: { "aria-hidden": !0 },
475
+ children: /* @__PURE__ */ v(c, {
476
+ viewBox: "0 0 10 6",
477
+ width: "0.6rem",
478
+ props: { fill: "none" },
479
+ children: /* @__PURE__ */ v(s, {
480
+ d: "m1 1 4 4 4-4",
481
+ stroke: "currentColor",
482
+ strokeWidth: 2,
483
+ strokeLinecap: "round",
484
+ strokeLinejoin: "round"
485
+ })
486
+ })
487
+ }), Ve = T === void 0 ? null : U.map((e) => /* @__PURE__ */ v(t, {
488
+ tag: "input",
489
+ props: {
490
+ type: "hidden",
491
+ name: T,
492
+ value: String(J(e))
493
+ }
494
+ }, J(e))), He = Le && /* @__PURE__ */ v(d, {
495
+ present: W,
496
+ children: (e) => /* @__PURE__ */ v(ne, {
497
+ presence: e,
498
+ rows: X,
499
+ def: C,
500
+ display: C.display,
501
+ selection: U,
502
+ multiple: P,
503
+ activeIndex: Q,
504
+ optionId: he,
505
+ rowRef: (e) => Oe.itemProps(e).ref,
506
+ onSelect: Z,
507
+ anchorRef: ge,
508
+ popupRef: _e,
509
+ listboxId: me,
510
+ labelledBy: H ? V : B,
511
+ loading: A,
512
+ loadingText: ae,
513
+ emptyText: j,
514
+ createLabel: oe,
515
+ virtualize: ce,
516
+ variant: R.variant,
517
+ itemsProps: O
518
+ })
519
+ }), Ue = /* @__PURE__ */ y(l, {
520
+ ref: ge,
521
+ component: "combobox",
522
+ ai: "center",
523
+ gap: 1,
524
+ flexWrap: "wrap",
525
+ ...R,
526
+ props: { onPointerDown: Ie },
527
+ children: [
528
+ Ve,
529
+ P && /* @__PURE__ */ v(S, {
530
+ selection: U,
531
+ def: C,
532
+ display: C.display,
533
+ removeLabel: se,
534
+ onRemove: Me,
535
+ disabled: E,
536
+ variant: R.variant
537
+ }),
538
+ ze,
539
+ Be
540
+ ]
541
+ });
542
+ return H ? /* @__PURE__ */ y(l, {
543
+ d: "column",
544
+ gap: 1,
545
+ width: "fit-content",
546
+ children: [
547
+ /* @__PURE__ */ v(t, {
548
+ tag: "label",
549
+ component: "combobox.label",
550
+ id: V,
551
+ ...ee,
552
+ props: { htmlFor: B },
553
+ children: w
554
+ }),
555
+ Ue,
556
+ He
557
+ ]
558
+ }) : /* @__PURE__ */ y(_, { children: [Ue, He] });
559
+ }
560
+ var E = f(T);
561
+ E.displayName = "Combobox";
562
+ //#endregion
563
+ export { x as ComboboxUtils, E as default };
@@ -0,0 +1,10 @@
1
+ import { default as AggregateCellModel } from '../models/aggregateCellModel';
2
+ interface Props<TRow> {
3
+ cell: AggregateCellModel<TRow>;
4
+ }
5
+ /**
6
+ * What an aggregated cell draws when the column supplies no `AggregateCell` of its own. The scope picks the
7
+ * style node, so a group row's totals and the footer's are themed apart without two components.
8
+ */
9
+ export default function DataGridAggregateValue<TRow>(props: Props<TRow>): import("react").JSX.Element;
10
+ export {};
@@ -1,9 +1,10 @@
1
1
  import { BoxProps } from '../../../box';
2
+ import { default as AggregateCellModel } from '../models/aggregateCellModel';
2
3
  import { default as CellModel } from '../models/cellModel';
3
4
  import { default as GroupRowCellModel } from '../models/groupRowCellModel';
4
5
  interface Props<TRow> extends BoxProps {
5
6
  children: React.ReactNode;
6
- cell: CellModel<TRow> | GroupRowCellModel<TRow>;
7
+ cell: CellModel<TRow> | GroupRowCellModel<TRow> | AggregateCellModel<TRow>;
7
8
  /** Navigation coordinates. `columnIndex` counts rendered cells, which a group row has fewer of. */
8
9
  row: number;
9
10
  columnIndex: number;