@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.
@@ -395,9 +395,9 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
395
395
  window.scrollX;
396
396
  // Place the tooltip (with arrow) just above the top of the histogram bars
397
397
  this._tooltipOffsetY = histogramY - heightAboveHistogram + window.scrollY;
398
- this._tooltipContent = html `
399
- ${formattedNumItems} ${itemsText}<br />
400
- ${dataset.tooltip}
398
+ this._tooltipContent = html `
399
+ ${formattedNumItems} ${itemsText}<br />
400
+ ${dataset.tooltip}
401
401
  `;
402
402
  (_b = (_a = this._tooltip).showPopover) === null || _b === void 0 ? void 0 : _b.call(_a);
403
403
  }
@@ -594,25 +594,25 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
594
594
  // border-radius); used as part of a SVG quadratic curve. see
595
595
  // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands
596
596
  const cs = SLIDER_CORNER_SIZE;
597
- const sliderShape = `
598
- M${this.minSliderX},0
599
- h-${this.sliderWidth - cs}
600
- q-${cs},0 -${cs},${cs}
601
- v${this.height - cs * 2}
602
- q0,${cs} ${cs},${cs}
603
- h${this.sliderWidth - cs}
597
+ const sliderShape = `
598
+ M${this.minSliderX},0
599
+ h-${this.sliderWidth - cs}
600
+ q-${cs},0 -${cs},${cs}
601
+ v${this.height - cs * 2}
602
+ q0,${cs} ${cs},${cs}
603
+ h${this.sliderWidth - cs}
604
604
  `;
605
605
  return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);
606
606
  }
607
607
  get maxSliderTemplate() {
608
608
  const cs = SLIDER_CORNER_SIZE;
609
- const sliderShape = `
610
- M${this.maxSliderX},0
611
- h${this.sliderWidth - cs}
612
- q${cs},0 ${cs},${cs}
613
- v${this.height - cs * 2}
614
- q0,${cs} -${cs},${cs}
615
- h-${this.sliderWidth - cs}
609
+ const sliderShape = `
610
+ M${this.maxSliderX},0
611
+ h${this.sliderWidth - cs}
612
+ q${cs},0 ${cs},${cs}
613
+ v${this.height - cs * 2}
614
+ q0,${cs} -${cs},${cs}
615
+ h-${this.sliderWidth - cs}
616
616
  `;
617
617
  return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);
618
618
  }
@@ -625,38 +625,38 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
625
625
  draggable: !this.disabled,
626
626
  dragging: this._isDragging,
627
627
  });
628
- return svg `
629
- <svg
630
- id=${id}
631
- class=${sliderClasses}
632
- @pointerdown=${this.drag}
633
- >
634
- <path d="${sliderShape} z" fill="${sliderColor}" />
635
- <rect
636
- x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k}"
637
- y="${this.height / 3}"
638
- width="1"
639
- height="${this.height / 3}"
640
- fill="white"
641
- />
642
- <rect
643
- x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k}"
644
- y="${this.height / 3}"
645
- width="1"
646
- height="${this.height / 3}"
647
- fill="white"
648
- />
649
- </svg>
628
+ return svg `
629
+ <svg
630
+ id=${id}
631
+ class=${sliderClasses}
632
+ @pointerdown=${this.drag}
633
+ >
634
+ <path d="${sliderShape} z" fill="${sliderColor}" />
635
+ <rect
636
+ x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k}"
637
+ y="${this.height / 3}"
638
+ width="1"
639
+ height="${this.height / 3}"
640
+ fill="white"
641
+ />
642
+ <rect
643
+ x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k}"
644
+ y="${this.height / 3}"
645
+ width="1"
646
+ height="${this.height / 3}"
647
+ fill="white"
648
+ />
649
+ </svg>
650
650
  `;
651
651
  }
652
652
  get selectedRangeTemplate() {
653
- return svg `
654
- <rect
655
- x="${this.minSliderX}"
656
- y="0"
657
- width="${this.maxSliderX - this.minSliderX}"
658
- height="${this.height}"
659
- fill="${selectedRangeColor}"
653
+ return svg `
654
+ <rect
655
+ x="${this.minSliderX}"
656
+ y="0"
657
+ width="${this.maxSliderX - this.minSliderX}"
658
+ height="${this.height}"
659
+ fill="${selectedRangeColor}"
660
660
  />`;
661
661
  }
662
662
  get histogramTemplate() {
@@ -674,22 +674,22 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
674
674
  // between adjacent bars (eg when viewing the tooltips or when trying to
675
675
  // extend the range by clicking on a bar)
676
676
  const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;
677
- const bar = svg `
678
- <rect
679
- class="bar"
680
- style=${barStyle}
681
- x=${x}
682
- y=${this.height - barHeight}
683
- width=${barWidth}
684
- height=${barHeight}
685
- @pointerenter=${this.showTooltip}
686
- @pointerleave=${this.hideTooltip}
687
- @click=${this.handleBarClick}
688
- fill=${barFill}
689
- data-num-items=${data.value}
690
- data-bin-start=${data.binStart}
691
- data-bin-end=${data.binEnd}
692
- data-tooltip=${data.tooltip}
677
+ const bar = svg `
678
+ <rect
679
+ class="bar"
680
+ style=${barStyle}
681
+ x=${x}
682
+ y=${this.height - barHeight}
683
+ width=${barWidth}
684
+ height=${barHeight}
685
+ @pointerenter=${this.showTooltip}
686
+ @pointerleave=${this.hideTooltip}
687
+ @click=${this.handleBarClick}
688
+ fill=${barFill}
689
+ data-num-items=${data.value}
690
+ data-bin-start=${data.binStart}
691
+ data-bin-end=${data.binEnd}
692
+ data-tooltip=${data.tooltip}
693
693
  />`;
694
694
  x += xScale;
695
695
  return bar;
@@ -729,31 +729,31 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
729
729
  * https://lit.dev/docs/templates/directives/#live
730
730
  */
731
731
  get minInputTemplate() {
732
- return html `
733
- <input
734
- id="date-min"
735
- placeholder=${this.dateFormat}
736
- type="text"
737
- @focus=${this.handleInputFocus}
738
- @blur=${this.handleMinDateInput}
739
- @keyup=${this.handleKeyUp}
740
- .value=${live(this.minSelectedDate)}
741
- ?disabled=${this.disabled}
742
- />
732
+ return html `
733
+ <input
734
+ id="date-min"
735
+ placeholder=${this.dateFormat}
736
+ type="text"
737
+ @focus=${this.handleInputFocus}
738
+ @blur=${this.handleMinDateInput}
739
+ @keyup=${this.handleKeyUp}
740
+ .value=${live(this.minSelectedDate)}
741
+ ?disabled=${this.disabled}
742
+ />
743
743
  `;
744
744
  }
745
745
  get maxInputTemplate() {
746
- return html `
747
- <input
748
- id="date-max"
749
- placeholder=${this.dateFormat}
750
- type="text"
751
- @focus=${this.handleInputFocus}
752
- @blur=${this.handleMaxDateInput}
753
- @keyup=${this.handleKeyUp}
754
- .value=${live(this.maxSelectedDate)}
755
- ?disabled=${this.disabled}
756
- />
746
+ return html `
747
+ <input
748
+ id="date-max"
749
+ placeholder=${this.dateFormat}
750
+ type="text"
751
+ @focus=${this.handleInputFocus}
752
+ @blur=${this.handleMaxDateInput}
753
+ @keyup=${this.handleKeyUp}
754
+ .value=${live(this.maxSelectedDate)}
755
+ ?disabled=${this.disabled}
756
+ />
757
757
  `;
758
758
  }
759
759
  get minLabelTemplate() {
@@ -769,179 +769,179 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
769
769
  top: `${this._tooltipOffsetY}px`,
770
770
  left: `${this._tooltipOffsetX}px`,
771
771
  });
772
- return html `
773
- <div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
772
+ return html `
773
+ <div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
774
774
  `;
775
775
  }
776
776
  get noDataTemplate() {
777
- return html `
778
- <div class="missing-data-message">${this.missingDataMessage}</div>
777
+ return html `
778
+ <div class="missing-data-message">${this.missingDataMessage}</div>
779
779
  `;
780
780
  }
781
781
  get activityIndicatorTemplate() {
782
782
  if (!this.loading) {
783
783
  return nothing;
784
784
  }
785
- return html `
786
- <ia-activity-indicator mode="processing"> </ia-activity-indicator>
785
+ return html `
786
+ <ia-activity-indicator mode="processing"> </ia-activity-indicator>
787
787
  `;
788
788
  }
789
789
  render() {
790
790
  if (!this.hasBinData) {
791
791
  return this.noDataTemplate;
792
792
  }
793
- return html `
794
- <div
795
- id="container"
796
- class="
797
- noselect
798
- ${this._isDragging ? 'dragging' : ''}
799
- "
800
- style="width: ${this.width}px"
801
- >
802
- ${this.activityIndicatorTemplate} ${this.tooltipTemplate}
803
- <div
804
- class="inner-container
805
- ${this.disabled ? 'disabled' : ''}"
806
- >
807
- <svg
808
- width="${this.width}"
809
- height="${this.height}"
810
- @pointerleave="${this.drop}"
811
- >
812
- ${this.selectedRangeTemplate}
813
- <svg id="histogram">${this.histogramTemplate}</svg>
814
- ${this.minSliderTemplate} ${this.maxSliderTemplate}
815
- </svg>
816
- <div id="inputs">
817
- ${this.minLabelTemplate} ${this.minInputTemplate}
818
- <div class="dash">-</div>
819
- ${this.maxLabelTemplate} ${this.maxInputTemplate}
820
- <slot name="inputs-right-side"></slot>
821
- </div>
822
- </div>
823
- </div>
793
+ return html `
794
+ <div
795
+ id="container"
796
+ class="
797
+ noselect
798
+ ${this._isDragging ? 'dragging' : ''}
799
+ "
800
+ style="width: ${this.width}px"
801
+ >
802
+ ${this.activityIndicatorTemplate} ${this.tooltipTemplate}
803
+ <div
804
+ class="inner-container
805
+ ${this.disabled ? 'disabled' : ''}"
806
+ >
807
+ <svg
808
+ width="${this.width}"
809
+ height="${this.height}"
810
+ @pointerleave="${this.drop}"
811
+ >
812
+ ${this.selectedRangeTemplate}
813
+ <svg id="histogram">${this.histogramTemplate}</svg>
814
+ ${this.minSliderTemplate} ${this.maxSliderTemplate}
815
+ </svg>
816
+ <div id="inputs">
817
+ ${this.minLabelTemplate} ${this.minInputTemplate}
818
+ <div class="dash">-</div>
819
+ ${this.maxLabelTemplate} ${this.maxInputTemplate}
820
+ <slot name="inputs-right-side"></slot>
821
+ </div>
822
+ </div>
823
+ </div>
824
824
  `;
825
825
  }
826
826
  };
827
- HistogramDateRange.styles = css `
828
- .missing-data-message {
829
- text-align: center;
830
- }
831
- #container {
832
- margin: 0;
833
- touch-action: none;
834
- position: relative;
835
- }
836
- .disabled {
837
- opacity: 0.3;
838
- }
839
- ia-activity-indicator {
840
- position: absolute;
841
- left: calc(50% - 10px);
842
- top: 10px;
843
- width: 20px;
844
- height: 20px;
845
- --activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);
846
- --activityIndicatorLoadingRingColor: ${activityIndicatorColor};
847
- }
848
-
849
- /* prevent selection from interfering with tooltip, especially on mobile */
850
- /* https://stackoverflow.com/a/4407335/1163042 */
851
- .noselect {
852
- -webkit-touch-callout: none; /* iOS Safari */
853
- -webkit-user-select: none; /* Safari */
854
- -moz-user-select: none; /* Old versions of Firefox */
855
- -ms-user-select: none; /* Internet Explorer/Edge */
856
- user-select: none; /* current Chrome, Edge, Opera and Firefox */
857
- }
858
- .bar {
859
- /* create a transparent border around the hist bars to prevent "gaps" and
860
- flickering when moving around between bars. this also helps with handling
861
- clicks on the bars, preventing users from being able to click in between
862
- bars */
863
- stroke: rgba(0, 0, 0, 0);
864
- /* ensure transparent stroke wide enough to cover gap between bars */
865
- stroke-width: 2px;
866
- }
867
- .bar:hover {
868
- /* highlight currently hovered bar */
869
- fill-opacity: 0.7;
870
- }
871
- .disabled .bar:hover {
872
- /* ensure no visual hover interaction when disabled */
873
- fill-opacity: 1;
874
- }
875
- /****** histogram ********/
876
- #tooltip {
877
- position: absolute;
878
- background: ${tooltipBackgroundColor};
879
- margin: 0;
880
- border: 0;
881
- color: ${tooltipTextColor};
882
- text-align: center;
883
- border-radius: 3px;
884
- padding: 2px;
885
- font-size: ${tooltipFontSize};
886
- font-family: ${tooltipFontFamily};
887
- touch-action: none;
888
- pointer-events: none;
889
- overflow: visible;
890
- }
891
- #tooltip:after {
892
- content: '';
893
- position: absolute;
894
- margin-left: -5px;
895
- top: 100%;
896
- left: 50%;
897
- /* arrow */
898
- border: 5px solid ${tooltipTextColor};
899
- border-color: ${tooltipBackgroundColor} transparent transparent
900
- transparent;
901
- }
902
- /****** slider ********/
903
- .slider {
904
- shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */
905
- }
906
- .draggable:hover {
907
- cursor: grab;
908
- }
909
- .dragging {
910
- cursor: grabbing !important;
911
- }
912
- /****** inputs ********/
913
- #inputs {
914
- display: flex;
915
- justify-content: center;
916
- margin: ${inputRowMargin};
917
- }
918
- #inputs .dash {
919
- position: relative;
920
- bottom: -1px;
921
- align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */
922
- }
923
- input {
924
- width: ${inputWidth};
925
- margin: 0 3px;
926
- border: ${inputBorder};
927
- border-radius: 2px !important;
928
- text-align: center;
929
- font-size: ${inputFontSize};
930
- font-family: ${inputFontFamily};
931
- }
932
- .sr-only {
933
- position: absolute !important;
934
- width: 1px !important;
935
- height: 1px !important;
936
- margin: 0 !important;
937
- padding: 0 !important;
938
- border: 0 !important;
939
- overflow: hidden !important;
940
- white-space: nowrap !important;
941
- clip: rect(1px, 1px, 1px, 1px) !important;
942
- -webkit-clip-path: inset(50%) !important;
943
- clip-path: inset(50%) !important;
944
- }
827
+ HistogramDateRange.styles = css `
828
+ .missing-data-message {
829
+ text-align: center;
830
+ }
831
+ #container {
832
+ margin: 0;
833
+ touch-action: none;
834
+ position: relative;
835
+ }
836
+ .disabled {
837
+ opacity: 0.3;
838
+ }
839
+ ia-activity-indicator {
840
+ position: absolute;
841
+ left: calc(50% - 10px);
842
+ top: 10px;
843
+ width: 20px;
844
+ height: 20px;
845
+ --activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);
846
+ --activityIndicatorLoadingRingColor: ${activityIndicatorColor};
847
+ }
848
+
849
+ /* prevent selection from interfering with tooltip, especially on mobile */
850
+ /* https://stackoverflow.com/a/4407335/1163042 */
851
+ .noselect {
852
+ -webkit-touch-callout: none; /* iOS Safari */
853
+ -webkit-user-select: none; /* Safari */
854
+ -moz-user-select: none; /* Old versions of Firefox */
855
+ -ms-user-select: none; /* Internet Explorer/Edge */
856
+ user-select: none; /* current Chrome, Edge, Opera and Firefox */
857
+ }
858
+ .bar {
859
+ /* create a transparent border around the hist bars to prevent "gaps" and
860
+ flickering when moving around between bars. this also helps with handling
861
+ clicks on the bars, preventing users from being able to click in between
862
+ bars */
863
+ stroke: rgba(0, 0, 0, 0);
864
+ /* ensure transparent stroke wide enough to cover gap between bars */
865
+ stroke-width: 2px;
866
+ }
867
+ .bar:hover {
868
+ /* highlight currently hovered bar */
869
+ fill-opacity: 0.7;
870
+ }
871
+ .disabled .bar:hover {
872
+ /* ensure no visual hover interaction when disabled */
873
+ fill-opacity: 1;
874
+ }
875
+ /****** histogram ********/
876
+ #tooltip {
877
+ position: absolute;
878
+ background: ${tooltipBackgroundColor};
879
+ margin: 0;
880
+ border: 0;
881
+ color: ${tooltipTextColor};
882
+ text-align: center;
883
+ border-radius: 3px;
884
+ padding: 2px;
885
+ font-size: ${tooltipFontSize};
886
+ font-family: ${tooltipFontFamily};
887
+ touch-action: none;
888
+ pointer-events: none;
889
+ overflow: visible;
890
+ }
891
+ #tooltip:after {
892
+ content: '';
893
+ position: absolute;
894
+ margin-left: -5px;
895
+ top: 100%;
896
+ left: 50%;
897
+ /* arrow */
898
+ border: 5px solid ${tooltipTextColor};
899
+ border-color: ${tooltipBackgroundColor} transparent transparent
900
+ transparent;
901
+ }
902
+ /****** slider ********/
903
+ .slider {
904
+ shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */
905
+ }
906
+ .draggable:hover {
907
+ cursor: grab;
908
+ }
909
+ .dragging {
910
+ cursor: grabbing !important;
911
+ }
912
+ /****** inputs ********/
913
+ #inputs {
914
+ display: flex;
915
+ justify-content: center;
916
+ margin: ${inputRowMargin};
917
+ }
918
+ #inputs .dash {
919
+ position: relative;
920
+ bottom: -1px;
921
+ align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */
922
+ }
923
+ input {
924
+ width: ${inputWidth};
925
+ margin: 0 3px;
926
+ border: ${inputBorder};
927
+ border-radius: 2px !important;
928
+ text-align: center;
929
+ font-size: ${inputFontSize};
930
+ font-family: ${inputFontFamily};
931
+ }
932
+ .sr-only {
933
+ position: absolute !important;
934
+ width: 1px !important;
935
+ height: 1px !important;
936
+ margin: 0 !important;
937
+ padding: 0 !important;
938
+ border: 0 !important;
939
+ overflow: hidden !important;
940
+ white-space: nowrap !important;
941
+ clip: rect(1px, 1px, 1px, 1px) !important;
942
+ -webkit-clip-path: inset(50%) !important;
943
+ clip-path: inset(50%) !important;
944
+ }
945
945
  `;
946
946
  __decorate([
947
947
  property({ type: Number })