@neo4j-ndl/react 4.1.5 → 4.1.7

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 (525) hide show
  1. package/lib/cjs/_common/CodeBlockWrapper.js +5 -4
  2. package/lib/cjs/_common/CodeBlockWrapper.js.map +1 -1
  3. package/lib/cjs/_common/utils.js +4 -2
  4. package/lib/cjs/_common/utils.js.map +1 -1
  5. package/lib/cjs/accordion/Accordion.js +9 -6
  6. package/lib/cjs/accordion/Accordion.js.map +1 -1
  7. package/lib/cjs/accordion/accordion-types.js.map +1 -1
  8. package/lib/cjs/accordion/stories/accordion.stories.js +1 -1
  9. package/lib/cjs/accordion/stories/accordion.stories.js.map +1 -1
  10. package/lib/cjs/avatar/Avatar.js +1 -1
  11. package/lib/cjs/avatar/Avatar.js.map +1 -1
  12. package/lib/cjs/banner/Banner.js +3 -2
  13. package/lib/cjs/banner/Banner.js.map +1 -1
  14. package/lib/cjs/banner/stories/banner.stories.js +1 -1
  15. package/lib/cjs/banner/stories/banner.stories.js.map +1 -1
  16. package/lib/cjs/box/Box.js +14 -2
  17. package/lib/cjs/box/Box.js.map +1 -1
  18. package/lib/cjs/box/stories/box.stories.js +2 -2
  19. package/lib/cjs/box/stories/box.stories.js.map +1 -1
  20. package/lib/cjs/breadcrumbs/Breadcrumbs.js +10 -7
  21. package/lib/cjs/breadcrumbs/Breadcrumbs.js.map +1 -1
  22. package/lib/cjs/button/stories/button.stories.js +2 -2
  23. package/lib/cjs/button/stories/button.stories.js.map +1 -1
  24. package/lib/cjs/checkbox/Checkbox.js +2 -1
  25. package/lib/cjs/checkbox/Checkbox.js.map +1 -1
  26. package/lib/cjs/checkbox/stories/checkbox.stories.js +1 -1
  27. package/lib/cjs/checkbox/stories/checkbox.stories.js.map +1 -1
  28. package/lib/cjs/clipboard-button/ClipboardButton.js +6 -3
  29. package/lib/cjs/clipboard-button/ClipboardButton.js.map +1 -1
  30. package/lib/cjs/color-picker/ColorPicker.js +2 -1
  31. package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
  32. package/lib/cjs/data-grid/Components.js +9 -6
  33. package/lib/cjs/data-grid/Components.js.map +1 -1
  34. package/lib/cjs/data-grid/DataGrid.js +16 -4
  35. package/lib/cjs/data-grid/DataGrid.js.map +1 -1
  36. package/lib/cjs/data-grid/data-grid-nav/data-grid-nav.js +28 -14
  37. package/lib/cjs/data-grid/data-grid-nav/data-grid-nav.js.map +1 -1
  38. package/lib/cjs/data-grid/data-grid-nav/helpers.js +2 -1
  39. package/lib/cjs/data-grid/data-grid-nav/helpers.js.map +1 -1
  40. package/lib/cjs/data-grid/stories/datagrid-component-overriding.story.js +1 -3
  41. package/lib/cjs/data-grid/stories/datagrid-component-overriding.story.js.map +1 -1
  42. package/lib/cjs/data-grid/stories/datagrid-in-dialog.story.js +2 -1
  43. package/lib/cjs/data-grid/stories/datagrid-in-dialog.story.js.map +1 -1
  44. package/lib/cjs/data-grid/stories/datagrid-keyboard-navigation.story.js +2 -1
  45. package/lib/cjs/data-grid/stories/datagrid-keyboard-navigation.story.js.map +1 -1
  46. package/lib/cjs/data-grid/stories/datagrid-kitchen-sink.story.js +1 -2
  47. package/lib/cjs/data-grid/stories/datagrid-kitchen-sink.story.js.map +1 -1
  48. package/lib/cjs/data-grid/stories/datagrid-search-and-filters.stories.js +13 -10
  49. package/lib/cjs/data-grid/stories/datagrid-search-and-filters.stories.js.map +1 -1
  50. package/lib/cjs/date-picker/DatePicker.js +2 -1
  51. package/lib/cjs/date-picker/DatePicker.js.map +1 -1
  52. package/lib/cjs/date-picker/stories/date-picker-range.story.js +1 -1
  53. package/lib/cjs/date-picker/stories/date-picker-range.story.js.map +1 -1
  54. package/lib/cjs/date-picker/stories/date-picker.stories.js +1 -1
  55. package/lib/cjs/date-picker/stories/date-picker.stories.js.map +1 -1
  56. package/lib/cjs/dialog/Dialog.js +20 -13
  57. package/lib/cjs/dialog/Dialog.js.map +1 -1
  58. package/lib/cjs/dialog/dialog-context.js +35 -6
  59. package/lib/cjs/dialog/dialog-context.js.map +1 -1
  60. package/lib/cjs/dialog/stories/dialog.stories.js +1 -1
  61. package/lib/cjs/dialog/stories/dialog.stories.js.map +1 -1
  62. package/lib/cjs/divider/stories/divider.stories.js +1 -1
  63. package/lib/cjs/divider/stories/divider.stories.js.map +1 -1
  64. package/lib/cjs/drawer/Drawer.js +9 -8
  65. package/lib/cjs/drawer/Drawer.js.map +1 -1
  66. package/lib/cjs/dropdown-button/DropdownButton.js +14 -2
  67. package/lib/cjs/dropdown-button/DropdownButton.js.map +1 -1
  68. package/lib/cjs/dropzone/Dropzone.js +3 -2
  69. package/lib/cjs/dropzone/Dropzone.js.map +1 -1
  70. package/lib/cjs/dropzone/stories/dropzone-csv-files.story.js +1 -3
  71. package/lib/cjs/dropzone/stories/dropzone-csv-files.story.js.map +1 -1
  72. package/lib/cjs/dropzone/stories/dropzone-custom-extensions.story.js +1 -3
  73. package/lib/cjs/dropzone/stories/dropzone-custom-extensions.story.js.map +1 -1
  74. package/lib/cjs/dropzone/stories/dropzone-default.story.js +1 -3
  75. package/lib/cjs/dropzone/stories/dropzone-default.story.js.map +1 -1
  76. package/lib/cjs/dropzone/stories/dropzone-disabled.story.js +1 -3
  77. package/lib/cjs/dropzone/stories/dropzone-disabled.story.js.map +1 -1
  78. package/lib/cjs/flex/Flex.js +14 -2
  79. package/lib/cjs/flex/Flex.js.map +1 -1
  80. package/lib/cjs/graph-label/GraphLabel.js +18 -4
  81. package/lib/cjs/graph-label/GraphLabel.js.map +1 -1
  82. package/lib/cjs/icon-button/stories/icon-button.stories.js +1 -1
  83. package/lib/cjs/icon-button/stories/icon-button.stories.js.map +1 -1
  84. package/lib/cjs/icon-button-array/IconButtonArray.js +14 -2
  85. package/lib/cjs/icon-button-array/IconButtonArray.js.map +1 -1
  86. package/lib/cjs/icon-button-array/index.js +1 -1
  87. package/lib/cjs/icon-button-array/index.js.map +1 -1
  88. package/lib/cjs/icon-button-array/stories/icon-button-array.stories.js +1 -1
  89. package/lib/cjs/icon-button-array/stories/icon-button-array.stories.js.map +1 -1
  90. package/lib/cjs/icons/wrapIcon.js +1 -1
  91. package/lib/cjs/icons/wrapIcon.js.map +1 -1
  92. package/lib/cjs/inline-edit/InlineEdit.js +18 -6
  93. package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
  94. package/lib/cjs/kbd/Kbd.js +5 -3
  95. package/lib/cjs/kbd/Kbd.js.map +1 -1
  96. package/lib/cjs/kbd/stories/kbd.stories.js +1 -1
  97. package/lib/cjs/kbd/stories/kbd.stories.js.map +1 -1
  98. package/lib/cjs/loading-bar/LoadingBar.js +14 -2
  99. package/lib/cjs/loading-bar/LoadingBar.js.map +1 -1
  100. package/lib/cjs/loading-spinner/LoadingSpinner.js +1 -1
  101. package/lib/cjs/loading-spinner/LoadingSpinner.js.map +1 -1
  102. package/lib/cjs/logo/stories/logo.stories.js +1 -1
  103. package/lib/cjs/logo/stories/logo.stories.js.map +1 -1
  104. package/lib/cjs/menu/Menu.js +9 -6
  105. package/lib/cjs/menu/Menu.js.map +1 -1
  106. package/lib/cjs/popover/Popover.js +6 -4
  107. package/lib/cjs/popover/Popover.js.map +1 -1
  108. package/lib/cjs/popover/stories/popover-custom-offset.story.js +2 -1
  109. package/lib/cjs/popover/stories/popover-custom-offset.story.js.map +1 -1
  110. package/lib/cjs/popover/stories/popover-separate-anchor.story.js +1 -1
  111. package/lib/cjs/popover/stories/popover-separate-anchor.story.js.map +1 -1
  112. package/lib/cjs/progress-bar/ProgressBar.js +1 -1
  113. package/lib/cjs/progress-bar/ProgressBar.js.map +1 -1
  114. package/lib/cjs/radio/Radio.js +2 -1
  115. package/lib/cjs/radio/Radio.js.map +1 -1
  116. package/lib/cjs/radio/stories/radio.stories.js +1 -1
  117. package/lib/cjs/radio/stories/radio.stories.js.map +1 -1
  118. package/lib/cjs/select/Overrides.js +1 -1
  119. package/lib/cjs/select/Overrides.js.map +1 -1
  120. package/lib/cjs/select/Select.js +18 -6
  121. package/lib/cjs/select/Select.js.map +1 -1
  122. package/lib/cjs/side-navigation/SideNavigation.js +5 -4
  123. package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
  124. package/lib/cjs/skeleton/Skeleton.js +14 -2
  125. package/lib/cjs/skeleton/Skeleton.js.map +1 -1
  126. package/lib/cjs/skeleton/stories/skeleton.stories.js +1 -1
  127. package/lib/cjs/skeleton/stories/skeleton.stories.js.map +1 -1
  128. package/lib/cjs/spotlight/Spotlight.js +33 -14
  129. package/lib/cjs/spotlight/Spotlight.js.map +1 -1
  130. package/lib/cjs/spotlight/SpotlightProvider.js +6 -3
  131. package/lib/cjs/spotlight/SpotlightProvider.js.map +1 -1
  132. package/lib/cjs/spotlight/SpotlightTarget.js +14 -2
  133. package/lib/cjs/spotlight/SpotlightTarget.js.map +1 -1
  134. package/lib/cjs/spotlight/SpotlightTour.js +1 -1
  135. package/lib/cjs/spotlight/SpotlightTour.js.map +1 -1
  136. package/lib/cjs/spotlight/stories/spotlight.stories.js +1 -1
  137. package/lib/cjs/spotlight/stories/spotlight.stories.js.map +1 -1
  138. package/lib/cjs/spotlight/use-indicator.js +2 -1
  139. package/lib/cjs/spotlight/use-indicator.js.map +1 -1
  140. package/lib/cjs/status-label/StatusLabel.js +1 -1
  141. package/lib/cjs/status-label/StatusLabel.js.map +1 -1
  142. package/lib/cjs/switch/Switch.js +2 -1
  143. package/lib/cjs/switch/Switch.js.map +1 -1
  144. package/lib/cjs/switch/stories/switch.stories.js +1 -1
  145. package/lib/cjs/switch/stories/switch.stories.js.map +1 -1
  146. package/lib/cjs/tabs/stories/tabs-disabled.story.js +1 -1
  147. package/lib/cjs/tabs/stories/tabs-disabled.story.js.map +1 -1
  148. package/lib/cjs/tabs/stories/tabs-fill-variants.story.js +1 -1
  149. package/lib/cjs/tabs/stories/tabs-fill-variants.story.js.map +1 -1
  150. package/lib/cjs/tabs/stories/tabs-overflow.story.js +1 -1
  151. package/lib/cjs/tabs/stories/tabs-overflow.story.js.map +1 -1
  152. package/lib/cjs/tabs/stories/tabs-sizes.story.js +1 -1
  153. package/lib/cjs/tabs/stories/tabs-sizes.story.js.map +1 -1
  154. package/lib/cjs/tabs/use-tabs-scroll-overflow.js +8 -4
  155. package/lib/cjs/tabs/use-tabs-scroll-overflow.js.map +1 -1
  156. package/lib/cjs/tag/Tag.js +14 -2
  157. package/lib/cjs/tag/Tag.js.map +1 -1
  158. package/lib/cjs/text-area/TextArea.js +14 -2
  159. package/lib/cjs/text-area/TextArea.js.map +1 -1
  160. package/lib/cjs/text-area/stories/text-area.stories.js +1 -1
  161. package/lib/cjs/text-area/stories/text-area.stories.js.map +1 -1
  162. package/lib/cjs/text-input/TextInput.js +14 -2
  163. package/lib/cjs/text-input/TextInput.js.map +1 -1
  164. package/lib/cjs/text-link/TextLink.js +14 -2
  165. package/lib/cjs/text-link/TextLink.js.map +1 -1
  166. package/lib/cjs/text-overflow/TextOverflow.js +2 -1
  167. package/lib/cjs/text-overflow/TextOverflow.js.map +1 -1
  168. package/lib/cjs/text-overflow/stories/text-overflow.stories.js +1 -1
  169. package/lib/cjs/text-overflow/stories/text-overflow.stories.js.map +1 -1
  170. package/lib/cjs/text-overflow/text-overflow-utils.js +12 -6
  171. package/lib/cjs/text-overflow/text-overflow-utils.js.map +1 -1
  172. package/lib/cjs/text-overflow/use-ellipsis-observer.js +2 -1
  173. package/lib/cjs/text-overflow/use-ellipsis-observer.js.map +1 -1
  174. package/lib/cjs/text-overflow/use-truncate-with-button.js +4 -2
  175. package/lib/cjs/text-overflow/use-truncate-with-button.js.map +1 -1
  176. package/lib/cjs/theme/ThemeProvider.js +2 -1
  177. package/lib/cjs/theme/ThemeProvider.js.map +1 -1
  178. package/lib/cjs/time-picker/TimePicker.js +22 -8
  179. package/lib/cjs/time-picker/TimePicker.js.map +1 -1
  180. package/lib/cjs/time-picker/stories/time-picker.stories.js +1 -1
  181. package/lib/cjs/time-picker/stories/time-picker.stories.js.map +1 -1
  182. package/lib/cjs/timezone-picker/TimeZonePicker.js +8 -4
  183. package/lib/cjs/timezone-picker/TimeZonePicker.js.map +1 -1
  184. package/lib/cjs/timezone-picker/generate-timezone-options.js +15 -9
  185. package/lib/cjs/timezone-picker/generate-timezone-options.js.map +1 -1
  186. package/lib/cjs/timezone-picker/stories/timezone-picker.stories.js +1 -1
  187. package/lib/cjs/timezone-picker/stories/timezone-picker.stories.js.map +1 -1
  188. package/lib/cjs/toast/Toast.js +11 -6
  189. package/lib/cjs/toast/Toast.js.map +1 -1
  190. package/lib/cjs/tooltip/Tooltip.js +35 -15
  191. package/lib/cjs/tooltip/Tooltip.js.map +1 -1
  192. package/lib/cjs/tree-view/TreeItemWrapper.js +3 -1
  193. package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
  194. package/lib/cjs/tree-view/TreeView.js +2 -1
  195. package/lib/cjs/tree-view/TreeView.js.map +1 -1
  196. package/lib/cjs/tree-view/TreeViewItem.js +3 -1
  197. package/lib/cjs/tree-view/TreeViewItem.js.map +1 -1
  198. package/lib/cjs/tree-view/TreeViewTextItem.js +1 -2
  199. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  200. package/lib/cjs/tree-view/TreeViewTrail.js +14 -2
  201. package/lib/cjs/tree-view/TreeViewTrail.js.map +1 -1
  202. package/lib/cjs/wizard/Wizard.js +3 -2
  203. package/lib/cjs/wizard/Wizard.js.map +1 -1
  204. package/lib/esm/_common/CodeBlockWrapper.js +5 -4
  205. package/lib/esm/_common/CodeBlockWrapper.js.map +1 -1
  206. package/lib/esm/_common/utils.js +4 -2
  207. package/lib/esm/_common/utils.js.map +1 -1
  208. package/lib/esm/accordion/Accordion.js +9 -6
  209. package/lib/esm/accordion/Accordion.js.map +1 -1
  210. package/lib/esm/accordion/accordion-types.js.map +1 -1
  211. package/lib/esm/accordion/stories/accordion.stories.js +1 -1
  212. package/lib/esm/accordion/stories/accordion.stories.js.map +1 -1
  213. package/lib/esm/avatar/Avatar.js +1 -1
  214. package/lib/esm/avatar/Avatar.js.map +1 -1
  215. package/lib/esm/banner/Banner.js +3 -2
  216. package/lib/esm/banner/Banner.js.map +1 -1
  217. package/lib/esm/banner/stories/banner.stories.js +1 -1
  218. package/lib/esm/banner/stories/banner.stories.js.map +1 -1
  219. package/lib/esm/box/Box.js +14 -2
  220. package/lib/esm/box/Box.js.map +1 -1
  221. package/lib/esm/box/stories/box.stories.js +2 -2
  222. package/lib/esm/box/stories/box.stories.js.map +1 -1
  223. package/lib/esm/breadcrumbs/Breadcrumbs.js +10 -7
  224. package/lib/esm/breadcrumbs/Breadcrumbs.js.map +1 -1
  225. package/lib/esm/button/stories/button.stories.js +1 -1
  226. package/lib/esm/button/stories/button.stories.js.map +1 -1
  227. package/lib/esm/checkbox/Checkbox.js +2 -1
  228. package/lib/esm/checkbox/Checkbox.js.map +1 -1
  229. package/lib/esm/checkbox/stories/checkbox.stories.js +1 -1
  230. package/lib/esm/checkbox/stories/checkbox.stories.js.map +1 -1
  231. package/lib/esm/clipboard-button/ClipboardButton.js +6 -3
  232. package/lib/esm/clipboard-button/ClipboardButton.js.map +1 -1
  233. package/lib/esm/color-picker/ColorPicker.js +2 -1
  234. package/lib/esm/color-picker/ColorPicker.js.map +1 -1
  235. package/lib/esm/data-grid/Components.js +9 -6
  236. package/lib/esm/data-grid/Components.js.map +1 -1
  237. package/lib/esm/data-grid/DataGrid.js +16 -4
  238. package/lib/esm/data-grid/DataGrid.js.map +1 -1
  239. package/lib/esm/data-grid/data-grid-nav/data-grid-nav.js +28 -14
  240. package/lib/esm/data-grid/data-grid-nav/data-grid-nav.js.map +1 -1
  241. package/lib/esm/data-grid/data-grid-nav/helpers.js +2 -1
  242. package/lib/esm/data-grid/data-grid-nav/helpers.js.map +1 -1
  243. package/lib/esm/data-grid/stories/datagrid-component-overriding.story.js +1 -3
  244. package/lib/esm/data-grid/stories/datagrid-component-overriding.story.js.map +1 -1
  245. package/lib/esm/data-grid/stories/datagrid-in-dialog.story.js +2 -1
  246. package/lib/esm/data-grid/stories/datagrid-in-dialog.story.js.map +1 -1
  247. package/lib/esm/data-grid/stories/datagrid-keyboard-navigation.story.js +2 -1
  248. package/lib/esm/data-grid/stories/datagrid-keyboard-navigation.story.js.map +1 -1
  249. package/lib/esm/data-grid/stories/datagrid-kitchen-sink.story.js +1 -2
  250. package/lib/esm/data-grid/stories/datagrid-kitchen-sink.story.js.map +1 -1
  251. package/lib/esm/data-grid/stories/datagrid-search-and-filters.stories.js +9 -6
  252. package/lib/esm/data-grid/stories/datagrid-search-and-filters.stories.js.map +1 -1
  253. package/lib/esm/date-picker/DatePicker.js +2 -1
  254. package/lib/esm/date-picker/DatePicker.js.map +1 -1
  255. package/lib/esm/date-picker/stories/date-picker-range.story.js +1 -1
  256. package/lib/esm/date-picker/stories/date-picker-range.story.js.map +1 -1
  257. package/lib/esm/date-picker/stories/date-picker.stories.js +1 -1
  258. package/lib/esm/date-picker/stories/date-picker.stories.js.map +1 -1
  259. package/lib/esm/dialog/Dialog.js +20 -13
  260. package/lib/esm/dialog/Dialog.js.map +1 -1
  261. package/lib/esm/dialog/dialog-context.js +1 -2
  262. package/lib/esm/dialog/dialog-context.js.map +1 -1
  263. package/lib/esm/dialog/stories/dialog.stories.js +1 -1
  264. package/lib/esm/dialog/stories/dialog.stories.js.map +1 -1
  265. package/lib/esm/divider/stories/divider.stories.js +1 -1
  266. package/lib/esm/divider/stories/divider.stories.js.map +1 -1
  267. package/lib/esm/drawer/Drawer.js +9 -8
  268. package/lib/esm/drawer/Drawer.js.map +1 -1
  269. package/lib/esm/dropdown-button/DropdownButton.js +14 -2
  270. package/lib/esm/dropdown-button/DropdownButton.js.map +1 -1
  271. package/lib/esm/dropzone/Dropzone.js +3 -2
  272. package/lib/esm/dropzone/Dropzone.js.map +1 -1
  273. package/lib/esm/dropzone/stories/dropzone-csv-files.story.js +1 -3
  274. package/lib/esm/dropzone/stories/dropzone-csv-files.story.js.map +1 -1
  275. package/lib/esm/dropzone/stories/dropzone-custom-extensions.story.js +1 -3
  276. package/lib/esm/dropzone/stories/dropzone-custom-extensions.story.js.map +1 -1
  277. package/lib/esm/dropzone/stories/dropzone-default.story.js +1 -3
  278. package/lib/esm/dropzone/stories/dropzone-default.story.js.map +1 -1
  279. package/lib/esm/dropzone/stories/dropzone-disabled.story.js +1 -3
  280. package/lib/esm/dropzone/stories/dropzone-disabled.story.js.map +1 -1
  281. package/lib/esm/flex/Flex.js +14 -2
  282. package/lib/esm/flex/Flex.js.map +1 -1
  283. package/lib/esm/graph-label/GraphLabel.js +18 -4
  284. package/lib/esm/graph-label/GraphLabel.js.map +1 -1
  285. package/lib/esm/icon-button/stories/icon-button.stories.js +1 -1
  286. package/lib/esm/icon-button/stories/icon-button.stories.js.map +1 -1
  287. package/lib/esm/icon-button-array/IconButtonArray.js +14 -2
  288. package/lib/esm/icon-button-array/IconButtonArray.js.map +1 -1
  289. package/lib/esm/icon-button-array/index.js +1 -1
  290. package/lib/esm/icon-button-array/index.js.map +1 -1
  291. package/lib/esm/icon-button-array/stories/icon-button-array.stories.js +1 -1
  292. package/lib/esm/icon-button-array/stories/icon-button-array.stories.js.map +1 -1
  293. package/lib/esm/icons/wrapIcon.js +1 -1
  294. package/lib/esm/icons/wrapIcon.js.map +1 -1
  295. package/lib/esm/inline-edit/InlineEdit.js +18 -6
  296. package/lib/esm/inline-edit/InlineEdit.js.map +1 -1
  297. package/lib/esm/kbd/Kbd.js +5 -3
  298. package/lib/esm/kbd/Kbd.js.map +1 -1
  299. package/lib/esm/kbd/stories/kbd.stories.js +1 -1
  300. package/lib/esm/kbd/stories/kbd.stories.js.map +1 -1
  301. package/lib/esm/loading-bar/LoadingBar.js +14 -2
  302. package/lib/esm/loading-bar/LoadingBar.js.map +1 -1
  303. package/lib/esm/loading-spinner/LoadingSpinner.js +1 -1
  304. package/lib/esm/loading-spinner/LoadingSpinner.js.map +1 -1
  305. package/lib/esm/logo/stories/logo.stories.js +1 -1
  306. package/lib/esm/logo/stories/logo.stories.js.map +1 -1
  307. package/lib/esm/menu/Menu.js +9 -6
  308. package/lib/esm/menu/Menu.js.map +1 -1
  309. package/lib/esm/popover/Popover.js +6 -4
  310. package/lib/esm/popover/Popover.js.map +1 -1
  311. package/lib/esm/popover/stories/popover-custom-offset.story.js +2 -1
  312. package/lib/esm/popover/stories/popover-custom-offset.story.js.map +1 -1
  313. package/lib/esm/popover/stories/popover-separate-anchor.story.js +1 -1
  314. package/lib/esm/popover/stories/popover-separate-anchor.story.js.map +1 -1
  315. package/lib/esm/progress-bar/ProgressBar.js +1 -1
  316. package/lib/esm/progress-bar/ProgressBar.js.map +1 -1
  317. package/lib/esm/radio/Radio.js +2 -1
  318. package/lib/esm/radio/Radio.js.map +1 -1
  319. package/lib/esm/radio/stories/radio.stories.js +1 -1
  320. package/lib/esm/radio/stories/radio.stories.js.map +1 -1
  321. package/lib/esm/select/Overrides.js +1 -1
  322. package/lib/esm/select/Overrides.js.map +1 -1
  323. package/lib/esm/select/Select.js +18 -6
  324. package/lib/esm/select/Select.js.map +1 -1
  325. package/lib/esm/side-navigation/SideNavigation.js +5 -4
  326. package/lib/esm/side-navigation/SideNavigation.js.map +1 -1
  327. package/lib/esm/skeleton/Skeleton.js +14 -2
  328. package/lib/esm/skeleton/Skeleton.js.map +1 -1
  329. package/lib/esm/skeleton/stories/skeleton.stories.js +1 -1
  330. package/lib/esm/skeleton/stories/skeleton.stories.js.map +1 -1
  331. package/lib/esm/spotlight/Spotlight.js +33 -14
  332. package/lib/esm/spotlight/Spotlight.js.map +1 -1
  333. package/lib/esm/spotlight/SpotlightProvider.js +6 -3
  334. package/lib/esm/spotlight/SpotlightProvider.js.map +1 -1
  335. package/lib/esm/spotlight/SpotlightTarget.js +14 -2
  336. package/lib/esm/spotlight/SpotlightTarget.js.map +1 -1
  337. package/lib/esm/spotlight/SpotlightTour.js +1 -1
  338. package/lib/esm/spotlight/SpotlightTour.js.map +1 -1
  339. package/lib/esm/spotlight/stories/spotlight.stories.js +1 -1
  340. package/lib/esm/spotlight/stories/spotlight.stories.js.map +1 -1
  341. package/lib/esm/spotlight/use-indicator.js +2 -1
  342. package/lib/esm/spotlight/use-indicator.js.map +1 -1
  343. package/lib/esm/status-label/StatusLabel.js +1 -1
  344. package/lib/esm/status-label/StatusLabel.js.map +1 -1
  345. package/lib/esm/switch/Switch.js +2 -1
  346. package/lib/esm/switch/Switch.js.map +1 -1
  347. package/lib/esm/switch/stories/switch.stories.js +1 -1
  348. package/lib/esm/switch/stories/switch.stories.js.map +1 -1
  349. package/lib/esm/tabs/stories/tabs-disabled.story.js +1 -1
  350. package/lib/esm/tabs/stories/tabs-disabled.story.js.map +1 -1
  351. package/lib/esm/tabs/stories/tabs-fill-variants.story.js +1 -1
  352. package/lib/esm/tabs/stories/tabs-fill-variants.story.js.map +1 -1
  353. package/lib/esm/tabs/stories/tabs-overflow.story.js +1 -1
  354. package/lib/esm/tabs/stories/tabs-overflow.story.js.map +1 -1
  355. package/lib/esm/tabs/stories/tabs-sizes.story.js +1 -1
  356. package/lib/esm/tabs/stories/tabs-sizes.story.js.map +1 -1
  357. package/lib/esm/tabs/use-tabs-scroll-overflow.js +8 -4
  358. package/lib/esm/tabs/use-tabs-scroll-overflow.js.map +1 -1
  359. package/lib/esm/tag/Tag.js +14 -2
  360. package/lib/esm/tag/Tag.js.map +1 -1
  361. package/lib/esm/text-area/TextArea.js +14 -2
  362. package/lib/esm/text-area/TextArea.js.map +1 -1
  363. package/lib/esm/text-area/stories/text-area.stories.js +1 -1
  364. package/lib/esm/text-area/stories/text-area.stories.js.map +1 -1
  365. package/lib/esm/text-input/TextInput.js +14 -2
  366. package/lib/esm/text-input/TextInput.js.map +1 -1
  367. package/lib/esm/text-link/TextLink.js +14 -2
  368. package/lib/esm/text-link/TextLink.js.map +1 -1
  369. package/lib/esm/text-overflow/TextOverflow.js +2 -1
  370. package/lib/esm/text-overflow/TextOverflow.js.map +1 -1
  371. package/lib/esm/text-overflow/stories/text-overflow.stories.js +1 -1
  372. package/lib/esm/text-overflow/stories/text-overflow.stories.js.map +1 -1
  373. package/lib/esm/text-overflow/text-overflow-utils.js +12 -6
  374. package/lib/esm/text-overflow/text-overflow-utils.js.map +1 -1
  375. package/lib/esm/text-overflow/use-ellipsis-observer.js +2 -1
  376. package/lib/esm/text-overflow/use-ellipsis-observer.js.map +1 -1
  377. package/lib/esm/text-overflow/use-truncate-with-button.js +4 -2
  378. package/lib/esm/text-overflow/use-truncate-with-button.js.map +1 -1
  379. package/lib/esm/theme/ThemeProvider.js +2 -1
  380. package/lib/esm/theme/ThemeProvider.js.map +1 -1
  381. package/lib/esm/time-picker/TimePicker.js +22 -8
  382. package/lib/esm/time-picker/TimePicker.js.map +1 -1
  383. package/lib/esm/time-picker/stories/time-picker.stories.js +1 -1
  384. package/lib/esm/time-picker/stories/time-picker.stories.js.map +1 -1
  385. package/lib/esm/timezone-picker/TimeZonePicker.js +8 -4
  386. package/lib/esm/timezone-picker/TimeZonePicker.js.map +1 -1
  387. package/lib/esm/timezone-picker/generate-timezone-options.js +15 -9
  388. package/lib/esm/timezone-picker/generate-timezone-options.js.map +1 -1
  389. package/lib/esm/timezone-picker/stories/timezone-picker.stories.js +1 -1
  390. package/lib/esm/timezone-picker/stories/timezone-picker.stories.js.map +1 -1
  391. package/lib/esm/toast/Toast.js +11 -6
  392. package/lib/esm/toast/Toast.js.map +1 -1
  393. package/lib/esm/tooltip/Tooltip.js +35 -15
  394. package/lib/esm/tooltip/Tooltip.js.map +1 -1
  395. package/lib/esm/tree-view/TreeItemWrapper.js +3 -1
  396. package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
  397. package/lib/esm/tree-view/TreeView.js +2 -1
  398. package/lib/esm/tree-view/TreeView.js.map +1 -1
  399. package/lib/esm/tree-view/TreeViewItem.js +3 -1
  400. package/lib/esm/tree-view/TreeViewItem.js.map +1 -1
  401. package/lib/esm/tree-view/TreeViewTextItem.js +1 -2
  402. package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
  403. package/lib/esm/tree-view/TreeViewTrail.js +14 -2
  404. package/lib/esm/tree-view/TreeViewTrail.js.map +1 -1
  405. package/lib/esm/wizard/Wizard.js +3 -2
  406. package/lib/esm/wizard/Wizard.js.map +1 -1
  407. package/lib/types/_common/CodeBlockWrapper.d.ts +1 -1
  408. package/lib/types/_common/CodeBlockWrapper.d.ts.map +1 -1
  409. package/lib/types/_common/utils.d.ts.map +1 -1
  410. package/lib/types/accordion/Accordion.d.ts +4 -4
  411. package/lib/types/accordion/Accordion.d.ts.map +1 -1
  412. package/lib/types/accordion/accordion-types.d.ts +1 -1
  413. package/lib/types/accordion/accordion-types.d.ts.map +1 -1
  414. package/lib/types/accordion/stories/accordion.stories.d.ts +4 -4
  415. package/lib/types/avatar/Avatar.d.ts.map +1 -1
  416. package/lib/types/banner/Banner.d.ts +1 -1
  417. package/lib/types/banner/Banner.d.ts.map +1 -1
  418. package/lib/types/box/Box.d.ts +1 -1
  419. package/lib/types/box/Box.d.ts.map +1 -1
  420. package/lib/types/box/stories/box.stories.d.ts +1 -1
  421. package/lib/types/breadcrumbs/Breadcrumbs.d.ts +3 -3
  422. package/lib/types/breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  423. package/lib/types/breadcrumbs/stories/breadcrumbs.stories.d.ts +3 -3
  424. package/lib/types/button/stories/button.stories.d.ts +1 -1
  425. package/lib/types/button/stories/button.stories.d.ts.map +1 -1
  426. package/lib/types/checkbox/Checkbox.d.ts.map +1 -1
  427. package/lib/types/clipboard-button/ClipboardButton.d.ts.map +1 -1
  428. package/lib/types/color-picker/ColorPicker.d.ts.map +1 -1
  429. package/lib/types/data-grid/Components.d.ts.map +1 -1
  430. package/lib/types/data-grid/DataGrid.d.ts +23 -23
  431. package/lib/types/data-grid/DataGrid.d.ts.map +1 -1
  432. package/lib/types/data-grid/data-grid-nav/data-grid-nav.d.ts.map +1 -1
  433. package/lib/types/data-grid/data-grid-nav/helpers.d.ts.map +1 -1
  434. package/lib/types/data-grid/stories/datagrid-component-overriding.story.d.ts.map +1 -1
  435. package/lib/types/data-grid/stories/datagrid-in-dialog.story.d.ts.map +1 -1
  436. package/lib/types/data-grid/stories/datagrid-keyboard-navigation.story.d.ts.map +1 -1
  437. package/lib/types/data-grid/stories/datagrid-kitchen-sink.story.d.ts.map +1 -1
  438. package/lib/types/data-grid/stories/datagrid-pinned-columns.stories.d.ts +1 -1
  439. package/lib/types/data-grid/stories/datagrid-placeholder-states.stories.d.ts +1 -1
  440. package/lib/types/data-grid/stories/datagrid-search-and-filters.stories.d.ts +1 -1
  441. package/lib/types/data-grid/stories/datagrid-search-and-filters.stories.d.ts.map +1 -1
  442. package/lib/types/date-picker/DatePicker.d.ts.map +1 -1
  443. package/lib/types/date-picker/stories/date-picker-range.story.d.ts.map +1 -1
  444. package/lib/types/dialog/Dialog.d.ts +6 -6
  445. package/lib/types/dialog/Dialog.d.ts.map +1 -1
  446. package/lib/types/dialog/dialog-context.d.ts.map +1 -1
  447. package/lib/types/drawer/Drawer.d.ts +3 -3
  448. package/lib/types/drawer/Drawer.d.ts.map +1 -1
  449. package/lib/types/dropdown-button/DropdownButton.d.ts +1 -1
  450. package/lib/types/dropdown-button/DropdownButton.d.ts.map +1 -1
  451. package/lib/types/dropzone/Dropzone.d.ts.map +1 -1
  452. package/lib/types/flex/Flex.d.ts +1 -1
  453. package/lib/types/flex/Flex.d.ts.map +1 -1
  454. package/lib/types/flex/stories/flex.stories.d.ts +1 -1
  455. package/lib/types/graph-label/GraphLabel.d.ts +1 -1
  456. package/lib/types/graph-label/GraphLabel.d.ts.map +1 -1
  457. package/lib/types/icon-button-array/IconButtonArray.d.ts +2 -2
  458. package/lib/types/icon-button-array/IconButtonArray.d.ts.map +1 -1
  459. package/lib/types/icon-button-array/index.d.ts +1 -1
  460. package/lib/types/icon-button-array/index.d.ts.map +1 -1
  461. package/lib/types/inline-edit/InlineEdit.d.ts +1 -1
  462. package/lib/types/inline-edit/InlineEdit.d.ts.map +1 -1
  463. package/lib/types/kbd/Kbd.d.ts.map +1 -1
  464. package/lib/types/loading-bar/LoadingBar.d.ts +1 -1
  465. package/lib/types/loading-bar/LoadingBar.d.ts.map +1 -1
  466. package/lib/types/menu/Menu.d.ts +2 -2
  467. package/lib/types/menu/Menu.d.ts.map +1 -1
  468. package/lib/types/popover/Popover.d.ts +1 -1
  469. package/lib/types/popover/Popover.d.ts.map +1 -1
  470. package/lib/types/popover/stories/popover-custom-offset.story.d.ts.map +1 -1
  471. package/lib/types/radio/Radio.d.ts.map +1 -1
  472. package/lib/types/select/Overrides.d.ts +1 -2
  473. package/lib/types/select/Overrides.d.ts.map +1 -1
  474. package/lib/types/select/Select.d.ts +1 -1
  475. package/lib/types/select/Select.d.ts.map +1 -1
  476. package/lib/types/side-navigation/SideNavigation.d.ts +1 -1
  477. package/lib/types/side-navigation/SideNavigation.d.ts.map +1 -1
  478. package/lib/types/side-navigation/stories/side-nav.stories.d.ts +1 -1
  479. package/lib/types/skeleton/Skeleton.d.ts +1 -1
  480. package/lib/types/skeleton/Skeleton.d.ts.map +1 -1
  481. package/lib/types/skeleton/stories/skeleton.stories.d.ts +1 -1
  482. package/lib/types/spotlight/Spotlight.d.ts +6 -6
  483. package/lib/types/spotlight/Spotlight.d.ts.map +1 -1
  484. package/lib/types/spotlight/SpotlightProvider.d.ts.map +1 -1
  485. package/lib/types/spotlight/SpotlightTarget.d.ts +1 -1
  486. package/lib/types/spotlight/SpotlightTarget.d.ts.map +1 -1
  487. package/lib/types/spotlight/use-indicator.d.ts.map +1 -1
  488. package/lib/types/switch/Switch.d.ts.map +1 -1
  489. package/lib/types/tabs/use-tabs-scroll-overflow.d.ts.map +1 -1
  490. package/lib/types/tag/Tag.d.ts +1 -1
  491. package/lib/types/tag/Tag.d.ts.map +1 -1
  492. package/lib/types/text-area/TextArea.d.ts +1 -1
  493. package/lib/types/text-area/TextArea.d.ts.map +1 -1
  494. package/lib/types/text-input/TextInput.d.ts +1 -1
  495. package/lib/types/text-input/TextInput.d.ts.map +1 -1
  496. package/lib/types/text-link/TextLink.d.ts +1 -1
  497. package/lib/types/text-link/TextLink.d.ts.map +1 -1
  498. package/lib/types/text-overflow/TextOverflow.d.ts.map +1 -1
  499. package/lib/types/text-overflow/text-overflow-utils.d.ts.map +1 -1
  500. package/lib/types/text-overflow/use-ellipsis-observer.d.ts.map +1 -1
  501. package/lib/types/text-overflow/use-truncate-with-button.d.ts.map +1 -1
  502. package/lib/types/theme/ThemeProvider.d.ts.map +1 -1
  503. package/lib/types/time-picker/TimePicker.d.ts +1 -1
  504. package/lib/types/time-picker/TimePicker.d.ts.map +1 -1
  505. package/lib/types/time-picker/stories/time-picker.stories.d.ts +1 -1
  506. package/lib/types/timezone-picker/TimeZonePicker.d.ts.map +1 -1
  507. package/lib/types/timezone-picker/generate-timezone-options.d.ts.map +1 -1
  508. package/lib/types/toast/Toast.d.ts +1 -1
  509. package/lib/types/toast/Toast.d.ts.map +1 -1
  510. package/lib/types/tooltip/Tooltip.d.ts +8 -7
  511. package/lib/types/tooltip/Tooltip.d.ts.map +1 -1
  512. package/lib/types/tree-view/TreeItemWrapper.d.ts.map +1 -1
  513. package/lib/types/tree-view/TreeView.d.ts.map +1 -1
  514. package/lib/types/tree-view/TreeViewItem.d.ts.map +1 -1
  515. package/lib/types/tree-view/TreeViewTrail.d.ts +2 -1
  516. package/lib/types/tree-view/TreeViewTrail.d.ts.map +1 -1
  517. package/lib/types/wizard/Wizard.d.ts +1 -1
  518. package/lib/types/wizard/Wizard.d.ts.map +1 -1
  519. package/package.json +2 -2
  520. package/lib/cjs/dropdown-button/avatar-test.stories.tsx.js +0 -31
  521. package/lib/cjs/dropdown-button/avatar-test.stories.tsx.js.map +0 -1
  522. package/lib/esm/dropdown-button/avatar-test.stories.tsx.js +0 -27
  523. package/lib/esm/dropdown-button/avatar-test.stories.tsx.js.map +0 -1
  524. package/lib/types/dropdown-button/avatar-test.stories.tsx.d.ts +0 -24
  525. package/lib/types/dropdown-button/avatar-test.stories.tsx.d.ts.map +0 -1
@@ -1 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GACkB,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 type React from 'react';\nimport { useEffect, useRef, useState } 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';\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}: PolymorphicCommonProps<T, SpotlightHeaderProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-header', className);\n\n return (\n <Typography\n variant=\"title-4\"\n ref={ref}\n as={as ?? 'div'}\n className={classes}\n style={style}\n {...htmlAttributes}\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}: PolymorphicCommonProps<T, SpotlightBodyProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-body', className);\n\n return (\n <Typography\n variant=\"body-medium\"\n className={classes}\n as={as ?? 'div'}\n style={style}\n ref={ref}\n {...htmlAttributes}\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}: 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 {...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}: 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 {...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}: PolymorphicCommonProps<T, SpotlightIconWrapperProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-icon-wrapper', className);\n const Component = as ?? 'div';\n\n return (\n <Component ref={ref} className={classes} style={style} {...htmlAttributes}>\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}: CommonProps<'div', SpotlightProps>) => {\n const [targetElement, setTargetElement] = useState<HTMLElement | null>(null);\n const actionsRef = useRef<HTMLDivElement | null>(null);\n\n const {\n isActiveSpotlight,\n isOpen,\n setActiveSpotlight,\n setIsOpen,\n registeredTargets,\n hasOverlay,\n } = useSpotlightContext();\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) return undefined;\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) return null;\n\n return (\n <FloatingPortal>\n <FloatingFocusManager\n context={spotlight.context}\n modal={true}\n initialFocus={findInitialFocus()}\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({ ...htmlAttributes })}\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 </>\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":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAK4B;AAC5B,4DAAoC;AAEpC,iCAAoD;AAMpD,wCAAgE;AAChE,kDAA8C;AAC9C,oCAA0C;AAC1C,8CAA2C;AAC3C,2DAA0D;AAC1D,mDAA+C;AAO/C,MAAM,eAAe,GAAG,CAAsC,EAQZ,EAAE,EAAE;QARQ,EAC5D,QAAQ,EACR,SAAS,EACT,EAAE,EACF,KAAK,EACL,cAAc,EACd,GAAG,OAE6C,EAD7C,SAAS,cAPgD,iEAQ7D,CADa;IAEZ,IAAA,uCAAmB,GAAE,CAAC;IACtB,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;IAE9D,OAAO,CACL,uBAAC,uBAAU,kBACT,OAAO,EAAC,SAAS,EACjB,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,KAAK,EACf,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAEjB,QAAQ,IACE,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAOjD,MAAM,aAAa,GAAG,CAAsC,EAQZ,EAAE,EAAE;QARQ,EAC1D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C;4BACpB,CAAC,CAAC,cAAc,EAAE,CAAC;wBACrB,CAAC,EACD,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE;4BAClB,CAAC,CAAC,eAAe,EAAE,CAAC;4BACpB,CAAC,CAAC,cAAc,EAAE,CAAC;wBACrB,CAAC,GACD,CACH,EACD,+CACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,OAAO,EAClB,KAAK,gDACA,SAAS,CAAC,cAAc,GACxB,SAAS,CAAC,gBAAgB,GAC1B,KAAK,KAEN,SAAS,CAAC,gBAAgB,mBAAM,cAAc,EAAG,EACjD,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,IACL,GACkB,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 type React from 'react';\nimport { useEffect, useRef, useState } 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';\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 useSpotlightContext();\n const classes = classNames('ndl-spotlight-header', className);\n\n return (\n <Typography\n variant=\"title-4\"\n ref={ref}\n as={as ?? 'div'}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\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 useSpotlightContext();\n const classes = classNames('ndl-spotlight-body', className);\n\n return (\n <Typography\n variant=\"body-medium\"\n className={classes}\n as={as ?? 'div'}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\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 [targetElement, setTargetElement] = useState<HTMLElement | null>(null);\n const actionsRef = useRef<HTMLDivElement | null>(null);\n\n const {\n isActiveSpotlight,\n isOpen,\n setActiveSpotlight,\n setIsOpen,\n registeredTargets,\n hasOverlay,\n } = useSpotlightContext();\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 <>\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({ ...htmlAttributes })}\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 </>\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"]}
@@ -92,8 +92,9 @@ const SpotlightProvider = ({ children, hasOverlay = true, isOverlayTransparent =
92
92
  return 0;
93
93
  }, [active, targets]);
94
94
  const getMaskStyle = () => {
95
- if (!targetRect || isOverlayTransparent)
95
+ if (!targetRect || isOverlayTransparent) {
96
96
  return {};
97
+ }
97
98
  const { left, top, width, height } = targetRect;
98
99
  const x = Math.max(0, left);
99
100
  const y = Math.max(0, top);
@@ -126,11 +127,13 @@ const SpotlightProvider = ({ children, hasOverlay = true, isOverlayTransparent =
126
127
  /** useEffect to update the target rect, so that the mask tracks the target element */
127
128
  (0, react_2.useEffect)(() => {
128
129
  var _a;
129
- if (active == null)
130
+ if (active === null) {
130
131
  return;
132
+ }
131
133
  const el = (_a = targets[active]) === null || _a === void 0 ? void 0 : _a.current;
132
- if (el === null || el === undefined)
134
+ if (el === null || el === undefined) {
133
135
  return;
136
+ }
134
137
  const update = () => setTargetRect(el.getBoundingClientRect());
135
138
  update();
136
139
  const ro = new ResizeObserver(update);
@@ -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,CAAC,GAAG,IAAA,gBAAQ,EAEpC,EAAE,CAAC,CAAC;IACN,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA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,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;AApKW,QAAA,iBAAiB,qBAoK5B;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) return {};\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) return;\n\n const el = targets[active]?.current;\n if (el === null || el === undefined) return;\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,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,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,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;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"]}
@@ -32,6 +32,17 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
+ var __rest = (this && this.__rest) || function (s, e) {
36
+ var t = {};
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
+ t[p] = s[p];
39
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
+ t[p[i]] = s[p[i]];
43
+ }
44
+ return t;
45
+ };
35
46
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
47
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
48
  };
@@ -64,7 +75,8 @@ const react_2 = __importStar(require("react"));
64
75
  const conditional_wrap_1 = require("../conditional-wrap");
65
76
  const SpotlightProvider_1 = require("./SpotlightProvider");
66
77
  const use_indicator_1 = require("./use-indicator");
67
- const SpotlightTarget = ({ id, hasPulse = true, indicatorVariant = 'border', indicatorPlacement = 'top-right', borderRadius, shouldFitToChildren = false, children, className, htmlAttributes, style, as, ref, asChild, }) => {
78
+ const SpotlightTarget = (_a) => {
79
+ var { id, hasPulse = true, indicatorVariant = 'border', indicatorPlacement = 'top-right', borderRadius, shouldFitToChildren = false, children, className, htmlAttributes, style, as, ref, asChild } = _a, restProps = __rest(_a, ["id", "hasPulse", "indicatorVariant", "indicatorPlacement", "borderRadius", "shouldFitToChildren", "children", "className", "htmlAttributes", "style", "as", "ref", "asChild"]);
68
80
  const Component = as !== null && as !== void 0 ? as : 'div';
69
81
  const { isActiveSpotlight, isOpen, setIsOpen, registerTarget, unregisterTarget, setActiveSpotlight, } = (0, SpotlightProvider_1.useSpotlightContext)();
70
82
  const internalRef = react_2.default.useRef(null);
@@ -148,7 +160,7 @@ const SpotlightTarget = ({ id, hasPulse = true, indicatorVariant = 'border', ind
148
160
  else if (e.code === 'Escape' && isActive) {
149
161
  setActiveSpotlight(null);
150
162
  }
151
- }, tabIndex: isActive ? 0 : undefined }, (isActive && { 'aria-label': 'Open spotlight' }), 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) })) })] }));
163
+ }, 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) })) })] }));
152
164
  };
153
165
  exports.SpotlightTarget = SpotlightTarget;
154
166
  //# sourceMappingURL=SpotlightTarget.js.map
@@ -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;AAoClB,MAAM,eAAe,GAAG,CAAC,EAC9B,EAAE,EACF,QAAQ,GAAG,IAAI,EACf,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K,OAAO,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,EAC1C,CAAC;wBACD,SAAS,CAAC,IAAI,CAAC,CAAC;wBAChB,CAAC,CAAC,cAAc,EAAE,CAAC;oBACrB,CAAC;yBAAM,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,QAAQ,EAAE,CAAC;wBAC3C,kBAAkB,CAAC,IAAI,CAAC,CAAC;oBAC3B,CAAC;gBACH,CAAC,EACD,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAC9B,CAAC,QAAQ,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,EAChD,cAAc,cAElB,uBAAC,kCAAe,IACd,UAAU,EAAE,QAAQ,EACpB,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAClB,gCAAK,KAAK,+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;AAxMW,QAAA,eAAe,mBAwM1B","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 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}: 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 mergedRefs = useMergeRefs<HTMLElement>([\n ref as React.RefObject<HTMLElement>,\n internalRef as React.RefObject<HTMLElement>,\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 {...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;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAAkE;AAClE,4DAAoC;AACpC,+CAAyC;AAGzC,0DAAsD;AACtD,2DAA0D;AAC1D,mDAIyB;AAoClB,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,UAAU,GAAG,IAAA,oBAAY,EAAc;QAC3C,GAAmC;QACnC,WAA2C;KAC5C,CAAC,CAAC;IACH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,WAAW,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACjC,cAAc,CAAC,EAAE,EAAE,WAA2C,CAAC,CAAC;QAClE,CAAC;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9B,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;AA1MW,QAAA,eAAe,mBA0M1B","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 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 mergedRefs = useMergeRefs<HTMLElement>([\n ref as React.RefObject<HTMLElement>,\n internalRef as React.RefObject<HTMLElement>,\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"]}
@@ -95,7 +95,7 @@ const SpotlightTour = ({ spotlights, dismissButtonLabel = 'Dismiss', backButtonL
95
95
  if (beforeActions !== undefined && beforeActions !== null) {
96
96
  return beforeActions;
97
97
  }
98
- return spotlights.length > 1 ? index + 1 + '/' + spotlights.length : null;
98
+ return spotlights.length > 1 ? `${index + 1}/${spotlights.length}` : null;
99
99
  }, [spotlights]);
100
100
  const getOnClose = (0, react_1.useCallback)((index, onClose) => {
101
101
  if (onClose) {
@@ -1 +1 @@
1
- {"version":3,"file":"SpotlightTour.js","sourceRoot":"","sources":["../../../src/spotlight/SpotlightTour.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqBA,iCAAoC;AAEpC,wDAAoD;AACpD,gDAA4C;AAC5C,2CAAmE;AACnE,2DAA0D;AAyBnD,MAAM,aAAa,GAAG,CAAC,EAC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C;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,GAAG,EAAE;YACV,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,QAAQ,EAAE,UAAU,CAAC,CACvB,CAAC;IAEF,OAAO,CACL,2DACG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;YACnC,MAAM,EACJ,OAAO,EACP,aAAa,EACb,YAAY,EACZ,OAAO,EACP,MAAM,KAEJ,SAAS,EADR,aAAa,UACd,SAAS,EAPP,iEAOL,CAAY,CAAC;YACd,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9C,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;YAChE,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9C,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAE3C,OAAO,CACL,uBAAC,qBAAS,oBAEJ,aAAa,IACjB,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,gBAAgB,EAC/B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,SAAS,KANZ,KAAK,CAOV,CACH,CAAC;QACJ,CAAC,CAAC,GACD,CACJ,CAAC;AACJ,CAAC,CAAC;AApLW,QAAA,aAAa,iBAoLxB","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 type React from 'react';\nimport { useCallback } from 'react';\n\nimport { OutlinedButton } from '../outlined-button';\nimport { TextButton } from '../text-button';\nimport { Spotlight, type SpotlightCloseAction } from './Spotlight';\nimport { useSpotlightContext } from './SpotlightProvider';\n\ntype SpotlightTourAction =\n | SpotlightCloseAction\n | 'dismiss'\n | 'back'\n | 'next'\n | 'close'\n | 'open';\n\ntype SpotlightTourProps = {\n /** An array of `Spotlight` component props objects. SpotlightTour overrides the following props, to simplify your implementation, if they are undefined: `actions`, `beforeActions`, `initialFocus`, `onClose`. If you want custom behaviour for a certain `Spotlight` you can set these props yourself. */\n spotlights: React.ComponentProps<typeof Spotlight>[];\n /** A string that will be the text for the dismiss button */\n dismissButtonLabel?: string;\n /** A string that will be the text for the back button */\n backButtonLabel?: string;\n /** A string that will be the text for the next button */\n nextButtonLabel?: string;\n /** A string that will be the text for the close button */\n closeButtonLabel?: string;\n /** A callback function that is called when some actions are performed inside a `Spotlight`. It receives two arguments: `target` (string identifying the `Spotlight` that the action was performed in) and `action` (string describing the action that has been performed. These actions can be \"dismiss\", \"back\", \"next\", \"close\", \"clickOutside\" or \"escapeKeyDown\") */\n onAction?: (target: string, action: SpotlightTourAction) => void;\n};\n\nexport const SpotlightTour = ({\n spotlights,\n dismissButtonLabel = 'Dismiss',\n backButtonLabel = 'Back',\n nextButtonLabel = 'Next',\n closeButtonLabel = 'Close',\n onAction,\n}: SpotlightTourProps) => {\n const { setActiveSpotlight, setIsOpen } = useSpotlightContext();\n\n const next = useCallback(\n (index: number) => {\n onAction?.(spotlights[index].target, 'next');\n setActiveSpotlight(spotlights[index + 1].target);\n },\n [onAction, spotlights, setActiveSpotlight],\n );\n\n const back = useCallback(\n (index: number) => {\n onAction?.(spotlights[index].target, 'back');\n setActiveSpotlight(spotlights[index - 1].target);\n },\n [onAction, spotlights, setActiveSpotlight],\n );\n\n const dismiss = useCallback(\n (index: number) => {\n onAction?.(spotlights[index].target, 'dismiss');\n setActiveSpotlight(null);\n setIsOpen(false);\n },\n [onAction, spotlights, setActiveSpotlight, setIsOpen],\n );\n\n const close = useCallback(\n (index: number) => {\n onAction?.(spotlights[index].target, 'close');\n setActiveSpotlight(null);\n setIsOpen(false);\n },\n [onAction, spotlights, setActiveSpotlight, setIsOpen],\n );\n\n const getActions = useCallback(\n (index: number, actions: React.ReactNode): React.ReactNode => {\n if (actions !== undefined && actions !== null) {\n return actions;\n }\n\n const isFirst = index === 0;\n const isLast = index === spotlights.length - 1;\n const hasMultiple = spotlights.length > 1;\n\n const newActions: React.ReactNode[] = [];\n\n if (!isLast && hasMultiple) {\n newActions.push(\n <TextButton onClick={() => dismiss(index)}>\n {dismissButtonLabel}\n </TextButton>,\n );\n }\n\n if (!isFirst && hasMultiple) {\n newActions.push(\n <TextButton onClick={() => back(index)}>\n {backButtonLabel}\n </TextButton>,\n );\n }\n\n if (isLast) {\n newActions.push(\n <OutlinedButton onClick={() => close(index)}>\n {closeButtonLabel}\n </OutlinedButton>,\n );\n } else {\n newActions.push(\n <OutlinedButton onClick={() => next(index)}>\n {nextButtonLabel}\n </OutlinedButton>,\n );\n }\n\n return newActions;\n },\n [\n spotlights,\n dismissButtonLabel,\n dismiss,\n backButtonLabel,\n back,\n closeButtonLabel,\n close,\n nextButtonLabel,\n next,\n ],\n );\n\n const getBeforeActions: (\n index: number,\n beforeActions: React.ReactNode,\n ) => React.ReactNode = useCallback(\n (index: number, beforeActions: React.ReactNode) => {\n if (beforeActions !== undefined && beforeActions !== null) {\n return beforeActions;\n }\n\n return spotlights.length > 1 ? index + 1 + '/' + spotlights.length : null;\n },\n [spotlights],\n );\n\n const getOnClose: (\n index: number,\n onClose: ((reason: SpotlightCloseAction) => void) | undefined,\n ) => ((reason: SpotlightCloseAction) => void) | undefined = useCallback(\n (\n index: number,\n onClose: ((reason: SpotlightCloseAction) => void) | undefined,\n ) => {\n if (onClose) {\n return onClose;\n }\n\n return (reason) => {\n onAction?.(spotlights[index].target, reason);\n };\n },\n [onAction, spotlights],\n );\n\n const getOnOpen: (\n index: number,\n onOpen: (() => void) | undefined,\n ) => (() => void) | undefined = useCallback(\n (index: number, onOpen: (() => void) | undefined) => {\n if (onOpen) {\n return onOpen;\n }\n\n return () => {\n onAction?.(spotlights[index].target, 'open');\n };\n },\n [onAction, spotlights],\n );\n\n return (\n <>\n {spotlights.map((spotlight, index) => {\n const {\n actions,\n beforeActions,\n initialFocus,\n onClose,\n onOpen,\n ...restSpotlight\n } = spotlight;\n const newActions = getActions(index, actions);\n const newBeforeActions = getBeforeActions(index, beforeActions);\n const newOnClose = getOnClose(index, onClose);\n const newOnOpen = getOnOpen(index, onOpen);\n\n return (\n <Spotlight\n key={index}\n {...restSpotlight}\n actions={newActions}\n beforeActions={newBeforeActions}\n initialFocus={initialFocus}\n onClose={newOnClose}\n onOpen={newOnOpen}\n />\n );\n })}\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"SpotlightTour.js","sourceRoot":"","sources":["../../../src/spotlight/SpotlightTour.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqBA,iCAAoC;AAEpC,wDAAoD;AACpD,gDAA4C;AAC5C,2CAAmE;AACnE,2DAA0D;AAyBnD,MAAM,aAAa,GAAG,CAAC,EAC5B,UAAU,EACV,kBAAkB,GAAG,SAAS,EAC9B,eAAe,GAAG,MAAM,EACxB,eAAe,GAAG,MAAM,EACxB,gBAAgB,GAAG,OAAO,EAC1B,QAAQ,GACW,EAAE,EAAE;IACvB,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,GAAG,IAAA,uCAAmB,GAAE,CAAC;IAEhE,MAAM,IAAI,GAAG,IAAA,mBAAW,EACtB,CAAC,KAAa,EAAE,EAAE;QAChB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,C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ACnC,MAAM,EACJ,OAAO,EACP,aAAa,EACb,YAAY,EACZ,OAAO,EACP,MAAM,KAEJ,SAAS,EADR,aAAa,UACd,SAAS,EAPP,iEAOL,CAAY,CAAC;YACd,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9C,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;YAChE,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9C,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAE3C,OAAO,CACL,uBAAC,qBAAS,oBAEJ,aAAa,IACjB,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,gBAAgB,EAC/B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,SAAS,KANZ,KAAK,CAOV,CACH,CAAC;QACJ,CAAC,CAAC,GACD,CACJ,CAAC;AACJ,CAAC,CAAC;AApLW,QAAA,aAAa,iBAoLxB","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 type React from 'react';\nimport { useCallback } from 'react';\n\nimport { OutlinedButton } from '../outlined-button';\nimport { TextButton } from '../text-button';\nimport { Spotlight, type SpotlightCloseAction } from './Spotlight';\nimport { useSpotlightContext } from './SpotlightProvider';\n\ntype SpotlightTourAction =\n | SpotlightCloseAction\n | 'dismiss'\n | 'back'\n | 'next'\n | 'close'\n | 'open';\n\ntype SpotlightTourProps = {\n /** An array of `Spotlight` component props objects. SpotlightTour overrides the following props, to simplify your implementation, if they are undefined: `actions`, `beforeActions`, `initialFocus`, `onClose`. If you want custom behaviour for a certain `Spotlight` you can set these props yourself. */\n spotlights: React.ComponentProps<typeof Spotlight>[];\n /** A string that will be the text for the dismiss button */\n dismissButtonLabel?: string;\n /** A string that will be the text for the back button */\n backButtonLabel?: string;\n /** A string that will be the text for the next button */\n nextButtonLabel?: string;\n /** A string that will be the text for the close button */\n closeButtonLabel?: string;\n /** A callback function that is called when some actions are performed inside a `Spotlight`. It receives two arguments: `target` (string identifying the `Spotlight` that the action was performed in) and `action` (string describing the action that has been performed. These actions can be \"dismiss\", \"back\", \"next\", \"close\", \"clickOutside\" or \"escapeKeyDown\") */\n onAction?: (target: string, action: SpotlightTourAction) => void;\n};\n\nexport const SpotlightTour = ({\n spotlights,\n dismissButtonLabel = 'Dismiss',\n backButtonLabel = 'Back',\n nextButtonLabel = 'Next',\n closeButtonLabel = 'Close',\n onAction,\n}: SpotlightTourProps) => {\n const { setActiveSpotlight, setIsOpen } = useSpotlightContext();\n\n const next = useCallback(\n (index: number) => {\n onAction?.(spotlights[index].target, 'next');\n setActiveSpotlight(spotlights[index + 1].target);\n },\n [onAction, spotlights, setActiveSpotlight],\n );\n\n const back = useCallback(\n (index: number) => {\n onAction?.(spotlights[index].target, 'back');\n setActiveSpotlight(spotlights[index - 1].target);\n },\n [onAction, spotlights, setActiveSpotlight],\n );\n\n const dismiss = useCallback(\n (index: number) => {\n onAction?.(spotlights[index].target, 'dismiss');\n setActiveSpotlight(null);\n setIsOpen(false);\n },\n [onAction, spotlights, setActiveSpotlight, setIsOpen],\n );\n\n const close = useCallback(\n (index: number) => {\n onAction?.(spotlights[index].target, 'close');\n setActiveSpotlight(null);\n setIsOpen(false);\n },\n [onAction, spotlights, setActiveSpotlight, setIsOpen],\n );\n\n const getActions = useCallback(\n (index: number, actions: React.ReactNode): React.ReactNode => {\n if (actions !== undefined && actions !== null) {\n return actions;\n }\n\n const isFirst = index === 0;\n const isLast = index === spotlights.length - 1;\n const hasMultiple = spotlights.length > 1;\n\n const newActions: React.ReactNode[] = [];\n\n if (!isLast && hasMultiple) {\n newActions.push(\n <TextButton onClick={() => dismiss(index)}>\n {dismissButtonLabel}\n </TextButton>,\n );\n }\n\n if (!isFirst && hasMultiple) {\n newActions.push(\n <TextButton onClick={() => back(index)}>\n {backButtonLabel}\n </TextButton>,\n );\n }\n\n if (isLast) {\n newActions.push(\n <OutlinedButton onClick={() => close(index)}>\n {closeButtonLabel}\n </OutlinedButton>,\n );\n } else {\n newActions.push(\n <OutlinedButton onClick={() => next(index)}>\n {nextButtonLabel}\n </OutlinedButton>,\n );\n }\n\n return newActions;\n },\n [\n spotlights,\n dismissButtonLabel,\n dismiss,\n backButtonLabel,\n back,\n closeButtonLabel,\n close,\n nextButtonLabel,\n next,\n ],\n );\n\n const getBeforeActions: (\n index: number,\n beforeActions: React.ReactNode,\n ) => React.ReactNode = useCallback(\n (index: number, beforeActions: React.ReactNode) => {\n if (beforeActions !== undefined && beforeActions !== null) {\n return beforeActions;\n }\n\n return spotlights.length > 1 ? `${index + 1}/${spotlights.length}` : null;\n },\n [spotlights],\n );\n\n const getOnClose: (\n index: number,\n onClose: ((reason: SpotlightCloseAction) => void) | undefined,\n ) => ((reason: SpotlightCloseAction) => void) | undefined = useCallback(\n (\n index: number,\n onClose: ((reason: SpotlightCloseAction) => void) | undefined,\n ) => {\n if (onClose) {\n return onClose;\n }\n\n return (reason) => {\n onAction?.(spotlights[index].target, reason);\n };\n },\n [onAction, spotlights],\n );\n\n const getOnOpen: (\n index: number,\n onOpen: (() => void) | undefined,\n ) => (() => void) | undefined = useCallback(\n (index: number, onOpen: (() => void) | undefined) => {\n if (onOpen) {\n return onOpen;\n }\n\n return () => {\n onAction?.(spotlights[index].target, 'open');\n };\n },\n [onAction, spotlights],\n );\n\n return (\n <>\n {spotlights.map((spotlight, index) => {\n const {\n actions,\n beforeActions,\n initialFocus,\n onClose,\n onOpen,\n ...restSpotlight\n } = spotlight;\n const newActions = getActions(index, actions);\n const newBeforeActions = getBeforeActions(index, beforeActions);\n const newOnClose = getOnClose(index, onClose);\n const newOnOpen = getOnOpen(index, onOpen);\n\n return (\n <Spotlight\n key={index}\n {...restSpotlight}\n actions={newActions}\n beforeActions={newBeforeActions}\n initialFocus={initialFocus}\n onClose={newOnClose}\n onOpen={newOnOpen}\n />\n );\n })}\n </>\n );\n};\n"]}
@@ -28,7 +28,7 @@ exports.OnTabs = exports.FixedPositioning = exports.TargetInDialog = exports.InS
28
28
  const jsx_runtime_1 = require("react/jsx-runtime");
29
29
  const chromatic_1 = __importDefault(require("chromatic"));
30
30
  const index_1 = require("../../index");
31
- const _1 = require("./");
31
+ const _1 = require(".");
32
32
  const componentMeta = {
33
33
  component: index_1.Spotlight,
34
34
  decorators: [
@@ -1 +1 @@
1
- {"version":3,"file":"spotlight.stories.js","sourceRoot":"","sources":["../../../../src/spotlight/stories/spotlight.stories.tsx"],"names":[],"mappings":";;;;;;;AAqBA,0DAAoC;AAEpC,uCAA2D;AAC3D,yBAmBY;AAOZ,MAAM,aAAa,GAAyB;IAC1C,SAAS,EAAE,iBAAS;IACpB,UAAU,EAAE;QACV,CAAC,OAAO,EAAE,EAAE,CAAC,CACX,uBAAC,yBAAiB,IAAC,UAAU,kBAC3B,uBAAC,OAAO,KAAG,GACO,CACrB;KACF;IACD,EAAE,EAAE,sBAAsB;IAC1B,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KAC5B;IACD,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,KAAK,EAAE,sBAAsB;CACf,CAAC;AAEjB,kBAAe,aAAa,CAAC;AAGhB,QAAA,SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,WAAW,EAAE,IAAA,mBAAW,GAAE;KAC3B;IACD,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SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,WAAW,EAAE,IAAA,mBAAW,GAAE;KAC3B;IACD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,wBAAqB;gBAC3B,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,qBAAkB;CAC3B,CAAC;AAEW,QAAA,cAAc,GAAU;IACnC,IAAI,EAAE;QACJ,WAAW,EAAE,IAAA,mBAAW,GAAE;KAC3B;IACD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,uBAAoB;gBAC1B,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,oBAAiB;CAC1B,CAAC;AAEW,QAAA,gBAAgB,GAAU;IACrC,IAAI,EAAE;QACJ,WAAW,EAAE,IAAA,mBAAW,GAAE;KAC3B;IACD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,+BAA4B;gBAClC,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,4BAAyB;CAClC,CAAC;AAEW,QAAA,MAAM,GAAU;IAC3B,IAAI,EAAE;QACJ,WAAW,EAAE,IAAA,mBAAW,GAAE;KAC3B;IACD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,qBAAkB;gBACxB,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,kBAAe;CACxB,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 { type Meta, type StoryObj } from '@storybook/react-vite';\nimport isChromatic from 'chromatic';\n\nimport { Spotlight, SpotlightProvider } from '../../index';\nimport {\n SpotlightFixedPositioning,\n SpotlightFixedPositioningSrc,\n SpotlightInDialog,\n SpotlightInDialogSrc,\n SpotlightInSideNav,\n SpotlightInSideNavSrc,\n SpotlightOnTabs,\n SpotlightOnTabsSrc,\n SpotlightTour,\n SpotlightTourSrc,\n SpotlightWithIcon,\n SpotlightWithIconSrc,\n SpotlightWithImage,\n SpotlightWithImageSrc,\n SpotlightWithLabel,\n SpotlightWithLabelSrc,\n SpotlightWithPointer,\n SpotlightWithPointerSrc,\n} from './';\n\ntype ComponentProps = React.ComponentProps<typeof Spotlight> & {\n isChromatic: boolean;\n hasPulse?: boolean;\n};\n\nconst componentMeta: Meta<ComponentProps> = {\n component: Spotlight,\n decorators: [\n (StoryFn) => (\n <SpotlightProvider hasOverlay>\n <StoryFn />\n </SpotlightProvider>\n ),\n ],\n id: 'components-spotlight',\n parameters: {\n controls: { disable: true },\n },\n tags: ['docsPage'],\n title: 'Components/Spotlight',\n} satisfies Meta;\n\nexport default componentMeta;\ntype Story = StoryObj<typeof componentMeta>;\n\nexport const WithLabel: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightWithLabelSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightWithLabel,\n};\n\nexport const WithIcon: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightWithIconSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightWithIcon,\n};\n\nexport const WithImage: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightWithImageSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightWithImage,\n};\n\nexport const WithPointerIndicator: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightWithPointerSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightWithPointer,\n};\n\nexport const Tour: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: SpotlightTourSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightTour,\n};\n\nexport const InSideNav: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightInSideNavSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightInSideNav,\n};\n\nexport const TargetInDialog: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightInDialogSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightInDialog,\n};\n\nexport const FixedPositioning: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightFixedPositioningSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightFixedPositioning,\n};\n\nexport const OnTabs: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightOnTabsSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightOnTabs,\n};\n"]}
1
+ {"version":3,"file":"spotlight.stories.js","sourceRoot":"","sources":["../../../../src/spotlight/stories/spotlight.stories.tsx"],"names":[],"mappings":";;;;;;;AAqBA,0DAAoC;AAEpC,uCAA2D;AAC3D,wBAmBW;AAOX,MAAM,aAAa,GAAyB;IAC1C,SAAS,EAAE,iBAAS;IACpB,UAAU,EAAE;QACV,CAAC,O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QACJ,WAAW,EAAE,IAAA,mBAAW,GAAE;KAC3B;IACD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,qBAAkB;gBACxB,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,kBAAe;CACxB,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 { type Meta, type StoryObj } from '@storybook/react-vite';\nimport isChromatic from 'chromatic';\n\nimport { Spotlight, SpotlightProvider } from '../../index';\nimport {\n SpotlightFixedPositioning,\n SpotlightFixedPositioningSrc,\n SpotlightInDialog,\n SpotlightInDialogSrc,\n SpotlightInSideNav,\n SpotlightInSideNavSrc,\n SpotlightOnTabs,\n SpotlightOnTabsSrc,\n SpotlightTour,\n SpotlightTourSrc,\n SpotlightWithIcon,\n SpotlightWithIconSrc,\n SpotlightWithImage,\n SpotlightWithImageSrc,\n SpotlightWithLabel,\n SpotlightWithLabelSrc,\n SpotlightWithPointer,\n SpotlightWithPointerSrc,\n} from '.';\n\ntype ComponentProps = React.ComponentProps<typeof Spotlight> & {\n isChromatic: boolean;\n hasPulse?: boolean;\n};\n\nconst componentMeta: Meta<ComponentProps> = {\n component: Spotlight,\n decorators: [\n (StoryFn) => (\n <SpotlightProvider hasOverlay>\n <StoryFn />\n </SpotlightProvider>\n ),\n ],\n id: 'components-spotlight',\n parameters: {\n controls: { disable: true },\n },\n tags: ['docsPage'],\n title: 'Components/Spotlight',\n} satisfies Meta;\n\nexport default componentMeta;\ntype Story = StoryObj<typeof componentMeta>;\n\nexport const WithLabel: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightWithLabelSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightWithLabel,\n};\n\nexport const WithIcon: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightWithIconSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightWithIcon,\n};\n\nexport const WithImage: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightWithImageSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightWithImage,\n};\n\nexport const WithPointerIndicator: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightWithPointerSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightWithPointer,\n};\n\nexport const Tour: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: SpotlightTourSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightTour,\n};\n\nexport const InSideNav: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightInSideNavSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightInSideNav,\n};\n\nexport const TargetInDialog: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightInDialogSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightInDialog,\n};\n\nexport const FixedPositioning: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightFixedPositioningSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightFixedPositioning,\n};\n\nexport const OnTabs: Story = {\n args: {\n isChromatic: isChromatic(),\n },\n parameters: {\n docs: {\n source: {\n code: SpotlightOnTabsSrc,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: SpotlightOnTabs,\n};\n"]}
@@ -65,8 +65,9 @@ const calcOffset = (variant, placement, rects) => {
65
65
  };
66
66
  };
67
67
  const getComputedBorderRadius = (element) => {
68
- if (!element)
68
+ if (!element) {
69
69
  return undefined;
70
+ }
70
71
  // First check if there's an inline style
71
72
  if (element.style.borderRadius) {
72
73
  return element.style.borderRadius;
@@ -1 +1 @@
1
- {"version":3,"file":"use-indicator.js","sourceRoot":"","sources":["../../../src/spotlight/use-indicator.tsx"],"names":[],"mappings":";;;;;AAwHA,oCA8CC;AAtKD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAK4B;AAC5B,4DAAoC;AACpC,iCAAgC;AA8BhC,MAAM,aAAa,GAA2B;IAC5C,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,UAAU,GAAG,CACjB,OAAyB,EACzB,SAA6B,EAC7B,KAAmB,EACnB,EAAE;IACF,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,4DAA4D;QAC5D,OAAO;YACL,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;SAClE,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrE;;;SAGK;IAEL,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,iBAAiB,KAAK,QAAQ,EAAE,CAAC;QACnC,kFAAkF;QAClF,QAAQ,GAAG,CAAC,CAAC,GAAG,KAAK,CA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CAAC,CAC9C,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 {\n autoUpdate,\n type ElementRects,\n offset,\n useFloating,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { useMemo } from 'react';\n\nexport type IndicatorVariant = 'border' | 'point';\n\ninterface IndicatorOptions {\n isOpen: boolean;\n indicatorVariant?: IndicatorVariant;\n indicatorPlacement?: IndicatorPlacement;\n targetRef: React.RefObject<HTMLElement | undefined | null>;\n hasPulse?: boolean;\n hasAnchorPortal?: boolean;\n}\n\ninterface UseIndicatorReturn extends ReturnType<typeof useFloating> {\n style: React.CSSProperties;\n indicatorClasses?: string;\n hasAnchorPortal?: boolean;\n}\n\nexport type IndicatorPlacement =\n | 'top-left'\n | 'top-middle'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-middle'\n | 'bottom-right'\n | 'middle-left'\n | 'middle-middle'\n | 'middle-right';\n\nconst crossAxisMult: Record<string, number> = {\n left: -1,\n middle: 0,\n right: 1,\n};\n\nconst calcOffset = (\n variant: IndicatorVariant,\n placement: IndicatorPlacement,\n rects: ElementRects,\n) => {\n if (variant === 'border') {\n // Border variant is always centered around the middle point\n return {\n crossAxis: 0,\n mainAxis: -rects.reference.height / 2 - rects.floating.height / 2,\n };\n }\n\n const [mainAxisPlacement, crossAxisPlacement] = placement.split('-');\n /** Note for future reference:\n * Main axis (vertical) is zero at the bottom border of the target.\n * Cross axis (horizontal) is zero at the middle of the target\n * */\n\n let mainAxis = 0;\n if (mainAxisPlacement === 'bottom') {\n // put the indicator one height of the point above the bottom border of the target\n mainAxis = -2 * rects.floating.height;\n } else if (mainAxisPlacement === 'middle') {\n // put the indicator in the middle of the target\n mainAxis = -rects.reference.height / 2 - rects.floating.height / 2;\n } else if (mainAxisPlacement === 'top') {\n // put the indicator one height of the point below the top border of the target\n mainAxis = -rects.reference.height + rects.floating.height;\n }\n\n return {\n crossAxis:\n crossAxisMult[crossAxisPlacement] *\n (rects.reference.width / 2 - rects.floating.width * 1.5),\n mainAxis,\n };\n};\n\nconst getComputedBorderRadius = (\n element: HTMLElement | null | undefined,\n): string | undefined => {\n if (!element) return undefined;\n\n // First check if there's an inline style\n if (element.style.borderRadius) {\n return element.style.borderRadius;\n }\n\n // If no inline style, get the computed style (includes CSS classes)\n const computedStyle = window.getComputedStyle(element);\n const borderRadius = computedStyle.borderRadius;\n\n // Return undefined if border-radius is '0px' or empty\n return borderRadius && borderRadius !== '0px' ? borderRadius : undefined;\n};\n\nexport function useIndicator({\n isOpen,\n indicatorVariant = 'border',\n indicatorPlacement = 'top-right',\n targetRef,\n hasPulse = true,\n}: IndicatorOptions): UseIndicatorReturn {\n const data = useFloating({\n elements: {\n reference: targetRef?.current,\n },\n middleware: [\n offset(({ rects }) =>\n calcOffset(indicatorVariant, indicatorPlacement, rects),\n ),\n ],\n open: isOpen,\n placement: 'bottom',\n whileElementsMounted: autoUpdate,\n });\n\n return useMemo(\n () => ({\n ...data,\n indicatorClasses: classNames('ndl-spotlight-target-indicator', {\n 'ndl-spotlight-target-indicator-border': indicatorVariant === 'border',\n 'ndl-spotlight-target-indicator-point': indicatorVariant === 'point',\n 'ndl-spotlight-target-pulse': hasPulse,\n }),\n style: {\n borderRadius:\n indicatorVariant === 'border'\n ? getComputedBorderRadius(targetRef?.current)\n : '50%',\n height:\n indicatorVariant === 'border'\n ? `${targetRef?.current?.clientHeight ?? 0}px`\n : '8px',\n width:\n indicatorVariant === 'border'\n ? `${targetRef?.current?.clientWidth ?? 0}px`\n : '8px',\n },\n }),\n [data, indicatorVariant, targetRef, hasPulse],\n );\n}\n"]}
1
+ {"version":3,"file":"use-indicator.js","sourceRoot":"","sources":["../../../src/spotlight/use-indicator.tsx"],"names":[],"mappings":";;;;;AA0HA,oCA8CC;AAxKD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAK4B;AAC5B,4DAAoC;AACpC,iCAAgC;AA8BhC,MAAM,aAAa,GAA2B;IAC5C,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,UAAU,GAAG,CACjB,OAAyB,EACzB,SAA6B,EAC7B,KAAmB,EACnB,EAAE;IACF,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,4DAA4D;QAC5D,OAAO;YACL,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;SAClE,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrE;;;SAGK;IAEL,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,iBAAiB,KAAK,QAAQ,EAAE,CAAC;QACnC,kFAAkF;QAClF,QAAQ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxC,CAAC;SAAM,IAAI,iBAAiB,KAAK,QAAQ,EAAE,CAAC;QAC1C,gDAAgD;QAChD,QAAQ,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACrE,CAAC;SAAM,IAAI,iBAAiB,KAAK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EAAE,kBAAkB,EAAE,KAAK,CAAC,CACxD;SACF;QACD,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;QACnB,oBAAoB,EAAE,kBAAU;KACjC,CAAC,CAAC;IAEH,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE;;QAAC,OAAA,iCACD,IAAI,KACP,gBAAgB,EAAE,IAAA,oBAAU,EAAC,gCAAgC,EAAE;gBAC7D,uCAAuC,EAAE,gBAAgB,KAAK,QAAQ;gBACtE,sCAAsC,EAAE,gBAAgB,KAAK,OAAO;gBACpE,4BAA4B,EAAE,QAAQ;aACvC,CAAC,EACF,KAAK,EAAE;gBACL,YAAY,EACV,gBAAgB,KAAK,QAAQ;oBAC3B,CAAC,CAAC,uBAAuB,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAC;oBAC7C,CAAC,CAAC,KAAK;gBACX,MAAM,EACJ,gBAAgB,KAAK,QAAQ;oBAC3B,CAAC,CAAC,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,0CAAE,YAAY,mCAAI,CAAC,IAAI;oBAC9C,CAAC,CAAC,KAAK;gBACX,KAAK,EACH,gBAAgB,KAAK,QAAQ;oBAC3B,CAAC,CAAC,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,0CAAE,WAAW,mCAAI,CAAC,IAAI;oBAC7C,CAAC,CAAC,KAAK;aACZ,IACD,CAAA;KAAA,EACF,CAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,CAAC,CAC9C,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 {\n autoUpdate,\n type ElementRects,\n offset,\n useFloating,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { useMemo } from 'react';\n\nexport type IndicatorVariant = 'border' | 'point';\n\ninterface IndicatorOptions {\n isOpen: boolean;\n indicatorVariant?: IndicatorVariant;\n indicatorPlacement?: IndicatorPlacement;\n targetRef: React.RefObject<HTMLElement | undefined | null>;\n hasPulse?: boolean;\n hasAnchorPortal?: boolean;\n}\n\ninterface UseIndicatorReturn extends ReturnType<typeof useFloating> {\n style: React.CSSProperties;\n indicatorClasses?: string;\n hasAnchorPortal?: boolean;\n}\n\nexport type IndicatorPlacement =\n | 'top-left'\n | 'top-middle'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-middle'\n | 'bottom-right'\n | 'middle-left'\n | 'middle-middle'\n | 'middle-right';\n\nconst crossAxisMult: Record<string, number> = {\n left: -1,\n middle: 0,\n right: 1,\n};\n\nconst calcOffset = (\n variant: IndicatorVariant,\n placement: IndicatorPlacement,\n rects: ElementRects,\n) => {\n if (variant === 'border') {\n // Border variant is always centered around the middle point\n return {\n crossAxis: 0,\n mainAxis: -rects.reference.height / 2 - rects.floating.height / 2,\n };\n }\n\n const [mainAxisPlacement, crossAxisPlacement] = placement.split('-');\n /** Note for future reference:\n * Main axis (vertical) is zero at the bottom border of the target.\n * Cross axis (horizontal) is zero at the middle of the target\n * */\n\n let mainAxis = 0;\n if (mainAxisPlacement === 'bottom') {\n // put the indicator one height of the point above the bottom border of the target\n mainAxis = -2 * rects.floating.height;\n } else if (mainAxisPlacement === 'middle') {\n // put the indicator in the middle of the target\n mainAxis = -rects.reference.height / 2 - rects.floating.height / 2;\n } else if (mainAxisPlacement === 'top') {\n // put the indicator one height of the point below the top border of the target\n mainAxis = -rects.reference.height + rects.floating.height;\n }\n\n return {\n crossAxis:\n crossAxisMult[crossAxisPlacement] *\n (rects.reference.width / 2 - rects.floating.width * 1.5),\n mainAxis,\n };\n};\n\nconst getComputedBorderRadius = (\n element: HTMLElement | null | undefined,\n): string | undefined => {\n if (!element) {\n return undefined;\n }\n\n // First check if there's an inline style\n if (element.style.borderRadius) {\n return element.style.borderRadius;\n }\n\n // If no inline style, get the computed style (includes CSS classes)\n const computedStyle = window.getComputedStyle(element);\n const borderRadius = computedStyle.borderRadius;\n\n // Return undefined if border-radius is '0px' or empty\n return borderRadius && borderRadius !== '0px' ? borderRadius : undefined;\n};\n\nexport function useIndicator({\n isOpen,\n indicatorVariant = 'border',\n indicatorPlacement = 'top-right',\n targetRef,\n hasPulse = true,\n}: IndicatorOptions): UseIndicatorReturn {\n const data = useFloating({\n elements: {\n reference: targetRef?.current,\n },\n middleware: [\n offset(({ rects }) =>\n calcOffset(indicatorVariant, indicatorPlacement, rects),\n ),\n ],\n open: isOpen,\n placement: 'bottom',\n whileElementsMounted: autoUpdate,\n });\n\n return useMemo(\n () => ({\n ...data,\n indicatorClasses: classNames('ndl-spotlight-target-indicator', {\n 'ndl-spotlight-target-indicator-border': indicatorVariant === 'border',\n 'ndl-spotlight-target-indicator-point': indicatorVariant === 'point',\n 'ndl-spotlight-target-pulse': hasPulse,\n }),\n style: {\n borderRadius:\n indicatorVariant === 'border'\n ? getComputedBorderRadius(targetRef?.current)\n : '50%',\n height:\n indicatorVariant === 'border'\n ? `${targetRef?.current?.clientHeight ?? 0}px`\n : '8px',\n width:\n indicatorVariant === 'border'\n ? `${targetRef?.current?.clientWidth ?? 0}px`\n : '8px',\n },\n }),\n [data, indicatorVariant, targetRef, hasPulse],\n );\n}\n"]}
@@ -121,7 +121,7 @@ const StatusLabel = (_a) => {
121
121
  'ndl-small': size === 'small',
122
122
  });
123
123
  const Component = as !== null && as !== void 0 ? as : 'span';
124
- return ((0, jsx_runtime_1.jsx)(Component, Object.assign({ role: "status", className: classes, style: style, ref: ref }, htmlAttributes, restProps, { children: (0, jsx_runtime_1.jsxs)("div", { className: "ndl-status-label-content", children: [icon, (0, jsx_runtime_1.jsx)("span", {
124
+ return ((0, jsx_runtime_1.jsx)(Component, Object.assign({ role: "status", className: classes, style: style, ref: ref }, restProps, htmlAttributes, { children: (0, jsx_runtime_1.jsxs)("div", { className: "ndl-status-label-content", children: [icon, (0, jsx_runtime_1.jsx)("span", {
125
125
  // To enable native tooltip on hover if the children is a string
126
126
  title: typeof children === 'string' ? children : 'status label', className: "ndl-status-label-text", children: children })] }) })));
127
127
  };
@@ -1 +1 @@
1
- {"version":3,"file":"StatusLabel.js","sourceRoot":"","sources":["../../../src/status-label/StatusLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAIpC,oCAA6E;AA8B7E,MAAM,mBAAmB,GAAG;IAC1B,MAAM;IACN,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,WAAW;CACH,CAAC;AAEX,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,CAAU,CAAC;AAEzE,MAAM,WAAW,GAAG,CAAuC,EAYX,EAAE,EAAE;QAZO,EAChE,EAAE,EACF,OAAO,GAAG,SAAS,EACnB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,KAAK,EACf,cAAc,EACd,IAAI,GAAG,OAAO,EACd,GAAG,OAEkD,EADlD,SAAS,cAXoD,uGAYjE,CADa;IAEZ,IAAI,WAAmB,CAAC;IACxB,IAAI,IAA4B,CAAC;IAEjC,iDAAiD;IACjD,IAAI,CAAC,OAAO,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACzD,CAAC;IAED,4DAA4D;IA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AW,EAAE,IAAI,KAAK,OAAO;QAC7B,cAAc,EAAE,IAAI,KAAK,UAAU;QACnC,iBAAiB,EAAE,IAAI,KAAK,aAAa;QACzC,WAAW,EAAE,IAAI,KAAK,OAAO;KAC9B,CAAC,CAAC;IAEH,MAAM,SAAS,GAAsB,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,MAAM,CAAC;IAElD,OAAO,CACL,uBAAC,SAAS,kBACR,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,IACJ,cAAc,EACd,SAAS,cAEb,iCAAK,SAAS,EAAC,0BAA0B,aACtC,IAAI,EACL;oBACE,gEAAgE;oBAChE,KAAK,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,EAC/D,SAAS,EAAC,uBAAuB,YAEhC,QAAQ,GACJ,IACH,IACI,CACb,CAAC;AACJ,CAAC,CAAC;AAjHW,QAAA,WAAW,eAiHtB","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 PolymorphicCommonProps } from '../_common/types';\nimport { CircleIcon, RhombusIcon, SquareIcon, TriangleIcon } from '../icons';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype EventTypeStatusLabelProps = {\n /** Additional Classnames */\n className?: string;\n\n /** The content displayed inside the status label */\n children: React.ReactNode;\n\n /** Color of the status label that indicates its purpose. */\n variant?: (typeof StatusLabelVariants)[number];\n\n /** Fill type of status label, determines the background and border styles. */\n fill?: (typeof StatusLabelFill)[number];\n\n /** Whether the status label have an icon */\n hasIcon?: boolean;\n\n /** Size of the status label */\n size?: 'small' | 'large';\n};\n\nconst StatusLabelVariants = [\n 'info',\n 'success',\n 'warning',\n 'danger',\n 'default',\n 'discovery',\n] as const;\n\nconst StatusLabelFill = ['filled', 'outlined', 'semi-filled', 'clean'] as const;\n\nexport const StatusLabel = <T extends React.ElementType = 'span'>({\n as,\n variant = 'default',\n children,\n className,\n style,\n fill = 'filled',\n hasIcon = false,\n htmlAttributes,\n size = 'large',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, EventTypeStatusLabelProps>) => {\n let baseClasses: string;\n let icon: React.ReactNode | null;\n\n // Clean Status label without icon is not allowed\n if (!hasIcon && fill === 'clean') {\n console.error('Clean StatusLabel has to have an icon');\n }\n\n // All colors map to the light-theme palette except the info\n const mappedColor = variant === 'info' ? 'primary' : variant;\n\n if (hasIcon) {\n const isFilled = fill === 'filled';\n if (mappedColor === 'default') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-neutral-bg-status)';\n icon = <SquareIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'primary') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-primary-bg-status)';\n icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'success') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-success-bg-status)';\n icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'danger') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-danger-bg-status)';\n icon = <RhombusIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'warning') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-warning-bg-status)';\n icon = <TriangleIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'discovery') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-discovery-bg-status)';\n icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n }\n }\n\n if (mappedColor === 'default') {\n baseClasses = classNames({\n [`n-bg-neutral-bg-default n-text-neutral-text-weak n-border-neutral-border-strong`]:\n fill === 'semi-filled',\n [`n-bg-neutral-bg-strongest n-text-neutral-text-inverse`]:\n fill === 'filled',\n [`n-text-neutral-text-weak n-border-neutral-border-strong`]:\n fill === 'outlined',\n [`n-text-neutral-text-weaker`]: fill === 'clean',\n });\n } else {\n baseClasses = classNames({\n [`n-bg-${mappedColor}-bg-strong n-text-neutral-text-inverse`]:\n fill === 'filled',\n [`n-text-${mappedColor}-text n-border-${mappedColor}-border-strong`]:\n fill === 'outlined',\n [`n-bg-${mappedColor}-bg-weak n-text-${mappedColor}-text n-border-${mappedColor}-border-weak`]:\n fill === 'semi-filled',\n [`n-text-neutral-text-default`]: fill === 'clean',\n });\n }\n\n const classes = classNames('ndl-status-label', baseClasses, className, {\n 'ndl-clean': fill === 'clean',\n 'ndl-filled': fill === 'filled',\n 'ndl-large': size === 'large',\n 'ndl-outlined': fill === 'outlined',\n 'ndl-semi-filled': fill === 'semi-filled',\n 'ndl-small': size === 'small',\n });\n\n const Component: React.ElementType = as ?? 'span';\n\n return (\n <Component\n role=\"status\"\n className={classes}\n style={style}\n ref={ref}\n {...htmlAttributes}\n {...restProps}\n >\n <div className=\"ndl-status-label-content\">\n {icon}\n <span\n // To enable native tooltip on hover if the children is a string\n title={typeof children === 'string' ? children : 'status label'}\n className=\"ndl-status-label-text\"\n >\n {children}\n </span>\n </div>\n </Component>\n );\n};\n"]}
1
+ {"version":3,"file":"StatusLabel.js","sourceRoot":"","sources":["../../../src/status-label/StatusLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;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c,EAC/D,SAAS,EAAC,uBAAuB,YAEhC,QAAQ,GACJ,IACH,IACI,CACb,CAAC;AACJ,CAAC,CAAC;AAjHW,QAAA,WAAW,eAiHtB","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 PolymorphicCommonProps } from '../_common/types';\nimport { CircleIcon, RhombusIcon, SquareIcon, TriangleIcon } from '../icons';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype EventTypeStatusLabelProps = {\n /** Additional Classnames */\n className?: string;\n\n /** The content displayed inside the status label */\n children: React.ReactNode;\n\n /** Color of the status label that indicates its purpose. */\n variant?: (typeof StatusLabelVariants)[number];\n\n /** Fill type of status label, determines the background and border styles. */\n fill?: (typeof StatusLabelFill)[number];\n\n /** Whether the status label have an icon */\n hasIcon?: boolean;\n\n /** Size of the status label */\n size?: 'small' | 'large';\n};\n\nconst StatusLabelVariants = [\n 'info',\n 'success',\n 'warning',\n 'danger',\n 'default',\n 'discovery',\n] as const;\n\nconst StatusLabelFill = ['filled', 'outlined', 'semi-filled', 'clean'] as const;\n\nexport const StatusLabel = <T extends React.ElementType = 'span'>({\n as,\n variant = 'default',\n children,\n className,\n style,\n fill = 'filled',\n hasIcon = false,\n htmlAttributes,\n size = 'large',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, EventTypeStatusLabelProps>) => {\n let baseClasses: string;\n let icon: React.ReactNode | null;\n\n // Clean Status label without icon is not allowed\n if (!hasIcon && fill === 'clean') {\n console.error('Clean StatusLabel has to have an icon');\n }\n\n // All colors map to the light-theme palette except the info\n const mappedColor = variant === 'info' ? 'primary' : variant;\n\n if (hasIcon) {\n const isFilled = fill === 'filled';\n if (mappedColor === 'default') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-neutral-bg-status)';\n icon = <SquareIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'primary') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-primary-bg-status)';\n icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'success') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-success-bg-status)';\n icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'danger') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-danger-bg-status)';\n icon = <RhombusIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'warning') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-warning-bg-status)';\n icon = <TriangleIcon htmlAttributes={{ color: fillColor }} />;\n } else if (mappedColor === 'discovery') {\n const fillColor = isFilled\n ? 'currentColor'\n : 'var(--theme-color-discovery-bg-status)';\n icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n }\n }\n\n if (mappedColor === 'default') {\n baseClasses = classNames({\n [`n-bg-neutral-bg-default n-text-neutral-text-weak n-border-neutral-border-strong`]:\n fill === 'semi-filled',\n [`n-bg-neutral-bg-strongest n-text-neutral-text-inverse`]:\n fill === 'filled',\n [`n-text-neutral-text-weak n-border-neutral-border-strong`]:\n fill === 'outlined',\n [`n-text-neutral-text-weaker`]: fill === 'clean',\n });\n } else {\n baseClasses = classNames({\n [`n-bg-${mappedColor}-bg-strong n-text-neutral-text-inverse`]:\n fill === 'filled',\n [`n-text-${mappedColor}-text n-border-${mappedColor}-border-strong`]:\n fill === 'outlined',\n [`n-bg-${mappedColor}-bg-weak n-text-${mappedColor}-text n-border-${mappedColor}-border-weak`]:\n fill === 'semi-filled',\n [`n-text-neutral-text-default`]: fill === 'clean',\n });\n }\n\n const classes = classNames('ndl-status-label', baseClasses, className, {\n 'ndl-clean': fill === 'clean',\n 'ndl-filled': fill === 'filled',\n 'ndl-large': size === 'large',\n 'ndl-outlined': fill === 'outlined',\n 'ndl-semi-filled': fill === 'semi-filled',\n 'ndl-small': size === 'small',\n });\n\n const Component: React.ElementType = as ?? 'span';\n\n return (\n <Component\n role=\"status\"\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-status-label-content\">\n {icon}\n <span\n // To enable native tooltip on hover if the children is a string\n title={typeof children === 'string' ? children : 'status label'}\n className=\"ndl-status-label-text\"\n >\n {children}\n </span>\n </div>\n </Component>\n );\n};\n"]}
@@ -66,8 +66,9 @@ const Switch = (_a) => {
66
66
  }, [isIndeterminate]);
67
67
  /** TODO: Label handling. We can get rid of this annoying stuff as soon as we do proper form control. */
68
68
  const labelContent = (0, react_2.useMemo)(() => {
69
- if (Boolean(label) === false)
69
+ if (Boolean(label) === false) {
70
70
  return null;
71
+ }
71
72
  if (typeof label === 'string') {
72
73
  return ((0, jsx_runtime_1.jsx)("span", { title: label, className: "ndl-switch-label-text", children: label }));
73
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/switch/Switch.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,8CAAkD;AAClD,4DAAoC;AACpC,iCAAmD;AAGnD,oFAA8E;AAC9E,4CAAwD;AAkCjD,MAAM,MAAM,GAAG,CAAC,EAiBa,EAAE,EAAE;;QAjBjB,EACrB,SAAS,EACT,gBAAgB,EAChB,eAAe,GAAG,KAAK,EACvB,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,KAAK,EACl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AuB,YAClD,KAAK,GACD,CACR,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;YAC7D,IAAA,4BAAoB,EAClB,6GAA6G,CAC9G,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,OAAO,CACL,mCAAO,SAAS,EAAE,oBAAoB,aACnC,eAAe,KAAK,IAAI,IAAI,YAAY,EACzC,gDACE,GAAG,EAAE,UAAU,EACf,IAAI,EAAC,UAAU,EACf,IAAI,EAAC,QAAQ,gBACD,SAAS,EACrB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,IACpB,SAAS,EACT,cAAc,EAClB,EACD,OAAO,CAAC,eAAe,CAAC,KAAK,KAAK,IAAI,YAAY,IAC7C,CACT,CAAC;AACJ,CAAC,CAAC;AAtFW,QAAA,MAAM,UAsFjB","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 { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport { type CommonProps, type HtmlAttributes } from '../_common/types';\nimport { useSemiControlledInput } from '../_common/use-semi-controlled-input';\nimport { needleWarningMessage } from '../_common/utils';\n\ntype SwitchProps = {\n /** Whether the switch is checked */\n isChecked?: boolean;\n /** Checks the input by default in uncontrolled mode */\n isDefaultChecked?: boolean; // isDefaultChecked sounds weird to me?\n /** Whether the switch is indeterminate */\n isIndeterminate?: boolean;\n /** Whether the switch is disabled */\n isDisabled?: boolean;\n /** Whether the switch & label should take the full available width of its container */\n isFluid?: boolean;\n /** The value of the switch */\n value?: HtmlAttributes<'input'>['value']; // should this be required?\n /** Whether the label should be displayed before the switch */\n hasLeadingLabel?: boolean;\n /** The callback function triggered when the switch value changes */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n /** The callback function triggered when the switch is clicked */\n onClick?: (event: React.MouseEvent<HTMLInputElement>) => void;\n} & (\n | {\n /** The aria label of the switch. Required if the label is not a string. */\n ariaLabel: string;\n /** The label of the switch. If not a string, supply an aria label for screen reader support. */\n label?: undefined;\n }\n | {\n ariaLabel?: string;\n label: React.ReactNode;\n }\n);\n\nexport const Switch = ({\n isChecked,\n isDefaultChecked,\n isIndeterminate = false,\n isFluid = false,\n isDisabled = false,\n hasLeadingLabel,\n ariaLabel,\n onChange,\n onClick,\n value,\n label,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'input', SwitchProps>) => {\n const internalRef = useRef<HTMLInputElement>(null);\n const mergedRefs = useMergeRefs([internalRef, ref]);\n\n const [isCheckedState, internalOnChange] = useSemiControlledInput({\n inputType: 'switch',\n isControlled: isChecked !== undefined,\n onChange,\n state: isChecked ?? isDefaultChecked ?? false,\n });\n\n const labelWrappingClasses = classNames('ndl-switch-label', {\n 'ndl-disabled': isDisabled,\n 'ndl-fluid': isFluid,\n });\n\n const switchClasses = classNames('ndl-switch', className, {\n 'ndl-disabled': isDisabled,\n });\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.indeterminate = isIndeterminate;\n }\n }, [isIndeterminate]);\n\n /** TODO: Label handling. We can get rid of this annoying stuff as soon as we do proper form control. */\n const labelContent = useMemo(() => {\n if (Boolean(label) === false) return null;\n\n if (typeof label === 'string') {\n return (\n <span title={label} className=\"ndl-switch-label-text\">\n {label}\n </span>\n );\n }\n return label;\n }, [label]);\n\n useEffect(() => {\n if (Boolean(label) === false && Boolean(ariaLabel) === false) {\n needleWarningMessage(\n 'Switch needs a valid label or ariaLabel: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI',\n );\n }\n }, [ariaLabel, label]);\n\n return (\n <label className={labelWrappingClasses}>\n {hasLeadingLabel === true && labelContent}\n <input\n ref={mergedRefs}\n type=\"checkbox\"\n role=\"switch\"\n aria-label={ariaLabel}\n disabled={isDisabled}\n checked={isCheckedState}\n onClick={onClick}\n onChange={internalOnChange}\n value={value}\n style={style}\n className={switchClasses}\n {...restProps}\n {...htmlAttributes}\n />\n {Boolean(hasLeadingLabel) === false && labelContent}\n </label>\n );\n};\n"]}
1
+ {"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/switch/Switch.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,8CAAkD;AAClD,4DAAoC;AACpC,iCAAmD;AAGnD,oFAA8E;AAC9E,4CAAwD;AAkCjD,MAAM,MAAM,GAAG,CAAC,EAiBa,EAAE,EAAE;;QAjBjB,EACrB,SAAS,EACT,gBAAgB,EAChB,eAAe,GAAG,KAAK,EACvB,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,KAAK,EAClB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,OAE+B,EAD/B,SAAS,cAhBS,qMAiBtB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IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;YAC7D,IAAA,4BAAoB,EAClB,6GAA6G,CAC9G,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,OAAO,CACL,mCAAO,SAAS,EAAE,oBAAoB,aACnC,eAAe,KAAK,IAAI,IAAI,YAAY,EACzC,gDACE,GAAG,EAAE,UAAU,EACf,IAAI,EAAC,UAAU,EACf,IAAI,EAAC,QAAQ,gBACD,SAAS,EACrB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,IACpB,SAAS,EACT,cAAc,EAClB,EACD,OAAO,CAAC,eAAe,CAAC,KAAK,KAAK,IAAI,YAAY,IAC7C,CACT,CAAC;AACJ,CAAC,CAAC;AAxFW,QAAA,MAAM,UAwFjB","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 { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport { type CommonProps, type HtmlAttributes } from '../_common/types';\nimport { useSemiControlledInput } from '../_common/use-semi-controlled-input';\nimport { needleWarningMessage } from '../_common/utils';\n\ntype SwitchProps = {\n /** Whether the switch is checked */\n isChecked?: boolean;\n /** Checks the input by default in uncontrolled mode */\n isDefaultChecked?: boolean; // isDefaultChecked sounds weird to me?\n /** Whether the switch is indeterminate */\n isIndeterminate?: boolean;\n /** Whether the switch is disabled */\n isDisabled?: boolean;\n /** Whether the switch & label should take the full available width of its container */\n isFluid?: boolean;\n /** The value of the switch */\n value?: HtmlAttributes<'input'>['value']; // should this be required?\n /** Whether the label should be displayed before the switch */\n hasLeadingLabel?: boolean;\n /** The callback function triggered when the switch value changes */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n /** The callback function triggered when the switch is clicked */\n onClick?: (event: React.MouseEvent<HTMLInputElement>) => void;\n} & (\n | {\n /** The aria label of the switch. Required if the label is not a string. */\n ariaLabel: string;\n /** The label of the switch. If not a string, supply an aria label for screen reader support. */\n label?: undefined;\n }\n | {\n ariaLabel?: string;\n label: React.ReactNode;\n }\n);\n\nexport const Switch = ({\n isChecked,\n isDefaultChecked,\n isIndeterminate = false,\n isFluid = false,\n isDisabled = false,\n hasLeadingLabel,\n ariaLabel,\n onChange,\n onClick,\n value,\n label,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'input', SwitchProps>) => {\n const internalRef = useRef<HTMLInputElement>(null);\n const mergedRefs = useMergeRefs([internalRef, ref]);\n\n const [isCheckedState, internalOnChange] = useSemiControlledInput({\n inputType: 'switch',\n isControlled: isChecked !== undefined,\n onChange,\n state: isChecked ?? isDefaultChecked ?? false,\n });\n\n const labelWrappingClasses = classNames('ndl-switch-label', {\n 'ndl-disabled': isDisabled,\n 'ndl-fluid': isFluid,\n });\n\n const switchClasses = classNames('ndl-switch', className, {\n 'ndl-disabled': isDisabled,\n });\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.indeterminate = isIndeterminate;\n }\n }, [isIndeterminate]);\n\n /** TODO: Label handling. We can get rid of this annoying stuff as soon as we do proper form control. */\n const labelContent = useMemo(() => {\n if (Boolean(label) === false) {\n return null;\n }\n\n if (typeof label === 'string') {\n return (\n <span title={label} className=\"ndl-switch-label-text\">\n {label}\n </span>\n );\n }\n return label;\n }, [label]);\n\n useEffect(() => {\n if (Boolean(label) === false && Boolean(ariaLabel) === false) {\n needleWarningMessage(\n 'Switch needs a valid label or ariaLabel: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI',\n );\n }\n }, [ariaLabel, label]);\n\n return (\n <label className={labelWrappingClasses}>\n {hasLeadingLabel === true && labelContent}\n <input\n ref={mergedRefs}\n type=\"checkbox\"\n role=\"switch\"\n aria-label={ariaLabel}\n disabled={isDisabled}\n checked={isCheckedState}\n onClick={onClick}\n onChange={internalOnChange}\n value={value}\n style={style}\n className={switchClasses}\n {...restProps}\n {...htmlAttributes}\n />\n {Boolean(hasLeadingLabel) === false && labelContent}\n </label>\n );\n};\n"]}
@@ -24,7 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.Full = exports.Disabled = exports.HasLeadingLabel = exports.NoLabel = exports.Controlled = exports.Indeterminate = exports.Default = void 0;
25
25
  const jsx_runtime_1 = require("react/jsx-runtime");
26
26
  const index_1 = require("../../index");
27
- const _1 = require("./");
27
+ const _1 = require(".");
28
28
  const componentMeta = {
29
29
  title: 'Components/Switch',
30
30
  id: 'components-switch',