@internetarchive/histogram-date-range 1.3.2-alpha-webdev7713.0 → 1.3.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.
@@ -3,31 +3,31 @@ import { html, fixture, expect, oneEvent, aTimeout } from '@open-wc/testing';
3
3
  import '../src/histogram-date-range';
4
4
  const SLIDER_WIDTH = 10;
5
5
  const WIDTH = 200;
6
- const subject = html `
7
- <histogram-date-range
8
- width="${WIDTH}"
9
- tooltipWidth="140"
10
- height="50"
11
- dateFormat="M/D/YYYY"
12
- minDate="1900"
13
- maxDate="12/4/2020"
14
- bins="[33, 1, 100]"
15
- >
16
- </histogram-date-range>
6
+ const subject = html `
7
+ <histogram-date-range
8
+ width="${WIDTH}"
9
+ tooltipWidth="140"
10
+ height="50"
11
+ dateFormat="M/D/YYYY"
12
+ minDate="1900"
13
+ maxDate="12/4/2020"
14
+ bins="[33, 1, 100]"
15
+ >
16
+ </histogram-date-range>
17
17
  `;
18
18
  async function createCustomElementInHTMLContainer() {
19
- document.head.insertAdjacentHTML('beforeend', `<style>
20
- html {
21
- font-size:10px;
22
- }
23
- .container {
24
- width: 400px;
25
- height: 400px;
26
- display: flex;
27
- background: #FFF6E1;
28
- justify-content: center;
29
- align-items: center;
30
- }
19
+ document.head.insertAdjacentHTML('beforeend', `<style>
20
+ html {
21
+ font-size:10px;
22
+ }
23
+ .container {
24
+ width: 400px;
25
+ height: 400px;
26
+ display: flex;
27
+ background: #FFF6E1;
28
+ justify-content: center;
29
+ align-items: center;
30
+ }
31
31
  </style>`);
32
32
  // https://open-wc.org/docs/testing/helpers/#customize-the-fixture-container
33
33
  const parentNode = document.createElement('div');
@@ -342,15 +342,15 @@ describe('HistogramDateRange', () => {
342
342
  });
343
343
  it('allows range to be pre-selected', async () => {
344
344
  var _a, _b;
345
- const el = await fixture(html `
346
- <histogram-date-range
347
- minDate="1900"
348
- maxDate="Dec 4, 2020"
349
- minSelectedDate="2012"
350
- maxSelectedDate="2019"
351
- bins="[33, 1, 100]"
352
- >
353
- </histogram-date-range>
345
+ const el = await fixture(html `
346
+ <histogram-date-range
347
+ minDate="1900"
348
+ maxDate="Dec 4, 2020"
349
+ minSelectedDate="2012"
350
+ maxSelectedDate="2019"
351
+ bins="[33, 1, 100]"
352
+ >
353
+ </histogram-date-range>
354
354
  `);
355
355
  const minDateInput = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#date-min');
356
356
  expect(minDateInput.value).to.eq('2012');
@@ -359,15 +359,15 @@ describe('HistogramDateRange', () => {
359
359
  });
360
360
  it('extends the selected range when the histogram is clicked outside of the current range', async () => {
361
361
  var _a, _b;
362
- const el = await fixture(html `
363
- <histogram-date-range
364
- minDate="1900"
365
- maxDate="2020"
366
- minSelectedDate="1950"
367
- maxSelectedDate="1955"
368
- bins="[33, 1, 1, 1, 10, 10, 1, 1, 1, 50, 100]"
369
- >
370
- </histogram-date-range>
362
+ const el = await fixture(html `
363
+ <histogram-date-range
364
+ minDate="1900"
365
+ maxDate="2020"
366
+ minSelectedDate="1950"
367
+ maxSelectedDate="1955"
368
+ bins="[33, 1, 1, 1, 10, 10, 1, 1, 1, 50, 100]"
369
+ >
370
+ </histogram-date-range>
371
371
  `);
372
372
  const leftBarToClick = Array.from((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar'))[1]; // click on second bar to the left
373
373
  leftBarToClick.dispatchEvent(new Event('click'));
@@ -379,15 +379,15 @@ describe('HistogramDateRange', () => {
379
379
  });
380
380
  it('narrows the selected range when the histogram is clicked inside of the current range', async () => {
381
381
  var _a, _b;
382
- const el = await fixture(html `
383
- <histogram-date-range
384
- minDate="1900"
385
- maxDate="2020"
386
- minSelectedDate="1900"
387
- maxSelectedDate="2020"
388
- bins="[33, 1, 1, 1, 10, 10, 1, 1, 1, 50, 100]"
389
- >
390
- </histogram-date-range>
382
+ const el = await fixture(html `
383
+ <histogram-date-range
384
+ minDate="1900"
385
+ maxDate="2020"
386
+ minSelectedDate="1900"
387
+ maxSelectedDate="2020"
388
+ bins="[33, 1, 1, 1, 10, 10, 1, 1, 1, 50, 100]"
389
+ >
390
+ </histogram-date-range>
391
391
  `);
392
392
  ///////////////////////////////////////////////
393
393
  // NB: the slider nearest the clicked bar moves
@@ -401,15 +401,15 @@ describe('HistogramDateRange', () => {
401
401
  });
402
402
  it('handles invalid pre-selected range by defaulting to overall max and min', async () => {
403
403
  var _a, _b;
404
- const el = await fixture(html `
405
- <histogram-date-range
406
- minDate="1900"
407
- maxDate="2020"
408
- minSelectedDate="2000xyz"
409
- maxSelectedDate="5000"
410
- bins="[33, 1, 100]"
411
- >
412
- </histogram-date-range>
404
+ const el = await fixture(html `
405
+ <histogram-date-range
406
+ minDate="1900"
407
+ maxDate="2020"
408
+ minSelectedDate="2000xyz"
409
+ maxSelectedDate="5000"
410
+ bins="[33, 1, 100]"
411
+ >
412
+ </histogram-date-range>
413
413
  `);
414
414
  const minDateInput = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#date-min');
415
415
  // malformed min date defaults to overall min
@@ -420,16 +420,16 @@ describe('HistogramDateRange', () => {
420
420
  });
421
421
  it('handles year values less than 1000 correctly', async () => {
422
422
  var _a, _b;
423
- const el = await fixture(html `
424
- <histogram-date-range
425
- dateFormat="M/D/YYYY"
426
- minDate="-2000"
427
- maxDate="2000"
428
- minSelectedDate="-500"
429
- maxSelectedDate="500"
430
- bins="[33, 1, 100]"
431
- >
432
- </histogram-date-range>
423
+ const el = await fixture(html `
424
+ <histogram-date-range
425
+ dateFormat="M/D/YYYY"
426
+ minDate="-2000"
427
+ maxDate="2000"
428
+ minSelectedDate="-500"
429
+ maxSelectedDate="500"
430
+ bins="[33, 1, 100]"
431
+ >
432
+ </histogram-date-range>
433
433
  `);
434
434
  const minDateInput = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#date-min');
435
435
  expect(minDateInput.value).to.eq('1/1/-500');
@@ -438,23 +438,23 @@ describe('HistogramDateRange', () => {
438
438
  });
439
439
  it('handles missing data', async () => {
440
440
  var _a, _b;
441
- let el = await fixture(html `<histogram-date-range>
442
- minDate="1900" maxDate="2020" bins=""
441
+ let el = await fixture(html `<histogram-date-range>
442
+ minDate="1900" maxDate="2020" bins=""
443
443
  </histogram-date-range>`);
444
444
  expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.innerHTML).to.contain('no data');
445
- el = await fixture(html `<histogram-date-range
446
- minDate="1900"
447
- maxDate="2020"
448
- bins="[]"
449
- missingDataMessage="no data available"
445
+ el = await fixture(html `<histogram-date-range
446
+ minDate="1900"
447
+ maxDate="2020"
448
+ bins="[]"
449
+ missingDataMessage="no data available"
450
450
  ></histogram-date-range>`);
451
451
  expect((_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.innerHTML).to.contain('no data available');
452
452
  });
453
453
  it('correctly displays data consisting of a single bin', async () => {
454
454
  var _a;
455
- const el = await fixture(html `
456
- <histogram-date-range minDate="2020" maxDate="2020" bins="[50]">
457
- </histogram-date-range>
455
+ const el = await fixture(html `
456
+ <histogram-date-range minDate="2020" maxDate="2020" bins="[50]">
457
+ </histogram-date-range>
458
458
  `);
459
459
  const bars = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar');
460
460
  const heights = Array.from(bars).map(b => b.height.baseVal.value);
@@ -462,9 +462,9 @@ describe('HistogramDateRange', () => {
462
462
  });
463
463
  it('correctly displays small diff between max and min values', async () => {
464
464
  var _a;
465
- const el = await fixture(html `
466
- <histogram-date-range bins="[1519,2643,1880,2041,1638,1441]">
467
- </histogram-date-range>
465
+ const el = await fixture(html `
466
+ <histogram-date-range bins="[1519,2643,1880,2041,1638,1441]">
467
+ </histogram-date-range>
468
468
  `);
469
469
  const bars = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar');
470
470
  const heights = Array.from(bars).map(b => b.height.baseVal.value);
@@ -472,15 +472,15 @@ describe('HistogramDateRange', () => {
472
472
  });
473
473
  it('correctly aligns bins to exact month boundaries when binSnapping=month', async () => {
474
474
  var _a;
475
- const el = await fixture(html `
476
- <histogram-date-range
477
- binSnapping="month"
478
- dateFormat="YYYY-MM"
479
- tooltipDateFormat="MMM YYYY"
480
- minDate="2020-01"
481
- maxDate="2021-12"
482
- bins="[10,20,30,40,50,60,70,80]"
483
- ></histogram-date-range>
475
+ const el = await fixture(html `
476
+ <histogram-date-range
477
+ binSnapping="month"
478
+ dateFormat="YYYY-MM"
479
+ tooltipDateFormat="MMM YYYY"
480
+ minDate="2020-01"
481
+ maxDate="2021-12"
482
+ bins="[10,20,30,40,50,60,70,80]"
483
+ ></histogram-date-range>
484
484
  `);
485
485
  const bars = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar');
486
486
  const tooltips = Array.from(bars).map(b => b.dataset.tooltip);
@@ -497,15 +497,15 @@ describe('HistogramDateRange', () => {
497
497
  });
498
498
  it('correctly handles month snapping for years 0-99', async () => {
499
499
  var _a;
500
- const el = await fixture(html `
501
- <histogram-date-range
502
- binSnapping="month"
503
- dateFormat="YYYY-MM"
504
- tooltipDateFormat="MMM YYYY"
505
- minDate="0050-01"
506
- maxDate="0065-12"
507
- bins="[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]"
508
- ></histogram-date-range>
500
+ const el = await fixture(html `
501
+ <histogram-date-range
502
+ binSnapping="month"
503
+ dateFormat="YYYY-MM"
504
+ tooltipDateFormat="MMM YYYY"
505
+ minDate="0050-01"
506
+ maxDate="0065-12"
507
+ bins="[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]"
508
+ ></histogram-date-range>
509
509
  `);
510
510
  const bars = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar');
511
511
  const tooltips = Array.from(bars).map(b => b.dataset.tooltip);
@@ -546,13 +546,13 @@ describe('HistogramDateRange', () => {
546
546
  });
547
547
  it('correctly aligns bins to exact year boundaries when binSnapping=year', async () => {
548
548
  var _a;
549
- const el = await fixture(html `
550
- <histogram-date-range
551
- binSnapping="year"
552
- minDate="2000"
553
- maxDate="2019"
554
- bins="[10,20,30,40,50,60,70,80,90,100]"
555
- ></histogram-date-range>
549
+ const el = await fixture(html `
550
+ <histogram-date-range
551
+ binSnapping="year"
552
+ minDate="2000"
553
+ maxDate="2019"
554
+ bins="[10,20,30,40,50,60,70,80,90,100]"
555
+ ></histogram-date-range>
556
556
  `);
557
557
  const bars = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar');
558
558
  const tooltips = Array.from(bars).map(b => b.dataset.tooltip);
@@ -571,14 +571,14 @@ describe('HistogramDateRange', () => {
571
571
  });
572
572
  it('correctly handles year snapping for years 0-99', async () => {
573
573
  var _a;
574
- const el = await fixture(html `
575
- <histogram-date-range
576
- binSnapping="year"
577
- dateFormat="YYYY"
578
- minDate="0020"
579
- maxDate="0025"
580
- bins="[1,2,3,4,5,6]"
581
- ></histogram-date-range>
574
+ const el = await fixture(html `
575
+ <histogram-date-range
576
+ binSnapping="year"
577
+ dateFormat="YYYY"
578
+ minDate="0020"
579
+ maxDate="0025"
580
+ bins="[1,2,3,4,5,6]"
581
+ ></histogram-date-range>
582
582
  `);
583
583
  const bars = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar');
584
584
  const tooltips = Array.from(bars).map(b => b.dataset.tooltip);
@@ -586,14 +586,14 @@ describe('HistogramDateRange', () => {
586
586
  });
587
587
  it('does not duplicate start/end date in tooltips when representing a single year', async () => {
588
588
  var _a;
589
- const el = await fixture(html `
590
- <histogram-date-range
591
- binSnapping="year"
592
- dateFormat="YYYY"
593
- minDate="2001"
594
- maxDate="2005"
595
- bins="[10,20,30,40,50]"
596
- ></histogram-date-range>
589
+ const el = await fixture(html `
590
+ <histogram-date-range
591
+ binSnapping="year"
592
+ dateFormat="YYYY"
593
+ minDate="2001"
594
+ maxDate="2005"
595
+ bins="[10,20,30,40,50]"
596
+ ></histogram-date-range>
597
597
  `);
598
598
  const bars = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar');
599
599
  const tooltips = Array.from(bars).map(b => b.dataset.tooltip);
@@ -601,13 +601,13 @@ describe('HistogramDateRange', () => {
601
601
  });
602
602
  it('falls back to default date format for tooltips if no tooltip date format provided', async () => {
603
603
  var _a;
604
- const el = await fixture(html `
605
- <histogram-date-range
606
- binSnapping="year"
607
- minDate="2001"
608
- maxDate="2005"
609
- bins="[10,20,30,40,50]"
610
- ></histogram-date-range>
604
+ const el = await fixture(html `
605
+ <histogram-date-range
606
+ binSnapping="year"
607
+ minDate="2001"
608
+ maxDate="2005"
609
+ bins="[10,20,30,40,50]"
610
+ ></histogram-date-range>
611
611
  `);
612
612
  const bars = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.bar');
613
613
  let tooltips = Array.from(bars).map(b => b.dataset.tooltip);
@@ -642,14 +642,14 @@ describe('HistogramDateRange', () => {
642
642
  });
643
643
  it('has a disabled state', async () => {
644
644
  var _a, _b, _c;
645
- const el = await fixture(html `
646
- <histogram-date-range
647
- minDate="1900"
648
- maxDate="2020"
649
- disabled
650
- bins="[33, 1, 100]"
651
- >
652
- </histogram-date-range>
645
+ const el = await fixture(html `
646
+ <histogram-date-range
647
+ minDate="1900"
648
+ maxDate="2020"
649
+ disabled
650
+ bins="[33, 1, 100]"
651
+ >
652
+ </histogram-date-range>
653
653
  `);
654
654
  expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.inner-container')) === null || _b === void 0 ? void 0 : _b.classList.contains('disabled')).to.eq(true);
655
655
  const minSlider = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#slider-min');
@@ -667,28 +667,28 @@ describe('HistogramDateRange', () => {
667
667
  });
668
668
  it('has a loading state with an activity indicator', async () => {
669
669
  var _a, _b, _c, _d;
670
- const el = await fixture(html `
671
- <histogram-date-range
672
- minDate="1900"
673
- maxDate="2020"
674
- loading
675
- bins="[33, 1, 100]"
676
- >
677
- </histogram-date-range>
670
+ const el = await fixture(html `
671
+ <histogram-date-range
672
+ minDate="1900"
673
+ maxDate="2020"
674
+ loading
675
+ bins="[33, 1, 100]"
676
+ >
677
+ </histogram-date-range>
678
678
  `);
679
679
  expect((_d = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('ia-activity-indicator')) === null || _b === void 0 ? void 0 : _b.attributes) === null || _c === void 0 ? void 0 : _c.getNamedItem('mode')) === null || _d === void 0 ? void 0 : _d.value).to.eq('processing');
680
680
  });
681
681
  it('can use LitElement bound properties', async () => {
682
682
  var _a, _b;
683
- const el = await fixture(html `
684
- <histogram-date-range
685
- .minDate=${1900}
686
- .maxDate=${'Dec 4, 2020'}
687
- .minSelectedDate=${2012}
688
- .maxSelectedDate=${2019}
689
- .bins=${[33, 1, 100]}
690
- >
691
- </histogram-date-range>
683
+ const el = await fixture(html `
684
+ <histogram-date-range
685
+ .minDate=${1900}
686
+ .maxDate=${'Dec 4, 2020'}
687
+ .minSelectedDate=${2012}
688
+ .maxSelectedDate=${2019}
689
+ .bins=${[33, 1, 100]}
690
+ >
691
+ </histogram-date-range>
692
692
  `);
693
693
  const minDateInput = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#date-min');
694
694
  expect(minDateInput.value).to.eq('2012');