@internetarchive/collection-browser 2.22.1-alpha-webdev7818.4 → 2.22.1-alpha-webdev7761.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/collection-browser.d.ts +12 -5
- package/dist/src/collection-browser.js +785 -691
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets.js +12 -0
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source-interface.d.ts +10 -1
- package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +19 -1
- package/dist/src/data-source/collection-browser-data-source.js +36 -18
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +1 -2
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/data-source/models.d.ts +11 -0
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/models.d.ts +2 -6
- package/dist/src/models.js +8 -12
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +1 -2
- package/dist/src/restoration-state-handler.js +3 -9
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.js +45 -45
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +97 -97
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +289 -289
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/test/collection-browser.test.js +206 -196
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +5 -37
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +2848 -2755
- package/src/collection-facets.ts +11 -0
- package/src/data-source/collection-browser-data-source-interface.ts +345 -333
- package/src/data-source/collection-browser-data-source.ts +1432 -1390
- package/src/data-source/collection-browser-query-state.ts +1 -7
- package/src/data-source/models.ts +13 -0
- package/src/models.ts +10 -14
- package/src/restoration-state-handler.ts +9 -11
- package/src/tiles/list/tile-list-compact-header.ts +86 -86
- package/src/tiles/list/tile-list-compact.ts +236 -236
- package/src/tiles/list/tile-list.ts +688 -688
- package/test/collection-browser.test.ts +2369 -2359
- package/test/restoration-state-handler.test.ts +12 -42
|
@@ -6,12 +6,7 @@ import type {
|
|
|
6
6
|
SortDirection,
|
|
7
7
|
SortParam,
|
|
8
8
|
} from '@internetarchive/search-service';
|
|
9
|
-
import type {
|
|
10
|
-
FacetLoadStrategy,
|
|
11
|
-
SelectedFacets,
|
|
12
|
-
SortField,
|
|
13
|
-
TvClipFilterType,
|
|
14
|
-
} from '../models';
|
|
9
|
+
import type { FacetLoadStrategy, SelectedFacets, SortField } from '../models';
|
|
15
10
|
import type { CollectionBrowserDataSourceInterface } from './collection-browser-data-source-interface';
|
|
16
11
|
|
|
17
12
|
/**
|
|
@@ -29,7 +24,6 @@ export interface CollectionBrowserQueryState {
|
|
|
29
24
|
maxSelectedDate?: string;
|
|
30
25
|
selectedTitleFilter: string | null;
|
|
31
26
|
selectedCreatorFilter: string | null;
|
|
32
|
-
tvClipFilter?: TvClipFilterType;
|
|
33
27
|
selectedSort?: SortField;
|
|
34
28
|
sortDirection: SortDirection | null;
|
|
35
29
|
}
|
|
@@ -13,6 +13,19 @@ export type CollectionTitles = Map<string, string>;
|
|
|
13
13
|
*/
|
|
14
14
|
export type TVChannelAliases = Map<string, string>;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* A Map from program (show) names to a mapping of all the channels that run them.
|
|
18
|
+
*/
|
|
19
|
+
export type TVProgramChannels = Map<string, Record<string, number>>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Object storing the different TV channel mappings used by the data source.
|
|
23
|
+
*/
|
|
24
|
+
export type TVChannelMaps = {
|
|
25
|
+
channelToNetwork?: TVChannelAliases;
|
|
26
|
+
programToChannels?: TVProgramChannels;
|
|
27
|
+
};
|
|
28
|
+
|
|
16
29
|
/**
|
|
17
30
|
* The subset of search service params that uniquely specify the type of results
|
|
18
31
|
* that are sought by an instance of collection browser.
|
package/src/models.ts
CHANGED
|
@@ -636,6 +636,7 @@ export type FacetOption =
|
|
|
636
636
|
| 'collection'
|
|
637
637
|
| 'year'
|
|
638
638
|
// TV-specific facet options:
|
|
639
|
+
| 'clip_type'
|
|
639
640
|
| 'program'
|
|
640
641
|
| 'person'
|
|
641
642
|
| 'sponsor';
|
|
@@ -693,6 +694,7 @@ export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
|
|
|
693
694
|
creator: {},
|
|
694
695
|
collection: {},
|
|
695
696
|
year: {},
|
|
697
|
+
clip_type: {},
|
|
696
698
|
program: {},
|
|
697
699
|
person: {},
|
|
698
700
|
sponsor: {},
|
|
@@ -701,25 +703,15 @@ export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
|
|
|
701
703
|
/**
|
|
702
704
|
* For TV search results, what types of TV clips to restrict the results to.
|
|
703
705
|
*/
|
|
704
|
-
export type TvClipFilterType = '
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* Map from TV clip filter types to their corresponding URL params
|
|
708
|
-
*/
|
|
709
|
-
export const tvClipFiltersToURLParams: Record<TvClipFilterType, string> = {
|
|
710
|
-
all: '',
|
|
711
|
-
commercials: 'only_commercials',
|
|
712
|
-
factchecks: 'only_factchecks',
|
|
713
|
-
quotes: 'only_quotes',
|
|
714
|
-
};
|
|
706
|
+
export type TvClipFilterType = 'commercial' | 'fact check' | 'quote';
|
|
715
707
|
|
|
716
708
|
/**
|
|
717
709
|
* Map from allowed TV filtering parameters in the URL to their corresponding filter type
|
|
718
710
|
*/
|
|
719
711
|
export const tvClipURLParamsToFilters: Record<string, TvClipFilterType> = {
|
|
720
|
-
only_commercials: '
|
|
721
|
-
only_factchecks: '
|
|
722
|
-
only_quotes: '
|
|
712
|
+
only_commercials: 'commercial',
|
|
713
|
+
only_factchecks: 'fact check',
|
|
714
|
+
only_quotes: 'quote',
|
|
723
715
|
};
|
|
724
716
|
|
|
725
717
|
/**
|
|
@@ -739,6 +731,7 @@ export const defaultFacetDisplayOrder: FacetOption[] = [
|
|
|
739
731
|
* Specialized facet ordering when displaying TV search results
|
|
740
732
|
*/
|
|
741
733
|
export const tvFacetDisplayOrder: FacetOption[] = [
|
|
734
|
+
'clip_type',
|
|
742
735
|
'program',
|
|
743
736
|
'creator',
|
|
744
737
|
'year',
|
|
@@ -760,6 +753,7 @@ export const facetTitles: Record<FacetOption, string> = {
|
|
|
760
753
|
creator: 'Creator',
|
|
761
754
|
collection: 'Collection',
|
|
762
755
|
year: 'Year',
|
|
756
|
+
clip_type: 'Clip Type',
|
|
763
757
|
program: 'Program',
|
|
764
758
|
person: 'Person',
|
|
765
759
|
sponsor: 'Sponsor',
|
|
@@ -776,6 +770,7 @@ export const defaultFacetSort: Record<FacetOption, AggregationSortType> = {
|
|
|
776
770
|
creator: AggregationSortType.COUNT,
|
|
777
771
|
collection: AggregationSortType.COUNT,
|
|
778
772
|
year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default
|
|
773
|
+
clip_type: AggregationSortType.COUNT,
|
|
779
774
|
program: AggregationSortType.COUNT,
|
|
780
775
|
person: AggregationSortType.COUNT,
|
|
781
776
|
sponsor: AggregationSortType.COUNT,
|
|
@@ -793,6 +788,7 @@ export const valueFacetSort: Record<FacetOption, AggregationSortType> = {
|
|
|
793
788
|
creator: AggregationSortType.ALPHABETICAL,
|
|
794
789
|
collection: AggregationSortType.ALPHABETICAL,
|
|
795
790
|
year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)
|
|
791
|
+
clip_type: AggregationSortType.ALPHABETICAL,
|
|
796
792
|
program: AggregationSortType.ALPHABETICAL,
|
|
797
793
|
person: AggregationSortType.ALPHABETICAL,
|
|
798
794
|
sponsor: AggregationSortType.ALPHABETICAL,
|
|
@@ -5,14 +5,12 @@ import {
|
|
|
5
5
|
CollectionBrowserContext,
|
|
6
6
|
CollectionDisplayMode,
|
|
7
7
|
SelectedFacets,
|
|
8
|
-
TvClipFilterType,
|
|
9
8
|
SortField,
|
|
10
9
|
FacetBucket,
|
|
11
10
|
FacetState,
|
|
12
11
|
getDefaultSelectedFacets,
|
|
13
12
|
sortOptionFromAPIString,
|
|
14
13
|
SORT_OPTIONS,
|
|
15
|
-
tvClipFiltersToURLParams,
|
|
16
14
|
tvClipURLParamsToFilters,
|
|
17
15
|
} from './models';
|
|
18
16
|
import { arrayEquals } from './utils/array-equals';
|
|
@@ -31,7 +29,6 @@ export interface RestorationState {
|
|
|
31
29
|
maxSelectedDate?: string;
|
|
32
30
|
selectedTitleFilter?: string;
|
|
33
31
|
selectedCreatorFilter?: string;
|
|
34
|
-
tvClipFilter?: TvClipFilterType;
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
export interface RestorationStatePersistOptions {
|
|
@@ -210,12 +207,6 @@ export class RestorationStateHandler
|
|
|
210
207
|
newParams.append('and[]', state.creatorQuery);
|
|
211
208
|
}
|
|
212
209
|
|
|
213
|
-
// TV clip special filters
|
|
214
|
-
if (state.tvClipFilter) {
|
|
215
|
-
const tvClipParam = tvClipFiltersToURLParams[state.tvClipFilter];
|
|
216
|
-
if (tvClipParam) newParams.append(tvClipParam, '1');
|
|
217
|
-
}
|
|
218
|
-
|
|
219
210
|
// Ensure we aren't pushing consecutive identical states to the history stack.
|
|
220
211
|
// - If the state has changed, we push a new history entry.
|
|
221
212
|
// - If only the page number has changed, we replace the current history entry.
|
|
@@ -412,9 +403,16 @@ export class RestorationStateHandler
|
|
|
412
403
|
}
|
|
413
404
|
|
|
414
405
|
// TV clip special filters (carryovers from legacy page)
|
|
415
|
-
for (const [paramKey,
|
|
406
|
+
for (const [paramKey, facetKey] of Object.entries(
|
|
407
|
+
tvClipURLParamsToFilters,
|
|
408
|
+
)) {
|
|
416
409
|
if (url.searchParams.get(paramKey)) {
|
|
417
|
-
|
|
410
|
+
this.setSelectedFacetState(
|
|
411
|
+
restorationState.selectedFacets,
|
|
412
|
+
'clip_type',
|
|
413
|
+
facetKey,
|
|
414
|
+
'selected',
|
|
415
|
+
);
|
|
418
416
|
break;
|
|
419
417
|
}
|
|
420
418
|
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { css, html } from 'lit';
|
|
2
|
-
import { customElement } from 'lit/decorators.js';
|
|
3
|
-
import { msg } from '@lit/localize';
|
|
4
|
-
import { BaseTileComponent } from '../base-tile-component';
|
|
5
|
-
|
|
6
|
-
@customElement('tile-list-compact-header')
|
|
7
|
-
export class TileListCompactHeader extends BaseTileComponent {
|
|
8
|
-
/*
|
|
9
|
-
* Reactive properties inherited from BaseTileComponent:
|
|
10
|
-
* - model?: TileModel;
|
|
11
|
-
* - currentWidth?: number;
|
|
12
|
-
* - currentHeight?: number;
|
|
13
|
-
* - baseNavigationUrl?: string;
|
|
14
|
-
* - baseImageUrl?: string;
|
|
15
|
-
* - collectionPagePath?: string;
|
|
16
|
-
* - sortParam: SortParam | null = null;
|
|
17
|
-
* - creatorFilter?: string;
|
|
18
|
-
* - mobileBreakpoint?: number;
|
|
19
|
-
* - loggedIn = false;
|
|
20
|
-
* - suppressBlurring = false;
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
render() {
|
|
24
|
-
return html`
|
|
25
|
-
<div id="list-line-header" class="${this.classSize}">
|
|
26
|
-
<div id="thumb"></div>
|
|
27
|
-
<div id="title">${msg('Title')}</div>
|
|
28
|
-
<div id="creator">${msg('Creator')}</div>
|
|
29
|
-
<div id="date">
|
|
30
|
-
${this.displayValueProvider.dateLabel || msg('Published')}
|
|
31
|
-
</div>
|
|
32
|
-
<div id="icon">${msg('Type')}</div>
|
|
33
|
-
<div id="views">${msg('Views')}</div>
|
|
34
|
-
</div>
|
|
35
|
-
`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private get classSize(): string {
|
|
39
|
-
if (
|
|
40
|
-
this.mobileBreakpoint &&
|
|
41
|
-
this.currentWidth &&
|
|
42
|
-
this.currentWidth < this.mobileBreakpoint
|
|
43
|
-
) {
|
|
44
|
-
return 'mobile';
|
|
45
|
-
}
|
|
46
|
-
return 'desktop';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static get styles() {
|
|
50
|
-
return css`
|
|
51
|
-
html {
|
|
52
|
-
font-size: unset;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
div {
|
|
56
|
-
font-size: 14px;
|
|
57
|
-
font-weight: bold;
|
|
58
|
-
line-height: 20px;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.mobile #views {
|
|
62
|
-
display: none;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
#views {
|
|
66
|
-
text-align: right;
|
|
67
|
-
padding-right: 8px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
#list-line-header {
|
|
71
|
-
display: grid;
|
|
72
|
-
column-gap: 10px;
|
|
73
|
-
align-items: flex-end;
|
|
74
|
-
padding-bottom: 2px;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
#list-line-header.mobile {
|
|
78
|
-
grid-template-columns: 36px 3fr 2fr 68px 35px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
#list-line-header.desktop {
|
|
82
|
-
grid-template-columns: 51px 3fr 2fr 95px 30px 60px;
|
|
83
|
-
}
|
|
84
|
-
`;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
import { css, html } from 'lit';
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
import { msg } from '@lit/localize';
|
|
4
|
+
import { BaseTileComponent } from '../base-tile-component';
|
|
5
|
+
|
|
6
|
+
@customElement('tile-list-compact-header')
|
|
7
|
+
export class TileListCompactHeader extends BaseTileComponent {
|
|
8
|
+
/*
|
|
9
|
+
* Reactive properties inherited from BaseTileComponent:
|
|
10
|
+
* - model?: TileModel;
|
|
11
|
+
* - currentWidth?: number;
|
|
12
|
+
* - currentHeight?: number;
|
|
13
|
+
* - baseNavigationUrl?: string;
|
|
14
|
+
* - baseImageUrl?: string;
|
|
15
|
+
* - collectionPagePath?: string;
|
|
16
|
+
* - sortParam: SortParam | null = null;
|
|
17
|
+
* - creatorFilter?: string;
|
|
18
|
+
* - mobileBreakpoint?: number;
|
|
19
|
+
* - loggedIn = false;
|
|
20
|
+
* - suppressBlurring = false;
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
render() {
|
|
24
|
+
return html`
|
|
25
|
+
<div id="list-line-header" class="${this.classSize}">
|
|
26
|
+
<div id="thumb"></div>
|
|
27
|
+
<div id="title">${msg('Title')}</div>
|
|
28
|
+
<div id="creator">${msg('Creator')}</div>
|
|
29
|
+
<div id="date">
|
|
30
|
+
${this.displayValueProvider.dateLabel || msg('Published')}
|
|
31
|
+
</div>
|
|
32
|
+
<div id="icon">${msg('Type')}</div>
|
|
33
|
+
<div id="views">${msg('Views')}</div>
|
|
34
|
+
</div>
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private get classSize(): string {
|
|
39
|
+
if (
|
|
40
|
+
this.mobileBreakpoint &&
|
|
41
|
+
this.currentWidth &&
|
|
42
|
+
this.currentWidth < this.mobileBreakpoint
|
|
43
|
+
) {
|
|
44
|
+
return 'mobile';
|
|
45
|
+
}
|
|
46
|
+
return 'desktop';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static get styles() {
|
|
50
|
+
return css`
|
|
51
|
+
html {
|
|
52
|
+
font-size: unset;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
div {
|
|
56
|
+
font-size: 14px;
|
|
57
|
+
font-weight: bold;
|
|
58
|
+
line-height: 20px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.mobile #views {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#views {
|
|
66
|
+
text-align: right;
|
|
67
|
+
padding-right: 8px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#list-line-header {
|
|
71
|
+
display: grid;
|
|
72
|
+
column-gap: 10px;
|
|
73
|
+
align-items: flex-end;
|
|
74
|
+
padding-bottom: 2px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#list-line-header.mobile {
|
|
78
|
+
grid-template-columns: 36px 3fr 2fr 68px 35px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#list-line-header.desktop {
|
|
82
|
+
grid-template-columns: 51px 3fr 2fr 95px 30px 60px;
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
}
|