@neo4j-ndl/react 4.20.0 → 4.21.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 (439) hide show
  1. package/lib/cjs/_common/export-stories-utils.js +1 -1
  2. package/lib/cjs/_common/export-stories-utils.js.map +1 -1
  3. package/lib/cjs/_common/utils.js +3 -3
  4. package/lib/cjs/_common/utils.js.map +1 -1
  5. package/lib/cjs/_generated/style-rules/color-utils.js +3 -0
  6. package/lib/cjs/_generated/style-rules/color-utils.js.map +1 -1
  7. package/lib/cjs/_generated/style-rules/date-utils.js +14 -13
  8. package/lib/cjs/_generated/style-rules/date-utils.js.map +1 -1
  9. package/lib/cjs/_generated/style-rules/literal-schemas.js +5 -3
  10. package/lib/cjs/_generated/style-rules/literal-schemas.js.map +1 -1
  11. package/lib/cjs/ai/code-preview/CodePreview.js +1 -1
  12. package/lib/cjs/ai/code-preview/CodePreview.js.map +1 -1
  13. package/lib/cjs/ai/file-tag/FileTag.js.map +1 -1
  14. package/lib/cjs/ai/image-tag/ImageTag.js.map +1 -1
  15. package/lib/cjs/ai/prompt/Prompt.js +10 -10
  16. package/lib/cjs/ai/prompt/Prompt.js.map +1 -1
  17. package/lib/cjs/ai/prompt/stories/prompt-advanced.story.js +1 -1
  18. package/lib/cjs/ai/prompt/stories/prompt-advanced.story.js.map +1 -1
  19. package/lib/cjs/ai/prompt/stories/prompt-context.story.js +1 -1
  20. package/lib/cjs/ai/prompt/stories/prompt-context.story.js.map +1 -1
  21. package/lib/cjs/ai/prompt/stories/prompt-default.story.js +1 -1
  22. package/lib/cjs/ai/prompt/stories/prompt-default.story.js.map +1 -1
  23. package/lib/cjs/ai/prompt/stories/prompt-header.story.js +1 -1
  24. package/lib/cjs/ai/prompt/stories/prompt-header.story.js.map +1 -1
  25. package/lib/cjs/ai/response/Response.js +4 -4
  26. package/lib/cjs/ai/response/Response.js.map +1 -1
  27. package/lib/cjs/ai/response/stories/response-full-example.story.js +1 -1
  28. package/lib/cjs/ai/response/stories/response-full-example.story.js.map +1 -1
  29. package/lib/cjs/ai/suggestion/Suggestion.js.map +1 -1
  30. package/lib/cjs/ai/thinking/thinking-duration-formatter.js +5 -5
  31. package/lib/cjs/ai/thinking/thinking-duration-formatter.js.map +1 -1
  32. package/lib/cjs/banner/Banner.js +2 -2
  33. package/lib/cjs/banner/Banner.js.map +1 -1
  34. package/lib/cjs/button/ButtonBase.js +4 -4
  35. package/lib/cjs/button/ButtonBase.js.map +1 -1
  36. package/lib/cjs/code/Code.js +3 -3
  37. package/lib/cjs/code/Code.js.map +1 -1
  38. package/lib/cjs/code-block/CodeBlock.js +2 -2
  39. package/lib/cjs/code-block/CodeBlock.js.map +1 -1
  40. package/lib/cjs/color-picker/ColorPicker.js +22 -22
  41. package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
  42. package/lib/cjs/color-picker/stories/color-picker-custom-swatches.story.js +20 -20
  43. package/lib/cjs/color-picker/stories/color-picker-custom-swatches.story.js.map +1 -1
  44. package/lib/cjs/color-picker/stories/color-picker-default.story.js +4 -4
  45. package/lib/cjs/color-picker/stories/color-picker-default.story.js.map +1 -1
  46. package/lib/cjs/color-picker/stories/color-picker-dialog.story.js +4 -4
  47. package/lib/cjs/color-picker/stories/color-picker-dialog.story.js.map +1 -1
  48. package/lib/cjs/color-picker/stories/color-picker-without-eyedropper.story.js +4 -4
  49. package/lib/cjs/color-picker/stories/color-picker-without-eyedropper.story.js.map +1 -1
  50. package/lib/cjs/combobox/stories/combobox-large-data-set.story.js +1 -1
  51. package/lib/cjs/combobox/stories/combobox-large-data-set.story.js.map +1 -1
  52. package/lib/cjs/data-grid/Components.js +20 -20
  53. package/lib/cjs/data-grid/Components.js.map +1 -1
  54. package/lib/cjs/data-grid/DataGrid.js +3 -3
  55. package/lib/cjs/data-grid/DataGrid.js.map +1 -1
  56. package/lib/cjs/data-grid/data-grid-nav/data-grid-nav.js +55 -54
  57. package/lib/cjs/data-grid/data-grid-nav/data-grid-nav.js.map +1 -1
  58. package/lib/cjs/data-grid/data-grid-nav/helpers.js +1 -1
  59. package/lib/cjs/data-grid/data-grid-nav/helpers.js.map +1 -1
  60. package/lib/cjs/data-grid/data-grid-nav/index.js +2 -2
  61. package/lib/cjs/data-grid/data-grid-nav/index.js.map +1 -1
  62. package/lib/cjs/data-grid/helpers/index.js +42 -40
  63. package/lib/cjs/data-grid/helpers/index.js.map +1 -1
  64. package/lib/cjs/data-grid/stories/datagrid-in-dialog.story.js +10 -7
  65. package/lib/cjs/data-grid/stories/datagrid-in-dialog.story.js.map +1 -1
  66. package/lib/cjs/data-grid/stories/datagrid-keyboard-navigation.story.js +10 -7
  67. package/lib/cjs/data-grid/stories/datagrid-keyboard-navigation.story.js.map +1 -1
  68. package/lib/cjs/data-grid/stories/datagrid-rule-based-styling-datetime.story.js +5 -5
  69. package/lib/cjs/data-grid/stories/datagrid-rule-based-styling-datetime.story.js.map +1 -1
  70. package/lib/cjs/data-grid/stories/datagrid-search-and-filters.stories.js +1 -1
  71. package/lib/cjs/data-grid/stories/datagrid-search-and-filters.stories.js.map +1 -1
  72. package/lib/cjs/data-grid/stories/datagrid-virtualization.story.js +5 -5
  73. package/lib/cjs/data-grid/stories/datagrid-virtualization.story.js.map +1 -1
  74. package/lib/cjs/data-grid/style-rules/evaluate.js +23 -23
  75. package/lib/cjs/data-grid/style-rules/evaluate.js.map +1 -1
  76. package/lib/cjs/data-grid/style-rules/types.js +1 -1
  77. package/lib/cjs/data-grid/style-rules/types.js.map +1 -1
  78. package/lib/cjs/dialog/Dialog.js +5 -5
  79. package/lib/cjs/dialog/Dialog.js.map +1 -1
  80. package/lib/cjs/dialog/dialog-types.js.map +1 -1
  81. package/lib/cjs/drawer/Drawer.js +5 -5
  82. package/lib/cjs/drawer/Drawer.js.map +1 -1
  83. package/lib/cjs/dropdown-button/DropdownButton.js +4 -4
  84. package/lib/cjs/dropdown-button/DropdownButton.js.map +1 -1
  85. package/lib/cjs/dropzone/stories/dropzone-full.story.js +1 -1
  86. package/lib/cjs/dropzone/stories/dropzone-full.story.js.map +1 -1
  87. package/lib/cjs/flex/stories/flex-default.story.js +1 -1
  88. package/lib/cjs/flex/stories/flex-default.story.js.map +1 -1
  89. package/lib/cjs/hooks/index.js +3 -3
  90. package/lib/cjs/hooks/index.js.map +1 -1
  91. package/lib/cjs/icon-button-base/IconButtonBase.js +4 -4
  92. package/lib/cjs/icon-button-base/IconButtonBase.js.map +1 -1
  93. package/lib/cjs/icons/generated/custom/ScatterPlot.js +30 -0
  94. package/lib/cjs/icons/generated/custom/ScatterPlot.js.map +1 -0
  95. package/lib/cjs/icons/generated/custom/index.js +4 -2
  96. package/lib/cjs/icons/generated/custom/index.js.map +1 -1
  97. package/lib/cjs/inline-edit/InlineEdit.js +8 -8
  98. package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
  99. package/lib/cjs/kbd/kbd-utils.js +2 -2
  100. package/lib/cjs/kbd/kbd-utils.js.map +1 -1
  101. package/lib/cjs/modal/Modal.js +6 -6
  102. package/lib/cjs/modal/Modal.js.map +1 -1
  103. package/lib/cjs/next/tree-view/TreeView.js +23 -23
  104. package/lib/cjs/next/tree-view/TreeView.js.map +1 -1
  105. package/lib/cjs/next/tree-view/stories/tree-view-lazy.story.js +1 -1
  106. package/lib/cjs/next/tree-view/stories/tree-view-lazy.story.js.map +1 -1
  107. package/lib/cjs/next/tree-view/stories/tree-view-multi.story.js +6 -6
  108. package/lib/cjs/next/tree-view/stories/tree-view-multi.story.js.map +1 -1
  109. package/lib/cjs/popover/Popover.js.map +1 -1
  110. package/lib/cjs/popover/stories/popover-custom-offset.story.js +3 -3
  111. package/lib/cjs/popover/stories/popover-custom-offset.story.js.map +1 -1
  112. package/lib/cjs/popover/use-popover.js +2 -0
  113. package/lib/cjs/popover/use-popover.js.map +1 -1
  114. package/lib/cjs/segmented-control/SegmentedControl.js.map +1 -1
  115. package/lib/cjs/select/Overrides.js +30 -30
  116. package/lib/cjs/select/Overrides.js.map +1 -1
  117. package/lib/cjs/select-icon-button/SelectIconButton.js +4 -4
  118. package/lib/cjs/select-icon-button/SelectIconButton.js.map +1 -1
  119. package/lib/cjs/selectable-tag/stories/selectable-tag-sizes.story.js +1 -1
  120. package/lib/cjs/selectable-tag/stories/selectable-tag-sizes.story.js.map +1 -1
  121. package/lib/cjs/side-navigation/SideNavigation.js +9 -9
  122. package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
  123. package/lib/cjs/slider/Slider.js +1 -1
  124. package/lib/cjs/slider/Slider.js.map +1 -1
  125. package/lib/cjs/slider/stories/slider-single-controlled.story.js +2 -2
  126. package/lib/cjs/slider/stories/slider-single-controlled.story.js.map +1 -1
  127. package/lib/cjs/spotlight/Spotlight.js +6 -6
  128. package/lib/cjs/spotlight/Spotlight.js.map +1 -1
  129. package/lib/cjs/spotlight/SpotlightProvider.js +6 -6
  130. package/lib/cjs/spotlight/SpotlightProvider.js.map +1 -1
  131. package/lib/cjs/spotlight/SpotlightTarget.js +18 -16
  132. package/lib/cjs/spotlight/SpotlightTarget.js.map +1 -1
  133. package/lib/cjs/status-indicator/StatusIndicator.js +4 -2
  134. package/lib/cjs/status-indicator/StatusIndicator.js.map +1 -1
  135. package/lib/cjs/tabs/Tabs.js +3 -3
  136. package/lib/cjs/tabs/Tabs.js.map +1 -1
  137. package/lib/cjs/tabs/use-tabs-scroll-overflow.js +2 -2
  138. package/lib/cjs/tabs/use-tabs-scroll-overflow.js.map +1 -1
  139. package/lib/cjs/text-input/stories/text-input-full.story.js +1 -1
  140. package/lib/cjs/text-input/stories/text-input-full.story.js.map +1 -1
  141. package/lib/cjs/text-input/stories/text-input-with-icons.story.js +1 -1
  142. package/lib/cjs/text-input/stories/text-input-with-icons.story.js.map +1 -1
  143. package/lib/cjs/theme/agnostic.js +4 -4
  144. package/lib/cjs/theme/agnostic.js.map +1 -1
  145. package/lib/cjs/time-picker/TimePicker.js +24 -24
  146. package/lib/cjs/time-picker/TimePicker.js.map +1 -1
  147. package/lib/cjs/time-picker/generate-time-options.js +3 -3
  148. package/lib/cjs/time-picker/generate-time-options.js.map +1 -1
  149. package/lib/cjs/timezone-picker/TimeZonePicker.js +44 -44
  150. package/lib/cjs/timezone-picker/TimeZonePicker.js.map +1 -1
  151. package/lib/cjs/timezone-picker/generate-timezone-options.js +5 -5
  152. package/lib/cjs/timezone-picker/generate-timezone-options.js.map +1 -1
  153. package/lib/cjs/toast/ToastControlled.js +1 -1
  154. package/lib/cjs/toast/ToastControlled.js.map +1 -1
  155. package/lib/cjs/tooltip/use-tooltip.js +8 -1
  156. package/lib/cjs/tooltip/use-tooltip.js.map +1 -1
  157. package/lib/cjs/tree-view/TreeItemWrapper.js +8 -8
  158. package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
  159. package/lib/cjs/tree-view/TreeView.js +6 -2
  160. package/lib/cjs/tree-view/TreeView.js.map +1 -1
  161. package/lib/cjs/tree-view/TreeViewTextItem.js +17 -17
  162. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  163. package/lib/cjs/tree-view/tree-view-keyboard-coordinates.js +2 -0
  164. package/lib/cjs/tree-view/tree-view-keyboard-coordinates.js.map +1 -1
  165. package/lib/cjs/tree-view/tree-view-utils.js +12 -12
  166. package/lib/cjs/tree-view/tree-view-utils.js.map +1 -1
  167. package/lib/esm/_common/export-stories-utils.js +1 -1
  168. package/lib/esm/_common/export-stories-utils.js.map +1 -1
  169. package/lib/esm/_common/utils.js +3 -3
  170. package/lib/esm/_common/utils.js.map +1 -1
  171. package/lib/esm/_generated/style-rules/color-utils.js +3 -0
  172. package/lib/esm/_generated/style-rules/color-utils.js.map +1 -1
  173. package/lib/esm/_generated/style-rules/date-utils.js +14 -13
  174. package/lib/esm/_generated/style-rules/date-utils.js.map +1 -1
  175. package/lib/esm/_generated/style-rules/literal-schemas.js +5 -3
  176. package/lib/esm/_generated/style-rules/literal-schemas.js.map +1 -1
  177. package/lib/esm/ai/code-preview/CodePreview.js +1 -1
  178. package/lib/esm/ai/code-preview/CodePreview.js.map +1 -1
  179. package/lib/esm/ai/file-tag/FileTag.js.map +1 -1
  180. package/lib/esm/ai/image-tag/ImageTag.js.map +1 -1
  181. package/lib/esm/ai/prompt/Prompt.js +10 -10
  182. package/lib/esm/ai/prompt/Prompt.js.map +1 -1
  183. package/lib/esm/ai/prompt/stories/prompt-advanced.story.js +1 -1
  184. package/lib/esm/ai/prompt/stories/prompt-advanced.story.js.map +1 -1
  185. package/lib/esm/ai/prompt/stories/prompt-context.story.js +1 -1
  186. package/lib/esm/ai/prompt/stories/prompt-context.story.js.map +1 -1
  187. package/lib/esm/ai/prompt/stories/prompt-default.story.js +1 -1
  188. package/lib/esm/ai/prompt/stories/prompt-default.story.js.map +1 -1
  189. package/lib/esm/ai/prompt/stories/prompt-header.story.js +1 -1
  190. package/lib/esm/ai/prompt/stories/prompt-header.story.js.map +1 -1
  191. package/lib/esm/ai/response/Response.js +4 -4
  192. package/lib/esm/ai/response/Response.js.map +1 -1
  193. package/lib/esm/ai/response/stories/response-full-example.story.js +1 -1
  194. package/lib/esm/ai/response/stories/response-full-example.story.js.map +1 -1
  195. package/lib/esm/ai/suggestion/Suggestion.js.map +1 -1
  196. package/lib/esm/ai/thinking/thinking-duration-formatter.js +5 -5
  197. package/lib/esm/ai/thinking/thinking-duration-formatter.js.map +1 -1
  198. package/lib/esm/banner/Banner.js +2 -2
  199. package/lib/esm/banner/Banner.js.map +1 -1
  200. package/lib/esm/button/ButtonBase.js +4 -4
  201. package/lib/esm/button/ButtonBase.js.map +1 -1
  202. package/lib/esm/code/Code.js +3 -3
  203. package/lib/esm/code/Code.js.map +1 -1
  204. package/lib/esm/code-block/CodeBlock.js +2 -2
  205. package/lib/esm/code-block/CodeBlock.js.map +1 -1
  206. package/lib/esm/color-picker/ColorPicker.js +22 -22
  207. package/lib/esm/color-picker/ColorPicker.js.map +1 -1
  208. package/lib/esm/color-picker/stories/color-picker-custom-swatches.story.js +20 -20
  209. package/lib/esm/color-picker/stories/color-picker-custom-swatches.story.js.map +1 -1
  210. package/lib/esm/color-picker/stories/color-picker-default.story.js +4 -4
  211. package/lib/esm/color-picker/stories/color-picker-default.story.js.map +1 -1
  212. package/lib/esm/color-picker/stories/color-picker-dialog.story.js +4 -4
  213. package/lib/esm/color-picker/stories/color-picker-dialog.story.js.map +1 -1
  214. package/lib/esm/color-picker/stories/color-picker-without-eyedropper.story.js +4 -4
  215. package/lib/esm/color-picker/stories/color-picker-without-eyedropper.story.js.map +1 -1
  216. package/lib/esm/combobox/stories/combobox-large-data-set.story.js +1 -1
  217. package/lib/esm/combobox/stories/combobox-large-data-set.story.js.map +1 -1
  218. package/lib/esm/data-grid/Components.js +20 -20
  219. package/lib/esm/data-grid/Components.js.map +1 -1
  220. package/lib/esm/data-grid/DataGrid.js +3 -3
  221. package/lib/esm/data-grid/DataGrid.js.map +1 -1
  222. package/lib/esm/data-grid/data-grid-nav/data-grid-nav.js +55 -54
  223. package/lib/esm/data-grid/data-grid-nav/data-grid-nav.js.map +1 -1
  224. package/lib/esm/data-grid/data-grid-nav/helpers.js +1 -1
  225. package/lib/esm/data-grid/data-grid-nav/helpers.js.map +1 -1
  226. package/lib/esm/data-grid/data-grid-nav/index.js +2 -2
  227. package/lib/esm/data-grid/data-grid-nav/index.js.map +1 -1
  228. package/lib/esm/data-grid/helpers/index.js +42 -40
  229. package/lib/esm/data-grid/helpers/index.js.map +1 -1
  230. package/lib/esm/data-grid/stories/datagrid-in-dialog.story.js +10 -7
  231. package/lib/esm/data-grid/stories/datagrid-in-dialog.story.js.map +1 -1
  232. package/lib/esm/data-grid/stories/datagrid-keyboard-navigation.story.js +10 -7
  233. package/lib/esm/data-grid/stories/datagrid-keyboard-navigation.story.js.map +1 -1
  234. package/lib/esm/data-grid/stories/datagrid-rule-based-styling-datetime.story.js +5 -5
  235. package/lib/esm/data-grid/stories/datagrid-rule-based-styling-datetime.story.js.map +1 -1
  236. package/lib/esm/data-grid/stories/datagrid-search-and-filters.stories.js +1 -1
  237. package/lib/esm/data-grid/stories/datagrid-search-and-filters.stories.js.map +1 -1
  238. package/lib/esm/data-grid/stories/datagrid-virtualization.story.js +5 -5
  239. package/lib/esm/data-grid/stories/datagrid-virtualization.story.js.map +1 -1
  240. package/lib/esm/data-grid/style-rules/evaluate.js +23 -23
  241. package/lib/esm/data-grid/style-rules/evaluate.js.map +1 -1
  242. package/lib/esm/data-grid/style-rules/types.js +1 -1
  243. package/lib/esm/data-grid/style-rules/types.js.map +1 -1
  244. package/lib/esm/dialog/Dialog.js +5 -5
  245. package/lib/esm/dialog/Dialog.js.map +1 -1
  246. package/lib/esm/dialog/dialog-types.js.map +1 -1
  247. package/lib/esm/drawer/Drawer.js +5 -5
  248. package/lib/esm/drawer/Drawer.js.map +1 -1
  249. package/lib/esm/dropdown-button/DropdownButton.js +4 -4
  250. package/lib/esm/dropdown-button/DropdownButton.js.map +1 -1
  251. package/lib/esm/dropzone/stories/dropzone-full.story.js +1 -1
  252. package/lib/esm/dropzone/stories/dropzone-full.story.js.map +1 -1
  253. package/lib/esm/flex/stories/flex-default.story.js +1 -1
  254. package/lib/esm/flex/stories/flex-default.story.js.map +1 -1
  255. package/lib/esm/hooks/index.js +3 -3
  256. package/lib/esm/hooks/index.js.map +1 -1
  257. package/lib/esm/icon-button-base/IconButtonBase.js +4 -4
  258. package/lib/esm/icon-button-base/IconButtonBase.js.map +1 -1
  259. package/lib/esm/icons/generated/custom/ScatterPlot.js +28 -0
  260. package/lib/esm/icons/generated/custom/ScatterPlot.js.map +1 -0
  261. package/lib/esm/icons/generated/custom/index.js +1 -0
  262. package/lib/esm/icons/generated/custom/index.js.map +1 -1
  263. package/lib/esm/inline-edit/InlineEdit.js +8 -8
  264. package/lib/esm/inline-edit/InlineEdit.js.map +1 -1
  265. package/lib/esm/kbd/kbd-utils.js +2 -2
  266. package/lib/esm/kbd/kbd-utils.js.map +1 -1
  267. package/lib/esm/modal/Modal.js +6 -6
  268. package/lib/esm/modal/Modal.js.map +1 -1
  269. package/lib/esm/next/tree-view/TreeView.js +23 -23
  270. package/lib/esm/next/tree-view/TreeView.js.map +1 -1
  271. package/lib/esm/next/tree-view/stories/tree-view-lazy.story.js +1 -1
  272. package/lib/esm/next/tree-view/stories/tree-view-lazy.story.js.map +1 -1
  273. package/lib/esm/next/tree-view/stories/tree-view-multi.story.js +6 -6
  274. package/lib/esm/next/tree-view/stories/tree-view-multi.story.js.map +1 -1
  275. package/lib/esm/popover/Popover.js.map +1 -1
  276. package/lib/esm/popover/stories/popover-custom-offset.story.js +3 -3
  277. package/lib/esm/popover/stories/popover-custom-offset.story.js.map +1 -1
  278. package/lib/esm/popover/use-popover.js +2 -0
  279. package/lib/esm/popover/use-popover.js.map +1 -1
  280. package/lib/esm/segmented-control/SegmentedControl.js.map +1 -1
  281. package/lib/esm/select/Overrides.js +30 -30
  282. package/lib/esm/select/Overrides.js.map +1 -1
  283. package/lib/esm/select-icon-button/SelectIconButton.js +4 -4
  284. package/lib/esm/select-icon-button/SelectIconButton.js.map +1 -1
  285. package/lib/esm/selectable-tag/stories/selectable-tag-sizes.story.js +1 -1
  286. package/lib/esm/selectable-tag/stories/selectable-tag-sizes.story.js.map +1 -1
  287. package/lib/esm/side-navigation/SideNavigation.js +9 -9
  288. package/lib/esm/side-navigation/SideNavigation.js.map +1 -1
  289. package/lib/esm/slider/Slider.js +1 -1
  290. package/lib/esm/slider/Slider.js.map +1 -1
  291. package/lib/esm/slider/stories/slider-single-controlled.story.js +2 -2
  292. package/lib/esm/slider/stories/slider-single-controlled.story.js.map +1 -1
  293. package/lib/esm/spotlight/Spotlight.js +6 -6
  294. package/lib/esm/spotlight/Spotlight.js.map +1 -1
  295. package/lib/esm/spotlight/SpotlightProvider.js +6 -6
  296. package/lib/esm/spotlight/SpotlightProvider.js.map +1 -1
  297. package/lib/esm/spotlight/SpotlightTarget.js +18 -16
  298. package/lib/esm/spotlight/SpotlightTarget.js.map +1 -1
  299. package/lib/esm/status-indicator/StatusIndicator.js +4 -2
  300. package/lib/esm/status-indicator/StatusIndicator.js.map +1 -1
  301. package/lib/esm/tabs/Tabs.js +3 -3
  302. package/lib/esm/tabs/Tabs.js.map +1 -1
  303. package/lib/esm/tabs/use-tabs-scroll-overflow.js +2 -2
  304. package/lib/esm/tabs/use-tabs-scroll-overflow.js.map +1 -1
  305. package/lib/esm/text-input/stories/text-input-full.story.js +1 -1
  306. package/lib/esm/text-input/stories/text-input-full.story.js.map +1 -1
  307. package/lib/esm/text-input/stories/text-input-with-icons.story.js +1 -1
  308. package/lib/esm/text-input/stories/text-input-with-icons.story.js.map +1 -1
  309. package/lib/esm/theme/agnostic.js +3 -3
  310. package/lib/esm/theme/agnostic.js.map +1 -1
  311. package/lib/esm/time-picker/TimePicker.js +24 -24
  312. package/lib/esm/time-picker/TimePicker.js.map +1 -1
  313. package/lib/esm/time-picker/generate-time-options.js +3 -3
  314. package/lib/esm/time-picker/generate-time-options.js.map +1 -1
  315. package/lib/esm/timezone-picker/TimeZonePicker.js +44 -44
  316. package/lib/esm/timezone-picker/TimeZonePicker.js.map +1 -1
  317. package/lib/esm/timezone-picker/generate-timezone-options.js +5 -5
  318. package/lib/esm/timezone-picker/generate-timezone-options.js.map +1 -1
  319. package/lib/esm/toast/ToastControlled.js +1 -1
  320. package/lib/esm/toast/ToastControlled.js.map +1 -1
  321. package/lib/esm/tooltip/use-tooltip.js +8 -1
  322. package/lib/esm/tooltip/use-tooltip.js.map +1 -1
  323. package/lib/esm/tree-view/TreeItemWrapper.js +8 -8
  324. package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
  325. package/lib/esm/tree-view/TreeView.js +6 -2
  326. package/lib/esm/tree-view/TreeView.js.map +1 -1
  327. package/lib/esm/tree-view/TreeViewTextItem.js +17 -17
  328. package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
  329. package/lib/esm/tree-view/tree-view-keyboard-coordinates.js +2 -0
  330. package/lib/esm/tree-view/tree-view-keyboard-coordinates.js.map +1 -1
  331. package/lib/esm/tree-view/tree-view-utils.js +12 -12
  332. package/lib/esm/tree-view/tree-view-utils.js.map +1 -1
  333. package/lib/types/_common/export-stories-utils.d.ts +1 -1
  334. package/lib/types/_common/utils.d.ts +3 -3
  335. package/lib/types/_generated/style-rules/color-utils.d.ts.map +1 -1
  336. package/lib/types/_generated/style-rules/date-utils.d.ts +3 -3
  337. package/lib/types/_generated/style-rules/date-utils.d.ts.map +1 -1
  338. package/lib/types/_generated/style-rules/literal-schemas.d.ts.map +1 -1
  339. package/lib/types/ai/code-preview/CodePreview.d.ts +1 -1
  340. package/lib/types/ai/file-tag/FileTag.d.ts +1 -1
  341. package/lib/types/ai/file-tag/FileTag.d.ts.map +1 -1
  342. package/lib/types/ai/image-tag/ImageTag.d.ts +1 -1
  343. package/lib/types/ai/image-tag/ImageTag.d.ts.map +1 -1
  344. package/lib/types/ai/prompt/Prompt.d.ts +3 -3
  345. package/lib/types/ai/prompt/Prompt.d.ts.map +1 -1
  346. package/lib/types/ai/suggestion/Suggestion.d.ts +1 -1
  347. package/lib/types/ai/suggestion/Suggestion.d.ts.map +1 -1
  348. package/lib/types/ai/thinking/thinking-duration-formatter.d.ts +5 -5
  349. package/lib/types/banner/Banner.d.ts +1 -1
  350. package/lib/types/banner/Banner.d.ts.map +1 -1
  351. package/lib/types/button/ButtonBase.d.ts +2 -2
  352. package/lib/types/button/ButtonBase.d.ts.map +1 -1
  353. package/lib/types/code/Code.d.ts +1 -1
  354. package/lib/types/code/Code.d.ts.map +1 -1
  355. package/lib/types/data-grid/Components.d.ts +2 -2
  356. package/lib/types/data-grid/Components.d.ts.map +1 -1
  357. package/lib/types/data-grid/DataGrid.d.ts +2 -2
  358. package/lib/types/data-grid/data-grid-nav/data-grid-nav.d.ts +4 -4
  359. package/lib/types/data-grid/data-grid-nav/data-grid-nav.d.ts.map +1 -1
  360. package/lib/types/data-grid/data-grid-nav/helpers.d.ts +1 -1
  361. package/lib/types/data-grid/data-grid-nav/index.d.ts +1 -1
  362. package/lib/types/data-grid/data-grid-nav/index.d.ts.map +1 -1
  363. package/lib/types/data-grid/helpers/index.d.ts +5 -5
  364. package/lib/types/data-grid/helpers/index.d.ts.map +1 -1
  365. package/lib/types/data-grid/stories/datagrid-in-dialog.story.d.ts.map +1 -1
  366. package/lib/types/data-grid/stories/datagrid-keyboard-navigation.story.d.ts.map +1 -1
  367. package/lib/types/data-grid/stories/datagrid-pinned-columns.stories.d.ts +2 -2
  368. package/lib/types/data-grid/stories/datagrid-search-and-filters.stories.d.ts +2 -2
  369. package/lib/types/data-grid/stories/datagrid-virtualization.story.d.ts.map +1 -1
  370. package/lib/types/data-grid/style-rules/evaluate.d.ts +1 -1
  371. package/lib/types/dialog/Dialog.d.ts.map +1 -1
  372. package/lib/types/dialog/dialog-types.d.ts +1 -1
  373. package/lib/types/dialog/dialog-types.d.ts.map +1 -1
  374. package/lib/types/drawer/Drawer.d.ts +1 -1
  375. package/lib/types/drawer/Drawer.d.ts.map +1 -1
  376. package/lib/types/dropdown-button/DropdownButton.d.ts +1 -1
  377. package/lib/types/dropdown-button/DropdownButton.d.ts.map +1 -1
  378. package/lib/types/hooks/index.d.ts +3 -3
  379. package/lib/types/icon-button-base/IconButtonBase.d.ts +1 -1
  380. package/lib/types/icon-button-base/IconButtonBase.d.ts.map +1 -1
  381. package/lib/types/icons/generated/custom/ScatterPlot.d.ts +29 -0
  382. package/lib/types/icons/generated/custom/ScatterPlot.d.ts.map +1 -0
  383. package/lib/types/icons/generated/custom/index.d.ts +1 -0
  384. package/lib/types/icons/generated/custom/index.d.ts.map +1 -1
  385. package/lib/types/modal/Modal.d.ts +1 -1
  386. package/lib/types/modal/Modal.d.ts.map +1 -1
  387. package/lib/types/popover/Popover.d.ts.map +1 -1
  388. package/lib/types/popover/use-popover.d.ts.map +1 -1
  389. package/lib/types/segmented-control/SegmentedControl.d.ts +1 -1
  390. package/lib/types/segmented-control/SegmentedControl.d.ts.map +1 -1
  391. package/lib/types/select/Overrides.d.ts.map +1 -1
  392. package/lib/types/select-icon-button/SelectIconButton.d.ts +1 -1
  393. package/lib/types/select-icon-button/SelectIconButton.d.ts.map +1 -1
  394. package/lib/types/selectable-tag/stories/selectable-tag-sizes.story.d.ts.map +1 -1
  395. package/lib/types/spotlight/SpotlightProvider.d.ts.map +1 -1
  396. package/lib/types/spotlight/SpotlightTarget.d.ts +4 -3
  397. package/lib/types/spotlight/SpotlightTarget.d.ts.map +1 -1
  398. package/lib/types/status-indicator/StatusIndicator.d.ts.map +1 -1
  399. package/lib/types/tabs/Tabs.d.ts +1 -1
  400. package/lib/types/tabs/Tabs.d.ts.map +1 -1
  401. package/lib/types/theme/agnostic.d.ts +2 -2
  402. package/lib/types/theme/agnostic.d.ts.map +1 -1
  403. package/lib/types/tooltip/use-tooltip.d.ts.map +1 -1
  404. package/lib/types/tree-view/TreeView.d.ts.map +1 -1
  405. package/lib/types/tree-view/TreeViewTextItem.d.ts.map +1 -1
  406. package/lib/types/tree-view/tree-view-keyboard-coordinates.d.ts.map +1 -1
  407. package/lib/types/tree-view/tree-view-utils.d.ts +12 -12
  408. package/lib/types/tree-view/tree-view-utils.d.ts.map +1 -1
  409. package/package.json +5 -3
  410. package/skills/ndl-react/SKILL.md +54 -3
  411. package/skills/ndl-react/components/ai/file-tag.md +1 -1
  412. package/skills/ndl-react/components/ai/image-tag.md +1 -1
  413. package/skills/ndl-react/components/ai/prompt.md +10 -10
  414. package/skills/ndl-react/components/ai/response.md +1 -1
  415. package/skills/ndl-react/components/ai/suggestion.md +1 -1
  416. package/skills/ndl-react/components/banner.md +1 -1
  417. package/skills/ndl-react/components/clean-icon-button.md +1 -1
  418. package/skills/ndl-react/components/code.md +1 -1
  419. package/skills/ndl-react/components/combobox.md +1 -1
  420. package/skills/ndl-react/components/data-grid.md +35 -28
  421. package/skills/ndl-react/components/dialog.md +1 -1
  422. package/skills/ndl-react/components/drawer.md +1 -1
  423. package/skills/ndl-react/components/dropdown-button.md +1 -1
  424. package/skills/ndl-react/components/dropzone.md +1 -1
  425. package/skills/ndl-react/components/filled-button.md +2 -2
  426. package/skills/ndl-react/components/flex.md +2 -2
  427. package/skills/ndl-react/components/icon-button.md +1 -1
  428. package/skills/ndl-react/components/modal.md +1 -1
  429. package/skills/ndl-react/components/next/tree-view.md +8 -8
  430. package/skills/ndl-react/components/outlined-button.md +2 -2
  431. package/skills/ndl-react/components/popover.md +3 -3
  432. package/skills/ndl-react/components/segmented-control.md +1 -1
  433. package/skills/ndl-react/components/select-icon-button.md +1 -1
  434. package/skills/ndl-react/components/selectable-tag.md +10 -4
  435. package/skills/ndl-react/components/slider.md +2 -2
  436. package/skills/ndl-react/components/tabs.md +1 -1
  437. package/skills/ndl-react/components/text-button.md +2 -2
  438. package/skills/ndl-react/components/text-input.md +2 -2
  439. package/skills/ndl-react/references/styling.md +290 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../../src/slider/Slider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AACpC,+CAAsD;AACtD,2CAMoB;AACpB,iDAAiE;AAMjE,wCAAqC;AA+C9B,MAAM,MAAM,GAAG,CAAsC,EAgBnB,EAAE,EAAE;QAhBe,EAC1D,EAAE,EACF,UAAU,GAAG,EAAE,EACf,SAAS,EACT,KAAK,EACL,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,GAAG,EACd,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,CAAC,EACR,IAAI,GAAG,QAAQ,EACf,QAAQ,EACR,cAAc,EACd,GAAG,OAEoC,EADpC,SAAS,cAf8C,gKAgB3D,CADa;IAEZ,MAAM,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAwB,IAAI,CAAC,CAAC;IAE3D,MAAM,WAAW,GACf,IAAI,KAAK,OAAO;QACd,CA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,IAAI,WAAW,CAAC,KAAK,KAAK,CAAC;QACxD,CAAC,CAAC,WAAW,CAAC,KAAK;QACnB,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,CACL,wBAAC,iBAAO,IACN,UAAU,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,EACrC,MAAM,EAAE,UAAU,IAAI,SAAS,EAC/B,SAAS,EAAC,KAAK,EACf,IAAI,EAAC,QAAQ,aAEb,uBAAC,iBAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,gDACM,UAAU,IACd,SAAS,EAAE,IAAA,oBAAU,EAAC,WAAW,EAAE;wBACjC,WAAW,EAAE,cAAc;wBAC3B,iBAAiB,EAAE,UAAU;qBAC9B,CAAC,YAEF,uBAAC,2BAAc,cACb,gDAAO,GAAG,EAAE,QAAQ,IAAM,WAAW,EAAI,GAC1B,IACb,GACU,EAClB,uBAAC,iBAAO,CAAC,OAAO,cAAE,KAAK,GAAmB,IAClC,CACX,CAAC;AACJ,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport React, { useCallback, useEffect } from 'react';\nimport {\n mergeProps,\n useFocusRing,\n useSlider,\n useSliderThumb,\n VisuallyHidden,\n} from 'react-aria';\nimport { type SliderState, useSliderState } from 'react-stately';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { Tooltip } from '../tooltip';\n\ntype SliderPropsBase = {\n /** Input props of the underlying input element */\n inputProps?: HtmlAttributes<'input'>;\n /** Determines the step size that will be added or removed from the current value when moving the slider button */\n step?: number;\n /** Whether the slider is disabled */\n isDisabled?: boolean;\n /** The minimum value possible to choose */\n minValue?: number;\n /** The maximum value possible to choose */\n maxValue?: number;\n /** Whether to display a tooltip with the current value when the slider is being dragged */\n // TODO v5: decide if this naming is okay, or change it\n // eslint-disable-next-line @typescript-eslint/naming-convention\n showValues?: boolean;\n /** Whether to display visual indicators for each step in the slider */\n // TODO v5: decide if this naming is okay, or change it\n // eslint-disable-next-line @typescript-eslint/naming-convention\n showSteps?: boolean;\n};\n\ntype SingleSlider = SliderPropsBase & {\n /** Type of the slider */\n type?: 'single';\n /** Current value of the single slider. **Only required when the type is 'single'**. */\n value: number;\n /** Callback function triggered when the slider value(s) changes. The function parameter varies depending on the slider type, for single slider, it is a number and for range slider, it is an array of two numbers. */\n onChange: (value: number) => void;\n};\n\ntype RangeSlider = SliderPropsBase & {\n /** Type of the slider */\n type: 'range';\n /** Current values of the range slider as an array of two numbers `[min, max]`. **Only required when the type is 'range'**.*/\n values: [number, number];\n /** Callback function triggered when the slider value(s) changes. The function parameter varies depending on the slider type, for single slider, it is a number and for range slider, it is an array of two numbers. */\n onChange: (value: [number, number]) => void;\n};\n\n/**\n * @remarks\n * The `type` prop is used to determine the type of the slider. It can be `single` or `range`. The `value` prop is required when the `type` is `single` and `values` is required when the `type` is `range`. It also affects the `onChange` prop type.\n */\ntype SliderProps = SingleSlider | RangeSlider;\n\nexport const Slider = <T extends React.ElementType = 'div'>({\n as,\n inputProps = {},\n className,\n style,\n minValue = 0,\n maxValue = 100,\n isDisabled = false,\n showSteps = false,\n showValues = false,\n step = 1,\n type = 'single',\n onChange,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SliderProps>) => {\n const trackRef = React.useRef<HTMLDivElement | null>(null);\n\n const castedValue =\n type === 'range'\n ? (restProps as RangeSlider).values\n : (restProps as SingleSlider).value;\n\n const castedOnChange =\n type === 'range'\n ? (onChange as RangeSlider['onChange'])\n : (onChange as SingleSlider['onChange']);\n\n const state = useSliderState<typeof castedValue>({\n defaultValue: castedValue,\n isDisabled,\n maxValue,\n minValue,\n numberFormatter: new Intl.NumberFormat('en-US'),\n // oxlint-disable-next-line no-explicit-any\n onChange: castedOnChange as any,\n step,\n });\n\n const { setThumbValue } = state;\n\n const { groupProps, trackProps } = useSlider(\n { 'aria-label': 'slider' },\n state,\n trackRef,\n );\n\n const updatesSliderValue = useCallback(\n (newValue: number | [number, number]) => {\n if (type === 'single' && typeof newValue === 'number') {\n setThumbValue(0, newValue);\n } else if (type === 'range' && Array.isArray(newValue)) {\n setThumbValue(0, newValue[0]);\n setThumbValue(1, newValue[1]);\n }\n },\n [type, setThumbValue],\n );\n\n useEffect(() => {\n updatesSliderValue(castedValue);\n // Needed to make the slider work with controlled values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [castedValue]);\n\n const Component: React.ElementType = as ?? 'div';\n\n return (\n <Component\n className={classNames('ndl-slider', className)}\n style={style}\n role=\"presentation\"\n ref={ref}\n {...groupProps}\n {...restProps}\n {...htmlAttributes}\n >\n {/* The track element holds the visible track line, the filled track line and the thumb. */}\n <div\n {...trackProps}\n ref={trackRef as React.RefObject<HTMLDivElement>}\n className={classNames('ndl-track', {\n 'ndl-is-disabled': state.isDisabled,\n })}\n >\n {/* Circular marks, acting as indicators for the steps */}\n {showSteps && (\n <TrackMarks state={state} min={minValue} max={maxValue} />\n )}\n <FilledTrack state={state} />\n <Thumb\n index={0}\n state={state}\n trackRef={trackRef as React.RefObject<HTMLDivElement>}\n showValues={showValues}\n inputForwardedProps={inputProps}\n />\n {type === 'range' && (\n <Thumb\n index={1}\n state={state}\n trackRef={trackRef as React.RefObject<HTMLDivElement>}\n showValues={showValues}\n inputForwardedProps={inputProps}\n />\n )}\n </div>\n </Component>\n );\n};\n\nSlider.displayName = 'Slider';\n\nfunction FilledTrack({ state }: { state: SliderState }) {\n let width: number;\n let left: number;\n if (state.values.length === 1) {\n width = state.getValuePercent(state.values[0]) * 100;\n left = 0;\n } else {\n width =\n state.getValuePercent(state.values[1]) * 100 -\n state.getValuePercent(state.values[0]) * 100;\n left = state.getValuePercent(state.values[0]) * 100;\n }\n\n return (\n <div\n className=\"ndl-filled-track\"\n style={{\n left: `${left}%`,\n width: `${width}%`,\n }}\n />\n );\n}\n\nfunction TrackMarks({\n state,\n max,\n min,\n}: {\n state: SliderState;\n max: number;\n min: number;\n}) {\n const markNo = Math.round((max - min) / state.step);\n\n return (\n <div role=\"presentation\" className=\"ndl-track-marks\">\n {Array.from({ length: markNo - 1 }).map((_, index) => {\n const percent = (index / markNo) * 100;\n\n let isFilled;\n if (state.values.length === 1) {\n isFilled = state.getValuePercent(state.values[0]) * 100 > percent;\n } else {\n isFilled =\n state.getValuePercent(state.values[0]) * 100 < percent &&\n state.getValuePercent(state.values[1]) * 100 > percent;\n }\n\n return (\n <div\n key={`track-mark-${index}`}\n className={classNames('ndl-track-mark', {\n 'ndl-on-active-track': isFilled,\n })}\n style={{\n left: `${((index + 1) / markNo) * 100}%`,\n }}\n />\n );\n })}\n </div>\n );\n}\n\nfunction Thumb(props: {\n index: number;\n state: SliderState;\n // TODO v5: decide if this naming is okay, or change it\n // eslint-disable-next-line @typescript-eslint/naming-convention\n showValues?: boolean;\n trackRef: React.RefObject<HTMLDivElement>;\n inputForwardedProps: HtmlAttributes<'input'>;\n}) {\n const { state, trackRef, index, inputForwardedProps } = props;\n const inputRef = React.useRef(null);\n const { thumbProps, inputProps, isDragging } = useSliderThumb(\n {\n index,\n inputRef,\n name: 'slider-thumb',\n trackRef,\n },\n state,\n );\n\n const { focusProps, isFocusVisible } = useFocusRing();\n\n /**\n * Solve issue with:\n * Warning: Received NaN for the `value` attribute. If this is expected, cast the value to a string.\n * Receiving NaN for other attributes also, like `max`. Waiting for a fix in react-aria.\n * @see https://github.com/adobe/react-spectrum/issues/5859\n * @see https://github.com/adobe/react-spectrum/pull/5861\n */\n const mergedProps = mergeProps(\n inputProps,\n focusProps,\n // Omitting aria-valuetext double announcements, unless explicitly provided\n { 'aria-valuetext': '' },\n inputForwardedProps,\n );\n const value =\n mergedProps.value !== undefined || mergedProps.value === 0\n ? mergedProps.value\n : '';\n\n return (\n <Tooltip\n isDisabled={props.showValues !== true}\n isOpen={isDragging || undefined}\n placement=\"top\"\n type=\"simple\"\n >\n <Tooltip.Trigger hasButtonWrapper>\n <div\n {...thumbProps}\n className={classNames('ndl-thumb', {\n 'ndl-focus': isFocusVisible,\n 'ndl-is-dragging': isDragging,\n })}\n >\n <VisuallyHidden>\n <input ref={inputRef} {...mergedProps} />\n </VisuallyHidden>\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>{value}</Tooltip.Content>\n </Tooltip>\n );\n}\n"]}
1
+ {"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../../src/slider/Slider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AACpC,+CAAsD;AACtD,2CAMoB;AACpB,iDAAiE;AAMjE,wCAAqC;AA+C9B,MAAM,MAAM,GAAG,CAAsC,EAgBnB,EAAE,EAAE;QAhBe,EAC1D,EAAE,EACF,UAAU,GAAG,EAAE,EACf,SAAS,EACT,KAAK,EACL,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,GAAG,EACd,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,CAAC,EACR,IAAI,GAAG,QAAQ,EACf,QAAQ,EACR,cAAc,EACd,GAAG,OAEoC,EADpC,SAAS,cAf8C,gKAgB3D,CADa;IAEZ,MAAM,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAwB,IAAI,CAAC,CAAC;IAE3D,MAAM,WAAW,GACf,IAAI,KAAK,OAAO;QACd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AAS,IAAI,WAAW,CAAC,KAAK,KAAK,CAAC;QACxD,CAAC,CAAC,WAAW,CAAC,KAAK;QACnB,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,CACL,wBAAC,iBAAO,IACN,UAAU,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,EACrC,MAAM,EAAE,UAAU,IAAI,SAAS,EAC/B,SAAS,EAAC,KAAK,EACf,IAAI,EAAC,QAAQ,aAEb,uBAAC,iBAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,gDACM,UAAU,IACd,SAAS,EAAE,IAAA,oBAAU,EAAC,WAAW,EAAE;wBACjC,WAAW,EAAE,cAAc;wBAC3B,iBAAiB,EAAE,UAAU;qBAC9B,CAAC,YAEF,uBAAC,2BAAc,cACb,gDAAO,GAAG,EAAE,QAAQ,IAAM,WAAW,EAAI,GAC1B,IACb,GACU,EAClB,uBAAC,iBAAO,CAAC,OAAO,cAAE,KAAK,GAAmB,IAClC,CACX,CAAC;AACJ,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport React, { useCallback, useEffect } from 'react';\nimport {\n mergeProps,\n useFocusRing,\n useSlider,\n useSliderThumb,\n VisuallyHidden,\n} from 'react-aria';\nimport { type SliderState, useSliderState } from 'react-stately';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { Tooltip } from '../tooltip';\n\ntype SliderPropsBase = {\n /** Input props of the underlying input element */\n inputProps?: HtmlAttributes<'input'>;\n /** Determines the step size that will be added or removed from the current value when moving the slider button */\n step?: number;\n /** Whether the slider is disabled */\n isDisabled?: boolean;\n /** The minimum value possible to choose */\n minValue?: number;\n /** The maximum value possible to choose */\n maxValue?: number;\n /** Whether to display a tooltip with the current value when the slider is being dragged */\n // TODO v5: decide if this naming is okay, or change it\n // eslint-disable-next-line @typescript-eslint/naming-convention\n showValues?: boolean;\n /** Whether to display visual indicators for each step in the slider */\n // TODO v5: decide if this naming is okay, or change it\n // eslint-disable-next-line @typescript-eslint/naming-convention\n showSteps?: boolean;\n};\n\ntype SingleSlider = SliderPropsBase & {\n /** Type of the slider */\n type?: 'single';\n /** Current value of the single slider. **Only required when the type is 'single'**. */\n value: number;\n /** Callback function triggered when the slider value(s) changes. The function parameter varies depending on the slider type, for single slider, it is a number and for range slider, it is an array of two numbers. */\n onChange: (value: number) => void;\n};\n\ntype RangeSlider = SliderPropsBase & {\n /** Type of the slider */\n type: 'range';\n /** Current values of the range slider as an array of two numbers `[min, max]`. **Only required when the type is 'range'**.*/\n values: [number, number];\n /** Callback function triggered when the slider value(s) changes. The function parameter varies depending on the slider type, for single slider, it is a number and for range slider, it is an array of two numbers. */\n onChange: (value: [number, number]) => void;\n};\n\n/**\n * @remarks\n * The `type` prop is used to determine the type of the slider. It can be `single` or `range`. The `value` prop is required when the `type` is `single` and `values` is required when the `type` is `range`. It also affects the `onChange` prop type.\n */\ntype SliderProps = SingleSlider | RangeSlider;\n\nexport const Slider = <T extends React.ElementType = 'div'>({\n as,\n inputProps = {},\n className,\n style,\n minValue = 0,\n maxValue = 100,\n isDisabled = false,\n showSteps = false,\n showValues = false,\n step = 1,\n type = 'single',\n onChange,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SliderProps>) => {\n const trackRef = React.useRef<HTMLDivElement | null>(null);\n\n const castedValue =\n type === 'range'\n ? (restProps as RangeSlider).values\n : (restProps as SingleSlider).value;\n\n const castedOnChange =\n type === 'range'\n ? (onChange as RangeSlider['onChange'])\n : (onChange as SingleSlider['onChange']);\n\n const state = useSliderState<typeof castedValue>({\n defaultValue: castedValue,\n isDisabled,\n maxValue,\n minValue,\n numberFormatter: new Intl.NumberFormat('en-US'),\n // oxlint-disable-next-line no-explicit-any\n onChange: castedOnChange as any,\n step,\n });\n\n const { setThumbValue } = state;\n\n const { groupProps, trackProps } = useSlider(\n { 'aria-label': 'slider' },\n state,\n trackRef,\n );\n\n const updatesSliderValue = useCallback(\n (newValue: number | [number, number]) => {\n if (type === 'single' && typeof newValue === 'number') {\n setThumbValue(0, newValue);\n } else if (type === 'range' && Array.isArray(newValue)) {\n setThumbValue(0, newValue[0]);\n setThumbValue(1, newValue[1]);\n }\n },\n [type, setThumbValue],\n );\n\n useEffect(() => {\n updatesSliderValue(castedValue);\n // Needed to make the slider work with controlled values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [castedValue]);\n\n const Component: React.ElementType = as ?? 'div';\n\n return (\n <Component\n className={classNames('ndl-slider', className)}\n style={style}\n role=\"presentation\"\n ref={ref}\n {...groupProps}\n {...restProps}\n {...htmlAttributes}\n >\n {/* The track element holds the visible track line, the filled track line and the thumb. */}\n <div\n {...trackProps}\n ref={trackRef as React.RefObject<HTMLDivElement>}\n className={classNames('ndl-track', {\n 'ndl-is-disabled': state.isDisabled,\n })}\n >\n {/* Circular marks, acting as indicators for the steps */}\n {showSteps && (\n <TrackMarks state={state} min={minValue} max={maxValue} />\n )}\n <FilledTrack state={state} />\n <Thumb\n index={0}\n state={state}\n trackRef={trackRef as React.RefObject<HTMLDivElement>}\n showValues={showValues}\n inputForwardedProps={inputProps}\n />\n {type === 'range' && (\n <Thumb\n index={1}\n state={state}\n trackRef={trackRef as React.RefObject<HTMLDivElement>}\n showValues={showValues}\n inputForwardedProps={inputProps}\n />\n )}\n </div>\n </Component>\n );\n};\n\nSlider.displayName = 'Slider';\n\nfunction FilledTrack({ state }: { state: SliderState }) {\n let width: number;\n let left: number;\n if (state.values.length === 1) {\n width = state.getValuePercent(state.values[0]) * 100;\n left = 0;\n } else {\n width =\n state.getValuePercent(state.values[1]) * 100 -\n state.getValuePercent(state.values[0]) * 100;\n left = state.getValuePercent(state.values[0]) * 100;\n }\n\n return (\n <div\n className=\"ndl-filled-track\"\n style={{\n left: `${left}%`,\n width: `${width}%`,\n }}\n />\n );\n}\n\nfunction TrackMarks({\n state,\n max,\n min,\n}: {\n state: SliderState;\n max: number;\n min: number;\n}) {\n const markNo = Math.round((max - min) / state.step);\n\n return (\n <div role=\"presentation\" className=\"ndl-track-marks\">\n {Array.from({ length: markNo - 1 }).map((_unused, index) => {\n const percent = (index / markNo) * 100;\n\n let isFilled;\n if (state.values.length === 1) {\n isFilled = state.getValuePercent(state.values[0]) * 100 > percent;\n } else {\n isFilled =\n state.getValuePercent(state.values[0]) * 100 < percent &&\n state.getValuePercent(state.values[1]) * 100 > percent;\n }\n\n return (\n <div\n key={`track-mark-${index}`}\n className={classNames('ndl-track-mark', {\n 'ndl-on-active-track': isFilled,\n })}\n style={{\n left: `${((index + 1) / markNo) * 100}%`,\n }}\n />\n );\n })}\n </div>\n );\n}\n\nfunction Thumb(props: {\n index: number;\n state: SliderState;\n // TODO v5: decide if this naming is okay, or change it\n // eslint-disable-next-line @typescript-eslint/naming-convention\n showValues?: boolean;\n trackRef: React.RefObject<HTMLDivElement>;\n inputForwardedProps: HtmlAttributes<'input'>;\n}) {\n const { state, trackRef, index, inputForwardedProps } = props;\n const inputRef = React.useRef(null);\n const { thumbProps, inputProps, isDragging } = useSliderThumb(\n {\n index,\n inputRef,\n name: 'slider-thumb',\n trackRef,\n },\n state,\n );\n\n const { focusProps, isFocusVisible } = useFocusRing();\n\n /**\n * Solve issue with:\n * Warning: Received NaN for the `value` attribute. If this is expected, cast the value to a string.\n * Receiving NaN for other attributes also, like `max`. Waiting for a fix in react-aria.\n * @see https://github.com/adobe/react-spectrum/issues/5859\n * @see https://github.com/adobe/react-spectrum/pull/5861\n */\n const mergedProps = mergeProps(\n inputProps,\n focusProps,\n // Omitting aria-valuetext double announcements, unless explicitly provided\n { 'aria-valuetext': '' },\n inputForwardedProps,\n );\n const value =\n mergedProps.value !== undefined || mergedProps.value === 0\n ? mergedProps.value\n : '';\n\n return (\n <Tooltip\n isDisabled={props.showValues !== true}\n isOpen={isDragging || undefined}\n placement=\"top\"\n type=\"simple\"\n >\n <Tooltip.Trigger hasButtonWrapper>\n <div\n {...thumbProps}\n className={classNames('ndl-thumb', {\n 'ndl-focus': isFocusVisible,\n 'ndl-is-dragging': isDragging,\n })}\n >\n <VisuallyHidden>\n <input ref={inputRef} {...mergedProps} />\n </VisuallyHidden>\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>{value}</Tooltip.Content>\n </Tooltip>\n );\n}\n"]}
@@ -52,8 +52,8 @@ const Component = () => {
52
52
  const [inputValue, setInputValue] = (0, react_2.useState)(String(INITIAL_VALUE));
53
53
  const { error, isValid } = getValidationError(inputValue);
54
54
  const hasError = !isValid;
55
- const handleInputChange = (0, react_2.useCallback)((e) => {
56
- const newInputValue = e.target.value;
55
+ const handleInputChange = (0, react_2.useCallback)((event) => {
56
+ const newInputValue = event.target.value;
57
57
  setInputValue(newInputValue);
58
58
  if (isValid) {
59
59
  setValue(Number(newInputValue));
@@ -1 +1 @@
1
- {"version":3,"file":"slider-single-controlled.story.js","sourceRoot":"","sources":["../../../../src/slider/stories/slider-single-controlled.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4CAAqD;AACrD,iCAA8C;AAE9C,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,kBAAkB,GAAG,CACzB,KAAa,EAC4D,EAAE;IAC3E,MAAM,OAAO,GAAG,KAAK,CAA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AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { Slider, TextInput } from '@neo4j-ndl/react';\nimport { useCallback, useState } from 'react';\n\nconst MIN_VALUE = 0;\nconst MAX_VALUE = 100;\nconst STEP = 5;\nconst INITIAL_VALUE = 50;\n\nconst getValidationError = (\n input: string,\n): { error: string; isValid: false } | { error: undefined; isValid: true } => {\n const trimmed = input.trim();\n\n if (!trimmed) {\n return { error: 'Value is required', isValid: false };\n }\n\n const numValue = Number(trimmed);\n if (isNaN(numValue)) {\n return { error: 'Please enter a valid number', isValid: false };\n }\n\n if (!Number.isInteger(numValue)) {\n return { error: 'Please enter a whole number', isValid: false };\n }\n\n if (numValue < MIN_VALUE) {\n return { error: `Value must be at least ${MIN_VALUE}`, isValid: false };\n }\n\n if (numValue > MAX_VALUE) {\n return { error: `Value must be at most ${MAX_VALUE}`, isValid: false };\n }\n\n return { error: undefined, isValid: true };\n};\n\nconst Component = () => {\n const [value, setValue] = useState(INITIAL_VALUE);\n const [inputValue, setInputValue] = useState(String(INITIAL_VALUE));\n const { error, isValid } = getValidationError(inputValue);\n const hasError = !isValid;\n\n const handleInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const newInputValue = e.target.value;\n setInputValue(newInputValue);\n\n if (isValid) {\n setValue(Number(newInputValue));\n }\n },\n [setInputValue, setValue, isValid],\n );\n\n const handleSliderChange = useCallback(\n (newValue: number) => {\n setValue(newValue);\n setInputValue(String(newValue));\n },\n [setInputValue, setValue],\n );\n\n return (\n <div className=\"n-flex n-flex-col n-gap-token-16\">\n <TextInput\n label=\"Slider value\"\n helpText={`Enter a value between ${MIN_VALUE} and ${MAX_VALUE}`}\n isRequired\n errorText={error}\n htmlAttributes={{\n max: MAX_VALUE,\n min: MIN_VALUE,\n step: STEP,\n type: 'number',\n }}\n value={inputValue}\n onChange={handleInputChange}\n />\n\n <Slider\n type=\"single\"\n value={value}\n onChange={handleSliderChange}\n minValue={MIN_VALUE}\n maxValue={MAX_VALUE}\n step={STEP}\n showSteps\n showValues\n isDisabled={hasError}\n inputProps={{\n 'aria-valuetext': `${value} out of ${MAX_VALUE}`,\n }}\n />\n </div>\n );\n};\n\nexport default Component;\n"]}
1
+ {"version":3,"file":"slider-single-controlled.story.js","sourceRoot":"","sources":["../../../../src/slider/stories/slider-single-controlled.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4CAAqD;AACrD,iCAA8C;AAE9C,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,kBAAkB,GAAG,CACzB,KAAa,EAC4D,EAAE;IAC3E,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,KAAK,EAAE,6BAA6B,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClE,CAAC;IAED,IA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GAAG,IAAA,mBAAW,EACpC,CAAC,QAAgB,EAAE,EAAE;QACnB,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClC,CAAC,EACD,CAAC,aAAa,EAAE,QAAQ,CAAC,CAC1B,CAAC;IAEF,OAAO,CACL,iCAAK,SAAS,EAAC,kCAAkC,aAC/C,uBAAC,iBAAS,IACR,KAAK,EAAC,cAAc,EACpB,QAAQ,EAAE,yBAAyB,SAAS,QAAQ,SAAS,EAAE,EAC/D,UAAU,QACV,SAAS,EAAE,KAAK,EAChB,cAAc,EAAE;oBACd,GAAG,EAAE,SAAS;oBACd,GAAG,EAAE,SAAS;oBACd,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,QAAQ;iBACf,EACD,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,iBAAiB,GAC3B,EAEF,uBAAC,cAAM,IACL,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,SAAS,EACnB,IAAI,EAAE,IAAI,EACV,SAAS,QACT,UAAU,QACV,UAAU,EAAE,QAAQ,EACpB,UAAU,EAAE;oBACV,gBAAgB,EAAE,GAAG,KAAK,WAAW,SAAS,EAAE;iBACjD,GACD,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { Slider, TextInput } from '@neo4j-ndl/react';\nimport { useCallback, useState } from 'react';\n\nconst MIN_VALUE = 0;\nconst MAX_VALUE = 100;\nconst STEP = 5;\nconst INITIAL_VALUE = 50;\n\nconst getValidationError = (\n input: string,\n): { error: string; isValid: false } | { error: undefined; isValid: true } => {\n const trimmed = input.trim();\n\n if (!trimmed) {\n return { error: 'Value is required', isValid: false };\n }\n\n const numValue = Number(trimmed);\n if (isNaN(numValue)) {\n return { error: 'Please enter a valid number', isValid: false };\n }\n\n if (!Number.isInteger(numValue)) {\n return { error: 'Please enter a whole number', isValid: false };\n }\n\n if (numValue < MIN_VALUE) {\n return { error: `Value must be at least ${MIN_VALUE}`, isValid: false };\n }\n\n if (numValue > MAX_VALUE) {\n return { error: `Value must be at most ${MAX_VALUE}`, isValid: false };\n }\n\n return { error: undefined, isValid: true };\n};\n\nconst Component = () => {\n const [value, setValue] = useState(INITIAL_VALUE);\n const [inputValue, setInputValue] = useState(String(INITIAL_VALUE));\n const { error, isValid } = getValidationError(inputValue);\n const hasError = !isValid;\n\n const handleInputChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const newInputValue = event.target.value;\n setInputValue(newInputValue);\n\n if (isValid) {\n setValue(Number(newInputValue));\n }\n },\n [setInputValue, setValue, isValid],\n );\n\n const handleSliderChange = useCallback(\n (newValue: number) => {\n setValue(newValue);\n setInputValue(String(newValue));\n },\n [setInputValue, setValue],\n );\n\n return (\n <div className=\"n-flex n-flex-col n-gap-token-16\">\n <TextInput\n label=\"Slider value\"\n helpText={`Enter a value between ${MIN_VALUE} and ${MAX_VALUE}`}\n isRequired\n errorText={error}\n htmlAttributes={{\n max: MAX_VALUE,\n min: MIN_VALUE,\n step: STEP,\n type: 'number',\n }}\n value={inputValue}\n onChange={handleInputChange}\n />\n\n <Slider\n type=\"single\"\n value={value}\n onChange={handleSliderChange}\n minValue={MIN_VALUE}\n maxValue={MAX_VALUE}\n step={STEP}\n showSteps\n showValues\n isDisabled={hasError}\n inputProps={{\n 'aria-valuetext': `${value} out of ${MAX_VALUE}`,\n }}\n />\n </div>\n );\n};\n\nexport default Component;\n"]}
@@ -206,12 +206,12 @@ const SpotlightComponent = (_a) => {
206
206
  headerId,
207
207
  setDescriptionId,
208
208
  setHeaderId,
209
- }, children: [hasOverlay === true && ((0, jsx_runtime_1.jsx)(react_1.FloatingOverlay, { className: "ndl-spotlight-overlay ndl-spotlight-overlay-top", onPointerDown: (e) => {
210
- e.stopPropagation();
211
- e.preventDefault();
212
- }, onTouchStart: (e) => {
213
- e.stopPropagation();
214
- e.preventDefault();
209
+ }, children: [hasOverlay === true && ((0, jsx_runtime_1.jsx)(react_1.FloatingOverlay, { className: "ndl-spotlight-overlay ndl-spotlight-overlay-top", onPointerDown: (event) => {
210
+ event.stopPropagation();
211
+ event.preventDefault();
212
+ }, onTouchStart: (event) => {
213
+ event.stopPropagation();
214
+ event.preventDefault();
215
215
  } })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: mergedRef, className: classes, style: Object.assign(Object.assign(Object.assign({}, spotlight.floatingStyles), spotlight.transitionStyles), style) }, spotlight.getFloatingProps(Object.assign(Object.assign({}, htmlAttributes), { 'aria-describedby': ariaDescribedBy, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-modal': 'true' })), restProps, { children: [(0, jsx_runtime_1.jsx)("div", { children: children }), (Boolean(beforeActions) || Boolean(actions)) && ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-spotlight-footer", children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "body-medium", children: beforeActions }), Boolean(actions) && ((0, jsx_runtime_1.jsx)("div", { className: "ndl-spotlight-actions", ref: actionsRef, children: actions }))] }))] }))] }) }) }));
216
216
  };
217
217
  SpotlightComponent.displayName = 'Spotlight';
@@ -1 +1 @@
1
- {"version":3,"file":"Spotlight.js","sourceRo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KAAK,KAEN,SAAS,CAAC,gBAAgB,iCACzB,cAAc,KACjB,kBAAkB,EAAE,eAAe,EACnC,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,YAAY,EAAE,MAAM,IACpB,EACE,SAAS,eAEb,0CAAM,QAAQ,GAAO,EACpB,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAC/C,iCAAK,SAAS,EAAC,sBAAsB,aACnC,uBAAC,uBAAU,IAAC,OAAO,EAAC,aAAa,YAAE,aAAa,GAAc,EAC7D,OAAO,CAAC,OAAO,CAAC,IAAI,CACnB,gCAAK,SAAS,EAAC,uBAAuB,EAAC,GAAG,EAAE,UAAU,YACnD,OAAO,GACJ,CACP,IACG,CACP,KACG,IAC4B,GACf,GACR,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAkB,CAAC,WAAW,GAAG,WAAW,CAAC;AAE7C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAClD,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,eAAe;IACvB,WAAW,EAAE,oBAAoB;IACjC,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;CACtB,CAAC,CAAC;AAEM,8BAAS","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, {\n createContext,\n useContext,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { placementTranslation, type Popover } from '../popover';\nimport { StatusLabel } from '../status-label';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport { useSpotlightContext } from './SpotlightProvider';\n\n// Local instance context to pass stable ARIA ids to subcomponents\ntype SpotlightInstanceContextType = {\n headerId?: string;\n descriptionId?: string;\n setHeaderId?: (id: string | undefined) => void;\n setDescriptionId?: (id: string | undefined) => void;\n};\n\nconst SpotlightInstanceContext =\n createContext<SpotlightInstanceContextType | null>(null);\n\nconst useSpotlightInstance = (): SpotlightInstanceContextType => {\n const ctx = useContext(SpotlightInstanceContext);\n if (ctx === null) {\n throw new Error(\n 'Spotlight subcomponents must be used within <Spotlight />',\n );\n }\n return ctx;\n};\nimport { useSpotlight } from './use-spotlight';\n\ntype SpotlightHeaderProps = {\n /** The spotlight header content */\n children?: React.ReactNode;\n};\n\nconst SpotlightHeader = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightHeaderProps>) => {\n const classes = classNames('ndl-spotlight-header', className);\n const { headerId, setHeaderId } = useSpotlightInstance();\n const Component: React.ElementType = as ?? 'div';\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n setHeaderId?.(htmlAttributes?.id);\n }\n }, [setHeaderId, htmlAttributes?.id]);\n\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"title-4\"\n {...restProps}\n htmlAttributes={{ ...htmlAttributes, id: headerId }}\n >\n {children}\n </Typography>\n );\n};\n\nSpotlightHeader.displayName = 'Spotlight.Header';\n\ntype SpotlightBodyProps = {\n /** The spotlight body content */\n children?: React.ReactNode;\n};\n\nconst SpotlightBody = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightBodyProps>) => {\n const classes = classNames('ndl-spotlight-body', className);\n const { descriptionId, setDescriptionId } = useSpotlightInstance();\n const Component: React.ElementType = as ?? 'div';\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n setDescriptionId?.(htmlAttributes?.id);\n }\n }, [setDescriptionId, htmlAttributes?.id]);\n\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"body-medium\"\n {...restProps}\n htmlAttributes={{ ...htmlAttributes, id: descriptionId }}\n >\n {children}\n </Typography>\n );\n};\n\nSpotlightBody.displayName = 'Spotlight.Body';\n\ntype SpotlightLabelProps = Omit<\n React.ComponentProps<typeof StatusLabel>,\n 'color' | 'fill'\n>;\n\nconst SpotlightLabel = <T extends React.ElementType = 'div'>({\n className,\n children,\n hasIcon,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightLabelProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-label', className);\n\n return (\n <StatusLabel\n fill=\"semi-filled\"\n variant=\"discovery\"\n hasIcon={hasIcon}\n ref={ref}\n as={as}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </StatusLabel>\n );\n};\n\nSpotlightLabel.displayName = 'Spotlight.Label';\n\ntype SpotlightImageProps = {\n /** A string that represents the URL of the image */\n src: string;\n /** A string that represents the alt text of the image */\n alt: string;\n};\n\nconst SpotlightImage = ({\n src,\n alt,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'img', SpotlightImageProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-image n-body-medium', className);\n\n return (\n <img\n src={src}\n alt={alt}\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n />\n );\n};\n\nSpotlightImage.displayName = 'Spotlight.Image';\n\ntype SpotlightIconWrapperProps = {\n /** Content displayed in the icon wrapper */\n children?: React.ReactNode;\n};\n\nconst SpotlightIconWrapper = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightIconWrapperProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-icon-wrapper', className);\n const Component = as ?? 'div';\n\n return (\n <Component\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n );\n};\n\nSpotlightIconWrapper.displayName = 'Spotlight.IconWrapper';\n\nexport type SpotlightCloseAction = 'clickOutside' | 'escapeKeyDown';\n\nexport type SpotlightProps = {\n /** The id of the `SpotlightTarget` that this `Spotlight` should be rendered next to */\n target: string;\n /** The actions to be displayed in the Spotlight. Should only be TextButton or OutlinedButton components. */\n actions?: React.ReactNode;\n /** A ReactNode that can be put in the left corner of the Spotlight (left of action buttons). It should be used to display the current step if you have a multi-step tour */\n beforeActions?: React.ReactNode;\n /** A callback function that is called if the Spotlight is closed by either clicking outside the Spotlight, or by pressing the Escape key. The function has one argument: action (string that can be either \"clickOutside\" or \"escapeKeyDown\") */\n onClose?: (action: SpotlightCloseAction) => void;\n /** Callback function called when the spotlight is opened */\n onOpen?: () => void;\n /** Children should be Spotlight subcomponents */\n children?: React.ReactNode;\n} & Pick<\n React.ComponentProps<typeof Popover>,\n 'placement' | 'initialFocus' | 'closeOnClickOutside'\n>;\n\nconst SpotlightComponent = ({\n target,\n beforeActions,\n actions,\n initialFocus,\n onClose,\n placement,\n children,\n className,\n style,\n htmlAttributes,\n closeOnClickOutside = false,\n onOpen,\n ref,\n ...restProps\n}: CommonProps<'div', SpotlightProps>) => {\n const generatedHeaderId = useId();\n const generatedDescriptionId = useId();\n const [targetElement, setTargetElement] = useState<HTMLElement | null>(null);\n const actionsRef = useRef<HTMLDivElement | null>(null);\n\n const {\n hasOverlay,\n isActiveSpotlight,\n isOpen,\n registeredTargets,\n setActiveSpotlight,\n setIsOpen,\n } = useSpotlightContext();\n\n const [headerId, setHeaderId] = useState<string | undefined>(\n generatedHeaderId,\n );\n const [descriptionId, setDescriptionId] = useState<string | undefined>(\n generatedDescriptionId,\n );\n\n // Determine if a Header child exists\n const hasHeaderChild = React.useMemo(() => {\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === SpotlightHeader,\n );\n }, [children]);\n\n // Source ARIA from htmlAttributes\n const ariaLabel = htmlAttributes?.['aria-label'];\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? headerId : undefined);\n const ariaDescribedBy = htmlAttributes?.['aria-describedby'] ?? descriptionId;\n\n if (ariaLabel === undefined && !ariaLabelledBy) {\n console.warn(\n 'The Spotlight is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n const onOpenChange = (isOpen: boolean, event?: Event) => {\n if (!isOpen) {\n if (event instanceof PointerEvent) {\n onClose?.('clickOutside');\n } else if (event instanceof KeyboardEvent) {\n onClose?.('escapeKeyDown');\n }\n setActiveSpotlight(null);\n setIsOpen(false);\n }\n };\n\n const spotlight = useSpotlight({\n anchorElement: targetElement,\n closeOnClickOutside,\n initialFocus,\n isOpen: isActiveSpotlight(target) && isOpen && !!targetElement,\n onOpenChange,\n placement: placement ? placementTranslation[placement] : undefined,\n });\n\n const mergedRef = useMergeRefs([spotlight.refs.setFloating, ref]);\n\n const { themeClassName } = useNeedleTheme();\n const classes = classNames('ndl-spotlight', themeClassName, className);\n\n useEffect(() => {\n setTargetElement(registeredTargets[target]?.current);\n }, [target, registeredTargets]);\n\n useEffect(() => {\n if (isOpen && isActiveSpotlight(target)) {\n onOpen?.();\n }\n }, [isOpen, onOpen, isActiveSpotlight, target]);\n\n const findInitialFocus = () => {\n if (spotlight.initialFocus !== undefined) {\n return spotlight.initialFocus;\n }\n if (!actionsRef.current) {\n return undefined;\n }\n const focusableEls = actionsRef.current.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n return focusableEls.length - 1;\n };\n\n if (!spotlight.context.open) {\n return null;\n }\n\n return (\n <FloatingPortal>\n <FloatingFocusManager\n context={spotlight.context}\n modal={true}\n initialFocus={findInitialFocus()}\n >\n <SpotlightInstanceContext.Provider\n value={{\n descriptionId,\n headerId,\n setDescriptionId,\n setHeaderId,\n }}\n >\n {hasOverlay === true && (\n <FloatingOverlay\n className=\"ndl-spotlight-overlay ndl-spotlight-overlay-top\"\n onPointerDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n onTouchStart={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n />\n )}\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...spotlight.floatingStyles,\n ...spotlight.transitionStyles,\n ...style,\n }}\n {...spotlight.getFloatingProps({\n ...htmlAttributes,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-modal': 'true',\n })}\n {...restProps}\n >\n <div>{children}</div>\n {(Boolean(beforeActions) || Boolean(actions)) && (\n <div className=\"ndl-spotlight-footer\">\n <Typography variant=\"body-medium\">{beforeActions}</Typography>\n {Boolean(actions) && (\n <div className=\"ndl-spotlight-actions\" ref={actionsRef}>\n {actions}\n </div>\n )}\n </div>\n )}\n </div>\n </SpotlightInstanceContext.Provider>\n </FloatingFocusManager>\n </FloatingPortal>\n );\n};\n\nSpotlightComponent.displayName = 'Spotlight';\n\nconst Spotlight = Object.assign(SpotlightComponent, {\n Body: SpotlightBody,\n Header: SpotlightHeader,\n IconWrapper: SpotlightIconWrapper,\n Image: SpotlightImage,\n Label: SpotlightLabel,\n});\n\nexport { Spotlight };\n"]}
1
+ {"version":3,"file":"Spotlight.js","sourceRoot":"","sources":["../../../src/spotlight/Spotlight.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,YAAY,EAAE,MAAM,IACpB,EACE,SAAS,eAEb,0CAAM,QAAQ,GAAO,EACpB,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAC/C,iCAAK,SAAS,EAAC,sBAAsB,aACnC,uBAAC,uBAAU,IAAC,OAAO,EAAC,aAAa,YAAE,aAAa,GAAc,EAC7D,OAAO,CAAC,OAAO,CAAC,IAAI,CACnB,gCAAK,SAAS,EAAC,uBAAuB,EAAC,GAAG,EAAE,UAAU,YACnD,OAAO,GACJ,CACP,IACG,CACP,KACG,IAC4B,GACf,GACR,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAkB,CAAC,WAAW,GAAG,WAAW,CAAC;AAE7C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAClD,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,eAAe;IACvB,WAAW,EAAE,oBAAoB;IACjC,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;CACtB,CAAC,CAAC;AAEM,8BAAS","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, {\n createContext,\n useContext,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { placementTranslation, type Popover } from '../popover';\nimport { StatusLabel } from '../status-label';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport { useSpotlightContext } from './SpotlightProvider';\n\n// Local instance context to pass stable ARIA ids to subcomponents\ntype SpotlightInstanceContextType = {\n headerId?: string;\n descriptionId?: string;\n setHeaderId?: (id: string | undefined) => void;\n setDescriptionId?: (id: string | undefined) => void;\n};\n\nconst SpotlightInstanceContext =\n createContext<SpotlightInstanceContextType | null>(null);\n\nconst useSpotlightInstance = (): SpotlightInstanceContextType => {\n const ctx = useContext(SpotlightInstanceContext);\n if (ctx === null) {\n throw new Error(\n 'Spotlight subcomponents must be used within <Spotlight />',\n );\n }\n return ctx;\n};\nimport { useSpotlight } from './use-spotlight';\n\ntype SpotlightHeaderProps = {\n /** The spotlight header content */\n children?: React.ReactNode;\n};\n\nconst SpotlightHeader = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightHeaderProps>) => {\n const classes = classNames('ndl-spotlight-header', className);\n const { headerId, setHeaderId } = useSpotlightInstance();\n const Component: React.ElementType = as ?? 'div';\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n setHeaderId?.(htmlAttributes?.id);\n }\n }, [setHeaderId, htmlAttributes?.id]);\n\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"title-4\"\n {...restProps}\n htmlAttributes={{ ...htmlAttributes, id: headerId }}\n >\n {children}\n </Typography>\n );\n};\n\nSpotlightHeader.displayName = 'Spotlight.Header';\n\ntype SpotlightBodyProps = {\n /** The spotlight body content */\n children?: React.ReactNode;\n};\n\nconst SpotlightBody = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightBodyProps>) => {\n const classes = classNames('ndl-spotlight-body', className);\n const { descriptionId, setDescriptionId } = useSpotlightInstance();\n const Component: React.ElementType = as ?? 'div';\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n setDescriptionId?.(htmlAttributes?.id);\n }\n }, [setDescriptionId, htmlAttributes?.id]);\n\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"body-medium\"\n {...restProps}\n htmlAttributes={{ ...htmlAttributes, id: descriptionId }}\n >\n {children}\n </Typography>\n );\n};\n\nSpotlightBody.displayName = 'Spotlight.Body';\n\ntype SpotlightLabelProps = Omit<\n React.ComponentProps<typeof StatusLabel>,\n 'color' | 'fill'\n>;\n\nconst SpotlightLabel = <T extends React.ElementType = 'div'>({\n className,\n children,\n hasIcon,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightLabelProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-label', className);\n\n return (\n <StatusLabel\n fill=\"semi-filled\"\n variant=\"discovery\"\n hasIcon={hasIcon}\n ref={ref}\n as={as}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </StatusLabel>\n );\n};\n\nSpotlightLabel.displayName = 'Spotlight.Label';\n\ntype SpotlightImageProps = {\n /** A string that represents the URL of the image */\n src: string;\n /** A string that represents the alt text of the image */\n alt: string;\n};\n\nconst SpotlightImage = ({\n src,\n alt,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'img', SpotlightImageProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-image n-body-medium', className);\n\n return (\n <img\n src={src}\n alt={alt}\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n />\n );\n};\n\nSpotlightImage.displayName = 'Spotlight.Image';\n\ntype SpotlightIconWrapperProps = {\n /** Content displayed in the icon wrapper */\n children?: React.ReactNode;\n};\n\nconst SpotlightIconWrapper = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightIconWrapperProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-icon-wrapper', className);\n const Component = as ?? 'div';\n\n return (\n <Component\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n );\n};\n\nSpotlightIconWrapper.displayName = 'Spotlight.IconWrapper';\n\nexport type SpotlightCloseAction = 'clickOutside' | 'escapeKeyDown';\n\nexport type SpotlightProps = {\n /** The id of the `SpotlightTarget` that this `Spotlight` should be rendered next to */\n target: string;\n /** The actions to be displayed in the Spotlight. Should only be TextButton or OutlinedButton components. */\n actions?: React.ReactNode;\n /** A ReactNode that can be put in the left corner of the Spotlight (left of action buttons). It should be used to display the current step if you have a multi-step tour */\n beforeActions?: React.ReactNode;\n /** A callback function that is called if the Spotlight is closed by either clicking outside the Spotlight, or by pressing the Escape key. The function has one argument: action (string that can be either \"clickOutside\" or \"escapeKeyDown\") */\n onClose?: (action: SpotlightCloseAction) => void;\n /** Callback function called when the spotlight is opened */\n onOpen?: () => void;\n /** Children should be Spotlight subcomponents */\n children?: React.ReactNode;\n} & Pick<\n React.ComponentProps<typeof Popover>,\n 'placement' | 'initialFocus' | 'closeOnClickOutside'\n>;\n\nconst SpotlightComponent = ({\n target,\n beforeActions,\n actions,\n initialFocus,\n onClose,\n placement,\n children,\n className,\n style,\n htmlAttributes,\n closeOnClickOutside = false,\n onOpen,\n ref,\n ...restProps\n}: CommonProps<'div', SpotlightProps>) => {\n const generatedHeaderId = useId();\n const generatedDescriptionId = useId();\n const [targetElement, setTargetElement] = useState<HTMLElement | null>(null);\n const actionsRef = useRef<HTMLDivElement | null>(null);\n\n const {\n hasOverlay,\n isActiveSpotlight,\n isOpen,\n registeredTargets,\n setActiveSpotlight,\n setIsOpen,\n } = useSpotlightContext();\n\n const [headerId, setHeaderId] = useState<string | undefined>(\n generatedHeaderId,\n );\n const [descriptionId, setDescriptionId] = useState<string | undefined>(\n generatedDescriptionId,\n );\n\n // Determine if a Header child exists\n const hasHeaderChild = React.useMemo(() => {\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === SpotlightHeader,\n );\n }, [children]);\n\n // Source ARIA from htmlAttributes\n const ariaLabel = htmlAttributes?.['aria-label'];\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? headerId : undefined);\n const ariaDescribedBy = htmlAttributes?.['aria-describedby'] ?? descriptionId;\n\n if (ariaLabel === undefined && !ariaLabelledBy) {\n console.warn(\n 'The Spotlight is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n const onOpenChange = (isOpen: boolean, event?: Event) => {\n if (!isOpen) {\n if (event instanceof PointerEvent) {\n onClose?.('clickOutside');\n } else if (event instanceof KeyboardEvent) {\n onClose?.('escapeKeyDown');\n }\n setActiveSpotlight(null);\n setIsOpen(false);\n }\n };\n\n const spotlight = useSpotlight({\n anchorElement: targetElement,\n closeOnClickOutside,\n initialFocus,\n isOpen: isActiveSpotlight(target) && isOpen && !!targetElement,\n onOpenChange,\n placement: placement ? placementTranslation[placement] : undefined,\n });\n\n const mergedRef = useMergeRefs([spotlight.refs.setFloating, ref]);\n\n const { themeClassName } = useNeedleTheme();\n const classes = classNames('ndl-spotlight', themeClassName, className);\n\n useEffect(() => {\n setTargetElement(registeredTargets[target]?.current);\n }, [target, registeredTargets]);\n\n useEffect(() => {\n if (isOpen && isActiveSpotlight(target)) {\n onOpen?.();\n }\n }, [isOpen, onOpen, isActiveSpotlight, target]);\n\n const findInitialFocus = () => {\n if (spotlight.initialFocus !== undefined) {\n return spotlight.initialFocus;\n }\n if (!actionsRef.current) {\n return undefined;\n }\n const focusableEls = actionsRef.current.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n return focusableEls.length - 1;\n };\n\n if (!spotlight.context.open) {\n return null;\n }\n\n return (\n <FloatingPortal>\n <FloatingFocusManager\n context={spotlight.context}\n modal={true}\n initialFocus={findInitialFocus()}\n >\n <SpotlightInstanceContext.Provider\n value={{\n descriptionId,\n headerId,\n setDescriptionId,\n setHeaderId,\n }}\n >\n {hasOverlay === true && (\n <FloatingOverlay\n className=\"ndl-spotlight-overlay ndl-spotlight-overlay-top\"\n onPointerDown={(event) => {\n event.stopPropagation();\n event.preventDefault();\n }}\n onTouchStart={(event) => {\n event.stopPropagation();\n event.preventDefault();\n }}\n />\n )}\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...spotlight.floatingStyles,\n ...spotlight.transitionStyles,\n ...style,\n }}\n {...spotlight.getFloatingProps({\n ...htmlAttributes,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-modal': 'true',\n })}\n {...restProps}\n >\n <div>{children}</div>\n {(Boolean(beforeActions) || Boolean(actions)) && (\n <div className=\"ndl-spotlight-footer\">\n <Typography variant=\"body-medium\">{beforeActions}</Typography>\n {Boolean(actions) && (\n <div className=\"ndl-spotlight-actions\" ref={actionsRef}>\n {actions}\n </div>\n )}\n </div>\n )}\n </div>\n </SpotlightInstanceContext.Provider>\n </FloatingFocusManager>\n </FloatingPortal>\n );\n};\n\nSpotlightComponent.displayName = 'Spotlight';\n\nconst Spotlight = Object.assign(SpotlightComponent, {\n Body: SpotlightBody,\n Header: SpotlightHeader,\n IconWrapper: SpotlightIconWrapper,\n Image: SpotlightImage,\n Label: SpotlightLabel,\n});\n\nexport { Spotlight };\n"]}
@@ -96,11 +96,11 @@ const SpotlightProvider = ({ children, hasOverlay = true, isOverlayTransparent =
96
96
  return {};
97
97
  }
98
98
  const { left, top, width, height } = targetRect;
99
- const x = Math.max(0, left);
100
- const y = Math.max(0, top);
101
- const w = Math.max(0, width);
102
- const h = Math.max(0, height);
103
- const r = Math.max(0, Math.min(getHoleRadius(), Math.min(w, h) / 2));
99
+ const xPos = Math.max(0, left);
100
+ const yPos = Math.max(0, top);
101
+ const holeWidth = Math.max(0, width);
102
+ const holeHeight = Math.max(0, height);
103
+ const radius = Math.max(0, Math.min(getHoleRadius(), Math.min(holeWidth, holeHeight) / 2));
104
104
  const vw = window.innerWidth;
105
105
  const vh = window.innerHeight;
106
106
  // SVG mask: white = visible overlay, black = hole (transparent)
@@ -109,7 +109,7 @@ const SpotlightProvider = ({ children, hasOverlay = true, isOverlayTransparent =
109
109
  <defs>
110
110
  <mask id="spotlightMask" maskUnits="userSpaceOnUse">
111
111
  <rect x="0" y="0" width="${vw}" height="${vh}" fill="white"/>
112
- <rect x="${x}" y="${y}" width="${w}" height="${h}" rx="${r}" ry="${r}" fill="black"/>
112
+ <rect x="${xPos}" y="${yPos}" width="${holeWidth}" height="${holeHeight}" rx="${radius}" ry="${radius}" fill="black"/>
113
113
  </mask>
114
114
  </defs>
115
115
  <rect x="0" y="0" width="${vw}" height="${vh}" fill="black" mask="url(#spotlightMask)"/>
@@ -1 +1 @@
1
- {"version":3,"file":"SpotlightProvider.js","sourceRoot":"","sources":["../../../src/spotlight/SpotlightProvider.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAAqE;AACrE,4DAAoC;AAEpC,iCAOe;AA8Bf,MAAM,gBAAgB,GAAG,IAAA,qBAAa,EAA8B,IAAI,CAAC,CAAC;AAEnE,MAAM,iBAAiB,GAAG,CAAC,EAChC,QAAQ,EACR,UAAU,GAAG,IAAI,EACjB,oBAAoB,GAAG,KAAK,GACL,EAAE,EAAE;IAC3B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAgB,IAAI,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IACrD,MAAM,CAAC,OAAO,EAAE,UAAU,C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,OAAO,CACL,wBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,aAC3C,UAAU,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,IAAI,CAC1C,uBAAC,sBAAc,cACb,uBAAC,uBAAe,IACd,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,YAAY,EAAE,iBACT,uBAAuB,GACnC,GACa,CAClB,EACA,QAAQ,IACiB,CAC7B,CAAC;AACJ,CAAC,CAAC;AA1KW,QAAA,iBAAiB,qBA0K5B;AAEK,MAAM,mBAAmB,GAAG,GAAyB,EAAE;IAC5D,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,gBAAgB,CAAC,CAAC;IAE7C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,mBAAmB,uBAU9B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { FloatingOverlay, FloatingPortal } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ntype SpotlightProviderProps = {\n /** The app/screen content to wrap */\n children: React.ReactNode;\n /** A boolean that decides if there is a gray overlay when a spotlight is open. */\n hasOverlay?: boolean;\n /** If the overlay should be transparent */\n isOverlayTransparent?: boolean;\n};\n\ntype SpotlightContextType = {\n /** A boolean that indicates if a spotlight is open */\n isOpen: boolean;\n /** A function that can be used to close or open the spotlight */\n setIsOpen: (arg: boolean) => void;\n /** A function that can be used to check if a spotlight is active. It takes a target id as an argument */\n isActiveSpotlight: (target: string) => boolean;\n /** A function that can be used to set a spotlight as active. It takes a target id as an argument, or null to clear the active spotlight */\n setActiveSpotlight: (target: string | null) => void;\n /** A function that can be used to register a target. It takes a target id, and a ref to the target element as arguments */\n registerTarget: (id: string, ref: React.RefObject<HTMLElement>) => void;\n /** A function that can be used to unregister a target. It takes a target id as an argument */\n unregisterTarget: (id: string) => void;\n /** An object that contains all registered targets. The keys are the target ids, and the values are the refs to the target elements */\n registeredTargets: Record<string, React.RefObject<HTMLElement>>;\n /** A boolean that decides if there is a gray overlay when a spotlight is open */\n hasOverlay?: boolean;\n};\n\nconst SpotlightContext = createContext<SpotlightContextType | null>(null);\n\nexport const SpotlightProvider = ({\n children,\n hasOverlay = true,\n isOverlayTransparent = false,\n}: SpotlightProviderProps) => {\n const [active, setActive] = useState<string | null>(null);\n const [isOpen, setIsOpen] = useState<boolean>(false);\n const [targets, setTargets] = useState<\n Record<string, React.RefObject<HTMLElement>>\n >({});\n const [targetRect, setTargetRect] = useState<DOMRect | null>(null);\n\n const registerTarget = useCallback(\n (id: string, ref: React.RefObject<HTMLElement>) => {\n setTargets((prev) => ({ ...prev, [id]: ref }));\n },\n [],\n );\n\n const unregisterTarget = useCallback((id: string) => {\n setTargets((prev) => {\n const newTargets = { ...prev };\n delete newTargets[id];\n return newTargets;\n });\n }, []);\n\n // Calculate target element position and size for mask\n useEffect(() => {\n if (\n active !== null &&\n targets[active] !== undefined &&\n targets[active]?.current !== null\n ) {\n const element = targets[active].current;\n const rect = element.getBoundingClientRect();\n setTargetRect(rect);\n } else {\n setTargetRect(null);\n }\n }, [active, targets]);\n\n const contextValue: SpotlightContextType = {\n hasOverlay,\n isActiveSpotlight: useCallback(\n (target: string) => target === active,\n [active],\n ),\n isOpen,\n registerTarget,\n registeredTargets: targets,\n setActiveSpotlight: useCallback(\n (target: string | null) => setActive(target),\n [],\n ),\n setIsOpen: useCallback((open: boolean) => setIsOpen(open), []),\n unregisterTarget,\n };\n\n const overlayClasses = classNames('ndl-spotlight-overlay', {\n 'ndl-spotlight-overlay-opaque': !isOverlayTransparent,\n 'ndl-spotlight-overlay-open': isOpen && active !== null,\n });\n\n const overlayRootRef = useRef<HTMLElement | null>(null);\n\n if (active !== null) {\n overlayRootRef.current = document.getElementById(active);\n }\n\n // Get the border radius from the target element\n const getHoleRadius = useCallback(() => {\n if (\n active !== null &&\n targets[active] !== undefined &&\n targets[active]?.current !== null\n ) {\n const element = targets[active].current;\n const computedStyle = window.getComputedStyle(element);\n const borderRadius = computedStyle.borderRadius;\n\n // Parse the border radius value (handle px, rem, em, etc.)\n const radiusValue = parseFloat(borderRadius);\n return isNaN(radiusValue) ? 0 : radiusValue;\n }\n return 0;\n }, [active, targets]);\n\n const getMaskStyle = () => {\n if (!targetRect || isOverlayTransparent) {\n return {};\n }\n\n const { left, top, width, height } = targetRect;\n\n const x = Math.max(0, left);\n const y = Math.max(0, top);\n const w = Math.max(0, width);\n const h = Math.max(0, height);\n const r = Math.max(0, Math.min(getHoleRadius(), Math.min(w, h) / 2));\n\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n\n // SVG mask: white = visible overlay, black = hole (transparent)\n const svg = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${vw}\" height=\"${vh}\" viewBox=\"0 0 ${vw} ${vh}\">\n <defs>\n <mask id=\"spotlightMask\" maskUnits=\"userSpaceOnUse\">\n <rect x=\"0\" y=\"0\" width=\"${vw}\" height=\"${vh}\" fill=\"white\"/>\n <rect x=\"${x}\" y=\"${y}\" width=\"${w}\" height=\"${h}\" rx=\"${r}\" ry=\"${r}\" fill=\"black\"/>\n </mask>\n </defs>\n <rect x=\"0\" y=\"0\" width=\"${vw}\" height=\"${vh}\" fill=\"black\" mask=\"url(#spotlightMask)\"/>\n </svg>`.trim();\n\n const encoded = `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;\n\n return {\n WebkitMaskImage: `url(\"${encoded}\")`,\n WebkitMaskRepeat: 'no-repeat',\n WebkitMaskSize: `${vw}px ${vh}px`,\n maskImage: `url(\"${encoded}\")`,\n maskRepeat: 'no-repeat',\n maskSize: `${vw}px ${vh}px`,\n } as React.CSSProperties;\n };\n\n /** useEffect to update the target rect, so that the mask tracks the target element */\n useEffect(() => {\n if (active === null) {\n return;\n }\n\n const el = targets[active]?.current;\n if (el === null || el === undefined) {\n return;\n }\n\n const update = () => setTargetRect(el.getBoundingClientRect());\n update();\n\n const ro = new ResizeObserver(update);\n ro.observe(el);\n\n window.addEventListener('scroll', update, true);\n window.addEventListener('resize', update);\n\n return () => {\n ro.disconnect();\n window.removeEventListener('scroll', update, true);\n window.removeEventListener('resize', update);\n };\n }, [active, targets]);\n\n return (\n <SpotlightContext.Provider value={contextValue}>\n {hasOverlay && active !== null && isOpen && (\n <FloatingPortal>\n <FloatingOverlay\n lockScroll={true}\n className={overlayClasses}\n style={getMaskStyle()}\n data-testid=\"ndl-spotlight-overlay\"\n />\n </FloatingPortal>\n )}\n {children}\n </SpotlightContext.Provider>\n );\n};\n\nexport const useSpotlightContext = (): SpotlightContextType => {\n const context = useContext(SpotlightContext);\n\n if (context === null) {\n throw new Error(\n 'Spotlight components must be wrapped in <SpotlightProvider />',\n );\n }\n\n return context;\n};\n"]}
1
+ {"version":3,"file":"SpotlightProvider.js","sourceRoot":"","sources":["../../../src/spotlight/SpotlightProvider.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAAqE;AACrE,4DAAoC;AAEpC,iCAOe;AA8Bf,MAAM,gBAAgB,GAAG,IAAA,qBAAa,EAA8B,IAAI,CAAC,CAAC;AAEnE,MAAM,iBAAiB,GAAG,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CAAC,CAAC;QAE1C,OAAO,GAAG,EAAE;YACV,EAAE,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YACnD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtB,OAAO,CACL,wBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,aAC3C,UAAU,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,IAAI,CAC1C,uBAAC,sBAAc,cACb,uBAAC,uBAAe,IACd,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,YAAY,EAAE,iBACT,uBAAuB,GACnC,GACa,CAClB,EACA,QAAQ,IACiB,CAC7B,CAAC;AACJ,CAAC,CAAC;AA7KW,QAAA,iBAAiB,qBA6K5B;AAEK,MAAM,mBAAmB,GAAG,GAAyB,EAAE;IAC5D,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,gBAAgB,CAAC,CAAC;IAE7C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,mBAAmB,uBAU9B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { FloatingOverlay, FloatingPortal } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ntype SpotlightProviderProps = {\n /** The app/screen content to wrap */\n children: React.ReactNode;\n /** A boolean that decides if there is a gray overlay when a spotlight is open. */\n hasOverlay?: boolean;\n /** If the overlay should be transparent */\n isOverlayTransparent?: boolean;\n};\n\ntype SpotlightContextType = {\n /** A boolean that indicates if a spotlight is open */\n isOpen: boolean;\n /** A function that can be used to close or open the spotlight */\n setIsOpen: (arg: boolean) => void;\n /** A function that can be used to check if a spotlight is active. It takes a target id as an argument */\n isActiveSpotlight: (target: string) => boolean;\n /** A function that can be used to set a spotlight as active. It takes a target id as an argument, or null to clear the active spotlight */\n setActiveSpotlight: (target: string | null) => void;\n /** A function that can be used to register a target. It takes a target id, and a ref to the target element as arguments */\n registerTarget: (id: string, ref: React.RefObject<HTMLElement>) => void;\n /** A function that can be used to unregister a target. It takes a target id as an argument */\n unregisterTarget: (id: string) => void;\n /** An object that contains all registered targets. The keys are the target ids, and the values are the refs to the target elements */\n registeredTargets: Record<string, React.RefObject<HTMLElement>>;\n /** A boolean that decides if there is a gray overlay when a spotlight is open */\n hasOverlay?: boolean;\n};\n\nconst SpotlightContext = createContext<SpotlightContextType | null>(null);\n\nexport const SpotlightProvider = ({\n children,\n hasOverlay = true,\n isOverlayTransparent = false,\n}: SpotlightProviderProps) => {\n const [active, setActive] = useState<string | null>(null);\n const [isOpen, setIsOpen] = useState<boolean>(false);\n const [targets, setTargets] = useState<\n Record<string, React.RefObject<HTMLElement>>\n >({});\n const [targetRect, setTargetRect] = useState<DOMRect | null>(null);\n\n const registerTarget = useCallback(\n (id: string, ref: React.RefObject<HTMLElement>) => {\n setTargets((prev) => ({ ...prev, [id]: ref }));\n },\n [],\n );\n\n const unregisterTarget = useCallback((id: string) => {\n setTargets((prev) => {\n const newTargets = { ...prev };\n delete newTargets[id];\n return newTargets;\n });\n }, []);\n\n // Calculate target element position and size for mask\n useEffect(() => {\n if (\n active !== null &&\n targets[active] !== undefined &&\n targets[active]?.current !== null\n ) {\n const element = targets[active].current;\n const rect = element.getBoundingClientRect();\n setTargetRect(rect);\n } else {\n setTargetRect(null);\n }\n }, [active, targets]);\n\n const contextValue: SpotlightContextType = {\n hasOverlay,\n isActiveSpotlight: useCallback(\n (target: string) => target === active,\n [active],\n ),\n isOpen,\n registerTarget,\n registeredTargets: targets,\n setActiveSpotlight: useCallback(\n (target: string | null) => setActive(target),\n [],\n ),\n setIsOpen: useCallback((open: boolean) => setIsOpen(open), []),\n unregisterTarget,\n };\n\n const overlayClasses = classNames('ndl-spotlight-overlay', {\n 'ndl-spotlight-overlay-opaque': !isOverlayTransparent,\n 'ndl-spotlight-overlay-open': isOpen && active !== null,\n });\n\n const overlayRootRef = useRef<HTMLElement | null>(null);\n\n if (active !== null) {\n overlayRootRef.current = document.getElementById(active);\n }\n\n // Get the border radius from the target element\n const getHoleRadius = useCallback(() => {\n if (\n active !== null &&\n targets[active] !== undefined &&\n targets[active]?.current !== null\n ) {\n const element = targets[active].current;\n const computedStyle = window.getComputedStyle(element);\n const borderRadius = computedStyle.borderRadius;\n\n // Parse the border radius value (handle px, rem, em, etc.)\n const radiusValue = parseFloat(borderRadius);\n return isNaN(radiusValue) ? 0 : radiusValue;\n }\n return 0;\n }, [active, targets]);\n\n const getMaskStyle = () => {\n if (!targetRect || isOverlayTransparent) {\n return {};\n }\n\n const { left, top, width, height } = targetRect;\n\n const xPos = Math.max(0, left);\n const yPos = Math.max(0, top);\n const holeWidth = Math.max(0, width);\n const holeHeight = Math.max(0, height);\n const radius = Math.max(\n 0,\n Math.min(getHoleRadius(), Math.min(holeWidth, holeHeight) / 2),\n );\n\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n\n // SVG mask: white = visible overlay, black = hole (transparent)\n const svg = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${vw}\" height=\"${vh}\" viewBox=\"0 0 ${vw} ${vh}\">\n <defs>\n <mask id=\"spotlightMask\" maskUnits=\"userSpaceOnUse\">\n <rect x=\"0\" y=\"0\" width=\"${vw}\" height=\"${vh}\" fill=\"white\"/>\n <rect x=\"${xPos}\" y=\"${yPos}\" width=\"${holeWidth}\" height=\"${holeHeight}\" rx=\"${radius}\" ry=\"${radius}\" fill=\"black\"/>\n </mask>\n </defs>\n <rect x=\"0\" y=\"0\" width=\"${vw}\" height=\"${vh}\" fill=\"black\" mask=\"url(#spotlightMask)\"/>\n </svg>`.trim();\n\n const encoded = `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;\n\n return {\n WebkitMaskImage: `url(\"${encoded}\")`,\n WebkitMaskRepeat: 'no-repeat',\n WebkitMaskSize: `${vw}px ${vh}px`,\n maskImage: `url(\"${encoded}\")`,\n maskRepeat: 'no-repeat',\n maskSize: `${vw}px ${vh}px`,\n } as React.CSSProperties;\n };\n\n /** useEffect to update the target rect, so that the mask tracks the target element */\n useEffect(() => {\n if (active === null) {\n return;\n }\n\n const el = targets[active]?.current;\n if (el === null || el === undefined) {\n return;\n }\n\n const update = () => setTargetRect(el.getBoundingClientRect());\n update();\n\n const ro = new ResizeObserver(update);\n ro.observe(el);\n\n window.addEventListener('scroll', update, true);\n window.addEventListener('resize', update);\n\n return () => {\n ro.disconnect();\n window.removeEventListener('scroll', update, true);\n window.removeEventListener('resize', update);\n };\n }, [active, targets]);\n\n return (\n <SpotlightContext.Provider value={contextValue}>\n {hasOverlay && active !== null && isOpen && (\n <FloatingPortal>\n <FloatingOverlay\n lockScroll={true}\n className={overlayClasses}\n style={getMaskStyle()}\n data-testid=\"ndl-spotlight-overlay\"\n />\n </FloatingPortal>\n )}\n {children}\n </SpotlightContext.Provider>\n );\n};\n\nexport const useSpotlightContext = (): SpotlightContextType => {\n const context = useContext(SpotlightContext);\n\n if (context === null) {\n throw new Error(\n 'Spotlight components must be wrapped in <SpotlightProvider />',\n );\n }\n\n return context;\n};\n"]}
@@ -104,11 +104,11 @@ const SpotlightTarget = (_a) => {
104
104
  });
105
105
  if (asChild === true && react_2.default.isValidElement(children)) {
106
106
  const child = children;
107
- const onClick = (e) => {
107
+ const onClick = (event) => {
108
108
  var _a, _b;
109
109
  if (isActive) {
110
110
  // When spotlight is active, always prevent the child's click handler
111
- e.preventDefault();
111
+ event.preventDefault();
112
112
  if (!isOpen) {
113
113
  setIsOpen(true);
114
114
  }
@@ -116,21 +116,23 @@ const SpotlightTarget = (_a) => {
116
116
  return;
117
117
  }
118
118
  // Only call the child's click handler when spotlight is not active
119
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
119
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
120
120
  };
121
- const onKeyDown = (e) => {
121
+ const onKeyDown = (event) => {
122
122
  var _a, _b;
123
- if (isActive && !isOpen && (e.code === 'Enter' || e.code === 'Space')) {
124
- e.preventDefault();
123
+ if (isActive &&
124
+ !isOpen &&
125
+ (event.code === 'Enter' || event.code === 'Space')) {
126
+ event.preventDefault();
125
127
  setIsOpen(true);
126
128
  return;
127
129
  }
128
- if (isActive && e.code === 'Escape') {
129
- e.preventDefault();
130
+ if (isActive && event.code === 'Escape') {
131
+ event.preventDefault();
130
132
  setActiveSpotlight(null);
131
133
  return;
132
134
  }
133
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
135
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(_a, event);
134
136
  };
135
137
  // IMPORTANT: do NOT force role/tabIndex here; preserves Composite semantics for the SideNavigation
136
138
  const mergedProps = Object.assign({ id,
@@ -146,22 +148,22 @@ const SpotlightTarget = (_a) => {
146
148
  const inertClasses = (0, classnames_1.default)('ndl-spotlight-target-inert', {
147
149
  'ndl-spotlight-target-inert-fit-to-children': shouldFitToChildren,
148
150
  }, className);
149
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Component, Object.assign({ role: isActive ? 'button' : undefined, id: id, ref: mergedRefs, className: classes, onClick: (e) => {
151
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Component, Object.assign({ role: isActive ? 'button' : undefined, id: id, ref: mergedRefs, className: classes, onClick: (event) => {
150
152
  if (isActive) {
151
- e.preventDefault();
152
- e.stopPropagation();
153
+ event.preventDefault();
154
+ event.stopPropagation();
153
155
  if (!isOpen) {
154
156
  setIsOpen(true);
155
157
  }
156
158
  }
157
- }, style: Object.assign({ borderRadius }, style), onKeyDown: (e) => {
159
+ }, style: Object.assign({ borderRadius }, style), onKeyDown: (event) => {
158
160
  if (isActive &&
159
161
  !isOpen &&
160
- (e.code === 'Enter' || e.code === 'Space')) {
162
+ (event.code === 'Enter' || event.code === 'Space')) {
161
163
  setIsOpen(true);
162
- e.preventDefault();
164
+ event.preventDefault();
163
165
  }
164
- else if (e.code === 'Escape' && isActive) {
166
+ else if (event.code === 'Escape' && isActive) {
165
167
  setActiveSpotlight(null);
166
168
  }
167
169
  }, tabIndex: isActive ? 0 : undefined }, (isActive && { 'aria-label': 'Open spotlight' }), restProps, htmlAttributes, { children: (0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: isActive, wrap: (children) => ((0, jsx_runtime_1.jsx)("div", { inert: true, "aria-disabled": true, className: inertClasses, children: children })), children: children }) })), (0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: isActive && isOpen, wrap: (wrapChildren) => (0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { children: wrapChildren }), children: indicator.context.open && ((0, jsx_runtime_1.jsx)("div", { className: indicator.indicatorClasses, ref: indicator.context.refs.setFloating, style: Object.assign(Object.assign({}, indicator.floatingStyles), indicator.style) })) })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"SpotlightTarget.js","sourceRoot":"","sources":["../../../src/spotlight/SpotlightTarget.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAAkE;AAClE,4DAAoC;AACpC,+CAAyC;AAGzC,0DAAsD;AACtD,2DAA0D;AAC1D,mDAIyB;AAsClB,MAAM,eAAe,GAAG,CAAC,EAesB,EAAE,EAAE;QAf1B,EAC9B,EAAE,EACF,QAAQ,GAAG,IAAI,EACf,gBAAgB,GAAG,QAAQ,EAC3B,kBAAkB,GAAG,WAAW,EAChC,YAAY,EACZ,mBAAmB,GAAG,KAAK,EAC3B,QAAQ,EACR,SAAS,EACT,cAAc,EACd,KAAK,EACL,EAAE,EACF,GAAG,EACH,OAAO,OAE6C,EADjD,SAAS,cAdkB,+KAe/B,CADa;IAEZ,MAAM,SAAS,GAAG,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,KAAK,CAAC;IAE9B,MAAM,EACJ,iBAAiB,EACjB,MAAM,EACN,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,kBAAkB,GACnB,GAAG,IAAA,uCAAmB,GAAE,CAAC;IAE1B,MAAM,WAAW,GAAG,eAAK,CAAC,MAAM,CAAc,IAAI,CAAC,CAAC;IACpD,MAAM,QAAQ,GACZ,OAAO,IAAI,eAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;QACvC,CAAC,CACG,QAGD,CAAC,GAAG;QACP,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,UAAU,GAAG,IAAA,oBAAY,EAAc;QAC3C,GAAmC;QACnC,WAA2C;QAC3C,QAA8C;KAC/C,CAAC,CAAC;IACH,IAAA,iBAAS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,+BAAe,SAAS,EAAE,YAAY,YAC7C,QAAQ,GACL,CACP,YAEA,QAAQ,GACO,IACR,EACZ,uBAAC,kCAAe,IACd,UAAU,EAAE,QAAQ,IAAI,MAAM,EAC9B,IAAI,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,uBAAC,sBAAc,cAAE,YAAY,GAAkB,YAEtE,SAAS,CAAC,OAAO,CAAC,IAAI,IAAI,CACzB,gCACE,SAAS,EAAE,SAAS,CAAC,gBAAgB,EACrC,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EACvC,KAAK,kCAAO,SAAS,CAAC,cAAc,GAAK,SAAS,CAAC,KAAK,IACxD,CACH,GACe,IACjB,CACJ,CAAC;AACJ,CAAC,CAAC;AAnNW,QAAA,eAAe,mBAmN1B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { FloatingPortal, useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useSpotlightContext } from './SpotlightProvider';\nimport {\n type IndicatorPlacement,\n type IndicatorVariant,\n useIndicator,\n} from './use-indicator';\n\ntype SpotlightTargetProps = {\n /** The id of the wrapper. This should match a `target` prop in a `Spotlight`, to indicate that this is where it should be rendered when open */\n id: string;\n /** A boolean that controls if the pulse animation should be used or not */\n hasPulse?: boolean;\n /** A string that controls the style of the indicator. It can be either \"point\" or \"border\" */\n indicatorVariant?: IndicatorVariant;\n /** A string that controls the placement of the indicator. A combination of \"middle\", \"top\", \"right\", \"bottom\" and \"left\" separated by a dash, e.g. \"top-right\" */\n indicatorPlacement?: IndicatorPlacement;\n /** An inline style CSS property to control the border radius of the wrapper */\n borderRadius?: React.CSSProperties['borderRadius'];\n /** The content to wrap */\n children?: React.ReactNode;\n /** Fit the target size to the children. */\n shouldFitToChildren?: boolean;\n /**\n * When true, merges the spotlight target props directly with the child element instead of wrapping it in a div.\n *\n * This is useful for applying spotlight functionality to existing interactive elements (buttons, links, etc.)\n * while preserving their original behavior, styling, and accessibility attributes.\n *\n * @example\n * ```tsx\n * <SpotlightTarget id=\"my-button\" asChild>\n * <FilledButton>Click me</FilledButton>\n * </SpotlightTarget>\n * ```\n *\n * @warning Only use with interactive elements that can receive focus and handle click events\n * @warning The child element's `id` will be overridden with the target's `id`\n */\n // TODO v5: decide if this naming is okay, don't see how to follow the rule without a name that is tooo long\n // eslint-disable-next-line @typescript-eslint/naming-convention\n asChild?: boolean;\n};\n\nexport const SpotlightTarget = ({\n id,\n hasPulse = true,\n indicatorVariant = 'border',\n indicatorPlacement = 'top-right',\n borderRadius,\n shouldFitToChildren = false,\n children,\n className,\n htmlAttributes,\n style,\n as,\n ref,\n asChild,\n ...restProps\n}: PolymorphicCommonProps<'div', SpotlightTargetProps>) => {\n const Component = as ?? 'div';\n\n const {\n isActiveSpotlight,\n isOpen,\n setIsOpen,\n registerTarget,\n unregisterTarget,\n setActiveSpotlight,\n } = useSpotlightContext();\n\n const internalRef = React.useRef<HTMLElement>(null);\n const childRef =\n asChild && React.isValidElement(children)\n ? (\n children as React.ReactElement<unknown> & {\n ref?: React.Ref<HTMLElement>;\n }\n ).ref\n : undefined;\n const mergedRefs = useMergeRefs<HTMLElement>([\n ref as React.RefObject<HTMLElement>,\n internalRef as React.RefObject<HTMLElement>,\n childRef as React.Ref<HTMLElement> | undefined,\n ]);\n useEffect(() => {\n if (internalRef.current !== null) {\n registerTarget(id, internalRef as React.RefObject<HTMLElement>);\n }\n return () => unregisterTarget(id);\n }, [id, registerTarget, unregisterTarget]);\n\n const isActive = isActiveSpotlight(id);\n const indicator = useIndicator({\n hasPulse,\n indicatorPlacement,\n indicatorVariant,\n isOpen: isActive,\n targetRef: internalRef,\n });\n\n if (asChild === true && React.isValidElement(children)) {\n const child = children as React.ReactElement<{\n className?: string;\n style?: React.CSSProperties;\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n }>;\n\n const onClick = (e: React.MouseEvent<HTMLElement>) => {\n if (isActive) {\n // When spotlight is active, always prevent the child's click handler\n e.preventDefault();\n\n if (!isOpen) {\n setIsOpen(true);\n }\n // Don't call child.props?.onClick when spotlight is active\n return;\n }\n\n // Only call the child's click handler when spotlight is not active\n child.props?.onClick?.(e);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (isActive && !isOpen && (e.code === 'Enter' || e.code === 'Space')) {\n e.preventDefault();\n setIsOpen(true);\n return;\n }\n\n if (isActive && e.code === 'Escape') {\n e.preventDefault();\n setActiveSpotlight(null);\n return;\n }\n\n child.props?.onKeyDown?.(e);\n };\n\n // IMPORTANT: do NOT force role/tabIndex here; preserves Composite semantics for the SideNavigation\n const mergedProps = {\n id,\n onClick,\n onKeyDown,\n ref: mergedRefs,\n style: {\n ...style,\n ...child.props.style,\n },\n // Avoid overriding the child's own role/tabIndex with any passed htmlAttributes\n ...(htmlAttributes\n ? { ...htmlAttributes, role: undefined, tabIndex: undefined }\n : {}),\n };\n\n return (\n <>\n {React.cloneElement(child, mergedProps as Record<string, unknown>)}\n <ConditionalWrap\n shouldWrap={isActive && isOpen}\n wrap={(wrapChildren) => (\n <FloatingPortal>{wrapChildren}</FloatingPortal>\n )}\n >\n {indicator.context.open && (\n <div\n className={indicator.indicatorClasses}\n ref={indicator.context.refs.setFloating}\n style={{ ...indicator.floatingStyles, ...indicator.style }}\n />\n )}\n </ConditionalWrap>\n </>\n );\n }\n\n const classes = classNames(\n 'ndl-spotlight-target',\n {\n 'ndl-spotlight-target-fit-to-children': shouldFitToChildren,\n 'ndl-spotlight-target-open': isOpen && isActive,\n },\n className,\n );\n\n const inertClasses = classNames(\n 'ndl-spotlight-target-inert',\n {\n 'ndl-spotlight-target-inert-fit-to-children': shouldFitToChildren,\n },\n className,\n );\n\n return (\n <>\n <Component\n role={isActive ? 'button' : undefined}\n id={id}\n ref={mergedRefs}\n className={classes}\n onClick={(e) => {\n if (isActive) {\n e.preventDefault();\n e.stopPropagation();\n\n if (!isOpen) {\n setIsOpen(true);\n }\n }\n }}\n style={{ borderRadius, ...style }}\n onKeyDown={(e) => {\n if (\n isActive &&\n !isOpen &&\n (e.code === 'Enter' || e.code === 'Space')\n ) {\n setIsOpen(true);\n e.preventDefault();\n } else if (e.code === 'Escape' && isActive) {\n setActiveSpotlight(null);\n }\n }}\n tabIndex={isActive ? 0 : undefined}\n {...(isActive && { 'aria-label': 'Open spotlight' })}\n {...restProps}\n {...htmlAttributes}\n >\n <ConditionalWrap\n shouldWrap={isActive}\n wrap={(children) => (\n <div inert aria-disabled className={inertClasses}>\n {children}\n </div>\n )}\n >\n {children}\n </ConditionalWrap>\n </Component>\n <ConditionalWrap\n shouldWrap={isActive && isOpen}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n {indicator.context.open && (\n <div\n className={indicator.indicatorClasses}\n ref={indicator.context.refs.setFloating}\n style={{ ...indicator.floatingStyles, ...indicator.style }}\n />\n )}\n </ConditionalWrap>\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"SpotlightTarget.js","sourceRoot":"","sources":["../../../src/spotlight/SpotlightTarget.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAm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G,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EACvC,KAAK,kCAAO,SAAS,CAAC,cAAc,GAAK,SAAS,CAAC,KAAK,IACxD,CACH,GACe,IACjB,CACJ,CAAC;AACJ,CAAC,CAAC;AAvNW,QAAA,eAAe,mBAuN1B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { FloatingPortal, useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useSpotlightContext } from './SpotlightProvider';\nimport {\n type IndicatorPlacement,\n type IndicatorVariant,\n useIndicator,\n} from './use-indicator';\n\ntype SpotlightTargetProps = {\n /** The id of the wrapper. This should match a `target` prop in a `Spotlight`, to indicate that this is where it should be rendered when open */\n id: string;\n /** A boolean that controls if the pulse animation should be used or not */\n hasPulse?: boolean;\n /** A string that controls the style of the indicator. It can be either \"point\" or \"border\" */\n indicatorVariant?: IndicatorVariant;\n /** A string that controls the placement of the indicator. A combination of \"middle\", \"top\", \"right\", \"bottom\" and \"left\" separated by a dash, e.g. \"top-right\" */\n indicatorPlacement?: IndicatorPlacement;\n /** An inline style CSS property to control the border radius of the wrapper */\n borderRadius?: React.CSSProperties['borderRadius'];\n /** The content to wrap */\n children?: React.ReactNode;\n /** Fit the target size to the children. */\n shouldFitToChildren?: boolean;\n /**\n * When true, merges the spotlight target props directly with the child element instead of wrapping it in a div.\n *\n * This is useful for applying spotlight functionality to existing interactive elements (buttons, links, etc.)\n * while preserving their original behavior, styling, and accessibility attributes.\n *\n * @remarks\n * - **Warning:** Only use with interactive elements that can receive focus and handle click events.\n * - **Warning:** The child element's `id` will be overridden with the target's `id`.\n *\n * @example\n * ```tsx\n * <SpotlightTarget id=\"my-button\" asChild>\n * <FilledButton>Click me</FilledButton>\n * </SpotlightTarget>\n * ```\n */\n // TODO v5: decide if this naming is okay, don't see how to follow the rule without a name that is tooo long\n // eslint-disable-next-line @typescript-eslint/naming-convention\n asChild?: boolean;\n};\n\nexport const SpotlightTarget = ({\n id,\n hasPulse = true,\n indicatorVariant = 'border',\n indicatorPlacement = 'top-right',\n borderRadius,\n shouldFitToChildren = false,\n children,\n className,\n htmlAttributes,\n style,\n as,\n ref,\n asChild,\n ...restProps\n}: PolymorphicCommonProps<'div', SpotlightTargetProps>) => {\n const Component = as ?? 'div';\n\n const {\n isActiveSpotlight,\n isOpen,\n setIsOpen,\n registerTarget,\n unregisterTarget,\n setActiveSpotlight,\n } = useSpotlightContext();\n\n const internalRef = React.useRef<HTMLElement>(null);\n const childRef =\n asChild && React.isValidElement(children)\n ? (\n children as React.ReactElement<unknown> & {\n ref?: React.Ref<HTMLElement>;\n }\n ).ref\n : undefined;\n const mergedRefs = useMergeRefs<HTMLElement>([\n ref as React.RefObject<HTMLElement>,\n internalRef as React.RefObject<HTMLElement>,\n childRef as React.Ref<HTMLElement> | undefined,\n ]);\n useEffect(() => {\n if (internalRef.current !== null) {\n registerTarget(id, internalRef as React.RefObject<HTMLElement>);\n }\n return () => unregisterTarget(id);\n }, [id, registerTarget, unregisterTarget]);\n\n const isActive = isActiveSpotlight(id);\n const indicator = useIndicator({\n hasPulse,\n indicatorPlacement,\n indicatorVariant,\n isOpen: isActive,\n targetRef: internalRef,\n });\n\n if (asChild === true && React.isValidElement(children)) {\n const child = children as React.ReactElement<{\n className?: string;\n style?: React.CSSProperties;\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void;\n }>;\n\n const onClick = (event: React.MouseEvent<HTMLElement>) => {\n if (isActive) {\n // When spotlight is active, always prevent the child's click handler\n event.preventDefault();\n\n if (!isOpen) {\n setIsOpen(true);\n }\n // Don't call child.props?.onClick when spotlight is active\n return;\n }\n\n // Only call the child's click handler when spotlight is not active\n child.props?.onClick?.(event);\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (\n isActive &&\n !isOpen &&\n (event.code === 'Enter' || event.code === 'Space')\n ) {\n event.preventDefault();\n setIsOpen(true);\n return;\n }\n\n if (isActive && event.code === 'Escape') {\n event.preventDefault();\n setActiveSpotlight(null);\n return;\n }\n\n child.props?.onKeyDown?.(event);\n };\n\n // IMPORTANT: do NOT force role/tabIndex here; preserves Composite semantics for the SideNavigation\n const mergedProps = {\n id,\n onClick,\n onKeyDown,\n ref: mergedRefs,\n style: {\n ...style,\n ...child.props.style,\n },\n // Avoid overriding the child's own role/tabIndex with any passed htmlAttributes\n ...(htmlAttributes\n ? { ...htmlAttributes, role: undefined, tabIndex: undefined }\n : {}),\n };\n\n return (\n <>\n {React.cloneElement(child, mergedProps as Record<string, unknown>)}\n <ConditionalWrap\n shouldWrap={isActive && isOpen}\n wrap={(wrapChildren) => (\n <FloatingPortal>{wrapChildren}</FloatingPortal>\n )}\n >\n {indicator.context.open && (\n <div\n className={indicator.indicatorClasses}\n ref={indicator.context.refs.setFloating}\n style={{ ...indicator.floatingStyles, ...indicator.style }}\n />\n )}\n </ConditionalWrap>\n </>\n );\n }\n\n const classes = classNames(\n 'ndl-spotlight-target',\n {\n 'ndl-spotlight-target-fit-to-children': shouldFitToChildren,\n 'ndl-spotlight-target-open': isOpen && isActive,\n },\n className,\n );\n\n const inertClasses = classNames(\n 'ndl-spotlight-target-inert',\n {\n 'ndl-spotlight-target-inert-fit-to-children': shouldFitToChildren,\n },\n className,\n );\n\n return (\n <>\n <Component\n role={isActive ? 'button' : undefined}\n id={id}\n ref={mergedRefs}\n className={classes}\n onClick={(event) => {\n if (isActive) {\n event.preventDefault();\n event.stopPropagation();\n\n if (!isOpen) {\n setIsOpen(true);\n }\n }\n }}\n style={{ borderRadius, ...style }}\n onKeyDown={(event) => {\n if (\n isActive &&\n !isOpen &&\n (event.code === 'Enter' || event.code === 'Space')\n ) {\n setIsOpen(true);\n event.preventDefault();\n } else if (event.code === 'Escape' && isActive) {\n setActiveSpotlight(null);\n }\n }}\n tabIndex={isActive ? 0 : undefined}\n {...(isActive && { 'aria-label': 'Open spotlight' })}\n {...restProps}\n {...htmlAttributes}\n >\n <ConditionalWrap\n shouldWrap={isActive}\n wrap={(children) => (\n <div inert aria-disabled className={inertClasses}>\n {children}\n </div>\n )}\n >\n {children}\n </ConditionalWrap>\n </Component>\n <ConditionalWrap\n shouldWrap={isActive && isOpen}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n {indicator.context.open && (\n <div\n className={indicator.indicatorClasses}\n ref={indicator.context.refs.setFloating}\n style={{ ...indicator.floatingStyles, ...indicator.style }}\n />\n )}\n </ConditionalWrap>\n </>\n );\n};\n"]}
@@ -41,6 +41,7 @@ const statusConfig = {
41
41
  danger: {
42
42
  element: 'path',
43
43
  props: {
44
+ // oxlint-disable-next-line id-length
44
45
  d: 'M0.188426 4.45553C0.067771 4.33472 0 4.17097 0 4.00024C0 3.8295 0.067771 3.66575 0.188426 3.54494L3.54489 0.188838C3.6046 0.128979 3.67554 0.0814871 3.75363 0.0490833C3.83173 0.0166795 3.91545 0 4 0C4.08455 0 4.16827 0.0166795 4.24637 0.0490833C4.32446 0.0814871 4.3954 0.128979 4.45511 0.188838L7.81157 3.54494C7.93223 3.66575 8 3.8295 8 4.00024C8 4.17097 7.93223 4.33472 7.81157 4.45553L4.45511 7.81163C4.33437 7.93226 4.17068 8.00003 4 8.00003C3.82932 8.00003 3.66563 7.93226 3.54489 7.81163L0.188426 4.45553Z',
45
46
  fill: 'var(--theme-color-danger-bg-status)',
46
47
  },
@@ -51,7 +52,7 @@ const statusConfig = {
51
52
  cx: '4',
52
53
  cy: '4',
53
54
  fill: 'var(--theme-color-primary-bg-status)',
54
- r: '4',
55
+ r: '4', // oxlint-disable-line id-length
55
56
  },
56
57
  },
57
58
  success: {
@@ -60,7 +61,7 @@ const statusConfig = {
60
61
  cx: '4',
61
62
  cy: '4',
62
63
  fill: 'var(--theme-color-success-bg-status)',
63
- r: '4',
64
+ r: '4', // oxlint-disable-line id-length
64
65
  },
65
66
  },
66
67
  unknown: {
@@ -75,6 +76,7 @@ const statusConfig = {
75
76
  warning: {
76
77
  element: 'path',
77
78
  props: {
79
+ // oxlint-disable-next-line id-length
78
80
  d: 'M4.57641 0.35903C4.52349 0.251301 4.44144 0.160559 4.33957 0.0970988C4.23769 0.0336384 4.12007 0 4.00005 0C3.88002 0 3.7624 0.0336384 3.66053 0.0970988C3.55865 0.160559 3.4766 0.251301 3.42368 0.35903L0.0554707 7.22061C0.0149262 7.30309 -0.00393024 7.39454 0.000681349 7.48633C0.00529294 7.57812 0.0332205 7.66722 0.0818275 7.74522C0.130434 7.82322 0.198117 7.88754 0.278487 7.93212C0.358856 7.9767 0.44926 8.00006 0.541165 8H7.45893C7.55083 8.00006 7.64124 7.9767 7.7216 7.93212C7.80197 7.88754 7.86966 7.82322 7.91826 7.74522C7.96687 7.66722 7.9948 7.57812 7.99941 7.48633C8.00402 7.39454 7.98517 7.30309 7.94462 7.22061L4.57641 0.35903Z',
79
81
  fill: 'var(--theme-color-warning-bg-status)',
80
82
  },
@@ -1 +1 @@
1
- {"version":3,"file":"StatusIndicator.js","sourceRoot":"","sources":["../../../src/status-indicator/StatusIndicator.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAUpC,MAAM,YAAY,GAAG;IACnB,MAAM,E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AC,4BAA4B,iBACtB,MAAM,EAClB,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAElB,uBAAC,OAAO,oBAAK,MAAM,CAAC,KAAK,EAAI,IACzB,CACP,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,eAAe,mBA6B1B;AAEF,uBAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport { type CommonProps } from '../_common/types';\n\ntype StatusIndicatorProps = {\n /** Type of the status indicator. */\n variant?: 'unknown' | 'success' | 'info' | 'warning' | 'danger';\n};\n\nconst statusConfig = {\n danger: {\n element: 'path',\n props: {\n d: 'M0.188426 4.45553C0.067771 4.33472 0 4.17097 0 4.00024C0 3.8295 0.067771 3.66575 0.188426 3.54494L3.54489 0.188838C3.6046 0.128979 3.67554 0.0814871 3.75363 0.0490833C3.83173 0.0166795 3.91545 0 4 0C4.08455 0 4.16827 0.0166795 4.24637 0.0490833C4.32446 0.0814871 4.3954 0.128979 4.45511 0.188838L7.81157 3.54494C7.93223 3.66575 8 3.8295 8 4.00024C8 4.17097 7.93223 4.33472 7.81157 4.45553L4.45511 7.81163C4.33437 7.93226 4.17068 8.00003 4 8.00003C3.82932 8.00003 3.66563 7.93226 3.54489 7.81163L0.188426 4.45553Z',\n fill: 'var(--theme-color-danger-bg-status)',\n },\n },\n info: {\n element: 'circle',\n props: {\n cx: '4',\n cy: '4',\n fill: 'var(--theme-color-primary-bg-status)',\n r: '4',\n },\n },\n success: {\n element: 'circle',\n props: {\n cx: '4',\n cy: '4',\n fill: 'var(--theme-color-success-bg-status)',\n r: '4',\n },\n },\n unknown: {\n element: 'rect',\n props: {\n fill: 'var(--theme-color-neutral-bg-status)',\n height: '8',\n rx: '1',\n width: '8',\n },\n },\n warning: {\n element: 'path',\n props: {\n d: 'M4.57641 0.35903C4.52349 0.251301 4.44144 0.160559 4.33957 0.0970988C4.23769 0.0336384 4.12007 0 4.00005 0C3.88002 0 3.7624 0.0336384 3.66053 0.0970988C3.55865 0.160559 3.4766 0.251301 3.42368 0.35903L0.0554707 7.22061C0.0149262 7.30309 -0.00393024 7.39454 0.000681349 7.48633C0.00529294 7.57812 0.0332205 7.66722 0.0818275 7.74522C0.130434 7.82322 0.198117 7.88754 0.278487 7.93212C0.358856 7.9767 0.44926 8.00006 0.541165 8H7.45893C7.55083 8.00006 7.64124 7.9767 7.7216 7.93212C7.80197 7.88754 7.86966 7.82322 7.91826 7.74522C7.96687 7.66722 7.9948 7.57812 7.99941 7.48633C8.00402 7.39454 7.98517 7.30309 7.94462 7.22061L4.57641 0.35903Z',\n fill: 'var(--theme-color-warning-bg-status)',\n },\n },\n} as const;\n\nexport const StatusIndicator = ({\n className,\n style,\n variant = 'unknown',\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'svg', StatusIndicatorProps>) => {\n const classes = classNames('ndl-status-indicator', className);\n const config = statusConfig[variant];\n const Element = config.element as keyof React.JSX.IntrinsicElements;\n\n return (\n <svg\n ref={ref}\n width=\"8\"\n height=\"8\"\n viewBox=\"0 0 8 8\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden=\"true\"\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <Element {...config.props} />\n </svg>\n );\n};\n\nStatusIndicator.displayName = 'StatusIndicator';\n"]}
1
+ {"version":3,"file":"StatusIndicator.js","sourceRoot":"","sources":["../../../src/status-indicator/StatusIndicator.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAUpC,MAAM,YAAY,GAAG;IACnB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM;QACf,KAAK,EAAE;YACL,qCAAqC;YACrC,CAAC,EAAE,kgBAAkgB;YACrgB,IAAI,EAAE,qCAAqC;SAC5C;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,QAAQ;QACjB,KAAK,EAAE;YACL,EAAE,EAAE,GAAG;YACP,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,sCAAsC;YAC5C,CAAC,EAAE,GAAG,EAAE,gCAAgC;SACzC;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,QAAQ;QACjB,KAAK,EAAE;YACL,EAAE,EAAE,GAAG;YACP,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,sCAAsC;YAC5C,CAAC,EAAE,GAAG,EAAE,gCAAgC;SACzC;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;QACf,KAAK,EAAE;YACL,IAAI,EAAE,sCAAsC;YAC5C,MAAM,EAAE,GAAG;YACX,EAAE,EAAE,GAAG;YACP,KAAK,EAAE,GAAG;SACX;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;QACf,KAAK,EAAE;YACL,qCAAqC;YACrC,CAAC,EAAE,ioBAAioB;YACpoB,IAAI,EAAE,sCAAsC;SAC7C;KACF;CACO,CAAC;AAEJ,MAAM,eAAe,GAAG,CAAC,EAOW,EAAE,EAAE;QAPf,EAC9B,SAAS,EACT,KAAK,EACL,OAAO,GAAG,SAAS,EACnB,cAAc,EACd,GAAG,OAEsC,EADtC,SAAS,cANkB,0DAO/B,CADa;IAEZ,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,OAA4C,CAAC;IAEpE,OAAO,CACL,8CACE,GAAG,EAAE,GAAG,EACR,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,GAAG,EACV,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,iBACtB,MAAM,EAClB,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAElB,uBAAC,OAAO,oBAAK,MAAM,CAAC,KAAK,EAAI,IACzB,CACP,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,eAAe,mBA6B1B;AAEF,uBAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport { type CommonProps } from '../_common/types';\n\ntype StatusIndicatorProps = {\n /** Type of the status indicator. */\n variant?: 'unknown' | 'success' | 'info' | 'warning' | 'danger';\n};\n\nconst statusConfig = {\n danger: {\n element: 'path',\n props: {\n // oxlint-disable-next-line id-length\n d: 'M0.188426 4.45553C0.067771 4.33472 0 4.17097 0 4.00024C0 3.8295 0.067771 3.66575 0.188426 3.54494L3.54489 0.188838C3.6046 0.128979 3.67554 0.0814871 3.75363 0.0490833C3.83173 0.0166795 3.91545 0 4 0C4.08455 0 4.16827 0.0166795 4.24637 0.0490833C4.32446 0.0814871 4.3954 0.128979 4.45511 0.188838L7.81157 3.54494C7.93223 3.66575 8 3.8295 8 4.00024C8 4.17097 7.93223 4.33472 7.81157 4.45553L4.45511 7.81163C4.33437 7.93226 4.17068 8.00003 4 8.00003C3.82932 8.00003 3.66563 7.93226 3.54489 7.81163L0.188426 4.45553Z',\n fill: 'var(--theme-color-danger-bg-status)',\n },\n },\n info: {\n element: 'circle',\n props: {\n cx: '4',\n cy: '4',\n fill: 'var(--theme-color-primary-bg-status)',\n r: '4', // oxlint-disable-line id-length\n },\n },\n success: {\n element: 'circle',\n props: {\n cx: '4',\n cy: '4',\n fill: 'var(--theme-color-success-bg-status)',\n r: '4', // oxlint-disable-line id-length\n },\n },\n unknown: {\n element: 'rect',\n props: {\n fill: 'var(--theme-color-neutral-bg-status)',\n height: '8',\n rx: '1',\n width: '8',\n },\n },\n warning: {\n element: 'path',\n props: {\n // oxlint-disable-next-line id-length\n d: 'M4.57641 0.35903C4.52349 0.251301 4.44144 0.160559 4.33957 0.0970988C4.23769 0.0336384 4.12007 0 4.00005 0C3.88002 0 3.7624 0.0336384 3.66053 0.0970988C3.55865 0.160559 3.4766 0.251301 3.42368 0.35903L0.0554707 7.22061C0.0149262 7.30309 -0.00393024 7.39454 0.000681349 7.48633C0.00529294 7.57812 0.0332205 7.66722 0.0818275 7.74522C0.130434 7.82322 0.198117 7.88754 0.278487 7.93212C0.358856 7.9767 0.44926 8.00006 0.541165 8H7.45893C7.55083 8.00006 7.64124 7.9767 7.7216 7.93212C7.80197 7.88754 7.86966 7.82322 7.91826 7.74522C7.96687 7.66722 7.9948 7.57812 7.99941 7.48633C8.00402 7.39454 7.98517 7.30309 7.94462 7.22061L4.57641 0.35903Z',\n fill: 'var(--theme-color-warning-bg-status)',\n },\n },\n} as const;\n\nexport const StatusIndicator = ({\n className,\n style,\n variant = 'unknown',\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'svg', StatusIndicatorProps>) => {\n const classes = classNames('ndl-status-indicator', className);\n const config = statusConfig[variant];\n const Element = config.element as keyof React.JSX.IntrinsicElements;\n\n return (\n <svg\n ref={ref}\n width=\"8\"\n height=\"8\"\n viewBox=\"0 0 8 8\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden=\"true\"\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <Element {...config.props} />\n </svg>\n );\n};\n\nStatusIndicator.displayName = 'StatusIndicator';\n"]}
@@ -168,10 +168,10 @@ const TabsComponent = (_a) => {
168
168
  const focusedElement = document.activeElement;
169
169
  // Find the currently focused tab
170
170
  let currentIndex = -1;
171
- for (let i = 0; i < tabIds.length; i++) {
172
- const tabRef = tabRefs.current.get(tabIds[i]);
171
+ for (let index = 0; index < tabIds.length; index++) {
172
+ const tabRef = tabRefs.current.get(tabIds[index]);
173
173
  if ((tabRef === null || tabRef === void 0 ? void 0 : tabRef.current) === focusedElement) {
174
- currentIndex = i;
174
+ currentIndex = index;
175
175
  break;
176
176
  }
177
177
  }