tablefilter 0.7.4 → 0.7.5

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 (75) hide show
  1. package/.gitattributes +16 -0
  2. package/.github/workflows/build-deploy.yml +30 -2
  3. package/.github/workflows/opencode-review.yml +104 -0
  4. package/.github/workflows/opencode.yml +34 -0
  5. package/ROADMAP/README.md +6 -1
  6. package/ROADMAP/content-projection-parity.md +162 -0
  7. package/ROADMAP/hybrid-migration-strategy.md +48 -7
  8. package/ROADMAP/key-decisions-review.md +5 -3
  9. package/ROADMAP/preliminary-and-milestone-0.8.0-plan.md +11 -12
  10. package/ROADMAP/v1-webcomponents-investigation.md +6 -1
  11. package/dist/starter.html +2 -2
  12. package/dist/tablefilter/style/colsVisibility.css +1 -1
  13. package/dist/tablefilter/style/filtersVisibility.css +1 -1
  14. package/dist/tablefilter/style/tablefilter.css +1 -1
  15. package/dist/tablefilter/style/themes/default/default.css +1 -1
  16. package/dist/tablefilter/style/themes/mytheme/mytheme.css +1 -1
  17. package/dist/tablefilter/style/themes/skyblue/skyblue.css +1 -1
  18. package/dist/tablefilter/style/themes/transparent/transparent.css +1 -1
  19. package/dist/tablefilter/tablefilter.js +1 -1
  20. package/dist/tablefilter/tablefilter.vite.js +4 -0
  21. package/dist/tablefilter/tf-1-a5c3a73bd559e47dd5a2.js +1 -0
  22. package/dist/tablefilter/tf-2-3a936d22b849361acff5.js +6 -0
  23. package/dist/tablefilter.cjs.js +4 -0
  24. package/dist/tablefilter.esm.js +7278 -0
  25. package/dist/tablefilter.umd.js +4 -0
  26. package/package.json +12 -5
  27. package/playwright.config.js +25 -0
  28. package/scripts/check-css-tokens.js +65 -0
  29. package/src/components/table-filter.js +243 -0
  30. package/src/components/tf-clear-button.js +95 -0
  31. package/src/components/tf-rows-counter.js +82 -0
  32. package/src/components/tf-status.js +106 -0
  33. package/src/modules/clearButton.js +65 -11
  34. package/src/modules/rowsCounter.js +48 -25
  35. package/src/modules/statusBar.js +62 -30
  36. package/src/sanitize.js +25 -0
  37. package/static/style/active-header.styl +2 -2
  38. package/static/style/alternating-rows.styl +2 -2
  39. package/static/style/config.styl +18 -18
  40. package/static/style/custom-properties.styl +43 -0
  41. package/static/style/ezedittable.styl +12 -12
  42. package/static/style/filter-checklist.styl +3 -3
  43. package/static/style/filters.styl +8 -8
  44. package/static/style/grid-layout.styl +9 -9
  45. package/static/style/help.styl +9 -9
  46. package/static/style/keyword.styl +1 -1
  47. package/static/style/loader.styl +3 -3
  48. package/static/style/noresults.styl +1 -1
  49. package/static/style/paging.styl +1 -1
  50. package/static/style/rows-counter.styl +1 -1
  51. package/static/style/status-bar.styl +1 -4
  52. package/static/style/tablefilter.styl +1 -0
  53. package/static/style/themes/skyblue/skyblue.styl +2 -2
  54. package/static/style/themes/transparent/transparent.styl +2 -2
  55. package/static/style/toolbar.styl +1 -1
  56. package/static/templates/table-filter.html +40 -0
  57. package/test/playwright/axe.baseline.spec.js +34 -0
  58. package/test/playwright/axe.statusbar.spec.js +35 -0
  59. package/test/playwright/axeScan.js +42 -0
  60. package/test/playwright/ce-bridge.spec.js +167 -0
  61. package/test/playwright/qunit.all.spec.js +10 -0
  62. package/test/playwright/qunit.single.spec.js +14 -0
  63. package/test/playwright/qunitSuite.js +56 -0
  64. package/test/playwright/table-filter.config.spec.js +265 -0
  65. package/test/playwright/table-filter.demo.spec.js +60 -0
  66. package/test/playwright/table-filter.element.spec.js +477 -0
  67. package/test/playwright/tf-clear-button.spec.js +135 -0
  68. package/test/playwright/tf-rows-counter.spec.js +172 -0
  69. package/test/playwright/tf-status.spec.js +258 -0
  70. package/test/test-clear-button.js +1 -0
  71. package/test/test-rows-counter.js +2 -0
  72. package/test/test-status-bar.js +3 -0
  73. package/vite.config.js +71 -0
  74. package/webpack.config.js +12 -0
  75. package/dist/tablefilter/tf-1-d2360db09a424b1ed633.js +0 -1
@@ -0,0 +1,265 @@
1
+ // Component gate (#901): declarative configuration — the `config`
2
+ // JSON attribute merged with kebab-case attributes mapped onto the
3
+ // engine's snake_case options, attributes winning over the blob,
4
+ // valueless attributes enabling their flag, and HTML presentation
5
+ // attributes staying out of the engine config. Fails CI on regression.
6
+
7
+ const { test, expect } = require('@playwright/test');
8
+
9
+ const FIXTURE = '/test/test-emitter.html';
10
+ const COMPONENT = '/src/components/table-filter.js';
11
+
12
+ const VALID_TABLE =
13
+ '<table><tbody>' +
14
+ '<tr><th>City</th></tr>' +
15
+ '<tr><td>Sydney</td></tr>' +
16
+ '<tr><td>Adelaide</td></tr>' +
17
+ '</tbody></table>';
18
+
19
+ // Mounts a <table-filter> with the given extra markup inside the
20
+ // element tag, then reports selected engine state as primitives.
21
+ async function mount(page, elementAttrs, body) {
22
+ return page.evaluate(
23
+ async ({ elementAttrs, component, table, body }) => {
24
+ await import(component);
25
+ const host = document.createElement('div');
26
+ host.innerHTML =
27
+ '<table-filter' + elementAttrs + '>' + table +
28
+ '</table-filter>';
29
+ document.body.appendChild(host);
30
+ const el = host.querySelector('table-filter');
31
+ const tf = el.tf;
32
+ const result = {
33
+ hasTf: Boolean(tf),
34
+ initialized: Boolean(tf && tf.isInitialized()),
35
+ watermark: tf && tf.watermark,
36
+ caseSensitive: tf && tf.caseSensitive,
37
+ onSlcChange: tf && tf.onSlcChange,
38
+ paging: tf && tf.paging,
39
+ colTypes: tf && tf.colTypes,
40
+ hasConfig: tf && tf.hasConfig,
41
+ modCount: tf ? Object.keys(tf.Mod).length : null,
42
+ protoIsPlain: tf ?
43
+ Object.getPrototypeOf(tf.cfg) === Object.prototype :
44
+ null,
45
+ cfgKeys: tf ? Object.keys(tf.cfg) : null,
46
+ validRows: null,
47
+ filterValue: null,
48
+ basePath: tf && tf.basePath,
49
+ themes: tf && tf.themes,
50
+ fltCssClass: tf && tf.fltCssClass,
51
+ fltsRowCssClass: tf && tf.fltsRowCssClass,
52
+ fltMultiCssClass: tf && tf.fltMultiCssClass,
53
+ fltSmallCssClass: tf && tf.fltSmallCssClass,
54
+ singleFltCssClass: tf && tf.singleFltCssClass,
55
+ btnCssClass: tf && tf.btnCssClass
56
+ };
57
+ if (body === 'filter-lowercase') {
58
+ tf.setFilterValue(0, 'sydney');
59
+ tf.filter();
60
+ result.validRows = tf.getValidRowsNb();
61
+ }
62
+ if (body === 'filter-match') {
63
+ tf.setFilterValue(0, 'Sydney');
64
+ tf.filter();
65
+ result.validRows = tf.getValidRowsNb();
66
+ }
67
+ return result;
68
+ },
69
+ {
70
+ elementAttrs,
71
+ component: COMPONENT,
72
+ table: VALID_TABLE,
73
+ body: body || null
74
+ }
75
+ );
76
+ }
77
+
78
+ test('attributes map onto engine options', async ({ page }) => {
79
+ await page.goto(FIXTURE);
80
+ const result = await mount(
81
+ page,
82
+ ' watermark="Search" case-sensitive="true" ' +
83
+ 'col-types=\'["string"]\''
84
+ );
85
+ expect(result.watermark).toBe('Search');
86
+ expect(result.caseSensitive).toBe(true);
87
+ expect(result.colTypes).toEqual(['string']);
88
+ expect(result.initialized).toBe(true);
89
+ });
90
+
91
+ test('config attribute maps a JSON object', async ({ page }) => {
92
+ await page.goto(FIXTURE);
93
+ const result = await mount(
94
+ page,
95
+ ' config=\'{"watermark":"Blob","on_change":false}\''
96
+ );
97
+ expect(result.watermark).toBe('Blob');
98
+ expect(result.onSlcChange).toBe(false);
99
+ });
100
+
101
+ test('attributes win over the config attribute', async ({ page }) => {
102
+ await page.goto(FIXTURE);
103
+ const result = await mount(
104
+ page,
105
+ ' config=\'{"watermark":"Blob"}\' watermark="Explicit"'
106
+ );
107
+ expect(result.watermark).toBe('Explicit');
108
+ });
109
+
110
+ test('for and id are never mapped into the config', async ({ page }) => {
111
+ await page.goto(FIXTURE);
112
+ const result = await mount(page, ' for="demo" id="host-el"');
113
+ expect(result.cfgKeys).not.toContain('for');
114
+ expect(result.cfgKeys).not.toContain('id');
115
+ });
116
+
117
+ test('valueless attributes enable their flag (HTML convention)', async ({
118
+ page
119
+ }) => {
120
+ await page.goto(FIXTURE);
121
+ // <table-filter paging> is the roadmap's primary declarative usage:
122
+ // presence must enable paging, not `Boolean('') === false`.
123
+ const result = await mount(page, ' paging');
124
+ expect(result.paging).toBe(true);
125
+ expect(result.initialized).toBe(true);
126
+ });
127
+
128
+ test('presentation attributes are not engine config', async ({ page }) => {
129
+ await page.goto(FIXTURE);
130
+ const result = await mount(
131
+ page,
132
+ ' class="card" style="color:red" data-x="1" aria-label="grid" ' +
133
+ 'role="region" title="Cities"'
134
+ );
135
+ // A stray class/style/data/aria attribute must not count as
136
+ // configuration: it would flip hasConfig and cut constructed
137
+ // features down to the config-path subset.
138
+ expect(result.cfgKeys).toEqual([]);
139
+ expect(result.hasConfig).toBe(false);
140
+ expect(result.modCount).toBeGreaterThan(3);
141
+ });
142
+
143
+ test('boolean spellings the JSON parser rejects are coerced', async ({
144
+ page
145
+ }) => {
146
+ await page.goto(FIXTURE);
147
+ const result = await mount(
148
+ page,
149
+ ' case-sensitive="False" on-change="FALSE"'
150
+ );
151
+ // Without coercion these stay strings and Boolean('False') is true.
152
+ expect(result.caseSensitive).toBe(false);
153
+ expect(result.onSlcChange).toBe(false);
154
+
155
+ const truthy = await mount(page, ' case-sensitive="True"');
156
+ expect(truthy.caseSensitive).toBe(true);
157
+ });
158
+
159
+ test('prototype-reaching attribute names are ignored', async ({ page }) => {
160
+ await page.goto(FIXTURE);
161
+ const result = await mount(
162
+ page,
163
+ ' __proto__=\'{"paging":true}\' constructor="x" prototype="y"'
164
+ );
165
+ // Assigning config['__proto__'] would invoke the Object.prototype
166
+ // setter and swap the config's prototype instead of setting paging.
167
+ expect(result.protoIsPlain).toBe(true);
168
+ expect(result.hasConfig).toBe(false);
169
+ expect(result.paging).toBe(false);
170
+ });
171
+
172
+ test('no config keeps engine defaults and hasConfig false', async ({
173
+ page
174
+ }) => {
175
+ await page.goto(FIXTURE);
176
+ const result = await mount(page, '');
177
+ // An empty {} reaching the constructor would flip hasConfig and
178
+ // change feature instantiation; the mapping must omit it.
179
+ expect(result.hasConfig).toBe(false);
180
+ expect(result.watermark).toBe('');
181
+ expect(result.initialized).toBe(true);
182
+ });
183
+
184
+ test('invalid config JSON warns and still inits on defaults', async ({
185
+ page
186
+ }) => {
187
+ await page.goto(FIXTURE);
188
+ const warnings = [];
189
+ page.on('console', (msg) => {
190
+ if (msg.type() === 'warning') {
191
+ warnings.push(msg.text());
192
+ }
193
+ });
194
+ const result = await mount(page, ' config="{not json"');
195
+ expect(result.initialized).toBe(true);
196
+ expect(result.watermark).toBe('');
197
+ expect(warnings.join('\n')).toContain('<table-filter>');
198
+ });
199
+
200
+ // Styling configurability lives in the core engine, not only in the
201
+ // features (#993): the loader keys (base_path, themes) and the core
202
+ // filter class options must reach the engine through the declarative
203
+ // surface. NOTE: the `style_path` / `stylesheet` / `themes_path`
204
+ // overrides are currently ignored by the engine (#822), so asserting
205
+ // them here would encode the bug; that is tracked separately.
206
+ test('styling configuration reaches the engine', async ({ page }) => {
207
+ // base_path drives the stylesheet/theme the engine loads on init, and
208
+ // its loader throws from `file.onerror` when a file 404s. Serve the
209
+ // fake path so this test asserts config mapping, not asset
210
+ // availability (otherwise it emits unhandled load errors).
211
+ await page.route('**/assets/tf/**', (route) =>
212
+ route.fulfill({
213
+ status: 200,
214
+ contentType: 'text/css',
215
+ body: ''
216
+ }));
217
+ await page.goto(FIXTURE);
218
+ const result = await mount(
219
+ page,
220
+ ' base-path="/assets/tf/" flt-css-class="my-flt" ' +
221
+ 'flts-row-css-class="my-fltrow" btn-css-class="my-btn" ' +
222
+ 'single-filter=\'{"css_class":"my-single"}\' ' +
223
+ 'config=\'{"themes":[{"name":"skyblue"}],' +
224
+ '"flt_multi_css_class":"my-multi"}\''
225
+ );
226
+ expect(result.initialized).toBe(true);
227
+ // Core stylesheet/theme loader key.
228
+ expect(result.basePath).toBe('/assets/tf/');
229
+ expect(result.themes).toContainEqual({ name: 'skyblue' });
230
+ // Core filter class options.
231
+ expect(result.fltsRowCssClass).toBe('my-fltrow');
232
+ expect(result.fltCssClass).toBe('my-flt');
233
+ expect(result.fltMultiCssClass).toBe('my-multi');
234
+ expect(result.singleFltCssClass).toBe('my-single');
235
+ expect(result.btnCssClass).toBe('my-btn');
236
+ });
237
+
238
+ test('core styling defaults are unchanged when unset', async ({ page }) => {
239
+ await page.goto(FIXTURE);
240
+ const result = await mount(page, '');
241
+ expect(result.basePath).toBe('tablefilter/');
242
+ expect(result.fltsRowCssClass).toBe('fltrow');
243
+ expect(result.fltCssClass).toBe('flt');
244
+ expect(result.fltMultiCssClass).toBe('flt_multi');
245
+ expect(result.fltSmallCssClass).toBe('flt_s');
246
+ expect(result.singleFltCssClass).toBe('single_flt');
247
+ });
248
+
249
+ test('mapped option drives filtering behaviour', async ({ page }) => {
250
+ await page.goto(FIXTURE);
251
+ const match = await mount(page, '', 'filter-match');
252
+ expect(match.validRows).toBe(1);
253
+
254
+ const caseSensitive = await mount(
255
+ page,
256
+ ' case-sensitive="true"',
257
+ 'filter-lowercase'
258
+ );
259
+ // case_sensitive is on: lowercase 'sydney' must not match 'Sydney'
260
+ expect(caseSensitive.validRows).toBe(0);
261
+
262
+ const insensitive = await mount(page, '', 'filter-lowercase');
263
+ // default is case-insensitive: 'sydney' matches
264
+ expect(insensitive.validRows).toBe(1);
265
+ });
@@ -0,0 +1,60 @@
1
+ // Component gate (#904): the declarative demo page mounts and filters,
2
+ // which is the Milestone 0.8.0 acceptance gate for <table-filter>
3
+ // (ROADMAP/preliminary-and-milestone-0.8.0-plan.md, step 1.5). The
4
+ // page lives in static/templates/ and is built into the gitignored
5
+ // demos/ by grunt build-demos; the Vite dev server that serves the
6
+ // repo root compiles the element module it imports. Fails CI on
7
+ // regression.
8
+ const { test, expect } = require('@playwright/test');
9
+
10
+ const DEMO_PAGE = 'demos/table-filter.html';
11
+
12
+ test(`declarative <table-filter> mounts and filters: ${DEMO_PAGE}`, async ({
13
+ page
14
+ }) => {
15
+ await page.goto(`/${DEMO_PAGE}`);
16
+
17
+ // The module registered the custom element.
18
+ await page.waitForFunction(
19
+ () => Boolean(customElements.get('table-filter'))
20
+ );
21
+
22
+ // The engine initialised on connect, so it inserted its filter row
23
+ // into the wrapped table (#demo, from the countries-table partial).
24
+ await page.waitForSelector('table-filter #demo .fltrow', {
25
+ timeout: 15000
26
+ });
27
+
28
+ const result = await page.evaluate(async () => {
29
+ const el = document.querySelector('table-filter');
30
+ const tf = el.tf;
31
+ // Cache-free baseline: getFilteredData() reads a validRowsIndex
32
+ // cache that init() only fills as a side effect of a feature
33
+ // such as alternate_rows, so deriving `before` from it made the
34
+ // gate depend on that styling option.
35
+ const before = tf.getFilterableRowsNb();
36
+ // col-1="select" is applied from the declarative attribute.
37
+ const isoTag = tf.getFilterElement(1).tagName;
38
+
39
+ tf.setFilterValue(1, 'AGO');
40
+ tf.filter();
41
+ const filtered = tf.getFilteredData().length;
42
+
43
+ await tf.clearFilters();
44
+ const restored = tf.getFilteredData().length;
45
+
46
+ return {
47
+ initialized: tf.isInitialized(),
48
+ isoTag,
49
+ before,
50
+ filtered,
51
+ restored
52
+ };
53
+ });
54
+
55
+ expect(result.initialized).toBe(true);
56
+ expect(result.isoTag).toBe('SELECT');
57
+ expect(result.filtered).toBeGreaterThan(0);
58
+ expect(result.filtered).toBeLessThan(result.before);
59
+ expect(result.restored).toBe(result.before);
60
+ });