@internetarchive/collection-browser 3.1.0 → 3.1.1-alpha-webdev6778.2
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.
- package/dist/src/app-root.js +606 -606
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +9 -0
- package/dist/src/collection-browser.js +7 -0
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.js +140 -140
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/models.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +1 -0
- package/dist/src/collection-facets/more-facets-content.js +122 -118
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +54 -54
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
- package/dist/src/collection-facets.d.ts +1 -0
- package/dist/src/collection-facets.js +269 -265
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +27 -13
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +1 -0
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/data-source/models.d.ts +1 -1
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/expanded-date-picker.js +52 -52
- package/dist/src/expanded-date-picker.js.map +1 -1
- package/dist/src/manage/manage-bar.js +77 -77
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +376 -376
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +77 -77
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +139 -139
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/search-tile.js +42 -42
- package/dist/src/tiles/grid/search-tile.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +119 -119
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +297 -297
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +200 -200
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/utils/analytics-events.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.js +23 -23
- package/dist/test/collection-facets/facet-row.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +20 -20
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +37 -37
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +113 -113
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/package.json +2 -2
- package/src/app-root.ts +1140 -1140
- package/src/collection-browser.ts +14 -0
- package/src/collection-facets/facet-row.ts +296 -296
- package/src/collection-facets/models.ts +10 -10
- package/src/collection-facets/more-facets-content.ts +639 -636
- package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
- package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +185 -185
- package/src/collection-facets.ts +995 -992
- package/src/data-source/collection-browser-data-source-interface.ts +333 -333
- package/src/data-source/collection-browser-data-source.ts +21 -11
- package/src/data-source/collection-browser-query-state.ts +1 -0
- package/src/data-source/models.ts +1 -1
- package/src/expanded-date-picker.ts +191 -191
- package/src/manage/manage-bar.ts +247 -247
- package/src/models.ts +870 -870
- package/src/sort-filter-bar/sort-filter-bar.ts +1283 -1283
- package/src/tiles/grid/collection-tile.ts +162 -162
- package/src/tiles/grid/item-tile.ts +339 -339
- package/src/tiles/grid/search-tile.ts +90 -90
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
- package/src/tiles/list/tile-list.ts +696 -696
- package/src/tiles/tile-dispatcher.ts +486 -486
- package/src/utils/analytics-events.ts +29 -29
- package/test/collection-facets/facet-row.test.ts +375 -375
- package/test/collection-facets.test.ts +928 -928
- package/test/sort-filter-bar/sort-filter-bar.test.ts +885 -885
- package/test/tiles/list/tile-list.test.ts +497 -497
|
@@ -599,6 +599,7 @@ export class CollectionBrowserDataSource
|
|
|
599
599
|
|
|
600
600
|
const trimmedQuery = this.host.baseQuery?.trim();
|
|
601
601
|
const hasNonEmptyQuery = !!trimmedQuery;
|
|
602
|
+
const hasIdentifiers = !!this.host.identifiers?.length;
|
|
602
603
|
const isCollectionSearch = !!this.host.withinCollection;
|
|
603
604
|
const isProfileSearch = !!this.host.withinProfile;
|
|
604
605
|
const hasProfileElement = !!this.host.profileElement;
|
|
@@ -617,6 +618,7 @@ export class CollectionBrowserDataSource
|
|
|
617
618
|
// Otherwise, a non-empty query must be set.
|
|
618
619
|
return (
|
|
619
620
|
hasNonEmptyQuery ||
|
|
621
|
+
hasIdentifiers ||
|
|
620
622
|
(isCollectionSearch && isValidForCollectionSearch) ||
|
|
621
623
|
(isProfileSearch && isValidForProfileSearch)
|
|
622
624
|
);
|
|
@@ -826,6 +828,11 @@ export class CollectionBrowserDataSource
|
|
|
826
828
|
* @inheritdoc
|
|
827
829
|
*/
|
|
828
830
|
get pageSpecifierParams(): PageSpecifierParams | null {
|
|
831
|
+
if (this.host.identifiers?.length) {
|
|
832
|
+
return {
|
|
833
|
+
pageType: 'client_document_fetch',
|
|
834
|
+
};
|
|
835
|
+
}
|
|
829
836
|
if (this.host.withinCollection) {
|
|
830
837
|
return {
|
|
831
838
|
pageType: 'collection_details',
|
|
@@ -848,20 +855,20 @@ export class CollectionBrowserDataSource
|
|
|
848
855
|
* The full query, including year facets and date range clauses
|
|
849
856
|
*/
|
|
850
857
|
private get fullQuery(): string | undefined {
|
|
851
|
-
|
|
858
|
+
const parts = [];
|
|
859
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
860
|
+
if (trimmedQuery) parts.push(trimmedQuery);
|
|
861
|
+
|
|
862
|
+
if (this.host.identifiers) {
|
|
863
|
+
parts.push(`identifier:(${this.host.identifiers.join(' OR ')})`);
|
|
864
|
+
}
|
|
852
865
|
|
|
853
866
|
const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
|
|
867
|
+
if (facetQuery) parts.push(facetQuery);
|
|
868
|
+
if (dateRangeQueryClause) parts.push(dateRangeQueryClause);
|
|
869
|
+
if (sortFilterQueries) parts.push(sortFilterQueries);
|
|
854
870
|
|
|
855
|
-
|
|
856
|
-
fullQuery += ` AND ${facetQuery}`;
|
|
857
|
-
}
|
|
858
|
-
if (dateRangeQueryClause) {
|
|
859
|
-
fullQuery += ` AND ${dateRangeQueryClause}`;
|
|
860
|
-
}
|
|
861
|
-
if (sortFilterQueries) {
|
|
862
|
-
fullQuery += ` AND ${sortFilterQueries}`;
|
|
863
|
-
}
|
|
864
|
-
return fullQuery.trim();
|
|
871
|
+
return parts.join(' AND ').trim();
|
|
865
872
|
}
|
|
866
873
|
|
|
867
874
|
/**
|
|
@@ -1001,6 +1008,7 @@ export class CollectionBrowserDataSource
|
|
|
1001
1008
|
const params: SearchParams = {
|
|
1002
1009
|
...this.pageSpecifierParams,
|
|
1003
1010
|
query: trimmedQuery || '',
|
|
1011
|
+
identifiers: this.host.identifiers,
|
|
1004
1012
|
rows: 0,
|
|
1005
1013
|
filters: this.filterMap,
|
|
1006
1014
|
// Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
|
|
@@ -1133,6 +1141,7 @@ export class CollectionBrowserDataSource
|
|
|
1133
1141
|
const params: SearchParams = {
|
|
1134
1142
|
...this.pageSpecifierParams,
|
|
1135
1143
|
query: trimmedQuery || '',
|
|
1144
|
+
identifiers: this.host.identifiers,
|
|
1136
1145
|
page: pageNumber,
|
|
1137
1146
|
rows: numRows,
|
|
1138
1147
|
sort: sortParams,
|
|
@@ -1318,6 +1327,7 @@ export class CollectionBrowserDataSource
|
|
|
1318
1327
|
const params: SearchParams = {
|
|
1319
1328
|
...this.pageSpecifierParams,
|
|
1320
1329
|
query: trimmedQuery || '',
|
|
1330
|
+
identifiers: this.host.identifiers,
|
|
1321
1331
|
rows: 0,
|
|
1322
1332
|
filters: this.filterMap,
|
|
1323
1333
|
// Only fetch the firstTitle or firstCreator aggregation
|
|
@@ -19,6 +19,7 @@ import type { CollectionBrowserDataSourceInterface } from './collection-browser-
|
|
|
19
19
|
*/
|
|
20
20
|
export interface CollectionBrowserQueryState {
|
|
21
21
|
baseQuery?: string;
|
|
22
|
+
identifiers?: string[];
|
|
22
23
|
withinCollection?: string;
|
|
23
24
|
withinProfile?: string;
|
|
24
25
|
profileElement?: PageElementName;
|
|
@@ -25,7 +25,7 @@ export type PageSpecifierParams = {
|
|
|
25
25
|
/**
|
|
26
26
|
* The target identifier for collection or profile pages (e.g., "prelinger", "@brewster", ...)
|
|
27
27
|
*/
|
|
28
|
-
pageTarget
|
|
28
|
+
pageTarget?: string;
|
|
29
29
|
/**
|
|
30
30
|
* Which specific elements of a profile page to fetch. Corresponds to individual tab data
|
|
31
31
|
* (e.g., "uploads", "reviews", ...)
|
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
import {
|
|
2
|
-
css,
|
|
3
|
-
html,
|
|
4
|
-
LitElement,
|
|
5
|
-
CSSResultGroup,
|
|
6
|
-
TemplateResult,
|
|
7
|
-
nothing,
|
|
8
|
-
} from 'lit';
|
|
9
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
-
import { msg } from '@lit/localize';
|
|
12
|
-
import type { ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
13
|
-
import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
|
|
14
|
-
import {
|
|
15
|
-
BarScalingOption,
|
|
16
|
-
BinSnappingInterval,
|
|
17
|
-
} from '@internetarchive/histogram-date-range';
|
|
18
|
-
import {
|
|
19
|
-
analyticsActions,
|
|
20
|
-
analyticsCategories,
|
|
21
|
-
} from './utils/analytics-events';
|
|
22
|
-
|
|
23
|
-
import '@internetarchive/histogram-date-range';
|
|
24
|
-
|
|
25
|
-
@customElement('expanded-date-picker')
|
|
26
|
-
export class ExpandedDatePicker extends LitElement {
|
|
27
|
-
@property({ type: String }) minDate?: string;
|
|
28
|
-
|
|
29
|
-
@property({ type: String }) maxDate?: string;
|
|
30
|
-
|
|
31
|
-
@property({ type: String }) minSelectedDate?: string;
|
|
32
|
-
|
|
33
|
-
@property({ type: String }) maxSelectedDate?: string;
|
|
34
|
-
|
|
35
|
-
@property({ type: Array }) buckets?: number[];
|
|
36
|
-
|
|
37
|
-
@property({ type: String }) customDateFormat?: string;
|
|
38
|
-
|
|
39
|
-
@property({ type: String }) customTooltipDateFormat?: string;
|
|
40
|
-
|
|
41
|
-
@property({ type: String }) customTooltipLabel?: string;
|
|
42
|
-
|
|
43
|
-
@property({ type: String }) binSnapping: BinSnappingInterval = 'none';
|
|
44
|
-
|
|
45
|
-
@property({ type: String }) barScaling: BarScalingOption = 'logarithmic';
|
|
46
|
-
|
|
47
|
-
@property({ type: Object, attribute: false })
|
|
48
|
-
modalManager?: ModalManagerInterface;
|
|
49
|
-
|
|
50
|
-
@property({ type: Object, attribute: false })
|
|
51
|
-
analyticsHandler?: AnalyticsManagerInterface;
|
|
52
|
-
|
|
53
|
-
render(): TemplateResult {
|
|
54
|
-
return html`
|
|
55
|
-
<div id="container">
|
|
56
|
-
<histogram-date-range
|
|
57
|
-
id="date-picker"
|
|
58
|
-
.minDate=${this.minDate}
|
|
59
|
-
.maxDate=${this.maxDate}
|
|
60
|
-
.minSelectedDate=${this.minSelectedDate ?? this.minDate}
|
|
61
|
-
.maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
|
|
62
|
-
dateFormat=${ifDefined(this.customDateFormat)}
|
|
63
|
-
tooltipDateFormat=${ifDefined(this.customTooltipDateFormat)}
|
|
64
|
-
tooltipLabel=${ifDefined(this.customTooltipLabel)}
|
|
65
|
-
.binSnapping=${this.binSnapping}
|
|
66
|
-
.barScaling=${this.barScaling ?? nothing}
|
|
67
|
-
.updateDelay=${0}
|
|
68
|
-
updateWhileFocused
|
|
69
|
-
missingDataMessage="..."
|
|
70
|
-
.width=${560}
|
|
71
|
-
.height=${120}
|
|
72
|
-
.bins=${this.buckets}
|
|
73
|
-
@histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
|
|
74
|
-
>
|
|
75
|
-
<button
|
|
76
|
-
id="apply-btn"
|
|
77
|
-
slot="inputs-right-side"
|
|
78
|
-
@click=${this.applyBtnClicked}
|
|
79
|
-
>
|
|
80
|
-
${msg('Apply date range')}
|
|
81
|
-
</button>
|
|
82
|
-
</histogram-date-range>
|
|
83
|
-
</div>
|
|
84
|
-
`;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
connectedCallback(): void {
|
|
88
|
-
super.connectedCallback?.();
|
|
89
|
-
this.setupEscapeListener();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
disconnectedCallback(): void {
|
|
93
|
-
super.disconnectedCallback?.();
|
|
94
|
-
this.removeEscapeListener();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Add an event listener to close the date picker modal when the Esc key is pressed
|
|
99
|
-
*/
|
|
100
|
-
private setupEscapeListener() {
|
|
101
|
-
document.addEventListener('keydown', this.boundEscapeListener);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Remove the Esc key listener that was previously added
|
|
106
|
-
*/
|
|
107
|
-
private removeEscapeListener() {
|
|
108
|
-
document.removeEventListener('keydown', this.boundEscapeListener);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Closes the modal dialog if the given event is pressing the Esc key.
|
|
113
|
-
* Arrow function to ensure `this` remains bound to the current component.
|
|
114
|
-
*/
|
|
115
|
-
private boundEscapeListener = (e: KeyboardEvent) => {
|
|
116
|
-
if (e.key === 'Escape') {
|
|
117
|
-
this.closeModal();
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* When the histogram is updated, keep track of the newly selected date range.
|
|
123
|
-
* We don't commit to the new range until the apply button is clicked.
|
|
124
|
-
*/
|
|
125
|
-
private histogramDateRangeUpdated(
|
|
126
|
-
e: CustomEvent<{
|
|
127
|
-
minDate: string;
|
|
128
|
-
maxDate: string;
|
|
129
|
-
}>,
|
|
130
|
-
): void {
|
|
131
|
-
this.minSelectedDate = e.detail.minDate;
|
|
132
|
-
this.maxSelectedDate = e.detail.maxDate;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* When the Apply button is clicked, emit the current date range and close the modal.
|
|
137
|
-
*/
|
|
138
|
-
private applyBtnClicked(): void {
|
|
139
|
-
const event = new CustomEvent('histogramDateRangeApplied', {
|
|
140
|
-
detail: {
|
|
141
|
-
minDate: this.minSelectedDate,
|
|
142
|
-
maxDate: this.maxSelectedDate,
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
this.dispatchEvent(event);
|
|
146
|
-
this.closeModal();
|
|
147
|
-
|
|
148
|
-
this.analyticsHandler?.sendEvent({
|
|
149
|
-
category: analyticsCategories.default,
|
|
150
|
-
action: analyticsActions.histogramChangedFromModal,
|
|
151
|
-
label: window.location.href,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Closes the modal associated with this component (if it exists) and dispatches a
|
|
157
|
-
* modalClosed event.
|
|
158
|
-
*/
|
|
159
|
-
private closeModal(): void {
|
|
160
|
-
if (this.modalManager) {
|
|
161
|
-
this.modalManager.closeModal();
|
|
162
|
-
this.dispatchEvent(new CustomEvent('modalClosed'));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
static get styles(): CSSResultGroup {
|
|
167
|
-
return css`
|
|
168
|
-
#container {
|
|
169
|
-
display: flex;
|
|
170
|
-
justify-content: center;
|
|
171
|
-
padding: 40px 10px 10px;
|
|
172
|
-
overflow: hidden;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
#date-picker {
|
|
176
|
-
--histogramDateRangeInputWidth: 50px;
|
|
177
|
-
--histogramDateRangeInputRowMargin: 5px 0 0 0;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
#apply-btn {
|
|
181
|
-
margin: 0 0 0 5px;
|
|
182
|
-
padding: 8px 10px;
|
|
183
|
-
border: 0;
|
|
184
|
-
border-radius: 4px;
|
|
185
|
-
background: var(--primaryButtonBGColor, #194880);
|
|
186
|
-
color: white;
|
|
187
|
-
cursor: pointer;
|
|
188
|
-
}
|
|
189
|
-
`;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
html,
|
|
4
|
+
LitElement,
|
|
5
|
+
CSSResultGroup,
|
|
6
|
+
TemplateResult,
|
|
7
|
+
nothing,
|
|
8
|
+
} from 'lit';
|
|
9
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { msg } from '@lit/localize';
|
|
12
|
+
import type { ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
13
|
+
import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
|
|
14
|
+
import {
|
|
15
|
+
BarScalingOption,
|
|
16
|
+
BinSnappingInterval,
|
|
17
|
+
} from '@internetarchive/histogram-date-range';
|
|
18
|
+
import {
|
|
19
|
+
analyticsActions,
|
|
20
|
+
analyticsCategories,
|
|
21
|
+
} from './utils/analytics-events';
|
|
22
|
+
|
|
23
|
+
import '@internetarchive/histogram-date-range';
|
|
24
|
+
|
|
25
|
+
@customElement('expanded-date-picker')
|
|
26
|
+
export class ExpandedDatePicker extends LitElement {
|
|
27
|
+
@property({ type: String }) minDate?: string;
|
|
28
|
+
|
|
29
|
+
@property({ type: String }) maxDate?: string;
|
|
30
|
+
|
|
31
|
+
@property({ type: String }) minSelectedDate?: string;
|
|
32
|
+
|
|
33
|
+
@property({ type: String }) maxSelectedDate?: string;
|
|
34
|
+
|
|
35
|
+
@property({ type: Array }) buckets?: number[];
|
|
36
|
+
|
|
37
|
+
@property({ type: String }) customDateFormat?: string;
|
|
38
|
+
|
|
39
|
+
@property({ type: String }) customTooltipDateFormat?: string;
|
|
40
|
+
|
|
41
|
+
@property({ type: String }) customTooltipLabel?: string;
|
|
42
|
+
|
|
43
|
+
@property({ type: String }) binSnapping: BinSnappingInterval = 'none';
|
|
44
|
+
|
|
45
|
+
@property({ type: String }) barScaling: BarScalingOption = 'logarithmic';
|
|
46
|
+
|
|
47
|
+
@property({ type: Object, attribute: false })
|
|
48
|
+
modalManager?: ModalManagerInterface;
|
|
49
|
+
|
|
50
|
+
@property({ type: Object, attribute: false })
|
|
51
|
+
analyticsHandler?: AnalyticsManagerInterface;
|
|
52
|
+
|
|
53
|
+
render(): TemplateResult {
|
|
54
|
+
return html`
|
|
55
|
+
<div id="container">
|
|
56
|
+
<histogram-date-range
|
|
57
|
+
id="date-picker"
|
|
58
|
+
.minDate=${this.minDate}
|
|
59
|
+
.maxDate=${this.maxDate}
|
|
60
|
+
.minSelectedDate=${this.minSelectedDate ?? this.minDate}
|
|
61
|
+
.maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
|
|
62
|
+
dateFormat=${ifDefined(this.customDateFormat)}
|
|
63
|
+
tooltipDateFormat=${ifDefined(this.customTooltipDateFormat)}
|
|
64
|
+
tooltipLabel=${ifDefined(this.customTooltipLabel)}
|
|
65
|
+
.binSnapping=${this.binSnapping}
|
|
66
|
+
.barScaling=${this.barScaling ?? nothing}
|
|
67
|
+
.updateDelay=${0}
|
|
68
|
+
updateWhileFocused
|
|
69
|
+
missingDataMessage="..."
|
|
70
|
+
.width=${560}
|
|
71
|
+
.height=${120}
|
|
72
|
+
.bins=${this.buckets}
|
|
73
|
+
@histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
|
|
74
|
+
>
|
|
75
|
+
<button
|
|
76
|
+
id="apply-btn"
|
|
77
|
+
slot="inputs-right-side"
|
|
78
|
+
@click=${this.applyBtnClicked}
|
|
79
|
+
>
|
|
80
|
+
${msg('Apply date range')}
|
|
81
|
+
</button>
|
|
82
|
+
</histogram-date-range>
|
|
83
|
+
</div>
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
connectedCallback(): void {
|
|
88
|
+
super.connectedCallback?.();
|
|
89
|
+
this.setupEscapeListener();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
disconnectedCallback(): void {
|
|
93
|
+
super.disconnectedCallback?.();
|
|
94
|
+
this.removeEscapeListener();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Add an event listener to close the date picker modal when the Esc key is pressed
|
|
99
|
+
*/
|
|
100
|
+
private setupEscapeListener() {
|
|
101
|
+
document.addEventListener('keydown', this.boundEscapeListener);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Remove the Esc key listener that was previously added
|
|
106
|
+
*/
|
|
107
|
+
private removeEscapeListener() {
|
|
108
|
+
document.removeEventListener('keydown', this.boundEscapeListener);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Closes the modal dialog if the given event is pressing the Esc key.
|
|
113
|
+
* Arrow function to ensure `this` remains bound to the current component.
|
|
114
|
+
*/
|
|
115
|
+
private boundEscapeListener = (e: KeyboardEvent) => {
|
|
116
|
+
if (e.key === 'Escape') {
|
|
117
|
+
this.closeModal();
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* When the histogram is updated, keep track of the newly selected date range.
|
|
123
|
+
* We don't commit to the new range until the apply button is clicked.
|
|
124
|
+
*/
|
|
125
|
+
private histogramDateRangeUpdated(
|
|
126
|
+
e: CustomEvent<{
|
|
127
|
+
minDate: string;
|
|
128
|
+
maxDate: string;
|
|
129
|
+
}>,
|
|
130
|
+
): void {
|
|
131
|
+
this.minSelectedDate = e.detail.minDate;
|
|
132
|
+
this.maxSelectedDate = e.detail.maxDate;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* When the Apply button is clicked, emit the current date range and close the modal.
|
|
137
|
+
*/
|
|
138
|
+
private applyBtnClicked(): void {
|
|
139
|
+
const event = new CustomEvent('histogramDateRangeApplied', {
|
|
140
|
+
detail: {
|
|
141
|
+
minDate: this.minSelectedDate,
|
|
142
|
+
maxDate: this.maxSelectedDate,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
this.dispatchEvent(event);
|
|
146
|
+
this.closeModal();
|
|
147
|
+
|
|
148
|
+
this.analyticsHandler?.sendEvent({
|
|
149
|
+
category: analyticsCategories.default,
|
|
150
|
+
action: analyticsActions.histogramChangedFromModal,
|
|
151
|
+
label: window.location.href,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Closes the modal associated with this component (if it exists) and dispatches a
|
|
157
|
+
* modalClosed event.
|
|
158
|
+
*/
|
|
159
|
+
private closeModal(): void {
|
|
160
|
+
if (this.modalManager) {
|
|
161
|
+
this.modalManager.closeModal();
|
|
162
|
+
this.dispatchEvent(new CustomEvent('modalClosed'));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static get styles(): CSSResultGroup {
|
|
167
|
+
return css`
|
|
168
|
+
#container {
|
|
169
|
+
display: flex;
|
|
170
|
+
justify-content: center;
|
|
171
|
+
padding: 40px 10px 10px;
|
|
172
|
+
overflow: hidden;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#date-picker {
|
|
176
|
+
--histogramDateRangeInputWidth: 50px;
|
|
177
|
+
--histogramDateRangeInputRowMargin: 5px 0 0 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#apply-btn {
|
|
181
|
+
margin: 0 0 0 5px;
|
|
182
|
+
padding: 8px 10px;
|
|
183
|
+
border: 0;
|
|
184
|
+
border-radius: 4px;
|
|
185
|
+
background: var(--primaryButtonBGColor, #194880);
|
|
186
|
+
color: white;
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
}
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
}
|