@fremtind/jokul 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/LICENSE +21 -0
  2. package/build/build-stats.html +4842 -0
  3. package/build/cjs/components/ScreenReaderOnly.js +2 -0
  4. package/build/cjs/components/ScreenReaderOnly.js.map +1 -0
  5. package/build/cjs/components/SlotComponent.js +2 -0
  6. package/build/cjs/components/SlotComponent.js.map +1 -0
  7. package/build/cjs/components/index.js +2 -0
  8. package/build/cjs/components/index.js.map +1 -0
  9. package/build/cjs/components/navigation/Link.js +2 -0
  10. package/build/cjs/components/navigation/Link.js.map +1 -0
  11. package/build/cjs/components/navigation/NavLink.js +2 -0
  12. package/build/cjs/components/navigation/NavLink.js.map +1 -0
  13. package/build/cjs/components/navigation/index.js +2 -0
  14. package/build/cjs/components/navigation/index.js.map +1 -0
  15. package/build/cjs/core/as-child.js +2 -0
  16. package/build/cjs/core/as-child.js.map +1 -0
  17. package/build/cjs/core/index.js +2 -0
  18. package/build/cjs/core/index.js.map +1 -0
  19. package/build/cjs/core/polymorphism.js +2 -0
  20. package/build/cjs/core/polymorphism.js.map +1 -0
  21. package/build/cjs/core/tokens.js +2 -0
  22. package/build/cjs/core/tokens.js.map +1 -0
  23. package/build/cjs/core/types.js +2 -0
  24. package/build/cjs/core/types.js.map +1 -0
  25. package/build/cjs/core/utils/breakpoints.js +2 -0
  26. package/build/cjs/core/utils/breakpoints.js.map +1 -0
  27. package/build/cjs/core/utils/density.js +2 -0
  28. package/build/cjs/core/utils/density.js.map +1 -0
  29. package/build/cjs/core/utils/getValuePair.js +2 -0
  30. package/build/cjs/core/utils/getValuePair.js.map +1 -0
  31. package/build/cjs/core/utils/index.js +2 -0
  32. package/build/cjs/core/utils/index.js.map +1 -0
  33. package/build/cjs/core/utils/mergeProps.js +2 -0
  34. package/build/cjs/core/utils/mergeProps.js.map +1 -0
  35. package/build/cjs/core/utils/mergeRefs.js +2 -0
  36. package/build/cjs/core/utils/mergeRefs.js.map +1 -0
  37. package/build/cjs/core/utils/motion.js +2 -0
  38. package/build/cjs/core/utils/motion.js.map +1 -0
  39. package/build/cjs/core/utils/tabListener.js +2 -0
  40. package/build/cjs/core/utils/tabListener.js.map +1 -0
  41. package/build/cjs/hooks/index.js +2 -0
  42. package/build/cjs/hooks/index.js.map +1 -0
  43. package/build/cjs/hooks/mediaQueryUtils.js +2 -0
  44. package/build/cjs/hooks/mediaQueryUtils.js.map +1 -0
  45. package/build/cjs/hooks/useAnimatedDetails/index.js +2 -0
  46. package/build/cjs/hooks/useAnimatedDetails/index.js.map +1 -0
  47. package/build/cjs/hooks/useAnimatedDetails/useAnimatedDetails.js +2 -0
  48. package/build/cjs/hooks/useAnimatedDetails/useAnimatedDetails.js.map +1 -0
  49. package/build/cjs/hooks/useAnimatedHeight/index.js +2 -0
  50. package/build/cjs/hooks/useAnimatedHeight/index.js.map +1 -0
  51. package/build/cjs/hooks/useAnimatedHeight/types.js +2 -0
  52. package/build/cjs/hooks/useAnimatedHeight/types.js.map +1 -0
  53. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeight.js +2 -0
  54. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeight.js.map +1 -0
  55. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeightBetween.js +2 -0
  56. package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeightBetween.js.map +1 -0
  57. package/build/cjs/hooks/useAnimatedHeight/useAutoAnimateHeight.js +2 -0
  58. package/build/cjs/hooks/useAnimatedHeight/useAutoAnimateHeight.js.map +1 -0
  59. package/build/cjs/hooks/useAriaLiveRegion/index.js +2 -0
  60. package/build/cjs/hooks/useAriaLiveRegion/index.js.map +1 -0
  61. package/build/cjs/hooks/useAriaLiveRegion/useAriaLiveRegion.js +2 -0
  62. package/build/cjs/hooks/useAriaLiveRegion/useAriaLiveRegion.js.map +1 -0
  63. package/build/cjs/hooks/useBrowserPreferences/index.js +2 -0
  64. package/build/cjs/hooks/useBrowserPreferences/index.js.map +1 -0
  65. package/build/cjs/hooks/useBrowserPreferences/useBrowserPreferences.js +2 -0
  66. package/build/cjs/hooks/useBrowserPreferences/useBrowserPreferences.js.map +1 -0
  67. package/build/cjs/hooks/useClickOutside/index.js +2 -0
  68. package/build/cjs/hooks/useClickOutside/index.js.map +1 -0
  69. package/build/cjs/hooks/useClickOutside/useClickOutside.js +2 -0
  70. package/build/cjs/hooks/useClickOutside/useClickOutside.js.map +1 -0
  71. package/build/cjs/hooks/useElementDimensions/index.js +2 -0
  72. package/build/cjs/hooks/useElementDimensions/index.js.map +1 -0
  73. package/build/cjs/hooks/useElementDimensions/useElementDimensions.js +2 -0
  74. package/build/cjs/hooks/useElementDimensions/useElementDimensions.js.map +1 -0
  75. package/build/cjs/hooks/useFocusOutside/index.js +2 -0
  76. package/build/cjs/hooks/useFocusOutside/index.js.map +1 -0
  77. package/build/cjs/hooks/useFocusOutside/useFocusOutside.js +2 -0
  78. package/build/cjs/hooks/useFocusOutside/useFocusOutside.js.map +1 -0
  79. package/build/cjs/hooks/useId/index.js +2 -0
  80. package/build/cjs/hooks/useId/index.js.map +1 -0
  81. package/build/cjs/hooks/useId/useId.js +2 -0
  82. package/build/cjs/hooks/useId/useId.js.map +1 -0
  83. package/build/cjs/hooks/useIntersectionObserver/index.js +2 -0
  84. package/build/cjs/hooks/useIntersectionObserver/index.js.map +1 -0
  85. package/build/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -0
  86. package/build/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -0
  87. package/build/cjs/hooks/useKeyListener/index.js +2 -0
  88. package/build/cjs/hooks/useKeyListener/index.js.map +1 -0
  89. package/build/cjs/hooks/useKeyListener/useKeyListener.js +2 -0
  90. package/build/cjs/hooks/useKeyListener/useKeyListener.js.map +1 -0
  91. package/build/cjs/hooks/useListNavigation/index.js +2 -0
  92. package/build/cjs/hooks/useListNavigation/index.js.map +1 -0
  93. package/build/cjs/hooks/useListNavigation/useListNavigation.js +2 -0
  94. package/build/cjs/hooks/useListNavigation/useListNavigation.js.map +1 -0
  95. package/build/cjs/hooks/useLocalStorage/index.js +2 -0
  96. package/build/cjs/hooks/useLocalStorage/index.js.map +1 -0
  97. package/build/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -0
  98. package/build/cjs/hooks/useLocalStorage/useLocalStorage.js.map +1 -0
  99. package/build/cjs/hooks/useMutationObserver/index.js +2 -0
  100. package/build/cjs/hooks/useMutationObserver/index.js.map +1 -0
  101. package/build/cjs/hooks/useMutationObserver/useMutationObserver.js +2 -0
  102. package/build/cjs/hooks/useMutationObserver/useMutationObserver.js.map +1 -0
  103. package/build/cjs/hooks/usePreviousValue/index.js +2 -0
  104. package/build/cjs/hooks/usePreviousValue/index.js.map +1 -0
  105. package/build/cjs/hooks/usePreviousValue/usePreviousValue.js +2 -0
  106. package/build/cjs/hooks/usePreviousValue/usePreviousValue.js.map +1 -0
  107. package/build/cjs/hooks/useProgressiveImg/index.js +2 -0
  108. package/build/cjs/hooks/useProgressiveImg/index.js.map +1 -0
  109. package/build/cjs/hooks/useProgressiveImg/useProgressiveImg.js +2 -0
  110. package/build/cjs/hooks/useProgressiveImg/useProgressiveImg.js.map +1 -0
  111. package/build/cjs/hooks/useScreen/index.js +2 -0
  112. package/build/cjs/hooks/useScreen/index.js.map +1 -0
  113. package/build/cjs/hooks/useScreen/state.js +2 -0
  114. package/build/cjs/hooks/useScreen/state.js.map +1 -0
  115. package/build/cjs/hooks/useScreen/useScreen.js +2 -0
  116. package/build/cjs/hooks/useScreen/useScreen.js.map +1 -0
  117. package/build/cjs/hooks/useScrollIntoView/index.js +2 -0
  118. package/build/cjs/hooks/useScrollIntoView/index.js.map +1 -0
  119. package/build/cjs/hooks/useScrollIntoView/useScrollIntoView.js +2 -0
  120. package/build/cjs/hooks/useScrollIntoView/useScrollIntoView.js.map +1 -0
  121. package/build/cjs/hooks/useSwipeGesture/index.js +2 -0
  122. package/build/cjs/hooks/useSwipeGesture/index.js.map +1 -0
  123. package/build/cjs/hooks/useSwipeGesture/useSwipeGesture.js +2 -0
  124. package/build/cjs/hooks/useSwipeGesture/useSwipeGesture.js.map +1 -0
  125. package/build/clsx-BeLtu-UY.js +2 -0
  126. package/build/clsx-BeLtu-UY.js.map +1 -0
  127. package/build/clsx-E3yX_9sL.cjs +2 -0
  128. package/build/clsx-E3yX_9sL.cjs.map +1 -0
  129. package/build/components/ScreenReaderOnly.d.ts +6 -0
  130. package/build/components/SlotComponent.d.ts +7 -0
  131. package/build/components/index.d.ts +2 -0
  132. package/build/components/navigation/Link.d.ts +5 -0
  133. package/build/components/navigation/NavLink.d.ts +6 -0
  134. package/build/components/navigation/index.d.ts +2 -0
  135. package/build/core/as-child.d.ts +39 -0
  136. package/build/core/index.d.ts +7 -0
  137. package/build/core/polymorphism.d.ts +11 -0
  138. package/build/core/tokens.d.ts +351 -0
  139. package/build/core/types.d.ts +42 -0
  140. package/build/core/utils/breakpoints.d.ts +6 -0
  141. package/build/core/utils/density.d.ts +1 -0
  142. package/build/core/utils/getValuePair.d.ts +2 -0
  143. package/build/core/utils/index.d.ts +8 -0
  144. package/build/core/utils/mergeProps.d.ts +3 -0
  145. package/build/core/utils/mergeRefs.d.ts +3 -0
  146. package/build/core/utils/motion.d.ts +16 -0
  147. package/build/core/utils/tabListener.d.ts +1 -0
  148. package/build/es/components/ScreenReaderOnly.js +2 -0
  149. package/build/es/components/ScreenReaderOnly.js.map +1 -0
  150. package/build/es/components/SlotComponent.js +2 -0
  151. package/build/es/components/SlotComponent.js.map +1 -0
  152. package/build/es/components/index.js +2 -0
  153. package/build/es/components/index.js.map +1 -0
  154. package/build/es/components/navigation/Link.js +2 -0
  155. package/build/es/components/navigation/Link.js.map +1 -0
  156. package/build/es/components/navigation/NavLink.js +2 -0
  157. package/build/es/components/navigation/NavLink.js.map +1 -0
  158. package/build/es/components/navigation/index.js +2 -0
  159. package/build/es/components/navigation/index.js.map +1 -0
  160. package/build/es/core/as-child.js +2 -0
  161. package/build/es/core/as-child.js.map +1 -0
  162. package/build/es/core/index.js +2 -0
  163. package/build/es/core/index.js.map +1 -0
  164. package/build/es/core/polymorphism.js +2 -0
  165. package/build/es/core/polymorphism.js.map +1 -0
  166. package/build/es/core/tokens.js +2 -0
  167. package/build/es/core/tokens.js.map +1 -0
  168. package/build/es/core/types.js +2 -0
  169. package/build/es/core/types.js.map +1 -0
  170. package/build/es/core/utils/breakpoints.js +2 -0
  171. package/build/es/core/utils/breakpoints.js.map +1 -0
  172. package/build/es/core/utils/density.js +2 -0
  173. package/build/es/core/utils/density.js.map +1 -0
  174. package/build/es/core/utils/getValuePair.js +2 -0
  175. package/build/es/core/utils/getValuePair.js.map +1 -0
  176. package/build/es/core/utils/index.js +2 -0
  177. package/build/es/core/utils/index.js.map +1 -0
  178. package/build/es/core/utils/mergeProps.js +2 -0
  179. package/build/es/core/utils/mergeProps.js.map +1 -0
  180. package/build/es/core/utils/mergeRefs.js +2 -0
  181. package/build/es/core/utils/mergeRefs.js.map +1 -0
  182. package/build/es/core/utils/motion.js +2 -0
  183. package/build/es/core/utils/motion.js.map +1 -0
  184. package/build/es/core/utils/tabListener.js +2 -0
  185. package/build/es/core/utils/tabListener.js.map +1 -0
  186. package/build/es/hooks/index.js +2 -0
  187. package/build/es/hooks/index.js.map +1 -0
  188. package/build/es/hooks/mediaQueryUtils.js +2 -0
  189. package/build/es/hooks/mediaQueryUtils.js.map +1 -0
  190. package/build/es/hooks/useAnimatedDetails/index.js +2 -0
  191. package/build/es/hooks/useAnimatedDetails/index.js.map +1 -0
  192. package/build/es/hooks/useAnimatedDetails/useAnimatedDetails.js +2 -0
  193. package/build/es/hooks/useAnimatedDetails/useAnimatedDetails.js.map +1 -0
  194. package/build/es/hooks/useAnimatedHeight/index.js +2 -0
  195. package/build/es/hooks/useAnimatedHeight/index.js.map +1 -0
  196. package/build/es/hooks/useAnimatedHeight/types.js +2 -0
  197. package/build/es/hooks/useAnimatedHeight/types.js.map +1 -0
  198. package/build/es/hooks/useAnimatedHeight/useAnimatedHeight.js +2 -0
  199. package/build/es/hooks/useAnimatedHeight/useAnimatedHeight.js.map +1 -0
  200. package/build/es/hooks/useAnimatedHeight/useAnimatedHeightBetween.js +2 -0
  201. package/build/es/hooks/useAnimatedHeight/useAnimatedHeightBetween.js.map +1 -0
  202. package/build/es/hooks/useAnimatedHeight/useAutoAnimateHeight.js +2 -0
  203. package/build/es/hooks/useAnimatedHeight/useAutoAnimateHeight.js.map +1 -0
  204. package/build/es/hooks/useAriaLiveRegion/index.js +2 -0
  205. package/build/es/hooks/useAriaLiveRegion/index.js.map +1 -0
  206. package/build/es/hooks/useAriaLiveRegion/useAriaLiveRegion.js +2 -0
  207. package/build/es/hooks/useAriaLiveRegion/useAriaLiveRegion.js.map +1 -0
  208. package/build/es/hooks/useBrowserPreferences/index.js +2 -0
  209. package/build/es/hooks/useBrowserPreferences/index.js.map +1 -0
  210. package/build/es/hooks/useBrowserPreferences/useBrowserPreferences.js +2 -0
  211. package/build/es/hooks/useBrowserPreferences/useBrowserPreferences.js.map +1 -0
  212. package/build/es/hooks/useClickOutside/index.js +2 -0
  213. package/build/es/hooks/useClickOutside/index.js.map +1 -0
  214. package/build/es/hooks/useClickOutside/useClickOutside.js +2 -0
  215. package/build/es/hooks/useClickOutside/useClickOutside.js.map +1 -0
  216. package/build/es/hooks/useElementDimensions/index.js +2 -0
  217. package/build/es/hooks/useElementDimensions/index.js.map +1 -0
  218. package/build/es/hooks/useElementDimensions/useElementDimensions.js +2 -0
  219. package/build/es/hooks/useElementDimensions/useElementDimensions.js.map +1 -0
  220. package/build/es/hooks/useFocusOutside/index.js +2 -0
  221. package/build/es/hooks/useFocusOutside/index.js.map +1 -0
  222. package/build/es/hooks/useFocusOutside/useFocusOutside.js +2 -0
  223. package/build/es/hooks/useFocusOutside/useFocusOutside.js.map +1 -0
  224. package/build/es/hooks/useId/index.js +2 -0
  225. package/build/es/hooks/useId/index.js.map +1 -0
  226. package/build/es/hooks/useId/useId.js +2 -0
  227. package/build/es/hooks/useId/useId.js.map +1 -0
  228. package/build/es/hooks/useIntersectionObserver/index.js +2 -0
  229. package/build/es/hooks/useIntersectionObserver/index.js.map +1 -0
  230. package/build/es/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -0
  231. package/build/es/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -0
  232. package/build/es/hooks/useKeyListener/index.js +2 -0
  233. package/build/es/hooks/useKeyListener/index.js.map +1 -0
  234. package/build/es/hooks/useKeyListener/useKeyListener.js +2 -0
  235. package/build/es/hooks/useKeyListener/useKeyListener.js.map +1 -0
  236. package/build/es/hooks/useListNavigation/index.js +2 -0
  237. package/build/es/hooks/useListNavigation/index.js.map +1 -0
  238. package/build/es/hooks/useListNavigation/useListNavigation.js +2 -0
  239. package/build/es/hooks/useListNavigation/useListNavigation.js.map +1 -0
  240. package/build/es/hooks/useLocalStorage/index.js +2 -0
  241. package/build/es/hooks/useLocalStorage/index.js.map +1 -0
  242. package/build/es/hooks/useLocalStorage/useLocalStorage.js +2 -0
  243. package/build/es/hooks/useLocalStorage/useLocalStorage.js.map +1 -0
  244. package/build/es/hooks/useMutationObserver/index.js +2 -0
  245. package/build/es/hooks/useMutationObserver/index.js.map +1 -0
  246. package/build/es/hooks/useMutationObserver/useMutationObserver.js +2 -0
  247. package/build/es/hooks/useMutationObserver/useMutationObserver.js.map +1 -0
  248. package/build/es/hooks/usePreviousValue/index.js +2 -0
  249. package/build/es/hooks/usePreviousValue/index.js.map +1 -0
  250. package/build/es/hooks/usePreviousValue/usePreviousValue.js +2 -0
  251. package/build/es/hooks/usePreviousValue/usePreviousValue.js.map +1 -0
  252. package/build/es/hooks/useProgressiveImg/index.js +2 -0
  253. package/build/es/hooks/useProgressiveImg/index.js.map +1 -0
  254. package/build/es/hooks/useProgressiveImg/useProgressiveImg.js +2 -0
  255. package/build/es/hooks/useProgressiveImg/useProgressiveImg.js.map +1 -0
  256. package/build/es/hooks/useScreen/index.js +2 -0
  257. package/build/es/hooks/useScreen/index.js.map +1 -0
  258. package/build/es/hooks/useScreen/state.js +2 -0
  259. package/build/es/hooks/useScreen/state.js.map +1 -0
  260. package/build/es/hooks/useScreen/useScreen.js +2 -0
  261. package/build/es/hooks/useScreen/useScreen.js.map +1 -0
  262. package/build/es/hooks/useScrollIntoView/index.js +2 -0
  263. package/build/es/hooks/useScrollIntoView/index.js.map +1 -0
  264. package/build/es/hooks/useScrollIntoView/useScrollIntoView.js +2 -0
  265. package/build/es/hooks/useScrollIntoView/useScrollIntoView.js.map +1 -0
  266. package/build/es/hooks/useSwipeGesture/index.js +2 -0
  267. package/build/es/hooks/useSwipeGesture/index.js.map +1 -0
  268. package/build/es/hooks/useSwipeGesture/useSwipeGesture.js +2 -0
  269. package/build/es/hooks/useSwipeGesture/useSwipeGesture.js.map +1 -0
  270. package/build/hooks/index.d.ts +18 -0
  271. package/build/hooks/mediaQueryUtils.d.ts +21 -0
  272. package/build/hooks/useAnimatedDetails/index.d.ts +1 -0
  273. package/build/hooks/useAnimatedDetails/useAnimatedDetails.d.ts +20 -0
  274. package/build/hooks/useAnimatedHeight/index.d.ts +4 -0
  275. package/build/hooks/useAnimatedHeight/types.d.ts +26 -0
  276. package/build/hooks/useAnimatedHeight/useAnimatedHeight.d.ts +10 -0
  277. package/build/hooks/useAnimatedHeight/useAnimatedHeightBetween.d.ts +10 -0
  278. package/build/hooks/useAnimatedHeight/useAutoAnimateHeight.d.ts +20 -0
  279. package/build/hooks/useAriaLiveRegion/index.d.ts +1 -0
  280. package/build/hooks/useAriaLiveRegion/useAriaLiveRegion.d.ts +15 -0
  281. package/build/hooks/useBrowserPreferences/index.d.ts +1 -0
  282. package/build/hooks/useBrowserPreferences/useBrowserPreferences.d.ts +12 -0
  283. package/build/hooks/useClickOutside/index.d.ts +1 -0
  284. package/build/hooks/useClickOutside/useClickOutside.d.ts +7 -0
  285. package/build/hooks/useElementDimensions/index.d.ts +1 -0
  286. package/build/hooks/useElementDimensions/useElementDimensions.d.ts +11 -0
  287. package/build/hooks/useFocusOutside/index.d.ts +1 -0
  288. package/build/hooks/useFocusOutside/useFocusOutside.d.ts +7 -0
  289. package/build/hooks/useId/index.d.ts +1 -0
  290. package/build/hooks/useId/useId.d.ts +11 -0
  291. package/build/hooks/useIntersectionObserver/index.d.ts +1 -0
  292. package/build/hooks/useIntersectionObserver/useIntersectionObserver.d.ts +13 -0
  293. package/build/hooks/useKeyListener/index.d.ts +1 -0
  294. package/build/hooks/useKeyListener/useKeyListener.d.ts +8 -0
  295. package/build/hooks/useListNavigation/index.d.ts +1 -0
  296. package/build/hooks/useListNavigation/useListNavigation.d.ts +7 -0
  297. package/build/hooks/useLocalStorage/index.d.ts +1 -0
  298. package/build/hooks/useLocalStorage/useLocalStorage.d.ts +1 -0
  299. package/build/hooks/useMutationObserver/index.d.ts +1 -0
  300. package/build/hooks/useMutationObserver/useMutationObserver.d.ts +9 -0
  301. package/build/hooks/usePreviousValue/index.d.ts +1 -0
  302. package/build/hooks/usePreviousValue/usePreviousValue.d.ts +6 -0
  303. package/build/hooks/useProgressiveImg/index.d.ts +1 -0
  304. package/build/hooks/useProgressiveImg/useProgressiveImg.d.ts +10 -0
  305. package/build/hooks/useScreen/index.d.ts +2 -0
  306. package/build/hooks/useScreen/state.d.ts +17 -0
  307. package/build/hooks/useScreen/useScreen.d.ts +6 -0
  308. package/build/hooks/useScrollIntoView/index.d.ts +1 -0
  309. package/build/hooks/useScrollIntoView/useScrollIntoView.d.ts +11 -0
  310. package/build/hooks/useSwipeGesture/index.d.ts +1 -0
  311. package/build/hooks/useSwipeGesture/useSwipeGesture.d.ts +27 -0
  312. package/package.json +83 -0
  313. package/src/components/navigation/styles/link.css +152 -0
  314. package/src/components/navigation/styles/link.min.css +1 -0
  315. package/src/components/navigation/styles/link.scss +138 -0
  316. package/src/core/jkl/_colors.scss +26 -0
  317. package/src/core/jkl/_convert.scss +96 -0
  318. package/src/core/jkl/_helpers.scss +20 -0
  319. package/src/core/jkl/_index.scss +18 -0
  320. package/src/core/jkl/_legacy-tokens.scss +22 -0
  321. package/src/core/jkl/_motion.scss +62 -0
  322. package/src/core/jkl/_navigation.scss +9 -0
  323. package/src/core/jkl/_ornaments.scss +26 -0
  324. package/src/core/jkl/_reset.scss +43 -0
  325. package/src/core/jkl/_responsive-units.scss +30 -0
  326. package/src/core/jkl/_screenreader.scss +59 -0
  327. package/src/core/jkl/_screens.scss +135 -0
  328. package/src/core/jkl/_shadows.scss +25 -0
  329. package/src/core/jkl/_spacing.scss +210 -0
  330. package/src/core/jkl/_theme.scss +144 -0
  331. package/src/core/jkl/_tokens.scss +148 -0
  332. package/src/core/jkl/_typography.scss +327 -0
  333. package/src/core/jkl/_underline.scss +16 -0
  334. package/src/core/jkl/_z-index.scss +23 -0
  335. package/src/core/styles/_color-tokens.scss +75 -0
  336. package/src/core/styles/_headings.scss +29 -0
  337. package/src/core/styles/_index.scss +10 -0
  338. package/src/core/styles/_legacy-tokens.scss +26 -0
  339. package/src/core/styles/_normalize.scss +250 -0
  340. package/src/core/styles/_paragraphs.scss +16 -0
  341. package/src/core/styles/_reset.scss +66 -0
  342. package/src/core/styles/_screen-reader.scss +9 -0
  343. package/src/core/styles/_spacing.scss +75 -0
  344. package/src/core/styles/_tokens.scss +114 -0
  345. package/src/core/styles/core.css +1614 -0
  346. package/src/core/styles/core.min.css +1 -0
  347. package/src/core/styles/core.scss +71 -0
  348. package/src/core/styles/vind/_flex.scss +113 -0
  349. package/src/core/styles/vind/_font.scss +19 -0
  350. package/src/core/styles/vind/_margin.scss +43 -0
  351. package/src/core/styles/vind/_padding.scss +43 -0
  352. package/src/core/styles/vind/_space-between.scss +13 -0
  353. package/src/core/styles/vind/_typography.scss +47 -0
  354. package/src/core/styles/vind/_vind.scss +6 -0
  355. package/src/core/styles/vind.css +1742 -0
  356. package/src/core/styles/vind.min.css +1 -0
  357. package/src/core/styles/vind.scss +3 -0
  358. package/src/core/tokens.less +196 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion.js","sources":["../../../../src/core/utils/motion.ts"],"sourcesContent":["export type Easing = keyof typeof easings;\n\nexport const easings = Object.freeze({\n standard: \"ease\",\n entrance: \"ease-out\",\n exit: \"ease-in\",\n easeInBounceOut: \"cubic-bezier(0, 0, 0.375, 1.17)\",\n focus: \"cubic-bezier(0.6, 0.2, 0.35, 1)\",\n});\n\nexport type Timing = keyof typeof timings;\n\nexport const timings = Object.freeze({\n energetic: \"75ms\",\n snappy: \"100ms\",\n productive: \"150ms\",\n expressive: \"250ms\",\n lazy: \"400ms\",\n});\n"],"names":["easings","Object","freeze","standard","entrance","exit","easeInBounceOut","focus","timings","energetic","snappy","productive","expressive","lazy"],"mappings":"AAEa,MAAAA,EAAUC,OAAOC,OAAO,CACjCC,SAAU,OACVC,SAAU,WACVC,KAAM,UACNC,gBAAiB,kCACjBC,MAAO,oCAKEC,EAAUP,OAAOC,OAAO,CACjCO,UAAW,OACXC,OAAQ,QACRC,WAAY,QACZC,WAAY,QACZC,KAAM"}
@@ -0,0 +1,2 @@
1
+ let t=!1,e=!1,o=!1;const n={mousedown:function(){if(!t&&!o){t=!0,e=!1;const o=document.querySelector("html");null==o||o.setAttribute("data-mousenavigation","true"),null==o||o.removeAttribute("data-touchnavigation"),u(),a("touchstart"),a("keydown")}},keydown:function(o){if("Tab"===o.key){const o=document.querySelector("html");u(),null==o||o.removeAttribute("data-mousenavigation"),null==o||o.removeAttribute("data-touchnavigation"),t=!1,e=!1,a("touchstart"),a("mousedown")}},touchstart:function(){if(!e){t=!1,e=!0;const o=document.querySelector("html");null==o||o.setAttribute("data-touchnavigation","true"),null==o||o.removeAttribute("data-mousenavigation"),u(),a("touchstart"),a("keydown"),a("mousedown")}o=!0,setTimeout((()=>{o=!1}),150)}};function u(){Object.keys(n).forEach((t=>{document.removeEventListener(t,n[t])}))}function a(t){document.addEventListener(t,n[t])}function i(){typeof document<"u"&&(a("touchstart"),a("mousedown"))}export{i as initTabListener};
2
+ //# sourceMappingURL=tabListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabListener.js","sources":["../../../../src/core/utils/tabListener.ts"],"sourcesContent":["let mousenavigation = false;\nlet touchnavigation = false;\nlet touchEventFired = false;\n\nconst listeners = {\n mousedown: handleMouseDown as EventListener,\n keydown: handleKeydown as EventListener,\n touchstart: handleTouchStart as EventListener,\n};\n\nfunction removeAllListeners() {\n (Object.keys(listeners) as Array<keyof typeof listeners>).forEach((listenerType) => {\n document.removeEventListener(listenerType, listeners[listenerType]);\n });\n}\n\nfunction addListener(listenerType: keyof typeof listeners) {\n document.addEventListener(listenerType, listeners[listenerType]);\n}\n\nfunction handleMouseDown() {\n if (!mousenavigation && !touchEventFired) {\n mousenavigation = true;\n touchnavigation = false;\n const htmlElement = document.querySelector(\"html\");\n htmlElement?.setAttribute(\"data-mousenavigation\", \"true\");\n htmlElement?.removeAttribute(\"data-touchnavigation\");\n\n // Reset listeners\n removeAllListeners();\n addListener(\"touchstart\");\n addListener(\"keydown\");\n }\n}\n\nfunction handleKeydown(event: KeyboardEvent) {\n if (event.key === \"Tab\") {\n const htmlElement = document.querySelector(\"html\");\n removeAllListeners();\n htmlElement?.removeAttribute(\"data-mousenavigation\");\n htmlElement?.removeAttribute(\"data-touchnavigation\");\n mousenavigation = false;\n touchnavigation = false;\n\n // Reset listeners\n addListener(\"touchstart\");\n addListener(\"mousedown\");\n }\n}\n\nfunction handleTouchStart() {\n if (!touchnavigation) {\n mousenavigation = false;\n touchnavigation = true;\n const htmlElement = document.querySelector(\"html\");\n htmlElement?.setAttribute(\"data-touchnavigation\", \"true\");\n htmlElement?.removeAttribute(\"data-mousenavigation\");\n\n // Reset listeners\n removeAllListeners();\n addListener(\"touchstart\");\n addListener(\"keydown\");\n addListener(\"mousedown\");\n }\n\n // Most touch devices fire both touch and mouse events on touch (in that order)\n // see https://w3c.github.io/touch-events/#mouse-events\n // Set a check variable to avoid resetting the data-attribute:\n touchEventFired = true;\n setTimeout(() => {\n touchEventFired = false;\n }, 150); // Yes, it can take this long between the events\n}\n\nexport function initTabListener(): void {\n if (typeof document !== \"undefined\") {\n addListener(\"touchstart\");\n addListener(\"mousedown\");\n }\n}\n"],"names":["mousenavigation","touchnavigation","touchEventFired","listeners","mousedown","htmlElement","document","querySelector","setAttribute","removeAttribute","removeAllListeners","addListener","keydown","event","key","touchstart","setTimeout","Object","keys","forEach","listenerType","removeEventListener","addEventListener","initTabListener"],"mappings":"AAAA,IAAIA,GAAkB,EAClBC,GAAkB,EAClBC,GAAkB,EAEtB,MAAMC,EAAY,CACdC,UAeJ,WACQ,IAACJ,IAAoBE,EAAiB,CACpBF,GAAA,EACAC,GAAA,EACZI,MAAAA,EAAcC,SAASC,cAAc,QAC9B,MAAAF,GAAAA,EAAAG,aAAa,uBAAwB,QAClD,MAAAH,GAAAA,EAAaI,gBAAgB,wBAGVC,IACnBC,EAAY,cACZA,EAAY,UAChB,CACJ,EA3BIC,QA6BJ,SAAuBC,GACfA,GAAc,QAAdA,EAAMC,IAAe,CACfT,MAAAA,EAAcC,SAASC,cAAc,QACxBG,IACnB,MAAAL,GAAAA,EAAaI,gBAAgB,wBAC7B,MAAAJ,GAAAA,EAAaI,gBAAgB,wBACXT,GAAA,EACAC,GAAA,EAGlBU,EAAY,cACZA,EAAY,YAChB,CACJ,EAzCII,WA2CJ,WACI,IAAKd,EAAiB,CACAD,GAAA,EACAC,GAAA,EACZI,MAAAA,EAAcC,SAASC,cAAc,QAC9B,MAAAF,GAAAA,EAAAG,aAAa,uBAAwB,QAClD,MAAAH,GAAAA,EAAaI,gBAAgB,wBAGVC,IACnBC,EAAY,cACZA,EAAY,WACZA,EAAY,YAChB,CAKkBT,GAAA,EAClBc,YAAW,KACWd,GAAA,CAAA,GACnB,IACP,GA9DA,SAASQ,IACJO,OAAOC,KAAKf,GAA6CgB,SAASC,IAC/Dd,SAASe,oBAAoBD,EAAcjB,EAAUiB,GAAa,GAE1E,CAEA,SAAST,EAAYS,GACjBd,SAASgB,iBAAiBF,EAAcjB,EAAUiB,GACtD,CAwDO,SAASG,WACDjB,SAAa,MACpBK,EAAY,cACZA,EAAY,aAEpB"}
@@ -0,0 +1,2 @@
1
+ import{useAnimatedDetails as e}from"./useAnimatedDetails/useAnimatedDetails.js";import{useAnimatedHeight as s}from"./useAnimatedHeight/useAnimatedHeight.js";import{useAnimatedHeightBetween as i}from"./useAnimatedHeight/useAnimatedHeightBetween.js";import{useAutoAnimatedHeight as r}from"./useAnimatedHeight/useAutoAnimateHeight.js";import{useBrowserPreferences as t}from"./useBrowserPreferences/useBrowserPreferences.js";import{useIntersectionObserver as u}from"./useIntersectionObserver/useIntersectionObserver.js";import{useLocalStorage as o}from"./useLocalStorage/useLocalStorage.js";import{useMutationObserver as a}from"./useMutationObserver/useMutationObserver.js";import{usePreviousValue as m}from"./usePreviousValue/usePreviousValue.js";import{useProgressiveImg as n}from"./useProgressiveImg/useProgressiveImg.js";import{useScreen as g}from"./useScreen/useScreen.js";import{useScrollIntoView as c}from"./useScrollIntoView/useScrollIntoView.js";import{useAriaLiveRegion as l}from"./useAriaLiveRegion/useAriaLiveRegion.js";import{useClickOutside as d}from"./useClickOutside/useClickOutside.js";import{useFocusOutside as p}from"./useFocusOutside/useFocusOutside.js";import{useElementDimensions as f}from"./useElementDimensions/useElementDimensions.js";import{useId as v}from"./useId/useId.js";import{useKeyListener as A}from"./useKeyListener/useKeyListener.js";import{useListNavigation as j}from"./useListNavigation/useListNavigation.js";import{useSwipeGesture as I}from"./useSwipeGesture/useSwipeGesture.js";export{e as useAnimatedDetails,s as useAnimatedHeight,i as useAnimatedHeightBetween,l as useAriaLiveRegion,r as useAutoAnimatedHeight,t as useBrowserPreferences,d as useClickOutside,f as useElementDimensions,p as useFocusOutside,v as useId,u as useIntersectionObserver,A as useKeyListener,j as useListNavigation,o as useLocalStorage,a as useMutationObserver,m as usePreviousValue,n as useProgressiveImg,g as useScreen,c as useScrollIntoView,I as useSwipeGesture};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ function e(e){return!!window.matchMedia&&window.matchMedia(e).matches}function t(e,t){typeof e.addEventListener<"u"?e.addEventListener("change",t):e.addListener(t)}function n(e,t){typeof e.removeEventListener<"u"?e.removeEventListener("change",t):e.removeListener(t)}export{t as addMediaQueryListener,e as getInitialMediaQueryMatch,n as removeMediaQueryListener};
2
+ //# sourceMappingURL=mediaQueryUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediaQueryUtils.js","sources":["../../../src/hooks/mediaQueryUtils.ts"],"sourcesContent":["/**\n * Sjekker om et CSS Media Query matcher nettleserens egenskaper\n *\n * @param mediaQuery CSS Media Query som skal sjekkes. F.eks. `(orientation: portrait)`\n * @returns om det er match på queryen\n */\nexport function getInitialMediaQueryMatch(mediaQuery: string): boolean {\n if (!window.matchMedia) {\n // Enhetstester\n return false;\n }\n return window.matchMedia(mediaQuery).matches;\n}\n/**\n * Lytt på endringer i match mot et CSS Media Query\n *\n * @param queryList en MediaQueryList initiert med `window.matchMedia(<CSS Media Query>)`\n * @param callback funksjon som kalles når match for `queryList` endres\n */\nexport function addMediaQueryListener(queryList: MediaQueryList, callback: (e: MediaQueryListEvent) => void) {\n if (typeof queryList.addEventListener !== \"undefined\") {\n queryList.addEventListener(\"change\", callback);\n } else {\n queryList.addListener(callback);\n }\n}\n\n/**\n * Fjern en lytter fra en MediaQueryList\n *\n * @param queryList en MediaQueryList initiert med `window.matchMedia(<CSS Media Query>)`\n * @param callback lytter som skal fjernes\n */\nexport function removeMediaQueryListener(queryList: MediaQueryList, callback: (e: MediaQueryListEvent) => void) {\n if (typeof queryList.removeEventListener !== \"undefined\") {\n queryList.removeEventListener(\"change\", callback);\n } else {\n queryList.removeListener(callback);\n }\n}\n"],"names":["getInitialMediaQueryMatch","mediaQuery","window","matchMedia","matches","addMediaQueryListener","queryList","callback","addEventListener","addListener","removeMediaQueryListener","removeEventListener","removeListener"],"mappings":"AAMO,SAASA,EAA0BC,GAClC,QAACC,OAAOC,YAILD,OAAOC,WAAWF,GAAYG,OACzC,CAOgB,SAAAC,EAAsBC,EAA2BC,UAClDD,EAAUE,iBAAqB,IAC5BF,EAAAE,iBAAiB,SAAUD,GAErCD,EAAUG,YAAYF,EAE9B,CAQgB,SAAAG,EAAyBJ,EAA2BC,UACrDD,EAAUK,oBAAwB,IAC/BL,EAAAK,oBAAoB,SAAUJ,GAExCD,EAAUM,eAAeL,EAEjC"}
@@ -0,0 +1,2 @@
1
+ import{useAnimatedDetails as e}from"./useAnimatedDetails.js";export{e as useAnimatedDetails};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useRef as e,useState as r,useEffect as t}from"react";const n=({onOpenChange:n,isExpanded:c})=>{const u=e(null),a=e(null),s=e(null),i=e(null),[o,f]=r(!1),[l,h]=r(!1);t((()=>{p(c)}),[c]);const p=e=>{u.current&&a.current&&(u.current.open=e,i.current=null,f(!1),h(!1),u.current.style.overflow="",u.current.style.height="")};return{detailsRef:u,summaryRef:a,contentRef:s,onSummaryClick:e=>{e.preventDefault(),u.current&&a.current&&(u.current.style.overflow="hidden",o||!u.current.open?(e=>{u.current&&a.current&&(u.current.style.height=`${u.current.offsetHeight}px`,u.current.open=!0,requestAnimationFrame((()=>{if(u.current&&a.current&&s.current){h(!0),n(!0,e);const r=u.current.offsetHeight,t=a.current.offsetHeight+s.current.offsetHeight;i.current&&i.current.cancel(),u.current.animate&&(i.current=u.current.animate({height:[`${r}px`,`${t}px`]},{duration:150,easing:"ease"}),i.current.onfinish=()=>p(!0),i.current.oncancel=()=>h(!1))}})))})(e):(l||u.current.open)&&(e=>{if(u.current&&a.current){f(!0),n(!1,e);const r=u.current.offsetHeight,t=a.current.offsetHeight;i.current&&i.current.cancel(),u.current.animate&&(i.current=u.current.animate({height:[`${r}px`,`${t}px`]},{duration:150,easing:"ease"}),i.current.onfinish=()=>p(!1),i.current.oncancel=()=>f(!1))}})(e))}}};export{n as useAnimatedDetails};
2
+ //# sourceMappingURL=useAnimatedDetails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimatedDetails.js","sources":["../../../../src/hooks/useAnimatedDetails/useAnimatedDetails.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\n\n/**\n * Lar deg animere et HTML details element med en summary trigger og noe innhold.\n * HTML strukturen din bør se ut som omtrent\n * <details ref={detailsRef}>\n * <summary ref={summaryRef} onClick={onSummaryClick}>Trigger for å åpne</summary>\n * <div ref={contentRef}>Ekspanderbart innhold</div>\n * </details>\n *\n * @param onOpenChange Callback med informasjon om når elementet åpner/lukker seg.\n * @param isExpanded Styr åpning/lukking utenfra.\n */\nexport const useAnimatedDetails = ({\n onOpenChange,\n isExpanded,\n}: {\n onOpenChange: (open: boolean, e: React.MouseEvent<HTMLElement>) => void;\n isExpanded: boolean;\n}): {\n detailsRef: React.RefObject<HTMLDetailsElement>;\n summaryRef: React.RefObject<HTMLButtonElement>;\n contentRef: React.RefObject<HTMLDivElement>;\n onSummaryClick: React.MouseEventHandler<HTMLElement>;\n} => {\n const detailsRef = useRef<HTMLDetailsElement>(null);\n const summaryRef = useRef<HTMLButtonElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const animation = useRef<Animation | null>(null);\n\n const [isClosing, setIsClosing] = useState(false);\n const [isExpanding, setIsExpanding] = useState(false);\n\n useEffect(() => {\n onAnimationFinish(isExpanded);\n }, [isExpanded]);\n\n const onAnimationFinish = (open: boolean) => {\n if (detailsRef.current && summaryRef.current) {\n detailsRef.current.open = open;\n animation.current = null;\n setIsClosing(false);\n setIsExpanding(false);\n detailsRef.current.style.overflow = \"\";\n detailsRef.current.style.height = \"\";\n }\n };\n\n const open = (e: React.MouseEvent<HTMLElement>) => {\n if (detailsRef.current && summaryRef.current) {\n detailsRef.current.style.height = `${detailsRef.current.offsetHeight}px`;\n detailsRef.current.open = true;\n requestAnimationFrame(() => {\n if (detailsRef.current && summaryRef.current && contentRef.current) {\n setIsExpanding(true);\n onOpenChange(true, e);\n const startHeight = detailsRef.current.offsetHeight;\n const endHeight = summaryRef.current.offsetHeight + contentRef.current.offsetHeight;\n\n if (animation.current) {\n animation.current.cancel();\n }\n\n if (detailsRef.current.animate) {\n animation.current = detailsRef.current.animate(\n {\n height: [`${startHeight}px`, `${endHeight}px`],\n },\n {\n duration: 150,\n easing: \"ease\",\n },\n );\n animation.current.onfinish = () => onAnimationFinish(true);\n animation.current.oncancel = () => setIsExpanding(false);\n }\n }\n });\n }\n };\n\n const close = (e: React.MouseEvent<HTMLElement>) => {\n if (detailsRef.current && summaryRef.current) {\n setIsClosing(true);\n onOpenChange(false, e);\n const startHeight = detailsRef.current.offsetHeight;\n const endHeight = summaryRef.current.offsetHeight;\n if (animation.current) {\n animation.current.cancel();\n }\n\n if (detailsRef.current.animate) {\n animation.current = detailsRef.current.animate(\n {\n height: [`${startHeight}px`, `${endHeight}px`],\n },\n {\n duration: 150,\n easing: \"ease\",\n },\n );\n animation.current.onfinish = () => onAnimationFinish(false);\n animation.current.oncancel = () => setIsClosing(false);\n }\n }\n };\n\n const onSummaryClick = (e: React.MouseEvent<HTMLElement>) => {\n e.preventDefault();\n if (detailsRef.current && summaryRef.current) {\n detailsRef.current.style.overflow = \"hidden\";\n if (isClosing || !detailsRef.current.open) {\n open(e);\n } else if (isExpanding || detailsRef.current.open) {\n close(e);\n }\n }\n };\n\n return { detailsRef, summaryRef, contentRef, onSummaryClick };\n};\n"],"names":["useAnimatedDetails","onOpenChange","isExpanded","detailsRef","useRef","summaryRef","contentRef","animation","isClosing","setIsClosing","useState","isExpanding","setIsExpanding","useEffect","onAnimationFinish","open","current","style","overflow","height","onSummaryClick","e","preventDefault","offsetHeight","requestAnimationFrame","startHeight","endHeight","cancel","animate","duration","easing","onfinish","oncancel","close"],"mappings":"4DAaO,MAAMA,EAAqB,EAC9BC,aAAAA,EACAC,WAAAA,MAUM,MAAAC,EAAaC,EAA2B,MACxCC,EAAaD,EAA0B,MACvCE,EAAaF,EAAuB,MACpCG,EAAYH,EAAyB,OAEpCI,EAAWC,GAAgBC,GAAS,IACpCC,EAAaC,GAAkBF,GAAS,GAE/CG,GAAU,KACNC,EAAkBZ,EAAU,GAC7B,CAACA,IAEEY,MAAAA,EAAqBC,IACnBZ,EAAWa,SAAWX,EAAWW,UACjCb,EAAWa,QAAQD,KAAOA,EAC1BR,EAAUS,QAAU,KACpBP,GAAa,GACbG,GAAe,GACJT,EAAAa,QAAQC,MAAMC,SAAW,GACzBf,EAAAa,QAAQC,MAAME,OAAS,GAAA,EA2EnC,MAAA,CAAEhB,WAAAA,EAAYE,WAAAA,EAAYC,WAAAA,EAAYc,eAZrBC,IACpBA,EAAEC,iBACEnB,EAAWa,SAAWX,EAAWW,UACtBb,EAAAa,QAAQC,MAAMC,SAAW,SAChCV,IAAcL,EAAWa,QAAQD,KA/DhC,CAACM,IACNlB,EAAWa,SAAWX,EAAWW,UACjCb,EAAWa,QAAQC,MAAME,OAAS,GAAGhB,EAAWa,QAAQO,iBACxDpB,EAAWa,QAAQD,MAAO,EAC1BS,uBAAsB,KAClB,GAAIrB,EAAWa,SAAWX,EAAWW,SAAWV,EAAWU,QAAS,CAChEJ,GAAe,GACfX,GAAa,EAAMoB,GACbI,MAAAA,EAActB,EAAWa,QAAQO,aACjCG,EAAYrB,EAAWW,QAAQO,aAAejB,EAAWU,QAAQO,aAEnEhB,EAAUS,SACVT,EAAUS,QAAQW,SAGlBxB,EAAWa,QAAQY,UACTrB,EAAAS,QAAUb,EAAWa,QAAQY,QACnC,CACIT,OAAQ,CAAC,GAAGM,MAAiB,GAAGC,QAEpC,CACIG,SAAU,IACVC,OAAQ,SAGhBvB,EAAUS,QAAQe,SAAW,IAAMjB,GAAkB,GACrDP,EAAUS,QAAQgB,SAAW,IAAMpB,GAAe,GAE1D,KACH,EAmCGG,CAAKM,IACEV,GAAeR,EAAWa,QAAQD,OAhCvC,CAACM,IACPlB,GAAAA,EAAWa,SAAWX,EAAWW,QAAS,CAC1CP,GAAa,GACbR,GAAa,EAAOoB,GACd,MAAAI,EAActB,EAAWa,QAAQO,aACjCG,EAAYrB,EAAWW,QAAQO,aACjChB,EAAUS,SACVT,EAAUS,QAAQW,SAGlBxB,EAAWa,QAAQY,UACTrB,EAAAS,QAAUb,EAAWa,QAAQY,QACnC,CACIT,OAAQ,CAAC,GAAGM,MAAiB,GAAGC,QAEpC,CACIG,SAAU,IACVC,OAAQ,SAGhBvB,EAAUS,QAAQe,SAAW,IAAMjB,GAAkB,GACrDP,EAAUS,QAAQgB,SAAW,IAAMvB,GAAa,GAExD,GAUQwB,CAAMZ,GAAC,EAKyC"}
@@ -0,0 +1,2 @@
1
+ import{useAnimatedHeight as e}from"./useAnimatedHeight.js";import{useAnimatedHeightBetween as t}from"./useAnimatedHeightBetween.js";import{useAutoAnimatedHeight as i}from"./useAutoAnimateHeight.js";export{e as useAnimatedHeight,t as useAnimatedHeightBetween,i as useAutoAnimatedHeight};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useRef as e,useCallback as t,useEffect as r}from"react";import{timings as n,easings as i}from"../../core/utils/motion.js";import{useBrowserPreferences as s}from"../useBrowserPreferences/useBrowserPreferences.js";import{usePreviousValue as l}from"../usePreviousValue/usePreviousValue.js";function o(o,u){const a=l(o),c=(null==u?void 0:u.easing)||"standard",d=(null==u?void 0:u.timing)||"productive",m=(null==u?void 0:u.display)||"block",v=`${n[d]} height ${i[c]}`,{prefersReducedMotion:f}=s(),y=e(),h=e(),g=e(null);function p(e){var t;const r=g.current;r&&e.target===r&&(o?r.removeAttribute("style"):(r.removeAttribute("style"),r.style.display="none"),null==(t=null==u?void 0:u.onTransitionEnd)||t.call(u,o,g))}const A=t((()=>{var e,t,r,n;const i=g.current;if(i&&void 0!==a){if(o){if(o&&a)return}else if(i.style.display="none",!a)return;if(null==(e=null==u?void 0:u.onTransitionStart)||e.call(u,o,g),f)return i.removeAttribute("style"),o&&(null==(t=null==u?void 0:u.onFirstVisible)||t.call(u,o,g)),void(null==(r=null==u?void 0:u.onTransitionEnd)||r.call(u,o,g));if(i.style.transition=v,i.style.display=m,i.style.overflow="hidden",o)null==(n=null==u?void 0:u.onFirstVisible)||n.call(u,o,g),i.style.height="0",i.style.height=`${i.scrollHeight}px`;else{if(0===i.scrollHeight)return void i.removeAttribute("style");i.style.height=`${i.scrollHeight}px`,y.current=requestAnimationFrame((()=>{h.current=requestAnimationFrame((()=>{i.style.height="0px"}))}))}}}),[o,u,a,v,f,m]);return r((()=>{A()}),[o,A]),r((()=>{const e=g.current;return e&&e.addEventListener("transitionend",p),()=>{e&&e.removeEventListener("transitionend",p)}}),[o]),r((()=>{const e=y.current,t=h.current;return()=>{e&&cancelAnimationFrame(e),t&&cancelAnimationFrame(t)}}),[y,h]),[g,A]}export{o as useAnimatedHeight};
2
+ //# sourceMappingURL=useAnimatedHeight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimatedHeight.js","sources":["../../../../src/hooks/useAnimatedHeight/useAnimatedHeight.ts"],"sourcesContent":["import { type RefObject, useCallback, useEffect, useRef } from \"react\";\nimport { easings, timings } from \"../../core\";\nimport { useBrowserPreferences } from \"../useBrowserPreferences/useBrowserPreferences\";\nimport { usePreviousValue } from \"../usePreviousValue/usePreviousValue\";\nimport { UseAnimatedHeightOptions } from \"./types\";\n\nconst defaultDisplay = \"block\";\nconst defaultEasing = \"standard\";\nconst defaultTiming = \"productive\";\n\n/**\n * Lar deg animere et element opp til sin maksimale høyde, eller ned til 0.\n *\n * @param isOpen Om elementet er åpent eller lukket.\n * @param options Konfigurer display-property, easing og timing, og eventuelle callbacks for life cycle til animasjonen.\n * @returns Ref til elementet som skal animeres, og en funksjon for å trigge animasjonen manuelt.\n */\nexport function useAnimatedHeight<T extends HTMLElement>(\n isOpen: boolean,\n options?: UseAnimatedHeightOptions<T>,\n): [RefObject<T>, () => void] {\n const wasOpen = usePreviousValue(isOpen);\n const easing = options?.easing || defaultEasing;\n const timing = options?.timing || defaultTiming;\n const display = options?.display || defaultDisplay;\n const transition = `${timings[timing]} height ${easings[easing]}`;\n\n const { prefersReducedMotion } = useBrowserPreferences();\n\n const raf1 = useRef<number>();\n const raf2 = useRef<number>();\n const elementRef = useRef<T>(null);\n\n function handleTransitionEnd(event: TransitionEvent) {\n const element = elementRef.current;\n\n // Ignore bubbling transitions from within container\n if (element && event.target === element) {\n if (isOpen) {\n element.removeAttribute(\"style\");\n } else {\n element.removeAttribute(\"style\");\n element.style.display = \"none\";\n }\n options?.onTransitionEnd?.(isOpen, elementRef);\n }\n }\n\n const runAnimation = useCallback(() => {\n const element = elementRef.current;\n\n // Ikke kjør animasjonen hvis elementet ikke er rendret,\n // eller hvis det er første render.\n if (!element || wasOpen === undefined) {\n return;\n }\n\n if (!isOpen) {\n element.style.display = \"none\";\n if (!wasOpen) {\n // Første render eller rerender med isOpen false\n return;\n }\n } else if (isOpen && wasOpen) {\n // Re-render etter å ha vært lukket, men forblitt åpen.\n return;\n }\n\n options?.onTransitionStart?.(isOpen, elementRef);\n\n if (prefersReducedMotion) {\n element.removeAttribute(\"style\");\n if (isOpen) {\n options?.onFirstVisible?.(isOpen, elementRef);\n }\n options?.onTransitionEnd?.(isOpen, elementRef); // make sure to call callback when animation is off\n return;\n }\n\n element.style.transition = transition;\n element.style.display = display;\n element.style.overflow = \"hidden\";\n\n if (isOpen) {\n options?.onFirstVisible?.(isOpen, elementRef);\n element.style.height = \"0\";\n element.style.height = `${element.scrollHeight}px`;\n } else {\n // If the scrollHeight is 0 it means that we are transitioning from height 0 -> 0.\n // This causes the \"transitionend\"-event to never fire and the element gets stuck with\n // style: height: 0; display: block; overflow:hidden\n if (element.scrollHeight === 0) {\n element.removeAttribute(\"style\");\n return;\n }\n\n element.style.height = `${element.scrollHeight}px`;\n\n raf1.current = requestAnimationFrame(() => {\n raf2.current = requestAnimationFrame(() => {\n element.style.height = `${0}px`;\n });\n });\n }\n }, [isOpen, options, wasOpen, transition, prefersReducedMotion, display]);\n\n useEffect(() => {\n runAnimation();\n }, [isOpen, runAnimation]);\n\n useEffect(() => {\n const element = elementRef.current;\n if (element) {\n element.addEventListener(\"transitionend\", handleTransitionEnd);\n }\n\n return () => {\n if (element) {\n element.removeEventListener(\"transitionend\", handleTransitionEnd);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n useEffect(() => {\n const r1 = raf1.current;\n const r2 = raf2.current;\n return () => {\n r1 && cancelAnimationFrame(r1);\n r2 && cancelAnimationFrame(r2);\n };\n }, [raf1, raf2]);\n\n return [elementRef, runAnimation];\n}\n"],"names":["useAnimatedHeight","isOpen","options","wasOpen","usePreviousValue","easing","timing","display","transition","timings","easings","prefersReducedMotion","useBrowserPreferences","raf1","useRef","raf2","elementRef","handleTransitionEnd","event","element","current","target","removeAttribute","style","_a","onTransitionEnd","call","runAnimation","useCallback","onTransitionStart","_b","onFirstVisible","_c","overflow","_d","height","scrollHeight","requestAnimationFrame","useEffect","addEventListener","removeEventListener","r1","r2","cancelAnimationFrame"],"mappings":"sSAiBgB,SAAAA,EACZC,EACAC,GAEMC,MAAAA,EAAUC,EAAiBH,GAC3BI,GAAS,MAAAH,OAAA,EAAAA,EAASG,SAfN,WAgBZC,GAAS,MAAAJ,OAAA,EAAAA,EAASI,SAfN,aAgBZC,GAAU,MAAAL,OAAA,EAAAA,EAASK,UAlBN,QAmBbC,EAAa,GAAGC,EAAQH,aAAkBI,EAAQL,MAEhDM,qBAAAA,GAAyBC,IAE3BC,EAAOC,IACPC,EAAOD,IACPE,EAAaF,EAAU,MAE7B,SAASG,EAAoBC,SACzB,MAAMC,EAAUH,EAAWI,QAGvBD,GAAWD,EAAMG,SAAWF,IACxBlB,EACAkB,EAAQG,gBAAgB,UAExBH,EAAQG,gBAAgB,SACxBH,EAAQI,MAAMhB,QAAU,QAEnB,OAAAiB,EAAA,MAAAtB,OAAA,EAAAA,EAAAuB,kBAAAD,EAAAE,KAAAxB,EAAkBD,EAAQe,GAE3C,CAEMW,MAAAA,EAAeC,GAAY,iBAC7B,MAAMT,EAAUH,EAAWI,QAIvB,GAACD,QAAuB,IAAZhB,EAIhB,CAAKF,GAAAA,GAML,GAAWA,GAAUE,EAEjB,YAAA,GAPAgB,EAAQI,MAAMhB,QAAU,QACnBJ,EAED,OAOCqB,GAAA,OAAAA,EAAA,MAAAtB,OAAA,EAAAA,EAAA2B,oBAAAL,EAAAE,KAAAxB,EAAoBD,EAAQe,GAEjCL,EAMA,OALAQ,EAAQG,gBAAgB,SACpBrB,IACS,OAAA6B,EAAA,MAAA5B,OAAA,EAAAA,EAAA6B,iBAAAD,EAAAJ,KAAAxB,EAAiBD,EAAQe,SAE7B,OAAAgB,EAAA,MAAA9B,OAAA,EAAAA,EAAAuB,kBAAAO,EAAAN,KAAAxB,EAAkBD,EAAQe,IAIvCG,GAAAA,EAAQI,MAAMf,WAAaA,EAC3BW,EAAQI,MAAMhB,QAAUA,EACxBY,EAAQI,MAAMU,SAAW,SAErBhC,EACS,OAAAiC,EAAA,MAAAhC,OAAAA,EAAAA,EAAA6B,iBAAAG,EAAAR,KAAAxB,EAAiBD,EAAQe,GAClCG,EAAQI,MAAMY,OAAS,IACvBhB,EAAQI,MAAMY,OAAS,GAAGhB,EAAQiB,qBAC/B,CAICjB,GAAyB,IAAzBA,EAAQiB,aAER,YADAjB,EAAQG,gBAAgB,SAI5BH,EAAQI,MAAMY,OAAS,GAAGhB,EAAQiB,iBAE7BvB,EAAAO,QAAUiB,uBAAsB,KAC5BtB,EAAAK,QAAUiB,uBAAsB,KACzBlB,EAAAI,MAAMY,OAAS,KAAA,GAC1B,GAET,CAAA,IACD,CAAClC,EAAQC,EAASC,EAASK,EAAYG,EAAsBJ,IAEhE,OAAA+B,GAAU,KACOX,MACd,CAAC1B,EAAQ0B,IAEZW,GAAU,KACN,MAAMnB,EAAUH,EAAWI,QAC3B,OAAID,GACQA,EAAAoB,iBAAiB,gBAAiBtB,GAGvC,KACCE,GACQA,EAAAqB,oBAAoB,gBAAiBvB,EAAmB,CACpE,GAGL,CAAChB,IAEJqC,GAAU,KACN,MAAMG,EAAK5B,EAAKO,QACVsB,EAAK3B,EAAKK,QAChB,MAAO,KACHqB,GAAME,qBAAqBF,GAC3BC,GAAMC,qBAAqBD,EAAE,CAAA,GAElC,CAAC7B,EAAME,IAEH,CAACC,EAAYW,EACxB"}
@@ -0,0 +1,2 @@
1
+ import{useRef as e,useCallback as t,useEffect as r}from"react";import{timings as n,easings as s}from"../../core/utils/motion.js";import{useBrowserPreferences as o}from"../useBrowserPreferences/useBrowserPreferences.js";import{usePreviousValue as i}from"../usePreviousValue/usePreviousValue.js";function a(a,u){const l=i(a),d=(null==u?void 0:u.easing)||"standard",c=(null==u?void 0:u.timing)||"productive",m=`${n[c]} height ${s[d]}`,{prefersReducedMotion:p}=o(),y=e(),f=e(),v=e(null),g=t((e=>{var t;const r=v.current;r&&e.target===r&&(r.removeAttribute("style"),null==(t=null==u?void 0:u.onTransitionEnd)||t.call(u,a,v))}),[u,a]),h=t((()=>{var e,t;const r=v.current;if(r&&(void 0===l&&(r.dataset.expanded=a?"true":"false"),!(!a&&!l||a&&l))){if(null==(e=null==u?void 0:u.onTransitionStart)||e.call(u,a,v),p)return r.removeAttribute("style"),r.dataset.expanded=a?"true":"false",void(null==(t=null==u?void 0:u.onTransitionEnd)||t.call(u,a,v));a?function(e,t,r,n){const s=e.current;if(!s)return;s.removeAttribute("style");const o=s.scrollHeight;r.current=requestAnimationFrame((()=>{s.style.removeProperty("transition"),s.dataset.expanded="false";const e=s.getBoundingClientRect().height;s.style.setProperty("height",`${e}px`),s.style.setProperty("overflow-y","hidden"),n.current=requestAnimationFrame((()=>{s.style.setProperty("transition",t),s.style.setProperty("height",`${o}px`),s.dataset.expanded="true"}))}))}(v,m,y,f):function(e,t,r,n){const s=e.current;if(!s)return;s.removeAttribute("style");const o=s.scrollHeight;r.current=requestAnimationFrame((()=>{s.style.removeProperty("transition"),s.dataset.expanded="false";const e=s.getBoundingClientRect().height;s.dataset.expanded="true",s.style.setProperty("height",`${o}px`),s.style.setProperty("overflow-y","hidden"),n.current=requestAnimationFrame((()=>{s.style.setProperty("transition",t),s.style.setProperty("height",`${e}px`),s.dataset.expanded="false"}))}))}(v,m,y,f)}}),[l,a,u,p,m]);return r((()=>{h()}),[a,h]),r((()=>{const e=v.current;return e&&e.addEventListener("transitionend",g),()=>{e&&e.removeEventListener("transitionend",g)}}),[a]),r((()=>{const e=y.current,t=f.current;return()=>{e&&cancelAnimationFrame(e),t&&cancelAnimationFrame(t)}}),[y,f]),[v,h]}export{a as useAnimatedHeightBetween};
2
+ //# sourceMappingURL=useAnimatedHeightBetween.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimatedHeightBetween.js","sources":["../../../../src/hooks/useAnimatedHeight/useAnimatedHeightBetween.ts"],"sourcesContent":["import { type RefObject, useCallback, useEffect, useRef } from \"react\";\nimport { timings, easings } from \"../../core\";\nimport { useBrowserPreferences } from \"../useBrowserPreferences/useBrowserPreferences\";\nimport { usePreviousValue } from \"../usePreviousValue/usePreviousValue\";\nimport { UseAnimatedHeightOptions } from \"./types\";\n\nconst defaultEasing = \"standard\";\nconst defaultTiming = \"productive\";\n\nfunction collapseElement<T extends HTMLElement>(\n elementRef: RefObject<T>,\n transition: string,\n raf1: React.MutableRefObject<number | undefined>,\n raf2: React.MutableRefObject<number | undefined>,\n) {\n const element = elementRef.current;\n\n if (!element) return;\n\n element.removeAttribute(\"style\");\n const expandedHeight = element.scrollHeight;\n\n raf1.current = requestAnimationFrame(() => {\n // Hent kollapset høyde\n element.style.removeProperty(\"transition\");\n element.dataset[\"expanded\"] = \"false\";\n const collapsedHeight = element.getBoundingClientRect().height;\n element.dataset[\"expanded\"] = \"true\";\n\n // Sett høyde tilbake til utvidet høyde\n element.style.setProperty(\"height\", `${expandedHeight}px`);\n element.style.setProperty(\"overflow-y\", \"hidden\");\n\n raf2.current = requestAnimationFrame(() => {\n // Sett høyde til kollapset høyde og start transition\n element.style.setProperty(\"transition\", transition);\n element.style.setProperty(\"height\", `${collapsedHeight}px`);\n element.dataset[\"expanded\"] = \"false\";\n });\n });\n}\n\nfunction expandElement<T extends HTMLElement>(\n elementRef: RefObject<T>,\n transition: string,\n raf1: React.MutableRefObject<number | undefined>,\n raf2: React.MutableRefObject<number | undefined>,\n) {\n const element = elementRef.current;\n\n if (!element) return;\n\n element.removeAttribute(\"style\");\n const expandedHeight = element.scrollHeight;\n\n raf1.current = requestAnimationFrame(() => {\n // Hent utvidet høyde\n element.style.removeProperty(\"transition\");\n element.dataset[\"expanded\"] = \"false\";\n const collapsedHeight = element.getBoundingClientRect().height;\n\n // Sett høyde tilbake til kollapset høyde\n element.style.setProperty(\"height\", `${collapsedHeight}px`);\n element.style.setProperty(\"overflow-y\", \"hidden\");\n\n raf2.current = requestAnimationFrame(() => {\n // Sett høyde til utvidet høyde og start transition\n element.style.setProperty(\"transition\", transition);\n element.style.setProperty(\"height\", `${expandedHeight}px`);\n element.dataset[\"expanded\"] = \"true\";\n });\n });\n}\n\n/**\n * Lar deg enklere animere mellom to tilstander, gitt ved å sette `data-expanded` på et element til `true` eller `false`.\n * Du bestemmer selv hvilke stiler elementet skal ha i de to tilstandene (vha CSS/Sass), og høyden animeres dersom den endrer seg.\n * @param isExpanded indikerer om elementet skal være utvidet eller ikke\n * @param options konfigurasjon for animasjonen, og lyttere for når animasjonen starter og slutter\n * @returns En tuple med referanse til elementet og en funksjon som kan trigge animasjonen\n */\nexport function useAnimatedHeightBetween<T extends HTMLElement>(\n isExpanded: boolean,\n options?: Omit<UseAnimatedHeightOptions<T>, \"display\" | \"onFirstVisible\">,\n): [RefObject<T>, () => void] {\n const wasExpanded = usePreviousValue(isExpanded);\n const easing = options?.easing || defaultEasing;\n const timing = options?.timing || defaultTiming;\n const transition = `${timings[timing]} height ${easings[easing]}`;\n\n const { prefersReducedMotion } = useBrowserPreferences();\n\n const raf1 = useRef<number>();\n const raf2 = useRef<number>();\n const elementRef = useRef<T>(null);\n\n const handleTransitionEnd = useCallback(\n (event: TransitionEvent) => {\n const element = elementRef.current;\n\n // Ignore bubbling transitions from within container\n if (element && event.target === element) {\n element.removeAttribute(\"style\");\n options?.onTransitionEnd?.(isExpanded, elementRef);\n }\n },\n [options, isExpanded],\n );\n\n const runAnimation = useCallback(() => {\n const element = elementRef.current;\n\n if (!element) return;\n\n if (wasExpanded === undefined) {\n // Første render\n element.dataset[\"expanded\"] = isExpanded ? \"true\" : \"false\";\n }\n\n if ((!isExpanded && !wasExpanded) || (isExpanded && wasExpanded)) {\n // Ingen endring\n return;\n }\n\n options?.onTransitionStart?.(isExpanded, elementRef);\n\n if (prefersReducedMotion) {\n element.removeAttribute(\"style\");\n element.dataset[\"expanded\"] = isExpanded ? \"true\" : \"false\";\n options?.onTransitionEnd?.(isExpanded, elementRef); // make sure to call callback when animation is off\n return;\n }\n\n if (isExpanded) {\n expandElement(elementRef, transition, raf1, raf2);\n } else {\n collapseElement(elementRef, transition, raf1, raf2);\n }\n }, [wasExpanded, isExpanded, options, prefersReducedMotion, transition]);\n\n useEffect(() => {\n runAnimation();\n }, [isExpanded, runAnimation]);\n\n useEffect(() => {\n const element = elementRef.current;\n if (element) {\n element.addEventListener(\"transitionend\", handleTransitionEnd);\n }\n\n return () => {\n if (element) {\n element.removeEventListener(\"transitionend\", handleTransitionEnd);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isExpanded]);\n\n useEffect(() => {\n const r1 = raf1.current;\n const r2 = raf2.current;\n return () => {\n r1 && cancelAnimationFrame(r1);\n r2 && cancelAnimationFrame(r2);\n };\n }, [raf1, raf2]);\n\n return [elementRef, runAnimation];\n}\n"],"names":["useAnimatedHeightBetween","isExpanded","options","wasExpanded","usePreviousValue","easing","timing","transition","timings","easings","prefersReducedMotion","useBrowserPreferences","raf1","useRef","raf2","elementRef","handleTransitionEnd","useCallback","event","element","current","target","removeAttribute","_a","onTransitionEnd","call","runAnimation","dataset","expanded","onTransitionStart","_b","expandedHeight","scrollHeight","requestAnimationFrame","style","removeProperty","collapsedHeight","getBoundingClientRect","height","setProperty","expandElement","collapseElement","useEffect","addEventListener","removeEventListener","r1","r2","cancelAnimationFrame"],"mappings":"sSAiFgB,SAAAA,EACZC,EACAC,GAEM,MAAAC,EAAcC,EAAiBH,GAC/BI,GAAS,MAAAH,SAAAA,EAASG,SAhFN,WAiFZC,GAAS,MAAAJ,SAAAA,EAASI,SAhFN,aAiFZC,EAAa,GAAGC,EAAQF,aAAkBG,EAAQJ,MAEhDK,qBAAAA,GAAyBC,IAE3BC,EAAOC,IACPC,EAAOD,IACPE,EAAaF,EAAU,MAEvBG,EAAsBC,GACvBC,UACG,MAAMC,EAAUJ,EAAWK,QAGvBD,GAAWD,EAAMG,SAAWF,IAC5BA,EAAQG,gBAAgB,SACf,OAAAC,EAAA,MAAArB,SAAAA,EAAAsB,kBAAAD,EAAAE,KAAAvB,EAAkBD,EAAYc,GAAAA,GAG/C,CAACb,EAASD,IAGRyB,EAAeT,GAAY,aAC7B,MAAME,EAAUJ,EAAWK,QAE3B,GAAKD,SAEe,IAAhBhB,IAEAgB,EAAQQ,QAAQC,SAAc3B,EAAa,OAAS,YAGlDA,IAAeE,GAAiBF,GAAcE,IAOpD,CAFSoB,GAAA,OAAAA,EAAA,MAAArB,OAAA,EAAAA,EAAA2B,oBAAAN,EAAAE,KAAAvB,EAAoBD,EAAYc,GAErCL,EAIA,OAHAS,EAAQG,gBAAgB,SACxBH,EAAQQ,QAAQC,SAAc3B,EAAa,OAAS,aAC3C,OAAA6B,EAAA,MAAA5B,SAAAA,EAAAsB,kBAAAM,EAAAL,KAAAvB,EAAkBD,EAAYc,IAIvCd,EA3FZ,SACIc,EACAR,EACAK,EACAE,GAEA,MAAMK,EAAUJ,EAAWK,QAE3B,IAAKD,EAAS,OAEdA,EAAQG,gBAAgB,SACxB,MAAMS,EAAiBZ,EAAQa,aAE1BpB,EAAAQ,QAAUa,uBAAsB,KAEzBd,EAAAe,MAAMC,eAAe,cACrBhB,EAAAQ,QAAQC,SAAc,QACxBQ,MAAAA,EAAkBjB,EAAQkB,wBAAwBC,OAGxDnB,EAAQe,MAAMK,YAAY,SAAU,GAAGH,OAC/BjB,EAAAe,MAAMK,YAAY,aAAc,UAEnCzB,EAAAM,QAAUa,uBAAsB,KAEzBd,EAAAe,MAAMK,YAAY,aAAchC,GACxCY,EAAQe,MAAMK,YAAY,SAAU,GAAGR,OAC/BZ,EAAAQ,QAAQC,SAAc,MAAA,GACjC,GAET,CA8D0BY,CAAAzB,EAAYR,EAAYK,EAAME,GA7HxD,SACIC,EACAR,EACAK,EACAE,GAEA,MAAMK,EAAUJ,EAAWK,QAE3B,IAAKD,EAAS,OAEdA,EAAQG,gBAAgB,SACxB,MAAMS,EAAiBZ,EAAQa,aAE1BpB,EAAAQ,QAAUa,uBAAsB,KAEzBd,EAAAe,MAAMC,eAAe,cACrBhB,EAAAQ,QAAQC,SAAc,QACxBQ,MAAAA,EAAkBjB,EAAQkB,wBAAwBC,OAChDnB,EAAAQ,QAAQC,SAAc,OAG9BT,EAAQe,MAAMK,YAAY,SAAU,GAAGR,OAC/BZ,EAAAe,MAAMK,YAAY,aAAc,UAEnCzB,EAAAM,QAAUa,uBAAsB,KAEzBd,EAAAe,MAAMK,YAAY,aAAchC,GACxCY,EAAQe,MAAMK,YAAY,SAAU,GAAGH,OAC/BjB,EAAAQ,QAAQC,SAAc,OAAA,GACjC,GAET,CAgG4Ba,CAAA1B,EAAYR,EAAYK,EAAME,EAAI,IAEvD,CAACX,EAAaF,EAAYC,EAASQ,EAAsBH,IAE5D,OAAAmC,GAAU,KACOhB,MACd,CAACzB,EAAYyB,IAEhBgB,GAAU,KACN,MAAMvB,EAAUJ,EAAWK,QAC3B,OAAID,GACQA,EAAAwB,iBAAiB,gBAAiB3B,GAGvC,KACCG,GACQA,EAAAyB,oBAAoB,gBAAiB5B,EAAmB,CACpE,GAGL,CAACf,IAEJyC,GAAU,KACN,MAAMG,EAAKjC,EAAKQ,QACV0B,EAAKhC,EAAKM,QAChB,MAAO,KACHyB,GAAME,qBAAqBF,GAC3BC,GAAMC,qBAAqBD,EAAE,CAAA,GAElC,CAAClC,EAAME,IAEH,CAACC,EAAYW,EACxB"}
@@ -0,0 +1,2 @@
1
+ import{useState as e,useRef as r,useCallback as t,useEffect as n}from"react";import{timings as s,easings as i}from"../../core/utils/motion.js";import{useBrowserPreferences as o}from"../useBrowserPreferences/useBrowserPreferences.js";import{usePreviousValue as u}from"../usePreviousValue/usePreviousValue.js";function a(a,l){const c=u(a),[m,d]=e(0),v=(null==l?void 0:l.easing)||"standard",f=(null==l?void 0:l.timing)||"expressive",p=`${s[f]} height ${i[v]}`,{prefersReducedMotion:y}=o(),g=r(),P=r(),h=r(null),A=t((e=>{var r;const t=h.current;t&&e.target===t&&(t.removeAttribute("style"),null==(r=null==l?void 0:l.onTransitionEnd)||r.call(l,h))}),[l]),E=t((()=>{const e=h.current;if(!e)return;e.removeAttribute("style");const r=e.scrollHeight;g.current=requestAnimationFrame((()=>{e.style.removeProperty("transition"),e.style.setProperty("height",`${m}px`),e.style.setProperty("overflow-y","hidden"),P.current=requestAnimationFrame((()=>{e.style.setProperty("transition",p),e.style.setProperty("height",`${r}px`)}))})),d(r)}),[p,m]),w=t((()=>{var e,r;const t=h.current;if(t){if(void 0===c)return void d(t.scrollHeight);if(a!==c){if(null==(e=null==l?void 0:l.onTransitionStart)||e.call(l,h),y)return void(null==(r=null==l?void 0:l.onTransitionEnd)||r.call(l,h));E()}}}),[E,a,c,l,y]);return n((()=>{w()}),[a,w]),n((()=>{const e=h.current;return e&&e.addEventListener("transitionend",A),()=>{e&&e.removeEventListener("transitionend",A)}}),[A]),n((()=>{const e=g.current,r=P.current;return()=>{e&&cancelAnimationFrame(e),r&&cancelAnimationFrame(r)}}),[g,P]),h}export{a as useAutoAnimatedHeight};
2
+ //# sourceMappingURL=useAutoAnimateHeight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAutoAnimateHeight.js","sources":["../../../../src/hooks/useAnimatedHeight/useAutoAnimateHeight.ts"],"sourcesContent":["import { RefObject, useCallback, useEffect, useRef, useState } from \"react\";\nimport { easings, timings, type Easing, type Timing } from \"../../core\";\nimport { useBrowserPreferences } from \"../useBrowserPreferences/useBrowserPreferences\";\nimport { usePreviousValue } from \"../usePreviousValue/usePreviousValue\";\n\nconst defaultEasing = \"standard\";\nconst defaultTiming = \"expressive\";\n\nexport type UseAutoAnimatedHeightOptions<T extends HTMLElement> = {\n easing?: Easing;\n /**\n * Overstyr standard timing\n * @default \"expressive\"\n */\n timing?: Timing;\n onTransitionStart?: (ref: RefObject<T>) => void;\n onTransitionEnd?: (ref: RefObject<T>) => void;\n};\n\n/**\n * Gjør det enklere å animere høyden på et element når innholdet endrer seg, men kan brukes på mer generelt grunnlag.\n * Hooken tar inn en triggerverdi, og når denne endrer seg animeres høyden på elementet dersom den har endret seg.\n * @param trigger verdien som brukes til å trigge animasjonen. Dersom denne endrer seg animeres høyden på elementet.\n * @param options konfigurasjon for animasjonen, og lyttere for når animasjonen starter og slutter\n * @returns en referanse til elementet som skal animeres\n */\nexport function useAutoAnimatedHeight<T extends HTMLElement = HTMLElement>(\n trigger: any,\n options?: UseAutoAnimatedHeightOptions<T>,\n) {\n const previousTriggerValue = usePreviousValue(trigger);\n const [previousHeight, setPreviousHeight] = useState(0);\n\n const easing = options?.easing || defaultEasing;\n const timing = options?.timing || defaultTiming;\n const transition = `${timings[timing]} height ${easings[easing]}`;\n\n const { prefersReducedMotion } = useBrowserPreferences();\n\n const raf1 = useRef<number>();\n const raf2 = useRef<number>();\n const elementRef = useRef<T>(null);\n\n const handleTransitionEnd = useCallback(\n (event: TransitionEvent) => {\n const element = elementRef.current;\n\n // Ignore bubbling transitions from within container\n if (element && event.target === element) {\n element.removeAttribute(\"style\");\n options?.onTransitionEnd?.(elementRef);\n }\n },\n [options],\n );\n\n const animateElement = useCallback(() => {\n const element = elementRef.current;\n\n if (!element) return;\n\n element.removeAttribute(\"style\");\n const newHeight = element.scrollHeight;\n\n raf1.current = requestAnimationFrame(() => {\n // Sett høyde tilbake til forrige høyde\n element.style.removeProperty(\"transition\");\n element.style.setProperty(\"height\", `${previousHeight}px`);\n element.style.setProperty(\"overflow-y\", \"hidden\");\n\n raf2.current = requestAnimationFrame(() => {\n // Sett høyde til kollapset høyde og start transition\n element.style.setProperty(\"transition\", transition);\n element.style.setProperty(\"height\", `${newHeight}px`);\n });\n });\n\n setPreviousHeight(newHeight);\n }, [transition, previousHeight]);\n\n const runAnimation = useCallback(() => {\n const element = elementRef.current;\n\n if (!element) return;\n\n if (previousTriggerValue === undefined) {\n // Første render\n setPreviousHeight(element.scrollHeight);\n return;\n }\n\n if (trigger === previousTriggerValue) {\n // Ingen endring\n return;\n }\n\n options?.onTransitionStart?.(elementRef);\n\n if (prefersReducedMotion) {\n options?.onTransitionEnd?.(elementRef); // make sure to call callback when animation is off\n return;\n }\n\n animateElement();\n }, [animateElement, trigger, previousTriggerValue, options, prefersReducedMotion]);\n\n useEffect(() => {\n runAnimation();\n }, [trigger, runAnimation]);\n\n useEffect(() => {\n const element = elementRef.current;\n if (element) {\n element.addEventListener(\"transitionend\", handleTransitionEnd);\n }\n\n return () => {\n if (element) {\n element.removeEventListener(\"transitionend\", handleTransitionEnd);\n }\n };\n }, [handleTransitionEnd]);\n\n useEffect(() => {\n const r1 = raf1.current;\n const r2 = raf2.current;\n return () => {\n r1 && cancelAnimationFrame(r1);\n r2 && cancelAnimationFrame(r2);\n };\n }, [raf1, raf2]);\n\n return elementRef;\n}\n"],"names":["useAutoAnimatedHeight","trigger","options","previousTriggerValue","usePreviousValue","previousHeight","setPreviousHeight","useState","easing","timing","transition","timings","easings","prefersReducedMotion","useBrowserPreferences","raf1","useRef","raf2","elementRef","handleTransitionEnd","useCallback","event","element","current","target","removeAttribute","_a","onTransitionEnd","call","animateElement","newHeight","scrollHeight","requestAnimationFrame","style","removeProperty","setProperty","runAnimation","onTransitionStart","_b","useEffect","addEventListener","removeEventListener","r1","r2","cancelAnimationFrame"],"mappings":"oTA0BgB,SAAAA,EACZC,EACAC,GAEMC,MAAAA,EAAuBC,EAAiBH,IACvCI,EAAgBC,GAAqBC,EAAS,GAE/CC,GAAS,MAAAN,OAAA,EAAAA,EAASM,SA5BN,WA6BZC,GAAS,MAAAP,OAAA,EAAAA,EAASO,SA5BN,aA6BZC,EAAa,GAAGC,EAAQF,aAAkBG,EAAQJ,MAEhDK,qBAAAA,GAAyBC,IAE3BC,EAAOC,IACPC,EAAOD,IACPE,EAAaF,EAAU,MAEvBG,EAAsBC,GACvBC,UACG,MAAMC,EAAUJ,EAAWK,QAGvBD,GAAWD,EAAMG,SAAWF,IAC5BA,EAAQG,gBAAgB,SACxB,OAAAC,EAAA,MAAAxB,SAAAA,EAASyB,kBAATD,EAAAE,KAAA1B,EAA2BgB,GAAAA,GAGnC,CAAChB,IAGC2B,EAAiBT,GAAY,KAC/B,MAAME,EAAUJ,EAAWK,QAE3B,IAAKD,EAAS,OAEdA,EAAQG,gBAAgB,SACxB,MAAMK,EAAYR,EAAQS,aAErBhB,EAAAQ,QAAUS,uBAAsB,KAEzBV,EAAAW,MAAMC,eAAe,cAC7BZ,EAAQW,MAAME,YAAY,SAAU,GAAG9B,OAC/BiB,EAAAW,MAAME,YAAY,aAAc,UAEnClB,EAAAM,QAAUS,uBAAsB,KAEzBV,EAAAW,MAAME,YAAY,aAAczB,GACxCY,EAAQW,MAAME,YAAY,SAAU,GAAGL,MAAa,GACvD,IAGLxB,EAAkBwB,EAAS,GAC5B,CAACpB,EAAYL,IAEV+B,EAAehB,GAAY,aAC7B,MAAME,EAAUJ,EAAWK,QAE3B,GAAKD,EAEL,CAAA,QAA6B,IAAzBnB,EAGA,YADAG,EAAkBgB,EAAQS,cAI9B,GAAI9B,IAAYE,EAOhB,CAFAuB,GAAA,OAAAA,EAAA,MAAAxB,OAAA,EAAAA,EAASmC,oBAATX,EAAAE,KAAA1B,EAA6BgB,GAEzBL,EAEA,YADA,OAAAyB,EAAA,MAAApC,OAAAA,EAAAA,EAASyB,kBAATW,EAAAV,KAAA1B,EAA2BgB,IAIhBW,QAChB,CAACA,EAAgB5B,EAASE,EAAsBD,EAASW,IAE5D,OAAA0B,GAAU,KACOH,MACd,CAACnC,EAASmC,IAEbG,GAAU,KACN,MAAMjB,EAAUJ,EAAWK,QAC3B,OAAID,GACQA,EAAAkB,iBAAiB,gBAAiBrB,GAGvC,KACCG,GACQA,EAAAmB,oBAAoB,gBAAiBtB,EAAmB,CACpE,GAEL,CAACA,IAEJoB,GAAU,KACN,MAAMG,EAAK3B,EAAKQ,QACVoB,EAAK1B,EAAKM,QAChB,MAAO,KACHmB,GAAME,qBAAqBF,GAC3BC,GAAMC,qBAAqBD,EAAE,CAAA,GAElC,CAAC5B,EAAME,IAEHC,CACX"}
@@ -0,0 +1,2 @@
1
+ import{useAriaLiveRegion as e}from"./useAriaLiveRegion.js";export{e as useAriaLiveRegion};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useState as e,useEffect as r}from"react";import{usePreviousValue as s}from"../usePreviousValue/usePreviousValue.js";function i(i,a){const o=s(i),[u,t]=e(!1);return r((()=>{if(Array.isArray(i)&&Array.isArray(o)){for(let e=0;e<i.length;e++)if(i[e]!==o[e]&&!u){t(!0);break}}else o&&i!==o&&!u&&t(!0)}),[i,o,u]),{"aria-live":u?(null==a?void 0:a.politeness)||"polite":void 0}}export{i as useAriaLiveRegion};
2
+ //# sourceMappingURL=useAriaLiveRegion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAriaLiveRegion.js","sources":["../../../../src/hooks/useAriaLiveRegion/useAriaLiveRegion.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { usePreviousValue } from \"../usePreviousValue\";\n\nexport interface UseAriaLiveRegionOptions {\n /**\n * @default \"polite\"\n */\n politeness?: \"polite\" | \"assertive\" | \"off\";\n}\n\n/**\n * Hjelper for å bare sette aria-live dersom det har skjedd en endring. Unngår at innholdet annonseres ved sidelasting.\n * @param watch Verdi som indikerer at det har skjedd en endring. For eksempel en boolean som styrer en loader, eller selve teksten som skal bli lest opp.\n * @param options Bestem om aria-live skal være polite, assertive eller off.\n * @returns\n */\nexport function useAriaLiveRegion(watch: unknown | unknown[], options?: UseAriaLiveRegionOptions) {\n const previousValue = usePreviousValue(watch);\n\n const [hasChanged, setHasChanged] = useState(false);\n useEffect(() => {\n if (Array.isArray(watch) && Array.isArray(previousValue)) {\n for (let i = 0; i < watch.length; i++) {\n if (watch[i] !== previousValue[i] && !hasChanged) {\n setHasChanged(true);\n break;\n }\n }\n } else if (previousValue && watch !== previousValue && !hasChanged) {\n setHasChanged(true);\n }\n }, [watch, previousValue, hasChanged]);\n\n return {\n \"aria-live\": hasChanged ? options?.politeness || \"polite\" : undefined,\n };\n}\n"],"names":["useAriaLiveRegion","watch","options","previousValue","usePreviousValue","hasChanged","setHasChanged","useState","useEffect","Array","isArray","i","length","politeness"],"mappings":"2HAgBgB,SAAAA,EAAkBC,EAA4BC,GACpDC,MAAAA,EAAgBC,EAAiBH,IAEhCI,EAAYC,GAAiBC,GAAS,GAC7C,OAAAC,GAAU,KACN,GAAIC,MAAMC,QAAQT,IAAUQ,MAAMC,QAAQP,IACtC,IAAA,IAASQ,EAAI,EAAGA,EAAIV,EAAMW,OAAQD,IAC9B,GAAIV,EAAMU,KAAOR,EAAcQ,KAAON,EAAY,CAC9CC,GAAc,GACd,KACJ,OAEGH,GAAiBF,IAAUE,IAAkBE,GACpDC,GAAc,EAAI,GAEvB,CAACL,EAAOE,EAAeE,IAEnB,CACH,YAAaA,GAAa,MAAAH,OAAAA,EAAAA,EAASW,aAAc,cAAW,EAEpE"}
@@ -0,0 +1,2 @@
1
+ import{useBrowserPreferences as e}from"./useBrowserPreferences.js";export{e as useBrowserPreferences};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useState as e,useReducer as r,useEffect as t}from"react";import{getInitialMediaQueryMatch as a,addMediaQueryListener as o,removeMediaQueryListener as s}from"../mediaQueryUtils.js";const c="(prefers-reduced-motion: reduce)",i="(prefers-color-scheme: light)",d="(forced-colors: active)",u={prefersReducedMotion:!1,prefersColorScheme:"light",forcedColors:!1},C=(e,r)=>{switch(r.type){case"COLOR_SCHEME_CHANGED":return{...e,prefersColorScheme:r.value};case"REDUCED_MOTION_CHANGED":return{...e,prefersReducedMotion:r.value};case"FORCED_COLORS_CHANGED":return{...e,forcedColors:r.value};default:return e}},n=()=>{const[n,E]=e(!1),[l,O]=r(C,u);return t((()=>{E(!0);const e=a(c),r=a(i)?"light":"dark",t=a(d);O({type:"REDUCED_MOTION_CHANGED",value:e}),O({type:"COLOR_SCHEME_CHANGED",value:r}),O({type:"FORCED_COLORS_CHANGED",value:t})}),[]),t((()=>{if(!n||!window.matchMedia)return;const e=e=>{O({type:"REDUCED_MOTION_CHANGED",value:e.matches})},r=e=>{O({type:"COLOR_SCHEME_CHANGED",value:e.matches?"light":"dark"})},t=e=>{O({type:"FORCED_COLORS_CHANGED",value:e.matches})};return o(window.matchMedia(c),e),o(window.matchMedia(i),r),o(window.matchMedia(d),t),()=>{s(window.matchMedia(c),e),s(window.matchMedia(i),r),s(window.matchMedia(d),t)}}),[n]),{...l}};export{n as useBrowserPreferences};
2
+ //# sourceMappingURL=useBrowserPreferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBrowserPreferences.js","sources":["../../../../src/hooks/useBrowserPreferences/useBrowserPreferences.tsx"],"sourcesContent":["import { Reducer, useEffect, useReducer, useState } from \"react\";\nimport { ColorScheme } from \"../../core\";\nimport { addMediaQueryListener, getInitialMediaQueryMatch, removeMediaQueryListener } from \"../mediaQueryUtils\";\n\ntype BrowserPreferences = {\n prefersReducedMotion: boolean;\n prefersColorScheme: ColorScheme;\n forcedColors: boolean;\n};\n\nenum ActionType {\n PrefersColorScheme = \"COLOR_SCHEME_CHANGED\",\n PrefersReducedMotion = \"REDUCED_MOTION_CHANGED\",\n ForcedColors = \"FORCED_COLORS_CHANGED\",\n}\n\ntype Action =\n | {\n type: ActionType.PrefersColorScheme;\n value: ColorScheme;\n }\n | {\n type: ActionType.PrefersReducedMotion;\n value: boolean;\n }\n | {\n type: ActionType.ForcedColors;\n value: boolean;\n };\n\nconst PREFERS_REDUCED_MOTION = \"(prefers-reduced-motion: reduce)\";\nconst PREFERS_LIGHT_COLOR_SCHEME = \"(prefers-color-scheme: light)\";\nconst FORCED_COLORS = \"(forced-colors: active)\";\n\nconst initialState: BrowserPreferences = {\n prefersReducedMotion: false,\n prefersColorScheme: \"light\",\n forcedColors: false,\n};\n\nconst reducer: Reducer<BrowserPreferences, Action> = (state, action) => {\n switch (action.type) {\n case ActionType.PrefersColorScheme:\n return {\n ...state,\n prefersColorScheme: action.value,\n };\n case ActionType.PrefersReducedMotion:\n return {\n ...state,\n prefersReducedMotion: action.value,\n };\n case ActionType.ForcedColors:\n return {\n ...state,\n forcedColors: action.value,\n };\n default:\n return state;\n }\n};\n\n/**\n * Hook som gir informasjon om brukerens foretrukne konfigurasjon.\n * @returns Objekt med informasjon om brukerens foretrukne tema (lyst vs mørkt), redusert bevegelse, og høykontrast (forced colors).\n */\nexport const useBrowserPreferences = (): BrowserPreferences => {\n const [hasMounted, setHasMounted] = useState(false);\n\n const [state, dispatch] = useReducer(reducer, initialState);\n\n useEffect(() => {\n setHasMounted(true);\n const prefersReducedMotion = getInitialMediaQueryMatch(PREFERS_REDUCED_MOTION);\n const prefersColorScheme = getInitialMediaQueryMatch(PREFERS_LIGHT_COLOR_SCHEME) ? \"light\" : \"dark\";\n const forcedColors = getInitialMediaQueryMatch(FORCED_COLORS);\n dispatch({ type: ActionType.PrefersReducedMotion, value: prefersReducedMotion });\n dispatch({ type: ActionType.PrefersColorScheme, value: prefersColorScheme });\n dispatch({ type: ActionType.ForcedColors, value: forcedColors });\n }, []);\n\n useEffect(() => {\n if (!hasMounted || !window.matchMedia) {\n return;\n }\n const onPrefersReducedMotionChange = (e: MediaQueryListEvent) => {\n dispatch({ type: ActionType.PrefersReducedMotion, value: e.matches });\n };\n const onPrefersColorSchemeChange = (e: MediaQueryListEvent) => {\n dispatch({ type: ActionType.PrefersColorScheme, value: e.matches ? \"light\" : \"dark\" });\n };\n const onForcedColorsChange = (e: MediaQueryListEvent) => {\n dispatch({ type: ActionType.ForcedColors, value: e.matches });\n };\n\n addMediaQueryListener(window.matchMedia(PREFERS_REDUCED_MOTION), onPrefersReducedMotionChange);\n addMediaQueryListener(window.matchMedia(PREFERS_LIGHT_COLOR_SCHEME), onPrefersColorSchemeChange);\n addMediaQueryListener(window.matchMedia(FORCED_COLORS), onForcedColorsChange);\n\n return () => {\n removeMediaQueryListener(window.matchMedia(PREFERS_REDUCED_MOTION), onPrefersReducedMotionChange);\n removeMediaQueryListener(window.matchMedia(PREFERS_LIGHT_COLOR_SCHEME), onPrefersColorSchemeChange);\n removeMediaQueryListener(window.matchMedia(FORCED_COLORS), onForcedColorsChange);\n };\n }, [hasMounted]);\n\n return { ...state };\n};\n"],"names":["PREFERS_REDUCED_MOTION","PREFERS_LIGHT_COLOR_SCHEME","FORCED_COLORS","initialState","prefersReducedMotion","prefersColorScheme","forcedColors","reducer","state","action","type","value","useBrowserPreferences","hasMounted","setHasMounted","useState","dispatch","useReducer","useEffect","getInitialMediaQueryMatch","window","matchMedia","onPrefersReducedMotionChange","e","matches","onPrefersColorSchemeChange","onForcedColorsChange","addMediaQueryListener","removeMediaQueryListener"],"mappings":"2LA8BA,MAAMA,EAAyB,mCACzBC,EAA6B,gCAC7BC,EAAgB,0BAEhBC,EAAmC,CACrCC,sBAAsB,EACtBC,mBAAoB,QACpBC,cAAc,GAGZC,EAA+C,CAACC,EAAOC,KACzD,OAAQA,EAAOC,MACX,IAAK,uBACM,MAAA,IACAF,EACHH,mBAAoBI,EAAOE,OAEnC,IAAK,yBACM,MAAA,IACAH,EACHJ,qBAAsBK,EAAOE,OAErC,IAAK,wBACM,MAAA,IACAH,EACHF,aAAcG,EAAOE,OAE7B,QACWH,OAAAA,EACf,EAOSI,EAAwB,KACjC,MAAOC,EAAYC,GAAiBC,GAAS,IAEtCP,EAAOQ,GAAYC,EAAWV,EAASJ,GAE9C,OAAAe,GAAU,KACNJ,GAAc,GACR,MAAAV,EAAuBe,EAA0BnB,GACjDK,EAAqBc,EAA0BlB,GAA8B,QAAU,OACvFK,EAAea,EAA0BjB,GAC/Cc,EAAS,CAAEN,KAAM,yBAAiCC,MAAOP,IACzDY,EAAS,CAAEN,KAAM,uBAA+BC,MAAON,IACvDW,EAAS,CAAEN,KAAM,wBAAyBC,MAAOL,GAAc,GAChE,IAEHY,GAAU,KACF,IAACL,IAAeO,OAAOC,WACvB,OAEEC,MAAAA,EAAgCC,IAClCP,EAAS,CAAEN,KAAM,yBAAiCC,MAAOY,EAAEC,SAAS,EAElEC,EAA8BF,IACvBP,EAAA,CAAEN,KAAM,uBAA+BC,MAAOY,EAAEC,QAAU,QAAU,QAAQ,EAEnFE,EAAwBH,IAC1BP,EAAS,CAAEN,KAAM,wBAAyBC,MAAOY,EAAEC,SAAS,EAGhEG,OAAAA,EAAsBP,OAAOC,WAAWrB,GAAyBsB,GACjEK,EAAsBP,OAAOC,WAAWpB,GAA6BwB,GACrEE,EAAsBP,OAAOC,WAAWnB,GAAgBwB,GAEjD,KACHE,EAAyBR,OAAOC,WAAWrB,GAAyBsB,GACpEM,EAAyBR,OAAOC,WAAWpB,GAA6BwB,GACxEG,EAAyBR,OAAOC,WAAWnB,GAAgBwB,EAAoB,CAAA,GAEpF,CAACb,IAEG,IAAKL"}
@@ -0,0 +1,2 @@
1
+ import{useClickOutside as s}from"./useClickOutside.js";export{s as useClickOutside};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useEffect as e}from"react";function t(t,n){function c(e){null!=t&&t.current&&!t.current.contains(e.target)&&n()}e((()=>(t&&document&&document.addEventListener("click",c),()=>{document&&document.removeEventListener("click",c)})))}export{t as useClickOutside};
2
+ //# sourceMappingURL=useClickOutside.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useClickOutside.js","sources":["../../../../src/hooks/useClickOutside/useClickOutside.ts"],"sourcesContent":["import { RefObject, useEffect } from \"react\";\n\n/**\n * Hook for å sette opp en lytter ved klikk utenfor et element.\n * @param ref Elementet du ønsker å sjekke om en klikk er utenfor.\n * @param fn Callback-funksjon som kalles når det klikkes utenfor elementet.\n */\nexport function useClickOutside(ref: RefObject<HTMLElement> | null, fn: () => void): void {\n function handleClickOutside(event: MouseEvent) {\n if (ref?.current && !ref.current.contains(event.target as Node)) {\n fn();\n }\n }\n\n useEffect(() => {\n if (ref) {\n document && document.addEventListener(\"click\", handleClickOutside);\n }\n return () => {\n document && document.removeEventListener(\"click\", handleClickOutside);\n };\n });\n}\n"],"names":["useClickOutside","ref","fn","handleClickOutside","event","current","contains","target","useEffect","document","addEventListener","removeEventListener"],"mappings":"kCAOgB,SAAAA,EAAgBC,EAAoCC,GAChE,SAASC,EAAmBC,GACpB,MAAAH,GAAAA,EAAKI,UAAYJ,EAAII,QAAQC,SAASF,EAAMG,SACzCL,GAEX,CAEAM,GAAU,KACFP,GACYQ,UAAAA,SAASC,iBAAiB,QAASP,GAE5C,KACSM,UAAAA,SAASE,oBAAoB,QAASR,EAAkB,IAGhF"}
@@ -0,0 +1,2 @@
1
+ import{useElementDimensions as e}from"./useElementDimensions.js";export{e as useElementDimensions};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useRef as e,useState as t,useMemo as r,useEffect as n}from"react";function i(i=200){const o=e(null),[u,s]=t({height:0,width:0}),l=r((()=>function(e,t){let r=!1;return(...n)=>{if(r)return;const i=e(...n);return 0!==t&&(r=!0,window.setTimeout((()=>{r=!1}),t)),i}}((()=>{var e,t;return s({height:(null==(e=o.current)?void 0:e.scrollHeight)||0,width:(null==(t=o.current)?void 0:t.scrollWidth)||0})}),i)),[i]);return n((()=>{var e,t;return s({height:(null==(e=o.current)?void 0:e.scrollHeight)||0,width:(null==(t=o.current)?void 0:t.scrollWidth)||0}),typeof window<"u"&&window.addEventListener("resize",l),()=>{typeof window<"u"&&window.removeEventListener("resize",l)}}),[l]),[o,u]}export{i as useElementDimensions};
2
+ //# sourceMappingURL=useElementDimensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useElementDimensions.js","sources":["../../../../src/hooks/useElementDimensions/useElementDimensions.ts"],"sourcesContent":["import { RefObject, useEffect, useMemo, useRef, useState } from \"react\";\n\n// TODO: Denne er sikkert nyttig flere steder enn her!\n// eslint-disable-next-line\nfunction throttle<R, A extends any[]>(fn: (...args: A) => R, delay: number) {\n let wait = false;\n\n return (...args: A) => {\n if (wait) return undefined;\n\n const result = fn(...args);\n\n if (delay !== 0) {\n wait = true;\n window.setTimeout(() => {\n wait = false;\n }, delay);\n }\n\n return result;\n };\n}\n\nexport type Dimensions = {\n height: number;\n width: number;\n};\n\n/**\n * Lar deg måle størrelsen på et element, og oppdatere målene når vinduet endrer størrelse.\n * @param throttleDelay Antall milisekunder som skal gå mellom hver gang dimensjonene oppdateres.\n * @returns Ref til elementet som skal måles, og dimensjonene til elementet.\n */\nexport function useElementDimensions<T extends HTMLElement>(throttleDelay = 200): [RefObject<T>, Dimensions] {\n const elementRef = useRef<T>(null);\n const [dimensions, setDimensions] = useState<Dimensions>({ height: 0, width: 0 });\n\n const throttledSetDimensions = useMemo(\n () =>\n throttle(\n () =>\n setDimensions({\n height: elementRef.current?.scrollHeight || 0,\n width: elementRef.current?.scrollWidth || 0,\n }),\n throttleDelay,\n ),\n [throttleDelay],\n );\n\n useEffect(() => {\n setDimensions({\n height: elementRef.current?.scrollHeight || 0,\n width: elementRef.current?.scrollWidth || 0,\n });\n\n typeof window !== \"undefined\" && window.addEventListener(\"resize\", throttledSetDimensions);\n\n return () => {\n typeof window !== \"undefined\" && window.removeEventListener(\"resize\", throttledSetDimensions);\n };\n }, [throttledSetDimensions]);\n\n return [elementRef, dimensions];\n}\n"],"names":["useElementDimensions","throttleDelay","elementRef","useRef","dimensions","setDimensions","useState","height","width","throttledSetDimensions","useMemo","fn","delay","wait","args","result","window","setTimeout","throttle","_a","current","scrollHeight","_b","scrollWidth","useEffect","addEventListener","removeEventListener"],"mappings":"yEAiCgB,SAAAA,EAA4CC,EAAgB,KAClE,MAAAC,EAAaC,EAAU,OACtBC,EAAYC,GAAiBC,EAAqB,CAAEC,OAAQ,EAAGC,MAAO,IAEvEC,EAAyBC,GAC3B,IAlCR,SAAsCC,EAAuBC,GACzD,IAAIC,GAAO,EAEX,MAAO,IAAIC,KACP,GAAID,EAAa,OAEXE,MAAAA,EAASJ,KAAMG,GAErB,OAAc,IAAVF,IACOC,GAAA,EACPG,OAAOC,YAAW,KACPJ,GAAA,CAAA,GACRD,IAGAG,CAAAA,CAEf,CAkBYG,EACI,aACI,OAAAb,EAAc,CACVE,QAAQ,OAAAY,EAAAjB,EAAWkB,cAAX,EAAAD,EAAoBE,eAAgB,EAC5Cb,OAAO,OAAAc,EAAApB,EAAWkB,cAAX,EAAAE,EAAoBC,cAAe,GAC7C,GACLtB,IAER,CAACA,IAGL,OAAAuB,GAAU,aACQ,OAAAnB,EAAA,CACVE,QAAQ,OAAAY,EAAAjB,EAAWkB,cAAX,EAAAD,EAAoBE,eAAgB,EAC5Cb,OAAO,OAAAc,EAAApB,EAAWkB,cAAX,EAAAE,EAAoBC,cAAe,WAGvCP,OAAW,KAAeA,OAAOS,iBAAiB,SAAUhB,GAE5D,YACIO,OAAW,KAAeA,OAAOU,oBAAoB,SAAUjB,EAAsB,CAAA,GAEjG,CAACA,IAEG,CAACP,EAAYE,EACxB"}
@@ -0,0 +1,2 @@
1
+ import{useFocusOutside as s}from"./useFocusOutside.js";export{s as useFocusOutside};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useEffect as e}from"react";function t(t,n){function u(e){null!=t&&t.current&&!t.current.contains(e.target)&&n()}e((()=>(t&&document&&document.addEventListener("focusin",u),()=>{document&&document.removeEventListener("focusin",u)})))}export{t as useFocusOutside};
2
+ //# sourceMappingURL=useFocusOutside.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFocusOutside.js","sources":["../../../../src/hooks/useFocusOutside/useFocusOutside.ts"],"sourcesContent":["import { RefObject, useEffect } from \"react\";\n\n/**\n * Hook for å lytte etter fokus utenfor et element. Nyttig dersom flere fokuserbare elementer samspiller i en komponent.\n * @param ref Elementet som skal observeres\n * @param fn Funksjon som kalles når fokus flyttes utenfor elementet\n */\nexport function useFocusOutside(ref: RefObject<HTMLElement> | null, fn: () => void): void {\n function handleFocusOutside(event: FocusEvent) {\n if (ref?.current && !ref.current.contains(event.target as Node)) {\n fn();\n }\n }\n\n useEffect(() => {\n if (ref) {\n document && document.addEventListener(\"focusin\", handleFocusOutside);\n }\n return () => {\n document && document.removeEventListener(\"focusin\", handleFocusOutside);\n };\n });\n}\n"],"names":["useFocusOutside","ref","fn","handleFocusOutside","event","current","contains","target","useEffect","document","addEventListener","removeEventListener"],"mappings":"kCAOgB,SAAAA,EAAgBC,EAAoCC,GAChE,SAASC,EAAmBC,GACpB,MAAAH,GAAAA,EAAKI,UAAYJ,EAAII,QAAQC,SAASF,EAAMG,SACzCL,GAEX,CAEAM,GAAU,KACFP,GACYQ,UAAAA,SAASC,iBAAiB,UAAWP,GAE9C,KACSM,UAAAA,SAASE,oBAAoB,UAAWR,EAAkB,IAGlF"}
@@ -0,0 +1,2 @@
1
+ import{useId as s}from"./useId.js";export{s as useId};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import e from"react";const t=e.useId,r={generateSuffix:!0},s=(s,n=r)=>{const o=t();let u=s;s&&n.generateSuffix&&(u=`${s}-${o}`);const[a]=e.useState(u||o);return a};export{s as useId};
2
+ //# sourceMappingURL=useId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useId.js","sources":["../../../../src/hooks/useId/useId.ts"],"sourcesContent":["import React from \"react\";\n\nexport interface UseIdOptions {\n /** @default true */\n generateSuffix?: boolean;\n}\n\nconst useReactId = React.useId;\n\nconst defaultOptions: UseIdOptions = {\n generateSuffix: true,\n};\n\nconst useModernId = (id?: string, options = defaultOptions): string => {\n const uid = useReactId();\n let elementId: string | undefined = id;\n if (id && options.generateSuffix) {\n elementId = `${id}-${uid}`;\n }\n const [elId] = React.useState(elementId || uid);\n return elId;\n};\n\n/**\n * Hook som genererer en unik ID.\n * @param id En valgfri eksisterende ID som kan brukes som prefix.\n * @param options Objekt med innstillinger, dersom du angir et prefix.\n * @deprecated Bruk useId fra \"react\" pakka i stedet\n */\nexport const useId = useModernId;\n"],"names":["useReactId","React","useId","defaultOptions","generateSuffix","id","options","uid","elementId","elId","useState"],"mappings":"qBAOA,MAAMA,EAAaC,EAAMC,MAEnBC,EAA+B,CACjCC,gBAAgB,GAmBPF,EAhBO,CAACG,EAAaC,EAAUH,KACxC,MAAMI,EAAMP,IACZ,IAAIQ,EAAgCH,EAChCA,GAAMC,EAAQF,iBACFI,EAAA,GAAGH,KAAME,KAEzB,MAAOE,GAAQR,EAAMS,SAASF,GAAaD,GACpCE,OAAAA,CAAAA"}
@@ -0,0 +1,2 @@
1
+ import{useIntersectionObserver as e}from"./useIntersectionObserver.js";export{e as useIntersectionObserver};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useRef as e,useEffect as r}from"react";function n(e){return void 0!==e.forEach}const t=()=>typeof window<"u"&&typeof IntersectionObserver<"u",o=(o,c,s,u)=>{const i=e(null);r((()=>{let e=i.current;return t()?(e&&e.disconnect(),e=new IntersectionObserver(c,u),n(o)?o.forEach((r=>null==e?void 0:e.observe(r))):o.current&&n(o.current)?o.current.forEach((r=>null==e?void 0:e.observe(r))):o.current&&e.observe(o.current)):s&&s(),()=>{t()&&e&&e.disconnect()}}),[o,c,s,u])};export{o as useIntersectionObserver};
2
+ //# sourceMappingURL=useIntersectionObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntersectionObserver.js","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import { useEffect, useRef, RefObject, MutableRefObject } from \"react\";\n\ntype ValidElement = HTMLElement | SVGElement;\ntype Target =\n | MutableRefObject<ValidElement>\n | RefObject<ValidElement>\n | MutableRefObject<NodeListOf<ValidElement>>\n | RefObject<NodeListOf<ValidElement>>\n | NodeListOf<ValidElement>;\n\nfunction isNodeList(target: Target | ValidElement): target is NodeListOf<ValidElement> {\n return (target as NodeListOf<ValidElement>).forEach !== undefined;\n}\n\nconst hasWindowWithIntersectionObserver = () =>\n typeof window !== \"undefined\" && typeof IntersectionObserver !== \"undefined\";\n\n/**\n * Hook som gjør det enkelt å observere om et element er synlig i viewporten.\n *\n * @param target Elementet eller elementene som skal observeres. Du kan sende in en React ref til et HTMLElement eller SVG Element, eller en NodeList av samme type elementer (returneres f.eks. av document.querySelectorAll), eller en React ref med en NodeList av samme type elementer.\n * @param onIntersect Callback-funksjon som utføres når et av elementene som observeres overlapper angitt mål. Se https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#parameters for mer info.\n * @param fallback Funksjon som kalles dersom nettleseren ikke støtter IntersectionOpserver-APIet.\n * @param options Objekt med innstillinger for oberveren. Se https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#parameters for mer info.\n */\nexport const useIntersectionObserver = (\n target: Target,\n onIntersect: IntersectionObserverCallback,\n fallback?: VoidFunction | null,\n options?: Partial<IntersectionObserverInit>,\n): void => {\n const observerRef = useRef<IntersectionObserver>(null);\n\n useEffect(() => {\n let observer = observerRef.current;\n\n if (hasWindowWithIntersectionObserver()) {\n if (observer) {\n observer.disconnect();\n }\n\n observer = new IntersectionObserver(onIntersect, options);\n\n if (isNodeList(target)) {\n target.forEach((element) => observer?.observe(element));\n } else if (target.current && isNodeList(target.current)) {\n target.current.forEach((element) => observer?.observe(element));\n } else if (target.current) {\n observer.observe(target.current);\n }\n } else if (fallback) {\n fallback();\n }\n\n return () => {\n if (hasWindowWithIntersectionObserver() && observer) {\n observer.disconnect();\n }\n };\n }, [target, onIntersect, fallback, options]);\n};\n"],"names":["isNodeList","target","forEach","hasWindowWithIntersectionObserver","window","IntersectionObserver","useIntersectionObserver","onIntersect","fallback","options","observerRef","useRef","useEffect","observer","current","disconnect","element","observe"],"mappings":"8CAUA,SAASA,EAAWC,GAChB,YAAwD,IAAhDA,EAAoCC,OAChD,CAEA,MAAMC,EAAoC,WAC/BC,OAAW,YAAsBC,qBAAyB,IAUxDC,EAA0B,CACnCL,EACAM,EACAC,EACAC,KAEMC,MAAAA,EAAcC,EAA6B,MAEjDC,GAAU,KACN,IAAIC,EAAWH,EAAYI,QAEvBX,OAAAA,KACIU,GACAA,EAASE,aAGFF,EAAA,IAAIR,qBAAqBE,EAAaE,GAE7CT,EAAWC,GACXA,EAAOC,SAASc,GAAY,MAAAH,OAAAA,EAAAA,EAAUI,QAAQD,KACvCf,EAAOa,SAAWd,EAAWC,EAAOa,SAC3Cb,EAAOa,QAAQZ,SAASc,GAAY,MAAAH,OAAA,EAAAA,EAAUI,QAAQD,KAC/Cf,EAAOa,SACLD,EAAAI,QAAQhB,EAAOa,UAErBN,GACEA,IAGN,KACCL,KAAuCU,GACvCA,EAASE,YAAW,CACxB,GAEL,CAACd,EAAQM,EAAaC,EAAUC,GAAQ"}
@@ -0,0 +1,2 @@
1
+ import{useKeyListener as e}from"./useKeyListener.js";export{e as useKeyListener};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useEffect as e}from"react";function n(n,t,r){function o(e){t&&!t.includes(e.key)||r(e)}"string"==typeof t&&(t=[t]),e((()=>{const e=n&&n.current;return e&&e.addEventListener("keydown",o),()=>{e&&e.removeEventListener("keydown",o)}}))}export{n as useKeyListener};
2
+ //# sourceMappingURL=useKeyListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyListener.js","sources":["../../../../src/hooks/useKeyListener/useKeyListener.ts"],"sourcesContent":["import { RefObject, useEffect } from \"react\";\n\n/**\n * Lar deg sette opp en tastaturlytter på et element.\n * @param ref Element som skal observeres\n * @param keys Taster som skal lyttes på\n * @param fn Funksjon som kalles når en tastetrykk observeres\n */\nexport function useKeyListener(\n ref: RefObject<HTMLElement> | null,\n keys: string[] | string | null,\n fn: (event: KeyboardEvent) => void,\n): void {\n if (typeof keys === \"string\") {\n keys = [keys];\n }\n function handleKeyDown(event: KeyboardEvent) {\n if (keys && !keys.includes(event.key)) {\n return;\n }\n fn(event);\n }\n\n useEffect(() => {\n const element = ref && ref.current;\n if (element) {\n element.addEventListener(\"keydown\", handleKeyDown);\n }\n return () => {\n if (element) {\n element.removeEventListener(\"keydown\", handleKeyDown);\n }\n };\n });\n}\n"],"names":["useKeyListener","ref","keys","fn","handleKeyDown","event","includes","key","useEffect","element","current","addEventListener","removeEventListener"],"mappings":"kCAQgB,SAAAA,EACZC,EACAC,EACAC,GAKA,SAASC,EAAcC,GACfH,IAASA,EAAKI,SAASD,EAAME,MAGjCJ,EAAGE,EACP,CARoB,iBAATH,IACPA,EAAO,CAACA,IASZM,GAAU,KACAC,MAAAA,EAAUR,GAAOA,EAAIS,QAC3B,OAAID,GACQA,EAAAE,iBAAiB,UAAWP,GAEjC,KACCK,GACQA,EAAAG,oBAAoB,UAAWR,EAAa,CACxD,GAGZ"}
@@ -0,0 +1,2 @@
1
+ import{useListNavigation as i}from"./useListNavigation.js";export{i as useListNavigation};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useEffect as e}from"react";function t({ref:t}){e((()=>{const e={keys:""},n=t.current,s=t=>{n&&function({list:e,event:t,search:n,searchResetTimer:s}){const{key:o,target:c}=t,i={event:t,list:e,currentFocus:c};switch(o){case"ArrowUp":r("prev",i);break;case"ArrowDown":r("next",i);break;case"Home":r("first",i);break;case"End":r("last",i);break;case"Tab":t.preventDefault();break;case"Enter":break;default:if(void 0!==n){const t=function({list:e,key:t,search:r,searchResetTimer:n}){const s=e.querySelectorAll('[role="option"]');if(!s.length)return null;if(r){r.keys=r.keys.concat(t),function(e,t){t&&(clearTimeout(t),t=void 0),t=setTimeout((()=>{e?e.keys="":e={keys:""},t=void 0}),500,e,t)}(r,n);for(let e=0;e<s.length;e++){const t=s[e].innerText;if(t&&0===t.toLowerCase().indexOf(r.keys))return s[e]}}return null}({list:e,key:o,search:n,searchResetTimer:s});t&&t.focus()}}}({list:n,event:t,search:e,searchResetTimer:undefined})};return n&&n.addEventListener("keydown",s),()=>{n&&n.removeEventListener("keydown",s)}}),[t])}function r(e,{event:t,list:r,currentFocus:n}){t.preventDefault(),function(e,t,r){const n=r;switch(e){case"prev":const e=n&&n.previousElementSibling;e&&e.focus();break;case"next":const r=n&&n.nextElementSibling;r&&r.focus();break;case"first":const s=t.querySelector('[role="option"]');s&&s.focus();break;case"last":const o=t.querySelectorAll('[role="option"]');o.length&&o[o.length-1].focus()}}(e,r,n)}export{t as useListNavigation};
2
+ //# sourceMappingURL=useListNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useListNavigation.js","sources":["../../../../src/hooks/useListNavigation/useListNavigation.ts"],"sourcesContent":["import { useEffect, RefObject } from \"react\";\n\ntype Timer = number | undefined;\ntype KeyBuffer = { keys: string } | undefined;\ntype Direction = \"prev\" | \"next\" | \"first\" | \"last\";\ninterface MoveDetails {\n event: KeyboardEvent;\n list: HTMLElement;\n currentFocus: HTMLButtonElement;\n}\ninterface ListDetails {\n list: HTMLElement;\n search: KeyBuffer;\n searchResetTimer: Timer;\n}\ninterface SearchDetails extends ListDetails {\n key: string;\n}\ninterface EventDetails extends ListDetails {\n event: KeyboardEvent;\n}\ntype UseListNavigationProps<T> = {\n /** Ref til et element med rollen `listbox` */\n ref: RefObject<T>;\n};\n\nexport function useListNavigation<T extends HTMLElement>({ ref }: UseListNavigationProps<T>): void {\n useEffect(() => {\n let searchResetTimer: Timer;\n const search: KeyBuffer = { keys: \"\" }; // keypress buffer is an object to preserve state\n const list = ref.current;\n const handler = (event: KeyboardEvent) => {\n if (list) {\n handleListKeyNav({ list, event, search, searchResetTimer });\n }\n };\n\n if (list) {\n list.addEventListener(\"keydown\", handler);\n }\n\n return () => {\n if (list) {\n list.removeEventListener(\"keydown\", handler);\n }\n };\n }, [ref]);\n}\n\nfunction handleMoveTo(direction: Direction, { event, list, currentFocus }: MoveDetails) {\n event.preventDefault();\n moveFocusTo(direction, list, currentFocus);\n}\n\nfunction handleListKeyNav({ list, event, search, searchResetTimer }: EventDetails) {\n const { key, target } = event;\n const currentFocus = target as HTMLButtonElement;\n\n const moveDetails = {\n event,\n list,\n currentFocus,\n };\n\n switch (key) {\n case \"ArrowUp\" || \"PageUp\":\n handleMoveTo(\"prev\", moveDetails);\n break;\n case \"ArrowDown\" || \"PageDown\":\n handleMoveTo(\"next\", moveDetails);\n break;\n case \"Home\":\n handleMoveTo(\"first\", moveDetails);\n break;\n case \"End\":\n handleMoveTo(\"last\", moveDetails);\n break;\n case \"Tab\":\n // in a standard select, tab does nothing in-menu\n event.preventDefault();\n break;\n case \"Enter\" || \" \":\n break;\n\n default:\n if (search !== undefined) {\n const searchResult = findItem({ list, key, search, searchResetTimer });\n if (searchResult) {\n searchResult.focus();\n }\n }\n break;\n }\n}\n\nfunction moveFocusTo(direction: Direction, list: HTMLElement, current: HTMLButtonElement) {\n const thisOption = current;\n switch (direction) {\n case \"prev\":\n const prevOption: HTMLButtonElement | null =\n thisOption && (thisOption.previousElementSibling as HTMLButtonElement);\n if (prevOption) {\n prevOption.focus();\n }\n break;\n case \"next\":\n const nextOption: HTMLButtonElement | null =\n thisOption && (thisOption.nextElementSibling as HTMLButtonElement);\n if (nextOption) {\n nextOption.focus();\n }\n break;\n case \"first\":\n const firstItem = list.querySelector<HTMLButtonElement>(`[role=\"option\"]`);\n if (firstItem) {\n firstItem.focus();\n }\n break;\n case \"last\":\n const listItems = list.querySelectorAll<HTMLButtonElement>(`[role=\"option\"]`);\n if (listItems.length) {\n listItems[listItems.length - 1].focus();\n }\n break;\n }\n}\n\nfunction findItem({ list, key, search, searchResetTimer }: SearchDetails): HTMLButtonElement | null {\n const listItems = list.querySelectorAll(`[role=\"option\"]`);\n if (!listItems.length) return null;\n\n if (search) {\n search.keys = search.keys.concat(key);\n resetWhenIdle(search, searchResetTimer);\n\n for (let n = 0; n < listItems.length; n++) {\n const label = (listItems[n] as HTMLButtonElement).innerText;\n if (label && label.toLowerCase().indexOf(search.keys) === 0) {\n return listItems[n] as HTMLButtonElement;\n }\n }\n }\n\n return null;\n}\n\nfunction resetWhenIdle(search: KeyBuffer, timer: Timer) {\n if (timer) {\n clearTimeout(timer);\n timer = undefined;\n }\n timer = setTimeout(\n () => {\n search ? (search.keys = \"\") : (search = { keys: \"\" });\n timer = undefined;\n },\n 500,\n search,\n timer,\n );\n}\n"],"names":["useListNavigation","ref","useEffect","search","keys","list","current","handler","event","searchResetTimer","key","target","moveDetails","currentFocus","handleMoveTo","preventDefault","searchResult","listItems","querySelectorAll","length","concat","timer","clearTimeout","setTimeout","resetWhenIdle","n","label","innerText","toLowerCase","indexOf","findItem","focus","handleListKeyNav","addEventListener","removeEventListener","direction","thisOption","prevOption","previousElementSibling","nextOption","nextElementSibling","firstItem","querySelector","moveFocusTo"],"mappings":"kCA0BgB,SAAAA,GAA2CC,IAAAA,IACvDC,GAAU,KAEAC,MAAAA,EAAoB,CAAEC,KAAM,IAC5BC,EAAOJ,EAAIK,QACXC,EAAWC,IACTH,GAsBhB,UAA4BA,KAAAA,EAAMG,MAAAA,EAAOL,OAAAA,EAAQM,iBAAAA,IACvC,MAAEC,IAAAA,EAAKC,OAAAA,GAAWH,EAGlBI,EAAc,CAChBJ,MAAAA,EACAH,KAAAA,EACAQ,aALiBF,GAQrB,OAAQD,GACJ,IAAK,UACDI,EAAa,OAAQF,GACrB,MACJ,IAAK,YACDE,EAAa,OAAQF,GACrB,MACJ,IAAK,OACDE,EAAa,QAASF,GACtB,MACJ,IAAK,MACDE,EAAa,OAAQF,GACrB,MACJ,IAAK,MAEDJ,EAAMO,iBACN,MACJ,IAAK,QACD,MAEJ,QACI,QAAe,IAAXZ,EAAsB,CAChBa,MAAAA,EAyCtB,UAAoBX,KAAAA,EAAMK,IAAAA,EAAKP,OAAAA,EAAQM,iBAAAA,IAC7BQ,MAAAA,EAAYZ,EAAKa,iBAAiB,mBACpC,IAACD,EAAUE,OAAe,OAAA,KAE9B,GAAIhB,EAAQ,CACRA,EAAOC,KAAOD,EAAOC,KAAKgB,OAAOV,GAczC,SAAuBP,EAAmBkB,GAClCA,IACAC,aAAaD,GACLA,OAAA,GAEJA,EAAAE,YACJ,KACIpB,EAAUA,EAAOC,KAAO,GAAOD,EAAS,CAAEC,KAAM,IACxCiB,OAAA,CAAA,GAEZ,IACAlB,EACAkB,EAER,CA3BQG,CAAcrB,EAAQM,GAEtB,IAAA,IAASgB,EAAI,EAAGA,EAAIR,EAAUE,OAAQM,IAAK,CACjCC,MAAAA,EAAST,EAAUQ,GAAyBE,UAC9C,GAAAD,GAAsD,IAA7CA,EAAME,cAAcC,QAAQ1B,EAAOC,MAC5C,OAAOa,EAAUQ,EAEzB,CACJ,CAEO,OAAA,IACX,CA1DqCK,CAAS,CAAEzB,KAAAA,EAAMK,IAAAA,EAAKP,OAAAA,EAAQM,iBAAAA,IAC/CO,GACAA,EAAae,OAErB,EAGZ,CA5DgBC,CAAiB,CAAE3B,KAAAA,EAAMG,MAAAA,EAAOL,OAAAA,EAAQM,iBAL5CA,WAK8D,EAIlE,OAAIJ,GACKA,EAAA4B,iBAAiB,UAAW1B,GAG9B,KACCF,GACKA,EAAA6B,oBAAoB,UAAW3B,EAAO,CAC/C,GAEL,CAACN,GACR,CAEA,SAASa,EAAaqB,GAAwB3B,MAAAA,EAAOH,KAAAA,EAAMQ,aAAAA,IACvDL,EAAMO,iBA6CV,SAAqBoB,EAAsB9B,EAAmBC,GAC1D,MAAM8B,EAAa9B,EACnB,OAAQ6B,GACJ,IAAK,OACKE,MAAAA,EACFD,GAAeA,EAAWE,uBAC1BD,GACAA,EAAWN,QAEf,MACJ,IAAK,OACKQ,MAAAA,EACFH,GAAeA,EAAWI,mBAC1BD,GACAA,EAAWR,QAEf,MACJ,IAAK,QACKU,MAAAA,EAAYpC,EAAKqC,cAAiC,mBACpDD,GACAA,EAAUV,QAEd,MACJ,IAAK,OACKd,MAAAA,EAAYZ,EAAKa,iBAAoC,mBACvDD,EAAUE,QACVF,EAAUA,EAAUE,OAAS,GAAGY,QAIhD,CA1EgBY,CAAAR,EAAW9B,EAAMQ,EACjC"}
@@ -0,0 +1,2 @@
1
+ import{useLocalStorage as o}from"./useLocalStorage.js";export{o as useLocalStorage};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useState as t,useCallback as e}from"react";const o=(o,a)=>{const[l,r]=t((()=>typeof window>"u"||!localStorage?a:JSON.parse(localStorage.getItem(o)||"null")||a));return[l,e((t=>{r(t),typeof window<"u"&&localStorage&&localStorage.setItem(o,JSON.stringify(t))}),[o])]};export{o as useLocalStorage};
2
+ //# sourceMappingURL=useLocalStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalStorage.js","sources":["../../../../src/hooks/useLocalStorage/useLocalStorage.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\nexport const useLocalStorage = <T>(key: string, defaultValue: T): [T, (newValue: T) => void] => {\n const [state, setState] = useState(() => {\n if (typeof window === \"undefined\" || !localStorage) {\n return defaultValue;\n }\n const storedValue = JSON.parse(localStorage.getItem(key) || \"null\");\n return storedValue || defaultValue;\n });\n\n const updateState = useCallback(\n (newValue: T) => {\n setState(newValue);\n if (typeof window !== \"undefined\" && localStorage) {\n localStorage.setItem(key, JSON.stringify(newValue));\n }\n },\n [key],\n );\n\n return [state, updateState];\n};\n"],"names":["useLocalStorage","key","defaultValue","state","setState","useState","window","localStorage","JSON","parse","getItem","useCallback","newValue","setItem","stringify"],"mappings":"kDAEa,MAAAA,EAAkB,CAAIC,EAAaC,KACtC,MAACC,EAAOC,GAAYC,GAAS,WACpBC,OAAW,MAAgBC,aAC3BL,EAESM,KAAKC,MAAMF,aAAaG,QAAQT,IAAQ,SACtCC,IAanB,MAAA,CAACC,EAVYQ,GACfC,IACGR,EAASQ,UACEN,OAAW,KAAeC,cACjCA,aAAaM,QAAQZ,EAAKO,KAAKM,UAAUF,GAAS,GAG1D,CAACX,IAGqB"}
@@ -0,0 +1,2 @@
1
+ import{useMutationObserver as e}from"./useMutationObserver.js";export{e as useMutationObserver};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useRef as e,useEffect as t}from"react";const r=()=>typeof window<"u"&&typeof MutationObserver<"u",n=(n,o,s)=>{const u=e(null);t((()=>{let e=u.current;if(r()){const t=n.current;e&&e.disconnect(),e=new MutationObserver(o),t&&e.observe(t,s)}return()=>{r()&&e&&e.disconnect()}}),[n,o,s])};export{n as useMutationObserver};
2
+ //# sourceMappingURL=useMutationObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMutationObserver.js","sources":["../../../../src/hooks/useMutationObserver/useMutationObserver.ts"],"sourcesContent":["import { useEffect, useRef, RefObject } from \"react\";\n\nconst hasWindowWithMutationObserver = () => typeof window !== \"undefined\" && typeof MutationObserver !== \"undefined\";\n\n/**\n * Hook som gjør det enklere å sjekke en komponents children for endringer.\n *\n * @param targetRef Container som skal observeres. Containeren må ikke rerendres, da vil observereren bli opprettet på nytt.\n * @param onObservation Callback-funksjon som utføres når en mutasjon observeres.\n * @param config Parametere til observereren. Se https://developer.mozilla.org/en-US/docs/Web/API/MutationObserverInit#properties for mer info.\n */\nexport const useMutationObserver = (\n targetRef: RefObject<HTMLElement>,\n onObservation: MutationCallback,\n config?: Partial<MutationObserverInit>,\n): void => {\n const observerRef = useRef<MutationObserver>(null);\n\n useEffect(() => {\n let observer = observerRef.current;\n\n if (hasWindowWithMutationObserver()) {\n const target = targetRef.current;\n\n if (observer) {\n observer.disconnect();\n }\n\n observer = new MutationObserver(onObservation);\n\n if (target) {\n observer.observe(target, config);\n }\n }\n return () => {\n if (hasWindowWithMutationObserver() && observer) {\n observer.disconnect();\n }\n };\n }, [targetRef, onObservation, config]);\n};\n"],"names":["hasWindowWithMutationObserver","window","MutationObserver","useMutationObserver","targetRef","onObservation","config","observerRef","useRef","useEffect","observer","current","target","disconnect","observe"],"mappings":"8CAEA,MAAMA,EAAgC,WAAaC,OAAW,YAAsBC,iBAAqB,IAS5FC,EAAsB,CAC/BC,EACAC,EACAC,KAEMC,MAAAA,EAAcC,EAAyB,MAE7CC,GAAU,KACN,IAAIC,EAAWH,EAAYI,QAE3B,GAAIX,IAAiC,CACjC,MAAMY,EAASR,EAAUO,QAErBD,GACAA,EAASG,aAGFH,EAAA,IAAIR,iBAAiBG,GAE5BO,GACSF,EAAAI,QAAQF,EAAQN,EAEjC,CACA,MAAO,KACCN,KAAmCU,GACnCA,EAASG,YAAW,CACxB,GAEL,CAACT,EAAWC,EAAeC,GAAO"}
@@ -0,0 +1,2 @@
1
+ import{usePreviousValue as e}from"./usePreviousValue.js";export{e as usePreviousValue};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useRef as e,useEffect as r}from"react";const s=s=>{const t=e();return r((()=>{t.current=s})),t.current};export{s as usePreviousValue};
2
+ //# sourceMappingURL=usePreviousValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreviousValue.js","sources":["../../../../src/hooks/usePreviousValue/usePreviousValue.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\n/**\n * Lar deg huske en verdi fra forrige render.\n * @param value Verdien som skal huskes.\n * @returns Forrige render av verdien, eller undefined første render.\n */\nexport const usePreviousValue = <T>(value: T): T | undefined => {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n });\n\n return ref.current;\n};\n"],"names":["usePreviousValue","value","ref","useRef","useEffect","current"],"mappings":"8CAOa,MAAAA,EAAuBC,IAChC,MAAMC,EAAMC,IAEZ,OAAAC,GAAU,KACNF,EAAIG,QAAUJ,CAAAA,IAGXC,EAAIG,OAAA"}
@@ -0,0 +1,2 @@
1
+ import{useProgressiveImg as s}from"./useProgressiveImg.js";export{s as useProgressiveImg};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useState as r,useEffect as s}from"react";const e=({lowQualitySrc:e,highQualitySrc:t})=>{const[o,a]=r(e);return s((()=>{a(e);const r=new Image;r.src=t,r.onload=()=>{a(t)}}),[e,t]),{src:o,isBlurred:o===e}};export{e as useProgressiveImg};
2
+ //# sourceMappingURL=useProgressiveImg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProgressiveImg.js","sources":["../../../../src/hooks/useProgressiveImg/useProgressiveImg.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\nexport interface ProgressiveImageProps {\n lowQualitySrc: string;\n highQualitySrc: string;\n}\n\ntype ProgressiveImage = { src: string; isBlurred: boolean };\n\nexport const useProgressiveImg = ({ lowQualitySrc, highQualitySrc }: ProgressiveImageProps): ProgressiveImage => {\n const [src, setSrc] = useState(lowQualitySrc);\n\n useEffect(() => {\n setSrc(lowQualitySrc);\n const img = new Image();\n img.src = highQualitySrc;\n\n img.onload = () => {\n setSrc(highQualitySrc);\n };\n }, [lowQualitySrc, highQualitySrc]);\n\n return { src, isBlurred: src === lowQualitySrc };\n};\n"],"names":["useProgressiveImg","lowQualitySrc","highQualitySrc","src","setSrc","useState","useEffect","img","Image","onload","isBlurred"],"mappings":"gDASO,MAAMA,EAAoB,EAAGC,cAAAA,EAAeC,eAAAA,MAC/C,MAAOC,EAAKC,GAAUC,EAASJ,GAE/B,OAAAK,GAAU,KACNF,EAAOH,GACDM,MAAAA,EAAM,IAAIC,MAChBD,EAAIJ,IAAMD,EAEVK,EAAIE,OAAS,KACTL,EAAOF,EAAc,CAAA,GAE1B,CAACD,EAAeC,IAEZ,CAAEC,IAAAA,EAAKO,UAAWP,IAAQF,EAAc"}
@@ -0,0 +1,2 @@
1
+ import{useScreen as e}from"./useScreen.js";export{e as useScreen};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ var e=(e=>(e.orientation="ORIENTATION_CHANGED",e.deviceSize="DEVICE_SIZE_CHANGED",e))(e||{});function i(e){return{isSmallDevice:"isSmallDevice"===e,isMediumDevice:"isMediumDevice"===e,isLargeDevice:"isLargeDevice"===e,isXlDevice:"isXlDevice"===e}}function r(e){return{isLandscape:"isLandscape"===e,isPortrait:"isPortrait"===e}}const t=(e,t)=>{switch(t.type){case"ORIENTATION_CHANGED":return{...e,...r(t.property)};case"DEVICE_SIZE_CHANGED":return{...e,...i(t.property)};default:return e}};export{e as ActionType,t as reducer};
2
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sources":["../../../../src/hooks/useScreen/state.ts"],"sourcesContent":["export interface ScreenState {\n isSmallDevice: boolean;\n isMediumDevice: boolean;\n isLargeDevice: boolean;\n isXlDevice: boolean;\n isLandscape: boolean;\n isPortrait: boolean;\n}\n\nexport enum ActionType {\n orientation = \"ORIENTATION_CHANGED\",\n deviceSize = \"DEVICE_SIZE_CHANGED\",\n}\n\nexport interface ScreenAction {\n type: ActionType;\n property: keyof ScreenState;\n}\n\nfunction setDeviceSize(deviceSize: keyof ScreenState): Omit<ScreenState, \"isLandscape\" | \"isPortrait\"> {\n return {\n isSmallDevice: deviceSize === \"isSmallDevice\",\n isMediumDevice: deviceSize === \"isMediumDevice\",\n isLargeDevice: deviceSize === \"isLargeDevice\",\n isXlDevice: deviceSize === \"isXlDevice\",\n };\n}\n\nfunction setOrientation(orientation: keyof ScreenState): Pick<ScreenState, \"isLandscape\" | \"isPortrait\"> {\n return {\n isLandscape: orientation === \"isLandscape\",\n isPortrait: orientation === \"isPortrait\",\n };\n}\n\nexport const reducer = (state: ScreenState, action: ScreenAction): ScreenState => {\n switch (action.type) {\n case ActionType.orientation:\n return {\n ...state,\n ...setOrientation(action.property),\n };\n case ActionType.deviceSize:\n return {\n ...state,\n ...setDeviceSize(action.property),\n };\n default:\n return state;\n }\n};\n"],"names":["ActionType","orientation","deviceSize","setDeviceSize","isSmallDevice","isMediumDevice","isLargeDevice","isXlDevice","setOrientation","isLandscape","isPortrait","reducer","state","action","type","property"],"mappings":"AASY,IAAAA,GAAAA,IACRA,EAAAC,YAAc,sBACdD,EAAAE,WAAa,sBAFLF,IAAAA,GAAA,CAAA,GAUZ,SAASG,EAAcD,GACZ,MAAA,CACHE,cAA8B,kBAAfF,EACfG,eAA+B,mBAAfH,EAChBI,cAA8B,kBAAfJ,EACfK,WAA2B,eAAfL,EAEpB,CAEA,SAASM,EAAeP,GACb,MAAA,CACHQ,YAA6B,gBAAhBR,EACbS,WAA4B,eAAhBT,EAEpB,CAEa,MAAAU,EAAU,CAACC,EAAoBC,KACxC,OAAQA,EAAOC,MACX,IAAK,sBACM,MAAA,IACAF,KACAJ,EAAeK,EAAOE,WAEjC,IAAK,sBACM,MAAA,IACAH,KACAT,EAAcU,EAAOE,WAEhC,QACWH,OAAAA,EACf"}
@@ -0,0 +1,2 @@
1
+ import{useState as e,useReducer as i,useEffect as a,useCallback as t}from"react";import{breakpoints as r}from"../../core/utils/breakpoints.js";import{getInitialMediaQueryMatch as s,addMediaQueryListener as n,removeMediaQueryListener as o}from"../mediaQueryUtils.js";import{reducer as c,ActionType as m}from"./state.js";const d={isSmallDevice:`(max-width: ${r.medium-1}px)`,isMediumDevice:`(min-width: ${r.medium}px) and (max-width: ${r.large-1}px)`,isLargeDevice:`(min-width: ${r.large}px) and (max-width: ${r.xl-1}px)`,isXlDevice:`(min-width: ${r.xl}px)`,isPortrait:"(orientation: portrait)",isLandscape:"(orientation: landscape)"},p=e=>({type:"isLandscape"===e||"isPortrait"===e?m.orientation:m.deviceSize,property:e}),u=()=>{const[r,m]=e(!1),[u,l]=i(c,{isSmallDevice:!1,isMediumDevice:!1,isLargeDevice:!1,isXlDevice:!1,isLandscape:!1,isPortrait:!1});a((()=>{m(!0),Object.entries(d).map((([e,i])=>[e,s(i)])).forEach((([e,i])=>{i&&l(p(e))}))}),[]);const h=t((e=>i=>{requestAnimationFrame((()=>{i.matches&&l(p(e))}))}),[]);return a((()=>{if(!r||!window.matchMedia)return;const e=[];return Object.entries(d).forEach((([i,a])=>{const t=window.matchMedia(a),r=h(i);e.push([t,r]),n(t,r)})),()=>{e.forEach((([e,i])=>o(e,i)))}}),[h,r]),{...u}};export{u as useScreen};
2
+ //# sourceMappingURL=useScreen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScreen.js","sources":["../../../../src/hooks/useScreen/useScreen.ts"],"sourcesContent":["import { useCallback, useEffect, useReducer, useState } from \"react\";\nimport { breakpoints } from \"../../core\";\nimport { addMediaQueryListener, getInitialMediaQueryMatch, removeMediaQueryListener } from \"../mediaQueryUtils\";\nimport { ScreenAction, ActionType, reducer, ScreenState } from \"./state\";\n\nconst MEDIA_RULES: Record<keyof ScreenState, string> = {\n isSmallDevice: `(max-width: ${breakpoints.medium - 1}px)`,\n isMediumDevice: `(min-width: ${breakpoints.medium}px) and (max-width: ${breakpoints.large - 1}px)`,\n isLargeDevice: `(min-width: ${breakpoints.large}px) and (max-width: ${breakpoints.xl - 1}px)`,\n isXlDevice: `(min-width: ${breakpoints.xl}px)`,\n isPortrait: \"(orientation: portrait)\",\n isLandscape: \"(orientation: landscape)\",\n};\n\nconst createAction = (property: keyof ScreenState): ScreenAction => ({\n type: property === \"isLandscape\" || property === \"isPortrait\" ? ActionType.orientation : ActionType.deviceSize,\n property,\n});\n\n/**\n * Finn størrelsen og orienteringen til skjermen.\n * @returns Et objekt med boolean som indikerer om skjermstørrelsen er liten, medium, stor eller ekstra stor, og om skjermen er i portrett- eller landskapsmodus.\n */\nexport const useScreen = (): ScreenState => {\n const [hasMounted, setHasMounted] = useState(false);\n\n const [device, deviceDispatch] = useReducer(reducer, {\n isSmallDevice: false,\n isMediumDevice: false,\n isLargeDevice: false,\n isXlDevice: false,\n isLandscape: false,\n isPortrait: false,\n });\n\n useEffect(() => {\n setHasMounted(true);\n Object.entries(MEDIA_RULES)\n .map(([key, rule]) => [key, getInitialMediaQueryMatch(rule)])\n .forEach(([key, value]) => {\n if (value) {\n deviceDispatch(createAction(key as keyof ScreenState));\n }\n });\n }, []);\n\n const createListener = useCallback(\n (key: keyof ScreenState) => (e: MediaQueryListEvent) => {\n requestAnimationFrame(() => {\n if (e.matches) {\n deviceDispatch(createAction(key));\n }\n });\n },\n [],\n );\n\n useEffect(() => {\n if (!hasMounted || !window.matchMedia) {\n return;\n }\n const eventListenerPairs: Array<[MediaQueryList, (e: MediaQueryListEvent) => void]> = [];\n\n Object.entries(MEDIA_RULES).forEach(([key, rule]) => {\n const queryList = window.matchMedia(rule);\n const listener = createListener(key as keyof ScreenState);\n eventListenerPairs.push([queryList, listener]);\n addMediaQueryListener(queryList, listener);\n });\n\n return () => {\n eventListenerPairs.forEach(([queryList, listener]) => removeMediaQueryListener(queryList, listener));\n };\n }, [createListener, hasMounted]);\n\n return { ...device };\n};\n"],"names":["MEDIA_RULES","isSmallDevice","breakpoints","medium","isMediumDevice","large","isLargeDevice","xl","isXlDevice","isPortrait","isLandscape","createAction","property","type","ActionType","orientation","deviceSize","useScreen","hasMounted","setHasMounted","useState","device","deviceDispatch","useReducer","reducer","useEffect","Object","entries","map","key","rule","getInitialMediaQueryMatch","forEach","value","createListener","useCallback","e","requestAnimationFrame","matches","window","matchMedia","eventListenerPairs","queryList","listener","push","addMediaQueryListener","removeMediaQueryListener"],"mappings":"+TAKA,MAAMA,EAAiD,CACnDC,cAAe,eAAeC,EAAYC,OAAS,OACnDC,eAAgB,eAAeF,EAAYC,6BAA6BD,EAAYG,MAAQ,OAC5FC,cAAe,eAAeJ,EAAYG,4BAA4BH,EAAYK,GAAK,OACvFC,WAAY,eAAeN,EAAYK,QACvCE,WAAY,0BACZC,YAAa,4BAGXC,EAAgBC,IAA+C,CACjEC,KAAmB,gBAAbD,GAA2C,eAAbA,EAA4BE,EAAWC,YAAcD,EAAWE,WACpGJ,SAAAA,IAOSK,EAAY,KACrB,MAAOC,EAAYC,GAAiBC,GAAS,IAEtCC,EAAQC,GAAkBC,EAAWC,EAAS,CACjDvB,eAAe,EACfG,gBAAgB,EAChBE,eAAe,EACfE,YAAY,EACZE,aAAa,EACbD,YAAY,IAGhBgB,GAAU,KACNN,GAAc,GACPO,OAAAC,QAAQ3B,GACV4B,KAAI,EAAEC,EAAKC,KAAU,CAACD,EAAKE,EAA0BD,MACrDE,SAAQ,EAAEH,EAAKI,MACRA,GACeX,EAAAX,EAAakB,GAAyB,GAE5D,GACN,IAEH,MAAMK,EAAiBC,GAClBN,GAA4BO,IACzBC,uBAAsB,KACdD,EAAEE,SACahB,EAAAX,EAAakB,GAAI,GAEvC,GAEL,IAGJ,OAAAJ,GAAU,KACF,IAACP,IAAeqB,OAAOC,WACvB,OAEJ,MAAMC,EAAgF,GAE/E,OAAAf,OAAAC,QAAQ3B,GAAagC,SAAQ,EAAEH,EAAKC,MACjC,MAAAY,EAAYH,OAAOC,WAAWV,GAC9Ba,EAAWT,EAAeL,GAChCY,EAAmBG,KAAK,CAACF,EAAWC,IACpCE,EAAsBH,EAAWC,EAAQ,IAGtC,KACgBF,EAAAT,SAAQ,EAAEU,EAAWC,KAAcG,EAAyBJ,EAAWC,IAAS,CAAA,GAExG,CAACT,EAAgBhB,IAEb,IAAKG"}
@@ -0,0 +1,2 @@
1
+ import{useScrollIntoView as o}from"./useScrollIntoView.js";export{o as useScrollIntoView};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{useEffect as t}from"react";const o=({ref:o,timeout:r=0,autoScroll:e=!0,options:n={behavior:"smooth"}})=>{const u=()=>{null!=o&&o.current&&o.current.scrollIntoView(n)};return t((()=>{if(!e)return;const t=setTimeout(u,r);return()=>clearTimeout(t)}),[o,r,e]),[u]};export{o as useScrollIntoView};
2
+ //# sourceMappingURL=useScrollIntoView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollIntoView.js","sources":["../../../../src/hooks/useScrollIntoView/useScrollIntoView.tsx"],"sourcesContent":["import { useEffect, RefObject } from \"react\";\n\ntype ValueOf<T> = T[keyof T];\n\nexport interface ScrollIntoViewProps {\n ref: RefObject<ValueOf<HTMLElementTagNameMap>>;\n timeout?: number;\n autoScroll?: boolean;\n options?: ScrollIntoViewOptions;\n}\n\ntype ScrollFunction = () => void;\n\nexport const useScrollIntoView = ({\n ref,\n timeout = 0,\n autoScroll = true,\n options = { behavior: \"smooth\" },\n}: ScrollIntoViewProps): [ScrollFunction] => {\n const scrollIntoView: ScrollFunction = () => {\n if (ref?.current) {\n ref.current.scrollIntoView(options);\n }\n };\n useEffect(() => {\n if (!autoScroll) {\n return;\n }\n const scrollFn = setTimeout(scrollIntoView, timeout);\n return () => clearTimeout(scrollFn);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ref, timeout, autoScroll]);\n\n return [scrollIntoView];\n};\n"],"names":["useScrollIntoView","ref","timeout","autoScroll","options","behavior","scrollIntoView","current","useEffect","scrollFn","setTimeout","clearTimeout"],"mappings":"kCAaO,MAAMA,EAAoB,EAC7BC,IAAAA,EACAC,QAAAA,EAAU,EACVC,WAAAA,GAAa,EACbC,QAAAA,EAAU,CAAEC,SAAU,cAEtB,MAAMC,EAAiC,KAC/B,MAAAL,GAAAA,EAAKM,SACDN,EAAAM,QAAQD,eAAeF,EAAO,EAG1C,OAAAI,GAAU,KACN,IAAKL,EACD,OAEEM,MAAAA,EAAWC,WAAWJ,EAAgBJ,GACrC,MAAA,IAAMS,aAAaF,EAAQ,GAEnC,CAACR,EAAKC,EAASC,IAEX,CAACG,EAAc"}
@@ -0,0 +1,2 @@
1
+ import{useSwipeGesture as e}from"./useSwipeGesture.js";export{e as useSwipeGesture};
2
+ //# sourceMappingURL=index.js.map