@internetarchive/histogram-date-range 1.4.2-alpha-webdev8495.0 → 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.
@@ -431,9 +431,9 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
431
431
  window.scrollX;
432
432
  // Place the tooltip (with arrow) just above the top of the histogram bars
433
433
  this._tooltipOffsetY = histogramY - heightAboveHistogram + window.scrollY;
434
- this._tooltipContent = html `
435
- ${formattedNumItems} ${itemsText}<br />
436
- ${dataset.tooltip}
434
+ this._tooltipContent = html `
435
+ ${formattedNumItems} ${itemsText}<br />
436
+ ${dataset.tooltip}
437
437
  `;
438
438
  (_b = (_a = this._tooltip).showPopover) === null || _b === void 0 ? void 0 : _b.call(_a);
439
439
  }
@@ -630,25 +630,25 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
630
630
  // border-radius); used as part of a SVG quadratic curve. see
631
631
  // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands
632
632
  const cs = SLIDER_CORNER_SIZE;
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}
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}
640
640
  `;
641
641
  return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);
642
642
  }
643
643
  get maxSliderTemplate() {
644
644
  const cs = SLIDER_CORNER_SIZE;
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}
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}
652
652
  `;
653
653
  return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);
654
654
  }
@@ -661,38 +661,38 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
661
661
  draggable: !this.disabled,
662
662
  dragging: this._isDragging,
663
663
  });
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>
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>
686
686
  `;
687
687
  }
688
688
  get selectedRangeTemplate() {
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}"
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}"
696
696
  />`;
697
697
  }
698
698
  get histogramTemplate() {
@@ -710,30 +710,30 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
710
710
  // between adjacent bars (eg when viewing the tooltips or when trying to
711
711
  // extend the range by clicking on a bar)
712
712
  const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;
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}
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}
737
737
  />`;
738
738
  x += xScale;
739
739
  return bar;
@@ -773,31 +773,31 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
773
773
  * https://lit.dev/docs/templates/directives/#live
774
774
  */
775
775
  get minInputTemplate() {
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
- />
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
+ />
787
787
  `;
788
788
  }
789
789
  get maxInputTemplate() {
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
- />
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
+ />
801
801
  `;
802
802
  }
803
803
  get minLabelTemplate() {
@@ -813,8 +813,8 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
813
813
  top: `${this._tooltipOffsetY}px`,
814
814
  left: `${this._tooltipOffsetX}px`,
815
815
  });
816
- return html `
817
- <div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
816
+ return html `
817
+ <div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
818
818
  `;
819
819
  }
820
820
  get histogramAccessibilityTemplate() {
@@ -830,184 +830,184 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
830
830
  }
831
831
  const titleText = `Filter results for dates${rangeText}`;
832
832
  const descText = `This histogram shows the distribution of dates${rangeText}`;
833
- return html `<title id="histogram-title">${titleText}</title
833
+ return html `<title id="histogram-title">${titleText}</title
834
834
  ><desc id="histogram-desc">${descText}</desc>`;
835
835
  }
836
836
  get noDataTemplate() {
837
- return html `
838
- <div class="missing-data-message">${this.missingDataMessage}</div>
837
+ return html `
838
+ <div class="missing-data-message">${this.missingDataMessage}</div>
839
839
  `;
840
840
  }
841
841
  get activityIndicatorTemplate() {
842
842
  if (!this.loading) {
843
843
  return nothing;
844
844
  }
845
- return html `
846
- <ia-activity-indicator mode="processing"> </ia-activity-indicator>
845
+ return html `
846
+ <ia-activity-indicator mode="processing"> </ia-activity-indicator>
847
847
  `;
848
848
  }
849
849
  render() {
850
850
  if (!this.hasBinData) {
851
851
  return this.noDataTemplate;
852
852
  }
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>
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>
885
885
  `;
886
886
  }
887
887
  };
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
- }
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
+ }
1011
1011
  `;
1012
1012
  __decorate([
1013
1013
  property({ type: Number })