@internetarchive/histogram-date-range 1.4.1 → 1.4.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.
@@ -189,7 +189,6 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
189
189
  this._maxDateMS =
190
190
  this.snapTimestamp(this.getMSFromString(this.maxDate) + this.snapInterval) + this.snapEndOffset;
191
191
  this._binWidth = this._histWidth / this._numBins;
192
- this._previousDateRange = this.currentDateRangeString;
193
192
  this._histData = this.calculateHistData();
194
193
  this.minSelectedDate = this.minSelectedDate
195
194
  ? this.minSelectedDate
@@ -432,9 +431,9 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
432
431
  window.scrollX;
433
432
  // Place the tooltip (with arrow) just above the top of the histogram bars
434
433
  this._tooltipOffsetY = histogramY - heightAboveHistogram + window.scrollY;
435
- this._tooltipContent = html `
436
- ${formattedNumItems} ${itemsText}<br />
437
- ${dataset.tooltip}
434
+ this._tooltipContent = html `
435
+ ${formattedNumItems} ${itemsText}<br />
436
+ ${dataset.tooltip}
438
437
  `;
439
438
  (_b = (_a = this._tooltip).showPopover) === null || _b === void 0 ? void 0 : _b.call(_a);
440
439
  }
@@ -631,25 +630,25 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
631
630
  // border-radius); used as part of a SVG quadratic curve. see
632
631
  // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands
633
632
  const cs = SLIDER_CORNER_SIZE;
634
- const sliderShape = `
635
- M${this.minSliderX},0
636
- h-${this.sliderWidth - cs}
637
- q-${cs},0 -${cs},${cs}
638
- v${this.height - cs * 2}
639
- q0,${cs} ${cs},${cs}
640
- h${this.sliderWidth - cs}
633
+ const sliderShape = `
634
+ M${this.minSliderX},0
635
+ h-${this.sliderWidth - cs}
636
+ q-${cs},0 -${cs},${cs}
637
+ v${this.height - cs * 2}
638
+ q0,${cs} ${cs},${cs}
639
+ h${this.sliderWidth - cs}
641
640
  `;
642
641
  return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);
643
642
  }
644
643
  get maxSliderTemplate() {
645
644
  const cs = SLIDER_CORNER_SIZE;
646
- const sliderShape = `
647
- M${this.maxSliderX},0
648
- h${this.sliderWidth - cs}
649
- q${cs},0 ${cs},${cs}
650
- v${this.height - cs * 2}
651
- q0,${cs} -${cs},${cs}
652
- h-${this.sliderWidth - cs}
645
+ const sliderShape = `
646
+ M${this.maxSliderX},0
647
+ h${this.sliderWidth - cs}
648
+ q${cs},0 ${cs},${cs}
649
+ v${this.height - cs * 2}
650
+ q0,${cs} -${cs},${cs}
651
+ h-${this.sliderWidth - cs}
653
652
  `;
654
653
  return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);
655
654
  }
@@ -662,38 +661,38 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
662
661
  draggable: !this.disabled,
663
662
  dragging: this._isDragging,
664
663
  });
665
- return svg `
666
- <svg
667
- id=${id}
668
- class=${sliderClasses}
669
- @pointerdown=${this.drag}
670
- >
671
- <path d="${sliderShape} z" fill="${sliderColor}" />
672
- <rect
673
- x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k}"
674
- y="${this.height / 3}"
675
- width="1"
676
- height="${this.height / 3}"
677
- fill="white"
678
- />
679
- <rect
680
- x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k}"
681
- y="${this.height / 3}"
682
- width="1"
683
- height="${this.height / 3}"
684
- fill="white"
685
- />
686
- </svg>
664
+ return svg `
665
+ <svg
666
+ id=${id}
667
+ class=${sliderClasses}
668
+ @pointerdown=${this.drag}
669
+ >
670
+ <path d="${sliderShape} z" fill="${sliderColor}" />
671
+ <rect
672
+ x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k}"
673
+ y="${this.height / 3}"
674
+ width="1"
675
+ height="${this.height / 3}"
676
+ fill="white"
677
+ />
678
+ <rect
679
+ x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k}"
680
+ y="${this.height / 3}"
681
+ width="1"
682
+ height="${this.height / 3}"
683
+ fill="white"
684
+ />
685
+ </svg>
687
686
  `;
688
687
  }
689
688
  get selectedRangeTemplate() {
690
- return svg `
691
- <rect
692
- x="${this.minSliderX}"
693
- y="0"
694
- width="${this.maxSliderX - this.minSliderX}"
695
- height="${this.height}"
696
- fill="${selectedRangeColor}"
689
+ return svg `
690
+ <rect
691
+ x="${this.minSliderX}"
692
+ y="0"
693
+ width="${this.maxSliderX - this.minSliderX}"
694
+ height="${this.height}"
695
+ fill="${selectedRangeColor}"
697
696
  />`;
698
697
  }
699
698
  get histogramTemplate() {
@@ -711,30 +710,30 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
711
710
  // between adjacent bars (eg when viewing the tooltips or when trying to
712
711
  // extend the range by clicking on a bar)
713
712
  const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;
714
- const bar = svg `
715
- <rect
716
- class="bar-pointer-target"
717
- x=${x}
718
- y="0"
719
- width=${barWidth}
720
- height=${this.height}
721
- @pointerenter=${this.showTooltip}
722
- @pointerleave=${this.hideTooltip}
723
- @click=${this.handleBarClick}
724
- fill="transparent"
725
- data-num-items=${data.value}
726
- data-bin-start=${data.binStart}
727
- data-bin-end=${data.binEnd}
728
- data-tooltip=${data.tooltip}
729
- />
730
- <rect
731
- class="bar"
732
- style=${barStyle}
733
- x=${x}
734
- y=${this.height - barHeight}
735
- width=${barWidth}
736
- height=${barHeight}
737
- fill=${barFill}
713
+ const bar = svg `
714
+ <rect
715
+ class="bar-pointer-target"
716
+ x=${x}
717
+ y="0"
718
+ width=${barWidth}
719
+ height=${this.height}
720
+ @pointerenter=${this.showTooltip}
721
+ @pointerleave=${this.hideTooltip}
722
+ @click=${this.handleBarClick}
723
+ fill="transparent"
724
+ data-num-items=${data.value}
725
+ data-bin-start=${data.binStart}
726
+ data-bin-end=${data.binEnd}
727
+ data-tooltip=${data.tooltip}
728
+ />
729
+ <rect
730
+ class="bar"
731
+ style=${barStyle}
732
+ x=${x}
733
+ y=${this.height - barHeight}
734
+ width=${barWidth}
735
+ height=${barHeight}
736
+ fill=${barFill}
738
737
  />`;
739
738
  x += xScale;
740
739
  return bar;
@@ -774,31 +773,31 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
774
773
  * https://lit.dev/docs/templates/directives/#live
775
774
  */
776
775
  get minInputTemplate() {
777
- return html `
778
- <input
779
- id="date-min"
780
- placeholder=${this.dateFormat}
781
- type="text"
782
- @focus=${this.handleInputFocus}
783
- @blur=${this.handleMinDateInput}
784
- @keyup=${this.handleKeyUp}
785
- .value=${live(this.minSelectedDate)}
786
- ?disabled=${this.disabled}
787
- />
776
+ return html `
777
+ <input
778
+ id="date-min"
779
+ placeholder=${this.dateFormat}
780
+ type="text"
781
+ @focus=${this.handleInputFocus}
782
+ @blur=${this.handleMinDateInput}
783
+ @keyup=${this.handleKeyUp}
784
+ .value=${live(this.minSelectedDate)}
785
+ ?disabled=${this.disabled}
786
+ />
788
787
  `;
789
788
  }
790
789
  get maxInputTemplate() {
791
- return html `
792
- <input
793
- id="date-max"
794
- placeholder=${this.dateFormat}
795
- type="text"
796
- @focus=${this.handleInputFocus}
797
- @blur=${this.handleMaxDateInput}
798
- @keyup=${this.handleKeyUp}
799
- .value=${live(this.maxSelectedDate)}
800
- ?disabled=${this.disabled}
801
- />
790
+ return html `
791
+ <input
792
+ id="date-max"
793
+ placeholder=${this.dateFormat}
794
+ type="text"
795
+ @focus=${this.handleInputFocus}
796
+ @blur=${this.handleMaxDateInput}
797
+ @keyup=${this.handleKeyUp}
798
+ .value=${live(this.maxSelectedDate)}
799
+ ?disabled=${this.disabled}
800
+ />
802
801
  `;
803
802
  }
804
803
  get minLabelTemplate() {
@@ -814,8 +813,8 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
814
813
  top: `${this._tooltipOffsetY}px`,
815
814
  left: `${this._tooltipOffsetX}px`,
816
815
  });
817
- return html `
818
- <div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
816
+ return html `
817
+ <div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
819
818
  `;
820
819
  }
821
820
  get histogramAccessibilityTemplate() {
@@ -831,184 +830,184 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
831
830
  }
832
831
  const titleText = `Filter results for dates${rangeText}`;
833
832
  const descText = `This histogram shows the distribution of dates${rangeText}`;
834
- return html `<title id="histogram-title">${titleText}</title
833
+ return html `<title id="histogram-title">${titleText}</title
835
834
  ><desc id="histogram-desc">${descText}</desc>`;
836
835
  }
837
836
  get noDataTemplate() {
838
- return html `
839
- <div class="missing-data-message">${this.missingDataMessage}</div>
837
+ return html `
838
+ <div class="missing-data-message">${this.missingDataMessage}</div>
840
839
  `;
841
840
  }
842
841
  get activityIndicatorTemplate() {
843
842
  if (!this.loading) {
844
843
  return nothing;
845
844
  }
846
- return html `
847
- <ia-activity-indicator mode="processing"> </ia-activity-indicator>
845
+ return html `
846
+ <ia-activity-indicator mode="processing"> </ia-activity-indicator>
848
847
  `;
849
848
  }
850
849
  render() {
851
850
  if (!this.hasBinData) {
852
851
  return this.noDataTemplate;
853
852
  }
854
- return html `
855
- <div
856
- id="container"
857
- class="
858
- noselect
859
- ${this._isDragging ? 'dragging' : ''}
860
- "
861
- style="width: ${this.width}px"
862
- >
863
- ${this.activityIndicatorTemplate} ${this.tooltipTemplate}
864
- <div
865
- class="inner-container
866
- ${this.disabled ? 'disabled' : ''}"
867
- >
868
- <svg
869
- width="${this.width}"
870
- height="${this.height}"
871
- aria-labelledby="histogram-title histogram-desc"
872
- @pointerleave="${this.drop}"
873
- >
874
- ${this.histogramAccessibilityTemplate} ${this.selectedRangeTemplate}
875
- <svg id="histogram">${this.histogramTemplate}</svg>
876
- ${this.minSliderTemplate} ${this.maxSliderTemplate}
877
- </svg>
878
- <div id="inputs">
879
- ${this.minLabelTemplate} ${this.minInputTemplate}
880
- <div class="dash">-</div>
881
- ${this.maxLabelTemplate} ${this.maxInputTemplate}
882
- <slot name="inputs-right-side"></slot>
883
- </div>
884
- </div>
885
- </div>
853
+ return html `
854
+ <div
855
+ id="container"
856
+ class="
857
+ noselect
858
+ ${this._isDragging ? 'dragging' : ''}
859
+ "
860
+ style="width: ${this.width}px"
861
+ >
862
+ ${this.activityIndicatorTemplate} ${this.tooltipTemplate}
863
+ <div
864
+ class="inner-container
865
+ ${this.disabled ? 'disabled' : ''}"
866
+ >
867
+ <svg
868
+ width="${this.width}"
869
+ height="${this.height}"
870
+ aria-labelledby="histogram-title histogram-desc"
871
+ @pointerleave="${this.drop}"
872
+ >
873
+ ${this.histogramAccessibilityTemplate} ${this.selectedRangeTemplate}
874
+ <svg id="histogram">${this.histogramTemplate}</svg>
875
+ ${this.minSliderTemplate} ${this.maxSliderTemplate}
876
+ </svg>
877
+ <div id="inputs">
878
+ ${this.minLabelTemplate} ${this.minInputTemplate}
879
+ <div class="dash">-</div>
880
+ ${this.maxLabelTemplate} ${this.maxInputTemplate}
881
+ <slot name="inputs-right-side"></slot>
882
+ </div>
883
+ </div>
884
+ </div>
886
885
  `;
887
886
  }
888
887
  };
889
- HistogramDateRange.styles = css `
890
- .missing-data-message {
891
- text-align: center;
892
- }
893
- #container {
894
- margin: 0;
895
- touch-action: none;
896
- position: relative;
897
- }
898
- .disabled {
899
- opacity: 0.3;
900
- }
901
- ia-activity-indicator {
902
- position: absolute;
903
- left: calc(50% - 10px);
904
- top: 10px;
905
- width: 20px;
906
- height: 20px;
907
- --activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);
908
- --activityIndicatorLoadingRingColor: ${activityIndicatorColor};
909
- }
910
-
911
- /* prevent selection from interfering with tooltip, especially on mobile */
912
- /* https://stackoverflow.com/a/4407335/1163042 */
913
- .noselect {
914
- -webkit-touch-callout: none; /* iOS Safari */
915
- -webkit-user-select: none; /* Safari */
916
- -moz-user-select: none; /* Old versions of Firefox */
917
- -ms-user-select: none; /* Internet Explorer/Edge */
918
- user-select: none; /* current Chrome, Edge, Opera and Firefox */
919
- }
920
- .bar,
921
- .bar-pointer-target {
922
- /* create a transparent border around the hist bars to prevent "gaps" and
923
- flickering when moving around between bars. this also helps with handling
924
- clicks on the bars, preventing users from being able to click in between
925
- bars */
926
- stroke: rgba(0, 0, 0, 0);
927
- /* ensure transparent stroke wide enough to cover gap between bars */
928
- stroke-width: 2px;
929
- }
930
- .bar {
931
- /* ensure the bar's pointer target receives events, not the bar itself */
932
- pointer-events: none;
933
- }
934
- .bar-pointer-target:hover + .bar {
935
- /* highlight currently hovered bar */
936
- fill-opacity: 0.7;
937
- }
938
- .disabled .bar-pointer-target:hover + .bar {
939
- /* ensure no visual hover interaction when disabled */
940
- fill-opacity: 1;
941
- }
942
- /****** histogram ********/
943
- #tooltip {
944
- position: absolute;
945
- background: ${tooltipBackgroundColor};
946
- margin: 0;
947
- border: 0;
948
- color: ${tooltipTextColor};
949
- text-align: center;
950
- border-radius: 3px;
951
- padding: 2px;
952
- font-size: ${tooltipFontSize};
953
- font-family: ${tooltipFontFamily};
954
- touch-action: none;
955
- pointer-events: none;
956
- overflow: visible;
957
- }
958
- #tooltip:after {
959
- content: '';
960
- position: absolute;
961
- margin-left: -5px;
962
- top: 100%;
963
- left: 50%;
964
- /* arrow */
965
- border: 5px solid ${tooltipTextColor};
966
- border-color: ${tooltipBackgroundColor} transparent transparent
967
- transparent;
968
- }
969
- /****** slider ********/
970
- .slider {
971
- shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */
972
- }
973
- .draggable:hover {
974
- cursor: grab;
975
- }
976
- .dragging {
977
- cursor: grabbing !important;
978
- }
979
- /****** inputs ********/
980
- #inputs {
981
- display: flex;
982
- justify-content: center;
983
- margin: ${inputRowMargin};
984
- }
985
- #inputs .dash {
986
- position: relative;
987
- bottom: -1px;
988
- align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */
989
- }
990
- input {
991
- width: ${inputWidth};
992
- margin: 0 3px;
993
- border: ${inputBorder};
994
- border-radius: 2px !important;
995
- text-align: center;
996
- font-size: ${inputFontSize};
997
- font-family: ${inputFontFamily};
998
- }
999
- .sr-only {
1000
- position: absolute !important;
1001
- width: 1px !important;
1002
- height: 1px !important;
1003
- margin: 0 !important;
1004
- padding: 0 !important;
1005
- border: 0 !important;
1006
- overflow: hidden !important;
1007
- white-space: nowrap !important;
1008
- clip: rect(1px, 1px, 1px, 1px) !important;
1009
- -webkit-clip-path: inset(50%) !important;
1010
- clip-path: inset(50%) !important;
1011
- }
888
+ HistogramDateRange.styles = css `
889
+ .missing-data-message {
890
+ text-align: center;
891
+ }
892
+ #container {
893
+ margin: 0;
894
+ touch-action: none;
895
+ position: relative;
896
+ }
897
+ .disabled {
898
+ opacity: 0.3;
899
+ }
900
+ ia-activity-indicator {
901
+ position: absolute;
902
+ left: calc(50% - 10px);
903
+ top: 10px;
904
+ width: 20px;
905
+ height: 20px;
906
+ --activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);
907
+ --activityIndicatorLoadingRingColor: ${activityIndicatorColor};
908
+ }
909
+
910
+ /* prevent selection from interfering with tooltip, especially on mobile */
911
+ /* https://stackoverflow.com/a/4407335/1163042 */
912
+ .noselect {
913
+ -webkit-touch-callout: none; /* iOS Safari */
914
+ -webkit-user-select: none; /* Safari */
915
+ -moz-user-select: none; /* Old versions of Firefox */
916
+ -ms-user-select: none; /* Internet Explorer/Edge */
917
+ user-select: none; /* current Chrome, Edge, Opera and Firefox */
918
+ }
919
+ .bar,
920
+ .bar-pointer-target {
921
+ /* create a transparent border around the hist bars to prevent "gaps" and
922
+ flickering when moving around between bars. this also helps with handling
923
+ clicks on the bars, preventing users from being able to click in between
924
+ bars */
925
+ stroke: rgba(0, 0, 0, 0);
926
+ /* ensure transparent stroke wide enough to cover gap between bars */
927
+ stroke-width: 2px;
928
+ }
929
+ .bar {
930
+ /* ensure the bar's pointer target receives events, not the bar itself */
931
+ pointer-events: none;
932
+ }
933
+ .bar-pointer-target:hover + .bar {
934
+ /* highlight currently hovered bar */
935
+ fill-opacity: 0.7;
936
+ }
937
+ .disabled .bar-pointer-target:hover + .bar {
938
+ /* ensure no visual hover interaction when disabled */
939
+ fill-opacity: 1;
940
+ }
941
+ /****** histogram ********/
942
+ #tooltip {
943
+ position: absolute;
944
+ background: ${tooltipBackgroundColor};
945
+ margin: 0;
946
+ border: 0;
947
+ color: ${tooltipTextColor};
948
+ text-align: center;
949
+ border-radius: 3px;
950
+ padding: 2px;
951
+ font-size: ${tooltipFontSize};
952
+ font-family: ${tooltipFontFamily};
953
+ touch-action: none;
954
+ pointer-events: none;
955
+ overflow: visible;
956
+ }
957
+ #tooltip:after {
958
+ content: '';
959
+ position: absolute;
960
+ margin-left: -5px;
961
+ top: 100%;
962
+ left: 50%;
963
+ /* arrow */
964
+ border: 5px solid ${tooltipTextColor};
965
+ border-color: ${tooltipBackgroundColor} transparent transparent
966
+ transparent;
967
+ }
968
+ /****** slider ********/
969
+ .slider {
970
+ shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */
971
+ }
972
+ .draggable:hover {
973
+ cursor: grab;
974
+ }
975
+ .dragging {
976
+ cursor: grabbing !important;
977
+ }
978
+ /****** inputs ********/
979
+ #inputs {
980
+ display: flex;
981
+ justify-content: center;
982
+ margin: ${inputRowMargin};
983
+ }
984
+ #inputs .dash {
985
+ position: relative;
986
+ bottom: -1px;
987
+ align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */
988
+ }
989
+ input {
990
+ width: ${inputWidth};
991
+ margin: 0 3px;
992
+ border: ${inputBorder};
993
+ border-radius: 2px !important;
994
+ text-align: center;
995
+ font-size: ${inputFontSize};
996
+ font-family: ${inputFontFamily};
997
+ }
998
+ .sr-only {
999
+ position: absolute !important;
1000
+ width: 1px !important;
1001
+ height: 1px !important;
1002
+ margin: 0 !important;
1003
+ padding: 0 !important;
1004
+ border: 0 !important;
1005
+ overflow: hidden !important;
1006
+ white-space: nowrap !important;
1007
+ clip: rect(1px, 1px, 1px, 1px) !important;
1008
+ -webkit-clip-path: inset(50%) !important;
1009
+ clip-path: inset(50%) !important;
1010
+ }
1012
1011
  `;
1013
1012
  __decorate([
1014
1013
  property({ type: Number })