@internetarchive/histogram-date-range 1.4.1-alpha1 → 1.4.2-alpha-webdev8495.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.
@@ -1,10 +1,10 @@
1
- module.exports = {
2
- buildOptions: {
3
- out: 'docs',
4
- },
5
- mount: {
6
- 'demo/js': { url: '/dist/demo/js' },
7
- demo: { url: '/demo' },
8
- src: { url: '/dist/src' },
9
- },
10
- };
1
+ module.exports = {
2
+ buildOptions: {
3
+ out: 'docs',
4
+ },
5
+ mount: {
6
+ 'demo/js': { url: '/dist/demo/js' },
7
+ demo: { url: '/demo' },
8
+ src: { url: '/dist/src' },
9
+ },
10
+ };
@@ -204,7 +204,6 @@ export class HistogramDateRange extends LitElement {
204
204
  ) + this.snapEndOffset;
205
205
 
206
206
  this._binWidth = this._histWidth / this._numBins;
207
- this._previousDateRange = this.currentDateRangeString;
208
207
  this._histData = this.calculateHistData();
209
208
  this.minSelectedDate = this.minSelectedDate
210
209
  ? this.minSelectedDate
@@ -984,22 +983,18 @@ export class HistogramDateRange extends LitElement {
984
983
  `;
985
984
  }
986
985
 
987
- private get histogramAccessibility(): TemplateResult {
988
- let rangeText: string;
986
+ private get histogramAccessibilityTemplate(): TemplateResult {
987
+ let rangeText: string = '';
989
988
  if (this.minSelectedDate && this.maxSelectedDate) {
990
- rangeText = `from ${this.minSelectedDate} to ${this.maxSelectedDate}`;
989
+ rangeText = ` from ${this.minSelectedDate} to ${this.maxSelectedDate}`;
991
990
  } else if (this.minSelectedDate) {
992
- rangeText = `from ${this.minSelectedDate}`;
991
+ rangeText = ` from ${this.minSelectedDate}`;
993
992
  } else if (this.maxSelectedDate) {
994
- rangeText = `up to ${this.maxSelectedDate}`;
995
- } else {
996
- rangeText = 'for all available dates';
993
+ rangeText = ` up to ${this.maxSelectedDate}`;
997
994
  }
998
995
 
999
- const titleText = `Filter results distribution ${rangeText}`;
1000
-
1001
- const descText =
1002
- `This chart shows the distribution of search results ${rangeText}. The bars represent result counts for each time period within the selected date range.`.trim();
996
+ const titleText = `Filter results for dates${rangeText}`;
997
+ const descText = `This histogram shows the distribution of dates${rangeText}`;
1003
998
 
1004
999
  return html`<title id="histogram-title">${titleText}</title
1005
1000
  ><desc id="histogram-desc">${descText}</desc>`;
@@ -1169,7 +1164,7 @@ export class HistogramDateRange extends LitElement {
1169
1164
  aria-labelledby="histogram-title histogram-desc"
1170
1165
  @pointerleave="${this.drop}"
1171
1166
  >
1172
- ${this.histogramAccessibility} ${this.selectedRangeTemplate}
1167
+ ${this.histogramAccessibilityTemplate} ${this.selectedRangeTemplate}
1173
1168
  <svg id="histogram">${this.histogramTemplate}</svg>
1174
1169
  ${this.minSliderTemplate} ${this.maxSliderTemplate}
1175
1170
  </svg>
@@ -436,6 +436,25 @@ describe('HistogramDateRange', () => {
436
436
  expect(eventCount).to.equal(1); // only one event was fired
437
437
  });
438
438
 
439
+ it('emits a custom event when sliders are dragged to a new range', async () => {
440
+ const el = await createCustomElementInHTMLContainer();
441
+ el.updateDelay = 0;
442
+ await el.updateComplete;
443
+
444
+ const minSlider = el.shadowRoot?.querySelector('#slider-min') as SVGElement;
445
+
446
+ const updateEventPromise = oneEvent(el, 'histogramDateRangeUpdated');
447
+
448
+ // simulate dragging the min slider to the right and releasing
449
+ minSlider.dispatchEvent(new PointerEvent('pointerdown'));
450
+ window.dispatchEvent(new PointerEvent('pointermove', { clientX: 75 }));
451
+ window.dispatchEvent(new PointerEvent('pointerup'));
452
+
453
+ const { detail } = await updateEventPromise;
454
+ expect(detail.minDate).to.equal('5/21/1950');
455
+ expect(detail.maxDate).to.equal('12/4/2020');
456
+ });
457
+
439
458
  it('shows/hides tooltip when hovering over (or pointing at) a bar', async () => {
440
459
  const el = await createCustomElementInHTMLContainer();
441
460
  // include a number which will require commas (1,000,000)
@@ -1003,7 +1022,7 @@ describe('HistogramDateRange', () => {
1003
1022
  );
1004
1023
  const svg = el.shadowRoot?.querySelector('svg') as SVGElement;
1005
1024
  expect(svg.querySelector('title')?.textContent).to.equal(
1006
- 'Filter results distribution from 1900 to 2020'
1025
+ 'Filter results for dates from 1900 to 2020'
1007
1026
  );
1008
1027
  });
1009
1028
 
@@ -1016,7 +1035,7 @@ describe('HistogramDateRange', () => {
1016
1035
  );
1017
1036
  const svg = el.shadowRoot?.querySelector('svg') as SVGElement;
1018
1037
  expect(svg.querySelector('title')?.textContent).to.equal(
1019
- 'Filter results distribution from 1900'
1038
+ 'Filter results for dates from 1900'
1020
1039
  );
1021
1040
  });
1022
1041
 
@@ -1029,7 +1048,7 @@ describe('HistogramDateRange', () => {
1029
1048
  );
1030
1049
  const svg = el.shadowRoot?.querySelector('svg') as SVGElement;
1031
1050
  expect(svg.querySelector('title')?.textContent).to.equal(
1032
- 'Filter results distribution up to 2020'
1051
+ 'Filter results for dates up to 2020'
1033
1052
  );
1034
1053
  });
1035
1054
 
@@ -1041,19 +1060,20 @@ describe('HistogramDateRange', () => {
1041
1060
  );
1042
1061
  const svg = el.shadowRoot?.querySelector('svg') as SVGElement;
1043
1062
  expect(svg.querySelector('title')?.textContent).to.equal(
1044
- 'Filter results distribution for all available dates'
1063
+ 'Filter results for dates'
1045
1064
  );
1046
1065
  });
1047
1066
 
1048
1067
  it('SVG accessibility - dynamic desc', async () => {
1049
1068
  const el = await fixture<HistogramDateRange>(
1050
1069
  html`
1051
- <histogram-date-range .bins=${[33, 1, 100]}> </histogram-date-range>
1070
+ <histogram-date-range maxDate="2020" .bins=${[33, 1, 100]}>
1071
+ </histogram-date-range>
1052
1072
  `
1053
1073
  );
1054
1074
  const svg = el.shadowRoot?.querySelector('svg') as SVGElement;
1055
1075
  expect(svg.querySelector('desc')?.textContent).to.equal(
1056
- 'This chart shows the distribution of search results for all available dates. The bars represent result counts for each time period within the selected date range.'
1076
+ 'This histogram shows the distribution of dates up to 2020'
1057
1077
  );
1058
1078
  });
1059
1079
  });
package/tsconfig.json CHANGED
@@ -1,21 +1,21 @@
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": ["**/*.ts"],
20
- "exclude": ["node_modules", "dist"]
21
- }
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": ["**/*.ts"],
20
+ "exclude": ["node_modules", "dist"]
21
+ }
@@ -1,28 +1,28 @@
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: '/demo/',
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
- // See documentation for all available options
28
- });
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: '/demo/',
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
+ // See documentation for all available options
28
+ });
@@ -1,29 +1,29 @@
1
- // import { playwrightLauncher } from '@web/test-runner-playwright';
2
-
3
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
4
- files: 'dist/test/**/*.test.js',
5
- nodeResolve: true,
6
-
7
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
8
- // esbuildTarget: 'auto',
9
-
10
- /** Confgure bare import resolve plugin */
11
- // nodeResolve: {
12
- // exportConditions: ['browser', 'development']
13
- // },
14
-
15
- /** Amount of browsers to run concurrently */
16
- // concurrentBrowsers: 2,
17
-
18
- /** Amount of test files per browser to test concurrently */
19
- // concurrency: 1,
20
-
21
- /** Browsers to run tests on */
22
- // browsers: [
23
- // playwrightLauncher({ product: 'chromium' }),
24
- // playwrightLauncher({ product: 'firefox' }),
25
- // playwrightLauncher({ product: 'webkit' }),
26
- // ],
27
-
28
- // See documentation for all available options
29
- });
1
+ // import { playwrightLauncher } from '@web/test-runner-playwright';
2
+
3
+ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
4
+ files: 'dist/test/**/*.test.js',
5
+ nodeResolve: true,
6
+
7
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
8
+ // esbuildTarget: 'auto',
9
+
10
+ /** Confgure bare import resolve plugin */
11
+ // nodeResolve: {
12
+ // exportConditions: ['browser', 'development']
13
+ // },
14
+
15
+ /** Amount of browsers to run concurrently */
16
+ // concurrentBrowsers: 2,
17
+
18
+ /** Amount of test files per browser to test concurrently */
19
+ // concurrency: 1,
20
+
21
+ /** Browsers to run tests on */
22
+ // browsers: [
23
+ // playwrightLauncher({ product: 'chromium' }),
24
+ // playwrightLauncher({ product: 'firefox' }),
25
+ // playwrightLauncher({ product: 'webkit' }),
26
+ // ],
27
+
28
+ // See documentation for all available options
29
+ });