awesome-timeline-react 0.12.0 → 0.13.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.
@@ -283,15 +283,18 @@ export declare const drawRowDividers: (ctx: CanvasRenderingContext2D, view: Rend
283
283
  /**
284
284
  * Two-row time bar (top row over bottom row) — canvas replacement for the
285
285
  * day/hour block divs of time-bar.tsx. The two rows are unit-agnostic
286
- * (day/hour by default, configurable via TimeBarConfig). Background is left
287
- * transparent so the .time-bar container color shows through.
286
+ * (day/hour by default, configurable via TimeBarConfig). A row without its own
287
+ * background is left transparent, so the .time-bar container color shows through.
288
288
  */
289
- export declare const drawTimeBar: (ctx: CanvasRenderingContext2D, { width, height, topBlocks, bottomBlocks, font, borderColor, textColor, }: {
289
+ export declare const drawTimeBar: (ctx: CanvasRenderingContext2D, { width, height, topBlocks, bottomBlocks, font, borderColor, textColor, topBackground, bottomBackground, bottomTextColor, }: {
290
290
  width: number;
291
291
  height: number;
292
292
  font: string;
293
293
  borderColor?: string;
294
294
  textColor?: string;
295
+ topBackground?: string;
296
+ bottomBackground?: string;
297
+ bottomTextColor?: string;
295
298
  topBlocks: TimeBlock[];
296
299
  bottomBlocks: TimeBlock[];
297
300
  }) => void;
@@ -491,7 +494,7 @@ export declare type Geometry = {
491
494
  /** Derive the full Geometry from the resolved theme's geometry tokens. */
492
495
  export declare const geometryFromTheme: (theme: ResolvedTheme) => Geometry;
493
496
 
494
- declare type HeaderToken = "headerBackground" | "headerTextColor" | "headerBorderColor" | "headerShadow" | "borderColor";
497
+ declare type HeaderToken = "headerBackground" | "headerTextColor" | "headerBorderColor" | "headerShadow" | "borderColor" | "timeBarTopBackground" | "timeBarBottomBackground" | "timeBarBottomTextColor";
495
498
 
496
499
  export declare type HitTarget = {
497
500
  kind: "event" | "static";
@@ -864,6 +867,12 @@ declare type Theme = {
864
867
  gridColor?: string;
865
868
  timeBarBorder?: string;
866
869
  timeBarTextColor?: string;
870
+ /** fills of the time bar's top and bottom rows, so the two read apart; unset, both show the
871
+ * header background */
872
+ timeBarTopBackground?: string;
873
+ timeBarBottomBackground?: string;
874
+ /** the bottom row's labels; unset, `timeBarTextColor` */
875
+ timeBarBottomTextColor?: string;
867
876
  /** opacity applied to NON-selected events while a selection is active, so the
868
877
  * selection stands out (default 0.35). 1 disables dimming. */
869
878
  dimmedOpacity?: number;
@@ -980,12 +989,6 @@ declare const Timeline: React_2.ForwardRefExoticComponent<TimelineProps & React_
980
989
  export { Timeline }
981
990
  export { Timeline as Timeline_alias_1 }
982
991
 
983
- /**
984
- * `timeBar.auto`: the rows follow the zoom (day/hour → day/6 h → week/day → month/week → year/month),
985
- * and the grid follows the bottom row. Zoom with the buttons or ctrl/cmd + wheel; no block may get
986
- * narrower than 40 px. "Uneven blocks" swaps the two finest levels for a `boundaries` row: three
987
- * blocks a weekday and one over the weekend.
988
- */
989
992
  export declare const TimelineAutoTimeBar: () => React_2.JSX.Element;
990
993
 
991
994
  export declare const TimelineCanvas: () => React_2.JSX.Element;
@@ -283,15 +283,18 @@ export declare const drawRowDividers: (ctx: CanvasRenderingContext2D, view: Rend
283
283
  /**
284
284
  * Two-row time bar (top row over bottom row) — canvas replacement for the
285
285
  * day/hour block divs of time-bar.tsx. The two rows are unit-agnostic
286
- * (day/hour by default, configurable via TimeBarConfig). Background is left
287
- * transparent so the .time-bar container color shows through.
286
+ * (day/hour by default, configurable via TimeBarConfig). A row without its own
287
+ * background is left transparent, so the .time-bar container color shows through.
288
288
  */
289
- export declare const drawTimeBar: (ctx: CanvasRenderingContext2D, { width, height, topBlocks, bottomBlocks, font, borderColor, textColor, }: {
289
+ export declare const drawTimeBar: (ctx: CanvasRenderingContext2D, { width, height, topBlocks, bottomBlocks, font, borderColor, textColor, topBackground, bottomBackground, bottomTextColor, }: {
290
290
  width: number;
291
291
  height: number;
292
292
  font: string;
293
293
  borderColor?: string;
294
294
  textColor?: string;
295
+ topBackground?: string;
296
+ bottomBackground?: string;
297
+ bottomTextColor?: string;
295
298
  topBlocks: TimeBlock[];
296
299
  bottomBlocks: TimeBlock[];
297
300
  }) => void;
@@ -491,7 +494,7 @@ export declare type Geometry = {
491
494
  /** Derive the full Geometry from the resolved theme's geometry tokens. */
492
495
  export declare const geometryFromTheme: (theme: ResolvedTheme) => Geometry;
493
496
 
494
- declare type HeaderToken = "headerBackground" | "headerTextColor" | "headerBorderColor" | "headerShadow" | "borderColor";
497
+ declare type HeaderToken = "headerBackground" | "headerTextColor" | "headerBorderColor" | "headerShadow" | "borderColor" | "timeBarTopBackground" | "timeBarBottomBackground" | "timeBarBottomTextColor";
495
498
 
496
499
  export declare type HitTarget = {
497
500
  kind: "event" | "static";
@@ -864,6 +867,12 @@ declare type Theme = {
864
867
  gridColor?: string;
865
868
  timeBarBorder?: string;
866
869
  timeBarTextColor?: string;
870
+ /** fills of the time bar's top and bottom rows, so the two read apart; unset, both show the
871
+ * header background */
872
+ timeBarTopBackground?: string;
873
+ timeBarBottomBackground?: string;
874
+ /** the bottom row's labels; unset, `timeBarTextColor` */
875
+ timeBarBottomTextColor?: string;
867
876
  /** opacity applied to NON-selected events while a selection is active, so the
868
877
  * selection stands out (default 0.35). 1 disables dimming. */
869
878
  dimmedOpacity?: number;
@@ -980,12 +989,6 @@ declare const Timeline: React_2.ForwardRefExoticComponent<TimelineProps & React_
980
989
  export { Timeline }
981
990
  export { Timeline as Timeline_alias_1 }
982
991
 
983
- /**
984
- * `timeBar.auto`: the rows follow the zoom (day/hour → day/6 h → week/day → month/week → year/month),
985
- * and the grid follows the bottom row. Zoom with the buttons or ctrl/cmd + wheel; no block may get
986
- * narrower than 40 px. "Uneven blocks" swaps the two finest levels for a `boundaries` row: three
987
- * blocks a weekday and one over the weekend.
988
- */
989
992
  export declare const TimelineAutoTimeBar: () => React_2.JSX.Element;
990
993
 
991
994
  export declare const TimelineCanvas: () => React_2.JSX.Element;
package/dist/index.js CHANGED
@@ -594,9 +594,20 @@ var drawTimeBar = (ctx, {
594
594
  bottomBlocks,
595
595
  font,
596
596
  borderColor = DEFAULT_THEME.timeBarBorder,
597
- textColor = DEFAULT_THEME.timeBarTextColor
597
+ textColor = DEFAULT_THEME.timeBarTextColor,
598
+ topBackground,
599
+ bottomBackground,
600
+ bottomTextColor = textColor
598
601
  }) => {
599
602
  const mid = height / 2;
603
+ if (topBackground) {
604
+ ctx.fillStyle = topBackground;
605
+ ctx.fillRect(0, 0, width, Math.round(mid));
606
+ }
607
+ if (bottomBackground) {
608
+ ctx.fillStyle = bottomBackground;
609
+ ctx.fillRect(0, Math.round(mid), width, height - Math.round(mid));
610
+ }
600
611
  ctx.strokeStyle = borderColor;
601
612
  ctx.lineWidth = 1;
602
613
  ctx.beginPath();
@@ -628,6 +639,7 @@ var drawTimeBar = (ctx, {
628
639
  block.width - inset
629
640
  );
630
641
  }
642
+ ctx.fillStyle = bottomTextColor;
631
643
  for (const block of bottomBlocks) {
632
644
  ctx.fillText(
633
645
  block.label,
@@ -653,7 +665,7 @@ var CanvasTimeBar = ({
653
665
  const canvasRef = (0, import_react4.useRef)(null);
654
666
  const header = theme != null ? theme : DEFAULT_THEME;
655
667
  (0, import_react4.useEffect)(() => {
656
- var _a2;
668
+ var _a2, _b;
657
669
  const canvas = canvasRef.current;
658
670
  if (!canvas || !contentWidth) return;
659
671
  const ctx = sizeCanvas(
@@ -671,6 +683,9 @@ var CanvasTimeBar = ({
671
683
  font: (_a2 = theme == null ? void 0 : theme.font) != null ? _a2 : getComputedStyle(canvas).font,
672
684
  borderColor: theme == null ? void 0 : theme.timeBarBorder,
673
685
  textColor: theme == null ? void 0 : theme.timeBarTextColor,
686
+ topBackground: theme == null ? void 0 : theme.timeBarTopBackground,
687
+ bottomBackground: theme == null ? void 0 : theme.timeBarBottomBackground,
688
+ bottomTextColor: (_b = theme == null ? void 0 : theme.timeBarBottomTextColor) != null ? _b : theme == null ? void 0 : theme.timeBarTextColor,
674
689
  topBlocks: generateUnitBlocks(__spreadProps(__spreadValues({}, topRow), { windowStart, windowEnd, tick })),
675
690
  bottomBlocks: generateUnitBlocks(__spreadProps(__spreadValues({}, bottomRow), {
676
691
  windowStart,