@fremtind/jokul 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/README.md +52 -35
  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/index.d.cts +0 -1
  119. package/build/cjs/hooks/useAnimatedDetails/useAnimatedDetails.cjs.map +1 -1
  120. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeight.cjs.map +1 -1
  121. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeightBetween.cjs.map +1 -1
  122. package/build/cjs/hooks/useAnimatedHeight/useAutoAnimateHeight.cjs.map +1 -1
  123. package/build/cjs/hooks/useAriaLiveRegion/useAriaLiveRegion.cjs.map +1 -1
  124. package/build/cjs/hooks/useBrowserPreferences/useBrowserPreferences.cjs.map +1 -1
  125. package/build/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
  126. package/build/cjs/hooks/useElementDimensions/useElementDimensions.cjs.map +1 -1
  127. package/build/cjs/hooks/useFocusOutside/useFocusOutside.cjs.map +1 -1
  128. package/build/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
  129. package/build/cjs/hooks/useKeyListener/useKeyListener.cjs.map +1 -1
  130. package/build/cjs/hooks/useListNavigation/useListNavigation.cjs.map +1 -1
  131. package/build/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
  132. package/build/cjs/hooks/useProgressiveImg/useProgressiveImg.cjs.map +1 -1
  133. package/build/cjs/hooks/useScreen/state.cjs.map +1 -1
  134. package/build/cjs/hooks/useScreen/useScreen.cjs +1 -1
  135. package/build/cjs/hooks/useScreen/useScreen.cjs.map +1 -1
  136. package/build/cjs/index.cjs +1 -1
  137. package/build/cjs/tailwind/colors.cjs.map +1 -0
  138. package/build/cjs/tailwind/index.cjs +2 -0
  139. package/build/cjs/tailwind/index.cjs.map +1 -0
  140. package/build/cjs/tailwind/index.d.cts +2 -0
  141. package/build/cjs/tailwind/plugins/jokulTypographyPlugin.cjs +2 -0
  142. package/build/cjs/tailwind/plugins/jokulTypographyPlugin.cjs.map +1 -0
  143. package/build/cjs/tailwind/plugins/jokulTypographyPlugin.d.cts +4 -0
  144. package/build/cjs/tailwind/tailwindPreset.cjs +2 -0
  145. package/build/cjs/tailwind/tailwindPreset.cjs.map +1 -0
  146. package/build/cjs/tailwind/tailwindPreset.d.cts +2 -0
  147. package/build/cjs/utilities/formatters/avstand/formatAvstand.cjs.map +1 -1
  148. package/build/cjs/utilities/formatters/bytes/formatBytes.cjs.map +1 -1
  149. package/build/cjs/utilities/formatters/fodselsnummer/formatFodselsnummer.cjs.map +1 -1
  150. package/build/cjs/utilities/formatters/kontonummer/formatKontonummer.cjs.map +1 -1
  151. package/build/cjs/utilities/formatters/kortnummer/formatKortnummer.cjs.map +1 -1
  152. package/build/cjs/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.cjs.map +1 -1
  153. package/build/cjs/utilities/formatters/telefonnummer/formatTelefonnummer.cjs.map +1 -1
  154. package/build/cjs/utilities/formatters/util/registerWithMask.cjs.map +1 -1
  155. package/build/cjs/utilities/getThemeAndDensity.cjs.map +1 -1
  156. package/build/cjs/utilities/polymorphism/SlotComponent.cjs.map +1 -1
  157. package/build/cjs/utilities/polymorphism/mergeProps.cjs.map +1 -1
  158. package/build/cjs/utilities/tabListener.cjs.map +1 -1
  159. package/build/cjs/utilities/validators/isValidKortnummer/isValidKortnummer.cjs.map +1 -1
  160. package/build/es/components/accordion/AccordionItem.js.map +1 -1
  161. package/build/es/components/autosuggest/Autosuggest.js +1 -1
  162. package/build/es/components/autosuggest/Autosuggest.js.map +1 -1
  163. package/build/es/components/autosuggest/BaseAutosuggest.js +2 -2
  164. package/build/es/components/autosuggest/BaseAutosuggest.js.map +1 -1
  165. package/build/es/components/autosuggest/utils.js.map +1 -1
  166. package/build/es/components/breadcrumb/Breadcrumb.js.map +1 -1
  167. package/build/es/components/button/Button.js.map +1 -1
  168. package/build/es/components/card/NavCard.js.map +1 -1
  169. package/build/es/components/checkbox/Checkbox.js.map +1 -1
  170. package/build/es/components/combobox/Combobox.js.map +1 -1
  171. package/build/es/components/cookie-consent/CookieConsent.js.map +1 -1
  172. package/build/es/components/cookie-consent/CookieConsentContext.js.map +1 -1
  173. package/build/es/components/cookie-consent/cookieConsentUtils.js.map +1 -1
  174. package/build/es/components/datepicker/DatePicker.js.map +1 -1
  175. package/build/es/components/datepicker/internal/Calendar.js.map +1 -1
  176. package/build/es/components/datepicker/internal/calendarReducer.js.map +1 -1
  177. package/build/es/components/datepicker/internal/useCalendar.js.map +1 -1
  178. package/build/es/components/datepicker/internal/utils.js.map +1 -1
  179. package/build/es/components/expander/ExpandablePanelContent.js.map +1 -1
  180. package/build/es/components/expander/Expander.js.map +1 -1
  181. package/build/es/components/expander/deprecated/ExpandSection.js.map +1 -1
  182. package/build/es/components/expander/deprecated/Expander.js.map +1 -1
  183. package/build/es/components/feedback/Feedback.js.map +1 -1
  184. package/build/es/components/feedback/followup/useFollowup.js.map +1 -1
  185. package/build/es/components/feedback/main-question/useMainQuestion.js.map +1 -1
  186. package/build/es/components/feedback/questions/CheckboxQuestion.js.map +1 -1
  187. package/build/es/components/feedback/questions/ContactQuestion.js.map +1 -1
  188. package/build/es/components/feedback/questions/RadioQuestion.js.map +1 -1
  189. package/build/es/components/feedback/questions/SmileyQuestion.js.map +1 -1
  190. package/build/es/components/feedback/questions/TextQuestion.js.map +1 -1
  191. package/build/es/components/feedback/questions/smileyUtils.js.map +1 -1
  192. package/build/es/components/feedback/utils.js.map +1 -1
  193. package/build/es/components/file-input/File.js.map +1 -1
  194. package/build/es/components/file-input/FileInput.js.map +1 -1
  195. package/build/es/components/file-input/internal/Dropzone.js.map +1 -1
  196. package/build/es/components/file-input/internal/Input.js.map +1 -1
  197. package/build/es/components/flex/Flex.js.map +1 -1
  198. package/build/es/components/icon-button/IconButton.js.map +1 -1
  199. package/build/es/components/image/Image.js.map +1 -1
  200. package/build/es/components/image/useImageLoadingStatus.js.map +1 -1
  201. package/build/es/components/input-group/FieldGroup.js.map +1 -1
  202. package/build/es/components/input-group/InputGroup.js.map +1 -1
  203. package/build/es/components/input-group/Label.js.map +1 -1
  204. package/build/es/components/input-group/SupportLabel.js.map +1 -1
  205. package/build/es/components/input-panel/RadioPanel.js.map +1 -1
  206. package/build/es/components/loader/Loader.js.map +1 -1
  207. package/build/es/components/loader/skeletons/SkeletonAnimation.js.map +1 -1
  208. package/build/es/components/loader/skeletons/SkeletonLabel.js.map +1 -1
  209. package/build/es/components/loader/skeletons/SkeletonTextArea.js.map +1 -1
  210. package/build/es/components/logo/Logo.js.map +1 -1
  211. package/build/es/components/logo/LogoStamp.js.map +1 -1
  212. package/build/es/components/menu/Menu.js.map +1 -1
  213. package/build/es/components/menu/MenuItem.js.map +1 -1
  214. package/build/es/components/menu/MenuItemCheckbox.js.map +1 -1
  215. package/build/es/components/menu/useMenuWideEvents.js.map +1 -1
  216. package/build/es/components/message/FormErrorMessage.js.map +1 -1
  217. package/build/es/components/message/Message.js.map +1 -1
  218. package/build/es/components/pagination/Pagination.js.map +1 -1
  219. package/build/es/components/popover/Popover.js.map +1 -1
  220. package/build/es/components/progress-bar/Countdown.js.map +1 -1
  221. package/build/es/components/progress-bar/ProgressBar.js.map +1 -1
  222. package/build/es/components/radio-button/BaseRadioButton.js.map +1 -1
  223. package/build/es/components/radio-button/RadioButtonGroup.js.map +1 -1
  224. package/build/es/components/select/NativeSelect.js.map +1 -1
  225. package/build/es/components/select/Select.js.map +1 -1
  226. package/build/es/components/system-message/SystemMessage.js.map +1 -1
  227. package/build/es/components/system-message/common/MessageIcon.js.map +1 -1
  228. package/build/es/components/table/ExpandableTableRowController.js.map +1 -1
  229. package/build/es/components/table/Table.js.map +1 -1
  230. package/build/es/components/table/TableCell.js.map +1 -1
  231. package/build/es/components/table/TableHead.js.map +1 -1
  232. package/build/es/components/table/TableHeader.js.map +1 -1
  233. package/build/es/components/table/TablePagination.js.map +1 -1
  234. package/build/es/components/table/TableRow.js.map +1 -1
  235. package/build/es/components/table/utils.js.map +1 -1
  236. package/build/es/components/tabs/NavTab.js.map +1 -1
  237. package/build/es/components/tabs/NavTabs.js.map +1 -1
  238. package/build/es/components/tabs/Tab.js.map +1 -1
  239. package/build/es/components/tabs/TabList.js.map +1 -1
  240. package/build/es/components/tabs/Tabs.js.map +1 -1
  241. package/build/es/components/text-input/BaseTextArea.js.map +1 -1
  242. package/build/es/components/text-input/BaseTextInput.js.map +1 -1
  243. package/build/es/components/text-input/TextArea.js.map +1 -1
  244. package/build/es/components/text-input/TextInput.js.map +1 -1
  245. package/build/es/components/toast/Toast.js.map +1 -1
  246. package/build/es/components/toast/toastContext.js.map +1 -1
  247. package/build/es/components/toggle-switch/ToggleSlider.js.map +1 -1
  248. package/build/es/components/toggle-switch/ToggleSwitch.js.map +1 -1
  249. package/build/es/components/toggle-switch/usePillStyles.js.map +1 -1
  250. package/build/es/components/tooltip/Tooltip.js.map +1 -1
  251. package/build/es/components/tooltip/TooltipTrigger.js.map +1 -1
  252. package/build/es/core/index.d.ts +0 -1
  253. package/build/es/core/index.js +1 -1
  254. package/build/es/hooks/useAnimatedDetails/useAnimatedDetails.js.map +1 -1
  255. package/build/es/hooks/useAnimatedHeight/useAnimatedHeight.js.map +1 -1
  256. package/build/es/hooks/useAnimatedHeight/useAnimatedHeightBetween.js.map +1 -1
  257. package/build/es/hooks/useAnimatedHeight/useAutoAnimateHeight.js.map +1 -1
  258. package/build/es/hooks/useAriaLiveRegion/useAriaLiveRegion.js.map +1 -1
  259. package/build/es/hooks/useBrowserPreferences/useBrowserPreferences.js.map +1 -1
  260. package/build/es/hooks/useClickOutside/useClickOutside.js.map +1 -1
  261. package/build/es/hooks/useElementDimensions/useElementDimensions.js.map +1 -1
  262. package/build/es/hooks/useFocusOutside/useFocusOutside.js.map +1 -1
  263. package/build/es/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -1
  264. package/build/es/hooks/useKeyListener/useKeyListener.js.map +1 -1
  265. package/build/es/hooks/useListNavigation/useListNavigation.js.map +1 -1
  266. package/build/es/hooks/useMutationObserver/useMutationObserver.js.map +1 -1
  267. package/build/es/hooks/useProgressiveImg/useProgressiveImg.js.map +1 -1
  268. package/build/es/hooks/useScreen/state.js.map +1 -1
  269. package/build/es/hooks/useScreen/useScreen.js +1 -1
  270. package/build/es/hooks/useScreen/useScreen.js.map +1 -1
  271. package/build/es/index.js +1 -1
  272. package/build/es/tailwind/colors.js.map +1 -0
  273. package/build/es/tailwind/index.d.ts +2 -0
  274. package/build/es/tailwind/index.js +2 -0
  275. package/build/es/tailwind/index.js.map +1 -0
  276. package/build/es/tailwind/plugins/jokulTypographyPlugin.d.ts +4 -0
  277. package/build/es/tailwind/plugins/jokulTypographyPlugin.js +2 -0
  278. package/build/es/tailwind/plugins/jokulTypographyPlugin.js.map +1 -0
  279. package/build/es/tailwind/tailwindPreset.d.ts +2 -0
  280. package/build/es/tailwind/tailwindPreset.js +2 -0
  281. package/build/es/tailwind/tailwindPreset.js.map +1 -0
  282. package/build/es/utilities/formatters/util/registerWithMask.js.map +1 -1
  283. package/build/es/utilities/getThemeAndDensity.js.map +1 -1
  284. package/build/es/utilities/polymorphism/SlotComponent.js.map +1 -1
  285. package/build/es/utilities/polymorphism/mergeProps.js.map +1 -1
  286. package/build/es/utilities/tabListener.js.map +1 -1
  287. package/build/es/utilities/validators/isValidKortnummer/isValidKortnummer.js.map +1 -1
  288. package/package.json +14 -3
  289. package/styles/components/button/button.css +2 -2
  290. package/styles/components/button/button.min.css +1 -1
  291. package/styles/components/checkbox/checkbox.css +4 -4
  292. package/styles/components/checkbox/checkbox.min.css +1 -1
  293. package/styles/components/feedback/feedback.css +2 -2
  294. package/styles/components/feedback/feedback.min.css +1 -1
  295. package/styles/components/input-group/input-group.css +2 -2
  296. package/styles/components/input-group/input-group.min.css +1 -1
  297. package/styles/components/input-panel/checkbox-panel.css +2 -2
  298. package/styles/components/input-panel/checkbox-panel.min.css +1 -1
  299. package/styles/components/input-panel/radio-panel.css +2 -2
  300. package/styles/components/input-panel/radio-panel.min.css +1 -1
  301. package/styles/components/loader/loader.css +6 -6
  302. package/styles/components/loader/loader.min.css +1 -1
  303. package/styles/components/loader/skeleton-loader.css +5 -5
  304. package/styles/components/loader/skeleton-loader.min.css +1 -1
  305. package/styles/components/message/message.css +2 -2
  306. package/styles/components/message/message.min.css +1 -1
  307. package/styles/components/progress-bar/progress-bar.css +2 -2
  308. package/styles/components/progress-bar/progress-bar.min.css +1 -1
  309. package/styles/components/radio-button/radio-button.css +2 -2
  310. package/styles/components/radio-button/radio-button.min.css +1 -1
  311. package/styles/components/system-message/system-message.css +2 -2
  312. package/styles/components/system-message/system-message.min.css +1 -1
  313. package/styles/components/toast/toast.css +4 -4
  314. package/styles/components/toast/toast.min.css +1 -1
  315. package/styles/styles.css +37 -37
  316. package/styles/styles.min.css +1 -1
  317. package/build/cjs/core/tailwind/colors.cjs.map +0 -1
  318. package/build/cjs/core/tailwind/plugins/typographyPlugin.cjs +0 -2
  319. package/build/cjs/core/tailwind/plugins/typographyPlugin.cjs.map +0 -1
  320. package/build/cjs/core/tailwind/plugins/typographyPlugin.d.cts +0 -2
  321. package/build/cjs/core/tailwind/tailwindPreset.cjs +0 -2
  322. package/build/cjs/core/tailwind/tailwindPreset.cjs.map +0 -1
  323. package/build/cjs/core/tailwind/tailwindPreset.d.cts +0 -3
  324. package/build/es/core/tailwind/colors.js.map +0 -1
  325. package/build/es/core/tailwind/plugins/typographyPlugin.d.ts +0 -2
  326. package/build/es/core/tailwind/plugins/typographyPlugin.js +0 -2
  327. package/build/es/core/tailwind/plugins/typographyPlugin.js.map +0 -1
  328. package/build/es/core/tailwind/tailwindPreset.d.ts +0 -3
  329. package/build/es/core/tailwind/tailwindPreset.js +0 -2
  330. package/build/es/core/tailwind/tailwindPreset.js.map +0 -1
  331. package/build/tailwindPreset-CSQrgZ57.cjs +0 -2
  332. package/build/tailwindPreset-CSQrgZ57.cjs.map +0 -1
  333. package/build/tailwindPreset-D4TYL0kz.js +0 -2
  334. package/build/tailwindPreset-D4TYL0kz.js.map +0 -1
  335. /package/build/cjs/{core/tailwind → tailwind}/colors.cjs +0 -0
  336. /package/build/cjs/{core/tailwind → tailwind}/colors.d.cts +0 -0
  337. /package/build/es/{core/tailwind → tailwind}/colors.d.ts +0 -0
  338. /package/build/es/{core/tailwind → tailwind}/colors.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"useMainQuestion.js","sources":["../../../../../src/components/feedback/main-question/useMainQuestion.ts"],"sourcesContent":["import {\n useState,\n useRef,\n useCallback,\n useEffect,\n SetStateAction,\n Dispatch,\n FormEventHandler,\n} from \"react\";\nimport { FeedbackType, FeedbackOption } from \"../types.js\";\n\ntype Value =\n | FeedbackOption<string | number>\n | FeedbackOption<string | number>[]\n | undefined;\n\ntype MainQuestion = {\n currentValue: Value;\n setCurrentValue: Dispatch<SetStateAction<Value>>;\n message: string | undefined;\n setMessage: Dispatch<SetStateAction<string | undefined>>;\n submitted: boolean;\n handleSubmit: FormEventHandler<HTMLFormElement>;\n};\n\nexport const useMainQuestion = (\n onSubmit: (f: FeedbackType) => void,\n): MainQuestion => {\n const [currentValue, setCurrentValue] = useState<\n FeedbackOption | FeedbackOption[]\n >();\n const [message, setMessage] = useState<string>();\n const [submitted, setSubmitted] = useState(false);\n\n const feedbackRef = useRef({\n onSubmit,\n currentValue,\n message,\n submitted,\n });\n\n useEffect(() => {\n feedbackRef.current = {\n ...feedbackRef.current,\n onSubmit,\n currentValue,\n message,\n submitted,\n };\n }, [onSubmit, currentValue, message, submitted]);\n\n const submitHandler = useCallback((intentionalSubmit = true) => {\n const { message, currentValue, submitted, onSubmit } =\n feedbackRef.current;\n\n if (!submitted && currentValue !== undefined) {\n const feedbackValue = Array.isArray(currentValue)\n ? currentValue.map((option) => option.value)\n : currentValue?.value;\n onSubmit({\n feedbackValue,\n intentionalSubmit,\n ...(intentionalSubmit && message ? { message } : {}),\n });\n }\n }, []);\n\n const autoSubmit = useCallback(() => submitHandler(false), [submitHandler]);\n\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeunload\", autoSubmit);\n }\n return () => {\n autoSubmit();\n window.removeEventListener(\"beforeunload\", autoSubmit);\n };\n }, [autoSubmit]);\n\n const handleSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n submitHandler();\n setSubmitted(true);\n };\n\n return {\n currentValue,\n setCurrentValue,\n message,\n setMessage,\n submitted,\n handleSubmit,\n };\n};\n"],"names":["useMainQuestion","onSubmit","currentValue","setCurrentValue","useState","message","setMessage","submitted","setSubmitted","feedbackRef","useRef","useEffect","current","submitHandler","useCallback","intentionalSubmit","feedbackValue","Array","isArray","map","option","value","autoSubmit","window","addEventListener","removeEventListener","handleSubmit","e","preventDefault"],"mappings":"6EAyBa,MAAAA,EACTC,IAEM,MAACC,EAAcC,GAAmBC,KAGjCC,EAASC,GAAcF,KACvBG,EAAWC,GAAgBJ,GAAS,GAErCK,EAAcC,EAAO,CACvBT,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,IAGJI,GAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACfX,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,EACJ,GACD,CAACN,EAAUC,EAAcG,EAASE,IAErC,MAAMM,EAAgBC,GAAY,CAACC,GAAoB,KAC7C,MAAEV,QAAAA,EAASH,aAAAA,EAAcK,UAAAA,EAAWN,SAAAA,GACtCQ,EAAYG,QAEZ,IAACL,QAA8B,IAAjBL,EAA4B,CAI1CD,EAAS,CACLe,cAJkBC,MAAMC,QAAQhB,GAC9BA,EAAaiB,KAAKC,GAAWA,EAAOC,QACpCnB,MAAAA,SAAAA,EAAcmB,MAGhBN,kBAAAA,KACIA,GAAqBV,EAAU,CAAEA,QAAAA,GAAY,CAAA,GACpD,IAEN,IAEGiB,EAAaR,GAAY,IAAMD,GAAc,IAAQ,CAACA,IAE5DF,OAAAA,GAAU,YACKY,OAAW,KACXA,OAAAC,iBAAiB,eAAgBF,GAErC,KACQA,IACJC,OAAAE,oBAAoB,eAAgBH,EAAU,IAE1D,CAACA,IAQG,CACHpB,aAAAA,EACAC,gBAAAA,EACAE,QAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAmB,aAZqDC,IACrDA,EAAEC,iBACYf,IACdL,GAAa,EAAI,EAUrB"}
1
+ {"version":3,"file":"useMainQuestion.js","sources":["../../../../../src/components/feedback/main-question/useMainQuestion.ts"],"sourcesContent":["import {\n useState,\n useRef,\n useCallback,\n useEffect,\n SetStateAction,\n Dispatch,\n FormEventHandler,\n} from \"react\";\nimport { FeedbackType, FeedbackOption } from \"../types.js\";\n\ntype Value =\n | FeedbackOption<string | number>\n | FeedbackOption<string | number>[]\n | undefined;\n\ntype MainQuestion = {\n currentValue: Value;\n setCurrentValue: Dispatch<SetStateAction<Value>>;\n message: string | undefined;\n setMessage: Dispatch<SetStateAction<string | undefined>>;\n submitted: boolean;\n handleSubmit: FormEventHandler<HTMLFormElement>;\n};\n\nexport const useMainQuestion = (\n onSubmit: (f: FeedbackType) => void,\n): MainQuestion => {\n const [currentValue, setCurrentValue] = useState<\n FeedbackOption | FeedbackOption[]\n >();\n const [message, setMessage] = useState<string>();\n const [submitted, setSubmitted] = useState(false);\n\n const feedbackRef = useRef({\n onSubmit,\n currentValue,\n message,\n submitted,\n });\n\n useEffect(() => {\n feedbackRef.current = {\n ...feedbackRef.current,\n onSubmit,\n currentValue,\n message,\n submitted,\n };\n }, [onSubmit, currentValue, message, submitted]);\n\n const submitHandler = useCallback((intentionalSubmit = true) => {\n const { message, currentValue, submitted, onSubmit } =\n feedbackRef.current;\n\n if (!submitted && currentValue !== undefined) {\n const feedbackValue = Array.isArray(currentValue)\n ? currentValue.map((option) => option.value)\n : currentValue?.value;\n onSubmit({\n feedbackValue,\n intentionalSubmit,\n ...(intentionalSubmit && message ? { message } : {}),\n });\n }\n }, []);\n\n const autoSubmit = useCallback(() => submitHandler(false), [submitHandler]);\n\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeunload\", autoSubmit);\n }\n return () => {\n autoSubmit();\n window.removeEventListener(\"beforeunload\", autoSubmit);\n };\n }, [autoSubmit]);\n\n const handleSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n submitHandler();\n setSubmitted(true);\n };\n\n return {\n currentValue,\n setCurrentValue,\n message,\n setMessage,\n submitted,\n handleSubmit,\n };\n};\n"],"names":["useMainQuestion","onSubmit","currentValue","setCurrentValue","useState","message","setMessage","submitted","setSubmitted","feedbackRef","useRef","useEffect","current","submitHandler","useCallback","intentionalSubmit","feedbackValue","Array","isArray","map","option","value","autoSubmit","window","addEventListener","removeEventListener","handleSubmit","e","preventDefault"],"mappings":"6EAyBa,MAAAA,EACTC,IAEM,MAACC,EAAcC,GAAmBC,KAGjCC,EAASC,GAAcF,KACvBG,EAAWC,GAAgBJ,GAAS,GAErCK,EAAcC,EAAO,CACvBT,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,IAGJI,GAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACfX,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,EAAA,GAEL,CAACN,EAAUC,EAAcG,EAASE,IAErC,MAAMM,EAAgBC,GAAY,CAACC,GAAoB,KAC7C,MAAEV,QAAAA,EAASH,aAAAA,EAAcK,UAAAA,EAAWN,SAAAA,GACtCQ,EAAYG,QAEZ,IAACL,QAA8B,IAAjBL,EAA4B,CAI1CD,EAAS,CACLe,cAJkBC,MAAMC,QAAQhB,GAC9BA,EAAaiB,KAAKC,GAAWA,EAAOC,QACpCnB,MAAAA,SAAAA,EAAcmB,MAGhBN,kBAAAA,KACIA,GAAqBV,EAAU,CAAEA,QAAAA,GAAY,CAAC,GAE1D,IACD,IAEGiB,EAAaR,GAAY,IAAMD,GAAc,IAAQ,CAACA,IAE5DF,OAAAA,GAAU,YACKY,OAAW,KACXA,OAAAC,iBAAiB,eAAgBF,GAErC,KACQA,IACJC,OAAAE,oBAAoB,eAAgBH,EAAU,IAE1D,CAACA,IAQG,CACHpB,aAAAA,EACAC,gBAAAA,EACAE,QAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAmB,aAZqDC,IACrDA,EAAEC,iBACYf,IACdL,GAAa,EAAI,EASjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxQuestion.js","sources":["../../../../../src/components/feedback/questions/CheckboxQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useRef } from \"react\";\nimport { Checkbox } from \"../../checkbox/Checkbox.js\";\nimport { FieldGroup } from \"../../input-group/FieldGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackOption, QuestionProps } from \"../types.js\";\n\nexport const CheckboxQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n options,\n helpLabel,\n autoFocus = false,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n const matchingOption = options?.find(\n (option) => option.value.toString() === value,\n );\n if (!matchingOption) return;\n\n if (!context?.currentValue) {\n context?.setCurrentValue([matchingOption]);\n return;\n }\n\n if (Array.isArray(context?.currentValue)) {\n const found = context.currentValue.find(\n (option) => option === matchingOption,\n );\n if (found) {\n context.setCurrentValue((oldValues) =>\n (oldValues as FeedbackOption[]).filter(\n (option) => option !== found,\n ),\n );\n } else {\n context.setCurrentValue((oldValues) => [\n ...(oldValues as FeedbackOption[]),\n matchingOption,\n ]);\n }\n }\n };\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <FieldGroup\n labelProps={{ variant: \"large\" }}\n legend={label}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <Checkbox\n key={`${label}-${option.value}`}\n name={name || label}\n value={option.value.toString()}\n onChange={handleChange}\n ref={i === 0 ? ref : undefined}\n >\n {option.label}\n </Checkbox>\n ))}\n </FieldGroup>\n );\n};\n"],"names":["CheckboxQuestion","label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","handleChange","event","value","target","matchingOption","find","option","toString","currentValue","setCurrentValue","Array","isArray","found","oldValues","filter","jsx","FieldGroup","labelProps","variant","legend","children","map","i","Checkbox","onChange","console","error"],"mappings":"8VAOO,MAAMA,EAA4C,EACrDC,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAENC,MAAAA,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,EAAyB,MAErCC,GAAU,KACFR,GAAaM,EAAIG,SACjBH,EAAIG,QAAQC,OAAM,GAEvB,CAACV,EAAWM,IAETK,MAAAA,EAAsDC,IAClD,MAAEC,MAAAA,GAAUD,EAAME,OAClBC,EAAiB,MAAAjB,OAAA,EAAAA,EAASkB,MAC3BC,GAAWA,EAAOJ,MAAMK,aAAeL,IAE5C,GAAKE,EAED,CAAA,GAAC,MAAAV,IAAAA,EAASc,aAEV,YADS,MAAAd,GAAAA,EAAAe,gBAAgB,CAACL,KAI9B,GAAIM,MAAMC,QAAQ,MAAAjB,OAAAA,EAAAA,EAASc,cAAe,CAChCI,MAAAA,EAAQlB,EAAQc,aAAaH,MAC9BC,GAAWA,IAAWF,IAEvBQ,EACQlB,EAAAe,iBAAiBI,GACpBA,EAA+BC,QAC3BR,GAAWA,IAAWM,MAIvBlB,EAAAe,iBAAiBI,GAAc,IAC/BA,EACJT,IAER,CAAA,GAIR,OAAKV,EAQDqB,EAACC,EAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQlC,EACRG,UAAAA,EAECgC,SAAS,MAAAjC,OAAAA,EAAAA,EAAAkC,KAAI,CAACf,EAAQgB,IACnBP,EAACQ,EAAA,CAEGrC,KAAMA,GAAQD,EACdiB,MAAOI,EAAOJ,MAAMK,WACpBiB,SAAUxB,EACVL,IAAW,IAAN2B,EAAU3B,OAAM,EAEpByB,SAAOd,EAAArB,OANH,GAAGA,KAASqB,EAAOJ,cAd5BuB,QAAAC,MACJ,yEAEG,KAAA"}
1
+ {"version":3,"file":"CheckboxQuestion.js","sources":["../../../../../src/components/feedback/questions/CheckboxQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useRef } from \"react\";\nimport { Checkbox } from \"../../checkbox/Checkbox.js\";\nimport { FieldGroup } from \"../../input-group/FieldGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackOption, QuestionProps } from \"../types.js\";\n\nexport const CheckboxQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n options,\n helpLabel,\n autoFocus = false,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n const matchingOption = options?.find(\n (option) => option.value.toString() === value,\n );\n if (!matchingOption) return;\n\n if (!context?.currentValue) {\n context?.setCurrentValue([matchingOption]);\n return;\n }\n\n if (Array.isArray(context?.currentValue)) {\n const found = context.currentValue.find(\n (option) => option === matchingOption,\n );\n if (found) {\n context.setCurrentValue((oldValues) =>\n (oldValues as FeedbackOption[]).filter(\n (option) => option !== found,\n ),\n );\n } else {\n context.setCurrentValue((oldValues) => [\n ...(oldValues as FeedbackOption[]),\n matchingOption,\n ]);\n }\n }\n };\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <FieldGroup\n labelProps={{ variant: \"large\" }}\n legend={label}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <Checkbox\n key={`${label}-${option.value}`}\n name={name || label}\n value={option.value.toString()}\n onChange={handleChange}\n ref={i === 0 ? ref : undefined}\n >\n {option.label}\n </Checkbox>\n ))}\n </FieldGroup>\n );\n};\n"],"names":["CheckboxQuestion","label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","handleChange","event","value","target","matchingOption","find","option","toString","currentValue","setCurrentValue","Array","isArray","found","oldValues","filter","jsx","FieldGroup","labelProps","variant","legend","children","map","i","Checkbox","onChange","console","error"],"mappings":"8VAOO,MAAMA,EAA4C,EACrDC,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAENC,MAAAA,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,EAAyB,MAErCC,GAAU,KACFR,GAAaM,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACV,EAAWM,IAETK,MAAAA,EAAsDC,IAClD,MAAEC,MAAAA,GAAUD,EAAME,OAClBC,EAAiB,MAAAjB,OAAA,EAAAA,EAASkB,MAC3BC,GAAWA,EAAOJ,MAAMK,aAAeL,IAE5C,GAAKE,EAED,CAAA,GAAC,MAAAV,IAAAA,EAASc,aAEV,YADS,MAAAd,GAAAA,EAAAe,gBAAgB,CAACL,KAI9B,GAAIM,MAAMC,QAAQ,MAAAjB,OAAAA,EAAAA,EAASc,cAAe,CAChCI,MAAAA,EAAQlB,EAAQc,aAAaH,MAC9BC,GAAWA,IAAWF,IAEvBQ,EACQlB,EAAAe,iBAAiBI,GACpBA,EAA+BC,QAC3BR,GAAWA,IAAWM,MAIvBlB,EAAAe,iBAAiBI,GAAc,IAC/BA,EACJT,IAGZ,CAAA,GAGJ,OAAKV,EAQDqB,EAACC,EAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQlC,EACRG,UAAAA,EAECgC,SAAS,MAAAjC,OAAAA,EAAAA,EAAAkC,KAAI,CAACf,EAAQgB,IACnBP,EAACQ,EAAA,CAEGrC,KAAMA,GAAQD,EACdiB,MAAOI,EAAOJ,MAAMK,WACpBiB,SAAUxB,EACVL,IAAW,IAAN2B,EAAU3B,OAAM,EAEpByB,SAAOd,EAAArB,OANH,GAAGA,KAASqB,EAAOJ,cAd5BuB,QAAAC,MACJ,yEAEG,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContactQuestion.js","sources":["../../../../../src/components/feedback/questions/ContactQuestion.tsx"],"sourcesContent":["import React, { ChangeEvent, FC, useEffect, useRef, useState } from \"react\";\nimport { isValidEpost } from \"../../../utilities/validators/isValidEpost/isValidEpost.js\";\nimport { isValidTelefonnummer } from \"../../../utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport { TextInput } from \"../../text-input/TextInput.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { ContactQuestionProps } from \"../types.js\";\n\nconst validateEmail = (email?: string) => {\n if (!email || email === \"\") {\n return \"Du må oppgi e-postadresse for at vi kan kontakte deg\";\n }\n if (!isValidEpost(email)) {\n return \"Skriv inn en gyldig e-postadresse\";\n }\n return;\n};\n\nconst validatePhone = (phone?: string) => {\n if (!phone || phone === \"\") {\n return \"Du må oppgi telefonnummer for at vi kan kontakte deg\";\n }\n if (!isValidTelefonnummer(phone)) {\n return \"Skriv inn et gyldig telefonnummer\";\n }\n return;\n};\n\nconst defaultSuccessMessage = {\n title: \"Takk for tiden din!\",\n children:\n \"Neste gang vi gjennomfører intervjuer og tester kan det hende vi tar kontakt med deg. Dine innspill hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem.\",\n};\n\nexport const ContactQuestion: FC<ContactQuestionProps> = ({\n label = \"Kan vi kontakte deg for flere innspill?\",\n sendButtonLabel = \"Sett meg på lista!\",\n withPhone = false,\n onSubmit,\n successMessage = defaultSuccessMessage,\n children,\n}) => {\n const [email, setEmail] = useState(\"\");\n const [phone, setPhone] = useState(\"\");\n const [errors, setErrors] = useState<{ email?: string; phone?: string }>(\n {},\n );\n const emailRef = useRef<HTMLInputElement>(null);\n const phoneRef = useRef<HTMLInputElement>(null);\n const [shouldValidate, setShouldValidate] = useState(false);\n\n const [noThanks, setNoThanks] = useState(false);\n const { contactSubmitted, setContactSubmitted, landmarkLabel } =\n useFeedbackContext();\n\n const ChildrenWrapper = typeof children === \"string\" ? \"p\" : \"div\";\n\n const validate = (email: string, phone: string) => {\n const emailError = validateEmail(email);\n const phoneError = validatePhone(phone);\n setErrors({ email: emailError, phone: phoneError });\n return { emailError, phoneError };\n };\n\n useEffect(() => {\n if (shouldValidate) {\n const { emailError, phoneError } = validate(email, phone);\n\n if (!emailError && (!withPhone || !phoneError)) {\n setShouldValidate(false);\n }\n }\n }, [email, phone, shouldValidate, withPhone]);\n\n const handleChange =\n (consumer: (value: string) => void) =>\n (e: ChangeEvent<HTMLInputElement>) =>\n consumer(e.target.value);\n\n const handleSubmit: React.FormEventHandler = (e) => {\n e.preventDefault();\n\n const { emailError, phoneError } = validate(email, phone);\n if (emailError) {\n setShouldValidate(true);\n emailRef.current?.focus();\n return;\n }\n if (withPhone && phoneError) {\n setShouldValidate(true);\n phoneRef.current?.focus();\n return;\n }\n\n onSubmit({ email, phone: withPhone ? phone : undefined });\n setContactSubmitted(true);\n };\n\n if (noThanks) {\n return null;\n }\n\n if (contactSubmitted) {\n return <FeedbackSuccess {...successMessage} />;\n }\n\n return (\n <form\n className=\"jkl-spacing-xl--top\"\n onSubmit={handleSubmit}\n aria-label={landmarkLabel}\n >\n <p className=\"jkl-heading-4 jkl-spacing-xs--bottom\">{label}</p>\n {children && (\n <ChildrenWrapper className=\"jkl-body\">\n {children}\n </ChildrenWrapper>\n )}\n\n <TextInput\n ref={emailRef}\n className=\"jkl-spacing-l--top\"\n label=\"E-post\"\n labelProps={{ variant: \"small\" }}\n autoComplete=\"email\"\n name=\"email\"\n value={email}\n onChange={handleChange(setEmail)}\n errorLabel={errors.email}\n />\n {withPhone && (\n <TextInput\n ref={phoneRef}\n className=\"jkl-spacing-l--top\"\n label=\"Telefonnummer\"\n labelProps={{ variant: \"small\" }}\n autoComplete=\"tel\"\n name=\"phone\"\n value={phone}\n onChange={handleChange(setPhone)}\n errorLabel={errors.phone}\n />\n )}\n\n <div className=\"jkl-spacing-xl--top\">\n <PrimaryButton type=\"submit\" className=\"jkl-spacing-xl--right\">\n {sendButtonLabel}\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>\n Nei takk\n </TertiaryButton>\n </div>\n </form>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","ContactQuestion","label","sendButtonLabel","withPhone","onSubmit","successMessage","email","setEmail","useState","phone","setPhone","errors","setErrors","emailRef","useRef","phoneRef","shouldValidate","setShouldValidate","noThanks","setNoThanks","contactSubmitted","setContactSubmitted","landmarkLabel","useFeedbackContext","ChildrenWrapper","validate","emailError","isValidEpost","validateEmail","phoneError","isValidTelefonnummer","validatePhone","useEffect","handleChange","consumer","e","target","value","jsx","FeedbackSuccess","jsxs","className","preventDefault","_a","current","focus","_b","TextInput","ref","labelProps","variant","autoComplete","name","onChange","errorLabel","PrimaryButton","type","TertiaryButton","onClick"],"mappings":"kjBASA,MAoBMA,EAAwB,CAC1BC,MAAO,sBACPC,SACI,sLAGKC,EAA4C,EACrDC,MAAAA,EAAQ,0CACRC,gBAAAA,EAAkB,qBAClBC,UAAAA,GAAY,EACZC,SAAAA,EACAC,eAAAA,EAAiBR,EACjBE,SAAAA,MAEA,MAAOO,EAAOC,GAAYC,EAAS,KAC5BC,EAAOC,GAAYF,EAAS,KAC5BG,EAAQC,GAAaJ,EACxB,CAAA,GAEEK,EAAWC,EAAyB,MACpCC,EAAWD,EAAyB,OACnCE,EAAgBC,GAAqBT,GAAS,IAE9CU,EAAUC,GAAeX,GAAS,IACjCY,iBAAAA,EAAkBC,oBAAAA,EAAqBC,cAAAA,GAC3CC,IAEEC,EAAsC,iBAAbzB,EAAwB,IAAM,MAEvD0B,EAAW,CAACnB,EAAeG,KACvB,MAAAiB,EAlDQ,CAACpB,GACdA,GAAmB,KAAVA,EAGTqB,EAAarB,QAAd,EACO,oCAHA,uDAgDYsB,CAActB,GAC3BuB,EAzCQ,CAACpB,GACdA,GAAmB,KAAVA,EAGTqB,EAAqBrB,QAAtB,EACO,oCAHA,uDAuCYsB,CAActB,GACjC,OAAAG,EAAU,CAAEN,MAAOoB,EAAYjB,MAAOoB,IAC/B,CAAEH,WAAAA,EAAYG,WAAAA,EAAW,EAGpCG,GAAU,KACN,GAAIhB,EAAgB,CACV,MAAEU,WAAAA,EAAYG,WAAAA,GAAeJ,EAASnB,EAAOG,IAE9CiB,KAAgBvB,IAAc0B,IAC/BZ,GAAkB,EACtB,IAEL,CAACX,EAAOG,EAAOO,EAAgBb,IAE5B,MAAA8B,EACDC,GACAC,GACGD,EAASC,EAAEC,OAAOC,OAqBtBnB,OAAAA,EACO,KAGPE,EACOkB,EAACC,EAAiB,IAAGlC,IAI5BmC,EAAC,OAAA,CACGC,UAAU,sBACVrC,SA9BsC+B,YAC1CA,EAAEO,iBAEI,MAAEhB,WAAAA,EAAYG,WAAAA,GAAeJ,EAASnB,EAAOG,GACnD,OAAIiB,GACAT,GAAkB,QAClB,OAAA0B,EAAA9B,EAAS+B,UAATD,EAAkBE,UAGlB1C,GAAa0B,GACbZ,GAAkB,QAClB,OAAA6B,EAAA/B,EAAS6B,UAATE,EAAkBD,WAItBzC,EAAS,CAAEE,MAAAA,EAAOG,MAAON,EAAYM,OAAQ,SAC7CY,GAAoB,GAAI,EAepB,aAAYC,EAEZvB,SAAA,CAACuC,EAAA,IAAA,CAAEG,UAAU,uCAAwC1C,SAAME,IAC1DF,GACGuC,EAACd,EAAgB,CAAAiB,UAAU,WACtB1C,SAAAA,IAITuC,EAACS,EAAA,CACGC,IAAKnC,EACL4B,UAAU,qBACVxC,MAAM,SACNgD,WAAY,CAAEC,QAAS,SACvBC,aAAa,QACbC,KAAK,QACLf,MAAO/B,EACP+C,SAAUpB,EAAa1B,GACvB+C,WAAY3C,EAAOL,QAEtBH,GACGmC,EAACS,EAAA,CACGC,IAAKjC,EACL0B,UAAU,qBACVxC,MAAM,gBACNgD,WAAY,CAAEC,QAAS,SACvBC,aAAa,MACbC,KAAK,QACLf,MAAO5B,EACP4C,SAAUpB,EAAavB,GACvB4C,WAAY3C,EAAOF,QAI3B+B,EAAC,MAAI,CAAAC,UAAU,sBACX1C,SAAA,CAAAuC,EAACiB,EAAc,CAAAC,KAAK,SAASf,UAAU,wBAClC1C,SACLG,MACCuD,EAAe,CAAAC,QAAS,IAAMvC,GAAY,GAAOpB,SAElD,kBAER"}
1
+ {"version":3,"file":"ContactQuestion.js","sources":["../../../../../src/components/feedback/questions/ContactQuestion.tsx"],"sourcesContent":["import React, { ChangeEvent, FC, useEffect, useRef, useState } from \"react\";\nimport { isValidEpost } from \"../../../utilities/validators/isValidEpost/isValidEpost.js\";\nimport { isValidTelefonnummer } from \"../../../utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport { TextInput } from \"../../text-input/TextInput.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { ContactQuestionProps } from \"../types.js\";\n\nconst validateEmail = (email?: string) => {\n if (!email || email === \"\") {\n return \"Du må oppgi e-postadresse for at vi kan kontakte deg\";\n }\n if (!isValidEpost(email)) {\n return \"Skriv inn en gyldig e-postadresse\";\n }\n return;\n};\n\nconst validatePhone = (phone?: string) => {\n if (!phone || phone === \"\") {\n return \"Du må oppgi telefonnummer for at vi kan kontakte deg\";\n }\n if (!isValidTelefonnummer(phone)) {\n return \"Skriv inn et gyldig telefonnummer\";\n }\n return;\n};\n\nconst defaultSuccessMessage = {\n title: \"Takk for tiden din!\",\n children:\n \"Neste gang vi gjennomfører intervjuer og tester kan det hende vi tar kontakt med deg. Dine innspill hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem.\",\n};\n\nexport const ContactQuestion: FC<ContactQuestionProps> = ({\n label = \"Kan vi kontakte deg for flere innspill?\",\n sendButtonLabel = \"Sett meg på lista!\",\n withPhone = false,\n onSubmit,\n successMessage = defaultSuccessMessage,\n children,\n}) => {\n const [email, setEmail] = useState(\"\");\n const [phone, setPhone] = useState(\"\");\n const [errors, setErrors] = useState<{ email?: string; phone?: string }>(\n {},\n );\n const emailRef = useRef<HTMLInputElement>(null);\n const phoneRef = useRef<HTMLInputElement>(null);\n const [shouldValidate, setShouldValidate] = useState(false);\n\n const [noThanks, setNoThanks] = useState(false);\n const { contactSubmitted, setContactSubmitted, landmarkLabel } =\n useFeedbackContext();\n\n const ChildrenWrapper = typeof children === \"string\" ? \"p\" : \"div\";\n\n const validate = (email: string, phone: string) => {\n const emailError = validateEmail(email);\n const phoneError = validatePhone(phone);\n setErrors({ email: emailError, phone: phoneError });\n return { emailError, phoneError };\n };\n\n useEffect(() => {\n if (shouldValidate) {\n const { emailError, phoneError } = validate(email, phone);\n\n if (!emailError && (!withPhone || !phoneError)) {\n setShouldValidate(false);\n }\n }\n }, [email, phone, shouldValidate, withPhone]);\n\n const handleChange =\n (consumer: (value: string) => void) =>\n (e: ChangeEvent<HTMLInputElement>) =>\n consumer(e.target.value);\n\n const handleSubmit: React.FormEventHandler = (e) => {\n e.preventDefault();\n\n const { emailError, phoneError } = validate(email, phone);\n if (emailError) {\n setShouldValidate(true);\n emailRef.current?.focus();\n return;\n }\n if (withPhone && phoneError) {\n setShouldValidate(true);\n phoneRef.current?.focus();\n return;\n }\n\n onSubmit({ email, phone: withPhone ? phone : undefined });\n setContactSubmitted(true);\n };\n\n if (noThanks) {\n return null;\n }\n\n if (contactSubmitted) {\n return <FeedbackSuccess {...successMessage} />;\n }\n\n return (\n <form\n className=\"jkl-spacing-xl--top\"\n onSubmit={handleSubmit}\n aria-label={landmarkLabel}\n >\n <p className=\"jkl-heading-4 jkl-spacing-xs--bottom\">{label}</p>\n {children && (\n <ChildrenWrapper className=\"jkl-body\">\n {children}\n </ChildrenWrapper>\n )}\n\n <TextInput\n ref={emailRef}\n className=\"jkl-spacing-l--top\"\n label=\"E-post\"\n labelProps={{ variant: \"small\" }}\n autoComplete=\"email\"\n name=\"email\"\n value={email}\n onChange={handleChange(setEmail)}\n errorLabel={errors.email}\n />\n {withPhone && (\n <TextInput\n ref={phoneRef}\n className=\"jkl-spacing-l--top\"\n label=\"Telefonnummer\"\n labelProps={{ variant: \"small\" }}\n autoComplete=\"tel\"\n name=\"phone\"\n value={phone}\n onChange={handleChange(setPhone)}\n errorLabel={errors.phone}\n />\n )}\n\n <div className=\"jkl-spacing-xl--top\">\n <PrimaryButton type=\"submit\" className=\"jkl-spacing-xl--right\">\n {sendButtonLabel}\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>\n Nei takk\n </TertiaryButton>\n </div>\n </form>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","ContactQuestion","label","sendButtonLabel","withPhone","onSubmit","successMessage","email","setEmail","useState","phone","setPhone","errors","setErrors","emailRef","useRef","phoneRef","shouldValidate","setShouldValidate","noThanks","setNoThanks","contactSubmitted","setContactSubmitted","landmarkLabel","useFeedbackContext","ChildrenWrapper","validate","emailError","isValidEpost","validateEmail","phoneError","isValidTelefonnummer","validatePhone","useEffect","handleChange","consumer","e","target","value","jsx","FeedbackSuccess","jsxs","className","preventDefault","_a","current","focus","_b","TextInput","ref","labelProps","variant","autoComplete","name","onChange","errorLabel","PrimaryButton","type","TertiaryButton","onClick"],"mappings":"kjBASA,MAoBMA,EAAwB,CAC1BC,MAAO,sBACPC,SACI,sLAGKC,EAA4C,EACrDC,MAAAA,EAAQ,0CACRC,gBAAAA,EAAkB,qBAClBC,UAAAA,GAAY,EACZC,SAAAA,EACAC,eAAAA,EAAiBR,EACjBE,SAAAA,MAEA,MAAOO,EAAOC,GAAYC,EAAS,KAC5BC,EAAOC,GAAYF,EAAS,KAC5BG,EAAQC,GAAaJ,EACxB,CAAC,GAECK,EAAWC,EAAyB,MACpCC,EAAWD,EAAyB,OACnCE,EAAgBC,GAAqBT,GAAS,IAE9CU,EAAUC,GAAeX,GAAS,IACjCY,iBAAAA,EAAkBC,oBAAAA,EAAqBC,cAAAA,GAC3CC,IAEEC,EAAsC,iBAAbzB,EAAwB,IAAM,MAEvD0B,EAAW,CAACnB,EAAeG,KACvB,MAAAiB,EAlDQ,CAACpB,GACdA,GAAmB,KAAVA,EAGTqB,EAAarB,QAAd,EACO,oCAHA,uDAgDYsB,CAActB,GAC3BuB,EAzCQ,CAACpB,GACdA,GAAmB,KAAVA,EAGTqB,EAAqBrB,QAAtB,EACO,oCAHA,uDAuCYsB,CAActB,GACjC,OAAAG,EAAU,CAAEN,MAAOoB,EAAYjB,MAAOoB,IAC/B,CAAEH,WAAAA,EAAYG,WAAAA,IAGzBG,GAAU,KACN,GAAIhB,EAAgB,CACV,MAAEU,WAAAA,EAAYG,WAAAA,GAAeJ,EAASnB,EAAOG,IAE9CiB,KAAgBvB,IAAc0B,IAC/BZ,GAAkB,EAE1B,IACD,CAACX,EAAOG,EAAOO,EAAgBb,IAE5B,MAAA8B,EACDC,GACAC,GACGD,EAASC,EAAEC,OAAOC,OAqBtBnB,OAAAA,EACO,KAGPE,EACOkB,EAACC,EAAiB,IAAGlC,IAI5BmC,EAAC,OAAA,CACGC,UAAU,sBACVrC,SA9BsC+B,YAC1CA,EAAEO,iBAEI,MAAEhB,WAAAA,EAAYG,WAAAA,GAAeJ,EAASnB,EAAOG,GACnD,OAAIiB,GACAT,GAAkB,QAClB,OAAA0B,EAAA9B,EAAS+B,UAATD,EAAkBE,UAGlB1C,GAAa0B,GACbZ,GAAkB,QAClB,OAAA6B,EAAA/B,EAAS6B,UAATE,EAAkBD,WAItBzC,EAAS,CAAEE,MAAAA,EAAOG,MAAON,EAAYM,OAAQ,SAC7CY,GAAoB,GAAI,EAepB,aAAYC,EAEZvB,SAAA,CAACuC,EAAA,IAAA,CAAEG,UAAU,uCAAwC1C,SAAME,IAC1DF,GACGuC,EAACd,EAAgB,CAAAiB,UAAU,WACtB1C,SAAAA,IAITuC,EAACS,EAAA,CACGC,IAAKnC,EACL4B,UAAU,qBACVxC,MAAM,SACNgD,WAAY,CAAEC,QAAS,SACvBC,aAAa,QACbC,KAAK,QACLf,MAAO/B,EACP+C,SAAUpB,EAAa1B,GACvB+C,WAAY3C,EAAOL,QAEtBH,GACGmC,EAACS,EAAA,CACGC,IAAKjC,EACL0B,UAAU,qBACVxC,MAAM,gBACNgD,WAAY,CAAEC,QAAS,SACvBC,aAAa,MACbC,KAAK,QACLf,MAAO5B,EACP4C,SAAUpB,EAAavB,GACvB4C,WAAY3C,EAAOF,QAI3B+B,EAAC,MAAI,CAAAC,UAAU,sBACX1C,SAAA,CAAAuC,EAACiB,EAAc,CAAAC,KAAK,SAASf,UAAU,wBAClC1C,SACLG,MACCuD,EAAe,CAAAC,QAAS,IAAMvC,GAAY,GAAOpB,SAElD,kBACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"RadioQuestion.js","sources":["../../../../../src/components/feedback/questions/RadioQuestion.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n useEffect,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport { RadioButton } from \"../../radio-button/RadioButton.js\";\nimport { RadioButtonGroup } from \"../../radio-button/RadioButtonGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { QuestionProps } from \"../types.js\";\n\nexport const RadioQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n options,\n helpLabel,\n autoFocus = false,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const numOptions = options?.length || 0;\n\n const ref = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n const option = options?.find(\n (option) => option.value.toString() === e.target.value,\n );\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <RadioButtonGroup\n legend={label}\n labelProps={{ variant: \"large\" }}\n name={`${id}-${name || label}`}\n inline={numOptions < 3}\n value={selectedValue || \"\"}\n onChange={handleChange}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <RadioButton\n ref={i === 0 ? ref : undefined}\n key={`${id}-${name || label}-${option.value}`}\n label={option.label}\n value={String(option.value)}\n />\n ))}\n </RadioButtonGroup>\n );\n};\n"],"names":["RadioQuestion","label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","numOptions","length","ref","useRef","useEffect","current","focus","handleChange","selectedValue","useMemo","Array","isArray","currentValue","value","toString","_a","jsx","RadioButtonGroup","legend","labelProps","variant","inline","onChange","e","option","find","target","setCurrentValue","children","map","i","RadioButton","String","console","error"],"mappings":"6YAaO,MAAMA,EAAyC,EAClDC,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAENC,MAAAA,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,IAELC,GAAa,MAAAV,OAAAA,EAAAA,EAASW,SAAU,EAEhCC,EAAMC,EAAyB,MACrCC,GAAU,KACFZ,GAAaU,EAAIG,SACjBH,EAAIG,QAAQC,OAAM,GAEvB,CAACd,EAAWU,IAETK,MAOAC,EAAgBC,GAClB,WACU,OAAAC,MAAAC,QAAQ,MAAAd,OAAAA,EAAAA,EAASe,cACjB,MAAAf,SAAAA,EAASe,aAAa,GAAGC,MAAMC,WAC/B,OAAAC,EAAA,MAAAlB,OAAA,EAAAA,EAASe,mBAAT,EAAAG,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAjB,OAAAA,EAAAA,EAASe,eAGd,OAAKf,EAQDmB,EAACC,EAAA,CACGC,OAAQ9B,EACR+B,WAAY,CAAEC,QAAS,SACvB/B,KAAM,GAAGS,KAAMT,GAAQD,IACvBiC,OAAQrB,EAAa,EACrBa,MAAOL,GAAiB,GACxBc,SA7BoDC,IAClDC,MAAAA,EAAS,MAAAlC,OAAA,EAAAA,EAASmC,MACnBD,GAAWA,EAAOX,MAAMC,aAAeS,EAAEG,OAAOb,QAErD,MAAAhB,GAAAA,EAAS8B,gBAAgBH,EAAAA,EA0BrBjC,UAAAA,EAECqC,SAAS,MAAAtC,OAAAA,EAAAA,EAAAuC,KAAI,CAACL,EAAQM,IACnBd,EAACe,EAAA,CACG7B,IAAW,IAAN4B,EAAU5B,OAAM,EAErBd,MAAOoC,EAAOpC,MACdyB,MAAOmB,OAAOR,EAAOX,QAFhB,GAAGf,KAAMT,GAAQD,KAASoC,EAAOX,cAnB1CoB,QAAAC,MACJ,yEAEG,KAAA"}
1
+ {"version":3,"file":"RadioQuestion.js","sources":["../../../../../src/components/feedback/questions/RadioQuestion.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n useEffect,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport { RadioButton } from \"../../radio-button/RadioButton.js\";\nimport { RadioButtonGroup } from \"../../radio-button/RadioButtonGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { QuestionProps } from \"../types.js\";\n\nexport const RadioQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n options,\n helpLabel,\n autoFocus = false,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const numOptions = options?.length || 0;\n\n const ref = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n const option = options?.find(\n (option) => option.value.toString() === e.target.value,\n );\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <RadioButtonGroup\n legend={label}\n labelProps={{ variant: \"large\" }}\n name={`${id}-${name || label}`}\n inline={numOptions < 3}\n value={selectedValue || \"\"}\n onChange={handleChange}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <RadioButton\n ref={i === 0 ? ref : undefined}\n key={`${id}-${name || label}-${option.value}`}\n label={option.label}\n value={String(option.value)}\n />\n ))}\n </RadioButtonGroup>\n );\n};\n"],"names":["RadioQuestion","label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","numOptions","length","ref","useRef","useEffect","current","focus","handleChange","selectedValue","useMemo","Array","isArray","currentValue","value","toString","_a","jsx","RadioButtonGroup","legend","labelProps","variant","inline","onChange","e","option","find","target","setCurrentValue","children","map","i","RadioButton","String","console","error"],"mappings":"6YAaO,MAAMA,EAAyC,EAClDC,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAENC,MAAAA,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,IAELC,GAAa,MAAAV,OAAAA,EAAAA,EAASW,SAAU,EAEhCC,EAAMC,EAAyB,MACrCC,GAAU,KACFZ,GAAaU,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACd,EAAWU,IAETK,MAOAC,EAAgBC,GAClB,WACU,OAAAC,MAAAC,QAAQ,MAAAd,OAAAA,EAAAA,EAASe,cACjB,MAAAf,SAAAA,EAASe,aAAa,GAAGC,MAAMC,WAC/B,OAAAC,EAAA,MAAAlB,OAAA,EAAAA,EAASe,mBAAT,EAAAG,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAjB,OAAAA,EAAAA,EAASe,eAGd,OAAKf,EAQDmB,EAACC,EAAA,CACGC,OAAQ9B,EACR+B,WAAY,CAAEC,QAAS,SACvB/B,KAAM,GAAGS,KAAMT,GAAQD,IACvBiC,OAAQrB,EAAa,EACrBa,MAAOL,GAAiB,GACxBc,SA7BoDC,IAClDC,MAAAA,EAAS,MAAAlC,OAAA,EAAAA,EAASmC,MACnBD,GAAWA,EAAOX,MAAMC,aAAeS,EAAEG,OAAOb,QAErD,MAAAhB,GAAAA,EAAS8B,gBAAgBH,EAAAA,EA0BrBjC,UAAAA,EAECqC,SAAS,MAAAtC,OAAAA,EAAAA,EAAAuC,KAAI,CAACL,EAAQM,IACnBd,EAACe,EAAA,CACG7B,IAAW,IAAN4B,EAAU5B,OAAM,EAErBd,MAAOoC,EAAOpC,MACdyB,MAAOmB,OAAOR,EAAOX,QAFhB,GAAGf,KAAMT,GAAQD,KAASoC,EAAOX,cAnB1CoB,QAAAC,MACJ,yEAEG,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SmileyQuestion.js","sources":["../../../../../src/components/feedback/questions/SmileyQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, Fragment, useId, useMemo } from \"react\";\nimport { FieldGroup } from \"../../input-group/FieldGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackOption, QuestionProps } from \"../types.js\";\nimport { defaultOptions, getSmiley } from \"./smileyUtils.js\";\n\nconst isNotInScale = (option: FeedbackOption) =>\n typeof option.value !== \"number\" || ![1, 2, 3, 4, 5].includes(option.value);\n\nexport const SmileyQuestion: React.FC<QuestionProps> = ({\n label,\n name = \"smiley\",\n helpLabel,\n options = defaultOptions,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n console.log(e.target.value);\n const option = options?.find(\n (option) => option.value.toString() === e.target.value,\n );\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value\n : context?.currentValue?.value,\n [context?.currentValue],\n );\n\n if (options.some(isNotInScale)) {\n console.error(\n \"SmileyQuestion må ha tallene 1 til 5 som verdier for alternativene sine\",\n );\n return null;\n }\n\n if (!context || !options) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <FieldGroup\n labelProps={{ variant: \"large\" }}\n legend={label}\n helpLabel={helpLabel}\n >\n <div className=\"jkl-feedback-smileys\">\n {options.map((option) => (\n <Fragment key={option.value}>\n <input\n className=\"jkl-sr-only\"\n id={`${id}-${name}-${option.value}`}\n name={`${id}-${name}`}\n type=\"radio\"\n value={option.value}\n onChange={handleChange}\n checked={selectedValue === option.value}\n />\n <label\n className=\"jkl-feedback-smiley-option\"\n htmlFor={`${id}-${name}-${option.value}`}\n >\n <span className=\"jkl-sr-only\">{option.label}</span>\n {getSmiley(Number(option.value))}\n </label>\n </Fragment>\n ))}\n </div>\n </FieldGroup>\n );\n};\n"],"names":["isNotInScale","option","value","includes","SmileyQuestion","label","name","helpLabel","options","defaultOptions","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","handleChange","e","console","log","target","find","toString","setCurrentValue","selectedValue","useMemo","Array","isArray","currentValue","_a","some","error","jsx","FieldGroup","labelProps","variant","legend","children","className","map","jsxs","Fragment","type","onChange","checked","htmlFor","getSmiley","Number"],"mappings":"8XAOA,MAAMA,EAAgBC,GACM,iBAAjBA,EAAOC,QAAuB,CAAC,EAAG,EAAG,EAAG,EAAG,GAAGC,SAASF,EAAOC,OAE5DE,EAA0C,EACnDC,MAAAA,EACAC,KAAAA,EAAO,SACPC,UAAAA,EACAC,QAAAA,EAAUC,MAEV,MAAMC,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,IAELC,EAAsDC,IAChDC,QAAAC,IAAIF,EAAEG,OAAOnB,OACfD,MAAAA,EAAS,MAAAO,OAAA,EAAAA,EAASc,MACnBrB,GAAWA,EAAOC,MAAMqB,aAAeL,EAAEG,OAAOnB,QAErD,MAAAY,GAAAA,EAASU,gBAAgBvB,EAAAA,EAGvBwB,EAAgBC,GAClB,WACI,OAAAC,MAAMC,QAAQ,MAAAd,OAAA,EAAAA,EAASe,cACjB,MAAAf,OAAAA,EAAAA,EAASe,aAAa,GAAG3B,MACzB,OAAA4B,EAAA,MAAAhB,SAAAA,EAASe,qBAATC,EAAuB5B,KAAA,GACjC,CAAC,MAAAY,OAAAA,EAAAA,EAASe,eAGV,OAAArB,EAAQuB,KAAK/B,IACLmB,QAAAa,MACJ,2EAEG,MAGNlB,GAAYN,EAQbyB,EAACC,EAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQhC,EACRE,UAAAA,EAEA+B,SAAAL,EAAC,OAAIM,UAAU,uBACVD,WAAQE,KAAKvC,GACVwC,EAACC,EACG,CAAAJ,SAAA,CAAAL,EAAC,QAAA,CACGM,UAAU,cACVxB,GAAI,GAAGA,KAAMT,KAAQL,EAAOC,QAC5BI,KAAM,GAAGS,KAAMT,IACfqC,KAAK,QACLzC,MAAOD,EAAOC,MACd0C,SAAU3B,EACV4B,QAASpB,IAAkBxB,EAAOC,QAEtCuC,EAAC,QAAA,CACGF,UAAU,6BACVO,QAAS,GAAG/B,KAAMT,KAAQL,EAAOC,QAEjCoC,SAAA,CAAAL,EAAC,OAAK,CAAAM,UAAU,cAAeD,SAAArC,EAAOI,QACrC0C,EAAUC,OAAO/C,EAAOC,aAflBD,EAAOC,cAd1BiB,QAAAa,MACJ,yEAEG,KA+BP"}
1
+ {"version":3,"file":"SmileyQuestion.js","sources":["../../../../../src/components/feedback/questions/SmileyQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, Fragment, useId, useMemo } from \"react\";\nimport { FieldGroup } from \"../../input-group/FieldGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackOption, QuestionProps } from \"../types.js\";\nimport { defaultOptions, getSmiley } from \"./smileyUtils.js\";\n\nconst isNotInScale = (option: FeedbackOption) =>\n typeof option.value !== \"number\" || ![1, 2, 3, 4, 5].includes(option.value);\n\nexport const SmileyQuestion: React.FC<QuestionProps> = ({\n label,\n name = \"smiley\",\n helpLabel,\n options = defaultOptions,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n console.log(e.target.value);\n const option = options?.find(\n (option) => option.value.toString() === e.target.value,\n );\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value\n : context?.currentValue?.value,\n [context?.currentValue],\n );\n\n if (options.some(isNotInScale)) {\n console.error(\n \"SmileyQuestion må ha tallene 1 til 5 som verdier for alternativene sine\",\n );\n return null;\n }\n\n if (!context || !options) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <FieldGroup\n labelProps={{ variant: \"large\" }}\n legend={label}\n helpLabel={helpLabel}\n >\n <div className=\"jkl-feedback-smileys\">\n {options.map((option) => (\n <Fragment key={option.value}>\n <input\n className=\"jkl-sr-only\"\n id={`${id}-${name}-${option.value}`}\n name={`${id}-${name}`}\n type=\"radio\"\n value={option.value}\n onChange={handleChange}\n checked={selectedValue === option.value}\n />\n <label\n className=\"jkl-feedback-smiley-option\"\n htmlFor={`${id}-${name}-${option.value}`}\n >\n <span className=\"jkl-sr-only\">{option.label}</span>\n {getSmiley(Number(option.value))}\n </label>\n </Fragment>\n ))}\n </div>\n </FieldGroup>\n );\n};\n"],"names":["isNotInScale","option","value","includes","SmileyQuestion","label","name","helpLabel","options","defaultOptions","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","handleChange","e","console","log","target","find","toString","setCurrentValue","selectedValue","useMemo","Array","isArray","currentValue","_a","some","error","jsx","FieldGroup","labelProps","variant","legend","children","className","map","jsxs","Fragment","type","onChange","checked","htmlFor","getSmiley","Number"],"mappings":"8XAOA,MAAMA,EAAgBC,GACM,iBAAjBA,EAAOC,QAAuB,CAAC,EAAG,EAAG,EAAG,EAAG,GAAGC,SAASF,EAAOC,OAE5DE,EAA0C,EACnDC,MAAAA,EACAC,KAAAA,EAAO,SACPC,UAAAA,EACAC,QAAAA,EAAUC,MAEV,MAAMC,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,IAELC,EAAsDC,IAChDC,QAAAC,IAAIF,EAAEG,OAAOnB,OACfD,MAAAA,EAAS,MAAAO,OAAA,EAAAA,EAASc,MACnBrB,GAAWA,EAAOC,MAAMqB,aAAeL,EAAEG,OAAOnB,QAErD,MAAAY,GAAAA,EAASU,gBAAgBvB,EAAAA,EAGvBwB,EAAgBC,GAClB,WACI,OAAAC,MAAMC,QAAQ,MAAAd,OAAA,EAAAA,EAASe,cACjB,MAAAf,OAAAA,EAAAA,EAASe,aAAa,GAAG3B,MACzB,OAAA4B,EAAA,MAAAhB,SAAAA,EAASe,qBAATC,EAAuB5B,KAAA,GACjC,CAAC,MAAAY,OAAAA,EAAAA,EAASe,eAGV,OAAArB,EAAQuB,KAAK/B,IACLmB,QAAAa,MACJ,2EAEG,MAGNlB,GAAYN,EAQbyB,EAACC,EAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQhC,EACRE,UAAAA,EAEA+B,SAAAL,EAAC,OAAIM,UAAU,uBACVD,WAAQE,KAAKvC,GACVwC,EAACC,EACG,CAAAJ,SAAA,CAAAL,EAAC,QAAA,CACGM,UAAU,cACVxB,GAAI,GAAGA,KAAMT,KAAQL,EAAOC,QAC5BI,KAAM,GAAGS,KAAMT,IACfqC,KAAK,QACLzC,MAAOD,EAAOC,MACd0C,SAAU3B,EACV4B,QAASpB,IAAkBxB,EAAOC,QAEtCuC,EAAC,QAAA,CACGF,UAAU,6BACVO,QAAS,GAAG/B,KAAMT,KAAQL,EAAOC,QAEjCoC,SAAA,CAAAL,EAAC,OAAK,CAAAM,UAAU,cAAeD,SAAArC,EAAOI,QACrC0C,EAAUC,OAAO/C,EAAOC,aAflBD,EAAOC,cAd1BiB,QAAAa,MACJ,yEAEG,KA8BH"}
@@ -1 +1 @@
1
- {"version":3,"file":"TextQuestion.js","sources":["../../../../../src/components/feedback/questions/TextQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useMemo, useRef } from \"react\";\nimport { TextArea } from \"../../text-input/TextArea.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackAnswer, QuestionProps } from \"../types.js\";\n\nexport const TextQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n helpLabel = \"Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.\",\n autoFocus = false,\n}) => {\n const { counter } = useFeedbackContext();\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n const value: FeedbackAnswer = {\n label,\n name: name || label,\n type: \"text\",\n value: e.target.value,\n };\n context?.setCurrentValue(value);\n };\n\n const currentValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <TextArea\n ref={ref}\n label={label}\n labelProps={{ variant: \"large\" }}\n name={name || label}\n startOpen\n rows={5}\n value={currentValue}\n onChange={handleChange}\n helpLabel={helpLabel}\n counter={counter}\n />\n );\n};\n"],"names":["TextQuestion","label","name","helpLabel","autoFocus","counter","useFeedbackContext","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","handleChange","currentValue","useMemo","Array","isArray","value","toString","_a","jsx","TextArea","labelProps","variant","startOpen","rows","onChange","e","type","target","setCurrentValue","console","error"],"mappings":"2WAOO,MAAMA,EAAwC,EACjDC,MAAAA,EACAC,KAAAA,EACAC,UAAAA,EAAY,uJACZC,UAAAA,GAAY,MAEN,MAAEC,QAAAA,GAAYC,IACdC,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,EAA4B,MAExCC,GAAU,KACFV,GAAaQ,EAAIG,SACjBH,EAAIG,QAAQC,OAAM,GAEvB,CAACZ,EAAWQ,IAETK,MAUAC,EAAeC,GACjB,WACU,OAAAC,MAAAC,QAAQ,MAAAV,OAAAA,EAAAA,EAASO,cACjB,MAAAP,SAAAA,EAASO,aAAa,GAAGI,MAAMC,WAC/B,OAAAC,EAAA,MAAAb,OAAA,EAAAA,EAASO,mBAAT,EAAAM,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAZ,OAAAA,EAAAA,EAASO,eAGd,OAAKP,EAQDc,EAACC,EAAA,CACGd,IAAAA,EACAX,MAAAA,EACA0B,WAAY,CAAEC,QAAS,SACvB1B,KAAMA,GAAQD,EACd4B,WAAS,EACTC,KAAM,EACNR,MAAOJ,EACPa,SAlCuDC,IAC3D,MAAMV,EAAwB,CAC1BrB,MAAAA,EACAC,KAAMA,GAAQD,EACdgC,KAAM,OACNX,MAAOU,EAAEE,OAAOZ,OAEpB,MAAAX,GAAAA,EAASwB,gBAAgBb,EAAAA,EA4BrBnB,UAAAA,EACAE,QAAAA,KAjBI+B,QAAAC,MACJ,yEAEG,KAAA"}
1
+ {"version":3,"file":"TextQuestion.js","sources":["../../../../../src/components/feedback/questions/TextQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useMemo, useRef } from \"react\";\nimport { TextArea } from \"../../text-input/TextArea.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackAnswer, QuestionProps } from \"../types.js\";\n\nexport const TextQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n helpLabel = \"Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.\",\n autoFocus = false,\n}) => {\n const { counter } = useFeedbackContext();\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n const value: FeedbackAnswer = {\n label,\n name: name || label,\n type: \"text\",\n value: e.target.value,\n };\n context?.setCurrentValue(value);\n };\n\n const currentValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <TextArea\n ref={ref}\n label={label}\n labelProps={{ variant: \"large\" }}\n name={name || label}\n startOpen\n rows={5}\n value={currentValue}\n onChange={handleChange}\n helpLabel={helpLabel}\n counter={counter}\n />\n );\n};\n"],"names":["TextQuestion","label","name","helpLabel","autoFocus","counter","useFeedbackContext","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","handleChange","currentValue","useMemo","Array","isArray","value","toString","_a","jsx","TextArea","labelProps","variant","startOpen","rows","onChange","e","type","target","setCurrentValue","console","error"],"mappings":"2WAOO,MAAMA,EAAwC,EACjDC,MAAAA,EACAC,KAAAA,EACAC,UAAAA,EAAY,uJACZC,UAAAA,GAAY,MAEN,MAAEC,QAAAA,GAAYC,IACdC,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,EAA4B,MAExCC,GAAU,KACFV,GAAaQ,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACZ,EAAWQ,IAETK,MAUAC,EAAeC,GACjB,WACU,OAAAC,MAAAC,QAAQ,MAAAV,OAAAA,EAAAA,EAASO,cACjB,MAAAP,SAAAA,EAASO,aAAa,GAAGI,MAAMC,WAC/B,OAAAC,EAAA,MAAAb,OAAA,EAAAA,EAASO,mBAAT,EAAAM,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAZ,OAAAA,EAAAA,EAASO,eAGd,OAAKP,EAQDc,EAACC,EAAA,CACGd,IAAAA,EACAX,MAAAA,EACA0B,WAAY,CAAEC,QAAS,SACvB1B,KAAMA,GAAQD,EACd4B,WAAS,EACTC,KAAM,EACNR,MAAOJ,EACPa,SAlCuDC,IAC3D,MAAMV,EAAwB,CAC1BrB,MAAAA,EACAC,KAAMA,GAAQD,EACdgC,KAAM,OACNX,MAAOU,EAAEE,OAAOZ,OAEpB,MAAAX,GAAAA,EAASwB,gBAAgBb,EAAAA,EA4BrBnB,UAAAA,EACAE,QAAAA,KAjBI+B,QAAAC,MACJ,yEAEG,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"smileyUtils.js","sources":["../../../../../src/components/feedback/questions/smileyUtils.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FeedbackOption } from \"../types.js\";\n\nexport const defaultOptions: FeedbackOption<number>[] = [\n {\n label: \"Veldig misfornøyd\",\n value: 1,\n textAreaLabel:\n \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Litt misfornøyd\",\n value: 2,\n textAreaLabel:\n \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Midt på treet\",\n value: 3,\n textAreaLabel:\n \"Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Ganske fornøyd\",\n value: 4,\n textAreaLabel:\n \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n {\n label: \"Veldig fornøyd\",\n value: 5,\n textAreaLabel:\n \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n];\n\nconst Smiley: FC<WithChildren> = ({ children }) => (\n <svg\n className=\"jkl-feedback-smiley-option__icon\"\n aria-hidden\n viewBox=\"0 0 40 40\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle cx=\"20\" cy=\"20\" r=\"19\" stroke=\"currentColor\" strokeWidth=\"2\" />\n {children}\n </svg>\n);\n\nconst VeldigSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 30C10 24.4772 14.4772 20 20 20C25.5228 20 30 24.4772 30 30\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M10 13.9865H16.6667\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <path\n d=\"M23.3333 13.9865H29.9999\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n </Smiley>\n);\n\nconst LittSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 28.75C10 28.75 13.75 23.3334 20 23.3334C26.25 23.3334 30 28.75 30 28.75\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst NoytralSmiley = () => (\n <Smiley>\n <path\n d=\"M9.15283 25.6986H30.8477\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst LittGladSmiley = () => (\n <Smiley>\n <path\n d=\"M10 23.3334C10 23.3334 12.9167 30 20 30C27.0833 30 30 23.3334 30 23.3334\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst VeldigGladSmiley = () => (\n <Smiley>\n <path\n d=\"M30 21C30 26.5228 25.5228 31 20 31C14.4772 31 10 26.5228 10 21\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M24 14.5H29\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nexport const getSmiley = (value: number) => {\n switch (value) {\n case 1:\n return <VeldigSurSmiley />;\n case 2:\n return <LittSurSmiley />;\n case 3:\n return <NoytralSmiley />;\n case 4:\n return <LittGladSmiley />;\n case 5:\n return <VeldigGladSmiley />;\n\n default:\n return <NoytralSmiley />;\n }\n};\n"],"names":["defaultOptions","label","value","textAreaLabel","Smiley","children","jsxs","className","viewBox","fill","xmlns","jsx","cx","cy","r","stroke","strokeWidth","VeldigSurSmiley","d","LittSurSmiley","NoytralSmiley","LittGladSmiley","VeldigGladSmiley","getSmiley"],"mappings":"kDAIO,MAAMA,EAA2C,CACpD,CACIC,MAAO,oBACPC,MAAO,EACPC,cACI,sFAER,CACIF,MAAO,kBACPC,MAAO,EACPC,cACI,sFAER,CACIF,MAAO,gBACPC,MAAO,EACPC,cACI,wEAER,CACIF,MAAO,iBACPC,MAAO,EACPC,cACI,+DAER,CACIF,MAAO,iBACPC,MAAO,EACPC,cACI,gEAINC,EAA2B,EAAGC,SAAAA,KAChCC,EAAC,MAAA,CACGC,UAAU,mCACV,eAAW,EACXC,QAAQ,YACRC,KAAK,OACLC,MAAM,6BAENL,SAAA,CAACM,EAAA,SAAA,CAAOC,GAAG,KAAKC,GAAG,KAAKC,EAAE,KAAKC,OAAO,eAAeC,YAAY,MAChEX,KAIHY,EAAkB,IACpBX,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,QAEf,OAAK,CAAAE,EAAE,sBAAsBH,OAAO,eAAeC,YAAY,MAChEL,EAAC,OAAA,CACGO,EAAE,2BACFH,OAAO,eACPC,YAAY,SAKlBG,EAAgB,IAClBb,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,8EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CW,EAAgB,IAClBd,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,2BACFH,OAAO,eACPC,YAAY,MAEhBL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CY,EAAiB,IACnBf,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,2EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3Ca,EAAmB,IACrBhB,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,QAEf,OAAK,CAAAE,EAAE,cAAcH,OAAO,eAAeC,YAAY,MACxDL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAIpCc,EAAarB,IACtB,OAAQA,GACJ,KAAK,EACD,SAAQe,EAAgB,IAC5B,KAAK,EACD,SAAQE,EAAc,IAC1B,KAAK,EAOL,QACI,SAAQC,EAAc,IAN1B,KAAK,EACD,SAAQC,EAAe,IAC3B,KAAK,EACD,SAAQC,EAAiB,IAGH"}
1
+ {"version":3,"file":"smileyUtils.js","sources":["../../../../../src/components/feedback/questions/smileyUtils.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FeedbackOption } from \"../types.js\";\n\nexport const defaultOptions: FeedbackOption<number>[] = [\n {\n label: \"Veldig misfornøyd\",\n value: 1,\n textAreaLabel:\n \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Litt misfornøyd\",\n value: 2,\n textAreaLabel:\n \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Midt på treet\",\n value: 3,\n textAreaLabel:\n \"Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Ganske fornøyd\",\n value: 4,\n textAreaLabel:\n \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n {\n label: \"Veldig fornøyd\",\n value: 5,\n textAreaLabel:\n \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n];\n\nconst Smiley: FC<WithChildren> = ({ children }) => (\n <svg\n className=\"jkl-feedback-smiley-option__icon\"\n aria-hidden\n viewBox=\"0 0 40 40\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle cx=\"20\" cy=\"20\" r=\"19\" stroke=\"currentColor\" strokeWidth=\"2\" />\n {children}\n </svg>\n);\n\nconst VeldigSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 30C10 24.4772 14.4772 20 20 20C25.5228 20 30 24.4772 30 30\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M10 13.9865H16.6667\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <path\n d=\"M23.3333 13.9865H29.9999\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n </Smiley>\n);\n\nconst LittSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 28.75C10 28.75 13.75 23.3334 20 23.3334C26.25 23.3334 30 28.75 30 28.75\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst NoytralSmiley = () => (\n <Smiley>\n <path\n d=\"M9.15283 25.6986H30.8477\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst LittGladSmiley = () => (\n <Smiley>\n <path\n d=\"M10 23.3334C10 23.3334 12.9167 30 20 30C27.0833 30 30 23.3334 30 23.3334\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst VeldigGladSmiley = () => (\n <Smiley>\n <path\n d=\"M30 21C30 26.5228 25.5228 31 20 31C14.4772 31 10 26.5228 10 21\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M24 14.5H29\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nexport const getSmiley = (value: number) => {\n switch (value) {\n case 1:\n return <VeldigSurSmiley />;\n case 2:\n return <LittSurSmiley />;\n case 3:\n return <NoytralSmiley />;\n case 4:\n return <LittGladSmiley />;\n case 5:\n return <VeldigGladSmiley />;\n\n default:\n return <NoytralSmiley />;\n }\n};\n"],"names":["defaultOptions","label","value","textAreaLabel","Smiley","children","jsxs","className","viewBox","fill","xmlns","jsx","cx","cy","r","stroke","strokeWidth","VeldigSurSmiley","d","LittSurSmiley","NoytralSmiley","LittGladSmiley","VeldigGladSmiley","getSmiley"],"mappings":"kDAIO,MAAMA,EAA2C,CACpD,CACIC,MAAO,oBACPC,MAAO,EACPC,cACI,sFAER,CACIF,MAAO,kBACPC,MAAO,EACPC,cACI,sFAER,CACIF,MAAO,gBACPC,MAAO,EACPC,cACI,wEAER,CACIF,MAAO,iBACPC,MAAO,EACPC,cACI,+DAER,CACIF,MAAO,iBACPC,MAAO,EACPC,cACI,gEAINC,EAA2B,EAAGC,SAAAA,KAChCC,EAAC,MAAA,CACGC,UAAU,mCACV,eAAW,EACXC,QAAQ,YACRC,KAAK,OACLC,MAAM,6BAENL,SAAA,CAACM,EAAA,SAAA,CAAOC,GAAG,KAAKC,GAAG,KAAKC,EAAE,KAAKC,OAAO,eAAeC,YAAY,MAChEX,KAIHY,EAAkB,IACpBX,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,QAEf,OAAK,CAAAE,EAAE,sBAAsBH,OAAO,eAAeC,YAAY,MAChEL,EAAC,OAAA,CACGO,EAAE,2BACFH,OAAO,eACPC,YAAY,SAKlBG,EAAgB,IAClBb,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,8EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CW,EAAgB,IAClBd,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,2BACFH,OAAO,eACPC,YAAY,MAEhBL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CY,EAAiB,IACnBf,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,2EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3Ca,EAAmB,IACrBhB,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,QAEf,OAAK,CAAAE,EAAE,cAAcH,OAAO,eAAeC,YAAY,MACxDL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAIpCc,EAAarB,IACtB,OAAQA,GACJ,KAAK,EACD,SAAQe,EAAgB,CAAA,GAC5B,KAAK,EACD,SAAQE,EAAc,CAAA,GAC1B,KAAK,EAOL,QACI,SAAQC,EAAc,CAAA,GAN1B,KAAK,EACD,SAAQC,EAAe,CAAA,GAC3B,KAAK,EACD,SAAQC,EAAiB,CAAA,GAIjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/components/feedback/utils.ts"],"sourcesContent":["import React, { JSXElementConstructor, FC } from \"react\";\nimport {\n CheckboxQuestion,\n RadioQuestion,\n TextQuestion,\n SmileyQuestion,\n} from \"./questions/index.js\";\nimport { QuestionProps, QuestionType } from \"./types.js\";\n\nexport function getChildrenOfType<P>(\n ...allowedTypes: Array<string | JSXElementConstructor<P>>\n) {\n return (\n children: React.ReactNode,\n ):\n | React.ReactElement<P, string | React.JSXElementConstructor<unknown>>[]\n | null\n | undefined =>\n React.Children.map(children, (child) => {\n if (\n React.isValidElement<P>(child) &&\n allowedTypes.includes(child.type)\n ) {\n return child;\n }\n return undefined;\n });\n}\n\nexport const getQuestionFromType = (type: QuestionType): FC<QuestionProps> => {\n switch (type) {\n case \"radio\":\n return RadioQuestion;\n case \"checkbox\":\n return CheckboxQuestion;\n case \"text\":\n return TextQuestion;\n case \"smiley\":\n return SmileyQuestion;\n\n default:\n return RadioQuestion;\n }\n};\n"],"names":["getChildrenOfType","allowedTypes","children","React","Children","map","child","isValidElement","includes","type","getQuestionFromType","RadioQuestion","CheckboxQuestion","TextQuestion","SmileyQuestion"],"mappings":"ofASO,SAASA,KACTC,GAEH,OACIC,GAKAC,EAAMC,SAASC,IAAIH,GAAWI,IAEtB,GAAAH,EAAMI,eAAkBD,IACxBL,EAAaO,SAASF,EAAMG,MAErBH,OAAAA,CAAAA,GAIvB,CAEa,MAAAI,EAAuBD,IAChC,OAAQA,GACJ,IAAK,QASL,QACWE,OAAAA,EARX,IAAK,WACMC,OAAAA,EACX,IAAK,OACMC,OAAAA,EACX,IAAK,SACMC,OAAAA,EAGA"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/components/feedback/utils.ts"],"sourcesContent":["import React, { JSXElementConstructor, FC } from \"react\";\nimport {\n CheckboxQuestion,\n RadioQuestion,\n TextQuestion,\n SmileyQuestion,\n} from \"./questions/index.js\";\nimport { QuestionProps, QuestionType } from \"./types.js\";\n\nexport function getChildrenOfType<P>(\n ...allowedTypes: Array<string | JSXElementConstructor<P>>\n) {\n return (\n children: React.ReactNode,\n ):\n | React.ReactElement<P, string | React.JSXElementConstructor<unknown>>[]\n | null\n | undefined =>\n React.Children.map(children, (child) => {\n if (\n React.isValidElement<P>(child) &&\n allowedTypes.includes(child.type)\n ) {\n return child;\n }\n return undefined;\n });\n}\n\nexport const getQuestionFromType = (type: QuestionType): FC<QuestionProps> => {\n switch (type) {\n case \"radio\":\n return RadioQuestion;\n case \"checkbox\":\n return CheckboxQuestion;\n case \"text\":\n return TextQuestion;\n case \"smiley\":\n return SmileyQuestion;\n\n default:\n return RadioQuestion;\n }\n};\n"],"names":["getChildrenOfType","allowedTypes","children","React","Children","map","child","isValidElement","includes","type","getQuestionFromType","RadioQuestion","CheckboxQuestion","TextQuestion","SmileyQuestion"],"mappings":"ofASO,SAASA,KACTC,GAEH,OACIC,GAKAC,EAAMC,SAASC,IAAIH,GAAWI,IAEtB,GAAAH,EAAMI,eAAkBD,IACxBL,EAAaO,SAASF,EAAMG,MAErBH,OAAAA,CAAAA,GAIvB,CAEa,MAAAI,EAAuBD,IAChC,OAAQA,GACJ,IAAK,QASL,QACWE,OAAAA,EARX,IAAK,WACMC,OAAAA,EACX,IAAK,OACMC,OAAAA,EACX,IAAK,SACMC,OAAAA,EAIf"}
@@ -1 +1 @@
1
- {"version":3,"file":"File.js","sources":["../../../../src/components/file-input/File.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC, MouseEvent } from \"react\";\nimport { TrashCanIcon, SuccessIcon } from \"../../components/icon/index.js\";\nimport { IconButton } from \"../../components/icon-button/IconButton.js\";\nimport { SupportLabel } from \"../../components/input-group/SupportLabel.js\";\nimport { type WithOptionalChildren } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { formatBytes } from \"../../utilities/formatters/bytes/formatBytes.js\";\nimport { useFileInputContext } from \"./internal/fileInputContext.js\";\nimport { Thumbnail } from \"./internal/Thumbnail.js\";\nimport { FileInputFileState } from \"./types.js\";\n\nexport interface FileProps extends WithOptionalChildren {\n fileName: string;\n fileType: string;\n fileSize: number;\n path?: string;\n file?: File;\n supportLabel?: string;\n supportLabelType?: \"help\" | \"error\" | \"warning\" | \"success\";\n state?: FileInputFileState;\n onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport const File: FC<FileProps> = (props) => {\n const {\n children,\n fileName,\n fileType,\n fileSize,\n path,\n file,\n supportLabel,\n supportLabelType,\n state,\n onRemove,\n } = props;\n\n const id = useId(\"jkl-file-preview\");\n const supportId = id + \"-support\";\n\n const context = useFileInputContext();\n\n const Component = path ? \"a\" : \"div\";\n\n const hasErrorOrWarning =\n supportLabelType === \"error\" || supportLabelType === \"warning\";\n const hasSuccess = supportLabelType === \"success\";\n\n const renderFeedbackElement = () => {\n if (!hasErrorOrWarning && !hasSuccess) {\n return (\n <SupportLabel\n className=\"jkl-file__support-label jkl-body\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n );\n }\n\n if (hasSuccess)\n return (\n <SuccessIcon\n variant=\"small\"\n aria-label=\"Filen ble lastet opp uten feil\"\n />\n );\n\n return null;\n };\n\n const fileComponent = (\n <div id={id} className=\"jkl-file\">\n <Component\n className={clsx(\"jkl-file__content\", {\n \"jkl-file__content--error\": supportLabelType === \"error\",\n \"jkl-file__content--warning\":\n supportLabelType === \"warning\",\n })}\n href={path}\n target={path ? \"_blank\" : undefined}\n >\n <Thumbnail\n fileName={fileName}\n fileType={fileType}\n file={file}\n path={path}\n state={state}\n >\n {children}\n </Thumbnail>\n <div>\n <p className=\"jkl-file__name\">{fileName}</p>\n <p className=\"jkl-file__description\">\n <span>{formatBytes(fileSize)}</span>\n {renderFeedbackElement()}\n </p>\n {supportLabel && hasErrorOrWarning && (\n <SupportLabel\n className=\"jkl-file__support-label\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n )}\n </div>\n </Component>\n {onRemove && (\n <IconButton\n className=\"jkl-file__delete\"\n onClick={onRemove}\n title={`Fjern ${fileName}`}\n >\n <TrashCanIcon />\n </IconButton>\n )}\n </div>\n );\n\n return context ? <li>{fileComponent}</li> : fileComponent;\n};\n"],"names":["File","props","children","fileName","fileType","fileSize","path","file","supportLabel","supportLabelType","state","onRemove","id","useId","supportId","context","useFileInputContext","hasErrorOrWarning","hasSuccess","fileComponent","jsxs","className","clsx","href","target","jsx","Thumbnail","formatBytes","SuccessIcon","variant","SupportLabel","label","labelType","IconButton","onClick","title","TrashCanIcon"],"mappings":"y2DAwBa,MAAAA,EAAuBC,IAC1B,MACFC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,KAAAA,EACAC,KAAAA,EACAC,aAAAA,EACAC,iBAAAA,EACAC,MAAAA,EACAC,SAAAA,GACAV,EAEEW,EAAKC,EAAM,oBACXC,EAAYF,EAAK,WAEjBG,EAAUC,IAIVC,EACmB,UAArBR,GAAqD,YAArBA,EAC9BS,EAAkC,YAArBT,EAyBbU,EACFC,EAAC,MAAI,CAAAR,GAAAA,EAAQS,UAAU,WACnBnB,SAAA,CAAAkB,EA/BUd,EAAO,IAAM,MA+BtB,CACGe,UAAWC,EAAK,oBAAqB,CACjC,2BAAiD,UAArBb,EAC5B,6BACyB,YAArBA,IAERc,KAAMjB,EACNkB,OAAQlB,EAAO,cAAW,EAE1BJ,SAAA,CAAAuB,EAACC,EAAA,CACGvB,SAAAA,EACAC,SAAAA,EACAG,KAAAA,EACAD,KAAAA,EACAI,MAAAA,EAECR,SAAAA,MAEJ,MACG,CAAAA,SAAA,CAACuB,EAAA,IAAA,CAAEJ,UAAU,iBAAkBnB,SAASC,IACxCiB,EAAC,IAAE,CAAAC,UAAU,wBACTnB,SAAA,CAACuB,EAAA,OAAA,CAAMvB,SAAYyB,EAAAtB,KA7C9BY,GAAsBC,EAWvBA,EAEIO,EAACG,EAAA,CACGC,QAAQ,QACR,aAAW,mCAIhB,KAjBCJ,EAACK,EAAA,CACGT,UAAU,mCACVT,GAAIE,EACJiB,MAAOvB,EACPwB,UAAWvB,OA0CVD,GAAgBS,GACbQ,EAACK,EAAA,CACGT,UAAU,0BACVT,GAAIE,EACJiB,MAAOvB,EACPwB,UAAWvB,UAK1BE,GACGc,EAACQ,EAAA,CACGZ,UAAU,mBACVa,QAASvB,EACTwB,MAAO,SAAShC,IAEhBD,WAACkC,EAAa,CAAA,QAMvBrB,OAAAA,EAAUU,EAAC,KAAI,CAAAvB,SAAAiB,IAAsBA,CAAAA"}
1
+ {"version":3,"file":"File.js","sources":["../../../../src/components/file-input/File.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC, MouseEvent } from \"react\";\nimport { TrashCanIcon, SuccessIcon } from \"../../components/icon/index.js\";\nimport { IconButton } from \"../../components/icon-button/IconButton.js\";\nimport { SupportLabel } from \"../../components/input-group/SupportLabel.js\";\nimport { type WithOptionalChildren } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { formatBytes } from \"../../utilities/formatters/bytes/formatBytes.js\";\nimport { useFileInputContext } from \"./internal/fileInputContext.js\";\nimport { Thumbnail } from \"./internal/Thumbnail.js\";\nimport { FileInputFileState } from \"./types.js\";\n\nexport interface FileProps extends WithOptionalChildren {\n fileName: string;\n fileType: string;\n fileSize: number;\n path?: string;\n file?: File;\n supportLabel?: string;\n supportLabelType?: \"help\" | \"error\" | \"warning\" | \"success\";\n state?: FileInputFileState;\n onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport const File: FC<FileProps> = (props) => {\n const {\n children,\n fileName,\n fileType,\n fileSize,\n path,\n file,\n supportLabel,\n supportLabelType,\n state,\n onRemove,\n } = props;\n\n const id = useId(\"jkl-file-preview\");\n const supportId = id + \"-support\";\n\n const context = useFileInputContext();\n\n const Component = path ? \"a\" : \"div\";\n\n const hasErrorOrWarning =\n supportLabelType === \"error\" || supportLabelType === \"warning\";\n const hasSuccess = supportLabelType === \"success\";\n\n const renderFeedbackElement = () => {\n if (!hasErrorOrWarning && !hasSuccess) {\n return (\n <SupportLabel\n className=\"jkl-file__support-label jkl-body\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n );\n }\n\n if (hasSuccess)\n return (\n <SuccessIcon\n variant=\"small\"\n aria-label=\"Filen ble lastet opp uten feil\"\n />\n );\n\n return null;\n };\n\n const fileComponent = (\n <div id={id} className=\"jkl-file\">\n <Component\n className={clsx(\"jkl-file__content\", {\n \"jkl-file__content--error\": supportLabelType === \"error\",\n \"jkl-file__content--warning\":\n supportLabelType === \"warning\",\n })}\n href={path}\n target={path ? \"_blank\" : undefined}\n >\n <Thumbnail\n fileName={fileName}\n fileType={fileType}\n file={file}\n path={path}\n state={state}\n >\n {children}\n </Thumbnail>\n <div>\n <p className=\"jkl-file__name\">{fileName}</p>\n <p className=\"jkl-file__description\">\n <span>{formatBytes(fileSize)}</span>\n {renderFeedbackElement()}\n </p>\n {supportLabel && hasErrorOrWarning && (\n <SupportLabel\n className=\"jkl-file__support-label\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n )}\n </div>\n </Component>\n {onRemove && (\n <IconButton\n className=\"jkl-file__delete\"\n onClick={onRemove}\n title={`Fjern ${fileName}`}\n >\n <TrashCanIcon />\n </IconButton>\n )}\n </div>\n );\n\n return context ? <li>{fileComponent}</li> : fileComponent;\n};\n"],"names":["File","props","children","fileName","fileType","fileSize","path","file","supportLabel","supportLabelType","state","onRemove","id","useId","supportId","context","useFileInputContext","hasErrorOrWarning","hasSuccess","fileComponent","jsxs","className","clsx","href","target","jsx","Thumbnail","formatBytes","SuccessIcon","variant","SupportLabel","label","labelType","IconButton","onClick","title","TrashCanIcon"],"mappings":"y2DAwBa,MAAAA,EAAuBC,IAC1B,MACFC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,KAAAA,EACAC,KAAAA,EACAC,aAAAA,EACAC,iBAAAA,EACAC,MAAAA,EACAC,SAAAA,GACAV,EAEEW,EAAKC,EAAM,oBACXC,EAAYF,EAAK,WAEjBG,EAAUC,IAIVC,EACmB,UAArBR,GAAqD,YAArBA,EAC9BS,EAAkC,YAArBT,EAyBbU,EACFC,EAAC,MAAI,CAAAR,GAAAA,EAAQS,UAAU,WACnBnB,SAAA,CAAAkB,EA/BUd,EAAO,IAAM,MA+BtB,CACGe,UAAWC,EAAK,oBAAqB,CACjC,2BAAiD,UAArBb,EAC5B,6BACyB,YAArBA,IAERc,KAAMjB,EACNkB,OAAQlB,EAAO,cAAW,EAE1BJ,SAAA,CAAAuB,EAACC,EAAA,CACGvB,SAAAA,EACAC,SAAAA,EACAG,KAAAA,EACAD,KAAAA,EACAI,MAAAA,EAECR,SAAAA,MAEJ,MACG,CAAAA,SAAA,CAACuB,EAAA,IAAA,CAAEJ,UAAU,iBAAkBnB,SAASC,IACxCiB,EAAC,IAAE,CAAAC,UAAU,wBACTnB,SAAA,CAACuB,EAAA,OAAA,CAAMvB,SAAYyB,EAAAtB,KA7C9BY,GAAsBC,EAWvBA,EAEIO,EAACG,EAAA,CACGC,QAAQ,QACR,aAAW,mCAIhB,KAjBCJ,EAACK,EAAA,CACGT,UAAU,mCACVT,GAAIE,EACJiB,MAAOvB,EACPwB,UAAWvB,OA0CVD,GAAgBS,GACbQ,EAACK,EAAA,CACGT,UAAU,0BACVT,GAAIE,EACJiB,MAAOvB,EACPwB,UAAWvB,UAK1BE,GACGc,EAACQ,EAAA,CACGZ,UAAU,mBACVa,QAASvB,EACTwB,MAAO,SAAShC,IAEhBD,WAACkC,EAAa,SAMvBrB,OAAAA,EAAUU,EAAC,KAAI,CAAAvB,SAAAiB,IAAsBA,CAAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"FileInput.js","sources":["../../../../src/components/file-input/FileInput.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useId } from \"react\";\nimport {\n FieldGroup,\n type FieldGroupProps,\n} from \"../../components/input-group/FieldGroup.js\";\nimport { type Density } from \"../../core/types.js\";\nimport { Dropzone } from \"./internal/Dropzone.js\";\nimport { FileInputContextProvider } from \"./internal/fileInputContext.js\";\nimport { Input } from \"./internal/Input.js\";\nimport { MaxSize } from \"./internal/MaxSize.js\";\nimport { FileInputFile } from \"./types.js\";\n\nexport interface FileInputProps extends Omit<FieldGroupProps, \"onChange\"> {\n className?: string;\n id?: string;\n density?: Density;\n /**\n * En string som begrenser hvilke filtyper som kan velges.\n *\n * Flere filtyper kan defineres som en kommaseparert liste.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept\n */\n accept?: \"image/*\" | \".pdf\" | \"image/*,.pdf\" | HTMLInputElement[\"accept\"];\n maxSizeBytes?: number;\n /**\n * @default true\n */\n multiple?: boolean;\n value: FileInputFile[];\n variant?: \"flexible\" | \"small\";\n onChange: (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.DragEvent<HTMLDivElement>,\n files: FileInputFile[],\n ) => void;\n}\n\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const {\n accept,\n className,\n children,\n id,\n value,\n density,\n multiple = true,\n maxSizeBytes,\n onChange,\n variant,\n ...rest\n } = props;\n\n const hasFiles = value.length > 0;\n\n const maxSizeDescriptionId = useId();\n\n if (variant === \"small\") {\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={clsx(\n \"jkl-file-input\",\n \"jkl-file-input--small\",\n className,\n {\n \"jkl-file-input--has-files\": hasFiles,\n },\n )}\n data-layout-density={density ? density : \"compact\"}\n {...rest}\n >\n <Dropzone>\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label=\"Legg til fil\"\n multiple={multiple}\n ref={ref}\n aria-describedby={maxSizeDescriptionId}\n />\n </div>\n </Dropzone>\n <MaxSize id={maxSizeDescriptionId} />\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n </FieldGroup>\n </FileInputContextProvider>\n );\n }\n\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={clsx(\"jkl-file-input\", className, {\n \"jkl-file-input--has-files\": hasFiles,\n })}\n data-layout-density={density}\n {...rest}\n >\n <Dropzone>\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label={\n multiple && hasFiles\n ? \"Legg til flere filer\"\n : \"Legg til fil\"\n }\n multiple={multiple}\n ref={ref}\n aria-describedby={maxSizeDescriptionId}\n />\n <MaxSize id={maxSizeDescriptionId} />\n </div>\n </Dropzone>\n </FieldGroup>\n </FileInputContextProvider>\n );\n },\n);\n\nFileInput.displayName = \"FileInput\";\n"],"names":["FileInput","forwardRef","props","ref","accept","className","children","id","value","density","multiple","maxSizeBytes","onChange","variant","rest","hasFiles","length","maxSizeDescriptionId","useId","jsx","FileInputContextProvider","context","files","jsxs","FieldGroup","clsx","Dropzone","Input","label","MaxSize","displayName"],"mappings":"gaAwCO,MAAMA,EAAYC,GACrB,CAACC,EAAOC,KACE,MACFC,OAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,GAAAA,EACAC,MAAAA,EACAC,QAAAA,EACAC,SAAAA,GAAW,EACXC,aAAAA,EACAC,SAAAA,EACAC,QAAAA,KACGC,GACHZ,EAEEa,EAAWP,EAAMQ,OAAS,EAE1BC,EAAuBC,IAEzBL,OAEIM,EAACC,EAFO,UAAZP,EAEK,CACGQ,QAAS,CAAEjB,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcW,MAAOd,GAElDF,SAAAiB,EAACC,EAAA,CACGnB,UAAWoB,EACP,iBACA,wBACApB,EACA,CACI,4BAA6BU,IAGrC,sBAAqBN,GAAoB,aACrCK,EAEJR,SAAA,CAAAa,EAACO,EACG,CAAApB,SAAAa,EAAC,MAAI,CAAAd,UAAU,iCACXC,SAAAa,EAACQ,EAAA,CACGpB,GAAAA,EACAqB,MAAM,eACNlB,SAAAA,EACAP,IAAAA,EACA,mBAAkBc,QAI9BE,EAACU,EAAQ,CAAAtB,GAAIU,IACZT,EAAMQ,OAAS,KACX,KAAG,CAAAX,UAAU,wBACTC,SAAAA,QASpB,CACGe,QAAS,CAAEjB,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcW,MAAOd,GAElDF,SAAAa,EAACK,EAAA,CACGnB,UAAWoB,EAAK,iBAAkBpB,EAAW,CACzC,4BAA6BU,IAEjC,sBAAqBN,KACjBK,EAEJR,WAACoB,EACI,CAAApB,SAAA,CAAAE,EAAMQ,OAAS,GACZG,EAAC,KAAG,CAAAd,UAAU,wBACTC,SAAAA,IAGTiB,EAAC,MAAI,CAAAlB,UAAU,iCACXC,SAAA,CAAAa,EAACQ,EAAA,CACGpB,GAAAA,EACAqB,MACIlB,GAAYK,EACN,uBACA,eAEVL,SAAAA,EACAP,IAAAA,EACA,mBAAkBc,IAEtBE,EAACU,EAAQ,CAAAtB,GAAIU,aAI7B,IAKZjB,EAAU8B,YAAc"}
1
+ {"version":3,"file":"FileInput.js","sources":["../../../../src/components/file-input/FileInput.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useId } from \"react\";\nimport {\n FieldGroup,\n type FieldGroupProps,\n} from \"../../components/input-group/FieldGroup.js\";\nimport { type Density } from \"../../core/types.js\";\nimport { Dropzone } from \"./internal/Dropzone.js\";\nimport { FileInputContextProvider } from \"./internal/fileInputContext.js\";\nimport { Input } from \"./internal/Input.js\";\nimport { MaxSize } from \"./internal/MaxSize.js\";\nimport { FileInputFile } from \"./types.js\";\n\nexport interface FileInputProps extends Omit<FieldGroupProps, \"onChange\"> {\n className?: string;\n id?: string;\n density?: Density;\n /**\n * En string som begrenser hvilke filtyper som kan velges.\n *\n * Flere filtyper kan defineres som en kommaseparert liste.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept\n */\n accept?: \"image/*\" | \".pdf\" | \"image/*,.pdf\" | HTMLInputElement[\"accept\"];\n maxSizeBytes?: number;\n /**\n * @default true\n */\n multiple?: boolean;\n value: FileInputFile[];\n variant?: \"flexible\" | \"small\";\n onChange: (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.DragEvent<HTMLDivElement>,\n files: FileInputFile[],\n ) => void;\n}\n\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const {\n accept,\n className,\n children,\n id,\n value,\n density,\n multiple = true,\n maxSizeBytes,\n onChange,\n variant,\n ...rest\n } = props;\n\n const hasFiles = value.length > 0;\n\n const maxSizeDescriptionId = useId();\n\n if (variant === \"small\") {\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={clsx(\n \"jkl-file-input\",\n \"jkl-file-input--small\",\n className,\n {\n \"jkl-file-input--has-files\": hasFiles,\n },\n )}\n data-layout-density={density ? density : \"compact\"}\n {...rest}\n >\n <Dropzone>\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label=\"Legg til fil\"\n multiple={multiple}\n ref={ref}\n aria-describedby={maxSizeDescriptionId}\n />\n </div>\n </Dropzone>\n <MaxSize id={maxSizeDescriptionId} />\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n </FieldGroup>\n </FileInputContextProvider>\n );\n }\n\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={clsx(\"jkl-file-input\", className, {\n \"jkl-file-input--has-files\": hasFiles,\n })}\n data-layout-density={density}\n {...rest}\n >\n <Dropzone>\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label={\n multiple && hasFiles\n ? \"Legg til flere filer\"\n : \"Legg til fil\"\n }\n multiple={multiple}\n ref={ref}\n aria-describedby={maxSizeDescriptionId}\n />\n <MaxSize id={maxSizeDescriptionId} />\n </div>\n </Dropzone>\n </FieldGroup>\n </FileInputContextProvider>\n );\n },\n);\n\nFileInput.displayName = \"FileInput\";\n"],"names":["FileInput","forwardRef","props","ref","accept","className","children","id","value","density","multiple","maxSizeBytes","onChange","variant","rest","hasFiles","length","maxSizeDescriptionId","useId","jsx","FileInputContextProvider","context","files","jsxs","FieldGroup","clsx","Dropzone","Input","label","MaxSize","displayName"],"mappings":"gaAwCO,MAAMA,EAAYC,GACrB,CAACC,EAAOC,KACE,MACFC,OAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,GAAAA,EACAC,MAAAA,EACAC,QAAAA,EACAC,SAAAA,GAAW,EACXC,aAAAA,EACAC,SAAAA,EACAC,QAAAA,KACGC,GACHZ,EAEEa,EAAWP,EAAMQ,OAAS,EAE1BC,EAAuBC,IAEzBL,OAEIM,EAACC,EAFO,UAAZP,EAEK,CACGQ,QAAS,CAAEjB,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcW,MAAOd,GAElDF,SAAAiB,EAACC,EAAA,CACGnB,UAAWoB,EACP,iBACA,wBACApB,EACA,CACI,4BAA6BU,IAGrC,sBAAqBN,GAAoB,aACrCK,EAEJR,SAAA,CAAAa,EAACO,EACG,CAAApB,SAAAa,EAAC,MAAI,CAAAd,UAAU,iCACXC,SAAAa,EAACQ,EAAA,CACGpB,GAAAA,EACAqB,MAAM,eACNlB,SAAAA,EACAP,IAAAA,EACA,mBAAkBc,QAI9BE,EAACU,EAAQ,CAAAtB,GAAIU,IACZT,EAAMQ,OAAS,KACX,KAAG,CAAAX,UAAU,wBACTC,SAAAA,QASpB,CACGe,QAAS,CAAEjB,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcW,MAAOd,GAElDF,SAAAa,EAACK,EAAA,CACGnB,UAAWoB,EAAK,iBAAkBpB,EAAW,CACzC,4BAA6BU,IAEjC,sBAAqBN,KACjBK,EAEJR,WAACoB,EACI,CAAApB,SAAA,CAAAE,EAAMQ,OAAS,GACZG,EAAC,KAAG,CAAAd,UAAU,wBACTC,SAAAA,IAGTiB,EAAC,MAAI,CAAAlB,UAAU,iCACXC,SAAA,CAAAa,EAACQ,EAAA,CACGpB,GAAAA,EACAqB,MACIlB,GAAYK,EACN,uBACA,eAEVL,SAAAA,EACAP,IAAAA,EACA,mBAAkBc,IAEtBE,EAACU,EAAQ,CAAAtB,GAAIU,aAGzB,IAMhBjB,EAAU8B,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Dropzone.js","sources":["../../../../../src/components/file-input/internal/Dropzone.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useState } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface DropzoneProps extends WithChildren {}\n\nexport const Dropzone = forwardRef<HTMLDivElement, DropzoneProps>(\n (props, ref) => {\n const { children, ...rest } = props;\n const [onDragClassName, setOnDragClassName] = useState<string>(\"\");\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>\n Dropzone must be placed inside a FileInputContextProvider.\n </p>\n );\n }\n const { maxSizeBytes, accept, onChange } = context;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={clsx(\"jkl-file-input__dropzone\", onDragClassName)}\n onDragEnter={(e) => {\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDragOver={(e) => {\n /* Prevent browser from opening file in a new tab */\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDrop={(e) => {\n e.preventDefault();\n setOnDragClassName(\"\");\n\n if (e.dataTransfer.files) {\n onChange(\n e,\n [...e.dataTransfer.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n onDragLeave={(e) => {\n setOnDragClassName(\"\");\n e.preventDefault();\n }}\n >\n {children}\n </div>\n );\n },\n);\n\nDropzone.displayName = \"Dropzone\";\n"],"names":["Dropzone","forwardRef","props","ref","children","rest","onDragClassName","setOnDragClassName","useState","context","useFileInputContext","jsx","maxSizeBytes","accept","onChange","className","clsx","onDragEnter","e","preventDefault","onDragOver","onDrop","dataTransfer","files","map","file","state","validation","validateFile","uploadProgress","onDragLeave","displayName"],"mappings":"uPASO,MAAMA,EAAWC,GACpB,CAACC,EAAOC,KACJ,MAAQC,SAAAA,KAAaC,GAASH,GACvBI,EAAiBC,GAAsBC,EAAiB,IAEzDC,EAAUC,IAChB,IAAKD,EAEG,OAAAE,EAAC,KAAEP,SAEH,+DAGR,MAAQQ,aAAAA,EAAcC,OAAAA,EAAQC,SAAAA,GAAaL,EAGvC,OAAAE,EAAC,MAAA,IACON,EACJF,IAAAA,EACAY,UAAWC,EAAK,2BAA4BV,GAC5CW,YAAcC,IACVX,EAAmB,mCACnBW,EAAEC,gBAAe,EAErBC,WAAaF,IAETX,EAAmB,mCACnBW,EAAEC,gBAAe,EAErBE,OAASH,IACLA,EAAEC,iBACFZ,EAAmB,IAEfW,EAAEI,aAAaC,OACfT,EACII,EACA,IAAIA,EAAEI,aAAaC,OAAOC,KACrBC,IAAU,CACPA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EACRH,EACAZ,EACAD,GAEJiB,eAAgB,MAG5B,EAGRC,YAAcZ,IACVX,EAAmB,IACnBW,EAAEC,gBAAe,EAGpBf,SAAAA,GACL,IAKZJ,EAAS+B,YAAc"}
1
+ {"version":3,"file":"Dropzone.js","sources":["../../../../../src/components/file-input/internal/Dropzone.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useState } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface DropzoneProps extends WithChildren {}\n\nexport const Dropzone = forwardRef<HTMLDivElement, DropzoneProps>(\n (props, ref) => {\n const { children, ...rest } = props;\n const [onDragClassName, setOnDragClassName] = useState<string>(\"\");\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>\n Dropzone must be placed inside a FileInputContextProvider.\n </p>\n );\n }\n const { maxSizeBytes, accept, onChange } = context;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={clsx(\"jkl-file-input__dropzone\", onDragClassName)}\n onDragEnter={(e) => {\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDragOver={(e) => {\n /* Prevent browser from opening file in a new tab */\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDrop={(e) => {\n e.preventDefault();\n setOnDragClassName(\"\");\n\n if (e.dataTransfer.files) {\n onChange(\n e,\n [...e.dataTransfer.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n onDragLeave={(e) => {\n setOnDragClassName(\"\");\n e.preventDefault();\n }}\n >\n {children}\n </div>\n );\n },\n);\n\nDropzone.displayName = \"Dropzone\";\n"],"names":["Dropzone","forwardRef","props","ref","children","rest","onDragClassName","setOnDragClassName","useState","context","useFileInputContext","jsx","maxSizeBytes","accept","onChange","className","clsx","onDragEnter","e","preventDefault","onDragOver","onDrop","dataTransfer","files","map","file","state","validation","validateFile","uploadProgress","onDragLeave","displayName"],"mappings":"uPASO,MAAMA,EAAWC,GACpB,CAACC,EAAOC,KACJ,MAAQC,SAAAA,KAAaC,GAASH,GACvBI,EAAiBC,GAAsBC,EAAiB,IAEzDC,EAAUC,IAChB,IAAKD,EAEG,OAAAE,EAAC,KAAEP,SAEH,+DAGR,MAAQQ,aAAAA,EAAcC,OAAAA,EAAQC,SAAAA,GAAaL,EAGvC,OAAAE,EAAC,MAAA,IACON,EACJF,IAAAA,EACAY,UAAWC,EAAK,2BAA4BV,GAC5CW,YAAcC,IACVX,EAAmB,mCACnBW,EAAEC,gBAAe,EAErBC,WAAaF,IAETX,EAAmB,mCACnBW,EAAEC,gBAAe,EAErBE,OAASH,IACLA,EAAEC,iBACFZ,EAAmB,IAEfW,EAAEI,aAAaC,OACfT,EACII,EACA,IAAIA,EAAEI,aAAaC,OAAOC,KACrBC,IAAU,CACPA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EACRH,EACAZ,EACAD,GAEJiB,eAAgB,MAExB,EAIZC,YAAcZ,IACVX,EAAmB,IACnBW,EAAEC,gBAAe,EAGpBf,SAAAA,GAAA,IAMjBJ,EAAS+B,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","sources":["../../../../../src/components/file-input/internal/Input.tsx"],"sourcesContent":["import React, { forwardRef, useId } from \"react\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface FileInputProps {\n id?: string;\n label: string;\n multiple: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const { multiple, id, label, ...rest } = props;\n\n const defaultId = useId();\n\n const maxSizeDescriptionId = id + \"-description\";\n const descriptor = multiple ? \"filer\" : \"fil\";\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>Input must be placed inside a FileInputContextProvider.</p>\n );\n }\n const { accept, maxSizeBytes, onChange } = context;\n\n const elementId = id || defaultId;\n\n return (\n <>\n <label\n className=\"jkl-button jkl-button--secondary\"\n htmlFor={elementId}\n id={`${elementId}__add-btn`}\n >\n {label}\n </label>\n <input\n {...rest}\n ref={ref}\n id={elementId}\n accept={accept}\n aria-describedby={\n maxSizeBytes ? maxSizeDescriptionId : undefined\n }\n className=\"jkl-sr-only\"\n type=\"file\"\n multiple={multiple}\n value=\"\"\n onChange={(e) => {\n if (e.target.files) {\n onChange(\n e,\n [...e.target.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n />\n <p className=\"jkl-file-input__dropzone-hint\">\n eller slipp {descriptor} her\n </p>{\" \"}\n </>\n );\n },\n);\n\nInput.displayName = \"Input\";\n"],"names":["Input","forwardRef","props","ref","multiple","id","label","rest","defaultId","useId","maxSizeDescriptionId","descriptor","context","useFileInputContext","jsx","children","accept","maxSizeBytes","onChange","elementId","jsxs","Fragment","className","htmlFor","type","value","e","target","files","map","file","state","validation","validateFile","uploadProgress","displayName"],"mappings":"2NAWO,MAAMA,EAAQC,GACjB,CAACC,EAAOC,KACE,MAAEC,SAAAA,EAAUC,GAAAA,EAAIC,MAAAA,KAAUC,GAASL,EAEnCM,EAAYC,IAEZC,EAAuBL,EAAK,eAC5BM,EAAaP,EAAW,QAAU,MAElCQ,EAAUC,IAChB,IAAKD,EAEG,OAAAE,EAAC,KAAEC,SAAuD,4DAG5D,MAAEC,OAAAA,EAAQC,aAAAA,EAAcC,SAAAA,GAAaN,EAErCO,EAAYd,GAAMG,EAExB,OAEQY,EAAAC,EAAA,CAAAN,SAAA,CAAAD,EAAC,QAAA,CACGQ,UAAU,mCACVC,QAASJ,EACTd,GAAI,GAAGc,aAENJ,SAAAT,IAELQ,EAAC,QAAA,IACOP,EACJJ,IAAAA,EACAE,GAAIc,EACJH,OAAAA,EACA,mBACIC,EAAeP,OAAuB,EAE1CY,UAAU,cACVE,KAAK,OACLpB,SAAAA,EACAqB,MAAM,GACNP,SAAWQ,IACHA,EAAEC,OAAOC,OACTV,EACIQ,EACA,IAAIA,EAAEC,OAAOC,OAAOC,KACfC,IAAU,CACPA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EACRH,EACAd,EACAC,GAEJiB,eAAgB,MAG5B,IAIZd,EAAC,IAAE,CAAAE,UAAU,gCAAgCP,SAAA,CAAA,eAC5BJ,EAAW,UACvB,MACT,IAKZX,EAAMmC,YAAc"}
1
+ {"version":3,"file":"Input.js","sources":["../../../../../src/components/file-input/internal/Input.tsx"],"sourcesContent":["import React, { forwardRef, useId } from \"react\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface FileInputProps {\n id?: string;\n label: string;\n multiple: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const { multiple, id, label, ...rest } = props;\n\n const defaultId = useId();\n\n const maxSizeDescriptionId = id + \"-description\";\n const descriptor = multiple ? \"filer\" : \"fil\";\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>Input must be placed inside a FileInputContextProvider.</p>\n );\n }\n const { accept, maxSizeBytes, onChange } = context;\n\n const elementId = id || defaultId;\n\n return (\n <>\n <label\n className=\"jkl-button jkl-button--secondary\"\n htmlFor={elementId}\n id={`${elementId}__add-btn`}\n >\n {label}\n </label>\n <input\n {...rest}\n ref={ref}\n id={elementId}\n accept={accept}\n aria-describedby={\n maxSizeBytes ? maxSizeDescriptionId : undefined\n }\n className=\"jkl-sr-only\"\n type=\"file\"\n multiple={multiple}\n value=\"\"\n onChange={(e) => {\n if (e.target.files) {\n onChange(\n e,\n [...e.target.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n />\n <p className=\"jkl-file-input__dropzone-hint\">\n eller slipp {descriptor} her\n </p>{\" \"}\n </>\n );\n },\n);\n\nInput.displayName = \"Input\";\n"],"names":["Input","forwardRef","props","ref","multiple","id","label","rest","defaultId","useId","maxSizeDescriptionId","descriptor","context","useFileInputContext","jsx","children","accept","maxSizeBytes","onChange","elementId","jsxs","Fragment","className","htmlFor","type","value","e","target","files","map","file","state","validation","validateFile","uploadProgress","displayName"],"mappings":"2NAWO,MAAMA,EAAQC,GACjB,CAACC,EAAOC,KACE,MAAEC,SAAAA,EAAUC,GAAAA,EAAIC,MAAAA,KAAUC,GAASL,EAEnCM,EAAYC,IAEZC,EAAuBL,EAAK,eAC5BM,EAAaP,EAAW,QAAU,MAElCQ,EAAUC,IAChB,IAAKD,EAEG,OAAAE,EAAC,KAAEC,SAAuD,4DAG5D,MAAEC,OAAAA,EAAQC,aAAAA,EAAcC,SAAAA,GAAaN,EAErCO,EAAYd,GAAMG,EAExB,OAEQY,EAAAC,EAAA,CAAAN,SAAA,CAAAD,EAAC,QAAA,CACGQ,UAAU,mCACVC,QAASJ,EACTd,GAAI,GAAGc,aAENJ,SAAAT,IAELQ,EAAC,QAAA,IACOP,EACJJ,IAAAA,EACAE,GAAIc,EACJH,OAAAA,EACA,mBACIC,EAAeP,OAAuB,EAE1CY,UAAU,cACVE,KAAK,OACLpB,SAAAA,EACAqB,MAAM,GACNP,SAAWQ,IACHA,EAAEC,OAAOC,OACTV,EACIQ,EACA,IAAIA,EAAEC,OAAOC,OAAOC,KACfC,IAAU,CACPA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EACRH,EACAd,EACAC,GAEJiB,eAAgB,MAExB,IAKhBd,EAAC,IAAE,CAAAE,UAAU,gCAAgCP,SAAA,CAAA,eAC5BJ,EAAW,UACvB,MACT,IAKZX,EAAMmC,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Flex.js","sources":["../../../../src/components/flex/Flex.tsx"],"sourcesContent":["import React, { type CSSProperties } from \"react\";\nimport tokens from \"../../core/tokens.js\";\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 FlexDirection = \"row\" | \"row-reverse\" | \"column\" | \"column-reverse\";\nexport type GapValue = Exclude<keyof (typeof tokens)[\"spacing\"], 0>;\n\nexport type FlexProps<ElementType extends React.ElementType> =\n PolymorphicPropsWithRef<\n ElementType,\n {\n direction?: FlexDirection;\n wrap?: boolean;\n gap?: GapValue;\n colGap?: GapValue;\n rowGap?: GapValue;\n } & Pick<\n CSSProperties,\n \"alignContent\" | \"alignItems\" | \"justifyContent\" | \"justifyItems\"\n >\n >;\n\nexport type FlexComponent = <ElementType extends React.ElementType = \"div\">(\n props: FlexProps<ElementType> & AsChildProps,\n) => React.ReactElement | null;\n\nexport const Flex = React.forwardRef(function Flex<\n ElementType extends React.ElementType = \"div\",\n>(props: FlexProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n asChild,\n as = \"div\",\n alignContent,\n alignItems,\n children,\n colGap,\n direction,\n gap,\n justifyContent,\n justifyItems,\n rowGap,\n wrap = false,\n ...rest\n } = props;\n const Component = asChild ? SlotComponent : as;\n\n const flexStyle: CSSProperties = {\n display: \"flex\",\n flexDirection: direction,\n alignContent,\n alignItems,\n justifyContent,\n justifyItems,\n ...(wrap ? { flexWrap: \"wrap\" } : {}),\n ...(gap ? { gap: tokens.spacing[gap] } : {}),\n ...(colGap ? { columnGap: tokens.spacing[colGap] } : {}),\n ...(rowGap ? { rowGap: tokens.spacing[rowGap] } : {}),\n };\n\n return (\n <Component ref={ref} {...rest} style={{ ...flexStyle, ...rest.style }}>\n {children}\n </Component>\n );\n}) as FlexComponent;\n"],"names":["Flex","React","forwardRef","props","ref","asChild","as","alignContent","alignItems","children","colGap","direction","gap","justifyContent","justifyItems","rowGap","wrap","rest","Component","SlotComponent","flexStyle","display","flexDirection","flexWrap","tokens","spacing","columnGap","jsx","style"],"mappings":"+KA+BO,MAAMA,EAAOC,EAAMC,YAAW,SAEnCC,EAA+BC,GACvB,MACFC,QAAAA,EACAC,GAAAA,EAAK,MACLC,aAAAA,EACAC,WAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,IAAAA,EACAC,eAAAA,EACAC,aAAAA,EACAC,OAAAA,EACAC,KAAAA,GAAO,KACJC,GACHd,EACEe,EAAYb,EAAUc,EAAgBb,EAEtCc,EAA2B,CAC7BC,QAAS,OACTC,cAAeX,EACfJ,aAAAA,EACAC,WAAAA,EACAK,eAAAA,EACAC,aAAAA,KACIE,EAAO,CAAEO,SAAU,QAAW,CAAC,KAC/BX,EAAM,CAAEA,IAAKY,EAAOC,QAAQb,IAAS,CAAC,KACtCF,EAAS,CAAEgB,UAAWF,EAAOC,QAAQf,IAAY,CAAC,KAClDK,EAAS,CAAEA,OAAQS,EAAOC,QAAQV,IAAY,CAAA,GAGtD,OACKY,EAAAT,EAAA,CAAUd,IAAAA,KAAca,EAAMW,MAAO,IAAKR,KAAcH,EAAKW,OACzDnB,SAAAA,GAGb"}
1
+ {"version":3,"file":"Flex.js","sources":["../../../../src/components/flex/Flex.tsx"],"sourcesContent":["import React, { type CSSProperties } from \"react\";\nimport tokens from \"../../core/tokens.js\";\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 FlexDirection = \"row\" | \"row-reverse\" | \"column\" | \"column-reverse\";\nexport type GapValue = Exclude<keyof (typeof tokens)[\"spacing\"], 0>;\n\nexport type FlexProps<ElementType extends React.ElementType> =\n PolymorphicPropsWithRef<\n ElementType,\n {\n direction?: FlexDirection;\n wrap?: boolean;\n gap?: GapValue;\n colGap?: GapValue;\n rowGap?: GapValue;\n } & Pick<\n CSSProperties,\n \"alignContent\" | \"alignItems\" | \"justifyContent\" | \"justifyItems\"\n >\n >;\n\nexport type FlexComponent = <ElementType extends React.ElementType = \"div\">(\n props: FlexProps<ElementType> & AsChildProps,\n) => React.ReactElement | null;\n\nexport const Flex = React.forwardRef(function Flex<\n ElementType extends React.ElementType = \"div\",\n>(props: FlexProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n asChild,\n as = \"div\",\n alignContent,\n alignItems,\n children,\n colGap,\n direction,\n gap,\n justifyContent,\n justifyItems,\n rowGap,\n wrap = false,\n ...rest\n } = props;\n const Component = asChild ? SlotComponent : as;\n\n const flexStyle: CSSProperties = {\n display: \"flex\",\n flexDirection: direction,\n alignContent,\n alignItems,\n justifyContent,\n justifyItems,\n ...(wrap ? { flexWrap: \"wrap\" } : {}),\n ...(gap ? { gap: tokens.spacing[gap] } : {}),\n ...(colGap ? { columnGap: tokens.spacing[colGap] } : {}),\n ...(rowGap ? { rowGap: tokens.spacing[rowGap] } : {}),\n };\n\n return (\n <Component ref={ref} {...rest} style={{ ...flexStyle, ...rest.style }}>\n {children}\n </Component>\n );\n}) as FlexComponent;\n"],"names":["Flex","React","forwardRef","props","ref","asChild","as","alignContent","alignItems","children","colGap","direction","gap","justifyContent","justifyItems","rowGap","wrap","rest","Component","SlotComponent","flexStyle","display","flexDirection","flexWrap","tokens","spacing","columnGap","jsx","style"],"mappings":"+KA+BO,MAAMA,EAAOC,EAAMC,YAAW,SAEnCC,EAA+BC,GACvB,MACFC,QAAAA,EACAC,GAAAA,EAAK,MACLC,aAAAA,EACAC,WAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,IAAAA,EACAC,eAAAA,EACAC,aAAAA,EACAC,OAAAA,EACAC,KAAAA,GAAO,KACJC,GACHd,EACEe,EAAYb,EAAUc,EAAgBb,EAEtCc,EAA2B,CAC7BC,QAAS,OACTC,cAAeX,EACfJ,aAAAA,EACAC,WAAAA,EACAK,eAAAA,EACAC,aAAAA,KACIE,EAAO,CAAEO,SAAU,QAAW,CAAC,KAC/BX,EAAM,CAAEA,IAAKY,EAAOC,QAAQb,IAAS,CAAC,KACtCF,EAAS,CAAEgB,UAAWF,EAAOC,QAAQf,IAAY,CAAC,KAClDK,EAAS,CAAEA,OAAQS,EAAOC,QAAQV,IAAY,CAAC,GAGvD,OACKY,EAAAT,EAAA,CAAUd,IAAAA,KAAca,EAAMW,MAAO,IAAKR,KAAcH,EAAKW,OACzDnB,SAAAA,GAGb"}
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","sources":["../../../../src/components/icon-button/IconButton.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { ButtonHTMLAttributes, forwardRef } from \"react\";\nimport { Density } from \"../../core/types.js\";\n\nexport interface IconButtonProps\n extends Exclude<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n density?: Density;\n}\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n (props, ref) => {\n const { className, children, density, ...rest } = props;\n return (\n <button\n ref={ref}\n type=\"button\"\n className={clsx(\"jkl-icon-button\", className)}\n data-testid=\"jkl-icon-button\"\n data-density={density}\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\n\nIconButton.displayName = \"IconButton\";\n"],"names":["IconButton","forwardRef","props","ref","className","children","density","rest","jsx","type","clsx","displayName"],"mappings":"yHASO,MAAMA,EAAaC,GACtB,CAACC,EAAOC,KACE,MAAEC,UAAAA,EAAWC,SAAAA,EAAUC,QAAAA,KAAYC,GAASL,EAE9C,OAAAM,EAAC,SAAA,CACGL,IAAAA,EACAM,KAAK,SACLL,UAAWM,EAAK,kBAAmBN,GACnC,cAAY,kBACZ,eAAcE,KACVC,EAEHF,SAAAA,GACL,IAKZL,EAAWW,YAAc"}
1
+ {"version":3,"file":"IconButton.js","sources":["../../../../src/components/icon-button/IconButton.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { ButtonHTMLAttributes, forwardRef } from \"react\";\nimport { Density } from \"../../core/types.js\";\n\nexport interface IconButtonProps\n extends Exclude<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n density?: Density;\n}\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n (props, ref) => {\n const { className, children, density, ...rest } = props;\n return (\n <button\n ref={ref}\n type=\"button\"\n className={clsx(\"jkl-icon-button\", className)}\n data-testid=\"jkl-icon-button\"\n data-density={density}\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\n\nIconButton.displayName = \"IconButton\";\n"],"names":["IconButton","forwardRef","props","ref","className","children","density","rest","jsx","type","clsx","displayName"],"mappings":"yHASO,MAAMA,EAAaC,GACtB,CAACC,EAAOC,KACE,MAAEC,UAAAA,EAAWC,SAAAA,EAAUC,QAAAA,KAAYC,GAASL,EAE9C,OAAAM,EAAC,SAAA,CACGL,IAAAA,EACAM,KAAK,SACLL,UAAWM,EAAK,kBAAmBN,GACnC,cAAY,kBACZ,eAAcE,KACVC,EAEHF,SAAAA,GAAA,IAMjBL,EAAWW,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Image.js","sources":["../../../../src/components/image/Image.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC } from \"react\";\nimport { useElementDimensions } from \"../../hooks/useElementDimensions/useElementDimensions.js\";\nimport { useImageLoadingStatus } from \"./useImageLoadingStatus.js\";\n\nexport interface ImageProps {\n src: string;\n srcSet?: string;\n placeholder?: string;\n /**\n * Send inn en tom streng hvis bildet kun er dekorativt. Sannsynligvis bør du beskrive innholdet i bildet så en person med nedsatt syn får en fullgod opplevelse av siden.\n * Les mer på https://jokul.fremtind.no/universell-utforming/guide#uu/dekorativt-innhold\n */\n alt: string;\n className?: string;\n}\n\nexport const Image: FC<ImageProps> = ({\n className,\n placeholder,\n alt,\n ...imageProperties\n}) => {\n const [imageRef, imageLoaded] = useImageLoadingStatus();\n const [containerRef, dimensions] =\n useElementDimensions<HTMLDivElement>(400);\n\n return (\n <div\n ref={containerRef}\n className={clsx(\"jkl-image\", className, {\n \"jkl-image--loading\": !imageLoaded,\n })}\n >\n {/* Placeholder er bevisst uten loading og decoding for å vises umiddelbart */}\n <img\n className=\"jkl-image__placeholder\"\n alt={alt}\n src={placeholder || imageProperties.src}\n />\n <img\n alt={alt}\n className=\"jkl-image__image\"\n data-testid=\"jkl-image__image\"\n ref={imageRef}\n sizes={`${dimensions.width}px`}\n loading=\"lazy\"\n decoding=\"async\"\n {...imageProperties}\n />\n </div>\n );\n};\n"],"names":["Image","className","placeholder","alt","imageProperties","imageRef","imageLoaded","useImageLoadingStatus","containerRef","dimensions","useElementDimensions","jsxs","ref","clsx","children","jsx","src","sizes","width","loading","decoding"],"mappings":"mQAiBO,MAAMA,EAAwB,EACjCC,UAAAA,EACAC,YAAAA,EACAC,IAAAA,KACGC,MAEG,MAACC,EAAUC,GAAeC,KACzBC,EAAcC,GACjBC,EAAqC,KAGrC,OAAAC,EAAC,MAAA,CACGC,IAAKJ,EACLP,UAAWY,EAAK,YAAaZ,EAAW,CACpC,sBAAuBK,IAI3BQ,SAAA,CAAAC,EAAC,MAAA,CACGd,UAAU,yBACVE,IAAAA,EACAa,IAAKd,GAAeE,EAAgBY,MAExCD,EAAC,MAAA,CACGZ,IAAAA,EACAF,UAAU,mBACV,cAAY,mBACZW,IAAKP,EACLY,MAAO,GAAGR,EAAWS,UACrBC,QAAQ,OACRC,SAAS,WACLhB,MAEZ"}
1
+ {"version":3,"file":"Image.js","sources":["../../../../src/components/image/Image.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC } from \"react\";\nimport { useElementDimensions } from \"../../hooks/useElementDimensions/useElementDimensions.js\";\nimport { useImageLoadingStatus } from \"./useImageLoadingStatus.js\";\n\nexport interface ImageProps {\n src: string;\n srcSet?: string;\n placeholder?: string;\n /**\n * Send inn en tom streng hvis bildet kun er dekorativt. Sannsynligvis bør du beskrive innholdet i bildet så en person med nedsatt syn får en fullgod opplevelse av siden.\n * Les mer på https://jokul.fremtind.no/universell-utforming/guide#uu/dekorativt-innhold\n */\n alt: string;\n className?: string;\n}\n\nexport const Image: FC<ImageProps> = ({\n className,\n placeholder,\n alt,\n ...imageProperties\n}) => {\n const [imageRef, imageLoaded] = useImageLoadingStatus();\n const [containerRef, dimensions] =\n useElementDimensions<HTMLDivElement>(400);\n\n return (\n <div\n ref={containerRef}\n className={clsx(\"jkl-image\", className, {\n \"jkl-image--loading\": !imageLoaded,\n })}\n >\n {/* Placeholder er bevisst uten loading og decoding for å vises umiddelbart */}\n <img\n className=\"jkl-image__placeholder\"\n alt={alt}\n src={placeholder || imageProperties.src}\n />\n <img\n alt={alt}\n className=\"jkl-image__image\"\n data-testid=\"jkl-image__image\"\n ref={imageRef}\n sizes={`${dimensions.width}px`}\n loading=\"lazy\"\n decoding=\"async\"\n {...imageProperties}\n />\n </div>\n );\n};\n"],"names":["Image","className","placeholder","alt","imageProperties","imageRef","imageLoaded","useImageLoadingStatus","containerRef","dimensions","useElementDimensions","jsxs","ref","clsx","children","jsx","src","sizes","width","loading","decoding"],"mappings":"mQAiBO,MAAMA,EAAwB,EACjCC,UAAAA,EACAC,YAAAA,EACAC,IAAAA,KACGC,MAEG,MAACC,EAAUC,GAAeC,KACzBC,EAAcC,GACjBC,EAAqC,KAGrC,OAAAC,EAAC,MAAA,CACGC,IAAKJ,EACLP,UAAWY,EAAK,YAAaZ,EAAW,CACpC,sBAAuBK,IAI3BQ,SAAA,CAAAC,EAAC,MAAA,CACGd,UAAU,yBACVE,IAAAA,EACAa,IAAKd,GAAeE,EAAgBY,MAExCD,EAAC,MAAA,CACGZ,IAAAA,EACAF,UAAU,mBACV,cAAY,mBACZW,IAAKP,EACLY,MAAO,GAAGR,EAAWS,UACrBC,QAAQ,OACRC,SAAS,WACLhB,MACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"useImageLoadingStatus.js","sources":["../../../../src/components/image/useImageLoadingStatus.ts"],"sourcesContent":["import { RefObject, useEffect, useRef, useState } from \"react\";\n\nconst doWhenImageLoaded = (image: HTMLImageElement, callback?: () => void) => {\n let timeout: number | undefined;\n\n function checkLoaded() {\n if (image.complete) {\n clearTimeout(timeout);\n callback?.();\n return;\n }\n timeout = window.setTimeout(checkLoaded, 50);\n }\n\n checkLoaded();\n};\n\nexport const useImageLoadingStatus = (\n callback?: () => void,\n): [RefObject<HTMLImageElement>, boolean] => {\n const imageRef = useRef<HTMLImageElement>(null);\n const [imageLoaded, setImageLoaded] = useState(false);\n\n useEffect(() => {\n imageRef.current &&\n doWhenImageLoaded(imageRef.current, () => {\n setImageLoaded(true);\n callback?.();\n });\n }, [callback]);\n\n return [imageRef, imageLoaded];\n};\n"],"names":["useImageLoadingStatus","callback","imageRef","useRef","imageLoaded","setImageLoaded","useState","useEffect","current","image","timeout","checkLoaded","complete","window","setTimeout","doWhenImageLoaded"],"mappings":"4DAEA,MAeaA,EACTC,IAEMC,MAAAA,EAAWC,EAAyB,OACnCC,EAAaC,GAAkBC,GAAS,GAE/C,OAAAC,GAAU,KACNL,EAASM,SAtBS,EAACC,EAAyBR,KAC5CS,IAAAA,GAEJ,SAASC,IACL,GAAIF,EAAMG,SAGN,OAFaF,aAAAA,QACF,MAAAT,GAAAA,KAGLS,EAAAG,OAAOC,WAAWH,EAAa,GAAE,CAGnCA,EAAA,EAWJI,CAAkBb,EAASM,SAAS,KAChCH,GAAe,GACJ,MAAAJ,GAAAA,GAAAA,GACd,GACN,CAACA,IAEG,CAACC,EAAUE,EAAW"}
1
+ {"version":3,"file":"useImageLoadingStatus.js","sources":["../../../../src/components/image/useImageLoadingStatus.ts"],"sourcesContent":["import { RefObject, useEffect, useRef, useState } from \"react\";\n\nconst doWhenImageLoaded = (image: HTMLImageElement, callback?: () => void) => {\n let timeout: number | undefined;\n\n function checkLoaded() {\n if (image.complete) {\n clearTimeout(timeout);\n callback?.();\n return;\n }\n timeout = window.setTimeout(checkLoaded, 50);\n }\n\n checkLoaded();\n};\n\nexport const useImageLoadingStatus = (\n callback?: () => void,\n): [RefObject<HTMLImageElement>, boolean] => {\n const imageRef = useRef<HTMLImageElement>(null);\n const [imageLoaded, setImageLoaded] = useState(false);\n\n useEffect(() => {\n imageRef.current &&\n doWhenImageLoaded(imageRef.current, () => {\n setImageLoaded(true);\n callback?.();\n });\n }, [callback]);\n\n return [imageRef, imageLoaded];\n};\n"],"names":["useImageLoadingStatus","callback","imageRef","useRef","imageLoaded","setImageLoaded","useState","useEffect","current","image","timeout","checkLoaded","complete","window","setTimeout","doWhenImageLoaded"],"mappings":"4DAEA,MAeaA,EACTC,IAEMC,MAAAA,EAAWC,EAAyB,OACnCC,EAAaC,GAAkBC,GAAS,GAE/C,OAAAC,GAAU,KACNL,EAASM,SAtBS,EAACC,EAAyBR,KAC5CS,IAAAA,GAEJ,SAASC,IACL,GAAIF,EAAMG,SAGN,OAFaF,aAAAA,QACF,MAAAT,GAAAA,KAGLS,EAAAG,OAAOC,WAAWH,EAAa,GAC7C,CAEYA,IAWJI,CAAkBb,EAASM,SAAS,KAChCH,GAAe,GACJ,MAAAJ,GAAAA,GAAAA,GACd,GACN,CAACA,IAEG,CAACC,EAAUE,EAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldGroup.js","sources":["../../../../src/components/input-group/FieldGroup.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC, FieldsetHTMLAttributes, type ReactNode } from \"react\";\nimport { DataTestAutoId, Density } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { Label, LabelProps } from \"./Label.js\";\nimport { SupportLabel, SupportLabelProps } from \"./SupportLabel.js\";\n\nexport interface FieldGroupProps\n extends DataTestAutoId,\n FieldsetHTMLAttributes<HTMLFieldSetElement> {\n legend: string;\n labelProps?: Omit<LabelProps, \"children\" | \"density\">;\n supportLabelProps?: Omit<\n SupportLabelProps,\n \"id\" | \"errorLabel\" | \"helpLabel\" | \"density\"\n >;\n tooltip?: ReactNode;\n className?: string;\n helpLabel?: string;\n errorLabel?: string;\n density?: Density;\n}\n\nexport const FieldGroup: FC<FieldGroupProps> = (props) => {\n const {\n id,\n legend,\n labelProps,\n supportLabelProps,\n tooltip,\n className,\n children,\n helpLabel,\n errorLabel,\n density,\n \"data-testautoid\": testAutoId,\n ...rest\n } = props;\n\n const uid = useId(id || \"jkl-field-group\", { generateSuffix: !id });\n const supportId = `${uid}_support-label`;\n\n const supportText = errorLabel || helpLabel;\n const supportTextType = errorLabel\n ? \"error\"\n : helpLabel\n ? \"help\"\n : undefined;\n\n const describedBy = supportText ? supportId : undefined;\n\n return (\n <fieldset\n id={uid}\n className={clsx(\"jkl-field-group\", className)}\n data-testautoid={testAutoId}\n {...rest}\n aria-describedby={describedBy}\n data-density={density}\n >\n <legend className=\"jkl-field-group__legend\">\n <Label {...labelProps} density={density}>\n {tooltip ? (\n <>\n <span style={{ whiteSpace: \"normal\" }}>\n {legend}\n </span>\n {`\\u00A0`}\n {tooltip}\n </>\n ) : (\n legend\n )}\n </Label>\n </legend>\n {children}\n {(helpLabel || errorLabel) && (\n <SupportLabel\n {...supportLabelProps}\n label={supportText}\n labelType={supportTextType}\n id={supportId}\n density={density}\n />\n )}\n </fieldset>\n );\n};\n"],"names":["FieldGroup","props","id","legend","labelProps","supportLabelProps","tooltip","className","children","helpLabel","errorLabel","density","testAutoId","rest","uid","useId","generateSuffix","supportId","supportText","supportTextType","describedBy","jsxs","clsx","jsx","Label","Fragment","style","whiteSpace","SupportLabel","label","labelType"],"mappings":"qPAuBa,MAAAA,EAAmCC,IACtC,MACFC,GAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,kBAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACA,kBAAmBC,KAChBC,GACHZ,EAEEa,EAAMC,EAAMb,GAAM,kBAAmB,CAAEc,gBAAiBd,IACxDe,EAAY,GAAGH,kBAEfI,EAAcR,GAAcD,EAC5BU,EAAkBT,EAClB,QACAD,EACA,YACA,EAEAW,EAAcF,EAAcD,OAAY,EAG1C,OAAAI,EAAC,WAAA,CACGnB,GAAIY,EACJP,UAAWe,EAAK,kBAAmBf,GACnC,kBAAiBK,KACbC,EACJ,mBAAkBO,EAClB,eAAcT,EAEdH,SAAA,CAACe,EAAA,SAAA,CAAOhB,UAAU,0BACdC,SAAAe,EAACC,MAAUpB,EAAYO,QAAAA,EAClBH,SAAAF,EAEOe,EAAAI,EAAA,CAAAjB,SAAA,CAAAe,EAAC,QAAKG,MAAO,CAAEC,WAAY,UACtBnB,SACLL,IACC,IACAG,KAGLH,MAIXK,GACCC,GAAaC,IACXa,EAACK,EAAA,IACOvB,EACJwB,MAAOX,EACPY,UAAWX,EACXjB,GAAIe,EACJN,QAAAA,MAGZ"}
1
+ {"version":3,"file":"FieldGroup.js","sources":["../../../../src/components/input-group/FieldGroup.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC, FieldsetHTMLAttributes, type ReactNode } from \"react\";\nimport { DataTestAutoId, Density } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { Label, LabelProps } from \"./Label.js\";\nimport { SupportLabel, SupportLabelProps } from \"./SupportLabel.js\";\n\nexport interface FieldGroupProps\n extends DataTestAutoId,\n FieldsetHTMLAttributes<HTMLFieldSetElement> {\n legend: string;\n labelProps?: Omit<LabelProps, \"children\" | \"density\">;\n supportLabelProps?: Omit<\n SupportLabelProps,\n \"id\" | \"errorLabel\" | \"helpLabel\" | \"density\"\n >;\n tooltip?: ReactNode;\n className?: string;\n helpLabel?: string;\n errorLabel?: string;\n density?: Density;\n}\n\nexport const FieldGroup: FC<FieldGroupProps> = (props) => {\n const {\n id,\n legend,\n labelProps,\n supportLabelProps,\n tooltip,\n className,\n children,\n helpLabel,\n errorLabel,\n density,\n \"data-testautoid\": testAutoId,\n ...rest\n } = props;\n\n const uid = useId(id || \"jkl-field-group\", { generateSuffix: !id });\n const supportId = `${uid}_support-label`;\n\n const supportText = errorLabel || helpLabel;\n const supportTextType = errorLabel\n ? \"error\"\n : helpLabel\n ? \"help\"\n : undefined;\n\n const describedBy = supportText ? supportId : undefined;\n\n return (\n <fieldset\n id={uid}\n className={clsx(\"jkl-field-group\", className)}\n data-testautoid={testAutoId}\n {...rest}\n aria-describedby={describedBy}\n data-density={density}\n >\n <legend className=\"jkl-field-group__legend\">\n <Label {...labelProps} density={density}>\n {tooltip ? (\n <>\n <span style={{ whiteSpace: \"normal\" }}>\n {legend}\n </span>\n {`\\u00A0`}\n {tooltip}\n </>\n ) : (\n legend\n )}\n </Label>\n </legend>\n {children}\n {(helpLabel || errorLabel) && (\n <SupportLabel\n {...supportLabelProps}\n label={supportText}\n labelType={supportTextType}\n id={supportId}\n density={density}\n />\n )}\n </fieldset>\n );\n};\n"],"names":["FieldGroup","props","id","legend","labelProps","supportLabelProps","tooltip","className","children","helpLabel","errorLabel","density","testAutoId","rest","uid","useId","generateSuffix","supportId","supportText","supportTextType","describedBy","jsxs","clsx","jsx","Label","Fragment","style","whiteSpace","SupportLabel","label","labelType"],"mappings":"qPAuBa,MAAAA,EAAmCC,IACtC,MACFC,GAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,kBAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACA,kBAAmBC,KAChBC,GACHZ,EAEEa,EAAMC,EAAMb,GAAM,kBAAmB,CAAEc,gBAAiBd,IACxDe,EAAY,GAAGH,kBAEfI,EAAcR,GAAcD,EAC5BU,EAAkBT,EAClB,QACAD,EACA,YACA,EAEAW,EAAcF,EAAcD,OAAY,EAG1C,OAAAI,EAAC,WAAA,CACGnB,GAAIY,EACJP,UAAWe,EAAK,kBAAmBf,GACnC,kBAAiBK,KACbC,EACJ,mBAAkBO,EAClB,eAAcT,EAEdH,SAAA,CAACe,EAAA,SAAA,CAAOhB,UAAU,0BACdC,SAAAe,EAACC,MAAUpB,EAAYO,QAAAA,EAClBH,SAAAF,EAEOe,EAAAI,EAAA,CAAAjB,SAAA,CAAAe,EAAC,QAAKG,MAAO,CAAEC,WAAY,UACtBnB,SACLL,IACC,IACAG,KAGLH,MAIXK,GACCC,GAAaC,IACXa,EAACK,EAAA,IACOvB,EACJwB,MAAOX,EACPY,UAAWX,EACXjB,GAAIe,EACJN,QAAAA,MACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"InputGroup.js","sources":["../../../../src/components/input-group/InputGroup.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, type CSSProperties, type ReactNode } from \"react\";\nimport {\n DataTestAutoId,\n Density,\n WithOptionalChildren,\n} from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { Label, LabelProps } from \"./Label.js\";\nimport { SupportLabel, SupportLabelProps } from \"./SupportLabel.js\";\n\nexport interface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n}\n\nexport type InputGroupProps = WithOptionalChildren &\n DataTestAutoId & {\n id?: string;\n className?: string;\n \"data-testid\"?: string;\n density?: Density;\n errorLabel?: ReactNode;\n helpLabel?: ReactNode;\n inline?: boolean;\n label: ReactNode;\n labelProps?: Omit<LabelProps, \"children\" | \"density\">;\n supportLabelProps?: Omit<\n SupportLabelProps,\n \"id\" | \"errorLabel\" | \"helpLabel\" | \"density\"\n >;\n tooltip?: ReactNode;\n style?: CSSProperties;\n render?: (props: InputProps) => JSX.Element;\n };\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(\n (props, ref) => {\n const {\n className,\n children,\n density,\n errorLabel,\n helpLabel,\n inline,\n label,\n labelProps,\n render,\n supportLabelProps,\n tooltip,\n id,\n ...rest\n } = props;\n\n const uid = useId(id || \"jkl-input\", { generateSuffix: !id });\n const supportId = useId(\"jkl-support-label\");\n\n const hasTooltip = !!tooltip;\n\n const supportText = errorLabel || helpLabel;\n const supportTextType = errorLabel\n ? \"error\"\n : helpLabel\n ? \"help\"\n : undefined;\n\n const describedBy = supportText ? supportId : undefined;\n\n const inputProps: InputProps = {\n \"aria-describedby\": describedBy,\n \"aria-invalid\": Boolean(errorLabel) ? true : undefined,\n id: uid,\n };\n\n const renderInput = render\n ? () => render(inputProps)\n : () => {\n const input = React.Children.toArray(props.children)[0];\n\n if (!React.isValidElement<InputProps>(input)) return;\n\n return React.cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n });\n };\n\n return (\n <div\n ref={ref}\n className={clsx(className, \"jkl-input-group\", {\n \"jkl-input-group--inline\": inline,\n })}\n data-density={density}\n {...rest}\n >\n <Label\n standAlone\n htmlFor={uid}\n srOnly={inline}\n {...labelProps}\n style={{\n whiteSpace: hasTooltip ? \"nowrap\" : undefined,\n ...labelProps?.style,\n }}\n density={density}\n >\n {hasTooltip ? (\n <>\n <span style={{ whiteSpace: \"normal\" }}>\n {label}\n </span>\n {`\\u00A0`}\n {tooltip}\n </>\n ) : (\n label\n )}\n </Label>\n {renderInput()}\n <SupportLabel\n srOnly={inline}\n {...supportLabelProps}\n label={supportText}\n labelType={supportTextType}\n id={supportId}\n density={density}\n />\n </div>\n );\n },\n);\n\nInputGroup.displayName = \"InputGroup\";\n"],"names":["InputGroup","forwardRef","props","ref","className","children","density","errorLabel","helpLabel","inline","label","labelProps","render","supportLabelProps","tooltip","id","rest","uid","useId","generateSuffix","supportId","hasTooltip","supportText","supportTextType","inputProps","renderInput","input","React","Children","toArray","isValidElement","cloneElement","jsxs","clsx","jsx","Label","standAlone","htmlFor","srOnly","style","whiteSpace","Fragment","SupportLabel","labelType","displayName"],"mappings":"2RAqCO,MAAMA,EAAaC,GACtB,CAACC,EAAOC,KACE,MACFC,UAAAA,EACAC,SAAAA,EACAC,QAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAC,OAAAA,EACAC,MAAAA,EACAC,WAAAA,EACAC,OAAAA,EACAC,kBAAAA,EACAC,QAAAA,EACAC,GAAAA,KACGC,GACHd,EAEEe,EAAMC,EAAMH,GAAM,YAAa,CAAEI,gBAAiBJ,IAClDK,EAAYF,EAAM,qBAElBG,IAAeP,EAEfQ,EAAcf,GAAcC,EAC5Be,EAAkBhB,EAClB,QACAC,EACA,YACA,EAIAgB,EAAyB,CAC3B,mBAHgBF,EAAcF,OAAY,EAI1C,iBAAwBb,QAAqB,EAC7CQ,GAAIE,GAGFQ,EAAcb,EACd,IAAMA,EAAOY,GACb,KACI,MAAME,EAAQC,EAAMC,SAASC,QAAQ3B,EAAMG,UAAU,GAEhDsB,GAAAA,EAAMG,eAA2BJ,GAE/BC,OAAAA,EAAMI,aAAyBL,EAAO,IACtCF,KACAE,EAAMxB,OACZ,EAIP,OAAA8B,EAAC,MAAA,CACG7B,IAAAA,EACAC,UAAW6B,EAAK7B,EAAW,kBAAmB,CAC1C,0BAA2BK,IAE/B,eAAcH,KACVU,EAEJX,SAAA,CAAA6B,EAACC,EAAA,CACGC,YAAU,EACVC,QAASpB,EACTqB,OAAQ7B,KACJE,EACJ4B,MAAO,CACHC,WAAYnB,EAAa,cAAW,KACjC,MAAAV,OAAA,EAAAA,EAAY4B,OAEnBjC,QAAAA,EAECD,WAEO2B,EAAAS,EAAA,CAAApC,SAAA,CAAA6B,EAAC,QAAKK,MAAO,CAAEC,WAAY,UACtBnC,SACLK,IACC,IACAI,KAGLJ,IAGPe,IACDS,EAACQ,EAAA,CACGJ,OAAQ7B,KACJI,EACJH,MAAOY,EACPqB,UAAWpB,EACXR,GAAIK,EACJd,QAAAA,MAER,IAKZN,EAAW4C,YAAc"}
1
+ {"version":3,"file":"InputGroup.js","sources":["../../../../src/components/input-group/InputGroup.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, type CSSProperties, type ReactNode } from \"react\";\nimport {\n DataTestAutoId,\n Density,\n WithOptionalChildren,\n} from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { Label, LabelProps } from \"./Label.js\";\nimport { SupportLabel, SupportLabelProps } from \"./SupportLabel.js\";\n\nexport interface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n}\n\nexport type InputGroupProps = WithOptionalChildren &\n DataTestAutoId & {\n id?: string;\n className?: string;\n \"data-testid\"?: string;\n density?: Density;\n errorLabel?: ReactNode;\n helpLabel?: ReactNode;\n inline?: boolean;\n label: ReactNode;\n labelProps?: Omit<LabelProps, \"children\" | \"density\">;\n supportLabelProps?: Omit<\n SupportLabelProps,\n \"id\" | \"errorLabel\" | \"helpLabel\" | \"density\"\n >;\n tooltip?: ReactNode;\n style?: CSSProperties;\n render?: (props: InputProps) => JSX.Element;\n };\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(\n (props, ref) => {\n const {\n className,\n children,\n density,\n errorLabel,\n helpLabel,\n inline,\n label,\n labelProps,\n render,\n supportLabelProps,\n tooltip,\n id,\n ...rest\n } = props;\n\n const uid = useId(id || \"jkl-input\", { generateSuffix: !id });\n const supportId = useId(\"jkl-support-label\");\n\n const hasTooltip = !!tooltip;\n\n const supportText = errorLabel || helpLabel;\n const supportTextType = errorLabel\n ? \"error\"\n : helpLabel\n ? \"help\"\n : undefined;\n\n const describedBy = supportText ? supportId : undefined;\n\n const inputProps: InputProps = {\n \"aria-describedby\": describedBy,\n \"aria-invalid\": Boolean(errorLabel) ? true : undefined,\n id: uid,\n };\n\n const renderInput = render\n ? () => render(inputProps)\n : () => {\n const input = React.Children.toArray(props.children)[0];\n\n if (!React.isValidElement<InputProps>(input)) return;\n\n return React.cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n });\n };\n\n return (\n <div\n ref={ref}\n className={clsx(className, \"jkl-input-group\", {\n \"jkl-input-group--inline\": inline,\n })}\n data-density={density}\n {...rest}\n >\n <Label\n standAlone\n htmlFor={uid}\n srOnly={inline}\n {...labelProps}\n style={{\n whiteSpace: hasTooltip ? \"nowrap\" : undefined,\n ...labelProps?.style,\n }}\n density={density}\n >\n {hasTooltip ? (\n <>\n <span style={{ whiteSpace: \"normal\" }}>\n {label}\n </span>\n {`\\u00A0`}\n {tooltip}\n </>\n ) : (\n label\n )}\n </Label>\n {renderInput()}\n <SupportLabel\n srOnly={inline}\n {...supportLabelProps}\n label={supportText}\n labelType={supportTextType}\n id={supportId}\n density={density}\n />\n </div>\n );\n },\n);\n\nInputGroup.displayName = \"InputGroup\";\n"],"names":["InputGroup","forwardRef","props","ref","className","children","density","errorLabel","helpLabel","inline","label","labelProps","render","supportLabelProps","tooltip","id","rest","uid","useId","generateSuffix","supportId","hasTooltip","supportText","supportTextType","inputProps","renderInput","input","React","Children","toArray","isValidElement","cloneElement","jsxs","clsx","jsx","Label","standAlone","htmlFor","srOnly","style","whiteSpace","Fragment","SupportLabel","labelType","displayName"],"mappings":"2RAqCO,MAAMA,EAAaC,GACtB,CAACC,EAAOC,KACE,MACFC,UAAAA,EACAC,SAAAA,EACAC,QAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAC,OAAAA,EACAC,MAAAA,EACAC,WAAAA,EACAC,OAAAA,EACAC,kBAAAA,EACAC,QAAAA,EACAC,GAAAA,KACGC,GACHd,EAEEe,EAAMC,EAAMH,GAAM,YAAa,CAAEI,gBAAiBJ,IAClDK,EAAYF,EAAM,qBAElBG,IAAeP,EAEfQ,EAAcf,GAAcC,EAC5Be,EAAkBhB,EAClB,QACAC,EACA,YACA,EAIAgB,EAAyB,CAC3B,mBAHgBF,EAAcF,OAAY,EAI1C,iBAAwBb,QAAqB,EAC7CQ,GAAIE,GAGFQ,EAAcb,EACd,IAAMA,EAAOY,GACb,KACI,MAAME,EAAQC,EAAMC,SAASC,QAAQ3B,EAAMG,UAAU,GAEhDsB,GAAAA,EAAMG,eAA2BJ,GAE/BC,OAAAA,EAAMI,aAAyBL,EAAO,IACtCF,KACAE,EAAMxB,OACZ,EAIP,OAAA8B,EAAC,MAAA,CACG7B,IAAAA,EACAC,UAAW6B,EAAK7B,EAAW,kBAAmB,CAC1C,0BAA2BK,IAE/B,eAAcH,KACVU,EAEJX,SAAA,CAAA6B,EAACC,EAAA,CACGC,YAAU,EACVC,QAASpB,EACTqB,OAAQ7B,KACJE,EACJ4B,MAAO,CACHC,WAAYnB,EAAa,cAAW,KACjC,MAAAV,OAAA,EAAAA,EAAY4B,OAEnBjC,QAAAA,EAECD,WAEO2B,EAAAS,EAAA,CAAApC,SAAA,CAAA6B,EAAC,QAAKK,MAAO,CAAEC,WAAY,UACtBnC,SACLK,IACC,IACAI,KAGLJ,IAGPe,IACDS,EAACQ,EAAA,CACGJ,OAAQ7B,KACJI,EACJH,MAAOY,EACPqB,UAAWpB,EACXR,GAAIK,EACJd,QAAAA,MACJ,IAMhBN,EAAW4C,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Label.js","sources":["../../../../src/components/input-group/Label.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type CSSProperties, type FC } from \"react\";\nimport { Density, WithChildren } from \"../../core/types.js\";\n\nexport type LabelVariant = \"small\" | \"medium\" | \"large\";\n\nexport interface LabelProps extends WithChildren {\n id?: string;\n variant?: LabelVariant;\n density?: Density;\n srOnly?: boolean;\n standAlone?: boolean;\n htmlFor?: string;\n className?: string;\n style?: CSSProperties;\n}\n\nexport const Label: FC<LabelProps> = ({\n variant = \"small\",\n density,\n srOnly,\n children,\n standAlone,\n htmlFor,\n className = \"\",\n ...rest\n}) => {\n const labelClassNames = clsx(\"jkl-label\", className, {\n [`jkl-label--${variant}`]: variant,\n \"jkl-label--sr-only\": srOnly,\n });\n\n const C = standAlone ? \"label\" : \"span\";\n\n if (!standAlone && htmlFor) {\n htmlFor = undefined;\n if (process.env.NODE_ENV !== \"production\") {\n console.warn(\n \"WARNING: The standard Label component renders as a <span> element, which does not take a htmlFor prop. If you want the Label to belong to a specific input, use the standAlone prop, which renders as a <label> element instead. In most cases the Label component should not be used directly, as it is part of all our input components.\",\n );\n }\n }\n\n return (\n <C\n {...rest}\n className={labelClassNames}\n htmlFor={htmlFor}\n data-density={density}\n >\n {children}\n </C>\n );\n};\n"],"names":["Label","variant","density","srOnly","children","standAlone","htmlFor","className","rest","labelClassNames","clsx","C","process","env","NODE_ENV","console","warn","jsx"],"mappings":"sFAiBO,MAAMA,EAAwB,EACjCC,QAAAA,EAAU,QACVC,QAAAA,EACAC,OAAAA,EACAC,SAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,UAAAA,EAAY,MACTC,MAEGC,MAAAA,EAAkBC,EAAK,YAAaH,EAAW,CACjD,CAAC,cAAcN,KAAYA,EAC3B,qBAAsBE,IAGpBQ,EAAIN,EAAa,QAAU,OAE7B,OAACA,GAAcC,IACLA,OAAA,EACmB,eAAzBM,QAAQC,IAAIC,UACJC,QAAAC,KACJ,+UAMRC,EAACN,EAAA,IACOH,EACJD,UAAWE,EACXH,QAAAA,EACA,eAAcJ,EAEbE,SAAAA,GACL"}
1
+ {"version":3,"file":"Label.js","sources":["../../../../src/components/input-group/Label.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type CSSProperties, type FC } from \"react\";\nimport { Density, WithChildren } from \"../../core/types.js\";\n\nexport type LabelVariant = \"small\" | \"medium\" | \"large\";\n\nexport interface LabelProps extends WithChildren {\n id?: string;\n variant?: LabelVariant;\n density?: Density;\n srOnly?: boolean;\n standAlone?: boolean;\n htmlFor?: string;\n className?: string;\n style?: CSSProperties;\n}\n\nexport const Label: FC<LabelProps> = ({\n variant = \"small\",\n density,\n srOnly,\n children,\n standAlone,\n htmlFor,\n className = \"\",\n ...rest\n}) => {\n const labelClassNames = clsx(\"jkl-label\", className, {\n [`jkl-label--${variant}`]: variant,\n \"jkl-label--sr-only\": srOnly,\n });\n\n const C = standAlone ? \"label\" : \"span\";\n\n if (!standAlone && htmlFor) {\n htmlFor = undefined;\n if (process.env.NODE_ENV !== \"production\") {\n console.warn(\n \"WARNING: The standard Label component renders as a <span> element, which does not take a htmlFor prop. If you want the Label to belong to a specific input, use the standAlone prop, which renders as a <label> element instead. In most cases the Label component should not be used directly, as it is part of all our input components.\",\n );\n }\n }\n\n return (\n <C\n {...rest}\n className={labelClassNames}\n htmlFor={htmlFor}\n data-density={density}\n >\n {children}\n </C>\n );\n};\n"],"names":["Label","variant","density","srOnly","children","standAlone","htmlFor","className","rest","labelClassNames","clsx","C","process","env","NODE_ENV","console","warn","jsx"],"mappings":"sFAiBO,MAAMA,EAAwB,EACjCC,QAAAA,EAAU,QACVC,QAAAA,EACAC,OAAAA,EACAC,SAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,UAAAA,EAAY,MACTC,MAEGC,MAAAA,EAAkBC,EAAK,YAAaH,EAAW,CACjD,CAAC,cAAcN,KAAYA,EAC3B,qBAAsBE,IAGpBQ,EAAIN,EAAa,QAAU,OAE7B,OAACA,GAAcC,IACLA,OAAA,EACmB,eAAzBM,QAAQC,IAAIC,UACJC,QAAAC,KACJ,+UAMRC,EAACN,EAAA,IACOH,EACJD,UAAWE,EACXH,QAAAA,EACA,eAAcJ,EAEbE,SAAAA,GAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SupportLabel.js","sources":["../../../../src/components/input-group/SupportLabel.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC, type ReactNode } from \"react\";\nimport { Density } from \"../../core/types.js\";\nimport { ErrorIcon } from \"../icon/icons/ErrorIcon.js\";\nimport { SuccessIcon } from \"../icon/icons/SuccessIcon.js\";\nimport { WarningIcon } from \"../icon/icons/WarningIcon.js\";\n\nexport type SupportLabelType = \"help\" | \"error\" | \"warning\" | \"success\";\n\nexport interface SupportLabelProps {\n /**\n * En ID er påkrevd for å kunne referere til SupportLabel med aria-describedby.\n *\n * @example\n * ```tsx\n * const uid = useId();\n * const supportId = useId();\n * const hasSupportText = helpLabel || errorLabel;\n * const describedBy = hasSupportText ? supportId : undefined;\n *\n * return (\n * <div>\n * <Label standAlone htmlFor={uid}>\n * Velg en tekst\n * </Label>\n * <select\n * id={uid}\n * aria-describedby={describedBy}\n * >\n * <option value=\"e\">Example</option>\n * </select>\n * <SupportLabel\n * id={supportId}\n * label={errorLabel}\n * labelType=\"error\"\n * density={density}\n * />\n * </div>\n * );\n * ```\n */\n id: string;\n /**\n * @deprecated Bruk `label` for å få samme resultat.\n */\n helpLabel?: ReactNode;\n /**\n * @deprecated Bruk `label` og `labelType=\"warning\"` for å få samme resultat.\n */\n errorLabel?: ReactNode;\n label?: ReactNode;\n /**\n * Bestemmer hvilket ikon som skal vises:\n *\n * - \"help\" viser ikke noe ikon\n * - \"warning\" viser WarningIcon, det som tidligere ble vist med `errorLabel`\n * - \"error\" viser ErrorIcon\n * - \"success\" viser SuccessIcon\n *\n * @default \"help\"\n */\n labelType?: SupportLabelType;\n density?: Density;\n className?: string;\n srOnly?: boolean;\n}\n\nexport const SupportLabel: FC<SupportLabelProps> = ({\n id,\n helpLabel,\n errorLabel,\n label,\n labelType = \"help\",\n density,\n className,\n srOnly,\n ...rest\n}) => {\n const hasLabel = errorLabel || helpLabel || label;\n\n const isHelp = labelType === \"help\" || (helpLabel && !errorLabel);\n const isWarning = labelType === \"warning\" || errorLabel;\n const isError = labelType === \"error\";\n const isSuccess = labelType === \"success\";\n\n const componentClassName = hasLabel\n ? clsx(\"jkl-form-support-label\", className, {\n \"jkl-form-support-label--sr-only\": srOnly,\n \"jkl-form-support-label--help\": isHelp,\n \"jkl-form-support-label--error\": isError,\n \"jkl-form-support-label--warning\": isWarning,\n \"jkl-form-support-label--success\": isSuccess,\n })\n : \"jkl-dormant-form-support-label\";\n\n const restProps = hasLabel ? rest : {};\n\n const Icon = isError ? ErrorIcon : isSuccess ? SuccessIcon : WarningIcon;\n\n return (\n <span\n id={id}\n className={componentClassName}\n {...restProps}\n data-density={density}\n >\n <Icon variant=\"small\" className=\"jkl-form-support-label__icon\" />\n <span>{errorLabel || helpLabel || label}</span>\n </span>\n );\n};\n"],"names":["SupportLabel","id","helpLabel","errorLabel","label","labelType","density","className","srOnly","rest","hasLabel","isError","isSuccess","componentClassName","clsx","jsxs","children","jsx","ErrorIcon","SuccessIcon","WarningIcon","variant"],"mappings":"6QAmEO,MAAMA,EAAsC,EAC/CC,GAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,MAAAA,EACAC,UAAAA,EAAY,OACZC,QAAAA,EACAC,UAAAA,EACAC,OAAAA,KACGC,MAEGC,MAAAA,EAAWP,GAAcD,GAAaE,EAItCO,EAAwB,UAAdN,EACVO,EAA0B,YAAdP,EAEZQ,EAAqBH,EACrBI,EAAK,yBAA0BP,EAAW,CACtC,kCAAmCC,EACnC,+BARmB,SAAdH,GAAyBH,IAAcC,EAS5C,gCAAiCQ,EACjC,kCATsB,YAAdN,GAA2BF,EAUnC,kCAAmCS,IAEvC,iCAOF,OAAAG,EAAC,OAAA,CACGd,GAAAA,EACAM,UAAWM,KAPDH,EAAWD,EAAO,CAAC,EAS7B,eAAcH,EAEdU,SAAA,CAAAC,EATKN,EAAUO,EAAYN,EAAYO,EAAcC,EAS/C,CAAAC,QAAQ,QAAQd,UAAU,iCAC/BU,EAAA,OAAA,CAAMD,SAAcb,GAAAD,GAAaE,MACtC"}
1
+ {"version":3,"file":"SupportLabel.js","sources":["../../../../src/components/input-group/SupportLabel.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC, type ReactNode } from \"react\";\nimport { Density } from \"../../core/types.js\";\nimport { ErrorIcon } from \"../icon/icons/ErrorIcon.js\";\nimport { SuccessIcon } from \"../icon/icons/SuccessIcon.js\";\nimport { WarningIcon } from \"../icon/icons/WarningIcon.js\";\n\nexport type SupportLabelType = \"help\" | \"error\" | \"warning\" | \"success\";\n\nexport interface SupportLabelProps {\n /**\n * En ID er påkrevd for å kunne referere til SupportLabel med aria-describedby.\n *\n * @example\n * ```tsx\n * const uid = useId();\n * const supportId = useId();\n * const hasSupportText = helpLabel || errorLabel;\n * const describedBy = hasSupportText ? supportId : undefined;\n *\n * return (\n * <div>\n * <Label standAlone htmlFor={uid}>\n * Velg en tekst\n * </Label>\n * <select\n * id={uid}\n * aria-describedby={describedBy}\n * >\n * <option value=\"e\">Example</option>\n * </select>\n * <SupportLabel\n * id={supportId}\n * label={errorLabel}\n * labelType=\"error\"\n * density={density}\n * />\n * </div>\n * );\n * ```\n */\n id: string;\n /**\n * @deprecated Bruk `label` for å få samme resultat.\n */\n helpLabel?: ReactNode;\n /**\n * @deprecated Bruk `label` og `labelType=\"warning\"` for å få samme resultat.\n */\n errorLabel?: ReactNode;\n label?: ReactNode;\n /**\n * Bestemmer hvilket ikon som skal vises:\n *\n * - \"help\" viser ikke noe ikon\n * - \"warning\" viser WarningIcon, det som tidligere ble vist med `errorLabel`\n * - \"error\" viser ErrorIcon\n * - \"success\" viser SuccessIcon\n *\n * @default \"help\"\n */\n labelType?: SupportLabelType;\n density?: Density;\n className?: string;\n srOnly?: boolean;\n}\n\nexport const SupportLabel: FC<SupportLabelProps> = ({\n id,\n helpLabel,\n errorLabel,\n label,\n labelType = \"help\",\n density,\n className,\n srOnly,\n ...rest\n}) => {\n const hasLabel = errorLabel || helpLabel || label;\n\n const isHelp = labelType === \"help\" || (helpLabel && !errorLabel);\n const isWarning = labelType === \"warning\" || errorLabel;\n const isError = labelType === \"error\";\n const isSuccess = labelType === \"success\";\n\n const componentClassName = hasLabel\n ? clsx(\"jkl-form-support-label\", className, {\n \"jkl-form-support-label--sr-only\": srOnly,\n \"jkl-form-support-label--help\": isHelp,\n \"jkl-form-support-label--error\": isError,\n \"jkl-form-support-label--warning\": isWarning,\n \"jkl-form-support-label--success\": isSuccess,\n })\n : \"jkl-dormant-form-support-label\";\n\n const restProps = hasLabel ? rest : {};\n\n const Icon = isError ? ErrorIcon : isSuccess ? SuccessIcon : WarningIcon;\n\n return (\n <span\n id={id}\n className={componentClassName}\n {...restProps}\n data-density={density}\n >\n <Icon variant=\"small\" className=\"jkl-form-support-label__icon\" />\n <span>{errorLabel || helpLabel || label}</span>\n </span>\n );\n};\n"],"names":["SupportLabel","id","helpLabel","errorLabel","label","labelType","density","className","srOnly","rest","hasLabel","isError","isSuccess","componentClassName","clsx","jsxs","children","jsx","ErrorIcon","SuccessIcon","WarningIcon","variant"],"mappings":"6QAmEO,MAAMA,EAAsC,EAC/CC,GAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,MAAAA,EACAC,UAAAA,EAAY,OACZC,QAAAA,EACAC,UAAAA,EACAC,OAAAA,KACGC,MAEGC,MAAAA,EAAWP,GAAcD,GAAaE,EAItCO,EAAwB,UAAdN,EACVO,EAA0B,YAAdP,EAEZQ,EAAqBH,EACrBI,EAAK,yBAA0BP,EAAW,CACtC,kCAAmCC,EACnC,+BARmB,SAAdH,GAAyBH,IAAcC,EAS5C,gCAAiCQ,EACjC,kCATsB,YAAdN,GAA2BF,EAUnC,kCAAmCS,IAEvC,iCAOF,OAAAG,EAAC,OAAA,CACGd,GAAAA,EACAM,UAAWM,KAPDH,EAAWD,EAAO,GAS5B,eAAcH,EAEdU,SAAA,CAAAC,EATKN,EAAUO,EAAYN,EAAYO,EAAcC,EAS/C,CAAAC,QAAQ,QAAQd,UAAU,iCAC/BU,EAAA,OAAA,CAAMD,SAAcb,GAAAD,GAAaE,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"RadioPanel.js","sources":["../../../../src/components/input-panel/RadioPanel.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ComponentPropsWithRef,\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n} from \"react\";\nimport { BasePanel } from \"./BasePanel.js\";\nimport { context } from \"./radioPanelContext.js\";\n\n// aria-invalid has been deprecated for the \"radio\" role, it should go on the\n// parent radiogroup\nexport type RadioPanelProps = Omit<\n ComponentPropsWithRef<\"input\">,\n \"type\" | \"aria-invalid\"\n> & {\n value: string;\n label: string;\n extraLabel?: React.ReactNode;\n alwaysOpen?: boolean;\n};\n\nexport const RadioPanel = forwardRef(function RadioPanel(\n {\n alwaysOpen = false,\n label,\n extraLabel,\n checked,\n onChange,\n value,\n defaultChecked,\n ...rest\n }: RadioPanelProps,\n ref: ForwardedRef<HTMLInputElement>,\n) {\n const { onValueChange, checkedValue } = useContext(context);\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n if (!onValueChange) {\n throw new Error(\n \"RadioPanel will not work properly when used outside a RadioPanelGroup\",\n );\n }\n onValueChange(value);\n },\n [onChange, onValueChange, value],\n );\n\n useEffect(() => {\n if (defaultChecked) {\n if (!onValueChange) {\n throw new Error(\n \"RadioPanel will not work properly when used outside a RadioPanelGroup\",\n );\n }\n onValueChange(value);\n }\n // We never want to rerun this effect. Changing the default value after the\n // input control is first mounted should not cause any updates\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, []);\n\n const isControlled = typeof checked !== \"undefined\";\n const isChecked = isControlled ? checked : checkedValue === value;\n\n return (\n <BasePanel\n ref={ref}\n type=\"radio\"\n value={value}\n isChecked={isChecked}\n defaultChecked={defaultChecked}\n checked={isControlled ? checked : undefined}\n onChange={handleChange}\n alwaysOpen={alwaysOpen}\n label={label}\n extraLabel={extraLabel}\n {...rest}\n />\n );\n});\n"],"names":["RadioPanel","forwardRef","alwaysOpen","label","extraLabel","checked","onChange","value","defaultChecked","rest","ref","onValueChange","checkedValue","useContext","context","handleChange","useCallback","e","Error","useEffect","isControlled","jsx","BasePanel","type","isChecked"],"mappings":"uNAwBa,MAAAA,EAAaC,GAAW,UAE7BC,WAAAA,GAAa,EACbC,MAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,SAAAA,EACAC,MAAAA,EACAC,eAAAA,KACGC,GAEPC,GAEM,MAAEC,cAAAA,EAAeC,aAAAA,GAAiBC,EAAWC,GAE7CC,EAAeC,GAChBC,IAEG,GADA,MAAAX,GAAAA,EAAWW,IACNN,EACD,MAAM,IAAIO,MACN,yEAGRP,EAAcJ,EAAK,GAEvB,CAACD,EAAUK,EAAeJ,IAG9BY,GAAU,KACN,GAAIX,EAAgB,CAChB,IAAKG,EACD,MAAM,IAAIO,MACN,yEAGRP,EAAcJ,EAAK,IAKxB,IAEGa,MAAAA,SAAsBf,EAAY,IAIpC,OAAAgB,EAACC,EAAA,CACGZ,IAAAA,EACAa,KAAK,QACLhB,MAAAA,EACAiB,UAPUJ,EAAef,EAAUO,IAAiBL,EAQpDC,eAAAA,EACAH,QAASe,EAAef,OAAU,EAClCC,SAAUS,EACVb,WAAAA,EACAC,MAAAA,EACAC,WAAAA,KACIK,GAGhB"}
1
+ {"version":3,"file":"RadioPanel.js","sources":["../../../../src/components/input-panel/RadioPanel.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ComponentPropsWithRef,\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n} from \"react\";\nimport { BasePanel } from \"./BasePanel.js\";\nimport { context } from \"./radioPanelContext.js\";\n\n// aria-invalid has been deprecated for the \"radio\" role, it should go on the\n// parent radiogroup\nexport type RadioPanelProps = Omit<\n ComponentPropsWithRef<\"input\">,\n \"type\" | \"aria-invalid\"\n> & {\n value: string;\n label: string;\n extraLabel?: React.ReactNode;\n alwaysOpen?: boolean;\n};\n\nexport const RadioPanel = forwardRef(function RadioPanel(\n {\n alwaysOpen = false,\n label,\n extraLabel,\n checked,\n onChange,\n value,\n defaultChecked,\n ...rest\n }: RadioPanelProps,\n ref: ForwardedRef<HTMLInputElement>,\n) {\n const { onValueChange, checkedValue } = useContext(context);\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n if (!onValueChange) {\n throw new Error(\n \"RadioPanel will not work properly when used outside a RadioPanelGroup\",\n );\n }\n onValueChange(value);\n },\n [onChange, onValueChange, value],\n );\n\n useEffect(() => {\n if (defaultChecked) {\n if (!onValueChange) {\n throw new Error(\n \"RadioPanel will not work properly when used outside a RadioPanelGroup\",\n );\n }\n onValueChange(value);\n }\n // We never want to rerun this effect. Changing the default value after the\n // input control is first mounted should not cause any updates\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, []);\n\n const isControlled = typeof checked !== \"undefined\";\n const isChecked = isControlled ? checked : checkedValue === value;\n\n return (\n <BasePanel\n ref={ref}\n type=\"radio\"\n value={value}\n isChecked={isChecked}\n defaultChecked={defaultChecked}\n checked={isControlled ? checked : undefined}\n onChange={handleChange}\n alwaysOpen={alwaysOpen}\n label={label}\n extraLabel={extraLabel}\n {...rest}\n />\n );\n});\n"],"names":["RadioPanel","forwardRef","alwaysOpen","label","extraLabel","checked","onChange","value","defaultChecked","rest","ref","onValueChange","checkedValue","useContext","context","handleChange","useCallback","e","Error","useEffect","isControlled","jsx","BasePanel","type","isChecked"],"mappings":"uNAwBa,MAAAA,EAAaC,GAAW,UAE7BC,WAAAA,GAAa,EACbC,MAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,SAAAA,EACAC,MAAAA,EACAC,eAAAA,KACGC,GAEPC,GAEM,MAAEC,cAAAA,EAAeC,aAAAA,GAAiBC,EAAWC,GAE7CC,EAAeC,GAChBC,IAEG,GADA,MAAAX,GAAAA,EAAWW,IACNN,EACD,MAAM,IAAIO,MACN,yEAGRP,EAAcJ,EAAK,GAEvB,CAACD,EAAUK,EAAeJ,IAG9BY,GAAU,KACN,GAAIX,EAAgB,CAChB,IAAKG,EACD,MAAM,IAAIO,MACN,yEAGRP,EAAcJ,EAClB,IAID,IAEGa,MAAAA,SAAsBf,EAAY,IAIpC,OAAAgB,EAACC,EAAA,CACGZ,IAAAA,EACAa,KAAK,QACLhB,MAAAA,EACAiB,UAPUJ,EAAef,EAAUO,IAAiBL,EAQpDC,eAAAA,EACAH,QAASe,EAAef,OAAU,EAClCC,SAAUS,EACVb,WAAAA,EACAC,MAAAA,EACAC,WAAAA,KACIK,GAGhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Loader.js","sources":["../../../../src/components/loader/Loader.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { AriaRole } from \"react\";\nimport { useDelayedRender } from \"./useDelayedRender.js\";\n\nexport type LoaderVariant = \"small\" | \"medium\" | \"large\";\n\nexport interface LoaderProps {\n variant?: LoaderVariant;\n textDescription: string;\n className?: string;\n dataTestAutoId?: string;\n role?: AriaRole;\n inline?: boolean;\n /**\n * Antall millisekunder komponenten vil vente før den rendrer\n * @default 0\n */\n delay?: number;\n}\n\nexport const Loader = ({\n delay = 0,\n variant = \"large\",\n textDescription,\n className,\n dataTestAutoId = \"jkl-loader\",\n inline = false,\n ...rest\n}: LoaderProps): JSX.Element | null => {\n const renderComponent = useDelayedRender(delay);\n\n if (delay && !renderComponent) {\n return null;\n }\n\n const componentClassName = clsx(\"jkl-loader\", className, {\n \"jkl-loader--medium\": variant === \"medium\",\n \"jkl-loader--small\": variant === \"small\",\n \"jkl-loader--inline\": inline,\n });\n\n return (\n <span\n aria-busy=\"true\"\n className={componentClassName}\n data-testautoid={dataTestAutoId}\n data-testid=\"jkl-loader\"\n title={textDescription}\n {...rest}\n >\n <span className=\"jkl-loader__dot jkl-loader__dot--left\" />\n <span className=\"jkl-loader__dot jkl-loader__dot--middle\" />\n <span className=\"jkl-loader__dot jkl-loader__dot--right\" />\n <span className=\"jkl-sr-only\">{textDescription}</span>\n </span>\n );\n};\n"],"names":["Loader","delay","variant","textDescription","className","dataTestAutoId","inline","rest","renderComponent","useDelayedRender","componentClassName","clsx","jsxs","title","children","jsx"],"mappings":"yJAoBO,MAAMA,EAAS,EAClBC,MAAAA,EAAQ,EACRC,QAAAA,EAAU,QACVC,gBAAAA,EACAC,UAAAA,EACAC,eAAAA,EAAiB,aACjBC,OAAAA,GAAS,KACNC,MAEGC,MAAAA,EAAkBC,EAAiBR,GAErC,GAAAA,IAAUO,EACH,OAAA,KAGLE,MAAAA,EAAqBC,EAAK,aAAcP,EAAW,CACrD,qBAAkC,WAAZF,EACtB,oBAAiC,UAAZA,EACrB,qBAAsBI,IAItB,OAAAM,EAAC,OAAA,CACG,YAAU,OACVR,UAAWM,EACX,kBAAiBL,EACjB,cAAY,aACZQ,MAAOV,KACHI,EAEJO,SAAA,CAACC,EAAA,OAAA,CAAKX,UAAU,0CAChBW,EAAC,OAAK,CAAAX,UAAU,4CAChBW,EAAC,OAAK,CAAAX,UAAU,2CACfW,EAAA,OAAA,CAAKX,UAAU,cAAeU,SAAgBX,MACnD"}
1
+ {"version":3,"file":"Loader.js","sources":["../../../../src/components/loader/Loader.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { AriaRole } from \"react\";\nimport { useDelayedRender } from \"./useDelayedRender.js\";\n\nexport type LoaderVariant = \"small\" | \"medium\" | \"large\";\n\nexport interface LoaderProps {\n variant?: LoaderVariant;\n textDescription: string;\n className?: string;\n dataTestAutoId?: string;\n role?: AriaRole;\n inline?: boolean;\n /**\n * Antall millisekunder komponenten vil vente før den rendrer\n * @default 0\n */\n delay?: number;\n}\n\nexport const Loader = ({\n delay = 0,\n variant = \"large\",\n textDescription,\n className,\n dataTestAutoId = \"jkl-loader\",\n inline = false,\n ...rest\n}: LoaderProps): JSX.Element | null => {\n const renderComponent = useDelayedRender(delay);\n\n if (delay && !renderComponent) {\n return null;\n }\n\n const componentClassName = clsx(\"jkl-loader\", className, {\n \"jkl-loader--medium\": variant === \"medium\",\n \"jkl-loader--small\": variant === \"small\",\n \"jkl-loader--inline\": inline,\n });\n\n return (\n <span\n aria-busy=\"true\"\n className={componentClassName}\n data-testautoid={dataTestAutoId}\n data-testid=\"jkl-loader\"\n title={textDescription}\n {...rest}\n >\n <span className=\"jkl-loader__dot jkl-loader__dot--left\" />\n <span className=\"jkl-loader__dot jkl-loader__dot--middle\" />\n <span className=\"jkl-loader__dot jkl-loader__dot--right\" />\n <span className=\"jkl-sr-only\">{textDescription}</span>\n </span>\n );\n};\n"],"names":["Loader","delay","variant","textDescription","className","dataTestAutoId","inline","rest","renderComponent","useDelayedRender","componentClassName","clsx","jsxs","title","children","jsx"],"mappings":"yJAoBO,MAAMA,EAAS,EAClBC,MAAAA,EAAQ,EACRC,QAAAA,EAAU,QACVC,gBAAAA,EACAC,UAAAA,EACAC,eAAAA,EAAiB,aACjBC,OAAAA,GAAS,KACNC,MAEGC,MAAAA,EAAkBC,EAAiBR,GAErC,GAAAA,IAAUO,EACH,OAAA,KAGLE,MAAAA,EAAqBC,EAAK,aAAcP,EAAW,CACrD,qBAAkC,WAAZF,EACtB,oBAAiC,UAAZA,EACrB,qBAAsBI,IAItB,OAAAM,EAAC,OAAA,CACG,YAAU,OACVR,UAAWM,EACX,kBAAiBL,EACjB,cAAY,aACZQ,MAAOV,KACHI,EAEJO,SAAA,CAACC,EAAA,OAAA,CAAKX,UAAU,0CAChBW,EAAC,OAAK,CAAAX,UAAU,4CAChBW,EAAC,OAAK,CAAAX,UAAU,2CACfW,EAAA,OAAA,CAAKX,UAAU,cAAeU,SAAgBX,MAAA"}