@internetarchive/collection-browser 0.2.23-fa1 → 0.2.23
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 +1 -0
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-facets/facets-template.js +6 -9
- package/dist/src/collection-facets/facets-template.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +1 -1
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +7 -0
- package/dist/src/restoration-state-handler.js +22 -5
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/test/restoration-state-handler.test.d.ts +1 -0
- package/dist/test/restoration-state-handler.test.js +118 -0
- package/dist/test/restoration-state-handler.test.js.map +1 -0
- package/package.json +1 -1
- package/src/app-root.ts +1 -0
- package/src/collection-facets/facets-template.ts +6 -9
- package/src/collection-facets/more-facets-content.ts +1 -1
- package/src/restoration-state-handler.ts +45 -11
- package/test/restoration-state-handler.test.ts +176 -0
- package/dist/src/collection-facets/facet-group.d.ts +0 -0
- package/dist/src/collection-facets/facet-group.js +0 -72
- package/dist/src/collection-facets/facet-group.js.map +0 -1
- package/dist/src/styles/facet-group-styles.d.ts +0 -0
- package/dist/src/styles/facet-group-styles.js +0 -2
- package/dist/src/styles/facet-group-styles.js.map +0 -1
- package/src/collection-facets/facet-group.ts +0 -85
- package/src/styles/facet-group-styles.ts +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { RestorationStateHandler } from '../src/restoration-state-handler';
|
|
3
|
+
describe('Restoration state handler', () => {
|
|
4
|
+
it('should restore query from URL', async () => {
|
|
5
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
6
|
+
const url = new URL(window.location.href);
|
|
7
|
+
url.search = '?query=boop';
|
|
8
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
9
|
+
const restorationState = handler.getRestorationState();
|
|
10
|
+
expect(restorationState.baseQuery).to.equal('boop');
|
|
11
|
+
});
|
|
12
|
+
it('should restore page number from URL', async () => {
|
|
13
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
14
|
+
const url = new URL(window.location.href);
|
|
15
|
+
url.search = '?page=42';
|
|
16
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
17
|
+
const restorationState = handler.getRestorationState();
|
|
18
|
+
expect(restorationState.currentPage).to.equal(42);
|
|
19
|
+
});
|
|
20
|
+
it('should restore selected year facets from URL', async () => {
|
|
21
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
22
|
+
const url = new URL(window.location.href);
|
|
23
|
+
url.search = '?and[]=year:"2018"';
|
|
24
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
25
|
+
const restorationState = handler.getRestorationState();
|
|
26
|
+
expect(restorationState.selectedFacets.year['2018'].state).to.equal('selected');
|
|
27
|
+
});
|
|
28
|
+
it('should restore selected date range facets from URL', async () => {
|
|
29
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
30
|
+
const url = new URL(window.location.href);
|
|
31
|
+
url.search = '?and[]=year:"2018+TO+2021"';
|
|
32
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
33
|
+
const restorationState = handler.getRestorationState();
|
|
34
|
+
expect(restorationState.minSelectedDate).to.equal('2018');
|
|
35
|
+
expect(restorationState.maxSelectedDate).to.equal('2021');
|
|
36
|
+
expect(restorationState.dateRangeQueryClause).to.equal('year:"2018 TO 2021"');
|
|
37
|
+
});
|
|
38
|
+
it('should restore creator filter from URL', async () => {
|
|
39
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
40
|
+
const url = new URL(window.location.href);
|
|
41
|
+
url.search = '?and[]=firstCreator:F';
|
|
42
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
43
|
+
const restorationState = handler.getRestorationState();
|
|
44
|
+
expect(restorationState.selectedCreatorFilter).to.equal('F');
|
|
45
|
+
});
|
|
46
|
+
it('should restore title filter from URL', async () => {
|
|
47
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
48
|
+
const url = new URL(window.location.href);
|
|
49
|
+
url.search = '?and[]=firstTitle:F';
|
|
50
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
51
|
+
const restorationState = handler.getRestorationState();
|
|
52
|
+
expect(restorationState.selectedTitleFilter).to.equal('F');
|
|
53
|
+
});
|
|
54
|
+
it('should restore other selected facets from URL', async () => {
|
|
55
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
56
|
+
const url = new URL(window.location.href);
|
|
57
|
+
url.search = '?and[]=subject:"foo"';
|
|
58
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
59
|
+
const restorationState = handler.getRestorationState();
|
|
60
|
+
expect(restorationState.selectedFacets.subject.foo.state).to.equal('selected');
|
|
61
|
+
});
|
|
62
|
+
it('should restore negative facets from URL', async () => {
|
|
63
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
64
|
+
const url = new URL(window.location.href);
|
|
65
|
+
url.search = '?not[]=year:2018';
|
|
66
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
67
|
+
const restorationState = handler.getRestorationState();
|
|
68
|
+
expect(restorationState.selectedFacets.year['2018'].state).to.equal('hidden');
|
|
69
|
+
});
|
|
70
|
+
it('should restore multiple selected/negative facets from URL', async () => {
|
|
71
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
72
|
+
const url = new URL(window.location.href);
|
|
73
|
+
url.search =
|
|
74
|
+
'?and[]=collection:"foo"&and[]=collection:"bar"¬[]=collection:"baz"¬[]=collection:"boop"';
|
|
75
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
76
|
+
const restorationState = handler.getRestorationState();
|
|
77
|
+
expect(restorationState.selectedFacets.collection.foo.state).to.equal('selected');
|
|
78
|
+
expect(restorationState.selectedFacets.collection.bar.state).to.equal('selected');
|
|
79
|
+
expect(restorationState.selectedFacets.collection.baz.state).to.equal('hidden');
|
|
80
|
+
expect(restorationState.selectedFacets.collection.boop.state).to.equal('hidden');
|
|
81
|
+
});
|
|
82
|
+
it('negative facets take precedence if both present in URL', async () => {
|
|
83
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
84
|
+
const url = new URL(window.location.href);
|
|
85
|
+
url.search = '?and[]=collection:"foo"¬[]=collection:"foo"';
|
|
86
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
87
|
+
const restorationState = handler.getRestorationState();
|
|
88
|
+
expect(restorationState.selectedFacets.collection.foo.state).to.equal('hidden');
|
|
89
|
+
});
|
|
90
|
+
it('should restore sort from URL (space format)', async () => {
|
|
91
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
92
|
+
const url = new URL(window.location.href);
|
|
93
|
+
url.search = '?sort=date+desc';
|
|
94
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
95
|
+
const restorationState = handler.getRestorationState();
|
|
96
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
97
|
+
expect(restorationState.sortDirection).to.equal('desc');
|
|
98
|
+
});
|
|
99
|
+
it('should restore sort from URL (prefix format, desc)', async () => {
|
|
100
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
101
|
+
const url = new URL(window.location.href);
|
|
102
|
+
url.search = '?sort=-date';
|
|
103
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
104
|
+
const restorationState = handler.getRestorationState();
|
|
105
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
106
|
+
expect(restorationState.sortDirection).to.equal('desc');
|
|
107
|
+
});
|
|
108
|
+
it('should restore sort from URL (prefix format, asc)', async () => {
|
|
109
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
110
|
+
const url = new URL(window.location.href);
|
|
111
|
+
url.search = '?sort=date';
|
|
112
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
113
|
+
const restorationState = handler.getRestorationState();
|
|
114
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
115
|
+
expect(restorationState.sortDirection).to.equal('asc');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=restoration-state-handler.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restoration-state-handler.test.js","sourceRoot":"","sources":["../../test/restoration-state-handler.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,OAAO,GAAG,IAAI,uBAAuB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEnE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,GAAG,CAAC,MAAM,GAAG,aAAa,CAAC;QAC3B,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAE9D,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;QACvD,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,OAAO,GAAG,IAAI,uBAAuB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEnE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,GAAG,CAAC,MAAM,GAAG,UAAU,CAA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,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAE9D,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;QACvD,MAAM,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { RestorationStateHandler } from '../src/restoration-state-handler';\n\ndescribe('Restoration state handler', () => {\n it('should restore query from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?query=boop';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.baseQuery).to.equal('boop');\n });\n\n it('should restore page number from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?page=42';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.currentPage).to.equal(42);\n });\n\n it('should restore selected year facets from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?and[]=year:\"2018\"';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedFacets.year['2018'].state).to.equal(\n 'selected'\n );\n });\n\n it('should restore selected date range facets from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?and[]=year:\"2018+TO+2021\"';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.minSelectedDate).to.equal('2018');\n expect(restorationState.maxSelectedDate).to.equal('2021');\n expect(restorationState.dateRangeQueryClause).to.equal(\n 'year:\"2018 TO 2021\"'\n );\n });\n\n it('should restore creator filter from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?and[]=firstCreator:F';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedCreatorFilter).to.equal('F');\n });\n\n it('should restore title filter from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?and[]=firstTitle:F';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedTitleFilter).to.equal('F');\n });\n\n it('should restore other selected facets from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?and[]=subject:\"foo\"';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedFacets.subject.foo.state).to.equal(\n 'selected'\n );\n });\n\n it('should restore negative facets from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?not[]=year:2018';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedFacets.year['2018'].state).to.equal(\n 'hidden'\n );\n });\n\n it('should restore multiple selected/negative facets from URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search =\n '?and[]=collection:\"foo\"&and[]=collection:\"bar\"¬[]=collection:\"baz\"¬[]=collection:\"boop\"';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n\n expect(restorationState.selectedFacets.collection.foo.state).to.equal(\n 'selected'\n );\n expect(restorationState.selectedFacets.collection.bar.state).to.equal(\n 'selected'\n );\n\n expect(restorationState.selectedFacets.collection.baz.state).to.equal(\n 'hidden'\n );\n expect(restorationState.selectedFacets.collection.boop.state).to.equal(\n 'hidden'\n );\n });\n\n it('negative facets take precedence if both present in URL', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?and[]=collection:\"foo\"¬[]=collection:\"foo\"';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedFacets.collection.foo.state).to.equal(\n 'hidden'\n );\n });\n\n it('should restore sort from URL (space format)', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?sort=date+desc';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedSort).to.equal('date');\n expect(restorationState.sortDirection).to.equal('desc');\n });\n\n it('should restore sort from URL (prefix format, desc)', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?sort=-date';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedSort).to.equal('date');\n expect(restorationState.sortDirection).to.equal('desc');\n });\n\n it('should restore sort from URL (prefix format, asc)', async () => {\n const handler = new RestorationStateHandler({ context: 'search' });\n\n const url = new URL(window.location.href);\n url.search = '?sort=date';\n window.history.replaceState({ path: url.href }, '', url.href);\n\n const restorationState = handler.getRestorationState();\n expect(restorationState.selectedSort).to.equal('date');\n expect(restorationState.sortDirection).to.equal('asc');\n });\n});\n"]}
|
package/package.json
CHANGED
package/src/app-root.ts
CHANGED
|
@@ -213,12 +213,13 @@ export class FacetsTemplate extends LitElement {
|
|
|
213
213
|
.facet-checkbox {
|
|
214
214
|
margin: 0 5px 0 0;
|
|
215
215
|
display: flex;
|
|
216
|
+
height: 15px;
|
|
216
217
|
}
|
|
217
218
|
.facet-checkbox input:first-child {
|
|
218
219
|
margin-right: 5px;
|
|
219
220
|
}
|
|
220
221
|
.facet-checkbox input {
|
|
221
|
-
height:
|
|
222
|
+
height: 15px;
|
|
222
223
|
width: 15px;
|
|
223
224
|
margin: 0;
|
|
224
225
|
}
|
|
@@ -227,12 +228,9 @@ export class FacetsTemplate extends LitElement {
|
|
|
227
228
|
font-weight: 500;
|
|
228
229
|
font-size: 1.2rem;
|
|
229
230
|
margin: 2.5px auto;
|
|
230
|
-
height:
|
|
231
|
-
border-top: var(--facet-row-border-top,
|
|
232
|
-
border-bottom: var(--facet-row-border-bottom,
|
|
233
|
-
}
|
|
234
|
-
.facet-row > * {
|
|
235
|
-
height: inherit;
|
|
231
|
+
height: auto;
|
|
232
|
+
border-top: var(--facet-row-border-top, 1px solid transparent);
|
|
233
|
+
border-bottom: var(--facet-row-border-bottom, 1px solid transparent);
|
|
236
234
|
}
|
|
237
235
|
.facet-info-display {
|
|
238
236
|
display: flex;
|
|
@@ -257,11 +255,10 @@ export class FacetsTemplate extends LitElement {
|
|
|
257
255
|
}
|
|
258
256
|
.hide-facet-icon {
|
|
259
257
|
width: 15px;
|
|
260
|
-
height:
|
|
258
|
+
height: 15px;
|
|
261
259
|
cursor: pointer;
|
|
262
260
|
opacity: 0.3;
|
|
263
261
|
display: inline-block;
|
|
264
|
-
margin-top: -1px;
|
|
265
262
|
}
|
|
266
263
|
.hide-facet-icon:hover,
|
|
267
264
|
.active {
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
CollectionDisplayMode,
|
|
9
9
|
SelectedFacets,
|
|
10
10
|
SortField,
|
|
11
|
+
FacetBucket,
|
|
12
|
+
FacetState,
|
|
11
13
|
} from './models';
|
|
12
14
|
|
|
13
15
|
export interface RestorationState {
|
|
@@ -206,7 +208,6 @@ export class RestorationStateHandler
|
|
|
206
208
|
if (facetAnds) {
|
|
207
209
|
facetAnds.forEach(and => {
|
|
208
210
|
const [field, value] = and.split(':');
|
|
209
|
-
const unQuotedValue = this.stripQuotes(value);
|
|
210
211
|
|
|
211
212
|
switch (field) {
|
|
212
213
|
case 'year': {
|
|
@@ -226,9 +227,12 @@ export class RestorationStateHandler
|
|
|
226
227
|
);
|
|
227
228
|
restorationState.dateRangeQueryClause = `year:${value}`;
|
|
228
229
|
} else {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
this.setSelectedFacetState(
|
|
231
|
+
restorationState.selectedFacets,
|
|
232
|
+
field as FacetOption,
|
|
233
|
+
value,
|
|
234
|
+
'selected'
|
|
235
|
+
);
|
|
232
236
|
}
|
|
233
237
|
break;
|
|
234
238
|
}
|
|
@@ -239,19 +243,24 @@ export class RestorationStateHandler
|
|
|
239
243
|
restorationState.selectedCreatorFilter = value;
|
|
240
244
|
break;
|
|
241
245
|
default:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
246
|
+
this.setSelectedFacetState(
|
|
247
|
+
restorationState.selectedFacets,
|
|
248
|
+
field as FacetOption,
|
|
249
|
+
value,
|
|
250
|
+
'selected'
|
|
251
|
+
);
|
|
245
252
|
}
|
|
246
253
|
});
|
|
247
254
|
}
|
|
248
255
|
if (facetNots) {
|
|
249
256
|
facetNots.forEach(not => {
|
|
250
257
|
const [field, value] = not.split(':');
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
258
|
+
this.setSelectedFacetState(
|
|
259
|
+
restorationState.selectedFacets,
|
|
260
|
+
field as FacetOption,
|
|
261
|
+
value,
|
|
262
|
+
'hidden'
|
|
263
|
+
);
|
|
255
264
|
});
|
|
256
265
|
}
|
|
257
266
|
return restorationState;
|
|
@@ -264,4 +273,29 @@ export class RestorationStateHandler
|
|
|
264
273
|
}
|
|
265
274
|
return value;
|
|
266
275
|
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Sets the facet state for the given field & value to the given state,
|
|
279
|
+
* creating any previously-undefined buckets as needed.
|
|
280
|
+
*/
|
|
281
|
+
private setSelectedFacetState(
|
|
282
|
+
selectedFacets: SelectedFacets,
|
|
283
|
+
field: FacetOption,
|
|
284
|
+
value: string,
|
|
285
|
+
state: FacetState
|
|
286
|
+
): void {
|
|
287
|
+
const facet = selectedFacets[field];
|
|
288
|
+
const unQuotedValue = this.stripQuotes(value);
|
|
289
|
+
facet[unQuotedValue] ??= this.getDefaultBucket(value);
|
|
290
|
+
facet[unQuotedValue].state = state;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Returns a default bucket with the given key, count of 0, and state 'none'. */
|
|
294
|
+
private getDefaultBucket(key: string): FacetBucket {
|
|
295
|
+
return {
|
|
296
|
+
key,
|
|
297
|
+
count: 0,
|
|
298
|
+
state: 'none',
|
|
299
|
+
};
|
|
300
|
+
}
|
|
267
301
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { RestorationStateHandler } from '../src/restoration-state-handler';
|
|
3
|
+
|
|
4
|
+
describe('Restoration state handler', () => {
|
|
5
|
+
it('should restore query from URL', async () => {
|
|
6
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
7
|
+
|
|
8
|
+
const url = new URL(window.location.href);
|
|
9
|
+
url.search = '?query=boop';
|
|
10
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
11
|
+
|
|
12
|
+
const restorationState = handler.getRestorationState();
|
|
13
|
+
expect(restorationState.baseQuery).to.equal('boop');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should restore page number from URL', async () => {
|
|
17
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
18
|
+
|
|
19
|
+
const url = new URL(window.location.href);
|
|
20
|
+
url.search = '?page=42';
|
|
21
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
22
|
+
|
|
23
|
+
const restorationState = handler.getRestorationState();
|
|
24
|
+
expect(restorationState.currentPage).to.equal(42);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should restore selected year facets from URL', async () => {
|
|
28
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
29
|
+
|
|
30
|
+
const url = new URL(window.location.href);
|
|
31
|
+
url.search = '?and[]=year:"2018"';
|
|
32
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
33
|
+
|
|
34
|
+
const restorationState = handler.getRestorationState();
|
|
35
|
+
expect(restorationState.selectedFacets.year['2018'].state).to.equal(
|
|
36
|
+
'selected'
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should restore selected date range facets from URL', async () => {
|
|
41
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
42
|
+
|
|
43
|
+
const url = new URL(window.location.href);
|
|
44
|
+
url.search = '?and[]=year:"2018+TO+2021"';
|
|
45
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
46
|
+
|
|
47
|
+
const restorationState = handler.getRestorationState();
|
|
48
|
+
expect(restorationState.minSelectedDate).to.equal('2018');
|
|
49
|
+
expect(restorationState.maxSelectedDate).to.equal('2021');
|
|
50
|
+
expect(restorationState.dateRangeQueryClause).to.equal(
|
|
51
|
+
'year:"2018 TO 2021"'
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should restore creator filter from URL', async () => {
|
|
56
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
57
|
+
|
|
58
|
+
const url = new URL(window.location.href);
|
|
59
|
+
url.search = '?and[]=firstCreator:F';
|
|
60
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
61
|
+
|
|
62
|
+
const restorationState = handler.getRestorationState();
|
|
63
|
+
expect(restorationState.selectedCreatorFilter).to.equal('F');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should restore title filter from URL', async () => {
|
|
67
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
68
|
+
|
|
69
|
+
const url = new URL(window.location.href);
|
|
70
|
+
url.search = '?and[]=firstTitle:F';
|
|
71
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
72
|
+
|
|
73
|
+
const restorationState = handler.getRestorationState();
|
|
74
|
+
expect(restorationState.selectedTitleFilter).to.equal('F');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should restore other selected facets from URL', async () => {
|
|
78
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
79
|
+
|
|
80
|
+
const url = new URL(window.location.href);
|
|
81
|
+
url.search = '?and[]=subject:"foo"';
|
|
82
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
83
|
+
|
|
84
|
+
const restorationState = handler.getRestorationState();
|
|
85
|
+
expect(restorationState.selectedFacets.subject.foo.state).to.equal(
|
|
86
|
+
'selected'
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should restore negative facets from URL', async () => {
|
|
91
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
92
|
+
|
|
93
|
+
const url = new URL(window.location.href);
|
|
94
|
+
url.search = '?not[]=year:2018';
|
|
95
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
96
|
+
|
|
97
|
+
const restorationState = handler.getRestorationState();
|
|
98
|
+
expect(restorationState.selectedFacets.year['2018'].state).to.equal(
|
|
99
|
+
'hidden'
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should restore multiple selected/negative facets from URL', async () => {
|
|
104
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
105
|
+
|
|
106
|
+
const url = new URL(window.location.href);
|
|
107
|
+
url.search =
|
|
108
|
+
'?and[]=collection:"foo"&and[]=collection:"bar"¬[]=collection:"baz"¬[]=collection:"boop"';
|
|
109
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
110
|
+
|
|
111
|
+
const restorationState = handler.getRestorationState();
|
|
112
|
+
|
|
113
|
+
expect(restorationState.selectedFacets.collection.foo.state).to.equal(
|
|
114
|
+
'selected'
|
|
115
|
+
);
|
|
116
|
+
expect(restorationState.selectedFacets.collection.bar.state).to.equal(
|
|
117
|
+
'selected'
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(restorationState.selectedFacets.collection.baz.state).to.equal(
|
|
121
|
+
'hidden'
|
|
122
|
+
);
|
|
123
|
+
expect(restorationState.selectedFacets.collection.boop.state).to.equal(
|
|
124
|
+
'hidden'
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('negative facets take precedence if both present in URL', async () => {
|
|
129
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
130
|
+
|
|
131
|
+
const url = new URL(window.location.href);
|
|
132
|
+
url.search = '?and[]=collection:"foo"¬[]=collection:"foo"';
|
|
133
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
134
|
+
|
|
135
|
+
const restorationState = handler.getRestorationState();
|
|
136
|
+
expect(restorationState.selectedFacets.collection.foo.state).to.equal(
|
|
137
|
+
'hidden'
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should restore sort from URL (space format)', async () => {
|
|
142
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
143
|
+
|
|
144
|
+
const url = new URL(window.location.href);
|
|
145
|
+
url.search = '?sort=date+desc';
|
|
146
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
147
|
+
|
|
148
|
+
const restorationState = handler.getRestorationState();
|
|
149
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
150
|
+
expect(restorationState.sortDirection).to.equal('desc');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should restore sort from URL (prefix format, desc)', async () => {
|
|
154
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
155
|
+
|
|
156
|
+
const url = new URL(window.location.href);
|
|
157
|
+
url.search = '?sort=-date';
|
|
158
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
159
|
+
|
|
160
|
+
const restorationState = handler.getRestorationState();
|
|
161
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
162
|
+
expect(restorationState.sortDirection).to.equal('desc');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should restore sort from URL (prefix format, asc)', async () => {
|
|
166
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
167
|
+
|
|
168
|
+
const url = new URL(window.location.href);
|
|
169
|
+
url.search = '?sort=date';
|
|
170
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
171
|
+
|
|
172
|
+
const restorationState = handler.getRestorationState();
|
|
173
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
174
|
+
expect(restorationState.sortDirection).to.equal('asc');
|
|
175
|
+
});
|
|
176
|
+
});
|
|
File without changes
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { LitElement, html, css, CSSResultGroup } from "lit";
|
|
3
|
-
// import { query, property, customElement } from "lit/decorators.js";
|
|
4
|
-
// @customElement('facet-group')
|
|
5
|
-
// export class FacetGroup extends LitElement {
|
|
6
|
-
// override render() {
|
|
7
|
-
// return html`
|
|
8
|
-
// <slot></slot>
|
|
9
|
-
// <slot></slot>
|
|
10
|
-
// `
|
|
11
|
-
// }
|
|
12
|
-
// static get styles(): CSSResultGroup {
|
|
13
|
-
// return css`
|
|
14
|
-
// :host {
|
|
15
|
-
// margin-bottom: 1rem;
|
|
16
|
-
// display: flex;
|
|
17
|
-
// align-items: start;
|
|
18
|
-
// font-weight: 500;
|
|
19
|
-
// font-size: 1.2rem;
|
|
20
|
-
// cursor: pointer;
|
|
21
|
-
// }
|
|
22
|
-
// ::slotted(.facet-checkbox) {
|
|
23
|
-
// border: 1px solid red;
|
|
24
|
-
// margin-right: 0.5rem;
|
|
25
|
-
// display: flex;
|
|
26
|
-
// align-items: center;
|
|
27
|
-
// }
|
|
28
|
-
// ::slotted(.select-facet-checkbox) {
|
|
29
|
-
// cursor: pointer;
|
|
30
|
-
// margin-right: 5px;
|
|
31
|
-
// }
|
|
32
|
-
// ::slotted(.hide-facet-checkbox) {
|
|
33
|
-
// display: none;
|
|
34
|
-
// }
|
|
35
|
-
// ::slotted(.hide-facet-icon) {
|
|
36
|
-
// width: 15px;
|
|
37
|
-
// height: 15px;
|
|
38
|
-
// cursor: pointer;
|
|
39
|
-
// opacity: 0.3;
|
|
40
|
-
// }
|
|
41
|
-
// ::slotted(.facet-info-display) {
|
|
42
|
-
// border: 1px solid blue;
|
|
43
|
-
// display: flex;
|
|
44
|
-
// flex: 1;
|
|
45
|
-
// }
|
|
46
|
-
// ::slotted(.facet-title) {
|
|
47
|
-
// flex: 1;
|
|
48
|
-
// }
|
|
49
|
-
// `
|
|
50
|
-
// }
|
|
51
|
-
// )
|
|
52
|
-
// /**
|
|
53
|
-
// <div class="facet-row">
|
|
54
|
-
// <div class="facet-checkbox">
|
|
55
|
-
// <input type="checkbox" class="select-facet-checkbox" name="mediatype" value="texts" title="Only show mediatype: texts" id="mediatype:texts-show-only">
|
|
56
|
-
// <input type="checkbox" class="hide-facet-checkbox" id="mediatype:texts-negative" name="mediatype" value="texts">
|
|
57
|
-
// <label for="mediatype:texts-negative" class="hide-facet-icon" title="Hide mediatype: texts">
|
|
58
|
-
// <span class="eye"><!--?lit$141655362$-->
|
|
59
|
-
// <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="m98 50.5704143c-.2830293-.471515-.671154-1.1088947-1.1643742-1.9121392s-1.6003642-2.3617474-3.3214321-4.6755089c-1.7210678-2.3137614-3.522258-4.5325939-5.4035703-6.6564975-1.8813124-2.1239037-4.2828993-4.473133-7.2047606-7.0476881-2.9218612-2.5745551-5.8895067-4.7933876-8.9029363-6.6564976-3.0134295-1.86311-6.4628491-3.4330878-10.3482587-4.7099336-3.8854095-1.2768458-7.7822651-1.9142256-11.6905667-1.9121443-3.9083017.0020914-7.8051573.6154781-11.6905668 1.8401652-3.8854096 1.2246871-7.3702078 2.8301329-10.4543947 4.8163375-3.0841869 1.9862045-6.0278997 4.1695691-8.8311384 6.5500937s-5.2048256 4.7652219-7.2047605 7.1540919c-1.99993501 2.38887-3.75430043 4.5722346-5.26309632 6.5500938s-2.63883199 3.583305-3.39010829 4.8163374l-1.13003609 1.8401602c.2830293.4715149.67115403 1.1088946 1.16437421 1.9121391.49322017.8032445 1.5878776 2.3617475 3.28397229 4.6755089s3.47439274 4.521119 5.3348942 6.6220728c1.8605014 2.1009538 4.2506422 4.4387083 7.1704224 7.0132633 2.9197801 2.5745551 5.8874256 4.7819127 8.9029363 6.6220729 3.0155106 1.8401601 6.4774168 3.398663 10.3857184 4.6755088 3.9083017 1.2768458 7.8176438 1.9142256 11.7280266 1.9121443 3.9103827-.0020914 7.7957922-.6154781 11.6562286-1.8401652s7.3337886-2.818658 10.4200566-4.7819127 6.0299808-4.1351444 8.8311384-6.515669 5.2152311-4.7652219 7.2422203-7.1540919 3.8052873-4.5607597 5.3348942-6.515669c1.5296068-1.9549093 2.6721295-3.5488802 3.427568-4.7819127zm-24.5142913 0c0 6.467683-2.3079374 12.0152859-6.9238123 16.6428087s-10.1495139 6.9412843-16.600917 6.9412843c-6.4992683 0-12.0453939-2.3137615-16.6383767-6.9412843s-6.8894742-10.1751257-6.8894742-16.6428087 2.2964914-12.003811 6.8894742-16.608384 10.1391084-6.9068595 16.6383767-6.9068595c6.4534842 0 11.9871232 2.3022865 16.600917 6.9068595s6.9217312 10.140701 6.9238123 16.608384zm-23.5247293-10.552755c2.8261308 0 5.2870289 1.0619518 7.3826944 3.1858555 2.0956655 2.1239036 3.1434982 4.5795368 3.1434982 7.3668995 0 2.8332624-1.0478327 5.2888956-3.1434982 7.3668995-2.0956655 2.078004-4.5565636 3.1170059-7.3826944 3.1170059-2.873996 0-5.3348941-1.0264838-7.3826944-3.0794516-2.0478002-2.0529677-3.0717003-4.5200758-3.0717003-7.4013243 0-2.8332624 1.0239001-5.3003705 3.0717003-7.4013243 2.0478003-2.1009538 4.5086984-3.1514307 7.3826944-3.1514307z" fill="#000"></path></svg>
|
|
60
|
-
// </span>
|
|
61
|
-
// <span class="eye-closed"><!--?lit$141655362$-->
|
|
62
|
-
// <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="m97.5245976 14.5407294-15.0809624 14.6188347c3.3026825 2.8601369 6.4111526 6.0234269 9.3254105 9.48987 2.9142578 3.4664431 5.0023086 6.2183876 6.2641522 8.2558335l1.9668021 3.1268688c-.291855.4841879-.6920826 1.1386987-1.2006828 1.9635322s-1.6502683 2.4252247-3.4250041 4.8011737c-1.7747358 2.3759489-3.6202894 4.6426342-5.5366607 6.8000558-1.9163713 2.1574217-4.3810437 4.5580085-7.3940172 7.2017606-3.0129735 2.643752-6.0731589 4.9104373-9.180556 6.8000558-3.1073972 1.8896186-6.6643798 3.4900098-10.6709478 4.8011737-4.0065681 1.3111639-8.0249391 1.9656747-12.055113 1.9635322-6.7019347 0-13.2343359-1.6732336-19.5972037-5.019701l-17.1185824 16.6562806-10.27179318-10.6917703 14.93288898-14.5449211c-3.2533247-2.8601369-6.3371159-6.0116436-9.25137378-9.45452-2.91425785-3.4428764-5.02698749-6.1819664-6.33818892-8.2172698l-1.8927654-3.0529552c.29185498-.4841879.69208259-1.1386987 1.20068282-1.9635322.50860022-.8248335 1.65026824-2.437008 3.42500406-4.8365236 1.77473582-2.3995157 3.62028938-4.6908389 5.53666072-6.8739696 1.9163713-2.1831307 4.3810437-4.5955009 7.3940172-7.2371105s6.0731589-4.9200783 9.180556-6.8354059c3.1073972-1.9153277 6.6772558-3.5275022 10.7095757-4.8365237 4.03232-1.3090215 8.0635669-1.9635322 12.0937409-1.9635322 6.5560071 0 13.0637294 1.6968003 19.5231669 5.090401l17.1185824-16.5823669zm-46.478979 24.584323 10.7803934-10.473243c-3.5451796-1.891761-7.3092505-2.8376415-11.2922126-2.8376415-6.6547228 0-12.3609169 2.3641657-17.1185824 7.0924969-4.7576654 4.7283312-7.1375711 10.437893-7.1397171 17.1286852 0 3.8306553.8251341 7.3945787 2.4754024 10.6917703l10.9284669-10.5471566v-.1446137c0-2.9094127 1.0687043-5.4546132 3.2061128-7.6356015 2.1374086-2.1809883 4.6868477-3.2714825 7.6483174-3.2714825h.5086002zm-1.1652739 21.5988543-10.7803935 10.6178566c3.5945375 1.9388943 7.4068932 2.9083415 11.4370672 2.9083415 6.6547228 0 12.3491139-2.375949 17.0831734-7.1278469s7.1021623-10.4486051 7.1043083-17.0901215c0-4.0234736-.874492-7.6356015-2.6234759-10.836384l-10.7095757 10.473243v.363141c0 2.9586884-1.0687042 5.4803223-3.2061128 7.5649015-2.1374085 2.0845792-4.6868476 3.1268688-7.6483173 3.1268688z" fill="#000"></path></svg>
|
|
63
|
-
// </span>
|
|
64
|
-
// </label>
|
|
65
|
-
// </div>
|
|
66
|
-
// <label class="facet-info-display" for="mediatype:texts-show-only" title="Only show mediatype: texts">
|
|
67
|
-
// <div class="facet-title"><!--?lit$141655362$--><!--?lit$141655362$-->texts<!--?--></div>
|
|
68
|
-
// <div class="facet-count"><!--?lit$141655362$-->51</div>
|
|
69
|
-
// </label>
|
|
70
|
-
// </div>
|
|
71
|
-
// */
|
|
72
|
-
//# sourceMappingURL=facet-group.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"facet-group.js","sourceRoot":"","sources":["../../../src/collection-facets/facet-group.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,sEAAsE;AAEtE,gCAAgC;AAChC,+CAA+C;AAE/C,wBAAwB;AACxB,mBAAmB;AACnB,sBAAsB;AACtB,sBAAsB;AACtB,QAAQ;AACR,MAAM;AAEN,0CAA0C;AAC1C,kBAAkB;AAClB,gBAAgB;AAChB,+BAA+B;AAC/B,yBAAyB;AACzB,8BAA8B;AAC9B,4BAA4B;AAC5B,6BAA6B;AAC7B,2BAA2B;AAC3B,UAAU;AAEV,qCAAqC;AACrC,iCAAiC;AACjC,gCAAgC;AAChC,yBAAyB;AACzB,+BAA+B;AAC/B,UAAU;AAEV,4CAA4C;AAC5C,2BAA2B;AAC3B,6BAA6B;AAC7B,UAAU;AAEV,0CAA0C;AAC1C,yBAAyB;AACzB,UAAU;AAEV,sCAAsC;AACtC,uBAAuB;AACvB,wBAAwB;AACxB,2BAA2B;AAC3B,wBAAwB;AACxB,UAAU;AAEV,yCAAyC;AACzC,kCAAkC;AAClC,yBAAyB;AACzB,mBAAmB;AACnB,UAAU;AAEV,kCAAkC;AAClC,mBAAmB;AACnB,UAAU;AAGV,QAAQ;AACR,MAAM;AACN,IAAI;AAEJ,MAAM;AAEN,0BAA0B;AAC1B,iDAAiD;AACjD,6KAA6K;AAC7K,uIAAuI;AACvI,mHAAmH;AACnH,iEAAiE;AACjE,60EAA60E;AAC70E,UAAU;AACV,wEAAwE;AACxE,8rEAA8rE;AAC9rE,UAAU;AACV,+BAA+B;AAC/B,2BAA2B;AAE3B,0HAA0H;AAC1H,+GAA+G;AAC/G,8EAA8E;AAC9E,6BAA6B;AAC7B,yBAAyB;AAEzB,MAAM","sourcesContent":["// import { LitElement, html, css, CSSResultGroup } from \"lit\";\n// import { query, property, customElement } from \"lit/decorators.js\";\n\n// @customElement('facet-group')\n// export class FacetGroup extends LitElement {\n\n// override render() {\n// return html`\n// <slot></slot>\n// <slot></slot>\n// `\n// }\n\n// static get styles(): CSSResultGroup {\n// return css`\n// :host {\n// margin-bottom: 1rem;\n// display: flex;\n// align-items: start;\n// font-weight: 500;\n// font-size: 1.2rem;\n// cursor: pointer;\n// }\n\n// ::slotted(.facet-checkbox) {\n// border: 1px solid red;\n// margin-right: 0.5rem;\n// display: flex;\n// align-items: center;\n// }\n\n// ::slotted(.select-facet-checkbox) {\n// cursor: pointer;\n// margin-right: 5px;\n// }\n\n// ::slotted(.hide-facet-checkbox) {\n// display: none;\n// }\n\n// ::slotted(.hide-facet-icon) {\n// width: 15px;\n// height: 15px;\n// cursor: pointer;\n// opacity: 0.3;\n// }\n\n// ::slotted(.facet-info-display) {\n// border: 1px solid blue;\n// display: flex;\n// flex: 1;\n// }\n\n// ::slotted(.facet-title) {\n// flex: 1;\n// }\n\n\n// `\n// }\n// )\n\n// /**\n\n// <div class=\"facet-row\">\n// <div class=\"facet-checkbox\">\n// <input type=\"checkbox\" class=\"select-facet-checkbox\" name=\"mediatype\" value=\"texts\" title=\"Only show mediatype: texts\" id=\"mediatype:texts-show-only\">\n// <input type=\"checkbox\" class=\"hide-facet-checkbox\" id=\"mediatype:texts-negative\" name=\"mediatype\" value=\"texts\">\n// <label for=\"mediatype:texts-negative\" class=\"hide-facet-icon\" title=\"Hide mediatype: texts\">\n// <span class=\"eye\"><!--?lit$141655362$-->\n// <svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m98 50.5704143c-.2830293-.471515-.671154-1.1088947-1.1643742-1.9121392s-1.6003642-2.3617474-3.3214321-4.6755089c-1.7210678-2.3137614-3.522258-4.5325939-5.4035703-6.6564975-1.8813124-2.1239037-4.2828993-4.473133-7.2047606-7.0476881-2.9218612-2.5745551-5.8895067-4.7933876-8.9029363-6.6564976-3.0134295-1.86311-6.4628491-3.4330878-10.3482587-4.7099336-3.8854095-1.2768458-7.7822651-1.9142256-11.6905667-1.9121443-3.9083017.0020914-7.8051573.6154781-11.6905668 1.8401652-3.8854096 1.2246871-7.3702078 2.8301329-10.4543947 4.8163375-3.0841869 1.9862045-6.0278997 4.1695691-8.8311384 6.5500937s-5.2048256 4.7652219-7.2047605 7.1540919c-1.99993501 2.38887-3.75430043 4.5722346-5.26309632 6.5500938s-2.63883199 3.583305-3.39010829 4.8163374l-1.13003609 1.8401602c.2830293.4715149.67115403 1.1088946 1.16437421 1.9121391.49322017.8032445 1.5878776 2.3617475 3.28397229 4.6755089s3.47439274 4.521119 5.3348942 6.6220728c1.8605014 2.1009538 4.2506422 4.4387083 7.1704224 7.0132633 2.9197801 2.5745551 5.8874256 4.7819127 8.9029363 6.6220729 3.0155106 1.8401601 6.4774168 3.398663 10.3857184 4.6755088 3.9083017 1.2768458 7.8176438 1.9142256 11.7280266 1.9121443 3.9103827-.0020914 7.7957922-.6154781 11.6562286-1.8401652s7.3337886-2.818658 10.4200566-4.7819127 6.0299808-4.1351444 8.8311384-6.515669 5.2152311-4.7652219 7.2422203-7.1540919 3.8052873-4.5607597 5.3348942-6.515669c1.5296068-1.9549093 2.6721295-3.5488802 3.427568-4.7819127zm-24.5142913 0c0 6.467683-2.3079374 12.0152859-6.9238123 16.6428087s-10.1495139 6.9412843-16.600917 6.9412843c-6.4992683 0-12.0453939-2.3137615-16.6383767-6.9412843s-6.8894742-10.1751257-6.8894742-16.6428087 2.2964914-12.003811 6.8894742-16.608384 10.1391084-6.9068595 16.6383767-6.9068595c6.4534842 0 11.9871232 2.3022865 16.600917 6.9068595s6.9217312 10.140701 6.9238123 16.608384zm-23.5247293-10.552755c2.8261308 0 5.2870289 1.0619518 7.3826944 3.1858555 2.0956655 2.1239036 3.1434982 4.5795368 3.1434982 7.3668995 0 2.8332624-1.0478327 5.2888956-3.1434982 7.3668995-2.0956655 2.078004-4.5565636 3.1170059-7.3826944 3.1170059-2.873996 0-5.3348941-1.0264838-7.3826944-3.0794516-2.0478002-2.0529677-3.0717003-4.5200758-3.0717003-7.4013243 0-2.8332624 1.0239001-5.3003705 3.0717003-7.4013243 2.0478003-2.1009538 4.5086984-3.1514307 7.3826944-3.1514307z\" fill=\"#000\"></path></svg>\n// </span>\n// <span class=\"eye-closed\"><!--?lit$141655362$-->\n// <svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m97.5245976 14.5407294-15.0809624 14.6188347c3.3026825 2.8601369 6.4111526 6.0234269 9.3254105 9.48987 2.9142578 3.4664431 5.0023086 6.2183876 6.2641522 8.2558335l1.9668021 3.1268688c-.291855.4841879-.6920826 1.1386987-1.2006828 1.9635322s-1.6502683 2.4252247-3.4250041 4.8011737c-1.7747358 2.3759489-3.6202894 4.6426342-5.5366607 6.8000558-1.9163713 2.1574217-4.3810437 4.5580085-7.3940172 7.2017606-3.0129735 2.643752-6.0731589 4.9104373-9.180556 6.8000558-3.1073972 1.8896186-6.6643798 3.4900098-10.6709478 4.8011737-4.0065681 1.3111639-8.0249391 1.9656747-12.055113 1.9635322-6.7019347 0-13.2343359-1.6732336-19.5972037-5.019701l-17.1185824 16.6562806-10.27179318-10.6917703 14.93288898-14.5449211c-3.2533247-2.8601369-6.3371159-6.0116436-9.25137378-9.45452-2.91425785-3.4428764-5.02698749-6.1819664-6.33818892-8.2172698l-1.8927654-3.0529552c.29185498-.4841879.69208259-1.1386987 1.20068282-1.9635322.50860022-.8248335 1.65026824-2.437008 3.42500406-4.8365236 1.77473582-2.3995157 3.62028938-4.6908389 5.53666072-6.8739696 1.9163713-2.1831307 4.3810437-4.5955009 7.3940172-7.2371105s6.0731589-4.9200783 9.180556-6.8354059c3.1073972-1.9153277 6.6772558-3.5275022 10.7095757-4.8365237 4.03232-1.3090215 8.0635669-1.9635322 12.0937409-1.9635322 6.5560071 0 13.0637294 1.6968003 19.5231669 5.090401l17.1185824-16.5823669zm-46.478979 24.584323 10.7803934-10.473243c-3.5451796-1.891761-7.3092505-2.8376415-11.2922126-2.8376415-6.6547228 0-12.3609169 2.3641657-17.1185824 7.0924969-4.7576654 4.7283312-7.1375711 10.437893-7.1397171 17.1286852 0 3.8306553.8251341 7.3945787 2.4754024 10.6917703l10.9284669-10.5471566v-.1446137c0-2.9094127 1.0687043-5.4546132 3.2061128-7.6356015 2.1374086-2.1809883 4.6868477-3.2714825 7.6483174-3.2714825h.5086002zm-1.1652739 21.5988543-10.7803935 10.6178566c3.5945375 1.9388943 7.4068932 2.9083415 11.4370672 2.9083415 6.6547228 0 12.3491139-2.375949 17.0831734-7.1278469s7.1021623-10.4486051 7.1043083-17.0901215c0-4.0234736-.874492-7.6356015-2.6234759-10.836384l-10.7095757 10.473243v.363141c0 2.9586884-1.0687042 5.4803223-3.2061128 7.5649015-2.1374085 2.0845792-4.6868476 3.1268688-7.6483173 3.1268688z\" fill=\"#000\"></path></svg>\n// </span>\n// </label>\n// </div>\n\n// <label class=\"facet-info-display\" for=\"mediatype:texts-show-only\" title=\"Only show mediatype: texts\">\n// <div class=\"facet-title\"><!--?lit$141655362$--><!--?lit$141655362$-->texts<!--?--></div>\n// <div class=\"facet-count\"><!--?lit$141655362$-->51</div>\n// </label>\n// </div>\n\n// */"]}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"facet-group-styles.js","sourceRoot":"","sources":["../../../src/styles/facet-group-styles.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|