@svgrid/grid 1.1.2 → 1.2.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 (143) hide show
  1. package/dist/SvGrid.css +294 -16
  2. package/dist/SvGrid.svelte +4 -1
  3. package/dist/SvGridDropdown.svelte +7 -3
  4. package/dist/cdn/svgrid.js +13506 -0
  5. package/dist/cdn/svgrid.svelte-external.js +11190 -0
  6. package/package.json +12 -2
  7. package/src/SvGrid.css +294 -16
  8. package/src/SvGrid.svelte +4 -1
  9. package/src/SvGridDropdown.svelte +7 -3
  10. package/dist/SvGrid.helpers.test.d.ts +0 -1
  11. package/dist/SvGrid.helpers.test.js +0 -298
  12. package/dist/SvGridChart.test.d.ts +0 -1
  13. package/dist/SvGridChart.test.js +0 -62
  14. package/dist/a11y.contract.test.d.ts +0 -1
  15. package/dist/a11y.contract.test.js +0 -39
  16. package/dist/a11y.test.d.ts +0 -1
  17. package/dist/a11y.test.js +0 -44
  18. package/dist/aligned-grids.test.d.ts +0 -1
  19. package/dist/aligned-grids.test.js +0 -75
  20. package/dist/build-api.coverage.test.d.ts +0 -20
  21. package/dist/build-api.coverage.test.js +0 -505
  22. package/dist/cell-formatting.test.d.ts +0 -1
  23. package/dist/cell-formatting.test.js +0 -234
  24. package/dist/cell-render.test.d.ts +0 -1
  25. package/dist/cell-render.test.js +0 -338
  26. package/dist/chart-export.test.d.ts +0 -1
  27. package/dist/chart-export.test.js +0 -302
  28. package/dist/chart.coverage.test.d.ts +0 -1
  29. package/dist/chart.coverage.test.js +0 -748
  30. package/dist/chart.test.d.ts +0 -1
  31. package/dist/chart.test.js +0 -289
  32. package/dist/clipboard.test.d.ts +0 -1
  33. package/dist/clipboard.test.js +0 -700
  34. package/dist/collaboration.coverage.test.d.ts +0 -1
  35. package/dist/collaboration.coverage.test.js +0 -200
  36. package/dist/collaboration.test.d.ts +0 -1
  37. package/dist/collaboration.test.js +0 -65
  38. package/dist/column-groups.test.d.ts +0 -1
  39. package/dist/column-groups.test.js +0 -56
  40. package/dist/column-types.test.d.ts +0 -1
  41. package/dist/column-types.test.js +0 -62
  42. package/dist/columns.test.d.ts +0 -1
  43. package/dist/columns.test.js +0 -625
  44. package/dist/conditional-formatting.test.d.ts +0 -1
  45. package/dist/conditional-formatting.test.js +0 -87
  46. package/dist/core.coverage.test.d.ts +0 -1
  47. package/dist/core.coverage.test.js +0 -186
  48. package/dist/core.performance.test.d.ts +0 -1
  49. package/dist/core.performance.test.js +0 -29
  50. package/dist/createGrid.test.d.ts +0 -1
  51. package/dist/createGrid.test.js +0 -9
  52. package/dist/editing.test.d.ts +0 -1
  53. package/dist/editing.test.js +0 -732
  54. package/dist/editors/cell-editors.coverage.test.d.ts +0 -1
  55. package/dist/editors/cell-editors.coverage.test.js +0 -139
  56. package/dist/editors/cell-editors.test.d.ts +0 -1
  57. package/dist/editors/cell-editors.test.js +0 -75
  58. package/dist/facet-buckets.test.d.ts +0 -1
  59. package/dist/facet-buckets.test.js +0 -296
  60. package/dist/fill-patterns.test.d.ts +0 -1
  61. package/dist/fill-patterns.test.js +0 -81
  62. package/dist/filter-operators.test.d.ts +0 -1
  63. package/dist/filter-operators.test.js +0 -135
  64. package/dist/filtering/excel-filters.test.d.ts +0 -1
  65. package/dist/filtering/excel-filters.test.js +0 -116
  66. package/dist/filtering/locale-filter.test.d.ts +0 -13
  67. package/dist/filtering/locale-filter.test.js +0 -189
  68. package/dist/flex-render.test.d.ts +0 -1
  69. package/dist/flex-render.test.js +0 -142
  70. package/dist/group-aggregate.test.d.ts +0 -1
  71. package/dist/group-aggregate.test.js +0 -32
  72. package/dist/hyperformula-adapter.test.d.ts +0 -1
  73. package/dist/hyperformula-adapter.test.js +0 -205
  74. package/dist/keyboard-handlers.coverage.test.d.ts +0 -1
  75. package/dist/keyboard-handlers.coverage.test.js +0 -495
  76. package/dist/keyboard.test.d.ts +0 -1
  77. package/dist/keyboard.test.js +0 -27
  78. package/dist/menus.test.d.ts +0 -1
  79. package/dist/menus.test.js +0 -560
  80. package/dist/named-views.coverage.test.d.ts +0 -1
  81. package/dist/named-views.coverage.test.js +0 -180
  82. package/dist/named-views.test.d.ts +0 -1
  83. package/dist/named-views.test.js +0 -57
  84. package/dist/new-features.test.d.ts +0 -1
  85. package/dist/new-features.test.js +0 -183
  86. package/dist/render-component.test.d.ts +0 -1
  87. package/dist/render-component.test.js +0 -41
  88. package/dist/row-drag.test.d.ts +0 -1
  89. package/dist/row-drag.test.js +0 -142
  90. package/dist/row-resize.test.d.ts +0 -1
  91. package/dist/row-resize.test.js +0 -329
  92. package/dist/scroll-sync.test.d.ts +0 -1
  93. package/dist/scroll-sync.test.js +0 -290
  94. package/dist/selection.multi-range.test.d.ts +0 -1
  95. package/dist/selection.multi-range.test.js +0 -55
  96. package/dist/selection.test.d.ts +0 -1
  97. package/dist/selection.test.js +0 -647
  98. package/dist/server-data-source.coverage.test.d.ts +0 -1
  99. package/dist/server-data-source.coverage.test.js +0 -154
  100. package/dist/server-data-source.test.d.ts +0 -1
  101. package/dist/server-data-source.test.js +0 -81
  102. package/dist/sparkline.test.d.ts +0 -1
  103. package/dist/sparkline.test.js +0 -52
  104. package/dist/spreadsheet.test.d.ts +0 -1
  105. package/dist/spreadsheet.test.js +0 -446
  106. package/dist/subscribe.test.d.ts +0 -1
  107. package/dist/subscribe.test.js +0 -93
  108. package/dist/svgrid.api-extensions.test.d.ts +0 -14
  109. package/dist/svgrid.api-extensions.test.js +0 -334
  110. package/dist/svgrid.api.test.d.ts +0 -15
  111. package/dist/svgrid.api.test.js +0 -169
  112. package/dist/svgrid.behavior.test.d.ts +0 -15
  113. package/dist/svgrid.behavior.test.js +0 -625
  114. package/dist/svgrid.column-reorder.test.d.ts +0 -15
  115. package/dist/svgrid.column-reorder.test.js +0 -224
  116. package/dist/svgrid.comments-autocomplete.test.d.ts +0 -1
  117. package/dist/svgrid.comments-autocomplete.test.js +0 -96
  118. package/dist/svgrid.context-menu.test.d.ts +0 -1
  119. package/dist/svgrid.context-menu.test.js +0 -102
  120. package/dist/svgrid.features.test.d.ts +0 -1
  121. package/dist/svgrid.features.test.js +0 -129
  122. package/dist/svgrid.interaction.test.d.ts +0 -9
  123. package/dist/svgrid.interaction.test.js +0 -349
  124. package/dist/svgrid.locale-filtering.test.d.ts +0 -15
  125. package/dist/svgrid.locale-filtering.test.js +0 -261
  126. package/dist/svgrid.new-features.wrapper.test.d.ts +0 -1
  127. package/dist/svgrid.new-features.wrapper.test.js +0 -194
  128. package/dist/svgrid.row-pinning.test.d.ts +0 -14
  129. package/dist/svgrid.row-pinning.test.js +0 -250
  130. package/dist/svgrid.set-filter.test.d.ts +0 -17
  131. package/dist/svgrid.set-filter.test.js +0 -268
  132. package/dist/svgrid.wrapper.test.d.ts +0 -1
  133. package/dist/svgrid.wrapper.test.js +0 -59
  134. package/dist/test-setup.d.ts +0 -1
  135. package/dist/test-setup.js +0 -35
  136. package/dist/transaction.test.d.ts +0 -1
  137. package/dist/transaction.test.js +0 -89
  138. package/dist/virtualization/column-virtualizer.test.d.ts +0 -1
  139. package/dist/virtualization/column-virtualizer.test.js +0 -25
  140. package/dist/virtualization/scroll-scaling.test.d.ts +0 -1
  141. package/dist/virtualization/scroll-scaling.test.js +0 -127
  142. package/dist/virtualization/virtualizer.test.d.ts +0 -1
  143. package/dist/virtualization/virtualizer.test.js +0 -41
@@ -1,135 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { filterOperatorOptions, fallbackOperatorOption, TEXT_OPERATORS, NUMBER_OPERATORS, DATE_OPERATORS, CHECKBOX_OPERATORS, operatorOption, operatorsForColumn, defaultOperatorFor, operatorLabelFor, } from "./filter-operators";
3
- // `operatorsForColumn` / `defaultOperatorFor` / `operatorLabelFor` only ever
4
- // read `column?.columnDef.editorType`, so a minimal duck-typed stub is enough
5
- // to exercise every branch without standing up a real grid/column instance.
6
- function col(editorType) {
7
- return editorType === undefined
8
- ? { columnDef: {} }
9
- : { columnDef: { editorType } };
10
- }
11
- describe("filter-operators: catalogue integrity", () => {
12
- it("every option exposes value/label/iconName and a unique value", () => {
13
- const values = filterOperatorOptions.map((o) => o.value);
14
- expect(new Set(values).size).toBe(values.length);
15
- for (const o of filterOperatorOptions) {
16
- expect(typeof o.value).toBe("string");
17
- expect(typeof o.label).toBe("string");
18
- expect(o.iconName).toMatch(/^op-/);
19
- }
20
- });
21
- it("fallback option is the 'contains' operator", () => {
22
- expect(fallbackOperatorOption.value).toBe("contains");
23
- expect(fallbackOperatorOption.label).toBe("Contains");
24
- });
25
- it("each type's operator list only references catalogued operators", () => {
26
- const known = new Set(filterOperatorOptions.map((o) => o.value));
27
- for (const list of [
28
- TEXT_OPERATORS,
29
- NUMBER_OPERATORS,
30
- DATE_OPERATORS,
31
- CHECKBOX_OPERATORS,
32
- ]) {
33
- for (const id of list)
34
- expect(known.has(id)).toBe(true);
35
- }
36
- });
37
- it("the catalogue includes between / isBlank for numeric + date filtering", () => {
38
- const values = filterOperatorOptions.map((o) => o.value);
39
- expect(values).toContain("between");
40
- expect(values).toContain("isBlank");
41
- });
42
- });
43
- describe("operatorOption", () => {
44
- it("returns the matching option for every catalogued operator", () => {
45
- for (const o of filterOperatorOptions) {
46
- expect(operatorOption(o.value)).toBe(o);
47
- }
48
- });
49
- it("looks up a specific operator by value", () => {
50
- expect(operatorOption("between")).toMatchObject({
51
- value: "between",
52
- label: "Between",
53
- });
54
- expect(operatorOption("greaterThan").label).toBe("Greater than");
55
- expect(operatorOption("lessThan").label).toBe("Less than");
56
- expect(operatorOption("startsWith").label).toBe("Starts with");
57
- });
58
- it("falls back to 'contains' for an unknown operator value", () => {
59
- const result = operatorOption("nope");
60
- expect(result).toBe(fallbackOperatorOption);
61
- expect(result.value).toBe("contains");
62
- });
63
- });
64
- describe("operatorsForColumn", () => {
65
- const labels = (opts) => opts.map((o) => o.value);
66
- it("number columns get equals/greaterThan/lessThan/between/isBlank", () => {
67
- expect(labels(operatorsForColumn(col("number")))).toEqual(NUMBER_OPERATORS);
68
- });
69
- it("date columns get the date operator set", () => {
70
- expect(labels(operatorsForColumn(col("date")))).toEqual(DATE_OPERATORS);
71
- });
72
- it("datetime columns share the date operator set", () => {
73
- expect(labels(operatorsForColumn(col("datetime")))).toEqual(DATE_OPERATORS);
74
- });
75
- it("checkbox columns get only equals + isBlank", () => {
76
- expect(labels(operatorsForColumn(col("checkbox")))).toEqual(CHECKBOX_OPERATORS);
77
- });
78
- it("text columns get the text operator set", () => {
79
- expect(labels(operatorsForColumn(col("text")))).toEqual(TEXT_OPERATORS);
80
- });
81
- it("an unknown editor type defaults to the text operator set", () => {
82
- expect(labels(operatorsForColumn(col("currency")))).toEqual(TEXT_OPERATORS);
83
- });
84
- it("a column with no editorType defaults to text", () => {
85
- expect(labels(operatorsForColumn(col()))).toEqual(TEXT_OPERATORS);
86
- });
87
- it("an undefined column defaults to the text operator set", () => {
88
- expect(labels(operatorsForColumn(undefined))).toEqual(TEXT_OPERATORS);
89
- });
90
- it("returns full FilterOption objects (value+label+iconName), in order", () => {
91
- const opts = operatorsForColumn(col("number"));
92
- expect(opts[0]).toMatchObject({ value: "equals", iconName: "op-equals" });
93
- for (const o of opts) {
94
- expect(o).toHaveProperty("label");
95
- expect(o).toHaveProperty("iconName");
96
- }
97
- });
98
- });
99
- describe("defaultOperatorFor", () => {
100
- it("picks the first operator valid for the column type", () => {
101
- expect(defaultOperatorFor(col("number"))).toBe("equals");
102
- expect(defaultOperatorFor(col("date"))).toBe("equals");
103
- expect(defaultOperatorFor(col("checkbox"))).toBe("equals");
104
- expect(defaultOperatorFor(col("text"))).toBe("contains");
105
- });
106
- it("defaults to 'contains' for text / unknown / undefined columns", () => {
107
- expect(defaultOperatorFor(col())).toBe("contains");
108
- expect(defaultOperatorFor(undefined)).toBe("contains");
109
- expect(defaultOperatorFor(col("mystery"))).toBe("contains");
110
- });
111
- });
112
- describe("operatorLabelFor", () => {
113
- const less = operatorOption("lessThan");
114
- const greater = operatorOption("greaterThan");
115
- const equals = operatorOption("equals");
116
- it("renames lessThan/greaterThan to Before/After for date columns", () => {
117
- expect(operatorLabelFor(less, col("date"))).toBe("Before");
118
- expect(operatorLabelFor(greater, col("date"))).toBe("After");
119
- });
120
- it("applies the date relabelling for datetime columns too", () => {
121
- expect(operatorLabelFor(less, col("datetime"))).toBe("Before");
122
- expect(operatorLabelFor(greater, col("datetime"))).toBe("After");
123
- });
124
- it("leaves non-relabelled operators untouched on date columns", () => {
125
- expect(operatorLabelFor(equals, col("date"))).toBe(equals.label);
126
- });
127
- it("keeps the catalogue label for non-date columns", () => {
128
- expect(operatorLabelFor(less, col("number"))).toBe("Less than");
129
- expect(operatorLabelFor(greater, col("number"))).toBe("Greater than");
130
- expect(operatorLabelFor(less, col("text"))).toBe("Less than");
131
- });
132
- it("keeps the catalogue label when the column is undefined", () => {
133
- expect(operatorLabelFor(greater, undefined)).toBe("Greater than");
134
- });
135
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,116 +0,0 @@
1
- /**
2
- * Unit tests for applyExcelFilter. Every operator + edge case.
3
- */
4
- import { describe, expect, it } from 'vitest';
5
- import { applyExcelFilter } from './excel-filters';
6
- const make = (operator, value, valueTo) => ({
7
- id: 'col',
8
- operator,
9
- value,
10
- valueTo,
11
- });
12
- describe('applyExcelFilter - basic operators (smoke regression)', () => {
13
- it('supports text operators (contains, startsWith, equals)', () => {
14
- expect(applyExcelFilter('alphabet', make('contains', 'pha'))).toBe(true);
15
- expect(applyExcelFilter('alphabet', make('startsWith', 'alp'))).toBe(true);
16
- expect(applyExcelFilter('alphabet', make('equals', 'alphabet'))).toBe(true);
17
- });
18
- it('supports numeric operators (greaterThan, between)', () => {
19
- expect(applyExcelFilter(15, make('greaterThan', 10))).toBe(true);
20
- expect(applyExcelFilter(15, make('between', 10, 20))).toBe(true);
21
- });
22
- it('supports blank checks', () => {
23
- expect(applyExcelFilter('', make('isBlank'))).toBe(true);
24
- expect(applyExcelFilter('x', make('isBlank'))).toBe(false);
25
- });
26
- });
27
- describe('applyExcelFilter - contains', () => {
28
- it('matches case-insensitive substrings', () => {
29
- expect(applyExcelFilter('Hello World', make('contains', 'world'))).toBe(true);
30
- expect(applyExcelFilter('Hello World', make('contains', 'World'))).toBe(true);
31
- });
32
- it('returns false when substring absent', () => {
33
- expect(applyExcelFilter('Hello', make('contains', 'xyz'))).toBe(false);
34
- });
35
- it('treats empty filter value as universal match', () => {
36
- expect(applyExcelFilter('anything', make('contains', ''))).toBe(true);
37
- });
38
- it('coerces null cell to empty string', () => {
39
- expect(applyExcelFilter(null, make('contains', 'x'))).toBe(false);
40
- expect(applyExcelFilter(null, make('contains', ''))).toBe(true);
41
- });
42
- });
43
- describe('applyExcelFilter - equals', () => {
44
- it('matches case-insensitively', () => {
45
- expect(applyExcelFilter('Boston', make('equals', 'boston'))).toBe(true);
46
- });
47
- it('rejects partial matches', () => {
48
- expect(applyExcelFilter('Boston', make('equals', 'bost'))).toBe(false);
49
- });
50
- it('treats null as empty', () => {
51
- expect(applyExcelFilter(null, make('equals', ''))).toBe(true);
52
- });
53
- });
54
- describe('applyExcelFilter - startsWith', () => {
55
- it('matches a prefix case-insensitively', () => {
56
- expect(applyExcelFilter('Brooklyn', make('startsWith', 'brook'))).toBe(true);
57
- expect(applyExcelFilter('Brooklyn', make('startsWith', 'lyn'))).toBe(false);
58
- });
59
- });
60
- describe('applyExcelFilter - greaterThan', () => {
61
- it('compares numerically when both sides parse as numbers', () => {
62
- expect(applyExcelFilter(100, make('greaterThan', 99))).toBe(true);
63
- expect(applyExcelFilter('100', make('greaterThan', 50))).toBe(true);
64
- expect(applyExcelFilter(50, make('greaterThan', 50))).toBe(false);
65
- });
66
- it('falls back to string comparison when either side is non-numeric', () => {
67
- expect(applyExcelFilter('banana', make('greaterThan', 'apple'))).toBe(true);
68
- expect(applyExcelFilter('apple', make('greaterThan', 'banana'))).toBe(false);
69
- });
70
- it('treats null on either side as empty string in the fallback', () => {
71
- expect(applyExcelFilter(null, make('greaterThan', 'a'))).toBe(false);
72
- expect(applyExcelFilter('a', make('greaterThan', null))).toBe(true);
73
- });
74
- });
75
- describe('applyExcelFilter - lessThan', () => {
76
- it('compares numerically when both sides parse', () => {
77
- expect(applyExcelFilter(10, make('lessThan', 20))).toBe(true);
78
- expect(applyExcelFilter(20, make('lessThan', 10))).toBe(false);
79
- });
80
- it('falls back to string comparison', () => {
81
- expect(applyExcelFilter('apple', make('lessThan', 'banana'))).toBe(true);
82
- });
83
- it('treats nulls as empty strings in fallback', () => {
84
- expect(applyExcelFilter(null, make('lessThan', 'a'))).toBe(true);
85
- });
86
- });
87
- describe('applyExcelFilter - between', () => {
88
- it('includes both endpoints', () => {
89
- expect(applyExcelFilter(5, make('between', 1, 10))).toBe(true);
90
- expect(applyExcelFilter(1, make('between', 1, 10))).toBe(true);
91
- expect(applyExcelFilter(10, make('between', 1, 10))).toBe(true);
92
- });
93
- it('excludes values outside the range', () => {
94
- expect(applyExcelFilter(0, make('between', 1, 10))).toBe(false);
95
- expect(applyExcelFilter(11, make('between', 1, 10))).toBe(false);
96
- });
97
- it('treats undefined endpoints as 0', () => {
98
- expect(applyExcelFilter(0, make('between'))).toBe(true);
99
- expect(applyExcelFilter(1, make('between'))).toBe(false);
100
- });
101
- it('treats null cell as 0', () => {
102
- expect(applyExcelFilter(null, make('between', -1, 1))).toBe(true);
103
- });
104
- });
105
- describe('applyExcelFilter - isBlank', () => {
106
- it('matches null, undefined, and whitespace-only strings', () => {
107
- expect(applyExcelFilter(null, make('isBlank'))).toBe(true);
108
- expect(applyExcelFilter(undefined, make('isBlank'))).toBe(true);
109
- expect(applyExcelFilter('', make('isBlank'))).toBe(true);
110
- expect(applyExcelFilter(' ', make('isBlank'))).toBe(true);
111
- });
112
- it('rejects non-blank content', () => {
113
- expect(applyExcelFilter('x', make('isBlank'))).toBe(false);
114
- expect(applyExcelFilter(0, make('isBlank'))).toBe(false);
115
- });
116
- });
@@ -1,13 +0,0 @@
1
- /**
2
- * Pure unit tests for the locale-aware text normalization + Excel
3
- * filter pipeline. No DOM, no mounted grid - just the two exported
4
- * helpers `normalizeForFilter` and `applyExcelFilter`.
5
- *
6
- * Covers:
7
- * - Diacritic stripping (Café → cafe)
8
- * - Composed / decomposed Unicode round-trip
9
- * - Locale-specific lowercasing (Turkish dotted-I)
10
- * - All Excel operators × locale option × accented inputs
11
- * - Edge cases: empty strings, null/undefined, numeric mixed with text
12
- */
13
- export {};
@@ -1,189 +0,0 @@
1
- /**
2
- * Pure unit tests for the locale-aware text normalization + Excel
3
- * filter pipeline. No DOM, no mounted grid - just the two exported
4
- * helpers `normalizeForFilter` and `applyExcelFilter`.
5
- *
6
- * Covers:
7
- * - Diacritic stripping (Café → cafe)
8
- * - Composed / decomposed Unicode round-trip
9
- * - Locale-specific lowercasing (Turkish dotted-I)
10
- * - All Excel operators × locale option × accented inputs
11
- * - Edge cases: empty strings, null/undefined, numeric mixed with text
12
- */
13
- import { describe, expect, it } from 'vitest';
14
- import { applyExcelFilter, normalizeForFilter, } from './excel-filters';
15
- describe('normalizeForFilter - diacritic stripping', () => {
16
- it('strips Latin accents (NFD path)', () => {
17
- expect(normalizeForFilter('Café')).toBe('cafe');
18
- expect(normalizeForFilter('CAFÉ')).toBe('cafe');
19
- expect(normalizeForFilter('München')).toBe('munchen');
20
- expect(normalizeForFilter('São Paulo')).toBe('sao paulo');
21
- expect(normalizeForFilter('Tōkyō')).toBe('tokyo');
22
- expect(normalizeForFilter('Genève')).toBe('geneve');
23
- expect(normalizeForFilter('Québec')).toBe('quebec');
24
- expect(normalizeForFilter('Málaga')).toBe('malaga');
25
- expect(normalizeForFilter('Brasília')).toBe('brasilia');
26
- });
27
- it('handles already-decomposed input (NFD-stable)', () => {
28
- // "Café" composed (4 code points) vs decomposed (5 code points).
29
- const composed = 'Café'.normalize('NFC');
30
- const decomposed = 'Café'.normalize('NFD');
31
- expect(normalizeForFilter(composed)).toBe('cafe');
32
- expect(normalizeForFilter(decomposed)).toBe('cafe');
33
- });
34
- it('preserves base ASCII unchanged', () => {
35
- expect(normalizeForFilter('Hello World')).toBe('hello world');
36
- expect(normalizeForFilter('ABC-123')).toBe('abc-123');
37
- expect(normalizeForFilter('email@example.com')).toBe('email@example.com');
38
- });
39
- it('returns empty string for empty / falsy input', () => {
40
- expect(normalizeForFilter('')).toBe('');
41
- });
42
- it('keeps non-Latin alphabets intact', () => {
43
- // The diacritic strip only touches the Combining Diacritical Marks
44
- // block (U+0300..U+036F). CJK / Cyrillic / Arabic stay as-is.
45
- expect(normalizeForFilter('東京')).toBe('東京');
46
- expect(normalizeForFilter('Москва')).toBe('москва');
47
- expect(normalizeForFilter('القاهرة')).toBe('القاهرة');
48
- });
49
- });
50
- describe('normalizeForFilter - locale-aware lowercase', () => {
51
- it('default (no locale) makes English "istanbul" match dotted Turkish "İstanbul"', () => {
52
- // No locale: NFD decomposes İ → I + combining dot above; the dot is
53
- // stripped; remaining 'I' becomes 'i' under default lowercase.
54
- expect(normalizeForFilter('İstanbul')).toBe('istanbul');
55
- expect(normalizeForFilter('istanbul')).toBe('istanbul');
56
- });
57
- it('Turkish locale honors dotted-I / dotless-i asymmetry', () => {
58
- // With "tr-TR" the bare 'I' (post-dot-strip) lowercases to dotless
59
- // 'ı'. This is intentional Turkish behavior and is why we expose a
60
- // locale prop: consumers who explicitly want Turkish casing get it.
61
- // English-typed "istanbul" then no longer matches Turkish "İstanbul"
62
- // - locale-pickers should make that trade-off knowingly.
63
- expect(normalizeForFilter('İSTANBUL', 'tr-TR')).toBe('ıstanbul');
64
- expect(normalizeForFilter('I', 'tr-TR')).toBe('ı');
65
- });
66
- it('default (no locale) behaves like toLowerCase()', () => {
67
- expect(normalizeForFilter('HELLO')).toBe('hello');
68
- expect(normalizeForFilter('CafÉ')).toBe('cafe'); // É
69
- });
70
- it('accepts an array of fallback locales', () => {
71
- expect(normalizeForFilter('Café', ['fr-CA', 'en-US'])).toBe('cafe');
72
- });
73
- it('Greek / Cyrillic / German all fold cleanly', () => {
74
- // Greek: stripped tones (oxia)
75
- expect(normalizeForFilter('Αθήνα')).toBe('αθηνα');
76
- // German: umlauts strip
77
- expect(normalizeForFilter('Düsseldorf')).toBe('dusseldorf');
78
- // Cyrillic: no diacritics, just locale-aware lowercase
79
- expect(normalizeForFilter('Москва', 'ru-RU')).toBe('москва');
80
- });
81
- });
82
- describe('applyExcelFilter - contains (locale-aware)', () => {
83
- it('matches case + accent insensitively without a locale', () => {
84
- const ok = applyExcelFilter('Café Genève', {
85
- id: 'name', operator: 'contains', value: 'cafe geneve',
86
- });
87
- expect(ok).toBe(true);
88
- });
89
- it('matches with a German locale', () => {
90
- const ok = applyExcelFilter('München', {
91
- id: 'city', operator: 'contains', value: 'munch',
92
- }, { locale: 'de-DE' });
93
- expect(ok).toBe(true);
94
- });
95
- it('matches with a French locale', () => {
96
- const ok = applyExcelFilter('Montréal', {
97
- id: 'city', operator: 'contains', value: 'montreal',
98
- }, { locale: 'fr-CA' });
99
- expect(ok).toBe(true);
100
- });
101
- it('matches with a Portuguese locale', () => {
102
- const ok = applyExcelFilter('São Paulo', {
103
- id: 'city', operator: 'contains', value: 'sao paulo',
104
- }, { locale: 'pt-BR' });
105
- expect(ok).toBe(true);
106
- });
107
- it('rejects non-matching queries even with locale', () => {
108
- const ok = applyExcelFilter('München', {
109
- id: 'city', operator: 'contains', value: 'berlin',
110
- }, { locale: 'de-DE' });
111
- expect(ok).toBe(false);
112
- });
113
- it('empty needle matches every cell (includes "")', () => {
114
- expect(applyExcelFilter('München', {
115
- id: 'city', operator: 'contains', value: '',
116
- })).toBe(true);
117
- });
118
- });
119
- describe('applyExcelFilter - equals (locale-aware)', () => {
120
- it('case + accent insensitive equals', () => {
121
- expect(applyExcelFilter('Café', { id: 'x', operator: 'equals', value: 'CAFE' })).toBe(true);
122
- expect(applyExcelFilter('Café', { id: 'x', operator: 'equals', value: 'cafe' })).toBe(true);
123
- expect(applyExcelFilter('Café', { id: 'x', operator: 'equals', value: 'Café' })).toBe(true);
124
- });
125
- it('rejects when normalized strings differ', () => {
126
- expect(applyExcelFilter('Café', { id: 'x', operator: 'equals', value: 'cafes' })).toBe(false);
127
- expect(applyExcelFilter('Café', { id: 'x', operator: 'equals', value: 'café!' })).toBe(false);
128
- });
129
- });
130
- describe('applyExcelFilter - startsWith (locale-aware)', () => {
131
- it('matches stripped prefix', () => {
132
- expect(applyExcelFilter('München-Schwabing', {
133
- id: 'x', operator: 'startsWith', value: 'munchen',
134
- })).toBe(true);
135
- });
136
- it('rejects mid-string match', () => {
137
- expect(applyExcelFilter('Großmünchen', {
138
- id: 'x', operator: 'startsWith', value: 'munchen',
139
- })).toBe(false);
140
- });
141
- });
142
- describe('applyExcelFilter - numeric operators (locale-independent)', () => {
143
- it('greaterThan / lessThan / between still work', () => {
144
- expect(applyExcelFilter(150, { id: 'price', operator: 'greaterThan', value: 100 })).toBe(true);
145
- expect(applyExcelFilter(150, { id: 'price', operator: 'lessThan', value: 200 })).toBe(true);
146
- expect(applyExcelFilter(150, {
147
- id: 'price', operator: 'between', value: 100, valueTo: 200,
148
- })).toBe(true);
149
- });
150
- it('between rejects out-of-range', () => {
151
- expect(applyExcelFilter(50, {
152
- id: 'price', operator: 'between', value: 100, valueTo: 200,
153
- })).toBe(false);
154
- });
155
- });
156
- describe('applyExcelFilter - isBlank', () => {
157
- it('treats empty / whitespace-only as blank', () => {
158
- expect(applyExcelFilter('', { id: 'x', operator: 'isBlank' })).toBe(true);
159
- expect(applyExcelFilter(' ', { id: 'x', operator: 'isBlank' })).toBe(true);
160
- expect(applyExcelFilter(null, { id: 'x', operator: 'isBlank' })).toBe(true);
161
- expect(applyExcelFilter(undefined, { id: 'x', operator: 'isBlank' })).toBe(true);
162
- });
163
- it('rejects non-blank cells', () => {
164
- expect(applyExcelFilter('Café', { id: 'x', operator: 'isBlank' })).toBe(false);
165
- expect(applyExcelFilter(' x ', { id: 'x', operator: 'isBlank' })).toBe(false);
166
- });
167
- });
168
- describe('applyExcelFilter - regression: pre-locale behavior preserved', () => {
169
- // Before locale support, ASCII case-insensitive matching was the rule.
170
- // Verify nothing regressed for the common path.
171
- it('plain ASCII contains', () => {
172
- expect(applyExcelFilter('Ada Lovelace', {
173
- id: 'name', operator: 'contains', value: 'lovelace',
174
- })).toBe(true);
175
- expect(applyExcelFilter('Ada Lovelace', {
176
- id: 'name', operator: 'contains', value: 'LOVELACE',
177
- })).toBe(true);
178
- });
179
- it('plain ASCII equals', () => {
180
- expect(applyExcelFilter('active', {
181
- id: 'status', operator: 'equals', value: 'ACTIVE',
182
- })).toBe(true);
183
- });
184
- it('plain ASCII startsWith', () => {
185
- expect(applyExcelFilter('Linus Torvalds', {
186
- id: 'name', operator: 'startsWith', value: 'linus',
187
- })).toBe(true);
188
- });
189
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,142 +0,0 @@
1
- /**
2
- * FlexRender tests. The component routes one of {content+context, cell,
3
- * header, footer} into the right render path: string, RenderComponentConfig,
4
- * RenderSnippetConfig, or raw value.
5
- */
6
- import { describe, expect, it } from 'vitest';
7
- import { mount, unmount } from 'svelte';
8
- import FlexRender from './FlexRender.svelte';
9
- import { RenderComponentConfig, RenderSnippetConfig } from './render-component';
10
- function mountFlex(props) {
11
- const target = document.createElement('div');
12
- document.body.appendChild(target);
13
- const app = mount(FlexRender, { target, props });
14
- return {
15
- target,
16
- destroy: () => {
17
- unmount(app);
18
- target.remove();
19
- },
20
- };
21
- }
22
- describe('FlexRender', () => {
23
- it('renders a plain string content directly', () => {
24
- const { target, destroy } = mountFlex({
25
- content: 'Hello header',
26
- context: { column: {}, table: {} },
27
- });
28
- try {
29
- expect(target.textContent).toContain('Hello header');
30
- }
31
- finally {
32
- destroy();
33
- }
34
- });
35
- it('calls a function content with the context and renders the result', () => {
36
- const fn = (ctx) => `value=${ctx.value}`;
37
- const { target, destroy } = mountFlex({
38
- content: fn,
39
- context: { value: 42 },
40
- });
41
- try {
42
- expect(target.textContent).toContain('value=42');
43
- }
44
- finally {
45
- destroy();
46
- }
47
- });
48
- it('renders nothing when content is undefined', () => {
49
- const { target, destroy } = mountFlex({
50
- content: undefined,
51
- context: {},
52
- });
53
- try {
54
- expect(target.textContent?.trim()).toBe('');
55
- }
56
- finally {
57
- destroy();
58
- }
59
- });
60
- it('pulls content + context from `cell` when provided', () => {
61
- const cell = {
62
- column: { columnDef: { cell: (ctx) => `row=${ctx.row.id}` } },
63
- getContext: () => ({ row: { id: 7 } }),
64
- };
65
- const { target, destroy } = mountFlex({ cell });
66
- try {
67
- expect(target.textContent).toContain('row=7');
68
- }
69
- finally {
70
- destroy();
71
- }
72
- });
73
- it('pulls content + context from `header` when provided', () => {
74
- const header = {
75
- column: { columnDef: { header: 'Total' } },
76
- getContext: () => ({}),
77
- };
78
- const { target, destroy } = mountFlex({ header });
79
- try {
80
- expect(target.textContent).toContain('Total');
81
- }
82
- finally {
83
- destroy();
84
- }
85
- });
86
- it('pulls content + context from `footer` when provided', () => {
87
- const footer = {
88
- column: { columnDef: { footer: 'Sum' } },
89
- getContext: () => ({}),
90
- };
91
- const { target, destroy } = mountFlex({ footer });
92
- try {
93
- expect(target.textContent).toContain('Sum');
94
- }
95
- finally {
96
- destroy();
97
- }
98
- });
99
- it('renders a RenderComponentConfig result (smoke)', () => {
100
- // Anonymous Svelte-like component would require compilation; we just
101
- // exercise the constructor path so the discriminator branch executes.
102
- const fn = () => new RenderComponentConfig(null, {});
103
- const { destroy } = mountFlex({
104
- content: fn,
105
- context: {},
106
- });
107
- try {
108
- // No throw means the discriminator was hit.
109
- expect(true).toBe(true);
110
- }
111
- finally {
112
- destroy();
113
- }
114
- });
115
- it('renders a RenderSnippetConfig result (smoke)', () => {
116
- const fakeSnippet = (() => null);
117
- const fn = () => new RenderSnippetConfig(fakeSnippet, undefined);
118
- const { destroy } = mountFlex({
119
- content: fn,
120
- context: {},
121
- });
122
- try {
123
- expect(true).toBe(true);
124
- }
125
- finally {
126
- destroy();
127
- }
128
- });
129
- it('renders a raw scalar value when the function returns one', () => {
130
- const fn = () => 99;
131
- const { target, destroy } = mountFlex({
132
- content: fn,
133
- context: {},
134
- });
135
- try {
136
- expect(target.textContent).toContain('99');
137
- }
138
- finally {
139
- destroy();
140
- }
141
- });
142
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,32 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { applyGroupAggregate } from './core';
3
- // Minimal Row stubs - applyGroupAggregate only touches getCellValueByColumnId
4
- // and original.
5
- function rows(values) {
6
- return values.map((v) => ({
7
- original: { v, cat: 'x' },
8
- getCellValueByColumnId: (id) => (id === 'v' ? v : 'x'),
9
- }));
10
- }
11
- describe('applyGroupAggregate', () => {
12
- const r = rows([10, 20, 30]);
13
- it('sum / avg / min / max', () => {
14
- expect(applyGroupAggregate('sum', 'v', r)).toBe(60);
15
- expect(applyGroupAggregate('avg', 'v', r)).toBe(20);
16
- expect(applyGroupAggregate('min', 'v', r)).toBe(10);
17
- expect(applyGroupAggregate('max', 'v', r)).toBe(30);
18
- });
19
- it('count / countDistinct / first / extent', () => {
20
- expect(applyGroupAggregate('count', 'v', r)).toBe(3);
21
- expect(applyGroupAggregate('countDistinct', 'cat', r)).toBe(1);
22
- expect(applyGroupAggregate('first', 'v', r)).toBe(10);
23
- expect(applyGroupAggregate('extent', 'v', r)).toBe('10 – 30');
24
- });
25
- it('custom function receives numeric values + rows', () => {
26
- const median = applyGroupAggregate((vals) => vals.sort((a, b) => a - b)[Math.floor(vals.length / 2)], 'v', r);
27
- expect(median).toBe(20);
28
- });
29
- it('numeric reducers ignore non-numeric and empty groups', () => {
30
- expect(applyGroupAggregate('sum', 'v', rows([]))).toBeUndefined();
31
- });
32
- });
@@ -1 +0,0 @@
1
- export {};