@mantine-vue/schedule 2.1.0 → 2.2.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/cjs/index.cjs +2228 -1
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +2220 -3
- package/esm/index.mjs.map +1 -1
- package/lib/components/ResourcesDayView/ResourcesDayView.d.ts +346 -0
- package/lib/components/ResourcesDayView/get-overlap-clusters/get-overlap-clusters.d.ts +2 -0
- package/lib/components/ResourcesDayView/get-resources-day-view-events/get-resources-day-view-events.d.ts +15 -0
- package/lib/components/ResourcesDayView/index.d.ts +3 -0
- package/lib/components/ResourcesMonthView/ResourcesMonthView.d.ts +279 -0
- package/lib/components/ResourcesMonthView/index.d.ts +1 -0
- package/lib/components/ResourcesSchedule/ResourcesSchedule.d.ts +201 -0
- package/lib/components/ResourcesSchedule/index.d.ts +1 -0
- package/lib/components/ResourcesWeekView/ResourcesWeekView.d.ts +412 -0
- package/lib/components/ResourcesWeekView/get-resources-week-view-events/get-resources-week-view-events.d.ts +21 -0
- package/lib/components/ResourcesWeekView/index.d.ts +2 -0
- package/lib/hooks/use-horizontal-event-resize.d.ts +200 -0
- package/lib/index.d.mts +4 -0
- package/lib/index.d.ts +4 -0
- package/lib/labels.d.ts +3 -0
- package/lib/types.d.ts +15 -0
- package/lib/utils/get-group-to-resource-id-map/get-group-to-resource-id-map.d.ts +2 -0
- package/lib/utils/get-ordered-resources/get-ordered-resources.d.ts +17 -0
- package/lib/utils/handle-resources-grid-key-down/handle-resources-grid-key-down.d.ts +8 -0
- package/lib/utils/index.d.ts +5 -0
- package/package.json +4 -4
- package/styles.css +933 -0
- package/styles.layer.css +933 -0
package/cjs/index.cjs
CHANGED
|
@@ -50,7 +50,10 @@ var DEFAULT_SCHEDULE_LABELS = {
|
|
|
50
50
|
switchToYearView: "Switch to year view",
|
|
51
51
|
viewSelectLabel: "Calendar view",
|
|
52
52
|
noEvents: "No events",
|
|
53
|
-
moreLabel: (hiddenEventsCount) => `+${hiddenEventsCount} more
|
|
53
|
+
moreLabel: (hiddenEventsCount) => `+${hiddenEventsCount} more`,
|
|
54
|
+
resource: "Resource",
|
|
55
|
+
resources: "Resources",
|
|
56
|
+
resourceSlot: "Resource time slot"
|
|
54
57
|
};
|
|
55
58
|
function getLabel(key, override) {
|
|
56
59
|
if (override) return {
|
|
@@ -633,6 +636,85 @@ function expandRecurringEvents({ events, rangeStart, rangeEnd, expansionLimit =
|
|
|
633
636
|
return output;
|
|
634
637
|
}
|
|
635
638
|
//#endregion
|
|
639
|
+
//#region src/utils/get-ordered-resources/get-ordered-resources.ts
|
|
640
|
+
function getOrderedResources(resources, groups) {
|
|
641
|
+
if (!groups?.length) return {
|
|
642
|
+
orderedResources: resources,
|
|
643
|
+
groupRanges: [],
|
|
644
|
+
resourceGroupMap: []
|
|
645
|
+
};
|
|
646
|
+
const resourceMap = new Map(resources.map((resource) => [resource.id, resource]));
|
|
647
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
648
|
+
const orderedResources = [];
|
|
649
|
+
const groupRanges = [];
|
|
650
|
+
groups.forEach((group) => {
|
|
651
|
+
const startIndex = orderedResources.length;
|
|
652
|
+
group.resourceIds.forEach((id) => {
|
|
653
|
+
const resource = resourceMap.get(id);
|
|
654
|
+
if (resource && !usedIds.has(id)) {
|
|
655
|
+
orderedResources.push(resource);
|
|
656
|
+
usedIds.add(id);
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
const count = orderedResources.length - startIndex;
|
|
660
|
+
if (count) groupRanges.push({
|
|
661
|
+
group,
|
|
662
|
+
startIndex,
|
|
663
|
+
count
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
resources.forEach((resource) => {
|
|
667
|
+
if (!usedIds.has(resource.id)) orderedResources.push(resource);
|
|
668
|
+
});
|
|
669
|
+
const resourceGroupMap = Array(orderedResources.length).fill(null);
|
|
670
|
+
groupRanges.forEach(({ group, startIndex, count }) => {
|
|
671
|
+
for (let index = 0; index < count; index += 1) {
|
|
672
|
+
const position = count === 1 ? "only" : index === 0 ? "first" : index === count - 1 ? "last" : "middle";
|
|
673
|
+
resourceGroupMap[startIndex + index] = {
|
|
674
|
+
group,
|
|
675
|
+
position,
|
|
676
|
+
count
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
return {
|
|
681
|
+
orderedResources,
|
|
682
|
+
groupRanges,
|
|
683
|
+
resourceGroupMap
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region src/utils/get-group-to-resource-id-map/get-group-to-resource-id-map.ts
|
|
688
|
+
function getGroupToResourceIdMap(resources) {
|
|
689
|
+
return new Map(resources.map((resource) => [String(resource.id), resource.id]));
|
|
690
|
+
}
|
|
691
|
+
//#endregion
|
|
692
|
+
//#region src/utils/handle-resources-grid-key-down/handle-resources-grid-key-down.ts
|
|
693
|
+
function handleResourcesGridKeyDown({ controls, resourceIndex, slotIndex, event }) {
|
|
694
|
+
const delta = {
|
|
695
|
+
ArrowLeft: [0, -1],
|
|
696
|
+
ArrowRight: [0, 1],
|
|
697
|
+
ArrowUp: [-1, 0],
|
|
698
|
+
ArrowDown: [1, 0]
|
|
699
|
+
}[event.key];
|
|
700
|
+
if (!delta) return;
|
|
701
|
+
event.preventDefault();
|
|
702
|
+
let row = resourceIndex + delta[0];
|
|
703
|
+
let column = slotIndex + delta[1];
|
|
704
|
+
while (row >= 0 && row < controls.length) {
|
|
705
|
+
const rowControls = controls[row] || [];
|
|
706
|
+
if (delta[0] !== 0) column = Math.min(column, rowControls.length - 1);
|
|
707
|
+
if (column < 0 || column >= rowControls.length) return;
|
|
708
|
+
const control = rowControls[column];
|
|
709
|
+
if (control && !control.disabled && !control.hasAttribute("data-hidden")) {
|
|
710
|
+
control.focus();
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
row += delta[0];
|
|
714
|
+
column += delta[1];
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
//#endregion
|
|
636
718
|
//#region src/hooks/use-event-resize.ts
|
|
637
719
|
function useEventResize(input) {
|
|
638
720
|
const resizeState = (0, vue.ref)(null);
|
|
@@ -4113,6 +4195,2141 @@ var Schedule = (0, vue.defineComponent)({
|
|
|
4113
4195
|
}
|
|
4114
4196
|
});
|
|
4115
4197
|
//#endregion
|
|
4198
|
+
//#region src/hooks/use-horizontal-event-resize.ts
|
|
4199
|
+
function useHorizontalEventResize(input) {
|
|
4200
|
+
const state = (0, vue.ref)(null);
|
|
4201
|
+
let justResized = false;
|
|
4202
|
+
let savedUserSelect = "";
|
|
4203
|
+
const metrics = () => {
|
|
4204
|
+
const start = parseTimeString(input.startTime());
|
|
4205
|
+
const end = parseTimeString(input.endTime());
|
|
4206
|
+
const startMinutes = start.hours * 60 + start.minutes;
|
|
4207
|
+
const literalRange = end.hours * 60 + end.minutes - startMinutes;
|
|
4208
|
+
const interval = clampIntervalMinutes(input.intervalMinutes());
|
|
4209
|
+
const total = Math.ceil(literalRange / interval) * interval;
|
|
4210
|
+
return {
|
|
4211
|
+
startMinutes,
|
|
4212
|
+
literalRange,
|
|
4213
|
+
interval,
|
|
4214
|
+
total,
|
|
4215
|
+
minWidth: interval / total * 100
|
|
4216
|
+
};
|
|
4217
|
+
};
|
|
4218
|
+
const snap = (percent) => {
|
|
4219
|
+
const { literalRange, interval, total } = metrics();
|
|
4220
|
+
return Math.max(0, Math.min(literalRange, Math.round(percent / 100 * total / interval) * interval)) / total * 100;
|
|
4221
|
+
};
|
|
4222
|
+
const toDateTime = (percent, date) => {
|
|
4223
|
+
const { startMinutes, total } = metrics();
|
|
4224
|
+
const minutes = startMinutes + Math.round(snap(percent) / 100 * total);
|
|
4225
|
+
return `${date} ${String(Math.floor(minutes / 60)).padStart(2, "0")}:${String(minutes % 60).padStart(2, "0")}:00`;
|
|
4226
|
+
};
|
|
4227
|
+
const move = (event) => {
|
|
4228
|
+
if (!state.value) return;
|
|
4229
|
+
const rect = state.value.container.getBoundingClientRect();
|
|
4230
|
+
const dayWidth = rect.width / state.value.dayCount;
|
|
4231
|
+
const point = snap((event.clientX - rect.left - state.value.dayIndex * dayWidth) / dayWidth * 100);
|
|
4232
|
+
const { minWidth } = metrics();
|
|
4233
|
+
const current = state.value;
|
|
4234
|
+
if (current.edge === "end") current.currentWidth = Math.max(minWidth, point - current.originalLeft);
|
|
4235
|
+
else {
|
|
4236
|
+
const right = current.originalLeft + current.originalWidth;
|
|
4237
|
+
current.currentLeft = Math.min(point, right - minWidth);
|
|
4238
|
+
current.currentWidth = right - current.currentLeft;
|
|
4239
|
+
}
|
|
4240
|
+
state.value = { ...current };
|
|
4241
|
+
};
|
|
4242
|
+
const cleanup = () => {
|
|
4243
|
+
document.removeEventListener("pointermove", move);
|
|
4244
|
+
document.removeEventListener("pointerup", finish);
|
|
4245
|
+
document.body.style.userSelect = savedUserSelect;
|
|
4246
|
+
};
|
|
4247
|
+
const finish = () => {
|
|
4248
|
+
const current = state.value;
|
|
4249
|
+
if (current && (current.currentLeft !== current.originalLeft || current.currentWidth !== current.originalWidth)) input.onEventResize()?.({
|
|
4250
|
+
eventId: current.event.id,
|
|
4251
|
+
newStart: current.edge === "start" ? toDateTime(current.currentLeft, current.eventDate) : current.originalStart,
|
|
4252
|
+
newEnd: current.edge === "end" ? toDateTime(current.currentLeft + current.currentWidth, current.eventDate) : current.originalEnd,
|
|
4253
|
+
event: current.event
|
|
4254
|
+
});
|
|
4255
|
+
state.value = null;
|
|
4256
|
+
cleanup();
|
|
4257
|
+
justResized = true;
|
|
4258
|
+
requestAnimationFrame(() => justResized = false);
|
|
4259
|
+
};
|
|
4260
|
+
const handleResizeStart = (params) => {
|
|
4261
|
+
if (!input.enabled() || input.mode() === "static") return;
|
|
4262
|
+
params.pointerEvent.preventDefault();
|
|
4263
|
+
params.pointerEvent.stopPropagation();
|
|
4264
|
+
state.value = {
|
|
4265
|
+
...params,
|
|
4266
|
+
currentLeft: params.originalLeft,
|
|
4267
|
+
currentWidth: params.originalWidth,
|
|
4268
|
+
originalStart: (0, dayjs.default)(params.event.start).format("YYYY-MM-DD HH:mm:ss"),
|
|
4269
|
+
originalEnd: (0, dayjs.default)(params.event.end).format("YYYY-MM-DD HH:mm:ss"),
|
|
4270
|
+
dayIndex: params.dayIndex ?? 0,
|
|
4271
|
+
dayCount: params.dayCount ?? 1
|
|
4272
|
+
};
|
|
4273
|
+
savedUserSelect = document.body.style.userSelect;
|
|
4274
|
+
document.body.style.userSelect = "none";
|
|
4275
|
+
document.addEventListener("pointermove", move);
|
|
4276
|
+
document.addEventListener("pointerup", finish);
|
|
4277
|
+
};
|
|
4278
|
+
(0, vue.onBeforeUnmount)(cleanup);
|
|
4279
|
+
return {
|
|
4280
|
+
state,
|
|
4281
|
+
handleResizeStart,
|
|
4282
|
+
getResizePosition: (id) => state.value?.event.id === id ? {
|
|
4283
|
+
left: state.value.currentLeft,
|
|
4284
|
+
width: state.value.currentWidth
|
|
4285
|
+
} : null,
|
|
4286
|
+
isResizableEvent: (event) => input.enabled() && input.mode() !== "static" && event.display !== "background" && (input.canResizeEvent()?.(event) ?? true),
|
|
4287
|
+
wasResizing: () => justResized
|
|
4288
|
+
};
|
|
4289
|
+
}
|
|
4290
|
+
//#endregion
|
|
4291
|
+
//#region src/components/ResourcesDayView/get-overlap-clusters/get-overlap-clusters.ts
|
|
4292
|
+
function getOverlapClusters(events) {
|
|
4293
|
+
const sorted = [...events].sort((a, b) => a.position.top - b.position.top);
|
|
4294
|
+
const clusters = [];
|
|
4295
|
+
let current = [];
|
|
4296
|
+
let end = -1;
|
|
4297
|
+
sorted.forEach((event) => {
|
|
4298
|
+
if (current.length && event.position.top >= end) {
|
|
4299
|
+
clusters.push(current);
|
|
4300
|
+
current = [];
|
|
4301
|
+
end = -1;
|
|
4302
|
+
}
|
|
4303
|
+
current.push(event);
|
|
4304
|
+
end = Math.max(end, event.position.top + event.position.height);
|
|
4305
|
+
});
|
|
4306
|
+
if (current.length) clusters.push(current);
|
|
4307
|
+
return clusters;
|
|
4308
|
+
}
|
|
4309
|
+
//#endregion
|
|
4310
|
+
//#region src/components/ResourcesDayView/get-resources-day-view-events/get-resources-day-view-events.ts
|
|
4311
|
+
function getResourcesDayViewEvents({ events, resources, date, startTime, endTime, intervalMinutes }) {
|
|
4312
|
+
const result = {
|
|
4313
|
+
regularEvents: {},
|
|
4314
|
+
allDayEvents: {},
|
|
4315
|
+
backgroundTimedEvents: {},
|
|
4316
|
+
backgroundAllDayEvents: {}
|
|
4317
|
+
};
|
|
4318
|
+
resources.forEach((resource) => {
|
|
4319
|
+
result.regularEvents[resource.id] = [];
|
|
4320
|
+
result.allDayEvents[resource.id] = [];
|
|
4321
|
+
result.backgroundTimedEvents[resource.id] = [];
|
|
4322
|
+
result.backgroundAllDayEvents[resource.id] = [];
|
|
4323
|
+
});
|
|
4324
|
+
if (!events) return result;
|
|
4325
|
+
const dayStart = (0, dayjs.default)(date).startOf("day");
|
|
4326
|
+
const dayEnd = (0, dayjs.default)(date).endOf("day");
|
|
4327
|
+
const regular = new Map(resources.map((resource) => [resource.id, []]));
|
|
4328
|
+
const background = new Map(resources.map((resource) => [resource.id, []]));
|
|
4329
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4330
|
+
events.forEach((event) => {
|
|
4331
|
+
if (event.resourceId === void 0 || !regular.has(event.resourceId)) return;
|
|
4332
|
+
const eventStart = (0, dayjs.default)(event.start);
|
|
4333
|
+
const eventEnd = (0, dayjs.default)(event.end);
|
|
4334
|
+
const startsOnDay = eventStart.isSame(dayStart, "day");
|
|
4335
|
+
if (!startsOnDay && !(eventStart.isBefore(dayEnd) && eventEnd.isAfter(dayStart))) return;
|
|
4336
|
+
if (startsOnDay && !isEventInTimeRange({
|
|
4337
|
+
event,
|
|
4338
|
+
startTime,
|
|
4339
|
+
endTime
|
|
4340
|
+
})) return;
|
|
4341
|
+
if (seen.has(event.id)) throw new Error(`[@mantine/schedule] ResourcesDayView: Duplicated event ids found: ${event.id}`);
|
|
4342
|
+
seen.add(event.id);
|
|
4343
|
+
const validated = validateEvent(event);
|
|
4344
|
+
if (event.display === "background") {
|
|
4345
|
+
background.get(event.resourceId).push(validated);
|
|
4346
|
+
return;
|
|
4347
|
+
}
|
|
4348
|
+
const clipped = startsOnDay ? validated : {
|
|
4349
|
+
...validated,
|
|
4350
|
+
start: (eventStart.isBefore(dayStart) ? dayStart : eventStart).format("YYYY-MM-DD HH:mm:ss"),
|
|
4351
|
+
end: (eventEnd.isAfter(dayEnd) ? dayEnd : eventEnd).format("YYYY-MM-DD HH:mm:ss")
|
|
4352
|
+
};
|
|
4353
|
+
if (isEventInTimeRange({
|
|
4354
|
+
event: clipped,
|
|
4355
|
+
startTime,
|
|
4356
|
+
endTime
|
|
4357
|
+
})) regular.get(event.resourceId).push(clipped);
|
|
4358
|
+
});
|
|
4359
|
+
resources.forEach((resource) => {
|
|
4360
|
+
getDayPositionedEvents({
|
|
4361
|
+
events: regular.get(resource.id),
|
|
4362
|
+
startTime,
|
|
4363
|
+
endTime,
|
|
4364
|
+
date,
|
|
4365
|
+
intervalMinutes
|
|
4366
|
+
}).forEach((event) => {
|
|
4367
|
+
(event.position.allDay ? result.allDayEvents : result.regularEvents)[resource.id].push(event);
|
|
4368
|
+
});
|
|
4369
|
+
background.get(resource.id).forEach((event) => {
|
|
4370
|
+
const clippedStart = (0, dayjs.default)(event.start).isBefore(dayStart) ? dayStart : (0, dayjs.default)(event.start);
|
|
4371
|
+
const clippedEnd = (0, dayjs.default)(event.end).isAfter(dayEnd) ? dayEnd : (0, dayjs.default)(event.end);
|
|
4372
|
+
const clipped = {
|
|
4373
|
+
...event,
|
|
4374
|
+
start: clippedStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
4375
|
+
end: clippedEnd.format("YYYY-MM-DD HH:mm:ss")
|
|
4376
|
+
};
|
|
4377
|
+
const allDay = isAllDayEvent({
|
|
4378
|
+
event: clipped,
|
|
4379
|
+
date
|
|
4380
|
+
});
|
|
4381
|
+
const position = allDay ? {
|
|
4382
|
+
top: 0,
|
|
4383
|
+
height: 100
|
|
4384
|
+
} : getDayPosition({
|
|
4385
|
+
event: clipped,
|
|
4386
|
+
startTime,
|
|
4387
|
+
endTime,
|
|
4388
|
+
intervalMinutes
|
|
4389
|
+
});
|
|
4390
|
+
if (!allDay && position.height <= 0) return;
|
|
4391
|
+
(allDay ? result.backgroundAllDayEvents : result.backgroundTimedEvents)[resource.id].push({
|
|
4392
|
+
...event,
|
|
4393
|
+
position: {
|
|
4394
|
+
...position,
|
|
4395
|
+
allDay,
|
|
4396
|
+
width: 100,
|
|
4397
|
+
offset: 0,
|
|
4398
|
+
column: 0,
|
|
4399
|
+
overlaps: 1
|
|
4400
|
+
}
|
|
4401
|
+
});
|
|
4402
|
+
});
|
|
4403
|
+
});
|
|
4404
|
+
return result;
|
|
4405
|
+
}
|
|
4406
|
+
var ResourcesDayView_module_default = {
|
|
4407
|
+
resourcesDayView: "_resourcesDayView_7b9z2_1",
|
|
4408
|
+
resourcesDayViewRoot: "_resourcesDayViewRoot_7b9z2_22",
|
|
4409
|
+
resourcesDayViewScrollArea: "_resourcesDayViewScrollArea_7b9z2_30",
|
|
4410
|
+
resourcesDayViewInner: "_resourcesDayViewInner_7b9z2_39",
|
|
4411
|
+
resourcesDayViewTimeLabelsRow: "_resourcesDayViewTimeLabelsRow_7b9z2_44",
|
|
4412
|
+
resourcesDayViewCorner: "_resourcesDayViewCorner_7b9z2_57",
|
|
4413
|
+
resourcesDayViewTimeLabel: "_resourcesDayViewTimeLabel_7b9z2_44",
|
|
4414
|
+
resourcesDayViewRow: "_resourcesDayViewRow_7b9z2_96",
|
|
4415
|
+
resourcesDayViewResourceLabel: "_resourcesDayViewResourceLabel_7b9z2_100",
|
|
4416
|
+
resourcesDayViewGroupColumn: "_resourcesDayViewGroupColumn_7b9z2_124",
|
|
4417
|
+
resourcesDayViewGroupColumnEmpty: "_resourcesDayViewGroupColumnEmpty_7b9z2_125",
|
|
4418
|
+
resourcesDayViewRowSlots: "_resourcesDayViewRowSlots_7b9z2_153",
|
|
4419
|
+
resourcesDayViewRowSlot: "_resourcesDayViewRowSlot_7b9z2_153",
|
|
4420
|
+
resourcesDayViewCurrentTimeIndicator: "_resourcesDayViewCurrentTimeIndicator_7b9z2_231",
|
|
4421
|
+
resourcesDayViewCurrentTimeIndicatorLine: "_resourcesDayViewCurrentTimeIndicatorLine_7b9z2_243",
|
|
4422
|
+
resourcesDayViewCurrentTimeIndicatorThumb: "_resourcesDayViewCurrentTimeIndicatorThumb_7b9z2_249",
|
|
4423
|
+
resourcesDayViewCurrentTimeIndicatorTimeBubble: "_resourcesDayViewCurrentTimeIndicatorTimeBubble_7b9z2_259",
|
|
4424
|
+
resourcesDayViewBackgroundEvent: "_resourcesDayViewBackgroundEvent_7b9z2_278",
|
|
4425
|
+
resourcesDayViewAllDayEvent: "_resourcesDayViewAllDayEvent_7b9z2_290",
|
|
4426
|
+
resourcesDayViewEventWrapper: "_resourcesDayViewEventWrapper_7b9z2_296",
|
|
4427
|
+
resourcesDayViewResizeHandle: "_resourcesDayViewResizeHandle_7b9z2_300"
|
|
4428
|
+
};
|
|
4429
|
+
//#endregion
|
|
4430
|
+
//#region src/components/ResourcesDayView/ResourcesDayView.ts
|
|
4431
|
+
function cssSize$2(value) {
|
|
4432
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
4433
|
+
}
|
|
4434
|
+
var ResourcesDayView = (0, vue.defineComponent)({
|
|
4435
|
+
name: "ResourcesDayView",
|
|
4436
|
+
inheritAttrs: false,
|
|
4437
|
+
slots: Object,
|
|
4438
|
+
props: {
|
|
4439
|
+
date: {
|
|
4440
|
+
type: [String, Date],
|
|
4441
|
+
required: true
|
|
4442
|
+
},
|
|
4443
|
+
onDateChange: Function,
|
|
4444
|
+
resources: {
|
|
4445
|
+
type: Array,
|
|
4446
|
+
required: true
|
|
4447
|
+
},
|
|
4448
|
+
startTime: {
|
|
4449
|
+
type: String,
|
|
4450
|
+
default: "00:00:00"
|
|
4451
|
+
},
|
|
4452
|
+
endTime: {
|
|
4453
|
+
type: String,
|
|
4454
|
+
default: "23:59:59"
|
|
4455
|
+
},
|
|
4456
|
+
intervalMinutes: {
|
|
4457
|
+
type: Number,
|
|
4458
|
+
default: 60
|
|
4459
|
+
},
|
|
4460
|
+
slotLabelFormat: {
|
|
4461
|
+
type: [String, Function],
|
|
4462
|
+
default: "HH:mm"
|
|
4463
|
+
},
|
|
4464
|
+
radius: [String, Number],
|
|
4465
|
+
startScrollTime: String,
|
|
4466
|
+
scrollAreaProps: Object,
|
|
4467
|
+
locale: String,
|
|
4468
|
+
withCurrentTimeIndicator: {
|
|
4469
|
+
type: Boolean,
|
|
4470
|
+
default: void 0
|
|
4471
|
+
},
|
|
4472
|
+
withCurrentTimeBubble: {
|
|
4473
|
+
type: Boolean,
|
|
4474
|
+
default: true
|
|
4475
|
+
},
|
|
4476
|
+
getCurrentTime: Function,
|
|
4477
|
+
withHeader: {
|
|
4478
|
+
type: Boolean,
|
|
4479
|
+
default: true
|
|
4480
|
+
},
|
|
4481
|
+
onViewChange: Function,
|
|
4482
|
+
previousControlProps: Object,
|
|
4483
|
+
nextControlProps: Object,
|
|
4484
|
+
todayControlProps: Object,
|
|
4485
|
+
viewSelectProps: Object,
|
|
4486
|
+
headerFormat: {
|
|
4487
|
+
type: [String, Function],
|
|
4488
|
+
default: "MMMM D, YYYY"
|
|
4489
|
+
},
|
|
4490
|
+
events: Array,
|
|
4491
|
+
slotWidth: {
|
|
4492
|
+
type: [String, Number],
|
|
4493
|
+
default: 80
|
|
4494
|
+
},
|
|
4495
|
+
rowHeight: {
|
|
4496
|
+
type: [String, Number],
|
|
4497
|
+
default: 64
|
|
4498
|
+
},
|
|
4499
|
+
labels: Object,
|
|
4500
|
+
highlightBusinessHours: Boolean,
|
|
4501
|
+
businessHours: {
|
|
4502
|
+
type: Array,
|
|
4503
|
+
default: () => ["09:00:00", "17:00:00"]
|
|
4504
|
+
},
|
|
4505
|
+
renderEventBody: Function,
|
|
4506
|
+
renderEvent: Function,
|
|
4507
|
+
renderResourceLabel: Function,
|
|
4508
|
+
groups: Array,
|
|
4509
|
+
renderGroupLabel: Function,
|
|
4510
|
+
groupLabelWidth: {
|
|
4511
|
+
type: [String, Number],
|
|
4512
|
+
default: 80
|
|
4513
|
+
},
|
|
4514
|
+
withEventsDragAndDrop: Boolean,
|
|
4515
|
+
onEventDrop: Function,
|
|
4516
|
+
canDragEvent: Function,
|
|
4517
|
+
onEventDragStart: Function,
|
|
4518
|
+
onEventDragEnd: Function,
|
|
4519
|
+
onTimeSlotClick: Function,
|
|
4520
|
+
onEventClick: Function,
|
|
4521
|
+
withDragSlotSelect: Boolean,
|
|
4522
|
+
onSlotDragEnd: Function,
|
|
4523
|
+
mode: {
|
|
4524
|
+
type: String,
|
|
4525
|
+
default: "default"
|
|
4526
|
+
},
|
|
4527
|
+
onExternalEventDrop: Function,
|
|
4528
|
+
withEventResize: Boolean,
|
|
4529
|
+
onEventResize: Function,
|
|
4530
|
+
canResizeEvent: Function,
|
|
4531
|
+
recurrenceExpansionLimit: {
|
|
4532
|
+
type: Number,
|
|
4533
|
+
default: 2e3
|
|
4534
|
+
},
|
|
4535
|
+
maxEventsPerTimeSlot: {
|
|
4536
|
+
type: Number,
|
|
4537
|
+
default: 2
|
|
4538
|
+
},
|
|
4539
|
+
moreEventsProps: Object
|
|
4540
|
+
},
|
|
4541
|
+
setup(props, { attrs, slots }) {
|
|
4542
|
+
const theme = (0, _mantine_vue_core.useSafeMantineTheme)();
|
|
4543
|
+
const controls = [];
|
|
4544
|
+
const rootElement = (0, vue.ref)(null);
|
|
4545
|
+
const rowContainers = /* @__PURE__ */ new Map();
|
|
4546
|
+
const dropTarget = (0, vue.ref)(null);
|
|
4547
|
+
const scrolled = (0, vue.ref)(false);
|
|
4548
|
+
const scrolledX = (0, vue.ref)(false);
|
|
4549
|
+
const intervals = (0, vue.computed)(() => getDayTimeIntervals({
|
|
4550
|
+
startTime: props.startTime,
|
|
4551
|
+
endTime: props.endTime,
|
|
4552
|
+
intervalMinutes: props.intervalMinutes
|
|
4553
|
+
}));
|
|
4554
|
+
const ordered = (0, vue.computed)(() => getOrderedResources(props.resources, props.groups));
|
|
4555
|
+
const resourceIdMap = (0, vue.computed)(() => getGroupToResourceIdMap(props.resources));
|
|
4556
|
+
const expandedEvents = (0, vue.computed)(() => expandRecurringEvents({
|
|
4557
|
+
events: props.events,
|
|
4558
|
+
rangeStart: (0, dayjs.default)(props.date).startOf("day").toDate(),
|
|
4559
|
+
rangeEnd: (0, dayjs.default)(props.date).endOf("day").toDate(),
|
|
4560
|
+
expansionLimit: props.recurrenceExpansionLimit
|
|
4561
|
+
}));
|
|
4562
|
+
(0, vue.onMounted)(async () => {
|
|
4563
|
+
if (!props.startScrollTime) return;
|
|
4564
|
+
await (0, vue.nextTick)();
|
|
4565
|
+
const targetIndex = intervals.value.findIndex((interval) => interval.startTime >= props.startScrollTime);
|
|
4566
|
+
if (targetIndex < 0) return;
|
|
4567
|
+
const target = controls[0]?.[targetIndex];
|
|
4568
|
+
const viewport = rootElement.value?.querySelector(".mantine-ScrollArea-viewport");
|
|
4569
|
+
if (target && viewport) {
|
|
4570
|
+
viewport.scrollLeft = target.offsetLeft;
|
|
4571
|
+
requestAnimationFrame(() => viewport.scrollLeft = target.offsetLeft);
|
|
4572
|
+
}
|
|
4573
|
+
});
|
|
4574
|
+
const positioned = (0, vue.computed)(() => getResourcesDayViewEvents({
|
|
4575
|
+
date: props.date,
|
|
4576
|
+
events: expandedEvents.value,
|
|
4577
|
+
resources: props.resources,
|
|
4578
|
+
startTime: props.startTime,
|
|
4579
|
+
endTime: props.endTime,
|
|
4580
|
+
intervalMinutes: props.intervalMinutes
|
|
4581
|
+
}));
|
|
4582
|
+
const slotSelect = useSlotDragSelect({
|
|
4583
|
+
enabled: () => props.withDragSlotSelect && props.mode !== "static",
|
|
4584
|
+
onDragEnd: () => (start, end, group) => {
|
|
4585
|
+
const first = intervals.value[start];
|
|
4586
|
+
const last = intervals.value[end];
|
|
4587
|
+
if (first && last) {
|
|
4588
|
+
const date = (0, dayjs.default)(props.date).format("YYYY-MM-DD");
|
|
4589
|
+
props.onSlotDragEnd?.({
|
|
4590
|
+
rangeStart: `${date} ${first.startTime}`,
|
|
4591
|
+
rangeEnd: `${date} ${last.endTime}`,
|
|
4592
|
+
resourceId: resourceIdMap.value.get(group)
|
|
4593
|
+
});
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
});
|
|
4597
|
+
const resize = useHorizontalEventResize({
|
|
4598
|
+
enabled: () => props.withEventResize,
|
|
4599
|
+
mode: () => props.mode,
|
|
4600
|
+
startTime: () => props.startTime,
|
|
4601
|
+
endTime: () => props.endTime,
|
|
4602
|
+
intervalMinutes: () => props.intervalMinutes,
|
|
4603
|
+
onEventResize: () => props.onEventResize,
|
|
4604
|
+
canResizeEvent: () => props.canResizeEvent
|
|
4605
|
+
});
|
|
4606
|
+
const emitDrop = (nativeEvent, resourceId, slotIndex) => {
|
|
4607
|
+
nativeEvent.preventDefault();
|
|
4608
|
+
dropTarget.value = null;
|
|
4609
|
+
const interval = intervals.value[slotIndex];
|
|
4610
|
+
if (!interval) return;
|
|
4611
|
+
const target = `${(0, dayjs.default)(props.date).format("YYYY-MM-DD")} ${interval.startTime}`;
|
|
4612
|
+
const event = getDropEvent(expandedEvents.value, nativeEvent.dataTransfer);
|
|
4613
|
+
if (event) props.onEventDrop?.({
|
|
4614
|
+
...moveEventTo(event, target),
|
|
4615
|
+
resourceId
|
|
4616
|
+
});
|
|
4617
|
+
else if (nativeEvent.dataTransfer) props.onExternalEventDrop?.({
|
|
4618
|
+
dataTransfer: nativeEvent.dataTransfer,
|
|
4619
|
+
dropDateTime: target,
|
|
4620
|
+
resourceId
|
|
4621
|
+
});
|
|
4622
|
+
};
|
|
4623
|
+
const getSlotIndexAtPoint = (nativeEvent, resourceIndex) => {
|
|
4624
|
+
const container = rowContainers.get(resourceIndex);
|
|
4625
|
+
if (!container || intervals.value.length === 0) return -1;
|
|
4626
|
+
const rect = container.getBoundingClientRect();
|
|
4627
|
+
if (rect.width <= 0) return -1;
|
|
4628
|
+
return Math.max(0, Math.min(intervals.value.length - 1, Math.floor((nativeEvent.clientX - rect.left) / rect.width * intervals.value.length)));
|
|
4629
|
+
};
|
|
4630
|
+
const renderGroupCell = (info) => {
|
|
4631
|
+
if (info === void 0) return null;
|
|
4632
|
+
if (info === null) return (0, vue.h)(_mantine_vue_core.Box, { class: ResourcesDayView_module_default.resourcesDayViewGroupColumnEmpty });
|
|
4633
|
+
const starts = info.position === "first" || info.position === "only";
|
|
4634
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
4635
|
+
class: ResourcesDayView_module_default.resourcesDayViewGroupColumn,
|
|
4636
|
+
"data-group-position": info.position
|
|
4637
|
+
}, () => starts ? (0, vue.h)("span", { style: info.count > 1 ? { transform: `translateY(calc((${info.count - 1} * (var(--resources-day-view-row-height) + 1px)) / 2))` } : void 0 }, slots.groupLabel?.({ group: info.group }) ?? props.renderGroupLabel?.(info.group) ?? info.group.label ?? void 0) : null);
|
|
4638
|
+
};
|
|
4639
|
+
return () => {
|
|
4640
|
+
const date = (0, dayjs.default)(props.date).format("YYYY-MM-DD");
|
|
4641
|
+
const now = (0, dayjs.default)(props.getCurrentTime?.() ?? /* @__PURE__ */ new Date());
|
|
4642
|
+
const isToday = (0, dayjs.default)(props.date).isSame(now, "day");
|
|
4643
|
+
const showIndicator = (props.withCurrentTimeIndicator ?? isToday) && isInTimeRange({
|
|
4644
|
+
date: now.toDate(),
|
|
4645
|
+
startTime: props.startTime,
|
|
4646
|
+
endTime: props.endTime
|
|
4647
|
+
});
|
|
4648
|
+
const indicatorOffset = getCurrentTimePosition({
|
|
4649
|
+
startTime: props.startTime,
|
|
4650
|
+
endTime: props.endTime,
|
|
4651
|
+
intervalMinutes: props.intervalMinutes,
|
|
4652
|
+
now
|
|
4653
|
+
});
|
|
4654
|
+
const currentTime = formatDate({
|
|
4655
|
+
date: now,
|
|
4656
|
+
locale: props.locale || "en",
|
|
4657
|
+
format: props.slotLabelFormat
|
|
4658
|
+
});
|
|
4659
|
+
const hasGroups = ordered.value.groupRanges.length > 0;
|
|
4660
|
+
const timeLabels = intervals.value.map((interval) => {
|
|
4661
|
+
const label = formatDate({
|
|
4662
|
+
date: `${date} ${interval.startTime}`,
|
|
4663
|
+
locale: props.locale || "en",
|
|
4664
|
+
format: props.slotLabelFormat
|
|
4665
|
+
});
|
|
4666
|
+
const mod = getBusinessHoursMod({
|
|
4667
|
+
time: interval.startTime,
|
|
4668
|
+
businessHours: props.businessHours,
|
|
4669
|
+
highlightBusinessHours: props.highlightBusinessHours
|
|
4670
|
+
});
|
|
4671
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
4672
|
+
key: interval.startTime,
|
|
4673
|
+
class: ResourcesDayView_module_default.resourcesDayViewTimeLabel,
|
|
4674
|
+
"data-business-hours": mod["business-hours"] || void 0,
|
|
4675
|
+
"data-non-business-hours": mod["non-business-hours"] || void 0
|
|
4676
|
+
}, () => slots.timeLabel?.({
|
|
4677
|
+
label,
|
|
4678
|
+
startTime: interval.startTime,
|
|
4679
|
+
endTime: interval.endTime
|
|
4680
|
+
}) ?? label);
|
|
4681
|
+
});
|
|
4682
|
+
const rows = ordered.value.orderedResources.map((resource, resourceIndex) => {
|
|
4683
|
+
const resourceEvents = positioned.value;
|
|
4684
|
+
const background = [...resourceEvents.backgroundTimedEvents[resource.id] || [], ...resourceEvents.backgroundAllDayEvents[resource.id] || []].map((event) => {
|
|
4685
|
+
const colors = theme.value.variantColorResolver({
|
|
4686
|
+
color: event.color || theme.value.primaryColor,
|
|
4687
|
+
theme: theme.value,
|
|
4688
|
+
variant: "light",
|
|
4689
|
+
autoContrast: true
|
|
4690
|
+
});
|
|
4691
|
+
return slots.backgroundEvent?.({ event }) ?? (0, vue.h)(_mantine_vue_core.Box, {
|
|
4692
|
+
key: `bg-${event.id}`,
|
|
4693
|
+
class: ResourcesDayView_module_default.resourcesDayViewBackgroundEvent,
|
|
4694
|
+
style: {
|
|
4695
|
+
left: `${event.position.top}%`,
|
|
4696
|
+
width: `${event.position.height}%`,
|
|
4697
|
+
top: 0,
|
|
4698
|
+
height: "100%",
|
|
4699
|
+
"--bg-event-bg": colors.background,
|
|
4700
|
+
"--bg-event-color": colors.color
|
|
4701
|
+
}
|
|
4702
|
+
}, () => props.renderEventBody?.(event) ?? slots.eventBody?.({ event }) ?? event.title);
|
|
4703
|
+
});
|
|
4704
|
+
const allRegular = resourceEvents.regularEvents[resource.id] || [];
|
|
4705
|
+
const regular = allRegular.filter((event) => event.position.column < Math.max(1, props.maxEventsPerTimeSlot)).map((event) => {
|
|
4706
|
+
const colors = theme.value.variantColorResolver({
|
|
4707
|
+
color: event.color || theme.value.primaryColor,
|
|
4708
|
+
theme: theme.value,
|
|
4709
|
+
variant: event.variant || "light",
|
|
4710
|
+
autoContrast: true
|
|
4711
|
+
});
|
|
4712
|
+
const position = resize.getResizePosition(event.id);
|
|
4713
|
+
const left = position?.left ?? event.position.top;
|
|
4714
|
+
const width = position?.width ?? event.position.height;
|
|
4715
|
+
const isResizable = resize.isResizableEvent(event);
|
|
4716
|
+
const isResizing = position !== null;
|
|
4717
|
+
const wrapperStyle = {
|
|
4718
|
+
left: `calc(${left}% + 1px)`,
|
|
4719
|
+
width: `calc(${width}% - 2px)`,
|
|
4720
|
+
top: `${event.position.offset}%`,
|
|
4721
|
+
height: `${event.position.width}%`
|
|
4722
|
+
};
|
|
4723
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
4724
|
+
key: event.id,
|
|
4725
|
+
class: ResourcesDayView_module_default.resourcesDayViewEventWrapper,
|
|
4726
|
+
"data-resizing": isResizing || void 0,
|
|
4727
|
+
style: {
|
|
4728
|
+
...wrapperStyle,
|
|
4729
|
+
"--event-color": colors.color
|
|
4730
|
+
}
|
|
4731
|
+
}, () => [(0, vue.h)(ScheduleEvent, {
|
|
4732
|
+
event,
|
|
4733
|
+
autoSize: true,
|
|
4734
|
+
nowrap: true,
|
|
4735
|
+
radius: props.radius,
|
|
4736
|
+
mode: props.mode,
|
|
4737
|
+
renderEvent: props.renderEvent,
|
|
4738
|
+
renderEventBody: props.renderEventBody,
|
|
4739
|
+
draggable: props.withEventsDragAndDrop && props.mode !== "static" && (props.canDragEvent?.(event) ?? true),
|
|
4740
|
+
onEventDragStart: props.onEventDragStart,
|
|
4741
|
+
onEventDragEnd: props.onEventDragEnd,
|
|
4742
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => {
|
|
4743
|
+
if (!resize.wasResizing()) props.onEventClick?.(event, nativeEvent);
|
|
4744
|
+
},
|
|
4745
|
+
style: {
|
|
4746
|
+
width: "100%",
|
|
4747
|
+
height: "100%"
|
|
4748
|
+
}
|
|
4749
|
+
}, forwardEventSlots(slots)), isResizable ? ["start", "end"].map((edge) => (0, vue.h)("div", {
|
|
4750
|
+
class: ResourcesDayView_module_default.resourcesDayViewResizeHandle,
|
|
4751
|
+
"data-edge": edge,
|
|
4752
|
+
"data-active": resize.state.value?.edge === edge || void 0,
|
|
4753
|
+
"aria-label": `${edge === "start" ? "Resize event start" : "Resize event end"} ${event.title}`,
|
|
4754
|
+
onDragstart: (nativeEvent) => nativeEvent.preventDefault(),
|
|
4755
|
+
onPointerdown: (pointerEvent) => {
|
|
4756
|
+
const container = rowContainers.get(resourceIndex);
|
|
4757
|
+
if (container) resize.handleResizeStart({
|
|
4758
|
+
event,
|
|
4759
|
+
edge,
|
|
4760
|
+
container,
|
|
4761
|
+
originalLeft: event.position.top,
|
|
4762
|
+
originalWidth: event.position.height,
|
|
4763
|
+
eventDate: date,
|
|
4764
|
+
pointerEvent
|
|
4765
|
+
});
|
|
4766
|
+
}
|
|
4767
|
+
})) : null]);
|
|
4768
|
+
});
|
|
4769
|
+
const allDay = (resourceEvents.allDayEvents[resource.id] || []).map((event, index) => (0, vue.h)(_mantine_vue_core.Box, {
|
|
4770
|
+
key: `all-${event.id}`,
|
|
4771
|
+
class: ResourcesDayView_module_default.resourcesDayViewAllDayEvent,
|
|
4772
|
+
style: { top: `calc(${index} * (var(--resources-day-view-all-day-height) + 2px) + 2px)` }
|
|
4773
|
+
}, () => slots.allDayEvent?.({ event }) ?? (0, vue.h)(ScheduleEvent, {
|
|
4774
|
+
event,
|
|
4775
|
+
autoSize: true,
|
|
4776
|
+
nowrap: true,
|
|
4777
|
+
radius: props.radius,
|
|
4778
|
+
mode: props.mode,
|
|
4779
|
+
renderEvent: props.renderEvent,
|
|
4780
|
+
renderEventBody: props.renderEventBody,
|
|
4781
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => props.onEventClick?.(event, nativeEvent),
|
|
4782
|
+
style: {
|
|
4783
|
+
width: "100%",
|
|
4784
|
+
height: "100%"
|
|
4785
|
+
}
|
|
4786
|
+
}, forwardEventSlots(slots))));
|
|
4787
|
+
const more = getOverlapClusters(allRegular).filter((cluster) => cluster.some((event) => event.position.column >= props.maxEventsPerTimeSlot)).map((cluster) => {
|
|
4788
|
+
const hiddenCount = cluster.filter((event) => event.position.column >= props.maxEventsPerTimeSlot).length;
|
|
4789
|
+
const left = Math.min(...cluster.map((event) => event.position.top));
|
|
4790
|
+
const right = Math.max(...cluster.map((event) => event.position.top + event.position.height));
|
|
4791
|
+
return slots.moreEvents?.({
|
|
4792
|
+
events: cluster,
|
|
4793
|
+
hiddenCount
|
|
4794
|
+
}) ?? (0, vue.h)(MoreEvents, {
|
|
4795
|
+
...props.moreEventsProps,
|
|
4796
|
+
key: `more-${cluster[0].id}`,
|
|
4797
|
+
events: cluster,
|
|
4798
|
+
moreEventsCount: hiddenCount,
|
|
4799
|
+
mode: props.mode,
|
|
4800
|
+
labels: props.labels,
|
|
4801
|
+
renderEventBody: props.renderEventBody,
|
|
4802
|
+
renderEvent: props.renderEvent,
|
|
4803
|
+
onEventClick: props.onEventClick,
|
|
4804
|
+
style: {
|
|
4805
|
+
position: "absolute",
|
|
4806
|
+
left: `calc(${left}% + 1px)`,
|
|
4807
|
+
width: `calc(${right - left}% - 2px)`,
|
|
4808
|
+
bottom: 0,
|
|
4809
|
+
height: "22px",
|
|
4810
|
+
zIndex: 4
|
|
4811
|
+
}
|
|
4812
|
+
}, forwardEventSlots(slots));
|
|
4813
|
+
});
|
|
4814
|
+
const slotGroup = String(resource.id);
|
|
4815
|
+
const buttons = intervals.value.map((interval, slotIndex) => {
|
|
4816
|
+
const mod = getBusinessHoursMod({
|
|
4817
|
+
time: interval.startTime,
|
|
4818
|
+
businessHours: props.businessHours,
|
|
4819
|
+
highlightBusinessHours: props.highlightBusinessHours
|
|
4820
|
+
});
|
|
4821
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
4822
|
+
key: interval.startTime,
|
|
4823
|
+
ref: (element) => {
|
|
4824
|
+
const button = element?.$el ?? element;
|
|
4825
|
+
controls[resourceIndex] ||= [];
|
|
4826
|
+
controls[resourceIndex][slotIndex] = button instanceof HTMLButtonElement ? button : void 0;
|
|
4827
|
+
},
|
|
4828
|
+
class: ResourcesDayView_module_default.resourcesDayViewRowSlot,
|
|
4829
|
+
"data-business-hours": mod["business-hours"] || void 0,
|
|
4830
|
+
"data-non-business-hours": mod["non-business-hours"] || void 0,
|
|
4831
|
+
"data-drop-target": dropTarget.value?.resourceId === resource.id && dropTarget.value.slotIndex === slotIndex ? true : void 0,
|
|
4832
|
+
"data-drag-selected": slotSelect.isSlotSelected(slotIndex, slotGroup) || void 0,
|
|
4833
|
+
"data-static": props.mode === "static" || void 0,
|
|
4834
|
+
"data-drag-slot-index": props.withDragSlotSelect ? slotIndex : void 0,
|
|
4835
|
+
"data-drag-slot-group": props.withDragSlotSelect ? slotGroup : void 0,
|
|
4836
|
+
"aria-label": `${getLabel("resourceSlot", props.labels)} ${String(resource.label)} ${date} ${interval.startTime} - ${interval.endTime}`,
|
|
4837
|
+
tabindex: props.mode === "static" ? -1 : resourceIndex === 0 && slotIndex === 0 ? 0 : -1,
|
|
4838
|
+
onKeydown: (event) => handleResourcesGridKeyDown({
|
|
4839
|
+
controls,
|
|
4840
|
+
resourceIndex,
|
|
4841
|
+
slotIndex,
|
|
4842
|
+
event
|
|
4843
|
+
}),
|
|
4844
|
+
onPointerdown: props.mode === "static" ? void 0 : (event) => slotSelect.handleSlotPointerDown(event, slotIndex, slotGroup),
|
|
4845
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => props.onTimeSlotClick?.({
|
|
4846
|
+
slotStart: `${date} ${interval.startTime}`,
|
|
4847
|
+
slotEnd: `${date} ${interval.endTime}`,
|
|
4848
|
+
nativeEvent,
|
|
4849
|
+
resourceId: resource.id
|
|
4850
|
+
})
|
|
4851
|
+
}, () => slots.timeSlot?.({
|
|
4852
|
+
resource,
|
|
4853
|
+
startTime: interval.startTime,
|
|
4854
|
+
endTime: interval.endTime
|
|
4855
|
+
}));
|
|
4856
|
+
});
|
|
4857
|
+
const groupInfo = hasGroups ? ordered.value.resourceGroupMap[resourceIndex] : void 0;
|
|
4858
|
+
const allDayCount = resourceEvents.allDayEvents[resource.id]?.length || 0;
|
|
4859
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
4860
|
+
key: resource.id,
|
|
4861
|
+
class: ResourcesDayView_module_default.resourcesDayViewRow
|
|
4862
|
+
}, () => [
|
|
4863
|
+
renderGroupCell(groupInfo),
|
|
4864
|
+
(0, vue.h)(_mantine_vue_core.Box, {
|
|
4865
|
+
class: ResourcesDayView_module_default.resourcesDayViewResourceLabel,
|
|
4866
|
+
"data-scrolled-x": scrolledX.value || void 0,
|
|
4867
|
+
"data-has-groups": groupInfo !== void 0 || void 0
|
|
4868
|
+
}, () => slots.resourceLabel?.({ resource }) ?? props.renderResourceLabel?.(resource) ?? resource.label),
|
|
4869
|
+
(0, vue.h)(_mantine_vue_core.Box, {
|
|
4870
|
+
class: ResourcesDayView_module_default.resourcesDayViewRowSlots,
|
|
4871
|
+
ref: (element) => {
|
|
4872
|
+
const node = element?.$el ?? element;
|
|
4873
|
+
if (node instanceof HTMLElement) rowContainers.set(resourceIndex, node);
|
|
4874
|
+
},
|
|
4875
|
+
style: allDayCount ? { minHeight: `max(var(--resources-day-view-row-height), calc(${allDayCount} * (var(--resources-day-view-all-day-height) + 2px) + 4px))` } : void 0,
|
|
4876
|
+
onDragover: props.withEventsDragAndDrop || props.onExternalEventDrop ? (nativeEvent) => {
|
|
4877
|
+
if (props.mode === "static") return;
|
|
4878
|
+
nativeEvent.preventDefault();
|
|
4879
|
+
const slotIndex = getSlotIndexAtPoint(nativeEvent, resourceIndex);
|
|
4880
|
+
if (slotIndex >= 0 && (dropTarget.value?.resourceId !== resource.id || dropTarget.value.slotIndex !== slotIndex)) dropTarget.value = {
|
|
4881
|
+
resourceId: resource.id,
|
|
4882
|
+
slotIndex
|
|
4883
|
+
};
|
|
4884
|
+
} : void 0,
|
|
4885
|
+
onDragleave: props.withEventsDragAndDrop || props.onExternalEventDrop ? (nativeEvent) => {
|
|
4886
|
+
const related = nativeEvent.relatedTarget;
|
|
4887
|
+
const current = nativeEvent.currentTarget;
|
|
4888
|
+
if (!(related instanceof Node) || !(current instanceof HTMLElement) || !current.contains(related)) dropTarget.value = null;
|
|
4889
|
+
} : void 0,
|
|
4890
|
+
onDrop: props.withEventsDragAndDrop || props.onExternalEventDrop ? (nativeEvent) => {
|
|
4891
|
+
const slotIndex = getSlotIndexAtPoint(nativeEvent, resourceIndex);
|
|
4892
|
+
if (slotIndex >= 0) emitDrop(nativeEvent, resource.id, slotIndex);
|
|
4893
|
+
} : void 0
|
|
4894
|
+
}, () => [
|
|
4895
|
+
...background,
|
|
4896
|
+
...allDay,
|
|
4897
|
+
...regular,
|
|
4898
|
+
...more,
|
|
4899
|
+
...buttons
|
|
4900
|
+
])
|
|
4901
|
+
]);
|
|
4902
|
+
});
|
|
4903
|
+
const headerLabel = formatDate({
|
|
4904
|
+
date: props.date,
|
|
4905
|
+
locale: props.locale || "en",
|
|
4906
|
+
format: props.headerFormat
|
|
4907
|
+
});
|
|
4908
|
+
const header = props.withHeader ? slots.header?.({
|
|
4909
|
+
date,
|
|
4910
|
+
label: headerLabel
|
|
4911
|
+
}) ?? (0, vue.h)(ScheduleHeaderBase, {
|
|
4912
|
+
view: "day",
|
|
4913
|
+
navigationHandlers: {
|
|
4914
|
+
previous: () => (0, dayjs.default)(props.date).subtract(1, "day").format("YYYY-MM-DD"),
|
|
4915
|
+
next: () => (0, dayjs.default)(props.date).add(1, "day").format("YYYY-MM-DD"),
|
|
4916
|
+
today: () => now.format("YYYY-MM-DD")
|
|
4917
|
+
},
|
|
4918
|
+
control: { title: headerLabel },
|
|
4919
|
+
labels: props.labels,
|
|
4920
|
+
onDateChange: props.onDateChange,
|
|
4921
|
+
onViewChange: props.onViewChange,
|
|
4922
|
+
previousControlProps: props.previousControlProps,
|
|
4923
|
+
nextControlProps: props.nextControlProps,
|
|
4924
|
+
todayControlProps: props.todayControlProps,
|
|
4925
|
+
viewSelectProps: {
|
|
4926
|
+
views: [
|
|
4927
|
+
"day",
|
|
4928
|
+
"week",
|
|
4929
|
+
"month"
|
|
4930
|
+
],
|
|
4931
|
+
...props.viewSelectProps
|
|
4932
|
+
}
|
|
4933
|
+
}) : null;
|
|
4934
|
+
const indicator = showIndicator ? slots.currentTimeIndicator?.({
|
|
4935
|
+
time: currentTime,
|
|
4936
|
+
offset: indicatorOffset
|
|
4937
|
+
}) ?? (0, vue.h)(_mantine_vue_core.Box, {
|
|
4938
|
+
class: ResourcesDayView_module_default.resourcesDayViewCurrentTimeIndicator,
|
|
4939
|
+
style: {
|
|
4940
|
+
"--indicator-left-offset": hasGroups ? `calc(var(--resources-day-view-resource-label-width) + var(--resources-day-view-group-label-width) + (100% - var(--resources-day-view-resource-label-width) - var(--resources-day-view-group-label-width)) * ${indicatorOffset} / 100)` : `calc(var(--resources-day-view-resource-label-width) + (100% - var(--resources-day-view-resource-label-width)) * ${indicatorOffset} / 100)`,
|
|
4941
|
+
"--_time-bubble-width": String(currentTime).toLowerCase().includes("m") ? "64px" : "46px"
|
|
4942
|
+
}
|
|
4943
|
+
}, () => [props.withCurrentTimeBubble ? (0, vue.h)("div", { class: ResourcesDayView_module_default.resourcesDayViewCurrentTimeIndicatorTimeBubble }, currentTime) : (0, vue.h)("div", { class: ResourcesDayView_module_default.resourcesDayViewCurrentTimeIndicatorThumb }), (0, vue.h)("div", { class: ResourcesDayView_module_default.resourcesDayViewCurrentTimeIndicatorLine })]) : null;
|
|
4944
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
4945
|
+
...attrs,
|
|
4946
|
+
ref: (element) => {
|
|
4947
|
+
const node = element?.$el ?? element;
|
|
4948
|
+
rootElement.value = node instanceof HTMLElement ? node : null;
|
|
4949
|
+
},
|
|
4950
|
+
class: [ResourcesDayView_module_default.resourcesDayView, attrs.class],
|
|
4951
|
+
style: [{
|
|
4952
|
+
"--resources-day-view-radius": resolveScheduleRadius(props.radius),
|
|
4953
|
+
"--resources-day-view-slot-width": cssSize$2(props.slotWidth),
|
|
4954
|
+
"--resources-day-view-row-height": cssSize$2(props.rowHeight),
|
|
4955
|
+
"--resources-day-view-group-label-width": cssSize$2(props.groupLabelWidth)
|
|
4956
|
+
}, attrs.style],
|
|
4957
|
+
"data-resizing": resize.state.value ? true : void 0,
|
|
4958
|
+
"data-event-interaction": resize.state.value ? true : void 0
|
|
4959
|
+
}, () => [header, (0, vue.h)(_mantine_vue_core.Box, { class: ResourcesDayView_module_default.resourcesDayViewRoot }, () => (0, vue.h)(_mantine_vue_core.ScrollArea, {
|
|
4960
|
+
scrollbarSize: 4,
|
|
4961
|
+
...props.scrollAreaProps,
|
|
4962
|
+
class: ResourcesDayView_module_default.resourcesDayViewScrollArea,
|
|
4963
|
+
onScrollPositionChange: (position) => {
|
|
4964
|
+
scrolled.value = position.y !== 0;
|
|
4965
|
+
scrolledX.value = position.x !== 0;
|
|
4966
|
+
}
|
|
4967
|
+
}, () => (0, vue.h)("div", { class: ResourcesDayView_module_default.resourcesDayViewInner }, [
|
|
4968
|
+
(0, vue.h)(_mantine_vue_core.Box, {
|
|
4969
|
+
class: ResourcesDayView_module_default.resourcesDayViewTimeLabelsRow,
|
|
4970
|
+
"data-scrolled": scrolled.value || void 0
|
|
4971
|
+
}, () => [(0, vue.h)("div", {
|
|
4972
|
+
class: ResourcesDayView_module_default.resourcesDayViewCorner,
|
|
4973
|
+
style: hasGroups ? {
|
|
4974
|
+
flexBasis: "calc(var(--resources-day-view-resource-label-width) + var(--resources-day-view-group-label-width))",
|
|
4975
|
+
minWidth: "calc(var(--resources-day-view-resource-label-width) + var(--resources-day-view-group-label-width))"
|
|
4976
|
+
} : void 0
|
|
4977
|
+
}, slots.corner?.({ resources: ordered.value.orderedResources }) ?? getLabel("resources", props.labels)), ...timeLabels]),
|
|
4978
|
+
...rows,
|
|
4979
|
+
indicator
|
|
4980
|
+
])))]);
|
|
4981
|
+
};
|
|
4982
|
+
}
|
|
4983
|
+
});
|
|
4984
|
+
//#endregion
|
|
4985
|
+
//#region src/components/ResourcesWeekView/get-resources-week-view-events/get-resources-week-view-events.ts
|
|
4986
|
+
function assignAllDayRows(bars) {
|
|
4987
|
+
const rowEnds = [];
|
|
4988
|
+
[...bars].sort((a, b) => a.startDayIndex - b.startDayIndex || a.endDayIndex - b.endDayIndex).forEach((bar) => {
|
|
4989
|
+
let row = 0;
|
|
4990
|
+
while (row < rowEnds.length && rowEnds[row] >= bar.startDayIndex) row += 1;
|
|
4991
|
+
rowEnds[row] = bar.endDayIndex;
|
|
4992
|
+
bar.row = row;
|
|
4993
|
+
});
|
|
4994
|
+
}
|
|
4995
|
+
function getResourcesWeekViewEvents({ events, resources, weekdays, startTime, endTime, intervalMinutes, expansionLimit }) {
|
|
4996
|
+
const expanded = expandRecurringEvents({
|
|
4997
|
+
events,
|
|
4998
|
+
rangeStart: (0, dayjs.default)(weekdays[0]).startOf("day").toDate(),
|
|
4999
|
+
rangeEnd: (0, dayjs.default)(weekdays.at(-1)).endOf("day").toDate(),
|
|
5000
|
+
expansionLimit
|
|
5001
|
+
});
|
|
5002
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5003
|
+
expanded?.forEach((event) => {
|
|
5004
|
+
if (seen.has(event.id)) throw new Error(`[@mantine/schedule] ResourcesWeekView: Duplicated event ids found: ${event.id}`);
|
|
5005
|
+
seen.add(event.id);
|
|
5006
|
+
});
|
|
5007
|
+
const byDay = {};
|
|
5008
|
+
const assigned = /* @__PURE__ */ new Set();
|
|
5009
|
+
const spanning = (event) => event.display !== "background" && isMultidayEvent(event);
|
|
5010
|
+
weekdays.forEach((day) => {
|
|
5011
|
+
const dayEvents = expanded?.filter((event) => {
|
|
5012
|
+
if (assigned.has(event.id) || spanning(event)) return false;
|
|
5013
|
+
const start = (0, dayjs.default)(event.start);
|
|
5014
|
+
const dayStart = (0, dayjs.default)(day).startOf("day");
|
|
5015
|
+
if (start.isSame(dayStart, "day")) {
|
|
5016
|
+
assigned.add(event.id);
|
|
5017
|
+
return true;
|
|
5018
|
+
}
|
|
5019
|
+
return event.display === "background" && start.isBefore((0, dayjs.default)(day).endOf("day")) && (0, dayjs.default)(event.end).isAfter(dayStart);
|
|
5020
|
+
});
|
|
5021
|
+
byDay[day] = getResourcesDayViewEvents({
|
|
5022
|
+
events: dayEvents,
|
|
5023
|
+
resources,
|
|
5024
|
+
date: day,
|
|
5025
|
+
startTime,
|
|
5026
|
+
endTime,
|
|
5027
|
+
intervalMinutes
|
|
5028
|
+
});
|
|
5029
|
+
});
|
|
5030
|
+
const allDayBars = {};
|
|
5031
|
+
resources.forEach((resource) => allDayBars[resource.id] = []);
|
|
5032
|
+
weekdays.forEach((day, dayIndex) => {
|
|
5033
|
+
resources.forEach((resource) => {
|
|
5034
|
+
byDay[day].allDayEvents[resource.id]?.forEach((event) => allDayBars[resource.id].push({
|
|
5035
|
+
event,
|
|
5036
|
+
startDayIndex: dayIndex,
|
|
5037
|
+
endDayIndex: dayIndex,
|
|
5038
|
+
row: 0
|
|
5039
|
+
}));
|
|
5040
|
+
});
|
|
5041
|
+
});
|
|
5042
|
+
expanded?.forEach((event) => {
|
|
5043
|
+
if (!spanning(event) || event.resourceId === void 0 || !(event.resourceId in allDayBars)) return;
|
|
5044
|
+
const days = calculateEventDays({
|
|
5045
|
+
event,
|
|
5046
|
+
weekDays: weekdays,
|
|
5047
|
+
actualEndDate: getEventEndDate(event)
|
|
5048
|
+
});
|
|
5049
|
+
if (!days.length) return;
|
|
5050
|
+
allDayBars[event.resourceId].push({
|
|
5051
|
+
event,
|
|
5052
|
+
startDayIndex: weekdays.indexOf(days[0]),
|
|
5053
|
+
endDayIndex: weekdays.indexOf(days.at(-1)),
|
|
5054
|
+
row: 0
|
|
5055
|
+
});
|
|
5056
|
+
});
|
|
5057
|
+
resources.forEach((resource) => assignAllDayRows(allDayBars[resource.id]));
|
|
5058
|
+
return {
|
|
5059
|
+
byDay,
|
|
5060
|
+
allDayBars
|
|
5061
|
+
};
|
|
5062
|
+
}
|
|
5063
|
+
var ResourcesWeekView_module_default = {
|
|
5064
|
+
resourcesWeekView: "_resourcesWeekView_jzd1a_1",
|
|
5065
|
+
resourcesWeekViewRoot: "_resourcesWeekViewRoot_jzd1a_19",
|
|
5066
|
+
resourcesWeekViewScrollArea: "_resourcesWeekViewScrollArea_jzd1a_26",
|
|
5067
|
+
resourcesWeekViewInner: "_resourcesWeekViewInner_jzd1a_34",
|
|
5068
|
+
resourcesWeekViewHeaderRows: "_resourcesWeekViewHeaderRows_jzd1a_39",
|
|
5069
|
+
resourcesWeekViewCorner: "_resourcesWeekViewCorner_jzd1a_48",
|
|
5070
|
+
resourcesWeekViewHeaderContent: "_resourcesWeekViewHeaderContent_jzd1a_63",
|
|
5071
|
+
resourcesWeekViewDayLabelsRow: "_resourcesWeekViewDayLabelsRow_jzd1a_67",
|
|
5072
|
+
resourcesWeekViewDayLabel: "_resourcesWeekViewDayLabel_jzd1a_67",
|
|
5073
|
+
resourcesWeekViewTimeLabelsRow: "_resourcesWeekViewTimeLabelsRow_jzd1a_94",
|
|
5074
|
+
resourcesWeekViewTimeLabel: "_resourcesWeekViewTimeLabel_jzd1a_94",
|
|
5075
|
+
resourcesWeekViewRow: "_resourcesWeekViewRow_jzd1a_121",
|
|
5076
|
+
resourcesWeekViewResourceLabel: "_resourcesWeekViewResourceLabel_jzd1a_125",
|
|
5077
|
+
resourcesWeekViewGroupColumn: "_resourcesWeekViewGroupColumn_jzd1a_149",
|
|
5078
|
+
resourcesWeekViewGroupColumnEmpty: "_resourcesWeekViewGroupColumnEmpty_jzd1a_150",
|
|
5079
|
+
resourcesWeekViewRowSlots: "_resourcesWeekViewRowSlots_jzd1a_178",
|
|
5080
|
+
resourcesWeekViewRowSlot: "_resourcesWeekViewRowSlot_jzd1a_178",
|
|
5081
|
+
resourcesWeekViewBackgroundEvent: "_resourcesWeekViewBackgroundEvent_jzd1a_250",
|
|
5082
|
+
resourcesWeekViewAllDayEvent: "_resourcesWeekViewAllDayEvent_jzd1a_262",
|
|
5083
|
+
resourcesWeekViewEventWrapper: "_resourcesWeekViewEventWrapper_jzd1a_267",
|
|
5084
|
+
resourcesWeekViewResizeHandle: "_resourcesWeekViewResizeHandle_jzd1a_271",
|
|
5085
|
+
resourcesWeekViewCurrentTimeIndicator: "_resourcesWeekViewCurrentTimeIndicator_jzd1a_312",
|
|
5086
|
+
resourcesWeekViewCurrentTimeIndicatorLine: "_resourcesWeekViewCurrentTimeIndicatorLine_jzd1a_324",
|
|
5087
|
+
resourcesWeekViewCurrentTimeIndicatorThumb: "_resourcesWeekViewCurrentTimeIndicatorThumb_jzd1a_330",
|
|
5088
|
+
resourcesWeekViewCurrentTimeIndicatorTimeBubble: "_resourcesWeekViewCurrentTimeIndicatorTimeBubble_jzd1a_340"
|
|
5089
|
+
};
|
|
5090
|
+
//#endregion
|
|
5091
|
+
//#region src/components/ResourcesWeekView/ResourcesWeekView.ts
|
|
5092
|
+
function cssSize$1(value) {
|
|
5093
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
5094
|
+
}
|
|
5095
|
+
var ResourcesWeekView = (0, vue.defineComponent)({
|
|
5096
|
+
name: "ResourcesWeekView",
|
|
5097
|
+
inheritAttrs: false,
|
|
5098
|
+
slots: Object,
|
|
5099
|
+
props: {
|
|
5100
|
+
date: {
|
|
5101
|
+
type: [String, Date],
|
|
5102
|
+
required: true
|
|
5103
|
+
},
|
|
5104
|
+
onDateChange: Function,
|
|
5105
|
+
resources: {
|
|
5106
|
+
type: Array,
|
|
5107
|
+
required: true
|
|
5108
|
+
},
|
|
5109
|
+
startTime: {
|
|
5110
|
+
type: String,
|
|
5111
|
+
default: "00:00:00"
|
|
5112
|
+
},
|
|
5113
|
+
endTime: {
|
|
5114
|
+
type: String,
|
|
5115
|
+
default: "23:59:59"
|
|
5116
|
+
},
|
|
5117
|
+
intervalMinutes: {
|
|
5118
|
+
type: Number,
|
|
5119
|
+
default: 60
|
|
5120
|
+
},
|
|
5121
|
+
slotLabelFormat: {
|
|
5122
|
+
type: [String, Function],
|
|
5123
|
+
default: "HH:mm"
|
|
5124
|
+
},
|
|
5125
|
+
radius: [String, Number],
|
|
5126
|
+
startScrollDateTime: String,
|
|
5127
|
+
scrollAreaProps: Object,
|
|
5128
|
+
locale: String,
|
|
5129
|
+
withCurrentTimeIndicator: {
|
|
5130
|
+
type: Boolean,
|
|
5131
|
+
default: void 0
|
|
5132
|
+
},
|
|
5133
|
+
withCurrentTimeBubble: {
|
|
5134
|
+
type: Boolean,
|
|
5135
|
+
default: true
|
|
5136
|
+
},
|
|
5137
|
+
getCurrentTime: Function,
|
|
5138
|
+
withHeader: {
|
|
5139
|
+
type: Boolean,
|
|
5140
|
+
default: true
|
|
5141
|
+
},
|
|
5142
|
+
onViewChange: Function,
|
|
5143
|
+
previousControlProps: Object,
|
|
5144
|
+
nextControlProps: Object,
|
|
5145
|
+
todayControlProps: Object,
|
|
5146
|
+
viewSelectProps: Object,
|
|
5147
|
+
weekLabelFormat: {
|
|
5148
|
+
type: [String, Function],
|
|
5149
|
+
default: "MMM DD"
|
|
5150
|
+
},
|
|
5151
|
+
renderWeekLabel: Function,
|
|
5152
|
+
events: Array,
|
|
5153
|
+
slotWidth: {
|
|
5154
|
+
type: [String, Number],
|
|
5155
|
+
default: 60
|
|
5156
|
+
},
|
|
5157
|
+
rowHeight: {
|
|
5158
|
+
type: [String, Number],
|
|
5159
|
+
default: 64
|
|
5160
|
+
},
|
|
5161
|
+
labels: Object,
|
|
5162
|
+
highlightBusinessHours: Boolean,
|
|
5163
|
+
businessHours: {
|
|
5164
|
+
type: Array,
|
|
5165
|
+
default: () => ["09:00:00", "17:00:00"]
|
|
5166
|
+
},
|
|
5167
|
+
renderEventBody: Function,
|
|
5168
|
+
renderEvent: Function,
|
|
5169
|
+
renderResourceLabel: Function,
|
|
5170
|
+
groups: Array,
|
|
5171
|
+
renderGroupLabel: Function,
|
|
5172
|
+
groupLabelWidth: {
|
|
5173
|
+
type: [String, Number],
|
|
5174
|
+
default: 80
|
|
5175
|
+
},
|
|
5176
|
+
withEventsDragAndDrop: Boolean,
|
|
5177
|
+
onEventDrop: Function,
|
|
5178
|
+
canDragEvent: Function,
|
|
5179
|
+
onEventDragStart: Function,
|
|
5180
|
+
onEventDragEnd: Function,
|
|
5181
|
+
onTimeSlotClick: Function,
|
|
5182
|
+
onEventClick: Function,
|
|
5183
|
+
withDragSlotSelect: Boolean,
|
|
5184
|
+
onSlotDragEnd: Function,
|
|
5185
|
+
mode: {
|
|
5186
|
+
type: String,
|
|
5187
|
+
default: "default"
|
|
5188
|
+
},
|
|
5189
|
+
onExternalEventDrop: Function,
|
|
5190
|
+
withEventResize: Boolean,
|
|
5191
|
+
onEventResize: Function,
|
|
5192
|
+
canResizeEvent: Function,
|
|
5193
|
+
recurrenceExpansionLimit: {
|
|
5194
|
+
type: Number,
|
|
5195
|
+
default: 2e3
|
|
5196
|
+
},
|
|
5197
|
+
maxEventsPerTimeSlot: {
|
|
5198
|
+
type: Number,
|
|
5199
|
+
default: 2
|
|
5200
|
+
},
|
|
5201
|
+
moreEventsProps: Object,
|
|
5202
|
+
firstDayOfWeek: {
|
|
5203
|
+
type: Number,
|
|
5204
|
+
default: 1
|
|
5205
|
+
},
|
|
5206
|
+
weekendDays: {
|
|
5207
|
+
type: Array,
|
|
5208
|
+
default: () => [0, 6]
|
|
5209
|
+
},
|
|
5210
|
+
withWeekendDays: {
|
|
5211
|
+
type: Boolean,
|
|
5212
|
+
default: true
|
|
5213
|
+
},
|
|
5214
|
+
weekdayFormat: {
|
|
5215
|
+
type: [String, Function],
|
|
5216
|
+
default: "ddd D"
|
|
5217
|
+
},
|
|
5218
|
+
highlightToday: {
|
|
5219
|
+
type: Boolean,
|
|
5220
|
+
default: true
|
|
5221
|
+
}
|
|
5222
|
+
},
|
|
5223
|
+
setup(props, { attrs, slots }) {
|
|
5224
|
+
const theme = (0, _mantine_vue_core.useSafeMantineTheme)();
|
|
5225
|
+
const controls = [];
|
|
5226
|
+
const rootElement = (0, vue.ref)(null);
|
|
5227
|
+
const rowContainers = /* @__PURE__ */ new Map();
|
|
5228
|
+
const dropTarget = (0, vue.ref)(null);
|
|
5229
|
+
const scrolledX = (0, vue.ref)(false);
|
|
5230
|
+
const intervals = (0, vue.computed)(() => getDayTimeIntervals({
|
|
5231
|
+
startTime: props.startTime,
|
|
5232
|
+
endTime: props.endTime,
|
|
5233
|
+
intervalMinutes: props.intervalMinutes
|
|
5234
|
+
}));
|
|
5235
|
+
const weekdays = (0, vue.computed)(() => getWeekDays({
|
|
5236
|
+
week: props.date,
|
|
5237
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
5238
|
+
weekendDays: props.weekendDays,
|
|
5239
|
+
withWeekendDays: props.withWeekendDays
|
|
5240
|
+
}).map((day) => (0, dayjs.default)(day).format("YYYY-MM-DD")));
|
|
5241
|
+
const ordered = (0, vue.computed)(() => getOrderedResources(props.resources, props.groups));
|
|
5242
|
+
const resourceIdMap = (0, vue.computed)(() => getGroupToResourceIdMap(props.resources));
|
|
5243
|
+
const weekEvents = (0, vue.computed)(() => getResourcesWeekViewEvents({
|
|
5244
|
+
events: props.events,
|
|
5245
|
+
resources: props.resources,
|
|
5246
|
+
weekdays: weekdays.value,
|
|
5247
|
+
startTime: props.startTime,
|
|
5248
|
+
endTime: props.endTime,
|
|
5249
|
+
intervalMinutes: props.intervalMinutes,
|
|
5250
|
+
expansionLimit: props.recurrenceExpansionLimit
|
|
5251
|
+
}));
|
|
5252
|
+
(0, vue.onMounted)(async () => {
|
|
5253
|
+
if (!props.startScrollDateTime) return;
|
|
5254
|
+
await (0, vue.nextTick)();
|
|
5255
|
+
const target = (0, dayjs.default)(props.startScrollDateTime);
|
|
5256
|
+
const dayIndex = weekdays.value.findIndex((day) => (0, dayjs.default)(day).isSame(target, "day"));
|
|
5257
|
+
if (dayIndex < 0) return;
|
|
5258
|
+
const targetTime = target.format("HH:mm:ss");
|
|
5259
|
+
const intervalIndex = intervals.value.findIndex((interval) => interval.startTime >= targetTime);
|
|
5260
|
+
if (intervalIndex < 0) return;
|
|
5261
|
+
const flatIndex = dayIndex * intervals.value.length + intervalIndex;
|
|
5262
|
+
const targetSlot = controls[0]?.[flatIndex];
|
|
5263
|
+
const viewport = rootElement.value?.querySelector(".mantine-ScrollArea-viewport");
|
|
5264
|
+
if (targetSlot && viewport) {
|
|
5265
|
+
viewport.scrollLeft = targetSlot.offsetLeft;
|
|
5266
|
+
requestAnimationFrame(() => viewport.scrollLeft = targetSlot.offsetLeft);
|
|
5267
|
+
}
|
|
5268
|
+
});
|
|
5269
|
+
const slotSelect = useSlotDragSelect({
|
|
5270
|
+
enabled: () => props.withDragSlotSelect && props.mode !== "static",
|
|
5271
|
+
onDragEnd: () => (start, end, group) => {
|
|
5272
|
+
const count = intervals.value.length;
|
|
5273
|
+
const startDay = Math.floor(start / count);
|
|
5274
|
+
const endDay = Math.floor(end / count);
|
|
5275
|
+
const first = intervals.value[start % count];
|
|
5276
|
+
const last = intervals.value[end % count];
|
|
5277
|
+
if (first && last && weekdays.value[startDay] && weekdays.value[endDay]) props.onSlotDragEnd?.({
|
|
5278
|
+
rangeStart: `${(0, dayjs.default)(weekdays.value[startDay]).format("YYYY-MM-DD")} ${first.startTime}`,
|
|
5279
|
+
rangeEnd: `${(0, dayjs.default)(weekdays.value[endDay]).format("YYYY-MM-DD")} ${last.endTime}`,
|
|
5280
|
+
resourceId: resourceIdMap.value.get(group)
|
|
5281
|
+
});
|
|
5282
|
+
}
|
|
5283
|
+
});
|
|
5284
|
+
const resize = useHorizontalEventResize({
|
|
5285
|
+
enabled: () => props.withEventResize,
|
|
5286
|
+
mode: () => props.mode,
|
|
5287
|
+
startTime: () => props.startTime,
|
|
5288
|
+
endTime: () => props.endTime,
|
|
5289
|
+
intervalMinutes: () => props.intervalMinutes,
|
|
5290
|
+
onEventResize: () => props.onEventResize,
|
|
5291
|
+
canResizeEvent: () => props.canResizeEvent
|
|
5292
|
+
});
|
|
5293
|
+
const emitDrop = (nativeEvent, resourceId, flatIndex) => {
|
|
5294
|
+
nativeEvent.preventDefault();
|
|
5295
|
+
dropTarget.value = null;
|
|
5296
|
+
const count = intervals.value.length;
|
|
5297
|
+
const day = weekdays.value[Math.floor(flatIndex / count)];
|
|
5298
|
+
const interval = intervals.value[flatIndex % count];
|
|
5299
|
+
if (!day || !interval) return;
|
|
5300
|
+
const target = `${(0, dayjs.default)(day).format("YYYY-MM-DD")} ${interval.startTime}`;
|
|
5301
|
+
const event = getDropEvent(props.events, nativeEvent.dataTransfer);
|
|
5302
|
+
if (event) props.onEventDrop?.({
|
|
5303
|
+
...moveEventTo(event, target),
|
|
5304
|
+
resourceId
|
|
5305
|
+
});
|
|
5306
|
+
else if (nativeEvent.dataTransfer) props.onExternalEventDrop?.({
|
|
5307
|
+
dataTransfer: nativeEvent.dataTransfer,
|
|
5308
|
+
dropDateTime: target,
|
|
5309
|
+
resourceId
|
|
5310
|
+
});
|
|
5311
|
+
};
|
|
5312
|
+
const getFlatIndexAtPoint = (nativeEvent, resourceIndex) => {
|
|
5313
|
+
const container = rowContainers.get(resourceIndex);
|
|
5314
|
+
const count = intervals.value.length * weekdays.value.length;
|
|
5315
|
+
if (!container || count === 0) return -1;
|
|
5316
|
+
const rect = container.getBoundingClientRect();
|
|
5317
|
+
if (rect.width <= 0) return -1;
|
|
5318
|
+
return Math.max(0, Math.min(count - 1, Math.floor((nativeEvent.clientX - rect.left) / rect.width * count)));
|
|
5319
|
+
};
|
|
5320
|
+
const groupCell = (info) => {
|
|
5321
|
+
if (info === void 0) return null;
|
|
5322
|
+
if (info === null) return (0, vue.h)(_mantine_vue_core.Box, { class: ResourcesWeekView_module_default.resourcesWeekViewGroupColumnEmpty });
|
|
5323
|
+
const starts = info.position === "first" || info.position === "only";
|
|
5324
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
5325
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewGroupColumn,
|
|
5326
|
+
"data-group-position": info.position
|
|
5327
|
+
}, () => starts ? (0, vue.h)("span", { style: info.count > 1 ? { transform: `translateY(calc((${info.count - 1} * (var(--resources-week-view-row-height) + 1px)) / 2))` } : void 0 }, slots.groupLabel?.({ group: info.group }) ?? props.renderGroupLabel?.(info.group) ?? info.group.label ?? void 0) : null);
|
|
5328
|
+
};
|
|
5329
|
+
return () => {
|
|
5330
|
+
const dayCount = weekdays.value.length;
|
|
5331
|
+
const slotsPerDay = intervals.value.length;
|
|
5332
|
+
const hasGroups = ordered.value.groupRanges.length > 0;
|
|
5333
|
+
const now = (0, dayjs.default)(props.getCurrentTime?.() ?? /* @__PURE__ */ new Date());
|
|
5334
|
+
const todayIndex = weekdays.value.findIndex((day) => (0, dayjs.default)(day).isSame(now, "day"));
|
|
5335
|
+
const showIndicator = (props.withCurrentTimeIndicator ?? todayIndex !== -1) && todayIndex !== -1 && isInTimeRange({
|
|
5336
|
+
date: now.toDate(),
|
|
5337
|
+
startTime: props.startTime,
|
|
5338
|
+
endTime: props.endTime
|
|
5339
|
+
});
|
|
5340
|
+
const indicatorOffset = (todayIndex + getCurrentTimePosition({
|
|
5341
|
+
startTime: props.startTime,
|
|
5342
|
+
endTime: props.endTime,
|
|
5343
|
+
intervalMinutes: props.intervalMinutes,
|
|
5344
|
+
now
|
|
5345
|
+
}) / 100) / dayCount * 100;
|
|
5346
|
+
const currentTime = formatDate({
|
|
5347
|
+
date: now,
|
|
5348
|
+
locale: props.locale || "en",
|
|
5349
|
+
format: props.slotLabelFormat
|
|
5350
|
+
});
|
|
5351
|
+
const dayLabels = weekdays.value.map((day) => {
|
|
5352
|
+
const label = formatDate({
|
|
5353
|
+
date: day,
|
|
5354
|
+
locale: props.locale || "en",
|
|
5355
|
+
format: props.weekdayFormat
|
|
5356
|
+
});
|
|
5357
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
5358
|
+
key: day,
|
|
5359
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewDayLabel,
|
|
5360
|
+
style: { flex: `0 0 calc(var(--resources-week-view-slot-width) * ${slotsPerDay})` },
|
|
5361
|
+
"data-weekend": props.weekendDays.includes((0, dayjs.default)(day).day()) || void 0,
|
|
5362
|
+
"data-today": props.highlightToday && (0, dayjs.default)(day).isSame(now, "day") || void 0
|
|
5363
|
+
}, () => slots.dayLabel?.({
|
|
5364
|
+
date: day,
|
|
5365
|
+
label
|
|
5366
|
+
}) ?? label);
|
|
5367
|
+
});
|
|
5368
|
+
const timeLabels = weekdays.value.flatMap((day) => intervals.value.map((interval) => {
|
|
5369
|
+
const label = formatDate({
|
|
5370
|
+
date: `${day} ${interval.startTime}`,
|
|
5371
|
+
locale: props.locale || "en",
|
|
5372
|
+
format: props.slotLabelFormat
|
|
5373
|
+
});
|
|
5374
|
+
const mod = getBusinessHoursMod({
|
|
5375
|
+
time: interval.startTime,
|
|
5376
|
+
businessHours: props.businessHours,
|
|
5377
|
+
highlightBusinessHours: props.highlightBusinessHours,
|
|
5378
|
+
dayOfWeek: (0, dayjs.default)(day).day()
|
|
5379
|
+
});
|
|
5380
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
5381
|
+
key: `${day}-${interval.startTime}`,
|
|
5382
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewTimeLabel,
|
|
5383
|
+
"data-business-hours": mod["business-hours"] || void 0,
|
|
5384
|
+
"data-non-business-hours": mod["non-business-hours"] || void 0
|
|
5385
|
+
}, () => slots.timeLabel?.({
|
|
5386
|
+
date: day,
|
|
5387
|
+
label,
|
|
5388
|
+
startTime: interval.startTime,
|
|
5389
|
+
endTime: interval.endTime
|
|
5390
|
+
}) ?? label);
|
|
5391
|
+
}));
|
|
5392
|
+
const rows = ordered.value.orderedResources.map((resource, resourceIndex) => {
|
|
5393
|
+
const background = [];
|
|
5394
|
+
const regular = [];
|
|
5395
|
+
const more = [];
|
|
5396
|
+
weekdays.value.forEach((day, dayIndex) => {
|
|
5397
|
+
const data = weekEvents.value.byDay[day];
|
|
5398
|
+
const dayOffset = dayIndex / dayCount * 100;
|
|
5399
|
+
const dayWidth = 100 / dayCount;
|
|
5400
|
+
[...data.backgroundTimedEvents[resource.id] || [], ...data.backgroundAllDayEvents[resource.id] || []].forEach((event) => {
|
|
5401
|
+
const colors = theme.value.variantColorResolver({
|
|
5402
|
+
color: event.color || theme.value.primaryColor,
|
|
5403
|
+
theme: theme.value,
|
|
5404
|
+
variant: "light",
|
|
5405
|
+
autoContrast: true
|
|
5406
|
+
});
|
|
5407
|
+
background.push(slots.backgroundEvent?.({
|
|
5408
|
+
event,
|
|
5409
|
+
date: day
|
|
5410
|
+
}) ?? (0, vue.h)(_mantine_vue_core.Box, {
|
|
5411
|
+
key: `bg-${day}-${event.id}`,
|
|
5412
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewBackgroundEvent,
|
|
5413
|
+
style: {
|
|
5414
|
+
left: `${dayOffset + event.position.top / 100 * dayWidth}%`,
|
|
5415
|
+
width: `${event.position.height / 100 * dayWidth}%`,
|
|
5416
|
+
top: 0,
|
|
5417
|
+
height: "100%",
|
|
5418
|
+
"--bg-event-bg": colors.background,
|
|
5419
|
+
"--bg-event-color": colors.color
|
|
5420
|
+
}
|
|
5421
|
+
}, () => props.renderEventBody?.(event) ?? slots.eventBody?.({ event }) ?? event.title));
|
|
5422
|
+
});
|
|
5423
|
+
const allRegular = data.regularEvents[resource.id] || [];
|
|
5424
|
+
allRegular.filter((event) => event.position.column < Math.max(1, props.maxEventsPerTimeSlot)).forEach((event) => {
|
|
5425
|
+
const colors = theme.value.variantColorResolver({
|
|
5426
|
+
color: event.color || theme.value.primaryColor,
|
|
5427
|
+
theme: theme.value,
|
|
5428
|
+
variant: event.variant || "light",
|
|
5429
|
+
autoContrast: true
|
|
5430
|
+
});
|
|
5431
|
+
const position = resize.getResizePosition(event.id);
|
|
5432
|
+
const relativeLeft = position?.left ?? event.position.top;
|
|
5433
|
+
const relativeWidth = position?.width ?? event.position.height;
|
|
5434
|
+
const isResizable = resize.isResizableEvent(event);
|
|
5435
|
+
regular.push((0, vue.h)(_mantine_vue_core.Box, {
|
|
5436
|
+
key: `${day}-${event.id}`,
|
|
5437
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewEventWrapper,
|
|
5438
|
+
"data-resizing": position !== null || void 0,
|
|
5439
|
+
style: {
|
|
5440
|
+
"--event-color": colors.color,
|
|
5441
|
+
left: `calc(${dayOffset + relativeLeft / 100 * dayWidth}% + 1px)`,
|
|
5442
|
+
width: `calc(${relativeWidth / 100 * dayWidth}% - 2px)`,
|
|
5443
|
+
top: `${event.position.offset}%`,
|
|
5444
|
+
height: `${event.position.width}%`
|
|
5445
|
+
}
|
|
5446
|
+
}, () => [(0, vue.h)(ScheduleEvent, {
|
|
5447
|
+
event,
|
|
5448
|
+
autoSize: true,
|
|
5449
|
+
nowrap: true,
|
|
5450
|
+
radius: props.radius,
|
|
5451
|
+
mode: props.mode,
|
|
5452
|
+
renderEvent: props.renderEvent,
|
|
5453
|
+
renderEventBody: props.renderEventBody,
|
|
5454
|
+
draggable: props.withEventsDragAndDrop && props.mode !== "static" && (props.canDragEvent?.(event) ?? true),
|
|
5455
|
+
onEventDragStart: props.onEventDragStart,
|
|
5456
|
+
onEventDragEnd: props.onEventDragEnd,
|
|
5457
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => {
|
|
5458
|
+
if (!resize.wasResizing()) props.onEventClick?.(event, nativeEvent);
|
|
5459
|
+
},
|
|
5460
|
+
style: {
|
|
5461
|
+
width: "100%",
|
|
5462
|
+
height: "100%"
|
|
5463
|
+
}
|
|
5464
|
+
}, forwardEventSlots(slots)), isResizable ? ["start", "end"].map((edge) => (0, vue.h)("div", {
|
|
5465
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewResizeHandle,
|
|
5466
|
+
"data-edge": edge,
|
|
5467
|
+
"data-active": resize.state.value?.edge === edge || void 0,
|
|
5468
|
+
"aria-label": `${edge === "start" ? "Resize event start" : "Resize event end"} ${event.title}`,
|
|
5469
|
+
onDragstart: (nativeEvent) => nativeEvent.preventDefault(),
|
|
5470
|
+
onPointerdown: (pointerEvent) => {
|
|
5471
|
+
const container = rowContainers.get(resourceIndex);
|
|
5472
|
+
if (container) resize.handleResizeStart({
|
|
5473
|
+
event,
|
|
5474
|
+
edge,
|
|
5475
|
+
container,
|
|
5476
|
+
originalLeft: event.position.top,
|
|
5477
|
+
originalWidth: event.position.height,
|
|
5478
|
+
eventDate: (0, dayjs.default)(day).format("YYYY-MM-DD"),
|
|
5479
|
+
dayIndex,
|
|
5480
|
+
dayCount,
|
|
5481
|
+
pointerEvent
|
|
5482
|
+
});
|
|
5483
|
+
}
|
|
5484
|
+
})) : null]));
|
|
5485
|
+
});
|
|
5486
|
+
getOverlapClusters(allRegular).filter((cluster) => cluster.some((event) => event.position.column >= props.maxEventsPerTimeSlot)).forEach((cluster) => {
|
|
5487
|
+
const hiddenCount = cluster.filter((event) => event.position.column >= props.maxEventsPerTimeSlot).length;
|
|
5488
|
+
const left = Math.min(...cluster.map((event) => event.position.top));
|
|
5489
|
+
const right = Math.max(...cluster.map((event) => event.position.top + event.position.height));
|
|
5490
|
+
more.push(slots.moreEvents?.({
|
|
5491
|
+
events: cluster,
|
|
5492
|
+
hiddenCount,
|
|
5493
|
+
date: day
|
|
5494
|
+
}) ?? (0, vue.h)(MoreEvents, {
|
|
5495
|
+
...props.moreEventsProps,
|
|
5496
|
+
key: `more-${day}-${cluster[0].id}`,
|
|
5497
|
+
events: cluster,
|
|
5498
|
+
moreEventsCount: hiddenCount,
|
|
5499
|
+
mode: props.mode,
|
|
5500
|
+
labels: props.labels,
|
|
5501
|
+
renderEventBody: props.renderEventBody,
|
|
5502
|
+
renderEvent: props.renderEvent,
|
|
5503
|
+
onEventClick: props.onEventClick,
|
|
5504
|
+
style: {
|
|
5505
|
+
position: "absolute",
|
|
5506
|
+
left: `calc(${dayOffset + left / 100 * dayWidth}% + 1px)`,
|
|
5507
|
+
width: `calc(${(right - left) / 100 * dayWidth}% - 2px)`,
|
|
5508
|
+
bottom: 0,
|
|
5509
|
+
height: "22px",
|
|
5510
|
+
zIndex: 4
|
|
5511
|
+
}
|
|
5512
|
+
}, forwardEventSlots(slots)));
|
|
5513
|
+
});
|
|
5514
|
+
});
|
|
5515
|
+
const allDayBars = weekEvents.value.allDayBars[resource.id] || [];
|
|
5516
|
+
const allDay = allDayBars.map((bar) => (0, vue.h)(_mantine_vue_core.Box, {
|
|
5517
|
+
key: `all-${bar.event.id}`,
|
|
5518
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewAllDayEvent,
|
|
5519
|
+
style: {
|
|
5520
|
+
left: `calc(${bar.startDayIndex / dayCount * 100}% + 1px)`,
|
|
5521
|
+
width: `calc(${(bar.endDayIndex - bar.startDayIndex + 1) / dayCount * 100}% - 2px)`,
|
|
5522
|
+
top: `calc(${bar.row} * (var(--resources-week-view-all-day-height) + 2px) + 2px)`
|
|
5523
|
+
}
|
|
5524
|
+
}, () => slots.allDayEvent?.({
|
|
5525
|
+
event: bar.event,
|
|
5526
|
+
startDayIndex: bar.startDayIndex,
|
|
5527
|
+
endDayIndex: bar.endDayIndex
|
|
5528
|
+
}) ?? (0, vue.h)(ScheduleEvent, {
|
|
5529
|
+
event: bar.event,
|
|
5530
|
+
autoSize: true,
|
|
5531
|
+
nowrap: true,
|
|
5532
|
+
radius: props.radius,
|
|
5533
|
+
mode: props.mode,
|
|
5534
|
+
renderEvent: props.renderEvent,
|
|
5535
|
+
renderEventBody: props.renderEventBody,
|
|
5536
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => props.onEventClick?.(bar.event, nativeEvent),
|
|
5537
|
+
style: {
|
|
5538
|
+
width: "100%",
|
|
5539
|
+
height: "100%"
|
|
5540
|
+
}
|
|
5541
|
+
}, forwardEventSlots(slots))));
|
|
5542
|
+
const slotGroup = String(resource.id);
|
|
5543
|
+
const buttons = weekdays.value.flatMap((day, dayIndex) => intervals.value.map((interval, slotIndex) => {
|
|
5544
|
+
const flatIndex = dayIndex * slotsPerDay + slotIndex;
|
|
5545
|
+
const mod = getBusinessHoursMod({
|
|
5546
|
+
time: interval.startTime,
|
|
5547
|
+
businessHours: props.businessHours,
|
|
5548
|
+
highlightBusinessHours: props.highlightBusinessHours,
|
|
5549
|
+
dayOfWeek: (0, dayjs.default)(day).day()
|
|
5550
|
+
});
|
|
5551
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
5552
|
+
key: `${day}-${interval.startTime}`,
|
|
5553
|
+
ref: (element) => {
|
|
5554
|
+
const button = element?.$el ?? element;
|
|
5555
|
+
controls[resourceIndex] ||= [];
|
|
5556
|
+
controls[resourceIndex][flatIndex] = button instanceof HTMLButtonElement ? button : void 0;
|
|
5557
|
+
},
|
|
5558
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewRowSlot,
|
|
5559
|
+
"data-business-hours": mod["business-hours"] || void 0,
|
|
5560
|
+
"data-non-business-hours": mod["non-business-hours"] || void 0,
|
|
5561
|
+
"data-drop-target": dropTarget.value?.resourceId === resource.id && dropTarget.value.flatIndex === flatIndex ? true : void 0,
|
|
5562
|
+
"data-drag-selected": slotSelect.isSlotSelected(flatIndex, slotGroup) || void 0,
|
|
5563
|
+
"data-static": props.mode === "static" || void 0,
|
|
5564
|
+
"data-drag-slot-index": props.withDragSlotSelect ? flatIndex : void 0,
|
|
5565
|
+
"data-drag-slot-group": props.withDragSlotSelect ? slotGroup : void 0,
|
|
5566
|
+
"aria-label": `${getLabel("resourceSlot", props.labels)} ${String(resource.label)} ${day} ${interval.startTime} - ${interval.endTime}`,
|
|
5567
|
+
tabindex: props.mode === "static" ? -1 : resourceIndex === 0 && flatIndex === 0 ? 0 : -1,
|
|
5568
|
+
onKeydown: (event) => handleResourcesGridKeyDown({
|
|
5569
|
+
controls,
|
|
5570
|
+
resourceIndex,
|
|
5571
|
+
slotIndex: flatIndex,
|
|
5572
|
+
event
|
|
5573
|
+
}),
|
|
5574
|
+
onPointerdown: props.mode === "static" ? void 0 : (event) => slotSelect.handleSlotPointerDown(event, flatIndex, slotGroup),
|
|
5575
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => props.onTimeSlotClick?.({
|
|
5576
|
+
slotStart: `${day} ${interval.startTime}`,
|
|
5577
|
+
slotEnd: `${day} ${interval.endTime}`,
|
|
5578
|
+
nativeEvent,
|
|
5579
|
+
resourceId: resource.id
|
|
5580
|
+
})
|
|
5581
|
+
}, () => slots.timeSlot?.({
|
|
5582
|
+
resource,
|
|
5583
|
+
date: day,
|
|
5584
|
+
startTime: interval.startTime,
|
|
5585
|
+
endTime: interval.endTime
|
|
5586
|
+
}));
|
|
5587
|
+
}));
|
|
5588
|
+
const info = hasGroups ? ordered.value.resourceGroupMap[resourceIndex] : void 0;
|
|
5589
|
+
const allDayRows = allDayBars.length ? Math.max(...allDayBars.map((bar) => bar.row)) + 1 : 0;
|
|
5590
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
5591
|
+
key: resource.id,
|
|
5592
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewRow
|
|
5593
|
+
}, () => [
|
|
5594
|
+
groupCell(info),
|
|
5595
|
+
(0, vue.h)(_mantine_vue_core.Box, {
|
|
5596
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewResourceLabel,
|
|
5597
|
+
"data-scrolled-x": scrolledX.value || void 0,
|
|
5598
|
+
"data-has-groups": info !== void 0 || void 0
|
|
5599
|
+
}, () => slots.resourceLabel?.({ resource }) ?? props.renderResourceLabel?.(resource) ?? resource.label),
|
|
5600
|
+
(0, vue.h)(_mantine_vue_core.Box, {
|
|
5601
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewRowSlots,
|
|
5602
|
+
ref: (element) => {
|
|
5603
|
+
const node = element?.$el ?? element;
|
|
5604
|
+
if (node instanceof HTMLElement) rowContainers.set(resourceIndex, node);
|
|
5605
|
+
},
|
|
5606
|
+
style: allDayRows ? { minHeight: `max(var(--resources-week-view-row-height), calc(${allDayRows} * (var(--resources-week-view-all-day-height) + 2px) + 4px))` } : void 0,
|
|
5607
|
+
onDragover: props.withEventsDragAndDrop || props.onExternalEventDrop ? (nativeEvent) => {
|
|
5608
|
+
if (props.mode === "static") return;
|
|
5609
|
+
nativeEvent.preventDefault();
|
|
5610
|
+
const flatIndex = getFlatIndexAtPoint(nativeEvent, resourceIndex);
|
|
5611
|
+
if (flatIndex >= 0 && (dropTarget.value?.resourceId !== resource.id || dropTarget.value.flatIndex !== flatIndex)) dropTarget.value = {
|
|
5612
|
+
resourceId: resource.id,
|
|
5613
|
+
flatIndex
|
|
5614
|
+
};
|
|
5615
|
+
} : void 0,
|
|
5616
|
+
onDragleave: props.withEventsDragAndDrop || props.onExternalEventDrop ? (nativeEvent) => {
|
|
5617
|
+
const related = nativeEvent.relatedTarget;
|
|
5618
|
+
const current = nativeEvent.currentTarget;
|
|
5619
|
+
if (!(related instanceof Node) || !(current instanceof HTMLElement) || !current.contains(related)) dropTarget.value = null;
|
|
5620
|
+
} : void 0,
|
|
5621
|
+
onDrop: props.withEventsDragAndDrop || props.onExternalEventDrop ? (nativeEvent) => {
|
|
5622
|
+
const flatIndex = getFlatIndexAtPoint(nativeEvent, resourceIndex);
|
|
5623
|
+
if (flatIndex >= 0) emitDrop(nativeEvent, resource.id, flatIndex);
|
|
5624
|
+
} : void 0
|
|
5625
|
+
}, () => [
|
|
5626
|
+
...background,
|
|
5627
|
+
...allDay,
|
|
5628
|
+
...regular,
|
|
5629
|
+
...more,
|
|
5630
|
+
...buttons
|
|
5631
|
+
])
|
|
5632
|
+
]);
|
|
5633
|
+
});
|
|
5634
|
+
const weekStart = (0, dayjs.default)(weekdays.value[0]).format("YYYY-MM-DD");
|
|
5635
|
+
const weekEnd = (0, dayjs.default)(weekdays.value.at(-1)).format("YYYY-MM-DD");
|
|
5636
|
+
const headerLabel = props.renderWeekLabel?.({
|
|
5637
|
+
weekStart,
|
|
5638
|
+
weekEnd
|
|
5639
|
+
}) ?? getWeekLabel({
|
|
5640
|
+
weekdays: weekdays.value,
|
|
5641
|
+
locale: props.locale || "en",
|
|
5642
|
+
weekLabelFormat: props.weekLabelFormat
|
|
5643
|
+
});
|
|
5644
|
+
const header = props.withHeader ? slots.header?.({
|
|
5645
|
+
weekStart,
|
|
5646
|
+
weekEnd,
|
|
5647
|
+
label: headerLabel
|
|
5648
|
+
}) ?? (0, vue.h)(ScheduleHeaderBase, {
|
|
5649
|
+
view: "week",
|
|
5650
|
+
navigationHandlers: {
|
|
5651
|
+
previous: () => (0, dayjs.default)(props.date).subtract(1, "week").format("YYYY-MM-DD"),
|
|
5652
|
+
next: () => (0, dayjs.default)(props.date).add(1, "week").format("YYYY-MM-DD"),
|
|
5653
|
+
today: () => now.format("YYYY-MM-DD")
|
|
5654
|
+
},
|
|
5655
|
+
control: { title: headerLabel },
|
|
5656
|
+
labels: props.labels,
|
|
5657
|
+
onDateChange: props.onDateChange,
|
|
5658
|
+
onViewChange: props.onViewChange,
|
|
5659
|
+
previousControlProps: props.previousControlProps,
|
|
5660
|
+
nextControlProps: props.nextControlProps,
|
|
5661
|
+
todayControlProps: props.todayControlProps,
|
|
5662
|
+
viewSelectProps: {
|
|
5663
|
+
views: [
|
|
5664
|
+
"day",
|
|
5665
|
+
"week",
|
|
5666
|
+
"month"
|
|
5667
|
+
],
|
|
5668
|
+
...props.viewSelectProps
|
|
5669
|
+
}
|
|
5670
|
+
}) : null;
|
|
5671
|
+
const indicator = showIndicator ? slots.currentTimeIndicator?.({
|
|
5672
|
+
time: currentTime,
|
|
5673
|
+
offset: indicatorOffset,
|
|
5674
|
+
date: weekdays.value[todayIndex]
|
|
5675
|
+
}) ?? (0, vue.h)(_mantine_vue_core.Box, {
|
|
5676
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewCurrentTimeIndicator,
|
|
5677
|
+
style: {
|
|
5678
|
+
"--indicator-left-offset": hasGroups ? `calc(var(--resources-week-view-resource-label-width) + var(--resources-week-view-group-label-width) + (100% - var(--resources-week-view-resource-label-width) - var(--resources-week-view-group-label-width)) * ${indicatorOffset} / 100)` : `calc(var(--resources-week-view-resource-label-width) + (100% - var(--resources-week-view-resource-label-width)) * ${indicatorOffset} / 100)`,
|
|
5679
|
+
"--_time-bubble-width": String(currentTime).toLowerCase().includes("m") ? "64px" : "46px"
|
|
5680
|
+
}
|
|
5681
|
+
}, () => [props.withCurrentTimeBubble ? (0, vue.h)("div", { class: ResourcesWeekView_module_default.resourcesWeekViewCurrentTimeIndicatorTimeBubble }, currentTime) : (0, vue.h)("div", { class: ResourcesWeekView_module_default.resourcesWeekViewCurrentTimeIndicatorThumb }), (0, vue.h)("div", { class: ResourcesWeekView_module_default.resourcesWeekViewCurrentTimeIndicatorLine })]) : null;
|
|
5682
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
5683
|
+
...attrs,
|
|
5684
|
+
ref: (element) => {
|
|
5685
|
+
const node = element?.$el ?? element;
|
|
5686
|
+
rootElement.value = node instanceof HTMLElement ? node : null;
|
|
5687
|
+
},
|
|
5688
|
+
class: [ResourcesWeekView_module_default.resourcesWeekView, attrs.class],
|
|
5689
|
+
style: [{
|
|
5690
|
+
"--resources-week-view-radius": resolveScheduleRadius(props.radius),
|
|
5691
|
+
"--resources-week-view-slot-width": cssSize$1(props.slotWidth),
|
|
5692
|
+
"--resources-week-view-row-height": cssSize$1(props.rowHeight),
|
|
5693
|
+
"--resources-week-view-group-label-width": cssSize$1(props.groupLabelWidth)
|
|
5694
|
+
}, attrs.style],
|
|
5695
|
+
"data-resizing": resize.state.value ? true : void 0,
|
|
5696
|
+
"data-event-interaction": resize.state.value ? true : void 0
|
|
5697
|
+
}, () => [header, (0, vue.h)(_mantine_vue_core.Box, { class: ResourcesWeekView_module_default.resourcesWeekViewRoot }, () => (0, vue.h)(_mantine_vue_core.ScrollArea, {
|
|
5698
|
+
scrollbarSize: 4,
|
|
5699
|
+
...props.scrollAreaProps,
|
|
5700
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewScrollArea,
|
|
5701
|
+
onScrollPositionChange: (position) => scrolledX.value = position.x !== 0
|
|
5702
|
+
}, () => (0, vue.h)("div", { class: ResourcesWeekView_module_default.resourcesWeekViewInner }, [
|
|
5703
|
+
(0, vue.h)(_mantine_vue_core.Box, { class: ResourcesWeekView_module_default.resourcesWeekViewHeaderRows }, () => [(0, vue.h)("div", {
|
|
5704
|
+
class: ResourcesWeekView_module_default.resourcesWeekViewCorner,
|
|
5705
|
+
style: hasGroups ? {
|
|
5706
|
+
flexBasis: "calc(var(--resources-week-view-resource-label-width) + var(--resources-week-view-group-label-width))",
|
|
5707
|
+
minWidth: "calc(var(--resources-week-view-resource-label-width) + var(--resources-week-view-group-label-width))"
|
|
5708
|
+
} : void 0
|
|
5709
|
+
}, slots.corner?.({ resources: ordered.value.orderedResources }) ?? getLabel("resources", props.labels)), (0, vue.h)("div", { class: ResourcesWeekView_module_default.resourcesWeekViewHeaderContent }, [(0, vue.h)("div", { class: ResourcesWeekView_module_default.resourcesWeekViewDayLabelsRow }, dayLabels), (0, vue.h)("div", { class: ResourcesWeekView_module_default.resourcesWeekViewTimeLabelsRow }, timeLabels)])]),
|
|
5710
|
+
...rows,
|
|
5711
|
+
indicator
|
|
5712
|
+
])))]);
|
|
5713
|
+
};
|
|
5714
|
+
}
|
|
5715
|
+
});
|
|
5716
|
+
var ResourcesMonthView_module_default = {
|
|
5717
|
+
resourcesMonthView: "_resourcesMonthView_wgbmp_1",
|
|
5718
|
+
resourcesMonthViewRoot: "_resourcesMonthViewRoot_wgbmp_17",
|
|
5719
|
+
resourcesMonthViewScrollArea: "_resourcesMonthViewScrollArea_wgbmp_24",
|
|
5720
|
+
resourcesMonthViewInner: "_resourcesMonthViewInner_wgbmp_33",
|
|
5721
|
+
resourcesMonthViewDayLabelsRow: "_resourcesMonthViewDayLabelsRow_wgbmp_37",
|
|
5722
|
+
resourcesMonthViewCorner: "_resourcesMonthViewCorner_wgbmp_46",
|
|
5723
|
+
resourcesMonthViewDayLabel: "_resourcesMonthViewDayLabel_wgbmp_37",
|
|
5724
|
+
resourcesMonthViewDayLabelWeekday: "_resourcesMonthViewDayLabelWeekday_wgbmp_85",
|
|
5725
|
+
resourcesMonthViewDayLabelNumber: "_resourcesMonthViewDayLabelNumber_wgbmp_92",
|
|
5726
|
+
resourcesMonthViewRow: "_resourcesMonthViewRow_wgbmp_97",
|
|
5727
|
+
resourcesMonthViewResourceLabel: "_resourcesMonthViewResourceLabel_wgbmp_101",
|
|
5728
|
+
resourcesMonthViewGroupColumn: "_resourcesMonthViewGroupColumn_wgbmp_120",
|
|
5729
|
+
resourcesMonthViewGroupColumnEmpty: "_resourcesMonthViewGroupColumnEmpty_wgbmp_121",
|
|
5730
|
+
resourcesMonthViewRowSlots: "_resourcesMonthViewRowSlots_wgbmp_149",
|
|
5731
|
+
resourcesMonthViewCell: "_resourcesMonthViewCell_wgbmp_154"
|
|
5732
|
+
};
|
|
5733
|
+
//#endregion
|
|
5734
|
+
//#region src/components/ResourcesMonthView/ResourcesMonthView.ts
|
|
5735
|
+
var cssSize = (value) => typeof value === "number" ? `${value}px` : value;
|
|
5736
|
+
var isMulti = (event) => (0, dayjs.default)(event.end).startOf("day").isAfter((0, dayjs.default)(event.start).startOf("day"));
|
|
5737
|
+
var compareEvents = (a, b) => {
|
|
5738
|
+
const aSpan = (0, dayjs.default)(a.end).startOf("day").diff((0, dayjs.default)(a.start).startOf("day"), "day");
|
|
5739
|
+
const bSpan = (0, dayjs.default)(b.end).startOf("day").diff((0, dayjs.default)(b.start).startOf("day"), "day");
|
|
5740
|
+
return aSpan === bSpan ? (0, dayjs.default)(a.start).valueOf() - (0, dayjs.default)(b.start).valueOf() : bSpan - aSpan;
|
|
5741
|
+
};
|
|
5742
|
+
var ResourcesMonthView = (0, vue.defineComponent)({
|
|
5743
|
+
name: "ResourcesMonthView",
|
|
5744
|
+
inheritAttrs: false,
|
|
5745
|
+
slots: Object,
|
|
5746
|
+
props: {
|
|
5747
|
+
date: {
|
|
5748
|
+
type: [String, Date],
|
|
5749
|
+
required: true
|
|
5750
|
+
},
|
|
5751
|
+
onDateChange: Function,
|
|
5752
|
+
resources: {
|
|
5753
|
+
type: Array,
|
|
5754
|
+
required: true
|
|
5755
|
+
},
|
|
5756
|
+
locale: String,
|
|
5757
|
+
weekdayFormat: {
|
|
5758
|
+
type: [String, Function],
|
|
5759
|
+
default: "ddd"
|
|
5760
|
+
},
|
|
5761
|
+
weekendDays: {
|
|
5762
|
+
type: Array,
|
|
5763
|
+
default: () => [0, 6]
|
|
5764
|
+
},
|
|
5765
|
+
withWeekendDays: {
|
|
5766
|
+
type: Boolean,
|
|
5767
|
+
default: true
|
|
5768
|
+
},
|
|
5769
|
+
startScrollDate: String,
|
|
5770
|
+
onDayClick: Function,
|
|
5771
|
+
highlightToday: {
|
|
5772
|
+
type: Boolean,
|
|
5773
|
+
default: true
|
|
5774
|
+
},
|
|
5775
|
+
radius: [String, Number],
|
|
5776
|
+
withHeader: {
|
|
5777
|
+
type: Boolean,
|
|
5778
|
+
default: true
|
|
5779
|
+
},
|
|
5780
|
+
monthYearSelectProps: Object,
|
|
5781
|
+
onViewChange: Function,
|
|
5782
|
+
previousControlProps: Object,
|
|
5783
|
+
nextControlProps: Object,
|
|
5784
|
+
todayControlProps: Object,
|
|
5785
|
+
viewSelectProps: Object,
|
|
5786
|
+
events: Array,
|
|
5787
|
+
dayWidth: {
|
|
5788
|
+
type: [String, Number],
|
|
5789
|
+
default: 80
|
|
5790
|
+
},
|
|
5791
|
+
rowHeight: {
|
|
5792
|
+
type: [String, Number],
|
|
5793
|
+
default: 64
|
|
5794
|
+
},
|
|
5795
|
+
renderEventBody: Function,
|
|
5796
|
+
renderEvent: Function,
|
|
5797
|
+
renderResourceLabel: Function,
|
|
5798
|
+
groups: Array,
|
|
5799
|
+
renderGroupLabel: Function,
|
|
5800
|
+
groupLabelWidth: {
|
|
5801
|
+
type: [String, Number],
|
|
5802
|
+
default: 80
|
|
5803
|
+
},
|
|
5804
|
+
withEventsDragAndDrop: Boolean,
|
|
5805
|
+
onEventDrop: Function,
|
|
5806
|
+
canDragEvent: Function,
|
|
5807
|
+
onEventDragStart: Function,
|
|
5808
|
+
onEventDragEnd: Function,
|
|
5809
|
+
onEventClick: Function,
|
|
5810
|
+
withDragSlotSelect: Boolean,
|
|
5811
|
+
onSlotDragEnd: Function,
|
|
5812
|
+
labels: Object,
|
|
5813
|
+
mode: {
|
|
5814
|
+
type: String,
|
|
5815
|
+
default: "default"
|
|
5816
|
+
},
|
|
5817
|
+
scrollAreaProps: Object,
|
|
5818
|
+
onExternalEventDrop: Function,
|
|
5819
|
+
maxEventsPerTimeSlot: {
|
|
5820
|
+
type: Number,
|
|
5821
|
+
default: 2
|
|
5822
|
+
},
|
|
5823
|
+
moreEventsProps: Object,
|
|
5824
|
+
recurrenceExpansionLimit: {
|
|
5825
|
+
type: Number,
|
|
5826
|
+
default: 2e3
|
|
5827
|
+
}
|
|
5828
|
+
},
|
|
5829
|
+
setup(props, { attrs, slots }) {
|
|
5830
|
+
const controls = [];
|
|
5831
|
+
const rowContainers = /* @__PURE__ */ new Map();
|
|
5832
|
+
const rootElement = (0, vue.ref)(null);
|
|
5833
|
+
const dropTarget = (0, vue.ref)(null);
|
|
5834
|
+
const days = (0, vue.computed)(() => {
|
|
5835
|
+
const month = (0, dayjs.default)(props.date).startOf("month");
|
|
5836
|
+
return Array.from({ length: month.daysInMonth() }, (_, index) => month.date(index + 1)).filter((day) => props.withWeekendDays || !props.weekendDays.includes(day.day())).map((day) => day.format("YYYY-MM-DD"));
|
|
5837
|
+
});
|
|
5838
|
+
const ordered = (0, vue.computed)(() => getOrderedResources(props.resources, props.groups));
|
|
5839
|
+
const idMap = (0, vue.computed)(() => getGroupToResourceIdMap(props.resources));
|
|
5840
|
+
const expanded = (0, vue.computed)(() => expandRecurringEvents({
|
|
5841
|
+
events: props.events,
|
|
5842
|
+
rangeStart: (0, dayjs.default)(props.date).startOf("month").toDate(),
|
|
5843
|
+
rangeEnd: (0, dayjs.default)(props.date).endOf("month").toDate(),
|
|
5844
|
+
expansionLimit: props.recurrenceExpansionLimit
|
|
5845
|
+
}));
|
|
5846
|
+
const slotSelect = useSlotDragSelect({
|
|
5847
|
+
enabled: () => props.withDragSlotSelect && props.mode !== "static",
|
|
5848
|
+
onDragEnd: () => props.onSlotDragEnd ? (start, end, group) => {
|
|
5849
|
+
const first = days.value[start];
|
|
5850
|
+
const last = days.value[end];
|
|
5851
|
+
if (first && last) props.onSlotDragEnd?.({
|
|
5852
|
+
rangeStart: `${first} 00:00:00`,
|
|
5853
|
+
rangeEnd: (0, dayjs.default)(last).endOf("day").format("YYYY-MM-DD HH:mm:ss"),
|
|
5854
|
+
resourceId: idMap.value.get(group) ?? group
|
|
5855
|
+
});
|
|
5856
|
+
} : void 0
|
|
5857
|
+
});
|
|
5858
|
+
(0, vue.onMounted)(async () => {
|
|
5859
|
+
if (!props.startScrollDate) return;
|
|
5860
|
+
await (0, vue.nextTick)();
|
|
5861
|
+
const index = days.value.indexOf((0, dayjs.default)(props.startScrollDate).format("YYYY-MM-DD"));
|
|
5862
|
+
const target = controls[0]?.[index];
|
|
5863
|
+
const viewport = rootElement.value?.querySelector(".mantine-ScrollArea-viewport");
|
|
5864
|
+
if (target && viewport) {
|
|
5865
|
+
viewport.scrollLeft = target.offsetLeft;
|
|
5866
|
+
requestAnimationFrame(() => viewport.scrollLeft = target.offsetLeft);
|
|
5867
|
+
}
|
|
5868
|
+
});
|
|
5869
|
+
const indexAtPoint = (event, resourceIndex) => {
|
|
5870
|
+
const container = rowContainers.get(resourceIndex);
|
|
5871
|
+
if (!container || !days.value.length) return -1;
|
|
5872
|
+
const rect = container.getBoundingClientRect();
|
|
5873
|
+
if (rect.width <= 0) return -1;
|
|
5874
|
+
return Math.max(0, Math.min(days.value.length - 1, Math.floor((event.clientX - rect.left) / rect.width * days.value.length)));
|
|
5875
|
+
};
|
|
5876
|
+
const emitDrop = (event, resourceId, dayIndex) => {
|
|
5877
|
+
event.preventDefault();
|
|
5878
|
+
dropTarget.value = null;
|
|
5879
|
+
const day = days.value[dayIndex];
|
|
5880
|
+
if (!day) return;
|
|
5881
|
+
const dragged = getDropEvent(expanded.value, event.dataTransfer);
|
|
5882
|
+
if (dragged) {
|
|
5883
|
+
const next = calculateMonthDropDate({
|
|
5884
|
+
draggedEvent: dragged,
|
|
5885
|
+
targetDay: day
|
|
5886
|
+
});
|
|
5887
|
+
props.onEventDrop?.({
|
|
5888
|
+
eventId: dragged.id,
|
|
5889
|
+
newStart: (0, dayjs.default)(next.start).format("YYYY-MM-DD HH:mm:ss"),
|
|
5890
|
+
newEnd: (0, dayjs.default)(next.end).format("YYYY-MM-DD HH:mm:ss"),
|
|
5891
|
+
event: dragged,
|
|
5892
|
+
resourceId
|
|
5893
|
+
});
|
|
5894
|
+
} else if (event.dataTransfer) props.onExternalEventDrop?.({
|
|
5895
|
+
dataTransfer: event.dataTransfer,
|
|
5896
|
+
dropDateTime: `${day} 00:00:00`,
|
|
5897
|
+
resourceId
|
|
5898
|
+
});
|
|
5899
|
+
};
|
|
5900
|
+
return () => {
|
|
5901
|
+
const maxRows = Math.min(10, Math.max(1, props.maxEventsPerTimeSlot));
|
|
5902
|
+
const hasGroups = ordered.value.groupRanges.length > 0;
|
|
5903
|
+
const monthStart = (0, dayjs.default)(days.value[0]).startOf("day");
|
|
5904
|
+
const monthEnd = (0, dayjs.default)(days.value.at(-1)).add(1, "day").startOf("day");
|
|
5905
|
+
const rows = ordered.value.orderedResources.map((resource, resourceIndex) => {
|
|
5906
|
+
const eventsByDay = days.value.map((day) => (expanded.value || []).filter((event) => event.resourceId === resource.id && (0, dayjs.default)(event.start).isBefore((0, dayjs.default)(day).endOf("day")) && (0, dayjs.default)(event.end).isAfter((0, dayjs.default)(day).startOf("day"))).sort(compareEvents));
|
|
5907
|
+
const layouts = [];
|
|
5908
|
+
const lastRow = /* @__PURE__ */ new Map();
|
|
5909
|
+
const rowByEvent = /* @__PURE__ */ new Map();
|
|
5910
|
+
eventsByDay.forEach((eventList, dayIndex) => {
|
|
5911
|
+
const used = /* @__PURE__ */ new Set();
|
|
5912
|
+
const visible = [];
|
|
5913
|
+
let hiddenCount = 0;
|
|
5914
|
+
eventList.forEach((event) => {
|
|
5915
|
+
let row = lastRow.get(event.id);
|
|
5916
|
+
if (row === void 0 || row >= maxRows || used.has(row)) row = Array.from({ length: maxRows }, (_, i) => i).find((i) => !used.has(i));
|
|
5917
|
+
if (row === void 0) {
|
|
5918
|
+
hiddenCount++;
|
|
5919
|
+
return;
|
|
5920
|
+
}
|
|
5921
|
+
used.add(row);
|
|
5922
|
+
visible.push({
|
|
5923
|
+
event,
|
|
5924
|
+
row
|
|
5925
|
+
});
|
|
5926
|
+
lastRow.set(event.id, row);
|
|
5927
|
+
if (!rowByEvent.has(event.id)) rowByEvent.set(event.id, /* @__PURE__ */ new Map());
|
|
5928
|
+
rowByEvent.get(event.id).set(dayIndex, row);
|
|
5929
|
+
});
|
|
5930
|
+
layouts.push({
|
|
5931
|
+
visible,
|
|
5932
|
+
hiddenCount
|
|
5933
|
+
});
|
|
5934
|
+
});
|
|
5935
|
+
const segments = [];
|
|
5936
|
+
Array.from(new Map(eventsByDay.flat().filter(isMulti).map((event) => [event.id, event])).values()).forEach((event) => {
|
|
5937
|
+
const rowsForEvent = rowByEvent.get(event.id);
|
|
5938
|
+
let run = null;
|
|
5939
|
+
const flush = () => {
|
|
5940
|
+
if (!run) return;
|
|
5941
|
+
const before = (0, dayjs.default)(event.start).isBefore(monthStart);
|
|
5942
|
+
const after = (0, dayjs.default)(event.end).isAfter(monthEnd);
|
|
5943
|
+
segments.push({
|
|
5944
|
+
event,
|
|
5945
|
+
...run,
|
|
5946
|
+
hanging: before && after ? "both" : before ? "start" : after ? "end" : "none",
|
|
5947
|
+
hidden: Array.from({ length: run.end - run.start + 1 }, (_, i) => layouts[run.start + i].hiddenCount > 0).some(Boolean)
|
|
5948
|
+
});
|
|
5949
|
+
run = null;
|
|
5950
|
+
};
|
|
5951
|
+
days.value.forEach((_day, index) => {
|
|
5952
|
+
const row = rowsForEvent?.get(index);
|
|
5953
|
+
if (row === void 0) flush();
|
|
5954
|
+
else if (run && run.row === row && run.end === index - 1) run.end = index;
|
|
5955
|
+
else {
|
|
5956
|
+
flush();
|
|
5957
|
+
run = {
|
|
5958
|
+
start: index,
|
|
5959
|
+
end: index,
|
|
5960
|
+
row
|
|
5961
|
+
};
|
|
5962
|
+
}
|
|
5963
|
+
});
|
|
5964
|
+
flush();
|
|
5965
|
+
});
|
|
5966
|
+
const eventNodes = [];
|
|
5967
|
+
layouts.forEach((layout, dayIndex) => layout.visible.forEach(({ event, row }) => {
|
|
5968
|
+
if (isMulti(event)) return;
|
|
5969
|
+
const compressed = layout.hiddenCount > 0 && props.mode !== "static";
|
|
5970
|
+
eventNodes.push((0, vue.h)(ScheduleEvent, {
|
|
5971
|
+
key: `${event.id}-${dayIndex}`,
|
|
5972
|
+
event,
|
|
5973
|
+
autoSize: true,
|
|
5974
|
+
nowrap: true,
|
|
5975
|
+
radius: props.radius,
|
|
5976
|
+
mode: props.mode,
|
|
5977
|
+
renderEvent: props.renderEvent,
|
|
5978
|
+
renderEventBody: props.renderEventBody,
|
|
5979
|
+
draggable: props.withEventsDragAndDrop && props.mode !== "static" && (props.canDragEvent?.(event) ?? true),
|
|
5980
|
+
onEventDragStart: props.onEventDragStart,
|
|
5981
|
+
onEventDragEnd: props.onEventDragEnd,
|
|
5982
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => props.onEventClick?.(event, nativeEvent),
|
|
5983
|
+
style: {
|
|
5984
|
+
position: "absolute",
|
|
5985
|
+
left: `calc(${dayIndex / days.value.length * 100}% + 1px)`,
|
|
5986
|
+
width: `calc(${100 / days.value.length}% - 2px)`,
|
|
5987
|
+
top: compressed ? `calc((100% - 18px) * ${row} / ${maxRows} + 1px)` : `calc(${row / maxRows * 100}% + 1px)`,
|
|
5988
|
+
height: compressed ? `calc((100% - 18px) / ${maxRows} - 2px)` : `calc(${100 / maxRows}% - 2px)`,
|
|
5989
|
+
zIndex: 3
|
|
5990
|
+
}
|
|
5991
|
+
}, forwardEventSlots(slots)));
|
|
5992
|
+
}));
|
|
5993
|
+
segments.forEach((segment) => eventNodes.push((0, vue.h)(ScheduleEvent, {
|
|
5994
|
+
key: `${segment.event.id}-${segment.start}`,
|
|
5995
|
+
event: segment.event,
|
|
5996
|
+
hanging: segment.hanging,
|
|
5997
|
+
autoSize: true,
|
|
5998
|
+
nowrap: true,
|
|
5999
|
+
radius: props.radius,
|
|
6000
|
+
mode: props.mode,
|
|
6001
|
+
renderEvent: props.renderEvent,
|
|
6002
|
+
renderEventBody: props.renderEventBody,
|
|
6003
|
+
draggable: props.withEventsDragAndDrop && props.mode !== "static" && (props.canDragEvent?.(segment.event) ?? true),
|
|
6004
|
+
onEventDragStart: props.onEventDragStart,
|
|
6005
|
+
onEventDragEnd: props.onEventDragEnd,
|
|
6006
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => props.onEventClick?.(segment.event, nativeEvent),
|
|
6007
|
+
style: {
|
|
6008
|
+
position: "absolute",
|
|
6009
|
+
left: `calc(${segment.start / days.value.length * 100}% + 1px)`,
|
|
6010
|
+
width: `calc(${(segment.end - segment.start + 1) / days.value.length * 100}% - 2px)`,
|
|
6011
|
+
top: segment.hidden ? `calc((100% - 18px) * ${segment.row} / ${maxRows} + 1px)` : `calc(${segment.row / maxRows * 100}% + 1px)`,
|
|
6012
|
+
height: segment.hidden ? `calc((100% - 18px) / ${maxRows} - 2px)` : `calc(${100 / maxRows}% - 2px)`,
|
|
6013
|
+
zIndex: 3
|
|
6014
|
+
}
|
|
6015
|
+
}, forwardEventSlots(slots))));
|
|
6016
|
+
const moreNodes = layouts.map((layout, dayIndex) => layout.hiddenCount && props.mode !== "static" ? slots.moreEvents?.({
|
|
6017
|
+
events: eventsByDay[dayIndex],
|
|
6018
|
+
hiddenCount: layout.hiddenCount,
|
|
6019
|
+
resource,
|
|
6020
|
+
date: days.value[dayIndex]
|
|
6021
|
+
}) ?? (0, vue.h)(MoreEvents, {
|
|
6022
|
+
...props.moreEventsProps,
|
|
6023
|
+
key: `more-${dayIndex}`,
|
|
6024
|
+
events: eventsByDay[dayIndex],
|
|
6025
|
+
moreEventsCount: layout.hiddenCount,
|
|
6026
|
+
mode: props.mode,
|
|
6027
|
+
labels: props.labels,
|
|
6028
|
+
renderEvent: props.renderEvent,
|
|
6029
|
+
renderEventBody: props.renderEventBody,
|
|
6030
|
+
onEventClick: props.onEventClick,
|
|
6031
|
+
style: {
|
|
6032
|
+
position: "absolute",
|
|
6033
|
+
bottom: "1px",
|
|
6034
|
+
left: `calc(${dayIndex / days.value.length * 100}% + 1px)`,
|
|
6035
|
+
width: `calc(${100 / days.value.length}% - 2px)`,
|
|
6036
|
+
height: "18px",
|
|
6037
|
+
zIndex: 4
|
|
6038
|
+
}
|
|
6039
|
+
}, forwardEventSlots(slots)) : null);
|
|
6040
|
+
const group = hasGroups ? ordered.value.resourceGroupMap[resourceIndex] : void 0;
|
|
6041
|
+
const groupCell = group === void 0 ? null : group === null ? (0, vue.h)(_mantine_vue_core.Box, { class: ResourcesMonthView_module_default.resourcesMonthViewGroupColumnEmpty }) : (0, vue.h)(_mantine_vue_core.Box, {
|
|
6042
|
+
class: ResourcesMonthView_module_default.resourcesMonthViewGroupColumn,
|
|
6043
|
+
"data-group-position": group.position
|
|
6044
|
+
}, () => group.position === "first" || group.position === "only" ? (0, vue.h)("span", { style: group.count > 1 ? { transform: `translateY(calc((${group.count - 1} * (var(--resources-month-view-row-height) + 1px)) / 2))` } : void 0 }, slots.groupLabel?.({ group: group.group }) ?? props.renderGroupLabel?.(group.group) ?? group.group.label ?? void 0) : null);
|
|
6045
|
+
const cells = days.value.map((day, dayIndex) => {
|
|
6046
|
+
const weekend = props.weekendDays.includes((0, dayjs.default)(day).day());
|
|
6047
|
+
const groupId = String(resource.id);
|
|
6048
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
6049
|
+
key: day,
|
|
6050
|
+
ref: (element) => {
|
|
6051
|
+
const button = element?.$el ?? element;
|
|
6052
|
+
controls[resourceIndex] ||= [];
|
|
6053
|
+
controls[resourceIndex][dayIndex] = button instanceof HTMLButtonElement ? button : void 0;
|
|
6054
|
+
},
|
|
6055
|
+
class: ResourcesMonthView_module_default.resourcesMonthViewCell,
|
|
6056
|
+
"data-weekend": weekend || void 0,
|
|
6057
|
+
"data-drop-target": dropTarget.value?.resourceId === resource.id && dropTarget.value.dayIndex === dayIndex || void 0,
|
|
6058
|
+
"data-drag-selected": slotSelect.isSlotSelected(dayIndex, groupId) || void 0,
|
|
6059
|
+
"data-static": props.mode === "static" || void 0,
|
|
6060
|
+
"data-drag-slot-index": props.withDragSlotSelect ? dayIndex : void 0,
|
|
6061
|
+
"data-drag-slot-group": props.withDragSlotSelect ? groupId : void 0,
|
|
6062
|
+
tabindex: props.mode === "static" ? -1 : resourceIndex === 0 && dayIndex === 0 ? 0 : -1,
|
|
6063
|
+
"aria-label": `${String(resource.label)} ${(0, dayjs.default)(day).format("MMMM D, YYYY")}`,
|
|
6064
|
+
onKeydown: (event) => handleResourcesGridKeyDown({
|
|
6065
|
+
controls,
|
|
6066
|
+
resourceIndex,
|
|
6067
|
+
slotIndex: dayIndex,
|
|
6068
|
+
event
|
|
6069
|
+
}),
|
|
6070
|
+
onPointerdown: props.mode === "static" ? void 0 : (event) => slotSelect.handleSlotPointerDown(event, dayIndex, groupId),
|
|
6071
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => props.onDayClick?.({
|
|
6072
|
+
date: day,
|
|
6073
|
+
nativeEvent,
|
|
6074
|
+
resourceId: resource.id
|
|
6075
|
+
})
|
|
6076
|
+
}, () => slots.dayCell?.({
|
|
6077
|
+
resource,
|
|
6078
|
+
date: day
|
|
6079
|
+
}));
|
|
6080
|
+
});
|
|
6081
|
+
return (0, vue.h)("div", {
|
|
6082
|
+
class: ResourcesMonthView_module_default.resourcesMonthViewRow,
|
|
6083
|
+
key: resource.id
|
|
6084
|
+
}, [
|
|
6085
|
+
groupCell,
|
|
6086
|
+
(0, vue.h)("div", {
|
|
6087
|
+
class: ResourcesMonthView_module_default.resourcesMonthViewResourceLabel,
|
|
6088
|
+
"data-has-groups": hasGroups || void 0
|
|
6089
|
+
}, slots.resourceLabel?.({ resource }) ?? props.renderResourceLabel?.(resource) ?? resource.label ?? void 0),
|
|
6090
|
+
(0, vue.h)("div", {
|
|
6091
|
+
class: ResourcesMonthView_module_default.resourcesMonthViewRowSlots,
|
|
6092
|
+
ref: (element) => {
|
|
6093
|
+
if (element instanceof HTMLElement) rowContainers.set(resourceIndex, element);
|
|
6094
|
+
},
|
|
6095
|
+
onDragover: props.mode !== "static" && (props.withEventsDragAndDrop || props.onExternalEventDrop) ? (event) => {
|
|
6096
|
+
event.preventDefault();
|
|
6097
|
+
const dayIndex = indexAtPoint(event, resourceIndex);
|
|
6098
|
+
if (dayIndex >= 0 && (dropTarget.value?.resourceId !== resource.id || dropTarget.value.dayIndex !== dayIndex)) dropTarget.value = {
|
|
6099
|
+
resourceId: resource.id,
|
|
6100
|
+
dayIndex
|
|
6101
|
+
};
|
|
6102
|
+
} : void 0,
|
|
6103
|
+
onDragleave: (event) => {
|
|
6104
|
+
const current = event.currentTarget;
|
|
6105
|
+
if (!(event.relatedTarget instanceof Node) || !(current instanceof HTMLElement) || !current.contains(event.relatedTarget)) dropTarget.value = null;
|
|
6106
|
+
},
|
|
6107
|
+
onDrop: props.mode !== "static" && (props.withEventsDragAndDrop || props.onExternalEventDrop) ? (event) => {
|
|
6108
|
+
const dayIndex = indexAtPoint(event, resourceIndex);
|
|
6109
|
+
if (dayIndex >= 0) emitDrop(event, resource.id, dayIndex);
|
|
6110
|
+
} : void 0
|
|
6111
|
+
}, [
|
|
6112
|
+
...eventNodes,
|
|
6113
|
+
...moreNodes,
|
|
6114
|
+
...cells
|
|
6115
|
+
])
|
|
6116
|
+
]);
|
|
6117
|
+
});
|
|
6118
|
+
const month = (0, dayjs.default)(props.date).startOf("month");
|
|
6119
|
+
const monthString = month.format("YYYY-MM-DD");
|
|
6120
|
+
const header = props.withHeader ? slots.header?.({ month: monthString }) ?? (0, vue.h)(ScheduleHeaderBase, {
|
|
6121
|
+
view: "month",
|
|
6122
|
+
navigationHandlers: {
|
|
6123
|
+
previous: () => month.subtract(1, "month").format("YYYY-MM-DD"),
|
|
6124
|
+
next: () => month.add(1, "month").format("YYYY-MM-DD"),
|
|
6125
|
+
today: () => (0, dayjs.default)().format("YYYY-MM-DD")
|
|
6126
|
+
},
|
|
6127
|
+
control: { monthYearSelect: {
|
|
6128
|
+
locale: props.locale,
|
|
6129
|
+
monthValue: month.month(),
|
|
6130
|
+
yearValue: month.year(),
|
|
6131
|
+
onMonthChange: (value) => props.onDateChange?.(month.month(value).format("YYYY-MM-DD")),
|
|
6132
|
+
onYearChange: (value) => props.onDateChange?.(month.year(value).format("YYYY-MM-DD")),
|
|
6133
|
+
...props.monthYearSelectProps
|
|
6134
|
+
} },
|
|
6135
|
+
labels: props.labels,
|
|
6136
|
+
onDateChange: props.onDateChange,
|
|
6137
|
+
onViewChange: props.onViewChange,
|
|
6138
|
+
previousControlProps: props.previousControlProps,
|
|
6139
|
+
nextControlProps: props.nextControlProps,
|
|
6140
|
+
todayControlProps: props.todayControlProps,
|
|
6141
|
+
viewSelectProps: {
|
|
6142
|
+
views: [
|
|
6143
|
+
"day",
|
|
6144
|
+
"week",
|
|
6145
|
+
"month"
|
|
6146
|
+
],
|
|
6147
|
+
...props.viewSelectProps
|
|
6148
|
+
}
|
|
6149
|
+
}) : null;
|
|
6150
|
+
const labels = days.value.map((day) => {
|
|
6151
|
+
const weekday = formatDate({
|
|
6152
|
+
date: day,
|
|
6153
|
+
locale: props.locale || "en",
|
|
6154
|
+
format: props.weekdayFormat
|
|
6155
|
+
});
|
|
6156
|
+
return slots.dayLabel?.({
|
|
6157
|
+
date: day,
|
|
6158
|
+
weekday,
|
|
6159
|
+
day: (0, dayjs.default)(day).date()
|
|
6160
|
+
}) ?? (0, vue.h)("div", {
|
|
6161
|
+
key: day,
|
|
6162
|
+
class: ResourcesMonthView_module_default.resourcesMonthViewDayLabel,
|
|
6163
|
+
"data-weekend": props.weekendDays.includes((0, dayjs.default)(day).day()) || void 0,
|
|
6164
|
+
"data-today": props.highlightToday && (0, dayjs.default)(day).isSame((0, dayjs.default)(), "day") || void 0
|
|
6165
|
+
}, [(0, vue.h)("span", { class: ResourcesMonthView_module_default.resourcesMonthViewDayLabelWeekday }, weekday), (0, vue.h)("span", { class: ResourcesMonthView_module_default.resourcesMonthViewDayLabelNumber }, (0, dayjs.default)(day).date())]);
|
|
6166
|
+
});
|
|
6167
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
6168
|
+
...attrs,
|
|
6169
|
+
ref: (element) => {
|
|
6170
|
+
const node = element?.$el ?? element;
|
|
6171
|
+
rootElement.value = node instanceof HTMLElement ? node : null;
|
|
6172
|
+
},
|
|
6173
|
+
class: [ResourcesMonthView_module_default.resourcesMonthView, attrs.class],
|
|
6174
|
+
style: [{
|
|
6175
|
+
"--resources-month-view-radius": resolveScheduleRadius(props.radius),
|
|
6176
|
+
"--resources-month-view-day-width": cssSize(props.dayWidth),
|
|
6177
|
+
"--resources-month-view-row-height": cssSize(props.rowHeight),
|
|
6178
|
+
"--resources-month-view-group-label-width": cssSize(props.groupLabelWidth)
|
|
6179
|
+
}, attrs.style],
|
|
6180
|
+
"data-event-interaction": dropTarget.value ? true : void 0
|
|
6181
|
+
}, () => [header, (0, vue.h)(_mantine_vue_core.Box, { class: ResourcesMonthView_module_default.resourcesMonthViewRoot }, () => (0, vue.h)(_mantine_vue_core.ScrollArea, {
|
|
6182
|
+
scrollbarSize: 4,
|
|
6183
|
+
scrollbars: "x",
|
|
6184
|
+
...props.scrollAreaProps,
|
|
6185
|
+
class: ResourcesMonthView_module_default.resourcesMonthViewScrollArea
|
|
6186
|
+
}, () => (0, vue.h)("div", { class: ResourcesMonthView_module_default.resourcesMonthViewInner }, [(0, vue.h)("div", { class: ResourcesMonthView_module_default.resourcesMonthViewDayLabelsRow }, [(0, vue.h)("div", {
|
|
6187
|
+
class: ResourcesMonthView_module_default.resourcesMonthViewCorner,
|
|
6188
|
+
style: hasGroups ? {
|
|
6189
|
+
flexBasis: "calc(var(--resources-month-view-resource-label-width) + var(--resources-month-view-group-label-width))",
|
|
6190
|
+
minWidth: "calc(var(--resources-month-view-resource-label-width) + var(--resources-month-view-group-label-width))"
|
|
6191
|
+
} : void 0
|
|
6192
|
+
}, slots.corner?.({ resources: ordered.value.orderedResources }) ?? getLabel("resources", props.labels)), ...labels]), ...rows])))]);
|
|
6193
|
+
};
|
|
6194
|
+
}
|
|
6195
|
+
});
|
|
6196
|
+
var ResourcesSchedule_module_default = { root: "_root_13xbl_1" };
|
|
6197
|
+
//#endregion
|
|
6198
|
+
//#region src/components/ResourcesSchedule/ResourcesSchedule.ts
|
|
6199
|
+
var ResourcesSchedule = (0, vue.defineComponent)({
|
|
6200
|
+
name: "ResourcesSchedule",
|
|
6201
|
+
inheritAttrs: false,
|
|
6202
|
+
slots: Object,
|
|
6203
|
+
props: {
|
|
6204
|
+
resources: {
|
|
6205
|
+
type: Array,
|
|
6206
|
+
required: true
|
|
6207
|
+
},
|
|
6208
|
+
date: [String, Date],
|
|
6209
|
+
defaultDate: [String, Date],
|
|
6210
|
+
onDateChange: Function,
|
|
6211
|
+
view: String,
|
|
6212
|
+
defaultView: {
|
|
6213
|
+
type: String,
|
|
6214
|
+
default: "day"
|
|
6215
|
+
},
|
|
6216
|
+
onViewChange: Function,
|
|
6217
|
+
events: Array,
|
|
6218
|
+
locale: String,
|
|
6219
|
+
radius: [String, Number],
|
|
6220
|
+
labels: Object,
|
|
6221
|
+
renderEventBody: Function,
|
|
6222
|
+
renderResourceLabel: Function,
|
|
6223
|
+
withEventsDragAndDrop: Boolean,
|
|
6224
|
+
onEventDrop: Function,
|
|
6225
|
+
canDragEvent: Function,
|
|
6226
|
+
onEventDragStart: Function,
|
|
6227
|
+
onEventDragEnd: Function,
|
|
6228
|
+
onTimeSlotClick: Function,
|
|
6229
|
+
onDayClick: Function,
|
|
6230
|
+
onEventClick: Function,
|
|
6231
|
+
withDragSlotSelect: Boolean,
|
|
6232
|
+
onSlotDragEnd: Function,
|
|
6233
|
+
mode: {
|
|
6234
|
+
type: String,
|
|
6235
|
+
default: "default"
|
|
6236
|
+
},
|
|
6237
|
+
onExternalEventDrop: Function,
|
|
6238
|
+
withEventResize: Boolean,
|
|
6239
|
+
onEventResize: Function,
|
|
6240
|
+
canResizeEvent: Function,
|
|
6241
|
+
recurrenceExpansionLimit: {
|
|
6242
|
+
type: Number,
|
|
6243
|
+
default: 2e3
|
|
6244
|
+
},
|
|
6245
|
+
dayViewProps: Object,
|
|
6246
|
+
weekViewProps: Object,
|
|
6247
|
+
monthViewProps: Object
|
|
6248
|
+
},
|
|
6249
|
+
setup(props, { attrs, slots }) {
|
|
6250
|
+
const currentDate = (0, vue.ref)(toDateString(props.date ?? props.defaultDate ?? (0, dayjs.default)()));
|
|
6251
|
+
const currentView = (0, vue.ref)(props.view ?? props.defaultView);
|
|
6252
|
+
(0, vue.watch)(() => props.date, (value) => {
|
|
6253
|
+
if (value !== void 0) currentDate.value = toDateString(value);
|
|
6254
|
+
});
|
|
6255
|
+
(0, vue.watch)(() => props.view, (value) => {
|
|
6256
|
+
if (value !== void 0) currentView.value = value;
|
|
6257
|
+
});
|
|
6258
|
+
const changeDate = (date) => {
|
|
6259
|
+
if (props.date === void 0) currentDate.value = date;
|
|
6260
|
+
props.onDateChange?.(date);
|
|
6261
|
+
};
|
|
6262
|
+
const changeView = (view) => {
|
|
6263
|
+
if (view !== "day" && view !== "week" && view !== "month") return;
|
|
6264
|
+
if (props.view === void 0) currentView.value = view;
|
|
6265
|
+
props.onViewChange?.(view);
|
|
6266
|
+
};
|
|
6267
|
+
return () => {
|
|
6268
|
+
const isStatic = props.mode === "static";
|
|
6269
|
+
const shared = {
|
|
6270
|
+
resources: props.resources,
|
|
6271
|
+
date: currentDate.value,
|
|
6272
|
+
onDateChange: changeDate,
|
|
6273
|
+
onViewChange: changeView,
|
|
6274
|
+
events: props.events,
|
|
6275
|
+
locale: props.locale,
|
|
6276
|
+
radius: props.radius,
|
|
6277
|
+
labels: props.labels,
|
|
6278
|
+
renderEventBody: props.renderEventBody,
|
|
6279
|
+
renderResourceLabel: props.renderResourceLabel,
|
|
6280
|
+
withEventsDragAndDrop: isStatic ? false : props.withEventsDragAndDrop,
|
|
6281
|
+
onEventDrop: props.onEventDrop,
|
|
6282
|
+
canDragEvent: props.canDragEvent,
|
|
6283
|
+
onEventDragStart: props.onEventDragStart,
|
|
6284
|
+
onEventDragEnd: props.onEventDragEnd,
|
|
6285
|
+
onEventClick: props.onEventClick,
|
|
6286
|
+
withDragSlotSelect: props.withDragSlotSelect,
|
|
6287
|
+
onSlotDragEnd: props.onSlotDragEnd,
|
|
6288
|
+
onExternalEventDrop: props.onExternalEventDrop,
|
|
6289
|
+
recurrenceExpansionLimit: props.recurrenceExpansionLimit,
|
|
6290
|
+
mode: props.mode
|
|
6291
|
+
};
|
|
6292
|
+
const forwarded = {};
|
|
6293
|
+
for (const key of Object.keys(slots)) {
|
|
6294
|
+
const slot = slots[key];
|
|
6295
|
+
if (typeof slot === "function") forwarded[key] = slot;
|
|
6296
|
+
}
|
|
6297
|
+
const forwardedSlots = Object.keys(forwarded).length ? forwarded : void 0;
|
|
6298
|
+
const content = (() => {
|
|
6299
|
+
switch (currentView.value) {
|
|
6300
|
+
case "day": return (0, vue.h)(ResourcesDayView, {
|
|
6301
|
+
...shared,
|
|
6302
|
+
onTimeSlotClick: props.onTimeSlotClick,
|
|
6303
|
+
withEventResize: isStatic ? false : props.withEventResize,
|
|
6304
|
+
onEventResize: props.onEventResize,
|
|
6305
|
+
canResizeEvent: props.canResizeEvent,
|
|
6306
|
+
...props.dayViewProps
|
|
6307
|
+
}, forwardedSlots);
|
|
6308
|
+
case "week": return (0, vue.h)(ResourcesWeekView, {
|
|
6309
|
+
...shared,
|
|
6310
|
+
onTimeSlotClick: props.onTimeSlotClick,
|
|
6311
|
+
withEventResize: isStatic ? false : props.withEventResize,
|
|
6312
|
+
onEventResize: props.onEventResize,
|
|
6313
|
+
canResizeEvent: props.canResizeEvent,
|
|
6314
|
+
...props.weekViewProps
|
|
6315
|
+
}, forwardedSlots);
|
|
6316
|
+
case "month": return (0, vue.h)(ResourcesMonthView, {
|
|
6317
|
+
...shared,
|
|
6318
|
+
onDayClick: props.onDayClick,
|
|
6319
|
+
...props.monthViewProps
|
|
6320
|
+
}, forwardedSlots);
|
|
6321
|
+
default: return null;
|
|
6322
|
+
}
|
|
6323
|
+
})();
|
|
6324
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
6325
|
+
...attrs,
|
|
6326
|
+
class: [ResourcesSchedule_module_default.root, attrs.class],
|
|
6327
|
+
style: attrs.style
|
|
6328
|
+
}, () => [content]);
|
|
6329
|
+
};
|
|
6330
|
+
}
|
|
6331
|
+
});
|
|
6332
|
+
//#endregion
|
|
4116
6333
|
//#region src/components/DragContext/DragContext.ts
|
|
4117
6334
|
var DragContext = Symbol("mantine-schedule-drag-context");
|
|
4118
6335
|
function provideDragContext(value) {
|
|
@@ -4136,6 +6353,10 @@ exports.MobileMonthView = MobileMonthView;
|
|
|
4136
6353
|
exports.MonthView = MonthView;
|
|
4137
6354
|
exports.MonthYearSelect = MonthYearSelect;
|
|
4138
6355
|
exports.MoreEvents = MoreEvents;
|
|
6356
|
+
exports.ResourcesDayView = ResourcesDayView;
|
|
6357
|
+
exports.ResourcesMonthView = ResourcesMonthView;
|
|
6358
|
+
exports.ResourcesSchedule = ResourcesSchedule;
|
|
6359
|
+
exports.ResourcesWeekView = ResourcesWeekView;
|
|
4139
6360
|
exports.Schedule = Schedule;
|
|
4140
6361
|
exports.ScheduleEvent = ScheduleEvent;
|
|
4141
6362
|
exports.ScheduleHeader = ScheduleHeader;
|
|
@@ -4159,6 +6380,7 @@ exports.getDayPositionedEvents = getDayPositionedEvents;
|
|
|
4159
6380
|
exports.getDayTimeIntervals = getDayTimeIntervals;
|
|
4160
6381
|
exports.getDayViewEvents = getDayViewEvents;
|
|
4161
6382
|
exports.getEndOfWeek = getEndOfWeek;
|
|
6383
|
+
exports.getGroupToResourceIdMap = getGroupToResourceIdMap;
|
|
4162
6384
|
exports.getLabel = getLabel;
|
|
4163
6385
|
exports.getMonthDays = getMonthDays;
|
|
4164
6386
|
exports.getMonthPositionedEvents = getMonthPositionedEvents;
|
|
@@ -4166,7 +6388,11 @@ exports.getMonthRange = getMonthRange;
|
|
|
4166
6388
|
exports.getMonthViewEvents = getMonthViewEvents;
|
|
4167
6389
|
exports.getMonthsByQuarter = getMonthsByQuarter;
|
|
4168
6390
|
exports.getMonthsList = getMonthsList;
|
|
6391
|
+
exports.getOrderedResources = getOrderedResources;
|
|
6392
|
+
exports.getOverlapClusters = getOverlapClusters;
|
|
4169
6393
|
exports.getRenderableMonthEventSegments = getRenderableMonthEventSegments;
|
|
6394
|
+
exports.getResourcesDayViewEvents = getResourcesDayViewEvents;
|
|
6395
|
+
exports.getResourcesWeekViewEvents = getResourcesWeekViewEvents;
|
|
4170
6396
|
exports.getStartOfWeek = getStartOfWeek;
|
|
4171
6397
|
exports.getVisibleEvents = getVisibleEvents;
|
|
4172
6398
|
exports.getWeekDays = getWeekDays;
|
|
@@ -4176,6 +6402,7 @@ exports.getWeekPositionedEvents = getWeekPositionedEvents;
|
|
|
4176
6402
|
exports.getWeekViewEvents = getWeekViewEvents;
|
|
4177
6403
|
exports.getWeekdaysNames = getWeekdaysNames;
|
|
4178
6404
|
exports.getYearsList = getYearsList;
|
|
6405
|
+
exports.handleResourcesGridKeyDown = handleResourcesGridKeyDown;
|
|
4179
6406
|
exports.isAfterMinDate = isAfterMinDate;
|
|
4180
6407
|
exports.isAllDayEvent = isAllDayEvent;
|
|
4181
6408
|
exports.isBeforeMaxDate = isBeforeMaxDate;
|