@helsenorge/designsystem-react 1.0.0-beta92 → 1.0.0-beta97
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.
- package/Button-8af0be6e.js +2 -0
- package/Button-8af0be6e.js.map +1 -0
- package/Checkbox-fb5dff56.js +2 -0
- package/Checkbox-fb5dff56.js.map +1 -0
- package/{Close-80751ae6.js → Close-9f68bcd0.js} +2 -2
- package/Close-9f68bcd0.js.map +1 -0
- package/FormGroup-6c545646.js +2 -0
- package/FormGroup-6c545646.js.map +1 -0
- package/{Icon-9b4a8a2d.js → Icon-04613a89.js} +2 -2
- package/Icon-04613a89.js.map +1 -0
- package/Input-adeb7f88.js +2 -0
- package/Input-adeb7f88.js.map +1 -0
- package/Loader-b3fd59f4.js +2 -0
- package/Loader-b3fd59f4.js.map +1 -0
- package/Modal-3742133d.js +2 -0
- package/Modal-3742133d.js.map +1 -0
- package/RadioButton-d90884c9.js +2 -0
- package/RadioButton-d90884c9.js.map +1 -0
- package/Textarea-05e33ba3.js +2 -0
- package/Textarea-05e33ba3.js.map +1 -0
- package/Title-90910763.js +2 -0
- package/Title-90910763.js.map +1 -0
- package/{Validation-1236e8ef.js → Validation-9bf0c0ec.js} +2 -2
- package/Validation-9bf0c0ec.js.map +1 -0
- package/components/AnchorLink/index.d.ts +1 -0
- package/components/AnchorLink/index.d.ts.map +1 -1
- package/components/AnchorLink/index.js +1 -1
- package/components/Avatar/index.d.ts +1 -0
- package/components/Avatar/index.d.ts.map +1 -1
- package/components/Avatar/index.js +1 -1
- package/components/Badge/index.d.ts +1 -0
- package/components/Badge/index.d.ts.map +1 -1
- package/components/Button/Button.d.ts.map +1 -1
- package/components/Button/index.d.ts +1 -0
- package/components/Button/index.d.ts.map +1 -1
- package/components/Button/index.js +1 -1
- package/components/ButtonWithModal/componentdata.json +19 -0
- package/components/ButtonWithModal/index.d.ts +1 -0
- package/components/ButtonWithModal/index.d.ts.map +1 -1
- package/components/ButtonWithModal/index.js +1 -1
- package/components/Checkbox/componentdata.json +9 -9
- package/components/Checkbox/index.d.ts +1 -0
- package/components/Checkbox/index.d.ts.map +1 -1
- package/components/Checkbox/index.js +1 -1
- package/components/Checkbox/styles.module.scss +2 -1
- package/components/Close/index.d.ts +1 -0
- package/components/Close/index.d.ts.map +1 -1
- package/components/Close/index.js +1 -1
- package/components/ExpanderList/index.d.ts +1 -0
- package/components/ExpanderList/index.d.ts.map +1 -1
- package/components/ExpanderList/index.js +1 -1
- package/components/FormExample/FormExample.d.ts +2 -1
- package/components/FormExample/FormExample.d.ts.map +1 -1
- package/components/FormExample/componentdata.json +6 -3
- package/components/FormExample/index.d.ts +1 -0
- package/components/FormExample/index.d.ts.map +1 -1
- package/components/FormExample/index.js +1 -1
- package/components/FormExample/index.js.map +1 -1
- package/components/FormGroup/FormGroup.d.ts.map +1 -1
- package/components/FormGroup/componentdata.json +9 -9
- package/components/FormGroup/index.d.ts +1 -0
- package/components/FormGroup/index.d.ts.map +1 -1
- package/components/FormGroup/index.js +1 -1
- package/components/FormGroup/styles.module.scss +2 -2
- package/components/HighlightBox/HighlightBox.d.ts +24 -0
- package/components/HighlightBox/HighlightBox.d.ts.map +1 -0
- package/components/HighlightBox/componentdata.json +484 -0
- package/components/HighlightBox/index.d.ts +4 -0
- package/components/HighlightBox/index.d.ts.map +1 -0
- package/components/HighlightBox/index.js +2 -0
- package/components/HighlightBox/index.js.map +1 -0
- package/components/HighlightBox/styles.module.scss +89 -0
- package/components/Icons/AcupunctureBack.js +1 -1
- package/components/Icons/Icon.js +1 -1
- package/components/Icons/NoEye.js +1 -1
- package/components/Icons/SectionSign.js +1 -1
- package/components/Icons/SpeechBubble.js +1 -1
- package/components/Icons/SupportingPerson.js +1 -1
- package/components/Icons/Syringe.js +1 -1
- package/components/Icons/index.js +1 -1
- package/components/Input/Input.d.ts +55 -0
- package/components/Input/Input.d.ts.map +1 -0
- package/components/Input/componentdata.json +425 -0
- package/components/Input/index.d.ts +4 -0
- package/components/Input/index.d.ts.map +1 -0
- package/components/Input/index.js +2 -0
- package/components/Input/index.js.map +1 -0
- package/components/Input/styles.module.scss +55 -0
- package/components/Input/styles.module.scss.d.ts +23 -0
- package/components/LinkList/index.d.ts +1 -0
- package/components/LinkList/index.d.ts.map +1 -1
- package/components/LinkList/index.js +1 -1
- package/components/List/index.d.ts +1 -0
- package/components/List/index.d.ts.map +1 -1
- package/components/Loader/Loader.d.ts +2 -2
- package/components/Loader/componentdata.json +3 -3
- package/components/Loader/index.d.ts +1 -0
- package/components/Loader/index.d.ts.map +1 -1
- package/components/Loader/index.js +1 -1
- package/components/Logo/index.d.ts +1 -0
- package/components/Logo/index.d.ts.map +1 -1
- package/components/Modal/Modal.d.ts +2 -0
- package/components/Modal/Modal.d.ts.map +1 -1
- package/components/Modal/componentdata.json +19 -0
- package/components/Modal/index.d.ts +1 -0
- package/components/Modal/index.d.ts.map +1 -1
- package/components/Modal/index.js +1 -1
- package/components/NotificationPanel/index.d.ts +1 -0
- package/components/NotificationPanel/index.d.ts.map +1 -1
- package/components/NotificationPanel/index.js +1 -1
- package/components/RadioButton/componentdata.json +9 -9
- package/components/RadioButton/index.d.ts +1 -0
- package/components/RadioButton/index.d.ts.map +1 -1
- package/components/RadioButton/index.js +1 -1
- package/components/RadioButton/styles.module.scss +2 -2
- package/components/Slider/index.d.ts +1 -0
- package/components/Slider/index.d.ts.map +1 -1
- package/components/Slider/index.js +1 -1
- package/components/Spacer/index.d.ts +1 -0
- package/components/Spacer/index.d.ts.map +1 -1
- package/components/Textarea/Textarea.d.ts +4 -0
- package/components/Textarea/Textarea.d.ts.map +1 -1
- package/components/Textarea/componentdata.json +44 -6
- package/components/Textarea/index.d.ts +1 -0
- package/components/Textarea/index.d.ts.map +1 -1
- package/components/Textarea/index.js +1 -1
- package/components/Textarea/styles.module.scss +13 -110
- package/components/Textarea/styles.module.scss.d.ts +13 -8
- package/components/Tile/index.d.ts +1 -0
- package/components/Tile/index.d.ts.map +1 -1
- package/components/Tile/index.js +1 -1
- package/components/Title/index.d.ts +1 -0
- package/components/Title/index.d.ts.map +1 -1
- package/components/Title/index.js +1 -1
- package/components/Validation/componentdata.json +3 -3
- package/components/Validation/index.d.ts +1 -0
- package/components/Validation/index.d.ts.map +1 -1
- package/components/Validation/index.js +1 -1
- package/constants-42547490.js +2 -0
- package/constants-42547490.js.map +1 -0
- package/constants.d.ts +7 -7
- package/constants.d.ts.map +1 -1
- package/hooks/useIcons.d.ts +4 -0
- package/hooks/useIcons.d.ts.map +1 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/scss/_input.scss +174 -0
- package/scss/_title.scss +16 -12
- package/Button-2be46c88.js +0 -2
- package/Button-2be46c88.js.map +0 -1
- package/Checkbox-0ba01292.js +0 -2
- package/Checkbox-0ba01292.js.map +0 -1
- package/Close-80751ae6.js.map +0 -1
- package/FormGroup-9555dd73.js +0 -2
- package/FormGroup-9555dd73.js.map +0 -1
- package/Icon-9b4a8a2d.js.map +0 -1
- package/Loader-3589bdb1.js +0 -2
- package/Loader-3589bdb1.js.map +0 -1
- package/Modal-b68c7a72.js +0 -2
- package/Modal-b68c7a72.js.map +0 -1
- package/RadioButton-84ca988e.js +0 -2
- package/RadioButton-84ca988e.js.map +0 -1
- package/Textarea-9c91191a.js +0 -2
- package/Textarea-9c91191a.js.map +0 -1
- package/Title-72851d51.js +0 -2
- package/Title-72851d51.js.map +0 -1
- package/Validation-1236e8ef.js.map +0 -1
- package/constants-a4b0b501.js +0 -2
- package/constants-a4b0b501.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 a,useMemo as u,isValidElement as o}from"react";import{V as s}from"../../Validation-1236e8ef.js";import{F as c}from"../../FormGroup-9555dd73.js";import{C as l}from"../../Checkbox-0ba01292.js";import{B as f}from"../../Button-2be46c88.js";import{R as d}from"../../RadioButton-84ca988e.js";import{T as v}from"../../Textarea-9c91191a.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../_rollupPluginBabelHelpers-d0752906.js";import"../FormGroup/styles.module.scss";import"../../constants-a4b0b501.js";import"../../Title-72851d51.js";import"../Title/styles.module.scss";import"../../uuid-8870ab4b.js";import"../../Check-6291ad09.js";import"../../Icon-9b4a8a2d.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-3589bdb1.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";var m=function(r){return r instanceof HTMLElement},g="blur",p="change",b="input",y="onBlur",h="onChange",O="onSubmit",j="onTouched",V="all",A="max",E="min",w="maxLength",k="minLength",S="pattern",D="required",F="validate";var x=function(r){return null==r},R=function(r){return"object"==typeof r},C=function(r){return!x(r)&&!Array.isArray(r)&&R(r)&&!(r instanceof Date)},N=function(r){return/^\w*$/.test(r)},B=function(r){return r.filter(Boolean)},L=function(r){return B(r.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."))};function T(r,e,t){for(var n=-1,i=N(e)?[e]:L(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 q=function(r,e){for(var t in void 0===e&&(e={}),r)N(t)?e[t]=r[t]:T(e,t,r[t]);return e},M=function(r){return void 0===r},W=function(r,e,t){void 0===r&&(r={});var n=B(e.split(/[,[\].]+?/)).reduce((function(r,e){return x(r)?r:r[e]}),r);return M(n)||n===r?M(r[e])?t:r[e]:n},H=function(r,e){m(r)&&r.removeEventListener&&(r.removeEventListener(b,e),r.removeEventListener(p,e),r.removeEventListener(g,e))},_={isValid:!1,value:null},P=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),_):_},z=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},I={value:!1,isValid:!1},J={value:!0,isValid:!0},K=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&&!M(a.value)?M(i)||""===i?J:{value:i,isValid:!0}:J:I}return I};function Q(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,d=u.valueAsDate,v=u.setValueAs;if(c&&n)return;return U(l)?l.files:z(l)?P(u.options).value:G(l)?(a=l.options,[].concat(a).filter((function(r){return r.selected})).map((function(r){return r.value}))):$(l)?K(u.options).value:i?s:f?""===s?NaN:+s:d?l.valueAsDate:v?v(s):s}if(t)return W(t.current,e)}function X(r){return!r||r instanceof HTMLElement&&r.nodeType!==Node.DOCUMENT_NODE&&X(r.parentNode)}var Y=function(r){return C(r)&&!Object.keys(r).length},Z=function(r){return"boolean"==typeof r};function rr(r,e){var t,n=N(e)?[e]:L(e),i=1==n.length?r:function(r,e){for(var t=e.slice(0,-1).length,n=0;n<t;)r=M(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)&&Y(s)||Array.isArray(s)&&!s.filter((function(r){return C(r)&&!Y(r)||Z(r)})).length)&&(t?delete t[f]:delete r[f]),t=s}}return r}var er=function(r,e){return r&&r.ref===e};var tr=function(r){return x(r)||!R(r)};function nr(r,e){if(tr(r)||tr(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)?nr(n,i):i}catch(r){}}return r}function ir(r,e,t){if(tr(r)||tr(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))?!ir(c,l,t):c!==l)return!1}}}return!0}function ar(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]=[],ar(r[u][o],W(e[u]||{},o,[]),t[u][o],t[u],o)):ir(W(e[u]||{},o),r[u][o])?T(t[u]||{},o):t[u]=Object.assign(Object.assign({},t[u]),((a={})[o]=!0,a));n&&!t.length&&delete n[i]}return t}var ur=function(r){return"string"==typeof r},or=function(r,e,t,n,i){var a={},u=function(e){(M(i)||(ur(i)?e.startsWith(i):Array.isArray(i)&&i.find((function(r){return e.startsWith(r)}))))&&(a[e]=Q(r,e,void 0,n))};for(var o in r.current)u(o);return t?q(a):nr(e,q(a))},sr=function(r){return r instanceof RegExp},cr=function(r){return C(r)&&!sr(r)?r:{value:r,message:""}},lr=function(r){return"function"==typeof r},fr=function(r){return ur(r)||o(r)};function dr(r,e,t){if(void 0===t&&(t="validate"),fr(r)||Z(r)&&!r)return{type:t,message:fr(r)?r:"",ref:e}}var vr=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))}):{}},mr=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,d=t.pattern,v=t.validate,m=i.name,g={},p=z(i),b=$(i),y=p||b,h=""===a,O=vr.bind(null,m,e,g),j=function(r,e,t,n,a){void 0===n&&(n=w),void 0===a&&(a=k);var u=r?e:t;g[m]=Object.assign({type:r?n:a,message:u,ref:i},O(r?n:a,u))};if(o&&(!p&&!b&&(h||x(a))||Z(a)&&!a||b&&!K(u).isValid||p&&!P(u).isValid)){var V=fr(o)?{value:!!o,message:o}:cr(o),R=V.value,N=V.message;if(R&&(g[m]=Object.assign({type:D,message:N,ref:y?((r.current[m].options||[])[0]||{}).ref:i},O(D,N)),!e))return g}if(!(x(l)&&x(f)||""===a)){var B,L,T=cr(f),q=cr(l);if(isNaN(a)){var M=i.valueAsDate||new Date(a);ur(T.value)&&(B=M>new Date(T.value)),ur(q.value)&&(L=M<new Date(q.value))}else{var W=i.valueAsNumber||parseFloat(a);x(T.value)||(B=W>T.value),x(q.value)||(L=W<q.value)}if((B||L)&&(j(!!B,T.message,q.message,A,E),!e))return g}if(ur(a)&&!h&&(s||c)){var H=cr(s),_=cr(c),U=!x(H.value)&&a.length>H.value,G=!x(_.value)&&a.length<_.value;if((U||G)&&(j(U,H.message,_.message),!e))return g}if(ur(a)&&d&&!h){var I=cr(d),J=I.value,X=I.message;if(sr(J)&&!J.test(a)&&(g[m]=Object.assign({type:S,message:X,ref:i},O(S,X)),!e))return g}if(v){var rr=Q(r,m,n,!1,!0),er=y&&u?u[0].ref:i;if(lr(v)){var tr=dr(await v(rr),er);if(tr&&(g[m]=Object.assign(Object.assign({},tr),O(F,tr.message)),!e))return g}else if(C(v)){for(var nr={},ir=0,ar=Object.entries(v);ir<ar.length;ir+=1){var or=ar[ir],mr=or[0],gr=or[1];if(!Y(nr)&&!e)break;var pr=dr(await gr(rr),er,mr);pr&&(nr=Object.assign(Object.assign({},pr),O(mr,pr.message)),e&&(g[m]=nr))}if(!Y(nr)&&(g[m]=Object.assign({ref:er},nr),!e))return g}}return g},gr=function(r,e,t){for(var n in void 0===t&&(t=[]),e){var i=r+(C(e)?"."+n:"["+n+"]");tr(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),Y(r)||(a=W(r,e),(C(a)||Array.isArray(a))&&gr(e,a).forEach((function(r){return t.add(r)}))),M(a)?i?n:W(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 hr="undefined"!=typeof window&&"undefined"!=typeof document;function Or(r){var e,t;if(tr(r)||hr&&(r instanceof File||m(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,Vr=function(r){return{isOnSubmit:!r||r===O,isOnBlur:r===y,isOnChange:r===h,isOnAll:r===V,isOnTouch:r===j}},Ar=function(r){return z(r)||$(r)},Er="undefined"==typeof window,wr=hr?"Proxy"in window:"undefined"!=typeof Proxy;function kr(r){void 0===r&&(r={});var e=r.mode;void 0===e&&(e=O);var o=r.reValidateMode;void 0===o&&(o=h);var s=r.resolver,c=r.context,l=r.defaultValues;void 0===l&&(l={});var f=r.shouldFocusError;void 0===f&&(f=!0);var d=r.shouldUnregister;void 0===d&&(d=!0);var v=r.criteriaMode,y=n({}),j=n({}),A=n({}),E=n(new Set),w=n({}),k=n({}),S=n({}),D=n({}),F=n(l),R=n(!1),L=n(!1),_=n(),P=n({}),I=n({}),J=n(c),K=n(s),Z=n(new Set),sr=n(Vr(e)),cr=sr.current,fr=cr.isOnSubmit,dr=cr.isOnTouch,vr=v===V,jr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!fr,errors:{}}),kr=jr[0],Sr=jr[1],Dr=n({isDirty:!wr,dirtyFields:!wr,touched:!wr||dr,isValidating:!wr,isSubmitting:!wr,isValid:!wr}),Fr=n(kr),xr=n(),Rr=n(Vr(o)).current,Cr=Rr.isOnBlur,Nr=Rr.isOnChange;J.current=c,K.current=s,Fr.current=kr,P.current=d?{}:Y(P.current)?Or(l):P.current;var Br=t((function(r){void 0===r&&(r={}),R.current||(Fr.current=Object.assign(Object.assign({},Fr.current),r),Sr(Fr.current))}),[]),Lr=function(){return Dr.current.isValidating&&Br({isValidating:!0})},Tr=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=M(n),o=W(e,t);return u&&!!o||!u&&!ir(o,n,!0)||u&&W(a,t)&&!W(i,t)}({errors:Fr.current.errors,error:e,name:r,validFields:D.current,fieldsWithValidation:S.current}),u=W(Fr.current.errors,r);e?(rr(D.current,r),a=a||!u||!ir(u,e,!0),T(Fr.current.errors,r,e)):((W(S.current,r)||K.current)&&(T(D.current,r,!0),a=a||u),rr(Fr.current.errors,r)),(a&&!x(t)||!Y(n)||Dr.current.isValidating)&&Br(Object.assign(Object.assign(Object.assign({},n),K.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),qr=t((function(r,e){var t=y.current[r],n=t.ref,i=t.options,a=hr&&m(n)&&x(e)?"":e;z(n)?(i||[]).forEach((function(r){var e=r.ref;return e.checked=e.value===a})):U(n)&&!ur(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(Dr.current.isDirty){var t=Jr();return r&&e&&T(t,r,e),!ir(t,F.current)}return!1}),[]),Wr=t((function(r,e){if(void 0===e&&(e=!0),Dr.current.isDirty||Dr.current.dirtyFields){var t=!ir(W(F.current,r),Q(y,r,P)),n=W(Fr.current.dirtyFields,r),i=Fr.current.isDirty;t?T(Fr.current.dirtyFields,r,!0):rr(Fr.current.dirtyFields,r);var a={isDirty:Mr(),dirtyFields:Fr.current.dirtyFields},u=Dr.current.isDirty&&i!==a.isDirty||Dr.current.dirtyFields&&n!==W(Fr.current.dirtyFields,r);return u&&e&&Br(a),u?a:{}}return{}}),[]),Hr=t((async function(r,e){if("production"!==process.env.NODE_ENV&&!y.current[r])return console.warn("📋 Field is missing with `name` attribute: ",r),!1;var t=(await mr(y,vr,y.current[r],P))[r];return Tr(r,t,e),M(t)}),[Tr,vr]),_r=t((async function(r){var e=(await K.current(Jr(),J.current,vr)).errors,t=Fr.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=W(e,r);return t?T(Fr.current.errors,r,t):rr(Fr.current.errors,r),!t})).every(Boolean);return Br({isValid:Y(e),isValidating:!1}),n}var i=W(e,r);return Tr(r,i,t!==Y(e),{},Y(e)),!i}),[Tr,vr]),Pr=t((async function(r){var e=r||Object.keys(y.current);if(Lr(),K.current)return _r(e);if(Array.isArray(e)){!r&&(Fr.current.errors={});var t=await Promise.all(e.map((async function(r){return await Hr(r,null)})));return Br({isValidating:!1}),t.every(Boolean)}return await Hr(e)}),[_r,Hr]),zr=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,a={};T(a,r,e);for(var u=0,o=gr(r,e);u<o.length;u+=1){var s=o[u];y.current[s]&&(qr(s,W(a,s)),n&&Wr(s),i&&Pr(s))}}),[Pr,qr,Wr]),Ur=t((function(r,e,t){var n,i;if(!d&&!tr(e)&&T(P.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),y.current[r])qr(r,e),t.shouldDirty&&Wr(r),t.shouldValidate&&Pr(r);else if(!tr(e)&&(zr(r,e,t),Z.current.has(r))){var a=br(r)||r;T(j.current,r,e),I.current[a](((n={})[a]=W(j.current,a),n)),(Dr.current.isDirty||Dr.current.dirtyFields)&&t.shouldDirty&&(T(Fr.current.dirtyFields,r,function(r,e,t){return nr(ar(r,e,t.slice(0,r.length)),ar(e,r,t.slice(0,r.length)))}(e,W(F.current,r,[]),W(Fr.current.dirtyFields,r,[]))),Br({isDirty:!ir(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),F.current)}))}!d&&T(P.current,r,e)}),[Wr,qr,zr]),$r=function(r){return L.current||E.current.has(r)||E.current.has((r.match(/\w+/)||[])[0])},Gr=function(r){var e=!0;if(!Y(w.current))for(var t in w.current)r&&w.current[t].size&&!w.current[t].has(r)&&!w.current[t].has(br(r))||(k.current[t](),e=!1);return e};function Ir(r){var e;if(!d){for(var t=Or(r),n=0,i=Z.current;n<i.length;n+=1){var a=i[n];N(a)&&!t[a]&&(t=Object.assign(Object.assign({},t),((e={})[a]=[],e)))}return t}return r}function Jr(r){if(ur(r))return Q(y,r,P);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];T(e,i,Q(y,i,P))}return e}return Ir(or(y,Or(P.current),d))}_.current=_.current?_.current:async function(r){var e,t,n=r.type,i=r.target,a=i.name,u=y.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:Nr,isReValidateOnBlur:Cr,isTouched:!!W(Fr.current.touched,a),isSubmitted:Fr.current.isSubmitted},sr.current)),c=Wr(a,!1),l=!Y(c)||!o&&$r(a);if(o&&!W(Fr.current.touched,a)&&Dr.current.touched&&(T(Fr.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:Fr.current.touched})),!d&&$(i)&&T(P.current,a,Q(y,a)),s)return!o&&Gr(a),(!Y(c)||l&&Y(c))&&Br(c);if(Lr(),K.current){var f=(await K.current(Jr(),J.current,vr)).errors,v=Fr.current.isValid;if(e=W(f,a),$(i)&&!e&&K.current){var m=br(a),p=W(f,m,{});p.type&&p.message&&(e=p),m&&(p||W(Fr.current.errors,m))&&(a=m)}v!==(t=Y(f))&&(l=!0)}else e=(await mr(y,vr,u,P))[a];!o&&Gr(a),Tr(a,e,l,c,t)}};var Kr=t((async function(r){void 0===r&&(r={});var e=Y(y.current)?F.current:{},t=(await K.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),J.current,vr)||{}).errors,n=Y(t);Fr.current.isValid!==n&&Br({isValid:n})}),[vr]),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=Q(r,o,n);!M(c)&&T(n.current,o,c)}u.type&&s?z(u)||$(u)?Array.isArray(s.options)&&s.options.length?(B(s.options).forEach((function(r,t){void 0===r&&(r={}),(X(r.ref)&&er(r,r.ref)||a)&&(H(r.ref,e),rr(s.options,"["+t+"]"))})),s.options&&!B(s.options).length&&delete r.current[o]):delete r.current[o]:(X(u)&&er(s,u)||a)&&(H(u,e),delete r.current[o]):delete r.current[o]}(y,_.current,r,P,d,e),d&&(rr(D.current,r.ref.name),rr(S.current,r.ref.name))}),[d]),Xr=t((function(r){if(L.current)Br();else{for(var e=0,t=E.current;e<t.length;e+=1){if(t[e].startsWith(r)){Br();break}}Gr(r)}}),[]),Yr=t((function(r,e){r&&(Qr(r,e),d&&!B(r.options||[]).length&&(rr(Fr.current.errors,r.ref.name),T(Fr.current.dirtyFields,r.ref.name,!0),Br({isDirty:Mr()}),Dr.current.isValid&&K.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?w.current[t]:E.current,i=or(y,Or(P.current),d,!1,r);if(ur(r)){var a=br(r)||r;return Z.current.has(a)&&(i=Object.assign(Object.assign({},A.current),i)),pr(i,r,n,M(W(F.current,r))?e:W(F.current,r),!0)}var u=M(e)?F.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))}),{}):(L.current=M(t),q(!Y(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(Z.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=y.current,s=Ar(r),c=yr(Z.current,n),l=function(e){return hr&&(!m(r)||e===r)},f=o[n],v=!0;if(f&&(s?Array.isArray(f.options)&&B(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:B(f&&f.options||[]).concat([{ref:r}]),ref:{type:i,name:n}},e):Object.assign({},u):u,o[n]=f;var h=M(W(P.current,n));Y(F.current)&&h||(t=W(h?F.current:P.current,n),(v=M(t))||c||qr(n,t)),Y(e)||(T(S.current,n,!0),!fr&&Dr.current.isValid&&mr(y,vr,f,P).then((function(r){var e=Fr.current.isValid;Y(r)?T(D.current,n,!0):rr(D.current,n),e!==Y(r)&&Br()}))),!d||c&&v||!c&&rr(Fr.current.dirtyFields,n),i&&function(r,e,t){var n=r.ref;m(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,_.current)}}var ee=t((function(r,e){return async function(t){t&&t.preventDefault&&(t.preventDefault(),t.persist());var n={},i=Ir(or(y,Or(P.current),d,!0));Dr.current.isSubmitting&&Br({isSubmitting:!0});try{if(K.current){var a=await K.current(i,J.current,vr),u=a.errors,o=a.values;Fr.current.errors=n=u,i=o}else for(var s=0,c=Object.values(y.current);s<c.length;s+=1){var l=c[s];if(l){var v=l.ref.name,m=await mr(y,vr,l,P);m[v]?(T(n,v,m[v]),rr(D.current,v)):W(S.current,v)&&(rr(Fr.current.errors,v),T(D.current,v,!0))}}Y(n)&&Object.keys(Fr.current.errors).every((function(r){return r in y.current}))?(Br({errors:{},isSubmitting:!0}),await r(i,t)):(Fr.current.errors=Object.assign(Object.assign({},Fr.current.errors),n),e&&await e(Fr.current.errors,t),f&&function(r,e){for(var t in r)if(W(e,t)){var n=r[t];if(n){if(n.ref.focus&&M(n.ref.focus()))break;if(n.options){n.options[0].ref.focus();break}}}}(y.current,Fr.current.errors))}finally{Fr.current.isSubmitting=!1,Br({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Y(Fr.current.errors),submitCount:Fr.current.submitCount+1})}}}),[f,vr]);a((function(){s&&Dr.current.isValid&&Kr(),xr.current=xr.current||!hr?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&&X(o.ref)&&e(i)}else i&&X(i.ref)&&e(i)}}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(y,Yr)}),[Yr,F.current]),a((function(){return function(){xr.current&&xr.current.disconnect(),R.current=!0,"production"===process.env.NODE_ENV&&Object.values(y.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!s&&Dr.current.isValid&&(kr.isValid=ir(D.current,S.current)&&Y(Fr.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(!Er)if(ur(r))re({name:r},e);else{if(!C(r)||!("name"in r))return function(e){return e&&re(e,r)};re(r,e)}}),[F.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(y.current[n],!0)}}),[]),formState:wr?new Proxy(kr,{get:function(r,e){if("production"!==process.env.NODE_ENV&&"isValid"===e&&fr&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),e in r)return Dr.current[e]=!0,r[e]}}):kr},ne=u((function(){return Object.assign({isFormDirty:Mr,updateWatchedValue:Xr,shouldUnregister:d,updateFormState:Br,removeFieldEventListener:Qr,watchInternal:Zr,mode:sr.current,reValidateMode:{isReValidateOnBlur:Cr,isReValidateOnChange:Nr},validateResolver:s?Kr:void 0,fieldsRef:y,resetFieldArrayFunctionRef:I,useWatchFieldsRef:w,useWatchRenderFunctionsRef:k,fieldArrayDefaultValuesRef:j,validFieldsRef:D,fieldsWithValidationRef:S,fieldArrayNamesRef:Z,readFormStateRef:Dr,formStateRef:Fr,defaultValuesRef:F,shallowFieldsStateRef:P,fieldArrayValuesRef:A},te)}),[F.current,Xr,d,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={}),hr)for(var t=0,n=Object.values(y.current);t<n.length;t+=1){var i=n[t];if(i){var a=i.ref,u=i.options,o=Ar(a)&&Array.isArray(u)?u[0].ref:a;if(m(o))try{o.closest("form").reset();break}catch(r){}}}y.current={},F.current=Object.assign({},r||F.current),r&&Gr(""),Object.values(I.current).forEach((function(r){return lr(r)&&r()})),P.current=d?{}:Or(r||F.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||(D.current={},S.current={}),j.current={},E.current=new Set,L.current=!1,Br({submitCount:u?Fr.current.submitCount:0,isDirty:!!t&&Fr.current.isDirty,isSubmitted:!!n&&Fr.current.isSubmitted,isValid:!!a&&Fr.current.isValid,dirtyFields:o?Fr.current.dirtyFields:{},touched:i?Fr.current.touched:{},errors:e?Fr.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})}(e)}),[]),clearErrors:t((function(r){r&&(Array.isArray(r)?r:[r]).forEach((function(r){return y.current[r]&&N(r)?delete Fr.current.errors[r]:rr(Fr.current.errors,r)})),Br({errors:r?Fr.current.errors:{}})}),[]),setError:t((function(r,e){var t=(y.current[r]||{}).ref;T(Fr.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Br({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:kr.errors},te)}e(null).displayName="RHFContext",function(r){r.formgroup="formgroup",r.checkbox="checkbox",r.radiobutton="radiobutton",r.textarea="textarea"}(jr||(jr={}));export default function(e){var t=e.exampleType,n=void 0===t?jr.formgroup:t,i=kr(),a=i.register,u=i.handleSubmit,o=i.errors,m=o.formgroup1||o.formgroup2||o.formgroup3||o.formgroup4,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:m?"Sjekk at alt er riktig utfylt":void 0},n===jr.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(d,{label:"Radiobutton 1",ref:a({required:g})}),r.createElement(d,{label:"Radiobutton 2",ref:a({required:g})}),r.createElement(d,{label:"Radiobutton 3",ref:a({required:g})})),r.createElement(c,{key:3,error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(v,{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"}})}))]:n===jr.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===jr.radiobutton?r.createElement(c,{name:"formgroup3",error:o.formgroup3?o.formgroup3.message:void 0},r.createElement(d,{name:"formgroup3",label:"Radiobutton 1",error:o.formgroup3,variant:e.variant,ref:a({required:g})})):n===jr.textarea?r.createElement(c,{error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(v,{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"}})})):void 0),r.createElement(f,null,"Submit"))}
|
|
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
|