@primeui/scheduler-core 0.0.1-alpha.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/LICENSE +23 -0
- package/README.md +1 -0
- package/dist/calendar/index.d.mts +57 -0
- package/dist/calendar/index.mjs +1 -0
- package/dist/chunk-2B3YLWHA.mjs +196 -0
- package/dist/chunk-2THQAZ26.mjs +1669 -0
- package/dist/chunk-5KORIWDT.mjs +41 -0
- package/dist/chunk-5N4ZOBJV.mjs +866 -0
- package/dist/chunk-6OZAPQZ5.mjs +229 -0
- package/dist/chunk-6PK5WSKT.mjs +369 -0
- package/dist/chunk-6VYWVIGM.mjs +1170 -0
- package/dist/chunk-AAVM7UCG.mjs +100 -0
- package/dist/chunk-C7ADJGNV.mjs +157 -0
- package/dist/chunk-DYW6WUHE.mjs +277 -0
- package/dist/chunk-F5W5HD7S.mjs +285 -0
- package/dist/chunk-FIBAZFC4.mjs +871 -0
- package/dist/chunk-HPC5B3AR.mjs +558 -0
- package/dist/chunk-KQGRXTP5.mjs +650 -0
- package/dist/chunk-NMX4BW42.mjs +672 -0
- package/dist/chunk-NX46LPLF.mjs +440 -0
- package/dist/chunk-NZGJN7HG.mjs +314 -0
- package/dist/chunk-QDMZBJDV.mjs +251 -0
- package/dist/chunk-QR2SVYAD.mjs +1144 -0
- package/dist/chunk-SYJ5O4KH.mjs +136 -0
- package/dist/chunk-TNKJPFGI.mjs +569 -0
- package/dist/chunk-UMAMDBU4.mjs +1 -0
- package/dist/chunk-W2SJW3QQ.mjs +3925 -0
- package/dist/chunk-WFUJWDST.mjs +352 -0
- package/dist/chunk-XUBQ2IQS.mjs +1 -0
- package/dist/chunk-ZUKUKGNK.mjs +613 -0
- package/dist/controllers/index.d.mts +384 -0
- package/dist/controllers/index.mjs +13 -0
- package/dist/date-D_CjQPmM.d.mts +74 -0
- package/dist/display-format-CLVvRt4I.d.mts +57 -0
- package/dist/event/index.d.mts +267 -0
- package/dist/event/index.mjs +8 -0
- package/dist/event-surface-_R_LHD95.d.mts +21 -0
- package/dist/event.positioning-BdzAVPk7.d.mts +51 -0
- package/dist/event.utils-QSNdd-3W.d.mts +35 -0
- package/dist/index.d.mts +1128 -0
- package/dist/index.mjs +1022 -0
- package/dist/interaction/index.d.mts +442 -0
- package/dist/interaction/index.mjs +9 -0
- package/dist/month/index.d.mts +104 -0
- package/dist/month/index.mjs +6 -0
- package/dist/overlay-BYM9B6nC.d.mts +64 -0
- package/dist/resource/index.d.mts +172 -0
- package/dist/resource/index.mjs +1 -0
- package/dist/selection-CO_98HdS.d.mts +56 -0
- package/dist/time-grid/index.d.mts +92 -0
- package/dist/time-grid/index.mjs +13 -0
- package/dist/timeline/index.d.mts +165 -0
- package/dist/timeline/index.mjs +6 -0
- package/dist/touch-BhsMWsjf.d.mts +69 -0
- package/dist/utils/index.d.mts +494 -0
- package/dist/utils/index.mjs +17 -0
- package/dist/views/index.d.mts +51 -0
- package/dist/views/index.mjs +8 -0
- package/dist/views/timeline/index.d.mts +37 -0
- package/dist/views/timeline/index.mjs +4 -0
- package/dist/year/index.d.mts +70 -0
- package/dist/year/index.mjs +6 -0
- package/package.json +58 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// src/utils/resource-runtime.ts
|
|
2
|
+
function toCssLength(value, fallback) {
|
|
3
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
4
|
+
return `${value}px`;
|
|
5
|
+
}
|
|
6
|
+
if (typeof value === "string") {
|
|
7
|
+
const trimmed = value.trim();
|
|
8
|
+
if (trimmed.length > 0) {
|
|
9
|
+
if (/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
10
|
+
return `${trimmed}px`;
|
|
11
|
+
}
|
|
12
|
+
return trimmed;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
function toNumber(value, fallback) {
|
|
18
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === "string") {
|
|
22
|
+
const parsed = Number.parseFloat(value);
|
|
23
|
+
if (Number.isFinite(parsed)) {
|
|
24
|
+
return parsed;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return fallback;
|
|
28
|
+
}
|
|
29
|
+
function hasGroupingFieldValue(resourceList, fieldName) {
|
|
30
|
+
return resourceList.some((resource) => {
|
|
31
|
+
const metadataValue = resource.metadata?.[fieldName];
|
|
32
|
+
const directValue = resource[fieldName];
|
|
33
|
+
return metadataValue !== void 0 || directValue !== void 0;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function resolveAutoResourceGroupingField(resourceList, explicitField) {
|
|
37
|
+
const explicit = explicitField?.trim();
|
|
38
|
+
if (explicit) {
|
|
39
|
+
return explicit;
|
|
40
|
+
}
|
|
41
|
+
if (hasGroupingFieldValue(resourceList, "groupID")) {
|
|
42
|
+
return "groupID";
|
|
43
|
+
}
|
|
44
|
+
if (hasGroupingFieldValue(resourceList, "groupId")) {
|
|
45
|
+
return "groupId";
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
function getEventResourceIds(event) {
|
|
50
|
+
if (event.resourceIds && event.resourceIds.length > 0) {
|
|
51
|
+
return event.resourceIds;
|
|
52
|
+
}
|
|
53
|
+
if (event.resourceId !== void 0) {
|
|
54
|
+
return [event.resourceId];
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
function getPrimaryResourceId(event) {
|
|
59
|
+
if (event.resourceId !== void 0) {
|
|
60
|
+
return event.resourceId;
|
|
61
|
+
}
|
|
62
|
+
return event.resourceIds && event.resourceIds.length > 0 ? event.resourceIds[0] : void 0;
|
|
63
|
+
}
|
|
64
|
+
function dedupeIds(resourceIds) {
|
|
65
|
+
const seen = /* @__PURE__ */ new Set();
|
|
66
|
+
const deduped = [];
|
|
67
|
+
for (const resourceId of resourceIds) {
|
|
68
|
+
const key = String(resourceId);
|
|
69
|
+
if (seen.has(key)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
seen.add(key);
|
|
73
|
+
deduped.push(resourceId);
|
|
74
|
+
}
|
|
75
|
+
return deduped;
|
|
76
|
+
}
|
|
77
|
+
function applyDefaultResourceDrop(payload) {
|
|
78
|
+
const targetResourceId = payload.newResource?.id ?? payload.event.resourceId;
|
|
79
|
+
const oldPrimaryResourceId = getPrimaryResourceId(payload.oldEvent);
|
|
80
|
+
const oldResourceIds = dedupeIds(getEventResourceIds(payload.oldEvent));
|
|
81
|
+
if (targetResourceId === void 0) {
|
|
82
|
+
return payload.event;
|
|
83
|
+
}
|
|
84
|
+
let newResourceIds;
|
|
85
|
+
if (oldResourceIds.length > 0) {
|
|
86
|
+
const replaced = oldResourceIds.map((resourceId) => oldPrimaryResourceId !== void 0 && resourceId === oldPrimaryResourceId ? targetResourceId : resourceId);
|
|
87
|
+
if (!replaced.some((resourceId) => resourceId === targetResourceId)) {
|
|
88
|
+
replaced.unshift(targetResourceId);
|
|
89
|
+
}
|
|
90
|
+
newResourceIds = dedupeIds(replaced);
|
|
91
|
+
} else {
|
|
92
|
+
newResourceIds = [targetResourceId];
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
...payload.event,
|
|
96
|
+
resourceId: targetResourceId,
|
|
97
|
+
resourceIds: newResourceIds.length > 0 ? newResourceIds : void 0
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function resolveOverlapPolicy(policy, rowAutoHeight) {
|
|
101
|
+
if (policy === "auto") {
|
|
102
|
+
return rowAutoHeight ? "allow" : "prevent";
|
|
103
|
+
}
|
|
104
|
+
return policy;
|
|
105
|
+
}
|
|
106
|
+
function eventsTimeOverlap(startA, endA, startB, endB) {
|
|
107
|
+
return startA < endB && endA > startB;
|
|
108
|
+
}
|
|
109
|
+
function eventBelongsToResource(event, resourceId) {
|
|
110
|
+
if (event.resourceIds && event.resourceIds.length > 0) {
|
|
111
|
+
return event.resourceIds.some((id) => String(id) === String(resourceId));
|
|
112
|
+
}
|
|
113
|
+
return event.resourceId !== void 0 && String(event.resourceId) === String(resourceId);
|
|
114
|
+
}
|
|
115
|
+
function getEventDates(event) {
|
|
116
|
+
const start = typeof event.start === "string" ? new Date(event.start) : event.start;
|
|
117
|
+
const end = event.end ? typeof event.end === "string" ? new Date(event.end) : event.end : new Date(start.getTime() + 30 * 60 * 1e3);
|
|
118
|
+
return { start, end };
|
|
119
|
+
}
|
|
120
|
+
function findOverlappingEventsInResource(candidate, events, resourceId, excludeEventIds) {
|
|
121
|
+
const candidateDates = getEventDates(candidate);
|
|
122
|
+
return events.filter((other) => {
|
|
123
|
+
if (other.id === candidate.id) return false;
|
|
124
|
+
if (excludeEventIds && excludeEventIds.some((eid) => String(eid) === String(other.id))) return false;
|
|
125
|
+
if (!eventBelongsToResource(other, resourceId)) return false;
|
|
126
|
+
const otherDates = getEventDates(other);
|
|
127
|
+
return eventsTimeOverlap(candidateDates.start, candidateDates.end, otherDates.start, otherDates.end);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function hasOverlapInAnyAssignedResource(candidate, events, excludeEventIds) {
|
|
131
|
+
const assignedIds = getEventResourceIds(candidate);
|
|
132
|
+
if (assignedIds.length === 0) return false;
|
|
133
|
+
return assignedIds.some((resourceId) => findOverlappingEventsInResource(candidate, events, resourceId, excludeEventIds).length > 0);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { applyDefaultResourceDrop, eventsTimeOverlap, findOverlappingEventsInResource, getEventResourceIds, getPrimaryResourceId, hasGroupingFieldValue, hasOverlapInAnyAssignedResource, resolveAutoResourceGroupingField, resolveOverlapPolicy, toCssLength, toNumber };
|