@internetarchive/collection-browser 4.4.1 → 4.5.1-alpha-webdev8221.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 (85) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +1 -1
  7. package/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/src/app-root.d.ts +8 -0
  13. package/dist/src/app-root.js +26 -0
  14. package/dist/src/app-root.js.map +1 -1
  15. package/dist/src/collection-browser.d.ts +8 -4
  16. package/dist/src/collection-browser.js +20 -11
  17. package/dist/src/collection-browser.js.map +1 -1
  18. package/dist/src/collection-facets/facet-row.d.ts +6 -0
  19. package/dist/src/collection-facets/facet-row.js +19 -1
  20. package/dist/src/collection-facets/facet-row.js.map +1 -1
  21. package/dist/src/collection-facets/facets-template.js +2 -0
  22. package/dist/src/collection-facets/facets-template.js.map +1 -1
  23. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +5 -0
  24. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  25. package/dist/src/data-source/collection-browser-data-source.d.ts +1 -1
  26. package/dist/src/data-source/collection-browser-data-source.js +8 -6
  27. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  28. package/dist/src/restoration-state-handler.js +2 -4
  29. package/dist/src/restoration-state-handler.js.map +1 -1
  30. package/dist/src/styles/tile-action-styles.d.ts +14 -0
  31. package/dist/src/styles/tile-action-styles.js +59 -0
  32. package/dist/src/styles/tile-action-styles.js.map +1 -0
  33. package/dist/src/tiles/base-tile-component.d.ts +17 -1
  34. package/dist/src/tiles/base-tile-component.js +50 -1
  35. package/dist/src/tiles/base-tile-component.js.map +1 -1
  36. package/dist/src/tiles/grid/item-tile.js +1 -0
  37. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  38. package/dist/src/tiles/list/tile-list-compact-header.js +27 -2
  39. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  40. package/dist/src/tiles/list/tile-list-compact.d.ts +1 -1
  41. package/dist/src/tiles/list/tile-list-compact.js +113 -75
  42. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  43. package/dist/src/tiles/list/tile-list.d.ts +1 -1
  44. package/dist/src/tiles/list/tile-list.js +164 -146
  45. package/dist/src/tiles/list/tile-list.js.map +1 -1
  46. package/dist/src/tiles/models.d.ts +11 -0
  47. package/dist/src/tiles/models.js.map +1 -1
  48. package/dist/src/tiles/tile-dispatcher.d.ts +14 -0
  49. package/dist/src/tiles/tile-dispatcher.js +107 -4
  50. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  51. package/dist/src/utils/date-filter-field.d.ts +6 -0
  52. package/dist/src/utils/date-filter-field.js +9 -0
  53. package/dist/src/utils/date-filter-field.js.map +1 -0
  54. package/dist/test/collection-browser.test.js +81 -0
  55. package/dist/test/collection-browser.test.js.map +1 -1
  56. package/dist/test/collection-facets/facet-row.test.js +32 -0
  57. package/dist/test/collection-facets/facet-row.test.js.map +1 -1
  58. package/eslint.config.mjs +53 -53
  59. package/index.html +24 -24
  60. package/index.ts +1 -0
  61. package/local.archive.org.cert +86 -86
  62. package/local.archive.org.key +27 -27
  63. package/package.json +120 -120
  64. package/renovate.json +6 -6
  65. package/src/app-root.ts +30 -0
  66. package/src/collection-browser.ts +17 -13
  67. package/src/collection-facets/facet-row.ts +11 -1
  68. package/src/collection-facets/facets-template.ts +2 -0
  69. package/src/data-source/collection-browser-data-source-interface.ts +6 -0
  70. package/src/data-source/collection-browser-data-source.ts +16 -7
  71. package/src/restoration-state-handler.ts +5 -5
  72. package/src/styles/tile-action-styles.ts +59 -0
  73. package/src/tiles/base-tile-component.ts +60 -1
  74. package/src/tiles/grid/item-tile.ts +1 -0
  75. package/src/tiles/list/tile-list-compact-header.ts +28 -2
  76. package/src/tiles/list/tile-list-compact.ts +114 -75
  77. package/src/tiles/list/tile-list.ts +190 -172
  78. package/src/tiles/models.ts +13 -0
  79. package/src/tiles/tile-dispatcher.ts +114 -4
  80. package/src/utils/date-filter-field.ts +11 -0
  81. package/test/collection-browser.test.ts +132 -0
  82. package/test/collection-facets/facet-row.test.ts +46 -0
  83. package/tsconfig.json +25 -25
  84. package/web-dev-server.config.mjs +30 -30
  85. package/web-test-runner.config.mjs +52 -52
@@ -1,5 +1,6 @@
1
- import { css, html } from 'lit';
1
+ import { css, html, nothing } from 'lit';
2
2
  import { customElement } from 'lit/decorators.js';
3
+ import { classMap } from 'lit/directives/class-map.js';
3
4
  import { msg } from '@lit/localize';
4
5
  import { BaseTileComponent } from '../base-tile-component';
5
6
 
@@ -8,6 +9,7 @@ export class TileListCompactHeader extends BaseTileComponent {
8
9
  /*
9
10
  * Reactive properties inherited from BaseTileComponent:
10
11
  * - model?: TileModel;
12
+ * - tileActions: TileAction[] = [];
11
13
  * - currentWidth?: number;
12
14
  * - currentHeight?: number;
13
15
  * - baseNavigationUrl?: string;
@@ -21,9 +23,17 @@ export class TileListCompactHeader extends BaseTileComponent {
21
23
  */
22
24
 
23
25
  render() {
26
+ const hasActions = this.tileActions.length > 0;
27
+ const headerClasses = classMap({
28
+ mobile: this.classSize === 'mobile',
29
+ desktop: this.classSize === 'desktop',
30
+ 'has-actions': hasActions,
31
+ });
32
+
24
33
  return html`
25
- <div id="list-line-header" class="${this.classSize}">
34
+ <div id="list-line-header" class=${headerClasses}>
26
35
  <div id="thumb"></div>
36
+ ${hasActions ? html`<div id="actions-header"></div>` : nothing}
27
37
  <div id="title">${msg('Title')}</div>
28
38
  <div id="creator">${msg('Creator')}</div>
29
39
  <div id="date">
@@ -81,6 +91,22 @@ export class TileListCompactHeader extends BaseTileComponent {
81
91
  #list-line-header.desktop {
82
92
  grid-template-columns: 51px 3fr 2fr 95px 30px 115px;
83
93
  }
94
+
95
+ /*
96
+ * When tile actions are present in the rows below, reserve a matching
97
+ * column here so the columns stay aligned with each row.
98
+ */
99
+ #list-line-header.mobile.has-actions {
100
+ grid-template-columns:
101
+ 36px var(--tileActionColumnWidth, 90px) 3fr 2fr
102
+ 68px 35px;
103
+ }
104
+
105
+ #list-line-header.desktop.has-actions {
106
+ grid-template-columns:
107
+ 51px var(--tileActionColumnWidth, 100px) 3fr 2fr
108
+ 95px 30px 115px;
109
+ }
84
110
  `;
85
111
  }
86
112
  }
@@ -1,5 +1,6 @@
1
1
  import { css, html, nothing } from 'lit';
2
2
  import { customElement } from 'lit/decorators.js';
3
+ import { classMap } from 'lit/directives/class-map.js';
3
4
  import DOMPurify from 'dompurify';
4
5
  import type { SortParam } from '@internetarchive/search-service';
5
6
  import { BaseTileComponent } from '../base-tile-component';
@@ -7,6 +8,7 @@ import { BaseTileComponent } from '../base-tile-component';
7
8
  import { formatCount, NumberFormat } from '../../utils/format-count';
8
9
  import type { DateFormat } from '../../utils/format-date';
9
10
  import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
11
+ import { tileActionStyles } from '../../styles/tile-action-styles';
10
12
 
11
13
  import '../image-block';
12
14
  import '../tile-mediatype-icon';
@@ -16,6 +18,7 @@ export class TileListCompact extends BaseTileComponent {
16
18
  /*
17
19
  * Reactive properties inherited from BaseTileComponent:
18
20
  * - model?: TileModel;
21
+ * - tileActions: TileAction[] = [];
19
22
  * - currentWidth?: number;
20
23
  * - currentHeight?: number;
21
24
  * - baseNavigationUrl?: string;
@@ -31,8 +34,15 @@ export class TileListCompact extends BaseTileComponent {
31
34
  */
32
35
 
33
36
  render() {
37
+ const hasActions = this.tileActions.length > 0;
38
+ const lineClasses = classMap({
39
+ mobile: this.classSize === 'mobile',
40
+ desktop: this.classSize === 'desktop',
41
+ 'has-actions': hasActions,
42
+ });
43
+
34
44
  return html`
35
- <div id="list-line" class="${this.classSize}">
45
+ <div id="list-line" class=${lineClasses}>
36
46
  <image-block
37
47
  .model=${this.model}
38
48
  .baseImageUrl=${this.baseImageUrl}
@@ -43,6 +53,11 @@ export class TileListCompact extends BaseTileComponent {
43
53
  .suppressBlurring=${this.suppressBlurring}
44
54
  >
45
55
  </image-block>
56
+ ${hasActions
57
+ ? html`<div id="actions">
58
+ ${this.renderTileActions('list-compact')}
59
+ </div>`
60
+ : nothing}
46
61
  <a href=${this.href} id="title"
47
62
  >${DOMPurify.sanitize(this.model?.title ?? '')}</a
48
63
  >
@@ -161,79 +176,103 @@ export class TileListCompact extends BaseTileComponent {
161
176
  }
162
177
 
163
178
  static get styles() {
164
- return css`
165
- html {
166
- font-size: unset;
167
- }
168
-
169
- div {
170
- font-size: 14px;
171
- }
172
-
173
- #list-line {
174
- display: grid;
175
- column-gap: 10px;
176
- border-top: 1px solid #ddd;
177
- align-items: center;
178
- line-height: 20px;
179
- padding-top: 5px;
180
- margin-bottom: -5px;
181
- }
182
-
183
- #list-line.mobile {
184
- grid-template-columns: 36px 3fr 2fr 68px 35px;
185
- }
186
-
187
- #list-line.desktop {
188
- grid-template-columns: 51px 3fr 2fr 95px 30px 115px;
189
- }
190
-
191
- #list-line:hover #title {
192
- text-decoration: underline;
193
- }
194
-
195
- #title {
196
- text-decoration: none;
197
- }
198
-
199
- #title:link {
200
- color: var(--ia-theme-link-color, #4b64ff);
201
- }
202
-
203
- #title,
204
- #creator {
205
- text-overflow: ellipsis;
206
- overflow: hidden;
207
- white-space: nowrap;
208
- }
209
-
210
- #icon {
211
- margin-left: 2px;
212
- }
213
-
214
- #views {
215
- text-align: right;
216
- padding-right: 8px;
217
- }
218
-
219
- .mobile #views {
220
- display: none;
221
- }
222
-
223
- .mobile tile-mediatype-icon {
224
- --iconHeight: 14px;
225
- --iconWidth: 14px;
226
- }
227
-
228
- .desktop #icon {
229
- --iconHeight: 20px;
230
- --iconWidth: 20px;
231
- }
232
-
233
- item-image {
234
- --imgHeight: 100%;
235
- --imgWidth: 100%;
236
- }
237
- `;
179
+ return [
180
+ tileActionStyles,
181
+ css`
182
+ html {
183
+ font-size: unset;
184
+ }
185
+
186
+ div {
187
+ font-size: 14px;
188
+ }
189
+
190
+ #list-line {
191
+ display: grid;
192
+ column-gap: 10px;
193
+ border-top: 1px solid #ddd;
194
+ align-items: center;
195
+ line-height: 20px;
196
+ padding-top: 5px;
197
+ margin-bottom: -5px;
198
+ }
199
+
200
+ #list-line.mobile {
201
+ grid-template-columns: 36px 3fr 2fr 68px 35px;
202
+ }
203
+
204
+ #list-line.desktop {
205
+ grid-template-columns: 51px 3fr 2fr 95px 30px 115px;
206
+ }
207
+
208
+ /*
209
+ * When tile actions are present, insert an extra column for them
210
+ * between the thumbnail and the title.
211
+ */
212
+ #list-line.mobile.has-actions {
213
+ grid-template-columns:
214
+ 36px var(--tileActionColumnWidth, 90px)
215
+ 3fr 2fr 68px 35px;
216
+ }
217
+
218
+ #list-line.desktop.has-actions {
219
+ grid-template-columns:
220
+ 51px var(--tileActionColumnWidth, 100px)
221
+ 3fr 2fr 95px 30px 115px;
222
+ }
223
+
224
+ #actions {
225
+ /* The flex container inside is what holds the action buttons */
226
+ display: flex;
227
+ }
228
+
229
+ #list-line:hover #title {
230
+ text-decoration: underline;
231
+ }
232
+
233
+ #title {
234
+ text-decoration: none;
235
+ }
236
+
237
+ #title:link {
238
+ color: var(--ia-theme-link-color, #4b64ff);
239
+ }
240
+
241
+ #title,
242
+ #creator {
243
+ text-overflow: ellipsis;
244
+ overflow: hidden;
245
+ white-space: nowrap;
246
+ }
247
+
248
+ #icon {
249
+ margin-left: 2px;
250
+ }
251
+
252
+ #views {
253
+ text-align: right;
254
+ padding-right: 8px;
255
+ }
256
+
257
+ .mobile #views {
258
+ display: none;
259
+ }
260
+
261
+ .mobile tile-mediatype-icon {
262
+ --iconHeight: 14px;
263
+ --iconWidth: 14px;
264
+ }
265
+
266
+ .desktop #icon {
267
+ --iconHeight: 20px;
268
+ --iconWidth: 20px;
269
+ }
270
+
271
+ item-image {
272
+ --imgHeight: 100%;
273
+ --imgWidth: 100%;
274
+ }
275
+ `,
276
+ ];
238
277
  }
239
278
  }