@getsoren/design-system 4.53.1 → 4.54.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/main.cjs +61 -61
- package/dist/main.js +4534 -4474
- package/dist/src/components/DataDisplay/PlanningTimeline/PlanningTimeline.d.ts +2 -2
- package/dist/src/components/DataDisplay/PlanningTimeline/components/TaskBar.d.ts +1 -1
- package/dist/src/components/DataDisplay/PlanningTimeline/types.d.ts +169 -42
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PlanningTimelineProps, PlanningTimelineTask } from './types';
|
|
2
|
-
declare const PlanningTimeline: <T extends PlanningTimelineTask>({ tasks, isLoading,
|
|
1
|
+
import { PlanningTimelineGroup, PlanningTimelineProps, PlanningTimelineResource, PlanningTimelineTask } from './types';
|
|
2
|
+
declare const PlanningTimeline: <G extends PlanningTimelineGroup, R extends PlanningTimelineResource, T extends PlanningTimelineTask>({ groups, resources, tasks, isLoading, onTaskClick, onResourceClick, onGroupClick, onBarResize, renderGroup, renderResource, renderBar, renderTooltip, isTaskSelected, recenterKey, toolbarActions, sidebarTitle, locale, labels, localStorageKeys, defaultViewMode, sidebarWidth, rowHeight, }: PlanningTimelineProps<G, R, T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default PlanningTimeline;
|
|
@@ -3,7 +3,7 @@ import { PlanningTimelineBarContext, PlanningTimelineTask } from '../types';
|
|
|
3
3
|
import { TimeScale } from '../utils/timeScale';
|
|
4
4
|
interface TaskBarProps<T extends PlanningTimelineTask> {
|
|
5
5
|
/**
|
|
6
|
-
* The task
|
|
6
|
+
* The task this bar represents — its start/end drive the bar geometry, its statusColor the
|
|
7
7
|
* hue, and its overdue/plannedEnd/incidents the hatched overlays.
|
|
8
8
|
*/
|
|
9
9
|
task: T;
|
|
@@ -1,58 +1,131 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ViewMode } from './utils/timeScale';
|
|
3
3
|
export type PlanningTimelineViewMode = ViewMode;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* MUI palette color driving a bar's hue; "default" renders muted (grey).
|
|
6
|
+
*/
|
|
6
7
|
export type PlanningTimelineStatusColor = "default" | "error" | "info" | "success" | "warning";
|
|
7
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* An incident (e.g. a breakdown) rendered as a hatched day-wide segment on the bar.
|
|
10
|
+
*/
|
|
8
11
|
export interface PlanningTimelineIncident {
|
|
9
12
|
incidentDate: string | Date;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
|
-
* A
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
+
* A collapsible section header grouping resources (e.g. an equipment status). Extend this interface
|
|
16
|
+
* to attach your own domain data and get it back, typed, in `renderGroup` and `onGroupClick`.
|
|
17
|
+
*/
|
|
18
|
+
export interface PlanningTimelineGroup {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the group's resources are hidden. Toggle it from `onGroupClick` to make headers collapsible.
|
|
23
|
+
*/
|
|
24
|
+
collapsed?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Count shown next to the name. Defaults to the number of resources in the group (override e.g. when paginating).
|
|
27
|
+
*/
|
|
28
|
+
childCount?: number;
|
|
29
|
+
/**
|
|
30
|
+
* The group's data is being fetched.
|
|
31
|
+
*/
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A timeline resource (a left-column cell and its horizontal track), e.g. one equipment. A resource
|
|
36
|
+
* carries zero or more task bars — a resource without any task renders an empty track (e.g. an idle
|
|
37
|
+
* equipment). Extend this interface to attach your own domain data and get it back, typed, in
|
|
38
|
+
* `renderResource` and `onResourceClick`.
|
|
39
|
+
*/
|
|
40
|
+
export interface PlanningTimelineResource {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
/**
|
|
44
|
+
* Id of the `groups` entry this resource belongs to; omit for an ungrouped top-level resource.
|
|
45
|
+
*/
|
|
46
|
+
groupId?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A bar on a resource's track, e.g. one booking. Bars paint in array order (later tasks above
|
|
50
|
+
* earlier ones when they overlap). Extend this interface to attach your own domain data and get it
|
|
51
|
+
* back, typed, in every render prop and callback.
|
|
15
52
|
*/
|
|
16
53
|
export interface PlanningTimelineTask {
|
|
17
54
|
id: string;
|
|
18
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Id of the `resources` entry this bar is drawn on.
|
|
57
|
+
*/
|
|
58
|
+
resourceId: string;
|
|
19
59
|
name: string;
|
|
20
60
|
start: Date;
|
|
21
61
|
end: Date;
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
project?: string;
|
|
26
|
-
/** Incidents rendered as red hatched day-wide segments on the bar. */
|
|
62
|
+
/**
|
|
63
|
+
* Incidents rendered as red hatched day-wide segments on the bar.
|
|
64
|
+
*/
|
|
27
65
|
incidents?: PlanningTimelineIncident[];
|
|
28
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Original planned end (before any overdue extension of `end`).
|
|
68
|
+
*/
|
|
29
69
|
plannedEnd?: Date;
|
|
30
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Task past its planned end — the segment `plannedEnd` → `end` is hatched in warning.
|
|
72
|
+
*/
|
|
31
73
|
overdue?: boolean;
|
|
32
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* MUI palette color of the bar. @default "default"
|
|
76
|
+
*/
|
|
33
77
|
statusColor?: PlanningTimelineStatusColor;
|
|
34
|
-
/** For project (group header) rows: number of task rows in the group. */
|
|
35
|
-
childCount?: number;
|
|
36
|
-
/** For project rows: the group's data is being fetched. */
|
|
37
|
-
loading?: boolean;
|
|
38
78
|
}
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Context given to `renderGroup` for a group header cell.
|
|
81
|
+
*/
|
|
82
|
+
export interface PlanningTimelineGroupContext<G extends PlanningTimelineGroup = PlanningTimelineGroup> {
|
|
83
|
+
/**
|
|
84
|
+
* Forwarded `onGroupClick` — call it to make the whole header clickable (e.g. a collapse toggle).
|
|
85
|
+
*/
|
|
86
|
+
onJump: (group: G) => void;
|
|
87
|
+
sidebarCollapsed: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* `group.childCount` when set, otherwise the number of resources in the group.
|
|
90
|
+
*/
|
|
91
|
+
childCount: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Context given to `renderResource` for a left-column resource cell.
|
|
95
|
+
*/
|
|
96
|
+
export interface PlanningTimelineResourceContext<R extends PlanningTimelineResource = PlanningTimelineResource, T extends PlanningTimelineTask = PlanningTimelineTask> {
|
|
97
|
+
/**
|
|
98
|
+
* Forwarded `onResourceClick` — call it to make the whole cell clickable like the bars.
|
|
99
|
+
*/
|
|
100
|
+
onJump: (resource: R) => void;
|
|
101
|
+
/**
|
|
102
|
+
* True when one of the resource's tasks is selected (`isTaskSelected`).
|
|
103
|
+
*/
|
|
43
104
|
selected: boolean;
|
|
44
105
|
sidebarCollapsed: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The resource's tasks (its bars), e.g. to summarize them in the cell.
|
|
108
|
+
*/
|
|
109
|
+
tasks: T[];
|
|
45
110
|
}
|
|
46
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Context given to `renderBar` for a bar's inner content.
|
|
113
|
+
*/
|
|
47
114
|
export interface PlanningTimelineBarContext {
|
|
48
115
|
sidebarCollapsed: boolean;
|
|
49
116
|
}
|
|
50
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* localStorage keys used to persist the timeline UI preferences.
|
|
119
|
+
*/
|
|
51
120
|
export interface PlanningTimelineLocalStorageKeys {
|
|
52
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Key storing the selected view mode. @default "soren-planning-timeline-view-mode"
|
|
123
|
+
*/
|
|
53
124
|
viewMode: string;
|
|
54
125
|
}
|
|
55
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* Built-in UI strings; each falls back to the design-system locale (en/fr) when not overridden.
|
|
128
|
+
*/
|
|
56
129
|
export interface PlanningTimelineLabels {
|
|
57
130
|
day: string;
|
|
58
131
|
week: string;
|
|
@@ -61,29 +134,79 @@ export interface PlanningTimelineLabels {
|
|
|
61
134
|
today: string;
|
|
62
135
|
noResult: string;
|
|
63
136
|
}
|
|
64
|
-
export interface PlanningTimelineProps<T extends PlanningTimelineTask = PlanningTimelineTask> {
|
|
137
|
+
export interface PlanningTimelineProps<G extends PlanningTimelineGroup = PlanningTimelineGroup, R extends PlanningTimelineResource = PlanningTimelineResource, T extends PlanningTimelineTask = PlanningTimelineTask> {
|
|
138
|
+
/**
|
|
139
|
+
* Collapsible section headers; resources reference them via `groupId`. Omit for a flat list of resources.
|
|
140
|
+
*/
|
|
141
|
+
groups?: G[];
|
|
142
|
+
/**
|
|
143
|
+
* The timeline resources (left-column cells); tasks reference them via `resourceId`.
|
|
144
|
+
*/
|
|
145
|
+
resources?: R[];
|
|
146
|
+
/**
|
|
147
|
+
* The bars; each is drawn on the resource matching its `resourceId`.
|
|
148
|
+
*/
|
|
65
149
|
tasks?: T[];
|
|
150
|
+
/**
|
|
151
|
+
* Whether the timeline is loading data — shows a skeleton and disables interactions.
|
|
152
|
+
*/
|
|
66
153
|
isLoading?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Click a bar — e.g. open the task's detail view.
|
|
156
|
+
*/
|
|
157
|
+
onTaskClick?: (task: T) => void;
|
|
158
|
+
/**
|
|
159
|
+
* Click a resource's left-column cell.
|
|
160
|
+
*/
|
|
161
|
+
onResourceClick?: (resource: R) => void;
|
|
162
|
+
/**
|
|
163
|
+
* Click a group header — e.g. toggle its `collapsed` flag.
|
|
164
|
+
*/
|
|
165
|
+
onGroupClick?: (group: G) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Drag the right edge of a bar — extend the task to `newEnd`. Omit to disable resizing.
|
|
168
|
+
*/
|
|
70
169
|
onBarResize?: (task: T, newEnd: Date) => void;
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Group header cell renderer. Defaults to the group name, its resource count and a collapse chevron.
|
|
172
|
+
*/
|
|
173
|
+
renderGroup?: (group: G, context: PlanningTimelineGroupContext<G>) => ReactNode;
|
|
174
|
+
/**
|
|
175
|
+
* Left-column resource cell renderer. Defaults to the resource name.
|
|
176
|
+
*/
|
|
177
|
+
renderResource?: (resource: R, context: PlanningTimelineResourceContext<R, T>) => ReactNode;
|
|
178
|
+
/**
|
|
179
|
+
* Inner content of a bar. Defaults to the task name.
|
|
180
|
+
*/
|
|
74
181
|
renderBar?: (task: T, context: PlanningTimelineBarContext) => ReactNode;
|
|
75
182
|
renderTooltip?: (task: T) => ReactNode;
|
|
76
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Whether a task is the currently selected one (e.g. its detail view is open).
|
|
185
|
+
*/
|
|
77
186
|
isTaskSelected?: (task: T) => boolean;
|
|
78
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* Opaque value that changes when filters change — the timeline re-centres on today when it does.
|
|
189
|
+
*/
|
|
79
190
|
recenterKey?: string;
|
|
80
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Extra content rendered in the toolbar, just left of the view-mode toggle (e.g. a grouping switch).
|
|
193
|
+
*/
|
|
194
|
+
toolbarActions?: ReactNode;
|
|
195
|
+
/**
|
|
196
|
+
* Title of the left (frozen) column, also used as the collapse button tooltip.
|
|
197
|
+
*/
|
|
81
198
|
sidebarTitle?: string;
|
|
82
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* BCP 47 locale for the axis and toolbar date labels (e.g. "fr"). @default "en"
|
|
201
|
+
*/
|
|
83
202
|
locale?: string;
|
|
84
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Override the built-in labels (e.g. to plug the host app's i18n).
|
|
205
|
+
*/
|
|
85
206
|
labels?: Partial<PlanningTimelineLabels>;
|
|
86
|
-
/**
|
|
207
|
+
/**
|
|
208
|
+
* Initial zoom level, when none is persisted yet. @default "day"
|
|
209
|
+
*/
|
|
87
210
|
defaultViewMode?: PlanningTimelineViewMode;
|
|
88
211
|
/**
|
|
89
212
|
* localStorage keys used to persist UI preferences. Override them to namespace the keys per
|
|
@@ -91,8 +214,12 @@ export interface PlanningTimelineProps<T extends PlanningTimelineTask = Planning
|
|
|
91
214
|
* @default { viewMode: "soren-planning-timeline-view-mode" }
|
|
92
215
|
*/
|
|
93
216
|
localStorageKeys?: Partial<PlanningTimelineLocalStorageKeys>;
|
|
94
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Width (px) of the left column. @default 300
|
|
219
|
+
*/
|
|
95
220
|
sidebarWidth?: number;
|
|
96
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Height (px) of every row (group headers and resources alike). @default 56
|
|
223
|
+
*/
|
|
97
224
|
rowHeight?: number;
|
|
98
225
|
}
|