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,129 +0,0 @@
1
- # Design Tokens
2
-
3
- Tokens are defined in `styles/tokens.ts`.
4
-
5
- ## Palette
6
-
7
- Colors available in `palette` object. Shades follow Tailwind-style naming: `50`, `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, `900`, `950`.
8
-
9
- Access via `palette.{color}[{shade}]` (e.g., `palette.purple[500]`, `palette.slate[800]`).
10
-
11
- | Color | Shades Available | Notes |
12
- | ------ | ---------------- | ------------------------- |
13
- | black | 50-950 | Opacity scales (rgba) |
14
- | white | 50-950 | Opacity scales (rgba) |
15
- | slate | 50-950 | Full range |
16
- | purple | 50-900 | Primary for default theme |
17
- | navy | 50-900 | — |
18
- | blue | 50-900 | Primary for captain theme |
19
- | indigo | 50-900 | — |
20
- | yellow | 50-900 | Primary for vigilante |
21
- | green | 50-900 | Primary for doom theme |
22
- | red | 50-900 | Error states |
23
- | gray | 50-990 | Extended range |
24
-
25
- ## Base Variables
26
-
27
- ### Typography
28
-
29
- ```
30
- --text-xs: 0.75rem
31
- --text-sm: 0.875rem
32
- --text-base: 1rem
33
- --text-lg: 1.125rem
34
- --text-xl: 1.25rem
35
- --text-2xl: 1.5rem
36
- --text-3xl: 1.875rem
37
- --text-4xl: 2.25rem
38
- --text-5xl: 3rem
39
- --text-6xl: 3.75rem
40
- ```
41
-
42
- ### Font Weights
43
-
44
- ```
45
- --font-thin: 100
46
- --font-extralight: 200
47
- --font-light: 300
48
- --font-regular: 400
49
- --font-medium: 500
50
- --font-semibold: 600
51
- --font-bold: 700
52
- --font-extrabold: 800
53
- --font-black: 900
54
- ```
55
-
56
- ### Spacing
57
-
58
- ```
59
- --spacing-xs: 0.25rem
60
- --spacing-sm: 0.5rem
61
- --spacing-md: 1rem
62
- --spacing-lg: 1.5rem
63
- --spacing-xl: 2rem
64
- --spacing-2xl: 3rem
65
- ```
66
-
67
- ### Z-Index
68
-
69
- ```
70
- --z-base: 0
71
- --z-elevated: 10
72
- --z-header: 40
73
- --z-dropdown: 50
74
- --z-modal: 100
75
- --z-overlay: 150
76
- --z-drawer: 200
77
- --z-tooltip: 500
78
- ```
79
-
80
- ### Motion
81
-
82
- ```
83
- --duration-fast: 150ms
84
- --duration-normal: 250ms
85
- --duration-slow: 350ms
86
- --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1)
87
- --ease-out: cubic-bezier(0.0, 0, 0.2, 1)
88
- --ease-in: cubic-bezier(0.4, 0, 1, 1)
89
- ```
90
-
91
- ### Border Radius
92
-
93
- ```
94
- --radius: 4px
95
- --radius-pill: 9999px
96
- --radius-full: 50%
97
- ```
98
-
99
- ### Structural
100
-
101
- ```
102
- --border-width: 2px
103
- --shadow-hard: 4px 4px 0px 0px var(--shadow-base)
104
- --shadow-hover: 6px 6px 0px 0px var(--shadow-base)
105
- --shadow-sm: 2px 2px 0px 0px var(--card-border)
106
- --shadow-lg: 8px 8px 0px 0px var(--card-border)
107
- ```
108
-
109
- ### Outline (Focus States)
110
-
111
- ```
112
- --outline-width: 2px
113
- --outline-offset: 2px
114
- ```
115
-
116
- ### Sizes
117
-
118
- ```
119
- --size-icon-sm: 20px
120
- --size-icon-md: 24px
121
- --size-icon-lg: 32px
122
- --size-touch-target: 44px
123
- ```
124
-
125
- ### Overlay
126
-
127
- ```
128
- --overlay-opacity: 0.5
129
- ```
@@ -1,84 +0,0 @@
1
- # Utility Classes
2
-
3
- Available globally via `styles/_utilities.scss` (included in globals).
4
-
5
- ## Display
6
-
7
- | Class | Property |
8
- | -------------- | ---------------------- |
9
- | `.flex` | `display: flex` |
10
- | `.grid` | `display: grid` |
11
- | `.hidden` | `display: none` |
12
- | `.block` | `display: block` |
13
- | `.inline-flex` | `display: inline-flex` |
14
-
15
- ## Flexbox
16
-
17
- | Class | Property |
18
- | ------------------ | -------------------------------- |
19
- | `.flex-row` | `flex-direction: row` |
20
- | `.flex-col` | `flex-direction: column` |
21
- | `.flex-wrap` | `flex-wrap: wrap` |
22
- | `.items-center` | `align-items: center` |
23
- | `.items-start` | `align-items: flex-start` |
24
- | `.items-end` | `align-items: flex-end` |
25
- | `.justify-center` | `justify-content: center` |
26
- | `.justify-between` | `justify-content: space-between` |
27
- | `.justify-end` | `justify-content: flex-end` |
28
-
29
- ## Grid
30
-
31
- | Class | Property |
32
- | ------------------- | --------------------------------------- |
33
- | `.grid-cols-{1-12}` | `grid-template-columns: repeat(n, 1fr)` |
34
-
35
- ## Spacing
36
-
37
- All spacing uses 4px increments (0-10).
38
-
39
- | Class | Property |
40
- | ------------- | ------------------ |
41
- | `.gap-{0-10}` | Gap |
42
- | `.m-{0-10}` | Margin all |
43
- | `.mt-{0-10}` | Margin top |
44
- | `.mb-{0-10}` | Margin bottom |
45
- | `.mx-{0-10}` | Margin horizontal |
46
- | `.my-{0-10}` | Margin vertical |
47
- | `.p-{0-10}` | Padding all |
48
- | `.px-{0-10}` | Padding horizontal |
49
- | `.py-{0-10}` | Padding vertical |
50
-
51
- ## Typography
52
-
53
- | Class | Property |
54
- | ----------------------- | ----------------------------------- |
55
- | `.text-{xs-6xl}` | Font size |
56
- | `.font-{regular-black}` | Font weight |
57
- | `.text-{color}` | Color (primary, muted, error, etc.) |
58
- | `.uppercase` | Text transform |
59
- | `.text-center` | Text align |
60
-
61
- ## Sizing
62
-
63
- | Class | Property |
64
- | ----------- | --------------- |
65
- | `.w-full` | `width: 100%` |
66
- | `.h-full` | `height: 100%` |
67
- | `.h-screen` | `height: 100vh` |
68
-
69
- ## Responsive Prefixes
70
-
71
- Use breakpoint prefixes: `sm:`, `md:`, `lg:`, `xl:`
72
-
73
- ```html
74
- <div class="flex-col md:flex-row">
75
- <!-- Column on mobile, row on md+ -->
76
- </div>
77
- ```
78
-
79
- ## Shadows
80
-
81
- | Class | Property |
82
- | -------------------------------------- | ------------------------- |
83
- | `.shadow-hard` | Standard brutalist shadow |
84
- | `.shadow-{top/bottom/left/right}-hard` | Directional shadows |
@@ -1,82 +0,0 @@
1
- import { InteractionChannel } from "../types/interaction.js";
2
- import { findClosestTargets } from "./utils/search.js";
3
- /**
4
- * Professional-grade Keyboard Sensor for A11y.
5
- * Allows navigating data points using ArrowKeys.
6
- */
7
- export const KeyboardSensor = (options = {}) => {
8
- const { name = InteractionChannel.PRIMARY_HOVER } = options;
9
- let focusedIndex = -1;
10
- return ({ on, off, getChartContext, upsertInteraction, removeInteraction, }) => {
11
- const handleKeyDown = (event) => {
12
- const native = event.nativeEvent;
13
- const ctx = getChartContext();
14
- if (!ctx || !ctx.chartStore) {
15
- return;
16
- }
17
- const state = ctx.chartStore.getState();
18
- const { data, scales } = state;
19
- if (!data || data.length === 0 || !scales.x) {
20
- return;
21
- }
22
- if (native.key === "ArrowRight") {
23
- focusedIndex = Math.min(focusedIndex + 1, data.length - 1);
24
- native.preventDefault();
25
- }
26
- else if (native.key === "ArrowLeft") {
27
- focusedIndex = Math.max(focusedIndex - 1, 0);
28
- native.preventDefault();
29
- }
30
- else if (native.key === "Escape") {
31
- focusedIndex = -1;
32
- removeInteraction(name);
33
- return;
34
- }
35
- else {
36
- return;
37
- }
38
- if (focusedIndex >= 0) {
39
- const d = data[focusedIndex];
40
- const { x: xScale, y: yScale } = scales;
41
- // Resolve coordinates for the primary series/config
42
- const xAcc = state.config.x || ((v) => v[0]);
43
- const yAcc = state.config.y || ((v) => v[1]);
44
- const xVal = typeof xAcc === "function" ? xAcc(d) : d[xAcc];
45
- const yVal = typeof yAcc === "function" ? yAcc(d) : d[yAcc];
46
- const xPos = xScale(xVal) || 0;
47
- const yPos = yScale(yVal) || 0;
48
- // Leverage centralized search logic to identify targets at the keyboard-focused point.
49
- // This coordinates keyboard navigation with multi-series data processing.
50
- const focusEvent = {
51
- type: "CHART_POINTER_MOVE",
52
- nativeEvent: native,
53
- coordinates: {
54
- chartX: xPos,
55
- chartY: yPos,
56
- containerX: xPos,
57
- containerY: yPos,
58
- isWithinPlot: true,
59
- },
60
- };
61
- const targets = findClosestTargets(focusEvent, "nearest-x", state);
62
- if (targets.length > 0) {
63
- upsertInteraction(name, {
64
- pointer: {
65
- x: xPos,
66
- y: yPos,
67
- containerX: xPos,
68
- containerY: yPos,
69
- isTouch: false,
70
- },
71
- targets,
72
- target: targets[0],
73
- });
74
- }
75
- }
76
- };
77
- on("CHART_KEY_DOWN", handleKeyDown);
78
- return () => {
79
- off("CHART_KEY_DOWN", handleKeyDown);
80
- };
81
- };
82
- };
@@ -1,41 +0,0 @@
1
- import { InteractionChannel } from "../types/interaction.js";
2
- import { findClosestTargets } from "./utils/search.js";
3
- /**
4
- * Professional-grade Selection Sensor.
5
- * Coordinates with search logic to choose data points on click.
6
- */
7
- export const SelectionSensor = (options = {}) => {
8
- const { name = InteractionChannel.SELECTION } = options;
9
- return ({ on, off, getChartContext, upsertInteraction }) => {
10
- const handleDown = (event) => {
11
- var _a;
12
- const ctx = getChartContext();
13
- if (!ctx || !ctx.chartStore) {
14
- return;
15
- }
16
- const state = ctx.chartStore.getState();
17
- /**
18
- * For selection, we usually want 'closest' or 'exact' mode to ensure
19
- * the user clicked precisely what they intended.
20
- */
21
- const targets = findClosestTargets(event, "closest", state);
22
- if (targets.length > 0) {
23
- const selectedDatum = targets[0].data;
24
- const currentSelection = ((_a = state.interactions.get(name)) === null || _a === void 0 ? void 0 : _a.selection) || [];
25
- // Simple toggle logic
26
- const isAlreadySelected = currentSelection.includes(selectedDatum);
27
- const nextSelection = isAlreadySelected
28
- ? currentSelection.filter((d) => d !== selectedDatum)
29
- : [...currentSelection, selectedDatum];
30
- upsertInteraction(name, {
31
- selection: nextSelection,
32
- mode: "discrete",
33
- });
34
- }
35
- };
36
- on("CHART_POINTER_DOWN", handleDown);
37
- return () => {
38
- off("CHART_POINTER_DOWN", handleDown);
39
- };
40
- };
41
- };