@helsenorge/designsystem-react 1.0.0-beta104 → 1.0.0-beta105
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-f26a558e.js +2 -0
- package/Button-f26a558e.js.map +1 -0
- package/{Modal-ad02991b.js → Modal-1bae215e.js} +2 -2
- package/Modal-1bae215e.js.map +1 -0
- package/components/Button/Button.d.ts +2 -0
- package/components/Button/Button.d.ts.map +1 -1
- package/components/Button/componentdata.json +19 -0
- package/components/Button/index.js +1 -1
- package/components/ButtonWithModal/index.js +1 -1
- package/components/Expander/index.js +1 -1
- package/components/FormExample/index.js +1 -1
- package/components/Modal/index.js +1 -1
- package/package.json +1 -1
- package/Button-d5147e38.js +0 -2
- package/Button-d5147e38.js.map +0 -1
- package/Modal-ad02991b.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as t,b as e}from"./_rollupPluginBabelHelpers-b8ef6dd9.js";import{_ as n}from"./_tslib-51c8a283.js";import o from"react";import{A as r,I as i}from"./constants-ad6c82db.js";import{g as l}from"./color-a10c7892.js";import"./Icon-89da8de4.js";import{L as a}from"./Loader-fa16a352.js";import{u as s}from"./useHover-9710204a.js";import{u as d}from"./useWindowSize-750f9b68.js";import{b as u}from"./grid-11a70eb7.js";import{c}from"./index-9b84fabc.js";import m from"./components/Button/styles.module.scss";var b={primary:"blueberry",warning:"banana",danger:"cherry"},f=function(t,e){return e&&e<u.md&&t?i.Small:t?i.Medium:i.XSmall},p=o.forwardRef((function(u,p){var v,_,g,h=u.id,j=u.children,w=u.className,E=void 0===w?"":w,y=u.fluid,k=void 0!==y&&y,N=u.intent,I=void 0===N?"primary":N,B=u.inverted,C=void 0!==B&&B,H=u.htmlMarkup,O=void 0===H?"button":H,S=u.onClick,z=u.large,F=void 0!==z&&z,M=u.loading,x=void 0!==M&&M,A=u.variant,L=void 0===A?"fill":A,R=u.disabled,X=void 0!==R&&R,P=u.ellipsis,W=void 0!==P&&P,q=u.testId,D=u.href,G=u.target,J=n(u,["id","children","className","fluid","intent","inverted","htmlMarkup","onClick","large","loading","variant","disabled","ellipsis","testId","href","target"]),K=function(t){var e,n,o,r,i=null,l=null;void 0!==(null===(n=null===(e=t[0])||void 0===e?void 0:e.props)||void 0===n?void 0:n.svgIcon)&&(i=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)&&(l=t.pop());var a=t.filter((function(t){return t}));return[i,l,a.length>0?a:null]}(o.Children.toArray(j)),Q=t(K,3),T=Q[0],U=Q[1],V=Q[2],Y=s(p),Z=Y.hoverRef,$=Y.isHovered,tt=function(t,e,n,o,r){return e?l("neutral",600):t&&!o||!t&&o?"white":l(b[n],r?700:600)}("fill"===L,X,I,C,$),et=d(),nt="fill"===L,ot="outline"===L,rt="borderless"===L,it="warning"===I,lt="danger"===I,at=!(!T&&!U||x),st=Object.assign({},J),dt=c(m.button,(e(v={},m["button--fluid"],k),e(v,m["button--large"],F),e(v,m["button--warning"],it),e(v,m["button--danger"],lt),e(v,m["button--inverted"],C),e(v,m["button--fill"],nt),e(v,m["button--outline"],ot),e(v,m["button--borderless"],rt),e(v,m["button--with-icon"],at),e(v,m["button--ellipsis"],W),v),E),ut=c(m.button__content,(e(_={},m["button__content--warning"],it),e(_,m["button__content--danger"],lt),e(_,m["button__content--fill"],nt),e(_,m["button__content--borderless"],rt),e(_,m["button__content--with-icon"],at),e(_,m["button__content--large"],F),e(_,m["button__content--ellipsis"],W),e(_,m["button__content--inverted"],C),e(_,m["button__content--fluid"],k),_)),ct=c(m["button__left-fluid-content"],(e(g={},m["button__left-fluid-content--with-icon"],at),e(g,m["button__left-fluid-content--large"],F),g));function mt(t,e,n,r){var i=t&&t.props&&t.props.color?t.props.color:n;return t&&Object.keys(t).length>0?o.cloneElement(t,{size:e,color:i,isHovered:r}):null}var bt=function(){return V?o.createElement("span",{className:ut},V):null},ft=function(){return o.createElement("span",{className:m["content-wrapper"]},x?o.createElement("div",{className:m["button__left-fluid-content"]},o.createElement(a,{testId:"test-id-loader",color:"fill"!==L||C?b[I]:"white",size:"tiny"})):o.createElement(o.Fragment,null,k?o.createElement("div",{className:ct},mt(T,f(F,et.width),tt,$),bt()):o.createElement(o.Fragment,null,mt(T,f(F,et.width),tt,$),bt()),mt(U,i.XSmall,tt,$)))};return o.createElement(o.Fragment,null,"button"===O&&o.createElement("button",Object.assign({id:h,onClick:S,disabled:X,"data-testid":q,"data-analyticsid":r.Button,className:dt,ref:Z},st),ft()),"a"===O&&o.createElement("a",Object.assign({id:h,onClick:S,"data-testid":q,"data-analyticsid":r.Button,className:dt,href:D,target:G,rel:"_blank"===G?"noopener noreferrer":u.rel,ref:Z},J),ft()))}));export{p as B,b as i};
|
|
2
|
+
//# sourceMappingURL=Button-f26a558e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button-f26a558e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,b as a}from"./_rollupPluginBabelHelpers-b8ef6dd9.js";import t,{useEffect as r}from"react";import{c as l}from"./index-9b84fabc.js";import{p as n}from"./palette-f206f488.js";import{B as o}from"./Button-
|
|
2
|
-
//# sourceMappingURL=Modal-
|
|
1
|
+
import{_ as e,b as a}from"./_rollupPluginBabelHelpers-b8ef6dd9.js";import t,{useEffect as r}from"react";import{c as l}from"./index-9b84fabc.js";import{p as n}from"./palette-f206f488.js";import{B as o}from"./Button-f26a558e.js";import{I as s}from"./Icon-89da8de4.js";import{A as i,Z as c,I as d}from"./constants-ad6c82db.js";import m from"./components/Modal/styles.module.scss";import{A as u,a as p}from"./AlertSignFill-e607ff43.js";import{b as f,u as v}from"./useIsVisible-a1f67a11.js";import{T as _}from"./Title-af53f589.js";import{u as E}from"./uuid-fe7442b7.js";import{C as b}from"./Close-35ad7d35.js";import{createPortal as h}from"react-dom";var g,y,N=function(e){e.isExtraSmall;var a=e.isHovered,r=t.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 a?t.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 C(e){var a=e.children,r=e.parent,l=e.className,n=e.testId,o=t.useMemo((function(){return document.createElement("div")}),[]);return o.setAttribute("data-analyticsid",i.Portal),n&&o.setAttribute("data-testid",n),t.useEffect((function(){var e=r&&r.appendChild?r:document.body,a=["portal-container"];return l&&l.split(" ").forEach((function(e){return a.push(e)})),a.forEach((function(e){return o.classList.add(e)})),e.appendChild(o),function(){e.removeChild(o)}}),[o,r,l]),h(a,o)}!function(e){e.normal="normal",e.warning="warning",e.error="error",e.success="success",e.image="image"}(g||(g={})),function(e){e.large="large",e.medium="medium"}(y||(y={}));var w={variant:g.normal,primaryButtonText:"OK",titleId:E(),className:"",size:y.large,zIndex:c.Modal},B=function(e,a){var r=function(e){return e===g.error?t.createElement(s,{size:d.Small,svgIcon:u,color:n.cherry500}):e===g.warning?t.createElement(s,{size:d.Small,svgIcon:p,color:n.black}):e===g.success?t.createElement(s,{size:d.Small,svgIcon:N,color:n.kiwi900}):null}(e);return r?t.createElement("div",{className:m.modal__iconWrapper},r):a?t.createElement("div",{className:m.modal__iconWrapper},t.cloneElement(a,{size:d.Small})):null},I=function(n){var s,c,d,u=t.useState(0),p=e(u,2),E=p[0],h=p[1],y=t.useRef(null),N=t.useRef(null),w=t.useRef(null),I=f(N),z=t.useRef(null),x=f(z),L=w.current&&w.current.scrollHeight>w.current.clientHeight;function T(e){"Escape"===e.key&&n.onClose&&(e.stopPropagation(),n.onClose())}function W(e){e.target&&k.current===e.target&&n.onClose&&(e.stopPropagation(),n.onClose())}var j=n.variant===g.image,k=t.useRef(null),S=n.secondaryButtonText&&(null===(c=n.secondaryButtonText)||void 0===c?void 0:c.length)>0||n.onSuccess,M=n.ariaLabelledBy?void 0:n.ariaLabel,P=n.ariaLabelledBy?n.ariaLabelledBy:n.ariaLabel?void 0:n.titleId;r((function(){var e,a=k.current;return null===(e=y.current)||void 0===e||e.focus(),document.body.style.overflow="hidden",n.disableCloseEvents||!a||S||(a.addEventListener("keydown",T),a.addEventListener("click",W)),function(){document.body.style.removeProperty("overflow"),n.disableCloseEvents||!a||S||(a.removeEventListener("keydown",T),a.removeEventListener("click",W))}}),[]);var A=l((a(s={},m["modal__title--error"],n.variant===g.error),a(s,m["modal__title--success"],n.variant===g.success),s)),R=t.createElement("div",{"data-testid":"dialog-container"},t.createElement("div",{ref:k,className:m["modal-overlay"],"data-testid":n.testId,"data-analyticsid":i.Modal,style:{zIndex:n.zIndex}},t.createElement("div",{className:m.align,ref:v()},t.createElement("div",{className:l(n.className,m.modal,m["modal--".concat(n.variant)],m["modal--".concat(n.size)]),role:"dialog","aria-label":M,"aria-labelledby":P},t.createElement("div",{tabIndex:E,ref:y,onBlur:function(){return h(-1)}}),t.createElement("div",{className:l(m.modal__shadow,m["modal__shadow--top"],a({},m["modal__shadow--show"],!I&&L))}),t.createElement("div",{className:l(m.modal__contentWrapper,a({},m["modal__contentWrapper--image"],j)),ref:w},!n.noCloseButton&&t.createElement("div",{className:m.modal__closeWrapper},t.createElement("div",{className:l(m.modal__closeWrapper__close)},t.createElement(b,{onClick:n.onClose,ariaLabel:n.ariaLabelCloseBtn}))),t.createElement("div",{className:l(m["modal__contentWrapper__scroll--".concat(n.size)],a({},m["modal__contentWrapper__scroll--image"],j))},t.createElement("div",{ref:N}),t.createElement("div",{className:m.modal__contentWrapper__title},B(n.variant,n.icon),t.createElement(_,{id:P,htmlMarkup:"h3",appearance:"title3",className:A},n.title),n.afterTitleChildren&&t.createElement("div",{className:m.modal__afterTitleChildren},n.afterTitleChildren)),j&&t.createElement("div",null,t.createElement("div",{className:m.modal__contentWrapper__imageWrapper},n.children),t.createElement("span",{className:m.modal__contentWrapper__imageDescription},n.description)),!j&&n.children&&t.createElement("div",null,n.children),!j&&!n.children&&t.createElement("p",{className:m.modal__description},n.description),t.createElement("div",{ref:z}))),t.createElement("div",{className:l(m.modal__shadow,m["modal__shadow--bottom"],a({},m["modal__shadow--show"],!x&&L))}),S&&t.createElement("div",{className:l(m["modal__call-to-action"],m["modal__call-to-action--".concat(n.size)])},n.onSuccess&&t.createElement(o,{onClick:n.onSuccess},n.primaryButtonText),n.secondaryButtonText&&(null===(d=n.secondaryButtonText)||void 0===d?void 0:d.length)>0&&t.createElement(o,{variant:"borderless",onClick:n.onClose},n.secondaryButtonText))))));if(n.printable){return t.createElement(C,{className:"print-modal",testId:"print-modal"},t.createElement("style",{media:"print"},"body > *:not(.".concat("print-modal",") {display: none;}")),R)}return R};I.defaultProps=w;export{I as M,g as a,y as b};
|
|
2
|
+
//# sourceMappingURL=Modal-1bae215e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal-1bae215e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -11,6 +11,8 @@ interface IntentToColor {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const intentToColor: IntentToColor;
|
|
13
13
|
export interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps {
|
|
14
|
+
/** Gives a unique id to the button */
|
|
15
|
+
id?: string;
|
|
14
16
|
/** Sets the content of the button. */
|
|
15
17
|
children: React.ReactNode;
|
|
16
18
|
/** Adds custom classes to the element. */
|
|
@@ -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;AAahF,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,
|
|
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;AAahF,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,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,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,2GA6JV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"props": {
|
|
3
|
+
"id": {
|
|
4
|
+
"defaultValue": null,
|
|
5
|
+
"description": "Gives a unique id to the button",
|
|
6
|
+
"name": "id",
|
|
7
|
+
"parent": {
|
|
8
|
+
"fileName": "src/components/Button/Button.tsx",
|
|
9
|
+
"name": "ButtonProps"
|
|
10
|
+
},
|
|
11
|
+
"declarations": [
|
|
12
|
+
{
|
|
13
|
+
"fileName": "src/components/Button/Button.tsx",
|
|
14
|
+
"name": "ButtonProps"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"required": false,
|
|
18
|
+
"type": {
|
|
19
|
+
"name": "string"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
3
22
|
"children": {
|
|
4
23
|
"defaultValue": null,
|
|
5
24
|
"description": "Sets the content of the button.",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as o}from"../../Button-
|
|
1
|
+
import{B as o}from"../../Button-f26a558e.js";export{B as default,i as intentToColor}from"../../Button-f26a558e.js";import"../../_rollupPluginBabelHelpers-b8ef6dd9.js";import"../../_tslib-51c8a283.js";import"react";import"../../constants-ad6c82db.js";import"../../color-a10c7892.js";import"../../index-0e78dfa0.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../../Icon-89da8de4.js";import"../../Loader-fa16a352.js";import"../../index-9b84fabc.js";import"../../uuid-fe7442b7.js";import"../Loader/styles.module.scss";import"../../useHover-9710204a.js";import"../../useWindowSize-750f9b68.js";import"./styles.module.scss";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as t}from"../../_rollupPluginBabelHelpers-b8ef6dd9.js";import
|
|
1
|
+
import{_ as t}from"../../_rollupPluginBabelHelpers-b8ef6dd9.js";import e,{useState as s}from"react";import{B as o}from"../../Button-f26a558e.js";import{M as r}from"../../Modal-1bae215e.js";import"../../_tslib-51c8a283.js";import"../../constants-ad6c82db.js";import"../../color-a10c7892.js";import"../../index-0e78dfa0.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../../Icon-89da8de4.js";import"../../Loader-fa16a352.js";import"../../index-9b84fabc.js";import"../../uuid-fe7442b7.js";import"../Loader/styles.module.scss";import"../../useHover-9710204a.js";import"../../useWindowSize-750f9b68.js";import"../Button/styles.module.scss";import"../Modal/styles.module.scss";import"../../AlertSignFill-e607ff43.js";import"../../useIsVisible-a1f67a11.js";import"../../Title-af53f589.js";import"../Title/styles.module.scss";import"../../Close-35ad7d35.js";import"../Close/styles.module.scss";import"../../useBreakpoint-552af2b9.js";import"react-dom";var i=e.forwardRef((function(i,a){var m=s(!1),l=t(m,2),p=l[0],d=l[1];return e.createElement("div",{"data-testid":i.testId},e.createElement(o,{onClick:function(){return d(!0)}},i.buttonText),p&&e.createElement(r,Object.assign({},i,{onClose:function(){return d(!1)}})))}));export default i;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-b8ef6dd9.js";import t,{useState as a,useRef as n,useEffect as r}from"react";import{I as o}from"../../Icon-89da8de4.js";import{Z as s,A as i,I as d}from"../../constants-ad6c82db.js";import{u as l}from"../../useHover-9710204a.js";import c from"./styles.module.scss";import{c as p}from"../../index-9b84fabc.js";import{C as m,a as _}from"../../ChevronUp-4b6797ef.js";import{B as u}from"../../Button-
|
|
1
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-b8ef6dd9.js";import t,{useState as a,useRef as n,useEffect as r}from"react";import{I as o}from"../../Icon-89da8de4.js";import{Z as s,A as i,I as d}from"../../constants-ad6c82db.js";import{u as l}from"../../useHover-9710204a.js";import c from"./styles.module.scss";import{c as p}from"../../index-9b84fabc.js";import{C as m,a as _}from"../../ChevronUp-4b6797ef.js";import{B as u}from"../../Button-f26a558e.js";import{b as x,u as f}from"../../useSticky-194f2b78.js";import"../../_tslib-51c8a283.js";import"../../color-a10c7892.js";import"../../index-0e78dfa0.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../../Loader-fa16a352.js";import"../../uuid-fe7442b7.js";import"../Loader/styles.module.scss";import"../../useWindowSize-750f9b68.js";import"../Button/styles.module.scss";var g;!function(e){e.small="small",e.large="large"}(g||(g={}));export default function(v){var b=v.title,j=v.children,E=v.size,y=void 0===E?g.small:E,I=v.color,N=v.svgIcon,h=v.expanded,k=void 0!==h&&h,z=v.noNestedLine,H=void 0!==z&&z,S=v.sticky,w=void 0!==S&&S,B=v.testId,C=v.onExpand,L=a(k),W=e(L,2),X=W[0],T=W[1],A=n(null),O=n(null),P=n(null),U=l(O).isHovered,Z=x(A,O),q=Z.isOutsideWindow,D=Z.isLeavingWindow,F=Z.offsetHeight,G=Z.contentWidth;f(P,X);var J=w&&X&&q;r((function(){k!==X&&T(k)}),[k]),r((function(){C&&C(!!X)}),[X,C]);var K=function(e){return t.createElement("span",{className:p(c.expander__icon,c["expander__icon--".concat(e)])},t.createElement(o,{svgIcon:X?m:_,size:d.XSmall,isHovered:U}))},M=p(c.expander__trigger,c["expander__trigger--".concat(y)],y===g.large&&c["expander__trigger--".concat(I||"neutral")],y===g.large&&N&&c["expander__trigger--icon"],X&&c["expander__trigger--expanded"],J&&!D&&c["expander__trigger--sticky"],J&&D&&c["expander__trigger--absolute"]),Q=p(c.expander__button,X&&c["expander__button--expanded"],J&&!D&&c["expander__button--sticky"],J&&D&&c["expander__button--absolute"]),R=p(c.expander__content,c["expander__content--".concat(y)],y===g.large&&c["expander__content--".concat(I||"neutral")],y===g.large&&N&&c["expander__content--icon"],X&&c["expander__content--expanded"],y===g.small&&!H&&c["expander__content--nested-line"]);return t.createElement("div",{className:c.expander,ref:A,style:{paddingTop:J&&F?"".concat(F,"px"):void 0}},y===g.large?t.createElement("button",{className:M,style:{zIndex:U||J?s.ExpanderTrigger:void 0,width:J&&G?"".concat(G,"px"):void 0},"aria-expanded":X,ref:O,onClick:function(){return T(!X)},"data-testid":B,"data-analyticsid":i.Expander},y===g.small&&K("left"),N&&t.createElement("span",{className:p(c.expander__icon,c["expander__icon--left"])},t.createElement(o,{svgIcon:N,size:d.XSmall,isHovered:U})),b,y===g.large&&K("right")):t.createElement(u,{variant:"borderless",className:Q,"aria-expanded":X,ref:O,onClick:function(){return T(!X)},testId:B,"data-analyticsid":i.Expander},t.createElement(o,{svgIcon:X?m:_,size:d.XSmall}),b),t.createElement("div",{className:R,ref:P},j))}export{g as ExpanderSize};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -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-fd3f7f58.js";import{F as c}from"../../FormGroup-0577b07f.js";import{C as l}from"../../Checkbox-798282e4.js";import{B as f}from"../../Button-d5147e38.js";import{R as v}from"../../RadioButton-fe4bbd36.js";import{T as d}from"../../Textarea-e1d1144c.js";import{I as m}from"../../Input-19650c24.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../constants-ad6c82db.js";import"../../_rollupPluginBabelHelpers-b8ef6dd9.js";import"../FormGroup/styles.module.scss";import"../../Title-af53f589.js";import"../Title/styles.module.scss";import"../../uuid-fe7442b7.js";import"../../Check-6291ad09.js";import"../../Icon-89da8de4.js";import"../../_tslib-51c8a283.js";import"../../color-a10c7892.js";import"../../index-0e78dfa0.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../Checkbox/styles.module.scss";import"../../Loader-fa16a352.js";import"../Loader/styles.module.scss";import"../../useHover-9710204a.js";import"../../useWindowSize-750f9b68.js";import"../Button/styles.module.scss";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../../useBreakpoint-552af2b9.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",k="all",E="max",A="min",x="maxLength",S="minLength",z="pattern",w="required",D="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 I(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 L=function(r,e){for(var t in void 0===e&&(e={}),r)H(t)?e[t]=r[t]:I(e,t,r[t]);return e},M=function(r){return void 0===r},T=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 M(n)||n===r?M(r[e])?t:r[e]:n},q=function(r,e){h(r)&&r.removeEventListener&&(r.removeEventListener(b,e),r.removeEventListener(p,e),r.removeEventListener(g,e))},W={isValid:!1,value:null},_=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),W):W},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&&!M(a.value)?M(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)?_(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 T(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=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)&&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],T(e[u]||{},o,[]),t[u][o],t[u],o)):ar(T(e[u]||{},o),r[u][o])?I(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){(M(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?L(a):ir(e,L(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=x),void 0===a&&(a=S);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&&!_(u).isValid)){var j=vr(o)?{value:!!o,message:o}:lr(o),k=j.value,R=j.message;if(k&&(h[m]=Object.assign({type:w,message:R,ref:b?((r.current[m].options||[])[0]||{}).ref:i},V(w,R)),!e))return h}if(!(F(l)&&F(f)||""===a)){var H,N,B=lr(f),I=lr(l);if(isNaN(a)){var L=i.valueAsDate||new Date(a);or(B.value)&&(H=L>new Date(B.value)),or(I.value)&&(N=L<new Date(I.value))}else{var M=i.valueAsNumber||parseFloat(a);F(B.value)||(H=M>B.value),F(I.value)||(N=M<I.value)}if((H||N)&&(O(!!H,B.message,I.message,E,A),!e))return h}if(or(a)&&!y&&(s||c)){var T=lr(s),q=lr(c),W=!F(T.value)&&a.length>T.value,U=!F(q.value)&&a.length<q.value;if((W||U)&&(O(W,T.message,q.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:z,message:K,ref:i},V(z,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(D,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=T(r,e),(C(a)||Array.isArray(a))&&gr(e,a).forEach((function(r){return t.add(r)}))),M(a)?i?n:T(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===k,isOnTouch:r===j}},kr=function(r){return P(r)||$(r)},Er="undefined"==typeof window,Ar=Vr?"Proxy"in window:"undefined"!=typeof Proxy;function xr(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({}),E=n(new Set),A=n({}),x=n({}),S=n({}),z=n({}),w=n(l),D=n(!1),R=n(!1),B=n(),W=n({}),_=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===k,mr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!lr,errors:{}}),xr=mr[0],Sr=mr[1],zr=n({isDirty:!Ar,dirtyFields:!Ar,touched:!Ar||vr,isValidating:!Ar,isSubmitting:!Ar,isValid:!Ar}),wr=n(xr),Dr=n(),Fr=n(jr(o)).current,Rr=Fr.isOnBlur,Cr=Fr.isOnChange;J.current=c,K.current=s,wr.current=xr,W.current=v?{}:Z(W.current)?Or(l):W.current;var Hr=t((function(r){void 0===r&&(r={}),D.current||(wr.current=Object.assign(Object.assign({},wr.current),r),Sr(wr.current))}),[]),Nr=function(){return zr.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=M(n),o=T(e,t);return u&&!!o||!u&&!ar(o,n,!0)||u&&T(a,t)&&!T(i,t)}({errors:wr.current.errors,error:e,name:r,validFields:z.current,fieldsWithValidation:S.current}),u=T(wr.current.errors,r);e?(er(z.current,r),a=a||!u||!ar(u,e,!0),I(wr.current.errors,r,e)):((T(S.current,r)||K.current)&&(I(z.current,r,!0),a=a||u),er(wr.current.errors,r)),(a&&!F(t)||!Z(n)||zr.current.isValidating)&&Hr(Object.assign(Object.assign(Object.assign({},n),K.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Ir=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}),[]),Lr=t((function(r,e){if(zr.current.isDirty){var t=Jr();return r&&e&&I(t,r,e),!ar(t,w.current)}return!1}),[]),Mr=t((function(r,e){if(void 0===e&&(e=!0),zr.current.isDirty||zr.current.dirtyFields){var t=!ar(T(w.current,r),X(m,r,W)),n=T(wr.current.dirtyFields,r),i=wr.current.isDirty;t?I(wr.current.dirtyFields,r,!0):er(wr.current.dirtyFields,r);var a={isDirty:Lr(),dirtyFields:wr.current.dirtyFields},u=zr.current.isDirty&&i!==a.isDirty||zr.current.dirtyFields&&n!==T(wr.current.dirtyFields,r);return u&&e&&Hr(a),u?a:{}}return{}}),[]),Tr=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],W))[r];return Br(r,t,e),M(t)}),[Br,dr]),qr=t((async function(r){var e=(await K.current(Jr(),J.current,dr)).errors,t=wr.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=T(e,r);return t?I(wr.current.errors,r,t):er(wr.current.errors,r),!t})).every(Boolean);return Hr({isValid:Z(e),isValidating:!1}),n}var i=T(e,r);return Br(r,i,t!==Z(e),{},Z(e)),!i}),[Br,dr]),Wr=t((async function(r){var e=r||Object.keys(m.current);if(Nr(),K.current)return qr(e);if(Array.isArray(e)){!r&&(wr.current.errors={});var t=await Promise.all(e.map((async function(r){return await Tr(r,null)})));return Hr({isValidating:!1}),t.every(Boolean)}return await Tr(e)}),[qr,Tr]),_r=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,a={};I(a,r,e);for(var u=0,o=gr(r,e);u<o.length;u+=1){var s=o[u];m.current[s]&&(Ir(s,T(a,s)),n&&Mr(s),i&&Wr(s))}}),[Wr,Ir,Mr]),Pr=t((function(r,e,t){var n,i;if(!v&&!nr(e)&&I(W.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),m.current[r])Ir(r,e),t.shouldDirty&&Mr(r),t.shouldValidate&&Wr(r);else if(!nr(e)&&(_r(r,e,t),Q.current.has(r))){var a=br(r)||r;I(y.current,r,e),_.current[a](((n={})[a]=T(y.current,a),n)),(zr.current.isDirty||zr.current.dirtyFields)&&t.shouldDirty&&(I(wr.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,T(w.current,r,[]),T(wr.current.dirtyFields,r,[]))),Hr({isDirty:!ar(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),w.current)}))}!v&&I(W.current,r,e)}),[Mr,Ir,_r]),Ur=function(r){return R.current||E.current.has(r)||E.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))||(x.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,W);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];I(e,i,X(m,i,W))}return e}return Gr(sr(m,Or(W.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:!!T(wr.current.touched,a),isSubmitted:wr.current.isSubmitted},rr.current)),c=Mr(a,!1),l=!Z(c)||!o&&Ur(a);if(o&&!T(wr.current.touched,a)&&zr.current.touched&&(I(wr.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:wr.current.touched})),!v&&$(i)&&I(W.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=wr.current.isValid;if(e=T(f,a),$(i)&&!e&&K.current){var h=br(a),p=T(f,h,{});p.type&&p.message&&(e=p),h&&(p||T(wr.current.errors,h))&&(a=h)}d!==(t=Z(f))&&(l=!0)}else e=(await hr(m,dr,u,W))[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)?w.current:{},t=(await K.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),J.current,dr)||{}).errors,n=Z(t);wr.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);!M(c)&&I(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)&&(q(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)&&(q(u,e),delete r.current[o]):delete r.current[o]}(m,B.current,r,W,v,e),v&&(er(z.current,r.ref.name),er(S.current,r.ref.name))}),[v]),Xr=t((function(r){if(R.current)Hr();else{for(var e=0,t=E.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(wr.current.errors,r.ref.name),I(wr.current.dirtyFields,r.ref.name,!0),Hr({isDirty:Lr()}),zr.current.isValid&&K.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?A.current[t]:E.current,i=sr(m,Or(W.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,M(T(w.current,r))?e:T(w.current,r),!0)}var u=M(e)?w.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=M(t),L(!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=kr(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=M(T(W.current,n));Z(w.current)&&y||(t=T(y?w.current:W.current,n),(d=M(t))||c||Ir(n,t)),Z(e)||(I(S.current,n,!0),!lr&&zr.current.isValid&&hr(m,dr,f,W).then((function(r){var e=wr.current.isValid;Z(r)?I(z.current,n,!0):er(z.current,n),e!==Z(r)&&Hr()}))),!v||c&&d||!c&&er(wr.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(W.current),v,!0));zr.current.isSubmitting&&Hr({isSubmitting:!0});try{if(K.current){var a=await K.current(i,J.current,dr),u=a.errors,o=a.values;wr.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,W);h[d]?(I(n,d,h[d]),er(z.current,d)):T(S.current,d)&&(er(wr.current.errors,d),I(z.current,d,!0))}}Z(n)&&Object.keys(wr.current.errors).every((function(r){return r in m.current}))?(Hr({errors:{},isSubmitting:!0}),await r(i,t)):(wr.current.errors=Object.assign(Object.assign({},wr.current.errors),n),e&&await e(wr.current.errors,t),f&&function(r,e){for(var t in r)if(T(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}}}}(m.current,wr.current.errors))}finally{wr.current.isSubmitting=!1,Hr({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Z(wr.current.errors),submitCount:wr.current.submitCount+1})}}}),[f,dr]);a((function(){s&&zr.current.isValid&&Kr(),Dr.current=Dr.current||!Vr?Dr.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,w.current]),a((function(){return function(){Dr.current&&Dr.current.disconnect(),D.current=!0,"production"===process.env.NODE_ENV&&Object.values(m.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!s&&zr.current.isValid&&(xr.isValid=ar(z.current,S.current)&&Z(wr.current.errors));var te={trigger:Wr,setValue:t((function(r,e,t){Pr(r,e,t||{}),Ur(r)&&Hr(),$r(r)}),[Pr,Wr]),getValues:t(Jr,[]),register:t((function(r,e){if(!Er)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)}}),[w.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(xr,{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 zr.current[e]=!0,r[e]}}):xr},ne=u((function(){return Object.assign({isFormDirty:Lr,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:_,useWatchFieldsRef:A,useWatchRenderFunctionsRef:x,fieldArrayDefaultValuesRef:y,validFieldsRef:z,fieldsWithValidationRef:S,fieldArrayNamesRef:Q,readFormStateRef:zr,formStateRef:wr,defaultValuesRef:w,shallowFieldsStateRef:W,fieldArrayValuesRef:j},te)}),[w.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=kr(a)&&Array.isArray(u)?u[0].ref:a;if(h(o))try{o.closest("form").reset();break}catch(r){}}}m.current={},w.current=Object.assign({},r||w.current),r&&$r(""),Object.values(_.current).forEach((function(r){return fr(r)&&r()})),W.current=v?{}:Or(r||w.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||(z.current={},S.current={}),y.current={},E.current=new Set,R.current=!1,Hr({submitCount:u?wr.current.submitCount:0,isDirty:!!t&&wr.current.isDirty,isSubmitted:!!n&&wr.current.isSubmitted,isValid:!!a&&wr.current.isValid,dirtyFields:o?wr.current.dirtyFields:{},touched:i?wr.current.touched:{},errors:e?wr.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 wr.current.errors[r]:er(wr.current.errors,r)})),Hr({errors:r?wr.current.errors:{}})}),[]),setError:t((function(r,e){var t=(m.current[r]||{}).ref;I(wr.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Hr({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:xr.errors},te)}e(null).displayName="RHFContext";var Sr,zr=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"}(Sr||(Sr={}));var wr=function(e){var t=e.exampleType,n=void 0===t?Sr.formgroup:t,i=xr(),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===Sr.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,{inputId:"checkbox1",label:"Checkbox 1",ref:a({required:g})}),r.createElement(l,{inputId:"checkbox2",label:"Checkbox 2",ref:a({required:g})}),r.createElement(l,{inputId:"checkbox3",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,{inputId:"checkbox4",label:"Checkbox 4",ref:a({validate:p})}),r.createElement(l,{inputId:"checkbox5",label:"Checkbox 5",ref:a({validate:p})}),r.createElement(l,{inputId:"checkbox6",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,{inputId:"radiobutton1",label:"Radiobutton 1",ref:a({required:g})}),r.createElement(v,{inputId:"radiobutton2",label:"Radiobutton 2",ref:a({required:g})}),r.createElement(v,{inputId:"radiobutton3",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",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})),r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(m,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:zr,ref:a({required:"Du må skrive noe her"})}))]:n===Sr.checkbox?r.createElement(c,{name:"formgroup1",error:o.formgroup1?o.formgroup1.message:void 0},r.createElement(l,{name:"formgroup1",inputId:"checkbox1",label:"Checkbox 1",error:o.formgroup1,variant:e.variant,ref:a({required:g})})):n===Sr.radiobutton?r.createElement(c,{name:"formgroup3",error:o.formgroup3?o.formgroup3.message:void 0},r.createElement(v,{name:"formgroup3",inputId:"radiobutton1",label:"Radiobutton 1",error:o.formgroup3,variant:e.variant,ref:a({required:g})})):n===Sr.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",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})):n===Sr.input?r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(m,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:zr,ref:a({required:"Du må skrive noe her"})})):void 0),r.createElement(f,null,"Submit"))};export default wr;export{wr as FormExample,Sr 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-fd3f7f58.js";import{F as c}from"../../FormGroup-0577b07f.js";import{C as l}from"../../Checkbox-798282e4.js";import{B as f}from"../../Button-f26a558e.js";import{R as v}from"../../RadioButton-fe4bbd36.js";import{T as d}from"../../Textarea-e1d1144c.js";import{I as m}from"../../Input-19650c24.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../constants-ad6c82db.js";import"../../_rollupPluginBabelHelpers-b8ef6dd9.js";import"../FormGroup/styles.module.scss";import"../../Title-af53f589.js";import"../Title/styles.module.scss";import"../../uuid-fe7442b7.js";import"../../Check-6291ad09.js";import"../../Icon-89da8de4.js";import"../../_tslib-51c8a283.js";import"../../color-a10c7892.js";import"../../index-0e78dfa0.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../Checkbox/styles.module.scss";import"../../Loader-fa16a352.js";import"../Loader/styles.module.scss";import"../../useHover-9710204a.js";import"../../useWindowSize-750f9b68.js";import"../Button/styles.module.scss";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../../useBreakpoint-552af2b9.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",k="all",E="max",A="min",x="maxLength",S="minLength",z="pattern",w="required",D="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 I(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 L=function(r,e){for(var t in void 0===e&&(e={}),r)H(t)?e[t]=r[t]:I(e,t,r[t]);return e},M=function(r){return void 0===r},T=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 M(n)||n===r?M(r[e])?t:r[e]:n},q=function(r,e){h(r)&&r.removeEventListener&&(r.removeEventListener(b,e),r.removeEventListener(p,e),r.removeEventListener(g,e))},W={isValid:!1,value:null},_=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),W):W},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&&!M(a.value)?M(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)?_(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 T(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=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)&&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],T(e[u]||{},o,[]),t[u][o],t[u],o)):ar(T(e[u]||{},o),r[u][o])?I(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){(M(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?L(a):ir(e,L(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=x),void 0===a&&(a=S);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&&!_(u).isValid)){var j=vr(o)?{value:!!o,message:o}:lr(o),k=j.value,R=j.message;if(k&&(h[m]=Object.assign({type:w,message:R,ref:b?((r.current[m].options||[])[0]||{}).ref:i},V(w,R)),!e))return h}if(!(F(l)&&F(f)||""===a)){var H,N,B=lr(f),I=lr(l);if(isNaN(a)){var L=i.valueAsDate||new Date(a);or(B.value)&&(H=L>new Date(B.value)),or(I.value)&&(N=L<new Date(I.value))}else{var M=i.valueAsNumber||parseFloat(a);F(B.value)||(H=M>B.value),F(I.value)||(N=M<I.value)}if((H||N)&&(O(!!H,B.message,I.message,E,A),!e))return h}if(or(a)&&!y&&(s||c)){var T=lr(s),q=lr(c),W=!F(T.value)&&a.length>T.value,U=!F(q.value)&&a.length<q.value;if((W||U)&&(O(W,T.message,q.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:z,message:K,ref:i},V(z,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(D,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=T(r,e),(C(a)||Array.isArray(a))&&gr(e,a).forEach((function(r){return t.add(r)}))),M(a)?i?n:T(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===k,isOnTouch:r===j}},kr=function(r){return P(r)||$(r)},Er="undefined"==typeof window,Ar=Vr?"Proxy"in window:"undefined"!=typeof Proxy;function xr(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({}),E=n(new Set),A=n({}),x=n({}),S=n({}),z=n({}),w=n(l),D=n(!1),R=n(!1),B=n(),W=n({}),_=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===k,mr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!lr,errors:{}}),xr=mr[0],Sr=mr[1],zr=n({isDirty:!Ar,dirtyFields:!Ar,touched:!Ar||vr,isValidating:!Ar,isSubmitting:!Ar,isValid:!Ar}),wr=n(xr),Dr=n(),Fr=n(jr(o)).current,Rr=Fr.isOnBlur,Cr=Fr.isOnChange;J.current=c,K.current=s,wr.current=xr,W.current=v?{}:Z(W.current)?Or(l):W.current;var Hr=t((function(r){void 0===r&&(r={}),D.current||(wr.current=Object.assign(Object.assign({},wr.current),r),Sr(wr.current))}),[]),Nr=function(){return zr.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=M(n),o=T(e,t);return u&&!!o||!u&&!ar(o,n,!0)||u&&T(a,t)&&!T(i,t)}({errors:wr.current.errors,error:e,name:r,validFields:z.current,fieldsWithValidation:S.current}),u=T(wr.current.errors,r);e?(er(z.current,r),a=a||!u||!ar(u,e,!0),I(wr.current.errors,r,e)):((T(S.current,r)||K.current)&&(I(z.current,r,!0),a=a||u),er(wr.current.errors,r)),(a&&!F(t)||!Z(n)||zr.current.isValidating)&&Hr(Object.assign(Object.assign(Object.assign({},n),K.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Ir=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}),[]),Lr=t((function(r,e){if(zr.current.isDirty){var t=Jr();return r&&e&&I(t,r,e),!ar(t,w.current)}return!1}),[]),Mr=t((function(r,e){if(void 0===e&&(e=!0),zr.current.isDirty||zr.current.dirtyFields){var t=!ar(T(w.current,r),X(m,r,W)),n=T(wr.current.dirtyFields,r),i=wr.current.isDirty;t?I(wr.current.dirtyFields,r,!0):er(wr.current.dirtyFields,r);var a={isDirty:Lr(),dirtyFields:wr.current.dirtyFields},u=zr.current.isDirty&&i!==a.isDirty||zr.current.dirtyFields&&n!==T(wr.current.dirtyFields,r);return u&&e&&Hr(a),u?a:{}}return{}}),[]),Tr=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],W))[r];return Br(r,t,e),M(t)}),[Br,dr]),qr=t((async function(r){var e=(await K.current(Jr(),J.current,dr)).errors,t=wr.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=T(e,r);return t?I(wr.current.errors,r,t):er(wr.current.errors,r),!t})).every(Boolean);return Hr({isValid:Z(e),isValidating:!1}),n}var i=T(e,r);return Br(r,i,t!==Z(e),{},Z(e)),!i}),[Br,dr]),Wr=t((async function(r){var e=r||Object.keys(m.current);if(Nr(),K.current)return qr(e);if(Array.isArray(e)){!r&&(wr.current.errors={});var t=await Promise.all(e.map((async function(r){return await Tr(r,null)})));return Hr({isValidating:!1}),t.every(Boolean)}return await Tr(e)}),[qr,Tr]),_r=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,a={};I(a,r,e);for(var u=0,o=gr(r,e);u<o.length;u+=1){var s=o[u];m.current[s]&&(Ir(s,T(a,s)),n&&Mr(s),i&&Wr(s))}}),[Wr,Ir,Mr]),Pr=t((function(r,e,t){var n,i;if(!v&&!nr(e)&&I(W.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),m.current[r])Ir(r,e),t.shouldDirty&&Mr(r),t.shouldValidate&&Wr(r);else if(!nr(e)&&(_r(r,e,t),Q.current.has(r))){var a=br(r)||r;I(y.current,r,e),_.current[a](((n={})[a]=T(y.current,a),n)),(zr.current.isDirty||zr.current.dirtyFields)&&t.shouldDirty&&(I(wr.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,T(w.current,r,[]),T(wr.current.dirtyFields,r,[]))),Hr({isDirty:!ar(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),w.current)}))}!v&&I(W.current,r,e)}),[Mr,Ir,_r]),Ur=function(r){return R.current||E.current.has(r)||E.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))||(x.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,W);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];I(e,i,X(m,i,W))}return e}return Gr(sr(m,Or(W.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:!!T(wr.current.touched,a),isSubmitted:wr.current.isSubmitted},rr.current)),c=Mr(a,!1),l=!Z(c)||!o&&Ur(a);if(o&&!T(wr.current.touched,a)&&zr.current.touched&&(I(wr.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:wr.current.touched})),!v&&$(i)&&I(W.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=wr.current.isValid;if(e=T(f,a),$(i)&&!e&&K.current){var h=br(a),p=T(f,h,{});p.type&&p.message&&(e=p),h&&(p||T(wr.current.errors,h))&&(a=h)}d!==(t=Z(f))&&(l=!0)}else e=(await hr(m,dr,u,W))[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)?w.current:{},t=(await K.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),J.current,dr)||{}).errors,n=Z(t);wr.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);!M(c)&&I(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)&&(q(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)&&(q(u,e),delete r.current[o]):delete r.current[o]}(m,B.current,r,W,v,e),v&&(er(z.current,r.ref.name),er(S.current,r.ref.name))}),[v]),Xr=t((function(r){if(R.current)Hr();else{for(var e=0,t=E.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(wr.current.errors,r.ref.name),I(wr.current.dirtyFields,r.ref.name,!0),Hr({isDirty:Lr()}),zr.current.isValid&&K.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?A.current[t]:E.current,i=sr(m,Or(W.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,M(T(w.current,r))?e:T(w.current,r),!0)}var u=M(e)?w.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=M(t),L(!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=kr(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=M(T(W.current,n));Z(w.current)&&y||(t=T(y?w.current:W.current,n),(d=M(t))||c||Ir(n,t)),Z(e)||(I(S.current,n,!0),!lr&&zr.current.isValid&&hr(m,dr,f,W).then((function(r){var e=wr.current.isValid;Z(r)?I(z.current,n,!0):er(z.current,n),e!==Z(r)&&Hr()}))),!v||c&&d||!c&&er(wr.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(W.current),v,!0));zr.current.isSubmitting&&Hr({isSubmitting:!0});try{if(K.current){var a=await K.current(i,J.current,dr),u=a.errors,o=a.values;wr.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,W);h[d]?(I(n,d,h[d]),er(z.current,d)):T(S.current,d)&&(er(wr.current.errors,d),I(z.current,d,!0))}}Z(n)&&Object.keys(wr.current.errors).every((function(r){return r in m.current}))?(Hr({errors:{},isSubmitting:!0}),await r(i,t)):(wr.current.errors=Object.assign(Object.assign({},wr.current.errors),n),e&&await e(wr.current.errors,t),f&&function(r,e){for(var t in r)if(T(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}}}}(m.current,wr.current.errors))}finally{wr.current.isSubmitting=!1,Hr({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Z(wr.current.errors),submitCount:wr.current.submitCount+1})}}}),[f,dr]);a((function(){s&&zr.current.isValid&&Kr(),Dr.current=Dr.current||!Vr?Dr.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,w.current]),a((function(){return function(){Dr.current&&Dr.current.disconnect(),D.current=!0,"production"===process.env.NODE_ENV&&Object.values(m.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!s&&zr.current.isValid&&(xr.isValid=ar(z.current,S.current)&&Z(wr.current.errors));var te={trigger:Wr,setValue:t((function(r,e,t){Pr(r,e,t||{}),Ur(r)&&Hr(),$r(r)}),[Pr,Wr]),getValues:t(Jr,[]),register:t((function(r,e){if(!Er)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)}}),[w.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(xr,{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 zr.current[e]=!0,r[e]}}):xr},ne=u((function(){return Object.assign({isFormDirty:Lr,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:_,useWatchFieldsRef:A,useWatchRenderFunctionsRef:x,fieldArrayDefaultValuesRef:y,validFieldsRef:z,fieldsWithValidationRef:S,fieldArrayNamesRef:Q,readFormStateRef:zr,formStateRef:wr,defaultValuesRef:w,shallowFieldsStateRef:W,fieldArrayValuesRef:j},te)}),[w.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=kr(a)&&Array.isArray(u)?u[0].ref:a;if(h(o))try{o.closest("form").reset();break}catch(r){}}}m.current={},w.current=Object.assign({},r||w.current),r&&$r(""),Object.values(_.current).forEach((function(r){return fr(r)&&r()})),W.current=v?{}:Or(r||w.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||(z.current={},S.current={}),y.current={},E.current=new Set,R.current=!1,Hr({submitCount:u?wr.current.submitCount:0,isDirty:!!t&&wr.current.isDirty,isSubmitted:!!n&&wr.current.isSubmitted,isValid:!!a&&wr.current.isValid,dirtyFields:o?wr.current.dirtyFields:{},touched:i?wr.current.touched:{},errors:e?wr.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 wr.current.errors[r]:er(wr.current.errors,r)})),Hr({errors:r?wr.current.errors:{}})}),[]),setError:t((function(r,e){var t=(m.current[r]||{}).ref;I(wr.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Hr({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:xr.errors},te)}e(null).displayName="RHFContext";var Sr,zr=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"}(Sr||(Sr={}));var wr=function(e){var t=e.exampleType,n=void 0===t?Sr.formgroup:t,i=xr(),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===Sr.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,{inputId:"checkbox1",label:"Checkbox 1",ref:a({required:g})}),r.createElement(l,{inputId:"checkbox2",label:"Checkbox 2",ref:a({required:g})}),r.createElement(l,{inputId:"checkbox3",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,{inputId:"checkbox4",label:"Checkbox 4",ref:a({validate:p})}),r.createElement(l,{inputId:"checkbox5",label:"Checkbox 5",ref:a({validate:p})}),r.createElement(l,{inputId:"checkbox6",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,{inputId:"radiobutton1",label:"Radiobutton 1",ref:a({required:g})}),r.createElement(v,{inputId:"radiobutton2",label:"Radiobutton 2",ref:a({required:g})}),r.createElement(v,{inputId:"radiobutton3",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",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})),r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(m,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:zr,ref:a({required:"Du må skrive noe her"})}))]:n===Sr.checkbox?r.createElement(c,{name:"formgroup1",error:o.formgroup1?o.formgroup1.message:void 0},r.createElement(l,{name:"formgroup1",inputId:"checkbox1",label:"Checkbox 1",error:o.formgroup1,variant:e.variant,ref:a({required:g})})):n===Sr.radiobutton?r.createElement(c,{name:"formgroup3",error:o.formgroup3?o.formgroup3.message:void 0},r.createElement(v,{name:"formgroup3",inputId:"radiobutton1",label:"Radiobutton 1",error:o.formgroup3,variant:e.variant,ref:a({required:g})})):n===Sr.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",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})):n===Sr.input?r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(m,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:zr,ref:a({required:"Du må skrive noe her"})})):void 0),r.createElement(f,null,"Submit"))};export default wr;export{wr as FormExample,Sr as FormExampleVariants};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{M as s}from"../../Modal-
|
|
1
|
+
import{M as s}from"../../Modal-1bae215e.js";export{b as ModalSize,a as ModalVariants,M as default}from"../../Modal-1bae215e.js";import"../../_rollupPluginBabelHelpers-b8ef6dd9.js";import"react";import"../../index-9b84fabc.js";import"../../palette-f206f488.js";import"../../Button-f26a558e.js";import"../../_tslib-51c8a283.js";import"../../constants-ad6c82db.js";import"../../color-a10c7892.js";import"../../index-0e78dfa0.js";import"../../grid-11a70eb7.js";import"../../Icon-89da8de4.js";import"../../Loader-fa16a352.js";import"../../uuid-fe7442b7.js";import"../Loader/styles.module.scss";import"../../useHover-9710204a.js";import"../../useWindowSize-750f9b68.js";import"../Button/styles.module.scss";import"./styles.module.scss";import"../../AlertSignFill-e607ff43.js";import"../../useIsVisible-a1f67a11.js";import"../../Title-af53f589.js";import"../Title/styles.module.scss";import"../../Close-35ad7d35.js";import"../Close/styles.module.scss";import"../../useBreakpoint-552af2b9.js";import"react-dom";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
package/Button-d5147e38.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_ as t,b as e}from"./_rollupPluginBabelHelpers-b8ef6dd9.js";import{_ as n}from"./_tslib-51c8a283.js";import o from"react";import{A as r,I as l}from"./constants-ad6c82db.js";import{g as i}from"./color-a10c7892.js";import"./Icon-89da8de4.js";import{L as a}from"./Loader-fa16a352.js";import{u as s}from"./useHover-9710204a.js";import{u as d}from"./useWindowSize-750f9b68.js";import{b as u}from"./grid-11a70eb7.js";import{c}from"./index-9b84fabc.js";import m from"./components/Button/styles.module.scss";var b={primary:"blueberry",warning:"banana",danger:"cherry"},f=function(t,e){return e&&e<u.md&&t?l.Small:t?l.Medium:l.XSmall},p=o.forwardRef((function(u,p){var v,_,g,h=u.children,j=u.className,w=void 0===j?"":j,E=u.fluid,y=void 0!==E&&E,k=u.intent,N=void 0===k?"primary":k,I=u.inverted,B=void 0!==I&&I,C=u.htmlMarkup,H=void 0===C?"button":C,O=u.onClick,S=u.large,z=void 0!==S&&S,F=u.loading,M=void 0!==F&&F,x=u.variant,A=void 0===x?"fill":x,L=u.disabled,R=void 0!==L&&L,X=u.ellipsis,P=void 0!==X&&X,W=u.testId,q=u.href,D=u.target,G=n(u,["children","className","fluid","intent","inverted","htmlMarkup","onClick","large","loading","variant","disabled","ellipsis","testId","href","target"]),J=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(h)),K=t(J,3),Q=K[0],T=K[1],U=K[2],V=s(p),Y=V.hoverRef,Z=V.isHovered,$=function(t,e,n,o,r){return e?i("neutral",600):t&&!o||!t&&o?"white":i(b[n],r?700:600)}("fill"===A,R,N,B,Z),tt=d(),et="fill"===A,nt="outline"===A,ot="borderless"===A,rt="warning"===N,lt="danger"===N,it=!(!Q&&!T||M),at=Object.assign({},G),st=c(m.button,(e(v={},m["button--fluid"],y),e(v,m["button--large"],z),e(v,m["button--warning"],rt),e(v,m["button--danger"],lt),e(v,m["button--inverted"],B),e(v,m["button--fill"],et),e(v,m["button--outline"],nt),e(v,m["button--borderless"],ot),e(v,m["button--with-icon"],it),e(v,m["button--ellipsis"],P),v),w),dt=c(m.button__content,(e(_={},m["button__content--warning"],rt),e(_,m["button__content--danger"],lt),e(_,m["button__content--fill"],et),e(_,m["button__content--borderless"],ot),e(_,m["button__content--with-icon"],it),e(_,m["button__content--large"],z),e(_,m["button__content--ellipsis"],P),e(_,m["button__content--inverted"],B),e(_,m["button__content--fluid"],y),_)),ut=c(m["button__left-fluid-content"],(e(g={},m["button__left-fluid-content--with-icon"],it),e(g,m["button__left-fluid-content--large"],z),g));function ct(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 mt=function(){return U?o.createElement("span",{className:dt},U):null},bt=function(){return o.createElement("span",{className:m["content-wrapper"]},M?o.createElement("div",{className:m["button__left-fluid-content"]},o.createElement(a,{testId:"test-id-loader",color:"fill"!==A||B?b[N]:"white",size:"tiny"})):o.createElement(o.Fragment,null,y?o.createElement("div",{className:ut},ct(Q,f(z,tt.width),$,Z),mt()):o.createElement(o.Fragment,null,ct(Q,f(z,tt.width),$,Z),mt()),ct(T,l.XSmall,$,Z)))};return o.createElement(o.Fragment,null,"button"===H&&o.createElement("button",Object.assign({onClick:O,disabled:R,"data-testid":W,"data-analyticsid":r.Button,className:st,ref:Y},at),bt()),"a"===H&&o.createElement("a",Object.assign({onClick:O,"data-testid":W,"data-analyticsid":r.Button,className:st,href:q,target:D,rel:"_blank"===D?"noopener noreferrer":u.rel,ref:Y},G),bt()))}));export{p as B,b as i};
|
|
2
|
-
//# sourceMappingURL=Button-d5147e38.js.map
|
package/Button-d5147e38.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button-d5147e38.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/Modal-ad02991b.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Modal-ad02991b.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|