@redvars/peacock 4.4.0 → 4.5.1
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/dist/{BaseField-Cj2rNVeC.js → BaseField-BbOj212R.js} +3 -3
- package/dist/{BaseField-Cj2rNVeC.js.map → BaseField-BbOj212R.js.map} +1 -1
- package/dist/{BaseInput-CSOLv2-i.js → BaseInput-Cv03GZLu.js} +2 -2
- package/dist/{BaseInput-CSOLv2-i.js.map → BaseInput-Cv03GZLu.js.map} +1 -1
- package/dist/ai-badge.js +2 -2
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-progress-DduJjUeq.js → base-progress-CqsyiVOV.js} +2 -2
- package/dist/{base-progress-DduJjUeq.js.map → base-progress-CqsyiVOV.js.map} +1 -1
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/calendar-column-view.js +648 -30
- package/dist/calendar-column-view.js.map +1 -1
- package/dist/calendar-drag-IXMPZrTN.js +344 -0
- package/dist/calendar-drag-IXMPZrTN.js.map +1 -0
- package/dist/{calendar-event-_OYdAT3c.js → calendar-event-BQChlMXy.js} +15 -4
- package/dist/calendar-event-BQChlMXy.js.map +1 -0
- package/dist/calendar-header-DVrfThwr.js +59 -0
- package/dist/calendar-header-DVrfThwr.js.map +1 -0
- package/dist/calendar-month-view.js +311 -21
- package/dist/calendar-month-view.js.map +1 -1
- package/dist/calendar-timeline.js +1877 -0
- package/dist/calendar-timeline.js.map +1 -0
- package/dist/calendar.js +224 -62
- package/dist/calendar.js.map +1 -1
- package/dist/{canvas-base-Bfpv5_HJ.js → canvas-base-BjiU3Ecl.js} +2 -2
- package/dist/{canvas-base-Bfpv5_HJ.js.map → canvas-base-BjiU3Ecl.js.map} +1 -1
- package/dist/carousel.js +2 -2
- package/dist/{cartesian-chart-SnqFbbXV.js → cartesian-chart-iE3cmeGF.js} +2 -2
- package/dist/{cartesian-chart-SnqFbbXV.js.map → cartesian-chart-iE3cmeGF.js.map} +1 -1
- package/dist/{cb-group-base-DZIzMlen.js → cb-group-base-CWctDJvy.js} +2 -2
- package/dist/{cb-group-base-DZIzMlen.js.map → cb-group-base-CWctDJvy.js.map} +1 -1
- package/dist/cb-group.js +3 -3
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +4 -4
- package/dist/chart-bar.js +4 -4
- package/dist/{chart-base-C2N0WQLI.js → chart-base-CDyVDmz7.js} +2 -2
- package/dist/{chart-base-C2N0WQLI.js.map → chart-base-CDyVDmz7.js.map} +1 -1
- package/dist/chart-doughnut.js +3 -3
- package/dist/chart-line.js +4 -4
- package/dist/chart-pie.js +3 -3
- package/dist/chat-event.js +2 -2
- package/dist/chat-message.js +2 -2
- package/dist/chat-thread.js +2 -2
- package/dist/checkbox-group.js +3 -3
- package/dist/checkbox.js +3 -3
- package/dist/chip-set.js +2 -2
- package/dist/chip.js +2 -2
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +3 -3
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +4 -4
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +4 -4
- package/dist/condition-builder.js +3 -3
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +4 -4
- package/dist/custom-elements-jsdocs.json +52 -129
- package/dist/custom-elements.json +3109 -5
- package/dist/{date-vFrYT1S9.js → date-cfPx3alz.js} +20 -3
- package/dist/date-cfPx3alz.js.map +1 -0
- package/dist/date-field.js +8 -8
- package/dist/date-picker.js +4 -4
- package/dist/date-range-field.js +8 -8
- package/dist/datetime-field.js +7 -7
- package/dist/dependency-map.js +3 -3
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/{diagram-W_Kddt7I.js → diagram-D2aM93kf.js} +2 -2
- package/dist/{diagram-W_Kddt7I.js.map → diagram-D2aM93kf.js.map} +1 -1
- package/dist/diagram-controls.js +2 -2
- package/dist/diagram-minimap.js +2 -2
- package/dist/diagram.js +4 -4
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +2 -2
- package/dist/discussion-comment.js +2 -2
- package/dist/discussion.js +4 -4
- package/dist/{document-editor-dBgmcyUW.js → document-editor-BS6al7Hq.js} +2 -2
- package/dist/{document-editor-dBgmcyUW.js.map → document-editor-BS6al7Hq.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +2 -2
- package/dist/erd.js +3 -3
- package/dist/{event-manager-CWAWPOUE.js → event-manager-KGMT2x2Q.js} +10 -8
- package/dist/event-manager-KGMT2x2Q.js.map +1 -0
- package/dist/file-upload.js +3 -3
- package/dist/filter-bar.js +4 -4
- package/dist/flow.js +4 -4
- package/dist/form.js +2 -2
- package/dist/{generative-view-CfW6yMpY.js → generative-view-DsSOPf26.js} +2 -2
- package/dist/{generative-view-CfW6yMpY.js.map → generative-view-DsSOPf26.js.map} +1 -1
- package/dist/generative-view.js +3 -3
- package/dist/html-editor.js +4 -4
- package/dist/{i18n-controller-DNAjVSIP.js → i18n-controller-BTeChxE0.js} +2 -2
- package/dist/{i18n-controller-DNAjVSIP.js.map → i18n-controller-BTeChxE0.js.map} +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +26 -23
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +3 -3
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/listbox.js +2 -2
- package/dist/loader-full.js +13 -13
- package/dist/loader.js +17 -13
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +4 -4
- package/dist/mention-input.js +4 -4
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +2 -2
- package/dist/number-field.js +4 -4
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +4 -4
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +4 -4
- package/dist/{picker-field-Mi7_hbo8.js → picker-field-DmXYPvbF.js} +3 -3
- package/dist/{picker-field-Mi7_hbo8.js.map → picker-field-DmXYPvbF.js.map} +1 -1
- package/dist/pin-input.js +4 -4
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +4 -4
- package/dist/radio.js +3 -3
- package/dist/{range-utils-BoKOhxVX.js → range-utils-DZe96GnO.js} +2 -2
- package/dist/{range-utils-BoKOhxVX.js.map → range-utils-DZe96GnO.js.map} +1 -1
- package/dist/rating.js +3 -3
- package/dist/redvars-loader.js +2 -2
- package/dist/relative-time.js +2 -2
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-O1ku1q-J.js → rich-text-input-BCZ46UF8.js} +3 -3
- package/dist/{rich-text-input-O1ku1q-J.js.map → rich-text-input-BCZ46UF8.js.map} +1 -1
- package/dist/{schema-BWH1ANdE.js → schema-D0PCeIEA.js} +2 -2
- package/dist/{schema-BWH1ANdE.js.map → schema-D0PCeIEA.js.map} +1 -1
- package/dist/search.js +3 -3
- package/dist/select.js +4 -4
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +3 -3
- package/dist/site-header.js +2 -2
- package/dist/slider.js +3 -3
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/i18n/strings.d.ts +16 -0
- package/dist/src/__internal/utils/date.d.ts +5 -0
- package/dist/src/calendar/base-event.d.ts +5 -0
- package/dist/src/calendar/calendar-column-view.d.ts +65 -1
- package/dist/src/calendar/calendar-drag.d.ts +91 -0
- package/dist/src/calendar/calendar-header.d.ts +28 -0
- package/dist/src/calendar/calendar-month-view.d.ts +39 -1
- package/dist/src/calendar/calendar.d.ts +83 -6
- package/dist/src/calendar/index.d.ts +2 -2
- package/dist/src/calendar/types.d.ts +32 -0
- package/dist/src/calendar/utils.d.ts +53 -0
- package/dist/src/calendar-timeline/calendar-timeline.d.ts +287 -0
- package/dist/src/calendar-timeline/index.d.ts +3 -0
- package/dist/src/calendar-timeline/layout.d.ts +39 -0
- package/dist/src/calendar-timeline/types.d.ts +60 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-BpCoUL0V.js → strings-DeiQWMd9.js} +18 -1
- package/dist/strings-DeiQWMd9.js.map +1 -0
- package/dist/svg.js +2 -2
- package/dist/switch.js +3 -3
- package/dist/table.js +2 -2
- package/dist/test/calendar-timeline.test.d.ts +1 -0
- package/dist/textarea.js +4 -4
- package/dist/time-field.js +7 -7
- package/dist/time-picker.js +4 -4
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-BRNNka2o.js → toggle-base-BtjRAZ5z.js} +2 -2
- package/dist/{toggle-base-BRNNka2o.js.map → toggle-base-BtjRAZ5z.js.map} +1 -1
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +3 -3
- package/dist/tree-chart.js +3 -3
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +4 -4
- package/dist/user-menu.js +2 -2
- package/dist/{utils-D92ldd1V.js → utils-DcvLgexs.js} +116 -19
- package/dist/utils-DcvLgexs.js.map +1 -0
- package/dist/{video-DBdRuyh4.js → video-DPjOBk6I.js} +2 -2
- package/dist/{video-DBdRuyh4.js.map → video-DPjOBk6I.js.map} +1 -1
- package/dist/video.js +3 -3
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-timeline.js +2 -2
- package/dist/workflow.js +3 -3
- package/dist/workspace-switcher.js +2 -2
- package/package.json +1 -1
- package/readme.md +1 -0
- package/src/__internal/i18n/strings.ts +25 -0
- package/src/__internal/utils/date.ts +19 -0
- package/src/calendar/_calendar-header.scss +33 -0
- package/src/calendar/base-event.ts +19 -2
- package/src/calendar/calendar-column-view.scss +174 -2
- package/src/calendar/calendar-column-view.ts +665 -37
- package/src/calendar/calendar-drag.ts +403 -0
- package/src/calendar/calendar-header.ts +78 -0
- package/src/calendar/calendar-month-view.scss +89 -0
- package/src/calendar/calendar-month-view.ts +289 -23
- package/src/calendar/calendar.scss +2 -27
- package/src/calendar/calendar.ts +264 -62
- package/src/calendar/event-manager.ts +11 -7
- package/src/calendar/index.ts +8 -2
- package/src/calendar/types.ts +35 -0
- package/src/calendar/utils.ts +160 -20
- package/src/calendar-timeline/calendar-timeline.scss +564 -0
- package/src/calendar-timeline/calendar-timeline.ts +1528 -0
- package/src/calendar-timeline/index.ts +14 -0
- package/src/calendar-timeline/layout.ts +129 -0
- package/src/calendar-timeline/types.ts +65 -0
- package/src/index.ts +18 -0
- package/src/loader.ts +4 -0
- package/dist/calendar-event-_OYdAT3c.js.map +0 -1
- package/dist/date-vFrYT1S9.js.map +0 -1
- package/dist/event-manager-CWAWPOUE.js.map +0 -1
- package/dist/strings-BpCoUL0V.js.map +0 -1
- package/dist/utils-D92ldd1V.js.map +0 -1
package/dist/typing-indicator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i, _ as __decorate, I as IndividualComponent, a as i$1, b } from './IndividualComponent-BK7XZjE2.js';
|
|
2
2
|
import { n } from './property-B2TG3KEE.js';
|
|
3
|
-
import { I as I18nController } from './i18n-controller-
|
|
4
|
-
import './strings-
|
|
3
|
+
import { I as I18nController } from './i18n-controller-BTeChxE0.js';
|
|
4
|
+
import './strings-DeiQWMd9.js';
|
|
5
5
|
import './locale-DEsJZCQG.js';
|
|
6
6
|
|
|
7
7
|
var css_248z = i`* {
|
package/dist/url-field.js
CHANGED
|
@@ -3,12 +3,12 @@ import { n } from './property-B2TG3KEE.js';
|
|
|
3
3
|
import { r } from './state-BCeDVCI9.js';
|
|
4
4
|
import { e } from './query-CHb9Ft_d.js';
|
|
5
5
|
import { s as spread } from './spread-B5cgadZl.js';
|
|
6
|
-
import { I as I18nController } from './i18n-controller-
|
|
7
|
-
import { B as BaseField } from './BaseField-
|
|
8
|
-
import { n as nativeValidity } from './BaseInput-
|
|
6
|
+
import { I as I18nController } from './i18n-controller-BTeChxE0.js';
|
|
7
|
+
import { B as BaseField } from './BaseField-BbOj212R.js';
|
|
8
|
+
import { n as nativeValidity } from './BaseInput-Cv03GZLu.js';
|
|
9
9
|
import './base-Cl6v8-BZ.js';
|
|
10
10
|
import './directive-ZPhl09Yt.js';
|
|
11
|
-
import './strings-
|
|
11
|
+
import './strings-DeiQWMd9.js';
|
|
12
12
|
import './locale-DEsJZCQG.js';
|
|
13
13
|
import './element-internals-QME0yEz4.js';
|
|
14
14
|
import './form-associated-BHbg72PG.js';
|
package/dist/user-menu.js
CHANGED
|
@@ -2,10 +2,10 @@ import { i, _ as __decorate, I as IndividualComponent, a as i$1, A, b } from './
|
|
|
2
2
|
import { n } from './property-B2TG3KEE.js';
|
|
3
3
|
import { r } from './state-BCeDVCI9.js';
|
|
4
4
|
import { e } from './query-CHb9Ft_d.js';
|
|
5
|
-
import { I as I18nController } from './i18n-controller-
|
|
5
|
+
import { I as I18nController } from './i18n-controller-BTeChxE0.js';
|
|
6
6
|
import { M as MenuTriggerController } from './menu-trigger-controller-CEJq1ugC.js';
|
|
7
7
|
import './base-Cl6v8-BZ.js';
|
|
8
|
-
import './strings-
|
|
8
|
+
import './strings-DeiQWMd9.js';
|
|
9
9
|
import './locale-DEsJZCQG.js';
|
|
10
10
|
|
|
11
11
|
var css_248z = i`* {
|
|
@@ -78,6 +78,87 @@ function calculateDateRange(view, contextDate, days, weekStartsOn = 1) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
const LONG_EVENT_PADDING = 0.25;
|
|
81
|
+
/** Milliseconds in a day of 24 hours. */
|
|
82
|
+
const DAY_MS = 86400000;
|
|
83
|
+
/** Milliseconds in a minute. */
|
|
84
|
+
const MINUTE_MS = 60000;
|
|
85
|
+
function clamp(value, min, max) {
|
|
86
|
+
return Math.min(max, Math.max(min, value));
|
|
87
|
+
}
|
|
88
|
+
/** Whether `date` is at local midnight. */
|
|
89
|
+
function isMidnight(date) {
|
|
90
|
+
return (date.getHours() === 0 &&
|
|
91
|
+
date.getMinutes() === 0 &&
|
|
92
|
+
date.getSeconds() === 0 &&
|
|
93
|
+
date.getMilliseconds() === 0);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether a range belongs in the all-day row: it lasts a day or more, or runs from one midnight to
|
|
97
|
+
* a later one (a day the clocks go forward on has only 23 hours).
|
|
98
|
+
*/
|
|
99
|
+
function isAllDayRange(start, end) {
|
|
100
|
+
const length = end.valueOf() - start.valueOf();
|
|
101
|
+
return (length >= DAY_MS || (length > 0 && isMidnight(start) && isMidnight(end)));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The last day a range covers. `end` is exclusive, so a range that ends at midnight ends the day
|
|
105
|
+
* before. Never earlier than the day of `start`.
|
|
106
|
+
*/
|
|
107
|
+
function lastDayOf(start, end) {
|
|
108
|
+
const first = startOfDay(start);
|
|
109
|
+
const last = startOfDay(new Date(end.valueOf() - 1));
|
|
110
|
+
return last.valueOf() < first.valueOf() ? first : last;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether the range `start`–`end` (end exclusive) shares time with `from`–`to`. A range without
|
|
114
|
+
* length counts when its instant falls inside.
|
|
115
|
+
*/
|
|
116
|
+
function rangesOverlap(start, end, from, to) {
|
|
117
|
+
if (start.valueOf() >= end.valueOf()) {
|
|
118
|
+
return start.valueOf() >= from.valueOf() && start.valueOf() < to.valueOf();
|
|
119
|
+
}
|
|
120
|
+
return start.valueOf() < to.valueOf() && end.valueOf() > from.valueOf();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The start of the day after `date`'s. Unlike `addDays(day, 1)`, it lands on midnight even after a
|
|
124
|
+
* day whose midnight the clocks skipped, where `startOfDay` gives 01:00.
|
|
125
|
+
*/
|
|
126
|
+
function nextDay(date) {
|
|
127
|
+
return startOfDay(addDays(startOfDay(date), 1));
|
|
128
|
+
}
|
|
129
|
+
/** Minutes in a day on the wall clock, which the day and week views draw. */
|
|
130
|
+
const DAY_MINUTES = 1440;
|
|
131
|
+
/**
|
|
132
|
+
* Wall-clock minutes from the start of `day` to `date`: negative before it, 1440 or more after
|
|
133
|
+
* it. The day and week views draw 24 equal hours, also on the days the clocks change.
|
|
134
|
+
*/
|
|
135
|
+
function wallMinutes(date, day) {
|
|
136
|
+
return (differenceInDays(date, day) * DAY_MINUTES +
|
|
137
|
+
date.getHours() * 60 +
|
|
138
|
+
date.getMinutes() +
|
|
139
|
+
date.getSeconds() / 60 +
|
|
140
|
+
date.getMilliseconds() / MINUTE_MS);
|
|
141
|
+
}
|
|
142
|
+
/** The time `minutes` after the start of `day` on the wall clock; 1440 is the next midnight. */
|
|
143
|
+
function atWallMinutes(day, minutes) {
|
|
144
|
+
const date = startOfDay(day);
|
|
145
|
+
date.setHours(0, 0, 0, Math.round(minutes * MINUTE_MS));
|
|
146
|
+
return date;
|
|
147
|
+
}
|
|
148
|
+
/** The time at `fraction` (0 to 1) down `day`'s column: the inverse of `getTimePercent`. */
|
|
149
|
+
function timeAtFraction(day, fraction) {
|
|
150
|
+
return atWallMinutes(day, clamp(fraction, 0, 1) * DAY_MINUTES);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* `date` moved to a multiple of `minutes` on the wall clock after the start of `day` (by default
|
|
154
|
+
* its own day): the nearest one, or the one before or after. The result stays within `day`, whose
|
|
155
|
+
* end is the next midnight.
|
|
156
|
+
*/
|
|
157
|
+
function snapTime(date, minutes, mode = 'round', day = date) {
|
|
158
|
+
const step = Math.max(1, minutes);
|
|
159
|
+
const steps = Math[mode](wallMinutes(date, day) / step);
|
|
160
|
+
return atWallMinutes(day, clamp(steps * step, 0, DAY_MINUTES));
|
|
161
|
+
}
|
|
81
162
|
/**
|
|
82
163
|
* The wall-clock fields `date` shows in `timeZone` (an IANA name such as `America/New_York`),
|
|
83
164
|
* read from `Intl.DateTimeFormat#formatToParts`. Throws a `RangeError` for an unknown zone.
|
|
@@ -147,18 +228,38 @@ function formatDate(date, pattern, locale = resolveLocale()) {
|
|
|
147
228
|
return date.toLocaleDateString(locale);
|
|
148
229
|
return new Intl.DateTimeFormat(locale, options).format(date);
|
|
149
230
|
}
|
|
150
|
-
/**
|
|
151
|
-
function
|
|
152
|
-
const format = new Intl.DateTimeFormat(locale, allDay
|
|
153
|
-
? { dateStyle: 'medium' }
|
|
154
|
-
: { dateStyle: 'medium', timeStyle: 'short' });
|
|
155
|
-
let when;
|
|
231
|
+
/** `format.formatRange`, or both dates joined by a dash where it is missing or throws. */
|
|
232
|
+
function formatRange(format, start, end) {
|
|
156
233
|
try {
|
|
157
|
-
|
|
234
|
+
return format.formatRange(start, end);
|
|
158
235
|
}
|
|
159
236
|
catch {
|
|
160
|
-
|
|
237
|
+
return `${format.format(start)} – ${format.format(end)}`;
|
|
161
238
|
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* When an event happens, for example `Nov 6, 2026, 9:00 – 9:30 AM`. An all-day event shows its
|
|
242
|
+
* days only, through the day before an `end` at midnight.
|
|
243
|
+
*/
|
|
244
|
+
function formatEventWhen(start, end, locale, allDay = false) {
|
|
245
|
+
if (allDay) {
|
|
246
|
+
const format = new Intl.DateTimeFormat(locale, { dateStyle: 'medium' });
|
|
247
|
+
return formatRange(format, start, lastDayOf(start, end));
|
|
248
|
+
}
|
|
249
|
+
const format = new Intl.DateTimeFormat(locale, {
|
|
250
|
+
dateStyle: 'medium',
|
|
251
|
+
timeStyle: 'short',
|
|
252
|
+
});
|
|
253
|
+
return formatRange(format, start, end);
|
|
254
|
+
}
|
|
255
|
+
/** The times of a range without its date, for example `9:00 – 10:30 AM`. */
|
|
256
|
+
function formatTimeRange(start, end, locale) {
|
|
257
|
+
const format = new Intl.DateTimeFormat(locale, { timeStyle: 'short' });
|
|
258
|
+
return formatRange(format, start, end);
|
|
259
|
+
}
|
|
260
|
+
/** Accessible name of an event: its title and when it happens, for example `Standup, Nov 6, 2026, 9:00 – 9:30 AM`. */
|
|
261
|
+
function formatEventLabel(title, start, end, locale, allDay = false) {
|
|
262
|
+
const when = formatEventWhen(start, end, locale, allDay);
|
|
162
263
|
return title ? `${title}, ${when}` : when;
|
|
163
264
|
}
|
|
164
265
|
/** Runs `action` on Enter or Space, the keys that activate a button. */
|
|
@@ -170,17 +271,13 @@ function onActivateKey(action) {
|
|
|
170
271
|
action();
|
|
171
272
|
};
|
|
172
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* How far down `forDay`'s column (by default `date`'s own day) `date` falls, in percent, on a
|
|
276
|
+
* 24-hour wall clock: a 9:00 event sits at the 9 AM row also on the days the clocks change.
|
|
277
|
+
*/
|
|
173
278
|
function getTimePercent(date, forDay) {
|
|
174
|
-
|
|
175
|
-
const sd = startOfDay(day);
|
|
176
|
-
const ed = endOfDay(day);
|
|
177
|
-
const percent = ((date.valueOf() - sd.valueOf()) / (ed.valueOf() - sd.valueOf())) * 100;
|
|
178
|
-
if (percent < 0)
|
|
179
|
-
return 0;
|
|
180
|
-
if (percent > 100)
|
|
181
|
-
return 100;
|
|
182
|
-
return percent;
|
|
279
|
+
return clamp((wallMinutes(date, forDay || date) / DAY_MINUTES) * 100, 0, 100);
|
|
183
280
|
}
|
|
184
281
|
|
|
185
|
-
export { LONG_EVENT_PADDING as L, addDays as a,
|
|
186
|
-
//# sourceMappingURL=utils-
|
|
282
|
+
export { atWallMinutes as A, LONG_EVENT_PADDING as L, MINUTE_MS as M, addDays as a, startOfDay as b, addMonths as c, differenceInDays as d, endOfDay as e, formatEventWhen as f, formatEventLabel as g, formatDate as h, isAllDayRange as i, getTimePercent as j, calculateDateRange as k, lastDayOf as l, timeAtFraction as m, nextDay as n, snapTime as o, clamp as p, onActivateKey as q, rangesOverlap as r, startOfWeek as s, toZonedWallClock as t, addHours as u, formatTimeRange as v, calculateMonthRange as w, startOfMonth as x, endOfMonth as y, wallMinutes as z };
|
|
283
|
+
//# sourceMappingURL=utils-DcvLgexs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-DcvLgexs.js","sources":["../../src/calendar/utils.ts"],"sourcesContent":["/**\n * Pure date utility functions (no external dependencies).\n */\n\nimport { resolveLocale } from '@/__internal/i18n/locale.js';\n\nexport function startOfDay(date: Date): Date {\n const d = new Date(date);\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nexport function endOfDay(date: Date): Date {\n const d = new Date(date);\n d.setHours(23, 59, 59, 999);\n return d;\n}\n\nexport function addDays(date: Date, days: number): Date {\n const d = new Date(date);\n d.setDate(d.getDate() + days);\n return d;\n}\n\nexport function addMonths(date: Date, months: number): Date {\n const d = new Date(date);\n d.setMonth(d.getMonth() + months);\n return d;\n}\n\nexport function addHours(date: Date, hours: number): Date {\n const d = new Date(date);\n d.setHours(d.getHours() + hours);\n return d;\n}\n\nexport function differenceInDays(dateA: Date, dateB: Date): number {\n const a = startOfDay(dateA);\n const b = startOfDay(dateB);\n return Math.round((a.valueOf() - b.valueOf()) / 86400000);\n}\n\nexport function startOfWeek(\n date: Date,\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 1,\n): Date {\n const d = startOfDay(date);\n const day = d.getDay();\n const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n d.setDate(d.getDate() - diff);\n return d;\n}\n\nexport function endOfWeek(\n date: Date,\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 1,\n): Date {\n const d = startOfWeek(date, weekStartsOn);\n d.setDate(d.getDate() + 6);\n return endOfDay(d);\n}\n\nexport function startOfMonth(date: Date): Date {\n const d = new Date(date);\n d.setDate(1);\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nexport function endOfMonth(date: Date): Date {\n const d = new Date(date);\n d.setMonth(d.getMonth() + 1, 0);\n d.setHours(23, 59, 59, 999);\n return d;\n}\n\nexport function calculateMonthRange(\n date: Date,\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 1,\n) {\n const sd = startOfWeek(startOfMonth(date), weekStartsOn);\n const ed = endOfWeek(endOfMonth(date), weekStartsOn);\n return { startDate: sd, endDate: ed, totalDays: 42 };\n}\n\nexport function calculateWeekRange(\n date: Date,\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 1,\n) {\n const sd = startOfWeek(date, weekStartsOn);\n const ed = endOfWeek(date, weekStartsOn);\n return { startDate: sd, endDate: ed, totalDays: 7 };\n}\n\nexport function calculateDateRange(\n view: string,\n contextDate: Date,\n days: number,\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 1,\n) {\n if (view === 'week') {\n return calculateWeekRange(contextDate, weekStartsOn);\n }\n return {\n startDate: startOfDay(contextDate),\n endDate: endOfDay(addDays(contextDate, days - 1)),\n totalDays: days,\n };\n}\n\nexport const LONG_EVENT_PADDING = 0.25;\n\n/** Milliseconds in a day of 24 hours. */\nexport const DAY_MS = 86400000;\n\n/** Milliseconds in a minute. */\nexport const MINUTE_MS = 60000;\n\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\n/** Whether `date` is at local midnight. */\nexport function isMidnight(date: Date): boolean {\n return (\n date.getHours() === 0 &&\n date.getMinutes() === 0 &&\n date.getSeconds() === 0 &&\n date.getMilliseconds() === 0\n );\n}\n\n/**\n * Whether a range belongs in the all-day row: it lasts a day or more, or runs from one midnight to\n * a later one (a day the clocks go forward on has only 23 hours).\n */\nexport function isAllDayRange(start: Date, end: Date): boolean {\n const length = end.valueOf() - start.valueOf();\n return (\n length >= DAY_MS || (length > 0 && isMidnight(start) && isMidnight(end))\n );\n}\n\n/**\n * The last day a range covers. `end` is exclusive, so a range that ends at midnight ends the day\n * before. Never earlier than the day of `start`.\n */\nexport function lastDayOf(start: Date, end: Date): Date {\n const first = startOfDay(start);\n const last = startOfDay(new Date(end.valueOf() - 1));\n return last.valueOf() < first.valueOf() ? first : last;\n}\n\n/**\n * Whether the range `start`–`end` (end exclusive) shares time with `from`–`to`. A range without\n * length counts when its instant falls inside.\n */\nexport function rangesOverlap(\n start: Date,\n end: Date,\n from: Date,\n to: Date,\n): boolean {\n if (start.valueOf() >= end.valueOf()) {\n return start.valueOf() >= from.valueOf() && start.valueOf() < to.valueOf();\n }\n return start.valueOf() < to.valueOf() && end.valueOf() > from.valueOf();\n}\n\n/**\n * The start of the day after `date`'s. Unlike `addDays(day, 1)`, it lands on midnight even after a\n * day whose midnight the clocks skipped, where `startOfDay` gives 01:00.\n */\nexport function nextDay(date: Date): Date {\n return startOfDay(addDays(startOfDay(date), 1));\n}\n\n/** Minutes in a day on the wall clock, which the day and week views draw. */\nconst DAY_MINUTES = 1440;\n\n/**\n * Wall-clock minutes from the start of `day` to `date`: negative before it, 1440 or more after\n * it. The day and week views draw 24 equal hours, also on the days the clocks change.\n */\nexport function wallMinutes(date: Date, day: Date): number {\n return (\n differenceInDays(date, day) * DAY_MINUTES +\n date.getHours() * 60 +\n date.getMinutes() +\n date.getSeconds() / 60 +\n date.getMilliseconds() / MINUTE_MS\n );\n}\n\n/** The time `minutes` after the start of `day` on the wall clock; 1440 is the next midnight. */\nexport function atWallMinutes(day: Date, minutes: number): Date {\n const date = startOfDay(day);\n date.setHours(0, 0, 0, Math.round(minutes * MINUTE_MS));\n return date;\n}\n\n/** The time at `fraction` (0 to 1) down `day`'s column: the inverse of `getTimePercent`. */\nexport function timeAtFraction(day: Date, fraction: number): Date {\n return atWallMinutes(day, clamp(fraction, 0, 1) * DAY_MINUTES);\n}\n\n/**\n * `date` moved to a multiple of `minutes` on the wall clock after the start of `day` (by default\n * its own day): the nearest one, or the one before or after. The result stays within `day`, whose\n * end is the next midnight.\n */\nexport function snapTime(\n date: Date,\n minutes: number,\n mode: 'round' | 'floor' | 'ceil' = 'round',\n day: Date = date,\n): Date {\n const step = Math.max(1, minutes);\n const steps = Math[mode](wallMinutes(date, day) / step);\n return atWallMinutes(day, clamp(steps * step, 0, DAY_MINUTES));\n}\n\n/** Wall-clock date and time fields; `month` is 1–12. */\nexport type WallClockParts = {\n year: number;\n month: number;\n day: number;\n hour: number;\n minute: number;\n second: number;\n};\n\n/**\n * The wall-clock fields `date` shows in `timeZone` (an IANA name such as `America/New_York`),\n * read from `Intl.DateTimeFormat#formatToParts`. Throws a `RangeError` for an unknown zone.\n */\nexport function zonedParts(date: Date, timeZone: string): WallClockParts {\n const parts = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hourCycle: 'h23',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n }).formatToParts(date);\n const field = (type: Intl.DateTimeFormatPartTypes) =>\n Number(parts.find(part => part.type === type)?.value ?? 0);\n return {\n year: field('year'),\n month: field('month'),\n day: field('day'),\n // Some engines print midnight as 24 even with `h23`.\n hour: field('hour') % 24,\n minute: field('minute'),\n second: field('second'),\n };\n}\n\n/**\n * A `Date` whose local fields show the wall-clock time `date` has in `timeZone`, so the views can\n * lay it out with local getters. An empty or unknown zone returns a copy of `date`.\n */\nexport function toZonedWallClock(date: Date, timeZone: string): Date {\n if (!timeZone) return new Date(date);\n try {\n const { year, month, day, hour, minute, second } = zonedParts(\n date,\n timeZone,\n );\n const wall = new Date(\n year,\n month - 1,\n day,\n hour,\n minute,\n second,\n date.getMilliseconds(),\n );\n // Two-digit years would otherwise land in the 1900s.\n wall.setFullYear(year);\n return wall;\n } catch {\n return new Date(date);\n }\n}\n\n/** `Intl` options for each display pattern; the output matches the pattern in `en-US`. */\nconst DISPLAY_FORMATS: Record<string, Intl.DateTimeFormatOptions> = {\n 'MMMM d, yyyy': { month: 'long', day: 'numeric', year: 'numeric' },\n EEEE: { weekday: 'long' },\n E: { weekday: 'short' },\n d: { day: 'numeric' },\n dd: { day: '2-digit' },\n 'hh a': { hour: '2-digit' },\n 'hh:mm a': { hour: '2-digit', minute: '2-digit' },\n};\n\n/**\n * Formats a date for display in `locale`. The patterns name the `en-US` output; other locales get\n * their own month and day names, order and clock. `dd-MM-yyyy` is a fixed key, not display text.\n */\nexport function formatDate(\n date: Date,\n pattern: string,\n locale: string = resolveLocale(),\n): string {\n if (pattern === 'dd-MM-yyyy') {\n const day = String(date.getDate()).padStart(2, '0');\n const month = String(date.getMonth() + 1).padStart(2, '0');\n return `${day}-${month}-${date.getFullYear()}`;\n }\n const options = DISPLAY_FORMATS[pattern];\n if (!options) return date.toLocaleDateString(locale);\n return new Intl.DateTimeFormat(locale, options).format(date);\n}\n\n/** `format.formatRange`, or both dates joined by a dash where it is missing or throws. */\nfunction formatRange(\n format: Intl.DateTimeFormat,\n start: Date,\n end: Date,\n): string {\n try {\n return format.formatRange(start, end);\n } catch {\n return `${format.format(start)} – ${format.format(end)}`;\n }\n}\n\n/**\n * When an event happens, for example `Nov 6, 2026, 9:00 – 9:30 AM`. An all-day event shows its\n * days only, through the day before an `end` at midnight.\n */\nexport function formatEventWhen(\n start: Date,\n end: Date,\n locale: string,\n allDay = false,\n): string {\n if (allDay) {\n const format = new Intl.DateTimeFormat(locale, { dateStyle: 'medium' });\n return formatRange(format, start, lastDayOf(start, end));\n }\n const format = new Intl.DateTimeFormat(locale, {\n dateStyle: 'medium',\n timeStyle: 'short',\n });\n return formatRange(format, start, end);\n}\n\n/** The times of a range without its date, for example `9:00 – 10:30 AM`. */\nexport function formatTimeRange(\n start: Date,\n end: Date,\n locale: string,\n): string {\n const format = new Intl.DateTimeFormat(locale, { timeStyle: 'short' });\n return formatRange(format, start, end);\n}\n\n/** Accessible name of an event: its title and when it happens, for example `Standup, Nov 6, 2026, 9:00 – 9:30 AM`. */\nexport function formatEventLabel(\n title: string,\n start: Date,\n end: Date,\n locale: string,\n allDay = false,\n): string {\n const when = formatEventWhen(start, end, locale, allDay);\n return title ? `${title}, ${when}` : when;\n}\n\n/** Runs `action` on Enter or Space, the keys that activate a button. */\nexport function onActivateKey(action: () => void) {\n return (event: KeyboardEvent) => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n action();\n };\n}\n\n/**\n * How far down `forDay`'s column (by default `date`'s own day) `date` falls, in percent, on a\n * 24-hour wall clock: a 9:00 event sits at the 9 AM row also on the days the clocks change.\n */\nexport function getTimePercent(date: Date, forDay?: Date): number {\n return clamp((wallMinutes(date, forDay || date) / DAY_MINUTES) * 100, 0, 100);\n}\n"],"names":[],"mappings":";;AAAA;;AAEG;AAIG,SAAU,UAAU,CAAC,IAAU,EAAA;AACnC,IAAA,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACtB,IAAA,OAAO,CAAC;AACV;AAEM,SAAU,QAAQ,CAAC,IAAU,EAAA;AACjC,IAAA,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;AAC3B,IAAA,OAAO,CAAC;AACV;AAEM,SAAU,OAAO,CAAC,IAAU,EAAE,IAAY,EAAA;AAC9C,IAAA,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;AAC7B,IAAA,OAAO,CAAC;AACV;AAEM,SAAU,SAAS,CAAC,IAAU,EAAE,MAA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,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG;YAAE;QAChD,KAAK,CAAC,cAAc,EAAE;AACtB,QAAA,MAAM,EAAE;AACV,IAAA,CAAC;AACH;AAEA;;;AAGG;AACG,SAAU,cAAc,CAAC,IAAU,EAAE,MAAa,EAAA;IACtD,OAAO,KAAK,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI,CAAC,GAAG,WAAW,IAAI,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC;AAC/E;;;;"}
|
|
@@ -3,7 +3,7 @@ import { n } from './property-B2TG3KEE.js';
|
|
|
3
3
|
import { r } from './state-BCeDVCI9.js';
|
|
4
4
|
import { e } from './query-CHb9Ft_d.js';
|
|
5
5
|
import { o } from './style-map-CHOg6N_R.js';
|
|
6
|
-
import { I as I18nController } from './i18n-controller-
|
|
6
|
+
import { I as I18nController } from './i18n-controller-BTeChxE0.js';
|
|
7
7
|
|
|
8
8
|
const YOUTUBE_HOSTS = [
|
|
9
9
|
'youtube.com',
|
|
@@ -506,4 +506,4 @@ Video = __decorate([
|
|
|
506
506
|
], Video);
|
|
507
507
|
|
|
508
508
|
export { Video as V, parseVideoSource as p };
|
|
509
|
-
//# sourceMappingURL=video-
|
|
509
|
+
//# sourceMappingURL=video-DPjOBk6I.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video-DBdRuyh4.js","sources":["../../src/video/video-source.ts","../../src/video/video.ts"],"sourcesContent":["/** Where a video plays from. */\nexport type VideoProvider = 'youtube' | 'vimeo' | 'file';\n\nexport interface VideoSource {\n provider: VideoProvider;\n /** The player URL to load on play, for YouTube and Vimeo; the file URL for a file. */\n url: string;\n}\n\nconst YOUTUBE_HOSTS = [\n 'youtube.com',\n 'www.youtube.com',\n 'm.youtube.com',\n 'music.youtube.com',\n 'youtube-nocookie.com',\n 'www.youtube-nocookie.com',\n];\n\nconst VIMEO_HOSTS = ['vimeo.com', 'www.vimeo.com', 'player.vimeo.com'];\n\n/** A YouTube time such as `90`, `90s` or `1m30s`, in whole seconds. */\nfunction seconds(time: string | null): number {\n if (!time) return 0;\n if (/^\\d+$/.test(time)) return Number(time);\n const match = /^(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?$/.exec(time);\n if (!match) return 0;\n const [, h = '0', m = '0', s = '0'] = match;\n return Number(h) * 3600 + Number(m) * 60 + Number(s);\n}\n\nfunction youtubeId(url: URL): string | undefined {\n if (url.hostname === 'youtu.be') return url.pathname.split('/')[1];\n if (!YOUTUBE_HOSTS.includes(url.hostname)) return undefined;\n if (url.pathname === '/watch') return url.searchParams.get('v') ?? undefined;\n const [, kind, id] = url.pathname.split('/');\n return ['embed', 'shorts', 'live', 'v'].includes(kind) ? id : undefined;\n}\n\n/**\n * Reads a video URL. YouTube links play through youtube-nocookie.com and Vimeo links with\n * `dnt=1`, so neither sets tracking cookies; any other URL is treated as a video file.\n */\nexport function parseVideoSource(src: string): VideoSource {\n let url: URL;\n try {\n url = new URL(src, document.baseURI);\n } catch {\n return { provider: 'file', url: src };\n }\n\n const youtube = youtubeId(url);\n if (youtube && /^[\\w-]+$/.test(youtube)) {\n const params = new URLSearchParams({ autoplay: '1', rel: '0' });\n const start = seconds(\n url.searchParams.get('t') ?? url.searchParams.get('start'),\n );\n if (start) params.set('start', String(start));\n return {\n provider: 'youtube',\n url: `https://www.youtube-nocookie.com/embed/${youtube}?${params}`,\n };\n }\n\n if (VIMEO_HOSTS.includes(url.hostname)) {\n const parts = url.pathname.split('/').filter(Boolean);\n const at = parts[0] === 'video' ? 1 : 0;\n const id = parts[at];\n if (id && /^\\d+$/.test(id)) {\n const params = new URLSearchParams({ autoplay: '1', dnt: '1' });\n const hash = url.searchParams.get('h') ?? parts[at + 1];\n if (hash && /^\\w+$/.test(hash)) params.set('h', hash);\n return {\n provider: 'vimeo',\n url: `https://player.vimeo.com/video/${id}?${params}`,\n };\n }\n }\n\n return { provider: 'file', url: src };\n}\n","import { html, LitElement, nothing, type PropertyValues } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { I18nController } from '@/__internal/i18n/i18n-controller.js';\nimport {\n parseVideoSource,\n type VideoProvider,\n type VideoSource,\n} from './video-source.js';\nimport styles from './video.scss';\n\nexport type { VideoProvider } from './video-source.js';\n\n/**\n * @label Video\n * @tag wc-video\n * @rawTag video\n *\n * @summary A video from YouTube, Vimeo or a file, that loads its player only when the person presses play.\n * @overview\n * <p>Video shows a poster with a play button. A YouTube or Vimeo player loads only on that click, so\n * the page makes no request to the video site until the person asks for the video: no cookies, no\n * tracking, and a faster page. YouTube plays through <code>youtube-nocookie.com</code> and Vimeo with\n * Do Not Track, and a line on the poster says where the video plays from.</p>\n * <p>Any other <code>src</code> is a video file, shown in the browser's own player with its\n * controls. Put <code><track></code> elements in the video for captions and subtitles.</p>\n * <p>The video keeps its <code>aspect-ratio</code> before and after it loads, so nothing on the page\n * moves.</p>\n *\n * @slot - `<track>` elements for a video file's captions and subtitles.\n *\n * @csspart base - The frame that holds the poster or the player.\n * @csspart play-button - The poster button that loads and plays the video.\n * @csspart player - The `<iframe>` or `<video>`.\n *\n * @cssprop --video-shape - Corner radius of the frame. Defaults to `--shape-corner-large`.\n *\n * @fires {CustomEvent} play - Dispatched when the person starts the video: the player loads, or the file starts playing.\n *\n * @example\n * ```html\n * <wc-video\n * src=\"https://www.youtube.com/watch?v=aqz-KE-bpKQ\"\n * label=\"Build a portal in ten minutes\"\n * duration=\"9:42\"\n * poster=\"/img/portal-video.webp\"\n * ></wc-video>\n * ```\n * @example\n * ```html\n * <wc-video src=\"/media/tour.mp4\" poster=\"/media/tour.webp\" label=\"Product tour\">\n * <track kind=\"captions\" src=\"/media/tour.en.vtt\" srclang=\"en\" label=\"English\" default />\n * </wc-video>\n * ```\n * @tags media\n */\n@IndividualComponent\nexport class Video extends LitElement {\n // ── Static ───────────────────────────────────────────────────────────────\n\n static styles = [styles];\n\n // ── Properties ───────────────────────────────────────────────────────────\n\n /** A YouTube or Vimeo link, or the URL of a video file. */\n @property({ reflect: true })\n src = '';\n\n /** An image shown before the video plays. Without one, the frame shows the label on a plain surface. */\n @property({ reflect: true })\n poster = '';\n\n /** The video's title: shown on the poster, and the name of the play button and the player. */\n @property({ reflect: true })\n label = '';\n\n /** The video's length as text, such as `9:42`, shown on the poster. */\n @property({ reflect: true })\n duration = '';\n\n /** The frame's width to height, as a CSS `aspect-ratio`. */\n @property({ attribute: 'aspect-ratio', reflect: true })\n aspectRatio = '16 / 9';\n\n // ── State ────────────────────────────────────────────────────────────────\n\n /** Whether the person pressed play, so the YouTube or Vimeo player is loaded. */\n @state() private loaded = false;\n\n // ── Queries ──────────────────────────────────────────────────────────────\n\n @query('.player') private readonly player?:\n | HTMLIFrameElement\n | HTMLVideoElement;\n\n // ── Private fields ───────────────────────────────────────────────────────\n\n private readonly i18n = new I18nController(this);\n\n /** Whether the next update moves focus to the player that just loaded. */\n private focusPlayer = false;\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n protected override willUpdate(changed: PropertyValues<this>) {\n super.willUpdate(changed);\n if (changed.has('src') && changed.get('src') !== undefined) {\n this.loaded = false;\n }\n }\n\n protected override updated(changed: PropertyValues<this>) {\n super.updated(changed);\n if (this.player instanceof HTMLVideoElement) this.syncTracks();\n if (this.focusPlayer && this.player) {\n this.focusPlayer = false;\n this.player.focus();\n }\n }\n\n // ── Public methods ───────────────────────────────────────────────────────\n\n /** Where the video plays from, read from `src`. */\n get provider(): VideoProvider {\n return this.source.provider;\n }\n\n /** Loads the player and starts the video, as the play button does. */\n play() {\n if (this.player instanceof HTMLVideoElement) {\n this.player.play().catch(() => {\n // The browser refused to play without a gesture; its controls are still there.\n });\n return;\n }\n if (this.loaded) return;\n this.loaded = true;\n this.focusPlayer = true;\n this.dispatchEvent(new CustomEvent('play'));\n }\n\n // ── Private methods ──────────────────────────────────────────────────────\n\n private get source(): VideoSource {\n return parseVideoSource(this.src);\n }\n\n private get name() {\n return this.label || this.i18n.t('video');\n }\n\n /** Copies the light DOM `<track>` children into the shadow `<video>`, where tracks must be. */\n private syncTracks() {\n const video = this.player as HTMLVideoElement;\n const tracks = Array.from(this.querySelectorAll(':scope > track'));\n const current = Array.from(video.querySelectorAll('track'));\n const same =\n tracks.length === current.length &&\n tracks.every((track, i) => track.isEqualNode(current[i]));\n if (same) return;\n current.forEach(track => track.remove());\n tracks.forEach(track => video.append(track.cloneNode(true)));\n }\n\n private readonly handleSlotChange = () => {\n if (this.player instanceof HTMLVideoElement) this.syncTracks();\n };\n\n private readonly handleVideoPlay = () => {\n this.dispatchEvent(new CustomEvent('play'));\n };\n\n // ── Render helpers ───────────────────────────────────────────────────────\n\n private renderFile(url: string) {\n return html`<video\n class=\"player\"\n part=\"player\"\n src=${url}\n poster=${this.poster || nothing}\n aria-label=${this.name}\n controls\n playsinline\n preload=\"none\"\n @play=${this.handleVideoPlay}\n ></video>`;\n }\n\n private renderEmbed(source: VideoSource) {\n if (this.loaded) {\n return html`<iframe\n class=\"player\"\n part=\"player\"\n src=${source.url}\n title=${this.name}\n allow=\"autoplay; encrypted-media; fullscreen; picture-in-picture\"\n allowfullscreen\n referrerpolicy=\"strict-origin-when-cross-origin\"\n ></iframe>`;\n }\n const from =\n source.provider === 'youtube'\n ? this.i18n.t('videoFromYouTube')\n : this.i18n.t('videoFromVimeo');\n return html`<button\n id=\"play\"\n class=\"play-button\"\n part=\"play-button\"\n type=\"button\"\n aria-label=${this.i18n.t('playVideo')(this.name)}\n @click=${() => this.play()}\n >\n ${this.poster\n ? html`<img class=\"poster\" src=${this.poster} alt=\"\" />`\n : nothing}\n ${this.label\n ? html`<span class=\"title\" aria-hidden=\"true\">${this.label}</span>`\n : nothing}\n <span class=\"play-icon\" aria-hidden=\"true\">\n <wc-icon name=\"play_arrow\"></wc-icon>\n </span>\n <span class=\"meta\" aria-hidden=\"true\">\n <span>${from}</span>\n ${this.duration ? html`<span>${this.duration}</span>` : nothing}\n </span>\n <wc-focus-ring class=\"focus-ring\" for=\"play\"></wc-focus-ring>\n </button>`;\n }\n\n // ── Render ───────────────────────────────────────────────────────────────\n\n render() {\n const { source } = this;\n return html`<div\n class=\"frame\"\n part=\"base\"\n style=${styleMap({ aspectRatio: this.aspectRatio })}\n >\n ${source.provider === 'file'\n ? this.renderFile(source.url)\n : this.renderEmbed(source)}\n </div>\n <slot hidden @slotchange=${this.handleSlotChange}></slot>`;\n }\n}\n"],"names":["LitElement","html","nothing","styleMap","styles","property","state","query"],"mappings":";;;;;;;AASA,MAAM,aAAa,GAAG;IACpB,aAAa;IACb,iBAAiB;IACjB,eAAe;IACf,mBAAmB;IACnB,sBAAsB;IACtB,0BAA0B;CAC3B;AAED,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,eAAe,EAAE,kBAAkB,CAAC;AAEtE;AACA,SAAS,OAAO,CAAC,IAAmB,EAAA;AAClC,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,OAAO,CAAC;AACnB,IAAA,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC;IAC3C,MAAM,KAAK,GAAG,qCAAqC,CAAC,IAAI,CAAC,IAAI,CAAC;AAC9D,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,CAAC;AACpB,IAAA,MAAM,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK;AAC3C,IAAA,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;AACtD;AAEA,SAAS,SAAS,CAAC,GAAQ,EAAA;AACzB,IAAA,IAAI,GAAG,CAAC,QAAQ,KAAK,UAAU;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAC,KAA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AA,EAAA,MAAA,CAAA;AAId,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE;AAC/B,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAKN,UAAA,CAAA;AAAhB,IAAAC,CAAK;AAA0B,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAIG,UAAA,CAAA;IAAlCC,CAAK,CAAC,SAAS;AAEK,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AApCV,KAAK,GAAA,UAAA,CAAA;IADjB;AACY,CAAA,EAAA,KAAK,CA2LjB;;;;"}
|
|
1
|
+
{"version":3,"file":"video-DPjOBk6I.js","sources":["../../src/video/video-source.ts","../../src/video/video.ts"],"sourcesContent":["/** Where a video plays from. */\nexport type VideoProvider = 'youtube' | 'vimeo' | 'file';\n\nexport interface VideoSource {\n provider: VideoProvider;\n /** The player URL to load on play, for YouTube and Vimeo; the file URL for a file. */\n url: string;\n}\n\nconst YOUTUBE_HOSTS = [\n 'youtube.com',\n 'www.youtube.com',\n 'm.youtube.com',\n 'music.youtube.com',\n 'youtube-nocookie.com',\n 'www.youtube-nocookie.com',\n];\n\nconst VIMEO_HOSTS = ['vimeo.com', 'www.vimeo.com', 'player.vimeo.com'];\n\n/** A YouTube time such as `90`, `90s` or `1m30s`, in whole seconds. */\nfunction seconds(time: string | null): number {\n if (!time) return 0;\n if (/^\\d+$/.test(time)) return Number(time);\n const match = /^(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?$/.exec(time);\n if (!match) return 0;\n const [, h = '0', m = '0', s = '0'] = match;\n return Number(h) * 3600 + Number(m) * 60 + Number(s);\n}\n\nfunction youtubeId(url: URL): string | undefined {\n if (url.hostname === 'youtu.be') return url.pathname.split('/')[1];\n if (!YOUTUBE_HOSTS.includes(url.hostname)) return undefined;\n if (url.pathname === '/watch') return url.searchParams.get('v') ?? undefined;\n const [, kind, id] = url.pathname.split('/');\n return ['embed', 'shorts', 'live', 'v'].includes(kind) ? id : undefined;\n}\n\n/**\n * Reads a video URL. YouTube links play through youtube-nocookie.com and Vimeo links with\n * `dnt=1`, so neither sets tracking cookies; any other URL is treated as a video file.\n */\nexport function parseVideoSource(src: string): VideoSource {\n let url: URL;\n try {\n url = new URL(src, document.baseURI);\n } catch {\n return { provider: 'file', url: src };\n }\n\n const youtube = youtubeId(url);\n if (youtube && /^[\\w-]+$/.test(youtube)) {\n const params = new URLSearchParams({ autoplay: '1', rel: '0' });\n const start = seconds(\n url.searchParams.get('t') ?? url.searchParams.get('start'),\n );\n if (start) params.set('start', String(start));\n return {\n provider: 'youtube',\n url: `https://www.youtube-nocookie.com/embed/${youtube}?${params}`,\n };\n }\n\n if (VIMEO_HOSTS.includes(url.hostname)) {\n const parts = url.pathname.split('/').filter(Boolean);\n const at = parts[0] === 'video' ? 1 : 0;\n const id = parts[at];\n if (id && /^\\d+$/.test(id)) {\n const params = new URLSearchParams({ autoplay: '1', dnt: '1' });\n const hash = url.searchParams.get('h') ?? parts[at + 1];\n if (hash && /^\\w+$/.test(hash)) params.set('h', hash);\n return {\n provider: 'vimeo',\n url: `https://player.vimeo.com/video/${id}?${params}`,\n };\n }\n }\n\n return { provider: 'file', url: src };\n}\n","import { html, LitElement, nothing, type PropertyValues } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { I18nController } from '@/__internal/i18n/i18n-controller.js';\nimport {\n parseVideoSource,\n type VideoProvider,\n type VideoSource,\n} from './video-source.js';\nimport styles from './video.scss';\n\nexport type { VideoProvider } from './video-source.js';\n\n/**\n * @label Video\n * @tag wc-video\n * @rawTag video\n *\n * @summary A video from YouTube, Vimeo or a file, that loads its player only when the person presses play.\n * @overview\n * <p>Video shows a poster with a play button. A YouTube or Vimeo player loads only on that click, so\n * the page makes no request to the video site until the person asks for the video: no cookies, no\n * tracking, and a faster page. YouTube plays through <code>youtube-nocookie.com</code> and Vimeo with\n * Do Not Track, and a line on the poster says where the video plays from.</p>\n * <p>Any other <code>src</code> is a video file, shown in the browser's own player with its\n * controls. Put <code><track></code> elements in the video for captions and subtitles.</p>\n * <p>The video keeps its <code>aspect-ratio</code> before and after it loads, so nothing on the page\n * moves.</p>\n *\n * @slot - `<track>` elements for a video file's captions and subtitles.\n *\n * @csspart base - The frame that holds the poster or the player.\n * @csspart play-button - The poster button that loads and plays the video.\n * @csspart player - The `<iframe>` or `<video>`.\n *\n * @cssprop --video-shape - Corner radius of the frame. Defaults to `--shape-corner-large`.\n *\n * @fires {CustomEvent} play - Dispatched when the person starts the video: the player loads, or the file starts playing.\n *\n * @example\n * ```html\n * <wc-video\n * src=\"https://www.youtube.com/watch?v=aqz-KE-bpKQ\"\n * label=\"Build a portal in ten minutes\"\n * duration=\"9:42\"\n * poster=\"/img/portal-video.webp\"\n * ></wc-video>\n * ```\n * @example\n * ```html\n * <wc-video src=\"/media/tour.mp4\" poster=\"/media/tour.webp\" label=\"Product tour\">\n * <track kind=\"captions\" src=\"/media/tour.en.vtt\" srclang=\"en\" label=\"English\" default />\n * </wc-video>\n * ```\n * @tags media\n */\n@IndividualComponent\nexport class Video extends LitElement {\n // ── Static ───────────────────────────────────────────────────────────────\n\n static styles = [styles];\n\n // ── Properties ───────────────────────────────────────────────────────────\n\n /** A YouTube or Vimeo link, or the URL of a video file. */\n @property({ reflect: true })\n src = '';\n\n /** An image shown before the video plays. Without one, the frame shows the label on a plain surface. */\n @property({ reflect: true })\n poster = '';\n\n /** The video's title: shown on the poster, and the name of the play button and the player. */\n @property({ reflect: true })\n label = '';\n\n /** The video's length as text, such as `9:42`, shown on the poster. */\n @property({ reflect: true })\n duration = '';\n\n /** The frame's width to height, as a CSS `aspect-ratio`. */\n @property({ attribute: 'aspect-ratio', reflect: true })\n aspectRatio = '16 / 9';\n\n // ── State ────────────────────────────────────────────────────────────────\n\n /** Whether the person pressed play, so the YouTube or Vimeo player is loaded. */\n @state() private loaded = false;\n\n // ── Queries ──────────────────────────────────────────────────────────────\n\n @query('.player') private readonly player?:\n | HTMLIFrameElement\n | HTMLVideoElement;\n\n // ── Private fields ───────────────────────────────────────────────────────\n\n private readonly i18n = new I18nController(this);\n\n /** Whether the next update moves focus to the player that just loaded. */\n private focusPlayer = false;\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n protected override willUpdate(changed: PropertyValues<this>) {\n super.willUpdate(changed);\n if (changed.has('src') && changed.get('src') !== undefined) {\n this.loaded = false;\n }\n }\n\n protected override updated(changed: PropertyValues<this>) {\n super.updated(changed);\n if (this.player instanceof HTMLVideoElement) this.syncTracks();\n if (this.focusPlayer && this.player) {\n this.focusPlayer = false;\n this.player.focus();\n }\n }\n\n // ── Public methods ───────────────────────────────────────────────────────\n\n /** Where the video plays from, read from `src`. */\n get provider(): VideoProvider {\n return this.source.provider;\n }\n\n /** Loads the player and starts the video, as the play button does. */\n play() {\n if (this.player instanceof HTMLVideoElement) {\n this.player.play().catch(() => {\n // The browser refused to play without a gesture; its controls are still there.\n });\n return;\n }\n if (this.loaded) return;\n this.loaded = true;\n this.focusPlayer = true;\n this.dispatchEvent(new CustomEvent('play'));\n }\n\n // ── Private methods ──────────────────────────────────────────────────────\n\n private get source(): VideoSource {\n return parseVideoSource(this.src);\n }\n\n private get name() {\n return this.label || this.i18n.t('video');\n }\n\n /** Copies the light DOM `<track>` children into the shadow `<video>`, where tracks must be. */\n private syncTracks() {\n const video = this.player as HTMLVideoElement;\n const tracks = Array.from(this.querySelectorAll(':scope > track'));\n const current = Array.from(video.querySelectorAll('track'));\n const same =\n tracks.length === current.length &&\n tracks.every((track, i) => track.isEqualNode(current[i]));\n if (same) return;\n current.forEach(track => track.remove());\n tracks.forEach(track => video.append(track.cloneNode(true)));\n }\n\n private readonly handleSlotChange = () => {\n if (this.player instanceof HTMLVideoElement) this.syncTracks();\n };\n\n private readonly handleVideoPlay = () => {\n this.dispatchEvent(new CustomEvent('play'));\n };\n\n // ── Render helpers ───────────────────────────────────────────────────────\n\n private renderFile(url: string) {\n return html`<video\n class=\"player\"\n part=\"player\"\n src=${url}\n poster=${this.poster || nothing}\n aria-label=${this.name}\n controls\n playsinline\n preload=\"none\"\n @play=${this.handleVideoPlay}\n ></video>`;\n }\n\n private renderEmbed(source: VideoSource) {\n if (this.loaded) {\n return html`<iframe\n class=\"player\"\n part=\"player\"\n src=${source.url}\n title=${this.name}\n allow=\"autoplay; encrypted-media; fullscreen; picture-in-picture\"\n allowfullscreen\n referrerpolicy=\"strict-origin-when-cross-origin\"\n ></iframe>`;\n }\n const from =\n source.provider === 'youtube'\n ? this.i18n.t('videoFromYouTube')\n : this.i18n.t('videoFromVimeo');\n return html`<button\n id=\"play\"\n class=\"play-button\"\n part=\"play-button\"\n type=\"button\"\n aria-label=${this.i18n.t('playVideo')(this.name)}\n @click=${() => this.play()}\n >\n ${this.poster\n ? html`<img class=\"poster\" src=${this.poster} alt=\"\" />`\n : nothing}\n ${this.label\n ? html`<span class=\"title\" aria-hidden=\"true\">${this.label}</span>`\n : nothing}\n <span class=\"play-icon\" aria-hidden=\"true\">\n <wc-icon name=\"play_arrow\"></wc-icon>\n </span>\n <span class=\"meta\" aria-hidden=\"true\">\n <span>${from}</span>\n ${this.duration ? html`<span>${this.duration}</span>` : nothing}\n </span>\n <wc-focus-ring class=\"focus-ring\" for=\"play\"></wc-focus-ring>\n </button>`;\n }\n\n // ── Render ───────────────────────────────────────────────────────────────\n\n render() {\n const { source } = this;\n return html`<div\n class=\"frame\"\n part=\"base\"\n style=${styleMap({ aspectRatio: this.aspectRatio })}\n >\n ${source.provider === 'file'\n ? this.renderFile(source.url)\n : this.renderEmbed(source)}\n </div>\n <slot hidden @slotchange=${this.handleSlotChange}></slot>`;\n }\n}\n"],"names":["LitElement","html","nothing","styleMap","styles","property","state","query"],"mappings":";;;;;;;A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AA,EAAA,MAAA,CAAA;AApCV,KAAK,GAAA,UAAA,CAAA;IADjB;AACY,CAAA,EAAA,KAAK,CA2LjB;;;;"}
|
package/dist/video.js
CHANGED
|
@@ -3,10 +3,10 @@ import './property-B2TG3KEE.js';
|
|
|
3
3
|
import './state-BCeDVCI9.js';
|
|
4
4
|
import './query-CHb9Ft_d.js';
|
|
5
5
|
import './style-map-CHOg6N_R.js';
|
|
6
|
-
import './i18n-controller-
|
|
7
|
-
export { V as Video } from './video-
|
|
6
|
+
import './i18n-controller-BTeChxE0.js';
|
|
7
|
+
export { V as Video } from './video-DPjOBk6I.js';
|
|
8
8
|
import './base-Cl6v8-BZ.js';
|
|
9
9
|
import './directive-ZPhl09Yt.js';
|
|
10
|
-
import './strings-
|
|
10
|
+
import './strings-DeiQWMd9.js';
|
|
11
11
|
import './locale-DEsJZCQG.js';
|
|
12
12
|
//# sourceMappingURL=video.js.map
|
package/dist/virtual-list.js
CHANGED
|
@@ -2,11 +2,11 @@ import { i, _ as __decorate, I as IndividualComponent, a as i$1, D, A, b } from
|
|
|
2
2
|
import { n } from './property-B2TG3KEE.js';
|
|
3
3
|
import { r } from './state-BCeDVCI9.js';
|
|
4
4
|
import { c } from './repeat-D_ERDRYT.js';
|
|
5
|
-
import { I as I18nController } from './i18n-controller-
|
|
5
|
+
import { I as I18nController } from './i18n-controller-BTeChxE0.js';
|
|
6
6
|
import { v as virtualWindow } from './virtual-window-5OYyIqZh.js';
|
|
7
7
|
import './directive-ZPhl09Yt.js';
|
|
8
8
|
import './directive-helpers-Bx3mu42O.js';
|
|
9
|
-
import './strings-
|
|
9
|
+
import './strings-DeiQWMd9.js';
|
|
10
10
|
import './locale-DEsJZCQG.js';
|
|
11
11
|
|
|
12
12
|
var css_248z = i`* {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i, _ as __decorate, I as IndividualComponent, a as i$1, A, b } from './IndividualComponent-BK7XZjE2.js';
|
|
2
2
|
import { n } from './property-B2TG3KEE.js';
|
|
3
3
|
import { e } from './class-map-NDIkZErE.js';
|
|
4
|
-
import { I as I18nController } from './i18n-controller-
|
|
4
|
+
import { I as I18nController } from './i18n-controller-BTeChxE0.js';
|
|
5
5
|
import { D as DiagramCanvasLink } from './canvas-link-CtgsALq4.js';
|
|
6
6
|
import { w as walk } from './workflow-model-CauduOG2.js';
|
|
7
7
|
import { f as formatDuration } from './workflow-format-BsyveyeC.js';
|
|
8
8
|
import './directive-ZPhl09Yt.js';
|
|
9
|
-
import './strings-
|
|
9
|
+
import './strings-DeiQWMd9.js';
|
|
10
10
|
import './locale-DEsJZCQG.js';
|
|
11
11
|
import './host-CZK7xhzh.js';
|
|
12
12
|
|
package/dist/workflow.js
CHANGED
|
@@ -3,15 +3,15 @@ import { n } from './property-B2TG3KEE.js';
|
|
|
3
3
|
import { r } from './state-BCeDVCI9.js';
|
|
4
4
|
import { e } from './query-CHb9Ft_d.js';
|
|
5
5
|
import { e as e$1 } from './class-map-NDIkZErE.js';
|
|
6
|
-
import { D as DiagramCanvasElement, p as prefersReducedMotion, a as animateOut } from './canvas-base-
|
|
6
|
+
import { D as DiagramCanvasElement, p as prefersReducedMotion, a as animateOut } from './canvas-base-BjiU3Ecl.js';
|
|
7
7
|
import { r as roundedPath } from './geometry-INg82Lxq.js';
|
|
8
8
|
import { H as History } from './history-YbTSQZHj.js';
|
|
9
9
|
import { W as WORKFLOW_LOGIC_STEPS, f as findStep, w as walk, i as isReached, r as replaceStep, a as removeStep, g as getList, c as createStep, b as allIds, d as insertStep, m as moveStep, l as listKey, e as cloneWithNewIds, h as contains, j as countInside, k as listTerminates, s as stepTerminates } from './workflow-model-CauduOG2.js';
|
|
10
10
|
import { f as formatDuration } from './workflow-format-BsyveyeC.js';
|
|
11
11
|
import './base-Cl6v8-BZ.js';
|
|
12
12
|
import './directive-ZPhl09Yt.js';
|
|
13
|
-
import './i18n-controller-
|
|
14
|
-
import './strings-
|
|
13
|
+
import './i18n-controller-BTeChxE0.js';
|
|
14
|
+
import './strings-DeiQWMd9.js';
|
|
15
15
|
import './locale-DEsJZCQG.js';
|
|
16
16
|
import './host-CZK7xhzh.js';
|
|
17
17
|
|
|
@@ -3,11 +3,11 @@ import { n } from './property-B2TG3KEE.js';
|
|
|
3
3
|
import { r } from './state-BCeDVCI9.js';
|
|
4
4
|
import { e } from './query-CHb9Ft_d.js';
|
|
5
5
|
import { e as e$1 } from './class-map-NDIkZErE.js';
|
|
6
|
-
import { I as I18nController } from './i18n-controller-
|
|
6
|
+
import { I as I18nController } from './i18n-controller-BTeChxE0.js';
|
|
7
7
|
import { M as MenuTriggerController } from './menu-trigger-controller-CEJq1ugC.js';
|
|
8
8
|
import './base-Cl6v8-BZ.js';
|
|
9
9
|
import './directive-ZPhl09Yt.js';
|
|
10
|
-
import './strings-
|
|
10
|
+
import './strings-DeiQWMd9.js';
|
|
11
11
|
import './locale-DEsJZCQG.js';
|
|
12
12
|
|
|
13
13
|
var css_248z = i`* {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -240,6 +240,7 @@ Every component below ships in 4.0, except the [AI](#ai) group, which arrives in
|
|
|
240
240
|
[Time picker](https://peacock.redvars.com/components/time-picker) `wc-time-picker` ·
|
|
241
241
|
[Date time field](https://peacock.redvars.com/components/datetime-field) `wc-datetime-field` ·
|
|
242
242
|
[Calendar](https://peacock.redvars.com/components/calendar) `wc-calendar` ·
|
|
243
|
+
[Calendar timeline](https://peacock.redvars.com/components/calendar-timeline) `wc-calendar-timeline` ·
|
|
243
244
|
[Clock](https://peacock.redvars.com/components/clock) `wc-clock` ·
|
|
244
245
|
[Relative time](https://peacock.redvars.com/components/relative-time) `wc-relative-time`
|
|
245
246
|
|
|
@@ -108,6 +108,31 @@ export const defaultStrings = {
|
|
|
108
108
|
previousPeriod: 'Previous',
|
|
109
109
|
nextPeriod: 'Next',
|
|
110
110
|
invalidView: 'Invalid view',
|
|
111
|
+
/** Title shown for a calendar event without one. */
|
|
112
|
+
calendarUntitled: '(no title)',
|
|
113
|
+
/** Title of the block that marks a new calendar event while it is drawn, until the app adds it. */
|
|
114
|
+
calendarNewEvent: 'New event',
|
|
115
|
+
/** Announced when an event is dragged to a new time, for example "Moved Standup to Nov 4, 2026, 10:00 – 10:30 AM." */
|
|
116
|
+
calendarEventMoved: (title: string, when: string): string =>
|
|
117
|
+
`Moved ${title} to ${when}.`,
|
|
118
|
+
/** Announced when an event's start or end is dragged, for example "Changed Standup to Nov 4, 2026, 9:00 – 10:30 AM." */
|
|
119
|
+
calendarEventResized: (title: string, when: string): string =>
|
|
120
|
+
`Changed ${title} to ${when}.`,
|
|
121
|
+
|
|
122
|
+
// ── Calendar timeline ────────────────────────────────────────────────────
|
|
123
|
+
/** Header of a calendar timeline's resource column, unless `resource-label` names it. */
|
|
124
|
+
calendarTimelineResources: 'Resources',
|
|
125
|
+
/** A calendar timeline without resources. */
|
|
126
|
+
calendarTimelineEmpty: 'No resources',
|
|
127
|
+
/** Resource count of a calendar timeline's group header; `count` is formatted, `n` the number for plural rules. */
|
|
128
|
+
calendarTimelineGroupCount: (count: string, n: number): string =>
|
|
129
|
+
n === 1 ? `${count} resource` : `${count} resources`,
|
|
130
|
+
/** Announced when an event is dragged to another resource's row, for example "Moved Standup to Room B, Nov 4, 2026, 10:00 – 10:30 AM." */
|
|
131
|
+
calendarTimelineEventMoved: (
|
|
132
|
+
title: string,
|
|
133
|
+
resource: string,
|
|
134
|
+
when: string,
|
|
135
|
+
): string => `Moved ${title} to ${resource}, ${when}.`,
|
|
111
136
|
|
|
112
137
|
// ── Overlays and feedback ────────────────────────────────────────────────
|
|
113
138
|
closeDialog: 'Close dialog',
|
|
@@ -45,6 +45,25 @@ export function weekStart(locale: string): WeekDay {
|
|
|
45
45
|
return 0;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* The weekend days of a locale (0 = Sunday), from `Intl.Locale` week info when available, else
|
|
50
|
+
* Saturday and Sunday.
|
|
51
|
+
*/
|
|
52
|
+
export function weekendDays(locale: string): WeekDay[] {
|
|
53
|
+
try {
|
|
54
|
+
const loc = new Intl.Locale(locale) as Intl.Locale & {
|
|
55
|
+
weekInfo?: { weekend: number[] };
|
|
56
|
+
getWeekInfo?: () => { weekend: number[] };
|
|
57
|
+
};
|
|
58
|
+
const info = loc.getWeekInfo?.() ?? loc.weekInfo;
|
|
59
|
+
// Week info numbers days 1 (Monday) to 7 (Sunday).
|
|
60
|
+
if (info?.weekend) return info.weekend.map(day => (day % 7) as WeekDay);
|
|
61
|
+
} catch {
|
|
62
|
+
// Unknown locale tag: fall through.
|
|
63
|
+
}
|
|
64
|
+
return [6, 0];
|
|
65
|
+
}
|
|
66
|
+
|
|
48
67
|
/** The locale's preferred hour cycle. */
|
|
49
68
|
export function localeHourCycle(locale: string): HourCycle {
|
|
50
69
|
const options = new Intl.DateTimeFormat(locale, {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The header `wc-calendar` and `wc-calendar-timeline` share (calendar-header.ts): Today, Previous and
|
|
2
|
+
// Next, the period shown, and the views as segmented buttons. Include it inside the element that
|
|
3
|
+
// holds the header.
|
|
4
|
+
|
|
5
|
+
@mixin styles {
|
|
6
|
+
.calendar-header-classic {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
padding: 0.75rem 1rem;
|
|
10
|
+
gap: 0.5rem;
|
|
11
|
+
|
|
12
|
+
.header-left {
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: 0.5rem;
|
|
15
|
+
align-items: center;
|
|
16
|
+
flex: 1;
|
|
17
|
+
|
|
18
|
+
.title {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
font-weight: 500;
|
|
22
|
+
font-size: 1rem;
|
|
23
|
+
color: var(--calendar-on-surface, var(--color-on-surface));
|
|
24
|
+
padding-inline-start: 0.5rem;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.header-right {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { startOfDay, endOfDay } from './utils.js';
|
|
1
|
+
import { startOfDay, endOfDay, isAllDayRange, lastDayOf } from './utils.js';
|
|
2
|
+
|
|
3
|
+
let lastId = 0;
|
|
2
4
|
|
|
3
5
|
export class BaseEvent {
|
|
6
|
+
/** Identifies the event within a layout pass. */
|
|
4
7
|
gid: string;
|
|
8
|
+
|
|
5
9
|
start: Date;
|
|
10
|
+
|
|
6
11
|
end: Date;
|
|
7
12
|
|
|
8
13
|
constructor(start: Date, end: Date) {
|
|
9
|
-
|
|
14
|
+
// A counter, not `crypto.randomUUID()`, which only exists in secure contexts.
|
|
15
|
+
lastId += 1;
|
|
16
|
+
this.gid = `calendar-event-${lastId}`;
|
|
10
17
|
this.start = start;
|
|
11
18
|
this.end = end;
|
|
12
19
|
}
|
|
@@ -15,6 +22,16 @@ export class BaseEvent {
|
|
|
15
22
|
return this.end.valueOf() - this.start.valueOf();
|
|
16
23
|
}
|
|
17
24
|
|
|
25
|
+
/** Whether the event belongs in the all-day row: it lasts a day or more, or midnight to midnight. */
|
|
26
|
+
isAllDay(): boolean {
|
|
27
|
+
return isAllDayRange(this.start, this.end);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The last day the event covers; `end` is exclusive, so an event ending at midnight ends the day before. */
|
|
31
|
+
lastDay(): Date {
|
|
32
|
+
return lastDayOf(this.start, this.end);
|
|
33
|
+
}
|
|
34
|
+
|
|
18
35
|
isOverlapping(event: BaseEvent): boolean {
|
|
19
36
|
let totalLength: number;
|
|
20
37
|
if (this.start.valueOf() <= event.start.valueOf()) {
|