@g9tm/lynxcontrols-calendar 2.5.7 → 2.5.9
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/catalog/cards/G9AgendaView.md +4 -1
- package/catalog/cards/G9BirthdayField.md +14 -0
- package/catalog/cards/G9DateInput.md +3 -2
- package/catalog/cards/G9EventCard.md +17 -0
- package/catalog/cards/G9FindTime.md +16 -0
- package/catalog/cards/G9MiniMonth.md +2 -2
- package/catalog/cards/G9MonthView.md +6 -4
- package/catalog/cards/G9RepeatPicker.md +5 -1
- package/catalog/cards/G9TimeGrid.md +6 -6
- package/catalog/cards/G9TimeListPicker.md +17 -0
- package/catalog/cards/G9TodayWidget.md +16 -0
- package/catalog/cards/G9WorkingHoursEditor.md +16 -0
- package/catalog/catalog.json +3495 -564
- package/catalog/index.md +11 -5
- package/dist/.tsbuildinfo +1 -1
- package/dist/calendar.css +798 -2
- package/dist/calendar.css.map +1 -1
- package/dist/calendar.d.ts +83 -48
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.jsx +144 -254
- package/dist/cards.d.ts +131 -0
- package/dist/cards.d.ts.map +1 -0
- package/dist/cards.jsx +252 -0
- package/dist/events.d.ts +45 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.jsx +83 -0
- package/dist/gesture.d.ts +79 -0
- package/dist/gesture.d.ts.map +1 -0
- package/dist/gesture.jsx +160 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.jsx +10 -1
- package/dist/model.d.ts +9 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.jsx +33 -4
- package/dist/month-view.d.ts +50 -0
- package/dist/month-view.d.ts.map +1 -0
- package/dist/month-view.jsx +362 -0
- package/dist/people.d.ts +67 -0
- package/dist/people.d.ts.map +1 -0
- package/dist/people.jsx +211 -0
- package/dist/recurrence.d.ts +51 -0
- package/dist/recurrence.d.ts.map +1 -0
- package/dist/recurrence.jsx +280 -0
- package/dist/repeat-picker.d.ts +47 -0
- package/dist/repeat-picker.d.ts.map +1 -0
- package/dist/repeat-picker.jsx +289 -0
- package/dist/time-grid.d.ts +50 -0
- package/dist/time-grid.d.ts.map +1 -0
- package/dist/time-grid.jsx +639 -0
- package/dist/time-list.d.ts +25 -0
- package/dist/time-list.d.ts.map +1 -0
- package/dist/time-list.jsx +85 -0
- package/package.json +3 -3
package/dist/index.jsx
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
export * from "./events.jsx";
|
|
2
|
+
export * from "./gesture.jsx";
|
|
1
3
|
export * from "./model.jsx";
|
|
2
|
-
export
|
|
4
|
+
export * from "./recurrence.jsx";
|
|
5
|
+
export { G9AgendaView, G9DateInput, G9MiniMonth, agendaRows } from "./calendar.jsx";
|
|
6
|
+
export { G9EventCard, G9FindTime, G9TodayWidget, findCommonSlots } from "./cards.jsx";
|
|
3
7
|
export { G9MonthDayPicker, monthDayLength } from "./month-day.jsx";
|
|
8
|
+
export { G9MonthView } from "./month-view.jsx";
|
|
9
|
+
export { G9BirthdayField, G9WorkingHoursEditor, birthdayFrom, birthdayIn } from "./people.jsx";
|
|
10
|
+
export { G9RepeatPicker } from "./repeat-picker.jsx";
|
|
11
|
+
export { G9TimeGrid } from "./time-grid.jsx";
|
|
12
|
+
export { G9TimeListPicker, timeLabel, timeSteps } from "./time-list.jsx";
|
|
4
13
|
export { G9ZonePicker, zoneLabel, zoneOffsetLabel } from "./zone-picker.jsx";
|
package/dist/model.d.ts
CHANGED
|
@@ -28,7 +28,16 @@ export interface G9Recurrence {
|
|
|
28
28
|
readonly weekdays?: readonly number[];
|
|
29
29
|
readonly until?: G9LocalDate;
|
|
30
30
|
readonly count?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Monthly / yearly on a weekday instead of a date: the start's weekday, the 1st–4th of the month or -1 the last
|
|
33
|
+
* («the second Saturday», «the last Friday»; 2.5.8).
|
|
34
|
+
*/
|
|
35
|
+
readonly weekOfMonth?: 1 | 2 | 3 | 4 | -1;
|
|
36
|
+
/** The calendar monthly and yearly rules count in. Default the `calendar` argument of {@link occurrences}. */
|
|
37
|
+
readonly calendar?: G9CalendarSystem;
|
|
31
38
|
}
|
|
39
|
+
/** The day of `weekday` that is the `nth` (1–4, -1 last) of its kind in a month of `calendar`, or null. */
|
|
40
|
+
export declare function nthWeekdayOfMonth(calendar: G9CalendarSystem, year: number, month: number, weekday: number, nth: 1 | 2 | 3 | 4 | -1): G9LocalDate | null;
|
|
32
41
|
/**
|
|
33
42
|
* The occurrences of a recurrence that start on or after `from` and on or before `to`, in the event's calendar
|
|
34
43
|
* (a monthly event on the 31st skips shorter months, as calendars do). At most 1000 are produced.
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAGjB,MAAM,+BAA+B,CAAC;AAEvC,2FAA2F;AAC3F,eAAO,MAAM,YAAY,GAAI,UAAU,gBAAgB,EAAE,UAAU,MAAM,KAAG,MACC,CAAC;AAE9E,gCAAgC;AAChC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CACvB,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,UAAQ,GAChB,SAAS,EAAE,EAAE,CAuBf;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CACxB,IAAI,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(a, b)=>0 === compareLocal(a, b);
|
|
40
|
+
function nthWeekdayOfMonth(calendar, year, month, weekday, nth) {
|
|
41
|
+
const length = daysInMonth(calendar, year, month);
|
|
42
|
+
if (-1 === nth) {
|
|
43
|
+
const last = fromCalendarDate({
|
|
44
|
+
calendar,
|
|
45
|
+
year,
|
|
46
|
+
month,
|
|
47
|
+
day: length
|
|
48
|
+
});
|
|
49
|
+
return addDays(last, -((dayOfWeek(last) - weekday + 7) % 7));
|
|
50
|
+
}
|
|
51
|
+
const first = fromCalendarDate({
|
|
52
|
+
calendar,
|
|
53
|
+
year,
|
|
54
|
+
month,
|
|
55
|
+
day: 1
|
|
56
|
+
});
|
|
57
|
+
const day = 1 + (weekday - dayOfWeek(first) + 7) % 7 + (nth - 1) * 7;
|
|
58
|
+
return day <= length ? addDays(first, day - 1) : null;
|
|
59
|
+
}
|
|
40
60
|
function occurrences(start, rule, from, to, calendar = 'gregorian') {
|
|
41
61
|
var _rule_interval;
|
|
42
62
|
const interval = Math.max(1, null != (_rule_interval = rule.interval) ? _rule_interval : 1);
|
|
@@ -61,15 +81,24 @@ function occurrences(start, rule, from, to, calendar = 'gregorian') {
|
|
|
61
81
|
const weekOf = addDays(start, -dayOfWeek(start));
|
|
62
82
|
outer: for(let w = 0; w < 5200; w += interval)for (const wd of days)if (!take(addDays(weekOf, 7 * w + wd))) break outer;
|
|
63
83
|
} else {
|
|
64
|
-
|
|
84
|
+
var _rule_calendar;
|
|
85
|
+
const cal = null != (_rule_calendar = rule.calendar) ? _rule_calendar : calendar;
|
|
86
|
+
const c0 = toCalendarDate(start, cal);
|
|
87
|
+
const weekday = dayOfWeek(start);
|
|
65
88
|
for(let k = 0; k < 12000; k += interval){
|
|
66
89
|
const m = 'monthly' === rule.freq ? shiftMonth(c0.year, c0.month, k) : {
|
|
67
90
|
year: c0.year + k,
|
|
68
91
|
month: c0.month
|
|
69
92
|
};
|
|
70
|
-
if (
|
|
93
|
+
if (void 0 !== rule.weekOfMonth) {
|
|
94
|
+
const d = nthWeekdayOfMonth(cal, m.year, m.month, weekday, rule.weekOfMonth);
|
|
95
|
+
if (!d) continue;
|
|
96
|
+
if (!take(d)) break;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (!(c0.day > daysInMonth(cal, m.year, m.month))) {
|
|
71
100
|
if (!take(fromCalendarDate({
|
|
72
|
-
calendar,
|
|
101
|
+
calendar: cal,
|
|
73
102
|
year: m.year,
|
|
74
103
|
month: m.month,
|
|
75
104
|
day: c0.day
|
|
@@ -134,4 +163,4 @@ function slotAt(offsetY, hourHeight, fromHour, toHour) {
|
|
|
134
163
|
const quarters = Math.floor(offsetY / hourHeight * 4);
|
|
135
164
|
return Math.min(60 * toHour - 15, Math.max(60 * fromHour, 60 * fromHour + 15 * quarters));
|
|
136
165
|
}
|
|
137
|
-
export { agenda, layoutDay, monthGrid, occurrences, sameDay, shiftMonth, slotAt, weekStartFor };
|
|
166
|
+
export { agenda, layoutDay, monthGrid, nthWeekdayOfMonth, occurrences, sameDay, shiftMonth, slotAt, weekStartFor };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type G9LocalDate } from '@g9tm/lynxcontrols-foundation';
|
|
2
|
+
import { type ReactNode } from '@lynx-js/react';
|
|
3
|
+
import type { G9CalendarEvent } from './calendar.js';
|
|
4
|
+
/** What a drag or a tap on an empty day asks for (the app opens its editor with it). */
|
|
5
|
+
export type G9MonthDraft = {
|
|
6
|
+
readonly allDay: true;
|
|
7
|
+
readonly date: G9LocalDate;
|
|
8
|
+
readonly endDate: G9LocalDate;
|
|
9
|
+
} | {
|
|
10
|
+
readonly allDay: false;
|
|
11
|
+
readonly date: G9LocalDate;
|
|
12
|
+
readonly start: number;
|
|
13
|
+
readonly end: number;
|
|
14
|
+
};
|
|
15
|
+
/** Props of {@link G9MonthView}. */
|
|
16
|
+
export interface G9MonthViewProps {
|
|
17
|
+
readonly id?: string;
|
|
18
|
+
readonly today: G9LocalDate;
|
|
19
|
+
/** Any day of the month shown. */
|
|
20
|
+
readonly month: G9LocalDate;
|
|
21
|
+
readonly events: readonly G9CalendarEvent[];
|
|
22
|
+
/** A tap on a day (compact: it selects; wide: the app decides — default a new event there with `onCreate`). */
|
|
23
|
+
readonly onSelectDay?: (date: G9LocalDate) => void;
|
|
24
|
+
readonly onSelectEvent?: (event: G9CalendarEvent) => void;
|
|
25
|
+
/** Lanes drawn per day before «+n». Default: as many as the row's height holds. */
|
|
26
|
+
readonly perDay?: number;
|
|
27
|
+
/** A phone's month: dots, the selected day ringed; the day's list is the app's (2.5.8). */
|
|
28
|
+
readonly compact?: boolean;
|
|
29
|
+
readonly selected?: G9LocalDate | null;
|
|
30
|
+
/** Days off (a holiday that is one, the app's own). Holidays that are days off count by themselves. */
|
|
31
|
+
readonly dayOff?: (date: G9LocalDate) => boolean;
|
|
32
|
+
/** Weekend weekdays (0 Sunday … 6 Saturday), shaded and their numbers red. Default Friday in Persian, else Sat–Sun. */
|
|
33
|
+
readonly weekend?: readonly number[];
|
|
34
|
+
/** The other calendar's date beside each number (`'auto'`: Gregorian under Persian and back). Default `'none'`. */
|
|
35
|
+
readonly secondCalendar?: 'auto' | 'none' | 'persian' | 'gregorian';
|
|
36
|
+
/** A tap on the day's number (the day view). Default `onSelectDay`. */
|
|
37
|
+
readonly onOpenDay?: (date: G9LocalDate) => void;
|
|
38
|
+
/** A new event: a tap on an empty day (09:00–10:00), a mouse drag across days (all day). */
|
|
39
|
+
readonly onCreate?: (draft: G9MonthDraft) => void;
|
|
40
|
+
/** An event (`canEdit`) dragged to another day: its new first and last day. */
|
|
41
|
+
readonly onMove?: (event: G9CalendarEvent, change: {
|
|
42
|
+
readonly date: G9LocalDate;
|
|
43
|
+
readonly endDate: G9LocalDate;
|
|
44
|
+
}) => void;
|
|
45
|
+
/** «+n» in the app's words. Default `+n`. */
|
|
46
|
+
readonly moreText?: (n: number) => string;
|
|
47
|
+
}
|
|
48
|
+
/** The month with lanes of events, holidays, days off and a mouse drag (wide), or dots and a selected day (compact). */
|
|
49
|
+
export declare function G9MonthView(props: G9MonthViewProps): ReactNode;
|
|
50
|
+
//# sourceMappingURL=month-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"month-view.d.ts","sourceRoot":"","sources":["../src/month-view.tsx"],"names":[],"mappings":"AAOA,OAAO,EAKL,KAAK,WAAW,EAKjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,SAAS,EAAuD,MAAM,gBAAgB,CAAC;AAErG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,wFAAwF;AACxF,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GACpF;IAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzG,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C,+GAA+G;IAC/G,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1D,mFAAmF;IACnF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,uGAAuG;IACvG,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;IACjD,uHAAuH;IACvH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,mHAAmH;IACnH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC;IACpE,uEAAuE;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACjD,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAClD,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,CAChB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;KAAE,KAClE,IAAI,CAAC;IACV,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3C;AA6CD,wHAAwH;AACxH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CA2T9D"}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { g9IdProps } from "@g9tm/lynxcontrols/base";
|
|
2
|
+
import { useG9Culture, useG9Direction } from "@g9tm/lynxcontrols/provider";
|
|
3
|
+
import { addDays, compareLocal, formatLocalDateTime, formatNumber, g9Haptic, getWeekdayNames, toCalendarDate, toEpochDays } from "@g9tm/lynxcontrols-foundation";
|
|
4
|
+
import { runOnBackground, useMainThreadRef, useRef, useState } from "@lynx-js/react";
|
|
5
|
+
import { eventLastDay, eventTouches, isBarEvent, secondDateLabel, weekSegments } from "./events.jsx";
|
|
6
|
+
import { monthGrid, sameDay, weekStartFor } from "./model.jsx";
|
|
7
|
+
const LANE = 20;
|
|
8
|
+
const HEADER = 24;
|
|
9
|
+
const IDLE = {
|
|
10
|
+
phase: 'idle',
|
|
11
|
+
stamp: -1,
|
|
12
|
+
eventId: null,
|
|
13
|
+
from: -1,
|
|
14
|
+
target: -1,
|
|
15
|
+
x0: 0,
|
|
16
|
+
y0: 0,
|
|
17
|
+
rect: null,
|
|
18
|
+
token: 0
|
|
19
|
+
};
|
|
20
|
+
function cellAtMT(x, y, rect, rows, rtl) {
|
|
21
|
+
'main thread';
|
|
22
|
+
if (rect.height <= 0 || rect.width <= 0 || rows <= 0 || y < rect.top || y > rect.top + rect.height) return -1;
|
|
23
|
+
const row = Math.min(rows - 1, Math.floor((y - rect.top) / rect.height * rows));
|
|
24
|
+
let f = rtl ? (rect.left + rect.width - x) / rect.width : (x - rect.left) / rect.width;
|
|
25
|
+
f = Math.min(0.9999, Math.max(0, f));
|
|
26
|
+
return 7 * row + Math.floor(7 * f);
|
|
27
|
+
}
|
|
28
|
+
function G9MonthView(props) {
|
|
29
|
+
var _props_weekend, _props_secondCalendar, _props_perDay, _props_moreText;
|
|
30
|
+
const culture = useG9Culture();
|
|
31
|
+
const rtl = 'rtl' === useG9Direction();
|
|
32
|
+
const calendar = culture.calendar;
|
|
33
|
+
const weekStart = weekStartFor(calendar, culture.language);
|
|
34
|
+
const num = (n)=>formatNumber(n, {
|
|
35
|
+
numberingSystem: culture.numberingSystem,
|
|
36
|
+
useGrouping: false
|
|
37
|
+
});
|
|
38
|
+
const names = getWeekdayNames(culture, 'abbreviated');
|
|
39
|
+
const initial = (wd)=>{
|
|
40
|
+
var _names_wd;
|
|
41
|
+
const name = null != (_names_wd = names[wd]) ? _names_wd : '';
|
|
42
|
+
return 'fa' === culture.language ? name.charAt(0) : name.slice(0, 2);
|
|
43
|
+
};
|
|
44
|
+
const m = toCalendarDate(props.month, calendar);
|
|
45
|
+
const weeks = monthGrid(calendar, m.year, m.month, weekStart);
|
|
46
|
+
const weekend = null != (_props_weekend = props.weekend) ? _props_weekend : 'fa' === culture.language ? [
|
|
47
|
+
5
|
|
48
|
+
] : [
|
|
49
|
+
0,
|
|
50
|
+
6
|
|
51
|
+
];
|
|
52
|
+
const second = 'auto' === props.secondCalendar ? 'persian' === calendar ? 'gregorian' : 'persian' : null != (_props_secondCalendar = props.secondCalendar) ? _props_secondCalendar : 'none';
|
|
53
|
+
const compact = true === props.compact;
|
|
54
|
+
const [rowHeight, setRowHeight] = useState(null);
|
|
55
|
+
const lanesFit = null != (_props_perDay = props.perDay) ? _props_perDay : null === rowHeight ? 2 : Math.max(1, Math.floor((rowHeight - HEADER - 18) / LANE));
|
|
56
|
+
const holidays = props.events.filter((e)=>'holiday' === e.kind);
|
|
57
|
+
const others = props.events.filter((e)=>'holiday' !== e.kind);
|
|
58
|
+
const holidaysOn = (d)=>holidays.filter((e)=>eventTouches(e, d));
|
|
59
|
+
const off = (d)=>{
|
|
60
|
+
var _props_dayOff;
|
|
61
|
+
return (null == (_props_dayOff = props.dayOff) ? void 0 : _props_dayOff.call(props, d)) === true || holidaysOn(d).some((e)=>false !== e.dayOff);
|
|
62
|
+
};
|
|
63
|
+
const more = null != (_props_moreText = props.moreText) ? _props_moreText : (n)=>`+${num(n)}`;
|
|
64
|
+
const row = {
|
|
65
|
+
flexDirection: rtl ? 'row-reverse' : 'row',
|
|
66
|
+
direction: 'ltr'
|
|
67
|
+
};
|
|
68
|
+
const flat = weeks.flat().map((c)=>c.date);
|
|
69
|
+
const [drop, setDrop] = useState(null);
|
|
70
|
+
const suppressUntil = useRef(0);
|
|
71
|
+
const latest = useRef({
|
|
72
|
+
flat,
|
|
73
|
+
events: props.events,
|
|
74
|
+
onCreate: props.onCreate,
|
|
75
|
+
onMove: props.onMove
|
|
76
|
+
});
|
|
77
|
+
latest.current = {
|
|
78
|
+
flat,
|
|
79
|
+
events: props.events,
|
|
80
|
+
onCreate: props.onCreate,
|
|
81
|
+
onMove: props.onMove
|
|
82
|
+
};
|
|
83
|
+
const dropTarget = (from, to, eventId)=>setDrop({
|
|
84
|
+
from,
|
|
85
|
+
to,
|
|
86
|
+
eventId
|
|
87
|
+
});
|
|
88
|
+
const dropped = (from, to, eventId)=>{
|
|
89
|
+
var _latest_current_onMove, _latest_current;
|
|
90
|
+
setDrop(null);
|
|
91
|
+
suppressUntil.current = Date.now() + 120;
|
|
92
|
+
const days = latest.current.flat;
|
|
93
|
+
const a = days[from];
|
|
94
|
+
const b = days[to];
|
|
95
|
+
if (!a || !b) return;
|
|
96
|
+
if (!eventId) {
|
|
97
|
+
var _latest_current_onCreate, _latest_current1;
|
|
98
|
+
const [first, last] = compareLocal(a, b) <= 0 ? [
|
|
99
|
+
a,
|
|
100
|
+
b
|
|
101
|
+
] : [
|
|
102
|
+
b,
|
|
103
|
+
a
|
|
104
|
+
];
|
|
105
|
+
null == (_latest_current_onCreate = (_latest_current1 = latest.current).onCreate) || _latest_current_onCreate.call(_latest_current1, {
|
|
106
|
+
allDay: true,
|
|
107
|
+
date: first,
|
|
108
|
+
endDate: last
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const shift = toEpochDays(b) - toEpochDays(a);
|
|
113
|
+
const e = latest.current.events.find((x)=>x.id === eventId);
|
|
114
|
+
if (0 === shift || !e) return;
|
|
115
|
+
null == (_latest_current_onMove = (_latest_current = latest.current).onMove) || _latest_current_onMove.call(_latest_current, e, {
|
|
116
|
+
date: addDays(e.date, shift),
|
|
117
|
+
endDate: addDays(eventLastDay(e), shift)
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const cancelled = ()=>setDrop(null);
|
|
121
|
+
const started = ()=>g9Haptic('select');
|
|
122
|
+
const drag = useMainThreadRef({
|
|
123
|
+
...IDLE
|
|
124
|
+
});
|
|
125
|
+
const gridRef = useMainThreadRef(null);
|
|
126
|
+
const rows = weeks.length;
|
|
127
|
+
const dragging = !compact && (void 0 !== props.onCreate || void 0 !== props.onMove);
|
|
128
|
+
function begin(event, eventId, editable) {
|
|
129
|
+
'main thread';
|
|
130
|
+
var _gridRef_current;
|
|
131
|
+
const state = drag.current;
|
|
132
|
+
if (0 !== event.button) return;
|
|
133
|
+
if (state.stamp === event.timestamp && 'idle' !== state.phase) return;
|
|
134
|
+
if (eventId && !editable) {
|
|
135
|
+
drag.current = {
|
|
136
|
+
...IDLE,
|
|
137
|
+
phase: 'ignored',
|
|
138
|
+
stamp: event.timestamp,
|
|
139
|
+
token: state.token
|
|
140
|
+
};
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const token = state.token + 1;
|
|
144
|
+
drag.current = {
|
|
145
|
+
...IDLE,
|
|
146
|
+
phase: 'pending',
|
|
147
|
+
stamp: event.timestamp,
|
|
148
|
+
eventId,
|
|
149
|
+
x0: event.pageX,
|
|
150
|
+
y0: event.pageY,
|
|
151
|
+
token
|
|
152
|
+
};
|
|
153
|
+
null == (_gridRef_current = gridRef.current) || _gridRef_current.invoke('boundingClientRect', {}).then((r)=>{
|
|
154
|
+
const now = drag.current;
|
|
155
|
+
if (now.token !== token || !r) return;
|
|
156
|
+
now.rect = {
|
|
157
|
+
left: r.left,
|
|
158
|
+
top: r.top,
|
|
159
|
+
width: r.width,
|
|
160
|
+
height: r.height
|
|
161
|
+
};
|
|
162
|
+
now.from = cellAtMT(now.x0, now.y0, now.rect, rows, rtl);
|
|
163
|
+
}, ()=>void 0);
|
|
164
|
+
}
|
|
165
|
+
function rowDown(event) {
|
|
166
|
+
'main thread';
|
|
167
|
+
begin(event, null, true);
|
|
168
|
+
}
|
|
169
|
+
function ignore(event) {
|
|
170
|
+
'main thread';
|
|
171
|
+
drag.current = {
|
|
172
|
+
...drag.current,
|
|
173
|
+
phase: 'ignored',
|
|
174
|
+
stamp: event.timestamp
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function move(event) {
|
|
178
|
+
'main thread';
|
|
179
|
+
const s = drag.current;
|
|
180
|
+
if ('pending' !== s.phase && 'drag' !== s.phase) return;
|
|
181
|
+
if ('pending' === s.phase) {
|
|
182
|
+
if (Math.hypot(event.pageX - s.x0, event.pageY - s.y0) < 5 || !s.rect || s.from < 0) return;
|
|
183
|
+
s.phase = 'drag';
|
|
184
|
+
runOnBackground(started)();
|
|
185
|
+
}
|
|
186
|
+
if (!s.rect) return;
|
|
187
|
+
const target = cellAtMT(event.pageX, event.pageY, s.rect, rows, rtl);
|
|
188
|
+
if (target !== s.target) {
|
|
189
|
+
s.target = target;
|
|
190
|
+
if (target >= 0) runOnBackground(dropTarget)(s.from, target, s.eventId);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function up() {
|
|
194
|
+
'main thread';
|
|
195
|
+
const s = drag.current;
|
|
196
|
+
if ('drag' === s.phase) if (s.target >= 0) runOnBackground(dropped)(s.from, s.target, s.eventId);
|
|
197
|
+
else runOnBackground(cancelled)();
|
|
198
|
+
drag.current = {
|
|
199
|
+
...IDLE,
|
|
200
|
+
stamp: s.stamp,
|
|
201
|
+
token: s.token
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const tapAllowed = ()=>Date.now() > suppressUntil.current;
|
|
205
|
+
const preview = (d)=>{
|
|
206
|
+
if (!drop) return false;
|
|
207
|
+
const a = flat[drop.from];
|
|
208
|
+
const b = flat[drop.to];
|
|
209
|
+
if (!a || !b) return false;
|
|
210
|
+
if (!drop.eventId) {
|
|
211
|
+
const [first, last] = compareLocal(a, b) <= 0 ? [
|
|
212
|
+
a,
|
|
213
|
+
b
|
|
214
|
+
] : [
|
|
215
|
+
b,
|
|
216
|
+
a
|
|
217
|
+
];
|
|
218
|
+
return compareLocal(d, first) >= 0 && compareLocal(d, last) <= 0;
|
|
219
|
+
}
|
|
220
|
+
const e = props.events.find((x)=>x.id === drop.eventId);
|
|
221
|
+
if (!e) return false;
|
|
222
|
+
const shift = toEpochDays(b) - toEpochDays(a);
|
|
223
|
+
return compareLocal(d, addDays(e.date, shift)) >= 0 && compareLocal(d, addDays(eventLastDay(e), shift)) <= 0;
|
|
224
|
+
};
|
|
225
|
+
const tapDay = (d)=>{
|
|
226
|
+
var _props_onCreate;
|
|
227
|
+
if (!tapAllowed()) return;
|
|
228
|
+
if (props.onSelectDay) props.onSelectDay(d);
|
|
229
|
+
else if (!compact) null == (_props_onCreate = props.onCreate) || _props_onCreate.call(props, {
|
|
230
|
+
allDay: false,
|
|
231
|
+
date: d,
|
|
232
|
+
start: 540,
|
|
233
|
+
end: 600
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
const openDay = (d)=>{
|
|
237
|
+
var _props_onOpenDay;
|
|
238
|
+
var _this;
|
|
239
|
+
if (!tapAllowed()) return;
|
|
240
|
+
null == (_this = null != (_props_onOpenDay = props.onOpenDay) ? _props_onOpenDay : props.onSelectDay) || _this(d);
|
|
241
|
+
};
|
|
242
|
+
const side = rtl ? 'right' : 'left';
|
|
243
|
+
const hm = (minutes)=>`${num(Math.floor(minutes / 60))}:${num(minutes % 60).padStart(2, num(0))}`;
|
|
244
|
+
return <view className={`g9-month${compact ? ' g9-month--compact' : ''}`} {...g9IdProps(props.id)}>
|
|
245
|
+
<view className="g9-month__week g9-month__week--head" style={row}>
|
|
246
|
+
{Array.from({
|
|
247
|
+
length: 7
|
|
248
|
+
}, (_, i)=>(weekStart + i) % 7).map((wd)=><text key={wd} className={`g9-month__wd${weekend.includes(wd) ? ' g9-month__wd--weekend' : ''}`}>
|
|
249
|
+
{initial(wd)}
|
|
250
|
+
</text>)}
|
|
251
|
+
</view>
|
|
252
|
+
<view className="g9-month__grid" main-thread:ref={gridRef} {...dragging ? {
|
|
253
|
+
'main-thread:bindmousedown': rowDown,
|
|
254
|
+
'main-thread:bindmousemove': move,
|
|
255
|
+
'main-thread:bindmouseup': up
|
|
256
|
+
} : {}}>
|
|
257
|
+
{weeks.map((week, w)=>{
|
|
258
|
+
const segs = compact ? [] : weekSegments(others, week[0].date);
|
|
259
|
+
return <view key={w} className="g9-month__week g9-month__week--days" {...0 === w ? {
|
|
260
|
+
bindlayoutchange: (e)=>setRowHeight(e.detail.height)
|
|
261
|
+
} : {}}>
|
|
262
|
+
<view className="g9-month__cells" style={row}>
|
|
263
|
+
{week.map((c, index)=>{
|
|
264
|
+
const named = holidaysOn(c.date);
|
|
265
|
+
const isOff = off(c.date);
|
|
266
|
+
const isWeekend = weekend.includes((weekStart + index) % 7);
|
|
267
|
+
const isToday = sameDay(c.date, props.today);
|
|
268
|
+
const isSelected = compact && !!props.selected && sameDay(c.date, props.selected);
|
|
269
|
+
const other = secondDateLabel(c.date, calendar, second, culture);
|
|
270
|
+
const hidden = compact ? 0 : segs.filter((s)=>s.lane >= lanesFit && s.start <= index && s.end >= index).length;
|
|
271
|
+
const dots = compact ? others.filter((e)=>eventTouches(e, c.date)).slice(0, 4) : [];
|
|
272
|
+
return <view key={c.key} className={`g9-month__cell${compact ? ' g9-month__cell--compact' : ''}${c.inMonth ? '' : ' g9-month__cell--out'}${isOff ? ' g9-month__cell--off' : isWeekend ? ' g9-month__cell--weekend' : ''}${preview(c.date) ? ' g9-month__cell--drop' : ''}${isSelected ? ' g9-month__cell--selected' : ''}`} bindtap={()=>tapDay(c.date)} accessibility-element={compact} accessibility-label={formatLocalDateTime(c.date, 'dddd d MMMM', culture)} {...isSelected ? {
|
|
273
|
+
'accessibility-status': 'selected'
|
|
274
|
+
} : {}}>
|
|
275
|
+
<view className="g9-month__head" style={compact ? {} : row}>
|
|
276
|
+
<view className="g9-month__num-box" {...dragging ? {
|
|
277
|
+
'main-thread:bindmousedown': ignore
|
|
278
|
+
} : {}} catchtap={()=>compact ? tapDay(c.date) : openDay(c.date)} accessibility-element={!compact} accessibility-label={formatLocalDateTime(c.date, 'dddd d MMMM', culture)}>
|
|
279
|
+
<text className={`g9-month__num${isToday ? ' g9-month__num--today' : isOff || isWeekend ? ' g9-month__num--off' : ''}`}>
|
|
280
|
+
{num(c.day)}
|
|
281
|
+
</text>
|
|
282
|
+
</view>
|
|
283
|
+
{!compact && named[0] ? <text className="g9-month__holiday" text-maxline="1">
|
|
284
|
+
{named[0].title}
|
|
285
|
+
</text> : other ? <text className="g9-month__second" text-maxline="1">
|
|
286
|
+
{other}
|
|
287
|
+
</text> : null}
|
|
288
|
+
</view>
|
|
289
|
+
{compact ? <view className="g9-month__dots" style={row}>
|
|
290
|
+
{dots.map((e)=><view key={e.id} className="g9-month__dot" style={e.color ? {
|
|
291
|
+
backgroundColor: e.color
|
|
292
|
+
} : {}}/>)}
|
|
293
|
+
</view> : hidden > 0 ? <view className="g9-month__more-box" {...dragging ? {
|
|
294
|
+
'main-thread:bindmousedown': ignore
|
|
295
|
+
} : {}} catchtap={()=>openDay(c.date)}>
|
|
296
|
+
<text className="g9-month__more">{more(hidden)}</text>
|
|
297
|
+
</view> : null}
|
|
298
|
+
</view>;
|
|
299
|
+
})}
|
|
300
|
+
</view>
|
|
301
|
+
{segs.filter((s)=>s.lane < lanesFit).map((s)=>{
|
|
302
|
+
var _e_start;
|
|
303
|
+
var _week_, _week_1;
|
|
304
|
+
const e = s.event;
|
|
305
|
+
const bar = isBarEvent(e);
|
|
306
|
+
const editable = true === e.canEdit && void 0 !== props.onMove;
|
|
307
|
+
const firstDay = null == (_week_ = week[0]) ? void 0 : _week_.date;
|
|
308
|
+
const lastDay = null == (_week_1 = week[6]) ? void 0 : _week_1.date;
|
|
309
|
+
const cutStart = bar && compareLocal(e.date, firstDay) < 0;
|
|
310
|
+
const cutEnd = bar && compareLocal(eventLastDay(e), lastDay) > 0;
|
|
311
|
+
const r = (cut)=>cut ? '0px' : '4px';
|
|
312
|
+
const corners = rtl ? {
|
|
313
|
+
borderTopRightRadius: r(cutStart),
|
|
314
|
+
borderBottomRightRadius: r(cutStart),
|
|
315
|
+
borderTopLeftRadius: r(cutEnd),
|
|
316
|
+
borderBottomLeftRadius: r(cutEnd)
|
|
317
|
+
} : {
|
|
318
|
+
borderTopLeftRadius: r(cutStart),
|
|
319
|
+
borderBottomLeftRadius: r(cutStart),
|
|
320
|
+
borderTopRightRadius: r(cutEnd),
|
|
321
|
+
borderBottomRightRadius: r(cutEnd)
|
|
322
|
+
};
|
|
323
|
+
return <view key={e.id} className={`g9-month__event${bar ? ' g9-month__event--bar' : ' g9-month__event--timed'}${e.rsvp ? ` g9-month__event--${e.rsvp}` : ''}`} style={{
|
|
324
|
+
[side]: `${s.start / 7 * 100}%`,
|
|
325
|
+
width: `${(s.end - s.start + 1) / 7 * 100}%`,
|
|
326
|
+
top: `${HEADER + s.lane * LANE}px`,
|
|
327
|
+
height: `${LANE - 2}px`,
|
|
328
|
+
...corners,
|
|
329
|
+
...bar && e.color && 'pending' !== e.rsvp ? {
|
|
330
|
+
backgroundColor: e.color
|
|
331
|
+
} : {},
|
|
332
|
+
...bar && e.color && 'pending' === e.rsvp ? {
|
|
333
|
+
borderColor: e.color
|
|
334
|
+
} : {},
|
|
335
|
+
flexDirection: rtl ? 'row-reverse' : 'row',
|
|
336
|
+
direction: 'ltr'
|
|
337
|
+
}} {...dragging ? {
|
|
338
|
+
'main-thread:bindmousedown': (event)=>{
|
|
339
|
+
'main thread';
|
|
340
|
+
begin(event, e.id, editable);
|
|
341
|
+
}
|
|
342
|
+
} : {}} catchtap={()=>{
|
|
343
|
+
var _props_onSelectEvent;
|
|
344
|
+
return tapAllowed() && (null == (_props_onSelectEvent = props.onSelectEvent) ? void 0 : _props_onSelectEvent.call(props, e));
|
|
345
|
+
}} accessibility-element={true} accessibility-traits="button" accessibility-label={e.title}>
|
|
346
|
+
{bar ? null : <>
|
|
347
|
+
<view className="g9-month__event-dot" style={e.color ? {
|
|
348
|
+
backgroundColor: e.color
|
|
349
|
+
} : {}}/>
|
|
350
|
+
<text className="g9-month__event-time">{hm(null != (_e_start = e.start) ? _e_start : 0)}</text>
|
|
351
|
+
</>}
|
|
352
|
+
<text className="g9-month__event-text" text-maxline="1">
|
|
353
|
+
{e.title}
|
|
354
|
+
</text>
|
|
355
|
+
</view>;
|
|
356
|
+
})}
|
|
357
|
+
</view>;
|
|
358
|
+
})}
|
|
359
|
+
</view>
|
|
360
|
+
</view>;
|
|
361
|
+
}
|
|
362
|
+
export { G9MonthView };
|
package/dist/people.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type G9CalendarSystem } from '@g9tm/lynxcontrols-foundation';
|
|
2
|
+
import type { ReactNode } from '@lynx-js/react';
|
|
3
|
+
/** A birthday, in the Gregorian calendar (how it is stored), with or without the year. */
|
|
4
|
+
export interface G9Birthday {
|
|
5
|
+
readonly month: number;
|
|
6
|
+
readonly day: number;
|
|
7
|
+
readonly year?: number | null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A stored (Gregorian) birthday as the viewer's calendar shows it: with its year exactly; without one, on the
|
|
11
|
+
* reference year (this year), as the person celebrates it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function birthdayIn(b: G9Birthday, calendar: G9CalendarSystem, thisYear: number): G9Birthday;
|
|
14
|
+
/** A birthday picked on `calendar` back to the stored Gregorian one (no year: on the reference year). */
|
|
15
|
+
export declare function birthdayFrom(month: number, day: number, year: number | null, calendar: G9CalendarSystem, thisYear: number): G9Birthday;
|
|
16
|
+
/** The words of {@link G9BirthdayField}. */
|
|
17
|
+
export interface G9BirthdayLabels {
|
|
18
|
+
readonly month: string;
|
|
19
|
+
readonly day: string;
|
|
20
|
+
/** The optional year's label («only you see it»). */
|
|
21
|
+
readonly year: string;
|
|
22
|
+
}
|
|
23
|
+
/** Props of {@link G9BirthdayField}. */
|
|
24
|
+
export interface G9BirthdayFieldProps {
|
|
25
|
+
readonly id?: string;
|
|
26
|
+
readonly value: G9Birthday | null;
|
|
27
|
+
readonly onChange: (value: G9Birthday | null) => void;
|
|
28
|
+
readonly disabled?: boolean;
|
|
29
|
+
readonly labels: G9BirthdayLabels;
|
|
30
|
+
/** This year in the viewer's calendar (a year-less birthday maps through it). Default the clock's. */
|
|
31
|
+
readonly thisYear?: number;
|
|
32
|
+
}
|
|
33
|
+
/** A birthday on the viewer's calendar: the month, the day, an optional year; stored in Gregorian. */
|
|
34
|
+
export declare function G9BirthdayField(props: G9BirthdayFieldProps): ReactNode;
|
|
35
|
+
/** One working range of a day, minutes from midnight. */
|
|
36
|
+
export interface G9WorkRange {
|
|
37
|
+
readonly start: number;
|
|
38
|
+
readonly end: number;
|
|
39
|
+
}
|
|
40
|
+
/** A week of working hours: the ranges of each weekday (0 Sunday … 6 Saturday; none = a day off). */
|
|
41
|
+
export type G9WorkWeek = Readonly<Partial<Record<number, readonly G9WorkRange[]>>>;
|
|
42
|
+
/** The words of {@link G9WorkingHoursEditor}. */
|
|
43
|
+
export interface G9WorkingHoursLabels {
|
|
44
|
+
readonly from: string;
|
|
45
|
+
readonly to: string;
|
|
46
|
+
readonly add: string;
|
|
47
|
+
readonly remove: string;
|
|
48
|
+
/** «copy to every day». */
|
|
49
|
+
readonly copy: string;
|
|
50
|
+
readonly zone?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Props of {@link G9WorkingHoursEditor}. */
|
|
53
|
+
export interface G9WorkingHoursEditorProps {
|
|
54
|
+
readonly id?: string;
|
|
55
|
+
readonly value: G9WorkWeek;
|
|
56
|
+
readonly onChange: (week: G9WorkWeek) => void;
|
|
57
|
+
/** The time zone (with `onTimeZoneChange` a zone picker under the days). */
|
|
58
|
+
readonly timeZone?: string;
|
|
59
|
+
readonly onTimeZoneChange?: (zone: string) => void;
|
|
60
|
+
readonly zones?: readonly string[];
|
|
61
|
+
readonly labels: G9WorkingHoursLabels;
|
|
62
|
+
/** A new day's first range. Default 09:00–17:00. */
|
|
63
|
+
readonly defaultRange?: G9WorkRange;
|
|
64
|
+
}
|
|
65
|
+
/** The week's working hours: a switch per weekday (in the culture's week), its ranges, copy to every day, the zone. */
|
|
66
|
+
export declare function G9WorkingHoursEditor(props: G9WorkingHoursEditorProps): ReactNode;
|
|
67
|
+
//# sourceMappingURL=people.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../src/people.tsx"],"names":[],"mappings":"AASA,OAAO,EAGL,KAAK,gBAAgB,EAKtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAOhD,0FAA0F;AAC1F,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAiBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAMlG;AAED,yGAAyG;AACzG,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,MAAM,GACf,UAAU,CAKZ;AAED,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,wCAAwC;AACxC,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,KAAK,IAA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