@internetarchive/histogram-date-range 1.3.1-alpha-webdev7745.0 → 1.3.1

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.
@@ -381,9 +381,9 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
381
381
  const formattedNumItems = Number(dataset.numItems).toLocaleString();
382
382
  this._tooltipOffset =
383
383
  x + (this._binWidth - this.sliderWidth - this.tooltipWidth) / 2;
384
- this._tooltipContent = html `
385
- ${formattedNumItems} ${itemsText}<br />
386
- ${dataset.tooltip}
384
+ this._tooltipContent = html `
385
+ ${formattedNumItems} ${itemsText}<br />
386
+ ${dataset.tooltip}
387
387
  `;
388
388
  this._tooltipVisible = true;
389
389
  }
@@ -579,25 +579,25 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
579
579
  // border-radius); used as part of a SVG quadratic curve. see
580
580
  // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands
581
581
  const cs = SLIDER_CORNER_SIZE;
582
- const sliderShape = `
583
- M${this.minSliderX},0
584
- h-${this.sliderWidth - cs}
585
- q-${cs},0 -${cs},${cs}
586
- v${this.height - cs * 2}
587
- q0,${cs} ${cs},${cs}
588
- h${this.sliderWidth - cs}
582
+ const sliderShape = `
583
+ M${this.minSliderX},0
584
+ h-${this.sliderWidth - cs}
585
+ q-${cs},0 -${cs},${cs}
586
+ v${this.height - cs * 2}
587
+ q0,${cs} ${cs},${cs}
588
+ h${this.sliderWidth - cs}
589
589
  `;
590
590
  return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);
591
591
  }
592
592
  get maxSliderTemplate() {
593
593
  const cs = SLIDER_CORNER_SIZE;
594
- const sliderShape = `
595
- M${this.maxSliderX},0
596
- h${this.sliderWidth - cs}
597
- q${cs},0 ${cs},${cs}
598
- v${this.height - cs * 2}
599
- q0,${cs} -${cs},${cs}
600
- h-${this.sliderWidth - cs}
594
+ const sliderShape = `
595
+ M${this.maxSliderX},0
596
+ h${this.sliderWidth - cs}
597
+ q${cs},0 ${cs},${cs}
598
+ v${this.height - cs * 2}
599
+ q0,${cs} -${cs},${cs}
600
+ h-${this.sliderWidth - cs}
601
601
  `;
602
602
  return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);
603
603
  }
@@ -610,38 +610,38 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
610
610
  draggable: !this.disabled,
611
611
  dragging: this._isDragging,
612
612
  });
613
- return svg `
614
- <svg
615
- id=${id}
616
- class=${sliderClasses}
617
- @pointerdown=${this.drag}
618
- >
619
- <path d="${sliderShape} z" fill="${sliderColor}" />
620
- <rect
621
- x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k}"
622
- y="${this.height / 3}"
623
- width="1"
624
- height="${this.height / 3}"
625
- fill="white"
626
- />
627
- <rect
628
- x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k}"
629
- y="${this.height / 3}"
630
- width="1"
631
- height="${this.height / 3}"
632
- fill="white"
633
- />
634
- </svg>
613
+ return svg `
614
+ <svg
615
+ id=${id}
616
+ class=${sliderClasses}
617
+ @pointerdown=${this.drag}
618
+ >
619
+ <path d="${sliderShape} z" fill="${sliderColor}" />
620
+ <rect
621
+ x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k}"
622
+ y="${this.height / 3}"
623
+ width="1"
624
+ height="${this.height / 3}"
625
+ fill="white"
626
+ />
627
+ <rect
628
+ x="${sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k}"
629
+ y="${this.height / 3}"
630
+ width="1"
631
+ height="${this.height / 3}"
632
+ fill="white"
633
+ />
634
+ </svg>
635
635
  `;
636
636
  }
637
637
  get selectedRangeTemplate() {
638
- return svg `
639
- <rect
640
- x="${this.minSliderX}"
641
- y="0"
642
- width="${this.maxSliderX - this.minSliderX}"
643
- height="${this.height}"
644
- fill="${selectedRangeColor}"
638
+ return svg `
639
+ <rect
640
+ x="${this.minSliderX}"
641
+ y="0"
642
+ width="${this.maxSliderX - this.minSliderX}"
643
+ height="${this.height}"
644
+ fill="${selectedRangeColor}"
645
645
  />`;
646
646
  }
647
647
  get histogramTemplate() {
@@ -659,22 +659,22 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
659
659
  // between adjacent bars (eg when viewing the tooltips or when trying to
660
660
  // extend the range by clicking on a bar)
661
661
  const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;
662
- const bar = svg `
663
- <rect
664
- class="bar"
665
- style=${barStyle}
666
- x=${x}
667
- y=${this.height - barHeight}
668
- width=${barWidth}
669
- height=${barHeight}
670
- @pointerenter=${this.showTooltip}
671
- @pointerleave=${this.hideTooltip}
672
- @click=${this.handleBarClick}
673
- fill=${barFill}
674
- data-num-items=${data.value}
675
- data-bin-start=${data.binStart}
676
- data-bin-end=${data.binEnd}
677
- data-tooltip=${data.tooltip}
662
+ const bar = svg `
663
+ <rect
664
+ class="bar"
665
+ style=${barStyle}
666
+ x=${x}
667
+ y=${this.height - barHeight}
668
+ width=${barWidth}
669
+ height=${barHeight}
670
+ @pointerenter=${this.showTooltip}
671
+ @pointerleave=${this.hideTooltip}
672
+ @click=${this.handleBarClick}
673
+ fill=${barFill}
674
+ data-num-items=${data.value}
675
+ data-bin-start=${data.binStart}
676
+ data-bin-end=${data.binEnd}
677
+ data-tooltip=${data.tooltip}
678
678
  />`;
679
679
  x += xScale;
680
680
  return bar;
@@ -714,31 +714,31 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
714
714
  * https://lit.dev/docs/templates/directives/#live
715
715
  */
716
716
  get minInputTemplate() {
717
- return html `
718
- <input
719
- id="date-min"
720
- placeholder=${this.dateFormat}
721
- type="text"
722
- @focus=${this.handleInputFocus}
723
- @blur=${this.handleMinDateInput}
724
- @keyup=${this.handleKeyUp}
725
- .value=${live(this.minSelectedDate)}
726
- ?disabled=${this.disabled}
727
- />
717
+ return html `
718
+ <input
719
+ id="date-min"
720
+ placeholder=${this.dateFormat}
721
+ type="text"
722
+ @focus=${this.handleInputFocus}
723
+ @blur=${this.handleMinDateInput}
724
+ @keyup=${this.handleKeyUp}
725
+ .value=${live(this.minSelectedDate)}
726
+ ?disabled=${this.disabled}
727
+ />
728
728
  `;
729
729
  }
730
730
  get maxInputTemplate() {
731
- return html `
732
- <input
733
- id="date-max"
734
- placeholder=${this.dateFormat}
735
- type="text"
736
- @focus=${this.handleInputFocus}
737
- @blur=${this.handleMaxDateInput}
738
- @keyup=${this.handleKeyUp}
739
- .value=${live(this.maxSelectedDate)}
740
- ?disabled=${this.disabled}
741
- />
731
+ return html `
732
+ <input
733
+ id="date-max"
734
+ placeholder=${this.dateFormat}
735
+ type="text"
736
+ @focus=${this.handleInputFocus}
737
+ @blur=${this.handleMaxDateInput}
738
+ @keyup=${this.handleKeyUp}
739
+ .value=${live(this.maxSelectedDate)}
740
+ ?disabled=${this.disabled}
741
+ />
742
742
  `;
743
743
  }
744
744
  get minLabelTemplate() {
@@ -748,187 +748,187 @@ let HistogramDateRange = class HistogramDateRange extends LitElement {
748
748
  return html `<label for="date-max" class="sr-only">Maximum date:</label>`;
749
749
  }
750
750
  get tooltipTemplate() {
751
- return html `
752
- <style>
753
- #tooltip {
754
- width: ${this.tooltipWidth}px;
755
- height: ${this.tooltipHeight}px;
756
- top: ${-9 - this.tooltipHeight}px;
757
- left: ${this._tooltipOffset}px;
758
- display: ${this._tooltipVisible ? 'block' : 'none'};
759
- }
760
- #tooltip:after {
761
- left: ${this.tooltipWidth / 2}px;
762
- }
763
- </style>
764
- <div id="tooltip">${this._tooltipContent}</div>
751
+ return html `
752
+ <style>
753
+ #tooltip {
754
+ width: ${this.tooltipWidth}px;
755
+ height: ${this.tooltipHeight}px;
756
+ top: ${-9 - this.tooltipHeight}px;
757
+ left: ${this._tooltipOffset}px;
758
+ display: ${this._tooltipVisible ? 'block' : 'none'};
759
+ }
760
+ #tooltip:after {
761
+ left: ${this.tooltipWidth / 2}px;
762
+ }
763
+ </style>
764
+ <div id="tooltip">${this._tooltipContent}</div>
765
765
  `;
766
766
  }
767
767
  get noDataTemplate() {
768
- return html `
769
- <div class="missing-data-message">${this.missingDataMessage}</div>
768
+ return html `
769
+ <div class="missing-data-message">${this.missingDataMessage}</div>
770
770
  `;
771
771
  }
772
772
  get activityIndicatorTemplate() {
773
773
  if (!this.loading) {
774
774
  return nothing;
775
775
  }
776
- return html `
777
- <ia-activity-indicator mode="processing"> </ia-activity-indicator>
776
+ return html `
777
+ <ia-activity-indicator mode="processing"> </ia-activity-indicator>
778
778
  `;
779
779
  }
780
780
  render() {
781
781
  if (!this.hasBinData) {
782
782
  return this.noDataTemplate;
783
783
  }
784
- return html `
785
- <div
786
- id="container"
787
- class="
788
- noselect
789
- ${this._isDragging ? 'dragging' : ''}
790
- "
791
- style="width: ${this.width}px"
792
- >
793
- ${this.activityIndicatorTemplate} ${this.tooltipTemplate}
794
- <div
795
- class="inner-container
796
- ${this.disabled ? 'disabled' : ''}"
797
- >
798
- <svg
799
- width="${this.width}"
800
- height="${this.height}"
801
- @pointerleave="${this.drop}"
802
- >
803
- ${this.selectedRangeTemplate}
804
- <svg id="histogram">${this.histogramTemplate}</svg>
805
- ${this.minSliderTemplate} ${this.maxSliderTemplate}
806
- </svg>
807
- <div id="inputs">
808
- ${this.minLabelTemplate} ${this.minInputTemplate}
809
- <div class="dash">-</div>
810
- ${this.maxLabelTemplate} ${this.maxInputTemplate}
811
- <slot name="inputs-right-side"></slot>
812
- </div>
813
- </div>
814
- </div>
784
+ return html `
785
+ <div
786
+ id="container"
787
+ class="
788
+ noselect
789
+ ${this._isDragging ? 'dragging' : ''}
790
+ "
791
+ style="width: ${this.width}px"
792
+ >
793
+ ${this.activityIndicatorTemplate} ${this.tooltipTemplate}
794
+ <div
795
+ class="inner-container
796
+ ${this.disabled ? 'disabled' : ''}"
797
+ >
798
+ <svg
799
+ width="${this.width}"
800
+ height="${this.height}"
801
+ @pointerleave="${this.drop}"
802
+ >
803
+ ${this.selectedRangeTemplate}
804
+ <svg id="histogram">${this.histogramTemplate}</svg>
805
+ ${this.minSliderTemplate} ${this.maxSliderTemplate}
806
+ </svg>
807
+ <div id="inputs">
808
+ ${this.minLabelTemplate} ${this.minInputTemplate}
809
+ <div class="dash">-</div>
810
+ ${this.maxLabelTemplate} ${this.maxInputTemplate}
811
+ <slot name="inputs-right-side"></slot>
812
+ </div>
813
+ </div>
814
+ </div>
815
815
  `;
816
816
  }
817
817
  };
818
- HistogramDateRange.styles = css `
819
- .missing-data-message {
820
- text-align: center;
821
- }
822
- #container {
823
- margin: 0;
824
- touch-action: none;
825
- position: relative;
826
- }
827
- .disabled {
828
- opacity: 0.3;
829
- }
830
- ia-activity-indicator {
831
- position: absolute;
832
- left: calc(50% - 10px);
833
- top: 10px;
834
- width: 20px;
835
- height: 20px;
836
- --activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);
837
- --activityIndicatorLoadingRingColor: ${activityIndicatorColor};
838
- }
839
-
840
- /* prevent selection from interfering with tooltip, especially on mobile */
841
- /* https://stackoverflow.com/a/4407335/1163042 */
842
- .noselect {
843
- -webkit-touch-callout: none; /* iOS Safari */
844
- -webkit-user-select: none; /* Safari */
845
- -moz-user-select: none; /* Old versions of Firefox */
846
- -ms-user-select: none; /* Internet Explorer/Edge */
847
- user-select: none; /* current Chrome, Edge, Opera and Firefox */
848
- }
849
- .bar {
850
- /* create a transparent border around the hist bars to prevent "gaps" and
851
- flickering when moving around between bars. this also helps with handling
852
- clicks on the bars, preventing users from being able to click in between
853
- bars */
854
- stroke: rgba(0, 0, 0, 0);
855
- /* ensure transparent stroke wide enough to cover gap between bars */
856
- stroke-width: 2px;
857
- }
858
- .bar:hover {
859
- /* highlight currently hovered bar */
860
- fill-opacity: 0.7;
861
- }
862
- .disabled .bar:hover {
863
- /* ensure no visual hover interaction when disabled */
864
- fill-opacity: 1;
865
- }
866
- /****** histogram ********/
867
- #tooltip {
868
- position: absolute;
869
- background: ${tooltipBackgroundColor};
870
- color: ${tooltipTextColor};
871
- text-align: center;
872
- border-radius: 3px;
873
- padding: 2px;
874
- font-size: ${tooltipFontSize};
875
- font-family: ${tooltipFontFamily};
876
- touch-action: none;
877
- pointer-events: none;
878
- }
879
- #tooltip:after {
880
- content: '';
881
- position: absolute;
882
- margin-left: -5px;
883
- top: 100%;
884
- /* arrow */
885
- border: 5px solid ${tooltipTextColor};
886
- border-color: ${tooltipBackgroundColor} transparent transparent
887
- transparent;
888
- }
889
- /****** slider ********/
890
- .slider {
891
- shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */
892
- }
893
- .draggable:hover {
894
- cursor: grab;
895
- }
896
- .dragging {
897
- cursor: grabbing !important;
898
- }
899
- /****** inputs ********/
900
- #inputs {
901
- display: flex;
902
- justify-content: center;
903
- margin: ${inputRowMargin};
904
- }
905
- #inputs .dash {
906
- position: relative;
907
- bottom: -1px;
908
- align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */
909
- }
910
- input {
911
- width: ${inputWidth};
912
- margin: 0 3px;
913
- border: ${inputBorder};
914
- border-radius: 2px !important;
915
- text-align: center;
916
- font-size: ${inputFontSize};
917
- font-family: ${inputFontFamily};
918
- }
919
- .sr-only {
920
- position: absolute !important;
921
- width: 1px !important;
922
- height: 1px !important;
923
- margin: 0 !important;
924
- padding: 0 !important;
925
- border: 0 !important;
926
- overflow: hidden !important;
927
- white-space: nowrap !important;
928
- clip: rect(1px, 1px, 1px, 1px) !important;
929
- -webkit-clip-path: inset(50%) !important;
930
- clip-path: inset(50%) !important;
931
- }
818
+ HistogramDateRange.styles = css `
819
+ .missing-data-message {
820
+ text-align: center;
821
+ }
822
+ #container {
823
+ margin: 0;
824
+ touch-action: none;
825
+ position: relative;
826
+ }
827
+ .disabled {
828
+ opacity: 0.3;
829
+ }
830
+ ia-activity-indicator {
831
+ position: absolute;
832
+ left: calc(50% - 10px);
833
+ top: 10px;
834
+ width: 20px;
835
+ height: 20px;
836
+ --activityIndicatorLoadingDotColor: rgba(0, 0, 0, 0);
837
+ --activityIndicatorLoadingRingColor: ${activityIndicatorColor};
838
+ }
839
+
840
+ /* prevent selection from interfering with tooltip, especially on mobile */
841
+ /* https://stackoverflow.com/a/4407335/1163042 */
842
+ .noselect {
843
+ -webkit-touch-callout: none; /* iOS Safari */
844
+ -webkit-user-select: none; /* Safari */
845
+ -moz-user-select: none; /* Old versions of Firefox */
846
+ -ms-user-select: none; /* Internet Explorer/Edge */
847
+ user-select: none; /* current Chrome, Edge, Opera and Firefox */
848
+ }
849
+ .bar {
850
+ /* create a transparent border around the hist bars to prevent "gaps" and
851
+ flickering when moving around between bars. this also helps with handling
852
+ clicks on the bars, preventing users from being able to click in between
853
+ bars */
854
+ stroke: rgba(0, 0, 0, 0);
855
+ /* ensure transparent stroke wide enough to cover gap between bars */
856
+ stroke-width: 2px;
857
+ }
858
+ .bar:hover {
859
+ /* highlight currently hovered bar */
860
+ fill-opacity: 0.7;
861
+ }
862
+ .disabled .bar:hover {
863
+ /* ensure no visual hover interaction when disabled */
864
+ fill-opacity: 1;
865
+ }
866
+ /****** histogram ********/
867
+ #tooltip {
868
+ position: absolute;
869
+ background: ${tooltipBackgroundColor};
870
+ color: ${tooltipTextColor};
871
+ text-align: center;
872
+ border-radius: 3px;
873
+ padding: 2px;
874
+ font-size: ${tooltipFontSize};
875
+ font-family: ${tooltipFontFamily};
876
+ touch-action: none;
877
+ pointer-events: none;
878
+ }
879
+ #tooltip:after {
880
+ content: '';
881
+ position: absolute;
882
+ margin-left: -5px;
883
+ top: 100%;
884
+ /* arrow */
885
+ border: 5px solid ${tooltipTextColor};
886
+ border-color: ${tooltipBackgroundColor} transparent transparent
887
+ transparent;
888
+ }
889
+ /****** slider ********/
890
+ .slider {
891
+ shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */
892
+ }
893
+ .draggable:hover {
894
+ cursor: grab;
895
+ }
896
+ .dragging {
897
+ cursor: grabbing !important;
898
+ }
899
+ /****** inputs ********/
900
+ #inputs {
901
+ display: flex;
902
+ justify-content: center;
903
+ margin: ${inputRowMargin};
904
+ }
905
+ #inputs .dash {
906
+ position: relative;
907
+ bottom: -1px;
908
+ align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */
909
+ }
910
+ input {
911
+ width: ${inputWidth};
912
+ margin: 0 3px;
913
+ border: ${inputBorder};
914
+ border-radius: 2px !important;
915
+ text-align: center;
916
+ font-size: ${inputFontSize};
917
+ font-family: ${inputFontFamily};
918
+ }
919
+ .sr-only {
920
+ position: absolute !important;
921
+ width: 1px !important;
922
+ height: 1px !important;
923
+ margin: 0 !important;
924
+ padding: 0 !important;
925
+ border: 0 !important;
926
+ overflow: hidden !important;
927
+ white-space: nowrap !important;
928
+ clip: rect(1px, 1px, 1px, 1px) !important;
929
+ -webkit-clip-path: inset(50%) !important;
930
+ clip-path: inset(50%) !important;
931
+ }
932
932
  `;
933
933
  __decorate([
934
934
  property({ type: Number })