@redvars/peacock 4.4.0 → 4.5.0
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 +554 -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
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as isAllDayRange, l as lastDayOf, b as startOfDay, e as endOfDay } from './utils-DcvLgexs.js';
|
|
2
2
|
|
|
3
|
+
let lastId = 0;
|
|
3
4
|
class BaseEvent {
|
|
4
5
|
constructor(start, end) {
|
|
5
|
-
|
|
6
|
+
// A counter, not `crypto.randomUUID()`, which only exists in secure contexts.
|
|
7
|
+
lastId += 1;
|
|
8
|
+
this.gid = `calendar-event-${lastId}`;
|
|
6
9
|
this.start = start;
|
|
7
10
|
this.end = end;
|
|
8
11
|
}
|
|
9
12
|
length() {
|
|
10
13
|
return this.end.valueOf() - this.start.valueOf();
|
|
11
14
|
}
|
|
15
|
+
/** Whether the event belongs in the all-day row: it lasts a day or more, or midnight to midnight. */
|
|
16
|
+
isAllDay() {
|
|
17
|
+
return isAllDayRange(this.start, this.end);
|
|
18
|
+
}
|
|
19
|
+
/** The last day the event covers; `end` is exclusive, so an event ending at midnight ends the day before. */
|
|
20
|
+
lastDay() {
|
|
21
|
+
return lastDayOf(this.start, this.end);
|
|
22
|
+
}
|
|
12
23
|
isOverlapping(event) {
|
|
13
24
|
let totalLength;
|
|
14
25
|
if (this.start.valueOf() <= event.start.valueOf()) {
|
|
@@ -49,5 +60,5 @@ class CalendarEvent extends BaseEvent {
|
|
|
49
60
|
}
|
|
50
61
|
}
|
|
51
62
|
|
|
52
|
-
export {
|
|
53
|
-
//# sourceMappingURL=calendar-event-
|
|
63
|
+
export { CalendarEvent as C };
|
|
64
|
+
//# sourceMappingURL=calendar-event-BQChlMXy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-event-BQChlMXy.js","sources":["../../src/calendar/base-event.ts","../../src/calendar/calendar-event.ts"],"sourcesContent":["import { startOfDay, endOfDay, isAllDayRange, lastDayOf } from './utils.js';\n\nlet lastId = 0;\n\nexport class BaseEvent {\n /** Identifies the event within a layout pass. */\n gid: string;\n\n start: Date;\n\n end: Date;\n\n constructor(start: Date, end: Date) {\n // A counter, not `crypto.randomUUID()`, which only exists in secure contexts.\n lastId += 1;\n this.gid = `calendar-event-${lastId}`;\n this.start = start;\n this.end = end;\n }\n\n length(): number {\n return this.end.valueOf() - this.start.valueOf();\n }\n\n /** Whether the event belongs in the all-day row: it lasts a day or more, or midnight to midnight. */\n isAllDay(): boolean {\n return isAllDayRange(this.start, this.end);\n }\n\n /** The last day the event covers; `end` is exclusive, so an event ending at midnight ends the day before. */\n lastDay(): Date {\n return lastDayOf(this.start, this.end);\n }\n\n isOverlapping(event: BaseEvent): boolean {\n let totalLength: number;\n if (this.start.valueOf() <= event.start.valueOf()) {\n totalLength = event.end.valueOf() - this.start.valueOf();\n } else {\n totalLength = this.end.valueOf() - event.start.valueOf();\n }\n return this.length() + event.length() >= totalLength;\n }\n\n isOverlappingWithoutTime(event: BaseEvent): boolean {\n const thisStartDay = startOfDay(this.start);\n const eventStartDay = startOfDay(event.start);\n const thisEndDay = endOfDay(this.end);\n const eventEndDay = endOfDay(event.end);\n\n let totalLength: number;\n if (thisStartDay.valueOf() <= eventStartDay.valueOf()) {\n totalLength = eventEndDay.valueOf() - thisStartDay.valueOf();\n } else {\n totalLength = thisEndDay.valueOf() - eventStartDay.valueOf();\n }\n return this.length() + event.length() >= totalLength;\n }\n\n isOverlappingWithDate(date: Date): boolean {\n return (\n this.start.valueOf() <= date.valueOf() &&\n this.end.valueOf() >= date.valueOf()\n );\n }\n}\n","import { BaseEvent } from './base-event.js';\n\nexport class CalendarEvent extends BaseEvent {\n data: any;\n title: string;\n color?: string;\n\n constructor(\n start: Date,\n end: Date,\n title: string,\n color: string | undefined,\n data: any,\n ) {\n super(start, end);\n this.data = data;\n if (color) this.color = color;\n this.title = title;\n }\n}\n"],"names":[],"mappings":";;AAEA,IAAI,MAAM,GAAG,CAAC;MAED,SAAS,CAAA;IAQpB,WAAA,CAAY,KAAW,EAAE,GAAS,EAAA;;QAEhC,MAAM,IAAI,CAAC;AACX,QAAA,IAAI,CAAC,GAAG,GAAG,CAAA,eAAA,EAAkB,MAAM,EAAE;AACrC,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;IAChB;IAEA,MAAM,GAAA;AACJ,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IAClD;;IAGA,QAAQ,GAAA;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC;IAC5C;;IAGA,OAAO,GAAA;QACL,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC;IACxC;AAEA,IAAA,aAAa,CAAC,KAAgB,EAAA;AAC5B,QAAA,IAAI,WAAmB;AACvB,QAAA,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE;AACjD,YAAA,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;QAC1D;aAAO;AACL,YAAA,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;QAC1D;QACA,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,WAAW;IACtD;AAEA,IAAA,wBAAwB,CAAC,KAAgB,EAAA;QACvC,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3C,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7C,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;QACrC,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC;AAEvC,QAAA,IAAI,WAAmB;QACvB,IAAI,YAAY,CAAC,OAAO,EAAE,IAAI,aAAa,CAAC,OAAO,EAAE,EAAE;YACrD,WAAW,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE;QAC9D;aAAO;YACL,WAAW,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE;QAC9D;QACA,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,WAAW;IACtD;AAEA,IAAA,qBAAqB,CAAC,IAAU,EAAA;QAC9B,QACE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE;YACtC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE;IAExC;AACD;;AC/DK,MAAO,aAAc,SAAQ,SAAS,CAAA;IAK1C,WAAA,CACE,KAAW,EACX,GAAS,EACT,KAAa,EACb,KAAyB,EACzB,IAAS,EAAA;AAET,QAAA,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC;AACjB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,KAAK;AAAE,YAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAC7B,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;IACpB;AACD;;;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { b } from './IndividualComponent-BK7XZjE2.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The header `wc-calendar` and `wc-calendar-timeline` share: a Today button, Previous and Next, the
|
|
5
|
+
* period shown (a polite live region) and the views as segmented buttons. Its styles are the
|
|
6
|
+
* `styles` mixin of `_calendar-header.scss`.
|
|
7
|
+
*/
|
|
8
|
+
function renderCalendarHeader(options) {
|
|
9
|
+
const onChange = (event) => {
|
|
10
|
+
if (event.detail.value)
|
|
11
|
+
options.onViewChange(event.detail.value);
|
|
12
|
+
};
|
|
13
|
+
return b `
|
|
14
|
+
<div class="calendar-header-classic">
|
|
15
|
+
<div class="header-left">
|
|
16
|
+
<wc-button
|
|
17
|
+
variant="outlined"
|
|
18
|
+
size="sm"
|
|
19
|
+
class="color-secondary"
|
|
20
|
+
@click=${options.onToday}
|
|
21
|
+
>
|
|
22
|
+
${options.labels.today}
|
|
23
|
+
</wc-button>
|
|
24
|
+
<wc-icon-button
|
|
25
|
+
variant="text"
|
|
26
|
+
size="sm"
|
|
27
|
+
class="color-secondary"
|
|
28
|
+
aria-label=${options.labels.previous}
|
|
29
|
+
@click=${options.onPrevious}
|
|
30
|
+
>
|
|
31
|
+
<wc-icon name="chevron_left"></wc-icon>
|
|
32
|
+
</wc-icon-button>
|
|
33
|
+
<wc-icon-button
|
|
34
|
+
variant="text"
|
|
35
|
+
size="sm"
|
|
36
|
+
class="color-secondary"
|
|
37
|
+
aria-label=${options.labels.next}
|
|
38
|
+
@click=${options.onNext}
|
|
39
|
+
>
|
|
40
|
+
<wc-icon name="chevron_right"></wc-icon>
|
|
41
|
+
</wc-icon-button>
|
|
42
|
+
<div class="title" aria-live="polite">${options.title}</div>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="header-right">
|
|
45
|
+
<wc-segmented-button-group @change=${onChange}>
|
|
46
|
+
${options.views.map(view => b `<wc-segmented-button
|
|
47
|
+
.value=${view.value}
|
|
48
|
+
?selected=${options.view === view.value}
|
|
49
|
+
>
|
|
50
|
+
${view.label}
|
|
51
|
+
</wc-segmented-button>`)}
|
|
52
|
+
</wc-segmented-button-group>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { renderCalendarHeader as r };
|
|
59
|
+
//# sourceMappingURL=calendar-header-DVrfThwr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-header-DVrfThwr.js","sources":["../../src/calendar/calendar-header.ts"],"sourcesContent":["import { html } from 'lit';\n\n/** One button of the header's view switcher. */\nexport interface CalendarHeaderView {\n value: string;\n label: string;\n}\n\n/** What the header shows, and what its controls do. */\nexport interface CalendarHeaderOptions {\n /** The period shown, read out when it changes. */\n title: string;\n views: CalendarHeaderView[];\n /** The `value` of the selected view. */\n view: string;\n labels: { today: string; previous: string; next: string };\n onToday: () => void;\n onPrevious: () => void;\n onNext: () => void;\n onViewChange: (value: string) => void;\n}\n\n/**\n * The header `wc-calendar` and `wc-calendar-timeline` share: a Today button, Previous and Next, the\n * period shown (a polite live region) and the views as segmented buttons. Its styles are the\n * `styles` mixin of `_calendar-header.scss`.\n */\nexport function renderCalendarHeader(options: CalendarHeaderOptions) {\n const onChange = (event: CustomEvent<{ value: string | null }>) => {\n if (event.detail.value) options.onViewChange(event.detail.value);\n };\n return html`\n <div class=\"calendar-header-classic\">\n <div class=\"header-left\">\n <wc-button\n variant=\"outlined\"\n size=\"sm\"\n class=\"color-secondary\"\n @click=${options.onToday}\n >\n ${options.labels.today}\n </wc-button>\n <wc-icon-button\n variant=\"text\"\n size=\"sm\"\n class=\"color-secondary\"\n aria-label=${options.labels.previous}\n @click=${options.onPrevious}\n >\n <wc-icon name=\"chevron_left\"></wc-icon>\n </wc-icon-button>\n <wc-icon-button\n variant=\"text\"\n size=\"sm\"\n class=\"color-secondary\"\n aria-label=${options.labels.next}\n @click=${options.onNext}\n >\n <wc-icon name=\"chevron_right\"></wc-icon>\n </wc-icon-button>\n <div class=\"title\" aria-live=\"polite\">${options.title}</div>\n </div>\n <div class=\"header-right\">\n <wc-segmented-button-group @change=${onChange}>\n ${options.views.map(\n view =>\n html`<wc-segmented-button\n .value=${view.value}\n ?selected=${options.view === view.value}\n >\n ${view.label}\n </wc-segmented-button>`,\n )}\n </wc-segmented-button-group>\n </div>\n </div>\n `;\n}\n"],"names":["html"],"mappings":";;AAsBA;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,OAA8B,EAAA;AACjE,IAAA,MAAM,QAAQ,GAAG,CAAC,KAA4C,KAAI;AAChE,QAAA,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK;YAAE,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;AAClE,IAAA,CAAC;AACD,IAAA,OAAOA,CAAI,CAAA;;;;;;;AAOM,iBAAA,EAAA,OAAO,CAAC,OAAO;;YAEtB,OAAO,CAAC,MAAM,CAAC,KAAK;;;;;;uBAMT,OAAO,CAAC,MAAM,CAAC,QAAQ;AAC3B,iBAAA,EAAA,OAAO,CAAC,UAAU;;;;;;;;uBAQd,OAAO,CAAC,MAAM,CAAC,IAAI;AACvB,iBAAA,EAAA,OAAO,CAAC,MAAM;;;;AAIe,8CAAA,EAAA,OAAO,CAAC,KAAK,CAAA;;;6CAGhB,QAAQ,CAAA;YACzC,OAAO,CAAC,KAAK,CAAC,GAAG,CACjB,IAAI,IACFA,CAAI,CAAA,CAAA;AACO,uBAAA,EAAA,IAAI,CAAC,KAAK;AACP,0BAAA,EAAA,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK;;AAErC,gBAAA,EAAA,IAAI,CAAC,KAAK;qCACS,CAC1B;;;;GAIR;AACH;;;;"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { i, _ as __decorate, I as IndividualComponent, a as i$1, b, A } from './IndividualComponent-BK7XZjE2.js';
|
|
2
2
|
import { n } from './property-B2TG3KEE.js';
|
|
3
3
|
import { r } from './state-BCeDVCI9.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { e } from './class-map-NDIkZErE.js';
|
|
5
|
+
import { w as calculateMonthRange, a as addDays, b as startOfDay, r as rangesOverlap, d as differenceInDays, n as nextDay, h as formatDate, l as lastDayOf, L as LONG_EVENT_PADDING, g as formatEventLabel, q as onActivateKey } from './utils-DcvLgexs.js';
|
|
6
|
+
import { C as CalendarDragController, n as nearestIndex, d as dragByDays } from './calendar-drag-IXMPZrTN.js';
|
|
7
|
+
import { M as MonthEventManager } from './event-manager-KGMT2x2Q.js';
|
|
7
8
|
import { r as resolveLocale } from './locale-DEsJZCQG.js';
|
|
9
|
+
import './directive-ZPhl09Yt.js';
|
|
10
|
+
import './calendar-event-BQChlMXy.js';
|
|
8
11
|
|
|
9
12
|
var css_248z = i`@charset "UTF-8";
|
|
10
13
|
* {
|
|
@@ -203,6 +206,78 @@ var css_248z = i`@charset "UTF-8";
|
|
|
203
206
|
}
|
|
204
207
|
.calendar-month-view .view-body .view-body-scroll .drawing-area .multi-day-section .multi-day-background .columns .column.today .column-header {
|
|
205
208
|
border-top-color: var(--color-primary);
|
|
209
|
+
}
|
|
210
|
+
.calendar-month-view .view-body .view-body-scroll .drawing-area .multi-day-section .multi-day-background .columns .column.drop-target {
|
|
211
|
+
background: color-mix(in srgb, var(--color-primary) 14%, transparent);
|
|
212
|
+
box-shadow: inset 0 0 0 1px var(--color-primary);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* ── Editing ── */
|
|
216
|
+
.calendar-month-view.addable .drawing-area {
|
|
217
|
+
user-select: none;
|
|
218
|
+
-webkit-touch-callout: none;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.calendar-month-view.dragging {
|
|
222
|
+
user-select: none;
|
|
223
|
+
}
|
|
224
|
+
.calendar-month-view.dragging .event {
|
|
225
|
+
pointer-events: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.calendar-month-view.drag-move {
|
|
229
|
+
cursor: grabbing;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.calendar-month-view.drag-resize-x {
|
|
233
|
+
cursor: ew-resize;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.event.editable {
|
|
237
|
+
cursor: grab;
|
|
238
|
+
user-select: none;
|
|
239
|
+
-webkit-touch-callout: none;
|
|
240
|
+
}
|
|
241
|
+
.event.drag-source {
|
|
242
|
+
opacity: 0.4;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.resize-handle {
|
|
246
|
+
position: absolute;
|
|
247
|
+
z-index: 1;
|
|
248
|
+
inset-block: 0;
|
|
249
|
+
inline-size: 0.375rem;
|
|
250
|
+
cursor: ew-resize;
|
|
251
|
+
}
|
|
252
|
+
.resize-handle.start {
|
|
253
|
+
inset-inline-start: 0;
|
|
254
|
+
}
|
|
255
|
+
.resize-handle.end {
|
|
256
|
+
inset-inline-end: 0;
|
|
257
|
+
}
|
|
258
|
+
.resize-handle::after {
|
|
259
|
+
content: "";
|
|
260
|
+
position: absolute;
|
|
261
|
+
inset: 0;
|
|
262
|
+
margin: auto;
|
|
263
|
+
inline-size: 0.125rem;
|
|
264
|
+
block-size: 0.875rem;
|
|
265
|
+
border-radius: var(--shape-corner-full);
|
|
266
|
+
background: currentColor;
|
|
267
|
+
opacity: 0;
|
|
268
|
+
transition: opacity 150ms ease;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.event.editable:hover .resize-handle::after,
|
|
272
|
+
.event.editable:focus-visible .resize-handle::after {
|
|
273
|
+
opacity: 0.6;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
@media (forced-colors: active) {
|
|
277
|
+
.column.drop-target {
|
|
278
|
+
outline: 2px solid Highlight;
|
|
279
|
+
outline-offset: -2px;
|
|
280
|
+
}
|
|
206
281
|
}`;
|
|
207
282
|
|
|
208
283
|
/**
|
|
@@ -219,8 +294,13 @@ var css_248z = i`@charset "UTF-8";
|
|
|
219
294
|
* gridcell per day labelled with its full date. Each event is owned (<code>aria-owns</code>) by the
|
|
220
295
|
* cell of the day it starts on in that week. Events are buttons labelled with their title and
|
|
221
296
|
* time, or notes that cannot be focused when <code>events-readonly</code> is set.</p>
|
|
297
|
+
* <p>With <code>editable</code>, events are dragged to other days and all-day events resized by
|
|
298
|
+
* their edges; with <code>addable</code>, dragging across days or clicking one asks for an
|
|
299
|
+
* all-day event. The days a drag covers are highlighted.</p>
|
|
222
300
|
*
|
|
223
301
|
* @fires event-click - Internal, does not bubble; `wc-calendar` re-fires it. Detail contains `{ event }`.
|
|
302
|
+
* @fires event-change - Internal, does not bubble; an event was dropped on new days. `wc-calendar` re-fires it.
|
|
303
|
+
* @fires event-add - Internal, does not bubble; days were drawn across or a day clicked. `wc-calendar` re-fires it.
|
|
224
304
|
*/
|
|
225
305
|
let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
226
306
|
constructor() {
|
|
@@ -231,6 +311,14 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
231
311
|
this.events = [];
|
|
232
312
|
/** Events are shown but cannot be clicked or focused. */
|
|
233
313
|
this.eventsReadonly = false;
|
|
314
|
+
/** Events can be moved to other days, and all-day events resized, by dragging. */
|
|
315
|
+
this.editable = false;
|
|
316
|
+
/** Dragging across days, or clicking one, asks for a new all-day event. */
|
|
317
|
+
this.addable = false;
|
|
318
|
+
/** A range waiting for its new event; its days are highlighted. */
|
|
319
|
+
this.placeholder = null;
|
|
320
|
+
/** Title shown for an event without one. */
|
|
321
|
+
this.untitledLabel = '(no title)';
|
|
234
322
|
/** Now, which marks today. */
|
|
235
323
|
this.currentTime = new Date();
|
|
236
324
|
/** A date in the month to show. */
|
|
@@ -248,39 +336,59 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
248
336
|
};
|
|
249
337
|
/** Event rows per week. */
|
|
250
338
|
this.weekDayEvents = [];
|
|
339
|
+
/** The drag in progress, where it would put its event. */
|
|
340
|
+
this._preview = null;
|
|
341
|
+
// ── Private fields
|
|
342
|
+
this._drag = new CalendarDragController(this, {
|
|
343
|
+
lift: () => this._blurFocused(),
|
|
344
|
+
move: (press, point) => this._follow(press, point),
|
|
345
|
+
drop: (press, point) => this._drop(press, point),
|
|
346
|
+
cancel: () => {
|
|
347
|
+
this._preview = null;
|
|
348
|
+
},
|
|
349
|
+
tap: press => this._tap(press),
|
|
350
|
+
scrollers: () => [this.renderRoot.querySelector('.view-body')],
|
|
351
|
+
});
|
|
251
352
|
}
|
|
252
353
|
// ── Lifecycle
|
|
253
354
|
connectedCallback() {
|
|
254
355
|
super.connectedCallback();
|
|
255
356
|
this._processEvents();
|
|
256
357
|
}
|
|
257
|
-
firstUpdated() {
|
|
258
|
-
const viewBody = this.renderRoot.querySelector('.view-body');
|
|
259
|
-
if (viewBody) {
|
|
260
|
-
const viewBodyHeight = viewBody.scrollHeight;
|
|
261
|
-
viewBody.scrollTo({
|
|
262
|
-
top: (getTimePercent(this.currentTime) / 100) * viewBodyHeight - 150,
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
358
|
willUpdate(changed) {
|
|
267
359
|
super.willUpdate(changed);
|
|
360
|
+
this._drag.enabled = this.addable || (this.editable && this._interactive);
|
|
268
361
|
if (changed.has('events') ||
|
|
269
362
|
changed.has('contextDate') ||
|
|
270
363
|
changed.has('weekStartsOn')) {
|
|
271
364
|
this._processEvents();
|
|
272
365
|
}
|
|
366
|
+
// A drag cannot outlive the month it started in, or editing being turned off.
|
|
367
|
+
if (this._drag.pressing &&
|
|
368
|
+
(changed.has('contextDate') ||
|
|
369
|
+
changed.has('weekStartsOn') ||
|
|
370
|
+
changed.has('editable') ||
|
|
371
|
+
changed.has('addable') ||
|
|
372
|
+
changed.has('eventsReadonly'))) {
|
|
373
|
+
this._drag.abort();
|
|
374
|
+
}
|
|
273
375
|
}
|
|
274
376
|
// ── Private methods
|
|
275
377
|
get _interactive() {
|
|
276
378
|
return !this.eventsReadonly;
|
|
277
379
|
}
|
|
380
|
+
/** Whether an event can be dragged: the view is editable and the event did not opt out. */
|
|
381
|
+
_canEdit(node) {
|
|
382
|
+
const data = node.data;
|
|
383
|
+
return this.editable && this._interactive && data?.editable !== false;
|
|
384
|
+
}
|
|
278
385
|
_processEvents() {
|
|
279
386
|
this.dateRange = calculateMonthRange(this.contextDate, this.weekStartsOn);
|
|
280
387
|
this.weekDayEvents = [];
|
|
281
388
|
for (let i = new Date(this.dateRange.startDate), j = 0; j < 6; i = addDays(i, 7), j += 1) {
|
|
389
|
+
const weekStart = startOfDay(i);
|
|
282
390
|
const manager = new MonthEventManager();
|
|
283
|
-
manager.addEvents(this.events.filter(event => event.
|
|
391
|
+
manager.addEvents(this.events.filter(event => rangesOverlap(event.start, event.end, weekStart, startOfDay(addDays(weekStart, 7)))));
|
|
284
392
|
manager.process();
|
|
285
393
|
this.weekDayEvents.push(manager.columns);
|
|
286
394
|
}
|
|
@@ -315,6 +423,12 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
315
423
|
_emitEventClick(event) {
|
|
316
424
|
this.dispatchEvent(new CustomEvent('event-click', { detail: { event } }));
|
|
317
425
|
}
|
|
426
|
+
_emitChange(detail) {
|
|
427
|
+
this.dispatchEvent(new CustomEvent('event-change', { detail }));
|
|
428
|
+
}
|
|
429
|
+
_emitAdd(detail) {
|
|
430
|
+
this.dispatchEvent(new CustomEvent('event-add', { detail }));
|
|
431
|
+
}
|
|
318
432
|
/** The locale day names and numbers are formatted in. */
|
|
319
433
|
get _locale() {
|
|
320
434
|
return resolveLocale(this.locale, this);
|
|
@@ -337,6 +451,126 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
337
451
|
.map(([k, v]) => `${k}:${v}`)
|
|
338
452
|
.join(';');
|
|
339
453
|
}
|
|
454
|
+
// ── Drag and drop
|
|
455
|
+
/** The day of the cell under, or nearest, a point. */
|
|
456
|
+
_dayAt(x, y) {
|
|
457
|
+
const cells = [
|
|
458
|
+
...this.renderRoot.querySelectorAll('[role="gridcell"]'),
|
|
459
|
+
];
|
|
460
|
+
const index = nearestIndex(cells, x, y);
|
|
461
|
+
return index < 0
|
|
462
|
+
? null
|
|
463
|
+
: startOfDay(addDays(this.dateRange.startDate, index));
|
|
464
|
+
}
|
|
465
|
+
_onEventPointerDown(event, node) {
|
|
466
|
+
if (!this._canEdit(node))
|
|
467
|
+
return;
|
|
468
|
+
const handle = event.target instanceof Element
|
|
469
|
+
? event.target.closest('[data-handle]')?.dataset.handle
|
|
470
|
+
: undefined;
|
|
471
|
+
let action = 'move';
|
|
472
|
+
if (handle === 'start')
|
|
473
|
+
action = 'resize-start';
|
|
474
|
+
else if (handle === 'end')
|
|
475
|
+
action = 'resize-end';
|
|
476
|
+
const day = this._dayAt(event.clientX, event.clientY) ?? startOfDay(node.start);
|
|
477
|
+
this._drag.start(event, { action, event: node, day });
|
|
478
|
+
}
|
|
479
|
+
_onAreaPointerDown(event) {
|
|
480
|
+
if (!this.addable || this._drag.pressing)
|
|
481
|
+
return;
|
|
482
|
+
// Presses on events are theirs, even on events that cannot be dragged.
|
|
483
|
+
const onEvent = event
|
|
484
|
+
.composedPath()
|
|
485
|
+
.some(target => target instanceof HTMLElement && target.classList.contains('event'));
|
|
486
|
+
if (onEvent)
|
|
487
|
+
return;
|
|
488
|
+
const day = this._dayAt(event.clientX, event.clientY);
|
|
489
|
+
if (!day)
|
|
490
|
+
return;
|
|
491
|
+
this._drag.start(event, { action: 'add', day });
|
|
492
|
+
}
|
|
493
|
+
_previewFor(press, point) {
|
|
494
|
+
const day = this._dayAt(point.x, point.y) ?? press.day;
|
|
495
|
+
const range = dragByDays(press.action, press.day, day, press.event);
|
|
496
|
+
if (!range)
|
|
497
|
+
return null;
|
|
498
|
+
return {
|
|
499
|
+
action: press.action,
|
|
500
|
+
data: press.event?.data,
|
|
501
|
+
...range,
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
_follow(press, point) {
|
|
505
|
+
const preview = this._previewFor(press, point);
|
|
506
|
+
if (!preview)
|
|
507
|
+
return;
|
|
508
|
+
const current = this._preview;
|
|
509
|
+
if (current &&
|
|
510
|
+
current.start.valueOf() === preview.start.valueOf() &&
|
|
511
|
+
current.end.valueOf() === preview.end.valueOf()) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
this._preview = preview;
|
|
515
|
+
}
|
|
516
|
+
_drop(press, point) {
|
|
517
|
+
const preview = this._previewFor(press, point) ?? this._preview;
|
|
518
|
+
this._preview = null;
|
|
519
|
+
if (!preview)
|
|
520
|
+
return;
|
|
521
|
+
const { start, end } = preview;
|
|
522
|
+
if (press.action === 'add') {
|
|
523
|
+
this._emitAdd({ start, end, allDay: true });
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
const { event } = press;
|
|
527
|
+
if (!event || !preview.data)
|
|
528
|
+
return;
|
|
529
|
+
if (start.valueOf() === event.start.valueOf() &&
|
|
530
|
+
end.valueOf() === event.end.valueOf()) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
this._emitChange({
|
|
534
|
+
event: preview.data,
|
|
535
|
+
start,
|
|
536
|
+
end,
|
|
537
|
+
action: press.action === 'move' ? 'move' : 'resize',
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
/** A click on a day adds an all-day event on it. */
|
|
541
|
+
_tap(press) {
|
|
542
|
+
if (press.action !== 'add')
|
|
543
|
+
return;
|
|
544
|
+
this._emitAdd({
|
|
545
|
+
start: press.day,
|
|
546
|
+
end: nextDay(press.day),
|
|
547
|
+
allDay: true,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Blurs the focused event when a drag starts. The drop redraws the events, and the element that
|
|
552
|
+
* held focus could then show another event, which Enter would open.
|
|
553
|
+
*/
|
|
554
|
+
_blurFocused() {
|
|
555
|
+
const active = this.renderRoot.activeElement;
|
|
556
|
+
if (active instanceof HTMLElement)
|
|
557
|
+
active.blur();
|
|
558
|
+
}
|
|
559
|
+
/** The days the drag in progress, or the placeholder, covers. */
|
|
560
|
+
_target() {
|
|
561
|
+
return this._preview ?? this.placeholder;
|
|
562
|
+
}
|
|
563
|
+
/** Classes of the view while a drag is in progress, which set the cursor. */
|
|
564
|
+
_rootClasses() {
|
|
565
|
+
const action = this._preview?.action;
|
|
566
|
+
return {
|
|
567
|
+
'calendar-month-view': true,
|
|
568
|
+
addable: this.addable,
|
|
569
|
+
dragging: !!action,
|
|
570
|
+
'drag-move': action === 'move',
|
|
571
|
+
'drag-resize-x': action === 'resize-start' || action === 'resize-end',
|
|
572
|
+
};
|
|
573
|
+
}
|
|
340
574
|
// ── Render helpers
|
|
341
575
|
_renderHeader() {
|
|
342
576
|
const locale = this._locale;
|
|
@@ -355,6 +589,9 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
355
589
|
_renderDayCells(sd, placed) {
|
|
356
590
|
const locale = this._locale;
|
|
357
591
|
const long = new Intl.DateTimeFormat(locale, { dateStyle: 'full' });
|
|
592
|
+
const target = this._target();
|
|
593
|
+
const first = target ? startOfDay(target.start).valueOf() : 0;
|
|
594
|
+
const last = target ? lastDayOf(target.start, target.end).valueOf() : -1;
|
|
358
595
|
const columns = [];
|
|
359
596
|
for (let i = new Date(sd), j = 0; j < 7; i = addDays(i, 1), j += 1) {
|
|
360
597
|
const owned = placed
|
|
@@ -362,9 +599,11 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
362
599
|
.map(p => p.id)
|
|
363
600
|
.join(' ');
|
|
364
601
|
const today = this._getDayClass(i).includes('today');
|
|
602
|
+
const day = startOfDay(i).valueOf();
|
|
603
|
+
const covered = day >= first && day <= last;
|
|
365
604
|
columns.push(b `
|
|
366
605
|
<div
|
|
367
|
-
class
|
|
606
|
+
class="${this._getDayClass(i)}${covered ? ' drop-target' : ''}"
|
|
368
607
|
role="gridcell"
|
|
369
608
|
aria-label=${long.format(i)}
|
|
370
609
|
aria-current=${today ? 'date' : A}
|
|
@@ -383,29 +622,60 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
383
622
|
_renderEvent(placed, weekStartDate) {
|
|
384
623
|
const { node, id } = placed;
|
|
385
624
|
const interactive = this._interactive;
|
|
625
|
+
const editable = this._canEdit(node);
|
|
626
|
+
const allDay = node.isAllDay();
|
|
627
|
+
const lastDay = node.lastDay();
|
|
628
|
+
const dragged = !!this._preview?.data && this._preview.data === node.data;
|
|
386
629
|
const evtStyles = {
|
|
387
|
-
|
|
388
|
-
width: `${this._getDatePercent(
|
|
630
|
+
'inset-inline-start': `${this._getDatePercent(node.start, weekStartDate) + LONG_EVENT_PADDING}%`,
|
|
631
|
+
width: `${this._getDatePercent(nextDay(lastDay), weekStartDate) - this._getDatePercent(node.start, weekStartDate) - 2 * LONG_EVENT_PADDING}%`,
|
|
389
632
|
...(node.color ? this._colorVars(node.color) : {}),
|
|
390
633
|
};
|
|
391
634
|
const activate = () => this._emitEventClick(node.data);
|
|
635
|
+
// All-day events resize by whichever of their edges falls in this week.
|
|
636
|
+
const weekEnd = startOfDay(addDays(weekStartDate, 6)).valueOf();
|
|
637
|
+
const handle = (edge) => {
|
|
638
|
+
if (!editable || !allDay)
|
|
639
|
+
return A;
|
|
640
|
+
const shown = edge === 'start'
|
|
641
|
+
? startOfDay(node.start).valueOf() >=
|
|
642
|
+
startOfDay(weekStartDate).valueOf()
|
|
643
|
+
: lastDay.valueOf() <= weekEnd;
|
|
644
|
+
return shown
|
|
645
|
+
? b `<div
|
|
646
|
+
class="resize-handle ${edge}"
|
|
647
|
+
data-handle=${edge}
|
|
648
|
+
aria-hidden="true"
|
|
649
|
+
></div>`
|
|
650
|
+
: A;
|
|
651
|
+
};
|
|
392
652
|
return b `
|
|
393
653
|
<div
|
|
394
654
|
id=${id}
|
|
395
|
-
class=${
|
|
655
|
+
class=${e({
|
|
656
|
+
event: true,
|
|
657
|
+
clickable: interactive,
|
|
658
|
+
editable,
|
|
659
|
+
'drag-source': dragged,
|
|
660
|
+
})}
|
|
396
661
|
style=${this._styleMap(evtStyles)}
|
|
397
662
|
role=${interactive ? 'button' : 'note'}
|
|
398
663
|
tabindex=${interactive ? '0' : A}
|
|
399
|
-
aria-label=${formatEventLabel(node.title, node.start, node.end, this._locale,
|
|
664
|
+
aria-label=${formatEventLabel(node.title, node.start, node.end, this._locale, allDay)}
|
|
400
665
|
@click=${() => {
|
|
401
666
|
if (interactive)
|
|
402
667
|
activate();
|
|
403
668
|
}}
|
|
404
669
|
@keydown=${interactive ? onActivateKey(activate) : A}
|
|
670
|
+
@pointerdown=${editable
|
|
671
|
+
? (event) => this._onEventPointerDown(event, node)
|
|
672
|
+
: A}
|
|
405
673
|
>
|
|
674
|
+
${handle('start')}
|
|
406
675
|
<div class="event-title" aria-hidden="true">
|
|
407
|
-
${node.title ||
|
|
676
|
+
${node.title || this.untitledLabel}
|
|
408
677
|
</div>
|
|
678
|
+
${handle('end')}
|
|
409
679
|
</div>
|
|
410
680
|
`;
|
|
411
681
|
}
|
|
@@ -451,7 +721,7 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
451
721
|
}).format(context);
|
|
452
722
|
return b `
|
|
453
723
|
<div
|
|
454
|
-
class
|
|
724
|
+
class=${e(this._rootClasses())}
|
|
455
725
|
role="grid"
|
|
456
726
|
aria-label=${label}
|
|
457
727
|
aria-readonly="true"
|
|
@@ -462,7 +732,12 @@ let CalendarMonthView = class CalendarMonthView extends i$1 {
|
|
|
462
732
|
</div>
|
|
463
733
|
<div class="view-body">
|
|
464
734
|
<div class="view-body-scroll">
|
|
465
|
-
<div
|
|
735
|
+
<div
|
|
736
|
+
class="drawing-area"
|
|
737
|
+
@pointerdown=${(event) => this._onAreaPointerDown(event)}
|
|
738
|
+
>
|
|
739
|
+
${this._renderWeeks()}
|
|
740
|
+
</div>
|
|
466
741
|
</div>
|
|
467
742
|
</div>
|
|
468
743
|
</div>
|
|
@@ -476,6 +751,18 @@ __decorate([
|
|
|
476
751
|
__decorate([
|
|
477
752
|
n({ type: Boolean, attribute: 'events-readonly' })
|
|
478
753
|
], CalendarMonthView.prototype, "eventsReadonly", void 0);
|
|
754
|
+
__decorate([
|
|
755
|
+
n({ type: Boolean })
|
|
756
|
+
], CalendarMonthView.prototype, "editable", void 0);
|
|
757
|
+
__decorate([
|
|
758
|
+
n({ type: Boolean })
|
|
759
|
+
], CalendarMonthView.prototype, "addable", void 0);
|
|
760
|
+
__decorate([
|
|
761
|
+
n({ attribute: false })
|
|
762
|
+
], CalendarMonthView.prototype, "placeholder", void 0);
|
|
763
|
+
__decorate([
|
|
764
|
+
n({ attribute: false })
|
|
765
|
+
], CalendarMonthView.prototype, "untitledLabel", void 0);
|
|
479
766
|
__decorate([
|
|
480
767
|
n({ type: Object, attribute: false })
|
|
481
768
|
], CalendarMonthView.prototype, "currentTime", void 0);
|
|
@@ -494,6 +781,9 @@ __decorate([
|
|
|
494
781
|
__decorate([
|
|
495
782
|
r()
|
|
496
783
|
], CalendarMonthView.prototype, "weekDayEvents", void 0);
|
|
784
|
+
__decorate([
|
|
785
|
+
r()
|
|
786
|
+
], CalendarMonthView.prototype, "_preview", void 0);
|
|
497
787
|
CalendarMonthView = __decorate([
|
|
498
788
|
IndividualComponent
|
|
499
789
|
], CalendarMonthView);
|