@fremtind/jokul 0.71.1 → 1.0.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 (588) hide show
  1. package/README.md +5 -37
  2. package/build/build-stats.html +1 -1
  3. package/build/cjs/components/autosuggest/BaseAutosuggest.cjs +1 -1
  4. package/build/cjs/components/autosuggest/BaseAutosuggest.cjs.map +1 -1
  5. package/build/cjs/components/autosuggest/Menu.cjs +1 -1
  6. package/build/cjs/components/autosuggest/Menu.cjs.map +1 -1
  7. package/build/cjs/components/button/Button.cjs +1 -1
  8. package/build/cjs/components/button/Button.cjs.map +1 -1
  9. package/build/cjs/components/card/index.cjs +1 -1
  10. package/build/cjs/components/card/index.d.cts +1 -4
  11. package/build/cjs/components/card/types.cjs +1 -1
  12. package/build/cjs/components/card/types.cjs.map +1 -1
  13. package/build/cjs/components/card/types.d.cts +0 -51
  14. package/build/cjs/components/checkbox-panel/CheckboxPanel.cjs +1 -1
  15. package/build/cjs/components/checkbox-panel/CheckboxPanel.cjs.map +1 -1
  16. package/build/cjs/components/combobox/Combobox.cjs +1 -1
  17. package/build/cjs/components/combobox/Combobox.cjs.map +1 -1
  18. package/build/cjs/components/combobox/stories/Combobox.stories.cjs +1 -1
  19. package/build/cjs/components/combobox/stories/Combobox.stories.cjs.map +1 -1
  20. package/build/cjs/components/combobox/stories/Combobox.stories.d.cts +1 -0
  21. package/build/cjs/components/cookie-consent/CookieConsent.cjs +1 -1
  22. package/build/cjs/components/cookie-consent/CookieConsent.cjs.map +1 -1
  23. package/build/cjs/components/datepicker/DatePicker.cjs +1 -1
  24. package/build/cjs/components/datepicker/DatePicker.cjs.map +1 -1
  25. package/build/cjs/components/datepicker/internal/Calendar.cjs +1 -1
  26. package/build/cjs/components/datepicker/internal/Calendar.cjs.map +1 -1
  27. package/build/cjs/components/datepicker/internal/utils.cjs +1 -1
  28. package/build/cjs/components/datepicker/internal/utils.cjs.map +1 -1
  29. package/build/cjs/components/datepicker/stories/Datepicker.stories.cjs +1 -1
  30. package/build/cjs/components/datepicker/stories/Datepicker.stories.cjs.map +1 -1
  31. package/build/cjs/components/datepicker/stories/Datepicker.stories.d.cts +13 -0
  32. package/build/cjs/components/description-list/stories/DescriptionList.stories.cjs +1 -1
  33. package/build/cjs/components/description-list/stories/DescriptionList.stories.cjs.map +1 -1
  34. package/build/cjs/components/expander/ExpandablePanel.cjs +1 -1
  35. package/build/cjs/components/expander/ExpandablePanel.cjs.map +1 -1
  36. package/build/cjs/components/expander/ExpandablePanelContent.cjs +1 -1
  37. package/build/cjs/components/expander/ExpandablePanelContent.cjs.map +1 -1
  38. package/build/cjs/components/expander/Expander.cjs +1 -1
  39. package/build/cjs/components/expander/Expander.cjs.map +1 -1
  40. package/build/cjs/components/expander/index.cjs +1 -1
  41. package/build/cjs/components/expander/index.d.cts +0 -1
  42. package/build/cjs/components/expander/stories/{ExpanderPanel.stories.cjs → ExpandablePanel.stories.cjs} +1 -1
  43. package/build/cjs/components/expander/stories/ExpandablePanel.stories.cjs.map +1 -0
  44. package/build/cjs/components/feedback/followup/Followup.cjs +1 -1
  45. package/build/cjs/components/feedback/followup/Followup.cjs.map +1 -1
  46. package/build/cjs/components/feedback/followup/useFollowup.cjs +1 -1
  47. package/build/cjs/components/feedback/followup/useFollowup.cjs.map +1 -1
  48. package/build/cjs/components/feedback/main-question/MainQuestion.cjs +1 -1
  49. package/build/cjs/components/feedback/main-question/MainQuestion.cjs.map +1 -1
  50. package/build/cjs/components/feedback/main-question/useMainQuestion.cjs +1 -1
  51. package/build/cjs/components/feedback/main-question/useMainQuestion.cjs.map +1 -1
  52. package/build/cjs/components/feedback/questions/AddonQuestion.cjs +1 -1
  53. package/build/cjs/components/feedback/questions/AddonQuestion.cjs.map +1 -1
  54. package/build/cjs/components/feedback/questions/CheckboxQuestion.cjs +1 -1
  55. package/build/cjs/components/feedback/questions/CheckboxQuestion.cjs.map +1 -1
  56. package/build/cjs/components/feedback/questions/ContactQuestion.cjs +1 -1
  57. package/build/cjs/components/feedback/questions/ContactQuestion.cjs.map +1 -1
  58. package/build/cjs/components/feedback/questions/RadioQuestion.cjs +1 -1
  59. package/build/cjs/components/feedback/questions/RadioQuestion.cjs.map +1 -1
  60. package/build/cjs/components/feedback/questions/SmileyQuestion.cjs +1 -1
  61. package/build/cjs/components/feedback/questions/SmileyQuestion.cjs.map +1 -1
  62. package/build/cjs/components/feedback/questions/TextQuestion.cjs +1 -1
  63. package/build/cjs/components/feedback/questions/TextQuestion.cjs.map +1 -1
  64. package/build/cjs/components/file/File.cjs.map +1 -1
  65. package/build/cjs/components/file/stories/File.stories.cjs.map +1 -1
  66. package/build/cjs/components/file/stories/File.stories.d.cts +1 -1
  67. package/build/cjs/components/file-input/FileInput.cjs.map +1 -1
  68. package/build/cjs/components/file-input/index.d.cts +1 -1
  69. package/build/cjs/components/file-input/internal/Dropzone.cjs.map +1 -1
  70. package/build/cjs/components/file-input/internal/Input.cjs.map +1 -1
  71. package/build/cjs/components/file-input/internal/fileInputContext.cjs.map +1 -1
  72. package/build/cjs/components/file-input/internal/validateFileInputFiles.cjs +1 -1
  73. package/build/cjs/components/file-input/internal/validateFileInputFiles.cjs.map +1 -1
  74. package/build/cjs/components/file-input/stories/FileInput.stories.cjs.map +1 -1
  75. package/build/cjs/components/icon/stories/Icons.stories.cjs +1 -1
  76. package/build/cjs/components/image/useImageLoadingStatus.cjs +1 -1
  77. package/build/cjs/components/image/useImageLoadingStatus.cjs.map +1 -1
  78. package/build/cjs/components/input-group/InputGroup.cjs +1 -1
  79. package/build/cjs/components/input-group/InputGroup.cjs.map +1 -1
  80. package/build/cjs/components/input-group/stories/FieldGroup.stories.cjs +1 -1
  81. package/build/cjs/components/link/stories/Link.stories.cjs +1 -1
  82. package/build/cjs/components/link/stories/Link.stories.cjs.map +1 -1
  83. package/build/cjs/components/menu/Menu.cjs +1 -1
  84. package/build/cjs/components/menu/Menu.cjs.map +1 -1
  85. package/build/cjs/components/menu/MenuItemCheckbox.cjs +1 -1
  86. package/build/cjs/components/menu/MenuItemCheckbox.cjs.map +1 -1
  87. package/build/cjs/components/message/Message.cjs +1 -1
  88. package/build/cjs/components/message/Message.cjs.map +1 -1
  89. package/build/cjs/components/modal/stories/ModalCloseButton.stories.d.cts +1 -1
  90. package/build/cjs/components/modal/stories/ModalOverlay.stories.cjs +1 -1
  91. package/build/cjs/components/modal/stories/ModalOverlay.stories.cjs.map +1 -1
  92. package/build/cjs/components/popover/Popover.cjs +1 -1
  93. package/build/cjs/components/popover/Popover.cjs.map +1 -1
  94. package/build/cjs/components/radio-panel/RadioPanel.cjs +1 -1
  95. package/build/cjs/components/radio-panel/RadioPanel.cjs.map +1 -1
  96. package/build/cjs/components/screen-reader-only/ScreenReaderOnly.cjs.map +1 -0
  97. package/build/cjs/components/screen-reader-only/ScreenReaderOnly.d.cts +3 -0
  98. package/build/cjs/components/screen-reader-only/index.cjs +2 -0
  99. package/build/cjs/components/screen-reader-only/index.d.cts +2 -0
  100. package/build/cjs/components/screen-reader-only/types.d.cts +4 -0
  101. package/build/cjs/components/select/Select.cjs +1 -1
  102. package/build/cjs/components/select/Select.cjs.map +1 -1
  103. package/build/cjs/components/select/select-utils.cjs +1 -1
  104. package/build/cjs/components/select/select-utils.cjs.map +1 -1
  105. package/build/cjs/components/system-message/SystemMessage.cjs +1 -1
  106. package/build/cjs/components/system-message/SystemMessage.cjs.map +1 -1
  107. package/build/cjs/components/table/TableHeader.cjs +1 -1
  108. package/build/cjs/components/table/TableHeader.cjs.map +1 -1
  109. package/build/cjs/components/table/TableRow.cjs +1 -1
  110. package/build/cjs/components/table/TableRow.cjs.map +1 -1
  111. package/build/cjs/components/table/stories/data.cjs +2 -0
  112. package/build/cjs/components/table/stories/data.cjs.map +1 -0
  113. package/build/cjs/components/table/stories/data.d.cts +8 -0
  114. package/build/cjs/components/table/stories/table.stories.cjs +1 -1
  115. package/build/cjs/components/table/stories/table.stories.cjs.map +1 -1
  116. package/build/cjs/components/table/stories/table.stories.d.cts +10 -1
  117. package/build/cjs/components/table/stories/tableCollapsing.stories.cjs +2 -0
  118. package/build/cjs/components/table/stories/tableCollapsing.stories.cjs.map +1 -0
  119. package/build/cjs/components/table/stories/tableCollapsing.stories.d.cts +16 -0
  120. package/build/cjs/components/table/stories/tableComplex.stories.cjs +2 -0
  121. package/build/cjs/components/table/stories/tableComplex.stories.cjs.map +1 -0
  122. package/build/cjs/components/table/stories/tableComplex.stories.d.cts +21 -0
  123. package/build/cjs/components/table/stories/tableFiltering.stories.cjs +2 -0
  124. package/build/cjs/components/table/stories/tableFiltering.stories.cjs.map +1 -0
  125. package/build/cjs/components/table/stories/tableFiltering.stories.d.cts +21 -0
  126. package/build/cjs/components/table/stories/tablePagination.stories.cjs +2 -0
  127. package/build/cjs/components/table/stories/tablePagination.stories.cjs.map +1 -0
  128. package/build/cjs/components/{accordion/stories/Accordion.stories.d.cts → table/stories/tablePagination.stories.d.cts} +2 -2
  129. package/build/cjs/components/tabs/NavTab.cjs +1 -1
  130. package/build/cjs/components/tabs/NavTab.cjs.map +1 -1
  131. package/build/cjs/components/tabs/NavTabs.cjs +1 -1
  132. package/build/cjs/components/tabs/NavTabs.cjs.map +1 -1
  133. package/build/cjs/components/tabs/TabList.cjs +1 -1
  134. package/build/cjs/components/tabs/TabList.cjs.map +1 -1
  135. package/build/cjs/components/text-area/BaseTextArea.cjs +1 -1
  136. package/build/cjs/components/text-area/BaseTextArea.cjs.map +1 -1
  137. package/build/cjs/components/toast/Toast.cjs +1 -1
  138. package/build/cjs/components/toast/Toast.cjs.map +1 -1
  139. package/build/cjs/components/toast/toastContext.cjs +1 -1
  140. package/build/cjs/components/toast/toastContext.cjs.map +1 -1
  141. package/build/cjs/components/toggle-switch/ToggleSwitch.cjs +1 -1
  142. package/build/cjs/components/toggle-switch/ToggleSwitch.cjs.map +1 -1
  143. package/build/cjs/components/toggle-switch/usePillStyles.cjs +1 -1
  144. package/build/cjs/components/toggle-switch/usePillStyles.cjs.map +1 -1
  145. package/build/cjs/components/tooltip/PopupTip.cjs +1 -1
  146. package/build/cjs/components/tooltip/PopupTip.cjs.map +1 -1
  147. package/build/cjs/components/tooltip/Tooltip.cjs +1 -1
  148. package/build/cjs/components/tooltip/Tooltip.cjs.map +1 -1
  149. package/build/cjs/components/tooltip/TooltipTrigger.cjs +1 -1
  150. package/build/cjs/components/tooltip/TooltipTrigger.cjs.map +1 -1
  151. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeight.cjs +1 -1
  152. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeight.cjs.map +1 -1
  153. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeightBetween.cjs +1 -1
  154. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeightBetween.cjs.map +1 -1
  155. package/build/cjs/hooks/useAnimatedHeight/useAutoAnimateHeight.cjs +1 -1
  156. package/build/cjs/hooks/useAnimatedHeight/useAutoAnimateHeight.cjs.map +1 -1
  157. package/build/cjs/hooks/useAriaLiveRegion/useAriaLiveRegion.cjs +1 -1
  158. package/build/cjs/hooks/useAriaLiveRegion/useAriaLiveRegion.cjs.map +1 -1
  159. package/build/cjs/hooks/useAriaLiveRegion/useAriaLiveRegion.d.cts +1 -1
  160. package/build/cjs/hooks/useClickOutside/useClickOutside.cjs +1 -1
  161. package/build/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
  162. package/build/cjs/hooks/useElementDimensions/useElementDimensions.cjs +1 -1
  163. package/build/cjs/hooks/useElementDimensions/useElementDimensions.cjs.map +1 -1
  164. package/build/cjs/hooks/useFocusOutside/useFocusOutside.cjs +1 -1
  165. package/build/cjs/hooks/useFocusOutside/useFocusOutside.cjs.map +1 -1
  166. package/build/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -1
  167. package/build/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
  168. package/build/cjs/hooks/useKeyListener/useKeyListener.cjs +1 -1
  169. package/build/cjs/hooks/useKeyListener/useKeyListener.cjs.map +1 -1
  170. package/build/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs +1 -1
  171. package/build/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs.map +1 -1
  172. package/build/cjs/hooks/useSwipeGesture/useSwipeGesture.cjs +1 -1
  173. package/build/cjs/hooks/useSwipeGesture/useSwipeGesture.cjs.map +1 -1
  174. package/build/cjs/index.cjs +1 -1
  175. package/build/cjs/index.d.cts +0 -1
  176. package/build/cjs/utilities/formatters/date/formatDate.cjs +1 -1
  177. package/build/cjs/utilities/formatters/date/formatDate.cjs.map +1 -1
  178. package/build/cjs/utilities/formatters/fodselsnummer/formatFodselsnummer.cjs +1 -1
  179. package/build/cjs/utilities/formatters/fodselsnummer/formatFodselsnummer.cjs.map +1 -1
  180. package/build/cjs/utilities/formatters/kontonummer/formatKontonummer.cjs +1 -1
  181. package/build/cjs/utilities/formatters/kontonummer/formatKontonummer.cjs.map +1 -1
  182. package/build/cjs/utilities/formatters/kortnummer/formatKortnummer.cjs +1 -1
  183. package/build/cjs/utilities/formatters/kortnummer/formatKortnummer.cjs.map +1 -1
  184. package/build/cjs/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.cjs +1 -1
  185. package/build/cjs/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.cjs.map +1 -1
  186. package/build/cjs/utilities/formatters/telefonnummer/formatTelefonnummer.cjs +1 -1
  187. package/build/cjs/utilities/formatters/telefonnummer/formatTelefonnummer.cjs.map +1 -1
  188. package/build/cjs/utilities/formatters/util/registerWithMask.cjs +1 -1
  189. package/build/cjs/utilities/formatters/util/registerWithMask.cjs.map +1 -1
  190. package/build/cjs/utilities/formatters/valuta/formatValuta.cjs +1 -1
  191. package/build/cjs/utilities/formatters/valuta/formatValuta.cjs.map +1 -1
  192. package/build/cjs/utilities/tabListener.cjs +1 -1
  193. package/build/cjs/utilities/tabListener.cjs.map +1 -1
  194. package/build/cjs/utilities/validators/hasMinimumWords/hasMinimumWords.cjs +1 -1
  195. package/build/cjs/utilities/validators/hasMinimumWords/hasMinimumWords.cjs.map +1 -1
  196. package/build/es/components/autosuggest/BaseAutosuggest.js +2 -2
  197. package/build/es/components/autosuggest/BaseAutosuggest.js.map +1 -1
  198. package/build/es/components/autosuggest/Menu.js +1 -1
  199. package/build/es/components/autosuggest/Menu.js.map +1 -1
  200. package/build/es/components/button/Button.js +1 -1
  201. package/build/es/components/button/Button.js.map +1 -1
  202. package/build/es/components/card/index.d.ts +1 -4
  203. package/build/es/components/card/index.js +1 -1
  204. package/build/es/components/card/types.d.ts +0 -51
  205. package/build/es/components/card/types.js +1 -1
  206. package/build/es/components/card/types.js.map +1 -1
  207. package/build/es/components/checkbox-panel/CheckboxPanel.js +1 -1
  208. package/build/es/components/checkbox-panel/CheckboxPanel.js.map +1 -1
  209. package/build/es/components/combobox/Combobox.js +1 -1
  210. package/build/es/components/combobox/Combobox.js.map +1 -1
  211. package/build/es/components/combobox/stories/Combobox.stories.d.ts +1 -0
  212. package/build/es/components/combobox/stories/Combobox.stories.js +1 -1
  213. package/build/es/components/combobox/stories/Combobox.stories.js.map +1 -1
  214. package/build/es/components/cookie-consent/CookieConsent.js +1 -1
  215. package/build/es/components/cookie-consent/CookieConsent.js.map +1 -1
  216. package/build/es/components/datepicker/DatePicker.js +1 -1
  217. package/build/es/components/datepicker/DatePicker.js.map +1 -1
  218. package/build/es/components/datepicker/internal/Calendar.js +1 -1
  219. package/build/es/components/datepicker/internal/Calendar.js.map +1 -1
  220. package/build/es/components/datepicker/internal/utils.js +1 -1
  221. package/build/es/components/datepicker/internal/utils.js.map +1 -1
  222. package/build/es/components/datepicker/stories/Datepicker.stories.d.ts +13 -0
  223. package/build/es/components/datepicker/stories/Datepicker.stories.js +1 -1
  224. package/build/es/components/datepicker/stories/Datepicker.stories.js.map +1 -1
  225. package/build/es/components/description-list/stories/DescriptionList.stories.js +1 -1
  226. package/build/es/components/description-list/stories/DescriptionList.stories.js.map +1 -1
  227. package/build/es/components/expander/ExpandablePanel.js +1 -1
  228. package/build/es/components/expander/ExpandablePanel.js.map +1 -1
  229. package/build/es/components/expander/ExpandablePanelContent.js +1 -1
  230. package/build/es/components/expander/ExpandablePanelContent.js.map +1 -1
  231. package/build/es/components/expander/Expander.js +1 -1
  232. package/build/es/components/expander/Expander.js.map +1 -1
  233. package/build/es/components/expander/index.d.ts +0 -1
  234. package/build/es/components/expander/index.js +1 -1
  235. package/build/es/components/expander/stories/{ExpanderPanel.stories.js → ExpandablePanel.stories.js} +1 -1
  236. package/build/es/components/expander/stories/ExpandablePanel.stories.js.map +1 -0
  237. package/build/es/components/feedback/followup/Followup.js +1 -1
  238. package/build/es/components/feedback/followup/Followup.js.map +1 -1
  239. package/build/es/components/feedback/followup/useFollowup.js +1 -1
  240. package/build/es/components/feedback/followup/useFollowup.js.map +1 -1
  241. package/build/es/components/feedback/main-question/MainQuestion.js +1 -1
  242. package/build/es/components/feedback/main-question/MainQuestion.js.map +1 -1
  243. package/build/es/components/feedback/main-question/useMainQuestion.js +1 -1
  244. package/build/es/components/feedback/main-question/useMainQuestion.js.map +1 -1
  245. package/build/es/components/feedback/questions/AddonQuestion.js +1 -1
  246. package/build/es/components/feedback/questions/AddonQuestion.js.map +1 -1
  247. package/build/es/components/feedback/questions/CheckboxQuestion.js +1 -1
  248. package/build/es/components/feedback/questions/CheckboxQuestion.js.map +1 -1
  249. package/build/es/components/feedback/questions/ContactQuestion.js +1 -1
  250. package/build/es/components/feedback/questions/ContactQuestion.js.map +1 -1
  251. package/build/es/components/feedback/questions/RadioQuestion.js +1 -1
  252. package/build/es/components/feedback/questions/RadioQuestion.js.map +1 -1
  253. package/build/es/components/feedback/questions/SmileyQuestion.js +1 -1
  254. package/build/es/components/feedback/questions/SmileyQuestion.js.map +1 -1
  255. package/build/es/components/feedback/questions/TextQuestion.js +1 -1
  256. package/build/es/components/feedback/questions/TextQuestion.js.map +1 -1
  257. package/build/es/components/file/File.js.map +1 -1
  258. package/build/es/components/file/stories/File.stories.d.ts +1 -1
  259. package/build/es/components/file/stories/File.stories.js.map +1 -1
  260. package/build/es/components/file-input/FileInput.js.map +1 -1
  261. package/build/es/components/file-input/index.d.ts +1 -1
  262. package/build/es/components/file-input/internal/Dropzone.js.map +1 -1
  263. package/build/es/components/file-input/internal/Input.js.map +1 -1
  264. package/build/es/components/file-input/internal/fileInputContext.js.map +1 -1
  265. package/build/es/components/file-input/internal/validateFileInputFiles.js +1 -1
  266. package/build/es/components/file-input/internal/validateFileInputFiles.js.map +1 -1
  267. package/build/es/components/file-input/stories/FileInput.stories.js.map +1 -1
  268. package/build/es/components/icon/stories/Icons.stories.js +1 -1
  269. package/build/es/components/image/useImageLoadingStatus.js +1 -1
  270. package/build/es/components/image/useImageLoadingStatus.js.map +1 -1
  271. package/build/es/components/input-group/InputGroup.js +1 -1
  272. package/build/es/components/input-group/InputGroup.js.map +1 -1
  273. package/build/es/components/link/stories/Link.stories.js +1 -1
  274. package/build/es/components/link/stories/Link.stories.js.map +1 -1
  275. package/build/es/components/loader/stories/Skeleton.stories.js +1 -1
  276. package/build/es/components/menu/Menu.js +1 -1
  277. package/build/es/components/menu/Menu.js.map +1 -1
  278. package/build/es/components/menu/MenuItemCheckbox.js +1 -1
  279. package/build/es/components/menu/MenuItemCheckbox.js.map +1 -1
  280. package/build/es/components/message/Message.js +1 -1
  281. package/build/es/components/message/Message.js.map +1 -1
  282. package/build/es/components/modal/stories/ModalCloseButton.stories.d.ts +1 -1
  283. package/build/es/components/modal/stories/ModalOverlay.stories.js +1 -1
  284. package/build/es/components/modal/stories/ModalOverlay.stories.js.map +1 -1
  285. package/build/es/components/popover/Popover.js +1 -1
  286. package/build/es/components/popover/Popover.js.map +1 -1
  287. package/build/es/components/radio-panel/RadioPanel.js +1 -1
  288. package/build/es/components/radio-panel/RadioPanel.js.map +1 -1
  289. package/build/es/components/screen-reader-only/ScreenReaderOnly.d.ts +3 -0
  290. package/build/es/components/screen-reader-only/ScreenReaderOnly.js.map +1 -0
  291. package/build/es/components/screen-reader-only/index.d.ts +2 -0
  292. package/build/es/components/screen-reader-only/index.js +2 -0
  293. package/build/es/components/screen-reader-only/types.d.ts +4 -0
  294. package/build/es/components/select/Select.js +1 -1
  295. package/build/es/components/select/Select.js.map +1 -1
  296. package/build/es/components/select/select-utils.js +1 -1
  297. package/build/es/components/select/select-utils.js.map +1 -1
  298. package/build/es/components/system-message/SystemMessage.js +1 -1
  299. package/build/es/components/system-message/SystemMessage.js.map +1 -1
  300. package/build/es/components/table/TableHeader.js +1 -1
  301. package/build/es/components/table/TableHeader.js.map +1 -1
  302. package/build/es/components/table/TableRow.js +1 -1
  303. package/build/es/components/table/TableRow.js.map +1 -1
  304. package/build/es/components/table/stories/data.d.ts +8 -0
  305. package/build/es/components/table/stories/data.js +2 -0
  306. package/build/es/components/table/stories/data.js.map +1 -0
  307. package/build/es/components/table/stories/table.stories.d.ts +10 -1
  308. package/build/es/components/table/stories/table.stories.js +1 -1
  309. package/build/es/components/table/stories/table.stories.js.map +1 -1
  310. package/build/es/components/table/stories/tableCollapsing.stories.d.ts +16 -0
  311. package/build/es/components/table/stories/tableCollapsing.stories.js +2 -0
  312. package/build/es/components/table/stories/tableCollapsing.stories.js.map +1 -0
  313. package/build/es/components/table/stories/tableComplex.stories.d.ts +21 -0
  314. package/build/es/components/table/stories/tableComplex.stories.js +2 -0
  315. package/build/es/components/table/stories/tableComplex.stories.js.map +1 -0
  316. package/build/es/components/table/stories/tableFiltering.stories.d.ts +21 -0
  317. package/build/es/components/table/stories/tableFiltering.stories.js +2 -0
  318. package/build/es/components/table/stories/tableFiltering.stories.js.map +1 -0
  319. package/build/{cjs/components/accordion/stories/AccordionItem.stories.d.cts → es/components/table/stories/tablePagination.stories.d.ts} +2 -2
  320. package/build/es/components/table/stories/tablePagination.stories.js +2 -0
  321. package/build/es/components/table/stories/tablePagination.stories.js.map +1 -0
  322. package/build/es/components/tabs/NavTab.js +1 -1
  323. package/build/es/components/tabs/NavTab.js.map +1 -1
  324. package/build/es/components/tabs/NavTabs.js +1 -1
  325. package/build/es/components/tabs/NavTabs.js.map +1 -1
  326. package/build/es/components/tabs/TabList.js +1 -1
  327. package/build/es/components/tabs/TabList.js.map +1 -1
  328. package/build/es/components/text-area/BaseTextArea.js +1 -1
  329. package/build/es/components/text-area/BaseTextArea.js.map +1 -1
  330. package/build/es/components/toast/Toast.js +1 -1
  331. package/build/es/components/toast/Toast.js.map +1 -1
  332. package/build/es/components/toast/toastContext.js +1 -1
  333. package/build/es/components/toast/toastContext.js.map +1 -1
  334. package/build/es/components/toggle-switch/ToggleSwitch.js +1 -1
  335. package/build/es/components/toggle-switch/ToggleSwitch.js.map +1 -1
  336. package/build/es/components/toggle-switch/usePillStyles.js +1 -1
  337. package/build/es/components/toggle-switch/usePillStyles.js.map +1 -1
  338. package/build/es/components/tooltip/PopupTip.js +1 -1
  339. package/build/es/components/tooltip/PopupTip.js.map +1 -1
  340. package/build/es/components/tooltip/Tooltip.js +1 -1
  341. package/build/es/components/tooltip/Tooltip.js.map +1 -1
  342. package/build/es/components/tooltip/TooltipTrigger.js +1 -1
  343. package/build/es/components/tooltip/TooltipTrigger.js.map +1 -1
  344. package/build/es/hooks/useAnimatedHeight/useAnimatedHeight.js +1 -1
  345. package/build/es/hooks/useAnimatedHeight/useAnimatedHeight.js.map +1 -1
  346. package/build/es/hooks/useAnimatedHeight/useAnimatedHeightBetween.js +1 -1
  347. package/build/es/hooks/useAnimatedHeight/useAnimatedHeightBetween.js.map +1 -1
  348. package/build/es/hooks/useAnimatedHeight/useAutoAnimateHeight.js +1 -1
  349. package/build/es/hooks/useAnimatedHeight/useAutoAnimateHeight.js.map +1 -1
  350. package/build/es/hooks/useAriaLiveRegion/useAriaLiveRegion.d.ts +1 -1
  351. package/build/es/hooks/useAriaLiveRegion/useAriaLiveRegion.js +1 -1
  352. package/build/es/hooks/useAriaLiveRegion/useAriaLiveRegion.js.map +1 -1
  353. package/build/es/hooks/useClickOutside/useClickOutside.js +1 -1
  354. package/build/es/hooks/useClickOutside/useClickOutside.js.map +1 -1
  355. package/build/es/hooks/useElementDimensions/useElementDimensions.js +1 -1
  356. package/build/es/hooks/useElementDimensions/useElementDimensions.js.map +1 -1
  357. package/build/es/hooks/useFocusOutside/useFocusOutside.js +1 -1
  358. package/build/es/hooks/useFocusOutside/useFocusOutside.js.map +1 -1
  359. package/build/es/hooks/useIntersectionObserver/useIntersectionObserver.js +1 -1
  360. package/build/es/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -1
  361. package/build/es/hooks/useKeyListener/useKeyListener.js +1 -1
  362. package/build/es/hooks/useKeyListener/useKeyListener.js.map +1 -1
  363. package/build/es/hooks/useScrollIntoView/useScrollIntoView.js +1 -1
  364. package/build/es/hooks/useScrollIntoView/useScrollIntoView.js.map +1 -1
  365. package/build/es/hooks/useSwipeGesture/useSwipeGesture.js +1 -1
  366. package/build/es/hooks/useSwipeGesture/useSwipeGesture.js.map +1 -1
  367. package/build/es/index.d.ts +0 -1
  368. package/build/es/index.js +1 -1
  369. package/build/es/utilities/formatters/date/formatDate.js +1 -1
  370. package/build/es/utilities/formatters/date/formatDate.js.map +1 -1
  371. package/build/es/utilities/formatters/fodselsnummer/formatFodselsnummer.js +1 -1
  372. package/build/es/utilities/formatters/fodselsnummer/formatFodselsnummer.js.map +1 -1
  373. package/build/es/utilities/formatters/kontonummer/formatKontonummer.js +1 -1
  374. package/build/es/utilities/formatters/kontonummer/formatKontonummer.js.map +1 -1
  375. package/build/es/utilities/formatters/kortnummer/formatKortnummer.js +1 -1
  376. package/build/es/utilities/formatters/kortnummer/formatKortnummer.js.map +1 -1
  377. package/build/es/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.js +1 -1
  378. package/build/es/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.js.map +1 -1
  379. package/build/es/utilities/formatters/telefonnummer/formatTelefonnummer.js +1 -1
  380. package/build/es/utilities/formatters/telefonnummer/formatTelefonnummer.js.map +1 -1
  381. package/build/es/utilities/formatters/util/registerWithMask.js +1 -1
  382. package/build/es/utilities/formatters/util/registerWithMask.js.map +1 -1
  383. package/build/es/utilities/formatters/valuta/formatValuta.js +1 -1
  384. package/build/es/utilities/formatters/valuta/formatValuta.js.map +1 -1
  385. package/build/es/utilities/tabListener.js +1 -1
  386. package/build/es/utilities/tabListener.js.map +1 -1
  387. package/build/es/utilities/validators/hasMinimumWords/hasMinimumWords.js +1 -1
  388. package/build/es/utilities/validators/hasMinimumWords/hasMinimumWords.js.map +1 -1
  389. package/build/jokul.css +1 -1
  390. package/build/paginated-table-data-VQZB3_Aj.cjs +2 -0
  391. package/build/paginated-table-data-VQZB3_Aj.cjs.map +1 -0
  392. package/build/paginated-table-data-ZMeh4d0Y.js +2 -0
  393. package/build/paginated-table-data-ZMeh4d0Y.js.map +1 -0
  394. package/package.json +61 -81
  395. package/styles/components/autosuggest/autosuggest.scss +4 -4
  396. package/styles/components/card/card.css +0 -248
  397. package/styles/components/card/card.min.css +1 -1
  398. package/styles/components/card/card.scss +0 -3
  399. package/styles/components/checkbox/checkbox.css +4 -4
  400. package/styles/components/checkbox/checkbox.min.css +1 -1
  401. package/styles/components/checkbox-panel/checkbox-panel.css +2 -2
  402. package/styles/components/checkbox-panel/checkbox-panel.min.css +1 -1
  403. package/styles/components/chip/chip.css +9 -1
  404. package/styles/components/chip/chip.min.css +1 -1
  405. package/styles/components/chip/chip.scss +8 -1
  406. package/styles/components/combobox/combobox.css +17 -19
  407. package/styles/components/combobox/combobox.min.css +1 -1
  408. package/styles/components/combobox/combobox.scss +18 -18
  409. package/styles/components/countdown/countdown.css +2 -2
  410. package/styles/components/countdown/countdown.min.css +1 -1
  411. package/styles/components/datepicker/_index.scss +1 -0
  412. package/styles/components/description-list/description-list.scss +7 -7
  413. package/styles/components/expander/_index.scss +0 -1
  414. package/styles/components/feedback/feedback.css +2 -2
  415. package/styles/components/feedback/feedback.min.css +1 -1
  416. package/styles/components/feedback/feedback.scss +4 -3
  417. package/styles/components/file-input/file-input.css +13 -14
  418. package/styles/components/file-input/file-input.min.css +1 -1
  419. package/styles/components/input-group/_labels.scss +21 -21
  420. package/styles/components/input-group/input-group.css +2 -2
  421. package/styles/components/input-group/input-group.min.css +1 -1
  422. package/styles/components/link/link.css +2 -3
  423. package/styles/components/link/link.min.css +1 -1
  424. package/styles/components/link/link.scss +3 -2
  425. package/styles/components/loader/loader.css +6 -6
  426. package/styles/components/loader/loader.min.css +1 -1
  427. package/styles/components/loader/skeleton-loader.css +5 -5
  428. package/styles/components/loader/skeleton-loader.min.css +1 -1
  429. package/styles/components/loader/skeleton-loader.scss +10 -10
  430. package/styles/components/menu/menu.css +5 -5
  431. package/styles/components/menu/menu.min.css +1 -1
  432. package/styles/components/menu/menu.scss +3 -3
  433. package/styles/components/message/message.css +2 -2
  434. package/styles/components/message/message.min.css +1 -1
  435. package/styles/components/progress-bar/progress-bar.css +1 -1
  436. package/styles/components/progress-bar/progress-bar.min.css +1 -1
  437. package/styles/components/radio-button/radio-button.css +4 -3
  438. package/styles/components/radio-button/radio-button.min.css +1 -1
  439. package/styles/components/radio-button/radio-button.scss +18 -19
  440. package/styles/components/radio-panel/radio-panel.css +2 -2
  441. package/styles/components/radio-panel/radio-panel.min.css +1 -1
  442. package/styles/components/summary-table/summary-table.scss +3 -3
  443. package/styles/components/system-message/system-message.css +2 -2
  444. package/styles/components/system-message/system-message.min.css +1 -1
  445. package/styles/components/system-message/system-message.scss +8 -8
  446. package/styles/components/table/_table-cell.scss +4 -4
  447. package/styles/components/table/_table-header.scss +4 -2
  448. package/styles/components/table/_table-row.scss +13 -12
  449. package/styles/components/table/table.css +13 -11
  450. package/styles/components/text-area/text-area.css +6 -4
  451. package/styles/components/text-area/text-area.min.css +5 -1
  452. package/styles/components/text-input/text-input.css +6 -4
  453. package/styles/components/text-input/text-input.min.css +5 -1
  454. package/styles/components/toast/toast.css +4 -4
  455. package/styles/components/toast/toast.min.css +1 -1
  456. package/styles/components/toggle-switch/_toggle-slider.scss +2 -2
  457. package/styles/core/core.css +0 -160
  458. package/styles/core/core.min.css +1 -1
  459. package/styles/core/jkl/_spacing.scss +1 -62
  460. package/styles/core/jkl/_typography.scss +21 -91
  461. package/styles/shared/input/shared-input-styles.css +6 -4
  462. package/styles/shared/input/shared-input-styles.min.css +5 -1
  463. package/styles/shared/input/shared-input-styles.scss +15 -11
  464. package/styles/styles.css +265 -766
  465. package/styles/styles.min.css +5 -7
  466. package/styles/styles.scss +0 -1
  467. package/build/cjs/components/ScreenReaderOnly.cjs.map +0 -1
  468. package/build/cjs/components/ScreenReaderOnly.d.cts +0 -6
  469. package/build/cjs/components/accordion/Accordion.cjs +0 -2
  470. package/build/cjs/components/accordion/Accordion.cjs.map +0 -1
  471. package/build/cjs/components/accordion/Accordion.d.cts +0 -7
  472. package/build/cjs/components/accordion/AccordionItem.cjs +0 -2
  473. package/build/cjs/components/accordion/AccordionItem.cjs.map +0 -1
  474. package/build/cjs/components/accordion/AccordionItem.d.cts +0 -7
  475. package/build/cjs/components/accordion/documentation/AccordionDocs.cjs +0 -2
  476. package/build/cjs/components/accordion/documentation/AccordionDocs.cjs.map +0 -1
  477. package/build/cjs/components/accordion/documentation/AccordionDocs.d.cts +0 -2
  478. package/build/cjs/components/accordion/index.cjs +0 -2
  479. package/build/cjs/components/accordion/index.d.cts +0 -3
  480. package/build/cjs/components/accordion/stories/Accordion.stories.cjs +0 -2
  481. package/build/cjs/components/accordion/stories/Accordion.stories.cjs.map +0 -1
  482. package/build/cjs/components/accordion/stories/AccordionItem.stories.cjs +0 -2
  483. package/build/cjs/components/accordion/stories/AccordionItem.stories.cjs.map +0 -1
  484. package/build/cjs/components/accordion/types.d.cts +0 -13
  485. package/build/cjs/components/accordion/vite-env.d.cjs +0 -2
  486. package/build/cjs/components/accordion/vite-env.d.cjs.map +0 -1
  487. package/build/cjs/components/card/InfoCard.cjs +0 -2
  488. package/build/cjs/components/card/InfoCard.cjs.map +0 -1
  489. package/build/cjs/components/card/InfoCard.d.cts +0 -13
  490. package/build/cjs/components/card/NavCard.cjs +0 -2
  491. package/build/cjs/components/card/NavCard.cjs.map +0 -1
  492. package/build/cjs/components/card/NavCard.d.cts +0 -26
  493. package/build/cjs/components/card/TaskCard.cjs +0 -2
  494. package/build/cjs/components/card/TaskCard.cjs.map +0 -1
  495. package/build/cjs/components/card/TaskCard.d.cts +0 -23
  496. package/build/cjs/components/card/development/examples/InfoCardExample.d.cts +0 -3
  497. package/build/cjs/components/card/development/examples/NavCardExample.d.cts +0 -3
  498. package/build/cjs/components/card/development/examples/TaskCardExample.d.cts +0 -3
  499. package/build/cjs/components/card/development/examples/TopExample.d.cts +0 -3
  500. package/build/cjs/components/card/development/examples/cardExampleProps.d.cts +0 -13
  501. package/build/cjs/components/card/utils.cjs +0 -2
  502. package/build/cjs/components/card/utils.cjs.map +0 -1
  503. package/build/cjs/components/card/utils.d.cts +0 -3
  504. package/build/cjs/components/expander/deprecated/ExpandSection.cjs +0 -2
  505. package/build/cjs/components/expander/deprecated/ExpandSection.cjs.map +0 -1
  506. package/build/cjs/components/expander/deprecated/ExpandSection.d.cts +0 -26
  507. package/build/cjs/components/expander/deprecated/Expander.cjs +0 -2
  508. package/build/cjs/components/expander/deprecated/Expander.cjs.map +0 -1
  509. package/build/cjs/components/expander/deprecated/Expander.d.cts +0 -27
  510. package/build/cjs/components/expander/stories/ExpanderPanel.stories.cjs.map +0 -1
  511. package/build/cjs/components/index.cjs +0 -2
  512. package/build/cjs/components/index.cjs.map +0 -1
  513. package/build/cjs/components/index.d.cts +0 -47
  514. package/build/es/components/ScreenReaderOnly.d.ts +0 -6
  515. package/build/es/components/ScreenReaderOnly.js.map +0 -1
  516. package/build/es/components/accordion/Accordion.d.ts +0 -7
  517. package/build/es/components/accordion/Accordion.js +0 -2
  518. package/build/es/components/accordion/Accordion.js.map +0 -1
  519. package/build/es/components/accordion/AccordionItem.d.ts +0 -7
  520. package/build/es/components/accordion/AccordionItem.js +0 -2
  521. package/build/es/components/accordion/AccordionItem.js.map +0 -1
  522. package/build/es/components/accordion/documentation/AccordionDocs.d.ts +0 -2
  523. package/build/es/components/accordion/documentation/AccordionDocs.js +0 -2
  524. package/build/es/components/accordion/documentation/AccordionDocs.js.map +0 -1
  525. package/build/es/components/accordion/index.d.ts +0 -3
  526. package/build/es/components/accordion/index.js +0 -2
  527. package/build/es/components/accordion/stories/Accordion.stories.d.ts +0 -13
  528. package/build/es/components/accordion/stories/Accordion.stories.js +0 -2
  529. package/build/es/components/accordion/stories/Accordion.stories.js.map +0 -1
  530. package/build/es/components/accordion/stories/AccordionItem.stories.d.ts +0 -13
  531. package/build/es/components/accordion/stories/AccordionItem.stories.js +0 -2
  532. package/build/es/components/accordion/stories/AccordionItem.stories.js.map +0 -1
  533. package/build/es/components/accordion/types.d.ts +0 -13
  534. package/build/es/components/accordion/vite-env.d.js +0 -2
  535. package/build/es/components/accordion/vite-env.d.js.map +0 -1
  536. package/build/es/components/card/InfoCard.d.ts +0 -13
  537. package/build/es/components/card/InfoCard.js +0 -2
  538. package/build/es/components/card/InfoCard.js.map +0 -1
  539. package/build/es/components/card/NavCard.d.ts +0 -26
  540. package/build/es/components/card/NavCard.js +0 -2
  541. package/build/es/components/card/NavCard.js.map +0 -1
  542. package/build/es/components/card/TaskCard.d.ts +0 -23
  543. package/build/es/components/card/TaskCard.js +0 -2
  544. package/build/es/components/card/TaskCard.js.map +0 -1
  545. package/build/es/components/card/development/examples/InfoCardExample.d.ts +0 -3
  546. package/build/es/components/card/development/examples/NavCardExample.d.ts +0 -3
  547. package/build/es/components/card/development/examples/TaskCardExample.d.ts +0 -3
  548. package/build/es/components/card/development/examples/TopExample.d.ts +0 -3
  549. package/build/es/components/card/development/examples/cardExampleProps.d.ts +0 -13
  550. package/build/es/components/card/utils.d.ts +0 -3
  551. package/build/es/components/card/utils.js +0 -2
  552. package/build/es/components/card/utils.js.map +0 -1
  553. package/build/es/components/expander/deprecated/ExpandSection.d.ts +0 -26
  554. package/build/es/components/expander/deprecated/ExpandSection.js +0 -2
  555. package/build/es/components/expander/deprecated/ExpandSection.js.map +0 -1
  556. package/build/es/components/expander/deprecated/Expander.d.ts +0 -27
  557. package/build/es/components/expander/deprecated/Expander.js +0 -2
  558. package/build/es/components/expander/deprecated/Expander.js.map +0 -1
  559. package/build/es/components/expander/stories/ExpanderPanel.stories.js.map +0 -1
  560. package/build/es/components/index.d.ts +0 -47
  561. package/build/es/components/index.js +0 -2
  562. package/build/es/components/index.js.map +0 -1
  563. package/styles/components/accordion/_index.scss +0 -2
  564. package/styles/components/accordion/accordion.css +0 -189
  565. package/styles/components/accordion/accordion.min.css +0 -7
  566. package/styles/components/accordion/accordion.scss +0 -168
  567. package/styles/components/card/_info-card.scss +0 -42
  568. package/styles/components/card/_nav-card.scss +0 -119
  569. package/styles/components/card/_task-card.scss +0 -55
  570. package/styles/components/card/development/info-card-example.css +0 -26
  571. package/styles/components/card/development/info-card-example.min.css +0 -1
  572. package/styles/components/card/development/info-card-example.scss +0 -14
  573. package/styles/components/card/development/task-card-example.css +0 -9
  574. package/styles/components/card/development/task-card-example.min.css +0 -1
  575. package/styles/components/card/development/task-card-example.scss +0 -8
  576. package/styles/components/expander/deprecated/expander.css +0 -82
  577. package/styles/components/expander/deprecated/expander.min.css +0 -1
  578. package/styles/components/expander/deprecated/expander.scss +0 -87
  579. /package/build/cjs/components/expander/stories/{ExpanderPanel.stories.d.cts → ExpandablePanel.stories.d.cts} +0 -0
  580. /package/build/cjs/components/{ScreenReaderOnly.cjs → screen-reader-only/ScreenReaderOnly.cjs} +0 -0
  581. /package/build/cjs/components/{accordion → screen-reader-only}/index.cjs.map +0 -0
  582. /package/build/cjs/components/{accordion → screen-reader-only}/types.cjs +0 -0
  583. /package/build/cjs/components/{accordion → screen-reader-only}/types.cjs.map +0 -0
  584. /package/build/es/components/expander/stories/{ExpanderPanel.stories.d.ts → ExpandablePanel.stories.d.ts} +0 -0
  585. /package/build/es/components/{ScreenReaderOnly.js → screen-reader-only/ScreenReaderOnly.js} +0 -0
  586. /package/build/es/components/{accordion → screen-reader-only}/index.js.map +0 -0
  587. /package/build/es/components/{accordion → screen-reader-only}/types.js +0 -0
  588. /package/build/es/components/{accordion → screen-reader-only}/types.js.map +0 -0
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("../../../clsx-E3yX_9sL.cjs"),t=require("react"),a=require("./ExpandablePanelContent.cjs"),r=require("./context.cjs"),s=Object.assign(t.forwardRef((function(a,s){const{children:l,as:i="details",variant:o="fill",open:d,defaultOpen:c,onOpenChange:u,className:p,...x}=a,[j,v]=t.useState(c||!1),[f,g]=t.useState(!1),[b,E]=t.useState(0),h=t.useRef();t.useImperativeHandle(s,(()=>h.current),[]);const m=i,S=typeof d<"u",k=S?d:j;return t.useEffect((()=>{const e=e=>{v("open"===e.newState)},n=h.current;return null==n||n.addEventListener("toggle",e),()=>null==n?void 0:n.removeEventListener("toggle",e)}),[]),e.jsxs("div",{className:"jkl-expandable__wrapper",children:[e.jsx("div",{inert:"true",className:"jkl-expandable__focus-container",style:{height:b}}),e.jsx(m,{ref:h,"data-testid":"jkl-expand-section",className:n.clsx("jkl-expandable",`jkl-expandable--${o}`,p),open:"details"===i?k||f:void 0,"data-visible-content":k||f,...x,children:e.jsx(r.ExpanderContext.Provider,{value:{open:k,onToggle:()=>{S||v((e=>(null==u||u(!e),!e)))},onTransitionEnd:g,onTransitionStart:e=>{e&&g(!0)},setExpanderHeight:E},children:l})})]})})),{Content:a.ExpandablePanelContent});exports.ExpandablePanel=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../../clsx-E3yX_9sL.cjs"),n=require("react"),a=require("./ExpandablePanelContent.cjs"),r=require("./context.cjs"),s=Object.assign(n.forwardRef((function(a,s){const{children:l,as:i="details",variant:o="fill",open:c,defaultOpen:d,onOpenChange:u,className:p,...x}=a,[j,f]=n.useState(d||!1),[b,g]=n.useState(!1),[v,E]=n.useState(0),h=n.useRef();n.useImperativeHandle(s,(()=>h.current),[]);const m=i,S=typeof c<"u",k=S?c:j;return n.useEffect((()=>{const e=e=>{f("open"===e.newState)},t=h.current;return t?.addEventListener("toggle",e),()=>t?.removeEventListener("toggle",e)}),[]),e.jsxs("div",{className:"jkl-expandable__wrapper",children:[e.jsx("div",{ref:e=>e?.setAttribute("inert","true"),className:"jkl-expandable__focus-container",style:{height:v}}),e.jsx(m,{ref:h,"data-testid":"jkl-expand-section",className:t.clsx("jkl-expandable",`jkl-expandable--${o}`,p),open:"details"===i?k||b:void 0,"data-visible-content":k||b,...x,children:e.jsx(r.ExpanderContext.Provider,{value:{open:k,onToggle:()=>{S||f((e=>(u?.(!e),!e)))},onTransitionEnd:g,onTransitionStart:e=>{e&&g(!0)},setExpanderHeight:E},children:l})})]})})),{Content:a.ExpandablePanelContent});exports.ExpandablePanel=s;
2
2
  //# sourceMappingURL=ExpandablePanel.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpandablePanel.cjs","sources":["../../../../src/components/expander/ExpandablePanel.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport type { PolymorphicRef } from \"../../utilities/polymorphism/polymorphism.js\";\nimport { ExpandablePanelContent } from \"./ExpandablePanelContent.js\";\nimport { ExpanderContext } from \"./context.js\";\nimport type {\n ExpandablePanelComponent,\n ExpandablePanelProps,\n} from \"./types.js\";\n\nexport const ExpandablePanel = Object.assign(\n React.forwardRef(function ExpandablePanel<\n ElementType extends React.ElementType = \"details\",\n >(\n props: ExpandablePanelProps<ElementType>,\n ref?: PolymorphicRef<ElementType>,\n ) {\n const {\n children,\n as = \"details\",\n variant = \"fill\",\n open: controlledOpen,\n defaultOpen,\n onOpenChange,\n className,\n ...rest\n } = props;\n\n const [uncontrolledOpen, setUncontrolledOpen] = useState(\n defaultOpen || false,\n );\n const [contentIsVisible, setContentIsVisible] = useState(false);\n const [expanderHeight, setExpanderHeight] = useState(0);\n\n const internalRef = useRef<HTMLDetailsElement>();\n useImperativeHandle(ref, () => internalRef.current, []);\n\n const El = as;\n const isControlled = typeof controlledOpen !== \"undefined\";\n const isOpen = isControlled ? controlledOpen : uncontrolledOpen;\n\n const setVisibleIfOpening = (isOpening: boolean) => {\n if (isOpening) {\n setContentIsVisible(true);\n }\n };\n\n const syncUncontrolledState = () => {\n if (isControlled) {\n return;\n }\n setUncontrolledOpen((previousValue) => {\n onOpenChange?.(!previousValue);\n return !previousValue;\n });\n };\n\n useEffect(() => {\n const callback = (e: ToggleEvent & { newState: string }) => {\n setUncontrolledOpen(e.newState === \"open\");\n };\n\n const element = internalRef.current;\n\n element?.addEventListener(\"toggle\", callback as EventListener);\n\n return () =>\n element?.removeEventListener(\n \"toggle\",\n callback as EventListener,\n );\n }, []);\n\n return (\n <div className=\"jkl-expandable__wrapper\">\n <div\n // React typings don't include inert for some reason,\n // but destructuring lets us calm down the TS compiler\n {...{ inert: \"true\" }}\n className=\"jkl-expandable__focus-container\"\n style={{ height: expanderHeight }}\n />\n <El\n ref={internalRef}\n data-testid={\"jkl-expand-section\"}\n className={clsx(\n \"jkl-expandable\",\n `jkl-expandable--${variant}`,\n className,\n )}\n open={\n /* for the animation to work in Safari we must ensure that\n * the element is open *before* the transition starts */\n as === \"details\"\n ? isOpen || contentIsVisible\n : undefined\n }\n /* this attribute is used for styling purposes */\n data-visible-content={isOpen || contentIsVisible}\n {...rest}\n >\n <ExpanderContext.Provider\n value={{\n open: isOpen,\n onToggle: syncUncontrolledState,\n onTransitionEnd: setContentIsVisible,\n onTransitionStart: setVisibleIfOpening,\n setExpanderHeight,\n }}\n >\n {children}\n </ExpanderContext.Provider>\n </El>\n </div>\n );\n }),\n { Content: ExpandablePanelContent },\n) as ExpandablePanelComponent;\n"],"names":["ExpandablePanel","Object","assign","React","forwardRef","props","ref","children","as","variant","open","controlledOpen","defaultOpen","onOpenChange","className","rest","uncontrolledOpen","setUncontrolledOpen","useState","contentIsVisible","setContentIsVisible","expanderHeight","setExpanderHeight","internalRef","useRef","useImperativeHandle","current","El","isControlled","isOpen","useEffect","callback","e","newState","element","addEventListener","removeEventListener","jsxs","jsx","inert","style","height","clsx","ExpanderContext","Provider","value","onToggle","previousValue","onTransitionEnd","onTransitionStart","isOpening","Content","ExpandablePanelContent"],"mappings":"qPAUaA,EAAkBC,OAAOC,OAClCC,EAAMC,YAAW,SAGbC,EACAC,GAEM,MACFC,SAAAA,EACAC,GAAAA,EAAK,UACLC,QAAAA,EAAU,OACVC,KAAMC,EACNC,YAAAA,EACAC,aAAAA,EACAC,UAAAA,KACGC,GACHV,GAEGW,EAAkBC,GAAuBC,EAAAA,SAC5CN,IAAe,IAEZO,EAAkBC,GAAuBF,EAAAA,UAAS,IAClDG,EAAgBC,GAAqBJ,EAAAA,SAAS,GAE/CK,EAAcC,EAAAA,SACpBC,EAAAA,oBAAoBnB,GAAK,IAAMiB,EAAYG,SAAS,IAEpD,MAAMC,EAAKnB,EACLoB,SAAsBjB,EAAmB,IACzCkB,EAASD,EAAejB,EAAiBK,EAkB/Cc,OAAAA,EAAAA,WAAU,KACA,MAAAC,EAAYC,IACMf,EAAe,SAAfe,EAAEC,SAAmB,EAGvCC,EAAUX,EAAYG,QAEnB,OAAA,MAAAQ,GAAAA,EAAAC,iBAAiB,SAAUJ,GAE7B,IACH,MAAAG,OAAA,EAAAA,EAASE,oBACL,SACAL,EAAAA,GAET,IAGCM,EAAAA,KAAC,MAAI,CAAAvB,UAAU,0BACXP,SAAA,CAAA+B,EAAAA,IAAC,MAAA,CAGSC,MAAO,OACbzB,UAAU,kCACV0B,MAAO,CAAEC,OAAQpB,KAErBiB,EAAAA,IAACX,EAAA,CACGrB,IAAKiB,EACL,cAAa,qBACbT,UAAW4B,EAAAA,KACP,iBACA,mBAAmBjC,IACnBK,GAEJJ,KAGW,YAAPF,EACMqB,GAAUV,OACV,EAGV,uBAAsBU,GAAUV,KAC5BJ,EAEJR,SAAA+B,EAAAA,IAACK,EAAAA,gBAAgBC,SAAhB,CACGC,MAAO,CACHnC,KAAMmB,EACNiB,SAzDU,KACtBlB,GAGJX,GAAqB8B,IACjB,MAAAlC,GAAAA,GAAgBkC,IACRA,IACX,EAmDeC,gBAAiB5B,EACjB6B,kBAjESC,IACrBA,GACA9B,GAAoB,EAAI,EAgEZE,kBAAAA,GAGHf,SAAAA,QAGb,IAGR,CAAE4C,QAASC,EAAuBA"}
1
+ {"version":3,"file":"ExpandablePanel.cjs","sources":["../../../../src/components/expander/ExpandablePanel.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport type { PolymorphicRef } from \"../../utilities/polymorphism/polymorphism.js\";\nimport { ExpandablePanelContent } from \"./ExpandablePanelContent.js\";\nimport { ExpanderContext } from \"./context.js\";\nimport type {\n ExpandablePanelComponent,\n ExpandablePanelProps,\n} from \"./types.js\";\n\nexport const ExpandablePanel = Object.assign(\n React.forwardRef(function ExpandablePanel<\n ElementType extends React.ElementType = \"details\",\n >(\n props: ExpandablePanelProps<ElementType>,\n ref?: PolymorphicRef<ElementType>,\n ) {\n const {\n children,\n as = \"details\",\n variant = \"fill\",\n open: controlledOpen,\n defaultOpen,\n onOpenChange,\n className,\n ...rest\n } = props;\n\n const [uncontrolledOpen, setUncontrolledOpen] = useState(\n defaultOpen || false,\n );\n const [contentIsVisible, setContentIsVisible] = useState(false);\n const [expanderHeight, setExpanderHeight] = useState(0);\n\n const internalRef = useRef<HTMLDetailsElement>();\n useImperativeHandle(ref, () => internalRef.current, []);\n\n const El = as;\n const isControlled = typeof controlledOpen !== \"undefined\";\n const isOpen = isControlled ? controlledOpen : uncontrolledOpen;\n\n const setVisibleIfOpening = (isOpening: boolean) => {\n if (isOpening) {\n setContentIsVisible(true);\n }\n };\n\n const syncUncontrolledState = () => {\n if (isControlled) {\n return;\n }\n setUncontrolledOpen((previousValue) => {\n onOpenChange?.(!previousValue);\n return !previousValue;\n });\n };\n\n useEffect(() => {\n const callback = (e: ToggleEvent & { newState: string }) => {\n setUncontrolledOpen(e.newState === \"open\");\n };\n\n const element = internalRef.current;\n\n element?.addEventListener(\"toggle\", callback as EventListener);\n\n return () =>\n element?.removeEventListener(\n \"toggle\",\n callback as EventListener,\n );\n }, []);\n\n return (\n <div className=\"jkl-expandable__wrapper\">\n <div\n /*\n Setter `inert` manuelt for å støtte både React 18 og 19.\n\n Dette unngår typefeil i React 18 og advarsler i React 19.\n Se: https://github.com/WICG/inert/issues/58\n */\n ref={(node) => node?.setAttribute(\"inert\", \"true\")}\n className=\"jkl-expandable__focus-container\"\n style={{ height: expanderHeight }}\n />\n <El\n ref={internalRef}\n data-testid={\"jkl-expand-section\"}\n className={clsx(\n \"jkl-expandable\",\n `jkl-expandable--${variant}`,\n className,\n )}\n open={\n /* for the animation to work in Safari we must ensure that\n * the element is open *before* the transition starts */\n as === \"details\"\n ? isOpen || contentIsVisible\n : undefined\n }\n /* this attribute is used for styling purposes */\n data-visible-content={isOpen || contentIsVisible}\n {...rest}\n >\n <ExpanderContext.Provider\n value={{\n open: isOpen,\n onToggle: syncUncontrolledState,\n onTransitionEnd: setContentIsVisible,\n onTransitionStart: setVisibleIfOpening,\n setExpanderHeight,\n }}\n >\n {children}\n </ExpanderContext.Provider>\n </El>\n </div>\n );\n }),\n { Content: ExpandablePanelContent },\n) as ExpandablePanelComponent;\n"],"names":["ExpandablePanel","Object","assign","React","forwardRef","props","ref","children","as","variant","open","controlledOpen","defaultOpen","onOpenChange","className","rest","uncontrolledOpen","setUncontrolledOpen","useState","contentIsVisible","setContentIsVisible","expanderHeight","setExpanderHeight","internalRef","useRef","useImperativeHandle","current","El","isControlled","isOpen","useEffect","callback","e","newState","element","addEventListener","removeEventListener","jsxs","jsx","node","setAttribute","style","height","clsx","ExpanderContext","Provider","value","onToggle","previousValue","onTransitionEnd","onTransitionStart","isOpening","Content","ExpandablePanelContent"],"mappings":"qPAUaA,EAAkBC,OAAOC,OAClCC,EAAMC,YAAW,SAGbC,EACAC,GAEM,MACFC,SAAAA,EACAC,GAAAA,EAAK,UACLC,QAAAA,EAAU,OACVC,KAAMC,EACNC,YAAAA,EACAC,aAAAA,EACAC,UAAAA,KACGC,GACHV,GAEGW,EAAkBC,GAAuBC,EAAAA,SAC5CN,IAAe,IAEZO,EAAkBC,GAAuBF,EAAAA,UAAS,IAClDG,EAAgBC,GAAqBJ,EAAAA,SAAS,GAE/CK,EAAcC,EAAAA,SACpBC,EAAAA,oBAAoBnB,GAAK,IAAMiB,EAAYG,SAAS,IAEpD,MAAMC,EAAKnB,EACLoB,SAAsBjB,EAAmB,IACzCkB,EAASD,EAAejB,EAAiBK,EAkB/Cc,OAAAA,EAAAA,WAAU,KACA,MAAAC,EAAYC,IACMf,EAAe,SAAfe,EAAEC,SAAmB,EAGvCC,EAAUX,EAAYG,QAEnB,OAAAQ,GAAAC,iBAAiB,SAAUJ,GAE7B,IACHG,GAASE,oBACL,SACAL,EACJ,GACL,IAGCM,EAAAA,KAAC,MAAI,CAAAvB,UAAU,0BACXP,SAAA,CAAA+B,EAAAA,IAAC,MAAA,CAOGhC,IAAMiC,GAASA,GAAMC,aAAa,QAAS,QAC3C1B,UAAU,kCACV2B,MAAO,CAAEC,OAAQrB,KAErBiB,EAAAA,IAACX,EAAA,CACGrB,IAAKiB,EACL,cAAa,qBACbT,UAAW6B,EAAAA,KACP,iBACA,mBAAmBlC,IACnBK,GAEJJ,KAGW,YAAPF,EACMqB,GAAUV,OACV,EAGV,uBAAsBU,GAAUV,KAC5BJ,EAEJR,SAAA+B,EAAAA,IAACM,EAAAA,gBAAgBC,SAAhB,CACGC,MAAO,CACHpC,KAAMmB,EACNkB,SA7DU,KACtBnB,GAGJX,GAAqB+B,IACjBnC,KAAgBmC,IACRA,IACX,EAuDeC,gBAAiB7B,EACjB8B,kBArESC,IACrBA,GACA/B,GAAoB,EAAI,EAoEZE,kBAAAA,GAGHf,SAAAA,QAGb,IAGR,CAAE6C,QAASC,EAAuBA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("../../../clsx-E3yX_9sL.cjs"),t=require("react"),r=require("../../hooks/useAnimatedHeight/useAnimatedHeightBetween.cjs"),a=require("./context.cjs");exports.ExpandablePanelContent=({className:i,children:s,...o})=>{const{open:c,onTransitionStart:d,onTransitionEnd:l}=t.useContext(a.ExpanderContext),[u]=r.useAnimatedHeightBetween(c,{timing:"snappy",onTransitionStart:d,onTransitionEnd:l});return e.jsx("div",{ref:u,className:n.clsx("jkl-expandable__content",i),...o,"data-expanded":c,...c?{}:{inert:"true"},children:e.jsx("div",{className:"jkl-expandable__content-wrapper",children:s})})};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../../clsx-E3yX_9sL.cjs"),n=require("react"),r=require("../../hooks/useAnimatedHeight/useAnimatedHeightBetween.cjs"),i=require("./context.cjs");exports.ExpandablePanelContent=({className:s,children:a,...o})=>{const{open:c,onTransitionStart:d,onTransitionEnd:u}=n.useContext(i.ExpanderContext),[l]=r.useAnimatedHeightBetween(c,{timing:"snappy",onTransitionStart:d,onTransitionEnd:u});return n.useEffect((()=>{const e=l.current;c?e?.removeAttribute("inert"):e?.setAttribute("inert","true")}),[c,l]),e.jsx("div",{ref:l,className:t.clsx("jkl-expandable__content",s),...o,"data-expanded":c,children:e.jsx("div",{className:"jkl-expandable__content-wrapper",children:a})})};
2
2
  //# sourceMappingURL=ExpandablePanelContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpandablePanelContent.cjs","sources":["../../../../src/components/expander/ExpandablePanelContent.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { useContext } from \"react\";\nimport { useAnimatedHeightBetween } from \"../../hooks/useAnimatedHeight/useAnimatedHeightBetween.js\";\nimport { ExpanderContext } from \"./context.js\";\nimport type {\n ExpandableContext,\n ExpandablePanelContentComponent,\n} from \"./types.js\";\n\nexport const ExpandablePanelContent: ExpandablePanelContentComponent = ({\n className,\n children,\n ...rest\n}) => {\n const { open, onTransitionStart, onTransitionEnd } =\n useContext<ExpandableContext>(ExpanderContext);\n\n const [animationRef] = useAnimatedHeightBetween<HTMLDivElement>(open, {\n timing: \"snappy\",\n onTransitionStart,\n onTransitionEnd,\n });\n\n return (\n <div\n ref={animationRef}\n className={clsx(\"jkl-expandable__content\", className)}\n {...rest}\n data-expanded={open}\n {...(!open ? { inert: \"true\" } : {})}\n >\n <div className=\"jkl-expandable__content-wrapper\">{children}</div>\n </div>\n );\n};\n"],"names":["className","children","rest","open","onTransitionStart","onTransitionEnd","useContext","ExpanderContext","animationRef","useAnimatedHeightBetween","timing","jsx","ref","clsx","inert"],"mappings":"kTASuE,EACnEA,UAAAA,EACAC,SAAAA,KACGC,MAEH,MAAQC,KAAAA,EAAMC,kBAAAA,EAAmBC,gBAAAA,GAC7BC,EAAAA,WAA8BC,EAAAA,kBAE3BC,GAAgBC,EAAAA,yBAAyCN,EAAM,CAClEO,OAAQ,SACRN,kBAAAA,EACAC,gBAAAA,IAIA,OAAAM,EAAAA,IAAC,MAAA,CACGC,IAAKJ,EACLR,UAAWa,EAAAA,KAAK,0BAA2Bb,MACvCE,EACJ,gBAAeC,KACTA,EAA2B,CAAC,EAArB,CAAEW,MAAO,QAEtBb,SAACU,EAAAA,IAAA,MAAA,CAAIX,UAAU,kCAAmCC,SAAAA,KACtD"}
1
+ {"version":3,"file":"ExpandablePanelContent.cjs","sources":["../../../../src/components/expander/ExpandablePanelContent.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { useContext, useEffect } from \"react\";\nimport { useAnimatedHeightBetween } from \"../../hooks/useAnimatedHeight/useAnimatedHeightBetween.js\";\nimport { ExpanderContext } from \"./context.js\";\nimport type {\n ExpandableContext,\n ExpandablePanelContentComponent,\n} from \"./types.js\";\n\nexport const ExpandablePanelContent: ExpandablePanelContentComponent = ({\n className,\n children,\n ...rest\n}) => {\n const { open, onTransitionStart, onTransitionEnd } =\n useContext<ExpandableContext>(ExpanderContext);\n\n const [animationRef] = useAnimatedHeightBetween<HTMLDivElement>(open, {\n timing: \"snappy\",\n onTransitionStart,\n onTransitionEnd,\n });\n\n /*\n Setter `inert` manuelt for å støtte både React 18 og 19.\n\n Dette unngår typefeil i React 18 og advarsler i React 19.\n Se: https://github.com/WICG/inert/issues/58\n */\n useEffect(() => {\n const node = animationRef.current;\n\n if (!open) {\n node?.setAttribute(\"inert\", \"true\");\n } else {\n node?.removeAttribute(\"inert\");\n }\n }, [open, animationRef]);\n\n return (\n <div\n ref={animationRef}\n className={clsx(\"jkl-expandable__content\", className)}\n {...rest}\n data-expanded={open}\n >\n <div className=\"jkl-expandable__content-wrapper\">{children}</div>\n </div>\n );\n};\n"],"names":["className","children","rest","open","onTransitionStart","onTransitionEnd","useContext","ExpanderContext","animationRef","useAnimatedHeightBetween","timing","useEffect","node","current","removeAttribute","setAttribute","jsx","ref","clsx"],"mappings":"kTASuE,EACnEA,UAAAA,EACAC,SAAAA,KACGC,MAEH,MAAQC,KAAAA,EAAMC,kBAAAA,EAAmBC,gBAAAA,GAC7BC,EAAAA,WAA8BC,EAAAA,kBAE3BC,GAAgBC,EAAAA,yBAAyCN,EAAM,CAClEO,OAAQ,SACRN,kBAAAA,EACAC,gBAAAA,IASJM,OAAAA,EAAAA,WAAU,KACN,MAAMC,EAAOJ,EAAaK,QAErBV,EAGDS,GAAME,gBAAgB,SAFhBF,GAAAG,aAAa,QAAS,OAAM,GAIvC,CAACZ,EAAMK,IAGNQ,EAAAA,IAAC,MAAA,CACGC,IAAKT,EACLR,UAAWkB,EAAAA,KAAK,0BAA2BlB,MACvCE,EACJ,gBAAeC,EAEfF,SAACe,EAAAA,IAAA,MAAA,CAAIhB,UAAU,kCAAmCC,SAAAA,KACtD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("../../../clsx-E3yX_9sL.cjs"),c=require("react"),o=require("../icon/icons/ChevronDownIcon.cjs");require("../icon/Icon.cjs"),require("../icon/icons/animated/ArrowVerticalAnimated.cjs"),require("../icon/icons/animated/ArrowHorizontalAnimated.cjs"),require("../icon/icons/animated/PlusRemoveAnimated.cjs"),require("../icon/icons/ArrowDownIcon.cjs"),require("../icon/icons/ArrowLeftIcon.cjs"),require("../icon/icons/ArrowNorthEastIcon.cjs"),require("../icon/icons/ArrowRightIcon.cjs"),require("../icon/icons/ArrowUpIcon.cjs"),require("../icon/icons/CalendarIcon.cjs"),require("../icon/icons/CheckIcon.cjs"),require("../icon/icons/ChevronLeftIcon.cjs"),require("../icon/icons/ChevronRightIcon.cjs");const r=require("../icon/icons/ChevronUpIcon.cjs");require("../icon/icons/CloseIcon.cjs"),require("../icon/icons/CopyIcon.cjs"),require("../icon/icons/DotsIcon.cjs"),require("../icon/icons/DragIcon.cjs"),require("../icon/icons/ErrorIcon.cjs"),require("../icon/icons/GreenCheckIcon.cjs"),require("../icon/icons/HamburgerIcon.cjs"),require("../icon/icons/InfoIcon.cjs"),require("../icon/icons/LinkIcon.cjs"),require("../icon/icons/MinusIcon.cjs"),require("../icon/icons/OpenInNewIcon.cjs"),require("../icon/icons/PenIcon.cjs"),require("../icon/icons/PlusIcon.cjs"),require("../icon/icons/QuestionIcon.cjs"),require("../icon/icons/RedCrossIcon.cjs"),require("../icon/icons/SearchIcon.cjs"),require("../icon/icons/SuccessIcon.cjs"),require("../icon/icons/ThumbDownIcon.cjs"),require("../icon/icons/ThumbUpIcon.cjs"),require("../icon/icons/TrashCanIcon.cjs"),require("../icon/icons/WarningIcon.cjs");const i=require("./context.cjs"),s=c.forwardRef((function(s,u){const{children:t,as:a="summary",open:j,icon:q,className:I,onClick:l,expandDirection:p,...d}=s,h=a,{open:m,onToggle:x,setExpanderHeight:C}=c.useContext(i.ExpanderContext),v=c.useRef();c.useImperativeHandle(u,(()=>v.current),[]);const f=j||m,w="up"===p?r.ChevronUpIcon:o.ChevronDownIcon;return c.useEffect((()=>{const e=new ResizeObserver((()=>{var e;C((null==(e=v.current)?void 0:e.offsetHeight)||64)}));return v.current?(e.observe(v.current),()=>e.disconnect()):()=>{}}),[C]),e.jsxs(h,{ref:v,className:n.clsx("jkl-expander",{"jkl-expander--open":f},I),..."button"===a?{type:d.type||"button"}:{},onClick:e=>{e.preventDefault(),x(),null==l||l(e)},...d,children:[q||null,e.jsx("span",{className:"jkl-expander__label",children:t}),e.jsx(w,{className:"jkl-expander__chevron"})]})}));exports.Expander=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("../../../clsx-E3yX_9sL.cjs"),c=require("react"),o=require("../icon/icons/ChevronDownIcon.cjs");require("../icon/Icon.cjs"),require("../icon/icons/animated/ArrowVerticalAnimated.cjs"),require("../icon/icons/animated/ArrowHorizontalAnimated.cjs"),require("../icon/icons/animated/PlusRemoveAnimated.cjs"),require("../icon/icons/ArrowDownIcon.cjs"),require("../icon/icons/ArrowLeftIcon.cjs"),require("../icon/icons/ArrowNorthEastIcon.cjs"),require("../icon/icons/ArrowRightIcon.cjs"),require("../icon/icons/ArrowUpIcon.cjs"),require("../icon/icons/CalendarIcon.cjs"),require("../icon/icons/CheckIcon.cjs"),require("../icon/icons/ChevronLeftIcon.cjs"),require("../icon/icons/ChevronRightIcon.cjs");const r=require("../icon/icons/ChevronUpIcon.cjs");require("../icon/icons/CloseIcon.cjs"),require("../icon/icons/CopyIcon.cjs"),require("../icon/icons/DotsIcon.cjs"),require("../icon/icons/DragIcon.cjs"),require("../icon/icons/ErrorIcon.cjs"),require("../icon/icons/GreenCheckIcon.cjs"),require("../icon/icons/HamburgerIcon.cjs"),require("../icon/icons/InfoIcon.cjs"),require("../icon/icons/LinkIcon.cjs"),require("../icon/icons/MinusIcon.cjs"),require("../icon/icons/OpenInNewIcon.cjs"),require("../icon/icons/PenIcon.cjs"),require("../icon/icons/PlusIcon.cjs"),require("../icon/icons/QuestionIcon.cjs"),require("../icon/icons/RedCrossIcon.cjs"),require("../icon/icons/SearchIcon.cjs"),require("../icon/icons/SuccessIcon.cjs"),require("../icon/icons/ThumbDownIcon.cjs"),require("../icon/icons/ThumbUpIcon.cjs"),require("../icon/icons/TrashCanIcon.cjs"),require("../icon/icons/WarningIcon.cjs");const i=require("./context.cjs"),s=c.forwardRef((function(s,u){const{children:t,as:a="summary",open:j,icon:q,className:I,onClick:l,expandDirection:p,...d}=s,h=a,{open:m,onToggle:x,setExpanderHeight:C}=c.useContext(i.ExpanderContext),f=c.useRef();c.useImperativeHandle(u,(()=>f.current),[]);const w=j||m,v="up"===p?r.ChevronUpIcon:o.ChevronDownIcon;return c.useEffect((()=>{const e=new ResizeObserver((()=>{C(f.current?.offsetHeight||64)}));return f.current?(e.observe(f.current),()=>e.disconnect()):()=>{}}),[C]),e.jsxs(h,{ref:f,className:n.clsx("jkl-expander",{"jkl-expander--open":w},I),..."button"===a?{type:d.type||"button"}:{},onClick:e=>{e.preventDefault(),x(),l?.(e)},...d,children:[q||null,e.jsx("span",{className:"jkl-expander__label",children:t}),e.jsx(v,{className:"jkl-expander__chevron"})]})}));exports.Expander=s;
2
2
  //# sourceMappingURL=Expander.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Expander.cjs","sources":["../../../../src/components/expander/Expander.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport type { PolymorphicRef } from \"../../utilities/polymorphism/polymorphism.js\";\nimport { ChevronDownIcon } from \"../icon/icons/ChevronDownIcon.js\";\nimport { ChevronUpIcon } from \"../icon/index.js\";\nimport { ExpanderContext } from \"./context.js\";\nimport type {\n ExpandableContext,\n ExpanderComponent,\n ExpanderProps,\n} from \"./types.js\";\n\nexport const Expander = React.forwardRef(function Expander<\n ElementType extends React.ElementType = \"summary\",\n>(props: ExpanderProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n children,\n as = \"summary\",\n open: controlledOpen,\n icon,\n className,\n onClick,\n expandDirection,\n ...rest\n } = props;\n const El = as;\n\n const {\n open: contextOpen,\n onToggle,\n setExpanderHeight,\n } = useContext<ExpandableContext>(ExpanderContext);\n\n const internalRef = useRef<HTMLElement>();\n useImperativeHandle(ref, () => internalRef.current, []);\n\n const isOpen = controlledOpen || contextOpen;\n\n const Chevron = expandDirection === \"up\" ? ChevronUpIcon : ChevronDownIcon;\n\n useEffect(() => {\n const observer = new ResizeObserver(() => {\n // Default to 64 if the height can not be read because that is\n // the height of the default summary element. In a custom component\n // this means that the focus ring might be slightly misaligned but\n // in most cases we will be able to read the ref correctly.\n setExpanderHeight(internalRef.current?.offsetHeight || 64);\n });\n if (internalRef.current) {\n observer.observe(internalRef.current);\n return () => observer.disconnect();\n }\n return () => {};\n }, [setExpanderHeight]);\n\n return (\n <El\n ref={internalRef}\n className={clsx(\n \"jkl-expander\",\n {\n \"jkl-expander--open\": isOpen,\n },\n className,\n )}\n // If the consumer uses the Expander as a button but does not\n // supply a type, then we set type to \"button\"\n {...(as === \"button\" ? { type: rest.type || \"button\" } : {})}\n onClick={(e) => {\n e.preventDefault();\n onToggle();\n onClick?.(e);\n }}\n {...rest}\n >\n {icon || null}\n <span className=\"jkl-expander__label\">{children}</span>\n <Chevron className=\"jkl-expander__chevron\" />\n </El>\n );\n}) as ExpanderComponent;\n"],"names":["Expander","React","forwardRef","props","ref","children","as","open","controlledOpen","icon","className","onClick","expandDirection","rest","El","contextOpen","onToggle","setExpanderHeight","useContext","ExpanderContext","internalRef","useRef","useImperativeHandle","current","isOpen","Chevron","ChevronUpIcon","ChevronDownIcon","useEffect","observer","ResizeObserver","_a","offsetHeight","observe","disconnect","jsxs","clsx","type","e","preventDefault","jsx"],"mappings":"qtDAiBaA,EAAWC,EAAMC,YAAW,SAEvCC,EAAmCC,GAC3B,MACFC,SAAAA,EACAC,GAAAA,EAAK,UACLC,KAAMC,EACNC,KAAAA,EACAC,UAAAA,EACAC,QAAAA,EACAC,gBAAAA,KACGC,GACHV,EACEW,EAAKR,GAGPC,KAAMQ,EACNC,SAAAA,EACAC,kBAAAA,GACAC,EAAAA,WAA8BC,EAAAA,iBAE5BC,EAAcC,EAAAA,SACpBC,EAAAA,oBAAoBlB,GAAK,IAAMgB,EAAYG,SAAS,IAEpD,MAAMC,EAAShB,GAAkBO,EAE3BU,EAA8B,OAApBb,EAA2Bc,EAAgBA,cAAAC,EAAAA,gBAE3DC,OAAAA,EAAAA,WAAU,KACA,MAAAC,EAAW,IAAIC,gBAAe,WAKdb,GAAA,OAAAc,EAAAX,EAAYG,cAAZQ,EAAAA,EAAqBC,eAAgB,GAAE,IAE7D,OAAIZ,EAAYG,SACHM,EAAAI,QAAQb,EAAYG,SACtB,IAAMM,EAASK,cAEnB,MAAO,GACf,CAACjB,IAGAkB,EAAAA,KAACrB,EAAA,CACGV,IAAKgB,EACLV,UAAW0B,EAAAA,KACP,eACA,CACI,qBAAsBZ,GAE1Bd,MAIQ,WAAPJ,EAAkB,CAAE+B,KAAMxB,EAAKwB,MAAQ,UAAa,CAAC,EAC1D1B,QAAU2B,IACNA,EAAEC,iBACOvB,IACT,MAAAL,GAAAA,EAAU2B,OAEVzB,EAEHR,SAAA,CAAQI,GAAA,KACR+B,EAAAA,IAAA,OAAA,CAAK9B,UAAU,sBAAuBL,SAAAA,IACvCmC,EAAAA,IAACf,EAAQ,CAAAf,UAAU,4BAG/B"}
1
+ {"version":3,"file":"Expander.cjs","sources":["../../../../src/components/expander/Expander.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport type { PolymorphicRef } from \"../../utilities/polymorphism/polymorphism.js\";\nimport { ChevronDownIcon } from \"../icon/icons/ChevronDownIcon.js\";\nimport { ChevronUpIcon } from \"../icon/index.js\";\nimport { ExpanderContext } from \"./context.js\";\nimport type {\n ExpandableContext,\n ExpanderComponent,\n ExpanderProps,\n} from \"./types.js\";\n\nexport const Expander = React.forwardRef(function Expander<\n ElementType extends React.ElementType = \"summary\",\n>(props: ExpanderProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n children,\n as = \"summary\",\n open: controlledOpen,\n icon,\n className,\n onClick,\n expandDirection,\n ...rest\n } = props;\n const El = as;\n\n const {\n open: contextOpen,\n onToggle,\n setExpanderHeight,\n } = useContext<ExpandableContext>(ExpanderContext);\n\n const internalRef = useRef<HTMLElement>();\n useImperativeHandle(ref, () => internalRef.current, []);\n\n const isOpen = controlledOpen || contextOpen;\n\n const Chevron = expandDirection === \"up\" ? ChevronUpIcon : ChevronDownIcon;\n\n useEffect(() => {\n const observer = new ResizeObserver(() => {\n // Default to 64 if the height can not be read because that is\n // the height of the default summary element. In a custom component\n // this means that the focus ring might be slightly misaligned but\n // in most cases we will be able to read the ref correctly.\n setExpanderHeight(internalRef.current?.offsetHeight || 64);\n });\n if (internalRef.current) {\n observer.observe(internalRef.current);\n return () => observer.disconnect();\n }\n return () => {};\n }, [setExpanderHeight]);\n\n return (\n <El\n ref={internalRef}\n className={clsx(\n \"jkl-expander\",\n {\n \"jkl-expander--open\": isOpen,\n },\n className,\n )}\n // If the consumer uses the Expander as a button but does not\n // supply a type, then we set type to \"button\"\n {...(as === \"button\" ? { type: rest.type || \"button\" } : {})}\n onClick={(e) => {\n e.preventDefault();\n onToggle();\n onClick?.(e);\n }}\n {...rest}\n >\n {icon || null}\n <span className=\"jkl-expander__label\">{children}</span>\n <Chevron className=\"jkl-expander__chevron\" />\n </El>\n );\n}) as ExpanderComponent;\n"],"names":["Expander","React","forwardRef","props","ref","children","as","open","controlledOpen","icon","className","onClick","expandDirection","rest","El","contextOpen","onToggle","setExpanderHeight","useContext","ExpanderContext","internalRef","useRef","useImperativeHandle","current","isOpen","Chevron","ChevronUpIcon","ChevronDownIcon","useEffect","observer","ResizeObserver","offsetHeight","observe","disconnect","jsxs","clsx","type","e","preventDefault","jsx"],"mappings":"qtDAiBaA,EAAWC,EAAMC,YAAW,SAEvCC,EAAmCC,GAC3B,MACFC,SAAAA,EACAC,GAAAA,EAAK,UACLC,KAAMC,EACNC,KAAAA,EACAC,UAAAA,EACAC,QAAAA,EACAC,gBAAAA,KACGC,GACHV,EACEW,EAAKR,GAGPC,KAAMQ,EACNC,SAAAA,EACAC,kBAAAA,GACAC,EAAAA,WAA8BC,EAAAA,iBAE5BC,EAAcC,EAAAA,SACpBC,EAAAA,oBAAoBlB,GAAK,IAAMgB,EAAYG,SAAS,IAEpD,MAAMC,EAAShB,GAAkBO,EAE3BU,EAA8B,OAApBb,EAA2Bc,EAAgBA,cAAAC,EAAAA,gBAE3DC,OAAAA,EAAAA,WAAU,KACA,MAAAC,EAAW,IAAIC,gBAAe,KAKdb,EAAAG,EAAYG,SAASQ,cAAgB,GAAE,IAE7D,OAAIX,EAAYG,SACHM,EAAAG,QAAQZ,EAAYG,SACtB,IAAMM,EAASI,cAEnB,MAAO,GACf,CAAChB,IAGAiB,EAAAA,KAACpB,EAAA,CACGV,IAAKgB,EACLV,UAAWyB,EAAAA,KACP,eACA,CACI,qBAAsBX,GAE1Bd,MAIQ,WAAPJ,EAAkB,CAAE8B,KAAMvB,EAAKuB,MAAQ,UAAa,CAAC,EAC1DzB,QAAU0B,IACNA,EAAEC,iBACOtB,IACTL,IAAU0B,EAAC,KAEXxB,EAEHR,SAAA,CAAQI,GAAA,KACR8B,EAAAA,IAAA,OAAA,CAAK7B,UAAU,sBAAuBL,SAAAA,IACvCkC,EAAAA,IAACd,EAAQ,CAAAf,UAAU,4BAG/B"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ExpandablePanel.cjs"),a=require("./Expander.cjs"),n=require("./deprecated/ExpandSection.cjs");exports.ExpandablePanel=e.ExpandablePanel,exports.Expander=a.Expander,exports.ExpandSection=n.ExpandSection;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ExpandablePanel.cjs"),a=require("./Expander.cjs");exports.ExpandablePanel=e.ExpandablePanel,exports.Expander=a.Expander;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,3 @@
1
1
  export { ExpandablePanel } from './ExpandablePanel.cjs';
2
2
  export { Expander } from './Expander.cjs';
3
- export { ExpandSection, type ExpandSectionProps, } from './deprecated/ExpandSection.cjs';
4
3
  export type { ExpandablePanelProps, ExpanderProps } from './types.cjs';
@@ -1,2 +1,2 @@
1
1
  "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime");require("react");const n=require("../../flex/Flex.cjs");require("../../icon/Icon.cjs"),require("../../icon/icons/animated/ArrowVerticalAnimated.cjs"),require("../../icon/icons/animated/ArrowHorizontalAnimated.cjs"),require("../../icon/icons/animated/PlusRemoveAnimated.cjs"),require("../../icon/icons/ArrowDownIcon.cjs"),require("../../icon/icons/ArrowLeftIcon.cjs"),require("../../icon/icons/ArrowNorthEastIcon.cjs"),require("../../icon/icons/ArrowRightIcon.cjs"),require("../../icon/icons/ArrowUpIcon.cjs"),require("../../icon/icons/CalendarIcon.cjs"),require("../../icon/icons/CheckIcon.cjs"),require("../../icon/icons/ChevronDownIcon.cjs"),require("../../icon/icons/ChevronLeftIcon.cjs"),require("../../icon/icons/ChevronRightIcon.cjs"),require("../../icon/icons/ChevronUpIcon.cjs"),require("../../icon/icons/CloseIcon.cjs"),require("../../icon/icons/CopyIcon.cjs"),require("../../icon/icons/DotsIcon.cjs"),require("../../icon/icons/DragIcon.cjs"),require("../../icon/icons/ErrorIcon.cjs");const c=require("../../icon/icons/GreenCheckIcon.cjs");require("../../icon/icons/HamburgerIcon.cjs"),require("../../icon/icons/InfoIcon.cjs"),require("../../icon/icons/LinkIcon.cjs"),require("../../icon/icons/MinusIcon.cjs"),require("../../icon/icons/OpenInNewIcon.cjs"),require("../../icon/icons/PenIcon.cjs"),require("../../icon/icons/PlusIcon.cjs"),require("../../icon/icons/QuestionIcon.cjs"),require("../../icon/icons/RedCrossIcon.cjs"),require("../../icon/icons/SearchIcon.cjs"),require("../../icon/icons/SuccessIcon.cjs"),require("../../icon/icons/ThumbDownIcon.cjs"),require("../../icon/icons/ThumbUpIcon.cjs"),require("../../icon/icons/TrashCanIcon.cjs"),require("../../icon/icons/WarningIcon.cjs");const o=require("../ExpandablePanel.cjs"),i=require("../ExpandablePanelContent.cjs"),r=require("../Expander.cjs");;/* empty css */const s={title:"Komponenter/ExpandablePanel",component:o.ExpandablePanel,subcomponents:{Expander:r.Expander,ExpandablePanelContent:i.ExpandablePanelContent},parameters:{layout:"padded"},tags:["autodocs"],argTypes:{variant:{control:"select",options:["stroke","fill"]}}},a={name:"ExpandablePanel",args:{variant:"fill",icon:!0,flipDirection:!1},render:({icon:i,flipDirection:s,...a})=>e.jsx(n.Flex,{style:{width:"100%"},direction:"column",gap:4,children:[...Array(3)].map(((n,t)=>e.jsxs(o.ExpandablePanel,{...a,children:[e.jsx(r.Expander,{icon:i?e.jsx(c.GreenCheckIcon,{}):void 0,expandDirection:s?"up":void 0,children:"Når er det vi faktisk er åpne?"}),e.jsx(o.ExpandablePanel.Content,{children:"Velkommen innom når vi faktisk har kaffe! Vi er åpne mandag til fredag fra kl. 09:00 til 18:00. Lørdag kan du besøke oss fra 10:00 til 16:00 (vi liker en rolig start på lørdagen). Søndager hviler vi – og det burde du også!"})]},t)))})};exports.ExpandablePanelStory=a,exports.default=s;
2
- //# sourceMappingURL=ExpanderPanel.stories.cjs.map
2
+ //# sourceMappingURL=ExpandablePanel.stories.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpandablePanel.stories.cjs","sources":["../../../../../src/components/expander/stories/ExpandablePanel.stories.tsx"],"sourcesContent":["import type { Meta, StoryObj } from \"@storybook/react\";\nimport React from \"react\";\nimport { Flex } from \"../../flex/Flex.jsx\";\nimport { GreenCheckIcon } from \"../../icon/index.js\";\nimport { ExpandablePanel } from \"../ExpandablePanel.jsx\";\nimport { ExpandablePanelContent } from \"../ExpandablePanelContent.jsx\";\nimport { Expander } from \"../Expander.jsx\";\nimport \"../styles/_index.scss\";\n\nconst meta: Meta = {\n title: \"Komponenter/ExpandablePanel\",\n component: ExpandablePanel,\n subcomponents: { Expander, ExpandablePanelContent },\n parameters: {\n layout: \"padded\",\n },\n tags: [\"autodocs\"],\n argTypes: {\n variant: { control: \"select\", options: [\"stroke\", \"fill\"] },\n },\n};\n\nexport default meta;\n\ntype StoryExpanderPanel = StoryObj<{\n icon?: boolean;\n flipDirection?: boolean;\n variant: \"stroke\" | \"fill\";\n}>;\n\nexport const ExpandablePanelStory: StoryExpanderPanel = {\n name: \"ExpandablePanel\",\n args: {\n variant: \"fill\",\n icon: true,\n flipDirection: false,\n },\n render: ({ icon, flipDirection, ...props }) => (\n <Flex style={{ width: \"100%\" }} direction=\"column\" gap={4}>\n {[...Array(3)].map((_, index) => (\n <ExpandablePanel key={index} {...props}>\n <Expander\n icon={icon ? <GreenCheckIcon /> : undefined}\n expandDirection={flipDirection ? \"up\" : undefined}\n >\n Når er det vi faktisk er åpne?\n </Expander>\n <ExpandablePanel.Content>\n Velkommen innom når vi faktisk har kaffe! Vi er åpne\n mandag til fredag fra kl. 09:00 til 18:00. Lørdag kan du\n besøke oss fra 10:00 til 16:00 (vi liker en rolig start\n på lørdagen). Søndager hviler vi – og det burde du også!\n </ExpandablePanel.Content>\n </ExpandablePanel>\n ))}\n </Flex>\n ),\n};\n"],"names":["meta","title","component","ExpandablePanel","subcomponents","Expander","ExpandablePanelContent","parameters","layout","tags","argTypes","variant","control","options","ExpandablePanelStory","name","args","icon","flipDirection","render","props","jsx","Flex","style","width","direction","gap","children","Array","map","_","index","jsxs","GreenCheckIcon","expandDirection","Content"],"mappings":"o9DASA,MAAMA,EAAa,CACfC,MAAO,8BACPC,UAAWC,EAAAA,gBACXC,cAAe,CAAAC,SAAEA,EAAAA,SAAAC,uBAAUA,0BAC3BC,WAAY,CACRC,OAAQ,UAEZC,KAAM,CAAC,YACPC,SAAU,CACNC,QAAS,CAAEC,QAAS,SAAUC,QAAS,CAAC,SAAU,WAY7CC,EAA2C,CACpDC,KAAM,kBACNC,KAAM,CACFL,QAAS,OACTM,MAAM,EACNC,eAAe,GAEnBC,OAAQ,EAAGF,KAAAA,EAAMC,cAAAA,KAAkBE,KAC/BC,EAAAA,IAACC,EAAAA,KAAK,CAAAC,MAAO,CAAEC,MAAO,QAAUC,UAAU,SAASC,IAAK,EACnDC,SAAA,IAAIC,MAAM,IAAIC,KAAI,CAACC,EAAGC,IAClBC,EAAAA,KAAA7B,EAAAA,gBAAA,IAAgCiB,EAC7BO,SAAA,CAAAN,EAAAA,IAAChB,EAAAA,SAAA,CACGY,KAAMA,EAAQI,EAAAA,IAAAY,EAAAA,eAAA,CAAA,QAAoB,EAClCC,gBAAiBhB,EAAgB,UAAO,EAC3CS,SAAA,mCAGAN,EAAAA,IAAAlB,EAAAA,gBAAgBgC,QAAhB,CAAwBR,SAKzB,qOAZkBI"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),s=require("../../button/Button.cjs"),r=require("../FeedbackSuccess.cjs"),l=require("../feedbackContext.cjs"),i=require("../utils.cjs"),a=require("./followupContext.cjs"),n=require("./useFollowup.cjs"),o={title:"Takk, igjen!",children:"Vi setter pris på at du tok deg tid til å svare på flere spørsmål. Det hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem."};exports.Followup=({questions:c,successMessage:u=o,onSubmit:d})=>{const[j,p]=t.useState(!1),m=t.useRef(null),b=n.useFollowup(c,d),{handleAbort:k,handleNext:x,step:f,submitted:g}=b,{followupStarted:h,setFollowupStarted:S,setFollowupSubmitted:y,contactSubmitted:v,landmarkLabel:F}=l.useFeedbackContext();t.useEffect((()=>{var e;0!==f.number&&(null==(e=m.current)||e.focus())}),[f]),t.useEffect((()=>{y(g)}),[g,y]);const N=i.getQuestionFromType(c[f.number].type),q=f.isLast?s.PrimaryButton:s.SecondaryButton;return j?null:e.jsx("div",{"aria-live":"polite",children:e.jsxs(a.FollowUpProvider,{state:b,children:[!h&&e.jsxs("div",{className:"jkl-feedback__fade-in",children:[e.jsx("p",{className:"jkl-heading-4 jkl-spacing-xl--top jkl-spacing-xs--bottom",children:"Har du tid til å svare på noen flere spørsmål?"}),e.jsx("p",{className:"jkl-body jkl-spacing-xl--bottom",children:"Det tar kun et minutt, og hjelper oss å lage bedre løsninger for deg."}),e.jsx(s.PrimaryButton,{onClick:()=>S(!0),className:"jkl-spacing-xl--right",children:"Jeg har tid!"}),e.jsx(s.TertiaryButton,{onClick:()=>p(!0),children:"Nei takk"})]}),!g&&h&&e.jsxs("form",{onSubmit:x,className:"jkl-feedback__fade-in","aria-label":F,children:[e.jsxs("p",{className:"jkl-feedback__step-counter",ref:m,children:["Steg ",f.number+1," av ",c.length]}),t.createElement(N,{...c[f.number],autoFocus:!0,key:f.number}),e.jsxs("div",{className:"jkl-spacing-xl--top","aria-live":"off",children:[e.jsx(q,{type:"submit",children:f.isLast?"Send inn":"Neste"}),e.jsx(s.TertiaryButton,{onClick:k,className:"jkl-spacing-xl--left",children:"Avbryt"})]})]}),g&&!v&&e.jsx(r.FeedbackSuccess,{...u})]})})};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),s=require("../../button/Button.cjs"),r=require("../FeedbackSuccess.cjs"),l=require("../feedbackContext.cjs"),i=require("../utils.cjs"),a=require("./followupContext.cjs"),n=require("./useFollowup.cjs"),o={title:"Takk, igjen!",children:"Vi setter pris på at du tok deg tid til å svare på flere spørsmål. Det hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem."};exports.Followup=({questions:c,successMessage:u=o,onSubmit:d})=>{const[j,p]=t.useState(!1),m=t.useRef(null),b=n.useFollowup(c,d),{handleAbort:k,handleNext:f,step:g,submitted:h}=b,{followupStarted:x,setFollowupStarted:S,setFollowupSubmitted:y,contactSubmitted:v,landmarkLabel:F}=l.useFeedbackContext();t.useEffect((()=>{0!==g.number&&m.current?.focus()}),[g]),t.useEffect((()=>{y(h)}),[h,y]);const N=i.getQuestionFromType(c[g.number].type),q=g.isLast?s.PrimaryButton:s.SecondaryButton;return j?null:e.jsx("div",{"aria-live":"polite",children:e.jsxs(a.FollowUpProvider,{state:b,children:[!x&&e.jsxs("div",{className:"jkl-feedback__fade-in",children:[e.jsx("p",{className:"jkl-heading-4 jkl-spacing-40--top jkl-spacing-8--bottom",children:"Har du tid til å svare på noen flere spørsmål?"}),e.jsx("p",{className:"jkl-body jkl-spacing-40--bottom",children:"Det tar kun et minutt, og hjelper oss å lage bedre løsninger for deg."}),e.jsx(s.PrimaryButton,{onClick:()=>S(!0),className:"jkl-spacing-40--right",children:"Jeg har tid!"}),e.jsx(s.TertiaryButton,{onClick:()=>p(!0),children:"Nei takk"})]}),!h&&x&&e.jsxs("form",{onSubmit:f,className:"jkl-feedback__fade-in","aria-label":F,children:[e.jsxs("p",{className:"jkl-feedback__step-counter",ref:m,children:["Steg ",g.number+1," av ",c.length]}),t.createElement(N,{...c[g.number],autoFocus:!0,key:g.number}),e.jsxs("div",{className:"jkl-spacing-40--top","aria-live":"off",children:[e.jsx(q,{type:"submit",children:g.isLast?"Send inn":"Neste"}),e.jsx(s.TertiaryButton,{onClick:k,className:"jkl-spacing-40--left",children:"Avbryt"})]})]}),h&&!v&&e.jsx(r.FeedbackSuccess,{...u})]})})};
2
2
  //# sourceMappingURL=Followup.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Followup.cjs","sources":["../../../../../src/components/feedback/followup/Followup.tsx"],"sourcesContent":["import React, { type FC, useEffect, useRef, useState } from \"react\";\nimport {\n PrimaryButton,\n SecondaryButton,\n TertiaryButton,\n} from \"../../button/Button.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport type { FollowupProps } from \"../types.js\";\nimport { getQuestionFromType } from \"../utils.js\";\nimport { FollowUpProvider } from \"./followupContext.js\";\nimport { useFollowup } from \"./useFollowup.js\";\n\nconst defaultSuccessMessage = {\n title: \"Takk, igjen!\",\n children:\n \"Vi setter pris på at du tok deg tid til å svare på flere spørsmål. Det hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem.\",\n};\n\nexport const Followup: FC<FollowupProps> = ({\n questions,\n successMessage = defaultSuccessMessage,\n onSubmit,\n}) => {\n const [noThanks, setNoThanks] = useState(false);\n const focusRef = useRef<HTMLParagraphElement>(null);\n const followupState = useFollowup(questions, onSubmit);\n const { handleAbort, handleNext, step, submitted } = followupState;\n const {\n followupStarted,\n setFollowupStarted,\n setFollowupSubmitted,\n contactSubmitted,\n landmarkLabel,\n } = useFeedbackContext();\n\n useEffect(() => {\n if (step.number === 0) {\n return;\n }\n focusRef.current?.focus();\n }, [step]);\n\n useEffect(() => {\n setFollowupSubmitted(submitted);\n }, [submitted, setFollowupSubmitted]);\n\n const QuestionComponent = getQuestionFromType(questions[step.number].type);\n const Button = step.isLast ? PrimaryButton : SecondaryButton;\n\n if (noThanks) {\n return null;\n }\n\n return (\n <div aria-live=\"polite\">\n <FollowUpProvider state={followupState}>\n {!followupStarted && (\n <div className=\"jkl-feedback__fade-in\">\n <p className=\"jkl-heading-4 jkl-spacing-xl--top jkl-spacing-xs--bottom\">\n Har du tid til å svare på noen flere spørsmål?\n </p>\n <p className=\"jkl-body jkl-spacing-xl--bottom\">\n Det tar kun et minutt, og hjelper oss å lage bedre\n løsninger for deg.\n </p>\n <PrimaryButton\n onClick={() => setFollowupStarted(true)}\n className=\"jkl-spacing-xl--right\"\n >\n Jeg har tid!\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>\n Nei takk\n </TertiaryButton>\n </div>\n )}\n {!submitted && followupStarted && (\n <form\n onSubmit={handleNext}\n className=\"jkl-feedback__fade-in\"\n aria-label={landmarkLabel}\n >\n <p\n className=\"jkl-feedback__step-counter\"\n ref={focusRef}\n >\n Steg {step.number + 1} av {questions.length}\n </p>\n <QuestionComponent\n {...questions[step.number]}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n key={step.number}\n />\n <div className=\"jkl-spacing-xl--top\" aria-live=\"off\">\n <Button type=\"submit\">\n {step.isLast ? \"Send inn\" : \"Neste\"}\n </Button>\n <TertiaryButton\n onClick={handleAbort}\n className=\"jkl-spacing-xl--left\"\n >\n Avbryt\n </TertiaryButton>\n </div>\n </form>\n )}\n {submitted && !contactSubmitted && (\n <FeedbackSuccess {...successMessage} />\n )}\n </FollowUpProvider>\n </div>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","questions","successMessage","onSubmit","noThanks","setNoThanks","useState","focusRef","useRef","followupState","useFollowup","handleAbort","handleNext","step","submitted","followupStarted","setFollowupStarted","setFollowupSubmitted","contactSubmitted","landmarkLabel","useFeedbackContext","useEffect","number","_a","current","focus","QuestionComponent","getQuestionFromType","type","Button","isLast","PrimaryButton","SecondaryButton","jsxs","FollowUpProvider","state","className","jsx","onClick","TertiaryButton","ref","length","createElement","autoFocus","key","FeedbackSuccess"],"mappings":"iVAaMA,EAAwB,CAC1BC,MAAO,eACPC,SACI,0KAGmC,EACvCC,UAAAA,EACAC,eAAAA,EAAiBJ,EACjBK,SAAAA,MAEA,MAAOC,EAAUC,GAAeC,EAAAA,UAAS,GACnCC,EAAWC,SAA6B,MACxCC,EAAgBC,EAAAA,YAAYT,EAAWE,IACrCQ,YAAAA,EAAaC,WAAAA,EAAYC,KAAAA,EAAMC,UAAAA,GAAcL,GAEjDM,gBAAAA,EACAC,mBAAAA,EACAC,qBAAAA,EACAC,iBAAAA,EACAC,cAAAA,GACAC,uBAEJC,EAAAA,WAAU,WACc,IAAhBR,EAAKS,SAGT,OAAAC,EAAAhB,EAASiB,UAATD,EAAkBE,WACnB,CAACZ,IAEJQ,EAAAA,WAAU,KACNJ,EAAqBH,EAAS,GAC/B,CAACA,EAAWG,IAEf,MAAMS,EAAoBC,EAAAA,oBAAoB1B,EAAUY,EAAKS,QAAQM,MAC/DC,EAAShB,EAAKiB,OAASC,EAAgBA,cAAAC,EAAAA,gBAE7C,OAAI5B,EACO,WAIN,MAAI,CAAA,YAAU,SACXJ,SAACiC,EAAAA,KAAAC,mBAAA,CAAiBC,MAAO1B,EACpBT,SAAA,EAACe,GACEkB,EAAAA,KAAC,MAAI,CAAAG,UAAU,wBACXpC,SAAA,CAACqC,EAAAA,IAAA,IAAA,CAAED,UAAU,2DAA2DpC,SAExE,mDACCqC,EAAAA,IAAA,IAAA,CAAED,UAAU,kCAAkCpC,SAG/C,0EACAqC,EAAAA,IAACN,EAAAA,cAAA,CACGO,QAAS,IAAMtB,GAAmB,GAClCoB,UAAU,wBACbpC,SAAA,uBAGAuC,EAAAA,eAAe,CAAAD,QAAS,IAAMjC,GAAY,GAAOL,SAElD,iBAGNc,GAAaC,GACXkB,EAAAA,KAAC,OAAA,CACG9B,SAAUS,EACVwB,UAAU,wBACV,aAAYjB,EAEZnB,SAAA,CAAAiC,EAAAA,KAAC,IAAA,CACGG,UAAU,6BACVI,IAAKjC,EACRP,SAAA,CAAA,QACSa,EAAKS,OAAS,EAAE,OAAKrB,EAAUwC,UAEzCC,EAAAA,cAAChB,EAAA,IACOzB,EAAUY,EAAKS,QAEnBqB,WAAS,EACTC,IAAK/B,EAAKS,SAEbW,EAAAA,KAAA,MAAA,CAAIG,UAAU,sBAAsB,YAAU,MAC3CpC,SAAA,CAAAqC,MAACR,GAAOD,KAAK,SACR5B,SAAKa,EAAAiB,OAAS,WAAa,UAEhCO,EAAAA,IAACE,EAAAA,eAAA,CACGD,QAAS3B,EACTyB,UAAU,uBACbpC,SAAA,iBAMZc,IAAcI,GACVmB,EAAAA,IAAAQ,EAAAA,gBAAA,IAAoB3C,QAGjC"}
1
+ {"version":3,"file":"Followup.cjs","sources":["../../../../../src/components/feedback/followup/Followup.tsx"],"sourcesContent":["import React, { type FC, useEffect, useRef, useState } from \"react\";\nimport {\n PrimaryButton,\n SecondaryButton,\n TertiaryButton,\n} from \"../../button/Button.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport type { FollowupProps } from \"../types.js\";\nimport { getQuestionFromType } from \"../utils.js\";\nimport { FollowUpProvider } from \"./followupContext.js\";\nimport { useFollowup } from \"./useFollowup.js\";\n\nconst defaultSuccessMessage = {\n title: \"Takk, igjen!\",\n children:\n \"Vi setter pris på at du tok deg tid til å svare på flere spørsmål. Det hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem.\",\n};\n\nexport const Followup: FC<FollowupProps> = ({\n questions,\n successMessage = defaultSuccessMessage,\n onSubmit,\n}) => {\n const [noThanks, setNoThanks] = useState(false);\n const focusRef = useRef<HTMLParagraphElement>(null);\n const followupState = useFollowup(questions, onSubmit);\n const { handleAbort, handleNext, step, submitted } = followupState;\n const {\n followupStarted,\n setFollowupStarted,\n setFollowupSubmitted,\n contactSubmitted,\n landmarkLabel,\n } = useFeedbackContext();\n\n useEffect(() => {\n if (step.number === 0) {\n return;\n }\n focusRef.current?.focus();\n }, [step]);\n\n useEffect(() => {\n setFollowupSubmitted(submitted);\n }, [submitted, setFollowupSubmitted]);\n\n const QuestionComponent = getQuestionFromType(questions[step.number].type);\n const Button = step.isLast ? PrimaryButton : SecondaryButton;\n\n if (noThanks) {\n return null;\n }\n\n return (\n <div aria-live=\"polite\">\n <FollowUpProvider state={followupState}>\n {!followupStarted && (\n <div className=\"jkl-feedback__fade-in\">\n <p className=\"jkl-heading-4 jkl-spacing-40--top jkl-spacing-8--bottom\">\n Har du tid til å svare på noen flere spørsmål?\n </p>\n <p className=\"jkl-body jkl-spacing-40--bottom\">\n Det tar kun et minutt, og hjelper oss å lage bedre\n løsninger for deg.\n </p>\n <PrimaryButton\n onClick={() => setFollowupStarted(true)}\n className=\"jkl-spacing-40--right\"\n >\n Jeg har tid!\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>\n Nei takk\n </TertiaryButton>\n </div>\n )}\n {!submitted && followupStarted && (\n <form\n onSubmit={handleNext}\n className=\"jkl-feedback__fade-in\"\n aria-label={landmarkLabel}\n >\n <p\n className=\"jkl-feedback__step-counter\"\n ref={focusRef}\n >\n Steg {step.number + 1} av {questions.length}\n </p>\n <QuestionComponent\n {...questions[step.number]}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n key={step.number}\n />\n <div className=\"jkl-spacing-40--top\" aria-live=\"off\">\n <Button type=\"submit\">\n {step.isLast ? \"Send inn\" : \"Neste\"}\n </Button>\n <TertiaryButton\n onClick={handleAbort}\n className=\"jkl-spacing-40--left\"\n >\n Avbryt\n </TertiaryButton>\n </div>\n </form>\n )}\n {submitted && !contactSubmitted && (\n <FeedbackSuccess {...successMessage} />\n )}\n </FollowUpProvider>\n </div>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","questions","successMessage","onSubmit","noThanks","setNoThanks","useState","focusRef","useRef","followupState","useFollowup","handleAbort","handleNext","step","submitted","followupStarted","setFollowupStarted","setFollowupSubmitted","contactSubmitted","landmarkLabel","useFeedbackContext","useEffect","number","current","focus","QuestionComponent","getQuestionFromType","type","Button","isLast","PrimaryButton","SecondaryButton","jsxs","FollowUpProvider","state","className","jsx","onClick","TertiaryButton","ref","length","createElement","autoFocus","key","FeedbackSuccess"],"mappings":"iVAaMA,EAAwB,CAC1BC,MAAO,eACPC,SACI,0KAGmC,EACvCC,UAAAA,EACAC,eAAAA,EAAiBJ,EACjBK,SAAAA,MAEA,MAAOC,EAAUC,GAAeC,EAAAA,UAAS,GACnCC,EAAWC,SAA6B,MACxCC,EAAgBC,EAAAA,YAAYT,EAAWE,IACrCQ,YAAAA,EAAaC,WAAAA,EAAYC,KAAAA,EAAMC,UAAAA,GAAcL,GAEjDM,gBAAAA,EACAC,mBAAAA,EACAC,qBAAAA,EACAC,iBAAAA,EACAC,cAAAA,GACAC,uBAEJC,EAAAA,WAAU,KACc,IAAhBR,EAAKS,QAGTf,EAASgB,SAASC,OAAM,GACzB,CAACX,IAEJQ,EAAAA,WAAU,KACNJ,EAAqBH,EAAS,GAC/B,CAACA,EAAWG,IAEf,MAAMQ,EAAoBC,EAAAA,oBAAoBzB,EAAUY,EAAKS,QAAQK,MAC/DC,EAASf,EAAKgB,OAASC,EAAgBA,cAAAC,EAAAA,gBAE7C,OAAI3B,EACO,WAIN,MAAI,CAAA,YAAU,SACXJ,SAACgC,EAAAA,KAAAC,mBAAA,CAAiBC,MAAOzB,EACpBT,SAAA,EAACe,GACEiB,EAAAA,KAAC,MAAI,CAAAG,UAAU,wBACXnC,SAAA,CAACoC,EAAAA,IAAA,IAAA,CAAED,UAAU,0DAA0DnC,SAEvE,mDACCoC,EAAAA,IAAA,IAAA,CAAED,UAAU,kCAAkCnC,SAG/C,0EACAoC,EAAAA,IAACN,EAAAA,cAAA,CACGO,QAAS,IAAMrB,GAAmB,GAClCmB,UAAU,wBACbnC,SAAA,uBAGAsC,EAAAA,eAAe,CAAAD,QAAS,IAAMhC,GAAY,GAAOL,SAElD,iBAGNc,GAAaC,GACXiB,EAAAA,KAAC,OAAA,CACG7B,SAAUS,EACVuB,UAAU,wBACV,aAAYhB,EAEZnB,SAAA,CAAAgC,EAAAA,KAAC,IAAA,CACGG,UAAU,6BACVI,IAAKhC,EACRP,SAAA,CAAA,QACSa,EAAKS,OAAS,EAAE,OAAKrB,EAAUuC,UAEzCC,EAAAA,cAAChB,EAAA,IACOxB,EAAUY,EAAKS,QAEnBoB,WAAS,EACTC,IAAK9B,EAAKS,SAEbU,EAAAA,KAAA,MAAA,CAAIG,UAAU,sBAAsB,YAAU,MAC3CnC,SAAA,CAAAoC,MAACR,GAAOD,KAAK,SACR3B,SAAKa,EAAAgB,OAAS,WAAa,UAEhCO,EAAAA,IAACE,EAAAA,eAAA,CACGD,QAAS1B,EACTwB,UAAU,uBACbnC,SAAA,iBAMZc,IAAcI,GACVkB,EAAAA,IAAAQ,EAAAA,gBAAA,IAAoB1C,QAGjC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useFollowup=(t,u)=>{const[n,s]=e.useState(),[r,o]=e.useState({number:0,question:t[0],isLast:1===t.length}),[a,i]=e.useState(!1),[l,c]=e.useState(!1),[d,v]=e.useState(),b=e.useRef({values:n,submitted:l,onSubmit:u});e.useEffect((()=>{b.current={...b.current,values:n,submitted:l}}),[n,l]);const m=e.useCallback((()=>{!b.current.submitted&&void 0!==b.current.values&&b.current.onSubmit(b.current.values)}),[]);return e.useEffect((()=>{a&&(m(),c(!0))}),[a,m]),e.useEffect((()=>(typeof window<"u"&&window.addEventListener("beforeunload",m),()=>{m(),window.removeEventListener("beforeunload",m)})),[m]),{questions:t,values:n,step:r,currentValue:d,setCurrentValue:v,submitted:l,handleNext:function(e){null==e||e.preventDefault();const u=Array.isArray(d)?d.map((e=>e.value.toString())):null==d?void 0:d.value,n={...r.question,name:r.question.name||r.question.label,value:u};s((e=>[...(null==e?void 0:e.filter((e=>e.name!==n.name)))||[],n])),v(void 0),r.isLast?i(!0):o((e=>{const u=e.number+1;return{number:u,question:t[u],isLast:u+1>=t.length}}))},handleAbort:function(){s(void 0),v(void 0),o({number:0,question:t[0],isLast:1===t.length}),c(!0)}}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useFollowup=(t,u)=>{const[n,s]=e.useState(),[r,o]=e.useState({number:0,question:t[0],isLast:1===t.length}),[a,i]=e.useState(!1),[l,c]=e.useState(!1),[d,b]=e.useState(),m=e.useRef({values:n,submitted:l,onSubmit:u});e.useEffect((()=>{m.current={...m.current,values:n,submitted:l}}),[n,l]);const v=e.useCallback((()=>{!m.current.submitted&&void 0!==m.current.values&&m.current.onSubmit(m.current.values)}),[]);return e.useEffect((()=>{a&&(v(),c(!0))}),[a,v]),e.useEffect((()=>(typeof window<"u"&&window.addEventListener("beforeunload",v),()=>{v(),window.removeEventListener("beforeunload",v)})),[v]),{questions:t,values:n,step:r,currentValue:d,setCurrentValue:b,submitted:l,handleNext:function(e){e?.preventDefault();const u=Array.isArray(d)?d.map((e=>e.value.toString())):d?.value,n={...r.question,name:r.question.name||r.question.label,value:u};s((e=>[...e?.filter((e=>e.name!==n.name))||[],n])),b(void 0),r.isLast?i(!0):o((e=>{const u=e.number+1;return{number:u,question:t[u],isLast:u+1>=t.length}}))},handleAbort:function(){s(void 0),b(void 0),o({number:0,question:t[0],isLast:1===t.length}),c(!0)}}};
2
2
  //# sourceMappingURL=useFollowup.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFollowup.cjs","sources":["../../../../../src/components/feedback/followup/useFollowup.ts"],"sourcesContent":["import {\n type Dispatch,\n type FormEvent,\n type SetStateAction,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport type {\n FeedbackAnswer,\n FeedbackOption,\n FollowupQuestion,\n} from \"../types.js\";\n\ntype CurrentValue =\n | FeedbackOption<string | number>\n | FeedbackOption<string | number>[]\n | undefined;\n\ntype Followup = {\n questions: FollowupQuestion[];\n values: FeedbackAnswer[] | undefined;\n step: {\n number: number;\n question: FollowupQuestion;\n isLast: boolean;\n };\n currentValue: CurrentValue;\n setCurrentValue: Dispatch<SetStateAction<CurrentValue>>;\n submitted: boolean;\n handleNext: () => void;\n handleAbort: () => void;\n};\n\nexport const useFollowup = (\n questions: FollowupQuestion[],\n onSubmit: (a: FeedbackAnswer[]) => void,\n): Followup => {\n const [values, setValues] = useState<FeedbackAnswer[]>();\n const [step, setStep] = useState({\n number: 0,\n question: questions[0],\n isLast: questions.length === 1,\n });\n const [shouldSubmit, setShouldSubmit] = useState(false);\n const [submitted, setSubmitted] = useState(false);\n const [currentValue, setCurrentValue] = useState<\n FeedbackOption | FeedbackOption[]\n >();\n\n // Store info in a ref to facilitate autosubmit on component unmount,\n // or when leaving page\n const followupRef = useRef({\n values,\n submitted,\n onSubmit,\n });\n\n // Keep values in ref updated\n useEffect(() => {\n followupRef.current = {\n ...followupRef.current,\n values,\n submitted,\n };\n }, [values, submitted]);\n\n // General method for submitting info\n const _handleSubmit = useCallback(() => {\n if (\n !followupRef.current.submitted &&\n followupRef.current.values !== undefined\n ) {\n followupRef.current.onSubmit(followupRef.current.values);\n }\n }, []);\n\n // Function for handling going to the next step in the form wizard\n function handleNext(e?: FormEvent<HTMLFormElement>) {\n e?.preventDefault();\n\n const value = Array.isArray(currentValue)\n ? currentValue.map((option) => option.value.toString())\n : currentValue?.value;\n\n const newValue = {\n ...step.question,\n name: step.question.name || step.question.label,\n value,\n };\n\n setValues((oldValues) => {\n const filteredValues =\n oldValues?.filter(\n (oldValue) => oldValue.name !== newValue.name,\n ) || [];\n return [...filteredValues, newValue as FeedbackAnswer];\n });\n setCurrentValue(undefined);\n\n if (step.isLast) {\n setShouldSubmit(true);\n } else {\n setStep((currentStep) => {\n const newStepNum = currentStep.number + 1;\n return {\n number: newStepNum,\n question: questions[newStepNum],\n isLast: newStepNum + 1 >= questions.length,\n };\n });\n }\n }\n\n // Let the user abort without submitting answers\n function handleAbort() {\n setValues(undefined);\n setCurrentValue(undefined);\n setStep({\n number: 0,\n question: questions[0],\n isLast: questions.length === 1,\n });\n setSubmitted(true);\n }\n\n // Submit info after user submits last question\n useEffect(() => {\n if (shouldSubmit) {\n _handleSubmit();\n setSubmitted(true);\n }\n }, [shouldSubmit, _handleSubmit]);\n\n // Submit info if component unmounts or page unloads\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeunload\", _handleSubmit);\n }\n return () => {\n _handleSubmit();\n window.removeEventListener(\"beforeunload\", _handleSubmit);\n };\n }, [_handleSubmit]);\n\n return {\n questions,\n values,\n step,\n currentValue,\n setCurrentValue,\n submitted,\n handleNext,\n handleAbort,\n };\n};\n"],"names":["questions","onSubmit","values","setValues","useState","step","setStep","number","question","isLast","length","shouldSubmit","setShouldSubmit","submitted","setSubmitted","currentValue","setCurrentValue","followupRef","useRef","useEffect","current","_handleSubmit","useCallback","window","addEventListener","removeEventListener","handleNext","e","preventDefault","value","Array","isArray","map","option","toString","newValue","name","label","oldValues","filter","oldValue","currentStep","newStepNum","handleAbort"],"mappings":"6HAmC2B,CACvBA,EACAC,KAEA,MAAOC,EAAQC,GAAaC,cACrBC,EAAMC,GAAWF,WAAS,CAC7BG,OAAQ,EACRC,SAAUR,EAAU,GACpBS,OAA6B,IAArBT,EAAUU,UAEfC,EAAcC,GAAmBR,EAAAA,UAAS,IAC1CS,EAAWC,GAAgBV,EAAAA,UAAS,IACpCW,EAAcC,GAAmBZ,aAMlCa,EAAcC,EAAAA,OAAO,CACvBhB,OAAAA,EACAW,UAAAA,EACAZ,SAAAA,IAIJkB,EAAAA,WAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACflB,OAAAA,EACAW,UAAAA,EACJ,GACD,CAACX,EAAQW,IAGN,MAAAQ,EAAgBC,EAAAA,aAAY,MAEzBL,EAAYG,QAAQP,gBACU,IAA/BI,EAAYG,QAAQlB,QAEpBe,EAAYG,QAAQnB,SAASgB,EAAYG,QAAQlB,OAAM,GAE5D,IAoDHiB,OAAAA,EAAAA,WAAU,KACFR,IACcU,IACdP,GAAa,GACjB,GACD,CAACH,EAAcU,IAGlBF,EAAAA,WAAU,YACKI,OAAW,KACXA,OAAAC,iBAAiB,eAAgBH,GAErC,KACWA,IACPE,OAAAE,oBAAoB,eAAgBJ,EAAa,IAE7D,CAACA,IAEG,CACHrB,UAAAA,EACAE,OAAAA,EACAG,KAAAA,EACAU,aAAAA,EACAC,gBAAAA,EACAH,UAAAA,EACAa,WA1EJ,SAAoBC,GAChB,MAAAA,GAAAA,EAAGC,iBAEH,MAAMC,EAAQC,MAAMC,QAAQhB,GACtBA,EAAaiB,KAAKC,GAAWA,EAAOJ,MAAMK,aAC1C,MAAAnB,OAAA,EAAAA,EAAcc,MAEdM,EAAW,IACV9B,EAAKG,SACR4B,KAAM/B,EAAKG,SAAS4B,MAAQ/B,EAAKG,SAAS6B,MAC1CR,MAAAA,GAGJ1B,GAAWmC,GAKA,KAHH,MAAAA,OAAAA,EAAAA,EAAWC,QACNC,GAAaA,EAASJ,OAASD,EAASC,SACxC,GACkBD,KAE/BnB,OAAgB,GAEZX,EAAKI,OACLG,GAAgB,GAEhBN,GAASmC,IACC,MAAAC,EAAaD,EAAYlC,OAAS,EACjC,MAAA,CACHA,OAAQmC,EACRlC,SAAUR,EAAU0C,GACpBjC,OAAQiC,EAAa,GAAK1C,EAAUU,OACxC,GAER,EA0CAiC,YAtCJ,WACIxC,OAAU,GACVa,OAAgB,GACRV,EAAA,CACJC,OAAQ,EACRC,SAAUR,EAAU,GACpBS,OAA6B,IAArBT,EAAUU,SAEtBI,GAAa,EAAI,EA+BrB"}
1
+ {"version":3,"file":"useFollowup.cjs","sources":["../../../../../src/components/feedback/followup/useFollowup.ts"],"sourcesContent":["import {\n type Dispatch,\n type FormEvent,\n type SetStateAction,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport type {\n FeedbackAnswer,\n FeedbackOption,\n FollowupQuestion,\n} from \"../types.js\";\n\ntype CurrentValue =\n | FeedbackOption<string | number>\n | FeedbackOption<string | number>[]\n | undefined;\n\ntype Followup = {\n questions: FollowupQuestion[];\n values: FeedbackAnswer[] | undefined;\n step: {\n number: number;\n question: FollowupQuestion;\n isLast: boolean;\n };\n currentValue: CurrentValue;\n setCurrentValue: Dispatch<SetStateAction<CurrentValue>>;\n submitted: boolean;\n handleNext: () => void;\n handleAbort: () => void;\n};\n\nexport const useFollowup = (\n questions: FollowupQuestion[],\n onSubmit: (a: FeedbackAnswer[]) => void,\n): Followup => {\n const [values, setValues] = useState<FeedbackAnswer[]>();\n const [step, setStep] = useState({\n number: 0,\n question: questions[0],\n isLast: questions.length === 1,\n });\n const [shouldSubmit, setShouldSubmit] = useState(false);\n const [submitted, setSubmitted] = useState(false);\n const [currentValue, setCurrentValue] = useState<\n FeedbackOption | FeedbackOption[]\n >();\n\n // Store info in a ref to facilitate autosubmit on component unmount,\n // or when leaving page\n const followupRef = useRef({\n values,\n submitted,\n onSubmit,\n });\n\n // Keep values in ref updated\n useEffect(() => {\n followupRef.current = {\n ...followupRef.current,\n values,\n submitted,\n };\n }, [values, submitted]);\n\n // General method for submitting info\n const _handleSubmit = useCallback(() => {\n if (\n !followupRef.current.submitted &&\n followupRef.current.values !== undefined\n ) {\n followupRef.current.onSubmit(followupRef.current.values);\n }\n }, []);\n\n // Function for handling going to the next step in the form wizard\n function handleNext(e?: FormEvent<HTMLFormElement>) {\n e?.preventDefault();\n\n const value = Array.isArray(currentValue)\n ? currentValue.map((option) => option.value.toString())\n : currentValue?.value;\n\n const newValue = {\n ...step.question,\n name: step.question.name || step.question.label,\n value,\n };\n\n setValues((oldValues) => {\n const filteredValues =\n oldValues?.filter(\n (oldValue) => oldValue.name !== newValue.name,\n ) || [];\n return [...filteredValues, newValue as FeedbackAnswer];\n });\n setCurrentValue(undefined);\n\n if (step.isLast) {\n setShouldSubmit(true);\n } else {\n setStep((currentStep) => {\n const newStepNum = currentStep.number + 1;\n return {\n number: newStepNum,\n question: questions[newStepNum],\n isLast: newStepNum + 1 >= questions.length,\n };\n });\n }\n }\n\n // Let the user abort without submitting answers\n function handleAbort() {\n setValues(undefined);\n setCurrentValue(undefined);\n setStep({\n number: 0,\n question: questions[0],\n isLast: questions.length === 1,\n });\n setSubmitted(true);\n }\n\n // Submit info after user submits last question\n useEffect(() => {\n if (shouldSubmit) {\n _handleSubmit();\n setSubmitted(true);\n }\n }, [shouldSubmit, _handleSubmit]);\n\n // Submit info if component unmounts or page unloads\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeunload\", _handleSubmit);\n }\n return () => {\n _handleSubmit();\n window.removeEventListener(\"beforeunload\", _handleSubmit);\n };\n }, [_handleSubmit]);\n\n return {\n questions,\n values,\n step,\n currentValue,\n setCurrentValue,\n submitted,\n handleNext,\n handleAbort,\n };\n};\n"],"names":["questions","onSubmit","values","setValues","useState","step","setStep","number","question","isLast","length","shouldSubmit","setShouldSubmit","submitted","setSubmitted","currentValue","setCurrentValue","followupRef","useRef","useEffect","current","_handleSubmit","useCallback","window","addEventListener","removeEventListener","handleNext","e","preventDefault","value","Array","isArray","map","option","toString","newValue","name","label","oldValues","filter","oldValue","currentStep","newStepNum","handleAbort"],"mappings":"6HAmC2B,CACvBA,EACAC,KAEA,MAAOC,EAAQC,GAAaC,cACrBC,EAAMC,GAAWF,WAAS,CAC7BG,OAAQ,EACRC,SAAUR,EAAU,GACpBS,OAA6B,IAArBT,EAAUU,UAEfC,EAAcC,GAAmBR,EAAAA,UAAS,IAC1CS,EAAWC,GAAgBV,EAAAA,UAAS,IACpCW,EAAcC,GAAmBZ,aAMlCa,EAAcC,EAAAA,OAAO,CACvBhB,OAAAA,EACAW,UAAAA,EACAZ,SAAAA,IAIJkB,EAAAA,WAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACflB,OAAAA,EACAW,UAAAA,EACJ,GACD,CAACX,EAAQW,IAGN,MAAAQ,EAAgBC,EAAAA,aAAY,MAEzBL,EAAYG,QAAQP,gBACU,IAA/BI,EAAYG,QAAQlB,QAEpBe,EAAYG,QAAQnB,SAASgB,EAAYG,QAAQlB,OAAM,GAE5D,IAoDHiB,OAAAA,EAAAA,WAAU,KACFR,IACcU,IACdP,GAAa,GACjB,GACD,CAACH,EAAcU,IAGlBF,EAAAA,WAAU,YACKI,OAAW,KACXA,OAAAC,iBAAiB,eAAgBH,GAErC,KACWA,IACPE,OAAAE,oBAAoB,eAAgBJ,EAAa,IAE7D,CAACA,IAEG,CACHrB,UAAAA,EACAE,OAAAA,EACAG,KAAAA,EACAU,aAAAA,EACAC,gBAAAA,EACAH,UAAAA,EACAa,WA1EJ,SAAoBC,GAChBA,GAAGC,iBAEH,MAAMC,EAAQC,MAAMC,QAAQhB,GACtBA,EAAaiB,KAAKC,GAAWA,EAAOJ,MAAMK,aAC1CnB,GAAcc,MAEdM,EAAW,IACV9B,EAAKG,SACR4B,KAAM/B,EAAKG,SAAS4B,MAAQ/B,EAAKG,SAAS6B,MAC1CR,MAAAA,GAGJ1B,GAAWmC,GAKA,IAHHA,GAAWC,QACNC,GAAaA,EAASJ,OAASD,EAASC,QACxC,GACkBD,KAE/BnB,OAAgB,GAEZX,EAAKI,OACLG,GAAgB,GAEhBN,GAASmC,IACC,MAAAC,EAAaD,EAAYlC,OAAS,EACjC,MAAA,CACHA,OAAQmC,EACRlC,SAAUR,EAAU0C,GACpBjC,OAAQiC,EAAa,GAAK1C,EAAUU,OACxC,GAER,EA0CAiC,YAtCJ,WACIxC,OAAU,GACVa,OAAgB,GACRV,EAAA,CACJC,OAAQ,EACRC,SAAUR,EAAU,GACpBS,OAA6B,IAArBT,EAAUU,SAEtBI,GAAa,EAAI,EA+BrB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../../../clsx-E3yX_9sL.cjs"),s=require("react"),i=require("../../../hooks/useAnimatedHeight/useAnimatedHeight.cjs"),r=require("../../button/Button.cjs"),n=require("../FeedbackSuccess.cjs"),a=require("../feedbackContext.cjs"),o=require("../questions/AddonQuestion.cjs"),u=require("../utils.cjs"),l=require("./mainQuestionContext.cjs"),c=require("./useMainQuestion.cjs"),d={title:"Takk for tilbakemeldingen!",children:"Husk at vi ikke kan besvare meldinger fra dette skjemaet. Kontakt gjerne din forsikringsrådgiver om du har flere spørsmål."};exports.MainQuestion=({label:b,options:j,type:m,addOnQuestion:k,successMessage:p=d,helpLabel:x,onSubmit:h})=>{const g=c.useMainQuestion(h),{setFeedbackSubmitted:f,contactSubmitted:v,landmarkLabel:q}=a.useFeedbackContext(),{handleSubmit:y,currentValue:S,setCurrentValue:Q,submitted:A}=g,[C]=i.useAnimatedHeight(void 0!==S);s.useEffect((()=>{f(A)}),[A,f]);const F=u.getQuestionFromType(m);return e.jsxs(e.Fragment,{children:[!A&&e.jsx(l.MainQuestionContextProvider,{state:g,children:e.jsxs("form",{onSubmit:y,"aria-label":q,children:[e.jsx(F,{label:b,options:j,helpLabel:x}),e.jsxs("div",{ref:C,className:t.clsx({"jkl-feedback__submit-wrapper":!0,"jkl-feedback__submit-wrapper--hidden":void 0===S}),children:[k&&e.jsx(o.AddonQuestion,{helpLabel:"object"==typeof k?k.helpLabel:void 0,label:"object"==typeof k?k.label:void 0}),e.jsxs("div",{className:"jkl-feedback__buttons jkl-spacing-xl--top",children:[e.jsx(r.PrimaryButton,{className:"jkl-spacing-xl--right",children:"Send"}),e.jsx(r.TertiaryButton,{type:"button",onClick:()=>Q(void 0),children:"Avbryt"})]})]})]})}),A&&!v&&e.jsx(n.FeedbackSuccess,{...p})]})};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../../../clsx-E3yX_9sL.cjs"),s=require("react"),i=require("../../../hooks/useAnimatedHeight/useAnimatedHeight.cjs"),r=require("../../button/Button.cjs"),n=require("../FeedbackSuccess.cjs"),a=require("../feedbackContext.cjs"),o=require("../questions/AddonQuestion.cjs"),u=require("../utils.cjs"),c=require("./mainQuestionContext.cjs"),l=require("./useMainQuestion.cjs"),d={title:"Takk for tilbakemeldingen!",children:"Husk at vi ikke kan besvare meldinger fra dette skjemaet. Kontakt gjerne din forsikringsrådgiver om du har flere spørsmål."};exports.MainQuestion=({label:b,options:j,type:m,addOnQuestion:k,successMessage:p=d,helpLabel:h,onSubmit:x})=>{const g=l.useMainQuestion(x),{setFeedbackSubmitted:f,contactSubmitted:v,landmarkLabel:q}=a.useFeedbackContext(),{handleSubmit:y,currentValue:S,setCurrentValue:Q,submitted:A}=g,[C]=i.useAnimatedHeight(void 0!==S);s.useEffect((()=>{f(A)}),[A,f]);const F=u.getQuestionFromType(m);return e.jsxs(e.Fragment,{children:[!A&&e.jsx(c.MainQuestionContextProvider,{state:g,children:e.jsxs("form",{onSubmit:y,"aria-label":q,children:[e.jsx(F,{label:b,options:j,helpLabel:h}),e.jsxs("div",{ref:C,className:t.clsx({"jkl-feedback__submit-wrapper":!0,"jkl-feedback__submit-wrapper--hidden":void 0===S}),children:[k&&e.jsx(o.AddonQuestion,{helpLabel:"object"==typeof k?k.helpLabel:void 0,label:"object"==typeof k?k.label:void 0}),e.jsxs("div",{className:"jkl-feedback__buttons jkl-spacing-40--top",children:[e.jsx(r.PrimaryButton,{className:"jkl-spacing-40--right",children:"Send"}),e.jsx(r.TertiaryButton,{type:"button",onClick:()=>Q(void 0),children:"Avbryt"})]})]})]})}),A&&!v&&e.jsx(n.FeedbackSuccess,{...p})]})};
2
2
  //# sourceMappingURL=MainQuestion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MainQuestion.cjs","sources":["../../../../../src/components/feedback/main-question/MainQuestion.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n type ComponentProps,\n type FC,\n type ReactNode,\n useEffect,\n} from \"react\";\nimport { useAnimatedHeight } from \"../../../hooks/useAnimatedHeight/useAnimatedHeight.js\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport type { Feedback } from \"../Feedback.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { AddonQuestion } from \"../questions/AddonQuestion.js\";\nimport type { FeedbackOption, FeedbackType } from \"../types.js\";\nimport { getQuestionFromType } from \"../utils.js\";\nimport { MainQuestionContextProvider } from \"./mainQuestionContext.js\";\nimport { useMainQuestion } from \"./useMainQuestion.js\";\n\nconst defaultSuccessMessage = {\n title: \"Takk for tilbakemeldingen!\",\n children:\n \"Husk at vi ikke kan besvare meldinger fra dette skjemaet. Kontakt gjerne din forsikringsrådgiver om du har flere spørsmål.\",\n};\n\ntype Props = Pick<ComponentProps<typeof Feedback>, \"addOnQuestion\"> & {\n type: \"radio\" | \"smiley\";\n label: string;\n helpLabel?: string;\n options: FeedbackOption[];\n successMessage?: {\n title: string;\n children: ReactNode;\n };\n onSubmit: (value: FeedbackType) => void;\n};\n\nexport const MainQuestion: FC<Props> = ({\n label,\n options,\n type,\n addOnQuestion,\n successMessage = defaultSuccessMessage,\n helpLabel,\n onSubmit,\n}) => {\n const mainQuestionState = useMainQuestion(onSubmit);\n\n const { setFeedbackSubmitted, contactSubmitted, landmarkLabel } =\n useFeedbackContext();\n const { handleSubmit, currentValue, setCurrentValue, submitted } =\n mainQuestionState;\n const [submitWrapperRef] = useAnimatedHeight<HTMLDivElement>(\n currentValue !== undefined,\n );\n\n useEffect(() => {\n setFeedbackSubmitted(submitted);\n }, [submitted, setFeedbackSubmitted]);\n\n const MainQuestionComp = getQuestionFromType(type);\n\n return (\n <>\n {!submitted && (\n <MainQuestionContextProvider state={mainQuestionState}>\n <form onSubmit={handleSubmit} aria-label={landmarkLabel}>\n <MainQuestionComp\n label={label}\n options={options}\n helpLabel={helpLabel}\n />\n <div\n ref={submitWrapperRef}\n className={clsx({\n \"jkl-feedback__submit-wrapper\": true,\n \"jkl-feedback__submit-wrapper--hidden\":\n currentValue === undefined,\n })}\n >\n {addOnQuestion && (\n <AddonQuestion\n helpLabel={\n typeof addOnQuestion === \"object\"\n ? addOnQuestion.helpLabel\n : undefined\n }\n label={\n typeof addOnQuestion === \"object\"\n ? addOnQuestion.label\n : undefined\n }\n />\n )}\n <div className=\"jkl-feedback__buttons jkl-spacing-xl--top\">\n <PrimaryButton className=\"jkl-spacing-xl--right\">\n Send\n </PrimaryButton>\n <TertiaryButton\n type=\"button\"\n onClick={() => setCurrentValue(undefined)}\n >\n Avbryt\n </TertiaryButton>\n </div>\n </div>\n </form>\n </MainQuestionContextProvider>\n )}\n {submitted && !contactSubmitted && (\n <FeedbackSuccess {...successMessage} />\n )}\n </>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","label","options","type","addOnQuestion","successMessage","helpLabel","onSubmit","mainQuestionState","useMainQuestion","setFeedbackSubmitted","contactSubmitted","landmarkLabel","useFeedbackContext","handleSubmit","currentValue","setCurrentValue","submitted","submitWrapperRef","useAnimatedHeight","useEffect","MainQuestionComp","getQuestionFromType","jsxs","Fragment","jsx","MainQuestionContextProvider","state","ref","className","clsx","AddonQuestion","PrimaryButton","TertiaryButton","onClick","FeedbackSuccess"],"mappings":"ofAkBMA,EAAwB,CAC1BC,MAAO,6BACPC,SACI,mJAe+B,EACnCC,MAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,cAAAA,EACAC,eAAAA,EAAiBP,EACjBQ,UAAAA,EACAC,SAAAA,MAEM,MAAAC,EAAoBC,kBAAgBF,IAElCG,qBAAAA,EAAsBC,iBAAAA,EAAkBC,cAAAA,GAC5CC,EAAAA,sBACIC,aAAAA,EAAcC,aAAAA,EAAcC,gBAAAA,EAAiBC,UAAAA,GACjDT,GACGU,GAAoBC,EAAAA,uBACN,IAAjBJ,GAGJK,EAAAA,WAAU,KACNV,EAAqBO,EAAS,GAC/B,CAACA,EAAWP,IAET,MAAAW,EAAmBC,sBAAoBnB,GAE7C,OAESoB,EAAAA,KAAAC,WAAA,CAAAxB,SAAA,EAACiB,GACGQ,EAAAA,IAAAC,EAAAA,4BAAA,CAA4BC,MAAOnB,EAChCR,gBAAC,OAAK,CAAAO,SAAUO,EAAc,aAAYF,EACtCZ,SAAA,CAAAyB,EAAAA,IAACJ,EAAA,CACGpB,MAAAA,EACAC,QAAAA,EACAI,UAAAA,IAEJiB,EAAAA,KAAC,MAAA,CACGK,IAAKV,EACLW,UAAWC,EAAAA,KAAK,CACZ,gCAAgC,EAChC,4CACqB,IAAjBf,IAGPf,SAAA,CACGI,GAAAqB,EAAAA,IAACM,EAAAA,cAAA,CACGzB,UAC6B,iBAAlBF,EACDA,EAAcE,eACd,EAEVL,MAC6B,iBAAlBG,EACDA,EAAcH,WACd,IAIlBsB,EAAAA,KAAC,MAAI,CAAAM,UAAU,4CACX7B,SAAA,CAACyB,EAAAA,IAAAO,EAAAA,cAAA,CAAcH,UAAU,wBAAwB7B,SAEjD,SACAyB,EAAAA,IAACQ,EAAAA,eAAA,CACG9B,KAAK,SACL+B,QAAS,IAAMlB,OAAgB,GAClChB,SAAA,sBAQpBiB,IAAcN,GACVc,EAAAA,IAAAU,EAAAA,gBAAA,IAAoB9B,MAE7B"}
1
+ {"version":3,"file":"MainQuestion.cjs","sources":["../../../../../src/components/feedback/main-question/MainQuestion.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n type ComponentProps,\n type FC,\n type ReactNode,\n useEffect,\n} from \"react\";\nimport { useAnimatedHeight } from \"../../../hooks/useAnimatedHeight/useAnimatedHeight.js\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport type { Feedback } from \"../Feedback.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { AddonQuestion } from \"../questions/AddonQuestion.js\";\nimport type { FeedbackOption, FeedbackType } from \"../types.js\";\nimport { getQuestionFromType } from \"../utils.js\";\nimport { MainQuestionContextProvider } from \"./mainQuestionContext.js\";\nimport { useMainQuestion } from \"./useMainQuestion.js\";\n\nconst defaultSuccessMessage = {\n title: \"Takk for tilbakemeldingen!\",\n children:\n \"Husk at vi ikke kan besvare meldinger fra dette skjemaet. Kontakt gjerne din forsikringsrådgiver om du har flere spørsmål.\",\n};\n\ntype Props = Pick<ComponentProps<typeof Feedback>, \"addOnQuestion\"> & {\n type: \"radio\" | \"smiley\";\n label: string;\n helpLabel?: string;\n options: FeedbackOption[];\n successMessage?: {\n title: string;\n children: ReactNode;\n };\n onSubmit: (value: FeedbackType) => void;\n};\n\nexport const MainQuestion: FC<Props> = ({\n label,\n options,\n type,\n addOnQuestion,\n successMessage = defaultSuccessMessage,\n helpLabel,\n onSubmit,\n}) => {\n const mainQuestionState = useMainQuestion(onSubmit);\n\n const { setFeedbackSubmitted, contactSubmitted, landmarkLabel } =\n useFeedbackContext();\n const { handleSubmit, currentValue, setCurrentValue, submitted } =\n mainQuestionState;\n const [submitWrapperRef] = useAnimatedHeight<HTMLDivElement>(\n currentValue !== undefined,\n );\n\n useEffect(() => {\n setFeedbackSubmitted(submitted);\n }, [submitted, setFeedbackSubmitted]);\n\n const MainQuestionComp = getQuestionFromType(type);\n\n return (\n <>\n {!submitted && (\n <MainQuestionContextProvider state={mainQuestionState}>\n <form onSubmit={handleSubmit} aria-label={landmarkLabel}>\n <MainQuestionComp\n label={label}\n options={options}\n helpLabel={helpLabel}\n />\n <div\n ref={submitWrapperRef}\n className={clsx({\n \"jkl-feedback__submit-wrapper\": true,\n \"jkl-feedback__submit-wrapper--hidden\":\n currentValue === undefined,\n })}\n >\n {addOnQuestion && (\n <AddonQuestion\n helpLabel={\n typeof addOnQuestion === \"object\"\n ? addOnQuestion.helpLabel\n : undefined\n }\n label={\n typeof addOnQuestion === \"object\"\n ? addOnQuestion.label\n : undefined\n }\n />\n )}\n <div className=\"jkl-feedback__buttons jkl-spacing-40--top\">\n <PrimaryButton className=\"jkl-spacing-40--right\">\n Send\n </PrimaryButton>\n <TertiaryButton\n type=\"button\"\n onClick={() => setCurrentValue(undefined)}\n >\n Avbryt\n </TertiaryButton>\n </div>\n </div>\n </form>\n </MainQuestionContextProvider>\n )}\n {submitted && !contactSubmitted && (\n <FeedbackSuccess {...successMessage} />\n )}\n </>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","label","options","type","addOnQuestion","successMessage","helpLabel","onSubmit","mainQuestionState","useMainQuestion","setFeedbackSubmitted","contactSubmitted","landmarkLabel","useFeedbackContext","handleSubmit","currentValue","setCurrentValue","submitted","submitWrapperRef","useAnimatedHeight","useEffect","MainQuestionComp","getQuestionFromType","jsxs","Fragment","jsx","MainQuestionContextProvider","state","ref","className","clsx","AddonQuestion","PrimaryButton","TertiaryButton","onClick","FeedbackSuccess"],"mappings":"ofAkBMA,EAAwB,CAC1BC,MAAO,6BACPC,SACI,mJAe+B,EACnCC,MAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,cAAAA,EACAC,eAAAA,EAAiBP,EACjBQ,UAAAA,EACAC,SAAAA,MAEM,MAAAC,EAAoBC,kBAAgBF,IAElCG,qBAAAA,EAAsBC,iBAAAA,EAAkBC,cAAAA,GAC5CC,EAAAA,sBACIC,aAAAA,EAAcC,aAAAA,EAAcC,gBAAAA,EAAiBC,UAAAA,GACjDT,GACGU,GAAoBC,EAAAA,uBACN,IAAjBJ,GAGJK,EAAAA,WAAU,KACNV,EAAqBO,EAAS,GAC/B,CAACA,EAAWP,IAET,MAAAW,EAAmBC,sBAAoBnB,GAE7C,OAESoB,EAAAA,KAAAC,WAAA,CAAAxB,SAAA,EAACiB,GACGQ,EAAAA,IAAAC,EAAAA,4BAAA,CAA4BC,MAAOnB,EAChCR,gBAAC,OAAK,CAAAO,SAAUO,EAAc,aAAYF,EACtCZ,SAAA,CAAAyB,EAAAA,IAACJ,EAAA,CACGpB,MAAAA,EACAC,QAAAA,EACAI,UAAAA,IAEJiB,EAAAA,KAAC,MAAA,CACGK,IAAKV,EACLW,UAAWC,EAAAA,KAAK,CACZ,gCAAgC,EAChC,4CACqB,IAAjBf,IAGPf,SAAA,CACGI,GAAAqB,EAAAA,IAACM,EAAAA,cAAA,CACGzB,UAC6B,iBAAlBF,EACDA,EAAcE,eACd,EAEVL,MAC6B,iBAAlBG,EACDA,EAAcH,WACd,IAIlBsB,EAAAA,KAAC,MAAI,CAAAM,UAAU,4CACX7B,SAAA,CAACyB,EAAAA,IAAAO,EAAAA,cAAA,CAAcH,UAAU,wBAAwB7B,SAEjD,SACAyB,EAAAA,IAACQ,EAAAA,eAAA,CACG9B,KAAK,SACL+B,QAAS,IAAMlB,OAAgB,GAClChB,SAAA,sBAQpBiB,IAAcN,GACVc,EAAAA,IAAAU,EAAAA,gBAAA,IAAoB9B,MAE7B"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useMainQuestion=t=>{const[u,s]=e.useState(),[r,a]=e.useState(),[n,i]=e.useState(!1),o=e.useRef({onSubmit:t,currentValue:u,message:r,submitted:n});e.useEffect((()=>{o.current={...o.current,onSubmit:t,currentValue:u,message:r,submitted:n}}),[t,u,r,n]);const l=e.useCallback(((e=!0)=>{const{message:t,currentValue:u,submitted:s,onSubmit:r}=o.current;if(!s&&void 0!==u){r({feedbackValue:Array.isArray(u)?u.map((e=>e.value)):null==u?void 0:u.value,intentionalSubmit:e,...e&&t?{message:t}:{}})}}),[]),c=e.useCallback((()=>l(!1)),[l]);return e.useEffect((()=>(typeof window<"u"&&window.addEventListener("beforeunload",c),()=>{c(),window.removeEventListener("beforeunload",c)})),[c]),{currentValue:u,setCurrentValue:s,message:r,setMessage:a,submitted:n,handleSubmit:e=>{e.preventDefault(),l(),i(!0)}}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useMainQuestion=t=>{const[u,s]=e.useState(),[r,a]=e.useState(),[n,i]=e.useState(!1),o=e.useRef({onSubmit:t,currentValue:u,message:r,submitted:n});e.useEffect((()=>{o.current={...o.current,onSubmit:t,currentValue:u,message:r,submitted:n}}),[t,u,r,n]);const l=e.useCallback(((e=!0)=>{const{message:t,currentValue:u,submitted:s,onSubmit:r}=o.current;if(!s&&void 0!==u){r({feedbackValue:Array.isArray(u)?u.map((e=>e.value)):u?.value,intentionalSubmit:e,...e&&t?{message:t}:{}})}}),[]),c=e.useCallback((()=>l(!1)),[l]);return e.useEffect((()=>(typeof window<"u"&&window.addEventListener("beforeunload",c),()=>{c(),window.removeEventListener("beforeunload",c)})),[c]),{currentValue:u,setCurrentValue:s,message:r,setMessage:a,submitted:n,handleSubmit:e=>{e.preventDefault(),l(),i(!0)}}};
2
2
  //# sourceMappingURL=useMainQuestion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMainQuestion.cjs","sources":["../../../../../src/components/feedback/main-question/useMainQuestion.ts"],"sourcesContent":["import {\n type Dispatch,\n type FormEventHandler,\n type SetStateAction,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport type { FeedbackOption, FeedbackType } 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":["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":"iIA0BIA,IAEA,MAAOC,EAAcC,GAAmBC,cAGjCC,EAASC,GAAcF,cACvBG,EAAWC,GAAgBJ,EAAAA,UAAS,GAErCK,EAAcC,EAAAA,OAAO,CACvBT,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,IAGJI,EAAAA,WAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACfX,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,EACJ,GACD,CAACN,EAAUC,EAAcG,EAASE,IAErC,MAAMM,EAAgBC,EAAAA,aAAY,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,OAAAA,EAAAA,EAAcmB,MAGhBN,kBAAAA,KACIA,GAAqBV,EAAU,CAAEA,QAAAA,GAAY,CAAA,GACpD,IAEN,IAEGiB,EAAaR,EAAAA,aAAY,IAAMD,GAAc,IAAQ,CAACA,IAE5DF,OAAAA,EAAAA,WAAU,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.cjs","sources":["../../../../../src/components/feedback/main-question/useMainQuestion.ts"],"sourcesContent":["import {\n type Dispatch,\n type FormEventHandler,\n type SetStateAction,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport type { FeedbackOption, FeedbackType } 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":["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":"iIA0BIA,IAEA,MAAOC,EAAcC,GAAmBC,cAGjCC,EAASC,GAAcF,cACvBG,EAAWC,GAAgBJ,EAAAA,UAAS,GAErCK,EAAcC,EAAAA,OAAO,CACvBT,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,IAGJI,EAAAA,WAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACfX,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,EACJ,GACD,CAACN,EAAUC,EAAcG,EAASE,IAErC,MAAMM,EAAgBC,EAAAA,aAAY,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,GAAcmB,MAGhBN,kBAAAA,KACIA,GAAqBV,EAAU,CAAEA,QAAAA,GAAY,CAAA,GACpD,IAEN,IAEGiB,EAAaR,EAAAA,aAAY,IAAMD,GAAc,IAAQ,CAACA,IAE5DF,OAAAA,EAAAA,WAAU,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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("../../text-area/TextArea.cjs"),n=require("../feedbackContext.cjs"),l=require("../main-question/mainQuestionContext.cjs");exports.AddonQuestion=({helpLabel:a="Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.",label:s})=>{const{counter:i}=n.useFeedbackContext(),o=l.useMainQuestionContext(),[u,c]=r.useState();if(r.useEffect((()=>{var e,r,t;const n=Array.isArray(null==o?void 0:o.currentValue)?null==(e=null==o?void 0:o.currentValue[0].textAreaLabel)?void 0:e.toString():null==(t=null==(r=null==o?void 0:o.currentValue)?void 0:r.textAreaLabel)?void 0:t.toString();c(n||s)}),[null==o?void 0:o.currentValue,s]),!o)return console.error("Addon question must be used inside a MainQuestion context provider"),null;const{message:d,setMessage:b}=o;return e.jsxs(e.Fragment,{children:[void 0!==o.currentValue&&e.jsxs("div",{className:"jkl-sr-only","aria-live":"polite",children:[u," ",a]}),e.jsx(t.TextArea,{startOpen:!0,rows:4,"data-testid":"jkl-feedback__open-question",className:"jkl-spacing-xl--bottom jkl-spacing-xl--top",label:u,labelProps:{srOnly:!0},placeholder:u,helpLabel:a,value:d||"",onChange:e=>b(e.target.value),counter:i})]})};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("../../text-area/TextArea.cjs"),n=require("../feedbackContext.cjs"),s=require("../main-question/mainQuestionContext.cjs");exports.AddonQuestion=({helpLabel:a="Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.",label:i})=>{const{counter:o}=n.useFeedbackContext(),l=s.useMainQuestionContext(),[u,c]=r.useState();if(r.useEffect((()=>{const e=Array.isArray(l?.currentValue)?l?.currentValue[0].textAreaLabel?.toString():l?.currentValue?.textAreaLabel?.toString();c(e||i)}),[l?.currentValue,i]),!l)return console.error("Addon question must be used inside a MainQuestion context provider"),null;const{message:d,setMessage:b}=l;return e.jsxs(e.Fragment,{children:[void 0!==l.currentValue&&e.jsxs("div",{className:"jkl-sr-only","aria-live":"polite",children:[u," ",a]}),e.jsx(t.TextArea,{startOpen:!0,rows:4,"data-testid":"jkl-feedback__open-question",className:"jkl-spacing-40--bottom jkl-spacing-40--top",label:u,labelProps:{srOnly:!0},placeholder:u,helpLabel:a,value:d||"",onChange:e=>b(e.target.value),counter:o})]})};
2
2
  //# sourceMappingURL=AddonQuestion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddonQuestion.cjs","sources":["../../../../../src/components/feedback/questions/AddonQuestion.tsx"],"sourcesContent":["import React, { type ChangeEventHandler, useEffect, useState } from \"react\";\nimport { TextArea } from \"../../text-area/TextArea.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\n\ninterface Props {\n label?: string;\n helpLabel?: string;\n}\n\nexport const AddonQuestion: React.FC<Props> = ({\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 label,\n}) => {\n const { counter } = useFeedbackContext();\n const context = useMainQuestionContext();\n const [dynamicLabel, setDynamicLabel] = useState<string>();\n\n useEffect(() => {\n const labelFromValue = Array.isArray(context?.currentValue)\n ? context?.currentValue[0].textAreaLabel?.toString()\n : context?.currentValue?.textAreaLabel?.toString();\n setDynamicLabel(labelFromValue || label);\n }, [context?.currentValue, label]);\n\n if (!context) {\n console.error(\n \"Addon question must be used inside a MainQuestion context provider\",\n );\n return null;\n }\n\n const { message, setMessage } = context;\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) =>\n setMessage(e.target.value);\n\n return (\n <>\n {context.currentValue !== undefined && (\n <div className=\"jkl-sr-only\" aria-live=\"polite\">\n {dynamicLabel} {helpLabel}\n </div>\n )}\n <TextArea\n startOpen\n rows={4}\n data-testid=\"jkl-feedback__open-question\"\n className=\"jkl-spacing-xl--bottom jkl-spacing-xl--top\"\n label={dynamicLabel}\n labelProps={{ srOnly: true }}\n placeholder={dynamicLabel}\n helpLabel={helpLabel}\n value={message || \"\"}\n onChange={handleChange}\n counter={counter}\n />\n </>\n );\n};\n"],"names":["helpLabel","label","counter","useFeedbackContext","context","useMainQuestionContext","dynamicLabel","setDynamicLabel","useState","useEffect","labelFromValue","Array","isArray","currentValue","_a","textAreaLabel","toString","_c","_b","error","message","setMessage","jsxs","Fragment","children","className","jsx","TextArea","startOpen","rows","labelProps","srOnly","placeholder","value","onChange","e","target"],"mappings":"kSAU8C,EAC1CA,UAAAA,EAAY,uJACZC,MAAAA,MAEM,MAAEC,QAAAA,GAAYC,uBACdC,EAAUC,EAAAA,0BACTC,EAAcC,GAAmBC,aASxC,GAPAC,EAAAA,WAAU,eACN,MAAMC,EAAiBC,MAAMC,QAAQ,MAAAR,SAAAA,EAASS,cACxC,OAAAC,EAAA,MAAAV,SAAAA,EAASS,aAAa,GAAGE,oBAAzBD,EAAAA,EAAwCE,WACxC,OAAAC,EAAA,OAAAC,EAAA,MAAAd,OAAAA,EAAAA,EAASS,mBAATK,EAAAA,EAAuBH,oBAAvB,EAAAE,EAAsCD,WAC5CT,EAAgBG,GAAkBT,EAAK,GACxC,CAAC,MAAAG,OAAAA,EAAAA,EAASS,aAAcZ,KAEtBG,EACO,eAAAe,MACJ,sEAEG,KAGL,MAAEC,QAAAA,EAASC,WAAAA,GAAejB,EAIhC,OAESkB,EAAAA,KAAAC,WAAA,CAAAC,SAAA,MAAyB,IAAzBpB,EAAQS,cACLS,EAAAA,KAAC,OAAIG,UAAU,cAAc,YAAU,SAClCD,SAAA,CAAAlB,EAAa,IAAEN,KAGxB0B,EAAAA,IAACC,EAAAA,SAAA,CACGC,WAAS,EACTC,KAAM,EACN,cAAY,8BACZJ,UAAU,6CACVxB,MAAOK,EACPwB,WAAY,CAAEC,QAAQ,GACtBC,YAAa1B,EACbN,UAAAA,EACAiC,MAAOb,GAAW,GAClBc,SApBmDC,GAC3Dd,EAAWc,EAAEC,OAAOH,OAoBZ/B,QAAAA,MAER"}
1
+ {"version":3,"file":"AddonQuestion.cjs","sources":["../../../../../src/components/feedback/questions/AddonQuestion.tsx"],"sourcesContent":["import React, { type ChangeEventHandler, useEffect, useState } from \"react\";\nimport { TextArea } from \"../../text-area/TextArea.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\n\ninterface Props {\n label?: string;\n helpLabel?: string;\n}\n\nexport const AddonQuestion: React.FC<Props> = ({\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 label,\n}) => {\n const { counter } = useFeedbackContext();\n const context = useMainQuestionContext();\n const [dynamicLabel, setDynamicLabel] = useState<string>();\n\n useEffect(() => {\n const labelFromValue = Array.isArray(context?.currentValue)\n ? context?.currentValue[0].textAreaLabel?.toString()\n : context?.currentValue?.textAreaLabel?.toString();\n setDynamicLabel(labelFromValue || label);\n }, [context?.currentValue, label]);\n\n if (!context) {\n console.error(\n \"Addon question must be used inside a MainQuestion context provider\",\n );\n return null;\n }\n\n const { message, setMessage } = context;\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) =>\n setMessage(e.target.value);\n\n return (\n <>\n {context.currentValue !== undefined && (\n <div className=\"jkl-sr-only\" aria-live=\"polite\">\n {dynamicLabel} {helpLabel}\n </div>\n )}\n <TextArea\n startOpen\n rows={4}\n data-testid=\"jkl-feedback__open-question\"\n className=\"jkl-spacing-40--bottom jkl-spacing-40--top\"\n label={dynamicLabel}\n labelProps={{ srOnly: true }}\n placeholder={dynamicLabel}\n helpLabel={helpLabel}\n value={message || \"\"}\n onChange={handleChange}\n counter={counter}\n />\n </>\n );\n};\n"],"names":["helpLabel","label","counter","useFeedbackContext","context","useMainQuestionContext","dynamicLabel","setDynamicLabel","useState","useEffect","labelFromValue","Array","isArray","currentValue","textAreaLabel","toString","console","error","message","setMessage","jsxs","Fragment","children","className","jsx","TextArea","startOpen","rows","labelProps","srOnly","placeholder","value","onChange","e","target"],"mappings":"kSAU8C,EAC1CA,UAAAA,EAAY,uJACZC,MAAAA,MAEM,MAAEC,QAAAA,GAAYC,uBACdC,EAAUC,EAAAA,0BACTC,EAAcC,GAAmBC,aASxC,GAPAC,EAAAA,WAAU,KACN,MAAMC,EAAiBC,MAAMC,QAAQR,GAASS,cACxCT,GAASS,aAAa,GAAGC,eAAeC,WACxCX,GAASS,cAAcC,eAAeC,WAC5CR,EAAgBG,GAAkBT,EAAK,GACxC,CAACG,GAASS,aAAcZ,KAEtBG,EACO,OAAAY,QAAAC,MACJ,sEAEG,KAGL,MAAEC,QAAAA,EAASC,WAAAA,GAAef,EAIhC,OAESgB,EAAAA,KAAAC,WAAA,CAAAC,SAAA,MAAyB,IAAzBlB,EAAQS,cACLO,EAAAA,KAAC,OAAIG,UAAU,cAAc,YAAU,SAClCD,SAAA,CAAAhB,EAAa,IAAEN,KAGxBwB,EAAAA,IAACC,EAAAA,SAAA,CACGC,WAAS,EACTC,KAAM,EACN,cAAY,8BACZJ,UAAU,6CACVtB,MAAOK,EACPsB,WAAY,CAAEC,QAAQ,GACtBC,YAAaxB,EACbN,UAAAA,EACA+B,MAAOb,GAAW,GAClBc,SApBmDC,GAC3Dd,EAAWc,EAAEC,OAAOH,OAoBZ7B,QAAAA,MAER"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),u=require("../../checkbox/Checkbox.cjs"),t=require("../../input-group/FieldGroup.cjs"),o=require("../followup/followupContext.cjs"),l=require("../main-question/mainQuestionContext.cjs");exports.CheckboxQuestion=({label:n,name:i,options:s,helpLabel:a,autoFocus:c=!1})=>{const d=o.useFollowUpContext(),p=l.useMainQuestionContext(),f=d||p,x=r.useRef(null);r.useEffect((()=>{c&&x.current&&x.current.focus()}),[c]);const b=e=>{const{value:r}=e.target,u=null==s?void 0:s.find((e=>e.value.toString()===r));if(u){if(null==f||!f.currentValue)return void(null==f||f.setCurrentValue([u]));if(Array.isArray(null==f?void 0:f.currentValue)){const e=f.currentValue.find((e=>e===u));e?f.setCurrentValue((r=>r.filter((r=>r!==e)))):f.setCurrentValue((e=>[...e,u]))}}};return f?e.jsx(t.FieldGroup,{labelProps:{variant:"large"},legend:n,helpLabel:a,children:null==s?void 0:s.map(((r,t)=>e.jsx(u.Checkbox,{name:i||n,value:r.value.toString(),onChange:b,ref:0===t?x:void 0,children:r.label},`${n}-${r.value}`)))}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("../../checkbox/Checkbox.cjs"),u=require("../../input-group/FieldGroup.cjs"),o=require("../followup/followupContext.cjs"),n=require("../main-question/mainQuestionContext.cjs");exports.CheckboxQuestion=({label:l,name:i,options:s,helpLabel:a,autoFocus:c=!1})=>{const p=o.useFollowUpContext(),d=n.useMainQuestionContext(),f=p||d,x=r.useRef(null);r.useEffect((()=>{c&&x.current&&x.current.focus()}),[c]);const b=e=>{const{value:r}=e.target,t=s?.find((e=>e.value.toString()===r));if(t){if(!f?.currentValue)return void f?.setCurrentValue([t]);if(Array.isArray(f?.currentValue)){const e=f.currentValue.find((e=>e===t));e?f.setCurrentValue((r=>r.filter((r=>r!==e)))):f.setCurrentValue((e=>[...e,t]))}}};return f?e.jsx(u.FieldGroup,{labelProps:{variant:"large"},legend:l,helpLabel:a,children:s?.map(((r,u)=>e.jsx(t.Checkbox,{name:i||l,value:r.value.toString(),onChange:b,ref:0===u?x:void 0,children:r.label},`${l}-${r.value}`)))}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};
2
2
  //# sourceMappingURL=CheckboxQuestion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxQuestion.cjs","sources":["../../../../../src/components/feedback/questions/CheckboxQuestion.tsx"],"sourcesContent":["import React, { type 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 type { 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]);\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":["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":"2VAOyD,EACrDA,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAEZ,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,SAAyB,MAErCC,EAAAA,WAAU,KACFR,GAAaM,EAAIG,SACjBH,EAAIG,QAAQC,OAAM,GAEvB,CAACV,IAEE,MAAAW,EAAsDC,IAClD,MAAEC,MAAAA,GAAUD,EAAME,OAClBC,EAAiB,MAAAjB,OAAAA,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,SAAAA,EAASc,cAAe,CAChC,MAAAI,EAAQlB,EAAQc,aAAaH,MAC9BC,GAAWA,IAAWF,IAEvBQ,EACQlB,EAAAe,iBAAiBI,GACpBA,EAA+BC,QAC3BR,GAAWA,IAAWM,MAIvBlB,EAAAe,iBAAiBI,GAAc,IAC/BA,EACJT,IAER,CAER,GAEA,OAAKV,EAQDqB,EAAAA,IAACC,EAAAA,WAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQlC,EACRG,UAAAA,EAECgC,SAAS,MAAAjC,OAAAA,EAAAA,EAAAkC,KAAI,CAACf,EAAQgB,IACnBP,EAAAA,IAACQ,EAAAA,SAAA,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.cjs","sources":["../../../../../src/components/feedback/questions/CheckboxQuestion.tsx"],"sourcesContent":["import React, { type 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 type { 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]);\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":["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":"2VAOyD,EACrDA,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAEZ,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,SAAyB,MAErCC,EAAAA,WAAU,KACFR,GAAaM,EAAIG,SACjBH,EAAIG,QAAQC,OAAM,GAEvB,CAACV,IAEE,MAAAW,EAAsDC,IAClD,MAAEC,MAAAA,GAAUD,EAAME,OAClBC,EAAiBjB,GAASkB,MAC3BC,GAAWA,EAAOJ,MAAMK,aAAeL,IAE5C,GAAKE,EAED,CAAA,IAACV,GAASc,aAEV,YADSd,GAAAe,gBAAgB,CAACL,IAI9B,GAAIM,MAAMC,QAAQjB,GAASc,cAAe,CAChC,MAAAI,EAAQlB,EAAQc,aAAaH,MAC9BC,GAAWA,IAAWF,IAEvBQ,EACQlB,EAAAe,iBAAiBI,GACpBA,EAA+BC,QAC3BR,GAAWA,IAAWM,MAIvBlB,EAAAe,iBAAiBI,GAAc,IAC/BA,EACJT,IAER,CAER,GAEA,OAAKV,EAQDqB,EAAAA,IAACC,EAAAA,WAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQlC,EACRG,UAAAA,EAECgC,SAASjC,GAAAkC,KAAI,CAACf,EAAQgB,IACnBP,EAAAA,IAACQ,EAAAA,SAAA,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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),r=require("../../../utilities/validators/isValidEpost/isValidEpost.cjs"),n=require("../../../utilities/validators/isValidTelefonnummer/isValidTelefonnummer.cjs"),a=require("../../button/Button.cjs"),l=require("../../text-input/TextInput.cjs"),s=require("../FeedbackSuccess.cjs"),i=require("../feedbackContext.cjs"),o={title:"Takk for tiden din!",children:"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."};exports.ContactQuestion=({label:u="Kan vi kontakte deg for flere innspill?",sendButtonLabel:c="Sett meg på lista!",withPhone:d=!1,onSubmit:m,successMessage:p=o,children:g})=>{const[k,j]=t.useState(""),[b,f]=t.useState(""),[v,h]=t.useState({}),x=t.useRef(null),S=t.useRef(null),[E,C]=t.useState(!1),[T,y]=t.useState(!1),{contactSubmitted:N,setContactSubmitted:q,landmarkLabel:V}=i.useFeedbackContext(),P="string"==typeof g?"p":"div",B=t.useCallback(((e,t)=>{const a=(e=>e&&""!==e?r.isValidEpost(e)?void 0:"Skriv inn en gyldig e-postadresse":"Du må oppgi e-postadresse for at vi kan kontakte deg")(e),l=(e=>e&&""!==e?n.isValidTelefonnummer(e)?void 0:"Skriv inn et gyldig telefonnummer":"Du må oppgi telefonnummer for at vi kan kontakte deg")(t);return h({email:a,phone:l}),{emailError:a,phoneError:l}}),[]);t.useEffect((()=>{if(E){const{emailError:e,phoneError:t}=B(k,b);!e&&(!d||!t)&&C(!1)}}),[k,b,E,d,B]);const D=e=>t=>e(t.target.value);return T?null:N?e.jsx(s.FeedbackSuccess,{...p}):e.jsxs("form",{className:"jkl-spacing-xl--top",onSubmit:e=>{var t,r;e.preventDefault();const{emailError:n,phoneError:a}=B(k,b);return n?(C(!0),void(null==(t=x.current)||t.focus())):d&&a?(C(!0),void(null==(r=S.current)||r.focus())):(m({email:k,phone:d?b:void 0}),void q(!0))},"aria-label":V,children:[e.jsx("p",{className:"jkl-heading-4 jkl-spacing-xs--bottom",children:u}),g&&e.jsx(P,{className:"jkl-body",children:g}),e.jsx(l.TextInput,{ref:x,className:"jkl-spacing-l--top",label:"E-post",labelProps:{variant:"small"},autoComplete:"email",name:"email",value:k,onChange:D(j),errorLabel:v.email}),d&&e.jsx(l.TextInput,{ref:S,className:"jkl-spacing-l--top",label:"Telefonnummer",labelProps:{variant:"small"},autoComplete:"tel",name:"phone",value:b,onChange:D(f),errorLabel:v.phone}),e.jsxs("div",{className:"jkl-spacing-xl--top",children:[e.jsx(a.PrimaryButton,{type:"submit",className:"jkl-spacing-xl--right",children:c}),e.jsx(a.TertiaryButton,{onClick:()=>y(!0),children:"Nei takk"})]})]})};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),r=require("../../../utilities/validators/isValidEpost/isValidEpost.cjs"),a=require("../../../utilities/validators/isValidTelefonnummer/isValidTelefonnummer.cjs"),n=require("../../button/Button.cjs"),s=require("../../text-input/TextInput.cjs"),i=require("../FeedbackSuccess.cjs"),l=require("../feedbackContext.cjs"),o={title:"Takk for tiden din!",children:"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."};exports.ContactQuestion=({label:u="Kan vi kontakte deg for flere innspill?",sendButtonLabel:c="Sett meg på lista!",withPhone:d=!1,onSubmit:m,successMessage:p=o,children:g})=>{const[k,j]=t.useState(""),[b,f]=t.useState(""),[v,h]=t.useState({}),x=t.useRef(null),S=t.useRef(null),[E,C]=t.useState(!1),[T,y]=t.useState(!1),{contactSubmitted:N,setContactSubmitted:q,landmarkLabel:V}=l.useFeedbackContext(),P="string"==typeof g?"p":"div",B=t.useCallback(((e,t)=>{const n=(e=>e&&""!==e?r.isValidEpost(e)?void 0:"Skriv inn en gyldig e-postadresse":"Du må oppgi e-postadresse for at vi kan kontakte deg")(e),s=(e=>e&&""!==e?a.isValidTelefonnummer(e)?void 0:"Skriv inn et gyldig telefonnummer":"Du må oppgi telefonnummer for at vi kan kontakte deg")(t);return h({email:n,phone:s}),{emailError:n,phoneError:s}}),[]);t.useEffect((()=>{if(E){const{emailError:e,phoneError:t}=B(k,b);!e&&(!d||!t)&&C(!1)}}),[k,b,E,d,B]);const D=e=>t=>e(t.target.value);return T?null:N?e.jsx(i.FeedbackSuccess,{...p}):e.jsxs("form",{className:"jkl-spacing-40--top",onSubmit:e=>{e.preventDefault();const{emailError:t,phoneError:r}=B(k,b);return t?(C(!0),void x.current?.focus()):d&&r?(C(!0),void S.current?.focus()):(m({email:k,phone:d?b:void 0}),void q(!0))},"aria-label":V,children:[e.jsx("p",{className:"jkl-heading-4 jkl-spacing-8--bottom",children:u}),g&&e.jsx(P,{className:"jkl-body",children:g}),e.jsx(s.TextInput,{ref:x,className:"jkl-spacing-24--top",label:"E-post",labelProps:{variant:"small"},autoComplete:"email",name:"email",value:k,onChange:D(j),errorLabel:v.email}),d&&e.jsx(s.TextInput,{ref:S,className:"jkl-spacing-24--top",label:"Telefonnummer",labelProps:{variant:"small"},autoComplete:"tel",name:"phone",value:b,onChange:D(f),errorLabel:v.phone}),e.jsxs("div",{className:"jkl-spacing-40--top",children:[e.jsx(n.PrimaryButton,{type:"submit",className:"jkl-spacing-40--right",children:c}),e.jsx(n.TertiaryButton,{onClick:()=>y(!0),children:"Nei takk"})]})]})};
2
2
  //# sourceMappingURL=ContactQuestion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContactQuestion.cjs","sources":["../../../../../src/components/feedback/questions/ContactQuestion.tsx"],"sourcesContent":["import React, {\n type ChangeEvent,\n type FC,\n useCallback,\n useEffect,\n useRef,\n useState,\n} 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 { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport type { 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 = useCallback((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, validate]);\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","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","useCallback","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":"mcAoCMA,EAAwB,CAC1BC,MAAO,sBACPC,SACI,8MAGiD,EACrDC,MAAAA,EAAQ,0CACRC,gBAAAA,EAAkB,qBAClBC,UAAAA,GAAY,EACZC,SAAAA,EACAC,eAAAA,EAAiBP,EACjBE,SAAAA,MAEA,MAAOM,EAAOC,GAAYC,EAAAA,SAAS,KAC5BC,EAAOC,GAAYF,EAAAA,SAAS,KAC5BG,EAAQC,GAAaJ,EAAAA,SACxB,CAAA,GAEEK,EAAWC,SAAyB,MACpCC,EAAWD,SAAyB,OACnCE,EAAgBC,GAAqBT,EAAAA,UAAS,IAE9CU,EAAUC,GAAeX,EAAAA,UAAS,IACjCY,iBAAAA,EAAkBC,oBAAAA,EAAqBC,cAAAA,GAC3CC,EAAAA,qBAEEC,EAAsC,iBAAbxB,EAAwB,IAAM,MAEvDyB,EAAWC,EAAAA,aAAY,CAACpB,EAAeG,KACnC,MAAAkB,EAlDSrB,IACdA,GAAmB,KAAVA,EAGTsB,EAAAA,aAAatB,QAAd,EACO,oCAHA,uDAgDYuB,CAAcvB,GAC3BwB,EAzCSrB,IACdA,GAAmB,KAAVA,EAGTsB,EAAAA,qBAAqBtB,QAAtB,EACO,oCAHA,uDAuCYuB,CAAcvB,GACjC,OAAAG,EAAU,CAAEN,MAAOqB,EAAYlB,MAAOqB,IAC/B,CAAEH,WAAAA,EAAYG,WAAAA,EAAW,GACjC,IAEHG,EAAAA,WAAU,KACN,GAAIjB,EAAgB,CAChB,MAAQW,WAAAA,EAAYG,WAAAA,GAAeL,EAASnB,EAAOG,IAE9CkB,KAAgBxB,IAAc2B,IAC/Bb,GAAkB,EACtB,IAEL,CAACX,EAAOG,EAAOO,EAAgBb,EAAWsB,IAEvC,MAAAS,EACDC,GACAC,GACGD,EAASC,EAAEC,OAAOC,OAqB1B,OAAIpB,EACO,KAGPE,EACOmB,MAACC,EAAAA,gBAAiB,IAAGnC,IAI5BoC,EAAAA,KAAC,OAAA,CACGC,UAAU,sBACVtC,SA9BsCgC,YAC1CA,EAAEO,iBAEF,MAAQhB,WAAAA,EAAYG,WAAAA,GAAeL,EAASnB,EAAOG,GACnD,OAAIkB,GACAV,GAAkB,QAClB,OAAA2B,EAAA/B,EAASgC,UAATD,EAAkBE,UAGlB3C,GAAa2B,GACbb,GAAkB,QAClB,OAAA8B,EAAAhC,EAAS8B,UAATE,EAAkBD,WAItB1C,EAAS,CAAEE,MAAAA,EAAOG,MAAON,EAAYM,OAAQ,SAC7CY,GAAoB,GAAI,EAepB,aAAYC,EAEZtB,SAAA,CAACuC,EAAAA,IAAA,IAAA,CAAEG,UAAU,uCAAwC1C,SAAMC,IAC1DD,GACGuC,EAAAA,IAACf,EAAgB,CAAAkB,UAAU,WACtB1C,SAAAA,IAITuC,EAAAA,IAACS,EAAAA,UAAA,CACGC,IAAKpC,EACL6B,UAAU,qBACVzC,MAAM,SACNiD,WAAY,CAAEC,QAAS,SACvBC,aAAa,QACbC,KAAK,QACLf,MAAOhC,EACPgD,SAAUpB,EAAa3B,GACvBgD,WAAY5C,EAAOL,QAEtBH,GACGoC,EAAAA,IAACS,EAAAA,UAAA,CACGC,IAAKlC,EACL2B,UAAU,qBACVzC,MAAM,gBACNiD,WAAY,CAAEC,QAAS,SACvBC,aAAa,MACbC,KAAK,QACLf,MAAO7B,EACP6C,SAAUpB,EAAaxB,GACvB6C,WAAY5C,EAAOF,QAI3BgC,EAAAA,KAAC,MAAI,CAAAC,UAAU,sBACX1C,SAAA,CAAAuC,MAACiB,EAAAA,cAAc,CAAAC,KAAK,SAASf,UAAU,wBAClC1C,SACLE,UACCwD,EAAAA,eAAe,CAAAC,QAAS,IAAMxC,GAAY,GAAOnB,SAElD,kBAER"}
1
+ {"version":3,"file":"ContactQuestion.cjs","sources":["../../../../../src/components/feedback/questions/ContactQuestion.tsx"],"sourcesContent":["import React, {\n type ChangeEvent,\n type FC,\n useCallback,\n useEffect,\n useRef,\n useState,\n} 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 { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport type { 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 = useCallback((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, validate]);\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-40--top\"\n onSubmit={handleSubmit}\n aria-label={landmarkLabel}\n >\n <p className=\"jkl-heading-4 jkl-spacing-8--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-24--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-24--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-40--top\">\n <PrimaryButton type=\"submit\" className=\"jkl-spacing-40--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","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","useCallback","emailError","isValidEpost","validateEmail","phoneError","isValidTelefonnummer","validatePhone","useEffect","handleChange","consumer","e","target","value","jsx","FeedbackSuccess","jsxs","className","preventDefault","current","focus","TextInput","ref","labelProps","variant","autoComplete","name","onChange","errorLabel","PrimaryButton","type","TertiaryButton","onClick"],"mappings":"mcAoCMA,EAAwB,CAC1BC,MAAO,sBACPC,SACI,8MAGiD,EACrDC,MAAAA,EAAQ,0CACRC,gBAAAA,EAAkB,qBAClBC,UAAAA,GAAY,EACZC,SAAAA,EACAC,eAAAA,EAAiBP,EACjBE,SAAAA,MAEA,MAAOM,EAAOC,GAAYC,EAAAA,SAAS,KAC5BC,EAAOC,GAAYF,EAAAA,SAAS,KAC5BG,EAAQC,GAAaJ,EAAAA,SACxB,CAAA,GAEEK,EAAWC,SAAyB,MACpCC,EAAWD,SAAyB,OACnCE,EAAgBC,GAAqBT,EAAAA,UAAS,IAE9CU,EAAUC,GAAeX,EAAAA,UAAS,IACjCY,iBAAAA,EAAkBC,oBAAAA,EAAqBC,cAAAA,GAC3CC,EAAAA,qBAEEC,EAAsC,iBAAbxB,EAAwB,IAAM,MAEvDyB,EAAWC,EAAAA,aAAY,CAACpB,EAAeG,KACnC,MAAAkB,EAlDSrB,IACdA,GAAmB,KAAVA,EAGTsB,EAAAA,aAAatB,QAAd,EACO,oCAHA,uDAgDYuB,CAAcvB,GAC3BwB,EAzCSrB,IACdA,GAAmB,KAAVA,EAGTsB,EAAAA,qBAAqBtB,QAAtB,EACO,oCAHA,uDAuCYuB,CAAcvB,GACjC,OAAAG,EAAU,CAAEN,MAAOqB,EAAYlB,MAAOqB,IAC/B,CAAEH,WAAAA,EAAYG,WAAAA,EAAW,GACjC,IAEHG,EAAAA,WAAU,KACN,GAAIjB,EAAgB,CAChB,MAAQW,WAAAA,EAAYG,WAAAA,GAAeL,EAASnB,EAAOG,IAE9CkB,KAAgBxB,IAAc2B,IAC/Bb,GAAkB,EACtB,IAEL,CAACX,EAAOG,EAAOO,EAAgBb,EAAWsB,IAEvC,MAAAS,EACDC,GACAC,GACGD,EAASC,EAAEC,OAAOC,OAqB1B,OAAIpB,EACO,KAGPE,EACOmB,MAACC,EAAAA,gBAAiB,IAAGnC,IAI5BoC,EAAAA,KAAC,OAAA,CACGC,UAAU,sBACVtC,SA9BsCgC,IAC1CA,EAAEO,iBAEF,MAAQhB,WAAAA,EAAYG,WAAAA,GAAeL,EAASnB,EAAOG,GACnD,OAAIkB,GACAV,GAAkB,QAClBJ,EAAS+B,SAASC,SAGlB1C,GAAa2B,GACbb,GAAkB,QAClBF,EAAS6B,SAASC,UAItBzC,EAAS,CAAEE,MAAAA,EAAOG,MAAON,EAAYM,OAAQ,SAC7CY,GAAoB,GAAI,EAepB,aAAYC,EAEZtB,SAAA,CAACuC,EAAAA,IAAA,IAAA,CAAEG,UAAU,sCAAuC1C,SAAMC,IACzDD,GACGuC,EAAAA,IAACf,EAAgB,CAAAkB,UAAU,WACtB1C,SAAAA,IAITuC,EAAAA,IAACO,EAAAA,UAAA,CACGC,IAAKlC,EACL6B,UAAU,sBACVzC,MAAM,SACN+C,WAAY,CAAEC,QAAS,SACvBC,aAAa,QACbC,KAAK,QACLb,MAAOhC,EACP8C,SAAUlB,EAAa3B,GACvB8C,WAAY1C,EAAOL,QAEtBH,GACGoC,EAAAA,IAACO,EAAAA,UAAA,CACGC,IAAKhC,EACL2B,UAAU,sBACVzC,MAAM,gBACN+C,WAAY,CAAEC,QAAS,SACvBC,aAAa,MACbC,KAAK,QACLb,MAAO7B,EACP2C,SAAUlB,EAAaxB,GACvB2C,WAAY1C,EAAOF,QAI3BgC,EAAAA,KAAC,MAAI,CAAAC,UAAU,sBACX1C,SAAA,CAAAuC,MAACe,EAAAA,cAAc,CAAAC,KAAK,SAASb,UAAU,wBAClC1C,SACLE,UACCsD,EAAAA,eAAe,CAAAC,QAAS,IAAMtC,GAAY,GAAOnB,SAElD,kBAER"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),o=require("../../radio-button/RadioButton.cjs"),t=require("../../radio-button/RadioButtonGroup.cjs"),l=require("../followup/followupContext.cjs"),n=require("../main-question/mainQuestionContext.cjs");exports.RadioQuestion=({label:r,name:i,options:a,helpLabel:s,autoFocus:d=!1})=>{const c=l.useFollowUpContext(),v=n.useMainQuestionContext(),p=c||v,b=u.useId(),g=(null==a?void 0:a.length)||0,x=u.useRef(null);u.useEffect((()=>{d&&x.current&&x.current.focus()}),[d]);const f=u.useMemo((()=>{var e;return Array.isArray(null==p?void 0:p.currentValue)?null==p?void 0:p.currentValue[0].value.toString():null==(e=null==p?void 0:p.currentValue)?void 0:e.value.toString()}),[null==p?void 0:p.currentValue]);return p?e.jsx(t.RadioButtonGroup,{legend:r,labelProps:{variant:"large"},name:`${b}-${i||r}`,inline:g<3,value:f||"",onChange:e=>{const u=null==a?void 0:a.find((u=>u.value.toString()===e.target.value));null==p||p.setCurrentValue(u)},helpLabel:s,children:null==a?void 0:a.map(((u,t)=>e.jsx(o.RadioButton,{ref:0===t?x:void 0,label:u.label,value:String(u.value)},`${b}-${i||r}-${u.value}`)))}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),r=require("../../radio-button/RadioButton.cjs"),o=require("../../radio-button/RadioButtonGroup.cjs"),u=require("../followup/followupContext.cjs"),n=require("../main-question/mainQuestionContext.cjs");exports.RadioQuestion=({label:a,name:l,options:i,helpLabel:s,autoFocus:c=!1})=>{const d=u.useFollowUpContext(),p=n.useMainQuestionContext(),b=d||p,v=t.useId(),g=i?.length||0,x=t.useRef(null);t.useEffect((()=>{c&&x.current&&x.current.focus()}),[c]);const f=t.useMemo((()=>Array.isArray(b?.currentValue)?b?.currentValue[0].value.toString():b?.currentValue?.value.toString()),[b?.currentValue]);return b?e.jsx(o.RadioButtonGroup,{legend:a,labelProps:{variant:"large"},name:`${v}-${l||a}`,inline:g<3,value:f||"",onChange:e=>{const t=i?.find((t=>t.value.toString()===e.target.value));b?.setCurrentValue(t)},helpLabel:s,children:i?.map(((t,o)=>e.jsx(r.RadioButton,{ref:0===o?x:void 0,label:t.label,value:String(t.value)},`${v}-${l||a}-${t.value}`)))}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};
2
2
  //# sourceMappingURL=RadioQuestion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioQuestion.cjs","sources":["../../../../../src/components/feedback/questions/RadioQuestion.tsx"],"sourcesContent":["import React, {\n type 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 type { 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]);\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":["label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","numOptions","length","ref","useRef","useEffect","current","focus","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":"sWAasD,EAClDA,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAEZ,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,EAAAA,QAELC,GAAa,MAAAV,OAAAA,EAAAA,EAASW,SAAU,EAEhCC,EAAMC,SAAyB,MACrCC,EAAAA,WAAU,KACFZ,GAAaU,EAAIG,SACjBH,EAAIG,QAAQC,OAAM,GAEvB,CAACd,IAEE,MAOAe,EAAgBC,EAAAA,SAClB,WACI,OAAAC,MAAMC,QAAQ,MAAAb,OAAAA,EAAAA,EAASc,cACjB,MAAAd,OAAAA,EAAAA,EAASc,aAAa,GAAGC,MAAMC,WAC/B,OAAAC,EAAA,MAAAjB,OAAAA,EAAAA,EAASc,mBAAT,EAAAG,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAhB,OAAAA,EAAAA,EAASc,eAGd,OAAKd,EAQDkB,EAAAA,IAACC,EAAAA,iBAAA,CACGC,OAAQ7B,EACR8B,WAAY,CAAEC,QAAS,SACvB9B,KAAM,GAAGS,KAAMT,GAAQD,IACvBgC,OAAQpB,EAAa,EACrBY,MAAOL,GAAiB,GACxBc,SA7BoDC,IACxD,MAAMC,EAAS,MAAAjC,SAAAA,EAASkC,MACnBD,GAAWA,EAAOX,MAAMC,aAAeS,EAAEG,OAAOb,QAErD,MAAAf,GAAAA,EAAS6B,gBAAgBH,IA0BrBhC,UAAAA,EAECoC,SAAS,MAAArC,OAAA,EAAAA,EAAAsC,KAAI,CAACL,EAAQM,IACnBd,EAAAA,IAACe,EAAAA,YAAA,CACG5B,IAAW,IAAN2B,EAAU3B,OAAM,EAErBd,MAAOmC,EAAOnC,MACdwB,MAAOmB,OAAOR,EAAOX,QAFhB,GAAGd,KAAMT,GAAQD,KAASmC,EAAOX,cAnB1CoB,QAAAC,MACJ,yEAEG,KAAA"}
1
+ {"version":3,"file":"RadioQuestion.cjs","sources":["../../../../../src/components/feedback/questions/RadioQuestion.tsx"],"sourcesContent":["import React, {\n type 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 type { 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]);\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":["label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","numOptions","length","ref","useRef","useEffect","current","focus","selectedValue","useMemo","Array","isArray","currentValue","value","toString","jsx","RadioButtonGroup","legend","labelProps","variant","inline","onChange","e","option","find","target","setCurrentValue","children","map","i","RadioButton","String","console","error"],"mappings":"sWAasD,EAClDA,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAEZ,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,EAAAA,QAELC,EAAaV,GAASW,QAAU,EAEhCC,EAAMC,SAAyB,MACrCC,EAAAA,WAAU,KACFZ,GAAaU,EAAIG,SACjBH,EAAIG,QAAQC,OAAM,GAEvB,CAACd,IAEE,MAOAe,EAAgBC,EAAAA,SAClB,IACIC,MAAMC,QAAQb,GAASc,cACjBd,GAASc,aAAa,GAAGC,MAAMC,WAC/BhB,GAASc,cAAcC,MAAMC,YACvC,CAAChB,GAASc,eAGd,OAAKd,EAQDiB,EAAAA,IAACC,EAAAA,iBAAA,CACGC,OAAQ5B,EACR6B,WAAY,CAAEC,QAAS,SACvB7B,KAAM,GAAGS,KAAMT,GAAQD,IACvB+B,OAAQnB,EAAa,EACrBY,MAAOL,GAAiB,GACxBa,SA7BoDC,IACxD,MAAMC,EAAShC,GAASiC,MACnBD,GAAWA,EAAOV,MAAMC,aAAeQ,EAAEG,OAAOZ,QAErDf,GAAS4B,gBAAgBH,EAAM,EA0B3B/B,UAAAA,EAECmC,SAASpC,GAAAqC,KAAI,CAACL,EAAQM,IACnBd,EAAAA,IAACe,EAAAA,YAAA,CACG3B,IAAW,IAAN0B,EAAU1B,OAAM,EAErBd,MAAOkC,EAAOlC,MACdwB,MAAOkB,OAAOR,EAAOV,QAFhB,GAAGd,KAAMT,GAAQD,KAASkC,EAAOV,cAnB1CmB,QAAAC,MACJ,yEAEG,KAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),r=require("../../input-group/FieldGroup.cjs"),u=require("../followup/followupContext.cjs"),n=require("../main-question/mainQuestionContext.cjs"),o=require("./smileyUtils.cjs"),a=e=>"number"!=typeof e.value||![1,2,3,4,5].includes(e.value);exports.SmileyQuestion=({label:s,name:t="smiley",helpLabel:i,options:c=o.defaultOptions})=>{const d=u.useFollowUpContext(),m=n.useMainQuestionContext(),v=d||m,p=l.useId(),j=e=>{console.log(e.target.value);const l=null==c?void 0:c.find((l=>l.value.toString()===e.target.value));null==v||v.setCurrentValue(l)},y=l.useMemo((()=>{var e;return Array.isArray(null==v?void 0:v.currentValue)?null==v?void 0:v.currentValue[0].value:null==(e=null==v?void 0:v.currentValue)?void 0:e.value}),[null==v?void 0:v.currentValue]);return c.some(a)?(console.error("SmileyQuestion må ha tallene 1 til 5 som verdier for alternativene sine"),null):v&&c?e.jsx(r.FieldGroup,{labelProps:{variant:"large"},legend:s,helpLabel:i,children:e.jsx("div",{className:"jkl-feedback-smileys",children:c.map((r=>e.jsxs(l.Fragment,{children:[e.jsx("input",{className:"jkl-sr-only",id:`${p}-${t}-${r.value}`,name:`${p}-${t}`,type:"radio",value:r.value,onChange:j,checked:y===r.value}),e.jsxs("label",{className:"jkl-feedback-smiley-option",htmlFor:`${p}-${t}-${r.value}`,children:[e.jsx("span",{className:"jkl-sr-only",children:r.label}),o.getSmiley(Number(r.value))]})]},r.value)))})}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),r=require("../../input-group/FieldGroup.cjs"),a=require("../followup/followupContext.cjs"),s=require("../main-question/mainQuestionContext.cjs"),t=require("./smileyUtils.cjs"),u=e=>"number"!=typeof e.value||![1,2,3,4,5].includes(e.value);exports.SmileyQuestion=({label:n,name:o="smiley",helpLabel:i,options:c=t.defaultOptions})=>{const m=a.useFollowUpContext(),d=s.useMainQuestionContext(),p=m||d,v=l.useId(),j=e=>{console.log(e.target.value);const l=c?.find((l=>l.value.toString()===e.target.value));p?.setCurrentValue(l)},y=l.useMemo((()=>Array.isArray(p?.currentValue)?p?.currentValue[0].value:p?.currentValue?.value),[p?.currentValue]);return c.some(u)?(console.error("SmileyQuestion må ha tallene 1 til 5 som verdier for alternativene sine"),null):p&&c?e.jsx(r.FieldGroup,{labelProps:{variant:"large"},legend:n,helpLabel:i,children:e.jsx("div",{className:"jkl-feedback-smileys",children:c.map((r=>e.jsxs(l.Fragment,{children:[e.jsx("input",{className:"jkl-sr-only",id:`${v}-${o}-${r.value}`,name:`${v}-${o}`,type:"radio",value:r.value,onChange:j,checked:y===r.value}),e.jsxs("label",{className:"jkl-feedback-smiley-option",htmlFor:`${v}-${o}-${r.value}`,children:[e.jsx("span",{className:"jkl-sr-only",children:r.label}),t.getSmiley(Number(r.value))]})]},r.value)))})}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};
2
2
  //# sourceMappingURL=SmileyQuestion.cjs.map