@affino/datagrid-vue-app 0.1.2 → 0.1.3

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 (26) hide show
  1. package/dist/DataGrid.d.ts +4 -4
  2. package/dist/advanced-filter.d.ts +2 -0
  3. package/dist/advanced-filter.js +4 -0
  4. package/dist/chunks/DataGridAdvancedFilterPopover-Bak_CkaO.js +4 -0
  5. package/dist/chunks/DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-DixN56Qv.js +226 -0
  6. package/dist/chunks/DataGridAggregationsPopover-DfQ3-UV4.js +173 -0
  7. package/dist/chunks/DataGridColumnLayoutPopover-Qt56b3CA.js +136 -0
  8. package/dist/chunks/DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-_1TDQseN.js +399 -0
  9. package/dist/chunks/DataGridGanttStage.vue_vue_type_script_setup_true_lang-CYwB5Dpa.js +916 -0
  10. package/dist/chunks/DataGridGanttStageEntry-B9YlOHt1.js +40 -0
  11. package/dist/chunks/DataGridTableStage.vue_vue_type_script_setup_true_lang-BJJoBCsA.js +6681 -0
  12. package/dist/chunks/useDataGridAppRowModel-Di-Zatjs.js +2761 -0
  13. package/dist/gantt/DataGridGanttStageEntry.d.ts +52 -0
  14. package/dist/gantt.d.ts +3 -0
  15. package/dist/gantt.js +8 -0
  16. package/dist/host/DataGridRuntimeHost.d.ts +2 -2
  17. package/dist/index.js +32 -30
  18. package/dist/internal.js +39 -35
  19. package/dist/overlays/DataGridAdvancedFilterPopover.vue.d.ts +5 -5
  20. package/dist/overlays/DataGridAggregationsPopover.vue.d.ts +4 -4
  21. package/dist/overlays/DataGridColumnLayoutPopover.vue.d.ts +4 -4
  22. package/dist/overlays/DataGridColumnMenu.vue.d.ts +2 -2
  23. package/dist/overlays/DataGridFilterableCombobox.vue.d.ts +2 -2
  24. package/dist/stage/DataGridTableStageCenterPane.vue.d.ts +1 -1
  25. package/package.json +12 -4
  26. package/dist/chunks/useDataGridAppRowModel-CcTL-h8L.js +0 -11251
@@ -0,0 +1,399 @@
1
+ import { defineComponent as ye, inject as we, ref as s, useAttrs as Ee, computed as d, watch as G, nextTick as b, onMounted as Ie, onBeforeUnmount as Oe, openBlock as p, createElementBlock as g, createElementVNode as ee, mergeProps as Ce, withModifiers as F, createBlock as ke, Teleport as Ae, normalizeStyle as Le, normalizeClass as te, Fragment as ne, renderList as Re, toDisplayString as Se, createCommentVNode as H } from "vue";
2
+ const Fe = Symbol("affino-datagrid-app-root-element"), Me = [
3
+ "--datagrid-font-family",
4
+ "--datagrid-font-size",
5
+ "--datagrid-text-primary",
6
+ "--datagrid-text-muted",
7
+ "--datagrid-text-soft",
8
+ "--datagrid-accent-strong",
9
+ "--datagrid-glass-border",
10
+ "--datagrid-background-color",
11
+ "--datagrid-editor-bg",
12
+ "--datagrid-filter-trigger-border",
13
+ "--datagrid-column-menu-bg",
14
+ "--datagrid-column-menu-border",
15
+ "--datagrid-column-menu-shadow",
16
+ "--datagrid-column-menu-item-hover-bg",
17
+ "--datagrid-column-menu-muted-text",
18
+ "--datagrid-column-menu-focus-ring",
19
+ "--datagrid-column-menu-search-border",
20
+ "--datagrid-column-menu-search-bg",
21
+ "--datagrid-sort-indicator-color"
22
+ ];
23
+ function Ve(n) {
24
+ if (!n || typeof window > "u")
25
+ return {};
26
+ const o = window.getComputedStyle(n), t = {};
27
+ for (const l of Me)
28
+ t[l] = o.getPropertyValue(l).trim();
29
+ return t;
30
+ }
31
+ function De(n = {}) {
32
+ return {
33
+ open: n.open ?? !1,
34
+ filter: n.filter ?? "",
35
+ activeIndex: n.activeIndex ?? -1
36
+ };
37
+ }
38
+ function I(n, o) {
39
+ return n.open === o ? n : {
40
+ ...n,
41
+ open: o
42
+ };
43
+ }
44
+ function oe(n, o) {
45
+ return n.filter === o ? n : {
46
+ ...n,
47
+ filter: o
48
+ };
49
+ }
50
+ function O(n, o, t) {
51
+ const l = Te(o, t);
52
+ return l === n.activeIndex ? n : {
53
+ ...n,
54
+ activeIndex: l
55
+ };
56
+ }
57
+ function ae(n, o, t, l = !0) {
58
+ if (t <= 0 || o === 0)
59
+ return n;
60
+ if (n.activeIndex < 0)
61
+ return O(n, o > 0 ? 0 : t - 1, t);
62
+ const u = n.activeIndex + Math.trunc(o);
63
+ return l ? O(n, Be(u, t), t) : O(n, u, t);
64
+ }
65
+ function Te(n, o) {
66
+ if (o <= 0)
67
+ return -1;
68
+ if (!Number.isFinite(n))
69
+ return 0;
70
+ const t = Math.trunc(n);
71
+ return t < 0 ? 0 : t >= o ? o - 1 : t;
72
+ }
73
+ function Be(n, o) {
74
+ return (n % o + o) % o;
75
+ }
76
+ const Pe = 0, Ne = 1, $e = 2, Ge = 3, He = 4, We = 5, Ke = 6, Ue = 7, ie = 100;
77
+ function Xe(n, o) {
78
+ const t = W(o);
79
+ if (t.length === 0)
80
+ return [...n];
81
+ const l = n.map((u, f) => ({
82
+ option: u,
83
+ score: ze(u, t),
84
+ originalIndex: f
85
+ })).filter((u) => u.score < ie);
86
+ return l.sort((u, f) => {
87
+ if (u.score !== f.score)
88
+ return u.score - f.score;
89
+ const y = u.option.label.length, c = f.option.label.length;
90
+ return y !== c ? y - c : u.originalIndex - f.originalIndex;
91
+ }), l.map((u) => u.option);
92
+ }
93
+ function ze(n, o) {
94
+ const t = W(n.label), l = W(n.value);
95
+ return t === o ? Pe : l === o ? Ne : t.startsWith(o) ? $e : l.startsWith(o) ? Ge : le(t, o) ? He : le(l, o) ? We : t.includes(o) ? Ke : l.includes(o) ? Ue : ie;
96
+ }
97
+ function le(n, o) {
98
+ return n.length === 0 || o.length === 0 ? !1 : n.split(/[^a-z0-9]+/i).some((t) => t.length > 0 && t.startsWith(o));
99
+ }
100
+ function W(n) {
101
+ return n.trim().toLocaleLowerCase();
102
+ }
103
+ const qe = ["value", "placeholder", "disabled", "aria-expanded", "aria-activedescendant"], je = ["data-affino-popover-sticky"], Ye = {
104
+ key: 0,
105
+ class: "datagrid-cell-combobox__empty"
106
+ }, Je = ["id", "aria-selected", "data-option-index", "onMousemove", "onClick"], Ze = { class: "datagrid-cell-combobox__option-label" }, Qe = {
107
+ key: 0,
108
+ class: "datagrid-cell-combobox__option-state",
109
+ "aria-hidden": "true"
110
+ }, et = {
111
+ key: 0,
112
+ class: "datagrid-cell-combobox__empty"
113
+ }, tt = {
114
+ inheritAttrs: !1
115
+ }, rt = /* @__PURE__ */ ye({
116
+ ...tt,
117
+ __name: "DataGridFilterableCombobox",
118
+ props: {
119
+ value: {},
120
+ options: { default: () => [] },
121
+ loadOptions: {},
122
+ placeholder: { default: "Type to filter" },
123
+ disabled: { type: Boolean, default: !1 },
124
+ openOnMount: { type: Boolean, default: !0 },
125
+ initialFilter: { default: "" },
126
+ openOnFocus: { type: Boolean, default: !0 },
127
+ inlinePanel: { type: Boolean, default: !1 },
128
+ stickyPopoverId: {}
129
+ },
130
+ emits: ["commit", "cancel", "optionsResolved"],
131
+ setup(n, { emit: o }) {
132
+ const t = n, l = o, u = we(Fe, s(null)), f = Ee(), y = s(null), c = s(null), w = s(null), K = s({}), M = s({}), C = s("below"), k = s(""), V = s(!1), D = s([]), a = s(De({ open: !1 })), T = `datagrid-filterable-combobox-${Math.random().toString(36).slice(2, 10)}`;
133
+ let A = 0;
134
+ const re = d(() => {
135
+ const {
136
+ class: e,
137
+ style: i,
138
+ type: r,
139
+ value: v,
140
+ placeholder: _,
141
+ disabled: Z,
142
+ onInput: Q,
143
+ onFocus: nt,
144
+ onBlur: ot,
145
+ onKeydown: at,
146
+ onClick: lt,
147
+ ...xe
148
+ } = f;
149
+ return xe;
150
+ }), ue = d(() => [
151
+ "cell-editor-control",
152
+ "datagrid-cell-combobox__input",
153
+ f.class
154
+ ]), ce = d(() => f.style), se = d(() => {
155
+ if (!t.inlinePanel)
156
+ return "body";
157
+ }), B = d(() => U.value.find((e) => e.value === t.value) ?? null), U = d(() => t.loadOptions && D.value.length > 0 ? D.value : t.options), m = d(() => Xe(U.value, a.value.filter)), h = d(() => a.value.activeIndex), X = d(() => h.value >= 0 ? m.value[h.value] ?? null : null), de = d(() => h.value >= 0 ? z(h.value) : void 0), P = d(() => a.value.open);
158
+ function z(e) {
159
+ return `${T}-option-${e}`;
160
+ }
161
+ function fe() {
162
+ K.value = Ve(u.value);
163
+ }
164
+ function q() {
165
+ k.value = B.value?.label ?? t.value;
166
+ }
167
+ function ve() {
168
+ k.value = t.initialFilter;
169
+ }
170
+ function L(e) {
171
+ const i = m.value;
172
+ if (i.length === 0) {
173
+ a.value = {
174
+ ...a.value,
175
+ activeIndex: -1
176
+ };
177
+ return;
178
+ }
179
+ let r = 0;
180
+ if (e && B.value) {
181
+ const v = i.findIndex((_) => _.value === B.value?.value);
182
+ v >= 0 && (r = v);
183
+ }
184
+ a.value = O(a.value, r, i.length);
185
+ }
186
+ async function j(e) {
187
+ if (!t.loadOptions)
188
+ return;
189
+ const i = A + 1;
190
+ A = i, V.value = !0;
191
+ try {
192
+ const r = await t.loadOptions(e);
193
+ if (i !== A)
194
+ return;
195
+ D.value = r, l("optionsResolved", r), L(!0), b(() => {
196
+ E(), x();
197
+ });
198
+ } finally {
199
+ i === A && (V.value = !1);
200
+ }
201
+ }
202
+ function E() {
203
+ if (t.inlinePanel) {
204
+ C.value = "below", M.value = {
205
+ position: "absolute",
206
+ top: "calc(100% - 1px)",
207
+ left: "0px",
208
+ width: "100%",
209
+ maxHeight: "260px",
210
+ zIndex: "4"
211
+ };
212
+ return;
213
+ }
214
+ if (typeof window > "u" || !c.value)
215
+ return;
216
+ const e = c.value.getBoundingClientRect(), i = Math.max(e.width, 160), r = Math.min(w.value?.offsetHeight ?? 220, 260), _ = window.innerHeight - e.bottom - 8 < Math.min(180, r) && e.top > r + 12;
217
+ C.value = _ ? "above" : "below";
218
+ const Z = _ ? Math.max(8, e.top - r + 1) : Math.min(window.innerHeight - r - 8, e.bottom - 1), Q = Math.min(
219
+ Math.max(8, e.left),
220
+ Math.max(8, window.innerWidth - i - 8)
221
+ );
222
+ M.value = {
223
+ position: "fixed",
224
+ top: `${Z}px`,
225
+ left: `${Q}px`,
226
+ width: `${i}px`,
227
+ maxHeight: "260px",
228
+ zIndex: "240"
229
+ };
230
+ }
231
+ function x() {
232
+ if (!w.value || h.value < 0)
233
+ return;
234
+ w.value.querySelector(`[data-option-index="${h.value}"]`)?.scrollIntoView({ block: "nearest" });
235
+ }
236
+ function N() {
237
+ t.disabled || (a.value = I(a.value, !0), L(!0), b(() => {
238
+ if (E(), x(), c.value?.focus({ preventScroll: !0 }), !!c.value) {
239
+ if (a.value.filter.length > 0) {
240
+ const e = c.value.value.length;
241
+ c.value.setSelectionRange(e, e);
242
+ return;
243
+ }
244
+ c.value.select();
245
+ }
246
+ }), t.loadOptions && j(a.value.filter));
247
+ }
248
+ function R() {
249
+ a.value = I(a.value, !1);
250
+ }
251
+ function pe(e) {
252
+ return e instanceof Node && (y.value?.contains(e) === !0 || w.value?.contains(e) === !0);
253
+ }
254
+ function Y(e = "stay") {
255
+ R(), l("commit", t.value, e);
256
+ }
257
+ function J(e, i = "stay") {
258
+ R(), l("commit", e, i);
259
+ }
260
+ function $(e) {
261
+ a.value = O(a.value, e, m.value.length), b(x);
262
+ }
263
+ function me() {
264
+ t.openOnFocus && N();
265
+ }
266
+ function be() {
267
+ N();
268
+ }
269
+ function ge(e) {
270
+ if (t.disabled)
271
+ return;
272
+ const i = e.target.value;
273
+ k.value = i, a.value = oe(a.value, i), a.value = I(a.value, !0), L(!1), b(() => {
274
+ E(), x();
275
+ }), t.loadOptions && j(i);
276
+ }
277
+ function he() {
278
+ b(() => {
279
+ pe(document.activeElement) || Y("stay");
280
+ });
281
+ }
282
+ function _e(e) {
283
+ if (!t.disabled) {
284
+ if (e.key === "ArrowDown") {
285
+ e.preventDefault(), a.value = I(a.value, !0), a.value = ae(a.value, 1, m.value.length, !0), b(x);
286
+ return;
287
+ }
288
+ if (e.key === "ArrowUp") {
289
+ e.preventDefault(), a.value = I(a.value, !0), a.value = ae(a.value, -1, m.value.length, !0), b(x);
290
+ return;
291
+ }
292
+ if (e.key === "Home") {
293
+ e.preventDefault(), $(0);
294
+ return;
295
+ }
296
+ if (e.key === "End") {
297
+ e.preventDefault(), $(Math.max(0, m.value.length - 1));
298
+ return;
299
+ }
300
+ if (e.key === "Enter" || e.key === "Tab") {
301
+ if (e.preventDefault(), X.value) {
302
+ J(X.value.value, e.shiftKey ? "previous" : "next");
303
+ return;
304
+ }
305
+ Y(e.shiftKey ? "previous" : "next");
306
+ return;
307
+ }
308
+ e.key === "Escape" && (e.preventDefault(), R(), l("cancel"));
309
+ }
310
+ }
311
+ function S() {
312
+ P.value && E();
313
+ }
314
+ return G(() => t.options, () => {
315
+ t.loadOptions || (L(!0), b(E));
316
+ }, { immediate: !0 }), G(() => t.value, () => {
317
+ q();
318
+ }), G(() => t.disabled, (e) => {
319
+ e && R();
320
+ }), Ie(() => {
321
+ fe(), t.initialFilter.length > 0 ? (a.value = oe(a.value, t.initialFilter), ve()) : q(), t.openOnMount && N(), typeof window < "u" && (window.addEventListener("resize", S), window.addEventListener("scroll", S, !0));
322
+ }), Oe(() => {
323
+ typeof window < "u" && (window.removeEventListener("resize", S), window.removeEventListener("scroll", S, !0));
324
+ }), (e, i) => (p(), g("div", {
325
+ ref_key: "rootEl",
326
+ ref: y,
327
+ class: "datagrid-cell-combobox"
328
+ }, [
329
+ ee("input", Ce({
330
+ ref_key: "inputEl",
331
+ ref: c
332
+ }, re.value, {
333
+ class: ue.value,
334
+ style: ce.value,
335
+ type: "text",
336
+ role: "combobox",
337
+ value: k.value,
338
+ placeholder: e.placeholder,
339
+ disabled: e.disabled,
340
+ "aria-expanded": P.value ? "true" : "false",
341
+ "aria-controls": T,
342
+ "aria-autocomplete": "list",
343
+ "aria-activedescendant": de.value,
344
+ onFocus: me,
345
+ onClick: F(be, ["stop"]),
346
+ onInput: ge,
347
+ onKeydown: F(_e, ["stop"]),
348
+ onBlur: he
349
+ }), null, 16, qe),
350
+ (p(), ke(Ae, {
351
+ to: se.value,
352
+ disabled: e.inlinePanel
353
+ }, [
354
+ P.value ? (p(), g("div", {
355
+ key: 0,
356
+ id: T,
357
+ ref_key: "panelEl",
358
+ ref: w,
359
+ class: te(["datagrid-cell-combobox__panel", {
360
+ "datagrid-cell-combobox__panel--inline": e.inlinePanel,
361
+ "datagrid-cell-combobox__panel--attached-below": C.value === "below",
362
+ "datagrid-cell-combobox__panel--attached-above": C.value === "above"
363
+ }]),
364
+ "data-affino-popover-sticky": e.stickyPopoverId || void 0,
365
+ style: Le([K.value, M.value]),
366
+ role: "listbox",
367
+ onMousedown: i[0] || (i[0] = F(() => {
368
+ }, ["prevent"]))
369
+ }, [
370
+ V.value ? (p(), g("div", Ye, "Loading options...")) : (p(), g(ne, { key: 1 }, [
371
+ (p(!0), g(ne, null, Re(m.value, (r, v) => (p(), g("button", {
372
+ id: z(v),
373
+ key: `${r.value}-${v}`,
374
+ type: "button",
375
+ class: te(["datagrid-cell-combobox__option", {
376
+ "datagrid-cell-combobox__option--active": v === h.value,
377
+ "datagrid-cell-combobox__option--selected": r.value === e.value
378
+ }]),
379
+ role: "option",
380
+ "aria-selected": r.value === e.value ? "true" : "false",
381
+ "data-option-index": v,
382
+ onMousemove: (_) => $(v),
383
+ onClick: F((_) => J(r.value), ["stop"])
384
+ }, [
385
+ ee("span", Ze, Se(r.label), 1),
386
+ r.value === e.value ? (p(), g("span", Qe)) : H("", !0)
387
+ ], 42, Je))), 128)),
388
+ m.value.length === 0 ? (p(), g("div", et, " No matching options ")) : H("", !0)
389
+ ], 64))
390
+ ], 46, je)) : H("", !0)
391
+ ], 8, ["to", "disabled"]))
392
+ ], 512));
393
+ }
394
+ });
395
+ export {
396
+ rt as _,
397
+ Fe as d,
398
+ Ve as r
399
+ };