@helsenorge/designsystem-react 2.14.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/Avatar.js +1 -1
  2. package/Avatar.js.map +1 -1
  3. package/Button.js +1 -1
  4. package/Button.js.map +1 -1
  5. package/CHANGELOG.md +34 -1
  6. package/ErrorWrapper.js +1 -1
  7. package/ErrorWrapper.js.map +1 -1
  8. package/FormGroup.js +1 -1
  9. package/FormGroup.js.map +1 -1
  10. package/HorizontalScroll.js +1 -1
  11. package/HorizontalScroll.js.map +1 -1
  12. package/Input.js +1 -1
  13. package/Input.js.map +1 -1
  14. package/ListHeader.js +1 -1
  15. package/ListHeader.js.map +1 -1
  16. package/ListHeaderText.js +1 -1
  17. package/MaxCharacters.js +2 -0
  18. package/MaxCharacters.js.map +1 -0
  19. package/Panel.js +1 -1
  20. package/Panel.js.map +1 -1
  21. package/StatusDot.js +1 -1
  22. package/StatusDot.js.map +1 -1
  23. package/TableExpandedRow.js +1 -1
  24. package/TableExpandedRow.js.map +1 -1
  25. package/TableExpanderCell.js +1 -1
  26. package/TableExpanderCell.js.map +1 -1
  27. package/TableRow.js +1 -1
  28. package/TableRow.js.map +1 -1
  29. package/Textarea.js +1 -1
  30. package/Textarea.js.map +1 -1
  31. package/components/Avatar/Avatar.d.ts +6 -0
  32. package/components/Avatar/Avatar.d.ts.map +1 -1
  33. package/components/Avatar/componentdata.json +1 -1
  34. package/components/Avatar/index.js +1 -1
  35. package/components/Avatar/styles.module.scss +18 -3
  36. package/components/Avatar/styles.module.scss.d.ts +2 -0
  37. package/components/ErrorWrapper/ErrorWrapper.d.ts +4 -0
  38. package/components/ErrorWrapper/ErrorWrapper.d.ts.map +1 -1
  39. package/components/ErrorWrapper/componentdata.json +1 -1
  40. package/components/ExpanderList/index.js +1 -1
  41. package/components/ExpanderList/index.js.map +1 -1
  42. package/components/FormExample/index.js +3 -3
  43. package/components/FormExample/index.js.map +1 -1
  44. package/components/FormExample/styles.module.scss +17 -11
  45. package/components/FormExample/styles.module.scss.d.ts +4 -3
  46. package/components/FormGroup/FormGroup.d.ts +4 -0
  47. package/components/FormGroup/FormGroup.d.ts.map +1 -1
  48. package/components/FormGroup/componentdata.json +1 -1
  49. package/components/FormGroup/index.js +1 -1
  50. package/components/HorizontalScroll/HorizontalScroll.d.ts +2 -0
  51. package/components/HorizontalScroll/HorizontalScroll.d.ts.map +1 -1
  52. package/components/HorizontalScroll/componentdata.json +1 -1
  53. package/components/HorizontalScroll/styles.module.scss +5 -0
  54. package/components/Icons/AcupunctureBack.js +1 -1
  55. package/components/Icons/AcupunctureBack.js.map +1 -1
  56. package/components/Icons/AlarmClock.js +1 -1
  57. package/components/Icons/AlarmClock.js.map +1 -1
  58. package/components/Icons/AlertSignFill.js +1 -1
  59. package/components/Icons/AlertSignFill.js.map +1 -1
  60. package/components/Icons/AlertSignStroke.js +1 -1
  61. package/components/Icons/AlertSignStroke.js.map +1 -1
  62. package/components/Icons/Archive.js +1 -1
  63. package/components/Icons/Archive.js.map +1 -1
  64. package/components/Icons/ArrowDown.js +1 -1
  65. package/components/Icons/ArrowDown.js.map +1 -1
  66. package/components/Icons/ArrowLeft.d.ts.map +1 -1
  67. package/components/Icons/ArrowLeft.js +1 -1
  68. package/components/Icons/ArrowLeft.js.map +1 -1
  69. package/components/Icons/ArrowRight.d.ts.map +1 -1
  70. package/components/Icons/ArrowRight.js +1 -1
  71. package/components/Icons/ArrowRight.js.map +1 -1
  72. package/components/Icons/ArrowUp.js +1 -1
  73. package/components/Icons/ArrowUp.js.map +1 -1
  74. package/components/Icons/ArrowUpRight.js +1 -1
  75. package/components/Icons/ArrowUpRight.js.map +1 -1
  76. package/components/Icons/Attachment.d.ts.map +1 -1
  77. package/components/Icons/Attachment.js +1 -1
  78. package/components/Icons/Attachment.js.map +1 -1
  79. package/components/Icons/Avatar.js +1 -1
  80. package/components/Icons/Avatar.js.map +1 -1
  81. package/components/Icons/Bus.js +1 -1
  82. package/components/Icons/Bus.js.map +1 -1
  83. package/components/Icons/Calendar.js +1 -1
  84. package/components/Icons/Calendar.js.map +1 -1
  85. package/components/Icons/CalendarChange.js +1 -1
  86. package/components/Icons/CalendarChange.js.map +1 -1
  87. package/components/Icons/CalendarCheck.js +1 -1
  88. package/components/Icons/CalendarCheck.js.map +1 -1
  89. package/components/Icons/CalendarSave.js +1 -1
  90. package/components/Icons/CalendarSave.js.map +1 -1
  91. package/components/Icons/Change.js +1 -1
  92. package/components/Icons/Change.js.map +1 -1
  93. package/components/Icons/Check.js +1 -1
  94. package/components/Icons/Check.js.map +1 -1
  95. package/components/Icons/CheckFill.js +1 -1
  96. package/components/Icons/CheckFill.js.map +1 -1
  97. package/components/Icons/ChevronDown.js +1 -1
  98. package/components/Icons/ChevronDown.js.map +1 -1
  99. package/components/Icons/ChevronLeft.js +1 -1
  100. package/components/Icons/ChevronLeft.js.map +1 -1
  101. package/components/Icons/ChevronRight.js +1 -1
  102. package/components/Icons/ChevronRight.js.map +1 -1
  103. package/components/Icons/ChevronUp.js +1 -1
  104. package/components/Icons/ChevronUp.js.map +1 -1
  105. package/components/Icons/ChevronsDown.js +1 -1
  106. package/components/Icons/ChevronsDown.js.map +1 -1
  107. package/components/Icons/ChevronsUp.js +1 -1
  108. package/components/Icons/ChevronsUp.js.map +1 -1
  109. package/components/Icons/Contacts.js +1 -1
  110. package/components/Icons/Contacts.js.map +1 -1
  111. package/components/Icons/Copy.js +1 -1
  112. package/components/Icons/Copy.js.map +1 -1
  113. package/components/Icons/Download.js +1 -1
  114. package/components/Icons/Download.js.map +1 -1
  115. package/components/Icons/EChat.js +1 -1
  116. package/components/Icons/EChat.js.map +1 -1
  117. package/components/Icons/EmoticonAnnoyed.js +1 -1
  118. package/components/Icons/EmoticonAnnoyed.js.map +1 -1
  119. package/components/Icons/EmoticonDelighted.js +1 -1
  120. package/components/Icons/EmoticonDelighted.js.map +1 -1
  121. package/components/Icons/EmoticonDisappointed.js +1 -1
  122. package/components/Icons/EmoticonDisappointed.js.map +1 -1
  123. package/components/Icons/EmoticonHappy.js +1 -1
  124. package/components/Icons/EmoticonHappy.js.map +1 -1
  125. package/components/Icons/EmoticonMeh.js +1 -1
  126. package/components/Icons/EmoticonMeh.js.map +1 -1
  127. package/components/Icons/EnterFullScreen.js +1 -1
  128. package/components/Icons/EnterFullScreen.js.map +1 -1
  129. package/components/Icons/Envelope.js +1 -1
  130. package/components/Icons/Envelope.js.map +1 -1
  131. package/components/Icons/Eraser.js +1 -1
  132. package/components/Icons/Eraser.js.map +1 -1
  133. package/components/Icons/ErrorSignFill.js +1 -1
  134. package/components/Icons/ErrorSignFill.js.map +1 -1
  135. package/components/Icons/ErrorSignStroke.js +1 -1
  136. package/components/Icons/ErrorSignStroke.js.map +1 -1
  137. package/components/Icons/ExitFullScreen.js +1 -1
  138. package/components/Icons/ExitFullScreen.js.map +1 -1
  139. package/components/Icons/Eye.js +1 -1
  140. package/components/Icons/Eye.js.map +1 -1
  141. package/components/Icons/Filter.js +1 -1
  142. package/components/Icons/Filter.js.map +1 -1
  143. package/components/Icons/Form.js +1 -1
  144. package/components/Icons/Form.js.map +1 -1
  145. package/components/Icons/Forward.js +1 -1
  146. package/components/Icons/Forward.js.map +1 -1
  147. package/components/Icons/Gallery.js +1 -1
  148. package/components/Icons/Gallery.js.map +1 -1
  149. package/components/Icons/Globe.js +1 -1
  150. package/components/Icons/Globe.js.map +1 -1
  151. package/components/Icons/Group.js +1 -1
  152. package/components/Icons/Group.js.map +1 -1
  153. package/components/Icons/Heart.js +1 -1
  154. package/components/Icons/Heart.js.map +1 -1
  155. package/components/Icons/HeartHands.js +1 -1
  156. package/components/Icons/HeartHands.js.map +1 -1
  157. package/components/Icons/HelpSign.js +1 -1
  158. package/components/Icons/HelpSign.js.map +1 -1
  159. package/components/Icons/History.js +1 -1
  160. package/components/Icons/History.js.map +1 -1
  161. package/components/Icons/Home.js +1 -1
  162. package/components/Icons/Home.js.map +1 -1
  163. package/components/Icons/Hospital.js +1 -1
  164. package/components/Icons/Hospital.js.map +1 -1
  165. package/components/Icons/Hourglass.js +1 -1
  166. package/components/Icons/Hourglass.js.map +1 -1
  167. package/components/Icons/Icon.d.ts +11 -1
  168. package/components/Icons/Icon.d.ts.map +1 -1
  169. package/components/Icons/Icon.js +1 -1
  170. package/components/Icons/Icon.js.map +1 -1
  171. package/components/Icons/InfoSignFill.js +1 -1
  172. package/components/Icons/InfoSignFill.js.map +1 -1
  173. package/components/Icons/InfoSignStroke.js +1 -1
  174. package/components/Icons/InfoSignStroke.js.map +1 -1
  175. package/components/Icons/Journal.js +1 -1
  176. package/components/Icons/Journal.js.map +1 -1
  177. package/components/Icons/List.js +1 -1
  178. package/components/Icons/List.js.map +1 -1
  179. package/components/Icons/Location.js +1 -1
  180. package/components/Icons/Location.js.map +1 -1
  181. package/components/Icons/Lock.js +1 -1
  182. package/components/Icons/Lock.js.map +1 -1
  183. package/components/Icons/Login.js +1 -1
  184. package/components/Icons/Login.js.map +1 -1
  185. package/components/Icons/Logout.js +1 -1
  186. package/components/Icons/Logout.js.map +1 -1
  187. package/components/Icons/Medicine.js +1 -1
  188. package/components/Icons/Medicine.js.map +1 -1
  189. package/components/Icons/Menu.js +1 -1
  190. package/components/Icons/Menu.js.map +1 -1
  191. package/components/Icons/Minus.js +1 -1
  192. package/components/Icons/Minus.js.map +1 -1
  193. package/components/Icons/MobilePhone.js +1 -1
  194. package/components/Icons/MobilePhone.js.map +1 -1
  195. package/components/Icons/NoAccess.js +1 -1
  196. package/components/Icons/NoAccess.js.map +1 -1
  197. package/components/Icons/NoEye.js +1 -1
  198. package/components/Icons/NoEye.js.map +1 -1
  199. package/components/Icons/NoFilter.js +1 -1
  200. package/components/Icons/NoFilter.js.map +1 -1
  201. package/components/Icons/PaperPlane.js +1 -1
  202. package/components/Icons/PaperPlane.js.map +1 -1
  203. package/components/Icons/Pause.js +1 -1
  204. package/components/Icons/Pause.js.map +1 -1
  205. package/components/Icons/Pencil.js +1 -1
  206. package/components/Icons/Pencil.js.map +1 -1
  207. package/components/Icons/PersonCancel.js +1 -1
  208. package/components/Icons/PersonCancel.js.map +1 -1
  209. package/components/Icons/PersonalPlan.js +1 -1
  210. package/components/Icons/PersonalPlan.js.map +1 -1
  211. package/components/Icons/Play.js +1 -1
  212. package/components/Icons/Play.js.map +1 -1
  213. package/components/Icons/PlusLarge.js +1 -1
  214. package/components/Icons/PlusLarge.js.map +1 -1
  215. package/components/Icons/PlusSmall.js +1 -1
  216. package/components/Icons/PlusSmall.js.map +1 -1
  217. package/components/Icons/Printer.js +1 -1
  218. package/components/Icons/Printer.js.map +1 -1
  219. package/components/Icons/QrCode.js +1 -1
  220. package/components/Icons/QrCode.js.map +1 -1
  221. package/components/Icons/Receptionist.js +1 -1
  222. package/components/Icons/Receptionist.js.map +1 -1
  223. package/components/Icons/Referral.js +1 -1
  224. package/components/Icons/Referral.js.map +1 -1
  225. package/components/Icons/Refresh.js +1 -1
  226. package/components/Icons/Refresh.js.map +1 -1
  227. package/components/Icons/Reply.js +1 -1
  228. package/components/Icons/Reply.js.map +1 -1
  229. package/components/Icons/Save.js +1 -1
  230. package/components/Icons/Save.js.map +1 -1
  231. package/components/Icons/Search.js +1 -1
  232. package/components/Icons/Search.js.map +1 -1
  233. package/components/Icons/SectionSign.js +1 -1
  234. package/components/Icons/SectionSign.js.map +1 -1
  235. package/components/Icons/Settings.js +1 -1
  236. package/components/Icons/Settings.js.map +1 -1
  237. package/components/Icons/Share.js +1 -1
  238. package/components/Icons/Share.js.map +1 -1
  239. package/components/Icons/SortDown.js +1 -1
  240. package/components/Icons/SortDown.js.map +1 -1
  241. package/components/Icons/SortUp.js +1 -1
  242. package/components/Icons/SortUp.js.map +1 -1
  243. package/components/Icons/SpeechBubble.js +1 -1
  244. package/components/Icons/SpeechBubble.js.map +1 -1
  245. package/components/Icons/Stopwatch.js +1 -1
  246. package/components/Icons/Stopwatch.js.map +1 -1
  247. package/components/Icons/SupportingPerson.d.ts.map +1 -1
  248. package/components/Icons/SupportingPerson.js +1 -1
  249. package/components/Icons/SupportingPerson.js.map +1 -1
  250. package/components/Icons/Syringe.js +1 -1
  251. package/components/Icons/Syringe.js.map +1 -1
  252. package/components/Icons/TimePassing.js +1 -1
  253. package/components/Icons/TimePassing.js.map +1 -1
  254. package/components/Icons/Toolbox.js +1 -1
  255. package/components/Icons/Toolbox.js.map +1 -1
  256. package/components/Icons/TrashCan.js +1 -1
  257. package/components/Icons/TrashCan.js.map +1 -1
  258. package/components/Icons/TriangleX.d.ts +5 -0
  259. package/components/Icons/TriangleX.d.ts.map +1 -0
  260. package/components/Icons/TriangleX.js +2 -0
  261. package/components/Icons/TriangleX.js.map +1 -0
  262. package/components/Icons/Undo.js +1 -1
  263. package/components/Icons/Undo.js.map +1 -1
  264. package/components/Icons/Upload.js +1 -1
  265. package/components/Icons/Upload.js.map +1 -1
  266. package/components/Icons/Vaccine.js +1 -1
  267. package/components/Icons/Vaccine.js.map +1 -1
  268. package/components/Icons/VerticalDots.js +1 -1
  269. package/components/Icons/VerticalDots.js.map +1 -1
  270. package/components/Icons/VideoCamera.js +1 -1
  271. package/components/Icons/VideoCamera.js.map +1 -1
  272. package/components/Icons/VideoChat.js +1 -1
  273. package/components/Icons/VideoChat.js.map +1 -1
  274. package/components/Icons/Wallet.js +1 -1
  275. package/components/Icons/Wallet.js.map +1 -1
  276. package/components/Icons/Watch.js +1 -1
  277. package/components/Icons/Watch.js.map +1 -1
  278. package/components/Icons/X.js +1 -1
  279. package/components/Icons/X.js.map +1 -1
  280. package/components/Icons/Zoom.js +1 -1
  281. package/components/Icons/Zoom.js.map +1 -1
  282. package/components/Icons/componentdata.json +1 -1
  283. package/components/Input/Input.d.ts +4 -0
  284. package/components/Input/Input.d.ts.map +1 -1
  285. package/components/Input/componentdata.json +1 -1
  286. package/components/Input/index.js +1 -1
  287. package/components/LinkList/LinkList.d.ts.map +1 -1
  288. package/components/LinkList/index.js +1 -1
  289. package/components/LinkList/index.js.map +1 -1
  290. package/components/ListHeader/ListHeader.d.ts +4 -4
  291. package/components/ListHeader/ListHeader.d.ts.map +1 -1
  292. package/components/ListHeader/ListHeaderText/componentdata.json +1 -1
  293. package/components/ListHeader/ListHeaderText/index.js +1 -1
  294. package/components/ListHeader/index.js +1 -1
  295. package/components/ListHeader/styles.module.scss +1 -5
  296. package/components/ListHeader/styles.module.scss.d.ts +0 -2
  297. package/components/MaxCharacters/MaxCharacters.d.ts +17 -0
  298. package/components/MaxCharacters/MaxCharacters.d.ts.map +1 -0
  299. package/components/MaxCharacters/componentdata.json +1 -0
  300. package/components/MaxCharacters/styles.module.scss +26 -0
  301. package/components/MaxCharacters/styles.module.scss.d.ts +11 -0
  302. package/components/Panel/Panel.d.ts.map +1 -1
  303. package/components/Panel/styles.module.scss +1 -1
  304. package/components/StatusDot/StatusDot.d.ts +9 -3
  305. package/components/StatusDot/StatusDot.d.ts.map +1 -1
  306. package/components/StatusDot/componentdata.json +1 -1
  307. package/components/StatusDot/index.js +1 -1
  308. package/components/Table/Table.d.ts +19 -9
  309. package/components/Table/Table.d.ts.map +1 -1
  310. package/components/Table/TableExpandedRow/TableExpandedRow.d.ts.map +1 -1
  311. package/components/Table/TableExpanderCell/TableExpanderCell.d.ts.map +1 -1
  312. package/components/Table/TableExpanderCell/TableExpanderCellMobile.d.ts +6 -0
  313. package/components/Table/TableExpanderCell/TableExpanderCellMobile.d.ts.map +1 -0
  314. package/components/Table/TableRow/TableRow.d.ts +1 -1
  315. package/components/Table/TableRow/TableRow.d.ts.map +1 -1
  316. package/components/Table/TableRow/componentdata.json +1 -1
  317. package/components/Table/index.js +1 -1
  318. package/components/Table/index.js.map +1 -1
  319. package/components/Table/styles.module.scss +131 -126
  320. package/components/Table/styles.module.scss.d.ts +12 -4
  321. package/components/Table/utils.d.ts +21 -0
  322. package/components/Table/utils.d.ts.map +1 -0
  323. package/components/Textarea/Textarea.d.ts.map +1 -1
  324. package/components/Textarea/index.js +1 -1
  325. package/components/Textarea/styles.module.scss +0 -26
  326. package/components/Textarea/styles.module.scss.d.ts +0 -3
  327. package/components/Validation/index.js +1 -1
  328. package/package.json +1 -1
  329. package/scss/_input.scss +0 -1
  330. package/utils/device.d.ts +2 -0
  331. package/utils/device.d.ts.map +1 -0
  332. package/utils/device.js +2 -0
  333. package/utils/device.js.map +1 -0
  334. package/utils/environment.d.ts +1 -0
  335. package/utils/environment.d.ts.map +1 -1
  336. package/utils/environment.js +1 -1
  337. package/utils/environment.js.map +1 -1
  338. package/components/Icons/TrangleX.d.ts +0 -5
  339. package/components/Icons/TrangleX.d.ts.map +0 -1
  340. package/components/Icons/TrangleX.js +0 -2
  341. package/components/Icons/TrangleX.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/ExpanderList/ExpanderList.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport { PaletteNames } from '../../theme/palette';\nimport { useHover } from '../../hooks/useHover';\nimport { usePrevious } from '../../hooks/usePrevious';\nimport { isElementInViewport } from '../../utils/viewport';\n\nimport classNames from 'classnames';\n\nimport expanderListStyles from './styles.module.scss';\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { useSticky } from '../../hooks/useSticky';\n\nimport { mergeRefs } from '../../utils/refs';\nimport { ListHeaderType, renderListHeader } from '../ListHeader/ListHeader';\nimport ChevronUp from '../Icons/ChevronUp';\nimport ChevronDown from '../Icons/ChevronDown';\nimport { TitleTags } from '../Title';\n\nexport type ExpanderListColors = PaletteNames;\nexport interface ExpanderType extends React.ForwardRefExoticComponent<ExpanderProps & React.RefAttributes<HTMLLIElement>> {\n ListHeader?: ListHeaderType;\n}\n\nexport interface ExpanderListCompound extends React.ForwardRefExoticComponent<ExpanderListProps & React.RefAttributes<HTMLUListElement>> {\n Expander: ExpanderType;\n}\n\nexport type ExpanderListVariant = 'line' | 'outline' | 'fill';\n\ninterface ExpanderListProps {\n /** Toggles accordion functionality for the expanders. */\n accordion?: boolean;\n /** @deprecated Skal fases ut - Brukes ikke lenger. */\n bottomBorder?: boolean;\n /** Items in the ExpanderList */\n children: React.ReactNode;\n /** Toggles padding of child elements */\n childPadding?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the link list background color on hover. */\n color?: ExpanderListColors;\n /** Changes the font size. */\n large?: boolean;\n /** Opens the first item in the list. */\n /** @deprecated Skal fases ut til fordel for å bruke expanded-prop på første ExpanderList.Expander */\n isOpen?: boolean;\n /** Whether to render children when closed (in which case they are hidden with CSS). Default: false */\n renderChildrenWhenClosed?: boolean;\n /** @deprecated Skal fases ut - Brukes ikke lenger. */\n topBorder?: boolean;\n /** Stick expander trigger to top of screen while scrolling down */\n sticky?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets visual priority */\n variant?: ExpanderListVariant;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\ntype ExpanderProps = Modify<\n React.HTMLAttributes<HTMLButtonElement>,\n {\n id?: string;\n title: JSX.Element | string;\n /** Changes the underlying element of the title. Default: span*/\n titleHtmlMarkup?: TitleTags;\n children: React.ReactNode;\n className?: string;\n color?: ExpanderListColors;\n icon?: React.ReactElement;\n padding?: boolean;\n expanded?: boolean;\n large?: boolean;\n testId?: string;\n handleExpanderClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Called when expander is open/closed. */\n onExpand?: (isExpanded: boolean) => void;\n }\n> &\n Pick<ExpanderListProps, 'renderChildrenWhenClosed' | 'sticky' | 'variant'>;\n\nconst Expander: ExpanderType = React.forwardRef<HTMLLIElement, ExpanderProps>((props, ref) => {\n const {\n id,\n children,\n padding = true,\n color = 'neutral',\n className = '',\n icon,\n large = false,\n title,\n titleHtmlMarkup = 'span',\n expanded = false,\n sticky,\n testId,\n handleExpanderClick,\n onExpand,\n renderChildrenWhenClosed,\n variant = 'line',\n } = props;\n const [isExpanded, setIsExpanded] = useState<boolean>(expanded);\n const previousIsExpanded = usePrevious(isExpanded);\n const expanderRef = useRef<HTMLLIElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const { isHovered } = useHover(triggerRef);\n\n const { isOutsideWindow, isLeavingWindow, offsetHeight, contentWidth } = useSticky(expanderRef, triggerRef);\n const isSticky = sticky && isExpanded && isOutsideWindow;\n const isJsxTitle = typeof title === 'object';\n\n const itemClasses = classNames(className, {\n [expanderListStyles['expander-list__item--' + variant]]: variant,\n [expanderListStyles['expander-list__item--jsx']]: isJsxTitle,\n });\n\n const expanderClasses = classNames(expanderListStyles['expander-list-link'], expanderListStyles[`expander-list-link--${color}`], {\n [expanderListStyles['expander-list-link--fill']]: variant === 'fill',\n [expanderListStyles['expander-list-link--closed']]: !isExpanded,\n [expanderListStyles['expander-list-link--large']]: large,\n [expanderListStyles['expander-list-link--jsx']]: isJsxTitle,\n [expanderListStyles['expander-list-link--sticky']]: isSticky && !isLeavingWindow,\n [expanderListStyles['expander-list-link--absolute']]: isSticky && isLeavingWindow,\n });\n\n useEffect(() => {\n if (expanded !== isExpanded) {\n setIsExpanded(expanded);\n }\n }, [expanded]);\n\n useEffect(() => {\n if (onExpand && isExpanded !== !!previousIsExpanded) {\n onExpand(isExpanded);\n }\n }, [isExpanded, onExpand]);\n\n const renderContent = () => {\n if (!renderChildrenWhenClosed && !isExpanded) {\n return null;\n }\n\n const mainContentClasses = classNames(\n expanderListStyles['expander-list-link__main-content'],\n isExpanded && expanderListStyles['expander-list-link__main-content--expanded'],\n padding ? expanderListStyles['expander-list-link__main-content--padding'] : ''\n );\n\n return <div className={mainContentClasses}>{children}</div>;\n };\n\n return (\n <li\n className={itemClasses}\n ref={mergeRefs([ref, expanderRef])}\n style={{ paddingTop: isSticky && offsetHeight ? `${offsetHeight}px` : undefined }}\n >\n <button\n type=\"button\"\n id={id}\n onClick={handleExpanderClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.ExpanderListExpander}\n className={expanderClasses}\n ref={triggerRef}\n aria-expanded={isExpanded}\n style={{\n zIndex: isHovered || isSticky ? ZIndex.ExpanderTrigger : undefined,\n width: isSticky && contentWidth ? `${contentWidth}px` : undefined,\n }}\n >\n {renderListHeader(title, titleHtmlMarkup, isExpanded ? ChevronUp : ChevronDown, isHovered, large ? 'large' : 'medium', icon)}\n </button>\n {renderContent()}\n </li>\n );\n});\n\ntype ActiveExpander = Record<string, boolean>;\n\nconst isExpanderComponent = (element: {} | null | undefined): element is React.ReactElement<ExpanderProps> =>\n React.isValidElement<ExpanderProps>(element) && (element as React.ReactElement).type === Expander;\n\nexport const ExpanderList = React.forwardRef((props: ExpanderListProps, ref: React.Ref<HTMLUListElement>) => {\n const {\n children,\n childPadding = true,\n large,\n isOpen = false,\n renderChildrenWhenClosed = false,\n color,\n className = '',\n accordion = false,\n topBorder = true,\n bottomBorder = true,\n sticky = false,\n testId,\n variant,\n } = props;\n const [activeExpander, setActiveExpander] = useState<ActiveExpander>();\n const [latestExpander, setLatestExpander] = useState<HTMLElement>();\n const uuid = useUuid();\n const childCount = React.Children.count(children);\n const expanderListClasses = classNames(expanderListStyles['expander-list'], className);\n\n function handleExpanderClick(event: React.MouseEvent<HTMLElement, MouseEvent>, id: string): void {\n setActiveExpander(prevState => (accordion ? { [id]: !prevState?.[id] } : { ...prevState, [id]: !prevState?.[id] }));\n setLatestExpander(event.currentTarget);\n }\n\n /** Returns the class modifier top when we want to show the top border and no-bottom when we don't want to show the bottom border */\n const getExpanderItemClass = (index: number) => {\n return classNames(expanderListStyles['expander-list__item'], {\n [expanderListStyles['expander-list__item--top']]: index === 0 && topBorder,\n [expanderListStyles['expander-list__item--no-bottom']]: index === childCount - 1 && !bottomBorder,\n });\n };\n\n const getExpanderId = (index: number) => `${uuid}-${index}`;\n\n useEffect(() => {\n if (accordion && latestExpander && !isElementInViewport(latestExpander)) {\n latestExpander.scrollIntoView();\n }\n }, [accordion, latestExpander]);\n\n useEffect(() => {\n if (isOpen) {\n const id = getExpanderId(0);\n setActiveExpander(prevState => (accordion ? { [id]: !prevState?.[id] } : { ...prevState, [id]: !prevState?.[id] }));\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (!isOpen) {\n const newActiveExpander = React.Children.map(children, child => {\n if (isExpanderComponent(child)) {\n return child;\n }\n })?.reduce((acc, child, index) => {\n // Expanded-status skal bare settes dersom prop er satt av den som bruker komponenten\n if (typeof child.props.expanded !== 'undefined') {\n acc[getExpanderId(index)] = child.props.expanded;\n }\n return acc;\n }, {} as ActiveExpander);\n\n setActiveExpander({ ...activeExpander, ...newActiveExpander });\n }\n }, [children]);\n\n return (\n <ul className={expanderListClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderList}>\n {React.Children.map(children, (child, index) => {\n if (isExpanderComponent(child)) {\n const id = getExpanderId(index);\n const expanded = activeExpander?.[id];\n const expanderItemClass = getExpanderItemClass(index);\n\n return React.cloneElement(child as React.ReactElement<ExpanderProps>, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n sticky,\n 'aria-expanded': expanded,\n className: expanderItemClass,\n handleExpanderClick: (event: React.MouseEvent<HTMLElement>) => handleExpanderClick(event, `${uuid}-${index}`),\n renderChildrenWhenClosed,\n variant,\n });\n }\n return child;\n })}\n </ul>\n );\n}) as ExpanderListCompound;\n\nExpanderList.Expander = Expander;\nExpander.displayName = 'ExpanderList.Expander';\n\nexport default ExpanderList;\n"],"names":["Expander","React","props","ref","id","children","padding","color","className","icon","large","title","titleHtmlMarkup","expanded","sticky","testId","handleExpanderClick","onExpand","renderChildrenWhenClosed","variant","isExpanded","setIsExpanded","useState","previousIsExpanded","usePrevious","expanderRef","useRef","triggerRef","isHovered","useHover","isOutsideWindow","isLeavingWindow","offsetHeight","contentWidth","useSticky","isSticky","isJsxTitle","itemClasses","classNames","expanderListStyles","expanderClasses","useEffect","renderContent","mainContentClasses","mergeRefs","AnalyticsId","ZIndex","renderListHeader","ChevronUp","ChevronDown","isExpanderComponent","element","ExpanderList","childPadding","isOpen","accordion","topBorder","bottomBorder","activeExpander","setActiveExpander","latestExpander","setLatestExpander","uuid","useUuid","childCount","expanderListClasses","event","prevState","getExpanderItemClass","index","getExpanderId","isElementInViewport","newActiveExpander","_a","child","acc","expanderItemClass"],"mappings":"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"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/ExpanderList/ExpanderList.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport { PaletteNames } from '../../theme/palette';\nimport { useHover } from '../../hooks/useHover';\nimport { usePrevious } from '../../hooks/usePrevious';\nimport { isElementInViewport } from '../../utils/viewport';\n\nimport classNames from 'classnames';\n\nimport expanderListStyles from './styles.module.scss';\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { useSticky } from '../../hooks/useSticky';\n\nimport { mergeRefs } from '../../utils/refs';\nimport { ListHeaderType, renderListHeader } from '../ListHeader/ListHeader';\nimport ChevronUp from '../Icons/ChevronUp';\nimport ChevronDown from '../Icons/ChevronDown';\nimport { TitleTags } from '../Title';\n\nexport type ExpanderListColors = PaletteNames;\nexport interface ExpanderType extends React.ForwardRefExoticComponent<ExpanderProps & React.RefAttributes<HTMLLIElement>> {\n ListHeader?: ListHeaderType;\n}\n\nexport interface ExpanderListCompound extends React.ForwardRefExoticComponent<ExpanderListProps & React.RefAttributes<HTMLUListElement>> {\n Expander: ExpanderType;\n}\n\nexport type ExpanderListVariant = 'line' | 'outline' | 'fill';\n\ninterface ExpanderListProps {\n /** Toggles accordion functionality for the expanders. */\n accordion?: boolean;\n /** @deprecated Skal fases ut - Brukes ikke lenger. */\n bottomBorder?: boolean;\n /** Items in the ExpanderList */\n children: React.ReactNode;\n /** Toggles padding of child elements */\n childPadding?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the link list background color on hover. */\n color?: ExpanderListColors;\n /** Changes the font size. */\n large?: boolean;\n /** Opens the first item in the list. */\n /** @deprecated Skal fases ut til fordel for å bruke expanded-prop på første ExpanderList.Expander */\n isOpen?: boolean;\n /** Whether to render children when closed (in which case they are hidden with CSS). Default: false */\n renderChildrenWhenClosed?: boolean;\n /** @deprecated Skal fases ut - Brukes ikke lenger. */\n topBorder?: boolean;\n /** Stick expander trigger to top of screen while scrolling down */\n sticky?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets visual priority */\n variant?: ExpanderListVariant;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\ntype ExpanderProps = Modify<\n React.HTMLAttributes<HTMLButtonElement>,\n {\n id?: string;\n title: JSX.Element | string;\n /** Changes the underlying element of the title. Default: span*/\n titleHtmlMarkup?: TitleTags;\n children: React.ReactNode;\n className?: string;\n color?: ExpanderListColors;\n icon?: React.ReactElement;\n padding?: boolean;\n expanded?: boolean;\n large?: boolean;\n testId?: string;\n handleExpanderClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Called when expander is open/closed. */\n onExpand?: (isExpanded: boolean) => void;\n }\n> &\n Pick<ExpanderListProps, 'renderChildrenWhenClosed' | 'sticky' | 'variant'>;\n\nconst Expander: ExpanderType = React.forwardRef<HTMLLIElement, ExpanderProps>((props, ref) => {\n const {\n id,\n children,\n padding = true,\n color = 'neutral',\n className = '',\n icon,\n large = false,\n title,\n titleHtmlMarkup = 'span',\n expanded = false,\n sticky,\n testId,\n handleExpanderClick,\n onExpand,\n renderChildrenWhenClosed,\n variant = 'line',\n } = props;\n const [isExpanded, setIsExpanded] = useState<boolean>(expanded);\n const previousIsExpanded = usePrevious(isExpanded);\n const expanderRef = useRef<HTMLLIElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const { isHovered } = useHover(triggerRef);\n\n const { isOutsideWindow, isLeavingWindow, offsetHeight, contentWidth } = useSticky(expanderRef, triggerRef);\n const isSticky = sticky && isExpanded && isOutsideWindow;\n const isJsxTitle = typeof title === 'object';\n\n const itemClasses = classNames(className, {\n [expanderListStyles['expander-list__item--' + variant]]: variant,\n [expanderListStyles['expander-list__item--jsx']]: isJsxTitle,\n });\n\n const expanderClasses = classNames(expanderListStyles['expander-list-link'], expanderListStyles[`expander-list-link--${color}`], {\n [expanderListStyles['expander-list-link--fill']]: variant === 'fill',\n [expanderListStyles['expander-list-link--closed']]: !isExpanded,\n [expanderListStyles['expander-list-link--large']]: large,\n [expanderListStyles['expander-list-link--jsx']]: isJsxTitle,\n [expanderListStyles['expander-list-link--sticky']]: isSticky && !isLeavingWindow,\n [expanderListStyles['expander-list-link--absolute']]: isSticky && isLeavingWindow,\n });\n\n useEffect(() => {\n if (expanded !== isExpanded) {\n setIsExpanded(expanded);\n }\n }, [expanded]);\n\n useEffect(() => {\n if (onExpand && isExpanded !== !!previousIsExpanded) {\n onExpand(isExpanded);\n }\n }, [isExpanded, onExpand]);\n\n const renderContent = () => {\n if (!renderChildrenWhenClosed && !isExpanded) {\n return null;\n }\n\n const mainContentClasses = classNames(\n expanderListStyles['expander-list-link__main-content'],\n isExpanded && expanderListStyles['expander-list-link__main-content--expanded'],\n padding ? expanderListStyles['expander-list-link__main-content--padding'] : ''\n );\n\n return <div className={mainContentClasses}>{children}</div>;\n };\n\n return (\n <li\n className={itemClasses}\n ref={mergeRefs([ref, expanderRef])}\n style={{ paddingTop: isSticky && offsetHeight ? `${offsetHeight}px` : undefined }}\n >\n <button\n type=\"button\"\n id={id}\n onClick={handleExpanderClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.ExpanderListExpander}\n className={expanderClasses}\n ref={triggerRef}\n aria-expanded={isExpanded}\n style={{\n zIndex: isHovered || isSticky ? ZIndex.ExpanderTrigger : undefined,\n width: isSticky && contentWidth ? `${contentWidth}px` : undefined,\n }}\n >\n {renderListHeader(title, titleHtmlMarkup, isExpanded ? ChevronUp : ChevronDown, isHovered, large ? 'large' : 'medium', icon)}\n </button>\n {renderContent()}\n </li>\n );\n});\n\ntype ActiveExpander = Record<string, boolean>;\n\nconst isExpanderComponent = (element: {} | null | undefined): element is React.ReactElement<ExpanderProps> =>\n React.isValidElement<ExpanderProps>(element) && (element as React.ReactElement).type === Expander;\n\nexport const ExpanderList = React.forwardRef((props: ExpanderListProps, ref: React.Ref<HTMLUListElement>) => {\n const {\n children,\n childPadding = true,\n large,\n isOpen = false,\n renderChildrenWhenClosed = false,\n color,\n className = '',\n accordion = false,\n topBorder = true,\n bottomBorder = true,\n sticky = false,\n testId,\n variant,\n } = props;\n const [activeExpander, setActiveExpander] = useState<ActiveExpander>();\n const [latestExpander, setLatestExpander] = useState<HTMLElement>();\n const uuid = useUuid();\n const childCount = React.Children.count(children);\n const expanderListClasses = classNames(expanderListStyles['expander-list'], className);\n\n function handleExpanderClick(event: React.MouseEvent<HTMLElement, MouseEvent>, id: string): void {\n setActiveExpander(prevState => (accordion ? { [id]: !prevState?.[id] } : { ...prevState, [id]: !prevState?.[id] }));\n setLatestExpander(event.currentTarget);\n }\n\n /** Returns the class modifier top when we want to show the top border and no-bottom when we don't want to show the bottom border */\n const getExpanderItemClass = (index: number) => {\n return classNames(expanderListStyles['expander-list__item'], {\n [expanderListStyles['expander-list__item--top']]: index === 0 && topBorder,\n [expanderListStyles['expander-list__item--no-bottom']]: index === childCount - 1 && !bottomBorder,\n });\n };\n\n const getExpanderId = (index: number) => `${uuid}-${index}`;\n\n useEffect(() => {\n if (accordion && latestExpander && !isElementInViewport(latestExpander)) {\n latestExpander.scrollIntoView();\n }\n }, [accordion, latestExpander]);\n\n useEffect(() => {\n if (isOpen) {\n const id = getExpanderId(0);\n setActiveExpander(prevState => (accordion ? { [id]: !prevState?.[id] } : { ...prevState, [id]: !prevState?.[id] }));\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (!isOpen) {\n const newActiveExpander = React.Children.map(children, child => {\n if (isExpanderComponent(child)) {\n return child;\n }\n })?.reduce((acc, child, index) => {\n // Expanded-status skal bare settes dersom prop er satt av den som bruker komponenten\n if (typeof child.props.expanded !== 'undefined') {\n acc[getExpanderId(index)] = child.props.expanded;\n }\n return acc;\n }, {} as ActiveExpander);\n\n setActiveExpander({ ...activeExpander, ...newActiveExpander });\n }\n }, [children]);\n\n return (\n <ul className={expanderListClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderList}>\n {React.Children.map(children, (child, index) => {\n if (isExpanderComponent(child)) {\n const id = getExpanderId(index);\n const expanded = activeExpander?.[id];\n const expanderItemClass = getExpanderItemClass(index);\n\n return React.cloneElement(child as React.ReactElement<ExpanderProps>, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n sticky,\n 'aria-expanded': expanded,\n className: expanderItemClass,\n handleExpanderClick: (event: React.MouseEvent<HTMLElement>) => handleExpanderClick(event, `${uuid}-${index}`),\n renderChildrenWhenClosed,\n variant,\n });\n }\n return child;\n })}\n </ul>\n );\n}) as ExpanderListCompound;\n\nExpanderList.Expander = Expander;\nExpander.displayName = 'ExpanderList.Expander';\n\nexport default ExpanderList;\n"],"names":["Expander","React","props","ref","id","children","padding","color","className","icon","large","title","titleHtmlMarkup","expanded","sticky","testId","handleExpanderClick","onExpand","renderChildrenWhenClosed","variant","isExpanded","setIsExpanded","useState","previousIsExpanded","usePrevious","expanderRef","useRef","triggerRef","isHovered","useHover","isOutsideWindow","isLeavingWindow","offsetHeight","contentWidth","useSticky","isSticky","isJsxTitle","itemClasses","classNames","expanderListStyles","expanderClasses","useEffect","renderContent","mainContentClasses","mergeRefs","AnalyticsId","ZIndex","renderListHeader","ChevronUp","ChevronDown","isExpanderComponent","element","ExpanderList","childPadding","isOpen","accordion","topBorder","bottomBorder","activeExpander","setActiveExpander","latestExpander","setLatestExpander","uuid","useUuid","childCount","expanderListClasses","event","prevState","getExpanderItemClass","index","getExpanderId","isElementInViewport","newActiveExpander","_a","child","acc","expanderItemClass"],"mappings":"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"}
@@ -1,12 +1,12 @@
1
- import h from"react";import{V as yt}from"../../Validation.js";import{F as Y}from"../../FormGroup.js";import{C as ee}from"../../Checkbox.js";import{B as mt}from"../../Button.js";import{R as me}from"../../RadioButton.js";import{T as Be}from"../../Textarea.js";import{I as ae}from"../../Input.js";import Ue from"../Icons/Hospital.js";import{F as gt,a as ht}from"../../FormLayout.js";import{isTest as vt}from"../../utils/environment.js";import{S as Pe}from"../../Select.js";import we from"./styles.module.scss";import"classnames";import"../Validation/styles.module.scss";import"../../constants.js";import"../FormGroup/styles.module.scss";import"../../Title.js";import"../Title/styles.module.scss";import"../../ErrorWrapper.js";import"../ErrorWrapper/styles.module.scss";import"../../utils/component.js";import"../../uuid.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../hooks/useUuid.js";import"../../theme/currys/color.js";import"../../theme/index.js";import"../../theme/palette.js";import"../../theme/spacers.js";import"../../theme/grid.js";import"../Checkbox/styles.module.scss";import"../../hooks/useHover.js";import"../../hooks/useIcons.js";import"../../hooks/useBreakpoint.js";import"../Button/styles.module.scss";import"../Icons/ArrowRight.js";import"../../hooks/useSize.js";import"../../utils/debounce.js";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../Input/styles.module.scss";import"../FormLayout/styles.module.scss";import"../Select/styles.module.scss";import"../Icons/ChevronDown.js";var de=e=>e.type==="checkbox",ne=e=>e instanceof Date,N=e=>e==null;const Xe=e=>typeof e=="object";var L=e=>!N(e)&&!Array.isArray(e)&&Xe(e)&&!ne(e),bt=e=>L(e)&&e.target?de(e.target)?e.target.checked:e.target.value:e,xt=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,kt=(e,i)=>e.has(xt(i)),fe=e=>Array.isArray(e)?e.filter(Boolean):[],T=e=>e===void 0,f=(e,i,t)=>{if(!i||!L(e))return t;const l=fe(i.split(/[,[\].]+?/)).reduce((s,a)=>N(s)?s:s[a],e);return T(l)||l===e?T(e[i])?t:e[i]:l};const He={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},$={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},j={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};h.createContext(null);var pt=(e,i,t,l=!0)=>{const s={defaultValues:i._defaultValues};for(const a in e)Object.defineProperty(s,a,{get:()=>{const m=a;return i._proxyFormState[m]!==$.all&&(i._proxyFormState[m]=!l||$.all),t&&(t[m]=!0),e[m]}});return s},B=e=>L(e)&&!Object.keys(e).length,Et=(e,i,t)=>{const{name:l,...s}=e;return B(s)||Object.keys(s).length>=Object.keys(i).length||Object.keys(s).find(a=>i[a]===(!t||$.all))},Ae=e=>Array.isArray(e)?e:[e];function wt(e){const i=h.useRef(e);i.current=e,h.useEffect(()=>{const t=!e.disabled&&i.current.subject.subscribe({next:i.current.callback});return()=>{t&&t.unsubscribe()}},[e.disabled])}var W=e=>typeof e=="string",At=(e,i,t,l)=>{const s=Array.isArray(e);return W(e)?(l&&i.watch.add(e),f(t,e)):s?e.map(a=>(l&&i.watch.add(a),f(t,a))):(l&&(i.watchAll=!0),t)},he=e=>typeof e=="function",Ye=e=>{for(const i in e)if(he(e[i]))return!0;return!1},Dt=(e,i,t,l,s)=>i?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[l]:s||!0}}:{},Le=e=>/^\w*$/.test(e),Ze=e=>fe(e.replace(/["|']|\]/g,"").split(/\.|\[/));function A(e,i,t){let l=-1;const s=Le(i)?[i]:Ze(i),a=s.length,m=a-1;for(;++l<a;){const g=s[l];let E=t;if(l!==m){const V=e[g];E=L(V)||Array.isArray(V)?V:isNaN(+s[l+1])?{}:[]}e[g]=E,e=e[g]}return e}const Ve=(e,i,t)=>{for(const l of t||Object.keys(e)){const s=f(e,l);if(s){const{_f:a,...m}=s;if(a&&i(a.name)){if(a.ref.focus){a.ref.focus();break}else if(a.refs&&a.refs[0].focus){a.refs[0].focus();break}}else L(m)&&Ve(m,i)}}};var $e=(e,i,t)=>!t&&(i.watchAll||i.watch.has(e)||[...i.watch].some(l=>e.startsWith(l)&&/^\.\w+/.test(e.slice(l.length)))),St=(e,i,t)=>{const l=fe(f(e,t));return A(l,"root",i[t]),A(e,t,l),e},ce=e=>typeof e=="boolean",Oe=e=>e.type==="file",ge=e=>W(e)||h.isValidElement(e),Re=e=>e.type==="radio",ve=e=>e instanceof RegExp;const We={value:!1,isValid:!1},Ge={value:!0,isValid:!0};var et=e=>{if(Array.isArray(e)){if(e.length>1){const i=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:i,isValid:!!i.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!T(e[0].attributes.value)?T(e[0].value)||e[0].value===""?Ge:{value:e[0].value,isValid:!0}:Ge:We}return We};const Ke={isValid:!1,value:null};var tt=e=>Array.isArray(e)?e.reduce((i,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:i,Ke):Ke;function je(e,i,t="validate"){if(ge(e)||Array.isArray(e)&&e.every(ge)||ce(e)&&!e)return{type:t,message:ge(e)?e:"",ref:i}}var se=e=>L(e)&&!ve(e)?e:{value:e,message:""},ze=async(e,i,t,l,s)=>{const{ref:a,refs:m,required:g,maxLength:E,minLength:V,min:O,max:p,pattern:b,validate:U,name:q,valueAsNumber:re,mount:le,disabled:P}=e._f;if(!le||P)return{};const C=m?m[0]:a,H=v=>{l&&W(v)&&(C.setCustomValidity(v),C.reportValidity())},D={},z=Re(a),ie=de(a),K=z||ie,J=(re||Oe(a))&&!a.value||i===""||Array.isArray(i)&&!i.length,R=Dt.bind(null,q,t,D),Z=(v,x,S,k=j.maxLength,w=j.minLength)=>{const _=v?x:S;D[q]={type:v?k:w,message:_,ref:a,...R(v?k:w,_)}};if(s?!Array.isArray(i)||!i.length:g&&(!K&&(J||N(i))||ce(i)&&!i||ie&&!et(m).isValid||z&&!tt(m).isValid)){const{value:v,message:x}=ge(g)?{value:!!g,message:g}:se(g);if(v&&(D[q]={type:j.required,message:x,ref:C,...R(j.required,x)},!t))return H(x),D}if(!J&&(!N(O)||!N(p))){let v,x;const S=se(p),k=se(O);if(!N(i)&&!isNaN(i)){const w=a.valueAsNumber||i&&+i;N(S.value)||(v=w>S.value),N(k.value)||(x=w<k.value)}else{const w=a.valueAsDate||new Date(i),_=X=>new Date(new Date().toDateString()+" "+X),G=a.type=="time",Q=a.type=="week";W(S.value)&&i&&(v=G?_(i)>_(S.value):Q?i>S.value:w>new Date(S.value)),W(k.value)&&i&&(x=G?_(i)<_(k.value):Q?i<k.value:w<new Date(k.value))}if((v||x)&&(Z(!!v,S.message,k.message,j.max,j.min),!t))return H(D[q].message),D}if((E||V)&&!J&&(W(i)||s&&Array.isArray(i))){const v=se(E),x=se(V),S=!N(v.value)&&i.length>v.value,k=!N(x.value)&&i.length<x.value;if((S||k)&&(Z(S,v.message,x.message),!t))return H(D[q].message),D}if(b&&!J&&W(i)){const{value:v,message:x}=se(b);if(ve(v)&&!i.match(v)&&(D[q]={type:j.pattern,message:x,ref:a,...R(j.pattern,x)},!t))return H(x),D}if(U){if(he(U)){const v=await U(i),x=je(v,C);if(x&&(D[q]={...x,...R(j.validate,x.message)},!t))return H(x.message),D}else if(L(U)){let v={};for(const x in U){if(!B(v)&&!t)break;const S=je(await U[x](i),C,x);S&&(v={...S,...R(x,S.message)},H(S.message),t&&(D[q]=v))}if(!B(v)&&(D[q]={ref:C,...v},!t))return D}}return H(!0),D},_t=e=>{const i=e.constructor&&e.constructor.prototype;return L(i)&&i.hasOwnProperty("isPrototypeOf")},Te=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function te(e){let i;const t=Array.isArray(e);if(e instanceof Date)i=new Date(e);else if(e instanceof Set)i=new Set(e);else if(!(Te&&(e instanceof Blob||e instanceof FileList))&&(t||L(e)))if(i=t?[]:{},!Array.isArray(e)&&!_t(e))i=e;else for(const l in e)i[l]=te(e[l]);else return e;return i}var Je=e=>({isOnSubmit:!e||e===$.onSubmit,isOnBlur:e===$.onBlur,isOnChange:e===$.onChange,isOnAll:e===$.all,isOnTouch:e===$.onTouched});function Ft(e,i){const t=i.slice(0,-1).length;let l=0;for(;l<t;)e=T(e)?l++:e[i[l++]];return e}function Vt(e){for(const i in e)if(!T(e[i]))return!1;return!0}function I(e,i){const t=Le(i)?[i]:Ze(i),l=t.length==1?e:Ft(e,t),s=t[t.length-1];let a;l&&delete l[s];for(let m=0;m<t.slice(0,-1).length;m++){let g=-1,E;const V=t.slice(0,-(m+1)),O=V.length-1;for(m>0&&(a=e);++g<V.length;){const p=V[g];E=E?E[p]:e[p],O===g&&(L(E)&&B(E)||Array.isArray(E)&&Vt(E))&&(a?delete a[p]:delete e[p]),a=E}}return e}function De(){let e=[];return{get observers(){return e},next:s=>{for(const a of e)a.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(a=>a!==s)}}),unsubscribe:()=>{e=[]}}}var be=e=>N(e)||!Xe(e);function oe(e,i){if(be(e)||be(i))return e===i;if(ne(e)&&ne(i))return e.getTime()===i.getTime();const t=Object.keys(e),l=Object.keys(i);if(t.length!==l.length)return!1;for(const s of t){const a=e[s];if(!l.includes(s))return!1;if(s!=="ref"){const m=i[s];if(ne(a)&&ne(m)||L(a)&&L(m)||Array.isArray(a)&&Array.isArray(m)?!oe(a,m):a!==m)return!1}}return!0}var Ce=e=>{const i=e?e.ownerDocument:0,t=i&&i.defaultView?i.defaultView.HTMLElement:HTMLElement;return e instanceof t},rt=e=>e.type==="select-multiple",Tt=e=>Re(e)||de(e),Se=e=>Ce(e)&&e.isConnected;function xe(e,i={}){const t=Array.isArray(e);if(L(e)||t)for(const l in e)Array.isArray(e[l])||L(e[l])&&!Ye(e[l])?(i[l]=Array.isArray(e[l])?[]:{},xe(e[l],i[l])):N(e[l])||(i[l]=!0);return i}function it(e,i,t){const l=Array.isArray(e);if(L(e)||l)for(const s in e)Array.isArray(e[s])||L(e[s])&&!Ye(e[s])?T(i)||be(t[s])?t[s]=Array.isArray(e[s])?xe(e[s],[]):{...xe(e[s])}:it(e[s],N(i)?{}:i[s],t[s]):oe(e[s],i[s])?delete t[s]:t[s]=!0;return t}var _e=(e,i)=>it(e,i,xe(i)),st=(e,{valueAsNumber:i,valueAsDate:t,setValueAs:l})=>T(e)?e:i?e===""?NaN:e&&+e:t&&W(e)?new Date(e):l?l(e):e;function Fe(e){const i=e.ref;if(!(e.refs?e.refs.every(t=>t.disabled):i.disabled))return Oe(i)?i.files:Re(i)?tt(e.refs).value:rt(i)?[...i.selectedOptions].map(({value:t})=>t):de(i)?et(e.refs).value:st(T(i.value)?e.ref.value:i.value,e)}var Ct=(e,i,t,l)=>{const s={};for(const a of e){const m=f(i,a);m&&A(s,a,m._f)}return{criteriaMode:t,names:[...e],fields:s,shouldUseNativeValidation:l}},ue=e=>T(e)?void 0:ve(e)?e.source:L(e)?ve(e.value)?e.value.source:e.value:e,Lt=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Qe(e,i,t){const l=f(e,t);if(l||Le(t))return{error:l,name:t};const s=t.split(".");for(;s.length;){const a=s.join("."),m=f(i,a),g=f(e,a);if(m&&!Array.isArray(m)&&t!==a)return{name:t};if(g&&g.type)return{name:a,error:g};s.pop()}return{name:t}}var Ot=(e,i,t,l,s)=>s.isOnAll?!1:!t&&s.isOnTouch?!(i||e):(t?l.isOnBlur:s.isOnBlur)?!e:(t?l.isOnChange:s.isOnChange)?e:!0,Rt=(e,i)=>!fe(f(e,i)).length&&I(e,i);const Mt={mode:$.onSubmit,reValidateMode:$.onChange,shouldFocusError:!0};function It(e={}){let i={...Mt,...e},t={submitCount:0,isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},l={},s=te(i.defaultValues)||{},a=i.shouldUnregister?{}:te(s),m={action:!1,mount:!1,watch:!1},g={mount:new Set,unMount:new Set,array:new Set,watch:new Set},E,V=0,O={};const p={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={watch:De(),array:De(),state:De()},U=Je(i.mode),q=Je(i.reValidateMode),re=i.criteriaMode===$.all,le=r=>n=>{clearTimeout(V),V=window.setTimeout(r,n)},P=async()=>{let r=!1;return p.isValid&&(r=i.resolver?B((await K()).errors):await R(l,!0),r!==t.isValid&&(t.isValid=r,b.state.next({isValid:r}))),r},C=(r,n=[],o,c,d=!0,u=!0)=>{if(c&&o){if(m.action=!0,u&&Array.isArray(f(l,r))){const y=o(f(l,r),c.argA,c.argB);d&&A(l,r,y)}if(p.errors&&u&&Array.isArray(f(t.errors,r))){const y=o(f(t.errors,r),c.argA,c.argB);d&&A(t.errors,r,y),Rt(t.errors,r)}if(p.touchedFields&&u&&Array.isArray(f(t.touchedFields,r))){const y=o(f(t.touchedFields,r),c.argA,c.argB);d&&A(t.touchedFields,r,y)}p.dirtyFields&&(t.dirtyFields=_e(s,a)),b.state.next({isDirty:v(r,n),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else A(a,r,n)},H=(r,n)=>{A(t.errors,r,n),b.state.next({errors:t.errors})},D=(r,n,o,c)=>{const d=f(l,r);if(d){const u=f(a,r,T(o)?f(s,r):o);T(u)||c&&c.defaultChecked||n?A(a,r,n?u:Fe(d._f)):k(r,u),m.mount&&P()}},z=(r,n,o,c,d)=>{let u=!1;const y={name:r},F=f(t.touchedFields,r);if(p.isDirty){const M=t.isDirty;t.isDirty=y.isDirty=v(),u=M!==y.isDirty}if(p.dirtyFields&&(!o||c)){const M=f(t.dirtyFields,r);oe(f(s,r),n)?I(t.dirtyFields,r):A(t.dirtyFields,r,!0),y.dirtyFields=t.dirtyFields,u=u||M!==f(t.dirtyFields,r)}return o&&!F&&(A(t.touchedFields,r,o),y.touchedFields=t.touchedFields,u=u||p.touchedFields&&F!==o),u&&d&&b.state.next(y),u?y:{}},ie=(r,n,o,c)=>{const d=f(t.errors,r),u=p.isValid&&ce(n)&&t.isValid!==n;if(e.delayError&&o?(E=le(()=>H(r,o)),E(e.delayError)):(clearTimeout(V),E=null,o?A(t.errors,r,o):I(t.errors,r)),(o?!oe(d,o):d)||!B(c)||u){const y={...c,...u&&ce(n)?{isValid:n}:{},errors:t.errors,name:r};t={...t,...y},b.state.next(y)}O[r]--,p.isValidating&&!Object.values(O).some(y=>y)&&(b.state.next({isValidating:!1}),O={})},K=async r=>i.resolver?await i.resolver({...a},i.context,Ct(r||g.mount,l,i.criteriaMode,i.shouldUseNativeValidation)):{},J=async r=>{const{errors:n}=await K();if(r)for(const o of r){const c=f(n,o);c?A(t.errors,o,c):I(t.errors,o)}else t.errors=n;return n},R=async(r,n,o={valid:!0})=>{for(const c in r){const d=r[c];if(d){const{_f:u,...y}=d;if(u){const F=g.array.has(u.name),M=await ze(d,f(a,u.name),re,i.shouldUseNativeValidation,F);if(M[u.name]&&(o.valid=!1,n))break;!n&&(f(M,u.name)?F?St(t.errors,M,u.name):A(t.errors,u.name,M[u.name]):I(t.errors,u.name))}y&&await R(y,n,o)}}return o.valid},Z=()=>{for(const r of g.unMount){const n=f(l,r);n&&(n._f.refs?n._f.refs.every(o=>!Se(o)):!Se(n._f.ref))&&ke(r)}g.unMount=new Set},v=(r,n)=>(r&&n&&A(a,r,n),!oe(X(),s)),x=(r,n,o)=>{const c={...m.mount?a:T(n)?s:W(r)?{[r]:n}:n};return At(r,g,c,o)},S=r=>fe(f(m.mount?a:s,r,e.shouldUnregister?f(s,r,[]):[])),k=(r,n,o={})=>{const c=f(l,r);let d=n;if(c){const u=c._f;u&&(!u.disabled&&A(a,r,st(n,u)),d=Te&&Ce(u.ref)&&N(n)?"":n,rt(u.ref)?[...u.ref.options].forEach(y=>y.selected=d.includes(y.value)):u.refs?de(u.ref)?u.refs.length>1?u.refs.forEach(y=>(!y.defaultChecked||!y.disabled)&&(y.checked=Array.isArray(d)?!!d.find(F=>F===y.value):d===y.value)):u.refs[0]&&(u.refs[0].checked=!!d):u.refs.forEach(y=>y.checked=y.value===d):Oe(u.ref)?u.ref.value="":(u.ref.value=d,u.ref.type||b.watch.next({name:r})))}(o.shouldDirty||o.shouldTouch)&&z(r,d,o.shouldTouch,o.shouldDirty,!0),o.shouldValidate&&Q(r)},w=(r,n,o)=>{for(const c in n){const d=n[c],u=`${r}.${c}`,y=f(l,u);(g.array.has(r)||!be(d)||y&&!y._f)&&!ne(d)?w(u,d,o):k(u,d,o)}},_=(r,n,o={})=>{const c=f(l,r),d=g.array.has(r),u=te(n);A(a,r,u),d?(b.array.next({name:r,values:a}),(p.isDirty||p.dirtyFields)&&o.shouldDirty&&(t.dirtyFields=_e(s,a),b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:v(r,u)}))):c&&!c._f&&!N(u)?w(r,u,o):k(r,u,o),$e(r,g)&&b.state.next({}),b.watch.next({name:r})},G=async r=>{const n=r.target;let o=n.name;const c=f(l,o);if(c){let d,u;const y=n.type?Fe(c._f):bt(r),F=r.type===He.BLUR||r.type===He.FOCUS_OUT,M=!Lt(c._f)&&!i.resolver&&!f(t.errors,o)&&!c._f.deps||Ot(F,f(t.touchedFields,o),t.isSubmitted,q,U),ye=$e(o,g,F);A(a,o,y),F?(c._f.onBlur&&c._f.onBlur(r),E&&E(0)):c._f.onChange&&c._f.onChange(r);const Ee=z(o,y,F,!1),dt=!B(Ee)||ye;if(!F&&b.watch.next({name:o,type:r.type}),M)return p.isValid&&P(),dt&&b.state.next({name:o,...ye?{}:Ee});if(!F&&ye&&b.state.next({}),O[o]=O[o]?O[o]+1:1,b.state.next({isValidating:!0}),i.resolver){const{errors:Ne}=await K([o]),ft=Qe(t.errors,l,o),qe=Qe(Ne,l,ft.name||o);d=qe.error,o=qe.name,u=B(Ne)}else d=(await ze(c,f(a,o),re,i.shouldUseNativeValidation))[o],P();c._f.deps&&Q(c._f.deps),ie(o,u,d,Ee)}},Q=async(r,n={})=>{let o,c;const d=Ae(r);if(b.state.next({isValidating:!0}),i.resolver){const u=await J(T(r)?r:d);o=B(u),c=r?!d.some(y=>f(u,y)):o}else r?(c=(await Promise.all(d.map(async u=>{const y=f(l,u);return await R(y&&y._f?{[u]:y}:y)}))).every(Boolean),!(!c&&!t.isValid)&&P()):c=o=await R(l);return b.state.next({...!W(r)||p.isValid&&o!==t.isValid?{}:{name:r},...i.resolver||!r?{isValid:o}:{},errors:t.errors,isValidating:!1}),n.shouldFocus&&!c&&Ve(l,u=>u&&f(t.errors,u),r?d:g.mount),c},X=r=>{const n={...s,...m.mount?a:{}};return T(r)?n:W(r)?f(n,r):r.map(o=>f(n,o))},Me=(r,n)=>({invalid:!!f((n||t).errors,r),isDirty:!!f((n||t).dirtyFields,r),isTouched:!!f((n||t).touchedFields,r),error:f((n||t).errors,r)}),nt=r=>{r?Ae(r).forEach(n=>I(t.errors,n)):t.errors={},b.state.next({errors:t.errors})},ot=(r,n,o)=>{const c=(f(l,r,{_f:{}})._f||{}).ref;A(t.errors,r,{...n,ref:c}),b.state.next({name:r,errors:t.errors,isValid:!1}),o&&o.shouldFocus&&c&&c.focus&&c.focus()},lt=(r,n)=>he(r)?b.watch.subscribe({next:o=>r(x(void 0,n),o)}):x(r,n,!0),ke=(r,n={})=>{for(const o of r?Ae(r):g.mount)g.mount.delete(o),g.array.delete(o),f(l,o)&&(n.keepValue||(I(l,o),I(a,o)),!n.keepError&&I(t.errors,o),!n.keepDirty&&I(t.dirtyFields,o),!n.keepTouched&&I(t.touchedFields,o),!i.shouldUnregister&&!n.keepDefaultValue&&I(s,o));b.watch.next({}),b.state.next({...t,...n.keepDirty?{isDirty:v()}:{}}),!n.keepIsValid&&P()},pe=(r,n={})=>{let o=f(l,r);const c=ce(n.disabled);return A(l,r,{...o||{},_f:{...o&&o._f?o._f:{ref:{name:r}},name:r,mount:!0,...n}}),g.mount.add(r),o?c&&A(a,r,n.disabled?void 0:f(a,r,Fe(o._f))):D(r,!0,n.value),{...c?{disabled:n.disabled}:{},...i.shouldUseNativeValidation?{required:!!n.required,min:ue(n.min),max:ue(n.max),minLength:ue(n.minLength),maxLength:ue(n.maxLength),pattern:ue(n.pattern)}:{},name:r,onChange:G,onBlur:G,ref:d=>{if(d){pe(r,n),o=f(l,r);const u=T(d.value)&&d.querySelectorAll&&d.querySelectorAll("input,select,textarea")[0]||d,y=Tt(u),F=o._f.refs||[];if(y?F.find(M=>M===u):u===o._f.ref)return;A(l,r,{_f:{...o._f,...y?{refs:[...F.filter(Se),u,...Array.isArray(f(s,r))?[{}]:[]],ref:{type:u.type,name:r}}:{ref:u}}}),D(r,!1,void 0,u)}else o=f(l,r,{}),o._f&&(o._f.mount=!1),(i.shouldUnregister||n.shouldUnregister)&&!(kt(g.array,r)&&m.action)&&g.unMount.add(r)}}},Ie=()=>i.shouldFocusError&&Ve(l,r=>r&&f(t.errors,r),g.mount),at=(r,n)=>async o=>{o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let c=!0,d=te(a);b.state.next({isSubmitting:!0});try{if(i.resolver){const{errors:u,values:y}=await K();t.errors=u,d=y}else await R(l);B(t.errors)?(b.state.next({errors:{},isSubmitting:!0}),await r(d,o)):(n&&await n({...t.errors},o),Ie())}catch(u){throw c=!1,u}finally{t.isSubmitted=!0,b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(t.errors)&&c,submitCount:t.submitCount+1,errors:t.errors})}},ut=(r,n={})=>{f(l,r)&&(T(n.defaultValue)?_(r,f(s,r)):(_(r,n.defaultValue),A(s,r,n.defaultValue)),n.keepTouched||I(t.touchedFields,r),n.keepDirty||(I(t.dirtyFields,r),t.isDirty=n.defaultValue?v(r,f(s,r)):v()),n.keepError||(I(t.errors,r),p.isValid&&P()),b.state.next({...t}))},ct=(r,n={})=>{const o=r||s,c=te(o),d=r&&!B(r)?c:s;if(n.keepDefaultValues||(s=o),!n.keepValues){if(n.keepDirtyValues)for(const u of g.mount)f(t.dirtyFields,u)?A(d,u,f(a,u)):_(u,f(d,u));else{if(Te&&T(r))for(const u of g.mount){const y=f(l,u);if(y&&y._f){const F=Array.isArray(y._f.refs)?y._f.refs[0]:y._f.ref;if(Ce(F)){const M=F.closest("form");if(M){M.reset();break}}}}l={}}a=e.shouldUnregister?n.keepDefaultValues?te(s):{}:c,b.array.next({values:d}),b.watch.next({values:d})}g={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},m.mount=!p.isValid||!!n.keepIsValid,m.watch=!!e.shouldUnregister,b.state.next({submitCount:n.keepSubmitCount?t.submitCount:0,isDirty:n.keepDirty||n.keepDirtyValues?t.isDirty:!!(n.keepDefaultValues&&!oe(r,s)),isSubmitted:n.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:n.keepDirty||n.keepDirtyValues?t.dirtyFields:n.keepDefaultValues&&r?_e(s,r):{},touchedFields:n.keepTouched?t.touchedFields:{},errors:n.keepErrors?t.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})};return{control:{register:pe,unregister:ke,getFieldState:Me,_executeSchema:K,_focusError:Ie,_getWatch:x,_getDirty:v,_updateValid:P,_removeUnmounted:Z,_updateFieldArray:C,_getFieldArray:S,_subjects:b,_proxyFormState:p,get _fields(){return l},get _formValues(){return a},get _stateFlags(){return m},set _stateFlags(r){m=r},get _defaultValues(){return s},get _names(){return g},set _names(r){g=r},get _formState(){return t},set _formState(r){t=r},get _options(){return i},set _options(r){i={...i,...r}}},trigger:Q,register:pe,handleSubmit:at,watch:lt,setValue:_,getValues:X,reset:(r,n)=>ct(he(r)?r(a):r,n),resetField:ut,clearErrors:nt,unregister:ke,setError:ot,setFocus:(r,n={})=>{const o=f(l,r),c=o&&o._f;if(c){const d=c.refs?c.refs[0]:c.ref;d.focus&&(d.focus(),n.shouldSelect&&d.select())}},getFieldState:Me}}function Nt(e={}){const i=h.useRef(),[t,l]=h.useState({isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:e.defaultValues});i.current||(i.current={...It(e),formState:t});const s=i.current.control;return s._options=e,wt({subject:s._subjects.state,callback:h.useCallback(a=>{Et(a,s._proxyFormState,!0)&&(s._formState={...s._formState,...a},l({...s._formState}))},[s])}),h.useEffect(()=>{s._stateFlags.mount||(s._proxyFormState.isValid&&s._updateValid(),s._stateFlags.mount=!0),s._stateFlags.watch&&(s._stateFlags.watch=!1,s._subjects.state.next({})),s._removeUnmounted()}),h.useEffect(()=>{t.submitCount&&s._focusError()},[s,t.submitCount]),i.current.formState=pt(t,s),i.current}var qt=(e=>(e.formgroup="formgroup",e.checkbox="checkbox",e.radiobutton="radiobutton",e.textarea="textarea",e.input="input",e.select="select",e.date="date",e))(qt||{});const Lr=e=>{const{exampleType:i="formgroup"}=e,{register:t,handleSubmit:l,formState:{errors:s}}=Nt(),a=new Date;a.setHours(0),a.setMinutes(0),a.setSeconds(0);const m=new Date;m.setDate(a.getDate()-5),m.setHours(6),m.setMinutes(10),m.setSeconds(0);const g=new Date;g.setDate(a.getDate()+5),g.setHours(22),g.setMinutes(0),g.setSeconds(0);const E="field1",V="field2",O="field3",p="field4",b="field5",U="field6",q="field7",re="field8",le="field9",P=s.field1||s.field2||s.field3||s.field4||s.field5||s.field6||s.field7||s.field8||s.field9,C="Du m\xE5 velge et alternativ",H="Du m\xE5 velge to alternativ",D="Det kan ikke legges inn mer enn 40 tegn",z="Du m\xE5 skrive noe her",ie='Du m\xE5 velge "Option 2"',K=`Du m\xE5 velge dato mellom ${m.toLocaleDateString("nb")} og ${g.toLocaleDateString("nb")}`,J=`Du m\xE5 skrive inn tidspunkt mellom ${m.toLocaleTimeString("nb",{hour:"2-digit",minute:"2-digit"})} og ${g.toLocaleTimeString("nb",{hour:"2-digit",minute:"2-digit"})}`,R=k=>k.length>=2||H,Z=k=>k.toString()==="Option 2"||ie,v=(k,w,_)=>{const G=new Date(k);return!!k&&G.getTime()>=w.getTime()&&G.getTime()<=_.getTime()||K},x=(k,w)=>{const _=new Date;_.setHours(k),_.setMinutes(w),_.setSeconds(0);const G=m.toLocaleTimeString("nb"),Q=g.toLocaleTimeString("nb"),X=_.toLocaleTimeString("nb");return console.log("value",X),!!_&&X>=G&&X<=Q||J},S=()=>{if(i==="formgroup"){const k=[h.createElement(ee,{key:0,inputId:"checkbox1",label:"Checkbox 1",...t(E,{required:C})}),h.createElement(ee,{key:1,inputId:"checkbox2",label:"Checkbox 2",...t(E,{required:C})}),h.createElement(ee,{key:2,inputId:"checkbox3",label:"Checkbox 3",...t(E,{required:C})})];return[h.createElement(Y,{key:0,title:"Gruppe tittel",legend:"Velg minst en",error:s.field1?s.field1.message:void 0,variant:e.variant},h.createElement(gt,{maxColumns:ht.two},k.map(w=>w))),h.createElement(Y,{key:1,legend:"Velg minst to",error:s.field2?s.field2.message:void 0,variant:e.variant},h.createElement(ee,{inputId:"checkbox4",label:"Checkbox 4",...t(V,{validate:R})}),h.createElement(ee,{inputId:"checkbox5",label:"Checkbox 5",...t(V,{validate:R})}),h.createElement(ee,{inputId:"checkbox6",label:"Checkbox 6",...t(V,{validate:R})})),h.createElement(Y,{key:2,legend:"Velg en",error:s.field3?s.field3.message:void 0,variant:e.variant},h.createElement(me,{inputId:"radiobutton1",label:"Radiobutton 1",...t(O,{required:C})}),h.createElement(me,{inputId:"radiobutton2",label:"Radiobutton 2",...t(O,{required:C})}),h.createElement(me,{inputId:"radiobutton3",label:"Radiobutton 3",...t(O,{required:C})})),h.createElement(Y,{key:3,error:s.field4?s.field4.message:void 0},h.createElement(Be,{defaultValue:`Dette er en test
1
+ import h from"react";import{V as mt}from"../../Validation.js";import{F as Y}from"../../FormGroup.js";import{C as ee}from"../../Checkbox.js";import{B as yt}from"../../Button.js";import{R as ye}from"../../RadioButton.js";import{T as Be}from"../../Textarea.js";import{I as le}from"../../Input.js";import Ue from"../Icons/Hospital.js";import{F as gt,a as ht}from"../../FormLayout.js";import{isTest as vt}from"../../utils/environment.js";import{S as Pe}from"../../Select.js";import ge from"./styles.module.scss";import"classnames";import"../Validation/styles.module.scss";import"../../constants.js";import"../FormGroup/styles.module.scss";import"../../Title.js";import"../Title/styles.module.scss";import"../../ErrorWrapper.js";import"../ErrorWrapper/styles.module.scss";import"../../utils/component.js";import"../../uuid.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../hooks/useUuid.js";import"../../theme/currys/color.js";import"../../theme/index.js";import"../../theme/palette.js";import"../../theme/spacers.js";import"../../theme/grid.js";import"../Checkbox/styles.module.scss";import"../../hooks/useHover.js";import"../../hooks/useIcons.js";import"../../hooks/useBreakpoint.js";import"../Button/styles.module.scss";import"../Icons/ArrowRight.js";import"../../hooks/useSize.js";import"../../utils/debounce.js";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../../MaxCharacters.js";import"../MaxCharacters/styles.module.scss";import"../Input/styles.module.scss";import"../FormLayout/styles.module.scss";import"../Select/styles.module.scss";import"../Icons/ChevronDown.js";var de=e=>e.type==="checkbox",ne=e=>e instanceof Date,N=e=>e==null;const Xe=e=>typeof e=="object";var L=e=>!N(e)&&!Array.isArray(e)&&Xe(e)&&!ne(e),bt=e=>L(e)&&e.target?de(e.target)?e.target.checked:e.target.value:e,xt=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,kt=(e,i)=>e.has(xt(i)),fe=e=>Array.isArray(e)?e.filter(Boolean):[],T=e=>e===void 0,f=(e,i,t)=>{if(!i||!L(e))return t;const a=fe(i.split(/[,[\].]+?/)).reduce((s,l)=>N(s)?s:s[l],e);return T(a)||a===e?T(e[i])?t:e[i]:a};const He={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},$={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},j={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};h.createContext(null);var pt=(e,i,t,a=!0)=>{const s={defaultValues:i._defaultValues};for(const l in e)Object.defineProperty(s,l,{get:()=>{const y=l;return i._proxyFormState[y]!==$.all&&(i._proxyFormState[y]=!a||$.all),t&&(t[y]=!0),e[y]}});return s},B=e=>L(e)&&!Object.keys(e).length,Et=(e,i,t)=>{const{name:a,...s}=e;return B(s)||Object.keys(s).length>=Object.keys(i).length||Object.keys(s).find(l=>i[l]===(!t||$.all))},_e=e=>Array.isArray(e)?e:[e];function wt(e){const i=h.useRef(e);i.current=e,h.useEffect(()=>{const t=!e.disabled&&i.current.subject.subscribe({next:i.current.callback});return()=>{t&&t.unsubscribe()}},[e.disabled])}var W=e=>typeof e=="string",_t=(e,i,t,a)=>{const s=Array.isArray(e);return W(e)?(a&&i.watch.add(e),f(t,e)):s?e.map(l=>(a&&i.watch.add(l),f(t,l))):(a&&(i.watchAll=!0),t)},ve=e=>typeof e=="function",Ye=e=>{for(const i in e)if(ve(e[i]))return!0;return!1},At=(e,i,t,a,s)=>i?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:s||!0}}:{},Le=e=>/^\w*$/.test(e),Ze=e=>fe(e.replace(/["|']|\]/g,"").split(/\.|\[/));function _(e,i,t){let a=-1;const s=Le(i)?[i]:Ze(i),l=s.length,y=l-1;for(;++a<l;){const g=s[a];let E=t;if(a!==y){const V=e[g];E=L(V)||Array.isArray(V)?V:isNaN(+s[a+1])?{}:[]}e[g]=E,e=e[g]}return e}const Ve=(e,i,t)=>{for(const a of t||Object.keys(e)){const s=f(e,a);if(s){const{_f:l,...y}=s;if(l&&i(l.name)){if(l.ref.focus){l.ref.focus();break}else if(l.refs&&l.refs[0].focus){l.refs[0].focus();break}}else L(y)&&Ve(y,i)}}};var $e=(e,i,t)=>!t&&(i.watchAll||i.watch.has(e)||[...i.watch].some(a=>e.startsWith(a)&&/^\.\w+/.test(e.slice(a.length)))),Dt=(e,i,t)=>{const a=fe(f(e,t));return _(a,"root",i[t]),_(e,t,a),e},ce=e=>typeof e=="boolean",Oe=e=>e.type==="file",he=e=>W(e)||h.isValidElement(e),Re=e=>e.type==="radio",be=e=>e instanceof RegExp;const We={value:!1,isValid:!1},Ge={value:!0,isValid:!0};var et=e=>{if(Array.isArray(e)){if(e.length>1){const i=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:i,isValid:!!i.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!T(e[0].attributes.value)?T(e[0].value)||e[0].value===""?Ge:{value:e[0].value,isValid:!0}:Ge:We}return We};const Ke={isValid:!1,value:null};var tt=e=>Array.isArray(e)?e.reduce((i,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:i,Ke):Ke;function je(e,i,t="validate"){if(he(e)||Array.isArray(e)&&e.every(he)||ce(e)&&!e)return{type:t,message:he(e)?e:"",ref:i}}var se=e=>L(e)&&!be(e)?e:{value:e,message:""},ze=async(e,i,t,a,s)=>{const{ref:l,refs:y,required:g,maxLength:E,minLength:V,min:O,max:p,pattern:b,validate:U,name:q,valueAsNumber:re,mount:ae,disabled:P}=e._f;if(!ae||P)return{};const C=y?y[0]:l,H=v=>{a&&W(v)&&(C.setCustomValidity(v),C.reportValidity())},A={},z=Re(l),ie=de(l),K=z||ie,J=(re||Oe(l))&&!l.value||i===""||Array.isArray(i)&&!i.length,R=At.bind(null,q,t,A),Z=(v,x,D,k=j.maxLength,w=j.minLength)=>{const S=v?x:D;A[q]={type:v?k:w,message:S,ref:l,...R(v?k:w,S)}};if(s?!Array.isArray(i)||!i.length:g&&(!K&&(J||N(i))||ce(i)&&!i||ie&&!et(y).isValid||z&&!tt(y).isValid)){const{value:v,message:x}=he(g)?{value:!!g,message:g}:se(g);if(v&&(A[q]={type:j.required,message:x,ref:C,...R(j.required,x)},!t))return H(x),A}if(!J&&(!N(O)||!N(p))){let v,x;const D=se(p),k=se(O);if(!N(i)&&!isNaN(i)){const w=l.valueAsNumber||i&&+i;N(D.value)||(v=w>D.value),N(k.value)||(x=w<k.value)}else{const w=l.valueAsDate||new Date(i),S=X=>new Date(new Date().toDateString()+" "+X),G=l.type=="time",Q=l.type=="week";W(D.value)&&i&&(v=G?S(i)>S(D.value):Q?i>D.value:w>new Date(D.value)),W(k.value)&&i&&(x=G?S(i)<S(k.value):Q?i<k.value:w<new Date(k.value))}if((v||x)&&(Z(!!v,D.message,k.message,j.max,j.min),!t))return H(A[q].message),A}if((E||V)&&!J&&(W(i)||s&&Array.isArray(i))){const v=se(E),x=se(V),D=!N(v.value)&&i.length>v.value,k=!N(x.value)&&i.length<x.value;if((D||k)&&(Z(D,v.message,x.message),!t))return H(A[q].message),A}if(b&&!J&&W(i)){const{value:v,message:x}=se(b);if(be(v)&&!i.match(v)&&(A[q]={type:j.pattern,message:x,ref:l,...R(j.pattern,x)},!t))return H(x),A}if(U){if(ve(U)){const v=await U(i),x=je(v,C);if(x&&(A[q]={...x,...R(j.validate,x.message)},!t))return H(x.message),A}else if(L(U)){let v={};for(const x in U){if(!B(v)&&!t)break;const D=je(await U[x](i),C,x);D&&(v={...D,...R(x,D.message)},H(D.message),t&&(A[q]=v))}if(!B(v)&&(A[q]={ref:C,...v},!t))return A}}return H(!0),A},St=e=>{const i=e.constructor&&e.constructor.prototype;return L(i)&&i.hasOwnProperty("isPrototypeOf")},Te=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function te(e){let i;const t=Array.isArray(e);if(e instanceof Date)i=new Date(e);else if(e instanceof Set)i=new Set(e);else if(!(Te&&(e instanceof Blob||e instanceof FileList))&&(t||L(e)))if(i=t?[]:{},!Array.isArray(e)&&!St(e))i=e;else for(const a in e)i[a]=te(e[a]);else return e;return i}var Je=e=>({isOnSubmit:!e||e===$.onSubmit,isOnBlur:e===$.onBlur,isOnChange:e===$.onChange,isOnAll:e===$.all,isOnTouch:e===$.onTouched});function Ft(e,i){const t=i.slice(0,-1).length;let a=0;for(;a<t;)e=T(e)?a++:e[i[a++]];return e}function Vt(e){for(const i in e)if(!T(e[i]))return!1;return!0}function I(e,i){const t=Le(i)?[i]:Ze(i),a=t.length==1?e:Ft(e,t),s=t[t.length-1];let l;a&&delete a[s];for(let y=0;y<t.slice(0,-1).length;y++){let g=-1,E;const V=t.slice(0,-(y+1)),O=V.length-1;for(y>0&&(l=e);++g<V.length;){const p=V[g];E=E?E[p]:e[p],O===g&&(L(E)&&B(E)||Array.isArray(E)&&Vt(E))&&(l?delete l[p]:delete e[p]),l=E}}return e}function Ae(){let e=[];return{get observers(){return e},next:s=>{for(const l of e)l.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(l=>l!==s)}}),unsubscribe:()=>{e=[]}}}var xe=e=>N(e)||!Xe(e);function oe(e,i){if(xe(e)||xe(i))return e===i;if(ne(e)&&ne(i))return e.getTime()===i.getTime();const t=Object.keys(e),a=Object.keys(i);if(t.length!==a.length)return!1;for(const s of t){const l=e[s];if(!a.includes(s))return!1;if(s!=="ref"){const y=i[s];if(ne(l)&&ne(y)||L(l)&&L(y)||Array.isArray(l)&&Array.isArray(y)?!oe(l,y):l!==y)return!1}}return!0}var Ce=e=>{const i=e?e.ownerDocument:0,t=i&&i.defaultView?i.defaultView.HTMLElement:HTMLElement;return e instanceof t},rt=e=>e.type==="select-multiple",Tt=e=>Re(e)||de(e),De=e=>Ce(e)&&e.isConnected;function ke(e,i={}){const t=Array.isArray(e);if(L(e)||t)for(const a in e)Array.isArray(e[a])||L(e[a])&&!Ye(e[a])?(i[a]=Array.isArray(e[a])?[]:{},ke(e[a],i[a])):N(e[a])||(i[a]=!0);return i}function it(e,i,t){const a=Array.isArray(e);if(L(e)||a)for(const s in e)Array.isArray(e[s])||L(e[s])&&!Ye(e[s])?T(i)||xe(t[s])?t[s]=Array.isArray(e[s])?ke(e[s],[]):{...ke(e[s])}:it(e[s],N(i)?{}:i[s],t[s]):oe(e[s],i[s])?delete t[s]:t[s]=!0;return t}var Se=(e,i)=>it(e,i,ke(i)),st=(e,{valueAsNumber:i,valueAsDate:t,setValueAs:a})=>T(e)?e:i?e===""?NaN:e&&+e:t&&W(e)?new Date(e):a?a(e):e;function Fe(e){const i=e.ref;if(!(e.refs?e.refs.every(t=>t.disabled):i.disabled))return Oe(i)?i.files:Re(i)?tt(e.refs).value:rt(i)?[...i.selectedOptions].map(({value:t})=>t):de(i)?et(e.refs).value:st(T(i.value)?e.ref.value:i.value,e)}var Ct=(e,i,t,a)=>{const s={};for(const l of e){const y=f(i,l);y&&_(s,l,y._f)}return{criteriaMode:t,names:[...e],fields:s,shouldUseNativeValidation:a}},ue=e=>T(e)?void 0:be(e)?e.source:L(e)?be(e.value)?e.value.source:e.value:e,Lt=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Qe(e,i,t){const a=f(e,t);if(a||Le(t))return{error:a,name:t};const s=t.split(".");for(;s.length;){const l=s.join("."),y=f(i,l),g=f(e,l);if(y&&!Array.isArray(y)&&t!==l)return{name:t};if(g&&g.type)return{name:l,error:g};s.pop()}return{name:t}}var Ot=(e,i,t,a,s)=>s.isOnAll?!1:!t&&s.isOnTouch?!(i||e):(t?a.isOnBlur:s.isOnBlur)?!e:(t?a.isOnChange:s.isOnChange)?e:!0,Rt=(e,i)=>!fe(f(e,i)).length&&I(e,i);const Mt={mode:$.onSubmit,reValidateMode:$.onChange,shouldFocusError:!0};function It(e={}){let i={...Mt,...e},t={submitCount:0,isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},a={},s=te(i.defaultValues)||{},l=i.shouldUnregister?{}:te(s),y={action:!1,mount:!1,watch:!1},g={mount:new Set,unMount:new Set,array:new Set,watch:new Set},E,V=0,O={};const p={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={watch:Ae(),array:Ae(),state:Ae()},U=Je(i.mode),q=Je(i.reValidateMode),re=i.criteriaMode===$.all,ae=r=>n=>{clearTimeout(V),V=window.setTimeout(r,n)},P=async()=>{let r=!1;return p.isValid&&(r=i.resolver?B((await K()).errors):await R(a,!0),r!==t.isValid&&(t.isValid=r,b.state.next({isValid:r}))),r},C=(r,n=[],o,c,d=!0,u=!0)=>{if(c&&o){if(y.action=!0,u&&Array.isArray(f(a,r))){const m=o(f(a,r),c.argA,c.argB);d&&_(a,r,m)}if(p.errors&&u&&Array.isArray(f(t.errors,r))){const m=o(f(t.errors,r),c.argA,c.argB);d&&_(t.errors,r,m),Rt(t.errors,r)}if(p.touchedFields&&u&&Array.isArray(f(t.touchedFields,r))){const m=o(f(t.touchedFields,r),c.argA,c.argB);d&&_(t.touchedFields,r,m)}p.dirtyFields&&(t.dirtyFields=Se(s,l)),b.state.next({isDirty:v(r,n),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else _(l,r,n)},H=(r,n)=>{_(t.errors,r,n),b.state.next({errors:t.errors})},A=(r,n,o,c)=>{const d=f(a,r);if(d){const u=f(l,r,T(o)?f(s,r):o);T(u)||c&&c.defaultChecked||n?_(l,r,n?u:Fe(d._f)):k(r,u),y.mount&&P()}},z=(r,n,o,c,d)=>{let u=!1;const m={name:r},F=f(t.touchedFields,r);if(p.isDirty){const M=t.isDirty;t.isDirty=m.isDirty=v(),u=M!==m.isDirty}if(p.dirtyFields&&(!o||c)){const M=f(t.dirtyFields,r);oe(f(s,r),n)?I(t.dirtyFields,r):_(t.dirtyFields,r,!0),m.dirtyFields=t.dirtyFields,u=u||M!==f(t.dirtyFields,r)}return o&&!F&&(_(t.touchedFields,r,o),m.touchedFields=t.touchedFields,u=u||p.touchedFields&&F!==o),u&&d&&b.state.next(m),u?m:{}},ie=(r,n,o,c)=>{const d=f(t.errors,r),u=p.isValid&&ce(n)&&t.isValid!==n;if(e.delayError&&o?(E=ae(()=>H(r,o)),E(e.delayError)):(clearTimeout(V),E=null,o?_(t.errors,r,o):I(t.errors,r)),(o?!oe(d,o):d)||!B(c)||u){const m={...c,...u&&ce(n)?{isValid:n}:{},errors:t.errors,name:r};t={...t,...m},b.state.next(m)}O[r]--,p.isValidating&&!Object.values(O).some(m=>m)&&(b.state.next({isValidating:!1}),O={})},K=async r=>i.resolver?await i.resolver({...l},i.context,Ct(r||g.mount,a,i.criteriaMode,i.shouldUseNativeValidation)):{},J=async r=>{const{errors:n}=await K();if(r)for(const o of r){const c=f(n,o);c?_(t.errors,o,c):I(t.errors,o)}else t.errors=n;return n},R=async(r,n,o={valid:!0})=>{for(const c in r){const d=r[c];if(d){const{_f:u,...m}=d;if(u){const F=g.array.has(u.name),M=await ze(d,f(l,u.name),re,i.shouldUseNativeValidation,F);if(M[u.name]&&(o.valid=!1,n))break;!n&&(f(M,u.name)?F?Dt(t.errors,M,u.name):_(t.errors,u.name,M[u.name]):I(t.errors,u.name))}m&&await R(m,n,o)}}return o.valid},Z=()=>{for(const r of g.unMount){const n=f(a,r);n&&(n._f.refs?n._f.refs.every(o=>!De(o)):!De(n._f.ref))&&pe(r)}g.unMount=new Set},v=(r,n)=>(r&&n&&_(l,r,n),!oe(X(),s)),x=(r,n,o)=>{const c={...y.mount?l:T(n)?s:W(r)?{[r]:n}:n};return _t(r,g,c,o)},D=r=>fe(f(y.mount?l:s,r,e.shouldUnregister?f(s,r,[]):[])),k=(r,n,o={})=>{const c=f(a,r);let d=n;if(c){const u=c._f;u&&(!u.disabled&&_(l,r,st(n,u)),d=Te&&Ce(u.ref)&&N(n)?"":n,rt(u.ref)?[...u.ref.options].forEach(m=>m.selected=d.includes(m.value)):u.refs?de(u.ref)?u.refs.length>1?u.refs.forEach(m=>(!m.defaultChecked||!m.disabled)&&(m.checked=Array.isArray(d)?!!d.find(F=>F===m.value):d===m.value)):u.refs[0]&&(u.refs[0].checked=!!d):u.refs.forEach(m=>m.checked=m.value===d):Oe(u.ref)?u.ref.value="":(u.ref.value=d,u.ref.type||b.watch.next({name:r})))}(o.shouldDirty||o.shouldTouch)&&z(r,d,o.shouldTouch,o.shouldDirty,!0),o.shouldValidate&&Q(r)},w=(r,n,o)=>{for(const c in n){const d=n[c],u=`${r}.${c}`,m=f(a,u);(g.array.has(r)||!xe(d)||m&&!m._f)&&!ne(d)?w(u,d,o):k(u,d,o)}},S=(r,n,o={})=>{const c=f(a,r),d=g.array.has(r),u=te(n);_(l,r,u),d?(b.array.next({name:r,values:l}),(p.isDirty||p.dirtyFields)&&o.shouldDirty&&(t.dirtyFields=Se(s,l),b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:v(r,u)}))):c&&!c._f&&!N(u)?w(r,u,o):k(r,u,o),$e(r,g)&&b.state.next({}),b.watch.next({name:r})},G=async r=>{const n=r.target;let o=n.name;const c=f(a,o);if(c){let d,u;const m=n.type?Fe(c._f):bt(r),F=r.type===He.BLUR||r.type===He.FOCUS_OUT,M=!Lt(c._f)&&!i.resolver&&!f(t.errors,o)&&!c._f.deps||Ot(F,f(t.touchedFields,o),t.isSubmitted,q,U),me=$e(o,g,F);_(l,o,m),F?(c._f.onBlur&&c._f.onBlur(r),E&&E(0)):c._f.onChange&&c._f.onChange(r);const we=z(o,m,F,!1),dt=!B(we)||me;if(!F&&b.watch.next({name:o,type:r.type}),M)return p.isValid&&P(),dt&&b.state.next({name:o,...me?{}:we});if(!F&&me&&b.state.next({}),O[o]=O[o]?O[o]+1:1,b.state.next({isValidating:!0}),i.resolver){const{errors:Ne}=await K([o]),ft=Qe(t.errors,a,o),qe=Qe(Ne,a,ft.name||o);d=qe.error,o=qe.name,u=B(Ne)}else d=(await ze(c,f(l,o),re,i.shouldUseNativeValidation))[o],P();c._f.deps&&Q(c._f.deps),ie(o,u,d,we)}},Q=async(r,n={})=>{let o,c;const d=_e(r);if(b.state.next({isValidating:!0}),i.resolver){const u=await J(T(r)?r:d);o=B(u),c=r?!d.some(m=>f(u,m)):o}else r?(c=(await Promise.all(d.map(async u=>{const m=f(a,u);return await R(m&&m._f?{[u]:m}:m)}))).every(Boolean),!(!c&&!t.isValid)&&P()):c=o=await R(a);return b.state.next({...!W(r)||p.isValid&&o!==t.isValid?{}:{name:r},...i.resolver||!r?{isValid:o}:{},errors:t.errors,isValidating:!1}),n.shouldFocus&&!c&&Ve(a,u=>u&&f(t.errors,u),r?d:g.mount),c},X=r=>{const n={...s,...y.mount?l:{}};return T(r)?n:W(r)?f(n,r):r.map(o=>f(n,o))},Me=(r,n)=>({invalid:!!f((n||t).errors,r),isDirty:!!f((n||t).dirtyFields,r),isTouched:!!f((n||t).touchedFields,r),error:f((n||t).errors,r)}),nt=r=>{r?_e(r).forEach(n=>I(t.errors,n)):t.errors={},b.state.next({errors:t.errors})},ot=(r,n,o)=>{const c=(f(a,r,{_f:{}})._f||{}).ref;_(t.errors,r,{...n,ref:c}),b.state.next({name:r,errors:t.errors,isValid:!1}),o&&o.shouldFocus&&c&&c.focus&&c.focus()},at=(r,n)=>ve(r)?b.watch.subscribe({next:o=>r(x(void 0,n),o)}):x(r,n,!0),pe=(r,n={})=>{for(const o of r?_e(r):g.mount)g.mount.delete(o),g.array.delete(o),f(a,o)&&(n.keepValue||(I(a,o),I(l,o)),!n.keepError&&I(t.errors,o),!n.keepDirty&&I(t.dirtyFields,o),!n.keepTouched&&I(t.touchedFields,o),!i.shouldUnregister&&!n.keepDefaultValue&&I(s,o));b.watch.next({}),b.state.next({...t,...n.keepDirty?{isDirty:v()}:{}}),!n.keepIsValid&&P()},Ee=(r,n={})=>{let o=f(a,r);const c=ce(n.disabled);return _(a,r,{...o||{},_f:{...o&&o._f?o._f:{ref:{name:r}},name:r,mount:!0,...n}}),g.mount.add(r),o?c&&_(l,r,n.disabled?void 0:f(l,r,Fe(o._f))):A(r,!0,n.value),{...c?{disabled:n.disabled}:{},...i.shouldUseNativeValidation?{required:!!n.required,min:ue(n.min),max:ue(n.max),minLength:ue(n.minLength),maxLength:ue(n.maxLength),pattern:ue(n.pattern)}:{},name:r,onChange:G,onBlur:G,ref:d=>{if(d){Ee(r,n),o=f(a,r);const u=T(d.value)&&d.querySelectorAll&&d.querySelectorAll("input,select,textarea")[0]||d,m=Tt(u),F=o._f.refs||[];if(m?F.find(M=>M===u):u===o._f.ref)return;_(a,r,{_f:{...o._f,...m?{refs:[...F.filter(De),u,...Array.isArray(f(s,r))?[{}]:[]],ref:{type:u.type,name:r}}:{ref:u}}}),A(r,!1,void 0,u)}else o=f(a,r,{}),o._f&&(o._f.mount=!1),(i.shouldUnregister||n.shouldUnregister)&&!(kt(g.array,r)&&y.action)&&g.unMount.add(r)}}},Ie=()=>i.shouldFocusError&&Ve(a,r=>r&&f(t.errors,r),g.mount),lt=(r,n)=>async o=>{o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let c=!0,d=te(l);b.state.next({isSubmitting:!0});try{if(i.resolver){const{errors:u,values:m}=await K();t.errors=u,d=m}else await R(a);B(t.errors)?(b.state.next({errors:{},isSubmitting:!0}),await r(d,o)):(n&&await n({...t.errors},o),Ie())}catch(u){throw c=!1,u}finally{t.isSubmitted=!0,b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(t.errors)&&c,submitCount:t.submitCount+1,errors:t.errors})}},ut=(r,n={})=>{f(a,r)&&(T(n.defaultValue)?S(r,f(s,r)):(S(r,n.defaultValue),_(s,r,n.defaultValue)),n.keepTouched||I(t.touchedFields,r),n.keepDirty||(I(t.dirtyFields,r),t.isDirty=n.defaultValue?v(r,f(s,r)):v()),n.keepError||(I(t.errors,r),p.isValid&&P()),b.state.next({...t}))},ct=(r,n={})=>{const o=r||s,c=te(o),d=r&&!B(r)?c:s;if(n.keepDefaultValues||(s=o),!n.keepValues){if(n.keepDirtyValues)for(const u of g.mount)f(t.dirtyFields,u)?_(d,u,f(l,u)):S(u,f(d,u));else{if(Te&&T(r))for(const u of g.mount){const m=f(a,u);if(m&&m._f){const F=Array.isArray(m._f.refs)?m._f.refs[0]:m._f.ref;if(Ce(F)){const M=F.closest("form");if(M){M.reset();break}}}}a={}}l=e.shouldUnregister?n.keepDefaultValues?te(s):{}:c,b.array.next({values:d}),b.watch.next({values:d})}g={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},y.mount=!p.isValid||!!n.keepIsValid,y.watch=!!e.shouldUnregister,b.state.next({submitCount:n.keepSubmitCount?t.submitCount:0,isDirty:n.keepDirty||n.keepDirtyValues?t.isDirty:!!(n.keepDefaultValues&&!oe(r,s)),isSubmitted:n.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:n.keepDirty||n.keepDirtyValues?t.dirtyFields:n.keepDefaultValues&&r?Se(s,r):{},touchedFields:n.keepTouched?t.touchedFields:{},errors:n.keepErrors?t.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})};return{control:{register:Ee,unregister:pe,getFieldState:Me,_executeSchema:K,_focusError:Ie,_getWatch:x,_getDirty:v,_updateValid:P,_removeUnmounted:Z,_updateFieldArray:C,_getFieldArray:D,_subjects:b,_proxyFormState:p,get _fields(){return a},get _formValues(){return l},get _stateFlags(){return y},set _stateFlags(r){y=r},get _defaultValues(){return s},get _names(){return g},set _names(r){g=r},get _formState(){return t},set _formState(r){t=r},get _options(){return i},set _options(r){i={...i,...r}}},trigger:Q,register:Ee,handleSubmit:lt,watch:at,setValue:S,getValues:X,reset:(r,n)=>ct(ve(r)?r(l):r,n),resetField:ut,clearErrors:nt,unregister:pe,setError:ot,setFocus:(r,n={})=>{const o=f(a,r),c=o&&o._f;if(c){const d=c.refs?c.refs[0]:c.ref;d.focus&&(d.focus(),n.shouldSelect&&d.select())}},getFieldState:Me}}function Nt(e={}){const i=h.useRef(),[t,a]=h.useState({isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:e.defaultValues});i.current||(i.current={...It(e),formState:t});const s=i.current.control;return s._options=e,wt({subject:s._subjects.state,callback:h.useCallback(l=>{Et(l,s._proxyFormState,!0)&&(s._formState={...s._formState,...l},a({...s._formState}))},[s])}),h.useEffect(()=>{s._stateFlags.mount||(s._proxyFormState.isValid&&s._updateValid(),s._stateFlags.mount=!0),s._stateFlags.watch&&(s._stateFlags.watch=!1,s._subjects.state.next({})),s._removeUnmounted()}),h.useEffect(()=>{t.submitCount&&s._focusError()},[s,t.submitCount]),i.current.formState=pt(t,s),i.current}var qt=(e=>(e.formgroup="formgroup",e.checkbox="checkbox",e.radiobutton="radiobutton",e.textarea="textarea",e.input="input",e.select="select",e.date="date",e))(qt||{});const Rr=e=>{const{exampleType:i="formgroup"}=e,{register:t,handleSubmit:a,formState:{errors:s}}=Nt(),l=new Date;l.setHours(0),l.setMinutes(0),l.setSeconds(0);const y=new Date;y.setDate(l.getDate()-5),y.setHours(6),y.setMinutes(10),y.setSeconds(0);const g=new Date;g.setDate(l.getDate()+5),g.setHours(22),g.setMinutes(0),g.setSeconds(0);const E="field1",V="field2",O="field3",p="field4",b="field5",U="field6",q="field7",re="field8",ae="field9",P=s.field1||s.field2||s.field3||s.field4||s.field5||s.field6||s.field7||s.field8||s.field9,C="Du m\xE5 velge et alternativ",H="Du m\xE5 velge to alternativ",A="Det kan ikke legges inn mer enn 40 tegn",z="Du m\xE5 skrive noe her",ie='Du m\xE5 velge "Option 2"',K=`Du m\xE5 velge dato mellom ${y.toLocaleDateString("nb")} og ${g.toLocaleDateString("nb")}`,J=`Du m\xE5 skrive inn tidspunkt mellom ${y.toLocaleTimeString("nb",{hour:"2-digit",minute:"2-digit"})} og ${g.toLocaleTimeString("nb",{hour:"2-digit",minute:"2-digit"})}`,R=k=>k.length>=2||H,Z=k=>k.toString()==="Option 2"||ie,v=(k,w,S)=>{const G=new Date(k);return!!k&&G.getTime()>=w.getTime()&&G.getTime()<=S.getTime()||K},x=(k,w)=>{const S=new Date;S.setHours(k),S.setMinutes(w),S.setSeconds(0);const G=y.toLocaleTimeString("nb"),Q=g.toLocaleTimeString("nb"),X=S.toLocaleTimeString("nb");return console.log("value",X),!!S&&X>=G&&X<=Q||J},D=()=>{if(i==="formgroup"){const k=[h.createElement(ee,{key:0,inputId:"checkbox1",label:"Checkbox 1",...t(E,{required:C})}),h.createElement(ee,{key:1,inputId:"checkbox2",label:"Checkbox 2",...t(E,{required:C})}),h.createElement(ee,{key:2,inputId:"checkbox3",label:"Checkbox 3",...t(E,{required:C})})];return[h.createElement(Y,{key:0,title:"Gruppe tittel",legend:"Velg minst en",error:s.field1?s.field1.message:void 0,variant:e.variant},h.createElement(gt,{maxColumns:ht.two},k.map(w=>w))),h.createElement(Y,{key:1,legend:"Velg minst to",error:s.field2?s.field2.message:void 0,variant:e.variant},h.createElement(ee,{inputId:"checkbox4",label:"Checkbox 4",...t(V,{validate:R})}),h.createElement(ee,{inputId:"checkbox5",label:"Checkbox 5",...t(V,{validate:R})}),h.createElement(ee,{inputId:"checkbox6",label:"Checkbox 6",...t(V,{validate:R})})),h.createElement(Y,{key:2,legend:"Velg en",error:s.field3?s.field3.message:void 0,variant:e.variant},h.createElement(ye,{inputId:"radiobutton1",label:"Radiobutton 1",...t(O,{required:C})}),h.createElement(ye,{inputId:"radiobutton2",label:"Radiobutton 2",...t(O,{required:C})}),h.createElement(ye,{inputId:"radiobutton3",label:"Radiobutton 3",...t(O,{required:C})})),h.createElement(Y,{key:3,error:s.field4?s.field4.message:void 0},h.createElement(Be,{defaultValue:`Dette er en test
2
2
 
3
3
  Hello
4
4
 
5
5
  test
6
6
 
7
- test test`,grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",textareaId:"textarea1",...t(p,{maxLength:{value:40,message:D}})})),h.createElement(Y,{key:4,variant:e.variant,error:s.field5?s.field5.message:void 0},h.createElement(ae,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:Ue,...t(b,{required:z})})),h.createElement(Y,{key:5,variant:e.variant,error:s.field6?s.field6.message:void 0},h.createElement(Pe,{label:"Skriv inn din tekst",...t(U,{validate:Z})},h.createElement("option",{value:"Option 1"},"Option 1"),h.createElement("option",{value:"Option 2"},"Option 2"),h.createElement("option",{value:"Option 3"},"Option 3")))]}else{if(i==="checkbox")return h.createElement(ee,{inputId:"checkbox1",label:"Checkbox 1",errorText:s.field1?s.field1.message:void 0,variant:e.variant,...t(E,{required:C})});if(i==="radiobutton")return h.createElement(me,{inputId:"radiobutton1",label:"Radiobutton 1",errorText:s.field3?s.field3.message:void 0,variant:e.variant,...t(O,{required:C})});if(i==="textarea")return h.createElement(Be,{defaultValue:`Dette er min historie
7
+ test test`,grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",textareaId:"textarea1",...t(p,{maxLength:{value:40,message:A}})})),h.createElement(Y,{key:4,variant:e.variant,error:s.field5?s.field5.message:void 0},h.createElement(le,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:Ue,...t(b,{required:z})})),h.createElement(Y,{key:5,variant:e.variant,error:s.field6?s.field6.message:void 0},h.createElement(Pe,{label:"Skriv inn din tekst",...t(U,{validate:Z})},h.createElement("option",{value:"Option 1"},"Option 1"),h.createElement("option",{value:"Option 2"},"Option 2"),h.createElement("option",{value:"Option 3"},"Option 3")))]}else{if(i==="checkbox")return h.createElement(ee,{inputId:"checkbox1",label:"Checkbox 1",errorText:s.field1?s.field1.message:void 0,variant:e.variant,...t(E,{required:C})});if(i==="radiobutton")return h.createElement(ye,{inputId:"radiobutton1",label:"Radiobutton 1",errorText:s.field3?s.field3.message:void 0,variant:e.variant,...t(O,{required:C})});if(i==="textarea")return h.createElement(Be,{defaultValue:`Dette er min historie
8
8
 
9
9
  Hello
10
10
 
11
- test`,grow:!0,maxCharacters:40,minRows:5,errorText:s.field4?s.field4.message:void 0,label:"Skriv din historie her",textareaId:"textarea1",...t(p,{maxLength:{value:40,message:D}})});if(i==="input")return h.createElement(ae,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",errorText:s.field5?s.field5.message:void 0,icon:Ue,...t(b,{required:z})});if(i==="select")return h.createElement(Pe,{errorText:s.field6?s.field6.message:void 0,label:"Skriv inn din tekst",...t(U,{validate:Z})},h.createElement("option",{value:"Option 1"},"Option 1"),h.createElement("option",{value:"Option 2"},"Option 2"),h.createElement("option",{value:"Option 3"},"Option 3"));if(i==="date"){const k=s.field7||s.field8||s.field9;return h.createElement(h.Fragment,null,h.createElement(Y,{legend:"Velg en dato og et klokkeslett",fieldsetClassName:we["fieldset--flex"],error:k?k.message:void 0},h.createElement(ae,{className:we["date-picker--spacing"],label:"dato",width:20,type:"date",defaultValue:a.toLocaleDateString("en-CA"),min:m.toLocaleDateString("en-CA"),max:g.toLocaleDateString("en-CA"),...t(q,{validate:w=>v(w,m,g)})}),h.createElement(Y,{htmlMarkup:"div",fieldsetClassName:we["fieldset--flex-time"]},h.createElement(ae,{labelId:"time-label-id",afterInputChildren:h.createElement("span",{style:{padding:"0 1rem"}},":"),label:"klokke",width:4,type:"number",defaultValue:a.toLocaleTimeString("nb",{hour:"2-digit"}),max:23,min:0,...t(re,{validate:w=>x(w,w)})}),h.createElement(ae,{"aria-labelledby":"time-label-id",width:4,type:"number",defaultValue:a.toLocaleTimeString("nb",{minute:"2-digit"}),max:59,min:0,...t(le,{validate:w=>x(7,w)})}))))}}};return h.createElement("form",{noValidate:!0,onSubmit:l(k=>{!vt()&&console.log(k)})},h.createElement(yt,{variant:e.variant,errorSummary:P?"Sjekk at alt er riktig utfylt":void 0},S()),h.createElement(mt,{type:"submit"},"Send inn"))};export{Lr as FormExample,qt as FormExampleVariants,Lr as default};
11
+ test`,grow:!0,maxCharacters:40,minRows:5,errorText:s.field4?s.field4.message:void 0,label:"Skriv din historie her",textareaId:"textarea1",...t(p,{maxLength:{value:40,message:A}})});if(i==="input")return h.createElement(le,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",errorText:s.field5?s.field5.message:void 0,icon:Ue,...t(b,{required:z})});if(i==="select")return h.createElement(Pe,{errorText:s.field6?s.field6.message:void 0,label:"Skriv inn din tekst",...t(U,{validate:Z})},h.createElement("option",{value:"Option 1"},"Option 1"),h.createElement("option",{value:"Option 2"},"Option 2"),h.createElement("option",{value:"Option 3"},"Option 3"));if(i==="date"){const k=s.field7||s.field8||s.field9;return h.createElement(h.Fragment,null,h.createElement(Y,{legend:"Velg en dato og et klokkeslett",fieldsetClassName:ge["date-time"],error:k?k.message:void 0},h.createElement(le,{className:ge["date-time__date-picker"],label:"dato",width:20,type:"date",defaultValue:l.toLocaleDateString("en-CA"),min:y.toLocaleDateString("en-CA"),max:g.toLocaleDateString("en-CA"),...t(q,{validate:w=>v(w,y,g)})}),h.createElement(Y,{htmlMarkup:"div",fieldsetClassName:ge["date-time__time-wrapper"]},h.createElement(le,{labelId:"time-label-id",label:"klokke",width:4,type:"number",defaultValue:l.toLocaleTimeString("nb",{hour:"2-digit"}),max:23,min:0,...t(re,{validate:w=>x(w,w)})}),h.createElement("span",{className:ge["date-time__time-separator"]},":"),h.createElement(le,{"aria-labelledby":"time-label-id",width:4,type:"number",defaultValue:l.toLocaleTimeString("nb",{minute:"2-digit"}),max:59,min:0,...t(ae,{validate:w=>x(7,w)})}))))}}};return h.createElement("form",{noValidate:!0,onSubmit:a(k=>{!vt()&&console.log(k)})},h.createElement(mt,{variant:e.variant,errorSummary:P?"Sjekk at alt er riktig utfylt":void 0},D()),h.createElement(yt,{type:"submit"},"Send inn"))};export{Rr as FormExample,qt as FormExampleVariants,Rr as default};
12
12
  //# sourceMappingURL=index.js.map