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/index.mjs CHANGED
@@ -447,6 +447,7 @@ var DEFAULT_THEME = {
447
447
  laneGap: 2,
448
448
  rowPaddingY: 10,
449
449
  barRadius: 5,
450
+ minHitWidth: 0,
450
451
  groupChildBackground: "rgba(0,0,0,0.05)",
451
452
  groupShadowColor: "rgba(0,0,0,0.22)"
452
453
  };
@@ -537,8 +538,9 @@ var CanvasTimeBar = ({
537
538
  theme,
538
539
  timeBar
539
540
  }) => {
540
- var _a, _b;
541
+ var _a, _b, _c;
541
542
  const canvasRef = useRef4(null);
543
+ const header = theme != null ? theme : DEFAULT_THEME;
542
544
  const topRow = (_a = timeBar == null ? void 0 : timeBar.topRow) != null ? _a : { unit: "day" };
543
545
  const bottomRow = (_b = timeBar == null ? void 0 : timeBar.bottomRow) != null ? _b : { unit: "hour" };
544
546
  useEffect3(() => {
@@ -567,24 +569,33 @@ var CanvasTimeBar = ({
567
569
  }))
568
570
  });
569
571
  }, [windowTime, tick, contentWidth, theme, timeBar]);
570
- return /* @__PURE__ */ React3.createElement("div", { className: "time-bar" }, /* @__PURE__ */ React3.createElement("div", { className: "empty-block" }), /* @__PURE__ */ React3.createElement(
571
- "canvas",
572
- {
573
- ref: canvasRef,
574
- className: "canvas-time-bar",
575
- style: { minWidth: contentWidth ? contentWidth : 0 }
576
- }
577
- ), scrollWidth ? /* @__PURE__ */ React3.createElement(
572
+ return /* @__PURE__ */ React3.createElement(
578
573
  "div",
579
574
  {
580
- style: {
581
- width: scrollWidth,
582
- height: "100%",
583
- boxSizing: "border-box",
584
- borderLeft: "1px solid yellow"
575
+ className: "time-bar",
576
+ style: { background: header.headerBackground, color: header.headerTextColor, borderColor: header.headerBorderColor }
577
+ },
578
+ /* @__PURE__ */ React3.createElement("div", { className: "empty-block", style: { borderRightColor: header.headerBorderColor } }),
579
+ /* @__PURE__ */ React3.createElement(
580
+ "canvas",
581
+ {
582
+ ref: canvasRef,
583
+ className: "canvas-time-bar",
584
+ style: { minWidth: contentWidth ? contentWidth : 0 }
585
585
  }
586
- }
587
- ) : null);
586
+ ),
587
+ scrollWidth ? /* @__PURE__ */ React3.createElement(
588
+ "div",
589
+ {
590
+ style: {
591
+ width: scrollWidth,
592
+ height: "100%",
593
+ boxSizing: "border-box",
594
+ borderLeft: `1px solid ${(_c = header.headerBorderColor) != null ? _c : "yellow"}`
595
+ }
596
+ }
597
+ ) : null
598
+ );
588
599
  };
589
600
  var canvas_time_bar_default = CanvasTimeBar;
590
601
 
@@ -670,7 +681,8 @@ var DEFAULT_GEOMETRY = {
670
681
  laneTopOffset: 10,
671
682
  rowBaseHeight: 40,
672
683
  staticEventBaseHeight: 20,
673
- barRadius: 5
684
+ barRadius: 5,
685
+ minHitWidth: 0
674
686
  };
675
687
  var geometryFromTheme = (theme) => {
676
688
  const barHeight = theme.barHeight;
@@ -681,7 +693,8 @@ var geometryFromTheme = (theme) => {
681
693
  laneTopOffset: rowPaddingY,
682
694
  rowBaseHeight: barHeight + 2 * rowPaddingY,
683
695
  staticEventBaseHeight: barHeight,
684
- barRadius: theme.barRadius
696
+ barRadius: theme.barRadius,
697
+ minHitWidth: theme.minHitWidth
685
698
  };
686
699
  };
687
700
 
@@ -1230,7 +1243,8 @@ var hitTest = (scene, view, x, y) => {
1230
1243
  width: timeToWidth(event.startTime, event.endTime, tick),
1231
1244
  height: geometry.barHeight
1232
1245
  };
1233
- if (rectContains(rect, x, y)) {
1246
+ const hit = rect.width >= geometry.minHitWidth ? rect : __spreadProps(__spreadValues({}, rect), { x: rect.x + (rect.width - geometry.minHitWidth) / 2, width: geometry.minHitWidth });
1247
+ if (rectContains(hit, x, y)) {
1234
1248
  return { kind: "event", event, rowId, rect };
1235
1249
  }
1236
1250
  }
@@ -1990,6 +2004,7 @@ var CanvasBoard = forwardRef2(
1990
2004
  applySelection,
1991
2005
  getSelection
1992
2006
  }, contentRef) => {
2007
+ var _a;
1993
2008
  const staticCanvasRef = useRef6(null);
1994
2009
  const dynamicCanvasRef = useRef6(null);
1995
2010
  const ghostRef = useRef6(null);
@@ -2012,8 +2027,8 @@ var CanvasBoard = forwardRef2(
2012
2027
  };
2013
2028
  }, [scene, rendererRef]);
2014
2029
  useEffect5(() => {
2015
- var _a, _b;
2016
- (_a = rendererRef.current) == null ? void 0 : _a.animator.setDurations(
2030
+ var _a2, _b;
2031
+ (_a2 = rendererRef.current) == null ? void 0 : _a2.animator.setDurations(
2017
2032
  animations.layoutMs,
2018
2033
  animations.fadeMs
2019
2034
  );
@@ -2038,14 +2053,14 @@ var CanvasBoard = forwardRef2(
2038
2053
  rendererRef
2039
2054
  ]);
2040
2055
  const measureViewport = useCallback2(() => {
2041
- var _a;
2056
+ var _a2;
2042
2057
  const column = contentRef && "current" in contentRef ? contentRef.current : null;
2043
2058
  const body = bodyRef.current;
2044
2059
  if (!column || !body) return;
2045
2060
  const cap = totalHeightRef.current > 0 ? totalHeightRef.current : Infinity;
2046
2061
  const height = Math.min(body.clientHeight, cap, window.innerHeight);
2047
2062
  setViewportHeight(height);
2048
- (_a = rendererRef.current) == null ? void 0 : _a.setView({
2063
+ (_a2 = rendererRef.current) == null ? void 0 : _a2.setView({
2049
2064
  width: column.getBoundingClientRect().width,
2050
2065
  height
2051
2066
  });
@@ -2064,8 +2079,8 @@ var CanvasBoard = forwardRef2(
2064
2079
  const body = bodyRef.current;
2065
2080
  if (!body) return;
2066
2081
  const handleScroll = () => {
2067
- var _a;
2068
- (_a = rendererRef.current) == null ? void 0 : _a.setView({ scrollTop: body.scrollTop });
2082
+ var _a2;
2083
+ (_a2 = rendererRef.current) == null ? void 0 : _a2.setView({ scrollTop: body.scrollTop });
2069
2084
  setScrollTop(body.scrollTop);
2070
2085
  };
2071
2086
  body.addEventListener("scroll", handleScroll, { passive: true });
@@ -2090,14 +2105,14 @@ var CanvasBoard = forwardRef2(
2090
2105
  wrapper.appendChild(measurer);
2091
2106
  let lastWidth = -1;
2092
2107
  const measure = () => {
2093
- var _a;
2108
+ var _a2;
2094
2109
  const width = wrapper.clientWidth;
2095
2110
  if (width === 0 || width === lastWidth) return;
2096
2111
  lastWidth = width;
2097
2112
  measurer.style.width = `${width}px`;
2098
2113
  const heights = /* @__PURE__ */ new Map();
2099
2114
  for (const row of rows) {
2100
- measurer.textContent = (_a = row.name) != null ? _a : "";
2115
+ measurer.textContent = (_a2 = row.name) != null ? _a2 : "";
2101
2116
  heights.set(
2102
2117
  row.id,
2103
2118
  Math.ceil(measurer.offsetHeight) + 2 * theme.rowPaddingY
@@ -2168,8 +2183,8 @@ var CanvasBoard = forwardRef2(
2168
2183
  getSelection
2169
2184
  });
2170
2185
  useEffect5(() => {
2171
- var _a;
2172
- (_a = rendererRef.current) == null ? void 0 : _a.setView({
2186
+ var _a2;
2187
+ (_a2 = rendererRef.current) == null ? void 0 : _a2.setView({
2173
2188
  selectedEventIds: new Set(getSelection())
2174
2189
  });
2175
2190
  }, [getSelection, rendererRef]);
@@ -2208,7 +2223,7 @@ var CanvasBoard = forwardRef2(
2208
2223
  style: {
2209
2224
  top,
2210
2225
  height,
2211
- borderBottom: i === rows.length - 1 ? "none" : "1px solid yellow",
2226
+ borderBottom: i === rows.length - 1 ? "none" : `1px solid ${(_a = theme.headerBorderColor) != null ? _a : "yellow"}`,
2212
2227
  // Row heights/positions apply instantly (no layout tween) so the
2213
2228
  // header snaps in lockstep with its canvas row — see draw-events.
2214
2229
  // Grouped rows left-align so the caret + tree spine line up; plain
@@ -2282,7 +2297,13 @@ var CanvasBoard = forwardRef2(
2282
2297
  {
2283
2298
  ref: headerWrapperRef,
2284
2299
  className: headerClassNames,
2285
- style: { height: totalHeight }
2300
+ style: {
2301
+ height: totalHeight,
2302
+ background: theme.headerBackground,
2303
+ color: theme.headerTextColor,
2304
+ borderRightColor: theme.headerBorderColor,
2305
+ boxShadow: theme.headerShadow
2306
+ }
2286
2307
  },
2287
2308
  visibleHeaders,
2288
2309
  renderRowLabel && // off-screen: renders every row's custom header so its natural height can be measured
@@ -3041,7 +3062,7 @@ var Timeline = forwardRef3(
3041
3062
  theme: resolvedTheme,
3042
3063
  timeBar
3043
3064
  }
3044
- ), /* @__PURE__ */ React6.createElement("div", { className: "body-wrapper", ref: bodyRef }, /* @__PURE__ */ React6.createElement(
3065
+ ), /* @__PURE__ */ React6.createElement("div", { className: "body-wrapper", ref: bodyRef, style: { borderColor: resolvedTheme.borderColor } }, /* @__PURE__ */ React6.createElement(
3045
3066
  canvas_board_default,
3046
3067
  {
3047
3068
  scene,