@helsenorge/designsystem-react 1.0.0-beta94 → 1.0.0-beta95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/{Modal-6b4a2c9c.js → Modal-b7d10081.js} +2 -2
- package/Modal-b7d10081.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/{Validation-ef9ee0ae.js → Validation-9bf0c0ec.js} +2 -2
- package/Validation-9bf0c0ec.js.map +1 -0
- package/components/AnchorLink/index.js +1 -1
- package/components/Avatar/index.js +1 -1
- package/components/Button/Button.d.ts.map +1 -1
- package/components/Button/index.js +1 -1
- package/components/ButtonWithModal/index.js +1 -1
- package/components/Checkbox/componentdata.json +9 -9
- package/components/Checkbox/index.js +1 -1
- package/components/Close/index.js +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.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.js +1 -1
- 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.js +1 -1
- package/components/Modal/index.js +1 -1
- package/components/NotificationPanel/index.js +1 -1
- package/components/RadioButton/componentdata.json +9 -9
- package/components/RadioButton/index.js +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.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.js +1 -1
- package/components/Validation/componentdata.json +3 -3
- 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.js +1 -1
- package/package.json +1 -1
- package/scss/_input.scss +174 -0
- package/Button-72f96290.js +0 -2
- package/Button-72f96290.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-68288be3.js +0 -2
- package/FormGroup-68288be3.js.map +0 -1
- package/Icon-9b4a8a2d.js.map +0 -1
- package/Modal-6b4a2c9c.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/Validation-ef9ee0ae.js.map +0 -1
- package/constants-a4b0b501.js +0 -2
- package/constants-a4b0b501.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as t,a as e}from"./_rollupPluginBabelHelpers-d0752906.js";import{_ as n}from"./_tslib-51c8a283.js";import o from"react";import{g as r}from"./color-acb834c6.js";import"./Icon-04613a89.js";import{I as l}from"./constants-42547490.js";import{L as i}from"./Loader-b3fd59f4.js";import{u as a}from"./useHover-037be19d.js";import{u as s}from"./useWindowSize-73b47451.js";import{b as u}from"./grid-11a70eb7.js";import{c as d}from"./index-9b84fabc.js";import c from"./components/Button/styles.module.scss";var m={primary:"blueberry",warning:"banana",danger:"cherry"},b=function(t,e){return e&&e<u.md&&t?l.Small:t?l.Medium:l.XSmall},f=o.forwardRef((function(u,f){var p,v,_,g=u.children,h=u.className,j=void 0===h?"":h,w=u.fluid,E=void 0!==w&&w,k=u.intent,y=void 0===k?"primary":k,N=u.inverted,I=void 0!==N&&N,C=u.htmlMarkup,H=void 0===C?"button":C,O=u.onClick,S=u.large,z=void 0!==S&&S,B=u.loading,F=void 0!==B&&B,M=u.variant,x=void 0===M?"fill":M,L=u.disabled,R=void 0!==L&&L,X=u.ellipsis,A=void 0!==X&&X,P=u.testId,W=u.href,q=u.target,D=n(u,["children","className","fluid","intent","inverted","htmlMarkup","onClick","large","loading","variant","disabled","ellipsis","testId","href","target"]),G=function(t){var e,n,o,r,l=null,i=null;void 0!==(null===(n=null===(e=t[0])||void 0===e?void 0:e.props)||void 0===n?void 0:n.svgIcon)&&(l=t.shift()),void 0!==(null===(r=null===(o=t[t.length-1])||void 0===o?void 0:o.props)||void 0===r?void 0:r.svgIcon)&&(i=t.pop());var a=t.filter((function(t){return t}));return[l,i,a.length>0?a:null]}(o.Children.toArray(g)),J=t(G,3),K=J[0],Q=J[1],T=J[2],U=a(f),V=U.hoverRef,Y=U.isHovered,Z=function(t,e,n,o,l){return e?r("neutral",600):t&&!o||!t&&o?"white":r(m[n],l?700:600)}("fill"===x,R,y,I,Y),$=s(),tt="fill"===x,et="outline"===x,nt="borderless"===x,ot="warning"===y,rt="danger"===y,lt=!(!K&&!Q||F),it=Object.assign({},D),at=d(c.button,(e(p={},c["button--fluid"],E),e(p,c["button--large"],z),e(p,c["button--warning"],ot),e(p,c["button--danger"],rt),e(p,c["button--inverted"],I),e(p,c["button--fill"],tt),e(p,c["button--outline"],et),e(p,c["button--borderless"],nt),e(p,c["button--with-icon"],lt),e(p,c["button--ellipsis"],A),p),j),st=d(c.button__content,(e(v={},c["button__content--warning"],ot),e(v,c["button__content--danger"],rt),e(v,c["button__content--fill"],tt),e(v,c["button__content--borderless"],nt),e(v,c["button__content--with-icon"],lt),e(v,c["button__content--large"],z),e(v,c["button__content--ellipsis"],A),e(v,c["button__content--inverted"],I),e(v,c["button__content--fluid"],E),v)),ut=d(c["button__left-fluid-content"],(e(_={},c["button__left-fluid-content--with-icon"],lt),e(_,c["button__left-fluid-content--large"],z),_));function dt(t,e,n,r){var l=t&&t.props&&t.props.color?t.props.color:n;return t&&Object.keys(t).length>0?o.cloneElement(t,{size:e,color:l,isHovered:r}):null}var ct=function(){return T?o.createElement("span",{className:st},T):null},mt=function(){return o.createElement("span",{className:c["content-wrapper"]},F?o.createElement("div",{className:c["button__left-fluid-content"]},o.createElement(i,{testId:"test-id-loader",color:"fill"!==x||I?m[y]:"white",size:"tiny"})):o.createElement(o.Fragment,null,E?o.createElement("div",{className:ut},dt(K,b(z,$.width),Z,Y),ct()):o.createElement(o.Fragment,null,dt(K,b(z,$.width),Z,Y),ct()),dt(Q,l.XSmall,Z,Y)))};return o.createElement(o.Fragment,null,"button"===H&&o.createElement("button",Object.assign({onClick:O,disabled:R,"data-testid":P,className:at,ref:V},it),mt()),"a"===H&&o.createElement("a",Object.assign({onClick:O,"data-testid":P,className:at,href:W,target:q,rel:"_blank"===q?"noopener noreferrer":u.rel,ref:V},D),mt()))}));export{f as B,m as i};
|
|
2
|
+
//# sourceMappingURL=Button-8af0be6e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button-8af0be6e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,a as r}from"./_rollupPluginBabelHelpers-d0752906.js";import o,{useState as a,useEffect as c}from"react";import{c as l}from"./index-9b84fabc.js";import{u as b}from"./uuid-8870ab4b.js";import{C as i}from"./Check-6291ad09.js";import{I as s}from"./Icon-04613a89.js";import{F as n,a as t}from"./constants-42547490.js";import{g as m}from"./color-acb834c6.js";import d from"./components/Checkbox/styles.module.scss";var p=o.forwardRef((function(p,h){var k,x,f,u=p.className,v=p.checked,_=void 0!==v&&v,w=p.disabled,g=p.label,y=p.inputid,j=void 0===y?b():y,N=p.mode,E=p.name,C=void 0===E?j:E,I=p.variant,F=p.errorText,z=p.error,B=void 0===z?!!F:z,H=p.value,P=void 0===H?g:H,R=a(_),T=e(R,2),q=T[0],A=T[1],D=B||N===n.oninvalid,G=N===n.ondark,J=N===n.onblueberry,K=I===t.bigform,L=l(d["checkbox-wrapper"],(r(k={},d["checkbox-wrapper--with-error"],F),r(k,d["checkbox-wrapper--bigform"],K),k)),M=l(d["checkbox-label"],(r(x={},d["checkbox-label--disabled"],w),r(x,d["checkbox-label--on-dark"],G),r(x,d["checkbox-label--on-blueberry"],J),r(x,d["checkbox-label--invalid"],D),r(x,d["checkbox-label--bigform"],K),x)),O=l(d.checkbox,u),Q=l(d["checkbox__icon-wrapper"],(r(f={},d["checkbox__icon-wrapper--checked"],q),r(f,d["checkbox__icon-wrapper--disabled"],w),r(f,d["checkbox__icon-wrapper--on-dark"],G),r(f,d["checkbox__icon-wrapper--on-blueberry"],J),r(f,d["checkbox__icon-wrapper--invalid"],D),f)),S=l(d["checkbox-errors"],r({},d["checkbox-errors--bigform"],K)),U=m("blueberry",500);return w&&(U=m("neutral",400)),G&&(U=m("blueberry",200)),D&&(U=m("cherry",500)),c((function(){A(_)}),[_]),o.createElement("div",{"data-testid":p.testId,className:L},F&&o.createElement("p",{className:S},F),o.createElement("label",{htmlFor:j,className:M},o.createElement("input",{id:j,name:C,className:O,type:"checkbox",checked:q,disabled:w,onChange:function(){A(!q)},value:P,ref:h,"aria-invalid":B}),o.createElement("span",{className:Q},q&&o.createElement(s,{color:U,className:d.checkbox__icon,svgIcon:i,size:38})),g))}));export{p as C};
|
|
2
|
+
//# sourceMappingURL=Checkbox-fb5dff56.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox-fb5dff56.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"react";import{p as t}from"./palette-f206f488.js";import{I as a}from"./Icon-
|
|
2
|
-
//# sourceMappingURL=Close-
|
|
1
|
+
import e from"react";import{p as t}from"./palette-f206f488.js";import{I as a}from"./Icon-04613a89.js";import"./constants-42547490.js";import l from"./components/Close/styles.module.scss";import{u as r,B as o}from"./useBreakpoint-324a9b14.js";var s=function(t){var a=t.isExtraSmall,l=t.isHovered,r=e.createElement("path",{d:"M25.403 24l10.259-10.259-1.403-1.403L24 22.597l-10.259-10.26-1.403 1.403L22.597 24 12.338 34.26l1.403 1.403L24 25.403l10.259 10.259 1.403-1.403z"}),o=e.createElement("path",{d:"M24 22.597L12.327 10.924l-1.403 1.402L22.597 24 10.923 35.674l1.403 1.402L24 25.403l11.674 11.673 1.403-1.402L25.403 24l11.673-11.674-1.403-1.402z"}),s=e.createElement("path",{d:"M25.773 24l10.432-10.432-1.772-1.773-10.432 10.433-10.433-10.433-1.773 1.772L22.229 24 11.795 34.433l1.773 1.772 10.433-10.433 10.432 10.433 1.772-1.773z"});return a?l?e.createElement("path",{d:"M24 22.227L11.781 10.008l-1.772 1.772 12.219 12.219-12.22 12.22 1.772 1.772L24 25.771l12.22 12.22 1.772-1.772-12.22-12.22L37.991 11.78l-1.772-1.772z"}):s:l?o:r},n=function(n){var m=r()===o.Xs?38:48;return e.createElement("button",{"data-testid":n.testId,className:l.close,"aria-label":n.ariaLabel||"Lukk",onClick:n.onClick,role:"button"},e.createElement(a,{svgIcon:s,color:t.blueberry600,size:m}))};export{n as C};
|
|
2
|
+
//# sourceMappingURL=Close-9f68bcd0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Close-9f68bcd0.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e}from"./_rollupPluginBabelHelpers-d0752906.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-fb5dff56.js";import{R as m}from"./RadioButton-d90884c9.js";import{I as n}from"./Input-adeb7f88.js";import{F as l,a as i}from"./constants-42547490.js";import{T as p}from"./Title-90910763.js";var s=r.forwardRef((function(s,f){var d,u,c,g=s.className,v=s.mode,_=void 0===v?l.onwhite:v,b=s.variant,w=void 0===b?i.normal:b,E=s.error,j=s.name,y=_===l.ondark,N=w===i.bigform,h=a(o["form-group-wrapper"],(e(d={},o["form-group-wrapper--on-dark"],y),e(d,o["form-group-wrapper--invalid"],E),d),g),k=a(o["form-group-wrapper__title"],(e(u={},o["form-group-wrapper__title--on-dark"],y&&!E),e(u,o["form-group-wrapper__title--bigform"],N),u)),x=a(o["form-group"],e({},o["form-group--invalid"],E)),B=a(o["form-group-wrapper__errors"],e({},o["form-group-wrapper__errors--bigform"],N)),C=a(o["field-set__legend"],(e(c={},o["field-set__legend--on-dark"],y&&!E),e(c,o["field-set__legend--bigform"],N),c));return r.createElement("div",{"data-testid":s.testId,className:h},s.title&&r.createElement(p,{className:k,htmlMarkup:"h4",appearance:"title4",margin:{marginTop:0,marginBottom:2}},s.title),r.createElement("div",{className:x},E&&r.createElement("p",{className:B},E),r.createElement("fieldset",{name:s.title,className:o["field-set"]},s.legend&&r.createElement("legend",{className:C},s.legend),r.Children.map(s.children,(function(e){if(e.type===t){var a=e.type===t;return r.cloneElement(e,{name:null!=j?j:a.valueOf.name,mode:_,variant:w,error:!!E})}if(e.type===m){var o=e.type===m;return r.cloneElement(e,{name:null!=j?j:o.valueOf.name,mode:_,variant:w,error:!!E})}if(e.type===n){var l=e.type===n;return r.cloneElement(e,{name:null!=j?j:l.valueOf.name,mode:_,variant:w,error:!!E})}return e})))))}));export{s as F};
|
|
2
|
+
//# sourceMappingURL=FormGroup-6c545646.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormGroup-6c545646.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e}from"./_tslib-51c8a283.js";import a from"react";import{I as i}from"./constants-
|
|
2
|
-
//# sourceMappingURL=Icon-
|
|
1
|
+
import{_ as e}from"./_tslib-51c8a283.js";import a from"react";import{I as i}from"./constants-42547490.js";var t=function(e,a,i,t,o,r){return e&&o&&r?a?r:o:a?t:i},o=a.forwardRef((function(t,o){var r=t.svgIcon,l=t.ariaLabel,s=t.id,d=t.className,c=void 0===d?"":d,n=t.size,m=void 0===n?i.Small:n,v=t.color,b=void 0===v?"black":v,f=t.hoverColor,h=void 0===f?b||"black":f,g=t.isHovered,I=void 0!==g&&g,p=t.testId,u=e(t,["svgIcon","ariaLabel","id","className","size","color","hoverColor","isHovered","testId"]),y=a.createElement(r,{isExtraSmall:m<=i.XSmall,isHovered:I}),E=s&&l?"title-".concat(s):void 0;return a.createElement("svg",Object.assign({id:s,"data-testid":p,ref:o,className:"hnds-style-icon ".concat(c),role:"img","aria-label":!s&&l?l:void 0,"aria-labelledby":E,"aria-hidden":"true",viewBox:"0 0 48 48",style:{minWidth:m,minHeight:m},width:m,height:m,fill:I?h:b},u),E&&a.createElement("title",{id:E},l),y)}));o.displayName="Icon";export{o as I,t as r};
|
|
2
|
+
//# sourceMappingURL=Icon-04613a89.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon-04613a89.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e}from"./_rollupPluginBabelHelpers-d0752906.js";import{_ as r}from"./_tslib-51c8a283.js";import a,{useRef as t}from"react";import{c as n}from"./index-9b84fabc.js";import{F as l,a as o,I as i}from"./constants-42547490.js";import{u as p}from"./uuid-8870ab4b.js";import{I as s}from"./Icon-04613a89.js";import{g as c}from"./color-acb834c6.js";import{u as d,B as m}from"./useBreakpoint-324a9b14.js";import u from"./components/Input/styles.module.scss";var b;!function(e){e.text="text",e.number="number",e.email="email",e.password="password",e.search="search",e.tel="tel",e.url="url"}(b||(b={}));var f=a.forwardRef((function(f,w){var v,_,h,g=f.defaultValue,j=f.placeholder,y=f.type,E=void 0===y?b.text:y,I=f.inputid,k=void 0===I?p():I,x=f.name,C=f.transparent,N=void 0!==C&&C,L=f.icon,O=f.iconRight,B=f.mode,R=f.variant,V=f.label,F=f.error,S=f.errorText,T=f.testId,X=f.disabled,z=f.readOnly,H=f.autocomplete,P=f.afterLabelChildren,q=f.belowLabelChildren,A=r(f,["defaultValue","placeholder","type","inputid","name","transparent","icon","iconRight","mode","variant","label","error","errorText","testId","disabled","readOnly","autocomplete","afterLabelChildren","belowLabelChildren"]),D=d(),G=t(null),J=B===l.ondark,K=B===l.onblueberry,M=B===l.oninvalid||S||F,Q=R===o.bigform,U=N&&B!==l.ondark&&!M,W=n(u["input-wrapper"],e({},u["input-wrapper--invalid"],S)),Y=n(u["input-wrapper__label-wrapper"],(e(v={},u["input-wrapper__label-wrapper--on-dark"],J),e(v,u["input-wrapper__label-wrapper--disabled"],X),v)),Z=n(u["content-wrapper"],(e(_={},u["content-wrapper--transparent"],U),e(_,u["content-wrapper--on-blueberry"],K),e(_,u["content-wrapper--on-dark"],J),e(_,u["content-wrapper--invalid"],M),e(_,u["content-wrapper--bigform"],Q),e(_,u["content-wrapper--disabled"],X),e(_,u["content-wrapper--with-icon"],L),_)),$=n(u["content-wrapper__input"],(e(h={},u["content-wrapper__input--bigform"],Q),e(h,u["content-wrapper__input--disabled"],X),h)),ee=X?c("neutral",500):c("black"),re=function(){var e=D!==m.Xs&&Q?i.Small:i.XSmall;return void 0!==L?a.createElement(s,{color:ee,size:e,svgIcon:L}):null};return a.createElement("div",{"data-testid":T,className:W},V&&a.createElement("div",{className:Y},a.createElement("label",{htmlFor:k},V),P&&a.createElement("div",{className:u["input-wrapper__after-label-children"]},P)),q&&a.createElement("div",null,q),a.createElement("div",{onClick:function(){if(G&&G.current&&L){var e=O?0:1;G.current.children[e].focus()}},ref:G,className:Z},!O&&re(),a.createElement("input",Object.assign({name:x,type:E,defaultValue:g,id:k,className:$,ref:w,"aria-invalid":!!M,disabled:X,placeholder:j,readOnly:z,autoComplete:H||"off"},A)),O&&re()))}));export{f as I,b as a};
|
|
2
|
+
//# sourceMappingURL=Input-adeb7f88.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input-adeb7f88.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,a as t}from"./_rollupPluginBabelHelpers-d0752906.js";import a,{useRef as r,useEffect as n,useState as l}from"react";import{c as o}from"./index-9b84fabc.js";import{p as
|
|
2
|
-
//# sourceMappingURL=Modal-
|
|
1
|
+
import{_ as e,a as t}from"./_rollupPluginBabelHelpers-d0752906.js";import a,{useRef as r,useEffect as n,useState as l}from"react";import{c as o}from"./index-9b84fabc.js";import{p as c}from"./palette-f206f488.js";import{B as i}from"./Button-8af0be6e.js";import{I as s}from"./Icon-04613a89.js";import{Z as d,I as m}from"./constants-42547490.js";import u from"./components/Modal/styles.module.scss";import{A as v,a as p}from"./AlertSignFill-e607ff43.js";import{T as f}from"./Title-90910763.js";import{u as _}from"./uuid-8870ab4b.js";import{C as E}from"./Close-9f68bcd0.js";import{createPortal as h}from"react-dom";function y(){var e=r(null);function t(t){var a=e.current,r="Tab"===t.key;if(a&&r){var n=function(e){try{return("string"==typeof e?document.querySelector(e):e).getRootNode().activeElement}catch(t){return console.error("Feil ved å ta tak i active element basert på angitt node: ",e,t),null}}(a),l=null==a?void 0:a.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),o=l[0],c=1===l.length?o:l[l.length-1];t.shiftKey?n===o&&(c.focus(),t.preventDefault()):n===c&&(o.focus(),t.preventDefault())}}function a(t){var a=e.current;if(a){var r=a.querySelectorAll('a[href], button, textarea, input[type="text"], input[type="radio"], input[type="checkbox"], select');1===r.length&&(r[0].focus(),t.preventDefault())}}return n((function(){var r=e.current;return r.addEventListener("keydown",t),r.addEventListener("click",a),function(){r.removeEventListener("keydown",t),r.removeEventListener("click",a)}}),[]),e}var b,g,N=function(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=l(!1),o=e(r,2),c=o[0],i=o[1];return n((function(){var e=new IntersectionObserver((function(e){i(e[0].intersectionRatio>=a)}),{threshold:a});return(null==t?void 0:t.current)&&e.observe(t.current),function(){(null==t?void 0:t.current)&&e.unobserve(t.current)}}),[t]),c},x=function(e){e.isExtraSmall;var t=e.isHovered,r=a.createElement("path",{d:"m9.16 23.421 2.883-2.773 8.262 8.584L35.958 12.97l2.882 2.774-18.536 19.257-11.143-11.58zm26.744-13.279-15.6 16.206-8.206-8.529-5.766 5.547 13.973 14.518 21.362-22.193-5.764-5.549z","fill-rule":"evenodd"});return t?a.createElement("path",{d:"m11.128 25.394 2.88-2.771 6.291 6.613 17.071-17.68 2.882 2.775-19.944 20.668-9.18-9.605zM37.318 8.73 20.31 26.345l-6.239-6.558-5.766 5.548 11.996 12.552 22.781-23.609-5.764-5.548z","fill-rule":"evenodd"}):r};function w(e){var t=e.children,r=e.parent,n=e.className,l=e.testId,o=a.useMemo((function(){return document.createElement("div")}),[]);return l&&o.setAttribute("data-testid",l),a.useEffect((function(){var e=r&&r.appendChild?r:document.body,t=["portal-container"];return n&&n.split(" ").forEach((function(e){return t.push(e)})),t.forEach((function(e){return o.classList.add(e)})),e.appendChild(o),function(){e.removeChild(o)}}),[o,r,n]),h(t,o)}!function(e){e.normal="normal",e.warning="warning",e.error="error",e.success="success",e.image="image"}(b||(b={})),function(e){e.large="large",e.medium="medium"}(g||(g={}));var C={variant:b.normal,primaryButtonText:"OK",large:!1,className:"",size:g.large,zIndex:d.Modal},k=function(e,t){var r=function(e){return e===b.error?a.createElement(s,{size:m.Small,svgIcon:v,color:c.cherry500}):e===b.warning?a.createElement(s,{size:m.Small,svgIcon:p,color:c.black}):e===b.success?a.createElement(s,{size:m.Small,svgIcon:x,color:c.kiwi900}):null}(e);return r?a.createElement("div",{className:u.modal__iconWrapper},r):t?a.createElement("div",{className:u.modal__iconWrapper},a.cloneElement(t,{size:m.Small})):null},L=function(r){var l,c,s,d,m=a.useState(0),v=e(m,2),p=v[0],h=v[1],g=a.useState(_()),x=e(g,1)[0],C=a.useRef(null),L=a.useRef(null),B=a.useRef(null),z=N(L),I=a.useRef(null),S=N(I),T=B.current&&B.current.scrollHeight>B.current.clientHeight;function W(e){"Escape"===e.key&&r.onClose&&(e.stopPropagation(),r.onClose())}function j(e){e.target&&A.current===e.target&&r.onClose&&(e.stopPropagation(),r.onClose())}var R=r.variant===b.image,M=null!==(c=r.titleId)&&void 0!==c?c:x,A=a.useRef(null),P=r.secondaryButtonText&&(null===(s=r.secondaryButtonText)||void 0===s?void 0:s.length)>0||r.onSuccess,D=r.ariaLabelledBy?void 0:r.ariaLabel,H=r.ariaLabelledBy?r.ariaLabelledBy:r.ariaLabel?void 0:M;n((function(){var e,t=A.current;return null===(e=C.current)||void 0===e||e.focus(),document.body.style.overflow="hidden",t&&!P&&(t.addEventListener("keydown",W),t.addEventListener("click",j)),function(){document.body.style.removeProperty("overflow"),t&&!P&&(t.removeEventListener("keydown",W),t.removeEventListener("click",j))}}),[]);var q=o((t(l={},u["modal__title--error"],r.variant===b.error),t(l,u["modal__title--success"],r.variant===b.success),l)),F=a.createElement("div",{"data-testid":"dialog-container"},a.createElement("div",{ref:A,className:u["modal-overlay"],"data-testid":r.testId,style:{zIndex:r.zIndex}},a.createElement("div",{className:u.align,ref:y()},a.createElement("div",{className:o(r.className,u.modal,u["modal--".concat(r.variant)],u["modal--".concat(r.size)]),role:"dialog","aria-label":D,"aria-labelledby":H},a.createElement("div",{tabIndex:p,ref:C,onBlur:function(){return h(-1)}}),a.createElement("div",{className:o(u.modal__shadow,u["modal__shadow--top"],t({},u["modal__shadow--show"],!z&&T))}),a.createElement("div",{className:o(u.modal__contentWrapper,t({},u["modal__contentWrapper--image"],R)),ref:B},!r.noCloseButton&&a.createElement("div",{className:u.modal__closeWrapper},a.createElement("div",{className:o(u.modal__closeWrapper__close)},a.createElement(E,{onClick:r.onClose,ariaLabel:r.ariaLabelCloseBtn}))),a.createElement("div",{className:o(u["modal__contentWrapper__scroll--".concat(r.size)],t({},u["modal__contentWrapper__scroll--image"],R))},a.createElement("div",{ref:L}),a.createElement("div",{className:u.modal__contentWrapper__title},k(r.variant,r.icon),a.createElement(f,{id:M,htmlMarkup:"h3",appearance:"title3",className:q},r.title),r.afterTitleChildren&&a.createElement("div",{className:u.modal__afterTitleChildren},r.afterTitleChildren)),R&&a.createElement("div",null,a.createElement("div",{className:u.modal__contentWrapper__imageWrapper},r.children),a.createElement("span",{className:u.modal__contentWrapper__imageDescription},r.description)),!R&&r.children&&a.createElement("div",null,r.children),!R&&!r.children&&a.createElement("p",{className:u.modal__description},r.description),a.createElement("div",{ref:I}))),a.createElement("div",{className:o(u.modal__shadow,u["modal__shadow--bottom"],t({},u["modal__shadow--show"],!S&&T))}),P&&a.createElement("div",{className:o(u["modal__call-to-action"],u["modal__call-to-action--".concat(r.size)])},r.onSuccess&&a.createElement(i,{onClick:r.onSuccess},r.primaryButtonText),r.secondaryButtonText&&(null===(d=r.secondaryButtonText)||void 0===d?void 0:d.length)>0&&a.createElement(i,{variant:"borderless",onClick:r.onClose},r.secondaryButtonText))))));if(r.printable){return a.createElement(w,{className:"print-modal",testId:"print-modal"},a.createElement("style",{media:"print"},"body > *:not(.".concat("print-modal",") {display: none;}")),F)}return F};L.defaultProps=C;export{L as M,b as a,g as b};
|
|
2
|
+
//# sourceMappingURL=Modal-b7d10081.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal-b7d10081.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./_rollupPluginBabelHelpers-d0752906.js";import r from"react";import{c as o}from"./index-9b84fabc.js";import{u as e}from"./uuid-8870ab4b.js";import t from"./components/RadioButton/styles.module.scss";import{F as i,a as d}from"./constants-42547490.js";var l=r.forwardRef((function(l,n){var b,s,u,m=l.className,p=l.defaultChecked,c=void 0!==p&&p,f=l.disabled,v=l.label,g=l.inputid,k=void 0===g?e():g,w=l.mode,y=l.name,N=void 0===y?k:y,h=l.variant,j=l.errorText,E=l.error,x=void 0===E?!!j:E,R=l.value,B=void 0===R?v:R,C=x||w===i.oninvalid,F=w===i.ondark,H=w===i.onblueberry,I=h===d.bigform,P=o(t["radio-button-wrapper"],(a(b={},t["radio-button-wrapper--with-error"],j),a(b,t["radio-button-wrapper--bigform"],I),b)),T=o(t["radio-button-label"],(a(s={},t["radio-button-label--disabled"],f),a(s,t["radio-button-label--on-dark"],F),a(s,t["radio-button-label--on-blueberry"],H),a(s,t["radio-button-label--invalid"],C),a(s,t["radio-button-label--bigform"],I),s)),_=o(t["radio-button"],(a(u={},t["radio-button--on-dark"],F),a(u,t["radio-button--disabled"],f),a(u,t["radio-button--on-blueberry"],H),a(u,t["radio-button--invalid"],C),u),m),q=o(t["radio-button-errors"],a({},t["radio-button-errors--bigform"],I));return r.createElement("div",{"data-testid":l.testId,className:P},j&&r.createElement("p",{className:q},j),r.createElement("label",{htmlFor:k,className:T},r.createElement("input",{id:k,name:N,className:_,type:"radio",disabled:f,value:B,ref:n,"aria-invalid":x,defaultChecked:c}),v))}));export{l as R};
|
|
2
|
+
//# sourceMappingURL=RadioButton-d90884c9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton-d90884c9.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,a}from"./_rollupPluginBabelHelpers-d0752906.js";import{_ as r}from"./_tslib-51c8a283.js";import t,{useState as n,useRef as l,useEffect as o}from"react";import{c as i}from"./index-9b84fabc.js";import s from"./components/Textarea/styles.module.scss";import{F as c}from"./constants-42547490.js";import{u as d}from"./uuid-8870ab4b.js";var m=t.forwardRef((function(m,p){var u,b,v,w=m.maxCharacters,f=m.maxText,x=m.testId,_=m.defaultValue,h=m.marginBottom,g=m.transparent,E=m.mode,C=m.label,T=m.minRows,j=void 0===T?3:T,N=m.maxRows,R=void 0===N?10:N,k=m.grow,B=m.errorText,L=m.afterLabelChildren,y=m.belowLabelChildren,H=r(m,["maxCharacters","maxText","testId","defaultValue","marginBottom","transparent","mode","label","minRows","maxRows","grow","errorText","afterLabelChildren","belowLabelChildren"]),V=n(j),F=e(V,2),I=F[0],M=F[1],O=n(_||""),P=e(O,2),q=P[0],z=P[1],A=l(null),D=function(e){var a=e.rows;e.rows=j;var r=Math.floor((e.scrollHeight-16)/28);r===a&&(e.rows=r),r>=R&&(e.rows=R,e.scrollTop=e.scrollHeight),M(r<R?r:R)},G=E===c.ondark,J=E===c.onblueberry,K=w&&q.length>w,Q=E===c.oninvalid||B||K,S=i(s.textarea,(a(u={},s["textarea--gutterBottom"],h),a(u,s["textarea--invalid"],B),u)),U=i(s["textarea__label-wrapper"],a({},s["textarea__label-wrapper--on-dark"],G)),W=i(s["content-wrapper"],(a(b={},s["content-wrapper--transparent"],g),a(b,s["content-wrapper--on-blueberry"],J),a(b,s["content-wrapper--on-dark"],G),a(b,s["content-wrapper--invalid"],Q),a(b,s["content-wrapper--disabled"],m.disabled),b)),X=i(s["content-wrapper__input"],a({},s["content-wrapper__input--disabled"],m.disabled)),Y=i(s["textarea__counter-wrapper"],(a(v={},s["textarea__counter-wrapper--on-dark"],G),a(v,s["textarea__counter-wrapper--invalid"],Q),v)),Z=C?d():void 0;return o((function(){var e,a,r;if(k&&(null===(e=A.current)||void 0===e?void 0:e.children)&&(null===(a=A.current)||void 0===a?void 0:a.children[0])){var t=null===(r=A.current)||void 0===r?void 0:r.children[0];D(t)}}),[]),t.createElement("div",{"data-testid":x,className:S},C&&t.createElement("div",{className:U},t.createElement("label",{htmlFor:Z},C),L&&t.createElement("div",{className:s["textarea__after-label-children"]},L)),y&&t.createElement("div",null,y),t.createElement("div",{className:W,ref:A},t.createElement("textarea",Object.assign({rows:I,defaultValue:_,id:Z,className:X,ref:p,onChange:function(e){k&&D(e.target),z(e.target.value)},"aria-invalid":!!Q},H))),w&&t.createElement("div",{className:Y},t.createElement("p",null,"".concat(q.length,"/").concat(w," ").concat(f||"tegn"))))}));export{m as T};
|
|
2
|
+
//# sourceMappingURL=Textarea-05e33ba3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea-05e33ba3.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import r from"react";import{c as e}from"./index-9b84fabc.js";import{F as a}from"./FormGroup-
|
|
2
|
-
//# sourceMappingURL=Validation-
|
|
1
|
+
import r from"react";import{c as e}from"./index-9b84fabc.js";import{F as a}from"./FormGroup-6c545646.js";import t from"./components/Validation/styles.module.scss";var o=r.forwardRef((function(o,m){var s=o.errorSummary,n=o.className,i=e(t.validation,n);return r.createElement(r.Fragment,null,r.createElement("div",{"data-testid":o.testId,className:i},r.Children.map(o.children,(function(e){return e.type===a?r.cloneElement(e,{className:s?t["form-group-wrapper--error-sibling"]:""}):e}))),s&&r.createElement("p",{className:t.validation__errors},s))}));export{o as V};
|
|
2
|
+
//# sourceMappingURL=Validation-9bf0c0ec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Validation-9bf0c0ec.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"react";import{I as r}from"../../Icon-
|
|
1
|
+
import e from"react";import{I as r}from"../../Icon-04613a89.js";import{I as t}from"../../constants-42547490.js";import{g as o}from"../../color-acb834c6.js";import{u as a}from"../../useHover-037be19d.js";import l from"./styles.module.scss";import{c as s}from"../../index-9b84fabc.js";import"../../_tslib-51c8a283.js";import"../../index-19b48c51.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../../_rollupPluginBabelHelpers-d0752906.js";var i=function(r){var t=r.isExtraSmall,o=r.isHovered,a=e.createElement("path",{d:"M33.305 14.659v14.546h-1.3V16.948L15.804 33.149l-.919-.92 16.27-16.27-12.394.001v-1.301z"}),l=e.createElement("path",{d:"M36.52 11.537v14.545h-1.3l-.001-12.347-19.415 19.414-.919-.92 19.393-19.392-12.302.001v-1.301z"}),s=e.createElement("path",{d:"M18.76 14.426v1.768h11.83L14.719 32.065l1.251 1.25 15.801-15.801v11.691h1.768V14.426z"});return t?o?e.createElement("path",{d:"M22.076 11.122v1.769h11.736L14.819 31.884l1.252 1.25 19.015-19.015v11.782h1.769V11.122z"}):s:o?l:a},m=e.forwardRef((function(m,n){var c=m.id,d=m.href,f=m.children,p=m.className,v=m.target,h=void 0===v?"_self":v,b=m.testId,u="_blank"===h,j=a(n,void 0,!1),E=j.hoverRef,g=j.isHovered,_=s(l.anchorlink,null!=p?p:"");return e.createElement("a",{id:c,href:d,className:_,target:h,rel:u?"noopener noreferrer":void 0,ref:E,"data-testid":b},f,u&&e.createElement(r,{className:l.anchorlink__icon,svgIcon:i,color:o("blueberry",600),hoverColor:o("blueberry",700),size:t.XSmall,isHovered:g}))}));export default m;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import a from"react";import{I as r}from"../../Icon-
|
|
1
|
+
import a from"react";import{I as r}from"../../Icon-04613a89.js";import{I as e}from"../../constants-42547490.js";import{C as t}from"../../Check-6291ad09.js";import{c as s}from"../../index-9b84fabc.js";import o from"./styles.module.scss";import{p as c}from"../../palette-f206f488.js";import"../../_tslib-51c8a283.js";var l=a.forwardRef((function(l,m){var i=l.children,n=l.className,f=void 0===n?"":n,d=l.selected,p=void 0!==d&&d,v=l.variant,b=void 0===v?"normal":v,u=l.testId,j=i.charAt(0).toLocaleUpperCase()+i.substring(1,2);return a.createElement("span",{className:s(o.avatar,p&&o["avatar--selected"],"black"===b&&o["avatar--black"],f),ref:m,"data-testid":u},p?a.createElement(r,{svgIcon:t,size:e.Small,color:"black"===b?c.neutral900:c.blueberry600}):j)}));export default l;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAanE,oBAAY,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC7D,oBAAY,mBAAmB,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAC1F,oBAAY,UAAU,GAAG,QAAQ,GAAG,GAAG,CAAC;AACxC,oBAAY,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,YAAY,CAAC;AAE/D,UAAU,aAAa;IACrB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,OAAO,EAAE,mBAAmB,CAAC;IAC7B,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,eAAO,MAAM,aAAa,EAAE,aAI3B,CAAC;AAEF,MAAM,WAAW,WAAY,SAAQ,eAAe,EAAE,eAAe;IACnE,sCAAsC;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;IAClE,uDAAuD;IACvD,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAeD,QAAA,MAAM,MAAM,2GAwJV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as o}from"../../Button-
|
|
1
|
+
import{B as o}from"../../Button-8af0be6e.js";export{B as default,i as intentToColor}from"../../Button-8af0be6e.js";import"../../_rollupPluginBabelHelpers-d0752906.js";import"../../_tslib-51c8a283.js";import"react";import"../../color-acb834c6.js";import"../../index-19b48c51.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../../Icon-04613a89.js";import"../../constants-42547490.js";import"../../Loader-b3fd59f4.js";import"../../index-9b84fabc.js";import"../../uuid-8870ab4b.js";import"../Loader/styles.module.scss";import"../../useHover-037be19d.js";import"../../useWindowSize-73b47451.js";import"./styles.module.scss";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as t}from"../../_rollupPluginBabelHelpers-d0752906.js";import o,{useState as s}from"react";import{B as e}from"../../Button-
|
|
1
|
+
import{_ as t}from"../../_rollupPluginBabelHelpers-d0752906.js";import o,{useState as s}from"react";import{B as e}from"../../Button-8af0be6e.js";import{M as r}from"../../Modal-b7d10081.js";import"../../_tslib-51c8a283.js";import"../../color-acb834c6.js";import"../../index-19b48c51.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../../Icon-04613a89.js";import"../../constants-42547490.js";import"../../Loader-b3fd59f4.js";import"../../index-9b84fabc.js";import"../../uuid-8870ab4b.js";import"../Loader/styles.module.scss";import"../../useHover-037be19d.js";import"../../useWindowSize-73b47451.js";import"../Button/styles.module.scss";import"../Modal/styles.module.scss";import"../../AlertSignFill-e607ff43.js";import"../../Title-90910763.js";import"../Title/styles.module.scss";import"../../Close-9f68bcd0.js";import"../Close/styles.module.scss";import"../../useBreakpoint-324a9b14.js";import"react-dom";var i=o.forwardRef((function(i,m){var l=s(!1),a=t(l,2),p=a[0],n=a[1];return o.createElement("div",{"data-testid":i.testId},o.createElement(e,{onClick:function(){return n(!0)}},i.buttonText),p&&o.createElement(r,Object.assign({},i,{onClose:function(){return n(!1)}})))}));export default i;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -112,25 +112,25 @@
|
|
|
112
112
|
"required": false,
|
|
113
113
|
"type": {
|
|
114
114
|
"name": "enum",
|
|
115
|
-
"raw": "\"
|
|
115
|
+
"raw": "\"onwhite\" | \"ongrey\" | \"onblueberry\" | \"ondark\" | \"oninvalid\" | undefined",
|
|
116
116
|
"value": [
|
|
117
117
|
{
|
|
118
118
|
"value": "undefined"
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
|
-
"value": "\"
|
|
121
|
+
"value": "\"onwhite\""
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
|
-
"value": "\"
|
|
124
|
+
"value": "\"ongrey\""
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
|
-
"value": "\"
|
|
127
|
+
"value": "\"onblueberry\""
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
|
-
"value": "\"
|
|
130
|
+
"value": "\"ondark\""
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
|
-
"value": "\"
|
|
133
|
+
"value": "\"oninvalid\""
|
|
134
134
|
}
|
|
135
135
|
]
|
|
136
136
|
}
|
|
@@ -190,16 +190,16 @@
|
|
|
190
190
|
"required": false,
|
|
191
191
|
"type": {
|
|
192
192
|
"name": "enum",
|
|
193
|
-
"raw": "\"
|
|
193
|
+
"raw": "\"normal\" | \"bigform\" | undefined",
|
|
194
194
|
"value": [
|
|
195
195
|
{
|
|
196
196
|
"value": "undefined"
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
|
-
"value": "\"
|
|
199
|
+
"value": "\"normal\""
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
|
-
"value": "\"
|
|
202
|
+
"value": "\"bigform\""
|
|
203
203
|
}
|
|
204
204
|
]
|
|
205
205
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as o}from"../../Checkbox-
|
|
1
|
+
import{C as o}from"../../Checkbox-fb5dff56.js";export{C as Checkbox,C as default}from"../../Checkbox-fb5dff56.js";import"../../_rollupPluginBabelHelpers-d0752906.js";import"react";import"../../index-9b84fabc.js";import"../../uuid-8870ab4b.js";import"../../Check-6291ad09.js";import"../../Icon-04613a89.js";import"../../_tslib-51c8a283.js";import"../../constants-42547490.js";import"../../color-acb834c6.js";import"../../index-19b48c51.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"./styles.module.scss";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as s}from"../../Close-
|
|
1
|
+
import{C as s}from"../../Close-9f68bcd0.js";export{C as default}from"../../Close-9f68bcd0.js";import"react";import"../../palette-f206f488.js";import"../../Icon-04613a89.js";import"../../_tslib-51c8a283.js";import"../../constants-42547490.js";import"./styles.module.scss";import"../../useBreakpoint-324a9b14.js";import"../../_rollupPluginBabelHelpers-d0752906.js";import"../../useWindowSize-73b47451.js";import"../../grid-11a70eb7.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,a as t}from"../../_rollupPluginBabelHelpers-d0752906.js";import n,{useState as a,useEffect as r}from"react";import{I as i}from"../../Icon-
|
|
1
|
+
import{_ as e,a as t}from"../../_rollupPluginBabelHelpers-d0752906.js";import n,{useState as a,useEffect as r}from"react";import{I as i}from"../../Icon-04613a89.js";import{I as l}from"../../constants-42547490.js";import{u as o}from"../../useHover-037be19d.js";import{u as d,B as s}from"../../useBreakpoint-324a9b14.js";import{c}from"../../index-9b84fabc.js";import m from"./styles.module.scss";import"../../_tslib-51c8a283.js";import"../../useWindowSize-73b47451.js";import"../../grid-11a70eb7.js";var p=function(e){var t=e.isExtraSmall,a=e.isHovered,r=n.createElement("path",{d:"M15.049 30.277l-1.419-1.409 10.371-10.451L34.37 28.868l-1.419 1.409L24 21.257z"}),i=n.createElement("path",{d:"M24.001 10.14L36.37 22.591 34.951 24 25 13.985V35h-2V13.985L13.049 24l-1.419-1.409z"}),l=n.createElement("path",{d:"M32.577 30.115l1.793-1.779-10.371-10.451L13.63 28.336l1.793 1.779 8.576-8.644z"});return t?a?n.createElement("path",{d:"M23.999 9.043L36.897 22.02l-1.794 1.78-9.841-9.9.001 20.205h-2.526L22.736 13.9l-9.839 9.9-1.794-1.78z"}):l:a?i:r},u=function(e){var t=e.isExtraSmall,a=e.isHovered,r=n.createElement("path",{d:"M32.951 18.788l1.419 1.409-10.371 10.451L13.63 20.197l1.419-1.409L24 27.809z"}),i=n.createElement("path",{d:"M25 13v20.083l9.951-10.013 1.419 1.409L23.999 36.93 11.63 24.479l1.419-1.409L23 33.085V13z"}),l=n.createElement("path",{d:"M32.577 17.885l1.793 1.779-10.371 10.451L13.63 19.664l1.793-1.779 8.576 8.644z"});return t?a?n.createElement("path",{d:"M25 13v20.083l9.951-10.013 1.419 1.409L23.999 36.93 11.63 24.479l1.419-1.409L23 33.085V13z"}):l:a?i:r},f=n.forwardRef((function(e,a){var r,f=e.id,v=e.children,x=e.padding,E=void 0===x||x,h=e.color,g=void 0===h?"neutral":h,_=e.className,b=void 0===_?"":_,L=e.icon,k=e.large,j=void 0!==k&&k,z=e.title,N=e.isExpanded,H=void 0!==N&&N,w=e.testId,M=e.handleExpanderClick,I=o(),B=I.hoverRef,C=I.isHovered,S=d(),O=c(m["expander-list-link"],m["expander-list-link--".concat(g)],(t(r={},m["expander-list-link--closed"],!H),t(r,m["expander-list-link--large"],j),r)),V=c(m["expander-list-link__main-content"],E?m["expander-list-link__main-content--padding"]:"");return n.createElement("li",{className:b,ref:a},n.createElement("button",{id:f,onClick:M,"data-testid":w,className:O,ref:B},L&&n.createElement("span",{className:m["expander-list-link__icon"]},n.cloneElement(L,{size:S===s.Xs?l.XSmall:l.Small,isHovered:C})),n.createElement("span",{className:m["expander-list-link__title"]},z),n.createElement("span",{className:m["expander-list-link__chevron"]},n.createElement(i,{size:l.XSmall,svgIcon:H?p:u,isHovered:C}))),H?n.createElement("div",{className:V},v):null)})),v=n.forwardRef((function(i,l){var o=i.children,d=i.childPadding,s=void 0===d||d,p=i.large,u=i.isOpen,v=void 0!==u&&u,x=i.color,E=i.className,h=void 0===E?"":E,g=i.accordion,_=void 0!==g&&g,b=i.topBorder,L=void 0===b||b,k=i.bottomBorder,j=void 0===k||k,z=i.testId,N=a({}),H=e(N,2),w=H[0],M=H[1],I=a(),B=e(I,2),C=B[0],S=B[1],O=n.Children.count(o),V=c(m["expander-list"],h);return r((function(){var e,t,n,a,r;!_||!C||(e=C.getBoundingClientRect(),t=e.top,n=e.left,a=e.bottom,r=e.right,t>=0&&n>=0&&a<=(window.innerHeight||document.documentElement.clientHeight)&&r<=(window.innerWidth||document.documentElement.clientWidth))||C.scrollIntoView()}),[_,C]),r((function(){if(v){var e="expander-0";M((function(n){return _?t({},e,!n[e]):Object.assign(Object.assign({},n),t({},e,!n[e]))}))}}),[v]),n.createElement("ul",{className:V,ref:l,"data-testid":z},n.Children.map(o,(function(e,a){if(e.type===f){var r=w["expander-".concat(a)],i=function(e){var n;return c(m["expander-list__item"],(t(n={},m["expander-list__item--top"],0===e&&L),t(n,m["expander-list__item--no-bottom"],e===O-1&&!j),n))}(a);return n.cloneElement(e,{id:"expander-".concat(a),key:"expander-".concat(a),isExpanded:r,padding:s,color:x,large:p,"aria-expanded":r,className:i,handleExpanderClick:function(e){return function(e,n){M((function(e){return _?t({},n,!e[n]):Object.assign(Object.assign({},e),t({},n,!e[n]))})),S(e.currentTarget)}(e,"expander-".concat(a))}})}return e})))}));v.Expander=f,f.displayName="ExpanderList.Expander";export default v;export{v as ExpanderList};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -8,7 +8,8 @@ export declare enum FormExampleVariants {
|
|
|
8
8
|
formgroup = "formgroup",
|
|
9
9
|
checkbox = "checkbox",
|
|
10
10
|
radiobutton = "radiobutton",
|
|
11
|
-
textarea = "textarea"
|
|
11
|
+
textarea = "textarea",
|
|
12
|
+
input = "input"
|
|
12
13
|
}
|
|
13
14
|
export declare const FormExample: (props: FormExampleProps) => JSX.Element;
|
|
14
15
|
export default FormExample;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormExample.d.ts","sourceRoot":"","sources":["../../../src/components/FormExample/FormExample.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormExample.d.ts","sourceRoot":"","sources":["../../../src/components/FormExample/FormExample.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C,UAAU,gBAAgB;IACxB,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,OAAO,WAAW,CAAC;CACpC;AAED,oBAAY,mBAAmB;IAC7B,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AAED,eAAO,MAAM,WAAW,0CAkIvB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"value": "\"textarea\""
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"value": "\"input\""
|
|
33
36
|
}
|
|
34
37
|
]
|
|
35
38
|
}
|
|
@@ -51,16 +54,16 @@
|
|
|
51
54
|
"required": false,
|
|
52
55
|
"type": {
|
|
53
56
|
"name": "enum",
|
|
54
|
-
"raw": "\"
|
|
57
|
+
"raw": "\"normal\" | \"bigform\" | undefined",
|
|
55
58
|
"value": [
|
|
56
59
|
{
|
|
57
60
|
"value": "undefined"
|
|
58
61
|
},
|
|
59
62
|
{
|
|
60
|
-
"value": "\"
|
|
63
|
+
"value": "\"normal\""
|
|
61
64
|
},
|
|
62
65
|
{
|
|
63
|
-
"value": "\"
|
|
66
|
+
"value": "\"bigform\""
|
|
64
67
|
}
|
|
65
68
|
]
|
|
66
69
|
}
|
|
@@ -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-ef9ee0ae.js";import{F as c}from"../../FormGroup-68288be3.js";import{C as l}from"../../Checkbox-0ba01292.js";import{B as f}from"../../Button-72f96290.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-90910763.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-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";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",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)},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 F(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 F(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||F(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(!(F(l)&&F(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);F(T.value)||(B=W>T.value),F(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=!F(H.value)&&a.length>H.value,G=!F(_.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(x,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({}),x=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}),xr=n(kr),Fr=n(),Rr=n(Vr(o)).current,Cr=Rr.isOnBlur,Nr=Rr.isOnChange;J.current=c,K.current=s,xr.current=kr,P.current=d?{}:Y(P.current)?Or(l):P.current;var Br=t((function(r){void 0===r&&(r={}),R.current||(xr.current=Object.assign(Object.assign({},xr.current),r),Sr(xr.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:xr.current.errors,error:e,name:r,validFields:D.current,fieldsWithValidation:S.current}),u=W(xr.current.errors,r);e?(rr(D.current,r),a=a||!u||!ir(u,e,!0),T(xr.current.errors,r,e)):((W(S.current,r)||K.current)&&(T(D.current,r,!0),a=a||u),rr(xr.current.errors,r)),(a&&!F(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)&&F(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,x.current)}return!1}),[]),Wr=t((function(r,e){if(void 0===e&&(e=!0),Dr.current.isDirty||Dr.current.dirtyFields){var t=!ir(W(x.current,r),Q(y,r,P)),n=W(xr.current.dirtyFields,r),i=xr.current.isDirty;t?T(xr.current.dirtyFields,r,!0):rr(xr.current.dirtyFields,r);var a={isDirty:Mr(),dirtyFields:xr.current.dirtyFields},u=Dr.current.isDirty&&i!==a.isDirty||Dr.current.dirtyFields&&n!==W(xr.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=xr.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=W(e,r);return t?T(xr.current.errors,r,t):rr(xr.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&&(xr.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(xr.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(x.current,r,[]),W(xr.current.dirtyFields,r,[]))),Br({isDirty:!ir(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),x.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(xr.current.touched,a),isSubmitted:xr.current.isSubmitted},sr.current)),c=Wr(a,!1),l=!Y(c)||!o&&$r(a);if(o&&!W(xr.current.touched,a)&&Dr.current.touched&&(T(xr.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:xr.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=xr.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(xr.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)?x.current:{},t=(await K.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),J.current,vr)||{}).errors,n=Y(t);xr.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(xr.current.errors,r.ref.name),T(xr.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(x.current,r))?e:W(x.current,r),!0)}var u=M(e)?x.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(x.current)&&h||(t=W(h?x.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=xr.current.isValid;Y(r)?T(D.current,n,!0):rr(D.current,n),e!==Y(r)&&Br()}))),!d||c&&v||!c&&rr(xr.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;xr.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(xr.current.errors,v),T(D.current,v,!0))}}Y(n)&&Object.keys(xr.current.errors).every((function(r){return r in y.current}))?(Br({errors:{},isSubmitting:!0}),await r(i,t)):(xr.current.errors=Object.assign(Object.assign({},xr.current.errors),n),e&&await e(xr.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,xr.current.errors))}finally{xr.current.isSubmitting=!1,Br({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Y(xr.current.errors),submitCount:xr.current.submitCount+1})}}}),[f,vr]);a((function(){s&&Dr.current.isValid&&Kr(),Fr.current=Fr.current||!hr?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&&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,x.current]),a((function(){return function(){Fr.current&&Fr.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(xr.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)}}),[x.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:xr,defaultValuesRef:x,shallowFieldsStateRef:P,fieldArrayValuesRef:A},te)}),[x.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={},x.current=Object.assign({},r||x.current),r&&Gr(""),Object.values(I.current).forEach((function(r){return lr(r)&&r()})),P.current=d?{}:Or(r||x.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?xr.current.submitCount:0,isDirty:!!t&&xr.current.isDirty,isSubmitted:!!n&&xr.current.isSubmitted,isValid:!!a&&xr.current.isValid,dirtyFields:o?xr.current.dirtyFields:{},touched:i?xr.current.touched:{},errors:e?xr.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 xr.current.errors[r]:rr(xr.current.errors,r)})),Br({errors:r?xr.current.errors:{}})}),[]),setError:t((function(r,e){var t=(y.current[r]||{}).ref;T(xr.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={}));var Sr=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"))};export default Sr;export{Sr as FormExample,jr 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-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
|