@pisell/materials 6.12.61 → 6.12.63
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/meta.js +1 -1
- package/build/lowcode/render/default/view.js +48 -48
- package/build/lowcode/view.js +48 -48
- package/es/components/page/dateLocale.js +33 -0
- package/es/components/page/index.d.ts +1 -0
- package/es/components/page/index.js +30 -4
- package/es/components/pisellRecordBoard/shellFrame/Calendar/BookingCalendar.js +13 -7
- package/es/components/pisellRecordBoard/shellFrame/Calendar/calendarI18n.js +2 -1
- package/es/components/pisellRecordBoard/shellFrame/Calendar/utils/bookingCalendarDateUtils.js +6 -6
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarMonthView.js +3 -3
- package/es/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarWeekView.js +3 -3
- package/es/components/pisellRecordBoard/types.d.ts +2 -0
- package/lib/components/page/dateLocale.js +35 -0
- package/lib/components/page/index.d.ts +1 -0
- package/lib/components/page/index.js +33 -4
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/BookingCalendar.js +12 -6
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/calendarI18n.js +2 -0
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/utils/bookingCalendarDateUtils.js +6 -6
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarMonthView.js +2 -2
- package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarWeekView.js +2 -2
- package/lib/components/pisellRecordBoard/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/components/page/dateLocale.ts
|
|
2
|
+
const COUNTRY_WEEK_STARTS_ON = {
|
|
3
|
+
US: 0,
|
|
4
|
+
CA: 0,
|
|
5
|
+
AU: 1,
|
|
6
|
+
NZ: 1,
|
|
7
|
+
SG: 0,
|
|
8
|
+
HK: 0,
|
|
9
|
+
TW: 0,
|
|
10
|
+
CN: 1,
|
|
11
|
+
JP: 0,
|
|
12
|
+
KR: 0,
|
|
13
|
+
MY: 1,
|
|
14
|
+
GB: 1,
|
|
15
|
+
FR: 1,
|
|
16
|
+
IT: 1
|
|
17
|
+
};
|
|
18
|
+
function normalizePageCountryCode(value) {
|
|
19
|
+
const countryCode = String(value !== null && value !== void 0 ? value : "").trim().toUpperCase();
|
|
20
|
+
return /^[A-Z]{2}$/.test(countryCode) ? countryCode : void 0;
|
|
21
|
+
}
|
|
22
|
+
/** Undefined tells Page to preserve its previous locale behaviour. */
|
|
23
|
+
function getPageWeekStartsOn(countryCode) {
|
|
24
|
+
const normalized = normalizePageCountryCode(countryCode);
|
|
25
|
+
return normalized ? COUNTRY_WEEK_STARTS_ON[normalized] : void 0;
|
|
26
|
+
}
|
|
27
|
+
function getPageEnglishAdapterLocale(countryCode) {
|
|
28
|
+
const weekStartsOn = getPageWeekStartsOn(countryCode);
|
|
29
|
+
if (weekStartsOn === void 0) return void 0;
|
|
30
|
+
return weekStartsOn === 1 ? "en-gb" : "en";
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { getPageEnglishAdapterLocale, getPageWeekStartsOn, normalizePageCountryCode };
|
|
@@ -5,25 +5,31 @@ import ConfigProvider$1 from "../config-provider/index.js";
|
|
|
5
5
|
import VariablesProvider from "../dataSourceComponents/provider/variables/VariablesProvider.js";
|
|
6
6
|
import PisellConfigProvider from "../pisell-config-provider/index.js";
|
|
7
7
|
import { getThemeConfig } from "../../theme/tokens.js";
|
|
8
|
+
import { getPageEnglishAdapterLocale, getPageWeekStartsOn, normalizePageCountryCode } from "./dateLocale.js";
|
|
8
9
|
import React, { useEffect, useMemo } from "react";
|
|
9
10
|
import { App } from "antd";
|
|
11
|
+
import dayjs from "dayjs";
|
|
10
12
|
import { LocaleProvider, LocalizationProvider, ThemeProvider, createTheme } from "@pisell/date-picker";
|
|
11
13
|
import zhCN from "antd/es/locale/zh_CN";
|
|
12
14
|
import { AdapterDayjs } from "@pisell/date-picker/es/AdapterDayjs";
|
|
13
15
|
import enUS from "antd/es/locale/en_US";
|
|
16
|
+
import enGB from "antd/es/locale/en_GB";
|
|
14
17
|
import zhTW from "antd/es/locale/zh_TW";
|
|
15
18
|
import zhHK from "antd/es/locale/zh_HK";
|
|
16
19
|
import jaJP from "antd/es/locale/ja_JP";
|
|
17
20
|
import ptPT from "antd/es/locale/pt_PT";
|
|
21
|
+
import enGbLocale from "dayjs/locale/en-gb";
|
|
18
22
|
//#region src/components/page/index.tsx
|
|
19
23
|
const _excluded = [
|
|
20
24
|
"children",
|
|
21
25
|
"style",
|
|
22
26
|
"className",
|
|
23
27
|
"locale",
|
|
28
|
+
"countryCode",
|
|
24
29
|
"variablesConfig",
|
|
25
30
|
"isRenderPisellConfigProvider"
|
|
26
31
|
];
|
|
32
|
+
dayjs.locale(enGbLocale, void 0, true);
|
|
27
33
|
const localMap = {
|
|
28
34
|
"zh-TW": zhTW,
|
|
29
35
|
"zh-CN": zhCN,
|
|
@@ -43,11 +49,31 @@ const localeDateMap = {
|
|
|
43
49
|
"pt": { adapterLocale: "pt" }
|
|
44
50
|
};
|
|
45
51
|
const Page = (props) => {
|
|
46
|
-
var _context$appHelper, _context$engine, _localeDateMap, _context$engine2;
|
|
47
|
-
const { children, style, className, locale: propsLocale, variablesConfig, isRenderPisellConfigProvider = true } = props, others = _objectWithoutProperties(props, _excluded);
|
|
52
|
+
var _context$appHelper, _context$engine, _context$appHelper2, _localeDateMap, _context$engine2;
|
|
53
|
+
const { children, style, className, locale: propsLocale, countryCode: propsCountryCode, variablesConfig, isRenderPisellConfigProvider = true } = props, others = _objectWithoutProperties(props, _excluded);
|
|
48
54
|
const context = useEngineContext();
|
|
49
55
|
const { platform, themeColor } = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.constants) || {};
|
|
50
56
|
const locale = propsLocale || (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en";
|
|
57
|
+
const utils = context === null || context === void 0 || (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.utils;
|
|
58
|
+
let countryCode = normalizePageCountryCode(propsCountryCode);
|
|
59
|
+
try {
|
|
60
|
+
var _utils$getStore, _utils$getStore$getSt, _utils$store, _utils$store$getState, _utils$getApp, _utils$getApp$getStor, _utils$getApp$getStor2, _hostState$global, _utils$getData, _context$appHelper3, _context$appHelper4, _context$appHelper5;
|
|
61
|
+
const hostState = (utils === null || utils === void 0 || (_utils$getStore = utils.getStore) === null || _utils$getStore === void 0 || (_utils$getStore = _utils$getStore.call(utils)) === null || _utils$getStore === void 0 || (_utils$getStore$getSt = _utils$getStore.getState) === null || _utils$getStore$getSt === void 0 ? void 0 : _utils$getStore$getSt.call(_utils$getStore)) || (utils === null || utils === void 0 || (_utils$store = utils.store) === null || _utils$store === void 0 || (_utils$store$getState = _utils$store.getState) === null || _utils$store$getState === void 0 ? void 0 : _utils$store$getState.call(_utils$store));
|
|
62
|
+
const appCore = utils === null || utils === void 0 || (_utils$getApp = utils.getApp) === null || _utils$getApp === void 0 || (_utils$getApp = _utils$getApp.call(utils)) === null || _utils$getApp === void 0 || (_utils$getApp = _utils$getApp.data) === null || _utils$getApp === void 0 || (_utils$getApp = _utils$getApp.store) === null || _utils$getApp === void 0 || (_utils$getApp$getStor = _utils$getApp.getStore) === null || _utils$getApp$getStor === void 0 || (_utils$getApp$getStor = _utils$getApp$getStor.call(_utils$getApp)) === null || _utils$getApp$getStor === void 0 || (_utils$getApp$getStor2 = _utils$getApp$getStor.getDataByModel) === null || _utils$getApp$getStor2 === void 0 ? void 0 : _utils$getApp$getStor2.call(_utils$getApp$getStor, "core", "core");
|
|
63
|
+
countryCode = [
|
|
64
|
+
countryCode,
|
|
65
|
+
hostState === null || hostState === void 0 || (_hostState$global = hostState.global) === null || _hostState$global === void 0 || (_hostState$global = _hostState$global.shopDetail) === null || _hostState$global === void 0 ? void 0 : _hostState$global.country_code,
|
|
66
|
+
utils === null || utils === void 0 || (_utils$getData = utils.getData) === null || _utils$getData === void 0 || (_utils$getData = _utils$getData.call(utils, "shop_info")) === null || _utils$getData === void 0 ? void 0 : _utils$getData.country_code,
|
|
67
|
+
appCore === null || appCore === void 0 ? void 0 : appCore.country_code,
|
|
68
|
+
context === null || context === void 0 || (_context$appHelper3 = context.appHelper) === null || _context$appHelper3 === void 0 || (_context$appHelper3 = _context$appHelper3.constants) === null || _context$appHelper3 === void 0 ? void 0 : _context$appHelper3.countryCode,
|
|
69
|
+
context === null || context === void 0 || (_context$appHelper4 = context.appHelper) === null || _context$appHelper4 === void 0 || (_context$appHelper4 = _context$appHelper4.constants) === null || _context$appHelper4 === void 0 ? void 0 : _context$appHelper4.country_code,
|
|
70
|
+
context === null || context === void 0 || (_context$appHelper5 = context.appHelper) === null || _context$appHelper5 === void 0 || (_context$appHelper5 = _context$appHelper5.constants) === null || _context$appHelper5 === void 0 ? void 0 : _context$appHelper5.country
|
|
71
|
+
].map(normalizePageCountryCode).find((candidate) => candidate !== void 0);
|
|
72
|
+
} catch (_unused) {}
|
|
73
|
+
const englishAdapterLocale = getPageEnglishAdapterLocale(countryCode);
|
|
74
|
+
const weekStartsOn = getPageWeekStartsOn(countryCode);
|
|
75
|
+
const isEnglish = String(locale).toLowerCase().startsWith("en");
|
|
76
|
+
const antdLocale = isEnglish && weekStartsOn !== void 0 ? weekStartsOn === 1 ? enGB : enUS : localMap[locale];
|
|
51
77
|
const theme = useMemo(() => {
|
|
52
78
|
if (props === null || props === void 0 ? void 0 : props.theme) {
|
|
53
79
|
var _props$theme;
|
|
@@ -64,7 +90,7 @@ const Page = (props) => {
|
|
|
64
90
|
document.body.id = "body";
|
|
65
91
|
}, []);
|
|
66
92
|
return /* @__PURE__ */ React.createElement(ConfigProvider$1, _objectSpread2(_objectSpread2({}, others), {}, {
|
|
67
|
-
locale:
|
|
93
|
+
locale: antdLocale,
|
|
68
94
|
prefixCls: props.prefixCls || "pisell-lowcode",
|
|
69
95
|
theme
|
|
70
96
|
}), /* @__PURE__ */ React.createElement(App, {
|
|
@@ -72,7 +98,7 @@ const Page = (props) => {
|
|
|
72
98
|
message: { maxCount: 1 }
|
|
73
99
|
}, /* @__PURE__ */ React.createElement(LocalizationProvider, {
|
|
74
100
|
dateAdapter: AdapterDayjs,
|
|
75
|
-
adapterLocale: (localeDateMap === null || localeDateMap === void 0 || (_localeDateMap = localeDateMap[locale]) === null || _localeDateMap === void 0 ? void 0 : _localeDateMap.adapterLocale) || "en"
|
|
101
|
+
adapterLocale: isEnglish && englishAdapterLocale || (localeDateMap === null || localeDateMap === void 0 || (_localeDateMap = localeDateMap[locale]) === null || _localeDateMap === void 0 ? void 0 : _localeDateMap.adapterLocale) || "en"
|
|
76
102
|
}, /* @__PURE__ */ React.createElement(ThemeProvider, { theme: datePickerTheme }, /* @__PURE__ */ React.createElement(LocaleProvider, { value: { locale } }, /* @__PURE__ */ React.createElement(PisellConfigProvid, { locale }, /* @__PURE__ */ React.createElement(VariablesProvider, {
|
|
77
103
|
variables: ((_context$engine2 = context.engine) === null || _context$engine2 === void 0 || (_context$engine2 = _context$engine2.props) === null || _context$engine2 === void 0 ? void 0 : _context$engine2.variables) || {},
|
|
78
104
|
config: variablesConfig
|
|
@@ -3,7 +3,7 @@ import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.
|
|
|
3
3
|
import { buildCalendarTimelineSlotStartsFromRange } from "../../../pisellTimeNavigator/utils/index.js";
|
|
4
4
|
import { useCalendarPersist } from "./calendarPersistGuard.js";
|
|
5
5
|
import { DEFAULT_CALENDAR_TIMELINE } from "./const/bookingCalendarConstants.js";
|
|
6
|
-
import { tCal } from "./calendarI18n.js";
|
|
6
|
+
import { CALENDAR_WEEKDAY_IDS, SUNDAY_FIRST_CALENDAR_WEEKDAY_IDS, tCal } from "./calendarI18n.js";
|
|
7
7
|
import { addDays, dayAndHourToDayjs, fmtDate, groupSelectedSlots, isCrossDayBooking, isFreeSelectionContiguousSameResource, isHourInTimelineSlots, monthCalendarDays, monthGrid, rangeDays, startOfWeek } from "./utils/bookingCalendarDateUtils.js";
|
|
8
8
|
import { MoveConfirmModal } from "./modal/MoveConfirmModal.js";
|
|
9
9
|
import { BookingCalendarBlockPanel } from "./modal/BookingCalendarBlockPanel.js";
|
|
@@ -32,7 +32,9 @@ import "./BookingCalendar.less";
|
|
|
32
32
|
*/
|
|
33
33
|
/** 看板日历根组件:内含主题 CSS 与 Spin,按 `view` 挂载月 / 周 / 日子组件 */
|
|
34
34
|
function BookingCalendar(props = {}) {
|
|
35
|
-
var _hourSlots$;
|
|
35
|
+
var _props$weekStartsOn, _hourSlots$;
|
|
36
|
+
const weekStartsOn = (_props$weekStartsOn = props.weekStartsOn) !== null && _props$weekStartsOn !== void 0 ? _props$weekStartsOn : 1;
|
|
37
|
+
const weekdayIds = weekStartsOn === 0 ? SUNDAY_FIRST_CALENDAR_WEEKDAY_IDS : CALENDAR_WEEKDAY_IDS;
|
|
36
38
|
const allowPersist = useCalendarPersist();
|
|
37
39
|
/** 将 `resources` 规范为 `{ id, name, type }`,供分组与三视图共用 */
|
|
38
40
|
const courts = useMemo(() => {
|
|
@@ -97,7 +99,7 @@ function BookingCalendar(props = {}) {
|
|
|
97
99
|
rangeStart = new Date(a.getFullYear(), a.getMonth(), 1);
|
|
98
100
|
rangeEnd = new Date(a.getFullYear(), a.getMonth() + 1, 0);
|
|
99
101
|
} else if (view === "week") {
|
|
100
|
-
rangeStart = startOfWeek(a);
|
|
102
|
+
rangeStart = startOfWeek(a, weekStartsOn);
|
|
101
103
|
rangeEnd = addDays(rangeStart, 6);
|
|
102
104
|
} else {
|
|
103
105
|
rangeStart = new Date(a);
|
|
@@ -112,7 +114,8 @@ function BookingCalendar(props = {}) {
|
|
|
112
114
|
}, [
|
|
113
115
|
view,
|
|
114
116
|
anchorDate,
|
|
115
|
-
props.onViewportChange
|
|
117
|
+
props.onViewportChange,
|
|
118
|
+
weekStartsOn
|
|
116
119
|
]);
|
|
117
120
|
const [selectedFreeSlots, setSelectedFreeSlots] = useState([]);
|
|
118
121
|
const [selectedBlockSlots, setSelectedBlockSlots] = useState([]);
|
|
@@ -175,7 +178,7 @@ function BookingCalendar(props = {}) {
|
|
|
175
178
|
*/
|
|
176
179
|
const { dayRowHeights, overlayBookings, courtDayDisplayLaneCount, hiddenDayOverlayIdSet, dayOverlayOverflowPluses } = useBookingCalendarDayOverlayLayout(visibleCourtRows, dayKey, bookings, hourSlots, slotStepHours);
|
|
177
180
|
/** 周视图表头对应的 7 个自然日 */
|
|
178
|
-
const weekDays = useMemo(() => rangeDays(anchorDate), [anchorDate]);
|
|
181
|
+
const weekDays = useMemo(() => rangeDays(anchorDate, weekStartsOn), [anchorDate, weekStartsOn]);
|
|
179
182
|
/** 资源视图:当月每日一列 */
|
|
180
183
|
const resourceMonthDays = useMemo(() => monthCalendarDays(anchorDate), [anchorDate]);
|
|
181
184
|
useMemo(() => new Set(weekDays.map((d) => fmtDate(d))), [weekDays]);
|
|
@@ -211,12 +214,13 @@ function BookingCalendar(props = {}) {
|
|
|
211
214
|
}
|
|
212
215
|
}, [view]);
|
|
213
216
|
/** 月历每格摘要(占用点、锁台等),供月视图渲染 */
|
|
214
|
-
const monthDays = useMemo(() => monthGrid(anchorDate, bookings, courts, hourSlots, slotStepHours), [
|
|
217
|
+
const monthDays = useMemo(() => monthGrid(anchorDate, bookings, courts, hourSlots, slotStepHours, weekStartsOn), [
|
|
215
218
|
anchorDate,
|
|
216
219
|
bookings,
|
|
217
220
|
courts,
|
|
218
221
|
hourSlots,
|
|
219
|
-
slotStepHours
|
|
222
|
+
slotStepHours,
|
|
223
|
+
weekStartsOn
|
|
220
224
|
]);
|
|
221
225
|
/** 日视图内容区总高度(表头 + 各资源行叠加以 overlay 抬高后的高度) */
|
|
222
226
|
const dayContentHeight = 56 + dayRowHeights.reduce((sum, h) => sum + h, 0);
|
|
@@ -610,6 +614,7 @@ function BookingCalendar(props = {}) {
|
|
|
610
614
|
className: "theme-shell soft-shadow mx-0 flex h-full min-h-0 w-full max-w-none flex-1 flex-col overflow-hidden transition-[padding-right] duration-200",
|
|
611
615
|
style: { paddingRight: 0 }
|
|
612
616
|
}, /* @__PURE__ */ React.createElement("div", { className: "flex min-h-0 flex-1 flex-col" }, view === "month" && /* @__PURE__ */ React.createElement(BookingCalendarMonthView, {
|
|
617
|
+
weekdayIds,
|
|
613
618
|
isLight,
|
|
614
619
|
anchorDate,
|
|
615
620
|
monthDays,
|
|
@@ -622,6 +627,7 @@ function BookingCalendar(props = {}) {
|
|
|
622
627
|
renderMonthWeekBooking: props.renderMonthWeekBooking,
|
|
623
628
|
tickFillMode: resolveTickFillMode("month", props.tickFillMode)
|
|
624
629
|
}), view === "week" && /* @__PURE__ */ React.createElement(BookingCalendarWeekView, {
|
|
630
|
+
weekdayIds,
|
|
625
631
|
calendarProps: props,
|
|
626
632
|
isLight,
|
|
627
633
|
weekDays,
|
|
@@ -18,5 +18,6 @@ const CALENDAR_WEEKDAY_IDS = [
|
|
|
18
18
|
"pisell2.recordBoard.calendar.weekday.sat",
|
|
19
19
|
"pisell2.recordBoard.calendar.weekday.sun"
|
|
20
20
|
];
|
|
21
|
+
const SUNDAY_FIRST_CALENDAR_WEEKDAY_IDS = [CALENDAR_WEEKDAY_IDS[6], ...CALENDAR_WEEKDAY_IDS.slice(0, 6)];
|
|
21
22
|
//#endregion
|
|
22
|
-
export { CALENDAR_WEEKDAY_IDS, tCal };
|
|
23
|
+
export { CALENDAR_WEEKDAY_IDS, SUNDAY_FIRST_CALENDAR_WEEKDAY_IDS, tCal };
|
package/es/components/pisellRecordBoard/shellFrame/Calendar/utils/bookingCalendarDateUtils.js
CHANGED
|
@@ -24,16 +24,16 @@ function addDays(date, n) {
|
|
|
24
24
|
next.setDate(next.getDate() + n);
|
|
25
25
|
return next;
|
|
26
26
|
}
|
|
27
|
-
function startOfWeek(date) {
|
|
27
|
+
function startOfWeek(date, weekStartsOn = 1) {
|
|
28
28
|
const d = new Date(date);
|
|
29
29
|
const day = d.getDay();
|
|
30
|
-
const diff = day === 0 ? -6 : 1 - day;
|
|
30
|
+
const diff = weekStartsOn === 0 ? -day : day === 0 ? -6 : 1 - day;
|
|
31
31
|
d.setDate(d.getDate() + diff);
|
|
32
32
|
d.setHours(0, 0, 0, 0);
|
|
33
33
|
return d;
|
|
34
34
|
}
|
|
35
|
-
function rangeDays(anchor) {
|
|
36
|
-
const start = startOfWeek(anchor);
|
|
35
|
+
function rangeDays(anchor, weekStartsOn = 1) {
|
|
36
|
+
const start = startOfWeek(anchor, weekStartsOn);
|
|
37
37
|
return Array.from({ length: 7 }, (_, i) => addDays(start, i));
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
@@ -67,11 +67,11 @@ function formatShortMonthDay(dateKey) {
|
|
|
67
67
|
if (!m || !d) return dateKey;
|
|
68
68
|
return `${m}/${d}`;
|
|
69
69
|
}
|
|
70
|
-
function monthGrid(date, bookings, courtsList = [], hourSlotsIn, slotStepHours = 1) {
|
|
70
|
+
function monthGrid(date, bookings, courtsList = [], hourSlotsIn, slotStepHours = 1, weekStartsOn = 1) {
|
|
71
71
|
const hourSlots = hourSlotsIn && hourSlotsIn.length ? hourSlotsIn : buildCalendarTimelineSlotStartsFromRange(DEFAULT_CALENDAR_TIMELINE, date, 60);
|
|
72
72
|
const year = date.getFullYear();
|
|
73
73
|
const month = date.getMonth();
|
|
74
|
-
const start = startOfWeek(new Date(year, month, 1));
|
|
74
|
+
const start = startOfWeek(new Date(year, month, 1), weekStartsOn);
|
|
75
75
|
return Array.from({ length: 35 }, (_, i) => addDays(start, i)).map((day) => {
|
|
76
76
|
const key = fmtDate(day);
|
|
77
77
|
const dayBookings = bookings.filter((b) => b.kind === "booking" && getBookingSegmentForDate(b, key) != null);
|
package/es/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarMonthView.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { monthViewEffectiveMaxLanes } from "../const/bookingCalendarConstants.js";
|
|
2
|
-
import {
|
|
2
|
+
import { tCal } from "../calendarI18n.js";
|
|
3
3
|
import { assignPerDateLanesCrossDayUnified, clipBookingDaySpanToWindow, fmtDate, formatHourLabel, formatShortMonthDay, getBookingSegmentForDate, isCrossDayBooking } from "../utils/bookingCalendarDateUtils.js";
|
|
4
4
|
import { getGridBookingRowStateClasses } from "../utils/BookingCalendarStyle.js";
|
|
5
5
|
import { CalendarGridBookingClipMarkers } from "../bookingCalendarViewShared.js";
|
|
@@ -15,7 +15,7 @@ const MONTH_GRID_COLS = 7;
|
|
|
15
15
|
* - 行高内自适应 effectiveMaxLane,超出 → cell 级 `+N` tile;
|
|
16
16
|
* - cell 层只负责日期 header / 点击跳日 / drop 改期,不再渲染 booking 列表(被 overlay 替代)。
|
|
17
17
|
*/
|
|
18
|
-
function BookingCalendarMonthView({ isLight, anchorDate, monthDays, bookings, goToDayFromCell, handleGridDropMove, setDraggingItem, openBookingDetail, setOverflowListModal, renderMonthWeekBooking, tickFillMode }) {
|
|
18
|
+
function BookingCalendarMonthView({ weekdayIds, isLight, anchorDate, monthDays, bookings, goToDayFromCell, handleGridDropMove, setDraggingItem, openBookingDetail, setOverflowListModal, renderMonthWeekBooking, tickFillMode }) {
|
|
19
19
|
const todayKey = fmtDate(/* @__PURE__ */ new Date());
|
|
20
20
|
const weekRows = useMemo(() => {
|
|
21
21
|
const out = [];
|
|
@@ -48,7 +48,7 @@ function BookingCalendarMonthView({ isLight, anchorDate, monthDays, bookings, go
|
|
|
48
48
|
return /* @__PURE__ */ React.createElement("div", {
|
|
49
49
|
key: `month-${anchorDate.getFullYear()}-${anchorDate.getMonth()}`,
|
|
50
50
|
className: "flex min-h-0 flex-1 flex-col"
|
|
51
|
-
}, /* @__PURE__ */ React.createElement("div", { className: "relative flex min-h-0 flex-1 flex-col overflow-hidden" }, /* @__PURE__ */ React.createElement("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-auto overflow-y-hidden" }, /* @__PURE__ */ React.createElement("div", { className: "theme-panel flex min-h-[0] min-w-[980px] flex-1 flex-col overflow-hidden" }, /* @__PURE__ */ React.createElement("div", { className: "theme-panel-alt grid shrink-0 grid-cols-7 border-b theme-border shadow-[0_6px_12px_rgba(0,0,0,0.08)]" },
|
|
51
|
+
}, /* @__PURE__ */ React.createElement("div", { className: "relative flex min-h-0 flex-1 flex-col overflow-hidden" }, /* @__PURE__ */ React.createElement("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-auto overflow-y-hidden" }, /* @__PURE__ */ React.createElement("div", { className: "theme-panel flex min-h-[0] min-w-[980px] flex-1 flex-col overflow-hidden" }, /* @__PURE__ */ React.createElement("div", { className: "theme-panel-alt grid shrink-0 grid-cols-7 border-b theme-border shadow-[0_6px_12px_rgba(0,0,0,0.08)]" }, weekdayIds.map((id) => /* @__PURE__ */ React.createElement("div", {
|
|
52
52
|
key: id,
|
|
53
53
|
className: "px-4 py-2.5 text-center text-sm font-medium"
|
|
54
54
|
}, tCal(id)))), /* @__PURE__ */ React.createElement("div", {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CALENDAR_EMPTY_DASHED_SLOT_CLASSNAME } from "../const/bookingCalendarConstants.js";
|
|
2
|
-
import {
|
|
2
|
+
import { tCal } from "../calendarI18n.js";
|
|
3
3
|
import { assignLanesByInterval, bookingIntersectsDateWindow, courtDaySummary, dayOccupancy, fmtDate, formatHourLabel, formatShortMonthDay, getBookingSegmentForDate, isCrossDayBooking } from "../utils/bookingCalendarDateUtils.js";
|
|
4
4
|
import { getGridBookingRowStateClasses } from "../utils/BookingCalendarStyle.js";
|
|
5
5
|
import { CalendarGridBookingClipMarkers, getRemainingToneClass } from "../bookingCalendarViewShared.js";
|
|
@@ -13,7 +13,7 @@ const WEEK_VIEW_OVERLAY_LANE_GAP = 4;
|
|
|
13
13
|
/**
|
|
14
14
|
* 周视图:7 日网格 + 左侧分组(可折叠),单元格调起日视图;格内 drop 触发改期草稿。
|
|
15
15
|
*/
|
|
16
|
-
function BookingCalendarWeekView({ calendarProps, isLight, weekDays, bookings, courts, hourSlots, slotStepHours, visibleCourts, visibleCourtRows, isBusinessHour, goToDayFromCell, handleGridDropMove, openBookingDetail, setDraggingItem, setCollapsedGroups, setOverflowListModal, tickFillMode }) {
|
|
16
|
+
function BookingCalendarWeekView({ weekdayIds, calendarProps, isLight, weekDays, bookings, courts, hourSlots, slotStepHours, visibleCourts, visibleCourtRows, isBusinessHour, goToDayFromCell, handleGridDropMove, openBookingDetail, setDraggingItem, setCollapsedGroups, setOverflowListModal, tickFillMode }) {
|
|
17
17
|
const props = calendarProps;
|
|
18
18
|
const todayKey = fmtDate(/* @__PURE__ */ new Date());
|
|
19
19
|
/** 与下方 grid `minmax(…px, 1fr)` 一致:窄屏由外层 overflow-auto + min-w-0 定视口宽,本值撑开 scrollWidth */
|
|
@@ -142,7 +142,7 @@ function BookingCalendarWeekView({ calendarProps, isLight, weekDays, bookings, c
|
|
|
142
142
|
return /* @__PURE__ */ React.createElement("div", {
|
|
143
143
|
key,
|
|
144
144
|
className: `relative z-20 border-b border-l px-1.5 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]"}`
|
|
145
|
-
}, /* @__PURE__ */ React.createElement("div", { className: `text-sm leading-tight ${isLight ? "theme-text-faint" : "text-zinc-400"}` }, tCal(
|
|
145
|
+
}, /* @__PURE__ */ React.createElement("div", { className: `text-sm leading-tight ${isLight ? "theme-text-faint" : "text-zinc-400"}` }, tCal(weekdayIds[i])), /* @__PURE__ */ React.createElement("div", { className: "mt-0.5 flex justify-center" }, /* @__PURE__ */ React.createElement("span", {
|
|
146
146
|
className: "grid h-10 w-10 place-items-center text-3xl font-semibold leading-none",
|
|
147
147
|
"aria-label": isToday ? "Today" : void 0
|
|
148
148
|
}, day.getDate())));
|
|
@@ -329,6 +329,8 @@ interface RecordBoardBlockedTimePanelPayload {
|
|
|
329
329
|
}
|
|
330
330
|
/** 日历视图槽位 props:由 Shell 合并根级与子槽后传入 PisellRecordBoardCalendarView */
|
|
331
331
|
interface RecordBoardCalendarProps {
|
|
332
|
+
/** 0 = Sunday, 1 = Monday. Omitted keeps the original Monday-first behaviour. */
|
|
333
|
+
weekStartsOn?: 0 | 1;
|
|
332
334
|
persistGuard?: CalendarPersistContextValue;
|
|
333
335
|
/**
|
|
334
336
|
* 日历画布外观:亮色切换 `theme-root.theme-light`;未传或 `dark` 为深色(默认)。
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/components/page/dateLocale.ts
|
|
2
|
+
const COUNTRY_WEEK_STARTS_ON = {
|
|
3
|
+
US: 0,
|
|
4
|
+
CA: 0,
|
|
5
|
+
AU: 1,
|
|
6
|
+
NZ: 1,
|
|
7
|
+
SG: 0,
|
|
8
|
+
HK: 0,
|
|
9
|
+
TW: 0,
|
|
10
|
+
CN: 1,
|
|
11
|
+
JP: 0,
|
|
12
|
+
KR: 0,
|
|
13
|
+
MY: 1,
|
|
14
|
+
GB: 1,
|
|
15
|
+
FR: 1,
|
|
16
|
+
IT: 1
|
|
17
|
+
};
|
|
18
|
+
function normalizePageCountryCode(value) {
|
|
19
|
+
const countryCode = String(value !== null && value !== void 0 ? value : "").trim().toUpperCase();
|
|
20
|
+
return /^[A-Z]{2}$/.test(countryCode) ? countryCode : void 0;
|
|
21
|
+
}
|
|
22
|
+
/** Undefined tells Page to preserve its previous locale behaviour. */
|
|
23
|
+
function getPageWeekStartsOn(countryCode) {
|
|
24
|
+
const normalized = normalizePageCountryCode(countryCode);
|
|
25
|
+
return normalized ? COUNTRY_WEEK_STARTS_ON[normalized] : void 0;
|
|
26
|
+
}
|
|
27
|
+
function getPageEnglishAdapterLocale(countryCode) {
|
|
28
|
+
const weekStartsOn = getPageWeekStartsOn(countryCode);
|
|
29
|
+
if (weekStartsOn === void 0) return void 0;
|
|
30
|
+
return weekStartsOn === 1 ? "en-gb" : "en";
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.getPageEnglishAdapterLocale = getPageEnglishAdapterLocale;
|
|
34
|
+
exports.getPageWeekStartsOn = getPageWeekStartsOn;
|
|
35
|
+
exports.normalizePageCountryCode = normalizePageCountryCode;
|
|
@@ -6,15 +6,20 @@ const require_index = require("../config-provider/index.js");
|
|
|
6
6
|
const require_VariablesProvider = require("../dataSourceComponents/provider/variables/VariablesProvider.js");
|
|
7
7
|
const require_index$1 = require("../pisell-config-provider/index.js");
|
|
8
8
|
const require_tokens = require("../../theme/tokens.js");
|
|
9
|
+
const require_dateLocale = require("./dateLocale.js");
|
|
9
10
|
let react = require("react");
|
|
10
11
|
react = require_runtime.__toESM(react);
|
|
11
12
|
let antd = require("antd");
|
|
13
|
+
let dayjs = require("dayjs");
|
|
14
|
+
dayjs = require_runtime.__toESM(dayjs);
|
|
12
15
|
let _pisell_date_picker = require("@pisell/date-picker");
|
|
13
16
|
let antd_es_locale_zh_CN = require("antd/es/locale/zh_CN");
|
|
14
17
|
antd_es_locale_zh_CN = require_runtime.__toESM(antd_es_locale_zh_CN);
|
|
15
18
|
let _pisell_date_picker_es_AdapterDayjs = require("@pisell/date-picker/es/AdapterDayjs");
|
|
16
19
|
let antd_es_locale_en_US = require("antd/es/locale/en_US");
|
|
17
20
|
antd_es_locale_en_US = require_runtime.__toESM(antd_es_locale_en_US);
|
|
21
|
+
let antd_es_locale_en_GB = require("antd/es/locale/en_GB");
|
|
22
|
+
antd_es_locale_en_GB = require_runtime.__toESM(antd_es_locale_en_GB);
|
|
18
23
|
let antd_es_locale_zh_TW = require("antd/es/locale/zh_TW");
|
|
19
24
|
antd_es_locale_zh_TW = require_runtime.__toESM(antd_es_locale_zh_TW);
|
|
20
25
|
let antd_es_locale_zh_HK = require("antd/es/locale/zh_HK");
|
|
@@ -23,15 +28,19 @@ let antd_es_locale_ja_JP = require("antd/es/locale/ja_JP");
|
|
|
23
28
|
antd_es_locale_ja_JP = require_runtime.__toESM(antd_es_locale_ja_JP);
|
|
24
29
|
let antd_es_locale_pt_PT = require("antd/es/locale/pt_PT");
|
|
25
30
|
antd_es_locale_pt_PT = require_runtime.__toESM(antd_es_locale_pt_PT);
|
|
31
|
+
let dayjs_locale_en_gb = require("dayjs/locale/en-gb");
|
|
32
|
+
dayjs_locale_en_gb = require_runtime.__toESM(dayjs_locale_en_gb);
|
|
26
33
|
//#region src/components/page/index.tsx
|
|
27
34
|
const _excluded = [
|
|
28
35
|
"children",
|
|
29
36
|
"style",
|
|
30
37
|
"className",
|
|
31
38
|
"locale",
|
|
39
|
+
"countryCode",
|
|
32
40
|
"variablesConfig",
|
|
33
41
|
"isRenderPisellConfigProvider"
|
|
34
42
|
];
|
|
43
|
+
dayjs.default.locale(dayjs_locale_en_gb.default, void 0, true);
|
|
35
44
|
const localMap = {
|
|
36
45
|
"zh-TW": antd_es_locale_zh_TW.default,
|
|
37
46
|
"zh-CN": antd_es_locale_zh_CN.default,
|
|
@@ -51,11 +60,31 @@ const localeDateMap = {
|
|
|
51
60
|
"pt": { adapterLocale: "pt" }
|
|
52
61
|
};
|
|
53
62
|
const Page = (props) => {
|
|
54
|
-
var _context$appHelper, _context$engine, _localeDateMap, _context$engine2;
|
|
55
|
-
const { children, style, className, locale: propsLocale, variablesConfig, isRenderPisellConfigProvider = true } = props, others = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
|
|
63
|
+
var _context$appHelper, _context$engine, _context$appHelper2, _localeDateMap, _context$engine2;
|
|
64
|
+
const { children, style, className, locale: propsLocale, countryCode: propsCountryCode, variablesConfig, isRenderPisellConfigProvider = true } = props, others = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
|
|
56
65
|
const context = require_useEngineContext.default();
|
|
57
66
|
const { platform, themeColor } = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.constants) || {};
|
|
58
67
|
const locale = propsLocale || (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en";
|
|
68
|
+
const utils = context === null || context === void 0 || (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.utils;
|
|
69
|
+
let countryCode = require_dateLocale.normalizePageCountryCode(propsCountryCode);
|
|
70
|
+
try {
|
|
71
|
+
var _utils$getStore, _utils$getStore$getSt, _utils$store, _utils$store$getState, _utils$getApp, _utils$getApp$getStor, _utils$getApp$getStor2, _hostState$global, _utils$getData, _context$appHelper3, _context$appHelper4, _context$appHelper5;
|
|
72
|
+
const hostState = (utils === null || utils === void 0 || (_utils$getStore = utils.getStore) === null || _utils$getStore === void 0 || (_utils$getStore = _utils$getStore.call(utils)) === null || _utils$getStore === void 0 || (_utils$getStore$getSt = _utils$getStore.getState) === null || _utils$getStore$getSt === void 0 ? void 0 : _utils$getStore$getSt.call(_utils$getStore)) || (utils === null || utils === void 0 || (_utils$store = utils.store) === null || _utils$store === void 0 || (_utils$store$getState = _utils$store.getState) === null || _utils$store$getState === void 0 ? void 0 : _utils$store$getState.call(_utils$store));
|
|
73
|
+
const appCore = utils === null || utils === void 0 || (_utils$getApp = utils.getApp) === null || _utils$getApp === void 0 || (_utils$getApp = _utils$getApp.call(utils)) === null || _utils$getApp === void 0 || (_utils$getApp = _utils$getApp.data) === null || _utils$getApp === void 0 || (_utils$getApp = _utils$getApp.store) === null || _utils$getApp === void 0 || (_utils$getApp$getStor = _utils$getApp.getStore) === null || _utils$getApp$getStor === void 0 || (_utils$getApp$getStor = _utils$getApp$getStor.call(_utils$getApp)) === null || _utils$getApp$getStor === void 0 || (_utils$getApp$getStor2 = _utils$getApp$getStor.getDataByModel) === null || _utils$getApp$getStor2 === void 0 ? void 0 : _utils$getApp$getStor2.call(_utils$getApp$getStor, "core", "core");
|
|
74
|
+
countryCode = [
|
|
75
|
+
countryCode,
|
|
76
|
+
hostState === null || hostState === void 0 || (_hostState$global = hostState.global) === null || _hostState$global === void 0 || (_hostState$global = _hostState$global.shopDetail) === null || _hostState$global === void 0 ? void 0 : _hostState$global.country_code,
|
|
77
|
+
utils === null || utils === void 0 || (_utils$getData = utils.getData) === null || _utils$getData === void 0 || (_utils$getData = _utils$getData.call(utils, "shop_info")) === null || _utils$getData === void 0 ? void 0 : _utils$getData.country_code,
|
|
78
|
+
appCore === null || appCore === void 0 ? void 0 : appCore.country_code,
|
|
79
|
+
context === null || context === void 0 || (_context$appHelper3 = context.appHelper) === null || _context$appHelper3 === void 0 || (_context$appHelper3 = _context$appHelper3.constants) === null || _context$appHelper3 === void 0 ? void 0 : _context$appHelper3.countryCode,
|
|
80
|
+
context === null || context === void 0 || (_context$appHelper4 = context.appHelper) === null || _context$appHelper4 === void 0 || (_context$appHelper4 = _context$appHelper4.constants) === null || _context$appHelper4 === void 0 ? void 0 : _context$appHelper4.country_code,
|
|
81
|
+
context === null || context === void 0 || (_context$appHelper5 = context.appHelper) === null || _context$appHelper5 === void 0 || (_context$appHelper5 = _context$appHelper5.constants) === null || _context$appHelper5 === void 0 ? void 0 : _context$appHelper5.country
|
|
82
|
+
].map(require_dateLocale.normalizePageCountryCode).find((candidate) => candidate !== void 0);
|
|
83
|
+
} catch (_unused) {}
|
|
84
|
+
const englishAdapterLocale = require_dateLocale.getPageEnglishAdapterLocale(countryCode);
|
|
85
|
+
const weekStartsOn = require_dateLocale.getPageWeekStartsOn(countryCode);
|
|
86
|
+
const isEnglish = String(locale).toLowerCase().startsWith("en");
|
|
87
|
+
const antdLocale = isEnglish && weekStartsOn !== void 0 ? weekStartsOn === 1 ? antd_es_locale_en_GB.default : antd_es_locale_en_US.default : localMap[locale];
|
|
59
88
|
const theme = (0, react.useMemo)(() => {
|
|
60
89
|
if (props === null || props === void 0 ? void 0 : props.theme) {
|
|
61
90
|
var _props$theme;
|
|
@@ -72,7 +101,7 @@ const Page = (props) => {
|
|
|
72
101
|
document.body.id = "body";
|
|
73
102
|
}, []);
|
|
74
103
|
return /* @__PURE__ */ react.default.createElement(require_index.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, others), {}, {
|
|
75
|
-
locale:
|
|
104
|
+
locale: antdLocale,
|
|
76
105
|
prefixCls: props.prefixCls || "pisell-lowcode",
|
|
77
106
|
theme
|
|
78
107
|
}), /* @__PURE__ */ react.default.createElement(antd.App, {
|
|
@@ -80,7 +109,7 @@ const Page = (props) => {
|
|
|
80
109
|
message: { maxCount: 1 }
|
|
81
110
|
}, /* @__PURE__ */ react.default.createElement(_pisell_date_picker.LocalizationProvider, {
|
|
82
111
|
dateAdapter: _pisell_date_picker_es_AdapterDayjs.AdapterDayjs,
|
|
83
|
-
adapterLocale: (localeDateMap === null || localeDateMap === void 0 || (_localeDateMap = localeDateMap[locale]) === null || _localeDateMap === void 0 ? void 0 : _localeDateMap.adapterLocale) || "en"
|
|
112
|
+
adapterLocale: isEnglish && englishAdapterLocale || (localeDateMap === null || localeDateMap === void 0 || (_localeDateMap = localeDateMap[locale]) === null || _localeDateMap === void 0 ? void 0 : _localeDateMap.adapterLocale) || "en"
|
|
84
113
|
}, /* @__PURE__ */ react.default.createElement(_pisell_date_picker.ThemeProvider, { theme: datePickerTheme }, /* @__PURE__ */ react.default.createElement(_pisell_date_picker.LocaleProvider, { value: { locale } }, /* @__PURE__ */ react.default.createElement(PisellConfigProvid, { locale }, /* @__PURE__ */ react.default.createElement(require_VariablesProvider.default, {
|
|
85
114
|
variables: ((_context$engine2 = context.engine) === null || _context$engine2 === void 0 || (_context$engine2 = _context$engine2.props) === null || _context$engine2 === void 0 ? void 0 : _context$engine2.variables) || {},
|
|
86
115
|
config: variablesConfig
|
|
@@ -34,7 +34,9 @@ require("./BookingCalendar.less");
|
|
|
34
34
|
*/
|
|
35
35
|
/** 看板日历根组件:内含主题 CSS 与 Spin,按 `view` 挂载月 / 周 / 日子组件 */
|
|
36
36
|
function BookingCalendar(props = {}) {
|
|
37
|
-
var _hourSlots$;
|
|
37
|
+
var _props$weekStartsOn, _hourSlots$;
|
|
38
|
+
const weekStartsOn = (_props$weekStartsOn = props.weekStartsOn) !== null && _props$weekStartsOn !== void 0 ? _props$weekStartsOn : 1;
|
|
39
|
+
const weekdayIds = weekStartsOn === 0 ? require_calendarI18n.SUNDAY_FIRST_CALENDAR_WEEKDAY_IDS : require_calendarI18n.CALENDAR_WEEKDAY_IDS;
|
|
38
40
|
const allowPersist = require_calendarPersistGuard.useCalendarPersist();
|
|
39
41
|
/** 将 `resources` 规范为 `{ id, name, type }`,供分组与三视图共用 */
|
|
40
42
|
const courts = (0, react.useMemo)(() => {
|
|
@@ -99,7 +101,7 @@ function BookingCalendar(props = {}) {
|
|
|
99
101
|
rangeStart = new Date(a.getFullYear(), a.getMonth(), 1);
|
|
100
102
|
rangeEnd = new Date(a.getFullYear(), a.getMonth() + 1, 0);
|
|
101
103
|
} else if (view === "week") {
|
|
102
|
-
rangeStart = require_bookingCalendarDateUtils.startOfWeek(a);
|
|
104
|
+
rangeStart = require_bookingCalendarDateUtils.startOfWeek(a, weekStartsOn);
|
|
103
105
|
rangeEnd = require_bookingCalendarDateUtils.addDays(rangeStart, 6);
|
|
104
106
|
} else {
|
|
105
107
|
rangeStart = new Date(a);
|
|
@@ -114,7 +116,8 @@ function BookingCalendar(props = {}) {
|
|
|
114
116
|
}, [
|
|
115
117
|
view,
|
|
116
118
|
anchorDate,
|
|
117
|
-
props.onViewportChange
|
|
119
|
+
props.onViewportChange,
|
|
120
|
+
weekStartsOn
|
|
118
121
|
]);
|
|
119
122
|
const [selectedFreeSlots, setSelectedFreeSlots] = (0, react.useState)([]);
|
|
120
123
|
const [selectedBlockSlots, setSelectedBlockSlots] = (0, react.useState)([]);
|
|
@@ -177,7 +180,7 @@ function BookingCalendar(props = {}) {
|
|
|
177
180
|
*/
|
|
178
181
|
const { dayRowHeights, overlayBookings, courtDayDisplayLaneCount, hiddenDayOverlayIdSet, dayOverlayOverflowPluses } = require_useBookingCalendarDayOverlayLayout.useBookingCalendarDayOverlayLayout(visibleCourtRows, dayKey, bookings, hourSlots, slotStepHours);
|
|
179
182
|
/** 周视图表头对应的 7 个自然日 */
|
|
180
|
-
const weekDays = (0, react.useMemo)(() => require_bookingCalendarDateUtils.rangeDays(anchorDate), [anchorDate]);
|
|
183
|
+
const weekDays = (0, react.useMemo)(() => require_bookingCalendarDateUtils.rangeDays(anchorDate, weekStartsOn), [anchorDate, weekStartsOn]);
|
|
181
184
|
/** 资源视图:当月每日一列 */
|
|
182
185
|
const resourceMonthDays = (0, react.useMemo)(() => require_bookingCalendarDateUtils.monthCalendarDays(anchorDate), [anchorDate]);
|
|
183
186
|
(0, react.useMemo)(() => new Set(weekDays.map((d) => require_bookingCalendarDateUtils.fmtDate(d))), [weekDays]);
|
|
@@ -213,12 +216,13 @@ function BookingCalendar(props = {}) {
|
|
|
213
216
|
}
|
|
214
217
|
}, [view]);
|
|
215
218
|
/** 月历每格摘要(占用点、锁台等),供月视图渲染 */
|
|
216
|
-
const monthDays = (0, react.useMemo)(() => require_bookingCalendarDateUtils.monthGrid(anchorDate, bookings, courts, hourSlots, slotStepHours), [
|
|
219
|
+
const monthDays = (0, react.useMemo)(() => require_bookingCalendarDateUtils.monthGrid(anchorDate, bookings, courts, hourSlots, slotStepHours, weekStartsOn), [
|
|
217
220
|
anchorDate,
|
|
218
221
|
bookings,
|
|
219
222
|
courts,
|
|
220
223
|
hourSlots,
|
|
221
|
-
slotStepHours
|
|
224
|
+
slotStepHours,
|
|
225
|
+
weekStartsOn
|
|
222
226
|
]);
|
|
223
227
|
/** 日视图内容区总高度(表头 + 各资源行叠加以 overlay 抬高后的高度) */
|
|
224
228
|
const dayContentHeight = 56 + dayRowHeights.reduce((sum, h) => sum + h, 0);
|
|
@@ -612,6 +616,7 @@ function BookingCalendar(props = {}) {
|
|
|
612
616
|
className: "theme-shell soft-shadow mx-0 flex h-full min-h-0 w-full max-w-none flex-1 flex-col overflow-hidden transition-[padding-right] duration-200",
|
|
613
617
|
style: { paddingRight: 0 }
|
|
614
618
|
}, /* @__PURE__ */ react.default.createElement("div", { className: "flex min-h-0 flex-1 flex-col" }, view === "month" && /* @__PURE__ */ react.default.createElement(require_BookingCalendarMonthView.BookingCalendarMonthView, {
|
|
619
|
+
weekdayIds,
|
|
615
620
|
isLight,
|
|
616
621
|
anchorDate,
|
|
617
622
|
monthDays,
|
|
@@ -624,6 +629,7 @@ function BookingCalendar(props = {}) {
|
|
|
624
629
|
renderMonthWeekBooking: props.renderMonthWeekBooking,
|
|
625
630
|
tickFillMode: require_bookingCalendarAxis.resolveTickFillMode("month", props.tickFillMode)
|
|
626
631
|
}), view === "week" && /* @__PURE__ */ react.default.createElement(require_BookingCalendarWeekView.BookingCalendarWeekView, {
|
|
632
|
+
weekdayIds,
|
|
627
633
|
calendarProps: props,
|
|
628
634
|
isLight,
|
|
629
635
|
weekDays,
|
|
@@ -18,6 +18,8 @@ const CALENDAR_WEEKDAY_IDS = [
|
|
|
18
18
|
"pisell2.recordBoard.calendar.weekday.sat",
|
|
19
19
|
"pisell2.recordBoard.calendar.weekday.sun"
|
|
20
20
|
];
|
|
21
|
+
const SUNDAY_FIRST_CALENDAR_WEEKDAY_IDS = [CALENDAR_WEEKDAY_IDS[6], ...CALENDAR_WEEKDAY_IDS.slice(0, 6)];
|
|
21
22
|
//#endregion
|
|
22
23
|
exports.CALENDAR_WEEKDAY_IDS = CALENDAR_WEEKDAY_IDS;
|
|
24
|
+
exports.SUNDAY_FIRST_CALENDAR_WEEKDAY_IDS = SUNDAY_FIRST_CALENDAR_WEEKDAY_IDS;
|
|
23
25
|
exports.tCal = tCal;
|
package/lib/components/pisellRecordBoard/shellFrame/Calendar/utils/bookingCalendarDateUtils.js
CHANGED
|
@@ -26,16 +26,16 @@ function addDays(date, n) {
|
|
|
26
26
|
next.setDate(next.getDate() + n);
|
|
27
27
|
return next;
|
|
28
28
|
}
|
|
29
|
-
function startOfWeek(date) {
|
|
29
|
+
function startOfWeek(date, weekStartsOn = 1) {
|
|
30
30
|
const d = new Date(date);
|
|
31
31
|
const day = d.getDay();
|
|
32
|
-
const diff = day === 0 ? -6 : 1 - day;
|
|
32
|
+
const diff = weekStartsOn === 0 ? -day : day === 0 ? -6 : 1 - day;
|
|
33
33
|
d.setDate(d.getDate() + diff);
|
|
34
34
|
d.setHours(0, 0, 0, 0);
|
|
35
35
|
return d;
|
|
36
36
|
}
|
|
37
|
-
function rangeDays(anchor) {
|
|
38
|
-
const start = startOfWeek(anchor);
|
|
37
|
+
function rangeDays(anchor, weekStartsOn = 1) {
|
|
38
|
+
const start = startOfWeek(anchor, weekStartsOn);
|
|
39
39
|
return Array.from({ length: 7 }, (_, i) => addDays(start, i));
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
@@ -69,11 +69,11 @@ function formatShortMonthDay(dateKey) {
|
|
|
69
69
|
if (!m || !d) return dateKey;
|
|
70
70
|
return `${m}/${d}`;
|
|
71
71
|
}
|
|
72
|
-
function monthGrid(date, bookings, courtsList = [], hourSlotsIn, slotStepHours = 1) {
|
|
72
|
+
function monthGrid(date, bookings, courtsList = [], hourSlotsIn, slotStepHours = 1, weekStartsOn = 1) {
|
|
73
73
|
const hourSlots = hourSlotsIn && hourSlotsIn.length ? hourSlotsIn : require_index.buildCalendarTimelineSlotStartsFromRange(require_bookingCalendarConstants.DEFAULT_CALENDAR_TIMELINE, date, 60);
|
|
74
74
|
const year = date.getFullYear();
|
|
75
75
|
const month = date.getMonth();
|
|
76
|
-
const start = startOfWeek(new Date(year, month, 1));
|
|
76
|
+
const start = startOfWeek(new Date(year, month, 1), weekStartsOn);
|
|
77
77
|
return Array.from({ length: 35 }, (_, i) => addDays(start, i)).map((day) => {
|
|
78
78
|
const key = fmtDate(day);
|
|
79
79
|
const dayBookings = bookings.filter((b) => b.kind === "booking" && getBookingSegmentForDate(b, key) != null);
|
package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarMonthView.js
CHANGED
|
@@ -17,7 +17,7 @@ const MONTH_GRID_COLS = 7;
|
|
|
17
17
|
* - 行高内自适应 effectiveMaxLane,超出 → cell 级 `+N` tile;
|
|
18
18
|
* - cell 层只负责日期 header / 点击跳日 / drop 改期,不再渲染 booking 列表(被 overlay 替代)。
|
|
19
19
|
*/
|
|
20
|
-
function BookingCalendarMonthView({ isLight, anchorDate, monthDays, bookings, goToDayFromCell, handleGridDropMove, setDraggingItem, openBookingDetail, setOverflowListModal, renderMonthWeekBooking, tickFillMode }) {
|
|
20
|
+
function BookingCalendarMonthView({ weekdayIds, isLight, anchorDate, monthDays, bookings, goToDayFromCell, handleGridDropMove, setDraggingItem, openBookingDetail, setOverflowListModal, renderMonthWeekBooking, tickFillMode }) {
|
|
21
21
|
const todayKey = require_bookingCalendarDateUtils.fmtDate(/* @__PURE__ */ new Date());
|
|
22
22
|
const weekRows = (0, react.useMemo)(() => {
|
|
23
23
|
const out = [];
|
|
@@ -50,7 +50,7 @@ function BookingCalendarMonthView({ isLight, anchorDate, monthDays, bookings, go
|
|
|
50
50
|
return /* @__PURE__ */ react.default.createElement("div", {
|
|
51
51
|
key: `month-${anchorDate.getFullYear()}-${anchorDate.getMonth()}`,
|
|
52
52
|
className: "flex min-h-0 flex-1 flex-col"
|
|
53
|
-
}, /* @__PURE__ */ react.default.createElement("div", { className: "relative flex min-h-0 flex-1 flex-col overflow-hidden" }, /* @__PURE__ */ react.default.createElement("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-auto overflow-y-hidden" }, /* @__PURE__ */ react.default.createElement("div", { className: "theme-panel flex min-h-[0] min-w-[980px] flex-1 flex-col overflow-hidden" }, /* @__PURE__ */ react.default.createElement("div", { className: "theme-panel-alt grid shrink-0 grid-cols-7 border-b theme-border shadow-[0_6px_12px_rgba(0,0,0,0.08)]" },
|
|
53
|
+
}, /* @__PURE__ */ react.default.createElement("div", { className: "relative flex min-h-0 flex-1 flex-col overflow-hidden" }, /* @__PURE__ */ react.default.createElement("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-auto overflow-y-hidden" }, /* @__PURE__ */ react.default.createElement("div", { className: "theme-panel flex min-h-[0] min-w-[980px] flex-1 flex-col overflow-hidden" }, /* @__PURE__ */ react.default.createElement("div", { className: "theme-panel-alt grid shrink-0 grid-cols-7 border-b theme-border shadow-[0_6px_12px_rgba(0,0,0,0.08)]" }, weekdayIds.map((id) => /* @__PURE__ */ react.default.createElement("div", {
|
|
54
54
|
key: id,
|
|
55
55
|
className: "px-4 py-2.5 text-center text-sm font-medium"
|
|
56
56
|
}, require_calendarI18n.tCal(id)))), /* @__PURE__ */ react.default.createElement("div", {
|
package/lib/components/pisellRecordBoard/shellFrame/Calendar/view/BookingCalendarWeekView.js
CHANGED
|
@@ -15,7 +15,7 @@ const WEEK_VIEW_OVERLAY_LANE_GAP = 4;
|
|
|
15
15
|
/**
|
|
16
16
|
* 周视图:7 日网格 + 左侧分组(可折叠),单元格调起日视图;格内 drop 触发改期草稿。
|
|
17
17
|
*/
|
|
18
|
-
function BookingCalendarWeekView({ calendarProps, isLight, weekDays, bookings, courts, hourSlots, slotStepHours, visibleCourts, visibleCourtRows, isBusinessHour, goToDayFromCell, handleGridDropMove, openBookingDetail, setDraggingItem, setCollapsedGroups, setOverflowListModal, tickFillMode }) {
|
|
18
|
+
function BookingCalendarWeekView({ weekdayIds, calendarProps, isLight, weekDays, bookings, courts, hourSlots, slotStepHours, visibleCourts, visibleCourtRows, isBusinessHour, goToDayFromCell, handleGridDropMove, openBookingDetail, setDraggingItem, setCollapsedGroups, setOverflowListModal, tickFillMode }) {
|
|
19
19
|
const props = calendarProps;
|
|
20
20
|
const todayKey = require_bookingCalendarDateUtils.fmtDate(/* @__PURE__ */ new Date());
|
|
21
21
|
/** 与下方 grid `minmax(…px, 1fr)` 一致:窄屏由外层 overflow-auto + min-w-0 定视口宽,本值撑开 scrollWidth */
|
|
@@ -144,7 +144,7 @@ function BookingCalendarWeekView({ calendarProps, isLight, weekDays, bookings, c
|
|
|
144
144
|
return /* @__PURE__ */ react.default.createElement("div", {
|
|
145
145
|
key,
|
|
146
146
|
className: `relative z-20 border-b border-l px-1.5 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]"}`
|
|
147
|
-
}, /* @__PURE__ */ react.default.createElement("div", { className: `text-sm leading-tight ${isLight ? "theme-text-faint" : "text-zinc-400"}` }, require_calendarI18n.tCal(
|
|
147
|
+
}, /* @__PURE__ */ react.default.createElement("div", { className: `text-sm leading-tight ${isLight ? "theme-text-faint" : "text-zinc-400"}` }, require_calendarI18n.tCal(weekdayIds[i])), /* @__PURE__ */ react.default.createElement("div", { className: "mt-0.5 flex justify-center" }, /* @__PURE__ */ react.default.createElement("span", {
|
|
148
148
|
className: "grid h-10 w-10 place-items-center text-3xl font-semibold leading-none",
|
|
149
149
|
"aria-label": isToday ? "Today" : void 0
|
|
150
150
|
}, day.getDate())));
|
|
@@ -329,6 +329,8 @@ interface RecordBoardBlockedTimePanelPayload {
|
|
|
329
329
|
}
|
|
330
330
|
/** 日历视图槽位 props:由 Shell 合并根级与子槽后传入 PisellRecordBoardCalendarView */
|
|
331
331
|
interface RecordBoardCalendarProps {
|
|
332
|
+
/** 0 = Sunday, 1 = Monday. Omitted keeps the original Monday-first behaviour. */
|
|
333
|
+
weekStartsOn?: 0 | 1;
|
|
332
334
|
persistGuard?: CalendarPersistContextValue;
|
|
333
335
|
/**
|
|
334
336
|
* 日历画布外观:亮色切换 `theme-root.theme-light`;未传或 `dark` 为深色(默认)。
|