@internetarchive/collection-browser 1.1.0 → 1.1.1-alpha.2

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 (111) hide show
  1. package/dist/index.d.ts +9 -9
  2. package/dist/index.js +9 -9
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/app-root.js.map +1 -1
  5. package/dist/src/collection-browser.d.ts +35 -4
  6. package/dist/src/collection-browser.js +115 -38
  7. package/dist/src/collection-browser.js.map +1 -1
  8. package/dist/src/collection-facets/facets-template.d.ts +1 -1
  9. package/dist/src/collection-facets/facets-template.js +3 -3
  10. package/dist/src/collection-facets/facets-template.js.map +1 -1
  11. package/dist/src/collection-facets/more-facets-content.d.ts +1 -1
  12. package/dist/src/collection-facets/more-facets-content.js +3 -3
  13. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  14. package/dist/src/collection-facets/more-facets-pagination.js +3 -3
  15. package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
  16. package/dist/src/collection-facets/toggle-switch.js +1 -1
  17. package/dist/src/collection-facets/toggle-switch.js.map +1 -1
  18. package/dist/src/collection-facets.d.ts +2 -2
  19. package/dist/src/collection-facets.js +12 -11
  20. package/dist/src/collection-facets.js.map +1 -1
  21. package/dist/src/empty-placeholder.js +2 -2
  22. package/dist/src/empty-placeholder.js.map +1 -1
  23. package/dist/src/language-code-handler/language-code-handler.js +1 -1
  24. package/dist/src/language-code-handler/language-code-handler.js.map +1 -1
  25. package/dist/src/mediatype/mediatype-config.js +13 -13
  26. package/dist/src/mediatype/mediatype-config.js.map +1 -1
  27. package/dist/src/restoration-state-handler.d.ts +1 -1
  28. package/dist/src/restoration-state-handler.js +18 -2
  29. package/dist/src/restoration-state-handler.js.map +1 -1
  30. package/dist/src/sort-filter-bar/alpha-bar.d.ts +1 -1
  31. package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
  32. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +1 -1
  33. package/dist/src/sort-filter-bar/sort-filter-bar.js +8 -8
  34. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  35. package/dist/src/tiles/grid/account-tile.d.ts +1 -1
  36. package/dist/src/tiles/grid/account-tile.js +1 -1
  37. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  38. package/dist/src/tiles/grid/collection-tile.d.ts +1 -1
  39. package/dist/src/tiles/grid/collection-tile.js +3 -3
  40. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  41. package/dist/src/tiles/grid/item-tile.d.ts +1 -1
  42. package/dist/src/tiles/grid/item-tile.js +3 -3
  43. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  44. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +1 -1
  45. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  46. package/dist/src/tiles/grid/tile-stats.js +6 -6
  47. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  48. package/dist/src/tiles/hover/hover-pane-controller.d.ts +1 -1
  49. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  50. package/dist/src/tiles/hover/tile-hover-pane.d.ts +1 -1
  51. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  52. package/dist/src/tiles/image-block.d.ts +1 -1
  53. package/dist/src/tiles/image-block.js.map +1 -1
  54. package/dist/src/tiles/item-image.d.ts +1 -1
  55. package/dist/src/tiles/item-image.js +1 -1
  56. package/dist/src/tiles/item-image.js.map +1 -1
  57. package/dist/src/tiles/list/tile-list-compact-header.d.ts +1 -1
  58. package/dist/src/tiles/list/tile-list-compact-header.js +1 -1
  59. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  60. package/dist/src/tiles/list/tile-list-compact.d.ts +1 -1
  61. package/dist/src/tiles/list/tile-list-compact.js +4 -4
  62. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  63. package/dist/src/tiles/list/tile-list.d.ts +1 -1
  64. package/dist/src/tiles/list/tile-list.js +6 -6
  65. package/dist/src/tiles/list/tile-list.js.map +1 -1
  66. package/dist/src/tiles/mediatype-icon.js +1 -1
  67. package/dist/src/tiles/mediatype-icon.js.map +1 -1
  68. package/dist/src/tiles/overlay/icon-overlay.js +2 -2
  69. package/dist/src/tiles/overlay/icon-overlay.js.map +1 -1
  70. package/dist/src/tiles/overlay/icon-text-overlay.js +2 -2
  71. package/dist/src/tiles/overlay/icon-text-overlay.js.map +1 -1
  72. package/dist/src/tiles/overlay/text-overlay.js +2 -2
  73. package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
  74. package/dist/src/tiles/tile-dispatcher.d.ts +4 -3
  75. package/dist/src/tiles/tile-dispatcher.js +7 -1
  76. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  77. package/dist/test/restoration-state-handler.test.js +28 -0
  78. package/dist/test/restoration-state-handler.test.js.map +1 -1
  79. package/index.ts +9 -9
  80. package/package.json +14 -13
  81. package/src/app-root.ts +1 -1
  82. package/src/collection-browser.ts +116 -38
  83. package/src/collection-facets/facets-template.ts +3 -3
  84. package/src/collection-facets/more-facets-content.ts +3 -3
  85. package/src/collection-facets/more-facets-pagination.ts +3 -3
  86. package/src/collection-facets/toggle-switch.ts +1 -1
  87. package/src/collection-facets.ts +11 -11
  88. package/src/empty-placeholder.ts +2 -2
  89. package/src/language-code-handler/language-code-handler.ts +1 -1
  90. package/src/mediatype/mediatype-config.ts +13 -13
  91. package/src/restoration-state-handler.ts +19 -2
  92. package/src/sort-filter-bar/alpha-bar.ts +2 -2
  93. package/src/sort-filter-bar/sort-filter-bar.ts +8 -8
  94. package/src/tiles/grid/account-tile.ts +2 -2
  95. package/src/tiles/grid/collection-tile.ts +4 -4
  96. package/src/tiles/grid/item-tile.ts +4 -4
  97. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +1 -1
  98. package/src/tiles/grid/tile-stats.ts +6 -6
  99. package/src/tiles/hover/hover-pane-controller.ts +1 -1
  100. package/src/tiles/hover/tile-hover-pane.ts +1 -1
  101. package/src/tiles/image-block.ts +1 -1
  102. package/src/tiles/item-image.ts +2 -2
  103. package/src/tiles/list/tile-list-compact-header.ts +2 -2
  104. package/src/tiles/list/tile-list-compact.ts +5 -5
  105. package/src/tiles/list/tile-list.ts +6 -6
  106. package/src/tiles/mediatype-icon.ts +1 -1
  107. package/src/tiles/overlay/icon-overlay.ts +2 -2
  108. package/src/tiles/overlay/icon-text-overlay.ts +2 -2
  109. package/src/tiles/overlay/text-overlay.ts +2 -2
  110. package/src/tiles/tile-dispatcher.ts +6 -3
  111. package/test/restoration-state-handler.test.ts +44 -0
@@ -1,8 +1,8 @@
1
1
  import { css, html, LitElement } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
  import type { SortParam } from '@internetarchive/search-service';
4
- import { dateLabel } from './date-label';
5
- import type { TileModel } from '../../models';
4
+ import { dateLabel } from './date-label.js';
5
+ import type { TileModel } from '../../models.js';
6
6
 
7
7
  @customElement('tile-list-compact-header')
8
8
  export class TileListCompactHeader extends LitElement {
@@ -2,12 +2,12 @@ import { css, html, LitElement } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
  import DOMPurify from 'dompurify';
4
4
  import type { SortParam } from '@internetarchive/search-service';
5
- import type { TileModel } from '../../models';
5
+ import type { TileModel } from '../../models.js';
6
6
 
7
- import { formatCount, NumberFormat } from '../../utils/format-count';
8
- import { formatDate, DateFormat } from '../../utils/format-date';
9
- import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
10
- import { accountLabel } from './account-label';
7
+ import { formatCount, NumberFormat } from '../../utils/format-count.js';
8
+ import { formatDate, DateFormat } from '../../utils/format-date.js';
9
+ import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc.js';
10
+ import { accountLabel } from './account-label.js';
11
11
 
12
12
  import '../image-block';
13
13
  import '../mediatype-icon';
@@ -15,13 +15,13 @@ import DOMPurify from 'dompurify';
15
15
 
16
16
  import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
17
17
  import type { SortParam } from '@internetarchive/search-service';
18
- import { suppressedCollections, TileModel } from '../../models';
18
+ import { suppressedCollections, TileModel } from '../../models.js';
19
19
 
20
- import { dateLabel } from './date-label';
21
- import { accountLabel } from './account-label';
22
- import { formatCount, NumberFormat } from '../../utils/format-count';
23
- import { formatDate, DateFormat } from '../../utils/format-date';
24
- import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
20
+ import { dateLabel } from './date-label.js';
21
+ import { accountLabel } from './account-label.js';
22
+ import { formatCount, NumberFormat } from '../../utils/format-count.js';
23
+ import { formatDate, DateFormat } from '../../utils/format-date.js';
24
+ import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc.js';
25
25
 
26
26
  import '../image-block';
27
27
  import '../mediatype-icon';
@@ -1,7 +1,7 @@
1
1
  import { css, CSSResultGroup, html, LitElement } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
 
4
- import { mediatypeConfig } from '../mediatype/mediatype-config';
4
+ import { mediatypeConfig } from '../mediatype/mediatype-config.js';
5
5
 
6
6
  @customElement('mediatype-icon')
7
7
  export class MediatypeIcon extends LitElement {
@@ -1,8 +1,8 @@
1
1
  import { css, CSSResultGroup, html, LitElement } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
 
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
5
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
4
+ import { restrictedIcon } from '../../assets/img/icons/restricted.js';
5
+ import { loginRequiredIcon } from '../../assets/img/icons/login-required.js';
6
6
 
7
7
  @customElement('icon-overlay')
8
8
  export class IconOverlay extends LitElement {
@@ -1,7 +1,7 @@
1
1
  import { css, CSSResultGroup, html, LitElement } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
3
+ import { loginRequiredIcon } from '../../assets/img/icons/login-required.js';
4
+ import { restrictedIcon } from '../../assets/img/icons/restricted.js';
5
5
 
6
6
  @customElement('icon-text-overlay')
7
7
  export class IconTextOverlay extends LitElement {
@@ -1,7 +1,7 @@
1
1
  import { css, CSSResultGroup, html, LitElement } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
3
+ import { loginRequiredIcon } from '../../assets/img/icons/login-required.js';
4
+ import { restrictedIcon } from '../../assets/img/icons/restricted.js';
5
5
 
6
6
  @customElement('text-overlay')
7
7
  export class TextOverlay extends LitElement {
@@ -7,7 +7,7 @@ import type {
7
7
  } from '@internetarchive/shared-resize-observer';
8
8
  import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
9
9
  import type { SortParam } from '@internetarchive/search-service';
10
- import type { TileDisplayMode, TileModel } from '../models';
10
+ import type { TileDisplayMode, TileModel } from '../models.js';
11
11
  import './grid/collection-tile';
12
12
  import './grid/item-tile';
13
13
  import './grid/account-tile';
@@ -15,13 +15,13 @@ import './hover/tile-hover-pane';
15
15
  import './list/tile-list';
16
16
  import './list/tile-list-compact';
17
17
  import './list/tile-list-compact-header';
18
- import type { TileHoverPane } from './hover/tile-hover-pane';
18
+ import type { TileHoverPane } from './hover/tile-hover-pane.js';
19
19
  import {
20
20
  HoverPaneController,
21
21
  HoverPaneControllerInterface,
22
22
  HoverPaneProperties,
23
23
  HoverPaneProviderInterface,
24
- } from './hover/hover-pane-controller';
24
+ } from './hover/hover-pane-controller.js';
25
25
 
26
26
  @customElement('tile-dispatcher')
27
27
  export class TileDispatcher
@@ -56,6 +56,8 @@ export class TileDispatcher
56
56
  /** Whether this tile should include a hover pane at all (for applicable tile modes) */
57
57
  @property({ type: Boolean }) enableHoverPane = false;
58
58
 
59
+ @property({ type: Boolean }) prerender = false;
60
+
59
61
  private hoverPaneController?: HoverPaneControllerInterface;
60
62
 
61
63
  @query('#container')
@@ -158,6 +160,7 @@ export class TileDispatcher
158
160
  }
159
161
 
160
162
  private get isHoverEnabled(): boolean {
163
+ if (this.prerender) return false;
161
164
  return window.matchMedia('(hover: hover)').matches;
162
165
  }
163
166
 
@@ -183,6 +183,32 @@ describe('Restoration state handler', () => {
183
183
  );
184
184
  });
185
185
 
186
+ it('should restore selected facets with numbers in the square brackets', async () => {
187
+ const handler = new RestorationStateHandler({ context: 'search' });
188
+
189
+ const url = new URL(window.location.href);
190
+ url.search = '?and[12]=subject:"foo"';
191
+ window.history.replaceState({ path: url.href }, '', url.href);
192
+
193
+ const restorationState = handler.getRestorationState();
194
+ expect(restorationState.selectedFacets.subject.foo.state).to.equal(
195
+ 'selected'
196
+ );
197
+ });
198
+
199
+ it('should restore negative facets with numbers in the square brackets', async () => {
200
+ const handler = new RestorationStateHandler({ context: 'search' });
201
+
202
+ const url = new URL(window.location.href);
203
+ url.search = '?not[12]=year:2018';
204
+ window.history.replaceState({ path: url.href }, '', url.href);
205
+
206
+ const restorationState = handler.getRestorationState();
207
+ expect(restorationState.selectedFacets.year['2018'].state).to.equal(
208
+ 'hidden'
209
+ );
210
+ });
211
+
186
212
  it('should restore sort from URL (space format)', async () => {
187
213
  const handler = new RestorationStateHandler({ context: 'search' });
188
214
 
@@ -270,4 +296,22 @@ describe('Restoration state handler', () => {
270
296
  handler.persistState({ selectedFacets: getDefaultSelectedFacets() });
271
297
  expect(window.location.search).to.equal('');
272
298
  });
299
+
300
+ it('round trip load/persist should erase numbers in square brackets', async () => {
301
+ const handler = new RestorationStateHandler({ context: 'search' });
302
+
303
+ const url = new URL(window.location.href);
304
+ url.search = '?and[0]=subject:"foo"';
305
+ window.history.replaceState({ path: url.href }, '', url.href);
306
+
307
+ // Load state from the URL and immediately persist it back to the URL
308
+ const restorationState = handler.getRestorationState();
309
+ handler.persistState(restorationState);
310
+
311
+ // Ensure the new URL includes the "normalized" facet parameter and not the numbered one
312
+ expect(decodeURIComponent(window.location.search)).to.include(
313
+ 'and[]=subject:"foo"'
314
+ );
315
+ expect(new URL(window.location.href).searchParams.get('and[0]')).to.be.null;
316
+ });
273
317
  });