@internetarchive/collection-browser 3.0.7-alpha-webdev7989.0 → 3.1.1-alpha-webdev6778.1

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 (75) hide show
  1. package/dist/src/app-root.js +606 -606
  2. package/dist/src/app-root.js.map +1 -1
  3. package/dist/src/collection-browser.d.ts +9 -0
  4. package/dist/src/collection-browser.js +689 -682
  5. package/dist/src/collection-browser.js.map +1 -1
  6. package/dist/src/collection-facets/models.js.map +1 -1
  7. package/dist/src/collection-facets/more-facets-content.d.ts +1 -0
  8. package/dist/src/collection-facets/more-facets-content.js +122 -118
  9. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  10. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
  11. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  12. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +54 -54
  13. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
  14. package/dist/src/collection-facets.d.ts +1 -0
  15. package/dist/src/collection-facets.js +269 -265
  16. package/dist/src/collection-facets.js.map +1 -1
  17. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  18. package/dist/src/data-source/collection-browser-data-source.js +27 -13
  19. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  20. package/dist/src/data-source/collection-browser-query-state.d.ts +1 -0
  21. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  22. package/dist/src/data-source/models.d.ts +1 -1
  23. package/dist/src/data-source/models.js.map +1 -1
  24. package/dist/src/expanded-date-picker.js +52 -52
  25. package/dist/src/expanded-date-picker.js.map +1 -1
  26. package/dist/src/manage/manage-bar.js +77 -77
  27. package/dist/src/manage/manage-bar.js.map +1 -1
  28. package/dist/src/models.js.map +1 -1
  29. package/dist/src/sort-filter-bar/sort-filter-bar.js +376 -376
  30. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  31. package/dist/src/tiles/grid/collection-tile.js +77 -77
  32. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  33. package/dist/src/tiles/grid/item-tile.js +139 -139
  34. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  35. package/dist/src/tiles/grid/search-tile.js +42 -42
  36. package/dist/src/tiles/grid/search-tile.js.map +1 -1
  37. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +119 -119
  38. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  39. package/dist/src/tiles/list/tile-list.js +297 -297
  40. package/dist/src/tiles/list/tile-list.js.map +1 -1
  41. package/dist/src/tiles/tile-dispatcher.js +200 -200
  42. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  43. package/dist/src/utils/analytics-events.js.map +1 -1
  44. package/dist/test/collection-browser.test.js +196 -183
  45. package/dist/test/collection-browser.test.js.map +1 -1
  46. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +37 -37
  47. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  48. package/dist/test/tiles/list/tile-list.test.js +113 -113
  49. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/app-root.ts +1140 -1140
  52. package/src/collection-browser.ts +2802 -2788
  53. package/src/collection-facets/models.ts +10 -10
  54. package/src/collection-facets/more-facets-content.ts +639 -636
  55. package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
  56. package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +185 -185
  57. package/src/collection-facets.ts +995 -992
  58. package/src/data-source/collection-browser-data-source-interface.ts +333 -333
  59. package/src/data-source/collection-browser-data-source.ts +1401 -1391
  60. package/src/data-source/collection-browser-query-state.ts +65 -64
  61. package/src/data-source/models.ts +1 -1
  62. package/src/expanded-date-picker.ts +191 -191
  63. package/src/manage/manage-bar.ts +247 -247
  64. package/src/models.ts +870 -870
  65. package/src/sort-filter-bar/sort-filter-bar.ts +1283 -1283
  66. package/src/tiles/grid/collection-tile.ts +162 -162
  67. package/src/tiles/grid/item-tile.ts +339 -339
  68. package/src/tiles/grid/search-tile.ts +90 -90
  69. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
  70. package/src/tiles/list/tile-list.ts +696 -696
  71. package/src/tiles/tile-dispatcher.ts +486 -486
  72. package/src/utils/analytics-events.ts +29 -29
  73. package/test/collection-browser.test.ts +2359 -2340
  74. package/test/sort-filter-bar/sort-filter-bar.test.ts +885 -885
  75. package/test/tiles/list/tile-list.test.ts +497 -497
@@ -1,185 +1,185 @@
1
- import { css, html, LitElement, CSSResultGroup, nothing } from 'lit';
2
- import { customElement, property, query } from 'lit/decorators.js';
3
- import type { IaDropdown, optionInterface } from '@internetarchive/ia-dropdown';
4
- import type { FacetRef, SmartFacet, SmartFacetEvent } from './models';
5
- import { log } from '../../utils/log';
6
-
7
- @customElement('smart-facet-dropdown')
8
- export class SmartFacetDropdown extends LitElement {
9
- @property({ type: Array }) facetInfo?: SmartFacet[];
10
-
11
- @property({ type: String }) labelPrefix?: string;
12
-
13
- @property({ type: Object }) activeFacetRef?: FacetRef;
14
-
15
- @query('ia-dropdown') dropdown?: IaDropdown;
16
-
17
- //
18
- // COMPONENT LIFECYCLE METHODS
19
- //
20
-
21
- render() {
22
- if (!this.facetInfo || !this.activeFacetRef) return nothing;
23
- if (this.facetInfo.length === 0) return nothing;
24
-
25
- const displayText =
26
- this.activeFacetRef.displayText ?? this.activeFacetRef.bucketKey;
27
- if (!displayText) return nothing;
28
-
29
- return html`
30
- <div class="dropdown-container">
31
- <ia-dropdown
32
- class="dropdown"
33
- displayCaret
34
- closeOnSelect
35
- closeOnEscape
36
- closeOnBackdropClick
37
- includeSelectedOption
38
- usePopover
39
- .options=${this.dropdownOptions}
40
- .selectedOption=${this.activeDropdownOption}
41
- .openViaButton=${false}
42
- @optionSelected=${this.optionSelected}
43
- @click=${this.onDropdownClick}
44
- >
45
- <span
46
- class="dropdown-label"
47
- slot="dropdown-label"
48
- @click=${this.defaultOptionSelected}
49
- >${this.labelPrefix ?? nothing} ${displayText}</span
50
- >
51
- </ia-dropdown>
52
- </div>
53
- `;
54
- }
55
-
56
- //
57
- // OTHER METHODS
58
- //
59
-
60
- private get dropdownOptions(): optionInterface[] {
61
- return (
62
- this.facetInfo?.map(smartFacet => {
63
- const firstFacet = smartFacet.facets[0];
64
- return {
65
- id: firstFacet.bucketKey,
66
- label: html`<span>
67
- ${smartFacet.label ??
68
- firstFacet.displayText ??
69
- firstFacet.bucketKey}
70
- </span>`,
71
- };
72
- }) ?? []
73
- );
74
- }
75
-
76
- private get activeDropdownOption(): optionInterface | undefined {
77
- if (!this.activeFacetRef) return undefined;
78
- return this.dropdownOptions.find(
79
- opt => opt.id === this.activeFacetRef?.bucketKey,
80
- );
81
- }
82
-
83
- /**
84
- * Handler for when the default option on the dropdown button is clicked
85
- */
86
- private defaultOptionSelected(): void {
87
- this.handleSelection(this.activeFacetRef?.bucketKey);
88
- }
89
-
90
- /**
91
- * Handler for when an option in the dropdown menu is selected
92
- */
93
- private optionSelected(e: CustomEvent<{ option: optionInterface }>): void {
94
- this.handleSelection(e.detail.option.id);
95
- }
96
-
97
- /**
98
- * Responds to a dropdown selection by emitting a `facetClick` event with
99
- * the appropriate facet details.
100
- */
101
- private handleSelection(bucketKey?: string): void {
102
- if (!bucketKey || !this.facetInfo || !this.activeFacetRef) return;
103
-
104
- let selectedSmartFacet;
105
- for (const smartFacet of this.facetInfo) {
106
- const selectedRef = smartFacet.facets.find(
107
- b => b.bucketKey === bucketKey,
108
- );
109
- if (selectedRef) {
110
- this.activeFacetRef = selectedRef;
111
- selectedSmartFacet = smartFacet;
112
- }
113
- }
114
-
115
- if (!selectedSmartFacet) return;
116
-
117
- this.dispatchEvent(
118
- new CustomEvent<SmartFacetEvent>('facetClick', {
119
- detail: {
120
- smartFacet: selectedSmartFacet,
121
- details: [
122
- {
123
- facetType: this.activeFacetRef.facetType,
124
- bucket: {
125
- key: this.activeFacetRef.bucketKey,
126
- count: 0,
127
- state: 'selected',
128
- },
129
- negative: false,
130
- },
131
- ],
132
- },
133
- }),
134
- );
135
- }
136
-
137
- private onDropdownClick(): void {
138
- log('smart dropdown: onDropdownClick', this);
139
- this.dispatchEvent(
140
- new CustomEvent<SmartFacetDropdown>('dropdownClick', { detail: this }),
141
- );
142
- }
143
-
144
- close(): void {
145
- if (this.dropdown) {
146
- this.dropdown.open = false;
147
- }
148
- }
149
-
150
- //
151
- // STYLES
152
- //
153
-
154
- static get styles(): CSSResultGroup {
155
- return css`
156
- .dropdown-container {
157
- padding: 5px 5px;
158
- border-radius: 5px;
159
- background: white;
160
- color: #2c2c2c;
161
- border: 1px solid #194880;
162
- font-size: 1.4rem;
163
- font-family: inherit;
164
- }
165
-
166
- .dropdown-label {
167
- font-size: 1.4rem;
168
- font-family: inherit;
169
- }
170
-
171
- .dropdown {
172
- --dropdownBorderColor: #194880;
173
- --dropdownBorderWidth: 1px;
174
- --dropdownBgColor: white;
175
- --dropdownHoverBgColor: #f8f8f8;
176
- --dropdownTextColor: #2c2c2c;
177
- --dropdownHoverTextColor: #2c2c2c;
178
- --dropdownCaretColor: #2c2c2c;
179
- --dropdownWhiteSpace: nowrap;
180
- --caretWidth: 14px;
181
- --caretHeight: 14px;
182
- }
183
- `;
184
- }
185
- }
1
+ import { css, html, LitElement, CSSResultGroup, nothing } from 'lit';
2
+ import { customElement, property, query } from 'lit/decorators.js';
3
+ import type { IaDropdown, optionInterface } from '@internetarchive/ia-dropdown';
4
+ import type { FacetRef, SmartFacet, SmartFacetEvent } from './models';
5
+ import { log } from '../../utils/log';
6
+
7
+ @customElement('smart-facet-dropdown')
8
+ export class SmartFacetDropdown extends LitElement {
9
+ @property({ type: Array }) facetInfo?: SmartFacet[];
10
+
11
+ @property({ type: String }) labelPrefix?: string;
12
+
13
+ @property({ type: Object }) activeFacetRef?: FacetRef;
14
+
15
+ @query('ia-dropdown') dropdown?: IaDropdown;
16
+
17
+ //
18
+ // COMPONENT LIFECYCLE METHODS
19
+ //
20
+
21
+ render() {
22
+ if (!this.facetInfo || !this.activeFacetRef) return nothing;
23
+ if (this.facetInfo.length === 0) return nothing;
24
+
25
+ const displayText =
26
+ this.activeFacetRef.displayText ?? this.activeFacetRef.bucketKey;
27
+ if (!displayText) return nothing;
28
+
29
+ return html`
30
+ <div class="dropdown-container">
31
+ <ia-dropdown
32
+ class="dropdown"
33
+ displayCaret
34
+ closeOnSelect
35
+ closeOnEscape
36
+ closeOnBackdropClick
37
+ includeSelectedOption
38
+ usePopover
39
+ .options=${this.dropdownOptions}
40
+ .selectedOption=${this.activeDropdownOption}
41
+ .openViaButton=${false}
42
+ @optionSelected=${this.optionSelected}
43
+ @click=${this.onDropdownClick}
44
+ >
45
+ <span
46
+ class="dropdown-label"
47
+ slot="dropdown-label"
48
+ @click=${this.defaultOptionSelected}
49
+ >${this.labelPrefix ?? nothing} ${displayText}</span
50
+ >
51
+ </ia-dropdown>
52
+ </div>
53
+ `;
54
+ }
55
+
56
+ //
57
+ // OTHER METHODS
58
+ //
59
+
60
+ private get dropdownOptions(): optionInterface[] {
61
+ return (
62
+ this.facetInfo?.map(smartFacet => {
63
+ const firstFacet = smartFacet.facets[0];
64
+ return {
65
+ id: firstFacet.bucketKey,
66
+ label: html`<span>
67
+ ${smartFacet.label ??
68
+ firstFacet.displayText ??
69
+ firstFacet.bucketKey}
70
+ </span>`,
71
+ };
72
+ }) ?? []
73
+ );
74
+ }
75
+
76
+ private get activeDropdownOption(): optionInterface | undefined {
77
+ if (!this.activeFacetRef) return undefined;
78
+ return this.dropdownOptions.find(
79
+ opt => opt.id === this.activeFacetRef?.bucketKey,
80
+ );
81
+ }
82
+
83
+ /**
84
+ * Handler for when the default option on the dropdown button is clicked
85
+ */
86
+ private defaultOptionSelected(): void {
87
+ this.handleSelection(this.activeFacetRef?.bucketKey);
88
+ }
89
+
90
+ /**
91
+ * Handler for when an option in the dropdown menu is selected
92
+ */
93
+ private optionSelected(e: CustomEvent<{ option: optionInterface }>): void {
94
+ this.handleSelection(e.detail.option.id);
95
+ }
96
+
97
+ /**
98
+ * Responds to a dropdown selection by emitting a `facetClick` event with
99
+ * the appropriate facet details.
100
+ */
101
+ private handleSelection(bucketKey?: string): void {
102
+ if (!bucketKey || !this.facetInfo || !this.activeFacetRef) return;
103
+
104
+ let selectedSmartFacet;
105
+ for (const smartFacet of this.facetInfo) {
106
+ const selectedRef = smartFacet.facets.find(
107
+ b => b.bucketKey === bucketKey,
108
+ );
109
+ if (selectedRef) {
110
+ this.activeFacetRef = selectedRef;
111
+ selectedSmartFacet = smartFacet;
112
+ }
113
+ }
114
+
115
+ if (!selectedSmartFacet) return;
116
+
117
+ this.dispatchEvent(
118
+ new CustomEvent<SmartFacetEvent>('facetClick', {
119
+ detail: {
120
+ smartFacet: selectedSmartFacet,
121
+ details: [
122
+ {
123
+ facetType: this.activeFacetRef.facetType,
124
+ bucket: {
125
+ key: this.activeFacetRef.bucketKey,
126
+ count: 0,
127
+ state: 'selected',
128
+ },
129
+ negative: false,
130
+ },
131
+ ],
132
+ },
133
+ }),
134
+ );
135
+ }
136
+
137
+ private onDropdownClick(): void {
138
+ log('smart dropdown: onDropdownClick', this);
139
+ this.dispatchEvent(
140
+ new CustomEvent<SmartFacetDropdown>('dropdownClick', { detail: this }),
141
+ );
142
+ }
143
+
144
+ close(): void {
145
+ if (this.dropdown) {
146
+ this.dropdown.open = false;
147
+ }
148
+ }
149
+
150
+ //
151
+ // STYLES
152
+ //
153
+
154
+ static get styles(): CSSResultGroup {
155
+ return css`
156
+ .dropdown-container {
157
+ padding: 5px 5px;
158
+ border-radius: 5px;
159
+ background: white;
160
+ color: #2c2c2c;
161
+ border: 1px solid #194880;
162
+ font-size: 1.4rem;
163
+ font-family: inherit;
164
+ }
165
+
166
+ .dropdown-label {
167
+ font-size: 1.4rem;
168
+ font-family: inherit;
169
+ }
170
+
171
+ .dropdown {
172
+ --dropdownBorderColor: #194880;
173
+ --dropdownBorderWidth: 1px;
174
+ --dropdownBgColor: white;
175
+ --dropdownHoverBgColor: #f8f8f8;
176
+ --dropdownTextColor: #2c2c2c;
177
+ --dropdownHoverTextColor: #2c2c2c;
178
+ --dropdownCaretColor: #2c2c2c;
179
+ --dropdownWhiteSpace: nowrap;
180
+ --caretWidth: 14px;
181
+ --caretHeight: 14px;
182
+ }
183
+ `;
184
+ }
185
+ }