@internetarchive/histogram-date-range 0.1.0 → 0.1.1-alpha
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.
- package/demo/index.css +23 -0
- package/demo/index.html +37 -31
- package/dist/src/histogram-date-range.d.ts +7 -5
- package/dist/src/histogram-date-range.js +86 -47
- package/dist/src/histogram-date-range.js.map +1 -1
- package/dist/test/histogram-date-range.test.js +27 -9
- package/dist/test/histogram-date-range.test.js.map +1 -1
- package/docs/_snowpack/pkg/common/lit-html-bb3fcd20.js +8 -0
- package/docs/_snowpack/pkg/dayjs/esm/plugin/customParseFormat.js +327 -0
- package/docs/_snowpack/pkg/import-map.json +1 -0
- package/docs/_snowpack/pkg/lit/decorators.js +8 -2
- package/docs/_snowpack/pkg/lit/directives/live.js +4 -4
- package/docs/_snowpack/pkg/lit.js +6 -6
- package/docs/demo/index.css +23 -0
- package/docs/demo/index.html +37 -31
- package/docs/dist/src/histogram-date-range.js +69 -40
- package/package.json +3 -3
- package/src/histogram-date-range.ts +108 -53
- package/test/histogram-date-range.test.ts +33 -9
- package/docs/_snowpack/pkg/common/lit-html-e67c9f49.js +0 -8
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
2
|
+
var t = function t(format) {
|
|
3
|
+
return format.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function (_, a, b) {
|
|
4
|
+
return a || b.slice(1);
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
var englishFormats = {
|
|
8
|
+
LTS: 'h:mm:ss A',
|
|
9
|
+
LT: 'h:mm A',
|
|
10
|
+
L: 'MM/DD/YYYY',
|
|
11
|
+
LL: 'MMMM D, YYYY',
|
|
12
|
+
LLL: 'MMMM D, YYYY h:mm A',
|
|
13
|
+
LLLL: 'dddd, MMMM D, YYYY h:mm A'
|
|
14
|
+
};
|
|
15
|
+
var u = function u(formatStr, formats) {
|
|
16
|
+
return formatStr.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function (_, a, b) {
|
|
17
|
+
var B = b && b.toUpperCase();
|
|
18
|
+
return a || formats[b] || englishFormats[b] || t(formats[B]);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var formattingTokens = /(\[[^[]*\])|([-:/.()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g;
|
|
23
|
+
var match1 = /\d/; // 0 - 9
|
|
24
|
+
|
|
25
|
+
var match2 = /\d\d/; // 00 - 99
|
|
26
|
+
|
|
27
|
+
var match3 = /\d{3}/; // 000 - 999
|
|
28
|
+
|
|
29
|
+
var match4 = /\d{4}/; // 0000 - 9999
|
|
30
|
+
|
|
31
|
+
var match1to2 = /\d\d?/; // 0 - 99
|
|
32
|
+
|
|
33
|
+
var matchSigned = /[+-]?\d+/; // -inf - inf
|
|
34
|
+
|
|
35
|
+
var matchOffset = /[+-]\d\d:?(\d\d)?/; // +00:00 -00:00 +0000 or -0000 +00
|
|
36
|
+
|
|
37
|
+
var matchWord = /\d*[^\s\d-:/()]+/; // Word
|
|
38
|
+
|
|
39
|
+
var locale;
|
|
40
|
+
|
|
41
|
+
function offsetFromString(string) {
|
|
42
|
+
if (!string) return 0;
|
|
43
|
+
var parts = string.match(/([+-]|\d\d)/g);
|
|
44
|
+
var minutes = +(parts[1] * 60) + (+parts[2] || 0);
|
|
45
|
+
return minutes === 0 ? 0 : parts[0] === '+' ? -minutes : minutes; // eslint-disable-line no-nested-ternary
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var addInput = function addInput(property) {
|
|
49
|
+
return function (input) {
|
|
50
|
+
this[property] = +input;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var zoneExpressions = [matchOffset, function (input) {
|
|
55
|
+
var zone = this.zone || (this.zone = {});
|
|
56
|
+
zone.offset = offsetFromString(input);
|
|
57
|
+
}];
|
|
58
|
+
|
|
59
|
+
var getLocalePart = function getLocalePart(name) {
|
|
60
|
+
var part = locale[name];
|
|
61
|
+
return part && (part.indexOf ? part : part.s.concat(part.f));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var meridiemMatch = function meridiemMatch(input, isLowerCase) {
|
|
65
|
+
var isAfternoon;
|
|
66
|
+
var _locale = locale,
|
|
67
|
+
meridiem = _locale.meridiem;
|
|
68
|
+
|
|
69
|
+
if (!meridiem) {
|
|
70
|
+
isAfternoon = input === (isLowerCase ? 'pm' : 'PM');
|
|
71
|
+
} else {
|
|
72
|
+
for (var i = 1; i <= 24; i += 1) {
|
|
73
|
+
// todo: fix input === meridiem(i, 0, isLowerCase)
|
|
74
|
+
if (input.indexOf(meridiem(i, 0, isLowerCase)) > -1) {
|
|
75
|
+
isAfternoon = i > 12;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return isAfternoon;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var expressions = {
|
|
85
|
+
A: [matchWord, function (input) {
|
|
86
|
+
this.afternoon = meridiemMatch(input, false);
|
|
87
|
+
}],
|
|
88
|
+
a: [matchWord, function (input) {
|
|
89
|
+
this.afternoon = meridiemMatch(input, true);
|
|
90
|
+
}],
|
|
91
|
+
S: [match1, function (input) {
|
|
92
|
+
this.milliseconds = +input * 100;
|
|
93
|
+
}],
|
|
94
|
+
SS: [match2, function (input) {
|
|
95
|
+
this.milliseconds = +input * 10;
|
|
96
|
+
}],
|
|
97
|
+
SSS: [match3, function (input) {
|
|
98
|
+
this.milliseconds = +input;
|
|
99
|
+
}],
|
|
100
|
+
s: [match1to2, addInput('seconds')],
|
|
101
|
+
ss: [match1to2, addInput('seconds')],
|
|
102
|
+
m: [match1to2, addInput('minutes')],
|
|
103
|
+
mm: [match1to2, addInput('minutes')],
|
|
104
|
+
H: [match1to2, addInput('hours')],
|
|
105
|
+
h: [match1to2, addInput('hours')],
|
|
106
|
+
HH: [match1to2, addInput('hours')],
|
|
107
|
+
hh: [match1to2, addInput('hours')],
|
|
108
|
+
D: [match1to2, addInput('day')],
|
|
109
|
+
DD: [match2, addInput('day')],
|
|
110
|
+
Do: [matchWord, function (input) {
|
|
111
|
+
var _locale2 = locale,
|
|
112
|
+
ordinal = _locale2.ordinal;
|
|
113
|
+
|
|
114
|
+
var _input$match = input.match(/\d+/);
|
|
115
|
+
|
|
116
|
+
this.day = _input$match[0];
|
|
117
|
+
if (!ordinal) return;
|
|
118
|
+
|
|
119
|
+
for (var i = 1; i <= 31; i += 1) {
|
|
120
|
+
if (ordinal(i).replace(/\[|\]/g, '') === input) {
|
|
121
|
+
this.day = i;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}],
|
|
125
|
+
M: [match1to2, addInput('month')],
|
|
126
|
+
MM: [match2, addInput('month')],
|
|
127
|
+
MMM: [matchWord, function (input) {
|
|
128
|
+
var months = getLocalePart('months');
|
|
129
|
+
var monthsShort = getLocalePart('monthsShort');
|
|
130
|
+
var matchIndex = (monthsShort || months.map(function (_) {
|
|
131
|
+
return _.substr(0, 3);
|
|
132
|
+
})).indexOf(input) + 1;
|
|
133
|
+
|
|
134
|
+
if (matchIndex < 1) {
|
|
135
|
+
throw new Error();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.month = matchIndex % 12 || matchIndex;
|
|
139
|
+
}],
|
|
140
|
+
MMMM: [matchWord, function (input) {
|
|
141
|
+
var months = getLocalePart('months');
|
|
142
|
+
var matchIndex = months.indexOf(input) + 1;
|
|
143
|
+
|
|
144
|
+
if (matchIndex < 1) {
|
|
145
|
+
throw new Error();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.month = matchIndex % 12 || matchIndex;
|
|
149
|
+
}],
|
|
150
|
+
Y: [matchSigned, addInput('year')],
|
|
151
|
+
YY: [match2, function (input) {
|
|
152
|
+
input = +input;
|
|
153
|
+
this.year = input + (input > 68 ? 1900 : 2000);
|
|
154
|
+
}],
|
|
155
|
+
YYYY: [match4, addInput('year')],
|
|
156
|
+
Z: zoneExpressions,
|
|
157
|
+
ZZ: zoneExpressions
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
function correctHours(time) {
|
|
161
|
+
var afternoon = time.afternoon;
|
|
162
|
+
|
|
163
|
+
if (afternoon !== undefined) {
|
|
164
|
+
var hours = time.hours;
|
|
165
|
+
|
|
166
|
+
if (afternoon) {
|
|
167
|
+
if (hours < 12) {
|
|
168
|
+
time.hours += 12;
|
|
169
|
+
}
|
|
170
|
+
} else if (hours === 12) {
|
|
171
|
+
time.hours = 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
delete time.afternoon;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function makeParser(format) {
|
|
179
|
+
format = u(format, locale && locale.formats);
|
|
180
|
+
var array = format.match(formattingTokens);
|
|
181
|
+
var length = array.length;
|
|
182
|
+
|
|
183
|
+
for (var i = 0; i < length; i += 1) {
|
|
184
|
+
var token = array[i];
|
|
185
|
+
var parseTo = expressions[token];
|
|
186
|
+
var regex = parseTo && parseTo[0];
|
|
187
|
+
var parser = parseTo && parseTo[1];
|
|
188
|
+
|
|
189
|
+
if (parser) {
|
|
190
|
+
array[i] = {
|
|
191
|
+
regex: regex,
|
|
192
|
+
parser: parser
|
|
193
|
+
};
|
|
194
|
+
} else {
|
|
195
|
+
array[i] = token.replace(/^\[|\]$/g, '');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return function (input) {
|
|
200
|
+
var time = {};
|
|
201
|
+
|
|
202
|
+
for (var _i = 0, start = 0; _i < length; _i += 1) {
|
|
203
|
+
var _token = array[_i];
|
|
204
|
+
|
|
205
|
+
if (typeof _token === 'string') {
|
|
206
|
+
start += _token.length;
|
|
207
|
+
} else {
|
|
208
|
+
var _regex = _token.regex,
|
|
209
|
+
_parser = _token.parser;
|
|
210
|
+
var part = input.substr(start);
|
|
211
|
+
|
|
212
|
+
var match = _regex.exec(part);
|
|
213
|
+
|
|
214
|
+
var value = match[0];
|
|
215
|
+
|
|
216
|
+
_parser.call(time, value);
|
|
217
|
+
|
|
218
|
+
input = input.replace(value, '');
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
correctHours(time);
|
|
223
|
+
return time;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
var parseFormattedInput = function parseFormattedInput(input, format, utc) {
|
|
228
|
+
try {
|
|
229
|
+
var parser = makeParser(format);
|
|
230
|
+
|
|
231
|
+
var _parser2 = parser(input),
|
|
232
|
+
year = _parser2.year,
|
|
233
|
+
month = _parser2.month,
|
|
234
|
+
day = _parser2.day,
|
|
235
|
+
hours = _parser2.hours,
|
|
236
|
+
minutes = _parser2.minutes,
|
|
237
|
+
seconds = _parser2.seconds,
|
|
238
|
+
milliseconds = _parser2.milliseconds,
|
|
239
|
+
zone = _parser2.zone;
|
|
240
|
+
|
|
241
|
+
var now = new Date();
|
|
242
|
+
var d = day || (!year && !month ? now.getDate() : 1);
|
|
243
|
+
var y = year || now.getFullYear();
|
|
244
|
+
var M = 0;
|
|
245
|
+
|
|
246
|
+
if (!(year && !month)) {
|
|
247
|
+
M = month > 0 ? month - 1 : now.getMonth();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
var h = hours || 0;
|
|
251
|
+
var m = minutes || 0;
|
|
252
|
+
var s = seconds || 0;
|
|
253
|
+
var ms = milliseconds || 0;
|
|
254
|
+
|
|
255
|
+
if (zone) {
|
|
256
|
+
return new Date(Date.UTC(y, M, d, h, m, s, ms + zone.offset * 60 * 1000));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (utc) {
|
|
260
|
+
return new Date(Date.UTC(y, M, d, h, m, s, ms));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return new Date(y, M, d, h, m, s, ms);
|
|
264
|
+
} catch (e) {
|
|
265
|
+
return new Date(''); // Invalid Date
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
var __pika_web_default_export_for_treeshaking__ = (function (o, C, d) {
|
|
270
|
+
d.p.customParseFormat = true;
|
|
271
|
+
var proto = C.prototype;
|
|
272
|
+
var oldParse = proto.parse;
|
|
273
|
+
|
|
274
|
+
proto.parse = function (cfg) {
|
|
275
|
+
var date = cfg.date,
|
|
276
|
+
utc = cfg.utc,
|
|
277
|
+
args = cfg.args;
|
|
278
|
+
this.$u = utc;
|
|
279
|
+
var format = args[1];
|
|
280
|
+
|
|
281
|
+
if (typeof format === 'string') {
|
|
282
|
+
var isStrictWithoutLocale = args[2] === true;
|
|
283
|
+
var isStrictWithLocale = args[3] === true;
|
|
284
|
+
var isStrict = isStrictWithoutLocale || isStrictWithLocale;
|
|
285
|
+
var pl = args[2];
|
|
286
|
+
|
|
287
|
+
if (isStrictWithLocale) {
|
|
288
|
+
pl = args[2];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (!isStrictWithoutLocale) {
|
|
292
|
+
locale = pl ? d.Ls[pl] : this.$locale();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
this.$d = parseFormattedInput(date, format, utc);
|
|
296
|
+
this.init();
|
|
297
|
+
if (pl && pl !== true) this.$L = this.locale(pl).$L;
|
|
298
|
+
|
|
299
|
+
if (isStrict && date !== this.format(format)) {
|
|
300
|
+
this.$d = new Date('');
|
|
301
|
+
} // reset global locale to make parallel unit test
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
locale = undefined;
|
|
305
|
+
} else if (format instanceof Array) {
|
|
306
|
+
var len = format.length;
|
|
307
|
+
|
|
308
|
+
for (var i = 1; i <= len; i += 1) {
|
|
309
|
+
args[1] = format[i - 1];
|
|
310
|
+
var result = d.apply(this, args);
|
|
311
|
+
|
|
312
|
+
if (result.isValid()) {
|
|
313
|
+
this.$d = result.$d;
|
|
314
|
+
this.$L = result.$L;
|
|
315
|
+
this.init();
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (i === len) this.$d = new Date('');
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
oldParse.call(this, cfg);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
export default __pika_web_default_export_for_treeshaking__;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"imports": {
|
|
3
3
|
"@internetarchive/ia-activity-indicator/ia-activity-indicator": "./@internetarchive/ia-activity-indicator/ia-activity-indicator.js",
|
|
4
4
|
"dayjs/esm/index.js": "./dayjs/esm/index.js",
|
|
5
|
+
"dayjs/esm/plugin/customParseFormat": "./dayjs/esm/plugin/customParseFormat.js",
|
|
5
6
|
"lit": "./lit.js",
|
|
6
7
|
"lit/decorators.js": "./lit/decorators.js",
|
|
7
8
|
"lit/directives/live.js": "./lit/directives/live.js"
|
|
@@ -16,6 +16,12 @@ const i=(i,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,
|
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2017 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/function
|
|
19
|
+
*/function t(t){return e({...t,state:!0})}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2021 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/var n$1;const e$1=null!=(null===(n$1=window.HTMLSlotElement)||void 0===n$1?void 0:n$1.prototype.assignedElements)?(o,n)=>o.assignedElements(n):(o,n)=>o.assignedNodes(n).filter((o=>o.nodeType===Node.ELEMENT_NODE));
|
|
26
|
+
|
|
27
|
+
export { n as customElement, e as property, t as state };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b, w } from '../../common/lit-html-bb3fcd20.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2017 Google LLC
|
|
6
6
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
7
7
|
*/
|
|
8
|
-
const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},
|
|
8
|
+
const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
12
12
|
* Copyright 2020 Google LLC
|
|
13
13
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
14
|
-
*/const
|
|
14
|
+
*/const r=o=>void 0===o.strings,f={},s=(o,i=f)=>o._$AH=i;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @license
|
|
18
18
|
* Copyright 2020 Google LLC
|
|
19
19
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
20
|
-
*/const l=
|
|
20
|
+
*/const l=e(class extends i{constructor(r$1){if(super(r$1),r$1.type!==t.PROPERTY&&r$1.type!==t.ATTRIBUTE&&r$1.type!==t.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!r(r$1))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(i,[t$1]){if(t$1===b||t$1===w)return t$1;const o=i.element,l=i.name;if(i.type===t.PROPERTY){if(t$1===o[l])return b}else if(i.type===t.BOOLEAN_ATTRIBUTE){if(!!t$1===o.hasAttribute(l))return b}else if(i.type===t.ATTRIBUTE&&o.getAttribute(l)===t$1+"")return b;return s(i),t$1}});
|
|
21
21
|
|
|
22
22
|
export { l as live };
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { x, b } from './common/lit-html-bb3fcd20.js';
|
|
2
|
+
export { $ as html, w as nothing, y as svg } from './common/lit-html-bb3fcd20.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2019 Google LLC
|
|
7
7
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
8
8
|
*/
|
|
9
|
-
const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e=Symbol();class s{constructor(t,
|
|
9
|
+
const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e=Symbol(),n=new Map;class s{constructor(t,n){if(this._$cssResult$=!0,n!==e)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t;}get styleSheet(){let e=n.get(this.cssText);return t&&void 0===e&&(n.set(this.cssText,e=new CSSStyleSheet),e.replaceSync(this.cssText)),e}toString(){return this.cssText}}const o=t=>new s("string"==typeof t?t:t+"",e),r=(t,...n)=>{const o=1===t.length?t[0]:n.reduce(((e,n,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[s+1]),t[0]);return new s(o,e)},i=(e,n)=>{t?e.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):n.forEach((t=>{const n=document.createElement("style"),s=window.litNonce;void 0!==s&&n.setAttribute("nonce",s),n.textContent=t.cssText,e.appendChild(n);}));},S=t?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return o(e)})(t):t;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @license
|
|
13
13
|
* Copyright 2017 Google LLC
|
|
14
14
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
15
|
-
*/var s$1,e$1,h,
|
|
15
|
+
*/var s$1;const e$1=window.trustedTypes,r$1=e$1?e$1.emptyScript:"",h=window.reactiveElementPolyfillSupport,o$1={toAttribute(t,i){switch(i){case Boolean:t=t?r$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,i){let s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t);}catch(t){s=null;}}return s}},n$1=(t,i)=>i!==t&&(i==i||t==t),l={attribute:!0,type:String,converter:o$1,reflect:!1,hasChanged:n$1};class a extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o();}static addInitializer(t){var i;null!==(i=this.l)&&void 0!==i||(this.l=[]),this.l.push(t);}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,s)=>{const e=this._$Eh(s,i);void 0!==e&&(this._$Eu.set(e,s),t.push(e));})),t}static createProperty(t,i=l){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const s="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,s,i);void 0!==e&&Object.defineProperty(this.prototype,t,e);}}static getPropertyDescriptor(t,i,s){return {get(){return this[i]},set(e){const r=this[t];this[i]=e,this.requestUpdate(t,r,s);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||l}static finalize(){if(this.hasOwnProperty("finalized"))return !1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const s of i)this.createProperty(s,t[s]);}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(i){const s=[];if(Array.isArray(i)){const e=new Set(i.flat(1/0).reverse());for(const i of e)s.unshift(S(i));}else void 0!==i&&s.push(S(i));return s}static _$Eh(t,i){const s=i.attribute;return !1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)));}addController(t){var i,s;(null!==(i=this._$Eg)&&void 0!==i?i:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.call(t));}removeController(t){var i;null===(i=this._$Eg)||void 0===i||i.splice(this._$Eg.indexOf(t)>>>0,1);}_$Em(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Et.set(i,this[i]),delete this[i]);}));}createRenderRoot(){var t;const s=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return i(s,this.constructor.elementStyles),s}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}));}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}));}attributeChangedCallback(t,i,s){this._$AK(t,s);}_$ES(t,i,s=l){var e,r;const h=this.constructor._$Eh(t,s);if(void 0!==h&&!0===s.reflect){const n=(null!==(r=null===(e=s.converter)||void 0===e?void 0:e.toAttribute)&&void 0!==r?r:o$1.toAttribute)(i,s.type);this._$Ei=t,null==n?this.removeAttribute(h):this.setAttribute(h,n),this._$Ei=null;}}_$AK(t,i){var s,e,r;const h=this.constructor,n=h._$Eu.get(t);if(void 0!==n&&this._$Ei!==n){const t=h.getPropertyOptions(n),l=t.converter,a=null!==(r=null!==(e=null===(s=l)||void 0===s?void 0:s.fromAttribute)&&void 0!==e?e:"function"==typeof l?l:null)&&void 0!==r?r:o$1.fromAttribute;this._$Ei=n,this[n]=a(i,t.type),this._$Ei=null;}}requestUpdate(t,i,s){let e=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||n$1)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$Ei!==t&&(void 0===this._$E_&&(this._$E_=new Map),this._$E_.set(t,s))):e=!1),!this.isUpdatePending&&e&&(this._$Ep=this._$EC());}async _$EC(){this.isUpdatePending=!0;try{await this._$Ep;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,i)=>this[i]=t)),this._$Et=void 0);let i=!1;const s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(s)):this._$EU();}catch(t){throw i=!1,this._$EU(),t}i&&this._$AE(s);}willUpdate(t){}_$AE(t){var i;null===(i=this._$Eg)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$EU(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return !0}update(t){void 0!==this._$E_&&(this._$E_.forEach(((t,i)=>this._$ES(i,this[i],t))),this._$E_=void 0),this._$EU();}updated(t){}firstUpdated(t){}}a.finalized=!0,a.elementProperties=new Map,a.elementStyles=[],a.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:a}),(null!==(s$1=globalThis.reactiveElementVersions)&&void 0!==s$1?s$1:globalThis.reactiveElementVersions=[]).push("1.1.2");
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @license
|
|
19
19
|
* Copyright 2017 Google LLC
|
|
20
20
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
21
|
-
*/var
|
|
21
|
+
*/var l$1,o$2;class s$2 extends a{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0;}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=x(i,this.renderRoot,this.renderOptions);}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0);}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1);}render(){return b}}s$2.finalized=!0,s$2._$litElement$=!0,null===(l$1=globalThis.litElementHydrateSupport)||void 0===l$1||l$1.call(globalThis,{LitElement:s$2});const n$2=globalThis.litElementPolyfillSupport;null==n$2||n$2({LitElement:s$2});(null!==(o$2=globalThis.litElementVersions)&&void 0!==o$2?o$2:globalThis.litElementVersions=[]).push("3.1.1");
|
|
22
22
|
|
|
23
|
-
export {
|
|
23
|
+
export { s$2 as LitElement, r as css };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
html {
|
|
2
|
+
font-size: 10px;
|
|
3
|
+
font-family: sans-serif;
|
|
4
|
+
}
|
|
5
|
+
body {
|
|
6
|
+
background: white;
|
|
7
|
+
}
|
|
8
|
+
.container {
|
|
9
|
+
margin-top: 20px;
|
|
10
|
+
display: grid;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
}
|
|
13
|
+
.description {
|
|
14
|
+
margin: 10px auto;
|
|
15
|
+
}
|
|
16
|
+
.received-events {
|
|
17
|
+
position: absolute;
|
|
18
|
+
top: 0;
|
|
19
|
+
}
|
|
20
|
+
button {
|
|
21
|
+
font-size: 100%;
|
|
22
|
+
margin: 10px auto;
|
|
23
|
+
}
|
package/docs/demo/index.html
CHANGED
|
@@ -3,40 +3,16 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
5
5
|
<meta charset="utf-8" />
|
|
6
|
-
<
|
|
7
|
-
html {
|
|
8
|
-
font-size: 10px;
|
|
9
|
-
font-family: sans-serif;
|
|
10
|
-
}
|
|
11
|
-
body {
|
|
12
|
-
background: white;
|
|
13
|
-
}
|
|
14
|
-
.container {
|
|
15
|
-
margin-top: 20px;
|
|
16
|
-
display: grid;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
}
|
|
19
|
-
.description {
|
|
20
|
-
margin: 10px auto;
|
|
21
|
-
}
|
|
22
|
-
.received-events {
|
|
23
|
-
position: absolute;
|
|
24
|
-
top: 0;
|
|
25
|
-
}
|
|
26
|
-
button {
|
|
27
|
-
font-size: 100%;
|
|
28
|
-
margin: 10px auto;
|
|
29
|
-
}
|
|
30
|
-
</style>
|
|
6
|
+
<link rel="stylesheet" href="index.css">
|
|
31
7
|
</head>
|
|
32
8
|
|
|
33
9
|
<script type="module">
|
|
34
10
|
import '../dist/src/histogram-date-range.js';
|
|
11
|
+
let eventCount = 0;
|
|
35
12
|
// listen to events from the component and display the data received from them
|
|
36
13
|
document.addEventListener('histogramDateRangeUpdated', e => {
|
|
37
|
-
document.querySelector('.received-events').innerHTML =
|
|
38
|
-
|
|
39
|
-
);
|
|
14
|
+
document.querySelector('.received-events').innerHTML =
|
|
15
|
+
++eventCount + ': ' + JSON.stringify(e.detail);
|
|
40
16
|
});
|
|
41
17
|
</script>
|
|
42
18
|
<body>
|
|
@@ -60,6 +36,27 @@
|
|
|
60
36
|
></histogram-date-range>
|
|
61
37
|
</div>
|
|
62
38
|
|
|
39
|
+
<div class="container">
|
|
40
|
+
<div class="description">range spanning negative to positive years</div>
|
|
41
|
+
<histogram-date-range
|
|
42
|
+
mindate="-1050" maxdate="2200"
|
|
43
|
+
bins="[ 74, 67, 17, 66, 49, 93, 47, 61, 32, 46, 53, 2,
|
|
44
|
+
13, 45, 28, 1, 8, 70, 37, 74, 67, 17, 66, 49, 93,
|
|
45
|
+
47, 61, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32,
|
|
46
|
+
32, 70, 37, 74, 67, 17, 66, 49, 93, 47, 61, 32
|
|
47
|
+
]"
|
|
48
|
+
></histogram-date-range>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<div class="container">
|
|
54
|
+
<div class="description">small year range and few bins</div>
|
|
55
|
+
<histogram-date-range width="175" tooltipwidth="120"
|
|
56
|
+
mindate="2008" maxdate="2016" bins="[76104,866978,1151617,986331,218672,107410,3324]">
|
|
57
|
+
</histogram-date-range>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
63
60
|
<div class="container">
|
|
64
61
|
<div class="description">
|
|
65
62
|
default range with custom styling and date format
|
|
@@ -77,8 +74,8 @@
|
|
|
77
74
|
--histogramDateRangeTooltipFontSize: 1rem;
|
|
78
75
|
--histogramDateRangeInputWidth: 85px;
|
|
79
76
|
"
|
|
80
|
-
minDate="May
|
|
81
|
-
maxDate="
|
|
77
|
+
minDate="05 May 1972"
|
|
78
|
+
maxDate="21 Dec 1980"
|
|
82
79
|
bins="[ 85, 25, 200, 0, 0, 34, 0, 2, 5, 10, 0, 56, 10, 45, 100, 70, 50 ]"
|
|
83
80
|
></histogram-date-range>
|
|
84
81
|
</div>
|
|
@@ -123,9 +120,18 @@
|
|
|
123
120
|
});
|
|
124
121
|
</script>
|
|
125
122
|
|
|
123
|
+
<!-- <div class="container">
|
|
124
|
+
<div class="description">
|
|
125
|
+
single bin
|
|
126
|
+
</div>
|
|
127
|
+
<histogram-date-range mindate="1926" maxdate="1926" bins="[8]">
|
|
128
|
+
</histogram-date-range>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
126
131
|
<div class="container">
|
|
127
132
|
<div class="description">empty data</div>
|
|
128
133
|
<histogram-date-range missingDataMessage="no data..."></histoghistogram-date-range>
|
|
129
|
-
</div>
|
|
134
|
+
</div> -->
|
|
135
|
+
|
|
130
136
|
</body>
|
|
131
137
|
</html>
|