@navikt/ds-react 6.0.0-alpha.1 → 6.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (658) hide show
  1. package/_docs.json +520 -60
  2. package/cjs/chat/Bubble.d.ts +0 -5
  3. package/cjs/chat/Bubble.js +2 -2
  4. package/cjs/chat/Bubble.js.map +1 -1
  5. package/cjs/chat/Chat.d.ts +0 -10
  6. package/cjs/chat/Chat.js +3 -3
  7. package/cjs/chat/Chat.js.map +1 -1
  8. package/cjs/date/context/useSharedMonthContext.js +2 -6
  9. package/cjs/date/context/useSharedMonthContext.js.map +1 -1
  10. package/cjs/date/datepicker/DatePicker.js +3 -5
  11. package/cjs/date/datepicker/DatePicker.js.map +1 -1
  12. package/cjs/date/datepicker/DatePickerStandalone.js +3 -5
  13. package/cjs/date/datepicker/DatePickerStandalone.js.map +1 -1
  14. package/cjs/date/datepicker/parts/DayButton.js +2 -5
  15. package/cjs/date/datepicker/parts/DayButton.js.map +1 -1
  16. package/cjs/date/datepicker/parts/DropdownCaption.js +3 -6
  17. package/cjs/date/datepicker/parts/DropdownCaption.js.map +1 -1
  18. package/cjs/date/datepicker/parts/Row.js +2 -1
  19. package/cjs/date/datepicker/parts/Row.js.map +1 -1
  20. package/cjs/date/hooks/useDatepicker.d.ts +1 -6
  21. package/cjs/date/hooks/useDatepicker.js +7 -11
  22. package/cjs/date/hooks/useDatepicker.js.map +1 -1
  23. package/cjs/date/hooks/useMonthPicker.d.ts +1 -6
  24. package/cjs/date/hooks/useMonthPicker.js.map +1 -1
  25. package/cjs/date/hooks/useRangeDatepicker.js +20 -25
  26. package/cjs/date/hooks/useRangeDatepicker.js.map +1 -1
  27. package/cjs/date/monthpicker/MonthButton.js +11 -15
  28. package/cjs/date/monthpicker/MonthButton.js.map +1 -1
  29. package/cjs/date/monthpicker/MonthCaption.js +4 -7
  30. package/cjs/date/monthpicker/MonthCaption.js.map +1 -1
  31. package/cjs/date/monthpicker/MonthPicker.js +7 -1
  32. package/cjs/date/monthpicker/MonthPicker.js.map +1 -1
  33. package/cjs/date/monthpicker/MonthPickerStandalone.js +7 -1
  34. package/cjs/date/monthpicker/MonthPickerStandalone.js.map +1 -1
  35. package/cjs/date/monthpicker/MonthSelector.js +8 -11
  36. package/cjs/date/monthpicker/MonthSelector.js.map +1 -1
  37. package/cjs/date/parts/DateInput.d.ts +1 -1
  38. package/cjs/date/utils/check-dates.js +2 -6
  39. package/cjs/date/utils/check-dates.js.map +1 -1
  40. package/cjs/date/utils/dates-disabled.js +3 -6
  41. package/cjs/date/utils/dates-disabled.js.map +1 -1
  42. package/cjs/date/utils/format-date.d.ts +1 -0
  43. package/cjs/date/utils/format-date.js +2 -5
  44. package/cjs/date/utils/format-date.js.map +1 -1
  45. package/cjs/date/utils/get-dates.js +14 -21
  46. package/cjs/date/utils/get-dates.js.map +1 -1
  47. package/cjs/date/utils/get-initial-year.js +2 -5
  48. package/cjs/date/utils/get-initial-year.js.map +1 -1
  49. package/cjs/date/utils/is-match.js +14 -20
  50. package/cjs/date/utils/is-match.js.map +1 -1
  51. package/cjs/date/utils/labels.d.ts +1 -0
  52. package/cjs/date/utils/labels.js.map +1 -1
  53. package/cjs/date/utils/locale.d.ts +1 -1
  54. package/cjs/date/utils/locale.js +4 -9
  55. package/cjs/date/utils/locale.js.map +1 -1
  56. package/cjs/date/utils/navigation.js +21 -24
  57. package/cjs/date/utils/navigation.js.map +1 -1
  58. package/cjs/date/utils/parse-date.d.ts +1 -0
  59. package/cjs/date/utils/parse-date.js +8 -13
  60. package/cjs/date/utils/parse-date.js.map +1 -1
  61. package/cjs/form/Textarea.js +8 -8
  62. package/cjs/form/Textarea.js.map +1 -1
  63. package/cjs/form/combobox/Combobox.js +1 -1
  64. package/cjs/form/combobox/Combobox.js.map +1 -1
  65. package/cjs/form/combobox/ComboboxProvider.js +2 -1
  66. package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
  67. package/cjs/form/combobox/ComboboxWrapper.js +1 -1
  68. package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
  69. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +59 -41
  70. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  71. package/cjs/form/combobox/FilteredOptions/filtered-options-util.d.ts +2 -1
  72. package/cjs/form/combobox/FilteredOptions/filtered-options-util.js +3 -1
  73. package/cjs/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
  74. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +15 -3
  75. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  76. package/cjs/form/combobox/FilteredOptions/useVirtualFocus.d.ts +2 -4
  77. package/cjs/form/combobox/FilteredOptions/useVirtualFocus.js +52 -32
  78. package/cjs/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
  79. package/cjs/form/combobox/Input/Input.js +3 -1
  80. package/cjs/form/combobox/Input/Input.js.map +1 -1
  81. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +5 -2
  82. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +3 -1
  83. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  84. package/cjs/form/combobox/types.d.ts +14 -0
  85. package/cjs/form/error-summary/ErrorSummary.d.ts +9 -3
  86. package/cjs/form/error-summary/ErrorSummary.js +4 -9
  87. package/cjs/form/error-summary/ErrorSummary.js.map +1 -1
  88. package/cjs/form/error-summary/ErrorSummaryItem.d.ts +1 -1
  89. package/cjs/form/error-summary/ErrorSummaryItem.js +2 -1
  90. package/cjs/form/error-summary/ErrorSummaryItem.js.map +1 -1
  91. package/cjs/form/search/Search.d.ts +1 -0
  92. package/cjs/form/search/Search.js +2 -2
  93. package/cjs/form/search/Search.js.map +1 -1
  94. package/cjs/index.d.ts +1 -2
  95. package/cjs/index.js +1 -3
  96. package/cjs/index.js.map +1 -1
  97. package/cjs/layout/bleed/Bleed.d.ts +2 -2
  98. package/cjs/layout/utilities/css.js +4 -0
  99. package/cjs/layout/utilities/css.js.map +1 -1
  100. package/cjs/layout/utilities/types.d.ts +1 -1
  101. package/cjs/overlays/index.d.ts +2 -0
  102. package/cjs/overlays/index.js +6 -0
  103. package/cjs/overlays/index.js.map +1 -0
  104. package/cjs/overlays/portal/Portal.d.ts +11 -0
  105. package/cjs/{grid/Grid.js → overlays/portal/Portal.js} +15 -11
  106. package/cjs/overlays/portal/Portal.js.map +1 -0
  107. package/cjs/tabs/TabList.js +2 -2
  108. package/cjs/tabs/TabList.js.map +1 -1
  109. package/cjs/tabs/TabPanel.js +2 -2
  110. package/cjs/tabs/TabPanel.js.map +1 -1
  111. package/cjs/timeline/AxisLabels.js +4 -4
  112. package/cjs/timeline/AxisLabels.js.map +1 -1
  113. package/cjs/tooltip/Tooltip.js +3 -7
  114. package/cjs/tooltip/Tooltip.js.map +1 -1
  115. package/cjs/util/Slot.js +5 -2
  116. package/cjs/util/Slot.js.map +1 -1
  117. package/cjs/util/TextareaAutoSize.js +14 -24
  118. package/cjs/util/TextareaAutoSize.js.map +1 -1
  119. package/cjs/util/types/AsChildProps.d.ts +36 -0
  120. package/cjs/util/types/AsChildProps.js +3 -0
  121. package/cjs/util/types/AsChildProps.js.map +1 -0
  122. package/cjs/util/types/index.d.ts +1 -0
  123. package/esm/accordion/Accordion.d.ts +3 -3
  124. package/esm/accordion/Accordion.js +4 -4
  125. package/esm/accordion/AccordionContent.js +2 -2
  126. package/esm/accordion/AccordionHeader.js +4 -4
  127. package/esm/accordion/AccordionItem.js +3 -3
  128. package/esm/accordion/index.d.ts +1 -1
  129. package/esm/accordion/index.js +1 -1
  130. package/esm/alert/Alert.js +2 -2
  131. package/esm/alert/index.d.ts +2 -2
  132. package/esm/alert/index.js +1 -1
  133. package/esm/button/Button.d.ts +1 -1
  134. package/esm/button/Button.js +6 -6
  135. package/esm/button/index.d.ts +2 -2
  136. package/esm/button/index.js +1 -1
  137. package/esm/chat/Bubble.d.ts +0 -5
  138. package/esm/chat/Bubble.js +3 -3
  139. package/esm/chat/Bubble.js.map +1 -1
  140. package/esm/chat/Chat.d.ts +1 -11
  141. package/esm/chat/Chat.js +5 -5
  142. package/esm/chat/Chat.js.map +1 -1
  143. package/esm/chat/index.d.ts +1 -1
  144. package/esm/chat/index.js +1 -1
  145. package/esm/chips/Chips.d.ts +3 -3
  146. package/esm/chips/Chips.js +2 -2
  147. package/esm/chips/Removable.js +1 -1
  148. package/esm/chips/Toggle.d.ts +1 -1
  149. package/esm/chips/index.d.ts +1 -1
  150. package/esm/chips/index.js +1 -1
  151. package/esm/copybutton/CopyButton.js +3 -3
  152. package/esm/copybutton/index.d.ts +1 -1
  153. package/esm/copybutton/index.js +1 -1
  154. package/esm/date/context/index.d.ts +2 -2
  155. package/esm/date/context/index.js +2 -2
  156. package/esm/date/context/useSharedMonthContext.d.ts +1 -1
  157. package/esm/date/context/useSharedMonthContext.js +2 -3
  158. package/esm/date/context/useSharedMonthContext.js.map +1 -1
  159. package/esm/date/datepicker/DatePicker.d.ts +3 -3
  160. package/esm/date/datepicker/DatePicker.js +15 -17
  161. package/esm/date/datepicker/DatePicker.js.map +1 -1
  162. package/esm/date/datepicker/DatePickerStandalone.d.ts +1 -1
  163. package/esm/date/datepicker/DatePickerStandalone.js +9 -11
  164. package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
  165. package/esm/date/datepicker/parts/Caption.js +3 -3
  166. package/esm/date/datepicker/parts/DayButton.js +1 -1
  167. package/esm/date/datepicker/parts/DayButton.js.map +1 -1
  168. package/esm/date/datepicker/parts/DropdownCaption.js +6 -9
  169. package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
  170. package/esm/date/datepicker/parts/HeadRow.js +1 -1
  171. package/esm/date/datepicker/parts/Row.js +5 -4
  172. package/esm/date/datepicker/parts/Row.js.map +1 -1
  173. package/esm/date/datepicker/parts/WeekNumber.js +1 -1
  174. package/esm/date/datepicker/parts/WeekRow.js +6 -6
  175. package/esm/date/hooks/index.d.ts +6 -6
  176. package/esm/date/hooks/index.js +3 -3
  177. package/esm/date/hooks/useDatepicker.d.ts +3 -8
  178. package/esm/date/hooks/useDatepicker.js +2 -3
  179. package/esm/date/hooks/useDatepicker.js.map +1 -1
  180. package/esm/date/hooks/useMonthPicker.d.ts +3 -8
  181. package/esm/date/hooks/useMonthPicker.js +1 -1
  182. package/esm/date/hooks/useMonthPicker.js.map +1 -1
  183. package/esm/date/hooks/useRangeDatepicker.d.ts +3 -3
  184. package/esm/date/hooks/useRangeDatepicker.js +2 -4
  185. package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
  186. package/esm/date/index.d.ts +7 -7
  187. package/esm/date/index.js +3 -3
  188. package/esm/date/monthpicker/MonthButton.js +3 -7
  189. package/esm/date/monthpicker/MonthButton.js.map +1 -1
  190. package/esm/date/monthpicker/MonthCaption.js +5 -8
  191. package/esm/date/monthpicker/MonthCaption.js.map +1 -1
  192. package/esm/date/monthpicker/MonthPicker.d.ts +3 -3
  193. package/esm/date/monthpicker/MonthPicker.js +17 -11
  194. package/esm/date/monthpicker/MonthPicker.js.map +1 -1
  195. package/esm/date/monthpicker/MonthPickerStandalone.d.ts +1 -1
  196. package/esm/date/monthpicker/MonthPickerStandalone.js +12 -6
  197. package/esm/date/monthpicker/MonthPickerStandalone.js.map +1 -1
  198. package/esm/date/monthpicker/MonthSelector.js +5 -8
  199. package/esm/date/monthpicker/MonthSelector.js.map +1 -1
  200. package/esm/date/monthpicker/types.d.ts +1 -1
  201. package/esm/date/parts/DateInput.d.ts +2 -2
  202. package/esm/date/parts/DateInput.js +5 -5
  203. package/esm/date/parts/DateWrapper.js +6 -6
  204. package/esm/date/utils/check-dates.js +1 -2
  205. package/esm/date/utils/check-dates.js.map +1 -1
  206. package/esm/date/utils/dates-disabled.js +1 -1
  207. package/esm/date/utils/dates-disabled.js.map +1 -1
  208. package/esm/date/utils/format-date.d.ts +1 -0
  209. package/esm/date/utils/format-date.js +2 -2
  210. package/esm/date/utils/format-date.js.map +1 -1
  211. package/esm/date/utils/get-dates.js +1 -5
  212. package/esm/date/utils/get-dates.js.map +1 -1
  213. package/esm/date/utils/get-initial-year.js +1 -1
  214. package/esm/date/utils/get-initial-year.js.map +1 -1
  215. package/esm/date/utils/index.d.ts +10 -10
  216. package/esm/date/utils/index.js +10 -10
  217. package/esm/date/utils/is-match.js +1 -4
  218. package/esm/date/utils/is-match.js.map +1 -1
  219. package/esm/date/utils/labels.d.ts +1 -0
  220. package/esm/date/utils/labels.js.map +1 -1
  221. package/esm/date/utils/locale.d.ts +1 -1
  222. package/esm/date/utils/locale.js +1 -3
  223. package/esm/date/utils/locale.js.map +1 -1
  224. package/esm/date/utils/navigation.d.ts +1 -1
  225. package/esm/date/utils/navigation.js +2 -2
  226. package/esm/date/utils/navigation.js.map +1 -1
  227. package/esm/date/utils/parse-date.d.ts +1 -0
  228. package/esm/date/utils/parse-date.js +2 -4
  229. package/esm/date/utils/parse-date.js.map +1 -1
  230. package/esm/dropdown/Dropdown.d.ts +2 -2
  231. package/esm/dropdown/Dropdown.js +4 -4
  232. package/esm/dropdown/Menu/GroupedList/GroupedItem.d.ts +1 -1
  233. package/esm/dropdown/Menu/GroupedList/GroupedItem.js +2 -2
  234. package/esm/dropdown/Menu/GroupedList/index.d.ts +3 -3
  235. package/esm/dropdown/Menu/GroupedList/index.js +2 -2
  236. package/esm/dropdown/Menu/List/Item.d.ts +1 -1
  237. package/esm/dropdown/Menu/List/Item.js +2 -2
  238. package/esm/dropdown/Menu/List/index.d.ts +2 -2
  239. package/esm/dropdown/Menu/List/index.js +1 -1
  240. package/esm/dropdown/Menu/index.d.ts +2 -2
  241. package/esm/dropdown/Menu/index.js +5 -5
  242. package/esm/dropdown/Toggle.js +2 -2
  243. package/esm/dropdown/index.d.ts +1 -1
  244. package/esm/dropdown/index.js +1 -1
  245. package/esm/expansion-card/ExpansionCard.d.ts +5 -5
  246. package/esm/expansion-card/ExpansionCard.js +5 -5
  247. package/esm/expansion-card/ExpansionCardContent.js +2 -2
  248. package/esm/expansion-card/ExpansionCardDescription.js +2 -2
  249. package/esm/expansion-card/ExpansionCardHeader.js +1 -1
  250. package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
  251. package/esm/expansion-card/index.d.ts +1 -1
  252. package/esm/expansion-card/index.js +1 -1
  253. package/esm/form/ConfirmationPanel.d.ts +1 -1
  254. package/esm/form/ConfirmationPanel.js +4 -4
  255. package/esm/form/Fieldset/Fieldset.d.ts +1 -1
  256. package/esm/form/Fieldset/Fieldset.js +5 -5
  257. package/esm/form/Fieldset/index.d.ts +2 -2
  258. package/esm/form/Fieldset/index.js +2 -2
  259. package/esm/form/Fieldset/useFieldset.js +1 -1
  260. package/esm/form/Select.d.ts +1 -1
  261. package/esm/form/Select.js +4 -4
  262. package/esm/form/Switch.d.ts +1 -1
  263. package/esm/form/Switch.js +5 -5
  264. package/esm/form/TextField.d.ts +1 -1
  265. package/esm/form/TextField.js +4 -4
  266. package/esm/form/Textarea.d.ts +1 -1
  267. package/esm/form/Textarea.js +15 -15
  268. package/esm/form/Textarea.js.map +1 -1
  269. package/esm/form/TextareaCounter.d.ts +1 -1
  270. package/esm/form/TextareaCounter.js +2 -2
  271. package/esm/form/checkbox/Checkbox.d.ts +1 -1
  272. package/esm/form/checkbox/Checkbox.js +5 -5
  273. package/esm/form/checkbox/CheckboxGroup.d.ts +1 -1
  274. package/esm/form/checkbox/CheckboxGroup.js +1 -1
  275. package/esm/form/checkbox/index.d.ts +3 -3
  276. package/esm/form/checkbox/index.js +2 -2
  277. package/esm/form/checkbox/types.d.ts +1 -1
  278. package/esm/form/checkbox/useCheckbox.d.ts +1 -1
  279. package/esm/form/checkbox/useCheckbox.js +3 -3
  280. package/esm/form/combobox/Combobox.d.ts +1 -1
  281. package/esm/form/combobox/Combobox.js +12 -12
  282. package/esm/form/combobox/Combobox.js.map +1 -1
  283. package/esm/form/combobox/ComboboxProvider.d.ts +1 -1
  284. package/esm/form/combobox/ComboboxProvider.js +7 -6
  285. package/esm/form/combobox/ComboboxProvider.js.map +1 -1
  286. package/esm/form/combobox/ComboboxWrapper.js +1 -1
  287. package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
  288. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +65 -47
  289. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  290. package/esm/form/combobox/FilteredOptions/filtered-options-util.d.ts +2 -1
  291. package/esm/form/combobox/FilteredOptions/filtered-options-util.js +3 -1
  292. package/esm/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
  293. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +2 -2
  294. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +20 -8
  295. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  296. package/esm/form/combobox/FilteredOptions/useVirtualFocus.d.ts +2 -4
  297. package/esm/form/combobox/FilteredOptions/useVirtualFocus.js +52 -32
  298. package/esm/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
  299. package/esm/form/combobox/Input/Input.js +8 -6
  300. package/esm/form/combobox/Input/Input.js.map +1 -1
  301. package/esm/form/combobox/Input/inputContext.d.ts +1 -1
  302. package/esm/form/combobox/Input/inputContext.js +2 -2
  303. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +3 -3
  304. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +5 -2
  305. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +6 -4
  306. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  307. package/esm/form/combobox/ToggleListButton.js +1 -1
  308. package/esm/form/combobox/customOptionsContext.js +1 -1
  309. package/esm/form/combobox/index.d.ts +2 -2
  310. package/esm/form/combobox/index.js +1 -1
  311. package/esm/form/combobox/types.d.ts +15 -1
  312. package/esm/form/error-summary/ErrorSummary.d.ts +9 -3
  313. package/esm/form/error-summary/ErrorSummary.js +8 -13
  314. package/esm/form/error-summary/ErrorSummary.js.map +1 -1
  315. package/esm/form/error-summary/ErrorSummaryItem.d.ts +2 -2
  316. package/esm/form/error-summary/ErrorSummaryItem.js +2 -1
  317. package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
  318. package/esm/form/error-summary/index.d.ts +2 -2
  319. package/esm/form/error-summary/index.js +1 -1
  320. package/esm/form/index.d.ts +11 -11
  321. package/esm/form/index.js +11 -11
  322. package/esm/form/radio/Radio.d.ts +1 -1
  323. package/esm/form/radio/Radio.js +4 -4
  324. package/esm/form/radio/RadioGroup.d.ts +1 -1
  325. package/esm/form/radio/RadioGroup.js +2 -2
  326. package/esm/form/radio/index.d.ts +3 -3
  327. package/esm/form/radio/index.js +2 -2
  328. package/esm/form/radio/types.d.ts +1 -1
  329. package/esm/form/radio/useRadio.d.ts +1 -1
  330. package/esm/form/radio/useRadio.js +3 -3
  331. package/esm/form/search/Search.d.ts +3 -2
  332. package/esm/form/search/Search.js +8 -8
  333. package/esm/form/search/Search.js.map +1 -1
  334. package/esm/form/search/SearchButton.d.ts +1 -1
  335. package/esm/form/search/SearchButton.js +3 -3
  336. package/esm/form/search/index.d.ts +1 -1
  337. package/esm/form/search/index.js +1 -1
  338. package/esm/form/useFormField.js +2 -2
  339. package/esm/guide-panel/GuidePanel.js +1 -1
  340. package/esm/guide-panel/Illustration.js +1 -1
  341. package/esm/guide-panel/index.d.ts +2 -2
  342. package/esm/guide-panel/index.js +2 -2
  343. package/esm/help-text/HelpText.d.ts +1 -1
  344. package/esm/help-text/HelpText.js +4 -4
  345. package/esm/help-text/HelpTextIcon.js +1 -1
  346. package/esm/help-text/index.d.ts +2 -2
  347. package/esm/help-text/index.js +1 -1
  348. package/esm/index.d.ts +40 -41
  349. package/esm/index.js +40 -42
  350. package/esm/index.js.map +1 -1
  351. package/esm/internal-header/InternalHeader.d.ts +5 -5
  352. package/esm/internal-header/InternalHeader.js +4 -4
  353. package/esm/internal-header/InternalHeaderButton.d.ts +1 -1
  354. package/esm/internal-header/InternalHeaderTitle.d.ts +1 -1
  355. package/esm/internal-header/InternalHeaderUser.js +1 -1
  356. package/esm/internal-header/InternalHeaderUserButton.d.ts +1 -1
  357. package/esm/internal-header/InternalHeaderUserButton.js +2 -2
  358. package/esm/internal-header/index.d.ts +5 -5
  359. package/esm/internal-header/index.js +1 -1
  360. package/esm/layout/bleed/Bleed.d.ts +3 -3
  361. package/esm/layout/bleed/Bleed.js +2 -2
  362. package/esm/layout/bleed/index.d.ts +1 -1
  363. package/esm/layout/bleed/index.js +1 -1
  364. package/esm/layout/box/Box.d.ts +2 -2
  365. package/esm/layout/box/Box.js +1 -1
  366. package/esm/layout/box/index.d.ts +1 -1
  367. package/esm/layout/box/index.js +1 -1
  368. package/esm/layout/grid/HGrid.d.ts +1 -1
  369. package/esm/layout/grid/HGrid.js +1 -1
  370. package/esm/layout/grid/index.d.ts +1 -1
  371. package/esm/layout/grid/index.js +1 -1
  372. package/esm/layout/page/Page.d.ts +2 -2
  373. package/esm/layout/page/Page.js +1 -1
  374. package/esm/layout/page/index.d.ts +2 -2
  375. package/esm/layout/page/index.js +1 -1
  376. package/esm/layout/page/parts/PageBlock.d.ts +1 -1
  377. package/esm/layout/responsive/Responsive.d.ts +1 -1
  378. package/esm/layout/responsive/Responsive.js +1 -1
  379. package/esm/layout/responsive/index.d.ts +1 -1
  380. package/esm/layout/responsive/index.js +1 -1
  381. package/esm/layout/sidemal-test/AvatarPanel.js +2 -2
  382. package/esm/layout/sidemal-test/Content.js +9 -9
  383. package/esm/layout/sidemal-test/Filter.js +4 -4
  384. package/esm/layout/sidemal-test/Header.js +5 -5
  385. package/esm/layout/sidemal-test/Intro.js +4 -4
  386. package/esm/layout/sidemal-test/Sidebar.js +4 -4
  387. package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +1 -1
  388. package/esm/layout/sidemal-test/content-box/index.d.ts +1 -1
  389. package/esm/layout/sidemal-test/content-box/index.js +1 -1
  390. package/esm/layout/stack/HStack.d.ts +2 -2
  391. package/esm/layout/stack/HStack.js +1 -1
  392. package/esm/layout/stack/Stack.d.ts +2 -2
  393. package/esm/layout/stack/Stack.js +1 -1
  394. package/esm/layout/stack/VStack.d.ts +2 -2
  395. package/esm/layout/stack/VStack.js +1 -1
  396. package/esm/layout/stack/index.d.ts +4 -4
  397. package/esm/layout/stack/index.js +4 -4
  398. package/esm/layout/utilities/css.d.ts +1 -1
  399. package/esm/layout/utilities/css.js +4 -0
  400. package/esm/layout/utilities/css.js.map +1 -1
  401. package/esm/layout/utilities/types.d.ts +1 -1
  402. package/esm/link/Link.d.ts +1 -1
  403. package/esm/link/index.d.ts +2 -2
  404. package/esm/link/index.js +1 -1
  405. package/esm/link-panel/LinkPanel.d.ts +3 -3
  406. package/esm/link-panel/LinkPanel.js +3 -3
  407. package/esm/link-panel/LinkPanelDescription.js +1 -1
  408. package/esm/link-panel/LinkPanelTitle.d.ts +1 -1
  409. package/esm/link-panel/index.d.ts +2 -2
  410. package/esm/link-panel/index.js +1 -1
  411. package/esm/list/List.d.ts +2 -2
  412. package/esm/list/List.js +4 -4
  413. package/esm/list/ListItem.js +2 -2
  414. package/esm/list/context.d.ts +1 -1
  415. package/esm/list/index.d.ts +2 -2
  416. package/esm/list/index.js +1 -1
  417. package/esm/loader/Loader.js +2 -2
  418. package/esm/loader/index.d.ts +2 -2
  419. package/esm/loader/index.js +1 -1
  420. package/esm/modal/Modal.d.ts +4 -4
  421. package/esm/modal/Modal.js +12 -12
  422. package/esm/modal/ModalHeader.js +2 -2
  423. package/esm/modal/ModalUtils.d.ts +1 -1
  424. package/esm/modal/index.d.ts +5 -5
  425. package/esm/modal/index.js +1 -1
  426. package/esm/overlays/index.d.ts +2 -0
  427. package/esm/overlays/index.js +2 -0
  428. package/esm/overlays/index.js.map +1 -0
  429. package/esm/overlays/portal/Portal.d.ts +11 -0
  430. package/esm/overlays/portal/Portal.js +27 -0
  431. package/esm/overlays/portal/Portal.js.map +1 -0
  432. package/esm/package.json +1 -1
  433. package/esm/pagination/Pagination.d.ts +1 -1
  434. package/esm/pagination/Pagination.js +2 -2
  435. package/esm/pagination/PaginationItem.d.ts +2 -2
  436. package/esm/pagination/PaginationItem.js +1 -1
  437. package/esm/pagination/index.d.ts +1 -1
  438. package/esm/pagination/index.js +1 -1
  439. package/esm/panel/Panel.d.ts +1 -1
  440. package/esm/panel/index.d.ts +2 -2
  441. package/esm/panel/index.js +1 -1
  442. package/esm/popover/Popover.d.ts +1 -1
  443. package/esm/popover/Popover.js +5 -5
  444. package/esm/popover/index.d.ts +2 -2
  445. package/esm/popover/index.js +1 -1
  446. package/esm/provider/index.d.ts +1 -1
  447. package/esm/provider/index.js +1 -1
  448. package/esm/read-more/ReadMore.js +3 -3
  449. package/esm/read-more/index.d.ts +2 -2
  450. package/esm/read-more/index.js +1 -1
  451. package/esm/skeleton/index.d.ts +2 -2
  452. package/esm/skeleton/index.js +1 -1
  453. package/esm/stepper/Step.d.ts +1 -1
  454. package/esm/stepper/Step.js +3 -3
  455. package/esm/stepper/Stepper.d.ts +1 -1
  456. package/esm/stepper/Stepper.js +2 -2
  457. package/esm/stepper/index.d.ts +1 -1
  458. package/esm/stepper/index.js +1 -1
  459. package/esm/table/ColumnHeader.d.ts +1 -1
  460. package/esm/table/ColumnHeader.js +2 -2
  461. package/esm/table/DataCell.js +1 -1
  462. package/esm/table/ExpandableRow.d.ts +1 -1
  463. package/esm/table/ExpandableRow.js +6 -6
  464. package/esm/table/Table.d.ts +8 -8
  465. package/esm/table/Table.js +8 -8
  466. package/esm/table/context.d.ts +1 -1
  467. package/esm/table/index.d.ts +9 -9
  468. package/esm/table/index.js +1 -1
  469. package/esm/tabs/Tab.d.ts +1 -1
  470. package/esm/tabs/Tab.js +2 -2
  471. package/esm/tabs/TabList.js +5 -5
  472. package/esm/tabs/TabList.js.map +1 -1
  473. package/esm/tabs/TabPanel.js +2 -2
  474. package/esm/tabs/TabPanel.js.map +1 -1
  475. package/esm/tabs/Tabs.d.ts +4 -4
  476. package/esm/tabs/Tabs.js +4 -4
  477. package/esm/tabs/index.d.ts +4 -4
  478. package/esm/tabs/index.js +1 -1
  479. package/esm/tag/Tag.js +1 -1
  480. package/esm/tag/index.d.ts +1 -1
  481. package/esm/tag/index.js +1 -1
  482. package/esm/timeline/AxisLabels.d.ts +1 -1
  483. package/esm/timeline/AxisLabels.js +5 -5
  484. package/esm/timeline/AxisLabels.js.map +1 -1
  485. package/esm/timeline/Pin.d.ts +1 -1
  486. package/esm/timeline/Pin.js +3 -3
  487. package/esm/timeline/Timeline.d.ts +5 -5
  488. package/esm/timeline/Timeline.js +9 -9
  489. package/esm/timeline/TimelineRow.d.ts +1 -1
  490. package/esm/timeline/TimelineRow.js +5 -5
  491. package/esm/timeline/hooks/useRowContext.d.ts +1 -1
  492. package/esm/timeline/hooks/useTimelineRows.d.ts +1 -1
  493. package/esm/timeline/hooks/useTimelineRows.js +3 -3
  494. package/esm/timeline/index.d.ts +6 -6
  495. package/esm/timeline/index.js +1 -1
  496. package/esm/timeline/period/ClickablePeriod.d.ts +1 -1
  497. package/esm/timeline/period/ClickablePeriod.js +5 -5
  498. package/esm/timeline/period/NonClickablePeriod.d.ts +1 -1
  499. package/esm/timeline/period/NonClickablePeriod.js +1 -1
  500. package/esm/timeline/period/index.d.ts +1 -1
  501. package/esm/timeline/period/index.js +4 -4
  502. package/esm/timeline/utils/filter.d.ts +1 -1
  503. package/esm/timeline/utils/index.d.ts +1 -1
  504. package/esm/timeline/utils/index.js +1 -1
  505. package/esm/timeline/utils/sort.d.ts +1 -1
  506. package/esm/timeline/utils/timeline.d.ts +1 -1
  507. package/esm/timeline/utils/timeline.js +1 -1
  508. package/esm/timeline/zoom/ZoomButton.js +2 -2
  509. package/esm/timeline/zoom/index.d.ts +1 -1
  510. package/esm/timeline/zoom/index.js +1 -1
  511. package/esm/toggle-group/ToggleGroup.d.ts +1 -1
  512. package/esm/toggle-group/ToggleGroup.js +4 -4
  513. package/esm/toggle-group/ToggleItem.js +2 -2
  514. package/esm/toggle-group/index.d.ts +2 -2
  515. package/esm/toggle-group/index.js +1 -1
  516. package/esm/tooltip/Tooltip.js +9 -13
  517. package/esm/tooltip/Tooltip.js.map +1 -1
  518. package/esm/tooltip/index.d.ts +1 -1
  519. package/esm/tooltip/index.js +1 -1
  520. package/esm/typography/BodyLong.d.ts +2 -2
  521. package/esm/typography/BodyLong.js +1 -1
  522. package/esm/typography/BodyShort.d.ts +2 -2
  523. package/esm/typography/BodyShort.js +1 -1
  524. package/esm/typography/Detail.d.ts +2 -2
  525. package/esm/typography/Detail.js +1 -1
  526. package/esm/typography/ErrorMessage.d.ts +2 -2
  527. package/esm/typography/ErrorMessage.js +1 -1
  528. package/esm/typography/Heading.d.ts +2 -2
  529. package/esm/typography/Heading.js +1 -1
  530. package/esm/typography/Ingress.d.ts +1 -1
  531. package/esm/typography/Label.d.ts +2 -2
  532. package/esm/typography/Label.js +1 -1
  533. package/esm/typography/index.d.ts +7 -7
  534. package/esm/typography/index.js +7 -7
  535. package/esm/typography/util.d.ts +1 -1
  536. package/esm/util/Slot.js +6 -3
  537. package/esm/util/Slot.js.map +1 -1
  538. package/esm/util/TextareaAutoSize.js +17 -27
  539. package/esm/util/TextareaAutoSize.js.map +1 -1
  540. package/esm/util/hooks/descendants/descendant.js +1 -1
  541. package/esm/util/hooks/descendants/useDescendant.d.ts +1 -1
  542. package/esm/util/hooks/descendants/useDescendant.js +5 -5
  543. package/esm/util/hooks/index.d.ts +8 -8
  544. package/esm/util/hooks/index.js +8 -8
  545. package/esm/util/hooks/useControllableState.js +1 -1
  546. package/esm/util/index.d.ts +6 -6
  547. package/esm/util/index.js +5 -5
  548. package/esm/util/types/AsChildProps.d.ts +36 -0
  549. package/esm/util/types/AsChildProps.js +2 -0
  550. package/esm/util/types/AsChildProps.js.map +1 -0
  551. package/esm/util/types/index.d.ts +2 -1
  552. package/package.json +13 -12
  553. package/src/alert/alert.stories.tsx +202 -113
  554. package/src/chat/Bubble.tsx +2 -23
  555. package/src/chat/Chat.tsx +1 -18
  556. package/src/chat/chat.stories.tsx +0 -31
  557. package/src/date/context/useSharedMonthContext.tsx +1 -2
  558. package/src/date/datepicker/DatePicker.tsx +1 -3
  559. package/src/date/datepicker/DatePickerStandalone.tsx +1 -3
  560. package/src/date/datepicker/datepicker.stories.tsx +5 -5
  561. package/src/date/datepicker/parts/DayButton.tsx +1 -1
  562. package/src/date/datepicker/parts/DropdownCaption.tsx +1 -4
  563. package/src/date/datepicker/parts/Row.tsx +3 -2
  564. package/src/date/hooks/useDatepicker.tsx +2 -8
  565. package/src/date/hooks/useMonthPicker.tsx +1 -6
  566. package/src/date/hooks/useRangeDatepicker.tsx +5 -3
  567. package/src/date/monthpicker/MonthButton.tsx +7 -5
  568. package/src/date/monthpicker/MonthCaption.tsx +7 -4
  569. package/src/date/monthpicker/MonthPicker.tsx +10 -8
  570. package/src/date/monthpicker/MonthPickerStandalone.tsx +10 -8
  571. package/src/date/monthpicker/MonthSelector.tsx +1 -4
  572. package/src/date/monthpicker/monthpicker.stories.tsx +3 -2
  573. package/src/date/parts/DateInput.tsx +1 -1
  574. package/src/date/utils/__tests__/format-dates.test.ts +1 -1
  575. package/src/date/utils/__tests__/get-initial-year.test.ts +1 -1
  576. package/src/date/utils/__tests__/parse-dates.test.ts +2 -2
  577. package/src/date/utils/check-dates.ts +1 -2
  578. package/src/date/utils/dates-disabled.ts +1 -1
  579. package/src/date/utils/format-date.ts +1 -1
  580. package/src/date/utils/get-dates.ts +7 -5
  581. package/src/date/utils/get-initial-year.ts +1 -1
  582. package/src/date/utils/is-match.ts +6 -4
  583. package/src/date/utils/labels.ts +1 -0
  584. package/src/date/utils/locale.ts +1 -3
  585. package/src/date/utils/navigation.ts +1 -1
  586. package/src/date/utils/parse-date.ts +1 -3
  587. package/src/form/Textarea.tsx +34 -34
  588. package/src/form/combobox/Combobox.tsx +1 -1
  589. package/src/form/combobox/ComboboxProvider.tsx +2 -0
  590. package/src/form/combobox/ComboboxWrapper.tsx +0 -1
  591. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +131 -92
  592. package/src/form/combobox/FilteredOptions/filtered-options-util.ts +9 -2
  593. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +22 -3
  594. package/src/form/combobox/FilteredOptions/useVirtualFocus.ts +63 -45
  595. package/src/form/combobox/Input/Input.tsx +3 -1
  596. package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +11 -1
  597. package/src/form/combobox/combobox.stories.tsx +36 -1
  598. package/src/form/combobox/combobox.test.tsx +1 -3
  599. package/src/form/combobox/types.ts +15 -0
  600. package/src/form/error-summary/ErrorSummary.tsx +15 -11
  601. package/src/form/error-summary/ErrorSummaryItem.tsx +10 -8
  602. package/src/form/error-summary/error-summary.stories.tsx +55 -1
  603. package/src/form/search/Search.tsx +6 -1
  604. package/src/form/stories/textarea.stories.tsx +37 -0
  605. package/src/index.ts +1 -2
  606. package/src/layout/bleed/Bleed.stories.tsx +13 -0
  607. package/src/layout/bleed/Bleed.tsx +2 -2
  608. package/src/layout/box/Box.stories.tsx +1 -1
  609. package/src/layout/sidemal-test/navno-sidemal.stories.tsx +1 -0
  610. package/src/layout/utilities/css.ts +3 -0
  611. package/src/layout/utilities/types.ts +1 -1
  612. package/src/overlays/index.ts +2 -0
  613. package/src/overlays/portal/Portal.stories.tsx +99 -0
  614. package/src/overlays/portal/Portal.tsx +32 -0
  615. package/src/tabs/TabList.tsx +2 -2
  616. package/src/tabs/TabPanel.tsx +2 -2
  617. package/src/timeline/AxisLabels.tsx +1 -1
  618. package/src/tooltip/Tooltip.tsx +4 -8
  619. package/src/util/Slot.tsx +4 -2
  620. package/src/util/TextareaAutoSize.tsx +16 -31
  621. package/src/util/types/AsChildProps.ts +37 -0
  622. package/src/util/types/index.ts +1 -0
  623. package/cjs/grid/Cell.d.ts +0 -30
  624. package/cjs/grid/Cell.js +0 -52
  625. package/cjs/grid/Cell.js.map +0 -1
  626. package/cjs/grid/Grid.d.ts +0 -13
  627. package/cjs/grid/Grid.js.map +0 -1
  628. package/cjs/grid/index.d.ts +0 -2
  629. package/cjs/grid/index.js +0 -11
  630. package/cjs/grid/index.js.map +0 -1
  631. package/cjs/layout/content-container/ContentContainer.d.ts +0 -9
  632. package/cjs/layout/content-container/ContentContainer.js +0 -48
  633. package/cjs/layout/content-container/ContentContainer.js.map +0 -1
  634. package/cjs/layout/content-container/index.d.ts +0 -1
  635. package/cjs/layout/content-container/index.js +0 -9
  636. package/cjs/layout/content-container/index.js.map +0 -1
  637. package/esm/grid/Cell.d.ts +0 -30
  638. package/esm/grid/Cell.js +0 -23
  639. package/esm/grid/Cell.js.map +0 -1
  640. package/esm/grid/Grid.d.ts +0 -13
  641. package/esm/grid/Grid.js +0 -23
  642. package/esm/grid/Grid.js.map +0 -1
  643. package/esm/grid/index.d.ts +0 -2
  644. package/esm/grid/index.js +0 -3
  645. package/esm/grid/index.js.map +0 -1
  646. package/esm/layout/content-container/ContentContainer.d.ts +0 -9
  647. package/esm/layout/content-container/ContentContainer.js +0 -19
  648. package/esm/layout/content-container/ContentContainer.js.map +0 -1
  649. package/esm/layout/content-container/index.d.ts +0 -1
  650. package/esm/layout/content-container/index.js +0 -2
  651. package/esm/layout/content-container/index.js.map +0 -1
  652. package/src/grid/Cell.tsx +0 -53
  653. package/src/grid/Grid.tsx +0 -23
  654. package/src/grid/grid.stories.tsx +0 -67
  655. package/src/grid/index.ts +0 -2
  656. package/src/layout/content-container/ContentContainer.tsx +0 -22
  657. package/src/layout/content-container/index.ts +0 -4
  658. package/src/layout/sidemal-test/navno-sidemal.stories.mdx +0 -29
@@ -1,8 +1,8 @@
1
1
  import cl from "clsx";
2
- import React, { HTMLAttributes, forwardRef, isValidElement } from "react";
2
+ import React, { HTMLAttributes, forwardRef } from "react";
3
3
  import { BodyShort, Heading } from "../../typography";
4
4
  import { useId } from "../../util/hooks";
5
- import ErrorSummaryItem, { ErrorSummaryItemType } from "./ErrorSummaryItem";
5
+ import ErrorSummaryItem from "./ErrorSummaryItem";
6
6
 
7
7
  export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
8
8
  /**
@@ -17,12 +17,18 @@ export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
17
17
  /**
18
18
  * Heading above links
19
19
  */
20
- heading?: React.ReactNode;
20
+ heading: React.ReactNode;
21
21
  /**
22
22
  * Allows setting a different HTML h-tag
23
23
  * @default "h2"
24
24
  */
25
25
  headingTag?: React.ElementType<any>;
26
+ /**
27
+ * When manually setting focus to `<ErrorSummary />` use the
28
+ * `focusTargetRef`-prop and not ref.
29
+ * This directs focus to heading, improving screen reader experience
30
+ */
31
+ focusTargetRef?: React.RefObject<HTMLElement>;
26
32
  }
27
33
 
28
34
  interface ErrorSummaryComponent
@@ -41,7 +47,7 @@ interface ErrorSummaryComponent
41
47
  * </ErrorSummary.Item>
42
48
  * ```
43
49
  */
44
- Item: ErrorSummaryItemType;
50
+ Item: typeof ErrorSummaryItem;
45
51
  }
46
52
 
47
53
  /**
@@ -70,6 +76,7 @@ export const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(
70
76
  size = "medium",
71
77
  headingTag = "h2",
72
78
  heading,
79
+ focusTargetRef,
73
80
  ...rest
74
81
  },
75
82
  ref,
@@ -85,7 +92,7 @@ export const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(
85
92
  "navds-error-summary",
86
93
  `navds-error-summary--${size}`,
87
94
  )}
88
- tabIndex={-1}
95
+ tabIndex={ref ? -1 : undefined}
89
96
  aria-live="polite"
90
97
  aria-relevant="all"
91
98
  aria-labelledby={headingId}
@@ -95,16 +102,13 @@ export const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(
95
102
  as={headingTag}
96
103
  size="small"
97
104
  id={headingId}
105
+ ref={focusTargetRef}
106
+ tabIndex={focusTargetRef ? -1 : undefined}
98
107
  >
99
108
  {heading}
100
109
  </Heading>
101
110
  <BodyShort as="ul" size={size} className="navds-error-summary__list">
102
- {React.Children.map(children, (child) => {
103
- if (!isValidElement(child)) {
104
- return null;
105
- }
106
- return <li key={child.toString()}>{child}</li>;
107
- })}
111
+ {children}
108
112
  </BodyShort>
109
113
  </section>
110
114
  );
@@ -14,7 +14,7 @@ export interface ErrorSummaryItemProps
14
14
  href?: string;
15
15
  }
16
16
 
17
- export type ErrorSummaryItemType = OverridableComponent<
17
+ type ErrorSummaryItemType = OverridableComponent<
18
18
  ErrorSummaryItemProps,
19
19
  HTMLAnchorElement
20
20
  >;
@@ -22,13 +22,15 @@ export type ErrorSummaryItemType = OverridableComponent<
22
22
  export const ErrorSummaryItem: ErrorSummaryItemType = forwardRef(
23
23
  ({ children, as: Component = "a", className, ...rest }, ref) => {
24
24
  return (
25
- <Component
26
- {...rest}
27
- ref={ref}
28
- className={cl(className, "navds-error-summary__item", "navds-link")}
29
- >
30
- {children}
31
- </Component>
25
+ <li>
26
+ <Component
27
+ {...rest}
28
+ ref={ref}
29
+ className={cl(className, "navds-error-summary__item", "navds-link")}
30
+ >
31
+ {children}
32
+ </Component>
33
+ </li>
32
34
  );
33
35
  },
34
36
  );
@@ -1,5 +1,6 @@
1
1
  import { Meta } from "@storybook/react";
2
- import React from "react";
2
+ import { expect, userEvent, within } from "@storybook/test";
3
+ import React, { useRef } from "react";
3
4
  import { ErrorSummary } from "..";
4
5
 
5
6
  export default {
@@ -43,3 +44,56 @@ export const Small = () => (
43
44
  </ErrorSummary.Item>
44
45
  </ErrorSummary>
45
46
  );
47
+
48
+ export const A11yDemo = {
49
+ render: () => {
50
+ // eslint-disable-next-line react-hooks/rules-of-hooks
51
+ const ref = useRef<HTMLHeadingElement>(null);
52
+ return (
53
+ <div>
54
+ <button onClick={() => ref.current?.focus()}>
55
+ Fokuser Errorsummary på klikk
56
+ </button>
57
+ <ErrorSummary heading="Feiloppsummering tittel" focusTargetRef={ref}>
58
+ <ErrorSummary.Item href="#1">Checkbox må fylles ut</ErrorSummary.Item>
59
+ <ErrorSummary.Item href="#2">
60
+ Tekstfeltet må ha en godkjent e-mail
61
+ </ErrorSummary.Item>
62
+ </ErrorSummary>
63
+ </div>
64
+ );
65
+ },
66
+ };
67
+
68
+ export const FocusDemo = {
69
+ render: () => {
70
+ // eslint-disable-next-line react-hooks/rules-of-hooks
71
+ const ref = useRef<HTMLHeadingElement>(null);
72
+ return (
73
+ <div>
74
+ <button onClick={() => ref.current?.focus()}>Focus summary</button>
75
+ <ErrorSummary heading="Feiloppsummering tittel" focusTargetRef={ref}>
76
+ <ErrorSummary.Item href="#1">Checkbox må fylles ut</ErrorSummary.Item>
77
+ <ErrorSummary.Item href="#2">
78
+ Tekstfeltet må ha en godkjent e-mail
79
+ </ErrorSummary.Item>
80
+ </ErrorSummary>
81
+ </div>
82
+ );
83
+ },
84
+ play: async ({ canvasElement, step }) => {
85
+ const canvas = within(canvasElement);
86
+
87
+ const button = canvas.getByText("Focus summary");
88
+ const heading = canvas.getByText("Feiloppsummering tittel");
89
+
90
+ await step("click button", async () => {
91
+ await userEvent.click(button);
92
+ });
93
+
94
+ expect(heading).toHaveFocus();
95
+ },
96
+ parameters: {
97
+ chromatic: { disableSnapshot: true },
98
+ },
99
+ };
@@ -66,6 +66,10 @@ export interface SearchProps
66
66
  * Exposes the HTML size attribute
67
67
  */
68
68
  htmlSize?: number | string;
69
+ /*
70
+ * Exposes role attribute
71
+ */
72
+ role?: string
69
73
  }
70
74
 
71
75
  interface SearchComponent
@@ -114,6 +118,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
114
118
  onChange,
115
119
  onSearchClick,
116
120
  htmlSize,
121
+ role,
117
122
  ...rest
118
123
  } = props;
119
124
 
@@ -205,7 +210,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
205
210
  value={value ?? internalValue}
206
211
  onChange={(e) => handleChange(e.target.value)}
207
212
  type="search"
208
- role="searchbox"
213
+ role={role ?? 'searchbox'}
209
214
  className={cl(
210
215
  className,
211
216
  "navds-search__input",
@@ -1,6 +1,8 @@
1
1
  import { Meta, StoryFn, StoryObj } from "@storybook/react";
2
+ import { expect, userEvent, within } from "@storybook/test";
2
3
  import React, { useState } from "react";
3
4
  import { Button } from "../../button";
5
+ import { Modal } from "../../modal";
4
6
  import { Textarea } from "../index";
5
7
 
6
8
  const meta: Meta<typeof Textarea> = {
@@ -124,6 +126,24 @@ export const Resize: StoryFn = () => {
124
126
  return <Textarea resize label="Ipsum enim quis culpa" />;
125
127
  };
126
128
 
129
+ export const OnChange: StoryFn = () => {
130
+ return (
131
+ <Textarea
132
+ label="Ipsum enim quis culpa"
133
+ onChange={console.log}
134
+ maxLength={50}
135
+ />
136
+ );
137
+ };
138
+ OnChange.play = async ({ canvasElement }) => {
139
+ const canvas = within(canvasElement);
140
+ const input = canvas.getByLabelText("Ipsum enim quis culpa");
141
+ userEvent.click(input);
142
+ await userEvent.type(input, "Aute fugiat ut culpa");
143
+ const text = canvas.getByText("30 tegn igjen");
144
+ expect(text).toBeVisible();
145
+ };
146
+
127
147
  export const Controlled: StoryFn = () => {
128
148
  const [value, setValue] = useState("");
129
149
  return (
@@ -186,3 +206,20 @@ AutoScrollbar.argTypes = {
186
206
  maxRows: { type: "number" },
187
207
  minRows: { type: "number" },
188
208
  };
209
+
210
+ export const ModalStrictMode: StoryFn<typeof Textarea> = () => {
211
+ // Story added after fixing an issue where TextareaAutoSize would reach max re-renders
212
+ // and set the height to 2px when used in StrictMode in a Modal that is initially open.
213
+ return (
214
+ <React.StrictMode>
215
+ <Modal open>
216
+ <Modal.Body>
217
+ <Textarea label="Har du noen tilbakemeldinger?" />
218
+ </Modal.Body>
219
+ </Modal>
220
+ </React.StrictMode>
221
+ );
222
+ };
223
+ ModalStrictMode.parameters = {
224
+ chromatic: { disable: true }, // Not reproducable in Chromatic
225
+ };
package/src/index.ts CHANGED
@@ -8,8 +8,8 @@ export * from "./date";
8
8
  export * from "./dropdown";
9
9
  export * from "./expansion-card";
10
10
  export * from "./form";
11
- export * from "./grid";
12
11
  export * from "./guide-panel";
12
+ export * from "./overlays";
13
13
  export * from "./help-text";
14
14
  export * from "./internal-header";
15
15
  export * from "./link";
@@ -36,6 +36,5 @@ export * from "./layout/bleed";
36
36
  export * from "./layout/box";
37
37
  export * from "./layout/stack";
38
38
  export * from "./layout/grid";
39
- export * from "./layout/content-container";
40
39
  export * from "./layout/responsive";
41
40
  export * from "./layout/page";
@@ -272,6 +272,19 @@ export const Full = {
272
272
  </Bleed>
273
273
  </Box>
274
274
  </Box>
275
+ <Box
276
+ className="maxWidth"
277
+ background="surface-alt-1-subtle"
278
+ padding="10"
279
+ >
280
+ <Box background="surface-alt-2-subtle" padding="10">
281
+ <Bleed marginInline="full" reflectivePadding asChild>
282
+ <Box background="surface-success-subtle">
283
+ <BodyLong>full + reflectivePadding</BodyLong>
284
+ </Box>
285
+ </Bleed>
286
+ </Box>
287
+ </Box>
275
288
  </VStack>
276
289
  </>
277
290
  ),
@@ -13,7 +13,7 @@ export interface BleedProps extends React.HTMLAttributes<HTMLDivElement> {
13
13
  * @example
14
14
  * marginInline='4'
15
15
  * marginInline='4 5'
16
- * marginInline={{xs: '0 32', sm: '3', md: '4 5', lg: '5', xl: '6'}}
16
+ * marginInline={{xs: '0 32', sm: '3', md: '4 5', lg: '5', xl: '6', "2xl": '12'}}
17
17
  */
18
18
  marginInline?: ResponsiveProp<
19
19
  BleedSpacingInline | `${BleedSpacingInline} ${BleedSpacingInline}`
@@ -23,7 +23,7 @@ export interface BleedProps extends React.HTMLAttributes<HTMLDivElement> {
23
23
  * @example
24
24
  * marginBlock='4'
25
25
  * marginBlock='4 5'
26
- * marginBlock={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
26
+ * marginBlock={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6', "2xl": '12'}}
27
27
  */
28
28
  marginBlock?: ResponsiveProp<
29
29
  BleedSpacingBlock | `${BleedSpacingBlock} ${BleedSpacingBlock}`
@@ -196,7 +196,7 @@ export const PaddingBreakpoints = {
196
196
  render: () => (
197
197
  <div>
198
198
  <Box
199
- padding={{ xs: "2", sm: "3", md: "4", lg: "5", xl: "6" }}
199
+ padding={{ xs: "2", sm: "3", md: "4", lg: "5", xl: "6", "2xl": "8" }}
200
200
  background="surface-neutral"
201
201
  >
202
202
  <Box background="surface-alt-3-subtle">
@@ -13,6 +13,7 @@ const meta = {
13
13
  title: "kitchen sink/navno-sidemal",
14
14
  parameters: {
15
15
  layout: "fullscreen",
16
+ chromatic: { disableSnapshot: true },
16
17
  },
17
18
  } satisfies Meta;
18
19
 
@@ -44,6 +44,9 @@ const translateTokenStringToCSS = (
44
44
  if (componentProp === "margin-inline" && x === "full") {
45
45
  const width = 100 / arr.length;
46
46
  return `calc((100vw - ${width}%)/-2)`;
47
+ } else if (componentProp === "padding-inline" && x === "full") {
48
+ const width = 100 / arr.length;
49
+ return `calc((100vw - ${width}%)/2)`;
47
50
  }
48
51
 
49
52
  let output = `var(--a-${tokenSubgroup}-${x})`;
@@ -14,7 +14,7 @@ export type BorderRadiiToken =
14
14
  | "0";
15
15
  export type ShadowToken = keyof typeof shadows.a.shadow;
16
16
 
17
- export type BreakpointsAlias = "xs" | "sm" | "md" | "lg" | "xl";
17
+ export type BreakpointsAlias = "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
18
18
 
19
19
  export type SpacingScale = keyof (typeof Spacing)["a"]["spacing"];
20
20
 
@@ -0,0 +1,2 @@
1
+ export { Portal } from "./portal/Portal";
2
+ export type { PortalProps } from "./portal/Portal";
@@ -0,0 +1,99 @@
1
+ import React from "react";
2
+ import { Box } from "../../layout/box";
3
+ import { Provider } from "../../provider";
4
+ import { Portal } from "./Portal";
5
+
6
+ export default {
7
+ title: "Utilities/Portal",
8
+ parameters: {
9
+ chromatic: { disable: true },
10
+ },
11
+ };
12
+
13
+ export const Default = () => {
14
+ return (
15
+ <Box background="surface-neutral-subtle" border>
16
+ <h1>In regular DOM tree</h1>
17
+ <p>
18
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Temporibus
19
+ necessitatibus quis esse nesciunt est velit voluptatibus. Distinctio eum
20
+ commodi tempora unde. Nulla vel tempora incidunt? Voluptatem molestias
21
+ impedit commodi. Tenetur!
22
+ </p>
23
+ <Portal>
24
+ <h1>Inside Portal to different DOM tree</h1>
25
+ <p>
26
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Temporibus
27
+ necessitatibus quis esse nesciunt est velit voluptatibus. Distinctio
28
+ eum commodi tempora unde. Nulla vel tempora incidunt? Voluptatem
29
+ molestias impedit commodi. Tenetur!
30
+ </p>
31
+ </Portal>
32
+ </Box>
33
+ );
34
+ };
35
+
36
+ export const CustomPortalRoot = () => {
37
+ const [portalContainer, setPortalContainer] =
38
+ React.useState<HTMLDivElement | null>(null);
39
+
40
+ return (
41
+ <Box background="surface-neutral-subtle">
42
+ <Box background="surface-alt-1-subtle">
43
+ <h1>Tree A</h1>
44
+ <Portal rootElement={portalContainer}>
45
+ <p>This is mounted to Tree B, while created inside Tree A</p>
46
+ </Portal>
47
+ </Box>
48
+ <Box background="surface-alt-3-subtle" ref={setPortalContainer}>
49
+ <h1>Tree B</h1>
50
+ </Box>
51
+ </Box>
52
+ );
53
+ };
54
+
55
+ export const CustomPortalRootFromProvider = () => {
56
+ const [portalContainer, setPortalContainer] =
57
+ React.useState<HTMLDivElement>();
58
+
59
+ return (
60
+ <Provider rootElement={portalContainer}>
61
+ <Box background="surface-neutral-subtle">
62
+ <Box background="surface-alt-1-subtle">
63
+ <h1>Tree A</h1>
64
+ <Portal>
65
+ <p>This is mounted to Tree B, while created inside Tree A</p>
66
+ </Portal>
67
+ </Box>
68
+ <Box background="surface-alt-3-subtle" ref={setPortalContainer}>
69
+ <h1>Tree B</h1>
70
+ </Box>
71
+ </Box>
72
+ </Provider>
73
+ );
74
+ };
75
+
76
+ export const AsChild = () => {
77
+ return (
78
+ <Box background="surface-neutral-subtle" border>
79
+ <h1>In regular DOM tree</h1>
80
+ <p>
81
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Temporibus
82
+ necessitatibus quis esse nesciunt est velit voluptatibus. Distinctio eum
83
+ commodi tempora unde. Nulla vel tempora incidunt? Voluptatem molestias
84
+ impedit commodi. Tenetur!
85
+ </p>
86
+ <Portal asChild>
87
+ <div data-this-is-the-child>
88
+ <h1>Inside Portal to different DOM tree</h1>
89
+ <p>
90
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Temporibus
91
+ necessitatibus quis esse nesciunt est velit voluptatibus. Distinctio
92
+ eum commodi tempora unde. Nulla vel tempora incidunt? Voluptatem
93
+ molestias impedit commodi. Tenetur!
94
+ </p>
95
+ </div>
96
+ </Portal>
97
+ </Box>
98
+ );
99
+ };
@@ -0,0 +1,32 @@
1
+ import React, { HTMLAttributes, forwardRef } from "react";
2
+ import ReactDOM from "react-dom";
3
+ import { useProvider } from "../../provider";
4
+ import { Slot } from "../../util/Slot";
5
+ import { AsChildProps } from "../../util/types";
6
+
7
+ interface PortalBaseProps extends HTMLAttributes<HTMLDivElement> {
8
+ /**
9
+ * An optional container where the portaled content should be appended.
10
+ */
11
+ rootElement?: HTMLElement | null;
12
+ }
13
+
14
+ export type PortalProps = PortalBaseProps & AsChildProps;
15
+
16
+ export const Portal = forwardRef<HTMLDivElement, PortalProps>(
17
+ ({ rootElement, asChild, ...rest }, ref) => {
18
+ const contextRoot = useProvider()?.rootElement;
19
+ const root = rootElement ?? contextRoot ?? globalThis?.document?.body;
20
+
21
+ const Component = asChild ? Slot : "div";
22
+
23
+ return root
24
+ ? ReactDOM.createPortal(
25
+ <Component ref={ref} data-aksel-portal="" {...rest} />,
26
+ root,
27
+ )
28
+ : null;
29
+ },
30
+ );
31
+
32
+ export default Portal;
@@ -1,4 +1,4 @@
1
- import { TabsList } from "@radix-ui/react-tabs";
1
+ import * as RadixTabs from "@radix-ui/react-tabs";
2
2
  import cl from "clsx";
3
3
  import React, {
4
4
  forwardRef,
@@ -112,7 +112,7 @@ export const TabList = forwardRef<HTMLDivElement, TabListProps>(
112
112
  {showSteppers && (
113
113
  <ScrollButton dir={-1} hidden={!displayScroll.start} />
114
114
  )}
115
- <TabsList
115
+ <RadixTabs.TabsList
116
116
  {...rest}
117
117
  ref={mergedRef}
118
118
  onScroll={updateScrollButtonState}
@@ -1,4 +1,4 @@
1
- import { TabsContent } from "@radix-ui/react-tabs";
1
+ import * as RadixTabs from "@radix-ui/react-tabs";
2
2
  import cl from "clsx";
3
3
  import React, { forwardRef } from "react";
4
4
 
@@ -15,7 +15,7 @@ export interface TabPanelProps extends React.HTMLAttributes<HTMLDivElement> {
15
15
 
16
16
  const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(
17
17
  ({ className, ...rest }, ref) => (
18
- <TabsContent
18
+ <RadixTabs.TabsContent
19
19
  {...rest}
20
20
  ref={ref}
21
21
  className={cl("navds-tabs__tabpanel", className)}
@@ -13,7 +13,7 @@ import {
13
13
  startOfYear,
14
14
  subDays,
15
15
  } from "date-fns";
16
- import nbLocale from "date-fns/locale/nb";
16
+ import { nb as nbLocale } from "date-fns/locale";
17
17
  import React from "react";
18
18
  import { Detail } from "../typography/Detail";
19
19
  import { useTimelineContext } from "./hooks/useTimelineContext";
@@ -1,5 +1,4 @@
1
1
  import {
2
- FloatingPortal,
3
2
  autoUpdate,
4
3
  arrow as flArrow,
5
4
  flip,
@@ -21,7 +20,7 @@ import React, {
21
20
  useRef,
22
21
  } from "react";
23
22
  import { ModalContext } from "../modal/ModalContext";
24
- import { useProvider } from "../provider";
23
+ import Portal from "../overlays/portal/Portal";
25
24
  import { Detail } from "../typography";
26
25
  import { useId } from "../util/hooks";
27
26
  import { useControllableState } from "../util/hooks/useControllableState";
@@ -123,10 +122,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
123
122
 
124
123
  const arrowRef = useRef<HTMLDivElement | null>(null);
125
124
  const modalContext = useContext(ModalContext);
126
- const providerRootElement = useProvider()?.rootElement;
127
- const rootElement = modalContext
128
- ? modalContext.ref.current
129
- : providerRootElement;
125
+ const rootElement = modalContext ? modalContext.ref.current : undefined;
130
126
 
131
127
  const {
132
128
  x,
@@ -199,7 +195,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
199
195
  : children?.props["aria-describedby"],
200
196
  }),
201
197
  )}
202
- <FloatingPortal root={rootElement}>
198
+ <Portal rootElement={rootElement}>
203
199
  {_open && (
204
200
  <div
205
201
  {...getFloatingProps({
@@ -253,7 +249,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
253
249
  )}
254
250
  </div>
255
251
  )}
256
- </FloatingPortal>
252
+ </Portal>
257
253
  </>
258
254
  );
259
255
  },
package/src/util/Slot.tsx CHANGED
@@ -20,10 +20,12 @@ export const Slot = React.forwardRef<HTMLElement, SlotProps>(
20
20
  }
21
21
 
22
22
  if (React.Children.count(children) > 1) {
23
- console.error(
23
+ const error = new Error(
24
24
  "Aksel: Components using 'asChild' expects to recieve a single React element child.",
25
25
  );
26
- return React.Children.only(null);
26
+ error.name = "SlotError";
27
+ Error.captureStackTrace?.(error, Slot);
28
+ throw error;
27
29
  }
28
30
 
29
31
  return null;