@molecule/app-day-timeline-angular 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +435 -2
- package/dist/day-timeline.component.d.ts +219 -0
- package/dist/day-timeline.component.d.ts.map +1 -0
- package/dist/day-timeline.component.js +568 -0
- package/dist/day-timeline.component.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +74 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,436 @@
|
|
|
1
|
-
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-11-18T20:20:29.713Z
|
|
7
|
+
-->
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
# @molecule/app-day-timeline-angular
|
|
10
|
+
|
|
11
|
+
Angular vertical 24h day-of-events timeline — itinerary planner, daily
|
|
12
|
+
agenda, schedule view. Events are absolutely positioned by start/end hour
|
|
13
|
+
and scaled by `pxPerHour` (total height = (endHour - startHour) * pxPerHour).
|
|
14
|
+
|
|
15
|
+
Exports `<div mol-day-timeline>` and `formatHour` — the Angular counterpart
|
|
16
|
+
of `@molecule/app-day-timeline-react`, with the same props (React names) and
|
|
17
|
+
the same DOM for the same input.
|
|
18
|
+
|
|
19
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
20
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
21
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { Component } from '@angular/core'
|
|
27
|
+
import { DayTimeline } from '@molecule/app-day-timeline-angular'
|
|
28
|
+
|
|
29
|
+
@Component({
|
|
30
|
+
selector: 'app-trip-day',
|
|
31
|
+
standalone: true,
|
|
32
|
+
imports: [DayTimeline],
|
|
33
|
+
template: `<div mol-day-timeline [startHour]="7" [endHour]="22" [events]="events"></div>`,
|
|
34
|
+
})
|
|
35
|
+
export class TripDay {
|
|
36
|
+
events = [
|
|
37
|
+
{ id: 'flight', title: 'Flight to LAX', startHour: 13, endHour: 16 },
|
|
38
|
+
{ id: 'dinner', title: 'Dinner', startHour: 19, endHour: 20.5 },
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Type
|
|
44
|
+
|
|
45
|
+
`feature`
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install @molecule/app-day-timeline-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-i18n @molecule/app-ui @molecule/app-ui-angular
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
### Interfaces
|
|
56
|
+
|
|
57
|
+
#### `DayTimelineEvent`
|
|
58
|
+
|
|
59
|
+
A single event positioned on the day axis.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
interface DayTimelineEvent {
|
|
63
|
+
/** Stable id (used as the render key + `data-event-id`). */
|
|
64
|
+
id: string
|
|
65
|
+
/** Event title: a template reference (a node), or text. */
|
|
66
|
+
title: string | number | TemplateRef<unknown>
|
|
67
|
+
/** Optional secondary line (location, type, etc.): a template reference, or text. */
|
|
68
|
+
subtitle?: string | number | TemplateRef<unknown>
|
|
69
|
+
/** Start hour in fractional 24h (e.g. `9.5` = 9:30 AM). */
|
|
70
|
+
startHour: number
|
|
71
|
+
/** End hour in fractional 24h. Must be > `startHour`. */
|
|
72
|
+
endHour: number
|
|
73
|
+
/** Optional accent color (CSS color value). */
|
|
74
|
+
accentColor?: string
|
|
75
|
+
/** Optional click handler. */
|
|
76
|
+
onClick?: () => void
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### `DayTimelineProps`
|
|
81
|
+
|
|
82
|
+
Props accepted by {@link DayTimeline} — the same props
|
|
83
|
+
`@molecule/app-day-timeline-react` accepts. Node-valued event fields
|
|
84
|
+
(`title`, `subtitle`) are template references in Angular (an input cannot
|
|
85
|
+
carry a node), or plain text.
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
interface DayTimelineProps {
|
|
89
|
+
/** Events to render on the timeline. */
|
|
90
|
+
events: DayTimelineEvent[]
|
|
91
|
+
/** First hour rendered (inclusive). Defaults to `0`. */
|
|
92
|
+
startHour?: number
|
|
93
|
+
/** Last hour rendered (exclusive). Defaults to `24`. */
|
|
94
|
+
endHour?: number
|
|
95
|
+
/**
|
|
96
|
+
* Pixel height per hour. Drives the overall axis size: total height =
|
|
97
|
+
* `(endHour - startHour) * pxPerHour`. Defaults to `60`.
|
|
98
|
+
*/
|
|
99
|
+
pxPerHour?: number
|
|
100
|
+
/**
|
|
101
|
+
* Whether to render the axis tick labels (e.g. "9 AM"). Defaults to
|
|
102
|
+
* `true`.
|
|
103
|
+
*/
|
|
104
|
+
showAxisLabels?: boolean
|
|
105
|
+
/** `data-mol-id` attribute for AI-agent selectors. */
|
|
106
|
+
dataMolId?: string
|
|
107
|
+
/** Extra classes appended via the ClassMap `cn()` helper. */
|
|
108
|
+
className?: string
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Classes
|
|
113
|
+
|
|
114
|
+
#### `DayTimeline`
|
|
115
|
+
|
|
116
|
+
DayTimeline component.
|
|
117
|
+
|
|
118
|
+
Vertical 24h day-of-events timeline. The host IS the root `<div>`
|
|
119
|
+
(`div[mol-day-timeline]`), matching React's root exactly: `role="list"` +
|
|
120
|
+
the accessible label on the host, the hour axis, the rail with its
|
|
121
|
+
gridlines and one absolutely-positioned card per event. Node-valued event
|
|
122
|
+
fields (`title`, `subtitle`) are `ng-template` references rendered through
|
|
123
|
+
{@link NgTemplateOutlet}; string / number fields render as text.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
@Component({
|
|
127
|
+
selector: 'div[mol-day-timeline]',
|
|
128
|
+
standalone: true,
|
|
129
|
+
imports: [NgTemplateOutlet],
|
|
130
|
+
inputs: [
|
|
131
|
+
'events',
|
|
132
|
+
'startHour',
|
|
133
|
+
'endHour',
|
|
134
|
+
'pxPerHour',
|
|
135
|
+
'showAxisLabels',
|
|
136
|
+
'dataMolId',
|
|
137
|
+
'className',
|
|
138
|
+
],
|
|
139
|
+
host: {
|
|
140
|
+
role: 'list',
|
|
141
|
+
'[class]': 'classes()',
|
|
142
|
+
'[attr.data-mol-id]': "dataMolId ?? 'day-timeline'",
|
|
143
|
+
'[attr.aria-label]': 'groupLabel()',
|
|
144
|
+
'[style]': 'wrapperStyle()',
|
|
145
|
+
},
|
|
146
|
+
// prettier-ignore
|
|
147
|
+
template: `
|
|
148
|
+
@if (showAxis()) {
|
|
149
|
+
<div aria-hidden="true" [style]="axisStyle()">
|
|
150
|
+
@for (hour of ticks(); track hour) {
|
|
151
|
+
<div [attr.data-axis-tick]="hour" [class]="tickClasses()" [style]="tickStyle(hour)">{{ tickLabel(hour) }}</div>
|
|
152
|
+
}
|
|
153
|
+
</div>
|
|
154
|
+
}
|
|
155
|
+
<div data-mol-id="day-timeline-rail" [class]="railClasses()" [style]="railStyle()">
|
|
156
|
+
@for (hour of ticks(); track hour) {
|
|
157
|
+
<div aria-hidden="true" [class]="gridlineClasses()" [style]="gridlineStyle(hour)"></div>
|
|
158
|
+
}
|
|
159
|
+
@for (event of events; track event.id) {
|
|
160
|
+
<div role="listitem" [attr.data-event-id]="event.id" data-mol-id="day-timeline-event" [attr.aria-label]="eventAria(event)" [class]="eventCardClasses(event)" [style]="cardStyle(event)">
|
|
161
|
+
@if (event.onClick) {
|
|
162
|
+
<button type="button" data-mol-id="day-timeline-event-action" [attr.aria-label]="eventAria(event)" (click)="handleClick(event, $event)" [style]="contentStyle(event)">
|
|
163
|
+
<div [class]="titleClasses()">@if (isTemplate(event.title)) {<ng-container [ngTemplateOutlet]="templateOf(event.title)"></ng-container>}@else {{{ textOf(event.title) }}}</div>
|
|
164
|
+
@if (event.subtitle) {
|
|
165
|
+
<div [class]="subtitleClasses(event)">@if (isTemplate(event.subtitle)) {<ng-container [ngTemplateOutlet]="templateOf(event.subtitle)"></ng-container>}@else {{{ textOf(event.subtitle) }}}</div>
|
|
166
|
+
}
|
|
167
|
+
</button>
|
|
168
|
+
} @else {
|
|
169
|
+
<div [style]="contentStyle(event)">
|
|
170
|
+
<div [class]="titleClasses()">@if (isTemplate(event.title)) {<ng-container [ngTemplateOutlet]="templateOf(event.title)"></ng-container>}@else {{{ textOf(event.title) }}}</div>
|
|
171
|
+
@if (event.subtitle) {
|
|
172
|
+
<div [class]="subtitleClasses(event)">@if (isTemplate(event.subtitle)) {<ng-container [ngTemplateOutlet]="templateOf(event.subtitle)"></ng-container>}@else {{{ textOf(event.subtitle) }}}</div>
|
|
173
|
+
}
|
|
174
|
+
</div>
|
|
175
|
+
}
|
|
176
|
+
</div>
|
|
177
|
+
}
|
|
178
|
+
</div>
|
|
179
|
+
`,
|
|
180
|
+
})
|
|
181
|
+
export class DayTimeline {
|
|
182
|
+
/** Events to render on the timeline. */
|
|
183
|
+
events: DayTimelineEvent[] = []
|
|
184
|
+
startHour?: number
|
|
185
|
+
/** Last hour rendered (exclusive; defaults to `24` at read time). */
|
|
186
|
+
endHour?: number
|
|
187
|
+
/** Pixel height per hour (defaults to `60` at read time). */
|
|
188
|
+
pxPerHour?: number
|
|
189
|
+
showAxisLabels?: boolean
|
|
190
|
+
/** `data-mol-id` attribute for AI-agent selectors. */
|
|
191
|
+
dataMolId?: string
|
|
192
|
+
/** Extra classes appended via the ClassMap `cn()` helper. */
|
|
193
|
+
className?: string
|
|
194
|
+
|
|
195
|
+
private readonly i18n = useTranslation()
|
|
196
|
+
|
|
197
|
+
/** The current class map. */
|
|
198
|
+
cm(): UIClassMap {
|
|
199
|
+
return getClassMap()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
showAxis(): boolean {
|
|
203
|
+
return this.showAxisLabels ?? true
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
safeStart(): number {
|
|
207
|
+
return Math.max(0, Math.min(24, this.startHour ?? 0))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
safeEnd(): number {
|
|
211
|
+
return Math.max(this.safeStart() + 1, Math.min(24, this.endHour ?? 24))
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** The pixel height of one hour (React's `pxPerHour = 60`). */
|
|
215
|
+
hourHeight(): number {
|
|
216
|
+
return this.pxPerHour ?? 60
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** The axis' total height. */
|
|
220
|
+
totalHeight(): number {
|
|
221
|
+
return (this.safeEnd() - this.safeStart()) * this.hourHeight()
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
ticks(): number[] {
|
|
225
|
+
const hours: number[] = []
|
|
226
|
+
for (let hour = Math.ceil(this.safeStart()); hour < this.safeEnd(); hour += 1) hours.push(hour)
|
|
227
|
+
return hours
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The wrapper's class list. */
|
|
231
|
+
classes(): string {
|
|
232
|
+
return this.cm().cn(this.className)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The root's accessible label. */
|
|
236
|
+
groupLabel(): string {
|
|
237
|
+
return this.i18n.t('dayTimeline.group', {}, { defaultValue: 'Day timeline' })
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
wrapperStyle(): string {
|
|
241
|
+
const columns = this.showAxis() ? '64px 1fr' : '1fr'
|
|
242
|
+
return `position: relative; display: grid; grid-template-columns: ${columns}; min-height: ${this.totalHeight()}px`
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** The axis column's inline style. */
|
|
246
|
+
axisStyle(): string {
|
|
247
|
+
return `position: relative; height: ${this.totalHeight()}px`
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
railStyle(): string {
|
|
251
|
+
return `position: relative; height: ${this.totalHeight()}px`
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
railClasses(): string {
|
|
255
|
+
return this.showAxis() ? this.cm().borderL : ''
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** A tick label's class list (the small text recipe, muted). */
|
|
259
|
+
tickClasses(): string {
|
|
260
|
+
const cm = this.cm()
|
|
261
|
+
return cm.cn(cm.textSize('xs'), cm.textMuted)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** A tick label's inline style. */
|
|
265
|
+
tickStyle(hour: number): string {
|
|
266
|
+
const top = (hour - this.safeStart()) * this.hourHeight()
|
|
267
|
+
return `position: absolute; top: ${top}px; right: 8px; transform: translateY(-50%)`
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The text a tick label shows. */
|
|
271
|
+
tickLabel(hour: number): string {
|
|
272
|
+
return formatHour(hour)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
gridlineClasses(): string {
|
|
276
|
+
return this.cm().bgBorder
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** One gridline's inline style. */
|
|
280
|
+
gridlineStyle(hour: number): string {
|
|
281
|
+
const top = (hour - this.safeStart()) * this.hourHeight()
|
|
282
|
+
return `position: absolute; top: ${top}px; left: 0px; right: 0px; height: 1px`
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
eventCardClasses(event: DayTimelineEvent): string {
|
|
286
|
+
const cm = this.cm()
|
|
287
|
+
return cm.cn(cm.accentCard({ tone: this.cardTone(event) }), cm.surfaceSecondary)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
cardTone(event: DayTimelineEvent): 'custom' | 'primary' {
|
|
291
|
+
return event.accentColor ? 'custom' : 'primary'
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** The event title's class list. */
|
|
295
|
+
titleClasses(): string {
|
|
296
|
+
const cm = this.cm()
|
|
297
|
+
return cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
subtitleClasses(event: DayTimelineEvent): string {
|
|
301
|
+
return this.cm().accentCardLabel({ tone: this.cardTone(event) })
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
safeEndOf(event: DayTimelineEvent): number {
|
|
305
|
+
return Math.max(event.endHour, event.startHour + 0.25)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
cardStyle(event: DayTimelineEvent): string {
|
|
309
|
+
const top = (event.startHour - this.safeStart()) * this.hourHeight()
|
|
310
|
+
const height = Math.max(20, (this.safeEndOf(event) - event.startHour) * this.hourHeight())
|
|
311
|
+
return [
|
|
312
|
+
'position: absolute',
|
|
313
|
+
`top: ${top}px`,
|
|
314
|
+
'left: 6px',
|
|
315
|
+
'right: 6px',
|
|
316
|
+
`height: ${height}px`,
|
|
317
|
+
'border-radius: 6px',
|
|
318
|
+
'overflow: hidden',
|
|
319
|
+
// The event's accent color drives an inset bar, not a border-left.
|
|
320
|
+
// Without it the bar is the brand primary, through the recipe's
|
|
321
|
+
// `primary` tone.
|
|
322
|
+
...(event.accentColor ? [`--mol-accent: ${event.accentColor}`] : []),
|
|
323
|
+
].join('; ')
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
contentStyle(event: DayTimelineEvent): string {
|
|
327
|
+
const parts = [
|
|
328
|
+
'position: absolute',
|
|
329
|
+
'inset: 0px',
|
|
330
|
+
'padding: 0.4rem 0.6rem 0.4rem 30px',
|
|
331
|
+
'font: inherit',
|
|
332
|
+
'color: inherit',
|
|
333
|
+
'text-align: left',
|
|
334
|
+
]
|
|
335
|
+
if (event.onClick) parts.push('cursor: pointer', 'background: transparent')
|
|
336
|
+
return parts.join('; ')
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
eventAria(event: DayTimelineEvent): string {
|
|
340
|
+
return this.i18n.t(
|
|
341
|
+
'dayTimeline.event',
|
|
342
|
+
{
|
|
343
|
+
title: typeof event.title === 'string' ? event.title : '',
|
|
344
|
+
start: formatHour(event.startHour),
|
|
345
|
+
end: formatHour(this.safeEndOf(event)),
|
|
346
|
+
},
|
|
347
|
+
{ defaultValue: '{{title}} from {{start}} to {{end}}' },
|
|
348
|
+
)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
handleClick(event: DayTimelineEvent, native: Event): void {
|
|
352
|
+
const onClick: ((click: Event) => void) | undefined = event.onClick
|
|
353
|
+
onClick?.(native)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
isTemplate(value: unknown): value is TemplateRef<unknown> {
|
|
357
|
+
return value instanceof TemplateRef
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Narrows a value to an embedded template. */
|
|
361
|
+
templateOf(value: unknown): TemplateRef<unknown> | null {
|
|
362
|
+
return value instanceof TemplateRef ? value : null
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
textOf(value: unknown): string {
|
|
366
|
+
return typeof value === 'string' || typeof value === 'number' ? String(value) : ''
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
_(Member comments are shortened to their first sentence, and the 21 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-day-timeline-angular/dist/day-timeline.component.d.ts`.)_
|
|
372
|
+
|
|
373
|
+
### Functions
|
|
374
|
+
|
|
375
|
+
#### `formatHour(hour)`
|
|
376
|
+
|
|
377
|
+
Format a fractional 24h hour as `H AM/PM` (e.g. `9.5` → `9:30 AM`).
|
|
378
|
+
|
|
379
|
+
```typescript
|
|
380
|
+
function formatHour(hour: number): string
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
- `hour` — Fractional 24h hour value.
|
|
384
|
+
|
|
385
|
+
**Returns:** A short clock-style label.
|
|
386
|
+
|
|
387
|
+
## Injection Notes
|
|
388
|
+
|
|
389
|
+
### Requirements
|
|
390
|
+
|
|
391
|
+
Peer dependencies:
|
|
392
|
+
|
|
393
|
+
- `@angular/common` ^22.0.0
|
|
394
|
+
- `@angular/core` ^22.0.0
|
|
395
|
+
- `@angular/platform-browser` ^22.0.0
|
|
396
|
+
- `@molecule/app-angular` ^3.5.0
|
|
397
|
+
- `@molecule/app-i18n` ^1.0.1
|
|
398
|
+
- `@molecule/app-ui` ^1.3.11
|
|
399
|
+
- `@molecule/app-ui-angular` ^1.1.0
|
|
400
|
+
|
|
401
|
+
### Runtime Dependencies
|
|
402
|
+
|
|
403
|
+
- `@angular/common`
|
|
404
|
+
- `@angular/core`
|
|
405
|
+
- `@angular/platform-browser`
|
|
406
|
+
- `@molecule/app-angular`
|
|
407
|
+
- `@molecule/app-i18n`
|
|
408
|
+
- `@molecule/app-ui`
|
|
409
|
+
- `@molecule/app-ui-angular`
|
|
410
|
+
|
|
411
|
+
- **No overlap/lane layout.** Events are absolutely positioned across the
|
|
412
|
+
full rail width, so events with overlapping time ranges render stacked
|
|
413
|
+
on top of each other. If your data can contain concurrent events,
|
|
414
|
+
partition them into separate `<DayTimeline>` columns (one per lane or
|
|
415
|
+
resource) before rendering — the component does not de-conflict.
|
|
416
|
+
- Bounds are clamped: `startHour` to [0, 24], `endHour` to at least
|
|
417
|
+
`startHour + 1`; an event shorter than 15 minutes still renders at a
|
|
418
|
+
20px minimum height so it stays clickable.
|
|
419
|
+
- Axis tick labels are formatted by the exported `formatHour()`, which
|
|
420
|
+
uses English 12-hour "AM/PM" notation. There is currently no prop to
|
|
421
|
+
localize tick formatting — hide them with `[showAxisLabels]="false"` and
|
|
422
|
+
render your own axis if you need 24h or localized labels.
|
|
423
|
+
- Aria labels resolve through `t()` with English fallbacks; the companion
|
|
424
|
+
locale bond is `@molecule/app-locales-day-timeline`. Requires the app's
|
|
425
|
+
i18n provider (`useTranslation()` throws without one) and a wired
|
|
426
|
+
ClassMap bond (standard molecule app setup).
|
|
427
|
+
- Events with an `onClick` render their content inside a native `<button>`
|
|
428
|
+
(Enter and Space activate it); events without one are not focusable.
|
|
429
|
+
- Node-valued event fields (`title`, `subtitle`) are `ng-template`
|
|
430
|
+
references or plain text, as React's `ReactNode` fields are.
|
|
431
|
+
- Events are tracked by `id` (`@for (… ; track event.id)`), so a re-passed
|
|
432
|
+
or re-ordered list keeps each card's DOM the way React's `key` does.
|
|
433
|
+
|
|
434
|
+
## Translations
|
|
435
|
+
|
|
436
|
+
Translation strings are provided by `@molecule/app-locales-day-timeline`.
|