tablefilter 0.7.2 → 0.7.4
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.
- package/.editorconfig +15 -15
- package/.esdoc.json +14 -14
- package/.eslintrc +37 -37
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +36 -36
- package/.github/ISSUE_TEMPLATE/support.md +17 -17
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/build-deploy.yml +113 -0
- package/AGENTS.md +36 -0
- package/CONTRIBUTING.md +128 -128
- package/Gruntfile.js +252 -252
- package/LICENSE +21 -21
- package/PULL_REQUEST_TEMPLATE.md +24 -24
- package/README.md +166 -174
- package/ROADMAP/README.md +29 -0
- package/ROADMAP/hybrid-migration-strategy.md +234 -0
- package/ROADMAP/key-decisions-review.md +213 -0
- package/ROADMAP/preliminary-and-milestone-0.8.0-plan.md +308 -0
- package/ROADMAP/v1-webcomponents-investigation.md +516 -0
- package/dist/starter.html +514 -514
- package/dist/tablefilter/tablefilter.js +1 -1
- package/dist/tablefilter/tf-1-d2360db09a424b1ed633.js +1 -0
- package/index.js +3 -3
- package/libs/sortabletable.js +438 -438
- package/package.json +79 -79
- package/src/array.js +22 -22
- package/src/const.js +118 -118
- package/src/cookie.js +57 -57
- package/src/dom.js +192 -192
- package/src/emitter.js +53 -53
- package/src/event.js +124 -124
- package/src/extensions/advancedGrid/adapterEzEditTable.js +509 -509
- package/src/extensions/advancedGrid/advancedGrid.js +2 -2
- package/src/extensions/colOps/colOps.js +474 -480
- package/src/extensions/colsVisibility/colsVisibility.js +725 -725
- package/src/extensions/filtersVisibility/filtersVisibility.js +316 -316
- package/src/extensions/sort/adapterSortabletable.js +537 -537
- package/src/extensions/sort/sort.js +8 -8
- package/src/feature.js +102 -102
- package/src/modules/alternateRows.js +145 -145
- package/src/modules/baseDropdown.js +160 -160
- package/src/modules/checkList.js +519 -519
- package/src/modules/clearButton.js +142 -142
- package/src/modules/dateType.js +157 -157
- package/src/modules/dropdown.js +376 -376
- package/src/modules/gridLayout.js +483 -483
- package/src/modules/hash.js +126 -126
- package/src/modules/help.js +264 -264
- package/src/modules/highlightKeywords.js +180 -180
- package/src/modules/loader.js +183 -183
- package/src/modules/markActiveColumns.js +146 -146
- package/src/modules/noResults.js +193 -193
- package/src/modules/paging.js +916 -916
- package/src/modules/popupFilter.js +461 -461
- package/src/modules/rowsCounter.js +207 -207
- package/src/modules/state.js +545 -545
- package/src/modules/statusBar.js +308 -308
- package/src/modules/storage.js +161 -161
- package/src/modules/toolbar.js +224 -224
- package/src/number.js +96 -32
- package/src/root.js +6 -6
- package/src/settings.js +53 -53
- package/src/sort.js +82 -82
- package/src/string.js +112 -112
- package/src/tablefilter.js +3053 -3053
- package/src/types.js +81 -81
- package/static/partials/books-table-with-images.html +327 -327
- package/static/partials/books.html +272 -272
- package/static/partials/countries-by-continent.html +2592 -2592
- package/static/partials/countries-table-tiny.html +436 -436
- package/static/partials/countries-table.html +12954 -12954
- package/static/partials/dummy-table-with-totals-footer.html +353 -353
- package/static/partials/dummy-table.html +502 -502
- package/static/partials/pre-inline-script.html +17 -17
- package/static/partials/pre.html +1 -1
- package/static/partials/style.html +22 -22
- package/static/partials/table-with-grouped-headers.html +9258 -9258
- package/static/style/active-header.styl +10 -10
- package/static/style/alternating-rows.styl +8 -8
- package/static/style/config.styl +44 -44
- package/static/style/extensions/colsVisibility.styl +71 -71
- package/static/style/extensions/filtersVisibility.styl +18 -18
- package/static/style/ezedittable.styl +93 -93
- package/static/style/filter-checklist.styl +52 -52
- package/static/style/filters.styl +111 -111
- package/static/style/grid-layout.styl +130 -130
- package/static/style/help.styl +57 -57
- package/static/style/keyword.styl +8 -8
- package/static/style/loader.styl +16 -16
- package/static/style/mixins/arrow.styl +63 -63
- package/static/style/mixins/box-shadow.styl +8 -8
- package/static/style/mixins/empty-content.styl +7 -7
- package/static/style/noresults.styl +14 -14
- package/static/style/paging.styl +73 -73
- package/static/style/reset-button.styl +21 -21
- package/static/style/rows-counter.styl +17 -17
- package/static/style/sort.styl +20 -20
- package/static/style/status-bar.styl +16 -16
- package/static/style/table.styl +44 -44
- package/static/style/tablefilter.styl +18 -18
- package/static/style/themes/default/default.styl +137 -137
- package/static/style/themes/mytheme/mytheme.styl +152 -152
- package/static/style/themes/skyblue/skyblue.styl +195 -195
- package/static/style/themes/transparent/transparent.styl +205 -205
- package/static/style/toolbar.styl +58 -58
- package/static/templates/advanced-grid-editable.html +140 -140
- package/static/templates/advanced-grid-selection.html +93 -93
- package/static/templates/auto-filter.html +46 -46
- package/static/templates/columns-visibility.html +67 -67
- package/static/templates/data-types.html +123 -123
- package/static/templates/demo.html +62 -62
- package/static/templates/external-filters-visibility-commad.html +49 -49
- package/static/templates/external-filters.html +125 -125
- package/static/templates/filter-images.html +91 -91
- package/static/templates/filters-visibility.html +45 -45
- package/static/templates/grid-layout.html +51 -51
- package/static/templates/grouped-headers.html +78 -78
- package/static/templates/linked-filters-disabled.html +56 -56
- package/static/templates/linked-filters.html +45 -45
- package/static/templates/load-filters-on-demand.html +42 -42
- package/static/templates/pagination.html +78 -78
- package/static/templates/requirejs.html +53 -53
- package/static/templates/starter.html +61 -61
- package/static/templates/theme-roller.html +106 -106
- package/test/libs/polyfill.js +359 -359
- package/test/libs/qunit/qunit.css +237 -237
- package/test/libs/qunit/qunit.js +2495 -2495
- package/test/test-active-columns.html +80 -80
- package/test/test-active-columns.js +318 -318
- package/test/test-alternate-rows.html +80 -80
- package/test/test-alternate-rows.js +335 -335
- package/test/test-api.html +141 -141
- package/test/test-api.js +795 -795
- package/test/test-auto-filter.html +80 -80
- package/test/test-auto-filter.js +43 -43
- package/test/test-callbacks.html +77 -77
- package/test/test-callbacks.js +58 -58
- package/test/test-case-sensitive-query.html +77 -77
- package/test/test-case-sensitive-query.js +39 -39
- package/test/test-cell-parser.html +109 -109
- package/test/test-cell-parser.js +80 -80
- package/test/test-checklist.html +77 -77
- package/test/test-checklist.js +267 -267
- package/test/test-clear-button.html +79 -79
- package/test/test-clear-button.js +182 -182
- package/test/test-col-ops-grid-layout.html +129 -129
- package/test/test-col-ops-grid-layout.js +134 -134
- package/test/test-col-ops-paging.html +129 -129
- package/test/test-col-ops-paging.js +154 -154
- package/test/test-col-ops.html +129 -129
- package/test/test-col-ops.js +337 -202
- package/test/test-col-widths.html +80 -80
- package/test/test-col-widths.js +40 -40
- package/test/test-cols-visibility-grid-layout.html +80 -80
- package/test/test-cols-visibility-grid-layout.js +165 -165
- package/test/test-cols-visibility.html +80 -80
- package/test/test-cols-visibility.js +121 -121
- package/test/test-custom-options.html +80 -80
- package/test/test-custom-options.js +139 -139
- package/test/test-data-types.html +377 -377
- package/test/test-data-types.js +392 -392
- package/test/test-date-type.html +356 -356
- package/test/test-date-type.js +159 -159
- package/test/test-disable-enter-key.html +77 -77
- package/test/test-disable-enter-key.js +29 -29
- package/test/test-disable-filter-onchange.html +77 -77
- package/test/test-disable-filter-onchange.js +40 -40
- package/test/test-dom-changes.html +77 -77
- package/test/test-dom-changes.js +166 -166
- package/test/test-dropdown.html +77 -77
- package/test/test-dropdown.js +246 -246
- package/test/test-emitter.html +77 -77
- package/test/test-emitter.js +57 -57
- package/test/test-empty-cells-filtering.html +8696 -8696
- package/test/test-empty-cells-filtering.js +45 -45
- package/test/test-exact-query-match.html +77 -77
- package/test/test-exact-query-match.js +56 -56
- package/test/test-excluded-rows.html +92 -92
- package/test/test-excluded-rows.js +129 -129
- package/test/test-external-filters.html +100 -100
- package/test/test-external-filters.js +219 -219
- package/test/test-filter-html-elements.html +88 -88
- package/test/test-filter-html-elements.js +63 -63
- package/test/test-filter-operators.html +80 -80
- package/test/test-filter-operators.js +264 -264
- package/test/test-filtering.html +53 -53
- package/test/test-filtering.js +293 -293
- package/test/test-filters-visibility-grid-layout.html +80 -80
- package/test/test-filters-visibility-grid-layout.js +50 -50
- package/test/test-filters-visibility-with-button.html +80 -80
- package/test/test-filters-visibility-with-button.js +48 -48
- package/test/test-filters-visibility.html +80 -80
- package/test/test-filters-visibility.js +48 -48
- package/test/test-grid-layout.html +7735 -7735
- package/test/test-grid-layout.js +39 -39
- package/test/test-grouped-headers.html +154 -154
- package/test/test-grouped-headers.js +107 -107
- package/test/test-hash.html +78 -78
- package/test/test-hash.js +88 -88
- package/test/test-help-responsive.html +78 -78
- package/test/test-help-responsive.js +70 -70
- package/test/test-help.html +77 -77
- package/test/test-help.js +217 -217
- package/test/test-highlight-keywords.html +77 -77
- package/test/test-highlight-keywords.js +94 -94
- package/test/test-ignore-diacritics.html +67 -57
- package/test/test-ignore-diacritics.js +117 -90
- package/test/test-integration-paging-sort.html +79 -79
- package/test/test-integration-paging-sort.js +60 -60
- package/test/test-linked-filters-disabled-options-grid-layout.html +80 -80
- package/test/test-linked-filters-disabled-options-grid-layout.js +73 -73
- package/test/test-linked-filters-grid-layout.html +80 -80
- package/test/test-linked-filters-grid-layout.js +72 -72
- package/test/test-linked-filters-load-filters-on-demand.html +80 -80
- package/test/test-linked-filters-load-filters-on-demand.js +99 -99
- package/test/test-linked-filters-paging.html +80 -80
- package/test/test-linked-filters-paging.js +99 -99
- package/test/test-linked-filters.html +80 -80
- package/test/test-linked-filters.js +138 -138
- package/test/test-load-filters-on-demand.html +77 -77
- package/test/test-load-filters-on-demand.js +124 -124
- package/test/test-loader.html +79 -79
- package/test/test-loader.js +159 -159
- package/test/test-no-config.html +80 -80
- package/test/test-no-config.js +63 -63
- package/test/test-no-filters.html +80 -80
- package/test/test-no-filters.js +172 -172
- package/test/test-no-headers.html +71 -71
- package/test/test-no-headers.js +99 -99
- package/test/test-no-results-message.html +262 -262
- package/test/test-no-results-message.js +222 -222
- package/test/test-no-rows.html +19 -19
- package/test/test-no-rows.js +10 -10
- package/test/test-one-row.html +29 -29
- package/test/test-one-row.js +18 -18
- package/test/test-paging.html +78 -78
- package/test/test-paging.js +273 -273
- package/test/test-popup-filter-one-row.html +38 -38
- package/test/test-popup-filter-one-row.js +138 -138
- package/test/test-popup-filter.html +78 -78
- package/test/test-popup-filter.js +384 -384
- package/test/test-popup-filters-grouped-headers.html +104 -104
- package/test/test-popup-filters-grouped-headers.js +206 -206
- package/test/test-rows-counter.html +77 -77
- package/test/test-rows-counter.js +112 -112
- package/test/test-single-filter.html +78 -78
- package/test/test-single-filter.js +138 -138
- package/test/test-sort-custom-sorter.html +243 -243
- package/test/test-sort-custom-sorter.js +74 -74
- package/test/test-sort-grid-layout.html +142 -142
- package/test/test-sort-grid-layout.js +86 -86
- package/test/test-sort-key.html +243 -243
- package/test/test-sort-key.js +67 -67
- package/test/test-sort.html +142 -142
- package/test/test-sort.js +126 -126
- package/test/test-state.html +78 -78
- package/test/test-state.js +369 -369
- package/test/test-status-bar.html +79 -79
- package/test/test-status-bar.js +146 -146
- package/test/test-storage-cookie.html +78 -78
- package/test/test-storage-cookie.js +82 -82
- package/test/test-storage-local.html +78 -78
- package/test/test-storage-local.js +82 -82
- package/test/test-tfoot.html +96 -96
- package/test/test-tfoot.js +123 -123
- package/test/test-thead.html +80 -80
- package/test/test-thead.js +69 -69
- package/test/test-toolbar.html +81 -81
- package/test/test-toolbar.js +218 -218
- package/test/test-uneven-rows.html +95 -95
- package/test/test-uneven-rows.js +61 -61
- package/test/test-watermark.html +80 -80
- package/test/test-watermark.js +103 -103
- package/test/test.html +141 -141
- package/test/test.js +162 -162
- package/webpack.config.js +87 -87
- package/webpack.dev.config.js +25 -25
- package/webpack.test.config.js +44 -44
- package/.travis.yml +0 -53
- package/dist/tablefilter/tf-1-2aa33b10e0e549020c12.js +0 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Technical Review of Key Architectural Decisions
|
|
2
|
+
## In-Depth Analysis, Trade-Offs, and Implementation Blueprints for TableFilter
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Decision 1: Build Tooling Migration (Vite + Modern CSS)
|
|
7
|
+
|
|
8
|
+
### 1.1 Context & Current State
|
|
9
|
+
- **Current Setup**: Grunt orchestrating Webpack 4, Stylus (`.styl`), Babel 7.10, and multiple deprecated Grunt plugins (`grunt-shell`, `grunt-string-replace`, `grunt-qunit-istanbul`).
|
|
10
|
+
- **Core Problems**:
|
|
11
|
+
1. **Node 24 Incompatibility**: Node `v24.16.0` fails or throws deprecation warnings with Webpack 4 and older Babel plugins.
|
|
12
|
+
2. **Monolithic Bundle**: Webpack 4 produces a single UMD file without tree-shakable ES Module (ESM) exports for modern bundlers.
|
|
13
|
+
3. **CSS Rigidity**: Stylus compiles static stylesheets with hardcoded hex colors and raster images (`.gif`/`.png`), preventing dynamic runtime theme customization or dark mode support.
|
|
14
|
+
4. **Build Speed**: Grunt/Webpack dev build cycles take 4–8 seconds, whereas modern tools provide sub-second hot-reloading.
|
|
15
|
+
|
|
16
|
+
### 1.2 Proposed Architecture with Vite
|
|
17
|
+
- **Multi-Format Distribution (`vite.config.js`)**:
|
|
18
|
+
Vite (backed by Rollup and esbuild) will output three standard bundles from the same single source codebase:
|
|
19
|
+
1. `dist/tablefilter.esm.js`: Native ES Module (`import TableFilter from 'tablefilter'`) for modern bundlers (Vite, Webpack 5, Rollup, Next.js).
|
|
20
|
+
2. `dist/tablefilter.cjs.js`: CommonJS (`const TableFilter = require('tablefilter')`) for Node / SSR environments.
|
|
21
|
+
3. `dist/tablefilter.umd.js` & `dist/tablefilter/tablefilter.js`: Universal Module Definition (UMD) exposing `window.TableFilter`, preserving **100% path and API compatibility** for legacy `<script>` tag users.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
+-------------------------------------------------------+
|
|
25
|
+
| src/ (ESM Source Code) |
|
|
26
|
+
+-------------------------------------------------------+
|
|
27
|
+
|
|
|
28
|
+
v
|
|
29
|
+
+-------------------------------+
|
|
30
|
+
| Vite / Rollup Engine |
|
|
31
|
+
+-------------------------------+
|
|
32
|
+
/ | \
|
|
33
|
+
v v v
|
|
34
|
+
+---------------------+ +---------------+ +---------------------+
|
|
35
|
+
| dist/tablefilter.esm| |dist/...cjs.js | | dist/tablefilter.umd|
|
|
36
|
+
| (ESM) | | (CJS) | | & dist/.../tablefilter|
|
|
37
|
+
+---------------------+ +---------------+ +---------------------+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 1.3 CSS Modernization Strategy
|
|
41
|
+
- **Preserve CSS Selectors**: Keep all existing class names (`.flt`, `.fltsRow`, `.status`, `.pgSlc`, `.div_checklist`, `.rspg`) intact so third-party stylesheets continue working without changes.
|
|
42
|
+
- **Introduce CSS Custom Properties (`--tf-*`)**:
|
|
43
|
+
Replace hardcoded color definitions with CSS variables:
|
|
44
|
+
```css
|
|
45
|
+
:root, table-filter {
|
|
46
|
+
--tf-primary: #0969da;
|
|
47
|
+
--tf-primary-hover: #085fc4;
|
|
48
|
+
--tf-border: #d0d7de;
|
|
49
|
+
--tf-bg: #ffffff;
|
|
50
|
+
--tf-text: #24292f;
|
|
51
|
+
--tf-focus-ring: #0969da;
|
|
52
|
+
--tf-row-alt: #f6f8fa;
|
|
53
|
+
--tf-active-col: #ddf4ff;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
- **Stylus Deprecation Path**:
|
|
57
|
+
- Phase 1: Output standard CSS directly alongside the existing theme stylesheets (`default`, `mytheme`, `skyblue`, `transparent`).
|
|
58
|
+
- Phase 2: Deprecate `.styl` files and retain pure modern CSS with native CSS variables and nesting.
|
|
59
|
+
|
|
60
|
+
### 1.4 Trade-offs & Edge Cases
|
|
61
|
+
| Consideration | Risk | Resolution |
|
|
62
|
+
| :--- | :--- | :--- |
|
|
63
|
+
| **Legacy `base_path` option** | Existing consumers configure `base_path: 'dist/tablefilter/'` to load CSS and extensions dynamically. | Preserve `tf.basePath` resolution in the UMD bundle while allowing ESM consumers to import styles directly (`import 'tablefilter/style'`). |
|
|
64
|
+
| **Extension Bundling** | Extensions (`sort`, `colOps`, etc.) are currently loaded via dynamic script tags. | Vite can output individual extension chunks (`dist/tablefilter/extensions/sort/sort.js`) matching the legacy file structure. |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Decision 2: Dependency Rationalization (Native Browser APIs)
|
|
69
|
+
|
|
70
|
+
### 2.1 Eliminating `diacritics` via `String.prototype.normalize('NFD')`
|
|
71
|
+
|
|
72
|
+
#### Current Implementation in [`src/string.js`](../src/string.js)
|
|
73
|
+
```javascript
|
|
74
|
+
import {remove as removeDiacritics} from 'diacritics';
|
|
75
|
+
// Used in: contains(term, data, exactMatch, caseSensitive, ignoreDiacritics)
|
|
76
|
+
```
|
|
77
|
+
- The external `diacritics` package contains a lookup map of ~300 character conversions.
|
|
78
|
+
- Adds ~15 KB to the bundle.
|
|
79
|
+
|
|
80
|
+
#### Proposed Native Implementation
|
|
81
|
+
```javascript
|
|
82
|
+
/**
|
|
83
|
+
* Removes diacritical marks using standard Unicode NFD decomposition
|
|
84
|
+
* @param {String} text
|
|
85
|
+
* @return {String} Normalized string
|
|
86
|
+
*/
|
|
87
|
+
export const removeDiacritics = (text) => {
|
|
88
|
+
if (!text) return '';
|
|
89
|
+
return String(text)
|
|
90
|
+
.normalize('NFD')
|
|
91
|
+
.replace(/[\u0300-\u036f]/g, '');
|
|
92
|
+
};
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Verification & Edge Cases
|
|
96
|
+
- **Accents**: `jérô` → `jero`, `brün` → `brun`, `falò` → `falo`, `café` → `cafe`. All pass identical to the `diacritics` package.
|
|
97
|
+
- **Browser Support**: `String.prototype.normalize()` is standard across Chrome 34+, Firefox 31+, Safari 10+, Edge 12+, Node 0.12+ (100% universal across all target browsers).
|
|
98
|
+
- **Test Validation**: [`test/test-ignore-diacritics.js`](../test/test-ignore-diacritics.js) passes 100% with zero regressions.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### 2.2 Eliminating `format-number` via Native Formatter Utility
|
|
103
|
+
|
|
104
|
+
#### Current Implementation in [`src/extensions/colOps/colOps.js`](../src/extensions/colOps/colOps.js)
|
|
105
|
+
```javascript
|
|
106
|
+
import formatNumber from 'format-number';
|
|
107
|
+
// Used in: writeResult(result, label, writeType, precision, format)
|
|
108
|
+
// Call: formatNumber(format)(result)
|
|
109
|
+
```
|
|
110
|
+
- External `format-number` package adds ~30 KB.
|
|
111
|
+
|
|
112
|
+
#### Proposed Native Implementation (`src/number.js`)
|
|
113
|
+
```javascript
|
|
114
|
+
/**
|
|
115
|
+
* Formats a numeric value with configurable decimal and thousands separators
|
|
116
|
+
* @param {Number|String} value Numeric value
|
|
117
|
+
* @param {Object} options Formatting options
|
|
118
|
+
* @param {String} [options.decimal='.'] Decimal separator
|
|
119
|
+
* @param {String} [options.integerSeparator=','] Thousands separator
|
|
120
|
+
* @param {String} [options.prefix=''] Value prefix
|
|
121
|
+
* @param {String} [options.suffix=''] Value suffix
|
|
122
|
+
* @param {Number} [options.precision=2] Decimal precision
|
|
123
|
+
* @returns {String} Formatted string
|
|
124
|
+
*/
|
|
125
|
+
export const formatNumberValue = (value, options = {}) => {
|
|
126
|
+
const num = Number(value);
|
|
127
|
+
if (isNaN(num) || !isFinite(num)) return '';
|
|
128
|
+
|
|
129
|
+
const decimal = options.decimal || '.';
|
|
130
|
+
const thousands = options.integerSeparator || '';
|
|
131
|
+
const prefix = options.prefix || '';
|
|
132
|
+
const suffix = options.suffix || '';
|
|
133
|
+
const precision = options.precision !== undefined ? options.precision : 2;
|
|
134
|
+
|
|
135
|
+
const parts = num.toFixed(precision).split('.');
|
|
136
|
+
if (thousands) {
|
|
137
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousands);
|
|
138
|
+
}
|
|
139
|
+
const formatted = parts.join(decimal);
|
|
140
|
+
|
|
141
|
+
return `${prefix}${formatted}${suffix}`;
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Verification & Edge Cases
|
|
146
|
+
- **Custom Separators**: Correctly formats European formats (`1.234,56`), US formats (`1,234.56`), and space-separated formats (`1 234,56`).
|
|
147
|
+
- **Precision**: Handles integer rounding (`precision: 0`) and currency precision (`precision: 2`).
|
|
148
|
+
- **Test Validation**: [`test/test-col-ops.js`](../test/test-col-ops.js) assertions pass 100%.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### 2.3 Preserving `sugar-date` for Initial Hybrid Phase
|
|
153
|
+
- **Contract Reality**: TableFilter's date parsing supports format patterns such as `{dd}.{MM}.{yyyy|yy}` and `{dd}-{months}-{yyyy}` across multiple locales.
|
|
154
|
+
- **Decision**: Keep `sugar-date` intact in the data engine during the hybrid transition to ensure zero date-filtering regressions. Once the Web Component shell and accessibility targets are complete, evaluate migrating date parsing to standard `Intl.DateTimeFormat` in a dedicated sub-phase.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Decision 3: Test Runner Modernization (Playwright + Axe-Core)
|
|
159
|
+
|
|
160
|
+
### 3.1 Context & Current Limitations
|
|
161
|
+
- **Current Setup**: QUnit executed via `grunt-qunit-istanbul` running a local Node `connect` server on port 8000.
|
|
162
|
+
- **Limitations**:
|
|
163
|
+
- Relies on PhantomJS/headless Chrome via Grunt, which is deprecated and fragile on modern systems.
|
|
164
|
+
- No automated accessibility checks (WCAG 2.2 rules must currently be verified manually).
|
|
165
|
+
- Slow serial execution of 74 test files.
|
|
166
|
+
|
|
167
|
+
### 3.2 Proposed Modern Test Architecture (Playwright)
|
|
168
|
+
Rather than rewriting all 74 HTML test files from scratch, Playwright serves as a headless browser runner that executes the existing QUnit test pages directly:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
[Playwright Test Runner]
|
|
172
|
+
|
|
|
173
|
+
+---> Starts Vite test server (http://localhost:8080)
|
|
174
|
+
|
|
|
175
|
+
+---> Discovers all 74 test/*.html suites
|
|
176
|
+
|
|
|
177
|
+
+---> Runs suites in parallel across Chromium / Firefox / WebKit
|
|
178
|
+
| |
|
|
179
|
+
| +--> Monitors window.QUnit.done()
|
|
180
|
+
| +--> Asserts: results.failed === 0
|
|
181
|
+
| +--> Injects @axe-core/playwright
|
|
182
|
+
| +--> Analyzes DOM against WCAG 2.2 AA rules
|
|
183
|
+
|
|
|
184
|
+
+---> Outputs unified TAP / JUnit / HTML test reports
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 3.3 Automated Accessibility Gate (`@axe-core/playwright`)
|
|
188
|
+
- For each test page loaded in Playwright, Axe-Core analyzes the generated DOM:
|
|
189
|
+
```javascript
|
|
190
|
+
const accessibilityScan = await new AxeBuilder({ page })
|
|
191
|
+
.withTags(['wcag2a', 'wcag2aa', 'wcag21aa', 'wcag22aa'])
|
|
192
|
+
.disableRules(['page-has-heading-one']) // Test fixture artifact exclusions
|
|
193
|
+
.analyze();
|
|
194
|
+
|
|
195
|
+
expect(accessibilityScan.violations).toEqual([]);
|
|
196
|
+
```
|
|
197
|
+
- **Benefit**: Every new component and refactored module is automatically audited against accessibility rules on every test run.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 4. Alignment Summary & Next Actions
|
|
202
|
+
|
|
203
|
+
| Decision Area | Alignment Consensus | Primary Benefit |
|
|
204
|
+
| :--- | :--- | :--- |
|
|
205
|
+
| **Build Tooling** | Migrate to **Vite** with multi-format output (ESM, CJS, UMD) and CSS Custom Properties. | Fast dev cycle, modern packaging, Node 24 compatibility, 100% legacy UMD support. |
|
|
206
|
+
| **Dependency Rationalization** | Replace `diacritics` and `format-number` with native APIs; retain `sugar-date`. | Drops ~45 KB bundle weight, zero third-party vulnerability risks. |
|
|
207
|
+
| **Test Runner Modernization** | Use **Playwright** to run existing QUnit HTML suites + **Axe-Core** automated audits. | Zero test rewrite risk, parallel execution, automated WCAG 2.2 verification. |
|
|
208
|
+
|
|
209
|
+
### Immediate Execution Order
|
|
210
|
+
1. **Step 1**: Implement native diacritics removal in [`src/string.js`](../src/string.js) & native number formatter in [`src/extensions/colOps/colOps.js`](../src/extensions/colOps/colOps.js).
|
|
211
|
+
2. **Step 2**: Add `vite.config.js` and modernize `package.json` build scripts.
|
|
212
|
+
3. **Step 3**: Configure Playwright QUnit test runner and verify baseline test passage.
|
|
213
|
+
4. **Step 4**: Implement `<table-filter>` and `<tf-status>` Web Components.
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# TableFilter: Preliminary Workstreams & Milestone 0.8.0 Blueprint
|
|
2
|
+
## Tooling Modernization, Dependency Rationalization, Automated A11y Testing, and Initial Hybrid Components
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Executive Summary
|
|
7
|
+
|
|
8
|
+
To establish a solid, regression-proof foundation before introducing Web Components, three preliminary workstreams must be completed. These workstreams eliminate decade-old build debt, remove unnecessary third-party dependencies in favor of modern standard browser APIs, and establish an automated test and accessibility gate.
|
|
9
|
+
|
|
10
|
+
Once in place, **Milestone 0.8.0** introduces the first hybrid Web Components: the `<table-filter>` shell element and the `<tf-status>` accessible status indicator.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
+-----------------------------------------------------------------------------------------+
|
|
14
|
+
| PRELIMINARY WORKSTREAMS |
|
|
15
|
+
| |
|
|
16
|
+
| 1. Build Tooling (Vite) 2. Dependency Rationalization 3. Testing & A11y |
|
|
17
|
+
| - ESM, CJS, UMD outputs - diacritics -> String.normalize - Playwright QUnit |
|
|
18
|
+
| - CSS Custom Properties - format-number -> Intl.Number - Axe-Core A11y gate |
|
|
19
|
+
+-----------------------------------------------------------------------------------------+
|
|
20
|
+
|
|
|
21
|
+
v
|
|
22
|
+
+-----------------------------------------------------------------------------------------+
|
|
23
|
+
| MILESTONE 0.8.0 |
|
|
24
|
+
| |
|
|
25
|
+
| <table-filter> Shell Element <tf-status> Custom Element |
|
|
26
|
+
| - Wraps existing TableFilter JS - Open Shadow DOM with ::part() |
|
|
27
|
+
| - Slotted light DOM <table> - role="status", aria-live="polite" |
|
|
28
|
+
| - Dispatches DOM CustomEvents - Full backward-compat with StatusBar |
|
|
29
|
+
+-----------------------------------------------------------------------------------------+
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 1. Preliminary Workstream A: Build Tooling Migration (Vite + Modern CSS)
|
|
35
|
+
|
|
36
|
+
### Current Limitations (`v0.7.3`)
|
|
37
|
+
- **Webpack 4 + Grunt**: Relies on deprecated Node 8–10 conventions and fails under modern Node.js versions (`v24.x`).
|
|
38
|
+
- **Stylus Preprocessor**: Pre-compiles CSS into static sheets using raster `.gif`/`.png` assets, preventing dynamic runtime CSS customization.
|
|
39
|
+
|
|
40
|
+
### Target Architecture (Vite)
|
|
41
|
+
- **Zero-Config Dev Server**: Instant hot-module replacement for local development and demos.
|
|
42
|
+
- **Multi-Format Distribution Output**:
|
|
43
|
+
- `dist/tablefilter.esm.js` (Modern ES Module for `import TableFilter from 'tablefilter'`).
|
|
44
|
+
- `dist/tablefilter.cjs.js` (CommonJS module for legacy Node/bundlers).
|
|
45
|
+
- `dist/tablefilter.umd.js` (UMD bundle exposing `window.TableFilter`).
|
|
46
|
+
- `dist/tablefilter/tablefilter.js` (Preserves the exact legacy distribution path).
|
|
47
|
+
|
|
48
|
+
### Vite Configuration Blueprint (`vite.config.js`)
|
|
49
|
+
```javascript
|
|
50
|
+
import { defineConfig } from 'vite';
|
|
51
|
+
import { resolve } from 'path';
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
build: {
|
|
55
|
+
lib: {
|
|
56
|
+
entry: resolve(__dirname, 'src/index.js'),
|
|
57
|
+
name: 'TableFilter',
|
|
58
|
+
formats: ['es', 'cjs', 'umd'],
|
|
59
|
+
fileName: (format) => {
|
|
60
|
+
if (format === 'es') return 'tablefilter.esm.js';
|
|
61
|
+
if (format === 'cjs') return 'tablefilter.cjs.js';
|
|
62
|
+
return 'tablefilter.umd.js';
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
rollupOptions: {
|
|
66
|
+
output: {
|
|
67
|
+
exports: 'named',
|
|
68
|
+
globals: {}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
sourcemap: true,
|
|
72
|
+
minify: 'esbuild'
|
|
73
|
+
},
|
|
74
|
+
server: {
|
|
75
|
+
port: 8080,
|
|
76
|
+
open: '/demos/index.html'
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Modern CSS & Custom Properties Transition
|
|
82
|
+
- Retain existing CSS class names (`.flt`, `.fltsRow`, `.status`, `.pgSlc`, `.div_checklist`) to guarantee that consumer styling does not break.
|
|
83
|
+
- Modernize styles by substituting hardcoded colors with **CSS Custom Properties**:
|
|
84
|
+
```css
|
|
85
|
+
:root, table-filter {
|
|
86
|
+
--tf-primary: #0969da;
|
|
87
|
+
--tf-primary-hover: #085fc4;
|
|
88
|
+
--tf-bg: #ffffff;
|
|
89
|
+
--tf-text: #24292f;
|
|
90
|
+
--tf-border: #d0d7de;
|
|
91
|
+
--tf-focus-ring: #0969da;
|
|
92
|
+
--tf-row-alt: #f6f8fa;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 2. Preliminary Workstream B: Dependency Rationalization
|
|
99
|
+
|
|
100
|
+
### 1. Eliminating `diacritics` (in [`src/string.js`](../src/string.js))
|
|
101
|
+
*Current Code*:
|
|
102
|
+
```javascript
|
|
103
|
+
import {remove as removeDiacritics} from 'diacritics';
|
|
104
|
+
// Used in contains(term, data, ..., ignoreDiacritics = true)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
*Replacement (Native W3C / ECMAScript)*:
|
|
108
|
+
```javascript
|
|
109
|
+
// Native Unicode Canonical Decomposition (NFD) + Combining Diacritical Mark removal
|
|
110
|
+
export const removeDiacritics = (text) => {
|
|
111
|
+
if (!text) return '';
|
|
112
|
+
return String(text)
|
|
113
|
+
.normalize('NFD')
|
|
114
|
+
.replace(/[\u0300-\u036f]/g, '');
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
*Benefits*:
|
|
118
|
+
- 100% native in all modern browsers and Node.js.
|
|
119
|
+
- Drops ~15 KB dependency.
|
|
120
|
+
- Identical output across all European diacritical marks (e.g. `é` → `e`, `ç` → `c`, `ö` → `o`).
|
|
121
|
+
|
|
122
|
+
### 2. Eliminating `format-number` (in [`src/extensions/colOps/colOps.js`](../src/extensions/colOps/colOps.js))
|
|
123
|
+
*Current Code*:
|
|
124
|
+
```javascript
|
|
125
|
+
import formatNumber from 'format-number';
|
|
126
|
+
// formatNumber(format)(result)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
*Replacement (Standard Native `Intl.NumberFormat` / Formatter Utility)*:
|
|
130
|
+
```javascript
|
|
131
|
+
export const formatNumberValue = (value, options = {}) => {
|
|
132
|
+
const num = Number(value);
|
|
133
|
+
if (isNaN(num) || !isFinite(num)) return '';
|
|
134
|
+
|
|
135
|
+
const decimal = options.decimal || '.';
|
|
136
|
+
const thousands = options.integerSeparator || (decimal === ',' ? '.' : ',');
|
|
137
|
+
const prefix = options.prefix || '';
|
|
138
|
+
const suffix = options.suffix || '';
|
|
139
|
+
const precision = options.precision !== undefined ? options.precision : 2;
|
|
140
|
+
|
|
141
|
+
const parts = num.toFixed(precision).split('.');
|
|
142
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousands);
|
|
143
|
+
const formatted = parts.join(decimal);
|
|
144
|
+
|
|
145
|
+
return `${prefix}${formatted}${suffix}`;
|
|
146
|
+
};
|
|
147
|
+
```
|
|
148
|
+
*Benefits*:
|
|
149
|
+
- Drops external `format-number` dependency (~30 KB).
|
|
150
|
+
- Exactly matches ColOps format configuration contract (`decimal`, `integerSeparator`, `prefix`, `suffix`).
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 3. Preliminary Workstream C: Test Runner Modernization & Automated A11y
|
|
155
|
+
|
|
156
|
+
### Preservation of Existing 74 QUnit Test Suites
|
|
157
|
+
The project contains 74 QUnit test files in `test/*.html` with 739 assertions. Rewriting all 74 HTML test fixtures upfront introduces high risk of regression.
|
|
158
|
+
|
|
159
|
+
### Modern Playwright Test Harness
|
|
160
|
+
Playwright can execute the existing QUnit test suites directly against Chromium, Firefox, and WebKit without modifying a single test assertion:
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
// test/runner.spec.js (Playwright QUnit runner)
|
|
164
|
+
import { test, expect } from '@playwright/test';
|
|
165
|
+
import { readdirSync } from 'fs';
|
|
166
|
+
import { resolve } from 'path';
|
|
167
|
+
|
|
168
|
+
const testFiles = readdirSync('test').filter(f => f.endsWith('.html'));
|
|
169
|
+
|
|
170
|
+
for (const file of testFiles) {
|
|
171
|
+
test(`QUnit Suite: ${file}`, async ({ page }) => {
|
|
172
|
+
await page.goto(`http://localhost:8080/test/${file}`);
|
|
173
|
+
|
|
174
|
+
// Wait for QUnit test execution to complete
|
|
175
|
+
await page.waitForSelector('#qunit-testresult .total', { timeout: 10000 });
|
|
176
|
+
|
|
177
|
+
// Assert zero test failures
|
|
178
|
+
const failed = await page.locator('#qunit-testresult .failed').innerText();
|
|
179
|
+
expect(Number(failed)).toBe(0);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Integration of `@axe-core/playwright`
|
|
185
|
+
Every test fixture will automatically run an accessibility audit during test execution:
|
|
186
|
+
```javascript
|
|
187
|
+
import AxeBuilder from '@axe-core/playwright';
|
|
188
|
+
|
|
189
|
+
test(`Accessibility Audit: ${file}`, async ({ page }) => {
|
|
190
|
+
await page.goto(`http://localhost:8080/test/${file}`);
|
|
191
|
+
const results = await new AxeBuilder({ page })
|
|
192
|
+
.withTags(['wcag2a', 'wcag2aa', 'wcag22aa'])
|
|
193
|
+
.analyze();
|
|
194
|
+
|
|
195
|
+
expect(results.violations).toEqual([]);
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
This guarantees that as we modernize components, accessibility regressions are flagged immediately in CI.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 4. Milestone 0.8.0: Initial Hybrid Web Components
|
|
203
|
+
|
|
204
|
+
Once the preliminary tooling is established, Milestone 0.8.0 implements the first two Web Components:
|
|
205
|
+
|
|
206
|
+
### Component 1: `<table-filter>` Shell Component (`src/components/table-filter.js`)
|
|
207
|
+
An autonomous custom element that acts as an outer container for slotted tables:
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
export class TableFilterElement extends HTMLElement {
|
|
211
|
+
connectedCallback() {
|
|
212
|
+
// Find slotted table or child table
|
|
213
|
+
const table = this.querySelector('table') ||
|
|
214
|
+
(this.hasAttribute('for') ? document.getElementById(this.getAttribute('for')) : null);
|
|
215
|
+
|
|
216
|
+
if (!table) return;
|
|
217
|
+
|
|
218
|
+
// Extract declarative attributes into TableFilter options
|
|
219
|
+
const config = this._extractConfig();
|
|
220
|
+
|
|
221
|
+
// Instantiate existing TableFilter JS engine
|
|
222
|
+
this.tf = new TableFilter(table, config);
|
|
223
|
+
this.tf.init();
|
|
224
|
+
|
|
225
|
+
// Bridge internal events to native DOM CustomEvents
|
|
226
|
+
this.tf.emitter.on(['after-filtering'], (tf, args) => {
|
|
227
|
+
this.dispatchEvent(new CustomEvent('tf-filter', { detail: { tf, args }, bubbles: true }));
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
disconnectedCallback() {
|
|
232
|
+
if (this.tf) {
|
|
233
|
+
this.tf.destroy();
|
|
234
|
+
this.tf = null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Expose public API methods directly on the DOM element
|
|
239
|
+
filter() { return this.tf.filter(); }
|
|
240
|
+
clearFilters() { return this.tf.clearFilters(); }
|
|
241
|
+
getFilteredData() { return this.tf.getFilteredData(); }
|
|
242
|
+
}
|
|
243
|
+
customElements.define('table-filter', TableFilterElement);
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Component 2: `<tf-status>` Component (`src/components/tf-status.js`)
|
|
247
|
+
An accessible status message component encapsulating Open Shadow DOM with CSS parts:
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
const template = document.createElement('template');
|
|
251
|
+
template.innerHTML = `
|
|
252
|
+
<style>
|
|
253
|
+
:host { display: inline-block; }
|
|
254
|
+
.status-text { margin-right: 0.25rem; font-weight: normal; }
|
|
255
|
+
.status-msg { font-weight: 600; color: var(--tf-status-color, inherit); }
|
|
256
|
+
</style>
|
|
257
|
+
<span class="status-text" part="label"></span>
|
|
258
|
+
<span class="status-msg" part="message"></span>
|
|
259
|
+
`;
|
|
260
|
+
|
|
261
|
+
export class TfStatusElement extends HTMLElement {
|
|
262
|
+
constructor() {
|
|
263
|
+
super();
|
|
264
|
+
this.attachShadow({ mode: 'open' });
|
|
265
|
+
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
266
|
+
this._labelEl = this.shadowRoot.querySelector('.status-text');
|
|
267
|
+
this._msgEl = this.shadowRoot.querySelector('.status-msg');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
connectedCallback() {
|
|
271
|
+
this.setAttribute('role', 'status');
|
|
272
|
+
this.setAttribute('aria-live', 'polite');
|
|
273
|
+
this.setAttribute('aria-atomic', 'true');
|
|
274
|
+
this._update();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
static get observedAttributes() { return ['text', 'message']; }
|
|
278
|
+
attributeChangedCallback() { this._update(); }
|
|
279
|
+
|
|
280
|
+
setMessage(msg) {
|
|
281
|
+
this.setAttribute('message', msg || '');
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
_update() {
|
|
285
|
+
if (this._labelEl) this._labelEl.textContent = this.getAttribute('text') || '';
|
|
286
|
+
if (this._msgEl) this._msgEl.textContent = this.getAttribute('message') || '';
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
customElements.define('tf-status', TfStatusElement);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Updating [`StatusBar`](../src/modules/statusBar.js#L26-L35) Feature Class
|
|
293
|
+
- Update `src/modules/statusBar.js` to create `<tf-status>` instead of raw `<div>` and `<span>` elements.
|
|
294
|
+
- The feature class retains all public properties and methods (`statusBar.message(...)`), fulfilling 100% of the existing contract.
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## 5. Execution Step Checklist
|
|
299
|
+
|
|
300
|
+
| Step # | Task Description | Verification Gate |
|
|
301
|
+
| :---: | :--- | :--- |
|
|
302
|
+
| **1.1** | Replace `diacritics` import with native `String.prototype.normalize('NFD')` in `src/string.js`. | Existing string and filtering tests pass. |
|
|
303
|
+
| **1.2** | Replace `format-number` in `src/extensions/colOps/colOps.js` with native formatter. | Existing `test-col-ops.js` tests pass. |
|
|
304
|
+
| **1.3** | Create `vite.config.js` with ESM, CJS, and UMD library builds. | Vite builds bundle without errors; outputs verified. |
|
|
305
|
+
| **1.4** | Setup Playwright QUnit test runner. | All 74 existing QUnit test files execute and pass. |
|
|
306
|
+
| **1.5** | Implement `<table-filter>` Custom Element in `src/components/table-filter.js`. | Declarative `<table-filter>` demo page mounts and filters. |
|
|
307
|
+
| **1.6** | Implement `<tf-status>` Custom Element and connect to `src/modules/statusBar.js`. | `test-status-bar.js` passes with zero regressions; screen reader live region verified. |
|
|
308
|
+
| **1.7** | Integrate `@axe-core/playwright` accessibility check for status bar. | Zero accessibility violations reported. |
|