@internetarchive/collection-browser 3.1.1-alpha-webdev6778.7 → 3.1.1-alpha-webdev6778.8

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 (73) 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.js.map +1 -1
  4. package/dist/src/collection-facets/facet-row.js +140 -140
  5. package/dist/src/collection-facets/facet-row.js.map +1 -1
  6. package/dist/src/collection-facets/models.js.map +1 -1
  7. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
  8. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  9. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +54 -54
  10. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
  11. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  12. package/dist/src/data-source/collection-browser-data-source.js +1 -3
  13. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  14. package/dist/src/data-source/models.js.map +1 -1
  15. package/dist/src/expanded-date-picker.js +52 -52
  16. package/dist/src/expanded-date-picker.js.map +1 -1
  17. package/dist/src/manage/manage-bar.js +77 -77
  18. package/dist/src/manage/manage-bar.js.map +1 -1
  19. package/dist/src/models.js.map +1 -1
  20. package/dist/src/sort-filter-bar/sort-filter-bar.js +376 -376
  21. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  22. package/dist/src/tiles/base-tile-component.js.map +1 -1
  23. package/dist/src/tiles/grid/account-tile.js +36 -36
  24. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  25. package/dist/src/tiles/grid/search-tile.js +42 -42
  26. package/dist/src/tiles/grid/search-tile.js.map +1 -1
  27. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +119 -119
  28. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  29. package/dist/src/tiles/list/tile-list-compact.js +97 -97
  30. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  31. package/dist/src/utils/analytics-events.js.map +1 -1
  32. package/dist/src/utils/format-date.js.map +1 -1
  33. package/dist/test/collection-browser.test.js +187 -187
  34. package/dist/test/collection-browser.test.js.map +1 -1
  35. package/dist/test/collection-facets/facet-row.test.js +23 -23
  36. package/dist/test/collection-facets/facet-row.test.js.map +1 -1
  37. package/dist/test/collection-facets.test.js +20 -20
  38. package/dist/test/collection-facets.test.js.map +1 -1
  39. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +37 -37
  40. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  41. package/dist/test/tiles/grid/item-tile.test.js +64 -64
  42. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  43. package/dist/test/tiles/list/tile-list-compact.test.js +57 -57
  44. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  45. package/dist/test/utils/format-date.test.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/app-root.ts +1140 -1140
  48. package/src/collection-browser.ts +1 -1
  49. package/src/collection-facets/facet-row.ts +296 -296
  50. package/src/collection-facets/models.ts +10 -10
  51. package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
  52. package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +185 -185
  53. package/src/data-source/collection-browser-data-source-interface.ts +333 -333
  54. package/src/data-source/collection-browser-data-source.ts +2 -4
  55. package/src/data-source/models.ts +43 -43
  56. package/src/expanded-date-picker.ts +191 -191
  57. package/src/manage/manage-bar.ts +247 -247
  58. package/src/models.ts +870 -870
  59. package/src/sort-filter-bar/sort-filter-bar.ts +1283 -1283
  60. package/src/tiles/base-tile-component.ts +53 -53
  61. package/src/tiles/grid/account-tile.ts +112 -112
  62. package/src/tiles/grid/search-tile.ts +90 -90
  63. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
  64. package/src/tiles/list/tile-list-compact.ts +236 -236
  65. package/src/utils/analytics-events.ts +29 -29
  66. package/src/utils/format-date.ts +42 -42
  67. package/test/collection-browser.test.ts +2359 -2359
  68. package/test/collection-facets/facet-row.test.ts +375 -375
  69. package/test/collection-facets.test.ts +928 -928
  70. package/test/sort-filter-bar/sort-filter-bar.test.ts +885 -885
  71. package/test/tiles/grid/item-tile.test.ts +464 -464
  72. package/test/tiles/list/tile-list-compact.test.ts +228 -228
  73. package/test/utils/format-date.test.ts +39 -39
@@ -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
+ }