@svgrid/grid 1.0.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 (213) hide show
  1. package/LICENSE +33 -0
  2. package/README.md +39 -0
  3. package/dist/FlexRender.svelte +96 -0
  4. package/dist/FlexRender.svelte.d.ts +49 -0
  5. package/dist/SvGrid.svelte +8742 -0
  6. package/dist/SvGrid.svelte.d.ts +381 -0
  7. package/dist/SvGridChart.svelte +653 -0
  8. package/dist/SvGridChart.svelte.d.ts +25 -0
  9. package/dist/SvGridChart.test.d.ts +1 -0
  10. package/dist/SvGridChart.test.js +62 -0
  11. package/dist/SvGridDropdown.svelte +675 -0
  12. package/dist/SvGridDropdown.svelte.d.ts +40 -0
  13. package/dist/a11y.contract.test.d.ts +1 -0
  14. package/dist/a11y.contract.test.js +39 -0
  15. package/dist/a11y.d.ts +38 -0
  16. package/dist/a11y.js +37 -0
  17. package/dist/a11y.test.d.ts +1 -0
  18. package/dist/a11y.test.js +44 -0
  19. package/dist/cell-formatting.d.ts +17 -0
  20. package/dist/cell-formatting.js +141 -0
  21. package/dist/cell-formatting.test.d.ts +1 -0
  22. package/dist/cell-formatting.test.js +234 -0
  23. package/dist/chart-export.d.ts +14 -0
  24. package/dist/chart-export.js +112 -0
  25. package/dist/chart.d.ts +226 -0
  26. package/dist/chart.js +732 -0
  27. package/dist/chart.test.d.ts +1 -0
  28. package/dist/chart.test.js +289 -0
  29. package/dist/collaboration.d.ts +74 -0
  30. package/dist/collaboration.js +98 -0
  31. package/dist/collaboration.test.d.ts +1 -0
  32. package/dist/collaboration.test.js +65 -0
  33. package/dist/conditional-formatting.d.ts +91 -0
  34. package/dist/conditional-formatting.js +170 -0
  35. package/dist/conditional-formatting.test.d.ts +1 -0
  36. package/dist/conditional-formatting.test.js +87 -0
  37. package/dist/core.coverage.test.d.ts +1 -0
  38. package/dist/core.coverage.test.js +186 -0
  39. package/dist/core.d.ts +370 -0
  40. package/dist/core.js +568 -0
  41. package/dist/core.performance.test.d.ts +1 -0
  42. package/dist/core.performance.test.js +29 -0
  43. package/dist/createGrid.svelte.d.ts +6 -0
  44. package/dist/createGrid.svelte.js +17 -0
  45. package/dist/createGrid.test.d.ts +1 -0
  46. package/dist/createGrid.test.js +9 -0
  47. package/dist/createGridState.svelte.d.ts +3 -0
  48. package/dist/createGridState.svelte.js +13 -0
  49. package/dist/editors/cell-editors.d.ts +23 -0
  50. package/dist/editors/cell-editors.js +97 -0
  51. package/dist/editors/cell-editors.test.d.ts +1 -0
  52. package/dist/editors/cell-editors.test.js +75 -0
  53. package/dist/fill-patterns.d.ts +30 -0
  54. package/dist/fill-patterns.js +207 -0
  55. package/dist/fill-patterns.test.d.ts +1 -0
  56. package/dist/fill-patterns.test.js +81 -0
  57. package/dist/filtering/excel-filters.d.ts +26 -0
  58. package/dist/filtering/excel-filters.js +64 -0
  59. package/dist/filtering/excel-filters.test.d.ts +1 -0
  60. package/dist/filtering/excel-filters.test.js +116 -0
  61. package/dist/filtering/locale-filter.test.d.ts +13 -0
  62. package/dist/filtering/locale-filter.test.js +189 -0
  63. package/dist/flex-render.d.ts +1 -0
  64. package/dist/flex-render.js +2 -0
  65. package/dist/flex-render.test.d.ts +1 -0
  66. package/dist/flex-render.test.js +142 -0
  67. package/dist/group-aggregate.test.d.ts +1 -0
  68. package/dist/group-aggregate.test.js +32 -0
  69. package/dist/index.d.ts +29 -0
  70. package/dist/index.js +27 -0
  71. package/dist/keyboard.d.ts +8 -0
  72. package/dist/keyboard.js +91 -0
  73. package/dist/keyboard.test.d.ts +1 -0
  74. package/dist/keyboard.test.js +27 -0
  75. package/dist/merge-objects.d.ts +9 -0
  76. package/dist/merge-objects.js +28 -0
  77. package/dist/named-views.d.ts +42 -0
  78. package/dist/named-views.js +80 -0
  79. package/dist/named-views.test.d.ts +1 -0
  80. package/dist/named-views.test.js +57 -0
  81. package/dist/new-features.test.d.ts +1 -0
  82. package/dist/new-features.test.js +183 -0
  83. package/dist/render-component.d.ts +13 -0
  84. package/dist/render-component.js +14 -0
  85. package/dist/render-component.test.d.ts +1 -0
  86. package/dist/render-component.test.js +41 -0
  87. package/dist/server-data-source.d.ts +76 -0
  88. package/dist/server-data-source.js +83 -0
  89. package/dist/server-data-source.test.d.ts +1 -0
  90. package/dist/server-data-source.test.js +81 -0
  91. package/dist/sparkline.d.ts +56 -0
  92. package/dist/sparkline.js +97 -0
  93. package/dist/sparkline.test.d.ts +1 -0
  94. package/dist/sparkline.test.js +52 -0
  95. package/dist/static-functions.d.ts +1 -0
  96. package/dist/static-functions.js +1 -0
  97. package/dist/subscribe.d.ts +9 -0
  98. package/dist/subscribe.js +31 -0
  99. package/dist/subscribe.test.d.ts +1 -0
  100. package/dist/subscribe.test.js +93 -0
  101. package/dist/sv-grid-scrollbar.d.ts +1 -0
  102. package/dist/sv-grid-scrollbar.js +310 -0
  103. package/dist/svgrid-wrapper.types.d.ts +341 -0
  104. package/dist/svgrid-wrapper.types.js +1 -0
  105. package/dist/svgrid.api-extensions.test.d.ts +14 -0
  106. package/dist/svgrid.api-extensions.test.js +334 -0
  107. package/dist/svgrid.api.test.d.ts +15 -0
  108. package/dist/svgrid.api.test.js +169 -0
  109. package/dist/svgrid.behavior.test.d.ts +15 -0
  110. package/dist/svgrid.behavior.test.js +605 -0
  111. package/dist/svgrid.column-reorder.test.d.ts +15 -0
  112. package/dist/svgrid.column-reorder.test.js +224 -0
  113. package/dist/svgrid.features.test.d.ts +1 -0
  114. package/dist/svgrid.features.test.js +129 -0
  115. package/dist/svgrid.interaction.test.d.ts +9 -0
  116. package/dist/svgrid.interaction.test.js +318 -0
  117. package/dist/svgrid.locale-filtering.test.d.ts +15 -0
  118. package/dist/svgrid.locale-filtering.test.js +261 -0
  119. package/dist/svgrid.new-features.wrapper.test.d.ts +1 -0
  120. package/dist/svgrid.new-features.wrapper.test.js +136 -0
  121. package/dist/svgrid.row-pinning.test.d.ts +14 -0
  122. package/dist/svgrid.row-pinning.test.js +250 -0
  123. package/dist/svgrid.set-filter.test.d.ts +17 -0
  124. package/dist/svgrid.set-filter.test.js +268 -0
  125. package/dist/svgrid.wrapper.test.d.ts +1 -0
  126. package/dist/svgrid.wrapper.test.js +33 -0
  127. package/dist/test-setup.d.ts +1 -0
  128. package/dist/test-setup.js +29 -0
  129. package/dist/transaction.test.d.ts +1 -0
  130. package/dist/transaction.test.js +89 -0
  131. package/dist/virtualization/column-virtualizer.d.ts +20 -0
  132. package/dist/virtualization/column-virtualizer.js +19 -0
  133. package/dist/virtualization/column-virtualizer.test.d.ts +1 -0
  134. package/dist/virtualization/column-virtualizer.test.js +25 -0
  135. package/dist/virtualization/svelte-virtualizer.svelte.d.ts +11 -0
  136. package/dist/virtualization/svelte-virtualizer.svelte.js +20 -0
  137. package/dist/virtualization/types.d.ts +28 -0
  138. package/dist/virtualization/types.js +1 -0
  139. package/dist/virtualization/virtualizer.d.ts +13 -0
  140. package/dist/virtualization/virtualizer.js +232 -0
  141. package/dist/virtualization/virtualizer.test.d.ts +1 -0
  142. package/dist/virtualization/virtualizer.test.js +41 -0
  143. package/package.json +69 -0
  144. package/src/FlexRender.svelte +96 -0
  145. package/src/SvGrid.svelte +8742 -0
  146. package/src/SvGridChart.svelte +653 -0
  147. package/src/SvGridChart.test.ts +69 -0
  148. package/src/SvGridDropdown.svelte +675 -0
  149. package/src/a11y.contract.test.ts +49 -0
  150. package/src/a11y.test.ts +59 -0
  151. package/src/a11y.ts +59 -0
  152. package/src/cell-formatting.test.ts +273 -0
  153. package/src/cell-formatting.ts +169 -0
  154. package/src/chart-export.ts +144 -0
  155. package/src/chart.test.ts +311 -0
  156. package/src/chart.ts +934 -0
  157. package/src/collaboration.test.ts +74 -0
  158. package/src/collaboration.ts +161 -0
  159. package/src/conditional-formatting.test.ts +107 -0
  160. package/src/conditional-formatting.ts +239 -0
  161. package/src/core.coverage.test.ts +230 -0
  162. package/src/core.performance.test.ts +30 -0
  163. package/src/core.ts +991 -0
  164. package/src/createGrid.svelte.ts +42 -0
  165. package/src/createGrid.test.ts +10 -0
  166. package/src/createGridState.svelte.ts +17 -0
  167. package/src/editors/cell-editors.test.ts +80 -0
  168. package/src/editors/cell-editors.ts +127 -0
  169. package/src/fill-patterns.test.ts +93 -0
  170. package/src/fill-patterns.ts +229 -0
  171. package/src/filtering/excel-filters.test.ts +131 -0
  172. package/src/filtering/excel-filters.ts +101 -0
  173. package/src/filtering/locale-filter.test.ts +220 -0
  174. package/src/flex-render.test.ts +143 -0
  175. package/src/flex-render.ts +3 -0
  176. package/src/group-aggregate.test.ts +48 -0
  177. package/src/index.ts +159 -0
  178. package/src/keyboard.test.ts +59 -0
  179. package/src/keyboard.ts +97 -0
  180. package/src/merge-objects.ts +48 -0
  181. package/src/named-views.test.ts +66 -0
  182. package/src/named-views.ts +120 -0
  183. package/src/new-features.test.ts +217 -0
  184. package/src/render-component.test.ts +51 -0
  185. package/src/render-component.ts +28 -0
  186. package/src/server-data-source.test.ts +88 -0
  187. package/src/server-data-source.ts +163 -0
  188. package/src/sparkline.test.ts +59 -0
  189. package/src/sparkline.ts +164 -0
  190. package/src/static-functions.ts +11 -0
  191. package/src/subscribe.test.ts +103 -0
  192. package/src/subscribe.ts +38 -0
  193. package/src/sv-grid-scrollbar.ts +347 -0
  194. package/src/svgrid-wrapper.types.ts +382 -0
  195. package/src/svgrid.api-extensions.test.ts +362 -0
  196. package/src/svgrid.api.test.ts +192 -0
  197. package/src/svgrid.behavior.test.ts +657 -0
  198. package/src/svgrid.column-reorder.test.ts +234 -0
  199. package/src/svgrid.features.test.ts +157 -0
  200. package/src/svgrid.interaction.test.ts +355 -0
  201. package/src/svgrid.locale-filtering.test.ts +259 -0
  202. package/src/svgrid.new-features.wrapper.test.ts +164 -0
  203. package/src/svgrid.row-pinning.test.ts +266 -0
  204. package/src/svgrid.set-filter.test.ts +270 -0
  205. package/src/svgrid.wrapper.test.ts +35 -0
  206. package/src/test-setup.ts +37 -0
  207. package/src/transaction.test.ts +100 -0
  208. package/src/virtualization/column-virtualizer.test.ts +27 -0
  209. package/src/virtualization/column-virtualizer.ts +30 -0
  210. package/src/virtualization/svelte-virtualizer.svelte.ts +24 -0
  211. package/src/virtualization/types.ts +30 -0
  212. package/src/virtualization/virtualizer.test.ts +47 -0
  213. package/src/virtualization/virtualizer.ts +270 -0
@@ -0,0 +1,116 @@
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
+ });
@@ -0,0 +1,13 @@
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 {};
@@ -0,0 +1,189 @@
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
+ });
@@ -0,0 +1 @@
1
+ export { default as FlexRender } from './FlexRender.svelte';
@@ -0,0 +1,2 @@
1
+ /// <reference types="svelte" />
2
+ export { default as FlexRender } from './FlexRender.svelte';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,142 @@
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
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
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
+ });
@@ -0,0 +1,29 @@
1
+ export { formatNumericWithConfig, resolveDatePattern } from './cell-formatting';
2
+ export { columnFilteringFeature, columnGroupingFeature, createCoreRowModel, createExpandedRowModel, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, applyGroupAggregate, filterFns, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFns, tableFeatures, type Cell, type CellContext, type EditorContext, type CellData, type ActiveCellState, type CellFormatConfig, type CellFormatter, type Column, type ColumnDef, type ColumnDefTemplate, type GroupAggregator, type Header, type HeaderContext, type HeaderGroup, type Row, type RowData, type SortingState, type SvGrid as SvGridInstance, type SvGridOptions, type TableFeatures, type Updater, } from './core';
3
+ export { createGrid, createSvGrid, type SvelteGrid } from './createGrid.svelte';
4
+ export { createGridState, createSvGridState } from './createGridState.svelte';
5
+ export { subscribeGrid, subscribeSvGrid } from './subscribe';
6
+ export { default as SvGrid } from './SvGrid.svelte';
7
+ export { default as FlexRender } from './FlexRender.svelte';
8
+ export { renderComponent, renderSnippet } from './render-component';
9
+ export { default as SvGridChart } from './SvGridChart.svelte';
10
+ export { buildChart, rowsToChartSpec, niceScale, DEFAULT_PALETTE, type ChartType, type ChartSpec, type ChartSeries, type ChartGeometry, type ChartBar, type ChartLine, type ChartLinePoint, type ChartPieSlice, type ChartSelection, type ChartReferenceLine, type ChartRefLineGeo, type ChartRefLineGeoV, type ChartScatterDot, type ScatterPoint, type NiceScale, } from './chart';
11
+ export { chartToSvgString, downloadChartSvg, chartToPngBlob, downloadChartPng, type ChartExportOptions, } from './chart-export';
12
+ export { buildSparkline, toSparklineValues, type SparklineConfig, type SparklineType, type SparklineGeometry, } from './sparkline';
13
+ export { createCollaboration, broadcastChannelTransport, type CollabUser, type CollabCell, type CollabPresence, type CollabMessage, type CollabTransport, type Collaboration, } from './collaboration';
14
+ export { createServerDataSource, type ServerDataSource, type ServerRequest, type ServerResult, type ServerController, type ServerState, type ServerSortModel, type ServerFilterModel, } from './server-data-source';
15
+ export { createNamedViews, memoryViews, localStorageViews, type SavedView, type ViewStorage, type NamedViews, } from './named-views';
16
+ export { resolveCellFormat, computeColumnStat, lerpColor, contrastText, type ConditionalFormat, type ConditionalFormatSpec, type ColorScaleFormat, type DataBarFormat, type IconSetFormat, type RuleFormat, type ResolvedCellFormat, } from './conditional-formatting';
17
+ export { getKeyboardIntent, getNextActiveCell, type GridKeyboardIntent } from './keyboard';
18
+ export { createVirtualizer } from './virtualization/virtualizer';
19
+ export { createSvelteVirtualizer } from './virtualization/svelte-virtualizer.svelte';
20
+ export { createColumnVirtualizer } from './virtualization/column-virtualizer';
21
+ export type { VirtualItem, VirtualizerOptions, VirtualizerState } from './virtualization/types';
22
+ export type { SvGridApi, SvGridFilterOperator, SvGridWrapperProps } from './svgrid-wrapper.types';
23
+ export { parseEditorValue, normalizeEditorOptions, type CellEditorType, type CellEditorOption, } from './editors/cell-editors';
24
+ export { applyExcelFilter, normalizeForFilter, type ExcelFilter, type ExcelFilterOperator, type ExcelFilterOptions, } from './filtering/excel-filters';
25
+ export { getGridCellDomId, getGridCellA11yProps, getGridHeaderA11yProps, getGridRootA11yProps, getGridRowA11yProps, type GridCellA11yInput, type GridColumnA11yInput, type GridSortDirection, } from './a11y';
26
+ /**
27
+ * Compatibility alias for teams migrating from `createTable`.
28
+ */
29
+ export { createSvGrid as createTable } from './createGrid.svelte';
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ export { formatNumericWithConfig, resolveDatePattern } from './cell-formatting';
2
+ export { columnFilteringFeature, columnGroupingFeature, createCoreRowModel, createExpandedRowModel, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, applyGroupAggregate, filterFns, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFns, tableFeatures, } from './core';
3
+ export { createGrid, createSvGrid } from './createGrid.svelte';
4
+ export { createGridState, createSvGridState } from './createGridState.svelte';
5
+ export { subscribeGrid, subscribeSvGrid } from './subscribe';
6
+ export { default as SvGrid } from './SvGrid.svelte';
7
+ export { default as FlexRender } from './FlexRender.svelte';
8
+ export { renderComponent, renderSnippet } from './render-component';
9
+ export { default as SvGridChart } from './SvGridChart.svelte';
10
+ export { buildChart, rowsToChartSpec, niceScale, DEFAULT_PALETTE, } from './chart';
11
+ export { chartToSvgString, downloadChartSvg, chartToPngBlob, downloadChartPng, } from './chart-export';
12
+ export { buildSparkline, toSparklineValues, } from './sparkline';
13
+ export { createCollaboration, broadcastChannelTransport, } from './collaboration';
14
+ export { createServerDataSource, } from './server-data-source';
15
+ export { createNamedViews, memoryViews, localStorageViews, } from './named-views';
16
+ export { resolveCellFormat, computeColumnStat, lerpColor, contrastText, } from './conditional-formatting';
17
+ export { getKeyboardIntent, getNextActiveCell } from './keyboard';
18
+ export { createVirtualizer } from './virtualization/virtualizer';
19
+ export { createSvelteVirtualizer } from './virtualization/svelte-virtualizer.svelte';
20
+ export { createColumnVirtualizer } from './virtualization/column-virtualizer';
21
+ export { parseEditorValue, normalizeEditorOptions, } from './editors/cell-editors';
22
+ export { applyExcelFilter, normalizeForFilter, } from './filtering/excel-filters';
23
+ export { getGridCellDomId, getGridCellA11yProps, getGridHeaderA11yProps, getGridRootA11yProps, getGridRowA11yProps, } from './a11y';
24
+ /**
25
+ * Compatibility alias for teams migrating from `createTable`.
26
+ */
27
+ export { createSvGrid as createTable } from './createGrid.svelte';
@@ -0,0 +1,8 @@
1
+ import type { ActiveCellState } from './core';
2
+ export type GridKeyboardIntent = 'moveLeft' | 'moveRight' | 'moveUp' | 'moveDown' | 'tabNext' | 'tabPrev' | 'rowStart' | 'rowEnd' | 'gridStart' | 'gridEnd' | 'pageUp' | 'pageDown' | 'activate' | 'clearCells' | 'noop';
3
+ export declare function getKeyboardIntent(event: KeyboardEvent): GridKeyboardIntent;
4
+ export declare function getNextActiveCell(current: ActiveCellState, intent: GridKeyboardIntent, bounds: {
5
+ maxRow: number;
6
+ maxCol: number;
7
+ pageSize?: number;
8
+ }): ActiveCellState;