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