@internetarchive/histogram-date-range 1.2.1-alpha.1 → 1.2.2-alpha-webdev7377.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.
Files changed (35) hide show
  1. package/.editorconfig +29 -29
  2. package/.eslintrc.js +14 -14
  3. package/.github/workflows/ci.yml +30 -26
  4. package/LICENSE +661 -661
  5. package/README.md +113 -113
  6. package/demo/index.css +22 -22
  7. package/demo/index.html +159 -159
  8. package/dist/demo/js/app-root.d.ts +19 -19
  9. package/dist/demo/js/app-root.js +46 -46
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/src/histogram-date-range.d.ts +166 -159
  14. package/dist/src/histogram-date-range.js +856 -846
  15. package/dist/src/histogram-date-range.js.map +1 -1
  16. package/dist/test/histogram-date-range.test.d.ts +1 -1
  17. package/dist/test/histogram-date-range.test.js +488 -488
  18. package/dist/test/histogram-date-range.test.js.map +1 -1
  19. package/docs/demo/index.css +22 -22
  20. package/docs/demo/index.html +159 -159
  21. package/docs/dist/src/histogram-date-range.js +17 -12
  22. package/index.ts +1 -1
  23. package/package.json +85 -85
  24. package/snowpack.config.js +10 -10
  25. package/src/histogram-date-range.ts +923 -915
  26. package/test/histogram-date-range.test.ts +684 -684
  27. package/tsconfig.json +21 -21
  28. package/web-dev-server.config.mjs +28 -28
  29. package/web-test-runner.config.mjs +29 -29
  30. package/dist/demo/app-root.d.ts +0 -19
  31. package/dist/demo/app-root.js +0 -58
  32. package/dist/demo/app-root.js.map +0 -1
  33. package/dist/docs/_snowpack/pkg/@internetarchive/ia-activity-indicator/ia-activity-indicator.d.ts +0 -1
  34. package/dist/docs/_snowpack/pkg/@internetarchive/ia-activity-indicator/ia-activity-indicator.js +0 -2
  35. package/dist/docs/_snowpack/pkg/@internetarchive/ia-activity-indicator/ia-activity-indicator.js.map +0 -1
@@ -1,26 +1,26 @@
1
- import { __decorate } from "tslib";
2
- import { LitElement, html } from 'lit';
3
- import { customElement, state } from 'lit/decorators.js';
4
- import '../../src/histogram-date-range';
5
- /**
6
- * This is mainly to test the histogram-date-range within
7
- * a lit-element.
8
- */
9
- let AppRoot = class AppRoot extends LitElement {
10
- constructor() {
11
- super(...arguments);
12
- this.dataSource = {
13
- minDate: 1955,
14
- maxDate: 2000,
15
- minSelectedDate: 1955,
16
- maxSelectedDate: 2000,
17
- bins: [
18
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
19
- ],
20
- };
21
- }
22
- render() {
23
- var _a, _b, _c, _d, _e;
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html } from 'lit';
3
+ import { customElement, state } from 'lit/decorators.js';
4
+ import '../../src/histogram-date-range';
5
+ /**
6
+ * This is mainly to test the histogram-date-range within
7
+ * a lit-element.
8
+ */
9
+ let AppRoot = class AppRoot extends LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.dataSource = {
13
+ minDate: 1955,
14
+ maxDate: 2000,
15
+ minSelectedDate: 1955,
16
+ maxSelectedDate: 2000,
17
+ bins: [
18
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
19
+ ],
20
+ };
21
+ }
22
+ render() {
23
+ var _a, _b, _c, _d, _e;
24
24
  return html `
25
25
  <histogram-date-range
26
26
  .minDate=${(_a = this.dataSource) === null || _a === void 0 ? void 0 : _a.minDate}
@@ -32,27 +32,27 @@ let AppRoot = class AppRoot extends LitElement {
32
32
  ></histogram-date-range>
33
33
 
34
34
  <button @click=${this.randomize}>Randomize</button>
35
- `;
36
- }
37
- randomize() {
38
- const minDate = Math.round(Math.random() * 1000);
39
- const maxDate = minDate + Math.round(Math.random() * 1000);
40
- // generate random bins
41
- const bins = Array.from({ length: 20 }, () => Math.floor(Math.random() * minDate));
42
- this.dataSource = {
43
- minDate,
44
- maxDate,
45
- minSelectedDate: minDate,
46
- maxSelectedDate: maxDate,
47
- bins: bins,
48
- };
49
- }
50
- };
51
- __decorate([
52
- state()
53
- ], AppRoot.prototype, "dataSource", void 0);
54
- AppRoot = __decorate([
55
- customElement('app-root')
56
- ], AppRoot);
57
- export { AppRoot };
35
+ `;
36
+ }
37
+ randomize() {
38
+ const minDate = Math.round(Math.random() * 1000);
39
+ const maxDate = minDate + Math.round(Math.random() * 1000);
40
+ // generate random bins
41
+ const bins = Array.from({ length: 20 }, () => Math.floor(Math.random() * minDate));
42
+ this.dataSource = {
43
+ minDate,
44
+ maxDate,
45
+ minSelectedDate: minDate,
46
+ maxSelectedDate: maxDate,
47
+ bins: bins,
48
+ };
49
+ }
50
+ };
51
+ __decorate([
52
+ state()
53
+ ], AppRoot.prototype, "dataSource", void 0);
54
+ AppRoot = __decorate([
55
+ customElement('app-root')
56
+ ], AppRoot);
57
+ export { AppRoot };
58
58
  //# sourceMappingURL=app-root.js.map
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { HistogramDateRange } from './src/histogram-date-range';
1
+ export { HistogramDateRange } from './src/histogram-date-range';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { HistogramDateRange } from './src/histogram-date-range';
1
+ export { HistogramDateRange } from './src/histogram-date-range';
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["export { HistogramDateRange } from './src/histogram-date-range';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["export { HistogramDateRange } from './src/histogram-date-range';\r\n"]}
@@ -1,159 +1,166 @@
1
- import { LitElement, PropertyValues, SVGTemplateResult, TemplateResult } from 'lit';
2
- import '@internetarchive/ia-activity-indicator';
3
- export declare class HistogramDateRange extends LitElement {
4
- width: number;
5
- height: number;
6
- sliderWidth: number;
7
- tooltipWidth: number;
8
- tooltipHeight: number;
9
- updateDelay: number;
10
- dateFormat: string;
11
- missingDataMessage: string;
12
- minDate: string;
13
- maxDate: string;
14
- disabled: boolean;
15
- bins: number[];
16
- /** If true, update events will not be canceled by the date inputs receiving focus */
17
- updateWhileFocused: boolean;
18
- private _tooltipOffset;
19
- private _tooltipContent?;
20
- private _tooltipVisible;
21
- private _isDragging;
22
- private _isLoading;
23
- private _minSelectedDate;
24
- private _maxSelectedDate;
25
- private _minDateMS;
26
- private _maxDateMS;
27
- private _dragOffset;
28
- private _histWidth;
29
- private _binWidth;
30
- private _currentSlider?;
31
- private _histData;
32
- private _emitUpdatedEventTimer?;
33
- private _previousDateRange;
34
- disconnectedCallback(): void;
35
- updated(changedProps: PropertyValues): void;
36
- /**
37
- * Set private properties that depend on the attribute bin data
38
- *
39
- * We're caching these values and not using getters to avoid recalculating all
40
- * of the hist data every time the user drags a slider or hovers over a bar
41
- * creating a tooltip.
42
- */
43
- private handleDataUpdate;
44
- private calculateHistData;
45
- private get hasBinData();
46
- private get _numBins();
47
- private get histogramLeftEdgeX();
48
- private get histogramRightEdgeX();
49
- /** component's loading (and disabled) state */
50
- get loading(): boolean;
51
- set loading(value: boolean);
52
- /** formatted minimum date of selected date range */
53
- get minSelectedDate(): string;
54
- /** updates minSelectedDate if new date is valid */
55
- set minSelectedDate(rawDate: string);
56
- /** formatted maximum date of selected date range */
57
- get maxSelectedDate(): string;
58
- /** updates maxSelectedDate if new date is valid */
59
- set maxSelectedDate(rawDate: string);
60
- /** horizontal position of min date slider */
61
- get minSliderX(): number;
62
- /** horizontal position of max date slider */
63
- get maxSliderX(): number;
64
- private get dateRangeMS();
65
- private showTooltip;
66
- private hideTooltip;
67
- private drag;
68
- private drop;
69
- /**
70
- * Adjust the date range based on slider movement
71
- *
72
- * @param e PointerEvent from the slider being moved
73
- */
74
- private move;
75
- /**
76
- * Constrain a proposed value for the minimum (left) slider
77
- *
78
- * If the value is less than the leftmost valid position, then set it to the
79
- * left edge of the histogram (ie the slider width). If the value is greater
80
- * than the rightmost valid position (the position of the max slider), then
81
- * set it to the position of the max slider
82
- */
83
- private validMinSliderX;
84
- /**
85
- * Constrain a proposed value for the maximum (right) slider
86
- *
87
- * If the value is greater than the rightmost valid position, then set it to
88
- * the right edge of the histogram (ie histogram width - slider width). If the
89
- * value is less than the leftmost valid position (the position of the min
90
- * slider), then set it to the position of the min slider
91
- */
92
- private validMaxSliderX;
93
- private addListeners;
94
- private removeListeners;
95
- /**
96
- * start a timer to emit an update event. this timer can be canceled (and the
97
- * event not emitted) if user drags a slider or focuses a date input within
98
- * the update delay
99
- */
100
- private beginEmitUpdateProcess;
101
- private cancelPendingUpdateEvent;
102
- /**
103
- * find position of pointer in relation to the current slider
104
- */
105
- private setDragOffset;
106
- /**
107
- * @param x horizontal position of slider
108
- * @returns string representation of date
109
- */
110
- private translatePositionToDate;
111
- /**
112
- * Returns slider x-position corresponding to given date
113
- *
114
- * @param date
115
- * @returns x-position of slider
116
- */
117
- private translateDateToPosition;
118
- /** ensure that the returned value is between minValue and maxValue */
119
- private clamp;
120
- private handleInputFocus;
121
- private handleMinDateInput;
122
- private handleMaxDateInput;
123
- private handleKeyUp;
124
- private get currentDateRangeString();
125
- private getMSFromString;
126
- /**
127
- * expand or narrow the selected range by moving the slider nearest the
128
- * clicked bar to the outer edge of the clicked bar
129
- *
130
- * @param e Event click event from a histogram bar
131
- */
132
- private handleBarClick;
133
- private get minSliderTemplate();
134
- private get maxSliderTemplate();
135
- private generateSliderSVG;
136
- get selectedRangeTemplate(): SVGTemplateResult;
137
- get histogramTemplate(): SVGTemplateResult[];
138
- private formatDate;
139
- /**
140
- * NOTE: we are relying on the lit `live` directive in the template to
141
- * ensure that the change to minSelectedDate is noticed and the input value
142
- * gets properly re-rendered. see
143
- * https://lit.dev/docs/templates/directives/#live
144
- */
145
- get minInputTemplate(): TemplateResult;
146
- get maxInputTemplate(): TemplateResult;
147
- get minLabelTemplate(): TemplateResult;
148
- get maxLabelTemplate(): TemplateResult;
149
- get tooltipTemplate(): TemplateResult;
150
- private get noDataTemplate();
151
- private get activityIndicatorTemplate();
152
- static styles: import("lit").CSSResult;
153
- render(): TemplateResult;
154
- }
155
- declare global {
156
- interface HTMLElementTagNameMap {
157
- 'histogram-date-range': HistogramDateRange;
158
- }
159
- }
1
+ import '@internetarchive/ia-activity-indicator';
2
+ import { LitElement, PropertyValues, SVGTemplateResult, TemplateResult } from 'lit';
3
+ export declare class HistogramDateRange extends LitElement {
4
+ width: number;
5
+ height: number;
6
+ sliderWidth: number;
7
+ tooltipWidth: number;
8
+ tooltipHeight: number;
9
+ updateDelay: number;
10
+ dateFormat: string;
11
+ /** Optional; falls back to `dateFormat` if not provided */
12
+ tooltipDateFormat?: string;
13
+ missingDataMessage: string;
14
+ minDate: string;
15
+ maxDate: string;
16
+ disabled: boolean;
17
+ bins: number[];
18
+ /** If true, update events will not be canceled by the date inputs receiving focus */
19
+ updateWhileFocused: boolean;
20
+ private _tooltipOffset;
21
+ private _tooltipContent?;
22
+ private _tooltipVisible;
23
+ private _isDragging;
24
+ private _isLoading;
25
+ private _minSelectedDate;
26
+ private _maxSelectedDate;
27
+ private _minDateMS;
28
+ private _maxDateMS;
29
+ private _dragOffset;
30
+ private _histWidth;
31
+ private _binWidth;
32
+ private _currentSlider?;
33
+ private _histData;
34
+ private _emitUpdatedEventTimer?;
35
+ private _previousDateRange;
36
+ disconnectedCallback(): void;
37
+ willUpdate(changedProps: PropertyValues): void;
38
+ /**
39
+ * Set private properties that depend on the attribute bin data
40
+ *
41
+ * We're caching these values and not using getters to avoid recalculating all
42
+ * of the hist data every time the user drags a slider or hovers over a bar
43
+ * creating a tooltip.
44
+ */
45
+ private handleDataUpdate;
46
+ private calculateHistData;
47
+ private get hasBinData();
48
+ private get _numBins();
49
+ private get histogramLeftEdgeX();
50
+ private get histogramRightEdgeX();
51
+ /**
52
+ * Returns the consumer-specified tooltip date format if set, falling back to
53
+ * the general `dateFormat` property and then the default format if none is set.
54
+ */
55
+ private get resolvedTooltipDateFormat();
56
+ /** component's loading (and disabled) state */
57
+ get loading(): boolean;
58
+ set loading(value: boolean);
59
+ /** formatted minimum date of selected date range */
60
+ get minSelectedDate(): string;
61
+ /** updates minSelectedDate if new date is valid */
62
+ set minSelectedDate(rawDate: string);
63
+ /** formatted maximum date of selected date range */
64
+ get maxSelectedDate(): string;
65
+ /** updates maxSelectedDate if new date is valid */
66
+ set maxSelectedDate(rawDate: string);
67
+ /** horizontal position of min date slider */
68
+ get minSliderX(): number;
69
+ /** horizontal position of max date slider */
70
+ get maxSliderX(): number;
71
+ private get dateRangeMS();
72
+ private showTooltip;
73
+ private hideTooltip;
74
+ private drag;
75
+ private drop;
76
+ /**
77
+ * Adjust the date range based on slider movement
78
+ *
79
+ * @param e PointerEvent from the slider being moved
80
+ */
81
+ private move;
82
+ /**
83
+ * Constrain a proposed value for the minimum (left) slider
84
+ *
85
+ * If the value is less than the leftmost valid position, then set it to the
86
+ * left edge of the histogram (ie the slider width). If the value is greater
87
+ * than the rightmost valid position (the position of the max slider), then
88
+ * set it to the position of the max slider
89
+ */
90
+ private validMinSliderX;
91
+ /**
92
+ * Constrain a proposed value for the maximum (right) slider
93
+ *
94
+ * If the value is greater than the rightmost valid position, then set it to
95
+ * the right edge of the histogram (ie histogram width - slider width). If the
96
+ * value is less than the leftmost valid position (the position of the min
97
+ * slider), then set it to the position of the min slider
98
+ */
99
+ private validMaxSliderX;
100
+ private addListeners;
101
+ private removeListeners;
102
+ /**
103
+ * start a timer to emit an update event. this timer can be canceled (and the
104
+ * event not emitted) if user drags a slider or focuses a date input within
105
+ * the update delay
106
+ */
107
+ private beginEmitUpdateProcess;
108
+ private cancelPendingUpdateEvent;
109
+ /**
110
+ * find position of pointer in relation to the current slider
111
+ */
112
+ private setDragOffset;
113
+ /**
114
+ * @param x horizontal position of slider
115
+ * @returns string representation of date
116
+ */
117
+ private translatePositionToDate;
118
+ /**
119
+ * Returns slider x-position corresponding to given date
120
+ *
121
+ * @param date
122
+ * @returns x-position of slider
123
+ */
124
+ private translateDateToPosition;
125
+ /** ensure that the returned value is between minValue and maxValue */
126
+ private clamp;
127
+ private handleInputFocus;
128
+ private handleMinDateInput;
129
+ private handleMaxDateInput;
130
+ private handleKeyUp;
131
+ private get currentDateRangeString();
132
+ private getMSFromString;
133
+ /**
134
+ * expand or narrow the selected range by moving the slider nearest the
135
+ * clicked bar to the outer edge of the clicked bar
136
+ *
137
+ * @param e Event click event from a histogram bar
138
+ */
139
+ private handleBarClick;
140
+ private get minSliderTemplate();
141
+ private get maxSliderTemplate();
142
+ private generateSliderSVG;
143
+ get selectedRangeTemplate(): SVGTemplateResult;
144
+ get histogramTemplate(): SVGTemplateResult[];
145
+ private formatDate;
146
+ /**
147
+ * NOTE: we are relying on the lit `live` directive in the template to
148
+ * ensure that the change to minSelectedDate is noticed and the input value
149
+ * gets properly re-rendered. see
150
+ * https://lit.dev/docs/templates/directives/#live
151
+ */
152
+ get minInputTemplate(): TemplateResult;
153
+ get maxInputTemplate(): TemplateResult;
154
+ get minLabelTemplate(): TemplateResult;
155
+ get maxLabelTemplate(): TemplateResult;
156
+ get tooltipTemplate(): TemplateResult;
157
+ private get noDataTemplate();
158
+ private get activityIndicatorTemplate();
159
+ static styles: import("lit").CSSResult;
160
+ render(): TemplateResult;
161
+ }
162
+ declare global {
163
+ interface HTMLElementTagNameMap {
164
+ 'histogram-date-range': HistogramDateRange;
165
+ }
166
+ }