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