awesome-timeline-react 0.8.0 → 0.10.0
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/dist/_tsup-dts-rollup.d.mts +18 -1
- package/dist/_tsup-dts-rollup.d.ts +18 -1
- package/dist/index.js +53 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -452,11 +452,15 @@ export declare type Geometry = {
|
|
|
452
452
|
staticEventBaseHeight: number;
|
|
453
453
|
/** event bar corner radius */
|
|
454
454
|
barRadius: number;
|
|
455
|
+
/** narrowest an event's hover/click rect is (see Theme.minHitWidth) */
|
|
456
|
+
minHitWidth: number;
|
|
455
457
|
};
|
|
456
458
|
|
|
457
459
|
/** Derive the full Geometry from the resolved theme's geometry tokens. */
|
|
458
460
|
export declare const geometryFromTheme: (theme: ResolvedTheme) => Geometry;
|
|
459
461
|
|
|
462
|
+
declare type HeaderToken = "headerBackground" | "headerTextColor" | "headerBorderColor" | "headerShadow" | "borderColor";
|
|
463
|
+
|
|
460
464
|
export declare type HitTarget = {
|
|
461
465
|
kind: "event" | "static";
|
|
462
466
|
event: EventType;
|
|
@@ -655,7 +659,7 @@ export declare type ResizePreview = {
|
|
|
655
659
|
direction: "left" | "right";
|
|
656
660
|
};
|
|
657
661
|
|
|
658
|
-
declare type ResolvedTheme = Required<Omit<Theme, "font">> & Pick<Theme, "font">;
|
|
662
|
+
declare type ResolvedTheme = Required<Omit<Theme, "font" | HeaderToken>> & Pick<Theme, "font" | HeaderToken>;
|
|
659
663
|
export { ResolvedTheme }
|
|
660
664
|
export { ResolvedTheme as ResolvedTheme_alias_1 }
|
|
661
665
|
|
|
@@ -836,6 +840,10 @@ declare type Theme = {
|
|
|
836
840
|
rowPaddingY?: number;
|
|
837
841
|
/** event bar corner radius in px (default 5) */
|
|
838
842
|
barRadius?: number;
|
|
843
|
+
/** narrowest an event is for hover and click, in px, centred on it (default 0): a short event
|
|
844
|
+
* — a milestone, a mark drawn wider than its time — stays hoverable at any zoom. Drawing is
|
|
845
|
+
* unaffected. */
|
|
846
|
+
minHitWidth?: number;
|
|
839
847
|
/** faint fill laid over the child-row block of an expanded group so it reads
|
|
840
848
|
* as recessed beneath its parent row (default "rgba(0,0,0,0.05)"). Also used
|
|
841
849
|
* to tint child row headers. */
|
|
@@ -845,6 +853,15 @@ declare type Theme = {
|
|
|
845
853
|
* "rgba(0,0,0,0.22)"). Also tints the header tree connector lines if no
|
|
846
854
|
* gridColor contrast is desired. */
|
|
847
855
|
groupShadowColor?: string;
|
|
856
|
+
/** the row-header column and the time bar: background, text, their borders and the column's row
|
|
857
|
+
* dividers, and the column's shadow onto the rows ("none" for none). Unset, the stylesheet's
|
|
858
|
+
* dark header with yellow borders applies. */
|
|
859
|
+
headerBackground?: string;
|
|
860
|
+
headerTextColor?: string;
|
|
861
|
+
headerBorderColor?: string;
|
|
862
|
+
headerShadow?: string;
|
|
863
|
+
/** the frame around the rows; unset, the stylesheet's black applies */
|
|
864
|
+
borderColor?: string;
|
|
848
865
|
};
|
|
849
866
|
export { Theme }
|
|
850
867
|
export { Theme as Theme_alias_1 }
|
|
@@ -452,11 +452,15 @@ export declare type Geometry = {
|
|
|
452
452
|
staticEventBaseHeight: number;
|
|
453
453
|
/** event bar corner radius */
|
|
454
454
|
barRadius: number;
|
|
455
|
+
/** narrowest an event's hover/click rect is (see Theme.minHitWidth) */
|
|
456
|
+
minHitWidth: number;
|
|
455
457
|
};
|
|
456
458
|
|
|
457
459
|
/** Derive the full Geometry from the resolved theme's geometry tokens. */
|
|
458
460
|
export declare const geometryFromTheme: (theme: ResolvedTheme) => Geometry;
|
|
459
461
|
|
|
462
|
+
declare type HeaderToken = "headerBackground" | "headerTextColor" | "headerBorderColor" | "headerShadow" | "borderColor";
|
|
463
|
+
|
|
460
464
|
export declare type HitTarget = {
|
|
461
465
|
kind: "event" | "static";
|
|
462
466
|
event: EventType;
|
|
@@ -655,7 +659,7 @@ export declare type ResizePreview = {
|
|
|
655
659
|
direction: "left" | "right";
|
|
656
660
|
};
|
|
657
661
|
|
|
658
|
-
declare type ResolvedTheme = Required<Omit<Theme, "font">> & Pick<Theme, "font">;
|
|
662
|
+
declare type ResolvedTheme = Required<Omit<Theme, "font" | HeaderToken>> & Pick<Theme, "font" | HeaderToken>;
|
|
659
663
|
export { ResolvedTheme }
|
|
660
664
|
export { ResolvedTheme as ResolvedTheme_alias_1 }
|
|
661
665
|
|
|
@@ -836,6 +840,10 @@ declare type Theme = {
|
|
|
836
840
|
rowPaddingY?: number;
|
|
837
841
|
/** event bar corner radius in px (default 5) */
|
|
838
842
|
barRadius?: number;
|
|
843
|
+
/** narrowest an event is for hover and click, in px, centred on it (default 0): a short event
|
|
844
|
+
* — a milestone, a mark drawn wider than its time — stays hoverable at any zoom. Drawing is
|
|
845
|
+
* unaffected. */
|
|
846
|
+
minHitWidth?: number;
|
|
839
847
|
/** faint fill laid over the child-row block of an expanded group so it reads
|
|
840
848
|
* as recessed beneath its parent row (default "rgba(0,0,0,0.05)"). Also used
|
|
841
849
|
* to tint child row headers. */
|
|
@@ -845,6 +853,15 @@ declare type Theme = {
|
|
|
845
853
|
* "rgba(0,0,0,0.22)"). Also tints the header tree connector lines if no
|
|
846
854
|
* gridColor contrast is desired. */
|
|
847
855
|
groupShadowColor?: string;
|
|
856
|
+
/** the row-header column and the time bar: background, text, their borders and the column's row
|
|
857
|
+
* dividers, and the column's shadow onto the rows ("none" for none). Unset, the stylesheet's
|
|
858
|
+
* dark header with yellow borders applies. */
|
|
859
|
+
headerBackground?: string;
|
|
860
|
+
headerTextColor?: string;
|
|
861
|
+
headerBorderColor?: string;
|
|
862
|
+
headerShadow?: string;
|
|
863
|
+
/** the frame around the rows; unset, the stylesheet's black applies */
|
|
864
|
+
borderColor?: string;
|
|
848
865
|
};
|
|
849
866
|
export { Theme }
|
|
850
867
|
export { Theme as Theme_alias_1 }
|
package/dist/index.js
CHANGED
|
@@ -467,6 +467,7 @@ var DEFAULT_THEME = {
|
|
|
467
467
|
laneGap: 2,
|
|
468
468
|
rowPaddingY: 10,
|
|
469
469
|
barRadius: 5,
|
|
470
|
+
minHitWidth: 0,
|
|
470
471
|
groupChildBackground: "rgba(0,0,0,0.05)",
|
|
471
472
|
groupShadowColor: "rgba(0,0,0,0.22)"
|
|
472
473
|
};
|
|
@@ -557,8 +558,9 @@ var CanvasTimeBar = ({
|
|
|
557
558
|
theme,
|
|
558
559
|
timeBar
|
|
559
560
|
}) => {
|
|
560
|
-
var _a, _b;
|
|
561
|
+
var _a, _b, _c;
|
|
561
562
|
const canvasRef = (0, import_react4.useRef)(null);
|
|
563
|
+
const header = theme != null ? theme : DEFAULT_THEME;
|
|
562
564
|
const topRow = (_a = timeBar == null ? void 0 : timeBar.topRow) != null ? _a : { unit: "day" };
|
|
563
565
|
const bottomRow = (_b = timeBar == null ? void 0 : timeBar.bottomRow) != null ? _b : { unit: "hour" };
|
|
564
566
|
(0, import_react4.useEffect)(() => {
|
|
@@ -587,24 +589,33 @@ var CanvasTimeBar = ({
|
|
|
587
589
|
}))
|
|
588
590
|
});
|
|
589
591
|
}, [windowTime, tick, contentWidth, theme, timeBar]);
|
|
590
|
-
return /* @__PURE__ */ import_react4.default.createElement(
|
|
591
|
-
"canvas",
|
|
592
|
-
{
|
|
593
|
-
ref: canvasRef,
|
|
594
|
-
className: "canvas-time-bar",
|
|
595
|
-
style: { minWidth: contentWidth ? contentWidth : 0 }
|
|
596
|
-
}
|
|
597
|
-
), scrollWidth ? /* @__PURE__ */ import_react4.default.createElement(
|
|
592
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
598
593
|
"div",
|
|
599
594
|
{
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
595
|
+
className: "time-bar",
|
|
596
|
+
style: { background: header.headerBackground, color: header.headerTextColor, borderColor: header.headerBorderColor }
|
|
597
|
+
},
|
|
598
|
+
/* @__PURE__ */ import_react4.default.createElement("div", { className: "empty-block", style: { borderRightColor: header.headerBorderColor } }),
|
|
599
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
600
|
+
"canvas",
|
|
601
|
+
{
|
|
602
|
+
ref: canvasRef,
|
|
603
|
+
className: "canvas-time-bar",
|
|
604
|
+
style: { minWidth: contentWidth ? contentWidth : 0 }
|
|
605
605
|
}
|
|
606
|
-
|
|
607
|
-
|
|
606
|
+
),
|
|
607
|
+
scrollWidth ? /* @__PURE__ */ import_react4.default.createElement(
|
|
608
|
+
"div",
|
|
609
|
+
{
|
|
610
|
+
style: {
|
|
611
|
+
width: scrollWidth,
|
|
612
|
+
height: "100%",
|
|
613
|
+
boxSizing: "border-box",
|
|
614
|
+
borderLeft: `1px solid ${(_c = header.headerBorderColor) != null ? _c : "yellow"}`
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
) : null
|
|
618
|
+
);
|
|
608
619
|
};
|
|
609
620
|
var canvas_time_bar_default = CanvasTimeBar;
|
|
610
621
|
|
|
@@ -682,7 +693,8 @@ var DEFAULT_GEOMETRY = {
|
|
|
682
693
|
laneTopOffset: 10,
|
|
683
694
|
rowBaseHeight: 40,
|
|
684
695
|
staticEventBaseHeight: 20,
|
|
685
|
-
barRadius: 5
|
|
696
|
+
barRadius: 5,
|
|
697
|
+
minHitWidth: 0
|
|
686
698
|
};
|
|
687
699
|
var geometryFromTheme = (theme) => {
|
|
688
700
|
const barHeight = theme.barHeight;
|
|
@@ -693,7 +705,8 @@ var geometryFromTheme = (theme) => {
|
|
|
693
705
|
laneTopOffset: rowPaddingY,
|
|
694
706
|
rowBaseHeight: barHeight + 2 * rowPaddingY,
|
|
695
707
|
staticEventBaseHeight: barHeight,
|
|
696
|
-
barRadius: theme.barRadius
|
|
708
|
+
barRadius: theme.barRadius,
|
|
709
|
+
minHitWidth: theme.minHitWidth
|
|
697
710
|
};
|
|
698
711
|
};
|
|
699
712
|
|
|
@@ -1242,7 +1255,8 @@ var hitTest = (scene, view, x, y) => {
|
|
|
1242
1255
|
width: timeToWidth(event.startTime, event.endTime, tick),
|
|
1243
1256
|
height: geometry.barHeight
|
|
1244
1257
|
};
|
|
1245
|
-
|
|
1258
|
+
const hit = rect.width >= geometry.minHitWidth ? rect : __spreadProps(__spreadValues({}, rect), { x: rect.x + (rect.width - geometry.minHitWidth) / 2, width: geometry.minHitWidth });
|
|
1259
|
+
if (rectContains(hit, x, y)) {
|
|
1246
1260
|
return { kind: "event", event, rowId, rect };
|
|
1247
1261
|
}
|
|
1248
1262
|
}
|
|
@@ -2002,6 +2016,7 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2002
2016
|
applySelection,
|
|
2003
2017
|
getSelection
|
|
2004
2018
|
}, contentRef) => {
|
|
2019
|
+
var _a;
|
|
2005
2020
|
const staticCanvasRef = (0, import_react6.useRef)(null);
|
|
2006
2021
|
const dynamicCanvasRef = (0, import_react6.useRef)(null);
|
|
2007
2022
|
const ghostRef = (0, import_react6.useRef)(null);
|
|
@@ -2024,8 +2039,8 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2024
2039
|
};
|
|
2025
2040
|
}, [scene, rendererRef]);
|
|
2026
2041
|
(0, import_react6.useEffect)(() => {
|
|
2027
|
-
var
|
|
2028
|
-
(
|
|
2042
|
+
var _a2, _b;
|
|
2043
|
+
(_a2 = rendererRef.current) == null ? void 0 : _a2.animator.setDurations(
|
|
2029
2044
|
animations.layoutMs,
|
|
2030
2045
|
animations.fadeMs
|
|
2031
2046
|
);
|
|
@@ -2050,14 +2065,14 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2050
2065
|
rendererRef
|
|
2051
2066
|
]);
|
|
2052
2067
|
const measureViewport = (0, import_react6.useCallback)(() => {
|
|
2053
|
-
var
|
|
2068
|
+
var _a2;
|
|
2054
2069
|
const column = contentRef && "current" in contentRef ? contentRef.current : null;
|
|
2055
2070
|
const body = bodyRef.current;
|
|
2056
2071
|
if (!column || !body) return;
|
|
2057
2072
|
const cap = totalHeightRef.current > 0 ? totalHeightRef.current : Infinity;
|
|
2058
2073
|
const height = Math.min(body.clientHeight, cap, window.innerHeight);
|
|
2059
2074
|
setViewportHeight(height);
|
|
2060
|
-
(
|
|
2075
|
+
(_a2 = rendererRef.current) == null ? void 0 : _a2.setView({
|
|
2061
2076
|
width: column.getBoundingClientRect().width,
|
|
2062
2077
|
height
|
|
2063
2078
|
});
|
|
@@ -2076,8 +2091,8 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2076
2091
|
const body = bodyRef.current;
|
|
2077
2092
|
if (!body) return;
|
|
2078
2093
|
const handleScroll = () => {
|
|
2079
|
-
var
|
|
2080
|
-
(
|
|
2094
|
+
var _a2;
|
|
2095
|
+
(_a2 = rendererRef.current) == null ? void 0 : _a2.setView({ scrollTop: body.scrollTop });
|
|
2081
2096
|
setScrollTop(body.scrollTop);
|
|
2082
2097
|
};
|
|
2083
2098
|
body.addEventListener("scroll", handleScroll, { passive: true });
|
|
@@ -2102,14 +2117,14 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2102
2117
|
wrapper.appendChild(measurer);
|
|
2103
2118
|
let lastWidth = -1;
|
|
2104
2119
|
const measure = () => {
|
|
2105
|
-
var
|
|
2120
|
+
var _a2;
|
|
2106
2121
|
const width = wrapper.clientWidth;
|
|
2107
2122
|
if (width === 0 || width === lastWidth) return;
|
|
2108
2123
|
lastWidth = width;
|
|
2109
2124
|
measurer.style.width = `${width}px`;
|
|
2110
2125
|
const heights = /* @__PURE__ */ new Map();
|
|
2111
2126
|
for (const row of rows) {
|
|
2112
|
-
measurer.textContent = (
|
|
2127
|
+
measurer.textContent = (_a2 = row.name) != null ? _a2 : "";
|
|
2113
2128
|
heights.set(
|
|
2114
2129
|
row.id,
|
|
2115
2130
|
Math.ceil(measurer.offsetHeight) + 2 * theme.rowPaddingY
|
|
@@ -2180,8 +2195,8 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2180
2195
|
getSelection
|
|
2181
2196
|
});
|
|
2182
2197
|
(0, import_react6.useEffect)(() => {
|
|
2183
|
-
var
|
|
2184
|
-
(
|
|
2198
|
+
var _a2;
|
|
2199
|
+
(_a2 = rendererRef.current) == null ? void 0 : _a2.setView({
|
|
2185
2200
|
selectedEventIds: new Set(getSelection())
|
|
2186
2201
|
});
|
|
2187
2202
|
}, [getSelection, rendererRef]);
|
|
@@ -2220,7 +2235,7 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2220
2235
|
style: {
|
|
2221
2236
|
top,
|
|
2222
2237
|
height,
|
|
2223
|
-
borderBottom: i === rows.length - 1 ? "none" :
|
|
2238
|
+
borderBottom: i === rows.length - 1 ? "none" : `1px solid ${(_a = theme.headerBorderColor) != null ? _a : "yellow"}`,
|
|
2224
2239
|
// Row heights/positions apply instantly (no layout tween) so the
|
|
2225
2240
|
// header snaps in lockstep with its canvas row — see draw-events.
|
|
2226
2241
|
// Grouped rows left-align so the caret + tree spine line up; plain
|
|
@@ -2294,7 +2309,13 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2294
2309
|
{
|
|
2295
2310
|
ref: headerWrapperRef,
|
|
2296
2311
|
className: headerClassNames,
|
|
2297
|
-
style: {
|
|
2312
|
+
style: {
|
|
2313
|
+
height: totalHeight,
|
|
2314
|
+
background: theme.headerBackground,
|
|
2315
|
+
color: theme.headerTextColor,
|
|
2316
|
+
borderRightColor: theme.headerBorderColor,
|
|
2317
|
+
boxShadow: theme.headerShadow
|
|
2318
|
+
}
|
|
2298
2319
|
},
|
|
2299
2320
|
visibleHeaders,
|
|
2300
2321
|
renderRowLabel && // off-screen: renders every row's custom header so its natural height can be measured
|
|
@@ -3053,7 +3074,7 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
3053
3074
|
theme: resolvedTheme,
|
|
3054
3075
|
timeBar
|
|
3055
3076
|
}
|
|
3056
|
-
), /* @__PURE__ */ import_react7.default.createElement("div", { className: "body-wrapper", ref: bodyRef }, /* @__PURE__ */ import_react7.default.createElement(
|
|
3077
|
+
), /* @__PURE__ */ import_react7.default.createElement("div", { className: "body-wrapper", ref: bodyRef, style: { borderColor: resolvedTheme.borderColor } }, /* @__PURE__ */ import_react7.default.createElement(
|
|
3057
3078
|
canvas_board_default,
|
|
3058
3079
|
{
|
|
3059
3080
|
scene,
|