@internetarchive/collection-browser 4.2.1-alpha-webdev8165.0 → 4.3.1-alpha-webdev8165.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 (50) hide show
  1. package/dist/src/app-root.d.ts +3 -0
  2. package/dist/src/app-root.js +695 -614
  3. package/dist/src/app-root.js.map +1 -1
  4. package/dist/src/collection-browser.d.ts +0 -4
  5. package/dist/src/collection-browser.js +761 -779
  6. package/dist/src/collection-browser.js.map +1 -1
  7. package/dist/src/data-source/collection-browser-data-source.d.ts +7 -0
  8. package/dist/src/data-source/collection-browser-data-source.js +24 -8
  9. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  10. package/dist/src/manage/manage-bar.d.ts +7 -2
  11. package/dist/src/manage/manage-bar.js +102 -80
  12. package/dist/src/manage/manage-bar.js.map +1 -1
  13. package/dist/src/models.js.map +1 -1
  14. package/dist/src/restoration-state-handler.js.map +1 -1
  15. package/dist/src/tiles/list/tile-list-compact-header.js +45 -45
  16. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  17. package/dist/src/tiles/list/tile-list-compact.js +99 -99
  18. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  19. package/dist/src/tiles/list/tile-list.js +300 -299
  20. package/dist/src/tiles/list/tile-list.js.map +1 -1
  21. package/dist/src/tiles/tile-display-value-provider.d.ts +5 -0
  22. package/dist/src/tiles/tile-display-value-provider.js +9 -0
  23. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  24. package/dist/test/data-source/collection-browser-data-source.test.js +54 -2
  25. package/dist/test/data-source/collection-browser-data-source.test.js.map +1 -1
  26. package/dist/test/manage/manage-bar.test.d.ts +1 -0
  27. package/dist/test/manage/manage-bar.test.js +129 -7
  28. package/dist/test/manage/manage-bar.test.js.map +1 -1
  29. package/dist/test/restoration-state-handler.test.js.map +1 -1
  30. package/dist/test/tiles/list/tile-list-compact-header.test.d.ts +1 -0
  31. package/dist/test/tiles/list/tile-list-compact-header.test.js +36 -0
  32. package/dist/test/tiles/list/tile-list-compact-header.test.js.map +1 -0
  33. package/dist/test/tiles/list/tile-list.test.js +147 -127
  34. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/app-root.ts +1251 -1166
  37. package/src/collection-browser.ts +3049 -3077
  38. package/src/data-source/collection-browser-data-source.ts +1465 -1445
  39. package/src/manage/manage-bar.ts +276 -247
  40. package/src/models.ts +879 -879
  41. package/src/restoration-state-handler.ts +546 -546
  42. package/src/tiles/list/tile-list-compact-header.ts +86 -86
  43. package/src/tiles/list/tile-list-compact.ts +239 -239
  44. package/src/tiles/list/tile-list.ts +700 -700
  45. package/src/tiles/tile-display-value-provider.ts +134 -124
  46. package/test/data-source/collection-browser-data-source.test.ts +193 -131
  47. package/test/manage/manage-bar.test.ts +347 -157
  48. package/test/restoration-state-handler.test.ts +569 -569
  49. package/test/tiles/list/tile-list-compact-header.test.ts +43 -0
  50. package/test/tiles/list/tile-list.test.ts +576 -552
@@ -1,247 +1,276 @@
1
- import { msg } from '@lit/localize';
2
- import { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';
3
- import { customElement, property } from 'lit/decorators.js';
4
- import { when } from 'lit/directives/when.js';
5
- import {
6
- ModalConfig,
7
- type ModalManagerInterface,
8
- } from '@internetarchive/modal-manager';
9
- import type { ManageableItem } from '../models';
10
- import iaButtonStyle from '../styles/ia-button';
11
- import './remove-items-modal-content';
12
-
13
- @customElement('manage-bar')
14
- export class ManageBar extends LitElement {
15
- /**
16
- * The label displayed in front of the management buttons
17
- */
18
- @property({ type: String }) label = msg('Select items to remove');
19
-
20
- /**
21
- * The shared modal manager component for displaying modal dialogs on this page
22
- */
23
- @property({ type: Object }) modalManager?: ModalManagerInterface;
24
-
25
- /**
26
- * Array of items that have been selected for management
27
- */
28
- @property({ type: Object }) selectedItems: Array<ManageableItem> = [];
29
-
30
- /**
31
- * Message shows as note in the modal when removing items
32
- */
33
- @property({ type: String }) manageViewModalMsg?: string;
34
-
35
- /**
36
- * Whether to show the "Select All" button (default false)
37
- */
38
- @property({ type: Boolean }) showSelectAll = false;
39
-
40
- /**
41
- * Whether to show the "Unselect All" button (default false)
42
- */
43
- @property({ type: Boolean }) showUnselectAll = false;
44
-
45
- /**
46
- * Whether to show "Item Manager the items" button (default false)
47
- */
48
- @property({ type: Boolean }) showItemManageButton = false;
49
-
50
- /**
51
- * Whether to active delete button for selectable items
52
- */
53
- @property({ type: Boolean }) removeAllowed = false;
54
-
55
- render(): TemplateResult {
56
- return html`
57
- <div class="manage-container">
58
- <span class="manage-label">${this.label}</span>
59
- <div class="manage-buttons">
60
- <button class="ia-button dark" @click=${this.cancelClicked}>
61
- ${msg('Cancel')}
62
- </button>
63
- <button
64
- class="ia-button danger"
65
- ?disabled=${!this.removeAllowed}
66
- @click=${this.showRemoveItemsModal}
67
- >
68
- ${msg('Remove selected items')} (${this.selectedItems.length})...
69
- </button>
70
- ${when(
71
- this.showItemManageButton,
72
- () =>
73
- html` <button
74
- class="ia-button warning"
75
- ?disabled=${!this.removeAllowed}
76
- @click=${this.manageItemsClicked}
77
- >
78
- ${msg('Item Manager the items')} (${this.selectedItems.length})
79
- </button>`,
80
- )}
81
- <div class="selection-buttons">
82
- ${when(
83
- this.showSelectAll,
84
- () =>
85
- html` <button
86
- class="ia-button link select-all-btn"
87
- @click=${this.selectAllClicked}
88
- >
89
- ${msg('Select all')}
90
- </button>`,
91
- )}
92
- ${when(
93
- this.showUnselectAll,
94
- () =>
95
- html` <button
96
- class="ia-button link unselect-all-btn"
97
- @click=${this.unselectAllClicked}
98
- >
99
- ${msg('Unselect all')}
100
- </button>`,
101
- )}
102
- </div>
103
- </div>
104
- </div>
105
- `;
106
- }
107
-
108
- private cancelClicked(): void {
109
- this.dispatchEvent(new CustomEvent('cancel'));
110
- }
111
-
112
- private removeItemsClicked(): void {
113
- this.dispatchEvent(new CustomEvent('removeItems'));
114
- }
115
-
116
- private manageItemsClicked(): void {
117
- this.dispatchEvent(new CustomEvent('manageItems'));
118
- }
119
-
120
- private selectAllClicked(): void {
121
- this.dispatchEvent(new CustomEvent('selectAll'));
122
- }
123
-
124
- private unselectAllClicked(): void {
125
- this.dispatchEvent(new CustomEvent('unselectAll'));
126
- }
127
-
128
- /**
129
- * Shows a modal dialog confirming the list of items to be removed
130
- * @param items Which items to list in the modal
131
- */
132
- private showRemoveItemsModal(): void {
133
- const customModalContent = html`
134
- <remove-items-modal-content
135
- .items=${this.selectedItems}
136
- .message=${this.manageViewModalMsg}
137
- @confirm=${() => this.removeItemsClicked()}
138
- ></remove-items-modal-content>
139
- `;
140
-
141
- const config = new ModalConfig({
142
- showProcessingIndicator: false,
143
- processingImageMode: 'processing',
144
- bodyColor: '#fff',
145
- headerColor: '#194880',
146
- showHeaderLogo: false,
147
- closeOnBackdropClick: true,
148
- title: html`${msg('Are you sure you want to remove these items?')}`,
149
- });
150
-
151
- this.modalManager?.classList.add('remove-items');
152
- this.modalManager?.showModal({
153
- config,
154
- customModalContent,
155
- userClosedModalCallback: () => {
156
- this.modalManager?.classList.remove('remove-items');
157
- },
158
- });
159
- }
160
-
161
- /**
162
- * Shows a modal dialog indicating that item removal is being processed
163
- */
164
- showRemoveItemsProcessingModal(): void {
165
- const config = new ModalConfig({
166
- showProcessingIndicator: true,
167
- processingImageMode: 'processing',
168
- bodyColor: '#fff',
169
- headerColor: '#194880',
170
- showHeaderLogo: false,
171
- closeOnBackdropClick: true,
172
- title: html`${msg('Removing selected items...')}`,
173
- });
174
-
175
- this.modalManager?.classList.add('remove-items');
176
- this.modalManager?.showModal({
177
- config,
178
- userClosedModalCallback: () => {
179
- this.modalManager?.classList.remove('remove-items');
180
- },
181
- });
182
- }
183
-
184
- /**
185
- * Shows a modal dialog indicating that an error occurred while removing items
186
- */
187
- showRemoveItemsErrorModal(): void {
188
- const config = new ModalConfig({
189
- showProcessingIndicator: false,
190
- processingImageMode: 'processing',
191
- bodyColor: '#fff',
192
- headerColor: '#691916',
193
- showHeaderLogo: false,
194
- closeOnBackdropClick: true,
195
- title: html`${msg('Error: unable to remove items')}`,
196
- message: html`${msg(
197
- 'An error occurred while removing items. Please try again in a few minutes.',
198
- )}`,
199
- });
200
-
201
- this.modalManager?.classList.add('remove-items');
202
- this.modalManager?.showModal({
203
- config,
204
- userClosedModalCallback: () => {
205
- this.modalManager?.classList.remove('remove-items');
206
- },
207
- });
208
- }
209
-
210
- static get styles(): CSSResultGroup {
211
- return css`
212
- ${iaButtonStyle}
213
- .manage-container {
214
- display: flex;
215
- align-items: center;
216
- column-gap: 5px;
217
- padding: 20px 0 20px;
218
- flex-wrap: wrap;
219
- }
220
-
221
- .manage-label {
222
- display: inline-block;
223
- font-weight: bold;
224
- font-size: 1.8rem;
225
- padding-right: 10px;
226
- }
227
-
228
- .manage-buttons {
229
- display: flex;
230
- flex-wrap: wrap;
231
- align-items: center;
232
- column-gap: 5px;
233
- }
234
-
235
- .selection-buttons {
236
- display: inherit;
237
- }
238
-
239
- .ia-button,
240
- button {
241
- padding: 6px 12px;
242
- font-size: 1.4rem;
243
- margin: 3px 0;
244
- }
245
- `;
246
- }
247
- }
1
+ import { msg, str } from '@lit/localize';
2
+ import { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import { when } from 'lit/directives/when.js';
5
+ import {
6
+ ModalConfig,
7
+ type ModalManagerInterface,
8
+ } from '@internetarchive/modal-manager';
9
+ import type { ManageableItem } from '../models';
10
+ import { PageElementName } from '@internetarchive/search-service';
11
+ import iaButtonStyle from '../styles/ia-button';
12
+ import './remove-items-modal-content';
13
+
14
+ @customElement('manage-bar')
15
+ export class ManageBar extends LitElement {
16
+ /**
17
+ * The label displayed in front of the management buttons
18
+ */
19
+ @property({ type: String }) label = msg('Select items to remove');
20
+
21
+ /**
22
+ * The shared modal manager component for displaying modal dialogs on this page
23
+ */
24
+ @property({ type: Object }) modalManager?: ModalManagerInterface;
25
+
26
+ /**
27
+ * Array of items that have been selected for management
28
+ */
29
+ @property({ type: Array }) selectedItems: Array<ManageableItem> = [];
30
+
31
+ /**
32
+ * Which section of the profile page searches are for (e.g., uploads, reviews, ...)
33
+ */
34
+ @property({ type: String }) profileElement?: PageElementName;
35
+
36
+ /**
37
+ * Whether to show the "Select All" button (default false)
38
+ */
39
+ @property({ type: Boolean }) showSelectAll = false;
40
+
41
+ /**
42
+ * Whether to show the "Unselect All" button (default false)
43
+ */
44
+ @property({ type: Boolean }) showUnselectAll = false;
45
+
46
+ /**
47
+ * Whether to show "Item Manager the items" button (default false)
48
+ */
49
+ @property({ type: Boolean }) showItemManageButton = false;
50
+
51
+ /**
52
+ * Whether to active delete button for selectable items
53
+ */
54
+ @property({ type: Boolean }) removeAllowed = false;
55
+
56
+ render(): TemplateResult {
57
+ return html`
58
+ <div class="manage-container">
59
+ <span class="manage-label">${this.label}</span>
60
+ <div class="manage-buttons">
61
+ <button class="ia-button dark" @click=${this.cancelClicked}>
62
+ ${msg('Cancel')}
63
+ </button>
64
+ <button
65
+ class="ia-button danger"
66
+ ?disabled=${!this.removeAllowed}
67
+ @click=${this.showRemoveItemsModal}
68
+ >
69
+ ${msg('Remove selected items')} (${this.selectedItems.length})...
70
+ </button>
71
+ ${when(
72
+ this.showItemManageButton,
73
+ () =>
74
+ html` <button
75
+ class="ia-button warning"
76
+ ?disabled=${!this.removeAllowed}
77
+ @click=${this.manageItemsClicked}
78
+ >
79
+ ${msg('Item Manager the items')} (${this.selectedItems.length})
80
+ </button>`,
81
+ )}
82
+ <div class="selection-buttons">
83
+ ${when(
84
+ this.showSelectAll,
85
+ () =>
86
+ html` <button
87
+ class="ia-button link select-all-btn"
88
+ @click=${this.selectAllClicked}
89
+ >
90
+ ${msg('Select all')}
91
+ </button>`,
92
+ )}
93
+ ${when(
94
+ this.showUnselectAll,
95
+ () =>
96
+ html` <button
97
+ class="ia-button link unselect-all-btn"
98
+ @click=${this.unselectAllClicked}
99
+ >
100
+ ${msg('Unselect all')}
101
+ </button>`,
102
+ )}
103
+ </div>
104
+ </div>
105
+ </div>
106
+ `;
107
+ }
108
+
109
+ /**
110
+ * Message to show in the manage view modal, depending on context.
111
+ */
112
+ private get manageViewModalMsg(): string {
113
+ const pluralize = this.selectedItems.length > 1;
114
+ const subject = pluralize ? 'these items' : 'this item';
115
+
116
+ let listName = '';
117
+
118
+ switch (this.profileElement) {
119
+ case 'uploads':
120
+ listName = 'uploads list';
121
+ break;
122
+ case 'web_archives':
123
+ listName = 'web archives list';
124
+ break;
125
+ case 'favorites':
126
+ listName = 'favorites list';
127
+ break;
128
+ default:
129
+ return '';
130
+ }
131
+
132
+ return msg(
133
+ str`Note: It may take a few minutes for ${subject} to stop appearing in your ${listName}.`,
134
+ );
135
+ }
136
+
137
+ private cancelClicked(): void {
138
+ this.dispatchEvent(new CustomEvent('cancel'));
139
+ }
140
+
141
+ private removeItemsClicked(): void {
142
+ this.dispatchEvent(new CustomEvent('removeItems'));
143
+ }
144
+
145
+ private manageItemsClicked(): void {
146
+ this.dispatchEvent(new CustomEvent('manageItems'));
147
+ }
148
+
149
+ private selectAllClicked(): void {
150
+ this.dispatchEvent(new CustomEvent('selectAll'));
151
+ }
152
+
153
+ private unselectAllClicked(): void {
154
+ this.dispatchEvent(new CustomEvent('unselectAll'));
155
+ }
156
+
157
+ /**
158
+ * Shows a modal dialog confirming the list of items to be removed
159
+ * @param items Which items to list in the modal
160
+ */
161
+ private showRemoveItemsModal(): void {
162
+ const customModalContent = html`
163
+ <remove-items-modal-content
164
+ .items=${this.selectedItems}
165
+ .message=${this.manageViewModalMsg}
166
+ @confirm=${() => this.removeItemsClicked()}
167
+ ></remove-items-modal-content>
168
+ `;
169
+
170
+ const config = new ModalConfig({
171
+ showProcessingIndicator: false,
172
+ processingImageMode: 'processing',
173
+ bodyColor: '#fff',
174
+ headerColor: '#194880',
175
+ showHeaderLogo: false,
176
+ closeOnBackdropClick: true,
177
+ title: html`${msg('Are you sure you want to remove these items?')}`,
178
+ });
179
+
180
+ this.modalManager?.classList.add('remove-items');
181
+ this.modalManager?.showModal({
182
+ config,
183
+ customModalContent,
184
+ userClosedModalCallback: () => {
185
+ this.modalManager?.classList.remove('remove-items');
186
+ },
187
+ });
188
+ }
189
+
190
+ /**
191
+ * Shows a modal dialog indicating that item removal is being processed
192
+ */
193
+ showRemoveItemsProcessingModal(): void {
194
+ const config = new ModalConfig({
195
+ showProcessingIndicator: true,
196
+ processingImageMode: 'processing',
197
+ bodyColor: '#fff',
198
+ headerColor: '#194880',
199
+ showHeaderLogo: false,
200
+ closeOnBackdropClick: true,
201
+ title: html`${msg('Removing selected items...')}`,
202
+ });
203
+
204
+ this.modalManager?.classList.add('remove-items');
205
+ this.modalManager?.showModal({
206
+ config,
207
+ userClosedModalCallback: () => {
208
+ this.modalManager?.classList.remove('remove-items');
209
+ },
210
+ });
211
+ }
212
+
213
+ /**
214
+ * Shows a modal dialog indicating that an error occurred while removing items
215
+ */
216
+ showRemoveItemsErrorModal(): void {
217
+ const config = new ModalConfig({
218
+ showProcessingIndicator: false,
219
+ processingImageMode: 'processing',
220
+ bodyColor: '#fff',
221
+ headerColor: '#691916',
222
+ showHeaderLogo: false,
223
+ closeOnBackdropClick: true,
224
+ title: html`${msg('Error: unable to remove items')}`,
225
+ message: html`${msg(
226
+ 'An error occurred while removing items. Please try again in a few minutes.',
227
+ )}`,
228
+ });
229
+
230
+ this.modalManager?.classList.add('remove-items');
231
+ this.modalManager?.showModal({
232
+ config,
233
+ userClosedModalCallback: () => {
234
+ this.modalManager?.classList.remove('remove-items');
235
+ },
236
+ });
237
+ }
238
+
239
+ static get styles(): CSSResultGroup {
240
+ return css`
241
+ ${iaButtonStyle}
242
+ .manage-container {
243
+ display: flex;
244
+ align-items: center;
245
+ column-gap: 5px;
246
+ padding: 20px 0 20px;
247
+ flex-wrap: wrap;
248
+ }
249
+
250
+ .manage-label {
251
+ display: inline-block;
252
+ font-weight: bold;
253
+ font-size: 1.8rem;
254
+ padding-right: 10px;
255
+ }
256
+
257
+ .manage-buttons {
258
+ display: flex;
259
+ flex-wrap: wrap;
260
+ align-items: center;
261
+ column-gap: 5px;
262
+ }
263
+
264
+ .selection-buttons {
265
+ display: inherit;
266
+ }
267
+
268
+ .ia-button,
269
+ button {
270
+ padding: 6px 12px;
271
+ font-size: 1.4rem;
272
+ margin: 3px 0;
273
+ }
274
+ `;
275
+ }
276
+ }