@g9tm/lynxcontrols-calendar 2.5.7 → 2.5.8
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/cards.jsx
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { g9IdProps } from "@g9tm/lynxcontrols/base";
|
|
2
|
+
import { G9Button } from "@g9tm/lynxcontrols/button";
|
|
3
|
+
import { G9ActivityIndicator } from "@g9tm/lynxcontrols/display";
|
|
4
|
+
import { G9Icon } from "@g9tm/lynxcontrols/icon";
|
|
5
|
+
import { useG9Culture, useG9Direction } from "@g9tm/lynxcontrols/provider";
|
|
6
|
+
import { addDays, compareLocal, dayOfWeek, formatLocalDateTime, formatNumber, toEpochDays } from "@g9tm/lynxcontrols-foundation";
|
|
7
|
+
import { useState } from "@lynx-js/react";
|
|
8
|
+
import { eventLastDay, eventsOn } from "./events.jsx";
|
|
9
|
+
function findCommonSlots(people, o) {
|
|
10
|
+
var _o_step, _o_dayStart, _o_dayEnd, _o_limit, _o_days;
|
|
11
|
+
const step = Math.max(5, null != (_o_step = o.step) ? _o_step : 30);
|
|
12
|
+
const dayStart = null != (_o_dayStart = o.dayStart) ? _o_dayStart : 540;
|
|
13
|
+
const dayEnd = null != (_o_dayEnd = o.dayEnd) ? _o_dayEnd : 1020;
|
|
14
|
+
const limit = null != (_o_limit = o.limit) ? _o_limit : 12;
|
|
15
|
+
const abs = (d, m)=>1440 * toEpochDays(d) + m;
|
|
16
|
+
const busy = people.map((spans)=>spans.map((s)=>[
|
|
17
|
+
abs(s.date, s.start),
|
|
18
|
+
abs(s.date, s.end)
|
|
19
|
+
]));
|
|
20
|
+
const all = [];
|
|
21
|
+
for(let i = 0; i < (null != (_o_days = o.days) ? _o_days : 7); i++){
|
|
22
|
+
const date = addDays(o.from, i);
|
|
23
|
+
if (!o.weekdays || o.weekdays.includes(dayOfWeek(date))) for(let m = dayStart; m + o.duration <= dayEnd; m += step){
|
|
24
|
+
if (o.notBefore && abs(date, m) < abs(o.notBefore.date, o.notBefore.minute)) continue;
|
|
25
|
+
const a = abs(date, m);
|
|
26
|
+
const b = a + o.duration;
|
|
27
|
+
const busyCount = busy.filter((spans)=>spans.some(([s, e])=>s < b && e > a)).length;
|
|
28
|
+
all.push({
|
|
29
|
+
date,
|
|
30
|
+
start: m,
|
|
31
|
+
end: m + o.duration,
|
|
32
|
+
busyCount
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const free = all.filter((s)=>0 === s.busyCount);
|
|
37
|
+
if (free.length >= Math.ceil(limit / 2)) return free.slice(0, limit);
|
|
38
|
+
const rest = all.filter((s)=>s.busyCount > 0 && s.busyCount < people.length).sort((x, y)=>x.busyCount - y.busyCount || abs(x.date, x.start) - abs(y.date, y.start));
|
|
39
|
+
return [
|
|
40
|
+
...free,
|
|
41
|
+
...rest
|
|
42
|
+
].slice(0, limit);
|
|
43
|
+
}
|
|
44
|
+
function G9FindTime(props) {
|
|
45
|
+
var _props_slots;
|
|
46
|
+
const culture = useG9Culture();
|
|
47
|
+
const rtl = 'rtl' === useG9Direction();
|
|
48
|
+
const [picked, setPicked] = useState(null);
|
|
49
|
+
const num = (n)=>formatNumber(n, {
|
|
50
|
+
numberingSystem: culture.numberingSystem,
|
|
51
|
+
useGrouping: false
|
|
52
|
+
});
|
|
53
|
+
const hm = (m)=>`${num(Math.floor(m / 60) % 24)}:${num(m % 60).padStart(2, num(0))}`;
|
|
54
|
+
const row = {
|
|
55
|
+
flexDirection: rtl ? 'row-reverse' : 'row',
|
|
56
|
+
direction: 'ltr'
|
|
57
|
+
};
|
|
58
|
+
const byDay = [];
|
|
59
|
+
for (const s of [
|
|
60
|
+
...null != (_props_slots = props.slots) ? _props_slots : []
|
|
61
|
+
].sort((a, b)=>compareLocal(a.date, b.date) || a.start - b.start)){
|
|
62
|
+
const last = byDay[byDay.length - 1];
|
|
63
|
+
if (last && 0 === compareLocal(last.date, s.date)) last.slots.push(s);
|
|
64
|
+
else byDay.push({
|
|
65
|
+
date: s.date,
|
|
66
|
+
slots: [
|
|
67
|
+
s
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const keyOf = (s)=>`${toEpochDays(s.date)}:${s.start}`;
|
|
72
|
+
return <view className="g9-find-time" {...g9IdProps(props.id)}>
|
|
73
|
+
<view className="g9-find-time__head" style={row}>
|
|
74
|
+
<view className="g9-find-time__texts">
|
|
75
|
+
<text className="g9-find-time__title">{props.labels.title}</text>
|
|
76
|
+
{props.labels.hint ? <text className="g9-find-time__hint">{props.labels.hint}</text> : null}
|
|
77
|
+
</view>
|
|
78
|
+
{props.onSearch ? <G9Button {...props.id ? {
|
|
79
|
+
id: `${props.id}.Search`
|
|
80
|
+
} : {}} text={props.labels.button} size="small" variant="tonal" isLoading={true === props.loading} disabled={true === props.disabled} onPress={()=>{
|
|
81
|
+
var _props_onSearch;
|
|
82
|
+
return null == (_props_onSearch = props.onSearch) ? void 0 : _props_onSearch.call(props);
|
|
83
|
+
}}/> : null}
|
|
84
|
+
</view>
|
|
85
|
+
{props.loading && !props.slots ? <G9ActivityIndicator running={true} size={18}/> : props.error ? <text className="g9-find-time__error">{props.error}</text> : props.slots ? 0 === props.slots.length ? <text className="g9-find-time__none">{props.labels.none}</text> : byDay.map((g)=><view key={toEpochDays(g.date)} className="g9-find-time__day">
|
|
86
|
+
<text className="g9-find-time__date">{formatLocalDateTime(g.date, 'dddd d MMMM', culture)}</text>
|
|
87
|
+
<view className="g9-find-time__slots" style={row}>
|
|
88
|
+
{g.slots.map((s)=>{
|
|
89
|
+
const free = 0 === s.busyCount;
|
|
90
|
+
const on = picked === keyOf(s);
|
|
91
|
+
const note = free ? props.labels.everyone : props.labels.busy.replace('{n}', num(s.busyCount));
|
|
92
|
+
return <view key={keyOf(s)} className={`g9-find-time__slot${on ? ' g9-find-time__slot--on' : free ? ' g9-find-time__slot--free' : ''}`} {...g9IdProps(props.id ? `${props.id}_${keyOf(s)}` : void 0)} bindtap={()=>{
|
|
93
|
+
setPicked(keyOf(s));
|
|
94
|
+
props.onPick(s);
|
|
95
|
+
}} accessibility-element={true} accessibility-traits="button" accessibility-label={`${hm(s.start)}–${hm(s.end)}, ${note}`} {...on ? {
|
|
96
|
+
'accessibility-status': 'selected'
|
|
97
|
+
} : {}}>
|
|
98
|
+
<text className="g9-find-time__time">{`${hm(s.start)}–${hm(s.end)}`}</text>
|
|
99
|
+
<text className={`g9-find-time__note${free ? ' g9-find-time__note--free' : ''}`}>{note}</text>
|
|
100
|
+
</view>;
|
|
101
|
+
})}
|
|
102
|
+
</view>
|
|
103
|
+
</view>) : null}
|
|
104
|
+
</view>;
|
|
105
|
+
}
|
|
106
|
+
function G9EventCard(props) {
|
|
107
|
+
const culture = useG9Culture();
|
|
108
|
+
const rtl = 'rtl' === useG9Direction();
|
|
109
|
+
const row = {
|
|
110
|
+
flexDirection: rtl ? 'row-reverse' : 'row',
|
|
111
|
+
direction: 'ltr'
|
|
112
|
+
};
|
|
113
|
+
const align = {
|
|
114
|
+
textAlign: rtl ? 'right' : 'left'
|
|
115
|
+
};
|
|
116
|
+
const num = (n)=>formatNumber(n, {
|
|
117
|
+
numberingSystem: culture.numberingSystem,
|
|
118
|
+
useGrouping: false
|
|
119
|
+
});
|
|
120
|
+
const hm = (m)=>`${num(Math.floor(m / 60) % 24)}:${num(m % 60).padStart(2, num(0))}`;
|
|
121
|
+
if (props.hidden) {
|
|
122
|
+
var _props_labels_hidden;
|
|
123
|
+
return <view className="g9-event-card g9-event-card--hidden" style={row} {...g9IdProps(props.id)}>
|
|
124
|
+
<G9Icon icon="eyeClosed" size={14} color="var(--g9-text-secondary)"/>
|
|
125
|
+
<text className="g9-event-card__hidden">{null != (_props_labels_hidden = props.labels.hidden) ? _props_labels_hidden : ''}</text>
|
|
126
|
+
</view>;
|
|
127
|
+
}
|
|
128
|
+
const e = props.event;
|
|
129
|
+
if (!e) return <view className="g9-event-card g9-event-card--placeholder" {...g9IdProps(props.id)}/>;
|
|
130
|
+
const date = formatLocalDateTime(e.date, 'dddd d MMMM', culture);
|
|
131
|
+
const last = eventLastDay(e);
|
|
132
|
+
const range = compareLocal(last, e.date) > 0 ? ` – ${formatLocalDateTime(last, 'd MMMM', culture)}` : '';
|
|
133
|
+
const when = void 0 === e.start ? `${date}${range}${props.labels.allDay ? ` · ${props.labels.allDay}` : ''}` : `${date}${range} · ${hm(e.start)}${void 0 !== e.end ? `–${hm(e.end)}` : ''}`;
|
|
134
|
+
const answers = [
|
|
135
|
+
{
|
|
136
|
+
key: 'accepted',
|
|
137
|
+
label: props.labels.yes,
|
|
138
|
+
icon: 'check'
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
key: 'tentative',
|
|
142
|
+
label: props.labels.maybe,
|
|
143
|
+
icon: 'info'
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
key: 'declined',
|
|
147
|
+
label: props.labels.no,
|
|
148
|
+
icon: 'close'
|
|
149
|
+
}
|
|
150
|
+
];
|
|
151
|
+
return <view className="g9-event-card" {...g9IdProps(props.id)} {...props.onOpen ? {
|
|
152
|
+
bindtap: ()=>{
|
|
153
|
+
var _props_onOpen;
|
|
154
|
+
return null == (_props_onOpen = props.onOpen) ? void 0 : _props_onOpen.call(props);
|
|
155
|
+
}
|
|
156
|
+
} : {}} accessibility-element={false}>
|
|
157
|
+
<view className="g9-event-card__top" style={row}>
|
|
158
|
+
<view className="g9-event-card__badge" style={e.color ? {
|
|
159
|
+
backgroundColor: e.color
|
|
160
|
+
} : {}}>
|
|
161
|
+
<G9Icon icon="calendar" size={18} color="#ffffff"/>
|
|
162
|
+
</view>
|
|
163
|
+
<view className="g9-event-card__texts">
|
|
164
|
+
<text className="g9-event-card__title" text-maxline="1" style={align}>
|
|
165
|
+
{e.title}
|
|
166
|
+
</text>
|
|
167
|
+
<text className="g9-event-card__line" style={align}>
|
|
168
|
+
{when}
|
|
169
|
+
</text>
|
|
170
|
+
{props.repeat ? <text className="g9-event-card__line g9-event-card__line--faint" style={align}>
|
|
171
|
+
{props.repeat}
|
|
172
|
+
</text> : null}
|
|
173
|
+
{e.location ? <text className="g9-event-card__line g9-event-card__line--faint" text-maxline="1" style={align}>
|
|
174
|
+
{e.location}
|
|
175
|
+
</text> : null}
|
|
176
|
+
{void 0 !== props.guests && props.labels.guests ? <text className="g9-event-card__line g9-event-card__line--faint" style={align}>
|
|
177
|
+
{props.labels.guests.replace('{n}', num(props.guests))}
|
|
178
|
+
</text> : null}
|
|
179
|
+
</view>
|
|
180
|
+
</view>
|
|
181
|
+
{void 0 !== props.rsvp && props.onRespond ? <view className="g9-event-card__answers" style={row}>
|
|
182
|
+
{answers.map((a)=><view key={a.key} className={`g9-event-card__answer${props.rsvp === a.key ? ' g9-event-card__answer--on' : ''}`} {...g9IdProps(props.id ? `${props.id}_${a.key}` : void 0)} catchtap={()=>{
|
|
183
|
+
var _props_onRespond;
|
|
184
|
+
if (!props.busy && props.rsvp !== a.key) null == (_props_onRespond = props.onRespond) || _props_onRespond.call(props, a.key);
|
|
185
|
+
}} accessibility-element={true} accessibility-traits="button" accessibility-label={a.label} {...props.rsvp === a.key ? {
|
|
186
|
+
'accessibility-status': 'selected'
|
|
187
|
+
} : {}} {...props.busy ? {
|
|
188
|
+
'accessibility-value': 'busy'
|
|
189
|
+
} : {}}>
|
|
190
|
+
<G9Icon icon={a.icon} size={14} color={props.rsvp === a.key ? 'var(--g9-on-primary)' : 'var(--g9-text-secondary)'}/>
|
|
191
|
+
<text className={`g9-event-card__answer-text${props.rsvp === a.key ? ' g9-event-card__answer-text--on' : ''}`}>
|
|
192
|
+
{a.label}
|
|
193
|
+
</text>
|
|
194
|
+
</view>)}
|
|
195
|
+
{props.busy ? <G9ActivityIndicator running={true} size={14}/> : null}
|
|
196
|
+
</view> : null}
|
|
197
|
+
</view>;
|
|
198
|
+
}
|
|
199
|
+
function G9TodayWidget(props) {
|
|
200
|
+
var _props_max;
|
|
201
|
+
const culture = useG9Culture();
|
|
202
|
+
const rtl = 'rtl' === useG9Direction();
|
|
203
|
+
const row = {
|
|
204
|
+
flexDirection: rtl ? 'row-reverse' : 'row',
|
|
205
|
+
direction: 'ltr'
|
|
206
|
+
};
|
|
207
|
+
const num = (n)=>formatNumber(n, {
|
|
208
|
+
numberingSystem: culture.numberingSystem,
|
|
209
|
+
useGrouping: false
|
|
210
|
+
});
|
|
211
|
+
const hm = (m)=>`${num(Math.floor(m / 60) % 24)}:${num(m % 60).padStart(2, num(0))}`;
|
|
212
|
+
const on = eventsOn(props.events, props.today).filter((e)=>'holiday' !== e.kind);
|
|
213
|
+
const holiday = eventsOn(props.events, props.today).find((e)=>'holiday' === e.kind);
|
|
214
|
+
const max = null != (_props_max = props.max) ? _props_max : 4;
|
|
215
|
+
const next = on.find((e)=>{
|
|
216
|
+
var _e_end;
|
|
217
|
+
return void 0 !== e.start && (null != (_e_end = e.end) ? _e_end : e.start + 60) > props.now;
|
|
218
|
+
});
|
|
219
|
+
const shown = on.slice(0, max);
|
|
220
|
+
return <view className="g9-today" {...g9IdProps(props.id)} {...props.onOpen ? {
|
|
221
|
+
bindtap: ()=>{
|
|
222
|
+
var _props_onOpen;
|
|
223
|
+
return null == (_props_onOpen = props.onOpen) ? void 0 : _props_onOpen.call(props);
|
|
224
|
+
}
|
|
225
|
+
} : {}}>
|
|
226
|
+
<view className="g9-today__head" style={row}>
|
|
227
|
+
<text className="g9-today__title">{props.labels.title}</text>
|
|
228
|
+
<text className="g9-today__date">{formatLocalDateTime(props.today, 'dddd d MMMM', culture)}</text>
|
|
229
|
+
</view>
|
|
230
|
+
{holiday ? <text className="g9-today__holiday">{holiday.title}</text> : null}
|
|
231
|
+
{0 === shown.length ? <text className="g9-today__empty">{props.labels.empty}</text> : null}
|
|
232
|
+
{shown.map((e)=><view key={e.id} className={`g9-today__row${e === next ? ' g9-today__row--next' : ''}`} style={row} {...g9IdProps(props.id ? `${props.id}_${e.id}` : void 0)} {...props.onSelectEvent ? {
|
|
233
|
+
catchtap: ()=>{
|
|
234
|
+
var _props_onSelectEvent;
|
|
235
|
+
return null == (_props_onSelectEvent = props.onSelectEvent) ? void 0 : _props_onSelectEvent.call(props, e);
|
|
236
|
+
}
|
|
237
|
+
} : {}} accessibility-element={true} accessibility-label={`${e.title}, ${void 0 === e.start ? props.labels.allDay : hm(e.start)}`}>
|
|
238
|
+
<view className="g9-today__bar" style={e.color ? {
|
|
239
|
+
backgroundColor: e.color
|
|
240
|
+
} : {}}/>
|
|
241
|
+
<text className="g9-today__time">{void 0 === e.start ? props.labels.allDay : hm(e.start)}</text>
|
|
242
|
+
<text className="g9-today__text" text-maxline="1" style={{
|
|
243
|
+
textAlign: rtl ? 'right' : 'left'
|
|
244
|
+
}}>
|
|
245
|
+
{e.title}
|
|
246
|
+
</text>
|
|
247
|
+
{e === next && props.labels.next ? <text className="g9-today__next">{props.labels.next}</text> : null}
|
|
248
|
+
</view>)}
|
|
249
|
+
{on.length > max && props.labels.more ? <text className="g9-today__more">{props.labels.more.replace('{n}', num(on.length - max))}</text> : null}
|
|
250
|
+
</view>;
|
|
251
|
+
}
|
|
252
|
+
export { G9EventCard, G9FindTime, G9TodayWidget, findCommonSlots };
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type G9CalendarSystem, type G9Culture, type G9LocalDate } from '@g9tm/lynxcontrols-foundation';
|
|
2
|
+
/** What the person answered to an invitation. `'pending'`: not yet. */
|
|
3
|
+
export type G9Rsvp = 'accepted' | 'tentative' | 'declined' | 'pending';
|
|
4
|
+
/** The parts of an event these helpers read (G9CalendarEvent has them all). */
|
|
5
|
+
export interface G9EventSpan {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly date: G9LocalDate;
|
|
8
|
+
readonly endDate?: G9LocalDate;
|
|
9
|
+
readonly start?: number;
|
|
10
|
+
readonly end?: number;
|
|
11
|
+
readonly kind?: string;
|
|
12
|
+
}
|
|
13
|
+
/** The last day an event touches (its `endDate`, else its `date`). */
|
|
14
|
+
export declare function eventLastDay(e: G9EventSpan): G9LocalDate;
|
|
15
|
+
/** Drawn as a bar across days: all day (no `start`) or lasting a day or more (a timed night shift is not). */
|
|
16
|
+
export declare function isBarEvent(e: G9EventSpan): boolean;
|
|
17
|
+
/** Whether the event touches `day`. */
|
|
18
|
+
export declare function eventTouches(e: G9EventSpan, day: G9LocalDate): boolean;
|
|
19
|
+
/** The events on `day`: holidays first, then bars (longer first), then timed by start. */
|
|
20
|
+
export declare function eventsOn<T extends G9EventSpan>(events: readonly T[], day: G9LocalDate): T[];
|
|
21
|
+
/** One bar of a week row: its first and last day index (0–6, inclusive). */
|
|
22
|
+
export interface G9WeekSegment {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly start: number;
|
|
25
|
+
readonly end: number;
|
|
26
|
+
/** A tie-break for segments as long that start the same day (the start time). */
|
|
27
|
+
readonly order?: number;
|
|
28
|
+
}
|
|
29
|
+
/** The lane (0 = top) each bar of a week row takes: earliest first, longer first, never two in a lane on a day. */
|
|
30
|
+
export declare function layoutLanes(segments: readonly G9WeekSegment[]): Map<string, number>;
|
|
31
|
+
/** The segments of the events of a week starting `weekStart` (seven days), clamped to it, with their lanes. */
|
|
32
|
+
export declare function weekSegments<T extends G9EventSpan>(events: readonly T[], weekStart: G9LocalDate): {
|
|
33
|
+
readonly event: T;
|
|
34
|
+
readonly start: number;
|
|
35
|
+
readonly end: number;
|
|
36
|
+
readonly lane: number;
|
|
37
|
+
}[];
|
|
38
|
+
/**
|
|
39
|
+
* The day in the other calendar, short («۱ فروردین» under a Gregorian date, «21 Mar» under a Persian one), or `''` when
|
|
40
|
+
* `second` is `'none'` or the same as the primary.
|
|
41
|
+
*/
|
|
42
|
+
export declare function secondDateLabel(day: G9LocalDate, primary: G9CalendarSystem, second: G9CalendarSystem | 'none', culture: G9Culture): string;
|
|
43
|
+
/** The days from `from` to `to` (inclusive). */
|
|
44
|
+
export declare function daysBetween(from: G9LocalDate, to: G9LocalDate): G9LocalDate[];
|
|
45
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,WAAW,EAIjB,MAAM,+BAA+B,CAAC;AAKvC,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAEvE,+EAA+E;AAC/E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,CAAC,EAAE,WAAW,GAAG,WAAW,CAExD;AAED,8GAA8G;AAC9G,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAIlD;AAED,uCAAuC;AACvC,wBAAgB,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAEtE;AAED,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,GAAG,CAAC,EAAE,CAQ3F;AAED,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,mHAAmH;AACnH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBnF;AAED,+GAA+G;AAC/G,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAChD,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,SAAS,EAAE,WAAW,GACrB;IAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAmB9F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,gBAAgB,GAAG,MAAM,EACjC,OAAO,EAAE,SAAS,GACjB,MAAM,CAKR;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,GAAG,WAAW,EAAE,CAG7E"}
|
package/dist/events.jsx
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { addDays, compareLocal, formatNumber, getMonthName, toCalendarDate, toEpochDays } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
+
const byCode = (a, b)=>Number(a > b) - Number(a < b);
|
|
3
|
+
function eventLastDay(e) {
|
|
4
|
+
return e.endDate && compareLocal(e.endDate, e.date) > 0 ? e.endDate : e.date;
|
|
5
|
+
}
|
|
6
|
+
function isBarEvent(e) {
|
|
7
|
+
var _e_end;
|
|
8
|
+
if (void 0 === e.start) return true;
|
|
9
|
+
const days = toEpochDays(eventLastDay(e)) - toEpochDays(e.date);
|
|
10
|
+
return 1440 * days + (null != (_e_end = e.end) ? _e_end : e.start + 60) - e.start >= 1440;
|
|
11
|
+
}
|
|
12
|
+
function eventTouches(e, day) {
|
|
13
|
+
return compareLocal(e.date, day) <= 0 && compareLocal(eventLastDay(e), day) >= 0;
|
|
14
|
+
}
|
|
15
|
+
function eventsOn(events, day) {
|
|
16
|
+
const rank = (e)=>'holiday' === e.kind ? 0 : isBarEvent(e) ? 1 : 2;
|
|
17
|
+
const length = (e)=>toEpochDays(eventLastDay(e)) - toEpochDays(e.date);
|
|
18
|
+
return events.filter((e)=>eventTouches(e, day)).sort((a, b)=>{
|
|
19
|
+
var _a_start, _b_start;
|
|
20
|
+
return rank(a) - rank(b) || length(b) - length(a) || (null != (_a_start = a.start) ? _a_start : 0) - (null != (_b_start = b.start) ? _b_start : 0) || byCode(a.id, b.id);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function layoutLanes(segments) {
|
|
24
|
+
const sorted = [
|
|
25
|
+
...segments
|
|
26
|
+
].sort((a, b)=>{
|
|
27
|
+
var _a_order, _b_order;
|
|
28
|
+
return a.start - b.start || b.end - b.start - (a.end - a.start) || (null != (_a_order = a.order) ? _a_order : 0) - (null != (_b_order = b.order) ? _b_order : 0) || byCode(a.id, b.id);
|
|
29
|
+
});
|
|
30
|
+
const lanes = [];
|
|
31
|
+
const out = new Map();
|
|
32
|
+
for (const s of sorted){
|
|
33
|
+
let lane = lanes.findIndex((taken)=>taken.every((d)=>d < s.start || d > s.end));
|
|
34
|
+
if (lane < 0) {
|
|
35
|
+
lane = lanes.length;
|
|
36
|
+
lanes.push([]);
|
|
37
|
+
}
|
|
38
|
+
for(let d = s.start; d <= s.end; d++)lanes[lane].push(d);
|
|
39
|
+
out.set(s.id, lane);
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function weekSegments(events, weekStart) {
|
|
44
|
+
const first = toEpochDays(weekStart);
|
|
45
|
+
const last = first + 6;
|
|
46
|
+
const raw = events.filter((e)=>toEpochDays(e.date) <= last && toEpochDays(eventLastDay(e)) >= first).map((e)=>({
|
|
47
|
+
event: e,
|
|
48
|
+
start: Math.max(0, toEpochDays(e.date) - first),
|
|
49
|
+
end: Math.min(6, toEpochDays(eventLastDay(e)) - first)
|
|
50
|
+
}));
|
|
51
|
+
const lanes = layoutLanes(raw.map((r)=>{
|
|
52
|
+
var _r_event_start;
|
|
53
|
+
return {
|
|
54
|
+
id: r.event.id,
|
|
55
|
+
start: r.start,
|
|
56
|
+
end: r.end,
|
|
57
|
+
order: isBarEvent(r.event) ? -1 : null != (_r_event_start = r.event.start) ? _r_event_start : 0
|
|
58
|
+
};
|
|
59
|
+
}));
|
|
60
|
+
return raw.map((r)=>{
|
|
61
|
+
var _lanes_get;
|
|
62
|
+
return {
|
|
63
|
+
...r,
|
|
64
|
+
lane: null != (_lanes_get = lanes.get(r.event.id)) ? _lanes_get : 0
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function secondDateLabel(day, primary, second, culture) {
|
|
69
|
+
if ('none' === second || second === primary) return '';
|
|
70
|
+
const c = toCalendarDate(day, second);
|
|
71
|
+
const num = formatNumber(c.day, {
|
|
72
|
+
numberingSystem: culture.numberingSystem,
|
|
73
|
+
useGrouping: false
|
|
74
|
+
});
|
|
75
|
+
return `${num} ${getMonthName(second, c.month, culture)}`;
|
|
76
|
+
}
|
|
77
|
+
function daysBetween(from, to) {
|
|
78
|
+
const n = toEpochDays(to) - toEpochDays(from);
|
|
79
|
+
return Array.from({
|
|
80
|
+
length: Math.max(0, n + 1)
|
|
81
|
+
}, (_, i)=>addDays(from, i));
|
|
82
|
+
}
|
|
83
|
+
export { daysBetween, eventLastDay, eventTouches, eventsOn, isBarEvent, layoutLanes, secondDateLabel, weekSegments };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** Snapping of times while dragging (minutes). */
|
|
2
|
+
export declare const g9CalendarSnap = 15;
|
|
3
|
+
/** A box in the grid (dp): where a drag starts and what it covers. */
|
|
4
|
+
export interface G9GestureRect {
|
|
5
|
+
left: number;
|
|
6
|
+
top: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
/** Where a pointer is in the time grid: the all-day row or the hours, which day, which (snapped) minute. */
|
|
11
|
+
export interface G9Located {
|
|
12
|
+
region: 'grid' | 'allday';
|
|
13
|
+
index: number;
|
|
14
|
+
minute: number;
|
|
15
|
+
}
|
|
16
|
+
/** An entry as the main thread needs it (offsets from the first visible day). */
|
|
17
|
+
export interface G9DragEntry {
|
|
18
|
+
/** Offset of its first day (may be negative: it started before the visible days). */
|
|
19
|
+
startOffset: number;
|
|
20
|
+
/** Offset of its last day (inclusive). */
|
|
21
|
+
lastOffset: number;
|
|
22
|
+
/** Minutes since midnight of its start (local). */
|
|
23
|
+
startMinute: number;
|
|
24
|
+
/** Length in minutes. */
|
|
25
|
+
duration: number;
|
|
26
|
+
allDay: boolean;
|
|
27
|
+
/** Drawn as a bar (all-day or ≥ 24 h). */
|
|
28
|
+
bar: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** A change while dragging, in offsets . */
|
|
31
|
+
export interface G9DragPreview {
|
|
32
|
+
allDay: boolean;
|
|
33
|
+
start: number;
|
|
34
|
+
startMinute: number;
|
|
35
|
+
end: number;
|
|
36
|
+
endMinute: number;
|
|
37
|
+
}
|
|
38
|
+
/** What a drag does: draw a new event, move one, or resize one. */
|
|
39
|
+
export type G9DragMode = 'create' | 'move' | 'resize';
|
|
40
|
+
/** `value` held between `min` and `max`. */
|
|
41
|
+
export declare function clampNumber(value: number, min: number, max: number): number;
|
|
42
|
+
/** The day column under `x` in a row of `count` equal columns (RTL rows start at the right edge). */
|
|
43
|
+
export declare function columnAt(x: number, rect: G9GestureRect, count: number, rtl: boolean): number;
|
|
44
|
+
/** The snapped minute of the day at `y` in the hours (`rect.top` = midnight). */
|
|
45
|
+
export declare function minuteAt(y: number, rect: G9GestureRect, hourHeight: number, snap?: number): number;
|
|
46
|
+
/** Above the bottom of the all-day row it is the all-day row, else the hours. */
|
|
47
|
+
export declare function locate(x: number, y: number, grid: G9GestureRect, allDay: G9GestureRect, count: number, rtl: boolean, hourHeight: number): G9Located;
|
|
48
|
+
/** Minutes between the grab point and the entry's start (moving a timed entry keeps the finger on the same spot). */
|
|
49
|
+
export declare function grabOffset(entry: G9DragEntry | null, from: G9Located): number;
|
|
50
|
+
/** The change a drag stands for right now. */
|
|
51
|
+
export declare function dragPreview(mode: G9DragMode, entry: G9DragEntry | null, from: G9Located, at: G9Located, grab: number, count: number): G9DragPreview | null;
|
|
52
|
+
/** A click / tap on empty space makes a new event there (an hour from the half hour). */
|
|
53
|
+
export declare function tapDraft(at: G9Located, count: number): G9DragPreview;
|
|
54
|
+
/** The boxes a timed preview draws: one per visible day it covers (top/height in px). */
|
|
55
|
+
export declare function previewBoxes(preview: G9DragPreview, count: number, hourHeight: number): {
|
|
56
|
+
index: number;
|
|
57
|
+
top: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}[];
|
|
60
|
+
/** The columns an all-day preview covers within the visible days, or null. */
|
|
61
|
+
export declare function previewBar(preview: G9DragPreview, count: number): {
|
|
62
|
+
start: number;
|
|
63
|
+
end: number;
|
|
64
|
+
} | null;
|
|
65
|
+
/** Whether two drag previews draw the same (no re-render when they do). */
|
|
66
|
+
export declare function samePreview(a: G9DragPreview | null, b: G9DragPreview | null): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The month grid cell under a point: rows of equal height, seven columns. Returns the
|
|
69
|
+
* index into the flattened weeks (row * 7 + column), or -1 outside the grid.
|
|
70
|
+
*/
|
|
71
|
+
export declare function monthCellAt(x: number, y: number, rect: G9GestureRect, rows: number, rtl: boolean): number;
|
|
72
|
+
/**
|
|
73
|
+
* A quick horizontal fling: `end` = toward the reading end (right in LTR, left in RTL), which reveals
|
|
74
|
+
* the previous period; `start` the next one. Null when it was not a swipe.
|
|
75
|
+
*/
|
|
76
|
+
export declare function swipeDirection(dx: number, dy: number, elapsedMs: number, threshold: number, rtl: boolean): 'start' | 'end' | null;
|
|
77
|
+
/** How far the content follows the finger while swiping (damped, capped). */
|
|
78
|
+
export declare function swipeFollow(dx: number, width: number): number;
|
|
79
|
+
//# sourceMappingURL=gesture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gesture.d.ts","sourceRoot":"","sources":["../src/gesture.ts"],"names":[],"mappings":"AAIA,kDAAkD;AAClD,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,4GAA4G;AAC5G,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,GAAG,EAAE,OAAO,CAAC;CACd;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,qGAAqG;AACrG,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAK5F;AAED,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,SAAiB,GAAG,MAAM,CAG1G;AAED,iFAAiF;AACjF,wBAAgB,MAAM,CACpB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,OAAO,EACZ,UAAU,EAAE,MAAM,GACjB,SAAS,CAGX;AAED,qHAAqH;AACrH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAG7E;AAMD,8CAA8C;AAC9C,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,SAAS,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,aAAa,GAAG,IAAI,CAyCtB;AAED,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAKpE;AAED,yFAAyF;AACzF,wBAAgB,YAAY,CAC1B,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GACjB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,CAWlD;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAKvG;AAED,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,EAAE,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CASrF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAIzG;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,OAAO,GACX,OAAO,GAAG,KAAK,GAAG,IAAI,CAIxB;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI7D"}
|
package/dist/gesture.jsx
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
const g9CalendarSnap = 15;
|
|
2
|
+
function clampNumber(value, min, max) {
|
|
3
|
+
return Math.min(max, Math.max(min, value));
|
|
4
|
+
}
|
|
5
|
+
function columnAt(x, rect, count, rtl) {
|
|
6
|
+
if (rect.width <= 0 || count <= 0) return 0;
|
|
7
|
+
let fraction = rtl ? (rect.left + rect.width - x) / rect.width : (x - rect.left) / rect.width;
|
|
8
|
+
fraction = clampNumber(fraction, 0, 0.9999);
|
|
9
|
+
return Math.floor(fraction * count);
|
|
10
|
+
}
|
|
11
|
+
function minuteAt(y, rect, hourHeight, snap = g9CalendarSnap) {
|
|
12
|
+
const raw = (y - rect.top) / hourHeight * 60;
|
|
13
|
+
return clampNumber(Math.round(raw / snap) * snap, 0, 1440);
|
|
14
|
+
}
|
|
15
|
+
function locate(x, y, grid, allDay, count, rtl, hourHeight) {
|
|
16
|
+
if (y < allDay.top + allDay.height) return {
|
|
17
|
+
region: 'allday',
|
|
18
|
+
index: columnAt(x, allDay, count, rtl),
|
|
19
|
+
minute: 0
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
region: 'grid',
|
|
23
|
+
index: columnAt(x, grid, count, rtl),
|
|
24
|
+
minute: minuteAt(y, grid, hourHeight)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function grabOffset(entry, from) {
|
|
28
|
+
if (!entry || 'grid' !== from.region || entry.bar) return 0;
|
|
29
|
+
return from.minute - (entry.startOffset === from.index ? entry.startMinute : 0);
|
|
30
|
+
}
|
|
31
|
+
function keyAt(index, count) {
|
|
32
|
+
return clampNumber(index, 0, count - 1);
|
|
33
|
+
}
|
|
34
|
+
function dragPreview(mode, entry, from, at, grab, count) {
|
|
35
|
+
if ('create' === mode) {
|
|
36
|
+
if ('allday' === from.region || 'allday' === at.region) {
|
|
37
|
+
const other = 'allday' === at.region ? at.index : from.index;
|
|
38
|
+
const a = Math.min(from.index, other);
|
|
39
|
+
const b = Math.max(from.index, other);
|
|
40
|
+
return {
|
|
41
|
+
allDay: true,
|
|
42
|
+
start: keyAt(a, count),
|
|
43
|
+
end: keyAt(b, count),
|
|
44
|
+
startMinute: 0,
|
|
45
|
+
endMinute: 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const a = Math.min(from.minute, at.minute);
|
|
49
|
+
const b = Math.max(from.minute, at.minute);
|
|
50
|
+
const end = Math.max(b, a + g9CalendarSnap);
|
|
51
|
+
const day = keyAt(from.index, count);
|
|
52
|
+
return {
|
|
53
|
+
allDay: false,
|
|
54
|
+
start: day,
|
|
55
|
+
startMinute: Math.min(a, 1440 - g9CalendarSnap),
|
|
56
|
+
end: day,
|
|
57
|
+
endMinute: Math.min(end, 1440)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (!entry) return null;
|
|
61
|
+
if ('resize' === mode) {
|
|
62
|
+
const startMinute = entry.startOffset === keyAt(from.index, count) ? entry.startMinute : 0;
|
|
63
|
+
const day = entry.startOffset;
|
|
64
|
+
const endIndex = Math.max(day, at.index);
|
|
65
|
+
const endKey = keyAt(endIndex, count);
|
|
66
|
+
const endMinute = endKey === day ? Math.max(at.minute, startMinute + g9CalendarSnap) : at.minute;
|
|
67
|
+
return {
|
|
68
|
+
allDay: false,
|
|
69
|
+
start: day,
|
|
70
|
+
startMinute: entry.startMinute,
|
|
71
|
+
end: endKey,
|
|
72
|
+
endMinute
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if ('allday' === at.region) {
|
|
76
|
+
const span = entry.allDay ? entry.lastOffset - entry.startOffset : 0;
|
|
77
|
+
const shift = 'allday' === from.region ? at.index - from.index : 0;
|
|
78
|
+
const start = 'allday' === from.region ? entry.startOffset + shift : keyAt(at.index, count);
|
|
79
|
+
return {
|
|
80
|
+
allDay: true,
|
|
81
|
+
start,
|
|
82
|
+
end: start + span,
|
|
83
|
+
startMinute: 0,
|
|
84
|
+
endMinute: 0
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const duration = entry.allDay ? 60 : Math.max(g9CalendarSnap, entry.duration);
|
|
88
|
+
const startMinute = clampNumber(at.minute - ('grid' === from.region ? grab : 0), 0, 1440 - g9CalendarSnap);
|
|
89
|
+
const start = keyAt(at.index, count);
|
|
90
|
+
const endTotal = startMinute + duration;
|
|
91
|
+
return {
|
|
92
|
+
allDay: false,
|
|
93
|
+
start,
|
|
94
|
+
startMinute,
|
|
95
|
+
end: start + Math.floor(endTotal / 1440),
|
|
96
|
+
endMinute: endTotal % 1440
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function tapDraft(at, count) {
|
|
100
|
+
const day = keyAt(at.index, count);
|
|
101
|
+
if ('allday' === at.region) return {
|
|
102
|
+
allDay: true,
|
|
103
|
+
start: day,
|
|
104
|
+
end: day,
|
|
105
|
+
startMinute: 0,
|
|
106
|
+
endMinute: 0
|
|
107
|
+
};
|
|
108
|
+
const start = Math.min(30 * Math.floor(at.minute / 30), 1380);
|
|
109
|
+
return {
|
|
110
|
+
allDay: false,
|
|
111
|
+
start: day,
|
|
112
|
+
startMinute: start,
|
|
113
|
+
end: day,
|
|
114
|
+
endMinute: start + 60
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function previewBoxes(preview, count, hourHeight) {
|
|
118
|
+
const boxes = [];
|
|
119
|
+
if (preview.allDay) return boxes;
|
|
120
|
+
for(let index = 0; index < count; index++){
|
|
121
|
+
if (index < preview.start || index > preview.end) continue;
|
|
122
|
+
const start = index === preview.start ? preview.startMinute : 0;
|
|
123
|
+
const end = index === preview.end ? preview.endMinute : 1440;
|
|
124
|
+
if (!(end <= start)) boxes.push({
|
|
125
|
+
index,
|
|
126
|
+
top: start / 60 * hourHeight,
|
|
127
|
+
height: (end - start) / 60 * hourHeight
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return boxes;
|
|
131
|
+
}
|
|
132
|
+
function previewBar(preview, count) {
|
|
133
|
+
if (!preview.allDay) return null;
|
|
134
|
+
const start = Math.max(0, preview.start);
|
|
135
|
+
const end = Math.min(count - 1, preview.end);
|
|
136
|
+
return end >= start ? {
|
|
137
|
+
start,
|
|
138
|
+
end
|
|
139
|
+
} : null;
|
|
140
|
+
}
|
|
141
|
+
function samePreview(a, b) {
|
|
142
|
+
if (!a || !b) return a === b;
|
|
143
|
+
return a.allDay === b.allDay && a.start === b.start && a.end === b.end && a.startMinute === b.startMinute && a.endMinute === b.endMinute;
|
|
144
|
+
}
|
|
145
|
+
function monthCellAt(x, y, rect, rows, rtl) {
|
|
146
|
+
if (rect.height <= 0 || rows <= 0 || y < rect.top || y > rect.top + rect.height) return -1;
|
|
147
|
+
const row = Math.min(rows - 1, Math.floor((y - rect.top) / rect.height * rows));
|
|
148
|
+
return 7 * row + columnAt(x, rect, 7, rtl);
|
|
149
|
+
}
|
|
150
|
+
function swipeDirection(dx, dy, elapsedMs, threshold, rtl) {
|
|
151
|
+
const quick = elapsedMs < 700;
|
|
152
|
+
if (!quick || Math.abs(dx) < threshold || Math.abs(dy) > 0.6 * Math.abs(dx)) return null;
|
|
153
|
+
return dx > 0 !== rtl ? 'end' : 'start';
|
|
154
|
+
}
|
|
155
|
+
function swipeFollow(dx, width) {
|
|
156
|
+
const limit = Math.max(40, 0.25 * width);
|
|
157
|
+
const damped = 0.55 * dx;
|
|
158
|
+
return clampNumber(damped, -limit, limit);
|
|
159
|
+
}
|
|
160
|
+
export { clampNumber, columnAt, dragPreview, g9CalendarSnap, grabOffset, locate, minuteAt, monthCellAt, previewBar, previewBoxes, samePreview, swipeDirection, swipeFollow, tapDraft };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
export { G9AgendaView, type G9AgendaViewProps, type G9CalendarEvent, G9DateInput, type G9DateInputProps, G9MiniMonth, type G9MiniMonthProps,
|
|
1
|
+
export { agendaRows, type G9AgendaLabels, G9AgendaView, type G9AgendaViewProps, type G9CalendarEvent, G9DateInput, type G9DateInputProps, G9MiniMonth, type G9MiniMonthProps, } from './calendar.js';
|
|
2
|
+
export { findCommonSlots, type G9BusySpan, G9EventCard, type G9EventCardLabels, type G9EventCardProps, type G9FindSlotsOptions, G9FindTime, type G9FindTimeLabels, type G9FindTimeProps, type G9FreeSlot, G9TodayWidget, type G9TodayWidgetLabels, type G9TodayWidgetProps, } from './cards.js';
|
|
3
|
+
export * from './events.js';
|
|
4
|
+
export * from './gesture.js';
|
|
2
5
|
export * from './model.js';
|
|
3
6
|
export { type G9MonthDay, G9MonthDayPicker, type G9MonthDayPickerProps, monthDayLength } from './month-day.js';
|
|
7
|
+
export { type G9MonthDraft, G9MonthView, type G9MonthViewProps } from './month-view.js';
|
|
8
|
+
export { birthdayFrom, birthdayIn, type G9Birthday, G9BirthdayField, type G9BirthdayFieldProps, type G9BirthdayLabels, G9WorkingHoursEditor, type G9WorkingHoursEditorProps, type G9WorkingHoursLabels, type G9WorkRange, type G9WorkWeek, } from './people.js';
|
|
9
|
+
export * from './recurrence.js';
|
|
10
|
+
export { type G9RepeatEditorLabels, G9RepeatPicker, type G9RepeatPickerProps } from './repeat-picker.js';
|
|
11
|
+
export { type G9TimeDraft, G9TimeGrid, type G9TimeGridProps } from './time-grid.js';
|
|
12
|
+
export { G9TimeListPicker, type G9TimeListPickerProps, timeLabel, timeSteps } from './time-list.js';
|
|
4
13
|
export { G9ZonePicker, type G9ZonePickerProps, zoneLabel, zoneOffsetLabel } from './zone-picker.js';
|
|
5
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,WAAW,EACX,KAAK,gBAAgB,EACrB,WAAW,EACX,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,WAAW,EACX,KAAK,gBAAgB,EACrB,WAAW,EACX,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,KAAK,UAAU,EACf,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,SAAS,CAAC;AACjB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,UAAU,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5G,OAAO,EAAE,KAAK,YAAY,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EACL,YAAY,EACZ,UAAU,EACV,KAAK,UAAU,EACf,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAClB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,KAAK,oBAAoB,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtG,OAAO,EAAE,KAAK,WAAW,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|