tltv-timeline-element 1.0.19 → 1.0.21

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,352 @@
1
+ import { LitElement, nothing } from 'lit';
2
+ import { Resolution } from './model/Resolution';
3
+ import { Weekday } from './model/Weekday';
4
+ import { BlockRowData } from './model/blockRowData';
5
+ import { ILocaleDataProvider } from './model/ILocaleDataProvider';
6
+ import { IResolutionBlockFiller } from './model/IResolutionBlockFiller';
7
+ import { IResolutionBlockRegisterer } from './model/IResolutionBlockRegisterer';
8
+ /**
9
+ * Scalable timeline web component that supports more than one
10
+ * resolutions ({@link Resolution}). When timeline element doesn't overflow
11
+ * horizontally in it's parent element, it scales the content width up to fit in
12
+ * the space available.
13
+ * <p>
14
+ * When this component scales up, all widths are calculated as percentages.
15
+ * Pixel widths are used otherwise. Some browsers may not support percentages
16
+ * accurately enough, and for those it's best to call
17
+ * {@link #setAlwaysCalculatePixelWidths(boolean)} with 'true' to disable
18
+ * percentage values.
19
+ * <p>
20
+ * There's always a minimum width calculated and updated to the timeline
21
+ * element. Percentage values set some limitation for the component's width.
22
+ * Wider the component (&gt; 4000px), bigger the chance to get year, month and
23
+ * date blocks not being vertically in-line with each others.
24
+ * <p>
25
+ * Supports setting a scroll left position.
26
+ * <p>
27
+ * After construction, attach the component to it's parent and call update
28
+ * method with a required parameters and the timeline is ready. After that, all
29
+ * widths are calculated and all other API methods available can be used safely.
30
+ *
31
+ */
32
+ export declare class TimelineElement extends LitElement {
33
+ private static readonly STYLE_ROW;
34
+ private static readonly STYLE_COL;
35
+ private static readonly STYLE_MONTH;
36
+ private static readonly STYLE_YEAR;
37
+ private static readonly STYLE_DAY;
38
+ private static readonly STYLE_WEEK;
39
+ private static readonly STYLE_RESOLUTION;
40
+ private static readonly STYLE_EVEN;
41
+ private static readonly STYLE_WEEKEND;
42
+ private static readonly STYLE_SPACER;
43
+ private static readonly STYLE_FIRST;
44
+ private static readonly STYLE_CENTER;
45
+ private static readonly STYLE_LAST;
46
+ private static readonly STYLE_MEASURE;
47
+ private readonly resolutionWeekDayblockWidth;
48
+ resolution: Resolution;
49
+ startDateTime: string;
50
+ endDateTime: string;
51
+ /** Start Date of the timeline. Native Date object can be in "wrong" time zone, as it matches browser's time zone. */
52
+ internalInclusiveStartDateTime: Date;
53
+ /** End Date of the timeline. */
54
+ internalInclusiveEndDateTime: Date;
55
+ /** Timezone for date and time formatting. Doesn't match with actual start and end Date object's time zone. */
56
+ timeZone: string;
57
+ locale: string;
58
+ firstDayOfWeek: number;
59
+ twelveHourClock: boolean;
60
+ minWidth: number;
61
+ normalStartDate: Date;
62
+ normalEndDate: Date;
63
+ lastDayOfWeek: number;
64
+ firstDayOfRange: number;
65
+ firstHourOfRange: number;
66
+ scrollContainerId: string;
67
+ monthRowVisible: boolean;
68
+ yearRowVisible: boolean;
69
+ monthNames: string[];
70
+ weekdayNames: string[];
71
+ private localeDataProvider;
72
+ private blocksInRange;
73
+ private resolutionBlockCount;
74
+ private firstResBlockCount;
75
+ private lastResBlockCount;
76
+ private firstDay;
77
+ private timelineOverflowingHorizontally;
78
+ private monthFormat;
79
+ private yearFormat;
80
+ private weekFormat;
81
+ private dayFormat;
82
+ resolutionDiv: HTMLDivElement;
83
+ private resSpacerDiv;
84
+ private spacerBlocks;
85
+ private yearRowData;
86
+ private monthRowData;
87
+ private dayRowData;
88
+ private dayWidthPercentage;
89
+ private dayOrHourWidthPx;
90
+ private resBlockMinWidthPx;
91
+ private resBlockWidthPx;
92
+ private resBlockWidthPercentage;
93
+ private minResolutionWidth;
94
+ private calcPixels;
95
+ private positionLeft;
96
+ private setPositionForEachBlock;
97
+ private firstWeekBlockHidden;
98
+ private ie;
99
+ private lazyResolutionPaint;
100
+ private directlyInsideScrollContainer;
101
+ private scrollHandler;
102
+ private scrollContainer;
103
+ private previousContainerScrollLeft;
104
+ private previousContainerScrollTop;
105
+ connectedCallback(): void;
106
+ disconnectedCallback(): void;
107
+ static get styles(): import("lit").CSSResult;
108
+ render(): import("lit-html").TemplateResult<1>;
109
+ yearBlocks(): typeof nothing | import("lit-html").TemplateResult<1>[];
110
+ monthBlocks(): typeof nothing | import("lit-html").TemplateResult<1>[];
111
+ dayBlocks(): typeof nothing | import("lit-html").TemplateResult<1>[];
112
+ shouldUpdate(changedProperties: any): any;
113
+ willUpdate(changedProps: any): void;
114
+ protected updated(changedProps: any): void;
115
+ /**
116
+ * <p>
117
+ * Updates the content of this component. Builds the time-line and calculates
118
+ * width and heights for the content (calls in the end
119
+ * {@link #updateWidths()}). This should be called explicitly. Otherwise the
120
+ * component will be empty.
121
+ * <p>
122
+ * Date values should always follow specification in {@link Date#getTime()}.
123
+ * Start and end date is always required.
124
+ *
125
+ * @param resolution
126
+ * Resolution enum (not null)
127
+ * @param startDate
128
+ * Time-line's start date. (inclusive; not null)
129
+ * @param endDate
130
+ * Time-line's end date. (inclusive; not null)
131
+ * @param localeDataProvider
132
+ * Data provider for locale specific data. month names, first day
133
+ * of week etc.
134
+ *
135
+ */
136
+ updateTimeLine(resolution: Resolution, startDate: Date, endDate: Date, localeDataProvider: ILocaleDataProvider): void;
137
+ resetDateRange(startDate: Date, endDate: Date): void;
138
+ registerScrollHandler(): void;
139
+ setupScrollContainer(): HTMLElement | Window;
140
+ clear(): void;
141
+ calculateResolutionMinWidth(): number;
142
+ registerHourResolutionBlock(): void;
143
+ registerDayResolutionBlock(): void;
144
+ registerWeekResolutionBlock(index: number, weekDay: Weekday, lastBlock: boolean, firstWeek: boolean): void;
145
+ timelineBlocks(rowData: BlockRowData, style: string): import("lit-html").TemplateResult<1>[];
146
+ /**
147
+ * Returns true if Widget is set to calculate widths by itself. Default is
148
+ * false.
149
+ *
150
+ * @return
151
+ */
152
+ isAlwaysCalculatePixelWidths(): boolean;
153
+ createSpacerBlock(className: string): HTMLDivElement;
154
+ /** Clears Daylight saving time adjustment from the given time. */
155
+ toNormalDate(zonedDate: Date): Date;
156
+ getDSTAdjustedDate(previousIsDST: boolean, zonedDate: Date): Date;
157
+ getParentElement(node: any): any;
158
+ getDay(date: Date): string;
159
+ getYear(date: Date): string;
160
+ getMonth(date: Date): number;
161
+ isWeekEnd(dayCounter: number): boolean;
162
+ key(prefix: string, rowData: BlockRowData): string;
163
+ newKey(prefix: string, rowData: BlockRowData): string;
164
+ addBlock(current: string, target: string, date: Date, rowData: BlockRowData, operation: (target: string, value: string, date: Date) => void): string;
165
+ addDayBlock(currentDay: string, date: Date): string;
166
+ addMonthBlock(currentMonth: string, date: Date): string;
167
+ addYearBlock(currentYear: string, date: Date): string;
168
+ addMonthBlockElement(key: string, text: string): void;
169
+ addYearBlockElement(key: string, text: string): void;
170
+ addDayBlockElement(key: string, text: string): void;
171
+ createTimelineBlock(key: string, text: string, styleSuffix: string, rowData: BlockRowData): HTMLDivElement;
172
+ formatDayCaption(day: string, date: Date): string;
173
+ formatYearCaption(year: string, date: Date): string;
174
+ formatWeekCaption(date: Date): string;
175
+ formatMonthCaption(month: number, date: Date): string;
176
+ getWeekday(dayCounter: number): Weekday;
177
+ prepareTimelineForHourResolution(startDate: Date, endDate: Date): void;
178
+ prepareTimelineForHour(interval: number, startDate: Date, endDate: Date, resBlockRegisterer: IResolutionBlockRegisterer): void;
179
+ prepareTimelineForDayOrWeekResolution(startDate: Date, endDate: Date): void;
180
+ prepareTimelineForDayOrWeek(interval: number, startDate: Date, endDate: Date, resBlockRegisterer: IResolutionBlockRegisterer): void;
181
+ isDayRowVisible(): boolean;
182
+ /**
183
+ * Get actual width of the timeline.
184
+ *
185
+ * @return
186
+ */
187
+ getResolutionWidth(): number;
188
+ /**
189
+ * Calculate the exact width of the timeline. Excludes any spacers in the
190
+ * end.
191
+ *
192
+ * @return
193
+ */
194
+ calculateTimelineWidth(): number;
195
+ private getResolutionDivWidth;
196
+ /**
197
+ * Calculate matching left offset in percentage for a date (
198
+ * {@link Date#getTime()}).
199
+ *
200
+ * @param date
201
+ * Target date in milliseconds.
202
+ * @param contentWidth
203
+ * Width of the content that the given 'date' is relative to.
204
+ * @return Left offset in percentage.
205
+ */
206
+ getLeftPositionPercentageForDate(date: Date, contentWidth: number): number;
207
+ /**
208
+ * Calculate CSS value for 'left' property matching left offset in
209
+ * percentage for a date ( {@link Date#getTime()}).
210
+ * <p>
211
+ * May return '2.123456%' or 'calc(2.123456%)' if IE;
212
+ *
213
+ * @param date
214
+ * Target date in milliseconds.
215
+ * @param contentWidth
216
+ * Width of the content that the given 'date' is relative to.
217
+ * @return Left offset as a String value.
218
+ */
219
+ getLeftPositionPercentageStringForDate(date: Date, contentWidth: number): string;
220
+ getLeftPositionPercentageStringForDateRange(date: Date, rangeWidth: number, rangeStartDate: Date, rangeEndDate: Date): string;
221
+ /**
222
+ * Calculate CSS value for 'width' property matching date interval inside
223
+ * the time-line. Returns percentage value. Interval is in milliseconds.
224
+ * <p>
225
+ * May return '2.123456%' or 'calc(2.123456%)' if IE;
226
+ *
227
+ * @param interval
228
+ * Date interval in milliseconds.
229
+ * @return
230
+ */
231
+ getWidthPercentageStringForDateInterval(interval: number): string;
232
+ /** @see #getWidthPercentageStringForDateInterval(long) */
233
+ getWidthPercentageStringForDateIntervalForRange(interval: number, range: number): string;
234
+ /**
235
+ * Calculate matching left offset in pixels for a date (
236
+ * {@link Date#getTime()}).
237
+ *
238
+ * @param date
239
+ * Target date in milliseconds.
240
+ * @return Left offset in pixels.
241
+ */
242
+ getLeftPositionForDate(date: Date): number;
243
+ getLeftPositionForDateRange(date: Date, rangeWidth: number, rangeStartDate: Date, rangeEndDate: Date): number;
244
+ /**
245
+ * Calculate matching date ({@link Date#getTime()}) for the target left
246
+ * pixel offset.
247
+ *
248
+ * @param left
249
+ * Left offset in pixels.
250
+ * @return Date in a milliseconds or null if timeline width is invalid (<=0).
251
+ */
252
+ getDateForLeftPosition(left: number): Date;
253
+ getDateForLeftPositionNoticeDST(left: number, noticeDST: boolean): Date;
254
+ /**
255
+ * Convert left position for other relative target width.
256
+ *
257
+ * @param left
258
+ * @param contentWidthToConvertFor
259
+ * @return
260
+ */
261
+ convertRelativeLeftPosition(left: number, contentWidthToConvertFor: number): number;
262
+ adjustDateRangeByDST(range: number): number;
263
+ /**
264
+ * Set horizontal scroll position for the time-line.
265
+ *
266
+ * @param left
267
+ * Scroll position in pixels.
268
+ */
269
+ setScrollLeft(left: number): void;
270
+ /**
271
+ * Re-calculates required widths for this widget.
272
+ * <p>
273
+ * Re-creates and fills the visible part of the resolution element.
274
+ */
275
+ updateWidths(): void;
276
+ updateBlockWidths(rowData: BlockRowData): void;
277
+ updateSpacerBlocks(dayWidthPx: number): void;
278
+ hideSpacerBlocks(): void;
279
+ /**
280
+ * Set minimum width (pixels) of this widget's root DIV element. Default is
281
+ * -1. Notice that
282
+ * {@link #update(Resolution, long, long, int, int, LocaleDataProvider)}
283
+ * will calculate min-width and call this internally.
284
+ *
285
+ * @param minWidth
286
+ * Minimum width in pixels.
287
+ */
288
+ setMinWidth(minWidth: number): void;
289
+ /**
290
+ * Returns true if the timeline is overflowing the parent's width. This
291
+ * works only when this widget is attached to some parent.
292
+ *
293
+ * @return True when timeline width is more than the parent's width (@see
294
+ * {@link Element#getClientWidth()}).
295
+ */
296
+ isTimelineOverflowingHorizontally(): boolean;
297
+ /**
298
+ * Update horizontal overflow state.
299
+ */
300
+ updateTimelineOverflowingHorizontally(): void;
301
+ createTimelineElementsOnVisibleArea(): void;
302
+ calculateMinimumResolutionBlockWidth(): number;
303
+ createResolutionBlock(): HTMLDivElement;
304
+ createHourResolutionBlock(): HTMLDivElement;
305
+ createDayResolutionBlock(): HTMLDivElement;
306
+ createWeekResolutionBlock(): HTMLDivElement;
307
+ fillVisibleTimeline(): void;
308
+ showResolutionBlocksOnView(): void;
309
+ showAllResolutionBlocks(): void;
310
+ fillTimelineForResolution(startDate: Date, endDate: Date, left: number): void;
311
+ isFirstResBlockShort(): boolean;
312
+ isLastResBlockShort(): boolean;
313
+ getScrollOverflowForResolutionBlock(positionLeftSnapshot: number, left: number, firstResBlockShort: boolean): number;
314
+ getScrollOverflowForRegularResoultionBlock(positionLeftSnapshot: number, firstResBlockShort: boolean): number;
315
+ getScrollOverflowForShortFirstResolutionBlock(positionLeftSnapshot: number): number;
316
+ /**
317
+ * Returns a width of the first resolution block.
318
+ *
319
+ * @return
320
+ */
321
+ getFirstResolutionElementWidth(): number;
322
+ getFirstResolutionElement(): HTMLElement;
323
+ getLastResolutionElement(): HTMLElement;
324
+ containsResBlockSpacer(): boolean;
325
+ removeResolutionSpacerBlock(): void;
326
+ calculateDayOrHourResolutionBlockWidthPx(blockCount: number): number;
327
+ calculateActualResolutionBlockWidthPx(dayOrHourBlockWidthPx: number): number;
328
+ /**
329
+ * Adjust left position for optimal position to detect accurate date with
330
+ * the current resolution.
331
+ */
332
+ adjustLeftPositionForDateDetection(left: number): number;
333
+ createCalcCssValue(v: number, multiplier: number): string;
334
+ updateResolutionBlockWidths(pct: string): void;
335
+ getWidth(multiplier: number): string;
336
+ setWidth(element: HTMLElement, multiplier: number): void;
337
+ setWidthPct(resBlockWidthPx: number, pct: string, element: HTMLElement): void;
338
+ setCssPercentageWidth(element: HTMLElement, daysInRange: number, width: number, position: number): void;
339
+ getCssPercentageWidth(daysInRange: number, width: number, position: number): string;
340
+ setCssPercentageWidthFor(element: HTMLElement, nValue: number, pct: string): void;
341
+ getPercentageWidthString(nValue: number, pct: string): string;
342
+ getWidthStyleValue(pct: string): string;
343
+ fillTimelineForHourResolution(startDate: Date, endDate: Date, left: number): void;
344
+ fillTimelineForDayResolution(startDate: Date, endDate: Date, left: number): void;
345
+ logIndexOutOfBounds(indexName: string, index: number, childCount: number): void;
346
+ fillTimelineForHour(interval: number, startDate: Date, endDate: Date, resBlockFiller: IResolutionBlockFiller): void;
347
+ fillTimelineForDayOrWeek(interval: number, startDate: Date, endDate: Date, resBlockFiller: IResolutionBlockFiller): void;
348
+ isValidChildIndex(index: number, childCount: number): boolean;
349
+ fillDayResolutionBlock(resBlock: HTMLDivElement, date: Date, index: number, weekend: boolean, left: number): void;
350
+ fillWeekResolutionBlock(resBlock: HTMLDivElement, date: Date, index: number, weekDay: Weekday, firstWeek: boolean, lastBlock: boolean, left: number, even: boolean): void;
351
+ fillHourResolutionBlock(resBlock: HTMLDivElement, date: Date, index: number, hourCounter: number, lastBlock: boolean, left: number, even: boolean): void;
352
+ }