@f-ewald/components 1.27.2 → 1.27.3
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/custom-elements.json +83 -3
- package/dist/calendar-day.d.ts +21 -0
- package/dist/calendar-day.d.ts.map +1 -1
- package/dist/calendar-day.js +131 -9
- package/dist/calendar-day.js.map +1 -1
- package/dist/calendar-entry.d.ts +1 -0
- package/dist/calendar-entry.d.ts.map +1 -1
- package/dist/calendar-entry.js +2 -1
- package/dist/calendar-entry.js.map +1 -1
- package/dist/calendar-month.d.ts +3 -3
- package/dist/calendar-month.d.ts.map +1 -1
- package/dist/calendar-month.js +40 -7
- package/dist/calendar-month.js.map +1 -1
- package/dist/calendar-week.d.ts.map +1 -1
- package/dist/calendar-week.js +30 -3
- package/dist/calendar-week.js.map +1 -1
- package/dist/utils/calendar.d.ts +1 -0
- package/dist/utils/calendar.d.ts.map +1 -1
- package/dist/utils/calendar.js +2 -0
- package/dist/utils/calendar.js.map +1 -1
- package/docs/calendar-day.md +7 -1
- package/docs/calendar-entry.md +2 -0
- package/docs/calendar-month.md +3 -0
- package/docs/calendar-week.md +5 -1
- package/llms.txt +12 -5
- package/package.json +1 -1
package/custom-elements.json
CHANGED
|
@@ -2688,6 +2688,64 @@
|
|
|
2688
2688
|
"attribute": "date",
|
|
2689
2689
|
"reflects": true
|
|
2690
2690
|
},
|
|
2691
|
+
{
|
|
2692
|
+
"kind": "field",
|
|
2693
|
+
"name": "timeMarker",
|
|
2694
|
+
"type": {
|
|
2695
|
+
"text": "boolean"
|
|
2696
|
+
},
|
|
2697
|
+
"default": "false",
|
|
2698
|
+
"description": "Shows a fine live line marking the current time, Google-Calendar-style. Only rendered when `date` is today.",
|
|
2699
|
+
"attribute": "time-marker",
|
|
2700
|
+
"reflects": true
|
|
2701
|
+
},
|
|
2702
|
+
{
|
|
2703
|
+
"kind": "field",
|
|
2704
|
+
"name": "minWidth",
|
|
2705
|
+
"type": {
|
|
2706
|
+
"text": "string"
|
|
2707
|
+
},
|
|
2708
|
+
"default": "\"\"",
|
|
2709
|
+
"description": "Minimum width for the day column, as a CSS length (e.g. `\"18rem\"`).\nUnset leaves the host's width fully controlled by its container —\nuseful as the sizing floor when placing several `calendar-day`\nelements in a scrollable row.",
|
|
2710
|
+
"attribute": "min-width",
|
|
2711
|
+
"reflects": true
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
"kind": "field",
|
|
2715
|
+
"name": "_now",
|
|
2716
|
+
"privacy": "private"
|
|
2717
|
+
},
|
|
2718
|
+
{
|
|
2719
|
+
"kind": "field",
|
|
2720
|
+
"name": "_nowTimer",
|
|
2721
|
+
"type": {
|
|
2722
|
+
"text": "ReturnType<typeof setInterval> | null"
|
|
2723
|
+
},
|
|
2724
|
+
"privacy": "private",
|
|
2725
|
+
"default": "null"
|
|
2726
|
+
},
|
|
2727
|
+
{
|
|
2728
|
+
"kind": "method",
|
|
2729
|
+
"name": "_syncNowTimer",
|
|
2730
|
+
"privacy": "private",
|
|
2731
|
+
"return": {
|
|
2732
|
+
"type": {
|
|
2733
|
+
"text": "void"
|
|
2734
|
+
}
|
|
2735
|
+
},
|
|
2736
|
+
"description": "Ensures a 60s current-time ticker is running only while `timeMarker` is enabled."
|
|
2737
|
+
},
|
|
2738
|
+
{
|
|
2739
|
+
"kind": "method",
|
|
2740
|
+
"name": "_syncMinWidth",
|
|
2741
|
+
"privacy": "private",
|
|
2742
|
+
"return": {
|
|
2743
|
+
"type": {
|
|
2744
|
+
"text": "void"
|
|
2745
|
+
}
|
|
2746
|
+
},
|
|
2747
|
+
"description": "Reflects `minWidth` onto the `--calendar-day-min-width` custom property the host's own styles read."
|
|
2748
|
+
},
|
|
2691
2749
|
{
|
|
2692
2750
|
"kind": "method",
|
|
2693
2751
|
"name": "_renderAllDayLane",
|
|
@@ -2929,6 +2987,24 @@
|
|
|
2929
2987
|
},
|
|
2930
2988
|
"description": "The day shown, `\"YYYY-MM-DD\"`.",
|
|
2931
2989
|
"fieldName": "date"
|
|
2990
|
+
},
|
|
2991
|
+
{
|
|
2992
|
+
"name": "time-marker",
|
|
2993
|
+
"type": {
|
|
2994
|
+
"text": "boolean"
|
|
2995
|
+
},
|
|
2996
|
+
"default": "false",
|
|
2997
|
+
"description": "Shows a fine live line marking the current time, Google-Calendar-style. Only rendered when `date` is today.",
|
|
2998
|
+
"fieldName": "timeMarker"
|
|
2999
|
+
},
|
|
3000
|
+
{
|
|
3001
|
+
"name": "min-width",
|
|
3002
|
+
"type": {
|
|
3003
|
+
"text": "string"
|
|
3004
|
+
},
|
|
3005
|
+
"default": "\"\"",
|
|
3006
|
+
"description": "Minimum width for the day column, as a CSS length (e.g. `\"18rem\"`).\nUnset leaves the host's width fully controlled by its container —\nuseful as the sizing floor when placing several `calendar-day`\nelements in a scrollable row.",
|
|
3007
|
+
"fieldName": "minWidth"
|
|
2932
3008
|
}
|
|
2933
3009
|
],
|
|
2934
3010
|
"superclass": {
|
|
@@ -2978,6 +3054,10 @@
|
|
|
2978
3054
|
{
|
|
2979
3055
|
"description": "Plain-text ending note pinned to the bottom of the shared body.",
|
|
2980
3056
|
"name": "footer"
|
|
3057
|
+
},
|
|
3058
|
+
{
|
|
3059
|
+
"description": "Plain-text location, shown on its own line with a leading marker icon.",
|
|
3060
|
+
"name": "location"
|
|
2981
3061
|
}
|
|
2982
3062
|
],
|
|
2983
3063
|
"members": [
|
|
@@ -3347,7 +3427,7 @@
|
|
|
3347
3427
|
}
|
|
3348
3428
|
}
|
|
3349
3429
|
],
|
|
3350
|
-
"description": "Joins the event title, details, and visible footer for tooltips and accessible link names."
|
|
3430
|
+
"description": "Joins the event title, location, details, and visible footer for tooltips and accessible link names."
|
|
3351
3431
|
},
|
|
3352
3432
|
{
|
|
3353
3433
|
"kind": "method",
|
|
@@ -3377,7 +3457,7 @@
|
|
|
3377
3457
|
"default": "false"
|
|
3378
3458
|
}
|
|
3379
3459
|
],
|
|
3380
|
-
"description": "Renders the shared details body, with the footer reserved at
|
|
3460
|
+
"description": "Renders the shared details body, with the location pinned at the top and the footer reserved at the bottom."
|
|
3381
3461
|
},
|
|
3382
3462
|
{
|
|
3383
3463
|
"kind": "method",
|
|
@@ -3407,7 +3487,7 @@
|
|
|
3407
3487
|
"default": "false"
|
|
3408
3488
|
}
|
|
3409
3489
|
],
|
|
3410
|
-
"description": "Renders a row-spanning body cell with whole-line detail and footer budgets."
|
|
3490
|
+
"description": "Renders a row-spanning body cell with whole-line location, detail, and footer budgets."
|
|
3411
3491
|
},
|
|
3412
3492
|
{
|
|
3413
3493
|
"kind": "method",
|
package/dist/calendar-day.d.ts
CHANGED
|
@@ -19,7 +19,28 @@ import { CalendarTimelineBase } from "./calendar-timeline-base.js";
|
|
|
19
19
|
export declare class CalendarDay extends CalendarTimelineBase {
|
|
20
20
|
/** The day shown, `"YYYY-MM-DD"`. */
|
|
21
21
|
date: string;
|
|
22
|
+
/** Shows a fine live line marking the current time, Google-Calendar-style. Only rendered when `date` is today. */
|
|
23
|
+
timeMarker: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Minimum width for the day column, as a CSS length (e.g. `"18rem"`).
|
|
26
|
+
* Unset leaves the host's width fully controlled by its container —
|
|
27
|
+
* useful as the sizing floor when placing several `calendar-day`
|
|
28
|
+
* elements in a scrollable row.
|
|
29
|
+
*/
|
|
30
|
+
minWidth: string;
|
|
31
|
+
private _now;
|
|
32
|
+
private _nowTimer;
|
|
22
33
|
static styles: import("lit").CSSResult[];
|
|
34
|
+
/** Starts the current-time ticker if `time-marker` is already set on connect. */
|
|
35
|
+
connectedCallback(): void;
|
|
36
|
+
/** Stops the current-time ticker when this element disconnects. */
|
|
37
|
+
disconnectedCallback(): void;
|
|
38
|
+
/** Starts/stops the current-time ticker and re-syncs the min-width host style to match the latest properties. */
|
|
39
|
+
protected updated(): void;
|
|
40
|
+
/** Ensures a 60s current-time ticker is running only while `timeMarker` is enabled. */
|
|
41
|
+
private _syncNowTimer;
|
|
42
|
+
/** Reflects `minWidth` onto the `--calendar-day-min-width` custom property the host's own styles read. */
|
|
43
|
+
private _syncMinWidth;
|
|
23
44
|
/** Renders one lane's stacked all-day bars, given the entries assigned to it. */
|
|
24
45
|
private _renderAllDayLane;
|
|
25
46
|
/** Renders a positioned/sized block for one timed entry, clamped to this day's bounds. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-day.d.ts","sourceRoot":"","sources":["../src/calendar-day.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"calendar-day.d.ts","sourceRoot":"","sources":["../src/calendar-day.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAwBnE;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,WAAY,SAAQ,oBAAoB;IACnD,qCAAqC;IACR,IAAI,EAAE,MAAM,CAAyB;IAElE,kHAAkH;IAC5C,UAAU,UAAS;IAEzF;;;;;OAKG;IACkD,QAAQ,SAAM;IAE1D,OAAO,CAAC,IAAI,CAAc;IAEnC,OAAO,CAAC,SAAS,CAA+C;IAEhE,OAAgB,MAAM,4BAkNpB;IAEF,iFAAiF;IACxE,iBAAiB,IAAI,IAAI,CAGjC;IAED,mEAAmE;IAC1D,oBAAoB,IAAI,IAAI,CAIpC;IAED,iHAAiH;IACjH,UAAmB,OAAO,IAAI,IAAI,CAIjC;IAED,uFAAuF;IACvF,OAAO,CAAC,aAAa;IAYrB,0GAA0G;IAC1G,OAAO,CAAC,aAAa;IAQrB,iFAAiF;IACjF,OAAO,CAAC,iBAAiB;IA0BzB,0FAA0F;IAC1F,OAAO,CAAC,iBAAiB;IA0BzB,UAAmB,MAAM,yCAsDxB;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAC;KAC7B;CACF"}
|
package/dist/calendar-day.js
CHANGED
|
@@ -5,11 +5,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { css, html, nothing } from "lit";
|
|
8
|
-
import { customElement, property } from "lit/decorators.js";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
9
|
import { repeat } from "lit/directives/repeat.js";
|
|
10
10
|
import { CalendarTimelineBase } from "./calendar-timeline-base.js";
|
|
11
|
+
import { iconMapPin } from "./icons.js";
|
|
11
12
|
import { tokens } from "./tokens.js";
|
|
12
|
-
import { assignLanes, minutesSinceMidnight, monthName, parseIsoDate, toIsoDate, } from "./utils/calendar.js";
|
|
13
|
+
import { assignLanes, isWeekend, minutesSinceMidnight, monthName, parseIsoDate, toIsoDate, } from "./utils/calendar.js";
|
|
14
|
+
const NOW_MARKER_INTERVAL_MS = 60_000;
|
|
13
15
|
const HOUR_HEIGHT_REM = 3;
|
|
14
16
|
const HOURS = Array.from({ length: 24 }, (_, i) => i);
|
|
15
17
|
const hourLabelFormatter = new Intl.DateTimeFormat(undefined, { hour: "numeric" });
|
|
@@ -39,12 +41,24 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
39
41
|
super(...arguments);
|
|
40
42
|
/** The day shown, `"YYYY-MM-DD"`. */
|
|
41
43
|
this.date = toIsoDate(new Date());
|
|
44
|
+
/** Shows a fine live line marking the current time, Google-Calendar-style. Only rendered when `date` is today. */
|
|
45
|
+
this.timeMarker = false;
|
|
46
|
+
/**
|
|
47
|
+
* Minimum width for the day column, as a CSS length (e.g. `"18rem"`).
|
|
48
|
+
* Unset leaves the host's width fully controlled by its container —
|
|
49
|
+
* useful as the sizing floor when placing several `calendar-day`
|
|
50
|
+
* elements in a scrollable row.
|
|
51
|
+
*/
|
|
52
|
+
this.minWidth = "";
|
|
53
|
+
this._now = Date.now();
|
|
54
|
+
this._nowTimer = null;
|
|
42
55
|
}
|
|
43
56
|
static { this.styles = [
|
|
44
57
|
tokens,
|
|
45
58
|
css `
|
|
46
59
|
:host {
|
|
47
60
|
display: block;
|
|
61
|
+
min-width: var(--calendar-day-min-width, 0);
|
|
48
62
|
font-family: var(
|
|
49
63
|
--ui-font,
|
|
50
64
|
ui-sans-serif,
|
|
@@ -72,6 +86,9 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
72
86
|
font-weight: var(--ui-font-weight-semibold, 600);
|
|
73
87
|
line-height: var(--ui-line-height-tight, 1.25);
|
|
74
88
|
}
|
|
89
|
+
.day-name.weekend {
|
|
90
|
+
color: var(--ui-text-muted, #64748b);
|
|
91
|
+
}
|
|
75
92
|
.day-name.today {
|
|
76
93
|
color: var(--ui-primary, #4f46e5);
|
|
77
94
|
}
|
|
@@ -123,9 +140,32 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
123
140
|
flex: 1 1 auto;
|
|
124
141
|
height: ${HOUR_HEIGHT_REM * 24}rem;
|
|
125
142
|
}
|
|
143
|
+
.day-column.weekend {
|
|
144
|
+
background: var(--ui-surface-muted, #f8fafc);
|
|
145
|
+
}
|
|
126
146
|
.day-column.today {
|
|
127
147
|
background: color-mix(in srgb, var(--ui-primary, #4f46e5) 6%, transparent);
|
|
128
148
|
}
|
|
149
|
+
.now-line {
|
|
150
|
+
position: absolute;
|
|
151
|
+
left: 0;
|
|
152
|
+
right: 0;
|
|
153
|
+
height: 2px;
|
|
154
|
+
background: var(--ui-danger, #dc2626);
|
|
155
|
+
pointer-events: none;
|
|
156
|
+
z-index: 2;
|
|
157
|
+
}
|
|
158
|
+
.now-line::before {
|
|
159
|
+
content: "";
|
|
160
|
+
position: absolute;
|
|
161
|
+
top: 50%;
|
|
162
|
+
left: -3px;
|
|
163
|
+
width: 8px;
|
|
164
|
+
height: 8px;
|
|
165
|
+
border-radius: 50%;
|
|
166
|
+
background: var(--ui-danger, #dc2626);
|
|
167
|
+
transform: translateY(-50%);
|
|
168
|
+
}
|
|
129
169
|
.hour-line {
|
|
130
170
|
box-sizing: border-box;
|
|
131
171
|
height: ${HOUR_HEIGHT_REM}rem;
|
|
@@ -155,6 +195,21 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
155
195
|
text-overflow: ellipsis;
|
|
156
196
|
pointer-events: none;
|
|
157
197
|
}
|
|
198
|
+
.entry-location {
|
|
199
|
+
display: flex;
|
|
200
|
+
align-items: center;
|
|
201
|
+
gap: 0.25rem;
|
|
202
|
+
overflow: hidden;
|
|
203
|
+
color: inherit;
|
|
204
|
+
font-size: var(--ui-font-size-xs, 0.6875rem);
|
|
205
|
+
font-weight: var(--ui-font-weight-regular, 400);
|
|
206
|
+
white-space: nowrap;
|
|
207
|
+
text-overflow: ellipsis;
|
|
208
|
+
pointer-events: none;
|
|
209
|
+
}
|
|
210
|
+
.entry-location svg {
|
|
211
|
+
flex: 0 0 auto;
|
|
212
|
+
}
|
|
158
213
|
.entry-link {
|
|
159
214
|
position: absolute;
|
|
160
215
|
z-index: 1;
|
|
@@ -209,21 +264,69 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
209
264
|
}
|
|
210
265
|
`,
|
|
211
266
|
]; }
|
|
267
|
+
/** Starts the current-time ticker if `time-marker` is already set on connect. */
|
|
268
|
+
connectedCallback() {
|
|
269
|
+
super.connectedCallback();
|
|
270
|
+
this._syncNowTimer();
|
|
271
|
+
}
|
|
272
|
+
/** Stops the current-time ticker when this element disconnects. */
|
|
273
|
+
disconnectedCallback() {
|
|
274
|
+
super.disconnectedCallback();
|
|
275
|
+
if (this._nowTimer != null)
|
|
276
|
+
clearInterval(this._nowTimer);
|
|
277
|
+
this._nowTimer = null;
|
|
278
|
+
}
|
|
279
|
+
/** Starts/stops the current-time ticker and re-syncs the min-width host style to match the latest properties. */
|
|
280
|
+
updated() {
|
|
281
|
+
super.updated();
|
|
282
|
+
this._syncNowTimer();
|
|
283
|
+
this._syncMinWidth();
|
|
284
|
+
}
|
|
285
|
+
/** Ensures a 60s current-time ticker is running only while `timeMarker` is enabled. */
|
|
286
|
+
_syncNowTimer() {
|
|
287
|
+
if (this.timeMarker && this._nowTimer == null) {
|
|
288
|
+
this._now = Date.now();
|
|
289
|
+
this._nowTimer = setInterval(() => {
|
|
290
|
+
this._now = Date.now();
|
|
291
|
+
}, NOW_MARKER_INTERVAL_MS);
|
|
292
|
+
}
|
|
293
|
+
else if (!this.timeMarker && this._nowTimer != null) {
|
|
294
|
+
clearInterval(this._nowTimer);
|
|
295
|
+
this._nowTimer = null;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/** Reflects `minWidth` onto the `--calendar-day-min-width` custom property the host's own styles read. */
|
|
299
|
+
_syncMinWidth() {
|
|
300
|
+
if (this.minWidth) {
|
|
301
|
+
this.style.setProperty("--calendar-day-min-width", this.minWidth);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
this.style.removeProperty("--calendar-day-min-width");
|
|
305
|
+
}
|
|
306
|
+
}
|
|
212
307
|
/** Renders one lane's stacked all-day bars, given the entries assigned to it. */
|
|
213
308
|
_renderAllDayLane(laned, lane) {
|
|
214
309
|
const entries = laned.filter((entry) => entry.lane === lane);
|
|
215
310
|
return html `
|
|
216
311
|
<div class="all-day-lane">
|
|
217
|
-
${entries.map((entry) =>
|
|
312
|
+
${entries.map((entry) => {
|
|
313
|
+
const bodyText = [entry.label, entry.location].filter(Boolean).join(" · ");
|
|
314
|
+
return html `
|
|
218
315
|
<div
|
|
219
316
|
class="entry-bar ${entry.color}"
|
|
220
317
|
data-entry-key=${this.entryKey(entry)}
|
|
221
|
-
title=${entry.href ? nothing :
|
|
318
|
+
title=${entry.href ? nothing : bodyText}
|
|
222
319
|
>
|
|
223
|
-
${this.renderEntryLink(entry,
|
|
320
|
+
${this.renderEntryLink(entry, bodyText)}
|
|
224
321
|
<span class="entry-title" aria-hidden=${entry.href ? "true" : nothing}>${entry.label}</span>
|
|
322
|
+
${entry.location
|
|
323
|
+
? html `<span class="entry-location" aria-hidden=${entry.href ? "true" : nothing}
|
|
324
|
+
>${iconMapPin(14)}${entry.location}</span
|
|
325
|
+
>`
|
|
326
|
+
: nothing}
|
|
225
327
|
</div>
|
|
226
|
-
|
|
328
|
+
`;
|
|
329
|
+
})}
|
|
227
330
|
</div>
|
|
228
331
|
`;
|
|
229
332
|
}
|
|
@@ -235,7 +338,7 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
235
338
|
const bottomRem = (minutesSinceMidnight(visibleEnd) / 60) * HOUR_HEIGHT_REM;
|
|
236
339
|
const heightRem = Math.max(bottomRem - topRem, HOUR_HEIGHT_REM / 4);
|
|
237
340
|
const widthPercent = 100 / laneCount;
|
|
238
|
-
const bodyText = [entry.label, ...(entry.details ?? [])].filter(Boolean).join("\n");
|
|
341
|
+
const bodyText = [entry.label, ...(entry.details ?? []), entry.location].filter(Boolean).join("\n");
|
|
239
342
|
return html `
|
|
240
343
|
<div
|
|
241
344
|
class="entry-bar entry-block ${entry.color}"
|
|
@@ -245,6 +348,11 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
245
348
|
>
|
|
246
349
|
${this.renderEntryLink(entry, bodyText)}
|
|
247
350
|
<span class="entry-title" aria-hidden=${entry.href ? "true" : nothing}>${entry.label}</span>
|
|
351
|
+
${entry.location
|
|
352
|
+
? html `<span class="entry-location" aria-hidden=${entry.href ? "true" : nothing}
|
|
353
|
+
>${iconMapPin(14)}${entry.location}</span
|
|
354
|
+
>`
|
|
355
|
+
: nothing}
|
|
248
356
|
</div>
|
|
249
357
|
`;
|
|
250
358
|
}
|
|
@@ -255,15 +363,17 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
255
363
|
const dayEnd = new Date(day);
|
|
256
364
|
dayEnd.setHours(23, 59, 59, 999);
|
|
257
365
|
const isToday = toIsoDate(day) === toIsoDate(new Date());
|
|
366
|
+
const isWeekendDay = isWeekend(day);
|
|
258
367
|
const resolved = this.resolveTimedEntriesFor(dayStart, dayEnd);
|
|
259
368
|
const allDay = resolved.filter((entry) => entry.allDay);
|
|
260
369
|
const timed = resolved.filter((entry) => !entry.allDay);
|
|
261
370
|
const { entries: lanedAllDay, laneCount: allDayLaneCount } = assignLanes(allDay);
|
|
262
371
|
const { entries: lanedTimed, laneCount: timedLaneCount } = assignLanes(timed);
|
|
372
|
+
const nowTopRem = this.timeMarker && isToday ? (minutesSinceMidnight(new Date(this._now)) / 60) * HOUR_HEIGHT_REM : null;
|
|
263
373
|
return html `
|
|
264
374
|
<div class="day">
|
|
265
375
|
<div class="day-header">
|
|
266
|
-
<h4 class="day-name ${isToday ? "today" : ""}">
|
|
376
|
+
<h4 class="day-name ${isWeekendDay ? "weekend" : ""} ${isToday ? "today" : ""}">
|
|
267
377
|
${monthName(day.getMonth() + 1)} ${day.getDate()}, ${day.getFullYear()}
|
|
268
378
|
</h4>
|
|
269
379
|
<div class="actions"><slot name="actions"></slot></div>
|
|
@@ -278,9 +388,12 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
278
388
|
<div class="hour-gutter">
|
|
279
389
|
${HOURS.map((h) => html `<div class="hour-label-cell">${hourLabel(h)}</div>`)}
|
|
280
390
|
</div>
|
|
281
|
-
<div class="day-column ${isToday ? "today" : ""}">
|
|
391
|
+
<div class="day-column ${isWeekendDay ? "weekend" : ""} ${isToday ? "today" : ""}">
|
|
282
392
|
${HOURS.map(() => html `<div class="hour-line"></div>`)}
|
|
283
393
|
${repeat(lanedTimed, (entry) => this.entryKey(entry), (entry) => this._renderTimedEntry(entry, Math.max(timedLaneCount, 1), dayStart, dayEnd))}
|
|
394
|
+
${nowTopRem !== null
|
|
395
|
+
? html `<div class="now-line" style="top: ${nowTopRem}rem" aria-hidden="true"></div>`
|
|
396
|
+
: nothing}
|
|
284
397
|
</div>
|
|
285
398
|
</div>
|
|
286
399
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
@@ -291,6 +404,15 @@ let CalendarDay = class CalendarDay extends CalendarTimelineBase {
|
|
|
291
404
|
__decorate([
|
|
292
405
|
property({ reflect: true })
|
|
293
406
|
], CalendarDay.prototype, "date", void 0);
|
|
407
|
+
__decorate([
|
|
408
|
+
property({ type: Boolean, reflect: true, attribute: "time-marker" })
|
|
409
|
+
], CalendarDay.prototype, "timeMarker", void 0);
|
|
410
|
+
__decorate([
|
|
411
|
+
property({ reflect: true, attribute: "min-width" })
|
|
412
|
+
], CalendarDay.prototype, "minWidth", void 0);
|
|
413
|
+
__decorate([
|
|
414
|
+
state()
|
|
415
|
+
], CalendarDay.prototype, "_now", void 0);
|
|
294
416
|
CalendarDay = __decorate([
|
|
295
417
|
customElement("calendar-day")
|
|
296
418
|
], CalendarDay);
|
package/dist/calendar-day.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-day.js","sourceRoot":"","sources":["../src/calendar-day.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,SAAS,GAEV,MAAM,qBAAqB,CAAC;AAE7B,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACtD,MAAM,kBAAkB,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,EAA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,CAAC,cAAc,CAAC;GACjB,WAAW,CA0QvB","sourcesContent":["import { css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { CalendarTimelineBase } from \"./calendar-timeline-base.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n assignLanes,\n minutesSinceMidnight,\n monthName,\n parseIsoDate,\n toIsoDate,\n type LanedEntry,\n} from \"./utils/calendar.js\";\n\nconst HOUR_HEIGHT_REM = 3;\nconst HOURS = Array.from({ length: 24 }, (_, i) => i);\nconst hourLabelFormatter = new Intl.DateTimeFormat(undefined, { hour: \"numeric\" });\n\n/** Formats hour `h` (0-23) as a locale-aware hour label, e.g. \"9 AM\". */\nfunction hourLabel(h: number): string {\n return hourLabelFormatter.format(new Date(2000, 0, 1, h));\n}\n\n/**\n * A single day rendered as an hourly time grid — a Google-Calendar-style\n * view distinct from `calendar-month`'s whole-day table. Declarative\n * `calendar-entry` children with a time-of-day in `start`/`end` (e.g.\n * `start=\"2026-03-05T09:00\"`) render as positioned/sized blocks; entries\n * with only a date (no time) render in an all-day band above the grid.\n * Overlapping timed entries stack into side-by-side columns; overlapping\n * all-day/multi-day entries stack into lanes, same as `calendar-month`.\n * Read-only.\n *\n * Shares its slotted-entry observation, resolution, and hover/focus\n * interaction sync with `calendar-week` via `CalendarTimelineBase`.\n *\n * @element calendar-day\n * @slot - Declarative `calendar-entry` elements to render for this day.\n * @slot actions - Optional controls rendered beside the day name (e.g. day-navigation buttons).\n */\n@customElement(\"calendar-day\")\nexport class CalendarDay extends CalendarTimelineBase {\n /** The day shown, `\"YYYY-MM-DD\"`. */\n @property({ reflect: true }) date: string = toIsoDate(new Date());\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n .day-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n margin-bottom: 0.5rem;\n }\n .day-name {\n margin: 0;\n min-width: 0;\n color: var(--ui-text, #0f172a);\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n }\n .day-name.today {\n color: var(--ui-primary, #4f46e5);\n }\n .actions {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: 0.5rem;\n }\n .all-day-band {\n display: flex;\n margin-bottom: 0.5rem;\n }\n .all-day-band.empty {\n display: none;\n }\n .hour-gutter-spacer {\n flex: 0 0 3rem;\n }\n .all-day-lanes {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: 0.25rem;\n }\n .all-day-lane {\n display: flex;\n gap: 0.25rem;\n }\n .grid {\n display: flex;\n border-top: 1px solid var(--ui-border, #e2e8f0);\n }\n .hour-gutter {\n flex: 0 0 3rem;\n }\n .hour-label-cell {\n box-sizing: border-box;\n height: ${HOUR_HEIGHT_REM}rem;\n padding-right: 0.5rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n color: var(--ui-text-muted, #64748b);\n font-variant-numeric: tabular-nums;\n text-align: right;\n white-space: nowrap;\n }\n .day-column {\n position: relative;\n flex: 1 1 auto;\n height: ${HOUR_HEIGHT_REM * 24}rem;\n }\n .day-column.today {\n background: color-mix(in srgb, var(--ui-primary, #4f46e5) 6%, transparent);\n }\n .hour-line {\n box-sizing: border-box;\n height: ${HOUR_HEIGHT_REM}rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n }\n .entry-bar {\n position: relative;\n box-sizing: border-box;\n flex: 1 1 auto;\n overflow: hidden;\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.25rem 0.5rem;\n transition: box-shadow 120ms ease;\n }\n .entry-bar.entry-block {\n position: absolute;\n }\n .entry-bar.entry-hovered,\n .entry-bar.entry-focused {\n box-shadow: inset 0 0 0 100vmax var(--ui-hover-overlay, rgb(255 255 255 / 0.32));\n }\n .entry-title {\n display: block;\n overflow: hidden;\n font-weight: var(--ui-font-weight-medium, 500);\n white-space: nowrap;\n text-overflow: ellipsis;\n pointer-events: none;\n }\n .entry-link {\n position: absolute;\n z-index: 1;\n inset: 0;\n border-radius: inherit;\n color: inherit;\n cursor: pointer;\n text-decoration: none;\n }\n .entry-link:focus-visible {\n outline: 2px solid var(--ui-primary, #4f46e5);\n outline-offset: -2px;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)) inset;\n }\n .entry-bar.neutral {\n background: color-mix(in srgb, var(--ui-text-muted, #64748b) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-text-muted, #64748b);\n }\n .entry-bar.info {\n background: color-mix(in srgb, var(--ui-info, #0ea5e9) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-info, #0ea5e9);\n }\n .entry-bar.primary {\n background: color-mix(in srgb, var(--ui-primary, #4f46e5) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-primary, #4f46e5);\n }\n .entry-bar.success {\n background: color-mix(in srgb, var(--ui-success, #16a34a) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-success, #16a34a);\n }\n .entry-bar.warning {\n background: color-mix(in srgb, var(--ui-warning, #d97706) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-warning, #d97706);\n }\n .entry-bar.danger {\n background: color-mix(in srgb, var(--ui-danger, #dc2626) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-danger, #dc2626);\n }\n @media (forced-colors: active) {\n .entry-link:focus-visible {\n outline-color: Highlight;\n box-shadow: none;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .entry-bar {\n transition: none;\n }\n }\n slot:not([name]) {\n display: none;\n }\n `,\n ];\n\n /** Renders one lane's stacked all-day bars, given the entries assigned to it. */\n private _renderAllDayLane(laned: LanedEntry[], lane: number) {\n const entries = laned.filter((entry) => entry.lane === lane);\n return html`\n <div class=\"all-day-lane\">\n ${entries.map(\n (entry) => html`\n <div\n class=\"entry-bar ${entry.color}\"\n data-entry-key=${this.entryKey(entry)}\n title=${entry.href ? nothing : entry.label}\n >\n ${this.renderEntryLink(entry, entry.label)}\n <span class=\"entry-title\" aria-hidden=${entry.href ? \"true\" : nothing}>${entry.label}</span>\n </div>\n `,\n )}\n </div>\n `;\n }\n\n /** Renders a positioned/sized block for one timed entry, clamped to this day's bounds. */\n private _renderTimedEntry(entry: LanedEntry, laneCount: number, dayStart: Date, dayEnd: Date) {\n const visibleStart = entry.startDate < dayStart ? dayStart : entry.startDate;\n const visibleEnd = entry.endDate > dayEnd ? dayEnd : entry.endDate;\n const topRem = (minutesSinceMidnight(visibleStart) / 60) * HOUR_HEIGHT_REM;\n const bottomRem = (minutesSinceMidnight(visibleEnd) / 60) * HOUR_HEIGHT_REM;\n const heightRem = Math.max(bottomRem - topRem, HOUR_HEIGHT_REM / 4);\n const widthPercent = 100 / laneCount;\n const bodyText = [entry.label, ...(entry.details ?? [])].filter(Boolean).join(\"\\n\");\n return html`\n <div\n class=\"entry-bar entry-block ${entry.color}\"\n data-entry-key=${this.entryKey(entry)}\n title=${entry.href ? nothing : bodyText}\n style=\"top: ${topRem}rem; height: ${heightRem}rem; left: ${entry.lane * widthPercent}%; width: ${widthPercent}%;\"\n >\n ${this.renderEntryLink(entry, bodyText)}\n <span class=\"entry-title\" aria-hidden=${entry.href ? \"true\" : nothing}>${entry.label}</span>\n </div>\n `;\n }\n\n protected override render() {\n const day = parseIsoDate(this.date) ?? new Date();\n const dayStart = new Date(day);\n dayStart.setHours(0, 0, 0, 0);\n const dayEnd = new Date(day);\n dayEnd.setHours(23, 59, 59, 999);\n const isToday = toIsoDate(day) === toIsoDate(new Date());\n\n const resolved = this.resolveTimedEntriesFor(dayStart, dayEnd);\n const allDay = resolved.filter((entry) => entry.allDay);\n const timed = resolved.filter((entry) => !entry.allDay);\n const { entries: lanedAllDay, laneCount: allDayLaneCount } = assignLanes(allDay);\n const { entries: lanedTimed, laneCount: timedLaneCount } = assignLanes(timed);\n\n return html`\n <div class=\"day\">\n <div class=\"day-header\">\n <h4 class=\"day-name ${isToday ? \"today\" : \"\"}\">\n ${monthName(day.getMonth() + 1)} ${day.getDate()}, ${day.getFullYear()}\n </h4>\n <div class=\"actions\"><slot name=\"actions\"></slot></div>\n </div>\n <div class=\"all-day-band ${allDay.length === 0 ? \"empty\" : \"\"}\">\n <div class=\"hour-gutter-spacer\"></div>\n <div class=\"all-day-lanes\">\n ${repeat(\n Array.from({ length: Math.max(allDayLaneCount, 1) }, (_, i) => i),\n (lane) => lane,\n (lane) => this._renderAllDayLane(lanedAllDay, lane),\n )}\n </div>\n </div>\n <div class=\"grid\">\n <div class=\"hour-gutter\">\n ${HOURS.map((h) => html`<div class=\"hour-label-cell\">${hourLabel(h)}</div>`)}\n </div>\n <div class=\"day-column ${isToday ? \"today\" : \"\"}\">\n ${HOURS.map(() => html`<div class=\"hour-line\"></div>`)}\n ${repeat(\n lanedTimed,\n (entry) => this.entryKey(entry),\n (entry) => this._renderTimedEntry(entry, Math.max(timedLaneCount, 1), dayStart, dayEnd),\n )}\n </div>\n </div>\n <slot @slotchange=${this.handleSlotChange}></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"calendar-day\": CalendarDay;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"calendar-day.js","sourceRoot":"","sources":["../src/calendar-day.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAA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E,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAA,+BAA+B,CAAC;cACpD,MAAM,CACN,UAAU,EACV,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC/B,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CACxF;cACC,SAAS,KAAK,IAAI;YAClB,CAAC,CAAC,IAAI,CAAA,qCAAqC,SAAS,gCAAgC;YACpF,CAAC,CAAC,OAAO;;;4BAGK,IAAI,CAAC,gBAAgB;;KAE5C,CAAC;IACJ,CAAC;CACF,CAAA;AA5X8B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAsC;AAGI;IAArE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;+CAAoB;AAQpC;IAApD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;6CAAe;AAElD;IAAhB,KAAK,EAAE;yCAA2B;AAfxB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA8XvB","sourcesContent":["import { css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { CalendarTimelineBase } from \"./calendar-timeline-base.js\";\nimport { iconMapPin } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n assignLanes,\n isWeekend,\n minutesSinceMidnight,\n monthName,\n parseIsoDate,\n toIsoDate,\n type LanedEntry,\n} from \"./utils/calendar.js\";\n\nconst NOW_MARKER_INTERVAL_MS = 60_000;\n\nconst HOUR_HEIGHT_REM = 3;\nconst HOURS = Array.from({ length: 24 }, (_, i) => i);\nconst hourLabelFormatter = new Intl.DateTimeFormat(undefined, { hour: \"numeric\" });\n\n/** Formats hour `h` (0-23) as a locale-aware hour label, e.g. \"9 AM\". */\nfunction hourLabel(h: number): string {\n return hourLabelFormatter.format(new Date(2000, 0, 1, h));\n}\n\n/**\n * A single day rendered as an hourly time grid — a Google-Calendar-style\n * view distinct from `calendar-month`'s whole-day table. Declarative\n * `calendar-entry` children with a time-of-day in `start`/`end` (e.g.\n * `start=\"2026-03-05T09:00\"`) render as positioned/sized blocks; entries\n * with only a date (no time) render in an all-day band above the grid.\n * Overlapping timed entries stack into side-by-side columns; overlapping\n * all-day/multi-day entries stack into lanes, same as `calendar-month`.\n * Read-only.\n *\n * Shares its slotted-entry observation, resolution, and hover/focus\n * interaction sync with `calendar-week` via `CalendarTimelineBase`.\n *\n * @element calendar-day\n * @slot - Declarative `calendar-entry` elements to render for this day.\n * @slot actions - Optional controls rendered beside the day name (e.g. day-navigation buttons).\n */\n@customElement(\"calendar-day\")\nexport class CalendarDay extends CalendarTimelineBase {\n /** The day shown, `\"YYYY-MM-DD\"`. */\n @property({ reflect: true }) date: string = toIsoDate(new Date());\n\n /** Shows a fine live line marking the current time, Google-Calendar-style. Only rendered when `date` is today. */\n @property({ type: Boolean, reflect: true, attribute: \"time-marker\" }) timeMarker = false;\n\n /**\n * Minimum width for the day column, as a CSS length (e.g. `\"18rem\"`).\n * Unset leaves the host's width fully controlled by its container —\n * useful as the sizing floor when placing several `calendar-day`\n * elements in a scrollable row.\n */\n @property({ reflect: true, attribute: \"min-width\" }) minWidth = \"\";\n\n @state() private _now = Date.now();\n\n private _nowTimer: ReturnType<typeof setInterval> | null = null;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n min-width: var(--calendar-day-min-width, 0);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n .day-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n margin-bottom: 0.5rem;\n }\n .day-name {\n margin: 0;\n min-width: 0;\n color: var(--ui-text, #0f172a);\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n }\n .day-name.weekend {\n color: var(--ui-text-muted, #64748b);\n }\n .day-name.today {\n color: var(--ui-primary, #4f46e5);\n }\n .actions {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: 0.5rem;\n }\n .all-day-band {\n display: flex;\n margin-bottom: 0.5rem;\n }\n .all-day-band.empty {\n display: none;\n }\n .hour-gutter-spacer {\n flex: 0 0 3rem;\n }\n .all-day-lanes {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: 0.25rem;\n }\n .all-day-lane {\n display: flex;\n gap: 0.25rem;\n }\n .grid {\n display: flex;\n border-top: 1px solid var(--ui-border, #e2e8f0);\n }\n .hour-gutter {\n flex: 0 0 3rem;\n }\n .hour-label-cell {\n box-sizing: border-box;\n height: ${HOUR_HEIGHT_REM}rem;\n padding-right: 0.5rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n color: var(--ui-text-muted, #64748b);\n font-variant-numeric: tabular-nums;\n text-align: right;\n white-space: nowrap;\n }\n .day-column {\n position: relative;\n flex: 1 1 auto;\n height: ${HOUR_HEIGHT_REM * 24}rem;\n }\n .day-column.weekend {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .day-column.today {\n background: color-mix(in srgb, var(--ui-primary, #4f46e5) 6%, transparent);\n }\n .now-line {\n position: absolute;\n left: 0;\n right: 0;\n height: 2px;\n background: var(--ui-danger, #dc2626);\n pointer-events: none;\n z-index: 2;\n }\n .now-line::before {\n content: \"\";\n position: absolute;\n top: 50%;\n left: -3px;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--ui-danger, #dc2626);\n transform: translateY(-50%);\n }\n .hour-line {\n box-sizing: border-box;\n height: ${HOUR_HEIGHT_REM}rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n }\n .entry-bar {\n position: relative;\n box-sizing: border-box;\n flex: 1 1 auto;\n overflow: hidden;\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.25rem 0.5rem;\n transition: box-shadow 120ms ease;\n }\n .entry-bar.entry-block {\n position: absolute;\n }\n .entry-bar.entry-hovered,\n .entry-bar.entry-focused {\n box-shadow: inset 0 0 0 100vmax var(--ui-hover-overlay, rgb(255 255 255 / 0.32));\n }\n .entry-title {\n display: block;\n overflow: hidden;\n font-weight: var(--ui-font-weight-medium, 500);\n white-space: nowrap;\n text-overflow: ellipsis;\n pointer-events: none;\n }\n .entry-location {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n overflow: hidden;\n color: inherit;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n font-weight: var(--ui-font-weight-regular, 400);\n white-space: nowrap;\n text-overflow: ellipsis;\n pointer-events: none;\n }\n .entry-location svg {\n flex: 0 0 auto;\n }\n .entry-link {\n position: absolute;\n z-index: 1;\n inset: 0;\n border-radius: inherit;\n color: inherit;\n cursor: pointer;\n text-decoration: none;\n }\n .entry-link:focus-visible {\n outline: 2px solid var(--ui-primary, #4f46e5);\n outline-offset: -2px;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)) inset;\n }\n .entry-bar.neutral {\n background: color-mix(in srgb, var(--ui-text-muted, #64748b) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-text-muted, #64748b);\n }\n .entry-bar.info {\n background: color-mix(in srgb, var(--ui-info, #0ea5e9) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-info, #0ea5e9);\n }\n .entry-bar.primary {\n background: color-mix(in srgb, var(--ui-primary, #4f46e5) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-primary, #4f46e5);\n }\n .entry-bar.success {\n background: color-mix(in srgb, var(--ui-success, #16a34a) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-success, #16a34a);\n }\n .entry-bar.warning {\n background: color-mix(in srgb, var(--ui-warning, #d97706) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-warning, #d97706);\n }\n .entry-bar.danger {\n background: color-mix(in srgb, var(--ui-danger, #dc2626) 15%, var(--ui-surface, #ffffff));\n color: var(--ui-danger, #dc2626);\n }\n @media (forced-colors: active) {\n .entry-link:focus-visible {\n outline-color: Highlight;\n box-shadow: none;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .entry-bar {\n transition: none;\n }\n }\n slot:not([name]) {\n display: none;\n }\n `,\n ];\n\n /** Starts the current-time ticker if `time-marker` is already set on connect. */\n override connectedCallback(): void {\n super.connectedCallback();\n this._syncNowTimer();\n }\n\n /** Stops the current-time ticker when this element disconnects. */\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this._nowTimer != null) clearInterval(this._nowTimer);\n this._nowTimer = null;\n }\n\n /** Starts/stops the current-time ticker and re-syncs the min-width host style to match the latest properties. */\n protected override updated(): void {\n super.updated();\n this._syncNowTimer();\n this._syncMinWidth();\n }\n\n /** Ensures a 60s current-time ticker is running only while `timeMarker` is enabled. */\n private _syncNowTimer(): void {\n if (this.timeMarker && this._nowTimer == null) {\n this._now = Date.now();\n this._nowTimer = setInterval(() => {\n this._now = Date.now();\n }, NOW_MARKER_INTERVAL_MS);\n } else if (!this.timeMarker && this._nowTimer != null) {\n clearInterval(this._nowTimer);\n this._nowTimer = null;\n }\n }\n\n /** Reflects `minWidth` onto the `--calendar-day-min-width` custom property the host's own styles read. */\n private _syncMinWidth(): void {\n if (this.minWidth) {\n this.style.setProperty(\"--calendar-day-min-width\", this.minWidth);\n } else {\n this.style.removeProperty(\"--calendar-day-min-width\");\n }\n }\n\n /** Renders one lane's stacked all-day bars, given the entries assigned to it. */\n private _renderAllDayLane(laned: LanedEntry[], lane: number) {\n const entries = laned.filter((entry) => entry.lane === lane);\n return html`\n <div class=\"all-day-lane\">\n ${entries.map((entry) => {\n const bodyText = [entry.label, entry.location].filter(Boolean).join(\" · \");\n return html`\n <div\n class=\"entry-bar ${entry.color}\"\n data-entry-key=${this.entryKey(entry)}\n title=${entry.href ? nothing : bodyText}\n >\n ${this.renderEntryLink(entry, bodyText)}\n <span class=\"entry-title\" aria-hidden=${entry.href ? \"true\" : nothing}>${entry.label}</span>\n ${entry.location\n ? html`<span class=\"entry-location\" aria-hidden=${entry.href ? \"true\" : nothing}\n >${iconMapPin(14)}${entry.location}</span\n >`\n : nothing}\n </div>\n `;\n })}\n </div>\n `;\n }\n\n /** Renders a positioned/sized block for one timed entry, clamped to this day's bounds. */\n private _renderTimedEntry(entry: LanedEntry, laneCount: number, dayStart: Date, dayEnd: Date) {\n const visibleStart = entry.startDate < dayStart ? dayStart : entry.startDate;\n const visibleEnd = entry.endDate > dayEnd ? dayEnd : entry.endDate;\n const topRem = (minutesSinceMidnight(visibleStart) / 60) * HOUR_HEIGHT_REM;\n const bottomRem = (minutesSinceMidnight(visibleEnd) / 60) * HOUR_HEIGHT_REM;\n const heightRem = Math.max(bottomRem - topRem, HOUR_HEIGHT_REM / 4);\n const widthPercent = 100 / laneCount;\n const bodyText = [entry.label, ...(entry.details ?? []), entry.location].filter(Boolean).join(\"\\n\");\n return html`\n <div\n class=\"entry-bar entry-block ${entry.color}\"\n data-entry-key=${this.entryKey(entry)}\n title=${entry.href ? nothing : bodyText}\n style=\"top: ${topRem}rem; height: ${heightRem}rem; left: ${entry.lane * widthPercent}%; width: ${widthPercent}%;\"\n >\n ${this.renderEntryLink(entry, bodyText)}\n <span class=\"entry-title\" aria-hidden=${entry.href ? \"true\" : nothing}>${entry.label}</span>\n ${entry.location\n ? html`<span class=\"entry-location\" aria-hidden=${entry.href ? \"true\" : nothing}\n >${iconMapPin(14)}${entry.location}</span\n >`\n : nothing}\n </div>\n `;\n }\n\n protected override render() {\n const day = parseIsoDate(this.date) ?? new Date();\n const dayStart = new Date(day);\n dayStart.setHours(0, 0, 0, 0);\n const dayEnd = new Date(day);\n dayEnd.setHours(23, 59, 59, 999);\n const isToday = toIsoDate(day) === toIsoDate(new Date());\n const isWeekendDay = isWeekend(day);\n\n const resolved = this.resolveTimedEntriesFor(dayStart, dayEnd);\n const allDay = resolved.filter((entry) => entry.allDay);\n const timed = resolved.filter((entry) => !entry.allDay);\n const { entries: lanedAllDay, laneCount: allDayLaneCount } = assignLanes(allDay);\n const { entries: lanedTimed, laneCount: timedLaneCount } = assignLanes(timed);\n const nowTopRem =\n this.timeMarker && isToday ? (minutesSinceMidnight(new Date(this._now)) / 60) * HOUR_HEIGHT_REM : null;\n\n return html`\n <div class=\"day\">\n <div class=\"day-header\">\n <h4 class=\"day-name ${isWeekendDay ? \"weekend\" : \"\"} ${isToday ? \"today\" : \"\"}\">\n ${monthName(day.getMonth() + 1)} ${day.getDate()}, ${day.getFullYear()}\n </h4>\n <div class=\"actions\"><slot name=\"actions\"></slot></div>\n </div>\n <div class=\"all-day-band ${allDay.length === 0 ? \"empty\" : \"\"}\">\n <div class=\"hour-gutter-spacer\"></div>\n <div class=\"all-day-lanes\">\n ${repeat(\n Array.from({ length: Math.max(allDayLaneCount, 1) }, (_, i) => i),\n (lane) => lane,\n (lane) => this._renderAllDayLane(lanedAllDay, lane),\n )}\n </div>\n </div>\n <div class=\"grid\">\n <div class=\"hour-gutter\">\n ${HOURS.map((h) => html`<div class=\"hour-label-cell\">${hourLabel(h)}</div>`)}\n </div>\n <div class=\"day-column ${isWeekendDay ? \"weekend\" : \"\"} ${isToday ? \"today\" : \"\"}\">\n ${HOURS.map(() => html`<div class=\"hour-line\"></div>`)}\n ${repeat(\n lanedTimed,\n (entry) => this.entryKey(entry),\n (entry) => this._renderTimedEntry(entry, Math.max(timedLaneCount, 1), dayStart, dayEnd),\n )}\n ${nowTopRem !== null\n ? html`<div class=\"now-line\" style=\"top: ${nowTopRem}rem\" aria-hidden=\"true\"></div>`\n : nothing}\n </div>\n </div>\n <slot @slotchange=${this.handleSlotChange}></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"calendar-day\": CalendarDay;\n }\n}\n"]}
|
package/dist/calendar-entry.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { StatusPillColor } from "./status-pill.js";
|
|
|
9
9
|
* @slot title - Plain-text title shown instead of the `label` fallback.
|
|
10
10
|
* @slot detail - Repeatable plain-text details rendered inside the shared body spanning all remaining days.
|
|
11
11
|
* @slot footer - Plain-text ending note pinned to the bottom of the shared body.
|
|
12
|
+
* @slot location - Plain-text location, shown on its own line with a leading marker icon.
|
|
12
13
|
*/
|
|
13
14
|
export declare class CalendarEntry extends LitElement {
|
|
14
15
|
/** Inclusive start date, `"YYYY-MM-DD"`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-entry.d.ts","sourceRoot":"","sources":["../src/calendar-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD
|
|
1
|
+
{"version":3,"file":"calendar-entry.d.ts","sourceRoot":"","sources":["../src/calendar-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD;;;;;;;;;;GAUG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,4CAA4C;IACf,KAAK,SAAM;IAExC,+FAA+F;IAClE,GAAG,SAAM;IAEtC,4DAA4D;IAC/B,KAAK,SAAM;IAExC,sDAAsD;IACzB,KAAK,EAAE,eAAe,CAAa;IAEhE,+EAA+E;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IAE3C,OAAgB,MAAM,4BAOpB;IAEF,6FAA6F;IAC7F,UAAmB,MAAM,yCAExB;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
|
package/dist/calendar-entry.js
CHANGED
|
@@ -16,6 +16,7 @@ import { tokens } from "./tokens.js";
|
|
|
16
16
|
* @slot title - Plain-text title shown instead of the `label` fallback.
|
|
17
17
|
* @slot detail - Repeatable plain-text details rendered inside the shared body spanning all remaining days.
|
|
18
18
|
* @slot footer - Plain-text ending note pinned to the bottom of the shared body.
|
|
19
|
+
* @slot location - Plain-text location, shown on its own line with a leading marker icon.
|
|
19
20
|
*/
|
|
20
21
|
let CalendarEntry = class CalendarEntry extends LitElement {
|
|
21
22
|
constructor() {
|
|
@@ -39,7 +40,7 @@ let CalendarEntry = class CalendarEntry extends LitElement {
|
|
|
39
40
|
]; }
|
|
40
41
|
/** Keeps the metadata host hidden while exposing named text slots to the parent calendar. */
|
|
41
42
|
render() {
|
|
42
|
-
return html `<slot name="title"></slot><slot name="detail"></slot><slot name="footer"></slot>`;
|
|
43
|
+
return html `<slot name="title"></slot><slot name="detail"></slot><slot name="footer"></slot><slot name="location"></slot>`;
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
46
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-entry.js","sourceRoot":"","sources":["../src/calendar-entry.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC
|
|
1
|
+
{"version":3,"file":"calendar-entry.js","sourceRoot":"","sources":["../src/calendar-entry.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;GAUG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QACL,4CAA4C;QACf,UAAK,GAAG,EAAE,CAAC;QAExC,+FAA+F;QAClE,QAAG,GAAG,EAAE,CAAC;QAEtC,4DAA4D;QAC/B,UAAK,GAAG,EAAE,CAAC;QAExC,sDAAsD;QACzB,UAAK,GAAoB,SAAS,CAAC;IAkBlE,CAAC;aAbiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;KAIF;KACF,AAPqB,CAOpB;IAEF,6FAA6F;IAC1E,MAAM;QACvB,OAAO,IAAI,CAAA,+GAA+G,CAAC;IAC7H,CAAC;CACF,CAAA;AA3B8B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAY;AAGX;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAU;AAGT;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAY;AAGX;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAoC;AAGnC;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAe;AAdhC,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CA6BzB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport type { StatusPillColor } from \"./status-pill.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Declarative metadata for one calendar event, consumed by a parent\n * `calendar-month` or `calendar-year`. Read-only/non-interactive; renders\n * nothing itself.\n *\n * @element calendar-entry\n * @slot title - Plain-text title shown instead of the `label` fallback.\n * @slot detail - Repeatable plain-text details rendered inside the shared body spanning all remaining days.\n * @slot footer - Plain-text ending note pinned to the bottom of the shared body.\n * @slot location - Plain-text location, shown on its own line with a leading marker icon.\n */\n@customElement(\"calendar-entry\")\nexport class CalendarEntry extends LitElement {\n /** Inclusive start date, `\"YYYY-MM-DD\"`. */\n @property({ reflect: true }) start = \"\";\n\n /** Inclusive end date, `\"YYYY-MM-DD\"`. Falls back to `start` when unset (single-day entry). */\n @property({ reflect: true }) end = \"\";\n\n /** Fallback title used when no `title` slot is provided. */\n @property({ reflect: true }) label = \"\";\n\n /** Color variant, reusing `status-pill`'s palette. */\n @property({ reflect: true }) color: StatusPillColor = \"neutral\";\n\n /** Optional link target; the parent renders the entry as an `<a>` when set. */\n @property({ reflect: true }) href?: string;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: none;\n }\n `,\n ];\n\n /** Keeps the metadata host hidden while exposing named text slots to the parent calendar. */\n protected override render() {\n return html`<slot name=\"title\"></slot><slot name=\"detail\"></slot><slot name=\"footer\"></slot><slot name=\"location\"></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"calendar-entry\": CalendarEntry;\n }\n}\n"]}
|
package/dist/calendar-month.d.ts
CHANGED
|
@@ -50,11 +50,11 @@ export declare class CalendarMonth extends LitElement {
|
|
|
50
50
|
private _syncEntryInteractions;
|
|
51
51
|
/** Renders a transparent full-cell link without wrapping the visible text. */
|
|
52
52
|
private _renderEntryLink;
|
|
53
|
-
/** Joins the event title, details, and visible footer for tooltips and accessible link names. */
|
|
53
|
+
/** Joins the event title, location, details, and visible footer for tooltips and accessible link names. */
|
|
54
54
|
private _entryBodyText;
|
|
55
|
-
/** Renders the shared details body, with the footer reserved at
|
|
55
|
+
/** Renders the shared details body, with the location pinned at the top and the footer reserved at the bottom. */
|
|
56
56
|
private _renderEntryBody;
|
|
57
|
-
/** Renders a row-spanning body cell with whole-line detail and footer budgets. */
|
|
57
|
+
/** Renders a row-spanning body cell with whole-line location, detail, and footer budgets. */
|
|
58
58
|
private _renderEntryBodyCell;
|
|
59
59
|
/** Renders a lane's title/body cell, skips rows covered by a body rowspan, or emits an empty spacer. */
|
|
60
60
|
private _renderLaneCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-month.d.ts","sourceRoot":"","sources":["../src/calendar-month.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"calendar-month.d.ts","sourceRoot":"","sources":["../src/calendar-month.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAqBrD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,kCAAkC;IACS,IAAI,EAAE,MAAM,CAA4B;IAEnF,0CAA0C;IACC,KAAK,SAAK;IAGrD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmB;IAElD,2FAA2F;IAClF,OAAO,CAAC,eAAe,CAAK;IAErC,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAE5C,OAAgB,MAAM,4BAkPpB;IAEF,+EAA+E;IACtE,iBAAiB,IAAI,IAAI,CAWjC;IAED,+DAA+D;IACtD,oBAAoB,IAAI,IAAI,CAGpC;IAED,wFAAwF;IACxF,UAAmB,OAAO,IAAI,IAAI,CAEjC;IAED,kFAAkF;IAClF,OAAO,CAAC,iBAAiB;IAIzB,sEAAsE;IACtE,OAAO,CAAC,SAAS;IAIjB,8EAA8E;IAC9E,OAAO,CAAC,aAAa;IASrB,oEAAoE;IACpE,OAAO,CAAC,SAAS;IAIjB,kFAAkF;IAClF,OAAO,CAAC,oBAAoB;IAQ5B,uFAAuF;IACvF,OAAO,CAAC,sBAAsB;IAa9B,8EAA8E;IAC9E,OAAO,CAAC,gBAAgB;IAgBxB,2GAA2G;IAC3G,OAAO,CAAC,cAAc;IAMtB,kHAAkH;IAClH,OAAO,CAAC,gBAAgB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