@helsenorge/designsystem-react 1.0.0-beta90 → 1.0.0-beta95

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 (184) hide show
  1. package/Button-8af0be6e.js +2 -0
  2. package/Button-8af0be6e.js.map +1 -0
  3. package/Checkbox-fb5dff56.js +2 -0
  4. package/Checkbox-fb5dff56.js.map +1 -0
  5. package/Close-9f68bcd0.js +2 -0
  6. package/Close-9f68bcd0.js.map +1 -0
  7. package/FormGroup-6c545646.js +2 -0
  8. package/FormGroup-6c545646.js.map +1 -0
  9. package/Icon-04613a89.js +2 -0
  10. package/Icon-04613a89.js.map +1 -0
  11. package/Input-adeb7f88.js +2 -0
  12. package/Input-adeb7f88.js.map +1 -0
  13. package/Loader-b3fd59f4.js +2 -0
  14. package/Loader-b3fd59f4.js.map +1 -0
  15. package/Modal-b7d10081.js +2 -0
  16. package/Modal-b7d10081.js.map +1 -0
  17. package/RadioButton-d90884c9.js +2 -0
  18. package/RadioButton-d90884c9.js.map +1 -0
  19. package/Textarea-05e33ba3.js +2 -0
  20. package/Textarea-05e33ba3.js.map +1 -0
  21. package/Title-90910763.js +2 -0
  22. package/Title-90910763.js.map +1 -0
  23. package/Validation-9bf0c0ec.js +2 -0
  24. package/Validation-9bf0c0ec.js.map +1 -0
  25. package/components/AnchorLink/index.d.ts +1 -0
  26. package/components/AnchorLink/index.d.ts.map +1 -1
  27. package/components/AnchorLink/index.js +1 -1
  28. package/components/Avatar/index.d.ts +1 -0
  29. package/components/Avatar/index.d.ts.map +1 -1
  30. package/components/Avatar/index.js +1 -1
  31. package/components/Badge/index.d.ts +1 -0
  32. package/components/Badge/index.d.ts.map +1 -1
  33. package/components/Button/Button.d.ts.map +1 -1
  34. package/components/Button/index.d.ts +1 -0
  35. package/components/Button/index.d.ts.map +1 -1
  36. package/components/Button/index.js +1 -1
  37. package/components/ButtonWithModal/componentdata.json +38 -0
  38. package/components/ButtonWithModal/index.d.ts +1 -0
  39. package/components/ButtonWithModal/index.d.ts.map +1 -1
  40. package/components/ButtonWithModal/index.js +1 -1
  41. package/components/Checkbox/Checkbox.d.ts +3 -3
  42. package/components/Checkbox/Checkbox.d.ts.map +1 -1
  43. package/components/Checkbox/componentdata.json +10 -4
  44. package/components/Checkbox/index.d.ts +1 -0
  45. package/components/Checkbox/index.d.ts.map +1 -1
  46. package/components/Checkbox/index.js +1 -1
  47. package/components/Close/index.d.ts +1 -0
  48. package/components/Close/index.d.ts.map +1 -1
  49. package/components/Close/index.js +1 -1
  50. package/components/ExpanderList/index.d.ts +1 -0
  51. package/components/ExpanderList/index.d.ts.map +1 -1
  52. package/components/ExpanderList/index.js +1 -1
  53. package/components/FormExample/FormExample.d.ts +8 -5
  54. package/components/FormExample/FormExample.d.ts.map +1 -1
  55. package/components/FormExample/componentdata.json +9 -0
  56. package/components/FormExample/index.d.ts +1 -0
  57. package/components/FormExample/index.d.ts.map +1 -1
  58. package/components/FormExample/index.js +1 -1
  59. package/components/FormExample/index.js.map +1 -1
  60. package/components/FormGroup/FormGroup.d.ts +5 -6
  61. package/components/FormGroup/FormGroup.d.ts.map +1 -1
  62. package/components/FormGroup/componentdata.json +29 -4
  63. package/components/FormGroup/index.d.ts +1 -0
  64. package/components/FormGroup/index.d.ts.map +1 -1
  65. package/components/FormGroup/index.js +1 -1
  66. package/components/FormGroup/styles.module.scss +12 -3
  67. package/components/HighlightBox/HighlightBox.d.ts +24 -0
  68. package/components/HighlightBox/HighlightBox.d.ts.map +1 -0
  69. package/components/HighlightBox/componentdata.json +484 -0
  70. package/components/HighlightBox/index.d.ts +4 -0
  71. package/components/HighlightBox/index.d.ts.map +1 -0
  72. package/components/HighlightBox/index.js +2 -0
  73. package/components/HighlightBox/index.js.map +1 -0
  74. package/components/HighlightBox/styles.module.scss +89 -0
  75. package/components/Icons/AcupunctureBack.js +1 -1
  76. package/components/Icons/Icon.js +1 -1
  77. package/components/Icons/NoEye.js +1 -1
  78. package/components/Icons/SectionSign.js +1 -1
  79. package/components/Icons/SpeechBubble.js +1 -1
  80. package/components/Icons/SupportingPerson.js +1 -1
  81. package/components/Icons/Syringe.js +1 -1
  82. package/components/Icons/index.js +1 -1
  83. package/components/Input/Input.d.ts +55 -0
  84. package/components/Input/Input.d.ts.map +1 -0
  85. package/components/Input/componentdata.json +425 -0
  86. package/components/Input/index.d.ts +4 -0
  87. package/components/Input/index.d.ts.map +1 -0
  88. package/components/Input/index.js +2 -0
  89. package/components/Input/index.js.map +1 -0
  90. package/components/Input/styles.module.scss +55 -0
  91. package/components/Input/styles.module.scss.d.ts +23 -0
  92. package/components/LinkList/index.d.ts +1 -0
  93. package/components/LinkList/index.d.ts.map +1 -1
  94. package/components/LinkList/index.js +1 -1
  95. package/components/List/index.d.ts +1 -0
  96. package/components/List/index.d.ts.map +1 -1
  97. package/components/Loader/Loader.d.ts +7 -1
  98. package/components/Loader/Loader.d.ts.map +1 -1
  99. package/components/Loader/componentdata.json +32 -1
  100. package/components/Loader/index.d.ts +1 -0
  101. package/components/Loader/index.d.ts.map +1 -1
  102. package/components/Loader/index.js +1 -1
  103. package/components/Loader/styles.module.scss +19 -4
  104. package/components/Logo/index.d.ts +1 -0
  105. package/components/Logo/index.d.ts.map +1 -1
  106. package/components/Modal/Modal.d.ts +6 -0
  107. package/components/Modal/Modal.d.ts.map +1 -1
  108. package/components/Modal/componentdata.json +40 -0
  109. package/components/Modal/index.d.ts +1 -0
  110. package/components/Modal/index.d.ts.map +1 -1
  111. package/components/Modal/index.js +1 -1
  112. package/components/Modal/styles.module.scss +21 -2
  113. package/components/NotificationPanel/index.d.ts +1 -0
  114. package/components/NotificationPanel/index.d.ts.map +1 -1
  115. package/components/NotificationPanel/index.js +1 -1
  116. package/components/Portal/componentdata.json +80 -0
  117. package/components/Portal/index.d.ts +13 -0
  118. package/components/Portal/index.d.ts.map +1 -0
  119. package/components/Portal/index.js +2 -0
  120. package/components/Portal/index.js.map +1 -0
  121. package/components/RadioButton/RadioButton.d.ts +31 -0
  122. package/components/RadioButton/RadioButton.d.ts.map +1 -0
  123. package/components/RadioButton/componentdata.json +265 -0
  124. package/components/RadioButton/index.d.ts +4 -0
  125. package/components/RadioButton/index.d.ts.map +1 -0
  126. package/components/RadioButton/index.js +2 -0
  127. package/components/RadioButton/index.js.map +1 -0
  128. package/components/RadioButton/styles.module.scss +236 -0
  129. package/components/RadioButton/styles.module.scss.d.ts +23 -0
  130. package/components/Slider/index.d.ts +1 -0
  131. package/components/Slider/index.d.ts.map +1 -1
  132. package/components/Slider/index.js +1 -1
  133. package/components/Spacer/index.d.ts +1 -0
  134. package/components/Spacer/index.d.ts.map +1 -1
  135. package/components/Textarea/Textarea.d.ts +35 -0
  136. package/components/Textarea/Textarea.d.ts.map +1 -0
  137. package/components/Textarea/componentdata.json +565 -0
  138. package/components/Textarea/index.d.ts +4 -0
  139. package/components/Textarea/index.d.ts.map +1 -0
  140. package/components/Textarea/index.js +2 -0
  141. package/components/Textarea/index.js.map +1 -0
  142. package/components/Textarea/styles.module.scss +57 -0
  143. package/components/Textarea/styles.module.scss.d.ts +26 -0
  144. package/components/Tile/index.d.ts +1 -0
  145. package/components/Tile/index.d.ts.map +1 -1
  146. package/components/Tile/index.js +1 -1
  147. package/components/Title/index.d.ts +1 -0
  148. package/components/Title/index.d.ts.map +1 -1
  149. package/components/Title/index.js +1 -1
  150. package/components/Validation/Validation.d.ts +2 -2
  151. package/components/Validation/Validation.d.ts.map +1 -1
  152. package/components/Validation/index.d.ts +1 -0
  153. package/components/Validation/index.d.ts.map +1 -1
  154. package/components/Validation/index.js +1 -1
  155. package/constants-42547490.js +2 -0
  156. package/constants-42547490.js.map +1 -0
  157. package/constants.d.ts +29 -0
  158. package/constants.d.ts.map +1 -1
  159. package/hooks/useIcons.d.ts +4 -0
  160. package/hooks/useIcons.d.ts.map +1 -0
  161. package/index.d.ts +1 -0
  162. package/index.d.ts.map +1 -1
  163. package/index.js +1 -1
  164. package/package.json +2 -1
  165. package/scss/_input.scss +174 -0
  166. package/scss/_title.scss +16 -12
  167. package/Button-48132cc3.js +0 -2
  168. package/Button-48132cc3.js.map +0 -1
  169. package/Checkbox-46666e69.js +0 -2
  170. package/Checkbox-46666e69.js.map +0 -1
  171. package/Close-591125bb.js +0 -2
  172. package/Close-591125bb.js.map +0 -1
  173. package/FormGroup-56d60079.js +0 -2
  174. package/FormGroup-56d60079.js.map +0 -1
  175. package/Loader-6ff0d481.js +0 -2
  176. package/Loader-6ff0d481.js.map +0 -1
  177. package/Modal-145869ba.js +0 -2
  178. package/Modal-145869ba.js.map +0 -1
  179. package/Title-72851d51.js +0 -2
  180. package/Title-72851d51.js.map +0 -1
  181. package/Validation-372a97b9.js +0 -2
  182. package/Validation-372a97b9.js.map +0 -1
  183. package/constants-d919236e.js +0 -2
  184. package/constants-d919236e.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import r,{createContext as e,useCallback as t,useRef as n,useState as i,useEffect as u,useMemo as a,isValidElement as s}from"react";import{V as c}from"../../Validation-372a97b9.js";import{F as o}from"../../FormGroup-56d60079.js";import{C as f}from"../../Checkbox-46666e69.js";import{B as l}from"../../Button-48132cc3.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../_rollupPluginBabelHelpers-d0752906.js";import"../FormGroup/styles.module.scss";import"../../Title-72851d51.js";import"../Title/styles.module.scss";import"../../uuid-8870ab4b.js";import"../../Check-6291ad09.js";import"../../constants-d919236e.js";import"../../_tslib-51c8a283.js";import"../../color-acb834c6.js";import"../../index-19b48c51.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../Checkbox/styles.module.scss";import"../../Loader-6ff0d481.js";import"../Loader/styles.module.scss";import"../../useHover-037be19d.js";import"../../useWindowSize-73b47451.js";import"../Button/styles.module.scss";var d=function(r){return r instanceof HTMLElement},v="blur",m="change",g="input",p="onBlur",y="onChange",h="onSubmit",b="onTouched",O="all",j="max",V="min",A="maxLength",w="minLength",E="pattern",S="required",F="validate";var k=function(r){return null==r},D=function(r){return"object"==typeof r},x=function(r){return!k(r)&&!Array.isArray(r)&&D(r)&&!(r instanceof Date)},C=function(r){return/^\w*$/.test(r)},R=function(r){return r.filter(Boolean)},N=function(r){return R(r.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."))};function B(r,e,t){for(var n=-1,i=C(e)?[e]:N(e),u=i.length,a=u-1;++n<u;){var s=i[n],c=t;if(n!==a){var o=r[s];c=x(o)||Array.isArray(o)?o:isNaN(+i[n+1])?{}:[]}r[s]=c,r=r[s]}return r}var L=function(r,e){for(var t in void 0===e&&(e={}),r)C(t)?e[t]=r[t]:B(e,t,r[t]);return e},T=function(r){return void 0===r},M=function(r,e,t){void 0===r&&(r={});var n=R(e.split(/[,[\].]+?/)).reduce((function(r,e){return k(r)?r:r[e]}),r);return T(n)||n===r?T(r[e])?t:r[e]:n},W=function(r,e){d(r)&&r.removeEventListener&&(r.removeEventListener(g,e),r.removeEventListener(m,e),r.removeEventListener(v,e))},_={isValid:!1,value:null},q=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),_):_},H=function(r){return"radio"===r.type},P=function(r){return"file"===r.type},z=function(r){return"checkbox"===r.type},U=function(r){return"select-multiple"===r.type},$={value:!1,isValid:!1},G={value:!0,isValid:!0},I=function(r){if(Array.isArray(r)){if(r.length>1){var e=r.filter((function(r){return r&&r.ref.checked})).map((function(r){return r.ref.value}));return{value:e,isValid:!!e.length}}var t=r[0].ref,n=t.checked,i=t.value,u=t.attributes;return n?u&&!T(u.value)?T(i)||""===i?G:{value:i,isValid:!0}:G:$}return $};function J(r,e,t,n,i){var u,a=r.current[e];if(a){var s=a.ref,c=s.value,o=s.disabled,f=a.ref,l=a.valueAsNumber,d=a.valueAsDate,v=a.setValueAs;if(o&&n)return;return P(f)?f.files:H(f)?q(a.options).value:U(f)?(u=f.options,[].concat(u).filter((function(r){return r.selected})).map((function(r){return r.value}))):z(f)?I(a.options).value:i?c:l?""===c?NaN:+c:d?f.valueAsDate:v?v(c):c}if(t)return M(t.current,e)}function K(r){return!r||r instanceof HTMLElement&&r.nodeType!==Node.DOCUMENT_NODE&&K(r.parentNode)}var Q=function(r){return x(r)&&!Object.keys(r).length},X=function(r){return"boolean"==typeof r};function Y(r,e){var t,n=C(e)?[e]:N(e),i=1==n.length?r:function(r,e){for(var t=e.slice(0,-1).length,n=0;n<t;)r=T(r)?n++:r[e[n++]];return r}(r,n),u=n[n.length-1];i&&delete i[u];for(var a=0;a<n.slice(0,-1).length;a++){var s=-1,c=void 0,o=n.slice(0,-(a+1)),f=o.length-1;for(a>0&&(t=r);++s<o.length;){var l=o[s];c=c?c[l]:r[l],f===s&&(x(c)&&Q(c)||Array.isArray(c)&&!c.filter((function(r){return x(r)&&!Q(r)||X(r)})).length)&&(t?delete t[l]:delete r[l]),t=c}}return r}var Z=function(r,e){return r&&r.ref===e};var rr=function(r){return k(r)||!D(r)};function er(r,e){if(rr(r)||rr(e))return e;for(var t in e){var n=r[t],i=e[t];try{r[t]=x(n)&&x(i)||Array.isArray(n)&&Array.isArray(i)?er(n,i):i}catch(r){}}return r}function tr(r,e,t){if(rr(r)||rr(e)||r instanceof Date||e instanceof Date)return r===e;if(!s(r)){var n=Object.keys(r),i=Object.keys(e);if(n.length!==i.length)return!1;for(var u=0,a=n;u<a.length;u+=1){var c=a[u],o=r[c];if(!t||"ref"!==c){var f=e[c];if((x(o)||Array.isArray(o))&&(x(f)||Array.isArray(f))?!tr(o,f,t):o!==f)return!1}}}return!0}function nr(r,e,t,n,i){for(var u,a=-1;++a<r.length;){for(var s in r[a])Array.isArray(r[a][s])?(!t[a]&&(t[a]={}),t[a][s]=[],nr(r[a][s],M(e[a]||{},s,[]),t[a][s],t[a],s)):tr(M(e[a]||{},s),r[a][s])?B(t[a]||{},s):t[a]=Object.assign(Object.assign({},t[a]),((u={})[s]=!0,u));n&&!t.length&&delete n[i]}return t}var ir=function(r){return"string"==typeof r},ur=function(r,e,t,n,i){var u={},a=function(e){(T(i)||(ir(i)?e.startsWith(i):Array.isArray(i)&&i.find((function(r){return e.startsWith(r)}))))&&(u[e]=J(r,e,void 0,n))};for(var s in r.current)a(s);return t?L(u):er(e,L(u))},ar=function(r){return r instanceof RegExp},sr=function(r){return x(r)&&!ar(r)?r:{value:r,message:""}},cr=function(r){return"function"==typeof r},or=function(r){return ir(r)||s(r)};function fr(r,e,t){if(void 0===t&&(t="validate"),or(r)||X(r)&&!r)return{type:t,message:or(r)?r:"",ref:e}}var lr=function(r,e,t,n,i){var u;return e?Object.assign(Object.assign({},t[r]),{types:Object.assign(Object.assign({},t[r]&&t[r].types?t[r].types:{}),(u={},u[n]=i||!0,u))}):{}},dr=async function(r,e,t,n){var i=t.ref,u=t.ref.value,a=t.options,s=t.required,c=t.maxLength,o=t.minLength,f=t.min,l=t.max,d=t.pattern,v=t.validate,m=i.name,g={},p=H(i),y=z(i),h=p||y,b=""===u,O=lr.bind(null,m,e,g),D=function(r,e,t,n,u){void 0===n&&(n=A),void 0===u&&(u=w);var a=r?e:t;g[m]=Object.assign({type:r?n:u,message:a,ref:i},O(r?n:u,a))};if(s&&(!p&&!y&&(b||k(u))||X(u)&&!u||y&&!I(a).isValid||p&&!q(a).isValid)){var C=or(s)?{value:!!s,message:s}:sr(s),R=C.value,N=C.message;if(R&&(g[m]=Object.assign({type:S,message:N,ref:h?((r.current[m].options||[])[0]||{}).ref:i},O(S,N)),!e))return g}if(!(k(f)&&k(l)||""===u)){var B,L,T=sr(l),M=sr(f);if(isNaN(u)){var W=i.valueAsDate||new Date(u);ir(T.value)&&(B=W>new Date(T.value)),ir(M.value)&&(L=W<new Date(M.value))}else{var _=i.valueAsNumber||parseFloat(u);k(T.value)||(B=_>T.value),k(M.value)||(L=_<M.value)}if((B||L)&&(D(!!B,T.message,M.message,j,V),!e))return g}if(ir(u)&&!b&&(c||o)){var P=sr(c),U=sr(o),$=!k(P.value)&&u.length>P.value,G=!k(U.value)&&u.length<U.value;if(($||G)&&(D($,P.message,U.message),!e))return g}if(ir(u)&&d&&!b){var K=sr(d),Y=K.value,Z=K.message;if(ar(Y)&&!Y.test(u)&&(g[m]=Object.assign({type:E,message:Z,ref:i},O(E,Z)),!e))return g}if(v){var rr=J(r,m,n,!1,!0),er=h&&a?a[0].ref:i;if(cr(v)){var tr=fr(await v(rr),er);if(tr&&(g[m]=Object.assign(Object.assign({},tr),O(F,tr.message)),!e))return g}else if(x(v)){for(var nr={},ur=0,dr=Object.entries(v);ur<dr.length;ur+=1){var vr=dr[ur],mr=vr[0],gr=vr[1];if(!Q(nr)&&!e)break;var pr=fr(await gr(rr),er,mr);pr&&(nr=Object.assign(Object.assign({},pr),O(mr,pr.message)),e&&(g[m]=nr))}if(!Q(nr)&&(g[m]=Object.assign({ref:er},nr),!e))return g}}return g},vr=function(r,e,t){for(var n in void 0===t&&(t=[]),e){var i=r+(x(e)?"."+n:"["+n+"]");rr(e[n])?t.push(i):vr(i,e[n],t)}return t},mr=function(r,e,t,n,i){var u=void 0;return t.add(e),Q(r)||(u=M(r,e),(x(u)||Array.isArray(u))&&vr(e,u).forEach((function(r){return t.add(r)}))),T(u)?i?n:M(n,e):u},gr=function(r){return r.substring(0,r.indexOf("["))},pr=function(r,e){return[].concat(r).some((function(r){return function(r,e){return RegExp(("^"+e+"([|.)\\d+").replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(r)}(e,r)}))};var yr="undefined"!=typeof window&&"undefined"!=typeof document;function hr(r){var e,t;if(rr(r)||yr&&(r instanceof File||d(r)))return r;if(!["Set","Map","Object","Date","Array"].includes(null===(e=r.constructor)||void 0===e?void 0:e.name))return r;if(r instanceof Date)return t=new Date(r.getTime());if(r instanceof Set){t=new Set;for(var n=0,i=r;n<i.length;n+=1){var u=i[n];t.add(u)}return t}if(r instanceof Map){t=new Map;for(var a=0,s=r.keys();a<s.length;a+=1){var c=s[a];t.set(c,hr(r.get(c)))}return t}for(var o in t=Array.isArray(r)?[]:{},r)t[o]=hr(r[o]);return t}var br,Or=function(r){return{isOnSubmit:!r||r===h,isOnBlur:r===p,isOnChange:r===y,isOnAll:r===O,isOnTouch:r===b}},jr=function(r){return H(r)||z(r)},Vr="undefined"==typeof window,Ar=yr?"Proxy"in window:"undefined"!=typeof Proxy;function wr(r){void 0===r&&(r={});var e=r.mode;void 0===e&&(e=h);var s=r.reValidateMode;void 0===s&&(s=y);var c=r.resolver,o=r.context,f=r.defaultValues;void 0===f&&(f={});var l=r.shouldFocusError;void 0===l&&(l=!0);var p=r.shouldUnregister;void 0===p&&(p=!0);var b=r.criteriaMode,j=n({}),V=n({}),A=n({}),w=n(new Set),E=n({}),S=n({}),F=n({}),D=n({}),N=n(f),_=n(!1),q=n(!1),$=n(),G=n({}),I=n({}),X=n(o),ar=n(c),sr=n(new Set),or=n(Or(e)),fr=or.current,lr=fr.isOnSubmit,br=fr.isOnTouch,wr=b===O,Er=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!lr,errors:{}}),Sr=Er[0],Fr=Er[1],kr=n({isDirty:!Ar,dirtyFields:!Ar,touched:!Ar||br,isValidating:!Ar,isSubmitting:!Ar,isValid:!Ar}),Dr=n(Sr),xr=n(),Cr=n(Or(s)).current,Rr=Cr.isOnBlur,Nr=Cr.isOnChange;X.current=o,ar.current=c,Dr.current=Sr,G.current=p?{}:Q(G.current)?hr(f):G.current;var Br=t((function(r){void 0===r&&(r={}),_.current||(Dr.current=Object.assign(Object.assign({},Dr.current),r),Fr(Dr.current))}),[]),Lr=function(){return kr.current.isValidating&&Br({isValidating:!0})},Tr=t((function(r,e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n={});var u=t||function(r){var e=r.errors,t=r.name,n=r.error,i=r.validFields,u=r.fieldsWithValidation,a=T(n),s=M(e,t);return a&&!!s||!a&&!tr(s,n,!0)||a&&M(u,t)&&!M(i,t)}({errors:Dr.current.errors,error:e,name:r,validFields:D.current,fieldsWithValidation:F.current}),a=M(Dr.current.errors,r);e?(Y(D.current,r),u=u||!a||!tr(a,e,!0),B(Dr.current.errors,r,e)):((M(F.current,r)||ar.current)&&(B(D.current,r,!0),u=u||a),Y(Dr.current.errors,r)),(u&&!k(t)||!Q(n)||kr.current.isValidating)&&Br(Object.assign(Object.assign(Object.assign({},n),ar.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Mr=t((function(r,e){var t=j.current[r],n=t.ref,i=t.options,u=yr&&d(n)&&k(e)?"":e;H(n)?(i||[]).forEach((function(r){var e=r.ref;return e.checked=e.value===u})):P(n)&&!ir(u)?n.files=u:U(n)?[].concat(n.options).forEach((function(r){return r.selected=u.includes(r.value)})):z(n)&&i?i.length>1?i.forEach((function(r){var e=r.ref;return e.checked=Array.isArray(u)?!!u.find((function(r){return r===e.value})):u===e.value})):i[0].ref.checked=!!u:n.value=u}),[]),Wr=t((function(r,e){if(kr.current.isDirty){var t=Jr();return r&&e&&B(t,r,e),!tr(t,N.current)}return!1}),[]),_r=t((function(r,e){if(void 0===e&&(e=!0),kr.current.isDirty||kr.current.dirtyFields){var t=!tr(M(N.current,r),J(j,r,G)),n=M(Dr.current.dirtyFields,r),i=Dr.current.isDirty;t?B(Dr.current.dirtyFields,r,!0):Y(Dr.current.dirtyFields,r);var u={isDirty:Wr(),dirtyFields:Dr.current.dirtyFields},a=kr.current.isDirty&&i!==u.isDirty||kr.current.dirtyFields&&n!==M(Dr.current.dirtyFields,r);return a&&e&&Br(u),a?u:{}}return{}}),[]),qr=t((async function(r,e){if("production"!==process.env.NODE_ENV&&!j.current[r])return console.warn("📋 Field is missing with `name` attribute: ",r),!1;var t=(await dr(j,wr,j.current[r],G))[r];return Tr(r,t,e),T(t)}),[Tr,wr]),Hr=t((async function(r){var e=(await ar.current(Jr(),X.current,wr)).errors,t=Dr.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=M(e,r);return t?B(Dr.current.errors,r,t):Y(Dr.current.errors,r),!t})).every(Boolean);return Br({isValid:Q(e),isValidating:!1}),n}var i=M(e,r);return Tr(r,i,t!==Q(e),{},Q(e)),!i}),[Tr,wr]),Pr=t((async function(r){var e=r||Object.keys(j.current);if(Lr(),ar.current)return Hr(e);if(Array.isArray(e)){!r&&(Dr.current.errors={});var t=await Promise.all(e.map((async function(r){return await qr(r,null)})));return Br({isValidating:!1}),t.every(Boolean)}return await qr(e)}),[Hr,qr]),zr=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,u={};B(u,r,e);for(var a=0,s=vr(r,e);a<s.length;a+=1){var c=s[a];j.current[c]&&(Mr(c,M(u,c)),n&&_r(c),i&&Pr(c))}}),[Pr,Mr,_r]),Ur=t((function(r,e,t){var n,i;if(!p&&!rr(e)&&B(G.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),j.current[r])Mr(r,e),t.shouldDirty&&_r(r),t.shouldValidate&&Pr(r);else if(!rr(e)&&(zr(r,e,t),sr.current.has(r))){var u=gr(r)||r;B(V.current,r,e),I.current[u](((n={})[u]=M(V.current,u),n)),(kr.current.isDirty||kr.current.dirtyFields)&&t.shouldDirty&&(B(Dr.current.dirtyFields,r,function(r,e,t){return er(nr(r,e,t.slice(0,r.length)),nr(e,r,t.slice(0,r.length)))}(e,M(N.current,r,[]),M(Dr.current.dirtyFields,r,[]))),Br({isDirty:!tr(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),N.current)}))}!p&&B(G.current,r,e)}),[_r,Mr,zr]),$r=function(r){return q.current||w.current.has(r)||w.current.has((r.match(/\w+/)||[])[0])},Gr=function(r){var e=!0;if(!Q(E.current))for(var t in E.current)r&&E.current[t].size&&!E.current[t].has(r)&&!E.current[t].has(gr(r))||(S.current[t](),e=!1);return e};function Ir(r){var e;if(!p){for(var t=hr(r),n=0,i=sr.current;n<i.length;n+=1){var u=i[n];C(u)&&!t[u]&&(t=Object.assign(Object.assign({},t),((e={})[u]=[],e)))}return t}return r}function Jr(r){if(ir(r))return J(j,r,G);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];B(e,i,J(j,i,G))}return e}return Ir(ur(j,hr(G.current),p))}$.current=$.current?$.current:async function(r){var e,t,n=r.type,i=r.target,u=i.name,a=j.current[u];if(a){var s=n===v,c=function(r){var e=r.isOnBlur,t=r.isOnChange,n=r.isOnTouch,i=r.isTouched,u=r.isReValidateOnBlur,a=r.isReValidateOnChange,s=r.isBlurEvent,c=r.isSubmitted;return!r.isOnAll&&(!c&&n?!(i||s):(c?u:e)?!s:!(c?a:t)||s)}(Object.assign({isBlurEvent:s,isReValidateOnChange:Nr,isReValidateOnBlur:Rr,isTouched:!!M(Dr.current.touched,u),isSubmitted:Dr.current.isSubmitted},or.current)),o=_r(u,!1),f=!Q(o)||!s&&$r(u);if(s&&!M(Dr.current.touched,u)&&kr.current.touched&&(B(Dr.current.touched,u,!0),o=Object.assign(Object.assign({},o),{touched:Dr.current.touched})),!p&&z(i)&&B(G.current,u,J(j,u)),c)return!s&&Gr(u),(!Q(o)||f&&Q(o))&&Br(o);if(Lr(),ar.current){var l=(await ar.current(Jr(),X.current,wr)).errors,d=Dr.current.isValid;if(e=M(l,u),z(i)&&!e&&ar.current){var m=gr(u),g=M(l,m,{});g.type&&g.message&&(e=g),m&&(g||M(Dr.current.errors,m))&&(u=m)}d!==(t=Q(l))&&(f=!0)}else e=(await dr(j,wr,a,G))[u];!s&&Gr(u),Tr(u,e,f,o,t)}};var Kr=t((async function(r){void 0===r&&(r={});var e=Q(j.current)?N.current:{},t=(await ar.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),X.current,wr)||{}).errors,n=Q(t);Dr.current.isValid!==n&&Br({isValid:n})}),[wr]),Qr=t((function(r,e){!function(r,e,t,n,i,u){var a=t.ref,s=t.ref.name,c=r.current[s];if(!i){var o=J(r,s,n);!T(o)&&B(n.current,s,o)}a.type&&c?H(a)||z(a)?Array.isArray(c.options)&&c.options.length?(R(c.options).forEach((function(r,t){void 0===r&&(r={}),(K(r.ref)&&Z(r,r.ref)||u)&&(W(r.ref,e),Y(c.options,"["+t+"]"))})),c.options&&!R(c.options).length&&delete r.current[s]):delete r.current[s]:(K(a)&&Z(c,a)||u)&&(W(a,e),delete r.current[s]):delete r.current[s]}(j,$.current,r,G,p,e),p&&(Y(D.current,r.ref.name),Y(F.current,r.ref.name))}),[p]),Xr=t((function(r){if(q.current)Br();else{for(var e=0,t=w.current;e<t.length;e+=1){if(t[e].startsWith(r)){Br();break}}Gr(r)}}),[]),Yr=t((function(r,e){r&&(Qr(r,e),p&&!R(r.options||[]).length&&(Y(Dr.current.errors,r.ref.name),B(Dr.current.dirtyFields,r.ref.name,!0),Br({isDirty:Wr()}),kr.current.isValid&&ar.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?E.current[t]:w.current,i=ur(j,hr(G.current),p,!1,r);if(ir(r)){var u=gr(r)||r;return sr.current.has(u)&&(i=Object.assign(Object.assign({},A.current),i)),mr(i,r,n,T(M(N.current,r))?e:M(N.current,r),!0)}var a=T(e)?N.current:e;return Array.isArray(r)?r.reduce((function(r,e){var t;return Object.assign(Object.assign({},r),((t={})[e]=mr(i,e,n,a),t))}),{}):(q.current=T(t),L(!Q(i)&&i||a))}),[]);function re(r,e){if(void 0===e&&(e={}),"production"!==process.env.NODE_ENV){if(!r.name)return console.warn("📋 Field is missing `name` attribute",r,"https://react-hook-form.com/api#useForm");if(sr.current.has(r.name.split(/\[\d+\]$/)[0])&&!RegExp(("^"+r.name.split(/\[\d+\]$/)[0]+"[\\d+].\\w+").replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(r.name))return console.warn('📋 `name` prop should be in object shape: name="test[index].name"',r,"https://react-hook-form.com/api#useFieldArray")}var t,n=r.name,i=r.type,u=r.value,a=Object.assign({ref:r},e),s=j.current,c=jr(r),o=pr(sr.current,n),f=function(e){return yr&&(!d(r)||e===r)},l=s[n],y=!0;if(l&&(c?Array.isArray(l.options)&&R(l.options).find((function(r){return u===r.ref.value&&f(r.ref)})):f(l.ref)))s[n]=Object.assign(Object.assign({},l),e);else{l=i?c?Object.assign({options:R(l&&l.options||[]).concat([{ref:r}]),ref:{type:i,name:n}},e):Object.assign({},a):a,s[n]=l;var h=T(M(G.current,n));Q(N.current)&&h||(t=M(h?N.current:G.current,n),(y=T(t))||o||Mr(n,t)),Q(e)||(B(F.current,n,!0),!lr&&kr.current.isValid&&dr(j,wr,l,G).then((function(r){var e=Dr.current.isValid;Q(r)?B(D.current,n,!0):Y(D.current,n),e!==Q(r)&&Br()}))),!p||o&&y||!o&&Y(Dr.current.dirtyFields,n),i&&function(r,e,t){var n=r.ref;d(n)&&t&&(n.addEventListener(e?m:g,t),n.addEventListener(v,t))}(c&&l.options?l.options[l.options.length-1]:l,c||"select-one"===r.type,$.current)}}var ee=t((function(r,e){return async function(t){t&&t.preventDefault&&(t.preventDefault(),t.persist());var n={},i=Ir(ur(j,hr(G.current),p,!0));kr.current.isSubmitting&&Br({isSubmitting:!0});try{if(ar.current){var u=await ar.current(i,X.current,wr),a=u.errors,s=u.values;Dr.current.errors=n=a,i=s}else for(var c=0,o=Object.values(j.current);c<o.length;c+=1){var f=o[c];if(f){var d=f.ref.name,v=await dr(j,wr,f,G);v[d]?(B(n,d,v[d]),Y(D.current,d)):M(F.current,d)&&(Y(Dr.current.errors,d),B(D.current,d,!0))}}Q(n)&&Object.keys(Dr.current.errors).every((function(r){return r in j.current}))?(Br({errors:{},isSubmitting:!0}),await r(i,t)):(Dr.current.errors=Object.assign(Object.assign({},Dr.current.errors),n),e&&await e(Dr.current.errors,t),l&&function(r,e){for(var t in r)if(M(e,t)){var n=r[t];if(n){if(n.ref.focus&&T(n.ref.focus()))break;if(n.options){n.options[0].ref.focus();break}}}}(j.current,Dr.current.errors))}finally{Dr.current.isSubmitting=!1,Br({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Q(Dr.current.errors),submitCount:Dr.current.submitCount+1})}}}),[l,wr]);u((function(){c&&kr.current.isValid&&Kr(),xr.current=xr.current||!yr?xr.current:function(r,e){var t=new MutationObserver((function(){for(var t=0,n=Object.values(r.current);t<n.length;t+=1){var i=n[t];if(i&&i.options)for(var u=0,a=i.options;u<a.length;u+=1){var s=a[u];s&&s.ref&&K(s.ref)&&e(i)}else i&&K(i.ref)&&e(i)}}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(j,Yr)}),[Yr,N.current]),u((function(){return function(){xr.current&&xr.current.disconnect(),_.current=!0,"production"===process.env.NODE_ENV&&Object.values(j.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!c&&kr.current.isValid&&(Sr.isValid=tr(D.current,F.current)&&Q(Dr.current.errors));var te={trigger:Pr,setValue:t((function(r,e,t){Ur(r,e,t||{}),$r(r)&&Br(),Gr(r)}),[Ur,Pr]),getValues:t(Jr,[]),register:t((function(r,e){if(!Vr)if(ir(r))re({name:r},e);else{if(!x(r)||!("name"in r))return function(e){return e&&re(e,r)};re(r,e)}}),[N.current]),unregister:t((function(r){for(var e=0,t=Array.isArray(r)?r:[r];e<t.length;e+=1){var n=t[e];Yr(j.current[n],!0)}}),[]),formState:Ar?new Proxy(Sr,{get:function(r,e){if("production"!==process.env.NODE_ENV&&"isValid"===e&&lr&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),e in r)return kr.current[e]=!0,r[e]}}):Sr},ne=a((function(){return Object.assign({isFormDirty:Wr,updateWatchedValue:Xr,shouldUnregister:p,updateFormState:Br,removeFieldEventListener:Qr,watchInternal:Zr,mode:or.current,reValidateMode:{isReValidateOnBlur:Rr,isReValidateOnChange:Nr},validateResolver:c?Kr:void 0,fieldsRef:j,resetFieldArrayFunctionRef:I,useWatchFieldsRef:E,useWatchRenderFunctionsRef:S,fieldArrayDefaultValuesRef:V,validFieldsRef:D,fieldsWithValidationRef:F,fieldArrayNamesRef:sr,readFormStateRef:kr,formStateRef:Dr,defaultValuesRef:N,shallowFieldsStateRef:G,fieldArrayValuesRef:A},te)}),[N.current,Xr,p,Qr,Zr]);return Object.assign({watch:function(r,e){return Zr(r,e)},control:ne,handleSubmit:ee,reset:t((function(r,e){if(void 0===e&&(e={}),yr)for(var t=0,n=Object.values(j.current);t<n.length;t+=1){var i=n[t];if(i){var u=i.ref,a=i.options,s=jr(u)&&Array.isArray(a)?a[0].ref:u;if(d(s))try{s.closest("form").reset();break}catch(r){}}}j.current={},N.current=Object.assign({},r||N.current),r&&Gr(""),Object.values(I.current).forEach((function(r){return cr(r)&&r()})),G.current=p?{}:hr(r||N.current),function(r){var e=r.errors,t=r.isDirty,n=r.isSubmitted,i=r.touched,u=r.isValid,a=r.submitCount,s=r.dirtyFields;u||(D.current={},F.current={}),V.current={},w.current=new Set,q.current=!1,Br({submitCount:a?Dr.current.submitCount:0,isDirty:!!t&&Dr.current.isDirty,isSubmitted:!!n&&Dr.current.isSubmitted,isValid:!!u&&Dr.current.isValid,dirtyFields:s?Dr.current.dirtyFields:{},touched:i?Dr.current.touched:{},errors:e?Dr.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})}(e)}),[]),clearErrors:t((function(r){r&&(Array.isArray(r)?r:[r]).forEach((function(r){return j.current[r]&&C(r)?delete Dr.current.errors[r]:Y(Dr.current.errors,r)})),Br({errors:r?Dr.current.errors:{}})}),[]),setError:t((function(r,e){var t=(j.current[r]||{}).ref;B(Dr.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Br({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:Sr.errors},te)}e(null).displayName="RHFContext",function(r){r.formgroup="formgroup",r.checkbox="checkbox"}(br||(br={}));var Er=r.forwardRef((function(e,t){var n=e.exampleType,i=void 0===n?br.formgroup:n,u=wr(),a=u.register,s=u.handleSubmit,d=u.errors,v=d.formgroup1||d.formgroup2,m="Du må velge et alternativ",g=function(r){return r.length>=2||"Du må velge to alternativ"};return r.createElement("form",{onSubmit:s((function(r){console.log(r)}))},r.createElement(c,{variant:e.variant,errorSummary:v?"Sjekk at alt er riktig utfylt":void 0},i===br.formgroup?[r.createElement(o,{key:0,title:"One amazing title",legend:"Check out these checkboxes!",error:d.formgroup1?d.formgroup1.message:void 0,variant:e.variant},r.createElement(f,{name:"formgroup1",label:"Checkbox 1",ref:a({required:m})}),r.createElement(f,{name:"formgroup1",label:"Checkbox 2",ref:a({required:m})}),r.createElement(f,{name:"formgroup1",label:"Checkbox 3",ref:a({required:m})})),r.createElement(o,{key:1,legend:"Select two options!",error:d.formgroup2?d.formgroup2.message:void 0,variant:e.variant},r.createElement(f,{name:"formgroup2",label:"Checkbox 4",ref:a({validate:g})}),r.createElement(f,{name:"formgroup2",label:"Checkbox 5",ref:a({validate:g})}),r.createElement(f,{name:"formgroup2",label:"Checkbox 6",ref:a({validate:g})}))]:i===br.checkbox?r.createElement(r.Fragment,null,r.createElement(f,{name:"formgroup1",label:"Checkbox 1",error:d.formgroup1,errorText:d.formgroup1?d.formgroup1.message:void 0,variant:e.variant,ref:a({required:m})})):void 0),r.createElement(l,null,"Submit"))}));export default Er;
1
+ import r,{createContext as e,useCallback as t,useRef as n,useState as i,useEffect as a,useMemo as u,isValidElement as o}from"react";import{V as s}from"../../Validation-9bf0c0ec.js";import{F as c}from"../../FormGroup-6c545646.js";import{C as l}from"../../Checkbox-fb5dff56.js";import{B as f}from"../../Button-8af0be6e.js";import{R as v}from"../../RadioButton-d90884c9.js";import{T as d}from"../../Textarea-05e33ba3.js";import{I as m}from"../../Input-adeb7f88.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../_rollupPluginBabelHelpers-d0752906.js";import"../FormGroup/styles.module.scss";import"../../constants-42547490.js";import"../../Title-90910763.js";import"../Title/styles.module.scss";import"../../uuid-8870ab4b.js";import"../../Check-6291ad09.js";import"../../Icon-04613a89.js";import"../../_tslib-51c8a283.js";import"../../color-acb834c6.js";import"../../index-19b48c51.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../Checkbox/styles.module.scss";import"../../Loader-b3fd59f4.js";import"../Loader/styles.module.scss";import"../../useHover-037be19d.js";import"../../useWindowSize-73b47451.js";import"../Button/styles.module.scss";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../../useBreakpoint-324a9b14.js";import"../Input/styles.module.scss";var h=function(r){return r instanceof HTMLElement},g="blur",p="change",b="input",y="onBlur",V="onChange",O="onSubmit",j="onTouched",E="all",k="max",A="min",S="maxLength",z="minLength",w="pattern",D="required",x="validate";var F=function(r){return null==r},R=function(r){return"object"==typeof r},C=function(r){return!F(r)&&!Array.isArray(r)&&R(r)&&!(r instanceof Date)},H=function(r){return/^\w*$/.test(r)},N=function(r){return r.filter(Boolean)},B=function(r){return N(r.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."))};function L(r,e,t){for(var n=-1,i=H(e)?[e]:B(e),a=i.length,u=a-1;++n<a;){var o=i[n],s=t;if(n!==u){var c=r[o];s=C(c)||Array.isArray(c)?c:isNaN(+i[n+1])?{}:[]}r[o]=s,r=r[o]}return r}var M=function(r,e){for(var t in void 0===e&&(e={}),r)H(t)?e[t]=r[t]:L(e,t,r[t]);return e},T=function(r){return void 0===r},q=function(r,e,t){void 0===r&&(r={});var n=N(e.split(/[,[\].]+?/)).reduce((function(r,e){return F(r)?r:r[e]}),r);return T(n)||n===r?T(r[e])?t:r[e]:n},W=function(r,e){h(r)&&r.removeEventListener&&(r.removeEventListener(b,e),r.removeEventListener(p,e),r.removeEventListener(g,e))},_={isValid:!1,value:null},I=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),_):_},P=function(r){return"radio"===r.type},U=function(r){return"file"===r.type},$=function(r){return"checkbox"===r.type},G=function(r){return"select-multiple"===r.type},J={value:!1,isValid:!1},K={value:!0,isValid:!0},Q=function(r){if(Array.isArray(r)){if(r.length>1){var e=r.filter((function(r){return r&&r.ref.checked})).map((function(r){return r.ref.value}));return{value:e,isValid:!!e.length}}var t=r[0].ref,n=t.checked,i=t.value,a=t.attributes;return n?a&&!T(a.value)?T(i)||""===i?K:{value:i,isValid:!0}:K:J}return J};function X(r,e,t,n,i){var a,u=r.current[e];if(u){var o=u.ref,s=o.value,c=o.disabled,l=u.ref,f=u.valueAsNumber,v=u.valueAsDate,d=u.setValueAs;if(c&&n)return;return U(l)?l.files:P(l)?I(u.options).value:G(l)?(a=l.options,[].concat(a).filter((function(r){return r.selected})).map((function(r){return r.value}))):$(l)?Q(u.options).value:i?s:f?""===s?NaN:+s:v?l.valueAsDate:d?d(s):s}if(t)return q(t.current,e)}function Y(r){return!r||r instanceof HTMLElement&&r.nodeType!==Node.DOCUMENT_NODE&&Y(r.parentNode)}var Z=function(r){return C(r)&&!Object.keys(r).length},rr=function(r){return"boolean"==typeof r};function er(r,e){var t,n=H(e)?[e]:B(e),i=1==n.length?r:function(r,e){for(var t=e.slice(0,-1).length,n=0;n<t;)r=T(r)?n++:r[e[n++]];return r}(r,n),a=n[n.length-1];i&&delete i[a];for(var u=0;u<n.slice(0,-1).length;u++){var o=-1,s=void 0,c=n.slice(0,-(u+1)),l=c.length-1;for(u>0&&(t=r);++o<c.length;){var f=c[o];s=s?s[f]:r[f],l===o&&(C(s)&&Z(s)||Array.isArray(s)&&!s.filter((function(r){return C(r)&&!Z(r)||rr(r)})).length)&&(t?delete t[f]:delete r[f]),t=s}}return r}var tr=function(r,e){return r&&r.ref===e};var nr=function(r){return F(r)||!R(r)};function ir(r,e){if(nr(r)||nr(e))return e;for(var t in e){var n=r[t],i=e[t];try{r[t]=C(n)&&C(i)||Array.isArray(n)&&Array.isArray(i)?ir(n,i):i}catch(r){}}return r}function ar(r,e,t){if(nr(r)||nr(e)||r instanceof Date||e instanceof Date)return r===e;if(!o(r)){var n=Object.keys(r),i=Object.keys(e);if(n.length!==i.length)return!1;for(var a=0,u=n;a<u.length;a+=1){var s=u[a],c=r[s];if(!t||"ref"!==s){var l=e[s];if((C(c)||Array.isArray(c))&&(C(l)||Array.isArray(l))?!ar(c,l,t):c!==l)return!1}}}return!0}function ur(r,e,t,n,i){for(var a,u=-1;++u<r.length;){for(var o in r[u])Array.isArray(r[u][o])?(!t[u]&&(t[u]={}),t[u][o]=[],ur(r[u][o],q(e[u]||{},o,[]),t[u][o],t[u],o)):ar(q(e[u]||{},o),r[u][o])?L(t[u]||{},o):t[u]=Object.assign(Object.assign({},t[u]),((a={})[o]=!0,a));n&&!t.length&&delete n[i]}return t}var or=function(r){return"string"==typeof r},sr=function(r,e,t,n,i){var a={},u=function(e){(T(i)||(or(i)?e.startsWith(i):Array.isArray(i)&&i.find((function(r){return e.startsWith(r)}))))&&(a[e]=X(r,e,void 0,n))};for(var o in r.current)u(o);return t?M(a):ir(e,M(a))},cr=function(r){return r instanceof RegExp},lr=function(r){return C(r)&&!cr(r)?r:{value:r,message:""}},fr=function(r){return"function"==typeof r},vr=function(r){return or(r)||o(r)};function dr(r,e,t){if(void 0===t&&(t="validate"),vr(r)||rr(r)&&!r)return{type:t,message:vr(r)?r:"",ref:e}}var mr=function(r,e,t,n,i){var a;return e?Object.assign(Object.assign({},t[r]),{types:Object.assign(Object.assign({},t[r]&&t[r].types?t[r].types:{}),(a={},a[n]=i||!0,a))}):{}},hr=async function(r,e,t,n){var i=t.ref,a=t.ref.value,u=t.options,o=t.required,s=t.maxLength,c=t.minLength,l=t.min,f=t.max,v=t.pattern,d=t.validate,m=i.name,h={},g=P(i),p=$(i),b=g||p,y=""===a,V=mr.bind(null,m,e,h),O=function(r,e,t,n,a){void 0===n&&(n=S),void 0===a&&(a=z);var u=r?e:t;h[m]=Object.assign({type:r?n:a,message:u,ref:i},V(r?n:a,u))};if(o&&(!g&&!p&&(y||F(a))||rr(a)&&!a||p&&!Q(u).isValid||g&&!I(u).isValid)){var j=vr(o)?{value:!!o,message:o}:lr(o),E=j.value,R=j.message;if(E&&(h[m]=Object.assign({type:D,message:R,ref:b?((r.current[m].options||[])[0]||{}).ref:i},V(D,R)),!e))return h}if(!(F(l)&&F(f)||""===a)){var H,N,B=lr(f),L=lr(l);if(isNaN(a)){var M=i.valueAsDate||new Date(a);or(B.value)&&(H=M>new Date(B.value)),or(L.value)&&(N=M<new Date(L.value))}else{var T=i.valueAsNumber||parseFloat(a);F(B.value)||(H=T>B.value),F(L.value)||(N=T<L.value)}if((H||N)&&(O(!!H,B.message,L.message,k,A),!e))return h}if(or(a)&&!y&&(s||c)){var q=lr(s),W=lr(c),_=!F(q.value)&&a.length>q.value,U=!F(W.value)&&a.length<W.value;if((_||U)&&(O(_,q.message,W.message),!e))return h}if(or(a)&&v&&!y){var G=lr(v),J=G.value,K=G.message;if(cr(J)&&!J.test(a)&&(h[m]=Object.assign({type:w,message:K,ref:i},V(w,K)),!e))return h}if(d){var Y=X(r,m,n,!1,!0),er=b&&u?u[0].ref:i;if(fr(d)){var tr=dr(await d(Y),er);if(tr&&(h[m]=Object.assign(Object.assign({},tr),V(x,tr.message)),!e))return h}else if(C(d)){for(var nr={},ir=0,ar=Object.entries(d);ir<ar.length;ir+=1){var ur=ar[ir],sr=ur[0],hr=ur[1];if(!Z(nr)&&!e)break;var gr=dr(await hr(Y),er,sr);gr&&(nr=Object.assign(Object.assign({},gr),V(sr,gr.message)),e&&(h[m]=nr))}if(!Z(nr)&&(h[m]=Object.assign({ref:er},nr),!e))return h}}return h},gr=function(r,e,t){for(var n in void 0===t&&(t=[]),e){var i=r+(C(e)?"."+n:"["+n+"]");nr(e[n])?t.push(i):gr(i,e[n],t)}return t},pr=function(r,e,t,n,i){var a=void 0;return t.add(e),Z(r)||(a=q(r,e),(C(a)||Array.isArray(a))&&gr(e,a).forEach((function(r){return t.add(r)}))),T(a)?i?n:q(n,e):a},br=function(r){return r.substring(0,r.indexOf("["))},yr=function(r,e){return[].concat(r).some((function(r){return function(r,e){return RegExp(("^"+e+"([|.)\\d+").replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(r)}(e,r)}))};var Vr="undefined"!=typeof window&&"undefined"!=typeof document;function Or(r){var e,t;if(nr(r)||Vr&&(r instanceof File||h(r)))return r;if(!["Set","Map","Object","Date","Array"].includes(null===(e=r.constructor)||void 0===e?void 0:e.name))return r;if(r instanceof Date)return t=new Date(r.getTime());if(r instanceof Set){t=new Set;for(var n=0,i=r;n<i.length;n+=1){var a=i[n];t.add(a)}return t}if(r instanceof Map){t=new Map;for(var u=0,o=r.keys();u<o.length;u+=1){var s=o[u];t.set(s,Or(r.get(s)))}return t}for(var c in t=Array.isArray(r)?[]:{},r)t[c]=Or(r[c]);return t}var jr=function(r){return{isOnSubmit:!r||r===O,isOnBlur:r===y,isOnChange:r===V,isOnAll:r===E,isOnTouch:r===j}},Er=function(r){return P(r)||$(r)},kr="undefined"==typeof window,Ar=Vr?"Proxy"in window:"undefined"!=typeof Proxy;function Sr(r){void 0===r&&(r={});var e=r.mode;void 0===e&&(e=O);var o=r.reValidateMode;void 0===o&&(o=V);var s=r.resolver,c=r.context,l=r.defaultValues;void 0===l&&(l={});var f=r.shouldFocusError;void 0===f&&(f=!0);var v=r.shouldUnregister;void 0===v&&(v=!0);var d=r.criteriaMode,m=n({}),y=n({}),j=n({}),k=n(new Set),A=n({}),S=n({}),z=n({}),w=n({}),D=n(l),x=n(!1),R=n(!1),B=n(),_=n({}),I=n({}),J=n(c),K=n(s),Q=n(new Set),rr=n(jr(e)),cr=rr.current,lr=cr.isOnSubmit,vr=cr.isOnTouch,dr=d===E,mr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!lr,errors:{}}),Sr=mr[0],zr=mr[1],wr=n({isDirty:!Ar,dirtyFields:!Ar,touched:!Ar||vr,isValidating:!Ar,isSubmitting:!Ar,isValid:!Ar}),Dr=n(Sr),xr=n(),Fr=n(jr(o)).current,Rr=Fr.isOnBlur,Cr=Fr.isOnChange;J.current=c,K.current=s,Dr.current=Sr,_.current=v?{}:Z(_.current)?Or(l):_.current;var Hr=t((function(r){void 0===r&&(r={}),x.current||(Dr.current=Object.assign(Object.assign({},Dr.current),r),zr(Dr.current))}),[]),Nr=function(){return wr.current.isValidating&&Hr({isValidating:!0})},Br=t((function(r,e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n={});var a=t||function(r){var e=r.errors,t=r.name,n=r.error,i=r.validFields,a=r.fieldsWithValidation,u=T(n),o=q(e,t);return u&&!!o||!u&&!ar(o,n,!0)||u&&q(a,t)&&!q(i,t)}({errors:Dr.current.errors,error:e,name:r,validFields:w.current,fieldsWithValidation:z.current}),u=q(Dr.current.errors,r);e?(er(w.current,r),a=a||!u||!ar(u,e,!0),L(Dr.current.errors,r,e)):((q(z.current,r)||K.current)&&(L(w.current,r,!0),a=a||u),er(Dr.current.errors,r)),(a&&!F(t)||!Z(n)||wr.current.isValidating)&&Hr(Object.assign(Object.assign(Object.assign({},n),K.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Lr=t((function(r,e){var t=m.current[r],n=t.ref,i=t.options,a=Vr&&h(n)&&F(e)?"":e;P(n)?(i||[]).forEach((function(r){var e=r.ref;return e.checked=e.value===a})):U(n)&&!or(a)?n.files=a:G(n)?[].concat(n.options).forEach((function(r){return r.selected=a.includes(r.value)})):$(n)&&i?i.length>1?i.forEach((function(r){var e=r.ref;return e.checked=Array.isArray(a)?!!a.find((function(r){return r===e.value})):a===e.value})):i[0].ref.checked=!!a:n.value=a}),[]),Mr=t((function(r,e){if(wr.current.isDirty){var t=Jr();return r&&e&&L(t,r,e),!ar(t,D.current)}return!1}),[]),Tr=t((function(r,e){if(void 0===e&&(e=!0),wr.current.isDirty||wr.current.dirtyFields){var t=!ar(q(D.current,r),X(m,r,_)),n=q(Dr.current.dirtyFields,r),i=Dr.current.isDirty;t?L(Dr.current.dirtyFields,r,!0):er(Dr.current.dirtyFields,r);var a={isDirty:Mr(),dirtyFields:Dr.current.dirtyFields},u=wr.current.isDirty&&i!==a.isDirty||wr.current.dirtyFields&&n!==q(Dr.current.dirtyFields,r);return u&&e&&Hr(a),u?a:{}}return{}}),[]),qr=t((async function(r,e){if("production"!==process.env.NODE_ENV&&!m.current[r])return console.warn("📋 Field is missing with `name` attribute: ",r),!1;var t=(await hr(m,dr,m.current[r],_))[r];return Br(r,t,e),T(t)}),[Br,dr]),Wr=t((async function(r){var e=(await K.current(Jr(),J.current,dr)).errors,t=Dr.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=q(e,r);return t?L(Dr.current.errors,r,t):er(Dr.current.errors,r),!t})).every(Boolean);return Hr({isValid:Z(e),isValidating:!1}),n}var i=q(e,r);return Br(r,i,t!==Z(e),{},Z(e)),!i}),[Br,dr]),_r=t((async function(r){var e=r||Object.keys(m.current);if(Nr(),K.current)return Wr(e);if(Array.isArray(e)){!r&&(Dr.current.errors={});var t=await Promise.all(e.map((async function(r){return await qr(r,null)})));return Hr({isValidating:!1}),t.every(Boolean)}return await qr(e)}),[Wr,qr]),Ir=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,a={};L(a,r,e);for(var u=0,o=gr(r,e);u<o.length;u+=1){var s=o[u];m.current[s]&&(Lr(s,q(a,s)),n&&Tr(s),i&&_r(s))}}),[_r,Lr,Tr]),Pr=t((function(r,e,t){var n,i;if(!v&&!nr(e)&&L(_.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),m.current[r])Lr(r,e),t.shouldDirty&&Tr(r),t.shouldValidate&&_r(r);else if(!nr(e)&&(Ir(r,e,t),Q.current.has(r))){var a=br(r)||r;L(y.current,r,e),I.current[a](((n={})[a]=q(y.current,a),n)),(wr.current.isDirty||wr.current.dirtyFields)&&t.shouldDirty&&(L(Dr.current.dirtyFields,r,function(r,e,t){return ir(ur(r,e,t.slice(0,r.length)),ur(e,r,t.slice(0,r.length)))}(e,q(D.current,r,[]),q(Dr.current.dirtyFields,r,[]))),Hr({isDirty:!ar(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),D.current)}))}!v&&L(_.current,r,e)}),[Tr,Lr,Ir]),Ur=function(r){return R.current||k.current.has(r)||k.current.has((r.match(/\w+/)||[])[0])},$r=function(r){var e=!0;if(!Z(A.current))for(var t in A.current)r&&A.current[t].size&&!A.current[t].has(r)&&!A.current[t].has(br(r))||(S.current[t](),e=!1);return e};function Gr(r){var e;if(!v){for(var t=Or(r),n=0,i=Q.current;n<i.length;n+=1){var a=i[n];H(a)&&!t[a]&&(t=Object.assign(Object.assign({},t),((e={})[a]=[],e)))}return t}return r}function Jr(r){if(or(r))return X(m,r,_);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];L(e,i,X(m,i,_))}return e}return Gr(sr(m,Or(_.current),v))}B.current=B.current?B.current:async function(r){var e,t,n=r.type,i=r.target,a=i.name,u=m.current[a];if(u){var o=n===g,s=function(r){var e=r.isOnBlur,t=r.isOnChange,n=r.isOnTouch,i=r.isTouched,a=r.isReValidateOnBlur,u=r.isReValidateOnChange,o=r.isBlurEvent,s=r.isSubmitted;return!r.isOnAll&&(!s&&n?!(i||o):(s?a:e)?!o:!(s?u:t)||o)}(Object.assign({isBlurEvent:o,isReValidateOnChange:Cr,isReValidateOnBlur:Rr,isTouched:!!q(Dr.current.touched,a),isSubmitted:Dr.current.isSubmitted},rr.current)),c=Tr(a,!1),l=!Z(c)||!o&&Ur(a);if(o&&!q(Dr.current.touched,a)&&wr.current.touched&&(L(Dr.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:Dr.current.touched})),!v&&$(i)&&L(_.current,a,X(m,a)),s)return!o&&$r(a),(!Z(c)||l&&Z(c))&&Hr(c);if(Nr(),K.current){var f=(await K.current(Jr(),J.current,dr)).errors,d=Dr.current.isValid;if(e=q(f,a),$(i)&&!e&&K.current){var h=br(a),p=q(f,h,{});p.type&&p.message&&(e=p),h&&(p||q(Dr.current.errors,h))&&(a=h)}d!==(t=Z(f))&&(l=!0)}else e=(await hr(m,dr,u,_))[a];!o&&$r(a),Br(a,e,l,c,t)}};var Kr=t((async function(r){void 0===r&&(r={});var e=Z(m.current)?D.current:{},t=(await K.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),J.current,dr)||{}).errors,n=Z(t);Dr.current.isValid!==n&&Hr({isValid:n})}),[dr]),Qr=t((function(r,e){!function(r,e,t,n,i,a){var u=t.ref,o=t.ref.name,s=r.current[o];if(!i){var c=X(r,o,n);!T(c)&&L(n.current,o,c)}u.type&&s?P(u)||$(u)?Array.isArray(s.options)&&s.options.length?(N(s.options).forEach((function(r,t){void 0===r&&(r={}),(Y(r.ref)&&tr(r,r.ref)||a)&&(W(r.ref,e),er(s.options,"["+t+"]"))})),s.options&&!N(s.options).length&&delete r.current[o]):delete r.current[o]:(Y(u)&&tr(s,u)||a)&&(W(u,e),delete r.current[o]):delete r.current[o]}(m,B.current,r,_,v,e),v&&(er(w.current,r.ref.name),er(z.current,r.ref.name))}),[v]),Xr=t((function(r){if(R.current)Hr();else{for(var e=0,t=k.current;e<t.length;e+=1){if(t[e].startsWith(r)){Hr();break}}$r(r)}}),[]),Yr=t((function(r,e){r&&(Qr(r,e),v&&!N(r.options||[]).length&&(er(Dr.current.errors,r.ref.name),L(Dr.current.dirtyFields,r.ref.name,!0),Hr({isDirty:Mr()}),wr.current.isValid&&K.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?A.current[t]:k.current,i=sr(m,Or(_.current),v,!1,r);if(or(r)){var a=br(r)||r;return Q.current.has(a)&&(i=Object.assign(Object.assign({},j.current),i)),pr(i,r,n,T(q(D.current,r))?e:q(D.current,r),!0)}var u=T(e)?D.current:e;return Array.isArray(r)?r.reduce((function(r,e){var t;return Object.assign(Object.assign({},r),((t={})[e]=pr(i,e,n,u),t))}),{}):(R.current=T(t),M(!Z(i)&&i||u))}),[]);function re(r,e){if(void 0===e&&(e={}),"production"!==process.env.NODE_ENV){if(!r.name)return console.warn("📋 Field is missing `name` attribute",r,"https://react-hook-form.com/api#useForm");if(Q.current.has(r.name.split(/\[\d+\]$/)[0])&&!RegExp(("^"+r.name.split(/\[\d+\]$/)[0]+"[\\d+].\\w+").replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(r.name))return console.warn('📋 `name` prop should be in object shape: name="test[index].name"',r,"https://react-hook-form.com/api#useFieldArray")}var t,n=r.name,i=r.type,a=r.value,u=Object.assign({ref:r},e),o=m.current,s=Er(r),c=yr(Q.current,n),l=function(e){return Vr&&(!h(r)||e===r)},f=o[n],d=!0;if(f&&(s?Array.isArray(f.options)&&N(f.options).find((function(r){return a===r.ref.value&&l(r.ref)})):l(f.ref)))o[n]=Object.assign(Object.assign({},f),e);else{f=i?s?Object.assign({options:N(f&&f.options||[]).concat([{ref:r}]),ref:{type:i,name:n}},e):Object.assign({},u):u,o[n]=f;var y=T(q(_.current,n));Z(D.current)&&y||(t=q(y?D.current:_.current,n),(d=T(t))||c||Lr(n,t)),Z(e)||(L(z.current,n,!0),!lr&&wr.current.isValid&&hr(m,dr,f,_).then((function(r){var e=Dr.current.isValid;Z(r)?L(w.current,n,!0):er(w.current,n),e!==Z(r)&&Hr()}))),!v||c&&d||!c&&er(Dr.current.dirtyFields,n),i&&function(r,e,t){var n=r.ref;h(n)&&t&&(n.addEventListener(e?p:b,t),n.addEventListener(g,t))}(s&&f.options?f.options[f.options.length-1]:f,s||"select-one"===r.type,B.current)}}var ee=t((function(r,e){return async function(t){t&&t.preventDefault&&(t.preventDefault(),t.persist());var n={},i=Gr(sr(m,Or(_.current),v,!0));wr.current.isSubmitting&&Hr({isSubmitting:!0});try{if(K.current){var a=await K.current(i,J.current,dr),u=a.errors,o=a.values;Dr.current.errors=n=u,i=o}else for(var s=0,c=Object.values(m.current);s<c.length;s+=1){var l=c[s];if(l){var d=l.ref.name,h=await hr(m,dr,l,_);h[d]?(L(n,d,h[d]),er(w.current,d)):q(z.current,d)&&(er(Dr.current.errors,d),L(w.current,d,!0))}}Z(n)&&Object.keys(Dr.current.errors).every((function(r){return r in m.current}))?(Hr({errors:{},isSubmitting:!0}),await r(i,t)):(Dr.current.errors=Object.assign(Object.assign({},Dr.current.errors),n),e&&await e(Dr.current.errors,t),f&&function(r,e){for(var t in r)if(q(e,t)){var n=r[t];if(n){if(n.ref.focus&&T(n.ref.focus()))break;if(n.options){n.options[0].ref.focus();break}}}}(m.current,Dr.current.errors))}finally{Dr.current.isSubmitting=!1,Hr({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Z(Dr.current.errors),submitCount:Dr.current.submitCount+1})}}}),[f,dr]);a((function(){s&&wr.current.isValid&&Kr(),xr.current=xr.current||!Vr?xr.current:function(r,e){var t=new MutationObserver((function(){for(var t=0,n=Object.values(r.current);t<n.length;t+=1){var i=n[t];if(i&&i.options)for(var a=0,u=i.options;a<u.length;a+=1){var o=u[a];o&&o.ref&&Y(o.ref)&&e(i)}else i&&Y(i.ref)&&e(i)}}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(m,Yr)}),[Yr,D.current]),a((function(){return function(){xr.current&&xr.current.disconnect(),x.current=!0,"production"===process.env.NODE_ENV&&Object.values(m.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!s&&wr.current.isValid&&(Sr.isValid=ar(w.current,z.current)&&Z(Dr.current.errors));var te={trigger:_r,setValue:t((function(r,e,t){Pr(r,e,t||{}),Ur(r)&&Hr(),$r(r)}),[Pr,_r]),getValues:t(Jr,[]),register:t((function(r,e){if(!kr)if(or(r))re({name:r},e);else{if(!C(r)||!("name"in r))return function(e){return e&&re(e,r)};re(r,e)}}),[D.current]),unregister:t((function(r){for(var e=0,t=Array.isArray(r)?r:[r];e<t.length;e+=1){var n=t[e];Yr(m.current[n],!0)}}),[]),formState:Ar?new Proxy(Sr,{get:function(r,e){if("production"!==process.env.NODE_ENV&&"isValid"===e&&lr&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),e in r)return wr.current[e]=!0,r[e]}}):Sr},ne=u((function(){return Object.assign({isFormDirty:Mr,updateWatchedValue:Xr,shouldUnregister:v,updateFormState:Hr,removeFieldEventListener:Qr,watchInternal:Zr,mode:rr.current,reValidateMode:{isReValidateOnBlur:Rr,isReValidateOnChange:Cr},validateResolver:s?Kr:void 0,fieldsRef:m,resetFieldArrayFunctionRef:I,useWatchFieldsRef:A,useWatchRenderFunctionsRef:S,fieldArrayDefaultValuesRef:y,validFieldsRef:w,fieldsWithValidationRef:z,fieldArrayNamesRef:Q,readFormStateRef:wr,formStateRef:Dr,defaultValuesRef:D,shallowFieldsStateRef:_,fieldArrayValuesRef:j},te)}),[D.current,Xr,v,Qr,Zr]);return Object.assign({watch:function(r,e){return Zr(r,e)},control:ne,handleSubmit:ee,reset:t((function(r,e){if(void 0===e&&(e={}),Vr)for(var t=0,n=Object.values(m.current);t<n.length;t+=1){var i=n[t];if(i){var a=i.ref,u=i.options,o=Er(a)&&Array.isArray(u)?u[0].ref:a;if(h(o))try{o.closest("form").reset();break}catch(r){}}}m.current={},D.current=Object.assign({},r||D.current),r&&$r(""),Object.values(I.current).forEach((function(r){return fr(r)&&r()})),_.current=v?{}:Or(r||D.current),function(r){var e=r.errors,t=r.isDirty,n=r.isSubmitted,i=r.touched,a=r.isValid,u=r.submitCount,o=r.dirtyFields;a||(w.current={},z.current={}),y.current={},k.current=new Set,R.current=!1,Hr({submitCount:u?Dr.current.submitCount:0,isDirty:!!t&&Dr.current.isDirty,isSubmitted:!!n&&Dr.current.isSubmitted,isValid:!!a&&Dr.current.isValid,dirtyFields:o?Dr.current.dirtyFields:{},touched:i?Dr.current.touched:{},errors:e?Dr.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})}(e)}),[]),clearErrors:t((function(r){r&&(Array.isArray(r)?r:[r]).forEach((function(r){return m.current[r]&&H(r)?delete Dr.current.errors[r]:er(Dr.current.errors,r)})),Hr({errors:r?Dr.current.errors:{}})}),[]),setError:t((function(r,e){var t=(m.current[r]||{}).ref;L(Dr.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Hr({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:Sr.errors},te)}e(null).displayName="RHFContext";var zr,wr=function(e){var t=e.isExtraSmall,n=e.isHovered,i=r.createElement("path",{fillRule:"evenodd",d:"M13.554 28.445h2.873v-3.243h-2.873v3.243zm-1 1h4.873v-5.243h-4.873v5.243zm1 6.312h2.873v-3.243h-2.873v3.243zm-1 1h4.873v-5.243h-4.873v5.243zm5.986-16.908h1v-3.158h3.159v-1H19.54v-3.159h-1v3.159h-3.159v1h3.159v3.158zM30.791 39.72h8.37V20.682h-8.37V39.72zm-22.202 0h20.903V10.547H8.589V39.72zm22.203-20.338V9.247H7.289V41.02h33.173V19.382h-9.67zm-9.139 9.063h2.873v-3.243h-2.873v3.243zm-1 1h4.873v-5.243h-4.873v5.243zm1 6.312h2.873v-3.243h-2.873v3.243zm-1 1h4.873v-5.243h-4.873v5.243zM10.869 7.702h16.343v-1.3H10.869v1.3z"}),a=r.createElement("path",{fillRule:"evenodd",d:"M13.554 28.445h2.873v-3.243h-2.873v3.243zm-1 1h4.873v-5.243h-4.873v5.243zm1 6.312h2.873v-3.243h-2.873v3.243zm-1 1h4.873v-5.243h-4.873v5.243zm5.986-15.908h1v-4.158h4.159v-1H19.54v-4.159h-1v4.159h-4.159v1h4.159v4.158zM30.791 39.72h8.37V20.682h-8.37V39.72zm-22.202 0h20.903V10.547H8.589V39.72zm22.203-20.338V9.247H7.289V41.02h33.173V19.382h-9.67zm-9.139 9.063h2.873v-3.243h-2.873v3.243zm-1 1h4.873v-5.243h-4.873v5.243zm1 6.312h2.873v-3.243h-2.873v3.243zm-1 1h4.873v-5.243h-4.873v5.243zM10.869 7.702h16.343v-1.3H10.869v1.3z"}),u=r.createElement("path",{fillRule:"evenodd",d:"M21.527 35.62h2.862v-3.233h-2.862v3.234zm-1.01 1.01H25.4v-5.254h-4.884v5.254zm-7.09-1.01h2.863v-3.233h-2.863v3.234zm-1.01 1.01H17.3v-5.254h-4.883v5.254zm9.11-8.322h2.862v-3.232h-2.862v3.232zm-1.01 1.01H25.4v-5.254h-4.884v5.254zm-7.09-1.01h2.863v-3.232h-2.863v3.232zm-1.01 1.01H17.3v-5.253h-4.883v5.254zm5.86-9.6h1.264V16.69h3.027v-1.263H19.54V12.4h-1.263v3.027H15.25v1.263h3.028v3.028zm12.365 19.888h8.406V20.53h-8.406v19.075zm-22.204 0h20.94V9.132H8.439v30.474zm22.204-20.338V7.87H7.175v33H40.31V19.267h-9.67z"});return t?n?r.createElement("path",{fillRule:"evenodd",d:"M22.158 35.62h2.863v-3.233h-2.863v3.234zm-1.01 1.01h4.883v-5.254h-4.883v5.254zm-7.09-1.01h2.863v-3.233H14.06v3.234zm-1.01 1.01h4.884v-5.254h-4.884v5.254zm9.11-8.322h2.863v-3.232h-2.863v3.232zm-1.01 1.01h4.883v-5.254h-4.883v5.254zm-7.09-1.01h2.863v-3.232H14.06v3.232zm-1.01 1.01h4.884v-5.253h-4.884v5.254zm5.861-9.6h1.264V16.69h3.026v-1.263h-3.026V12.4h-1.264v3.027h-3.027v1.263h3.027v3.028zm12.364 19.888h8.407V20.53h-8.407v19.075zm-22.204 0H30.01V9.132H9.07v30.474zm22.204-20.338V7.87H7.806v33h33.137V19.267h-9.67z"}):u:n?a:i};!function(r){r.formgroup="formgroup",r.checkbox="checkbox",r.radiobutton="radiobutton",r.textarea="textarea",r.input="input"}(zr||(zr={}));var Dr=function(e){var t=e.exampleType,n=void 0===t?zr.formgroup:t,i=Sr(),a=i.register,u=i.handleSubmit,o=i.errors,h=o.formgroup1||o.formgroup2||o.formgroup3||o.formgroup4||o.formgroup5,g="Du må velge et alternativ",p=function(r){return r.length>=2||"Du må velge to alternativ"};return r.createElement("form",{onSubmit:u((function(r){console.log(r)}))},r.createElement(s,{variant:e.variant,errorSummary:h?"Sjekk at alt er riktig utfylt":void 0},n===zr.formgroup?[r.createElement(c,{key:0,title:"One amazing title",legend:"Check out these checkboxes!",error:o.formgroup1?o.formgroup1.message:void 0,variant:e.variant,name:"formgroup1"},r.createElement(l,{label:"Checkbox 1",ref:a({required:g})}),r.createElement(l,{label:"Checkbox 2",ref:a({required:g})}),r.createElement(l,{label:"Checkbox 3",ref:a({required:g})})),r.createElement(c,{key:1,legend:"Select two options!",error:o.formgroup2?o.formgroup2.message:void 0,variant:e.variant,name:"formgroup2"},r.createElement(l,{label:"Checkbox 4",ref:a({validate:p})}),r.createElement(l,{label:"Checkbox 5",ref:a({validate:p})}),r.createElement(l,{label:"Checkbox 6",ref:a({validate:p})})),r.createElement(c,{key:2,legend:"Select two options!",error:o.formgroup3?o.formgroup3.message:void 0,variant:e.variant,name:"formgroup3"},r.createElement(v,{label:"Radiobutton 1",ref:a({required:g})}),r.createElement(v,{label:"Radiobutton 2",ref:a({required:g})}),r.createElement(v,{label:"Radiobutton 3",ref:a({required:g})})),r.createElement(c,{key:3,error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(d,{defaultValue:"Dette er en test \n\n Hello \n\n test \n\n test test",grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})),r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(m,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:wr,ref:a({required:"Du må skrive noe her"})}))]:n===zr.checkbox?r.createElement(c,{name:"formgroup1",error:o.formgroup1?o.formgroup1.message:void 0},r.createElement(l,{name:"formgroup1",label:"Checkbox 1",error:o.formgroup1,variant:e.variant,ref:a({required:g})})):n===zr.radiobutton?r.createElement(c,{name:"formgroup3",error:o.formgroup3?o.formgroup3.message:void 0},r.createElement(v,{name:"formgroup3",label:"Radiobutton 1",error:o.formgroup3,variant:e.variant,ref:a({required:g})})):n===zr.textarea?r.createElement(c,{error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(d,{defaultValue:"Dette er min historie \n\n Hello \n\n test",grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})):n===zr.input?r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(m,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:wr,ref:a({required:"Du må skrive noe her"})})):void 0),r.createElement(f,null,"Submit"))};export default Dr;export{Dr as FormExample,zr as FormExampleVariants};
2
2
  //# sourceMappingURL=index.js.map