@affino/datagrid-vue-app 0.1.63 → 0.4.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 (40) hide show
  1. package/README.md +25 -7
  2. package/dist/DataGrid.d.ts +1 -3
  3. package/dist/advanced-filter.js +1 -1
  4. package/dist/aggregations.js +1 -1
  5. package/dist/chunks/{DataGridAdvancedFilterPopover-BmEL_QzN.js → DataGridAdvancedFilterPopover-p_hnZLCA.js} +1 -1
  6. package/dist/chunks/{DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-BkrpyjJb.js → DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-AVmOe3Bv.js} +1 -1
  7. package/dist/chunks/{DataGridAggregationsPopover-D-HP10PE.js → DataGridAggregationsPopover-Bzbn6Nuy.js} +1 -1
  8. package/dist/chunks/{DataGridAggregationsPopover.vue_vue_type_script_setup_true_lang-VYIMuuIQ.js → DataGridAggregationsPopover.vue_vue_type_script_setup_true_lang-TgxL5evy.js} +1 -1
  9. package/dist/chunks/DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-CpC_nuMk.js +419 -0
  10. package/dist/chunks/DataGridGanttStageEntry-Cypf1c3l.js +12522 -0
  11. package/dist/chunks/useDataGridAppRowModel-b5bfkfo3.js +5574 -0
  12. package/dist/gantt.js +1 -1
  13. package/dist/host/DataGridDefaultRenderer.d.ts +1 -1
  14. package/dist/index.js +694 -674
  15. package/dist/internal.js +3 -3
  16. package/dist/overlays/DataGridCellComboboxEditor.vue.d.ts +1 -0
  17. package/dist/perf/dataGridPerfTrace.d.ts +7 -0
  18. package/dist/stage/DataGridTableStageCenterPane.vue.d.ts +18 -0
  19. package/dist/stage/DataGridTableStagePinnedPane.vue.d.ts +10 -1
  20. package/dist/stage/dataGridMouseEventGuards.d.ts +8 -0
  21. package/dist/stage/dataGridTableStage.types.d.ts +5 -1
  22. package/dist/stage/dataGridTableStageA11y.d.ts +4 -0
  23. package/dist/stage/dataGridTableStageBody.types.d.ts +6 -0
  24. package/dist/stage/useDataGridStageCellRendering.d.ts +1 -1
  25. package/dist/stage/useDataGridStageCellState.d.ts +2 -0
  26. package/dist/stage/useDataGridStageChromeCanvas.d.ts +1 -0
  27. package/dist/stage/useDataGridStageFocusRuntime.d.ts +1 -0
  28. package/dist/stage/useDataGridStageOverlays.d.ts +1 -0
  29. package/dist/stage/useDataGridStagePanes.grouped.d.ts +6 -0
  30. package/dist/stage/useDataGridStageRenderApis.d.ts +6 -0
  31. package/dist/stage/useDataGridStageRenderApis.grouped.d.ts +6 -0
  32. package/dist/stage/useDataGridStageRowIndex.d.ts +1 -0
  33. package/dist/stage/useDataGridStageViewportRuntime.d.ts +4 -0
  34. package/dist/stage/useDataGridTableStageHistory.d.ts +3 -0
  35. package/dist/stage/useDataGridTableStageRuntime.d.ts +3 -0
  36. package/dist/stage/useDataGridTableStageScrollSync.d.ts +8 -0
  37. package/package.json +7 -7
  38. package/dist/chunks/DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-Dt_KqrSU.js +0 -405
  39. package/dist/chunks/DataGridGanttStageEntry-D6OYD0Gx.js +0 -11781
  40. package/dist/chunks/useDataGridAppRowModel-9ZIepsHi.js +0 -5281
package/README.md CHANGED
@@ -7,11 +7,11 @@
7
7
  Declarative Vue component layer for Affino DataGrid.
8
8
 
9
9
  `@affino/datagrid-vue-app` is the app-facing package.
10
- It depends on [`@affino/datagrid-vue`](https://github.com/affinio/affinio/tree/main/packages/datagrid-vue#readme), which remains the adapter and headless foundation between Vue and the grid engine.
10
+ It depends on [`@affino/datagrid-vue`](https://github.com/affinio/datagrid/tree/main/packages/datagrid-vue#readme), which remains the adapter and headless foundation between Vue and the grid engine.
11
11
 
12
12
  Boundary doc:
13
13
 
14
- - [datagrid-vue-app-community-vs-enterprise.md](https://github.com/affinio/affinio/blob/main/docs/datagrid-vue-app-community-vs-enterprise.md)
14
+ - [datagrid-vue-app-community-vs-enterprise.md](https://github.com/affinio/datagrid/blob/main/docs/datagrid-vue-app-community-vs-enterprise.md)
15
15
 
16
16
  Public export:
17
17
 
@@ -945,11 +945,11 @@ Current gantt capabilities:
945
945
 
946
946
  Reference:
947
947
 
948
- - [datagrid-gantt.md](https://github.com/affinio/affinio/blob/main/docs/datagrid-gantt.md)
948
+ - [datagrid-gantt.md](https://github.com/affinio/datagrid/blob/main/docs/datagrid-gantt.md)
949
949
 
950
950
  ## Table Chrome Engine
951
951
 
952
- The default table renderer uses [`@affino/datagrid-chrome`](https://github.com/affinio/affinio/tree/main/packages/datagrid-chrome#readme) for shared headless table chrome geometry.
952
+ The default table renderer uses [`@affino/datagrid-chrome`](https://github.com/affinio/datagrid/tree/main/packages/datagrid-chrome#readme) for shared headless table chrome geometry.
953
953
 
954
954
  That engine derives:
955
955
 
@@ -1268,6 +1268,8 @@ Object form:
1268
1268
  Columns can provide a `cellRenderer` callback that returns Vue content for the display layer.
1269
1269
  If a custom cell also needs keyboard-accessible interaction without breaking the grid-owned focus model, declare `cellInteraction` on the column and use `context.interactive` inside the renderer.
1270
1270
  For grouped rows, prefer `groupCellRenderer` so you receive structured group metadata instead of reverse-engineering the formatted disclosure label.
1271
+ If an authored renderer throws, the stage preserves the cell wrapper and falls back to the resolved `displayValue` for that cell.
1272
+ The full lifecycle, remount, cleanup, focus, async, and performance contract is documented in [`docs/datagrid-renderer-lifecycle.md`](../../docs/datagrid-renderer-lifecycle.md).
1271
1273
 
1272
1274
  ```vue
1273
1275
  <script setup lang="ts">
@@ -1339,6 +1341,7 @@ const columns: DataGridAppColumnInput<Row>[] = [
1339
1341
  - `column` and `columnIndex`
1340
1342
  - `value`: raw string value used by the stage
1341
1343
  - `displayValue`: formatted display string after presentation rules
1344
+ - `surface`: rendered surface metadata; `surface.kind` is `"real"` for materialized rows and `"placeholder"` for visual placeholder rows
1342
1345
  - `interactive`: resolved cell interaction contract when the column declares `cellInteraction`; otherwise `null`
1343
1346
 
1344
1347
  `groupCellRenderer` receives the same display fields for group rows plus `group`, which includes:
@@ -1386,9 +1389,23 @@ Guidelines:
1386
1389
  - keep group expand/collapse behind an explicit trigger inside `groupCellRenderer`; do not rely on the whole group cell acting as the disclosure target
1387
1390
  - the grid shell still owns focus, selection, fill, clipboard, menus, and editing; `cellInteraction` only adds semantic invoke behavior inside that model
1388
1391
  - prefer pure render output from row data over local mutable renderer state
1392
+ - do not mutate grid state, row data, selection, focus, or editor state while the renderer is running
1393
+ - avoid synchronous layout reads such as `getBoundingClientRect()`, `clientWidth`, or computed-style reads inside renderers; measure layout in your surrounding app lifecycle instead
1394
+ - return bounded Vue content for each cell; expensive charts, popovers, network work, or observers should mount lazily behind explicit user intent
1395
+ - provide stable keys for repeated child VNodes returned from a renderer so virtualized row/column remounts do not lose child identity unnecessarily
1396
+ - treat `surface.kind === "placeholder"` as a display-only state; do not assume placeholder rows are persisted or editable until the grid materializes them through the placeholder-row policy
1397
+ - keep per-cell renderer work proportional to one cell because the stage invokes renderers synchronously for every rendered center and pinned cell
1389
1398
  - keep identifiers, derived values, and formula-result columns read-only where appropriate
1390
1399
  - if a renderer caches local UI state, listen for targeted app-layer cell refresh and re-sync on refresh
1391
1400
 
1401
+ Performance expectations:
1402
+
1403
+ - Renderers run in the same Vue render pass as virtualized row and column window updates.
1404
+ - Wide grids, pinned panes, and pinned-bottom rows multiply the number of rendered cell surfaces.
1405
+ - Renderer exceptions are isolated to the affected cell and fall back to `displayValue`; they are still application bugs and should be fixed rather than used as control flow.
1406
+ - The grid may use lightweight display-value rendering during active touch scroll; renderers must not be the only place where essential text, ARIA labels, selection state, or edit affordances exist.
1407
+ - Enterprise custom-renderer scenarios should be validated with the browser-frame/perf gates documented in `docs/perf/datagrid-performance-gates.md` before being treated as a performance baseline.
1408
+
1392
1409
  ### System checkbox interactions
1393
1410
 
1394
1411
  The built-in row-selection checkbox column uses the same `cellInteraction` contract internally.
@@ -1509,7 +1526,7 @@ Controlled consumers can still manage quick filter directly through the same `fi
1509
1526
  />
1510
1527
  ```
1511
1528
 
1512
- The app facade remains `filterModel`-first. `quick-filter` only drives the existing filter snapshot, so quick filter stays serializable and aligned with the core projection/filter pipeline. See [DataGrid Quick Filter](https://github.com/affinio/affinio/blob/main/docs/datagrid-quick-filter.md).
1529
+ The app facade remains `filterModel`-first. `quick-filter` only drives the existing filter snapshot, so quick filter stays serializable and aligned with the core projection/filter pipeline. See [DataGrid Quick Filter](https://github.com/affinio/datagrid/blob/main/docs/datagrid-quick-filter.md).
1513
1530
 
1514
1531
  Controlled state:
1515
1532
 
@@ -1578,7 +1595,7 @@ const rowSelectionState = ref({
1578
1595
  </template>
1579
1596
  ```
1580
1597
 
1581
- The legacy `row-select` event still exists, but `rowSelectionState` is the stable controlled API when the page wants to bind selected row ids without diffing unified-state updates.
1598
+ `rowSelectionState` is the controlled API when the page wants to bind selected row ids without diffing unified-state updates.
1582
1599
 
1583
1600
  For server-backed row models, the header checkbox selects the full current row projection without materializing every row id:
1584
1601
 
@@ -1716,6 +1733,7 @@ Notes:
1716
1733
  - Multiple flex columns share leftover available stage width by their flex weight.
1717
1734
  - If there is no free space, the column falls back to its base width.
1718
1735
  - Pinned and unpinned columns participate in the same effective width calculation.
1736
+ - `columnGroup` can be a string id, `{ id, label }`, or a nested path. The stage renders group headers across left-pinned, center, and right-pinned panes; visibility, resize, reorder, and pinning recalculate group spans from the current visible column snapshot.
1719
1737
 
1720
1738
  Unified column-state object:
1721
1739
 
@@ -1796,7 +1814,6 @@ The component emits:
1796
1814
  - `cell-change`
1797
1815
  - `selection-change`
1798
1816
  - `row-selection-change`
1799
- - `row-select` (legacy alias; prefer `row-selection-change` for typed row-selection snapshots)
1800
1817
  - `update:column-state`
1801
1818
  - `update:column-order`
1802
1819
  - `update:hidden-column-keys`
@@ -1889,6 +1906,7 @@ Row drag-and-drop is declarative and opt-in.
1889
1906
  - `rowReorder: false` keeps the row index non-draggable
1890
1907
  - the feature only applies when the grid is using a mutable rows API and `showRowIndex` is enabled
1891
1908
  - placeholder rows, group rows, and pinned rows are not draggable
1909
+ - rows with `state.pinned: 'top' | 'bottom'` render outside the scrollable body; body virtualization and row drag only operate on unpinned rows
1892
1910
 
1893
1911
  ```vue
1894
1912
  <DataGrid
@@ -683,7 +683,6 @@ declare const DataGridRuntimeComponent: import("vue").DefineComponent<{
683
683
  "cell-edit": (_payload: DataGridCellEditEvent<Record<string, unknown>>) => true;
684
684
  "selection-change": (_payload: DataGridApiSelectionChangedEvent) => true;
685
685
  "row-selection-change": (_payload: DataGridApiRowSelectionChangedEvent) => true;
686
- "row-select": (_payload: DataGridRowSelectionSnapshot | null) => true;
687
686
  "update:rowSelectionState": (_payload: DataGridRowSelectionSnapshot | null) => true;
688
687
  "update:columnState": (_payload: DataGridUnifiedColumnState | null) => true;
689
688
  "update:columnOrder": (_payload: readonly string[] | null) => true;
@@ -988,7 +987,6 @@ declare const DataGridRuntimeComponent: import("vue").DefineComponent<{
988
987
  "onSelection-change"?: ((_payload: DataGridApiSelectionChangedEvent) => any) | undefined;
989
988
  "onRow-selection-change"?: ((_payload: DataGridApiRowSelectionChangedEvent) => any) | undefined;
990
989
  "onCell-edit"?: ((_payload: DataGridCellEditEvent<Record<string, unknown>>) => any) | undefined;
991
- "onRow-select"?: ((_payload: DataGridRowSelectionSnapshot | null) => any) | undefined;
992
990
  "onUpdate:rowSelectionState"?: ((_payload: DataGridRowSelectionSnapshot | null) => any) | undefined;
993
991
  "onUpdate:columnState"?: ((_payload: DataGridUnifiedColumnState | null) => any) | undefined;
994
992
  "onUpdate:columnOrder"?: ((_payload: readonly string[] | null) => any) | undefined;
@@ -1029,6 +1027,7 @@ declare const DataGridRuntimeComponent: import("vue").DefineComponent<{
1029
1027
  readonly virtualization: DataGridVirtualizationProp | undefined;
1030
1028
  readonly pagination: DataGridPaginationProp | undefined;
1031
1029
  readonly rowModel: DataGridRowModel<unknown> | undefined;
1030
+ readonly rangeMove: boolean;
1032
1031
  readonly aggregations: DataGridAggregationsProp | undefined;
1033
1032
  readonly quickFilter: DataGridQuickFilterProp | undefined;
1034
1033
  readonly reportFillWarning: ((message: string) => void) | undefined;
@@ -1049,7 +1048,6 @@ declare const DataGridRuntimeComponent: import("vue").DefineComponent<{
1049
1048
  readonly maxRows: number | undefined;
1050
1049
  readonly placeholderRows: DataGridPlaceholderRowsProp<Record<string, unknown>> | undefined;
1051
1050
  readonly fillHandle: boolean;
1052
- readonly rangeMove: boolean;
1053
1051
  readonly readSelectionCell: DataGridSelectionCellReader<unknown> | undefined;
1054
1052
  readonly rowReorder: DataGridRowReorderProp | undefined;
1055
1053
  readonly viewMode: DataGridAppViewMode | undefined;
@@ -1,4 +1,4 @@
1
- import { _ as e } from "./chunks/DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-BkrpyjJb.js";
1
+ import { _ as e } from "./chunks/DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-AVmOe3Bv.js";
2
2
  export {
3
3
  e as DataGridAdvancedFilterPopover
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _ as a } from "./chunks/DataGridAggregationsPopover.vue_vue_type_script_setup_true_lang-VYIMuuIQ.js";
1
+ import { _ as a } from "./chunks/DataGridAggregationsPopover.vue_vue_type_script_setup_true_lang-TgxL5evy.js";
2
2
  export {
3
3
  a as DataGridAggregationsPopover
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _ as f } from "./DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-BkrpyjJb.js";
1
+ import { _ as f } from "./DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-AVmOe3Bv.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as N, inject as z, ref as A, computed as c, watch as w, nextTick as O, openBlock as i, createElementBlock as u, Fragment as C, createElementVNode as a, mergeProps as F, unref as _, createCommentVNode as P, createTextVNode as K, toDisplayString as l, createBlock as M, Teleport as U, renderList as T, createVNode as k } from "vue";
2
2
  import { usePopoverController as Z, useFloatingPopover as H } from "@affino/popover-vue";
3
- import { _ as L } from "./DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-Dt_KqrSU.js";
3
+ import { _ as L } from "./DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-CpC_nuMk.js";
4
4
  import { d as J, r as Q } from "./dataGridOverlayThemeVars-vzY74EIz.js";
5
5
  import { D } from "./dataGridAdvancedFilter-xnME5bRa.js";
6
6
  import { u as W } from "./useDataGridDraggableOverlaySurface-BgkSR_nl.js";
@@ -1,4 +1,4 @@
1
- import { _ as f } from "./DataGridAggregationsPopover.vue_vue_type_script_setup_true_lang-VYIMuuIQ.js";
1
+ import { _ as f } from "./DataGridAggregationsPopover.vue_vue_type_script_setup_true_lang-TgxL5evy.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as V, inject as E, ref as b, computed as d, watch as _, nextTick as m, openBlock as l, createElementBlock as i, Fragment as y, createElementVNode as e, mergeProps as k, unref as f, toDisplayString as h, createBlock as G, Teleport as D, createVNode as C, renderList as I, createCommentVNode as L } from "vue";
2
2
  import { usePopoverController as j, useFloatingPopover as z } from "@affino/popover-vue";
3
- import { _ as O } from "./DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-Dt_KqrSU.js";
3
+ import { _ as O } from "./DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-CpC_nuMk.js";
4
4
  import { d as q, r as K } from "./dataGridOverlayThemeVars-vzY74EIz.js";
5
5
  const U = ["disabled", "title"], H = { class: "datagrid-aggregations__header" }, J = /* @__PURE__ */ e("div", null, [
6
6
  /* @__PURE__ */ e("div", { class: "datagrid-aggregations__eyebrow" }, "Aggregations"),
@@ -0,0 +1,419 @@
1
+ import { defineComponent as Se, inject as Pe, ref as v, useAttrs as Re, computed as s, watch as $, nextTick as m, onMounted as Me, onBeforeUnmount as Be, openBlock as b, createElementBlock as h, createElementVNode as ae, mergeProps as Ve, withModifiers as O, createBlock as De, Teleport as Te, normalizeStyle as Ne, normalizeClass as ie, Fragment as re, renderList as $e, toDisplayString as Ge, createCommentVNode as z } from "vue";
2
+ import { d as He, r as Ue } from "./dataGridOverlayThemeVars-vzY74EIz.js";
3
+ function We(n = {}) {
4
+ return {
5
+ open: n.open ?? !1,
6
+ filter: n.filter ?? "",
7
+ activeIndex: n.activeIndex ?? -1
8
+ };
9
+ }
10
+ function P(n, l) {
11
+ return n.open === l ? n : {
12
+ ...n,
13
+ open: l
14
+ };
15
+ }
16
+ function q(n, l) {
17
+ return n.filter === l ? n : {
18
+ ...n,
19
+ filter: l
20
+ };
21
+ }
22
+ function R(n, l, t) {
23
+ const r = Ke(l, t);
24
+ return r === n.activeIndex ? n : {
25
+ ...n,
26
+ activeIndex: r
27
+ };
28
+ }
29
+ function ue(n, l, t, r = !0) {
30
+ if (t <= 0 || l === 0)
31
+ return n;
32
+ if (n.activeIndex < 0)
33
+ return R(n, l > 0 ? 0 : t - 1, t);
34
+ const u = n.activeIndex + Math.trunc(l);
35
+ return r ? R(n, Xe(u, t), t) : R(n, u, t);
36
+ }
37
+ function Ke(n, l) {
38
+ if (l <= 0)
39
+ return -1;
40
+ if (!Number.isFinite(n))
41
+ return 0;
42
+ const t = Math.trunc(n);
43
+ return t < 0 ? 0 : t >= l ? l - 1 : t;
44
+ }
45
+ function Xe(n, l) {
46
+ return (n % l + l) % l;
47
+ }
48
+ const ze = 0, qe = 1, je = 2, Je = 3, Ye = 4, Ze = 5, Qe = 6, et = 7, ce = 100;
49
+ function tt(n, l) {
50
+ const t = j(l);
51
+ if (t.length === 0)
52
+ return [...n];
53
+ const r = n.map((u, c) => ({
54
+ option: u,
55
+ score: nt(u, t),
56
+ originalIndex: c
57
+ })).filter((u) => u.score < ce);
58
+ return r.sort((u, c) => {
59
+ if (u.score !== c.score)
60
+ return u.score - c.score;
61
+ const k = u.option.label.length, d = c.option.label.length;
62
+ return k !== d ? k - d : u.originalIndex - c.originalIndex;
63
+ }), r.map((u) => u.option);
64
+ }
65
+ function nt(n, l) {
66
+ const t = j(n.label), r = j(n.value);
67
+ return t === l ? ze : r === l ? qe : t.startsWith(l) ? je : r.startsWith(l) ? Je : se(t, l) ? Ye : se(r, l) ? Ze : t.includes(l) ? Qe : r.includes(l) ? et : ce;
68
+ }
69
+ function se(n, l) {
70
+ return n.length === 0 || l.length === 0 ? !1 : n.split(/[^a-z0-9]+/i).some((t) => t.length > 0 && t.startsWith(l));
71
+ }
72
+ function j(n) {
73
+ return n.trim().toLocaleLowerCase();
74
+ }
75
+ const lt = ["id", "name", "value", "placeholder", "disabled", "aria-busy", "aria-invalid", "aria-expanded", "aria-activedescendant"], ot = ["data-affino-popover-sticky"], at = {
76
+ key: 0,
77
+ class: "datagrid-cell-combobox__empty"
78
+ }, it = ["id", "aria-selected", "data-option-index", "onMousemove", "onClick"], rt = { class: "datagrid-cell-combobox__option-label" }, ut = {
79
+ key: 0,
80
+ class: "datagrid-cell-combobox__option-state",
81
+ "aria-hidden": "true"
82
+ }, st = {
83
+ key: 0,
84
+ class: "datagrid-cell-combobox__empty"
85
+ }, ct = {
86
+ inheritAttrs: !1
87
+ }, xt = /* @__PURE__ */ Se({
88
+ ...ct,
89
+ __name: "DataGridFilterableCombobox",
90
+ props: {
91
+ value: {},
92
+ options: { default: () => [] },
93
+ loadOptions: {},
94
+ placeholder: { default: "Type to filter" },
95
+ disabled: { type: Boolean, default: !1 },
96
+ openOnMount: { type: Boolean, default: !0 },
97
+ initialFilter: { default: "" },
98
+ openOnFocus: { type: Boolean, default: !0 },
99
+ inlinePanel: { type: Boolean, default: !1 },
100
+ stickyPopoverId: {}
101
+ },
102
+ emits: ["commit", "cancel", "optionsResolved"],
103
+ setup(n, { emit: l }) {
104
+ const t = n, r = l, u = Pe(He, v(null)), c = Re(), k = v(null), d = v(null), L = v(null), J = v({}), G = v({}), M = v("below"), F = v(""), I = v(!1), A = v(null), B = v([]), o = v(We({ open: !1 })), S = `datagrid-filterable-combobox-${Math.random().toString(36).slice(2, 10)}`, de = `${S}-input`, ve = `${S}-field`;
105
+ let E = 0, _ = null;
106
+ const fe = s(() => {
107
+ const {
108
+ class: e,
109
+ id: a,
110
+ name: i,
111
+ style: f,
112
+ type: w,
113
+ value: le,
114
+ placeholder: oe,
115
+ disabled: dt,
116
+ onInput: vt,
117
+ onFocus: ft,
118
+ onBlur: pt,
119
+ onKeydown: mt,
120
+ onClick: bt,
121
+ ...Ae
122
+ } = c;
123
+ return Ae;
124
+ }), pe = s(() => String(c.id ?? de)), me = s(() => String(c.name ?? ve)), be = s(() => [
125
+ "cell-editor-control",
126
+ "datagrid-cell-combobox__input",
127
+ c.class
128
+ ]), he = s(() => c.style), _e = s(() => {
129
+ if (A.value)
130
+ return "true";
131
+ const e = c["aria-invalid"];
132
+ if (e === !0 || e === "true")
133
+ return "true";
134
+ if (!(e === !1 || e === "false" || e == null))
135
+ return e === "grammar" || e === "spelling" ? e : "true";
136
+ }), xe = s(() => {
137
+ if (!t.inlinePanel)
138
+ return "body";
139
+ }), H = s(() => Y.value.find((e) => e.value === t.value) ?? null), Y = s(() => t.loadOptions && B.value.length > 0 ? B.value : t.options), p = s(() => tt(Y.value, o.value.filter)), x = s(() => o.value.activeIndex), V = s(() => x.value >= 0 ? p.value[x.value] ?? null : null), ye = s(() => x.value >= 0 ? Z(x.value) : void 0), D = s(() => o.value.open);
140
+ function Z(e) {
141
+ return `${S}-option-${e}`;
142
+ }
143
+ function ge() {
144
+ J.value = Ue(u.value);
145
+ }
146
+ function U() {
147
+ F.value = H.value?.label ?? t.value;
148
+ }
149
+ function Q() {
150
+ F.value = t.initialFilter;
151
+ }
152
+ function C(e) {
153
+ const a = p.value;
154
+ if (a.length === 0) {
155
+ o.value = {
156
+ ...o.value,
157
+ activeIndex: -1
158
+ };
159
+ return;
160
+ }
161
+ let i = 0;
162
+ if (e && H.value) {
163
+ const f = a.findIndex((w) => w.value === H.value?.value);
164
+ f >= 0 && (i = f);
165
+ }
166
+ o.value = R(o.value, i, a.length);
167
+ }
168
+ async function W(e) {
169
+ if (!t.loadOptions)
170
+ return;
171
+ const a = E + 1;
172
+ E = a, I.value = !0, A.value = null;
173
+ try {
174
+ const i = await t.loadOptions(e);
175
+ if (a !== E)
176
+ return;
177
+ B.value = i, r("optionsResolved", i), C(!0), m(() => {
178
+ y(), g();
179
+ });
180
+ } catch (i) {
181
+ if (a !== E)
182
+ return;
183
+ A.value = i instanceof Error ? i.message : "options-load-failed", B.value = [], C(!1);
184
+ } finally {
185
+ a === E && (I.value = !1);
186
+ }
187
+ }
188
+ function y() {
189
+ if (t.inlinePanel) {
190
+ M.value = "below", G.value = {
191
+ position: "absolute",
192
+ top: "calc(100% - 1px)",
193
+ left: "0px",
194
+ width: "100%",
195
+ maxHeight: "260px",
196
+ zIndex: "4"
197
+ };
198
+ return;
199
+ }
200
+ if (typeof window > "u" || !d.value)
201
+ return;
202
+ const e = d.value.getBoundingClientRect(), a = Math.max(e.width, 160), i = Math.min(L.value?.offsetHeight ?? 220, 260), w = window.innerHeight - e.bottom - 8 < Math.min(180, i) && e.top > i + 12;
203
+ M.value = w ? "above" : "below";
204
+ const le = w ? Math.max(8, e.top - i + 1) : Math.min(window.innerHeight - i - 8, e.bottom - 1), oe = Math.min(
205
+ Math.max(8, e.left),
206
+ Math.max(8, window.innerWidth - a - 8)
207
+ );
208
+ G.value = {
209
+ position: "fixed",
210
+ top: `${le}px`,
211
+ left: `${oe}px`,
212
+ width: `${a}px`,
213
+ maxHeight: "260px",
214
+ zIndex: "240"
215
+ };
216
+ }
217
+ function ee() {
218
+ if (_ == null || typeof window > "u") {
219
+ _ = null;
220
+ return;
221
+ }
222
+ window.cancelAnimationFrame(_), _ = null;
223
+ }
224
+ function we() {
225
+ if (typeof window > "u") {
226
+ y();
227
+ return;
228
+ }
229
+ _ == null && (_ = window.requestAnimationFrame(() => {
230
+ _ = null, D.value && y();
231
+ }));
232
+ }
233
+ function g() {
234
+ if (!L.value || x.value < 0)
235
+ return;
236
+ L.value.querySelector(`[data-option-index="${x.value}"]`)?.scrollIntoView({ block: "nearest" });
237
+ }
238
+ function K() {
239
+ t.disabled || (o.value = P(o.value, !0), C(!0), m(() => {
240
+ if (y(), g(), d.value?.focus({ preventScroll: !0 }), !!d.value) {
241
+ if (o.value.filter.length > 0) {
242
+ const e = d.value.value.length;
243
+ d.value.setSelectionRange(e, e);
244
+ return;
245
+ }
246
+ d.value.select();
247
+ }
248
+ }), t.loadOptions && W(o.value.filter));
249
+ }
250
+ function T() {
251
+ ee(), o.value = P(o.value, !1);
252
+ }
253
+ function Ie(e) {
254
+ return e instanceof Node && (k.value?.contains(e) === !0 || L.value?.contains(e) === !0);
255
+ }
256
+ function Ee() {
257
+ if (o.value.filter.trim().length === 0)
258
+ return t.value;
259
+ if (V.value)
260
+ return V.value.value;
261
+ const e = F.value.trim().toLocaleLowerCase();
262
+ return e.length === 0 ? t.value : p.value.find((i) => i.label.trim().toLocaleLowerCase() === e || i.value.trim().toLocaleLowerCase() === e)?.value ?? t.value;
263
+ }
264
+ function te(e = "stay") {
265
+ I.value || A.value || (T(), r("commit", Ee(), e));
266
+ }
267
+ function ne(e, a = "stay") {
268
+ I.value || A.value || (T(), r("commit", e, a));
269
+ }
270
+ function X(e) {
271
+ o.value = R(o.value, e, p.value.length), m(g);
272
+ }
273
+ function Ce() {
274
+ t.openOnFocus && K();
275
+ }
276
+ function Oe() {
277
+ K();
278
+ }
279
+ function ke(e) {
280
+ if (t.disabled)
281
+ return;
282
+ const a = e.target.value;
283
+ F.value = a, o.value = q(o.value, a), o.value = P(o.value, !0), C(!1), m(() => {
284
+ y(), g();
285
+ }), t.loadOptions && W(a);
286
+ }
287
+ function Le() {
288
+ m(() => {
289
+ Ie(document.activeElement) || te("stay");
290
+ });
291
+ }
292
+ function Fe(e) {
293
+ if (!t.disabled && !(e.isComposing || e.key === "Process" || e.keyCode === 229)) {
294
+ if (e.key === "ArrowDown") {
295
+ e.preventDefault(), o.value = P(o.value, !0), o.value = ue(o.value, 1, p.value.length, !0), m(g);
296
+ return;
297
+ }
298
+ if (e.key === "ArrowUp") {
299
+ e.preventDefault(), o.value = P(o.value, !0), o.value = ue(o.value, -1, p.value.length, !0), m(g);
300
+ return;
301
+ }
302
+ if (e.key === "Home") {
303
+ e.preventDefault(), X(0);
304
+ return;
305
+ }
306
+ if (e.key === "End") {
307
+ e.preventDefault(), X(Math.max(0, p.value.length - 1));
308
+ return;
309
+ }
310
+ if (e.key === "Enter" || e.key === "Tab") {
311
+ if (e.preventDefault(), V.value) {
312
+ ne(V.value.value, e.shiftKey ? "previous" : "next");
313
+ return;
314
+ }
315
+ te(e.shiftKey ? "previous" : "next");
316
+ return;
317
+ }
318
+ e.key === "Escape" && (e.preventDefault(), T(), r("cancel"));
319
+ }
320
+ }
321
+ function N() {
322
+ D.value && we();
323
+ }
324
+ return $(() => t.options, () => {
325
+ t.loadOptions || (C(!0), m(y));
326
+ }, { immediate: !0 }), $(() => t.value, () => {
327
+ U();
328
+ }), $(() => t.initialFilter, (e) => {
329
+ document.activeElement !== d.value && (o.value = q(o.value, e), e.length > 0 ? (Q(), W(e)) : U(), C(!0), m(() => {
330
+ y(), g();
331
+ }));
332
+ }), $(() => t.disabled, (e) => {
333
+ e && T();
334
+ }), Me(() => {
335
+ ge(), t.initialFilter.length > 0 ? (o.value = q(o.value, t.initialFilter), Q()) : U(), t.openOnMount && K(), typeof window < "u" && (window.addEventListener("resize", N), window.addEventListener("scroll", N, { capture: !0, passive: !0 }));
336
+ }), Be(() => {
337
+ E += 1, ee(), typeof window < "u" && (window.removeEventListener("resize", N), window.removeEventListener("scroll", N, { capture: !0 }));
338
+ }), (e, a) => (b(), h("div", {
339
+ ref_key: "rootEl",
340
+ ref: k,
341
+ class: "datagrid-cell-combobox"
342
+ }, [
343
+ ae("input", Ve({
344
+ ref_key: "inputEl",
345
+ ref: d
346
+ }, fe.value, {
347
+ id: pe.value,
348
+ name: me.value,
349
+ class: be.value,
350
+ style: he.value,
351
+ type: "text",
352
+ role: "combobox",
353
+ value: F.value,
354
+ placeholder: e.placeholder,
355
+ disabled: e.disabled,
356
+ "aria-busy": I.value ? "true" : void 0,
357
+ "aria-invalid": _e.value,
358
+ "aria-expanded": D.value ? "true" : "false",
359
+ "aria-controls": S,
360
+ "aria-autocomplete": "list",
361
+ "aria-activedescendant": ye.value,
362
+ onFocus: Ce,
363
+ onMousedown: a[0] || (a[0] = O(() => {
364
+ }, ["stop"])),
365
+ onContextmenu: a[1] || (a[1] = O(() => {
366
+ }, ["stop"])),
367
+ onClick: O(Oe, ["stop"]),
368
+ onInput: ke,
369
+ onKeydown: O(Fe, ["stop"]),
370
+ onBlur: Le
371
+ }), null, 16, lt),
372
+ (b(), De(Te, {
373
+ to: xe.value,
374
+ disabled: e.inlinePanel
375
+ }, [
376
+ D.value ? (b(), h("div", {
377
+ key: 0,
378
+ id: S,
379
+ ref_key: "panelEl",
380
+ ref: L,
381
+ class: ie(["datagrid-cell-combobox__panel", {
382
+ "datagrid-cell-combobox__panel--inline": e.inlinePanel,
383
+ "datagrid-cell-combobox__panel--attached-below": M.value === "below",
384
+ "datagrid-cell-combobox__panel--attached-above": M.value === "above"
385
+ }]),
386
+ "data-affino-popover-sticky": e.stickyPopoverId || void 0,
387
+ style: Ne([J.value, G.value]),
388
+ role: "listbox",
389
+ onMousedown: a[2] || (a[2] = O(() => {
390
+ }, ["prevent"]))
391
+ }, [
392
+ I.value ? (b(), h("div", at, "Loading options...")) : (b(), h(re, { key: 1 }, [
393
+ (b(!0), h(re, null, $e(p.value, (i, f) => (b(), h("button", {
394
+ id: Z(f),
395
+ key: `${i.value}-${f}`,
396
+ type: "button",
397
+ class: ie(["datagrid-cell-combobox__option", {
398
+ "datagrid-cell-combobox__option--active": f === x.value,
399
+ "datagrid-cell-combobox__option--selected": i.value === e.value
400
+ }]),
401
+ role: "option",
402
+ "aria-selected": i.value === e.value ? "true" : "false",
403
+ "data-option-index": f,
404
+ onMousemove: (w) => X(f),
405
+ onClick: O((w) => ne(i.value), ["stop"])
406
+ }, [
407
+ ae("span", rt, Ge(i.label), 1),
408
+ i.value === e.value ? (b(), h("span", ut)) : z("", !0)
409
+ ], 42, it))), 128)),
410
+ p.value.length === 0 ? (b(), h("div", st, " No matching options ")) : z("", !0)
411
+ ], 64))
412
+ ], 46, ot)) : z("", !0)
413
+ ], 8, ["to", "disabled"]))
414
+ ], 512));
415
+ }
416
+ });
417
+ export {
418
+ xt as _
419
+ };