tablefilter 0.7.5 → 0.7.7
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/dist/starter.html +2 -2
- package/dist/tablefilter/tablefilter.js +1 -1
- package/dist/tablefilter/tf-1-2aa33b10e0e549020c12.js +1 -0
- package/dist/tablefilter/tf-1-7e29d0dbe6e0e0a4ff05.js +1 -0
- package/dist/tablefilter/{tf-2-3a936d22b849361acff5.js → tf-2-0ea691278d572212426a.js} +2 -2
- package/dist/tablefilter.cjs.js +17787 -4
- package/dist/tablefilter.esm.js +15910 -5398
- package/dist/tablefilter.umd.js +17793 -4
- package/index.js +16 -1
- package/package.json +10 -1
- package/src/components/attributes.js +59 -0
- package/src/components/table-filter.js +193 -45
- package/src/components/tf-pager.js +325 -0
- package/src/components/tf-results-per-page.js +181 -0
- package/src/components/tf-rows-counter.js +3 -6
- package/src/components/tf-status.js +6 -11
- package/src/extensions/sort/sort.js +8 -1
- package/src/modules/paging.js +270 -46
- package/src/tablefilter.js +39 -6
- package/.editorconfig +0 -15
- package/.esdoc.json +0 -14
- package/.eslintrc +0 -37
- package/.gitattributes +0 -16
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -36
- package/.github/ISSUE_TEMPLATE/support.md +0 -17
- package/.github/dependabot.yml +0 -10
- package/.github/workflows/build-deploy.yml +0 -141
- package/.github/workflows/opencode-review.yml +0 -104
- package/.github/workflows/opencode.yml +0 -34
- package/AGENTS.md +0 -36
- package/CONTRIBUTING.md +0 -128
- package/Gruntfile.js +0 -252
- package/PULL_REQUEST_TEMPLATE.md +0 -24
- package/ROADMAP/README.md +0 -34
- package/ROADMAP/content-projection-parity.md +0 -162
- package/ROADMAP/hybrid-migration-strategy.md +0 -275
- package/ROADMAP/key-decisions-review.md +0 -215
- package/ROADMAP/preliminary-and-milestone-0.8.0-plan.md +0 -307
- package/ROADMAP/v1-webcomponents-investigation.md +0 -521
- package/dist/tablefilter/tablefilter.vite.js +0 -4
- package/dist/tablefilter/tf-1-a5c3a73bd559e47dd5a2.js +0 -1
- package/playwright.config.js +0 -25
- package/scripts/check-css-tokens.js +0 -65
- package/static/demos-assets/img_best-price.png +0 -0
- package/static/demos-assets/img_great-deal.png +0 -0
- package/static/demos-assets/img_maintenance.jpg +0 -0
- package/static/demos-assets/img_new-edition.png +0 -0
- package/static/demos-assets/img_sold-out.png +0 -0
- package/static/partials/books-table-with-images.html +0 -328
- package/static/partials/books.html +0 -273
- package/static/partials/countries-by-continent.html +0 -2592
- package/static/partials/countries-table-tiny.html +0 -436
- package/static/partials/countries-table.html +0 -12954
- package/static/partials/dummy-table-with-totals-footer.html +0 -353
- package/static/partials/dummy-table.html +0 -503
- package/static/partials/pre-inline-script.html +0 -17
- package/static/partials/pre.html +0 -1
- package/static/partials/style.html +0 -23
- package/static/partials/table-with-grouped-headers.html +0 -9258
- package/static/partials/tablefilter-script.html +0 -1
- package/static/style/active-header.styl +0 -10
- package/static/style/alternating-rows.styl +0 -8
- package/static/style/config.styl +0 -44
- package/static/style/custom-properties.styl +0 -43
- package/static/style/extensions/colsVisibility.styl +0 -71
- package/static/style/extensions/filtersVisibility.styl +0 -18
- package/static/style/ezedittable.styl +0 -93
- package/static/style/filter-checklist.styl +0 -52
- package/static/style/filters.styl +0 -111
- package/static/style/grid-layout.styl +0 -130
- package/static/style/help.styl +0 -57
- package/static/style/keyword.styl +0 -8
- package/static/style/loader.styl +0 -16
- package/static/style/mixins/arrow.styl +0 -63
- package/static/style/mixins/box-shadow.styl +0 -8
- package/static/style/mixins/empty-content.styl +0 -7
- package/static/style/noresults.styl +0 -14
- package/static/style/paging.styl +0 -73
- package/static/style/reset-button.styl +0 -21
- package/static/style/rows-counter.styl +0 -17
- package/static/style/sort.styl +0 -20
- package/static/style/status-bar.styl +0 -13
- package/static/style/table.styl +0 -44
- package/static/style/tablefilter.styl +0 -19
- package/static/style/themes/blank.png +0 -0
- package/static/style/themes/btn_clear_filters.png +0 -0
- package/static/style/themes/btn_filter.png +0 -0
- package/static/style/themes/btn_first_page.gif +0 -0
- package/static/style/themes/btn_last_page.gif +0 -0
- package/static/style/themes/btn_next_page.gif +0 -0
- package/static/style/themes/btn_previous_page.gif +0 -0
- package/static/style/themes/default/default.styl +0 -137
- package/static/style/themes/default/images/bg_infDiv.jpg +0 -0
- package/static/style/themes/default/images/bg_th.jpg +0 -0
- package/static/style/themes/default/images/btn_eraser.gif +0 -0
- package/static/style/themes/default/images/btn_first_page.gif +0 -0
- package/static/style/themes/default/images/btn_last_page.gif +0 -0
- package/static/style/themes/default/images/btn_next_page.gif +0 -0
- package/static/style/themes/default/images/btn_over_eraser.gif +0 -0
- package/static/style/themes/default/images/btn_over_first_page.gif +0 -0
- package/static/style/themes/default/images/btn_over_last_page.gif +0 -0
- package/static/style/themes/default/images/btn_over_next_page.gif +0 -0
- package/static/style/themes/default/images/btn_over_previous_page.gif +0 -0
- package/static/style/themes/default/images/btn_previous_page.gif +0 -0
- package/static/style/themes/default/images/img_loading.gif +0 -0
- package/static/style/themes/downsimple.png +0 -0
- package/static/style/themes/icn_clp.png +0 -0
- package/static/style/themes/icn_exp.png +0 -0
- package/static/style/themes/icn_filter.gif +0 -0
- package/static/style/themes/icn_filterActive.gif +0 -0
- package/static/style/themes/mytheme/images/bg_headers.jpg +0 -0
- package/static/style/themes/mytheme/images/bg_infDiv.jpg +0 -0
- package/static/style/themes/mytheme/images/btn_filter.png +0 -0
- package/static/style/themes/mytheme/images/btn_first_page.gif +0 -0
- package/static/style/themes/mytheme/images/btn_last_page.gif +0 -0
- package/static/style/themes/mytheme/images/btn_next_page.gif +0 -0
- package/static/style/themes/mytheme/images/btn_previous_page.gif +0 -0
- package/static/style/themes/mytheme/images/img_loading.gif +0 -0
- package/static/style/themes/mytheme/mytheme.styl +0 -152
- package/static/style/themes/skyblue/images/bg_skyblue.gif +0 -0
- package/static/style/themes/skyblue/images/btn_first_page.gif +0 -0
- package/static/style/themes/skyblue/images/btn_last_page.gif +0 -0
- package/static/style/themes/skyblue/images/btn_next_page.gif +0 -0
- package/static/style/themes/skyblue/images/btn_prev_page.gif +0 -0
- package/static/style/themes/skyblue/images/icn_clear_filters.png +0 -0
- package/static/style/themes/skyblue/images/img_loading.gif +0 -0
- package/static/style/themes/skyblue/skyblue.styl +0 -195
- package/static/style/themes/transparent/images/btn_first_page.gif +0 -0
- package/static/style/themes/transparent/images/btn_last_page.gif +0 -0
- package/static/style/themes/transparent/images/btn_next_page.gif +0 -0
- package/static/style/themes/transparent/images/btn_prev_page.gif +0 -0
- package/static/style/themes/transparent/images/icn_clear_filters.png +0 -0
- package/static/style/themes/transparent/images/img_loading.gif +0 -0
- package/static/style/themes/transparent/transparent.styl +0 -205
- package/static/style/themes/upsimple.png +0 -0
- package/static/style/toolbar.styl +0 -58
- package/static/templates/advanced-grid-editable.html +0 -140
- package/static/templates/advanced-grid-selection.html +0 -93
- package/static/templates/auto-filter.html +0 -46
- package/static/templates/columns-visibility.html +0 -67
- package/static/templates/data-types.html +0 -123
- package/static/templates/demo.html +0 -62
- package/static/templates/external-filters-visibility-commad.html +0 -49
- package/static/templates/external-filters.html +0 -125
- package/static/templates/filter-images.html +0 -91
- package/static/templates/filters-visibility.html +0 -45
- package/static/templates/grid-layout.html +0 -51
- package/static/templates/grouped-headers.html +0 -78
- package/static/templates/linked-filters-disabled.html +0 -56
- package/static/templates/linked-filters.html +0 -45
- package/static/templates/load-filters-on-demand.html +0 -42
- package/static/templates/pagination.html +0 -78
- package/static/templates/requirejs.html +0 -53
- package/static/templates/starter.html +0 -61
- package/static/templates/table-filter.html +0 -40
- package/static/templates/theme-roller.html +0 -106
- package/test/libs/polyfill.js +0 -359
- package/test/libs/qunit/qunit.css +0 -237
- package/test/libs/qunit/qunit.js +0 -2495
- package/test/playwright/axe.baseline.spec.js +0 -34
- package/test/playwright/axe.statusbar.spec.js +0 -35
- package/test/playwright/axeScan.js +0 -42
- package/test/playwright/ce-bridge.spec.js +0 -167
- package/test/playwright/qunit.all.spec.js +0 -10
- package/test/playwright/qunit.single.spec.js +0 -14
- package/test/playwright/qunitSuite.js +0 -56
- package/test/playwright/table-filter.config.spec.js +0 -265
- package/test/playwright/table-filter.demo.spec.js +0 -60
- package/test/playwright/table-filter.element.spec.js +0 -477
- package/test/playwright/tf-clear-button.spec.js +0 -135
- package/test/playwright/tf-rows-counter.spec.js +0 -172
- package/test/playwright/tf-status.spec.js +0 -258
- package/test/test-active-columns.html +0 -80
- package/test/test-active-columns.js +0 -318
- package/test/test-alternate-rows.html +0 -80
- package/test/test-alternate-rows.js +0 -335
- package/test/test-api.html +0 -141
- package/test/test-api.js +0 -795
- package/test/test-auto-filter.html +0 -80
- package/test/test-auto-filter.js +0 -43
- package/test/test-callbacks.html +0 -78
- package/test/test-callbacks.js +0 -58
- package/test/test-case-sensitive-query.html +0 -78
- package/test/test-case-sensitive-query.js +0 -39
- package/test/test-cell-parser.html +0 -109
- package/test/test-cell-parser.js +0 -80
- package/test/test-checklist.html +0 -78
- package/test/test-checklist.js +0 -267
- package/test/test-clear-button.html +0 -79
- package/test/test-clear-button.js +0 -183
- package/test/test-col-ops-grid-layout.html +0 -129
- package/test/test-col-ops-grid-layout.js +0 -134
- package/test/test-col-ops-paging.html +0 -129
- package/test/test-col-ops-paging.js +0 -154
- package/test/test-col-ops.html +0 -129
- package/test/test-col-ops.js +0 -337
- package/test/test-col-widths.html +0 -80
- package/test/test-col-widths.js +0 -40
- package/test/test-cols-visibility-grid-layout.html +0 -80
- package/test/test-cols-visibility-grid-layout.js +0 -165
- package/test/test-cols-visibility.html +0 -80
- package/test/test-cols-visibility.js +0 -121
- package/test/test-custom-options.html +0 -80
- package/test/test-custom-options.js +0 -139
- package/test/test-data-types.html +0 -377
- package/test/test-data-types.js +0 -392
- package/test/test-date-type.html +0 -356
- package/test/test-date-type.js +0 -159
- package/test/test-disable-enter-key.html +0 -78
- package/test/test-disable-enter-key.js +0 -29
- package/test/test-disable-filter-onchange.html +0 -78
- package/test/test-disable-filter-onchange.js +0 -40
- package/test/test-dom-changes.html +0 -78
- package/test/test-dom-changes.js +0 -166
- package/test/test-dropdown.html +0 -78
- package/test/test-dropdown.js +0 -246
- package/test/test-emitter.html +0 -78
- package/test/test-emitter.js +0 -57
- package/test/test-empty-cells-filtering.html +0 -8696
- package/test/test-empty-cells-filtering.js +0 -45
- package/test/test-exact-query-match.html +0 -78
- package/test/test-exact-query-match.js +0 -56
- package/test/test-excluded-rows.html +0 -92
- package/test/test-excluded-rows.js +0 -129
- package/test/test-external-filters.html +0 -100
- package/test/test-external-filters.js +0 -219
- package/test/test-filter-html-elements.html +0 -88
- package/test/test-filter-html-elements.js +0 -63
- package/test/test-filter-operators.html +0 -80
- package/test/test-filter-operators.js +0 -264
- package/test/test-filtering.html +0 -53
- package/test/test-filtering.js +0 -293
- package/test/test-filters-visibility-grid-layout.html +0 -80
- package/test/test-filters-visibility-grid-layout.js +0 -50
- package/test/test-filters-visibility-with-button.html +0 -80
- package/test/test-filters-visibility-with-button.js +0 -48
- package/test/test-filters-visibility.html +0 -80
- package/test/test-filters-visibility.js +0 -48
- package/test/test-grid-layout.html +0 -7736
- package/test/test-grid-layout.js +0 -39
- package/test/test-grouped-headers.html +0 -154
- package/test/test-grouped-headers.js +0 -107
- package/test/test-hash.html +0 -78
- package/test/test-hash.js +0 -88
- package/test/test-help-responsive.html +0 -79
- package/test/test-help-responsive.js +0 -70
- package/test/test-help.html +0 -78
- package/test/test-help.js +0 -217
- package/test/test-highlight-keywords.html +0 -78
- package/test/test-highlight-keywords.js +0 -94
- package/test/test-ignore-diacritics.html +0 -67
- package/test/test-ignore-diacritics.js +0 -117
- package/test/test-integration-paging-sort.html +0 -80
- package/test/test-integration-paging-sort.js +0 -60
- package/test/test-linked-filters-disabled-options-grid-layout.html +0 -80
- package/test/test-linked-filters-disabled-options-grid-layout.js +0 -73
- package/test/test-linked-filters-grid-layout.html +0 -80
- package/test/test-linked-filters-grid-layout.js +0 -72
- package/test/test-linked-filters-load-filters-on-demand.html +0 -80
- package/test/test-linked-filters-load-filters-on-demand.js +0 -99
- package/test/test-linked-filters-paging.html +0 -80
- package/test/test-linked-filters-paging.js +0 -99
- package/test/test-linked-filters.html +0 -80
- package/test/test-linked-filters.js +0 -138
- package/test/test-load-filters-on-demand.html +0 -78
- package/test/test-load-filters-on-demand.js +0 -124
- package/test/test-loader.html +0 -79
- package/test/test-loader.js +0 -159
- package/test/test-no-config.html +0 -80
- package/test/test-no-config.js +0 -63
- package/test/test-no-filters.html +0 -80
- package/test/test-no-filters.js +0 -172
- package/test/test-no-headers.html +0 -71
- package/test/test-no-headers.js +0 -99
- package/test/test-no-results-message.html +0 -262
- package/test/test-no-results-message.js +0 -222
- package/test/test-no-rows.html +0 -19
- package/test/test-no-rows.js +0 -10
- package/test/test-one-row.html +0 -29
- package/test/test-one-row.js +0 -18
- package/test/test-paging.html +0 -78
- package/test/test-paging.js +0 -273
- package/test/test-popup-filter-one-row.html +0 -38
- package/test/test-popup-filter-one-row.js +0 -138
- package/test/test-popup-filter.html +0 -78
- package/test/test-popup-filter.js +0 -384
- package/test/test-popup-filters-grouped-headers.html +0 -104
- package/test/test-popup-filters-grouped-headers.js +0 -206
- package/test/test-rows-counter.html +0 -78
- package/test/test-rows-counter.js +0 -114
- package/test/test-single-filter.html +0 -79
- package/test/test-single-filter.js +0 -138
- package/test/test-sort-custom-sorter.html +0 -244
- package/test/test-sort-custom-sorter.js +0 -74
- package/test/test-sort-grid-layout.html +0 -143
- package/test/test-sort-grid-layout.js +0 -86
- package/test/test-sort-key.html +0 -244
- package/test/test-sort-key.js +0 -67
- package/test/test-sort.html +0 -143
- package/test/test-sort.js +0 -126
- package/test/test-state.html +0 -78
- package/test/test-state.js +0 -369
- package/test/test-status-bar.html +0 -79
- package/test/test-status-bar.js +0 -149
- package/test/test-storage-cookie.html +0 -78
- package/test/test-storage-cookie.js +0 -82
- package/test/test-storage-local.html +0 -78
- package/test/test-storage-local.js +0 -82
- package/test/test-tfoot.html +0 -96
- package/test/test-tfoot.js +0 -123
- package/test/test-thead.html +0 -80
- package/test/test-thead.js +0 -69
- package/test/test-toolbar.html +0 -81
- package/test/test-toolbar.js +0 -218
- package/test/test-uneven-rows.html +0 -95
- package/test/test-uneven-rows.js +0 -61
- package/test/test-watermark.html +0 -80
- package/test/test-watermark.js +0 -103
- package/test/test.html +0 -141
- package/test/test.js +0 -162
- package/vite.config.js +0 -71
- package/webpack.config.js +0 -99
- package/webpack.dev.config.js +0 -25
- package/webpack.test.config.js +0 -44
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<tf-pager>` custom element: accessible pagination controls.
|
|
3
|
+
*
|
|
4
|
+
* An open shadow root exposing a `nav` landmark (`part="nav"`) with four
|
|
5
|
+
* semantic `<button type="button">` elements in first/prev/next/last
|
|
6
|
+
* order — each via its own `part`, a named slot and a text hook — plus a
|
|
7
|
+
* page indicator (`part="page-status"`) carrying `aria-current="page"`.
|
|
8
|
+
*
|
|
9
|
+
* Attributes:
|
|
10
|
+
* - `label` — `aria-label` on the landmark.
|
|
11
|
+
* - `first-label`, `prev-label`, `next-label`, `last-label` — `aria-label`
|
|
12
|
+
* on each button.
|
|
13
|
+
* - `first-text`, `prev-text`, `next-text`, `last-text` — button text.
|
|
14
|
+
* - `page` — current page number, 1-based.
|
|
15
|
+
* - `total-pages` — page count, rendered as supplied. The host resolves
|
|
16
|
+
* it from the legacy Paging feature.
|
|
17
|
+
* - `page-text`, `of-text` — text rendered either side of the selector.
|
|
18
|
+
* - `selector-type` — `select` (default) or `input`.
|
|
19
|
+
* - `selector-label` — `aria-label` on the page selector; defaults to
|
|
20
|
+
* `Current page`, and an empty value opts out of the name.
|
|
21
|
+
* - `disabled` — disables all four buttons.
|
|
22
|
+
* - `buttons` — `false` hides the four buttons, any other value renders
|
|
23
|
+
* them.
|
|
24
|
+
* No accessible name is rendered unless its attribute is set.
|
|
25
|
+
*
|
|
26
|
+
* Events:
|
|
27
|
+
* - `page-change` — dispatched when the user picks a page, with
|
|
28
|
+
* `detail: {page}`, the page number as a string. Bubbles and crosses
|
|
29
|
+
* the shadow boundary.
|
|
30
|
+
*
|
|
31
|
+
* The select is populated through `setPages()`, which takes `{text,
|
|
32
|
+
* value}` entries from the host — the legacy option model: page number
|
|
33
|
+
* as text, start row as value.
|
|
34
|
+
*
|
|
35
|
+
* Content is projected through the slots (`slot="first"`, `slot="prev"`,
|
|
36
|
+
* `slot="next"`, `slot="last"`). Styling is left to the theme via `--tf-*`
|
|
37
|
+
* custom properties and `::part()`; no CSS class or presentational style
|
|
38
|
+
* is shipped.
|
|
39
|
+
*
|
|
40
|
+
* Importing this module registers the element. It is not part of the
|
|
41
|
+
* legacy webpack bundle; consumers load it as a module.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
const BUTTONS = [
|
|
45
|
+
{ part: 'first' },
|
|
46
|
+
{ part: 'prev' },
|
|
47
|
+
{ part: 'next' },
|
|
48
|
+
{ part: 'last' }
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const DEFAULT_SELECTOR_LABEL = 'Current page';
|
|
52
|
+
|
|
53
|
+
// Cloned into every instance's shadow root. Structure and `part` hooks
|
|
54
|
+
// only; no class or presentational style is baked in. The indicator sits
|
|
55
|
+
// between the prev and next buttons, mirroring the legacy markup order
|
|
56
|
+
// (src/modules/paging.js: first, prev, page text, selector, of text,
|
|
57
|
+
// total, next, last).
|
|
58
|
+
const TEMPLATE = document.createElement('template');
|
|
59
|
+
TEMPLATE.innerHTML = `
|
|
60
|
+
<nav part="nav">
|
|
61
|
+
<button type="button" part="first">
|
|
62
|
+
<slot name="first"></slot><span part="first-text"></span>
|
|
63
|
+
</button>
|
|
64
|
+
<button type="button" part="prev">
|
|
65
|
+
<slot name="prev"></slot><span part="prev-text"></span>
|
|
66
|
+
</button>
|
|
67
|
+
<span part="page-status" aria-current="page">
|
|
68
|
+
<span part="page-text"></span>
|
|
69
|
+
<span part="page-selector"></span>
|
|
70
|
+
<span part="of-text"></span>
|
|
71
|
+
<span part="total-pages"></span>
|
|
72
|
+
</span>
|
|
73
|
+
<button type="button" part="next">
|
|
74
|
+
<slot name="next"></slot><span part="next-text"></span>
|
|
75
|
+
</button>
|
|
76
|
+
<button type="button" part="last">
|
|
77
|
+
<slot name="last"></slot><span part="last-text"></span>
|
|
78
|
+
</button>
|
|
79
|
+
</nav>
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
export class TfPagerElement extends HTMLElement {
|
|
83
|
+
constructor() {
|
|
84
|
+
super();
|
|
85
|
+
this.attachShadow({ mode: 'open' });
|
|
86
|
+
this.shadowRoot.appendChild(TEMPLATE.content.cloneNode(true));
|
|
87
|
+
this._nav = this.shadowRoot.querySelector('nav');
|
|
88
|
+
this._buttons = BUTTONS.map(
|
|
89
|
+
(btn) => this.shadowRoot.querySelector(`[part="${btn.part}"]`));
|
|
90
|
+
this._texts = BUTTONS.map(
|
|
91
|
+
(btn) =>
|
|
92
|
+
this.shadowRoot.querySelector(`[part="${btn.part}-text"]`));
|
|
93
|
+
this._pageText = this.shadowRoot.querySelector('[part="page-text"]');
|
|
94
|
+
this._pageSelector =
|
|
95
|
+
this.shadowRoot.querySelector('[part="page-selector"]');
|
|
96
|
+
this._ofText = this.shadowRoot.querySelector('[part="of-text"]');
|
|
97
|
+
this._totalPagesEl =
|
|
98
|
+
this.shadowRoot.querySelector('[part="total-pages"]');
|
|
99
|
+
// Page entries supplied through setPages().
|
|
100
|
+
this._pages = [];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static get observedAttributes() {
|
|
104
|
+
return ['label', 'disabled', 'buttons', 'page', 'total-pages',
|
|
105
|
+
'page-text', 'of-text', 'selector-type', 'selector-label']
|
|
106
|
+
.concat(BUTTONS.map((btn) => `${btn.part}-label`))
|
|
107
|
+
.concat(BUTTONS.map((btn) => `${btn.part}-text`));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
connectedCallback() {
|
|
111
|
+
this._update();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
attributeChangedCallback() {
|
|
115
|
+
this._update();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Set the landmark's accessible name, rendered as `aria-label` on
|
|
120
|
+
* the `nav` part.
|
|
121
|
+
* @param {*} label Accessible name
|
|
122
|
+
*/
|
|
123
|
+
setLabel(label) {
|
|
124
|
+
this.setAttribute('label', label == null ? '' : String(label));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Set the current page number.
|
|
129
|
+
* @param {*} page Page number, 1-based
|
|
130
|
+
*/
|
|
131
|
+
setPage(page) {
|
|
132
|
+
this.setAttribute('page', page == null ? '' : String(page));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Set the page count, resolved by the host from the legacy Paging
|
|
137
|
+
* feature.
|
|
138
|
+
* @param {*} totalPages Page count
|
|
139
|
+
*/
|
|
140
|
+
setTotalPages(totalPages) {
|
|
141
|
+
this.setAttribute('total-pages',
|
|
142
|
+
totalPages == null ? '' : String(totalPages));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Render the landmark, button attributes and page indicator into the
|
|
147
|
+
* shadow parts.
|
|
148
|
+
*/
|
|
149
|
+
_update() {
|
|
150
|
+
if (!this._nav) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this._setAriaLabel(this._nav, 'label');
|
|
155
|
+
|
|
156
|
+
const showButtons = this.getAttribute('buttons') !== 'false';
|
|
157
|
+
|
|
158
|
+
BUTTONS.forEach((btn, idx) => {
|
|
159
|
+
this._setAriaLabel(this._buttons[idx], `${btn.part}-label`);
|
|
160
|
+
this._texts[idx].textContent =
|
|
161
|
+
this.getAttribute(`${btn.part}-text`) || '';
|
|
162
|
+
|
|
163
|
+
if (this.hasAttribute('disabled')) {
|
|
164
|
+
this._buttons[idx].setAttribute('disabled', '');
|
|
165
|
+
} else {
|
|
166
|
+
this._buttons[idx].removeAttribute('disabled');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (showButtons) {
|
|
170
|
+
this._buttons[idx].removeAttribute('hidden');
|
|
171
|
+
} else {
|
|
172
|
+
this._buttons[idx].setAttribute('hidden', '');
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
this._pageText.textContent = this.getAttribute('page-text') || '';
|
|
177
|
+
this._ofText.textContent = this.getAttribute('of-text') || '';
|
|
178
|
+
this._totalPagesEl.textContent = this._totalPages();
|
|
179
|
+
|
|
180
|
+
this._updateSelector(this._syncSelector());
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The `total-pages` value supplied by the host, or empty when it has
|
|
185
|
+
* not been set.
|
|
186
|
+
* @return {String} Total pages, or an empty string
|
|
187
|
+
*/
|
|
188
|
+
_totalPages() {
|
|
189
|
+
return this.getAttribute('total-pages') || '';
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Supply the page list rendered into the select. Each entry is
|
|
194
|
+
* `{text, value}` — the legacy option model, page number as visible
|
|
195
|
+
* text and start row as value.
|
|
196
|
+
* @param {Array<Object>} pages Page entries
|
|
197
|
+
*/
|
|
198
|
+
setPages(pages) {
|
|
199
|
+
this._pages = Array.isArray(pages) ? pages : [];
|
|
200
|
+
this._update();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Ensure the page selector matches `selector-type`, creating it on
|
|
205
|
+
* first use and replacing it when the type changes. Exactly one
|
|
206
|
+
* control exists at a time, so no presentational attribute is needed
|
|
207
|
+
* to hide the other.
|
|
208
|
+
* @return {Element} The page selector control
|
|
209
|
+
*/
|
|
210
|
+
_syncSelector() {
|
|
211
|
+
const isInput = this.getAttribute('selector-type') === 'input';
|
|
212
|
+
const part = isInput ? 'page-input' : 'page-select';
|
|
213
|
+
const current = this._pageSelector.firstElementChild;
|
|
214
|
+
|
|
215
|
+
if (current && current.getAttribute('part') === part) {
|
|
216
|
+
return current;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
this._pageSelector.textContent = '';
|
|
220
|
+
const el = document.createElement(isInput ? 'input' : 'select');
|
|
221
|
+
el.setAttribute('part', part);
|
|
222
|
+
if (isInput) {
|
|
223
|
+
el.setAttribute('type', 'number');
|
|
224
|
+
el.setAttribute('min', '1');
|
|
225
|
+
el.addEventListener('keydown', (event) => {
|
|
226
|
+
if (event.key === 'Enter' && el.value !== '') {
|
|
227
|
+
this._dispatchPageChange(el.value);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
} else {
|
|
231
|
+
el.addEventListener('change', () => {
|
|
232
|
+
const option = el.options[el.selectedIndex];
|
|
233
|
+
if (option) {
|
|
234
|
+
this._dispatchPageChange(option.textContent);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
this._pageSelector.appendChild(el);
|
|
239
|
+
return el;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Dispatch `page-change` with the page number a user action resolved
|
|
244
|
+
* to.
|
|
245
|
+
* @param {String} page Page number
|
|
246
|
+
*/
|
|
247
|
+
_dispatchPageChange(page) {
|
|
248
|
+
this.dispatchEvent(new CustomEvent('page-change', {
|
|
249
|
+
detail: { page: String(page) },
|
|
250
|
+
bubbles: true,
|
|
251
|
+
composed: true
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Render the host-supplied page entries, page count and accessible
|
|
257
|
+
* name into the selector control; the input variant holds the page
|
|
258
|
+
* number itself.
|
|
259
|
+
* @param {Element} el The selector control
|
|
260
|
+
*/
|
|
261
|
+
_updateSelector(el) {
|
|
262
|
+
this._setSelectorLabel(el);
|
|
263
|
+
|
|
264
|
+
const page = this.getAttribute('page') || '';
|
|
265
|
+
const total = this._totalPages();
|
|
266
|
+
const isInput = el.getAttribute('part') === 'page-input';
|
|
267
|
+
|
|
268
|
+
if (isInput) {
|
|
269
|
+
el.value = page;
|
|
270
|
+
if (total !== '') {
|
|
271
|
+
el.setAttribute('max', total);
|
|
272
|
+
} else {
|
|
273
|
+
el.removeAttribute('max');
|
|
274
|
+
}
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
el.textContent = '';
|
|
279
|
+
this._pages.forEach((entry) => {
|
|
280
|
+
const option = document.createElement('option');
|
|
281
|
+
option.value = String(entry.value);
|
|
282
|
+
option.textContent = String(entry.text);
|
|
283
|
+
if (String(entry.text) === page) {
|
|
284
|
+
option.setAttribute('selected', 'true');
|
|
285
|
+
}
|
|
286
|
+
el.appendChild(option);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Name the page selector. Absent `selector-label` renders the
|
|
292
|
+
* ROADMAP default, a non-empty value overrides it, and an explicit
|
|
293
|
+
* empty value removes the name so it can be opted out of.
|
|
294
|
+
* @param {Element} el The selector control
|
|
295
|
+
*/
|
|
296
|
+
_setSelectorLabel(el) {
|
|
297
|
+
if (!this.hasAttribute('selector-label')) {
|
|
298
|
+
el.setAttribute('aria-label', DEFAULT_SELECTOR_LABEL);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
this._setAriaLabel(el, 'selector-label');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Render an attribute as `aria-label` on a shadow element, or remove
|
|
306
|
+
* it when the attribute is absent.
|
|
307
|
+
* @param {Element} el Shadow element to name
|
|
308
|
+
* @param {String} attr Attribute holding the accessible name
|
|
309
|
+
*/
|
|
310
|
+
_setAriaLabel(el, attr) {
|
|
311
|
+
const label = this.getAttribute(attr);
|
|
312
|
+
if (label) {
|
|
313
|
+
el.setAttribute('aria-label', label);
|
|
314
|
+
} else {
|
|
315
|
+
el.removeAttribute('aria-label');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Register once: loading this module twice (or on a page that already
|
|
321
|
+
// defined the element) must not throw.
|
|
322
|
+
if (typeof customElements !== 'undefined' &&
|
|
323
|
+
!customElements.get('tf-pager')) {
|
|
324
|
+
customElements.define('tf-pager', TfPagerElement);
|
|
325
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<tf-results-per-page>` custom element: the labelled select that picks
|
|
3
|
+
* how many rows a page holds.
|
|
4
|
+
*
|
|
5
|
+
* An open shadow root exposing a `<label>` (`part="results-label"`)
|
|
6
|
+
* wrapping the label text (`part="results-text"`) and a native `<select>`
|
|
7
|
+
* (`part="results-select"`). The select is the label's control: the
|
|
8
|
+
* rendered text is its accessible name, and activating the text focuses
|
|
9
|
+
* the select. Legacy keeps the text in a sibling `<span>` and names the
|
|
10
|
+
* select nowhere (src/modules/paging.js:662-669).
|
|
11
|
+
*
|
|
12
|
+
* Attributes:
|
|
13
|
+
* - `results-text` — label text, rendered as text content.
|
|
14
|
+
* - `page-length` — the selected page length. The matching option is
|
|
15
|
+
* selected, or the first option when the attribute is empty or matches
|
|
16
|
+
* none, and the effective value is reflected back into the attribute,
|
|
17
|
+
* so the attribute always reports what the select shows.
|
|
18
|
+
*
|
|
19
|
+
* The label text names the select. When `results-text` is absent or
|
|
20
|
+
* empty, `aria-label` (`Rows per page`, from ROADMAP
|
|
21
|
+
* v1-webcomponents-investigation.md:313) names it instead.
|
|
22
|
+
*
|
|
23
|
+
* Events:
|
|
24
|
+
* - `page-length-change` — dispatched when the user picks a length, with
|
|
25
|
+
* `detail: {pageLength}`. That value is the select's raw value, a
|
|
26
|
+
* string; the host parses it (paging.js:778).
|
|
27
|
+
*
|
|
28
|
+
* `setPageLengths()` takes the page lengths from the host, and each
|
|
29
|
+
* entry becomes an option whose value and text are both that entry
|
|
30
|
+
* (legacy `new Option(v, v)`, paging.js:681).
|
|
31
|
+
*
|
|
32
|
+
* Styling is left to the theme via `--tf-*` custom properties and
|
|
33
|
+
* `::part()`; the legacy `results_slc_css_class` and
|
|
34
|
+
* `results_span_css_class` keys are `::part()` hooks, and no CSS class or
|
|
35
|
+
* presentational style is shipped.
|
|
36
|
+
*
|
|
37
|
+
* Importing this module registers the element. It is not part of the
|
|
38
|
+
* legacy webpack bundle; consumers load it as a module.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
// Name used when the host supplies no label text.
|
|
42
|
+
const DEFAULT_RESULTS_LABEL = 'Rows per page';
|
|
43
|
+
|
|
44
|
+
const TEMPLATE = document.createElement('template');
|
|
45
|
+
TEMPLATE.innerHTML = `
|
|
46
|
+
<label part="results-label">
|
|
47
|
+
<span part="results-text"></span><select part="results-select"></select>
|
|
48
|
+
</label>
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export class TfResultsPerPageElement extends HTMLElement {
|
|
52
|
+
constructor() {
|
|
53
|
+
super();
|
|
54
|
+
this.attachShadow({ mode: 'open' });
|
|
55
|
+
this.shadowRoot.appendChild(TEMPLATE.content.cloneNode(true));
|
|
56
|
+
this._textEl =
|
|
57
|
+
this.shadowRoot.querySelector('[part="results-text"]');
|
|
58
|
+
this._select =
|
|
59
|
+
this.shadowRoot.querySelector('[part="results-select"]');
|
|
60
|
+
// Page lengths supplied through setPageLengths().
|
|
61
|
+
this._lengths = [];
|
|
62
|
+
// A change inside the shadow root does not reach the host: the
|
|
63
|
+
// native `change` event is not composed, so it is relayed as a
|
|
64
|
+
// composed CustomEvent carrying the chosen value. The pick is
|
|
65
|
+
// written into `page-length` before the event is dispatched.
|
|
66
|
+
this._select.addEventListener('change', () => {
|
|
67
|
+
this.setAttribute('page-length', this._select.value);
|
|
68
|
+
this.dispatchEvent(new CustomEvent('page-length-change', {
|
|
69
|
+
detail: { pageLength: this._select.value },
|
|
70
|
+
bubbles: true,
|
|
71
|
+
composed: true
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static get observedAttributes() {
|
|
77
|
+
return ['results-text', 'page-length'];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
connectedCallback() {
|
|
81
|
+
this._update();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
attributeChangedCallback() {
|
|
85
|
+
this._update();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Set the label text, rendered into the `results-text` part.
|
|
90
|
+
* @param {*} text Label text
|
|
91
|
+
*/
|
|
92
|
+
setText(text) {
|
|
93
|
+
this.setAttribute('results-text', text == null ? '' : String(text));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Set the selected page length.
|
|
98
|
+
* @param {*} pageLength Page length
|
|
99
|
+
*/
|
|
100
|
+
setPageLength(pageLength) {
|
|
101
|
+
this.setAttribute('page-length',
|
|
102
|
+
pageLength == null ? '' : String(pageLength));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Supply the option list. Each entry becomes an option whose value
|
|
107
|
+
* and text are both the entry (src/modules/paging.js:681).
|
|
108
|
+
* @param {Array<*>} lengths Page lengths
|
|
109
|
+
*/
|
|
110
|
+
setPageLengths(lengths) {
|
|
111
|
+
this._lengths = Array.isArray(lengths) ? lengths : [];
|
|
112
|
+
this._updateOptions();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Render the label text, name the select and select the option
|
|
117
|
+
* matching `page-length`.
|
|
118
|
+
*/
|
|
119
|
+
_update() {
|
|
120
|
+
this._textEl.textContent = this.getAttribute('results-text') || '';
|
|
121
|
+
this._setSelectName();
|
|
122
|
+
this._selectOptions();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Name the select from the label text, or from the default when
|
|
127
|
+
* `results-text` is absent or empty.
|
|
128
|
+
*/
|
|
129
|
+
_setSelectName() {
|
|
130
|
+
if (this.getAttribute('results-text')) {
|
|
131
|
+
this._select.removeAttribute('aria-label');
|
|
132
|
+
} else {
|
|
133
|
+
this._select.setAttribute('aria-label', DEFAULT_RESULTS_LABEL);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Rebuild the option list from the supplied page lengths.
|
|
139
|
+
*/
|
|
140
|
+
_updateOptions() {
|
|
141
|
+
this._select.textContent = '';
|
|
142
|
+
this._lengths.forEach((length) => {
|
|
143
|
+
this._select.add(new Option(length, length, false, false));
|
|
144
|
+
});
|
|
145
|
+
this._selectOptions();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Select the option whose value matches `page-length`, or the first
|
|
150
|
+
* option when the attribute is empty or matches none, and reflect the
|
|
151
|
+
* option that ended up selected back into the attribute.
|
|
152
|
+
*/
|
|
153
|
+
_selectOptions() {
|
|
154
|
+
const options = this._select.options;
|
|
155
|
+
if (options.length === 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const pageLength = this.getAttribute('page-length') || '';
|
|
159
|
+
let index = -1;
|
|
160
|
+
for (let i = 0; i < options.length; i++) {
|
|
161
|
+
if (options[i].value === pageLength) {
|
|
162
|
+
index = i;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (index === -1) {
|
|
167
|
+
index = 0;
|
|
168
|
+
}
|
|
169
|
+
options[index].selected = true;
|
|
170
|
+
if (options[index].value !== pageLength) {
|
|
171
|
+
this.setAttribute('page-length', options[index].value);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Register once: loading this module twice (or on a page that already
|
|
177
|
+
// defined the element) must not throw.
|
|
178
|
+
if (typeof customElements !== 'undefined' &&
|
|
179
|
+
!customElements.get('tf-results-per-page')) {
|
|
180
|
+
customElements.define('tf-results-per-page', TfResultsPerPageElement);
|
|
181
|
+
}
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
* in a bundle belongs with #965.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
import {applyLiveRegion} from './attributes.js';
|
|
23
|
+
|
|
22
24
|
const TEMPLATE = document.createElement('template');
|
|
23
25
|
TEMPLATE.innerHTML = `
|
|
24
26
|
<span part="label"></span>
|
|
@@ -40,12 +42,7 @@ export class TfRowsCounterElement extends HTMLElement {
|
|
|
40
42
|
|
|
41
43
|
connectedCallback() {
|
|
42
44
|
// Live-region contract: the counter announces count changes.
|
|
43
|
-
|
|
44
|
-
// `aria-atomic="true"`; set explicitly so the contract is visible
|
|
45
|
-
// to consumers and a wrong consumer value is corrected.
|
|
46
|
-
this.setAttribute('role', 'status');
|
|
47
|
-
this.setAttribute('aria-live', 'polite');
|
|
48
|
-
this.setAttribute('aria-atomic', 'true');
|
|
45
|
+
applyLiveRegion(this);
|
|
49
46
|
this._update();
|
|
50
47
|
}
|
|
51
48
|
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Scaffold (#905): an open shadow root exposing the `label` and
|
|
6
6
|
* `message` parts, rendered statically from the `text` and `message`
|
|
7
7
|
* attributes. The host is the live region (#906): connecting it enforces
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* the shared live-region contract (`applyLiveRegion()`) so message
|
|
9
|
+
* changes are announced. The StatusBar bridge (#907) follows.
|
|
10
10
|
*
|
|
11
11
|
* `text` is a plain label and is rendered as text. `message` is rendered
|
|
12
12
|
* as HTML, matching legacy `StatusBar` (`msgContainer.innerHTML = t`),
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
import {sanitizeHtml} from '../sanitize.js';
|
|
33
|
+
import {applyLiveRegion} from './attributes.js';
|
|
33
34
|
|
|
34
35
|
// Cloned into every instance's shadow root. Structure and `part` hooks
|
|
35
36
|
// only: `part` is the stable internal contract (selected by _update()
|
|
@@ -55,15 +56,9 @@ export class TfStatusElement extends HTMLElement {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
connectedCallback() {
|
|
58
|
-
// Live-region contract (#906)
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
// explicitly keeps the contract visible to consumers. The host
|
|
62
|
-
// is the region: the shadow parts carry no ARIA of their own, so
|
|
63
|
-
// a message change is announced once, as "label message".
|
|
64
|
-
this.setAttribute('role', 'status');
|
|
65
|
-
this.setAttribute('aria-live', 'polite');
|
|
66
|
-
this.setAttribute('aria-atomic', 'true');
|
|
59
|
+
// Live-region contract (#906): the host is the region, so a
|
|
60
|
+
// message change is announced once, as "label message".
|
|
61
|
+
applyLiveRegion(this);
|
|
67
62
|
this._update();
|
|
68
63
|
}
|
|
69
64
|
|
|
@@ -2,7 +2,14 @@ import AdapterSortableTable from './adapterSortabletable';
|
|
|
2
2
|
import {root} from '../../root';
|
|
3
3
|
|
|
4
4
|
if (!root.SortableTable) {
|
|
5
|
-
|
|
5
|
+
// The vendored SortableTable script is loaded through webpack's
|
|
6
|
+
// `script-loader!` syntax. The call is left unguarded by eval() so
|
|
7
|
+
// webpack can resolve it statically and inline the script in the
|
|
8
|
+
// bundle; the Vite build strips it and loads the script itself
|
|
9
|
+
// (see injectSortableTable in vite.config.js).
|
|
10
|
+
if (typeof require !== 'undefined') {
|
|
11
|
+
require('script-loader!sortabletable');
|
|
12
|
+
}
|
|
6
13
|
}
|
|
7
14
|
|
|
8
15
|
export default AdapterSortableTable;
|