awesome-timeline-react 0.11.0 → 0.12.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.
@@ -65,6 +65,7 @@ declare type CanvasBoardProps = {
65
65
  onEventHover?: (props: OnEventHoverProps) => void;
66
66
  eventsResize: boolean;
67
67
  stripeOverlap: boolean;
68
+ timeBar?: TimeBarConfig;
68
69
  panZoom?: PanZoomConfig;
69
70
  animations: {
70
71
  layoutMs: number;
@@ -219,9 +220,24 @@ export declare const DEFAULT_GEOMETRY: Geometry;
219
220
 
220
221
  export declare const DEFAULT_LAYOUT_DURATION_MS = 200;
221
222
 
223
+ export declare const DEFAULT_MIN_BLOCK_WIDTH = 40;
224
+
222
225
  /** Defaults mirror the pre-0.2.0 stylesheet values. */
223
226
  export declare const DEFAULT_THEME: ResolvedTheme;
224
227
 
228
+ declare const DEFAULT_TIME_BAR_LEVELS: TimeBarLevel[];
229
+ export { DEFAULT_TIME_BAR_LEVELS }
230
+ export { DEFAULT_TIME_BAR_LEVELS as DEFAULT_TIME_BAR_LEVELS_alias_1 }
231
+
232
+ /** Vertical grid lines on the time bar's block edges, so they line up with its
233
+ * separators at any unit. Same edge rule as `drawGridLines`. */
234
+ export declare const drawBlockGridLines: (ctx: CanvasRenderingContext2D, { width, height, blocks, color, }: {
235
+ width: number;
236
+ height: number;
237
+ blocks: TimeBlock[];
238
+ color?: string;
239
+ }) => void;
240
+
225
241
  /**
226
242
  * Custom canvas renderer for an event. Return false to fall through to the
227
243
  * library's default drawing.
@@ -423,8 +439,8 @@ export declare class FrameScheduler {
423
439
  /**
424
440
  * The default two-row time bar: a day row over an hour row. Thin wrapper over
425
441
  * `generateUnitBlocks` kept for the golden tests and as the documented
426
- * default; the canvas time bar resolves `TimeBarConfig` and calls
427
- * `generateUnitBlocks` per row directly.
442
+ * default; the canvas time bar resolves `TimeBarConfig` through
443
+ * `resolveTimeBar` and calls `generateUnitBlocks` per row.
428
444
  */
429
445
  export declare const generateTimeBlocks: ({ windowStart, tick, contentWidth, }: {
430
446
  windowStart: number;
@@ -503,6 +519,9 @@ export declare type HitTestView = {
503
519
 
504
520
  export declare const intersectsWindow: (event: EventType, windowStart: number, windowEnd: number) => boolean;
505
521
 
522
+ /** ISO-8601 week number (weeks start Monday; week 1 holds the year's first Thursday). */
523
+ export declare const isoWeek: (date: Date) => number;
524
+
506
525
  /**
507
526
  * Whether an event may be dropped onto a row, given its `droppableRowIds`.
508
527
  * `undefined` = unrestricted (any row); otherwise the target must be listed.
@@ -669,6 +688,7 @@ export declare type RendererView = {
669
688
  drawEvent?: DrawEventFn;
670
689
  eventsResize: boolean;
671
690
  stripeOverlap: boolean;
691
+ timeBar?: TimeBarConfig;
672
692
  hoveredEventId: string | null;
673
693
  draggedEventId: string | null;
674
694
  resizePreview: ResizePreview | null;
@@ -687,6 +707,9 @@ export { ResolvedTheme as ResolvedTheme_alias_1 }
687
707
 
688
708
  export declare const resolveTheme: (theme?: Theme) => ResolvedTheme;
689
709
 
710
+ /** The two rows `timeBar` draws at this zoom. */
711
+ export declare const resolveTimeBar: (timeBar: TimeBarConfig | undefined, windowStart: number, windowEnd: number, tick: number | null) => TimeBarLevel;
712
+
690
713
  export declare const rowMinHeight: (highestLane: number, g?: Geometry) => number;
691
714
 
692
715
  declare type RowType = {
@@ -895,24 +918,52 @@ export { Theme as Theme_alias_1 }
895
918
  export declare const TIME_BAR_HEIGHT = 50;
896
919
 
897
920
  /** Per-row configuration for the two-row time bar. */
898
- export declare type TimeBarConfig = {
921
+ declare type TimeBarConfig = {
899
922
  topRow?: TimeBarRowConfig;
900
923
  bottomRow?: TimeBarRowConfig;
924
+ /** pick the rows by zoom instead: the first of `levels` (finest first; default
925
+ * day/hour → day/6 h → week/day → month/week → year/month) whose bottom-row
926
+ * blocks are at least `minBlockWidth` px wide (default 40). `topRow`/`bottomRow`
927
+ * are ignored, and the grid lines follow the bottom row rather than the grid
928
+ * cell; drops still snap to the cell. */
929
+ auto?: boolean | {
930
+ levels?: TimeBarLevel[];
931
+ minBlockWidth?: number;
932
+ };
933
+ };
934
+ export { TimeBarConfig }
935
+ export { TimeBarConfig as TimeBarConfig_alias_1 }
936
+
937
+ /** One zoom level of an automatic time bar. */
938
+ declare type TimeBarLevel = {
939
+ topRow: TimeBarRowConfig;
940
+ bottomRow: TimeBarRowConfig;
901
941
  };
942
+ export { TimeBarLevel }
943
+ export { TimeBarLevel as TimeBarLevel_alias_1 }
902
944
 
903
- export declare type TimeBarRowConfig = {
945
+ declare type TimeBarRowConfig = {
904
946
  /** the unit each block spans (default: "day" for the top row, "hour" for
905
- * the bottom row), or a fixed step like `{ stepSeconds: 8 * 3600 }`. */
947
+ * the bottom row), a fixed step like `{ stepSeconds: 8 * 3600 }`, or
948
+ * `{ boundaries }` for uneven blocks such as real shifts: it returns the
949
+ * sorted block edges in unix seconds, one at or before `windowStart` and one
950
+ * at or after `windowEnd`, so the row tiles the window. */
906
951
  unit?: TimeBarUnit | {
907
952
  stepSeconds: number;
953
+ } | {
954
+ boundaries: (windowStart: number, windowEnd: number) => number[];
908
955
  };
909
956
  /** label for a block; receives the block's start and end. Defaults mirror
910
957
  * the built-in day ("Mon 1 Jan") and hour ("HH:00") labels. */
911
958
  format?: (blockStart: Date, blockEnd: Date) => string;
912
959
  };
960
+ export { TimeBarRowConfig }
961
+ export { TimeBarRowConfig as TimeBarRowConfig_alias_1 }
913
962
 
914
963
  /** Calendar unit for a time-bar row, or a fixed step in seconds. */
915
- export declare type TimeBarUnit = "hour" | "day" | "week" | "month";
964
+ declare type TimeBarUnit = "hour" | "day" | "week" | "month" | "year";
965
+ export { TimeBarUnit }
966
+ export { TimeBarUnit as TimeBarUnit_alias_1 }
916
967
 
917
968
  export declare type TimeBlock = {
918
969
  label: string;
@@ -929,6 +980,14 @@ declare const Timeline: React_2.ForwardRefExoticComponent<TimelineProps & React_
929
980
  export { Timeline }
930
981
  export { Timeline as Timeline_alias_1 }
931
982
 
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
+ export declare const TimelineAutoTimeBar: () => React_2.JSX.Element;
990
+
932
991
  export declare const TimelineCanvas: () => React_2.JSX.Element;
933
992
 
934
993
  /**
@@ -1099,8 +1158,8 @@ declare type TimelineProps = {
1099
1158
  /** draw the two-row time bar above the rows (default true). Off, the timeline is just its rows —
1100
1159
  * e.g. a secondary strip kept in step with a main timeline through `onWindowChange`/`setWindow`. */
1101
1160
  showTimeBar?: boolean;
1102
- /** a dashed vertical line follows the pointer over the rows, its time shown in the time bar
1103
- * (default false) */
1161
+ /** a dashed vertical line follows the pointer over the rows, its time shown in the time bar;
1162
+ * hidden while the pointer is on an event (default false) */
1104
1163
  showPointerLine?: boolean;
1105
1164
  /** the pointer line's label for a time in unix seconds (default: the browser's locale date and time) */
1106
1165
  formatPointerTime?: (time: number) => string;
@@ -1142,6 +1201,7 @@ export declare class TimelineRenderer {
1142
1201
  flush(): void;
1143
1202
  dispose(): void;
1144
1203
  private resizeCanvases;
1204
+ private drawGrid;
1145
1205
  private drawFrame;
1146
1206
  }
1147
1207
 
@@ -65,6 +65,7 @@ declare type CanvasBoardProps = {
65
65
  onEventHover?: (props: OnEventHoverProps) => void;
66
66
  eventsResize: boolean;
67
67
  stripeOverlap: boolean;
68
+ timeBar?: TimeBarConfig;
68
69
  panZoom?: PanZoomConfig;
69
70
  animations: {
70
71
  layoutMs: number;
@@ -219,9 +220,24 @@ export declare const DEFAULT_GEOMETRY: Geometry;
219
220
 
220
221
  export declare const DEFAULT_LAYOUT_DURATION_MS = 200;
221
222
 
223
+ export declare const DEFAULT_MIN_BLOCK_WIDTH = 40;
224
+
222
225
  /** Defaults mirror the pre-0.2.0 stylesheet values. */
223
226
  export declare const DEFAULT_THEME: ResolvedTheme;
224
227
 
228
+ declare const DEFAULT_TIME_BAR_LEVELS: TimeBarLevel[];
229
+ export { DEFAULT_TIME_BAR_LEVELS }
230
+ export { DEFAULT_TIME_BAR_LEVELS as DEFAULT_TIME_BAR_LEVELS_alias_1 }
231
+
232
+ /** Vertical grid lines on the time bar's block edges, so they line up with its
233
+ * separators at any unit. Same edge rule as `drawGridLines`. */
234
+ export declare const drawBlockGridLines: (ctx: CanvasRenderingContext2D, { width, height, blocks, color, }: {
235
+ width: number;
236
+ height: number;
237
+ blocks: TimeBlock[];
238
+ color?: string;
239
+ }) => void;
240
+
225
241
  /**
226
242
  * Custom canvas renderer for an event. Return false to fall through to the
227
243
  * library's default drawing.
@@ -423,8 +439,8 @@ export declare class FrameScheduler {
423
439
  /**
424
440
  * The default two-row time bar: a day row over an hour row. Thin wrapper over
425
441
  * `generateUnitBlocks` kept for the golden tests and as the documented
426
- * default; the canvas time bar resolves `TimeBarConfig` and calls
427
- * `generateUnitBlocks` per row directly.
442
+ * default; the canvas time bar resolves `TimeBarConfig` through
443
+ * `resolveTimeBar` and calls `generateUnitBlocks` per row.
428
444
  */
429
445
  export declare const generateTimeBlocks: ({ windowStart, tick, contentWidth, }: {
430
446
  windowStart: number;
@@ -503,6 +519,9 @@ export declare type HitTestView = {
503
519
 
504
520
  export declare const intersectsWindow: (event: EventType, windowStart: number, windowEnd: number) => boolean;
505
521
 
522
+ /** ISO-8601 week number (weeks start Monday; week 1 holds the year's first Thursday). */
523
+ export declare const isoWeek: (date: Date) => number;
524
+
506
525
  /**
507
526
  * Whether an event may be dropped onto a row, given its `droppableRowIds`.
508
527
  * `undefined` = unrestricted (any row); otherwise the target must be listed.
@@ -669,6 +688,7 @@ export declare type RendererView = {
669
688
  drawEvent?: DrawEventFn;
670
689
  eventsResize: boolean;
671
690
  stripeOverlap: boolean;
691
+ timeBar?: TimeBarConfig;
672
692
  hoveredEventId: string | null;
673
693
  draggedEventId: string | null;
674
694
  resizePreview: ResizePreview | null;
@@ -687,6 +707,9 @@ export { ResolvedTheme as ResolvedTheme_alias_1 }
687
707
 
688
708
  export declare const resolveTheme: (theme?: Theme) => ResolvedTheme;
689
709
 
710
+ /** The two rows `timeBar` draws at this zoom. */
711
+ export declare const resolveTimeBar: (timeBar: TimeBarConfig | undefined, windowStart: number, windowEnd: number, tick: number | null) => TimeBarLevel;
712
+
690
713
  export declare const rowMinHeight: (highestLane: number, g?: Geometry) => number;
691
714
 
692
715
  declare type RowType = {
@@ -895,24 +918,52 @@ export { Theme as Theme_alias_1 }
895
918
  export declare const TIME_BAR_HEIGHT = 50;
896
919
 
897
920
  /** Per-row configuration for the two-row time bar. */
898
- export declare type TimeBarConfig = {
921
+ declare type TimeBarConfig = {
899
922
  topRow?: TimeBarRowConfig;
900
923
  bottomRow?: TimeBarRowConfig;
924
+ /** pick the rows by zoom instead: the first of `levels` (finest first; default
925
+ * day/hour → day/6 h → week/day → month/week → year/month) whose bottom-row
926
+ * blocks are at least `minBlockWidth` px wide (default 40). `topRow`/`bottomRow`
927
+ * are ignored, and the grid lines follow the bottom row rather than the grid
928
+ * cell; drops still snap to the cell. */
929
+ auto?: boolean | {
930
+ levels?: TimeBarLevel[];
931
+ minBlockWidth?: number;
932
+ };
933
+ };
934
+ export { TimeBarConfig }
935
+ export { TimeBarConfig as TimeBarConfig_alias_1 }
936
+
937
+ /** One zoom level of an automatic time bar. */
938
+ declare type TimeBarLevel = {
939
+ topRow: TimeBarRowConfig;
940
+ bottomRow: TimeBarRowConfig;
901
941
  };
942
+ export { TimeBarLevel }
943
+ export { TimeBarLevel as TimeBarLevel_alias_1 }
902
944
 
903
- export declare type TimeBarRowConfig = {
945
+ declare type TimeBarRowConfig = {
904
946
  /** the unit each block spans (default: "day" for the top row, "hour" for
905
- * the bottom row), or a fixed step like `{ stepSeconds: 8 * 3600 }`. */
947
+ * the bottom row), a fixed step like `{ stepSeconds: 8 * 3600 }`, or
948
+ * `{ boundaries }` for uneven blocks such as real shifts: it returns the
949
+ * sorted block edges in unix seconds, one at or before `windowStart` and one
950
+ * at or after `windowEnd`, so the row tiles the window. */
906
951
  unit?: TimeBarUnit | {
907
952
  stepSeconds: number;
953
+ } | {
954
+ boundaries: (windowStart: number, windowEnd: number) => number[];
908
955
  };
909
956
  /** label for a block; receives the block's start and end. Defaults mirror
910
957
  * the built-in day ("Mon 1 Jan") and hour ("HH:00") labels. */
911
958
  format?: (blockStart: Date, blockEnd: Date) => string;
912
959
  };
960
+ export { TimeBarRowConfig }
961
+ export { TimeBarRowConfig as TimeBarRowConfig_alias_1 }
913
962
 
914
963
  /** Calendar unit for a time-bar row, or a fixed step in seconds. */
915
- export declare type TimeBarUnit = "hour" | "day" | "week" | "month";
964
+ declare type TimeBarUnit = "hour" | "day" | "week" | "month" | "year";
965
+ export { TimeBarUnit }
966
+ export { TimeBarUnit as TimeBarUnit_alias_1 }
916
967
 
917
968
  export declare type TimeBlock = {
918
969
  label: string;
@@ -929,6 +980,14 @@ declare const Timeline: React_2.ForwardRefExoticComponent<TimelineProps & React_
929
980
  export { Timeline }
930
981
  export { Timeline as Timeline_alias_1 }
931
982
 
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
+ export declare const TimelineAutoTimeBar: () => React_2.JSX.Element;
990
+
932
991
  export declare const TimelineCanvas: () => React_2.JSX.Element;
933
992
 
934
993
  /**
@@ -1099,8 +1158,8 @@ declare type TimelineProps = {
1099
1158
  /** draw the two-row time bar above the rows (default true). Off, the timeline is just its rows —
1100
1159
  * e.g. a secondary strip kept in step with a main timeline through `onWindowChange`/`setWindow`. */
1101
1160
  showTimeBar?: boolean;
1102
- /** a dashed vertical line follows the pointer over the rows, its time shown in the time bar
1103
- * (default false) */
1161
+ /** a dashed vertical line follows the pointer over the rows, its time shown in the time bar;
1162
+ * hidden while the pointer is on an event (default false) */
1104
1163
  showPointerLine?: boolean;
1105
1164
  /** the pointer line's label for a time in unix seconds (default: the browser's locale date and time) */
1106
1165
  formatPointerTime?: (time: number) => string;
@@ -1142,6 +1201,7 @@ export declare class TimelineRenderer {
1142
1201
  flush(): void;
1143
1202
  dispose(): void;
1144
1203
  private resizeCanvases;
1204
+ private drawGrid;
1145
1205
  private drawFrame;
1146
1206
  }
1147
1207
 
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ export { DEFAULT_TIME_BAR_LEVELS } from './_tsup-dts-rollup.mjs';
1
2
  export { RowType } from './_tsup-dts-rollup.mjs';
2
3
  export { EventType } from './_tsup-dts-rollup.mjs';
3
4
  export { EventPropsType } from './_tsup-dts-rollup.mjs';
@@ -13,6 +14,10 @@ export { OnEventClickProps } from './_tsup-dts-rollup.mjs';
13
14
  export { OnEventHoverProps } from './_tsup-dts-rollup.mjs';
14
15
  export { DroppableError } from './_tsup-dts-rollup.mjs';
15
16
  export { PanZoomConfig } from './_tsup-dts-rollup.mjs';
17
+ export { TimeBarConfig } from './_tsup-dts-rollup.mjs';
18
+ export { TimeBarLevel } from './_tsup-dts-rollup.mjs';
19
+ export { TimeBarRowConfig } from './_tsup-dts-rollup.mjs';
20
+ export { TimeBarUnit } from './_tsup-dts-rollup.mjs';
16
21
  export { EventPatch } from './_tsup-dts-rollup.mjs';
17
22
  export { TimelineHandle } from './_tsup-dts-rollup.mjs';
18
23
  export { TimelineProps } from './_tsup-dts-rollup.mjs';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { DEFAULT_TIME_BAR_LEVELS } from './_tsup-dts-rollup.js';
1
2
  export { RowType } from './_tsup-dts-rollup.js';
2
3
  export { EventType } from './_tsup-dts-rollup.js';
3
4
  export { EventPropsType } from './_tsup-dts-rollup.js';
@@ -13,6 +14,10 @@ export { OnEventClickProps } from './_tsup-dts-rollup.js';
13
14
  export { OnEventHoverProps } from './_tsup-dts-rollup.js';
14
15
  export { DroppableError } from './_tsup-dts-rollup.js';
15
16
  export { PanZoomConfig } from './_tsup-dts-rollup.js';
17
+ export { TimeBarConfig } from './_tsup-dts-rollup.js';
18
+ export { TimeBarLevel } from './_tsup-dts-rollup.js';
19
+ export { TimeBarRowConfig } from './_tsup-dts-rollup.js';
20
+ export { TimeBarUnit } from './_tsup-dts-rollup.js';
16
21
  export { EventPatch } from './_tsup-dts-rollup.js';
17
22
  export { TimelineHandle } from './_tsup-dts-rollup.js';
18
23
  export { TimelineProps } from './_tsup-dts-rollup.js';