@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,86 @@
1
+ import { Dispatch, FormEvent, SetStateAction } from 'react';
2
+ export type FeedbackOption<T = string | number> = {
3
+ /** Teksten som vises ved alternativet */
4
+ label: string;
5
+ value: T;
6
+ /** Her kan du spesifisere en egen tekst til oppfølgingsspørsmålet dersom dette alternativet er valgt (gjelder kun alternativene til hovedspørsmålet i Feedback, ignoreres ellers) */
7
+ textAreaLabel?: string;
8
+ };
9
+ export type QuestionType = "radio" | "checkbox" | "text" | "smiley";
10
+ interface BaseQuestion {
11
+ type: QuestionType;
12
+ label: string;
13
+ helpLabel?: string;
14
+ name?: string;
15
+ }
16
+ interface RadioQuestion extends BaseQuestion {
17
+ type: "radio";
18
+ options: FeedbackOption[];
19
+ }
20
+ interface CheckboxQuestion extends BaseQuestion {
21
+ type: "checkbox";
22
+ options: FeedbackOption[];
23
+ }
24
+ interface SmileyQuestion extends BaseQuestion {
25
+ type: "smiley";
26
+ options: FeedbackOption<number>[];
27
+ }
28
+ interface TextQuestion extends BaseQuestion {
29
+ type: "text";
30
+ }
31
+ export type MainQuestion = RadioQuestion | SmileyQuestion;
32
+ export type FollowupQuestion = MainQuestion | TextQuestion | CheckboxQuestion;
33
+ interface BaseFeedbackAnswer {
34
+ label: string;
35
+ name: string;
36
+ type: "radio" | "checkbox" | "text";
37
+ }
38
+ interface MultiFeedbackAnswer extends BaseFeedbackAnswer {
39
+ type: "checkbox";
40
+ value: string[];
41
+ }
42
+ interface SingleFeedbackAnswer extends BaseFeedbackAnswer {
43
+ type: "radio" | "text";
44
+ value: string;
45
+ }
46
+ export type FeedbackAnswer = SingleFeedbackAnswer | MultiFeedbackAnswer;
47
+ export type FeedbackType = {
48
+ /** Feedbackverdien, format avhenger av typen spørsmål */
49
+ feedbackValue: number | string | Array<string | number>;
50
+ /** Angir hvorvidt brukeren aktivt sendte inn tilbakemeldingen. Dersom `false` ble skjemaet sendt inn da brukeren forlot siden */
51
+ intentionalSubmit: boolean;
52
+ /** Eventuell utfyllende melding fra brukeren. Blir bare sendt inn dersom brukeren aktivt sender inn tilbakemelding */
53
+ message?: string;
54
+ };
55
+ export type FeedbackState = {
56
+ currentValue?: FeedbackOption | FeedbackOption[];
57
+ setCurrentValue: Dispatch<SetStateAction<FeedbackOption | FeedbackOption[] | undefined>>;
58
+ message?: string;
59
+ setMessage: Dispatch<SetStateAction<string | undefined>>;
60
+ submitted: boolean;
61
+ handleSubmit: () => void;
62
+ };
63
+ export type FollowUpStep = {
64
+ number: number;
65
+ question: BaseQuestion;
66
+ isLast: boolean;
67
+ };
68
+ export type FollowupState = {
69
+ questions: BaseQuestion[];
70
+ values: FeedbackAnswer[] | undefined;
71
+ currentValue?: FeedbackOption | FeedbackOption[];
72
+ step: FollowUpStep;
73
+ submitted: boolean;
74
+ handleNext: (e?: FormEvent<HTMLFormElement>) => void;
75
+ handleAbort: () => void;
76
+ setCurrentValue: Dispatch<SetStateAction<FeedbackOption | FeedbackOption[] | undefined>>;
77
+ };
78
+ export interface QuestionProps {
79
+ type?: QuestionType;
80
+ label: string;
81
+ name?: string;
82
+ helpLabel?: string;
83
+ options?: FeedbackOption[];
84
+ autoFocus?: boolean;
85
+ }
86
+ export {};
@@ -0,0 +1,4 @@
1
+ import { default as React, JSXElementConstructor, FC } from 'react';
2
+ import { QuestionProps, QuestionType } from './types';
3
+ export declare function getChildrenOfType<P>(...allowedTypes: Array<string | JSXElementConstructor<P>>): (children: React.ReactNode) => React.ReactElement<P, string | React.JSXElementConstructor<unknown>>[] | null | undefined;
4
+ export declare const getQuestionFromType: (type: QuestionType) => FC<QuestionProps>;
@@ -6,6 +6,7 @@ export * from './checkbox';
6
6
  export * from './combobox';
7
7
  export * from './cookie-consent';
8
8
  export * from './datepicker';
9
+ export * from './feedback';
9
10
  export * from './icon';
10
11
  export * from './icon-button';
11
12
  export * from './image';
@@ -14,7 +15,9 @@ export * from './link';
14
15
  export * from './link-list';
15
16
  export * from './list';
16
17
  export * from './loader';
18
+ export * from './message';
17
19
  export * from './modal';
20
+ export * from './popover';
18
21
  export * from './radio-button';
19
22
  export * from './select';
20
23
  export * from './tag';
@@ -0,0 +1,5 @@
1
+ import { default as React, ButtonHTMLAttributes } from 'react';
2
+ export interface DismissButtonProps extends Exclude<ButtonHTMLAttributes<HTMLButtonElement>, "disabled"> {
3
+ label?: string;
4
+ }
5
+ export declare const DismissButton: React.ForwardRefExoticComponent<DismissButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { MessageProps } from './Message';
3
+ export interface FormErrorMessageProps {
4
+ className?: string;
5
+ id?: string;
6
+ /**
7
+ * @default { title: "Feil og mangler i skjemaet" }
8
+ */
9
+ messageProps?: Partial<MessageProps>;
10
+ errors: (string | undefined)[];
11
+ isSubmitted: boolean;
12
+ isValid: boolean;
13
+ }
14
+ export declare const FormErrorMessage: React.ForwardRefExoticComponent<FormErrorMessageProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,19 @@
1
+ import { default as React, AriaRole } from 'react';
2
+ import { Density, WithChildren } from '../..';
3
+ export interface MessageProps extends WithChildren {
4
+ id?: string;
5
+ title?: string;
6
+ fullWidth?: boolean;
7
+ density?: Density;
8
+ className?: string;
9
+ dismissed?: boolean;
10
+ dismissAction?: {
11
+ handleDismiss: () => void;
12
+ buttonTitle?: string;
13
+ };
14
+ role?: AriaRole;
15
+ }
16
+ export declare const InfoMessage: React.ForwardRefExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>;
17
+ export declare const ErrorMessage: React.ForwardRefExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>;
18
+ export declare const WarningMessage: React.ForwardRefExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>;
19
+ export declare const SuccessMessage: React.ForwardRefExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ export { InfoMessage, ErrorMessage, SuccessMessage, WarningMessage, type MessageProps } from './Message';
2
+ export { FormErrorMessage, type FormErrorMessageProps } from './FormErrorMessage';
@@ -0,0 +1,114 @@
1
+ import { useFocus, useHover, useClick, useDismiss, useRole, UseFloatingOptions } from '@floating-ui/react';
2
+ import * as React from "react";
3
+ type ClickOptions = Parameters<typeof useClick>[1];
4
+ type DismissOptions = Parameters<typeof useDismiss>[1];
5
+ type FocusOptions = Parameters<typeof useFocus>[1];
6
+ type HoverOptions = Parameters<typeof useHover>[1];
7
+ type RoleOptions = Parameters<typeof useRole>[1];
8
+ interface PopoverOptions {
9
+ /**
10
+ * Angir om popoveren er åpen eller lukket.
11
+ * @see https://floating-ui.com/docs/useFloating#open
12
+ */
13
+ open?: boolean;
14
+ /**
15
+ * Callback som trigges når popoveren åpnes eller lukkes.
16
+ * @see https://floating-ui.com/docs/useFloating#onOpenChange
17
+ */
18
+ onOpenChange?: UseFloatingOptions["onOpenChange"];
19
+ /**
20
+ * Bestemmer plasseringen av popoveren.
21
+ * @default "bottom-start"
22
+ * @see https://floating-ui.com/docs/useFloating#placement
23
+ */
24
+ placement?: UseFloatingOptions["placement"];
25
+ /**
26
+ * Definerer strategien for posisjonering av popoveren.
27
+ * @default "absolute"
28
+ * @see https://floating-ui.com/docs/useFloating#strategy
29
+ */
30
+ strategy?: UseFloatingOptions["strategy"];
31
+ /**
32
+ * Angir om popoveren skal fungere som en modal, der fokus er låst til det flytende elementet
33
+ * og innhold utenfor ikke kan interageres med.
34
+ * @default true
35
+ * @see https://floating-ui.com/docs/useFloating#modal
36
+ */
37
+ modal?: boolean;
38
+ /**
39
+ * Offset til det flytende elementet.
40
+ * @see https://floating-ui.com/docs/offset
41
+ * @default 4
42
+ * */
43
+ /**
44
+ * Justerer avstanden mellom referanse-elementet og popoveren.
45
+ * @see https://floating-ui.com/docs/offset
46
+ * @default 4
47
+ */
48
+ offset?: number;
49
+ /**
50
+ * Options for hover-interaksjoner.
51
+ * @see https://floating-ui.com/docs/useHover
52
+ * @default { enabled: false }
53
+ */
54
+ hoverOptions?: HoverOptions;
55
+ /**
56
+ * Options for fokus-interaksjoner.
57
+ * @see https://floating-ui.com/docs/useFocus
58
+ * @default { enabled: false }
59
+ */
60
+ focusOptions?: FocusOptions;
61
+ /**
62
+ * Options for klikk-interaksjoner.
63
+ * @see https://floating-ui.com/docs/useClick
64
+ * @default { enabled: false }
65
+ */
66
+ clickOptions?: ClickOptions;
67
+ /**
68
+ * Konfigurerer rollen for popoveren.
69
+ * @see https://floating-ui.com/docs/useRole
70
+ * @default { enabled: true, role: "dialog" }
71
+ */
72
+ roleOptions?: RoleOptions;
73
+ /**
74
+ * Options for å lukke popoveren når en dismissal skjer,
75
+ * som ved å klikke utenfor eller trykke på "Escape"-tasten.
76
+ * @see https://floating-ui.com/docs/useDismiss
77
+ * @default { enabled: true }
78
+ */
79
+ dismissOptions?: DismissOptions;
80
+ }
81
+ declare const Popover: {
82
+ ({ children, ...restOptions }: {
83
+ children: React.ReactNode;
84
+ } & PopoverOptions): React.JSX.Element;
85
+ Trigger: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLElement> & PopoverTriggerProps, "ref"> & React.RefAttributes<HTMLElement>>;
86
+ Content: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLDivElement> & PopoverContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
87
+ };
88
+ interface PopoverTriggerProps {
89
+ children: React.ReactNode;
90
+ /**
91
+ * Rendrer komponenten som child-elementet sitt, og slår
92
+ * sammen egenskaper og props.
93
+ * @example
94
+ * ```tsx
95
+ * <Component asChild foo="bar">
96
+ * <Child baz="qux" />
97
+ * </Component>
98
+ *
99
+ * // Rendrer følgende:
100
+ * <Child foo="bar" baz="qux" />
101
+ * ```
102
+ *
103
+ * @default false
104
+ */
105
+ asChild?: boolean;
106
+ }
107
+ interface PopoverContentProps {
108
+ /**
109
+ * Padding rundt innholdet i popoveren.
110
+ * @default 0
111
+ */
112
+ padding?: 0 | 8 | 16 | 24;
113
+ }
114
+ export default Popover;
@@ -0,0 +1 @@
1
+ export { default as Popover } from './Popover';
@@ -0,0 +1,4 @@
1
+ export declare const getThemeAndDensity: (element: HTMLElement | null) => {
2
+ theme?: string | undefined;
3
+ density?: string | undefined;
4
+ };
@@ -1,2 +1,2 @@
1
- import{jsx as o,jsxs as e}from"react/jsx-runtime";import t from"classnames";import n from"date-fns/startOfDay";import{forwardRef as r,useState as i,useRef as s,useCallback as a}from"react";import{flushSync as c}from"react-dom";import{useAnimatedHeight as l}from"../../hooks/useAnimatedHeight/useAnimatedHeight.js";import"../../hooks/useScreen/useScreen.js";import{useClickOutside as p}from"../../hooks/useClickOutside/useClickOutside.js";import{useFocusOutside as u}from"../../hooks/useFocusOutside/useFocusOutside.js";import"../../hooks/useId/useId.js";import{useKeyListener as m}from"../../hooks/useKeyListener/useKeyListener.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{CalendarIcon as d}from"../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"../tooltip/Tooltip.js";import"../tooltip/TooltipContent.js";import"../tooltip/TooltipTrigger.js";import{InputGroup as j}from"../input-group/InputGroup.js";import"../text-input/BaseTextArea.js";import{BaseTextInput as f}from"../text-input/BaseTextInput.js";import"../text-input/TextArea.js";import"../text-input/TextInput.js";import{Calendar as h}from"./internal/Calendar.js";import{getInitialDate as I}from"./internal/utils.js";import{parseDateString as k,formatInput as v}from"./utils.js";import{isWithinLowerBound as y,isWithinUpperBound as D}from"./validation.js";const b=r(((r,b)=>{const{"data-testautoid":g,id:w,className:C="",label:L="Velg dato",labelProps:T,defaultValue:A,defaultShow:x=!1,value:O,disableBeforeDate:P,disableAfterDate:_,yearsToShow:E,name:S,helpLabel:N,errorLabel:R,invalid:B,density:U,days:K,months:H,monthLabel:V,yearLabel:F,placeholder:W="dd.mm.åååå",width:G="11.25rem",onChange:M,onBlur:q,onFocus:z,onKeyDown:Q,action:J,showCalendarLabel:X="Åpne kalender",hideCalendarLabel:Y="Lukk kalender",supportLabelProps:Z,tooltipProps:$,...oo}=r;"production"!==process.env.NODE_ENV&&O&&A&&console.warn("DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.");const eo=k(P),to=eo?n(eo):void 0,no=k(_),ro=no?n(no):void 0,[io,so]=i(I(O,A,to,ro)),[ao,co]=i(null),[lo,po]=i(x),[uo]=l(lo),mo=s(null),jo=s(null),fo=a((o=>{jo.current=o,b&&("function"==typeof b?b(o):b.current=o)}),[jo,b]),ho=s(null),Io=a((o=>{z&&ho.current&&(ho.current.contains(o.relatedTarget)||z(o,io,{error:ao,value:o.target.value}))}),[z,io,ao]),ko=a((o=>{q&&q(o,io,{error:ao,value:o.target.value})}),[q,io,ao]),vo=a((o=>{"Escape"===o.key&&(po(!1),o.preventDefault(),o.stopPropagation()),null!=J&&J.onKeyDown&&J.onKeyDown(o)}),[po,J]),yo=a((o=>{if("Escape"===o.key&&(po(!1),o.preventDefault(),o.stopPropagation()),Q){let e=o.currentTarget.value;/[\d.]/.test(o.key)&&(e+=o.key),Q(o,io,{error:ao,value:e})}}),[Q,po,io,ao]),Do=a((o=>{let e=null,t=null;if(o.target.value){const n=k(o.target.value);n?to&&!y(n,to)?t="OUTSIDE_LOWER_BOUND":ro&&!D(n,ro)?t="OUTSIDE_UPPER_BOUND":po(!1):t="WRONG_FORMAT",e=n||null}co(t),so(e),M&&M(o,e,{error:t,value:o.target.value})}),[M,co,so,po,to,ro]),bo=a((o=>{c((()=>{po(!lo)}));const e=uo.current,t=e&&e.querySelector('[aria-pressed="true"]');t&&t.focus(),null!=J&&J.onClick&&J.onClick(o)}),[po,lo,J,uo]),go=a((()=>{po(!lo)}),[po,lo]),wo=a((()=>{po(!1)}),[po]),Co=a((({date:o})=>{if(po(!1),so(o),jo.current){const e=jo.current;e.value=v(o);const t=document.createEvent("HTMLEvents");t.initEvent("input",!0,!1),e.dispatchEvent(t),e.focus(),M&&M(t,o,{error:null,value:e.value})}}),[po,so,M]),Lo=a((o=>{o.preventDefault(),po(!1),mo.current&&mo.current.focus()}),[po]);return p(ho,wo),u(ho,wo),m(uo,["Escape"],(()=>{po(!1),jo.current&&jo.current.focus()})),o(j,{id:w,className:t("jkl-datepicker",C,{"jkl-datepicker--open":lo}),...oo,ref:ho,label:L,labelProps:T,density:U,helpLabel:N,errorLabel:R,supportLabelProps:Z,tooltipProps:$,render:t=>e("div",{"data-testid":"jkl-datepicker__input-wrapper",className:"jkl-datepicker__input-wrapper","data-density":U,tabIndex:-1,onKeyDown:yo,children:[o(f,{ref:fo,"data-testid":"jkl-datepicker__input","data-testautoid":g,className:"jkl-datepicker__input",name:S,defaultValue:A,density:U,value:O,type:"text",placeholder:W,width:G,onFocus:Io,onBlur:ko,onClick:go,onChange:Do,...t,action:{buttonRef:mo,icon:o(d,{}),label:lo?Y:X,...J,onClick:bo,onKeyDown:vo}}),o("div",{className:"jkl-datepicker__calendar-wrapper",children:o(h,{ref:uo,density:U,date:io,minDate:to,maxDate:ro,days:K,months:H,monthLabel:V,yearLabel:F,yearsToShow:E,hidden:!lo,onDateSelected:Co,onTabOutside:Lo})})]})})}));b.displayName="DatePicker";export{b as DatePicker};
1
+ import{jsx as o,jsxs as e}from"react/jsx-runtime";import{c as t}from"../../../clsx-BeLtu-UY.js";import n from"date-fns/startOfDay";import{forwardRef as r,useState as i,useRef as s,useCallback as a}from"react";import{flushSync as c}from"react-dom";import{useAnimatedHeight as l}from"../../hooks/useAnimatedHeight/useAnimatedHeight.js";import"../../hooks/useScreen/useScreen.js";import{useClickOutside as p}from"../../hooks/useClickOutside/useClickOutside.js";import{useFocusOutside as u}from"../../hooks/useFocusOutside/useFocusOutside.js";import"../../hooks/useId/useId.js";import{useKeyListener as m}from"../../hooks/useKeyListener/useKeyListener.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{CalendarIcon as d}from"../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"../tooltip/Tooltip.js";import"../tooltip/TooltipContent.js";import"../tooltip/TooltipTrigger.js";import{InputGroup as j}from"../input-group/InputGroup.js";import"../text-input/BaseTextArea.js";import{BaseTextInput as f}from"../text-input/BaseTextInput.js";import"../text-input/TextArea.js";import"../text-input/TextInput.js";import{Calendar as h}from"./internal/Calendar.js";import{getInitialDate as I}from"./internal/utils.js";import{parseDateString as k,formatInput as v}from"./utils.js";import{isWithinLowerBound as y,isWithinUpperBound as D}from"./validation.js";const b=r(((r,b)=>{const{"data-testautoid":g,id:w,className:C="",label:L="Velg dato",labelProps:T,defaultValue:x,defaultShow:A=!1,value:O,disableBeforeDate:P,disableAfterDate:_,yearsToShow:E,name:S,helpLabel:N,errorLabel:R,invalid:B,density:U,days:K,months:H,monthLabel:V,yearLabel:F,placeholder:W="dd.mm.åååå",width:G="11.25rem",onChange:M,onBlur:q,onFocus:z,onKeyDown:Q,action:J,showCalendarLabel:X="Åpne kalender",hideCalendarLabel:Y="Lukk kalender",supportLabelProps:Z,tooltipProps:$,...oo}=r;"production"!==process.env.NODE_ENV&&O&&x&&console.warn("DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.");const eo=k(P),to=eo?n(eo):void 0,no=k(_),ro=no?n(no):void 0,[io,so]=i(I(O,x,to,ro)),[ao,co]=i(null),[lo,po]=i(A),[uo]=l(lo),mo=s(null),jo=s(null),fo=a((o=>{jo.current=o,b&&("function"==typeof b?b(o):b.current=o)}),[jo,b]),ho=s(null),Io=a((o=>{z&&ho.current&&(ho.current.contains(o.relatedTarget)||z(o,io,{error:ao,value:o.target.value}))}),[z,io,ao]),ko=a((o=>{q&&q(o,io,{error:ao,value:o.target.value})}),[q,io,ao]),vo=a((o=>{"Escape"===o.key&&(po(!1),o.preventDefault(),o.stopPropagation()),null!=J&&J.onKeyDown&&J.onKeyDown(o)}),[po,J]),yo=a((o=>{if("Escape"===o.key&&(po(!1),o.preventDefault(),o.stopPropagation()),Q){let e=o.currentTarget.value;/[\d.]/.test(o.key)&&(e+=o.key),Q(o,io,{error:ao,value:e})}}),[Q,po,io,ao]),Do=a((o=>{let e=null,t=null;if(o.target.value){const n=k(o.target.value);n?to&&!y(n,to)?t="OUTSIDE_LOWER_BOUND":ro&&!D(n,ro)?t="OUTSIDE_UPPER_BOUND":po(!1):t="WRONG_FORMAT",e=n||null}co(t),so(e),M&&M(o,e,{error:t,value:o.target.value})}),[M,co,so,po,to,ro]),bo=a((o=>{c((()=>{po(!lo)}));const e=uo.current,t=e&&e.querySelector('[aria-pressed="true"]');t&&t.focus(),null!=J&&J.onClick&&J.onClick(o)}),[po,lo,J,uo]),go=a((()=>{po(!lo)}),[po,lo]),wo=a((()=>{po(!1)}),[po]),Co=a((({date:o})=>{if(po(!1),so(o),jo.current){const e=jo.current;e.value=v(o);const t=document.createEvent("HTMLEvents");t.initEvent("input",!0,!1),e.dispatchEvent(t),e.focus(),M&&M(t,o,{error:null,value:e.value})}}),[po,so,M]),Lo=a((o=>{o.preventDefault(),po(!1),mo.current&&mo.current.focus()}),[po]);return p(ho,wo),u(ho,wo),m(uo,["Escape"],(()=>{po(!1),jo.current&&jo.current.focus()})),o(j,{id:w,className:t("jkl-datepicker",C,{"jkl-datepicker--open":lo}),...oo,ref:ho,label:L,labelProps:T,density:U,helpLabel:N,errorLabel:R,supportLabelProps:Z,tooltipProps:$,render:t=>e("div",{"data-testid":"jkl-datepicker__input-wrapper",className:"jkl-datepicker__input-wrapper","data-density":U,tabIndex:-1,onKeyDown:yo,children:[o(f,{ref:fo,"data-testid":"jkl-datepicker__input","data-testautoid":g,className:"jkl-datepicker__input",name:S,defaultValue:x,density:U,value:O,type:"text",placeholder:W,width:G,onFocus:Io,onBlur:ko,onClick:go,onChange:Do,...t,action:{buttonRef:mo,icon:o(d,{}),label:lo?Y:X,...J,onClick:bo,onKeyDown:vo}}),o("div",{className:"jkl-datepicker__calendar-wrapper",children:o(h,{ref:uo,density:U,date:io,minDate:to,maxDate:ro,days:K,months:H,monthLabel:V,yearLabel:F,yearsToShow:E,hidden:!lo,onDateSelected:Co,onTabOutside:Lo})})]})})}));b.displayName="DatePicker";export{b as DatePicker};
2
2
  //# sourceMappingURL=DatePicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sources":["../../../../src/components/datepicker/DatePicker.tsx"],"sourcesContent":["import cn from \"classnames\";\nimport startOfDay from \"date-fns/startOfDay\";\nimport React, {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { useAnimatedHeight, useClickOutside, useFocusOutside, useKeyListener } from \"../../hooks\";\nimport { CalendarIcon } from \"../icon\";\nimport { InputGroup } from \"../input-group\";\nimport { BaseTextInput } from \"../text-input\";\nimport { Calendar } from \"./internal/Calendar\";\nimport { getInitialDate, DateInfo } from \"./internal/utils\";\nimport { DatePickerProps, DateValidationError } from \"./types\";\nimport { formatInput, parseDateString } from \"./utils\";\nimport { isWithinLowerBound, isWithinUpperBound } from \"./validation\";\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>((props, forwardedInputRef) => {\n const {\n \"data-testautoid\": testAutoId,\n id,\n className = \"\",\n label = \"Velg dato\",\n labelProps,\n defaultValue,\n defaultShow = false,\n value,\n disableBeforeDate: disableBefore,\n disableAfterDate: disableAfter,\n yearsToShow,\n name,\n helpLabel,\n errorLabel,\n invalid,\n density,\n days,\n months,\n monthLabel,\n yearLabel,\n placeholder = \"dd.mm.åååå\",\n width = \"11.25rem\",\n onChange,\n onBlur,\n onFocus,\n onKeyDown,\n action,\n showCalendarLabel = \"Åpne kalender\",\n hideCalendarLabel = \"Lukk kalender\",\n supportLabelProps,\n tooltipProps,\n ...rest\n } = props;\n\n if (process.env.NODE_ENV !== \"production\" && value && defaultValue) {\n console.warn(\n \"DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.\",\n );\n }\n /// Input state\n\n const disableBeforeDate = parseDateString(disableBefore);\n const minDate = disableBeforeDate ? startOfDay(disableBeforeDate) : undefined;\n const disableAfterDate = parseDateString(disableAfter);\n const maxDate = disableAfterDate ? startOfDay(disableAfterDate) : undefined;\n\n const [date, setDate] = useState(getInitialDate(value, defaultValue, minDate, maxDate));\n const [error, setError] = useState<DateValidationError | null>(null);\n\n /// Calendar state\n\n const [showCalendar, setShowCalendar] = useState(defaultShow);\n const [calendarRef] = useAnimatedHeight<HTMLDivElement>(showCalendar);\n\n /// Input events\n\n const iconButtonRef = useRef<HTMLButtonElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n // Hjelper for å gjøre det enklere å både forwarde refen men også bruke den selv internt\n const unifiedInputRef = useCallback(\n (instance: HTMLInputElement | null) => {\n inputRef.current = instance;\n if (forwardedInputRef) {\n if (typeof forwardedInputRef === \"function\") {\n forwardedInputRef(instance);\n } else {\n forwardedInputRef.current = instance;\n }\n }\n },\n [inputRef, forwardedInputRef],\n );\n\n const datepickerRef = useRef<HTMLDivElement>(null);\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (!onFocus || !datepickerRef.current) {\n return;\n }\n\n const nextFocusIsInside = datepickerRef.current.contains(e.relatedTarget as Node);\n if (!nextFocusIsInside) {\n onFocus(e, date, { error, value: e.target.value });\n }\n },\n [onFocus, date, error],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e, date, { error, value: e.target.value });\n }\n },\n [onBlur, date, error],\n );\n\n const handleKeyDownAction = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Escape\") {\n setShowCalendar(false);\n e.preventDefault();\n e.stopPropagation();\n }\n\n if (action?.onKeyDown) {\n action.onKeyDown(e);\n }\n },\n [setShowCalendar, action],\n );\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Escape\") {\n setShowCalendar(false);\n e.preventDefault();\n e.stopPropagation();\n }\n\n if (onKeyDown) {\n let nextValue = e.currentTarget.value;\n if (/[\\d.]/.test(e.key)) {\n nextValue += e.key;\n }\n onKeyDown(e, date, { error, value: nextValue });\n }\n },\n [onKeyDown, setShowCalendar, date, error],\n );\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n let nextDate: Date | null = null;\n let nextError: DateValidationError | null = null;\n\n if (e.target.value) {\n const val = parseDateString(e.target.value);\n if (!val) {\n nextError = \"WRONG_FORMAT\";\n } else if (minDate && !isWithinLowerBound(val, minDate)) {\n nextError = \"OUTSIDE_LOWER_BOUND\";\n } else if (maxDate && !isWithinUpperBound(val, maxDate)) {\n nextError = \"OUTSIDE_UPPER_BOUND\";\n } else {\n setShowCalendar(false);\n }\n nextDate = val || null;\n }\n\n setError(nextError);\n setDate(nextDate);\n\n if (onChange) {\n onChange(e, nextDate, { error: nextError, value: e.target.value });\n }\n },\n [onChange, setError, setDate, setShowCalendar, minDate, maxDate],\n );\n\n /// Calendar events\n\n const clickCalendar = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n flushSync(() => {\n setShowCalendar(!showCalendar);\n });\n\n const calendarEl = calendarRef.current;\n const button = calendarEl && (calendarEl.querySelector('[aria-pressed=\"true\"]') as HTMLButtonElement);\n button && button.focus();\n\n if (action?.onClick) {\n action.onClick(e);\n }\n },\n [setShowCalendar, showCalendar, action, calendarRef],\n );\n\n const clickInput = useCallback(() => {\n setShowCalendar(!showCalendar);\n }, [setShowCalendar, showCalendar]);\n\n const hideCalendar = useCallback(() => {\n setShowCalendar(false);\n }, [setShowCalendar]);\n\n const handleClickCalendarDay = useCallback(\n ({ date }: DateInfo) => {\n setShowCalendar(false);\n setDate(date);\n\n if (inputRef.current) {\n const node = inputRef.current;\n\n node.value = formatInput(date);\n\n // Simulér et change-event så APIet blir så likt som mulig en endring av inputfeltet\n const event = document.createEvent(\"HTMLEvents\");\n event.initEvent(\"input\", true, false);\n node.dispatchEvent(event);\n\n node.focus();\n\n if (onChange) {\n // Det er ikke helt sant at dette er et React.SyntheticEvent, men it's fine – probably?\n // Den har tingene man kan forvente, men hvis du gjør serdeles fancy ting med events\n // så kan det hende du må utvide denne for å dekke behovet ditt.\n onChange(event as unknown as ChangeEvent<HTMLInputElement>, date, {\n error: null,\n value: node.value,\n });\n }\n }\n },\n [setShowCalendar, setDate, onChange],\n );\n\n const handleTabOutsideCalendar = useCallback(\n (e: KeyboardEvent) => {\n e.preventDefault();\n setShowCalendar(false);\n iconButtonRef.current && iconButtonRef.current.focus();\n },\n [setShowCalendar],\n );\n\n useClickOutside(datepickerRef, hideCalendar);\n useFocusOutside(datepickerRef, hideCalendar);\n useKeyListener(calendarRef, [\"Escape\"], () => {\n setShowCalendar(false);\n inputRef.current && inputRef.current.focus();\n });\n\n return (\n <InputGroup\n id={id}\n className={cn(\"jkl-datepicker\", className, {\n \"jkl-datepicker--open\": showCalendar,\n })}\n {...rest}\n ref={datepickerRef}\n label={label}\n labelProps={labelProps}\n density={density}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n supportLabelProps={supportLabelProps}\n tooltipProps={tooltipProps}\n render={(inputProps) => (\n // The <div> element handles keyboard events that bubble up from <button> elements inside\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n data-testid=\"jkl-datepicker__input-wrapper\"\n className=\"jkl-datepicker__input-wrapper\"\n data-density={density}\n tabIndex={-1} // Må være her for Safari onBlur quirk! https://bugs.webkit.org/show_bug.cgi?id=22261\n onKeyDown={handleKeyDown}\n >\n <BaseTextInput\n ref={unifiedInputRef}\n data-testid=\"jkl-datepicker__input\"\n data-testautoid={testAutoId}\n className=\"jkl-datepicker__input\"\n name={name}\n defaultValue={defaultValue}\n density={density}\n value={value}\n type=\"text\"\n placeholder={placeholder}\n width={width}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={clickInput}\n onChange={handleChange}\n {...inputProps}\n action={{\n buttonRef: iconButtonRef,\n icon: <CalendarIcon />,\n label: showCalendar ? hideCalendarLabel : showCalendarLabel,\n ...action,\n onClick: clickCalendar,\n onKeyDown: handleKeyDownAction,\n }}\n />\n <div className=\"jkl-datepicker__calendar-wrapper\">\n <Calendar\n ref={calendarRef}\n density={density}\n date={date}\n minDate={minDate}\n maxDate={maxDate}\n days={days}\n months={months}\n monthLabel={monthLabel}\n yearLabel={yearLabel}\n yearsToShow={yearsToShow}\n hidden={!showCalendar}\n onDateSelected={handleClickCalendarDay}\n onTabOutside={handleTabOutsideCalendar}\n />\n </div>\n </div>\n )}\n />\n );\n});\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":["DatePicker","forwardRef","props","forwardedInputRef","testAutoId","id","className","label","labelProps","defaultValue","defaultShow","value","disableBeforeDate","disableBefore","disableAfterDate","disableAfter","yearsToShow","name","helpLabel","errorLabel","invalid","density","days","months","monthLabel","yearLabel","placeholder","width","onChange","onBlur","onFocus","onKeyDown","action","showCalendarLabel","hideCalendarLabel","supportLabelProps","tooltipProps","rest","process","env","NODE_ENV","console","warn","parseDateString","minDate","startOfDay","maxDate","date","setDate","useState","getInitialDate","error","setError","showCalendar","setShowCalendar","calendarRef","useAnimatedHeight","iconButtonRef","useRef","inputRef","unifiedInputRef","useCallback","instance","current","datepickerRef","handleFocus","e","contains","relatedTarget","target","handleBlur","handleKeyDownAction","key","preventDefault","stopPropagation","handleKeyDown","nextValue","currentTarget","test","handleChange","nextDate","nextError","val","isWithinLowerBound","isWithinUpperBound","clickCalendar","flushSync","calendarEl","button","querySelector","focus","onClick","clickInput","hideCalendar","handleClickCalendarDay","node","formatInput","event","document","createEvent","initEvent","dispatchEvent","handleTabOutsideCalendar","useClickOutside","useFocusOutside","useKeyListener","jsx","InputGroup","cn","ref","render","inputProps","jsxs","tabIndex","children","BaseTextInput","type","buttonRef","icon","CalendarIcon","Calendar","hidden","onDateSelected","onTabOutside","displayName"],"mappings":"ghFAuBO,MAAMA,EAAaC,GAA8C,CAACC,EAAOC,KACtE,MACF,kBAAmBC,EACnBC,GAAAA,EACAC,UAAAA,EAAY,GACZC,MAAAA,EAAQ,YACRC,WAAAA,EACAC,aAAAA,EACAC,YAAAA,GAAc,EACdC,MAAAA,EACAC,kBAAmBC,EACnBC,iBAAkBC,EAClBC,YAAAA,EACAC,KAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,QA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ACJ/E,OAAQ,CACJqF,UAAW5D,GACX6D,OAAOC,EAAa,IACpBhH,MAAO8C,GAAenB,EAAoBD,KACvCD,EACH2D,QAASN,GACTtD,UAAWwC,MAGnBmC,EAAC,MAAI,CAAApG,UAAU,mCACX4G,SAAAR,EAACc,EAAA,CACGX,IAAKtD,GACLlC,QAAAA,EACA0B,KAAAA,GACAH,QAAAA,GACAE,QAAAA,GACAxB,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAT,YAAAA,EACAyG,QAASpE,GACTqE,eAAgB5B,GAChB6B,aAAcrB,WAG1B,IAMhBtG,EAAW4H,YAAc"}
1
+ {"version":3,"file":"DatePicker.js","sources":["../../../../src/components/datepicker/DatePicker.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport startOfDay from \"date-fns/startOfDay\";\nimport React, {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { useAnimatedHeight, useClickOutside, useFocusOutside, useKeyListener } from \"../../hooks\";\nimport { CalendarIcon } from \"../icon\";\nimport { InputGroup } from \"../input-group\";\nimport { BaseTextInput } from \"../text-input\";\nimport { Calendar } from \"./internal/Calendar\";\nimport { getInitialDate, DateInfo } from \"./internal/utils\";\nimport { DatePickerProps, DateValidationError } from \"./types\";\nimport { formatInput, parseDateString } from \"./utils\";\nimport { isWithinLowerBound, isWithinUpperBound } from \"./validation\";\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>((props, forwardedInputRef) => {\n const {\n \"data-testautoid\": testAutoId,\n id,\n className = \"\",\n label = \"Velg dato\",\n labelProps,\n defaultValue,\n defaultShow = false,\n value,\n disableBeforeDate: disableBefore,\n disableAfterDate: disableAfter,\n yearsToShow,\n name,\n helpLabel,\n errorLabel,\n invalid,\n density,\n days,\n months,\n monthLabel,\n yearLabel,\n placeholder = \"dd.mm.åååå\",\n width = \"11.25rem\",\n onChange,\n onBlur,\n onFocus,\n onKeyDown,\n action,\n showCalendarLabel = \"Åpne kalender\",\n hideCalendarLabel = \"Lukk kalender\",\n supportLabelProps,\n tooltipProps,\n ...rest\n } = props;\n\n if (process.env.NODE_ENV !== \"production\" && value && defaultValue) {\n console.warn(\n \"DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.\",\n );\n }\n /// Input state\n\n const disableBeforeDate = parseDateString(disableBefore);\n const minDate = disableBeforeDate ? startOfDay(disableBeforeDate) : undefined;\n const disableAfterDate = parseDateString(disableAfter);\n const maxDate = disableAfterDate ? startOfDay(disableAfterDate) : undefined;\n\n const [date, setDate] = useState(getInitialDate(value, defaultValue, minDate, maxDate));\n const [error, setError] = useState<DateValidationError | null>(null);\n\n /// Calendar state\n\n const [showCalendar, setShowCalendar] = useState(defaultShow);\n const [calendarRef] = useAnimatedHeight<HTMLDivElement>(showCalendar);\n\n /// Input events\n\n const iconButtonRef = useRef<HTMLButtonElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n // Hjelper for å gjøre det enklere å både forwarde refen men også bruke den selv internt\n const unifiedInputRef = useCallback(\n (instance: HTMLInputElement | null) => {\n inputRef.current = instance;\n if (forwardedInputRef) {\n if (typeof forwardedInputRef === \"function\") {\n forwardedInputRef(instance);\n } else {\n forwardedInputRef.current = instance;\n }\n }\n },\n [inputRef, forwardedInputRef],\n );\n\n const datepickerRef = useRef<HTMLDivElement>(null);\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (!onFocus || !datepickerRef.current) {\n return;\n }\n\n const nextFocusIsInside = datepickerRef.current.contains(e.relatedTarget as Node);\n if (!nextFocusIsInside) {\n onFocus(e, date, { error, value: e.target.value });\n }\n },\n [onFocus, date, error],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e, date, { error, value: e.target.value });\n }\n },\n [onBlur, date, error],\n );\n\n const handleKeyDownAction = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Escape\") {\n setShowCalendar(false);\n e.preventDefault();\n e.stopPropagation();\n }\n\n if (action?.onKeyDown) {\n action.onKeyDown(e);\n }\n },\n [setShowCalendar, action],\n );\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Escape\") {\n setShowCalendar(false);\n e.preventDefault();\n e.stopPropagation();\n }\n\n if (onKeyDown) {\n let nextValue = e.currentTarget.value;\n if (/[\\d.]/.test(e.key)) {\n nextValue += e.key;\n }\n onKeyDown(e, date, { error, value: nextValue });\n }\n },\n [onKeyDown, setShowCalendar, date, error],\n );\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n let nextDate: Date | null = null;\n let nextError: DateValidationError | null = null;\n\n if (e.target.value) {\n const val = parseDateString(e.target.value);\n if (!val) {\n nextError = \"WRONG_FORMAT\";\n } else if (minDate && !isWithinLowerBound(val, minDate)) {\n nextError = \"OUTSIDE_LOWER_BOUND\";\n } else if (maxDate && !isWithinUpperBound(val, maxDate)) {\n nextError = \"OUTSIDE_UPPER_BOUND\";\n } else {\n setShowCalendar(false);\n }\n nextDate = val || null;\n }\n\n setError(nextError);\n setDate(nextDate);\n\n if (onChange) {\n onChange(e, nextDate, { error: nextError, value: e.target.value });\n }\n },\n [onChange, setError, setDate, setShowCalendar, minDate, maxDate],\n );\n\n /// Calendar events\n\n const clickCalendar = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n flushSync(() => {\n setShowCalendar(!showCalendar);\n });\n\n const calendarEl = calendarRef.current;\n const button = calendarEl && (calendarEl.querySelector('[aria-pressed=\"true\"]') as HTMLButtonElement);\n button && button.focus();\n\n if (action?.onClick) {\n action.onClick(e);\n }\n },\n [setShowCalendar, showCalendar, action, calendarRef],\n );\n\n const clickInput = useCallback(() => {\n setShowCalendar(!showCalendar);\n }, [setShowCalendar, showCalendar]);\n\n const hideCalendar = useCallback(() => {\n setShowCalendar(false);\n }, [setShowCalendar]);\n\n const handleClickCalendarDay = useCallback(\n ({ date }: DateInfo) => {\n setShowCalendar(false);\n setDate(date);\n\n if (inputRef.current) {\n const node = inputRef.current;\n\n node.value = formatInput(date);\n\n // Simulér et change-event så APIet blir så likt som mulig en endring av inputfeltet\n const event = document.createEvent(\"HTMLEvents\");\n event.initEvent(\"input\", true, false);\n node.dispatchEvent(event);\n\n node.focus();\n\n if (onChange) {\n // Det er ikke helt sant at dette er et React.SyntheticEvent, men it's fine – probably?\n // Den har tingene man kan forvente, men hvis du gjør serdeles fancy ting med events\n // så kan det hende du må utvide denne for å dekke behovet ditt.\n onChange(event as unknown as ChangeEvent<HTMLInputElement>, date, {\n error: null,\n value: node.value,\n });\n }\n }\n },\n [setShowCalendar, setDate, onChange],\n );\n\n const handleTabOutsideCalendar = useCallback(\n (e: KeyboardEvent) => {\n e.preventDefault();\n setShowCalendar(false);\n iconButtonRef.current && iconButtonRef.current.focus();\n },\n [setShowCalendar],\n );\n\n useClickOutside(datepickerRef, hideCalendar);\n useFocusOutside(datepickerRef, hideCalendar);\n useKeyListener(calendarRef, [\"Escape\"], () => {\n setShowCalendar(false);\n inputRef.current && inputRef.current.focus();\n });\n\n return (\n <InputGroup\n id={id}\n className={clsx(\"jkl-datepicker\", className, {\n \"jkl-datepicker--open\": showCalendar,\n })}\n {...rest}\n ref={datepickerRef}\n label={label}\n labelProps={labelProps}\n density={density}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n supportLabelProps={supportLabelProps}\n tooltipProps={tooltipProps}\n render={(inputProps) => (\n // The <div> element handles keyboard events that bubble up from <button> elements inside\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n data-testid=\"jkl-datepicker__input-wrapper\"\n className=\"jkl-datepicker__input-wrapper\"\n data-density={density}\n tabIndex={-1} // Må være her for Safari onBlur quirk! https://bugs.webkit.org/show_bug.cgi?id=22261\n onKeyDown={handleKeyDown}\n >\n <BaseTextInput\n ref={unifiedInputRef}\n data-testid=\"jkl-datepicker__input\"\n data-testautoid={testAutoId}\n className=\"jkl-datepicker__input\"\n name={name}\n defaultValue={defaultValue}\n density={density}\n value={value}\n type=\"text\"\n placeholder={placeholder}\n width={width}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={clickInput}\n onChange={handleChange}\n {...inputProps}\n action={{\n buttonRef: iconButtonRef,\n icon: <CalendarIcon />,\n label: showCalendar ? hideCalendarLabel : showCalendarLabel,\n ...action,\n onClick: clickCalendar,\n onKeyDown: handleKeyDownAction,\n }}\n />\n <div className=\"jkl-datepicker__calendar-wrapper\">\n <Calendar\n ref={calendarRef}\n density={density}\n date={date}\n minDate={minDate}\n maxDate={maxDate}\n days={days}\n months={months}\n monthLabel={monthLabel}\n yearLabel={yearLabel}\n yearsToShow={yearsToShow}\n hidden={!showCalendar}\n onDateSelected={handleClickCalendarDay}\n onTabOutside={handleTabOutsideCalendar}\n />\n </div>\n </div>\n )}\n />\n );\n});\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":["DatePicker","forwardRef","props","forwardedInputRef","testAutoId","id","className","label","labelProps","defaultValue","defaultShow","value","disableBeforeDate","disableBefore","disableAfterDate","disableAfter","yearsToShow","name","helpLabel","errorLabel","invalid","density","days","months","monthLabel","yearLabel","placeholder","width","onChange","onBlur","onFocus","onKeyDown","action","showCalendarLabel","hideCalendarLabel","supportLabelProps","tooltipProps","rest","process","env","NODE_ENV","console","warn","parseDateString","minDate","startOfDay","maxDate","date","setDate","useState","getInitialDate","error","setError","showCalendar","setShowCalendar","calendarRef","useAnimatedHeight","iconButtonRef","useRef","inputRef","unifiedInputRef","useCallback","instance","current","datepickerRef","handleFocus","e","contains","relatedTarget","target","handleBlur","handleKeyDownAction","key","preventDefault","stopPropagation","handleKeyDown","nextValue","currentTarget","test","handleChange","nextDate","nextError","val","isWithinLowerBound","isWithinUpperBound","clickCalendar","flushSync","calendarEl","button","querySelector","focus","onClick","clickInput","hideCalendar","handleClickCalendarDay","node","formatInput","event","document","createEvent","initEvent","dispatchEvent","handleTabOutsideCalendar","useClickOutside","useFocusOutside","useKeyListener","jsx","InputGroup","clsx","ref","render","inputProps","jsxs","tabIndex","children","BaseTextInput","type","buttonRef","icon","CalendarIcon","Calendar","hidden","onDateSelected","onTabOutside","displayName"],"mappings":"oiFAuBO,MAAMA,EAAaC,GAA8C,CAACC,EAAOC,KACtE,MACF,kBAAmBC,EACnBC,GAAAA,EACAC,UAAAA,EAAY,GACZC,MAAAA,EAAQ,YACRC,WAAAA,EACAC,aAAAA,EACAC,YAAAA,GAAc,EACdC,MAAAA,EACAC,kBAAmBC,EACnBC,iBAAkBC,EAClBC,YAAAA,EACAC,KAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAC,YAAAA,EAAc,aACdC,MAAAA,EAAQ,WACRC,SAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,OAAAA,EACAC,kBAAAA,EAAoB,gBACpBC,kBAAAA,EAAoB,gBACpBC,kBAAAA,EACAC,aAAAA,KACGC,IACHnC,EAEyB,eAAzBoC,QAAQC,IAAIC,UAA6B7B,GAASF,GAC1CgC,QAAAC,KACJ,sIAKF,MAAA9B,GAAoB+B,EAAgB9B,GACpC+B,GAAUhC,GAAoBiC,EAAWjC,SAAqB,EAC9DE,GAAmB6B,EAAgB5B,GACnC+B,GAAUhC,GAAmB+B,EAAW/B,SAAoB,GAE3DiC,GAAMC,IAAWC,EAASC,EAAevC,EAAOF,EAAcmC,GAASE,MACvEK,GAAOC,IAAYH,EAAqC,OAIxDI,GAAcC,IAAmBL,EAASvC,IAC1C6C,IAAeC,EAAkCH,IAIlDI,GAAgBC,EAAiC,MACjDC,GAAWD,EAAgC,MAG3CE,GAAkBC,GACnBC,IACGH,GAASI,QAAUD,EACf3D,IACiC,mB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sG,EAAK,iBAAkBtG,EAAW,CACzC,uBAAwB+C,QAExBhB,GACJwE,IAAK7C,GACLzD,MAAAA,EACAC,WAAAA,EACAa,QAAAA,EACAH,UAAAA,EACAC,WAAAA,EACAgB,kBAAAA,EACAC,aAAAA,EACA0E,OAASC,GAGLC,EAAC,MAAA,CACG,cAAY,gCACZ1G,UAAU,gCACV,eAAce,EACd4F,UAAU,EACVlF,UAAW4C,GAEXuC,SAAA,CAAAR,EAACS,EAAA,CACGN,IAAKjD,GACL,cAAY,wBACZ,kBAAiBxD,EACjBE,UAAU,wBACVW,KAAAA,EACAR,aAAAA,EACAY,QAAAA,EACAV,MAAAA,EACAyG,KAAK,OACL1F,YAAAA,EACAC,MAAAA,EACAG,QAASmC,GACTpC,OAAQyC,GACRqB,QAASC,GACThE,SAAUmD,MACNgC,EACJ/E,OAAQ,CACJqF,UAAW5D,GACX6D,OAAOC,EAAa,IACpBhH,MAAO8C,GAAenB,EAAoBD,KACvCD,EACH2D,QAASN,GACTtD,UAAWwC,MAGnBmC,EAAC,MAAI,CAAApG,UAAU,mCACX4G,SAAAR,EAACc,EAAA,CACGX,IAAKtD,GACLlC,QAAAA,EACA0B,KAAAA,GACAH,QAAAA,GACAE,QAAAA,GACAxB,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAT,YAAAA,EACAyG,QAASpE,GACTqE,eAAgB5B,GAChB6B,aAAcrB,WAG1B,IAMhBtG,EAAW4H,YAAc"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import n from"classnames";import{forwardRef as a,useReducer as o,useEffect as r,useCallback as c,useRef as i}from"react";import{flushSync as s}from"react-dom";import"../../../hooks/useScreen/useScreen.js";import{useId as l}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{ArrowLeftIcon as d}from"../../icon/icons/ArrowLeftIcon.js";import"../../icon/icons/ArrowNorthEastIcon.js";import{ArrowRightIcon as u}from"../../icon/icons/ArrowRightIcon.js";import"../../icon/icons/ArrowUpIcon.js";import"../../icon/icons/CalendarIcon.js";import"../../icon/icons/CheckIcon.js";import{ChevronDownIcon as m}from"../../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{calendarReducer as h,calendarInitializer as p}from"./calendarReducer.js";import{useCalendar as g}from"./useCalendar.js";import{getInitialDateShown as f,isBackDisabled as j,subtractMonth as b,isForwardDisabled as v,addMonth as k,getYearSelectOptions as w,getMonthSelectOptions as D,DEFAULT_YEARS_TO_SHOW as I}from"./utils.js";const y=["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],A=["man","tir","ons","tor","fre","lør","søn"],S=a(((a,S)=>{const{hidden:_,date:M,defaultSelected:C,density:F,minDate:N,maxDate:E,days:Y=A,months:x=y,monthLabel:O="Velg måned",yearLabel:T="Velg år",yearsToShow:$=I,onTabOutside:R,...L}=a,q=l("jkl-calendar"),[{offset:P,selectedDate:U,shownDate:K},H]=o(h,f(M,C,N,E),p),J=K.getMonth(),V=K.getFullYear();r((()=>{H({type:"SET_SELECTED_DATE",newDate:f(M,C,N,E)})}),[M,C,N,E]);const W=c((e=>{H({type:"SET_OFFSET",newOffset:e})}),[]),{calendars:z,getBackProps:B,getDateProps:G,getForwardProps:Q,handleOffsetChanged:X}=g({date:U,selected:U,minDate:N,maxDate:E,offset:P,onOffsetChanged:W,firstDayOfWeek:1,...L}),Z=i(null),ee=c((e=>{if(!Z.current)return;const t=document.activeElement,n=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]'),a=async e=>{null==t||t.setAttribute("tabindex","-1"),e.setAttribute("tabindex","0"),e.focus()};n.forEach(((o,r)=>{const c=r+e;if(o==t)if(c<=n.length-1&&c>=0)a(n[c]);else if(e<0){if(j({calendars:z,minDate:N})||(s((()=>{X(P-b({calendars:z,offset:1,minDate:N}))})),!Z.current))return;const e=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[e.length+c]&&(e[0].setAttribute("tabindex","-1"),a(e[e.length+c]))}else{if(v({calendars:z,maxDate:E})||(s((()=>{X(P+k({calendars:z,offset:1,maxDate:E}))})),!Z.current))return;const e=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[c-n.length]&&(e[0].setAttribute("tabindex","-1"),a(e[c-n.length]))}}))}),[X,Z,P,z,E,N]),te=c((e=>{switch(e.key){case"ArrowUp":ee(-7),e.preventDefault();break;case"ArrowRight":ee(1),e.preventDefault();break;case"ArrowDown":ee(7),e.preventDefault();break;case"ArrowLeft":ee(-1),e.preventDefault()}}),[ee]),ne=c((e=>{var t;if("Tab"!==e.key)return;const n=null==(t=Z.current)?void 0:t.querySelectorAll('button:not([disabled]):not([tabindex="-1"]), select');if(!n)return;const a=n[0],o=n[n.length-1];e.shiftKey||document.activeElement!==o?e.shiftKey&&document.activeElement===a&&(o.focus(),e.preventDefault()):(a.focus(),e.preventDefault())}),[]),ae=c((e=>{const{date:t,selected:n,selectable:a,prevMonth:o,nextMonth:r}=e;return!!a&&!(!n&&t.toString()!==(null==N?void 0:N.toString())&&(o||r||K.getFullYear()!==t.getFullYear()||U.getMonth()===t.getMonth()||1!==t.getDate()))}),[K,N,U]),oe=c((()=>{N&&K.getFullYear()-N.getFullYear()==0&&K.getMonth()-N.getMonth()==1?document.querySelectorAll(".jkl-calendar-navigation__arrow")[1].focus():E&&E.getFullYear()-K.getFullYear()==0&&E.getMonth()-K.getMonth()==1&&document.querySelectorAll(".jkl-calendar-navigation__arrow")[0].focus()}),[N,E,K]),re=c((e=>{if(4!==e.target.value.length)return;const t=Number.parseInt(e.target.value);if(Number.isNaN(t))return;let n=12*(t-K.getFullYear());const a=new Date(K.getFullYear(),K.getMonth()+n,K.getDate());E&&E.getFullYear()===a.getFullYear()&&E.getMonth()<a.getMonth()?n-=a.getMonth()-E.getMonth():N&&N.getFullYear()===a.getFullYear()&&N.getMonth()>a.getMonth()&&(n+=N.getMonth()-a.getMonth()),H({type:"ADD_OFFSET",addedOffset:n})}),[K,N,E]),ce=c((e=>{if(!U&&!M)return;const t=K.getFullYear()-(U||new Date).getFullYear(),n=Number.parseInt(e.target.value)-(U||new Date).getMonth();H({type:"SET_OFFSET",newOffset:12*t+n})}),[U,M,K]),ie=w(V,N,E,$),se=D(V,x,N,E);return e("div",{ref:S,id:q,className:n("jkl-calendar",{"jkl-calendar--hidden":_}),"data-testid":"jkl-calendar",children:t("div",{className:"jkl-calendar__padding",ref:Z,onKeyDown:ne,children:[t("fieldset",{className:"jkl-calendar-navigation",children:[t("div",{children:[e("button",{...B({calendars:z,onClick:oe}),className:"jkl-calendar-navigation__arrow",type:"button",children:e(d,{variant:"medium",bold:!0})}),e("button",{...Q({calendars:z,onClick:oe}),className:"jkl-calendar-navigation__arrow",type:"button",children:e(u,{variant:"medium",bold:!0})})]}),t("div",{children:[t("div",{className:"jkl-calendar-navigation-dropdown",children:[e("select",{onChange:ce,className:"jkl-calendar-navigation-dropdown__select","aria-label":O,value:J.toString(),children:se.map((({label:t,value:n})=>e("option",{value:n,children:t},n)))}),e(m,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]}),t("div",{className:"jkl-calendar-navigation-dropdown",children:[e("select",{onChange:re,className:"jkl-calendar-navigation-dropdown__select","aria-label":T,value:V.toString(),children:ie.map((t=>e("option",{value:t,children:t},t)))}),e(m,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]})]})]}),z.map((n=>t("table",{className:"jkl-calendar-table","data-testid":"jkl-datepicker-calendar",children:[t("caption",{className:"jkl-sr-only",children:[x[n.month],", ",n.year]}),e("thead",{children:e("tr",{children:Y.map((t=>e("th",{children:t},`${n.month}${n.year}${t}`)))})}),e("tbody",{"data-testid":"jkl-datepicker-dates",children:n.weeks.map(((t,a)=>e("tr",{children:t.map(((t,o)=>{const r=`${n.month}${n.year}${a}${o}`;if("string"==typeof t)return e("td",{className:"jkl-calendar__date jkl-calendar__date--empty",children:t},r);const{date:c,selectable:i,today:s,prevMonth:l,nextMonth:d}=t;return e("td",{children:e("button",{...G({dateObj:t}),type:"button",className:"jkl-calendar-date-button",tabIndex:ae(t)?0:-1,"aria-label":`${c.getDate()}. ${x[c.getMonth()].toLowerCase()}`,"aria-current":s?"date":void 0,"data-adjacent":l||d?"true":void 0,disabled:!i,onKeyDown:te,children:e("span",{"aria-hidden":"true",children:c.getDate()})})},r)}))},`${n.month}${n.year}${a}`)))})]},`${n.month}${n.year}`)))]})})}));S.displayName="Calendar";export{S as Calendar};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{c as n}from"../../../../clsx-BeLtu-UY.js";import{forwardRef as a,useReducer as o,useEffect as r,useCallback as c,useRef as i}from"react";import{flushSync as s}from"react-dom";import"../../../hooks/useScreen/useScreen.js";import{useId as l}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{ArrowLeftIcon as d}from"../../icon/icons/ArrowLeftIcon.js";import"../../icon/icons/ArrowNorthEastIcon.js";import{ArrowRightIcon as u}from"../../icon/icons/ArrowRightIcon.js";import"../../icon/icons/ArrowUpIcon.js";import"../../icon/icons/CalendarIcon.js";import"../../icon/icons/CheckIcon.js";import{ChevronDownIcon as m}from"../../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{calendarReducer as h,calendarInitializer as p}from"./calendarReducer.js";import{useCalendar as g}from"./useCalendar.js";import{getInitialDateShown as j,isBackDisabled as f,subtractMonth as b,isForwardDisabled as v,addMonth as k,getYearSelectOptions as w,getMonthSelectOptions as D,DEFAULT_YEARS_TO_SHOW as I}from"./utils.js";const y=["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],A=["man","tir","ons","tor","fre","lør","søn"],S=a(((a,S)=>{const{hidden:_,date:M,defaultSelected:C,density:F,minDate:N,maxDate:E,days:x=A,months:Y=y,monthLabel:O="Velg måned",yearLabel:T="Velg år",yearsToShow:$=I,onTabOutside:R,...L}=a,q=l("jkl-calendar"),[{offset:P,selectedDate:U,shownDate:K},H]=o(h,j(M,C,N,E),p),J=K.getMonth(),V=K.getFullYear();r((()=>{H({type:"SET_SELECTED_DATE",newDate:j(M,C,N,E)})}),[M,C,N,E]);const W=c((e=>{H({type:"SET_OFFSET",newOffset:e})}),[]),{calendars:z,getBackProps:B,getDateProps:G,getForwardProps:Q,handleOffsetChanged:X}=g({date:U,selected:U,minDate:N,maxDate:E,offset:P,onOffsetChanged:W,firstDayOfWeek:1,...L}),Z=i(null),ee=c((e=>{if(!Z.current)return;const t=document.activeElement,n=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]'),a=async e=>{null==t||t.setAttribute("tabindex","-1"),e.setAttribute("tabindex","0"),e.focus()};n.forEach(((o,r)=>{const c=r+e;if(o==t)if(c<=n.length-1&&c>=0)a(n[c]);else if(e<0){if(f({calendars:z,minDate:N})||(s((()=>{X(P-b({calendars:z,offset:1,minDate:N}))})),!Z.current))return;const e=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[e.length+c]&&(e[0].setAttribute("tabindex","-1"),a(e[e.length+c]))}else{if(v({calendars:z,maxDate:E})||(s((()=>{X(P+k({calendars:z,offset:1,maxDate:E}))})),!Z.current))return;const e=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[c-n.length]&&(e[0].setAttribute("tabindex","-1"),a(e[c-n.length]))}}))}),[X,Z,P,z,E,N]),te=c((e=>{switch(e.key){case"ArrowUp":ee(-7),e.preventDefault();break;case"ArrowRight":ee(1),e.preventDefault();break;case"ArrowDown":ee(7),e.preventDefault();break;case"ArrowLeft":ee(-1),e.preventDefault()}}),[ee]),ne=c((e=>{var t;if("Tab"!==e.key)return;const n=null==(t=Z.current)?void 0:t.querySelectorAll('button:not([disabled]):not([tabindex="-1"]), select');if(!n)return;const a=n[0],o=n[n.length-1];e.shiftKey||document.activeElement!==o?e.shiftKey&&document.activeElement===a&&(o.focus(),e.preventDefault()):(a.focus(),e.preventDefault())}),[]),ae=c((e=>{const{date:t,selected:n,selectable:a,prevMonth:o,nextMonth:r}=e;return!!a&&!(!n&&t.toString()!==(null==N?void 0:N.toString())&&(o||r||K.getFullYear()!==t.getFullYear()||U.getMonth()===t.getMonth()||1!==t.getDate()))}),[K,N,U]),oe=c((()=>{N&&K.getFullYear()-N.getFullYear()==0&&K.getMonth()-N.getMonth()==1?document.querySelectorAll(".jkl-calendar-navigation__arrow")[1].focus():E&&E.getFullYear()-K.getFullYear()==0&&E.getMonth()-K.getMonth()==1&&document.querySelectorAll(".jkl-calendar-navigation__arrow")[0].focus()}),[N,E,K]),re=c((e=>{if(4!==e.target.value.length)return;const t=Number.parseInt(e.target.value);if(Number.isNaN(t))return;let n=12*(t-K.getFullYear());const a=new Date(K.getFullYear(),K.getMonth()+n,K.getDate());E&&E.getFullYear()===a.getFullYear()&&E.getMonth()<a.getMonth()?n-=a.getMonth()-E.getMonth():N&&N.getFullYear()===a.getFullYear()&&N.getMonth()>a.getMonth()&&(n+=N.getMonth()-a.getMonth()),H({type:"ADD_OFFSET",addedOffset:n})}),[K,N,E]),ce=c((e=>{if(!U&&!M)return;const t=K.getFullYear()-(U||new Date).getFullYear(),n=Number.parseInt(e.target.value)-(U||new Date).getMonth();H({type:"SET_OFFSET",newOffset:12*t+n})}),[U,M,K]),ie=w(V,N,E,$),se=D(V,Y,N,E);return e("div",{ref:S,id:q,className:n("jkl-calendar",{"jkl-calendar--hidden":_}),"data-testid":"jkl-calendar",children:t("div",{className:"jkl-calendar__padding",ref:Z,onKeyDown:ne,children:[t("fieldset",{className:"jkl-calendar-navigation",children:[t("div",{children:[e("button",{...B({calendars:z,onClick:oe}),className:"jkl-calendar-navigation__arrow",type:"button",children:e(d,{variant:"medium",bold:!0})}),e("button",{...Q({calendars:z,onClick:oe}),className:"jkl-calendar-navigation__arrow",type:"button",children:e(u,{variant:"medium",bold:!0})})]}),t("div",{children:[t("div",{className:"jkl-calendar-navigation-dropdown",children:[e("select",{onChange:ce,className:"jkl-calendar-navigation-dropdown__select","aria-label":O,value:J.toString(),children:se.map((({label:t,value:n})=>e("option",{value:n,children:t},n)))}),e(m,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]}),t("div",{className:"jkl-calendar-navigation-dropdown",children:[e("select",{onChange:re,className:"jkl-calendar-navigation-dropdown__select","aria-label":T,value:V.toString(),children:ie.map((t=>e("option",{value:t,children:t},t)))}),e(m,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]})]})]}),z.map((n=>t("table",{className:"jkl-calendar-table","data-testid":"jkl-datepicker-calendar",children:[t("caption",{className:"jkl-sr-only",children:[Y[n.month],", ",n.year]}),e("thead",{children:e("tr",{children:x.map((t=>e("th",{children:t},`${n.month}${n.year}${t}`)))})}),e("tbody",{"data-testid":"jkl-datepicker-dates",children:n.weeks.map(((t,a)=>e("tr",{children:t.map(((t,o)=>{const r=`${n.month}${n.year}${a}${o}`;if("string"==typeof t)return e("td",{className:"jkl-calendar__date jkl-calendar__date--empty",children:t},r);const{date:c,selectable:i,today:s,prevMonth:l,nextMonth:d}=t;return e("td",{children:e("button",{...G({dateObj:t}),type:"button",className:"jkl-calendar-date-button",tabIndex:ae(t)?0:-1,"aria-label":`${c.getDate()}. ${Y[c.getMonth()].toLowerCase()}`,"aria-current":s?"date":void 0,"data-adjacent":l||d?"true":void 0,disabled:!i,onKeyDown:te,children:e("span",{"aria-hidden":"true",children:c.getDate()})})},r)}))},`${n.month}${n.year}${a}`)))})]},`${n.month}${n.year}`)))]})})}));S.displayName="Calendar";export{S as Calendar};
2
2
  //# sourceMappingURL=Calendar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","sources":["../../../../../src/components/datepicker/internal/Calendar.tsx"],"sourcesContent":["import cn from \"classnames\";\nimport React, { forwardRef, useCallback, useEffect, useReducer, useRef } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { Density } from \"../../../core\";\nimport { useId } from \"../../../hooks\";\nimport { ArrowLeftIcon, ArrowRightIcon, ChevronDownIcon } from \"../../icon\";\nimport type { YearsToShow } from \"../types\";\nimport { calendarInitializer, calendarReducer } from \"./calendarReducer\";\nimport { useCalendar, UseCalendarProps } from \"./useCalendar\";\nimport {\n addMonth,\n subtractMonth,\n isBackDisabled,\n isForwardDisabled,\n getYearSelectOptions,\n getMonthSelectOptions,\n DateInfo,\n getInitialDateShown,\n DEFAULT_YEARS_TO_SHOW,\n} from \"./utils\";\n\ninterface CalendarProps\n extends Omit<UseCalendarProps, \"date\" | \"onOffsetChanged\" | \"offset\" | \"firstDayOfWeek\" | \"selected\"> {\n date: Date | null;\n density?: Density;\n defaultSelected?: Date;\n hidden?: boolean;\n days?: string[];\n months?: string[];\n monthLabel?: string;\n yearLabel?: string;\n yearsToShow?: YearsToShow;\n onTabOutside: React.KeyboardEventHandler;\n}\n\nconst defaultMonths = [\n \"Januar\",\n \"Februar\",\n \"Mars\",\n \"April\",\n \"Mai\",\n \"Juni\",\n \"Juli\",\n \"August\",\n \"September\",\n \"Oktober\",\n \"November\",\n \"Desember\",\n];\n\nconst defaultDays = [\"man\", \"tir\", \"ons\", \"tor\", \"fre\", \"lør\", \"søn\"];\n\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>((props, ref) => {\n const {\n hidden,\n date,\n defaultSelected,\n density,\n minDate,\n maxDate,\n days = defaultDays,\n months = defaultMonths,\n monthLabel = \"Velg måned\",\n yearLabel = \"Velg år\",\n yearsToShow = DEFAULT_YEARS_TO_SHOW,\n onTabOutside,\n ...rest\n } = props;\n\n const id = useId(\"jkl-calendar\");\n\n const [{ offset, selectedDate, shownDate }, dispatch] = useReducer(\n calendarReducer,\n getInitialDateShown(date, defaultSelected, minDate, maxDate),\n calendarInitializer,\n );\n\n const shownMonth = shownDate.getMonth();\n const shownYear = shownDate.getFullYear();\n\n useEffect(() => {\n dispatch({\n type: \"SET_SELECTED_DATE\",\n newDate: getInitialDateShown(date, defaultSelected, minDate, maxDate),\n });\n }, [date, defaultSelected, minDate, maxDate]);\n\n const onOffsetChanged = useCallback((newOffset: number) => {\n dispatch({\n type: \"SET_OFFSET\",\n newOffset,\n });\n }, []);\n\n const { calendars, getBackProps, getDateProps, getForwardProps, handleOffsetChanged } = useCalendar({\n date: selectedDate,\n selected: selectedDate,\n minDate,\n maxDate,\n offset,\n onOffsetChanged,\n firstDayOfWeek: 1,\n ...rest,\n });\n\n /// Calendar keyboard navigation\n\n const calendarPaddingRef = useRef<HTMLDivElement>(null);\n const doFocusChange = useCallback(\n (offsetDiff: number) => {\n if (!calendarPaddingRef.current) {\n return;\n }\n\n const e = document.activeElement;\n const buttons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n\n const changeFocusTo = async (nextButton: HTMLButtonElement) => {\n e?.setAttribute(\"tabindex\", \"-1\");\n nextButton.setAttribute(\"tabindex\", \"0\");\n nextButton.focus();\n };\n\n buttons.forEach((el, i) => {\n const newNodeKey = i + offsetDiff;\n\n if (el == e) {\n if (newNodeKey <= buttons.length - 1 && newNodeKey >= 0) {\n changeFocusTo(buttons[newNodeKey]);\n } else if (offsetDiff < 0) {\n if (isBackDisabled({ calendars, minDate })) {\n return;\n }\n\n // Hvis newNodeKey er utenfor samlingen med knapper så har vi prøvd å gå til\n // en dag utenfor måneden. Er offsetDiff negativ så har vi gått tilbake en\n // måned.\n flushSync(() => {\n handleOffsetChanged(offset - subtractMonth({ calendars, offset: 1, minDate }));\n });\n if (!calendarPaddingRef.current) {\n return;\n }\n const newButtons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n // + - = -\n if (newButtons[newButtons.length + newNodeKey]) {\n // Sørg for at ikke både 1. i måneden og valgt dag er fokuserbare\n newButtons[0].setAttribute(\"tabindex\", \"-1\");\n changeFocusTo(newButtons[newButtons.length + newNodeKey]);\n }\n } else {\n if (isForwardDisabled({ calendars, maxDate })) {\n return;\n }\n\n // Hvis newNodeKey er utenfor samlingen med knapper så har vi prøvd å gå til\n // en dag utenfor måneden. Er offsetDiff positiv så har vi gått frem en\n // måned.\n flushSync(() => {\n handleOffsetChanged(offset + addMonth({ calendars, offset: 1, maxDate }));\n });\n if (!calendarPaddingRef.current) {\n return;\n }\n const newButtons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n // NewNodeKey er basert på forrige måneds liste med knapper. For at verdien skal bli\n // riktig i vår nye måned må vi trekke fra anntal dager fra forrige måned.\n if (newButtons[newNodeKey - buttons.length]) {\n // Sørg for at ikke både 1. i måneden og valgt dag er fokuserbare\n newButtons[0].setAttribute(\"tabindex\", \"-1\");\n changeFocusTo(newButtons[newNodeKey - buttons.length]);\n }\n }\n }\n });\n },\n [handleOffsetChanged, calendarPaddingRef, offset, calendars, maxDate, minDate],\n );\n\n const handleArrowNavigation = useCallback(\n (event: React.KeyboardEvent) => {\n switch (event.key) {\n case \"ArrowUp\":\n doFocusChange(-7);\n event.preventDefault();\n break;\n case \"ArrowRight\":\n doFocusChange(1);\n event.preventDefault();\n break;\n case \"ArrowDown\":\n doFocusChange(7);\n event.preventDefault();\n break;\n case \"ArrowLeft\":\n doFocusChange(-1);\n event.preventDefault();\n break;\n default:\n break;\n }\n },\n [doFocusChange],\n );\n\n const handleTabInside: React.KeyboardEventHandler = useCallback((event) => {\n if (event.key !== \"Tab\") return;\n\n const focusableElements = calendarPaddingRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]):not([tabindex=\"-1\"]), select',\n );\n\n if (!focusableElements) return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n if (!event.shiftKey && document.activeElement === lastElement) {\n firstElement.focus();\n event.preventDefault();\n } else if (event.shiftKey && document.activeElement === firstElement) {\n lastElement.focus();\n event.preventDefault();\n }\n }, []);\n\n const isFocusableDate = useCallback(\n (dateInfo: DateInfo) => {\n const { date, selected, selectable, prevMonth, nextMonth } = dateInfo;\n\n // Datoen kan ikke velges\n if (!selectable) {\n return false;\n }\n // Datoen er valgt dato\n if (selected) {\n return true;\n }\n // Datoen er første valgbare dato\n if (date.toString() === minDate?.toString()) {\n return true;\n }\n\n // Datoen er første i måneden som vises\n if (\n !prevMonth &&\n !nextMonth &&\n shownDate.getFullYear() === date.getFullYear() &&\n selectedDate.getMonth() !== date.getMonth() &&\n date.getDate() === 1\n ) {\n return true;\n }\n\n return false;\n },\n [shownDate, minDate, selectedDate],\n );\n\n const handleGotoEdgeMonth = useCallback(() => {\n if (\n // Vi er i ferd med å gå til første måned\n minDate &&\n shownDate.getFullYear() - minDate.getFullYear() === 0 &&\n shownDate.getMonth() - minDate.getMonth() === 1\n ) {\n // Fokuser på \"neste månded\"-knappen\n document.querySelectorAll<HTMLButtonElement>(\".jkl-calendar-navigation__arrow\")[1].focus();\n } else if (\n // Vi er i ferd med å gå til siste måned\n maxDate &&\n maxDate.getFullYear() - shownDate.getFullYear() === 0 &&\n maxDate.getMonth() - shownDate.getMonth() === 1\n ) {\n // Fokuser på \"forrige månded\"-knappen\n document.querySelectorAll<HTMLButtonElement>(\".jkl-calendar-navigation__arrow\")[0].focus();\n }\n }, [minDate, maxDate, shownDate]);\n\n /// Extended variant events\n\n const handleYearChange = useCallback<React.ChangeEventHandler<HTMLSelectElement>>(\n (event) => {\n if (event.target.value.length !== 4) {\n return;\n }\n\n const year: number = Number.parseInt(event.target.value);\n if (Number.isNaN(year)) {\n return;\n }\n\n let offset = (year - shownDate.getFullYear()) * 12;\n const expectedDate = new Date(shownDate.getFullYear(), shownDate.getMonth() + offset, shownDate.getDate());\n\n // Pass på at vi ikke hopper forbi maks. eller min. dato\n if (\n maxDate &&\n maxDate.getFullYear() === expectedDate.getFullYear() &&\n maxDate.getMonth() < expectedDate.getMonth()\n ) {\n offset -= expectedDate.getMonth() - maxDate.getMonth();\n } else if (\n minDate &&\n minDate.getFullYear() === expectedDate.getFullYear() &&\n minDate.getMonth() > expectedDate.getMonth()\n ) {\n offset += minDate.getMonth() - expectedDate.getMonth();\n }\n\n dispatch({\n type: \"ADD_OFFSET\",\n addedOffset: offset,\n });\n\n return;\n },\n [shownDate, minDate, maxDate],\n );\n\n const handleMonthChange = useCallback<React.ChangeEventHandler<HTMLSelectElement>>(\n (event) => {\n if (!selectedDate && !date) {\n return;\n }\n\n const yearDiff = shownDate.getFullYear() - (selectedDate || new Date()).getFullYear();\n const monthDiff = Number.parseInt(event.target.value) - (selectedDate || new Date()).getMonth();\n\n dispatch({\n type: \"SET_OFFSET\",\n newOffset: yearDiff * 12 + monthDiff,\n });\n\n return;\n },\n [selectedDate, date, shownDate],\n );\n\n const yearSelectOptions = getYearSelectOptions(shownYear, minDate, maxDate, yearsToShow);\n const monthSelectOptions = getMonthSelectOptions(shownYear, months, minDate, maxDate);\n\n return (\n <div\n ref={ref}\n id={id}\n className={cn(\"jkl-calendar\", {\n \"jkl-calendar--hidden\": hidden,\n })}\n data-testid=\"jkl-calendar\"\n >\n {/* Vi lytter på på trykk på Tab inne i kalenderen for å håndtere fokus */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div className=\"jkl-calendar__padding\" ref={calendarPaddingRef} onKeyDown={handleTabInside}>\n <fieldset className=\"jkl-calendar-navigation\">\n <div>\n <button\n {...getBackProps({ calendars, onClick: handleGotoEdgeMonth })}\n className=\"jkl-calendar-navigation__arrow\"\n type=\"button\"\n >\n <ArrowLeftIcon variant=\"medium\" bold />\n </button>\n <button\n {...getForwardProps({ calendars, onClick: handleGotoEdgeMonth })}\n className=\"jkl-calendar-navigation__arrow\"\n type=\"button\"\n >\n <ArrowRightIcon variant=\"medium\" bold />\n </button>\n </div>\n <div>\n <div className=\"jkl-calendar-navigation-dropdown\">\n <select\n onChange={handleMonthChange}\n className=\"jkl-calendar-navigation-dropdown__select\"\n aria-label={monthLabel}\n value={shownMonth.toString()}\n >\n {monthSelectOptions.map(({ label, value }) => (\n <option key={value} value={value}>\n {label}\n </option>\n ))}\n </select>\n <ChevronDownIcon bold className=\"jkl-calendar-navigation-dropdown__chevron\" />\n </div>\n <div className=\"jkl-calendar-navigation-dropdown\">\n <select\n onChange={handleYearChange}\n className=\"jkl-calendar-navigation-dropdown__select\"\n aria-label={yearLabel}\n value={shownYear.toString()}\n >\n {yearSelectOptions.map((year) => (\n <option key={year} value={year}>\n {year}\n </option>\n ))}\n </select>\n <ChevronDownIcon bold className=\"jkl-calendar-navigation-dropdown__chevron\" />\n </div>\n </div>\n </fieldset>\n {calendars.map((calendar) => (\n <table\n className=\"jkl-calendar-table\"\n key={`${calendar.month}${calendar.year}`}\n data-testid=\"jkl-datepicker-calendar\"\n >\n <caption className=\"jkl-sr-only\">\n {months[calendar.month]}, {calendar.year}\n </caption>\n <thead>\n <tr>\n {days.map((weekday) => (\n <th key={`${calendar.month}${calendar.year}${weekday}`}>{weekday}</th>\n ))}\n </tr>\n </thead>\n <tbody data-testid=\"jkl-datepicker-dates\">\n {calendar.weeks.map((week, weekIndex) => (\n <tr key={`${calendar.month}${calendar.year}${weekIndex}`}>\n {week.map((dateInfo, index) => {\n const key = `${calendar.month}${calendar.year}${weekIndex}${index}`;\n if (typeof dateInfo === \"string\") {\n return (\n <td className=\"jkl-calendar__date jkl-calendar__date--empty\" key={key}>\n {dateInfo}\n </td>\n );\n }\n const { date, selectable, today, prevMonth, nextMonth } = dateInfo;\n\n return (\n <td key={key}>\n <button\n {...getDateProps({\n dateObj: dateInfo,\n })}\n type=\"button\"\n className=\"jkl-calendar-date-button\"\n tabIndex={isFocusableDate(dateInfo) ? 0 : -1}\n aria-label={`${date.getDate()}. ${months[\n date.getMonth()\n ].toLowerCase()}`}\n aria-current={today ? \"date\" : undefined}\n data-adjacent={prevMonth || nextMonth ? \"true\" : undefined}\n disabled={!selectable}\n onKeyDown={handleArrowNavigation}\n >\n <span aria-hidden=\"true\">{date.getDate()}</span>\n </button>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n ))}\n </div>\n </div>\n );\n});\n\nCalendar.displayName = \"Calendar\";\n"],"names":["defaultMonths","defaultDays","Calendar","forwardRef","props","ref","hidden","date","defaultSelected","density","minDate","maxDate","days","months","monthLabel","yearLabel","yearsToShow","DEFAULT_YEARS_TO_SHOW","onTabOutside","rest","id","useId","offset","selectedDate","shownDate","dispatch","useReducer","calendarReducer","getInitialDateShown","calendarInitializer","shownMonth","getMonth","shownYear","getFullYear","useEffect","type","newDate","onOffsetChanged","useCallback","newOffset","calendars","getBackProps","getDateProps","getForwardProps","handleOffsetChanged","useCalendar","selected","firstDayOfWeek","calendarPaddingRef","useRef","doFocusChange","offsetDiff","current","e","document","activeElement","buttons","querySelectorAll","changeFocusTo","async","nextButton","setAttribute","focus","forEach","el","i","newNodeKey","length","isBackDisabled","flushSync","subtractMonth","newButtons","isForwardDisabled","addMonth","handleArrowNavigation","event","key","preventDefault","handleTabInside","focusableElements","_a","firstElement","lastElement","shiftKey","isFocusableDate","dateInfo","selectable","prevMonth","nextMonth","toString","getDate","handleGotoEdgeMonth","handleYearChange","target","value","year","Number","parseInt","isNaN","expectedDate","Date","addedOffset","handleMonthChange","yearDiff","monthDiff","yearSelectOptions","getYearSelectOptions","monthSelectOptions","getMonthSelectOptions","jsx","className","cn","children","onKeyDown","jsxs","onClick","ArrowLeftIcon","variant","bold","ArrowRightIcon","onChange","map","label","ChevronDownIcon","calendar","month","weekday","weeks","week","weekIndex","index","today","dateObj","tabIndex","toLowerCase","disabled","displayName"],"mappings":"wnEAmCA,MAAMA,EAAgB,CAClB,SACA,UACA,OACA,QACA,MACA,OACA,OACA,SACA,YACA,UACA,WACA,YAGEC,EAAc,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,OAElDC,EAAWC,GAA0C,CAACC,EAAOC,KAChE,MACFC,OAAAA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EAC9BN,EAAKwB,YACPuG,gBACF,eAAcH,EAAQ,YAAS,EAC/B,gBAAe5C,GAAaC,EAAY,YAAS,EACjD+C,UAAWjD,EACX2B,UAAWvC,GAEXsC,WAAC,OAAK,CAAA,cAAY,OAAQA,SAAAzG,EAAKmF,eAhB9Bd,EAkBT,KA/BH,GAAGgD,EAASC,QAAQD,EAAS7B,OAAOkC,WAfhD,GAAGL,EAASC,QAAQD,EAAS7B,cAsD9C,IAKZ7F,EAASsI,YAAc"}
1
+ {"version":3,"file":"Calendar.js","sources":["../../../../../src/components/datepicker/internal/Calendar.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useCallback, useEffect, useReducer, useRef } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { Density } from \"../../../core\";\nimport { useId } from \"../../../hooks\";\nimport { ArrowLeftIcon, ArrowRightIcon, ChevronDownIcon } from \"../../icon\";\nimport type { YearsToShow } from \"../types\";\nimport { calendarInitializer, calendarReducer } from \"./calendarReducer\";\nimport { useCalendar, UseCalendarProps } from \"./useCalendar\";\nimport {\n addMonth,\n subtractMonth,\n isBackDisabled,\n isForwardDisabled,\n getYearSelectOptions,\n getMonthSelectOptions,\n DateInfo,\n getInitialDateShown,\n DEFAULT_YEARS_TO_SHOW,\n} from \"./utils\";\n\ninterface CalendarProps\n extends Omit<UseCalendarProps, \"date\" | \"onOffsetChanged\" | \"offset\" | \"firstDayOfWeek\" | \"selected\"> {\n date: Date | null;\n density?: Density;\n defaultSelected?: Date;\n hidden?: boolean;\n days?: string[];\n months?: string[];\n monthLabel?: string;\n yearLabel?: string;\n yearsToShow?: YearsToShow;\n onTabOutside: React.KeyboardEventHandler;\n}\n\nconst defaultMonths = [\n \"Januar\",\n \"Februar\",\n \"Mars\",\n \"April\",\n \"Mai\",\n \"Juni\",\n \"Juli\",\n \"August\",\n \"September\",\n \"Oktober\",\n \"November\",\n \"Desember\",\n];\n\nconst defaultDays = [\"man\", \"tir\", \"ons\", \"tor\", \"fre\", \"lør\", \"søn\"];\n\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>((props, ref) => {\n const {\n hidden,\n date,\n defaultSelected,\n density,\n minDate,\n maxDate,\n days = defaultDays,\n months = defaultMonths,\n monthLabel = \"Velg måned\",\n yearLabel = \"Velg år\",\n yearsToShow = DEFAULT_YEARS_TO_SHOW,\n onTabOutside,\n ...rest\n } = props;\n\n const id = useId(\"jkl-calendar\");\n\n const [{ offset, selectedDate, shownDate }, dispatch] = useReducer(\n calendarReducer,\n getInitialDateShown(date, defaultSelected, minDate, maxDate),\n calendarInitializer,\n );\n\n const shownMonth = shownDate.getMonth();\n const shownYear = shownDate.getFullYear();\n\n useEffect(() => {\n dispatch({\n type: \"SET_SELECTED_DATE\",\n newDate: getInitialDateShown(date, defaultSelected, minDate, maxDate),\n });\n }, [date, defaultSelected, minDate, maxDate]);\n\n const onOffsetChanged = useCallback((newOffset: number) => {\n dispatch({\n type: \"SET_OFFSET\",\n newOffset,\n });\n }, []);\n\n const { calendars, getBackProps, getDateProps, getForwardProps, handleOffsetChanged } = useCalendar({\n date: selectedDate,\n selected: selectedDate,\n minDate,\n maxDate,\n offset,\n onOffsetChanged,\n firstDayOfWeek: 1,\n ...rest,\n });\n\n /// Calendar keyboard navigation\n\n const calendarPaddingRef = useRef<HTMLDivElement>(null);\n const doFocusChange = useCallback(\n (offsetDiff: number) => {\n if (!calendarPaddingRef.current) {\n return;\n }\n\n const e = document.activeElement;\n const buttons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n\n const changeFocusTo = async (nextButton: HTMLButtonElement) => {\n e?.setAttribute(\"tabindex\", \"-1\");\n nextButton.setAttribute(\"tabindex\", \"0\");\n nextButton.focus();\n };\n\n buttons.forEach((el, i) => {\n const newNodeKey = i + offsetDiff;\n\n if (el == e) {\n if (newNodeKey <= buttons.length - 1 && newNodeKey >= 0) {\n changeFocusTo(buttons[newNodeKey]);\n } else if (offsetDiff < 0) {\n if (isBackDisabled({ calendars, minDate })) {\n return;\n }\n\n // Hvis newNodeKey er utenfor samlingen med knapper så har vi prøvd å gå til\n // en dag utenfor måneden. Er offsetDiff negativ så har vi gått tilbake en\n // måned.\n flushSync(() => {\n handleOffsetChanged(offset - subtractMonth({ calendars, offset: 1, minDate }));\n });\n if (!calendarPaddingRef.current) {\n return;\n }\n const newButtons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n // + - = -\n if (newButtons[newButtons.length + newNodeKey]) {\n // Sørg for at ikke både 1. i måneden og valgt dag er fokuserbare\n newButtons[0].setAttribute(\"tabindex\", \"-1\");\n changeFocusTo(newButtons[newButtons.length + newNodeKey]);\n }\n } else {\n if (isForwardDisabled({ calendars, maxDate })) {\n return;\n }\n\n // Hvis newNodeKey er utenfor samlingen med knapper så har vi prøvd å gå til\n // en dag utenfor måneden. Er offsetDiff positiv så har vi gått frem en\n // måned.\n flushSync(() => {\n handleOffsetChanged(offset + addMonth({ calendars, offset: 1, maxDate }));\n });\n if (!calendarPaddingRef.current) {\n return;\n }\n const newButtons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n // NewNodeKey er basert på forrige måneds liste med knapper. For at verdien skal bli\n // riktig i vår nye måned må vi trekke fra anntal dager fra forrige måned.\n if (newButtons[newNodeKey - buttons.length]) {\n // Sørg for at ikke både 1. i måneden og valgt dag er fokuserbare\n newButtons[0].setAttribute(\"tabindex\", \"-1\");\n changeFocusTo(newButtons[newNodeKey - buttons.length]);\n }\n }\n }\n });\n },\n [handleOffsetChanged, calendarPaddingRef, offset, calendars, maxDate, minDate],\n );\n\n const handleArrowNavigation = useCallback(\n (event: React.KeyboardEvent) => {\n switch (event.key) {\n case \"ArrowUp\":\n doFocusChange(-7);\n event.preventDefault();\n break;\n case \"ArrowRight\":\n doFocusChange(1);\n event.preventDefault();\n break;\n case \"ArrowDown\":\n doFocusChange(7);\n event.preventDefault();\n break;\n case \"ArrowLeft\":\n doFocusChange(-1);\n event.preventDefault();\n break;\n default:\n break;\n }\n },\n [doFocusChange],\n );\n\n const handleTabInside: React.KeyboardEventHandler = useCallback((event) => {\n if (event.key !== \"Tab\") return;\n\n const focusableElements = calendarPaddingRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]):not([tabindex=\"-1\"]), select',\n );\n\n if (!focusableElements) return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n if (!event.shiftKey && document.activeElement === lastElement) {\n firstElement.focus();\n event.preventDefault();\n } else if (event.shiftKey && document.activeElement === firstElement) {\n lastElement.focus();\n event.preventDefault();\n }\n }, []);\n\n const isFocusableDate = useCallback(\n (dateInfo: DateInfo) => {\n const { date, selected, selectable, prevMonth, nextMonth } = dateInfo;\n\n // Datoen kan ikke velges\n if (!selectable) {\n return false;\n }\n // Datoen er valgt dato\n if (selected) {\n return true;\n }\n // Datoen er første valgbare dato\n if (date.toString() === minDate?.toString()) {\n return true;\n }\n\n // Datoen er første i måneden som vises\n if (\n !prevMonth &&\n !nextMonth &&\n shownDate.getFullYear() === date.getFullYear() &&\n selectedDate.getMonth() !== date.getMonth() &&\n date.getDate() === 1\n ) {\n return true;\n }\n\n return false;\n },\n [shownDate, minDate, selectedDate],\n );\n\n const handleGotoEdgeMonth = useCallback(() => {\n if (\n // Vi er i ferd med å gå til første måned\n minDate &&\n shownDate.getFullYear() - minDate.getFullYear() === 0 &&\n shownDate.getMonth() - minDate.getMonth() === 1\n ) {\n // Fokuser på \"neste månded\"-knappen\n document.querySelectorAll<HTMLButtonElement>(\".jkl-calendar-navigation__arrow\")[1].focus();\n } else if (\n // Vi er i ferd med å gå til siste måned\n maxDate &&\n maxDate.getFullYear() - shownDate.getFullYear() === 0 &&\n maxDate.getMonth() - shownDate.getMonth() === 1\n ) {\n // Fokuser på \"forrige månded\"-knappen\n document.querySelectorAll<HTMLButtonElement>(\".jkl-calendar-navigation__arrow\")[0].focus();\n }\n }, [minDate, maxDate, shownDate]);\n\n /// Extended variant events\n\n const handleYearChange = useCallback<React.ChangeEventHandler<HTMLSelectElement>>(\n (event) => {\n if (event.target.value.length !== 4) {\n return;\n }\n\n const year: number = Number.parseInt(event.target.value);\n if (Number.isNaN(year)) {\n return;\n }\n\n let offset = (year - shownDate.getFullYear()) * 12;\n const expectedDate = new Date(shownDate.getFullYear(), shownDate.getMonth() + offset, shownDate.getDate());\n\n // Pass på at vi ikke hopper forbi maks. eller min. dato\n if (\n maxDate &&\n maxDate.getFullYear() === expectedDate.getFullYear() &&\n maxDate.getMonth() < expectedDate.getMonth()\n ) {\n offset -= expectedDate.getMonth() - maxDate.getMonth();\n } else if (\n minDate &&\n minDate.getFullYear() === expectedDate.getFullYear() &&\n minDate.getMonth() > expectedDate.getMonth()\n ) {\n offset += minDate.getMonth() - expectedDate.getMonth();\n }\n\n dispatch({\n type: \"ADD_OFFSET\",\n addedOffset: offset,\n });\n\n return;\n },\n [shownDate, minDate, maxDate],\n );\n\n const handleMonthChange = useCallback<React.ChangeEventHandler<HTMLSelectElement>>(\n (event) => {\n if (!selectedDate && !date) {\n return;\n }\n\n const yearDiff = shownDate.getFullYear() - (selectedDate || new Date()).getFullYear();\n const monthDiff = Number.parseInt(event.target.value) - (selectedDate || new Date()).getMonth();\n\n dispatch({\n type: \"SET_OFFSET\",\n newOffset: yearDiff * 12 + monthDiff,\n });\n\n return;\n },\n [selectedDate, date, shownDate],\n );\n\n const yearSelectOptions = getYearSelectOptions(shownYear, minDate, maxDate, yearsToShow);\n const monthSelectOptions = getMonthSelectOptions(shownYear, months, minDate, maxDate);\n\n return (\n <div\n ref={ref}\n id={id}\n className={clsx(\"jkl-calendar\", {\n \"jkl-calendar--hidden\": hidden,\n })}\n data-testid=\"jkl-calendar\"\n >\n {/* Vi lytter på på trykk på Tab inne i kalenderen for å håndtere fokus */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div className=\"jkl-calendar__padding\" ref={calendarPaddingRef} onKeyDown={handleTabInside}>\n <fieldset className=\"jkl-calendar-navigation\">\n <div>\n <button\n {...getBackProps({ calendars, onClick: handleGotoEdgeMonth })}\n className=\"jkl-calendar-navigation__arrow\"\n type=\"button\"\n >\n <ArrowLeftIcon variant=\"medium\" bold />\n </button>\n <button\n {...getForwardProps({ calendars, onClick: handleGotoEdgeMonth })}\n className=\"jkl-calendar-navigation__arrow\"\n type=\"button\"\n >\n <ArrowRightIcon variant=\"medium\" bold />\n </button>\n </div>\n <div>\n <div className=\"jkl-calendar-navigation-dropdown\">\n <select\n onChange={handleMonthChange}\n className=\"jkl-calendar-navigation-dropdown__select\"\n aria-label={monthLabel}\n value={shownMonth.toString()}\n >\n {monthSelectOptions.map(({ label, value }) => (\n <option key={value} value={value}>\n {label}\n </option>\n ))}\n </select>\n <ChevronDownIcon bold className=\"jkl-calendar-navigation-dropdown__chevron\" />\n </div>\n <div className=\"jkl-calendar-navigation-dropdown\">\n <select\n onChange={handleYearChange}\n className=\"jkl-calendar-navigation-dropdown__select\"\n aria-label={yearLabel}\n value={shownYear.toString()}\n >\n {yearSelectOptions.map((year) => (\n <option key={year} value={year}>\n {year}\n </option>\n ))}\n </select>\n <ChevronDownIcon bold className=\"jkl-calendar-navigation-dropdown__chevron\" />\n </div>\n </div>\n </fieldset>\n {calendars.map((calendar) => (\n <table\n className=\"jkl-calendar-table\"\n key={`${calendar.month}${calendar.year}`}\n data-testid=\"jkl-datepicker-calendar\"\n >\n <caption className=\"jkl-sr-only\">\n {months[calendar.month]}, {calendar.year}\n </caption>\n <thead>\n <tr>\n {days.map((weekday) => (\n <th key={`${calendar.month}${calendar.year}${weekday}`}>{weekday}</th>\n ))}\n </tr>\n </thead>\n <tbody data-testid=\"jkl-datepicker-dates\">\n {calendar.weeks.map((week, weekIndex) => (\n <tr key={`${calendar.month}${calendar.year}${weekIndex}`}>\n {week.map((dateInfo, index) => {\n const key = `${calendar.month}${calendar.year}${weekIndex}${index}`;\n if (typeof dateInfo === \"string\") {\n return (\n <td className=\"jkl-calendar__date jkl-calendar__date--empty\" key={key}>\n {dateInfo}\n </td>\n );\n }\n const { date, selectable, today, prevMonth, nextMonth } = dateInfo;\n\n return (\n <td key={key}>\n <button\n {...getDateProps({\n dateObj: dateInfo,\n })}\n type=\"button\"\n className=\"jkl-calendar-date-button\"\n tabIndex={isFocusableDate(dateInfo) ? 0 : -1}\n aria-label={`${date.getDate()}. ${months[\n date.getMonth()\n ].toLowerCase()}`}\n aria-current={today ? \"date\" : undefined}\n data-adjacent={prevMonth || nextMonth ? \"true\" : undefined}\n disabled={!selectable}\n onKeyDown={handleArrowNavigation}\n >\n <span aria-hidden=\"true\">{date.getDate()}</span>\n </button>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n ))}\n </div>\n </div>\n );\n});\n\nCalendar.displayName = \"Calendar\";\n"],"names":["defaultMonths","defaultDays","Calendar","forwardRef","props","ref","hidden","date","defaultSelected","density","minDate","maxDate","days","months","monthLabel","yearLabel","yearsToShow","DEFAULT_YEARS_TO_SHOW","onTabOutside","rest","id","useId","offset","selectedDate","shownDate","dispatch","useReducer","calendarReducer","getInitialDateShown","calendarInitializer","shownMonth","getMonth","shownYear","getFullYear","useEffect","type","newDate","onOffsetChanged","useCallback","newOffset","calendars","getBackProps","getDateProps","getForwardProps","handleOffsetChanged","useCalendar","selected","firstDayOfWeek","calendarPaddingRef","useRef","doFocusChange","offsetDiff","current","e","document","activeElement","buttons","querySelectorAll","changeFocusTo","async","nextButton","setAttribute","focus","forEach","el","i","newNodeKey","length","isBackDisabled","flushSync","subtractMonth","newButtons","isForwardDisabled","addMonth","handleArrowNavigation","event","key","preventDefault","handleTabInside","focusableElements","_a","firstElement","lastElement","shiftKey","isFocusableDate","dateInfo","selectable","prevMonth","nextMonth","toString","getDate","handleGotoEdgeMonth","handleYearChange","target","value","year","Number","parseInt","isNaN","expectedDate","Date","addedOffset","handleMonthChange","yearDiff","monthDiff","yearSelectOptions","getYearSelectOptions","monthSelectOptions","getMonthSelectOptions","jsx","className","clsx","children","onKeyDown","jsxs","onClick","ArrowLeftIcon","variant","bold","ArrowRightIcon","onChange","map","label","ChevronDownIcon","calendar","month","weekday","weeks","week","weekIndex","index","today","dateObj","tabIndex","toLowerCase","disabled","displayName"],"mappings":"+oEAmCA,MAAMA,EAAgB,CAClB,SACA,UACA,OACA,QACA,MACA,OACA,OACA,SACA,YACA,UACA,WACA,YAGEC,EAAc,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,OAElDC,EAAWC,GAA0C,CAACC,EAAOC,KAChE,MACFC,OAAAA,EACAC,KAAAA,EACAC,gBAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,KAAAA,EAAOX,EACPY,OAAAA,EAASb,EACTc,WAAAA,EAAa,aACbC,UAAAA,EAAY,UACZC,YAAAA,EAAcC,EACdC,aAAAA,KACGC,GACHf,EAEEgB,EAAKC,EAAM,kBAERC,OAAAA,EAAQC,aAAAA,EAAcC,UAAAA,GAAaC,GAAYC,EACpDC,EACAC,EAAoBrB,EAAMC,EAAiBE,EAASC,GACpDkB,GAGEC,EAAaN,EAAUO,WACvBC,EAAYR,EAAUS,cAE5BC,GAAU,KACGT,EAAA,CACLU,KAAM,oBACNC,QAASR,EAAoBrB,EAAMC,EAAiBE,EAASC,IAChE,GACF,CAACJ,EAAMC,EAAiBE,EAASC,IAE9B0B,MAAAA,EAAkBC,GAAaC,IACxBd,EAAA,CACLU,KAAM,aACNI,UAAAA,GACH,GACF,KAEKC,UAAAA,EAAWC,aAAAA,EAAcC,aAAAA,EAAcC,gBAAAA,EAAiBC,oBAAAA,GAAwBC,EAAY,CAChGtC,KAAMgB,EACNuB,SAAUvB,EACVb,QAAAA,EACAC,QAAAA,EACAW,OAAAA,EACAe,gBAAAA,EACAU,eAAgB,KACb5B,IAKD6B,EAAq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