@g9tm/lynxcontrols-projects 0.0.0-stage → 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/README.md +23 -2
- package/catalog/cards/G9Board.md +17 -0
- package/catalog/cards/G9RuleBuilder.md +17 -0
- package/catalog/cards/G9TaskCard.md +17 -0
- package/catalog/cards/G9Timeline.md +17 -0
- package/catalog/catalog.json +1881 -0
- package/catalog/index.md +8 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/board.d.ts +47 -0
- package/dist/board.d.ts.map +1 -0
- package/dist/board.jsx +380 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.jsx +5 -0
- package/dist/model.d.ts +127 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.jsx +242 -0
- package/dist/projects.css +582 -0
- package/dist/projects.css.map +1 -0
- package/dist/rule-builder.d.ts +60 -0
- package/dist/rule-builder.d.ts.map +1 -0
- package/dist/rule-builder.jsx +145 -0
- package/dist/task-card.d.ts +54 -0
- package/dist/task-card.d.ts.map +1 -0
- package/dist/task-card.jsx +117 -0
- package/dist/timeline.d.ts +60 -0
- package/dist/timeline.d.ts.map +1 -0
- package/dist/timeline.jsx +389 -0
- package/package.json +36 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AACjB,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,SAAS,EACd,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.jsx
ADDED
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type G9CalendarSystem } from '@g9tm/lynxcontrols-foundation';
|
|
2
|
+
/** A card's box in a column, measured when a card is lifted (page px). */
|
|
3
|
+
export interface G9CardBox {
|
|
4
|
+
readonly key: string;
|
|
5
|
+
readonly top: number;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
}
|
|
8
|
+
/** A column's box and its cards, measured when a card is lifted. */
|
|
9
|
+
export interface G9ColumnBox {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly left: number;
|
|
12
|
+
readonly width: number;
|
|
13
|
+
readonly top: number;
|
|
14
|
+
readonly height: number;
|
|
15
|
+
/** Its scrollTop when measured. */
|
|
16
|
+
readonly scrollTop: number;
|
|
17
|
+
readonly cards: readonly G9CardBox[];
|
|
18
|
+
}
|
|
19
|
+
/** The board when a card was lifted. */
|
|
20
|
+
export interface G9BoardGeometry {
|
|
21
|
+
/** The board's own box (the lifted card's layer is inside it). */
|
|
22
|
+
readonly rootLeft: number;
|
|
23
|
+
readonly rootTop: number;
|
|
24
|
+
/** The columns scroller's visible box. */
|
|
25
|
+
readonly left: number;
|
|
26
|
+
readonly width: number;
|
|
27
|
+
/** Its scrollLeft when measured. */
|
|
28
|
+
readonly scrollLeft: number;
|
|
29
|
+
readonly columns: readonly G9ColumnBox[];
|
|
30
|
+
}
|
|
31
|
+
/** Where a lifted card would land. */
|
|
32
|
+
export interface G9DropTarget {
|
|
33
|
+
readonly column: string;
|
|
34
|
+
readonly index: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Where a card held at (`x`, `y`) would drop: the column under the finger (the nearest in a gap or past the ends) and
|
|
38
|
+
* the index among its cards without the lifted one. `scrollLeft` and `columnScroll` are the scroll positions now.
|
|
39
|
+
*/
|
|
40
|
+
export declare function boardDropTarget(geo: G9BoardGeometry, x: number, y: number, scrollLeft: number, columnScroll: Readonly<Record<string, number>>, dragged: string): G9DropTarget | null;
|
|
41
|
+
/** {@link boardDropTarget} on the main thread. */
|
|
42
|
+
export declare function boardDropTargetMT(geo: G9BoardGeometry, x: number, y: number, scrollLeft: number, columnScroll: Readonly<Record<string, number>>, dragged: string): G9DropTarget | null;
|
|
43
|
+
/**
|
|
44
|
+
* The auto-scroll speed (px/s) for a pointer at `position` along a scroller over [`start`, `end`]: negative within
|
|
45
|
+
* `zone` of the start, positive near the end, faster closer to the edge; 0 elsewhere (and in a scroller too small).
|
|
46
|
+
*/
|
|
47
|
+
export declare function edgeRate(position: number, start: number, end: number, zone?: number, max?: number): number;
|
|
48
|
+
/** {@link edgeRate} on the main thread. */
|
|
49
|
+
export declare function edgeRateMT(position: number, start: number, end: number, zone?: number, max?: number): number;
|
|
50
|
+
/** A column's width: at least `min(264, 82% of the window)`, sharing the pane when it is wide, at most 384. */
|
|
51
|
+
export declare function boardColumnWidth(paneWidth: number, windowWidth: number, padding: number, gap: number, count: number): number;
|
|
52
|
+
/** The keys of a column after `key` moves to `index` in it (it leaves its old place first). */
|
|
53
|
+
export declare function moveKey(keys: readonly string[], key: string, index: number): string[];
|
|
54
|
+
/** How wide a day is: a week ≈ 280, 112 or 35 px. */
|
|
55
|
+
export type G9TimelineZoom = 'week' | 'month' | 'quarter';
|
|
56
|
+
/** Pixels per day at each zoom. */
|
|
57
|
+
export declare const g9TimelineZoomPx: Readonly<Record<G9TimelineZoom, number>>;
|
|
58
|
+
/** A bar: its first and last day (epoch days), inclusive. */
|
|
59
|
+
export interface G9DaySpan {
|
|
60
|
+
readonly start: number;
|
|
61
|
+
readonly end: number;
|
|
62
|
+
}
|
|
63
|
+
/** The chart's scale: the day at x = 0, the px of a day and how many days it covers. */
|
|
64
|
+
export interface G9TimelineScale {
|
|
65
|
+
readonly origin: number;
|
|
66
|
+
readonly pxPerDay: number;
|
|
67
|
+
readonly days: number;
|
|
68
|
+
}
|
|
69
|
+
/** A scale over [from, to] at a zoom (or a px per day). */
|
|
70
|
+
export declare function timelineScale(from: number, to: number, zoom: G9TimelineZoom | number): G9TimelineScale;
|
|
71
|
+
/** A day's logical x (from the reading start). */
|
|
72
|
+
export declare function dayToX(day: number, scale: G9TimelineScale): number;
|
|
73
|
+
/** The day under a logical x. */
|
|
74
|
+
export declare function xToDay(x: number, scale: G9TimelineScale): number;
|
|
75
|
+
/** The chart's width in px. */
|
|
76
|
+
export declare function timelineWidth(scale: G9TimelineScale): number;
|
|
77
|
+
/** A movement in whole days (half a day or more rounds). */
|
|
78
|
+
export declare function snapDays(dx: number, pxPerDay: number): number;
|
|
79
|
+
/** {@link snapDays} on the main thread. */
|
|
80
|
+
export declare function snapDaysMT(dx: number, pxPerDay: number): number;
|
|
81
|
+
/** What a bar drag does: move it, or one of its ends. */
|
|
82
|
+
export type G9SpanDrag = 'move' | 'start' | 'end';
|
|
83
|
+
/** A span after a drag of `delta` days (an end never passes the other). */
|
|
84
|
+
export declare function dragSpan(span: G9DaySpan, mode: G9SpanDrag, delta: number): G9DaySpan;
|
|
85
|
+
/** {@link dragSpan} on the main thread (start and end apart, so no object crosses). */
|
|
86
|
+
export declare function dragSpanMT(start: number, end: number, mode: G9SpanDrag, delta: number): [number, number];
|
|
87
|
+
/** A span from a start and/or an end (one day when only one is set; null when neither is). */
|
|
88
|
+
export declare function spanOf(start: number | null | undefined, end: number | null | undefined): G9DaySpan | null;
|
|
89
|
+
/** 0 Sunday … 6 Saturday. */
|
|
90
|
+
export declare function weekdayOf(day: number): number;
|
|
91
|
+
/** The first day of the week `day` is in. */
|
|
92
|
+
export declare function weekStartOf(day: number, weekStartsOn: number): number;
|
|
93
|
+
/** What to draw: every span and today, padded by the zoom, starting on a week's first day. */
|
|
94
|
+
export declare function timelineRange(spans: readonly G9DaySpan[], today: number, weekStartsOn: number, zoom: G9TimelineZoom): {
|
|
95
|
+
readonly from: number;
|
|
96
|
+
readonly to: number;
|
|
97
|
+
};
|
|
98
|
+
/** The first day of the month `day` is in, on a calendar. */
|
|
99
|
+
export declare function monthStartOf(day: number, calendar: G9CalendarSystem): number;
|
|
100
|
+
/** The first day of the next month. */
|
|
101
|
+
export declare function nextMonthStart(day: number, calendar: G9CalendarSystem): number;
|
|
102
|
+
/** The first days of the months over [from, to] (from's own month first). */
|
|
103
|
+
export declare function monthStarts(from: number, to: number, calendar: G9CalendarSystem): number[];
|
|
104
|
+
/** The first days of the weeks over [from, to]. */
|
|
105
|
+
export declare function weekStarts(from: number, to: number, weekStartsOn: number): number[];
|
|
106
|
+
/** The physical left of a logical [x, x + w) in a chart `width` wide (mirrored right to left). */
|
|
107
|
+
export declare function physicalLeft(x: number, w: number, width: number, rtl: boolean): number;
|
|
108
|
+
/** The scroll offset that puts logical `x` a third into the visible window. */
|
|
109
|
+
export declare function scrollForX(x: number, viewWidth: number, width: number, rtl: boolean): number;
|
|
110
|
+
/** A straight piece of a dependency arrow (logical px): horizontal (`w`) or vertical (`h`). */
|
|
111
|
+
export interface G9Segment {
|
|
112
|
+
readonly x: number;
|
|
113
|
+
readonly y: number;
|
|
114
|
+
readonly w: number;
|
|
115
|
+
readonly h: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A «blocked by» arrow from the blocker's end (x1, y1) to the task's start (x2, y2): across, down or up, across — or
|
|
119
|
+
* around the row's edge when the task starts before the blocker ends.
|
|
120
|
+
*/
|
|
121
|
+
export declare function linkSegments(x1: number, y1: number, x2: number, y2: number, rowHeight: number): G9Segment[];
|
|
122
|
+
/** The rows to draw for a vertical scroll (fixed row height, `overscan` on both sides). */
|
|
123
|
+
export declare function rowWindow(scrollTop: number, viewHeight: number, rowHeight: number, count: number, overscan?: number): {
|
|
124
|
+
readonly first: number;
|
|
125
|
+
readonly last: number;
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 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,kGAAkG;AAClG,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAEtF;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAK5F;AAED,+FAA+F;AAC/F,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,CAY3G;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,SAAI,GACX;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAKnD"}
|
package/dist/model.jsx
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { daysInMonth, fromCalendarDate, fromEpochDays, toCalendarDate, toEpochDays } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
+
function dropTargetOf(geo, x, y, scrollLeft, columnScroll, dragged) {
|
|
3
|
+
var _columnScroll_best_id;
|
|
4
|
+
const shift = scrollLeft - geo.scrollLeft;
|
|
5
|
+
let best = null;
|
|
6
|
+
let bestDistance = 1 / 0;
|
|
7
|
+
for (const column of geo.columns){
|
|
8
|
+
const left = column.left - shift;
|
|
9
|
+
const right = left + column.width;
|
|
10
|
+
const distance = x < left ? left - x : x > right ? x - right : 0;
|
|
11
|
+
if (distance < bestDistance) {
|
|
12
|
+
best = column;
|
|
13
|
+
bestDistance = distance;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (!best) return null;
|
|
17
|
+
const scrolled = (null != (_columnScroll_best_id = columnScroll[best.id]) ? _columnScroll_best_id : best.scrollTop) - best.scrollTop;
|
|
18
|
+
const cards = best.cards.filter((c)=>c.key !== dragged);
|
|
19
|
+
let index = cards.length;
|
|
20
|
+
for(let i = 0; i < cards.length; i++){
|
|
21
|
+
const c = cards[i];
|
|
22
|
+
if (y < c.top - scrolled + c.height / 2) {
|
|
23
|
+
index = i;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
column: best.id,
|
|
29
|
+
index
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function boardDropTarget(geo, x, y, scrollLeft, columnScroll, dragged) {
|
|
33
|
+
return dropTargetOf(geo, x, y, scrollLeft, columnScroll, dragged);
|
|
34
|
+
}
|
|
35
|
+
function boardDropTargetMT(geo, x, y, scrollLeft, columnScroll, dragged) {
|
|
36
|
+
'main thread';
|
|
37
|
+
var _columnScroll_best_id;
|
|
38
|
+
const shift = scrollLeft - geo.scrollLeft;
|
|
39
|
+
let best = null;
|
|
40
|
+
let bestDistance = 1 / 0;
|
|
41
|
+
for (const column of geo.columns){
|
|
42
|
+
const left = column.left - shift;
|
|
43
|
+
const right = left + column.width;
|
|
44
|
+
const distance = x < left ? left - x : x > right ? x - right : 0;
|
|
45
|
+
if (distance < bestDistance) {
|
|
46
|
+
best = column;
|
|
47
|
+
bestDistance = distance;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!best) return null;
|
|
51
|
+
const scrolled = (null != (_columnScroll_best_id = columnScroll[best.id]) ? _columnScroll_best_id : best.scrollTop) - best.scrollTop;
|
|
52
|
+
const cards = best.cards.filter((c)=>c.key !== dragged);
|
|
53
|
+
let index = cards.length;
|
|
54
|
+
for(let i = 0; i < cards.length; i++){
|
|
55
|
+
const c = cards[i];
|
|
56
|
+
if (y < c.top - scrolled + c.height / 2) {
|
|
57
|
+
index = i;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
column: best.id,
|
|
63
|
+
index
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function edgeRate(position, start, end, zone = 56, max = 900) {
|
|
67
|
+
if (end - start < 2 * zone) return 0;
|
|
68
|
+
if (position < start + zone) return -Math.round(max * Math.min(1, (start + zone - position) / zone));
|
|
69
|
+
if (position > end - zone) return Math.round(max * Math.min(1, (position - (end - zone)) / zone));
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
function edgeRateMT(position, start, end, zone = 56, max = 900) {
|
|
73
|
+
'main thread';
|
|
74
|
+
if (end - start < 2 * zone) return 0;
|
|
75
|
+
if (position < start + zone) return -Math.round(max * Math.min(1, (start + zone - position) / zone));
|
|
76
|
+
if (position > end - zone) return Math.round(max * Math.min(1, (position - (end - zone)) / zone));
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
function boardColumnWidth(paneWidth, windowWidth, padding, gap, count) {
|
|
80
|
+
const basis = Math.min(264, Math.round(0.82 * windowWidth));
|
|
81
|
+
const shared = Math.floor((paneWidth - 2 * padding - gap * (Math.max(1, count) - 1)) / Math.max(1, count));
|
|
82
|
+
return Math.max(basis, Math.min(384, shared));
|
|
83
|
+
}
|
|
84
|
+
function moveKey(keys, key, index) {
|
|
85
|
+
const rest = keys.filter((k)=>k !== key);
|
|
86
|
+
const at = Math.max(0, Math.min(index, rest.length));
|
|
87
|
+
return [
|
|
88
|
+
...rest.slice(0, at),
|
|
89
|
+
key,
|
|
90
|
+
...rest.slice(at)
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
const g9TimelineZoomPx = Object.freeze({
|
|
94
|
+
week: 40,
|
|
95
|
+
month: 16,
|
|
96
|
+
quarter: 5
|
|
97
|
+
});
|
|
98
|
+
function timelineScale(from, to, zoom) {
|
|
99
|
+
return {
|
|
100
|
+
origin: from,
|
|
101
|
+
pxPerDay: 'number' == typeof zoom ? zoom : g9TimelineZoomPx[zoom],
|
|
102
|
+
days: Math.max(1, to - from + 1)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function dayToX(day, scale) {
|
|
106
|
+
return (day - scale.origin) * scale.pxPerDay;
|
|
107
|
+
}
|
|
108
|
+
function xToDay(x, scale) {
|
|
109
|
+
return scale.origin + Math.floor(x / scale.pxPerDay);
|
|
110
|
+
}
|
|
111
|
+
function timelineWidth(scale) {
|
|
112
|
+
return scale.days * scale.pxPerDay;
|
|
113
|
+
}
|
|
114
|
+
function snapDays(dx, pxPerDay) {
|
|
115
|
+
return Math.round(dx / pxPerDay) || 0;
|
|
116
|
+
}
|
|
117
|
+
function snapDaysMT(dx, pxPerDay) {
|
|
118
|
+
'main thread';
|
|
119
|
+
return Math.round(dx / pxPerDay) || 0;
|
|
120
|
+
}
|
|
121
|
+
function dragSpan(span, mode, delta) {
|
|
122
|
+
if ('move' === mode) return {
|
|
123
|
+
start: span.start + delta,
|
|
124
|
+
end: span.end + delta
|
|
125
|
+
};
|
|
126
|
+
if ('start' === mode) return {
|
|
127
|
+
start: Math.min(span.start + delta, span.end),
|
|
128
|
+
end: span.end
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
start: span.start,
|
|
132
|
+
end: Math.max(span.end + delta, span.start)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function dragSpanMT(start, end, mode, delta) {
|
|
136
|
+
'main thread';
|
|
137
|
+
if ('move' === mode) return [
|
|
138
|
+
start + delta,
|
|
139
|
+
end + delta
|
|
140
|
+
];
|
|
141
|
+
if ('start' === mode) return [
|
|
142
|
+
Math.min(start + delta, end),
|
|
143
|
+
end
|
|
144
|
+
];
|
|
145
|
+
return [
|
|
146
|
+
start,
|
|
147
|
+
Math.max(end + delta, start)
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
function spanOf(start, end) {
|
|
151
|
+
const s = null != start ? start : null;
|
|
152
|
+
const e = null != end ? end : null;
|
|
153
|
+
if (null === s && null === e) return null;
|
|
154
|
+
const first = null != s ? s : e;
|
|
155
|
+
return {
|
|
156
|
+
start: first,
|
|
157
|
+
end: Math.max(first, null != e ? e : first)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function weekdayOf(day) {
|
|
161
|
+
return ((day + 4) % 7 + 7) % 7;
|
|
162
|
+
}
|
|
163
|
+
function weekStartOf(day, weekStartsOn) {
|
|
164
|
+
return day - (weekdayOf(day) - weekStartsOn + 7) % 7;
|
|
165
|
+
}
|
|
166
|
+
function timelineRange(spans, today, weekStartsOn, zoom) {
|
|
167
|
+
const pad = 'week' === zoom ? 14 : 'month' === zoom ? 30 : 60;
|
|
168
|
+
let from = today;
|
|
169
|
+
let to = today;
|
|
170
|
+
for (const s of spans){
|
|
171
|
+
from = Math.min(from, s.start);
|
|
172
|
+
to = Math.max(to, s.end);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
from: weekStartOf(from - pad, weekStartsOn),
|
|
176
|
+
to: to + 2 * pad
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function monthStartOf(day, calendar) {
|
|
180
|
+
const c = toCalendarDate(fromEpochDays(day), calendar);
|
|
181
|
+
return toEpochDays(fromCalendarDate({
|
|
182
|
+
...c,
|
|
183
|
+
day: 1
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
function nextMonthStart(day, calendar) {
|
|
187
|
+
const c = toCalendarDate(fromEpochDays(day), calendar);
|
|
188
|
+
return monthStartOf(day, calendar) + daysInMonth(calendar, c.year, c.month);
|
|
189
|
+
}
|
|
190
|
+
function monthStarts(from, to, calendar) {
|
|
191
|
+
const out = [];
|
|
192
|
+
for(let d = monthStartOf(from, calendar); d <= to; d = nextMonthStart(d, calendar))out.push(d);
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
function weekStarts(from, to, weekStartsOn) {
|
|
196
|
+
const out = [];
|
|
197
|
+
for(let d = weekStartOf(from, weekStartsOn); d <= to; d += 7)out.push(d);
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
function physicalLeft(x, w, width, rtl) {
|
|
201
|
+
return rtl ? width - x - w : x;
|
|
202
|
+
}
|
|
203
|
+
function scrollForX(x, viewWidth, width, rtl) {
|
|
204
|
+
const max = Math.max(0, width - viewWidth);
|
|
205
|
+
const start = Math.max(0, x - viewWidth / 3);
|
|
206
|
+
const offset = rtl ? width - viewWidth - start : start;
|
|
207
|
+
return Math.round(Math.max(0, Math.min(max, offset)));
|
|
208
|
+
}
|
|
209
|
+
function linkSegments(x1, y1, x2, y2, rowHeight) {
|
|
210
|
+
const across = (a, b, y)=>({
|
|
211
|
+
x: Math.min(a, b),
|
|
212
|
+
y,
|
|
213
|
+
w: Math.abs(b - a),
|
|
214
|
+
h: 0
|
|
215
|
+
});
|
|
216
|
+
const down = (x, a, b)=>({
|
|
217
|
+
x,
|
|
218
|
+
y: Math.min(a, b),
|
|
219
|
+
w: 0,
|
|
220
|
+
h: Math.abs(b - a)
|
|
221
|
+
});
|
|
222
|
+
if (x2 - 10 >= x1 + 6) return [
|
|
223
|
+
across(x1, x1 + 6, y1),
|
|
224
|
+
down(x1 + 6, y1, y2),
|
|
225
|
+
across(x1 + 6, x2 - 2, y2)
|
|
226
|
+
];
|
|
227
|
+
const turn = y2 - Math.sign(y2 - y1 || 1) * (rowHeight / 2 - 4);
|
|
228
|
+
return [
|
|
229
|
+
across(x1, x1 + 6, y1),
|
|
230
|
+
down(x1 + 6, y1, turn),
|
|
231
|
+
across(x1 + 6, x2 - 10, turn),
|
|
232
|
+
down(x2 - 10, turn, y2),
|
|
233
|
+
across(x2 - 10, x2 - 2, y2)
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
function rowWindow(scrollTop, viewHeight, rowHeight, count, overscan = 6) {
|
|
237
|
+
return {
|
|
238
|
+
first: Math.max(0, Math.floor(scrollTop / rowHeight) - overscan),
|
|
239
|
+
last: Math.min(count, Math.ceil((scrollTop + viewHeight) / rowHeight) + overscan)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
export { boardColumnWidth, boardDropTarget, boardDropTargetMT, dayToX, dragSpan, dragSpanMT, edgeRate, edgeRateMT, g9TimelineZoomPx, linkSegments, monthStartOf, monthStarts, moveKey, nextMonthStart, physicalLeft, rowWindow, scrollForX, snapDays, snapDaysMT, spanOf, timelineRange, timelineScale, timelineWidth, weekStartOf, weekStarts, weekdayOf, xToDay };
|