@internetarchive/collection-browser 2.19.0 → 2.20.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 (43) hide show
  1. package/dist/src/app-root.js +606 -605
  2. package/dist/src/app-root.js.map +1 -1
  3. package/dist/src/collection-browser.js +28 -11
  4. package/dist/src/collection-browser.js.map +1 -1
  5. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
  6. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  7. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +54 -54
  8. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
  9. package/dist/src/collection-facets.js +263 -263
  10. package/dist/src/collection-facets.js.map +1 -1
  11. package/dist/src/expanded-date-picker.js +52 -52
  12. package/dist/src/expanded-date-picker.js.map +1 -1
  13. package/dist/src/models.d.ts +13 -0
  14. package/dist/src/models.js +41 -0
  15. package/dist/src/models.js.map +1 -1
  16. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +79 -24
  17. package/dist/src/sort-filter-bar/sort-filter-bar.js +201 -119
  18. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  19. package/dist/src/tiles/grid/item-tile.js +139 -139
  20. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  21. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +118 -118
  22. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  23. package/dist/src/tiles/list/tile-list.js +289 -289
  24. package/dist/src/tiles/list/tile-list.js.map +1 -1
  25. package/dist/src/tiles/tile-dispatcher.js +200 -200
  26. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  27. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +157 -11
  28. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/app-root.ts +1140 -1140
  31. package/src/collection-browser.ts +32 -10
  32. package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
  33. package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +185 -185
  34. package/src/collection-facets.ts +990 -990
  35. package/src/expanded-date-picker.ts +191 -191
  36. package/src/models.ts +48 -0
  37. package/src/sort-filter-bar/sort-filter-bar.ts +220 -126
  38. package/src/tiles/grid/item-tile.ts +339 -339
  39. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +129 -129
  40. package/src/tiles/list/tile-list.ts +688 -688
  41. package/src/tiles/tile-dispatcher.ts +486 -486
  42. package/test/sort-filter-bar/sort-filter-bar.test.ts +205 -12
  43. package/tsconfig.json +1 -1
@@ -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
+ }