awesome-timeline-react 0.4.3 → 0.5.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 +23 -0
- package/dist/_tsup-dts-rollup.d.ts +23 -0
- package/dist/index.js +68 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -52,6 +52,7 @@ declare type CanvasBoardProps = {
|
|
|
52
52
|
onEventClick?: (props: OnEventClickProps) => void;
|
|
53
53
|
onEventHover?: (props: OnEventHoverProps) => void;
|
|
54
54
|
eventsResize: boolean;
|
|
55
|
+
stripeOverlap: boolean;
|
|
55
56
|
panZoom?: PanZoomConfig;
|
|
56
57
|
animations: {
|
|
57
58
|
layoutMs: number;
|
|
@@ -629,6 +630,7 @@ export declare type RendererView = {
|
|
|
629
630
|
theme: ResolvedTheme;
|
|
630
631
|
drawEvent?: DrawEventFn;
|
|
631
632
|
eventsResize: boolean;
|
|
633
|
+
stripeOverlap: boolean;
|
|
632
634
|
hoveredEventId: string | null;
|
|
633
635
|
draggedEventId: string | null;
|
|
634
636
|
resizePreview: ResizePreview | null;
|
|
@@ -788,6 +790,10 @@ declare type Theme = {
|
|
|
788
790
|
eventStroke?: string;
|
|
789
791
|
eventTextColor?: string;
|
|
790
792
|
staticEventFill?: string;
|
|
793
|
+
/** color of the 45° stripes drawn over the slice of an event bar that overlaps
|
|
794
|
+
* a static event, when the `stripeOverlap` prop is on (default a translucent
|
|
795
|
+
* slate so it reads over any bar fill). */
|
|
796
|
+
overlapStripeColor?: string;
|
|
791
797
|
gridColor?: string;
|
|
792
798
|
timeBarBorder?: string;
|
|
793
799
|
timeBarTextColor?: string;
|
|
@@ -972,6 +978,12 @@ declare type TimelineProps = {
|
|
|
972
978
|
additionalClassNames?: PartialRecord<keyof ModifableElements, string>;
|
|
973
979
|
showRTIndicator?: boolean;
|
|
974
980
|
eventsResize?: boolean;
|
|
981
|
+
/** draw 45° diagonal stripes on the slice of an event bar that overlaps a
|
|
982
|
+
* static event (e.g. an off-shift/downtime band) on the same row. This gives
|
|
983
|
+
* a visible cause for a bar that looks "too wide" because it spans
|
|
984
|
+
* non-working time. Stripe color is `theme.overlapStripeColor`. Default
|
|
985
|
+
* false (no striping). */
|
|
986
|
+
stripeOverlap?: boolean;
|
|
975
987
|
showEventPrompt?: boolean;
|
|
976
988
|
eventPromptTemplate?: (event: EventType) => JSX.Element;
|
|
977
989
|
panZoom?: PanZoomConfig;
|
|
@@ -1040,6 +1052,17 @@ export declare const TimelineShiftBar: () => React_2.JSX.Element;
|
|
|
1040
1052
|
*/
|
|
1041
1053
|
export declare const TimelineStreaming10k: () => React_2.JSX.Element;
|
|
1042
1054
|
|
|
1055
|
+
/**
|
|
1056
|
+
* `stripeOverlap`: where an event bar overlaps a static event (an off-shift /
|
|
1057
|
+
* downtime band) on the same row, its overlapping slice is hatched with 45°
|
|
1058
|
+
* stripes so an over-wide bar has a visible cause (spec §6.4 — "why is my 2h op
|
|
1059
|
+
* 14h wide?"). Toggle it to compare. Row 1's op straddles the band (striped over
|
|
1060
|
+
* the gap only); row 2's op starts at the band's end (no overlap → no stripes),
|
|
1061
|
+
* modelling a "continuous / no-straddle" op that shifted whole. Stripe color is
|
|
1062
|
+
* `theme.overlapStripeColor`.
|
|
1063
|
+
*/
|
|
1064
|
+
export declare const TimelineStripedOverlap: () => React_2.JSX.Element;
|
|
1065
|
+
|
|
1043
1066
|
/**
|
|
1044
1067
|
* Themeable bar geometry: chunky 32px bars with a 6px lane gap, wide row
|
|
1045
1068
|
* padding, and a larger corner radius. Verifies stacking, hit-testing
|
|
@@ -52,6 +52,7 @@ declare type CanvasBoardProps = {
|
|
|
52
52
|
onEventClick?: (props: OnEventClickProps) => void;
|
|
53
53
|
onEventHover?: (props: OnEventHoverProps) => void;
|
|
54
54
|
eventsResize: boolean;
|
|
55
|
+
stripeOverlap: boolean;
|
|
55
56
|
panZoom?: PanZoomConfig;
|
|
56
57
|
animations: {
|
|
57
58
|
layoutMs: number;
|
|
@@ -629,6 +630,7 @@ export declare type RendererView = {
|
|
|
629
630
|
theme: ResolvedTheme;
|
|
630
631
|
drawEvent?: DrawEventFn;
|
|
631
632
|
eventsResize: boolean;
|
|
633
|
+
stripeOverlap: boolean;
|
|
632
634
|
hoveredEventId: string | null;
|
|
633
635
|
draggedEventId: string | null;
|
|
634
636
|
resizePreview: ResizePreview | null;
|
|
@@ -788,6 +790,10 @@ declare type Theme = {
|
|
|
788
790
|
eventStroke?: string;
|
|
789
791
|
eventTextColor?: string;
|
|
790
792
|
staticEventFill?: string;
|
|
793
|
+
/** color of the 45° stripes drawn over the slice of an event bar that overlaps
|
|
794
|
+
* a static event, when the `stripeOverlap` prop is on (default a translucent
|
|
795
|
+
* slate so it reads over any bar fill). */
|
|
796
|
+
overlapStripeColor?: string;
|
|
791
797
|
gridColor?: string;
|
|
792
798
|
timeBarBorder?: string;
|
|
793
799
|
timeBarTextColor?: string;
|
|
@@ -972,6 +978,12 @@ declare type TimelineProps = {
|
|
|
972
978
|
additionalClassNames?: PartialRecord<keyof ModifableElements, string>;
|
|
973
979
|
showRTIndicator?: boolean;
|
|
974
980
|
eventsResize?: boolean;
|
|
981
|
+
/** draw 45° diagonal stripes on the slice of an event bar that overlaps a
|
|
982
|
+
* static event (e.g. an off-shift/downtime band) on the same row. This gives
|
|
983
|
+
* a visible cause for a bar that looks "too wide" because it spans
|
|
984
|
+
* non-working time. Stripe color is `theme.overlapStripeColor`. Default
|
|
985
|
+
* false (no striping). */
|
|
986
|
+
stripeOverlap?: boolean;
|
|
975
987
|
showEventPrompt?: boolean;
|
|
976
988
|
eventPromptTemplate?: (event: EventType) => JSX.Element;
|
|
977
989
|
panZoom?: PanZoomConfig;
|
|
@@ -1040,6 +1052,17 @@ export declare const TimelineShiftBar: () => React_2.JSX.Element;
|
|
|
1040
1052
|
*/
|
|
1041
1053
|
export declare const TimelineStreaming10k: () => React_2.JSX.Element;
|
|
1042
1054
|
|
|
1055
|
+
/**
|
|
1056
|
+
* `stripeOverlap`: where an event bar overlaps a static event (an off-shift /
|
|
1057
|
+
* downtime band) on the same row, its overlapping slice is hatched with 45°
|
|
1058
|
+
* stripes so an over-wide bar has a visible cause (spec §6.4 — "why is my 2h op
|
|
1059
|
+
* 14h wide?"). Toggle it to compare. Row 1's op straddles the band (striped over
|
|
1060
|
+
* the gap only); row 2's op starts at the band's end (no overlap → no stripes),
|
|
1061
|
+
* modelling a "continuous / no-straddle" op that shifted whole. Stripe color is
|
|
1062
|
+
* `theme.overlapStripeColor`.
|
|
1063
|
+
*/
|
|
1064
|
+
export declare const TimelineStripedOverlap: () => React_2.JSX.Element;
|
|
1065
|
+
|
|
1043
1066
|
/**
|
|
1044
1067
|
* Themeable bar geometry: chunky 32px bars with a 6px lane gap, wide row
|
|
1045
1068
|
* padding, and a larger corner radius. Verifies stacking, hit-testing
|
package/dist/index.js
CHANGED
|
@@ -454,6 +454,7 @@ var DEFAULT_THEME = {
|
|
|
454
454
|
eventStroke: "#000000",
|
|
455
455
|
eventTextColor: "#000000",
|
|
456
456
|
staticEventFill: "#e0e0e0",
|
|
457
|
+
overlapStripeColor: "rgba(15,23,42,0.6)",
|
|
457
458
|
gridColor: "#e4dcdc",
|
|
458
459
|
timeBarBorder: "yellow",
|
|
459
460
|
timeBarTextColor: "white",
|
|
@@ -956,6 +957,43 @@ var defaultDrawEvent = (ctx, event, rect, view, font, barRadius) => {
|
|
|
956
957
|
ctx.restore();
|
|
957
958
|
}
|
|
958
959
|
};
|
|
960
|
+
var STRIPE_STEP = 6;
|
|
961
|
+
var STRIPE_WIDTH = 2;
|
|
962
|
+
var STRIPE_WASH_ALPHA = 0.18;
|
|
963
|
+
var paintOverlapStripes = (ctx, event, rect, rowStatics, windowStart, tick, color) => {
|
|
964
|
+
const barRight = rect.x + rect.width;
|
|
965
|
+
for (const band of rowStatics) {
|
|
966
|
+
const overlapStart = Math.max(event.startTime, band.startTime);
|
|
967
|
+
const overlapEnd = Math.min(event.endTime, band.endTime);
|
|
968
|
+
if (overlapEnd <= overlapStart) continue;
|
|
969
|
+
const x0 = Math.max(timeToX(overlapStart, windowStart, tick), rect.x);
|
|
970
|
+
const x1 = Math.min(
|
|
971
|
+
timeToX(overlapStart, windowStart, tick) + timeToWidth(overlapStart, overlapEnd, tick),
|
|
972
|
+
barRight
|
|
973
|
+
);
|
|
974
|
+
const width = x1 - x0;
|
|
975
|
+
if (width <= 0) continue;
|
|
976
|
+
const { y, height } = rect;
|
|
977
|
+
ctx.save();
|
|
978
|
+
ctx.beginPath();
|
|
979
|
+
ctx.rect(x0, y, width, height);
|
|
980
|
+
ctx.clip();
|
|
981
|
+
const baseAlpha = ctx.globalAlpha;
|
|
982
|
+
ctx.globalAlpha = baseAlpha * STRIPE_WASH_ALPHA;
|
|
983
|
+
ctx.fillStyle = color;
|
|
984
|
+
ctx.fillRect(x0, y, width, height);
|
|
985
|
+
ctx.globalAlpha = baseAlpha;
|
|
986
|
+
ctx.strokeStyle = color;
|
|
987
|
+
ctx.lineWidth = STRIPE_WIDTH;
|
|
988
|
+
for (let sx = x0 - height; sx < x1; sx += STRIPE_STEP) {
|
|
989
|
+
ctx.beginPath();
|
|
990
|
+
ctx.moveTo(sx, y + height);
|
|
991
|
+
ctx.lineTo(sx + height, y);
|
|
992
|
+
ctx.stroke();
|
|
993
|
+
}
|
|
994
|
+
ctx.restore();
|
|
995
|
+
}
|
|
996
|
+
};
|
|
959
997
|
var drawEvents = (ctx, view, scene, font, animator) => {
|
|
960
998
|
var _a;
|
|
961
999
|
if (view.tick === null) return;
|
|
@@ -968,7 +1006,7 @@ var drawEvents = (ctx, view, scene, font, animator) => {
|
|
|
968
1006
|
const selectedIds = view.selectedEventIds;
|
|
969
1007
|
const hasSelection = selectedIds.size > 0;
|
|
970
1008
|
const deferred = [];
|
|
971
|
-
const paintEvent = (event, rect, state, opts) => {
|
|
1009
|
+
const paintEvent = (event, rect, state, opts, rowStatics) => {
|
|
972
1010
|
var _a2, _b, _c, _d, _e;
|
|
973
1011
|
ctx.save();
|
|
974
1012
|
ctx.globalAlpha = 1;
|
|
@@ -985,6 +1023,17 @@ var drawEvents = (ctx, view, scene, font, animator) => {
|
|
|
985
1023
|
if (!drawn) {
|
|
986
1024
|
defaultDrawEvent(ctx, event, rect, view, font, geometry.barRadius);
|
|
987
1025
|
}
|
|
1026
|
+
if (view.stripeOverlap && rowStatics.length > 0) {
|
|
1027
|
+
paintOverlapStripes(
|
|
1028
|
+
ctx,
|
|
1029
|
+
event,
|
|
1030
|
+
rect,
|
|
1031
|
+
rowStatics,
|
|
1032
|
+
windowStart,
|
|
1033
|
+
tick,
|
|
1034
|
+
view.theme.overlapStripeColor
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
988
1037
|
if (canResizeEvent(event, view.eventsResize)) {
|
|
989
1038
|
const alpha = animator.handleAlpha(
|
|
990
1039
|
event.id,
|
|
@@ -1010,11 +1059,12 @@ var drawEvents = (ctx, view, scene, font, animator) => {
|
|
|
1010
1059
|
if (rowY + rowHeight < 0) continue;
|
|
1011
1060
|
if (rowY > view.height) break;
|
|
1012
1061
|
const lanes = scene.getLanes(rowId, windowStart, windowEnd);
|
|
1013
|
-
|
|
1062
|
+
const rowStatics = cullToWindow(
|
|
1014
1063
|
scene.getRowStaticEvents(rowId),
|
|
1015
1064
|
windowStart,
|
|
1016
1065
|
windowEnd
|
|
1017
|
-
)
|
|
1066
|
+
);
|
|
1067
|
+
for (const event of rowStatics) {
|
|
1018
1068
|
const x = timeToX(event.startTime, windowStart, tick);
|
|
1019
1069
|
const width = timeToWidth(event.startTime, event.endTime, tick);
|
|
1020
1070
|
ctx.fillStyle = view.theme.staticEventFill;
|
|
@@ -1059,10 +1109,16 @@ var drawEvents = (ctx, view, scene, font, animator) => {
|
|
|
1059
1109
|
};
|
|
1060
1110
|
if (selected) {
|
|
1061
1111
|
deferred.push(
|
|
1062
|
-
() => paintEvent(event, rect, state, { dim: false, elevate: true })
|
|
1112
|
+
() => paintEvent(event, rect, state, { dim: false, elevate: true }, rowStatics)
|
|
1063
1113
|
);
|
|
1064
1114
|
} else {
|
|
1065
|
-
paintEvent(
|
|
1115
|
+
paintEvent(
|
|
1116
|
+
event,
|
|
1117
|
+
rect,
|
|
1118
|
+
state,
|
|
1119
|
+
{ dim: hasSelection, elevate: false },
|
|
1120
|
+
rowStatics
|
|
1121
|
+
);
|
|
1066
1122
|
}
|
|
1067
1123
|
}
|
|
1068
1124
|
}
|
|
@@ -1085,6 +1141,7 @@ var TimelineRenderer = class {
|
|
|
1085
1141
|
theme: DEFAULT_THEME,
|
|
1086
1142
|
drawEvent: void 0,
|
|
1087
1143
|
eventsResize: true,
|
|
1144
|
+
stripeOverlap: false,
|
|
1088
1145
|
hoveredEventId: null,
|
|
1089
1146
|
draggedEventId: null,
|
|
1090
1147
|
resizePreview: null,
|
|
@@ -1960,6 +2017,7 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
1960
2017
|
onEventClick,
|
|
1961
2018
|
onEventHover,
|
|
1962
2019
|
eventsResize,
|
|
2020
|
+
stripeOverlap,
|
|
1963
2021
|
panZoom,
|
|
1964
2022
|
animations,
|
|
1965
2023
|
selectable,
|
|
@@ -1998,7 +2056,8 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
1998
2056
|
cellWidth,
|
|
1999
2057
|
theme,
|
|
2000
2058
|
drawEvent,
|
|
2001
|
-
eventsResize
|
|
2059
|
+
eventsResize,
|
|
2060
|
+
stripeOverlap
|
|
2002
2061
|
});
|
|
2003
2062
|
}, [
|
|
2004
2063
|
windowTime,
|
|
@@ -2007,6 +2066,7 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2007
2066
|
theme,
|
|
2008
2067
|
drawEvent,
|
|
2009
2068
|
eventsResize,
|
|
2069
|
+
stripeOverlap,
|
|
2010
2070
|
animations,
|
|
2011
2071
|
rendererRef
|
|
2012
2072
|
]);
|
|
@@ -2733,6 +2793,7 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2733
2793
|
additionalClassNames,
|
|
2734
2794
|
showRTIndicator = true,
|
|
2735
2795
|
eventsResize = true,
|
|
2796
|
+
stripeOverlap = false,
|
|
2736
2797
|
eventPromptTemplate,
|
|
2737
2798
|
showEventPrompt = true,
|
|
2738
2799
|
panZoom,
|
|
@@ -2974,6 +3035,7 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2974
3035
|
onEventClick,
|
|
2975
3036
|
onEventHover,
|
|
2976
3037
|
eventsResize,
|
|
3038
|
+
stripeOverlap,
|
|
2977
3039
|
panZoom,
|
|
2978
3040
|
animations: resolvedAnimations,
|
|
2979
3041
|
selectable,
|