@internetarchive/collection-browser 1.12.0 → 1.13.0-alpha2
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 +29 -29
- package/.github/workflows/ci.yml +26 -26
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +4 -4
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/index.d.ts +9 -9
- package/dist/index.js +9 -9
- package/dist/src/app-root.d.ts +54 -54
- package/dist/src/app-root.js +293 -293
- package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
- package/dist/src/assets/img/icons/arrow-left.js +2 -2
- package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
- package/dist/src/assets/img/icons/arrow-right.js +2 -2
- package/dist/src/assets/img/icons/chevron.d.ts +2 -2
- package/dist/src/assets/img/icons/chevron.js +2 -2
- package/dist/src/assets/img/icons/contract.d.ts +2 -2
- package/dist/src/assets/img/icons/contract.js +2 -2
- package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
- package/dist/src/assets/img/icons/empty-query.js +2 -2
- package/dist/src/assets/img/icons/expand.d.ts +2 -2
- package/dist/src/assets/img/icons/expand.js +2 -2
- package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
- package/dist/src/assets/img/icons/eye-closed.js +2 -2
- package/dist/src/assets/img/icons/eye.d.ts +2 -2
- package/dist/src/assets/img/icons/eye.js +2 -2
- package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
- package/dist/src/assets/img/icons/favorite-filled.js +2 -2
- package/dist/src/assets/img/icons/login-required.d.ts +1 -1
- package/dist/src/assets/img/icons/login-required.js +2 -2
- package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/account.js +2 -2
- package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
- package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
- package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/data.js +2 -2
- package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
- package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/film.js +2 -2
- package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/images.js +2 -2
- package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
- package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/software.js +2 -2
- package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
- package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
- package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/video.js +2 -2
- package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/web.js +2 -2
- package/dist/src/assets/img/icons/null-result.d.ts +2 -2
- package/dist/src/assets/img/icons/null-result.js +2 -2
- package/dist/src/assets/img/icons/restricted.d.ts +1 -1
- package/dist/src/assets/img/icons/restricted.js +2 -2
- package/dist/src/assets/img/icons/reviews.d.ts +1 -1
- package/dist/src/assets/img/icons/reviews.js +2 -2
- package/dist/src/assets/img/icons/upload.d.ts +1 -1
- package/dist/src/assets/img/icons/upload.js +2 -2
- package/dist/src/assets/img/icons/views.d.ts +1 -1
- package/dist/src/assets/img/icons/views.js +2 -2
- package/dist/src/circular-activity-indicator.d.ts +5 -5
- package/dist/src/circular-activity-indicator.js +17 -17
- package/dist/src/collection-browser.d.ts +473 -472
- package/dist/src/collection-browser.js +1696 -1686
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
- package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
- package/dist/src/collection-facets/facets-template.d.ts +20 -20
- package/dist/src/collection-facets/facets-template.js +152 -152
- package/dist/src/collection-facets/more-facets-content.d.ts +77 -77
- package/dist/src/collection-facets/more-facets-content.js +359 -359
- package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
- package/dist/src/collection-facets/more-facets-pagination.js +196 -196
- package/dist/src/collection-facets/toggle-switch.d.ts +41 -41
- package/dist/src/collection-facets/toggle-switch.js +94 -94
- package/dist/src/collection-facets.d.ts +103 -103
- package/dist/src/collection-facets.js +497 -497
- package/dist/src/empty-placeholder.d.ts +23 -21
- package/dist/src/empty-placeholder.js +83 -69
- package/dist/src/empty-placeholder.js.map +1 -1
- package/dist/src/expanded-date-picker.d.ts +43 -43
- package/dist/src/expanded-date-picker.js +109 -109
- package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
- package/dist/src/language-code-handler/language-code-handler.js +26 -26
- package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
- package/dist/src/language-code-handler/language-code-mapping.js +562 -562
- package/dist/src/mediatype/mediatype-config.d.ts +3 -3
- package/dist/src/mediatype/mediatype-config.js +85 -85
- package/dist/src/models.d.ts +163 -163
- package/dist/src/models.js +269 -269
- package/dist/src/restoration-state-handler.d.ts +70 -70
- package/dist/src/restoration-state-handler.js +355 -355
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
- package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -21
- package/dist/src/sort-filter-bar/alpha-bar.js +128 -128
- package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/compact.js +2 -2
- package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/list.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-down.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-up.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
- package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/tile.js +2 -2
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +208 -208
- package/dist/src/sort-filter-bar/sort-filter-bar.js +637 -637
- package/dist/src/styles/item-image-styles.d.ts +8 -8
- package/dist/src/styles/item-image-styles.js +9 -9
- package/dist/src/styles/sr-only.d.ts +1 -1
- package/dist/src/styles/sr-only.js +2 -2
- package/dist/src/tiles/base-tile-component.d.ts +18 -18
- package/dist/src/tiles/base-tile-component.js +59 -59
- package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
- package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
- package/dist/src/tiles/grid/account-tile.d.ts +18 -18
- package/dist/src/tiles/grid/account-tile.js +72 -72
- package/dist/src/tiles/grid/collection-tile.d.ts +15 -15
- package/dist/src/tiles/grid/collection-tile.js +80 -80
- package/dist/src/tiles/grid/item-tile.d.ts +27 -27
- package/dist/src/tiles/grid/item-tile.js +134 -134
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +8 -8
- package/dist/src/tiles/grid/tile-stats.d.ts +11 -11
- package/dist/src/tiles/grid/tile-stats.js +48 -48
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
- package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
- package/dist/src/tiles/hover/tile-hover-pane.d.ts +15 -15
- package/dist/src/tiles/hover/tile-hover-pane.js +38 -38
- package/dist/src/tiles/image-block.d.ts +17 -17
- package/dist/src/tiles/image-block.js +72 -72
- package/dist/src/tiles/item-image.d.ts +35 -35
- package/dist/src/tiles/item-image.js +117 -117
- package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -6
- package/dist/src/tiles/list/tile-list-compact-header.js +38 -38
- package/dist/src/tiles/list/tile-list-compact.d.ts +15 -15
- package/dist/src/tiles/list/tile-list-compact.js +114 -114
- package/dist/src/tiles/list/tile-list.d.ts +46 -46
- package/dist/src/tiles/list/tile-list.js +298 -298
- package/dist/src/tiles/mediatype-icon.d.ts +9 -9
- package/dist/src/tiles/mediatype-icon.js +47 -47
- package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
- package/dist/src/tiles/overlay/icon-overlay.js +40 -40
- package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
- package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
- package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
- package/dist/src/tiles/overlay/text-overlay.js +42 -42
- package/dist/src/tiles/text-snippet-block.d.ts +27 -27
- package/dist/src/tiles/text-snippet-block.js +73 -73
- package/dist/src/tiles/tile-dispatcher.d.ts +50 -50
- package/dist/src/tiles/tile-dispatcher.js +185 -185
- package/dist/src/tiles/tile-display-value-provider.d.ts +43 -43
- package/dist/src/tiles/tile-display-value-provider.js +80 -80
- package/dist/src/utils/analytics-events.d.ts +25 -25
- package/dist/src/utils/analytics-events.js +27 -27
- package/dist/src/utils/array-equals.d.ts +4 -4
- package/dist/src/utils/array-equals.js +10 -10
- package/dist/src/utils/format-count.d.ts +7 -7
- package/dist/src/utils/format-count.js +76 -76
- package/dist/src/utils/format-date.d.ts +2 -2
- package/dist/src/utils/format-date.js +25 -25
- package/dist/src/utils/format-unit-size.d.ts +2 -2
- package/dist/src/utils/format-unit-size.js +33 -33
- package/dist/src/utils/local-date-from-utc.d.ts +9 -9
- package/dist/src/utils/local-date-from-utc.js +15 -15
- package/dist/src/utils/sha1.d.ts +2 -2
- package/dist/src/utils/sha1.js +8 -8
- package/dist/test/collection-browser.test.d.ts +1 -1
- package/dist/test/collection-browser.test.js +981 -967
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
- package/dist/test/collection-facets/facets-template.test.js +134 -134
- package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +133 -133
- package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
- package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -1
- package/dist/test/collection-facets/toggle-switch.test.js +73 -73
- package/dist/test/collection-facets.test.d.ts +2 -2
- package/dist/test/collection-facets.test.js +682 -682
- package/dist/test/empty-placeholder.test.d.ts +1 -1
- package/dist/test/empty-placeholder.test.js +63 -56
- package/dist/test/empty-placeholder.test.js.map +1 -1
- package/dist/test/expanded-date-picker.test.d.ts +1 -1
- package/dist/test/expanded-date-picker.test.js +95 -95
- package/dist/test/icon-overlay.test.d.ts +1 -1
- package/dist/test/icon-overlay.test.js +24 -24
- package/dist/test/image-block.test.d.ts +1 -1
- package/dist/test/image-block.test.js +48 -48
- package/dist/test/item-image.test.d.ts +1 -1
- package/dist/test/item-image.test.js +84 -84
- package/dist/test/mediatype-config.test.d.ts +1 -1
- package/dist/test/mediatype-config.test.js +16 -16
- package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
- package/dist/test/mocks/mock-analytics-handler.js +15 -15
- package/dist/test/mocks/mock-collection-name-cache.d.ts +9 -9
- package/dist/test/mocks/mock-collection-name-cache.js +17 -17
- package/dist/test/mocks/mock-search-responses.d.ts +21 -21
- package/dist/test/mocks/mock-search-responses.js +707 -707
- package/dist/test/mocks/mock-search-service.d.ts +15 -15
- package/dist/test/mocks/mock-search-service.js +50 -50
- package/dist/test/restoration-state-handler.test.d.ts +1 -1
- package/dist/test/restoration-state-handler.test.js +270 -270
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
- package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
- package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +378 -378
- package/dist/test/text-overlay.test.d.ts +1 -1
- package/dist/test/text-overlay.test.js +48 -48
- package/dist/test/text-snippet-block.test.d.ts +1 -1
- package/dist/test/text-snippet-block.test.js +57 -57
- package/dist/test/tile-stats.test.d.ts +1 -1
- package/dist/test/tile-stats.test.js +33 -33
- package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/account-tile.test.js +76 -76
- package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/collection-tile.test.js +73 -73
- package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +254 -254
- package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +257 -257
- package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
- package/dist/test/tiles/hover/tile-hover-pane.test.js +13 -13
- package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +143 -143
- package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
- package/dist/test/tiles/list/tile-list.test.js +242 -242
- package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +67 -67
- package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -1
- package/dist/test/tiles/tile-display-value-provider.test.js +141 -141
- package/dist/test/utils/array-equals.test.d.ts +1 -1
- package/dist/test/utils/array-equals.test.js +26 -26
- package/dist/test/utils/format-count.test.d.ts +1 -1
- package/dist/test/utils/format-count.test.js +23 -23
- package/dist/test/utils/format-date.test.d.ts +1 -1
- package/dist/test/utils/format-date.test.js +17 -17
- package/dist/test/utils/format-unit-size.test.d.ts +1 -1
- package/dist/test/utils/format-unit-size.test.js +17 -17
- package/dist/test/utils/local-date-from-utc.test.d.ts +1 -1
- package/dist/test/utils/local-date-from-utc.test.js +26 -26
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +1 -1
- package/renovate.json +6 -6
- package/src/collection-browser.ts +15 -1
- package/src/empty-placeholder.ts +17 -0
- package/test/collection-browser.test.ts +23 -0
- package/test/empty-placeholder.test.ts +26 -19
- package/tsconfig.json +21 -21
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { LitElement, html, css, nothing, } from 'lit';
|
|
3
|
-
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
|
-
import '@internetarchive/ia-dropdown';
|
|
5
|
-
import { SORT_OPTIONS, SortField, } from '../models';
|
|
6
|
-
import './alpha-bar';
|
|
7
|
-
import { sortUpIcon } from './img/sort-toggle-up';
|
|
8
|
-
import { sortDownIcon } from './img/sort-toggle-down';
|
|
9
|
-
import { sortDisabledIcon } from './img/sort-toggle-disabled';
|
|
10
|
-
import { tileIcon } from './img/tile';
|
|
11
|
-
import { listIcon } from './img/list';
|
|
12
|
-
import { compactIcon } from './img/compact';
|
|
13
|
-
import { srOnlyStyle } from '../styles/sr-only';
|
|
14
|
-
let SortFilterBar = class SortFilterBar extends LitElement {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments);
|
|
17
|
-
/** The default sort direction to use if none is set */
|
|
18
|
-
this.defaultSortDirection = null;
|
|
19
|
-
/** The default sort field to use if none is set */
|
|
20
|
-
this.defaultSortField = SortField.relevance;
|
|
21
|
-
/** The current sort direction (asc/desc), or null if none is set */
|
|
22
|
-
this.sortDirection = null;
|
|
23
|
-
/** The field currently being sorted on (e.g., 'title'). Defaults to relevance. */
|
|
24
|
-
this.selectedSort = SortField.default;
|
|
25
|
-
/** The currently selected title letter filter, or null if none is set */
|
|
26
|
-
this.selectedTitleFilter = null;
|
|
27
|
-
/** The currently selected creator letter filter, or null if none is set */
|
|
28
|
-
this.selectedCreatorFilter = null;
|
|
29
|
-
/** Whether to show the Relevance sort option (default `true`) */
|
|
30
|
-
this.showRelevance = true;
|
|
31
|
-
/** Whether to show the Date Favorited sort option instead of Date Published/Archived/Reviewed (default `false`) */
|
|
32
|
-
this.showDateFavorited = false;
|
|
33
|
-
/**
|
|
34
|
-
* Which of the alphabet bars (title/creator) should be shown, or null if one
|
|
35
|
-
* should not currently be rendered.
|
|
36
|
-
*/
|
|
37
|
-
this.alphaSelectorVisible = null;
|
|
38
|
-
/**
|
|
39
|
-
* Whether the transparent backdrop to catch clicks outside the dropdown menu
|
|
40
|
-
* should be rendered.
|
|
41
|
-
*/
|
|
42
|
-
this.dropdownBackdropVisible = false;
|
|
43
|
-
/**
|
|
44
|
-
* The width of the desktop view sort option container, updated upon each resize.
|
|
45
|
-
* Used for dynamically determining whether to use desktop or mobile view.
|
|
46
|
-
*/
|
|
47
|
-
this.desktopSortContainerWidth = 0;
|
|
48
|
-
/**
|
|
49
|
-
* The width of the full sort bar, updated upon each resize.
|
|
50
|
-
* Used for dynamically determining whether to use desktop or mobile view.
|
|
51
|
-
*/
|
|
52
|
-
this.selectorBarContainerWidth = 0;
|
|
53
|
-
this.boundSortBarSelectorEscapeListener = (e) => {
|
|
54
|
-
if (e.key === 'Escape') {
|
|
55
|
-
this.closeDropdowns();
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
render() {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, html, css, nothing, } from 'lit';
|
|
3
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
|
+
import '@internetarchive/ia-dropdown';
|
|
5
|
+
import { SORT_OPTIONS, SortField, } from '../models';
|
|
6
|
+
import './alpha-bar';
|
|
7
|
+
import { sortUpIcon } from './img/sort-toggle-up';
|
|
8
|
+
import { sortDownIcon } from './img/sort-toggle-down';
|
|
9
|
+
import { sortDisabledIcon } from './img/sort-toggle-disabled';
|
|
10
|
+
import { tileIcon } from './img/tile';
|
|
11
|
+
import { listIcon } from './img/list';
|
|
12
|
+
import { compactIcon } from './img/compact';
|
|
13
|
+
import { srOnlyStyle } from '../styles/sr-only';
|
|
14
|
+
let SortFilterBar = class SortFilterBar extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
/** The default sort direction to use if none is set */
|
|
18
|
+
this.defaultSortDirection = null;
|
|
19
|
+
/** The default sort field to use if none is set */
|
|
20
|
+
this.defaultSortField = SortField.relevance;
|
|
21
|
+
/** The current sort direction (asc/desc), or null if none is set */
|
|
22
|
+
this.sortDirection = null;
|
|
23
|
+
/** The field currently being sorted on (e.g., 'title'). Defaults to relevance. */
|
|
24
|
+
this.selectedSort = SortField.default;
|
|
25
|
+
/** The currently selected title letter filter, or null if none is set */
|
|
26
|
+
this.selectedTitleFilter = null;
|
|
27
|
+
/** The currently selected creator letter filter, or null if none is set */
|
|
28
|
+
this.selectedCreatorFilter = null;
|
|
29
|
+
/** Whether to show the Relevance sort option (default `true`) */
|
|
30
|
+
this.showRelevance = true;
|
|
31
|
+
/** Whether to show the Date Favorited sort option instead of Date Published/Archived/Reviewed (default `false`) */
|
|
32
|
+
this.showDateFavorited = false;
|
|
33
|
+
/**
|
|
34
|
+
* Which of the alphabet bars (title/creator) should be shown, or null if one
|
|
35
|
+
* should not currently be rendered.
|
|
36
|
+
*/
|
|
37
|
+
this.alphaSelectorVisible = null;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the transparent backdrop to catch clicks outside the dropdown menu
|
|
40
|
+
* should be rendered.
|
|
41
|
+
*/
|
|
42
|
+
this.dropdownBackdropVisible = false;
|
|
43
|
+
/**
|
|
44
|
+
* The width of the desktop view sort option container, updated upon each resize.
|
|
45
|
+
* Used for dynamically determining whether to use desktop or mobile view.
|
|
46
|
+
*/
|
|
47
|
+
this.desktopSortContainerWidth = 0;
|
|
48
|
+
/**
|
|
49
|
+
* The width of the full sort bar, updated upon each resize.
|
|
50
|
+
* Used for dynamically determining whether to use desktop or mobile view.
|
|
51
|
+
*/
|
|
52
|
+
this.selectorBarContainerWidth = 0;
|
|
53
|
+
this.boundSortBarSelectorEscapeListener = (e) => {
|
|
54
|
+
if (e.key === 'Escape') {
|
|
55
|
+
this.closeDropdowns();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
60
|
return html `
|
|
61
61
|
<div id="container">
|
|
62
62
|
<section id="sort-bar" aria-label="Sorting options">
|
|
@@ -76,106 +76,106 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
76
76
|
${this.dropdownBackdropVisible ? this.dropdownBackdrop : nothing}
|
|
77
77
|
${this.alphaBarTemplate}
|
|
78
78
|
</div>
|
|
79
|
-
`;
|
|
80
|
-
}
|
|
81
|
-
updated(changed) {
|
|
82
|
-
if (changed.has('displayMode')) {
|
|
83
|
-
this.displayModeChanged();
|
|
84
|
-
}
|
|
85
|
-
if (changed.has('selectedSort') && this.sortDirection === null) {
|
|
86
|
-
const sortOption = SORT_OPTIONS[this.finalizedSortField];
|
|
87
|
-
this.sortDirection = sortOption.defaultSortDirection;
|
|
88
|
-
}
|
|
89
|
-
if (changed.has('selectedTitleFilter') && this.selectedTitleFilter) {
|
|
90
|
-
this.alphaSelectorVisible = 'title';
|
|
91
|
-
}
|
|
92
|
-
if (changed.has('selectedCreatorFilter') && this.selectedCreatorFilter) {
|
|
93
|
-
this.alphaSelectorVisible = 'creator';
|
|
94
|
-
}
|
|
95
|
-
if (changed.has('dropdownBackdropVisible')) {
|
|
96
|
-
this.setupEscapeListeners();
|
|
97
|
-
}
|
|
98
|
-
if (changed.has('resizeObserver')) {
|
|
99
|
-
const oldObserver = changed.get('resizeObserver');
|
|
100
|
-
if (oldObserver)
|
|
101
|
-
this.disconnectResizeObserver(oldObserver);
|
|
102
|
-
this.setupResizeObserver();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
setupEscapeListeners() {
|
|
106
|
-
if (this.dropdownBackdropVisible) {
|
|
107
|
-
document.addEventListener('keydown', this.boundSortBarSelectorEscapeListener);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
document.removeEventListener('keydown', this.boundSortBarSelectorEscapeListener);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
disconnectedCallback() {
|
|
114
|
-
if (this.resizeObserver) {
|
|
115
|
-
this.disconnectResizeObserver(this.resizeObserver);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
disconnectResizeObserver(resizeObserver) {
|
|
119
|
-
resizeObserver.removeObserver({
|
|
120
|
-
target: this.sortSelectorContainer,
|
|
121
|
-
handler: this,
|
|
122
|
-
});
|
|
123
|
-
resizeObserver.removeObserver({
|
|
124
|
-
target: this.desktopSortContainer,
|
|
125
|
-
handler: this,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
setupResizeObserver() {
|
|
129
|
-
if (!this.resizeObserver)
|
|
130
|
-
return;
|
|
131
|
-
this.resizeObserver.addObserver({
|
|
132
|
-
target: this.sortSelectorContainer,
|
|
133
|
-
handler: this,
|
|
134
|
-
});
|
|
135
|
-
this.resizeObserver.addObserver({
|
|
136
|
-
target: this.desktopSortContainer,
|
|
137
|
-
handler: this,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
handleResize(entry) {
|
|
141
|
-
if (entry.target === this.desktopSortContainer) {
|
|
142
|
-
this.desktopSortContainerWidth = entry.contentRect.width;
|
|
143
|
-
}
|
|
144
|
-
else if (entry.target === this.sortSelectorContainer) {
|
|
145
|
-
this.selectorBarContainerWidth = entry.contentRect.width;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Whether to show the mobile sort bar because there is not enough space
|
|
150
|
-
* for the desktop sort bar.
|
|
151
|
-
*/
|
|
152
|
-
get mobileSelectorVisible() {
|
|
153
|
-
return this.selectorBarContainerWidth - 10 < this.desktopSortContainerWidth;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Template to render the alphabet bar, or `nothing` if it should not be rendered
|
|
157
|
-
* for the current sort
|
|
158
|
-
*/
|
|
159
|
-
get alphaBarTemplate() {
|
|
160
|
-
if (!['title', 'creator'].includes(this.selectedSort))
|
|
161
|
-
return nothing;
|
|
162
|
-
if (this.alphaSelectorVisible === null) {
|
|
163
|
-
if (this.selectedSort === 'creator')
|
|
164
|
-
return this.creatorSelectorBar;
|
|
165
|
-
if (this.selectedSort === 'title')
|
|
166
|
-
return this.titleSelectorBar;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
return this.alphaSelectorVisible === 'creator'
|
|
170
|
-
? this.creatorSelectorBar
|
|
171
|
-
: this.titleSelectorBar;
|
|
172
|
-
}
|
|
173
|
-
return nothing;
|
|
174
|
-
}
|
|
175
|
-
/** Template to render the sort direction toggle button */
|
|
176
|
-
get sortDirectionSelectorTemplate() {
|
|
177
|
-
const oppositeSortDirectionReadable = this.sortDirection === 'asc' ? 'descending' : 'ascending';
|
|
178
|
-
const srLabel = `Change to ${oppositeSortDirectionReadable} sort`;
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
updated(changed) {
|
|
82
|
+
if (changed.has('displayMode')) {
|
|
83
|
+
this.displayModeChanged();
|
|
84
|
+
}
|
|
85
|
+
if (changed.has('selectedSort') && this.sortDirection === null) {
|
|
86
|
+
const sortOption = SORT_OPTIONS[this.finalizedSortField];
|
|
87
|
+
this.sortDirection = sortOption.defaultSortDirection;
|
|
88
|
+
}
|
|
89
|
+
if (changed.has('selectedTitleFilter') && this.selectedTitleFilter) {
|
|
90
|
+
this.alphaSelectorVisible = 'title';
|
|
91
|
+
}
|
|
92
|
+
if (changed.has('selectedCreatorFilter') && this.selectedCreatorFilter) {
|
|
93
|
+
this.alphaSelectorVisible = 'creator';
|
|
94
|
+
}
|
|
95
|
+
if (changed.has('dropdownBackdropVisible')) {
|
|
96
|
+
this.setupEscapeListeners();
|
|
97
|
+
}
|
|
98
|
+
if (changed.has('resizeObserver')) {
|
|
99
|
+
const oldObserver = changed.get('resizeObserver');
|
|
100
|
+
if (oldObserver)
|
|
101
|
+
this.disconnectResizeObserver(oldObserver);
|
|
102
|
+
this.setupResizeObserver();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
setupEscapeListeners() {
|
|
106
|
+
if (this.dropdownBackdropVisible) {
|
|
107
|
+
document.addEventListener('keydown', this.boundSortBarSelectorEscapeListener);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
document.removeEventListener('keydown', this.boundSortBarSelectorEscapeListener);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
disconnectedCallback() {
|
|
114
|
+
if (this.resizeObserver) {
|
|
115
|
+
this.disconnectResizeObserver(this.resizeObserver);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
disconnectResizeObserver(resizeObserver) {
|
|
119
|
+
resizeObserver.removeObserver({
|
|
120
|
+
target: this.sortSelectorContainer,
|
|
121
|
+
handler: this,
|
|
122
|
+
});
|
|
123
|
+
resizeObserver.removeObserver({
|
|
124
|
+
target: this.desktopSortContainer,
|
|
125
|
+
handler: this,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
setupResizeObserver() {
|
|
129
|
+
if (!this.resizeObserver)
|
|
130
|
+
return;
|
|
131
|
+
this.resizeObserver.addObserver({
|
|
132
|
+
target: this.sortSelectorContainer,
|
|
133
|
+
handler: this,
|
|
134
|
+
});
|
|
135
|
+
this.resizeObserver.addObserver({
|
|
136
|
+
target: this.desktopSortContainer,
|
|
137
|
+
handler: this,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
handleResize(entry) {
|
|
141
|
+
if (entry.target === this.desktopSortContainer) {
|
|
142
|
+
this.desktopSortContainerWidth = entry.contentRect.width;
|
|
143
|
+
}
|
|
144
|
+
else if (entry.target === this.sortSelectorContainer) {
|
|
145
|
+
this.selectorBarContainerWidth = entry.contentRect.width;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Whether to show the mobile sort bar because there is not enough space
|
|
150
|
+
* for the desktop sort bar.
|
|
151
|
+
*/
|
|
152
|
+
get mobileSelectorVisible() {
|
|
153
|
+
return this.selectorBarContainerWidth - 10 < this.desktopSortContainerWidth;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Template to render the alphabet bar, or `nothing` if it should not be rendered
|
|
157
|
+
* for the current sort
|
|
158
|
+
*/
|
|
159
|
+
get alphaBarTemplate() {
|
|
160
|
+
if (!['title', 'creator'].includes(this.selectedSort))
|
|
161
|
+
return nothing;
|
|
162
|
+
if (this.alphaSelectorVisible === null) {
|
|
163
|
+
if (this.selectedSort === 'creator')
|
|
164
|
+
return this.creatorSelectorBar;
|
|
165
|
+
if (this.selectedSort === 'title')
|
|
166
|
+
return this.titleSelectorBar;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
return this.alphaSelectorVisible === 'creator'
|
|
170
|
+
? this.creatorSelectorBar
|
|
171
|
+
: this.titleSelectorBar;
|
|
172
|
+
}
|
|
173
|
+
return nothing;
|
|
174
|
+
}
|
|
175
|
+
/** Template to render the sort direction toggle button */
|
|
176
|
+
get sortDirectionSelectorTemplate() {
|
|
177
|
+
const oppositeSortDirectionReadable = this.sortDirection === 'asc' ? 'descending' : 'ascending';
|
|
178
|
+
const srLabel = `Change to ${oppositeSortDirectionReadable} sort`;
|
|
179
179
|
return html `
|
|
180
180
|
<button
|
|
181
181
|
class="sort-direction-selector"
|
|
@@ -185,148 +185,148 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
185
185
|
<span class="sr-only">${srLabel}</span>
|
|
186
186
|
${this.sortDirectionIcon}
|
|
187
187
|
</button>
|
|
188
|
-
`;
|
|
189
|
-
}
|
|
190
|
-
/** Template to render the sort direction button's icon in the correct current state */
|
|
191
|
-
get sortDirectionIcon() {
|
|
192
|
-
// Show a fully disabled icon for sort options without direction support
|
|
193
|
-
if (!this.canChangeSortDirection) {
|
|
194
|
-
return html `<div class="sort-direction-icon">${sortDisabledIcon}</div>`;
|
|
195
|
-
}
|
|
196
|
-
// For all other sorts, show the ascending/descending direction
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
/** Template to render the sort direction button's icon in the correct current state */
|
|
191
|
+
get sortDirectionIcon() {
|
|
192
|
+
// Show a fully disabled icon for sort options without direction support
|
|
193
|
+
if (!this.canChangeSortDirection) {
|
|
194
|
+
return html `<div class="sort-direction-icon">${sortDisabledIcon}</div>`;
|
|
195
|
+
}
|
|
196
|
+
// For all other sorts, show the ascending/descending direction
|
|
197
197
|
return html `
|
|
198
198
|
<div class="sort-direction-icon">
|
|
199
199
|
${this.finalizedSortDirection === 'asc' ? sortUpIcon : sortDownIcon}
|
|
200
200
|
</div>
|
|
201
|
-
`;
|
|
202
|
-
}
|
|
203
|
-
/** The template to render all the sort options in desktop view */
|
|
204
|
-
get desktopSortSelectorTemplate() {
|
|
201
|
+
`;
|
|
202
|
+
}
|
|
203
|
+
/** The template to render all the sort options in desktop view */
|
|
204
|
+
get desktopSortSelectorTemplate() {
|
|
205
205
|
return html `
|
|
206
206
|
<div
|
|
207
207
|
id="desktop-sort-container"
|
|
208
208
|
class=${this.mobileSelectorVisible ? 'hidden' : 'visible'}
|
|
209
209
|
>
|
|
210
210
|
<ul id="desktop-sort-selector">
|
|
211
|
-
${this.showRelevance
|
|
211
|
+
${this.showRelevance
|
|
212
212
|
? html `<li>
|
|
213
|
-
${this.getSortDisplayOption(SortField.relevance, {
|
|
214
|
-
onClick: () => {
|
|
215
|
-
this.dropdownBackdropVisible = false;
|
|
216
|
-
if (this.finalizedSortField !== SortField.relevance) {
|
|
217
|
-
this.clearAlphaBarFilters();
|
|
218
|
-
this.setSelectedSort(SortField.relevance);
|
|
219
|
-
}
|
|
220
|
-
},
|
|
213
|
+
${this.getSortDisplayOption(SortField.relevance, {
|
|
214
|
+
onClick: () => {
|
|
215
|
+
this.dropdownBackdropVisible = false;
|
|
216
|
+
if (this.finalizedSortField !== SortField.relevance) {
|
|
217
|
+
this.clearAlphaBarFilters();
|
|
218
|
+
this.setSelectedSort(SortField.relevance);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
221
|
})}
|
|
222
|
-
</li>`
|
|
222
|
+
</li>`
|
|
223
223
|
: nothing}
|
|
224
224
|
<li>${this.viewsDropdownTemplate}</li>
|
|
225
225
|
<li>
|
|
226
|
-
${this.getSortDisplayOption(SortField.title, {
|
|
227
|
-
onClick: () => {
|
|
228
|
-
this.dropdownBackdropVisible = false;
|
|
229
|
-
if (this.finalizedSortField !== SortField.title) {
|
|
230
|
-
this.alphaSelectorVisible = 'title';
|
|
231
|
-
this.selectedCreatorFilter = null;
|
|
232
|
-
this.setSelectedSort(SortField.title);
|
|
233
|
-
this.emitCreatorLetterChangedEvent();
|
|
234
|
-
}
|
|
235
|
-
},
|
|
226
|
+
${this.getSortDisplayOption(SortField.title, {
|
|
227
|
+
onClick: () => {
|
|
228
|
+
this.dropdownBackdropVisible = false;
|
|
229
|
+
if (this.finalizedSortField !== SortField.title) {
|
|
230
|
+
this.alphaSelectorVisible = 'title';
|
|
231
|
+
this.selectedCreatorFilter = null;
|
|
232
|
+
this.setSelectedSort(SortField.title);
|
|
233
|
+
this.emitCreatorLetterChangedEvent();
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
236
|
})}
|
|
237
237
|
</li>
|
|
238
238
|
<li>${this.dateDropdownTemplate}</li>
|
|
239
239
|
<li>
|
|
240
|
-
${this.getSortDisplayOption(SortField.creator, {
|
|
241
|
-
onClick: () => {
|
|
242
|
-
this.dropdownBackdropVisible = false;
|
|
243
|
-
if (this.finalizedSortField !== SortField.creator) {
|
|
244
|
-
this.alphaSelectorVisible = 'creator';
|
|
245
|
-
this.selectedTitleFilter = null;
|
|
246
|
-
this.setSelectedSort(SortField.creator);
|
|
247
|
-
this.emitTitleLetterChangedEvent();
|
|
248
|
-
}
|
|
249
|
-
},
|
|
240
|
+
${this.getSortDisplayOption(SortField.creator, {
|
|
241
|
+
onClick: () => {
|
|
242
|
+
this.dropdownBackdropVisible = false;
|
|
243
|
+
if (this.finalizedSortField !== SortField.creator) {
|
|
244
|
+
this.alphaSelectorVisible = 'creator';
|
|
245
|
+
this.selectedTitleFilter = null;
|
|
246
|
+
this.setSelectedSort(SortField.creator);
|
|
247
|
+
this.emitTitleLetterChangedEvent();
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
250
|
})}
|
|
251
251
|
</li>
|
|
252
252
|
</ul>
|
|
253
253
|
</div>
|
|
254
|
-
`;
|
|
255
|
-
}
|
|
256
|
-
/** The template to render all the sort options in mobile view */
|
|
257
|
-
get mobileSortSelectorTemplate() {
|
|
258
|
-
const displayedOptions = Object.values(SORT_OPTIONS)
|
|
259
|
-
.filter(opt => opt.shownInSortBar)
|
|
260
|
-
.filter(opt => this.showRelevance || opt.field !== SortField.relevance)
|
|
261
|
-
.filter(opt => this.showDateFavorited || opt.field !== SortField.datefavorited);
|
|
254
|
+
`;
|
|
255
|
+
}
|
|
256
|
+
/** The template to render all the sort options in mobile view */
|
|
257
|
+
get mobileSortSelectorTemplate() {
|
|
258
|
+
const displayedOptions = Object.values(SORT_OPTIONS)
|
|
259
|
+
.filter(opt => opt.shownInSortBar)
|
|
260
|
+
.filter(opt => this.showRelevance || opt.field !== SortField.relevance)
|
|
261
|
+
.filter(opt => this.showDateFavorited || opt.field !== SortField.datefavorited);
|
|
262
262
|
return html `
|
|
263
263
|
<div
|
|
264
264
|
id="mobile-sort-container"
|
|
265
265
|
class=${this.mobileSelectorVisible ? 'visible' : 'hidden'}
|
|
266
266
|
>
|
|
267
|
-
${this.getSortDropdown({
|
|
268
|
-
displayName: html `${SORT_OPTIONS[this.finalizedSortField]
|
|
269
|
-
.displayName}`,
|
|
270
|
-
id: 'mobile-dropdown',
|
|
271
|
-
selected: true,
|
|
272
|
-
dropdownOptions: displayedOptions.map(opt => this.getDropdownOption(opt.field)),
|
|
273
|
-
selectedOption: this.finalizedSortField,
|
|
274
|
-
onOptionSelected: this.mobileSortChanged,
|
|
275
|
-
onDropdownClick: () => {
|
|
276
|
-
this.dropdownBackdropVisible = this.mobileDropdown.open;
|
|
277
|
-
this.mobileDropdown.classList.toggle('open', this.mobileDropdown.open);
|
|
278
|
-
},
|
|
267
|
+
${this.getSortDropdown({
|
|
268
|
+
displayName: html `${SORT_OPTIONS[this.finalizedSortField]
|
|
269
|
+
.displayName}`,
|
|
270
|
+
id: 'mobile-dropdown',
|
|
271
|
+
selected: true,
|
|
272
|
+
dropdownOptions: displayedOptions.map(opt => this.getDropdownOption(opt.field)),
|
|
273
|
+
selectedOption: this.finalizedSortField,
|
|
274
|
+
onOptionSelected: this.mobileSortChanged,
|
|
275
|
+
onDropdownClick: () => {
|
|
276
|
+
this.dropdownBackdropVisible = this.mobileDropdown.open;
|
|
277
|
+
this.mobileDropdown.classList.toggle('open', this.mobileDropdown.open);
|
|
278
|
+
},
|
|
279
279
|
})}
|
|
280
280
|
</div>
|
|
281
|
-
`;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* This generates each of the non-dropdown sort option links.
|
|
285
|
-
*
|
|
286
|
-
* It manages the display value and the selected state of the option.
|
|
287
|
-
*
|
|
288
|
-
* @param sortField
|
|
289
|
-
* @param options {
|
|
290
|
-
* onClick?: (e: Event) => void; If this is provided, it will also be called when the option is clicked.
|
|
291
|
-
* displayName?: TemplateResult; The name to display for the option. Defaults to the sortField display name.
|
|
292
|
-
* selected?: boolean; true if the option is selected. Defaults to the selectedSort === sortField.
|
|
293
|
-
* }
|
|
294
|
-
* @returns
|
|
295
|
-
*/
|
|
296
|
-
getSortDisplayOption(sortField, options) {
|
|
297
|
-
var _a, _b;
|
|
298
|
-
const isSelected = (_a = options === null || options === void 0 ? void 0 : options.selected) !== null && _a !== void 0 ? _a : this.finalizedSortField === sortField;
|
|
299
|
-
const displayName = (_b = options === null || options === void 0 ? void 0 : options.displayName) !== null && _b !== void 0 ? _b : SORT_OPTIONS[sortField].displayName;
|
|
281
|
+
`;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* This generates each of the non-dropdown sort option links.
|
|
285
|
+
*
|
|
286
|
+
* It manages the display value and the selected state of the option.
|
|
287
|
+
*
|
|
288
|
+
* @param sortField
|
|
289
|
+
* @param options {
|
|
290
|
+
* onClick?: (e: Event) => void; If this is provided, it will also be called when the option is clicked.
|
|
291
|
+
* displayName?: TemplateResult; The name to display for the option. Defaults to the sortField display name.
|
|
292
|
+
* selected?: boolean; true if the option is selected. Defaults to the selectedSort === sortField.
|
|
293
|
+
* }
|
|
294
|
+
* @returns
|
|
295
|
+
*/
|
|
296
|
+
getSortDisplayOption(sortField, options) {
|
|
297
|
+
var _a, _b;
|
|
298
|
+
const isSelected = (_a = options === null || options === void 0 ? void 0 : options.selected) !== null && _a !== void 0 ? _a : this.finalizedSortField === sortField;
|
|
299
|
+
const displayName = (_b = options === null || options === void 0 ? void 0 : options.displayName) !== null && _b !== void 0 ? _b : SORT_OPTIONS[sortField].displayName;
|
|
300
300
|
return html `
|
|
301
301
|
<button
|
|
302
302
|
class=${isSelected ? 'selected' : nothing}
|
|
303
303
|
data-title="${displayName}"
|
|
304
|
-
@click=${(e) => {
|
|
305
|
-
var _a;
|
|
306
|
-
e.preventDefault();
|
|
307
|
-
(_a = options === null || options === void 0 ? void 0 : options.onClick) === null || _a === void 0 ? void 0 : _a.call(options, e);
|
|
304
|
+
@click=${(e) => {
|
|
305
|
+
var _a;
|
|
306
|
+
e.preventDefault();
|
|
307
|
+
(_a = options === null || options === void 0 ? void 0 : options.onClick) === null || _a === void 0 ? void 0 : _a.call(options, e);
|
|
308
308
|
}}
|
|
309
309
|
>
|
|
310
310
|
${displayName}
|
|
311
311
|
</button>
|
|
312
|
-
`;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Generates a dropdown component containing multiple grouped sort options.
|
|
316
|
-
*
|
|
317
|
-
* @param options.displayName The name to use for the dropdown's visible label
|
|
318
|
-
* @param options.id The id to apply to the dropdown element
|
|
319
|
-
* @param options.dropdownOptions An array of option objects used to populate the dropdown
|
|
320
|
-
* @param options.selectedOption The id of the option that should be initially selected
|
|
321
|
-
* @param options.selected A boolean indicating whether this dropdown should use its
|
|
322
|
-
* selected appearance
|
|
323
|
-
* @param options.onOptionSelected A handler for optionSelected events coming from the dropdown
|
|
324
|
-
* @param options.onDropdownClick A handler for click events on the dropdown
|
|
325
|
-
* @param options.onLabelInteraction A handler for click events and Enter/Space keydown events
|
|
326
|
-
* on the dropdown's label
|
|
327
|
-
*/
|
|
328
|
-
getSortDropdown(options) {
|
|
329
|
-
var _a, _b, _c, _d, _e;
|
|
312
|
+
`;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Generates a dropdown component containing multiple grouped sort options.
|
|
316
|
+
*
|
|
317
|
+
* @param options.displayName The name to use for the dropdown's visible label
|
|
318
|
+
* @param options.id The id to apply to the dropdown element
|
|
319
|
+
* @param options.dropdownOptions An array of option objects used to populate the dropdown
|
|
320
|
+
* @param options.selectedOption The id of the option that should be initially selected
|
|
321
|
+
* @param options.selected A boolean indicating whether this dropdown should use its
|
|
322
|
+
* selected appearance
|
|
323
|
+
* @param options.onOptionSelected A handler for optionSelected events coming from the dropdown
|
|
324
|
+
* @param options.onDropdownClick A handler for click events on the dropdown
|
|
325
|
+
* @param options.onLabelInteraction A handler for click events and Enter/Space keydown events
|
|
326
|
+
* on the dropdown's label
|
|
327
|
+
*/
|
|
328
|
+
getSortDropdown(options) {
|
|
329
|
+
var _a, _b, _c, _d, _e;
|
|
330
330
|
return html `
|
|
331
331
|
<ia-dropdown
|
|
332
332
|
id=${(_a = options.id) !== null && _a !== void 0 ? _a : nothing}
|
|
@@ -345,121 +345,121 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
345
345
|
slot="dropdown-label"
|
|
346
346
|
data-title="${options.displayName.values}"
|
|
347
347
|
@click=${(_e = options.onLabelInteraction) !== null && _e !== void 0 ? _e : nothing}
|
|
348
|
-
@keydown=${options.onLabelInteraction
|
|
349
|
-
? (e) => {
|
|
350
|
-
var _a;
|
|
351
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
352
|
-
(_a = options.onLabelInteraction) === null || _a === void 0 ? void 0 : _a.call(options, e);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
348
|
+
@keydown=${options.onLabelInteraction
|
|
349
|
+
? (e) => {
|
|
350
|
+
var _a;
|
|
351
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
352
|
+
(_a = options.onLabelInteraction) === null || _a === void 0 ? void 0 : _a.call(options, e);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
355
|
: nothing}
|
|
356
356
|
>
|
|
357
357
|
${options.displayName}
|
|
358
358
|
</span>
|
|
359
359
|
</ia-dropdown>
|
|
360
|
-
`;
|
|
361
|
-
}
|
|
362
|
-
/** Generates a single dropdown option object for the given sort field */
|
|
363
|
-
getDropdownOption(sortField) {
|
|
364
|
-
return {
|
|
365
|
-
id: sortField,
|
|
366
|
-
selectedHandler: () => {
|
|
367
|
-
this.selectDropdownSortField(sortField);
|
|
368
|
-
},
|
|
360
|
+
`;
|
|
361
|
+
}
|
|
362
|
+
/** Generates a single dropdown option object for the given sort field */
|
|
363
|
+
getDropdownOption(sortField) {
|
|
364
|
+
return {
|
|
365
|
+
id: sortField,
|
|
366
|
+
selectedHandler: () => {
|
|
367
|
+
this.selectDropdownSortField(sortField);
|
|
368
|
+
},
|
|
369
369
|
label: html `
|
|
370
370
|
<span class="dropdown-option-label">
|
|
371
371
|
${SORT_OPTIONS[sortField].displayName}
|
|
372
372
|
</span>
|
|
373
|
-
`,
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
/** Handler for when any sort dropdown option is selected */
|
|
377
|
-
dropdownOptionSelected(e) {
|
|
378
|
-
this.dropdownBackdropVisible = false;
|
|
379
|
-
this.clearAlphaBarFilters();
|
|
380
|
-
this.setSelectedSort(e.detail.option.id);
|
|
381
|
-
}
|
|
382
|
-
/** The template to render for the views dropdown */
|
|
383
|
-
get viewsDropdownTemplate() {
|
|
384
|
-
return this.getSortDropdown({
|
|
385
|
-
displayName: html `${this.viewSortField}`,
|
|
386
|
-
id: 'views-dropdown',
|
|
387
|
-
selected: this.viewOptionSelected,
|
|
388
|
-
dropdownOptions: [
|
|
389
|
-
this.getDropdownOption(SortField.weeklyview),
|
|
390
|
-
this.getDropdownOption(SortField.alltimeview),
|
|
391
|
-
],
|
|
392
|
-
selectedOption: this.viewOptionSelected ? this.selectedSort : '',
|
|
393
|
-
onOptionSelected: this.dropdownOptionSelected,
|
|
394
|
-
onDropdownClick: () => {
|
|
395
|
-
this.dateDropdown.open = false;
|
|
396
|
-
this.dropdownBackdropVisible = this.viewsDropdown.open;
|
|
397
|
-
this.viewsDropdown.classList.toggle('open', this.viewsDropdown.open);
|
|
398
|
-
},
|
|
399
|
-
onLabelInteraction: (e) => {
|
|
400
|
-
if (!this.viewsDropdown.open && !this.viewOptionSelected) {
|
|
401
|
-
e.stopPropagation();
|
|
402
|
-
this.clearAlphaBarFilters();
|
|
403
|
-
this.setSelectedSort(SortField.weeklyview);
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
/** The template to render for the date dropdown */
|
|
409
|
-
get dateDropdownTemplate() {
|
|
410
|
-
return this.getSortDropdown({
|
|
411
|
-
displayName: html `${this.dateSortField}`,
|
|
412
|
-
id: 'date-dropdown',
|
|
413
|
-
selected: this.dateOptionSelected,
|
|
414
|
-
dropdownOptions: [
|
|
415
|
-
...(this.showDateFavorited
|
|
416
|
-
? [this.getDropdownOption(SortField.datefavorited)]
|
|
417
|
-
: []),
|
|
418
|
-
this.getDropdownOption(SortField.date),
|
|
419
|
-
this.getDropdownOption(SortField.datearchived),
|
|
420
|
-
this.getDropdownOption(SortField.datereviewed),
|
|
421
|
-
this.getDropdownOption(SortField.dateadded),
|
|
422
|
-
],
|
|
423
|
-
selectedOption: this.dateOptionSelected ? this.selectedSort : '',
|
|
424
|
-
onOptionSelected: this.dropdownOptionSelected,
|
|
425
|
-
onDropdownClick: () => {
|
|
426
|
-
this.viewsDropdown.open = false;
|
|
427
|
-
this.dropdownBackdropVisible = this.dateDropdown.open;
|
|
428
|
-
this.dateDropdown.classList.toggle('open', this.dateDropdown.open);
|
|
429
|
-
},
|
|
430
|
-
onLabelInteraction: (e) => {
|
|
431
|
-
if (!this.dateDropdown.open && !this.dateOptionSelected) {
|
|
432
|
-
e.stopPropagation();
|
|
433
|
-
this.clearAlphaBarFilters();
|
|
434
|
-
this.setSelectedSort(this.defaultDateSortField);
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
/** Handler for when a new mobile sort dropdown option is selected */
|
|
440
|
-
mobileSortChanged(e) {
|
|
441
|
-
this.dropdownBackdropVisible = false;
|
|
442
|
-
const sortField = e.detail.option.id;
|
|
443
|
-
this.setSelectedSort(sortField);
|
|
444
|
-
this.alphaSelectorVisible = null;
|
|
445
|
-
if (sortField !== 'title' && this.selectedTitleFilter) {
|
|
446
|
-
this.selectedTitleFilter = null;
|
|
447
|
-
this.emitTitleLetterChangedEvent();
|
|
448
|
-
}
|
|
449
|
-
if (sortField !== 'creator' && this.selectedCreatorFilter) {
|
|
450
|
-
this.selectedCreatorFilter = null;
|
|
451
|
-
this.emitCreatorLetterChangedEvent();
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
/** Template for rendering the three display mode options */
|
|
455
|
-
get displayOptionTemplate() {
|
|
373
|
+
`,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/** Handler for when any sort dropdown option is selected */
|
|
377
|
+
dropdownOptionSelected(e) {
|
|
378
|
+
this.dropdownBackdropVisible = false;
|
|
379
|
+
this.clearAlphaBarFilters();
|
|
380
|
+
this.setSelectedSort(e.detail.option.id);
|
|
381
|
+
}
|
|
382
|
+
/** The template to render for the views dropdown */
|
|
383
|
+
get viewsDropdownTemplate() {
|
|
384
|
+
return this.getSortDropdown({
|
|
385
|
+
displayName: html `${this.viewSortField}`,
|
|
386
|
+
id: 'views-dropdown',
|
|
387
|
+
selected: this.viewOptionSelected,
|
|
388
|
+
dropdownOptions: [
|
|
389
|
+
this.getDropdownOption(SortField.weeklyview),
|
|
390
|
+
this.getDropdownOption(SortField.alltimeview),
|
|
391
|
+
],
|
|
392
|
+
selectedOption: this.viewOptionSelected ? this.selectedSort : '',
|
|
393
|
+
onOptionSelected: this.dropdownOptionSelected,
|
|
394
|
+
onDropdownClick: () => {
|
|
395
|
+
this.dateDropdown.open = false;
|
|
396
|
+
this.dropdownBackdropVisible = this.viewsDropdown.open;
|
|
397
|
+
this.viewsDropdown.classList.toggle('open', this.viewsDropdown.open);
|
|
398
|
+
},
|
|
399
|
+
onLabelInteraction: (e) => {
|
|
400
|
+
if (!this.viewsDropdown.open && !this.viewOptionSelected) {
|
|
401
|
+
e.stopPropagation();
|
|
402
|
+
this.clearAlphaBarFilters();
|
|
403
|
+
this.setSelectedSort(SortField.weeklyview);
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
/** The template to render for the date dropdown */
|
|
409
|
+
get dateDropdownTemplate() {
|
|
410
|
+
return this.getSortDropdown({
|
|
411
|
+
displayName: html `${this.dateSortField}`,
|
|
412
|
+
id: 'date-dropdown',
|
|
413
|
+
selected: this.dateOptionSelected,
|
|
414
|
+
dropdownOptions: [
|
|
415
|
+
...(this.showDateFavorited
|
|
416
|
+
? [this.getDropdownOption(SortField.datefavorited)]
|
|
417
|
+
: []),
|
|
418
|
+
this.getDropdownOption(SortField.date),
|
|
419
|
+
this.getDropdownOption(SortField.datearchived),
|
|
420
|
+
this.getDropdownOption(SortField.datereviewed),
|
|
421
|
+
this.getDropdownOption(SortField.dateadded),
|
|
422
|
+
],
|
|
423
|
+
selectedOption: this.dateOptionSelected ? this.selectedSort : '',
|
|
424
|
+
onOptionSelected: this.dropdownOptionSelected,
|
|
425
|
+
onDropdownClick: () => {
|
|
426
|
+
this.viewsDropdown.open = false;
|
|
427
|
+
this.dropdownBackdropVisible = this.dateDropdown.open;
|
|
428
|
+
this.dateDropdown.classList.toggle('open', this.dateDropdown.open);
|
|
429
|
+
},
|
|
430
|
+
onLabelInteraction: (e) => {
|
|
431
|
+
if (!this.dateDropdown.open && !this.dateOptionSelected) {
|
|
432
|
+
e.stopPropagation();
|
|
433
|
+
this.clearAlphaBarFilters();
|
|
434
|
+
this.setSelectedSort(this.defaultDateSortField);
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/** Handler for when a new mobile sort dropdown option is selected */
|
|
440
|
+
mobileSortChanged(e) {
|
|
441
|
+
this.dropdownBackdropVisible = false;
|
|
442
|
+
const sortField = e.detail.option.id;
|
|
443
|
+
this.setSelectedSort(sortField);
|
|
444
|
+
this.alphaSelectorVisible = null;
|
|
445
|
+
if (sortField !== 'title' && this.selectedTitleFilter) {
|
|
446
|
+
this.selectedTitleFilter = null;
|
|
447
|
+
this.emitTitleLetterChangedEvent();
|
|
448
|
+
}
|
|
449
|
+
if (sortField !== 'creator' && this.selectedCreatorFilter) {
|
|
450
|
+
this.selectedCreatorFilter = null;
|
|
451
|
+
this.emitCreatorLetterChangedEvent();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
/** Template for rendering the three display mode options */
|
|
455
|
+
get displayOptionTemplate() {
|
|
456
456
|
return html `
|
|
457
457
|
<ul>
|
|
458
458
|
<li>
|
|
459
459
|
<button
|
|
460
460
|
id="grid-button"
|
|
461
|
-
@click=${() => {
|
|
462
|
-
this.displayMode = 'grid';
|
|
461
|
+
@click=${() => {
|
|
462
|
+
this.displayMode = 'grid';
|
|
463
463
|
}}
|
|
464
464
|
class=${this.displayMode === 'grid' ? 'active' : ''}
|
|
465
465
|
title="Tile view"
|
|
@@ -470,8 +470,8 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
470
470
|
<li>
|
|
471
471
|
<button
|
|
472
472
|
id="list-detail-button"
|
|
473
|
-
@click=${() => {
|
|
474
|
-
this.displayMode = 'list-detail';
|
|
473
|
+
@click=${() => {
|
|
474
|
+
this.displayMode = 'list-detail';
|
|
475
475
|
}}
|
|
476
476
|
class=${this.displayMode === 'list-detail' ? 'active' : ''}
|
|
477
477
|
title="List view"
|
|
@@ -482,8 +482,8 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
482
482
|
<li>
|
|
483
483
|
<button
|
|
484
484
|
id="list-compact-button"
|
|
485
|
-
@click=${() => {
|
|
486
|
-
this.displayMode = 'list-compact';
|
|
485
|
+
@click=${() => {
|
|
486
|
+
this.displayMode = 'list-compact';
|
|
487
487
|
}}
|
|
488
488
|
class=${this.displayMode === 'list-compact' ? 'active' : ''}
|
|
489
489
|
title="Compact list view"
|
|
@@ -492,223 +492,223 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
492
492
|
</button>
|
|
493
493
|
</li>
|
|
494
494
|
</ul>
|
|
495
|
-
`;
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Template for rendering the transparent backdrop to capture clicks outside the
|
|
499
|
-
* dropdown menu while it is open.
|
|
500
|
-
*/
|
|
501
|
-
get dropdownBackdrop() {
|
|
495
|
+
`;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Template for rendering the transparent backdrop to capture clicks outside the
|
|
499
|
+
* dropdown menu while it is open.
|
|
500
|
+
*/
|
|
501
|
+
get dropdownBackdrop() {
|
|
502
502
|
return html `
|
|
503
503
|
<div
|
|
504
504
|
id="sort-selector-backdrop"
|
|
505
505
|
@keyup=${this.closeDropdowns}
|
|
506
506
|
@click=${this.closeDropdowns}
|
|
507
507
|
></div>
|
|
508
|
-
`;
|
|
509
|
-
}
|
|
510
|
-
/** Closes all of the sorting dropdown components' menus */
|
|
511
|
-
closeDropdowns() {
|
|
512
|
-
this.dropdownBackdropVisible = false;
|
|
513
|
-
const allDropdowns = [
|
|
514
|
-
this.viewsDropdown,
|
|
515
|
-
this.dateDropdown,
|
|
516
|
-
this.mobileDropdown,
|
|
517
|
-
];
|
|
518
|
-
for (const dropdown of allDropdowns) {
|
|
519
|
-
dropdown.open = false;
|
|
520
|
-
dropdown.classList.remove('open');
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
selectDropdownSortField(sortField) {
|
|
524
|
-
// When a dropdown sort option is selected, we additionally need to clear the backdrop
|
|
525
|
-
this.dropdownBackdropVisible = false;
|
|
526
|
-
this.setSelectedSort(sortField);
|
|
527
|
-
}
|
|
528
|
-
clearAlphaBarFilters() {
|
|
529
|
-
this.alphaSelectorVisible = null;
|
|
530
|
-
this.selectedTitleFilter = null;
|
|
531
|
-
this.selectedCreatorFilter = null;
|
|
532
|
-
this.emitTitleLetterChangedEvent();
|
|
533
|
-
this.emitCreatorLetterChangedEvent();
|
|
534
|
-
}
|
|
535
|
-
setSortDirection(sortDirection) {
|
|
536
|
-
this.sortDirection = sortDirection;
|
|
537
|
-
this.emitSortChangedEvent();
|
|
538
|
-
}
|
|
539
|
-
/** Toggles the current sort direction between 'asc' and 'desc' */
|
|
540
|
-
toggleSortDirection() {
|
|
541
|
-
this.setSortDirection(this.finalizedSortDirection === 'desc' ? 'asc' : 'desc');
|
|
542
|
-
}
|
|
543
|
-
handleSortDirectionClicked() {
|
|
544
|
-
if (!this.sortDirection &&
|
|
545
|
-
this.defaultSortField &&
|
|
546
|
-
this.defaultSortDirection) {
|
|
547
|
-
// When the sort direction is merely defaulted (not set by the user), clicking
|
|
548
|
-
// the toggled button should "promote" the default sort to an explicitly-set one
|
|
549
|
-
// and then toggle it as usual.
|
|
550
|
-
this.selectedSort = this.defaultSortField;
|
|
551
|
-
this.sortDirection = this.defaultSortDirection;
|
|
552
|
-
}
|
|
553
|
-
this.toggleSortDirection();
|
|
554
|
-
}
|
|
555
|
-
setSelectedSort(sort) {
|
|
556
|
-
this.selectedSort = sort;
|
|
557
|
-
// Apply this field's default sort direction
|
|
558
|
-
const sortOption = SORT_OPTIONS[sort];
|
|
559
|
-
this.sortDirection = sortOption.defaultSortDirection;
|
|
560
|
-
this.emitSortChangedEvent();
|
|
561
|
-
}
|
|
562
|
-
/** The current sort field, or the default one if no explicit sort is set */
|
|
563
|
-
get finalizedSortField() {
|
|
564
|
-
return this.selectedSort === SortField.default
|
|
565
|
-
? this.defaultSortField
|
|
566
|
-
: this.selectedSort;
|
|
567
|
-
}
|
|
568
|
-
/** The current sort direction, or the default one if no explicit direction is set */
|
|
569
|
-
get finalizedSortDirection() {
|
|
570
|
-
return this.sortDirection === null
|
|
571
|
-
? this.defaultSortDirection
|
|
572
|
-
: this.sortDirection;
|
|
573
|
-
}
|
|
574
|
-
/** Whether the sort direction button should be enabled for the current sort */
|
|
575
|
-
get canChangeSortDirection() {
|
|
576
|
-
return SORT_OPTIONS[this.finalizedSortField].canSetDirection;
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* There are four date sort options.
|
|
580
|
-
*
|
|
581
|
-
* This checks to see if the current sort is one of them.
|
|
582
|
-
*
|
|
583
|
-
* @readonly
|
|
584
|
-
* @private
|
|
585
|
-
* @type {boolean}
|
|
586
|
-
* @memberof SortFilterBar
|
|
587
|
-
*/
|
|
588
|
-
get dateOptionSelected() {
|
|
589
|
-
const dateSortFields = [
|
|
590
|
-
SortField.datefavorited,
|
|
591
|
-
SortField.datearchived,
|
|
592
|
-
SortField.date,
|
|
593
|
-
SortField.datereviewed,
|
|
594
|
-
SortField.dateadded,
|
|
595
|
-
];
|
|
596
|
-
return dateSortFields.includes(this.finalizedSortField);
|
|
597
|
-
}
|
|
598
|
-
/**
|
|
599
|
-
* There are two view sort options.
|
|
600
|
-
*
|
|
601
|
-
* This checks to see if the current sort is one of them.
|
|
602
|
-
*
|
|
603
|
-
* @readonly
|
|
604
|
-
* @private
|
|
605
|
-
* @type {boolean}
|
|
606
|
-
* @memberof SortFilterBar
|
|
607
|
-
*/
|
|
608
|
-
get viewOptionSelected() {
|
|
609
|
-
const viewSortFields = [
|
|
610
|
-
SortField.alltimeview,
|
|
611
|
-
SortField.weeklyview,
|
|
612
|
-
];
|
|
613
|
-
return viewSortFields.includes(this.finalizedSortField);
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* The default field for the date sort dropdown.
|
|
617
|
-
* This is Date Favorited when that option is available, or Date Published otherwise.
|
|
618
|
-
*/
|
|
619
|
-
get defaultDateSortField() {
|
|
620
|
-
return this.showDateFavorited ? SortField.datefavorited : SortField.date;
|
|
621
|
-
}
|
|
622
|
-
/**
|
|
623
|
-
* The display name of the current date field
|
|
624
|
-
*
|
|
625
|
-
* @readonly
|
|
626
|
-
* @private
|
|
627
|
-
* @type {string}
|
|
628
|
-
* @memberof SortFilterBar
|
|
629
|
-
*/
|
|
630
|
-
get dateSortField() {
|
|
631
|
-
var _a;
|
|
632
|
-
const defaultDateSort = SORT_OPTIONS[this.defaultDateSortField];
|
|
633
|
-
const currentDateSort = this.dateOptionSelected
|
|
634
|
-
? (_a = SORT_OPTIONS[this.finalizedSortField]) !== null && _a !== void 0 ? _a : defaultDateSort
|
|
635
|
-
: defaultDateSort;
|
|
636
|
-
return currentDateSort.displayName;
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* The display name of the current view field
|
|
640
|
-
*
|
|
641
|
-
* @readonly
|
|
642
|
-
* @private
|
|
643
|
-
* @type {string}
|
|
644
|
-
* @memberof SortFilterBar
|
|
645
|
-
*/
|
|
646
|
-
get viewSortField() {
|
|
647
|
-
var _a;
|
|
648
|
-
const defaultViewSort = SORT_OPTIONS[SortField.weeklyview];
|
|
649
|
-
const currentViewSort = this.viewOptionSelected
|
|
650
|
-
? (_a = SORT_OPTIONS[this.finalizedSortField]) !== null && _a !== void 0 ? _a : defaultViewSort
|
|
651
|
-
: defaultViewSort;
|
|
652
|
-
return currentViewSort.displayName;
|
|
653
|
-
}
|
|
654
|
-
get titleSelectorBar() {
|
|
655
|
-
var _a;
|
|
508
|
+
`;
|
|
509
|
+
}
|
|
510
|
+
/** Closes all of the sorting dropdown components' menus */
|
|
511
|
+
closeDropdowns() {
|
|
512
|
+
this.dropdownBackdropVisible = false;
|
|
513
|
+
const allDropdowns = [
|
|
514
|
+
this.viewsDropdown,
|
|
515
|
+
this.dateDropdown,
|
|
516
|
+
this.mobileDropdown,
|
|
517
|
+
];
|
|
518
|
+
for (const dropdown of allDropdowns) {
|
|
519
|
+
dropdown.open = false;
|
|
520
|
+
dropdown.classList.remove('open');
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
selectDropdownSortField(sortField) {
|
|
524
|
+
// When a dropdown sort option is selected, we additionally need to clear the backdrop
|
|
525
|
+
this.dropdownBackdropVisible = false;
|
|
526
|
+
this.setSelectedSort(sortField);
|
|
527
|
+
}
|
|
528
|
+
clearAlphaBarFilters() {
|
|
529
|
+
this.alphaSelectorVisible = null;
|
|
530
|
+
this.selectedTitleFilter = null;
|
|
531
|
+
this.selectedCreatorFilter = null;
|
|
532
|
+
this.emitTitleLetterChangedEvent();
|
|
533
|
+
this.emitCreatorLetterChangedEvent();
|
|
534
|
+
}
|
|
535
|
+
setSortDirection(sortDirection) {
|
|
536
|
+
this.sortDirection = sortDirection;
|
|
537
|
+
this.emitSortChangedEvent();
|
|
538
|
+
}
|
|
539
|
+
/** Toggles the current sort direction between 'asc' and 'desc' */
|
|
540
|
+
toggleSortDirection() {
|
|
541
|
+
this.setSortDirection(this.finalizedSortDirection === 'desc' ? 'asc' : 'desc');
|
|
542
|
+
}
|
|
543
|
+
handleSortDirectionClicked() {
|
|
544
|
+
if (!this.sortDirection &&
|
|
545
|
+
this.defaultSortField &&
|
|
546
|
+
this.defaultSortDirection) {
|
|
547
|
+
// When the sort direction is merely defaulted (not set by the user), clicking
|
|
548
|
+
// the toggled button should "promote" the default sort to an explicitly-set one
|
|
549
|
+
// and then toggle it as usual.
|
|
550
|
+
this.selectedSort = this.defaultSortField;
|
|
551
|
+
this.sortDirection = this.defaultSortDirection;
|
|
552
|
+
}
|
|
553
|
+
this.toggleSortDirection();
|
|
554
|
+
}
|
|
555
|
+
setSelectedSort(sort) {
|
|
556
|
+
this.selectedSort = sort;
|
|
557
|
+
// Apply this field's default sort direction
|
|
558
|
+
const sortOption = SORT_OPTIONS[sort];
|
|
559
|
+
this.sortDirection = sortOption.defaultSortDirection;
|
|
560
|
+
this.emitSortChangedEvent();
|
|
561
|
+
}
|
|
562
|
+
/** The current sort field, or the default one if no explicit sort is set */
|
|
563
|
+
get finalizedSortField() {
|
|
564
|
+
return this.selectedSort === SortField.default
|
|
565
|
+
? this.defaultSortField
|
|
566
|
+
: this.selectedSort;
|
|
567
|
+
}
|
|
568
|
+
/** The current sort direction, or the default one if no explicit direction is set */
|
|
569
|
+
get finalizedSortDirection() {
|
|
570
|
+
return this.sortDirection === null
|
|
571
|
+
? this.defaultSortDirection
|
|
572
|
+
: this.sortDirection;
|
|
573
|
+
}
|
|
574
|
+
/** Whether the sort direction button should be enabled for the current sort */
|
|
575
|
+
get canChangeSortDirection() {
|
|
576
|
+
return SORT_OPTIONS[this.finalizedSortField].canSetDirection;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* There are four date sort options.
|
|
580
|
+
*
|
|
581
|
+
* This checks to see if the current sort is one of them.
|
|
582
|
+
*
|
|
583
|
+
* @readonly
|
|
584
|
+
* @private
|
|
585
|
+
* @type {boolean}
|
|
586
|
+
* @memberof SortFilterBar
|
|
587
|
+
*/
|
|
588
|
+
get dateOptionSelected() {
|
|
589
|
+
const dateSortFields = [
|
|
590
|
+
SortField.datefavorited,
|
|
591
|
+
SortField.datearchived,
|
|
592
|
+
SortField.date,
|
|
593
|
+
SortField.datereviewed,
|
|
594
|
+
SortField.dateadded,
|
|
595
|
+
];
|
|
596
|
+
return dateSortFields.includes(this.finalizedSortField);
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* There are two view sort options.
|
|
600
|
+
*
|
|
601
|
+
* This checks to see if the current sort is one of them.
|
|
602
|
+
*
|
|
603
|
+
* @readonly
|
|
604
|
+
* @private
|
|
605
|
+
* @type {boolean}
|
|
606
|
+
* @memberof SortFilterBar
|
|
607
|
+
*/
|
|
608
|
+
get viewOptionSelected() {
|
|
609
|
+
const viewSortFields = [
|
|
610
|
+
SortField.alltimeview,
|
|
611
|
+
SortField.weeklyview,
|
|
612
|
+
];
|
|
613
|
+
return viewSortFields.includes(this.finalizedSortField);
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* The default field for the date sort dropdown.
|
|
617
|
+
* This is Date Favorited when that option is available, or Date Published otherwise.
|
|
618
|
+
*/
|
|
619
|
+
get defaultDateSortField() {
|
|
620
|
+
return this.showDateFavorited ? SortField.datefavorited : SortField.date;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* The display name of the current date field
|
|
624
|
+
*
|
|
625
|
+
* @readonly
|
|
626
|
+
* @private
|
|
627
|
+
* @type {string}
|
|
628
|
+
* @memberof SortFilterBar
|
|
629
|
+
*/
|
|
630
|
+
get dateSortField() {
|
|
631
|
+
var _a;
|
|
632
|
+
const defaultDateSort = SORT_OPTIONS[this.defaultDateSortField];
|
|
633
|
+
const currentDateSort = this.dateOptionSelected
|
|
634
|
+
? (_a = SORT_OPTIONS[this.finalizedSortField]) !== null && _a !== void 0 ? _a : defaultDateSort
|
|
635
|
+
: defaultDateSort;
|
|
636
|
+
return currentDateSort.displayName;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* The display name of the current view field
|
|
640
|
+
*
|
|
641
|
+
* @readonly
|
|
642
|
+
* @private
|
|
643
|
+
* @type {string}
|
|
644
|
+
* @memberof SortFilterBar
|
|
645
|
+
*/
|
|
646
|
+
get viewSortField() {
|
|
647
|
+
var _a;
|
|
648
|
+
const defaultViewSort = SORT_OPTIONS[SortField.weeklyview];
|
|
649
|
+
const currentViewSort = this.viewOptionSelected
|
|
650
|
+
? (_a = SORT_OPTIONS[this.finalizedSortField]) !== null && _a !== void 0 ? _a : defaultViewSort
|
|
651
|
+
: defaultViewSort;
|
|
652
|
+
return currentViewSort.displayName;
|
|
653
|
+
}
|
|
654
|
+
get titleSelectorBar() {
|
|
655
|
+
var _a;
|
|
656
656
|
return html ` <alpha-bar
|
|
657
657
|
.selectedLetter=${this.selectedTitleFilter}
|
|
658
658
|
.letterCounts=${(_a = this.prefixFilterCountMap) === null || _a === void 0 ? void 0 : _a.title}
|
|
659
659
|
ariaLandmarkLabel="Filter by title letter"
|
|
660
660
|
@letterChanged=${this.titleLetterChanged}
|
|
661
|
-
></alpha-bar>`;
|
|
662
|
-
}
|
|
663
|
-
get creatorSelectorBar() {
|
|
664
|
-
var _a;
|
|
661
|
+
></alpha-bar>`;
|
|
662
|
+
}
|
|
663
|
+
get creatorSelectorBar() {
|
|
664
|
+
var _a;
|
|
665
665
|
return html ` <alpha-bar
|
|
666
666
|
.selectedLetter=${this.selectedCreatorFilter}
|
|
667
667
|
.letterCounts=${(_a = this.prefixFilterCountMap) === null || _a === void 0 ? void 0 : _a.creator}
|
|
668
668
|
ariaLandmarkLabel="Filter by creator letter"
|
|
669
669
|
@letterChanged=${this.creatorLetterChanged}
|
|
670
|
-
></alpha-bar>`;
|
|
671
|
-
}
|
|
672
|
-
titleLetterChanged(e) {
|
|
673
|
-
var _a;
|
|
674
|
-
this.selectedTitleFilter = (_a = e.detail.selectedLetter) !== null && _a !== void 0 ? _a : null;
|
|
675
|
-
this.emitTitleLetterChangedEvent();
|
|
676
|
-
}
|
|
677
|
-
creatorLetterChanged(e) {
|
|
678
|
-
var _a;
|
|
679
|
-
this.selectedCreatorFilter = (_a = e.detail.selectedLetter) !== null && _a !== void 0 ? _a : null;
|
|
680
|
-
this.emitCreatorLetterChangedEvent();
|
|
681
|
-
}
|
|
682
|
-
emitTitleLetterChangedEvent() {
|
|
683
|
-
const event = new CustomEvent('titleLetterChanged', {
|
|
684
|
-
detail: { selectedLetter: this.selectedTitleFilter },
|
|
685
|
-
});
|
|
686
|
-
this.dispatchEvent(event);
|
|
687
|
-
}
|
|
688
|
-
emitCreatorLetterChangedEvent() {
|
|
689
|
-
const event = new CustomEvent('creatorLetterChanged', {
|
|
690
|
-
detail: { selectedLetter: this.selectedCreatorFilter },
|
|
691
|
-
});
|
|
692
|
-
this.dispatchEvent(event);
|
|
693
|
-
}
|
|
694
|
-
displayModeChanged() {
|
|
695
|
-
const event = new CustomEvent('displayModeChanged', {
|
|
696
|
-
detail: { displayMode: this.displayMode },
|
|
697
|
-
});
|
|
698
|
-
this.dispatchEvent(event);
|
|
699
|
-
}
|
|
700
|
-
emitSortChangedEvent() {
|
|
701
|
-
const event = new CustomEvent('sortChanged', {
|
|
702
|
-
detail: {
|
|
703
|
-
selectedSort: this.selectedSort,
|
|
704
|
-
sortDirection: this.sortDirection,
|
|
705
|
-
},
|
|
706
|
-
});
|
|
707
|
-
this.dispatchEvent(event);
|
|
708
|
-
}
|
|
709
|
-
static get styles() {
|
|
710
|
-
return [
|
|
711
|
-
srOnlyStyle,
|
|
670
|
+
></alpha-bar>`;
|
|
671
|
+
}
|
|
672
|
+
titleLetterChanged(e) {
|
|
673
|
+
var _a;
|
|
674
|
+
this.selectedTitleFilter = (_a = e.detail.selectedLetter) !== null && _a !== void 0 ? _a : null;
|
|
675
|
+
this.emitTitleLetterChangedEvent();
|
|
676
|
+
}
|
|
677
|
+
creatorLetterChanged(e) {
|
|
678
|
+
var _a;
|
|
679
|
+
this.selectedCreatorFilter = (_a = e.detail.selectedLetter) !== null && _a !== void 0 ? _a : null;
|
|
680
|
+
this.emitCreatorLetterChangedEvent();
|
|
681
|
+
}
|
|
682
|
+
emitTitleLetterChangedEvent() {
|
|
683
|
+
const event = new CustomEvent('titleLetterChanged', {
|
|
684
|
+
detail: { selectedLetter: this.selectedTitleFilter },
|
|
685
|
+
});
|
|
686
|
+
this.dispatchEvent(event);
|
|
687
|
+
}
|
|
688
|
+
emitCreatorLetterChangedEvent() {
|
|
689
|
+
const event = new CustomEvent('creatorLetterChanged', {
|
|
690
|
+
detail: { selectedLetter: this.selectedCreatorFilter },
|
|
691
|
+
});
|
|
692
|
+
this.dispatchEvent(event);
|
|
693
|
+
}
|
|
694
|
+
displayModeChanged() {
|
|
695
|
+
const event = new CustomEvent('displayModeChanged', {
|
|
696
|
+
detail: { displayMode: this.displayMode },
|
|
697
|
+
});
|
|
698
|
+
this.dispatchEvent(event);
|
|
699
|
+
}
|
|
700
|
+
emitSortChangedEvent() {
|
|
701
|
+
const event = new CustomEvent('sortChanged', {
|
|
702
|
+
detail: {
|
|
703
|
+
selectedSort: this.selectedSort,
|
|
704
|
+
sortDirection: this.sortDirection,
|
|
705
|
+
},
|
|
706
|
+
});
|
|
707
|
+
this.dispatchEvent(event);
|
|
708
|
+
}
|
|
709
|
+
static get styles() {
|
|
710
|
+
return [
|
|
711
|
+
srOnlyStyle,
|
|
712
712
|
css `
|
|
713
713
|
#container {
|
|
714
714
|
position: relative;
|
|
@@ -932,72 +932,72 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
932
932
|
white-space: nowrap;
|
|
933
933
|
user-select: none;
|
|
934
934
|
}
|
|
935
|
-
`,
|
|
936
|
-
];
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
__decorate([
|
|
940
|
-
property({ type: String })
|
|
941
|
-
], SortFilterBar.prototype, "displayMode", void 0);
|
|
942
|
-
__decorate([
|
|
943
|
-
property({ type: String })
|
|
944
|
-
], SortFilterBar.prototype, "defaultSortDirection", void 0);
|
|
945
|
-
__decorate([
|
|
946
|
-
property({ type: String })
|
|
947
|
-
], SortFilterBar.prototype, "defaultSortField", void 0);
|
|
948
|
-
__decorate([
|
|
949
|
-
property({ type: String })
|
|
950
|
-
], SortFilterBar.prototype, "sortDirection", void 0);
|
|
951
|
-
__decorate([
|
|
952
|
-
property({ type: String })
|
|
953
|
-
], SortFilterBar.prototype, "selectedSort", void 0);
|
|
954
|
-
__decorate([
|
|
955
|
-
property({ type: String })
|
|
956
|
-
], SortFilterBar.prototype, "selectedTitleFilter", void 0);
|
|
957
|
-
__decorate([
|
|
958
|
-
property({ type: String })
|
|
959
|
-
], SortFilterBar.prototype, "selectedCreatorFilter", void 0);
|
|
960
|
-
__decorate([
|
|
961
|
-
property({ type: Boolean })
|
|
962
|
-
], SortFilterBar.prototype, "showRelevance", void 0);
|
|
963
|
-
__decorate([
|
|
964
|
-
property({ type: Boolean })
|
|
965
|
-
], SortFilterBar.prototype, "showDateFavorited", void 0);
|
|
966
|
-
__decorate([
|
|
967
|
-
property({ type: Object })
|
|
968
|
-
], SortFilterBar.prototype, "prefixFilterCountMap", void 0);
|
|
969
|
-
__decorate([
|
|
970
|
-
property({ type: Object })
|
|
971
|
-
], SortFilterBar.prototype, "resizeObserver", void 0);
|
|
972
|
-
__decorate([
|
|
973
|
-
state()
|
|
974
|
-
], SortFilterBar.prototype, "alphaSelectorVisible", void 0);
|
|
975
|
-
__decorate([
|
|
976
|
-
state()
|
|
977
|
-
], SortFilterBar.prototype, "dropdownBackdropVisible", void 0);
|
|
978
|
-
__decorate([
|
|
979
|
-
state()
|
|
980
|
-
], SortFilterBar.prototype, "desktopSortContainerWidth", void 0);
|
|
981
|
-
__decorate([
|
|
982
|
-
state()
|
|
983
|
-
], SortFilterBar.prototype, "selectorBarContainerWidth", void 0);
|
|
984
|
-
__decorate([
|
|
985
|
-
query('#desktop-sort-container')
|
|
986
|
-
], SortFilterBar.prototype, "desktopSortContainer", void 0);
|
|
987
|
-
__decorate([
|
|
988
|
-
query('#sort-selector-container')
|
|
989
|
-
], SortFilterBar.prototype, "sortSelectorContainer", void 0);
|
|
990
|
-
__decorate([
|
|
991
|
-
query('#views-dropdown')
|
|
992
|
-
], SortFilterBar.prototype, "viewsDropdown", void 0);
|
|
993
|
-
__decorate([
|
|
994
|
-
query('#date-dropdown')
|
|
995
|
-
], SortFilterBar.prototype, "dateDropdown", void 0);
|
|
996
|
-
__decorate([
|
|
997
|
-
query('#mobile-dropdown')
|
|
998
|
-
], SortFilterBar.prototype, "mobileDropdown", void 0);
|
|
999
|
-
SortFilterBar = __decorate([
|
|
1000
|
-
customElement('sort-filter-bar')
|
|
1001
|
-
], SortFilterBar);
|
|
1002
|
-
export { SortFilterBar };
|
|
935
|
+
`,
|
|
936
|
+
];
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
__decorate([
|
|
940
|
+
property({ type: String })
|
|
941
|
+
], SortFilterBar.prototype, "displayMode", void 0);
|
|
942
|
+
__decorate([
|
|
943
|
+
property({ type: String })
|
|
944
|
+
], SortFilterBar.prototype, "defaultSortDirection", void 0);
|
|
945
|
+
__decorate([
|
|
946
|
+
property({ type: String })
|
|
947
|
+
], SortFilterBar.prototype, "defaultSortField", void 0);
|
|
948
|
+
__decorate([
|
|
949
|
+
property({ type: String })
|
|
950
|
+
], SortFilterBar.prototype, "sortDirection", void 0);
|
|
951
|
+
__decorate([
|
|
952
|
+
property({ type: String })
|
|
953
|
+
], SortFilterBar.prototype, "selectedSort", void 0);
|
|
954
|
+
__decorate([
|
|
955
|
+
property({ type: String })
|
|
956
|
+
], SortFilterBar.prototype, "selectedTitleFilter", void 0);
|
|
957
|
+
__decorate([
|
|
958
|
+
property({ type: String })
|
|
959
|
+
], SortFilterBar.prototype, "selectedCreatorFilter", void 0);
|
|
960
|
+
__decorate([
|
|
961
|
+
property({ type: Boolean })
|
|
962
|
+
], SortFilterBar.prototype, "showRelevance", void 0);
|
|
963
|
+
__decorate([
|
|
964
|
+
property({ type: Boolean })
|
|
965
|
+
], SortFilterBar.prototype, "showDateFavorited", void 0);
|
|
966
|
+
__decorate([
|
|
967
|
+
property({ type: Object })
|
|
968
|
+
], SortFilterBar.prototype, "prefixFilterCountMap", void 0);
|
|
969
|
+
__decorate([
|
|
970
|
+
property({ type: Object })
|
|
971
|
+
], SortFilterBar.prototype, "resizeObserver", void 0);
|
|
972
|
+
__decorate([
|
|
973
|
+
state()
|
|
974
|
+
], SortFilterBar.prototype, "alphaSelectorVisible", void 0);
|
|
975
|
+
__decorate([
|
|
976
|
+
state()
|
|
977
|
+
], SortFilterBar.prototype, "dropdownBackdropVisible", void 0);
|
|
978
|
+
__decorate([
|
|
979
|
+
state()
|
|
980
|
+
], SortFilterBar.prototype, "desktopSortContainerWidth", void 0);
|
|
981
|
+
__decorate([
|
|
982
|
+
state()
|
|
983
|
+
], SortFilterBar.prototype, "selectorBarContainerWidth", void 0);
|
|
984
|
+
__decorate([
|
|
985
|
+
query('#desktop-sort-container')
|
|
986
|
+
], SortFilterBar.prototype, "desktopSortContainer", void 0);
|
|
987
|
+
__decorate([
|
|
988
|
+
query('#sort-selector-container')
|
|
989
|
+
], SortFilterBar.prototype, "sortSelectorContainer", void 0);
|
|
990
|
+
__decorate([
|
|
991
|
+
query('#views-dropdown')
|
|
992
|
+
], SortFilterBar.prototype, "viewsDropdown", void 0);
|
|
993
|
+
__decorate([
|
|
994
|
+
query('#date-dropdown')
|
|
995
|
+
], SortFilterBar.prototype, "dateDropdown", void 0);
|
|
996
|
+
__decorate([
|
|
997
|
+
query('#mobile-dropdown')
|
|
998
|
+
], SortFilterBar.prototype, "mobileDropdown", void 0);
|
|
999
|
+
SortFilterBar = __decorate([
|
|
1000
|
+
customElement('sort-filter-bar')
|
|
1001
|
+
], SortFilterBar);
|
|
1002
|
+
export { SortFilterBar };
|
|
1003
1003
|
//# sourceMappingURL=sort-filter-bar.js.map
|