@internetarchive/elements 1.0.0 → 1.0.1-webdev-9121.0

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.
@@ -0,0 +1,205 @@
1
+ import '../../elements/ia-status-indicator/ia-status-indicator.js';
2
+ import { LitElement, PropertyValues, SVGTemplateResult, TemplateResult } from 'lit';
3
+ import type { BinSnappingInterval } from './models.js';
4
+ export declare class IAHistogramDateRange extends LitElement {
5
+ width: number;
6
+ height: number;
7
+ sliderWidth: number;
8
+ tooltipWidth: number;
9
+ tooltipHeight: number;
10
+ updateDelay: number;
11
+ dateFormat: string;
12
+ missingDataMessage: string;
13
+ minDate: string;
14
+ maxDate: string;
15
+ disabled: boolean;
16
+ bins: number[];
17
+ /** If true, update events will not be canceled by the date inputs receiving focus */
18
+ updateWhileFocused: boolean;
19
+ binSnapping: BinSnappingInterval;
20
+ private _tooltipOffset;
21
+ private _tooltipContent?;
22
+ private _tooltipVisible;
23
+ private _tooltipDateFormat?;
24
+ private _isDragging;
25
+ private _isLoading;
26
+ private _minSelectedDate;
27
+ private _maxSelectedDate;
28
+ private _minDateMS;
29
+ private _maxDateMS;
30
+ private _dragOffset;
31
+ private _histWidth;
32
+ private _binWidth;
33
+ private _currentSlider?;
34
+ private _histData;
35
+ private _emitUpdatedEventTimer?;
36
+ private _previousDateRange;
37
+ private _updateDeferredWhileFocused;
38
+ disconnectedCallback(): void;
39
+ willUpdate(changedProps: PropertyValues): void;
40
+ /**
41
+ * Set private properties that depend on the attribute bin data
42
+ *
43
+ * We're caching these values and not using getters to avoid recalculating all
44
+ * of the hist data every time the user drags a slider or hovers over a bar
45
+ * creating a tooltip.
46
+ */
47
+ private handleDataUpdate;
48
+ /**
49
+ * Rounds the given timestamp to the next full second.
50
+ */
51
+ private snapToNextSecond;
52
+ /**
53
+ * Rounds the given timestamp to the (approximate) nearest start of a month,
54
+ * such that dates up to and including the 15th of the month are rounded down,
55
+ * while dates past the 15th are rounded up.
56
+ */
57
+ private snapToMonth;
58
+ /**
59
+ * Rounds the given timestamp to the (approximate) nearest start of a year,
60
+ * such that dates up to the end of June are rounded down, while dates in
61
+ * July or later are rounded up.
62
+ */
63
+ private snapToYear;
64
+ /**
65
+ * Rounds the given timestamp according to the `binSnapping` property.
66
+ * Default is simply to snap to the nearest full second.
67
+ */
68
+ private snapTimestamp;
69
+ private calculateHistData;
70
+ private get hasBinData();
71
+ private get _numBins();
72
+ private get histogramLeftEdgeX();
73
+ private get histogramRightEdgeX();
74
+ /**
75
+ * Approximate size in ms of the interval to which bins are snapped.
76
+ */
77
+ private get snapInterval();
78
+ /**
79
+ * Offset added to the end of each bin to ensure disjoint intervals,
80
+ * depending on whether snapping is enabled and there are multiple bins.
81
+ */
82
+ private get snapEndOffset();
83
+ /**
84
+ * Optional date format to use for tooltips only.
85
+ * Falls back to `dateFormat` if not provided.
86
+ */
87
+ get tooltipDateFormat(): string;
88
+ set tooltipDateFormat(value: string);
89
+ /** component's loading (and disabled) state */
90
+ get loading(): boolean;
91
+ set loading(value: boolean);
92
+ /** formatted minimum date of selected date range */
93
+ get minSelectedDate(): string;
94
+ /** updates minSelectedDate if new date is valid */
95
+ set minSelectedDate(rawDate: string);
96
+ /** formatted maximum date of selected date range */
97
+ get maxSelectedDate(): string;
98
+ /** updates maxSelectedDate if new date is valid */
99
+ set maxSelectedDate(rawDate: string);
100
+ /** horizontal position of min date slider */
101
+ get minSliderX(): number;
102
+ /** horizontal position of max date slider */
103
+ get maxSliderX(): number;
104
+ private get dateRangeMS();
105
+ private showTooltip;
106
+ private hideTooltip;
107
+ private drag;
108
+ private drop;
109
+ /**
110
+ * Adjust the date range based on slider movement
111
+ *
112
+ * @param e PointerEvent from the slider being moved
113
+ */
114
+ private move;
115
+ /**
116
+ * Constrain a proposed value for the minimum (left) slider
117
+ *
118
+ * If the value is less than the leftmost valid position, then set it to the
119
+ * left edge of the histogram (ie the slider width). If the value is greater
120
+ * than the rightmost valid position (the position of the max slider), then
121
+ * set it to the position of the max slider
122
+ */
123
+ private validMinSliderX;
124
+ /**
125
+ * Constrain a proposed value for the maximum (right) slider
126
+ *
127
+ * If the value is greater than the rightmost valid position, then set it to
128
+ * the right edge of the histogram (ie histogram width - slider width). If the
129
+ * value is less than the leftmost valid position (the position of the min
130
+ * slider), then set it to the position of the min slider
131
+ */
132
+ private validMaxSliderX;
133
+ private addListeners;
134
+ private removeListeners;
135
+ /**
136
+ * start a timer to emit an update event. this timer can be canceled (and the
137
+ * event not emitted) if user drags a slider or focuses a date input within
138
+ * the update delay
139
+ */
140
+ private beginEmitUpdateProcess;
141
+ /** @returns whether there was a pending update event to cancel */
142
+ private cancelPendingUpdateEvent;
143
+ /**
144
+ * find position of pointer in relation to the current slider
145
+ */
146
+ private setDragOffset;
147
+ /**
148
+ * @param x horizontal position of slider
149
+ * @returns string representation of date
150
+ */
151
+ private translatePositionToDate;
152
+ /**
153
+ * Returns slider x-position corresponding to given date
154
+ *
155
+ * @param date
156
+ * @returns x-position of slider
157
+ */
158
+ private translateDateToPosition;
159
+ /** ensure that the returned value is between minValue and maxValue */
160
+ private clamp;
161
+ private handleInputFocus;
162
+ private handleMinDateInput;
163
+ private handleMaxDateInput;
164
+ private handleKeyUp;
165
+ private get currentDateRangeString();
166
+ private getMSFromString;
167
+ /**
168
+ * expand or narrow the selected range by moving the slider nearest the
169
+ * clicked bar to the outer edge of the clicked bar
170
+ *
171
+ * @param e Event click event from a histogram bar
172
+ */
173
+ private handleBarClick;
174
+ private get minSliderTemplate();
175
+ private get maxSliderTemplate();
176
+ private generateSliderSVG;
177
+ get selectedRangeTemplate(): SVGTemplateResult;
178
+ get histogramTemplate(): SVGTemplateResult[];
179
+ /** Whether the first arg represents a date strictly before the second arg */
180
+ private isBefore;
181
+ /** Whether the first arg represents a date strictly after the second arg */
182
+ private isAfter;
183
+ private formatDate;
184
+ /**
185
+ * NOTE: we are relying on the lit `live` directive in the template to
186
+ * ensure that the change to minSelectedDate is noticed and the input value
187
+ * gets properly re-rendered. see
188
+ * https://lit.dev/docs/templates/directives/#live
189
+ */
190
+ get minInputTemplate(): TemplateResult;
191
+ get maxInputTemplate(): TemplateResult;
192
+ get minLabelTemplate(): TemplateResult;
193
+ get maxLabelTemplate(): TemplateResult;
194
+ get tooltipTemplate(): TemplateResult;
195
+ private get noDataTemplate();
196
+ private get activityIndicatorTemplate();
197
+ static styles: import("lit").CSSResult;
198
+ render(): TemplateResult;
199
+ }
200
+ declare global {
201
+ interface HTMLElementTagNameMap {
202
+ 'ia-histogram-date-range': IAHistogramDateRange;
203
+ }
204
+ }
205
+ //# sourceMappingURL=ia-histogram-date-range.d.ts.map
@@ -0,0 +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,SAAQ,UAAU;IAEtB,KAAK,SAAS;IACd,MAAM,SAAU;IAChB,WAAW,SAAgB;IAC3B,YAAY,SAAiB;IAC7B,aAAa,SAAkB;IAC/B,WAAW,SAA4B;IACvC,UAAU,SAAe;IACzB,kBAAkB,SAAgB;IAClC,OAAO,SAAM;IACb,OAAO,SAAM;IACZ,QAAQ,UAAS;IACnB,IAAI,EAAE,MAAM,EAAE,CAAM;IAC/C,qFAAqF;IACxD,kBAAkB,UAAS;IAE5B,WAAW,EAAE,mBAAmB,CAAU;IAG7D,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,eAAe,CAAC,CAAiB;IACzC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,kBAAkB,CAAC,CAAS;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,C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