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.
Files changed (211) hide show
  1. package/dist/components/Accordion/Accordion.module.css +121 -124
  2. package/dist/components/ActionRow/ActionRow.module.css +25 -24
  3. package/dist/components/Alert/Alert.module.css +74 -76
  4. package/dist/components/Avatar/Avatar.module.css +66 -66
  5. package/dist/components/Badge/Badge.module.css +50 -48
  6. package/dist/components/Breadcrumbs/Breadcrumbs.module.css +32 -33
  7. package/dist/components/Button/Button.d.ts +2 -2
  8. package/dist/components/Button/Button.js +1 -1
  9. package/dist/components/Button/Button.module.css +150 -152
  10. package/dist/components/Card/Card.module.css +37 -39
  11. package/dist/components/Chart/Chart.module.css +213 -245
  12. package/dist/components/Chart/behaviors/DraggablePuck.d.ts +36 -0
  13. package/dist/components/Chart/behaviors/DraggablePuck.js +94 -0
  14. package/dist/components/Chart/behaviors/Markers.js +6 -4
  15. package/dist/components/Chart/behaviors/SelectionUpdate.js +2 -4
  16. package/dist/components/Chart/behaviors/index.d.ts +1 -1
  17. package/dist/components/Chart/behaviors/index.js +1 -1
  18. package/dist/components/Chart/engine/CoordinateSystem.d.ts +59 -0
  19. package/dist/components/Chart/engine/CoordinateSystem.js +126 -0
  20. package/dist/components/Chart/engine/Engine.d.ts +102 -0
  21. package/dist/components/Chart/engine/Engine.js +226 -0
  22. package/dist/components/Chart/engine/Scheduler.d.ts +59 -0
  23. package/dist/components/Chart/engine/Scheduler.js +139 -0
  24. package/dist/components/Chart/engine/SpatialMap.d.ts +114 -0
  25. package/dist/components/Chart/engine/SpatialMap.js +270 -0
  26. package/dist/components/Chart/engine/index.d.ts +13 -0
  27. package/dist/components/Chart/engine/index.js +9 -0
  28. package/dist/components/Chart/engine/types.d.ts +137 -0
  29. package/dist/components/Chart/engine/types.js +47 -0
  30. package/dist/components/Chart/hooks/useEngine.d.ts +43 -0
  31. package/dist/components/Chart/hooks/useEngine.js +128 -0
  32. package/dist/components/Chart/sensors/DataHoverSensor/DataHoverSensor.d.ts +17 -19
  33. package/dist/components/Chart/sensors/DataHoverSensor/DataHoverSensor.js +38 -51
  34. package/dist/components/Chart/sensors/DragSensor/DragSensor.d.ts +38 -0
  35. package/dist/components/Chart/sensors/DragSensor/DragSensor.js +105 -0
  36. package/dist/components/Chart/sensors/DragSensor/index.d.ts +2 -0
  37. package/dist/components/Chart/sensors/DragSensor/index.js +1 -0
  38. package/dist/components/Chart/sensors/{KeyboardSensor.d.ts → KeyboardSensor/KeyboardSensor.d.ts} +1 -1
  39. package/dist/components/Chart/sensors/KeyboardSensor/KeyboardSensor.js +86 -0
  40. package/dist/components/Chart/sensors/KeyboardSensor/index.d.ts +1 -0
  41. package/dist/components/Chart/sensors/KeyboardSensor/index.js +1 -0
  42. package/dist/components/Chart/sensors/{SelectionSensor.d.ts → SelectionSensor/SelectionSensor.d.ts} +2 -2
  43. package/dist/components/Chart/sensors/SelectionSensor/SelectionSensor.js +39 -0
  44. package/dist/components/Chart/sensors/SelectionSensor/index.d.ts +1 -0
  45. package/dist/components/Chart/sensors/SelectionSensor/index.js +1 -0
  46. package/dist/components/Chart/sensors/SensorManager/SensorManager.js +36 -41
  47. package/dist/components/Chart/sensors/index.d.ts +1 -0
  48. package/dist/components/Chart/sensors/index.js +3 -2
  49. package/dist/components/Chart/sensors/utils/search.d.ts +1 -1
  50. package/dist/components/Chart/sensors/utils/search.js +25 -4
  51. package/dist/components/Chart/state/store/chart.store.js +18 -0
  52. package/dist/components/Chart/state/store/slices/series.slice.d.ts +1 -0
  53. package/dist/components/Chart/state/store/slices/series.slice.js +3 -2
  54. package/dist/components/Chart/subcomponents/Axis/Axis.module.css +32 -33
  55. package/dist/components/Chart/subcomponents/BarSeries/BarSeries.js +6 -1
  56. package/dist/components/Chart/subcomponents/BarSeries/BarSeries.module.css +11 -9
  57. package/dist/components/Chart/subcomponents/Cursor/Cursor.js +8 -1
  58. package/dist/components/Chart/subcomponents/Cursor/Cursor.module.css +14 -13
  59. package/dist/components/Chart/subcomponents/CustomSeries/CustomSeries.js +4 -0
  60. package/dist/components/Chart/subcomponents/CustomSeries/CustomSeries.module.css +5 -3
  61. package/dist/components/Chart/subcomponents/Footer/Footer.module.css +5 -3
  62. package/dist/components/Chart/subcomponents/Grid/Grid.module.css +12 -11
  63. package/dist/components/Chart/subcomponents/Header/Header.module.css +8 -7
  64. package/dist/components/Chart/subcomponents/InteractionLayer/InteractionLayer.d.ts +4 -4
  65. package/dist/components/Chart/subcomponents/InteractionLayer/InteractionLayer.js +39 -76
  66. package/dist/components/Chart/subcomponents/Legend/Legend.module.css +30 -32
  67. package/dist/components/Chart/subcomponents/LineSeries/LineSeries.js +9 -3
  68. package/dist/components/Chart/subcomponents/LineSeries/LineSeries.module.css +21 -21
  69. package/dist/components/Chart/subcomponents/Root/Root.js +113 -7
  70. package/dist/components/Chart/subcomponents/Root/Root.module.css +70 -82
  71. package/dist/components/Chart/subcomponents/ScatterSeries/ScatterSeries.js +6 -1
  72. package/dist/components/Chart/subcomponents/ScatterSeries/ScatterSeries.module.css +7 -5
  73. package/dist/components/Chart/subcomponents/Series/Series.module.css +118 -128
  74. package/dist/components/Chart/subcomponents/SeriesPoint/SeriesPoint.module.css +10 -8
  75. package/dist/components/Chart/subcomponents/Tooltip/Tooltip.js +2 -3
  76. package/dist/components/Chart/subcomponents/Tooltip/Tooltip.module.css +52 -67
  77. package/dist/components/Chart/types/context.d.ts +9 -0
  78. package/dist/components/Chart/types/events.d.ts +5 -7
  79. package/dist/components/Chart/types/interaction.d.ts +24 -2
  80. package/dist/components/Chart/types/interaction.js +1 -0
  81. package/dist/components/Checkbox/Checkbox.module.css +57 -59
  82. package/dist/components/Chip/Chip.module.css +105 -115
  83. package/dist/components/Combobox/Combobox.d.ts +2 -1
  84. package/dist/components/Combobox/Combobox.js +2 -2
  85. package/dist/components/Combobox/Combobox.module.css +233 -210
  86. package/dist/components/CopyButton/CopyButton.module.css +84 -90
  87. package/dist/components/Drawer/Drawer.module.css +126 -145
  88. package/dist/components/Dropdown/Dropdown.d.ts +3 -1
  89. package/dist/components/Dropdown/Dropdown.js +3 -3
  90. package/dist/components/Dropdown/Dropdown.module.css +52 -32
  91. package/dist/components/FileUpload/FileUpload.js +24 -0
  92. package/dist/components/FileUpload/FileUpload.module.css +295 -313
  93. package/dist/components/Form/Form.module.css +35 -39
  94. package/dist/components/Image/Image.module.css +53 -54
  95. package/dist/components/Input/Input.d.ts +4 -2
  96. package/dist/components/Input/Input.js +2 -2
  97. package/dist/components/Input/Input.module.css +135 -119
  98. package/dist/components/Label/Label.module.css +17 -15
  99. package/dist/components/Layout/Layout.module.css +95 -111
  100. package/dist/components/Link/Link.module.css +67 -65
  101. package/dist/components/Modal/Modal.module.css +112 -132
  102. package/dist/components/Page/Page.module.css +21 -21
  103. package/dist/components/Pagination/Pagination.module.css +56 -56
  104. package/dist/components/Popover/Popover.module.css +17 -16
  105. package/dist/components/ProgressBar/ProgressBar.module.css +36 -37
  106. package/dist/components/RadioGroup/RadioGroup.module.css +74 -77
  107. package/dist/components/Select/Select.d.ts +2 -1
  108. package/dist/components/Select/Select.js +2 -2
  109. package/dist/components/Select/Select.module.css +133 -98
  110. package/dist/components/Sheet/Sheet.module.css +134 -154
  111. package/dist/components/Sidebar/Sidebar.module.css +72 -74
  112. package/dist/components/Sidebar/subcomponents/Footer/Footer.module.css +7 -5
  113. package/dist/components/Sidebar/subcomponents/Group/Group.module.css +80 -85
  114. package/dist/components/Sidebar/subcomponents/Header/Header.module.css +12 -10
  115. package/dist/components/Sidebar/subcomponents/Item/Item.module.css +54 -55
  116. package/dist/components/Sidebar/subcomponents/MobileOverlay/MobileOverlay.module.css +38 -38
  117. package/dist/components/Sidebar/subcomponents/MobileTrigger/MobileTrigger.module.css +5 -3
  118. package/dist/components/Sidebar/subcomponents/Nav/Nav.module.css +13 -11
  119. package/dist/components/Sidebar/subcomponents/Rail/Rail.module.css +62 -63
  120. package/dist/components/Sidebar/subcomponents/Section/Section.module.css +86 -91
  121. package/dist/components/Skeleton/Skeleton.module.css +28 -26
  122. package/dist/components/Slat/Slat.module.css +93 -94
  123. package/dist/components/Slider/Slider.module.css +116 -121
  124. package/dist/components/Spinner/Spinner.module.css +28 -27
  125. package/dist/components/SplitButton/SplitButton.d.ts +3 -1
  126. package/dist/components/SplitButton/SplitButton.js +2 -2
  127. package/dist/components/SplitButton/SplitButton.module.css +104 -87
  128. package/dist/components/Switch/Switch.module.css +64 -63
  129. package/dist/components/Table/FilterBuilder/FilterBuilder.module.css +36 -36
  130. package/dist/components/Table/FilterBuilder/FilterConditionRow.js +1 -1
  131. package/dist/components/Table/FilterBuilder/FilterConditionRow.module.css +21 -22
  132. package/dist/components/Table/FilterBuilder/FilterGroup.js +4 -4
  133. package/dist/components/Table/FilterBuilder/FilterGroup.module.css +355 -389
  134. package/dist/components/Table/FilterBuilder/FilterSheet.module.css +68 -71
  135. package/dist/components/Table/Table.d.ts +4 -2
  136. package/dist/components/Table/Table.js +50 -13
  137. package/dist/components/Table/Table.module.css +210 -188
  138. package/dist/components/Table/TableHeaderFilter.js +1 -1
  139. package/dist/components/Table/TableHeaderFilter.module.css +51 -57
  140. package/dist/components/Tabs/Tabs.module.css +79 -80
  141. package/dist/components/Text/Text.module.css +108 -131
  142. package/dist/components/Textarea/Textarea.d.ts +3 -1
  143. package/dist/components/Textarea/Textarea.js +2 -2
  144. package/dist/components/Textarea/Textarea.module.css +114 -94
  145. package/dist/components/Toast/Toast.module.css +82 -82
  146. package/dist/components/Tooltip/Tooltip.module.css +17 -16
  147. package/dist/styles/globals.css +1677 -1691
  148. package/dist/styles/palettes.d.ts +0 -5
  149. package/dist/styles/palettes.js +0 -8
  150. package/dist/styles/themes/definitions.d.ts +0 -8
  151. package/dist/styles/themes/definitions.js +117 -5
  152. package/dist/styles/types.d.ts +2 -0
  153. package/dist/styles/types.js +1 -0
  154. package/dist/tsconfig.build.tsbuildinfo +1 -1
  155. package/package.json +4 -4
  156. package/.agent/skills/doom/a2ui/a2ui-examples.md +0 -289
  157. package/.agent/skills/doom/a2ui/a2ui-principles.md +0 -49
  158. package/.agent/skills/doom/a2ui/a2ui-protocol.md +0 -191
  159. package/.agent/skills/doom/components/a2ui.md +0 -46
  160. package/.agent/skills/doom/components/accordion.md +0 -44
  161. package/.agent/skills/doom/components/actionrow.md +0 -33
  162. package/.agent/skills/doom/components/alert.md +0 -35
  163. package/.agent/skills/doom/components/avatar.md +0 -36
  164. package/.agent/skills/doom/components/badge.md +0 -29
  165. package/.agent/skills/doom/components/breadcrumbs.md +0 -33
  166. package/.agent/skills/doom/components/button.md +0 -43
  167. package/.agent/skills/doom/components/card.md +0 -41
  168. package/.agent/skills/doom/components/chart.md +0 -106
  169. package/.agent/skills/doom/components/checkbox.md +0 -38
  170. package/.agent/skills/doom/components/chip.md +0 -35
  171. package/.agent/skills/doom/components/combobox.md +0 -50
  172. package/.agent/skills/doom/components/copybutton.md +0 -41
  173. package/.agent/skills/doom/components/drawer.md +0 -69
  174. package/.agent/skills/doom/components/dropdown.md +0 -33
  175. package/.agent/skills/doom/components/fileupload.md +0 -49
  176. package/.agent/skills/doom/components/form.md +0 -55
  177. package/.agent/skills/doom/components/icon.md +0 -47
  178. package/.agent/skills/doom/components/image.md +0 -48
  179. package/.agent/skills/doom/components/input.md +0 -54
  180. package/.agent/skills/doom/components/label.md +0 -32
  181. package/.agent/skills/doom/components/layout.md +0 -92
  182. package/.agent/skills/doom/components/link.md +0 -39
  183. package/.agent/skills/doom/components/modal.md +0 -71
  184. package/.agent/skills/doom/components/page.md +0 -41
  185. package/.agent/skills/doom/components/pagination.md +0 -32
  186. package/.agent/skills/doom/components/popover.md +0 -45
  187. package/.agent/skills/doom/components/progressbar.md +0 -37
  188. package/.agent/skills/doom/components/radiogroup.md +0 -45
  189. package/.agent/skills/doom/components/select.md +0 -43
  190. package/.agent/skills/doom/components/sheet.md +0 -71
  191. package/.agent/skills/doom/components/sidebar.md +0 -92
  192. package/.agent/skills/doom/components/skeleton.md +0 -35
  193. package/.agent/skills/doom/components/slat.md +0 -46
  194. package/.agent/skills/doom/components/slider.md +0 -51
  195. package/.agent/skills/doom/components/spinner.md +0 -34
  196. package/.agent/skills/doom/components/splitbutton.md +0 -35
  197. package/.agent/skills/doom/components/switch.md +0 -40
  198. package/.agent/skills/doom/components/table.md +0 -82
  199. package/.agent/skills/doom/components/tabs.md +0 -65
  200. package/.agent/skills/doom/components/text.md +0 -42
  201. package/.agent/skills/doom/components/textarea.md +0 -46
  202. package/.agent/skills/doom/components/toast.md +0 -59
  203. package/.agent/skills/doom/components/tooltip.md +0 -35
  204. package/.agent/skills/doom/index.md +0 -167
  205. package/.agent/skills/doom/styles/aesthetic.md +0 -151
  206. package/.agent/skills/doom/styles/css-variables.md +0 -80
  207. package/.agent/skills/doom/styles/mixins.md +0 -97
  208. package/.agent/skills/doom/styles/tokens.md +0 -129
  209. package/.agent/skills/doom/styles/utilities.md +0 -84
  210. package/dist/components/Chart/sensors/KeyboardSensor.js +0 -82
  211. package/dist/components/Chart/sensors/SelectionSensor.js +0 -41
@@ -1,33 +1,29 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useRef } from "react";
3
3
  import { useChartContext } from "../../context.js";
4
- import { useEventContext } from "../../state/EventContext.js";
5
- import { normalizeCoordinates } from "../../utils/coordinates.js";
4
+ import { InputAction } from "../../engine/index.js";
6
5
  /**
7
6
  * InteractionLayer
8
7
  *
9
8
  * The root-level driver that captures native DOM pointer events on the Chart Container
10
- * and broadcasts normalized chart events to the EventContext.
9
+ * and forwards them to the Engine as InputSignals.
11
10
  *
12
11
  * Features:
13
- * - RAF Throttling (60fps aligned)
14
- * - Coordinate Normalization (fixes margins, borders, padding)
15
- * - Keyboard Support (basic)
12
+ * - RAF Throttling (60fps aligned for moves)
13
+ * - Direct Engine integration (no EventContext)
14
+ * - Keyboard Support
16
15
  */
17
16
  export const InteractionLayer = () => {
18
- const { emit } = useEventContext();
19
- const { chartStore } = useChartContext();
17
+ const { chartStore, engine } = useChartContext();
20
18
  const observerRef = useRef(null);
21
19
  // RAF State
22
20
  const frameRef = useRef(null);
23
21
  const lastEventRef = useRef(null);
24
- // Cache
25
- const plotRef = useRef(null);
26
22
  useEffect(() => {
27
23
  var _a;
28
24
  // 1. Locate the container (parent of this invisible element)
29
25
  const container = (_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.closest("[data-chart-container]");
30
- if (!container) {
26
+ if (!container || !engine) {
31
27
  return;
32
28
  }
33
29
  // 2. Define the throttled processor
@@ -36,52 +32,12 @@ export const InteractionLayer = () => {
36
32
  if (!event) {
37
33
  return;
38
34
  }
39
- // Lazy-find the plot SVG to avoid querySelector thrashing
40
- let svg = plotRef.current;
41
- if (!svg || !svg.isConnected) {
42
- svg = container.querySelector("[data-chart-plot]");
43
- plotRef.current = svg;
44
- }
45
- if (!svg) {
46
- return;
47
- } // Not ready yet
48
- // Map native event to ChartEventType
49
- const type = getChartEventType(event.type);
50
- // --- CRITICAL COORDINATE CALCULATION ---
51
- // We rely on the Store for margins, NOT the inner plot group BBox.
52
- // This ensures x=0 is always the true axis line, even if data doesn't touch it.
53
- const state = chartStore.getState();
54
- const { margin, innerWidth, innerHeight } = state.dimensions;
55
- const svgRect = svg.getBoundingClientRect();
56
- const containerRect = container.getBoundingClientRect();
57
- const containerStyle = window.getComputedStyle(container);
58
- // Account for container borders
59
- const borderLeft = parseFloat(containerStyle.borderLeftWidth) || 0;
60
- const borderTop = parseFloat(containerStyle.borderTopWidth) || 0;
61
- // Construct the Virtual Plot Rect (where the plot *logically* exists)
62
- const plotLeft = svgRect.left + margin.left;
63
- const plotTop = svgRect.top + margin.top;
64
- const virtualPlotRect = {
65
- left: plotLeft,
66
- top: plotTop,
67
- width: innerWidth,
68
- height: innerHeight,
69
- right: plotLeft + innerWidth,
70
- bottom: plotTop + innerHeight,
71
- x: plotLeft,
72
- y: plotTop,
73
- toJSON: () => { },
74
- };
75
- const coords = normalizeCoordinates(event, containerRect, virtualPlotRect, {
76
- left: borderLeft,
77
- top: borderTop,
78
- });
79
- if (coords) {
80
- emit({
81
- type,
82
- coordinates: coords,
83
- nativeEvent: event,
84
- });
35
+ // Map native event to InputAction
36
+ const action = getInputAction(event.type);
37
+ // Create signal and send to engine
38
+ const signal = engine.createSignal(event, action);
39
+ if (signal) {
40
+ engine.input(signal);
85
41
  }
86
42
  // Reset
87
43
  lastEventRef.current = null;
@@ -89,6 +45,22 @@ export const InteractionLayer = () => {
89
45
  };
90
46
  // 3. Define the listener (Throttler)
91
47
  const onPointerEvent = (e) => {
48
+ // CRITICAL: Do NOT throttle state-change events (down, up, leave).
49
+ // These need immediate processing for proper drag/click handling.
50
+ if (e.type === "pointerdown" ||
51
+ e.type === "pointerup" ||
52
+ e.type === "pointerleave") {
53
+ // Cancel any pending frame to avoid processing stale events
54
+ if (frameRef.current) {
55
+ cancelAnimationFrame(frameRef.current);
56
+ frameRef.current = null;
57
+ }
58
+ // Force synchronous processing
59
+ lastEventRef.current = e;
60
+ processEvent();
61
+ return;
62
+ }
63
+ // Throttle moves to RAF
92
64
  lastEventRef.current = e;
93
65
  if (!frameRef.current) {
94
66
  frameRef.current = requestAnimationFrame(processEvent);
@@ -103,18 +75,9 @@ export const InteractionLayer = () => {
103
75
  "Enter",
104
76
  " ",
105
77
  ].includes(e.key)) {
106
- // Keyboard events are not throttled for responsiveness
107
- emit({
108
- type: "CHART_KEY_DOWN",
109
- coordinates: {
110
- containerX: 0,
111
- containerY: 0,
112
- chartX: 0,
113
- chartY: 0,
114
- isWithinPlot: true,
115
- },
116
- nativeEvent: e,
117
- });
78
+ // Create and send keyboard signal
79
+ const signal = engine.createKeySignal(e);
80
+ engine.input(signal);
118
81
  }
119
82
  };
120
83
  // 4. Attach Listeners
@@ -133,7 +96,7 @@ export const InteractionLayer = () => {
133
96
  cancelAnimationFrame(frameRef.current);
134
97
  }
135
98
  };
136
- }, [emit, chartStore]);
99
+ }, [engine, chartStore]);
137
100
  return (_jsx("div", { ref: observerRef, "data-testid": "interaction-layer", style: {
138
101
  position: "absolute",
139
102
  width: 0,
@@ -142,16 +105,16 @@ export const InteractionLayer = () => {
142
105
  visibility: "hidden",
143
106
  } }));
144
107
  };
145
- // Helper
146
- function getChartEventType(nativeType) {
108
+ // Helper: Map pointer event type to InputAction
109
+ function getInputAction(nativeType) {
147
110
  switch (nativeType) {
148
111
  case "pointerdown":
149
- return "CHART_POINTER_DOWN";
112
+ return InputAction.START;
150
113
  case "pointerup":
151
- return "CHART_POINTER_UP";
114
+ return InputAction.END;
152
115
  case "pointerleave":
153
- return "CHART_POINTER_LEAVE";
116
+ return InputAction.CANCEL;
154
117
  default:
155
- return "CHART_POINTER_MOVE";
118
+ return InputAction.MOVE;
156
119
  }
157
120
  }
@@ -1,33 +1,31 @@
1
- .legend {
2
- align-items: center;
3
- justify-content: flex-start;
4
- }
5
- .legend.legendBottom {
6
- justify-content: center;
7
- }
8
-
9
- .legendItem {
10
- align-items: center;
11
- }
12
-
13
- .legendDot {
14
- width: var(--spacing-4);
15
- height: var(--spacing-2);
16
- border-radius: var(--radius);
17
- flex-shrink: 0;
18
- border: var(--border-width) solid var(--border-strong);
19
- }
20
-
21
- .legendLabel {
22
- color: var(--foreground);
23
- margin: 0;
24
- white-space: nowrap;
25
- }
26
-
27
- .legendVertical {
28
- display: flex;
29
- flex-direction: column;
30
- align-self: center;
31
- gap: var(--spacing-2);
32
- padding: 0 var(--spacing-2);
1
+ @layer doom.components {
2
+ .legend {
3
+ align-items: center;
4
+ justify-content: flex-start;
5
+ }
6
+ .legend.legendBottom {
7
+ justify-content: center;
8
+ }
9
+ .legendItem {
10
+ align-items: center;
11
+ }
12
+ .legendDot {
13
+ width: var(--space-4);
14
+ height: var(--space-2);
15
+ border-radius: var(--radius-md);
16
+ flex-shrink: 0;
17
+ border: var(--surface-border-width) solid var(--border-strong);
18
+ }
19
+ .legendLabel {
20
+ color: var(--foreground);
21
+ margin: 0;
22
+ white-space: nowrap;
23
+ }
24
+ .legendVertical {
25
+ display: flex;
26
+ flex-direction: column;
27
+ align-self: center;
28
+ gap: var(--space-2);
29
+ padding: 0 var(--space-2);
30
+ }
33
31
  }
@@ -13,6 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import React, { useEffect, useId, useMemo } from "react";
15
15
  import { useChartContext } from "../../context.js";
16
+ import { CHART_DATA_ATTRS } from "../../engine/index.js";
16
17
  import { registerSeries, unregisterSeries, } from "../../state/store/chart.store.js";
17
18
  import { resolveAccessor } from "../../utils/accessors.js";
18
19
  import { d3 } from "../../utils/d3.js";
@@ -39,6 +40,7 @@ const LineSeriesComponent = ({ data: localData, x: localX, y: localY, color, cur
39
40
  }
40
41
  registerSeries(chartStore, gradientId, [
41
42
  {
43
+ id: gradientId,
42
44
  label: label || ((_a = config.yAxisLabel) !== null && _a !== void 0 ? _a : "Series"),
43
45
  color: strokeColor,
44
46
  x: xAccessor,
@@ -115,9 +117,11 @@ const LineSeriesComponent = ({ data: localData, x: localX, y: localY, color, cur
115
117
  config,
116
118
  colors: [color || "var(--primary)"],
117
119
  styles: {},
118
- gradientId: "",
120
+ gradientId,
119
121
  isMobile,
120
122
  chartStore,
123
+ seriesId: gradientId,
124
+ chartDataAttrs: CHART_DATA_ATTRS,
121
125
  });
122
126
  }
123
127
  } }));
@@ -129,7 +133,9 @@ const LineSeriesComponent = ({ data: localData, x: localX, y: localY, color, cur
129
133
  const showGradient = isArea && config.withGradient !== false;
130
134
  return (_jsxs("g", { className: "chart-line-series", children: [showGradient && (_jsx("defs", { children: _jsxs("linearGradient", { id: gradientId, x1: "0", x2: "0", y1: "0", y2: "1", children: [_jsx("stop", { offset: "5%", stopColor: strokeColor, stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: strokeColor, stopOpacity: 0 })] }) })), showGradient && (_jsx("path", { className: styles.area, d: paths.area || "", style: {
131
135
  fill: `url(#${gradientId})`,
132
- } })), _jsx("path", { "aria-label": label || "Line Series", "aria-roledescription": "line", className: styles.path, d: paths.line || "", role: "graphics-object", style: { stroke: strokeColor } }), (showDots || config.showDots) &&
136
+ } })), _jsx("path", { "aria-label": label || "Line Series", "aria-roledescription": "line", className: styles.path, d: paths.line || "", role: "graphics-object", style: { stroke: strokeColor }, [CHART_DATA_ATTRS.TYPE]: "line",
137
+ [CHART_DATA_ATTRS.SERIES_ID]: gradientId,
138
+ [CHART_DATA_ATTRS.DRAGGABLE]: false }), (showDots || config.showDots) &&
133
139
  xScale &&
134
140
  yScale &&
135
141
  yAccessor &&
@@ -137,7 +143,7 @@ const LineSeriesComponent = ({ data: localData, x: localX, y: localY, color, cur
137
143
  data.map((d, i) => {
138
144
  const cx = xScale(xAccessor(d));
139
145
  const cy = yScale(yAccessor(d));
140
- return _jsx(SeriesPoint, { color: strokeColor, x: cx, y: cy }, i);
146
+ return (_jsx(SeriesPoint, { color: strokeColor, datum: d, x: cx, y: cy }, i));
141
147
  })] }));
142
148
  };
143
149
  export const LineSeries = React.memo(LineSeriesComponent);
@@ -1,22 +1,22 @@
1
- .path {
2
- fill: none;
3
- stroke: var(--primary);
4
- stroke-width: calc(var(--border-width) * 1.5);
5
- stroke-linecap: round;
6
- stroke-linejoin: round;
7
- transition: stroke-dasharray 0.3s ease;
8
- }
9
-
10
- .area {
11
- fill: var(--primary);
12
- stroke: none;
13
- /* opacity: 0.1; */
14
- }
15
-
16
- .dot {
17
- fill: var(--primary);
18
- stroke: var(--border-strong);
19
- stroke-width: var(--border-width);
20
- transition: r 0.2s;
21
- z-index: var(--z-overlay);
1
+ @layer doom.components {
2
+ .path {
3
+ fill: none;
4
+ stroke: var(--primary);
5
+ stroke-width: calc(var(--surface-border-width) * 1.5);
6
+ stroke-linecap: round;
7
+ stroke-linejoin: round;
8
+ transition: stroke-dasharray 0.3s ease;
9
+ }
10
+ .area {
11
+ fill: var(--primary);
12
+ stroke: none;
13
+ /* opacity: 0.1; */
14
+ }
15
+ .dot {
16
+ fill: var(--primary);
17
+ stroke: var(--border-strong);
18
+ stroke-width: var(--surface-border-width);
19
+ transition: r 0.2s;
20
+ z-index: var(--z-overlay);
21
+ }
22
22
  }
@@ -1,13 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
- import React, { useCallback, useEffect, useMemo, useRef, useState, } from "react";
4
+ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
5
5
  import { ChartContext } from "../../context.js";
6
6
  import { useChartBehaviors } from "../../hooks/useChartBehaviors.js";
7
+ import { useEngine } from "../../hooks/useEngine.js";
7
8
  import { SensorManager } from "../../sensors/SensorManager/SensorManager.js";
8
9
  import { EventsProvider } from "../../state/EventContext.js";
9
10
  import { createChartStore, updateChartDimensions, updateChartState, } from "../../state/store/chart.store.js";
10
- import { InteractionChannel, } from "../../types/index.js";
11
+ import { InteractionChannel, resolveAccessor, } from "../../types/index.js";
11
12
  import { hasChildOfTypeDeep } from "../../utils/componentDetection.js";
12
13
  import { Axis } from "../Axis/Axis.js";
13
14
  import { CursorWrapper } from "../Cursor/Cursor.js";
@@ -59,9 +60,115 @@ function RootPlot({ children, chartStore, }) {
59
60
  export function Root({ data, d3Config, className, style, onValueChange, variant = "default", flat = false, withFrame = true, title, subtitle, withLegend = false, children, type, render, x, y, behaviors, sensors, }) {
60
61
  const [chartStore] = useState(() => createChartStore(Object.assign(Object.assign({}, d3Config), { type }), x, y));
61
62
  const [isMobile, setIsMobile] = useState(false);
63
+ const containerRef = useRef(null);
62
64
  const wrapperRef = useRef(null);
63
65
  const lastValueRef = useRef(null);
64
- // Sync data to store
66
+ const { engine } = useEngine();
67
+ useLayoutEffect(() => {
68
+ var _a, _b, _c;
69
+ if (!containerRef.current) {
70
+ return;
71
+ }
72
+ const state = chartStore.getState();
73
+ const { dimensions } = state;
74
+ // In composition mode wrapperRef is never mounted; fall back to the SVG
75
+ // element that Plot.tsx registers via chartStore.elements.svg.
76
+ const plotEl = (_c = (_a = wrapperRef.current) !== null && _a !== void 0 ? _a : (_b = chartStore.getState().elements) === null || _b === void 0 ? void 0 : _b.svg) !== null && _c !== void 0 ? _c : null;
77
+ engine.setContainer(containerRef.current, plotEl, {
78
+ x: dimensions.margin.left,
79
+ y: dimensions.margin.top,
80
+ width: dimensions.innerWidth,
81
+ height: dimensions.innerHeight,
82
+ });
83
+ }, [
84
+ engine,
85
+ chartStore,
86
+ title,
87
+ subtitle,
88
+ withLegend,
89
+ withFrame,
90
+ flat,
91
+ variant,
92
+ isMobile,
93
+ ]);
94
+ useEffect(() => {
95
+ return chartStore.subscribe(() => {
96
+ var _a, _b, _c;
97
+ const state = chartStore.getState();
98
+ if (!state) {
99
+ return;
100
+ }
101
+ const { data, scales, dimensions, processedSeries } = state;
102
+ const { x: xScale, y: yScale } = scales;
103
+ if (containerRef.current) {
104
+ // In composition mode wrapperRef is null; use the SVG registered by Plot.tsx.
105
+ const plotEl = (_c = (_a = wrapperRef.current) !== null && _a !== void 0 ? _a : (_b = state.elements) === null || _b === void 0 ? void 0 : _b.svg) !== null && _c !== void 0 ? _c : null;
106
+ engine.setContainer(containerRef.current, plotEl, {
107
+ x: dimensions.margin.left,
108
+ y: dimensions.margin.top,
109
+ width: dimensions.innerWidth,
110
+ height: dimensions.innerHeight,
111
+ });
112
+ }
113
+ if (xScale && yScale) {
114
+ const allPoints = [];
115
+ const hasSeries = processedSeries && processedSeries.length > 0;
116
+ if (hasSeries) {
117
+ processedSeries.forEach((series) => {
118
+ const seriesData = series.data || data;
119
+ if (!seriesData) {
120
+ return;
121
+ }
122
+ const getX = series.xAccessor
123
+ ? resolveAccessor(series.xAccessor)
124
+ : x
125
+ ? resolveAccessor(x)
126
+ : null;
127
+ const getY = series.yAccessor
128
+ ? resolveAccessor(series.yAccessor)
129
+ : y
130
+ ? resolveAccessor(y)
131
+ : null;
132
+ const points = seriesData.map((d, i) => {
133
+ var _a, _b;
134
+ return ({
135
+ x: ((_a = xScale((getX ? getX(d) : i))) !== null && _a !== void 0 ? _a : 0) +
136
+ dimensions.margin.left,
137
+ y: ((_b = yScale((getY ? getY(d) : d))) !== null && _b !== void 0 ? _b : 0) +
138
+ dimensions.margin.top,
139
+ data: d,
140
+ seriesId: series.id,
141
+ seriesColor: series.color,
142
+ dataIndex: i,
143
+ });
144
+ });
145
+ allPoints.push(...points);
146
+ });
147
+ }
148
+ else if (data.length > 0) {
149
+ const getX = x ? resolveAccessor(x) : null;
150
+ const getY = y ? resolveAccessor(y) : null;
151
+ const points = data.map((d, i) => {
152
+ var _a, _b;
153
+ return ({
154
+ x: ((_a = xScale((getX ? getX(d) : i))) !== null && _a !== void 0 ? _a : 0) +
155
+ dimensions.margin.left,
156
+ y: ((_b = yScale((getY ? getY(d) : d))) !== null && _b !== void 0 ? _b : 0) +
157
+ dimensions.margin.top,
158
+ data: d,
159
+ seriesId: "default",
160
+ seriesColor: null,
161
+ dataIndex: i,
162
+ });
163
+ });
164
+ allPoints.push(...points);
165
+ }
166
+ if (allPoints.length > 0) {
167
+ engine.updateData(allPoints);
168
+ }
169
+ }
170
+ });
171
+ }, [chartStore, engine, x, y]);
65
172
  useEffect(() => {
66
173
  updateChartState(chartStore, {
67
174
  data,
@@ -69,7 +176,6 @@ export function Root({ data, d3Config, className, style, onValueChange, variant
69
176
  dimensions: chartStore.getState().dimensions,
70
177
  });
71
178
  }, [chartStore, data, type]);
72
- // Handle onValueChange proxy from Interaction Store
73
179
  useEffect(() => {
74
180
  return chartStore.subscribe(() => {
75
181
  var _a, _b;
@@ -116,7 +222,6 @@ export function Root({ data, d3Config, className, style, onValueChange, variant
116
222
  chartStore.setState((prev) => ({
117
223
  dimensions: Object.assign(Object.assign({}, prev.dimensions), { margin: next }),
118
224
  }));
119
- // Trigger re-calculation
120
225
  updateChartDimensions(chartStore, state.dimensions.width, state.dimensions.height);
121
226
  }
122
227
  }, [chartStore]);
@@ -178,6 +283,7 @@ export function Root({ data, d3Config, className, style, onValueChange, variant
178
283
  }, []);
179
284
  const value = useMemo(() => ({
180
285
  chartStore,
286
+ engine,
181
287
  data,
182
288
  config: config,
183
289
  width: chartStore.getState().dimensions.width,
@@ -187,7 +293,6 @@ export function Root({ data, d3Config, className, style, onValueChange, variant
187
293
  isMobile,
188
294
  requestLayoutAdjustment,
189
295
  colorPalette: LEGEND_PALETTE,
190
- // Internal bridges - maintained for system stability during architectural shift
191
296
  seriesStore: chartStore,
192
297
  interactionStore: chartStore,
193
298
  x: x ? x : undefined,
@@ -203,6 +308,7 @@ export function Root({ data, d3Config, className, style, onValueChange, variant
203
308
  x,
204
309
  y,
205
310
  variant,
311
+ engine,
206
312
  ]);
207
313
  const hasContent = React.Children.count(children) > 0;
208
314
  const showShorthand = !hasContent && (type || render || x || y);
@@ -211,5 +317,5 @@ export function Root({ data, d3Config, className, style, onValueChange, variant
211
317
  const hasGrid = hasContent && hasChildOfTypeDeep(children, Grid);
212
318
  const hasAxis = hasContent && hasChildOfTypeDeep(children, Axis);
213
319
  const hasCursor = hasContent && hasChildOfTypeDeep(children, CursorWrapper);
214
- return (_jsx(ChartContext.Provider, { value: value, children: _jsxs(EventsProvider, { children: [_jsx(BehaviorManager, { behaviors: behaviors, value: value }), _jsxs("div", { "data-chart-container": true, "aria-describedby": subtitle ? "chart-subtitle" : undefined, "aria-label": title ? `Chart: ${title}` : "Interactive Chart", className: clsx(styles.chartContainer, variant === "solid" && styles.solid, flat && styles.flat, isMobile && styles.mobile, !withFrame && styles.frameless, className), role: "region", style: style, tabIndex: 0, children: [_jsx(InteractionLayer, {}), _jsx(SensorManager, { sensors: sensors }), isAutoLayout && (title || subtitle) && (_jsx(Header, { subtitle: subtitle, title: title })), isAutoLayout ? (_jsx("div", { ref: wrapperRef, className: styles.responsiveWrapper, style: { flex: 1, position: "relative" }, children: _jsxs(RootPlot, { chartStore: chartStore, children: [!hasGrid && config.grid !== false && _jsx(Grid, {}), !hasCursor && !render && _jsx(CursorWrapper, { mode: "line" }), children, !hasAxis && config.showAxes !== false && _jsx(Axis, {}), showShorthand && (_jsx(Series, { render: render, type: type, x: x, y: y }))] }) })) : (children), withLegend && _jsx(Legend, {}), _jsx(Tooltip, { containerRef: wrapperRef })] })] }) }));
320
+ return (_jsx(ChartContext.Provider, { value: value, children: _jsxs(EventsProvider, { children: [_jsx(BehaviorManager, { behaviors: behaviors, value: value }), _jsxs("div", { ref: containerRef, "data-chart-container": true, "aria-describedby": subtitle ? "chart-subtitle" : undefined, "aria-label": title ? `Chart: ${title}` : "Interactive Chart", className: clsx(styles.chartContainer, variant === "solid" && styles.solid, flat && styles.flat, isMobile && styles.mobile, !withFrame && styles.frameless, className), role: "region", style: style, tabIndex: 0, children: [_jsx(InteractionLayer, {}), _jsx(SensorManager, { sensors: sensors }), isAutoLayout && (title || subtitle) && (_jsx(Header, { subtitle: subtitle, title: title })), isAutoLayout ? (_jsx("div", { ref: wrapperRef, className: styles.responsiveWrapper, style: { flex: 1, position: "relative" }, children: _jsxs(RootPlot, { chartStore: chartStore, children: [!hasGrid && config.grid !== false && _jsx(Grid, {}), !hasCursor && !render && _jsx(CursorWrapper, { mode: "line" }), children, !hasAxis && config.showAxes !== false && _jsx(Axis, {}), showShorthand && (_jsx(Series, { render: render, type: type, x: x, y: y }))] }) })) : (children), withLegend && _jsx(Legend, {}), _jsx(Tooltip, { containerRef: wrapperRef })] })] }) }));
215
321
  }