doom-design-system 0.5.0 → 0.6.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/components/Accordion/Accordion.module.css +121 -124
- package/dist/components/ActionRow/ActionRow.module.css +25 -24
- package/dist/components/Alert/Alert.module.css +74 -76
- package/dist/components/Avatar/Avatar.module.css +66 -66
- package/dist/components/Badge/Badge.module.css +50 -48
- package/dist/components/Breadcrumbs/Breadcrumbs.module.css +32 -33
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Button/Button.module.css +150 -152
- package/dist/components/Card/Card.module.css +37 -39
- package/dist/components/Chart/Chart.module.css +213 -245
- package/dist/components/Chart/behaviors/DraggablePuck.d.ts +36 -0
- package/dist/components/Chart/behaviors/DraggablePuck.js +94 -0
- package/dist/components/Chart/behaviors/Markers.js +6 -4
- package/dist/components/Chart/behaviors/SelectionUpdate.js +2 -4
- package/dist/components/Chart/behaviors/index.d.ts +1 -1
- package/dist/components/Chart/behaviors/index.js +1 -1
- package/dist/components/Chart/engine/CoordinateSystem.d.ts +59 -0
- package/dist/components/Chart/engine/CoordinateSystem.js +126 -0
- package/dist/components/Chart/engine/Engine.d.ts +102 -0
- package/dist/components/Chart/engine/Engine.js +226 -0
- package/dist/components/Chart/engine/Scheduler.d.ts +59 -0
- package/dist/components/Chart/engine/Scheduler.js +139 -0
- package/dist/components/Chart/engine/SpatialMap.d.ts +114 -0
- package/dist/components/Chart/engine/SpatialMap.js +270 -0
- package/dist/components/Chart/engine/index.d.ts +13 -0
- package/dist/components/Chart/engine/index.js +9 -0
- package/dist/components/Chart/engine/types.d.ts +137 -0
- package/dist/components/Chart/engine/types.js +47 -0
- package/dist/components/Chart/hooks/useEngine.d.ts +43 -0
- package/dist/components/Chart/hooks/useEngine.js +128 -0
- package/dist/components/Chart/sensors/DataHoverSensor/DataHoverSensor.d.ts +17 -19
- package/dist/components/Chart/sensors/DataHoverSensor/DataHoverSensor.js +38 -51
- package/dist/components/Chart/sensors/DragSensor/DragSensor.d.ts +38 -0
- package/dist/components/Chart/sensors/DragSensor/DragSensor.js +105 -0
- package/dist/components/Chart/sensors/DragSensor/index.d.ts +2 -0
- package/dist/components/Chart/sensors/DragSensor/index.js +1 -0
- package/dist/components/Chart/sensors/{KeyboardSensor.d.ts → KeyboardSensor/KeyboardSensor.d.ts} +1 -1
- package/dist/components/Chart/sensors/KeyboardSensor/KeyboardSensor.js +86 -0
- package/dist/components/Chart/sensors/KeyboardSensor/index.d.ts +1 -0
- package/dist/components/Chart/sensors/KeyboardSensor/index.js +1 -0
- package/dist/components/Chart/sensors/{SelectionSensor.d.ts → SelectionSensor/SelectionSensor.d.ts} +2 -2
- package/dist/components/Chart/sensors/SelectionSensor/SelectionSensor.js +39 -0
- package/dist/components/Chart/sensors/SelectionSensor/index.d.ts +1 -0
- package/dist/components/Chart/sensors/SelectionSensor/index.js +1 -0
- package/dist/components/Chart/sensors/SensorManager/SensorManager.js +36 -41
- package/dist/components/Chart/sensors/index.d.ts +1 -0
- package/dist/components/Chart/sensors/index.js +3 -2
- package/dist/components/Chart/sensors/utils/search.d.ts +1 -1
- package/dist/components/Chart/sensors/utils/search.js +25 -4
- package/dist/components/Chart/state/store/chart.store.js +18 -0
- package/dist/components/Chart/state/store/slices/series.slice.d.ts +1 -0
- package/dist/components/Chart/state/store/slices/series.slice.js +3 -2
- package/dist/components/Chart/subcomponents/Axis/Axis.module.css +32 -33
- package/dist/components/Chart/subcomponents/BarSeries/BarSeries.js +6 -1
- package/dist/components/Chart/subcomponents/BarSeries/BarSeries.module.css +11 -9
- package/dist/components/Chart/subcomponents/Cursor/Cursor.js +8 -1
- package/dist/components/Chart/subcomponents/Cursor/Cursor.module.css +14 -13
- package/dist/components/Chart/subcomponents/CustomSeries/CustomSeries.js +4 -0
- package/dist/components/Chart/subcomponents/CustomSeries/CustomSeries.module.css +5 -3
- package/dist/components/Chart/subcomponents/Footer/Footer.module.css +5 -3
- package/dist/components/Chart/subcomponents/Grid/Grid.module.css +12 -11
- package/dist/components/Chart/subcomponents/Header/Header.module.css +8 -7
- package/dist/components/Chart/subcomponents/InteractionLayer/InteractionLayer.d.ts +4 -4
- package/dist/components/Chart/subcomponents/InteractionLayer/InteractionLayer.js +39 -76
- package/dist/components/Chart/subcomponents/Legend/Legend.module.css +30 -32
- package/dist/components/Chart/subcomponents/LineSeries/LineSeries.js +9 -3
- package/dist/components/Chart/subcomponents/LineSeries/LineSeries.module.css +21 -21
- package/dist/components/Chart/subcomponents/Root/Root.js +113 -7
- package/dist/components/Chart/subcomponents/Root/Root.module.css +70 -82
- package/dist/components/Chart/subcomponents/ScatterSeries/ScatterSeries.js +6 -1
- package/dist/components/Chart/subcomponents/ScatterSeries/ScatterSeries.module.css +7 -5
- package/dist/components/Chart/subcomponents/Series/Series.module.css +118 -128
- package/dist/components/Chart/subcomponents/SeriesPoint/SeriesPoint.module.css +10 -8
- package/dist/components/Chart/subcomponents/Tooltip/Tooltip.js +2 -3
- package/dist/components/Chart/subcomponents/Tooltip/Tooltip.module.css +52 -67
- package/dist/components/Chart/types/context.d.ts +9 -0
- package/dist/components/Chart/types/events.d.ts +5 -7
- package/dist/components/Chart/types/interaction.d.ts +24 -2
- package/dist/components/Chart/types/interaction.js +1 -0
- package/dist/components/Checkbox/Checkbox.module.css +57 -59
- package/dist/components/Chip/Chip.module.css +105 -115
- package/dist/components/Combobox/Combobox.d.ts +2 -1
- package/dist/components/Combobox/Combobox.js +2 -2
- package/dist/components/Combobox/Combobox.module.css +233 -210
- package/dist/components/CopyButton/CopyButton.module.css +84 -90
- package/dist/components/Drawer/Drawer.module.css +126 -145
- package/dist/components/Dropdown/Dropdown.d.ts +3 -1
- package/dist/components/Dropdown/Dropdown.js +3 -3
- package/dist/components/Dropdown/Dropdown.module.css +52 -32
- package/dist/components/FileUpload/FileUpload.js +24 -0
- package/dist/components/FileUpload/FileUpload.module.css +295 -313
- package/dist/components/Form/Form.module.css +35 -39
- package/dist/components/Image/Image.module.css +53 -54
- package/dist/components/Input/Input.d.ts +4 -2
- package/dist/components/Input/Input.js +2 -2
- package/dist/components/Input/Input.module.css +135 -119
- package/dist/components/Label/Label.module.css +17 -15
- package/dist/components/Layout/Layout.module.css +95 -111
- package/dist/components/Link/Link.module.css +67 -65
- package/dist/components/Modal/Modal.module.css +112 -132
- package/dist/components/Page/Page.module.css +21 -21
- package/dist/components/Pagination/Pagination.module.css +56 -56
- package/dist/components/Popover/Popover.module.css +17 -16
- package/dist/components/ProgressBar/ProgressBar.module.css +36 -37
- package/dist/components/RadioGroup/RadioGroup.module.css +74 -77
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.js +2 -2
- package/dist/components/Select/Select.module.css +133 -98
- package/dist/components/Sheet/Sheet.module.css +134 -154
- package/dist/components/Sidebar/Sidebar.module.css +72 -74
- package/dist/components/Sidebar/subcomponents/Footer/Footer.module.css +7 -5
- package/dist/components/Sidebar/subcomponents/Group/Group.module.css +80 -85
- package/dist/components/Sidebar/subcomponents/Header/Header.module.css +12 -10
- package/dist/components/Sidebar/subcomponents/Item/Item.module.css +54 -55
- package/dist/components/Sidebar/subcomponents/MobileOverlay/MobileOverlay.module.css +38 -38
- package/dist/components/Sidebar/subcomponents/MobileTrigger/MobileTrigger.module.css +5 -3
- package/dist/components/Sidebar/subcomponents/Nav/Nav.module.css +13 -11
- package/dist/components/Sidebar/subcomponents/Rail/Rail.module.css +62 -63
- package/dist/components/Sidebar/subcomponents/Section/Section.module.css +86 -91
- package/dist/components/Skeleton/Skeleton.module.css +28 -26
- package/dist/components/Slat/Slat.module.css +93 -94
- package/dist/components/Slider/Slider.module.css +116 -121
- package/dist/components/Spinner/Spinner.module.css +28 -27
- package/dist/components/SplitButton/SplitButton.d.ts +3 -1
- package/dist/components/SplitButton/SplitButton.js +2 -2
- package/dist/components/SplitButton/SplitButton.module.css +104 -87
- package/dist/components/Switch/Switch.module.css +64 -63
- package/dist/components/Table/FilterBuilder/FilterBuilder.module.css +36 -36
- package/dist/components/Table/FilterBuilder/FilterConditionRow.js +1 -1
- package/dist/components/Table/FilterBuilder/FilterConditionRow.module.css +21 -22
- package/dist/components/Table/FilterBuilder/FilterGroup.js +4 -4
- package/dist/components/Table/FilterBuilder/FilterGroup.module.css +355 -389
- package/dist/components/Table/FilterBuilder/FilterSheet.module.css +68 -71
- package/dist/components/Table/Table.d.ts +4 -2
- package/dist/components/Table/Table.js +50 -13
- package/dist/components/Table/Table.module.css +210 -188
- package/dist/components/Table/TableHeaderFilter.js +1 -1
- package/dist/components/Table/TableHeaderFilter.module.css +51 -57
- package/dist/components/Tabs/Tabs.module.css +79 -80
- package/dist/components/Text/Text.module.css +108 -131
- package/dist/components/Textarea/Textarea.d.ts +3 -1
- package/dist/components/Textarea/Textarea.js +2 -2
- package/dist/components/Textarea/Textarea.module.css +114 -94
- package/dist/components/Toast/Toast.module.css +82 -82
- package/dist/components/Tooltip/Tooltip.module.css +17 -16
- package/dist/styles/globals.css +1677 -1691
- package/dist/styles/palettes.d.ts +0 -5
- package/dist/styles/palettes.js +0 -8
- package/dist/styles/themes/definitions.d.ts +0 -8
- package/dist/styles/themes/definitions.js +117 -5
- package/dist/styles/types.d.ts +2 -0
- package/dist/styles/types.js +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/.agent/skills/doom/a2ui/a2ui-examples.md +0 -289
- package/.agent/skills/doom/a2ui/a2ui-principles.md +0 -49
- package/.agent/skills/doom/a2ui/a2ui-protocol.md +0 -191
- package/.agent/skills/doom/components/a2ui.md +0 -46
- package/.agent/skills/doom/components/accordion.md +0 -44
- package/.agent/skills/doom/components/actionrow.md +0 -33
- package/.agent/skills/doom/components/alert.md +0 -35
- package/.agent/skills/doom/components/avatar.md +0 -36
- package/.agent/skills/doom/components/badge.md +0 -29
- package/.agent/skills/doom/components/breadcrumbs.md +0 -33
- package/.agent/skills/doom/components/button.md +0 -43
- package/.agent/skills/doom/components/card.md +0 -41
- package/.agent/skills/doom/components/chart.md +0 -106
- package/.agent/skills/doom/components/checkbox.md +0 -38
- package/.agent/skills/doom/components/chip.md +0 -35
- package/.agent/skills/doom/components/combobox.md +0 -50
- package/.agent/skills/doom/components/copybutton.md +0 -41
- package/.agent/skills/doom/components/drawer.md +0 -69
- package/.agent/skills/doom/components/dropdown.md +0 -33
- package/.agent/skills/doom/components/fileupload.md +0 -49
- package/.agent/skills/doom/components/form.md +0 -55
- package/.agent/skills/doom/components/icon.md +0 -47
- package/.agent/skills/doom/components/image.md +0 -48
- package/.agent/skills/doom/components/input.md +0 -54
- package/.agent/skills/doom/components/label.md +0 -32
- package/.agent/skills/doom/components/layout.md +0 -92
- package/.agent/skills/doom/components/link.md +0 -39
- package/.agent/skills/doom/components/modal.md +0 -71
- package/.agent/skills/doom/components/page.md +0 -41
- package/.agent/skills/doom/components/pagination.md +0 -32
- package/.agent/skills/doom/components/popover.md +0 -45
- package/.agent/skills/doom/components/progressbar.md +0 -37
- package/.agent/skills/doom/components/radiogroup.md +0 -45
- package/.agent/skills/doom/components/select.md +0 -43
- package/.agent/skills/doom/components/sheet.md +0 -71
- package/.agent/skills/doom/components/sidebar.md +0 -92
- package/.agent/skills/doom/components/skeleton.md +0 -35
- package/.agent/skills/doom/components/slat.md +0 -46
- package/.agent/skills/doom/components/slider.md +0 -51
- package/.agent/skills/doom/components/spinner.md +0 -34
- package/.agent/skills/doom/components/splitbutton.md +0 -35
- package/.agent/skills/doom/components/switch.md +0 -40
- package/.agent/skills/doom/components/table.md +0 -82
- package/.agent/skills/doom/components/tabs.md +0 -65
- package/.agent/skills/doom/components/text.md +0 -42
- package/.agent/skills/doom/components/textarea.md +0 -46
- package/.agent/skills/doom/components/toast.md +0 -59
- package/.agent/skills/doom/components/tooltip.md +0 -35
- package/.agent/skills/doom/index.md +0 -167
- package/.agent/skills/doom/styles/aesthetic.md +0 -151
- package/.agent/skills/doom/styles/css-variables.md +0 -80
- package/.agent/skills/doom/styles/mixins.md +0 -97
- package/.agent/skills/doom/styles/tokens.md +0 -129
- package/.agent/skills/doom/styles/utilities.md +0 -84
- package/dist/components/Chart/sensors/KeyboardSensor.js +0 -82
- package/dist/components/Chart/sensors/SelectionSensor.js +0 -41
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectionSensor.js";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useEffect, useMemo } from "react";
|
|
2
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { useChartContext } from "../../context.js";
|
|
4
|
-
import { useEventContext } from "../../state/EventContext.js";
|
|
5
4
|
import { removeInteraction, upsertInteraction, } from "../../state/store/chart.store.js";
|
|
6
5
|
import { InteractionChannel } from "../../types/interaction.js";
|
|
7
6
|
import { DataHoverSensor } from "../DataHoverSensor/DataHoverSensor.js";
|
|
8
|
-
import { KeyboardSensor } from "../KeyboardSensor.js";
|
|
7
|
+
import { KeyboardSensor } from "../KeyboardSensor/index.js";
|
|
9
8
|
/**
|
|
10
9
|
* The SensorManager is a headless component that manages the lifecycle of
|
|
11
10
|
* Chart Sensors. It coordinates event listeners, identifies default sensors
|
|
@@ -13,25 +12,25 @@ import { KeyboardSensor } from "../KeyboardSensor.js";
|
|
|
13
12
|
* to the interaction store.
|
|
14
13
|
*/
|
|
15
14
|
export const SensorManager = ({ sensors }) => {
|
|
16
|
-
const { chartStore, config, colorPalette } = useChartContext();
|
|
17
|
-
const eventContext = useEventContext();
|
|
18
|
-
// Subscribe to status and data for lifecycle protection
|
|
15
|
+
const { chartStore, config, colorPalette, engine } = useChartContext();
|
|
19
16
|
const status = chartStore.useStore((s) => s.status);
|
|
20
17
|
const data = chartStore.useStore((s) => s.data);
|
|
18
|
+
// Use a ref to access the latest colorPalette without triggering re-instantiation
|
|
19
|
+
const colorPaletteRef = useRef(colorPalette);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
colorPaletteRef.current = colorPalette;
|
|
22
|
+
}, [colorPalette]);
|
|
21
23
|
const activeSensors = useMemo(() => {
|
|
22
24
|
if (sensors && sensors.length > 0) {
|
|
23
25
|
return sensors;
|
|
24
26
|
}
|
|
25
|
-
// Default injection
|
|
26
27
|
const defaults = [];
|
|
27
28
|
const type = config.type || "line";
|
|
28
29
|
if (["line", "area", "bar", "scatter", "bubble"].includes(type)) {
|
|
29
|
-
const
|
|
30
|
-
? "closest"
|
|
31
|
-
: "nearest-x";
|
|
30
|
+
const isVerticalSliceType = ["line", "area", "bar"].includes(type);
|
|
32
31
|
defaults.push(DataHoverSensor({
|
|
33
|
-
mode,
|
|
34
32
|
name: InteractionChannel.PRIMARY_HOVER,
|
|
33
|
+
verticalSlice: isVerticalSliceType,
|
|
35
34
|
}));
|
|
36
35
|
// A11y: Always include keyboard sensor for line/bar/scatter
|
|
37
36
|
defaults.push(KeyboardSensor({
|
|
@@ -40,47 +39,43 @@ export const SensorManager = ({ sensors }) => {
|
|
|
40
39
|
}
|
|
41
40
|
else {
|
|
42
41
|
defaults.push(DataHoverSensor({
|
|
43
|
-
mode: "exact",
|
|
44
42
|
name: InteractionChannel.PRIMARY_HOVER,
|
|
45
43
|
}));
|
|
46
44
|
}
|
|
47
45
|
return defaults;
|
|
48
46
|
}, [sensors, config.type]);
|
|
49
47
|
useEffect(() => {
|
|
50
|
-
|
|
51
|
-
if (status !== "ready" || !data.length) {
|
|
48
|
+
if (status !== "ready" || !data.length || !engine) {
|
|
52
49
|
return;
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
51
|
+
const sensorContext = {
|
|
52
|
+
getChartContext: () => {
|
|
53
|
+
const state = chartStore.getState();
|
|
54
|
+
return Object.assign(Object.assign({}, state), { xScale: state.scales.x, yScale: state.scales.y, colorPalette: colorPaletteRef.current || [], chartStore });
|
|
55
|
+
},
|
|
56
|
+
getInteraction: (name) => {
|
|
57
|
+
return chartStore.getState().interactions.get(name) || null;
|
|
58
|
+
},
|
|
59
|
+
upsertInteraction: (name, value) => {
|
|
60
|
+
upsertInteraction(chartStore, name, value);
|
|
61
|
+
},
|
|
62
|
+
removeInteraction: (name) => {
|
|
63
|
+
removeInteraction(chartStore, name);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
engine.setHandler((event) => {
|
|
67
|
+
activeSensors.forEach((sensor) => {
|
|
68
|
+
try {
|
|
69
|
+
sensor(event, sensorContext);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
console.error("Sensor Error:", err);
|
|
73
|
+
}
|
|
75
74
|
});
|
|
76
75
|
});
|
|
77
76
|
return () => {
|
|
78
|
-
|
|
79
|
-
if (typeof cleanup === "function") {
|
|
80
|
-
cleanup();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
77
|
+
engine.setHandler(() => { });
|
|
83
78
|
};
|
|
84
|
-
}, [activeSensors,
|
|
79
|
+
}, [activeSensors, engine, chartStore, status, data.length]);
|
|
85
80
|
return null;
|
|
86
81
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./DataHoverSensor/index.js";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
2
|
+
export * from "./DragSensor/index.js";
|
|
3
|
+
export * from "./KeyboardSensor/index.js";
|
|
4
|
+
export * from "./SelectionSensor/index.js";
|
|
4
5
|
export * from "./SensorManager/index.js";
|
|
@@ -12,4 +12,4 @@ export interface SearchResult {
|
|
|
12
12
|
* Coordinated search logic to find target(s) across all registered series.
|
|
13
13
|
* This is the "Engine" of the sensor architecture.
|
|
14
14
|
*/
|
|
15
|
-
export declare const findClosestTargets: (event: ChartEvent, mode: HoverMode, state: State) => InteractionTarget[];
|
|
15
|
+
export declare const findClosestTargets: (event: ChartEvent, mode: HoverMode, state: State, radius?: number) => InteractionTarget[];
|
|
@@ -3,17 +3,38 @@ const INTERACTION_RADIUS = 50;
|
|
|
3
3
|
* Coordinated search logic to find target(s) across all registered series.
|
|
4
4
|
* This is the "Engine" of the sensor architecture.
|
|
5
5
|
*/
|
|
6
|
-
export const findClosestTargets = (event, mode, state) => {
|
|
6
|
+
export const findClosestTargets = (event, mode, state, radius = INTERACTION_RADIUS) => {
|
|
7
|
+
var _a, _b, _c;
|
|
7
8
|
const chartX = event.coordinates.chartX;
|
|
8
9
|
const chartY = event.coordinates.chartY;
|
|
9
|
-
// Exact target finding (DOM
|
|
10
|
+
// Exact target finding (DOM hit-test) - Uses elementFromPoint since
|
|
11
|
+
// events are captured at container level, not individual elements
|
|
10
12
|
if (mode === "exact") {
|
|
11
|
-
|
|
13
|
+
// First check if the event target itself has __data__ (direct click on element)
|
|
14
|
+
const directTarget = event.nativeEvent.target;
|
|
15
|
+
if (directTarget && directTarget.__data__) {
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
data: directTarget.__data__,
|
|
19
|
+
coordinate: { x: chartX, y: chartY },
|
|
20
|
+
seriesColor: ((_b = (_a = directTarget).getAttribute) === null || _b === void 0 ? void 0 : _b.call(_a, "fill")) || undefined,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
// Use elementFromPoint to find what's under the cursor
|
|
25
|
+
// IMPORTANT: Use the event target's ownerDocument for correct context (handles iframes)
|
|
26
|
+
const pointerEvent = event.nativeEvent;
|
|
27
|
+
const { clientX, clientY } = pointerEvent;
|
|
28
|
+
// Get the correct document - if the event target is in an iframe,
|
|
29
|
+
// its ownerDocument will be the iframe's document
|
|
30
|
+
const targetDoc = (directTarget === null || directTarget === void 0 ? void 0 : directTarget.ownerDocument) || document;
|
|
31
|
+
const domTarget = targetDoc.elementFromPoint(clientX, clientY);
|
|
12
32
|
if (domTarget && domTarget.__data__) {
|
|
13
33
|
return [
|
|
14
34
|
{
|
|
15
35
|
data: domTarget.__data__,
|
|
16
36
|
coordinate: { x: chartX, y: chartY },
|
|
37
|
+
seriesColor: ((_c = domTarget.getAttribute) === null || _c === void 0 ? void 0 : _c.call(domTarget, "fill")) || undefined,
|
|
17
38
|
},
|
|
18
39
|
];
|
|
19
40
|
}
|
|
@@ -31,7 +52,7 @@ export const findClosestTargets = (event, mode, state) => {
|
|
|
31
52
|
if (!series.strategy) {
|
|
32
53
|
return;
|
|
33
54
|
}
|
|
34
|
-
const result = series.strategy.find(chartX, chartY,
|
|
55
|
+
const result = series.strategy.find(chartX, chartY, radius, xScale, yScale);
|
|
35
56
|
if (result) {
|
|
36
57
|
targets.push(result);
|
|
37
58
|
}
|
|
@@ -64,11 +64,22 @@ export const updateChartState = (store, props) => {
|
|
|
64
64
|
innerHeight });
|
|
65
65
|
// Recalculate scales based on new data/type/dimensions
|
|
66
66
|
const nextScales = calculateScales(data, nextDimensions, Object.assign(Object.assign({}, prev), { type: type || prev.type }));
|
|
67
|
+
// Re-hydrate series with new data
|
|
68
|
+
// This is critical for real-time updates (e.g. drag interactions)
|
|
69
|
+
// We must use the stored configs to re-create the series strategies with the fresh data
|
|
70
|
+
const nextSeries = new Map();
|
|
71
|
+
const currentConfigs = prev.seriesConfigs || new Map();
|
|
72
|
+
currentConfigs.forEach((configs, id) => {
|
|
73
|
+
const hydrated = configs.map((c, i) => hydrateSeries(c, (prev.processedSeries.length || 0) + i, data));
|
|
74
|
+
nextSeries.set(id, hydrated);
|
|
75
|
+
});
|
|
67
76
|
return {
|
|
68
77
|
data,
|
|
69
78
|
type: type || prev.type,
|
|
70
79
|
dimensions: nextDimensions,
|
|
71
80
|
scales: nextScales,
|
|
81
|
+
series: nextSeries, // Update series map
|
|
82
|
+
processedSeries: combineSeries(nextSeries), // Update flattened series
|
|
72
83
|
status: nextDimensions.width > 0 && nextDimensions.height > 0
|
|
73
84
|
? "ready"
|
|
74
85
|
: "idle",
|
|
@@ -82,10 +93,14 @@ export const updateChartState = (store, props) => {
|
|
|
82
93
|
export const registerSeries = (store, id, configs) => {
|
|
83
94
|
store.setState((state) => {
|
|
84
95
|
const nextSeries = new Map(state.series);
|
|
96
|
+
const nextConfigs = new Map(state.seriesConfigs); // Clone configs map
|
|
97
|
+
// Store raw configs for future re-hydration
|
|
98
|
+
nextConfigs.set(id, configs);
|
|
85
99
|
const hydrated = configs.map((c, i) => hydrateSeries(c, (state.processedSeries.length || 0) + i, state.data));
|
|
86
100
|
nextSeries.set(id, hydrated);
|
|
87
101
|
return {
|
|
88
102
|
series: nextSeries,
|
|
103
|
+
seriesConfigs: nextConfigs,
|
|
89
104
|
processedSeries: combineSeries(nextSeries),
|
|
90
105
|
};
|
|
91
106
|
});
|
|
@@ -96,9 +111,12 @@ export const unregisterSeries = (store, id) => {
|
|
|
96
111
|
return state;
|
|
97
112
|
}
|
|
98
113
|
const nextSeries = new Map(state.series);
|
|
114
|
+
const nextConfigs = new Map(state.seriesConfigs);
|
|
99
115
|
nextSeries.delete(id);
|
|
116
|
+
nextConfigs.delete(id);
|
|
100
117
|
return {
|
|
101
118
|
series: nextSeries,
|
|
119
|
+
seriesConfigs: nextConfigs,
|
|
102
120
|
processedSeries: combineSeries(nextSeries),
|
|
103
121
|
};
|
|
104
122
|
});
|
|
@@ -3,10 +3,12 @@ import { LinearStrategy } from "../../../sensors/utils/strategies/LinearStrategy
|
|
|
3
3
|
import { QuadtreeStrategy } from "../../../sensors/utils/strategies/QuadtreeStrategy/index.js";
|
|
4
4
|
export const getSeriesInitialState = () => ({
|
|
5
5
|
series: new Map(),
|
|
6
|
+
seriesConfigs: new Map(),
|
|
6
7
|
processedSeries: [],
|
|
7
8
|
});
|
|
8
9
|
const LEGEND_PALETTE = ["#2E93fA", "#66DA26", "#546E7A", "#E91E63", "#FF9800"];
|
|
9
10
|
export const hydrateSeries = (props, index, defaultData) => {
|
|
11
|
+
const data = props.data || defaultData;
|
|
10
12
|
const series = {
|
|
11
13
|
id: props.id || `series-${index}`,
|
|
12
14
|
label: props.label || `Series ${index + 1}`,
|
|
@@ -16,9 +18,8 @@ export const hydrateSeries = (props, index, defaultData) => {
|
|
|
16
18
|
hideCursor: props.hideCursor,
|
|
17
19
|
interactionMode: props.interactionMode,
|
|
18
20
|
type: props.type,
|
|
21
|
+
data,
|
|
19
22
|
};
|
|
20
|
-
// --- Strategy Selection Heuristic ---
|
|
21
|
-
const data = props.data || defaultData;
|
|
22
23
|
if (!data || data.length === 0) {
|
|
23
24
|
series.strategy = new LinearStrategy(series, []);
|
|
24
25
|
return series;
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
text-anchor: middle;
|
|
1
|
+
@layer doom.components {
|
|
2
|
+
.axes {
|
|
3
|
+
pointer-events: none;
|
|
4
|
+
font-family: var(--font-montserrat); /* Keep this as it matches font-bold usually */
|
|
5
|
+
font-size: var(--text-xs);
|
|
6
|
+
}
|
|
7
|
+
.axes :global(.domain) {
|
|
8
|
+
stroke: var(--card-border);
|
|
9
|
+
stroke-width: var(--surface-border-width);
|
|
10
|
+
}
|
|
11
|
+
.axes :global(.domain).hideDomain {
|
|
12
|
+
stroke: none;
|
|
13
|
+
}
|
|
14
|
+
.axes :global(.tick) line {
|
|
15
|
+
stroke: var(--card-border);
|
|
16
|
+
stroke-width: var(--surface-border-width);
|
|
17
|
+
opacity: 1;
|
|
18
|
+
}
|
|
19
|
+
.axes :global(.tick) text {
|
|
20
|
+
fill: var(--foreground);
|
|
21
|
+
font-family: inherit;
|
|
22
|
+
font-weight: var(--font-bold);
|
|
23
|
+
text-transform: uppercase;
|
|
24
|
+
font-size: var(--text-xs);
|
|
25
|
+
}
|
|
26
|
+
.axes .label {
|
|
27
|
+
fill: var(--foreground);
|
|
28
|
+
font-size: var(--text-xs);
|
|
29
|
+
font-weight: var(--font-bold);
|
|
30
|
+
text-transform: uppercase;
|
|
31
|
+
text-anchor: middle;
|
|
32
|
+
}
|
|
34
33
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React, { useEffect, useId, useMemo } from "react";
|
|
4
4
|
import { useChartContext } from "../../context.js";
|
|
5
|
+
import { CHART_DATA_ATTRS } from "../../engine/index.js";
|
|
5
6
|
import { registerSeries, unregisterSeries, } from "../../state/store/chart.store.js";
|
|
6
7
|
import { resolveAccessor } from "../../utils/accessors.js";
|
|
7
8
|
import { createRoundedTopBarPath } from "../../utils/shapes.js";
|
|
@@ -24,6 +25,7 @@ const BarSeriesComponent = ({ data: localData, x: localX, y: localY, color, hide
|
|
|
24
25
|
}
|
|
25
26
|
registerSeries(chartStore, gradientId, [
|
|
26
27
|
{
|
|
28
|
+
id: gradientId,
|
|
27
29
|
label: label || "Bar Series",
|
|
28
30
|
color: color || "var(--primary)",
|
|
29
31
|
x: xAccessor,
|
|
@@ -86,7 +88,10 @@ const BarSeriesComponent = ({ data: localData, x: localX, y: localY, color, hide
|
|
|
86
88
|
: `Bar: ${JSON.stringify(d)}`, "aria-roledescription": "bar", className: `${styles.bar} chart-bar`, d: createRoundedTopBarPath(finalX, yVal, w, h, BAR_RADIUS), role: "graphics-symbol", style: {
|
|
87
89
|
fill: fillColor,
|
|
88
90
|
pointerEvents: "all",
|
|
89
|
-
}
|
|
91
|
+
}, [CHART_DATA_ATTRS.TYPE]: "bar",
|
|
92
|
+
[CHART_DATA_ATTRS.SERIES_ID]: gradientId,
|
|
93
|
+
[CHART_DATA_ATTRS.INDEX]: i,
|
|
94
|
+
[CHART_DATA_ATTRS.DRAGGABLE]: false }, i));
|
|
90
95
|
}) }));
|
|
91
96
|
};
|
|
92
97
|
export const BarSeries = React.memo(BarSeriesComponent);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
@layer doom.components {
|
|
2
|
+
.bar {
|
|
3
|
+
fill: var(--primary);
|
|
4
|
+
stroke: var(--card-border);
|
|
5
|
+
stroke-width: var(--surface-border-width);
|
|
6
|
+
stroke-linejoin: round;
|
|
7
|
+
transition: opacity 0.2s;
|
|
8
|
+
}
|
|
9
|
+
.bar:hover {
|
|
10
|
+
filter: brightness(1.1);
|
|
11
|
+
}
|
|
10
12
|
}
|
|
@@ -27,7 +27,14 @@ export function CursorLine() {
|
|
|
27
27
|
// Use primary target or first target in list
|
|
28
28
|
const target = (_b = (_a = hover === null || hover === void 0 ? void 0 : hover.targets) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
|
|
29
29
|
// Use pointer for fallback or if target is missing
|
|
30
|
-
|
|
30
|
+
let point = target ? target.coordinate : ((_c = hover === null || hover === void 0 ? void 0 : hover.pointer) !== null && _c !== void 0 ? _c : null);
|
|
31
|
+
// Normalize point to plot-relative coordinates consistently
|
|
32
|
+
if (target && point) {
|
|
33
|
+
point = {
|
|
34
|
+
x: point.x - dimensions.margin.left,
|
|
35
|
+
y: point.y - dimensions.margin.top,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
31
38
|
if (!point) {
|
|
32
39
|
return null;
|
|
33
40
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.cursorPoint {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
@layer doom.components {
|
|
2
|
+
.cursorLine {
|
|
3
|
+
stroke: var(--muted-foreground);
|
|
4
|
+
stroke-width: var(--surface-border-width);
|
|
5
|
+
stroke-dasharray: 4 4;
|
|
6
|
+
opacity: 1;
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
}
|
|
9
|
+
.cursorPoint {
|
|
10
|
+
fill: var(--primary);
|
|
11
|
+
stroke: var(--border-strong);
|
|
12
|
+
stroke-width: var(--surface-border-width);
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
}
|
|
14
15
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React, { useEffect, useId, useRef } from "react";
|
|
3
3
|
import { useChartContext } from "../../context.js";
|
|
4
|
+
import { CHART_DATA_ATTRS } from "../../engine/index.js";
|
|
4
5
|
import { registerSeries, unregisterSeries, } from "../../state/store/chart.store.js";
|
|
5
6
|
import { resolveAccessor } from "../../utils/accessors.js";
|
|
6
7
|
import { d3 } from "../../utils/d3.js";
|
|
@@ -30,6 +31,7 @@ const CustomSeriesComponent = (props) => {
|
|
|
30
31
|
hideCursor: true,
|
|
31
32
|
interactionMode: "x",
|
|
32
33
|
data,
|
|
34
|
+
id: seriesId,
|
|
33
35
|
},
|
|
34
36
|
]);
|
|
35
37
|
return () => {
|
|
@@ -74,6 +76,8 @@ const CustomSeriesComponent = (props) => {
|
|
|
74
76
|
},
|
|
75
77
|
config,
|
|
76
78
|
resolveInteraction,
|
|
79
|
+
seriesId,
|
|
80
|
+
chartDataAttrs: CHART_DATA_ATTRS,
|
|
77
81
|
});
|
|
78
82
|
}, [
|
|
79
83
|
render,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
@layer doom.components {
|
|
2
|
+
.customSeries {
|
|
3
|
+
/* Placeholder for custom series styles */
|
|
4
|
+
pointer-events: none; /* Usually custom render handles its own events */
|
|
5
|
+
}
|
|
4
6
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
.grid line
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
.grid path {
|
|
11
|
-
|
|
1
|
+
@layer doom.components {
|
|
2
|
+
.grid {
|
|
3
|
+
pointer-events: none;
|
|
4
|
+
}
|
|
5
|
+
.grid :global(.tick) line,
|
|
6
|
+
.grid line {
|
|
7
|
+
stroke: var(--muted);
|
|
8
|
+
stroke-opacity: 0.5;
|
|
9
|
+
}
|
|
10
|
+
.grid path {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
12
13
|
}
|
|
@@ -3,11 +3,11 @@ import React from "react";
|
|
|
3
3
|
* InteractionLayer
|
|
4
4
|
*
|
|
5
5
|
* The root-level driver that captures native DOM pointer events on the Chart Container
|
|
6
|
-
* and
|
|
6
|
+
* and forwards them to the Engine as InputSignals.
|
|
7
7
|
*
|
|
8
8
|
* Features:
|
|
9
|
-
* - RAF Throttling (60fps aligned)
|
|
10
|
-
* -
|
|
11
|
-
* - Keyboard Support
|
|
9
|
+
* - RAF Throttling (60fps aligned for moves)
|
|
10
|
+
* - Direct Engine integration (no EventContext)
|
|
11
|
+
* - Keyboard Support
|
|
12
12
|
*/
|
|
13
13
|
export declare const InteractionLayer: React.FC;
|