@fremtind/jokul 0.43.0 → 0.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/README.md +4 -16
  2. package/build/build-stats.html +1 -1
  3. package/build/cjs/components/accordion/AccordionItem.cjs.map +1 -1
  4. package/build/cjs/components/autosuggest/Autosuggest.cjs +1 -1
  5. package/build/cjs/components/autosuggest/Autosuggest.cjs.map +1 -1
  6. package/build/cjs/components/autosuggest/BaseAutosuggest.cjs +2 -2
  7. package/build/cjs/components/autosuggest/BaseAutosuggest.cjs.map +1 -1
  8. package/build/cjs/components/autosuggest/ControllerButton.cjs.map +1 -1
  9. package/build/cjs/components/autosuggest/utils.cjs.map +1 -1
  10. package/build/cjs/components/breadcrumb/Breadcrumb.cjs.map +1 -1
  11. package/build/cjs/components/button/Button.cjs.map +1 -1
  12. package/build/cjs/components/card/Card.cjs.map +1 -1
  13. package/build/cjs/components/card/CardImage.cjs.map +1 -1
  14. package/build/cjs/components/card/NavCard.cjs.map +1 -1
  15. package/build/cjs/components/checkbox/Checkbox.cjs.map +1 -1
  16. package/build/cjs/components/combobox/Combobox.cjs.map +1 -1
  17. package/build/cjs/components/cookie-consent/CookieConsent.cjs.map +1 -1
  18. package/build/cjs/components/cookie-consent/CookieConsentContext.cjs.map +1 -1
  19. package/build/cjs/components/cookie-consent/cookieConsentUtils.cjs.map +1 -1
  20. package/build/cjs/components/datepicker/DatePicker.cjs.map +1 -1
  21. package/build/cjs/components/datepicker/internal/Calendar.cjs.map +1 -1
  22. package/build/cjs/components/datepicker/internal/calendarReducer.cjs.map +1 -1
  23. package/build/cjs/components/datepicker/internal/useCalendar.cjs.map +1 -1
  24. package/build/cjs/components/datepicker/internal/utils.cjs.map +1 -1
  25. package/build/cjs/components/expander/ExpandablePanel.cjs.map +1 -1
  26. package/build/cjs/components/expander/ExpandablePanelContent.cjs.map +1 -1
  27. package/build/cjs/components/expander/Expander.cjs.map +1 -1
  28. package/build/cjs/components/expander/deprecated/ExpandSection.cjs.map +1 -1
  29. package/build/cjs/components/expander/deprecated/Expander.cjs.map +1 -1
  30. package/build/cjs/components/feedback/Feedback.cjs.map +1 -1
  31. package/build/cjs/components/feedback/feedbackContext.cjs.map +1 -1
  32. package/build/cjs/components/feedback/followup/Followup.cjs.map +1 -1
  33. package/build/cjs/components/feedback/followup/useFollowup.cjs.map +1 -1
  34. package/build/cjs/components/feedback/main-question/MainQuestion.cjs.map +1 -1
  35. package/build/cjs/components/feedback/main-question/useMainQuestion.cjs.map +1 -1
  36. package/build/cjs/components/feedback/questions/AddonQuestion.cjs.map +1 -1
  37. package/build/cjs/components/feedback/questions/CheckboxQuestion.cjs.map +1 -1
  38. package/build/cjs/components/feedback/questions/ContactQuestion.cjs.map +1 -1
  39. package/build/cjs/components/feedback/questions/RadioQuestion.cjs.map +1 -1
  40. package/build/cjs/components/feedback/questions/SmileyQuestion.cjs.map +1 -1
  41. package/build/cjs/components/feedback/questions/TextQuestion.cjs.map +1 -1
  42. package/build/cjs/components/feedback/questions/smileyUtils.cjs.map +1 -1
  43. package/build/cjs/components/feedback/utils.cjs.map +1 -1
  44. package/build/cjs/components/file-input/File.cjs.map +1 -1
  45. package/build/cjs/components/file-input/FileInput.cjs.map +1 -1
  46. package/build/cjs/components/file-input/internal/Dropzone.cjs.map +1 -1
  47. package/build/cjs/components/file-input/internal/Input.cjs.map +1 -1
  48. package/build/cjs/components/file-input/internal/fileInputContext.cjs.map +1 -1
  49. package/build/cjs/components/file-input/internal/validateFile.cjs.map +1 -1
  50. package/build/cjs/components/flex/Flex.cjs.map +1 -1
  51. package/build/cjs/components/icon/icons/GreenCheckIcon.cjs.map +1 -1
  52. package/build/cjs/components/icon/icons/RedCrossIcon.cjs.map +1 -1
  53. package/build/cjs/components/icon-button/IconButton.cjs.map +1 -1
  54. package/build/cjs/components/image/Image.cjs.map +1 -1
  55. package/build/cjs/components/image/useImageLoadingStatus.cjs.map +1 -1
  56. package/build/cjs/components/input-group/FieldGroup.cjs.map +1 -1
  57. package/build/cjs/components/input-group/InputGroup.cjs.map +1 -1
  58. package/build/cjs/components/input-group/Label.cjs.map +1 -1
  59. package/build/cjs/components/input-group/SupportLabel.cjs.map +1 -1
  60. package/build/cjs/components/input-panel/RadioPanel.cjs.map +1 -1
  61. package/build/cjs/components/input-panel/RadioPanelGroup.cjs.map +1 -1
  62. package/build/cjs/components/link-list/LinkList.cjs.map +1 -1
  63. package/build/cjs/components/list/List.cjs.map +1 -1
  64. package/build/cjs/components/loader/Loader.cjs.map +1 -1
  65. package/build/cjs/components/loader/skeletons/SkeletonAnimation.cjs.map +1 -1
  66. package/build/cjs/components/loader/skeletons/SkeletonLabel.cjs.map +1 -1
  67. package/build/cjs/components/loader/skeletons/SkeletonTextArea.cjs.map +1 -1
  68. package/build/cjs/components/logo/Logo.cjs.map +1 -1
  69. package/build/cjs/components/logo/LogoStamp.cjs.map +1 -1
  70. package/build/cjs/components/logo/useTextSpinner.cjs.map +1 -1
  71. package/build/cjs/components/menu/Menu.cjs.map +1 -1
  72. package/build/cjs/components/menu/MenuItem.cjs.map +1 -1
  73. package/build/cjs/components/menu/MenuItemCheckbox.cjs.map +1 -1
  74. package/build/cjs/components/menu/useMenuWideEvents.cjs.map +1 -1
  75. package/build/cjs/components/message/FormErrorMessage.cjs.map +1 -1
  76. package/build/cjs/components/message/Message.cjs.map +1 -1
  77. package/build/cjs/components/modal/Modal.cjs.map +1 -1
  78. package/build/cjs/components/modal/useModal.cjs.map +1 -1
  79. package/build/cjs/components/pagination/Pagination.cjs.map +1 -1
  80. package/build/cjs/components/popover/Popover.cjs.map +1 -1
  81. package/build/cjs/components/progress-bar/Countdown.cjs.map +1 -1
  82. package/build/cjs/components/progress-bar/ProgressBar.cjs.map +1 -1
  83. package/build/cjs/components/radio-button/BaseRadioButton.cjs.map +1 -1
  84. package/build/cjs/components/radio-button/RadioButton.cjs.map +1 -1
  85. package/build/cjs/components/radio-button/RadioButtonGroup.cjs.map +1 -1
  86. package/build/cjs/components/select/NativeSelect.cjs.map +1 -1
  87. package/build/cjs/components/select/Select.cjs.map +1 -1
  88. package/build/cjs/components/system-message/SystemMessage.cjs.map +1 -1
  89. package/build/cjs/components/system-message/common/MessageIcon.cjs.map +1 -1
  90. package/build/cjs/components/table/ExpandableTableRowController.cjs.map +1 -1
  91. package/build/cjs/components/table/Table.cjs.map +1 -1
  92. package/build/cjs/components/table/TableCell.cjs.map +1 -1
  93. package/build/cjs/components/table/TableHead.cjs.map +1 -1
  94. package/build/cjs/components/table/TableHeader.cjs.map +1 -1
  95. package/build/cjs/components/table/TablePagination.cjs.map +1 -1
  96. package/build/cjs/components/table/TableRow.cjs.map +1 -1
  97. package/build/cjs/components/table/utils.cjs.map +1 -1
  98. package/build/cjs/components/tabs/NavTab.cjs.map +1 -1
  99. package/build/cjs/components/tabs/NavTabs.cjs.map +1 -1
  100. package/build/cjs/components/tabs/Tab.cjs.map +1 -1
  101. package/build/cjs/components/tabs/TabList.cjs.map +1 -1
  102. package/build/cjs/components/tabs/TabPanel.cjs.map +1 -1
  103. package/build/cjs/components/tabs/Tabs.cjs.map +1 -1
  104. package/build/cjs/components/text-input/BaseTextArea.cjs.map +1 -1
  105. package/build/cjs/components/text-input/BaseTextInput.cjs.map +1 -1
  106. package/build/cjs/components/text-input/TextArea.cjs.map +1 -1
  107. package/build/cjs/components/text-input/TextInput.cjs.map +1 -1
  108. package/build/cjs/components/toast/Toast.cjs.map +1 -1
  109. package/build/cjs/components/toast/toastContext.cjs.map +1 -1
  110. package/build/cjs/components/toggle-switch/ToggleSlider.cjs.map +1 -1
  111. package/build/cjs/components/toggle-switch/ToggleSwitch.cjs.map +1 -1
  112. package/build/cjs/components/toggle-switch/usePillStyles.cjs.map +1 -1
  113. package/build/cjs/components/tooltip/PopupTip.cjs.map +1 -1
  114. package/build/cjs/components/tooltip/Tooltip.cjs.map +1 -1
  115. package/build/cjs/components/tooltip/TooltipContent.cjs.map +1 -1
  116. package/build/cjs/components/tooltip/TooltipTrigger.cjs.map +1 -1
  117. package/build/cjs/core/index.cjs +1 -1
  118. package/build/cjs/core/tailwind/tailwindPreset.cjs +1 -1
  119. package/build/cjs/core/tailwind/tailwindPreset.cjs.map +1 -1
  120. package/build/cjs/hooks/useAnimatedDetails/useAnimatedDetails.cjs.map +1 -1
  121. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeight.cjs.map +1 -1
  122. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeightBetween.cjs.map +1 -1
  123. package/build/cjs/hooks/useAnimatedHeight/useAutoAnimateHeight.cjs.map +1 -1
  124. package/build/cjs/hooks/useAriaLiveRegion/useAriaLiveRegion.cjs.map +1 -1
  125. package/build/cjs/hooks/useBrowserPreferences/useBrowserPreferences.cjs.map +1 -1
  126. package/build/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
  127. package/build/cjs/hooks/useElementDimensions/useElementDimensions.cjs.map +1 -1
  128. package/build/cjs/hooks/useFocusOutside/useFocusOutside.cjs.map +1 -1
  129. package/build/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
  130. package/build/cjs/hooks/useKeyListener/useKeyListener.cjs.map +1 -1
  131. package/build/cjs/hooks/useListNavigation/useListNavigation.cjs.map +1 -1
  132. package/build/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
  133. package/build/cjs/hooks/useProgressiveImg/useProgressiveImg.cjs.map +1 -1
  134. package/build/cjs/hooks/useScreen/state.cjs.map +1 -1
  135. package/build/cjs/hooks/useScreen/useScreen.cjs +1 -1
  136. package/build/cjs/hooks/useScreen/useScreen.cjs.map +1 -1
  137. package/build/cjs/index.cjs +1 -1
  138. package/build/cjs/utilities/formatters/avstand/formatAvstand.cjs.map +1 -1
  139. package/build/cjs/utilities/formatters/bytes/formatBytes.cjs.map +1 -1
  140. package/build/cjs/utilities/formatters/fodselsnummer/formatFodselsnummer.cjs.map +1 -1
  141. package/build/cjs/utilities/formatters/kontonummer/formatKontonummer.cjs.map +1 -1
  142. package/build/cjs/utilities/formatters/kortnummer/formatKortnummer.cjs.map +1 -1
  143. package/build/cjs/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.cjs.map +1 -1
  144. package/build/cjs/utilities/formatters/telefonnummer/formatTelefonnummer.cjs.map +1 -1
  145. package/build/cjs/utilities/formatters/util/registerWithMask.cjs.map +1 -1
  146. package/build/cjs/utilities/getThemeAndDensity.cjs.map +1 -1
  147. package/build/cjs/utilities/polymorphism/SlotComponent.cjs.map +1 -1
  148. package/build/cjs/utilities/polymorphism/mergeProps.cjs.map +1 -1
  149. package/build/cjs/utilities/tabListener.cjs.map +1 -1
  150. package/build/cjs/utilities/validators/isValidKortnummer/isValidKortnummer.cjs.map +1 -1
  151. package/build/es/components/accordion/AccordionItem.js.map +1 -1
  152. package/build/es/components/autosuggest/Autosuggest.js +1 -1
  153. package/build/es/components/autosuggest/Autosuggest.js.map +1 -1
  154. package/build/es/components/autosuggest/BaseAutosuggest.js +2 -2
  155. package/build/es/components/autosuggest/BaseAutosuggest.js.map +1 -1
  156. package/build/es/components/autosuggest/utils.js.map +1 -1
  157. package/build/es/components/breadcrumb/Breadcrumb.js.map +1 -1
  158. package/build/es/components/button/Button.js.map +1 -1
  159. package/build/es/components/card/NavCard.js.map +1 -1
  160. package/build/es/components/checkbox/Checkbox.js.map +1 -1
  161. package/build/es/components/combobox/Combobox.js.map +1 -1
  162. package/build/es/components/cookie-consent/CookieConsent.js.map +1 -1
  163. package/build/es/components/cookie-consent/CookieConsentContext.js.map +1 -1
  164. package/build/es/components/cookie-consent/cookieConsentUtils.js.map +1 -1
  165. package/build/es/components/datepicker/DatePicker.js.map +1 -1
  166. package/build/es/components/datepicker/internal/Calendar.js.map +1 -1
  167. package/build/es/components/datepicker/internal/calendarReducer.js.map +1 -1
  168. package/build/es/components/datepicker/internal/useCalendar.js.map +1 -1
  169. package/build/es/components/datepicker/internal/utils.js.map +1 -1
  170. package/build/es/components/expander/ExpandablePanelContent.js.map +1 -1
  171. package/build/es/components/expander/Expander.js.map +1 -1
  172. package/build/es/components/expander/deprecated/ExpandSection.js.map +1 -1
  173. package/build/es/components/expander/deprecated/Expander.js.map +1 -1
  174. package/build/es/components/feedback/Feedback.js.map +1 -1
  175. package/build/es/components/feedback/followup/useFollowup.js.map +1 -1
  176. package/build/es/components/feedback/main-question/useMainQuestion.js.map +1 -1
  177. package/build/es/components/feedback/questions/CheckboxQuestion.js.map +1 -1
  178. package/build/es/components/feedback/questions/ContactQuestion.js.map +1 -1
  179. package/build/es/components/feedback/questions/RadioQuestion.js.map +1 -1
  180. package/build/es/components/feedback/questions/SmileyQuestion.js.map +1 -1
  181. package/build/es/components/feedback/questions/TextQuestion.js.map +1 -1
  182. package/build/es/components/feedback/questions/smileyUtils.js.map +1 -1
  183. package/build/es/components/feedback/utils.js.map +1 -1
  184. package/build/es/components/file-input/File.js.map +1 -1
  185. package/build/es/components/file-input/FileInput.js.map +1 -1
  186. package/build/es/components/file-input/internal/Dropzone.js.map +1 -1
  187. package/build/es/components/file-input/internal/Input.js.map +1 -1
  188. package/build/es/components/flex/Flex.js.map +1 -1
  189. package/build/es/components/icon-button/IconButton.js.map +1 -1
  190. package/build/es/components/image/Image.js.map +1 -1
  191. package/build/es/components/image/useImageLoadingStatus.js.map +1 -1
  192. package/build/es/components/input-group/FieldGroup.js.map +1 -1
  193. package/build/es/components/input-group/InputGroup.js.map +1 -1
  194. package/build/es/components/input-group/Label.js.map +1 -1
  195. package/build/es/components/input-group/SupportLabel.js.map +1 -1
  196. package/build/es/components/input-panel/RadioPanel.js.map +1 -1
  197. package/build/es/components/loader/Loader.js.map +1 -1
  198. package/build/es/components/loader/skeletons/SkeletonAnimation.js.map +1 -1
  199. package/build/es/components/loader/skeletons/SkeletonLabel.js.map +1 -1
  200. package/build/es/components/loader/skeletons/SkeletonTextArea.js.map +1 -1
  201. package/build/es/components/logo/Logo.js.map +1 -1
  202. package/build/es/components/logo/LogoStamp.js.map +1 -1
  203. package/build/es/components/menu/Menu.js.map +1 -1
  204. package/build/es/components/menu/MenuItem.js.map +1 -1
  205. package/build/es/components/menu/MenuItemCheckbox.js.map +1 -1
  206. package/build/es/components/menu/useMenuWideEvents.js.map +1 -1
  207. package/build/es/components/message/FormErrorMessage.js.map +1 -1
  208. package/build/es/components/message/Message.js.map +1 -1
  209. package/build/es/components/pagination/Pagination.js.map +1 -1
  210. package/build/es/components/popover/Popover.js.map +1 -1
  211. package/build/es/components/progress-bar/Countdown.js.map +1 -1
  212. package/build/es/components/progress-bar/ProgressBar.js.map +1 -1
  213. package/build/es/components/radio-button/BaseRadioButton.js.map +1 -1
  214. package/build/es/components/radio-button/RadioButtonGroup.js.map +1 -1
  215. package/build/es/components/select/NativeSelect.js.map +1 -1
  216. package/build/es/components/select/Select.js.map +1 -1
  217. package/build/es/components/system-message/SystemMessage.js.map +1 -1
  218. package/build/es/components/system-message/common/MessageIcon.js.map +1 -1
  219. package/build/es/components/table/ExpandableTableRowController.js.map +1 -1
  220. package/build/es/components/table/Table.js.map +1 -1
  221. package/build/es/components/table/TableCell.js.map +1 -1
  222. package/build/es/components/table/TableHead.js.map +1 -1
  223. package/build/es/components/table/TableHeader.js.map +1 -1
  224. package/build/es/components/table/TablePagination.js.map +1 -1
  225. package/build/es/components/table/TableRow.js.map +1 -1
  226. package/build/es/components/table/utils.js.map +1 -1
  227. package/build/es/components/tabs/NavTab.js.map +1 -1
  228. package/build/es/components/tabs/NavTabs.js.map +1 -1
  229. package/build/es/components/tabs/Tab.js.map +1 -1
  230. package/build/es/components/tabs/TabList.js.map +1 -1
  231. package/build/es/components/tabs/Tabs.js.map +1 -1
  232. package/build/es/components/text-input/BaseTextArea.js.map +1 -1
  233. package/build/es/components/text-input/BaseTextInput.js.map +1 -1
  234. package/build/es/components/text-input/TextArea.js.map +1 -1
  235. package/build/es/components/text-input/TextInput.js.map +1 -1
  236. package/build/es/components/toast/Toast.js.map +1 -1
  237. package/build/es/components/toast/toastContext.js.map +1 -1
  238. package/build/es/components/toggle-switch/ToggleSlider.js.map +1 -1
  239. package/build/es/components/toggle-switch/ToggleSwitch.js.map +1 -1
  240. package/build/es/components/toggle-switch/usePillStyles.js.map +1 -1
  241. package/build/es/components/tooltip/Tooltip.js.map +1 -1
  242. package/build/es/components/tooltip/TooltipTrigger.js.map +1 -1
  243. package/build/es/core/index.js +1 -1
  244. package/build/es/core/tailwind/tailwindPreset.js +1 -1
  245. package/build/es/core/tailwind/tailwindPreset.js.map +1 -1
  246. package/build/es/hooks/useAnimatedDetails/useAnimatedDetails.js.map +1 -1
  247. package/build/es/hooks/useAnimatedHeight/useAnimatedHeight.js.map +1 -1
  248. package/build/es/hooks/useAnimatedHeight/useAnimatedHeightBetween.js.map +1 -1
  249. package/build/es/hooks/useAnimatedHeight/useAutoAnimateHeight.js.map +1 -1
  250. package/build/es/hooks/useAriaLiveRegion/useAriaLiveRegion.js.map +1 -1
  251. package/build/es/hooks/useBrowserPreferences/useBrowserPreferences.js.map +1 -1
  252. package/build/es/hooks/useClickOutside/useClickOutside.js.map +1 -1
  253. package/build/es/hooks/useElementDimensions/useElementDimensions.js.map +1 -1
  254. package/build/es/hooks/useFocusOutside/useFocusOutside.js.map +1 -1
  255. package/build/es/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -1
  256. package/build/es/hooks/useKeyListener/useKeyListener.js.map +1 -1
  257. package/build/es/hooks/useListNavigation/useListNavigation.js.map +1 -1
  258. package/build/es/hooks/useMutationObserver/useMutationObserver.js.map +1 -1
  259. package/build/es/hooks/useProgressiveImg/useProgressiveImg.js.map +1 -1
  260. package/build/es/hooks/useScreen/state.js.map +1 -1
  261. package/build/es/hooks/useScreen/useScreen.js +1 -1
  262. package/build/es/hooks/useScreen/useScreen.js.map +1 -1
  263. package/build/es/index.js +1 -1
  264. package/build/es/utilities/formatters/util/registerWithMask.js.map +1 -1
  265. package/build/es/utilities/getThemeAndDensity.js.map +1 -1
  266. package/build/es/utilities/polymorphism/SlotComponent.js.map +1 -1
  267. package/build/es/utilities/polymorphism/mergeProps.js.map +1 -1
  268. package/build/es/utilities/tabListener.js.map +1 -1
  269. package/build/es/utilities/validators/isValidKortnummer/isValidKortnummer.js.map +1 -1
  270. package/package.json +2 -2
  271. package/styles/components/button/button.css +2 -2
  272. package/styles/components/button/button.min.css +1 -1
  273. package/styles/components/checkbox/checkbox.css +4 -4
  274. package/styles/components/checkbox/checkbox.min.css +1 -1
  275. package/styles/components/feedback/feedback.css +2 -2
  276. package/styles/components/feedback/feedback.min.css +1 -1
  277. package/styles/components/input-group/input-group.css +2 -2
  278. package/styles/components/input-group/input-group.min.css +1 -1
  279. package/styles/components/input-panel/checkbox-panel.css +2 -2
  280. package/styles/components/input-panel/checkbox-panel.min.css +1 -1
  281. package/styles/components/input-panel/radio-panel.css +2 -2
  282. package/styles/components/input-panel/radio-panel.min.css +1 -1
  283. package/styles/components/loader/loader.css +6 -6
  284. package/styles/components/loader/loader.min.css +1 -1
  285. package/styles/components/loader/skeleton-loader.css +5 -5
  286. package/styles/components/loader/skeleton-loader.min.css +1 -1
  287. package/styles/components/message/message.css +2 -2
  288. package/styles/components/message/message.min.css +1 -1
  289. package/styles/components/progress-bar/progress-bar.css +2 -2
  290. package/styles/components/progress-bar/progress-bar.min.css +1 -1
  291. package/styles/components/radio-button/radio-button.css +2 -2
  292. package/styles/components/radio-button/radio-button.min.css +1 -1
  293. package/styles/components/system-message/system-message.css +2 -2
  294. package/styles/components/system-message/system-message.min.css +1 -1
  295. package/styles/components/toast/toast.css +4 -4
  296. package/styles/components/toast/toast.min.css +1 -1
  297. package/styles/styles.css +37 -37
  298. package/styles/styles.min.css +1 -1
  299. package/build/cjs/core/tailwind/plugins/typographyPlugin.cjs +0 -2
  300. package/build/cjs/core/tailwind/plugins/typographyPlugin.cjs.map +0 -1
  301. package/build/cjs/core/tailwind/plugins/typographyPlugin.d.cts +0 -2
  302. package/build/es/core/tailwind/plugins/typographyPlugin.d.ts +0 -2
  303. package/build/es/core/tailwind/plugins/typographyPlugin.js +0 -2
  304. package/build/es/core/tailwind/plugins/typographyPlugin.js.map +0 -1
  305. package/build/tailwindPreset-CSQrgZ57.cjs +0 -2
  306. package/build/tailwindPreset-CSQrgZ57.cjs.map +0 -1
  307. package/build/tailwindPreset-D4TYL0kz.js +0 -2
  308. package/build/tailwindPreset-D4TYL0kz.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ControllerButton.cjs","sources":["../../../../src/components/autosuggest/ControllerButton.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { CloseIcon } from \"../icon/icons/CloseIcon.js\";\nimport { SearchIcon } from \"../icon/icons/SearchIcon.js\";\nimport { IconButton } from \"../icon-button/IconButton.js\";\n\ninterface Props {\n clearSelection: () => void;\n hasSelectedItem: boolean;\n onClick: () => void;\n}\n\nconst ControllerButton: FC<Props> = ({\n hasSelectedItem,\n clearSelection,\n onClick,\n ...downshiftProps\n}) => (\n <IconButton\n {...downshiftProps}\n className=\"jkl-text-input-action-button\"\n aria-label={hasSelectedItem ? \"Fjern valg\" : \"Vis valg\"}\n title={hasSelectedItem ? \"Fjern valg\" : \"Vis valg\"}\n onClick={hasSelectedItem ? clearSelection : onClick}\n >\n {hasSelectedItem ? <CloseIcon /> : <SearchIcon />}\n </IconButton>\n);\n\nexport default ControllerButton;\n"],"names":["hasSelectedItem","clearSelection","onClick","downshiftProps","jsx","IconButton","className","title","children","CloseIcon","SearchIcon"],"mappings":"+LAWoC,EAChCA,gBAAAA,EACAC,eAAAA,EACAC,QAAAA,KACGC,KAEHC,EAAAA,IAACC,EAAAA,WAAA,IACOF,EACJG,UAAU,+BACV,aAAYN,EAAkB,aAAe,WAC7CO,MAAOP,EAAkB,aAAe,WACxCE,QAASF,EAAkBC,EAAiBC,EAE3CM,SAAkBR,EAAAI,MAACK,EAAAA,UAAU,CAAA,SAAMC,EAAAA,WAAW,CAAA"}
1
+ {"version":3,"file":"ControllerButton.cjs","sources":["../../../../src/components/autosuggest/ControllerButton.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { CloseIcon } from \"../icon/icons/CloseIcon.js\";\nimport { SearchIcon } from \"../icon/icons/SearchIcon.js\";\nimport { IconButton } from \"../icon-button/IconButton.js\";\n\ninterface Props {\n clearSelection: () => void;\n hasSelectedItem: boolean;\n onClick: () => void;\n}\n\nconst ControllerButton: FC<Props> = ({\n hasSelectedItem,\n clearSelection,\n onClick,\n ...downshiftProps\n}) => (\n <IconButton\n {...downshiftProps}\n className=\"jkl-text-input-action-button\"\n aria-label={hasSelectedItem ? \"Fjern valg\" : \"Vis valg\"}\n title={hasSelectedItem ? \"Fjern valg\" : \"Vis valg\"}\n onClick={hasSelectedItem ? clearSelection : onClick}\n >\n {hasSelectedItem ? <CloseIcon /> : <SearchIcon />}\n </IconButton>\n);\n\nexport default ControllerButton;\n"],"names":["hasSelectedItem","clearSelection","onClick","downshiftProps","jsx","IconButton","className","title","children","CloseIcon","SearchIcon"],"mappings":"+LAWoC,EAChCA,gBAAAA,EACAC,eAAAA,EACAC,QAAAA,KACGC,KAEHC,EAAAA,IAACC,EAAAA,WAAA,IACOF,EACJG,UAAU,+BACV,aAAYN,EAAkB,aAAe,WAC7CO,MAAOP,EAAkB,aAAe,WACxCE,QAASF,EAAkBC,EAAiBC,EAE3CM,SAAkBR,EAAAI,EAAAA,IAACK,EAAUA,UAAA,CAAA,SAAMC,EAAWA,WAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sources":["../../../../src/components/autosuggest/utils.ts"],"sourcesContent":["import { matchSorter } from \"match-sorter\";\n\nexport function filter<T>(\n allItems: T[],\n inputValue: string | null,\n keys?: string[],\n): T[] {\n const options = keys ? { keys } : {};\n if (!inputValue) {\n return allItems;\n }\n return matchSorter(allItems, inputValue, options);\n}\n"],"names":["allItems","inputValue","keys","options","matchSorter"],"mappings":"+HAEgB,SACZA,EACAC,EACAC,GAEA,MAAMC,EAAUD,EAAO,CAAEA,KAAAA,GAAS,CAAC,EACnC,OAAKD,EAGEG,cAAYJ,EAAUC,EAAYE,GAF9BH,CAGf"}
1
+ {"version":3,"file":"utils.cjs","sources":["../../../../src/components/autosuggest/utils.ts"],"sourcesContent":["import { matchSorter } from \"match-sorter\";\n\nexport function filter<T>(\n allItems: T[],\n inputValue: string | null,\n keys?: string[],\n): T[] {\n const options = keys ? { keys } : {};\n if (!inputValue) {\n return allItems;\n }\n return matchSorter(allItems, inputValue, options);\n}\n"],"names":["allItems","inputValue","keys","options","matchSorter"],"mappings":"+HAEgB,SACZA,EACAC,EACAC,GAEA,MAAMC,EAAUD,EAAO,CAAEA,KAAAA,GAAS,CAAA,EAClC,OAAKD,EAGEG,cAAYJ,EAAUC,EAAYE,GAF9BH,CAGf"}
@@ -1 +1 @@
1
- {"version":3,"file":"Breadcrumb.cjs","sources":["../../../../src/components/breadcrumb/Breadcrumb.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { Density, WithChildren } from \"../../core/types.js\";\nimport { BreadcrumbItemProps } from \"./BreadcrumbItem.js\";\n\nexport interface BreadcrumbProps extends WithChildren {\n className?: string;\n density?: Density;\n}\n\nexport const Breadcrumb = ({\n className,\n children,\n density,\n ...rest\n}: BreadcrumbProps): JSX.Element => {\n const numberOfChildren = React.Children.count(children);\n return (\n <nav\n aria-label=\"Sti\"\n className={clsx(\"jkl-breadcrumb\", className)}\n data-layout-density={density}\n {...rest}\n >\n <ol className=\"jkl-breadcrumb__list\">\n {React.Children.map(children, (child, index) => {\n const isLastElement = index + 1 === numberOfChildren;\n return (\n <>\n {React.isValidElement<BreadcrumbItemProps>(child)\n ? React.cloneElement<BreadcrumbItemProps>(\n child,\n {\n isLastElement,\n },\n )\n : child}\n {!isLastElement && (\n <span\n className=\"jkl-breadcrumb__item-separator\"\n aria-hidden=\"true\"\n >\n ›\n </span>\n )}\n </>\n );\n })}\n </ol>\n </nav>\n );\n};\n"],"names":["className","children","density","rest","numberOfChildren","React","Children","count","jsx","clsx","map","child","index","isLastElement","jsxs","Fragment","isValidElement","cloneElement"],"mappings":"mMAU0B,EACtBA,UAAAA,EACAC,SAAAA,EACAC,QAAAA,KACGC,MAEH,MAAMC,EAAmBC,EAAMC,SAASC,MAAMN,GAE1C,OAAAO,EAAAA,IAAC,MAAA,CACG,aAAW,MACXR,UAAWS,EAAAA,KAAK,iBAAkBT,GAClC,sBAAqBE,KACjBC,EAEJF,SAAAO,EAAAA,IAAC,KAAG,CAAAR,UAAU,uBACTC,SAAAI,EAAMC,SAASI,IAAIT,GAAU,CAACU,EAAOC,KAC5B,MAAAC,EAAgBD,EAAQ,IAAMR,EACpC,OAESU,EAAAA,KAAAC,WAAA,CAAAd,SAAA,CAAMI,EAAAW,eAAoCL,GACrCN,EAAMY,aACFN,EACA,CACIE,cAAAA,IAGRF,GACJE,GACEL,EAAAA,IAAC,OAAA,CACGR,UAAU,iCACV,cAAY,OACfC,SAAA,QAIT,OAIhB"}
1
+ {"version":3,"file":"Breadcrumb.cjs","sources":["../../../../src/components/breadcrumb/Breadcrumb.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { Density, WithChildren } from \"../../core/types.js\";\nimport { BreadcrumbItemProps } from \"./BreadcrumbItem.js\";\n\nexport interface BreadcrumbProps extends WithChildren {\n className?: string;\n density?: Density;\n}\n\nexport const Breadcrumb = ({\n className,\n children,\n density,\n ...rest\n}: BreadcrumbProps): JSX.Element => {\n const numberOfChildren = React.Children.count(children);\n return (\n <nav\n aria-label=\"Sti\"\n className={clsx(\"jkl-breadcrumb\", className)}\n data-layout-density={density}\n {...rest}\n >\n <ol className=\"jkl-breadcrumb__list\">\n {React.Children.map(children, (child, index) => {\n const isLastElement = index + 1 === numberOfChildren;\n return (\n <>\n {React.isValidElement<BreadcrumbItemProps>(child)\n ? React.cloneElement<BreadcrumbItemProps>(\n child,\n {\n isLastElement,\n },\n )\n : child}\n {!isLastElement && (\n <span\n className=\"jkl-breadcrumb__item-separator\"\n aria-hidden=\"true\"\n >\n ›\n </span>\n )}\n </>\n );\n })}\n </ol>\n </nav>\n );\n};\n"],"names":["className","children","density","rest","numberOfChildren","React","Children","count","jsx","clsx","map","child","index","isLastElement","jsxs","Fragment","isValidElement","cloneElement"],"mappings":"mMAU0B,EACtBA,UAAAA,EACAC,SAAAA,EACAC,QAAAA,KACGC,MAEH,MAAMC,EAAmBC,EAAMC,SAASC,MAAMN,GAE1C,OAAAO,EAAAA,IAAC,MAAA,CACG,aAAW,MACXR,UAAWS,EAAAA,KAAK,iBAAkBT,GAClC,sBAAqBE,KACjBC,EAEJF,SAAAO,EAAAA,IAAC,KAAG,CAAAR,UAAU,uBACTC,SAAAI,EAAMC,SAASI,IAAIT,GAAU,CAACU,EAAOC,KAC5B,MAAAC,EAAgBD,EAAQ,IAAMR,EACpC,OAESU,EAAAA,KAAAC,WAAA,CAAAd,SAAA,CAAMI,EAAAW,eAAoCL,GACrCN,EAAMY,aACFN,EACA,CACIE,cAAAA,IAGRF,GACJE,GACEL,EAAAA,IAAC,OAAA,CACGR,UAAU,iCACV,cAAY,OACfC,SAAA,QAIT,OAGZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Button.cjs","sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import cn from \"clsx\";\nimport React, {\n ButtonHTMLAttributes,\n type TouchEvent,\n useCallback,\n} from \"react\";\nimport { useAriaLiveRegion } from \"../../hooks/useAriaLiveRegion/useAriaLiveRegion.js\";\nimport { PolymorphicRef } from \"../../utilities/polymorphism/polymorphism.js\";\nimport { Loader } from \"../loader/Loader.js\";\nimport { ButtonComponent, ButtonProps } from \"./types.js\";\n\nexport const Button = React.forwardRef(function Button<\n ElementType extends React.ElementType = \"button\",\n>(props: ButtonProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n as = \"button\",\n children,\n className,\n density,\n onTouchStart,\n loader,\n icon,\n iconPosition = \"left\",\n iconLeft,\n iconRight,\n variant = \"secondary\",\n ...rest\n } = props;\n\n const Component = as;\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n React.Children.count(children) === 0 &&\n !props[\"aria-label\"] &&\n !props[\"aria-labelledby\"] &&\n !props.title\n ) {\n console.warn(\n \"Når du lager en Button uten synlig tekst må du huske å gi den et navn med enten aria-label, aria-labelledby eller title\",\n );\n }\n\n const handleTouch = useCallback(\n (event: TouchEvent<HTMLButtonElement>) => {\n onTouchStart && onTouchStart(event);\n\n const target = event.target as HTMLButtonElement;\n if (target && !target.disabled && event.targetTouches.length) {\n const Xcoord =\n event.targetTouches[0].clientX -\n target.getBoundingClientRect().x;\n const Ycoord =\n event.targetTouches[0].clientY -\n target.getBoundingClientRect().y;\n target.style.setProperty(\n \"--jkl-touch-xcoord\",\n Xcoord.toPrecision(4) + \"px\",\n );\n target.style.setProperty(\n \"--jkl-touch-ycoord\",\n Ycoord.toPrecision(4) + \"px\",\n );\n target.classList.add(\"jkl-button--pressed\");\n\n setTimeout(() => {\n target.classList.remove(\"jkl-button--pressed\");\n target.style.removeProperty(\"--jkl-touch-xcoord\");\n target.style.removeProperty(\"--jkl-touch-ycoord\");\n }, 400);\n }\n },\n [onTouchStart],\n );\n\n const ariaLive = useAriaLiveRegion(loader?.showLoader);\n const showLoader = Boolean(children) && Boolean(loader?.showLoader);\n\n return (\n <Component\n {...ariaLive}\n data-loading={showLoader}\n data-density={density}\n className={cn(\"jkl-button\", \"jkl-button--\" + variant, className)}\n disabled={as === \"button\" ? loader?.showLoader : undefined}\n onTouchStart={handleTouch}\n {...rest}\n ref={ref}\n >\n <div className=\"jkl-button__label\">\n {iconLeft && iconLeft}\n {icon && iconPosition === \"left\" && icon}\n {children && (\n <span className=\"jkl-button__text\">{children}</span>\n )}\n {iconRight && iconRight}\n {icon && iconPosition === \"right\" && icon}\n </div>\n\n {children && (\n <Loader\n className=\"jkl-button__loader\"\n variant=\"medium\"\n textDescription={\n loader?.textDescription || \"Vennligst vent\"\n }\n aria-hidden={!loader?.showLoader}\n />\n )}\n </Component>\n );\n}) as ButtonComponent;\n\nexport function PrimaryButton<ElementType extends React.ElementType = \"button\">(\n props: Omit<ButtonProps<ElementType>, \"variant\" | \"onClick\" | \"as\"> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"onClick\">,\n) {\n const buttonProps = {\n ...props,\n variant: \"primary\",\n } as ButtonProps<ElementType>;\n return <Button {...buttonProps} />;\n}\n\nexport function SecondaryButton<\n ElementType extends React.ElementType = \"button\",\n>(\n props: Omit<ButtonProps<ElementType>, \"variant\" | \"onClick\" | \"as\"> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"onClick\">,\n) {\n const buttonProps = {\n ...props,\n variant: \"secondary\",\n } as ButtonProps<ElementType>;\n return <Button {...buttonProps} />;\n}\n\nexport function TertiaryButton<\n ElementType extends React.ElementType = \"button\",\n>(\n props: Omit<ButtonProps<ElementType>, \"variant\" | \"onClick\" | \"as\"> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"onClick\">,\n) {\n const buttonProps = {\n ...props,\n variant: \"tertiary\",\n } as ButtonProps<ElementType>;\n return <Button {...buttonProps} />;\n}\n\nexport function GhostButton<ElementType extends React.ElementType = \"button\">(\n props: Omit<ButtonProps<ElementType>, \"variant\" | \"loader\">,\n) {\n const buttonProps = {\n ...props,\n variant: \"ghost\",\n } as ButtonProps<ElementType>;\n return <Button {...buttonProps} />;\n}\n"],"names":["Button","React","forwardRef","props","ref","as","children","className","density","onTouchStart","loader","icon","iconPosition","iconLeft","iconRight","variant","rest","Component","process","env","NODE_ENV","Children","count","title","console","warn","handleTouch","useCallback","event","target","disabled","targetTouches","length","Xcoord","clientX","getBoundingClientRect","x","Ycoord","clientY","y","style","setProperty","toPrecision","classList","add","setTimeout","remove","removeProperty","ariaLive","useAriaLiveRegion","showLoader","jsxs","cn","jsx","Loader","textDescription","buttonProps"],"mappings":"mRAWaA,EAASC,EAAMC,YAAW,SAErCC,EAAiCC,GACzB,MACFC,GAAAA,EAAK,SACLC,SAAAA,EACAC,UAAAA,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AAyB,SAAjBC,GAA2BD,EACnCL,GACG+C,EAAAA,IAAC,OAAK,CAAA9C,UAAU,mBAAoBD,SAAAA,IAEvCQ,GAAaA,EACbH,GAAyB,UAAjBC,GAA4BD,KAGxCL,GACG+C,EAAAA,IAACC,EAAAA,OAAA,CACG/C,UAAU,qBACVQ,QAAQ,SACRwC,iBACI,MAAA7C,OAAAA,EAAAA,EAAQ6C,kBAAmB,iBAE/B,gBAAc,MAAA7C,GAAAA,EAAQwC,gBAK1C,yCAuCO,SACH/C,GAEA,MAAMqD,EAAc,IACbrD,EACHY,QAAS,SAEN,OAAAsC,MAACrD,EAAQ,IAAGwD,GACvB,wBA7CO,SACHrD,GAGA,MAAMqD,EAAc,IACbrD,EACHY,QAAS,WAEN,OAAAsC,MAACrD,EAAQ,IAAGwD,GACvB,0BAEO,SAGHrD,GAGA,MAAMqD,EAAc,IACbrD,EACHY,QAAS,aAEN,OAAAsC,MAACrD,EAAQ,IAAGwD,GACvB,yBAEO,SAGHrD,GAGA,MAAMqD,EAAc,IACbrD,EACHY,QAAS,YAEN,OAAAsC,MAACrD,EAAQ,IAAGwD,GACvB"}
1
+ {"version":3,"file":"Button.cjs","sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import cn from \"clsx\";\nimport React, {\n ButtonHTMLAttributes,\n type TouchEvent,\n useCallback,\n} from \"react\";\nimport { useAriaLiveRegion } from \"../../hooks/useAriaLiveRegion/useAriaLiveRegion.js\";\nimport { PolymorphicRef } from \"../../utilities/polymorphism/polymorphism.js\";\nimport { Loader } from \"../loader/Loader.js\";\nimport { ButtonComponent, ButtonProps } from \"./types.js\";\n\nexport const Button = React.forwardRef(function Button<\n ElementType extends React.ElementType = \"button\",\n>(props: ButtonProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n as = \"button\",\n children,\n className,\n density,\n onTouchStart,\n loader,\n icon,\n iconPosition = \"left\",\n iconLeft,\n iconRight,\n variant = \"secondary\",\n ...rest\n } = props;\n\n const Component = as;\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n React.Children.count(children) === 0 &&\n !props[\"aria-label\"] &&\n !props[\"aria-labelledby\"] &&\n !props.title\n ) {\n console.warn(\n \"Når du lager en Button uten synlig tekst må du huske å gi den et navn med enten aria-label, aria-labelledby eller title\",\n );\n }\n\n const handleTouch = useCallback(\n (event: TouchEvent<HTMLButtonElement>) => {\n onTouchStart && onTouchStart(event);\n\n const target = event.target as HTMLButtonElement;\n if (target && !target.disabled && event.targetTouches.length) {\n const Xcoord =\n event.targetTouches[0].clientX -\n target.getBoundingClientRect().x;\n const Ycoord =\n event.targetTouches[0].clientY -\n target.getBoundingClientRect().y;\n target.style.setProperty(\n \"--jkl-touch-xcoord\",\n Xcoord.toPrecision(4) + \"px\",\n );\n target.style.setProperty(\n \"--jkl-touch-ycoord\",\n Ycoord.toPrecision(4) + \"px\",\n );\n target.classList.add(\"jkl-button--pressed\");\n\n setTimeout(() => {\n target.classList.remove(\"jkl-button--pressed\");\n target.style.removeProperty(\"--jkl-touch-xcoord\");\n target.style.removeProperty(\"--jkl-touch-ycoord\");\n }, 400);\n }\n },\n [onTouchStart],\n );\n\n const ariaLive = useAriaLiveRegion(loader?.showLoader);\n const showLoader = Boolean(children) && Boolean(loader?.showLoader);\n\n return (\n <Component\n {...ariaLive}\n data-loading={showLoader}\n data-density={density}\n className={cn(\"jkl-button\", \"jkl-button--\" + variant, className)}\n disabled={as === \"button\" ? loader?.showLoader : undefined}\n onTouchStart={handleTouch}\n {...rest}\n ref={ref}\n >\n <div className=\"jkl-button__label\">\n {iconLeft && iconLeft}\n {icon && iconPosition === \"left\" && icon}\n {children && (\n <span className=\"jkl-button__text\">{children}</span>\n )}\n {iconRight && iconRight}\n {icon && iconPosition === \"right\" && icon}\n </div>\n\n {children && (\n <Loader\n className=\"jkl-button__loader\"\n variant=\"medium\"\n textDescription={\n loader?.textDescription || \"Vennligst vent\"\n }\n aria-hidden={!loader?.showLoader}\n />\n )}\n </Component>\n );\n}) as ButtonComponent;\n\nexport function PrimaryButton<ElementType extends React.ElementType = \"button\">(\n props: Omit<ButtonProps<ElementType>, \"variant\" | \"onClick\" | \"as\"> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"onClick\">,\n) {\n const buttonProps = {\n ...props,\n variant: \"primary\",\n } as ButtonProps<ElementType>;\n return <Button {...buttonProps} />;\n}\n\nexport function SecondaryButton<\n ElementType extends React.ElementType = \"button\",\n>(\n props: Omit<ButtonProps<ElementType>, \"variant\" | \"onClick\" | \"as\"> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"onClick\">,\n) {\n const buttonProps = {\n ...props,\n variant: \"secondary\",\n } as ButtonProps<ElementType>;\n return <Button {...buttonProps} />;\n}\n\nexport function TertiaryButton<\n ElementType extends React.ElementType = \"button\",\n>(\n props: Omit<ButtonProps<ElementType>, \"variant\" | \"onClick\" | \"as\"> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"onClick\">,\n) {\n const buttonProps = {\n ...props,\n variant: \"tertiary\",\n } as ButtonProps<ElementType>;\n return <Button {...buttonProps} />;\n}\n\nexport function GhostButton<ElementType extends React.ElementType = \"button\">(\n props: Omit<ButtonProps<ElementType>, \"variant\" | \"loader\">,\n) {\n const buttonProps = {\n ...props,\n variant: \"ghost\",\n } as ButtonProps<ElementType>;\n return <Button {...buttonProps} />;\n}\n"],"names":["Button","React","forwardRef","props","ref","as","children","className","density","onTouchStart","loader","icon","iconPosition","iconLeft","iconRight","variant","rest","Component","process","env","NODE_ENV","Children","count","title","console","warn","handleTouch","useCallback","event","target","disabled","targetTouches","length","Xcoord","clientX","getBoundingClientRect","x","Ycoord","clientY","y","style","setProperty","toPrecision","classList","add","setTimeout","remove","removeProperty","ariaLive","useAriaLiveRegion","showLoader","jsxs","cn","jsx","Loader","textDescription","buttonProps"],"mappings":"mRAWaA,EAASC,EAAMC,YAAW,SAErCC,EAAiCC,GACzB,MACFC,GAAAA,EAAK,SACLC,SAAAA,EACAC,UAAAA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GAAyB,SAAjBC,GAA2BD,EACnCL,GACG+C,EAAAA,IAAC,OAAK,CAAA9C,UAAU,mBAAoBD,SAAAA,IAEvCQ,GAAaA,EACbH,GAAyB,UAAjBC,GAA4BD,KAGxCL,GACG+C,EAAAA,IAACC,EAAAA,OAAA,CACG/C,UAAU,qBACVQ,QAAQ,SACRwC,iBACI,MAAA7C,OAAAA,EAAAA,EAAQ6C,kBAAmB,iBAE/B,gBAAc,MAAA7C,GAAAA,EAAQwC,gBAK1C,yCAuCO,SACH/C,GAEA,MAAMqD,EAAc,IACbrD,EACHY,QAAS,SAEN,OAAAsC,EAAAA,IAACrD,EAAQ,IAAGwD,GACvB,wBA7CO,SACHrD,GAGA,MAAMqD,EAAc,IACbrD,EACHY,QAAS,WAEN,OAAAsC,EAAAA,IAACrD,EAAQ,IAAGwD,GACvB,0BAEO,SAGHrD,GAGA,MAAMqD,EAAc,IACbrD,EACHY,QAAS,aAEN,OAAAsC,EAAAA,IAACrD,EAAQ,IAAGwD,GACvB,yBAEO,SAGHrD,GAGA,MAAMqD,EAAc,IACbrD,EACHY,QAAS,YAEN,OAAAsC,EAAAA,IAACrD,EAAQ,IAAGwD,GACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Card.cjs","sources":["../../../../src/components/card/Card.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { AsChildProps } from \"../../utilities/polymorphism/as-child.js\";\nimport {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport { SlotComponent } from \"../../utilities/polymorphism/SlotComponent.js\";\n\nexport const CARD_PADDINGS = [\"s\", \"m\", \"l\", \"xl\"] as const;\nexport type CardPadding = (typeof CARD_PADDINGS)[number];\nexport const CARD_VARIANTS = [\"outlined\", \"high\", \"low\"] as const;\nexport type CardVariant = (typeof CARD_VARIANTS)[number];\n\nexport type CardProps<ElementType extends React.ElementType> =\n PolymorphicPropsWithRef<\n ElementType,\n {\n className?: string;\n /**\n * Setter padding på kortet. Tilsvarer samme property i Figma.\n * @default \"s\"\n */\n padding?: CardPadding;\n /**\n * Angir hvilken kortvariant du vil bruke. Velg en variant som gir god kontrast\n * til bakgrunnen på siden, slik at det er enkelt å skille innholdet fra hverandre.\n * @default \"high\"\n */\n variant?: CardVariant;\n /**\n * Angir om kortet visuelt skal fremstå som klikkbart. Du må selv rendre\n * kortet som et klikkbart element (f.eks. `<a>` eller en `<Link>` fra\n * et ruting-bibliotek) og gi det en `href` eller `onClick`-handler.\n * HUSK: Sett aria-label for at støtteverktøy, som skjermlesere, ikke\n * skal lese alt innholdet i kortet.\n */\n clickable?: boolean;\n }\n >;\n\ntype CardComponent = <ElementType extends React.ElementType = \"div\">(\n props: CardProps<ElementType> & AsChildProps,\n) => React.ReactElement | null;\n\n/**\n * En allsidig kortkomponent som brukes for å gruppere innhold på en side.\n * Komponenten rendres til vanlig som en `<div>`, men du kan velge å rendre\n * den som andre elementer eller komponenter der du trenger annen semantikk\n * eller funksjonalitet.\n */\nexport const Card = React.forwardRef(function Card<\n ElementType extends React.ElementType = \"div\",\n>(props: CardProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n className,\n clickable = false,\n padding = \"s\",\n variant = \"high\",\n asChild,\n as = \"div\",\n ...componentProps\n } = props;\n\n const Component = asChild ? SlotComponent : as;\n\n return (\n <Component\n data-testid=\"jkl-card\"\n data-clickable={clickable}\n data-padding={padding}\n className={clsx(\"jkl-card\", `jkl-card--${variant}`, className)}\n {...componentProps}\n ref={ref}\n />\n );\n}) as CardComponent;\n"],"names":["Card","React","forwardRef","props","ref","className","clickable","padding","variant","asChild","as","componentProps","Component","SlotComponent","jsx","clsx"],"mappings":"4OAmDaA,EAAOC,EAAMC,YAAW,SAEnCC,EAA+BC,GACvB,MACFC,UAAAA,EACAC,UAAAA,GAAY,EACZC,QAAAA,EAAU,IACVC,QAAAA,EAAU,OACVC,QAAAA,EACAC,GAAAA,EAAK,SACFC,GACHR,EAEES,EAAYH,EAAUI,EAAAA,cAAgBH,EAGxC,OAAAI,EAAAA,IAACF,EAAA,CACG,cAAY,WACZ,iBAAgBN,EAChB,eAAcC,EACdF,UAAWU,EAAKA,KAAA,WAAY,aAAaP,IAAWH,MAChDM,EACJP,IAAAA,GAGZ,0BAnE6B,CAAC,IAAK,IAAK,IAAK,4BAEhB,CAAC,WAAY,OAAQ"}
1
+ {"version":3,"file":"Card.cjs","sources":["../../../../src/components/card/Card.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { AsChildProps } from \"../../utilities/polymorphism/as-child.js\";\nimport {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport { SlotComponent } from \"../../utilities/polymorphism/SlotComponent.js\";\n\nexport const CARD_PADDINGS = [\"s\", \"m\", \"l\", \"xl\"] as const;\nexport type CardPadding = (typeof CARD_PADDINGS)[number];\nexport const CARD_VARIANTS = [\"outlined\", \"high\", \"low\"] as const;\nexport type CardVariant = (typeof CARD_VARIANTS)[number];\n\nexport type CardProps<ElementType extends React.ElementType> =\n PolymorphicPropsWithRef<\n ElementType,\n {\n className?: string;\n /**\n * Setter padding på kortet. Tilsvarer samme property i Figma.\n * @default \"s\"\n */\n padding?: CardPadding;\n /**\n * Angir hvilken kortvariant du vil bruke. Velg en variant som gir god kontrast\n * til bakgrunnen på siden, slik at det er enkelt å skille innholdet fra hverandre.\n * @default \"high\"\n */\n variant?: CardVariant;\n /**\n * Angir om kortet visuelt skal fremstå som klikkbart. Du må selv rendre\n * kortet som et klikkbart element (f.eks. `<a>` eller en `<Link>` fra\n * et ruting-bibliotek) og gi det en `href` eller `onClick`-handler.\n * HUSK: Sett aria-label for at støtteverktøy, som skjermlesere, ikke\n * skal lese alt innholdet i kortet.\n */\n clickable?: boolean;\n }\n >;\n\ntype CardComponent = <ElementType extends React.ElementType = \"div\">(\n props: CardProps<ElementType> & AsChildProps,\n) => React.ReactElement | null;\n\n/**\n * En allsidig kortkomponent som brukes for å gruppere innhold på en side.\n * Komponenten rendres til vanlig som en `<div>`, men du kan velge å rendre\n * den som andre elementer eller komponenter der du trenger annen semantikk\n * eller funksjonalitet.\n */\nexport const Card = React.forwardRef(function Card<\n ElementType extends React.ElementType = \"div\",\n>(props: CardProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n className,\n clickable = false,\n padding = \"s\",\n variant = \"high\",\n asChild,\n as = \"div\",\n ...componentProps\n } = props;\n\n const Component = asChild ? SlotComponent : as;\n\n return (\n <Component\n data-testid=\"jkl-card\"\n data-clickable={clickable}\n data-padding={padding}\n className={clsx(\"jkl-card\", `jkl-card--${variant}`, className)}\n {...componentProps}\n ref={ref}\n />\n );\n}) as CardComponent;\n"],"names":["Card","React","forwardRef","props","ref","className","clickable","padding","variant","asChild","as","componentProps","Component","SlotComponent","jsx","clsx"],"mappings":"4OAmDaA,EAAOC,EAAMC,YAAW,SAEnCC,EAA+BC,GACvB,MACFC,UAAAA,EACAC,UAAAA,GAAY,EACZC,QAAAA,EAAU,IACVC,QAAAA,EAAU,OACVC,QAAAA,EACAC,GAAAA,EAAK,SACFC,GACHR,EAEES,EAAYH,EAAUI,EAAgBA,cAAAH,EAGxC,OAAAI,EAAAA,IAACF,EAAA,CACG,cAAY,WACZ,iBAAgBN,EAChB,eAAcC,EACdF,UAAWU,EAAKA,KAAA,WAAY,aAAaP,IAAWH,MAChDM,EACJP,IAAAA,GAGZ,0BAnE6B,CAAC,IAAK,IAAK,IAAK,4BAEhB,CAAC,WAAY,OAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"CardImage.cjs","sources":["../../../../src/components/card/CardImage.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { AsChildProps } from \"../../utilities/polymorphism/as-child.js\";\nimport {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport { SlotComponent } from \"../../utilities/polymorphism/SlotComponent.js\";\n\nexport type CardImageProps<ElementType extends React.ElementType> =\n PolymorphicPropsWithRef<\n ElementType,\n {\n /**\n * Legger til riktig negativ margin avhengig av hvor i kortet bildet\n * skal plasseres. Margin justeres automatisk etter padding i kortet.\n * @default \"top\"\n */\n placement?: \"top\" | \"middle\" | \"bottom\";\n }\n >;\n\ntype CardImageComponent = <ElementType extends React.ElementType = \"img\">(\n props: CardImageProps<ElementType>,\n) => React.ReactElement | null;\n\n/**\n * Bildekomponent som kan brukes i `Card` for å sørge for at bildet\n * blør helt ut i kantene av kortet. Rendres normalt som et `<img>`-\n * element, men du kan overstyre dette med `as` dersom du f.eks. har\n * en egen komponent for å håndtere responsive bilder.\n */\nexport const CardImage = React.forwardRef(function CardImage<\n ElementType extends React.ElementType = \"img\",\n>(\n {\n as,\n asChild,\n className,\n placement = \"top\",\n ...imageProps\n }: CardImageProps<ElementType> & AsChildProps,\n ref?: PolymorphicRef<ElementType>,\n) {\n const Component = asChild ? SlotComponent : as || \"img\";\n\n return (\n <Component\n ref={ref}\n className={clsx(\n \"jkl-card-image\",\n `jkl-card-image--${placement}`,\n className,\n )}\n {...imageProps}\n />\n );\n}) as CardImageComponent;\n"],"names":["CardImage","React","forwardRef","as","asChild","className","placement","imageProps","ref","Component","SlotComponent","jsx","clsx"],"mappings":"4OAgCaA,EAAYC,EAAMC,YAAW,UAIlCC,GAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,EAAY,SACTC,GAEPC,GAEM,MAAAC,EAAYL,EAAUM,EAAAA,cAAgBP,GAAM,MAG9C,OAAAQ,EAAAA,IAACF,EAAA,CACGD,IAAAA,EACAH,UAAWO,EAAAA,KACP,iBACA,mBAAmBN,IACnBD,MAEAE,GAGhB"}
1
+ {"version":3,"file":"CardImage.cjs","sources":["../../../../src/components/card/CardImage.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { AsChildProps } from \"../../utilities/polymorphism/as-child.js\";\nimport {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport { SlotComponent } from \"../../utilities/polymorphism/SlotComponent.js\";\n\nexport type CardImageProps<ElementType extends React.ElementType> =\n PolymorphicPropsWithRef<\n ElementType,\n {\n /**\n * Legger til riktig negativ margin avhengig av hvor i kortet bildet\n * skal plasseres. Margin justeres automatisk etter padding i kortet.\n * @default \"top\"\n */\n placement?: \"top\" | \"middle\" | \"bottom\";\n }\n >;\n\ntype CardImageComponent = <ElementType extends React.ElementType = \"img\">(\n props: CardImageProps<ElementType>,\n) => React.ReactElement | null;\n\n/**\n * Bildekomponent som kan brukes i `Card` for å sørge for at bildet\n * blør helt ut i kantene av kortet. Rendres normalt som et `<img>`-\n * element, men du kan overstyre dette med `as` dersom du f.eks. har\n * en egen komponent for å håndtere responsive bilder.\n */\nexport const CardImage = React.forwardRef(function CardImage<\n ElementType extends React.ElementType = \"img\",\n>(\n {\n as,\n asChild,\n className,\n placement = \"top\",\n ...imageProps\n }: CardImageProps<ElementType> & AsChildProps,\n ref?: PolymorphicRef<ElementType>,\n) {\n const Component = asChild ? SlotComponent : as || \"img\";\n\n return (\n <Component\n ref={ref}\n className={clsx(\n \"jkl-card-image\",\n `jkl-card-image--${placement}`,\n className,\n )}\n {...imageProps}\n />\n );\n}) as CardImageComponent;\n"],"names":["CardImage","React","forwardRef","as","asChild","className","placement","imageProps","ref","Component","SlotComponent","jsx","clsx"],"mappings":"4OAgCaA,EAAYC,EAAMC,YAAW,UAIlCC,GAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,EAAY,SACTC,GAEPC,GAEM,MAAAC,EAAYL,EAAUM,gBAAgBP,GAAM,MAG9C,OAAAQ,EAAAA,IAACF,EAAA,CACGD,IAAAA,EACAH,UAAWO,EAAAA,KACP,iBACA,mBAAmBN,IACnBD,MAEAE,GAGhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"NavCard.cjs","sources":["../../../../src/components/card/NavCard.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { AnchorHTMLAttributes, ElementType, FC } from \"react\";\nimport { Density, WithChildren } from \"../../core/types.js\";\nimport { Image, ImageProps } from \"../image/Image.js\";\nimport {\n ErrorTag,\n InfoTag,\n SuccessTag,\n Tag,\n TagProps,\n WarningTag,\n} from \"../tag/Tag.js\";\nimport { CardTag, PaddingOptions, TagType } from \"./types.js\";\nimport { getPaddingStyles } from \"./utils.js\";\n\n/**\n * Bruk denne komponenten for å legge til ekstra informasjon i NavCard.\n * Innholdet blir rendret med skillelinje, og tekststil \"small\"\n */\nexport const InfoBlock: FC<WithChildren> = ({ children }) => (\n <div className=\"jkl-nav-card__info\">{children}</div>\n);\n\nexport interface NavCardProps\n extends PaddingOptions,\n AnchorHTMLAttributes<HTMLAnchorElement> {\n tag?: CardTag | Array<CardTag>;\n title: string;\n href?: string;\n to?: string;\n external?: boolean;\n description?: string;\n image?: Omit<ImageProps, \"className\">;\n className?: string;\n /**\n * Overstyr hvilken komponent som skal brukes, for eksempel hvis du har en Link-komponent fra en router.\n * @default \"a\"\n */\n component?: ElementType;\n density?: Density;\n}\n\nconst getTag = (type?: TagType) => {\n switch (type) {\n case \"info\":\n return InfoTag;\n case \"success\":\n return SuccessTag;\n case \"warning\":\n return WarningTag;\n case \"error\":\n return ErrorTag;\n default:\n return Tag;\n }\n};\nconst NavCardTag = ({\n text,\n type,\n density,\n}: CardTag & Pick<TagProps, \"density\">) => {\n const CardTag = getTag(type);\n return <CardTag density={density}>{text}</CardTag>;\n};\n\nexport const NavCard: FC<NavCardProps> = React.forwardRef<\n HTMLAnchorElement,\n NavCardProps\n>((props, ref) => {\n const {\n component = \"a\",\n padding = \"l\",\n image,\n tag,\n title,\n external,\n description,\n children,\n className,\n density,\n ...rest\n } = props;\n\n const Component = component;\n\n const tagArr = !tag ? undefined : Array.isArray(tag) ? tag : [tag];\n\n return (\n <Component\n ref={ref}\n aria-label={title}\n className={clsx(\"jkl-nav-card\", className)}\n data-density={density}\n {...rest}\n >\n {image && <Image className=\"jkl-nav-card__image\" {...image} />}\n <div\n className=\"jkl-nav-card__content\"\n style={getPaddingStyles(padding)}\n >\n {tagArr && (\n <div className=\"jkl-nav-card__tag-wrapper\">\n {tagArr.map((t, index) => (\n <NavCardTag\n type={t.type}\n text={t.text}\n key={index}\n />\n ))}\n </div>\n )}\n <div>\n <p\n className={clsx(\n \"jkl-nav-card__link\",\n external ? \"jkl-nav-card__link--external\" : \"\",\n )}\n >\n {title}\n </p>\n {description && (\n <p className=\"jkl-nav-card__description jkl-spacing-xs--top\">\n {description}\n </p>\n )}\n </div>\n {children}\n </div>\n </Component>\n );\n});\n\nNavCard.displayName = \"NavCard\";\n"],"names":["NavCardTag","text","type","density","CardTag","InfoTag","SuccessTag","WarningTag","ErrorTag","Tag","getTag","children","NavCard","React","forwardRef","props","ref","component","padding","image","tag","title","external","description","className","rest","Component","tagArr","Array","isArray","jsxs","clsx","jsx","Image","style","getPaddingStyles","map","t","index","displayName"],"mappings":"qQAwDMA,EAAa,EACfC,KAAAA,EACAC,KAAAA,EACAC,QAAAA,MAEMC,MAAAA,EAnBMF,KACZ,OAAQA,GACJ,IAAK,OACM,OAAAG,EAAAA,QACX,IAAK,UACM,OAAAC,EAAAA,WACX,IAAK,UACM,OAAAC,EAAAA,WACX,IAAK,QACM,OAAAC,EAAAA,SACX,QACW,OAAAC,EAAAA,IAAA,EAQCC,CAAOR,GACvB,OAAQE,EAAAA,IAAAA,EAAA,CAAQD,QAAAA,EAAmBQ,SAAKV,GAAA,EAG/BW,EAA4BC,EAAMC,YAG7C,CAACC,EAAOC,KACA,MACFC,UAAAA,EAAY,IACZC,QAAAA,EAAU,IACVC,MAAAA,EACAC,IAAAA,EACAC,MAAAA,EACAC,SAAAA,EACAC,YAAAA,EACAZ,SAAAA,EACAa,UAAAA,EACArB,QAAAA,KACGsB,GACHV,EAEEW,EAAYT,EAEZU,EAAUP,EAAkBQ,MAAMC,QAAQT,GAAOA,EAAM,CAACA,QAAxC,EAGlB,OAAAU,EAAAA,KAACJ,EAAA,CACGV,IAAAA,EACA,aAAYK,EACZG,UAAWO,EAAAA,KAAK,eAAgBP,GAChC,eAAcrB,KACVsB,EAEHd,SAAA,CAAAQ,GAAUa,EAAAA,IAAAC,QAAA,CAAMT,UAAU,yBAA0BL,IACrDW,EAAAA,KAAC,MAAA,CACGN,UAAU,wBACVU,MAAOC,mBAAiBjB,GAEvBP,SAAA,CACGgB,GAAAK,EAAAA,IAAC,OAAIR,UAAU,4BACVb,WAAOyB,KAAI,CAACC,EAAGC,IACZN,EAAAA,IAAChC,EAAA,CACGE,KAAMmC,EAAEnC,KACRD,KAAMoC,EAAEpC,MACHqC,cAKpB,MACG,CAAA3B,SAAA,CAAAqB,EAAAA,IAAC,IAAA,CACGR,UAAWO,EAAAA,KACP,qBACAT,EAAW,+BAAiC,IAG/CX,SAAAU,IAEJE,GACGS,EAAAA,IAAC,IAAE,CAAAR,UAAU,gDACRb,SACLY,OAGPZ,OAET,IAIRC,EAAQ2B,YAAc,4BAjHqB,EAAG5B,SAAAA,KACzCqB,EAAAA,IAAA,MAAA,CAAIR,UAAU,qBAAsBb,SAAAA"}
1
+ {"version":3,"file":"NavCard.cjs","sources":["../../../../src/components/card/NavCard.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { AnchorHTMLAttributes, ElementType, FC } from \"react\";\nimport { Density, WithChildren } from \"../../core/types.js\";\nimport { Image, ImageProps } from \"../image/Image.js\";\nimport {\n ErrorTag,\n InfoTag,\n SuccessTag,\n Tag,\n TagProps,\n WarningTag,\n} from \"../tag/Tag.js\";\nimport { CardTag, PaddingOptions, TagType } from \"./types.js\";\nimport { getPaddingStyles } from \"./utils.js\";\n\n/**\n * Bruk denne komponenten for å legge til ekstra informasjon i NavCard.\n * Innholdet blir rendret med skillelinje, og tekststil \"small\"\n */\nexport const InfoBlock: FC<WithChildren> = ({ children }) => (\n <div className=\"jkl-nav-card__info\">{children}</div>\n);\n\nexport interface NavCardProps\n extends PaddingOptions,\n AnchorHTMLAttributes<HTMLAnchorElement> {\n tag?: CardTag | Array<CardTag>;\n title: string;\n href?: string;\n to?: string;\n external?: boolean;\n description?: string;\n image?: Omit<ImageProps, \"className\">;\n className?: string;\n /**\n * Overstyr hvilken komponent som skal brukes, for eksempel hvis du har en Link-komponent fra en router.\n * @default \"a\"\n */\n component?: ElementType;\n density?: Density;\n}\n\nconst getTag = (type?: TagType) => {\n switch (type) {\n case \"info\":\n return InfoTag;\n case \"success\":\n return SuccessTag;\n case \"warning\":\n return WarningTag;\n case \"error\":\n return ErrorTag;\n default:\n return Tag;\n }\n};\nconst NavCardTag = ({\n text,\n type,\n density,\n}: CardTag & Pick<TagProps, \"density\">) => {\n const CardTag = getTag(type);\n return <CardTag density={density}>{text}</CardTag>;\n};\n\nexport const NavCard: FC<NavCardProps> = React.forwardRef<\n HTMLAnchorElement,\n NavCardProps\n>((props, ref) => {\n const {\n component = \"a\",\n padding = \"l\",\n image,\n tag,\n title,\n external,\n description,\n children,\n className,\n density,\n ...rest\n } = props;\n\n const Component = component;\n\n const tagArr = !tag ? undefined : Array.isArray(tag) ? tag : [tag];\n\n return (\n <Component\n ref={ref}\n aria-label={title}\n className={clsx(\"jkl-nav-card\", className)}\n data-density={density}\n {...rest}\n >\n {image && <Image className=\"jkl-nav-card__image\" {...image} />}\n <div\n className=\"jkl-nav-card__content\"\n style={getPaddingStyles(padding)}\n >\n {tagArr && (\n <div className=\"jkl-nav-card__tag-wrapper\">\n {tagArr.map((t, index) => (\n <NavCardTag\n type={t.type}\n text={t.text}\n key={index}\n />\n ))}\n </div>\n )}\n <div>\n <p\n className={clsx(\n \"jkl-nav-card__link\",\n external ? \"jkl-nav-card__link--external\" : \"\",\n )}\n >\n {title}\n </p>\n {description && (\n <p className=\"jkl-nav-card__description jkl-spacing-xs--top\">\n {description}\n </p>\n )}\n </div>\n {children}\n </div>\n </Component>\n );\n});\n\nNavCard.displayName = \"NavCard\";\n"],"names":["NavCardTag","text","type","density","CardTag","InfoTag","SuccessTag","WarningTag","ErrorTag","Tag","getTag","children","NavCard","React","forwardRef","props","ref","component","padding","image","tag","title","external","description","className","rest","Component","tagArr","Array","isArray","jsxs","clsx","jsx","Image","style","getPaddingStyles","map","t","index","displayName"],"mappings":"qQAwDMA,EAAa,EACfC,KAAAA,EACAC,KAAAA,EACAC,QAAAA,MAEMC,MAAAA,EAnBMF,KACZ,OAAQA,GACJ,IAAK,OACM,OAAAG,UACX,IAAK,UACM,OAAAC,aACX,IAAK,UACM,OAAAC,aACX,IAAK,QACM,OAAAC,WACX,QACW,OAAAC,MACf,EAOgBC,CAAOR,GACvB,OAAQE,EAAAA,IAAAA,EAAA,CAAQD,QAAAA,EAAmBQ,SAAKV,GAAA,EAG/BW,EAA4BC,EAAMC,YAG7C,CAACC,EAAOC,KACA,MACFC,UAAAA,EAAY,IACZC,QAAAA,EAAU,IACVC,MAAAA,EACAC,IAAAA,EACAC,MAAAA,EACAC,SAAAA,EACAC,YAAAA,EACAZ,SAAAA,EACAa,UAAAA,EACArB,QAAAA,KACGsB,GACHV,EAEEW,EAAYT,EAEZU,EAAUP,EAAkBQ,MAAMC,QAAQT,GAAOA,EAAM,CAACA,QAAxC,EAGlB,OAAAU,EAAAA,KAACJ,EAAA,CACGV,IAAAA,EACA,aAAYK,EACZG,UAAWO,EAAAA,KAAK,eAAgBP,GAChC,eAAcrB,KACVsB,EAEHd,SAAA,CAAAQ,GAAUa,EAAAA,IAAAC,QAAA,CAAMT,UAAU,yBAA0BL,IACrDW,EAAAA,KAAC,MAAA,CACGN,UAAU,wBACVU,MAAOC,mBAAiBjB,GAEvBP,SAAA,CACGgB,GAAAK,EAAAA,IAAC,OAAIR,UAAU,4BACVb,WAAOyB,KAAI,CAACC,EAAGC,IACZN,EAAAA,IAAChC,EAAA,CACGE,KAAMmC,EAAEnC,KACRD,KAAMoC,EAAEpC,MACHqC,cAKpB,MACG,CAAA3B,SAAA,CAAAqB,EAAAA,IAAC,IAAA,CACGR,UAAWO,EAAAA,KACP,qBACAT,EAAW,+BAAiC,IAG/CX,SAAAU,IAEJE,GACGS,EAAAA,IAAC,IAAE,CAAAR,UAAU,gDACRb,SACLY,OAGPZ,OACL,IAKZC,EAAQ2B,YAAc,4BAjHqB,EAAG5B,SAAAA,KACzCqB,EAAAA,IAAA,MAAA,CAAIR,UAAU,qBAAsBb,SAAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n ReactNode,\n forwardRef,\n ChangeEventHandler,\n FocusEventHandler,\n InputHTMLAttributes,\n useEffect,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport { DataTestAutoId, Density } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\n\nexport interface CheckboxProps\n extends DataTestAutoId,\n InputHTMLAttributes<HTMLInputElement> {\n children: ReactNode;\n name: string;\n value: string;\n checked?: boolean;\n inline?: boolean;\n className?: string;\n density?: Density;\n invalid?: boolean;\n onChange?: ChangeEventHandler<HTMLInputElement>;\n onFocus?: FocusEventHandler<HTMLInputElement>;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n indeterminate?: boolean;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(\n (props, ref) => {\n const {\n id,\n children,\n invalid,\n className,\n inline = false,\n density,\n \"data-testautoid\": testAutoId,\n checked,\n indeterminate,\n ...rest\n } = props;\n\n const inputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => inputRef.current!, []);\n\n const inputId = useId(id || \"jkl-checkbox\", { generateSuffix: !id });\n\n useEffect(() => {\n if (\n checked === true &&\n indeterminate === true &&\n process.env.NODE_ENV !== \"production\"\n ) {\n console.warn(\n \"A Checkbox can not be both checked and indeterminate, and will be treated as checked\",\n );\n }\n if (inputRef.current) {\n inputRef.current.indeterminate = !checked && !!indeterminate;\n }\n }, [checked, indeterminate]);\n\n return (\n <div\n className={clsx(\"jkl-checkbox\", className, {\n \"jkl-checkbox--inline\": inline,\n \"jkl-checkbox--error\": invalid,\n })}\n data-density={density}\n >\n <input\n id={inputId}\n ref={inputRef}\n className=\"jkl-checkbox__input\"\n data-testid=\"jkl-checkbox-input\"\n aria-invalid={invalid}\n type=\"checkbox\"\n data-testautoid={testAutoId}\n checked={checked}\n {...rest}\n />\n <label htmlFor={inputId} className=\"jkl-checkbox__label\">\n <span className=\"jkl-checkbox__mark\">\n <span className=\"jkl-checkbox__indeterminate-mark\" />\n <span className=\"jkl-checkbox__check-mark\" />\n </span>\n <span className=\"jkl-checkbox__text\">{children}</span>\n </label>\n </div>\n );\n },\n);\n\nCheckbox.displayName = \"Checkbox\";\n"],"names":["Checkbox","forwardRef","props","ref","id","children","invalid","className","inline","density","testAutoId","checked","indeterminate","rest","inputRef","useRef","useImperativeHandle","current","inputId","useId","generateSuffix","useEffect","process","env","NODE_ENV","console","warn","jsxs","clsx","jsx","type","htmlFor","displayName"],"mappings":"yNA+BaA,EAAWC,EAAAA,YACpB,CAACC,EAAOC,KACE,MACFC,GAAAA,EACAC,SAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,OAAAA,GAAS,EACTC,QAAAA,EACA,kBAAmBC,EACnBC,QAAAA,EACAC,cAAAA,KACGC,GACHX,EAEEY,EAAWC,SAAyB,MAC1CC,EAAAA,oBAAoBb,GAAK,IAAMW,EAASG,SAAU,IAE5C,MAAAC,EAAUC,EAAAA,MAAMf,GAAM,eAAgB,CAAEgB,gBAAiBhB,IAE/DiB,OAAAA,EAAAA,WAAU,MAEU,IAAZV,IACkB,IAAlBC,GACyB,eAAzBU,QAAQC,IAAIC,UAEJC,QAAAC,KACJ,wFAGJZ,EAASG,UACTH,EAASG,QAAQL,eAAiBD,KAAaC,KAEpD,CAACD,EAASC,IAGTe,EAAAA,KAAC,MAAA,CACGpB,UAAWqB,EAAAA,KAAK,eAAgBrB,EAAW,CACvC,uBAAwBC,EACxB,sBAAuBF,IAE3B,eAAcG,EAEdJ,SAAA,CAAAwB,EAAAA,IAAC,QAAA,CACGzB,GAAIc,EACJf,IAAKW,EACLP,UAAU,sBACV,cAAY,qBACZ,eAAcD,EACdwB,KAAK,WACL,kBAAiBpB,EACjBC,QAAAA,KACIE,IAEPc,EAAAA,KAAA,QAAA,CAAMI,QAASb,EAASX,UAAU,sBAC/BF,SAAA,CAACsB,EAAAA,KAAA,OAAA,CAAKpB,UAAU,qBACZF,SAAA,CAACwB,EAAAA,IAAA,OAAA,CAAKtB,UAAU,qCAChBsB,EAAAA,IAAC,OAAK,CAAAtB,UAAU,gCAEnBsB,EAAAA,IAAA,OAAA,CAAKtB,UAAU,qBAAsBF,SAAAA,SAE9C,IAKZL,EAASgC,YAAc"}
1
+ {"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n ReactNode,\n forwardRef,\n ChangeEventHandler,\n FocusEventHandler,\n InputHTMLAttributes,\n useEffect,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport { DataTestAutoId, Density } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\n\nexport interface CheckboxProps\n extends DataTestAutoId,\n InputHTMLAttributes<HTMLInputElement> {\n children: ReactNode;\n name: string;\n value: string;\n checked?: boolean;\n inline?: boolean;\n className?: string;\n density?: Density;\n invalid?: boolean;\n onChange?: ChangeEventHandler<HTMLInputElement>;\n onFocus?: FocusEventHandler<HTMLInputElement>;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n indeterminate?: boolean;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(\n (props, ref) => {\n const {\n id,\n children,\n invalid,\n className,\n inline = false,\n density,\n \"data-testautoid\": testAutoId,\n checked,\n indeterminate,\n ...rest\n } = props;\n\n const inputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => inputRef.current!, []);\n\n const inputId = useId(id || \"jkl-checkbox\", { generateSuffix: !id });\n\n useEffect(() => {\n if (\n checked === true &&\n indeterminate === true &&\n process.env.NODE_ENV !== \"production\"\n ) {\n console.warn(\n \"A Checkbox can not be both checked and indeterminate, and will be treated as checked\",\n );\n }\n if (inputRef.current) {\n inputRef.current.indeterminate = !checked && !!indeterminate;\n }\n }, [checked, indeterminate]);\n\n return (\n <div\n className={clsx(\"jkl-checkbox\", className, {\n \"jkl-checkbox--inline\": inline,\n \"jkl-checkbox--error\": invalid,\n })}\n data-density={density}\n >\n <input\n id={inputId}\n ref={inputRef}\n className=\"jkl-checkbox__input\"\n data-testid=\"jkl-checkbox-input\"\n aria-invalid={invalid}\n type=\"checkbox\"\n data-testautoid={testAutoId}\n checked={checked}\n {...rest}\n />\n <label htmlFor={inputId} className=\"jkl-checkbox__label\">\n <span className=\"jkl-checkbox__mark\">\n <span className=\"jkl-checkbox__indeterminate-mark\" />\n <span className=\"jkl-checkbox__check-mark\" />\n </span>\n <span className=\"jkl-checkbox__text\">{children}</span>\n </label>\n </div>\n );\n },\n);\n\nCheckbox.displayName = \"Checkbox\";\n"],"names":["Checkbox","forwardRef","props","ref","id","children","invalid","className","inline","density","testAutoId","checked","indeterminate","rest","inputRef","useRef","useImperativeHandle","current","inputId","useId","generateSuffix","useEffect","process","env","NODE_ENV","console","warn","jsxs","clsx","jsx","type","htmlFor","displayName"],"mappings":"yNA+BaA,EAAWC,EAAAA,YACpB,CAACC,EAAOC,KACE,MACFC,GAAAA,EACAC,SAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,OAAAA,GAAS,EACTC,QAAAA,EACA,kBAAmBC,EACnBC,QAAAA,EACAC,cAAAA,KACGC,GACHX,EAEEY,EAAWC,SAAyB,MAC1CC,EAAAA,oBAAoBb,GAAK,IAAMW,EAASG,SAAU,IAE5C,MAAAC,EAAUC,QAAMf,GAAM,eAAgB,CAAEgB,gBAAiBhB,IAE/DiB,OAAAA,EAAAA,WAAU,MAEU,IAAZV,IACkB,IAAlBC,GACyB,eAAzBU,QAAQC,IAAIC,UAEJC,QAAAC,KACJ,wFAGJZ,EAASG,UACTH,EAASG,QAAQL,eAAiBD,KAAaC,KAEpD,CAACD,EAASC,IAGTe,EAAAA,KAAC,MAAA,CACGpB,UAAWqB,EAAAA,KAAK,eAAgBrB,EAAW,CACvC,uBAAwBC,EACxB,sBAAuBF,IAE3B,eAAcG,EAEdJ,SAAA,CAAAwB,EAAAA,IAAC,QAAA,CACGzB,GAAIc,EACJf,IAAKW,EACLP,UAAU,sBACV,cAAY,qBACZ,eAAcD,EACdwB,KAAK,WACL,kBAAiBpB,EACjBC,QAAAA,KACIE,IAEPc,EAAAA,KAAA,QAAA,CAAMI,QAASb,EAASX,UAAU,sBAC/BF,SAAA,CAACsB,EAAAA,KAAA,OAAA,CAAKpB,UAAU,qBACZF,SAAA,CAACwB,EAAAA,IAAA,OAAA,CAAKtB,UAAU,qCAChBsB,EAAAA,IAAC,OAAK,CAAAtB,UAAU,gCAEnBsB,EAAAA,IAAA,OAAA,CAAKtB,UAAU,qBAAsBF,SAAAA,SAC1C,IAMhBL,EAASgC,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.cjs","sources":["../../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n ChangeEvent,\n FC,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Density } from \"../../core/types.js\";\nimport { useAnimatedHeight } from \"../../hooks/useAnimatedHeight/useAnimatedHeight.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { useListNavigation } from \"../../hooks/useListNavigation/useListNavigation.js\";\nimport { ValuePair } from \"../../utilities/valuePair.js\";\nimport { Chip } from \"../chip/Chip.js\";\nimport { ArrowVerticalAnimated } from \"../icon/icons/animated/ArrowVerticalAnimated.js\";\nimport { CheckIcon } from \"../icon/icons/CheckIcon.js\";\nimport { IconButton } from \"../icon-button/IconButton.js\";\nimport { InputGroup, InputGroupProps } from \"../input-group/InputGroup.js\";\nimport { LabelProps } from \"../input-group/Label.js\";\nimport { Tooltip } from \"../tooltip/Tooltip.js\";\nimport { TooltipContent } from \"../tooltip/TooltipContent.js\";\nimport { TooltipTrigger } from \"../tooltip/TooltipTrigger.js\";\n\nexport type ComboboxValuePair = ValuePair & {\n tagLabel?: string;\n isMarked?: boolean;\n};\n\nexport function getComboboxValuePair(\n item: string | ComboboxValuePair,\n): ComboboxValuePair {\n return typeof item === \"string\" ? { value: item, label: item } : item;\n}\n\nexport interface ComboboxPartialChangeEvent\n extends Partial<Omit<ChangeEvent<HTMLElement>, \"target\">> {\n type: \"change\" | \"blur\";\n target: {\n name: string;\n value: string;\n selectedOptions: Array<ValuePair>;\n };\n}\n\nexport type ComboboxChangeEventHandler = (\n event: ComboboxPartialChangeEvent,\n) => void;\n\nexport interface ComboboxProps extends InputGroupProps {\n id?: string;\n placeholder?: string;\n labelProps?: Omit<\n LabelProps,\n \"children\" | \"density\" | \"htmlFor\" | \"standAlone\"\n >;\n items: Array<ValuePair>;\n noMatchingOption?: string;\n label: string;\n name: string;\n value?: Array<ValuePair>;\n density?: Density;\n width?: string;\n helpLabel?: string;\n errorLabel?: string;\n className?: string;\n invalid?: boolean;\n hasTagHover?: boolean;\n onChange: ComboboxChangeEventHandler;\n onBlur?: ComboboxChangeEventHandler;\n onFocus?: ComboboxChangeEventHandler;\n}\n\nexport const Combobox: FC<ComboboxProps> = ({\n id,\n placeholder,\n items,\n onChange,\n onFocus,\n onBlur,\n value,\n label,\n noMatchingOption,\n labelProps,\n helpLabel,\n errorLabel,\n width,\n density,\n name,\n className,\n invalid,\n hasTagHover,\n}) => {\n const listId = useId(id || \"jkl-combobox\", { generateSuffix: !id });\n const labelId = `${listId}_label`;\n const buttonId = `${listId}_button`;\n const inputId = `${listId}_search-input`;\n\n const [selectedValue, setSelectedValue] = useState<\n Array<ComboboxValuePair>\n >(value || []);\n const [showMenu, setShowMenu] = useState<boolean>(false);\n const [searchValue, setSearchValue] = useState<string>(\"\");\n const [noResults, setNoResults] = useState(false);\n const [marked, setMarked] = useState<boolean>(false);\n\n const searchRef = useRef<HTMLInputElement>(null);\n const inputRef = useRef<HTMLDivElement>(null);\n const focusInsideRef = useRef(false);\n\n useEffect(() => {\n setSearchValue(\"\");\n if (showMenu && searchRef.current) {\n searchRef.current.focus();\n }\n }, [showMenu]);\n\n useEffect(() => {\n setSelectedValue((prev) => value || prev);\n }, [value]);\n\n // Funksjon for å stile valgt element\n const isSelected = (option: ValuePair) => {\n if (!selectedValue) {\n return false;\n } else {\n return selectedValue.some((value) => value.value === option.value);\n }\n };\n\n // Fjerne ett eller flere valg\n const removeOption = useCallback(\n (option: string) => {\n return selectedValue.filter((value) => value.value !== option);\n },\n [selectedValue],\n );\n\n const onTagRemove = useCallback(\n (\n e:\n | React.MouseEvent<HTMLButtonElement, globalThis.MouseEvent>\n | React.KeyboardEvent<HTMLInputElement>,\n option: string,\n ) => {\n let newValue = removeOption(option);\n setSelectedValue(newValue);\n onChange({\n type: \"change\",\n target: { name, value: option, selectedOptions: newValue },\n });\n e.stopPropagation();\n\n if (newValue.length === 0) {\n setMarked(false);\n }\n },\n [removeOption, setSelectedValue, onChange, name, setMarked],\n );\n\n // Håndtere valgt verdi i listen\n const onItemClick = useCallback(\n (option: string) => {\n let newValue: Array<ValuePair>;\n\n if (selectedValue.some((value) => value.value === option)) {\n newValue = removeOption(option);\n } else {\n const item = items.find((i) => i.value === option);\n newValue = [...selectedValue, item as ValuePair];\n }\n searchRef.current?.focus();\n setSelectedValue(newValue);\n onChange({\n type: \"change\",\n target: { name, value: option, selectedOptions: newValue },\n });\n },\n [selectedValue, setSelectedValue, onChange, name, removeOption, items],\n );\n\n // Funksjon for søk\n const onSearch = (e: {\n target: { value: React.SetStateAction<string> };\n }) => {\n searchRef.current?.focus();\n setShowMenu(true);\n setSearchValue(e.target.value);\n };\n\n const options = useMemo(() => {\n if (!searchValue) {\n return items;\n }\n\n const filteredOptions = items.filter(\n (option) =>\n option.label.toLowerCase().indexOf(searchValue.toLowerCase()) >=\n 0,\n );\n\n setNoResults(filteredOptions.length === 0);\n\n return filteredOptions;\n }, [searchValue, items]);\n\n // Det første elementet i listen skal være aktivt fram til brukeren klikker på noe annet\n const [activeDescendant, setActiveDescendant] = useState<\n string | undefined\n >(options[0]?.value ? `${listId}-${options[0]?.value}` : undefined);\n\n // Håndtere arrow-state\n const isPointingDown = !showMenu;\n\n // Lukk meny med ESC\n useEffect(() => {\n const handleEscape = (e: globalThis.KeyboardEvent) => {\n if (e.key === \"Escape\" && showMenu) {\n setShowMenu(false);\n }\n };\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"keydown\", handleEscape);\n }\n return () => {\n if (typeof window !== \"undefined\" && showMenu) {\n window.removeEventListener(\"keydown\", handleEscape);\n }\n };\n }, [setShowMenu, showMenu]);\n\n // Fokushåndtering\n const handleFocusPlacement = useCallback((isOpen: boolean) => {\n if (isOpen) {\n if (searchRef.current) {\n searchRef.current.focus();\n }\n } else {\n if (focusInsideRef.current && inputRef.current) {\n inputRef.current.focus();\n }\n }\n }, []);\n\n const handleFocus = useCallback(() => {\n if (!focusInsideRef.current) {\n if (onFocus) {\n onFocus({\n type: \"change\",\n target: {\n name,\n value: selectedValue?.[0].value || \"\",\n selectedOptions: selectedValue,\n },\n });\n }\n focusInsideRef.current = true;\n setShowMenu(true);\n }\n }, [onFocus, selectedValue, name]);\n\n const [dropdownRef] = useAnimatedHeight<HTMLDivElement>(showMenu, {\n onFirstVisible: handleFocusPlacement,\n onTransitionEnd: handleFocusPlacement,\n });\n\n useListNavigation({ ref: dropdownRef });\n\n const componentRootElementRef = useRef<HTMLDivElement>(null);\n\n const handleBlur = useCallback(\n (\n e: FocusEvent<\n HTMLDivElement | HTMLInputElement | HTMLButtonElement\n >,\n ) => {\n const componentRootElement = componentRootElementRef.current;\n const nextFocusIsInsideComponent =\n componentRootElement &&\n componentRootElement.contains(e.relatedTarget as Node);\n if (!nextFocusIsInsideComponent) {\n setSearchValue(\"\");\n\n if (onBlur) {\n onBlur({\n type: \"blur\",\n target: {\n name,\n value: selectedValue?.[0]?.value || \"\",\n selectedOptions: selectedValue,\n },\n });\n inputRef.current?.dispatchEvent(\n new Event(\"focusout\", { bubbles: true }),\n );\n }\n focusInsideRef.current = false;\n setShowMenu(false);\n }\n },\n [onBlur, name, selectedValue],\n );\n\n const handleMouseOver = useCallback((e: MouseEvent<HTMLButtonElement>) => {\n // Ved mouseOver på options flytter vi fokus til dem for å unngå \"dobbel fokus\"\n // der det ser ut som to forskjellige elementer er fokusert/hovered samtidig\n (e.target as HTMLButtonElement).focus({ preventScroll: true });\n }, []);\n\n // Tastaturnavigasjon\n const handleSearchOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n e.stopPropagation();\n const listElement = dropdownRef.current;\n if (listElement) {\n listElement\n .querySelector<HTMLButtonElement>('[role=\"option\"]')\n ?.focus();\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n setShowMenu(false);\n }\n\n if ((e.metaKey && e.key === \"a\") || (e.ctrlKey && e.key === \"a\")) {\n e.preventDefault();\n e.stopPropagation();\n const updatedSelectedValue = selectedValue.map((item) => ({\n ...item,\n isMarked: true,\n }));\n setMarked(true);\n setSelectedValue(updatedSelectedValue);\n } else if (e.key === \"Backspace\") {\n e.stopPropagation();\n setMarked(false);\n\n // Sjekk om selectedValue er markert\n const selectedValueIsMarked = selectedValue.some(\n (item) => item.isMarked,\n );\n\n if (selectedValueIsMarked) {\n const updatedSelectedValue = selectedValue.filter(\n (item) => !item.isMarked,\n );\n setSelectedValue(updatedSelectedValue);\n setSearchValue(\"\");\n } else if (selectedValue.length > 0 && searchValue === \"\") {\n // Hvis ingen items er markert, fjern siste valgte item\n onTagRemove(\n e,\n selectedValue[selectedValue.length - 1].value,\n );\n }\n }\n },\n [selectedValue, searchValue, dropdownRef, onTagRemove],\n );\n\n const handleOptionOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Tab\") {\n if (searchRef.current) {\n e.preventDefault();\n e.stopPropagation();\n\n if (e.shiftKey) {\n searchRef.current.focus();\n } else {\n setShowMenu(false);\n searchRef.current.focus();\n }\n }\n } else if (e.key === \"ArrowUp\") {\n if (dropdownRef.current && searchRef.current) {\n // Can't be based on index since the first item might be filtered out\n const firstVisible = dropdownRef.current.querySelector(\n '[role=\"option\"]:not([hidden])',\n );\n if (\n e.currentTarget.id === firstVisible?.id &&\n searchRef.current\n ) {\n searchRef.current.focus();\n }\n }\n }\n },\n [setShowMenu, dropdownRef],\n );\n\n const hasSelection = selectedValue.length >= 1;\n\n const renderSelectedOption = useCallback(\n (option: ComboboxValuePair) => (\n <Chip\n key={option.value}\n data-testid=\"jkl-chip\"\n aria-label={`Fjern ${option.tagLabel}`}\n className={`jkl-combobox__selected-option ${\n marked && \"jkl-combobox__selected-option--marked\"\n }`}\n variant=\"input\"\n onClick={(e) => {\n if (searchRef.current) {\n searchRef.current.focus();\n }\n onTagRemove(e, option.value);\n }}\n onBlur={handleBlur}\n >\n {option.tagLabel ? option.tagLabel : option.label}\n </Chip>\n ),\n [handleBlur, onTagRemove, marked],\n );\n\n return (\n <InputGroup\n label={label}\n id={inputId}\n ref={componentRootElementRef}\n data-testid=\"jkl-combobox\"\n className={clsx(\"jkl-combobox\", className, {\n \"jkl-combobox--invalid\": !!errorLabel || invalid,\n \"jkl-combobox--menu-open\": showMenu,\n \"jkl-combobox--menu-closed\": !showMenu && hasSelection,\n })}\n labelProps={{\n id: labelId,\n ...labelProps,\n }}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n density={density}\n render={(inputProps) => (\n <div\n className={clsx(\"jkl-combobox__wrapper\", {\n \"jkl-combobox__wrapper--active-value\": hasSelection,\n })}\n style={{ width }}\n tabIndex={-1}\n onFocus={handleFocus}\n onBlur={handleBlur}\n >\n <div\n className=\"jkl-combobox__chips\"\n data-testid=\"jkl-combobox__chips\"\n >\n {selectedValue\n .map(getComboboxValuePair)\n .map((option) => {\n return hasTagHover ? (\n <Tooltip key={option.value}>\n <TooltipTrigger>\n {renderSelectedOption(option)}\n </TooltipTrigger>\n <TooltipContent>\n {option.label}\n </TooltipContent>\n </Tooltip>\n ) : (\n renderSelectedOption(option)\n );\n })}\n <input\n {...inputProps}\n className=\"jkl-combobox__search-input\"\n onChange={onSearch}\n data-testid=\"jkl-combobox__search-input\"\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleSearchOnKeyDown}\n value={searchValue}\n ref={searchRef}\n aria-controls={listId}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={showMenu}\n placeholder={\n selectedValue.length > 0 ? \"\" : placeholder\n }\n autoComplete=\"off\"\n />\n </div>\n\n <div\n className=\"jkl-combobox__menu\"\n role=\"listbox\"\n ref={dropdownRef}\n id={listId}\n aria-labelledby={labelId}\n aria-multiselectable=\"true\"\n aria-activedescendant={activeDescendant}\n onFocus={handleFocus}\n onBlur={handleBlur}\n tabIndex={-1}\n >\n {options.map((option, i) => (\n <button\n key={`${listId}-${option.value}`}\n type=\"button\"\n id={`${listId}__${option.value}`}\n aria-selected={isSelected(option)}\n role=\"option\"\n value={option.value}\n onBlur={handleBlur}\n className={`jkl-combobox__option ${\n isSelected(option) &&\n \"jkl-combobox__option--selected\"\n }`}\n data-testid=\"jkl-combobox__option\"\n data-testautoid={`jkl-combobox__option-${i}`}\n onFocus={handleFocus}\n onKeyDown={handleOptionOnKeyDown}\n onClick={(e) => {\n setActiveDescendant(\n `${listId}__${option.value}`,\n ); // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role#required_javascript_features\n e.stopPropagation();\n onItemClick(option.value);\n setSearchValue(\"\");\n }}\n onMouseOver={handleMouseOver}\n >\n {option.description ? (\n <span>\n {option.label}\n <span className=\"jkl-combobox__option-description\">\n {option.description}\n </span>\n </span>\n ) : (\n option.label\n )}\n {isSelected(option) ? (\n <span>\n <CheckIcon />{\" \"}\n </span>\n ) : null}\n </button>\n ))}\n {noResults && (\n <div className=\"jkl-combobox__no-option\">\n {noMatchingOption}\n </div>\n )}\n </div>\n <div className=\"jkl-combobox__actions\">\n <IconButton\n id={buttonId}\n onFocus={handleFocus}\n onBlur={handleBlur}\n className=\"jkl-combobox__button\"\n data-testid=\"jkl-combobox__button\"\n aria-label={`${\n selectedValue.map((value) => value.label) ||\n \"Velg\"\n },${label}`}\n aria-expanded={showMenu}\n aria-controls={listId}\n role=\"button\"\n onClick={() => setShowMenu((previous) => !previous)}\n onMouseDown={(e) => {\n e.preventDefault();\n inputRef.current?.focus();\n }}\n >\n <ArrowVerticalAnimated\n pointingDown={isPointingDown}\n />\n </IconButton>\n </div>\n </div>\n )}\n />\n );\n};\nCombobox.displayName = \"Combobox\";\n"],"names":["getComboboxValuePair","item","value","label","Combobox","id","placeholder","items","onChange","onFocus","onBlur","noMatchingOption","labelProps","helpLabel","errorLabel","width","density","name","className","invalid","hasTagHover","listId","useId","generateSuffix","labelId","buttonId","inputId","selectedValue","setSelectedValue","useState","showMenu","setShowMenu","searchValue","setSearchValue","noResults","setNoResults","marked","setMarked","searchRef","useRef","inputRef","focusInsideRef","useEffect","current","focus","prev","isSelected","option","some","removeOption","useCallback","filter","onTagRemove","e","newValue","type","target","selectedOptions","stopPropagation","length","onItemClick","find","i","_a","onSearch","options","useMemo","filteredOptions","toLowerCase","indexOf","activeDescendant","setActiveDescendant","_b","isPointingDown","handleEscape","key","window","addEventListener","removeEventListener","handleFocusPlacement","isOpen","handleFocus","dropdownRef","useAnimatedHeight","onFirstVisible","onTransitionEnd","useListNavigation","ref","componentRootElementRef","handleBlur","componentRootElement","contains","relatedTarget","dispatchEvent","Event","bubbles","handleMouseOver","preventScroll","handleSearchOnKeyDown","preventDefault","listElement","querySelector","metaKey","ctrlKey","updatedSelectedValue","map","isMarked","handleOptionOnKeyDown","shiftKey","firstVisible","currentTarget","hasSelection","renderSelectedOption","jsx","Chip","tagLabel","variant","onClick","children","InputGroup","clsx","render","inputProps","jsxs","style","tabIndex","Tooltip","TooltipTrigger","TooltipContent","onKeyDown","role","autoComplete","onMouseOver","description","CheckIcon","IconButton","previous","onMouseDown","ArrowVerticalAnimated","pointingDown","displayName"],"mappings":"grBAiCO,SAASA,EACZC,GAEO,MAAgB,iBAATA,EAAoB,CAAEC,MAAOD,EAAME,MAAOF,GAASA,CACrE,CAwCO,MAAMG,EAA8B,EACvCC,GAAAA,EACAC,YAAAA,EACAC,MAAAA,EACAC,SAAAA,EACAC,QAAAA,EACAC,OAAAA,EACAR,MAAAA,EACAC,MAAAA,EACAQ,iBAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,MAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,UAAAA,EACAC,QAAAA,EACAC,YAAAA,cAEM,MAAAC,EAASC,EAAAA,MAAMjB,GAAM,eAAgB,CAAEkB,gBAAiBlB,IACxDmB,EAAU,GAAGH,UACbI,EAAW,GAAGJ,WACdK,EAAU,GAAGL,kBAEZM,EAAeC,GAAoBC,EAAAA,SAExC3B,GAAS,KACJ4B,EAAUC,GAAeF,EAAAA,UAAkB,IAC3CG,EAAaC,GAAkBJ,EAAAA,SAAiB,KAChDK,EAAWC,GAAgBN,EAAAA,UAAS,IACpCO,EAAQC,GAAaR,EAAAA,UAAkB,GAExCS,EAAYC,SAAyB,MACrCC,EAAWD,SAAuB,MAClCE,EAAiBF,UAAO,GAE9BG,EAAAA,WAAU,KACNT,EAAe,IACXH,GAAYQ,EAAUK,SACtBL,EAAUK,QAAQC,OAAM,GAE7B,CAACd,IAEJY,EAAAA,WAAU,KACWd,GAACiB,GAAS3C,GAAS2C,GAAI,GACzC,CAAC3C,IAGE,MAAA4C,EAAcC,KACXpB,GAGMA,EAAcqB,MAAM9C,GAAUA,EAAMA,QAAU6C,EAAO7C,QAK9D+C,E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,EAAAA,IAAC,MAAI,CAAA/F,UAAU,0BACVoG,SACL3G,OAGRsG,EAAAA,IAAC,MAAI,CAAA/F,UAAU,wBACXoG,SAAAL,EAAAA,IAACsB,EAAAA,WAAA,CACGlI,GAAIoB,EACJhB,QAASwE,GACTvE,OAAQ+E,GACRvE,UAAU,uBACV,cAAY,uBACZ,aAAY,GACRS,EAAc8E,KAAKvG,GAAUA,EAAMC,SACnC,UACAA,IACJ,gBAAe2B,EACf,gBAAeT,EACf6G,KAAK,SACLb,QAAS,IAAMtF,GAAayG,IAAcA,IAC1CC,YAAcpF,UACVA,EAAE8C,iBACF,OAAApC,EAAAvB,EAASG,UAAToB,EAAkBnB,SAGtB0E,SAAAL,EAAAA,IAACyB,EAAAA,sBAAA,CACGC,aAAclE,aAMtC,EAGRrE,EAASwI,YAAc"}
1
+ {"version":3,"file":"Combobox.cjs","sources":["../../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n ChangeEvent,\n FC,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Density } from \"../../core/types.js\";\nimport { useAnimatedHeight } from \"../../hooks/useAnimatedHeight/useAnimatedHeight.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { useListNavigation } from \"../../hooks/useListNavigation/useListNavigation.js\";\nimport { ValuePair } from \"../../utilities/valuePair.js\";\nimport { Chip } from \"../chip/Chip.js\";\nimport { ArrowVerticalAnimated } from \"../icon/icons/animated/ArrowVerticalAnimated.js\";\nimport { CheckIcon } from \"../icon/icons/CheckIcon.js\";\nimport { IconButton } from \"../icon-button/IconButton.js\";\nimport { InputGroup, InputGroupProps } from \"../input-group/InputGroup.js\";\nimport { LabelProps } from \"../input-group/Label.js\";\nimport { Tooltip } from \"../tooltip/Tooltip.js\";\nimport { TooltipContent } from \"../tooltip/TooltipContent.js\";\nimport { TooltipTrigger } from \"../tooltip/TooltipTrigger.js\";\n\nexport type ComboboxValuePair = ValuePair & {\n tagLabel?: string;\n isMarked?: boolean;\n};\n\nexport function getComboboxValuePair(\n item: string | ComboboxValuePair,\n): ComboboxValuePair {\n return typeof item === \"string\" ? { value: item, label: item } : item;\n}\n\nexport interface ComboboxPartialChangeEvent\n extends Partial<Omit<ChangeEvent<HTMLElement>, \"target\">> {\n type: \"change\" | \"blur\";\n target: {\n name: string;\n value: string;\n selectedOptions: Array<ValuePair>;\n };\n}\n\nexport type ComboboxChangeEventHandler = (\n event: ComboboxPartialChangeEvent,\n) => void;\n\nexport interface ComboboxProps extends InputGroupProps {\n id?: string;\n placeholder?: string;\n labelProps?: Omit<\n LabelProps,\n \"children\" | \"density\" | \"htmlFor\" | \"standAlone\"\n >;\n items: Array<ValuePair>;\n noMatchingOption?: string;\n label: string;\n name: string;\n value?: Array<ValuePair>;\n density?: Density;\n width?: string;\n helpLabel?: string;\n errorLabel?: string;\n className?: string;\n invalid?: boolean;\n hasTagHover?: boolean;\n onChange: ComboboxChangeEventHandler;\n onBlur?: ComboboxChangeEventHandler;\n onFocus?: ComboboxChangeEventHandler;\n}\n\nexport const Combobox: FC<ComboboxProps> = ({\n id,\n placeholder,\n items,\n onChange,\n onFocus,\n onBlur,\n value,\n label,\n noMatchingOption,\n labelProps,\n helpLabel,\n errorLabel,\n width,\n density,\n name,\n className,\n invalid,\n hasTagHover,\n}) => {\n const listId = useId(id || \"jkl-combobox\", { generateSuffix: !id });\n const labelId = `${listId}_label`;\n const buttonId = `${listId}_button`;\n const inputId = `${listId}_search-input`;\n\n const [selectedValue, setSelectedValue] = useState<\n Array<ComboboxValuePair>\n >(value || []);\n const [showMenu, setShowMenu] = useState<boolean>(false);\n const [searchValue, setSearchValue] = useState<string>(\"\");\n const [noResults, setNoResults] = useState(false);\n const [marked, setMarked] = useState<boolean>(false);\n\n const searchRef = useRef<HTMLInputElement>(null);\n const inputRef = useRef<HTMLDivElement>(null);\n const focusInsideRef = useRef(false);\n\n useEffect(() => {\n setSearchValue(\"\");\n if (showMenu && searchRef.current) {\n searchRef.current.focus();\n }\n }, [showMenu]);\n\n useEffect(() => {\n setSelectedValue((prev) => value || prev);\n }, [value]);\n\n // Funksjon for å stile valgt element\n const isSelected = (option: ValuePair) => {\n if (!selectedValue) {\n return false;\n } else {\n return selectedValue.some((value) => value.value === option.value);\n }\n };\n\n // Fjerne ett eller flere valg\n const removeOption = useCallback(\n (option: string) => {\n return selectedValue.filter((value) => value.value !== option);\n },\n [selectedValue],\n );\n\n const onTagRemove = useCallback(\n (\n e:\n | React.MouseEvent<HTMLButtonElement, globalThis.MouseEvent>\n | React.KeyboardEvent<HTMLInputElement>,\n option: string,\n ) => {\n let newValue = removeOption(option);\n setSelectedValue(newValue);\n onChange({\n type: \"change\",\n target: { name, value: option, selectedOptions: newValue },\n });\n e.stopPropagation();\n\n if (newValue.length === 0) {\n setMarked(false);\n }\n },\n [removeOption, setSelectedValue, onChange, name, setMarked],\n );\n\n // Håndtere valgt verdi i listen\n const onItemClick = useCallback(\n (option: string) => {\n let newValue: Array<ValuePair>;\n\n if (selectedValue.some((value) => value.value === option)) {\n newValue = removeOption(option);\n } else {\n const item = items.find((i) => i.value === option);\n newValue = [...selectedValue, item as ValuePair];\n }\n searchRef.current?.focus();\n setSelectedValue(newValue);\n onChange({\n type: \"change\",\n target: { name, value: option, selectedOptions: newValue },\n });\n },\n [selectedValue, setSelectedValue, onChange, name, removeOption, items],\n );\n\n // Funksjon for søk\n const onSearch = (e: {\n target: { value: React.SetStateAction<string> };\n }) => {\n searchRef.current?.focus();\n setShowMenu(true);\n setSearchValue(e.target.value);\n };\n\n const options = useMemo(() => {\n if (!searchValue) {\n return items;\n }\n\n const filteredOptions = items.filter(\n (option) =>\n option.label.toLowerCase().indexOf(searchValue.toLowerCase()) >=\n 0,\n );\n\n setNoResults(filteredOptions.length === 0);\n\n return filteredOptions;\n }, [searchValue, items]);\n\n // Det første elementet i listen skal være aktivt fram til brukeren klikker på noe annet\n const [activeDescendant, setActiveDescendant] = useState<\n string | undefined\n >(options[0]?.value ? `${listId}-${options[0]?.value}` : undefined);\n\n // Håndtere arrow-state\n const isPointingDown = !showMenu;\n\n // Lukk meny med ESC\n useEffect(() => {\n const handleEscape = (e: globalThis.KeyboardEvent) => {\n if (e.key === \"Escape\" && showMenu) {\n setShowMenu(false);\n }\n };\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"keydown\", handleEscape);\n }\n return () => {\n if (typeof window !== \"undefined\" && showMenu) {\n window.removeEventListener(\"keydown\", handleEscape);\n }\n };\n }, [setShowMenu, showMenu]);\n\n // Fokushåndtering\n const handleFocusPlacement = useCallback((isOpen: boolean) => {\n if (isOpen) {\n if (searchRef.current) {\n searchRef.current.focus();\n }\n } else {\n if (focusInsideRef.current && inputRef.current) {\n inputRef.current.focus();\n }\n }\n }, []);\n\n const handleFocus = useCallback(() => {\n if (!focusInsideRef.current) {\n if (onFocus) {\n onFocus({\n type: \"change\",\n target: {\n name,\n value: selectedValue?.[0].value || \"\",\n selectedOptions: selectedValue,\n },\n });\n }\n focusInsideRef.current = true;\n setShowMenu(true);\n }\n }, [onFocus, selectedValue, name]);\n\n const [dropdownRef] = useAnimatedHeight<HTMLDivElement>(showMenu, {\n onFirstVisible: handleFocusPlacement,\n onTransitionEnd: handleFocusPlacement,\n });\n\n useListNavigation({ ref: dropdownRef });\n\n const componentRootElementRef = useRef<HTMLDivElement>(null);\n\n const handleBlur = useCallback(\n (\n e: FocusEvent<\n HTMLDivElement | HTMLInputElement | HTMLButtonElement\n >,\n ) => {\n const componentRootElement = componentRootElementRef.current;\n const nextFocusIsInsideComponent =\n componentRootElement &&\n componentRootElement.contains(e.relatedTarget as Node);\n if (!nextFocusIsInsideComponent) {\n setSearchValue(\"\");\n\n if (onBlur) {\n onBlur({\n type: \"blur\",\n target: {\n name,\n value: selectedValue?.[0]?.value || \"\",\n selectedOptions: selectedValue,\n },\n });\n inputRef.current?.dispatchEvent(\n new Event(\"focusout\", { bubbles: true }),\n );\n }\n focusInsideRef.current = false;\n setShowMenu(false);\n }\n },\n [onBlur, name, selectedValue],\n );\n\n const handleMouseOver = useCallback((e: MouseEvent<HTMLButtonElement>) => {\n // Ved mouseOver på options flytter vi fokus til dem for å unngå \"dobbel fokus\"\n // der det ser ut som to forskjellige elementer er fokusert/hovered samtidig\n (e.target as HTMLButtonElement).focus({ preventScroll: true });\n }, []);\n\n // Tastaturnavigasjon\n const handleSearchOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n e.stopPropagation();\n const listElement = dropdownRef.current;\n if (listElement) {\n listElement\n .querySelector<HTMLButtonElement>('[role=\"option\"]')\n ?.focus();\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n setShowMenu(false);\n }\n\n if ((e.metaKey && e.key === \"a\") || (e.ctrlKey && e.key === \"a\")) {\n e.preventDefault();\n e.stopPropagation();\n const updatedSelectedValue = selectedValue.map((item) => ({\n ...item,\n isMarked: true,\n }));\n setMarked(true);\n setSelectedValue(updatedSelectedValue);\n } else if (e.key === \"Backspace\") {\n e.stopPropagation();\n setMarked(false);\n\n // Sjekk om selectedValue er markert\n const selectedValueIsMarked = selectedValue.some(\n (item) => item.isMarked,\n );\n\n if (selectedValueIsMarked) {\n const updatedSelectedValue = selectedValue.filter(\n (item) => !item.isMarked,\n );\n setSelectedValue(updatedSelectedValue);\n setSearchValue(\"\");\n } else if (selectedValue.length > 0 && searchValue === \"\") {\n // Hvis ingen items er markert, fjern siste valgte item\n onTagRemove(\n e,\n selectedValue[selectedValue.length - 1].value,\n );\n }\n }\n },\n [selectedValue, searchValue, dropdownRef, onTagRemove],\n );\n\n const handleOptionOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Tab\") {\n if (searchRef.current) {\n e.preventDefault();\n e.stopPropagation();\n\n if (e.shiftKey) {\n searchRef.current.focus();\n } else {\n setShowMenu(false);\n searchRef.current.focus();\n }\n }\n } else if (e.key === \"ArrowUp\") {\n if (dropdownRef.current && searchRef.current) {\n // Can't be based on index since the first item might be filtered out\n const firstVisible = dropdownRef.current.querySelector(\n '[role=\"option\"]:not([hidden])',\n );\n if (\n e.currentTarget.id === firstVisible?.id &&\n searchRef.current\n ) {\n searchRef.current.focus();\n }\n }\n }\n },\n [setShowMenu, dropdownRef],\n );\n\n const hasSelection = selectedValue.length >= 1;\n\n const renderSelectedOption = useCallback(\n (option: ComboboxValuePair) => (\n <Chip\n key={option.value}\n data-testid=\"jkl-chip\"\n aria-label={`Fjern ${option.tagLabel}`}\n className={`jkl-combobox__selected-option ${\n marked && \"jkl-combobox__selected-option--marked\"\n }`}\n variant=\"input\"\n onClick={(e) => {\n if (searchRef.current) {\n searchRef.current.focus();\n }\n onTagRemove(e, option.value);\n }}\n onBlur={handleBlur}\n >\n {option.tagLabel ? option.tagLabel : option.label}\n </Chip>\n ),\n [handleBlur, onTagRemove, marked],\n );\n\n return (\n <InputGroup\n label={label}\n id={inputId}\n ref={componentRootElementRef}\n data-testid=\"jkl-combobox\"\n className={clsx(\"jkl-combobox\", className, {\n \"jkl-combobox--invalid\": !!errorLabel || invalid,\n \"jkl-combobox--menu-open\": showMenu,\n \"jkl-combobox--menu-closed\": !showMenu && hasSelection,\n })}\n labelProps={{\n id: labelId,\n ...labelProps,\n }}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n density={density}\n render={(inputProps) => (\n <div\n className={clsx(\"jkl-combobox__wrapper\", {\n \"jkl-combobox__wrapper--active-value\": hasSelection,\n })}\n style={{ width }}\n tabIndex={-1}\n onFocus={handleFocus}\n onBlur={handleBlur}\n >\n <div\n className=\"jkl-combobox__chips\"\n data-testid=\"jkl-combobox__chips\"\n >\n {selectedValue\n .map(getComboboxValuePair)\n .map((option) => {\n return hasTagHover ? (\n <Tooltip key={option.value}>\n <TooltipTrigger>\n {renderSelectedOption(option)}\n </TooltipTrigger>\n <TooltipContent>\n {option.label}\n </TooltipContent>\n </Tooltip>\n ) : (\n renderSelectedOption(option)\n );\n })}\n <input\n {...inputProps}\n className=\"jkl-combobox__search-input\"\n onChange={onSearch}\n data-testid=\"jkl-combobox__search-input\"\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleSearchOnKeyDown}\n value={searchValue}\n ref={searchRef}\n aria-controls={listId}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={showMenu}\n placeholder={\n selectedValue.length > 0 ? \"\" : placeholder\n }\n autoComplete=\"off\"\n />\n </div>\n\n <div\n className=\"jkl-combobox__menu\"\n role=\"listbox\"\n ref={dropdownRef}\n id={listId}\n aria-labelledby={labelId}\n aria-multiselectable=\"true\"\n aria-activedescendant={activeDescendant}\n onFocus={handleFocus}\n onBlur={handleBlur}\n tabIndex={-1}\n >\n {options.map((option, i) => (\n <button\n key={`${listId}-${option.value}`}\n type=\"button\"\n id={`${listId}__${option.value}`}\n aria-selected={isSelected(option)}\n role=\"option\"\n value={option.value}\n onBlur={handleBlur}\n className={`jkl-combobox__option ${\n isSelected(option) &&\n \"jkl-combobox__option--selected\"\n }`}\n data-testid=\"jkl-combobox__option\"\n data-testautoid={`jkl-combobox__option-${i}`}\n onFocus={handleFocus}\n onKeyDown={handleOptionOnKeyDown}\n onClick={(e) => {\n setActiveDescendant(\n `${listId}__${option.value}`,\n ); // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role#required_javascript_features\n e.stopPropagation();\n onItemClick(option.value);\n setSearchValue(\"\");\n }}\n onMouseOver={handleMouseOver}\n >\n {option.description ? (\n <span>\n {option.label}\n <span className=\"jkl-combobox__option-description\">\n {option.description}\n </span>\n </span>\n ) : (\n option.label\n )}\n {isSelected(option) ? (\n <span>\n <CheckIcon />{\" \"}\n </span>\n ) : null}\n </button>\n ))}\n {noResults && (\n <div className=\"jkl-combobox__no-option\">\n {noMatchingOption}\n </div>\n )}\n </div>\n <div className=\"jkl-combobox__actions\">\n <IconButton\n id={buttonId}\n onFocus={handleFocus}\n onBlur={handleBlur}\n className=\"jkl-combobox__button\"\n data-testid=\"jkl-combobox__button\"\n aria-label={`${\n selectedValue.map((value) => value.label) ||\n \"Velg\"\n },${label}`}\n aria-expanded={showMenu}\n aria-controls={listId}\n role=\"button\"\n onClick={() => setShowMenu((previous) => !previous)}\n onMouseDown={(e) => {\n e.preventDefault();\n inputRef.current?.focus();\n }}\n >\n <ArrowVerticalAnimated\n pointingDown={isPointingDown}\n />\n </IconButton>\n </div>\n </div>\n )}\n />\n );\n};\nCombobox.displayName = \"Combobox\";\n"],"names":["getComboboxValuePair","item","value","label","Combobox","id","placeholder","items","onChange","onFocus","onBlur","noMatchingOption","labelProps","helpLabel","errorLabel","width","density","name","className","invalid","hasTagHover","listId","useId","generateSuffix","labelId","buttonId","inputId","selectedValue","setSelectedValue","useState","showMenu","setShowMenu","searchValue","setSearchValue","noResults","setNoResults","marked","setMarked","searchRef","useRef","inputRef","focusInsideRef","useEffect","current","focus","prev","isSelected","option","some","removeOption","useCallback","filter","onTagRemove","e","newValue","type","target","selectedOptions","stopPropagation","length","onItemClick","find","i","_a","onSearch","options","useMemo","filteredOptions","toLowerCase","indexOf","activeDescendant","setActiveDescendant","_b","isPointingDown","handleEscape","key","window","addEventListener","removeEventListener","handleFocusPlacement","isOpen","handleFocus","dropdownRef","useAnimatedHeight","onFirstVisible","onTransitionEnd","useListNavigation","ref","componentRootElementRef","handleBlur","componentRootElement","contains","relatedTarget","dispatchEvent","Event","bubbles","handleMouseOver","preventScroll","handleSearchOnKeyDown","preventDefault","listElement","querySelector","metaKey","ctrlKey","updatedSelectedValue","map","isMarked","handleOptionOnKeyDown","shiftKey","firstVisible","currentTarget","hasSelection","renderSelectedOption","jsx","Chip","tagLabel","variant","onClick","children","InputGroup","clsx","render","inputProps","jsxs","style","tabIndex","Tooltip","TooltipTrigger","TooltipContent","onKeyDown","role","autoComplete","onMouseOver","description","CheckIcon","IconButton","previous","onMou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,KAAKvG,GAAUA,EAAMC,SACnC,UACAA,IACJ,gBAAe2B,EACf,gBAAeT,EACf6G,KAAK,SACLb,QAAS,IAAMtF,GAAayG,IAAcA,IAC1CC,YAAcpF,UACVA,EAAE8C,iBACF,OAAApC,EAAAvB,EAASG,UAAToB,EAAkBnB,SAGtB0E,SAAAL,EAAAA,IAACyB,EAAAA,sBAAA,CACGC,aAAclE,aAI9B,EAKhBrE,EAASwI,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"CookieConsent.cjs","sources":["../../../../src/components/cookie-consent/CookieConsent.tsx"],"sourcesContent":["import React, { FormEventHandler, useEffect, useId } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { SecondaryButton } from \"../button/Button.js\";\nimport {\n Modal,\n ModalActions,\n ModalBody,\n ModalContainer,\n ModalHeader,\n ModalOverlay,\n ModalTitle,\n} from \"../modal/Modal.js\";\nimport { useModal } from \"../modal/useModal.js\";\nimport { useInternalState } from \"./CookieConsentContext.js\";\nimport {\n convertBooleanConsentObjectToConsentObject,\n setConsentCookie,\n} from \"./cookieConsentUtils.js\";\nimport { RequirementCheckbox } from \"./RequirementCheckbox.js\";\nimport { AcceptConsentCallback, Consent } from \"./types.js\";\n\nexport interface CookieConsentProps {\n blocking?: boolean;\n onAccept?: AcceptConsentCallback;\n}\n\nexport const CookieConsent = ({\n blocking,\n onAccept,\n ...rest\n}: CookieConsentProps): JSX.Element | null => {\n const {\n currentConsent,\n cookieName,\n cookieDomain,\n requirement,\n isOpen,\n setIsOpen,\n updateCurrentConsents,\n } = useInternalState();\n\n const [instance, modalConfig] = useModal({\n id: `jkl-cookie-modal-${useId()}`,\n // The optional `role` attribute of the dialog element, either `dialog`\n // (default) or `alertdialog` to make it a modal (preventing closing on\n // click outside of ESC key).\n role: blocking ? \"alertdialog\" : \"dialog\",\n // The required dialog title, mandatory in the document\n // to provide context to assistive technology.\n title: \"Informasjonskapsler\",\n });\n\n useEffect(() => {\n if (isOpen) {\n instance?.show();\n } else {\n instance?.hide();\n }\n }, [instance, isOpen]);\n\n useEffect(() => {\n const onHide = () => setIsOpen(false);\n instance?.on(\"hide\", onHide);\n return () => {\n instance?.off(\"hide\", onHide);\n };\n }, [instance, setIsOpen]);\n\n if (typeof document === \"undefined\") {\n return null;\n }\n\n // Cookies are disabled in the browser\n if (typeof navigator !== \"undefined\" && !navigator.cookieEnabled) {\n if (onAccept) {\n onAccept({\n functional: \"denied\",\n marketing: \"denied\",\n statistics: \"denied\",\n });\n }\n\n return null;\n }\n\n const accept = (\n selection = convertBooleanConsentObjectToConsentObject(\n {\n functional: true,\n statistics: true,\n marketing: true,\n },\n requirement,\n ),\n ) => {\n const selectionWithoutEmptyValues = Object.fromEntries(\n Object.entries(selection).filter(\n ([, value]) => typeof value !== \"undefined\",\n ),\n );\n\n const updatedConsent: Consent = {\n ...currentConsent,\n ...selectionWithoutEmptyValues,\n };\n\n setConsentCookie({\n consent: updatedConsent,\n name: cookieName,\n domain: cookieDomain,\n });\n\n updateCurrentConsents();\n\n onAccept?.(updatedConsent);\n\n instance?.hide();\n };\n\n const onSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n\n const formData = new FormData(e.currentTarget);\n\n const newConsents = convertBooleanConsentObjectToConsentObject(\n {\n functional: formData.get(\"functional\") === \"true\",\n statistics: formData.get(\"statistics\") === \"true\",\n marketing: formData.get(\"marketing\") === \"true\",\n },\n requirement,\n );\n\n accept(newConsents);\n };\n\n return ReactDOM.createPortal(\n <ModalContainer\n {...modalConfig.container}\n {...rest}\n data-cookie-consent-open={isOpen}\n >\n <ModalOverlay {...modalConfig.overlay} />\n <Modal component=\"form\" {...modalConfig.modal} {...{ onSubmit }}>\n <ModalHeader>\n <ModalTitle {...modalConfig.title}>\n Velg informasjonskapsler\n </ModalTitle>\n </ModalHeader>\n <ModalBody>\n <p>\n For at nettsidene skal fungere må vi bruke tekniske\n informasjonskaplser. Disse lagres derfor uten samtykke.\n </p>\n {requirement.functional && (\n <RequirementCheckbox\n name=\"functional\"\n label=\"Tillat funksjonelle\"\n defaultChecked={\n currentConsent.functional === \"accepted\"\n }\n key={`functional-${currentConsent.functional}`}\n >\n Funksjonelle informasjonskapsler lagrer opplysninger\n om din bruk av nettsidene og hvilke innstillinger du\n har gjort, slik at du kan få funksjonalitet\n tilpasset deg.\n </RequirementCheckbox>\n )}\n {requirement.statistics && (\n <RequirementCheckbox\n name=\"statistics\"\n label=\"Tillat statistikk\"\n defaultChecked={\n currentConsent.statistics === \"accepted\"\n }\n key={`statistics-${currentConsent.statistics}`}\n >\n Informasjonskapslene lagrer statistikk som hjelper\n oss med å forstå hvordan nettsidene blir brukt, slik\n at vi kan gjøre dem bedre og enklere å bruke.\n </RequirementCheckbox>\n )}\n {requirement.marketing && (\n <RequirementCheckbox\n name=\"marketing\"\n label=\"Tillat personlig markedsføring\"\n defaultChecked={\n currentConsent.marketing === \"accepted\"\n }\n key={`marketing-${currentConsent.marketing}`}\n >\n Dette gjør at vi kan gi deg mer relevant og\n tilpasset markedsføring, også gjennom våre\n samarbeidspartnere, på for eksempel nettsider,\n annonser og i sosiale medier.\n </RequirementCheckbox>\n )}\n </ModalBody>\n <ModalActions>\n <SecondaryButton\n data-testid=\"jkl-cookie-consent-godta-alle\"\n type=\"button\"\n onClick={() => accept()}\n >\n Godta alle\n </SecondaryButton>\n <SecondaryButton\n data-testid=\"jkl-cookie-consent-godta\"\n type=\"submit\"\n >\n Godta mine valg\n </SecondaryButton>\n </ModalActions>\n </Modal>\n </ModalContainer>,\n document.body,\n );\n};\n"],"names":["blocking","onAccept","rest","currentConsent","cookieName","cookieDomain","requirement","isOpen","setIsOpen","updateCurrentConsents","useInternalState","instance","modalConfig","useModal","id","useId","role","title","useEffect","show","hide","onHide","on","off","document","navigator","cookieEnabled","functional","marketing","statistics","accept","selection","convertBooleanConsentObjectToConsentObject","selectionWithoutEmptyValues","Object","fromEntries","entries","filter","value","updatedConsent","setConsentCookie","consent","name","domain","ReactDOM","createPortal","jsxs","ModalContainer","container","children","jsx","ModalOverlay","overlay","Modal","component","modal","onSubmit","e","preventDefault","formData","FormData","currentTarget","newConsents","get","ModalHeader","ModalTitle","ModalBody","RequirementCheckbox","label","defaultChecked","ModalActions","SecondaryButton","type","onClick","body"],"mappings":"+YA0B6B,EACzBA,SAAAA,EACAC,SAAAA,KACGC,MAEG,MACFC,eAAAA,EACAC,WAAAA,EACAC,aAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,sBAAAA,GACAC,sBAEGC,EAAUC,GAAeC,WAAS,CACrCC,GAAI,oBAAoBC,EAAAA,UAIxBC,KAAMhB,EAAW,cAAgB,SAGjCiB,MAAO,wBAmBP,GAhBJC,EAAAA,WAAU,KACFX,EACA,MAAAI,GAAAA,EAAUQ,OAEV,MAAAR,GAAAA,EAAUS,MACd,GACD,CAACT,EAAUJ,IAEdW,EAAAA,WAAU,KACA,MAAAG,EAAS,IAAMb,GAAU,GACrB,OAAA,MAAAG,GAAAA,EAAAW,GAAG,OAAQD,GACd,KACO,MAAAV,GAAAA,EAAAY,IAAI,OAAQF,EAAAA,CAC1B,GACD,CAACV,EAAUH,WAEHgB,SAAa,IACb,OAAA,KAIX,UAAWC,UAAc,MAAgBA,UAAUC,cAC/C,OAAIzB,GACSA,EAAA,CACL0B,WAAY,SACZC,UAAW,SACXC,WAAY,WAIb,KAGL,MAAAC,EAAS,CACXC,EAAYC,EAAAA,2CACR,CACIL,YAAY,EACZE,YAAY,EACZD,WAAW,GAEftB,MAGJ,MAAM2B,EAA8BC,OAAOC,YACvCD,OAAOE,QAAQL,GAAWM,QACtB,EAAI,CAAAC,YAAkBA,EAAU,OAIlCC,EAA0B,IACzBpC,KACA8B,GAGUO,mBAAA,CACbC,QAASF,EACTG,KAAMtC,EACNuC,OAAQtC,IAGUI,IAEtB,MAAAR,GAAAA,EAAWsC,GAEX,MAAA5B,GAAAA,EAAUS,MACd,EAmBA,OAAOwB,EAASC,aACZC,EAAAA,KAACC,EAAAA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ACRvB,SAAA,6BAMbzB,SAASkD,KACb"}
1
+ {"version":3,"file":"CookieConsent.cjs","sources":["../../../../src/components/cookie-consent/CookieConsent.tsx"],"sourcesContent":["import React, { FormEventHandler, useEffect, useId } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { SecondaryButton } from \"../button/Button.js\";\nimport {\n Modal,\n ModalActions,\n ModalBody,\n ModalContainer,\n ModalHeader,\n ModalOverlay,\n ModalTitle,\n} from \"../modal/Modal.js\";\nimport { useModal } from \"../modal/useModal.js\";\nimport { useInternalState } from \"./CookieConsentContext.js\";\nimport {\n convertBooleanConsentObjectToConsentObject,\n setConsentCookie,\n} from \"./cookieConsentUtils.js\";\nimport { RequirementCheckbox } from \"./RequirementCheckbox.js\";\nimport { AcceptConsentCallback, Consent } from \"./types.js\";\n\nexport interface CookieConsentProps {\n blocking?: boolean;\n onAccept?: AcceptConsentCallback;\n}\n\nexport const CookieConsent = ({\n blocking,\n onAccept,\n ...rest\n}: CookieConsentProps): JSX.Element | null => {\n const {\n currentConsent,\n cookieName,\n cookieDomain,\n requirement,\n isOpen,\n setIsOpen,\n updateCurrentConsents,\n } = useInternalState();\n\n const [instance, modalConfig] = useModal({\n id: `jkl-cookie-modal-${useId()}`,\n // The optional `role` attribute of the dialog element, either `dialog`\n // (default) or `alertdialog` to make it a modal (preventing closing on\n // click outside of ESC key).\n role: blocking ? \"alertdialog\" : \"dialog\",\n // The required dialog title, mandatory in the document\n // to provide context to assistive technology.\n title: \"Informasjonskapsler\",\n });\n\n useEffect(() => {\n if (isOpen) {\n instance?.show();\n } else {\n instance?.hide();\n }\n }, [instance, isOpen]);\n\n useEffect(() => {\n const onHide = () => setIsOpen(false);\n instance?.on(\"hide\", onHide);\n return () => {\n instance?.off(\"hide\", onHide);\n };\n }, [instance, setIsOpen]);\n\n if (typeof document === \"undefined\") {\n return null;\n }\n\n // Cookies are disabled in the browser\n if (typeof navigator !== \"undefined\" && !navigator.cookieEnabled) {\n if (onAccept) {\n onAccept({\n functional: \"denied\",\n marketing: \"denied\",\n statistics: \"denied\",\n });\n }\n\n return null;\n }\n\n const accept = (\n selection = convertBooleanConsentObjectToConsentObject(\n {\n functional: true,\n statistics: true,\n marketing: true,\n },\n requirement,\n ),\n ) => {\n const selectionWithoutEmptyValues = Object.fromEntries(\n Object.entries(selection).filter(\n ([, value]) => typeof value !== \"undefined\",\n ),\n );\n\n const updatedConsent: Consent = {\n ...currentConsent,\n ...selectionWithoutEmptyValues,\n };\n\n setConsentCookie({\n consent: updatedConsent,\n name: cookieName,\n domain: cookieDomain,\n });\n\n updateCurrentConsents();\n\n onAccept?.(updatedConsent);\n\n instance?.hide();\n };\n\n const onSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n\n const formData = new FormData(e.currentTarget);\n\n const newConsents = convertBooleanConsentObjectToConsentObject(\n {\n functional: formData.get(\"functional\") === \"true\",\n statistics: formData.get(\"statistics\") === \"true\",\n marketing: formData.get(\"marketing\") === \"true\",\n },\n requirement,\n );\n\n accept(newConsents);\n };\n\n return ReactDOM.createPortal(\n <ModalContainer\n {...modalConfig.container}\n {...rest}\n data-cookie-consent-open={isOpen}\n >\n <ModalOverlay {...modalConfig.overlay} />\n <Modal component=\"form\" {...modalConfig.modal} {...{ onSubmit }}>\n <ModalHeader>\n <ModalTitle {...modalConfig.title}>\n Velg informasjonskapsler\n </ModalTitle>\n </ModalHeader>\n <ModalBody>\n <p>\n For at nettsidene skal fungere må vi bruke tekniske\n informasjonskaplser. Disse lagres derfor uten samtykke.\n </p>\n {requirement.functional && (\n <RequirementCheckbox\n name=\"functional\"\n label=\"Tillat funksjonelle\"\n defaultChecked={\n currentConsent.functional === \"accepted\"\n }\n key={`functional-${currentConsent.functional}`}\n >\n Funksjonelle informasjonskapsler lagrer opplysninger\n om din bruk av nettsidene og hvilke innstillinger du\n har gjort, slik at du kan få funksjonalitet\n tilpasset deg.\n </RequirementCheckbox>\n )}\n {requirement.statistics && (\n <RequirementCheckbox\n name=\"statistics\"\n label=\"Tillat statistikk\"\n defaultChecked={\n currentConsent.statistics === \"accepted\"\n }\n key={`statistics-${currentConsent.statistics}`}\n >\n Informasjonskapslene lagrer statistikk som hjelper\n oss med å forstå hvordan nettsidene blir brukt, slik\n at vi kan gjøre dem bedre og enklere å bruke.\n </RequirementCheckbox>\n )}\n {requirement.marketing && (\n <RequirementCheckbox\n name=\"marketing\"\n label=\"Tillat personlig markedsføring\"\n defaultChecked={\n currentConsent.marketing === \"accepted\"\n }\n key={`marketing-${currentConsent.marketing}`}\n >\n Dette gjør at vi kan gi deg mer relevant og\n tilpasset markedsføring, også gjennom våre\n samarbeidspartnere, på for eksempel nettsider,\n annonser og i sosiale medier.\n </RequirementCheckbox>\n )}\n </ModalBody>\n <ModalActions>\n <SecondaryButton\n data-testid=\"jkl-cookie-consent-godta-alle\"\n type=\"button\"\n onClick={() => accept()}\n >\n Godta alle\n </SecondaryButton>\n <SecondaryButton\n data-testid=\"jkl-cookie-consent-godta\"\n type=\"submit\"\n >\n Godta mine valg\n </SecondaryButton>\n </ModalActions>\n </Modal>\n </ModalContainer>,\n document.body,\n );\n};\n"],"names":["blocking","onAccept","rest","currentConsent","cookieName","cookieDomain","requirement","isOpen","setIsOpen","updateCurrentConsents","useInternalState","instance","modalConfig","useModal","id","useId","role","title","useEffect","show","hide","onHide","on","off","document","navigator","cookieEnabled","functional","marketing","statistics","accept","selection","convertBooleanConsentObjectToConsentObject","selectionWithoutEmptyValues","Object","fromEntries","entries","filter","value","updatedConsent","setConsentCookie","consent","name","domain","ReactDOM","createPortal","jsxs","ModalContainer","container","children","jsx","ModalOverlay","overlay","Modal","component","modal","onSubmit","e","preventDefault","formData","FormData","currentTarget","newConsents","get","ModalHeader","ModalTitle","ModalBody","RequirementCheckbox","label","defaultChecked","ModalActions","SecondaryButton","type","onClick","body"],"mappings":"+YA0B6B,EACzBA,SAAAA,EACAC,SAAAA,KACGC,MAEG,MACFC,eAAAA,EACAC,WAAAA,EACAC,aAAAA,E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AE1BC,EAAc9B,EAAAA,2CAChB,CACIL,WAA2C,SAA/BgC,EAASI,IAAI,cACzBlC,WAA2C,SAA/B8B,EAASI,IAAI,cACzBnC,UAAyC,SAA9B+B,EAASI,IAAI,cAE5BzD,GAGJwB,EAAOgC,EAAW,EAWVb,SAAA,CAAAC,EAAAA,IAACc,eACGf,SAACC,EAAAA,IAAAe,EAAAA,WAAA,IAAerD,EAAYK,MAAOgC,+CAItCiB,EAAAA,UACG,CAAAjB,SAAA,CAAAC,EAAAA,IAAC,KAAED,SAGH,gHACC3C,EAAYqB,YACTuB,EAAAA,IAACiB,EAAAA,oBAAA,CACGzB,KAAK,aACL0B,MAAM,sBACNC,eACkC,aAA9BlE,EAAewB,WAGtBsB,SAAA,wKADQ,cAAc9C,EAAewB,cAQzCrB,EAAYuB,YACTqB,EAAAA,IAACiB,EAAAA,oBAAA,CACGzB,KAAK,aACL0B,MAAM,oBACNC,eACkC,aAA9BlE,EAAe0B,WAGtBoB,SAAA,yJADQ,cAAc9C,EAAe0B,cAOzCvB,EAAYsB,WACTsB,EAAAA,IAACiB,EAAAA,oBAAA,CACGzB,KAAK,YACL0B,MAAM,iCACNC,eACiC,aAA7BlE,EAAeyB,UAGtBqB,SAAA,uKADQ,aAAa9C,EAAeyB,uBAS5C0C,EAAAA,aACG,CAAArB,SAAA,CAAAC,EAAAA,IAACqB,EAAAA,gBAAA,CACG,cAAY,gCACZC,KAAK,SACLC,QAAS,IAAM3C,IAClBmB,SAAA,eAGDC,EAAAA,IAACqB,EAAAA,gBAAA,CACG,cAAY,2BACZC,KAAK,SACRvB,SAAA,6BAMbzB,SAASkD,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CookieConsentContext.cjs","sources":["../../../../src/components/cookie-consent/CookieConsentContext.tsx"],"sourcesContent":["import React, { useContext, useMemo, useState } from \"react\";\nimport {\n buildRequirementsObject,\n getConsentCookie,\n shouldShowConsentDialog,\n} from \"./cookieConsentUtils.js\";\nimport {\n Consent,\n CookieConsentProviderProps,\n InternalContext,\n} from \"./types.js\";\n\nexport const DEFAULT_COOKIE_NAME = \"fremtind-cookie-consent\";\n\nconst Context = React.createContext<InternalContext | undefined>(undefined);\n\nexport const CookieConsentProvider: React.FC<CookieConsentProviderProps> = ({\n children,\n cookieAdapter,\n marketing,\n functional,\n statistics,\n cookieName = DEFAULT_COOKIE_NAME,\n cookieDomain,\n}) => {\n const [timestamp, setTimestamp] = useState(() => Date.now());\n\n const requirement = useMemo(\n () => buildRequirementsObject({ marketing, functional, statistics }),\n [marketing, functional, statistics],\n );\n\n const consentCookie = useMemo(() => {\n return (\n getConsentCookie({ adapter: cookieAdapter, name: cookieName }) ?? {\n marketing: null,\n functional: null,\n statistics: null,\n }\n );\n /* Use timestamp as a dependency to be ablet to force re-reading of cookie */\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, [cookieAdapter, cookieName, timestamp]);\n\n const [isOpen, setIsOpen] = useState(() => {\n return shouldShowConsentDialog(requirement, consentCookie);\n });\n\n return (\n <Context.Provider\n value={{\n isOpen,\n setIsOpen,\n updateCurrentConsents: () => setTimestamp(Date.now()),\n requirement,\n currentConsent: consentCookie,\n cookieName,\n cookieDomain,\n }}\n >\n {children}\n </Context.Provider>\n );\n};\n\nexport const useInternalState = () => {\n const context = React.useContext(Context);\n if (context === undefined) {\n throw new Error(\n \"CookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n return context;\n};\n\ntype UseCookieConsent = {\n openConsentModal: () => void;\n consents: Consent;\n};\n\nexport const useCookieConsent = (): UseCookieConsent => {\n const context = useContext(Context);\n\n if (context === undefined) {\n throw new Error(\n \"useCookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n const openConsentModal = () => {\n context.setIsOpen(true);\n };\n\n const consents = context.currentConsent;\n\n return { openConsentModal, consents };\n};\n"],"names":["DEFAULT_COOKIE_NAME","Context","React","createContext","children","cookieAdapter","marketing","functional","statistics","cookieName","cookieDomain","timestamp","setTimestamp","useState","Date","now","requirement","useMemo","buildRequirementsObject","consentCookie","getConsentCookie","adapter","name","isOpen","setIsOpen","shouldShowConsentDialog","jsx","Provider","value","updateCurrentConsents","currentConsent","context","useContext","Error","openConsentModal","consents"],"mappings":"8KAYaA,EAAsB,0BAE7BC,EAAUC,EAAMC,mBAA2C,iCAEU,EACvEC,SAAAA,EACAC,cAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,WAAAA,EACAC,WAAAA,EAAaT,EACbU,aAAAA,MAEM,MAACC,EAAWC,GAAgBC,YAAS,IAAMC,KAAKC,QAEhDC,EAAcC,EAAAA,SAChB,IAAMC,EAAwBA,wBAAA,CAAEZ,UAAAA,EAAWC,WAAAA,EAAYC,WAAAA,KACvD,CAACF,EAAWC,EAAYC,IAGtBW,EAAgBF,EAAAA,SAAQ,IAEtBG,EAAAA,iBAAiB,CAAEC,QAAShB,EAAeiB,KAAMb,KAAiB,CAC9DH,UAAW,KACXC,WAAY,KACZC,WAAY,OAKrB,CAACH,EAAeI,EAAYE,KAExBY,EAAQC,GAAaX,YAAS,IAC1BY,EAAAA,wBAAwBT,EAAaG,KAI5C,OAAAO,EAAAA,IAACzB,EAAQ0B,SAAR,CACGC,MAAO,CACHL,OAAAA,EACAC,UAAAA,EACAK,sBAAuB,IAAMjB,EAAaE,KAAKC,OAC/CC,YAAAA,EACAc,eAAgBX,EAChBV,WAAAA,EACAC,aAAAA,GAGHN,SAAAA,GACL,yDAoBwB,KACtB,MAAA2B,EAAUC,aAAW/B,GAE3B,QAAgB,IAAZ8B,EACA,MAAM,IAAIE,MACN,gEAUD,MAAA,CAAEC,iBANgB,KACrBH,EAAQP,WAAU,EAAI,EAKCW,SAFVJ,EAAQD,eAEW,2BA/BR,KACtB,MAAAC,EAAU7B,EAAM8B,WAAW/B,GACjC,QAAgB,IAAZ8B,EACA,MAAM,IAAIE,MACN,6DAID,OAAAF"}
1
+ {"version":3,"file":"CookieConsentContext.cjs","sources":["../../../../src/components/cookie-consent/CookieConsentContext.tsx"],"sourcesContent":["import React, { useContext, useMemo, useState } from \"react\";\nimport {\n buildRequirementsObject,\n getConsentCookie,\n shouldShowConsentDialog,\n} from \"./cookieConsentUtils.js\";\nimport {\n Consent,\n CookieConsentProviderProps,\n InternalContext,\n} from \"./types.js\";\n\nexport const DEFAULT_COOKIE_NAME = \"fremtind-cookie-consent\";\n\nconst Context = React.createContext<InternalContext | undefined>(undefined);\n\nexport const CookieConsentProvider: React.FC<CookieConsentProviderProps> = ({\n children,\n cookieAdapter,\n marketing,\n functional,\n statistics,\n cookieName = DEFAULT_COOKIE_NAME,\n cookieDomain,\n}) => {\n const [timestamp, setTimestamp] = useState(() => Date.now());\n\n const requirement = useMemo(\n () => buildRequirementsObject({ marketing, functional, statistics }),\n [marketing, functional, statistics],\n );\n\n const consentCookie = useMemo(() => {\n return (\n getConsentCookie({ adapter: cookieAdapter, name: cookieName }) ?? {\n marketing: null,\n functional: null,\n statistics: null,\n }\n );\n /* Use timestamp as a dependency to be ablet to force re-reading of cookie */\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, [cookieAdapter, cookieName, timestamp]);\n\n const [isOpen, setIsOpen] = useState(() => {\n return shouldShowConsentDialog(requirement, consentCookie);\n });\n\n return (\n <Context.Provider\n value={{\n isOpen,\n setIsOpen,\n updateCurrentConsents: () => setTimestamp(Date.now()),\n requirement,\n currentConsent: consentCookie,\n cookieName,\n cookieDomain,\n }}\n >\n {children}\n </Context.Provider>\n );\n};\n\nexport const useInternalState = () => {\n const context = React.useContext(Context);\n if (context === undefined) {\n throw new Error(\n \"CookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n return context;\n};\n\ntype UseCookieConsent = {\n openConsentModal: () => void;\n consents: Consent;\n};\n\nexport const useCookieConsent = (): UseCookieConsent => {\n const context = useContext(Context);\n\n if (context === undefined) {\n throw new Error(\n \"useCookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n const openConsentModal = () => {\n context.setIsOpen(true);\n };\n\n const consents = context.currentConsent;\n\n return { openConsentModal, consents };\n};\n"],"names":["DEFAULT_COOKIE_NAME","Context","React","createContext","children","cookieAdapter","marketing","functional","statistics","cookieName","cookieDomain","timestamp","setTimestamp","useState","Date","now","requirement","useMemo","buildRequirementsObject","consentCookie","getConsentCookie","adapter","name","isOpen","setIsOpen","shouldShowConsentDialog","jsx","Provider","value","updateCurrentConsents","currentConsent","context","useContext","Error","openConsentModal","consents"],"mappings":"8KAYaA,EAAsB,0BAE7BC,EAAUC,EAAMC,mBAA2C,iCAEU,EACvEC,SAAAA,EACAC,cAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,WAAAA,EACAC,WAAAA,EAAaT,EACbU,aAAAA,MAEM,MAACC,EAAWC,GAAgBC,YAAS,IAAMC,KAAKC,QAEhDC,EAAcC,EAAAA,SAChB,IAAMC,EAAwBA,wBAAA,CAAEZ,UAAAA,EAAWC,WAAAA,EAAYC,WAAAA,KACvD,CAACF,EAAWC,EAAYC,IAGtBW,EAAgBF,EAAAA,SAAQ,IAEtBG,EAAAA,iBAAiB,CAAEC,QAAShB,EAAeiB,KAAMb,KAAiB,CAC9DH,UAAW,KACXC,WAAY,KACZC,WAAY,OAKrB,CAACH,EAAeI,EAAYE,KAExBY,EAAQC,GAAaX,YAAS,IAC1BY,EAAAA,wBAAwBT,EAAaG,KAI5C,OAAAO,EAAAA,IAACzB,EAAQ0B,SAAR,CACGC,MAAO,CACHL,OAAAA,EACAC,UAAAA,EACAK,sBAAuB,IAAMjB,EAAaE,KAAKC,OAC/CC,YAAAA,EACAc,eAAgBX,EAChBV,WAAAA,EACAC,aAAAA,GAGHN,SAAAA,GAAA,yDAqBmB,KACtB,MAAA2B,EAAUC,aAAW/B,GAE3B,QAAgB,IAAZ8B,EACA,MAAM,IAAIE,MACN,gEAUD,MAAA,CAAEC,iBANgB,KACrBH,EAAQP,WAAU,EAAI,EAKCW,SAFVJ,EAAQD,0CA7BG,KACtB,MAAAC,EAAU7B,EAAM8B,WAAW/B,GACjC,QAAgB,IAAZ8B,EACA,MAAM,IAAIE,MACN,6DAID,OAAAF"}
@@ -1 +1 @@
1
- {"version":3,"file":"cookieConsentUtils.cjs","sources":["../../../../src/components/cookie-consent/cookieConsentUtils.ts"],"sourcesContent":["import type { Consent, ConsentRequirement, ConsentState } from \"./types.js\";\n\nconst getCookie = (name: string) => {\n if (typeof document === \"undefined\") {\n return undefined;\n }\n\n const cookie = document.cookie\n // split a string of cookies into array of cookies\n .split(\";\")\n // split cookies into [name, value]\n .map((s) => s.trim().split(\"=\"))\n // find our golden nugget\n .find((c) => c[0] === name);\n\n if (!cookie) {\n return undefined;\n }\n\n return cookie;\n};\n\nexport const getConsentCookie = ({\n adapter,\n name,\n}: {\n adapter?: () => Consent | undefined;\n name: string;\n}): Consent | undefined => {\n const cookie = getCookie(name);\n\n if (cookie) {\n const consent = JSON.parse(cookie[1]);\n\n return consent as Consent;\n }\n\n if (adapter) {\n return adapter();\n }\n\n return undefined;\n};\n\n// 120 days\nconst DEFAULT_MAX_AGE = 10368000;\n\nexport const setConsentCookie = ({\n consent,\n maxAge = DEFAULT_MAX_AGE,\n name,\n domain,\n}: {\n consent: Consent;\n maxAge?: number;\n name: string;\n domain?: string;\n}): void => {\n document.cookie = [\n `${name}=${JSON.stringify(consent)}`,\n `max-age=${maxAge}`,\n `SameSite=Lax`,\n !!domain && `domain=${domain}`,\n ]\n .filter((f) => f)\n .join(\";\");\n};\n\nexport const shouldShowConsentDialog = (\n requirement: ConsentRequirement,\n consent: Consent | undefined,\n): boolean => {\n if (!consent) {\n // check if requirement has truthy values. should show consent if it has\n return Object.values(requirement).some(\n (requirementValue) => requirementValue,\n );\n } else {\n // convert to a map to ease accessing dynamic keys\n const consentMap = new Map(Object.entries(consent));\n\n // pls spare the CPU of converting to an entries array 3 times\n const requirementEntries = Object.entries(requirement);\n\n for (const [name, required] of requirementEntries) {\n // no need to check more if the value isn't required\n if (!required) {\n continue;\n }\n\n // cancel and show consent if a value isn't decided\n if (consentMap.get(name) === null) {\n return true;\n }\n }\n\n return false;\n }\n};\n\nexport const convertBooleanToConsentValue = (\n formValue: boolean | undefined,\n): ConsentState => {\n if (typeof formValue === \"undefined\") {\n return null;\n }\n\n if (formValue === false || String(formValue).toLowerCase() === \"false\") {\n return \"denied\";\n }\n\n return \"accepted\";\n};\n\nexport const convertBooleanConsentObjectToConsentObject = (\n consent: Partial<Record<keyof Consent, boolean | undefined>>,\n requirement: ConsentRequirement,\n): Consent => {\n return {\n functional: requirement.functional\n ? convertBooleanToConsentValue(consent.functional)\n : undefined,\n statistics: requirement.statistics\n ? convertBooleanToConsentValue(consent.statistics)\n : undefined,\n marketing: requirement.marketing\n ? convertBooleanToConsentValue(consent.marketing)\n : undefined,\n };\n};\n\nexport const buildRequirementsObject = ({\n marketing,\n functional,\n statistics,\n}: ConsentRequirement) => {\n return {\n ...(marketing && { marketing }),\n ...(functional && { functional }),\n ...(statistics && { statistics }),\n };\n};\n"],"names":["convertBooleanToConsentValue","formValue","String","toLowerCase","marketing","functional","statistics","consent","requirement","adapter","name","cookie","document","split","map","s","trim","find","c","getCookie","JSON","parse","maxAge","domain","stringify","filter","f","join","consentMap","Map","Object","entries","requirementEntries","required","get","values","some","requirementValue"],"mappings":"gFAEA,MAkGaA,EACTC,UAEWA,EAAc,IACd,MAGO,IAAdA,GAA2D,UAApCC,OAAOD,GAAWE,cAClC,SAGJ,2CAoB4B,EACnCC,UAAAA,EACAC,WAAAA,EACAC,WAAAA,MAEO,IACCF,GAAa,CAAEA,UAAAA,MACfC,GAAc,CAAEA,WAAAA,MAChBC,GAAc,CAAEA,WAAAA,wDAzB8B,CACtDC,EACAC,KAAAA,CAGIH,WAAYG,EAAYH,WAClBL,EAA6BO,EAAQF,iBACrC,EACNC,WAAYE,EAAYF,WAClBN,EAA6BO,EAAQD,iBACrC,EACNF,UAAWI,EAAYJ,UACjBJ,EAA6BO,EAAQH,gBACrC,oEAzGkB,EAC5BK,QAAAA,EACAC,KAAAA,MAKM,MAAAC,EA3BSD,KACX,UAAOE,SAAa,IACb,OAGL,MAAAD,EAASC,SAASD,OAEnBE,MAAM,KAENC,KAAKC,GAAMA,EAAEC,OAAOH,MAAM,OAE1BI,MAAMC,GAAMA,EAAE,KAAOR,IAE1B,OAAKC,QAAL,CAIOA,EAUQQ,CAAUT,GAEzB,OAAIC,EACgBS,KAAKC,MAAMV,EAAO,IAKlCF,EACOA,SADX,CACmB,2BASS,EAC5BF,QAAAA,EACAe,OAAAA,EAJoB,QAKpBZ,KAAAA,EACAa,OAAAA,MAOAX,SAASD,OAAS,CACd,GAAGD,KAAQU,KAAKI,UAAUjB,KAC1B,WAAWe,IACX,iBACEC,GAAU,UAAUA,KAErBE,QAAQC,GAAMA,IACdC,KAAK,IAAG,kCAGsB,CACnCnB,EACAD,KAEA,GAAKA,EAKE,CAEH,MAAMqB,EAAa,IAAIC,IAAIC,OAAOC,QAAQxB,IAGpCyB,EAAqBF,OAAOC,QAAQvB,GAE1C,IAAW,MAACE,EAAMuB,KAAaD,EAE3B,GAAKC,GAKwB,OAAzBL,EAAWM,IAAIxB,GACR,OAAA,EAIR,OAAA,CAAA,QAtBAoB,OAAOK,OAAO3B,GAAa4B,MAC7BC,GAAqBA,GAC1B"}
1
+ {"version":3,"file":"cookieConsentUtils.cjs","sources":["../../../../src/components/cookie-consent/cookieConsentUtils.ts"],"sourcesContent":["import type { Consent, ConsentRequirement, ConsentState } from \"./types.js\";\n\nconst getCookie = (name: string) => {\n if (typeof document === \"undefined\") {\n return undefined;\n }\n\n const cookie = document.cookie\n // split a string of cookies into array of cookies\n .split(\";\")\n // split cookies into [name, value]\n .map((s) => s.trim().split(\"=\"))\n // find our golden nugget\n .find((c) => c[0] === name);\n\n if (!cookie) {\n return undefined;\n }\n\n return cookie;\n};\n\nexport const getConsentCookie = ({\n adapter,\n name,\n}: {\n adapter?: () => Consent | undefined;\n name: string;\n}): Consent | undefined => {\n const cookie = getCookie(name);\n\n if (cookie) {\n const consent = JSON.parse(cookie[1]);\n\n return consent as Consent;\n }\n\n if (adapter) {\n return adapter();\n }\n\n return undefined;\n};\n\n// 120 days\nconst DEFAULT_MAX_AGE = 10368000;\n\nexport const setConsentCookie = ({\n consent,\n maxAge = DEFAULT_MAX_AGE,\n name,\n domain,\n}: {\n consent: Consent;\n maxAge?: number;\n name: string;\n domain?: string;\n}): void => {\n document.cookie = [\n `${name}=${JSON.stringify(consent)}`,\n `max-age=${maxAge}`,\n `SameSite=Lax`,\n !!domain && `domain=${domain}`,\n ]\n .filter((f) => f)\n .join(\";\");\n};\n\nexport const shouldShowConsentDialog = (\n requirement: ConsentRequirement,\n consent: Consent | undefined,\n): boolean => {\n if (!consent) {\n // check if requirement has truthy values. should show consent if it has\n return Object.values(requirement).some(\n (requirementValue) => requirementValue,\n );\n } else {\n // convert to a map to ease accessing dynamic keys\n const consentMap = new Map(Object.entries(consent));\n\n // pls spare the CPU of converting to an entries array 3 times\n const requirementEntries = Object.entries(requirement);\n\n for (const [name, required] of requirementEntries) {\n // no need to check more if the value isn't required\n if (!required) {\n continue;\n }\n\n // cancel and show consent if a value isn't decided\n if (consentMap.get(name) === null) {\n return true;\n }\n }\n\n return false;\n }\n};\n\nexport const convertBooleanToConsentValue = (\n formValue: boolean | undefined,\n): ConsentState => {\n if (typeof formValue === \"undefined\") {\n return null;\n }\n\n if (formValue === false || String(formValue).toLowerCase() === \"false\") {\n return \"denied\";\n }\n\n return \"accepted\";\n};\n\nexport const convertBooleanConsentObjectToConsentObject = (\n consent: Partial<Record<keyof Consent, boolean | undefined>>,\n requirement: ConsentRequirement,\n): Consent => {\n return {\n functional: requirement.functional\n ? convertBooleanToConsentValue(consent.functional)\n : undefined,\n statistics: requirement.statistics\n ? convertBooleanToConsentValue(consent.statistics)\n : undefined,\n marketing: requirement.marketing\n ? convertBooleanToConsentValue(consent.marketing)\n : undefined,\n };\n};\n\nexport const buildRequirementsObject = ({\n marketing,\n functional,\n statistics,\n}: ConsentRequirement) => {\n return {\n ...(marketing && { marketing }),\n ...(functional && { functional }),\n ...(statistics && { statistics }),\n };\n};\n"],"names":["convertBooleanToConsentValue","formValue","String","toLowerCase","marketing","functional","statistics","consent","requirement","adapter","name","cookie","document","split","map","s","trim","find","c","getCookie","JSON","parse","maxAge","domain","stringify","filter","f","join","consentMap","Map","Object","entries","requirementEntries","required","get","values","some","requirementValue"],"mappings":"gFAEA,MAkGaA,EACTC,UAEWA,EAAc,IACd,MAGO,IAAdA,GAA2D,UAApCC,OAAOD,GAAWE,cAClC,SAGJ,2CAoB4B,EACnCC,UAAAA,EACAC,WAAAA,EACAC,WAAAA,MAEO,IACCF,GAAa,CAAEA,UAAAA,MACfC,GAAc,CAAEA,WAAAA,MAChBC,GAAc,CAAEA,WAAAA,wDAzB8B,CACtDC,EACAC,KAAAA,CAGIH,WAAYG,EAAYH,WAClBL,EAA6BO,EAAQF,iBACrC,EACNC,WAAYE,EAAYF,WAClBN,EAA6BO,EAAQD,iBACrC,EACNF,UAAWI,EAAYJ,UACjBJ,EAA6BO,EAAQH,gBACrC,oEAzGkB,EAC5BK,QAAAA,EACAC,KAAAA,MAKM,MAAAC,EA3BSD,KACX,UAAOE,SAAa,IACb,OAGL,MAAAD,EAASC,SAASD,OAEnBE,MAAM,KAENC,KAAKC,GAAMA,EAAEC,OAAOH,MAAM,OAE1BI,MAAMC,GAAMA,EAAE,KAAOR,IAE1B,OAAKC,QAAL,CAIOA,EAUQQ,CAAUT,GAEzB,OAAIC,EACgBS,KAAKC,MAAMV,EAAO,IAKlCF,EACOA,SADX,CACmB,2BASS,EAC5BF,QAAAA,EACAe,OAAAA,EAJoB,QAKpBZ,KAAAA,EACAa,OAAAA,MAOAX,SAASD,OAAS,CACd,GAAGD,KAAQU,KAAKI,UAAUjB,KAC1B,WAAWe,IACX,iBACEC,GAAU,UAAUA,KAErBE,QAAQC,GAAMA,IACdC,KAAK,IAAG,kCAGsB,CACnCnB,EACAD,KAEA,GAAKA,EAKE,CAEH,MAAMqB,EAAa,IAAIC,IAAIC,OAAOC,QAAQxB,IAGpCyB,EAAqBF,OAAOC,QAAQvB,GAE1C,IAAW,MAACE,EAAMuB,KAAaD,EAE3B,GAAKC,GAKwB,OAAzBL,EAAWM,IAAIxB,GACR,OAAA,EAIR,OAAA,CACX,QAvBWoB,OAAOK,OAAO3B,GAAa4B,MAC7BC,GAAqBA,GAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.cjs","sources":["../../../../src/components/datepicker/DatePicker.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { startOfDay } from \"date-fns\";\nimport React, {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { CalendarIcon } from \"../icon/icons/CalendarIcon.js\";\nimport { IconButton } from \"../icon-button/IconButton.js\";\nimport { InputGroup } from \"../input-group/InputGroup.js\";\nimport Popover from \"../popover/Popover.js\";\nimport { BaseTextInput } from \"../text-input/BaseTextInput.js\";\nimport { Calendar } from \"./internal/Calendar.js\";\nimport { DateInfo, getInitialDate } from \"./internal/utils.js\";\nimport { DatePickerProps, DateValidationError } from \"./types.js\";\nimport { formatInput, parseDateString } from \"./utils.js\";\nimport { isWithinLowerBound, isWithinUpperBound } from \"./validation.js\";\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(\n (props, forwardedInputRef) => {\n const {\n \"data-testautoid\": testAutoId,\n id,\n className = \"\",\n label = \"Velg dato\",\n labelProps,\n defaultValue,\n defaultShow = false,\n value,\n disableBeforeDate: disableBefore,\n disableAfterDate: disableAfter,\n yearsToShow,\n name,\n helpLabel,\n errorLabel,\n invalid,\n density,\n days,\n months,\n monthLabel,\n yearLabel,\n placeholder = \"dd.mm.åååå\",\n width = \"11.25rem\",\n onChange,\n onBlur,\n onFocus,\n onKeyDown,\n action,\n showCalendarLabel = \"Åpne kalender\",\n hideCalendarLabel = \"Lukk kalender\",\n supportLabelProps,\n tooltip,\n textInputProps,\n ...rest\n } = props;\n\n if (process.env.NODE_ENV !== \"production\" && value && defaultValue) {\n console.warn(\n \"DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.\",\n );\n }\n /// Input state\n\n const disableBeforeDate = parseDateString(disableBefore);\n const minDate = disableBeforeDate\n ? startOfDay(disableBeforeDate)\n : undefined;\n const disableAfterDate = parseDateString(disableAfter);\n const maxDate = disableAfterDate\n ? startOfDay(disableAfterDate)\n : undefined;\n\n const [date, setDate] = useState(\n getInitialDate(value, defaultValue, minDate, maxDate),\n );\n const [error, setError] = useState<DateValidationError | null>(null);\n\n /// Calendar state\n\n const [showCalendar, setShowCalendar] = useState(defaultShow);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n const datepickerRef = useRef<HTMLDivElement>(null);\n\n /// Input events\n\n const iconButtonRef = useRef<HTMLButtonElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n // Hjelper for å gjøre det enklere å både forwarde refen men også bruke den selv internt\n const unifiedInputRef = useCallback(\n (instance: HTMLInputElement | null) => {\n inputRef.current = instance;\n if (forwardedInputRef) {\n if (typeof forwardedInputRef === \"function\") {\n forwardedInputRef(instance);\n } else {\n forwardedInputRef.current = instance;\n }\n }\n },\n [inputRef, forwardedInputRef],\n );\n\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (!onFocus || !datepickerRef.current) {\n return;\n }\n\n const nextFocusIsInside = datepickerRef.current.contains(\n e.relatedTarget as Node,\n );\n if (!nextFocusIsInside) {\n onFocus(e, date, { error, value: e.target.value });\n }\n },\n [onFocus, date, error],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e, date, { error, value: e.target.value });\n }\n },\n [onBlur, date, error],\n );\n\n const handleKeyDownAction = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Escape\") {\n setShowCalendar(false);\n e.preventDefault();\n e.stopPropagation();\n }\n\n if (action?.onKeyDown) {\n action.onKeyDown(e);\n }\n },\n [setShowCalendar, action],\n );\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n let nextDate: Date | null = null;\n let nextError: DateValidationError | null = null;\n\n if (e.target.value) {\n const val = parseDateString(e.target.value);\n if (!val) {\n nextError = \"WRONG_FORMAT\";\n } else if (minDate && !isWithinLowerBound(val, minDate)) {\n nextError = \"OUTSIDE_LOWER_BOUND\";\n } else if (maxDate && !isWithinUpperBound(val, maxDate)) {\n nextError = \"OUTSIDE_UPPER_BOUND\";\n } else {\n setShowCalendar(false);\n }\n nextDate = val || null;\n }\n\n setError(nextError);\n setDate(nextDate);\n\n if (onChange) {\n onChange(e, nextDate, {\n error: nextError,\n value: e.target.value,\n });\n }\n },\n [onChange, setError, setDate, setShowCalendar, minDate, maxDate],\n );\n\n /// Calendar events\n\n const clickCalendar = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n flushSync(() => {\n setShowCalendar(!showCalendar);\n });\n\n const calendarEl = calendarRef.current;\n const button =\n calendarEl &&\n (calendarEl.querySelector(\n '[aria-pressed=\"true\"]',\n ) as HTMLButtonElement);\n // Make sure the popover-modal is correctly positioned before focusing a button\n // so we avoid accidentally scrolling to the top of the page\n window.requestAnimationFrame(() => button && button.focus());\n\n if (action?.onClick) {\n action.onClick(e);\n }\n },\n [setShowCalendar, showCalendar, action, calendarRef],\n );\n\n const handleClickCalendarDay = useCallback(\n ({ date }: DateInfo) => {\n setShowCalendar(false);\n setDate(date);\n\n if (inputRef.current) {\n const node = inputRef.current;\n\n node.value = formatInput(date);\n\n // Simulér et change-event så APIet blir så likt som mulig en endring av inputfeltet\n const event = document.createEvent(\"HTMLEvents\");\n event.initEvent(\"input\", true, false);\n node.dispatchEvent(event);\n\n node.focus();\n\n if (onChange) {\n // Det er ikke helt sant at dette er et React.SyntheticEvent, men it's fine – probably?\n // Den har tingene man kan forvente, men hvis du gjør serdeles fancy ting med events\n // så kan det hende du må utvide denne for å dekke behovet ditt.\n onChange(\n event as unknown as ChangeEvent<HTMLInputElement>,\n date,\n {\n error: null,\n value: node.value,\n },\n );\n }\n }\n },\n [setShowCalendar, setDate, onChange],\n );\n\n const handleTabOutsideCalendar = useCallback(\n (e: KeyboardEvent) => {\n e.preventDefault();\n setShowCalendar(false);\n iconButtonRef.current && iconButtonRef.current.focus();\n },\n [setShowCalendar],\n );\n\n return (\n <InputGroup\n id={id}\n className={clsx(\"jkl-datepicker\", className, {\n \"jkl-datepicker--open\": showCalendar,\n })}\n {...rest}\n ref={datepickerRef}\n label={label}\n labelProps={labelProps}\n density={density}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n supportLabelProps={supportLabelProps}\n tooltip={tooltip}\n render={(inputProps) => (\n <BaseTextInput\n ref={unifiedInputRef}\n data-testid=\"jkl-datepicker__input\"\n data-testautoid={testAutoId}\n className=\"jkl-datepicker__input\"\n name={name}\n defaultValue={defaultValue}\n density={density}\n value={value}\n type=\"text\"\n placeholder={placeholder}\n width={width}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={handleChange}\n actionButton={\n <Popover\n positionReference={inputRef}\n open={showCalendar}\n onOpenChange={() =>\n setShowCalendar(!showCalendar)\n }\n offset={8}\n >\n <Popover.Trigger\n {...action}\n data-testid=\"jkl-datepicker__trigger\"\n className=\"jkl-text-input-action-button\"\n title={\n showCalendar\n ? hideCalendarLabel\n : showCalendarLabel\n }\n tabIndex={0}\n onClick={clickCalendar}\n onKeyDown={handleKeyDownAction}\n asChild\n >\n <IconButton>\n <CalendarIcon />\n </IconButton>\n </Popover.Trigger>\n <Popover.Content initialFocus={-1} padding={24}>\n <Calendar\n ref={calendarRef}\n density={density}\n date={date}\n minDate={minDate}\n maxDate={maxDate}\n days={days}\n months={months}\n monthLabel={monthLabel}\n yearLabel={yearLabel}\n yearsToShow={yearsToShow}\n onDateSelected={handleClickCalendarDay}\n onTabOutside={handleTabOutsideCalendar}\n />\n </Popover.Content>\n </Popover>\n }\n {...textInputProps}\n {...inputProps}\n />\n )}\n />\n );\n },\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":["DatePicker","forwardRef","props","forwardedInputRef","testAutoId","id","className","label","labelProps","defaultValue","defaultShow","value","disableBeforeDate","disableBefore","disableAfterDate","disableAfter","yearsToShow","name","helpLabel","errorLabel","invalid","density","days","months","monthLabel","yearLabel","placeholder","width","onChange","onBlur","onFocus","onKeyDown","action","showCalendarLabel","hideCalendarLabel","supportLabelProps","tooltip","textInputProps","rest","process","env","NODE_ENV","console","warn","parseDateString","minDate","startOfDay","maxDate","date","setDate","useState","getInitialDate","error","setError","showCalendar","setShowCalendar","calendarRef","useRef","datepickerRef","iconButtonRef","inputRef","unifiedInputRef","useCallback","instance","current","handleFocus","e","contains","relatedTarget","target","handleBlur","handleKeyDownAction","key","preventDefault","stopPropagation","handleChange","nextDate","nextError","val","isWithinLowerBound","isWithinUpperBound","clickCalendar","flushSync","calendarEl","button","querySelector","window","requestAnimationFrame","focus","onClick","handleClickCalendarDay","node","formatInput","event","document","createEvent","initEvent","dispatchEvent","handleTabOutsideCalendar","jsx","InputGroup","clsx","ref","render","inputProps","BaseTextInput","type","actionButton","jsxs","Popover","positionReference","open","onOpenChange","offset","children","Trigger","title","tabIndex","asChild","IconButton","CalendarIcon","Content","initialFocus","padding","Calendar","onDateSelected","onTabOutside","displayName"],"mappings":"8iBAwBaA,EAAaC,EAAAA,YACtB,CAACC,EAAOC,KACE,MACF,kBAAmBC,EACnBC,GAAAA,EACAC,UAAAA,EAAY,GACZC,MAAAA,EAAQ,YACRC,WAAAA,EACAC,aAAAA,EACAC,YAAAA,GAAc,EACdC,MAAAA,EACAC,kBAAmBC,EACnBC,iBAAkBC,EAClBC,YAAAA,EACAC,KAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAC,YAAAA,EAAc,aAC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ACA6G,eAAgBnC,GAChBoC,aAAc5B,aAK1B7D,KACAmE,KAGhB,IAKZxG,EAAW+H,YAAc"}
1
+ {"version":3,"file":"DatePicker.cjs","sources":["../../../../src/components/datepicker/DatePicker.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { startOfDay } from \"date-fns\";\nimport React, {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { CalendarIcon } from \"../icon/icons/CalendarIcon.js\";\nimport { IconButton } from \"../icon-button/IconButton.js\";\nimport { InputGroup } from \"../input-group/InputGroup.js\";\nimport Popover from \"../popover/Popover.js\";\nimport { BaseTextInput } from \"../text-input/BaseTextInput.js\";\nimport { Calendar } from \"./internal/Calendar.js\";\nimport { DateInfo, getInitialDate } from \"./internal/utils.js\";\nimport { DatePickerProps, DateValidationError } from \"./types.js\";\nimport { formatInput, parseDateString } from \"./utils.js\";\nimport { isWithinLowerBound, isWithinUpperBound } from \"./validation.js\";\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(\n (props, forwardedInputRef) => {\n const {\n \"data-testautoid\": testAutoId,\n id,\n className = \"\",\n label = \"Velg dato\",\n labelProps,\n defaultValue,\n defaultShow = false,\n value,\n disableBeforeDate: disableBefore,\n disableAfterDate: disableAfter,\n yearsToShow,\n name,\n helpLabel,\n errorLabel,\n invalid,\n density,\n days,\n months,\n monthLabel,\n yearLabel,\n placeholder = \"dd.mm.åååå\",\n width = \"11.25rem\",\n onChange,\n onBlur,\n onFocus,\n onKeyDown,\n action,\n showCalendarLabel = \"Åpne kalender\",\n hideCalendarLabel = \"Lukk kalender\",\n supportLabelProps,\n tooltip,\n textInputProps,\n ...rest\n } = props;\n\n if (process.env.NODE_ENV !== \"production\" && value && defaultValue) {\n console.warn(\n \"DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.\",\n );\n }\n /// Input state\n\n const disableBeforeDate = parseDateString(disableBefore);\n const minDate = disableBeforeDate\n ? startOfDay(disableBeforeDate)\n : undefined;\n const disableAfterDate = parseDateString(disableAfter);\n const maxDate = disableAfterDate\n ? startOfDay(disableAfterDate)\n : undefined;\n\n const [date, setDate] = useState(\n getInitialDate(value, defaultValue, minDate, maxDate),\n );\n const [error, setError] = useState<DateValidationError | null>(null);\n\n /// Calendar state\n\n const [showCalendar, setShowCalendar] = useState(defaultShow);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n const datepickerRef = useRef<HTMLDivElement>(null);\n\n /// Input events\n\n const iconButtonRef = useRef<HTMLButtonElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n // Hjelper for å gjøre det enklere å både forwarde refen men også bruke den selv internt\n const unifiedInputRef = useCallback(\n (instance: HTMLInputElement | null) => {\n inputRef.current = instance;\n if (forwardedInputRef) {\n if (typeof forwardedInputRef === \"function\") {\n forwardedInputRef(instance);\n } else {\n forwardedInputRef.current = instance;\n }\n }\n },\n [inputRef, forwardedInputRef],\n );\n\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (!onFocus || !datepickerRef.current) {\n return;\n }\n\n const nextFocusIsInside = datepickerRef.current.contains(\n e.relatedTarget as Node,\n );\n if (!nextFocusIsInside) {\n onFocus(e, date, { error, value: e.target.value });\n }\n },\n [onFocus, date, error],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e, date, { error, value: e.target.value });\n }\n },\n [onBlur, date, error],\n );\n\n const handleKeyDownAction = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Escape\") {\n setShowCalendar(false);\n e.preventDefault();\n e.stopPropagation();\n }\n\n if (action?.onKeyDown) {\n action.onKeyDown(e);\n }\n },\n [setShowCalendar, action],\n );\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n let nextDate: Date | null = null;\n let nextError: DateValidationError | null = null;\n\n if (e.target.value) {\n const val = parseDateString(e.target.value);\n if (!val) {\n nextError = \"WRONG_FORMAT\";\n } else if (minDate && !isWithinLowerBound(val, minDate)) {\n nextError = \"OUTSIDE_LOWER_BOUND\";\n } else if (maxDate && !isWithinUpperBound(val, maxDate)) {\n nextError = \"OUTSIDE_UPPER_BOUND\";\n } else {\n setShowCalendar(false);\n }\n nextDate = val || null;\n }\n\n setError(nextError);\n setDate(nextDate);\n\n if (onChange) {\n onChange(e, nextDate, {\n error: nextError,\n value: e.target.value,\n });\n }\n },\n [onChange, setError, setDate, setShowCalendar, minDate, maxDate],\n );\n\n /// Calendar events\n\n const clickCalendar = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n flushSync(() => {\n setShowCalendar(!showCalendar);\n });\n\n const calendarEl = calendarRef.current;\n const button =\n calendarEl &&\n (calendarEl.querySelector(\n '[aria-pressed=\"true\"]',\n ) as HTMLButtonElement);\n // Make sure the popover-modal is correctly positioned before focusing a button\n // so we avoid accidentally scrolling to the top of the page\n window.requestAnimationFrame(() => button && button.focus());\n\n if (action?.onClick) {\n action.onClick(e);\n }\n },\n [setShowCalendar, showCalendar, action, calendarRef],\n );\n\n const handleClickCalendarDay = useCallback(\n ({ date }: DateInfo) => {\n setShowCalendar(false);\n setDate(date);\n\n if (inputRef.current) {\n const node = inputRef.current;\n\n node.value = formatInput(date);\n\n // Simulér et change-event så APIet blir så likt som mulig en endring av inputfeltet\n const event = document.createEvent(\"HTMLEvents\");\n event.initEvent(\"input\", true, false);\n node.dispatchEvent(event);\n\n node.focus();\n\n if (onChange) {\n // Det er ikke helt sant at dette er et React.SyntheticEvent, men it's fine – probably?\n // Den har tingene man kan forvente, men hvis du gjør serdeles fancy ting med events\n // så kan det hende du må utvide denne for å dekke behovet ditt.\n onChange(\n event as unknown as ChangeEvent<HTMLInputElement>,\n date,\n {\n error: null,\n value: node.value,\n },\n );\n }\n }\n },\n [setShowCalendar, setDate, onChange],\n );\n\n const handleTabOutsideCalendar = useCallback(\n (e: KeyboardEvent) => {\n e.preventDefault();\n setShowCalendar(false);\n iconButtonRef.current && iconButtonRef.current.focus();\n },\n [setShowCalendar],\n );\n\n return (\n <InputGroup\n id={id}\n className={clsx(\"jkl-datepicker\", className, {\n \"jkl-datepicker--open\": showCalendar,\n })}\n {...rest}\n ref={datepickerRef}\n label={label}\n labelProps={labelProps}\n density={density}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n supportLabelProps={supportLabelProps}\n tooltip={tooltip}\n render={(inputProps) => (\n <BaseTextInput\n ref={unifiedInputRef}\n data-testid=\"jkl-datepicker__input\"\n data-testautoid={testAutoId}\n className=\"jkl-datepicker__input\"\n name={name}\n defaultValue={defaultValue}\n density={density}\n value={value}\n type=\"text\"\n placeholder={placeholder}\n width={width}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={handleChange}\n actionButton={\n <Popover\n positionReference={inputRef}\n open={showCalendar}\n onOpenChange={() =>\n setShowCalendar(!showCalendar)\n }\n offset={8}\n >\n <Popover.Trigger\n {...action}\n data-testid=\"jkl-datepicker__trigger\"\n className=\"jkl-text-input-action-button\"\n title={\n showCalendar\n ? hideCalendarLabel\n : showCalendarLabel\n }\n tabIndex={0}\n onClick={clickCalendar}\n onKeyDown={handleKeyDownAction}\n asChild\n >\n <IconButton>\n <CalendarIcon />\n </IconButton>\n </Popover.Trigger>\n <Popover.Content initialFocus={-1} padding={24}>\n <Calendar\n ref={calendarRef}\n density={density}\n date={date}\n minDate={minDate}\n maxDate={maxDate}\n days={days}\n months={months}\n monthLabel={monthLabel}\n yearLabel={yearLabel}\n yearsToShow={yearsToShow}\n onDateSelected={handleClickCalendarDay}\n onTabOutside={handleTabOutsideCalendar}\n />\n </Popover.Content>\n </Popover>\n }\n {...textInputProps}\n {...inputProps}\n />\n )}\n />\n );\n },\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":["DatePicker","forwardRef","props","forwardedInputRef","testAutoId","id","className","label","labelProps","defaultValue","defaultShow","value","disableBeforeDate","disableBefore","disableAfterDate","disableAfter","yearsToShow","name","helpLabel","errorLabel","invalid","density","days","months","monthLabel","yearLabel","placeholder","width","onChange","onBlur","onFocus","onKeyDown","action","showCalendarLabel","hideCalendarLabel","supportLabelProps","tooltip","textInputProps","rest","process","env","NODE_ENV","console","warn","parseDateString","minDate","startOfDay","maxDate","date","setDate","useState","getInitialDate","error","setError","showCalendar","setShowCalendar","calendarRef","useRef","datepickerRef","iconButtonRef","inputRef","unifiedInputRef","useCallback","instance","current","handleFocus","e","contains","relatedTarget","target","handleBlur","handleKeyDownAction","key","preventDefault","stopPropagation","handleChange","nextDate","nextError","val","isWithinLowerBound","isWithinUpperBound","clickCalendar","flushSync","calendarEl","button","querySelector","window","requestAnimationFrame","focus","onClick","handleClickCalendarDay","node","formatInput","event","document","createEvent","initEvent","dispatchEvent","handleTabOutsideCalendar","jsx","InputGroup","clsx","ref","render","inputProps","BaseTextInput","type","actionButton","jsxs","Popover","positionReference","open","onOpenChange","offset","children","Trigger","title","tabIndex","asChild","IconButton","CalendarIcon","Content","initialFocus","padding","Calendar","onDateSelected","onTabOutside","displayName"],"mappings":"8iBAwBaA,EAAaC,EAAAA,YACtB,CAACC,EAAOC,KACE,MACF,kBAAmBC,EACnBC,GAAAA,EACAC,UAAAA,EAAY,GACZC,MAAAA,EAAQ,YACRC,WAAAA,EACAC,aAAAA,EACAC,YAAAA,GAAc,EACdC,MAAAA,EACAC,kBAAmBC,EACnBC,iBAAkBC,EAClBC,YAAAA,EACAC,KAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAC,YAAAA,EAAc,aACdC,MAAAA,EAAQ,WACRC,SAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,OAAAA,EACAC,kBAAAA,EAAoB,gBACpBC,kBAAAA,EAAoB,g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