@helsenorge/designsystem-react 1.0.0-beta123 → 1.0.0-beta124
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/{FormGroup-157f9e03.js → FormGroup-9c5e238e.js} +2 -2
- package/FormGroup-9c5e238e.js.map +1 -0
- package/FormLayout-26368f0a.js +2 -0
- package/FormLayout-26368f0a.js.map +1 -0
- package/Validation-e36cb0d8.js +2 -0
- package/Validation-e36cb0d8.js.map +1 -0
- package/components/Button/styles.module.scss +3 -1
- package/components/FormExample/index.js +1 -1
- package/components/FormGroup/index.js +1 -1
- package/components/FormLayout/FormLayout.d.ts.map +1 -1
- package/components/FormLayout/index.js +1 -1
- package/components/FormLayout/styles.module.scss +16 -11
- package/components/FormLayout/styles.module.scss.d.ts +5 -4
- package/components/StatusDot/index.js +1 -1
- package/components/Validation/index.js +1 -1
- package/package.json +1 -1
- package/FormGroup-157f9e03.js.map +0 -1
- package/FormLayout-a3d440c1.js +0 -2
- package/FormLayout-a3d440c1.js.map +0 -1
- package/Validation-5d79f53e.js +0 -2
- package/Validation-5d79f53e.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as e}from"./_rollupPluginBabelHelpers-4f206abf.js";import r from"react";import{c as a}from"./index-9b84fabc.js";import o from"./components/FormGroup/styles.module.scss";import{C as t}from"./Checkbox-1e2c2047.js";import{F as m,a as n,A as l}from"./constants-9528513d.js";import{R as i}from"./RadioButton-71099f5c.js";import{I as p}from"./Input-5bb47387.js";import{T as s}from"./Title-3a6d4597.js";import{F as f}from"./FormLayout-
|
|
2
|
-
//# sourceMappingURL=FormGroup-
|
|
1
|
+
import{d as e}from"./_rollupPluginBabelHelpers-4f206abf.js";import r from"react";import{c as a}from"./index-9b84fabc.js";import o from"./components/FormGroup/styles.module.scss";import{C as t}from"./Checkbox-1e2c2047.js";import{F as m,a as n,A as l}from"./constants-9528513d.js";import{R as i}from"./RadioButton-71099f5c.js";import{I as p}from"./Input-5bb47387.js";import{T as s}from"./Title-3a6d4597.js";import{F as f}from"./FormLayout-26368f0a.js";var d=r.forwardRef((function(d,u){var c,g,v,_=d.className,b=d.mode,w=void 0===b?m.onwhite:b,y=d.variant,E=void 0===y?n.normal:y,j=d.error,N=d.name,h=w===m.ondark,k=E===n.bigform,F=a(o["form-group-wrapper"],(e(c={},o["form-group-wrapper--on-dark"],h),e(c,o["form-group-wrapper--invalid"],j),c),_),x=a(o["form-group-wrapper__title"],(e(g={},o["form-group-wrapper__title--on-dark"],h&&!j),e(g,o["form-group-wrapper__title--bigform"],k),g)),B=a(o["form-group"],e({},o["form-group--invalid"],j)),C=a(o["form-group-wrapper__errors"],e({},o["form-group-wrapper__errors--bigform"],k)),I=a(o["field-set__legend"],(e(v={},o["field-set__legend--on-dark"],h&&!j),e(v,o["field-set__legend--bigform"],k),v));return r.createElement("div",{"data-testid":d.testId,"data-analyticsid":l.FormGroup,className:F},d.title&&r.createElement(s,{className:x,htmlMarkup:"h4",appearance:"title4",margin:{marginTop:0,marginBottom:2}},d.title),r.createElement("div",{className:B},j&&r.createElement("p",{className:C},j),r.createElement("fieldset",{name:d.title,className:o["field-set"]},d.legend&&r.createElement("legend",{className:I},d.legend),r.Children.map(d.children,(function e(a){if(a.type===f)return r.cloneElement(a,{variant:E,mapHelper:e});if(a.type===t){var o=a.type===t;return r.cloneElement(a,{name:null!=N?N:o.valueOf.name,mode:w,variant:E,error:!!j})}if(a.type===i){var m=a.type===i;return r.cloneElement(a,{name:null!=N?N:m.valueOf.name,mode:w,variant:E,error:!!j})}if(a.type===p){var n=a.type===p;return r.cloneElement(a,{name:null!=N?N:n.valueOf.name,mode:w,variant:E,error:!!j})}return a})))))}));export{d as F};
|
|
2
|
+
//# sourceMappingURL=FormGroup-9c5e238e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormGroup-9c5e238e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as o}from"./_rollupPluginBabelHelpers-4f206abf.js";import t from"react";import{c as r}from"./index-9b84fabc.js";import a from"./components/FormLayout/styles.module.scss";import{a as e,A as i}from"./constants-9528513d.js";var m;!function(o){o.one="one",o.two="two",o.three="three",o.four="four",o.five="five"}(m||(m={}));var l=t.forwardRef((function(l,n){var f,s=l.maxColumns,c=void 0===s?m.one:s,d=l.colMinWidth,u=void 0===d?300:d,h=l.variant,p=l.className,v=l.mapHelper,y={"--min-col-width":"".concat(u,"px")},b=r(a["form-layout-container"],o({},a["form-layout-container--bigform"],h===e.bigform),p),w=r(a["form-layout-child"],(o(f={},a["form-layout-child--two"],c===m.two),o(f,a["form-layout-child--three"],c===m.three),o(f,a["form-layout-child--four"],c===m.four),o(f,a["form-layout-child--five"],c===m.five),f));return t.createElement("div",{"data-testid":l.testId,"data-analyticsid":i.FormLayout,style:y,className:b},t.Children.map(l.children,(function(o){return t.createElement("div",{className:w},v?v(o):o)})))}));export{l as F,m as a};
|
|
2
|
+
//# sourceMappingURL=FormLayout-26368f0a.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLayout-26368f0a.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import r from"react";import{c as e}from"./index-9b84fabc.js";import{F as a}from"./FormGroup-9c5e238e.js";import t from"./components/Validation/styles.module.scss";import{A as o}from"./constants-9528513d.js";var s=r.forwardRef((function(s,m){var n=s.errorSummary,i=s.className,l=e(t.validation,i);return r.createElement(r.Fragment,null,r.createElement("div",{"data-testid":s.testId,"data-analyticsid":o.Validation,className:l},r.Children.map(s.children,(function(e){return e.type===a?r.cloneElement(e,{className:n?t["form-group-wrapper--error-sibling"]:""}):e}))),n&&r.createElement("p",{className:t.validation__errors},n))}));export{s as V};
|
|
2
|
+
//# sourceMappingURL=Validation-e36cb0d8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Validation-e36cb0d8.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -27,7 +27,8 @@ $invertedHoverColor: #ffffff0d; //$white + '0D';
|
|
|
27
27
|
font-size: 1.125rem;
|
|
28
28
|
font-family: inherit;
|
|
29
29
|
font-weight: 600;
|
|
30
|
-
display: inline-
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
align-items: center;
|
|
31
32
|
box-sizing: border-box;
|
|
32
33
|
text-decoration: none;
|
|
33
34
|
outline: none;
|
|
@@ -437,6 +438,7 @@ $invertedHoverColor: #ffffff0d; //$white + '0D';
|
|
|
437
438
|
|
|
438
439
|
#{$button}:disabled & {
|
|
439
440
|
border-bottom: none;
|
|
441
|
+
color: $neutral600;
|
|
440
442
|
}
|
|
441
443
|
}
|
|
442
444
|
|
|
@@ -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-5d79f53e.js";import{F as c}from"../../FormGroup-157f9e03.js";import{C as l}from"../../Checkbox-1e2c2047.js";import{B as f}from"../../Button-9f2ce63d.js";import{R as d}from"../../RadioButton-71099f5c.js";import{T as m}from"../../Textarea-e1e649cf.js";import{I as v}from"../../Input-5bb47387.js";import g from"../Icons/Hospital.js";import{F as p,a as b}from"../../FormLayout-a3d440c1.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../constants-9528513d.js";import"../../_rollupPluginBabelHelpers-4f206abf.js";import"../FormGroup/styles.module.scss";import"../../Title-3a6d4597.js";import"../Title/styles.module.scss";import"../../uuid-11037462.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../_tslib-51c8a283.js";import"../../color-e7d082c1.js";import"../../index-d1c9177a.js";import"../../palette-f206f488.js";import"../../grid-c105cad1.js";import"../Checkbox/styles.module.scss";import"../../Loader-670979af.js";import"../Loader/styles.module.scss";import"../../useHover-026f72c1.js";import"../../useWindowSize-5cc481da.js";import"../Button/styles.module.scss";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../../useBreakpoint-6eb418f7.js";import"../Input/styles.module.scss";import"../FormLayout/styles.module.scss";var h=function(r){return r instanceof HTMLElement},y="blur",j="change",O="input",k="onBlur",V="onChange",E="onSubmit",A="onTouched",x="all",w="max",S="min",D="maxLength",F="minLength",R="pattern",C="required",I="validate";var N=function(r){return null==r},B=function(r){return"object"==typeof r},L=function(r){return!N(r)&&!Array.isArray(r)&&B(r)&&!(r instanceof Date)},T=function(r){return/^\w*$/.test(r)},q=function(r){return r.filter(Boolean)},M=function(r){return q(r.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."))};function W(r,e,t){for(var n=-1,i=T(e)?[e]:M(e),a=i.length,u=a-1;++n<a;){var o=i[n],s=t;if(n!==u){var c=r[o];s=L(c)||Array.isArray(c)?c:isNaN(+i[n+1])?{}:[]}r[o]=s,r=r[o]}return r}var H=function(r,e){for(var t in void 0===e&&(e={}),r)T(t)?e[t]=r[t]:W(e,t,r[t]);return e},_=function(r){return void 0===r},P=function(r,e,t){void 0===r&&(r={});var n=q(e.split(/[,[\].]+?/)).reduce((function(r,e){return N(r)?r:r[e]}),r);return _(n)||n===r?_(r[e])?t:r[e]:n},z=function(r,e){h(r)&&r.removeEventListener&&(r.removeEventListener(O,e),r.removeEventListener(j,e),r.removeEventListener(y,e))},U={isValid:!1,value:null},$=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),U):U},G=function(r){return"radio"===r.type},J=function(r){return"file"===r.type},K=function(r){return"checkbox"===r.type},Q=function(r){return"select-multiple"===r.type},X={value:!1,isValid:!1},Y={value:!0,isValid:!0},Z=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&&!_(a.value)?_(i)||""===i?Y:{value:i,isValid:!0}:Y:X}return X};function rr(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,m=u.setValueAs;if(c&&n)return;return J(l)?l.files:G(l)?$(u.options).value:Q(l)?(a=l.options,[].concat(a).filter((function(r){return r.selected})).map((function(r){return r.value}))):K(l)?Z(u.options).value:i?s:f?""===s?NaN:+s:d?l.valueAsDate:m?m(s):s}if(t)return P(t.current,e)}function er(r){return!r||r instanceof HTMLElement&&r.nodeType!==Node.DOCUMENT_NODE&&er(r.parentNode)}var tr=function(r){return L(r)&&!Object.keys(r).length},nr=function(r){return"boolean"==typeof r};function ir(r,e){var t,n=T(e)?[e]:M(e),i=1==n.length?r:function(r,e){for(var t=e.slice(0,-1).length,n=0;n<t;)r=_(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&&(L(s)&&tr(s)||Array.isArray(s)&&!s.filter((function(r){return L(r)&&!tr(r)||nr(r)})).length)&&(t?delete t[f]:delete r[f]),t=s}}return r}var ar=function(r,e){return r&&r.ref===e};var ur=function(r){return N(r)||!B(r)};function or(r,e){if(ur(r)||ur(e))return e;for(var t in e){var n=r[t],i=e[t];try{r[t]=L(n)&&L(i)||Array.isArray(n)&&Array.isArray(i)?or(n,i):i}catch(r){}}return r}function sr(r,e,t){if(ur(r)||ur(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((L(c)||Array.isArray(c))&&(L(l)||Array.isArray(l))?!sr(c,l,t):c!==l)return!1}}}return!0}function cr(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]=[],cr(r[u][o],P(e[u]||{},o,[]),t[u][o],t[u],o)):sr(P(e[u]||{},o),r[u][o])?W(t[u]||{},o):t[u]=Object.assign(Object.assign({},t[u]),((a={})[o]=!0,a));n&&!t.length&&delete n[i]}return t}var lr=function(r){return"string"==typeof r},fr=function(r,e,t,n,i){var a={},u=function(e){(_(i)||(lr(i)?e.startsWith(i):Array.isArray(i)&&i.find((function(r){return e.startsWith(r)}))))&&(a[e]=rr(r,e,void 0,n))};for(var o in r.current)u(o);return t?H(a):or(e,H(a))},dr=function(r){return r instanceof RegExp},mr=function(r){return L(r)&&!dr(r)?r:{value:r,message:""}},vr=function(r){return"function"==typeof r},gr=function(r){return lr(r)||o(r)};function pr(r,e,t){if(void 0===t&&(t="validate"),gr(r)||nr(r)&&!r)return{type:t,message:gr(r)?r:"",ref:e}}var br=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,d=t.pattern,m=t.validate,v=i.name,g={},p=G(i),b=K(i),h=p||b,y=""===a,j=br.bind(null,v,e,g),O=function(r,e,t,n,a){void 0===n&&(n=D),void 0===a&&(a=F);var u=r?e:t;g[v]=Object.assign({type:r?n:a,message:u,ref:i},j(r?n:a,u))};if(o&&(!p&&!b&&(y||N(a))||nr(a)&&!a||b&&!Z(u).isValid||p&&!$(u).isValid)){var k=gr(o)?{value:!!o,message:o}:mr(o),V=k.value,E=k.message;if(V&&(g[v]=Object.assign({type:C,message:E,ref:h?((r.current[v].options||[])[0]||{}).ref:i},j(C,E)),!e))return g}if(!(N(l)&&N(f)||""===a)){var A,x,B=mr(f),T=mr(l);if(isNaN(a)){var q=i.valueAsDate||new Date(a);lr(B.value)&&(A=q>new Date(B.value)),lr(T.value)&&(x=q<new Date(T.value))}else{var M=i.valueAsNumber||parseFloat(a);N(B.value)||(A=M>B.value),N(T.value)||(x=M<T.value)}if((A||x)&&(O(!!A,B.message,T.message,w,S),!e))return g}if(lr(a)&&!y&&(s||c)){var W=mr(s),H=mr(c),_=!N(W.value)&&a.length>W.value,P=!N(H.value)&&a.length<H.value;if((_||P)&&(O(_,W.message,H.message),!e))return g}if(lr(a)&&d&&!y){var z=mr(d),U=z.value,J=z.message;if(dr(U)&&!U.test(a)&&(g[v]=Object.assign({type:R,message:J,ref:i},j(R,J)),!e))return g}if(m){var Q=rr(r,v,n,!1,!0),X=h&&u?u[0].ref:i;if(vr(m)){var Y=pr(await m(Q),X);if(Y&&(g[v]=Object.assign(Object.assign({},Y),j(I,Y.message)),!e))return g}else if(L(m)){for(var er={},ir=0,ar=Object.entries(m);ir<ar.length;ir+=1){var ur=ar[ir],or=ur[0],sr=ur[1];if(!tr(er)&&!e)break;var cr=pr(await sr(Q),X,or);cr&&(er=Object.assign(Object.assign({},cr),j(or,cr.message)),e&&(g[v]=er))}if(!tr(er)&&(g[v]=Object.assign({ref:X},er),!e))return g}}return g},yr=function(r,e,t){for(var n in void 0===t&&(t=[]),e){var i=r+(L(e)?"."+n:"["+n+"]");ur(e[n])?t.push(i):yr(i,e[n],t)}return t},jr=function(r,e,t,n,i){var a=void 0;return t.add(e),tr(r)||(a=P(r,e),(L(a)||Array.isArray(a))&&yr(e,a).forEach((function(r){return t.add(r)}))),_(a)?i?n:P(n,e):a},Or=function(r){return r.substring(0,r.indexOf("["))},kr=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 Er(r){var e,t;if(ur(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,Er(r.get(s)))}return t}for(var c in t=Array.isArray(r)?[]:{},r)t[c]=Er(r[c]);return t}var Ar,xr=function(r){return{isOnSubmit:!r||r===E,isOnBlur:r===k,isOnChange:r===V,isOnAll:r===x,isOnTouch:r===A}},wr=function(r){return G(r)||K(r)},Sr="undefined"==typeof window,Dr=Vr?"Proxy"in window:"undefined"!=typeof Proxy;function Fr(r){void 0===r&&(r={});var e=r.mode;void 0===e&&(e=E);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 d=r.shouldUnregister;void 0===d&&(d=!0);var m=r.criteriaMode,v=n({}),g=n({}),p=n({}),b=n(new Set),k=n({}),A=n({}),w=n({}),S=n({}),D=n(l),F=n(!1),R=n(!1),C=n(),I=n({}),B=n({}),M=n(c),U=n(s),$=n(new Set),X=n(xr(e)),Y=X.current,Z=Y.isOnSubmit,nr=Y.isOnTouch,dr=m===x,mr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!Z,errors:{}}),gr=mr[0],pr=mr[1],br=n({isDirty:!Dr,dirtyFields:!Dr,touched:!Dr||nr,isValidating:!Dr,isSubmitting:!Dr,isValid:!Dr}),Ar=n(gr),Fr=n(),Rr=n(xr(o)).current,Cr=Rr.isOnBlur,Ir=Rr.isOnChange;M.current=c,U.current=s,Ar.current=gr,I.current=d?{}:tr(I.current)?Er(l):I.current;var Nr=t((function(r){void 0===r&&(r={}),F.current||(Ar.current=Object.assign(Object.assign({},Ar.current),r),pr(Ar.current))}),[]),Br=function(){return br.current.isValidating&&Nr({isValidating:!0})},Lr=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=_(n),o=P(e,t);return u&&!!o||!u&&!sr(o,n,!0)||u&&P(a,t)&&!P(i,t)}({errors:Ar.current.errors,error:e,name:r,validFields:S.current,fieldsWithValidation:w.current}),u=P(Ar.current.errors,r);e?(ir(S.current,r),a=a||!u||!sr(u,e,!0),W(Ar.current.errors,r,e)):((P(w.current,r)||U.current)&&(W(S.current,r,!0),a=a||u),ir(Ar.current.errors,r)),(a&&!N(t)||!tr(n)||br.current.isValidating)&&Nr(Object.assign(Object.assign(Object.assign({},n),U.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Tr=t((function(r,e){var t=v.current[r],n=t.ref,i=t.options,a=Vr&&h(n)&&N(e)?"":e;G(n)?(i||[]).forEach((function(r){var e=r.ref;return e.checked=e.value===a})):J(n)&&!lr(a)?n.files=a:Q(n)?[].concat(n.options).forEach((function(r){return r.selected=a.includes(r.value)})):K(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}),[]),qr=t((function(r,e){if(br.current.isDirty){var t=Jr();return r&&e&&W(t,r,e),!sr(t,D.current)}return!1}),[]),Mr=t((function(r,e){if(void 0===e&&(e=!0),br.current.isDirty||br.current.dirtyFields){var t=!sr(P(D.current,r),rr(v,r,I)),n=P(Ar.current.dirtyFields,r),i=Ar.current.isDirty;t?W(Ar.current.dirtyFields,r,!0):ir(Ar.current.dirtyFields,r);var a={isDirty:qr(),dirtyFields:Ar.current.dirtyFields},u=br.current.isDirty&&i!==a.isDirty||br.current.dirtyFields&&n!==P(Ar.current.dirtyFields,r);return u&&e&&Nr(a),u?a:{}}return{}}),[]),Wr=t((async function(r,e){if("production"!==process.env.NODE_ENV&&!v.current[r])return console.warn("📋 Field is missing with `name` attribute: ",r),!1;var t=(await hr(v,dr,v.current[r],I))[r];return Lr(r,t,e),_(t)}),[Lr,dr]),Hr=t((async function(r){var e=(await U.current(Jr(),M.current,dr)).errors,t=Ar.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=P(e,r);return t?W(Ar.current.errors,r,t):ir(Ar.current.errors,r),!t})).every(Boolean);return Nr({isValid:tr(e),isValidating:!1}),n}var i=P(e,r);return Lr(r,i,t!==tr(e),{},tr(e)),!i}),[Lr,dr]),_r=t((async function(r){var e=r||Object.keys(v.current);if(Br(),U.current)return Hr(e);if(Array.isArray(e)){!r&&(Ar.current.errors={});var t=await Promise.all(e.map((async function(r){return await Wr(r,null)})));return Nr({isValidating:!1}),t.every(Boolean)}return await Wr(e)}),[Hr,Wr]),Pr=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,a={};W(a,r,e);for(var u=0,o=yr(r,e);u<o.length;u+=1){var s=o[u];v.current[s]&&(Tr(s,P(a,s)),n&&Mr(s),i&&_r(s))}}),[_r,Tr,Mr]),zr=t((function(r,e,t){var n,i;if(!d&&!ur(e)&&W(I.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),v.current[r])Tr(r,e),t.shouldDirty&&Mr(r),t.shouldValidate&&_r(r);else if(!ur(e)&&(Pr(r,e,t),$.current.has(r))){var a=Or(r)||r;W(g.current,r,e),B.current[a](((n={})[a]=P(g.current,a),n)),(br.current.isDirty||br.current.dirtyFields)&&t.shouldDirty&&(W(Ar.current.dirtyFields,r,function(r,e,t){return or(cr(r,e,t.slice(0,r.length)),cr(e,r,t.slice(0,r.length)))}(e,P(D.current,r,[]),P(Ar.current.dirtyFields,r,[]))),Nr({isDirty:!sr(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),D.current)}))}!d&&W(I.current,r,e)}),[Mr,Tr,Pr]),Ur=function(r){return R.current||b.current.has(r)||b.current.has((r.match(/\w+/)||[])[0])},$r=function(r){var e=!0;if(!tr(k.current))for(var t in k.current)r&&k.current[t].size&&!k.current[t].has(r)&&!k.current[t].has(Or(r))||(A.current[t](),e=!1);return e};function Gr(r){var e;if(!d){for(var t=Er(r),n=0,i=$.current;n<i.length;n+=1){var a=i[n];T(a)&&!t[a]&&(t=Object.assign(Object.assign({},t),((e={})[a]=[],e)))}return t}return r}function Jr(r){if(lr(r))return rr(v,r,I);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];W(e,i,rr(v,i,I))}return e}return Gr(fr(v,Er(I.current),d))}C.current=C.current?C.current:async function(r){var e,t,n=r.type,i=r.target,a=i.name,u=v.current[a];if(u){var o=n===y,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:Ir,isReValidateOnBlur:Cr,isTouched:!!P(Ar.current.touched,a),isSubmitted:Ar.current.isSubmitted},X.current)),c=Mr(a,!1),l=!tr(c)||!o&&Ur(a);if(o&&!P(Ar.current.touched,a)&&br.current.touched&&(W(Ar.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:Ar.current.touched})),!d&&K(i)&&W(I.current,a,rr(v,a)),s)return!o&&$r(a),(!tr(c)||l&&tr(c))&&Nr(c);if(Br(),U.current){var f=(await U.current(Jr(),M.current,dr)).errors,m=Ar.current.isValid;if(e=P(f,a),K(i)&&!e&&U.current){var g=Or(a),p=P(f,g,{});p.type&&p.message&&(e=p),g&&(p||P(Ar.current.errors,g))&&(a=g)}m!==(t=tr(f))&&(l=!0)}else e=(await hr(v,dr,u,I))[a];!o&&$r(a),Lr(a,e,l,c,t)}};var Kr=t((async function(r){void 0===r&&(r={});var e=tr(v.current)?D.current:{},t=(await U.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),M.current,dr)||{}).errors,n=tr(t);Ar.current.isValid!==n&&Nr({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=rr(r,o,n);!_(c)&&W(n.current,o,c)}u.type&&s?G(u)||K(u)?Array.isArray(s.options)&&s.options.length?(q(s.options).forEach((function(r,t){void 0===r&&(r={}),(er(r.ref)&&ar(r,r.ref)||a)&&(z(r.ref,e),ir(s.options,"["+t+"]"))})),s.options&&!q(s.options).length&&delete r.current[o]):delete r.current[o]:(er(u)&&ar(s,u)||a)&&(z(u,e),delete r.current[o]):delete r.current[o]}(v,C.current,r,I,d,e),d&&(ir(S.current,r.ref.name),ir(w.current,r.ref.name))}),[d]),Xr=t((function(r){if(R.current)Nr();else{for(var e=0,t=b.current;e<t.length;e+=1){if(t[e].startsWith(r)){Nr();break}}$r(r)}}),[]),Yr=t((function(r,e){r&&(Qr(r,e),d&&!q(r.options||[]).length&&(ir(Ar.current.errors,r.ref.name),W(Ar.current.dirtyFields,r.ref.name,!0),Nr({isDirty:qr()}),br.current.isValid&&U.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?k.current[t]:b.current,i=fr(v,Er(I.current),d,!1,r);if(lr(r)){var a=Or(r)||r;return $.current.has(a)&&(i=Object.assign(Object.assign({},p.current),i)),jr(i,r,n,_(P(D.current,r))?e:P(D.current,r),!0)}var u=_(e)?D.current:e;return Array.isArray(r)?r.reduce((function(r,e){var t;return Object.assign(Object.assign({},r),((t={})[e]=jr(i,e,n,u),t))}),{}):(R.current=_(t),H(!tr(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($.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=v.current,s=wr(r),c=kr($.current,n),l=function(e){return Vr&&(!h(r)||e===r)},f=o[n],m=!0;if(f&&(s?Array.isArray(f.options)&&q(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:q(f&&f.options||[]).concat([{ref:r}]),ref:{type:i,name:n}},e):Object.assign({},u):u,o[n]=f;var g=_(P(I.current,n));tr(D.current)&&g||(t=P(g?D.current:I.current,n),(m=_(t))||c||Tr(n,t)),tr(e)||(W(w.current,n,!0),!Z&&br.current.isValid&&hr(v,dr,f,I).then((function(r){var e=Ar.current.isValid;tr(r)?W(S.current,n,!0):ir(S.current,n),e!==tr(r)&&Nr()}))),!d||c&&m||!c&&ir(Ar.current.dirtyFields,n),i&&function(r,e,t){var n=r.ref;h(n)&&t&&(n.addEventListener(e?j:O,t),n.addEventListener(y,t))}(s&&f.options?f.options[f.options.length-1]:f,s||"select-one"===r.type,C.current)}}var ee=t((function(r,e){return async function(t){t&&t.preventDefault&&(t.preventDefault(),t.persist());var n={},i=Gr(fr(v,Er(I.current),d,!0));br.current.isSubmitting&&Nr({isSubmitting:!0});try{if(U.current){var a=await U.current(i,M.current,dr),u=a.errors,o=a.values;Ar.current.errors=n=u,i=o}else for(var s=0,c=Object.values(v.current);s<c.length;s+=1){var l=c[s];if(l){var m=l.ref.name,g=await hr(v,dr,l,I);g[m]?(W(n,m,g[m]),ir(S.current,m)):P(w.current,m)&&(ir(Ar.current.errors,m),W(S.current,m,!0))}}tr(n)&&Object.keys(Ar.current.errors).every((function(r){return r in v.current}))?(Nr({errors:{},isSubmitting:!0}),await r(i,t)):(Ar.current.errors=Object.assign(Object.assign({},Ar.current.errors),n),e&&await e(Ar.current.errors,t),f&&function(r,e){for(var t in r)if(P(e,t)){var n=r[t];if(n){if(n.ref.focus&&_(n.ref.focus()))break;if(n.options){n.options[0].ref.focus();break}}}}(v.current,Ar.current.errors))}finally{Ar.current.isSubmitting=!1,Nr({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:tr(Ar.current.errors),submitCount:Ar.current.submitCount+1})}}}),[f,dr]);a((function(){s&&br.current.isValid&&Kr(),Fr.current=Fr.current||!Vr?Fr.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&&er(o.ref)&&e(i)}else i&&er(i.ref)&&e(i)}}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(v,Yr)}),[Yr,D.current]),a((function(){return function(){Fr.current&&Fr.current.disconnect(),F.current=!0,"production"===process.env.NODE_ENV&&Object.values(v.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!s&&br.current.isValid&&(gr.isValid=sr(S.current,w.current)&&tr(Ar.current.errors));var te={trigger:_r,setValue:t((function(r,e,t){zr(r,e,t||{}),Ur(r)&&Nr(),$r(r)}),[zr,_r]),getValues:t(Jr,[]),register:t((function(r,e){if(!Sr)if(lr(r))re({name:r},e);else{if(!L(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(v.current[n],!0)}}),[]),formState:Dr?new Proxy(gr,{get:function(r,e){if("production"!==process.env.NODE_ENV&&"isValid"===e&&Z&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),e in r)return br.current[e]=!0,r[e]}}):gr},ne=u((function(){return Object.assign({isFormDirty:qr,updateWatchedValue:Xr,shouldUnregister:d,updateFormState:Nr,removeFieldEventListener:Qr,watchInternal:Zr,mode:X.current,reValidateMode:{isReValidateOnBlur:Cr,isReValidateOnChange:Ir},validateResolver:s?Kr:void 0,fieldsRef:v,resetFieldArrayFunctionRef:B,useWatchFieldsRef:k,useWatchRenderFunctionsRef:A,fieldArrayDefaultValuesRef:g,validFieldsRef:S,fieldsWithValidationRef:w,fieldArrayNamesRef:$,readFormStateRef:br,formStateRef:Ar,defaultValuesRef:D,shallowFieldsStateRef:I,fieldArrayValuesRef:p},te)}),[D.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={}),Vr)for(var t=0,n=Object.values(v.current);t<n.length;t+=1){var i=n[t];if(i){var a=i.ref,u=i.options,o=wr(a)&&Array.isArray(u)?u[0].ref:a;if(h(o))try{o.closest("form").reset();break}catch(r){}}}v.current={},D.current=Object.assign({},r||D.current),r&&$r(""),Object.values(B.current).forEach((function(r){return vr(r)&&r()})),I.current=d?{}:Er(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||(S.current={},w.current={}),g.current={},b.current=new Set,R.current=!1,Nr({submitCount:u?Ar.current.submitCount:0,isDirty:!!t&&Ar.current.isDirty,isSubmitted:!!n&&Ar.current.isSubmitted,isValid:!!a&&Ar.current.isValid,dirtyFields:o?Ar.current.dirtyFields:{},touched:i?Ar.current.touched:{},errors:e?Ar.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})}(e)}),[]),clearErrors:t((function(r){r&&(Array.isArray(r)?r:[r]).forEach((function(r){return v.current[r]&&T(r)?delete Ar.current.errors[r]:ir(Ar.current.errors,r)})),Nr({errors:r?Ar.current.errors:{}})}),[]),setError:t((function(r,e){var t=(v.current[r]||{}).ref;W(Ar.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Nr({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:gr.errors},te)}e(null).displayName="RHFContext",function(r){r.formgroup="formgroup",r.checkbox="checkbox",r.radiobutton="radiobutton",r.textarea="textarea",r.input="input"}(Ar||(Ar={}));var Rr=function(e){var t=e.exampleType,n=void 0===t?Ar.formgroup:t,i=Fr(),a=i.register,u=i.handleSubmit,o=i.errors,h=o.formgroup1||o.formgroup2||o.formgroup3||o.formgroup4||o.formgroup5,y="Du må velge et alternativ",j=[r.createElement(l,{key:0,inputId:"checkbox1",label:"Checkbox 1",ref:a({required:y})}),r.createElement(l,{key:1,inputId:"checkbox2",label:"Checkbox 2",ref:a({required:y})}),r.createElement(l,{key:2,inputId:"checkbox3",label:"Checkbox 3",ref:a({required:y})})],O=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===Ar.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(p,{maxColumns:b.two},j.map((function(r){return r})))),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,{inputId:"checkbox4",label:"Checkbox 4",ref:a({validate:O})}),r.createElement(l,{inputId:"checkbox5",label:"Checkbox 5",ref:a({validate:O})}),r.createElement(l,{inputId:"checkbox6",label:"Checkbox 6",ref:a({validate:O})})),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,{inputId:"radiobutton1",label:"Radiobutton 1",ref:a({required:y})}),r.createElement(d,{inputId:"radiobutton2",label:"Radiobutton 2",ref:a({required:y})}),r.createElement(d,{inputId:"radiobutton3",label:"Radiobutton 3",ref:a({required:y})})),r.createElement(c,{key:3,error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(m,{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",textareaId:"textarea1",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(v,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:g,ref:a({required:"Du må skrive noe her"})}))]:n===Ar.checkbox?r.createElement(c,{name:"formgroup1",error:o.formgroup1?o.formgroup1.message:void 0},r.createElement(l,{name:"formgroup1",inputId:"checkbox1",label:"Checkbox 1",error:o.formgroup1,variant:e.variant,ref:a({required:y})})):n===Ar.radiobutton?r.createElement(c,{name:"formgroup3",error:o.formgroup3?o.formgroup3.message:void 0},r.createElement(d,{name:"formgroup3",inputId:"radiobutton1",label:"Radiobutton 1",error:o.formgroup3,variant:e.variant,ref:a({required:y})})):n===Ar.textarea?r.createElement(c,{error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(m,{defaultValue:"Dette er min historie \n\n Hello \n\n test",grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})):n===Ar.input?r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(v,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:g,ref:a({required:"Du må skrive noe her"})})):void 0),r.createElement(f,{type:"submit"},"Submit"))};export default Rr;export{Rr as FormExample,Ar as FormExampleVariants};
|
|
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-e36cb0d8.js";import{F as c}from"../../FormGroup-9c5e238e.js";import{C as l}from"../../Checkbox-1e2c2047.js";import{B as f}from"../../Button-9f2ce63d.js";import{R as d}from"../../RadioButton-71099f5c.js";import{T as m}from"../../Textarea-e1e649cf.js";import{I as v}from"../../Input-5bb47387.js";import g from"../Icons/Hospital.js";import{F as p,a as b}from"../../FormLayout-26368f0a.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../constants-9528513d.js";import"../../_rollupPluginBabelHelpers-4f206abf.js";import"../FormGroup/styles.module.scss";import"../../Title-3a6d4597.js";import"../Title/styles.module.scss";import"../../uuid-11037462.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../_tslib-51c8a283.js";import"../../color-e7d082c1.js";import"../../index-d1c9177a.js";import"../../palette-f206f488.js";import"../../grid-c105cad1.js";import"../Checkbox/styles.module.scss";import"../../Loader-670979af.js";import"../Loader/styles.module.scss";import"../../useHover-026f72c1.js";import"../../useWindowSize-5cc481da.js";import"../Button/styles.module.scss";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../../useBreakpoint-6eb418f7.js";import"../Input/styles.module.scss";import"../FormLayout/styles.module.scss";var h=function(r){return r instanceof HTMLElement},y="blur",j="change",O="input",k="onBlur",V="onChange",E="onSubmit",A="onTouched",x="all",w="max",S="min",D="maxLength",F="minLength",R="pattern",C="required",I="validate";var N=function(r){return null==r},B=function(r){return"object"==typeof r},L=function(r){return!N(r)&&!Array.isArray(r)&&B(r)&&!(r instanceof Date)},T=function(r){return/^\w*$/.test(r)},q=function(r){return r.filter(Boolean)},M=function(r){return q(r.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."))};function W(r,e,t){for(var n=-1,i=T(e)?[e]:M(e),a=i.length,u=a-1;++n<a;){var o=i[n],s=t;if(n!==u){var c=r[o];s=L(c)||Array.isArray(c)?c:isNaN(+i[n+1])?{}:[]}r[o]=s,r=r[o]}return r}var H=function(r,e){for(var t in void 0===e&&(e={}),r)T(t)?e[t]=r[t]:W(e,t,r[t]);return e},_=function(r){return void 0===r},P=function(r,e,t){void 0===r&&(r={});var n=q(e.split(/[,[\].]+?/)).reduce((function(r,e){return N(r)?r:r[e]}),r);return _(n)||n===r?_(r[e])?t:r[e]:n},z=function(r,e){h(r)&&r.removeEventListener&&(r.removeEventListener(O,e),r.removeEventListener(j,e),r.removeEventListener(y,e))},U={isValid:!1,value:null},$=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),U):U},G=function(r){return"radio"===r.type},J=function(r){return"file"===r.type},K=function(r){return"checkbox"===r.type},Q=function(r){return"select-multiple"===r.type},X={value:!1,isValid:!1},Y={value:!0,isValid:!0},Z=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&&!_(a.value)?_(i)||""===i?Y:{value:i,isValid:!0}:Y:X}return X};function rr(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,m=u.setValueAs;if(c&&n)return;return J(l)?l.files:G(l)?$(u.options).value:Q(l)?(a=l.options,[].concat(a).filter((function(r){return r.selected})).map((function(r){return r.value}))):K(l)?Z(u.options).value:i?s:f?""===s?NaN:+s:d?l.valueAsDate:m?m(s):s}if(t)return P(t.current,e)}function er(r){return!r||r instanceof HTMLElement&&r.nodeType!==Node.DOCUMENT_NODE&&er(r.parentNode)}var tr=function(r){return L(r)&&!Object.keys(r).length},nr=function(r){return"boolean"==typeof r};function ir(r,e){var t,n=T(e)?[e]:M(e),i=1==n.length?r:function(r,e){for(var t=e.slice(0,-1).length,n=0;n<t;)r=_(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&&(L(s)&&tr(s)||Array.isArray(s)&&!s.filter((function(r){return L(r)&&!tr(r)||nr(r)})).length)&&(t?delete t[f]:delete r[f]),t=s}}return r}var ar=function(r,e){return r&&r.ref===e};var ur=function(r){return N(r)||!B(r)};function or(r,e){if(ur(r)||ur(e))return e;for(var t in e){var n=r[t],i=e[t];try{r[t]=L(n)&&L(i)||Array.isArray(n)&&Array.isArray(i)?or(n,i):i}catch(r){}}return r}function sr(r,e,t){if(ur(r)||ur(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((L(c)||Array.isArray(c))&&(L(l)||Array.isArray(l))?!sr(c,l,t):c!==l)return!1}}}return!0}function cr(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]=[],cr(r[u][o],P(e[u]||{},o,[]),t[u][o],t[u],o)):sr(P(e[u]||{},o),r[u][o])?W(t[u]||{},o):t[u]=Object.assign(Object.assign({},t[u]),((a={})[o]=!0,a));n&&!t.length&&delete n[i]}return t}var lr=function(r){return"string"==typeof r},fr=function(r,e,t,n,i){var a={},u=function(e){(_(i)||(lr(i)?e.startsWith(i):Array.isArray(i)&&i.find((function(r){return e.startsWith(r)}))))&&(a[e]=rr(r,e,void 0,n))};for(var o in r.current)u(o);return t?H(a):or(e,H(a))},dr=function(r){return r instanceof RegExp},mr=function(r){return L(r)&&!dr(r)?r:{value:r,message:""}},vr=function(r){return"function"==typeof r},gr=function(r){return lr(r)||o(r)};function pr(r,e,t){if(void 0===t&&(t="validate"),gr(r)||nr(r)&&!r)return{type:t,message:gr(r)?r:"",ref:e}}var br=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,d=t.pattern,m=t.validate,v=i.name,g={},p=G(i),b=K(i),h=p||b,y=""===a,j=br.bind(null,v,e,g),O=function(r,e,t,n,a){void 0===n&&(n=D),void 0===a&&(a=F);var u=r?e:t;g[v]=Object.assign({type:r?n:a,message:u,ref:i},j(r?n:a,u))};if(o&&(!p&&!b&&(y||N(a))||nr(a)&&!a||b&&!Z(u).isValid||p&&!$(u).isValid)){var k=gr(o)?{value:!!o,message:o}:mr(o),V=k.value,E=k.message;if(V&&(g[v]=Object.assign({type:C,message:E,ref:h?((r.current[v].options||[])[0]||{}).ref:i},j(C,E)),!e))return g}if(!(N(l)&&N(f)||""===a)){var A,x,B=mr(f),T=mr(l);if(isNaN(a)){var q=i.valueAsDate||new Date(a);lr(B.value)&&(A=q>new Date(B.value)),lr(T.value)&&(x=q<new Date(T.value))}else{var M=i.valueAsNumber||parseFloat(a);N(B.value)||(A=M>B.value),N(T.value)||(x=M<T.value)}if((A||x)&&(O(!!A,B.message,T.message,w,S),!e))return g}if(lr(a)&&!y&&(s||c)){var W=mr(s),H=mr(c),_=!N(W.value)&&a.length>W.value,P=!N(H.value)&&a.length<H.value;if((_||P)&&(O(_,W.message,H.message),!e))return g}if(lr(a)&&d&&!y){var z=mr(d),U=z.value,J=z.message;if(dr(U)&&!U.test(a)&&(g[v]=Object.assign({type:R,message:J,ref:i},j(R,J)),!e))return g}if(m){var Q=rr(r,v,n,!1,!0),X=h&&u?u[0].ref:i;if(vr(m)){var Y=pr(await m(Q),X);if(Y&&(g[v]=Object.assign(Object.assign({},Y),j(I,Y.message)),!e))return g}else if(L(m)){for(var er={},ir=0,ar=Object.entries(m);ir<ar.length;ir+=1){var ur=ar[ir],or=ur[0],sr=ur[1];if(!tr(er)&&!e)break;var cr=pr(await sr(Q),X,or);cr&&(er=Object.assign(Object.assign({},cr),j(or,cr.message)),e&&(g[v]=er))}if(!tr(er)&&(g[v]=Object.assign({ref:X},er),!e))return g}}return g},yr=function(r,e,t){for(var n in void 0===t&&(t=[]),e){var i=r+(L(e)?"."+n:"["+n+"]");ur(e[n])?t.push(i):yr(i,e[n],t)}return t},jr=function(r,e,t,n,i){var a=void 0;return t.add(e),tr(r)||(a=P(r,e),(L(a)||Array.isArray(a))&&yr(e,a).forEach((function(r){return t.add(r)}))),_(a)?i?n:P(n,e):a},Or=function(r){return r.substring(0,r.indexOf("["))},kr=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 Er(r){var e,t;if(ur(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,Er(r.get(s)))}return t}for(var c in t=Array.isArray(r)?[]:{},r)t[c]=Er(r[c]);return t}var Ar,xr=function(r){return{isOnSubmit:!r||r===E,isOnBlur:r===k,isOnChange:r===V,isOnAll:r===x,isOnTouch:r===A}},wr=function(r){return G(r)||K(r)},Sr="undefined"==typeof window,Dr=Vr?"Proxy"in window:"undefined"!=typeof Proxy;function Fr(r){void 0===r&&(r={});var e=r.mode;void 0===e&&(e=E);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 d=r.shouldUnregister;void 0===d&&(d=!0);var m=r.criteriaMode,v=n({}),g=n({}),p=n({}),b=n(new Set),k=n({}),A=n({}),w=n({}),S=n({}),D=n(l),F=n(!1),R=n(!1),C=n(),I=n({}),B=n({}),M=n(c),U=n(s),$=n(new Set),X=n(xr(e)),Y=X.current,Z=Y.isOnSubmit,nr=Y.isOnTouch,dr=m===x,mr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!Z,errors:{}}),gr=mr[0],pr=mr[1],br=n({isDirty:!Dr,dirtyFields:!Dr,touched:!Dr||nr,isValidating:!Dr,isSubmitting:!Dr,isValid:!Dr}),Ar=n(gr),Fr=n(),Rr=n(xr(o)).current,Cr=Rr.isOnBlur,Ir=Rr.isOnChange;M.current=c,U.current=s,Ar.current=gr,I.current=d?{}:tr(I.current)?Er(l):I.current;var Nr=t((function(r){void 0===r&&(r={}),F.current||(Ar.current=Object.assign(Object.assign({},Ar.current),r),pr(Ar.current))}),[]),Br=function(){return br.current.isValidating&&Nr({isValidating:!0})},Lr=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=_(n),o=P(e,t);return u&&!!o||!u&&!sr(o,n,!0)||u&&P(a,t)&&!P(i,t)}({errors:Ar.current.errors,error:e,name:r,validFields:S.current,fieldsWithValidation:w.current}),u=P(Ar.current.errors,r);e?(ir(S.current,r),a=a||!u||!sr(u,e,!0),W(Ar.current.errors,r,e)):((P(w.current,r)||U.current)&&(W(S.current,r,!0),a=a||u),ir(Ar.current.errors,r)),(a&&!N(t)||!tr(n)||br.current.isValidating)&&Nr(Object.assign(Object.assign(Object.assign({},n),U.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Tr=t((function(r,e){var t=v.current[r],n=t.ref,i=t.options,a=Vr&&h(n)&&N(e)?"":e;G(n)?(i||[]).forEach((function(r){var e=r.ref;return e.checked=e.value===a})):J(n)&&!lr(a)?n.files=a:Q(n)?[].concat(n.options).forEach((function(r){return r.selected=a.includes(r.value)})):K(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}),[]),qr=t((function(r,e){if(br.current.isDirty){var t=Jr();return r&&e&&W(t,r,e),!sr(t,D.current)}return!1}),[]),Mr=t((function(r,e){if(void 0===e&&(e=!0),br.current.isDirty||br.current.dirtyFields){var t=!sr(P(D.current,r),rr(v,r,I)),n=P(Ar.current.dirtyFields,r),i=Ar.current.isDirty;t?W(Ar.current.dirtyFields,r,!0):ir(Ar.current.dirtyFields,r);var a={isDirty:qr(),dirtyFields:Ar.current.dirtyFields},u=br.current.isDirty&&i!==a.isDirty||br.current.dirtyFields&&n!==P(Ar.current.dirtyFields,r);return u&&e&&Nr(a),u?a:{}}return{}}),[]),Wr=t((async function(r,e){if("production"!==process.env.NODE_ENV&&!v.current[r])return console.warn("📋 Field is missing with `name` attribute: ",r),!1;var t=(await hr(v,dr,v.current[r],I))[r];return Lr(r,t,e),_(t)}),[Lr,dr]),Hr=t((async function(r){var e=(await U.current(Jr(),M.current,dr)).errors,t=Ar.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=P(e,r);return t?W(Ar.current.errors,r,t):ir(Ar.current.errors,r),!t})).every(Boolean);return Nr({isValid:tr(e),isValidating:!1}),n}var i=P(e,r);return Lr(r,i,t!==tr(e),{},tr(e)),!i}),[Lr,dr]),_r=t((async function(r){var e=r||Object.keys(v.current);if(Br(),U.current)return Hr(e);if(Array.isArray(e)){!r&&(Ar.current.errors={});var t=await Promise.all(e.map((async function(r){return await Wr(r,null)})));return Nr({isValidating:!1}),t.every(Boolean)}return await Wr(e)}),[Hr,Wr]),Pr=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,a={};W(a,r,e);for(var u=0,o=yr(r,e);u<o.length;u+=1){var s=o[u];v.current[s]&&(Tr(s,P(a,s)),n&&Mr(s),i&&_r(s))}}),[_r,Tr,Mr]),zr=t((function(r,e,t){var n,i;if(!d&&!ur(e)&&W(I.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),v.current[r])Tr(r,e),t.shouldDirty&&Mr(r),t.shouldValidate&&_r(r);else if(!ur(e)&&(Pr(r,e,t),$.current.has(r))){var a=Or(r)||r;W(g.current,r,e),B.current[a](((n={})[a]=P(g.current,a),n)),(br.current.isDirty||br.current.dirtyFields)&&t.shouldDirty&&(W(Ar.current.dirtyFields,r,function(r,e,t){return or(cr(r,e,t.slice(0,r.length)),cr(e,r,t.slice(0,r.length)))}(e,P(D.current,r,[]),P(Ar.current.dirtyFields,r,[]))),Nr({isDirty:!sr(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),D.current)}))}!d&&W(I.current,r,e)}),[Mr,Tr,Pr]),Ur=function(r){return R.current||b.current.has(r)||b.current.has((r.match(/\w+/)||[])[0])},$r=function(r){var e=!0;if(!tr(k.current))for(var t in k.current)r&&k.current[t].size&&!k.current[t].has(r)&&!k.current[t].has(Or(r))||(A.current[t](),e=!1);return e};function Gr(r){var e;if(!d){for(var t=Er(r),n=0,i=$.current;n<i.length;n+=1){var a=i[n];T(a)&&!t[a]&&(t=Object.assign(Object.assign({},t),((e={})[a]=[],e)))}return t}return r}function Jr(r){if(lr(r))return rr(v,r,I);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];W(e,i,rr(v,i,I))}return e}return Gr(fr(v,Er(I.current),d))}C.current=C.current?C.current:async function(r){var e,t,n=r.type,i=r.target,a=i.name,u=v.current[a];if(u){var o=n===y,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:Ir,isReValidateOnBlur:Cr,isTouched:!!P(Ar.current.touched,a),isSubmitted:Ar.current.isSubmitted},X.current)),c=Mr(a,!1),l=!tr(c)||!o&&Ur(a);if(o&&!P(Ar.current.touched,a)&&br.current.touched&&(W(Ar.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:Ar.current.touched})),!d&&K(i)&&W(I.current,a,rr(v,a)),s)return!o&&$r(a),(!tr(c)||l&&tr(c))&&Nr(c);if(Br(),U.current){var f=(await U.current(Jr(),M.current,dr)).errors,m=Ar.current.isValid;if(e=P(f,a),K(i)&&!e&&U.current){var g=Or(a),p=P(f,g,{});p.type&&p.message&&(e=p),g&&(p||P(Ar.current.errors,g))&&(a=g)}m!==(t=tr(f))&&(l=!0)}else e=(await hr(v,dr,u,I))[a];!o&&$r(a),Lr(a,e,l,c,t)}};var Kr=t((async function(r){void 0===r&&(r={});var e=tr(v.current)?D.current:{},t=(await U.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),M.current,dr)||{}).errors,n=tr(t);Ar.current.isValid!==n&&Nr({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=rr(r,o,n);!_(c)&&W(n.current,o,c)}u.type&&s?G(u)||K(u)?Array.isArray(s.options)&&s.options.length?(q(s.options).forEach((function(r,t){void 0===r&&(r={}),(er(r.ref)&&ar(r,r.ref)||a)&&(z(r.ref,e),ir(s.options,"["+t+"]"))})),s.options&&!q(s.options).length&&delete r.current[o]):delete r.current[o]:(er(u)&&ar(s,u)||a)&&(z(u,e),delete r.current[o]):delete r.current[o]}(v,C.current,r,I,d,e),d&&(ir(S.current,r.ref.name),ir(w.current,r.ref.name))}),[d]),Xr=t((function(r){if(R.current)Nr();else{for(var e=0,t=b.current;e<t.length;e+=1){if(t[e].startsWith(r)){Nr();break}}$r(r)}}),[]),Yr=t((function(r,e){r&&(Qr(r,e),d&&!q(r.options||[]).length&&(ir(Ar.current.errors,r.ref.name),W(Ar.current.dirtyFields,r.ref.name,!0),Nr({isDirty:qr()}),br.current.isValid&&U.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?k.current[t]:b.current,i=fr(v,Er(I.current),d,!1,r);if(lr(r)){var a=Or(r)||r;return $.current.has(a)&&(i=Object.assign(Object.assign({},p.current),i)),jr(i,r,n,_(P(D.current,r))?e:P(D.current,r),!0)}var u=_(e)?D.current:e;return Array.isArray(r)?r.reduce((function(r,e){var t;return Object.assign(Object.assign({},r),((t={})[e]=jr(i,e,n,u),t))}),{}):(R.current=_(t),H(!tr(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($.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=v.current,s=wr(r),c=kr($.current,n),l=function(e){return Vr&&(!h(r)||e===r)},f=o[n],m=!0;if(f&&(s?Array.isArray(f.options)&&q(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:q(f&&f.options||[]).concat([{ref:r}]),ref:{type:i,name:n}},e):Object.assign({},u):u,o[n]=f;var g=_(P(I.current,n));tr(D.current)&&g||(t=P(g?D.current:I.current,n),(m=_(t))||c||Tr(n,t)),tr(e)||(W(w.current,n,!0),!Z&&br.current.isValid&&hr(v,dr,f,I).then((function(r){var e=Ar.current.isValid;tr(r)?W(S.current,n,!0):ir(S.current,n),e!==tr(r)&&Nr()}))),!d||c&&m||!c&&ir(Ar.current.dirtyFields,n),i&&function(r,e,t){var n=r.ref;h(n)&&t&&(n.addEventListener(e?j:O,t),n.addEventListener(y,t))}(s&&f.options?f.options[f.options.length-1]:f,s||"select-one"===r.type,C.current)}}var ee=t((function(r,e){return async function(t){t&&t.preventDefault&&(t.preventDefault(),t.persist());var n={},i=Gr(fr(v,Er(I.current),d,!0));br.current.isSubmitting&&Nr({isSubmitting:!0});try{if(U.current){var a=await U.current(i,M.current,dr),u=a.errors,o=a.values;Ar.current.errors=n=u,i=o}else for(var s=0,c=Object.values(v.current);s<c.length;s+=1){var l=c[s];if(l){var m=l.ref.name,g=await hr(v,dr,l,I);g[m]?(W(n,m,g[m]),ir(S.current,m)):P(w.current,m)&&(ir(Ar.current.errors,m),W(S.current,m,!0))}}tr(n)&&Object.keys(Ar.current.errors).every((function(r){return r in v.current}))?(Nr({errors:{},isSubmitting:!0}),await r(i,t)):(Ar.current.errors=Object.assign(Object.assign({},Ar.current.errors),n),e&&await e(Ar.current.errors,t),f&&function(r,e){for(var t in r)if(P(e,t)){var n=r[t];if(n){if(n.ref.focus&&_(n.ref.focus()))break;if(n.options){n.options[0].ref.focus();break}}}}(v.current,Ar.current.errors))}finally{Ar.current.isSubmitting=!1,Nr({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:tr(Ar.current.errors),submitCount:Ar.current.submitCount+1})}}}),[f,dr]);a((function(){s&&br.current.isValid&&Kr(),Fr.current=Fr.current||!Vr?Fr.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&&er(o.ref)&&e(i)}else i&&er(i.ref)&&e(i)}}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(v,Yr)}),[Yr,D.current]),a((function(){return function(){Fr.current&&Fr.current.disconnect(),F.current=!0,"production"===process.env.NODE_ENV&&Object.values(v.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!s&&br.current.isValid&&(gr.isValid=sr(S.current,w.current)&&tr(Ar.current.errors));var te={trigger:_r,setValue:t((function(r,e,t){zr(r,e,t||{}),Ur(r)&&Nr(),$r(r)}),[zr,_r]),getValues:t(Jr,[]),register:t((function(r,e){if(!Sr)if(lr(r))re({name:r},e);else{if(!L(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(v.current[n],!0)}}),[]),formState:Dr?new Proxy(gr,{get:function(r,e){if("production"!==process.env.NODE_ENV&&"isValid"===e&&Z&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),e in r)return br.current[e]=!0,r[e]}}):gr},ne=u((function(){return Object.assign({isFormDirty:qr,updateWatchedValue:Xr,shouldUnregister:d,updateFormState:Nr,removeFieldEventListener:Qr,watchInternal:Zr,mode:X.current,reValidateMode:{isReValidateOnBlur:Cr,isReValidateOnChange:Ir},validateResolver:s?Kr:void 0,fieldsRef:v,resetFieldArrayFunctionRef:B,useWatchFieldsRef:k,useWatchRenderFunctionsRef:A,fieldArrayDefaultValuesRef:g,validFieldsRef:S,fieldsWithValidationRef:w,fieldArrayNamesRef:$,readFormStateRef:br,formStateRef:Ar,defaultValuesRef:D,shallowFieldsStateRef:I,fieldArrayValuesRef:p},te)}),[D.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={}),Vr)for(var t=0,n=Object.values(v.current);t<n.length;t+=1){var i=n[t];if(i){var a=i.ref,u=i.options,o=wr(a)&&Array.isArray(u)?u[0].ref:a;if(h(o))try{o.closest("form").reset();break}catch(r){}}}v.current={},D.current=Object.assign({},r||D.current),r&&$r(""),Object.values(B.current).forEach((function(r){return vr(r)&&r()})),I.current=d?{}:Er(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||(S.current={},w.current={}),g.current={},b.current=new Set,R.current=!1,Nr({submitCount:u?Ar.current.submitCount:0,isDirty:!!t&&Ar.current.isDirty,isSubmitted:!!n&&Ar.current.isSubmitted,isValid:!!a&&Ar.current.isValid,dirtyFields:o?Ar.current.dirtyFields:{},touched:i?Ar.current.touched:{},errors:e?Ar.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})}(e)}),[]),clearErrors:t((function(r){r&&(Array.isArray(r)?r:[r]).forEach((function(r){return v.current[r]&&T(r)?delete Ar.current.errors[r]:ir(Ar.current.errors,r)})),Nr({errors:r?Ar.current.errors:{}})}),[]),setError:t((function(r,e){var t=(v.current[r]||{}).ref;W(Ar.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Nr({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:gr.errors},te)}e(null).displayName="RHFContext",function(r){r.formgroup="formgroup",r.checkbox="checkbox",r.radiobutton="radiobutton",r.textarea="textarea",r.input="input"}(Ar||(Ar={}));var Rr=function(e){var t=e.exampleType,n=void 0===t?Ar.formgroup:t,i=Fr(),a=i.register,u=i.handleSubmit,o=i.errors,h=o.formgroup1||o.formgroup2||o.formgroup3||o.formgroup4||o.formgroup5,y="Du må velge et alternativ",j=[r.createElement(l,{key:0,inputId:"checkbox1",label:"Checkbox 1",ref:a({required:y})}),r.createElement(l,{key:1,inputId:"checkbox2",label:"Checkbox 2",ref:a({required:y})}),r.createElement(l,{key:2,inputId:"checkbox3",label:"Checkbox 3",ref:a({required:y})})],O=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===Ar.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(p,{maxColumns:b.two},j.map((function(r){return r})))),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,{inputId:"checkbox4",label:"Checkbox 4",ref:a({validate:O})}),r.createElement(l,{inputId:"checkbox5",label:"Checkbox 5",ref:a({validate:O})}),r.createElement(l,{inputId:"checkbox6",label:"Checkbox 6",ref:a({validate:O})})),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,{inputId:"radiobutton1",label:"Radiobutton 1",ref:a({required:y})}),r.createElement(d,{inputId:"radiobutton2",label:"Radiobutton 2",ref:a({required:y})}),r.createElement(d,{inputId:"radiobutton3",label:"Radiobutton 3",ref:a({required:y})})),r.createElement(c,{key:3,error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(m,{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",textareaId:"textarea1",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(v,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:g,ref:a({required:"Du må skrive noe her"})}))]:n===Ar.checkbox?r.createElement(c,{name:"formgroup1",error:o.formgroup1?o.formgroup1.message:void 0},r.createElement(l,{name:"formgroup1",inputId:"checkbox1",label:"Checkbox 1",error:o.formgroup1,variant:e.variant,ref:a({required:y})})):n===Ar.radiobutton?r.createElement(c,{name:"formgroup3",error:o.formgroup3?o.formgroup3.message:void 0},r.createElement(d,{name:"formgroup3",inputId:"radiobutton1",label:"Radiobutton 1",error:o.formgroup3,variant:e.variant,ref:a({required:y})})):n===Ar.textarea?r.createElement(c,{error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(m,{defaultValue:"Dette er min historie \n\n Hello \n\n test",grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})):n===Ar.input?r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(v,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:g,ref:a({required:"Du må skrive noe her"})})):void 0),r.createElement(f,{type:"submit"},"Submit"))};export default Rr;export{Rr as FormExample,Ar as FormExampleVariants};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F as s}from"../../FormGroup-
|
|
1
|
+
import{F as s}from"../../FormGroup-9c5e238e.js";export{F as FormGroup,F as default}from"../../FormGroup-9c5e238e.js";import"../../_rollupPluginBabelHelpers-4f206abf.js";import"react";import"../../index-9b84fabc.js";import"./styles.module.scss";import"../../Checkbox-1e2c2047.js";import"../../uuid-11037462.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../_tslib-51c8a283.js";import"../../constants-9528513d.js";import"../../color-e7d082c1.js";import"../../index-d1c9177a.js";import"../../palette-f206f488.js";import"../../grid-c105cad1.js";import"../Checkbox/styles.module.scss";import"../../RadioButton-71099f5c.js";import"../RadioButton/styles.module.scss";import"../../Input-5bb47387.js";import"../../useBreakpoint-6eb418f7.js";import"../Input/styles.module.scss";import"../../Title-3a6d4597.js";import"../Title/styles.module.scss";import"../../FormLayout-26368f0a.js";import"../FormLayout/styles.module.scss";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLayout.d.ts","sourceRoot":"","sources":["../../../src/components/FormLayout/FormLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAe,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3D,oBAAY,iBAAiB;IAC3B,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,OAAO,iBAAiB,CAAC;IAC5C,oGAAoG;IACpG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,OAAO,WAAW,CAAC;IACnC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC;CACzD;AAED,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"FormLayout.d.ts","sourceRoot":"","sources":["../../../src/components/FormLayout/FormLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAe,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3D,oBAAY,iBAAiB;IAC3B,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,OAAO,iBAAiB,CAAC;IAC5C,oGAAoG;IACpG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,OAAO,WAAW,CAAC;IACnC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC;CACzD;AAED,eAAO,MAAM,UAAU,qFAyBrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F as o}from"../../FormLayout-
|
|
1
|
+
import{F as o}from"../../FormLayout-26368f0a.js";export{F as FormLayout,a as FormLayoutColumns,F as default}from"../../FormLayout-26368f0a.js";import"../../_rollupPluginBabelHelpers-4f206abf.js";import"react";import"../../index-9b84fabc.js";import"./styles.module.scss";import"../../constants-9528513d.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -4,26 +4,31 @@
|
|
|
4
4
|
.form-layout-container {
|
|
5
5
|
// Settes med harde verdier fordi calc() lenger nede ikke støtter getSpacer()
|
|
6
6
|
--column-gap: 2rem;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-wrap: wrap;
|
|
9
10
|
row-gap: getSpacer(s);
|
|
10
11
|
column-gap: var(--column-gap);
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
&--bigform {
|
|
14
|
+
row-gap: getSpacer(2xs);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.form-layout-child {
|
|
19
|
+
min-width: var(--min-col-width);
|
|
20
|
+
flex-basis: calc(100% - var(--column-gap));
|
|
21
|
+
|
|
13
22
|
&--two {
|
|
14
|
-
|
|
23
|
+
flex-basis: calc(50% - var(--column-gap));
|
|
15
24
|
}
|
|
16
25
|
&--three {
|
|
17
|
-
|
|
26
|
+
flex-basis: calc(33% - var(--column-gap));
|
|
18
27
|
}
|
|
19
28
|
&--four {
|
|
20
|
-
|
|
29
|
+
flex-basis: calc(25% - var(--column-gap));
|
|
21
30
|
}
|
|
22
31
|
&--five {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&--bigform {
|
|
27
|
-
row-gap: getSpacer(2xs);
|
|
32
|
+
flex-basis: calc(20% - var(--column-gap));
|
|
28
33
|
}
|
|
29
34
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export type Styles = {
|
|
2
|
+
'form-layout-child': string;
|
|
3
|
+
'form-layout-child--five': string;
|
|
4
|
+
'form-layout-child--four': string;
|
|
5
|
+
'form-layout-child--three': string;
|
|
6
|
+
'form-layout-child--two': string;
|
|
2
7
|
'form-layout-container': string;
|
|
3
8
|
'form-layout-container--bigform': string;
|
|
4
|
-
'form-layout-container--five': string;
|
|
5
|
-
'form-layout-container--four': string;
|
|
6
|
-
'form-layout-container--three': string;
|
|
7
|
-
'form-layout-container--two': string;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
export type ClassNames = keyof Styles;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as t}from"../../_rollupPluginBabelHelpers-4f206abf.js";import a from"react";import{c as r}from"../../index-9b84fabc.js";import e from"./styles.module.scss";import{I as o,A as s}from"../../constants-9528513d.js";import{Icon as n}from"../Icons/Icon.js";import c from"../Icons/Undo.js";import l from"../Icons/Group.js";import"../../_tslib-51c8a283.js";var i;!function(t){t.info="info",t.warning="warning",t.alert="alert",t.cancelled="cancelled",t.active="active",t.transparent="transparent",t.recurring="recurring",t.group="group"}(i||(i={}));var m=a.forwardRef((function(m,d){var u=m.variant,p=void 0===u?i.info:u,f=m.text,g=m.className,_=p===i.recurring||p===i.group,v=p===i.cancelled,b=r(e.statusdot,t({},e["statusdot--cancelled"],v),g),j=r(e.statusdot__dot,[_?e["statusdot__dot--icon"]:e["statusdot__dot--".concat(p)]]),I=r(e.statusdot__label,t({},e["statusdot__label--icon"],_)
|
|
1
|
+
import{d as t}from"../../_rollupPluginBabelHelpers-4f206abf.js";import a from"react";import{c as r}from"../../index-9b84fabc.js";import e from"./styles.module.scss";import{I as o,A as s}from"../../constants-9528513d.js";import{Icon as n}from"../Icons/Icon.js";import c from"../Icons/Undo.js";import l from"../Icons/Group.js";import"../../_tslib-51c8a283.js";var i;!function(t){t.info="info",t.warning="warning",t.alert="alert",t.cancelled="cancelled",t.active="active",t.transparent="transparent",t.recurring="recurring",t.group="group"}(i||(i={}));var m=a.forwardRef((function(m,d){var u=m.variant,p=void 0===u?i.info:u,f=m.text,g=m.className,_=p===i.recurring||p===i.group,v=p===i.cancelled,b=r(e.statusdot,t({},e["statusdot--cancelled"],v),g),j=r(e.statusdot__dot,[_?e["statusdot__dot--icon"]:e["statusdot__dot--".concat(p)]]),I=r(e.statusdot__label,t({},e["statusdot__label--icon"],_)),E=null;return"recurring"===p?E=a.createElement(n,{size:o.XXSmall,svgIcon:c}):"group"===p&&(E=a.createElement(n,{size:o.XXSmall,svgIcon:l})),a.createElement("div",{className:b,"data-analyticsid":s.StatusDot},a.createElement("span",{className:j},E),a.createElement("span",{className:I},f))}));export default m;export{i as StatusDotVariant};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{V as s}from"../../Validation-
|
|
1
|
+
import{V as s}from"../../Validation-e36cb0d8.js";export{V as Validation,V as default}from"../../Validation-e36cb0d8.js";import"react";import"../../index-9b84fabc.js";import"../../FormGroup-9c5e238e.js";import"../../_rollupPluginBabelHelpers-4f206abf.js";import"../FormGroup/styles.module.scss";import"../../Checkbox-1e2c2047.js";import"../../uuid-11037462.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../_tslib-51c8a283.js";import"../../constants-9528513d.js";import"../../color-e7d082c1.js";import"../../index-d1c9177a.js";import"../../palette-f206f488.js";import"../../grid-c105cad1.js";import"../Checkbox/styles.module.scss";import"../../RadioButton-71099f5c.js";import"../RadioButton/styles.module.scss";import"../../Input-5bb47387.js";import"../../useBreakpoint-6eb418f7.js";import"../Input/styles.module.scss";import"../../Title-3a6d4597.js";import"../Title/styles.module.scss";import"../../FormLayout-26368f0a.js";import"../FormLayout/styles.module.scss";import"./styles.module.scss";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormGroup-157f9e03.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/FormLayout-a3d440c1.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d as o}from"./_rollupPluginBabelHelpers-4f206abf.js";import t from"react";import{c as r}from"./index-9b84fabc.js";import e from"./components/FormLayout/styles.module.scss";import{a,A as n}from"./constants-9528513d.js";var i;!function(o){o.one="one",o.two="two",o.three="three",o.four="four",o.five="five"}(i||(i={}));var m=t.forwardRef((function(m,f){var l,s=m.maxColumns,c=void 0===s?i.one:s,u=m.colMinWidth,d=void 0===u?300:u,p=m.variant,v=m.className,y=m.mapHelper,h={"--min-col-width":"".concat(d,"px")},b=r(e["form-layout-container"],(o(l={},e["form-layout-container--bigform"],p===a.bigform),o(l,e["form-layout-container--two"],c===i.two),o(l,e["form-layout-container--three"],c===i.three),o(l,e["form-layout-container--four"],c===i.four),o(l,e["form-layout-container--five"],c===i.five),l),v);return t.createElement("div",{"data-testid":m.testId,"data-analyticsid":n.FormLayout,style:h,className:b},t.Children.map(m.children,(function(o){return t.createElement("div",null,y?y(o):o)})))}));export{m as F,i as a};
|
|
2
|
-
//# sourceMappingURL=FormLayout-a3d440c1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormLayout-a3d440c1.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/Validation-5d79f53e.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import r from"react";import{c as a}from"./index-9b84fabc.js";import{F as e}from"./FormGroup-157f9e03.js";import t from"./components/Validation/styles.module.scss";import{A as o}from"./constants-9528513d.js";var s=r.forwardRef((function(s,m){var n=s.errorSummary,i=s.className,l=a(t.validation,i);return r.createElement(r.Fragment,null,r.createElement("div",{"data-testid":s.testId,"data-analyticsid":o.Validation,className:l},r.Children.map(s.children,(function(a){return a.type===e?r.cloneElement(a,{className:n?t["form-group-wrapper--error-sibling"]:""}):a}))),n&&r.createElement("p",{className:t.validation__errors},n))}));export{s as V};
|
|
2
|
-
//# sourceMappingURL=Validation-5d79f53e.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Validation-5d79f53e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|