@helsenorge/designsystem-react 2.9.3 → 2.10.1
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/Avatar.js +2 -0
- package/Avatar.js.map +1 -0
- package/Badge.js +1 -1
- package/Badge.js.map +1 -1
- package/CHANGELOG.md +19 -0
- package/FormGroup.js +1 -1
- package/FormGroup.js.map +1 -1
- package/ListHeader.js +2 -0
- package/ListHeader.js.map +1 -0
- package/ListHeaderText.js +2 -0
- package/ListHeaderText.js.map +1 -0
- package/StatusDot.js +2 -0
- package/StatusDot.js.map +1 -0
- package/components/Avatar/Avatar.d.ts +3 -2
- package/components/Avatar/Avatar.d.ts.map +1 -1
- package/components/Avatar/index.js +1 -1
- package/components/Avatar/index.js.map +1 -1
- package/components/Badge/Badge.d.ts +3 -2
- package/components/Badge/Badge.d.ts.map +1 -1
- package/components/Badge/styles.module.scss +1 -4
- package/components/Badge/styles.module.scss.d.ts +0 -1
- package/components/ExpanderList/ExpanderList.d.ts +10 -4
- package/components/ExpanderList/ExpanderList.d.ts.map +1 -1
- package/components/ExpanderList/componentdata.json +1 -1
- package/components/ExpanderList/index.js +1 -1
- package/components/ExpanderList/index.js.map +1 -1
- package/components/ExpanderList/styles.module.scss +29 -67
- package/components/ExpanderList/styles.module.scss.d.ts +3 -6
- package/components/FormExample/index.js +2 -2
- package/components/FormExample/index.js.map +1 -1
- package/components/FormGroup/FormGroup.d.ts.map +1 -1
- package/components/FormGroup/index.js +1 -1
- package/components/Icons/Coins.js +1 -1
- package/components/Icons/Coins.js.map +1 -1
- package/components/Icons/PersonCancel.js +1 -1
- package/components/Icons/PersonCancel.js.map +1 -1
- package/components/Icons/TravelRoute.js +1 -1
- package/components/Icons/TravelRoute.js.map +1 -1
- package/components/LinkList/LinkList.d.ts +13 -8
- package/components/LinkList/LinkList.d.ts.map +1 -1
- package/components/LinkList/componentdata.json +1 -1
- package/components/LinkList/index.js +1 -1
- package/components/LinkList/index.js.map +1 -1
- package/components/LinkList/styles.module.scss +35 -61
- package/components/LinkList/styles.module.scss.d.ts +3 -5
- package/components/ListHeader/ListHeader.d.ts +38 -0
- package/components/ListHeader/ListHeader.d.ts.map +1 -0
- package/components/ListHeader/ListHeaderText/ListHeaderText.d.ts +24 -0
- package/components/ListHeader/ListHeaderText/ListHeaderText.d.ts.map +1 -0
- package/components/ListHeader/ListHeaderText/componentdata.json +1 -0
- package/components/ListHeader/ListHeaderText/index.d.ts +4 -0
- package/components/ListHeader/ListHeaderText/index.d.ts.map +1 -0
- package/components/ListHeader/ListHeaderText/index.js +2 -0
- package/components/ListHeader/ListHeaderText/index.js.map +1 -0
- package/components/ListHeader/componentdata.json +1 -0
- package/components/ListHeader/index.d.ts +5 -0
- package/components/ListHeader/index.d.ts.map +1 -0
- package/components/ListHeader/index.js +2 -0
- package/components/ListHeader/index.js.map +1 -0
- package/components/ListHeader/styles.module.scss +150 -0
- package/components/ListHeader/styles.module.scss.d.ts +41 -0
- package/components/NotificationPanel/styles.module.scss +2 -1
- package/components/StatusDot/StatusDot.d.ts.map +1 -1
- package/components/StatusDot/index.js +1 -1
- package/components/StatusDot/index.js.map +1 -1
- package/components/StatusDot/styles.module.scss +1 -0
- package/components/Validation/index.js +1 -1
- package/package.json +1 -1
- package/utils/component.d.ts +3 -0
- package/utils/component.d.ts.map +1 -0
- package/utils/component.js +2 -0
- package/utils/component.js.map +1 -0
|
@@ -11,29 +11,37 @@
|
|
|
11
11
|
|
|
12
12
|
&__item {
|
|
13
13
|
border: 0;
|
|
14
|
-
border-bottom: 1px solid $neutral500;
|
|
15
14
|
position: relative;
|
|
16
15
|
|
|
17
|
-
&--
|
|
18
|
-
border-
|
|
16
|
+
&--line {
|
|
17
|
+
border-bottom: 1px solid $neutral500;
|
|
18
|
+
&:first-of-type {
|
|
19
|
+
border-top: 1px solid $neutral500;
|
|
20
|
+
}
|
|
19
21
|
}
|
|
22
|
+
&--outline {
|
|
23
|
+
border-top: getSpacer(2xs) $neutral100 solid;
|
|
24
|
+
border-left: getSpacer(2xs) $neutral100 solid;
|
|
25
|
+
border-right: getSpacer(2xs) $neutral100 solid;
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
&:last-of-type {
|
|
28
|
+
border-bottom: getSpacer(2xs) $neutral50 solid;
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
.expander-list-link {
|
|
28
|
-
padding:
|
|
35
|
+
padding: 0;
|
|
36
|
+
position: relative;
|
|
29
37
|
font-size: $font-size-sm;
|
|
30
38
|
line-height: $lineheight-size-sm;
|
|
39
|
+
|
|
31
40
|
@media (min-width: map-get($grid-breakpoints, md)) {
|
|
32
|
-
padding-left: getSpacer(2xs);
|
|
33
|
-
padding-right: getSpacer(2xs);
|
|
34
41
|
font-size: $font-size-md;
|
|
35
42
|
line-height: $lineheight-size-md;
|
|
36
43
|
}
|
|
44
|
+
|
|
37
45
|
display: flex;
|
|
38
46
|
cursor: pointer;
|
|
39
47
|
font-weight: 600;
|
|
@@ -49,67 +57,44 @@
|
|
|
49
57
|
|
|
50
58
|
&--banana {
|
|
51
59
|
background-color: $banana100;
|
|
52
|
-
|
|
53
|
-
&:hover,
|
|
54
|
-
&:focus {
|
|
55
|
-
background-color: $banana100;
|
|
56
|
-
}
|
|
57
60
|
}
|
|
58
61
|
&--blueberry {
|
|
59
62
|
background-color: $blueberry100;
|
|
60
|
-
|
|
61
|
-
&:hover,
|
|
62
|
-
&:focus {
|
|
63
|
-
background-color: $blueberry100;
|
|
64
|
-
}
|
|
65
63
|
}
|
|
66
64
|
&--cherry {
|
|
67
65
|
background-color: $cherry100;
|
|
68
|
-
|
|
69
|
-
&:hover,
|
|
70
|
-
&:focus {
|
|
71
|
-
background-color: $cherry100;
|
|
72
|
-
}
|
|
73
66
|
}
|
|
74
67
|
&--kiwi {
|
|
75
68
|
background-color: $kiwi100;
|
|
76
|
-
|
|
77
|
-
&:hover,
|
|
78
|
-
&:focus {
|
|
79
|
-
background-color: $kiwi100;
|
|
80
|
-
}
|
|
81
69
|
}
|
|
82
70
|
&--neutral {
|
|
83
71
|
background-color: $neutral100;
|
|
84
|
-
|
|
85
|
-
&:hover,
|
|
86
|
-
&:focus {
|
|
87
|
-
background-color: $neutral100;
|
|
88
|
-
}
|
|
89
72
|
}
|
|
90
73
|
&--plum {
|
|
91
74
|
background-color: $plum100;
|
|
92
|
-
|
|
93
|
-
&:hover,
|
|
94
|
-
&:focus {
|
|
95
|
-
background-color: $plum100;
|
|
96
|
-
}
|
|
97
75
|
}
|
|
98
76
|
&--white {
|
|
99
77
|
background-color: $neutral50;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&--closed:not(:hover, .expander-list-link--fill) {
|
|
81
|
+
background-color: transparent;
|
|
82
|
+
}
|
|
83
|
+
&--closed#{&}--fill {
|
|
84
|
+
margin: getSpacer(s) 0;
|
|
100
85
|
|
|
101
|
-
&:hover
|
|
102
|
-
&:focus {
|
|
86
|
+
&:not(:hover) {
|
|
103
87
|
background-color: $neutral50;
|
|
104
88
|
}
|
|
105
89
|
}
|
|
106
90
|
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
&:hover {
|
|
92
|
+
color: $blueberry700;
|
|
109
93
|
}
|
|
110
94
|
|
|
111
|
-
&:focus
|
|
112
|
-
|
|
95
|
+
&:focus,
|
|
96
|
+
&:focus-visible {
|
|
97
|
+
outline: getSpacer(4xs) solid $black;
|
|
113
98
|
}
|
|
114
99
|
|
|
115
100
|
&--large {
|
|
@@ -117,12 +102,6 @@
|
|
|
117
102
|
line-height: $lineheight-size-lg;
|
|
118
103
|
}
|
|
119
104
|
|
|
120
|
-
&--jsx {
|
|
121
|
-
&:focus {
|
|
122
|
-
box-shadow: 0px 3px 0px $neutral500, 0px -3px 0px $neutral500;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
105
|
&--sticky {
|
|
127
106
|
position: fixed;
|
|
128
107
|
top: 0;
|
|
@@ -132,23 +111,6 @@
|
|
|
132
111
|
bottom: 0;
|
|
133
112
|
}
|
|
134
113
|
|
|
135
|
-
&__title {
|
|
136
|
-
color: $black;
|
|
137
|
-
display: flex;
|
|
138
|
-
align-items: center;
|
|
139
|
-
text-align: left;
|
|
140
|
-
&--string {
|
|
141
|
-
border-bottom: 1px solid transparent;
|
|
142
|
-
|
|
143
|
-
:focus > & {
|
|
144
|
-
border-color: $black;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
&--jsx {
|
|
148
|
-
width: 100%;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
114
|
&__icon {
|
|
153
115
|
display: flex;
|
|
154
116
|
align-items: center;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
export type Styles = {
|
|
2
2
|
'expander-list': string;
|
|
3
3
|
'expander-list__item': string;
|
|
4
|
-
'expander-list__item--
|
|
5
|
-
'expander-list__item--
|
|
4
|
+
'expander-list__item--line': string;
|
|
5
|
+
'expander-list__item--outline': string;
|
|
6
6
|
'expander-list-link': string;
|
|
7
7
|
'expander-list-link__chevron': string;
|
|
8
8
|
'expander-list-link__icon': string;
|
|
9
9
|
'expander-list-link__main-content': string;
|
|
10
10
|
'expander-list-link__main-content--expanded': string;
|
|
11
11
|
'expander-list-link__main-content--padding': string;
|
|
12
|
-
'expander-list-link__title': string;
|
|
13
|
-
'expander-list-link__title--jsx': string;
|
|
14
|
-
'expander-list-link__title--string': string;
|
|
15
12
|
'expander-list-link--absolute': string;
|
|
16
13
|
'expander-list-link--banana': string;
|
|
17
14
|
'expander-list-link--blueberry': string;
|
|
18
15
|
'expander-list-link--cherry': string;
|
|
19
16
|
'expander-list-link--closed': string;
|
|
20
|
-
'expander-list-link--
|
|
17
|
+
'expander-list-link--fill': string;
|
|
21
18
|
'expander-list-link--kiwi': string;
|
|
22
19
|
'expander-list-link--large': string;
|
|
23
20
|
'expander-list-link--neutral': string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import h from"react";import{V as yt}from"../../Validation.js";import{F as Y}from"../../FormGroup.js";import{C as ee}from"../../Checkbox.js";import{B as mt}from"../../Button.js";import{R as me}from"../../RadioButton.js";import{T as Be}from"../../Textarea.js";import{I as ae}from"../../Input.js";import Ue from"../Icons/Hospital.js";import{F as gt,a as ht}from"../../FormLayout.js";import{isTest as vt}from"../../utils/environment.js";import{S as Pe}from"../../Select.js";import we from"./styles.module.scss";import"classnames";import"../Validation/styles.module.scss";import"../../constants.js";import"../FormGroup/styles.module.scss";import"../../Title.js";import"../Title/styles.module.scss";import"../../ErrorWrapper.js";import"../ErrorWrapper/styles.module.scss";import"../../uuid.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../hooks/useUuid.js";import"../../theme/currys/color.js";import"../../theme/index.js";import"../../theme/palette.js";import"../../theme/spacers.js";import"../../theme/grid.js";import"../Checkbox/styles.module.scss";import"../../hooks/useHover.js";import"../../hooks/useIcons.js";import"../../hooks/useBreakpoint.js";import"../Button/styles.module.scss";import"../Icons/ArrowRight.js";import"../../hooks/useSize.js";import"../../utils/debounce.js";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../Input/styles.module.scss";import"../FormLayout/styles.module.scss";import"../Select/styles.module.scss";import"../Icons/ChevronDown.js";var de=e=>e.type==="checkbox",ne=e=>e instanceof Date,N=e=>e==null;const Xe=e=>typeof e=="object";var L=e=>!N(e)&&!Array.isArray(e)&&Xe(e)&&!ne(e),bt=e=>L(e)&&e.target?de(e.target)?e.target.checked:e.target.value:e,xt=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,kt=(e,i)=>e.has(xt(i)),fe=e=>Array.isArray(e)?e.filter(Boolean):[],T=e=>e===void 0,f=(e,i,t)=>{if(!i||!L(e))return t;const l=fe(i.split(/[,[\].]+?/)).reduce((s,a)=>N(s)?s:s[a],e);return T(l)||l===e?T(e[i])?t:e[i]:l};const He={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},$={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},j={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};h.createContext(null);var pt=(e,i,t,l=!0)=>{const s={defaultValues:i._defaultValues};for(const a in e)Object.defineProperty(s,a,{get:()=>{const m=a;return i._proxyFormState[m]!==$.all&&(i._proxyFormState[m]=!l||$.all),t&&(t[m]=!0),e[m]}});return s},B=e=>L(e)&&!Object.keys(e).length,Et=(e,i,t)=>{const{name:l,...s}=e;return B(s)||Object.keys(s).length>=Object.keys(i).length||Object.keys(s).find(a=>i[a]===(!t||$.all))},Ae=e=>Array.isArray(e)?e:[e];function wt(e){const i=h.useRef(e);i.current=e,h.useEffect(()=>{const t=!e.disabled&&i.current.subject.subscribe({next:i.current.callback});return()=>{t&&t.unsubscribe()}},[e.disabled])}var W=e=>typeof e=="string",At=(e,i,t,l)=>{const s=Array.isArray(e);return W(e)?(l&&i.watch.add(e),f(t,e)):s?e.map(a=>(l&&i.watch.add(a),f(t,a))):(l&&(i.watchAll=!0),t)},he=e=>typeof e=="function",Ye=e=>{for(const i in e)if(he(e[i]))return!0;return!1},Dt=(e,i,t,l,s)=>i?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[l]:s||!0}}:{},Le=e=>/^\w*$/.test(e),Ze=e=>fe(e.replace(/["|']|\]/g,"").split(/\.|\[/));function A(e,i,t){let l=-1;const s=Le(i)?[i]:Ze(i),a=s.length,m=a-1;for(;++l<a;){const g=s[l];let E=t;if(l!==m){const V=e[g];E=L(V)||Array.isArray(V)?V:isNaN(+s[l+1])?{}:[]}e[g]=E,e=e[g]}return e}const Ve=(e,i,t)=>{for(const l of t||Object.keys(e)){const s=f(e,l);if(s){const{_f:a,...m}=s;if(a&&i(a.name)){if(a.ref.focus){a.ref.focus();break}else if(a.refs&&a.refs[0].focus){a.refs[0].focus();break}}else L(m)&&Ve(m,i)}}};var $e=(e,i,t)=>!t&&(i.watchAll||i.watch.has(e)||[...i.watch].some(l=>e.startsWith(l)&&/^\.\w+/.test(e.slice(l.length)))),St=(e,i,t)=>{const l=fe(f(e,t));return A(l,"root",i[t]),A(e,t,l),e},ce=e=>typeof e=="boolean",Oe=e=>e.type==="file",ge=e=>W(e)||h.isValidElement(e),Re=e=>e.type==="radio",ve=e=>e instanceof RegExp;const We={value:!1,isValid:!1},Ge={value:!0,isValid:!0};var et=e=>{if(Array.isArray(e)){if(e.length>1){const i=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:i,isValid:!!i.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!T(e[0].attributes.value)?T(e[0].value)||e[0].value===""?Ge:{value:e[0].value,isValid:!0}:Ge:We}return We};const Ke={isValid:!1,value:null};var tt=e=>Array.isArray(e)?e.reduce((i,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:i,Ke):Ke;function je(e,i,t="validate"){if(ge(e)||Array.isArray(e)&&e.every(ge)||ce(e)&&!e)return{type:t,message:ge(e)?e:"",ref:i}}var se=e=>L(e)&&!ve(e)?e:{value:e,message:""},ze=async(e,i,t,l,s)=>{const{ref:a,refs:m,required:g,maxLength:E,minLength:V,min:O,max:p,pattern:b,validate:U,name:q,valueAsNumber:re,mount:le,disabled:P}=e._f;if(!le||P)return{};const C=m?m[0]:a,H=v=>{l&&W(v)&&(C.setCustomValidity(v),C.reportValidity())},D={},z=Re(a),ie=de(a),K=z||ie,J=(re||Oe(a))&&!a.value||i===""||Array.isArray(i)&&!i.length,R=Dt.bind(null,q,t,D),Z=(v,x,S,k=j.maxLength,w=j.minLength)=>{const _=v?x:S;D[q]={type:v?k:w,message:_,ref:a,...R(v?k:w,_)}};if(s?!Array.isArray(i)||!i.length:g&&(!K&&(J||N(i))||ce(i)&&!i||ie&&!et(m).isValid||z&&!tt(m).isValid)){const{value:v,message:x}=ge(g)?{value:!!g,message:g}:se(g);if(v&&(D[q]={type:j.required,message:x,ref:C,...R(j.required,x)},!t))return H(x),D}if(!J&&(!N(O)||!N(p))){let v,x;const S=se(p),k=se(O);if(!N(i)&&!isNaN(i)){const w=a.valueAsNumber||i&&+i;N(S.value)||(v=w>S.value),N(k.value)||(x=w<k.value)}else{const w=a.valueAsDate||new Date(i),_=X=>new Date(new Date().toDateString()+" "+X),G=a.type=="time",Q=a.type=="week";W(S.value)&&i&&(v=G?_(i)>_(S.value):Q?i>S.value:w>new Date(S.value)),W(k.value)&&i&&(x=G?_(i)<_(k.value):Q?i<k.value:w<new Date(k.value))}if((v||x)&&(Z(!!v,S.message,k.message,j.max,j.min),!t))return H(D[q].message),D}if((E||V)&&!J&&(W(i)||s&&Array.isArray(i))){const v=se(E),x=se(V),S=!N(v.value)&&i.length>v.value,k=!N(x.value)&&i.length<x.value;if((S||k)&&(Z(S,v.message,x.message),!t))return H(D[q].message),D}if(b&&!J&&W(i)){const{value:v,message:x}=se(b);if(ve(v)&&!i.match(v)&&(D[q]={type:j.pattern,message:x,ref:a,...R(j.pattern,x)},!t))return H(x),D}if(U){if(he(U)){const v=await U(i),x=je(v,C);if(x&&(D[q]={...x,...R(j.validate,x.message)},!t))return H(x.message),D}else if(L(U)){let v={};for(const x in U){if(!B(v)&&!t)break;const S=je(await U[x](i),C,x);S&&(v={...S,...R(x,S.message)},H(S.message),t&&(D[q]=v))}if(!B(v)&&(D[q]={ref:C,...v},!t))return D}}return H(!0),D},_t=e=>{const i=e.constructor&&e.constructor.prototype;return L(i)&&i.hasOwnProperty("isPrototypeOf")},Te=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function te(e){let i;const t=Array.isArray(e);if(e instanceof Date)i=new Date(e);else if(e instanceof Set)i=new Set(e);else if(!(Te&&(e instanceof Blob||e instanceof FileList))&&(t||L(e)))if(i=t?[]:{},!Array.isArray(e)&&!_t(e))i=e;else for(const l in e)i[l]=te(e[l]);else return e;return i}var Je=e=>({isOnSubmit:!e||e===$.onSubmit,isOnBlur:e===$.onBlur,isOnChange:e===$.onChange,isOnAll:e===$.all,isOnTouch:e===$.onTouched});function Ft(e,i){const t=i.slice(0,-1).length;let l=0;for(;l<t;)e=T(e)?l++:e[i[l++]];return e}function Vt(e){for(const i in e)if(!T(e[i]))return!1;return!0}function I(e,i){const t=Le(i)?[i]:Ze(i),l=t.length==1?e:Ft(e,t),s=t[t.length-1];let a;l&&delete l[s];for(let m=0;m<t.slice(0,-1).length;m++){let g=-1,E;const V=t.slice(0,-(m+1)),O=V.length-1;for(m>0&&(a=e);++g<V.length;){const p=V[g];E=E?E[p]:e[p],O===g&&(L(E)&&B(E)||Array.isArray(E)&&Vt(E))&&(a?delete a[p]:delete e[p]),a=E}}return e}function De(){let e=[];return{get observers(){return e},next:s=>{for(const a of e)a.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(a=>a!==s)}}),unsubscribe:()=>{e=[]}}}var be=e=>N(e)||!Xe(e);function oe(e,i){if(be(e)||be(i))return e===i;if(ne(e)&&ne(i))return e.getTime()===i.getTime();const t=Object.keys(e),l=Object.keys(i);if(t.length!==l.length)return!1;for(const s of t){const a=e[s];if(!l.includes(s))return!1;if(s!=="ref"){const m=i[s];if(ne(a)&&ne(m)||L(a)&&L(m)||Array.isArray(a)&&Array.isArray(m)?!oe(a,m):a!==m)return!1}}return!0}var Ce=e=>{const i=e?e.ownerDocument:0,t=i&&i.defaultView?i.defaultView.HTMLElement:HTMLElement;return e instanceof t},rt=e=>e.type==="select-multiple",Tt=e=>Re(e)||de(e),Se=e=>Ce(e)&&e.isConnected;function xe(e,i={}){const t=Array.isArray(e);if(L(e)||t)for(const l in e)Array.isArray(e[l])||L(e[l])&&!Ye(e[l])?(i[l]=Array.isArray(e[l])?[]:{},xe(e[l],i[l])):N(e[l])||(i[l]=!0);return i}function it(e,i,t){const l=Array.isArray(e);if(L(e)||l)for(const s in e)Array.isArray(e[s])||L(e[s])&&!Ye(e[s])?T(i)||be(t[s])?t[s]=Array.isArray(e[s])?xe(e[s],[]):{...xe(e[s])}:it(e[s],N(i)?{}:i[s],t[s]):oe(e[s],i[s])?delete t[s]:t[s]=!0;return t}var _e=(e,i)=>it(e,i,xe(i)),st=(e,{valueAsNumber:i,valueAsDate:t,setValueAs:l})=>T(e)?e:i?e===""?NaN:e&&+e:t&&W(e)?new Date(e):l?l(e):e;function Fe(e){const i=e.ref;if(!(e.refs?e.refs.every(t=>t.disabled):i.disabled))return Oe(i)?i.files:Re(i)?tt(e.refs).value:rt(i)?[...i.selectedOptions].map(({value:t})=>t):de(i)?et(e.refs).value:st(T(i.value)?e.ref.value:i.value,e)}var Ct=(e,i,t,l)=>{const s={};for(const a of e){const m=f(i,a);m&&A(s,a,m._f)}return{criteriaMode:t,names:[...e],fields:s,shouldUseNativeValidation:l}},ue=e=>T(e)?void 0:ve(e)?e.source:L(e)?ve(e.value)?e.value.source:e.value:e,Lt=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Qe(e,i,t){const l=f(e,t);if(l||Le(t))return{error:l,name:t};const s=t.split(".");for(;s.length;){const a=s.join("."),m=f(i,a),g=f(e,a);if(m&&!Array.isArray(m)&&t!==a)return{name:t};if(g&&g.type)return{name:a,error:g};s.pop()}return{name:t}}var Ot=(e,i,t,l,s)=>s.isOnAll?!1:!t&&s.isOnTouch?!(i||e):(t?l.isOnBlur:s.isOnBlur)?!e:(t?l.isOnChange:s.isOnChange)?e:!0,Rt=(e,i)=>!fe(f(e,i)).length&&I(e,i);const Mt={mode:$.onSubmit,reValidateMode:$.onChange,shouldFocusError:!0};function It(e={}){let i={...Mt,...e},t={submitCount:0,isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},l={},s=te(i.defaultValues)||{},a=i.shouldUnregister?{}:te(s),m={action:!1,mount:!1,watch:!1},g={mount:new Set,unMount:new Set,array:new Set,watch:new Set},E,V=0,O={};const p={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={watch:De(),array:De(),state:De()},U=Je(i.mode),q=Je(i.reValidateMode),re=i.criteriaMode===$.all,le=r=>n=>{clearTimeout(V),V=window.setTimeout(r,n)},P=async()=>{let r=!1;return p.isValid&&(r=i.resolver?B((await K()).errors):await R(l,!0),r!==t.isValid&&(t.isValid=r,b.state.next({isValid:r}))),r},C=(r,n=[],o,c,d=!0,u=!0)=>{if(c&&o){if(m.action=!0,u&&Array.isArray(f(l,r))){const y=o(f(l,r),c.argA,c.argB);d&&A(l,r,y)}if(p.errors&&u&&Array.isArray(f(t.errors,r))){const y=o(f(t.errors,r),c.argA,c.argB);d&&A(t.errors,r,y),Rt(t.errors,r)}if(p.touchedFields&&u&&Array.isArray(f(t.touchedFields,r))){const y=o(f(t.touchedFields,r),c.argA,c.argB);d&&A(t.touchedFields,r,y)}p.dirtyFields&&(t.dirtyFields=_e(s,a)),b.state.next({isDirty:v(r,n),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else A(a,r,n)},H=(r,n)=>{A(t.errors,r,n),b.state.next({errors:t.errors})},D=(r,n,o,c)=>{const d=f(l,r);if(d){const u=f(a,r,T(o)?f(s,r):o);T(u)||c&&c.defaultChecked||n?A(a,r,n?u:Fe(d._f)):k(r,u),m.mount&&P()}},z=(r,n,o,c,d)=>{let u=!1;const y={name:r},F=f(t.touchedFields,r);if(p.isDirty){const M=t.isDirty;t.isDirty=y.isDirty=v(),u=M!==y.isDirty}if(p.dirtyFields&&(!o||c)){const M=f(t.dirtyFields,r);oe(f(s,r),n)?I(t.dirtyFields,r):A(t.dirtyFields,r,!0),y.dirtyFields=t.dirtyFields,u=u||M!==f(t.dirtyFields,r)}return o&&!F&&(A(t.touchedFields,r,o),y.touchedFields=t.touchedFields,u=u||p.touchedFields&&F!==o),u&&d&&b.state.next(y),u?y:{}},ie=(r,n,o,c)=>{const d=f(t.errors,r),u=p.isValid&&ce(n)&&t.isValid!==n;if(e.delayError&&o?(E=le(()=>H(r,o)),E(e.delayError)):(clearTimeout(V),E=null,o?A(t.errors,r,o):I(t.errors,r)),(o?!oe(d,o):d)||!B(c)||u){const y={...c,...u&&ce(n)?{isValid:n}:{},errors:t.errors,name:r};t={...t,...y},b.state.next(y)}O[r]--,p.isValidating&&!Object.values(O).some(y=>y)&&(b.state.next({isValidating:!1}),O={})},K=async r=>i.resolver?await i.resolver({...a},i.context,Ct(r||g.mount,l,i.criteriaMode,i.shouldUseNativeValidation)):{},J=async r=>{const{errors:n}=await K();if(r)for(const o of r){const c=f(n,o);c?A(t.errors,o,c):I(t.errors,o)}else t.errors=n;return n},R=async(r,n,o={valid:!0})=>{for(const c in r){const d=r[c];if(d){const{_f:u,...y}=d;if(u){const F=g.array.has(u.name),M=await ze(d,f(a,u.name),re,i.shouldUseNativeValidation,F);if(M[u.name]&&(o.valid=!1,n))break;!n&&(f(M,u.name)?F?St(t.errors,M,u.name):A(t.errors,u.name,M[u.name]):I(t.errors,u.name))}y&&await R(y,n,o)}}return o.valid},Z=()=>{for(const r of g.unMount){const n=f(l,r);n&&(n._f.refs?n._f.refs.every(o=>!Se(o)):!Se(n._f.ref))&&ke(r)}g.unMount=new Set},v=(r,n)=>(r&&n&&A(a,r,n),!oe(X(),s)),x=(r,n,o)=>{const c={...m.mount?a:T(n)?s:W(r)?{[r]:n}:n};return At(r,g,c,o)},S=r=>fe(f(m.mount?a:s,r,e.shouldUnregister?f(s,r,[]):[])),k=(r,n,o={})=>{const c=f(l,r);let d=n;if(c){const u=c._f;u&&(!u.disabled&&A(a,r,st(n,u)),d=Te&&Ce(u.ref)&&N(n)?"":n,rt(u.ref)?[...u.ref.options].forEach(y=>y.selected=d.includes(y.value)):u.refs?de(u.ref)?u.refs.length>1?u.refs.forEach(y=>(!y.defaultChecked||!y.disabled)&&(y.checked=Array.isArray(d)?!!d.find(F=>F===y.value):d===y.value)):u.refs[0]&&(u.refs[0].checked=!!d):u.refs.forEach(y=>y.checked=y.value===d):Oe(u.ref)?u.ref.value="":(u.ref.value=d,u.ref.type||b.watch.next({name:r})))}(o.shouldDirty||o.shouldTouch)&&z(r,d,o.shouldTouch,o.shouldDirty,!0),o.shouldValidate&&Q(r)},w=(r,n,o)=>{for(const c in n){const d=n[c],u=`${r}.${c}`,y=f(l,u);(g.array.has(r)||!be(d)||y&&!y._f)&&!ne(d)?w(u,d,o):k(u,d,o)}},_=(r,n,o={})=>{const c=f(l,r),d=g.array.has(r),u=te(n);A(a,r,u),d?(b.array.next({name:r,values:a}),(p.isDirty||p.dirtyFields)&&o.shouldDirty&&(t.dirtyFields=_e(s,a),b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:v(r,u)}))):c&&!c._f&&!N(u)?w(r,u,o):k(r,u,o),$e(r,g)&&b.state.next({}),b.watch.next({name:r})},G=async r=>{const n=r.target;let o=n.name;const c=f(l,o);if(c){let d,u;const y=n.type?Fe(c._f):bt(r),F=r.type===He.BLUR||r.type===He.FOCUS_OUT,M=!Lt(c._f)&&!i.resolver&&!f(t.errors,o)&&!c._f.deps||Ot(F,f(t.touchedFields,o),t.isSubmitted,q,U),ye=$e(o,g,F);A(a,o,y),F?(c._f.onBlur&&c._f.onBlur(r),E&&E(0)):c._f.onChange&&c._f.onChange(r);const Ee=z(o,y,F,!1),dt=!B(Ee)||ye;if(!F&&b.watch.next({name:o,type:r.type}),M)return p.isValid&&P(),dt&&b.state.next({name:o,...ye?{}:Ee});if(!F&&ye&&b.state.next({}),O[o]=O[o]?O[o]+1:1,b.state.next({isValidating:!0}),i.resolver){const{errors:Ne}=await K([o]),ft=Qe(t.errors,l,o),qe=Qe(Ne,l,ft.name||o);d=qe.error,o=qe.name,u=B(Ne)}else d=(await ze(c,f(a,o),re,i.shouldUseNativeValidation))[o],P();c._f.deps&&Q(c._f.deps),ie(o,u,d,Ee)}},Q=async(r,n={})=>{let o,c;const d=Ae(r);if(b.state.next({isValidating:!0}),i.resolver){const u=await J(T(r)?r:d);o=B(u),c=r?!d.some(y=>f(u,y)):o}else r?(c=(await Promise.all(d.map(async u=>{const y=f(l,u);return await R(y&&y._f?{[u]:y}:y)}))).every(Boolean),!(!c&&!t.isValid)&&P()):c=o=await R(l);return b.state.next({...!W(r)||p.isValid&&o!==t.isValid?{}:{name:r},...i.resolver||!r?{isValid:o}:{},errors:t.errors,isValidating:!1}),n.shouldFocus&&!c&&Ve(l,u=>u&&f(t.errors,u),r?d:g.mount),c},X=r=>{const n={...s,...m.mount?a:{}};return T(r)?n:W(r)?f(n,r):r.map(o=>f(n,o))},Me=(r,n)=>({invalid:!!f((n||t).errors,r),isDirty:!!f((n||t).dirtyFields,r),isTouched:!!f((n||t).touchedFields,r),error:f((n||t).errors,r)}),nt=r=>{r?Ae(r).forEach(n=>I(t.errors,n)):t.errors={},b.state.next({errors:t.errors})},ot=(r,n,o)=>{const c=(f(l,r,{_f:{}})._f||{}).ref;A(t.errors,r,{...n,ref:c}),b.state.next({name:r,errors:t.errors,isValid:!1}),o&&o.shouldFocus&&c&&c.focus&&c.focus()},lt=(r,n)=>he(r)?b.watch.subscribe({next:o=>r(x(void 0,n),o)}):x(r,n,!0),ke=(r,n={})=>{for(const o of r?Ae(r):g.mount)g.mount.delete(o),g.array.delete(o),f(l,o)&&(n.keepValue||(I(l,o),I(a,o)),!n.keepError&&I(t.errors,o),!n.keepDirty&&I(t.dirtyFields,o),!n.keepTouched&&I(t.touchedFields,o),!i.shouldUnregister&&!n.keepDefaultValue&&I(s,o));b.watch.next({}),b.state.next({...t,...n.keepDirty?{isDirty:v()}:{}}),!n.keepIsValid&&P()},pe=(r,n={})=>{let o=f(l,r);const c=ce(n.disabled);return A(l,r,{...o||{},_f:{...o&&o._f?o._f:{ref:{name:r}},name:r,mount:!0,...n}}),g.mount.add(r),o?c&&A(a,r,n.disabled?void 0:f(a,r,Fe(o._f))):D(r,!0,n.value),{...c?{disabled:n.disabled}:{},...i.shouldUseNativeValidation?{required:!!n.required,min:ue(n.min),max:ue(n.max),minLength:ue(n.minLength),maxLength:ue(n.maxLength),pattern:ue(n.pattern)}:{},name:r,onChange:G,onBlur:G,ref:d=>{if(d){pe(r,n),o=f(l,r);const u=T(d.value)&&d.querySelectorAll&&d.querySelectorAll("input,select,textarea")[0]||d,y=Tt(u),F=o._f.refs||[];if(y?F.find(M=>M===u):u===o._f.ref)return;A(l,r,{_f:{...o._f,...y?{refs:[...F.filter(Se),u,...Array.isArray(f(s,r))?[{}]:[]],ref:{type:u.type,name:r}}:{ref:u}}}),D(r,!1,void 0,u)}else o=f(l,r,{}),o._f&&(o._f.mount=!1),(i.shouldUnregister||n.shouldUnregister)&&!(kt(g.array,r)&&m.action)&&g.unMount.add(r)}}},Ie=()=>i.shouldFocusError&&Ve(l,r=>r&&f(t.errors,r),g.mount),at=(r,n)=>async o=>{o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let c=!0,d=te(a);b.state.next({isSubmitting:!0});try{if(i.resolver){const{errors:u,values:y}=await K();t.errors=u,d=y}else await R(l);B(t.errors)?(b.state.next({errors:{},isSubmitting:!0}),await r(d,o)):(n&&await n({...t.errors},o),Ie())}catch(u){throw c=!1,u}finally{t.isSubmitted=!0,b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(t.errors)&&c,submitCount:t.submitCount+1,errors:t.errors})}},ut=(r,n={})=>{f(l,r)&&(T(n.defaultValue)?_(r,f(s,r)):(_(r,n.defaultValue),A(s,r,n.defaultValue)),n.keepTouched||I(t.touchedFields,r),n.keepDirty||(I(t.dirtyFields,r),t.isDirty=n.defaultValue?v(r,f(s,r)):v()),n.keepError||(I(t.errors,r),p.isValid&&P()),b.state.next({...t}))},ct=(r,n={})=>{const o=r||s,c=te(o),d=r&&!B(r)?c:s;if(n.keepDefaultValues||(s=o),!n.keepValues){if(n.keepDirtyValues)for(const u of g.mount)f(t.dirtyFields,u)?A(d,u,f(a,u)):_(u,f(d,u));else{if(Te&&T(r))for(const u of g.mount){const y=f(l,u);if(y&&y._f){const F=Array.isArray(y._f.refs)?y._f.refs[0]:y._f.ref;if(Ce(F)){const M=F.closest("form");if(M){M.reset();break}}}}l={}}a=e.shouldUnregister?n.keepDefaultValues?te(s):{}:c,b.array.next({values:d}),b.watch.next({values:d})}g={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},m.mount=!p.isValid||!!n.keepIsValid,m.watch=!!e.shouldUnregister,b.state.next({submitCount:n.keepSubmitCount?t.submitCount:0,isDirty:n.keepDirty||n.keepDirtyValues?t.isDirty:!!(n.keepDefaultValues&&!oe(r,s)),isSubmitted:n.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:n.keepDirty||n.keepDirtyValues?t.dirtyFields:n.keepDefaultValues&&r?_e(s,r):{},touchedFields:n.keepTouched?t.touchedFields:{},errors:n.keepErrors?t.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})};return{control:{register:pe,unregister:ke,getFieldState:Me,_executeSchema:K,_focusError:Ie,_getWatch:x,_getDirty:v,_updateValid:P,_removeUnmounted:Z,_updateFieldArray:C,_getFieldArray:S,_subjects:b,_proxyFormState:p,get _fields(){return l},get _formValues(){return a},get _stateFlags(){return m},set _stateFlags(r){m=r},get _defaultValues(){return s},get _names(){return g},set _names(r){g=r},get _formState(){return t},set _formState(r){t=r},get _options(){return i},set _options(r){i={...i,...r}}},trigger:Q,register:pe,handleSubmit:at,watch:lt,setValue:_,getValues:X,reset:(r,n)=>ct(he(r)?r(a):r,n),resetField:ut,clearErrors:nt,unregister:ke,setError:ot,setFocus:(r,n={})=>{const o=f(l,r),c=o&&o._f;if(c){const d=c.refs?c.refs[0]:c.ref;d.focus&&(d.focus(),n.shouldSelect&&d.select())}},getFieldState:Me}}function Nt(e={}){const i=h.useRef(),[t,l]=h.useState({isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:e.defaultValues});i.current||(i.current={...It(e),formState:t});const s=i.current.control;return s._options=e,wt({subject:s._subjects.state,callback:h.useCallback(a=>{Et(a,s._proxyFormState,!0)&&(s._formState={...s._formState,...a},l({...s._formState}))},[s])}),h.useEffect(()=>{s._stateFlags.mount||(s._proxyFormState.isValid&&s._updateValid(),s._stateFlags.mount=!0),s._stateFlags.watch&&(s._stateFlags.watch=!1,s._subjects.state.next({})),s._removeUnmounted()}),h.useEffect(()=>{t.submitCount&&s._focusError()},[s,t.submitCount]),i.current.formState=pt(t,s),i.current}var qt=(e=>(e.formgroup="formgroup",e.checkbox="checkbox",e.radiobutton="radiobutton",e.textarea="textarea",e.input="input",e.select="select",e.date="date",e))(qt||{});const Cr=e=>{const{exampleType:i="formgroup"}=e,{register:t,handleSubmit:l,formState:{errors:s}}=Nt(),a=new Date;a.setHours(0),a.setMinutes(0),a.setSeconds(0);const m=new Date;m.setDate(a.getDate()-5),m.setHours(6),m.setMinutes(10),m.setSeconds(0);const g=new Date;g.setDate(a.getDate()+5),g.setHours(22),g.setMinutes(0),g.setSeconds(0);const E="field1",V="field2",O="field3",p="field4",b="field5",U="field6",q="field7",re="field8",le="field9",P=s.field1||s.field2||s.field3||s.field4||s.field5||s.field6||s.field7||s.field8||s.field9,C="Du m\xE5 velge et alternativ",H="Du m\xE5 velge to alternativ",D="Det kan ikke legges inn mer enn 40 tegn",z="Du m\xE5 skrive noe her",ie='Du m\xE5 velge "Option 2"',K=`Du m\xE5 velge dato mellom ${m.toLocaleDateString("nb")} og ${g.toLocaleDateString("nb")}`,J=`Du m\xE5 skrive inn tidspunkt mellom ${m.toLocaleTimeString("nb",{hour:"2-digit",minute:"2-digit"})} og ${g.toLocaleTimeString("nb",{hour:"2-digit",minute:"2-digit"})}`,R=k=>k.length>=2||H,Z=k=>k.toString()==="Option 2"||ie,v=(k,w,_)=>{const G=new Date(k);return!!k&&G.getTime()>=w.getTime()&&G.getTime()<=_.getTime()||K},x=(k,w)=>{const _=new Date;_.setHours(k),_.setMinutes(w),_.setSeconds(0);const G=m.toLocaleTimeString("nb"),Q=g.toLocaleTimeString("nb"),X=_.toLocaleTimeString("nb");return console.log("value",X),!!_&&X>=G&&X<=Q||J},S=()=>{if(i==="formgroup"){const k=[h.createElement(ee,{key:0,inputId:"checkbox1",label:"Checkbox 1",...t(E,{required:C})}),h.createElement(ee,{key:1,inputId:"checkbox2",label:"Checkbox 2",...t(E,{required:C})}),h.createElement(ee,{key:2,inputId:"checkbox3",label:"Checkbox 3",...t(E,{required:C})})];return[h.createElement(Y,{key:0,title:"Gruppe tittel",legend:"Velg minst en",error:s.field1?s.field1.message:void 0,variant:e.variant},h.createElement(gt,{maxColumns:ht.two},k.map(w=>w))),h.createElement(Y,{key:1,legend:"Velg minst to",error:s.field2?s.field2.message:void 0,variant:e.variant},h.createElement(ee,{inputId:"checkbox4",label:"Checkbox 4",...t(V,{validate:R})}),h.createElement(ee,{inputId:"checkbox5",label:"Checkbox 5",...t(V,{validate:R})}),h.createElement(ee,{inputId:"checkbox6",label:"Checkbox 6",...t(V,{validate:R})})),h.createElement(Y,{key:2,legend:"Velg en",error:s.field3?s.field3.message:void 0,variant:e.variant},h.createElement(me,{inputId:"radiobutton1",label:"Radiobutton 1",...t(O,{required:C})}),h.createElement(me,{inputId:"radiobutton2",label:"Radiobutton 2",...t(O,{required:C})}),h.createElement(me,{inputId:"radiobutton3",label:"Radiobutton 3",...t(O,{required:C})})),h.createElement(Y,{key:3,error:s.field4?s.field4.message:void 0},h.createElement(Be,{defaultValue:`Dette er en test
|
|
1
|
+
import h from"react";import{V as yt}from"../../Validation.js";import{F as Y}from"../../FormGroup.js";import{C as ee}from"../../Checkbox.js";import{B as mt}from"../../Button.js";import{R as me}from"../../RadioButton.js";import{T as Be}from"../../Textarea.js";import{I as ae}from"../../Input.js";import Ue from"../Icons/Hospital.js";import{F as gt,a as ht}from"../../FormLayout.js";import{isTest as vt}from"../../utils/environment.js";import{S as Pe}from"../../Select.js";import we from"./styles.module.scss";import"classnames";import"../Validation/styles.module.scss";import"../../constants.js";import"../FormGroup/styles.module.scss";import"../../Title.js";import"../Title/styles.module.scss";import"../../ErrorWrapper.js";import"../ErrorWrapper/styles.module.scss";import"../../utils/component.js";import"../../uuid.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../hooks/useUuid.js";import"../../theme/currys/color.js";import"../../theme/index.js";import"../../theme/palette.js";import"../../theme/spacers.js";import"../../theme/grid.js";import"../Checkbox/styles.module.scss";import"../../hooks/useHover.js";import"../../hooks/useIcons.js";import"../../hooks/useBreakpoint.js";import"../Button/styles.module.scss";import"../Icons/ArrowRight.js";import"../../hooks/useSize.js";import"../../utils/debounce.js";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../Input/styles.module.scss";import"../FormLayout/styles.module.scss";import"../Select/styles.module.scss";import"../Icons/ChevronDown.js";var de=e=>e.type==="checkbox",ne=e=>e instanceof Date,N=e=>e==null;const Xe=e=>typeof e=="object";var L=e=>!N(e)&&!Array.isArray(e)&&Xe(e)&&!ne(e),bt=e=>L(e)&&e.target?de(e.target)?e.target.checked:e.target.value:e,xt=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,kt=(e,i)=>e.has(xt(i)),fe=e=>Array.isArray(e)?e.filter(Boolean):[],T=e=>e===void 0,f=(e,i,t)=>{if(!i||!L(e))return t;const l=fe(i.split(/[,[\].]+?/)).reduce((s,a)=>N(s)?s:s[a],e);return T(l)||l===e?T(e[i])?t:e[i]:l};const He={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},$={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},j={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};h.createContext(null);var pt=(e,i,t,l=!0)=>{const s={defaultValues:i._defaultValues};for(const a in e)Object.defineProperty(s,a,{get:()=>{const m=a;return i._proxyFormState[m]!==$.all&&(i._proxyFormState[m]=!l||$.all),t&&(t[m]=!0),e[m]}});return s},B=e=>L(e)&&!Object.keys(e).length,Et=(e,i,t)=>{const{name:l,...s}=e;return B(s)||Object.keys(s).length>=Object.keys(i).length||Object.keys(s).find(a=>i[a]===(!t||$.all))},Ae=e=>Array.isArray(e)?e:[e];function wt(e){const i=h.useRef(e);i.current=e,h.useEffect(()=>{const t=!e.disabled&&i.current.subject.subscribe({next:i.current.callback});return()=>{t&&t.unsubscribe()}},[e.disabled])}var W=e=>typeof e=="string",At=(e,i,t,l)=>{const s=Array.isArray(e);return W(e)?(l&&i.watch.add(e),f(t,e)):s?e.map(a=>(l&&i.watch.add(a),f(t,a))):(l&&(i.watchAll=!0),t)},he=e=>typeof e=="function",Ye=e=>{for(const i in e)if(he(e[i]))return!0;return!1},Dt=(e,i,t,l,s)=>i?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[l]:s||!0}}:{},Le=e=>/^\w*$/.test(e),Ze=e=>fe(e.replace(/["|']|\]/g,"").split(/\.|\[/));function A(e,i,t){let l=-1;const s=Le(i)?[i]:Ze(i),a=s.length,m=a-1;for(;++l<a;){const g=s[l];let E=t;if(l!==m){const V=e[g];E=L(V)||Array.isArray(V)?V:isNaN(+s[l+1])?{}:[]}e[g]=E,e=e[g]}return e}const Ve=(e,i,t)=>{for(const l of t||Object.keys(e)){const s=f(e,l);if(s){const{_f:a,...m}=s;if(a&&i(a.name)){if(a.ref.focus){a.ref.focus();break}else if(a.refs&&a.refs[0].focus){a.refs[0].focus();break}}else L(m)&&Ve(m,i)}}};var $e=(e,i,t)=>!t&&(i.watchAll||i.watch.has(e)||[...i.watch].some(l=>e.startsWith(l)&&/^\.\w+/.test(e.slice(l.length)))),St=(e,i,t)=>{const l=fe(f(e,t));return A(l,"root",i[t]),A(e,t,l),e},ce=e=>typeof e=="boolean",Oe=e=>e.type==="file",ge=e=>W(e)||h.isValidElement(e),Re=e=>e.type==="radio",ve=e=>e instanceof RegExp;const We={value:!1,isValid:!1},Ge={value:!0,isValid:!0};var et=e=>{if(Array.isArray(e)){if(e.length>1){const i=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:i,isValid:!!i.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!T(e[0].attributes.value)?T(e[0].value)||e[0].value===""?Ge:{value:e[0].value,isValid:!0}:Ge:We}return We};const Ke={isValid:!1,value:null};var tt=e=>Array.isArray(e)?e.reduce((i,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:i,Ke):Ke;function je(e,i,t="validate"){if(ge(e)||Array.isArray(e)&&e.every(ge)||ce(e)&&!e)return{type:t,message:ge(e)?e:"",ref:i}}var se=e=>L(e)&&!ve(e)?e:{value:e,message:""},ze=async(e,i,t,l,s)=>{const{ref:a,refs:m,required:g,maxLength:E,minLength:V,min:O,max:p,pattern:b,validate:U,name:q,valueAsNumber:re,mount:le,disabled:P}=e._f;if(!le||P)return{};const C=m?m[0]:a,H=v=>{l&&W(v)&&(C.setCustomValidity(v),C.reportValidity())},D={},z=Re(a),ie=de(a),K=z||ie,J=(re||Oe(a))&&!a.value||i===""||Array.isArray(i)&&!i.length,R=Dt.bind(null,q,t,D),Z=(v,x,S,k=j.maxLength,w=j.minLength)=>{const _=v?x:S;D[q]={type:v?k:w,message:_,ref:a,...R(v?k:w,_)}};if(s?!Array.isArray(i)||!i.length:g&&(!K&&(J||N(i))||ce(i)&&!i||ie&&!et(m).isValid||z&&!tt(m).isValid)){const{value:v,message:x}=ge(g)?{value:!!g,message:g}:se(g);if(v&&(D[q]={type:j.required,message:x,ref:C,...R(j.required,x)},!t))return H(x),D}if(!J&&(!N(O)||!N(p))){let v,x;const S=se(p),k=se(O);if(!N(i)&&!isNaN(i)){const w=a.valueAsNumber||i&&+i;N(S.value)||(v=w>S.value),N(k.value)||(x=w<k.value)}else{const w=a.valueAsDate||new Date(i),_=X=>new Date(new Date().toDateString()+" "+X),G=a.type=="time",Q=a.type=="week";W(S.value)&&i&&(v=G?_(i)>_(S.value):Q?i>S.value:w>new Date(S.value)),W(k.value)&&i&&(x=G?_(i)<_(k.value):Q?i<k.value:w<new Date(k.value))}if((v||x)&&(Z(!!v,S.message,k.message,j.max,j.min),!t))return H(D[q].message),D}if((E||V)&&!J&&(W(i)||s&&Array.isArray(i))){const v=se(E),x=se(V),S=!N(v.value)&&i.length>v.value,k=!N(x.value)&&i.length<x.value;if((S||k)&&(Z(S,v.message,x.message),!t))return H(D[q].message),D}if(b&&!J&&W(i)){const{value:v,message:x}=se(b);if(ve(v)&&!i.match(v)&&(D[q]={type:j.pattern,message:x,ref:a,...R(j.pattern,x)},!t))return H(x),D}if(U){if(he(U)){const v=await U(i),x=je(v,C);if(x&&(D[q]={...x,...R(j.validate,x.message)},!t))return H(x.message),D}else if(L(U)){let v={};for(const x in U){if(!B(v)&&!t)break;const S=je(await U[x](i),C,x);S&&(v={...S,...R(x,S.message)},H(S.message),t&&(D[q]=v))}if(!B(v)&&(D[q]={ref:C,...v},!t))return D}}return H(!0),D},_t=e=>{const i=e.constructor&&e.constructor.prototype;return L(i)&&i.hasOwnProperty("isPrototypeOf")},Te=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function te(e){let i;const t=Array.isArray(e);if(e instanceof Date)i=new Date(e);else if(e instanceof Set)i=new Set(e);else if(!(Te&&(e instanceof Blob||e instanceof FileList))&&(t||L(e)))if(i=t?[]:{},!Array.isArray(e)&&!_t(e))i=e;else for(const l in e)i[l]=te(e[l]);else return e;return i}var Je=e=>({isOnSubmit:!e||e===$.onSubmit,isOnBlur:e===$.onBlur,isOnChange:e===$.onChange,isOnAll:e===$.all,isOnTouch:e===$.onTouched});function Ft(e,i){const t=i.slice(0,-1).length;let l=0;for(;l<t;)e=T(e)?l++:e[i[l++]];return e}function Vt(e){for(const i in e)if(!T(e[i]))return!1;return!0}function I(e,i){const t=Le(i)?[i]:Ze(i),l=t.length==1?e:Ft(e,t),s=t[t.length-1];let a;l&&delete l[s];for(let m=0;m<t.slice(0,-1).length;m++){let g=-1,E;const V=t.slice(0,-(m+1)),O=V.length-1;for(m>0&&(a=e);++g<V.length;){const p=V[g];E=E?E[p]:e[p],O===g&&(L(E)&&B(E)||Array.isArray(E)&&Vt(E))&&(a?delete a[p]:delete e[p]),a=E}}return e}function De(){let e=[];return{get observers(){return e},next:s=>{for(const a of e)a.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(a=>a!==s)}}),unsubscribe:()=>{e=[]}}}var be=e=>N(e)||!Xe(e);function oe(e,i){if(be(e)||be(i))return e===i;if(ne(e)&&ne(i))return e.getTime()===i.getTime();const t=Object.keys(e),l=Object.keys(i);if(t.length!==l.length)return!1;for(const s of t){const a=e[s];if(!l.includes(s))return!1;if(s!=="ref"){const m=i[s];if(ne(a)&&ne(m)||L(a)&&L(m)||Array.isArray(a)&&Array.isArray(m)?!oe(a,m):a!==m)return!1}}return!0}var Ce=e=>{const i=e?e.ownerDocument:0,t=i&&i.defaultView?i.defaultView.HTMLElement:HTMLElement;return e instanceof t},rt=e=>e.type==="select-multiple",Tt=e=>Re(e)||de(e),Se=e=>Ce(e)&&e.isConnected;function xe(e,i={}){const t=Array.isArray(e);if(L(e)||t)for(const l in e)Array.isArray(e[l])||L(e[l])&&!Ye(e[l])?(i[l]=Array.isArray(e[l])?[]:{},xe(e[l],i[l])):N(e[l])||(i[l]=!0);return i}function it(e,i,t){const l=Array.isArray(e);if(L(e)||l)for(const s in e)Array.isArray(e[s])||L(e[s])&&!Ye(e[s])?T(i)||be(t[s])?t[s]=Array.isArray(e[s])?xe(e[s],[]):{...xe(e[s])}:it(e[s],N(i)?{}:i[s],t[s]):oe(e[s],i[s])?delete t[s]:t[s]=!0;return t}var _e=(e,i)=>it(e,i,xe(i)),st=(e,{valueAsNumber:i,valueAsDate:t,setValueAs:l})=>T(e)?e:i?e===""?NaN:e&&+e:t&&W(e)?new Date(e):l?l(e):e;function Fe(e){const i=e.ref;if(!(e.refs?e.refs.every(t=>t.disabled):i.disabled))return Oe(i)?i.files:Re(i)?tt(e.refs).value:rt(i)?[...i.selectedOptions].map(({value:t})=>t):de(i)?et(e.refs).value:st(T(i.value)?e.ref.value:i.value,e)}var Ct=(e,i,t,l)=>{const s={};for(const a of e){const m=f(i,a);m&&A(s,a,m._f)}return{criteriaMode:t,names:[...e],fields:s,shouldUseNativeValidation:l}},ue=e=>T(e)?void 0:ve(e)?e.source:L(e)?ve(e.value)?e.value.source:e.value:e,Lt=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Qe(e,i,t){const l=f(e,t);if(l||Le(t))return{error:l,name:t};const s=t.split(".");for(;s.length;){const a=s.join("."),m=f(i,a),g=f(e,a);if(m&&!Array.isArray(m)&&t!==a)return{name:t};if(g&&g.type)return{name:a,error:g};s.pop()}return{name:t}}var Ot=(e,i,t,l,s)=>s.isOnAll?!1:!t&&s.isOnTouch?!(i||e):(t?l.isOnBlur:s.isOnBlur)?!e:(t?l.isOnChange:s.isOnChange)?e:!0,Rt=(e,i)=>!fe(f(e,i)).length&&I(e,i);const Mt={mode:$.onSubmit,reValidateMode:$.onChange,shouldFocusError:!0};function It(e={}){let i={...Mt,...e},t={submitCount:0,isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},l={},s=te(i.defaultValues)||{},a=i.shouldUnregister?{}:te(s),m={action:!1,mount:!1,watch:!1},g={mount:new Set,unMount:new Set,array:new Set,watch:new Set},E,V=0,O={};const p={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={watch:De(),array:De(),state:De()},U=Je(i.mode),q=Je(i.reValidateMode),re=i.criteriaMode===$.all,le=r=>n=>{clearTimeout(V),V=window.setTimeout(r,n)},P=async()=>{let r=!1;return p.isValid&&(r=i.resolver?B((await K()).errors):await R(l,!0),r!==t.isValid&&(t.isValid=r,b.state.next({isValid:r}))),r},C=(r,n=[],o,c,d=!0,u=!0)=>{if(c&&o){if(m.action=!0,u&&Array.isArray(f(l,r))){const y=o(f(l,r),c.argA,c.argB);d&&A(l,r,y)}if(p.errors&&u&&Array.isArray(f(t.errors,r))){const y=o(f(t.errors,r),c.argA,c.argB);d&&A(t.errors,r,y),Rt(t.errors,r)}if(p.touchedFields&&u&&Array.isArray(f(t.touchedFields,r))){const y=o(f(t.touchedFields,r),c.argA,c.argB);d&&A(t.touchedFields,r,y)}p.dirtyFields&&(t.dirtyFields=_e(s,a)),b.state.next({isDirty:v(r,n),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else A(a,r,n)},H=(r,n)=>{A(t.errors,r,n),b.state.next({errors:t.errors})},D=(r,n,o,c)=>{const d=f(l,r);if(d){const u=f(a,r,T(o)?f(s,r):o);T(u)||c&&c.defaultChecked||n?A(a,r,n?u:Fe(d._f)):k(r,u),m.mount&&P()}},z=(r,n,o,c,d)=>{let u=!1;const y={name:r},F=f(t.touchedFields,r);if(p.isDirty){const M=t.isDirty;t.isDirty=y.isDirty=v(),u=M!==y.isDirty}if(p.dirtyFields&&(!o||c)){const M=f(t.dirtyFields,r);oe(f(s,r),n)?I(t.dirtyFields,r):A(t.dirtyFields,r,!0),y.dirtyFields=t.dirtyFields,u=u||M!==f(t.dirtyFields,r)}return o&&!F&&(A(t.touchedFields,r,o),y.touchedFields=t.touchedFields,u=u||p.touchedFields&&F!==o),u&&d&&b.state.next(y),u?y:{}},ie=(r,n,o,c)=>{const d=f(t.errors,r),u=p.isValid&&ce(n)&&t.isValid!==n;if(e.delayError&&o?(E=le(()=>H(r,o)),E(e.delayError)):(clearTimeout(V),E=null,o?A(t.errors,r,o):I(t.errors,r)),(o?!oe(d,o):d)||!B(c)||u){const y={...c,...u&&ce(n)?{isValid:n}:{},errors:t.errors,name:r};t={...t,...y},b.state.next(y)}O[r]--,p.isValidating&&!Object.values(O).some(y=>y)&&(b.state.next({isValidating:!1}),O={})},K=async r=>i.resolver?await i.resolver({...a},i.context,Ct(r||g.mount,l,i.criteriaMode,i.shouldUseNativeValidation)):{},J=async r=>{const{errors:n}=await K();if(r)for(const o of r){const c=f(n,o);c?A(t.errors,o,c):I(t.errors,o)}else t.errors=n;return n},R=async(r,n,o={valid:!0})=>{for(const c in r){const d=r[c];if(d){const{_f:u,...y}=d;if(u){const F=g.array.has(u.name),M=await ze(d,f(a,u.name),re,i.shouldUseNativeValidation,F);if(M[u.name]&&(o.valid=!1,n))break;!n&&(f(M,u.name)?F?St(t.errors,M,u.name):A(t.errors,u.name,M[u.name]):I(t.errors,u.name))}y&&await R(y,n,o)}}return o.valid},Z=()=>{for(const r of g.unMount){const n=f(l,r);n&&(n._f.refs?n._f.refs.every(o=>!Se(o)):!Se(n._f.ref))&&ke(r)}g.unMount=new Set},v=(r,n)=>(r&&n&&A(a,r,n),!oe(X(),s)),x=(r,n,o)=>{const c={...m.mount?a:T(n)?s:W(r)?{[r]:n}:n};return At(r,g,c,o)},S=r=>fe(f(m.mount?a:s,r,e.shouldUnregister?f(s,r,[]):[])),k=(r,n,o={})=>{const c=f(l,r);let d=n;if(c){const u=c._f;u&&(!u.disabled&&A(a,r,st(n,u)),d=Te&&Ce(u.ref)&&N(n)?"":n,rt(u.ref)?[...u.ref.options].forEach(y=>y.selected=d.includes(y.value)):u.refs?de(u.ref)?u.refs.length>1?u.refs.forEach(y=>(!y.defaultChecked||!y.disabled)&&(y.checked=Array.isArray(d)?!!d.find(F=>F===y.value):d===y.value)):u.refs[0]&&(u.refs[0].checked=!!d):u.refs.forEach(y=>y.checked=y.value===d):Oe(u.ref)?u.ref.value="":(u.ref.value=d,u.ref.type||b.watch.next({name:r})))}(o.shouldDirty||o.shouldTouch)&&z(r,d,o.shouldTouch,o.shouldDirty,!0),o.shouldValidate&&Q(r)},w=(r,n,o)=>{for(const c in n){const d=n[c],u=`${r}.${c}`,y=f(l,u);(g.array.has(r)||!be(d)||y&&!y._f)&&!ne(d)?w(u,d,o):k(u,d,o)}},_=(r,n,o={})=>{const c=f(l,r),d=g.array.has(r),u=te(n);A(a,r,u),d?(b.array.next({name:r,values:a}),(p.isDirty||p.dirtyFields)&&o.shouldDirty&&(t.dirtyFields=_e(s,a),b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:v(r,u)}))):c&&!c._f&&!N(u)?w(r,u,o):k(r,u,o),$e(r,g)&&b.state.next({}),b.watch.next({name:r})},G=async r=>{const n=r.target;let o=n.name;const c=f(l,o);if(c){let d,u;const y=n.type?Fe(c._f):bt(r),F=r.type===He.BLUR||r.type===He.FOCUS_OUT,M=!Lt(c._f)&&!i.resolver&&!f(t.errors,o)&&!c._f.deps||Ot(F,f(t.touchedFields,o),t.isSubmitted,q,U),ye=$e(o,g,F);A(a,o,y),F?(c._f.onBlur&&c._f.onBlur(r),E&&E(0)):c._f.onChange&&c._f.onChange(r);const Ee=z(o,y,F,!1),dt=!B(Ee)||ye;if(!F&&b.watch.next({name:o,type:r.type}),M)return p.isValid&&P(),dt&&b.state.next({name:o,...ye?{}:Ee});if(!F&&ye&&b.state.next({}),O[o]=O[o]?O[o]+1:1,b.state.next({isValidating:!0}),i.resolver){const{errors:Ne}=await K([o]),ft=Qe(t.errors,l,o),qe=Qe(Ne,l,ft.name||o);d=qe.error,o=qe.name,u=B(Ne)}else d=(await ze(c,f(a,o),re,i.shouldUseNativeValidation))[o],P();c._f.deps&&Q(c._f.deps),ie(o,u,d,Ee)}},Q=async(r,n={})=>{let o,c;const d=Ae(r);if(b.state.next({isValidating:!0}),i.resolver){const u=await J(T(r)?r:d);o=B(u),c=r?!d.some(y=>f(u,y)):o}else r?(c=(await Promise.all(d.map(async u=>{const y=f(l,u);return await R(y&&y._f?{[u]:y}:y)}))).every(Boolean),!(!c&&!t.isValid)&&P()):c=o=await R(l);return b.state.next({...!W(r)||p.isValid&&o!==t.isValid?{}:{name:r},...i.resolver||!r?{isValid:o}:{},errors:t.errors,isValidating:!1}),n.shouldFocus&&!c&&Ve(l,u=>u&&f(t.errors,u),r?d:g.mount),c},X=r=>{const n={...s,...m.mount?a:{}};return T(r)?n:W(r)?f(n,r):r.map(o=>f(n,o))},Me=(r,n)=>({invalid:!!f((n||t).errors,r),isDirty:!!f((n||t).dirtyFields,r),isTouched:!!f((n||t).touchedFields,r),error:f((n||t).errors,r)}),nt=r=>{r?Ae(r).forEach(n=>I(t.errors,n)):t.errors={},b.state.next({errors:t.errors})},ot=(r,n,o)=>{const c=(f(l,r,{_f:{}})._f||{}).ref;A(t.errors,r,{...n,ref:c}),b.state.next({name:r,errors:t.errors,isValid:!1}),o&&o.shouldFocus&&c&&c.focus&&c.focus()},lt=(r,n)=>he(r)?b.watch.subscribe({next:o=>r(x(void 0,n),o)}):x(r,n,!0),ke=(r,n={})=>{for(const o of r?Ae(r):g.mount)g.mount.delete(o),g.array.delete(o),f(l,o)&&(n.keepValue||(I(l,o),I(a,o)),!n.keepError&&I(t.errors,o),!n.keepDirty&&I(t.dirtyFields,o),!n.keepTouched&&I(t.touchedFields,o),!i.shouldUnregister&&!n.keepDefaultValue&&I(s,o));b.watch.next({}),b.state.next({...t,...n.keepDirty?{isDirty:v()}:{}}),!n.keepIsValid&&P()},pe=(r,n={})=>{let o=f(l,r);const c=ce(n.disabled);return A(l,r,{...o||{},_f:{...o&&o._f?o._f:{ref:{name:r}},name:r,mount:!0,...n}}),g.mount.add(r),o?c&&A(a,r,n.disabled?void 0:f(a,r,Fe(o._f))):D(r,!0,n.value),{...c?{disabled:n.disabled}:{},...i.shouldUseNativeValidation?{required:!!n.required,min:ue(n.min),max:ue(n.max),minLength:ue(n.minLength),maxLength:ue(n.maxLength),pattern:ue(n.pattern)}:{},name:r,onChange:G,onBlur:G,ref:d=>{if(d){pe(r,n),o=f(l,r);const u=T(d.value)&&d.querySelectorAll&&d.querySelectorAll("input,select,textarea")[0]||d,y=Tt(u),F=o._f.refs||[];if(y?F.find(M=>M===u):u===o._f.ref)return;A(l,r,{_f:{...o._f,...y?{refs:[...F.filter(Se),u,...Array.isArray(f(s,r))?[{}]:[]],ref:{type:u.type,name:r}}:{ref:u}}}),D(r,!1,void 0,u)}else o=f(l,r,{}),o._f&&(o._f.mount=!1),(i.shouldUnregister||n.shouldUnregister)&&!(kt(g.array,r)&&m.action)&&g.unMount.add(r)}}},Ie=()=>i.shouldFocusError&&Ve(l,r=>r&&f(t.errors,r),g.mount),at=(r,n)=>async o=>{o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let c=!0,d=te(a);b.state.next({isSubmitting:!0});try{if(i.resolver){const{errors:u,values:y}=await K();t.errors=u,d=y}else await R(l);B(t.errors)?(b.state.next({errors:{},isSubmitting:!0}),await r(d,o)):(n&&await n({...t.errors},o),Ie())}catch(u){throw c=!1,u}finally{t.isSubmitted=!0,b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(t.errors)&&c,submitCount:t.submitCount+1,errors:t.errors})}},ut=(r,n={})=>{f(l,r)&&(T(n.defaultValue)?_(r,f(s,r)):(_(r,n.defaultValue),A(s,r,n.defaultValue)),n.keepTouched||I(t.touchedFields,r),n.keepDirty||(I(t.dirtyFields,r),t.isDirty=n.defaultValue?v(r,f(s,r)):v()),n.keepError||(I(t.errors,r),p.isValid&&P()),b.state.next({...t}))},ct=(r,n={})=>{const o=r||s,c=te(o),d=r&&!B(r)?c:s;if(n.keepDefaultValues||(s=o),!n.keepValues){if(n.keepDirtyValues)for(const u of g.mount)f(t.dirtyFields,u)?A(d,u,f(a,u)):_(u,f(d,u));else{if(Te&&T(r))for(const u of g.mount){const y=f(l,u);if(y&&y._f){const F=Array.isArray(y._f.refs)?y._f.refs[0]:y._f.ref;if(Ce(F)){const M=F.closest("form");if(M){M.reset();break}}}}l={}}a=e.shouldUnregister?n.keepDefaultValues?te(s):{}:c,b.array.next({values:d}),b.watch.next({values:d})}g={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},m.mount=!p.isValid||!!n.keepIsValid,m.watch=!!e.shouldUnregister,b.state.next({submitCount:n.keepSubmitCount?t.submitCount:0,isDirty:n.keepDirty||n.keepDirtyValues?t.isDirty:!!(n.keepDefaultValues&&!oe(r,s)),isSubmitted:n.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:n.keepDirty||n.keepDirtyValues?t.dirtyFields:n.keepDefaultValues&&r?_e(s,r):{},touchedFields:n.keepTouched?t.touchedFields:{},errors:n.keepErrors?t.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})};return{control:{register:pe,unregister:ke,getFieldState:Me,_executeSchema:K,_focusError:Ie,_getWatch:x,_getDirty:v,_updateValid:P,_removeUnmounted:Z,_updateFieldArray:C,_getFieldArray:S,_subjects:b,_proxyFormState:p,get _fields(){return l},get _formValues(){return a},get _stateFlags(){return m},set _stateFlags(r){m=r},get _defaultValues(){return s},get _names(){return g},set _names(r){g=r},get _formState(){return t},set _formState(r){t=r},get _options(){return i},set _options(r){i={...i,...r}}},trigger:Q,register:pe,handleSubmit:at,watch:lt,setValue:_,getValues:X,reset:(r,n)=>ct(he(r)?r(a):r,n),resetField:ut,clearErrors:nt,unregister:ke,setError:ot,setFocus:(r,n={})=>{const o=f(l,r),c=o&&o._f;if(c){const d=c.refs?c.refs[0]:c.ref;d.focus&&(d.focus(),n.shouldSelect&&d.select())}},getFieldState:Me}}function Nt(e={}){const i=h.useRef(),[t,l]=h.useState({isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:e.defaultValues});i.current||(i.current={...It(e),formState:t});const s=i.current.control;return s._options=e,wt({subject:s._subjects.state,callback:h.useCallback(a=>{Et(a,s._proxyFormState,!0)&&(s._formState={...s._formState,...a},l({...s._formState}))},[s])}),h.useEffect(()=>{s._stateFlags.mount||(s._proxyFormState.isValid&&s._updateValid(),s._stateFlags.mount=!0),s._stateFlags.watch&&(s._stateFlags.watch=!1,s._subjects.state.next({})),s._removeUnmounted()}),h.useEffect(()=>{t.submitCount&&s._focusError()},[s,t.submitCount]),i.current.formState=pt(t,s),i.current}var qt=(e=>(e.formgroup="formgroup",e.checkbox="checkbox",e.radiobutton="radiobutton",e.textarea="textarea",e.input="input",e.select="select",e.date="date",e))(qt||{});const Lr=e=>{const{exampleType:i="formgroup"}=e,{register:t,handleSubmit:l,formState:{errors:s}}=Nt(),a=new Date;a.setHours(0),a.setMinutes(0),a.setSeconds(0);const m=new Date;m.setDate(a.getDate()-5),m.setHours(6),m.setMinutes(10),m.setSeconds(0);const g=new Date;g.setDate(a.getDate()+5),g.setHours(22),g.setMinutes(0),g.setSeconds(0);const E="field1",V="field2",O="field3",p="field4",b="field5",U="field6",q="field7",re="field8",le="field9",P=s.field1||s.field2||s.field3||s.field4||s.field5||s.field6||s.field7||s.field8||s.field9,C="Du m\xE5 velge et alternativ",H="Du m\xE5 velge to alternativ",D="Det kan ikke legges inn mer enn 40 tegn",z="Du m\xE5 skrive noe her",ie='Du m\xE5 velge "Option 2"',K=`Du m\xE5 velge dato mellom ${m.toLocaleDateString("nb")} og ${g.toLocaleDateString("nb")}`,J=`Du m\xE5 skrive inn tidspunkt mellom ${m.toLocaleTimeString("nb",{hour:"2-digit",minute:"2-digit"})} og ${g.toLocaleTimeString("nb",{hour:"2-digit",minute:"2-digit"})}`,R=k=>k.length>=2||H,Z=k=>k.toString()==="Option 2"||ie,v=(k,w,_)=>{const G=new Date(k);return!!k&&G.getTime()>=w.getTime()&&G.getTime()<=_.getTime()||K},x=(k,w)=>{const _=new Date;_.setHours(k),_.setMinutes(w),_.setSeconds(0);const G=m.toLocaleTimeString("nb"),Q=g.toLocaleTimeString("nb"),X=_.toLocaleTimeString("nb");return console.log("value",X),!!_&&X>=G&&X<=Q||J},S=()=>{if(i==="formgroup"){const k=[h.createElement(ee,{key:0,inputId:"checkbox1",label:"Checkbox 1",...t(E,{required:C})}),h.createElement(ee,{key:1,inputId:"checkbox2",label:"Checkbox 2",...t(E,{required:C})}),h.createElement(ee,{key:2,inputId:"checkbox3",label:"Checkbox 3",...t(E,{required:C})})];return[h.createElement(Y,{key:0,title:"Gruppe tittel",legend:"Velg minst en",error:s.field1?s.field1.message:void 0,variant:e.variant},h.createElement(gt,{maxColumns:ht.two},k.map(w=>w))),h.createElement(Y,{key:1,legend:"Velg minst to",error:s.field2?s.field2.message:void 0,variant:e.variant},h.createElement(ee,{inputId:"checkbox4",label:"Checkbox 4",...t(V,{validate:R})}),h.createElement(ee,{inputId:"checkbox5",label:"Checkbox 5",...t(V,{validate:R})}),h.createElement(ee,{inputId:"checkbox6",label:"Checkbox 6",...t(V,{validate:R})})),h.createElement(Y,{key:2,legend:"Velg en",error:s.field3?s.field3.message:void 0,variant:e.variant},h.createElement(me,{inputId:"radiobutton1",label:"Radiobutton 1",...t(O,{required:C})}),h.createElement(me,{inputId:"radiobutton2",label:"Radiobutton 2",...t(O,{required:C})}),h.createElement(me,{inputId:"radiobutton3",label:"Radiobutton 3",...t(O,{required:C})})),h.createElement(Y,{key:3,error:s.field4?s.field4.message:void 0},h.createElement(Be,{defaultValue:`Dette er en test
|
|
2
2
|
|
|
3
3
|
Hello
|
|
4
4
|
|
|
@@ -8,5 +8,5 @@ import h from"react";import{V as yt}from"../../Validation.js";import{F as Y}from
|
|
|
8
8
|
|
|
9
9
|
Hello
|
|
10
10
|
|
|
11
|
-
test`,grow:!0,maxCharacters:40,minRows:5,errorText:s.field4?s.field4.message:void 0,label:"Skriv din historie her",textareaId:"textarea1",...t(p,{maxLength:{value:40,message:D}})});if(i==="input")return h.createElement(ae,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",errorText:s.field5?s.field5.message:void 0,icon:Ue,...t(b,{required:z})});if(i==="select")return h.createElement(Pe,{errorText:s.field6?s.field6.message:void 0,label:"Skriv inn din tekst",...t(U,{validate:Z})},h.createElement("option",{value:"Option 1"},"Option 1"),h.createElement("option",{value:"Option 2"},"Option 2"),h.createElement("option",{value:"Option 3"},"Option 3"));if(i==="date"){const k=s.field7||s.field8||s.field9;return h.createElement(h.Fragment,null,h.createElement(Y,{legend:"Velg en dato og et klokkeslett",fieldsetClassName:we["fieldset--flex"],error:k?k.message:void 0},h.createElement(ae,{className:we["date-picker--spacing"],label:"dato",width:20,type:"date",defaultValue:a.toLocaleDateString("en-CA"),min:m.toLocaleDateString("en-CA"),max:g.toLocaleDateString("en-CA"),...t(q,{validate:w=>v(w,m,g)})}),h.createElement(Y,{htmlMarkup:"div",fieldsetClassName:we["fieldset--flex-time"]},h.createElement(ae,{labelId:"time-label-id",afterInputChildren:h.createElement("span",{style:{padding:"0 1rem"}},":"),label:"klokke",width:4,type:"number",defaultValue:a.toLocaleTimeString("nb",{hour:"2-digit"}),max:23,min:0,...t(re,{validate:w=>x(w,w)})}),h.createElement(ae,{"aria-labelledby":"time-label-id",width:4,type:"number",defaultValue:a.toLocaleTimeString("nb",{minute:"2-digit"}),max:59,min:0,...t(le,{validate:w=>x(7,w)})}))))}}};return h.createElement("form",{noValidate:!0,onSubmit:l(k=>{!vt()&&console.log(k)})},h.createElement(yt,{variant:e.variant,errorSummary:P?"Sjekk at alt er riktig utfylt":void 0},S()),h.createElement(mt,{type:"submit"},"Send inn"))};export{
|
|
11
|
+
test`,grow:!0,maxCharacters:40,minRows:5,errorText:s.field4?s.field4.message:void 0,label:"Skriv din historie her",textareaId:"textarea1",...t(p,{maxLength:{value:40,message:D}})});if(i==="input")return h.createElement(ae,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",errorText:s.field5?s.field5.message:void 0,icon:Ue,...t(b,{required:z})});if(i==="select")return h.createElement(Pe,{errorText:s.field6?s.field6.message:void 0,label:"Skriv inn din tekst",...t(U,{validate:Z})},h.createElement("option",{value:"Option 1"},"Option 1"),h.createElement("option",{value:"Option 2"},"Option 2"),h.createElement("option",{value:"Option 3"},"Option 3"));if(i==="date"){const k=s.field7||s.field8||s.field9;return h.createElement(h.Fragment,null,h.createElement(Y,{legend:"Velg en dato og et klokkeslett",fieldsetClassName:we["fieldset--flex"],error:k?k.message:void 0},h.createElement(ae,{className:we["date-picker--spacing"],label:"dato",width:20,type:"date",defaultValue:a.toLocaleDateString("en-CA"),min:m.toLocaleDateString("en-CA"),max:g.toLocaleDateString("en-CA"),...t(q,{validate:w=>v(w,m,g)})}),h.createElement(Y,{htmlMarkup:"div",fieldsetClassName:we["fieldset--flex-time"]},h.createElement(ae,{labelId:"time-label-id",afterInputChildren:h.createElement("span",{style:{padding:"0 1rem"}},":"),label:"klokke",width:4,type:"number",defaultValue:a.toLocaleTimeString("nb",{hour:"2-digit"}),max:23,min:0,...t(re,{validate:w=>x(w,w)})}),h.createElement(ae,{"aria-labelledby":"time-label-id",width:4,type:"number",defaultValue:a.toLocaleTimeString("nb",{minute:"2-digit"}),max:59,min:0,...t(le,{validate:w=>x(7,w)})}))))}}};return h.createElement("form",{noValidate:!0,onSubmit:l(k=>{!vt()&&console.log(k)})},h.createElement(yt,{variant:e.variant,errorSummary:P?"Sjekk at alt er riktig utfylt":void 0},S()),h.createElement(mt,{type:"submit"},"Send inn"))};export{Lr as FormExample,qt as FormExampleVariants,Lr as default};
|
|
12
12
|
//# sourceMappingURL=index.js.map
|