@internetarchive/collection-browser 2.12.3-alpha-webdev7452.0 → 2.13.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.
Files changed (36) hide show
  1. package/dist/src/data-source/collection-browser-data-source.d.ts +6 -0
  2. package/dist/src/data-source/collection-browser-data-source.js +19 -3
  3. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  4. package/dist/src/mediatype/mediatype-config.js +2 -2
  5. package/dist/src/mediatype/mediatype-config.js.map +1 -1
  6. package/dist/src/models.d.ts +16 -3
  7. package/dist/src/models.js +24 -16
  8. package/dist/src/models.js.map +1 -1
  9. package/dist/src/tiles/grid/item-tile.d.ts +1 -1
  10. package/dist/src/tiles/grid/item-tile.js +7 -5
  11. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  12. package/dist/src/tiles/grid/tile-stats.js +3 -3
  13. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  14. package/dist/src/tiles/list/tile-list-compact.d.ts +1 -1
  15. package/dist/src/tiles/list/tile-list-compact.js +4 -4
  16. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  17. package/dist/src/tiles/list/tile-list.d.ts +1 -1
  18. package/dist/src/tiles/list/tile-list.js +3 -3
  19. package/dist/src/tiles/list/tile-list.js.map +1 -1
  20. package/dist/src/tiles/{mediatype-icon.d.ts → tile-mediatype-icon.d.ts} +1 -1
  21. package/dist/src/tiles/{mediatype-icon.js → tile-mediatype-icon.js} +14 -14
  22. package/dist/src/tiles/tile-mediatype-icon.js.map +1 -0
  23. package/dist/test/tiles/mediatype-icon.test.d.ts +1 -1
  24. package/dist/test/tiles/mediatype-icon.test.js +14 -14
  25. package/dist/test/tiles/mediatype-icon.test.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/data-source/collection-browser-data-source.ts +16 -3
  28. package/src/mediatype/mediatype-config.ts +2 -2
  29. package/src/models.ts +35 -5
  30. package/src/tiles/grid/item-tile.ts +4 -2
  31. package/src/tiles/grid/tile-stats.ts +3 -3
  32. package/src/tiles/list/tile-list-compact.ts +4 -4
  33. package/src/tiles/list/tile-list.ts +3 -3
  34. package/src/tiles/{mediatype-icon.ts → tile-mediatype-icon.ts} +6 -6
  35. package/test/tiles/mediatype-icon.test.ts +23 -23
  36. package/dist/src/tiles/mediatype-icon.js.map +0 -1
@@ -19,7 +19,7 @@ import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
19
19
  import '../image-block';
20
20
  import '../review-block';
21
21
  import '../text-snippet-block';
22
- import '../mediatype-icon';
22
+ import '../tile-mediatype-icon';
23
23
 
24
24
  @customElement('tile-list')
25
25
  export class TileList extends BaseTileComponent {
@@ -126,12 +126,12 @@ export class TileList extends BaseTileComponent {
126
126
  private get iconRightTemplate() {
127
127
  return html`
128
128
  <a id="icon-right" href=${this.mediatypeURL}>
129
- <mediatype-icon
129
+ <tile-mediatype-icon
130
130
  .mediatype=${this.model?.mediatype}
131
131
  .collections=${this.model?.collections}
132
132
  ?isTvSearchResult=${this.model?.isTvSearchResult}
133
133
  >
134
- </mediatype-icon>
134
+ </tile-mediatype-icon>
135
135
  </a>
136
136
  `;
137
137
  }
@@ -8,11 +8,11 @@ import {
8
8
 
9
9
  const TV_COMMERCIAL_COLLECTION = 'tv_ads';
10
10
  const TV_FACT_CHECK_COLLECTION = 'factchecked';
11
- const TV_TOP_LEVEL_COLLECTIONS = new Set(['tvnews', 'tvarchive']);
12
- const RADIO_TOP_LEVEL_COLLECTIONS = new Set(['radio', 'radioprogram']);
11
+ const TV_COLLECTIONS = new Set(['tvnews', 'tvarchive', 'television']);
12
+ const RADIO_COLLECTIONS = new Set(['radio', 'radioprogram']);
13
13
 
14
- @customElement('mediatype-icon')
15
- export class MediatypeIcon extends LitElement {
14
+ @customElement('tile-mediatype-icon')
15
+ export class TileMediatypeIcon extends LitElement {
16
16
  @property({ type: String }) mediatype?: MediatypeConfigKey;
17
17
 
18
18
  @property({ type: Array }) collections?: string[];
@@ -52,7 +52,7 @@ export class MediatypeIcon extends LitElement {
52
52
  private get isTvItem(): boolean {
53
53
  return (
54
54
  this.mediatype === 'movies' &&
55
- !!this.collections?.some(id => TV_TOP_LEVEL_COLLECTIONS.has(id))
55
+ !!this.collections?.some(id => TV_COLLECTIONS.has(id))
56
56
  );
57
57
  }
58
58
 
@@ -62,7 +62,7 @@ export class MediatypeIcon extends LitElement {
62
62
  private get isRadioItem(): boolean {
63
63
  return (
64
64
  this.mediatype === 'audio' &&
65
- !!this.collections?.some(id => RADIO_TOP_LEVEL_COLLECTIONS.has(id))
65
+ !!this.collections?.some(id => RADIO_COLLECTIONS.has(id))
66
66
  );
67
67
  }
68
68
 
@@ -1,13 +1,13 @@
1
1
  import { expect, fixture } from '@open-wc/testing';
2
2
  import { html } from 'lit';
3
- import type { MediatypeIcon } from '../../src/tiles/mediatype-icon';
3
+ import type { TileMediatypeIcon } from '../../src/tiles/tile-mediatype-icon';
4
4
 
5
- import '../../src/tiles/mediatype-icon';
5
+ import '../../src/tiles/tile-mediatype-icon';
6
6
 
7
7
  describe('Mediatype Icon', () => {
8
8
  it('renders component', async () => {
9
- const el = await fixture<MediatypeIcon>(html`
10
- <mediatype-icon mediatype="texts"></mediatype-icon>
9
+ const el = await fixture<TileMediatypeIcon>(html`
10
+ <tile-mediatype-icon mediatype="texts"></tile-mediatype-icon>
11
11
  `);
12
12
 
13
13
  const iconDiv = el.shadowRoot?.querySelector('#icon');
@@ -15,8 +15,8 @@ describe('Mediatype Icon', () => {
15
15
  });
16
16
 
17
17
  it('renders basic mediatype correctly', async () => {
18
- const el = await fixture<MediatypeIcon>(html`
19
- <mediatype-icon mediatype="movies"></mediatype-icon>
18
+ const el = await fixture<TileMediatypeIcon>(html`
19
+ <tile-mediatype-icon mediatype="movies"></tile-mediatype-icon>
20
20
  `);
21
21
 
22
22
  const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
@@ -26,11 +26,11 @@ describe('Mediatype Icon', () => {
26
26
  });
27
27
 
28
28
  it('renders TV mediatype', async () => {
29
- const el = await fixture<MediatypeIcon>(html`
30
- <mediatype-icon
29
+ const el = await fixture<TileMediatypeIcon>(html`
30
+ <tile-mediatype-icon
31
31
  mediatype="movies"
32
32
  .collections=${['tvnews']}
33
- ></mediatype-icon>
33
+ ></tile-mediatype-icon>
34
34
  `);
35
35
 
36
36
  const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
@@ -38,11 +38,11 @@ describe('Mediatype Icon', () => {
38
38
  });
39
39
 
40
40
  it('renders TV Commercial mediatype', async () => {
41
- const el = await fixture<MediatypeIcon>(html`
42
- <mediatype-icon
41
+ const el = await fixture<TileMediatypeIcon>(html`
42
+ <tile-mediatype-icon
43
43
  mediatype="movies"
44
44
  .collections=${['tvnews', 'tv_ads']}
45
- ></mediatype-icon>
45
+ ></tile-mediatype-icon>
46
46
  `);
47
47
 
48
48
  const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
@@ -50,12 +50,12 @@ describe('Mediatype Icon', () => {
50
50
  });
51
51
 
52
52
  it('renders TV Fact Check mediatype for search results', async () => {
53
- const el = await fixture<MediatypeIcon>(html`
54
- <mediatype-icon
53
+ const el = await fixture<TileMediatypeIcon>(html`
54
+ <tile-mediatype-icon
55
55
  isTvSearchResult
56
56
  mediatype="movies"
57
57
  .collections=${['tvnews', 'factchecked']}
58
- ></mediatype-icon>
58
+ ></tile-mediatype-icon>
59
59
  `);
60
60
 
61
61
  const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
@@ -63,11 +63,11 @@ describe('Mediatype Icon', () => {
63
63
  });
64
64
 
65
65
  it('does not use TV Fact Check mediatype for non-search results', async () => {
66
- const el = await fixture<MediatypeIcon>(html`
67
- <mediatype-icon
66
+ const el = await fixture<TileMediatypeIcon>(html`
67
+ <tile-mediatype-icon
68
68
  mediatype="movies"
69
69
  .collections=${['tvnews', 'factchecked']}
70
- ></mediatype-icon>
70
+ ></tile-mediatype-icon>
71
71
  `);
72
72
 
73
73
  const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
@@ -75,11 +75,11 @@ describe('Mediatype Icon', () => {
75
75
  });
76
76
 
77
77
  it('renders radio mediatype', async () => {
78
- const el = await fixture<MediatypeIcon>(html`
79
- <mediatype-icon
78
+ const el = await fixture<TileMediatypeIcon>(html`
79
+ <tile-mediatype-icon
80
80
  mediatype="audio"
81
81
  .collections=${['radio']}
82
- ></mediatype-icon>
82
+ ></tile-mediatype-icon>
83
83
  `);
84
84
 
85
85
  const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
@@ -87,8 +87,8 @@ describe('Mediatype Icon', () => {
87
87
  });
88
88
 
89
89
  it('renders no icon if mediatype is unrecognized', async () => {
90
- const el = await fixture<MediatypeIcon>(html`
91
- <mediatype-icon mediatype="foobar"></mediatype-icon>
90
+ const el = await fixture<TileMediatypeIcon>(html`
91
+ <tile-mediatype-icon mediatype="foobar"></tile-mediatype-icon>
92
92
  `);
93
93
 
94
94
  const iconDiv = el.shadowRoot?.querySelector('#icon');
@@ -1 +0,0 @@
1
- {"version":3,"file":"mediatype-icon.js","sourceRoot":"","sources":["../../../src/tiles/mediatype-icon.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EACL,eAAe,GAEhB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,wBAAwB,GAAG,QAAQ,CAAC;AAC1C,MAAM,wBAAwB,GAAG,aAAa,CAAC;AAC/C,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAClE,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;AAGhE,IAAM,aAAa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AC,gBAAgB,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAA,EAAE,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAA;;;iBAGE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;iBACzC,MAAM,CAAC,IAAI;kCACM,MAAM,CAAC,KAAK;;UAEpC,MAAM,CAAC,IAAI;iCACY,MAAM,CAAC,IAAI;;KAEvC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA0BT,CAAC;IACJ,CAAC;CACF,CAAA;AArG6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAgC;AAEhC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAwB;AAErB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAA0B;AAEzB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAAkB;AAPnC,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAsGzB","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport {\n mediatypeConfig,\n MediatypeConfigKey,\n} from '../mediatype/mediatype-config';\n\nconst TV_COMMERCIAL_COLLECTION = 'tv_ads';\nconst TV_FACT_CHECK_COLLECTION = 'factchecked';\nconst TV_TOP_LEVEL_COLLECTIONS = new Set(['tvnews', 'tvarchive']);\nconst RADIO_TOP_LEVEL_COLLECTIONS = new Set(['radio', 'radioprogram']);\n\n@customElement('mediatype-icon')\nexport class MediatypeIcon extends LitElement {\n @property({ type: String }) mediatype?: MediatypeConfigKey;\n\n @property({ type: Array }) collections?: string[];\n\n @property({ type: Boolean }) isTvSearchResult = false;\n\n @property({ type: Boolean }) showText = false;\n\n /**\n * Returns the appropriate mediatype config key for the current mediatype/collections.\n */\n private get displayMediatype(): MediatypeConfigKey {\n if (this.isTvItem) return this.tvDisplayMediatype;\n if (this.isRadioItem) return 'radio';\n return this.mediatype ?? 'none';\n }\n\n /**\n * Returns the appropriate TV mediatype, depending on the current collections.\n */\n private get tvDisplayMediatype(): MediatypeConfigKey {\n if (this.collections?.includes(TV_COMMERCIAL_COLLECTION)) {\n return 'tvCommercial';\n } else if (\n this.isTvSearchResult &&\n this.collections?.includes(TV_FACT_CHECK_COLLECTION)\n ) {\n return 'tvFactCheck';\n }\n\n return 'tv';\n }\n\n /**\n * Whether this represents a TV item\n */\n private get isTvItem(): boolean {\n return (\n this.mediatype === 'movies' &&\n !!this.collections?.some(id => TV_TOP_LEVEL_COLLECTIONS.has(id))\n );\n }\n\n /**\n * Whether this represents a radio item\n */\n private get isRadioItem(): boolean {\n return (\n this.mediatype === 'audio' &&\n !!this.collections?.some(id => RADIO_TOP_LEVEL_COLLECTIONS.has(id))\n );\n }\n\n render() {\n const config = mediatypeConfig[this.displayMediatype];\n if (!config) {\n return html``;\n }\n\n return html`\n <div\n id=\"icon\"\n class=\"${this.showText ? 'show-text' : 'hide-text'}\"\n title=\"${config.text}\"\n style=\"--iconFillColor: ${config.color}\"\n >\n ${config.icon}\n <p class=\"status-text\">${config.text}</p>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n #icon {\n height: var(--iconHeight, 25px);\n }\n\n .status-text {\n font-size: 14px;\n color: #2c2c2c;\n margin: auto;\n display: block;\n text-align: var(--iconTextAlign, center);\n }\n\n #icon.hide-text p {\n display: none;\n }\n\n svg {\n height: var(--iconHeight, 10px);\n width: var(--iconWidth, 10px);\n pointer-events: none;\n }\n\n .fill-color {\n fill: var(--iconFillColor, '#000000');\n }\n `;\n }\n}\n"]}