@neo4j-ndl/react 4.4.0 → 4.4.1

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 (365) hide show
  1. package/lib/cjs/_common/types.js.map +1 -1
  2. package/lib/cjs/_common/utils.js +4 -4
  3. package/lib/cjs/_common/utils.js.map +1 -1
  4. package/lib/cjs/accordion/Accordion.js +5 -5
  5. package/lib/cjs/accordion/Accordion.js.map +1 -1
  6. package/lib/cjs/accordion/accordion-context.js +1 -1
  7. package/lib/cjs/accordion/accordion-context.js.map +1 -1
  8. package/lib/cjs/accordion/stories/accordion.stories.js +20 -20
  9. package/lib/cjs/accordion/stories/accordion.stories.js.map +1 -1
  10. package/lib/cjs/avatar/stories/avatar.stories.js +18 -18
  11. package/lib/cjs/avatar/stories/avatar.stories.js.map +1 -1
  12. package/lib/cjs/breadcrumbs/stories/breadcrumbs.stories.js +1 -1
  13. package/lib/cjs/breadcrumbs/stories/breadcrumbs.stories.js.map +1 -1
  14. package/lib/cjs/checkbox/stories/checkbox-full.story.js +2 -2
  15. package/lib/cjs/checkbox/stories/checkbox-full.story.js.map +1 -1
  16. package/lib/cjs/checkbox/stories/checkbox.stories.js +19 -19
  17. package/lib/cjs/checkbox/stories/checkbox.stories.js.map +1 -1
  18. package/lib/cjs/clean-icon-button/stories/clean-icon-button.stories.js +11 -11
  19. package/lib/cjs/clean-icon-button/stories/clean-icon-button.stories.js.map +1 -1
  20. package/lib/cjs/code-block/stories/code-disabled.story.js +2 -2
  21. package/lib/cjs/code-block/stories/code-disabled.story.js.map +1 -1
  22. package/lib/cjs/code-block/stories/code-full.story.js +2 -2
  23. package/lib/cjs/code-block/stories/code-full.story.js.map +1 -1
  24. package/lib/cjs/code-block/stories/code-with-actions.story.js +2 -2
  25. package/lib/cjs/code-block/stories/code-with-actions.story.js.map +1 -1
  26. package/lib/cjs/code-block/themes/ndl-code-dark.js +64 -64
  27. package/lib/cjs/code-block/themes/ndl-code-dark.js.map +1 -1
  28. package/lib/cjs/code-block/themes/ndl-code-light.js +64 -64
  29. package/lib/cjs/code-block/themes/ndl-code-light.js.map +1 -1
  30. package/lib/cjs/color-picker/ColorPicker.js +1 -1
  31. package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
  32. package/lib/cjs/color-picker/stories/color-picker.stories.js +4 -4
  33. package/lib/cjs/color-picker/stories/color-picker.stories.js.map +1 -1
  34. package/lib/cjs/data-grid/Components.js +13 -11
  35. package/lib/cjs/data-grid/Components.js.map +1 -1
  36. package/lib/cjs/data-grid/DataGrid.js.map +1 -1
  37. package/lib/cjs/data-grid/data-grid-context.js +1 -1
  38. package/lib/cjs/data-grid/data-grid-context.js.map +1 -1
  39. package/lib/cjs/data-grid/data-grid-nav/index.js +1 -1
  40. package/lib/cjs/data-grid/data-grid-nav/index.js.map +1 -1
  41. package/lib/cjs/data-grid/stories/datagrid-kitchen-sink.story.js +1 -1
  42. package/lib/cjs/data-grid/stories/datagrid-kitchen-sink.story.js.map +1 -1
  43. package/lib/cjs/date-picker/stories/date-picker-full.story.js +9 -9
  44. package/lib/cjs/date-picker/stories/date-picker-full.story.js.map +1 -1
  45. package/lib/cjs/divider/stories/divider-horizontal.story.js +1 -1
  46. package/lib/cjs/divider/stories/divider-horizontal.story.js.map +1 -1
  47. package/lib/cjs/divider/stories/divider-vertical.story.js +1 -1
  48. package/lib/cjs/divider/stories/divider-vertical.story.js.map +1 -1
  49. package/lib/cjs/drawer/stories/drawer.stories.js +19 -19
  50. package/lib/cjs/drawer/stories/drawer.stories.js.map +1 -1
  51. package/lib/cjs/dropdown-button/stories/dropdown-button.stories.js +18 -18
  52. package/lib/cjs/dropdown-button/stories/dropdown-button.stories.js.map +1 -1
  53. package/lib/cjs/dropzone/stories/dropzone-disabled.story.js +1 -1
  54. package/lib/cjs/dropzone/stories/dropzone-disabled.story.js.map +1 -1
  55. package/lib/cjs/dropzone/stories/dropzone-full.story.js +11 -11
  56. package/lib/cjs/dropzone/stories/dropzone-full.story.js.map +1 -1
  57. package/lib/cjs/dropzone/stories/dropzone.stories.js +10 -10
  58. package/lib/cjs/dropzone/stories/dropzone.stories.js.map +1 -1
  59. package/lib/cjs/flex/Flex.js +4 -4
  60. package/lib/cjs/flex/Flex.js.map +1 -1
  61. package/lib/cjs/graph-label/stories/graph-label.stories.js +20 -20
  62. package/lib/cjs/graph-label/stories/graph-label.stories.js.map +1 -1
  63. package/lib/cjs/hooks/index.js +3 -3
  64. package/lib/cjs/hooks/index.js.map +1 -1
  65. package/lib/cjs/icon-button/stories/icon-button.stories.js +12 -12
  66. package/lib/cjs/icon-button/stories/icon-button.stories.js.map +1 -1
  67. package/lib/cjs/icon-button-array/stories/icon-button-array.stories.js +16 -16
  68. package/lib/cjs/icon-button-array/stories/icon-button-array.stories.js.map +1 -1
  69. package/lib/cjs/icons/wrapIcon.js +1 -1
  70. package/lib/cjs/icons/wrapIcon.js.map +1 -1
  71. package/lib/cjs/kbd/stories/kbd.stories.js +7 -7
  72. package/lib/cjs/kbd/stories/kbd.stories.js.map +1 -1
  73. package/lib/cjs/loading-spinner/LoadingSpinner.js +2 -2
  74. package/lib/cjs/loading-spinner/LoadingSpinner.js.map +1 -1
  75. package/lib/cjs/loading-spinner/stories/loading-spinner.stories.js +10 -10
  76. package/lib/cjs/loading-spinner/stories/loading-spinner.stories.js.map +1 -1
  77. package/lib/cjs/logo/Logo.js +6 -6
  78. package/lib/cjs/logo/Logo.js.map +1 -1
  79. package/lib/cjs/logo/stories/logo.stories.js +9 -9
  80. package/lib/cjs/logo/stories/logo.stories.js.map +1 -1
  81. package/lib/cjs/menu/Menu.js +3 -3
  82. package/lib/cjs/menu/Menu.js.map +1 -1
  83. package/lib/cjs/popover/Popover.js +15 -15
  84. package/lib/cjs/popover/Popover.js.map +1 -1
  85. package/lib/cjs/popover/use-popover.js +9 -9
  86. package/lib/cjs/popover/use-popover.js.map +1 -1
  87. package/lib/cjs/progress-bar/stories/progress-bar.stories.js +3 -3
  88. package/lib/cjs/progress-bar/stories/progress-bar.stories.js.map +1 -1
  89. package/lib/cjs/segmented-control/SegmentedControl.js +1 -1
  90. package/lib/cjs/segmented-control/SegmentedControl.js.map +1 -1
  91. package/lib/cjs/select/Overrides.js +41 -41
  92. package/lib/cjs/select/Overrides.js.map +1 -1
  93. package/lib/cjs/select/stories/select-async.story.js +4 -4
  94. package/lib/cjs/select/stories/select-async.story.js.map +1 -1
  95. package/lib/cjs/select/stories/select-controlled.story.js +4 -4
  96. package/lib/cjs/select/stories/select-controlled.story.js.map +1 -1
  97. package/lib/cjs/select/stories/select-creatable.story.js +1 -1
  98. package/lib/cjs/select/stories/select-creatable.story.js.map +1 -1
  99. package/lib/cjs/select/stories/select-custom-label.story.js +1 -1
  100. package/lib/cjs/select/stories/select-custom-label.story.js.map +1 -1
  101. package/lib/cjs/select/stories/select-disabled.story.js +1 -1
  102. package/lib/cjs/select/stories/select-disabled.story.js.map +1 -1
  103. package/lib/cjs/select/stories/select-inside-dialog.story.js +1 -1
  104. package/lib/cjs/select/stories/select-inside-dialog.story.js.map +1 -1
  105. package/lib/cjs/side-navigation/stories/side-nav.stories.js +1 -1
  106. package/lib/cjs/side-navigation/stories/side-nav.stories.js.map +1 -1
  107. package/lib/cjs/skeleton/stories/skeleton.stories.js +28 -28
  108. package/lib/cjs/skeleton/stories/skeleton.stories.js.map +1 -1
  109. package/lib/cjs/slider/Slider.js +2 -1
  110. package/lib/cjs/slider/Slider.js.map +1 -1
  111. package/lib/cjs/status-indicator/stories/status-indicator.stories.js +2 -2
  112. package/lib/cjs/status-indicator/stories/status-indicator.stories.js.map +1 -1
  113. package/lib/cjs/switch/stories/switch.stories.js +7 -7
  114. package/lib/cjs/switch/stories/switch.stories.js.map +1 -1
  115. package/lib/cjs/tabs/Tabs.js +1 -1
  116. package/lib/cjs/tabs/Tabs.js.map +1 -1
  117. package/lib/cjs/tag/Tag.js +2 -2
  118. package/lib/cjs/tag/Tag.js.map +1 -1
  119. package/lib/cjs/tag/stories/tag.stories.js +10 -10
  120. package/lib/cjs/tag/stories/tag.stories.js.map +1 -1
  121. package/lib/cjs/text-area/TextArea.js +5 -5
  122. package/lib/cjs/text-area/TextArea.js.map +1 -1
  123. package/lib/cjs/text-area/stories/text-area.stories.js +25 -25
  124. package/lib/cjs/text-area/stories/text-area.stories.js.map +1 -1
  125. package/lib/cjs/text-input/stories/text-input-number.story.js +2 -2
  126. package/lib/cjs/text-input/stories/text-input-number.story.js.map +1 -1
  127. package/lib/cjs/text-link/stories/text-link.stories.js +11 -11
  128. package/lib/cjs/text-link/stories/text-link.stories.js.map +1 -1
  129. package/lib/cjs/text-overflow/stories/text-overflow.stories.js +1 -1
  130. package/lib/cjs/text-overflow/stories/text-overflow.stories.js.map +1 -1
  131. package/lib/cjs/theme/ThemeProvider.js.map +1 -1
  132. package/lib/cjs/theme/agnostic.js +1 -1
  133. package/lib/cjs/theme/agnostic.js.map +1 -1
  134. package/lib/cjs/time-picker/TimePicker.js +4 -4
  135. package/lib/cjs/time-picker/TimePicker.js.map +1 -1
  136. package/lib/cjs/time-picker/time-picker-hooks.js +1 -1
  137. package/lib/cjs/time-picker/time-picker-hooks.js.map +1 -1
  138. package/lib/cjs/timezone-picker/TimeZonePicker.js +5 -5
  139. package/lib/cjs/timezone-picker/TimeZonePicker.js.map +1 -1
  140. package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js +7 -7
  141. package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -1
  142. package/lib/cjs/timezone-picker/stories/timezone-picker-fluid.story.js +1 -1
  143. package/lib/cjs/timezone-picker/stories/timezone-picker-fluid.story.js.map +1 -1
  144. package/lib/cjs/toast/Toast.js +12 -12
  145. package/lib/cjs/toast/Toast.js.map +1 -1
  146. package/lib/cjs/toast/stories/toast-action-story.js +1 -1
  147. package/lib/cjs/toast/stories/toast-action-story.js.map +1 -1
  148. package/lib/cjs/toast/stories/toast-controlled-story.js +2 -2
  149. package/lib/cjs/toast/stories/toast-controlled-story.js.map +1 -1
  150. package/lib/cjs/toast/stories/toast-progress-bar.js +1 -1
  151. package/lib/cjs/toast/stories/toast-progress-bar.js.map +1 -1
  152. package/lib/cjs/toast/stories/toast.stories.js +18 -18
  153. package/lib/cjs/toast/stories/toast.stories.js.map +1 -1
  154. package/lib/cjs/tooltip/Tooltip.js +1 -1
  155. package/lib/cjs/tooltip/Tooltip.js.map +1 -1
  156. package/lib/cjs/tooltip/stories/tooltip-hover-delay.story.js +1 -1
  157. package/lib/cjs/tooltip/stories/tooltip-hover-delay.story.js.map +1 -1
  158. package/lib/cjs/tooltip/stories/tooltip-placements.story.js +8 -8
  159. package/lib/cjs/tooltip/stories/tooltip-placements.story.js.map +1 -1
  160. package/lib/cjs/tooltip/stories/tooltip.stories.js +29 -29
  161. package/lib/cjs/tooltip/stories/tooltip.stories.js.map +1 -1
  162. package/lib/cjs/tooltip/use-tooltip.js +10 -10
  163. package/lib/cjs/tooltip/use-tooltip.js.map +1 -1
  164. package/lib/cjs/tree-view/TreeItemWrapper.js +2 -2
  165. package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
  166. package/lib/cjs/tree-view/TreeView.js +12 -12
  167. package/lib/cjs/tree-view/TreeView.js.map +1 -1
  168. package/lib/cjs/tree-view/TreeViewItem.js +1 -1
  169. package/lib/cjs/tree-view/TreeViewItem.js.map +1 -1
  170. package/lib/cjs/tree-view/TreeViewTextItem.js +1 -1
  171. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  172. package/lib/cjs/tree-view/tree-view-keyboard-coordinates.js +2 -2
  173. package/lib/cjs/tree-view/tree-view-keyboard-coordinates.js.map +1 -1
  174. package/lib/cjs/wizard/Wizard.js +2 -2
  175. package/lib/cjs/wizard/Wizard.js.map +1 -1
  176. package/lib/cjs/wizard/stories/wizard.stories.js +14 -14
  177. package/lib/cjs/wizard/stories/wizard.stories.js.map +1 -1
  178. package/lib/esm/_common/types.js.map +1 -1
  179. package/lib/esm/_common/utils.js +4 -4
  180. package/lib/esm/_common/utils.js.map +1 -1
  181. package/lib/esm/accordion/Accordion.js +5 -5
  182. package/lib/esm/accordion/Accordion.js.map +1 -1
  183. package/lib/esm/accordion/accordion-context.js +1 -1
  184. package/lib/esm/accordion/accordion-context.js.map +1 -1
  185. package/lib/esm/accordion/stories/accordion.stories.js +20 -20
  186. package/lib/esm/accordion/stories/accordion.stories.js.map +1 -1
  187. package/lib/esm/avatar/stories/avatar.stories.js +18 -18
  188. package/lib/esm/avatar/stories/avatar.stories.js.map +1 -1
  189. package/lib/esm/breadcrumbs/stories/breadcrumbs.stories.js +1 -1
  190. package/lib/esm/breadcrumbs/stories/breadcrumbs.stories.js.map +1 -1
  191. package/lib/esm/checkbox/stories/checkbox-full.story.js +2 -2
  192. package/lib/esm/checkbox/stories/checkbox-full.story.js.map +1 -1
  193. package/lib/esm/checkbox/stories/checkbox.stories.js +19 -19
  194. package/lib/esm/checkbox/stories/checkbox.stories.js.map +1 -1
  195. package/lib/esm/clean-icon-button/stories/clean-icon-button.stories.js +11 -11
  196. package/lib/esm/clean-icon-button/stories/clean-icon-button.stories.js.map +1 -1
  197. package/lib/esm/code-block/stories/code-disabled.story.js +2 -2
  198. package/lib/esm/code-block/stories/code-disabled.story.js.map +1 -1
  199. package/lib/esm/code-block/stories/code-full.story.js +2 -2
  200. package/lib/esm/code-block/stories/code-full.story.js.map +1 -1
  201. package/lib/esm/code-block/stories/code-with-actions.story.js +2 -2
  202. package/lib/esm/code-block/stories/code-with-actions.story.js.map +1 -1
  203. package/lib/esm/code-block/themes/ndl-code-dark.js +64 -64
  204. package/lib/esm/code-block/themes/ndl-code-dark.js.map +1 -1
  205. package/lib/esm/code-block/themes/ndl-code-light.js +64 -64
  206. package/lib/esm/code-block/themes/ndl-code-light.js.map +1 -1
  207. package/lib/esm/color-picker/ColorPicker.js +1 -1
  208. package/lib/esm/color-picker/ColorPicker.js.map +1 -1
  209. package/lib/esm/color-picker/stories/color-picker.stories.js +4 -4
  210. package/lib/esm/color-picker/stories/color-picker.stories.js.map +1 -1
  211. package/lib/esm/data-grid/Components.js +13 -11
  212. package/lib/esm/data-grid/Components.js.map +1 -1
  213. package/lib/esm/data-grid/DataGrid.js.map +1 -1
  214. package/lib/esm/data-grid/data-grid-context.js +1 -1
  215. package/lib/esm/data-grid/data-grid-context.js.map +1 -1
  216. package/lib/esm/data-grid/data-grid-nav/index.js +1 -1
  217. package/lib/esm/data-grid/data-grid-nav/index.js.map +1 -1
  218. package/lib/esm/data-grid/stories/datagrid-kitchen-sink.story.js +1 -1
  219. package/lib/esm/data-grid/stories/datagrid-kitchen-sink.story.js.map +1 -1
  220. package/lib/esm/date-picker/stories/date-picker-full.story.js +9 -9
  221. package/lib/esm/date-picker/stories/date-picker-full.story.js.map +1 -1
  222. package/lib/esm/divider/stories/divider-horizontal.story.js +1 -1
  223. package/lib/esm/divider/stories/divider-horizontal.story.js.map +1 -1
  224. package/lib/esm/divider/stories/divider-vertical.story.js +1 -1
  225. package/lib/esm/divider/stories/divider-vertical.story.js.map +1 -1
  226. package/lib/esm/drawer/stories/drawer.stories.js +19 -19
  227. package/lib/esm/drawer/stories/drawer.stories.js.map +1 -1
  228. package/lib/esm/dropdown-button/stories/dropdown-button.stories.js +18 -18
  229. package/lib/esm/dropdown-button/stories/dropdown-button.stories.js.map +1 -1
  230. package/lib/esm/dropzone/stories/dropzone-disabled.story.js +1 -1
  231. package/lib/esm/dropzone/stories/dropzone-disabled.story.js.map +1 -1
  232. package/lib/esm/dropzone/stories/dropzone-full.story.js +11 -11
  233. package/lib/esm/dropzone/stories/dropzone-full.story.js.map +1 -1
  234. package/lib/esm/dropzone/stories/dropzone.stories.js +10 -10
  235. package/lib/esm/dropzone/stories/dropzone.stories.js.map +1 -1
  236. package/lib/esm/flex/Flex.js +4 -4
  237. package/lib/esm/flex/Flex.js.map +1 -1
  238. package/lib/esm/graph-label/stories/graph-label.stories.js +20 -20
  239. package/lib/esm/graph-label/stories/graph-label.stories.js.map +1 -1
  240. package/lib/esm/hooks/index.js +3 -3
  241. package/lib/esm/hooks/index.js.map +1 -1
  242. package/lib/esm/icon-button/stories/icon-button.stories.js +12 -12
  243. package/lib/esm/icon-button/stories/icon-button.stories.js.map +1 -1
  244. package/lib/esm/icon-button-array/stories/icon-button-array.stories.js +16 -16
  245. package/lib/esm/icon-button-array/stories/icon-button-array.stories.js.map +1 -1
  246. package/lib/esm/icons/wrapIcon.js +1 -1
  247. package/lib/esm/icons/wrapIcon.js.map +1 -1
  248. package/lib/esm/kbd/stories/kbd.stories.js +7 -7
  249. package/lib/esm/kbd/stories/kbd.stories.js.map +1 -1
  250. package/lib/esm/loading-spinner/LoadingSpinner.js +2 -2
  251. package/lib/esm/loading-spinner/LoadingSpinner.js.map +1 -1
  252. package/lib/esm/loading-spinner/stories/loading-spinner.stories.js +10 -10
  253. package/lib/esm/loading-spinner/stories/loading-spinner.stories.js.map +1 -1
  254. package/lib/esm/logo/Logo.js +6 -6
  255. package/lib/esm/logo/Logo.js.map +1 -1
  256. package/lib/esm/logo/stories/logo.stories.js +9 -9
  257. package/lib/esm/logo/stories/logo.stories.js.map +1 -1
  258. package/lib/esm/menu/Menu.js +3 -3
  259. package/lib/esm/menu/Menu.js.map +1 -1
  260. package/lib/esm/popover/Popover.js +15 -15
  261. package/lib/esm/popover/Popover.js.map +1 -1
  262. package/lib/esm/popover/use-popover.js +9 -9
  263. package/lib/esm/popover/use-popover.js.map +1 -1
  264. package/lib/esm/progress-bar/stories/progress-bar.stories.js +3 -3
  265. package/lib/esm/progress-bar/stories/progress-bar.stories.js.map +1 -1
  266. package/lib/esm/segmented-control/SegmentedControl.js +1 -1
  267. package/lib/esm/segmented-control/SegmentedControl.js.map +1 -1
  268. package/lib/esm/select/Overrides.js +41 -41
  269. package/lib/esm/select/Overrides.js.map +1 -1
  270. package/lib/esm/select/stories/select-async.story.js +4 -4
  271. package/lib/esm/select/stories/select-async.story.js.map +1 -1
  272. package/lib/esm/select/stories/select-controlled.story.js +4 -4
  273. package/lib/esm/select/stories/select-controlled.story.js.map +1 -1
  274. package/lib/esm/select/stories/select-creatable.story.js +1 -1
  275. package/lib/esm/select/stories/select-creatable.story.js.map +1 -1
  276. package/lib/esm/select/stories/select-custom-label.story.js +1 -1
  277. package/lib/esm/select/stories/select-custom-label.story.js.map +1 -1
  278. package/lib/esm/select/stories/select-disabled.story.js +1 -1
  279. package/lib/esm/select/stories/select-disabled.story.js.map +1 -1
  280. package/lib/esm/select/stories/select-inside-dialog.story.js +1 -1
  281. package/lib/esm/select/stories/select-inside-dialog.story.js.map +1 -1
  282. package/lib/esm/side-navigation/stories/side-nav.stories.js +1 -1
  283. package/lib/esm/side-navigation/stories/side-nav.stories.js.map +1 -1
  284. package/lib/esm/skeleton/stories/skeleton.stories.js +28 -28
  285. package/lib/esm/skeleton/stories/skeleton.stories.js.map +1 -1
  286. package/lib/esm/slider/Slider.js +2 -1
  287. package/lib/esm/slider/Slider.js.map +1 -1
  288. package/lib/esm/status-indicator/stories/status-indicator.stories.js +2 -2
  289. package/lib/esm/status-indicator/stories/status-indicator.stories.js.map +1 -1
  290. package/lib/esm/switch/stories/switch.stories.js +7 -7
  291. package/lib/esm/switch/stories/switch.stories.js.map +1 -1
  292. package/lib/esm/tabs/Tabs.js +1 -1
  293. package/lib/esm/tabs/Tabs.js.map +1 -1
  294. package/lib/esm/tag/Tag.js +2 -2
  295. package/lib/esm/tag/Tag.js.map +1 -1
  296. package/lib/esm/tag/stories/tag.stories.js +10 -10
  297. package/lib/esm/tag/stories/tag.stories.js.map +1 -1
  298. package/lib/esm/text-area/TextArea.js +5 -5
  299. package/lib/esm/text-area/TextArea.js.map +1 -1
  300. package/lib/esm/text-area/stories/text-area.stories.js +25 -25
  301. package/lib/esm/text-area/stories/text-area.stories.js.map +1 -1
  302. package/lib/esm/text-input/stories/text-input-number.story.js +2 -2
  303. package/lib/esm/text-input/stories/text-input-number.story.js.map +1 -1
  304. package/lib/esm/text-link/stories/text-link.stories.js +11 -11
  305. package/lib/esm/text-link/stories/text-link.stories.js.map +1 -1
  306. package/lib/esm/text-overflow/stories/text-overflow.stories.js +1 -1
  307. package/lib/esm/text-overflow/stories/text-overflow.stories.js.map +1 -1
  308. package/lib/esm/theme/ThemeProvider.js.map +1 -1
  309. package/lib/esm/theme/agnostic.js +1 -1
  310. package/lib/esm/theme/agnostic.js.map +1 -1
  311. package/lib/esm/time-picker/TimePicker.js +4 -4
  312. package/lib/esm/time-picker/TimePicker.js.map +1 -1
  313. package/lib/esm/time-picker/time-picker-hooks.js +1 -1
  314. package/lib/esm/time-picker/time-picker-hooks.js.map +1 -1
  315. package/lib/esm/timezone-picker/TimeZonePicker.js +5 -5
  316. package/lib/esm/timezone-picker/TimeZonePicker.js.map +1 -1
  317. package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js +7 -7
  318. package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -1
  319. package/lib/esm/timezone-picker/stories/timezone-picker-fluid.story.js +1 -1
  320. package/lib/esm/timezone-picker/stories/timezone-picker-fluid.story.js.map +1 -1
  321. package/lib/esm/toast/Toast.js +12 -12
  322. package/lib/esm/toast/Toast.js.map +1 -1
  323. package/lib/esm/toast/stories/toast-action-story.js +1 -1
  324. package/lib/esm/toast/stories/toast-action-story.js.map +1 -1
  325. package/lib/esm/toast/stories/toast-controlled-story.js +2 -2
  326. package/lib/esm/toast/stories/toast-controlled-story.js.map +1 -1
  327. package/lib/esm/toast/stories/toast-progress-bar.js +1 -1
  328. package/lib/esm/toast/stories/toast-progress-bar.js.map +1 -1
  329. package/lib/esm/toast/stories/toast.stories.js +18 -18
  330. package/lib/esm/toast/stories/toast.stories.js.map +1 -1
  331. package/lib/esm/tooltip/Tooltip.js +1 -1
  332. package/lib/esm/tooltip/Tooltip.js.map +1 -1
  333. package/lib/esm/tooltip/stories/tooltip-hover-delay.story.js +1 -1
  334. package/lib/esm/tooltip/stories/tooltip-hover-delay.story.js.map +1 -1
  335. package/lib/esm/tooltip/stories/tooltip-placements.story.js +8 -8
  336. package/lib/esm/tooltip/stories/tooltip-placements.story.js.map +1 -1
  337. package/lib/esm/tooltip/stories/tooltip.stories.js +29 -29
  338. package/lib/esm/tooltip/stories/tooltip.stories.js.map +1 -1
  339. package/lib/esm/tooltip/use-tooltip.js +10 -10
  340. package/lib/esm/tooltip/use-tooltip.js.map +1 -1
  341. package/lib/esm/tree-view/TreeItemWrapper.js +2 -2
  342. package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
  343. package/lib/esm/tree-view/TreeView.js +12 -12
  344. package/lib/esm/tree-view/TreeView.js.map +1 -1
  345. package/lib/esm/tree-view/TreeViewItem.js +1 -1
  346. package/lib/esm/tree-view/TreeViewItem.js.map +1 -1
  347. package/lib/esm/tree-view/TreeViewTextItem.js +1 -1
  348. package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
  349. package/lib/esm/tree-view/tree-view-keyboard-coordinates.js +2 -2
  350. package/lib/esm/tree-view/tree-view-keyboard-coordinates.js.map +1 -1
  351. package/lib/esm/wizard/Wizard.js +2 -2
  352. package/lib/esm/wizard/Wizard.js.map +1 -1
  353. package/lib/esm/wizard/stories/wizard.stories.js +14 -14
  354. package/lib/esm/wizard/stories/wizard.stories.js.map +1 -1
  355. package/lib/types/accordion/stories/accordion.stories.d.ts +3 -3
  356. package/lib/types/breadcrumbs/stories/breadcrumbs.stories.d.ts +1 -1
  357. package/lib/types/data-grid/Components.d.ts.map +1 -1
  358. package/lib/types/logo/stories/logo.stories.d.ts +3 -3
  359. package/lib/types/side-navigation/stories/side-nav.stories.d.ts +1 -1
  360. package/lib/types/skeleton/stories/skeleton.stories.d.ts +3 -3
  361. package/lib/types/slider/Slider.d.ts.map +1 -1
  362. package/lib/types/time-picker/time-picker-hooks.d.ts +1 -1
  363. package/lib/types/time-picker/time-picker-hooks.d.ts.map +1 -1
  364. package/lib/types/toast/stories/toast.stories.d.ts +2 -2
  365. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":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AAI,UAAU,EAAE,CAAC;oBAC1B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,+BAAa,EAC7B,KAAK,EACL,MAAM,CAAC,EAAE,EACT,SAAS,EACT,CAAC,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,gBAAgB,EACrD,gBAAgB,CACjB,CAAC;oBACF,MAAM,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;oBACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAClC,MAAM,MAAM,GAAG,SAAS;wBACtB,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC;wBAChD,CAAC,CAAC,CAAC,CAAC;oBAEN,MAAM,cAAc,GAAG;wBACrB,CAAC,EAAE,OAAO,CAAC,IAAI,GAAG,KAAK,GAAG,gBAAgB;wBAC1C,CAAC,EAAE,OAAO,CAAC,GAAG,GAAG,QAAQ,GAAG,MAAM;qBACnC,CAAC;oBAEF,OAAO,cAAc,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AA1IS,QAAA,+BAA+B,mCA0IxC","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 closestCorners,\n type DroppableContainer,\n getFirstCollision,\n KeyboardCode,\n type KeyboardCoordinateGetter,\n} from '@dnd-kit/core';\n\nimport { getProjection, type SensorContext } from './tree-view-utils';\n\nconst directions: string[] = [\n KeyboardCode.Down,\n KeyboardCode.Right,\n KeyboardCode.Up,\n KeyboardCode.Left,\n];\n\nconst horizontal: string[] = [KeyboardCode.Left, KeyboardCode.Right];\n\nexport const sortableTreeKeyboardCoordinates: <T>(\n context: SensorContext<T>,\n indicator: boolean,\n indentationWidth: number,\n) => KeyboardCoordinateGetter =\n (context, indicator, indentationWidth) =>\n (\n event,\n {\n currentCoordinates,\n context: {\n active,\n over,\n collisionRect,\n droppableRects,\n droppableContainers,\n },\n },\n ) => {\n if (directions.includes(event.code)) {\n if (!active || !collisionRect) {\n return;\n }\n event.preventDefault();\n\n const {\n current: { items, offset },\n } = context;\n if (horizontal.includes(event.code) && over?.id) {\n const { depth, maxDepth, minDepth } = getProjection(\n items,\n active.id,\n over.id,\n offset,\n indentationWidth,\n );\n\n switch (event.code) {\n case KeyboardCode.Left:\n if (depth > minDepth) {\n return {\n ...currentCoordinates,\n x: currentCoordinates.x - indentationWidth,\n };\n }\n break;\n case KeyboardCode.Right:\n if (depth < maxDepth) {\n return {\n ...currentCoordinates,\n x: currentCoordinates.x + indentationWidth,\n };\n }\n break;\n }\n\n return undefined;\n }\n\n const containers: DroppableContainer[] = [];\n\n droppableContainers.forEach((container) => {\n if (\n container?.disabled ||\n container.id === over?.id ||\n container?.id === 'ndl-active-tree-item'\n ) {\n return;\n }\n const rect = droppableRects.get(container.id);\n\n if (!rect) {\n return;\n }\n\n switch (event.code) {\n case KeyboardCode.Down:\n if (collisionRect.top < rect.top) {\n containers.push(container);\n }\n break;\n case KeyboardCode.Up:\n if (collisionRect.top > rect.top) {\n containers.push(container);\n }\n break;\n }\n });\n\n const collisions = closestCorners({\n active,\n collisionRect,\n pointerCoordinates: null,\n droppableRects,\n droppableContainers: containers,\n });\n let closestId = getFirstCollision(collisions, 'id');\n if (closestId === over?.id && collisions.length > 1) {\n closestId = collisions[1].id;\n }\n\n if (closestId && over?.id) {\n const activeRect = droppableRects.get(active.id);\n const newRect = droppableRects.get(closestId);\n const newDroppable = droppableContainers.get(closestId);\n\n if (activeRect && newRect && newDroppable) {\n const newIndex = items.findIndex(({ id }) => id === closestId);\n const newItem = items[newIndex];\n const activeIndex = items.findIndex(({ id }) => id === active.id);\n const activeItem = items[activeIndex];\n\n if (newItem && activeItem) {\n const { depth } = getProjection(\n items,\n active.id,\n closestId,\n (newItem.depth - activeItem.depth) * indentationWidth,\n indentationWidth,\n );\n const isBelow = newIndex > activeIndex;\n const modifier = isBelow ? 1 : -1;\n const offset = indicator\n ? (collisionRect.height - activeRect.height) / 2\n : 0;\n\n const newCoordinates = {\n x: newRect.left + depth * indentationWidth,\n y: newRect.top + modifier * offset,\n };\n\n return newCoordinates;\n }\n }\n }\n }\n\n return undefined;\n };\n"]}
1
+ {"version":3,"file":"tree-view-keyboard-coordinates.js","sourceRoot":"","sources":["../../../src/tree-view/tree-view-keyboard-coordinates.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wCAMuB;AAEvB,uDAAsE;AAEtE,MAAM,UAAU,GAAa;IAC3B,mBAAY,CAAC,IAAI;IACjB,mBAAY,CAAC,KAAK;IAClB,mBAAY,CAAC,EAAE;IACf,mBAAY,CAAC,IAAI;CAClB,CAAC;AAEF,MAAM,UAAU,GAAa,CAAC,mBAAY,CAAC,IAAI,EAAE,mBAAY,CAAC,KAAK,CAAC,CAAC;AAE9D,MAAM,+BAA+B,GAK1C,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,CACzC,CACE,KAAK,EACL,EACE,kBAAkB,EAClB,OAAO,EAAE,EACP,MAAM,EACN,IAAI,EACJ,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,GACF,EACD,EAAE;IACF,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,C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AM;qBACnC,CAAC;oBAEF,OAAO,cAAc,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AA1IS,QAAA,+BAA+B,mCA0IxC","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 closestCorners,\n type DroppableContainer,\n getFirstCollision,\n KeyboardCode,\n type KeyboardCoordinateGetter,\n} from '@dnd-kit/core';\n\nimport { getProjection, type SensorContext } from './tree-view-utils';\n\nconst directions: string[] = [\n KeyboardCode.Down,\n KeyboardCode.Right,\n KeyboardCode.Up,\n KeyboardCode.Left,\n];\n\nconst horizontal: string[] = [KeyboardCode.Left, KeyboardCode.Right];\n\nexport const sortableTreeKeyboardCoordinates: <T>(\n context: SensorContext<T>,\n indicator: boolean,\n indentationWidth: number,\n) => KeyboardCoordinateGetter =\n (context, indicator, indentationWidth) =>\n (\n event,\n {\n currentCoordinates,\n context: {\n active,\n over,\n collisionRect,\n droppableRects,\n droppableContainers,\n },\n },\n ) => {\n if (directions.includes(event.code)) {\n if (!active || !collisionRect) {\n return;\n }\n event.preventDefault();\n\n const {\n current: { items, offset },\n } = context;\n if (horizontal.includes(event.code) && over?.id) {\n const { depth, maxDepth, minDepth } = getProjection(\n items,\n active.id,\n over.id,\n offset,\n indentationWidth,\n );\n\n switch (event.code) {\n case KeyboardCode.Left:\n if (depth > minDepth) {\n return {\n ...currentCoordinates,\n x: currentCoordinates.x - indentationWidth,\n };\n }\n break;\n case KeyboardCode.Right:\n if (depth < maxDepth) {\n return {\n ...currentCoordinates,\n x: currentCoordinates.x + indentationWidth,\n };\n }\n break;\n }\n\n return undefined;\n }\n\n const containers: DroppableContainer[] = [];\n\n droppableContainers.forEach((container) => {\n if (\n container?.disabled ||\n container.id === over?.id ||\n container?.id === 'ndl-active-tree-item'\n ) {\n return;\n }\n const rect = droppableRects.get(container.id);\n\n if (!rect) {\n return;\n }\n\n switch (event.code) {\n case KeyboardCode.Down:\n if (collisionRect.top < rect.top) {\n containers.push(container);\n }\n break;\n case KeyboardCode.Up:\n if (collisionRect.top > rect.top) {\n containers.push(container);\n }\n break;\n }\n });\n\n const collisions = closestCorners({\n active,\n collisionRect,\n droppableContainers: containers,\n droppableRects,\n pointerCoordinates: null,\n });\n let closestId = getFirstCollision(collisions, 'id');\n if (closestId === over?.id && collisions.length > 1) {\n closestId = collisions[1].id;\n }\n\n if (closestId && over?.id) {\n const activeRect = droppableRects.get(active.id);\n const newRect = droppableRects.get(closestId);\n const newDroppable = droppableContainers.get(closestId);\n\n if (activeRect && newRect && newDroppable) {\n const newIndex = items.findIndex(({ id }) => id === closestId);\n const newItem = items[newIndex];\n const activeIndex = items.findIndex(({ id }) => id === active.id);\n const activeItem = items[activeIndex];\n\n if (newItem && activeItem) {\n const { depth } = getProjection(\n items,\n active.id,\n closestId,\n (newItem.depth - activeItem.depth) * indentationWidth,\n indentationWidth,\n );\n const isBelow = newIndex > activeIndex;\n const modifier = isBelow ? 1 : -1;\n const offset = indicator\n ? (collisionRect.height - activeRect.height) / 2\n : 0;\n\n const newCoordinates = {\n x: newRect.left + depth * indentationWidth,\n y: newRect.top + modifier * offset,\n };\n\n return newCoordinates;\n }\n }\n }\n }\n\n return undefined;\n };\n"]}
@@ -161,9 +161,9 @@ const WizardSmall = (_a) => {
161
161
  exports.WizardSmall = WizardSmall;
162
162
  const Circle = ({ status, number, alignment = 'middle', }) => {
163
163
  const innerCircleClasses = (0, classnames_1.default)({
164
- 'n-fill-primary-bg-strong': status === 'complete' || status === 'active',
165
- 'n-fill-neutral-bg-stronger': status === 'incomplete',
166
164
  'n-fill-danger-bg-strong': status === 'error',
165
+ 'n-fill-neutral-bg-stronger': status === 'incomplete',
166
+ 'n-fill-primary-bg-strong': status === 'complete' || status === 'active',
167
167
  });
168
168
  const outerCircleClasses = (0, classnames_1.default)('ndl-wizard-circle', {
169
169
  [`ndl-wizard-align-${alignment}`]: alignment,
@@ -1 +1 @@
1
- {"version":3,"file":"Wizard.js","sourceRoot":"","sources":["../../../src/wizard/Wizard.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AACpC,+CAAyC;AAGzC,8CAA2C;AA+CpC,MAAM,MAAM,GAAG,CAAsC,EAC1D,EAAE,EACF,SAAS,EACT,KAAK,EACL,IAAI,GAAG,OAAO,EACd,KAAK,EACL,eAAe,EACf,WAAW,EACX,cAAc,EACd,SAAS,GAAG,WAAW,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EACzD,GAAG,GACoC,EAAE,EAAE;IAC3C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,eAAe,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;YAC9D,OAAO,CAAC,IAAI,CACV,uFAAuF,eAAe,+BAA+B,KAAK,CAAC,MAAM,GAAG,CACrJ,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,CACL,uBAAC,mBAAW,IACV,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,WAAW,EACxB,KA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GAAG,IAAA,oBAAU,EAAC;QACpC,0BAA0B,EAAE,MAAM,KAAK,UAAU,IAAI,MAAM,KAAK,QAAQ;QACxE,4BAA4B,EAAE,MAAM,KAAK,YAAY;QACrD,yBAAyB,EAAE,MAAM,KAAK,OAAO;KAC9C,CAAC,CAAC;IACH,MAAM,kBAAkB,GAAG,IAAA,oBAAU,EAAC,mBAAmB,EAAE;QACzD,CAAC,oBAAoB,SAAS,EAAE,CAAC,EAAE,SAAS;KAC7C,CAAC,CAAC;IAEH,OAAO,CACL,gCAAK,SAAS,EAAE,kBAAkB,YAChC,gDAAiB,MAAM,aACpB,MAAM,KAAK,QAAQ,IAAI,CACtB,wCACE,mCACE,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,EAAE,EAC9C,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,CAAC,EAAC,IAAI,GACN,GACA,CACL,EAED,mCAAQ,SAAS,EAAE,kBAAkB,EAAE,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,IAAI,GAAG,EAChE,iCACE,CAAC,EAAC,KAAK,EACP,CAAC,EAAC,KAAK,EACP,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAC,wBAAwB,EAClC,UAAU,EAAC,QAAQ,EACnB,gBAAgB,EAAC,QAAQ,EACzB,EAAE,EAAC,OAAO,YAET,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAC7B,IACH,GACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { Typography } from '../typography';\n\ninterface Step {\n /** Content displayed as the step label */\n content: React.ReactNode;\n /** Explicit status for the step. When set to `error`, the step is rendered in an error state */\n status?: 'default' | 'error';\n}\n\ninterface BaseWizardProps {\n /** Layout orientation of the wizard */\n orientation?: 'horizontal' | 'vertical';\n /** Visual size of the wizard */\n size?: 'small' | 'large';\n /** Additional style */\n style?: React.CSSProperties;\n /** Additional class name */\n className?: string;\n /** Zero-based index of the active step */\n activeStepIndex: number;\n /** Steps to display in the wizard */\n steps: Step[];\n}\n\ntype HorizontalWizardProps = BaseWizardProps & {\n orientation: 'horizontal';\n /** Alignment of labels/content, is set to `middle` for horizontal orientation and can be set to `top` or `middle` for vertical orientation and is not applicable when `orientation` is undefined */\n alignment?: 'middle';\n};\n\ntype VerticalWizardProps = BaseWizardProps & {\n orientation: 'vertical';\n /** Alignment of labels/content, is set to `middle` for horizontal orientation and can be set to `top` or `middle` for vertical orientation and is not applicable when `orientation` is undefined */\n alignment?: 'top' | 'middle';\n};\n\ntype NonOrientationWizardProps = BaseWizardProps & {\n orientation: undefined;\n /** Alignment of labels/content, is set to `middle` for horizontal orientation and can be set to `top` or `middle` for vertical orientation and is not applicable when `orientation` is undefined */\n alignment?: never;\n};\n\ntype WizardProps =\n | HorizontalWizardProps\n | VerticalWizardProps\n | NonOrientationWizardProps;\n\nexport const Wizard = <T extends React.ElementType = 'div'>({\n as,\n className,\n style,\n size = 'large',\n steps,\n activeStepIndex,\n orientation,\n htmlAttributes,\n alignment = orientation === 'vertical' ? 'top' : 'middle',\n ref,\n}: PolymorphicCommonProps<T, WizardProps>) => {\n useEffect(() => {\n if (activeStepIndex > steps.length - 1 || activeStepIndex < 0) {\n console.warn(\n `[🪡 Needle]: The activeStepIndex in Wizard is out of bounds. The activeStepIndex is ${activeStepIndex} and the number of steps is ${steps.length}.`,\n );\n }\n }, [activeStepIndex, steps.length]);\n\n switch (size) {\n case 'small':\n return (\n <WizardSmall\n as={as}\n orientation={orientation}\n style={style}\n className={className}\n steps={steps}\n activeStepIndex={activeStepIndex}\n ref={ref}\n htmlAttributes={htmlAttributes}\n alignment={alignment}\n />\n );\n case 'large':\n return (\n <WizardLarge\n as={as}\n orientation={orientation}\n style={style}\n className={className}\n steps={steps}\n activeStepIndex={activeStepIndex}\n ref={ref}\n htmlAttributes={htmlAttributes}\n alignment={alignment}\n />\n );\n }\n};\n\nconst getStatus = (activeStepIndex: number, stepIndex: number) =>\n stepIndex === activeStepIndex\n ? 'active'\n : activeStepIndex < stepIndex\n ? 'incomplete'\n : 'complete';\n\nconst WizardLarge = <T extends React.ElementType = 'div'>({\n orientation = 'horizontal',\n activeStepIndex,\n steps,\n as,\n style,\n className,\n htmlAttributes,\n alignment,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, Omit<WizardProps, 'size'>>) => {\n const Component: React.ElementType = as || 'div';\n\n const wizardClasses = classNames(\n 'ndl-wizard',\n 'ndl-wizard-large',\n {\n 'ndl-horizontal': orientation === 'horizontal',\n 'ndl-vertical': orientation === 'vertical',\n [`ndl-wizard-align-${alignment}`]: alignment,\n },\n className,\n );\n\n const componentStyle = {\n gridTemplateColumns:\n orientation === 'horizontal'\n ? `repeat(${steps.length}, 1fr)`\n : `32px 1fr`,\n\n gridTemplateRows:\n orientation === 'vertical' && `repeat(${steps.length}, 1fr)`,\n };\n\n const stepClasses = (index: number, step: Step) => {\n const status = getStatus(activeStepIndex, index);\n\n return classNames('ndl-wizard-step', {\n 'ndl-horizontal': orientation === 'horizontal',\n 'ndl-vertical': orientation === 'vertical',\n 'ndl-wizard-step-line-right': index < steps.length - 1,\n 'ndl-wizard-step-line-left': index > 0,\n 'ndl-wizard-step-complete': status === 'complete',\n 'ndl-wizard-step-active': status === 'active',\n 'ndl-wizard-step-error': step.status === 'error',\n [`ndl-wizard-align-${alignment}`]: alignment,\n });\n };\n\n return (\n <Component\n className={wizardClasses}\n style={{ ...style, ...componentStyle }}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {/* iterate over the steps to render the text content (the first row of the component)*/}\n {steps.map((step, index) => {\n if (typeof step.content === 'string') {\n const wizardStepClasses = classNames('ndl-wizard-step-text', {\n 'ndl-vertical': orientation === 'vertical',\n 'ndl-horizontal': orientation === 'horizontal',\n [`ndl-wizard-align-${alignment}`]: alignment,\n 'ndl-wizard-step-incomplete':\n getStatus(activeStepIndex, index) === 'incomplete',\n });\n\n return (\n <div key={index} className={wizardStepClasses}>\n <Typography variant=\"body-large\">{step.content}</Typography>\n </div>\n );\n } else {\n return <React.Fragment key={index}>{step.content}</React.Fragment>;\n }\n })}\n {/* iterate over the steps to render the circles (iterates again to render the second row of the component) */}\n {steps.map((step, index) => {\n return (\n <div\n className={stepClasses(index, step)}\n key={index}\n style={{\n gridRow: orientation === 'vertical' ? index + 1 : '',\n }}\n >\n <Circle\n status={\n step.status === 'error'\n ? 'error'\n : getStatus(activeStepIndex, index)\n }\n number={index + 1}\n text={step.content}\n alignment={alignment}\n />\n </div>\n );\n })}\n </Component>\n );\n};\n\nexport const WizardSmall = <T extends React.ElementType = 'div'>({\n orientation = 'horizontal',\n activeStepIndex,\n steps,\n as,\n className,\n htmlAttributes,\n style,\n alignment = 'middle',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, Omit<WizardProps, 'size'>>) => {\n const Component = as ?? 'div';\n\n const wizardClasses = classNames(\n 'ndl-wizard',\n 'ndl-wizard-small',\n {\n 'ndl-horizontal': orientation === 'horizontal',\n 'ndl-vertical': orientation === 'vertical',\n [`ndl-wizard-align-${alignment}`]: alignment,\n },\n className,\n );\n\n const stepClasses = (index: number) =>\n classNames('ndl-wizard-step', {\n 'ndl-horizontal': orientation === 'horizontal',\n 'ndl-vertical': orientation === 'vertical',\n 'ndl-wizard-step-active': getStatus(activeStepIndex, index) === 'active',\n 'ndl-wizard-step-complete':\n getStatus(activeStepIndex, index) === 'complete',\n [`ndl-wizard-align-${alignment}`]: alignment,\n });\n\n return (\n <Component\n className={wizardClasses}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-wizard-steps-line\" />\n {steps.map((step, index) => {\n return (\n <div key={index} className={stepClasses(index)}>\n <div className=\"ndl-wizard-circle\"></div>\n </div>\n );\n })}\n <div className=\"ndl-wizard-steps-line\" />\n </Component>\n );\n};\n\nconst Circle = ({\n status,\n number,\n alignment = 'middle',\n}: {\n status: 'active' | 'complete' | 'incomplete' | 'error';\n number: number;\n text: React.ReactNode;\n alignment?: 'top' | 'middle';\n}) => {\n const innerCircleClasses = classNames({\n 'n-fill-primary-bg-strong': status === 'complete' || status === 'active',\n 'n-fill-neutral-bg-stronger': status === 'incomplete',\n 'n-fill-danger-bg-strong': status === 'error',\n });\n const outerCircleClasses = classNames('ndl-wizard-circle', {\n [`ndl-wizard-align-${alignment}`]: alignment,\n });\n\n return (\n <div className={outerCircleClasses}>\n <svg aria-hidden=\"true\">\n {status === 'active' && (\n <g>\n <circle\n className=\"n-stroke-primary-bg-strong\"\n style={{ fill: 'transparent', strokeWidth: 2 }}\n cx=\"16\"\n cy=\"16\"\n r=\"14\"\n />\n </g>\n )}\n\n <circle className={innerCircleClasses} cx=\"16\" cy=\"16\" r=\"12\" />\n <text\n x=\"50%\"\n y=\"50%\"\n fontSize={14}\n className=\"n-fill-neutral-bg-weak\"\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n dy=\"0.1em\"\n >\n {status === 'error' ? '!' : number}\n </text>\n </svg>\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"Wizard.js","sourceRoot":"","sources":["../../../src/wizard/Wizard.tsx"],"names":[],"mappings":";;;;;;;;;;;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mCACE,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,EAAE,EAC9C,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,CAAC,EAAC,IAAI,GACN,GACA,CACL,EAED,mCAAQ,SAAS,EAAE,kBAAkB,EAAE,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,IAAI,GAAG,EAChE,iCACE,CAAC,EAAC,KAAK,EACP,CAAC,EAAC,KAAK,EACP,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAC,wBAAwB,EAClC,UAAU,EAAC,QAAQ,EACnB,gBAAgB,EAAC,QAAQ,EACzB,EAAE,EAAC,OAAO,YAET,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAC7B,IACH,GACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { Typography } from '../typography';\n\ninterface Step {\n /** Content displayed as the step label */\n content: React.ReactNode;\n /** Explicit status for the step. When set to `error`, the step is rendered in an error state */\n status?: 'default' | 'error';\n}\n\ninterface BaseWizardProps {\n /** Layout orientation of the wizard */\n orientation?: 'horizontal' | 'vertical';\n /** Visual size of the wizard */\n size?: 'small' | 'large';\n /** Additional style */\n style?: React.CSSProperties;\n /** Additional class name */\n className?: string;\n /** Zero-based index of the active step */\n activeStepIndex: number;\n /** Steps to display in the wizard */\n steps: Step[];\n}\n\ntype HorizontalWizardProps = BaseWizardProps & {\n orientation: 'horizontal';\n /** Alignment of labels/content, is set to `middle` for horizontal orientation and can be set to `top` or `middle` for vertical orientation and is not applicable when `orientation` is undefined */\n alignment?: 'middle';\n};\n\ntype VerticalWizardProps = BaseWizardProps & {\n orientation: 'vertical';\n /** Alignment of labels/content, is set to `middle` for horizontal orientation and can be set to `top` or `middle` for vertical orientation and is not applicable when `orientation` is undefined */\n alignment?: 'top' | 'middle';\n};\n\ntype NonOrientationWizardProps = BaseWizardProps & {\n orientation: undefined;\n /** Alignment of labels/content, is set to `middle` for horizontal orientation and can be set to `top` or `middle` for vertical orientation and is not applicable when `orientation` is undefined */\n alignment?: never;\n};\n\ntype WizardProps =\n | HorizontalWizardProps\n | VerticalWizardProps\n | NonOrientationWizardProps;\n\nexport const Wizard = <T extends React.ElementType = 'div'>({\n as,\n className,\n style,\n size = 'large',\n steps,\n activeStepIndex,\n orientation,\n htmlAttributes,\n alignment = orientation === 'vertical' ? 'top' : 'middle',\n ref,\n}: PolymorphicCommonProps<T, WizardProps>) => {\n useEffect(() => {\n if (activeStepIndex > steps.length - 1 || activeStepIndex < 0) {\n console.warn(\n `[🪡 Needle]: The activeStepIndex in Wizard is out of bounds. The activeStepIndex is ${activeStepIndex} and the number of steps is ${steps.length}.`,\n );\n }\n }, [activeStepIndex, steps.length]);\n\n switch (size) {\n case 'small':\n return (\n <WizardSmall\n as={as}\n orientation={orientation}\n style={style}\n className={className}\n steps={steps}\n activeStepIndex={activeStepIndex}\n ref={ref}\n htmlAttributes={htmlAttributes}\n alignment={alignment}\n />\n );\n case 'large':\n return (\n <WizardLarge\n as={as}\n orientation={orientation}\n style={style}\n className={className}\n steps={steps}\n activeStepIndex={activeStepIndex}\n ref={ref}\n htmlAttributes={htmlAttributes}\n alignment={alignment}\n />\n );\n }\n};\n\nconst getStatus = (activeStepIndex: number, stepIndex: number) =>\n stepIndex === activeStepIndex\n ? 'active'\n : activeStepIndex < stepIndex\n ? 'incomplete'\n : 'complete';\n\nconst WizardLarge = <T extends React.ElementType = 'div'>({\n orientation = 'horizontal',\n activeStepIndex,\n steps,\n as,\n style,\n className,\n htmlAttributes,\n alignment,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, Omit<WizardProps, 'size'>>) => {\n const Component: React.ElementType = as || 'div';\n\n const wizardClasses = classNames(\n 'ndl-wizard',\n 'ndl-wizard-large',\n {\n 'ndl-horizontal': orientation === 'horizontal',\n 'ndl-vertical': orientation === 'vertical',\n [`ndl-wizard-align-${alignment}`]: alignment,\n },\n className,\n );\n\n const componentStyle = {\n gridTemplateColumns:\n orientation === 'horizontal'\n ? `repeat(${steps.length}, 1fr)`\n : `32px 1fr`,\n\n gridTemplateRows:\n orientation === 'vertical' && `repeat(${steps.length}, 1fr)`,\n };\n\n const stepClasses = (index: number, step: Step) => {\n const status = getStatus(activeStepIndex, index);\n\n return classNames('ndl-wizard-step', {\n 'ndl-horizontal': orientation === 'horizontal',\n 'ndl-vertical': orientation === 'vertical',\n 'ndl-wizard-step-line-right': index < steps.length - 1,\n 'ndl-wizard-step-line-left': index > 0,\n 'ndl-wizard-step-complete': status === 'complete',\n 'ndl-wizard-step-active': status === 'active',\n 'ndl-wizard-step-error': step.status === 'error',\n [`ndl-wizard-align-${alignment}`]: alignment,\n });\n };\n\n return (\n <Component\n className={wizardClasses}\n style={{ ...style, ...componentStyle }}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {/* iterate over the steps to render the text content (the first row of the component)*/}\n {steps.map((step, index) => {\n if (typeof step.content === 'string') {\n const wizardStepClasses = classNames('ndl-wizard-step-text', {\n 'ndl-vertical': orientation === 'vertical',\n 'ndl-horizontal': orientation === 'horizontal',\n [`ndl-wizard-align-${alignment}`]: alignment,\n 'ndl-wizard-step-incomplete':\n getStatus(activeStepIndex, index) === 'incomplete',\n });\n\n return (\n <div key={index} className={wizardStepClasses}>\n <Typography variant=\"body-large\">{step.content}</Typography>\n </div>\n );\n } else {\n return <React.Fragment key={index}>{step.content}</React.Fragment>;\n }\n })}\n {/* iterate over the steps to render the circles (iterates again to render the second row of the component) */}\n {steps.map((step, index) => {\n return (\n <div\n className={stepClasses(index, step)}\n key={index}\n style={{\n gridRow: orientation === 'vertical' ? index + 1 : '',\n }}\n >\n <Circle\n status={\n step.status === 'error'\n ? 'error'\n : getStatus(activeStepIndex, index)\n }\n number={index + 1}\n text={step.content}\n alignment={alignment}\n />\n </div>\n );\n })}\n </Component>\n );\n};\n\nexport const WizardSmall = <T extends React.ElementType = 'div'>({\n orientation = 'horizontal',\n activeStepIndex,\n steps,\n as,\n className,\n htmlAttributes,\n style,\n alignment = 'middle',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, Omit<WizardProps, 'size'>>) => {\n const Component = as ?? 'div';\n\n const wizardClasses = classNames(\n 'ndl-wizard',\n 'ndl-wizard-small',\n {\n 'ndl-horizontal': orientation === 'horizontal',\n 'ndl-vertical': orientation === 'vertical',\n [`ndl-wizard-align-${alignment}`]: alignment,\n },\n className,\n );\n\n const stepClasses = (index: number) =>\n classNames('ndl-wizard-step', {\n 'ndl-horizontal': orientation === 'horizontal',\n 'ndl-vertical': orientation === 'vertical',\n 'ndl-wizard-step-active': getStatus(activeStepIndex, index) === 'active',\n 'ndl-wizard-step-complete':\n getStatus(activeStepIndex, index) === 'complete',\n [`ndl-wizard-align-${alignment}`]: alignment,\n });\n\n return (\n <Component\n className={wizardClasses}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-wizard-steps-line\" />\n {steps.map((step, index) => {\n return (\n <div key={index} className={stepClasses(index)}>\n <div className=\"ndl-wizard-circle\"></div>\n </div>\n );\n })}\n <div className=\"ndl-wizard-steps-line\" />\n </Component>\n );\n};\n\nconst Circle = ({\n status,\n number,\n alignment = 'middle',\n}: {\n status: 'active' | 'complete' | 'incomplete' | 'error';\n number: number;\n text: React.ReactNode;\n alignment?: 'top' | 'middle';\n}) => {\n const innerCircleClasses = classNames({\n 'n-fill-danger-bg-strong': status === 'error',\n 'n-fill-neutral-bg-stronger': status === 'incomplete',\n 'n-fill-primary-bg-strong': status === 'complete' || status === 'active',\n });\n const outerCircleClasses = classNames('ndl-wizard-circle', {\n [`ndl-wizard-align-${alignment}`]: alignment,\n });\n\n return (\n <div className={outerCircleClasses}>\n <svg aria-hidden=\"true\">\n {status === 'active' && (\n <g>\n <circle\n className=\"n-stroke-primary-bg-strong\"\n style={{ fill: 'transparent', strokeWidth: 2 }}\n cx=\"16\"\n cy=\"16\"\n r=\"14\"\n />\n </g>\n )}\n\n <circle className={innerCircleClasses} cx=\"16\" cy=\"16\" r=\"12\" />\n <text\n x=\"50%\"\n y=\"50%\"\n fontSize={14}\n className=\"n-fill-neutral-bg-weak\"\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n dy=\"0.1em\"\n >\n {status === 'error' ? '!' : number}\n </text>\n </svg>\n </div>\n );\n};\n"]}
@@ -26,21 +26,20 @@ const jsx_runtime_1 = require("react/jsx-runtime");
26
26
  const index_1 = require("../index");
27
27
  const _1 = require(".");
28
28
  const componentMeta = {
29
- title: 'Components/Wizard',
30
- id: 'components-wizard',
31
29
  component: index_1.Wizard,
32
- tags: ['docsPage'],
33
- parameters: {
34
- controls: { disable: true },
35
- },
36
30
  decorators: [
37
31
  (Story) => ((0, jsx_runtime_1.jsx)("div", { className: "n-w-1/2 n-mx-auto", children: (0, jsx_runtime_1.jsx)(Story, {}) })),
38
32
  ],
33
+ id: 'components-wizard',
34
+ parameters: {
35
+ controls: { disable: true },
36
+ },
37
+ tags: ['docsPage'],
38
+ title: 'Components/Wizard',
39
39
  };
40
40
  exports.default = componentMeta;
41
41
  exports.Horizontal = {
42
42
  args: {},
43
- render: _1.WizardHorizontal,
44
43
  parameters: {
45
44
  docs: {
46
45
  source: {
@@ -48,10 +47,10 @@ exports.Horizontal = {
48
47
  },
49
48
  },
50
49
  },
50
+ render: _1.WizardHorizontal,
51
51
  };
52
52
  exports.HorizontalSmall = {
53
53
  args: {},
54
- render: _1.WizardHorizontalSmall,
55
54
  parameters: {
56
55
  docs: {
57
56
  source: {
@@ -59,10 +58,13 @@ exports.HorizontalSmall = {
59
58
  },
60
59
  },
61
60
  },
61
+ render: _1.WizardHorizontalSmall,
62
62
  };
63
63
  exports.Vertical = {
64
64
  args: {},
65
- render: _1.WizardVertical,
65
+ decorators: [
66
+ (Story) => ((0, jsx_runtime_1.jsx)("div", { className: "n-flex n-justify-center", children: (0, jsx_runtime_1.jsx)(Story, {}) })),
67
+ ],
66
68
  parameters: {
67
69
  docs: {
68
70
  source: {
@@ -70,13 +72,10 @@ exports.Vertical = {
70
72
  },
71
73
  },
72
74
  },
73
- decorators: [
74
- (Story) => ((0, jsx_runtime_1.jsx)("div", { className: "n-flex n-justify-center", children: (0, jsx_runtime_1.jsx)(Story, {}) })),
75
- ],
75
+ render: _1.WizardVertical,
76
76
  };
77
77
  exports.VerticalSmall = {
78
78
  args: {},
79
- render: _1.WizardVerticalSmall,
80
79
  parameters: {
81
80
  docs: {
82
81
  source: {
@@ -84,10 +83,10 @@ exports.VerticalSmall = {
84
83
  },
85
84
  },
86
85
  },
86
+ render: _1.WizardVerticalSmall,
87
87
  };
88
88
  exports.ErrorState = {
89
89
  args: {},
90
- render: _1.WizardErrorState,
91
90
  parameters: {
92
91
  docs: {
93
92
  source: {
@@ -95,5 +94,6 @@ exports.ErrorState = {
95
94
  },
96
95
  },
97
96
  },
97
+ render: _1.WizardErrorState,
98
98
  };
99
99
  //# sourceMappingURL=wizard.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wizard.stories.js","sourceRoot":"","sources":["../../../../src/wizard/stories/wizard.stories.tsx"],"names":[],"mappings":";;;;AAuBA,oCAAkC;AAClC,wBAWW;AAEX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AU,GAAU;IAC/B,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,mBAAgB;IACxB,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,yBAAsB;aAC7B;SACF;KACF;CACF,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { type Meta, type StoryObj } from '@storybook/react-vite';\n\nimport { Wizard } from '../index';\nimport {\n WizardErrorState,\n WizardErrorStateSource,\n WizardHorizontal,\n WizardHorizontalSmall,\n WizardHorizontalSmallSource,\n WizardHorizontalSource,\n WizardVertical,\n WizardVerticalSmall,\n WizardVerticalSmallSource,\n WizardVerticalSource,\n} from '.';\n\nconst componentMeta: Meta<typeof Wizard> = {\n title: 'Components/Wizard',\n id: 'components-wizard',\n component: Wizard,\n tags: ['docsPage'],\n parameters: {\n controls: { disable: true },\n },\n decorators: [\n (Story) => (\n <div className=\"n-w-1/2 n-mx-auto\">\n <Story />\n </div>\n ),\n ],\n};\n\nexport default componentMeta;\ntype Story = StoryObj<typeof Wizard>;\n\nexport const Horizontal: Story = {\n args: {},\n render: WizardHorizontal,\n parameters: {\n docs: {\n source: {\n code: WizardHorizontalSource,\n },\n },\n },\n};\n\nexport const HorizontalSmall: Story = {\n args: {},\n render: WizardHorizontalSmall,\n parameters: {\n docs: {\n source: {\n code: WizardHorizontalSmallSource,\n },\n },\n },\n};\n\nexport const Vertical: Story = {\n args: {},\n render: WizardVertical,\n parameters: {\n docs: {\n source: {\n code: WizardVerticalSource,\n },\n },\n },\n decorators: [\n (Story) => (\n <div className=\"n-flex n-justify-center\">\n <Story />\n </div>\n ),\n ],\n};\n\nexport const VerticalSmall: Story = {\n args: {},\n render: WizardVerticalSmall,\n parameters: {\n docs: {\n source: {\n code: WizardVerticalSmallSource,\n },\n },\n },\n};\n\nexport const ErrorState: Story = {\n args: {},\n render: WizardErrorState,\n parameters: {\n docs: {\n source: {\n code: WizardErrorStateSource,\n },\n },\n },\n};\n"]}
1
+ {"version":3,"file":"wizard.stories.js","sourceRoot":"","sources":["../../../../src/wizard/stories/wizard.stories.tsx"],"names":[],"mappings":";;;;AAuBA,oCAAkC;AAClC,wBAWW;AAEX,MAAM,aAAa,GAAwB;IACzC,SAAS,EAAE,cAAM;IACjB,UAAU,EAAE;QACV,CAAC,KAAK,EAAE,EAAE,CAAC,CACT,gCAAK,SAAS,EAAC,mBAAmB,YAChC,uBAAC,KAAK,KAAG,GACL,CACP;KACF;IACD,EAAE,EAAE,mBAAmB;IACvB,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KAC5B;IACD,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,KAAK,EAAE,mBAAmB;CAC3B,CAAC;AAEF,kBAAe,aAAa,CAAC;AAGhB,QAAA,UAAU,GAAU;IAC/B,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,yBAAsB;aAC7B;SACF;KACF;IACD,MAAM,EAAE,mBAAgB;CACzB,CAAC;AAEW,QAAA,eAAe,GAAU;IACpC,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,8BAA2B;aAClC;SACF;KACF;IACD,MAAM,EAAE,wBAAqB;CAC9B,CAAC;AAEW,QAAA,QAAQ,GAAU;IAC7B,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,CAAC,KAAK,EAAE,EAAE,CAAC,CACT,gCAAK,SAAS,EAAC,yBAAyB,YACtC,uBAAC,KAAK,KAAG,GACL,CACP;KACF;IACD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,uBAAoB;aAC3B;SACF;KACF;IACD,MAAM,EAAE,iBAAc;CACvB,CAAC;AAEW,QAAA,aAAa,GAAU;IAClC,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,4BAAyB;aAChC;SACF;KACF;IACD,MAAM,EAAE,sBAAmB;CAC5B,CAAC;AAEW,QAAA,UAAU,GAAU;IAC/B,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,yBAAsB;aAC7B;SACF;KACF;IACD,MAAM,EAAE,mBAAgB;CACzB,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { type Meta, type StoryObj } from '@storybook/react-vite';\n\nimport { Wizard } from '../index';\nimport {\n WizardErrorState,\n WizardErrorStateSource,\n WizardHorizontal,\n WizardHorizontalSmall,\n WizardHorizontalSmallSource,\n WizardHorizontalSource,\n WizardVertical,\n WizardVerticalSmall,\n WizardVerticalSmallSource,\n WizardVerticalSource,\n} from '.';\n\nconst componentMeta: Meta<typeof Wizard> = {\n component: Wizard,\n decorators: [\n (Story) => (\n <div className=\"n-w-1/2 n-mx-auto\">\n <Story />\n </div>\n ),\n ],\n id: 'components-wizard',\n parameters: {\n controls: { disable: true },\n },\n tags: ['docsPage'],\n title: 'Components/Wizard',\n};\n\nexport default componentMeta;\ntype Story = StoryObj<typeof Wizard>;\n\nexport const Horizontal: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: WizardHorizontalSource,\n },\n },\n },\n render: WizardHorizontal,\n};\n\nexport const HorizontalSmall: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: WizardHorizontalSmallSource,\n },\n },\n },\n render: WizardHorizontalSmall,\n};\n\nexport const Vertical: Story = {\n args: {},\n decorators: [\n (Story) => (\n <div className=\"n-flex n-justify-center\">\n <Story />\n </div>\n ),\n ],\n parameters: {\n docs: {\n source: {\n code: WizardVerticalSource,\n },\n },\n },\n render: WizardVertical,\n};\n\nexport const VerticalSmall: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: WizardVerticalSmallSource,\n },\n },\n },\n render: WizardVerticalSmall,\n};\n\nexport const ErrorState: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: WizardErrorStateSource,\n },\n },\n },\n render: WizardErrorState,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/_common/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG","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 { type tokens } from '@neo4j-ndl/base';\nimport type React from 'react';\n\nimport type { Tooltip } from '../tooltip';\n\nexport type HtmlAttributes<T extends React.ElementType> =\n React.ComponentPropsWithoutRef<T> & {\n [key: `data-${string}`]: string | undefined;\n };\n\ntype BaseProps<T extends React.ElementType> = {\n /**\n * Additional classnames will be applied to the root element.\n */\n className?: string;\n /**\n * Additional css styling. Will be applied to the root element.\n */\n style?: React.CSSProperties;\n\n /**\n * Html attributes to apply to the root element. This will override any default html attributes, use with caution.\n */\n htmlAttributes?: HtmlAttributes<T>;\n\n /**\n * A ref to apply to the root element.\n */\n ref?: React.ComponentPropsWithRef<T>['ref'];\n};\n\nexport type PolymorphicCommonProps<T extends React.ElementType, P> = P & {\n /**\n * An override of the default HTML tag of the root of the component.\n * Can also be another React component.\n */\n as?: T;\n} & BaseProps<T>;\n\nexport type CommonProps<T extends React.ElementType, P> = P & BaseProps<T>;\n\nexport type TooltipObjectProps = {\n root?: Partial<React.ComponentProps<typeof Tooltip>>;\n trigger?: Partial<React.ComponentProps<typeof Tooltip.Trigger>>;\n content?: Partial<React.ComponentProps<typeof Tooltip.Content>>;\n};\n\nexport type Spacing = keyof typeof tokens.space;\n\nexport type Radius = keyof typeof tokens.borderRadius;\n\n/**\n * Currently supporting only native HTML elements.\n */\nexport type CustomElementType = keyof HTMLElementTagNameMap;\n\n/**\n * More info here:\n * https://stackoverflow.com/questions/75085783/conditional-react-component-properties-with-multiple-generics#comment132505139_75086121\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ReactComponent = (args: any) => React.JSX.Element;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/_common/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG","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 { type tokens } from '@neo4j-ndl/base';\nimport type React from 'react';\n\nimport type { Tooltip } from '../tooltip';\n\nexport type HtmlAttributes<T extends React.ElementType> =\n React.ComponentPropsWithoutRef<T> & {\n [key: `data-${string}`]: string | undefined;\n };\n\ntype BaseProps<T extends React.ElementType> = {\n /**\n * Additional classnames will be applied to the root element.\n */\n className?: string;\n /**\n * Additional css styling. Will be applied to the root element.\n */\n style?: React.CSSProperties;\n\n /**\n * Html attributes to apply to the root element. This will override any default html attributes, use with caution.\n */\n htmlAttributes?: HtmlAttributes<T>;\n\n /**\n * A ref to apply to the root element.\n */\n ref?: React.ComponentPropsWithRef<T>['ref'];\n};\n\nexport type PolymorphicCommonProps<T extends React.ElementType, P> = P & {\n /**\n * An override of the default HTML tag of the root of the component.\n * Can also be another React component.\n */\n as?: T;\n} & BaseProps<T>;\n\nexport type CommonProps<T extends React.ElementType, P> = P & BaseProps<T>;\n\nexport type TooltipObjectProps = {\n root?: Partial<React.ComponentProps<typeof Tooltip>>;\n trigger?: Partial<React.ComponentProps<typeof Tooltip.Trigger>>;\n content?: Partial<React.ComponentProps<typeof Tooltip.Content>>;\n};\n\nexport type Spacing = keyof typeof tokens.space;\n\nexport type Radius = keyof typeof tokens.borderRadius;\n\n/**\n * Currently supporting only native HTML elements.\n */\nexport type CustomElementType = keyof HTMLElementTagNameMap;\n\n/**\n * More info here:\n * https://stackoverflow.com/questions/75085783/conditional-react-component-properties-with-multiple-generics#comment132505139_75086121\n */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ReactComponent = (args: any) => React.JSX.Element;\n"]}
@@ -67,14 +67,14 @@ export const useOnClickOutside = (ref, handler) => {
67
67
  }
68
68
  handler(event); // Call the handler only if the click is outside of the element passed.
69
69
  };
70
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
71
71
  document.addEventListener('mousedown', listener);
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
73
73
  document.addEventListener('touchstart', listener);
74
74
  return () => {
75
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
76
76
  document.removeEventListener('mousedown', listener);
77
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
78
78
  document.removeEventListener('touchstart', listener);
79
79
  };
80
80
  }, [ref, handler]); // Reload only if ref or handler changes
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/_common/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAGL,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAC;AAIf,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE,CAC9C,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAEtC,qCAAqC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAC5C,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAAE,EAAE,CACtD,OAAO,CAAC,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K,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC,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 { tokens } from '@neo4j-ndl/base';\nimport {\n type MouseEvent,\n type TouchEvent,\n useCallback,\n useEffect,\n useRef,\n} from 'react';\n\nimport type { Radius, Spacing } from './types';\n\nexport const removeNewlines = (input: string) =>\n input.replace(/(\\r\\n|\\n|\\r)/gm, '');\n\n/** Remove extra spaces from sting */\nexport const removeSpaces = (input: string) =>\n input.replace(/\\s+/g, ' ').trim();\n\nexport const needleWarningMessage = (message: string) =>\n console.warn(`[🪡 Needle]: ${message}`);\n\nconst getScrollbarSize = (doc: Document): number => {\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes\n const documentWidth = doc.documentElement.clientWidth;\n const scrollBarSize = Math.abs(window.innerWidth - documentWidth);\n // Firefox with 110% and 120% zoom level return 1px even if there is no scrollbar\n return scrollBarSize > 1 ? scrollBarSize : 0;\n};\n\nconst getPaddingRight = (element: Element): number =>\n parseInt(window.getComputedStyle(element).paddingRight, 10) || 0;\n\n/**\n * Toggles scroll on the provided document.\n * Useful for disabling scroll when a popup is open (ie ContextMenu/Modal)\n */\nexport const useDocumentScrollToggle = () => {\n const bodyPadding = useRef<number>(0);\n\n return useCallback((disable: boolean, doc: Document = document) => {\n if (disable) {\n const existingPaddingRight = getPaddingRight(doc.body);\n bodyPadding.current = existingPaddingRight;\n const newPaddingRight = existingPaddingRight + getScrollbarSize(doc);\n doc.body.style.overflow = 'hidden';\n doc.body.style.paddingRight = `${newPaddingRight}px`;\n } else {\n doc.body.style.overflow = '';\n doc.body.style.paddingRight = `${bodyPadding.current}px`;\n }\n }, []);\n};\n\n/**\n * Detect if there is a click event outside\n * of the provided element\n * Source:\n * https://hashnode.com/post/useonclickoutside-custom-hook-to-detect-the-mouse-click-on-outside-typescript-ckrejmy3h0k5r91s18iu42t28\n */\nexport const useOnClickOutside = <T extends HTMLElement = HTMLElement>(\n ref: React.RefObject<T>,\n handler: (event: MouseEvent | TouchEvent) => void,\n) => {\n useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n const el = ref?.current;\n if (!el || el.contains((event?.target as Node) || null)) {\n return;\n }\n\n handler(event); // Call the handler only if the click is outside of the element passed.\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n document.addEventListener('mousedown', listener as any);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n document.addEventListener('touchstart', listener as any);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n document.removeEventListener('mousedown', listener as any);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n document.removeEventListener('touchstart', listener as any);\n };\n }, [ref, handler]); // Reload only if ref or handler changes\n};\n\n/**\n * X - char long pseudo-random string\n */\nexport const randomId = (length: number) =>\n Math.random()\n .toString(36)\n .slice(2, length + 2);\n\n// Utility / Type-Guard if the object is a ref\nexport function isRefObject<T>(\n obj: React.RefObject<T> | T,\n): obj is React.RefObject<T> {\n return obj && typeof obj === 'object' && 'current' in obj;\n}\n\n/**\n * Equivalent to prevUntil/nextUntil in jQuery\n * https://api.jquery.com/prevUntil/\n * https://api.jquery.com/nextUntil/\n *\n * Additional functionality is added to circle back\n * to the beginning of a list of siblings if it reaches the end\n * or vice versa.\n */\nexport function findUntil(\n direction: 'next' | 'prev',\n el: Element | ChildNode,\n matchSelector: string,\n): Element | null {\n const element: ChildNode = el;\n\n if (!element.parentElement) {\n return null;\n }\n\n const allSiblings = [...element.parentElement.children].filter((sibling) =>\n sibling.matches(matchSelector),\n );\n\n const index = allSiblings.findIndex((sibling) =>\n sibling.isEqualNode(element),\n );\n\n if (index === -1) {\n return null;\n }\n\n const newIndex =\n direction === 'next'\n ? (index + 1) % allSiblings.length\n : (index - 1 + allSiblings.length) % allSiblings.length;\n\n return allSiblings[newIndex];\n}\n\n/**\n * Find all html elements that are focusable given a parent element\n * @param parentElement the parent element\n * @returns an array of HTML elements\n */\nexport const findFocusableChildren = (parentElement: HTMLElement) => {\n const focusableElements =\n 'a:not([disabled]), button:not([disabled]), input[type=text]:not([disabled]), input[type=checkbox]:not([disabled]), [tabindex]:not([disabled]):not([tabindex=\"-1\"])';\n\n const focusable = Array.from(\n parentElement.querySelectorAll(focusableElements),\n ).filter((element) => {\n if (element instanceof HTMLElement) {\n return true;\n }\n\n return false;\n });\n return focusable;\n};\n\n/**\n * Using the element that currently has focus, finds the previous sibling of the currently focused element that is focusable\n * @param parentRef the parent element\n * @returns the previous focusable element\n */\nexport const findFocusableSibling = (\n parentRef: React.RefObject<HTMLElement | null>,\n direction: 'prev' | 'next',\n): HTMLElement | undefined => {\n const { current } = parentRef;\n const { activeElement } = document;\n\n if (current === null || activeElement === null) {\n return undefined;\n }\n\n const focusable = findFocusableChildren(current);\n const index = focusable.indexOf(activeElement);\n if (index > -1) {\n const siblingElement = focusable[index + (direction === 'next' ? 1 : -1)];\n if (\n siblingElement === undefined ||\n !(siblingElement instanceof HTMLElement)\n ) {\n return undefined;\n }\n return siblingElement;\n }\n return undefined;\n};\n\n/**\n * Convert hex color to rgb format\n *\n * @param hex color in hex code format\n * @returns color in rgb format rgb(_, _, _)\n */\nexport const convertHexToRGB = (hex: string) => {\n hex = hex.replace(/^#/, '');\n\n const red = parseInt(hex.substring(0, 2), 16);\n const green = parseInt(hex.substring(2, 4), 16);\n const blue = parseInt(hex.substring(4, 6), 16);\n\n return `rgb(${red}, ${green}, ${blue})`;\n};\n\nexport const SpacingDefaults = {\n gap: '4',\n padding: '4',\n paddingBlockEnd: undefined,\n paddingBlockStart: undefined,\n paddingInline: undefined,\n paddingInlineEnd: undefined,\n paddingInlineStart: undefined,\n} as const;\n\nexport const getSpacing = (\n spacing: Spacing | undefined,\n property: keyof typeof SpacingDefaults,\n) => {\n return spacing\n ? tokens.space[spacing || SpacingDefaults[property]]\n : undefined;\n};\n\nexport const RadiusDefaults = {\n borderRadius: undefined,\n};\n\nexport const getRadius = (\n spacing: Radius | undefined,\n property: keyof typeof RadiusDefaults,\n) => {\n return spacing\n ? tokens.borderRadius[spacing || RadiusDefaults[property]]\n : undefined;\n};\n\nexport const parseRgbString = (rgbString: string): [number, number, number] => {\n const match = rgbString.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);\n if (!match) {\n throw new Error(`Unable to parse RGB color: ${rgbString}`);\n }\n return [Number(match[1]), Number(match[2]), Number(match[3])];\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/_common/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAGL,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAC;AAIf,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE,CAC9C,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAEtC,qCAAqC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,C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SAAS,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAiB,EAA4B,EAAE;IAC5E,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC,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 { tokens } from '@neo4j-ndl/base';\nimport {\n type MouseEvent,\n type TouchEvent,\n useCallback,\n useEffect,\n useRef,\n} from 'react';\n\nimport type { Radius, Spacing } from './types';\n\nexport const removeNewlines = (input: string) =>\n input.replace(/(\\r\\n|\\n|\\r)/gm, '');\n\n/** Remove extra spaces from sting */\nexport const removeSpaces = (input: string) =>\n input.replace(/\\s+/g, ' ').trim();\n\nexport const needleWarningMessage = (message: string) =>\n console.warn(`[🪡 Needle]: ${message}`);\n\nconst getScrollbarSize = (doc: Document): number => {\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes\n const documentWidth = doc.documentElement.clientWidth;\n const scrollBarSize = Math.abs(window.innerWidth - documentWidth);\n // Firefox with 110% and 120% zoom level return 1px even if there is no scrollbar\n return scrollBarSize > 1 ? scrollBarSize : 0;\n};\n\nconst getPaddingRight = (element: Element): number =>\n parseInt(window.getComputedStyle(element).paddingRight, 10) || 0;\n\n/**\n * Toggles scroll on the provided document.\n * Useful for disabling scroll when a popup is open (ie ContextMenu/Modal)\n */\nexport const useDocumentScrollToggle = () => {\n const bodyPadding = useRef<number>(0);\n\n return useCallback((disable: boolean, doc: Document = document) => {\n if (disable) {\n const existingPaddingRight = getPaddingRight(doc.body);\n bodyPadding.current = existingPaddingRight;\n const newPaddingRight = existingPaddingRight + getScrollbarSize(doc);\n doc.body.style.overflow = 'hidden';\n doc.body.style.paddingRight = `${newPaddingRight}px`;\n } else {\n doc.body.style.overflow = '';\n doc.body.style.paddingRight = `${bodyPadding.current}px`;\n }\n }, []);\n};\n\n/**\n * Detect if there is a click event outside\n * of the provided element\n * Source:\n * https://hashnode.com/post/useonclickoutside-custom-hook-to-detect-the-mouse-click-on-outside-typescript-ckrejmy3h0k5r91s18iu42t28\n */\nexport const useOnClickOutside = <T extends HTMLElement = HTMLElement>(\n ref: React.RefObject<T>,\n handler: (event: MouseEvent | TouchEvent) => void,\n) => {\n useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n const el = ref?.current;\n if (!el || el.contains((event?.target as Node) || null)) {\n return;\n }\n\n handler(event); // Call the handler only if the click is outside of the element passed.\n };\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n document.addEventListener('mousedown', listener as any);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n document.addEventListener('touchstart', listener as any);\n\n return () => {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n document.removeEventListener('mousedown', listener as any);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n document.removeEventListener('touchstart', listener as any);\n };\n }, [ref, handler]); // Reload only if ref or handler changes\n};\n\n/**\n * X - char long pseudo-random string\n */\nexport const randomId = (length: number) =>\n Math.random()\n .toString(36)\n .slice(2, length + 2);\n\n// Utility / Type-Guard if the object is a ref\nexport function isRefObject<T>(\n obj: React.RefObject<T> | T,\n): obj is React.RefObject<T> {\n return obj && typeof obj === 'object' && 'current' in obj;\n}\n\n/**\n * Equivalent to prevUntil/nextUntil in jQuery\n * https://api.jquery.com/prevUntil/\n * https://api.jquery.com/nextUntil/\n *\n * Additional functionality is added to circle back\n * to the beginning of a list of siblings if it reaches the end\n * or vice versa.\n */\nexport function findUntil(\n direction: 'next' | 'prev',\n el: Element | ChildNode,\n matchSelector: string,\n): Element | null {\n const element: ChildNode = el;\n\n if (!element.parentElement) {\n return null;\n }\n\n const allSiblings = [...element.parentElement.children].filter((sibling) =>\n sibling.matches(matchSelector),\n );\n\n const index = allSiblings.findIndex((sibling) =>\n sibling.isEqualNode(element),\n );\n\n if (index === -1) {\n return null;\n }\n\n const newIndex =\n direction === 'next'\n ? (index + 1) % allSiblings.length\n : (index - 1 + allSiblings.length) % allSiblings.length;\n\n return allSiblings[newIndex];\n}\n\n/**\n * Find all html elements that are focusable given a parent element\n * @param parentElement the parent element\n * @returns an array of HTML elements\n */\nexport const findFocusableChildren = (parentElement: HTMLElement) => {\n const focusableElements =\n 'a:not([disabled]), button:not([disabled]), input[type=text]:not([disabled]), input[type=checkbox]:not([disabled]), [tabindex]:not([disabled]):not([tabindex=\"-1\"])';\n\n const focusable = Array.from(\n parentElement.querySelectorAll(focusableElements),\n ).filter((element) => {\n if (element instanceof HTMLElement) {\n return true;\n }\n\n return false;\n });\n return focusable;\n};\n\n/**\n * Using the element that currently has focus, finds the previous sibling of the currently focused element that is focusable\n * @param parentRef the parent element\n * @returns the previous focusable element\n */\nexport const findFocusableSibling = (\n parentRef: React.RefObject<HTMLElement | null>,\n direction: 'prev' | 'next',\n): HTMLElement | undefined => {\n const { current } = parentRef;\n const { activeElement } = document;\n\n if (current === null || activeElement === null) {\n return undefined;\n }\n\n const focusable = findFocusableChildren(current);\n const index = focusable.indexOf(activeElement);\n if (index > -1) {\n const siblingElement = focusable[index + (direction === 'next' ? 1 : -1)];\n if (\n siblingElement === undefined ||\n !(siblingElement instanceof HTMLElement)\n ) {\n return undefined;\n }\n return siblingElement;\n }\n return undefined;\n};\n\n/**\n * Convert hex color to rgb format\n *\n * @param hex color in hex code format\n * @returns color in rgb format rgb(_, _, _)\n */\nexport const convertHexToRGB = (hex: string) => {\n hex = hex.replace(/^#/, '');\n\n const red = parseInt(hex.substring(0, 2), 16);\n const green = parseInt(hex.substring(2, 4), 16);\n const blue = parseInt(hex.substring(4, 6), 16);\n\n return `rgb(${red}, ${green}, ${blue})`;\n};\n\nexport const SpacingDefaults = {\n gap: '4',\n padding: '4',\n paddingBlockEnd: undefined,\n paddingBlockStart: undefined,\n paddingInline: undefined,\n paddingInlineEnd: undefined,\n paddingInlineStart: undefined,\n} as const;\n\nexport const getSpacing = (\n spacing: Spacing | undefined,\n property: keyof typeof SpacingDefaults,\n) => {\n return spacing\n ? tokens.space[spacing || SpacingDefaults[property]]\n : undefined;\n};\n\nexport const RadiusDefaults = {\n borderRadius: undefined,\n};\n\nexport const getRadius = (\n spacing: Radius | undefined,\n property: keyof typeof RadiusDefaults,\n) => {\n return spacing\n ? tokens.borderRadius[spacing || RadiusDefaults[property]]\n : undefined;\n};\n\nexport const parseRgbString = (rgbString: string): [number, number, number] => {\n const match = rgbString.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);\n if (!match) {\n throw new Error(`Unable to parse RGB color: ${rgbString}`);\n }\n return [Number(match[1]), Number(match[2]), Number(match[3])];\n};\n"]}
@@ -99,14 +99,14 @@ const AccordionComponent = function AccordionComponent(_a) {
99
99
  const { expandedItemId } = restProps;
100
100
  const contextValue = isMultiple
101
101
  ? {
102
- onChange,
103
- isMultiple,
104
102
  expandedItemIds,
103
+ isMultiple,
104
+ onChange,
105
105
  }
106
106
  : {
107
- onChange,
108
- isMultiple,
109
107
  expandedItemId,
108
+ isMultiple,
109
+ onChange,
110
110
  };
111
111
  return (_jsx(Component, Object.assign({ className: classes, style: style, ref: accordionRef, onKeyDown: handleKeyDown, role: "presentation" }, restProps, htmlAttributes, { children: _jsx(AccordionContext.Provider, { value: contextValue, children: children }) })));
112
112
  };
@@ -185,8 +185,8 @@ const BaseAccordionItem = ({ itemId, children, title, className = '', arrowPosit
185
185
  'ndl-accordion-item-content-leading': arrowPosition === 'leading',
186
186
  });
187
187
  return (_jsxs(Component, Object.assign({ className: classes, style: style, id: itemElementId }, htmlAttributes, { children: [_jsxs("div", { className: headerClasses, id: headerElementId, children: [_jsx("button", { id: buttonElementId, onClick: handleOnClick, className: buttonClasses, "aria-expanded": isExpanded, "aria-disabled": isDisabled, "aria-label": title, "aria-controls": panelElementId, disabled: isDisabled, children: _jsxs("span", { className: iconClasses, children: [_jsx(Typography, { variant: titleTypographyVariant, className: titleClasses, htmlAttributes: {
188
- role: 'heading',
189
188
  'aria-level': 2,
189
+ role: 'heading',
190
190
  }, children: title }), _jsx(ChevronDownIconOutline, { className: classNames('ndl-accordion-item-header-icon', {
191
191
  '-n-rotate-180': isExpanded,
192
192
  }) })] }) }), trailingContent && (_jsx(Typography, { as: "div", variant: "body-medium", children: trailingContent }))] }), _jsx("div", { id: panelElementId, ref: contentRef, className: contentClasses, "aria-hidden": !isExpanded, "aria-labelledby": buttonElementId, role: "region", children: _jsx("div", { ref: innerContentRef, className: "ndl-accordion-item-content-inner", onKeyDown: (event) => event.stopPropagation(), children: _jsx(Typography, { variant: "body-medium", className: "n-text-neutral-text-weak", as: "div", children: children }) }) }), hasDivider && _jsx(Divider, {})] })));
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,mBA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Aa,EACrB,SAAS,EAAC,0BAA0B,EACpC,EAAE,EAAC,KAAK,YAEP,QAAQ,GACE,GACT,GACF,EACL,UAAU,IAAI,KAAC,OAAO,KAAG,KAChB,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAGpB,EAG+C,EAAE,EAAE;QAHnD,EACA,SAAS,OAEsC,EAD5C,SAAS,cAFZ,aAGD,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;IAEpE,OAAO,KAAC,iBAAiB,oBAAK,SAAS,IAAE,SAAS,EAAE,OAAO,IAAI,CAAC;AAClE,CAAC,CAAC;AACF,aAAa,CAAC,WAAW,GAAG,gBAAgB,CAAC;AAO7C,MAAM,SAAS,GAAG,CAGhB,EAG6C,EAAE,EAAE;QAHjD,EACA,SAAS,OAEoC,EAD1C,SAAS,cAFZ,aAGD,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAC;IAElE,OAAO,CACL,KAAC,iBAAiB,oBAAK,SAAS,IAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,CAC5E,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAE9C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAClD,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { findUntil } from '../_common/utils';\nimport { Divider } from '../divider';\nimport { ChevronDownIconOutline } from '../icons';\nimport { Typography } from '../typography';\nimport { AccordionContext, useAccordionContext } from './accordion-context';\nimport {\n type AccordionIsMultiple,\n type AccordionIsNotMultiple,\n type AccordionItemId,\n type AccordionItemProps,\n type AccordionProps,\n type ClassicItemProps,\n type IsMultiple,\n type IsNotMultiple,\n} from './accordion-types';\n\nenum AccordionSelector {\n Item = '.ndl-accordion-item',\n ItemNotDisabled = '.ndl-accordion-item:not(.ndl-accordion-item-disabled)',\n}\n\nconst getAccordionItem = (\n accordionElement: Element,\n selector: string,\n direction: 'next' | 'prev' = 'next',\n): Element | null => {\n const itemParent = accordionElement.closest(AccordionSelector.Item);\n if (!itemParent) {\n return null;\n }\n\n return findUntil(direction, itemParent, selector);\n};\n\nconst AccordionComponent = function AccordionComponent<\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n children,\n as,\n isMultiple,\n onChange,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, AccordionProps<T>>) {\n const accordionRef = useRef<U>(null);\n\n useImperativeHandle(ref, () => accordionRef.current!);\n\n const Component: React.ElementType = as || 'div';\n\n // The following function includes code needed to be\n // able to navigate with the arrow keys (not tab).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const accordionElement = accordionRef.current;\n if (!accordionElement) {\n return;\n }\n const activeElement = document.activeElement as HTMLElement;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'next',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'prev',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n activeElement.click();\n }\n };\n\n const focusAccordionItem = (accordionHtmlElement: HTMLElement) => {\n const accordionButton = accordionHtmlElement\n .getElementsByClassName('ndl-accordion-item-header-button')\n .item(0);\n\n if (accordionButton !== null && accordionButton instanceof HTMLElement) {\n accordionButton.focus();\n }\n };\n\n const classes = classNames('ndl-accordion', className);\n\n const { expandedItemIds } = restProps as AccordionIsMultiple<T>;\n const { expandedItemId } = restProps as AccordionIsNotMultiple<T>;\n\n const contextValue = isMultiple\n ? ({\n onChange,\n isMultiple,\n expandedItemIds,\n } as IsMultiple<T>)\n : ({\n onChange,\n isMultiple,\n expandedItemId,\n } as IsNotMultiple<T>);\n\n return (\n <Component\n className={classes}\n style={style}\n ref={accordionRef}\n onKeyDown={handleKeyDown}\n role=\"presentation\"\n {...restProps}\n {...htmlAttributes}\n >\n <AccordionContext.Provider value={contextValue}>\n {children}\n </AccordionContext.Provider>\n </Component>\n );\n};\n\nconst createItemId = (type: string, id: AccordionItemId) =>\n `ndl-accordionitem${type}id-${id}`;\n\nconst BaseAccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n itemId,\n children,\n title,\n className = '',\n arrowPosition = 'leading',\n isDisabled = false,\n onExpandedChange,\n htmlAttributes,\n style,\n as,\n titleTypographyVariant = 'subheading-medium',\n hasDivider = true,\n trailingContent,\n}: PolymorphicCommonProps<U, AccordionItemProps<T>>) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const innerContentRef = useRef<HTMLDivElement>(null);\n const itemElementId = createItemId('item', itemId);\n const headerElementId = createItemId('header', itemId);\n const buttonElementId = createItemId('button', itemId);\n const panelElementId = createItemId('panel', itemId);\n const Component: React.ElementType = as || 'div';\n\n const context = useAccordionContext();\n const { isMultiple } = context;\n\n const isExpanded = isMultiple\n ? context.expandedItemIds.includes(itemId)\n : context.expandedItemId === itemId;\n\n const handleOnClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n // Custom callback to call.\n if (onExpandedChange !== undefined) {\n onExpandedChange(!isExpanded);\n }\n\n if (isMultiple) {\n const { expandedItemIds, onChange }: IsMultiple<T> = context;\n // Multiple expanded.\n if (isExpanded) {\n // Remove from list.\n const newArray: T[] = expandedItemIds.filter(\n (activeId) => activeId !== itemId,\n );\n onChange(newArray);\n } else if (!isExpanded) {\n // Add to list.\n const newArray = [...expandedItemIds];\n newArray.push(itemId);\n onChange(newArray);\n }\n } else {\n const { onChange }: IsNotMultiple<T> = context;\n // Single expanded.\n if (isExpanded) {\n // Set null.\n onChange(null);\n } else if (!isExpanded) {\n // Set to id.\n onChange(itemId);\n }\n }\n\n // The W3 WAI-ARIA states that focus can only happen on the header not the header button.\n document.activeElement?.parentElement?.focus();\n }, [isExpanded, isMultiple, isDisabled, itemId, onExpandedChange, context]);\n\n const classes = classNames('ndl-accordion-item', className, {\n 'ndl-accordion-item-disabled': isDisabled,\n 'ndl-accordion-item-expanded': isExpanded,\n });\n\n const headerClasses = classNames('ndl-accordion-item-header', {\n 'ndl-accordion-item-header-disabled': isDisabled,\n });\n\n const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {\n 'ndl-accordion-item-header-icon-wrapper-leading':\n arrowPosition === 'leading',\n });\n\n const buttonClasses = classNames('ndl-accordion-item-header-button', {\n 'ndl-accordion-item-header-button-disabled': isDisabled,\n });\n\n const titleClasses = classNames('ndl-accordion-item-header-button-title', {\n 'ndl-accordion-item-header-button-title': isDisabled,\n 'ndl-accordion-item-header-button-title-leading':\n arrowPosition === 'leading',\n });\n\n const contentClasses = classNames('ndl-accordion-item-content', {\n 'ndl-accordion-item-content-expanded': isExpanded,\n 'ndl-accordion-item-content-leading': arrowPosition === 'leading',\n });\n\n return (\n <Component\n className={classes}\n style={style}\n id={itemElementId}\n {...htmlAttributes}\n >\n <div className={headerClasses} id={headerElementId}>\n <button\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-label={title}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <Typography\n variant={titleTypographyVariant}\n className={titleClasses}\n htmlAttributes={{\n role: 'heading',\n 'aria-level': 2,\n }}\n >\n {title}\n </Typography>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n '-n-rotate-180': isExpanded,\n })}\n />\n </span>\n </button>\n {trailingContent && (\n <Typography as=\"div\" variant=\"body-medium\">\n {trailingContent}\n </Typography>\n )}\n </div>\n\n <div\n id={panelElementId}\n ref={contentRef}\n className={contentClasses}\n aria-hidden={!isExpanded}\n aria-labelledby={buttonElementId}\n role=\"region\"\n >\n {/* The <div> element has a child <button> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={innerContentRef}\n className=\"ndl-accordion-item-content-inner\"\n onKeyDown={(event) => event.stopPropagation()}\n >\n <Typography\n variant=\"body-medium\"\n className=\"n-text-neutral-text-weak\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\nconst AccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, ClassicItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-classic', className);\n\n return <BaseAccordionItem {...restProps} className={classes} />;\n};\nAccordionItem.displayName = 'Accordion.Item';\n\ntype CleanItemProps<T extends AccordionItemId> = Omit<\n AccordionItemProps<T>,\n 'hasDivider'\n>;\n\nconst CleanItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, CleanItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-clean', className);\n\n return (\n <BaseAccordionItem {...restProps} className={classes} hasDivider={false} />\n );\n};\n\nCleanItem.displayName = 'Accordion.CleanItem';\n\nconst Accordion = Object.assign(AccordionComponent, {\n CleanItem: CleanItem,\n Item: AccordionItem,\n});\n\nexport { Accordion };\n"]}
1
+ {"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAY5E,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IACpB,iDAA4B,CAAA;IAC5B,8FAAyE,CAAA;AAC3E,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAM,gBAAgB,GAAG,CACvB,gBAAyB,EACzB,QAAgB,EAChB,YAA6B,MAAM,EACnB,EAAE;IAClB,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpE,IAAI,CAAC,UAAU,EAAE,CAAC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AElE,OAAO,CACL,KAAC,iBAAiB,oBAAK,SAAS,IAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,CAC5E,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAE9C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAClD,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { findUntil } from '../_common/utils';\nimport { Divider } from '../divider';\nimport { ChevronDownIconOutline } from '../icons';\nimport { Typography } from '../typography';\nimport { AccordionContext, useAccordionContext } from './accordion-context';\nimport {\n type AccordionIsMultiple,\n type AccordionIsNotMultiple,\n type AccordionItemId,\n type AccordionItemProps,\n type AccordionProps,\n type ClassicItemProps,\n type IsMultiple,\n type IsNotMultiple,\n} from './accordion-types';\n\nenum AccordionSelector {\n Item = '.ndl-accordion-item',\n ItemNotDisabled = '.ndl-accordion-item:not(.ndl-accordion-item-disabled)',\n}\n\nconst getAccordionItem = (\n accordionElement: Element,\n selector: string,\n direction: 'next' | 'prev' = 'next',\n): Element | null => {\n const itemParent = accordionElement.closest(AccordionSelector.Item);\n if (!itemParent) {\n return null;\n }\n\n return findUntil(direction, itemParent, selector);\n};\n\nconst AccordionComponent = function AccordionComponent<\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n children,\n as,\n isMultiple,\n onChange,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, AccordionProps<T>>) {\n const accordionRef = useRef<U>(null);\n\n useImperativeHandle(ref, () => accordionRef.current!);\n\n const Component: React.ElementType = as || 'div';\n\n // The following function includes code needed to be\n // able to navigate with the arrow keys (not tab).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const accordionElement = accordionRef.current;\n if (!accordionElement) {\n return;\n }\n const activeElement = document.activeElement as HTMLElement;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'next',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'prev',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n activeElement.click();\n }\n };\n\n const focusAccordionItem = (accordionHtmlElement: HTMLElement) => {\n const accordionButton = accordionHtmlElement\n .getElementsByClassName('ndl-accordion-item-header-button')\n .item(0);\n\n if (accordionButton !== null && accordionButton instanceof HTMLElement) {\n accordionButton.focus();\n }\n };\n\n const classes = classNames('ndl-accordion', className);\n\n const { expandedItemIds } = restProps as AccordionIsMultiple<T>;\n const { expandedItemId } = restProps as AccordionIsNotMultiple<T>;\n\n const contextValue = isMultiple\n ? ({\n expandedItemIds,\n isMultiple,\n onChange,\n } as IsMultiple<T>)\n : ({\n expandedItemId,\n isMultiple,\n onChange,\n } as IsNotMultiple<T>);\n\n return (\n <Component\n className={classes}\n style={style}\n ref={accordionRef}\n onKeyDown={handleKeyDown}\n role=\"presentation\"\n {...restProps}\n {...htmlAttributes}\n >\n <AccordionContext.Provider value={contextValue}>\n {children}\n </AccordionContext.Provider>\n </Component>\n );\n};\n\nconst createItemId = (type: string, id: AccordionItemId) =>\n `ndl-accordionitem${type}id-${id}`;\n\nconst BaseAccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n itemId,\n children,\n title,\n className = '',\n arrowPosition = 'leading',\n isDisabled = false,\n onExpandedChange,\n htmlAttributes,\n style,\n as,\n titleTypographyVariant = 'subheading-medium',\n hasDivider = true,\n trailingContent,\n}: PolymorphicCommonProps<U, AccordionItemProps<T>>) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const innerContentRef = useRef<HTMLDivElement>(null);\n const itemElementId = createItemId('item', itemId);\n const headerElementId = createItemId('header', itemId);\n const buttonElementId = createItemId('button', itemId);\n const panelElementId = createItemId('panel', itemId);\n const Component: React.ElementType = as || 'div';\n\n const context = useAccordionContext();\n const { isMultiple } = context;\n\n const isExpanded = isMultiple\n ? context.expandedItemIds.includes(itemId)\n : context.expandedItemId === itemId;\n\n const handleOnClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n // Custom callback to call.\n if (onExpandedChange !== undefined) {\n onExpandedChange(!isExpanded);\n }\n\n if (isMultiple) {\n const { expandedItemIds, onChange }: IsMultiple<T> = context;\n // Multiple expanded.\n if (isExpanded) {\n // Remove from list.\n const newArray: T[] = expandedItemIds.filter(\n (activeId) => activeId !== itemId,\n );\n onChange(newArray);\n } else if (!isExpanded) {\n // Add to list.\n const newArray = [...expandedItemIds];\n newArray.push(itemId);\n onChange(newArray);\n }\n } else {\n const { onChange }: IsNotMultiple<T> = context;\n // Single expanded.\n if (isExpanded) {\n // Set null.\n onChange(null);\n } else if (!isExpanded) {\n // Set to id.\n onChange(itemId);\n }\n }\n\n // The W3 WAI-ARIA states that focus can only happen on the header not the header button.\n document.activeElement?.parentElement?.focus();\n }, [isExpanded, isMultiple, isDisabled, itemId, onExpandedChange, context]);\n\n const classes = classNames('ndl-accordion-item', className, {\n 'ndl-accordion-item-disabled': isDisabled,\n 'ndl-accordion-item-expanded': isExpanded,\n });\n\n const headerClasses = classNames('ndl-accordion-item-header', {\n 'ndl-accordion-item-header-disabled': isDisabled,\n });\n\n const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {\n 'ndl-accordion-item-header-icon-wrapper-leading':\n arrowPosition === 'leading',\n });\n\n const buttonClasses = classNames('ndl-accordion-item-header-button', {\n 'ndl-accordion-item-header-button-disabled': isDisabled,\n });\n\n const titleClasses = classNames('ndl-accordion-item-header-button-title', {\n 'ndl-accordion-item-header-button-title': isDisabled,\n 'ndl-accordion-item-header-button-title-leading':\n arrowPosition === 'leading',\n });\n\n const contentClasses = classNames('ndl-accordion-item-content', {\n 'ndl-accordion-item-content-expanded': isExpanded,\n 'ndl-accordion-item-content-leading': arrowPosition === 'leading',\n });\n\n return (\n <Component\n className={classes}\n style={style}\n id={itemElementId}\n {...htmlAttributes}\n >\n <div className={headerClasses} id={headerElementId}>\n <button\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-label={title}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <Typography\n variant={titleTypographyVariant}\n className={titleClasses}\n htmlAttributes={{\n 'aria-level': 2,\n role: 'heading',\n }}\n >\n {title}\n </Typography>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n '-n-rotate-180': isExpanded,\n })}\n />\n </span>\n </button>\n {trailingContent && (\n <Typography as=\"div\" variant=\"body-medium\">\n {trailingContent}\n </Typography>\n )}\n </div>\n\n <div\n id={panelElementId}\n ref={contentRef}\n className={contentClasses}\n aria-hidden={!isExpanded}\n aria-labelledby={buttonElementId}\n role=\"region\"\n >\n {/* The <div> element has a child <button> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={innerContentRef}\n className=\"ndl-accordion-item-content-inner\"\n onKeyDown={(event) => event.stopPropagation()}\n >\n <Typography\n variant=\"body-medium\"\n className=\"n-text-neutral-text-weak\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\nconst AccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, ClassicItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-classic', className);\n\n return <BaseAccordionItem {...restProps} className={classes} />;\n};\nAccordionItem.displayName = 'Accordion.Item';\n\ntype CleanItemProps<T extends AccordionItemId> = Omit<\n AccordionItemProps<T>,\n 'hasDivider'\n>;\n\nconst CleanItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, CleanItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-clean', className);\n\n return (\n <BaseAccordionItem {...restProps} className={classes} hasDivider={false} />\n );\n};\n\nCleanItem.displayName = 'Accordion.CleanItem';\n\nconst Accordion = Object.assign(AccordionComponent, {\n CleanItem: CleanItem,\n Item: AccordionItem,\n});\n\nexport { Accordion };\n"]}
@@ -19,7 +19,7 @@
19
19
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  */
21
21
  import { createContext, useContext } from 'react';
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
23
23
  export const AccordionContext = createContext(null);
24
24
  export const useAccordionContext = () => {
25
25
  const context = useContext(AccordionContext);
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-context.js","sourceRoot":"","sources":["../../../src/accordion/accordion-context.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAsBlD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAC3C,IAAI,CACL,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,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 { createContext, useContext } from 'react';\n\nimport {\n type AccordionIsMultiple,\n type AccordionIsNotMultiple,\n type AccordionItemId,\n} from './accordion-types';\n\ntype AccordionContextType<T extends AccordionItemId> =\n | Required<\n Pick<\n AccordionIsMultiple<T>,\n 'onChange' | 'expandedItemIds' | 'isMultiple'\n >\n >\n | Required<\n Pick<\n AccordionIsNotMultiple<T>,\n 'onChange' | 'expandedItemId' | 'isMultiple'\n >\n >;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const AccordionContext = createContext<AccordionContextType<any> | null>(\n null,\n);\n\nexport const useAccordionContext = () => {\n const context = useContext(AccordionContext);\n if (context === null) {\n throw new Error('Accordion used without context');\n }\n return context;\n};\n"]}
1
+ {"version":3,"file":"accordion-context.js","sourceRoot":"","sources":["../../../src/accordion/accordion-context.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAsBlD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAC3C,IAAI,CACL,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,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 { createContext, useContext } from 'react';\n\nimport {\n type AccordionIsMultiple,\n type AccordionIsNotMultiple,\n type AccordionItemId,\n} from './accordion-types';\n\ntype AccordionContextType<T extends AccordionItemId> =\n | Required<\n Pick<\n AccordionIsMultiple<T>,\n 'onChange' | 'expandedItemIds' | 'isMultiple'\n >\n >\n | Required<\n Pick<\n AccordionIsNotMultiple<T>,\n 'onChange' | 'expandedItemId' | 'isMultiple'\n >\n >;\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport const AccordionContext = createContext<AccordionContextType<any> | null>(\n null,\n);\n\nexport const useAccordionContext = () => {\n const context = useContext(AccordionContext);\n if (context === null) {\n throw new Error('Accordion used without context');\n }\n return context;\n};\n"]}