tltv-timeline-element 1.0.8 → 1.0.12
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/dist/src/model/DefaultLocaleDataProvider.d.ts +3 -0
- package/dist/src/model/DefaultLocaleDataProvider.js +87 -0
- package/dist/src/model/DefaultLocaleDataProvider.js.map +1 -0
- package/dist/src/model/ILocaleDataProvider.d.ts +1 -1
- package/dist/src/model/ILocaleDataProvider.js +2 -0
- package/dist/src/model/ILocaleDataProvider.js.map +1 -0
- package/dist/src/model/IResolutionBlockFiller.d.ts +1 -1
- package/dist/src/model/IResolutionBlockFiller.js +2 -0
- package/dist/src/model/IResolutionBlockFiller.js.map +1 -0
- package/dist/src/model/IResolutionBlockRegisterer.d.ts +1 -1
- package/dist/src/model/IResolutionBlockRegisterer.js +2 -0
- package/dist/src/model/IResolutionBlockRegisterer.js.map +1 -0
- package/dist/src/model/Resolution.js +7 -0
- package/dist/src/model/Resolution.js.map +1 -0
- package/dist/src/model/Weekday.js +7 -0
- package/dist/src/model/Weekday.js.map +1 -0
- package/dist/src/model/blockRowData.js +29 -0
- package/dist/src/model/blockRowData.js.map +1 -0
- package/dist/src/timeline-element.d.ts +3 -3
- package/dist/src/timeline-element.js +1731 -0
- package/dist/src/timeline-element.js.map +1 -0
- package/dist/src/util/dateTimeUtil.js +56 -0
- package/dist/src/util/dateTimeUtil.js.map +1 -0
- package/dist/src/util/elementUtil.js +49 -0
- package/dist/src/util/elementUtil.js.map +1 -0
- package/package.json +3 -2
- package/src/model/DefaultLocaleDataProvider.ts +17 -8
- package/src/model/ILocaleDataProvider.ts +1 -1
- package/src/model/IResolutionBlockFiller.ts +1 -1
- package/src/model/IResolutionBlockRegisterer.ts +1 -1
- package/src/timeline-element.ts +3 -3
- package/tsconfig.json +3 -2
- package/dist/timeline-element.js +0 -10175
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILocaleDataProvider } from './ILocaleDataProvider';
|
|
1
2
|
export declare class DefaultLocaleDataProvider implements ILocaleDataProvider {
|
|
2
3
|
locale: string;
|
|
3
4
|
timeZone: string;
|
|
@@ -5,6 +6,7 @@ export declare class DefaultLocaleDataProvider implements ILocaleDataProvider {
|
|
|
5
6
|
firstDayOfWeek: number;
|
|
6
7
|
monthNames: string[];
|
|
7
8
|
weekDayNames: string[];
|
|
9
|
+
_offsetCache: Map<string, number>;
|
|
8
10
|
constructor(locale: string, timeZone: string, firstDayOfWeek: number, twelveHourClock: boolean);
|
|
9
11
|
getMonthNames(): string[];
|
|
10
12
|
getWeekdayNames(): string[];
|
|
@@ -16,4 +18,5 @@ export declare class DefaultLocaleDataProvider implements ILocaleDataProvider {
|
|
|
16
18
|
getDaylightAdjustment(zonedDate: Date): number;
|
|
17
19
|
isDaylightTime(zonedDate: Date): boolean;
|
|
18
20
|
getTimezoneOffset(zonedDate: Date): number;
|
|
21
|
+
_getOffset(fullYear: number, month: string, cache: Map<string, number>): number;
|
|
19
22
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { format } from 'date-fns-tz';
|
|
2
|
+
export class DefaultLocaleDataProvider {
|
|
3
|
+
constructor(locale, timeZone, firstDayOfWeek, twelveHourClock) {
|
|
4
|
+
this.locale = "en-US";
|
|
5
|
+
this.timeZone = "Europe/London";
|
|
6
|
+
this.twelveHourClock = false;
|
|
7
|
+
this.firstDayOfWeek = 1; // sunday
|
|
8
|
+
this.monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
9
|
+
this.weekDayNames = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
10
|
+
this._offsetCache = new Map();
|
|
11
|
+
this.locale = locale;
|
|
12
|
+
this.timeZone = timeZone;
|
|
13
|
+
this.firstDayOfWeek = firstDayOfWeek;
|
|
14
|
+
this.twelveHourClock = twelveHourClock;
|
|
15
|
+
}
|
|
16
|
+
getMonthNames() {
|
|
17
|
+
return this.monthNames;
|
|
18
|
+
}
|
|
19
|
+
getWeekdayNames() {
|
|
20
|
+
return this.weekDayNames;
|
|
21
|
+
}
|
|
22
|
+
getFirstDayOfWeek() {
|
|
23
|
+
return this.firstDayOfWeek + 1;
|
|
24
|
+
}
|
|
25
|
+
formatDate(date, pattern) {
|
|
26
|
+
return format(date, pattern, { timeZone: this.getTimeZone() });
|
|
27
|
+
}
|
|
28
|
+
isTwelveHourClock() {
|
|
29
|
+
return this.twelveHourClock;
|
|
30
|
+
}
|
|
31
|
+
getLocale() {
|
|
32
|
+
return this.locale;
|
|
33
|
+
}
|
|
34
|
+
getTimeZone() {
|
|
35
|
+
return this.timeZone;
|
|
36
|
+
}
|
|
37
|
+
getDaylightAdjustment(zonedDate) {
|
|
38
|
+
let fullYear = zonedDate.getFullYear();
|
|
39
|
+
let janOffset = this._getOffset(fullYear, "01", this._offsetCache);
|
|
40
|
+
let julOffset = this._getOffset(fullYear, "07", this._offsetCache);
|
|
41
|
+
if (janOffset !== julOffset) {
|
|
42
|
+
let maxOffset = Math.max(janOffset, julOffset);
|
|
43
|
+
let targetOffset = this.getTimezoneOffset(zonedDate);
|
|
44
|
+
if (targetOffset < maxOffset) {
|
|
45
|
+
// This is Daylight saving time
|
|
46
|
+
let minOffset = Math.min(janOffset, julOffset);
|
|
47
|
+
return maxOffset - minOffset;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
isDaylightTime(zonedDate) {
|
|
53
|
+
let fullYear = zonedDate.getFullYear();
|
|
54
|
+
let janOffset = this._getOffset(fullYear, "01", this._offsetCache);
|
|
55
|
+
let julOffset = this._getOffset(fullYear, "07", this._offsetCache);
|
|
56
|
+
if (janOffset !== julOffset) {
|
|
57
|
+
let maxOffset = Math.max(janOffset, julOffset);
|
|
58
|
+
let targetOffset = this.getTimezoneOffset(zonedDate);
|
|
59
|
+
return targetOffset < maxOffset;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
getTimezoneOffset(zonedDate) {
|
|
64
|
+
let offset = format(zonedDate, "xxx", { timeZone: this.getTimeZone() }); // like "+01:00"
|
|
65
|
+
if (offset && offset.length === 6) {
|
|
66
|
+
let hour = offset[1] + offset[2];
|
|
67
|
+
if (hour === '24') {
|
|
68
|
+
hour = '00';
|
|
69
|
+
}
|
|
70
|
+
let tzOffset = (parseInt(hour) * 60) + parseInt(offset[4] + offset[5]);
|
|
71
|
+
if (offset[0] === '-') {
|
|
72
|
+
tzOffset = -1 * tzOffset;
|
|
73
|
+
}
|
|
74
|
+
return tzOffset * 60000;
|
|
75
|
+
}
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
_getOffset(fullYear, month, cache) {
|
|
79
|
+
const key = `${fullYear}-${month}`;
|
|
80
|
+
if (!cache.get(key)) {
|
|
81
|
+
let jan = new Date(`${fullYear}-${month}-01T00:00:00Z`);
|
|
82
|
+
cache.set(key, this.getTimezoneOffset(jan));
|
|
83
|
+
}
|
|
84
|
+
return cache.get(key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=DefaultLocaleDataProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultLocaleDataProvider.js","sourceRoot":"","sources":["../../../src/model/DefaultLocaleDataProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrE,MAAM,OAAO,yBAAyB;IAWlC,YAAY,MAAc,EAAE,QAAgB,EAAE,cAAsB,EAAE,eAAwB;QATvF,WAAM,GAAW,OAAO,CAAC;QACzB,aAAQ,GAAW,eAAe,CAAC;QACnC,oBAAe,GAAY,KAAK,CAAC;QACjC,mBAAc,GAAW,CAAC,CAAC,CAAC,SAAS;QACrC,eAAU,GAAa,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EA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CAAC,CAAC;YACjC,IAAG,IAAI,KAAK,IAAI,EAAE;gBACd,IAAI,GAAG,IAAI,CAAC;aACf;YACD,IAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACvE,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBACnB,QAAQ,GAAG,CAAC,CAAC,GAAC,QAAQ,CAAC;aAC1B;YACD,OAAO,QAAQ,GAAG,KAAK,CAAC;SAC3B;QACD,OAAO,CAAC,CAAC;IACb,CAAC;IACD,UAAU,CAAC,QAAgB,EAAE,KAAa,EAAE,KAA0B;QAClE,MAAM,GAAG,GAAG,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC;QACnC,IAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAChB,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,QAAQ,IAAI,KAAK,eAAe,CAAC,CAAC;YACxD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC;SAC/C;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ILocaleDataProvider.js","sourceRoot":"","sources":["../../../src/model/ILocaleDataProvider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResolutionBlockFiller.js","sourceRoot":"","sources":["../../../src/model/IResolutionBlockFiller.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResolutionBlockRegisterer.js","sourceRoot":"","sources":["../../../src/model/IResolutionBlockRegisterer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var Resolution;
|
|
2
|
+
(function (Resolution) {
|
|
3
|
+
Resolution[Resolution["Hour"] = 1] = "Hour";
|
|
4
|
+
Resolution[Resolution["Day"] = 2] = "Day";
|
|
5
|
+
Resolution[Resolution["Week"] = 3] = "Week";
|
|
6
|
+
})(Resolution || (Resolution = {}));
|
|
7
|
+
//# sourceMappingURL=Resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Resolution.js","sourceRoot":"","sources":["../../../src/model/Resolution.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,2CAAQ,CAAA;IACR,yCAAO,CAAA;IACP,2CAAQ,CAAA;AACZ,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Weekday.js","sourceRoot":"","sources":["../../../src/model/Weekday.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,uCAAK,CAAA;IACL,2CAAO,CAAA;IACP,qCAAI,CAAA;AACN,CAAC,EAJW,OAAO,KAAP,OAAO,QAIlB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class BlockRowData {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.blocks = new Map();
|
|
4
|
+
this.blockLength = new Map();
|
|
5
|
+
}
|
|
6
|
+
size() {
|
|
7
|
+
return this.blocks.size;
|
|
8
|
+
}
|
|
9
|
+
getBlock(key) {
|
|
10
|
+
return this.blocks.get(key);
|
|
11
|
+
}
|
|
12
|
+
getBlockEntries() {
|
|
13
|
+
return this.blocks.entries();
|
|
14
|
+
}
|
|
15
|
+
setBlock(key, element) {
|
|
16
|
+
this.blocks.set(key, element);
|
|
17
|
+
}
|
|
18
|
+
getBlockLength(key) {
|
|
19
|
+
return this.blockLength.get(key);
|
|
20
|
+
}
|
|
21
|
+
setBlockLength(key, length) {
|
|
22
|
+
this.blockLength.set(key, length);
|
|
23
|
+
}
|
|
24
|
+
clear() {
|
|
25
|
+
this.blocks.clear();
|
|
26
|
+
this.blockLength.clear();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=blockRowData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockRowData.js","sourceRoot":"","sources":["../../../src/model/blockRowData.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAAzB;QAEE,WAAM,GAAqB,IAAI,GAAG,EAAE,CAAC;QACrC,gBAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;IA8B/C,CAAC;IA5BC,IAAI;QACA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,QAAQ,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAED,QAAQ,CAAC,GAAW,EAAE,OAAY;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,cAAc,CAAC,GAAW;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,cAAc,CAAC,GAAW,EAAE,MAAc;QACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,KAAK;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -2,9 +2,9 @@ import { LitElement } from 'lit-element';
|
|
|
2
2
|
import { Resolution } from './model/Resolution';
|
|
3
3
|
import { Weekday } from './model/Weekday';
|
|
4
4
|
import { BlockRowData } from './model/blockRowData';
|
|
5
|
-
import './model/ILocaleDataProvider
|
|
6
|
-
import './model/IResolutionBlockFiller
|
|
7
|
-
import './model/IResolutionBlockRegisterer
|
|
5
|
+
import { ILocaleDataProvider } from './model/ILocaleDataProvider';
|
|
6
|
+
import { IResolutionBlockFiller } from './model/IResolutionBlockFiller';
|
|
7
|
+
import { IResolutionBlockRegisterer } from './model/IResolutionBlockRegisterer';
|
|
8
8
|
/**
|
|
9
9
|
* Scalable timeline web component that supports more than one
|
|
10
10
|
* resolutions ({@link Resolution}). When timeline element doesn't overflow
|