@agregio-solutions/design-system 1.97.1 → 1.98.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/design-system.cjs +2 -2
- package/dist/design-system.js +1489 -1478
- package/dist/packages/components/Timeline/components/GroupLineContainer/GroupLineContainer.d.ts +3 -2
- package/dist/packages/components/Timeline/doc.md +62 -0
- package/dist/packages/components/Timeline/utils/Timeline.types.d.ts +27 -0
- package/dist/packages/components/Timeline/utils/mergeBlocksByColor/mergeBlocksByColor.d.ts +2 -2
- package/package.json +1 -1
package/dist/packages/components/Timeline/components/GroupLineContainer/GroupLineContainer.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Block, SubLine } from '../../utils/Timeline.types';
|
|
1
|
+
import { Block, GroupHoverTextFormatter, SubLine } from '../../utils/Timeline.types';
|
|
2
2
|
interface Props {
|
|
3
3
|
name: string;
|
|
4
4
|
subLines: Array<SubLine>;
|
|
5
5
|
lineStartDate: Block["startDate"];
|
|
6
6
|
lineEndDate: Block["endDate"];
|
|
7
|
+
groupHoverText?: GroupHoverTextFormatter;
|
|
7
8
|
}
|
|
8
|
-
export default function GroupLineContainer({ name, subLines, lineStartDate, lineEndDate, }: Props): import("react").JSX.Element;
|
|
9
|
+
export default function GroupLineContainer({ name, subLines, lineStartDate, lineEndDate, groupHoverText, }: Props): import("react").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -704,6 +704,52 @@ export const GroupWithOverflow: Story = {
|
|
|
704
704
|
},
|
|
705
705
|
};
|
|
706
706
|
|
|
707
|
+
export const GroupCustomHoverText: Story = {
|
|
708
|
+
args: {
|
|
709
|
+
startDate: new Date("2024-01-01T00:00:00.000Z"),
|
|
710
|
+
endDate: new Date("2024-01-08T00:00:00.000Z"),
|
|
711
|
+
lines: [
|
|
712
|
+
{
|
|
713
|
+
type: "group",
|
|
714
|
+
name: "Installation 5",
|
|
715
|
+
groupHoverText: ({ blocks }) => `${blocks.length} indisponibilité(s)`,
|
|
716
|
+
subLines: [
|
|
717
|
+
{
|
|
718
|
+
name: "Installation 5 PRM_1",
|
|
719
|
+
blocks: [
|
|
720
|
+
{
|
|
721
|
+
id: "unavailability-1",
|
|
722
|
+
startDate: new Date("2024-01-01T00:00:00.000Z"),
|
|
723
|
+
endDate: new Date("2024-01-03T00:00:00.000Z"),
|
|
724
|
+
color: "var(--color-content-dataviz-pink-3)",
|
|
725
|
+
hoverText: "Installation 5 PRM_1 - Indisponibilité 1",
|
|
726
|
+
},
|
|
727
|
+
],
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
name: "Installation 5 PRM_2",
|
|
731
|
+
blocks: [
|
|
732
|
+
{
|
|
733
|
+
id: "unavailability-1",
|
|
734
|
+
startDate: new Date("2024-01-02T00:00:00.000Z"),
|
|
735
|
+
endDate: new Date("2024-01-04T00:00:00.000Z"),
|
|
736
|
+
color: "var(--color-content-dataviz-pink-3)",
|
|
737
|
+
hoverText: "Installation 5 PRM_2 - Indisponibilité 1",
|
|
738
|
+
},
|
|
739
|
+
],
|
|
740
|
+
},
|
|
741
|
+
],
|
|
742
|
+
},
|
|
743
|
+
],
|
|
744
|
+
},
|
|
745
|
+
play: async ({ canvasElement, mount }) => {
|
|
746
|
+
MockDate.set("2024-01-05T12:00:00.000Z");
|
|
747
|
+
await mount();
|
|
748
|
+
const canvas = within(canvasElement);
|
|
749
|
+
await canvas.findByTestId("2 indisponibilité(s)");
|
|
750
|
+
},
|
|
751
|
+
};
|
|
752
|
+
|
|
707
753
|
export const MixedSimpleAndGroup: Story = {
|
|
708
754
|
args: {
|
|
709
755
|
startDate: new Date("2024-01-01T00:00:00.000Z"),
|
|
@@ -1018,6 +1064,22 @@ Use `type: "group"` with a `subLines` array instead of a `blocks` array.
|
|
|
1018
1064
|
|
|
1019
1065
|
When collapsed, the group displays a **merged view** of all sub-lines' blocks. Blocks sharing the same color are merged into a single block spanning their combined range. This gives a quick overview of activity across all sub-lines.
|
|
1020
1066
|
|
|
1067
|
+
By default, hovering a merged block shows its date range. Provide a `groupHoverText` function on the group line to customize this text. It receives the merged interval's `startDate`, `endDate`, `color`, and the original `blocks` that were merged into it:
|
|
1068
|
+
|
|
1069
|
+
```ts
|
|
1070
|
+
{
|
|
1071
|
+
type: "group",
|
|
1072
|
+
name: "Installation 3",
|
|
1073
|
+
groupHoverText: ({ startDate, endDate, blocks }) =>
|
|
1074
|
+
`${blocks.length} events between ${startDate} and ${endDate}`,
|
|
1075
|
+
subLines: [ /* ... */ ],
|
|
1076
|
+
}
|
|
1077
|
+
```
|
|
1078
|
+
|
|
1079
|
+
Give `groupHoverText` a stable identity (`useCallback`, or defined outside the component) — it's used as a dependency to memoize the merge computation, so a new function on every render defeats that memoization.
|
|
1080
|
+
|
|
1081
|
+
<Canvas of={Timeline.GroupCustomHoverText} />
|
|
1082
|
+
|
|
1021
1083
|
### Expanded state
|
|
1022
1084
|
|
|
1023
1085
|
Clicking the group name **expands** it, revealing each sub-line on its own indented row. Clicking again collapses it back.
|
|
@@ -34,6 +34,25 @@ export type Block = {
|
|
|
34
34
|
*/
|
|
35
35
|
onClick?: () => void;
|
|
36
36
|
};
|
|
37
|
+
export type MergedBlock = {
|
|
38
|
+
/**
|
|
39
|
+
* The start date of the merged interval
|
|
40
|
+
*/
|
|
41
|
+
startDate: Date;
|
|
42
|
+
/**
|
|
43
|
+
* The end date of the merged interval
|
|
44
|
+
*/
|
|
45
|
+
endDate: Date;
|
|
46
|
+
/**
|
|
47
|
+
* The color shared by all blocks merged into this interval
|
|
48
|
+
*/
|
|
49
|
+
color: Block["color"];
|
|
50
|
+
/**
|
|
51
|
+
* The original blocks (from all sub-lines) that were merged into this interval
|
|
52
|
+
*/
|
|
53
|
+
blocks: Array<Block>;
|
|
54
|
+
};
|
|
55
|
+
export type GroupHoverTextFormatter = (mergedBlock: MergedBlock) => string;
|
|
37
56
|
export type SubLine = {
|
|
38
57
|
/**
|
|
39
58
|
* The name of the sub-line, displayed at the left when expanded
|
|
@@ -71,6 +90,14 @@ export type GroupLine = {
|
|
|
71
90
|
* The sub-lines to display when expanded
|
|
72
91
|
*/
|
|
73
92
|
subLines: Array<SubLine>;
|
|
93
|
+
/**
|
|
94
|
+
* Custom formatter for the hover text of the merged blocks shown on the group's
|
|
95
|
+
* collapsed row. Receives the merged date range, color, and the original blocks
|
|
96
|
+
* that were merged into it. Defaults to a "start date - end date" format.
|
|
97
|
+
* Give it a stable identity (e.g. via `useCallback`, or defined outside the
|
|
98
|
+
* component) so the merge computation isn't redone on every render.
|
|
99
|
+
*/
|
|
100
|
+
groupHoverText?: GroupHoverTextFormatter;
|
|
74
101
|
};
|
|
75
102
|
export type Line = SimpleLine | GroupLine;
|
|
76
103
|
export declare function isGroupLine(line: Line): line is GroupLine;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Block, SubLine } from '../Timeline.types';
|
|
1
|
+
import { Block, GroupHoverTextFormatter, SubLine } from '../Timeline.types';
|
|
2
2
|
/**
|
|
3
3
|
* Merges blocks from all sub-lines by color.
|
|
4
4
|
* For each color group, overlapping intervals are merged into a single block.
|
|
5
5
|
* Returns a flat array of merged blocks.
|
|
6
6
|
*/
|
|
7
|
-
export declare function mergeBlocksByColor(subLines: SubLine[]): Block[];
|
|
7
|
+
export declare function mergeBlocksByColor(subLines: SubLine[], groupHoverText?: GroupHoverTextFormatter): Block[];
|
package/package.json
CHANGED