@fremtind/jokul 0.10.1 → 0.12.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 (298) hide show
  1. package/README.md +76 -0
  2. package/build/NativeSelect-CNcZmpDZ.cjs +2 -0
  3. package/build/{NativeSelect-DSmX3GZo.cjs.map → NativeSelect-CNcZmpDZ.cjs.map} +1 -1
  4. package/build/NativeSelect-CfNZEQF0.js +2 -0
  5. package/build/{NativeSelect-EidDABsT.js.map → NativeSelect-CfNZEQF0.js.map} +1 -1
  6. package/build/build-stats.html +1 -1
  7. package/build/cjs/components/datepicker/DatePicker.js +1 -1
  8. package/build/cjs/components/datepicker/DatePicker.js.map +1 -1
  9. package/build/cjs/components/datepicker/internal/Calendar.js +1 -1
  10. package/build/cjs/components/datepicker/internal/Calendar.js.map +1 -1
  11. package/build/cjs/components/feedback/Feedback.js +2 -0
  12. package/build/cjs/components/feedback/Feedback.js.map +1 -0
  13. package/build/cjs/components/feedback/FeedbackSuccess.js +2 -0
  14. package/build/cjs/components/feedback/FeedbackSuccess.js.map +1 -0
  15. package/build/cjs/components/feedback/FeedbackValues.js +2 -0
  16. package/build/cjs/components/feedback/FeedbackValues.js.map +1 -0
  17. package/build/cjs/components/feedback/feedbackContext.js +2 -0
  18. package/build/cjs/components/feedback/feedbackContext.js.map +1 -0
  19. package/build/cjs/components/feedback/followup/Followup.js +2 -0
  20. package/build/cjs/components/feedback/followup/Followup.js.map +1 -0
  21. package/build/cjs/components/feedback/followup/followupContext.js +2 -0
  22. package/build/cjs/components/feedback/followup/followupContext.js.map +1 -0
  23. package/build/cjs/components/feedback/followup/useFollowup.js +2 -0
  24. package/build/cjs/components/feedback/followup/useFollowup.js.map +1 -0
  25. package/build/cjs/components/feedback/index.js +2 -0
  26. package/build/cjs/components/feedback/index.js.map +1 -0
  27. package/build/cjs/components/feedback/main-question/MainQuestion.js +2 -0
  28. package/build/cjs/components/feedback/main-question/MainQuestion.js.map +1 -0
  29. package/build/cjs/components/feedback/main-question/mainQuestionContext.js +2 -0
  30. package/build/cjs/components/feedback/main-question/mainQuestionContext.js.map +1 -0
  31. package/build/cjs/components/feedback/main-question/useMainQuestion.js +2 -0
  32. package/build/cjs/components/feedback/main-question/useMainQuestion.js.map +1 -0
  33. package/build/cjs/components/feedback/presets.js +2 -0
  34. package/build/cjs/components/feedback/presets.js.map +1 -0
  35. package/build/cjs/components/feedback/questions/AddonQuestion.js +2 -0
  36. package/build/cjs/components/feedback/questions/AddonQuestion.js.map +1 -0
  37. package/build/cjs/components/feedback/questions/CheckboxQuestion.js +2 -0
  38. package/build/cjs/components/feedback/questions/CheckboxQuestion.js.map +1 -0
  39. package/build/cjs/components/feedback/questions/ContactQuestion.js +2 -0
  40. package/build/cjs/components/feedback/questions/ContactQuestion.js.map +1 -0
  41. package/build/cjs/components/feedback/questions/RadioQuestion.js +2 -0
  42. package/build/cjs/components/feedback/questions/RadioQuestion.js.map +1 -0
  43. package/build/cjs/components/feedback/questions/SmileyQuestion.js +2 -0
  44. package/build/cjs/components/feedback/questions/SmileyQuestion.js.map +1 -0
  45. package/build/cjs/components/feedback/questions/TextQuestion.js +2 -0
  46. package/build/cjs/components/feedback/questions/TextQuestion.js.map +1 -0
  47. package/build/cjs/components/feedback/questions/index.js +2 -0
  48. package/build/cjs/components/feedback/questions/index.js.map +1 -0
  49. package/build/cjs/components/feedback/questions/smileyUtils.js +2 -0
  50. package/build/cjs/components/feedback/questions/smileyUtils.js.map +1 -0
  51. package/build/cjs/components/feedback/types.js +2 -0
  52. package/build/cjs/components/feedback/types.js.map +1 -0
  53. package/build/cjs/components/feedback/utils.js +2 -0
  54. package/build/cjs/components/feedback/utils.js.map +1 -0
  55. package/build/cjs/components/index.js +1 -1
  56. package/build/cjs/components/message/DismissButton.js +2 -0
  57. package/build/cjs/components/message/DismissButton.js.map +1 -0
  58. package/build/cjs/components/message/FormErrorMessage.js +2 -0
  59. package/build/cjs/components/message/FormErrorMessage.js.map +1 -0
  60. package/build/cjs/components/message/Message.js +2 -0
  61. package/build/cjs/components/message/Message.js.map +1 -0
  62. package/build/cjs/components/message/index.js +2 -0
  63. package/build/cjs/components/message/index.js.map +1 -0
  64. package/build/cjs/components/popover/Popover.js +2 -0
  65. package/build/cjs/components/popover/Popover.js.map +1 -0
  66. package/build/cjs/components/popover/index.js +2 -0
  67. package/build/cjs/components/popover/index.js.map +1 -0
  68. package/build/cjs/components/popover/utils.js +2 -0
  69. package/build/cjs/components/popover/utils.js.map +1 -0
  70. package/build/cjs/components/select/NativeSelect.js +1 -1
  71. package/build/cjs/components/select/Select.js +1 -1
  72. package/build/cjs/components/select/index.js +1 -1
  73. package/build/cjs/components/text-input/BaseTextInput.js +1 -1
  74. package/build/cjs/components/text-input/BaseTextInput.js.map +1 -1
  75. package/build/cjs/components/text-input/TextArea.js +1 -1
  76. package/build/cjs/components/text-input/TextArea.js.map +1 -1
  77. package/build/cjs/components/text-input/TextInput.js +1 -1
  78. package/build/cjs/components/text-input/TextInput.js.map +1 -1
  79. package/build/cjs/components/tooltip/TooltipContent.js +1 -1
  80. package/build/cjs/components/tooltip/TooltipContent.js.map +1 -1
  81. package/build/cjs/index.js +1 -1
  82. package/build/cjs/utilities/index.js +1 -1
  83. package/build/cjs/utilities/validators/hasMinimumWords/hasMinimumWords.js +2 -0
  84. package/build/cjs/utilities/validators/hasMinimumWords/hasMinimumWords.js.map +1 -0
  85. package/build/cjs/utilities/validators/hasNoIllegalCharacters/hasNoIllegalCharacters.js +2 -0
  86. package/build/cjs/utilities/validators/hasNoIllegalCharacters/hasNoIllegalCharacters.js.map +1 -0
  87. package/build/cjs/utilities/validators/index.js +2 -0
  88. package/build/cjs/utilities/validators/index.js.map +1 -0
  89. package/build/cjs/utilities/validators/isExactLength/isExactLength.js +2 -0
  90. package/build/cjs/utilities/validators/isExactLength/isExactLength.js.map +1 -0
  91. package/build/cjs/utilities/validators/isInteger/isInteger.js +2 -0
  92. package/build/cjs/utilities/validators/isInteger/isInteger.js.map +1 -0
  93. package/build/cjs/utilities/validators/isValidChassisnummer/isValidChassisnummer.js +2 -0
  94. package/build/cjs/utilities/validators/isValidChassisnummer/isValidChassisnummer.js.map +1 -0
  95. package/build/cjs/utilities/validators/isValidDogId/isValidDogId.js +2 -0
  96. package/build/cjs/utilities/validators/isValidDogId/isValidDogId.js.map +1 -0
  97. package/build/cjs/utilities/validators/isValidEpost/isValidEpost.js +2 -0
  98. package/build/cjs/utilities/validators/isValidEpost/isValidEpost.js.map +1 -0
  99. package/build/cjs/utilities/validators/isValidFodselsnummer/isValidFodselsnummer.js +2 -0
  100. package/build/cjs/utilities/validators/isValidFodselsnummer/isValidFodselsnummer.js.map +1 -0
  101. package/build/cjs/utilities/validators/isValidKortnummer/isValidKortnummer.js +2 -0
  102. package/build/cjs/utilities/validators/isValidKortnummer/isValidKortnummer.js.map +1 -0
  103. package/build/cjs/utilities/validators/isValidName/isValidName.js +2 -0
  104. package/build/cjs/utilities/validators/isValidName/isValidName.js.map +1 -0
  105. package/build/cjs/utilities/validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.js +2 -0
  106. package/build/cjs/utilities/validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.js.map +1 -0
  107. package/build/cjs/utilities/validators/isValidRegistreringsnummer/isValidRegistreringsnummer.js +2 -0
  108. package/build/cjs/utilities/validators/isValidRegistreringsnummer/isValidRegistreringsnummer.js.map +1 -0
  109. package/build/cjs/utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js +2 -0
  110. package/build/cjs/utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js.map +1 -0
  111. package/build/components/feedback/Feedback.d.ts +42 -0
  112. package/build/components/feedback/FeedbackSuccess.d.ts +3 -0
  113. package/build/components/feedback/FeedbackValues.d.ts +6 -0
  114. package/build/components/feedback/feedbackContext.d.ts +19 -0
  115. package/build/components/feedback/followup/Followup.d.ts +14 -0
  116. package/build/components/feedback/followup/followupContext.d.ts +9 -0
  117. package/build/components/feedback/followup/useFollowup.d.ts +19 -0
  118. package/build/components/feedback/index.d.ts +3 -0
  119. package/build/components/feedback/main-question/MainQuestion.d.ts +16 -0
  120. package/build/components/feedback/main-question/mainQuestionContext.d.ts +9 -0
  121. package/build/components/feedback/main-question/useMainQuestion.d.ts +13 -0
  122. package/build/components/feedback/presets.d.ts +6 -0
  123. package/build/components/feedback/questions/AddonQuestion.d.ts +7 -0
  124. package/build/components/feedback/questions/CheckboxQuestion.d.ts +3 -0
  125. package/build/components/feedback/questions/ContactQuestion.d.ts +28 -0
  126. package/build/components/feedback/questions/RadioQuestion.d.ts +3 -0
  127. package/build/components/feedback/questions/SmileyQuestion.d.ts +3 -0
  128. package/build/components/feedback/questions/TextQuestion.d.ts +3 -0
  129. package/build/components/feedback/questions/index.d.ts +6 -0
  130. package/build/components/feedback/questions/smileyUtils.d.ts +4 -0
  131. package/build/components/feedback/types.d.ts +86 -0
  132. package/build/components/feedback/utils.d.ts +4 -0
  133. package/build/components/index.d.ts +3 -0
  134. package/build/components/message/DismissButton.d.ts +5 -0
  135. package/build/components/message/FormErrorMessage.d.ts +14 -0
  136. package/build/components/message/Message.d.ts +19 -0
  137. package/build/components/message/index.d.ts +2 -0
  138. package/build/components/popover/Popover.d.ts +114 -0
  139. package/build/components/popover/index.d.ts +1 -0
  140. package/build/components/popover/utils.d.ts +4 -0
  141. package/build/es/components/datepicker/DatePicker.js +1 -1
  142. package/build/es/components/datepicker/DatePicker.js.map +1 -1
  143. package/build/es/components/datepicker/internal/Calendar.js +1 -1
  144. package/build/es/components/datepicker/internal/Calendar.js.map +1 -1
  145. package/build/es/components/feedback/Feedback.js +2 -0
  146. package/build/es/components/feedback/Feedback.js.map +1 -0
  147. package/build/es/components/feedback/FeedbackSuccess.js +2 -0
  148. package/build/es/components/feedback/FeedbackSuccess.js.map +1 -0
  149. package/build/es/components/feedback/FeedbackValues.js +2 -0
  150. package/build/es/components/feedback/FeedbackValues.js.map +1 -0
  151. package/build/es/components/feedback/feedbackContext.js +2 -0
  152. package/build/es/components/feedback/feedbackContext.js.map +1 -0
  153. package/build/es/components/feedback/followup/Followup.js +2 -0
  154. package/build/es/components/feedback/followup/Followup.js.map +1 -0
  155. package/build/es/components/feedback/followup/followupContext.js +2 -0
  156. package/build/es/components/feedback/followup/followupContext.js.map +1 -0
  157. package/build/es/components/feedback/followup/useFollowup.js +2 -0
  158. package/build/es/components/feedback/followup/useFollowup.js.map +1 -0
  159. package/build/es/components/feedback/index.js +2 -0
  160. package/build/es/components/feedback/index.js.map +1 -0
  161. package/build/es/components/feedback/main-question/MainQuestion.js +2 -0
  162. package/build/es/components/feedback/main-question/MainQuestion.js.map +1 -0
  163. package/build/es/components/feedback/main-question/mainQuestionContext.js +2 -0
  164. package/build/es/components/feedback/main-question/mainQuestionContext.js.map +1 -0
  165. package/build/es/components/feedback/main-question/useMainQuestion.js +2 -0
  166. package/build/es/components/feedback/main-question/useMainQuestion.js.map +1 -0
  167. package/build/es/components/feedback/presets.js +2 -0
  168. package/build/es/components/feedback/presets.js.map +1 -0
  169. package/build/es/components/feedback/questions/AddonQuestion.js +2 -0
  170. package/build/es/components/feedback/questions/AddonQuestion.js.map +1 -0
  171. package/build/es/components/feedback/questions/CheckboxQuestion.js +2 -0
  172. package/build/es/components/feedback/questions/CheckboxQuestion.js.map +1 -0
  173. package/build/es/components/feedback/questions/ContactQuestion.js +2 -0
  174. package/build/es/components/feedback/questions/ContactQuestion.js.map +1 -0
  175. package/build/es/components/feedback/questions/RadioQuestion.js +2 -0
  176. package/build/es/components/feedback/questions/RadioQuestion.js.map +1 -0
  177. package/build/es/components/feedback/questions/SmileyQuestion.js +2 -0
  178. package/build/es/components/feedback/questions/SmileyQuestion.js.map +1 -0
  179. package/build/es/components/feedback/questions/TextQuestion.js +2 -0
  180. package/build/es/components/feedback/questions/TextQuestion.js.map +1 -0
  181. package/build/es/components/feedback/questions/index.js +2 -0
  182. package/build/es/components/feedback/questions/index.js.map +1 -0
  183. package/build/es/components/feedback/questions/smileyUtils.js +2 -0
  184. package/build/es/components/feedback/questions/smileyUtils.js.map +1 -0
  185. package/build/es/components/feedback/types.js +2 -0
  186. package/build/es/components/feedback/types.js.map +1 -0
  187. package/build/es/components/feedback/utils.js +2 -0
  188. package/build/es/components/feedback/utils.js.map +1 -0
  189. package/build/es/components/index.js +1 -1
  190. package/build/es/components/message/DismissButton.js +2 -0
  191. package/build/es/components/message/DismissButton.js.map +1 -0
  192. package/build/es/components/message/FormErrorMessage.js +2 -0
  193. package/build/es/components/message/FormErrorMessage.js.map +1 -0
  194. package/build/es/components/message/Message.js +2 -0
  195. package/build/es/components/message/Message.js.map +1 -0
  196. package/build/es/components/message/index.js +2 -0
  197. package/build/es/components/message/index.js.map +1 -0
  198. package/build/es/components/popover/Popover.js +2 -0
  199. package/build/es/components/popover/Popover.js.map +1 -0
  200. package/build/es/components/popover/index.js +2 -0
  201. package/build/es/components/popover/index.js.map +1 -0
  202. package/build/es/components/popover/utils.js +2 -0
  203. package/build/es/components/popover/utils.js.map +1 -0
  204. package/build/es/components/select/NativeSelect.js +1 -1
  205. package/build/es/components/select/Select.js +1 -1
  206. package/build/es/components/select/index.js +1 -1
  207. package/build/es/components/text-input/BaseTextInput.js +1 -1
  208. package/build/es/components/text-input/BaseTextInput.js.map +1 -1
  209. package/build/es/components/text-input/TextArea.js +1 -1
  210. package/build/es/components/text-input/TextArea.js.map +1 -1
  211. package/build/es/components/text-input/TextInput.js +1 -1
  212. package/build/es/components/text-input/TextInput.js.map +1 -1
  213. package/build/es/components/tooltip/TooltipContent.js +1 -1
  214. package/build/es/components/tooltip/TooltipContent.js.map +1 -1
  215. package/build/es/index.js +1 -1
  216. package/build/es/utilities/index.js +1 -1
  217. package/build/es/utilities/validators/hasMinimumWords/hasMinimumWords.js +2 -0
  218. package/build/es/utilities/validators/hasMinimumWords/hasMinimumWords.js.map +1 -0
  219. package/build/es/utilities/validators/hasNoIllegalCharacters/hasNoIllegalCharacters.js +2 -0
  220. package/build/es/utilities/validators/hasNoIllegalCharacters/hasNoIllegalCharacters.js.map +1 -0
  221. package/build/es/utilities/validators/index.js +2 -0
  222. package/build/es/utilities/validators/index.js.map +1 -0
  223. package/build/es/utilities/validators/isExactLength/isExactLength.js +2 -0
  224. package/build/es/utilities/validators/isExactLength/isExactLength.js.map +1 -0
  225. package/build/es/utilities/validators/isInteger/isInteger.js +2 -0
  226. package/build/es/utilities/validators/isInteger/isInteger.js.map +1 -0
  227. package/build/es/utilities/validators/isValidChassisnummer/isValidChassisnummer.js +2 -0
  228. package/build/es/utilities/validators/isValidChassisnummer/isValidChassisnummer.js.map +1 -0
  229. package/build/es/utilities/validators/isValidDogId/isValidDogId.js +2 -0
  230. package/build/es/utilities/validators/isValidDogId/isValidDogId.js.map +1 -0
  231. package/build/es/utilities/validators/isValidEpost/isValidEpost.js +2 -0
  232. package/build/es/utilities/validators/isValidEpost/isValidEpost.js.map +1 -0
  233. package/build/es/utilities/validators/isValidFodselsnummer/isValidFodselsnummer.js +2 -0
  234. package/build/es/utilities/validators/isValidFodselsnummer/isValidFodselsnummer.js.map +1 -0
  235. package/build/es/utilities/validators/isValidKortnummer/isValidKortnummer.js +2 -0
  236. package/build/es/utilities/validators/isValidKortnummer/isValidKortnummer.js.map +1 -0
  237. package/build/es/utilities/validators/isValidName/isValidName.js +2 -0
  238. package/build/es/utilities/validators/isValidName/isValidName.js.map +1 -0
  239. package/build/es/utilities/validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.js +2 -0
  240. package/build/es/utilities/validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.js.map +1 -0
  241. package/build/es/utilities/validators/isValidRegistreringsnummer/isValidRegistreringsnummer.js +2 -0
  242. package/build/es/utilities/validators/isValidRegistreringsnummer/isValidRegistreringsnummer.js.map +1 -0
  243. package/build/es/utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js +2 -0
  244. package/build/es/utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js.map +1 -0
  245. package/build/utilities/index.d.ts +1 -0
  246. package/build/utilities/validators/hasMinimumWords/hasMinimumWords.d.ts +10 -0
  247. package/build/utilities/validators/hasNoIllegalCharacters/hasNoIllegalCharacters.d.ts +7 -0
  248. package/build/utilities/validators/index.d.ts +12 -0
  249. package/build/utilities/validators/isExactLength/isExactLength.d.ts +7 -0
  250. package/build/utilities/validators/isInteger/isInteger.d.ts +7 -0
  251. package/build/utilities/validators/isValidChassisnummer/isValidChassisnummer.d.ts +7 -0
  252. package/build/utilities/validators/isValidDogId/isValidDogId.d.ts +7 -0
  253. package/build/utilities/validators/isValidEpost/isValidEpost.d.ts +7 -0
  254. package/build/utilities/validators/isValidFodselsnummer/isValidFodselsnummer.d.ts +30 -0
  255. package/build/utilities/validators/isValidKortnummer/isValidKortnummer.d.ts +6 -0
  256. package/build/utilities/validators/isValidName/isValidName.d.ts +7 -0
  257. package/build/utilities/validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.d.ts +6 -0
  258. package/build/utilities/validators/isValidRegistreringsnummer/isValidRegistreringsnummer.d.ts +12 -0
  259. package/build/utilities/validators/isValidTelefonnummer/isValidTelefonnummer.d.ts +7 -0
  260. package/package.json +12 -6
  261. package/src/components/button/styles/button.css +4 -4
  262. package/src/components/button/styles/button.min.css +1 -1
  263. package/src/components/card/styles/card.min.css +1 -1
  264. package/src/components/checkbox/styles/checkbox.css +4 -4
  265. package/src/components/checkbox/styles/checkbox.min.css +1 -1
  266. package/src/components/combobox/styles/combobox.min.css +1 -1
  267. package/src/components/cookie-consent/styles/cookie-consent.min.css +1 -1
  268. package/src/components/datepicker/styles/datepicker.min.css +1 -1
  269. package/src/components/feedback/styles/_index.scss +1 -0
  270. package/src/components/feedback/styles/feedback.css +104 -0
  271. package/src/components/feedback/styles/feedback.min.css +1 -0
  272. package/src/components/feedback/styles/feedback.scss +103 -0
  273. package/src/components/icon/styles/icon.min.css +1 -1
  274. package/src/components/link/styles/link.min.css +1 -1
  275. package/src/components/list/styles/list.min.css +1 -1
  276. package/src/components/loader/styles/loader.css +6 -6
  277. package/src/components/loader/styles/loader.min.css +1 -1
  278. package/src/components/loader/styles/skeleton-loader.css +5 -5
  279. package/src/components/loader/styles/skeleton-loader.min.css +1 -1
  280. package/src/components/message/styles/_index.scss +1 -0
  281. package/src/components/message/styles/message.css +203 -0
  282. package/src/components/message/styles/message.min.css +1 -0
  283. package/src/components/message/styles/message.scss +180 -0
  284. package/src/components/popover/styles/_index.scss +1 -0
  285. package/src/components/popover/styles/popover.css +10 -0
  286. package/src/components/popover/styles/popover.min.css +1 -0
  287. package/src/components/popover/styles/popover.scss +9 -0
  288. package/src/components/radio-button/styles/radio-button.css +2 -2
  289. package/src/components/radio-button/styles/radio-button.min.css +1 -1
  290. package/src/components/select/styles/select.min.css +1 -1
  291. package/src/components/tag/styles/tag.min.css +1 -1
  292. package/src/components/text-input/styles/text-input.min.css +1 -1
  293. package/src/components/tooltip/styles/tooltip.min.css +1 -1
  294. package/src/core/styles/core.min.css +1 -1
  295. package/src/core/styles/vind.min.css +1 -1
  296. package/build/NativeSelect-DSmX3GZo.cjs +0 -2
  297. package/build/NativeSelect-EidDABsT.js +0 -2
  298. package/build/components/tooltip/Tooltip.d.ts +0 -122
@@ -0,0 +1,2 @@
1
+ import{jsx as o,jsxs as i}from"react/jsx-runtime";import{useState as t}from"react";import{FeedbackContextProvider as n}from"./feedbackContext.js";import{Followup as s}from"./followup/Followup.js";import{MainQuestion as c}from"./main-question/MainQuestion.js";import"../checkbox/Checkbox.js";import"../../hooks/useScreen/useScreen.js";import"../../hooks/useId/useId.js";import"../tooltip/Tooltip.js";import"../tooltip/TooltipContent.js";import"../tooltip/TooltipTrigger.js";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";import"../input-group/InputGroup.js";import"./followup/followupContext.js";import"./main-question/mainQuestionContext.js";import"../radio-button/RadioButton.js";import"../radio-button/radioGroupContext.js";import"../radio-button/BaseRadioButton.js";import"../text-input/BaseTextArea.js";import"../text-input/BaseTextInput.js";import"../text-input/TextArea.js";import"../text-input/TextInput.js";import{ContactQuestion as r}from"./questions/ContactQuestion.js";const e=({className:e,followup:p,contactQuestion:m,counter:a,...j})=>{const[u,l]=t(!1),[d,I]=t(!1),[b,C]=t(!1),[h,w]=t(!1);return o("div",{className:`jkl-feedback ${e||""}`,"data-testid":"feedback",children:i(n,{value:{feedbackSubmitted:u,followupStarted:d,followupSubmitted:b,contactSubmitted:h,counter:a,setFeedbackSubmitted:l,setFollowupStarted:I,setFollowupSubmitted:C,setContactSubmitted:w},children:[!d&&o(c,{...j}),u&&!h&&p&&o(s,{...p}),m&&o("div",{"aria-live":"polite",children:(!p&&u||b)&&o(r,{...m})})]})})};export{e as Feedback};
2
+ //# sourceMappingURL=Feedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Feedback.js","sources":["../../../../src/components/feedback/Feedback.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode, useState, ComponentProps } from \"react\";\nimport { BaseTextAreaProps } from \"../text-input\";\nimport { FeedbackContextProvider } from \"./feedbackContext\";\nimport { Followup } from \"./followup/Followup\";\nimport { MainQuestion } from \"./main-question/MainQuestion\";\nimport { ContactQuestion } from \"./questions\";\nimport { FeedbackOption, FeedbackType } from \"./types\";\n\ntype FollowupProps = ComponentProps<typeof Followup>;\ntype ContactQuestionProps = ComponentProps<typeof ContactQuestion>;\n\ntype Props = {\n className?: string;\n /** Velg typen alternativer, Smiley eller RadioButtons. */\n type: \"radio\" | \"smiley\";\n /** Spørsmålet som stilles til brukeren */\n label: string;\n /** Hjelpetekst til hovedspørsmålet */\n helpLabel?: string;\n /** Svaralternativer til spørsmålet */\n options: FeedbackOption[];\n /** Dersom du vil stille et åpent spørsmål i tillegg kan du sette denne til en truthy verdi */\n addOnQuestion?:\n | {\n /** Spørsmålet du vil stille */\n label?: string;\n /** Eventuell hjelpetekst. Om du ikke spesifiserer en vil det vises en påminnelse om å ikke skrive inn personling informasjon. */\n helpLabel?: string;\n }\n | boolean;\n /** Lar deg tilpasse meldingen som kommer når brukeren sender inn tilbakemeldingen. */\n successMessage?: {\n title: string;\n children: ReactNode;\n };\n /**\n * Funksjon for å håndtere innsending av tilbakemelding\n * @param value Verdien av tilbakemeldingen. Dette er et objekt med følgende egenskaper:\n * - `feedbackValue`: Selve verdien av tilbakemeldingen (format varierer etter spørsmålstype)\n * - `intentionalSubmit`: Er `true` hvis brukeren aktivt sendte inn skjemaet, `false` hvis skjemaet ble sendt inn automatisk\n * - `message`: Eventuell utfyllende melding fra bruker. Blir kun sendt inn ved aktiv innsending\n */\n onSubmit: (value: FeedbackType) => void;\n\n followup?: FollowupProps;\n contactQuestion?: ContactQuestionProps;\n} & Pick<BaseTextAreaProps, \"counter\">;\n\nexport const Feedback = ({\n className,\n followup,\n contactQuestion,\n counter,\n ...mainQuestionProps\n}: Props): ReactElement => {\n const [feedbackSubmitted, setFeedbackSubmitted] = useState(false);\n const [followupStarted, setFollowupStarted] = useState(false);\n const [followupSubmitted, setFollowupSubmitted] = useState(false);\n const [contactSubmitted, setContactSubmitted] = useState(false);\n\n return (\n <div className={`jkl-feedback ${className || \"\"}`} data-testid=\"feedback\">\n <FeedbackContextProvider\n value={{\n feedbackSubmitted,\n followupStarted,\n followupSubmitted,\n contactSubmitted,\n counter,\n setFeedbackSubmitted,\n setFollowupStarted,\n setFollowupSubmitted,\n setContactSubmitted,\n }}\n >\n {!followupStarted && <MainQuestion {...mainQuestionProps} />}\n {feedbackSubmitted && !contactSubmitted && followup && <Followup {...followup} />}\n {contactQuestion && (\n <div aria-live=\"polite\">\n {/* Show contact question after followup, or after feedback if no followup */}\n {((!followup && feedbackSubmitted) || followupSubmitted) && (\n <ContactQuestion {...contactQuestion} />\n )}\n </div>\n )}\n </FeedbackContextProvider>\n </div>\n );\n};\n"],"names":["Feedback","className","followup","contactQuestion","counter","mainQuestionProps","feedbackSubmitted","setFeedbackSubmitted","useState","followupStarted","setFollowupStarted","followupSubmitted","setFollowupSubmitted","contactSubmitted","setContactSubmitted","jsx","children","jsxs","FeedbackContextProvider","value","MainQuestion","Followup","ContactQuestion"],"mappings":"wuEAgDO,MAAMA,EAAW,EACpBC,UAAAA,EACAC,SAAAA,EACAC,gBAAAA,EACAC,QAAAA,KACGC,MAEG,MAACC,EAAmBC,GAAwBC,GAAS,IACpDC,EAAiBC,GAAsBF,GAAS,IAChDG,EAAmBC,GAAwBJ,GAAS,IACpDK,EAAkBC,GAAuBN,GAAS,GAGrD,OAAAO,EAAC,OAAId,UAAW,gBAAgBA,GAAa,KAAM,cAAY,WAC3De,SAAAC,EAACC,EAAA,CACGC,MAAO,CACHb,kBAAAA,EACAG,gBAAAA,EACAE,kBAAAA,EACAE,iBAAAA,EACAT,QAAAA,EACAG,qBAAAA,EACAG,mBAAAA,EACAE,qBAAAA,EACAE,oBAAAA,GAGHE,SAAA,EAACP,GAAmBM,EAACK,EAAc,IAAGf,IACtCC,IAAsBO,GAAoBX,GAAaa,EAAAM,EAAA,IAAanB,IACpEC,GACGY,EAAC,MAAI,CAAA,YAAU,SAERC,WAACd,GAAYI,GAAsBK,IAClCI,EAACO,EAAiB,IAAGnB,UAKzC"}
@@ -0,0 +1,2 @@
1
+ import{jsx as s}from"react/jsx-runtime";import{c as e}from"../../../clsx-BeLtu-UY.js";import{SuccessMessage as a}from"../message/Message.js";import"../message/FormErrorMessage.js";const r=({children:r,className:c,...m})=>s(a,{className:e("jkl-feedback__fade-in",c),...m,"aria-live":"polite",children:r});export{r as FeedbackSuccess};
2
+ //# sourceMappingURL=FeedbackSuccess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedbackSuccess.js","sources":["../../../../src/components/feedback/FeedbackSuccess.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC } from \"react\";\nimport { SuccessMessage, MessageProps } from \"../message\";\n\nexport const FeedbackSuccess: FC<MessageProps> = ({ children, className, ...rest }) => (\n <SuccessMessage className={clsx(\"jkl-feedback__fade-in\", className)} {...rest} aria-live=\"polite\">\n {children}\n </SuccessMessage>\n);\n"],"names":["FeedbackSuccess","children","className","rest","jsx","SuccessMessage","clsx"],"mappings":"oLAIO,MAAMA,EAAoC,EAAGC,SAAAA,EAAUC,UAAAA,KAAcC,KACxEC,EAACC,GAAeH,UAAWI,EAAK,wBAAyBJ,MAAgBC,EAAM,YAAU,SACpFF,SAAAA"}
@@ -0,0 +1,2 @@
1
+ const e={label:"Ikke fornøyd i det hele tatt",value:1},l={label:"Ikke fornøyd",value:2},a={label:"Verken fornøyd eller misfornøyd",value:3},r={label:"Fornøyd",value:4},d={label:"Veldig fornøyd",value:5};export{r as HAPPY,a as NEUTRAL,l as UNHAPPY,d as VERY_HAPPY,e as VERY_UNHAPPY};
2
+ //# sourceMappingURL=FeedbackValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedbackValues.js","sources":["../../../../src/components/feedback/FeedbackValues.tsx"],"sourcesContent":["import { FeedbackOption } from \"./types\";\n\nexport const VERY_UNHAPPY: FeedbackOption = { label: \"Ikke fornøyd i det hele tatt\", value: 1 };\nexport const UNHAPPY: FeedbackOption = { label: \"Ikke fornøyd\", value: 2 };\nexport const NEUTRAL: FeedbackOption = { label: \"Verken fornøyd eller misfornøyd\", value: 3 };\nexport const HAPPY: FeedbackOption = { label: \"Fornøyd\", value: 4 };\nexport const VERY_HAPPY: FeedbackOption = { label: \"Veldig fornøyd\", value: 5 };\n"],"names":["VERY_UNHAPPY","label","value","UNHAPPY","NEUTRAL","HAPPY","VERY_HAPPY"],"mappings":"AAEO,MAAMA,EAA+B,CAAEC,MAAO,+BAAgCC,MAAO,GAC/EC,EAA0B,CAAEF,MAAO,eAAgBC,MAAO,GAC1DE,EAA0B,CAAEH,MAAO,kCAAmCC,MAAO,GAC7EG,EAAwB,CAAEJ,MAAO,UAAWC,MAAO,GACnDI,EAA6B,CAAEL,MAAO,iBAAkBC,MAAO"}
@@ -0,0 +1,2 @@
1
+ import{jsx as t}from"react/jsx-runtime";import{createContext as e,useContext as o}from"react";const l=e({feedbackSubmitted:!1,followupStarted:!1,followupSubmitted:!1,contactSubmitted:!1,setFeedbackSubmitted:()=>null,setFollowupStarted:()=>null,setFollowupSubmitted:()=>null,setContactSubmitted:()=>null}),u=()=>o(l),a=({value:e,children:o})=>t(l.Provider,{value:e,children:o});export{a as FeedbackContextProvider,u as useFeedbackContext};
2
+ //# sourceMappingURL=feedbackContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedbackContext.js","sources":["../../../../src/components/feedback/feedbackContext.tsx"],"sourcesContent":["import React, { createContext, FC, useContext } from \"react\";\nimport { WithChildren } from \"../..\";\nimport { BaseTextAreaProps } from \"../text-input\";\n\ntype FeedbackContext = {\n feedbackSubmitted: boolean;\n followupStarted: boolean;\n followupSubmitted: boolean;\n contactSubmitted: boolean;\n setFeedbackSubmitted: (state: boolean) => void;\n setFollowupStarted: (state: boolean) => void;\n setFollowupSubmitted: (state: boolean) => void;\n setContactSubmitted: (state: boolean) => void;\n} & Pick<BaseTextAreaProps, \"counter\">;\n\nconst initialState: FeedbackContext = {\n feedbackSubmitted: false,\n followupStarted: false,\n followupSubmitted: false,\n contactSubmitted: false,\n setFeedbackSubmitted: () => null,\n setFollowupStarted: () => null,\n setFollowupSubmitted: () => null,\n setContactSubmitted: () => null,\n};\n\nconst feedbackContext = createContext(initialState);\n\nexport const useFeedbackContext = (): FeedbackContext => useContext(feedbackContext);\n\ninterface FeedbackContextProviderProps extends WithChildren {\n value: FeedbackContext;\n}\n\nexport const FeedbackContextProvider: FC<FeedbackContextProviderProps> = ({ value, children }) => (\n <feedbackContext.Provider value={value}>{children}</feedbackContext.Provider>\n);\n"],"names":["feedbackContext","createContext","feedbackSubmitted","followupStarted","followupSubmitted","contactSubmitted","setFeedbackSubmitted","setFollowupStarted","setFollowupSubmitted","setContactSubmitted","useFeedbackContext","useContext","FeedbackContextProvider","value","children","jsx","Provider"],"mappings":"8FAeA,MAWMA,EAAkBC,EAXc,CAClCC,mBAAmB,EACnBC,iBAAiB,EACjBC,mBAAmB,EACnBC,kBAAkB,EAClBC,qBAAsB,IAAM,KAC5BC,mBAAoB,IAAM,KAC1BC,qBAAsB,IAAM,KAC5BC,oBAAqB,IAAM,OAKlBC,EAAqB,IAAuBC,EAAWX,GAMvDY,EAA4D,EAAGC,MAAAA,EAAOC,SAAAA,KAC/EC,EAACf,EAAgBgB,SAAhB,CAAyBH,MAAAA,EAAeC,SAAAA"}
@@ -0,0 +1,2 @@
1
+ import{jsx as o,jsxs as i}from"react/jsx-runtime";import{useState as t,useRef as s,useEffect as n,createElement as e}from"react";import"../../../hooks/useScreen/useScreen.js";import"../../../hooks/useId/useId.js";import"../../icon/Icon.js";import"../../icon/icons/animated/ArrowVerticalAnimated.js";import"../../icon/icons/animated/ArrowHorizontalAnimated.js";import"../../icon/icons/animated/PlusRemoveAnimated.js";import"../../icon/icons/ArrowDownIcon.js";import"../../icon/icons/ArrowLeftIcon.js";import"../../icon/icons/ArrowNorthEastIcon.js";import"../../icon/icons/ArrowRightIcon.js";import"../../icon/icons/ArrowUpIcon.js";import"../../icon/icons/CalendarIcon.js";import"../../icon/icons/CheckIcon.js";import"../../icon/icons/ChevronDownIcon.js";import"../../icon/icons/ChevronLeftIcon.js";import"../../icon/icons/ChevronRightIcon.js";import"../../icon/icons/ChevronUpIcon.js";import"../../icon/icons/CloseIcon.js";import"../../icon/icons/CopyIcon.js";import"../../icon/icons/DotsIcon.js";import"../../icon/icons/DragIcon.js";import"../../icon/icons/ErrorIcon.js";import"../../icon/icons/GreenCheckIcon.js";import"../../icon/icons/HamburgerIcon.js";import"../../icon/icons/InfoIcon.js";import"../../icon/icons/LinkIcon.js";import"../../icon/icons/PlusIcon.js";import"../../icon/icons/QuestionIcon.js";import"../../icon/icons/RedCrossIcon.js";import"../../icon/icons/SearchIcon.js";import"../../icon/icons/SuccessIcon.js";import"../../icon/icons/WarningIcon.js";import"../../icon/icons/MinusIcon.js";import"../../icon/icons/ThumbDownIcon.js";import"../../icon/icons/ThumbUpIcon.js";import"../../icon/icons/TrashCanIcon.js";import"../../icon/icons/PenIcon.js";import{PrimaryButton as r,SecondaryButton as c,TertiaryButton as m}from"../../button/Button.js";import"../../card/Card.js";import"../../card/CardImage.js";import"../../card/NavCard.js";import"../../checkbox/Checkbox.js";import"../../combobox/Combobox.js";import"../../cookie-consent/CookieConsentContext.js";import"react-dom";import"../../modal/Modal.js";import"react-a11y-dialog";import"../../list/List.js";import"../../list/ListItem.js";import"../../datepicker/DatePicker.js";import{useFeedbackContext as p}from"../feedbackContext.js";import{FeedbackSuccess as a}from"../FeedbackSuccess.js";import"../../tooltip/Tooltip.js";import"../../tooltip/TooltipContent.js";import"../../tooltip/TooltipTrigger.js";import"../../input-group/InputGroup.js";import{FollowUpProvider as l}from"./followupContext.js";import"../main-question/mainQuestionContext.js";import"../../radio-button/RadioButton.js";import"../../radio-button/radioGroupContext.js";import"../../radio-button/BaseRadioButton.js";import"../../text-input/BaseTextArea.js";import"../../text-input/BaseTextInput.js";import"../../text-input/TextArea.js";import"../../text-input/TextInput.js";import"../../../utilities/polymorphism/SlotComponent.js";import{getQuestionFromType as j}from"../utils.js";import"../../icon-button/IconButton.js";import"../../link/Link.js";import"../../link/NavLink.js";import"../../link-list/LinkList.js";import"../../message/Message.js";import"../../message/FormErrorMessage.js";import"../../popover/Popover.js";import"../../../../NativeSelect-CfNZEQF0.js";import"../../tag/Tag.js";import{useFollowup as u}from"./useFollowup.js";const d={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."},k=({questions:k,successMessage:I=d,onSubmit:b})=>{const[h,g]=t(!1),f=s(null),x=u(k,b),{handleAbort:C,handleNext:v,step:w,submitted:S}=x,{followupStarted:N,setFollowupStarted:T,setFollowupSubmitted:A,contactSubmitted:y}=p();n((()=>{0!==w.number&&f.current&&f.current.focus()}),[w]),n((()=>{A(S)}),[S,A]);const F=j(k[w.number].type),L=w.isLast?r:c;return h?null:o("div",{"aria-live":"polite",children:i(l,{state:x,children:[!N&&i("div",{className:"jkl-feedback__fade-in",children:[o("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?"}),o("p",{className:"jkl-body jkl-spacing-xl--bottom",children:"Det tar kun et minutt, og hjelper oss å lage bedre løsninger for deg."}),o(r,{onClick:()=>T(!0),className:"jkl-spacing-xl--right",children:"Jeg har tid!"}),o(m,{onClick:()=>g(!0),children:"Nei takk"})]}),!S&&N&&i("form",{onSubmit:v,className:"jkl-feedback__fade-in",children:[i("p",{className:"jkl-feedback__step-counter",ref:f,children:["Steg ",w.number+1," av ",k.length]}),e(F,{...k[w.number],autoFocus:!0,key:w.number}),i("div",{className:"jkl-spacing-xl--top","aria-live":"off",children:[o(L,{type:"submit",children:w.isLast?"Send inn":"Neste"}),o(m,{onClick:C,className:"jkl-spacing-xl--left",children:"Avbryt"})]})]}),S&&!y&&o(a,{...I})]})})};export{k as Followup};
2
+ //# sourceMappingURL=Followup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Followup.js","sources":["../../../../../src/components/feedback/followup/Followup.tsx"],"sourcesContent":["import React, { ReactNode, useEffect, useRef, useState, FC } from \"react\";\nimport { PrimaryButton, SecondaryButton, TertiaryButton } from \"../..\";\nimport { useFeedbackContext } from \"../feedbackContext\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess\";\nimport { FeedbackAnswer, FollowupQuestion } from \"../types\";\nimport { getQuestionFromType } from \"../utils\";\nimport { FollowUpProvider } from \"./followupContext\";\nimport { useFollowup } from \"./useFollowup\";\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\ninterface Props {\n /** Spørsmålet/ene som skal stilles. Kan være av typen radio, checkbox eller text */\n questions: FollowupQuestion[];\n /** Lar deg tilpasse meldingen som kommer når brukeren har svart på spørsmålene. */\n successMessage?: {\n title: string;\n children: ReactNode;\n };\n onSubmit: (values: FeedbackAnswer[]) => void;\n}\n\nexport const Followup: FC<Props> = ({ questions, successMessage = defaultSuccessMessage, onSubmit }) => {\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 { followupStarted, setFollowupStarted, setFollowupSubmitted, contactSubmitted } = useFeedbackContext();\n\n useEffect(() => {\n if (step.number === 0) {\n return;\n }\n focusRef.current && 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 løsninger for deg.\n </p>\n <PrimaryButton onClick={() => setFollowupStarted(true)} className=\"jkl-spacing-xl--right\">\n Jeg har tid!\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>Nei takk</TertiaryButton>\n </div>\n )}\n {!submitted && followupStarted && (\n <form onSubmit={handleNext} className=\"jkl-feedback__fade-in\">\n <p className=\"jkl-feedback__step-counter\" ref={focusRef}>\n Steg {step.number + 1} av {questions.length}\n </p>\n {/* eslint-disable-next-line jsx-a11y/no-autofocus */}\n <QuestionComponent {...questions[step.number]} autoFocus key={step.number} />\n <div className=\"jkl-spacing-xl--top\" aria-live=\"off\">\n <Button type=\"submit\">{step.isLast ? \"Send inn\" : \"Neste\"}</Button>\n <TertiaryButton onClick={handleAbort} className=\"jkl-spacing-xl--left\">\n Avbryt\n </TertiaryButton>\n </div>\n </form>\n )}\n {submitted && !contactSubmitted && <FeedbackSuccess {...successMessage} />}\n </FollowUpProvider>\n </div>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","Followup","questions","successMessage","onSubmit","noThanks","setNoThanks","useState","focusRef","useRef","followupState","useFollowup","handleAbort","handleNext","step","submitted","followupStarted","setFollowupStarted","setFollowupSubmitted","contactSubmitted","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":"0sGASA,MAAMA,EAAwB,CAC1BC,MAAO,eACPC,SACI,yJAcKC,EAAsB,EAAGC,UAAAA,EAAWC,eAAAA,EAAiBL,EAAuBM,SAAAA,MACrF,MAAOC,EAAUC,GAAeC,GAAS,GACnCC,EAAWC,EAA6B,MACxCC,EAAgBC,EAAYT,EAAWE,IACrCQ,YAAAA,EAAaC,WAAAA,EAAYC,KAAAA,EAAMC,UAAAA,GAAcL,GAC7CM,gBAAAA,EAAiBC,mBAAAA,EAAoBC,qBAAAA,EAAsBC,iBAAAA,GAAqBC,IAExFC,GAAU,KACc,IAAhBP,EAAKQ,QAGAd,EAAAe,SAAWf,EAASe,QAAQC,OAAM,GAC5C,CAACV,IAEJO,GAAU,KACNH,EAAqBH,EAAS,GAC/B,CAACA,EAAWG,IAETO,MAAAA,EAAoBC,EAAoBxB,EAAUY,EAAKQ,QAAQK,MAC/DC,EAASd,EAAKe,OAASC,EAAgBC,EAE7C,OAAI1B,EACO,OAIN,MAAI,CAAA,YAAU,SACXL,SAACgC,EAAAC,EAAA,CAAiBC,MAAOxB,EACpBV,SAAA,EAACgB,GACEgB,EAAC,MAAI,CAAAG,UAAU,wBACXnC,SAAA,CAACoC,EAAA,IAAA,CAAED,UAAU,2DAA2DnC,SAExE,mDACCoC,EAAA,IAAA,CAAED,UAAU,kCAAkCnC,SAE/C,0EACAoC,EAACN,GAAcO,QAAS,IAAMpB,GAAmB,GAAOkB,UAAU,wBAAwBnC,SAE1F,mBACCsC,EAAe,CAAAD,QAAS,IAAM/B,GAAY,GAAON,SAAQ,iBAGhEe,GAAaC,GACXgB,EAAC,QAAK5B,SAAUS,EAAYsB,UAAU,wBAClCnC,SAAA,CAAAgC,EAAC,IAAE,CAAAG,UAAU,6BAA6BI,IAAK/B,EAAUR,SAAA,CAAA,QAC/Cc,EAAKQ,OAAS,EAAE,OAAKpB,EAAUsC,UAGzCC,EAAChB,EAAmB,IAAGvB,EAAUY,EAAKQ,QAASoB,WAAS,EAACC,IAAK7B,EAAKQ,SAClEU,EAAA,MAAA,CAAIG,UAAU,sBAAsB,YAAU,MAC3CnC,SAAA,CAAAoC,EAACR,GAAOD,KAAK,SAAU3B,SAAKc,EAAAe,OAAS,WAAa,YACjDS,EAAe,CAAAD,QAASzB,EAAauB,UAAU,uBAAuBnC,SAEvE,iBAIXe,IAAcI,GAAqBiB,EAAAQ,EAAA,IAAoBzC,QAEhE"}
@@ -0,0 +1,2 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as o,useContext as t}from"react";const r=o(void 0),s=()=>t(r),a=({state:o,children:t})=>e(r.Provider,{value:o,children:t});export{a as FollowUpProvider,s as useFollowUpContext};
2
+ //# sourceMappingURL=followupContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"followupContext.js","sources":["../../../../../src/components/feedback/followup/followupContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport { WithChildren } from \"../../..\";\nimport { FollowupState } from \"../types\";\n\nconst followUpContext = createContext<FollowupState | undefined>(undefined);\n\nexport const useFollowUpContext = (): FollowupState | undefined => useContext(followUpContext);\n\ninterface FollowupContextProviderProps extends WithChildren {\n state: FollowupState;\n}\n\nexport const FollowUpProvider: React.FC<FollowupContextProviderProps> = ({ state, children }) => (\n <followUpContext.Provider value={state}>{children}</followUpContext.Provider>\n);\n"],"names":["followUpContext","createContext","useFollowUpContext","useContext","FollowUpProvider","state","children","jsx","Provider","value"],"mappings":"8FAIA,MAAMA,EAAkBC,OAAyC,GAEpDC,EAAqB,IAAiCC,EAAWH,GAMjEI,EAA2D,EAAGC,MAAAA,EAAOC,SAAAA,KAC7EC,EAAAP,EAAgBQ,SAAhB,CAAyBC,MAAOJ,EAAQC,SAAAA"}
@@ -0,0 +1,2 @@
1
+ import{useState as e,useRef as t,useEffect as n,useCallback as u}from"react";const s=(s,r)=>{const[o,a]=e(),[i,l]=e({number:0,question:s[0],isLast:1===s.length}),[d,m]=e(!1),[v,c]=e(!1),[b,f]=e(),p=t({values:o,submitted:v,onSubmit:r});n((()=>{p.current={...p.current,values:o,submitted:v}}),[o,v]);const q=u((()=>{!p.current.submitted&&void 0!==p.current.values&&p.current.onSubmit(p.current.values)}),[]);return n((()=>{d&&(q(),c(!0))}),[d,q]),n((()=>(typeof window<"u"&&window.addEventListener("beforeunload",q),()=>{q(),window.removeEventListener("beforeunload",q)})),[q]),{questions:s,values:o,step:i,currentValue:b,setCurrentValue:f,submitted:v,handleNext:function(e){null==e||e.preventDefault();const t=Array.isArray(b)?b.map((e=>e.value.toString())):null==b?void 0:b.value,n={...i.question,name:i.question.name||i.question.label,value:t};a((e=>[...(null==e?void 0:e.filter((e=>e.name!==n.name)))||[],n])),f(void 0),i.isLast?m(!0):l((e=>{const t=e.number+1;return{number:t,question:s[t],isLast:t+1>=s.length}}))},handleAbort:function(){a(void 0),f(void 0),l({number:0,question:s[0],isLast:1===s.length}),c(!0)}}};export{s as useFollowup};
2
+ //# sourceMappingURL=useFollowup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFollowup.js","sources":["../../../../../src/components/feedback/followup/useFollowup.ts"],"sourcesContent":["import { Dispatch, FormEvent, SetStateAction, useCallback, useEffect, useRef, useState } from \"react\";\nimport { FeedbackAnswer, FeedbackOption, FollowupQuestion } from \"../types\";\n\ntype CurrentValue = FeedbackOption<string | number> | FeedbackOption<string | number>[] | 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 = (questions: FollowupQuestion[], onSubmit: (a: FeedbackAnswer[]) => void): 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<FeedbackOption | FeedbackOption[]>();\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 (!followupRef.current.submitted && followupRef.current.values !== undefined) {\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 = oldValues?.filter((oldValue) => oldValue.name !== newValue.name) || [];\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 { questions, values, step, currentValue, setCurrentValue, submitted, handleNext, handleAbort };\n};\n"],"names":["useFollowup","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":"6EAoBa,MAAAA,EAAc,CAACC,EAA+BC,KACjD,MAACC,EAAQC,GAAaC,KACrBC,EAAMC,GAAWF,EAAS,CAC7BG,OAAQ,EACRC,SAAUR,EAAU,GACpBS,OAA6B,IAArBT,EAAUU,UAEfC,EAAcC,GAAmBR,GAAS,IAC1CS,EAAWC,GAAgBV,GAAS,IACpCW,EAAcC,GAAmBZ,IAIlCa,EAAcC,EAAO,CACvBhB,OAAAA,EACAW,UAAAA,EACAZ,SAAAA,IAIJkB,GAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACflB,OAAAA,EACAW,UAAAA,EAAA,GAEL,CAACX,EAAQW,IAGNQ,MAAAA,EAAgBC,GAAY,MACzBL,EAAYG,QAAQP,gBAA4C,IAA/BI,EAAYG,QAAQlB,QACtDe,EAAYG,QAAQnB,SAASgB,EAAYG,QAAQlB,OAAM,GAE5D,IAiDH,OAAAiB,GAAU,KACFR,IACcU,IACdP,GAAa,GAAI,GAEtB,CAACH,EAAcU,IAGlBF,GAAU,YACKI,OAAW,KACXA,OAAAC,iBAAiB,eAAgBH,GAErC,KACWA,IACPE,OAAAE,oBAAoB,eAAgBJ,EAAa,IAE7D,CAACA,IAEG,CAAErB,UAAAA,EAAWE,OAAAA,EAAQG,KAAAA,EAAMU,aAAAA,EAAcC,gBAAAA,EAAiBH,UAAAA,EAAWa,WAhE5E,SAAoBC,GAChB,MAAAA,GAAAA,EAAGC,iBAEH,MAAMC,EAAQC,MAAMC,QAAQhB,GACtBA,EAAaiB,KAAKC,GAAWA,EAAOJ,MAAMK,aAC1C,MAAAnB,OAAAA,EAAAA,EAAcc,MAEdM,EAAW,IACV9B,EAAKG,SACR4B,KAAM/B,EAAKG,SAAS4B,MAAQ/B,EAAKG,SAAS6B,MAC1CR,MAAAA,GAGJ1B,GAAWmC,GAEA,KADgB,MAAAA,OAAAA,EAAAA,EAAWC,QAAQC,GAAaA,EAASJ,OAASD,EAASC,SAAS,GAChED,KAE/BnB,OAAgB,GAEZX,EAAKI,OACLG,GAAgB,GAEhBN,GAASmC,IACCC,MAAAA,EAAaD,EAAYlC,OAAS,EACjC,MAAA,CACHA,OAAQmC,EACRlC,SAAUR,EAAU0C,GACpBjC,OAAQiC,EAAa,GAAK1C,EAAUU,OAAA,GAIpD,EAiCwFiC,YA9BxF,WACIxC,OAAU,GACVa,OAAgB,GACRV,EAAA,CACJC,OAAQ,EACRC,SAAUR,EAAU,GACpBS,OAA6B,IAArBT,EAAUU,SAEtBI,GAAa,EACjB"}
@@ -0,0 +1,2 @@
1
+ import{Feedback as e}from"./Feedback.js";import{PRESETS as s}from"./presets.js";export{e as Feedback,s as PRESETS};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{jsxs as o,Fragment as i,jsx as n}from"react/jsx-runtime";import{c as t}from"../../../../clsx-BeLtu-UY.js";import{useEffect as s}from"react";import{useAnimatedHeight as e}from"../../../hooks/useAnimatedHeight/useAnimatedHeight.js";import"../../../hooks/useScreen/useScreen.js";import"../../../hooks/useId/useId.js";import{PrimaryButton as r,TertiaryButton as c}from"../../button/Button.js";import{useFeedbackContext as m}from"../feedbackContext.js";import{FeedbackSuccess as p}from"../FeedbackSuccess.js";import"../../checkbox/Checkbox.js";import"../../tooltip/Tooltip.js";import"../../tooltip/TooltipContent.js";import"../../tooltip/TooltipTrigger.js";import"../../icon/Icon.js";import"../../icon/icons/animated/ArrowVerticalAnimated.js";import"../../icon/icons/animated/ArrowHorizontalAnimated.js";import"../../icon/icons/animated/PlusRemoveAnimated.js";import"../../icon/icons/ArrowDownIcon.js";import"../../icon/icons/ArrowLeftIcon.js";import"../../icon/icons/ArrowNorthEastIcon.js";import"../../icon/icons/ArrowRightIcon.js";import"../../icon/icons/ArrowUpIcon.js";import"../../icon/icons/CalendarIcon.js";import"../../icon/icons/CheckIcon.js";import"../../icon/icons/ChevronDownIcon.js";import"../../icon/icons/ChevronLeftIcon.js";import"../../icon/icons/ChevronRightIcon.js";import"../../icon/icons/ChevronUpIcon.js";import"../../icon/icons/CloseIcon.js";import"../../icon/icons/CopyIcon.js";import"../../icon/icons/DotsIcon.js";import"../../icon/icons/DragIcon.js";import"../../icon/icons/ErrorIcon.js";import"../../icon/icons/GreenCheckIcon.js";import"../../icon/icons/HamburgerIcon.js";import"../../icon/icons/InfoIcon.js";import"../../icon/icons/LinkIcon.js";import"../../icon/icons/PlusIcon.js";import"../../icon/icons/QuestionIcon.js";import"../../icon/icons/RedCrossIcon.js";import"../../icon/icons/SearchIcon.js";import"../../icon/icons/SuccessIcon.js";import"../../icon/icons/WarningIcon.js";import"../../icon/icons/MinusIcon.js";import"../../icon/icons/ThumbDownIcon.js";import"../../icon/icons/ThumbUpIcon.js";import"../../icon/icons/TrashCanIcon.js";import"../../icon/icons/PenIcon.js";import"../../input-group/InputGroup.js";import"../followup/followupContext.js";import{MainQuestionContextProvider as a}from"./mainQuestionContext.js";import"../../radio-button/RadioButton.js";import"../../radio-button/radioGroupContext.js";import"../../radio-button/BaseRadioButton.js";import"../../text-input/BaseTextArea.js";import"../../text-input/BaseTextInput.js";import"../../text-input/TextArea.js";import"../../text-input/TextInput.js";import{AddonQuestion as j}from"../questions/AddonQuestion.js";import"../../../utilities/polymorphism/SlotComponent.js";import{getQuestionFromType as u}from"../utils.js";import{useMainQuestion as l}from"./useMainQuestion.js";const 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."},I=({label:I,options:h,type:b,addOnQuestion:k,successMessage:f=d,helpLabel:x,onSubmit:C})=>{const g=l(C),{setFeedbackSubmitted:A,contactSubmitted:v}=m(),{handleSubmit:w,currentValue:T,setCurrentValue:S,submitted:Q}=g,[y]=e(void 0!==T);s((()=>{A(Q)}),[Q,A]);const B=u(b);return o(i,{children:[!Q&&o(a,{state:g,children:[n(B,{label:I,options:h,helpLabel:x}),o("div",{ref:y,className:t({"jkl-feedback__submit-wrapper":!0,"jkl-feedback__submit-wrapper--hidden":void 0===T}),children:[k&&n(j,{helpLabel:"object"==typeof k?k.helpLabel:void 0,label:"object"==typeof k?k.label:void 0}),o("div",{className:"jkl-spacing-xl--top",children:[n(r,{onClick:w,className:"jkl-spacing-xl--right",children:"Send"}),n(c,{onClick:()=>S(void 0),children:"Avbryt"})]})]})]}),Q&&!v&&n(p,{...f})]})};export{I as MainQuestion};
2
+ //# sourceMappingURL=MainQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MainQuestion.js","sources":["../../../../../src/components/feedback/main-question/MainQuestion.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { ReactNode, useEffect, FC, ComponentProps } from \"react\";\nimport { useAnimatedHeight } from \"../../../hooks\";\nimport { PrimaryButton, TertiaryButton } from \"../../button\";\nimport { Feedback } from \"../Feedback\";\nimport { useFeedbackContext } from \"../feedbackContext\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess\";\nimport { AddonQuestion } from \"../questions\";\nimport { FeedbackOption, FeedbackType } from \"../types\";\nimport { getQuestionFromType } from \"../utils\";\nimport { MainQuestionContextProvider } from \"./mainQuestionContext\";\nimport { useMainQuestion } from \"./useMainQuestion\";\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 } = useFeedbackContext();\n const { handleSubmit, currentValue, setCurrentValue, submitted } = mainQuestionState;\n const [submitWrapperRef] = useAnimatedHeight<HTMLDivElement>(currentValue !== undefined);\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 <MainQuestionComp label={label} options={options} helpLabel={helpLabel} />\n <div\n ref={submitWrapperRef}\n className={clsx({\n \"jkl-feedback__submit-wrapper\": true,\n \"jkl-feedback__submit-wrapper--hidden\": currentValue === undefined,\n })}\n >\n {addOnQuestion && (\n <AddonQuestion\n helpLabel={typeof addOnQuestion === \"object\" ? addOnQuestion.helpLabel : undefined}\n label={typeof addOnQuestion === \"object\" ? addOnQuestion.label : undefined}\n />\n )}\n <div className=\"jkl-spacing-xl--top\">\n <PrimaryButton onClick={handleSubmit} className=\"jkl-spacing-xl--right\">\n Send\n </PrimaryButton>\n <TertiaryButton onClick={() => setCurrentValue(undefined)}>Avbryt</TertiaryButton>\n </div>\n </div>\n </MainQuestionContextProvider>\n )}\n {submitted && !contactSubmitted && <FeedbackSuccess {...successMessage} />}\n </>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","MainQuestion","label","options","type","addOnQuestion","successMessage","helpLabel","onSubmit","mainQuestionState","useMainQuestion","setFeedbackSubmitted","contactSubmitted","useFeedbackContext","handleSubmit","currentValue","setCurrentValue","submitted","submitWrapperRef","useAnimatedHeight","useEffect","MainQuestionComp","getQuestionFromType","jsxs","Fragment","MainQuestionContextProvider","state","jsx","ref","className","clsx","AddonQuestion","PrimaryButton","onClick","TertiaryButton","FeedbackSuccess"],"mappings":"2tFAaA,MAAMA,EAAwB,CAC1BC,MAAO,6BACPC,SACI,8HAeKC,EAA0B,EACnCC,MAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,cAAAA,EACAC,eAAAA,EAAiBR,EACjBS,UAAAA,EACAC,SAAAA,MAEM,MAAAC,EAAoBC,EAAgBF,IAElCG,qBAAAA,EAAsBC,iBAAAA,GAAqBC,KAC3CC,aAAAA,EAAcC,aAAAA,EAAcC,gBAAAA,EAAiBC,UAAAA,GAAcR,GAC5DS,GAAoBC,OAAmD,IAAjBJ,GAE7DK,GAAU,KACNT,EAAqBM,EAAS,GAC/B,CAACA,EAAWN,IAETU,MAAAA,EAAmBC,EAAoBlB,GAE7C,OAESmB,EAAAC,EAAA,CAAAxB,SAAA,EAACiB,GACEM,EAACE,EAA4B,CAAAC,MAAOjB,EAChCT,SAAA,CAAC2B,EAAAN,EAAA,CAAiBnB,MAAAA,EAAcC,QAAAA,EAAkBI,UAAAA,IAClDgB,EAAC,MAAA,CACGK,IAAKV,EACLW,UAAWC,EAAK,CACZ,gCAAgC,EAChC,4CAAyD,IAAjBf,IAG3Cf,SAAA,CACGK,GAAAsB,EAACI,EAAA,CACGxB,UAAoC,iBAAlBF,EAA6BA,EAAcE,eAAY,EACzEL,MAAgC,iBAAlBG,EAA6BA,EAAcH,WAAQ,IAGzEqB,EAAC,MAAI,CAAAM,UAAU,sBACX7B,SAAA,CAAA2B,EAACK,EAAc,CAAAC,QAASnB,EAAce,UAAU,wBAAwB7B,SAExE,WACCkC,EAAe,CAAAD,QAAS,IAAMjB,OAAgB,GAAYhB,SAAM,oBAKhFiB,IAAcL,GAAqBe,EAAAQ,EAAA,IAAoB7B,MAC5D"}
@@ -0,0 +1,2 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as t,useContext as o}from"react";const r=t(void 0),s=()=>o(r),a=({state:t,children:o})=>e(r.Provider,{value:t,children:o});export{a as MainQuestionContextProvider,s as useMainQuestionContext};
2
+ //# sourceMappingURL=mainQuestionContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mainQuestionContext.js","sources":["../../../../../src/components/feedback/main-question/mainQuestionContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport { WithChildren } from \"../../..\";\nimport { FeedbackState } from \"../types\";\n\nconst mainQuestionContext = createContext<FeedbackState | undefined>(undefined);\n\nexport const useMainQuestionContext = (): FeedbackState | undefined => useContext(mainQuestionContext);\n\ninterface Props extends WithChildren {\n state: FeedbackState;\n}\n\nexport const MainQuestionContextProvider: React.FC<Props> = ({ state, children }) => (\n <mainQuestionContext.Provider value={state}>{children}</mainQuestionContext.Provider>\n);\n"],"names":["mainQuestionContext","createContext","useMainQuestionContext","useContext","MainQuestionContextProvider","state","children","jsx","Provider","value"],"mappings":"8FAIA,MAAMA,EAAsBC,OAAyC,GAExDC,EAAyB,IAAiCC,EAAWH,GAMrEI,EAA+C,EAAGC,MAAAA,EAAOC,SAAAA,KACjEC,EAAAP,EAAoBQ,SAApB,CAA6BC,MAAOJ,EAAQC,SAAAA"}
@@ -0,0 +1,2 @@
1
+ import{useState as e,useRef as t,useEffect as s,useCallback as u}from"react";const a=a=>{const[n,r]=e(),[i,o]=e(),[m,l]=e(!1),c=t({onSubmit:a,currentValue:n,message:i,submitted:m});s((()=>{c.current={...c.current,onSubmit:a,currentValue:n,message:i,submitted:m}}),[a,n,i,m]);const d=u(((e=!0)=>{const{message:t,currentValue:s,submitted:u,onSubmit:a}=c.current;if(!u&&void 0!==s){a({feedbackValue:Array.isArray(s)?s.map((e=>e.value)):null==s?void 0:s.value,intentionalSubmit:e,...e&&t?{message:t}:{}})}}),[]),b=u((()=>d(!1)),[d]);return s((()=>(typeof window<"u"&&window.addEventListener("beforeunload",b),()=>{b(),window.removeEventListener("beforeunload",b)})),[b]),{currentValue:n,setCurrentValue:r,message:i,setMessage:o,submitted:m,handleSubmit:()=>{d(),l(!0)}}};export{a as useMainQuestion};
2
+ //# sourceMappingURL=useMainQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMainQuestion.js","sources":["../../../../../src/components/feedback/main-question/useMainQuestion.ts"],"sourcesContent":["import { useState, useRef, useCallback, useEffect, SetStateAction, Dispatch } from \"react\";\nimport { FeedbackType, FeedbackOption } from \"../types\";\n\ntype Value = FeedbackOption<string | number> | FeedbackOption<string | number>[] | 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: () => void;\n};\n\nexport const useMainQuestion = (onSubmit: (f: FeedbackType) => void): MainQuestion => {\n const [currentValue, setCurrentValue] = useState<FeedbackOption | FeedbackOption[]>();\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 } = 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 = () => {\n submitHandler();\n setSubmitted(true);\n };\n\n return {\n currentValue,\n setCurrentValue,\n message,\n setMessage,\n submitted,\n handleSubmit,\n };\n};\n"],"names":["useMainQuestion","onSubmit","currentValue","setCurrentValue","useState","message","setMessage","submitted","setSubmitted","feedbackRef","useRef","useEffect","current","submitHandler","useCallback","intentionalSubmit","feedbackValue","Array","isArray","map","option","value","autoSubmit","window","addEventListener","removeEventListener","handleSubmit"],"mappings":"6EAca,MAAAA,EAAmBC,IACtB,MAACC,EAAcC,GAAmBC,KACjCC,EAASC,GAAcF,KACvBG,EAAWC,GAAgBJ,GAAS,GAErCK,EAAcC,EAAO,CACvBT,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,IAGJI,GAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACfX,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,EAAA,GAEL,CAACN,EAAUC,EAAcG,EAASE,IAErC,MAAMM,EAAgBC,GAAY,CAACC,GAAoB,KAC7C,MAAEV,QAAAA,EAASH,aAAAA,EAAcK,UAAAA,EAAWN,SAAAA,GAAaQ,EAAYG,QAE/D,IAACL,QAA8B,IAAjBL,EAA4B,CAI1CD,EAAS,CACLe,cAJkBC,MAAMC,QAAQhB,GAC9BA,EAAaiB,KAAKC,GAAWA,EAAOC,QACpCnB,MAAAA,SAAAA,EAAcmB,MAGhBN,kBAAAA,KACIA,GAAqBV,EAAU,CAAEA,QAAAA,GAAY,CAAC,GAE1D,IACD,IAEGiB,EAAaR,GAAY,IAAMD,GAAc,IAAQ,CAACA,IAE5DF,OAAAA,GAAU,YACKY,OAAW,KACXA,OAAAC,iBAAiB,eAAgBF,GAErC,KACQA,IACJC,OAAAE,oBAAoB,eAAgBH,EAAU,IAE1D,CAACA,IAOG,CACHpB,aAAAA,EACAC,gBAAAA,EACAE,QAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAmB,aAXiB,KACHb,IACdL,GAAa,EAAI,EASjB"}
@@ -0,0 +1,2 @@
1
+ import{defaultOptions as e}from"./questions/smileyUtils.js";const a={type:"smiley",label:"Hvor fornøyd er du med denne nettsiden?",options:e,addOnQuestion:!0},t={"Fant du":{type:"radio",label:"Fant du det du lette etter?",options:[{label:"Ja",value:"ja",textAreaLabel:"Så bra! Har du noen tilbakemeldinger kan du skrive dem her."},{label:"Nei",value:"nei",textAreaLabel:"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre."}],addOnQuestion:!0},"Fikk du gjort":{type:"radio",label:"Fikk du gjort det du skulle?",options:[{label:"Ja",value:"ja",textAreaLabel:"Så bra! Har du noen tilbakemeldinger kan du skrive dem her."},{label:"Nei",value:"nei",textAreaLabel:"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre."}],addOnQuestion:!0},"Hvor fornøyd 5":a,Smileys:a};export{t as PRESETS};
2
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.js","sources":["../../../../src/components/feedback/presets.tsx"],"sourcesContent":["import { ComponentProps } from \"react\";\nimport { defaultOptions as smileyOptions } from \"./questions/smileyUtils\";\nimport { Feedback } from \"./\";\n\ntype FeedbackProps = ComponentProps<typeof Feedback>;\ntype PresetProperties = Pick<FeedbackProps, \"label\" | \"type\" | \"options\" | \"addOnQuestion\">;\n\nconst smileyQuestion: PresetProperties = {\n type: \"smiley\",\n label: \"Hvor fornøyd er du med denne nettsiden?\",\n options: smileyOptions,\n addOnQuestion: true,\n};\n\nexport const PRESETS: Record<string, PresetProperties> = {\n \"Fant du\": {\n type: \"radio\",\n label: \"Fant du det du lette etter?\",\n options: [\n {\n label: \"Ja\",\n value: \"ja\",\n textAreaLabel: \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n {\n label: \"Nei\",\n value: \"nei\",\n textAreaLabel: \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n ],\n addOnQuestion: true,\n },\n \"Fikk du gjort\": {\n type: \"radio\",\n label: \"Fikk du gjort det du skulle?\",\n options: [\n {\n label: \"Ja\",\n value: \"ja\",\n textAreaLabel: \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n {\n label: \"Nei\",\n value: \"nei\",\n textAreaLabel: \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n ],\n addOnQuestion: true,\n },\n \"Hvor fornøyd 5\": smileyQuestion,\n Smileys: smileyQuestion,\n};\n"],"names":["smileyQuestion","type","label","options","smileyOptions","addOnQuestion","PRESETS","value","textAreaLabel","Smileys"],"mappings":"4DAOA,MAAMA,EAAmC,CACrCC,KAAM,SACNC,MAAO,0CACPC,QAASC,EACTC,eAAe,GAGNC,EAA4C,CACrD,UAAW,CACPL,KAAM,QACNC,MAAO,8BACPC,QAAS,CACL,CACID,MAAO,KACPK,MAAO,KACPC,cAAe,+DAEnB,CACIN,MAAO,MACPK,MAAO,MACPC,cAAe,uFAGvBH,eAAe,GAEnB,gBAAiB,CACbJ,KAAM,QACNC,MAAO,+BACPC,QAAS,CACL,CACID,MAAO,KACPK,MAAO,KACPC,cAAe,+DAEnB,CACIN,MAAO,MACPK,MAAO,MACPC,cAAe,uFAGvBH,eAAe,GAEnB,iBAAkBL,EAClBS,QAAST"}
@@ -0,0 +1,2 @@
1
+ import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import{useState as n,useEffect as a}from"react";import"../../text-input/BaseTextArea.js";import"../../text-input/BaseTextInput.js";import{TextArea as s}from"../../text-input/TextArea.js";import"../../text-input/TextInput.js";import{useFeedbackContext as o}from"../feedbackContext.js";import{useMainQuestionContext as i}from"../main-question/mainQuestionContext.js";const l=({helpLabel:l="Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.",label:u})=>{const{counter:d}=o(),p=i(),[m,c]=n();if(a((()=>{var e,t,r;const n=Array.isArray(null==p?void 0:p.currentValue)?null==(e=null==p?void 0:p.currentValue[0].textAreaLabel)?void 0:e.toString():null==(r=null==(t=null==p?void 0:p.currentValue)?void 0:t.textAreaLabel)?void 0:r.toString();c(n||u)}),[null==p?void 0:p.currentValue,u]),!p)return console.error("Addon question must be used inside a MainQuestion context provider"),null;const{message:x,setMessage:b}=p;return e(t,{children:[void 0!==p.currentValue&&e("div",{className:"jkl-sr-only","aria-live":"polite",children:[m," ",l]}),r(s,{startOpen:!0,rows:4,"data-testid":"jkl-feedback__open-question",className:"jkl-spacing-xl--bottom jkl-spacing-xl--top",label:m,labelProps:{srOnly:!0},placeholder:m,helpLabel:l,value:x||"",onChange:e=>b(e.target.value),counter:d})]})};export{l as AddonQuestion};
2
+ //# sourceMappingURL=AddonQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AddonQuestion.js","sources":["../../../../../src/components/feedback/questions/AddonQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useState } from \"react\";\nimport { TextArea } from \"../../text-input\";\nimport { useFeedbackContext } from \"../feedbackContext\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext\";\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(\"Addon question must be used inside a MainQuestion context provider\");\n return null;\n }\n\n const { message, setMessage } = context;\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => 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":["AddonQuestion","helpLabel","label","counter","useFeedbackContext","context","useMainQuestionContext","dynamicLabel","setDynamicLabel","useState","useEffect","labelFromValue","Array","isArray","currentValue","_a","textAreaLabel","toString","_c","_b","console","error","message","setMessage","jsxs","Fragment","children","className","jsx","TextArea","startOpen","rows","labelProps","srOnly","placeholder","value","onChange","e","target"],"mappings":"6aAUO,MAAMA,EAAiC,EAC1CC,UAAAA,EAAY,uJACZC,MAAAA,MAEM,MAAEC,QAAAA,GAAYC,IACdC,EAAUC,KACTC,EAAcC,GAAmBC,IASxC,GAPAC,GAAU,eACN,MAAMC,EAAiBC,MAAMC,QAAQ,MAAAR,OAAAA,EAAAA,EAASS,cACxC,OAAAC,EAAA,MAAAV,OAAAA,EAAAA,EAASS,aAAa,GAAGE,oBAAzB,EAAAD,EAAwCE,WACxC,OAAAC,EAAA,OAAAC,EAAA,MAAAd,OAAA,EAAAA,EAASS,mBAATK,EAAAA,EAAuBH,oBAAvB,EAAAE,EAAsCD,WAC5CT,EAAgBG,GAAkBT,EAAK,GACxC,CAAC,MAAAG,OAAA,EAAAA,EAASS,aAAcZ,KAEtBG,EACO,OAAAe,QAAAC,MAAM,sEACP,KAGL,MAAEC,QAAAA,EAASC,WAAAA,GAAelB,EAGhC,OAESmB,EAAAC,EAAA,CAAAC,SAAA,MAAyB,IAAzBrB,EAAQS,cACLU,EAAC,OAAIG,UAAU,cAAc,YAAU,SAClCD,SAAA,CAAAnB,EAAa,IAAEN,KAGxB2B,EAACC,EAAA,CACGC,WAAS,EACTC,KAAM,EACN,cAAY,8BACZJ,UAAU,6CACVzB,MAAOK,EACPyB,WAAY,CAAEC,QAAQ,GACtBC,YAAa3B,EACbN,UAAAA,EACAkC,MAAOb,GAAW,GAClBc,SAnBmDC,GAAMd,EAAWc,EAAEC,OAAOH,OAoB7EhC,QAAAA,MAER"}
@@ -0,0 +1,2 @@
1
+ import{jsx as o}from"react/jsx-runtime";import{useRef as n,useEffect as i}from"react";import{Checkbox as c}from"../../checkbox/Checkbox.js";import{FieldGroup as r}from"../../input-group/FieldGroup.js";import"../../input-group/InputGroup.js";import"../../icon/Icon.js";import"../../icon/icons/animated/ArrowVerticalAnimated.js";import"../../icon/icons/animated/ArrowHorizontalAnimated.js";import"../../icon/icons/animated/PlusRemoveAnimated.js";import"../../icon/icons/ArrowDownIcon.js";import"../../icon/icons/ArrowLeftIcon.js";import"../../icon/icons/ArrowNorthEastIcon.js";import"../../icon/icons/ArrowRightIcon.js";import"../../icon/icons/ArrowUpIcon.js";import"../../icon/icons/CalendarIcon.js";import"../../icon/icons/CheckIcon.js";import"../../icon/icons/ChevronDownIcon.js";import"../../icon/icons/ChevronLeftIcon.js";import"../../icon/icons/ChevronRightIcon.js";import"../../icon/icons/ChevronUpIcon.js";import"../../icon/icons/CloseIcon.js";import"../../icon/icons/CopyIcon.js";import"../../icon/icons/DotsIcon.js";import"../../icon/icons/DragIcon.js";import"../../icon/icons/ErrorIcon.js";import"../../icon/icons/GreenCheckIcon.js";import"../../icon/icons/HamburgerIcon.js";import"../../icon/icons/InfoIcon.js";import"../../icon/icons/LinkIcon.js";import"../../icon/icons/PlusIcon.js";import"../../icon/icons/QuestionIcon.js";import"../../icon/icons/RedCrossIcon.js";import"../../icon/icons/SearchIcon.js";import"../../icon/icons/SuccessIcon.js";import"../../icon/icons/WarningIcon.js";import"../../icon/icons/MinusIcon.js";import"../../icon/icons/ThumbDownIcon.js";import"../../icon/icons/ThumbUpIcon.js";import"../../icon/icons/TrashCanIcon.js";import"../../icon/icons/PenIcon.js";import{useFollowUpContext as s}from"../followup/followupContext.js";import{useMainQuestionContext as t}from"../main-question/mainQuestionContext.js";const e=({label:e,name:m,options:p,helpLabel:a,autoFocus:u=!1})=>{const l=s(),j=t(),I=l||j,d=n(null);i((()=>{u&&d.current&&d.current.focus()}),[u,d]);const f=o=>{const{value:n}=o.target,i=null==p?void 0:p.find((o=>o.value.toString()===n));if(i){if(null==I||!I.currentValue)return void(null==I||I.setCurrentValue([i]));if(Array.isArray(null==I?void 0:I.currentValue)){const o=I.currentValue.find((o=>o===i));o?I.setCurrentValue((n=>n.filter((n=>n!==o)))):I.setCurrentValue((o=>[...o,i]))}}};return I?o(r,{labelProps:{variant:"large"},legend:e,helpLabel:a,children:null==p?void 0:p.map(((n,i)=>o(c,{name:m||e,value:n.value.toString(),onChange:f,ref:0===i?d:void 0,children:n.label},`${e}-${n.value}`)))}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};export{e as CheckboxQuestion};
2
+ //# sourceMappingURL=CheckboxQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxQuestion.js","sources":["../../../../../src/components/feedback/questions/CheckboxQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useRef } from \"react\";\nimport { Checkbox } from \"../../checkbox\";\nimport { FieldGroup } from \"../../input-group\";\nimport { useFollowUpContext } from \"../followup/followupContext\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext\";\nimport { FeedbackOption, QuestionProps } from \"../types\";\n\nexport const CheckboxQuestion: React.FC<QuestionProps> = ({ label, name, options, helpLabel, autoFocus = false }) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n const matchingOption = options?.find((option) => option.value.toString() === value);\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((option) => option === matchingOption);\n if (found) {\n context.setCurrentValue((oldValues) =>\n (oldValues as FeedbackOption[]).filter((option) => option !== found),\n );\n } else {\n context.setCurrentValue((oldValues) => [...(oldValues as FeedbackOption[]), matchingOption]);\n }\n }\n };\n\n if (!context) {\n console.error(\"Questions must be used inside a Followup or Feedback context provider\");\n return null;\n }\n\n return (\n <FieldGroup labelProps={{ variant: \"large\" }} legend={label} helpLabel={helpLabel}>\n {options?.map((option, i) => (\n <Checkbox\n key={`${label}-${option.value}`}\n name={name || label}\n value={option.value.toString()}\n onChange={handleChange}\n ref={i === 0 ? ref : undefined}\n >\n {option.label}\n </Checkbox>\n ))}\n </FieldGroup>\n );\n};\n"],"names":["CheckboxQuestion","label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","handleChange","event","value","target","matchingOption","find","option","toString","currentValue","setCurrentValue","Array","isArray","found","oldValues","filter","jsx","FieldGroup","labelProps","variant","legend","children","map","i","Checkbox","onChange","console","error"],"mappings":"kzDAOa,MAAAA,EAA4C,EAAGC,MAAAA,EAAOC,KAAAA,EAAMC,QAAAA,EAASC,UAAAA,EAAWC,UAAAA,GAAY,MAC/FC,MAAAA,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,EAAyB,MAErCC,GAAU,KACFR,GAAaM,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACV,EAAWM,IAETK,MAAAA,EAAsDC,IAClD,MAAEC,MAAAA,GAAUD,EAAME,OAClBC,EAAiB,MAAAjB,OAAAA,EAAAA,EAASkB,MAAMC,GAAWA,EAAOJ,MAAMK,aAAeL,IAC7E,GAAKE,EAED,CAAA,GAAC,MAAAV,IAAAA,EAASc,aAEV,YADS,MAAAd,GAAAA,EAAAe,gBAAgB,CAACL,KAI9B,GAAIM,MAAMC,QAAQ,MAAAjB,OAAAA,EAAAA,EAASc,cAAe,CACtC,MAAMI,EAAQlB,EAAQc,aAAaH,MAAMC,GAAWA,IAAWF,IAC3DQ,EACQlB,EAAAe,iBAAiBI,GACpBA,EAA+BC,QAAQR,GAAWA,IAAWM,MAGlElB,EAAQe,iBAAiBI,GAAc,IAAKA,EAAgCT,IAEpF,CAAA,GAGCV,OAAAA,EAMAqB,EAAAC,EAAA,CAAWC,WAAY,CAAEC,QAAS,SAAWC,OAAQlC,EAAOG,UAAAA,EACxDgC,SAAA,MAAAjC,OAAA,EAAAA,EAASkC,KAAI,CAACf,EAAQgB,IACnBP,EAACQ,EAAA,CAEGrC,KAAMA,GAAQD,EACdiB,MAAOI,EAAOJ,MAAMK,WACpBiB,SAAUxB,EACVL,IAAW,IAAN2B,EAAU3B,OAAM,EAEpByB,SAAOd,EAAArB,OANH,GAAGA,KAASqB,EAAOJ,cARpCuB,QAAQC,MAAM,yEACP,KAAA"}
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as o,useRef as r,useEffect as a}from"react";import"../../../utilities/polymorphism/SlotComponent.js";import{isValidEpost as n}from"../../../utilities/validators/isValidEpost/isValidEpost.js";import{isValidTelefonnummer as i}from"../../../utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js";import{PrimaryButton as s,TertiaryButton as l}from"../../button/Button.js";import"../../text-input/BaseTextArea.js";import"../../text-input/BaseTextInput.js";import"../../text-input/TextArea.js";import{TextInput as m}from"../../text-input/TextInput.js";import{useFeedbackContext as p}from"../feedbackContext.js";import{FeedbackSuccess as u}from"../FeedbackSuccess.js";const d={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."},c=({label:c="Kan vi kontakte deg for flere innspill?",sendButtonLabel:f="Sett meg på lista!",withPhone:g=!1,onSubmit:k,successMessage:j=d,children:v})=>{const[h,b]=o(""),[x,E]=o(""),[S,T]=o({}),C=r(null),N=r(null),[y,B]=o(!1),[V,D]=o(!1),{contactSubmitted:P,setContactSubmitted:F}=p(),I="string"==typeof v?"p":"div",L=(e,t)=>{const o=(e=>e&&""!==e?n(e)?void 0:"Skriv inn en gyldig e-postadresse":"Du må oppgi e-postadresse for at vi kan kontakte deg")(e),r=(e=>e&&""!==e?i(e)?void 0:"Skriv inn et gyldig telefonnummer":"Du må oppgi telefonnummer for at vi kan kontakte deg")(t);return T({email:o,phone:r}),{emailError:o,phoneError:r}};a((()=>{if(y){const{emailError:e,phoneError:t}=L(h,x);!e&&(!g||!t)&&B(!1)}}),[h,x,y,g]);const A=e=>t=>e(t.target.value);return V?null:P?e(u,{...j}):t("form",{className:"jkl-spacing-xl--top",onSubmit:e=>{var t,o;e.preventDefault();const{emailError:r,phoneError:a}=L(h,x);return r?(B(!0),void(null==(t=C.current)||t.focus())):g&&a?(B(!0),void(null==(o=N.current)||o.focus())):(k({email:h,phone:g?x:void 0}),void F(!0))},children:[e("p",{className:"jkl-heading-4 jkl-spacing-xs--bottom",children:c}),v&&e(I,{className:"jkl-body",children:v}),e(m,{ref:C,className:"jkl-spacing-l--top",label:"E-post",labelProps:{variant:"small"},autoComplete:"email",name:"email",value:h,onChange:A(b),errorLabel:S.email}),g&&e(m,{ref:N,className:"jkl-spacing-l--top",label:"Telefonnummer",labelProps:{variant:"small"},autoComplete:"tel",name:"phone",value:x,onChange:A(E),errorLabel:S.phone}),t("div",{className:"jkl-spacing-xl--top",children:[e(s,{type:"submit",className:"jkl-spacing-xl--right",children:f}),e(l,{onClick:()=>D(!0),children:"Nei takk"})]})]})};export{c as ContactQuestion};
2
+ //# sourceMappingURL=ContactQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContactQuestion.js","sources":["../../../../../src/components/feedback/questions/ContactQuestion.tsx"],"sourcesContent":["import React, { ChangeEvent, FC, ReactNode, useEffect, useRef, useState } from \"react\";\nimport { isValidEpost, isValidTelefonnummer } from \"../../../utilities\";\nimport { PrimaryButton, TertiaryButton } from \"../../button\";\nimport { TextInput } from \"../../text-input\";\nimport { useFeedbackContext } from \"../feedbackContext\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess\";\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\ninterface Props {\n /**\n * Lar deg tilpasse spørsmålsteksten.\n * @default \"Kan vi kontakte deg for flere innspill?\"\n * */\n label?: string;\n /**\n * Lar deg tilpasse teksten på knappen for innsending.\n * @default \"Sett meg på lista!\"\n * */\n sendButtonLabel?: string;\n /** Sett til true om du også vil spørre om brukjerens telefonnummer i tillegg til epost */\n withPhone?: boolean;\n /** Her kan du legge inn eventuelt annet innhold du vil ha med. Kommer mellom overskriften og feltene for utfylling */\n children?: ReactNode;\n onSubmit: (values: { email: string; phone?: string }) => void;\n /** Lar deg tilpasse meldingen som kommer når brukeren sender inn skjemaet. */\n successMessage?: {\n title: string;\n children: ReactNode;\n };\n}\n\nexport const ContactQuestion: FC<Props> = ({\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 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 } = useFeedbackContext();\n\n const ChildrenWrapper = typeof children === \"string\" ? \"p\" : \"div\";\n\n const validate = (email: string, phone: string) => {\n const emailError = validateEmail(email);\n const phoneError = validatePhone(phone);\n setErrors({ email: emailError, phone: phoneError });\n return { emailError, phoneError };\n };\n\n useEffect(() => {\n if (shouldValidate) {\n const { emailError, phoneError } = validate(email, phone);\n\n if (!emailError && (!withPhone || !phoneError)) {\n setShouldValidate(false);\n }\n }\n }, [email, phone, shouldValidate, withPhone]);\n\n const handleChange = (consumer: (value: string) => void) => (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 className=\"jkl-spacing-xl--top\" onSubmit={handleSubmit}>\n <p className=\"jkl-heading-4 jkl-spacing-xs--bottom\">{label}</p>\n {children && <ChildrenWrapper className=\"jkl-body\">{children}</ChildrenWrapper>}\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)}>Nei takk</TertiaryButton>\n </div>\n </form>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","ContactQuestion","label","sendButtonLabel","withPhone","onSubmit","successMessage","email","setEmail","useState","phone","setPhone","errors","setErrors","emailRef","useRef","phoneRef","shouldValidate","setShouldValidate","noThanks","setNoThanks","contactSubmitted","setContactSubmitted","useFeedbackContext","ChildrenWrapper","validate","emailError","isValidEpost","validateEmail","phoneError","isValidTelefonnummer","validatePhone","useEffect","handleChange","consumer","e","target","value","jsx","FeedbackSuccess","jsxs","className","preventDefault","_a","current","focus","_b","TextInput","ref","labelProps","variant","autoComplete","name","onChange","errorLabel","PrimaryButton","type","TertiaryButton","onClick"],"mappings":"muBAOA,MAoBMA,EAAwB,CAC1BC,MAAO,sBACPC,SACI,sLA0BKC,EAA6B,EACtCC,MAAAA,EAAQ,0CACRC,gBAAAA,EAAkB,qBAClBC,UAAAA,GAAY,EACZC,SAAAA,EACAC,eAAAA,EAAiBR,EACjBE,SAAAA,MAEA,MAAOO,EAAOC,GAAYC,EAAS,KAC5BC,EAAOC,GAAYF,EAAS,KAC5BG,EAAQC,GAAaJ,EAA6C,CAAE,GACrEK,EAAWC,EAAyB,MACpCC,EAAWD,EAAyB,OACnCE,EAAgBC,GAAqBT,GAAS,IAE9CU,EAAUC,GAAeX,GAAS,IACjCY,iBAAAA,EAAkBC,oBAAAA,GAAwBC,IAE5CC,EAAsC,iBAAbxB,EAAwB,IAAM,MAEvDyB,EAAW,CAAClB,EAAeG,KACvB,MAAAgB,EAtEQ,CAACnB,GACdA,GAAmB,KAAVA,EAGToB,EAAapB,QAAd,EACO,oCAHA,uDAoEYqB,CAAcrB,GAC3BsB,EA7DQ,CAACnB,GACdA,GAAmB,KAAVA,EAGToB,EAAqBpB,QAAtB,EACO,oCAHA,uDA2DYqB,CAAcrB,GACjC,OAAAG,EAAU,CAAEN,MAAOmB,EAAYhB,MAAOmB,IAC/B,CAAEH,WAAAA,EAAYG,WAAAA,IAGzBG,GAAU,KACN,GAAIf,EAAgB,CACV,MAAES,WAAAA,EAAYG,WAAAA,GAAeJ,EAASlB,EAAOG,IAE9CgB,KAAgBtB,IAAcyB,IAC/BX,GAAkB,EAE1B,IACD,CAACX,EAAOG,EAAOO,EAAgBb,IAE5B,MAAA6B,EAAgBC,GAAuCC,GACzDD,EAASC,EAAEC,OAAOC,OAqBtB,OAAIlB,EACO,KAGPE,EACOiB,EAACC,EAAiB,IAAGjC,IAI3BkC,EAAA,OAAA,CAAKC,UAAU,sBAAsBpC,SA5BI8B,YAC1CA,EAAEO,iBAEI,MAAEhB,WAAAA,EAAYG,WAAAA,GAAeJ,EAASlB,EAAOG,GACnD,OAAIgB,GACAR,GAAkB,QAClB,OAAAyB,EAAA7B,EAAS8B,UAATD,EAAkBE,UAGlBzC,GAAayB,GACbX,GAAkB,QAClB,OAAA4B,EAAA9B,EAAS4B,UAATE,EAAkBD,WAItBxC,EAAS,CAAEE,MAAAA,EAAOG,MAAON,EAAYM,OAAQ,SAC7CY,GAAoB,GAAI,EAapBtB,SAAA,CAACsC,EAAA,IAAA,CAAEG,UAAU,uCAAwCzC,SAAME,IAC1DF,GAAYsC,EAACd,EAAgB,CAAAiB,UAAU,WAAYzC,SAAAA,IAEpDsC,EAACS,EAAA,CACGC,IAAKlC,EACL2B,UAAU,qBACVvC,MAAM,SACN+C,WAAY,CAAEC,QAAS,SACvBC,aAAa,QACbC,KAAK,QACLf,MAAO9B,EACP8C,SAAUpB,EAAazB,GACvB8C,WAAY1C,EAAOL,QAEtBH,GACGkC,EAACS,EAAA,CACGC,IAAKhC,EACLyB,UAAU,qBACVvC,MAAM,gBACN+C,WAAY,CAAEC,QAAS,SACvBC,aAAa,MACbC,KAAK,QACLf,MAAO3B,EACP2C,SAAUpB,EAAatB,GACvB2C,WAAY1C,EAAOF,QAI3B8B,EAAC,MAAI,CAAAC,UAAU,sBACXzC,SAAA,CAAAsC,EAACiB,EAAc,CAAAC,KAAK,SAASf,UAAU,wBAClCzC,SACLG,MACCsD,EAAe,CAAAC,QAAS,IAAMtC,GAAY,GAAOpB,SAAQ,kBAElE"}
@@ -0,0 +1,2 @@
1
+ import{jsx as o}from"react/jsx-runtime";import{useId as e,useRef as t,useEffect as n,useMemo as u}from"react";import{RadioButton as l}from"../../radio-button/RadioButton.js";import{RadioButtonGroup as r}from"../../radio-button/RadioButtonGroup.js";import"../../radio-button/BaseRadioButton.js";import{useFollowUpContext as a}from"../followup/followupContext.js";import{useMainQuestionContext as i}from"../main-question/mainQuestionContext.js";const s=({label:s,name:d,options:m,helpLabel:p,autoFocus:v=!1})=>{const c=a(),f=i(),b=c||f,g=e(),x=(null==m?void 0:m.length)||0,j=t(null);n((()=>{v&&j.current&&j.current.focus()}),[v,j]);const R=u((()=>{var o;return Array.isArray(null==b?void 0:b.currentValue)?null==b?void 0:b.currentValue[0].value.toString():null==(o=null==b?void 0:b.currentValue)?void 0:o.value.toString()}),[null==b?void 0:b.currentValue]);return b?o(r,{legend:s,labelProps:{variant:"large"},name:`${g}-${d||s}`,inline:x<3,value:R||"",onChange:o=>{const e=null==m?void 0:m.find((e=>e.value.toString()===o.target.value));null==b||b.setCurrentValue(e)},helpLabel:p,children:null==m?void 0:m.map(((e,t)=>o(l,{ref:0===t?j:void 0,label:e.label,value:String(e.value)},`${g}-${d||s}-${e.value}`)))}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};export{s as RadioQuestion};
2
+ //# sourceMappingURL=RadioQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioQuestion.js","sources":["../../../../../src/components/feedback/questions/RadioQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useId, useMemo, useRef } from \"react\";\nimport { RadioButton, RadioButtonGroup } from \"../../radio-button\";\nimport { useFollowUpContext } from \"../followup/followupContext\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext\";\nimport { QuestionProps } from \"../types\";\n\nexport const RadioQuestion: React.FC<QuestionProps> = ({ label, name, options, helpLabel, autoFocus = false }) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const numOptions = options?.length || 0;\n\n const ref = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n const option = options?.find((option) => option.value.toString() === e.target.value);\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(\"Questions must be used inside a Followup or Feedback context provider\");\n return null;\n }\n\n return (\n <RadioButtonGroup\n legend={label}\n labelProps={{ variant: \"large\" }}\n name={`${id}-${name || label}`}\n inline={numOptions < 3}\n value={selectedValue || \"\"}\n onChange={handleChange}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <RadioButton\n ref={i === 0 ? ref : undefined}\n key={`${id}-${name || label}-${option.value}`}\n label={option.label}\n value={String(option.value)}\n />\n ))}\n </RadioButtonGroup>\n );\n};\n"],"names":["RadioQuestion","label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","numOptions","length","ref","useRef","useEffect","current","focus","handleChange","selectedValue","useMemo","Array","isArray","currentValue","value","toString","_a","jsx","RadioButtonGroup","legend","labelProps","variant","inline","onChange","e","option","find","target","setCurrentValue","children","map","i","RadioButton","String","console","error"],"mappings":"2bAMa,MAAAA,EAAyC,EAAGC,MAAAA,EAAOC,KAAAA,EAAMC,QAAAA,EAASC,UAAAA,EAAWC,UAAAA,GAAY,MAC5FC,MAAAA,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,IAELC,GAAa,MAAAV,OAAAA,EAAAA,EAASW,SAAU,EAEhCC,EAAMC,EAAyB,MACrCC,GAAU,KACFZ,GAAaU,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACd,EAAWU,IAETK,MAKAC,EAAgBC,GAClB,WACU,OAAAC,MAAAC,QAAQ,MAAAd,OAAAA,EAAAA,EAASe,cACjB,MAAAf,SAAAA,EAASe,aAAa,GAAGC,MAAMC,WAC/B,OAAAC,EAAA,MAAAlB,OAAA,EAAAA,EAASe,mBAAT,EAAAG,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAjB,OAAAA,EAAAA,EAASe,eAGd,OAAKf,EAMDmB,EAACC,EAAA,CACGC,OAAQ9B,EACR+B,WAAY,CAAEC,QAAS,SACvB/B,KAAM,GAAGS,KAAMT,GAAQD,IACvBiC,OAAQrB,EAAa,EACrBa,MAAOL,GAAiB,GACxBc,SAzBoDC,IAClD,MAAAC,EAAS,MAAAlC,OAAAA,EAAAA,EAASmC,MAAMD,GAAWA,EAAOX,MAAMC,aAAeS,EAAEG,OAAOb,QAC9E,MAAAhB,GAAAA,EAAS8B,gBAAgBH,EAAAA,EAwBrBjC,UAAAA,EAECqC,SAAS,MAAAtC,OAAAA,EAAAA,EAAAuC,KAAI,CAACL,EAAQM,IACnBd,EAACe,EAAA,CACG7B,IAAW,IAAN4B,EAAU5B,OAAM,EAErBd,MAAOoC,EAAOpC,MACdyB,MAAOmB,OAAOR,EAAOX,QAFhB,GAAGf,KAAMT,GAAQD,KAASoC,EAAOX,cAjBlDoB,QAAQC,MAAM,yEACP,KAAA"}
@@ -0,0 +1,2 @@
1
+ import{jsx as o,jsxs as n}from"react/jsx-runtime";import{useId as i,useMemo as s,Fragment as e}from"react";import{FieldGroup as r}from"../../input-group/FieldGroup.js";import"../../input-group/InputGroup.js";import"../../icon/Icon.js";import"../../icon/icons/animated/ArrowVerticalAnimated.js";import"../../icon/icons/animated/ArrowHorizontalAnimated.js";import"../../icon/icons/animated/PlusRemoveAnimated.js";import"../../icon/icons/ArrowDownIcon.js";import"../../icon/icons/ArrowLeftIcon.js";import"../../icon/icons/ArrowNorthEastIcon.js";import"../../icon/icons/ArrowRightIcon.js";import"../../icon/icons/ArrowUpIcon.js";import"../../icon/icons/CalendarIcon.js";import"../../icon/icons/CheckIcon.js";import"../../icon/icons/ChevronDownIcon.js";import"../../icon/icons/ChevronLeftIcon.js";import"../../icon/icons/ChevronRightIcon.js";import"../../icon/icons/ChevronUpIcon.js";import"../../icon/icons/CloseIcon.js";import"../../icon/icons/CopyIcon.js";import"../../icon/icons/DotsIcon.js";import"../../icon/icons/DragIcon.js";import"../../icon/icons/ErrorIcon.js";import"../../icon/icons/GreenCheckIcon.js";import"../../icon/icons/HamburgerIcon.js";import"../../icon/icons/InfoIcon.js";import"../../icon/icons/LinkIcon.js";import"../../icon/icons/PlusIcon.js";import"../../icon/icons/QuestionIcon.js";import"../../icon/icons/RedCrossIcon.js";import"../../icon/icons/SearchIcon.js";import"../../icon/icons/SuccessIcon.js";import"../../icon/icons/WarningIcon.js";import"../../icon/icons/MinusIcon.js";import"../../icon/icons/ThumbDownIcon.js";import"../../icon/icons/ThumbUpIcon.js";import"../../icon/icons/TrashCanIcon.js";import"../../icon/icons/PenIcon.js";import{useFollowUpContext as c}from"../followup/followupContext.js";import{useMainQuestionContext as t}from"../main-question/mainQuestionContext.js";import{getSmiley as l,defaultOptions as a}from"./smileyUtils.js";const m=o=>"number"!=typeof o.value||![1,2,3,4,5].includes(o.value),u=({label:u,name:p="smiley",helpLabel:j,options:d=a})=>{const I=c(),v=t(),h=I||v,f=i(),C=o=>{console.log(o.target.value);const n=null==d?void 0:d.find((n=>n.value.toString()===o.target.value));null==h||h.setCurrentValue(n)},g=s((()=>{var o;return Array.isArray(null==h?void 0:h.currentValue)?null==h?void 0:h.currentValue[0].value:null==(o=null==h?void 0:h.currentValue)?void 0:o.value}),[null==h?void 0:h.currentValue]);return d.some(m)?(console.error("SmileyQuestion må ha tallene 1 til 5 som verdier for alternativene sine"),null):h&&d?o(r,{labelProps:{variant:"large"},legend:u,helpLabel:j,children:o("div",{className:"jkl-feedback-smileys",children:d.map((i=>n(e,{children:[o("input",{className:"jkl-sr-only",id:`${f}-${p}-${i.value}`,name:`${f}-${p}`,type:"radio",value:i.value,onChange:C,checked:g===i.value}),n("label",{className:"jkl-feedback-smiley-option",htmlFor:`${f}-${p}-${i.value}`,children:[o("span",{className:"jkl-sr-only",children:i.label}),l(Number(i.value))]})]},i.value)))})}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};export{u as SmileyQuestion};
2
+ //# sourceMappingURL=SmileyQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SmileyQuestion.js","sources":["../../../../../src/components/feedback/questions/SmileyQuestion.tsx"],"sourcesContent":["import React, { Fragment, ChangeEventHandler, useMemo, useId } from \"react\";\nimport { FieldGroup } from \"../../input-group\";\nimport { useFollowUpContext } from \"../followup/followupContext\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext\";\nimport { FeedbackOption, QuestionProps } from \"../types\";\nimport { defaultOptions, getSmiley } from \"./smileyUtils\";\n\nconst isNotInScale = (option: FeedbackOption) =>\n typeof option.value !== \"number\" || ![1, 2, 3, 4, 5].includes(option.value);\n\nexport const SmileyQuestion: React.FC<QuestionProps> = ({\n label,\n name = \"smiley\",\n helpLabel,\n options = defaultOptions,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n console.log(e.target.value);\n const option = options?.find((option) => option.value.toString() === e.target.value);\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () => (Array.isArray(context?.currentValue) ? context?.currentValue[0].value : context?.currentValue?.value),\n [context?.currentValue],\n );\n\n if (options.some(isNotInScale)) {\n console.error(\"SmileyQuestion må ha tallene 1 til 5 som verdier for alternativene sine\");\n return null;\n }\n\n if (!context || !options) {\n console.error(\"Questions must be used inside a Followup or Feedback context provider\");\n return null;\n }\n\n return (\n <FieldGroup labelProps={{ variant: \"large\" }} legend={label} helpLabel={helpLabel}>\n <div className=\"jkl-feedback-smileys\">\n {options.map((option) => (\n <Fragment key={option.value}>\n <input\n className=\"jkl-sr-only\"\n id={`${id}-${name}-${option.value}`}\n name={`${id}-${name}`}\n type=\"radio\"\n value={option.value}\n onChange={handleChange}\n checked={selectedValue === option.value}\n />\n <label className=\"jkl-feedback-smiley-option\" htmlFor={`${id}-${name}-${option.value}`}>\n <span className=\"jkl-sr-only\">{option.label}</span>\n {getSmiley(Number(option.value))}\n </label>\n </Fragment>\n ))}\n </div>\n </FieldGroup>\n );\n};\n"],"names":["isNotInScale","option","value","includes","SmileyQuestion","label","name","helpLabel","options","defaultOptions","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","handleChange","e","console","log","target","find","toString","setCurrentValue","selectedValue","useMemo","Array","isArray","currentValue","_a","some","error","FieldGroup","labelProps","variant","legend","children","jsx","className","map","Fragment","type","onChange","checked","jsxs","htmlFor","getSmiley","Number"],"mappings":"k1DAOA,MAAMA,EAAgBC,GACM,iBAAjBA,EAAOC,QAAuB,CAAC,EAAG,EAAG,EAAG,EAAG,GAAGC,SAASF,EAAOC,OAE5DE,EAA0C,EACnDC,MAAAA,EACAC,KAAAA,EAAO,SACPC,UAAAA,EACAC,QAAAA,EAAUC,MAEV,MAAMC,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,IAELC,EAAsDC,IAChDC,QAAAC,IAAIF,EAAEG,OAAOnB,OACf,MAAAD,EAAS,MAAAO,OAAAA,EAAAA,EAASc,MAAMrB,GAAWA,EAAOC,MAAMqB,aAAeL,EAAEG,OAAOnB,QAC9E,MAAAY,GAAAA,EAASU,gBAAgBvB,EAAAA,EAGvBwB,EAAgBC,GAClB,WAAO,OAAAC,MAAMC,QAAQ,MAAAd,OAAA,EAAAA,EAASe,cAAgB,MAAAf,OAAAA,EAAAA,EAASe,aAAa,GAAG3B,MAAQ,OAAA4B,EAAA,MAAAhB,SAAAA,EAASe,qBAATC,EAAuB5B,KAAA,GACtG,CAAC,MAAAY,OAAAA,EAAAA,EAASe,eAGVrB,OAAAA,EAAQuB,KAAK/B,IACbmB,QAAQa,MAAM,2EACP,MAGNlB,GAAYN,IAMZyB,EAAW,CAAAC,WAAY,CAAEC,QAAS,SAAWC,OAAQ/B,EAAOE,UAAAA,EACzD8B,SAACC,EAAA,MAAA,CAAIC,UAAU,uBACVF,SAAA7B,EAAQgC,KAAKvC,KACTwC,EACG,CAAAJ,SAAA,CAAAC,EAAC,QAAA,CACGC,UAAU,cACVxB,GAAI,GAAGA,KAAMT,KAAQL,EAAOC,QAC5BI,KAAM,GAAGS,KAAMT,IACfoC,KAAK,QACLxC,MAAOD,EAAOC,MACdyC,SAAU1B,EACV2B,QAASnB,IAAkBxB,EAAOC,QAErC2C,EAAA,QAAA,CAAMN,UAAU,6BAA6BO,QAAS,GAAG/B,KAAMT,KAAQL,EAAOC,QAC3EmC,SAAA,CAAAC,EAAC,OAAK,CAAAC,UAAU,cAAeF,SAAApC,EAAOI,QACrC0C,EAAUC,OAAO/C,EAAOC,aAZlBD,EAAOC,cARlCiB,QAAQa,MAAM,yEACP,KAwBP"}
@@ -0,0 +1,2 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{useRef as t,useEffect as r,useMemo as o}from"react";import"../../text-input/BaseTextArea.js";import"../../text-input/BaseTextInput.js";import{TextArea as n}from"../../text-input/TextArea.js";import"../../text-input/TextInput.js";import{useFeedbackContext as u}from"../feedbackContext.js";import{useFollowUpContext as a}from"../followup/followupContext.js";import{useMainQuestionContext as l}from"../main-question/mainQuestionContext.js";const s=({label:s,name:i,helpLabel:m="Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.",autoFocus:p=!1})=>{const{counter:c}=u(),x=a(),v=l(),b=x||v,d=t(null);r((()=>{p&&d.current&&d.current.focus()}),[p,d]);const f=o((()=>{var e;return Array.isArray(null==b?void 0:b.currentValue)?null==b?void 0:b.currentValue[0].value.toString():null==(e=null==b?void 0:b.currentValue)?void 0:e.value.toString()}),[null==b?void 0:b.currentValue]);return b?e(n,{ref:d,label:s,labelProps:{variant:"large"},name:i||s,startOpen:!0,rows:5,value:f,onChange:e=>{const t={label:s,name:i||s,type:"text",value:e.target.value};null==b||b.setCurrentValue(t)},helpLabel:m,counter:c}):(console.error("Questions must be used inside a Followup or Feedback context provider"),null)};export{s as TextQuestion};
2
+ //# sourceMappingURL=TextQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextQuestion.js","sources":["../../../../../src/components/feedback/questions/TextQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useMemo, useRef } from \"react\";\nimport { TextArea } from \"../../text-input\";\nimport { useFeedbackContext } from \"../feedbackContext\";\nimport { useFollowUpContext } from \"../followup/followupContext\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext\";\nimport { QuestionProps, FeedbackAnswer } from \"../types\";\n\nexport const TextQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n helpLabel = \"Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.\",\n autoFocus = false,\n}) => {\n const { counter } = useFeedbackContext();\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n const value: FeedbackAnswer = {\n label,\n name: name || label,\n type: \"text\",\n value: e.target.value,\n };\n context?.setCurrentValue(value);\n };\n\n const currentValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\"Questions must be used inside a Followup or Feedback context provider\");\n return null;\n }\n\n return (\n <TextArea\n ref={ref}\n label={label}\n labelProps={{ variant: \"large\" }}\n name={name || label}\n startOpen\n rows={5}\n value={currentValue}\n onChange={handleChange}\n helpLabel={helpLabel}\n counter={counter}\n />\n );\n};\n"],"names":["TextQuestion","label","name","helpLabel","autoFocus","counter","useFeedbackContext","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","handleChange","currentValue","useMemo","Array","isArray","value","toString","_a","jsx","TextArea","labelProps","variant","startOpen","rows","onChange","e","type","target","setCurrentValue","console","error"],"mappings":"oeAOO,MAAMA,EAAwC,EACjDC,MAAAA,EACAC,KAAAA,EACAC,UAAAA,EAAY,uJACZC,UAAAA,GAAY,MAEN,MAAEC,QAAAA,GAAYC,IACdC,EAAkBC,IAClBC,EAAkBC,IAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,EAA4B,MAExCC,GAAU,KACFV,GAAaQ,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACZ,EAAWQ,IAETK,MAUAC,EAAeC,GACjB,WACU,OAAAC,MAAAC,QAAQ,MAAAV,OAAAA,EAAAA,EAASO,cACjB,MAAAP,SAAAA,EAASO,aAAa,GAAGI,MAAMC,WAC/B,OAAAC,EAAA,MAAAb,OAAA,EAAAA,EAASO,mBAAT,EAAAM,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAZ,OAAAA,EAAAA,EAASO,eAGd,OAAKP,EAMDc,EAACC,EAAA,CACGd,IAAAA,EACAX,MAAAA,EACA0B,WAAY,CAAEC,QAAS,SACvB1B,KAAMA,GAAQD,EACd4B,WAAS,EACTC,KAAM,EACNR,MAAOJ,EACPa,SAhCuDC,IAC3D,MAAMV,EAAwB,CAC1BrB,MAAAA,EACAC,KAAMA,GAAQD,EACdgC,KAAM,OACNX,MAAOU,EAAEE,OAAOZ,OAEpB,MAAAX,GAAAA,EAASwB,gBAAgBb,EAAAA,EA0BrBnB,UAAAA,EACAE,QAAAA,KAfJ+B,QAAQC,MAAM,yEACP,KAAA"}
@@ -0,0 +1,2 @@
1
+ import{CheckboxQuestion as o}from"./CheckboxQuestion.js";import{RadioQuestion as s}from"./RadioQuestion.js";import{TextQuestion as t}from"./TextQuestion.js";import{SmileyQuestion as i}from"./SmileyQuestion.js";import{AddonQuestion as e}from"./AddonQuestion.js";import{ContactQuestion as n}from"./ContactQuestion.js";export{e as AddonQuestion,o as CheckboxQuestion,n as ContactQuestion,s as RadioQuestion,i as SmileyQuestion,t as TextQuestion};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";const t=[{label:"Veldig misfornøyd",value:1,textAreaLabel:"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre."},{label:"Litt misfornøyd",value:2,textAreaLabel:"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre."},{label:"Midt på treet",value:3,textAreaLabel:"Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre."},{label:"Ganske fornøyd",value:4,textAreaLabel:"Så bra! Har du noen tilbakemeldinger kan du skrive dem her."},{label:"Veldig fornøyd",value:5,textAreaLabel:"Så bra! Har du noen tilbakemeldinger kan du skrive dem her."}],l=({children:t})=>r("svg",{className:"jkl-feedback-smiley-option__icon","aria-hidden":!0,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("circle",{cx:"20",cy:"20",r:"19",stroke:"currentColor",strokeWidth:"2"}),t]}),o=()=>r(l,{children:[e("path",{d:"M10 30C10 24.4772 14.4772 20 20 20C25.5228 20 30 24.4772 30 30",stroke:"currentColor",strokeWidth:"2"}),e("path",{d:"M10 13.9865H16.6667",stroke:"currentColor",strokeWidth:"2"}),e("path",{d:"M23.3333 13.9865H29.9999",stroke:"currentColor",strokeWidth:"2"})]}),c=()=>r(l,{children:[e("path",{d:"M10 28.75C10 28.75 13.75 23.3334 20 23.3334C26.25 23.3334 30 28.75 30 28.75",stroke:"currentColor",strokeWidth:"2"}),e("circle",{cx:"12.5",cy:"14.5",r:"1.5",fill:"currentColor"}),e("circle",{cx:"27.5",cy:"14.5",r:"1.5",fill:"currentColor"})]}),a=()=>r(l,{children:[e("path",{d:"M9.15283 25.6986H30.8477",stroke:"currentColor",strokeWidth:"2"}),e("circle",{cx:"12.5",cy:"14.5",r:"1.5",fill:"currentColor"}),e("circle",{cx:"27.5",cy:"14.5",r:"1.5",fill:"currentColor"})]}),i=()=>r(l,{children:[e("path",{d:"M10 23.3334C10 23.3334 12.9167 30 20 30C27.0833 30 30 23.3334 30 23.3334",stroke:"currentColor",strokeWidth:"2"}),e("circle",{cx:"12.5",cy:"14.5",r:"1.5",fill:"currentColor"}),e("circle",{cx:"27.5",cy:"14.5",r:"1.5",fill:"currentColor"})]}),n=()=>r(l,{children:[e("path",{d:"M30 21C30 26.5228 25.5228 31 20 31C14.4772 31 10 26.5228 10 21",stroke:"currentColor",strokeWidth:"2"}),e("path",{d:"M24 14.5H29",stroke:"currentColor",strokeWidth:"2"}),e("circle",{cx:"12.5",cy:"14.5",r:"1.5",fill:"currentColor"})]}),s=r=>{switch(r){case 1:return e(o,{});case 2:return e(c,{});case 3:default:return e(a,{});case 4:return e(i,{});case 5:return e(n,{})}};export{t as defaultOptions,s as getSmiley};
2
+ //# sourceMappingURL=smileyUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smileyUtils.js","sources":["../../../../../src/components/feedback/questions/smileyUtils.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { WithChildren } from \"../../..\";\nimport { FeedbackOption } from \"../types\";\n\nexport const defaultOptions: FeedbackOption<number>[] = [\n {\n label: \"Veldig misfornøyd\",\n value: 1,\n textAreaLabel: \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Litt misfornøyd\",\n value: 2,\n textAreaLabel: \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Midt på treet\",\n value: 3,\n textAreaLabel: \"Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Ganske fornøyd\",\n value: 4,\n textAreaLabel: \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n {\n label: \"Veldig fornøyd\",\n value: 5,\n textAreaLabel: \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n];\n\nconst Smiley: FC<WithChildren> = ({ children }) => (\n <svg\n className=\"jkl-feedback-smiley-option__icon\"\n aria-hidden\n viewBox=\"0 0 40 40\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle cx=\"20\" cy=\"20\" r=\"19\" stroke=\"currentColor\" strokeWidth=\"2\" />\n {children}\n </svg>\n);\n\nconst VeldigSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 30C10 24.4772 14.4772 20 20 20C25.5228 20 30 24.4772 30 30\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M10 13.9865H16.6667\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <path d=\"M23.3333 13.9865H29.9999\" stroke=\"currentColor\" strokeWidth=\"2\" />\n </Smiley>\n);\n\nconst LittSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 28.75C10 28.75 13.75 23.3334 20 23.3334C26.25 23.3334 30 28.75 30 28.75\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst NoytralSmiley = () => (\n <Smiley>\n <path d=\"M9.15283 25.6986H30.8477\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst LittGladSmiley = () => (\n <Smiley>\n <path\n d=\"M10 23.3334C10 23.3334 12.9167 30 20 30C27.0833 30 30 23.3334 30 23.3334\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst VeldigGladSmiley = () => (\n <Smiley>\n <path\n d=\"M30 21C30 26.5228 25.5228 31 20 31C14.4772 31 10 26.5228 10 21\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M24 14.5H29\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nexport const getSmiley = (value: number) => {\n switch (value) {\n case 1:\n return <VeldigSurSmiley />;\n case 2:\n return <LittSurSmiley />;\n case 3:\n return <NoytralSmiley />;\n case 4:\n return <LittGladSmiley />;\n case 5:\n return <VeldigGladSmiley />;\n\n default:\n return <NoytralSmiley />;\n }\n};\n"],"names":["defaultOptions","label","value","textAreaLabel","Smiley","children","jsxs","className","viewBox","fill","xmlns","jsx","cx","cy","r","stroke","strokeWidth","VeldigSurSmiley","d","LittSurSmiley","NoytralSmiley","LittGladSmiley","VeldigGladSmiley","getSmiley"],"mappings":"kDAIO,MAAMA,EAA2C,CACpD,CACIC,MAAO,oBACPC,MAAO,EACPC,cAAe,sFAEnB,CACIF,MAAO,kBACPC,MAAO,EACPC,cAAe,sFAEnB,CACIF,MAAO,gBACPC,MAAO,EACPC,cAAe,wEAEnB,CACIF,MAAO,iBACPC,MAAO,EACPC,cAAe,+DAEnB,CACIF,MAAO,iBACPC,MAAO,EACPC,cAAe,gEAIjBC,EAA2B,EAAGC,SAAAA,KAChCC,EAAC,MAAA,CACGC,UAAU,mCACV,eAAW,EACXC,QAAQ,YACRC,KAAK,OACLC,MAAM,6BAENL,SAAA,CAACM,EAAA,SAAA,CAAOC,GAAG,KAAKC,GAAG,KAAKC,EAAE,KAAKC,OAAO,eAAeC,YAAY,MAChEX,KAIHY,EAAkB,IACpBX,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,QAEf,OAAK,CAAAE,EAAE,sBAAsBH,OAAO,eAAeC,YAAY,QAC/D,OAAK,CAAAE,EAAE,2BAA2BH,OAAO,eAAeC,YAAY,SAIvEG,EAAgB,IAClBb,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,8EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CW,EAAgB,IAClBd,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,QAAKO,EAAE,2BAA2BH,OAAO,eAAeC,YAAY,MACrEL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CY,EAAiB,IACnBf,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,2EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3Ca,EAAmB,IACrBhB,EAACF,EACG,CAAAC,SAAA,CAAAM,EAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,QAEf,OAAK,CAAAE,EAAE,cAAcH,OAAO,eAAeC,YAAY,MACxDL,EAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAIpCc,EAAarB,IACtB,OAAQA,GACJ,KAAK,EACD,SAAQe,EAAgB,CAAA,GAC5B,KAAK,EACD,SAAQE,EAAc,CAAA,GAC1B,KAAK,EAOL,QACI,SAAQC,EAAc,CAAA,GAN1B,KAAK,EACD,SAAQC,EAAe,CAAA,GAC3B,KAAK,EACD,SAAQC,EAAiB,CAAA,GAIjC"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import t from"react";import{CheckboxQuestion as e}from"./questions/CheckboxQuestion.js";import{RadioQuestion as s}from"./questions/RadioQuestion.js";import{TextQuestion as o}from"./questions/TextQuestion.js";import{SmileyQuestion as i}from"./questions/SmileyQuestion.js";import"react/jsx-runtime";import"../text-input/BaseTextArea.js";import"../text-input/BaseTextInput.js";import"../text-input/TextArea.js";import"../text-input/TextInput.js";import"./feedbackContext.js";import"./main-question/mainQuestionContext.js";import"../../utilities/polymorphism/SlotComponent.js";import"../button/Button.js";import"../message/Message.js";import"../message/FormErrorMessage.js";function r(...e){return s=>t.Children.map(s,(s=>{if(t.isValidElement(s)&&e.includes(s.type))return s}))}const n=t=>{switch(t){case"radio":default:return s;case"checkbox":return e;case"text":return o;case"smiley":return i}};export{r as getChildrenOfType,n as getQuestionFromType};
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/components/feedback/utils.ts"],"sourcesContent":["import React, { JSXElementConstructor, FC } from \"react\";\nimport { CheckboxQuestion, RadioQuestion, TextQuestion, SmileyQuestion } from \"./questions\";\nimport { QuestionProps, QuestionType } from \"./types\";\n\nexport function getChildrenOfType<P>(...allowedTypes: Array<string | JSXElementConstructor<P>>) {\n return (\n children: React.ReactNode,\n ): React.ReactElement<P, string | React.JSXElementConstructor<unknown>>[] | null | undefined =>\n React.Children.map(children, (child) => {\n if (React.isValidElement<P>(child) && allowedTypes.includes(child.type)) {\n return child;\n }\n return undefined;\n });\n}\n\nexport const getQuestionFromType = (type: QuestionType): FC<QuestionProps> => {\n switch (type) {\n case \"radio\":\n return RadioQuestion;\n case \"checkbox\":\n return CheckboxQuestion;\n case \"text\":\n return TextQuestion;\n case \"smiley\":\n return SmileyQuestion;\n\n default:\n return RadioQuestion;\n }\n};\n"],"names":["getChildrenOfType","allowedTypes","children","React","Children","map","child","isValidElement","includes","type","getQuestionFromType","RadioQuestion","CheckboxQuestion","TextQuestion","SmileyQuestion"],"mappings":"8pBAIO,SAASA,KAAwBC,GACpC,OACIC,GAEAC,EAAMC,SAASC,IAAIH,GAAWI,IACtB,GAAAH,EAAMI,eAAkBD,IAAUL,EAAaO,SAASF,EAAMG,MACvDH,OAAAA,CAAAA,GAIvB,CAEa,MAAAI,EAAuBD,IAChC,OAAQA,GACJ,IAAK,QASL,QACWE,OAAAA,EARX,IAAK,WACMC,OAAAA,EACX,IAAK,OACMC,OAAAA,EACX,IAAK,SACMC,OAAAA,EAIf"}
@@ -1,2 +1,2 @@
1
- import{AccordionItem as o}from"./accordion/AccordionItem.js";import{Accordion as s}from"./accordion/Accordion.js";import{Breadcrumb as a}from"./breadcrumb/Breadcrumb.js";import{BreadcrumbItem as r}from"./breadcrumb/BreadcrumbItem.js";import{Button as n,PrimaryButton as t,SecondaryButton as e,TertiaryButton as i}from"./button/Button.js";import{Card as c}from"./card/Card.js";import{CardImage as m}from"./card/CardImage.js";import{InfoBlock as p,NavCard as l}from"./card/NavCard.js";import{TaskCard as I}from"./card/TaskCard.js";import{InfoCard as d}from"./card/InfoCard.js";import{Checkbox as u}from"./checkbox/Checkbox.js";import{Combobox as f,getComboboxValuePair as C}from"./combobox/Combobox.js";import{CookieConsent as j}from"./cookie-consent/CookieConsent.js";import{CookieConsentProvider as k,useCookieConsent as T}from"./cookie-consent/CookieConsentContext.js";import{isCorrectFormat as b,isWithinLowerBound as g,isWithinUpperBound as h}from"./datepicker/validation.js";import{dayMonthYearRegex as B,formatInput as A,isBlurTargetOutside as S,parseDateString as L}from"./datepicker/utils.js";import{DatePicker as x}from"./datepicker/DatePicker.js";import{Icon as w}from"./icon/Icon.js";import{ArrowVerticalAnimated as R}from"./icon/icons/animated/ArrowVerticalAnimated.js";import{ArrowHorizontalAnimated as v}from"./icon/icons/animated/ArrowHorizontalAnimated.js";import{PlusRemoveAnimated as M}from"./icon/icons/animated/PlusRemoveAnimated.js";import{ArrowDownIcon as P}from"./icon/icons/ArrowDownIcon.js";import{ArrowLeftIcon as D}from"./icon/icons/ArrowLeftIcon.js";import{ArrowNorthEastIcon as y}from"./icon/icons/ArrowNorthEastIcon.js";import{ArrowRightIcon as G}from"./icon/icons/ArrowRightIcon.js";import{ArrowUpIcon as U}from"./icon/icons/ArrowUpIcon.js";import{CalendarIcon as N}from"./icon/icons/CalendarIcon.js";import{CheckIcon as E}from"./icon/icons/CheckIcon.js";import{ChevronDownIcon as H}from"./icon/icons/ChevronDownIcon.js";import{ChevronLeftIcon as O}from"./icon/icons/ChevronLeftIcon.js";import{ChevronRightIcon as W}from"./icon/icons/ChevronRightIcon.js";import{ChevronUpIcon as F}from"./icon/icons/ChevronUpIcon.js";import{CloseIcon as V}from"./icon/icons/CloseIcon.js";import{CopyIcon as z}from"./icon/icons/CopyIcon.js";import{DotsIcon as Q}from"./icon/icons/DotsIcon.js";import{DragIcon as Y}from"./icon/icons/DragIcon.js";import{ErrorIcon as q}from"./icon/icons/ErrorIcon.js";import{GreenCheckIcon as J}from"./icon/icons/GreenCheckIcon.js";import{HamburgerIcon as K}from"./icon/icons/HamburgerIcon.js";import{InfoIcon as X}from"./icon/icons/InfoIcon.js";import{LinkIcon as Z}from"./icon/icons/LinkIcon.js";import{PlusIcon as $}from"./icon/icons/PlusIcon.js";import{QuestionIcon as _}from"./icon/icons/QuestionIcon.js";import{RedCrossIcon as oo}from"./icon/icons/RedCrossIcon.js";import{SearchIcon as so}from"./icon/icons/SearchIcon.js";import{SuccessIcon as ao}from"./icon/icons/SuccessIcon.js";import{WarningIcon as ro}from"./icon/icons/WarningIcon.js";import{MinusIcon as no}from"./icon/icons/MinusIcon.js";import{ThumbDownIcon as to}from"./icon/icons/ThumbDownIcon.js";import{ThumbUpIcon as eo}from"./icon/icons/ThumbUpIcon.js";import{TrashCanIcon as io}from"./icon/icons/TrashCanIcon.js";import{PenIcon as co}from"./icon/icons/PenIcon.js";import{IconButton as mo}from"./icon-button/IconButton.js";import{Image as po}from"./image/Image.js";import{FieldGroup as lo}from"./input-group/FieldGroup.js";import{InputGroup as Io}from"./input-group/InputGroup.js";import{Label as uo}from"./input-group/Label.js";import{SupportLabel as fo}from"./input-group/SupportLabel.js";import{Link as Co}from"./link/Link.js";import{NavLink as jo}from"./link/NavLink.js";import{LinkList as ko}from"./link-list/LinkList.js";import{List as To,OrderedList as bo,UnorderedList as go}from"./list/List.js";import{CheckListItem as ho,CrossListItem as Bo,ListItem as Ao}from"./list/ListItem.js";import{Loader as So}from"./loader/Loader.js";import{SkeletonAnimation as Lo}from"./loader/skeletons/SkeletonAnimation.js";import{SkeletonButton as xo}from"./loader/skeletons/SkeletonButton.js";import{SkeletonCheckboxGroup as wo}from"./loader/skeletons/SkeletonCheckboxGroup.js";import{SkeletonElement as Ro}from"./loader/skeletons/SkeletonElement.js";import{SkeletonInput as vo}from"./loader/skeletons/SkeletonInput.js";import{SkeletonRadioButtonGroup as Mo}from"./loader/skeletons/SkeletonRadioButtonGroup.js";import{SkeletonTable as Po,SkeletonTableHeader as Do,SkeletonTableRow as yo}from"./loader/skeletons/SkeletonTable.js";import{SkeletonTextArea as Go}from"./loader/skeletons/SkeletonTextArea.js";import{Modal as Uo,ModalActions as No,ModalBody as Eo,ModalCloseButton as Ho,ModalContainer as Oo,ModalHeader as Wo,ModalOverlay as Fo,ModalTitle as Vo}from"./modal/Modal.js";import{useModal as zo}from"./modal/useModal.js";import{RadioButton as Qo}from"./radio-button/RadioButton.js";import{RadioButtonGroup as Yo}from"./radio-button/RadioButtonGroup.js";import{BaseRadioButton as qo}from"./radio-button/BaseRadioButton.js";import{N as Jo,S as Ko}from"../../NativeSelect-EidDABsT.js";import{ErrorTag as Xo,InfoTag as Zo,SuccessTag as $o,Tag as _o,WarningTag as os}from"./tag/Tag.js";import{BaseTextArea as ss}from"./text-input/BaseTextArea.js";import{BaseTextInput as as}from"./text-input/BaseTextInput.js";import{TextArea as rs}from"./text-input/TextArea.js";import{TextInput as ns}from"./text-input/TextInput.js";import{Tooltip as ts}from"./tooltip/Tooltip.js";import{TooltipContent as es}from"./tooltip/TooltipContent.js";import{TooltipTrigger as is}from"./tooltip/TooltipTrigger.js";import{PopupTip as cs}from"./tooltip/PopupTip.js";import{ScreenReaderOnly as ms}from"./ScreenReaderOnly.js";export{s as Accordion,o as AccordionItem,P as ArrowDownIcon,v as ArrowHorizontalAnimated,D as ArrowLeftIcon,y as ArrowNorthEastIcon,G as ArrowRightIcon,U as ArrowUpIcon,R as ArrowVerticalAnimated,qo as BaseRadioButton,ss as BaseTextArea,as as BaseTextInput,a as Breadcrumb,r as BreadcrumbItem,n as Button,N as CalendarIcon,c as Card,m as CardImage,E as CheckIcon,ho as CheckListItem,u as Checkbox,H as ChevronDownIcon,O as ChevronLeftIcon,W as ChevronRightIcon,F as ChevronUpIcon,V as CloseIcon,f as Combobox,j as CookieConsent,k as CookieConsentProvider,z as CopyIcon,Bo as CrossListItem,x as DatePicker,Q as DotsIcon,Y as DragIcon,q as ErrorIcon,Xo as ErrorTag,lo as FieldGroup,J as GreenCheckIcon,K as HamburgerIcon,w as Icon,mo as IconButton,po as Image,p as InfoBlock,d as InfoCard,X as InfoIcon,Zo as InfoTag,Io as InputGroup,uo as Label,Co as Link,Z as LinkIcon,ko as LinkList,To as List,Ao as ListItem,So as Loader,no as MinusIcon,Uo as Modal,No as ModalActions,Eo as ModalBody,Ho as ModalCloseButton,Oo as ModalContainer,Wo as ModalHeader,Fo as ModalOverlay,Vo as ModalTitle,Jo as NativeSelect,l as NavCard,jo as NavLink,bo as OrderedList,co as PenIcon,$ as PlusIcon,M as PlusRemoveAnimated,cs as PopupTip,t as PrimaryButton,_ as QuestionIcon,Qo as RadioButton,Yo as RadioButtonGroup,oo as RedCrossIcon,ms as ScreenReaderOnly,so as SearchIcon,e as SecondaryButton,Ko as Select,Lo as SkeletonAnimation,xo as SkeletonButton,wo as SkeletonCheckboxGroup,Ro as SkeletonElement,vo as SkeletonInput,Mo as SkeletonRadioButtonGroup,Po as SkeletonTable,Do as SkeletonTableHeader,yo as SkeletonTableRow,Go as SkeletonTextArea,ao as SuccessIcon,$o as SuccessTag,fo as SupportLabel,_o as Tag,I as TaskCard,i as TertiaryButton,rs as TextArea,ns as TextInput,to as ThumbDownIcon,eo as ThumbUpIcon,ts as Tooltip,es as TooltipContent,is as TooltipTrigger,io as TrashCanIcon,go as UnorderedList,ro as WarningIcon,os as WarningTag,B as dayMonthYearRegex,A as formatInput,C as getComboboxValuePair,S as isBlurTargetOutside,b as isCorrectFormat,g as isWithinLowerBound,h as isWithinUpperBound,L as parseDateString,T as useCookieConsent,zo as useModal};
1
+ import{AccordionItem as o}from"./accordion/AccordionItem.js";import{Accordion as s}from"./accordion/Accordion.js";import{Breadcrumb as a}from"./breadcrumb/Breadcrumb.js";import{BreadcrumbItem as r}from"./breadcrumb/BreadcrumbItem.js";import{Button as n,PrimaryButton as e,SecondaryButton as t,TertiaryButton as i}from"./button/Button.js";import{Card as c}from"./card/Card.js";import{CardImage as m}from"./card/CardImage.js";import{InfoBlock as p,NavCard as d}from"./card/NavCard.js";import{TaskCard as l}from"./card/TaskCard.js";import{InfoCard as I}from"./card/InfoCard.js";import{Checkbox as u}from"./checkbox/Checkbox.js";import{Combobox as f,getComboboxValuePair as j}from"./combobox/Combobox.js";import{CookieConsent as k}from"./cookie-consent/CookieConsent.js";import{CookieConsentProvider as C,useCookieConsent as g}from"./cookie-consent/CookieConsentContext.js";import{isCorrectFormat as T,isWithinLowerBound as b,isWithinUpperBound as S}from"./datepicker/validation.js";import{dayMonthYearRegex as h,formatInput as B,isBlurTargetOutside as A,parseDateString as L}from"./datepicker/utils.js";import{DatePicker as M}from"./datepicker/DatePicker.js";import{Feedback as x}from"./feedback/Feedback.js";import{PRESETS as w}from"./feedback/presets.js";import{Icon as R}from"./icon/Icon.js";import{ArrowVerticalAnimated as v}from"./icon/icons/animated/ArrowVerticalAnimated.js";import{ArrowHorizontalAnimated as P}from"./icon/icons/animated/ArrowHorizontalAnimated.js";import{PlusRemoveAnimated as D}from"./icon/icons/animated/PlusRemoveAnimated.js";import{ArrowDownIcon as E}from"./icon/icons/ArrowDownIcon.js";import{ArrowLeftIcon as y}from"./icon/icons/ArrowLeftIcon.js";import{ArrowNorthEastIcon as G}from"./icon/icons/ArrowNorthEastIcon.js";import{ArrowRightIcon as U}from"./icon/icons/ArrowRightIcon.js";import{ArrowUpIcon as N}from"./icon/icons/ArrowUpIcon.js";import{CalendarIcon as F}from"./icon/icons/CalendarIcon.js";import{CheckIcon as W}from"./icon/icons/CheckIcon.js";import{ChevronDownIcon as H}from"./icon/icons/ChevronDownIcon.js";import{ChevronLeftIcon as O}from"./icon/icons/ChevronLeftIcon.js";import{ChevronRightIcon as V}from"./icon/icons/ChevronRightIcon.js";import{ChevronUpIcon as z}from"./icon/icons/ChevronUpIcon.js";import{CloseIcon as Q}from"./icon/icons/CloseIcon.js";import{CopyIcon as Y}from"./icon/icons/CopyIcon.js";import{DotsIcon as q}from"./icon/icons/DotsIcon.js";import{DragIcon as J}from"./icon/icons/DragIcon.js";import{ErrorIcon as K}from"./icon/icons/ErrorIcon.js";import{GreenCheckIcon as X}from"./icon/icons/GreenCheckIcon.js";import{HamburgerIcon as Z}from"./icon/icons/HamburgerIcon.js";import{InfoIcon as $}from"./icon/icons/InfoIcon.js";import{LinkIcon as _}from"./icon/icons/LinkIcon.js";import{PlusIcon as oo}from"./icon/icons/PlusIcon.js";import{QuestionIcon as so}from"./icon/icons/QuestionIcon.js";import{RedCrossIcon as ao}from"./icon/icons/RedCrossIcon.js";import{SearchIcon as ro}from"./icon/icons/SearchIcon.js";import{SuccessIcon as no}from"./icon/icons/SuccessIcon.js";import{WarningIcon as eo}from"./icon/icons/WarningIcon.js";import{MinusIcon as to}from"./icon/icons/MinusIcon.js";import{ThumbDownIcon as io}from"./icon/icons/ThumbDownIcon.js";import{ThumbUpIcon as co}from"./icon/icons/ThumbUpIcon.js";import{TrashCanIcon as mo}from"./icon/icons/TrashCanIcon.js";import{PenIcon as po}from"./icon/icons/PenIcon.js";import{IconButton as lo}from"./icon-button/IconButton.js";import{Image as Io}from"./image/Image.js";import{FieldGroup as uo}from"./input-group/FieldGroup.js";import{InputGroup as fo}from"./input-group/InputGroup.js";import{Label as jo}from"./input-group/Label.js";import{SupportLabel as ko}from"./input-group/SupportLabel.js";import{Link as Co}from"./link/Link.js";import{NavLink as go}from"./link/NavLink.js";import{LinkList as To}from"./link-list/LinkList.js";import{List as bo,OrderedList as So,UnorderedList as ho}from"./list/List.js";import{CheckListItem as Bo,CrossListItem as Ao,ListItem as Lo}from"./list/ListItem.js";import{Loader as Mo}from"./loader/Loader.js";import{SkeletonAnimation as xo}from"./loader/skeletons/SkeletonAnimation.js";import{SkeletonButton as wo}from"./loader/skeletons/SkeletonButton.js";import{SkeletonCheckboxGroup as Ro}from"./loader/skeletons/SkeletonCheckboxGroup.js";import{SkeletonElement as vo}from"./loader/skeletons/SkeletonElement.js";import{SkeletonInput as Po}from"./loader/skeletons/SkeletonInput.js";import{SkeletonRadioButtonGroup as Do}from"./loader/skeletons/SkeletonRadioButtonGroup.js";import{SkeletonTable as Eo,SkeletonTableHeader as yo,SkeletonTableRow as Go}from"./loader/skeletons/SkeletonTable.js";import{SkeletonTextArea as Uo}from"./loader/skeletons/SkeletonTextArea.js";import{ErrorMessage as No,InfoMessage as Fo,SuccessMessage as Wo,WarningMessage as Ho}from"./message/Message.js";import{FormErrorMessage as Oo}from"./message/FormErrorMessage.js";import{Modal as Vo,ModalActions as zo,ModalBody as Qo,ModalCloseButton as Yo,ModalContainer as qo,ModalHeader as Jo,ModalOverlay as Ko,ModalTitle as Xo}from"./modal/Modal.js";import{useModal as Zo}from"./modal/useModal.js";import{default as $o}from"./popover/Popover.js";import{RadioButton as _o}from"./radio-button/RadioButton.js";import{RadioButtonGroup as os}from"./radio-button/RadioButtonGroup.js";import{BaseRadioButton as ss}from"./radio-button/BaseRadioButton.js";import{N as as,S as rs}from"../../NativeSelect-CfNZEQF0.js";import{ErrorTag as ns,InfoTag as es,SuccessTag as ts,Tag as is,WarningTag as cs}from"./tag/Tag.js";import{BaseTextArea as ms}from"./text-input/BaseTextArea.js";import{BaseTextInput as ps}from"./text-input/BaseTextInput.js";import{TextArea as ds}from"./text-input/TextArea.js";import{TextInput as ls}from"./text-input/TextInput.js";import{Tooltip as Is}from"./tooltip/Tooltip.js";import{TooltipContent as us}from"./tooltip/TooltipContent.js";import{TooltipTrigger as fs}from"./tooltip/TooltipTrigger.js";import{PopupTip as js}from"./tooltip/PopupTip.js";import{ScreenReaderOnly as ks}from"./ScreenReaderOnly.js";export{s as Accordion,o as AccordionItem,E as ArrowDownIcon,P as ArrowHorizontalAnimated,y as ArrowLeftIcon,G as ArrowNorthEastIcon,U as ArrowRightIcon,N as ArrowUpIcon,v as ArrowVerticalAnimated,ss as BaseRadioButton,ms as BaseTextArea,ps as BaseTextInput,a as Breadcrumb,r as BreadcrumbItem,n as Button,F as CalendarIcon,c as Card,m as CardImage,W as CheckIcon,Bo as CheckListItem,u as Checkbox,H as ChevronDownIcon,O as ChevronLeftIcon,V as ChevronRightIcon,z as ChevronUpIcon,Q as CloseIcon,f as Combobox,k as CookieConsent,C as CookieConsentProvider,Y as CopyIcon,Ao as CrossListItem,M as DatePicker,q as DotsIcon,J as DragIcon,K as ErrorIcon,No as ErrorMessage,ns as ErrorTag,x as Feedback,uo as FieldGroup,Oo as FormErrorMessage,X as GreenCheckIcon,Z as HamburgerIcon,R as Icon,lo as IconButton,Io as Image,p as InfoBlock,I as InfoCard,$ as InfoIcon,Fo as InfoMessage,es as InfoTag,fo as InputGroup,jo as Label,Co as Link,_ as LinkIcon,To as LinkList,bo as List,Lo as ListItem,Mo as Loader,to as MinusIcon,Vo as Modal,zo as ModalActions,Qo as ModalBody,Yo as ModalCloseButton,qo as ModalContainer,Jo as ModalHeader,Ko as ModalOverlay,Xo as ModalTitle,as as NativeSelect,d as NavCard,go as NavLink,So as OrderedList,w as PRESETS,po as PenIcon,oo as PlusIcon,D as PlusRemoveAnimated,$o as Popover,js as PopupTip,e as PrimaryButton,so as QuestionIcon,_o as RadioButton,os as RadioButtonGroup,ao as RedCrossIcon,ks as ScreenReaderOnly,ro as SearchIcon,t as SecondaryButton,rs as Select,xo as SkeletonAnimation,wo as SkeletonButton,Ro as SkeletonCheckboxGroup,vo as SkeletonElement,Po as SkeletonInput,Do as SkeletonRadioButtonGroup,Eo as SkeletonTable,yo as SkeletonTableHeader,Go as SkeletonTableRow,Uo as SkeletonTextArea,no as SuccessIcon,Wo as SuccessMessage,ts as SuccessTag,ko as SupportLabel,is as Tag,l as TaskCard,i as TertiaryButton,ds as TextArea,ls as TextInput,io as ThumbDownIcon,co as ThumbUpIcon,Is as Tooltip,us as TooltipContent,fs as TooltipTrigger,mo as TrashCanIcon,ho as UnorderedList,eo as WarningIcon,Ho as WarningMessage,cs as WarningTag,h as dayMonthYearRegex,B as formatInput,j as getComboboxValuePair,A as isBlurTargetOutside,T as isCorrectFormat,b as isWithinLowerBound,S as isWithinUpperBound,L as parseDateString,g as useCookieConsent,Zo as useModal};
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import{jsxs as o,jsx as n}from"react/jsx-runtime";import{forwardRef as i}from"react";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import{CloseIcon as c}from"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";const s=i((({label:i="Lukk",...s},r)=>o("button",{ref:r,type:"button",title:i,...s,children:[n(c,{variant:"small",bold:!0}),n("span",{className:"jkl-sr-only",children:i})]})));s.displayName="DismissButton";export{s as DismissButton};
2
+ //# sourceMappingURL=DismissButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DismissButton.js","sources":["../../../../src/components/message/DismissButton.tsx"],"sourcesContent":["import React, { ButtonHTMLAttributes, forwardRef } from \"react\";\nimport { CloseIcon } from \"../icon\";\n\nexport interface DismissButtonProps extends Exclude<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n label?: string;\n}\n\nexport const DismissButton = forwardRef<HTMLButtonElement, DismissButtonProps>(({ label = \"Lukk\", ...rest }, ref) => {\n return (\n <button ref={ref} type=\"button\" title={label} {...rest}>\n <CloseIcon variant=\"small\" bold />\n <span className=\"jkl-sr-only\">{label}</span>\n </button>\n );\n});\n\nDismissButton.displayName = \"DismissButton\";\n"],"names":["DismissButton","forwardRef","label","rest","ref","jsxs","type","title","children","jsx","CloseIcon","variant","bold","className","displayName"],"mappings":"46CAOa,MAAAA,EAAgBC,GAAkD,EAAGC,MAAAA,EAAQ,UAAWC,GAAQC,IAErGC,EAAC,UAAOD,IAAAA,EAAUE,KAAK,SAASC,MAAOL,KAAWC,EAC9CK,SAAA,CAAAC,EAACC,EAAU,CAAAC,QAAQ,QAAQC,MAAI,IAC9BH,EAAA,OAAA,CAAKI,UAAU,cAAeL,SAAMN,SAKjDF,EAAcc,YAAc"}
@@ -0,0 +1,2 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{c as s}from"../../../clsx-BeLtu-UY.js";import{forwardRef as r,useRef as t,useEffect as a}from"react";import{useAnimatedHeight as o}from"../../hooks/useAnimatedHeight/useAnimatedHeight.js";import"../../hooks/useScreen/useScreen.js";import"../../hooks/useId/useId.js";import{ErrorMessage as i}from"./Message.js";const m={title:"Feil og mangler i skjemaet"},l=r(((r,l)=>{const{className:n,errors:c,isSubmitted:d,isValid:u,messageProps:f,...g}=r,p=d&&!u,[h]=o(p,{display:"grid"}),j=t(c);a((()=>{j.current=c}),[c]);const k=c.length>j.current.length;return e("div",{ref:l,className:s("jkl-form-error-message",n),...g,children:e(i,{...m,...f,ref:h,role:k?"alert":"presentation",children:e("ul",{className:"jkl-list",children:c.filter((e=>typeof e<"u")).map((s=>e("li",{className:"jkl-list__item",children:s},s)))})})})}));l.displayName="FormErrorMessage";export{l as FormErrorMessage};
2
+ //# sourceMappingURL=FormErrorMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormErrorMessage.js","sources":["../../../../src/components/message/FormErrorMessage.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useEffect, useRef } from \"react\";\nimport { useAnimatedHeight } from \"../../hooks\";\nimport { MessageProps, ErrorMessage } from \"./Message\";\n\nexport interface FormErrorMessageProps {\n className?: string;\n id?: string;\n /**\n * @default { title: \"Feil og mangler i skjemaet\" }\n */\n messageProps?: Partial<MessageProps>;\n errors: (string | undefined)[];\n isSubmitted: boolean;\n isValid: boolean;\n}\n\nconst defaultMessageProps = {\n title: \"Feil og mangler i skjemaet\",\n};\n\nexport const FormErrorMessage = forwardRef<HTMLDivElement, FormErrorMessageProps>(\n (props, forwardedRef): JSX.Element | null => {\n const { className, errors, isSubmitted, isValid, messageProps, ...rest } = props;\n\n const showSummary = isSubmitted && !isValid;\n\n const [messageRef] = useAnimatedHeight<HTMLDivElement>(showSummary, { display: \"grid\" });\n\n const previousErrors = useRef<Array<string | undefined>>(errors);\n useEffect(() => {\n previousErrors.current = errors;\n }, [errors]);\n const hasNewErrors = errors.length > previousErrors.current.length;\n\n return (\n <div ref={forwardedRef} className={clsx(\"jkl-form-error-message\", className)} {...rest}>\n <ErrorMessage\n {...defaultMessageProps}\n {...messageProps}\n ref={messageRef}\n role={hasNewErrors ? \"alert\" : \"presentation\"} // Unngå å repetere hele oppsummeringen etter hvert som feilene rettes\n >\n <ul className=\"jkl-list\">\n {errors\n .filter((error) => typeof error !== \"undefined\")\n .map((error) => (\n <li className=\"jkl-list__item\" key={error}>\n {error}\n </li>\n ))}\n </ul>\n </ErrorMessage>\n </div>\n );\n },\n);\n\nFormErrorMessage.displayName = \"FormErrorMessage\";\n"],"names":["defaultMessageProps","title","FormErrorMessage","forwardRef","props","forwardedRef","className","errors","isSubmitted","isValid","messageProps","rest","showSummary","messageRef","useAnimatedHeight","display","previousErrors","useRef","useEffect","current","hasNewErrors","length","jsx","ref","clsx","children","ErrorMessage","role","filter","error","map","displayName"],"mappings":"qWAiBA,MAAMA,EAAsB,CACxBC,MAAO,8BAGEC,EAAmBC,GAC5B,CAACC,EAAOC,KACE,MAAEC,UAAAA,EAAWC,OAAAA,EAAQC,YAAAA,EAAaC,QAAAA,EAASC,aAAAA,KAAiBC,GAASP,EAErEQ,EAAcJ,IAAgBC,GAE7BI,GAAcC,EAAkCF,EAAa,CAAEG,QAAS,SAEzEC,EAAiBC,EAAkCV,GACzDW,GAAU,KACNF,EAAeG,QAAUZ,CAAAA,GAC1B,CAACA,IACJ,MAAMa,EAAeb,EAAOc,OAASL,EAAeG,QAAQE,OAGxD,OAAAC,EAAC,MAAI,CAAAC,IAAKlB,EAAcC,UAAWkB,EAAK,yBAA0BlB,MAAgBK,EAC9Ec,SAAAH,EAACI,EAAA,IACO1B,KACAU,EACJa,IAAKV,EACLc,KAAMP,EAAe,QAAU,eAE/BK,SAAAH,EAAC,MAAGhB,UAAU,WACTmB,WACIG,QAAQC,UAAiBA,EAAU,MACnCC,KAAKD,GACDP,EAAA,KAAA,CAAGhB,UAAU,iBACTmB,SAAAI,GAD+BA,UAMxD,IAKZ3B,EAAiB6B,YAAc"}
@@ -0,0 +1,2 @@
1
+ import{jsx as s,jsxs as o}from"react/jsx-runtime";import{c as n}from"../../../clsx-BeLtu-UY.js";import i,{forwardRef as c}from"react";import"../../hooks/useScreen/useScreen.js";import{useId as e}from"../../hooks/useId/useId.js";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import{ErrorIcon as r}from"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import{InfoIcon as a}from"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import{SuccessIcon as t}from"../icon/icons/SuccessIcon.js";import{WarningIcon as m}from"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";import{DismissButton as l}from"./DismissButton.js";const j=o=>{switch(o){case"error":return s(r,{className:"jkl-message__icon"});case"info":return s(a,{className:"jkl-message__icon"});case"success":return s(t,{className:"jkl-message__icon"});case"warning":return s(m,{className:"jkl-message__icon"});default:return null}};function p(r){const a=c(((c,a)=>{const{id:t,title:m,fullWidth:p,density:d,className:I="",dismissed:u,dismissAction:g,children:h,role:f,...k}=c,N=e(t||"jkl-message",{generateSuffix:!t}),_=i.Children.map(h,(s=>"string"==typeof s)),w=null!=_&&_[0]?s("p",{children:h}):h;return o("div",{...k,id:t,ref:a,className:n("jkl-message","jkl-message--"+r,I,{"jkl-message--full":p,"jkl-message--dismissed":u}),role:f,"data-density":d,children:[j(r),o("div",{className:"jkl-message__content","data-theme":"light",children:[m&&s("p",{className:"jkl-message__title",children:m}),s("div",{className:"jkl-message__message",children:w})]}),(null==g?void 0:g.handleDismiss)&&s(l,{"aria-controls":N,className:"jkl-message__dismiss-button",label:g.buttonTitle||"Lukk",onClick:g.handleDismiss})]})}));return a.displayName="Message",a}const d=p("info");d.displayName="InfoMessage";const I=p("error");I.displayName="ErrorMessage";const u=p("warning");u.displayName="WarningMessage";const g=p("success");g.displayName="SuccessMessage";export{I as ErrorMessage,d as InfoMessage,g as SuccessMessage,u as WarningMessage};
2
+ //# sourceMappingURL=Message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.js","sources":["../../../../src/components/message/Message.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { AriaRole, forwardRef } from \"react\";\nimport { Density, WithChildren } from \"../..\";\nimport { useId } from \"../../hooks\";\nimport { ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from \"../icon\";\nimport { DismissButton } from \"./DismissButton\";\n\nexport interface MessageProps extends WithChildren {\n id?: string;\n title?: string;\n fullWidth?: boolean;\n density?: Density;\n className?: string;\n dismissed?: boolean;\n dismissAction?: {\n handleDismiss: () => void;\n buttonTitle?: string;\n };\n role?: AriaRole;\n}\n\ntype messageTypes = \"info\" | \"error\" | \"success\" | \"warning\";\n\nconst getIcon = (messageType: messageTypes) => {\n switch (messageType) {\n case \"error\":\n return <ErrorIcon className=\"jkl-message__icon\" />;\n case \"info\":\n return <InfoIcon className=\"jkl-message__icon\" />;\n case \"success\":\n return <SuccessIcon className=\"jkl-message__icon\" />;\n case \"warning\":\n return <WarningIcon className=\"jkl-message__icon\" />;\n default:\n return null;\n }\n};\n\nfunction messageFactory(messageType: messageTypes) {\n const Message = forwardRef<HTMLDivElement, MessageProps>((props, ref) => {\n const {\n id,\n title,\n fullWidth,\n density,\n className = \"\",\n dismissed,\n dismissAction,\n children,\n role,\n ...rest\n } = props;\n\n const boxId = useId(id || \"jkl-message\", { generateSuffix: !id });\n\n const hasStringChild = React.Children.map(children, (child) => typeof child === \"string\");\n const newChildren = hasStringChild?.[0] ? <p>{children}</p> : children;\n\n return (\n <div\n {...rest}\n id={id}\n ref={ref}\n className={clsx(\"jkl-message\", \"jkl-message--\" + messageType, className, {\n \"jkl-message--full\": fullWidth,\n \"jkl-message--dismissed\": dismissed,\n })}\n role={role}\n data-density={density}\n >\n {getIcon(messageType)}\n <div className=\"jkl-message__content\" data-theme=\"light\">\n {title && <p className=\"jkl-message__title\">{title}</p>}\n <div className=\"jkl-message__message\">{newChildren}</div>\n </div>\n {dismissAction?.handleDismiss && (\n <DismissButton\n aria-controls={boxId}\n className=\"jkl-message__dismiss-button\"\n label={dismissAction.buttonTitle || \"Lukk\"}\n onClick={dismissAction.handleDismiss}\n />\n )}\n </div>\n );\n });\n\n Message.displayName = \"Message\";\n\n return Message;\n}\n\nexport const InfoMessage = messageFactory(\"info\");\nInfoMessage.displayName = \"InfoMessage\";\nexport const ErrorMessage = messageFactory(\"error\");\nErrorMessage.displayName = \"ErrorMessage\";\nexport const WarningMessage = messageFactory(\"warning\");\nWarningMessage.displayName = \"WarningMessage\";\nexport const SuccessMessage = messageFactory(\"success\");\nSuccessMessage.displayName = \"SuccessMessage\";\n"],"names":["getIcon","messageType","jsx","ErrorIcon","className","InfoIcon","SuccessIcon","WarningIcon","messageFactory","Message","forwardRef","props","ref","id","title","fullWidth","density","dismissed","dismissAction","children","role","rest","boxId","useId","generateSuffix","hasStringChild","React","Children","map","child","newChildren","jsxs","clsx","handleDismiss","DismissButton","label","buttonTitle","onClick","displayName","InfoMessage","ErrorMessage","WarningMessage","SuccessMessage"],"mappings":"6qDAuBA,MAAMA,EAAWC,IACb,OAAQA,GACJ,IAAK,QACM,OAAAC,EAACC,EAAU,CAAAC,UAAU,sBAChC,IAAK,OACM,OAAAF,EAACG,EAAS,CAAAD,UAAU,sBAC/B,IAAK,UACM,OAAAF,EAACI,EAAY,CAAAF,UAAU,sBAClC,IAAK,UACM,OAAAF,EAACK,EAAY,CAAAH,UAAU,sBAClC,QACW,OAAA,KACf,EAGJ,SAASI,EAAeP,GACpB,MAAMQ,EAAUC,GAAyC,CAACC,EAAOC,KACvD,MACFC,GAAAA,EACAC,MAAAA,EACAC,UAAAA,EACAC,QAAAA,EACAZ,UAAAA,EAAY,GACZa,UAAAA,EACAC,cAAAA,EACAC,SAAAA,EACAC,KAAAA,KACGC,GACHV,EAEEW,EAAQC,EAAMV,GAAM,cAAe,CAAEW,gBAAiBX,IAEtDY,EAAiBC,EAAMC,SAASC,IAAIT,GAAWU,GAA2B,iBAAVA,IAChEC,EAAc,MAAAL,GAAAA,EAAiB,GAAMvB,EAAA,IAAA,CAAGiB,SAAAA,IAAgBA,EAG1D,OAAAY,EAAC,MAAA,IACOV,EACJR,GAAAA,EACAD,IAAAA,EACAR,UAAW4B,EAAK,cAAe,gBAAkB/B,EAAaG,EAAW,CACrE,oBAAqBW,EACrB,yBAA0BE,IAE9BG,KAAAA,EACA,eAAcJ,EAEbG,SAAA,CAAAnB,EAAQC,GACR8B,EAAA,MAAA,CAAI3B,UAAU,uBAAuB,aAAW,QAC5Ce,SAAA,CAAAL,GAAUZ,EAAA,IAAA,CAAEE,UAAU,qBAAsBe,SAAML,IAClDZ,EAAA,MAAA,CAAIE,UAAU,uBAAwBe,SAAYW,QAEtD,MAAAZ,OAAA,EAAAA,EAAee,gBACZ/B,EAACgC,EAAA,CACG,gBAAeZ,EACflB,UAAU,8BACV+B,MAAOjB,EAAckB,aAAe,OACpCC,QAASnB,EAAce,kBAC3B,IAMhBxB,OAAAA,EAAQ6B,YAAc,UAEf7B,CACX,CAEa,MAAA8B,EAAc/B,EAAe,QAC1C+B,EAAYD,YAAc,cACb,MAAAE,EAAehC,EAAe,SAC3CgC,EAAaF,YAAc,eACd,MAAAG,EAAiBjC,EAAe,WAC7CiC,EAAeH,YAAc,iBAChB,MAAAI,EAAiBlC,EAAe,WAC7CkC,EAAeJ,YAAc"}