@navikt/ds-react 5.13.0 → 5.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/_docs.json +206 -135
  2. package/cjs/accordion/AccordionHeader.js +2 -4
  3. package/cjs/button/Button.js +11 -12
  4. package/cjs/chips/Removable.js +3 -6
  5. package/cjs/copybutton/CopyButton.js +4 -5
  6. package/cjs/date/datepicker/DatePicker.js +4 -2
  7. package/cjs/date/datepicker/parts/WeekRow.js +2 -2
  8. package/cjs/date/monthpicker/MonthPicker.js +4 -3
  9. package/cjs/date/parts/DateWrapper.js +2 -2
  10. package/cjs/dropdown/Menu/GroupedList/GroupedItem.js +3 -6
  11. package/cjs/dropdown/Menu/List/Item.js +3 -6
  12. package/cjs/dropdown/Toggle.js +6 -5
  13. package/cjs/form/ConfirmationPanel.js +2 -2
  14. package/cjs/form/Textarea.js +2 -1
  15. package/cjs/form/checkbox/Checkbox.js +3 -2
  16. package/cjs/form/combobox/Combobox.js +2 -2
  17. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +3 -4
  18. package/cjs/form/combobox/Input/inputContext.js +2 -2
  19. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +2 -5
  20. package/cjs/form/error-summary/ErrorSummary.js +2 -2
  21. package/cjs/form/radio/Radio.js +3 -2
  22. package/cjs/form/radio/RadioGroup.js +2 -2
  23. package/cjs/form/search/Search.js +2 -1
  24. package/cjs/form/search/SearchButton.js +2 -4
  25. package/cjs/form/useFormField.js +2 -2
  26. package/cjs/guide-panel/Illustration.js +2 -2
  27. package/cjs/help-text/HelpText.js +5 -7
  28. package/cjs/help-text/HelpTextIcon.js +2 -2
  29. package/cjs/list/List.js +2 -2
  30. package/cjs/loader/Loader.js +2 -1
  31. package/cjs/modal/Modal.js +21 -18
  32. package/cjs/modal/dialog-polyfill.js +2 -2
  33. package/cjs/popover/Popover.js +6 -5
  34. package/cjs/read-more/ReadMore.js +2 -4
  35. package/cjs/stepper/Step.js +6 -6
  36. package/cjs/{util → table}/AnimateHeight.js +4 -5
  37. package/cjs/table/DataCell.js +2 -2
  38. package/cjs/table/ExpandableRow.js +9 -9
  39. package/cjs/table/HeaderCell.js +2 -1
  40. package/cjs/tabs/TabList.js +2 -1
  41. package/cjs/tag/Tag.js +4 -2
  42. package/cjs/timeline/Pin.js +2 -2
  43. package/cjs/timeline/period/ClickablePeriod.js +2 -2
  44. package/cjs/toggle-group/ToggleGroup.js +2 -2
  45. package/cjs/tooltip/Tooltip.js +6 -5
  46. package/cjs/util/Slot.js +2 -5
  47. package/cjs/util/TextareaAutoSize.js +7 -5
  48. package/cjs/util/composeEventHandlers.js +17 -0
  49. package/cjs/util/hooks/index.js +19 -0
  50. package/cjs/util/hooks/package.json +6 -0
  51. package/cjs/util/hooks/useClientLayoutEffect.js +7 -0
  52. package/cjs/util/hooks/useMergeRefs.js +37 -0
  53. package/cjs/util/{usePrevious.js → hooks/usePrevious.js} +2 -1
  54. package/cjs/util/index.js +7 -7
  55. package/cjs/util/types/index.js +2 -0
  56. package/cjs/util/types/package.json +6 -0
  57. package/esm/accordion/AccordionHeader.js +2 -4
  58. package/esm/accordion/AccordionHeader.js.map +1 -1
  59. package/esm/button/Button.d.ts +1 -1
  60. package/esm/button/Button.js +12 -13
  61. package/esm/button/Button.js.map +1 -1
  62. package/esm/chips/Chips.d.ts +1 -1
  63. package/esm/chips/Removable.js +3 -6
  64. package/esm/chips/Removable.js.map +1 -1
  65. package/esm/chips/Toggle.d.ts +1 -1
  66. package/esm/copybutton/CopyButton.js +4 -5
  67. package/esm/copybutton/CopyButton.js.map +1 -1
  68. package/esm/date/datepicker/DatePicker.js +5 -3
  69. package/esm/date/datepicker/DatePicker.js.map +1 -1
  70. package/esm/date/datepicker/parts/WeekRow.js +1 -1
  71. package/esm/date/datepicker/parts/WeekRow.js.map +1 -1
  72. package/esm/date/monthpicker/MonthPicker.js +4 -3
  73. package/esm/date/monthpicker/MonthPicker.js.map +1 -1
  74. package/esm/date/parts/DateWrapper.js +1 -1
  75. package/esm/date/parts/DateWrapper.js.map +1 -1
  76. package/esm/date/utils/dates-disabled.d.ts +1 -1
  77. package/esm/date/utils/dates-disabled.js.map +1 -1
  78. package/esm/dropdown/Menu/GroupedList/GroupedItem.d.ts +1 -1
  79. package/esm/dropdown/Menu/GroupedList/GroupedItem.js +3 -6
  80. package/esm/dropdown/Menu/GroupedList/GroupedItem.js.map +1 -1
  81. package/esm/dropdown/Menu/GroupedList/index.d.ts +1 -1
  82. package/esm/dropdown/Menu/List/Item.d.ts +1 -1
  83. package/esm/dropdown/Menu/List/Item.js +3 -6
  84. package/esm/dropdown/Menu/List/Item.js.map +1 -1
  85. package/esm/dropdown/Menu/List/index.d.ts +1 -1
  86. package/esm/dropdown/Toggle.js +6 -5
  87. package/esm/dropdown/Toggle.js.map +1 -1
  88. package/esm/expansion-card/ExpansionCard.d.ts +1 -1
  89. package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
  90. package/esm/form/ConfirmationPanel.js +1 -1
  91. package/esm/form/ConfirmationPanel.js.map +1 -1
  92. package/esm/form/Textarea.js +2 -1
  93. package/esm/form/Textarea.js.map +1 -1
  94. package/esm/form/checkbox/Checkbox.js +2 -1
  95. package/esm/form/checkbox/Checkbox.js.map +1 -1
  96. package/esm/form/combobox/Combobox.js +3 -3
  97. package/esm/form/combobox/Combobox.js.map +1 -1
  98. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +1 -2
  99. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  100. package/esm/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
  101. package/esm/form/combobox/Input/inputContext.js +1 -1
  102. package/esm/form/combobox/Input/inputContext.js.map +1 -1
  103. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +1 -1
  104. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  105. package/esm/form/error-summary/ErrorSummary.js +1 -1
  106. package/esm/form/error-summary/ErrorSummary.js.map +1 -1
  107. package/esm/form/error-summary/ErrorSummaryItem.d.ts +1 -1
  108. package/esm/form/radio/Radio.js +2 -1
  109. package/esm/form/radio/Radio.js.map +1 -1
  110. package/esm/form/radio/RadioGroup.js +1 -1
  111. package/esm/form/radio/RadioGroup.js.map +1 -1
  112. package/esm/form/search/Search.js +4 -3
  113. package/esm/form/search/Search.js.map +1 -1
  114. package/esm/form/search/SearchButton.js +2 -4
  115. package/esm/form/search/SearchButton.js.map +1 -1
  116. package/esm/form/useFormField.js +1 -1
  117. package/esm/form/useFormField.js.map +1 -1
  118. package/esm/guide-panel/Illustration.js +1 -1
  119. package/esm/guide-panel/Illustration.js.map +1 -1
  120. package/esm/help-text/HelpText.d.ts +0 -5
  121. package/esm/help-text/HelpText.js +6 -8
  122. package/esm/help-text/HelpText.js.map +1 -1
  123. package/esm/help-text/HelpTextIcon.js +1 -1
  124. package/esm/internal-header/InternalHeader.d.ts +1 -1
  125. package/esm/internal-header/InternalHeaderButton.d.ts +1 -1
  126. package/esm/internal-header/InternalHeaderTitle.d.ts +1 -1
  127. package/esm/internal-header/InternalHeaderUserButton.d.ts +1 -1
  128. package/esm/layout/box/Box.d.ts +1 -1
  129. package/esm/layout/page/parts/PageBlock.d.ts +1 -1
  130. package/esm/layout/stack/HStack.d.ts +1 -1
  131. package/esm/layout/stack/Stack.d.ts +1 -1
  132. package/esm/layout/stack/VStack.d.ts +1 -1
  133. package/esm/link/Link.d.ts +1 -1
  134. package/esm/link-panel/LinkPanel.d.ts +1 -1
  135. package/esm/link-panel/LinkPanelTitle.d.ts +1 -1
  136. package/esm/list/List.js +1 -1
  137. package/esm/loader/Loader.js +2 -1
  138. package/esm/loader/Loader.js.map +1 -1
  139. package/esm/modal/Modal.js +21 -18
  140. package/esm/modal/Modal.js.map +1 -1
  141. package/esm/modal/dialog-polyfill.js +2 -2
  142. package/esm/modal/dialog-polyfill.js.map +1 -1
  143. package/esm/modal/types.d.ts +1 -1
  144. package/esm/pagination/PaginationItem.d.ts +1 -1
  145. package/esm/panel/Panel.d.ts +1 -1
  146. package/esm/popover/Popover.d.ts +1 -1
  147. package/esm/popover/Popover.js +4 -3
  148. package/esm/popover/Popover.js.map +1 -1
  149. package/esm/read-more/ReadMore.js +2 -4
  150. package/esm/read-more/ReadMore.js.map +1 -1
  151. package/esm/stepper/Step.d.ts +1 -1
  152. package/esm/stepper/Step.js +6 -6
  153. package/esm/stepper/Step.js.map +1 -1
  154. package/esm/{util → table}/AnimateHeight.js +4 -5
  155. package/esm/table/AnimateHeight.js.map +1 -0
  156. package/esm/table/DataCell.d.ts +4 -0
  157. package/esm/table/DataCell.js +2 -2
  158. package/esm/table/DataCell.js.map +1 -1
  159. package/esm/table/ExpandableRow.js +8 -8
  160. package/esm/table/ExpandableRow.js.map +1 -1
  161. package/esm/table/HeaderCell.d.ts +4 -0
  162. package/esm/table/HeaderCell.js +2 -1
  163. package/esm/table/HeaderCell.js.map +1 -1
  164. package/esm/tabs/Tab.d.ts +1 -1
  165. package/esm/tabs/TabList.js +3 -2
  166. package/esm/tabs/TabList.js.map +1 -1
  167. package/esm/tabs/Tabs.d.ts +1 -1
  168. package/esm/tag/Tag.d.ts +4 -0
  169. package/esm/tag/Tag.js +4 -2
  170. package/esm/tag/Tag.js.map +1 -1
  171. package/esm/timeline/Pin.js +3 -3
  172. package/esm/timeline/Pin.js.map +1 -1
  173. package/esm/timeline/period/ClickablePeriod.js +3 -3
  174. package/esm/timeline/period/ClickablePeriod.js.map +1 -1
  175. package/esm/toggle-group/ToggleGroup.js +1 -1
  176. package/esm/toggle-group/ToggleGroup.js.map +1 -1
  177. package/esm/tooltip/Tooltip.js +6 -5
  178. package/esm/tooltip/Tooltip.js.map +1 -1
  179. package/esm/typography/BodyLong.d.ts +1 -1
  180. package/esm/typography/BodyShort.d.ts +1 -1
  181. package/esm/typography/Detail.d.ts +1 -1
  182. package/esm/typography/ErrorMessage.d.ts +1 -1
  183. package/esm/typography/Heading.d.ts +1 -1
  184. package/esm/typography/Ingress.d.ts +1 -1
  185. package/esm/typography/Label.d.ts +1 -1
  186. package/esm/util/Slot.js +1 -1
  187. package/esm/util/Slot.js.map +1 -1
  188. package/esm/util/TextareaAutoSize.js +5 -3
  189. package/esm/util/TextareaAutoSize.js.map +1 -1
  190. package/esm/util/composeEventHandlers.d.ts +8 -0
  191. package/esm/util/composeEventHandlers.js +14 -0
  192. package/esm/util/composeEventHandlers.js.map +1 -0
  193. package/esm/util/hooks/index.d.ts +8 -0
  194. package/esm/util/hooks/index.js +9 -0
  195. package/esm/util/hooks/index.js.map +1 -0
  196. package/esm/util/hooks/useClientLayoutEffect.js +5 -0
  197. package/esm/util/hooks/useClientLayoutEffect.js.map +1 -0
  198. package/esm/util/{useEventListener.d.ts → hooks/useEventListener.d.ts} +1 -1
  199. package/esm/util/hooks/useEventListener.js.map +1 -0
  200. package/esm/util/hooks/useId.js.map +1 -0
  201. package/esm/util/hooks/useMedia.js.map +1 -0
  202. package/esm/util/hooks/useMergeRefs.d.ts +15 -0
  203. package/esm/util/hooks/useMergeRefs.js +30 -0
  204. package/esm/util/hooks/useMergeRefs.js.map +1 -0
  205. package/esm/util/hooks/usePrevious.d.ts +1 -0
  206. package/esm/util/{usePrevious.js → hooks/usePrevious.js} +1 -2
  207. package/esm/util/hooks/usePrevious.js.map +1 -0
  208. package/esm/util/index.d.ts +4 -5
  209. package/esm/util/index.js +3 -5
  210. package/esm/util/index.js.map +1 -1
  211. package/esm/util/types/OverridableComponent.js.map +1 -0
  212. package/esm/util/types/index.d.ts +1 -0
  213. package/esm/util/types/index.js +2 -0
  214. package/esm/util/types/index.js.map +1 -0
  215. package/package.json +3 -3
  216. package/src/accordion/AccordionHeader.tsx +2 -4
  217. package/src/accordion/AccordionItem.tsx +2 -2
  218. package/src/alert/alert.stories.tsx +1 -2
  219. package/src/button/Button.tsx +14 -19
  220. package/src/button/button.stories.tsx +2 -2
  221. package/src/chips/Chips.tsx +1 -1
  222. package/src/chips/Removable.tsx +3 -4
  223. package/src/chips/Toggle.tsx +1 -1
  224. package/src/copybutton/CopyButton.tsx +4 -5
  225. package/src/copybutton/copy-button.stories.tsx +1 -1
  226. package/src/date/datepicker/DatePicker.tsx +5 -3
  227. package/src/date/datepicker/parts/WeekRow.tsx +1 -1
  228. package/src/date/monthpicker/MonthPicker.tsx +4 -3
  229. package/src/date/parts/DateWrapper.tsx +1 -1
  230. package/src/date/utils/dates-disabled.ts +1 -1
  231. package/src/dropdown/Menu/GroupedList/GroupedItem.tsx +23 -23
  232. package/src/dropdown/Menu/GroupedList/index.tsx +1 -1
  233. package/src/dropdown/Menu/List/Item.tsx +23 -23
  234. package/src/dropdown/Menu/List/index.tsx +1 -1
  235. package/src/dropdown/Toggle.tsx +10 -6
  236. package/src/expansion-card/ExpansionCard.tsx +1 -1
  237. package/src/expansion-card/ExpansionCardTitle.tsx +1 -1
  238. package/src/form/ConfirmationPanel.tsx +1 -1
  239. package/src/form/Textarea.tsx +2 -1
  240. package/src/form/checkbox/Checkbox.tsx +2 -1
  241. package/src/form/combobox/Combobox.tsx +3 -6
  242. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +1 -2
  243. package/src/form/combobox/FilteredOptions/useVirtualFocus.ts +1 -1
  244. package/src/form/combobox/Input/inputContext.tsx +1 -1
  245. package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +1 -1
  246. package/src/form/combobox/combobox.stories.tsx +10 -11
  247. package/src/form/error-summary/ErrorSummary.tsx +1 -1
  248. package/src/form/error-summary/ErrorSummaryItem.tsx +1 -1
  249. package/src/form/radio/Radio.tsx +2 -1
  250. package/src/form/radio/RadioGroup.tsx +1 -1
  251. package/src/form/search/Search.tsx +3 -3
  252. package/src/form/search/SearchButton.tsx +2 -4
  253. package/src/form/useFormField.ts +1 -1
  254. package/src/guide-panel/Illustration.tsx +1 -1
  255. package/src/help-text/HelpText.tsx +7 -25
  256. package/src/help-text/HelpTextIcon.tsx +1 -1
  257. package/src/help-text/help-text.stories.tsx +58 -68
  258. package/src/internal-header/InternalHeader.tsx +1 -1
  259. package/src/internal-header/InternalHeaderButton.tsx +1 -1
  260. package/src/internal-header/InternalHeaderTitle.tsx +1 -1
  261. package/src/internal-header/InternalHeaderUserButton.tsx +1 -1
  262. package/src/layout/box/Box.tsx +1 -1
  263. package/src/layout/page/parts/PageBlock.tsx +1 -1
  264. package/src/layout/stack/HStack.tsx +1 -1
  265. package/src/layout/stack/Stack.tsx +1 -1
  266. package/src/layout/stack/VStack.tsx +1 -1
  267. package/src/link/Link.tsx +1 -1
  268. package/src/link/{link.stories.tsx → stories/link.stories.tsx} +2 -2
  269. package/src/link-panel/LinkPanel.tsx +1 -1
  270. package/src/link-panel/LinkPanelTitle.tsx +1 -1
  271. package/src/list/List.tsx +1 -1
  272. package/src/loader/Loader.tsx +2 -1
  273. package/src/modal/Modal.tsx +30 -30
  274. package/src/modal/dialog-polyfill.ts +2 -2
  275. package/src/modal/types.ts +1 -1
  276. package/src/pagination/PaginationItem.tsx +1 -1
  277. package/src/panel/Panel.tsx +1 -1
  278. package/src/popover/Popover.tsx +4 -7
  279. package/src/read-more/ReadMore.tsx +2 -4
  280. package/src/stepper/Step.tsx +8 -5
  281. package/src/{util → table}/AnimateHeight.tsx +5 -9
  282. package/src/table/DataCell.tsx +6 -1
  283. package/src/table/ExpandableRow.tsx +11 -6
  284. package/src/table/HeaderCell.tsx +6 -1
  285. package/src/table/stories/table.stories.tsx +43 -29
  286. package/src/table/stories/tests/table.stories.tsx +2 -3
  287. package/src/tabs/Tab.tsx +1 -1
  288. package/src/tabs/TabList.tsx +4 -2
  289. package/src/tabs/Tabs.tsx +1 -1
  290. package/src/tag/Tag.tsx +9 -2
  291. package/src/tag/tag.stories.tsx +27 -1
  292. package/src/timeline/Pin.tsx +3 -6
  293. package/src/timeline/period/ClickablePeriod.tsx +3 -6
  294. package/src/toggle-group/ToggleGroup.tsx +1 -1
  295. package/src/tooltip/Tooltip.tsx +11 -22
  296. package/src/typography/BodyLong.tsx +1 -1
  297. package/src/typography/BodyShort.tsx +1 -1
  298. package/src/typography/Detail.tsx +1 -1
  299. package/src/typography/ErrorMessage.tsx +1 -1
  300. package/src/typography/Heading.tsx +1 -1
  301. package/src/typography/Ingress.tsx +1 -1
  302. package/src/typography/Label.tsx +1 -1
  303. package/src/typography/stories/bodylong.stories.tsx +1 -2
  304. package/src/typography/stories/bodyshort.stories.tsx +1 -2
  305. package/src/typography/stories/detail.stories.tsx +1 -2
  306. package/src/typography/stories/error-message.stories.tsx +1 -2
  307. package/src/typography/stories/heading.stories.tsx +1 -2
  308. package/src/typography/stories/ingress.stories.tsx +1 -2
  309. package/src/typography/stories/label.stories.tsx +1 -2
  310. package/src/util/Slot.tsx +1 -1
  311. package/src/util/TextareaAutoSize.tsx +7 -3
  312. package/src/util/__tests__/useMedia.test.tsx +1 -1
  313. package/src/util/composeEventHandlers.ts +19 -0
  314. package/src/util/hooks/index.ts +8 -0
  315. package/src/util/hooks/useCallbackRef.ts +1 -1
  316. package/src/util/hooks/useClientLayoutEffect.ts +5 -0
  317. package/src/util/hooks/useControllableState.ts +1 -1
  318. package/src/util/hooks/useMergeRefs.ts +32 -0
  319. package/src/util/{usePrevious.ts → hooks/usePrevious.ts} +1 -4
  320. package/src/util/index.ts +4 -5
  321. package/src/util/types/index.ts +1 -0
  322. package/cjs/util/RandomIcon.js +0 -38
  323. package/cjs/util/mergeRefs.js +0 -16
  324. package/cjs/util/useClientLayoutEffect.js +0 -10
  325. package/esm/util/AnimateHeight.js.map +0 -1
  326. package/esm/util/OverridableComponent.js.map +0 -1
  327. package/esm/util/RandomIcon.d.ts +0 -2
  328. package/esm/util/RandomIcon.js +0 -9
  329. package/esm/util/RandomIcon.js.map +0 -1
  330. package/esm/util/mergeRefs.d.ts +0 -2
  331. package/esm/util/mergeRefs.js +0 -14
  332. package/esm/util/mergeRefs.js.map +0 -1
  333. package/esm/util/useClientLayoutEffect.js +0 -8
  334. package/esm/util/useClientLayoutEffect.js.map +0 -1
  335. package/esm/util/useEventListener.js.map +0 -1
  336. package/esm/util/useId.js.map +0 -1
  337. package/esm/util/useMedia.js.map +0 -1
  338. package/esm/util/usePrevious.d.ts +0 -2
  339. package/esm/util/usePrevious.js.map +0 -1
  340. package/src/util/mergeRefs.tsx +0 -16
  341. package/src/util/useClientLayoutEffect.ts +0 -11
  342. /package/cjs/util/{useEventListener.js → hooks/useEventListener.js} +0 -0
  343. /package/cjs/util/{useId.js → hooks/useId.js} +0 -0
  344. /package/cjs/util/{useMedia.js → hooks/useMedia.js} +0 -0
  345. /package/cjs/util/{OverridableComponent.js → types/OverridableComponent.js} +0 -0
  346. /package/esm/{util → table}/AnimateHeight.d.ts +0 -0
  347. /package/esm/util/{useClientLayoutEffect.d.ts → hooks/useClientLayoutEffect.d.ts} +0 -0
  348. /package/esm/util/{useEventListener.js → hooks/useEventListener.js} +0 -0
  349. /package/esm/util/{useId.d.ts → hooks/useId.d.ts} +0 -0
  350. /package/esm/util/{useId.js → hooks/useId.js} +0 -0
  351. /package/esm/util/{useMedia.d.ts → hooks/useMedia.d.ts} +0 -0
  352. /package/esm/util/{useMedia.js → hooks/useMedia.js} +0 -0
  353. /package/esm/util/{OverridableComponent.d.ts → types/OverridableComponent.d.ts} +0 -0
  354. /package/esm/util/{OverridableComponent.js → types/OverridableComponent.js} +0 -0
  355. /package/src/{util → link/stories}/RandomIcon.tsx +0 -0
  356. /package/src/util/{useEventListener.ts → hooks/useEventListener.ts} +0 -0
  357. /package/src/util/{useId.ts → hooks/useId.ts} +0 -0
  358. /package/src/util/{useMedia.ts → hooks/useMedia.ts} +0 -0
  359. /package/src/util/{OverridableComponent.ts → types/OverridableComponent.ts} +0 -0
@@ -1,63 +1,57 @@
1
+ import { Meta, StoryFn, StoryObj } from "@storybook/react";
1
2
  import React, { useEffect, useRef } from "react";
2
3
  import { BodyLong, Heading, HelpText } from "..";
3
4
 
4
- export default {
5
+ const meta: Meta<typeof HelpText> = {
5
6
  title: "ds-react/HelpText",
6
7
  component: HelpText,
7
8
  parameters: {
8
9
  chromatic: { delay: 300 },
9
10
  },
11
+ };
12
+ export default meta;
13
+
14
+ export const Default: StoryObj<typeof HelpText> = {
15
+ render: (props) => (
16
+ <HelpText {...props}>Id ullamco excepteur elit fugiat labore.</HelpText>
17
+ ),
18
+
19
+ args: {
20
+ title: "Show tooltip",
21
+ },
10
22
  argTypes: {
11
23
  placement: {
12
- control: {
13
- type: "radio",
14
- options: [
15
- "top",
16
- "bottom",
17
- "right",
18
- "left",
19
- "top-start",
20
- "top-end",
21
- "bottom-start",
22
- "bottom-end",
23
- "right-start",
24
- "right-end",
25
- "left-start",
26
- "left-end",
27
- ],
28
- },
24
+ control: { type: "radio" },
25
+ options: [
26
+ "top",
27
+ "bottom",
28
+ "right",
29
+ "left",
30
+ "top-start",
31
+ "top-end",
32
+ "bottom-start",
33
+ "bottom-end",
34
+ "right-start",
35
+ "right-end",
36
+ "left-start",
37
+ "left-end",
38
+ ],
29
39
  },
30
40
  strategy: {
31
- control: {
32
- type: "radio",
33
- options: ["fixed", "absolute"],
34
- },
41
+ control: { type: "radio" },
42
+ options: ["fixed", "absolute"],
35
43
  },
36
44
  },
37
45
  };
38
46
 
39
- export const Default = {
40
- render: (props: any) => {
41
- return (
42
- <HelpText title="show tooltip" strategy="fixed" {...props}>
43
- Id ullamco excepteur elit fugiat labore.
44
- </HelpText>
45
- );
46
- },
47
-
48
- args: {
49
- title: "show tooltip",
50
- },
51
- };
52
-
53
- export const Open = () => {
47
+ export const Open: StoryFn = () => {
54
48
  const ref = useRef<HTMLButtonElement | null>(null);
55
49
  useEffect(() => {
56
50
  ref.current && ref.current.click();
57
51
  }, []);
58
52
 
59
53
  return (
60
- <HelpText ref={ref} title="show tooltip" strategy="fixed">
54
+ <HelpText ref={ref} title="Show tooltip" strategy="fixed">
61
55
  Incididunt laborum eiusmod ullamco id aliquip officia ex irure aliqua
62
56
  laboris id ea do nisi. Ex esse ad duis culpa non aliquip exercitation eu
63
57
  culpa cupidatat nisi. Deserunt voluptate consectetur cillum elit qui ad
@@ -66,35 +60,31 @@ export const Open = () => {
66
60
  );
67
61
  };
68
62
 
69
- export const WrapperClassName = {
70
- render: () => {
71
- return (
72
- <div>
73
- <BodyLong spacing>
74
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta
75
- perspiciatis vero voluptatum, asperiores cumque, deserunt accusantium
76
- ullam ipsa accusamus officia cupiditate quae unde esse culpa, ratione
77
- ab quam ea quas?
78
- </BodyLong>
63
+ export const WrapperClassName: StoryFn = () => (
64
+ <div>
65
+ <BodyLong spacing>
66
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta
67
+ perspiciatis vero voluptatum, asperiores cumque, deserunt accusantium
68
+ ullam ipsa accusamus officia cupiditate quae unde esse culpa, ratione ab
69
+ quam ea quas?
70
+ </BodyLong>
79
71
 
80
- <Heading level="2" size="medium">
81
- 67 år og 1 måneder øklasdjkl askdak døkasøk daøkdkølasøkld asølkdøka
82
- <HelpText wrapperClassName="testClass">
83
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta
84
- perspiciatis vero voluptatum, asperiores cumque, deserunt
85
- accusantium ullam ipsa accusamus officia cupiditate quae unde esse
86
- culpa, ratione ab quam ea quas?
87
- </HelpText>
88
- <style>{`.testClass {display: inline-block; margin-left: 0.5rem; vertical-align: middle;}`}</style>
89
- </Heading>
72
+ <Heading level="2" size="medium">
73
+ 67 år og 1 måneder øklasdjkl askdak døkasøk daøkdkølasøkld asølkdøka
74
+ <HelpText wrapperClassName="testClass">
75
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta
76
+ perspiciatis vero voluptatum, asperiores cumque, deserunt accusantium
77
+ ullam ipsa accusamus officia cupiditate quae unde esse culpa, ratione ab
78
+ quam ea quas?
79
+ </HelpText>
80
+ <style>{`.testClass {display: inline-block; margin-left: 0.5rem; vertical-align: middle;}`}</style>
81
+ </Heading>
90
82
 
91
- <BodyLong spacing>
92
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta
93
- perspiciatis vero voluptatum, asperiores cumque, deserunt accusantium
94
- ullam ipsa accusamus officia cupiditate quae unde esse culpa, ratione
95
- ab quam ea quas?
96
- </BodyLong>
97
- </div>
98
- );
99
- },
100
- };
83
+ <BodyLong spacing>
84
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta
85
+ perspiciatis vero voluptatum, asperiores cumque, deserunt accusantium
86
+ ullam ipsa accusamus officia cupiditate quae unde esse culpa, ratione ab
87
+ quam ea quas?
88
+ </BodyLong>
89
+ </div>
90
+ );
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { HTMLAttributes, forwardRef } from "react";
3
- import { OverridableComponent } from "../util/OverridableComponent";
3
+ import { OverridableComponent } from "../util/types";
4
4
  import InternalHeaderButton, {
5
5
  InternalHeaderButtonProps,
6
6
  } from "./InternalHeaderButton";
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
- import { OverridableComponent } from "../util/OverridableComponent";
3
+ import { OverridableComponent } from "../util/types";
4
4
 
5
5
  export interface InternalHeaderButtonProps
6
6
  extends React.AnchorHTMLAttributes<HTMLButtonElement> {
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
- import { OverridableComponent } from "../util/OverridableComponent";
3
+ import { OverridableComponent } from "../util/types";
4
4
 
5
5
  export interface InternalHeaderTitleProps
6
6
  extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
@@ -2,7 +2,7 @@ import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { ChevronDownIcon } from "@navikt/aksel-icons";
4
4
  import { BodyShort, Detail } from "../typography";
5
- import { OverridableComponent } from "../util/OverridableComponent";
5
+ import { OverridableComponent } from "../util/types";
6
6
  import InternalHeaderButton from "./InternalHeaderButton";
7
7
 
8
8
  export interface InternalHeaderUserButtonProps
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
- import { OverridableComponent } from "../../util/OverridableComponent";
3
+ import { OverridableComponent } from "../../util/types";
4
4
  import { getResponsiveProps } from "../utilities/css";
5
5
  import {
6
6
  BackgroundToken,
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
- import { OverridableComponent } from "../../../util/OverridableComponent";
3
+ import { OverridableComponent } from "../../../util/types";
4
4
 
5
5
  export const widths = ["text", "md", "lg", "xl", "2xl"] as const;
6
6
 
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef } from "react";
2
- import { OverridableComponent } from "../../util/OverridableComponent";
2
+ import { OverridableComponent } from "../../util/types";
3
3
  import { Stack, StackProps } from "./Stack";
4
4
 
5
5
  export type HStackProps = Omit<StackProps, "direction">;
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { HTMLAttributes, forwardRef } from "react";
3
- import { OverridableComponent } from "../../util/OverridableComponent";
3
+ import { OverridableComponent } from "../../util/types";
4
4
  import { getResponsiveProps, getResponsiveValue } from "../utilities/css";
5
5
  import { ResponsiveProp, SpacingScale } from "../utilities/types";
6
6
 
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef } from "react";
2
- import { OverridableComponent } from "../../util/OverridableComponent";
2
+ import { OverridableComponent } from "../../util/types";
3
3
  import { Stack, StackProps } from "./Stack";
4
4
 
5
5
  export type VStackProps = Omit<StackProps, "direction" | "wrap">;
package/src/link/Link.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
- import { OverridableComponent } from "../util/OverridableComponent";
3
+ import { OverridableComponent } from "../util/types";
4
4
 
5
5
  export interface LinkProps
6
6
  extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
@@ -5,8 +5,8 @@ import {
5
5
  Alert as DsAlert,
6
6
  ConfirmationPanel as DsConfirmationPanel,
7
7
  Link,
8
- } from "..";
9
- import { RandomIcon } from "../util/RandomIcon";
8
+ } from "../..";
9
+ import { RandomIcon } from "./RandomIcon";
10
10
 
11
11
  export default {
12
12
  title: "ds-react/Link",
@@ -2,7 +2,7 @@ import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { ChevronRightIcon } from "@navikt/aksel-icons";
4
4
  import { Panel } from "../panel";
5
- import { OverridableComponent } from "../util";
5
+ import { OverridableComponent } from "../util/types";
6
6
  import {
7
7
  LinkPanelDescription,
8
8
  LinkPanelDescriptionProps,
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
- import { OverridableComponent } from "../util/OverridableComponent";
3
+ import { OverridableComponent } from "../util/types";
4
4
 
5
5
  export interface LinkPanelTitleProps
6
6
  extends React.HTMLAttributes<HTMLDivElement> {
package/src/list/List.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef, useContext } from "react";
3
3
  import { BodyShort, Heading } from "../typography";
4
- import { useId } from "../util/useId";
4
+ import { useId } from "../util/hooks";
5
5
  import { ListItem } from "./ListItem";
6
6
  import { ListContext } from "./context";
7
7
  import { ListProps } from "./types";
@@ -1,6 +1,7 @@
1
1
  import cl from "clsx";
2
2
  import React, { SVGProps, forwardRef } from "react";
3
- import { omit, useId } from "../util";
3
+ import { omit } from "../util";
4
+ import { useId } from "../util/hooks";
4
5
 
5
6
  export interface LoaderProps extends Omit<SVGProps<SVGSVGElement>, "ref"> {
6
7
  /**
@@ -1,17 +1,13 @@
1
1
  import { useFloatingPortalNode } from "@floating-ui/react";
2
2
  import cl from "clsx";
3
- import React, {
4
- forwardRef,
5
- useContext,
6
- useEffect,
7
- useMemo,
8
- useRef,
9
- } from "react";
3
+ import React, { forwardRef, useContext, useEffect, useRef } from "react";
10
4
  import { createPortal } from "react-dom";
11
5
  import { DateContext } from "../date/context";
12
6
  import { useProvider } from "../provider";
13
7
  import { Detail, Heading } from "../typography";
14
- import { mergeRefs, useId } from "../util";
8
+ import { composeEventHandlers } from "../util/composeEventHandlers";
9
+ import { useId } from "../util/hooks";
10
+ import { useMergeRefs } from "../util/hooks/useMergeRefs";
15
11
  import ModalBody from "./ModalBody";
16
12
  import { ModalContext } from "./ModalContext";
17
13
  import ModalFooter from "./ModalFooter";
@@ -95,7 +91,8 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
95
91
  ref,
96
92
  ) => {
97
93
  const modalRef = useRef<HTMLDialogElement>(null);
98
- const mergedRef = useMemo(() => mergeRefs([modalRef, ref]), [ref]);
94
+ const mergedRef = useMergeRefs(modalRef, ref);
95
+
99
96
  const ariaLabelId = useId();
100
97
  const rootElement = useProvider()?.rootElement;
101
98
  const portalNode = useFloatingPortalNode({ root: rootElement });
@@ -149,25 +146,28 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
149
146
  ...(!isWidthPreset ? { width } : {}),
150
147
  };
151
148
 
152
- const mergedOnCancel: React.DialogHTMLAttributes<HTMLDialogElement>["onCancel"] =
153
- (event) => {
154
- if (onBeforeClose && onBeforeClose() === false) {
155
- event.preventDefault();
156
- } else if (onCancel) onCancel(event);
157
- };
158
-
159
- const mergedOnClick =
160
- closeOnBackdropClick && !needPolyfill // closeOnBackdropClick has issues on polyfill when nesting modals (DatePicker)
161
- ? (event: React.MouseEvent<HTMLDialogElement>) => {
162
- onClick && onClick(event);
163
- if (
164
- event.target === modalRef.current &&
165
- (!onBeforeClose || onBeforeClose() !== false)
166
- ) {
167
- modalRef.current.close();
168
- }
169
- }
170
- : onClick;
149
+ /**
150
+ * @note `closeOnBackdropClick` has issues on polyfill when nesting modals (DatePicker)
151
+ */
152
+ const handleModalClick = (event: React.MouseEvent<HTMLDialogElement>) => {
153
+ if (
154
+ closeOnBackdropClick &&
155
+ !needPolyfill &&
156
+ event.target === modalRef.current &&
157
+ (!onBeforeClose || onBeforeClose() !== false)
158
+ ) {
159
+ modalRef.current.close();
160
+ }
161
+ };
162
+
163
+ /**
164
+ * @note onCancel fires when you press `Esc`
165
+ */
166
+ const handleModalCancel = (
167
+ event: React.SyntheticEvent<HTMLDialogElement, Event>,
168
+ ) => {
169
+ onBeforeClose && onBeforeClose() === false && event.preventDefault();
170
+ };
171
171
 
172
172
  const mergedAriaLabelledBy =
173
173
  !ariaLabelledby && !rest["aria-label"] && header
@@ -181,8 +181,8 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
181
181
  ref={mergedRef}
182
182
  className={mergedClassName}
183
183
  style={mergedStyle}
184
- onCancel={mergedOnCancel} // FYI: onCancel fires when you press Esc
185
- onClick={mergedOnClick}
184
+ onCancel={composeEventHandlers(onCancel, handleModalCancel)}
185
+ onClick={composeEventHandlers(onClick, handleModalClick)}
186
186
  aria-labelledby={mergedAriaLabelledBy}
187
187
  >
188
188
  <ModalContext.Provider
@@ -598,7 +598,7 @@ dialogPolyfill.registerDialog = function (element) {
598
598
  * @constructor
599
599
  */
600
600
  dialogPolyfill.DialogManager = function () {
601
- /** @type {!Array<!dialogPolyfillInfo>} */
601
+ /** @type {!dialogPolyfillInfo[]} */
602
602
  this.pendingDialogStack = [];
603
603
 
604
604
  var checkDOM = this.checkDOM_.bind(this);
@@ -769,7 +769,7 @@ dialogPolyfill.DialogManager.prototype.handleKey_ = function (event) {
769
769
  * Finds and downgrades any known modal dialogs that are no longer displayed. Dialogs that are
770
770
  * removed and immediately readded don't stay modal, they become normal.
771
771
  *
772
- * @param {!Array<!HTMLDialogElement>} removed that have definitely been removed
772
+ * @param {!HTMLDialogElement[]} removed that have definitely been removed
773
773
  */
774
774
  dialogPolyfill.DialogManager.prototype.checkDOM_ = function (removed) {
775
775
  // This operates on a clone because it may cause it to change. Each change also calls
@@ -41,7 +41,7 @@ export interface ModalProps
41
41
  */
42
42
  onBeforeClose?: () => boolean | void;
43
43
  /**
44
- * *Sometimes** called when the user presses the Esc key, unless you return `false` in `onBeforeClose()`.
44
+ * *Sometimes** called when the user presses the Esc key.
45
45
  * @warning *Some browsers does not always trigger this event. Chrome only triggers it if you have
46
46
  * interacted with the modal, and will not trigger it a second time if you press Esc twice in a row.
47
47
  */
@@ -1,7 +1,7 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { Button, ButtonProps } from "../button";
4
- import { OverridableComponent } from "../util";
4
+ import { OverridableComponent } from "../util/types";
5
5
 
6
6
  export interface PaginationItemProps extends ButtonProps {
7
7
  children: React.ReactNode;
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
- import { OverridableComponent } from "../util/OverridableComponent";
3
+ import { OverridableComponent } from "../util/types";
4
4
 
5
5
  export interface PanelProps extends React.HTMLAttributes<HTMLElement> {
6
6
  /**
@@ -15,12 +15,12 @@ import React, {
15
15
  forwardRef,
16
16
  useCallback,
17
17
  useContext,
18
- useMemo,
19
18
  useRef,
20
19
  } from "react";
21
20
  import { DateContext } from "../date/context";
22
21
  import { ModalContext } from "../modal/ModalContext";
23
- import { mergeRefs, useClientLayoutEffect, useEventListener } from "../util";
22
+ import { useClientLayoutEffect, useEventListener } from "../util/hooks";
23
+ import { useMergeRefs } from "../util/hooks/useMergeRefs";
24
24
  import PopoverContent, { PopoverContentType } from "./PopoverContent";
25
25
 
26
26
  export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
@@ -41,7 +41,7 @@ export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
41
41
  */
42
42
  onClose: () => void;
43
43
  /**
44
- * Orientation for popover
44
+ * Default orientation of popover
45
45
  * @note Try to keep general usage to "top", "bottom", "left", "right"
46
46
  * @default "top"
47
47
  */
@@ -163,10 +163,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
163
163
  refs.setReference(anchorEl);
164
164
  }, [anchorEl]);
165
165
 
166
- const floatingRef = useMemo(
167
- () => mergeRefs([refs.setFloating, ref]),
168
- [refs.setFloating, ref],
169
- );
166
+ const floatingRef = useMergeRefs(refs.setFloating, ref);
170
167
 
171
168
  useClientLayoutEffect(() => {
172
169
  if (!refs.reference.current || !refs.floating.current || !open) return;
@@ -2,6 +2,7 @@ import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { ChevronDownIcon } from "@navikt/aksel-icons";
4
4
  import { BodyLong } from "../typography";
5
+ import { composeEventHandlers } from "../util/composeEventHandlers";
5
6
  import { useControllableState } from "../util/hooks/useControllableState";
6
7
 
7
8
  export interface ReadMoreProps
@@ -89,10 +90,7 @@ export const ReadMore = forwardRef<HTMLButtonElement, ReadMoreProps>(
89
90
  className={cl("navds-read-more__button", "navds-body-short", {
90
91
  "navds-body-short--small": size === "small",
91
92
  })}
92
- onClick={(e) => {
93
- _setOpen((x) => !x);
94
- onClick?.(e);
95
- }}
93
+ onClick={composeEventHandlers(onClick, () => _setOpen((x) => !x))}
96
94
  aria-expanded={_open}
97
95
  >
98
96
  <ChevronDownIcon
@@ -1,7 +1,8 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef, useContext } from "react";
3
3
  import { Label } from "../typography";
4
- import { OverridableComponent } from "../util";
4
+ import { composeEventHandlers } from "../util/composeEventHandlers";
5
+ import { OverridableComponent } from "../util/types";
5
6
  import { StepperContext } from "./context";
6
7
 
7
8
  export interface StepperStepProps
@@ -56,6 +57,7 @@ export const Step: OverridableComponent<StepperStepProps, HTMLAnchorElement> =
56
57
  unsafe_index = 0,
57
58
  completed = false,
58
59
  interactive,
60
+ onClick,
59
61
  ...rest
60
62
  },
61
63
  ref,
@@ -71,6 +73,10 @@ export const Step: OverridableComponent<StepperStepProps, HTMLAnchorElement> =
71
73
 
72
74
  const Comp = isInteractive ? Component : "div";
73
75
 
76
+ const handleStepClick = () => {
77
+ isInteractive && context.onStepChange(unsafe_index + 1);
78
+ };
79
+
74
80
  return (
75
81
  <Comp
76
82
  {...rest}
@@ -82,10 +88,7 @@ export const Step: OverridableComponent<StepperStepProps, HTMLAnchorElement> =
82
88
  "navds-stepper__step--non-interactive": !isInteractive,
83
89
  "navds-stepper__step--completed": completed,
84
90
  })}
85
- onClick={(e) => {
86
- isInteractive && context.onStepChange(unsafe_index + 1);
87
- rest?.onClick?.(e);
88
- }}
91
+ onClick={composeEventHandlers(onClick, handleStepClick)}
89
92
  >
90
93
  {completed ? (
91
94
  <span className="navds-stepper__circle navds-stepper__circle--success">
@@ -9,6 +9,10 @@ type Overflow = "auto" | "visible" | "hidden" | undefined;
9
9
 
10
10
  // ------------------ Helpers
11
11
 
12
+ const prefersReducedMotion = globalThis?.matchMedia
13
+ ? globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches
14
+ : false;
15
+
12
16
  function isNumber(n: string) {
13
17
  const number = parseFloat(n);
14
18
  return !isNaN(number) && isFinite(number);
@@ -70,15 +74,7 @@ const AnimateHeight: React.FC<AnimateHeightProps> = ({
70
74
  const animationClassesTimeoutID = useRef<Timeout>();
71
75
  const timeoutID = useRef<Timeout>();
72
76
 
73
- const isBrowser = typeof window !== "undefined";
74
-
75
- const prefersReducedMotion = useRef<boolean>(
76
- isBrowser && window.matchMedia
77
- ? window.matchMedia("(prefers-reduced-motion)").matches
78
- : false,
79
- );
80
-
81
- const duration = prefersReducedMotion.current ? 0 : userDuration;
77
+ const duration = prefersReducedMotion ? 0 : userDuration;
82
78
 
83
79
  let initHeight: Height = height;
84
80
  let initOverflow: Overflow = "visible";
@@ -9,6 +9,10 @@ export interface DataCellProps
9
9
  * @default "left"
10
10
  */
11
11
  align?: "left" | "center" | "right";
12
+ /**
13
+ * Adjusts font-size
14
+ */
15
+ textSize?: "medium" | "small";
12
16
  }
13
17
 
14
18
  export interface DataCellType
@@ -17,7 +21,7 @@ export interface DataCellType
17
21
  > {}
18
22
 
19
23
  export const DataCell: DataCellType = forwardRef(
20
- ({ className, children = "", align, ...rest }, ref) => {
24
+ ({ className, children = "", align, textSize, ...rest }, ref) => {
21
25
  return (
22
26
  <BodyShort
23
27
  as="td"
@@ -25,6 +29,7 @@ export const DataCell: DataCellType = forwardRef(
25
29
  className={cl("navds-table__data-cell", className, {
26
30
  [`navds-table__data-cell--align-${align}`]: align,
27
31
  })}
32
+ size={textSize}
28
33
  {...rest}
29
34
  >
30
35
  {children}
@@ -1,9 +1,10 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { ChevronDownIcon } from "@navikt/aksel-icons";
4
- import { useId } from "../util";
5
- import AnimateHeight from "../util/AnimateHeight";
4
+ import { composeEventHandlers } from "../util/composeEventHandlers";
5
+ import { useId } from "../util/hooks";
6
6
  import { useControllableState } from "../util/hooks/useControllableState";
7
+ import AnimateHeight from "./AnimateHeight";
7
8
  import DataCell from "./DataCell";
8
9
  import Row, { RowProps } from "./Row";
9
10
 
@@ -66,6 +67,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
66
67
  expansionDisabled = false,
67
68
  expandOnRowClick = false,
68
69
  colSpan = 999,
70
+ onClick,
69
71
  ...rest
70
72
  },
71
73
  ref,
@@ -86,6 +88,12 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
86
88
  const onRowClick = (e) =>
87
89
  !isInteractiveTarget(e.target) && expansionHandler(e);
88
90
 
91
+ const handleRowClick = (
92
+ e: React.MouseEvent<HTMLTableRowElement, MouseEvent>,
93
+ ) => {
94
+ !expansionDisabled && expandOnRowClick && onRowClick(e);
95
+ };
96
+
89
97
  return (
90
98
  <>
91
99
  <Row
@@ -97,10 +105,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
97
105
  expansionDisabled,
98
106
  "navds-table__expandable-row--clickable": expandOnRowClick,
99
107
  })}
100
- onClick={(e) => {
101
- !expansionDisabled && expandOnRowClick && onRowClick(e);
102
- rest?.onClick?.(e);
103
- }}
108
+ onClick={composeEventHandlers(onClick, handleRowClick)}
104
109
  >
105
110
  {togglePlacement === "right" && children}
106
111
  <DataCell