tltv-timeline-element 1.0.17 → 1.0.18

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