tltv-timeline-element 1.0.24 → 1.0.25
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/README.md +132 -5
- package/custom-elements.json +4147 -0
- package/dist/src/model/DefaultLocaleDataProvider.d.ts +35 -27
- package/dist/src/model/DefaultLocaleDataProvider.d.ts.map +1 -0
- package/dist/src/model/DefaultLocaleDataProvider.js +78 -111
- package/dist/src/model/DefaultLocaleDataProvider.js.map +1 -1
- package/dist/src/model/ILocaleDataProvider.d.ts +71 -62
- package/dist/src/model/ILocaleDataProvider.d.ts.map +1 -0
- package/dist/src/model/ILocaleDataProvider.js +1 -1
- package/dist/src/model/IResolutionBlockFiller.d.ts +5 -4
- package/dist/src/model/IResolutionBlockFiller.d.ts.map +1 -0
- package/dist/src/model/IResolutionBlockFiller.js +1 -1
- package/dist/src/model/IResolutionBlockRegisterer.d.ts +4 -3
- package/dist/src/model/IResolutionBlockRegisterer.d.ts.map +1 -0
- package/dist/src/model/IResolutionBlockRegisterer.js +1 -1
- package/dist/src/model/Resolution.d.ts +8 -7
- package/dist/src/model/Resolution.d.ts.map +1 -0
- package/dist/src/model/Resolution.js +8 -8
- package/dist/src/model/Weekday.d.ts +6 -5
- package/dist/src/model/Weekday.d.ts.map +1 -0
- package/dist/src/model/Weekday.js +6 -6
- package/dist/src/model/blockRowData.d.ts +12 -11
- package/dist/src/model/blockRowData.d.ts.map +1 -0
- package/dist/src/model/blockRowData.js +28 -28
- package/dist/src/timeline-element.d.ts +391 -388
- package/dist/src/timeline-element.d.ts.map +1 -0
- package/dist/src/timeline-element.js +1890 -1894
- package/dist/src/timeline-element.js.map +1 -1
- package/dist/src/util/dateTimeUtil.d.ts +21 -14
- package/dist/src/util/dateTimeUtil.d.ts.map +1 -0
- package/dist/src/util/dateTimeUtil.js +42 -55
- package/dist/src/util/dateTimeUtil.js.map +1 -1
- package/dist/src/util/elementUtil.d.ts +5 -4
- package/dist/src/util/elementUtil.d.ts.map +1 -0
- package/dist/src/util/elementUtil.js +48 -48
- package/dist/src/util/elementUtil.js.map +1 -1
- package/dist/src/util/zonedTime.d.ts +85 -0
- package/dist/src/util/zonedTime.d.ts.map +1 -0
- package/dist/src/util/zonedTime.js +239 -0
- package/dist/src/util/zonedTime.js.map +1 -0
- package/package.json +49 -21
- package/src/model/DefaultLocaleDataProvider.ts +32 -66
- package/src/model/ILocaleDataProvider.ts +10 -2
- package/src/model/IResolutionBlockFiller.ts +1 -1
- package/src/model/IResolutionBlockRegisterer.ts +1 -1
- package/src/timeline-element.ts +202 -205
- package/src/util/dateTimeUtil.ts +16 -29
- package/src/util/elementUtil.ts +4 -4
- package/src/util/zonedTime.ts +280 -0
- package/server.js +0 -18
- package/src/index.html +0 -112
- package/tsconfig.json +0 -15
- package/webpack.config.js +0 -33
package/README.md
CHANGED
|
@@ -1,9 +1,126 @@
|
|
|
1
|
-
|
|
1
|
+
# timeline-element
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`<timeline-element>` is a scalable, time zone aware timeline header web
|
|
4
|
+
component built with [Lit](https://lit.dev). It renders a date range as rows of
|
|
5
|
+
year, month and day blocks above a resolution row of hours, days, weeks, months
|
|
6
|
+
or years, and provides an API for converting between dates and horizontal
|
|
7
|
+
positions. That makes it a foundation for scheduling views such as Gantt charts
|
|
8
|
+
([tltv-gantt-element](https://github.com/tltv/gantt-element) is built on it).
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Five resolutions:** `Hour`, `Day`, `Week`, `Month` and `Year`.
|
|
13
|
+
- **Time zone aware:** dates, weekdays, week numbers and the current-date highlight
|
|
14
|
+
are calculated in the configured IANA time zone, independent of the browser's
|
|
15
|
+
own zone. Daylight saving time switches (23 and 25 hour days, repeated or
|
|
16
|
+
skipped hours) are handled correctly.
|
|
17
|
+
- **Scales to fit:** the timeline stretches to fill its container, and switches
|
|
18
|
+
to minimum-width blocks with horizontal scrolling when the range doesn't fit.
|
|
19
|
+
Only the visible blocks are rendered while scrolling.
|
|
20
|
+
- **Positioning API:** convert dates to pixel or percentage positions and widths,
|
|
21
|
+
and pixel positions back to dates, for placing content on the timeline.
|
|
22
|
+
- **Current date highlight**, weekend highlighting, 12/24 hour clock and a
|
|
23
|
+
configurable first day of the week.
|
|
24
|
+
- **Themeable** with CSS custom properties.
|
|
25
|
+
- **No runtime dependencies besides Lit**; date and time zone handling uses the
|
|
26
|
+
native `Intl` API.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install tltv-timeline-element
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import 'tltv-timeline-element'; // registers <timeline-element>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<timeline-element
|
|
42
|
+
resolution="Day"
|
|
43
|
+
startdatetime="2020-04-01"
|
|
44
|
+
enddatetime="2020-06-30"
|
|
45
|
+
timezone="Europe/Helsinki"
|
|
46
|
+
currentdatevisible>
|
|
47
|
+
</timeline-element>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The package is published as ES modules with TypeScript declarations. Individual
|
|
51
|
+
modules such as `tltv-timeline-element/dist/src/model/Resolution.js` can also be
|
|
52
|
+
imported directly.
|
|
53
|
+
|
|
54
|
+
### Attributes
|
|
55
|
+
|
|
56
|
+
| Attribute | Property | Description |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `resolution` | `resolution` | `Hour`, `Day` (default), `Week`, `Month` or `Year`. |
|
|
59
|
+
| `startdatetime` | `startDateTime` | Inclusive start, e.g. `2020-04-01`, or `2020-04-01T08` for `Hour`. |
|
|
60
|
+
| `enddatetime` | `endDateTime` | Inclusive end, same format as the start. |
|
|
61
|
+
| `timezone` | `timeZone` | IANA time zone. Default `Europe/London`. |
|
|
62
|
+
| `locale` | `locale` | Locale for time formatting. Default `en-US`. |
|
|
63
|
+
| `firstdayofweek` | `firstDayOfWeek` | First day of the week, `1` (Sunday, default) to `7` (Saturday). |
|
|
64
|
+
| `twelvehourclock` | `twelveHourClock` | Show hours in 12 hour format. |
|
|
65
|
+
| `currentdatevisible` | `currentDateVisible` | Highlight the current hour, day, week, month or year. |
|
|
66
|
+
| `scrollcontainerid` | `scrollContainerId` | Id of the element whose horizontal scrolling the timeline follows. Defaults to the parent element. |
|
|
67
|
+
| | `yearRowVisible`, `monthRowVisible` | Show or hide the year and month header rows. |
|
|
68
|
+
| | `monthNames` | Custom month names, January first. |
|
|
69
|
+
|
|
70
|
+
### Positioning API
|
|
71
|
+
|
|
72
|
+
| Method | Returns |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `getLeftPositionForDate(date)` | Left offset of a date in pixels. |
|
|
75
|
+
| `getLeftPositionPercentageStringForDate(date, contentWidth)` | Left offset as a CSS percentage, relative to a content area of the given width. |
|
|
76
|
+
| `getLeftPositionPercentageStringForDateRange(date, rangeWidth, rangeStart, rangeEnd)` | Left offset as a CSS percentage within a nested date range. |
|
|
77
|
+
| `getWidthPercentageStringForDateInterval(interval)` | Width of a time interval (ms) as a CSS percentage of the timeline. |
|
|
78
|
+
| `getWidthPercentageStringForDateIntervalForRange(interval, range)` | Width of an interval as a CSS percentage of another range (ms). |
|
|
79
|
+
| `getDateForLeftPosition(left)` | Date at a pixel offset, e.g. for click and drag handling. |
|
|
80
|
+
| `getResolutionWidth()`, `isTimelineOverflowingHorizontally()` | Current timeline width and overflow state. |
|
|
81
|
+
| `refreshCurrentDate()` | Moves the current-date highlight without rebuilding the timeline. |
|
|
82
|
+
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
npm install
|
|
87
|
+
npm start # Vite dev server with the demo page (index.html)
|
|
88
|
+
npm run build # compile to dist/src (ES modules + type declarations) and generate custom-elements.json
|
|
89
|
+
npm run watch # recompile on change
|
|
90
|
+
npm run lint # ESLint (TypeScript, Lit and web component rules)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`dist/` and `custom-elements.json` are build output and are not committed;
|
|
94
|
+
`npm pack` and `npm publish` build them automatically (`prepack`).
|
|
95
|
+
|
|
96
|
+
The [Custom Elements Manifest](https://custom-elements-manifest.open-wc.org/)
|
|
97
|
+
(`custom-elements.json`) describes the element's attributes, properties,
|
|
98
|
+
methods and CSS custom properties for IDEs and documentation tools.
|
|
99
|
+
|
|
100
|
+
## Continuous integration
|
|
101
|
+
|
|
102
|
+
The CI workflow (`.github/workflows/ci.yml`) runs lint, build and the tests on
|
|
103
|
+
every pull request.
|
|
104
|
+
|
|
105
|
+
## Testing
|
|
106
|
+
|
|
107
|
+
Tests run with [Vitest](https://vitest.dev) browser mode in real browsers (the
|
|
108
|
+
timeline measures layout, which jsdom can't do).
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
npm run test:install-browsers # once: downloads Chromium, Firefox and WebKit
|
|
112
|
+
npm test # full matrix
|
|
113
|
+
npm run test:quick # Chromium in one time zone
|
|
114
|
+
npm run test:watch # watch mode
|
|
115
|
+
npm run test:visual # visible browser, pauses 1s after each render
|
|
116
|
+
npm run test:typecheck # type-check tests
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Every test runs in Chromium under several *browser* time zones (UTC,
|
|
120
|
+
Europe/Helsinki, America/New_York, Australia/Sydney, Asia/Kolkata), and once in
|
|
121
|
+
Firefox and WebKit, because parts of the date logic depend on the browser's
|
|
122
|
+
time zone. See `vitest.config.mts`. Tests marked `test.fails` document known
|
|
123
|
+
bugs; they start failing (and must be flipped) once the bug is fixed.
|
|
7
124
|
|
|
8
125
|
## Resolutions
|
|
9
126
|
|
|
@@ -37,4 +154,14 @@ customized with the following CSS custom properties (defaults in parentheses):
|
|
|
37
154
|
| `--timeline-col-background-color` (`#ddd`) | Background of resolution blocks. |
|
|
38
155
|
| `--timeline-col-even-background-color` (`#ccc`) | Background of even resolution blocks. |
|
|
39
156
|
| `--timeline-col-weekend` (`#ccc`) | Background of weekend resolution blocks. |
|
|
40
|
-
| `--timeline-col-font-size` (`10px`) | Font size of resolution blocks. |
|
|
157
|
+
| `--timeline-col-font-size` (`10px`) | Font size of resolution blocks. |
|
|
158
|
+
| `--timeline-col-current` (`#ffe082`) | Background of the current-date highlight. |
|
|
159
|
+
|
|
160
|
+
## Background
|
|
161
|
+
|
|
162
|
+
The component originates from the timeline widget of the Gantt add-on for
|
|
163
|
+
Vaadin Framework 8 (GWT), rewritten as a standalone web component.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
[MIT](LICENSE)
|