@navikt/ds-react 6.7.0 → 6.8.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 (318) hide show
  1. package/cjs/chat/Chat.d.ts +2 -1
  2. package/cjs/chat/Chat.js +2 -1
  3. package/cjs/chat/Chat.js.map +1 -1
  4. package/cjs/collapsible/parts/Collapsible.Trigger.d.ts +4 -0
  5. package/cjs/collapsible/parts/Collapsible.Trigger.js +1 -1
  6. package/cjs/collapsible/parts/Collapsible.Trigger.js.map +1 -1
  7. package/cjs/date/datepicker/parts/DropdownCaption.js +1 -1
  8. package/cjs/date/datepicker/parts/DropdownCaption.js.map +1 -1
  9. package/cjs/date/monthpicker/MonthCaption.js +1 -1
  10. package/cjs/date/utils/labels.d.ts +2 -2
  11. package/cjs/form/ReadOnlyIcon.d.ts +2 -2
  12. package/cjs/form/combobox/Combobox.js +7 -22
  13. package/cjs/form/combobox/Combobox.js.map +1 -1
  14. package/cjs/form/combobox/ComboboxProvider.js +2 -2
  15. package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
  16. package/cjs/form/combobox/ComboboxWrapper.d.ts +1 -2
  17. package/cjs/form/combobox/ComboboxWrapper.js +4 -2
  18. package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
  19. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
  20. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  21. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +4 -4
  22. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +13 -15
  23. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  24. package/cjs/form/combobox/Input/{inputContext.d.ts → Input.context.d.ts} +7 -5
  25. package/cjs/form/combobox/Input/{inputContext.js → Input.context.js} +22 -22
  26. package/cjs/form/combobox/Input/Input.context.js.map +1 -0
  27. package/cjs/form/combobox/Input/Input.js +2 -2
  28. package/cjs/form/combobox/Input/Input.js.map +1 -1
  29. package/cjs/form/combobox/Input/InputController.d.ts +3 -0
  30. package/cjs/form/combobox/Input/InputController.js +70 -0
  31. package/cjs/form/combobox/Input/InputController.js.map +1 -0
  32. package/cjs/form/combobox/{ToggleListButton.js → Input/ToggleListButton.js} +1 -1
  33. package/cjs/form/combobox/Input/ToggleListButton.js.map +1 -0
  34. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +2 -2
  35. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  36. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +4 -4
  37. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +7 -13
  38. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  39. package/cjs/form/combobox/customOptionsContext.d.ts +4 -4
  40. package/cjs/form/combobox/customOptionsContext.js +10 -13
  41. package/cjs/form/combobox/customOptionsContext.js.map +1 -1
  42. package/cjs/form/combobox/types.d.ts +1 -1
  43. package/cjs/form/file-upload/FileUpload.context.d.ts +1 -1
  44. package/cjs/form/file-upload/FileUpload.d.ts +1 -1
  45. package/cjs/form/file-upload/FileUpload.js.map +1 -1
  46. package/cjs/form/file-upload/parts/dropzone/Dropzone.js +1 -1
  47. package/cjs/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
  48. package/cjs/form/file-upload/parts/dropzone/dropzone.types.d.ts +1 -1
  49. package/cjs/form/file-upload/parts/item/Item.d.ts +1 -1
  50. package/cjs/form/file-upload/parts/item/Item.js +1 -1
  51. package/cjs/form/file-upload/parts/item/Item.js.map +1 -1
  52. package/cjs/form/form-progress/FormProgress.d.ts +66 -0
  53. package/cjs/form/form-progress/FormProgress.js +85 -0
  54. package/cjs/form/form-progress/FormProgress.js.map +1 -0
  55. package/cjs/form/form-progress/index.d.ts +1 -0
  56. package/cjs/form/form-progress/index.js +11 -0
  57. package/cjs/form/form-progress/index.js.map +1 -0
  58. package/cjs/help-text/HelpTextIcon.d.ts +1 -1
  59. package/cjs/index.d.ts +1 -0
  60. package/cjs/index.js +3 -1
  61. package/cjs/index.js.map +1 -1
  62. package/cjs/overlay/dismiss/DismissableLayer.d.ts +70 -0
  63. package/cjs/overlay/dismiss/DismissableLayer.js +253 -0
  64. package/cjs/overlay/dismiss/DismissableLayer.js.map +1 -0
  65. package/cjs/overlay/dismiss/util/dispatchCustomEvent.d.ts +50 -0
  66. package/cjs/overlay/dismiss/util/dispatchCustomEvent.js +65 -0
  67. package/cjs/overlay/dismiss/util/dispatchCustomEvent.js.map +1 -0
  68. package/cjs/overlay/dismiss/util/useEscapeKeydown.d.ts +1 -0
  69. package/cjs/overlay/dismiss/util/useEscapeKeydown.js +19 -0
  70. package/cjs/overlay/dismiss/util/useEscapeKeydown.js.map +1 -0
  71. package/cjs/overlay/dismiss/util/useFocusOutside.d.ts +8 -0
  72. package/cjs/overlay/dismiss/util/useFocusOutside.js +42 -0
  73. package/cjs/overlay/dismiss/util/useFocusOutside.js.map +1 -0
  74. package/cjs/overlay/dismiss/util/usePointerDownOutside.d.ts +10 -0
  75. package/cjs/overlay/dismiss/util/usePointerDownOutside.js +84 -0
  76. package/cjs/overlay/dismiss/util/usePointerDownOutside.js.map +1 -0
  77. package/cjs/overlays/floating/Floating.d.ts +53 -0
  78. package/cjs/overlays/floating/Floating.js +215 -0
  79. package/cjs/overlays/floating/Floating.js.map +1 -0
  80. package/cjs/overlays/floating/Floating.utils.d.ts +18 -0
  81. package/cjs/overlays/floating/Floating.utils.js +52 -0
  82. package/cjs/overlays/floating/Floating.utils.js.map +1 -0
  83. package/cjs/popover/Popover.js +13 -28
  84. package/cjs/popover/Popover.js.map +1 -1
  85. package/cjs/progress-bar/ProgressBar.d.ts +20 -8
  86. package/cjs/progress-bar/ProgressBar.js +19 -9
  87. package/cjs/progress-bar/ProgressBar.js.map +1 -1
  88. package/cjs/stepper/Step.js +1 -1
  89. package/cjs/stepper/Step.js.map +1 -1
  90. package/cjs/stepper/Stepper.d.ts +1 -1
  91. package/cjs/stepper/Stepper.js +1 -1
  92. package/cjs/tabs/Tabs.context.d.ts +7 -3
  93. package/cjs/tabs/Tabs.context.js +1 -0
  94. package/cjs/tabs/Tabs.context.js.map +1 -1
  95. package/cjs/timeline/AxisLabels.d.ts +1 -1
  96. package/cjs/toggle-group/ToggleGroup.context.d.ts +7 -3
  97. package/cjs/toggle-group/ToggleGroup.context.js +1 -0
  98. package/cjs/toggle-group/ToggleGroup.context.js.map +1 -1
  99. package/cjs/util/hooks/descendants/useDescendant.d.ts +2 -2
  100. package/cjs/util/hooks/descendants/useDescendant.js +49 -52
  101. package/cjs/util/hooks/descendants/useDescendant.js.map +1 -1
  102. package/cjs/util/i18n/get.js.map +1 -0
  103. package/cjs/util/i18n/i18n.context.js.map +1 -0
  104. package/cjs/util/i18n/i18n.types.js.map +1 -0
  105. package/{esm/form/file-upload → cjs/util}/i18n/locales/nb.d.ts +5 -0
  106. package/cjs/{form/file-upload → util}/i18n/locales/nb.js +5 -0
  107. package/cjs/util/i18n/locales/nb.js.map +1 -0
  108. package/cjs/util/i18n/merge.js.map +1 -0
  109. package/cjs/util/types/AsChild.d.ts +14 -0
  110. package/cjs/util/types/AsChild.js +3 -0
  111. package/cjs/util/types/AsChild.js.map +1 -0
  112. package/esm/chat/Chat.d.ts +2 -1
  113. package/esm/chat/Chat.js +1 -0
  114. package/esm/chat/Chat.js.map +1 -1
  115. package/esm/collapsible/parts/Collapsible.Trigger.d.ts +4 -0
  116. package/esm/collapsible/parts/Collapsible.Trigger.js +1 -1
  117. package/esm/collapsible/parts/Collapsible.Trigger.js.map +1 -1
  118. package/esm/date/datepicker/parts/DropdownCaption.js +1 -1
  119. package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
  120. package/esm/date/monthpicker/MonthCaption.js +1 -1
  121. package/esm/date/utils/labels.d.ts +2 -2
  122. package/esm/form/ReadOnlyIcon.d.ts +2 -2
  123. package/esm/form/combobox/Combobox.js +8 -23
  124. package/esm/form/combobox/Combobox.js.map +1 -1
  125. package/esm/form/combobox/ComboboxProvider.js +1 -1
  126. package/esm/form/combobox/ComboboxProvider.js.map +1 -1
  127. package/esm/form/combobox/ComboboxWrapper.d.ts +1 -2
  128. package/esm/form/combobox/ComboboxWrapper.js +4 -2
  129. package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
  130. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +3 -3
  131. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  132. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +4 -4
  133. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +15 -16
  134. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  135. package/esm/form/combobox/Input/{inputContext.d.ts → Input.context.d.ts} +7 -5
  136. package/esm/form/combobox/Input/{inputContext.js → Input.context.js} +22 -21
  137. package/esm/form/combobox/Input/Input.context.js.map +1 -0
  138. package/esm/form/combobox/Input/Input.js +1 -1
  139. package/esm/form/combobox/Input/Input.js.map +1 -1
  140. package/esm/form/combobox/Input/InputController.d.ts +3 -0
  141. package/esm/form/combobox/Input/InputController.js +41 -0
  142. package/esm/form/combobox/Input/InputController.js.map +1 -0
  143. package/esm/form/combobox/{ToggleListButton.js → Input/ToggleListButton.js} +1 -1
  144. package/esm/form/combobox/Input/ToggleListButton.js.map +1 -0
  145. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
  146. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  147. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +4 -4
  148. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +9 -14
  149. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  150. package/esm/form/combobox/customOptionsContext.d.ts +4 -4
  151. package/esm/form/combobox/customOptionsContext.js +10 -12
  152. package/esm/form/combobox/customOptionsContext.js.map +1 -1
  153. package/esm/form/combobox/types.d.ts +1 -1
  154. package/esm/form/file-upload/FileUpload.context.d.ts +1 -1
  155. package/esm/form/file-upload/FileUpload.d.ts +1 -1
  156. package/esm/form/file-upload/FileUpload.js.map +1 -1
  157. package/esm/form/file-upload/parts/dropzone/Dropzone.js +1 -1
  158. package/esm/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
  159. package/esm/form/file-upload/parts/dropzone/dropzone.types.d.ts +1 -1
  160. package/esm/form/file-upload/parts/item/Item.d.ts +1 -1
  161. package/esm/form/file-upload/parts/item/Item.js +1 -1
  162. package/esm/form/file-upload/parts/item/Item.js.map +1 -1
  163. package/esm/form/form-progress/FormProgress.d.ts +66 -0
  164. package/esm/form/form-progress/FormProgress.js +56 -0
  165. package/esm/form/form-progress/FormProgress.js.map +1 -0
  166. package/esm/form/form-progress/index.d.ts +1 -0
  167. package/esm/form/form-progress/index.js +3 -0
  168. package/esm/form/form-progress/index.js.map +1 -0
  169. package/esm/help-text/HelpTextIcon.d.ts +1 -1
  170. package/esm/index.d.ts +1 -0
  171. package/esm/index.js +1 -0
  172. package/esm/index.js.map +1 -1
  173. package/esm/overlay/dismiss/DismissableLayer.d.ts +70 -0
  174. package/esm/overlay/dismiss/DismissableLayer.js +226 -0
  175. package/esm/overlay/dismiss/DismissableLayer.js.map +1 -0
  176. package/esm/overlay/dismiss/util/dispatchCustomEvent.d.ts +50 -0
  177. package/esm/overlay/dismiss/util/dispatchCustomEvent.js +58 -0
  178. package/esm/overlay/dismiss/util/dispatchCustomEvent.js.map +1 -0
  179. package/esm/overlay/dismiss/util/useEscapeKeydown.d.ts +1 -0
  180. package/esm/overlay/dismiss/util/useEscapeKeydown.js +15 -0
  181. package/esm/overlay/dismiss/util/useEscapeKeydown.js.map +1 -0
  182. package/esm/overlay/dismiss/util/useFocusOutside.d.ts +8 -0
  183. package/esm/overlay/dismiss/util/useFocusOutside.js +38 -0
  184. package/esm/overlay/dismiss/util/useFocusOutside.js.map +1 -0
  185. package/esm/overlay/dismiss/util/usePointerDownOutside.d.ts +10 -0
  186. package/esm/overlay/dismiss/util/usePointerDownOutside.js +80 -0
  187. package/esm/overlay/dismiss/util/usePointerDownOutside.js.map +1 -0
  188. package/esm/overlays/floating/Floating.d.ts +53 -0
  189. package/esm/overlays/floating/Floating.js +188 -0
  190. package/esm/overlays/floating/Floating.js.map +1 -0
  191. package/esm/overlays/floating/Floating.utils.d.ts +18 -0
  192. package/esm/overlays/floating/Floating.utils.js +48 -0
  193. package/esm/overlays/floating/Floating.utils.js.map +1 -0
  194. package/esm/popover/Popover.js +16 -31
  195. package/esm/popover/Popover.js.map +1 -1
  196. package/esm/progress-bar/ProgressBar.d.ts +20 -8
  197. package/esm/progress-bar/ProgressBar.js +20 -10
  198. package/esm/progress-bar/ProgressBar.js.map +1 -1
  199. package/esm/stepper/Step.js +1 -1
  200. package/esm/stepper/Step.js.map +1 -1
  201. package/esm/stepper/Stepper.d.ts +1 -1
  202. package/esm/stepper/Stepper.js +1 -1
  203. package/esm/tabs/Tabs.context.d.ts +7 -3
  204. package/esm/tabs/Tabs.context.js +1 -0
  205. package/esm/tabs/Tabs.context.js.map +1 -1
  206. package/esm/timeline/AxisLabels.d.ts +1 -1
  207. package/esm/toggle-group/ToggleGroup.context.d.ts +7 -3
  208. package/esm/toggle-group/ToggleGroup.context.js +1 -0
  209. package/esm/toggle-group/ToggleGroup.context.js.map +1 -1
  210. package/esm/util/hooks/descendants/useDescendant.d.ts +2 -2
  211. package/esm/util/hooks/descendants/useDescendant.js +49 -52
  212. package/esm/util/hooks/descendants/useDescendant.js.map +1 -1
  213. package/esm/util/i18n/get.js.map +1 -0
  214. package/esm/util/i18n/i18n.context.js.map +1 -0
  215. package/esm/util/i18n/i18n.types.js.map +1 -0
  216. package/{cjs/form/file-upload → esm/util}/i18n/locales/nb.d.ts +5 -0
  217. package/esm/{form/file-upload → util}/i18n/locales/nb.js +5 -0
  218. package/esm/util/i18n/locales/nb.js.map +1 -0
  219. package/esm/util/i18n/merge.js.map +1 -0
  220. package/esm/util/types/AsChild.d.ts +14 -0
  221. package/esm/util/types/AsChild.js +2 -0
  222. package/esm/util/types/AsChild.js.map +1 -0
  223. package/package.json +16 -5
  224. package/src/chat/Chat.tsx +2 -1
  225. package/src/collapsible/parts/Collapsible.Trigger.tsx +5 -1
  226. package/src/date/datepicker/parts/DropdownCaption.tsx +5 -1
  227. package/src/date/monthpicker/MonthCaption.tsx +1 -1
  228. package/src/form/combobox/Combobox.tsx +6 -76
  229. package/src/form/combobox/ComboboxProvider.tsx +1 -1
  230. package/src/form/combobox/ComboboxWrapper.tsx +4 -3
  231. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +3 -3
  232. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +19 -29
  233. package/src/form/combobox/Input/{inputContext.tsx → Input.context.tsx} +30 -33
  234. package/src/form/combobox/Input/Input.tsx +1 -1
  235. package/src/form/combobox/Input/InputController.tsx +102 -0
  236. package/src/form/combobox/{ToggleListButton.tsx → Input/ToggleListButton.tsx} +1 -1
  237. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
  238. package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +12 -26
  239. package/src/form/combobox/{combobox-utils.test.ts → __tests__/combobox-utils.test.ts} +1 -1
  240. package/src/form/combobox/{combobox.test.tsx → __tests__/combobox.test.tsx} +2 -3
  241. package/src/form/combobox/customOptionsContext.tsx +14 -18
  242. package/src/form/combobox/types.ts +3 -1
  243. package/src/form/file-upload/FileUpload.context.tsx +1 -1
  244. package/src/form/file-upload/FileUpload.tsx +1 -1
  245. package/src/form/file-upload/parts/dropzone/Dropzone.tsx +1 -1
  246. package/src/form/file-upload/parts/dropzone/dropzone.types.ts +1 -1
  247. package/src/form/file-upload/parts/item/Item.tsx +2 -2
  248. package/src/form/form-progress/FormProgress.tsx +152 -0
  249. package/src/form/form-progress/index.ts +7 -0
  250. package/src/index.ts +1 -0
  251. package/src/overlay/README.md +5 -0
  252. package/src/overlay/dismiss/DismissableLayer.tsx +368 -0
  253. package/src/overlay/dismiss/util/dispatchCustomEvent.ts +77 -0
  254. package/src/overlay/dismiss/util/useEscapeKeydown.ts +21 -0
  255. package/src/overlay/dismiss/util/useFocusOutside.ts +52 -0
  256. package/src/overlay/dismiss/util/usePointerDownOutside.ts +95 -0
  257. package/src/overlays/floating/Floating.tsx +399 -0
  258. package/src/overlays/floating/Floating.utils.ts +63 -0
  259. package/src/popover/Popover.tsx +38 -70
  260. package/src/progress-bar/ProgressBar.tsx +45 -20
  261. package/src/stepper/Step.tsx +1 -1
  262. package/src/stepper/Stepper.tsx +1 -1
  263. package/src/tabs/Tabs.context.ts +2 -0
  264. package/src/toggle-group/ToggleGroup.context.ts +1 -0
  265. package/src/util/hooks/descendants/useDescendant.tsx +55 -68
  266. package/src/{form/file-upload → util}/i18n/locales/nb.ts +5 -0
  267. package/src/util/types/AsChild.ts +15 -0
  268. package/cjs/form/combobox/ClearButton.d.ts +0 -7
  269. package/cjs/form/combobox/ClearButton.js +0 -28
  270. package/cjs/form/combobox/ClearButton.js.map +0 -1
  271. package/cjs/form/combobox/FilteredOptions/CheckIcon.d.ts +0 -3
  272. package/cjs/form/combobox/FilteredOptions/CheckIcon.js +0 -12
  273. package/cjs/form/combobox/FilteredOptions/CheckIcon.js.map +0 -1
  274. package/cjs/form/combobox/Input/inputContext.js.map +0 -1
  275. package/cjs/form/combobox/ToggleListButton.js.map +0 -1
  276. package/cjs/form/file-upload/i18n/get.js.map +0 -1
  277. package/cjs/form/file-upload/i18n/i18n.context.js.map +0 -1
  278. package/cjs/form/file-upload/i18n/i18n.types.js.map +0 -1
  279. package/cjs/form/file-upload/i18n/locales/nb.js.map +0 -1
  280. package/cjs/form/file-upload/i18n/merge.js.map +0 -1
  281. package/esm/form/combobox/ClearButton.d.ts +0 -7
  282. package/esm/form/combobox/ClearButton.js +0 -21
  283. package/esm/form/combobox/ClearButton.js.map +0 -1
  284. package/esm/form/combobox/FilteredOptions/CheckIcon.d.ts +0 -3
  285. package/esm/form/combobox/FilteredOptions/CheckIcon.js +0 -7
  286. package/esm/form/combobox/FilteredOptions/CheckIcon.js.map +0 -1
  287. package/esm/form/combobox/Input/inputContext.js.map +0 -1
  288. package/esm/form/combobox/ToggleListButton.js.map +0 -1
  289. package/esm/form/file-upload/i18n/get.js.map +0 -1
  290. package/esm/form/file-upload/i18n/i18n.context.js.map +0 -1
  291. package/esm/form/file-upload/i18n/i18n.types.js.map +0 -1
  292. package/esm/form/file-upload/i18n/locales/nb.js.map +0 -1
  293. package/esm/form/file-upload/i18n/merge.js.map +0 -1
  294. package/src/form/combobox/ClearButton.tsx +0 -29
  295. package/src/form/combobox/FilteredOptions/CheckIcon.tsx +0 -23
  296. /package/cjs/form/combobox/{ToggleListButton.d.ts → Input/ToggleListButton.d.ts} +0 -0
  297. /package/cjs/{form/file-upload → util}/i18n/get.d.ts +0 -0
  298. /package/cjs/{form/file-upload → util}/i18n/get.js +0 -0
  299. /package/cjs/{form/file-upload → util}/i18n/i18n.context.d.ts +0 -0
  300. /package/cjs/{form/file-upload → util}/i18n/i18n.context.js +0 -0
  301. /package/cjs/{form/file-upload → util}/i18n/i18n.types.d.ts +0 -0
  302. /package/cjs/{form/file-upload → util}/i18n/i18n.types.js +0 -0
  303. /package/cjs/{form/file-upload → util}/i18n/merge.d.ts +0 -0
  304. /package/cjs/{form/file-upload → util}/i18n/merge.js +0 -0
  305. /package/esm/form/combobox/{ToggleListButton.d.ts → Input/ToggleListButton.d.ts} +0 -0
  306. /package/esm/{form/file-upload → util}/i18n/get.d.ts +0 -0
  307. /package/esm/{form/file-upload → util}/i18n/get.js +0 -0
  308. /package/esm/{form/file-upload → util}/i18n/i18n.context.d.ts +0 -0
  309. /package/esm/{form/file-upload → util}/i18n/i18n.context.js +0 -0
  310. /package/esm/{form/file-upload → util}/i18n/i18n.types.d.ts +0 -0
  311. /package/esm/{form/file-upload → util}/i18n/i18n.types.js +0 -0
  312. /package/esm/{form/file-upload → util}/i18n/merge.d.ts +0 -0
  313. /package/esm/{form/file-upload → util}/i18n/merge.js +0 -0
  314. /package/src/{form/file-upload → util}/i18n/get.ts +0 -0
  315. /package/src/{form/file-upload → util}/i18n/i18n.context.test.tsx +0 -0
  316. /package/src/{form/file-upload → util}/i18n/i18n.context.ts +0 -0
  317. /package/src/{form/file-upload → util}/i18n/i18n.types.ts +0 -0
  318. /package/src/{form/file-upload → util}/i18n/merge.ts +0 -0
@@ -1,17 +1,11 @@
1
1
  import cl from "clsx";
2
- import React, {
3
- SetStateAction,
4
- createContext,
5
- useCallback,
6
- useContext,
7
- useMemo,
8
- useState,
9
- } from "react";
2
+ import React, { SetStateAction, useCallback, useMemo, useState } from "react";
3
+ import { createContext } from "../../../util/create-context";
10
4
  import { useClientLayoutEffect, usePrevious } from "../../../util/hooks";
11
- import { useInputContext } from "../Input/inputContext";
5
+ import { useInputContext } from "../Input/Input.context";
12
6
  import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
13
7
  import { toComboboxOption } from "../combobox-utils";
14
- import { useCustomOptionsContext } from "../customOptionsContext";
8
+ import { useComboboxCustomOptions } from "../customOptionsContext";
15
9
  import { ComboboxOption, ComboboxProps } from "../types";
16
10
  import filteredOptionsUtils from "./filtered-options-util";
17
11
  import useVirtualFocus, { VirtualFocusType } from "./useVirtualFocus";
@@ -24,7 +18,7 @@ type FilteredOptionsProps = {
24
18
  };
25
19
  };
26
20
 
27
- type FilteredOptionsContextType = {
21
+ type FilteredOptionsContextValue = {
28
22
  activeDecendantId?: string;
29
23
  allowNewValues?: boolean;
30
24
  ariaDescribedBy?: string;
@@ -42,11 +36,14 @@ type FilteredOptionsContextType = {
42
36
  shouldAutocomplete?: boolean;
43
37
  virtualFocus: VirtualFocusType;
44
38
  };
45
- const FilteredOptionsContext = createContext<FilteredOptionsContextType>(
46
- {} as FilteredOptionsContextType,
47
- );
39
+ const [FilteredOptionsContextProvider, useFilteredOptionsContext] =
40
+ createContext<FilteredOptionsContextValue>({
41
+ name: "FilteredOptionsContext",
42
+ errorMessage:
43
+ "useFilteredOptionsContext must be used within a FilteredOptionsProvider",
44
+ });
48
45
 
49
- export const FilteredOptionsProvider = ({
46
+ const FilteredOptionsProvider = ({
50
47
  children,
51
48
  value: props,
52
49
  }: FilteredOptionsProps) => {
@@ -71,7 +68,7 @@ export const FilteredOptionsProvider = ({
71
68
  const { maxSelected } = useSelectedOptionsContext();
72
69
 
73
70
  const [isInternalListOpen, setInternalListOpen] = useState(false);
74
- const { customOptions } = useCustomOptionsContext();
71
+ const { customOptions } = useComboboxCustomOptions();
75
72
 
76
73
  const filteredOptions = useMemo(() => {
77
74
  if (externalFilteredOptions) {
@@ -152,9 +149,9 @@ export const FilteredOptionsProvider = ({
152
149
 
153
150
  const ariaDescribedBy = useMemo(() => {
154
151
  let activeOption;
155
- if (!isLoading && filteredOptions.length === 0) {
152
+ if (!isLoading && filteredOptions.length === 0 && !allowNewValues) {
156
153
  activeOption = filteredOptionsUtils.getNoHitsId(id);
157
- } else if ((value && value !== "") || isLoading) {
154
+ } else if (value || isLoading) {
158
155
  if (shouldAutocomplete && filteredOptions[0]) {
159
156
  activeOption = filteredOptionsUtils.getOptionId(
160
157
  id,
@@ -180,6 +177,7 @@ export const FilteredOptionsProvider = ({
180
177
  shouldAutocomplete,
181
178
  filteredOptions,
182
179
  id,
180
+ allowNewValues,
183
181
  ]);
184
182
 
185
183
  const currentOption = useMemo(
@@ -211,18 +209,10 @@ export const FilteredOptionsProvider = ({
211
209
  };
212
210
 
213
211
  return (
214
- <FilteredOptionsContext.Provider value={filteredOptionsState}>
212
+ <FilteredOptionsContextProvider {...filteredOptionsState}>
215
213
  {children}
216
- </FilteredOptionsContext.Provider>
214
+ </FilteredOptionsContextProvider>
217
215
  );
218
216
  };
219
217
 
220
- export const useFilteredOptionsContext = () => {
221
- const context = useContext(FilteredOptionsContext);
222
- if (!context) {
223
- throw new Error(
224
- "useFilteredOptionsContext must be used within a FilteredOptionsProvider",
225
- );
226
- }
227
- return context;
228
- };
218
+ export { FilteredOptionsProvider, useFilteredOptionsContext };
@@ -1,18 +1,18 @@
1
1
  import React, {
2
2
  ChangeEvent,
3
3
  ChangeEventHandler,
4
- createContext,
5
4
  useCallback,
6
- useContext,
7
5
  useMemo,
8
6
  useRef,
9
7
  useState,
10
8
  } from "react";
9
+ import { createContext } from "../../../util/create-context";
11
10
  import { useClientLayoutEffect } from "../../../util/hooks";
12
11
  import { FormFieldType, useFormField } from "../../useFormField";
12
+ import { ComboboxProps } from "../types";
13
13
 
14
- interface InputContextType extends FormFieldType {
15
- clearInput: (event: React.PointerEvent | React.KeyboardEvent) => void;
14
+ interface InputContextValue extends FormFieldType {
15
+ clearInput: NonNullable<ComboboxProps["onClear"]>;
16
16
  error?: string;
17
17
  focusInput: () => void;
18
18
  inputRef: React.RefObject<HTMLInputElement>;
@@ -22,11 +22,16 @@ interface InputContextType extends FormFieldType {
22
22
  searchTerm: string;
23
23
  setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
24
24
  shouldAutocomplete?: boolean;
25
+ toggleOpenButtonRef: React.RefObject<HTMLButtonElement>;
25
26
  }
26
27
 
27
- const InputContext = createContext<InputContextType>({} as InputContextType);
28
+ const [InputContextProvider, useInputContext] =
29
+ createContext<InputContextValue>({
30
+ name: "InputContext",
31
+ errorMessage: "useInputContext must be used within an InputContextProvider",
32
+ });
28
33
 
29
- export const InputContextProvider = ({ children, value: props }) => {
34
+ const InputProvider = ({ children, value: props }) => {
30
35
  const {
31
36
  defaultValue = "",
32
37
  description,
@@ -52,6 +57,7 @@ export const InputContextProvider = ({ children, value: props }) => {
52
57
  "comboboxfield",
53
58
  );
54
59
  const inputRef = useRef<HTMLInputElement | null>(null);
60
+ const toggleOpenButtonRef = useRef<HTMLButtonElement>(null);
55
61
  const [internalValue, setInternalValue] = useState<string>(defaultValue);
56
62
 
57
63
  const value = useMemo(
@@ -79,7 +85,7 @@ export const InputContextProvider = ({ children, value: props }) => {
79
85
  );
80
86
 
81
87
  const clearInput = useCallback(
82
- (event: React.PointerEvent | React.KeyboardEvent) => {
88
+ (event: React.PointerEvent | React.KeyboardEvent | React.MouseEvent) => {
83
89
  onClear?.(event);
84
90
  externalOnChange?.(null, "");
85
91
  setValue("");
@@ -98,33 +104,24 @@ export const InputContextProvider = ({ children, value: props }) => {
98
104
  }
99
105
  }, [value, searchTerm, shouldAutocomplete]);
100
106
 
107
+ const contextValue = {
108
+ ...formFieldProps,
109
+ clearInput,
110
+ error,
111
+ focusInput,
112
+ inputRef,
113
+ value,
114
+ setValue,
115
+ onChange,
116
+ searchTerm,
117
+ setSearchTerm,
118
+ shouldAutocomplete,
119
+ toggleOpenButtonRef,
120
+ };
121
+
101
122
  return (
102
- <InputContext.Provider
103
- value={{
104
- ...formFieldProps,
105
- clearInput,
106
- error,
107
- focusInput,
108
- inputRef,
109
- value,
110
- setValue,
111
- onChange,
112
- searchTerm,
113
- setSearchTerm,
114
- shouldAutocomplete,
115
- }}
116
- >
117
- {children}
118
- </InputContext.Provider>
123
+ <InputContextProvider {...contextValue}>{children}</InputContextProvider>
119
124
  );
120
125
  };
121
126
 
122
- export const useInputContext = () => {
123
- const context = useContext(InputContext);
124
- if (!context) {
125
- throw new Error(
126
- "useInputContext must be used within an InputContextProvider",
127
- );
128
- }
129
- return context;
130
- };
127
+ export { InputProvider as InputContextProvider, useInputContext };
@@ -9,7 +9,7 @@ import { omit } from "../../../util";
9
9
  import filteredOptionsUtil from "../FilteredOptions/filtered-options-util";
10
10
  import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext";
11
11
  import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
12
- import { useInputContext } from "./inputContext";
12
+ import { useInputContext } from "./Input.context";
13
13
 
14
14
  interface InputProps
15
15
  extends Omit<InputHTMLAttributes<HTMLInputElement>, "value"> {
@@ -0,0 +1,102 @@
1
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
2
+ import cl from "clsx";
3
+ import React, { forwardRef } from "react";
4
+ import { XMarkIcon } from "@navikt/aksel-icons";
5
+ import { useMergeRefs } from "../../../util/hooks";
6
+ import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext";
7
+ import SelectedOptions from "../SelectedOptions/SelectedOptions";
8
+ import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
9
+ import { ComboboxProps } from "../types";
10
+ import Input from "./Input";
11
+ import { useInputContext } from "./Input.context";
12
+ import ToggleListButton from "./ToggleListButton";
13
+
14
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
15
+ export const InputController = forwardRef<
16
+ HTMLInputElement,
17
+ Omit<
18
+ ComboboxProps,
19
+ | "label"
20
+ | "description"
21
+ | "hideLabel"
22
+ | "onChange"
23
+ | "options"
24
+ | "size"
25
+ | "onClear"
26
+ | "value"
27
+ >
28
+ >((props, ref) => {
29
+ const {
30
+ clearButton = true,
31
+ clearButtonLabel,
32
+ toggleListButton = true,
33
+ toggleListButtonLabel,
34
+ inputClassName,
35
+ shouldShowSelectedOptions = true,
36
+ ...rest
37
+ } = props;
38
+
39
+ const {
40
+ clearInput,
41
+ focusInput,
42
+ inputProps,
43
+ value,
44
+ size = "medium",
45
+ inputRef,
46
+ toggleOpenButtonRef,
47
+ } = useInputContext();
48
+
49
+ const { activeDecendantId } = useFilteredOptionsContext();
50
+ const { selectedOptions } = useSelectedOptionsContext();
51
+
52
+ const mergedInputRef = useMergeRefs(inputRef, ref);
53
+
54
+ return (
55
+ <div
56
+ className={cl("navds-combobox__wrapper-inner navds-text-field__input", {
57
+ "navds-combobox__wrapper-inner--virtually-unfocused":
58
+ activeDecendantId !== undefined,
59
+ })}
60
+ onClick={focusInput}
61
+ >
62
+ {!shouldShowSelectedOptions ? (
63
+ <Input
64
+ id={inputProps.id}
65
+ ref={mergedInputRef}
66
+ inputClassName={inputClassName}
67
+ {...rest}
68
+ />
69
+ ) : (
70
+ <SelectedOptions selectedOptions={selectedOptions} size={size}>
71
+ <Input
72
+ id={inputProps.id}
73
+ ref={mergedInputRef}
74
+ inputClassName={inputClassName}
75
+ {...rest}
76
+ />
77
+ </SelectedOptions>
78
+ )}
79
+ <div>
80
+ {value && clearButton && (
81
+ <button
82
+ type="button"
83
+ onClick={clearInput}
84
+ className="navds-combobox__button-clear"
85
+ tabIndex={-1}
86
+ >
87
+ <span className="navds-sr-only">
88
+ {clearButtonLabel ? clearButtonLabel : "Tøm"}
89
+ </span>
90
+ <XMarkIcon aria-hidden />
91
+ </button>
92
+ )}
93
+ {toggleListButton && (
94
+ <ToggleListButton
95
+ toggleListButtonLabel={toggleListButtonLabel}
96
+ ref={toggleOpenButtonRef}
97
+ />
98
+ )}
99
+ </div>
100
+ </div>
101
+ );
102
+ });
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef } from "react";
2
2
  import { ChevronDownIcon, ChevronUpIcon } from "@navikt/aksel-icons";
3
- import { useFilteredOptionsContext } from "./FilteredOptions/filteredOptionsContext";
3
+ import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext";
4
4
 
5
5
  interface ToggleListButtonProps {
6
6
  toggleListButtonLabel?: string;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Chips } from "../../../chips";
3
- import { useInputContext } from "../Input/inputContext";
3
+ import { useInputContext } from "../Input/Input.context";
4
4
  import { ComboboxOption } from "../types";
5
5
  import { useSelectedOptionsContext } from "./selectedOptionsContext";
6
6
 
@@ -1,17 +1,12 @@
1
- import React, {
2
- createContext,
3
- useCallback,
4
- useContext,
5
- useMemo,
6
- useState,
7
- } from "react";
1
+ import React, { useCallback, useMemo, useState } from "react";
2
+ import { createContext } from "../../../util/create-context";
8
3
  import { usePrevious } from "../../../util/hooks";
9
- import { useInputContext } from "../Input/inputContext";
4
+ import { useInputContext } from "../Input/Input.context";
10
5
  import { isInList } from "../combobox-utils";
11
- import { useCustomOptionsContext } from "../customOptionsContext";
6
+ import { useComboboxCustomOptions } from "../customOptionsContext";
12
7
  import { ComboboxOption, ComboboxProps, MaxSelected } from "../types";
13
8
 
14
- type SelectedOptionsContextType = {
9
+ type SelectedOptionsContextValue = {
15
10
  addSelectedOption: (option: ComboboxOption) => void;
16
11
  isMultiSelect?: boolean;
17
12
  removeSelectedOption: (option: ComboboxOption) => void;
@@ -25,11 +20,10 @@ type SelectedOptionsContextType = {
25
20
  ) => void;
26
21
  };
27
22
 
28
- const SelectedOptionsContext = createContext<SelectedOptionsContextType>(
29
- {} as SelectedOptionsContextType,
30
- );
23
+ const [SelectedOptionsContextProvider, useSelectedOptionsContext] =
24
+ createContext<SelectedOptionsContextValue>();
31
25
 
32
- export const SelectedOptionsProvider = ({
26
+ const SelectedOptionsProvider = ({
33
27
  children,
34
28
  value,
35
29
  }: {
@@ -45,7 +39,7 @@ export const SelectedOptionsProvider = ({
45
39
  removeCustomOption,
46
40
  addCustomOption,
47
41
  setCustomOptions,
48
- } = useCustomOptionsContext();
42
+ } = useComboboxCustomOptions();
49
43
  const {
50
44
  allowNewValues,
51
45
  isMultiSelect,
@@ -149,18 +143,10 @@ export const SelectedOptionsProvider = ({
149
143
  };
150
144
 
151
145
  return (
152
- <SelectedOptionsContext.Provider value={selectedOptionsState}>
146
+ <SelectedOptionsContextProvider {...selectedOptionsState}>
153
147
  {children}
154
- </SelectedOptionsContext.Provider>
148
+ </SelectedOptionsContextProvider>
155
149
  );
156
150
  };
157
151
 
158
- export const useSelectedOptionsContext = () => {
159
- const context = useContext(SelectedOptionsContext);
160
- if (!context) {
161
- throw new Error(
162
- "useSelectedOptionsContext must be used within a SelectedOptionsProvider",
163
- );
164
- }
165
- return context;
166
- };
152
+ export { SelectedOptionsProvider, useSelectedOptionsContext };
@@ -2,7 +2,7 @@ import {
2
2
  isInList,
3
3
  mapToComboboxOptionArray,
4
4
  toComboboxOption,
5
- } from "./combobox-utils";
5
+ } from "../combobox-utils";
6
6
 
7
7
  const list = [
8
8
  { label: "Hjelpemidler", value: "HJE" },
@@ -1,10 +1,9 @@
1
1
  /* eslint-disable testing-library/no-unnecessary-act -- https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning */
2
- import { render, screen } from "@testing-library/react";
2
+ import { act, render, screen } from "@testing-library/react";
3
3
  import userEvent from "@testing-library/user-event";
4
4
  import React, { useId } from "react";
5
- import { act } from "react-dom/test-utils";
6
5
  import { describe, expect, test, vi } from "vitest";
7
- import { UNSAFE_Combobox } from "./index";
6
+ import { UNSAFE_Combobox } from "../index";
8
7
 
9
8
  const options = [
10
9
  "banana",
@@ -1,19 +1,23 @@
1
- import React, { createContext, useCallback, useContext, useState } from "react";
2
- import { useInputContext } from "./Input/inputContext";
1
+ import React, { useCallback, useState } from "react";
2
+ import { createContext } from "../../util/create-context";
3
+ import { useInputContext } from "./Input/Input.context";
3
4
  import { ComboboxOption } from "./types";
4
5
 
5
- type CustomOptionsContextType = {
6
+ type CustomOptionsContextValue = {
6
7
  customOptions: ComboboxOption[];
7
8
  removeCustomOption: (option: ComboboxOption) => void;
8
9
  addCustomOption: (option: ComboboxOption) => void;
9
10
  setCustomOptions: React.Dispatch<React.SetStateAction<ComboboxOption[]>>;
10
11
  };
11
12
 
12
- const CustomOptionsContext = createContext<CustomOptionsContextType>(
13
- {} as CustomOptionsContextType,
14
- );
13
+ const [ComboboxCustomOptionsProvider, useComboboxCustomOptions] =
14
+ createContext<CustomOptionsContextValue>({
15
+ name: "ComboboxCustomOptions",
16
+ errorMessage:
17
+ "useComboboxCustomOptions must be used within a ComboboxCustomOptionsProvider",
18
+ });
15
19
 
16
- export const CustomOptionsProvider = ({
20
+ const CustomOptionsProvider = ({
17
21
  children,
18
22
  value,
19
23
  }: {
@@ -54,18 +58,10 @@ export const CustomOptionsProvider = ({
54
58
  };
55
59
 
56
60
  return (
57
- <CustomOptionsContext.Provider value={customOptionsState}>
61
+ <ComboboxCustomOptionsProvider {...customOptionsState}>
58
62
  {children}
59
- </CustomOptionsContext.Provider>
63
+ </ComboboxCustomOptionsProvider>
60
64
  );
61
65
  };
62
66
 
63
- export const useCustomOptionsContext = () => {
64
- const context = useContext(CustomOptionsContext);
65
- if (!context) {
66
- throw new Error(
67
- "useCustomOptionsContext must be used within a CustomOptionsProvider",
68
- );
69
- }
70
- return context;
71
- };
67
+ export { CustomOptionsProvider, useComboboxCustomOptions };
@@ -100,7 +100,9 @@ export interface ComboboxProps
100
100
  *
101
101
  * @param event
102
102
  */
103
- onClear?: (event: React.PointerEvent | React.KeyboardEvent) => void;
103
+ onClear?: (
104
+ event: React.PointerEvent | React.KeyboardEvent | React.MouseEvent,
105
+ ) => void;
104
106
  /**
105
107
  * Callback function triggered whenever an option is selected or de-selected.
106
108
  *
@@ -1,5 +1,5 @@
1
1
  import { createContext } from "../../util/create-context";
2
- import { ComponentTranslation } from "./i18n/i18n.types";
2
+ import { ComponentTranslation } from "../../util/i18n/i18n.types";
3
3
 
4
4
  export type FileUploadLocaleContextProps = {
5
5
  translations?: ComponentTranslation<"FileUpload">;
@@ -1,7 +1,7 @@
1
1
  import cl from "clsx";
2
2
  import React, { HTMLAttributes, forwardRef } from "react";
3
+ import { ComponentTranslation } from "../../util/i18n/i18n.types";
3
4
  import { FileUploadLocaleContextProvider } from "./FileUpload.context";
4
- import { ComponentTranslation } from "./i18n/i18n.types";
5
5
  import Trigger from "./parts/Trigger";
6
6
  import Dropzone from "./parts/dropzone/Dropzone";
7
7
  import Item from "./parts/item/Item";
@@ -5,10 +5,10 @@ import { Button } from "../../../../button";
5
5
  import { BodyShort, ErrorMessage, Label } from "../../../../typography";
6
6
  import { composeEventHandlers } from "../../../../util/composeEventHandlers";
7
7
  import { useId } from "../../../../util/hooks";
8
+ import { useI18n } from "../../../../util/i18n/i18n.context";
8
9
  import { omit } from "../../../../util/omit";
9
10
  import { useFormField } from "../../../useFormField";
10
11
  import { useFileUploadTranslation } from "../../FileUpload.context";
11
- import { useI18n } from "../../i18n/i18n.context";
12
12
  import { useFileUpload } from "../../useFileUpload";
13
13
  import { FileUploadDropzoneProps } from "./dropzone.types";
14
14
  import { useDropzone } from "./useDropzone";
@@ -1,6 +1,6 @@
1
+ import { ComponentTranslation } from "../../../../util/i18n/i18n.types";
1
2
  import { FormFieldProps } from "../../../useFormField";
2
3
  import { FileUploadBaseProps } from "../../FileUpload.types";
3
- import { ComponentTranslation } from "../../i18n/i18n.types";
4
4
 
5
5
  export interface FileUploadDropzoneProps
6
6
  extends FileUploadBaseProps,
@@ -3,9 +3,9 @@ import React, { MouseEvent, forwardRef } from "react";
3
3
  import { ExclamationmarkTriangleIcon } from "@navikt/aksel-icons";
4
4
  import { BodyShort } from "../../../../typography";
5
5
  import { OverridableComponent } from "../../../../util";
6
+ import { useI18n } from "../../../../util/i18n/i18n.context";
7
+ import { ComponentTranslation } from "../../../../util/i18n/i18n.types";
6
8
  import { useFileUploadTranslation } from "../../FileUpload.context";
7
- import { useI18n } from "../../i18n/i18n.context";
8
- import { ComponentTranslation } from "../../i18n/i18n.types";
9
9
  import { FileItem } from "./Item.types";
10
10
  import ItemButton from "./ItemButton";
11
11
  import ItemIcon from "./ItemIcon";