@internetarchive/collection-browser 2.18.1-alpha-webdev7768.0 → 2.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,175 +1,175 @@
1
- import { css, html, LitElement, CSSResultGroup, TemplateResult } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
- import { ifDefined } from 'lit/directives/if-defined.js';
4
- import { msg } from '@lit/localize';
5
- import type { ModalManagerInterface } from '@internetarchive/modal-manager';
6
- import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
7
- import { BinSnappingInterval } from '@internetarchive/histogram-date-range';
8
- import {
9
- analyticsActions,
10
- analyticsCategories,
11
- } from './utils/analytics-events';
12
-
13
- import '@internetarchive/histogram-date-range';
14
-
15
- @customElement('expanded-date-picker')
16
- export class ExpandedDatePicker extends LitElement {
17
- @property({ type: String }) minDate?: string;
18
-
19
- @property({ type: String }) maxDate?: string;
20
-
21
- @property({ type: String }) minSelectedDate?: string;
22
-
23
- @property({ type: String }) maxSelectedDate?: string;
24
-
25
- @property({ type: Array }) buckets?: number[];
26
-
27
- @property({ type: String }) dateFormat: string = 'YYYY';
28
-
29
- @property({ type: String }) tooltipDateFormat?: string;
30
-
31
- @property({ type: String }) binSnapping?: BinSnappingInterval;
32
-
33
- @property({ type: Object, attribute: false })
34
- modalManager?: ModalManagerInterface;
35
-
36
- @property({ type: Object, attribute: false })
37
- analyticsHandler?: AnalyticsManagerInterface;
38
-
39
- render(): TemplateResult {
40
- return html`
41
- <div id="container">
42
- <histogram-date-range
43
- id="date-picker"
44
- .minDate=${this.minDate}
45
- .maxDate=${this.maxDate}
46
- .minSelectedDate=${this.minSelectedDate ?? this.minDate}
47
- .maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
48
- .dateFormat=${this.dateFormat}
49
- tooltipDateFormat=${ifDefined(this.tooltipDateFormat)}
50
- binSnapping=${ifDefined(this.binSnapping)}
51
- .updateDelay=${0}
52
- updateWhileFocused
53
- missingDataMessage="..."
54
- .width=${560}
55
- .height=${120}
56
- .bins=${this.buckets}
57
- @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
58
- >
59
- <button
60
- id="apply-btn"
61
- slot="inputs-right-side"
62
- @click=${this.applyBtnClicked}
63
- >
64
- ${msg('Apply date range')}
65
- </button>
66
- </histogram-date-range>
67
- </div>
68
- `;
69
- }
70
-
71
- connectedCallback(): void {
72
- super.connectedCallback?.();
73
- this.setupEscapeListener();
74
- }
75
-
76
- disconnectedCallback(): void {
77
- super.disconnectedCallback?.();
78
- this.removeEscapeListener();
79
- }
80
-
81
- /**
82
- * Add an event listener to close the date picker modal when the Esc key is pressed
83
- */
84
- private setupEscapeListener() {
85
- document.addEventListener('keydown', this.boundEscapeListener);
86
- }
87
-
88
- /**
89
- * Remove the Esc key listener that was previously added
90
- */
91
- private removeEscapeListener() {
92
- document.removeEventListener('keydown', this.boundEscapeListener);
93
- }
94
-
95
- /**
96
- * Closes the modal dialog if the given event is pressing the Esc key.
97
- * Arrow function to ensure `this` remains bound to the current component.
98
- */
99
- private boundEscapeListener = (e: KeyboardEvent) => {
100
- if (e.key === 'Escape') {
101
- this.closeModal();
102
- }
103
- };
104
-
105
- /**
106
- * When the histogram is updated, keep track of the newly selected date range.
107
- * We don't commit to the new range until the apply button is clicked.
108
- */
109
- private histogramDateRangeUpdated(
110
- e: CustomEvent<{
111
- minDate: string;
112
- maxDate: string;
113
- }>,
114
- ): void {
115
- this.minSelectedDate = e.detail.minDate;
116
- this.maxSelectedDate = e.detail.maxDate;
117
- }
118
-
119
- /**
120
- * When the Apply button is clicked, emit the current date range and close the modal.
121
- */
122
- private applyBtnClicked(): void {
123
- const event = new CustomEvent('histogramDateRangeApplied', {
124
- detail: {
125
- minDate: this.minSelectedDate,
126
- maxDate: this.maxSelectedDate,
127
- },
128
- });
129
- this.dispatchEvent(event);
130
- this.closeModal();
131
-
132
- this.analyticsHandler?.sendEvent({
133
- category: analyticsCategories.default,
134
- action: analyticsActions.histogramChangedFromModal,
135
- label: window.location.href,
136
- });
137
- }
138
-
139
- /**
140
- * Closes the modal associated with this component (if it exists) and dispatches a
141
- * modalClosed event.
142
- */
143
- private closeModal(): void {
144
- if (this.modalManager) {
145
- this.modalManager.closeModal();
146
- this.dispatchEvent(new CustomEvent('modalClosed'));
147
- }
148
- }
149
-
150
- static get styles(): CSSResultGroup {
151
- return css`
152
- #container {
153
- display: flex;
154
- justify-content: center;
155
- padding: 40px 10px 10px;
156
- overflow: hidden;
157
- }
158
-
159
- #date-picker {
160
- --histogramDateRangeInputWidth: 50px;
161
- --histogramDateRangeInputRowMargin: 5px 0 0 0;
162
- }
163
-
164
- #apply-btn {
165
- margin: 0 0 0 5px;
166
- padding: 8px 10px;
167
- border: 0;
168
- border-radius: 4px;
169
- background: var(--primaryButtonBGColor, #194880);
170
- color: white;
171
- cursor: pointer;
172
- }
173
- `;
174
- }
175
- }
1
+ import { css, html, LitElement, CSSResultGroup, TemplateResult } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
+ import { msg } from '@lit/localize';
5
+ import type { ModalManagerInterface } from '@internetarchive/modal-manager';
6
+ import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
7
+ import { BinSnappingInterval } from '@internetarchive/histogram-date-range';
8
+ import {
9
+ analyticsActions,
10
+ analyticsCategories,
11
+ } from './utils/analytics-events';
12
+
13
+ import '@internetarchive/histogram-date-range';
14
+
15
+ @customElement('expanded-date-picker')
16
+ export class ExpandedDatePicker extends LitElement {
17
+ @property({ type: String }) minDate?: string;
18
+
19
+ @property({ type: String }) maxDate?: string;
20
+
21
+ @property({ type: String }) minSelectedDate?: string;
22
+
23
+ @property({ type: String }) maxSelectedDate?: string;
24
+
25
+ @property({ type: Array }) buckets?: number[];
26
+
27
+ @property({ type: String }) dateFormat: string = 'YYYY';
28
+
29
+ @property({ type: String }) tooltipDateFormat?: string;
30
+
31
+ @property({ type: String }) binSnapping?: BinSnappingInterval;
32
+
33
+ @property({ type: Object, attribute: false })
34
+ modalManager?: ModalManagerInterface;
35
+
36
+ @property({ type: Object, attribute: false })
37
+ analyticsHandler?: AnalyticsManagerInterface;
38
+
39
+ render(): TemplateResult {
40
+ return html`
41
+ <div id="container">
42
+ <histogram-date-range
43
+ id="date-picker"
44
+ .minDate=${this.minDate}
45
+ .maxDate=${this.maxDate}
46
+ .minSelectedDate=${this.minSelectedDate ?? this.minDate}
47
+ .maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
48
+ .dateFormat=${this.dateFormat}
49
+ tooltipDateFormat=${ifDefined(this.tooltipDateFormat)}
50
+ binSnapping=${ifDefined(this.binSnapping)}
51
+ .updateDelay=${0}
52
+ updateWhileFocused
53
+ missingDataMessage="..."
54
+ .width=${560}
55
+ .height=${120}
56
+ .bins=${this.buckets}
57
+ @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
58
+ >
59
+ <button
60
+ id="apply-btn"
61
+ slot="inputs-right-side"
62
+ @click=${this.applyBtnClicked}
63
+ >
64
+ ${msg('Apply date range')}
65
+ </button>
66
+ </histogram-date-range>
67
+ </div>
68
+ `;
69
+ }
70
+
71
+ connectedCallback(): void {
72
+ super.connectedCallback?.();
73
+ this.setupEscapeListener();
74
+ }
75
+
76
+ disconnectedCallback(): void {
77
+ super.disconnectedCallback?.();
78
+ this.removeEscapeListener();
79
+ }
80
+
81
+ /**
82
+ * Add an event listener to close the date picker modal when the Esc key is pressed
83
+ */
84
+ private setupEscapeListener() {
85
+ document.addEventListener('keydown', this.boundEscapeListener);
86
+ }
87
+
88
+ /**
89
+ * Remove the Esc key listener that was previously added
90
+ */
91
+ private removeEscapeListener() {
92
+ document.removeEventListener('keydown', this.boundEscapeListener);
93
+ }
94
+
95
+ /**
96
+ * Closes the modal dialog if the given event is pressing the Esc key.
97
+ * Arrow function to ensure `this` remains bound to the current component.
98
+ */
99
+ private boundEscapeListener = (e: KeyboardEvent) => {
100
+ if (e.key === 'Escape') {
101
+ this.closeModal();
102
+ }
103
+ };
104
+
105
+ /**
106
+ * When the histogram is updated, keep track of the newly selected date range.
107
+ * We don't commit to the new range until the apply button is clicked.
108
+ */
109
+ private histogramDateRangeUpdated(
110
+ e: CustomEvent<{
111
+ minDate: string;
112
+ maxDate: string;
113
+ }>,
114
+ ): void {
115
+ this.minSelectedDate = e.detail.minDate;
116
+ this.maxSelectedDate = e.detail.maxDate;
117
+ }
118
+
119
+ /**
120
+ * When the Apply button is clicked, emit the current date range and close the modal.
121
+ */
122
+ private applyBtnClicked(): void {
123
+ const event = new CustomEvent('histogramDateRangeApplied', {
124
+ detail: {
125
+ minDate: this.minSelectedDate,
126
+ maxDate: this.maxSelectedDate,
127
+ },
128
+ });
129
+ this.dispatchEvent(event);
130
+ this.closeModal();
131
+
132
+ this.analyticsHandler?.sendEvent({
133
+ category: analyticsCategories.default,
134
+ action: analyticsActions.histogramChangedFromModal,
135
+ label: window.location.href,
136
+ });
137
+ }
138
+
139
+ /**
140
+ * Closes the modal associated with this component (if it exists) and dispatches a
141
+ * modalClosed event.
142
+ */
143
+ private closeModal(): void {
144
+ if (this.modalManager) {
145
+ this.modalManager.closeModal();
146
+ this.dispatchEvent(new CustomEvent('modalClosed'));
147
+ }
148
+ }
149
+
150
+ static get styles(): CSSResultGroup {
151
+ return css`
152
+ #container {
153
+ display: flex;
154
+ justify-content: center;
155
+ padding: 40px 10px 10px;
156
+ overflow: hidden;
157
+ }
158
+
159
+ #date-picker {
160
+ --histogramDateRangeInputWidth: 50px;
161
+ --histogramDateRangeInputRowMargin: 5px 0 0 0;
162
+ }
163
+
164
+ #apply-btn {
165
+ margin: 0 0 0 5px;
166
+ padding: 8px 10px;
167
+ border: 0;
168
+ border-radius: 4px;
169
+ background: var(--primaryButtonBGColor, #194880);
170
+ color: white;
171
+ cursor: pointer;
172
+ }
173
+ `;
174
+ }
175
+ }
@@ -16,7 +16,7 @@ export const baseTileStyles = css`
16
16
  background-color: ${tileBackgroundColor};
17
17
  border: 1px #2c2c2c;
18
18
  border-radius: ${tileCornerRadius};
19
- /*box-shadow: 1px 1px 2px 0;*/
19
+ box-shadow: 1px 1px 2px 0;
20
20
  box-sizing: border-box;
21
21
  height: 100%;
22
22
  display: flex;
@@ -433,7 +433,7 @@ export class TileDispatcher
433
433
  }
434
434
 
435
435
  #container.hoverable:hover {
436
- box-shadow: 0 0 10px 0px rgba(8, 8, 32, 0.15);
436
+ box-shadow: 0 0 6px 2px rgba(8, 8, 32, 0.8);
437
437
  transition: box-shadow 0.1s ease;
438
438
  }
439
439
 
package/tsconfig.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": false,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "importHelpers": true,
13
- "outDir": "dist",
14
- "sourceMap": true,
15
- "inlineSources": true,
16
- "rootDir": "./",
17
- "declaration": true,
18
- },
19
- "include": ["src", "test", "index.ts", "types"],
20
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "noEmitOnError": true,
7
+ "lib": ["es2017", "dom"],
8
+ "strict": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "experimentalDecorators": true,
12
+ "importHelpers": true,
13
+ "outDir": "dist",
14
+ "sourceMap": true,
15
+ "inlineSources": true,
16
+ "rootDir": "./",
17
+ "declaration": true,
18
+ },
19
+ "include": ["src", "test", "index.ts", "types"],
20
+ }
@@ -1,30 +1,30 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- nodeResolve: true,
8
- open: '/',
9
- watch: !hmr,
10
-
11
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
12
- // esbuildTarget: 'auto'
13
-
14
- /** Set appIndex to enable SPA routing */
15
- // appIndex: 'demo/index.html',
16
-
17
- /** Confgure bare import resolve plugin */
18
- // nodeResolve: {
19
- // exportConditions: ['browser', 'development']
20
- // },
21
-
22
- plugins: [
23
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
24
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
25
- ],
26
-
27
- http2: true,
28
- sslCert: './local.archive.org.cert',
29
- sslKey: './local.archive.org.key',
30
- });
1
+ // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
+
3
+ /** Use Hot Module replacement by adding --hmr to the start command */
4
+ const hmr = process.argv.includes('--hmr');
5
+
6
+ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
+ nodeResolve: true,
8
+ open: '/',
9
+ watch: !hmr,
10
+
11
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
12
+ // esbuildTarget: 'auto'
13
+
14
+ /** Set appIndex to enable SPA routing */
15
+ // appIndex: 'demo/index.html',
16
+
17
+ /** Confgure bare import resolve plugin */
18
+ // nodeResolve: {
19
+ // exportConditions: ['browser', 'development']
20
+ // },
21
+
22
+ plugins: [
23
+ /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
24
+ // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
25
+ ],
26
+
27
+ http2: true,
28
+ sslCert: './local.archive.org.cert',
29
+ sslKey: './local.archive.org.key',
30
+ });
@@ -1,41 +1,41 @@
1
- // import { playwrightLauncher } from '@web/test-runner-playwright';
2
-
3
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
-
5
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
- /** Test files to run */
7
- files: 'dist/test/**/*.test.js',
8
-
9
- /** Resolve bare module imports */
10
- nodeResolve: {
11
- exportConditions: ['browser', 'development'],
12
- },
13
-
14
- /** Filter out lit dev mode logs */
15
- filterBrowserLogs(log) {
16
- for (const arg of log.args) {
17
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- },
23
-
24
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
- // esbuildTarget: 'auto',
26
-
27
- /** Amount of browsers to run concurrently */
28
- // concurrentBrowsers: 2,
29
-
30
- /** Amount of test files per browser to test concurrently */
31
- // concurrency: 1,
32
-
33
- /** Browsers to run tests on */
34
- // browsers: [
35
- // playwrightLauncher({ product: 'chromium' }),
36
- // playwrightLauncher({ product: 'firefox' }),
37
- // playwrightLauncher({ product: 'webkit' }),
38
- // ],
39
-
40
- // See documentation for all available options
41
- });
1
+ // import { playwrightLauncher } from '@web/test-runner-playwright';
2
+
3
+ const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
+
5
+ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
+ /** Test files to run */
7
+ files: 'dist/test/**/*.test.js',
8
+
9
+ /** Resolve bare module imports */
10
+ nodeResolve: {
11
+ exportConditions: ['browser', 'development'],
12
+ },
13
+
14
+ /** Filter out lit dev mode logs */
15
+ filterBrowserLogs(log) {
16
+ for (const arg of log.args) {
17
+ if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
+ return false;
19
+ }
20
+ }
21
+ return true;
22
+ },
23
+
24
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
+ // esbuildTarget: 'auto',
26
+
27
+ /** Amount of browsers to run concurrently */
28
+ // concurrentBrowsers: 2,
29
+
30
+ /** Amount of test files per browser to test concurrently */
31
+ // concurrency: 1,
32
+
33
+ /** Browsers to run tests on */
34
+ // browsers: [
35
+ // playwrightLauncher({ product: 'chromium' }),
36
+ // playwrightLauncher({ product: 'firefox' }),
37
+ // playwrightLauncher({ product: 'webkit' }),
38
+ // ],
39
+
40
+ // See documentation for all available options
41
+ });