@navikt/ds-react 5.12.5 → 5.13.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 (518) hide show
  1. package/_docs.json +79 -3
  2. package/cjs/accordion/Accordion.js +2 -2
  3. package/cjs/accordion/AccordionHeader.js +1 -1
  4. package/cjs/accordion/AccordionItem.js +11 -14
  5. package/cjs/alert/Alert.js +2 -2
  6. package/cjs/chat/Bubble.js +1 -1
  7. package/cjs/chat/Chat.js +2 -2
  8. package/cjs/chips/Chips.js +1 -1
  9. package/cjs/chips/Removable.js +1 -1
  10. package/cjs/copybutton/CopyButton.js +2 -2
  11. package/cjs/date/datepicker/parts/Caption.js +2 -2
  12. package/cjs/date/datepicker/parts/DropdownCaption.js +1 -1
  13. package/cjs/date/datepicker/parts/HeadRow.js +1 -1
  14. package/cjs/date/datepicker/parts/Row.js +2 -2
  15. package/cjs/date/monthpicker/MonthCaption.js +1 -1
  16. package/cjs/date/parts/DateInput.js +1 -1
  17. package/cjs/date/utils/check-dates.js +1 -1
  18. package/cjs/date/utils/is-match.js +2 -2
  19. package/cjs/date/utils/parse-date.js +1 -1
  20. package/cjs/dropdown/Dropdown.js +10 -12
  21. package/cjs/dropdown/Menu/Divider.js +1 -1
  22. package/cjs/dropdown/Menu/GroupedList/GroupedHeading.js +1 -1
  23. package/cjs/expansion-card/ExpansionCardHeader.js +1 -1
  24. package/cjs/form/ReadOnlyIcon.js +1 -1
  25. package/cjs/form/Select.js +1 -1
  26. package/cjs/form/combobox/Combobox.js +6 -6
  27. package/cjs/form/combobox/ComboboxProvider.js +2 -2
  28. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
  29. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +4 -4
  30. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
  31. package/cjs/form/error-summary/ErrorSummary.js +2 -2
  32. package/cjs/form/error-summary/ErrorSummaryItem.js +1 -1
  33. package/cjs/form/search/Search.js +1 -1
  34. package/cjs/form/search/SearchButton.js +1 -1
  35. package/cjs/grid/Cell.js +1 -1
  36. package/cjs/grid/Grid.js +1 -1
  37. package/cjs/guide-panel/GuidePanel.js +1 -1
  38. package/cjs/internal-header/InternalHeaderButton.js +1 -1
  39. package/cjs/internal-header/InternalHeaderTitle.js +1 -1
  40. package/cjs/internal-header/InternalHeaderUser.js +1 -1
  41. package/cjs/internal-header/InternalHeaderUserButton.js +1 -1
  42. package/cjs/layout/bleed/Bleed.js +1 -1
  43. package/cjs/layout/content-container/ContentContainer.js +1 -1
  44. package/cjs/layout/grid/HGrid.js +1 -1
  45. package/cjs/layout/page/parts/PageBlock.js +1 -1
  46. package/cjs/layout/sidemal-test/AvatarPanel.js +1 -1
  47. package/cjs/layout/sidemal-test/Content.js +3 -3
  48. package/cjs/layout/sidemal-test/Filter.js +1 -1
  49. package/cjs/layout/sidemal-test/Intro.js +1 -1
  50. package/cjs/link-panel/LinkPanel.js +3 -3
  51. package/cjs/link-panel/LinkPanelDescription.js +1 -1
  52. package/cjs/link-panel/LinkPanelTitle.js +1 -1
  53. package/cjs/modal/ModalBody.js +1 -1
  54. package/cjs/modal/ModalFooter.js +1 -1
  55. package/cjs/modal/ModalHeader.js +1 -1
  56. package/cjs/pagination/PaginationItem.js +1 -1
  57. package/cjs/panel/Panel.js +1 -1
  58. package/cjs/popover/PopoverContent.js +1 -1
  59. package/cjs/read-more/ReadMore.js +12 -10
  60. package/cjs/skeleton/Skeleton.js +1 -1
  61. package/cjs/table/Body.js +1 -1
  62. package/cjs/table/ColumnHeader.js +1 -1
  63. package/cjs/table/DataCell.js +1 -1
  64. package/cjs/table/ExpandableRow.js +14 -13
  65. package/cjs/table/Header.js +1 -1
  66. package/cjs/table/Row.js +1 -1
  67. package/cjs/tabs/TabList.js +1 -1
  68. package/cjs/tabs/Tabs.js +1 -1
  69. package/cjs/tag/Tag.js +1 -1
  70. package/cjs/timeline/AxisLabels.js +1 -1
  71. package/cjs/timeline/TimelineRow.js +2 -2
  72. package/cjs/timeline/hooks/useTimelineRows.js +5 -3
  73. package/cjs/timeline/utils/timeline.js +1 -1
  74. package/cjs/timeline/zoom/ZoomButton.js +1 -1
  75. package/cjs/toggle-group/ToggleGroup.js +1 -1
  76. package/cjs/tooltip/Tooltip.js +12 -7
  77. package/cjs/typography/BodyLong.js +1 -1
  78. package/cjs/typography/ErrorMessage.js +1 -1
  79. package/cjs/typography/Ingress.js +1 -1
  80. package/cjs/util/RandomIcon.js +1 -1
  81. package/cjs/util/hooks/useCallbackRef.js +18 -0
  82. package/cjs/util/hooks/useControllableState.js +25 -0
  83. package/esm/accordion/Accordion.d.ts +1 -1
  84. package/esm/accordion/Accordion.js +2 -2
  85. package/esm/accordion/Accordion.js.map +1 -1
  86. package/esm/accordion/AccordionHeader.js +1 -1
  87. package/esm/accordion/AccordionHeader.js.map +1 -1
  88. package/esm/accordion/AccordionItem.d.ts +4 -0
  89. package/esm/accordion/AccordionItem.js +12 -15
  90. package/esm/accordion/AccordionItem.js.map +1 -1
  91. package/esm/alert/Alert.js +2 -2
  92. package/esm/alert/Alert.js.map +1 -1
  93. package/esm/chat/Bubble.js +1 -1
  94. package/esm/chat/Bubble.js.map +1 -1
  95. package/esm/chat/Chat.js +2 -2
  96. package/esm/chat/Chat.js.map +1 -1
  97. package/esm/chips/Chips.d.ts +2 -2
  98. package/esm/chips/Chips.js +1 -1
  99. package/esm/chips/Chips.js.map +1 -1
  100. package/esm/chips/Removable.js +1 -1
  101. package/esm/chips/Removable.js.map +1 -1
  102. package/esm/copybutton/CopyButton.js +2 -2
  103. package/esm/copybutton/CopyButton.js.map +1 -1
  104. package/esm/date/context/useSharedMonthContext.js.map +1 -1
  105. package/esm/date/datepicker/parts/Caption.js +2 -2
  106. package/esm/date/datepicker/parts/Caption.js.map +1 -1
  107. package/esm/date/datepicker/parts/DropdownCaption.js +1 -1
  108. package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
  109. package/esm/date/datepicker/parts/HeadRow.js +1 -1
  110. package/esm/date/datepicker/parts/HeadRow.js.map +1 -1
  111. package/esm/date/datepicker/parts/Row.js +3 -3
  112. package/esm/date/datepicker/parts/Row.js.map +1 -1
  113. package/esm/date/monthpicker/MonthCaption.js +1 -1
  114. package/esm/date/monthpicker/MonthCaption.js.map +1 -1
  115. package/esm/date/parts/DateInput.js +1 -1
  116. package/esm/date/parts/DateInput.js.map +1 -1
  117. package/esm/date/utils/check-dates.js +1 -1
  118. package/esm/date/utils/check-dates.js.map +1 -1
  119. package/esm/date/utils/get-month-weeks.js.map +1 -1
  120. package/esm/date/utils/is-match.js +2 -2
  121. package/esm/date/utils/is-match.js.map +1 -1
  122. package/esm/date/utils/navigation.js.map +1 -1
  123. package/esm/date/utils/parse-date.js +1 -1
  124. package/esm/date/utils/parse-date.js.map +1 -1
  125. package/esm/dropdown/Dropdown.d.ts +4 -0
  126. package/esm/dropdown/Dropdown.js +10 -12
  127. package/esm/dropdown/Dropdown.js.map +1 -1
  128. package/esm/dropdown/Menu/Divider.js +1 -1
  129. package/esm/dropdown/Menu/Divider.js.map +1 -1
  130. package/esm/dropdown/Menu/GroupedList/GroupedHeading.js +1 -1
  131. package/esm/dropdown/Menu/GroupedList/GroupedHeading.js.map +1 -1
  132. package/esm/expansion-card/ExpansionCardHeader.js +1 -1
  133. package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
  134. package/esm/form/Fieldset/useFieldset.d.ts +1 -1
  135. package/esm/form/ReadOnlyIcon.js +1 -1
  136. package/esm/form/ReadOnlyIcon.js.map +1 -1
  137. package/esm/form/Select.js +1 -1
  138. package/esm/form/Select.js.map +1 -1
  139. package/esm/form/Switch.js.map +1 -1
  140. package/esm/form/TextField.js.map +1 -1
  141. package/esm/form/checkbox/useCheckbox.d.ts +1 -1
  142. package/esm/form/combobox/Combobox.d.ts +1 -1
  143. package/esm/form/combobox/Combobox.js +6 -6
  144. package/esm/form/combobox/Combobox.js.map +1 -1
  145. package/esm/form/combobox/ComboboxProvider.js +2 -2
  146. package/esm/form/combobox/ComboboxProvider.js.map +1 -1
  147. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
  148. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  149. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +1 -1
  150. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +4 -4
  151. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  152. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
  153. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  154. package/esm/form/combobox/ToggleListButton.js +1 -1
  155. package/esm/form/combobox/ToggleListButton.js.map +1 -1
  156. package/esm/form/combobox/customOptionsContext.js +1 -1
  157. package/esm/form/combobox/customOptionsContext.js.map +1 -1
  158. package/esm/form/error-summary/ErrorSummary.js +3 -3
  159. package/esm/form/error-summary/ErrorSummary.js.map +1 -1
  160. package/esm/form/error-summary/ErrorSummaryItem.js +1 -1
  161. package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
  162. package/esm/form/radio/useRadio.d.ts +1 -1
  163. package/esm/form/search/Search.js +1 -1
  164. package/esm/form/search/Search.js.map +1 -1
  165. package/esm/form/search/SearchButton.js +1 -1
  166. package/esm/form/search/SearchButton.js.map +1 -1
  167. package/esm/grid/Cell.js +1 -1
  168. package/esm/grid/Cell.js.map +1 -1
  169. package/esm/grid/Grid.js +1 -1
  170. package/esm/grid/Grid.js.map +1 -1
  171. package/esm/guide-panel/GuidePanel.js +1 -1
  172. package/esm/guide-panel/GuidePanel.js.map +1 -1
  173. package/esm/internal-header/InternalHeader.js.map +1 -1
  174. package/esm/internal-header/InternalHeaderButton.js +1 -1
  175. package/esm/internal-header/InternalHeaderButton.js.map +1 -1
  176. package/esm/internal-header/InternalHeaderTitle.js +1 -1
  177. package/esm/internal-header/InternalHeaderTitle.js.map +1 -1
  178. package/esm/internal-header/InternalHeaderUser.js +1 -1
  179. package/esm/internal-header/InternalHeaderUser.js.map +1 -1
  180. package/esm/internal-header/InternalHeaderUserButton.js +1 -1
  181. package/esm/internal-header/InternalHeaderUserButton.js.map +1 -1
  182. package/esm/layout/bleed/Bleed.js +1 -1
  183. package/esm/layout/bleed/Bleed.js.map +1 -1
  184. package/esm/layout/box/Box.d.ts +1 -1
  185. package/esm/layout/content-container/ContentContainer.js +1 -1
  186. package/esm/layout/content-container/ContentContainer.js.map +1 -1
  187. package/esm/layout/grid/HGrid.js +1 -1
  188. package/esm/layout/grid/HGrid.js.map +1 -1
  189. package/esm/layout/page/Page.d.ts +2 -2
  190. package/esm/layout/page/Page.js.map +1 -1
  191. package/esm/layout/page/parts/PageBlock.d.ts +6 -5
  192. package/esm/layout/page/parts/PageBlock.js +1 -1
  193. package/esm/layout/page/parts/PageBlock.js.map +1 -1
  194. package/esm/layout/responsive/Responsive.js.map +1 -1
  195. package/esm/layout/sidemal-test/AvatarPanel.js +1 -1
  196. package/esm/layout/sidemal-test/AvatarPanel.js.map +1 -1
  197. package/esm/layout/sidemal-test/Content.js +4 -4
  198. package/esm/layout/sidemal-test/Content.js.map +1 -1
  199. package/esm/layout/sidemal-test/Filter.js +1 -1
  200. package/esm/layout/sidemal-test/Filter.js.map +1 -1
  201. package/esm/layout/sidemal-test/Header.js +1 -1
  202. package/esm/layout/sidemal-test/Header.js.map +1 -1
  203. package/esm/layout/sidemal-test/Intro.js +2 -2
  204. package/esm/layout/sidemal-test/Intro.js.map +1 -1
  205. package/esm/layout/sidemal-test/content-box/ContentBox.js.map +1 -1
  206. package/esm/layout/stack/HStack.js.map +1 -1
  207. package/esm/layout/stack/Stack.js.map +1 -1
  208. package/esm/layout/stack/VStack.js.map +1 -1
  209. package/esm/layout/utilities/types.d.ts +2 -2
  210. package/esm/link-panel/LinkPanel.d.ts +2 -2
  211. package/esm/link-panel/LinkPanel.js +3 -3
  212. package/esm/link-panel/LinkPanel.js.map +1 -1
  213. package/esm/link-panel/LinkPanelDescription.js +1 -1
  214. package/esm/link-panel/LinkPanelDescription.js.map +1 -1
  215. package/esm/link-panel/LinkPanelTitle.js +1 -1
  216. package/esm/link-panel/LinkPanelTitle.js.map +1 -1
  217. package/esm/loader/Loader.js.map +1 -1
  218. package/esm/modal/ModalBody.js +1 -1
  219. package/esm/modal/ModalBody.js.map +1 -1
  220. package/esm/modal/ModalFooter.js +1 -1
  221. package/esm/modal/ModalFooter.js.map +1 -1
  222. package/esm/modal/ModalHeader.js +1 -1
  223. package/esm/modal/ModalHeader.js.map +1 -1
  224. package/esm/pagination/Pagination.js.map +1 -1
  225. package/esm/pagination/PaginationItem.js +1 -1
  226. package/esm/pagination/PaginationItem.js.map +1 -1
  227. package/esm/panel/Panel.js +1 -1
  228. package/esm/panel/Panel.js.map +1 -1
  229. package/esm/popover/Popover.js.map +1 -1
  230. package/esm/popover/PopoverContent.js +1 -1
  231. package/esm/popover/PopoverContent.js.map +1 -1
  232. package/esm/read-more/ReadMore.d.ts +4 -0
  233. package/esm/read-more/ReadMore.js +13 -11
  234. package/esm/read-more/ReadMore.js.map +1 -1
  235. package/esm/skeleton/Skeleton.js +1 -1
  236. package/esm/skeleton/Skeleton.js.map +1 -1
  237. package/esm/table/Body.js +1 -1
  238. package/esm/table/Body.js.map +1 -1
  239. package/esm/table/ColumnHeader.js +1 -1
  240. package/esm/table/ColumnHeader.js.map +1 -1
  241. package/esm/table/DataCell.js +1 -1
  242. package/esm/table/DataCell.js.map +1 -1
  243. package/esm/table/ExpandableRow.js +15 -14
  244. package/esm/table/ExpandableRow.js.map +1 -1
  245. package/esm/table/Header.js +1 -1
  246. package/esm/table/Header.js.map +1 -1
  247. package/esm/table/Row.js +1 -1
  248. package/esm/table/Row.js.map +1 -1
  249. package/esm/tabs/TabList.js +1 -1
  250. package/esm/tabs/TabList.js.map +1 -1
  251. package/esm/tabs/Tabs.js +1 -1
  252. package/esm/tabs/Tabs.js.map +1 -1
  253. package/esm/tag/Tag.js +1 -1
  254. package/esm/tag/Tag.js.map +1 -1
  255. package/esm/timeline/AxisLabels.js +1 -1
  256. package/esm/timeline/AxisLabels.js.map +1 -1
  257. package/esm/timeline/TimelineRow.js +2 -2
  258. package/esm/timeline/TimelineRow.js.map +1 -1
  259. package/esm/timeline/hooks/useTimelineRows.js +5 -3
  260. package/esm/timeline/hooks/useTimelineRows.js.map +1 -1
  261. package/esm/timeline/utils/timeline.js +1 -1
  262. package/esm/timeline/utils/timeline.js.map +1 -1
  263. package/esm/timeline/zoom/ZoomButton.js +1 -1
  264. package/esm/timeline/zoom/ZoomButton.js.map +1 -1
  265. package/esm/toggle-group/ToggleGroup.js +1 -1
  266. package/esm/toggle-group/ToggleGroup.js.map +1 -1
  267. package/esm/tooltip/Tooltip.d.ts +4 -0
  268. package/esm/tooltip/Tooltip.js +13 -8
  269. package/esm/tooltip/Tooltip.js.map +1 -1
  270. package/esm/typography/BodyLong.js +1 -1
  271. package/esm/typography/BodyLong.js.map +1 -1
  272. package/esm/typography/ErrorMessage.js +1 -1
  273. package/esm/typography/ErrorMessage.js.map +1 -1
  274. package/esm/typography/Ingress.js +1 -1
  275. package/esm/typography/Ingress.js.map +1 -1
  276. package/esm/util/RandomIcon.js +1 -1
  277. package/esm/util/RandomIcon.js.map +1 -1
  278. package/esm/util/hooks/useCallbackRef.d.ts +7 -0
  279. package/esm/util/hooks/useCallbackRef.js +15 -0
  280. package/esm/util/hooks/useCallbackRef.js.map +1 -0
  281. package/esm/util/hooks/useControllableState.d.ts +9 -0
  282. package/esm/util/hooks/useControllableState.js +22 -0
  283. package/esm/util/hooks/useControllableState.js.map +1 -0
  284. package/esm/util/mergeRefs.js.map +1 -1
  285. package/package.json +3 -3
  286. package/src/accordion/Accordion.tsx +5 -5
  287. package/src/accordion/AccordionContent.tsx +3 -3
  288. package/src/accordion/AccordionHeader.tsx +3 -3
  289. package/src/accordion/AccordionItem.tsx +21 -21
  290. package/src/accordion/accordion.stories.tsx +8 -5
  291. package/src/alert/Alert.tsx +8 -8
  292. package/src/alert/alert.stories.tsx +7 -7
  293. package/src/button/Button.tsx +4 -4
  294. package/src/button/button.stories.tsx +1 -1
  295. package/src/chat/Bubble.tsx +4 -4
  296. package/src/chat/Chat.tsx +5 -5
  297. package/src/chat/chat.stories.tsx +1 -1
  298. package/src/chips/Chips.tsx +4 -4
  299. package/src/chips/Removable.tsx +4 -4
  300. package/src/chips/Toggle.tsx +3 -3
  301. package/src/chips/chips.stories.tsx +5 -5
  302. package/src/copybutton/CopyButton.tsx +6 -6
  303. package/src/copybutton/copy-button.stories.tsx +3 -3
  304. package/src/date/context/useSharedMonthContext.tsx +1 -1
  305. package/src/date/datepicker/DatePicker.tsx +2 -2
  306. package/src/date/datepicker/DatePickerStandalone.tsx +2 -2
  307. package/src/date/datepicker/datepicker.stories.tsx +2 -2
  308. package/src/date/datepicker/parts/Caption.tsx +2 -3
  309. package/src/date/datepicker/parts/DropdownCaption.tsx +2 -2
  310. package/src/date/datepicker/parts/HeadRow.tsx +1 -1
  311. package/src/date/datepicker/parts/Row.tsx +3 -3
  312. package/src/date/hooks/useDatepicker.tsx +7 -7
  313. package/src/date/hooks/useMonthPicker.tsx +7 -7
  314. package/src/date/hooks/useRangeDatepicker.test.tsx +2 -2
  315. package/src/date/hooks/useRangeDatepicker.tsx +28 -28
  316. package/src/date/monthpicker/MonthButton.tsx +1 -1
  317. package/src/date/monthpicker/MonthCaption.tsx +1 -1
  318. package/src/date/monthpicker/MonthPicker.tsx +3 -3
  319. package/src/date/monthpicker/MonthPickerStandalone.tsx +3 -3
  320. package/src/date/monthpicker/MonthSelector.tsx +1 -1
  321. package/src/date/parts/DateInput.tsx +6 -6
  322. package/src/date/utils/__tests__/check-dates.test.ts +3 -3
  323. package/src/date/utils/__tests__/format-dates.test.ts +7 -7
  324. package/src/date/utils/__tests__/get-initial-year.test.ts +14 -14
  325. package/src/date/utils/__tests__/get-month-weeks.test.ts +0 -1
  326. package/src/date/utils/__tests__/is-match.test.ts +4 -4
  327. package/src/date/utils/__tests__/parse-dates.test.ts +2 -2
  328. package/src/date/utils/check-dates.ts +2 -2
  329. package/src/date/utils/dates-disabled.ts +1 -1
  330. package/src/date/utils/format-date.ts +1 -1
  331. package/src/date/utils/get-dates.ts +1 -1
  332. package/src/date/utils/get-month-weeks.ts +6 -6
  333. package/src/date/utils/is-match.ts +2 -3
  334. package/src/date/utils/labels.ts +1 -1
  335. package/src/date/utils/navigation.ts +18 -18
  336. package/src/date/utils/parse-date.ts +8 -8
  337. package/src/dropdown/Dropdown.tsx +14 -11
  338. package/src/dropdown/Menu/Divider.tsx +1 -1
  339. package/src/dropdown/Menu/GroupedList/GroupedHeading.tsx +2 -2
  340. package/src/dropdown/Menu/GroupedList/GroupedItem.tsx +1 -1
  341. package/src/dropdown/Menu/GroupedList/index.tsx +1 -1
  342. package/src/dropdown/Menu/List/Item.tsx +1 -1
  343. package/src/dropdown/Menu/index.tsx +1 -1
  344. package/src/dropdown/dropdown.stories.tsx +1 -1
  345. package/src/expansion-card/ExpansionCard.tsx +3 -3
  346. package/src/expansion-card/ExpansionCardContent.tsx +1 -1
  347. package/src/expansion-card/ExpansionCardDescription.tsx +1 -1
  348. package/src/expansion-card/ExpansionCardHeader.tsx +2 -2
  349. package/src/expansion-card/ExpansionCardTitle.tsx +2 -2
  350. package/src/expansion-card/expansion-card.stories.tsx +1 -1
  351. package/src/form/ConfirmationPanel.test.tsx +1 -1
  352. package/src/form/ConfirmationPanel.tsx +2 -2
  353. package/src/form/Fieldset/Fieldset.tsx +2 -2
  354. package/src/form/ReadOnlyIcon.tsx +1 -1
  355. package/src/form/Select.tsx +6 -6
  356. package/src/form/Switch.tsx +4 -4
  357. package/src/form/TextField.tsx +4 -4
  358. package/src/form/Textarea.tsx +4 -4
  359. package/src/form/checkbox/Checkbox.test.tsx +8 -8
  360. package/src/form/checkbox/Checkbox.tsx +3 -3
  361. package/src/form/checkbox/CheckboxGroup.tsx +4 -4
  362. package/src/form/checkbox/useCheckbox.ts +3 -3
  363. package/src/form/combobox/Combobox.tsx +8 -8
  364. package/src/form/combobox/ComboboxProvider.tsx +3 -3
  365. package/src/form/combobox/ComboboxWrapper.tsx +1 -1
  366. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +6 -6
  367. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +18 -18
  368. package/src/form/combobox/FilteredOptions/useVirtualFocus.ts +5 -5
  369. package/src/form/combobox/Input/Input.tsx +6 -6
  370. package/src/form/combobox/Input/inputContext.tsx +6 -6
  371. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
  372. package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +9 -9
  373. package/src/form/combobox/ToggleListButton.tsx +1 -2
  374. package/src/form/combobox/combobox.stories.tsx +8 -8
  375. package/src/form/combobox/combobox.test.tsx +14 -12
  376. package/src/form/combobox/customOptionsContext.tsx +6 -6
  377. package/src/form/combobox/types.ts +2 -2
  378. package/src/form/error-summary/ErrorSummary.tsx +6 -6
  379. package/src/form/error-summary/ErrorSummaryItem.tsx +2 -2
  380. package/src/form/error-summary/error-summary.stories.tsx +2 -1
  381. package/src/form/radio/Radio.test.tsx +1 -1
  382. package/src/form/radio/Radio.tsx +1 -1
  383. package/src/form/radio/RadioGroup.tsx +3 -3
  384. package/src/form/radio/useRadio.ts +1 -1
  385. package/src/form/search/Search.tsx +6 -6
  386. package/src/form/search/SearchButton.tsx +2 -2
  387. package/src/form/search/search.stories.tsx +1 -1
  388. package/src/form/stories/fieldset.stories.tsx +3 -2
  389. package/src/form/stories/select.stories.tsx +2 -1
  390. package/src/form/stories/text-field.stories.tsx +2 -1
  391. package/src/form/useFormField.ts +3 -3
  392. package/src/grid/Cell.tsx +3 -3
  393. package/src/grid/Grid.tsx +2 -2
  394. package/src/grid/grid.stories.tsx +1 -1
  395. package/src/guide-panel/GuidePanel.tsx +2 -2
  396. package/src/guide-panel/guidepanel.stories.tsx +1 -1
  397. package/src/help-text/HelpText.tsx +2 -2
  398. package/src/internal-header/InternalHeader.tsx +1 -1
  399. package/src/internal-header/InternalHeaderButton.tsx +1 -1
  400. package/src/internal-header/InternalHeaderTitle.tsx +1 -1
  401. package/src/internal-header/InternalHeaderUser.tsx +1 -1
  402. package/src/internal-header/InternalHeaderUserButton.tsx +1 -1
  403. package/src/internal-header/header.stories.tsx +3 -3
  404. package/src/layout/bleed/Bleed.tsx +7 -7
  405. package/src/layout/box/Box.stories.tsx +4 -4
  406. package/src/layout/box/Box.tsx +7 -7
  407. package/src/layout/content-container/ContentContainer.tsx +1 -1
  408. package/src/layout/grid/HGrid.tsx +4 -4
  409. package/src/layout/page/Page.stories.tsx +1 -1
  410. package/src/layout/page/Page.tsx +4 -4
  411. package/src/layout/page/parts/PageBlock.tsx +8 -7
  412. package/src/layout/responsive/Responsive.tsx +6 -6
  413. package/src/layout/responsive/hide.stories.tsx +1 -1
  414. package/src/layout/responsive/show.stories.tsx +1 -1
  415. package/src/layout/sidemal-test/AvatarPanel.tsx +1 -1
  416. package/src/layout/sidemal-test/Content.tsx +4 -4
  417. package/src/layout/sidemal-test/Filter.tsx +1 -1
  418. package/src/layout/sidemal-test/Header.tsx +1 -1
  419. package/src/layout/sidemal-test/Intro.tsx +2 -2
  420. package/src/layout/sidemal-test/content-box/ContentBox.tsx +6 -6
  421. package/src/layout/sidemal-test/navno-sidemal.stories.tsx +1 -1
  422. package/src/layout/stack/HStack.tsx +1 -1
  423. package/src/layout/stack/Stack.tsx +3 -3
  424. package/src/layout/stack/VStack.tsx +1 -1
  425. package/src/layout/stack/stack.stories.tsx +2 -2
  426. package/src/layout/utilities/css.ts +6 -6
  427. package/src/layout/utilities/types.ts +2 -2
  428. package/src/link/Link.tsx +2 -2
  429. package/src/link/link.stories.tsx +1 -1
  430. package/src/link-panel/LinkPanel.tsx +6 -7
  431. package/src/link-panel/LinkPanelDescription.tsx +1 -1
  432. package/src/link-panel/LinkPanelTitle.tsx +2 -2
  433. package/src/list/List.tsx +2 -2
  434. package/src/list/ListItem.tsx +2 -2
  435. package/src/list/list.stories.tsx +2 -2
  436. package/src/loader/Loader.tsx +4 -4
  437. package/src/loader/loader.stories.tsx +1 -0
  438. package/src/modal/Modal.test.tsx +4 -4
  439. package/src/modal/Modal.tsx +2 -2
  440. package/src/modal/ModalBody.tsx +2 -2
  441. package/src/modal/ModalFooter.tsx +2 -2
  442. package/src/modal/ModalHeader.tsx +2 -2
  443. package/src/modal/ModalUtils.ts +2 -2
  444. package/src/modal/dialog-polyfill.ts +16 -16
  445. package/src/pagination/Pagination.tsx +5 -6
  446. package/src/pagination/PaginationItem.tsx +3 -3
  447. package/src/pagination/steps.test.ts +8 -8
  448. package/src/panel/Panel.tsx +3 -3
  449. package/src/panel/panel.stories.tsx +2 -1
  450. package/src/popover/Popover.test.tsx +7 -7
  451. package/src/popover/Popover.tsx +8 -8
  452. package/src/popover/PopoverContent.tsx +2 -2
  453. package/src/provider/Provider.tsx +1 -1
  454. package/src/read-more/ReadMore.tsx +19 -13
  455. package/src/read-more/readmore.stories.tsx +4 -0
  456. package/src/skeleton/Skeleton.tsx +4 -4
  457. package/src/stepper/Step.tsx +2 -2
  458. package/src/stepper/Stepper.tsx +3 -3
  459. package/src/table/Body.tsx +1 -1
  460. package/src/table/ColumnHeader.tsx +2 -2
  461. package/src/table/DataCell.tsx +2 -2
  462. package/src/table/ExpandableRow.tsx +19 -17
  463. package/src/table/Header.tsx +1 -1
  464. package/src/table/HeaderCell.tsx +1 -1
  465. package/src/table/Row.tsx +2 -2
  466. package/src/table/Table.tsx +2 -2
  467. package/src/table/stories/table-async.stories.tsx +4 -4
  468. package/src/table/stories/table.stories.tsx +1 -1
  469. package/src/tabs/Tab.tsx +3 -3
  470. package/src/tabs/TabList.tsx +4 -4
  471. package/src/tabs/TabPanel.tsx +1 -1
  472. package/src/tabs/Tabs.stories.tsx +1 -1
  473. package/src/tabs/Tabs.tsx +4 -4
  474. package/src/tag/Tag.tsx +3 -3
  475. package/src/tag/tag.stories.tsx +1 -1
  476. package/src/timeline/AxisLabels.tsx +9 -9
  477. package/src/timeline/Pin.tsx +2 -2
  478. package/src/timeline/Timeline.tsx +7 -7
  479. package/src/timeline/TimelineRow.tsx +5 -5
  480. package/src/timeline/hooks/useTimelineContext.tsx +1 -1
  481. package/src/timeline/hooks/useTimelineRows.ts +18 -19
  482. package/src/timeline/period/ClickablePeriod.tsx +4 -4
  483. package/src/timeline/period/NonClickablePeriod.tsx +1 -1
  484. package/src/timeline/period/index.tsx +1 -1
  485. package/src/timeline/timeline.stories.tsx +2 -2
  486. package/src/timeline/utils/calc.ts +2 -2
  487. package/src/timeline/utils/filter.ts +2 -2
  488. package/src/timeline/utils/period.ts +2 -2
  489. package/src/timeline/utils/timeline.ts +1 -1
  490. package/src/timeline/zoom/ZoomButton.tsx +3 -3
  491. package/src/timeline/zoom/index.tsx +1 -1
  492. package/src/toggle-group/ToggleGroup.stories.tsx +2 -2
  493. package/src/toggle-group/ToggleGroup.tsx +5 -5
  494. package/src/toggle-group/ToggleItem.tsx +1 -1
  495. package/src/toggle-group/context.ts +1 -1
  496. package/src/tooltip/Tooltip.test.tsx +10 -10
  497. package/src/tooltip/Tooltip.tsx +20 -11
  498. package/src/tooltip/tooltip.stories.tsx +1 -1
  499. package/src/typography/BodyLong.tsx +4 -4
  500. package/src/typography/BodyShort.tsx +3 -3
  501. package/src/typography/Detail.tsx +3 -3
  502. package/src/typography/ErrorMessage.tsx +3 -3
  503. package/src/typography/Heading.tsx +3 -3
  504. package/src/typography/Ingress.tsx +1 -1
  505. package/src/typography/Label.tsx +3 -3
  506. package/src/typography/stories/heading.stories.tsx +1 -2
  507. package/src/util/AnimateHeight.tsx +1 -1
  508. package/src/util/OverridableComponent.ts +1 -1
  509. package/src/util/RandomIcon.tsx +1 -1
  510. package/src/util/Slot.tsx +3 -3
  511. package/src/util/TextareaAutoSize.tsx +4 -4
  512. package/src/util/__tests__/Slot.test.tsx +11 -11
  513. package/src/util/hooks/useCallbackRef.ts +20 -0
  514. package/src/util/hooks/useControllableState.ts +40 -0
  515. package/src/util/mergeRefs.tsx +2 -1
  516. package/src/util/omit.ts +1 -1
  517. package/src/util/useEventListener.ts +1 -1
  518. package/src/util/useMedia.ts +1 -1
@@ -79,7 +79,7 @@ export const Stepper: StepperComponent = forwardRef<
79
79
  interactive = true,
80
80
  ...rest
81
81
  },
82
- ref
82
+ ref,
83
83
  ) => {
84
84
  activeStep = activeStep - 1;
85
85
  return (
@@ -89,7 +89,7 @@ export const Stepper: StepperComponent = forwardRef<
89
89
  className={cl(
90
90
  "navds-stepper",
91
91
  orientation === "horizontal" ? "navds-stepper--horizontal" : "",
92
- className
92
+ className,
93
93
  )}
94
94
  >
95
95
  <StepperContext.Provider
@@ -129,7 +129,7 @@ export const Stepper: StepperComponent = forwardRef<
129
129
  </StepperContext.Provider>
130
130
  </ol>
131
131
  );
132
- }
132
+ },
133
133
  ) as StepperComponent;
134
134
 
135
135
  Stepper.Step = Step;
@@ -1,5 +1,5 @@
1
- import React, { forwardRef } from "react";
2
1
  import cl from "clsx";
2
+ import React, { forwardRef } from "react";
3
3
 
4
4
  export interface BodyProps
5
5
  extends React.HTMLAttributes<HTMLTableSectionElement> {}
@@ -1,9 +1,9 @@
1
+ import React, { forwardRef, useContext } from "react";
1
2
  import {
2
3
  ArrowDownIcon,
3
4
  ArrowUpIcon,
4
5
  ArrowsUpDownIcon,
5
6
  } from "@navikt/aksel-icons";
6
- import React, { forwardRef, useContext } from "react";
7
7
  import HeaderCell, { HeaderCellProps } from "./HeaderCell";
8
8
  import { TableContext } from "./context";
9
9
 
@@ -72,7 +72,7 @@ export const ColumnHeader: ColumnHeaderType = forwardRef(
72
72
  )}
73
73
  </HeaderCell>
74
74
  );
75
- }
75
+ },
76
76
  );
77
77
 
78
78
  export default ColumnHeader;
@@ -1,5 +1,5 @@
1
- import React, { forwardRef } from "react";
2
1
  import cl from "clsx";
2
+ import React, { forwardRef } from "react";
3
3
  import { BodyShort } from "../typography";
4
4
 
5
5
  export interface DataCellProps
@@ -30,7 +30,7 @@ export const DataCell: DataCellType = forwardRef(
30
30
  {children}
31
31
  </BodyShort>
32
32
  );
33
- }
33
+ },
34
34
  );
35
35
 
36
36
  export default DataCell;
@@ -1,8 +1,9 @@
1
- import { ChevronDownIcon } from "@navikt/aksel-icons";
2
1
  import cl from "clsx";
3
- import React, { forwardRef, useState } from "react";
2
+ import React, { forwardRef } from "react";
3
+ import { ChevronDownIcon } from "@navikt/aksel-icons";
4
4
  import { useId } from "../util";
5
5
  import AnimateHeight from "../util/AnimateHeight";
6
+ import { useControllableState } from "../util/hooks/useControllableState";
6
7
  import DataCell from "./DataCell";
7
8
  import Row, { RowProps } from "./Row";
8
9
 
@@ -67,17 +68,18 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
67
68
  colSpan = 999,
68
69
  ...rest
69
70
  },
70
- ref
71
+ ref,
71
72
  ) => {
72
- const [internalOpen, setInternalOpen] = useState<boolean>(defaultOpen);
73
+ const [_open, _setOpen] = useControllableState({
74
+ defaultValue: defaultOpen,
75
+ value: open,
76
+ onChange: onOpenChange,
77
+ });
78
+
73
79
  const id = useId();
74
- const isOpen = open ?? internalOpen;
75
80
 
76
81
  const expansionHandler = (e) => {
77
- onOpenChange?.(!isOpen);
78
- if (open === undefined) {
79
- setInternalOpen((oldOpen) => !oldOpen);
80
- }
82
+ _setOpen((x) => !x);
81
83
  e.stopPropagation();
82
84
  };
83
85
 
@@ -90,7 +92,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
90
92
  {...rest}
91
93
  ref={ref}
92
94
  className={cl("navds-table__expandable-row", className, {
93
- "navds-table__expandable-row--open": isOpen,
95
+ "navds-table__expandable-row--open": _open,
94
96
  "navds-table__expandable-row--expansion-disabled":
95
97
  expansionDisabled,
96
98
  "navds-table__expandable-row--clickable": expandOnRowClick,
@@ -103,7 +105,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
103
105
  {togglePlacement === "right" && children}
104
106
  <DataCell
105
107
  className={cl("navds-table__toggle-expand-cell", {
106
- "navds-table__toggle-expand-cell--open": isOpen,
108
+ "navds-table__toggle-expand-cell--open": _open,
107
109
  })}
108
110
  >
109
111
  {!expansionDisabled && (
@@ -111,24 +113,24 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
111
113
  className="navds-table__toggle-expand-button"
112
114
  type="button"
113
115
  aria-controls={id}
114
- aria-expanded={isOpen}
116
+ aria-expanded={_open}
115
117
  onClick={expansionHandler}
116
118
  >
117
119
  <ChevronDownIcon
118
120
  className="navds-table__expandable-icon"
119
- title={isOpen ? "Vis mindre" : "Vis mer"}
121
+ title={_open ? "Vis mindre" : "Vis mer"}
120
122
  />
121
123
  </button>
122
124
  )}
123
125
  </DataCell>
124
126
  {togglePlacement === "left" && children}
125
127
  </Row>
126
- <tr className="navds-table__expanded-row" aria-hidden={!isOpen} id={id}>
128
+ <tr className="navds-table__expanded-row" aria-hidden={!_open} id={id}>
127
129
  <td colSpan={colSpan} className="navds-table__expanded-row-cell">
128
130
  <AnimateHeight
129
131
  className="navds-table__expanded-row-collapse"
130
132
  innerClassName="navds-table__expanded-row-content"
131
- height={isOpen ? "auto" : 0}
133
+ height={_open ? "auto" : 0}
132
134
  duration={250}
133
135
  >
134
136
  {content}
@@ -137,7 +139,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
137
139
  </tr>
138
140
  </>
139
141
  );
140
- }
142
+ },
141
143
  );
142
144
 
143
145
  function isInteractiveTarget(elm: HTMLElement) {
@@ -146,7 +148,7 @@ function isInteractiveTarget(elm: HTMLElement) {
146
148
  }
147
149
  if (
148
150
  ["BUTTON", "DETAILS", "LABEL", "SELECT", "TEXTAREA", "INPUT", "A"].includes(
149
- elm.nodeName
151
+ elm.nodeName,
150
152
  )
151
153
  ) {
152
154
  return true;
@@ -1,5 +1,5 @@
1
- import React, { forwardRef } from "react";
2
1
  import cl from "clsx";
2
+ import React, { forwardRef } from "react";
3
3
 
4
4
  export interface HeaderProps
5
5
  extends React.HTMLAttributes<HTMLTableSectionElement> {}
@@ -29,7 +29,7 @@ export const HeaderCell: HeaderCellType = forwardRef(
29
29
  {children}
30
30
  </th>
31
31
  );
32
- }
32
+ },
33
33
  );
34
34
 
35
35
  export default HeaderCell;
package/src/table/Row.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React, { forwardRef } from "react";
2
1
  import cl from "clsx";
2
+ import React, { forwardRef } from "react";
3
3
 
4
4
  export interface RowProps extends React.HTMLAttributes<HTMLTableRowElement> {
5
5
  /**
@@ -29,7 +29,7 @@ export const Row: RowType = forwardRef(
29
29
  "navds-table__row--shade-on-hover": shadeOnHover,
30
30
  })}
31
31
  />
32
- )
32
+ ),
33
33
  );
34
34
 
35
35
  export default Row;
@@ -87,7 +87,7 @@ export const Table = forwardRef(
87
87
  sort,
88
88
  ...rest
89
89
  },
90
- ref
90
+ ref,
91
91
  ) => (
92
92
  <TableContext.Provider value={{ onSortChange, sort }}>
93
93
  <table
@@ -98,7 +98,7 @@ export const Table = forwardRef(
98
98
  })}
99
99
  />
100
100
  </TableContext.Provider>
101
- )
101
+ ),
102
102
  ) as TableType;
103
103
 
104
104
  Table.Header = Header;
@@ -25,7 +25,7 @@ const updateData = async (url: string) => {
25
25
  const comparator = (
26
26
  a: Record<string, string | number | null>,
27
27
  b: Record<string, string | number | null>,
28
- orderBy: string
28
+ orderBy: string,
29
29
  ) => {
30
30
  if ((b[orderBy] ?? "") < (a[orderBy] ?? "")) {
31
31
  return -1;
@@ -40,7 +40,7 @@ const updateData = async (url: string) => {
40
40
  const sort = newUrl.searchParams.get("sort");
41
41
 
42
42
  await new Promise((resolve) =>
43
- setTimeout(resolve, Math.round(Math.random() * (1000 - 200) + 200))
43
+ setTimeout(resolve, Math.round(Math.random() * (1000 - 200) + 200)),
44
44
  );
45
45
 
46
46
  return {
@@ -69,7 +69,7 @@ export const Async = () => {
69
69
  page,
70
70
  sort: sort ? `${sort.orderBy}:${sort.direction}` : undefined,
71
71
  })}`,
72
- (url) => updateData(url)
72
+ (url) => updateData(url),
73
73
  );
74
74
 
75
75
  if (!data) {
@@ -125,7 +125,7 @@ export const Async = () => {
125
125
  sort?.direction === "ascending"
126
126
  ? "descending"
127
127
  : "ascending",
128
- }
128
+ },
129
129
  )
130
130
  }
131
131
  >
@@ -164,7 +164,7 @@ const SelectionTable = ({ size = "medium" }: { size?: "small" | "medium" }) => {
164
164
  setList((oldList) =>
165
165
  oldList.includes(value)
166
166
  ? oldList.filter((id) => id !== value)
167
- : [...oldList, value]
167
+ : [...oldList, value],
168
168
  ),
169
169
  ];
170
170
  };
package/src/tabs/Tab.tsx CHANGED
@@ -25,7 +25,7 @@ export const Tab: OverridableComponent<TabProps, HTMLButtonElement> =
25
25
  forwardRef(
26
26
  (
27
27
  { className, as: Component = "button", label, icon, value, ...rest },
28
- ref
28
+ ref,
29
29
  ) => {
30
30
  const context = useContext(TabsContext);
31
31
 
@@ -45,7 +45,7 @@ export const Tab: OverridableComponent<TabProps, HTMLButtonElement> =
45
45
  className,
46
46
  {
47
47
  "navds-tabs__tab--icon-only": icon && !label,
48
- }
48
+ },
49
49
  )}
50
50
  {...rest}
51
51
  >
@@ -60,7 +60,7 @@ export const Tab: OverridableComponent<TabProps, HTMLButtonElement> =
60
60
  </Component>
61
61
  </RadixTabs.Trigger>
62
62
  );
63
- }
63
+ },
64
64
  );
65
65
 
66
66
  export default Tab;
@@ -1,4 +1,3 @@
1
- import { ChevronLeftIcon, ChevronRightIcon } from "@navikt/aksel-icons";
2
1
  import { TabsList } from "@radix-ui/react-tabs";
3
2
  import cl from "clsx";
4
3
  import React, {
@@ -9,6 +8,7 @@ import React, {
9
8
  useRef,
10
9
  useState,
11
10
  } from "react";
11
+ import { ChevronLeftIcon, ChevronRightIcon } from "@navikt/aksel-icons";
12
12
  import { debounce, mergeRefs } from "../util";
13
13
  import { TabsContext } from "./context";
14
14
 
@@ -43,10 +43,10 @@ export const TabList = forwardRef<HTMLDivElement, TabListProps>(
43
43
  showStartScroll === oldDisplayScroll.start &&
44
44
  showEndScroll === oldDisplayScroll.end
45
45
  ? oldDisplayScroll
46
- : { start: showStartScroll, end: showEndScroll }
46
+ : { start: showStartScroll, end: showEndScroll },
47
47
  );
48
48
  }),
49
- []
49
+ [],
50
50
  );
51
51
 
52
52
  useEffect(() => {
@@ -120,7 +120,7 @@ export const TabList = forwardRef<HTMLDivElement, TabListProps>(
120
120
  {showSteppers && <ScrollButton dir={1} hidden={!displayScroll.end} />}
121
121
  </div>
122
122
  );
123
- }
123
+ },
124
124
  );
125
125
 
126
126
  export default TabList;
@@ -20,7 +20,7 @@ const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(
20
20
  ref={ref}
21
21
  className={cl("navds-tabs__tabpanel", className)}
22
22
  />
23
- )
23
+ ),
24
24
  );
25
25
 
26
26
  export default TabPanel;
@@ -1,7 +1,7 @@
1
1
  import { Meta } from "@storybook/react";
2
2
  import React, { useState } from "react";
3
+ import { DishwasherIcon, FreezerIcon, MugIcon } from "@navikt/aksel-icons";
3
4
  import { Tabs } from ".";
4
- import { FreezerIcon, MugIcon, DishwasherIcon } from "@navikt/aksel-icons";
5
5
 
6
6
  export default {
7
7
  title: "ds-react/Tabs",
package/src/tabs/Tabs.tsx CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as RadixTabs from "@radix-ui/react-tabs";
2
2
  import cl from "clsx";
3
- import React, { forwardRef, HTMLAttributes } from "react";
3
+ import React, { HTMLAttributes, forwardRef } from "react";
4
4
  import { OverridableComponent } from "../util/OverridableComponent";
5
- import { TabsContext } from "./context";
6
5
  import Tab, { TabProps } from "./Tab";
7
6
  import TabList, { TabListProps } from "./TabList";
8
7
  import TabPanel, { TabPanelProps } from "./TabPanel";
8
+ import { TabsContext } from "./context";
9
9
 
10
10
  export interface TabsProps
11
11
  extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "dir"> {
@@ -105,7 +105,7 @@ export const Tabs = forwardRef<HTMLDivElement, TabsProps>(
105
105
  iconPosition = "left",
106
106
  ...rest
107
107
  },
108
- ref
108
+ ref,
109
109
  ) => {
110
110
  return (
111
111
  <RadixTabs.Root
@@ -126,7 +126,7 @@ export const Tabs = forwardRef<HTMLDivElement, TabsProps>(
126
126
  </TabsContext.Provider>
127
127
  </RadixTabs.Root>
128
128
  );
129
- }
129
+ },
130
130
  ) as TabsComponent;
131
131
 
132
132
  Tabs.Tab = Tab;
package/src/tag/Tag.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import React, { forwardRef, HTMLAttributes } from "react";
2
1
  import cl from "clsx";
2
+ import React, { HTMLAttributes, forwardRef } from "react";
3
3
  import { BodyShort } from "../typography";
4
4
 
5
5
  export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
@@ -60,10 +60,10 @@ export const Tag = forwardRef<HTMLSpanElement, TagProps>(
60
60
  "navds-tag",
61
61
  className,
62
62
  `navds-tag--${variant}`,
63
- `navds-tag--${size}`
63
+ `navds-tag--${size}`,
64
64
  )}
65
65
  />
66
- )
66
+ ),
67
67
  );
68
68
 
69
69
  export default Tag;
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import type { Meta } from "@storybook/react";
2
+ import React from "react";
3
3
  import { Tag, TagProps } from ".";
4
4
 
5
5
  const variants: TagProps["variant"][] = [
@@ -1,4 +1,3 @@
1
- import { Detail } from "../typography/Detail";
2
1
  import {
3
2
  addDays,
4
3
  addMonths,
@@ -16,6 +15,7 @@ import {
16
15
  } from "date-fns";
17
16
  import nbLocale from "date-fns/locale/nb";
18
17
  import React from "react";
18
+ import { Detail } from "../typography/Detail";
19
19
  import { useTimelineContext } from "./hooks/useTimelineContext";
20
20
  import { isVisible } from "./utils";
21
21
  import { horizontalPositionAndWidth } from "./utils/calc";
@@ -26,7 +26,7 @@ export const dayLabels = (
26
26
  end: Date,
27
27
  totalDays: number,
28
28
  direction: "left" | "right",
29
- template: string = "dd.MM"
29
+ template: string = "dd.MM",
30
30
  ): AxisLabel[] => {
31
31
  const increment = Math.ceil(totalDays / 10);
32
32
  const lastDay = startOfDay(end);
@@ -39,7 +39,7 @@ export const dayLabels = (
39
39
  day,
40
40
  addDays(day, 1),
41
41
  start,
42
- end
42
+ end,
43
43
  );
44
44
  return {
45
45
  direction,
@@ -56,7 +56,7 @@ export const monthLabels = (
56
56
  start: Date,
57
57
  end: Date,
58
58
  direction: "left" | "right",
59
- template: string = "MMM yy"
59
+ template: string = "MMM yy",
60
60
  ): AxisLabel[] => {
61
61
  const startMonth = startOfMonth(start);
62
62
  const endMonth = endOfMonth(end);
@@ -67,7 +67,7 @@ export const monthLabels = (
67
67
  month,
68
68
  addMonths(month, 1),
69
69
  start,
70
- end
70
+ end,
71
71
  );
72
72
  return {
73
73
  direction,
@@ -83,7 +83,7 @@ export const yearLabels = (
83
83
  start: Date,
84
84
  end: Date,
85
85
  direction: "left" | "right",
86
- template: string = "yyyy"
86
+ template: string = "yyyy",
87
87
  ): AxisLabel[] => {
88
88
  const firstYear = startOfYear(start);
89
89
  const lastYear = endOfYear(end);
@@ -94,7 +94,7 @@ export const yearLabels = (
94
94
  year,
95
95
  addYears(year, 1),
96
96
  start,
97
- end
97
+ end,
98
98
  );
99
99
  return {
100
100
  direction,
@@ -110,7 +110,7 @@ const axisLabels = (
110
110
  start: Date,
111
111
  end: Date,
112
112
  direction: "left" | "right",
113
- templates?: AxisLabelTemplates
113
+ templates?: AxisLabelTemplates,
114
114
  ): AxisLabel[] => {
115
115
  const totalDays = differenceInDays(end, start);
116
116
  if (totalDays < 40) {
@@ -129,7 +129,7 @@ export const AxisLabels = ({
129
129
  }) => {
130
130
  const { endDate, startDate, direction } = useTimelineContext();
131
131
  const labels = axisLabels(startDate, endDate, direction, templates).filter(
132
- isVisible
132
+ isVisible,
133
133
  );
134
134
 
135
135
  return (
@@ -83,7 +83,7 @@ export const Pin = forwardRef<HTMLButtonElement, TimelinePinProps>(
83
83
 
84
84
  const mergedRef = useMemo(
85
85
  () => mergeRefs([refs.setReference, ref]),
86
- [ref, refs.setReference]
86
+ [ref, refs.setReference],
87
87
  );
88
88
 
89
89
  const staticSide = {
@@ -148,7 +148,7 @@ export const Pin = forwardRef<HTMLButtonElement, TimelinePinProps>(
148
148
  )}
149
149
  </>
150
150
  );
151
- }
151
+ },
152
152
  ) as PinType;
153
153
 
154
154
  Pin.componentType = "pin";
@@ -89,7 +89,7 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
89
89
  axisLabelTemplates,
90
90
  ...rest
91
91
  },
92
- ref
92
+ ref,
93
93
  ) => {
94
94
  const isMultipleRows = Array.isArray(children);
95
95
 
@@ -101,7 +101,7 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
101
101
  children = [children];
102
102
  }
103
103
  const rowChildren = React.Children.toArray(children).filter(
104
- (c: any) => c?.type?.componentType === "row"
104
+ (c: any) => c?.type?.componentType === "row",
105
105
  );
106
106
 
107
107
  const pins = React.Children.toArray(children)
@@ -109,7 +109,7 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
109
109
  .map((x) => () => x);
110
110
 
111
111
  const zoomComponent = React.Children.toArray(children).find(
112
- (c: any) => c?.type?.componentType === "zoom"
112
+ (c: any) => c?.type?.componentType === "zoom",
113
113
  );
114
114
 
115
115
  const rowsRaw = useMemo(() => {
@@ -127,7 +127,7 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
127
127
  const [start, setStart] = useState(initialStartDate);
128
128
  const [activeRow, setActiveRow] = useState<number | null>(null);
129
129
  const [endInclusive, setEndInclusive] = useState(
130
- endOfDay(useLatestDate({ endDate, rows }))
130
+ endOfDay(useLatestDate({ endDate, rows })),
131
131
  );
132
132
 
133
133
  const initialEndDate = endOfDay(useLatestDate({ endDate, rows }));
@@ -135,14 +135,14 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
135
135
  rowsRaw,
136
136
  startDate ?? start,
137
137
  endDate ?? endInclusive,
138
- direction
138
+ direction,
139
139
  );
140
140
 
141
141
  const handleZoomChange = (zoomStart: Date) => {
142
142
  if (startDate || endDate) {
143
143
  if (process.env.NODE_ENV !== "production") {
144
144
  console.warn(
145
- "Zooming is not supported when startDate or endDate is set"
145
+ "Zooming is not supported when startDate or endDate is set",
146
146
  );
147
147
  }
148
148
  return;
@@ -242,7 +242,7 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
242
242
  </div>
243
243
  </TimelineContext.Provider>
244
244
  );
245
- }
245
+ },
246
246
  ) as TimelineComponent;
247
247
 
248
248
  Timeline.Row = TimelineRow;
@@ -1,6 +1,7 @@
1
- import { BodyShort } from "../typography/BodyShort";
1
+ import cl from "clsx";
2
2
  import { format } from "date-fns";
3
3
  import React, { forwardRef } from "react";
4
+ import { BodyShort } from "../typography/BodyShort";
4
5
  import { PeriodContext } from "./hooks/usePeriodContext";
5
6
  import { useRowContext } from "./hooks/useRowContext";
6
7
  import { useTimelineContext } from "./hooks/useTimelineContext";
@@ -9,7 +10,6 @@ import {
9
10
  PositionedPeriod,
10
11
  TimelineComponentTypes,
11
12
  } from "./utils/types.internal";
12
- import cl from "clsx";
13
13
 
14
14
  export interface TimelineRowProps
15
15
  extends React.HTMLAttributes<HTMLOListElement> {
@@ -49,7 +49,7 @@ export const TimelineRow = forwardRef<HTMLOListElement, TimelineRowProps>(
49
49
  }, {} as PositionedPeriod);
50
50
 
51
51
  const firstFocusable = periods.find(
52
- (p) => !!p.children || !!p.onSelectPeriod
52
+ (p) => !!p.children || !!p.onSelectPeriod,
53
53
  );
54
54
 
55
55
  return (
@@ -80,7 +80,7 @@ export const TimelineRow = forwardRef<HTMLOListElement, TimelineRowProps>(
80
80
  ? "Ingen perioder"
81
81
  : `${format(earliest.start, "dd.MM.yyyy")} til ${format(
82
82
  latest.end,
83
- "dd.MM.yyyy"
83
+ "dd.MM.yyyy",
84
84
  )}`
85
85
  }
86
86
  className={cl("navds-timeline__row-periods", className)}
@@ -116,7 +116,7 @@ export const TimelineRow = forwardRef<HTMLOListElement, TimelineRowProps>(
116
116
  </div>
117
117
  </>
118
118
  );
119
- }
119
+ },
120
120
  ) as TimelineRowType;
121
121
 
122
122
  TimelineRow.componentType = "row";
@@ -29,7 +29,7 @@ export const useTimelineContext = () => {
29
29
 
30
30
  if (!context) {
31
31
  console.warn(
32
- "useTimelineContext must be used with TimelineContext (<Timeline />)"
32
+ "useTimelineContext must be used with TimelineContext (<Timeline />)",
33
33
  );
34
34
  }
35
35