@pisell/materials 1.8.34 → 1.8.36
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +2 -2
- package/build/lowcode/preview.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +35 -35
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +35 -35
- package/es/components/pisellFloorMapLayout/PisellFloorMapLayout.js +25 -10
- package/es/components/pisellFloorMapLayout/appearance/floorMapAppearance.d.ts +4 -0
- package/es/components/pisellFloorMapLayout/appearance/floorMapAppearance.js +22 -0
- package/es/components/pisellFloorMapLayout/components/EditableItemLayer.js +3 -2
- package/es/components/pisellFloorMapLayout/components/ItemLayer.js +7 -4
- package/es/components/pisellFloorMapLayout/components/ItemLayer.less +10 -0
- package/es/components/pisellFloorMapLayout/components/ViewControls.js +6 -5
- package/es/components/pisellFloorMapLayout/components/ViewControls.less +29 -2
- package/es/components/pisellFloorMapLayout/components/ViewControlsWithZoom.js +1 -0
- package/es/components/pisellFloorMapLayout/context/mergeFloorMapLayoutContext.js +3 -1
- package/es/components/pisellFloorMapLayout/types.d.ts +21 -2
- package/es/components/pisellRecordBoard/index.d.ts +1 -1
- package/es/components/pisellRecordBoard/shellFrame/Calendar/BookingCalendar.js +280 -230
- package/es/components/pisellRecordBoard/shellFrame/Calendar/const/bookingCalendarConstants.js +18 -1
- package/es/components/pisellRecordBoard/shellFrame/Calendar/hooks/useBookingCalendarDayOverlayLayout.js +74 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/modal/BookingCalendarBlockPanel.js +61 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/modal/BookingCalendarOverflowListLayer.js +26 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/utils/bookingCalendarDateUtils.js +11 -1
- package/es/components/pisellRecordBoard/shellFrame/Calendar/utils/bookingCalendarSelectionUtils.js +17 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarDaySelectionBar.js +12 -8
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarDayView.js +3 -12
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarResourceView.js +612 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/day/useBookingCalendarDayHourRemaining.js +33 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/day/useBookingCalendarDaySelection.js +37 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/resource/useBookingCalendarResourceCellToggle.js +18 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/resource/useBookingCalendarResourceDayHeaderRemaining.js +33 -0
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/useBookingCalendarGoToDayFromCell.js +29 -0
- package/es/components/pisellRecordBoard/types.d.ts +38 -6
- package/es/components/pisellReservationSchedule/PisellReservationSchedule.js +19 -3
- package/es/components/pisellReservationSchedule/PisellReservationSchedule.less +23 -0
- package/es/index.d.ts +2 -2
- package/es/locales/en-US.js +6 -5
- package/es/locales/ja.js +1 -0
- package/es/locales/pt.js +1 -0
- package/es/locales/zh-CN.js +1 -0
- package/es/locales/zh-TW.js +1 -0
- package/es/pisell-materials.tw.css +2413 -2
- package/lib/components/pisellFloorMapLayout/PisellFloorMapLayout.js +25 -10
- package/lib/components/pisellFloorMapLayout/appearance/floorMapAppearance.d.ts +4 -0
- package/lib/components/pisellFloorMapLayout/appearance/floorMapAppearance.js +22 -0
- package/lib/components/pisellFloorMapLayout/components/EditableItemLayer.js +3 -2
- package/lib/components/pisellFloorMapLayout/components/ItemLayer.js +7 -4
- package/lib/components/pisellFloorMapLayout/components/ItemLayer.less +10 -0
- package/lib/components/pisellFloorMapLayout/components/ViewControls.js +6 -5
- package/lib/components/pisellFloorMapLayout/components/ViewControls.less +29 -2
- package/lib/components/pisellFloorMapLayout/components/ViewControlsWithZoom.js +1 -0
- package/lib/components/pisellFloorMapLayout/context/mergeFloorMapLayoutContext.js +3 -1
- package/lib/components/pisellFloorMapLayout/types.d.ts +21 -2
- package/lib/components/pisellRecordBoard/index.d.ts +1 -1
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/BookingCalendar.js +277 -227
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/const/bookingCalendarConstants.js +18 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/hooks/useBookingCalendarDayOverlayLayout.js +75 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/modal/BookingCalendarBlockPanel.js +63 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/modal/BookingCalendarOverflowListLayer.js +28 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/utils/bookingCalendarDateUtils.js +11 -1
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/utils/bookingCalendarSelectionUtils.js +17 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarDaySelectionBar.js +12 -8
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarDayView.js +3 -12
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarResourceView.js +614 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/day/useBookingCalendarDayHourRemaining.js +34 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/day/useBookingCalendarDaySelection.js +38 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/resource/useBookingCalendarResourceCellToggle.js +19 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/resource/useBookingCalendarResourceDayHeaderRemaining.js +34 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/useBookingCalendarGoToDayFromCell.js +30 -0
- package/lib/components/pisellRecordBoard/types.d.ts +38 -6
- package/lib/components/pisellReservationSchedule/PisellReservationSchedule.js +19 -3
- package/lib/components/pisellReservationSchedule/PisellReservationSchedule.less +23 -0
- package/lib/index.d.ts +2 -2
- package/lib/locales/en-US.js +6 -5
- package/lib/locales/ja.js +1 -0
- package/lib/locales/pt.js +1 -0
- package/lib/locales/zh-CN.js +1 -0
- package/lib/locales/zh-TW.js +1 -0
- package/lib/pisell-materials.tw.css +2413 -2
- package/lowcode/pisell-record-board-calendar-view/meta.ts +8 -0
- package/package.json +1 -1
package/es/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarResourceView.js
ADDED
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
import { CALENDAR_EMPTY_DASHED_SLOT_CLASSNAME, estimateResourceViewCourtCellHeightPx } from "../const/bookingCalendarConstants.js";
|
|
2
|
+
import { tCal } from "../calendarI18n.js";
|
|
3
|
+
import { courtDaySummary, fmtDate, formatHourLabel, getViewNowReference } from "../utils/bookingCalendarDateUtils.js";
|
|
4
|
+
import { getGridBookingRowStateClasses } from "../utils/BookingCalendarStyle.js";
|
|
5
|
+
import { getRemainingToneClass } from "../bookingCalendarViewShared.js";
|
|
6
|
+
import { BookingCalendarGroupRowHeader } from "./BookingCalendarGroupRowHeader.js";
|
|
7
|
+
import React, { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
//#region src/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarResourceView.tsx
|
|
9
|
+
/**
|
|
10
|
+
* 资源视图(按月):与日视图同款骨架——冻结左列 + 横向滚动 + sticky 顶部表头。
|
|
11
|
+
*
|
|
12
|
+
* 与日视图的唯一差异:
|
|
13
|
+
* - 日视图:横轴 = 营业小时槽,cell = 一个小时;booking 通过 overlay 跨 cell 横铺。
|
|
14
|
+
* - 资源视图:横轴 = 当月每一天,cell = 一个 (court, date);booking 通过 overlay 在 cell 内
|
|
15
|
+
* 垂直 stack 渲染(最多 3 条 + `+N` 溢出 tile)。
|
|
16
|
+
*
|
|
17
|
+
* 性能策略(与日视图对齐):
|
|
18
|
+
* - cell 是「轻 placeholder」:只渲染背景色 + selected ring + 空 dashed slot/Selected 文本。
|
|
19
|
+
* - 所有 booking 卡片 / `+N` tile 由 `BookingOverlay` 单独 absolute 渲染,独立于 grid。
|
|
20
|
+
* - 这样 grid 内 DOM 极轻,浏览器每帧 paint/layout 与日视图同档(cell 内含复杂 booking
|
|
21
|
+
* 卡片时实测每列 ~7ms paint 成本,整月 30 列 → ~150ms;overlay 化后接近零)。
|
|
22
|
+
*
|
|
23
|
+
* 选中:与日视图 `toggleSlot(courtId, hour)` 等价的「`toggleResourceCell(courtId, dateKey)`」。
|
|
24
|
+
* 选中态合并到 cell 自身 className(与日视图一致),不插入额外 grid item,避免 CSS Grid 整表 reflow。
|
|
25
|
+
*/
|
|
26
|
+
const PREVIEW_CAP = 3;
|
|
27
|
+
const BookingCalendarResourceView = React.memo(BookingCalendarResourceViewInner);
|
|
28
|
+
function BookingCalendarResourceViewInner({ calendarProps, isLight, anchorDate, monthDays, slotColWidth, bookings, visibleCourts, visibleCourtRows, hourSlots, slotStepHours, handleGridDropMove, openBookingDetail, setDraggingItem, setCollapsedGroups, overflowPopover, setOverflowPopover, setOverflowListModal, overflowPanelRef, resourceMonthScrollToTodayToken, resourceDayHeaderRemaining, toggleResourceCell, selectedResourceCells }) {
|
|
29
|
+
const props = calendarProps;
|
|
30
|
+
const todayKey = fmtDate(/* @__PURE__ */ new Date());
|
|
31
|
+
const monthKeyPrefix = `${anchorDate.getFullYear()}-${anchorDate.getMonth()}`;
|
|
32
|
+
const bookingsStable = useMemo(() => bookings, [useMemo(() => {
|
|
33
|
+
if (!Array.isArray(bookings) || bookings.length === 0) return "[]";
|
|
34
|
+
return bookings.map((b) => {
|
|
35
|
+
var _b$id, _b$courtId, _b$date, _b$kind, _b$startHour, _b$endHour;
|
|
36
|
+
return `${(_b$id = b === null || b === void 0 ? void 0 : b.id) !== null && _b$id !== void 0 ? _b$id : ""}|${(_b$courtId = b === null || b === void 0 ? void 0 : b.courtId) !== null && _b$courtId !== void 0 ? _b$courtId : ""}|${(_b$date = b === null || b === void 0 ? void 0 : b.date) !== null && _b$date !== void 0 ? _b$date : ""}|${(_b$kind = b === null || b === void 0 ? void 0 : b.kind) !== null && _b$kind !== void 0 ? _b$kind : ""}|${(_b$startHour = b === null || b === void 0 ? void 0 : b.startHour) !== null && _b$startHour !== void 0 ? _b$startHour : ""}|${(_b$endHour = b === null || b === void 0 ? void 0 : b.endHour) !== null && _b$endHour !== void 0 ? _b$endHour : ""}`;
|
|
37
|
+
}).join(";");
|
|
38
|
+
}, [bookings])]);
|
|
39
|
+
const scrollRef = useRef(null);
|
|
40
|
+
const dragRef = useRef({
|
|
41
|
+
dragging: false,
|
|
42
|
+
startX: 0,
|
|
43
|
+
startY: 0,
|
|
44
|
+
startLeft: 0,
|
|
45
|
+
startTop: 0,
|
|
46
|
+
moved: false
|
|
47
|
+
});
|
|
48
|
+
const [dragging, setDragging] = useState(false);
|
|
49
|
+
const [virt, setVirt] = useState({
|
|
50
|
+
i0: 0,
|
|
51
|
+
i1: 0,
|
|
52
|
+
r0: 0,
|
|
53
|
+
r1: 0,
|
|
54
|
+
ready: false
|
|
55
|
+
});
|
|
56
|
+
const rafRef = useRef(null);
|
|
57
|
+
/** 行前缀和 ref(updateVirt 内通过 ref 读取最新值,避免每次行高变化都重建 callback) */
|
|
58
|
+
const rowPrefixRef = useRef([0]);
|
|
59
|
+
const nCols = monthDays.length;
|
|
60
|
+
const updateVirt = useCallback(() => {
|
|
61
|
+
const root = scrollRef.current;
|
|
62
|
+
if (!root || nCols <= 0) return;
|
|
63
|
+
const sl = root.scrollLeft;
|
|
64
|
+
const st = root.scrollTop;
|
|
65
|
+
const vw = root.clientWidth;
|
|
66
|
+
const vh = root.clientHeight;
|
|
67
|
+
let i0 = Math.floor((sl - 132) / slotColWidth) - 5;
|
|
68
|
+
let i1 = Math.ceil((sl + vw - 132) / slotColWidth) - 1 + 5;
|
|
69
|
+
i0 = Math.max(0, i0);
|
|
70
|
+
i1 = Math.min(nCols - 1, i1);
|
|
71
|
+
if (i0 > i1) {
|
|
72
|
+
i0 = 0;
|
|
73
|
+
i1 = nCols - 1;
|
|
74
|
+
}
|
|
75
|
+
const pfx = rowPrefixRef.current;
|
|
76
|
+
const nr = Math.max(0, pfx.length - 1);
|
|
77
|
+
let r0 = 0;
|
|
78
|
+
let r1 = nr > 0 ? nr - 1 : 0;
|
|
79
|
+
if (nr > 0) {
|
|
80
|
+
const bodyTop = 56;
|
|
81
|
+
const vTop = st;
|
|
82
|
+
const vBot = st + vh;
|
|
83
|
+
const buf = 240;
|
|
84
|
+
for (let r = 0; r < nr; r += 1) {
|
|
85
|
+
var _pfx;
|
|
86
|
+
if (bodyTop + ((_pfx = pfx[r + 1]) !== null && _pfx !== void 0 ? _pfx : 0) > vTop - buf) {
|
|
87
|
+
r0 = r;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (let r = nr - 1; r >= 0; r -= 1) {
|
|
92
|
+
var _pfx$r;
|
|
93
|
+
if (bodyTop + ((_pfx$r = pfx[r]) !== null && _pfx$r !== void 0 ? _pfx$r : 0) < vBot + buf) {
|
|
94
|
+
r1 = r;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (r0 > r1) {
|
|
99
|
+
r0 = 0;
|
|
100
|
+
r1 = nr - 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
setVirt((prev) => prev.ready && prev.i0 === i0 && prev.i1 === i1 && prev.r0 === r0 && prev.r1 === r1 ? prev : {
|
|
104
|
+
i0,
|
|
105
|
+
i1,
|
|
106
|
+
r0,
|
|
107
|
+
r1,
|
|
108
|
+
ready: true
|
|
109
|
+
});
|
|
110
|
+
}, [nCols, slotColWidth]);
|
|
111
|
+
const scheduleVirt = useCallback(() => {
|
|
112
|
+
if (rafRef.current != null) return;
|
|
113
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
114
|
+
rafRef.current = null;
|
|
115
|
+
updateVirt();
|
|
116
|
+
});
|
|
117
|
+
}, [updateVirt]);
|
|
118
|
+
useLayoutEffect(() => {
|
|
119
|
+
const root = scrollRef.current;
|
|
120
|
+
if (!root) return void 0;
|
|
121
|
+
scheduleVirt();
|
|
122
|
+
const onScroll = () => scheduleVirt();
|
|
123
|
+
root.addEventListener("scroll", onScroll, { passive: true });
|
|
124
|
+
let ro = null;
|
|
125
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
126
|
+
ro = new ResizeObserver(() => scheduleVirt());
|
|
127
|
+
try {
|
|
128
|
+
ro.observe(root);
|
|
129
|
+
} catch (_unused) {}
|
|
130
|
+
}
|
|
131
|
+
return () => {
|
|
132
|
+
root.removeEventListener("scroll", onScroll);
|
|
133
|
+
ro === null || ro === void 0 || ro.disconnect();
|
|
134
|
+
if (rafRef.current != null) cancelAnimationFrame(rafRef.current);
|
|
135
|
+
rafRef.current = null;
|
|
136
|
+
};
|
|
137
|
+
}, [
|
|
138
|
+
monthKeyPrefix,
|
|
139
|
+
scheduleVirt,
|
|
140
|
+
nCols
|
|
141
|
+
]);
|
|
142
|
+
/** 切入资源视图时把今天列居中(仅当月含今天) */
|
|
143
|
+
useLayoutEffect(() => {
|
|
144
|
+
if (!resourceMonthScrollToTodayToken) return;
|
|
145
|
+
const root = scrollRef.current;
|
|
146
|
+
if (!root || monthDays.length === 0) return;
|
|
147
|
+
const idx = monthDays.findIndex((d) => fmtDate(d) === getViewNowReference().dateKey);
|
|
148
|
+
if (idx < 0) return;
|
|
149
|
+
const targetLeft = 132 + idx * slotColWidth - root.clientWidth / 2 + slotColWidth / 2;
|
|
150
|
+
root.scrollLeft = Math.max(0, Math.min(targetLeft, root.scrollWidth - root.clientWidth));
|
|
151
|
+
}, [
|
|
152
|
+
resourceMonthScrollToTodayToken,
|
|
153
|
+
monthKeyPrefix,
|
|
154
|
+
monthDays,
|
|
155
|
+
slotColWidth
|
|
156
|
+
]);
|
|
157
|
+
const onMouseDown = useCallback((e) => {
|
|
158
|
+
if (e.button !== 0 || !scrollRef.current) return;
|
|
159
|
+
dragRef.current = {
|
|
160
|
+
dragging: true,
|
|
161
|
+
startX: e.clientX,
|
|
162
|
+
startY: e.clientY,
|
|
163
|
+
startLeft: scrollRef.current.scrollLeft,
|
|
164
|
+
startTop: scrollRef.current.scrollTop,
|
|
165
|
+
moved: false
|
|
166
|
+
};
|
|
167
|
+
setDragging(true);
|
|
168
|
+
}, []);
|
|
169
|
+
const onMouseMove = useCallback((e) => {
|
|
170
|
+
if (!dragRef.current.dragging || !scrollRef.current) return;
|
|
171
|
+
const dx = e.clientX - dragRef.current.startX;
|
|
172
|
+
const dy = e.clientY - dragRef.current.startY;
|
|
173
|
+
if (Math.abs(dx) > 3 || Math.abs(dy) > 3) dragRef.current.moved = true;
|
|
174
|
+
scrollRef.current.scrollLeft = dragRef.current.startLeft - dx;
|
|
175
|
+
scrollRef.current.scrollTop = dragRef.current.startTop - dy;
|
|
176
|
+
}, []);
|
|
177
|
+
const onMouseUp = useCallback(() => {
|
|
178
|
+
dragRef.current.dragging = false;
|
|
179
|
+
setDragging(false);
|
|
180
|
+
}, []);
|
|
181
|
+
const visibleColIndices = useMemo(() => {
|
|
182
|
+
if (!virt.ready) {
|
|
183
|
+
const out = [];
|
|
184
|
+
for (let i = 0; i < nCols; i += 1) out.push(i);
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
const out = [];
|
|
188
|
+
for (let i = virt.i0; i <= virt.i1; i += 1) out.push(i);
|
|
189
|
+
return out;
|
|
190
|
+
}, [virt, nCols]);
|
|
191
|
+
const summaryCache = useMemo(() => {
|
|
192
|
+
const m = /* @__PURE__ */ new Map();
|
|
193
|
+
const visibleCourtIds = [];
|
|
194
|
+
for (const r of visibleCourtRows) if ((r === null || r === void 0 ? void 0 : r.kind) === "court" && r.id) visibleCourtIds.push(String(r.id));
|
|
195
|
+
const visibleDateKeys = visibleColIndices.map((ci) => monthDays[ci]).filter(Boolean).map((d) => fmtDate(d));
|
|
196
|
+
for (const cid of visibleCourtIds) for (const dk of visibleDateKeys) m.set(`${cid}\t${dk}`, courtDaySummary(cid, dk, bookingsStable, hourSlots, slotStepHours));
|
|
197
|
+
return m;
|
|
198
|
+
}, [
|
|
199
|
+
visibleCourtRows,
|
|
200
|
+
visibleColIndices,
|
|
201
|
+
monthDays,
|
|
202
|
+
bookingsStable,
|
|
203
|
+
hourSlots,
|
|
204
|
+
slotStepHours
|
|
205
|
+
]);
|
|
206
|
+
const getSummary = useCallback((courtId, dateKey) => {
|
|
207
|
+
var _summaryCache$get;
|
|
208
|
+
return (_summaryCache$get = summaryCache.get(`${courtId}\t${dateKey}`)) !== null && _summaryCache$get !== void 0 ? _summaryCache$get : courtDaySummary(courtId, dateKey, bookingsStable, hourSlots, slotStepHours);
|
|
209
|
+
}, [
|
|
210
|
+
summaryCache,
|
|
211
|
+
bookingsStable,
|
|
212
|
+
hourSlots,
|
|
213
|
+
slotStepHours
|
|
214
|
+
]);
|
|
215
|
+
const rowHeights = useMemo(() => {
|
|
216
|
+
return visibleCourtRows.map((row) => {
|
|
217
|
+
if (row.kind === "group") return 38;
|
|
218
|
+
let maxH = 44;
|
|
219
|
+
for (let di = 0; di < monthDays.length; di += 1) {
|
|
220
|
+
const day = monthDays[di];
|
|
221
|
+
if (!day) continue;
|
|
222
|
+
const summary = getSummary(row.id, fmtDate(day));
|
|
223
|
+
maxH = Math.max(maxH, estimateResourceViewCourtCellHeightPx(summary));
|
|
224
|
+
}
|
|
225
|
+
return maxH;
|
|
226
|
+
});
|
|
227
|
+
}, [
|
|
228
|
+
visibleCourtRows,
|
|
229
|
+
monthDays,
|
|
230
|
+
getSummary
|
|
231
|
+
]);
|
|
232
|
+
const gridTemplateRows = useMemo(() => visibleCourtRows.map((row, i) => row.kind === "group" ? `38px` : `${rowHeights[i]}px`).join(" "), [visibleCourtRows, rowHeights]);
|
|
233
|
+
/** 行前缀和:rowPrefixTop[i] = 前 i 行总高度(i 从 0 到 N) */
|
|
234
|
+
const rowPrefixTop = useMemo(() => {
|
|
235
|
+
const arr = new Array(rowHeights.length + 1);
|
|
236
|
+
arr[0] = 0;
|
|
237
|
+
for (let i = 0; i < rowHeights.length; i += 1) {
|
|
238
|
+
var _rowHeights$i;
|
|
239
|
+
arr[i + 1] = arr[i] + ((_rowHeights$i = rowHeights[i]) !== null && _rowHeights$i !== void 0 ? _rowHeights$i : 0);
|
|
240
|
+
}
|
|
241
|
+
return arr;
|
|
242
|
+
}, [rowHeights]);
|
|
243
|
+
/** 同步到 ref,让 updateVirt 拿到最新前缀和;行高变化后立刻触发一次行窗口重算 */
|
|
244
|
+
useLayoutEffect(() => {
|
|
245
|
+
rowPrefixRef.current = rowPrefixTop;
|
|
246
|
+
scheduleVirt();
|
|
247
|
+
}, [rowPrefixTop, scheduleVirt]);
|
|
248
|
+
const contentHeight = 56 + rowPrefixTop[rowPrefixTop.length - 1];
|
|
249
|
+
/**
|
|
250
|
+
* 按 court 切分的「选中日期签名」:传给 ResourceCourtRow 触发 React.memo 浅比较。
|
|
251
|
+
* - 同一 court 的选中集没变 → sig 字符串相等 → memo 命中 → 整行跳过 reconcile。
|
|
252
|
+
* - 这样点击 / 取消 cell 时,只有「新选中 / 旧选中」对应的 1~2 行真正重渲染,其他全部 N 行被 memo 跳过。
|
|
253
|
+
*/
|
|
254
|
+
const selectionSigByCourtId = useMemo(() => {
|
|
255
|
+
const grp = /* @__PURE__ */ new Map();
|
|
256
|
+
for (const s of selectedResourceCells) {
|
|
257
|
+
const cid = String(s.courtId);
|
|
258
|
+
let arr = grp.get(cid);
|
|
259
|
+
if (!arr) {
|
|
260
|
+
arr = [];
|
|
261
|
+
grp.set(cid, arr);
|
|
262
|
+
}
|
|
263
|
+
arr.push(s.dateKey);
|
|
264
|
+
}
|
|
265
|
+
const m = /* @__PURE__ */ new Map();
|
|
266
|
+
grp.forEach((arr, cid) => {
|
|
267
|
+
arr.sort();
|
|
268
|
+
m.set(cid, arr.join("|"));
|
|
269
|
+
});
|
|
270
|
+
return m;
|
|
271
|
+
}, [selectedResourceCells]);
|
|
272
|
+
const monthLabel = `${anchorDate.getFullYear()} / ${anchorDate.getMonth() + 1}`;
|
|
273
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
274
|
+
key: `resource-${monthKeyPrefix}`,
|
|
275
|
+
className: "flex min-h-0 flex-1 flex-col"
|
|
276
|
+
}, /* @__PURE__ */ React.createElement("div", { className: "relative flex min-h-0 flex-1 flex-col" }, /* @__PURE__ */ React.createElement("div", {
|
|
277
|
+
ref: scrollRef,
|
|
278
|
+
onMouseDown,
|
|
279
|
+
onMouseMove,
|
|
280
|
+
onMouseUp,
|
|
281
|
+
onMouseLeave: onMouseUp,
|
|
282
|
+
style: { overscrollBehavior: "none" },
|
|
283
|
+
className: `pisell-scroll-hidden relative border min-h-0 max-h-none flex-1 overflow-auto touch-pan-x touch-pan-y select-none ${isLight ? "theme-panel theme-border" : "border-zinc-800 bg-[#121217]"} ${dragging ? "cursor-grabbing" : "cursor-grab"}`
|
|
284
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
285
|
+
className: "relative",
|
|
286
|
+
style: {
|
|
287
|
+
minWidth: `${132 + nCols * slotColWidth}px`,
|
|
288
|
+
minHeight: `${contentHeight}px`
|
|
289
|
+
}
|
|
290
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
291
|
+
className: "grid sticky top-0 z-50",
|
|
292
|
+
style: { gridTemplateColumns: `132px repeat(${nCols}, ${slotColWidth}px)` }
|
|
293
|
+
}, /* @__PURE__ */ React.createElement("div", { className: `sticky left-0 top-0 z-[60] flex h-full min-h-0 w-[132px] min-w-[132px] max-w-[132px] flex-col justify-center px-2.5 font-semibold border-b shadow-[8px_0_16px_rgba(0,0,0,0.08)] ${isLight ? "surface-brand-side text-slate-900" : "bg-[#241d40] border-zinc-800 text-zinc-100"}` }, /* @__PURE__ */ React.createElement("span", { className: "text-lg font-bold leading-tight" }, monthLabel)), visibleColIndices.map((ci) => {
|
|
294
|
+
const day = monthDays[ci];
|
|
295
|
+
if (!day) return null;
|
|
296
|
+
const key = fmtDate(day);
|
|
297
|
+
const isToday = key === todayKey;
|
|
298
|
+
const remaining = resourceDayHeaderRemaining[key];
|
|
299
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
300
|
+
key: `rh-${key}`,
|
|
301
|
+
className: `relative z-20 border-b border-l px-1 py-2 text-center shadow-[0_8px_16px_rgba(0,0,0,0.06)] ${isLight ? "theme-border theme-text" : "border-zinc-800"} ${isToday ? isLight ? "bg-gradient-to-b from-violet-50 to-white" : "bg-gradient-to-b from-violet-950 to-[#1a1a22]" : isLight ? "theme-panel-soft" : "bg-[#1a1a22]"}`,
|
|
302
|
+
style: { gridColumn: ci + 2 }
|
|
303
|
+
}, /* @__PURE__ */ React.createElement("div", { className: "flex justify-center" }, /* @__PURE__ */ React.createElement("span", {
|
|
304
|
+
className: "grid h-10 w-10 place-items-center text-3xl font-semibold leading-none",
|
|
305
|
+
"aria-label": isToday ? "Today" : void 0
|
|
306
|
+
}, day.getDate())), remaining && remaining.total > 0 && /* @__PURE__ */ React.createElement("div", { className: `mt-1 text-[11px] font-semibold leading-tight ${getRemainingToneClass(remaining.ratio, isLight)}` }, tCal("pisell2.recordBoard.calendar.day.freeRatio", {
|
|
307
|
+
remaining: remaining.remaining,
|
|
308
|
+
total: remaining.total
|
|
309
|
+
})));
|
|
310
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
311
|
+
className: "grid relative",
|
|
312
|
+
style: {
|
|
313
|
+
gridTemplateColumns: `132px repeat(${nCols}, ${slotColWidth}px)`,
|
|
314
|
+
gridTemplateRows
|
|
315
|
+
}
|
|
316
|
+
}, visibleCourtRows.map((row, rowIndex) => {
|
|
317
|
+
var _selectionSigByCourtI;
|
|
318
|
+
if (virt.ready && (rowIndex < virt.r0 || rowIndex > virt.r1)) return /* @__PURE__ */ React.createElement("div", {
|
|
319
|
+
key: `${row.id}-skip`,
|
|
320
|
+
className: `pointer-events-none border-b ${isLight ? "theme-border" : "border-zinc-800"}`,
|
|
321
|
+
style: {
|
|
322
|
+
gridColumn: "1 / -1",
|
|
323
|
+
gridRow: rowIndex + 1
|
|
324
|
+
},
|
|
325
|
+
"aria-hidden": true
|
|
326
|
+
});
|
|
327
|
+
return row.kind === "group" ? /* @__PURE__ */ React.createElement(React.Fragment, { key: row.id }, /* @__PURE__ */ React.createElement(BookingCalendarGroupRowHeader, {
|
|
328
|
+
isLight,
|
|
329
|
+
view: "resource",
|
|
330
|
+
row: {
|
|
331
|
+
id: row.id,
|
|
332
|
+
label: row.label,
|
|
333
|
+
count: row.count,
|
|
334
|
+
collapsed: row.collapsed
|
|
335
|
+
},
|
|
336
|
+
renderResourceCell: props.renderResourceCell,
|
|
337
|
+
setCollapsedGroups,
|
|
338
|
+
style: {
|
|
339
|
+
gridRow: rowIndex + 1,
|
|
340
|
+
gridColumn: 1
|
|
341
|
+
}
|
|
342
|
+
}), visibleColIndices.map((ci) => {
|
|
343
|
+
const day = monthDays[ci];
|
|
344
|
+
if (!day) return null;
|
|
345
|
+
const key = fmtDate(day);
|
|
346
|
+
const groupCourts = visibleCourts.filter((c) => c.type === row.label);
|
|
347
|
+
const total = groupCourts.length;
|
|
348
|
+
const noRatioCell = total === 0;
|
|
349
|
+
let remaining = 0;
|
|
350
|
+
let ratio = 0;
|
|
351
|
+
if (!noRatioCell) {
|
|
352
|
+
remaining = total - groupCourts.filter((c) => getSummary(c.id, key).items.length > 0).length;
|
|
353
|
+
ratio = remaining / total;
|
|
354
|
+
}
|
|
355
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
356
|
+
key: `${row.id}-${key}`,
|
|
357
|
+
style: {
|
|
358
|
+
gridRow: rowIndex + 1,
|
|
359
|
+
gridColumn: ci + 2
|
|
360
|
+
},
|
|
361
|
+
className: `flex h-full items-center justify-center border-b border-l px-1.5 py-1 text-center text-sm font-medium ${isLight ? "theme-border" : "border-zinc-800"} ${noRatioCell ? isLight ? "bg-slate-100 theme-text-faint" : "bg-zinc-800/80 text-zinc-500" : isLight ? "theme-panel-soft" : "bg-[#151a2f] text-zinc-300"}`
|
|
362
|
+
}, noRatioCell ? /* @__PURE__ */ React.createElement("div", { className: "text-xs opacity-60" }, "—") : /* @__PURE__ */ React.createElement("div", { className: `text-xs font-semibold leading-none ${getRemainingToneClass(ratio, isLight)}` }, tCal("pisell2.recordBoard.calendar.day.freeRatio", {
|
|
363
|
+
remaining,
|
|
364
|
+
total
|
|
365
|
+
})));
|
|
366
|
+
})) : /* @__PURE__ */ React.createElement(ResourceCourtRow, {
|
|
367
|
+
key: row.id,
|
|
368
|
+
courtId: String(row.id),
|
|
369
|
+
courtName: row.name,
|
|
370
|
+
courtType: row.type,
|
|
371
|
+
rowIndex,
|
|
372
|
+
visibleColIndices,
|
|
373
|
+
monthDays,
|
|
374
|
+
getSummary,
|
|
375
|
+
toggleResourceCell,
|
|
376
|
+
isLight,
|
|
377
|
+
renderResourceCell: props.renderResourceCell,
|
|
378
|
+
handleGridDropMove,
|
|
379
|
+
selectedSig: (_selectionSigByCourtI = selectionSigByCourtId.get(String(row.id))) !== null && _selectionSigByCourtI !== void 0 ? _selectionSigByCourtI : ""
|
|
380
|
+
});
|
|
381
|
+
}), /* @__PURE__ */ React.createElement(BookingOverlay, {
|
|
382
|
+
visibleCourtRows,
|
|
383
|
+
visibleColIndices,
|
|
384
|
+
monthDays,
|
|
385
|
+
rowPrefixTop,
|
|
386
|
+
rowHeights,
|
|
387
|
+
slotColWidth,
|
|
388
|
+
virt,
|
|
389
|
+
getSummary,
|
|
390
|
+
isLight,
|
|
391
|
+
renderMonthWeekBooking: props.renderMonthWeekBooking,
|
|
392
|
+
openBookingDetail,
|
|
393
|
+
setDraggingItem,
|
|
394
|
+
handleGridDropMove,
|
|
395
|
+
overflowPopover,
|
|
396
|
+
setOverflowPopover,
|
|
397
|
+
setOverflowListModal,
|
|
398
|
+
overflowPanelRef
|
|
399
|
+
}))))));
|
|
400
|
+
}
|
|
401
|
+
const ResourceCourtRow = React.memo(function ResourceCourtRow({ courtId, courtName, courtType, rowIndex, visibleColIndices, monthDays, getSummary, toggleResourceCell, isLight, renderResourceCell, handleGridDropMove, selectedSig }) {
|
|
402
|
+
/** 由签名字符串还原 Set,仅 selectedSig 变化时才重建 */
|
|
403
|
+
const selectedDateKeys = useMemo(() => selectedSig ? new Set(selectedSig.split("|")) : null, [selectedSig]);
|
|
404
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
405
|
+
className: `sticky left-0 z-30 flex h-full min-h-0 w-[132px] min-w-[132px] max-w-[132px] flex-col justify-center border-b px-2.5 py-1.5 shadow-[8px_0_16px_rgba(0,0,0,0.06)] ${isLight ? "surface-brand-side-muted" : "border-zinc-800 bg-[#1a1a22]"}`,
|
|
406
|
+
style: {
|
|
407
|
+
gridRow: rowIndex + 1,
|
|
408
|
+
gridColumn: 1
|
|
409
|
+
}
|
|
410
|
+
}, renderResourceCell ? renderResourceCell({
|
|
411
|
+
view: "resource",
|
|
412
|
+
row: {
|
|
413
|
+
kind: "court",
|
|
414
|
+
id: courtId,
|
|
415
|
+
name: courtName,
|
|
416
|
+
type: courtType
|
|
417
|
+
},
|
|
418
|
+
isLight
|
|
419
|
+
}) : /* @__PURE__ */ React.createElement("div", { className: "pisell-rb-cal-week-resource-name min-w-0 w-full font-semibold text-[16px] leading-tight" }, courtName)), visibleColIndices.map((ci) => {
|
|
420
|
+
var _selectedDateKeys$has;
|
|
421
|
+
const day = monthDays[ci];
|
|
422
|
+
if (!day) return null;
|
|
423
|
+
const key = fmtDate(day);
|
|
424
|
+
const summary = getSummary(courtId, key);
|
|
425
|
+
return /* @__PURE__ */ React.createElement(ResourceCourtCell, {
|
|
426
|
+
key: `${courtId}-${key}`,
|
|
427
|
+
courtId,
|
|
428
|
+
dateKey: key,
|
|
429
|
+
rowIndex,
|
|
430
|
+
colIndex: ci,
|
|
431
|
+
summary,
|
|
432
|
+
selected: (_selectedDateKeys$has = selectedDateKeys === null || selectedDateKeys === void 0 ? void 0 : selectedDateKeys.has(key)) !== null && _selectedDateKeys$has !== void 0 ? _selectedDateKeys$has : false,
|
|
433
|
+
isLight,
|
|
434
|
+
toggleResourceCell,
|
|
435
|
+
handleGridDropMove
|
|
436
|
+
});
|
|
437
|
+
}));
|
|
438
|
+
});
|
|
439
|
+
const ResourceCourtCell = React.memo(function ResourceCourtCell({ courtId, dateKey, rowIndex, colIndex, summary, selected, isLight, toggleResourceCell, handleGridDropMove }) {
|
|
440
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
441
|
+
type: "button",
|
|
442
|
+
onClick: () => toggleResourceCell(courtId, dateKey),
|
|
443
|
+
onDragOver: (e) => e.preventDefault(),
|
|
444
|
+
onDrop: (e) => {
|
|
445
|
+
e.preventDefault();
|
|
446
|
+
handleGridDropMove(dateKey, courtId);
|
|
447
|
+
},
|
|
448
|
+
style: {
|
|
449
|
+
gridRow: rowIndex + 1,
|
|
450
|
+
gridColumn: colIndex + 2,
|
|
451
|
+
contain: "layout paint style"
|
|
452
|
+
},
|
|
453
|
+
className: `relative flex w-full min-h-0 flex-col justify-start border-b border-l p-1 text-left align-top outline-none ${isLight ? "theme-border" : "border-zinc-700"} ${summary.fullyBooked ? isLight ? "bg-slate-100 theme-text-faint" : "bg-zinc-800 text-zinc-500" : summary.hasBlock ? isLight ? "bg-red-50 border-red-200" : "bg-red-950/30 border-red-800/40" : summary.occupiedHours.length > 0 ? isLight ? "bg-violet-50" : "bg-[#1c1630]" : isLight ? "theme-grid-cell" : "bg-zinc-900"} ${selected ? isLight ? "ring-1 ring-inset ring-violet-400/75 bg-violet-400/10" : "ring-1 ring-inset ring-violet-400/70 bg-white/10" : ""}`
|
|
454
|
+
}, summary.items.length === 0 ? /* @__PURE__ */ React.createElement("div", { className: `${CALENDAR_EMPTY_DASHED_SLOT_CLASSNAME} text-center ${isLight ? "border-[#d8d0eb] text-[#8f86a9]" : "border-zinc-700 text-zinc-500"}` }, selected ? tCal("pisell2.recordBoard.calendar.day.selected") : null) : null);
|
|
455
|
+
});
|
|
456
|
+
const OVERLAY_CELL_PAD = 4;
|
|
457
|
+
const OVERLAY_ITEM_GAP = 4;
|
|
458
|
+
const BookingOverlay = React.memo(function BookingOverlay({ visibleCourtRows, visibleColIndices, monthDays, rowPrefixTop, rowHeights, slotColWidth, virt, getSummary, isLight, renderMonthWeekBooking, openBookingDetail, setDraggingItem, handleGridDropMove, overflowPopover, setOverflowPopover, setOverflowListModal, overflowPanelRef }) {
|
|
459
|
+
var _rowPrefixTop;
|
|
460
|
+
/** 一次遍历可见区域,计算出所有 overlay item 的 px 位置 */
|
|
461
|
+
const items = useMemo(() => {
|
|
462
|
+
const out = [];
|
|
463
|
+
for (let rowIdx = 0; rowIdx < visibleCourtRows.length; rowIdx += 1) {
|
|
464
|
+
var _rowPrefixTop$rowIdx;
|
|
465
|
+
if (virt.ready && (rowIdx < virt.r0 || rowIdx > virt.r1)) continue;
|
|
466
|
+
const row = visibleCourtRows[rowIdx];
|
|
467
|
+
if ((row === null || row === void 0 ? void 0 : row.kind) !== "court" || !row.id) continue;
|
|
468
|
+
const courtId = String(row.id);
|
|
469
|
+
const cellTop = (_rowPrefixTop$rowIdx = rowPrefixTop[rowIdx]) !== null && _rowPrefixTop$rowIdx !== void 0 ? _rowPrefixTop$rowIdx : 0;
|
|
470
|
+
for (const colIdx of visibleColIndices) {
|
|
471
|
+
const day = monthDays[colIdx];
|
|
472
|
+
if (!day) continue;
|
|
473
|
+
const dateKey = fmtDate(day);
|
|
474
|
+
const summary = getSummary(courtId, dateKey);
|
|
475
|
+
if (summary.items.length === 0) continue;
|
|
476
|
+
const cellLeft = colIdx * slotColWidth + 132;
|
|
477
|
+
const previewItems = summary.items.slice(0, PREVIEW_CAP);
|
|
478
|
+
const moreItems = summary.items.slice(PREVIEW_CAP);
|
|
479
|
+
const moreCount = moreItems.length;
|
|
480
|
+
const showMore = moreCount > 0 && previewItems.length > 0;
|
|
481
|
+
const itemLeft = cellLeft + OVERLAY_CELL_PAD;
|
|
482
|
+
const itemWidth = slotColWidth - OVERLAY_CELL_PAD * 2;
|
|
483
|
+
for (let i = 0; i < previewItems.length; i += 1) {
|
|
484
|
+
var _previewItems$i$id;
|
|
485
|
+
const top = cellTop + OVERLAY_CELL_PAD + i * (48 + OVERLAY_ITEM_GAP);
|
|
486
|
+
out.push({
|
|
487
|
+
kind: "booking",
|
|
488
|
+
key: `${courtId}\t${dateKey}\t${(_previewItems$i$id = previewItems[i].id) !== null && _previewItems$i$id !== void 0 ? _previewItems$i$id : i}`,
|
|
489
|
+
item: previewItems[i],
|
|
490
|
+
courtId,
|
|
491
|
+
dateKey,
|
|
492
|
+
top,
|
|
493
|
+
left: itemLeft,
|
|
494
|
+
width: itemWidth,
|
|
495
|
+
height: 48
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
if (showMore) {
|
|
499
|
+
const top = cellTop + OVERLAY_CELL_PAD + previewItems.length * (48 + OVERLAY_ITEM_GAP);
|
|
500
|
+
out.push({
|
|
501
|
+
kind: "more",
|
|
502
|
+
key: `${courtId}\t${dateKey}\tmore`,
|
|
503
|
+
courtId,
|
|
504
|
+
dateKey,
|
|
505
|
+
top,
|
|
506
|
+
left: itemLeft,
|
|
507
|
+
width: itemWidth,
|
|
508
|
+
moreItems,
|
|
509
|
+
moreCount,
|
|
510
|
+
allItems: summary.items
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return out;
|
|
516
|
+
}, [
|
|
517
|
+
visibleCourtRows,
|
|
518
|
+
visibleColIndices,
|
|
519
|
+
monthDays,
|
|
520
|
+
rowPrefixTop,
|
|
521
|
+
slotColWidth,
|
|
522
|
+
virt,
|
|
523
|
+
getSummary
|
|
524
|
+
]);
|
|
525
|
+
const overlayHeight = (_rowPrefixTop = rowPrefixTop[rowPrefixTop.length - 1]) !== null && _rowPrefixTop !== void 0 ? _rowPrefixTop : rowHeights.reduce((a, b) => a + b, 0);
|
|
526
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
527
|
+
"aria-hidden": true,
|
|
528
|
+
style: {
|
|
529
|
+
position: "absolute",
|
|
530
|
+
top: 0,
|
|
531
|
+
left: 0,
|
|
532
|
+
width: "100%",
|
|
533
|
+
height: overlayHeight,
|
|
534
|
+
pointerEvents: "none",
|
|
535
|
+
zIndex: 5
|
|
536
|
+
}
|
|
537
|
+
}, items.map((it) => {
|
|
538
|
+
if (it.kind === "booking") {
|
|
539
|
+
const layoutClassName = `flex flex-col justify-center rounded-lg px-2.5 py-1.5 text-xs text-left w-full h-full ${getGridBookingRowStateClasses(it.item)}`;
|
|
540
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
541
|
+
key: it.key,
|
|
542
|
+
style: {
|
|
543
|
+
position: "absolute",
|
|
544
|
+
top: it.top,
|
|
545
|
+
left: it.left,
|
|
546
|
+
width: it.width,
|
|
547
|
+
height: it.height,
|
|
548
|
+
pointerEvents: "auto"
|
|
549
|
+
},
|
|
550
|
+
onDragOver: (e) => e.preventDefault(),
|
|
551
|
+
onDrop: (e) => {
|
|
552
|
+
e.preventDefault();
|
|
553
|
+
handleGridDropMove(it.dateKey, it.courtId);
|
|
554
|
+
}
|
|
555
|
+
}, renderMonthWeekBooking ? renderMonthWeekBooking({
|
|
556
|
+
item: it.item,
|
|
557
|
+
dateKey: it.dateKey,
|
|
558
|
+
view: "resource",
|
|
559
|
+
isLight,
|
|
560
|
+
layoutClassName,
|
|
561
|
+
onOpenDetail: openBookingDetail,
|
|
562
|
+
onDragStart: (i) => setDraggingItem(i),
|
|
563
|
+
draggable: false
|
|
564
|
+
}) : /* @__PURE__ */ React.createElement("button", {
|
|
565
|
+
type: "button",
|
|
566
|
+
onClick: (e) => {
|
|
567
|
+
e.stopPropagation();
|
|
568
|
+
openBookingDetail(it.item);
|
|
569
|
+
},
|
|
570
|
+
className: layoutClassName
|
|
571
|
+
}, /* @__PURE__ */ React.createElement("div", { className: "truncate" }, it.item.name), /* @__PURE__ */ React.createElement("div", { className: "mt-1 opacity-80 truncate" }, formatHourLabel(it.item.startHour), " -", " ", formatHourLabel(it.item.endHour))));
|
|
572
|
+
}
|
|
573
|
+
const isThisPopover = (overflowPopover === null || overflowPopover === void 0 ? void 0 : overflowPopover.courtId) === it.courtId && (overflowPopover === null || overflowPopover === void 0 ? void 0 : overflowPopover.date) === it.dateKey;
|
|
574
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
575
|
+
key: it.key,
|
|
576
|
+
ref: isThisPopover ? overflowPanelRef : null,
|
|
577
|
+
style: {
|
|
578
|
+
position: "absolute",
|
|
579
|
+
top: it.top,
|
|
580
|
+
left: it.left,
|
|
581
|
+
width: it.width,
|
|
582
|
+
minHeight: 48,
|
|
583
|
+
pointerEvents: "auto"
|
|
584
|
+
}
|
|
585
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
586
|
+
type: "button",
|
|
587
|
+
onMouseEnter: (e) => {
|
|
588
|
+
e.stopPropagation();
|
|
589
|
+
setOverflowPopover({
|
|
590
|
+
courtId: it.courtId,
|
|
591
|
+
date: it.dateKey,
|
|
592
|
+
items: it.moreItems,
|
|
593
|
+
pinned: false
|
|
594
|
+
});
|
|
595
|
+
},
|
|
596
|
+
onClick: (e) => {
|
|
597
|
+
e.stopPropagation();
|
|
598
|
+
setOverflowPopover(null);
|
|
599
|
+
setOverflowListModal((prev) => prev && prev.scope === it.courtId && prev.date === it.dateKey ? null : {
|
|
600
|
+
scope: it.courtId,
|
|
601
|
+
date: it.dateKey,
|
|
602
|
+
title: tCal("pisell2.recordBoard.calendar.overflow.listTitleAllBookings", { date: it.dateKey }),
|
|
603
|
+
items: it.allItems.filter((x) => x.kind === "booking")
|
|
604
|
+
});
|
|
605
|
+
},
|
|
606
|
+
style: { minHeight: 48 },
|
|
607
|
+
className: "flex w-full items-center justify-center rounded-xl bg-violet-700/90 px-2.5 py-1 text-xs font-semibold text-white"
|
|
608
|
+
}, "+", it.moreCount));
|
|
609
|
+
}));
|
|
610
|
+
});
|
|
611
|
+
//#endregion
|
|
612
|
+
export { BookingCalendarResourceView };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { dayOccupancy } from "../../utils/bookingCalendarDateUtils.js";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
//#region src/components/pisellRecordBoard/shellFrame/Calendar/view/day/useBookingCalendarDayHourRemaining.ts
|
|
4
|
+
/**
|
|
5
|
+
* 日视图表头:每列整点仍空闲资源占比。
|
|
6
|
+
*/
|
|
7
|
+
function useBookingCalendarDayHourRemaining(visibleCourts, dayKey, bookings, hourSlots, slotStepHours, isBusinessHour) {
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
const total = visibleCourts.length;
|
|
10
|
+
return Object.fromEntries(hourSlots.map((hour) => {
|
|
11
|
+
if (!isBusinessHour(hour)) return [hour, {
|
|
12
|
+
remaining: 0,
|
|
13
|
+
total,
|
|
14
|
+
ratio: 0
|
|
15
|
+
}];
|
|
16
|
+
const remaining = visibleCourts.filter((court) => !dayOccupancy(court.id, dayKey, bookings, hourSlots, slotStepHours)[hour]).length;
|
|
17
|
+
return [hour, {
|
|
18
|
+
remaining,
|
|
19
|
+
total,
|
|
20
|
+
ratio: total > 0 ? remaining / total : 0
|
|
21
|
+
}];
|
|
22
|
+
}));
|
|
23
|
+
}, [
|
|
24
|
+
visibleCourts,
|
|
25
|
+
dayKey,
|
|
26
|
+
bookings,
|
|
27
|
+
hourSlots,
|
|
28
|
+
slotStepHours,
|
|
29
|
+
isBusinessHour
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { useBookingCalendarDayHourRemaining };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { dayOccupancy, sameSlot } from "../../utils/bookingCalendarDateUtils.js";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
//#region src/components/pisellRecordBoard/shellFrame/Calendar/view/day/useBookingCalendarDaySelection.ts
|
|
4
|
+
/**
|
|
5
|
+
* 日视图:空闲 / 锁台槽多选逻辑(状态仍在 Shell,便于与底部 SelectionBar 共用)。
|
|
6
|
+
*/
|
|
7
|
+
function useBookingCalendarDaySelection(dayKey, bookings, hourSlots, slotStepHours, courts, selectedFreeSlots, selectedBlockSlots, setSelectedFreeSlots, setSelectedBlockSlots) {
|
|
8
|
+
return {
|
|
9
|
+
isFreeSelected: useCallback((courtId, hour) => selectedFreeSlots.some((slot) => slot.courtId === courtId && slot.date === dayKey && slot.hour === hour), [selectedFreeSlots, dayKey]),
|
|
10
|
+
isBlockSelected: useCallback((courtId, hour) => selectedBlockSlots.some((slot) => slot.courtId === courtId && slot.date === dayKey && slot.hour === hour), [selectedBlockSlots, dayKey]),
|
|
11
|
+
toggleSlot: useCallback((courtId, hour) => {
|
|
12
|
+
const existing = dayOccupancy(courtId, dayKey, bookings, hourSlots, slotStepHours)[hour];
|
|
13
|
+
const court = courts.find((c) => c.id === courtId);
|
|
14
|
+
const slot = {
|
|
15
|
+
courtId,
|
|
16
|
+
court: court === null || court === void 0 ? void 0 : court.name,
|
|
17
|
+
date: dayKey,
|
|
18
|
+
hour
|
|
19
|
+
};
|
|
20
|
+
if (!existing) {
|
|
21
|
+
setSelectedFreeSlots((prev) => prev.some((s) => sameSlot(s, slot)) ? prev.filter((s) => !sameSlot(s, slot)) : [...prev, slot]);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (existing.kind === "block") setSelectedBlockSlots((prev) => prev.some((s) => sameSlot(s, slot)) ? prev.filter((s) => !sameSlot(s, slot)) : [...prev, slot]);
|
|
25
|
+
}, [
|
|
26
|
+
bookings,
|
|
27
|
+
courts,
|
|
28
|
+
dayKey,
|
|
29
|
+
hourSlots,
|
|
30
|
+
setSelectedBlockSlots,
|
|
31
|
+
setSelectedFreeSlots,
|
|
32
|
+
slotStepHours
|
|
33
|
+
])
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useBookingCalendarDaySelection };
|