@ishibashi0112/spreadsheet-grid 1.0.0 → 1.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 (60) hide show
  1. package/API_REFERENCE.md +99 -82
  2. package/README.md +4 -4
  3. package/dist/ColumnFilterPopover-VHTWLyQ7.cjs +1 -0
  4. package/dist/ColumnFilterPopover-xCX4O5Pb.js +1036 -0
  5. package/dist/editors/DateCellEditor.d.ts +2 -1
  6. package/dist/editors/NumberCellEditor.d.ts +2 -1
  7. package/dist/editors/SelectCellEditor.d.ts +2 -1
  8. package/dist/editors/TextCellEditor.d.ts +2 -1
  9. package/dist/hooks/useColumnSelectOptionsCollector.d.ts +2 -1
  10. package/dist/hooks/useGridViewportSync.d.ts +2 -1
  11. package/dist/index.cjs +7 -7
  12. package/dist/index.js +2875 -2771
  13. package/dist/lite/ColumnFilterPopover-BNzAJgCT.js +1036 -0
  14. package/dist/lite/ColumnFilterPopover-Dusx2AfV.cjs +1 -0
  15. package/dist/lite/columnMenu-C8LMgSDh.cjs +1 -0
  16. package/dist/lite/{columnMenu-tZSAVFch.js → columnMenu-DImtqeXz.js} +27 -12
  17. package/dist/lite/createSpreadsheetGrid-BsuvhGwN.cjs +7 -0
  18. package/dist/lite/createSpreadsheetGrid-CcUZV9Nl.js +4383 -0
  19. package/dist/lite/createSpreadsheetGrid.cjs +1 -1
  20. package/dist/lite/createSpreadsheetGrid.js +1 -1
  21. package/dist/lite/features/columnMenu.cjs +1 -1
  22. package/dist/lite/features/columnMenu.js +1 -1
  23. package/dist/lite/features/filtering.cjs +1 -1
  24. package/dist/lite/features/filtering.js +1 -1
  25. package/dist/lite/features/selectionAggregates.cjs +1 -1
  26. package/dist/lite/features/selectionAggregates.js +1 -1
  27. package/dist/lite/features/standard.cjs +1 -1
  28. package/dist/lite/features/standard.js +3 -3
  29. package/dist/lite/features/toolPanel.cjs +1 -1
  30. package/dist/lite/features/toolPanel.js +1 -1
  31. package/dist/lite/{filtering-DWiGawv7.js → filtering-BJD9TbJf.js} +14 -10
  32. package/dist/lite/filtering-CTgteY8F.cjs +1 -0
  33. package/dist/lite/{lazyPopups-BJXlFn1p.cjs → lazyPopups-BQZ_tQmx.cjs} +1 -1
  34. package/dist/lite/{lazyPopups-DVqRlLJf.js → lazyPopups-DbZ9rUbb.js} +1 -1
  35. package/dist/lite/{selectionAggregates-D5TcCyB5.cjs → selectionAggregates-CP0_LaAu.cjs} +1 -1
  36. package/dist/lite/{selectionAggregates-3u3kJh4W.js → selectionAggregates-CS_VR9ev.js} +14 -7
  37. package/dist/lite/{toolPanel-DZFTU5l3.js → toolPanel-DZ6JUS79.js} +1 -1
  38. package/dist/lite/{toolPanel-E0gQydUn.cjs → toolPanel-RciyWlun.cjs} +1 -1
  39. package/dist/lite/{toolPanelViews-CbMCZSFx.js → toolPanelViews-DYrngzT1.js} +2 -1
  40. package/dist/lite/toolPanelViews-DgY7fFl7.cjs +1 -0
  41. package/dist/lite.cjs +1 -1
  42. package/dist/lite.js +6 -6
  43. package/dist/style.css +1 -1
  44. package/dist/style.layer.css +1 -1
  45. package/dist/themes/heroui.css +2 -1
  46. package/dist/themes/shadcn.css +2 -1
  47. package/dist/toolPanelViews-BdtqSCJ6.cjs +1 -0
  48. package/dist/{toolPanelViews-BywJx-1p.js → toolPanelViews-C7C1j-ss.js} +2 -1
  49. package/package.json +2 -2
  50. package/skills/spreadsheet-grid/SKILL.md +7 -7
  51. package/dist/ColumnFilterPopover-BPUTyi1X.js +0 -1023
  52. package/dist/ColumnFilterPopover-C0BaV7ne.cjs +0 -1
  53. package/dist/lite/ColumnFilterPopover-CRrelKCm.cjs +0 -1
  54. package/dist/lite/ColumnFilterPopover-DZj1S5tC.js +0 -1023
  55. package/dist/lite/columnMenu-Dp1_-G7T.cjs +0 -1
  56. package/dist/lite/createSpreadsheetGrid--0D_J_WV.js +0 -4305
  57. package/dist/lite/createSpreadsheetGrid-BVm9M39W.cjs +0 -7
  58. package/dist/lite/filtering-SjDjhxZN.cjs +0 -1
  59. package/dist/lite/toolPanelViews-CRRJt6BV.cjs +0 -1
  60. package/dist/toolPanelViews-lSrwZauC.cjs +0 -1
@@ -1,1023 +0,0 @@
1
- import { o as e } from "./useGridLocaleText-B4ZVUbqa.js";
2
- import { t } from "./useVirtualizerCore-BubgiDzY.js";
3
- import { t as n } from "./usePopupLocaleText-u-9PpBon.js";
4
- import { useDeferredValue as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
5
- import { cx as c } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/cx";
6
- import { createPortal as l } from "react-dom";
7
- import { isImeComposingKeyEvent as u } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/domGuards";
8
- import { formatLocaleText as d } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeText";
9
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
10
- import { toDateKey as h } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/filtering";
11
- import { normalizeDateFilterPresets as ee } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/dateFilterPresets";
12
- import { DEFAULT_FILTER_LOCALE_TEXT as g } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFilters";
13
- import { filterSetOptionsBySearch as _, resolveSetFilterEnterAction as v } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/setFilterSearch";
14
- import { isSetValueSelected as y } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/setFilterSelection";
15
- import { DEFAULT_NUMBER_FILTER_DRAFT as b, NUMBER_FILTER_OPERATOR_OPTIONS as x, buildParsedNumberFilterFromDraft as S, filterOptionsByNumberCondition as C, numberFilterOperandCount as w } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/numberFilterCondition";
16
- import { DEFAULT_TEXT_FILTER_DRAFT as T, TEXT_FILTER_OPERATOR_OPTIONS as E, buildParsedTextFilterFromDraft as D, filterOptionsByTextCondition as O, textFilterOperandCount as k } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/textFilterCondition";
17
- import { DATE_FILTER_OPERATOR_OPTIONS as A, DEFAULT_DATE_FILTER_DRAFT as j, buildParsedDateFilterFromDraft as M, dateFilterOperandCount as N, filterOptionsByDateCondition as P, normalizeFilterDateInputValue as F } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/dateFilterCondition";
18
- import { buildCalendarDayCells as I, buildYearGrid as L, formatFilterDateDisplay as R, yearGridStart as z } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/datePickerCalendar";
19
- import { buildDateTreeRows as B } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/dateFilterTree";
20
- //#region src/view/FilterDateField.tsx
21
- function V({ value: e, onCommit: t, ariaLabel: r, inputRef: a, onRequestClose: l, align: ee = "left" }) {
22
- let g = n(), [_, v] = s(null), [y, b] = s(!1), [x, S] = s(!1), [C, w] = s("days"), [T, E] = s(() => (/* @__PURE__ */ new Date()).getFullYear()), [D, O] = s(() => (/* @__PURE__ */ new Date()).getMonth()), k = o(null), A = _ ?? R(e), j = h(/* @__PURE__ */ new Date()) ?? "", M = () => {
23
- if (_ === null) return;
24
- let e = _.trim();
25
- if (e === "") {
26
- t(""), v(null), b(!1);
27
- return;
28
- }
29
- let n = h(e);
30
- if (n === null) {
31
- b(!0);
32
- return;
33
- }
34
- t(n), v(null), b(!1);
35
- }, N = () => {
36
- let [t, n] = (e === "" ? j : e).split("-");
37
- E(Number(t)), O(Number(n) - 1), w("days"), S(!0);
38
- }, P = () => {
39
- S(!1);
40
- }, F = (e) => {
41
- t(e), v(null), b(!1), P();
42
- };
43
- i(() => {
44
- if (!x) return;
45
- let e = (e) => {
46
- let t = e.target;
47
- t && k.current?.contains(t) || S(!1);
48
- };
49
- return document.addEventListener("pointerdown", e, !0), () => {
50
- document.removeEventListener("pointerdown", e, !0);
51
- };
52
- }, [x]);
53
- let B = (e) => {
54
- if (e.stopPropagation(), e.key === "Enter") {
55
- if (u(e.nativeEvent)) return;
56
- e.preventDefault(), M(), P();
57
- return;
58
- }
59
- if (e.key === "Escape") {
60
- if (e.preventDefault(), x) {
61
- P();
62
- return;
63
- }
64
- l();
65
- }
66
- }, V = (e) => ({
67
- onPointerDown: (t) => {
68
- t.preventDefault(), t.stopPropagation(), e();
69
- },
70
- onKeyDown: (t) => {
71
- if (t.stopPropagation(), t.key === "Enter" || t.key === " ") {
72
- t.preventDefault(), e();
73
- return;
74
- }
75
- if (t.key === "Escape") {
76
- if (t.preventDefault(), x) {
77
- P(), t.currentTarget.closest(".ssg-dp-root")?.querySelector(".ssg-dp-input")?.focus();
78
- return;
79
- }
80
- l();
81
- }
82
- }
83
- }), H = (e) => {
84
- if (C === "days") {
85
- let t = new Date(T, D + e, 1);
86
- E(t.getFullYear()), O(t.getMonth());
87
- return;
88
- }
89
- if (C === "months") {
90
- E((t) => t + e);
91
- return;
92
- }
93
- E((t) => t + e * 12);
94
- }, U = () => {
95
- w((e) => e === "days" ? "months" : "years");
96
- }, W = () => {
97
- w((e) => e === "years" ? "months" : "days");
98
- }, G = C === "days" ? d(g.calendarTitle, {
99
- year: T,
100
- month: D + 1
101
- }) : C === "months" ? d(g.calendarYear, { year: T }) : `${z(T)} – ${z(T) + 11}`;
102
- return /* @__PURE__ */ m("div", {
103
- ref: k,
104
- className: "ssg-dp-root",
105
- children: [/* @__PURE__ */ m("div", {
106
- className: c("ssg-dp-field", x && "ssg-dp-field--open", y && "ssg-dp-field--invalid"),
107
- children: [/* @__PURE__ */ p("input", {
108
- ref: a,
109
- type: "text",
110
- inputMode: "numeric",
111
- value: A,
112
- placeholder: "yyyy/mm/dd",
113
- "aria-label": r,
114
- "aria-invalid": y || void 0,
115
- className: "ssg-dp-input",
116
- onChange: (e) => {
117
- v(e.target.value), b(!1);
118
- },
119
- onKeyDown: B,
120
- onBlur: M
121
- }), /* @__PURE__ */ p("button", {
122
- type: "button",
123
- className: "ssg-dp-cal-btn",
124
- "aria-label": x ? g.calendarClose : g.calendarOpen,
125
- ...V(() => {
126
- x ? P() : N();
127
- }),
128
- children: /* @__PURE__ */ m("svg", {
129
- width: "12",
130
- height: "12",
131
- viewBox: "0 0 16 16",
132
- "aria-hidden": "true",
133
- children: [
134
- /* @__PURE__ */ p("rect", {
135
- x: "1.5",
136
- y: "2.5",
137
- width: "13",
138
- height: "12",
139
- rx: "1.5",
140
- fill: "none",
141
- stroke: "currentColor"
142
- }),
143
- /* @__PURE__ */ p("line", {
144
- x1: "1.5",
145
- y1: "6",
146
- x2: "14.5",
147
- y2: "6",
148
- stroke: "currentColor"
149
- }),
150
- /* @__PURE__ */ p("line", {
151
- x1: "5",
152
- y1: "1",
153
- x2: "5",
154
- y2: "4",
155
- stroke: "currentColor"
156
- }),
157
- /* @__PURE__ */ p("line", {
158
- x1: "11",
159
- y1: "1",
160
- x2: "11",
161
- y2: "4",
162
- stroke: "currentColor"
163
- })
164
- ]
165
- })
166
- })]
167
- }), x && /* @__PURE__ */ m("div", {
168
- className: c("ssg-dp-panel", ee === "right" && "ssg-dp-panel--right"),
169
- children: [
170
- /* @__PURE__ */ m("div", {
171
- className: "ssg-dp-nav",
172
- children: [
173
- /* @__PURE__ */ p("button", {
174
- type: "button",
175
- className: "ssg-dp-nav-btn",
176
- "aria-label": g.calendarPrevious,
177
- ...V(() => H(-1)),
178
- children: "‹"
179
- }),
180
- /* @__PURE__ */ p("button", {
181
- type: "button",
182
- className: "ssg-dp-nav-title",
183
- disabled: C === "years",
184
- "aria-label": g.calendarChangeView,
185
- ...V(U),
186
- children: G
187
- }),
188
- /* @__PURE__ */ p("button", {
189
- type: "button",
190
- className: "ssg-dp-nav-btn",
191
- "aria-label": g.calendarNext,
192
- ...V(() => H(1)),
193
- children: "›"
194
- })
195
- ]
196
- }),
197
- C === "days" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", {
198
- className: "ssg-dp-dow",
199
- children: g.calendarWeekdays.map((e, t) => /* @__PURE__ */ p("span", {
200
- className: c(t === 0 && "ssg-dp-dow--sun", t === 6 && "ssg-dp-dow--sat"),
201
- children: e
202
- }, t))
203
- }), /* @__PURE__ */ p("div", {
204
- className: "ssg-dp-days",
205
- children: I(T, D).map((t) => /* @__PURE__ */ p("button", {
206
- type: "button",
207
- className: c("ssg-dp-day", !t.inCurrentMonth && "ssg-dp-day--out", t.key === j && "ssg-dp-day--today", t.key === e && "ssg-dp-day--selected"),
208
- "aria-label": t.key,
209
- ...V(() => F(t.key)),
210
- children: t.day
211
- }, t.key))
212
- })] }),
213
- C === "months" && /* @__PURE__ */ p("div", {
214
- className: "ssg-dp-grid",
215
- children: g.calendarMonths.map((e, t) => /* @__PURE__ */ p("button", {
216
- type: "button",
217
- className: c("ssg-dp-cell", t === D && "ssg-dp-cell--selected"),
218
- ...V(() => {
219
- O(t), w("days");
220
- }),
221
- children: e
222
- }, t))
223
- }),
224
- C === "years" && /* @__PURE__ */ p("div", {
225
- className: "ssg-dp-grid",
226
- children: L(T).map((e) => /* @__PURE__ */ p("button", {
227
- type: "button",
228
- className: c("ssg-dp-cell", e === T && "ssg-dp-cell--selected"),
229
- ...V(() => {
230
- E(e), w("months");
231
- }),
232
- children: e
233
- }, e))
234
- }),
235
- /* @__PURE__ */ m("div", {
236
- className: "ssg-dp-foot",
237
- children: [
238
- C !== "days" && /* @__PURE__ */ p("button", {
239
- type: "button",
240
- className: "ssg-dp-foot-btn",
241
- ...V(W),
242
- children: g.calendarBack
243
- }),
244
- /* @__PURE__ */ p("button", {
245
- type: "button",
246
- className: "ssg-dp-foot-btn",
247
- ...V(() => F(j)),
248
- children: g.calendarToday
249
- }),
250
- /* @__PURE__ */ p("button", {
251
- type: "button",
252
- className: "ssg-dp-foot-btn ssg-dp-foot-btn--muted",
253
- ...V(() => F("")),
254
- children: g.clear
255
- })
256
- ]
257
- })
258
- ]
259
- })]
260
- });
261
- }
262
- //#endregion
263
- //#region src/view/ColumnFilterPopover.tsx
264
- var H = 24, U = (e, t, n) => e === "" && t === g.blank ? n : t, W = (e, t) => t === g.blank ? e : e.map((e) => e.value === "" && e.label === g.blank ? {
265
- ...e,
266
- label: t
267
- } : e);
268
- function G({ options: e, setSelection: i, searchInputRef: c, onValueToggle: l, onSelectAllChange: h, onReplaceSelection: ee, onRequestClose: g, isServerSide: b, selectAllUsesExplicitScope: x = !1, truncated: S = !1 }) {
269
- let C = n(), [w, T] = s(""), E = r(w), D = a(() => W(e, C.blank), [e, C.blank]), O = a(() => _(D, E), [D, E]), k = E.trim().length > 0, A = o(null), j = t({
270
- count: O.length,
271
- getScrollElement: () => A.current,
272
- estimateSize: () => H,
273
- overscan: 10
274
- }), M = a(() => {
275
- if (i === null) return O.length;
276
- let e = 0;
277
- for (let t of O) y(i, t.value) && (e += 1);
278
- return e;
279
- }, [i, O]), N = O.length > 0 && M === O.length, P = M > 0 && !N, F = a(() => new Set(e.map((e) => e.value)), [e]), I = a(() => {
280
- if (i === null) return e.length;
281
- let t = 0;
282
- for (let e of i.values) F.has(e) && (t += 1);
283
- return i.mode === "include" ? t : e.length - t;
284
- }, [
285
- i,
286
- F,
287
- e.length
288
- ]);
289
- return /* @__PURE__ */ m(f, { children: [
290
- /* @__PURE__ */ p("input", {
291
- ref: c,
292
- type: "text",
293
- value: w,
294
- onChange: (e) => T(e.target.value),
295
- onKeyDown: (e) => {
296
- if (e.stopPropagation(), e.key === "Escape" && (e.preventDefault(), g()), e.key === "Enter") {
297
- if (u(e.nativeEvent)) return;
298
- e.preventDefault();
299
- let t = v(D, w);
300
- if (t.kind === "none") return;
301
- t.kind === "replace" && ee(t.values), g();
302
- }
303
- },
304
- placeholder: C.filterSearchPlaceholder,
305
- className: "ssg-filter-input"
306
- }),
307
- /* @__PURE__ */ m("label", {
308
- className: "ssg-filter-selectall",
309
- children: [/* @__PURE__ */ p("input", {
310
- type: "checkbox",
311
- checked: N,
312
- ref: (e) => {
313
- e && (e.indeterminate = P);
314
- },
315
- onChange: () => {
316
- h(k || x ? O.map((e) => e.value) : "all", !N);
317
- }
318
- }), /* @__PURE__ */ p("span", {
319
- className: "ssg-filter-selectall-label",
320
- children: k ? C.filterSelectAllResults : C.filterSelectAll
321
- })]
322
- }),
323
- /* @__PURE__ */ p("div", {
324
- ref: A,
325
- className: "ssg-filter-list",
326
- children: O.length === 0 ? /* @__PURE__ */ p("div", {
327
- className: "ssg-filter-empty",
328
- children: e.length === 0 ? b ? C.filterNoOptionsSource : C.noOptions : C.filterNoMatches
329
- }) : /* @__PURE__ */ p("div", {
330
- className: "ssg-filter-virt",
331
- style: { height: j.getTotalSize() },
332
- children: j.getVirtualItems().map((e) => {
333
- let t = O[e.index];
334
- if (!t) return null;
335
- let n = y(i, t.value);
336
- return /* @__PURE__ */ m("label", {
337
- className: "ssg-filter-option",
338
- style: {
339
- transform: `translateY(${e.start}px)`,
340
- height: e.size
341
- },
342
- children: [/* @__PURE__ */ p("input", {
343
- type: "checkbox",
344
- checked: n,
345
- onChange: () => l(t.value)
346
- }), /* @__PURE__ */ p("span", {
347
- className: "ssg-filter-option-label",
348
- children: U(t.value, t.label, C.blank)
349
- })]
350
- }, t.value);
351
- })
352
- })
353
- }),
354
- /* @__PURE__ */ m("div", {
355
- className: "ssg-filter-meta",
356
- children: [
357
- d(C.filterSelectedCount, {
358
- selected: I,
359
- total: e.length
360
- }),
361
- k ? d(C.filterShownCount, { count: O.length }) : "",
362
- S && /* @__PURE__ */ p(oe, {})
363
- ]
364
- })
365
- ] });
366
- }
367
- var K = (e) => {
368
- e.key !== "Escape" && e.stopPropagation();
369
- }, q = (e) => e.nativeEvent.isComposing === !0, J = (e, t, n) => {
370
- if (q(n)) {
371
- e(t, { commit: !1 });
372
- return;
373
- }
374
- e(t);
375
- };
376
- function te({ draft: e, valueInputRef: t, onDraftChange: r, onKeyDown: i }) {
377
- let a = n(), o = w(e.operator);
378
- return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("select", {
379
- value: e.operator,
380
- onChange: (t) => r({
381
- ...e,
382
- operator: t.target.value
383
- }),
384
- onKeyDown: i,
385
- className: "ssg-filter-select",
386
- "aria-label": a.filterOperator,
387
- children: x.map((e) => /* @__PURE__ */ p("option", {
388
- value: e.value,
389
- children: a[e.labelKey]
390
- }, e.value))
391
- }), o > 0 ? /* @__PURE__ */ m("div", {
392
- className: "ssg-filter-cond-values",
393
- children: [/* @__PURE__ */ p("input", {
394
- ref: t,
395
- type: "text",
396
- inputMode: "decimal",
397
- value: e.value1,
398
- onChange: (t) => J(r, {
399
- ...e,
400
- value1: t.target.value
401
- }, t),
402
- onCompositionEnd: (t) => r({
403
- ...e,
404
- value1: t.currentTarget.value
405
- }),
406
- onKeyDown: i,
407
- placeholder: o === 2 ? a.filterMin : a.filterValuePlaceholder,
408
- className: "ssg-filter-input",
409
- "aria-label": o === 2 ? a.filterMin : a.filterValue
410
- }), o === 2 && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", {
411
- className: "ssg-filter-cond-tilde",
412
- children: a.filterRangeSeparator
413
- }), /* @__PURE__ */ p("input", {
414
- type: "text",
415
- inputMode: "decimal",
416
- value: e.value2,
417
- onChange: (t) => J(r, {
418
- ...e,
419
- value2: t.target.value
420
- }, t),
421
- onCompositionEnd: (t) => r({
422
- ...e,
423
- value2: t.currentTarget.value
424
- }),
425
- onKeyDown: i,
426
- placeholder: a.filterMax,
427
- className: "ssg-filter-input",
428
- "aria-label": a.filterMax
429
- })] })]
430
- }) : /* @__PURE__ */ p("div", {
431
- className: "ssg-filter-meta",
432
- children: a.filterNoValue
433
- })] });
434
- }
435
- function ne({ draft: e, valueInputRef: t, onDraftChange: r, onKeyDown: i }) {
436
- let a = n(), o = k(e.operator);
437
- return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("select", {
438
- value: e.operator,
439
- onChange: (t) => r({
440
- ...e,
441
- operator: t.target.value
442
- }),
443
- onKeyDown: i,
444
- className: "ssg-filter-select",
445
- "aria-label": a.filterOperator,
446
- children: E.map((e) => /* @__PURE__ */ p("option", {
447
- value: e.value,
448
- children: a[e.labelKey]
449
- }, e.value))
450
- }), o > 0 ? /* @__PURE__ */ p("div", {
451
- className: "ssg-filter-cond-values",
452
- children: /* @__PURE__ */ p("input", {
453
- ref: t,
454
- type: "text",
455
- value: e.value,
456
- onChange: (t) => J(r, {
457
- ...e,
458
- value: t.target.value
459
- }, t),
460
- onCompositionEnd: (t) => r({
461
- ...e,
462
- value: t.currentTarget.value
463
- }),
464
- onKeyDown: i,
465
- placeholder: a.filterValuePlaceholder,
466
- className: "ssg-filter-input",
467
- "aria-label": a.filterValue
468
- })
469
- }) : /* @__PURE__ */ p("div", {
470
- className: "ssg-filter-meta",
471
- children: a.filterNoValue
472
- })] });
473
- }
474
- function re({ draft: e, valueInputRef: t, onDraftChange: r, onKeyDown: i, presets: a, renderDateInput: o, onRequestClose: s }) {
475
- let l = n(), u = e.preset === null ? N(e.operator) : 0, d = (t, n) => {
476
- r({
477
- ...e,
478
- [t]: F(n),
479
- preset: null
480
- });
481
- };
482
- return /* @__PURE__ */ m(f, { children: [
483
- /* @__PURE__ */ p("select", {
484
- value: e.operator,
485
- onChange: (t) => r({
486
- ...e,
487
- operator: t.target.value,
488
- preset: null
489
- }),
490
- onKeyDown: i,
491
- className: "ssg-filter-select",
492
- "aria-label": l.filterOperator,
493
- children: A.map((e) => /* @__PURE__ */ p("option", {
494
- value: e.value,
495
- children: l[e.labelKey]
496
- }, e.value))
497
- }),
498
- u > 0 ? /* @__PURE__ */ m("div", {
499
- className: "ssg-filter-cond-values",
500
- children: [o ? o({
501
- value: e.value1,
502
- onChange: (e) => d("value1", e),
503
- ariaLabel: u === 2 ? l.filterStartDate : l.filterDate,
504
- slot: u === 2 ? "from" : "single"
505
- }) : /* @__PURE__ */ p(V, {
506
- value: e.value1,
507
- onCommit: (t) => r({
508
- ...e,
509
- value1: t,
510
- preset: null
511
- }),
512
- ariaLabel: u === 2 ? l.filterStartDate : l.filterDate,
513
- inputRef: t,
514
- onRequestClose: s
515
- }), u === 2 && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", {
516
- className: "ssg-filter-cond-tilde",
517
- children: l.filterRangeSeparator
518
- }), o ? o({
519
- value: e.value2,
520
- onChange: (e) => d("value2", e),
521
- ariaLabel: l.filterEndDate,
522
- slot: "to"
523
- }) : /* @__PURE__ */ p(V, {
524
- value: e.value2,
525
- onCommit: (t) => r({
526
- ...e,
527
- value2: t,
528
- preset: null
529
- }),
530
- ariaLabel: l.filterEndDate,
531
- onRequestClose: s,
532
- align: "right"
533
- })] })]
534
- }) : e.preset === null ? /* @__PURE__ */ p("div", {
535
- className: "ssg-filter-meta",
536
- children: l.filterNoValue
537
- }) : null,
538
- a.length > 0 && /* @__PURE__ */ p("div", {
539
- className: "ssg-filter-presets",
540
- children: a.map((t) => /* @__PURE__ */ p("button", {
541
- type: "button",
542
- onPointerDown: (n) => {
543
- n.preventDefault(), n.stopPropagation(), r({
544
- ...e,
545
- preset: e.preset === t.id ? null : t.id
546
- });
547
- },
548
- onKeyDown: (n) => {
549
- K(n), (n.key === "Enter" || n.key === " ") && (n.preventDefault(), r({
550
- ...e,
551
- preset: e.preset === t.id ? null : t.id
552
- }));
553
- },
554
- className: c("ssg-filter-preset-chip", e.preset === t.id && "ssg-filter-preset-chip--active"),
555
- children: t.label
556
- }, t.id))
557
- })
558
- ] });
559
- }
560
- function ie({ options: e, setSelection: i, searchInputRef: c, onValueToggle: l, onSelectAllChange: h, onReplaceSelection: ee, onRequestClose: g, isServerSide: b, truncated: x = !1 }) {
561
- let S = n(), [C, w] = s(""), T = r(C), [E, D] = s(() => /* @__PURE__ */ new Set()), O = T.trim().length > 0, k = a(() => W(e, S.blank), [e, S.blank]), A = a(() => _(k, T), [k, T]), j = a(() => B(e, E, S), [
562
- e,
563
- E,
564
- S
565
- ]), M = o(null), N = O ? A.length : j.length, P = t({
566
- count: N,
567
- getScrollElement: () => M.current,
568
- estimateSize: () => H,
569
- overscan: 10
570
- }), F = a(() => (O ? A : e).map((e) => e.value), [
571
- O,
572
- A,
573
- e
574
- ]), I = a(() => {
575
- let e = 0;
576
- for (let t of F) y(i, t) && (e += 1);
577
- return e;
578
- }, [F, i]), L = F.length > 0 && I === F.length, R = I > 0 && !L, z = a(() => new Set(e.map((e) => e.value)), [e]), V = a(() => {
579
- if (i === null) return e.length;
580
- let t = 0;
581
- for (let e of i.values) z.has(e) && (t += 1);
582
- return i.mode === "include" ? t : e.length - t;
583
- }, [
584
- i,
585
- z,
586
- e.length
587
- ]), G = (e) => {
588
- D((t) => {
589
- let n = new Set(t);
590
- return n.has(e) ? n.delete(e) : n.add(e), n;
591
- });
592
- }, q = (e) => {
593
- let t = 0;
594
- for (let n of e) y(i, n) && (t += 1);
595
- return t;
596
- }, J = (e) => {
597
- let t = q(e.leafKeys), n = e.leafKeys.length > 0 && t === e.leafKeys.length, r = t > 0 && !n;
598
- return /* @__PURE__ */ m(f, { children: [
599
- e.type === "group" ? /* @__PURE__ */ p("button", {
600
- type: "button",
601
- onPointerDown: (t) => {
602
- t.preventDefault(), t.stopPropagation(), G(e.key);
603
- },
604
- onKeyDown: (t) => {
605
- K(t), (t.key === "Enter" || t.key === " ") && (t.preventDefault(), G(e.key));
606
- },
607
- className: "ssg-filter-tree-toggle",
608
- "aria-label": e.expanded ? S.treeCollapse : S.treeExpand,
609
- children: e.expanded ? "▾" : "▸"
610
- }) : /* @__PURE__ */ p("span", { className: "ssg-filter-tree-toggle ssg-filter-tree-toggle--placeholder" }),
611
- /* @__PURE__ */ p("input", {
612
- type: "checkbox",
613
- checked: n,
614
- ref: (e) => {
615
- e && (e.indeterminate = r);
616
- },
617
- onChange: () => {
618
- if (e.type === "leaf") {
619
- l(e.key);
620
- return;
621
- }
622
- h(e.leafKeys, !n);
623
- }
624
- }),
625
- /* @__PURE__ */ p("span", {
626
- className: "ssg-filter-option-label",
627
- children: U(e.key, e.label, S.blank)
628
- })
629
- ] });
630
- };
631
- return /* @__PURE__ */ m(f, { children: [
632
- /* @__PURE__ */ p("input", {
633
- ref: c,
634
- type: "text",
635
- value: C,
636
- onChange: (e) => w(e.target.value),
637
- onKeyDown: (e) => {
638
- if (e.stopPropagation(), e.key === "Escape" && (e.preventDefault(), g()), e.key === "Enter") {
639
- if (u(e.nativeEvent)) return;
640
- e.preventDefault();
641
- let t = v(k, C);
642
- if (t.kind === "none") return;
643
- t.kind === "replace" && ee(t.values), g();
644
- }
645
- },
646
- placeholder: S.filterSearchPlaceholder,
647
- className: "ssg-filter-input"
648
- }),
649
- /* @__PURE__ */ m("label", {
650
- className: "ssg-filter-selectall",
651
- children: [/* @__PURE__ */ p("input", {
652
- type: "checkbox",
653
- checked: L,
654
- ref: (e) => {
655
- e && (e.indeterminate = R);
656
- },
657
- onChange: () => h(F, !L)
658
- }), /* @__PURE__ */ p("span", {
659
- className: "ssg-filter-selectall-label",
660
- children: O ? S.filterSelectAllResults : S.filterSelectAll
661
- })]
662
- }),
663
- /* @__PURE__ */ p("div", {
664
- ref: M,
665
- className: "ssg-filter-list",
666
- children: N === 0 ? /* @__PURE__ */ p("div", {
667
- className: "ssg-filter-empty",
668
- children: e.length === 0 ? b ? S.filterNoOptionsSource : S.noOptions : S.filterNoMatches
669
- }) : /* @__PURE__ */ p("div", {
670
- className: "ssg-filter-virt",
671
- style: { height: P.getTotalSize() },
672
- children: P.getVirtualItems().map((e) => {
673
- if (O) {
674
- let t = A[e.index];
675
- return t ? /* @__PURE__ */ m("label", {
676
- className: "ssg-filter-option",
677
- style: {
678
- transform: `translateY(${e.start}px)`,
679
- height: e.size
680
- },
681
- children: [/* @__PURE__ */ p("input", {
682
- type: "checkbox",
683
- checked: y(i, t.value),
684
- onChange: () => l(t.value)
685
- }), /* @__PURE__ */ p("span", {
686
- className: "ssg-filter-option-label",
687
- children: U(t.value, t.label, S.blank)
688
- })]
689
- }, t.value) : null;
690
- }
691
- let t = j[e.index];
692
- return t ? /* @__PURE__ */ p("div", {
693
- className: "ssg-filter-option",
694
- style: {
695
- transform: `translateY(${e.start}px)`,
696
- height: e.size,
697
- paddingLeft: 8 + t.depth * 16
698
- },
699
- children: J(t)
700
- }, t.key) : null;
701
- })
702
- })
703
- }),
704
- /* @__PURE__ */ m("div", {
705
- className: "ssg-filter-meta",
706
- children: [
707
- d(S.filterSelectedCount, {
708
- selected: V,
709
- total: e.length
710
- }),
711
- O ? d(S.filterShownCount, { count: A.length }) : "",
712
- x && /* @__PURE__ */ p(oe, {})
713
- ]
714
- })
715
- ] });
716
- }
717
- function ae({ status: e, errorMessage: t, onRetry: r }) {
718
- let i = n();
719
- return e === "loading" ? /* @__PURE__ */ p("div", {
720
- className: "ssg-filter-collecting",
721
- children: i.filterOptionsLoading
722
- }) : /* @__PURE__ */ m("div", {
723
- className: "ssg-filter-error",
724
- role: "alert",
725
- children: [
726
- /* @__PURE__ */ p("div", { children: i.filterOptionsFailed }),
727
- t ? /* @__PURE__ */ p("div", {
728
- className: "ssg-filter-error-detail",
729
- title: t,
730
- children: t
731
- }) : null,
732
- r ? /* @__PURE__ */ p("button", {
733
- type: "button",
734
- onPointerDown: (e) => {
735
- e.preventDefault(), e.stopPropagation(), r();
736
- },
737
- onKeyDown: (e) => {
738
- K(e), (e.key === "Enter" || e.key === " ") && (e.preventDefault(), r());
739
- },
740
- className: "ssg-filter-btn-secondary",
741
- children: i.retry
742
- }) : null
743
- ]
744
- });
745
- }
746
- function oe() {
747
- return /* @__PURE__ */ p("span", {
748
- className: "ssg-filter-truncated",
749
- children: n().filterOptionsTruncated
750
- });
751
- }
752
- function se({ conditionEditor: e, conditionActive: t, onConditionClear: r, options: i, setSelection: a, onSelectionClear: o, summaryText: s, children: c, optionsMeta: l }) {
753
- let u = n();
754
- return /* @__PURE__ */ m(f, { children: [
755
- /* @__PURE__ */ m("div", {
756
- className: "ssg-filter-sec-head",
757
- children: [/* @__PURE__ */ p("span", {
758
- className: "ssg-filter-sec-label",
759
- children: u.filterConditionSection
760
- }), /* @__PURE__ */ p("button", {
761
- type: "button",
762
- onPointerDown: (e) => {
763
- e.preventDefault(), e.stopPropagation(), r();
764
- },
765
- onKeyDown: (e) => {
766
- K(e), (e.key === "Enter" || e.key === " ") && (e.preventDefault(), r());
767
- },
768
- className: "ssg-filter-sec-clear",
769
- disabled: !t,
770
- children: u.clear
771
- })]
772
- }),
773
- e,
774
- /* @__PURE__ */ p("div", { className: "ssg-filter-sep" }),
775
- /* @__PURE__ */ m("div", {
776
- className: "ssg-filter-sec-head",
777
- children: [
778
- /* @__PURE__ */ p("span", {
779
- className: "ssg-filter-sec-label",
780
- children: u.filterValuesSection
781
- }),
782
- /* @__PURE__ */ p("span", {
783
- className: "ssg-filter-sec-meta",
784
- children: l ?? d(t ? u.filterMatchCount : u.filterTotalCount, { count: i.length })
785
- }),
786
- /* @__PURE__ */ p("button", {
787
- type: "button",
788
- onPointerDown: (e) => {
789
- e.preventDefault(), e.stopPropagation(), o();
790
- },
791
- onKeyDown: (e) => {
792
- K(e), (e.key === "Enter" || e.key === " ") && (e.preventDefault(), o());
793
- },
794
- className: "ssg-filter-sec-clear",
795
- disabled: a === null,
796
- children: u.clear
797
- })
798
- ]
799
- }),
800
- c,
801
- /* @__PURE__ */ m("div", {
802
- className: "ssg-filter-summary",
803
- children: ["🔽 ", s]
804
- })
805
- ] });
806
- }
807
- function Y({ isOpen: t, themeClassName: r, popoverSlot: i, title: a, filterType: h, draftValue: g, numberConditionDraft: _, onNumberConditionDraftChange: v, textConditionDraft: y, onTextConditionDraftChange: x, dateConditionDraft: w, onDateConditionDraftChange: E, datePresets: k, renderDateInput: A, onComboConditionClear: N, onComboSelectionClear: F, comboSummaryText: I, currentValueText: L, layout: R, selectOptions: z, optionsStatus: B, optionsProgress: V, optionsTruncated: H = !1, optionsErrorMessage: W, onOptionsRetry: q, setSelection: J, popoverRef: Y, textInputRef: X, selectRef: ce, onRequestClose: Z, onDraftChange: le, onApply: Q, onClear: ue, onSetValueToggle: de, onSetSelectAllChange: fe, onSetClear: pe, onSetReplaceSelection: me, isServerSide: he = !1 }) {
808
- let $ = n(), ge = o(null), [_e] = s(() => /* @__PURE__ */ new Date());
809
- if (e(Y, t && R !== null, r), typeof document > "u" || !t || !R) return null;
810
- let ve = {
811
- top: R.top,
812
- left: R.left,
813
- width: R.width,
814
- maxHeight: R.maxHeight
815
- }, ye = (e) => {
816
- e.stopPropagation(), e.key === "Escape" && !e.defaultPrevented && !u(e.nativeEvent) && (e.preventDefault(), Z());
817
- }, be = (e) => {
818
- e.stopPropagation();
819
- }, xe = h === "set", Se = h === "numberSet", Ce = h === "textSet", we = h === "dateSet", Te = Se || Ce || we, Ee = xe || Te, De = B === "loading" || B === "error", Oe = _ ?? b, ke = y ?? T, Ae = w ?? j, je = k ?? ee(void 0, $), Me = Se ? S(Oe) : null, Ne = Ce ? D(ke) : null, Pe = we ? M(Ae) : null, Fe = Me !== null || Ne !== null || Pe !== null, Ie = Se ? C(z, Me) : Ce ? O(z, Ne) : we ? P(z, Pe, _e, je) : z, Le = (e) => {
820
- if (e.stopPropagation(), !u(e.nativeEvent)) {
821
- if (e.key === "Enter") {
822
- e.preventDefault(), Q();
823
- return;
824
- }
825
- e.key === "Escape" && (e.preventDefault(), Z());
826
- }
827
- }, Re = Se ? /* @__PURE__ */ p(te, {
828
- draft: Oe,
829
- valueInputRef: X,
830
- onDraftChange: v,
831
- onKeyDown: Le
832
- }) : Ce ? /* @__PURE__ */ p(ne, {
833
- draft: ke,
834
- valueInputRef: X,
835
- onDraftChange: x,
836
- onKeyDown: Le
837
- }) : /* @__PURE__ */ p(re, {
838
- draft: Ae,
839
- valueInputRef: X,
840
- onDraftChange: E,
841
- onKeyDown: Le,
842
- presets: je,
843
- renderDateInput: A,
844
- onRequestClose: Z
845
- });
846
- return l(/* @__PURE__ */ m("div", {
847
- ref: Y,
848
- onPointerDown: be,
849
- onKeyDown: ye,
850
- onPasteCapture: (e) => {
851
- e.stopPropagation();
852
- },
853
- className: c("ssg-filter-popover", r, i?.className),
854
- style: {
855
- ...i?.style,
856
- ...ve
857
- },
858
- children: [
859
- /* @__PURE__ */ p("div", {
860
- className: "ssg-filter-title",
861
- children: d($.filterTitle, { column: a })
862
- }),
863
- (Ee || h === "select") && B === "collecting" ? /* @__PURE__ */ p("div", {
864
- className: "ssg-filter-collecting",
865
- children: d($.filterCollecting, { percent: Math.round(V * 100) })
866
- }) : (Ee || h === "select") && De ? Te ? /* @__PURE__ */ p(se, {
867
- conditionEditor: Re,
868
- conditionActive: Fe,
869
- onConditionClear: N,
870
- options: Ie,
871
- setSelection: J,
872
- onSelectionClear: F,
873
- summaryText: I,
874
- optionsMeta: B === "loading" ? $.filterOptionsLoadingShort : $.filterOptionsFailedShort,
875
- children: /* @__PURE__ */ p(ae, {
876
- status: B === "loading" ? "loading" : "error",
877
- errorMessage: W,
878
- onRetry: q
879
- })
880
- }) : /* @__PURE__ */ p(ae, {
881
- status: B === "loading" ? "loading" : "error",
882
- errorMessage: W,
883
- onRetry: q
884
- }) : Te ? /* @__PURE__ */ p(se, {
885
- conditionEditor: Re,
886
- conditionActive: Fe,
887
- onConditionClear: N,
888
- options: Ie,
889
- setSelection: J,
890
- onSelectionClear: F,
891
- summaryText: I,
892
- children: we ? /* @__PURE__ */ p(ie, {
893
- options: Ie,
894
- setSelection: J,
895
- searchInputRef: ge,
896
- onValueToggle: de,
897
- onSelectAllChange: fe,
898
- onReplaceSelection: me,
899
- onRequestClose: Z,
900
- isServerSide: he,
901
- truncated: H
902
- }) : /* @__PURE__ */ p(G, {
903
- options: Ie,
904
- setSelection: J,
905
- searchInputRef: ge,
906
- onValueToggle: de,
907
- onSelectAllChange: fe,
908
- onReplaceSelection: me,
909
- onRequestClose: Z,
910
- isServerSide: he,
911
- selectAllUsesExplicitScope: !0,
912
- truncated: H
913
- })
914
- }) : xe ? /* @__PURE__ */ p(G, {
915
- options: z,
916
- setSelection: J,
917
- searchInputRef: X,
918
- onValueToggle: de,
919
- onSelectAllChange: fe,
920
- onReplaceSelection: me,
921
- onRequestClose: Z,
922
- isServerSide: he,
923
- truncated: H
924
- }) : h === "number" ? /* @__PURE__ */ p(f, { children: /* @__PURE__ */ p(te, {
925
- draft: Oe,
926
- valueInputRef: X,
927
- onDraftChange: v,
928
- onKeyDown: Le
929
- }) }) : h === "select" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("select", {
930
- ref: ce,
931
- value: g,
932
- onChange: (e) => le(e.target.value),
933
- onKeyDown: (e) => {
934
- if (e.stopPropagation(), e.key === "Enter") {
935
- e.preventDefault(), Q();
936
- return;
937
- }
938
- e.key === "Escape" && (e.preventDefault(), Z());
939
- },
940
- className: "ssg-filter-select",
941
- children: [/* @__PURE__ */ p("option", {
942
- value: "",
943
- children: $.filterAll
944
- }), z.map((e) => /* @__PURE__ */ p("option", {
945
- value: e.value,
946
- children: U(e.value, e.label, $.blank)
947
- }, `${a}-${e.value}`))]
948
- }), /* @__PURE__ */ m("div", {
949
- className: "ssg-filter-meta",
950
- children: [d($.filterOptionCount, { count: z.length }), H && /* @__PURE__ */ p(oe, {})]
951
- })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("input", {
952
- ref: X,
953
- type: "text",
954
- value: g,
955
- onChange: (e) => le(e.target.value),
956
- onKeyDown: (e) => {
957
- if (e.stopPropagation(), !u(e.nativeEvent)) {
958
- if (e.key === "Enter") {
959
- e.preventDefault(), Q();
960
- return;
961
- }
962
- e.key === "Escape" && (e.preventDefault(), Z());
963
- }
964
- },
965
- placeholder: $.filterTextPlaceholder,
966
- className: "ssg-filter-input"
967
- }), /* @__PURE__ */ p("div", {
968
- className: "ssg-filter-meta ssg-filter-meta--ellipsis",
969
- children: $.filterTextHint
970
- })] }),
971
- !Ee && /* @__PURE__ */ p("div", {
972
- className: "ssg-filter-meta ssg-filter-meta--ellipsis",
973
- children: d($.filterCurrentValue, { value: L })
974
- }),
975
- /* @__PURE__ */ p("div", {
976
- className: "ssg-filter-footer",
977
- children: Ee ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("button", {
978
- type: "button",
979
- onPointerDown: (e) => {
980
- e.preventDefault(), e.stopPropagation(), pe();
981
- },
982
- onKeyDown: (e) => {
983
- K(e), (e.key === "Enter" || e.key === " ") && (e.preventDefault(), pe());
984
- },
985
- className: "ssg-filter-btn-secondary",
986
- children: $.clear
987
- }), /* @__PURE__ */ p("button", {
988
- type: "button",
989
- onPointerDown: (e) => {
990
- e.preventDefault(), e.stopPropagation(), Z();
991
- },
992
- onKeyDown: (e) => {
993
- K(e), (e.key === "Enter" || e.key === " ") && (e.preventDefault(), Z());
994
- },
995
- className: "ssg-filter-btn-primary",
996
- children: $.close
997
- })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("button", {
998
- type: "button",
999
- onPointerDown: (e) => {
1000
- e.preventDefault(), e.stopPropagation(), ue();
1001
- },
1002
- onKeyDown: (e) => {
1003
- K(e), (e.key === "Enter" || e.key === " ") && (e.preventDefault(), ue());
1004
- },
1005
- className: "ssg-filter-btn-secondary",
1006
- children: $.clear
1007
- }), /* @__PURE__ */ p("button", {
1008
- type: "button",
1009
- onPointerDown: (e) => {
1010
- e.preventDefault(), e.stopPropagation(), Q();
1011
- },
1012
- onKeyDown: (e) => {
1013
- K(e), (e.key === "Enter" || e.key === " ") && (e.preventDefault(), Q());
1014
- },
1015
- className: "ssg-filter-btn-primary",
1016
- children: $.apply
1017
- })] })
1018
- })
1019
- ]
1020
- }), document.body);
1021
- }
1022
- //#endregion
1023
- export { Y as ColumnFilterPopover, Y as default };