@internetarchive/elements 1.0.1-webdev-9121.0 → 1.0.1-webdev-9121.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.
@@ -1,6 +1,6 @@
1
1
  import '../../elements/ia-status-indicator/ia-status-indicator.js';
2
2
  import { LitElement, PropertyValues, SVGTemplateResult, TemplateResult } from 'lit';
3
- import type { BinSnappingInterval } from './models.js';
3
+ import type { BarScalingOption, BinSnappingInterval } from './models.js';
4
4
  export declare class IAHistogramDateRange extends LitElement {
5
5
  width: number;
6
6
  height: number;
@@ -16,13 +16,45 @@ export declare class IAHistogramDateRange extends LitElement {
16
16
  bins: number[];
17
17
  /** If true, update events will not be canceled by the date inputs receiving focus */
18
18
  updateWhileFocused: boolean;
19
+ /**
20
+ * What interval bins should be snapped to for determining their time ranges.
21
+ * - `none` (default): Bins should each represent an identical duration of time,
22
+ * without regard for the actual dates represented.
23
+ * - `month`: Bins should each represent one or more full, non-overlapping months.
24
+ * The bin ranges will be "snapped" to the nearest month boundaries, which can
25
+ * result in bins that represent different amounts of time, particularly if the
26
+ * provided bins do not evenly divide the provided date range, or if the months
27
+ * represented are of different lengths.
28
+ * - `year`: Same as `month`, but snapping to year boundaries instead of months.
29
+ */
19
30
  binSnapping: BinSnappingInterval;
20
- private _tooltipOffset;
31
+ /**
32
+ * What label to use on tooltips to identify the type of data being represented.
33
+ * Defaults to `'item(s)'`.
34
+ */
35
+ tooltipLabel: string;
36
+ /**
37
+ * A function or preset value indicating how the height of each bar relates to its
38
+ * corresponding bin value. Current presets available are 'logarithmic' and 'linear',
39
+ * but a custom function may be provided instead if other behavior is desired.
40
+ *
41
+ * The default scaling (`'logarithmic'`) uses the logarithm of each bin value, yielding
42
+ * more prominent bars for smaller values. This ensures that even when the difference
43
+ * between the min & max values is large, small values are unlikely to completely disappear
44
+ * visually. However, the cost is that bars have less noticeable variation among values of
45
+ * a similar magnitude, and their heights are not a direct representation of the bin values.
46
+ *
47
+ * The `'linear'` preset option instead sizes the bars in linear proportion to their bin
48
+ * values.
49
+ */
50
+ barScaling: BarScalingOption;
51
+ private _tooltipOffsetX;
52
+ private _tooltipOffsetY;
21
53
  private _tooltipContent?;
22
- private _tooltipVisible;
23
54
  private _tooltipDateFormat?;
24
55
  private _isDragging;
25
56
  private _isLoading;
57
+ private _tooltip;
26
58
  private _minSelectedDate;
27
59
  private _maxSelectedDate;
28
60
  private _minDateMS;
@@ -35,6 +67,7 @@ export declare class IAHistogramDateRange extends LitElement {
35
67
  private _emitUpdatedEventTimer?;
36
68
  private _previousDateRange;
37
69
  private _updateDeferredWhileFocused;
70
+ updated(): void;
38
71
  disconnectedCallback(): void;
39
72
  willUpdate(changedProps: PropertyValues): void;
40
73
  /**
@@ -66,6 +99,10 @@ export declare class IAHistogramDateRange extends LitElement {
66
99
  * Default is simply to snap to the nearest full second.
67
100
  */
68
101
  private snapTimestamp;
102
+ /**
103
+ * Function to scale bin values, whether from a preset or a provided custom function.
104
+ */
105
+ private get barScalingFunction();
69
106
  private calculateHistData;
70
107
  private get hasBinData();
71
108
  private get _numBins();
@@ -192,6 +229,7 @@ export declare class IAHistogramDateRange extends LitElement {
192
229
  get minLabelTemplate(): TemplateResult;
193
230
  get maxLabelTemplate(): TemplateResult;
194
231
  get tooltipTemplate(): TemplateResult;
232
+ private get histogramAccessibilityTemplate();
195
233
  private get noDataTemplate();
196
234
  private get activityIndicatorTemplate();
197
235
  static styles: import("lit").CSSResult;
@@ -1 +1 @@
1
- {"version":3,"file":"ia-histogram-date-range.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-histogram-date-range/ia-histogram-date-range.ts"],"names":[],"mappings":"AAAA,OAAO,uDAAuD,CAAC;AAI/D,OAAO,EAGL,UAAU,EAEV,cAAc,EAEd,iBAAiB,EACjB,cAAc,EACf,MAAM,KAAK,CAAC;AAKb,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAkDpD,qBACa,oBAAqB,SAA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;OAKG;IACH,OAAO,CAAC,uBAAuB;IAQ/B,sEAAsE;IACtE,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,WAAW;IAYnB,OAAO,KAAK,sBAAsB,GAEjC;IAED,OAAO,CAAC,eAAe;IAgBvB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAuBtB,OAAO,KAAK,iBAAiB,GAe5B;IAED,OAAO,KAAK,iBAAiB,GAW5B;IAED,OAAO,CAAC,iBAAiB;IA4CzB,IAAI,qBAAqB,IAAI,iBAAiB,CAS7C;IAED,IAAI,iBAAiB,IAAI,iBAAiB,EAAE,CAwC3C;IAED,6EAA6E;IAC7E,OAAO,CAAC,QAAQ;IAMhB,4EAA4E;IAC5E,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,UAAU;IAgBlB;;;;;OAKG;IACH,IAAI,gBAAgB,IAAI,cAAc,CAarC;IAED,IAAI,gBAAgB,IAAI,cAAc,CAarC;IAED,IAAI,gBAAgB,IAAI,cAAc,CAErC;IAED,IAAI,gBAAgB,IAAI,cAAc,CAErC;IAED,IAAI,eAAe,IAAI,cAAc,CAgBpC;IAED,OAAO,KAAK,cAAc,GAIzB;IAED,OAAO,KAAK,yBAAyB,GAQpC;IAED,MAAM,CAAC,MAAM,0BAgHX;IAEF,MAAM,IAAI,cAAc;CAqCzB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,yBAAyB,EAAE,oBAAoB,CAAC;KACjD;CACF"}
1
+ {"version":3,"file":"ia-histogram-date-range.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-histogram-date-range/ia-histogram-date-range.ts"],"names":[],"mappings":"AAAA,OAAO,uDAAuD,CAAC;AAI/D,OAAO,EAGL,UAAU,EAEV,cAAc,EAEd,iBAAiB,EACjB,cAAc,EACf,MAAM,KAAK,CAAC;AAMb,OAAO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Ac;CAsCzB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,yBAAyB,EAAE,oBAAoB,CAAC;KACjD;CACF"}
@@ -4,9 +4,10 @@ import dayjs from 'dayjs/esm';
4
4
  import customParseFormat from 'dayjs/esm/plugin/customParseFormat';
5
5
  import fixFirstCenturyYears from './plugins/fix-first-century-years.js';
6
6
  import { css, html, LitElement, nothing, svg, } from 'lit';
7
- import { property, state } from 'lit/decorators.js';
7
+ import { property, state, query } from 'lit/decorators.js';
8
8
  import { live } from 'lit/directives/live.js';
9
9
  import { classMap } from 'lit/directives/class-map.js';
10
+ import { styleMap } from 'lit/directives/style-map.js';
10
11
  import { customElement } from '../../util/custom-element.js';
11
12
  dayjs.extend(customParseFormat);
12
13
  dayjs.extend(fixFirstCenturyYears);
@@ -19,8 +20,16 @@ const TOOLTIP_HEIGHT = 30;
19
20
  const DATE_FORMAT = 'YYYY';
20
21
  const MISSING_DATA = 'no data';
21
22
  const UPDATE_DEBOUNCE_DELAY_MS = 0;
23
+ const TOOLTIP_LABEL = 'item';
22
24
  // this constant is not set up to be overridden
23
25
  const SLIDER_CORNER_SIZE = 4;
26
+ /**
27
+ * Map from bar scaling preset options to the corresponding function they represent
28
+ */
29
+ const BAR_SCALING_PRESET_FNS = {
30
+ linear: (binValue) => binValue,
31
+ logarithmic: (binValue) => Math.log1p(binValue),
32
+ };
24
33
  // these CSS custom props can be overridden from the HTML that is invoking this component
25
34
  const sliderColor = css `var(--histogramDateRangeSliderColor, #4B65FE)`;
26
35
  const selectedRangeColor = css `var(--histogramDateRangeSelectedRangeColor, #DBE0FF)`;
@@ -54,10 +63,41 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
54
63
  this.bins = [];
55
64
  /** If true, update events will not be canceled by the date inputs receiving focus */
56
65
  this.updateWhileFocused = false;
66
+ /**
67
+ * What interval bins should be snapped to for determining their time ranges.
68
+ * - `none` (default): Bins should each represent an identical duration of time,
69
+ * without regard for the actual dates represented.
70
+ * - `month`: Bins should each represent one or more full, non-overlapping months.
71
+ * The bin ranges will be "snapped" to the nearest month boundaries, which can
72
+ * result in bins that represent different amounts of time, particularly if the
73
+ * provided bins do not evenly divide the provided date range, or if the months
74
+ * represented are of different lengths.
75
+ * - `year`: Same as `month`, but snapping to year boundaries instead of months.
76
+ */
57
77
  this.binSnapping = 'none';
78
+ /**
79
+ * What label to use on tooltips to identify the type of data being represented.
80
+ * Defaults to `'item(s)'`.
81
+ */
82
+ this.tooltipLabel = TOOLTIP_LABEL;
83
+ /**
84
+ * A function or preset value indicating how the height of each bar relates to its
85
+ * corresponding bin value. Current presets available are 'logarithmic' and 'linear',
86
+ * but a custom function may be provided instead if other behavior is desired.
87
+ *
88
+ * The default scaling (`'logarithmic'`) uses the logarithm of each bin value, yielding
89
+ * more prominent bars for smaller values. This ensures that even when the difference
90
+ * between the min & max values is large, small values are unlikely to completely disappear
91
+ * visually. However, the cost is that bars have less noticeable variation among values of
92
+ * a similar magnitude, and their heights are not a direct representation of the bin values.
93
+ *
94
+ * The `'linear'` preset option instead sizes the bars in linear proportion to their bin
95
+ * values.
96
+ */
97
+ this.barScaling = 'logarithmic';
58
98
  // internal reactive properties not exposed as attributes
59
- this._tooltipOffset = 0;
60
- this._tooltipVisible = false;
99
+ this._tooltipOffsetX = 0;
100
+ this._tooltipOffsetY = 0;
61
101
  this._isDragging = false;
62
102
  this._isLoading = false;
63
103
  // non-reactive properties (changes don't auto-trigger re-rendering)
@@ -113,25 +153,30 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
113
153
  }
114
154
  };
115
155
  }
156
+ updated() {
157
+ // The UA only hides a closed popover where showPopover() exists. Without
158
+ // it the tooltip would sit on the page whenever it isn't being shown, so
159
+ // hide it the one way that works either way. Not just on first render:
160
+ // the tooltip isn't in the DOM at all until there's data to draw.
161
+ if (this._tooltip && !this._tooltipContent) {
162
+ this._tooltip.hidden = true;
163
+ }
164
+ }
116
165
  disconnectedCallback() {
117
166
  this.removeListeners();
118
167
  super.disconnectedCallback();
119
168
  }
120
169
  willUpdate(changedProps) {
121
- // check for changes that would affect bin data calculations. Note:
122
- // minSelectedDate/maxSelectedDate deliberately aren't in this list even
123
- // though handleDataUpdate() defaults them from minDate/maxDate — the
124
- // recalculation here (histWidth/minDateMS/maxDateMS/binWidth/histData)
125
- // doesn't depend on either, and refreshing _previousDateRange as a side
126
- // effect of a date being picked would make beginEmitUpdateProcess's
127
- // "did anything change" check always see no change, since it compares
128
- // against a value this same pick had just overwritten.
170
+ // check for changes that would affect bin data calculations
129
171
  if (changedProps.has('bins') ||
130
172
  changedProps.has('minDate') ||
131
173
  changedProps.has('maxDate') ||
174
+ changedProps.has('minSelectedDate') ||
175
+ changedProps.has('maxSelectedDate') ||
132
176
  changedProps.has('width') ||
133
177
  changedProps.has('height') ||
134
- changedProps.has('binSnapping')) {
178
+ changedProps.has('binSnapping') ||
179
+ changedProps.has('barScaling')) {
135
180
  this.handleDataUpdate();
136
181
  }
137
182
  }
@@ -153,7 +198,6 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
153
198
  this._maxDateMS =
154
199
  this.snapTimestamp(this.getMSFromString(this.maxDate) + this.snapInterval) + this.snapEndOffset;
155
200
  this._binWidth = this._histWidth / this._numBins;
156
- this._previousDateRange = this.currentDateRangeString;
157
201
  this._histData = this.calculateHistData();
158
202
  this.minSelectedDate = this.minSelectedDate
159
203
  ? this.minSelectedDate
@@ -219,13 +263,22 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
219
263
  return this.snapToNextSecond(timestamp);
220
264
  }
221
265
  }
266
+ /**
267
+ * Function to scale bin values, whether from a preset or a provided custom function.
268
+ */
269
+ get barScalingFunction() {
270
+ if (typeof this.barScaling === 'string') {
271
+ return BAR_SCALING_PRESET_FNS[this.barScaling];
272
+ }
273
+ return this.barScaling;
274
+ }
222
275
  calculateHistData() {
223
276
  const { bins, height, dateRangeMS, _numBins, _minDateMS } = this;
224
277
  const minValue = Math.min(...this.bins);
225
278
  const maxValue = Math.max(...this.bins);
226
279
  // if there is no difference between the min and max values, use a range of
227
280
  // 1 because log scaling will fail if the range is 0
228
- const valueRange = minValue === maxValue ? 1 : Math.log1p(maxValue);
281
+ const valueRange = minValue === maxValue ? 1 : this.barScalingFunction(maxValue);
229
282
  const valueScale = height / valueRange;
230
283
  const dateScale = dateRangeMS / _numBins;
231
284
  return bins.map((v, i) => {
@@ -242,9 +295,8 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
242
295
  : `${tooltipStart} - ${tooltipEnd}`;
243
296
  return {
244
297
  value: v,
245
- // use log scaling for the height of the bar to prevent tall bars from
246
- // making the smaller ones too small to see
247
- height: Math.floor(Math.log1p(v) * valueScale),
298
+ // apply the configured scaling function to the bin value before determining bar height
299
+ height: Math.floor(this.barScalingFunction(v) * valueScale),
248
300
  binStart,
249
301
  binEnd,
250
302
  tooltip,
@@ -370,19 +422,33 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
370
422
  const target = e.currentTarget;
371
423
  const x = target.x.baseVal.value + this.sliderWidth / 2;
372
424
  const dataset = target.dataset;
373
- const itemsText = `item${dataset.numItems !== '1' ? 's' : ''}`;
425
+ const itemsText = `${this.tooltipLabel}${dataset.numItems !== '1' ? 's' : ''}`;
374
426
  const formattedNumItems = Number(dataset.numItems).toLocaleString();
375
- this._tooltipOffset =
376
- x + (this._binWidth - this.sliderWidth - this.tooltipWidth) / 2;
427
+ const tooltipPadding = 2;
428
+ const bufferHeight = 9;
429
+ const heightAboveHistogram = bufferHeight + this.tooltipHeight;
430
+ const histogramBounds = this.getBoundingClientRect();
431
+ const barX = histogramBounds.x + x;
432
+ const histogramY = histogramBounds.y;
433
+ // Center the tooltip horizontally along the bar
434
+ this._tooltipOffsetX =
435
+ barX -
436
+ tooltipPadding +
437
+ (this._binWidth - this.sliderWidth - this.tooltipWidth) / 2 +
438
+ window.scrollX;
439
+ // Place the tooltip (with arrow) just above the top of the histogram bars
440
+ this._tooltipOffsetY = histogramY - heightAboveHistogram + window.scrollY;
377
441
  this._tooltipContent = html `
378
442
  ${formattedNumItems} ${itemsText}<br />
379
443
  ${dataset.tooltip}
380
444
  `;
381
- this._tooltipVisible = true;
445
+ this._tooltip.hidden = false;
446
+ this._tooltip.showPopover?.();
382
447
  }
383
448
  hideTooltip() {
384
449
  this._tooltipContent = undefined;
385
- this._tooltipVisible = false;
450
+ this._tooltip.hidden = true;
451
+ this._tooltip.hidePopover?.();
386
452
  }
387
453
  /**
388
454
  * Constrain a proposed value for the minimum (left) slider
@@ -669,20 +735,28 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
669
735
  const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;
670
736
  const bar = svg `
671
737
  <rect
672
- class="bar"
673
- style=${barStyle}
738
+ class="bar-pointer-target"
674
739
  x=${x}
675
- y=${this.height - barHeight}
740
+ y="0"
676
741
  width=${barWidth}
677
- height=${barHeight}
742
+ height=${this.height}
678
743
  @pointerenter=${this.showTooltip}
679
744
  @pointerleave=${this.hideTooltip}
680
745
  @click=${this.handleBarClick}
681
- fill=${barFill}
746
+ fill="transparent"
682
747
  data-num-items=${data.value}
683
748
  data-bin-start=${data.binStart}
684
749
  data-bin-end=${data.binEnd}
685
750
  data-tooltip=${data.tooltip}
751
+ />
752
+ <rect
753
+ class="bar"
754
+ style=${barStyle}
755
+ x=${x}
756
+ y=${this.height - barHeight}
757
+ width=${barWidth}
758
+ height=${barHeight}
759
+ fill=${barFill}
686
760
  />`;
687
761
  x += xScale;
688
762
  return bar;
@@ -756,21 +830,31 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
756
830
  return html `<label for="date-max" class="sr-only">Maximum date:</label>`;
757
831
  }
758
832
  get tooltipTemplate() {
833
+ const styles = styleMap({
834
+ width: `${this.tooltipWidth}px`,
835
+ height: `${this.tooltipHeight}px`,
836
+ top: `${this._tooltipOffsetY}px`,
837
+ left: `${this._tooltipOffsetX}px`,
838
+ });
759
839
  return html `
760
- <style>
761
- #tooltip {
762
- width: ${this.tooltipWidth}px;
763
- height: ${this.tooltipHeight}px;
764
- top: ${-9 - this.tooltipHeight}px;
765
- left: ${this._tooltipOffset}px;
766
- display: ${this._tooltipVisible ? 'block' : 'none'};
840
+ <div id="tooltip" style=${styles} popover>${this._tooltipContent}</div>
841
+ `;
842
+ }
843
+ get histogramAccessibilityTemplate() {
844
+ let rangeText = '';
845
+ if (this.minSelectedDate && this.maxSelectedDate) {
846
+ rangeText = ` from ${this.minSelectedDate} to ${this.maxSelectedDate}`;
767
847
  }
768
- #tooltip:after {
769
- left: ${this.tooltipWidth / 2}px;
848
+ else if (this.minSelectedDate) {
849
+ rangeText = ` from ${this.minSelectedDate}`;
770
850
  }
771
- </style>
772
- <div id="tooltip">${this._tooltipContent}</div>
773
- `;
851
+ else if (this.maxSelectedDate) {
852
+ rangeText = ` up to ${this.maxSelectedDate}`;
853
+ }
854
+ const titleText = `Filter results for dates${rangeText}`;
855
+ const descText = `This histogram shows the distribution of dates${rangeText}`;
856
+ return html `<title id="histogram-title">${titleText}</title
857
+ ><desc id="histogram-desc">${descText}</desc>`;
774
858
  }
775
859
  get noDataTemplate() {
776
860
  return html `
@@ -807,9 +891,10 @@ let IAHistogramDateRange = class IAHistogramDateRange extends LitElement {
807
891
  <svg
808
892
  width="${this.width}"
809
893
  height="${this.height}"
894
+ aria-labelledby="histogram-title histogram-desc"
810
895
  @pointerleave="${this.drop}"
811
896
  >
812
- ${this.selectedRangeTemplate}
897
+ ${this.histogramAccessibilityTemplate} ${this.selectedRangeTemplate}
813
898
  <svg id="histogram">${this.histogramTemplate}</svg>
814
899
  ${this.minSliderTemplate} ${this.maxSliderTemplate}
815
900
  </svg>
@@ -853,7 +938,8 @@ IAHistogramDateRange.styles = css `
853
938
  -ms-user-select: none; /* Internet Explorer/Edge */
854
939
  user-select: none; /* current Chrome, Edge, Opera and Firefox */
855
940
  }
856
- .bar {
941
+ .bar,
942
+ .bar-pointer-target {
857
943
  /* create a transparent border around the hist bars to prevent "gaps" and
858
944
  flickering when moving around between bars. this also helps with handling
859
945
  clicks on the bars, preventing users from being able to click in between
@@ -862,11 +948,15 @@ IAHistogramDateRange.styles = css `
862
948
  /* ensure transparent stroke wide enough to cover gap between bars */
863
949
  stroke-width: 2px;
864
950
  }
865
- .bar:hover {
951
+ .bar {
952
+ /* ensure the bar's pointer target receives events, not the bar itself */
953
+ pointer-events: none;
954
+ }
955
+ .bar-pointer-target:hover + .bar {
866
956
  /* highlight currently hovered bar */
867
957
  fill-opacity: 0.7;
868
958
  }
869
- .disabled .bar:hover {
959
+ .disabled .bar-pointer-target:hover + .bar {
870
960
  /* ensure no visual hover interaction when disabled */
871
961
  fill-opacity: 1;
872
962
  }
@@ -874,6 +964,8 @@ IAHistogramDateRange.styles = css `
874
964
  #tooltip {
875
965
  position: absolute;
876
966
  background: ${tooltipBackgroundColor};
967
+ margin: 0;
968
+ border: 0;
877
969
  color: ${tooltipTextColor};
878
970
  text-align: center;
879
971
  border-radius: 3px;
@@ -882,12 +974,14 @@ IAHistogramDateRange.styles = css `
882
974
  font-family: ${tooltipFontFamily};
883
975
  touch-action: none;
884
976
  pointer-events: none;
977
+ overflow: visible;
885
978
  }
886
979
  #tooltip:after {
887
980
  content: '';
888
981
  position: absolute;
889
982
  margin-left: -5px;
890
983
  top: 100%;
984
+ left: 50%;
891
985
  /* arrow */
892
986
  border: 5px solid ${tooltipTextColor};
893
987
  border-color: ${tooltipBackgroundColor} transparent transparent
@@ -979,15 +1073,21 @@ __decorate([
979
1073
  __decorate([
980
1074
  property({ type: String })
981
1075
  ], IAHistogramDateRange.prototype, "binSnapping", void 0);
1076
+ __decorate([
1077
+ property({ type: String })
1078
+ ], IAHistogramDateRange.prototype, "tooltipLabel", void 0);
1079
+ __decorate([
1080
+ property({ type: String })
1081
+ ], IAHistogramDateRange.prototype, "barScaling", void 0);
982
1082
  __decorate([
983
1083
  state()
984
- ], IAHistogramDateRange.prototype, "_tooltipOffset", void 0);
1084
+ ], IAHistogramDateRange.prototype, "_tooltipOffsetX", void 0);
985
1085
  __decorate([
986
1086
  state()
987
- ], IAHistogramDateRange.prototype, "_tooltipContent", void 0);
1087
+ ], IAHistogramDateRange.prototype, "_tooltipOffsetY", void 0);
988
1088
  __decorate([
989
1089
  state()
990
- ], IAHistogramDateRange.prototype, "_tooltipVisible", void 0);
1090
+ ], IAHistogramDateRange.prototype, "_tooltipContent", void 0);
991
1091
  __decorate([
992
1092
  state()
993
1093
  ], IAHistogramDateRange.prototype, "_tooltipDateFormat", void 0);
@@ -997,6 +1097,9 @@ __decorate([
997
1097
  __decorate([
998
1098
  state()
999
1099
  ], IAHistogramDateRange.prototype, "_isLoading", void 0);
1100
+ __decorate([
1101
+ query('#tooltip')
1102
+ ], IAHistogramDateRange.prototype, "_tooltip", void 0);
1000
1103
  __decorate([
1001
1104
  property({ type: String })
1002
1105
  ], IAHistogramDateRange.prototype, "tooltipDateFormat", null);
@@ -1 +1 @@
1
- {"version":3,"file":"ia-histogram-date-range.js","sourceRoot":"","sources":["../../../../src/elements/ia-histogram-date-range/ia-histogram-date-range.ts"],"names":[],"mappings":";AAAA,OAAO,uDAAuD,CAAC;AAC/D,OAAO,KAAK,MAAM,WAAW,CAAC;AAC9B,OAAO,iBAAiB,MAAM,oCAAoC,CAAC;AACnE,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,EAEP,GAAG,GAGJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,KAAK,CAAC,MAAM,CA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EAAE,OAAO,EAAE,CAAC;mDAE3B;AAQW;IAAX,QAAQ,EAAE;2DAEV;AAsBW;IAAX,QAAQ,EAAE;2DAEV;AApSU,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CA6/BhC","sourcesContent":["import '@src/elements/ia-status-indicator/ia-status-indicator';\nimport dayjs from 'dayjs/esm';\nimport customParseFormat from 'dayjs/esm/plugin/customParseFormat';\nimport fixFirstCenturyYears from './plugins/fix-first-century-years';\nimport {\n css,\n html,\n LitElement,\n nothing,\n PropertyValues,\n svg,\n SVGTemplateResult,\n TemplateResult,\n} from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { live } from 'lit/directives/live.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { customElement } from '@src/util/custom-element';\nimport type { BinSnappingInterval } from './models';\n\ndayjs.extend(customParseFormat);\ndayjs.extend(fixFirstCenturyYears);\n\n// these values can be overridden via the component's HTML (camelCased) attributes\nconst WIDTH = 180;\nconst HEIGHT = 40;\nconst SLIDER_WIDTH = 10;\nconst TOOLTIP_WIDTH = 125;\nconst TOOLTIP_HEIGHT = 30;\nconst DATE_FORMAT = 'YYYY';\nconst MISSING_DATA = 'no data';\nconst UPDATE_DEBOUNCE_DELAY_MS = 0;\n\n// this constant is not set up to be overridden\nconst SLIDER_CORNER_SIZE = 4;\n\n// these CSS custom props can be overridden from the HTML that is invoking this component\nconst sliderColor = css`var(--histogramDateRangeSliderColor, #4B65FE)`;\nconst selectedRangeColor = css`var(--histogramDateRangeSelectedRangeColor, #DBE0FF)`;\nconst barIncludedFill = css`var(--histogramDateRangeBarIncludedFill, #2C2C2C)`;\nconst activityIndicatorColor = css`var(--histogramDateRangeActivityIndicator, #2C2C2C)`;\nconst barExcludedFill = css`var(--histogramDateRangeBarExcludedFill, #CCCCCC)`;\nconst inputRowMargin = css`var(--histogramDateRangeInputRowMargin, 0)`;\nconst inputBorder = css`var(--histogramDateRangeInputBorder, 0.5px solid #2C2C2C)`;\nconst inputWidth = css`var(--histogramDateRangeInputWidth, 35px)`;\nconst inputFontSize = css`var(--histogramDateRangeInputFontSize, 1.2rem)`;\nconst inputFontFamily = css`var(--histogramDateRangeInputFontFamily, sans-serif)`;\nconst tooltipBackgroundColor = css`var(--histogramDateRangeTooltipBackgroundColor, #2C2C2C)`;\nconst tooltipTextColor = css`var(--histogramDateRangeTooltipTextColor, #FFFFFF)`;\nconst tooltipFontSize = css`var(--histogramDateRangeTooltipFontSize, 1.1rem)`;\nconst tooltipFontFamily = css`var(--histogramDateRangeTooltipFontFamily, sans-serif)`;\n\ntype SliderId = 'slider-min' | 'slider-max';\n\ninterface HistogramItem {\n value: number;\n height: number;\n binStart: string;\n binEnd: string;\n tooltip: string;\n}\n\ninterface BarDataset extends DOMStringMap {\n numItems: string;\n binStart: string;\n binEnd: string;\n}\n\n@customElement('ia-histogram-date-range')\nexport class IAHistogramDateRange extends LitElement {\n // public reactive properties that can be set via HTML attributes\n @property({ type: Number }) width = WIDTH;\n @property({ type: Number }) height = HEIGHT;\n @property({ type: Number }) sliderWidth = SLIDER_WIDTH;\n @property({ type: Number }) tooltipWidth = TOOLTIP_WIDTH;\n @property({ type: Number }) tooltipHeight = TOOLTIP_HEIGHT;\n @property({ type: Number }) updateDelay = UPDATE_DEBOUNCE_DELAY_MS;\n @property({ type: String }) dateFormat = DATE_FORMAT;\n @property({ type: String }) missingDataMessage = MISSING_DATA;\n @property({ type: String }) minDate = '';\n @property({ type: String }) maxDate = '';\n @property({ type: Boolean }) disabled = false;\n @property({ type: Array }) bins: number[] = [];\n /** If true, update events will not be canceled by the date inputs receiving focus */\n @property({ type: Boolean }) updateWhileFocused = false;\n\n @property({ type: String }) binSnapping: BinSnappingInterval = 'none';\n\n // internal reactive properties not exposed as attributes\n @state() private _tooltipOffset = 0;\n @state() private _tooltipContent?: TemplateResult;\n @state() private _tooltipVisible = false;\n @state() private _tooltipDateFormat?: string;\n @state() private _isDragging = false;\n @state() private _isLoading = false;\n\n // non-reactive properties (changes don't auto-trigger re-rendering)\n private _minSelectedDate = '';\n private _maxSelectedDate = '';\n private _minDateMS = 0;\n private _maxDateMS = 0;\n private _dragOffset = 0;\n private _histWidth = 0;\n private _binWidth = 0;\n private _currentSlider?: SVGRectElement;\n private _histData: HistogramItem[] = [];\n private _emitUpdatedEventTimer?: ReturnType<typeof setTimeout>;\n private _previousDateRange = '';\n private _updateDeferredWhileFocused = false;\n\n disconnectedCallback(): void {\n this.removeListeners();\n super.disconnectedCallback();\n }\n\n willUpdate(changedProps: PropertyValues): void {\n // check for changes that would affect bin data calculations. Note:\n // minSelectedDate/maxSelectedDate deliberately aren't in this list even\n // though handleDataUpdate() defaults them from minDate/maxDate — the\n // recalculation here (histWidth/minDateMS/maxDateMS/binWidth/histData)\n // doesn't depend on either, and refreshing _previousDateRange as a side\n // effect of a date being picked would make beginEmitUpdateProcess's\n // \"did anything change\" check always see no change, since it compares\n // against a value this same pick had just overwritten.\n if (\n changedProps.has('bins') ||\n changedProps.has('minDate') ||\n changedProps.has('maxDate') ||\n changedProps.has('width') ||\n changedProps.has('height') ||\n changedProps.has('binSnapping')\n ) {\n this.handleDataUpdate();\n }\n }\n\n /**\n * Set private properties that depend on the attribute bin data\n *\n * We're caching these values and not using getters to avoid recalculating all\n * of the hist data every time the user drags a slider or hovers over a bar\n * creating a tooltip.\n */\n private handleDataUpdate(): void {\n if (!this.hasBinData) {\n return;\n }\n this._histWidth = this.width - this.sliderWidth * 2;\n\n this._minDateMS = this.snapTimestamp(this.getMSFromString(this.minDate));\n // NB: The max date string, converted as-is to ms, represents the *start* of the\n // final date interval; we want the *end*, so we add any snap interval/offset.\n this._maxDateMS =\n this.snapTimestamp(\n this.getMSFromString(this.maxDate) + this.snapInterval,\n ) + this.snapEndOffset;\n\n this._binWidth = this._histWidth / this._numBins;\n this._previousDateRange = this.currentDateRangeString;\n this._histData = this.calculateHistData();\n this.minSelectedDate = this.minSelectedDate\n ? this.minSelectedDate\n : this.minDate;\n this.maxSelectedDate = this.maxSelectedDate\n ? this.maxSelectedDate\n : this.maxDate;\n }\n\n /**\n * Rounds the given timestamp to the next full second.\n */\n private snapToNextSecond(timestamp: number): number {\n return Math.ceil(timestamp / 1000) * 1000;\n }\n\n /**\n * Rounds the given timestamp to the (approximate) nearest start of a month,\n * such that dates up to and including the 15th of the month are rounded down,\n * while dates past the 15th are rounded up.\n */\n private snapToMonth(timestamp: number): number {\n const d = dayjs(timestamp);\n const monthsToAdd = d.date() < 16 ? 0 : 1;\n const snapped = d\n .add(monthsToAdd, 'month')\n .date(1)\n .hour(0)\n .minute(0)\n .second(0)\n .millisecond(0); // First millisecond of the month\n return snapped.valueOf();\n }\n\n /**\n * Rounds the given timestamp to the (approximate) nearest start of a year,\n * such that dates up to the end of June are rounded down, while dates in\n * July or later are rounded up.\n */\n private snapToYear(timestamp: number): number {\n const d = dayjs(timestamp);\n const yearsToAdd = d.month() < 6 ? 0 : 1;\n const snapped = d\n .add(yearsToAdd, 'year')\n .month(0)\n .date(1)\n .hour(0)\n .minute(0)\n .second(0)\n .millisecond(0); // First millisecond of the year\n return snapped.valueOf();\n }\n\n /**\n * Rounds the given timestamp according to the `binSnapping` property.\n * Default is simply to snap to the nearest full second.\n */\n private snapTimestamp(timestamp: number): number {\n switch (this.binSnapping) {\n case 'year':\n return this.snapToYear(timestamp);\n case 'month':\n return this.snapToMonth(timestamp);\n case 'none':\n default:\n // We still align it to second boundaries to resolve minor discrepancies\n return this.snapToNextSecond(timestamp);\n }\n }\n\n private calculateHistData(): HistogramItem[] {\n const { bins, height, dateRangeMS, _numBins, _minDateMS } = this;\n const minValue = Math.min(...this.bins);\n const maxValue = Math.max(...this.bins);\n // if there is no difference between the min and max values, use a range of\n // 1 because log scaling will fail if the range is 0\n const valueRange = minValue === maxValue ? 1 : Math.log1p(maxValue);\n const valueScale = height / valueRange;\n const dateScale = dateRangeMS / _numBins;\n\n return bins.map((v: number, i: number) => {\n const binStartMS = this.snapTimestamp(i * dateScale + _minDateMS);\n const binStart = this.formatDate(binStartMS);\n\n const binEndMS =\n this.snapTimestamp((i + 1) * dateScale + _minDateMS) +\n this.snapEndOffset;\n const binEnd = this.formatDate(binEndMS);\n\n const tooltipStart = this.formatDate(binStartMS, this.tooltipDateFormat);\n const tooltipEnd = this.formatDate(binEndMS, this.tooltipDateFormat);\n // If start/end are the same, just render a single value\n const tooltip =\n tooltipStart === tooltipEnd\n ? tooltipStart\n : `${tooltipStart} - ${tooltipEnd}`;\n\n return {\n value: v,\n // use log scaling for the height of the bar to prevent tall bars from\n // making the smaller ones too small to see\n height: Math.floor(Math.log1p(v) * valueScale),\n binStart,\n binEnd,\n tooltip,\n };\n });\n }\n\n private get hasBinData(): boolean {\n return this._numBins > 0;\n }\n\n private get _numBins(): number {\n if (!this.bins || !this.bins.length) {\n return 0;\n }\n return this.bins.length;\n }\n\n private get histogramLeftEdgeX(): number {\n return this.sliderWidth;\n }\n\n private get histogramRightEdgeX(): number {\n return this.width - this.sliderWidth;\n }\n\n /**\n * Approximate size in ms of the interval to which bins are snapped.\n */\n private get snapInterval(): number {\n const yearMS = 31_536_000_000; // A 365-day approximation of ms in a year\n const monthMS = 2_592_000_000; // A 30-day approximation of ms in a month\n switch (this.binSnapping) {\n case 'year':\n return yearMS;\n case 'month':\n return monthMS;\n case 'none':\n default:\n return 0;\n }\n }\n\n /**\n * Offset added to the end of each bin to ensure disjoint intervals,\n * depending on whether snapping is enabled and there are multiple bins.\n */\n private get snapEndOffset(): number {\n return this.binSnapping !== 'none' && this._numBins > 1 ? -1 : 0;\n }\n\n /**\n * Optional date format to use for tooltips only.\n * Falls back to `dateFormat` if not provided.\n */\n @property({ type: String }) get tooltipDateFormat(): string {\n return this._tooltipDateFormat ?? this.dateFormat;\n }\n\n set tooltipDateFormat(value: string) {\n this._tooltipDateFormat = value;\n }\n\n /** component's loading (and disabled) state */\n @property({ type: Boolean }) get loading(): boolean {\n return this._isLoading;\n }\n\n set loading(value: boolean) {\n this.disabled = value;\n this._isLoading = value;\n }\n\n /** formatted minimum date of selected date range */\n @property() get minSelectedDate(): string {\n return this.formatDate(this.getMSFromString(this._minSelectedDate));\n }\n\n /** updates minSelectedDate if new date is valid */\n set minSelectedDate(rawDate: string) {\n if (!this._minSelectedDate) {\n // because the values needed to calculate valid max/min values are not\n // available during the lit init when it's populating properties from\n // attributes, fall back to just the raw date if nothing is already set\n this._minSelectedDate = rawDate;\n return;\n }\n const proposedDateMS = this.getMSFromString(rawDate);\n const isValidDate = !Number.isNaN(proposedDateMS);\n const isNotTooRecent =\n proposedDateMS <= this.getMSFromString(this.maxSelectedDate);\n if (isValidDate && isNotTooRecent) {\n this._minSelectedDate = this.formatDate(proposedDateMS);\n }\n this.requestUpdate();\n }\n\n /** formatted maximum date of selected date range */\n @property() get maxSelectedDate(): string {\n return this.formatDate(this.getMSFromString(this._maxSelectedDate));\n }\n\n /** updates maxSelectedDate if new date is valid */\n set maxSelectedDate(rawDate: string) {\n if (!this._maxSelectedDate) {\n // because the values needed to calculate valid max/min values are not\n // available during the lit init when it's populating properties from\n // attributes, fall back to just the raw date if nothing is already set\n this._maxSelectedDate = rawDate;\n return;\n }\n const proposedDateMS = this.getMSFromString(rawDate);\n const isValidDate = !Number.isNaN(proposedDateMS);\n const isNotTooOld =\n proposedDateMS >= this.getMSFromString(this.minSelectedDate);\n if (isValidDate && isNotTooOld) {\n this._maxSelectedDate = this.formatDate(proposedDateMS);\n }\n this.requestUpdate();\n }\n\n /** horizontal position of min date slider */\n get minSliderX(): number {\n const x = this.translateDateToPosition(this.minSelectedDate);\n return this.validMinSliderX(x);\n }\n\n /** horizontal position of max date slider */\n get maxSliderX(): number {\n const maxSelectedDateMS = this.snapTimestamp(\n this.getMSFromString(this.maxSelectedDate) + this.snapInterval,\n );\n const x = this.translateDateToPosition(this.formatDate(maxSelectedDateMS));\n return this.validMaxSliderX(x);\n }\n\n private get dateRangeMS(): number {\n return this._maxDateMS - this._minDateMS;\n }\n\n private showTooltip(e: PointerEvent): void {\n if (this._isDragging || this.disabled) {\n return;\n }\n const target = e.currentTarget as SVGRectElement;\n const x = target.x.baseVal.value + this.sliderWidth / 2;\n const dataset = target.dataset as BarDataset;\n const itemsText = `item${dataset.numItems !== '1' ? 's' : ''}`;\n const formattedNumItems = Number(dataset.numItems).toLocaleString();\n\n this._tooltipOffset =\n x + (this._binWidth - this.sliderWidth - this.tooltipWidth) / 2;\n\n this._tooltipContent = html`\n ${formattedNumItems} ${itemsText}<br />\n ${dataset.tooltip}\n `;\n this._tooltipVisible = true;\n }\n\n private hideTooltip(): void {\n this._tooltipContent = undefined;\n this._tooltipVisible = false;\n }\n\n // use arrow functions (rather than standard JS class instance methods) so\n // that `this` is bound to the histogramDateRange object and not the event\n // target. for more info see\n // https://lit-element.polymer-project.org/guide/events#using-this-in-event-listeners\n private drag = (e: PointerEvent): void => {\n // prevent selecting text or other ranges while dragging, especially in Safari\n e.preventDefault();\n if (this.disabled) {\n return;\n }\n this.setDragOffset(e);\n this._isDragging = true;\n this.addListeners();\n this.cancelPendingUpdateEvent();\n };\n\n private drop = (): void => {\n if (this._isDragging) {\n this.removeListeners();\n this.beginEmitUpdateProcess();\n }\n this._isDragging = false;\n };\n\n /**\n * Adjust the date range based on slider movement\n *\n * @param e PointerEvent from the slider being moved\n */\n private move = (e: PointerEvent): void => {\n const histogramClientX = this.getBoundingClientRect().x;\n const newX = e.clientX - histogramClientX - this._dragOffset;\n const slider = this._currentSlider as SVGRectElement;\n if ((slider.id as SliderId) === 'slider-min') {\n this.minSelectedDate = this.translatePositionToDate(\n this.validMinSliderX(newX),\n );\n } else {\n this.maxSelectedDate = this.translatePositionToDate(\n this.validMaxSliderX(newX),\n );\n if (this.getMSFromString(this.maxSelectedDate) > this._maxDateMS) {\n this.maxSelectedDate = this.maxDate;\n }\n }\n };\n\n /**\n * Constrain a proposed value for the minimum (left) slider\n *\n * If the value is less than the leftmost valid position, then set it to the\n * left edge of the histogram (ie the slider width). If the value is greater\n * than the rightmost valid position (the position of the max slider), then\n * set it to the position of the max slider\n */\n private validMinSliderX(newX: number): number {\n // allow the left slider to go right only to the right slider, even if the\n // max selected date is out of range\n const rightLimit = Math.min(\n this.translateDateToPosition(this.maxSelectedDate),\n this.histogramRightEdgeX,\n );\n newX = this.clamp(newX, this.histogramLeftEdgeX, rightLimit);\n const isInvalid =\n Number.isNaN(newX) || rightLimit < this.histogramLeftEdgeX;\n return isInvalid ? this.histogramLeftEdgeX : newX;\n }\n\n /**\n * Constrain a proposed value for the maximum (right) slider\n *\n * If the value is greater than the rightmost valid position, then set it to\n * the right edge of the histogram (ie histogram width - slider width). If the\n * value is less than the leftmost valid position (the position of the min\n * slider), then set it to the position of the min slider\n */\n private validMaxSliderX(newX: number): number {\n // allow the right slider to go left only to the left slider, even if the\n // min selected date is out of range\n const leftLimit = Math.max(\n this.histogramLeftEdgeX,\n this.translateDateToPosition(this.minSelectedDate),\n );\n newX = this.clamp(newX, leftLimit, this.histogramRightEdgeX);\n const isInvalid =\n Number.isNaN(newX) || leftLimit > this.histogramRightEdgeX;\n return isInvalid ? this.histogramRightEdgeX : newX;\n }\n\n private addListeners(): void {\n window.addEventListener('pointermove', this.move);\n window.addEventListener('pointerup', this.drop);\n window.addEventListener('pointercancel', this.drop);\n }\n\n private removeListeners(): void {\n window.removeEventListener('pointermove', this.move);\n window.removeEventListener('pointerup', this.drop);\n window.removeEventListener('pointercancel', this.drop);\n }\n\n /**\n * start a timer to emit an update event. this timer can be canceled (and the\n * event not emitted) if user drags a slider or focuses a date input within\n * the update delay\n */\n private beginEmitUpdateProcess(): void {\n this.cancelPendingUpdateEvent();\n this._updateDeferredWhileFocused = false;\n this._emitUpdatedEventTimer = setTimeout(() => {\n // the timer has run, so there is no longer a pending event to cancel\n this._emitUpdatedEventTimer = undefined;\n if (this.currentDateRangeString === this._previousDateRange) {\n // don't emit duplicate event if no change since last emitted event\n return;\n }\n this._previousDateRange = this.currentDateRangeString;\n const options = {\n detail: {\n minDate: this.minSelectedDate,\n maxDate: this.maxSelectedDate,\n },\n bubbles: true,\n composed: true,\n };\n this.dispatchEvent(new CustomEvent('histogramDateRangeUpdated', options));\n }, this.updateDelay);\n }\n\n /** @returns whether there was a pending update event to cancel */\n private cancelPendingUpdateEvent(): boolean {\n if (this._emitUpdatedEventTimer === undefined) {\n return false;\n }\n clearTimeout(this._emitUpdatedEventTimer);\n this._emitUpdatedEventTimer = undefined;\n return true;\n }\n\n /**\n * find position of pointer in relation to the current slider\n */\n private setDragOffset(e: PointerEvent): void {\n this._currentSlider = e.currentTarget as SVGRectElement;\n const sliderX =\n (this._currentSlider.id as SliderId) === 'slider-min'\n ? this.minSliderX\n : this.maxSliderX;\n const histogramClientX = this.getBoundingClientRect().x;\n this._dragOffset = e.clientX - histogramClientX - sliderX;\n }\n\n /**\n * @param x horizontal position of slider\n * @returns string representation of date\n */\n private translatePositionToDate(x: number): string {\n // Snap to the nearest second, fixing the case where input like 1/1/2010\n // would get translated to 12/31/2009 due to slight discrepancies from\n // pixel boundaries and floating point error.\n const milliseconds = this.snapToNextSecond(\n ((x - this.sliderWidth) * this.dateRangeMS) / this._histWidth,\n );\n return this.formatDate(this._minDateMS + milliseconds);\n }\n\n /**\n * Returns slider x-position corresponding to given date\n *\n * @param date\n * @returns x-position of slider\n */\n private translateDateToPosition(date: string): number {\n const milliseconds = this.getMSFromString(date);\n return (\n this.sliderWidth +\n ((milliseconds - this._minDateMS) * this._histWidth) / this.dateRangeMS\n );\n }\n\n /** ensure that the returned value is between minValue and maxValue */\n private clamp(x: number, minValue: number, maxValue: number): number {\n return Math.min(Math.max(x, minValue), maxValue);\n }\n\n private handleInputFocus(): void {\n if (!this.updateWhileFocused) {\n // Tabbing from one date input to the other lands focus here in between\n // the first input's blur and any chance for its update to be emitted.\n // Remember that so the second input's blur can pick it back up, rather\n // than the typed date never being reported at all.\n this._updateDeferredWhileFocused = this.cancelPendingUpdateEvent();\n }\n }\n\n private handleMinDateInput(e: Event): void {\n const target = e.currentTarget as HTMLInputElement;\n const isChanged = target.value !== this.minSelectedDate;\n if (isChanged) {\n this.minSelectedDate = target.value;\n }\n if (isChanged || this._updateDeferredWhileFocused) {\n this.beginEmitUpdateProcess();\n }\n }\n\n private handleMaxDateInput(e: Event): void {\n const target = e.currentTarget as HTMLInputElement;\n const isChanged = target.value !== this.maxSelectedDate;\n if (isChanged) {\n this.maxSelectedDate = target.value;\n }\n if (isChanged || this._updateDeferredWhileFocused) {\n this.beginEmitUpdateProcess();\n }\n }\n\n private handleKeyUp(e: KeyboardEvent): void {\n if (e.key === 'Enter') {\n const target = e.currentTarget as HTMLInputElement;\n target.blur();\n if (target.id === 'date-min') {\n this.handleMinDateInput(e);\n } else if (target.id === 'date-max') {\n this.handleMaxDateInput(e);\n }\n }\n }\n\n private get currentDateRangeString(): string {\n return `${this.minSelectedDate}:${this.maxSelectedDate}`;\n }\n\n private getMSFromString(date: unknown): number {\n // It's possible that `date` is not a string in certain situations.\n // For instance if you use LitElement bindings and the date is `2000`,\n // it will be treated as a number instead of a string. This just makes sure\n // we're dealing with a string.\n const stringified = typeof date === 'string' ? date : String(date);\n const digitGroupCount = (stringified.split(/(\\d+)/).length - 1) / 2;\n if (digitGroupCount === 1) {\n // if there's just a single set of digits, assume it's a year\n const dateObj = new Date(0, 0); // start at January 1, 1900\n dateObj.setFullYear(Number(stringified)); // override year\n return dateObj.getTime(); // get time in milliseconds\n }\n return dayjs(stringified, [this.dateFormat, DATE_FORMAT]).valueOf();\n }\n\n /**\n * expand or narrow the selected range by moving the slider nearest the\n * clicked bar to the outer edge of the clicked bar\n *\n * @param e Event click event from a histogram bar\n */\n private handleBarClick(e: Event): void {\n const dataset = (e.currentTarget as SVGRectElement).dataset as BarDataset;\n // use the midpoint of the width of the clicked bar to determine which is\n // the nearest slider\n const clickPosition =\n (this.getMSFromString(dataset.binStart) +\n this.getMSFromString(dataset.binEnd)) /\n 2;\n const distanceFromMinSlider = Math.abs(\n clickPosition - this.getMSFromString(this.minSelectedDate),\n );\n const distanceFromMaxSlider = Math.abs(\n clickPosition - this.getMSFromString(this.maxSelectedDate),\n );\n // update the selected range by moving the nearer slider\n if (distanceFromMinSlider < distanceFromMaxSlider) {\n this.minSelectedDate = dataset.binStart;\n } else {\n this.maxSelectedDate = dataset.binEnd;\n }\n this.beginEmitUpdateProcess();\n }\n\n private get minSliderTemplate(): SVGTemplateResult {\n // width/height in pixels of curved part of the sliders (like\n // border-radius); used as part of a SVG quadratic curve. see\n // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands\n const cs = SLIDER_CORNER_SIZE;\n\n const sliderShape = `\n M${this.minSliderX},0\n h-${this.sliderWidth - cs}\n q-${cs},0 -${cs},${cs}\n v${this.height - cs * 2}\n q0,${cs} ${cs},${cs}\n h${this.sliderWidth - cs}\n `;\n return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);\n }\n\n private get maxSliderTemplate(): SVGTemplateResult {\n const cs = SLIDER_CORNER_SIZE;\n const sliderShape = `\n M${this.maxSliderX},0\n h${this.sliderWidth - cs}\n q${cs},0 ${cs},${cs}\n v${this.height - cs * 2}\n q0,${cs} -${cs},${cs}\n h-${this.sliderWidth - cs}\n `;\n return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);\n }\n\n private generateSliderSVG(\n sliderPositionX: number,\n id: SliderId,\n sliderShape: string,\n ): SVGTemplateResult {\n // whether the curved part of the slider is facing towards the left (1), ie\n // minimum, or facing towards the right (-1), ie maximum\n const k = id === 'slider-min' ? 1 : -1;\n\n const sliderClasses = classMap({\n slider: true,\n draggable: !this.disabled,\n dragging: this._isDragging,\n });\n\n return svg`\n <svg\n id=${id}\n class=${sliderClasses}\n @pointerdown=${this.drag}\n >\n <path d=\"${sliderShape} z\" fill=\"${sliderColor}\" />\n <rect\n x=\"${\n sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k\n }\"\n y=\"${this.height / 3}\"\n width=\"1\"\n height=\"${this.height / 3}\"\n fill=\"white\"\n />\n <rect\n x=\"${\n sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k\n }\"\n y=\"${this.height / 3}\"\n width=\"1\"\n height=\"${this.height / 3}\"\n fill=\"white\"\n />\n </svg>\n `;\n }\n\n get selectedRangeTemplate(): SVGTemplateResult {\n return svg`\n <rect\n x=\"${this.minSliderX}\"\n y=\"0\"\n width=\"${this.maxSliderX - this.minSliderX}\"\n height=\"${this.height}\"\n fill=\"${selectedRangeColor}\"\n />`;\n }\n\n get histogramTemplate(): SVGTemplateResult[] {\n const xScale = this._histWidth / this._numBins;\n const barWidth = xScale - 1;\n let x = this.sliderWidth; // start at the left edge of the histogram\n\n return this._histData.map((data) => {\n const { minSelectedDate, maxSelectedDate } = this;\n const barHeight = data.height;\n\n const binIsBeforeMin = this.isBefore(data.binEnd, minSelectedDate);\n const binIsAfterMax = this.isAfter(data.binStart, maxSelectedDate);\n const barFill =\n binIsBeforeMin || binIsAfterMax ? barExcludedFill : barIncludedFill;\n\n // the stroke-dasharray style below creates a transparent border around the\n // right edge of the bar, which prevents user from encountering a gap\n // between adjacent bars (eg when viewing the tooltips or when trying to\n // extend the range by clicking on a bar)\n const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;\n\n const bar = svg`\n <rect\n class=\"bar\"\n style=${barStyle}\n x=${x}\n y=${this.height - barHeight}\n width=${barWidth}\n height=${barHeight}\n @pointerenter=${this.showTooltip}\n @pointerleave=${this.hideTooltip}\n @click=${this.handleBarClick}\n fill=${barFill}\n data-num-items=${data.value}\n data-bin-start=${data.binStart}\n data-bin-end=${data.binEnd}\n data-tooltip=${data.tooltip}\n />`;\n x += xScale;\n return bar;\n });\n }\n\n /** Whether the first arg represents a date strictly before the second arg */\n private isBefore(date1: string, date2: string): boolean {\n const date1MS = this.getMSFromString(date1);\n const date2MS = this.getMSFromString(date2);\n return date1MS < date2MS;\n }\n\n /** Whether the first arg represents a date strictly after the second arg */\n private isAfter(date1: string, date2: string): boolean {\n const date1MS = this.getMSFromString(date1);\n const date2MS = this.getMSFromString(date2);\n return date1MS > date2MS;\n }\n\n private formatDate(dateMS: number, format: string = this.dateFormat): string {\n if (Number.isNaN(dateMS)) {\n return '';\n }\n const date = dayjs(dateMS);\n if (date.year() < 1000) {\n // years before 1000 don't play well with dayjs custom formatting, so work around dayjs\n // by setting the year to a sentinel value and then replacing it instead.\n // this is a bit hacky but it does the trick for essentially all reasonable cases\n // until such time as we replace dayjs.\n const tmpDate = date.year(199999);\n return tmpDate.format(format).replace(/199999/g, date.year().toString());\n }\n return date.format(format);\n }\n\n /**\n * NOTE: we are relying on the lit `live` directive in the template to\n * ensure that the change to minSelectedDate is noticed and the input value\n * gets properly re-rendered. see\n * https://lit.dev/docs/templates/directives/#live\n */\n get minInputTemplate(): TemplateResult {\n return html`\n <input\n id=\"date-min\"\n placeholder=${this.dateFormat}\n type=\"text\"\n @focus=${this.handleInputFocus}\n @blur=${this.handleMinDateInput}\n @keyup=${this.handleKeyUp}\n .value=${live(this.minSelectedDate)}\n ?disabled=${this.disabled}\n />\n `;\n }\n\n get maxInputTemplate(): TemplateResult {\n return html`\n <input\n id=\"date-max\"\n placeholder=${this.dateFormat}\n type=\"text\"\n @focus=${this.handleInputFocus}\n @blur=${this.handleMaxDateInput}\n @keyup=${this.handleKeyUp}\n .value=${live(this.maxSelectedDate)}\n ?disabled=${this.disabled}\n />\n `;\n }\n\n get minLabelTemplate(): TemplateResult {\n return html`<label for=\"date-min\" class=\"sr-only\">Minimum date:</label>`;\n }\n\n get maxLabelTemplate(): TemplateResult {\n return html`<label for=\"date-max\" class=\"sr-only\">Maximum date:</label>`;\n }\n\n get tooltipTemplate(): TemplateResult {\n return html`\n <style>\n #tooltip {\n width: ${this.tooltipWidth}px;\n height: ${this.tooltipHeight}px;\n top: ${-9 - this.tooltipHeight}px;\n left: ${this._tooltipOffset}px;\n display: ${this._tooltipVisible ? 'block' : 'none'};\n }\n #tooltip:after {\n left: ${this.tooltipWidth / 2}px;\n }\n </style>\n <div id=\"tooltip\">${this._tooltipContent}</div>\n `;\n }\n\n private get noDataTemplate(): TemplateResult {\n return html`\n <div class=\"missing-data-message\">${this.missingDataMessage}</div>\n `;\n }\n\n private get activityIndicatorTemplate(): TemplateResult | typeof nothing {\n if (!this.loading) {\n return nothing;\n }\n return html`\n <ia-status-indicator mode=\"loading\" ?hideDots=${true}>\n </ia-status-indicator>\n `;\n }\n\n static styles = css`\n .missing-data-message {\n text-align: center;\n }\n #container {\n margin: 0;\n touch-action: none;\n position: relative;\n }\n .disabled {\n opacity: 0.3;\n }\n ia-status-indicator {\n position: absolute;\n left: calc(50% - 10px);\n top: 10px;\n --icon-width: 20px;\n --loading-ring-color--: ${activityIndicatorColor};\n }\n\n /* prevent selection from interfering with tooltip, especially on mobile */\n /* https://stackoverflow.com/a/4407335/1163042 */\n .noselect {\n -webkit-touch-callout: none; /* iOS Safari */\n -webkit-user-select: none; /* Safari */\n -moz-user-select: none; /* Old versions of Firefox */\n -ms-user-select: none; /* Internet Explorer/Edge */\n user-select: none; /* current Chrome, Edge, Opera and Firefox */\n }\n .bar {\n /* create a transparent border around the hist bars to prevent \"gaps\" and\n flickering when moving around between bars. this also helps with handling\n clicks on the bars, preventing users from being able to click in between\n bars */\n stroke: rgba(0, 0, 0, 0);\n /* ensure transparent stroke wide enough to cover gap between bars */\n stroke-width: 2px;\n }\n .bar:hover {\n /* highlight currently hovered bar */\n fill-opacity: 0.7;\n }\n .disabled .bar:hover {\n /* ensure no visual hover interaction when disabled */\n fill-opacity: 1;\n }\n /****** histogram ********/\n #tooltip {\n position: absolute;\n background: ${tooltipBackgroundColor};\n color: ${tooltipTextColor};\n text-align: center;\n border-radius: 3px;\n padding: 2px;\n font-size: ${tooltipFontSize};\n font-family: ${tooltipFontFamily};\n touch-action: none;\n pointer-events: none;\n }\n #tooltip:after {\n content: '';\n position: absolute;\n margin-left: -5px;\n top: 100%;\n /* arrow */\n border: 5px solid ${tooltipTextColor};\n border-color: ${tooltipBackgroundColor} transparent transparent\n transparent;\n }\n /****** slider ********/\n .slider {\n shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */\n }\n .draggable:hover {\n cursor: grab;\n }\n .dragging {\n cursor: grabbing !important;\n }\n /****** inputs ********/\n #inputs {\n display: flex;\n justify-content: center;\n margin: ${inputRowMargin};\n }\n #inputs .dash {\n position: relative;\n bottom: -1px;\n align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */\n }\n input {\n width: ${inputWidth};\n margin: 0 3px;\n border: ${inputBorder};\n border-radius: 2px !important;\n text-align: center;\n font-size: ${inputFontSize};\n font-family: ${inputFontFamily};\n }\n .sr-only {\n position: absolute !important;\n width: 1px !important;\n height: 1px !important;\n margin: 0 !important;\n padding: 0 !important;\n border: 0 !important;\n overflow: hidden !important;\n white-space: nowrap !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n -webkit-clip-path: inset(50%) !important;\n clip-path: inset(50%) !important;\n }\n `;\n\n render(): TemplateResult {\n if (!this.hasBinData) {\n return this.noDataTemplate;\n }\n return html`\n <div\n id=\"container\"\n class=\"\n noselect\n ${this._isDragging ? 'dragging' : ''}\n \"\n style=\"width: ${this.width}px\"\n >\n ${this.activityIndicatorTemplate} ${this.tooltipTemplate}\n <div\n class=\"inner-container\n ${this.disabled ? 'disabled' : ''}\"\n >\n <svg\n width=\"${this.width}\"\n height=\"${this.height}\"\n @pointerleave=\"${this.drop}\"\n >\n ${this.selectedRangeTemplate}\n <svg id=\"histogram\">${this.histogramTemplate}</svg>\n ${this.minSliderTemplate} ${this.maxSliderTemplate}\n </svg>\n <div id=\"inputs\">\n ${this.minLabelTemplate} ${this.minInputTemplate}\n <div class=\"dash\">-</div>\n ${this.maxLabelTemplate} ${this.maxInputTemplate}\n <slot name=\"inputs-right-side\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ia-histogram-date-range': IAHistogramDateRange;\n }\n}\n"]}
1
+ {"version":3,"file":"ia-histogram-date-range.js","sourceRoot":"","sources":["../../../../src/elements/ia-histogram-date-range/ia-histogram-date-range.ts"],"names":[],"mappings":";AAAA,OAAO,uDAAuD,CAAC;AAC/D,OAAO,KAAK,MAAM,WAAW,CAAC;AAC9B,OAAO,iBAAiB,MAAM,oCAAoC,CAAC;AACnE,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,EAEP,GAAG,GAGJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAQzD,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAChC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAkBnC,kFAAkF;AAClF,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,aAAa,GAAG,MAAM,CAAC;AAE7B,+CAA+C;AAC/C,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;GAEG;AACH,MAAM,sBAAsB,GAAiD;IAC3E,MAAM,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,QAAQ;IACtC,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EAAE,MAAM,EAAE,CAAC;0DAA8B;AAgB7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAA8C;AAGxD;IAAhB,KAAK,EAAE;6DAA6B;AACpB;IAAhB,KAAK,EAAE;6DAA6B;AACpB;IAAhB,KAAK,EAAE;6DAA0C;AACjC;IAAhB,KAAK,EAAE;gEAAqC;AAC5B;IAAhB,KAAK,EAAE;yDAA6B;AACpB;IAAhB,KAAK,EAAE;wDAA4B;AAET;IAA1B,KAAK,CAAC,UAAU,CAAC;sDAAmC;AA8OzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAE1B;AAO4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAE3B;AAQW;IAAX,QAAQ,EAAE;2DAEV;AAsBW;IAAX,QAAQ,EAAE;2DAEV;AAvVU,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAgmChC","sourcesContent":["import '@src/elements/ia-status-indicator/ia-status-indicator';\nimport dayjs from 'dayjs/esm';\nimport customParseFormat from 'dayjs/esm/plugin/customParseFormat';\nimport fixFirstCenturyYears from './plugins/fix-first-century-years';\nimport {\n css,\n html,\n LitElement,\n nothing,\n PropertyValues,\n svg,\n SVGTemplateResult,\n TemplateResult,\n} from 'lit';\nimport { property, state, query } from 'lit/decorators.js';\nimport { live } from 'lit/directives/live.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { customElement } from '@src/util/custom-element';\nimport type {\n BarScalingFunction,\n BarScalingOption,\n BarScalingPreset,\n BinSnappingInterval,\n} from './models';\n\ndayjs.extend(customParseFormat);\ndayjs.extend(fixFirstCenturyYears);\n\ntype SliderId = 'slider-min' | 'slider-max';\n\ninterface HistogramItem {\n value: number;\n height: number;\n binStart: string;\n binEnd: string;\n tooltip: string;\n}\n\ninterface BarDataset extends DOMStringMap {\n numItems: string;\n binStart: string;\n binEnd: string;\n}\n\n// these values can be overridden via the component's HTML (camelCased) attributes\nconst WIDTH = 180;\nconst HEIGHT = 40;\nconst SLIDER_WIDTH = 10;\nconst TOOLTIP_WIDTH = 125;\nconst TOOLTIP_HEIGHT = 30;\nconst DATE_FORMAT = 'YYYY';\nconst MISSING_DATA = 'no data';\nconst UPDATE_DEBOUNCE_DELAY_MS = 0;\nconst TOOLTIP_LABEL = 'item';\n\n// this constant is not set up to be overridden\nconst SLIDER_CORNER_SIZE = 4;\n\n/**\n * Map from bar scaling preset options to the corresponding function they represent\n */\nconst BAR_SCALING_PRESET_FNS: Record<BarScalingPreset, BarScalingFunction> = {\n linear: (binValue: number) => binValue,\n logarithmic: (binValue: number) => Math.log1p(binValue),\n};\n\n// these CSS custom props can be overridden from the HTML that is invoking this component\nconst sliderColor = css`var(--histogramDateRangeSliderColor, #4B65FE)`;\nconst selectedRangeColor = css`var(--histogramDateRangeSelectedRangeColor, #DBE0FF)`;\nconst barIncludedFill = css`var(--histogramDateRangeBarIncludedFill, #2C2C2C)`;\nconst activityIndicatorColor = css`var(--histogramDateRangeActivityIndicator, #2C2C2C)`;\nconst barExcludedFill = css`var(--histogramDateRangeBarExcludedFill, #CCCCCC)`;\nconst inputRowMargin = css`var(--histogramDateRangeInputRowMargin, 0)`;\nconst inputBorder = css`var(--histogramDateRangeInputBorder, 0.5px solid #2C2C2C)`;\nconst inputWidth = css`var(--histogramDateRangeInputWidth, 35px)`;\nconst inputFontSize = css`var(--histogramDateRangeInputFontSize, 1.2rem)`;\nconst inputFontFamily = css`var(--histogramDateRangeInputFontFamily, sans-serif)`;\nconst tooltipBackgroundColor = css`var(--histogramDateRangeTooltipBackgroundColor, #2C2C2C)`;\nconst tooltipTextColor = css`var(--histogramDateRangeTooltipTextColor, #FFFFFF)`;\nconst tooltipFontSize = css`var(--histogramDateRangeTooltipFontSize, 1.1rem)`;\nconst tooltipFontFamily = css`var(--histogramDateRangeTooltipFontFamily, sans-serif)`;\n\n@customElement('ia-histogram-date-range')\nexport class IAHistogramDateRange extends LitElement {\n // public reactive properties that can be set via HTML attributes\n @property({ type: Number }) width = WIDTH;\n @property({ type: Number }) height = HEIGHT;\n @property({ type: Number }) sliderWidth = SLIDER_WIDTH;\n @property({ type: Number }) tooltipWidth = TOOLTIP_WIDTH;\n @property({ type: Number }) tooltipHeight = TOOLTIP_HEIGHT;\n @property({ type: Number }) updateDelay = UPDATE_DEBOUNCE_DELAY_MS;\n @property({ type: String }) dateFormat = DATE_FORMAT;\n @property({ type: String }) missingDataMessage = MISSING_DATA;\n @property({ type: String }) minDate = '';\n @property({ type: String }) maxDate = '';\n @property({ type: Boolean }) disabled = false;\n @property({ type: Array }) bins: number[] = [];\n /** If true, update events will not be canceled by the date inputs receiving focus */\n @property({ type: Boolean }) updateWhileFocused = false;\n\n /**\n * What interval bins should be snapped to for determining their time ranges.\n * - `none` (default): Bins should each represent an identical duration of time,\n * without regard for the actual dates represented.\n * - `month`: Bins should each represent one or more full, non-overlapping months.\n * The bin ranges will be \"snapped\" to the nearest month boundaries, which can\n * result in bins that represent different amounts of time, particularly if the\n * provided bins do not evenly divide the provided date range, or if the months\n * represented are of different lengths.\n * - `year`: Same as `month`, but snapping to year boundaries instead of months.\n */\n @property({ type: String }) binSnapping: BinSnappingInterval = 'none';\n\n /**\n * What label to use on tooltips to identify the type of data being represented.\n * Defaults to `'item(s)'`.\n */\n @property({ type: String }) tooltipLabel = TOOLTIP_LABEL;\n\n /**\n * A function or preset value indicating how the height of each bar relates to its\n * corresponding bin value. Current presets available are 'logarithmic' and 'linear',\n * but a custom function may be provided instead if other behavior is desired.\n *\n * The default scaling (`'logarithmic'`) uses the logarithm of each bin value, yielding\n * more prominent bars for smaller values. This ensures that even when the difference\n * between the min & max values is large, small values are unlikely to completely disappear\n * visually. However, the cost is that bars have less noticeable variation among values of\n * a similar magnitude, and their heights are not a direct representation of the bin values.\n *\n * The `'linear'` preset option instead sizes the bars in linear proportion to their bin\n * values.\n */\n @property({ type: String }) barScaling: BarScalingOption = 'logarithmic';\n\n // internal reactive properties not exposed as attributes\n @state() private _tooltipOffsetX = 0;\n @state() private _tooltipOffsetY = 0;\n @state() private _tooltipContent?: TemplateResult;\n @state() private _tooltipDateFormat?: string;\n @state() private _isDragging = false;\n @state() private _isLoading = false;\n\n @query('#tooltip') private _tooltip!: HTMLDivElement;\n\n // non-reactive properties (changes don't auto-trigger re-rendering)\n private _minSelectedDate = '';\n private _maxSelectedDate = '';\n private _minDateMS = 0;\n private _maxDateMS = 0;\n private _dragOffset = 0;\n private _histWidth = 0;\n private _binWidth = 0;\n private _currentSlider?: SVGRectElement;\n private _histData: HistogramItem[] = [];\n private _emitUpdatedEventTimer?: ReturnType<typeof setTimeout>;\n private _previousDateRange = '';\n private _updateDeferredWhileFocused = false;\n\n updated(): void {\n // The UA only hides a closed popover where showPopover() exists. Without\n // it the tooltip would sit on the page whenever it isn't being shown, so\n // hide it the one way that works either way. Not just on first render:\n // the tooltip isn't in the DOM at all until there's data to draw.\n if (this._tooltip && !this._tooltipContent) {\n this._tooltip.hidden = true;\n }\n }\n\n disconnectedCallback(): void {\n this.removeListeners();\n super.disconnectedCallback();\n }\n\n willUpdate(changedProps: PropertyValues): void {\n // check for changes that would affect bin data calculations\n if (\n changedProps.has('bins') ||\n changedProps.has('minDate') ||\n changedProps.has('maxDate') ||\n changedProps.has('minSelectedDate') ||\n changedProps.has('maxSelectedDate') ||\n changedProps.has('width') ||\n changedProps.has('height') ||\n changedProps.has('binSnapping') ||\n changedProps.has('barScaling')\n ) {\n this.handleDataUpdate();\n }\n }\n\n /**\n * Set private properties that depend on the attribute bin data\n *\n * We're caching these values and not using getters to avoid recalculating all\n * of the hist data every time the user drags a slider or hovers over a bar\n * creating a tooltip.\n */\n private handleDataUpdate(): void {\n if (!this.hasBinData) {\n return;\n }\n this._histWidth = this.width - this.sliderWidth * 2;\n\n this._minDateMS = this.snapTimestamp(this.getMSFromString(this.minDate));\n // NB: The max date string, converted as-is to ms, represents the *start* of the\n // final date interval; we want the *end*, so we add any snap interval/offset.\n this._maxDateMS =\n this.snapTimestamp(\n this.getMSFromString(this.maxDate) + this.snapInterval,\n ) + this.snapEndOffset;\n\n this._binWidth = this._histWidth / this._numBins;\n this._histData = this.calculateHistData();\n this.minSelectedDate = this.minSelectedDate\n ? this.minSelectedDate\n : this.minDate;\n this.maxSelectedDate = this.maxSelectedDate\n ? this.maxSelectedDate\n : this.maxDate;\n }\n\n /**\n * Rounds the given timestamp to the next full second.\n */\n private snapToNextSecond(timestamp: number): number {\n return Math.ceil(timestamp / 1000) * 1000;\n }\n\n /**\n * Rounds the given timestamp to the (approximate) nearest start of a month,\n * such that dates up to and including the 15th of the month are rounded down,\n * while dates past the 15th are rounded up.\n */\n private snapToMonth(timestamp: number): number {\n const d = dayjs(timestamp);\n const monthsToAdd = d.date() < 16 ? 0 : 1;\n const snapped = d\n .add(monthsToAdd, 'month')\n .date(1)\n .hour(0)\n .minute(0)\n .second(0)\n .millisecond(0); // First millisecond of the month\n return snapped.valueOf();\n }\n\n /**\n * Rounds the given timestamp to the (approximate) nearest start of a year,\n * such that dates up to the end of June are rounded down, while dates in\n * July or later are rounded up.\n */\n private snapToYear(timestamp: number): number {\n const d = dayjs(timestamp);\n const yearsToAdd = d.month() < 6 ? 0 : 1;\n const snapped = d\n .add(yearsToAdd, 'year')\n .month(0)\n .date(1)\n .hour(0)\n .minute(0)\n .second(0)\n .millisecond(0); // First millisecond of the year\n return snapped.valueOf();\n }\n\n /**\n * Rounds the given timestamp according to the `binSnapping` property.\n * Default is simply to snap to the nearest full second.\n */\n private snapTimestamp(timestamp: number): number {\n switch (this.binSnapping) {\n case 'year':\n return this.snapToYear(timestamp);\n case 'month':\n return this.snapToMonth(timestamp);\n case 'none':\n default:\n // We still align it to second boundaries to resolve minor discrepancies\n return this.snapToNextSecond(timestamp);\n }\n }\n\n /**\n * Function to scale bin values, whether from a preset or a provided custom function.\n */\n private get barScalingFunction(): BarScalingFunction {\n if (typeof this.barScaling === 'string') {\n return BAR_SCALING_PRESET_FNS[this.barScaling];\n }\n\n return this.barScaling;\n }\n\n private calculateHistData(): HistogramItem[] {\n const { bins, height, dateRangeMS, _numBins, _minDateMS } = this;\n const minValue = Math.min(...this.bins);\n const maxValue = Math.max(...this.bins);\n // if there is no difference between the min and max values, use a range of\n // 1 because log scaling will fail if the range is 0\n const valueRange =\n minValue === maxValue ? 1 : this.barScalingFunction(maxValue);\n const valueScale = height / valueRange;\n const dateScale = dateRangeMS / _numBins;\n\n return bins.map((v: number, i: number) => {\n const binStartMS = this.snapTimestamp(i * dateScale + _minDateMS);\n const binStart = this.formatDate(binStartMS);\n\n const binEndMS =\n this.snapTimestamp((i + 1) * dateScale + _minDateMS) +\n this.snapEndOffset;\n const binEnd = this.formatDate(binEndMS);\n\n const tooltipStart = this.formatDate(binStartMS, this.tooltipDateFormat);\n const tooltipEnd = this.formatDate(binEndMS, this.tooltipDateFormat);\n // If start/end are the same, just render a single value\n const tooltip =\n tooltipStart === tooltipEnd\n ? tooltipStart\n : `${tooltipStart} - ${tooltipEnd}`;\n\n return {\n value: v,\n // apply the configured scaling function to the bin value before determining bar height\n height: Math.floor(this.barScalingFunction(v) * valueScale),\n binStart,\n binEnd,\n tooltip,\n };\n });\n }\n\n private get hasBinData(): boolean {\n return this._numBins > 0;\n }\n\n private get _numBins(): number {\n if (!this.bins || !this.bins.length) {\n return 0;\n }\n return this.bins.length;\n }\n\n private get histogramLeftEdgeX(): number {\n return this.sliderWidth;\n }\n\n private get histogramRightEdgeX(): number {\n return this.width - this.sliderWidth;\n }\n\n /**\n * Approximate size in ms of the interval to which bins are snapped.\n */\n private get snapInterval(): number {\n const yearMS = 31_536_000_000; // A 365-day approximation of ms in a year\n const monthMS = 2_592_000_000; // A 30-day approximation of ms in a month\n switch (this.binSnapping) {\n case 'year':\n return yearMS;\n case 'month':\n return monthMS;\n case 'none':\n default:\n return 0;\n }\n }\n\n /**\n * Offset added to the end of each bin to ensure disjoint intervals,\n * depending on whether snapping is enabled and there are multiple bins.\n */\n private get snapEndOffset(): number {\n return this.binSnapping !== 'none' && this._numBins > 1 ? -1 : 0;\n }\n\n /**\n * Optional date format to use for tooltips only.\n * Falls back to `dateFormat` if not provided.\n */\n @property({ type: String }) get tooltipDateFormat(): string {\n return this._tooltipDateFormat ?? this.dateFormat;\n }\n\n set tooltipDateFormat(value: string) {\n this._tooltipDateFormat = value;\n }\n\n /** component's loading (and disabled) state */\n @property({ type: Boolean }) get loading(): boolean {\n return this._isLoading;\n }\n\n set loading(value: boolean) {\n this.disabled = value;\n this._isLoading = value;\n }\n\n /** formatted minimum date of selected date range */\n @property() get minSelectedDate(): string {\n return this.formatDate(this.getMSFromString(this._minSelectedDate));\n }\n\n /** updates minSelectedDate if new date is valid */\n set minSelectedDate(rawDate: string) {\n if (!this._minSelectedDate) {\n // because the values needed to calculate valid max/min values are not\n // available during the lit init when it's populating properties from\n // attributes, fall back to just the raw date if nothing is already set\n this._minSelectedDate = rawDate;\n return;\n }\n const proposedDateMS = this.getMSFromString(rawDate);\n const isValidDate = !Number.isNaN(proposedDateMS);\n const isNotTooRecent =\n proposedDateMS <= this.getMSFromString(this.maxSelectedDate);\n if (isValidDate && isNotTooRecent) {\n this._minSelectedDate = this.formatDate(proposedDateMS);\n }\n this.requestUpdate();\n }\n\n /** formatted maximum date of selected date range */\n @property() get maxSelectedDate(): string {\n return this.formatDate(this.getMSFromString(this._maxSelectedDate));\n }\n\n /** updates maxSelectedDate if new date is valid */\n set maxSelectedDate(rawDate: string) {\n if (!this._maxSelectedDate) {\n // because the values needed to calculate valid max/min values are not\n // available during the lit init when it's populating properties from\n // attributes, fall back to just the raw date if nothing is already set\n this._maxSelectedDate = rawDate;\n return;\n }\n const proposedDateMS = this.getMSFromString(rawDate);\n const isValidDate = !Number.isNaN(proposedDateMS);\n const isNotTooOld =\n proposedDateMS >= this.getMSFromString(this.minSelectedDate);\n if (isValidDate && isNotTooOld) {\n this._maxSelectedDate = this.formatDate(proposedDateMS);\n }\n this.requestUpdate();\n }\n\n /** horizontal position of min date slider */\n get minSliderX(): number {\n const x = this.translateDateToPosition(this.minSelectedDate);\n return this.validMinSliderX(x);\n }\n\n /** horizontal position of max date slider */\n get maxSliderX(): number {\n const maxSelectedDateMS = this.snapTimestamp(\n this.getMSFromString(this.maxSelectedDate) + this.snapInterval,\n );\n const x = this.translateDateToPosition(this.formatDate(maxSelectedDateMS));\n return this.validMaxSliderX(x);\n }\n\n private get dateRangeMS(): number {\n return this._maxDateMS - this._minDateMS;\n }\n\n private showTooltip(e: PointerEvent): void {\n if (this._isDragging || this.disabled) {\n return;\n }\n\n const target = e.currentTarget as SVGRectElement;\n const x = target.x.baseVal.value + this.sliderWidth / 2;\n const dataset = target.dataset as BarDataset;\n const itemsText = `${this.tooltipLabel}${\n dataset.numItems !== '1' ? 's' : ''\n }`;\n const formattedNumItems = Number(dataset.numItems).toLocaleString();\n\n const tooltipPadding = 2;\n const bufferHeight = 9;\n const heightAboveHistogram = bufferHeight + this.tooltipHeight;\n const histogramBounds = this.getBoundingClientRect();\n const barX = histogramBounds.x + x;\n const histogramY = histogramBounds.y;\n\n // Center the tooltip horizontally along the bar\n this._tooltipOffsetX =\n barX -\n tooltipPadding +\n (this._binWidth - this.sliderWidth - this.tooltipWidth) / 2 +\n window.scrollX;\n // Place the tooltip (with arrow) just above the top of the histogram bars\n this._tooltipOffsetY = histogramY - heightAboveHistogram + window.scrollY;\n\n this._tooltipContent = html`\n ${formattedNumItems} ${itemsText}<br />\n ${dataset.tooltip}\n `;\n this._tooltip.hidden = false;\n this._tooltip.showPopover?.();\n }\n\n private hideTooltip(): void {\n this._tooltipContent = undefined;\n this._tooltip.hidden = true;\n this._tooltip.hidePopover?.();\n }\n\n // use arrow functions (rather than standard JS class instance methods) so\n // that `this` is bound to the histogramDateRange object and not the event\n // target. for more info see\n // https://lit-element.polymer-project.org/guide/events#using-this-in-event-listeners\n private drag = (e: PointerEvent): void => {\n // prevent selecting text or other ranges while dragging, especially in Safari\n e.preventDefault();\n if (this.disabled) {\n return;\n }\n this.setDragOffset(e);\n this._isDragging = true;\n this.addListeners();\n this.cancelPendingUpdateEvent();\n };\n\n private drop = (): void => {\n if (this._isDragging) {\n this.removeListeners();\n this.beginEmitUpdateProcess();\n }\n this._isDragging = false;\n };\n\n /**\n * Adjust the date range based on slider movement\n *\n * @param e PointerEvent from the slider being moved\n */\n private move = (e: PointerEvent): void => {\n const histogramClientX = this.getBoundingClientRect().x;\n const newX = e.clientX - histogramClientX - this._dragOffset;\n const slider = this._currentSlider as SVGRectElement;\n if ((slider.id as SliderId) === 'slider-min') {\n this.minSelectedDate = this.translatePositionToDate(\n this.validMinSliderX(newX),\n );\n } else {\n this.maxSelectedDate = this.translatePositionToDate(\n this.validMaxSliderX(newX),\n );\n if (this.getMSFromString(this.maxSelectedDate) > this._maxDateMS) {\n this.maxSelectedDate = this.maxDate;\n }\n }\n };\n\n /**\n * Constrain a proposed value for the minimum (left) slider\n *\n * If the value is less than the leftmost valid position, then set it to the\n * left edge of the histogram (ie the slider width). If the value is greater\n * than the rightmost valid position (the position of the max slider), then\n * set it to the position of the max slider\n */\n private validMinSliderX(newX: number): number {\n // allow the left slider to go right only to the right slider, even if the\n // max selected date is out of range\n const rightLimit = Math.min(\n this.translateDateToPosition(this.maxSelectedDate),\n this.histogramRightEdgeX,\n );\n newX = this.clamp(newX, this.histogramLeftEdgeX, rightLimit);\n const isInvalid =\n Number.isNaN(newX) || rightLimit < this.histogramLeftEdgeX;\n return isInvalid ? this.histogramLeftEdgeX : newX;\n }\n\n /**\n * Constrain a proposed value for the maximum (right) slider\n *\n * If the value is greater than the rightmost valid position, then set it to\n * the right edge of the histogram (ie histogram width - slider width). If the\n * value is less than the leftmost valid position (the position of the min\n * slider), then set it to the position of the min slider\n */\n private validMaxSliderX(newX: number): number {\n // allow the right slider to go left only to the left slider, even if the\n // min selected date is out of range\n const leftLimit = Math.max(\n this.histogramLeftEdgeX,\n this.translateDateToPosition(this.minSelectedDate),\n );\n newX = this.clamp(newX, leftLimit, this.histogramRightEdgeX);\n const isInvalid =\n Number.isNaN(newX) || leftLimit > this.histogramRightEdgeX;\n return isInvalid ? this.histogramRightEdgeX : newX;\n }\n\n private addListeners(): void {\n window.addEventListener('pointermove', this.move);\n window.addEventListener('pointerup', this.drop);\n window.addEventListener('pointercancel', this.drop);\n }\n\n private removeListeners(): void {\n window.removeEventListener('pointermove', this.move);\n window.removeEventListener('pointerup', this.drop);\n window.removeEventListener('pointercancel', this.drop);\n }\n\n /**\n * start a timer to emit an update event. this timer can be canceled (and the\n * event not emitted) if user drags a slider or focuses a date input within\n * the update delay\n */\n private beginEmitUpdateProcess(): void {\n this.cancelPendingUpdateEvent();\n this._updateDeferredWhileFocused = false;\n this._emitUpdatedEventTimer = setTimeout(() => {\n // the timer has run, so there is no longer a pending event to cancel\n this._emitUpdatedEventTimer = undefined;\n if (this.currentDateRangeString === this._previousDateRange) {\n // don't emit duplicate event if no change since last emitted event\n return;\n }\n this._previousDateRange = this.currentDateRangeString;\n const options = {\n detail: {\n minDate: this.minSelectedDate,\n maxDate: this.maxSelectedDate,\n },\n bubbles: true,\n composed: true,\n };\n this.dispatchEvent(new CustomEvent('histogramDateRangeUpdated', options));\n }, this.updateDelay);\n }\n\n /** @returns whether there was a pending update event to cancel */\n private cancelPendingUpdateEvent(): boolean {\n if (this._emitUpdatedEventTimer === undefined) {\n return false;\n }\n clearTimeout(this._emitUpdatedEventTimer);\n this._emitUpdatedEventTimer = undefined;\n return true;\n }\n\n /**\n * find position of pointer in relation to the current slider\n */\n private setDragOffset(e: PointerEvent): void {\n this._currentSlider = e.currentTarget as SVGRectElement;\n const sliderX =\n (this._currentSlider.id as SliderId) === 'slider-min'\n ? this.minSliderX\n : this.maxSliderX;\n const histogramClientX = this.getBoundingClientRect().x;\n this._dragOffset = e.clientX - histogramClientX - sliderX;\n }\n\n /**\n * @param x horizontal position of slider\n * @returns string representation of date\n */\n private translatePositionToDate(x: number): string {\n // Snap to the nearest second, fixing the case where input like 1/1/2010\n // would get translated to 12/31/2009 due to slight discrepancies from\n // pixel boundaries and floating point error.\n const milliseconds = this.snapToNextSecond(\n ((x - this.sliderWidth) * this.dateRangeMS) / this._histWidth,\n );\n return this.formatDate(this._minDateMS + milliseconds);\n }\n\n /**\n * Returns slider x-position corresponding to given date\n *\n * @param date\n * @returns x-position of slider\n */\n private translateDateToPosition(date: string): number {\n const milliseconds = this.getMSFromString(date);\n return (\n this.sliderWidth +\n ((milliseconds - this._minDateMS) * this._histWidth) / this.dateRangeMS\n );\n }\n\n /** ensure that the returned value is between minValue and maxValue */\n private clamp(x: number, minValue: number, maxValue: number): number {\n return Math.min(Math.max(x, minValue), maxValue);\n }\n\n private handleInputFocus(): void {\n if (!this.updateWhileFocused) {\n // Tabbing from one date input to the other lands focus here in between\n // the first input's blur and any chance for its update to be emitted.\n // Remember that so the second input's blur can pick it back up, rather\n // than the typed date never being reported at all.\n this._updateDeferredWhileFocused = this.cancelPendingUpdateEvent();\n }\n }\n\n private handleMinDateInput(e: Event): void {\n const target = e.currentTarget as HTMLInputElement;\n const isChanged = target.value !== this.minSelectedDate;\n if (isChanged) {\n this.minSelectedDate = target.value;\n }\n if (isChanged || this._updateDeferredWhileFocused) {\n this.beginEmitUpdateProcess();\n }\n }\n\n private handleMaxDateInput(e: Event): void {\n const target = e.currentTarget as HTMLInputElement;\n const isChanged = target.value !== this.maxSelectedDate;\n if (isChanged) {\n this.maxSelectedDate = target.value;\n }\n if (isChanged || this._updateDeferredWhileFocused) {\n this.beginEmitUpdateProcess();\n }\n }\n\n private handleKeyUp(e: KeyboardEvent): void {\n if (e.key === 'Enter') {\n const target = e.currentTarget as HTMLInputElement;\n target.blur();\n if (target.id === 'date-min') {\n this.handleMinDateInput(e);\n } else if (target.id === 'date-max') {\n this.handleMaxDateInput(e);\n }\n }\n }\n\n private get currentDateRangeString(): string {\n return `${this.minSelectedDate}:${this.maxSelectedDate}`;\n }\n\n private getMSFromString(date: unknown): number {\n // It's possible that `date` is not a string in certain situations.\n // For instance if you use LitElement bindings and the date is `2000`,\n // it will be treated as a number instead of a string. This just makes sure\n // we're dealing with a string.\n const stringified = typeof date === 'string' ? date : String(date);\n const digitGroupCount = (stringified.split(/(\\d+)/).length - 1) / 2;\n if (digitGroupCount === 1) {\n // if there's just a single set of digits, assume it's a year\n const dateObj = new Date(0, 0); // start at January 1, 1900\n dateObj.setFullYear(Number(stringified)); // override year\n return dateObj.getTime(); // get time in milliseconds\n }\n return dayjs(stringified, [this.dateFormat, DATE_FORMAT]).valueOf();\n }\n\n /**\n * expand or narrow the selected range by moving the slider nearest the\n * clicked bar to the outer edge of the clicked bar\n *\n * @param e Event click event from a histogram bar\n */\n private handleBarClick(e: Event): void {\n const dataset = (e.currentTarget as SVGRectElement).dataset as BarDataset;\n // use the midpoint of the width of the clicked bar to determine which is\n // the nearest slider\n const clickPosition =\n (this.getMSFromString(dataset.binStart) +\n this.getMSFromString(dataset.binEnd)) /\n 2;\n const distanceFromMinSlider = Math.abs(\n clickPosition - this.getMSFromString(this.minSelectedDate),\n );\n const distanceFromMaxSlider = Math.abs(\n clickPosition - this.getMSFromString(this.maxSelectedDate),\n );\n // update the selected range by moving the nearer slider\n if (distanceFromMinSlider < distanceFromMaxSlider) {\n this.minSelectedDate = dataset.binStart;\n } else {\n this.maxSelectedDate = dataset.binEnd;\n }\n this.beginEmitUpdateProcess();\n }\n\n private get minSliderTemplate(): SVGTemplateResult {\n // width/height in pixels of curved part of the sliders (like\n // border-radius); used as part of a SVG quadratic curve. see\n // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#curve_commands\n const cs = SLIDER_CORNER_SIZE;\n\n const sliderShape = `\n M${this.minSliderX},0\n h-${this.sliderWidth - cs}\n q-${cs},0 -${cs},${cs}\n v${this.height - cs * 2}\n q0,${cs} ${cs},${cs}\n h${this.sliderWidth - cs}\n `;\n return this.generateSliderSVG(this.minSliderX, 'slider-min', sliderShape);\n }\n\n private get maxSliderTemplate(): SVGTemplateResult {\n const cs = SLIDER_CORNER_SIZE;\n const sliderShape = `\n M${this.maxSliderX},0\n h${this.sliderWidth - cs}\n q${cs},0 ${cs},${cs}\n v${this.height - cs * 2}\n q0,${cs} -${cs},${cs}\n h-${this.sliderWidth - cs}\n `;\n return this.generateSliderSVG(this.maxSliderX, 'slider-max', sliderShape);\n }\n\n private generateSliderSVG(\n sliderPositionX: number,\n id: SliderId,\n sliderShape: string,\n ): SVGTemplateResult {\n // whether the curved part of the slider is facing towards the left (1), ie\n // minimum, or facing towards the right (-1), ie maximum\n const k = id === 'slider-min' ? 1 : -1;\n\n const sliderClasses = classMap({\n slider: true,\n draggable: !this.disabled,\n dragging: this._isDragging,\n });\n\n return svg`\n <svg\n id=${id}\n class=${sliderClasses}\n @pointerdown=${this.drag}\n >\n <path d=\"${sliderShape} z\" fill=\"${sliderColor}\" />\n <rect\n x=\"${\n sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.4 * k\n }\"\n y=\"${this.height / 3}\"\n width=\"1\"\n height=\"${this.height / 3}\"\n fill=\"white\"\n />\n <rect\n x=\"${\n sliderPositionX - this.sliderWidth * k + this.sliderWidth * 0.6 * k\n }\"\n y=\"${this.height / 3}\"\n width=\"1\"\n height=\"${this.height / 3}\"\n fill=\"white\"\n />\n </svg>\n `;\n }\n\n get selectedRangeTemplate(): SVGTemplateResult {\n return svg`\n <rect\n x=\"${this.minSliderX}\"\n y=\"0\"\n width=\"${this.maxSliderX - this.minSliderX}\"\n height=\"${this.height}\"\n fill=\"${selectedRangeColor}\"\n />`;\n }\n\n get histogramTemplate(): SVGTemplateResult[] {\n const xScale = this._histWidth / this._numBins;\n const barWidth = xScale - 1;\n let x = this.sliderWidth; // start at the left edge of the histogram\n\n return this._histData.map((data) => {\n const { minSelectedDate, maxSelectedDate } = this;\n const barHeight = data.height;\n\n const binIsBeforeMin = this.isBefore(data.binEnd, minSelectedDate);\n const binIsAfterMax = this.isAfter(data.binStart, maxSelectedDate);\n const barFill =\n binIsBeforeMin || binIsAfterMax ? barExcludedFill : barIncludedFill;\n\n // the stroke-dasharray style below creates a transparent border around the\n // right edge of the bar, which prevents user from encountering a gap\n // between adjacent bars (eg when viewing the tooltips or when trying to\n // extend the range by clicking on a bar)\n const barStyle = `stroke-dasharray: 0 ${barWidth} ${barHeight} ${barWidth} 0 ${barHeight}`;\n\n const bar = svg`\n <rect\n class=\"bar-pointer-target\"\n x=${x}\n y=\"0\"\n width=${barWidth}\n height=${this.height}\n @pointerenter=${this.showTooltip}\n @pointerleave=${this.hideTooltip}\n @click=${this.handleBarClick}\n fill=\"transparent\"\n data-num-items=${data.value}\n data-bin-start=${data.binStart}\n data-bin-end=${data.binEnd}\n data-tooltip=${data.tooltip}\n />\n <rect\n class=\"bar\"\n style=${barStyle}\n x=${x}\n y=${this.height - barHeight}\n width=${barWidth}\n height=${barHeight}\n fill=${barFill}\n />`;\n x += xScale;\n return bar;\n });\n }\n\n /** Whether the first arg represents a date strictly before the second arg */\n private isBefore(date1: string, date2: string): boolean {\n const date1MS = this.getMSFromString(date1);\n const date2MS = this.getMSFromString(date2);\n return date1MS < date2MS;\n }\n\n /** Whether the first arg represents a date strictly after the second arg */\n private isAfter(date1: string, date2: string): boolean {\n const date1MS = this.getMSFromString(date1);\n const date2MS = this.getMSFromString(date2);\n return date1MS > date2MS;\n }\n\n private formatDate(dateMS: number, format: string = this.dateFormat): string {\n if (Number.isNaN(dateMS)) {\n return '';\n }\n const date = dayjs(dateMS);\n if (date.year() < 1000) {\n // years before 1000 don't play well with dayjs custom formatting, so work around dayjs\n // by setting the year to a sentinel value and then replacing it instead.\n // this is a bit hacky but it does the trick for essentially all reasonable cases\n // until such time as we replace dayjs.\n const tmpDate = date.year(199999);\n return tmpDate.format(format).replace(/199999/g, date.year().toString());\n }\n return date.format(format);\n }\n\n /**\n * NOTE: we are relying on the lit `live` directive in the template to\n * ensure that the change to minSelectedDate is noticed and the input value\n * gets properly re-rendered. see\n * https://lit.dev/docs/templates/directives/#live\n */\n get minInputTemplate(): TemplateResult {\n return html`\n <input\n id=\"date-min\"\n placeholder=${this.dateFormat}\n type=\"text\"\n @focus=${this.handleInputFocus}\n @blur=${this.handleMinDateInput}\n @keyup=${this.handleKeyUp}\n .value=${live(this.minSelectedDate)}\n ?disabled=${this.disabled}\n />\n `;\n }\n\n get maxInputTemplate(): TemplateResult {\n return html`\n <input\n id=\"date-max\"\n placeholder=${this.dateFormat}\n type=\"text\"\n @focus=${this.handleInputFocus}\n @blur=${this.handleMaxDateInput}\n @keyup=${this.handleKeyUp}\n .value=${live(this.maxSelectedDate)}\n ?disabled=${this.disabled}\n />\n `;\n }\n\n get minLabelTemplate(): TemplateResult {\n return html`<label for=\"date-min\" class=\"sr-only\">Minimum date:</label>`;\n }\n\n get maxLabelTemplate(): TemplateResult {\n return html`<label for=\"date-max\" class=\"sr-only\">Maximum date:</label>`;\n }\n\n get tooltipTemplate(): TemplateResult {\n const styles = styleMap({\n width: `${this.tooltipWidth}px`,\n height: `${this.tooltipHeight}px`,\n top: `${this._tooltipOffsetY}px`,\n left: `${this._tooltipOffsetX}px`,\n });\n\n return html`\n <div id=\"tooltip\" style=${styles} popover>${this._tooltipContent}</div>\n `;\n }\n\n private get histogramAccessibilityTemplate(): TemplateResult {\n let rangeText: string = '';\n if (this.minSelectedDate && this.maxSelectedDate) {\n rangeText = ` from ${this.minSelectedDate} to ${this.maxSelectedDate}`;\n } else if (this.minSelectedDate) {\n rangeText = ` from ${this.minSelectedDate}`;\n } else if (this.maxSelectedDate) {\n rangeText = ` up to ${this.maxSelectedDate}`;\n }\n\n const titleText = `Filter results for dates${rangeText}`;\n const descText = `This histogram shows the distribution of dates${rangeText}`;\n\n return html`<title id=\"histogram-title\">${titleText}</title\n ><desc id=\"histogram-desc\">${descText}</desc>`;\n }\n\n private get noDataTemplate(): TemplateResult {\n return html`\n <div class=\"missing-data-message\">${this.missingDataMessage}</div>\n `;\n }\n\n private get activityIndicatorTemplate(): TemplateResult | typeof nothing {\n if (!this.loading) {\n return nothing;\n }\n return html`\n <ia-status-indicator mode=\"loading\" ?hideDots=${true}>\n </ia-status-indicator>\n `;\n }\n\n static styles = css`\n .missing-data-message {\n text-align: center;\n }\n #container {\n margin: 0;\n touch-action: none;\n position: relative;\n }\n .disabled {\n opacity: 0.3;\n }\n ia-status-indicator {\n position: absolute;\n left: calc(50% - 10px);\n top: 10px;\n --icon-width: 20px;\n --loading-ring-color--: ${activityIndicatorColor};\n }\n\n /* prevent selection from interfering with tooltip, especially on mobile */\n /* https://stackoverflow.com/a/4407335/1163042 */\n .noselect {\n -webkit-touch-callout: none; /* iOS Safari */\n -webkit-user-select: none; /* Safari */\n -moz-user-select: none; /* Old versions of Firefox */\n -ms-user-select: none; /* Internet Explorer/Edge */\n user-select: none; /* current Chrome, Edge, Opera and Firefox */\n }\n .bar,\n .bar-pointer-target {\n /* create a transparent border around the hist bars to prevent \"gaps\" and\n flickering when moving around between bars. this also helps with handling\n clicks on the bars, preventing users from being able to click in between\n bars */\n stroke: rgba(0, 0, 0, 0);\n /* ensure transparent stroke wide enough to cover gap between bars */\n stroke-width: 2px;\n }\n .bar {\n /* ensure the bar's pointer target receives events, not the bar itself */\n pointer-events: none;\n }\n .bar-pointer-target:hover + .bar {\n /* highlight currently hovered bar */\n fill-opacity: 0.7;\n }\n .disabled .bar-pointer-target:hover + .bar {\n /* ensure no visual hover interaction when disabled */\n fill-opacity: 1;\n }\n /****** histogram ********/\n #tooltip {\n position: absolute;\n background: ${tooltipBackgroundColor};\n margin: 0;\n border: 0;\n color: ${tooltipTextColor};\n text-align: center;\n border-radius: 3px;\n padding: 2px;\n font-size: ${tooltipFontSize};\n font-family: ${tooltipFontFamily};\n touch-action: none;\n pointer-events: none;\n overflow: visible;\n }\n #tooltip:after {\n content: '';\n position: absolute;\n margin-left: -5px;\n top: 100%;\n left: 50%;\n /* arrow */\n border: 5px solid ${tooltipTextColor};\n border-color: ${tooltipBackgroundColor} transparent transparent\n transparent;\n }\n /****** slider ********/\n .slider {\n shape-rendering: crispEdges; /* So the slider doesn't get blurry if dragged between pixels */\n }\n .draggable:hover {\n cursor: grab;\n }\n .dragging {\n cursor: grabbing !important;\n }\n /****** inputs ********/\n #inputs {\n display: flex;\n justify-content: center;\n margin: ${inputRowMargin};\n }\n #inputs .dash {\n position: relative;\n bottom: -1px;\n align-self: center; /* Otherwise the dash sticks to the top while the inputs grow */\n }\n input {\n width: ${inputWidth};\n margin: 0 3px;\n border: ${inputBorder};\n border-radius: 2px !important;\n text-align: center;\n font-size: ${inputFontSize};\n font-family: ${inputFontFamily};\n }\n .sr-only {\n position: absolute !important;\n width: 1px !important;\n height: 1px !important;\n margin: 0 !important;\n padding: 0 !important;\n border: 0 !important;\n overflow: hidden !important;\n white-space: nowrap !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n -webkit-clip-path: inset(50%) !important;\n clip-path: inset(50%) !important;\n }\n `;\n\n render(): TemplateResult {\n if (!this.hasBinData) {\n return this.noDataTemplate;\n }\n return html`\n <div\n id=\"container\"\n class=\"\n noselect\n ${this._isDragging ? 'dragging' : ''}\n \"\n style=\"width: ${this.width}px\"\n >\n ${this.activityIndicatorTemplate} ${this.tooltipTemplate}\n <div\n class=\"inner-container\n ${this.disabled ? 'disabled' : ''}\"\n >\n <svg\n width=\"${this.width}\"\n height=\"${this.height}\"\n aria-labelledby=\"histogram-title histogram-desc\"\n @pointerleave=\"${this.drop}\"\n >\n ${this.histogramAccessibilityTemplate} ${this.selectedRangeTemplate}\n <svg id=\"histogram\">${this.histogramTemplate}</svg>\n ${this.minSliderTemplate} ${this.maxSliderTemplate}\n </svg>\n <div id=\"inputs\">\n ${this.minLabelTemplate} ${this.minInputTemplate}\n <div class=\"dash\">-</div>\n ${this.maxLabelTemplate} ${this.maxInputTemplate}\n <slot name=\"inputs-right-side\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ia-histogram-date-range': IAHistogramDateRange;\n }\n}\n"]}
@@ -10,4 +10,10 @@
10
10
  * - `year`: Same as `month`, but snapping to year boundaries instead of months.
11
11
  */
12
12
  export type BinSnappingInterval = 'none' | 'month' | 'year';
13
+ /** Named bar scaling behaviors the element implements itself. */
14
+ export type BarScalingPreset = 'linear' | 'logarithmic';
15
+ /** Maps a bin's value to the relative height its bar should be drawn at. */
16
+ export type BarScalingFunction = (binValue: number) => number;
17
+ /** How bar heights relate to bin values: a preset name, or a function. */
18
+ export type BarScalingOption = BarScalingPreset | BarScalingFunction;
13
19
  //# sourceMappingURL=models.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-histogram-date-range/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-histogram-date-range/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5D,iEAAiE;AACjE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,aAAa,CAAC;AAExD,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAE9D,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/elements/ia-histogram-date-range/models.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * What interval bins should be snapped to for determining their time ranges.\n * - `none` (default): Bins should each represent an identical duration of time,\n * without regard for the actual dates represented.\n * - `month`: Bins should each represent one or more full, non-overlapping months.\n * The bin ranges will be \"snapped\" to the nearest month boundaries, which can\n * result in bins that represent different amounts of time, particularly if the\n * provided bins do not evenly divide the provided date range, or if the months\n * represented are of different lengths.\n * - `year`: Same as `month`, but snapping to year boundaries instead of months.\n */\nexport type BinSnappingInterval = 'none' | 'month' | 'year';\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/elements/ia-histogram-date-range/models.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * What interval bins should be snapped to for determining their time ranges.\n * - `none` (default): Bins should each represent an identical duration of time,\n * without regard for the actual dates represented.\n * - `month`: Bins should each represent one or more full, non-overlapping months.\n * The bin ranges will be \"snapped\" to the nearest month boundaries, which can\n * result in bins that represent different amounts of time, particularly if the\n * provided bins do not evenly divide the provided date range, or if the months\n * represented are of different lengths.\n * - `year`: Same as `month`, but snapping to year boundaries instead of months.\n */\nexport type BinSnappingInterval = 'none' | 'month' | 'year';\n\n/** Named bar scaling behaviors the element implements itself. */\nexport type BarScalingPreset = 'linear' | 'logarithmic';\n\n/** Maps a bin's value to the relative height its bar should be drawn at. */\nexport type BarScalingFunction = (binValue: number) => number;\n\n/** How bar heights relate to bin values: a preset name, or a function. */\nexport type BarScalingOption = BarScalingPreset | BarScalingFunction;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/elements",
3
- "version": "1.0.1-webdev-9121.0",
3
+ "version": "1.0.1-webdev-9121.1",
4
4
  "description": "A web component library from the Internet Archive.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "types": "./dist/src/elements/index.d.ts",