@helsenorge/designsystem-react 1.0.0-beta80 → 1.0.0-beta81

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.
Files changed (66) hide show
  1. package/{Button-7200b617.js → Button-e2087687.js} +2 -2
  2. package/Button-e2087687.js.map +1 -0
  3. package/Loader-3767cb6e.js +2 -0
  4. package/Loader-3767cb6e.js.map +1 -0
  5. package/Modal-459c67d7.js +2 -0
  6. package/Modal-459c67d7.js.map +1 -0
  7. package/components/Avatar/index.js +1 -1
  8. package/components/Button/index.js +1 -1
  9. package/components/ButtonWithModal/ButtonWithModal.d.ts +1 -1
  10. package/components/ButtonWithModal/ButtonWithModal.d.ts.map +1 -1
  11. package/components/ButtonWithModal/index.js +1 -1
  12. package/components/Loader/index.js +1 -1
  13. package/components/Modal/index.js +1 -1
  14. package/components/Modal/styles.module.scss +6 -6
  15. package/components/Tabs/componentdata.json +3 -0
  16. package/package.json +1 -2
  17. package/scss/_palette.scss +0 -1
  18. package/Button-7200b617.js.map +0 -1
  19. package/Check-6291ad09.js +0 -2
  20. package/Check-6291ad09.js.map +0 -1
  21. package/Checkbox-ffdd3cb7.js +0 -2
  22. package/Checkbox-ffdd3cb7.js.map +0 -1
  23. package/FormGroup-17d2a3d3.js +0 -2
  24. package/FormGroup-17d2a3d3.js.map +0 -1
  25. package/Loader-9e099b42.js +0 -2
  26. package/Loader-9e099b42.js.map +0 -1
  27. package/Modal-5c2defa7.js +0 -2
  28. package/Modal-5c2defa7.js.map +0 -1
  29. package/Validation-e113da7e.js +0 -2
  30. package/Validation-e113da7e.js.map +0 -1
  31. package/components/Checkbox/Checkbox.d.ts +0 -31
  32. package/components/Checkbox/Checkbox.d.ts.map +0 -1
  33. package/components/Checkbox/componentdata.json +0 -259
  34. package/components/Checkbox/index.d.ts +0 -3
  35. package/components/Checkbox/index.d.ts.map +0 -1
  36. package/components/Checkbox/index.js +0 -2
  37. package/components/Checkbox/index.js.map +0 -1
  38. package/components/Checkbox/styles.module.scss +0 -191
  39. package/components/Checkbox/styles.module.scss.d.ts +0 -25
  40. package/components/FormExample/FormExample.d.ts +0 -13
  41. package/components/FormExample/FormExample.d.ts.map +0 -1
  42. package/components/FormExample/componentdata.json +0 -63
  43. package/components/FormExample/index.d.ts +0 -3
  44. package/components/FormExample/index.d.ts.map +0 -1
  45. package/components/FormExample/index.js +0 -2
  46. package/components/FormExample/index.js.map +0 -1
  47. package/components/FormGroup/FormGroup.d.ts +0 -26
  48. package/components/FormGroup/FormGroup.d.ts.map +0 -1
  49. package/components/FormGroup/componentdata.json +0 -183
  50. package/components/FormGroup/index.d.ts +0 -3
  51. package/components/FormGroup/index.d.ts.map +0 -1
  52. package/components/FormGroup/index.js +0 -2
  53. package/components/FormGroup/index.js.map +0 -1
  54. package/components/FormGroup/styles.module.scss +0 -79
  55. package/components/FormGroup/styles.module.scss.d.ts +0 -22
  56. package/components/Validation/Validation.d.ts +0 -17
  57. package/components/Validation/Validation.d.ts.map +0 -1
  58. package/components/Validation/componentdata.json +0 -111
  59. package/components/Validation/index.d.ts +0 -3
  60. package/components/Validation/index.d.ts.map +0 -1
  61. package/components/Validation/index.js +0 -2
  62. package/components/Validation/index.js.map +0 -1
  63. package/components/Validation/styles.module.scss +0 -15
  64. package/components/Validation/styles.module.scss.d.ts +0 -10
  65. package/uuid-484288be.js +0 -2
  66. package/uuid-484288be.js.map +0 -1
@@ -1,191 +0,0 @@
1
- @import '../../scss/_spacers.scss';
2
- @import '../../scss/_breakpoints.scss';
3
- @import '../../scss/_palette.scss';
4
- @import '../../scss/font-settings.scss';
5
-
6
- .checkbox-errors {
7
- font-size: $font-size-sm;
8
- font-weight: 600;
9
- color: $cherry500;
10
- margin-top: 0;
11
- }
12
-
13
- .checkbox-wrapper {
14
- &--with-error {
15
- padding: getSpacer(s) getSpacer(xs) getSpacer(m);
16
- background-color: $cherry50;
17
- border-left: 0.25rem solid $cherry500;
18
-
19
- @media (min-width: map-get($grid-breakpoints, md)) {
20
- padding: getSpacer(s) getSpacer(m) getSpacer(l);
21
- }
22
- }
23
-
24
- &--with-error#{&}--bigform {
25
- padding: getSpacer(m) getSpacer(m);
26
- }
27
- }
28
-
29
- .checkbox-label {
30
- display: flex;
31
- align-items: center;
32
- cursor: pointer;
33
- font-size: $font-size-sm;
34
- margin: getSpacer(s) 0;
35
-
36
- @media (min-width: map-get($grid-breakpoints, md)) {
37
- font-size: $font-size-md;
38
- }
39
-
40
- &--on-dark {
41
- color: $white;
42
- }
43
-
44
- &--invalid {
45
- color: $black;
46
- padding: getSpacer(s);
47
- }
48
-
49
- &--disabled {
50
- cursor: default;
51
- color: $neutral400;
52
- }
53
-
54
- &--bigform {
55
- margin: getSpacer(xs) 0 getSpacer(xs) 0;
56
- padding: 1.68rem getSpacer(l);
57
- background-color: $neutral50;
58
- }
59
-
60
- &--bigform#{&}--on-blueberry {
61
- background-color: $blueberry50;
62
- }
63
-
64
- &--bigform#{&}--on-dark {
65
- background-color: $blueberry800;
66
- }
67
-
68
- &--invalid,
69
- &--bigform#{&}--invalid {
70
- background-color: $white;
71
- }
72
- }
73
-
74
- .checkbox-label:last-of-type {
75
- margin-bottom: 0;
76
- }
77
-
78
- .checkbox {
79
- width: 0px;
80
-
81
- -moz-appearance: none;
82
- -webkit-appearance: none;
83
- -o-appearance: none;
84
-
85
- &__icon-wrapper {
86
- display: flex;
87
- justify-content: center;
88
- align-items: center;
89
- margin: getSpacer(3xs) getSpacer(s) getSpacer(3xs) getSpacer(3xs);
90
- height: 1.625rem;
91
- width: 1.625rem;
92
- min-width: auto !important;
93
- min-height: auto !important;
94
- color: $neutral700;
95
- box-shadow: 0 0 0 getSpacer(3xs);
96
-
97
- :hover > & {
98
- box-shadow: 0 0 0 getSpacer(2xs);
99
- background-color: $neutral100;
100
- }
101
-
102
- :active > & {
103
- box-shadow: 0 0 0 getSpacer(2xs);
104
- color: $black;
105
- }
106
-
107
- &--checked {
108
- color: $blueberry500;
109
-
110
- :hover > & {
111
- background-color: $blueberry50;
112
- }
113
- }
114
-
115
- &--on-blueberry {
116
- color: $blueberry500;
117
-
118
- :hover > & {
119
- background-color: $blueberry100;
120
- }
121
- }
122
-
123
- &--on-dark {
124
- color: $neutral200;
125
-
126
- :hover > & {
127
- background-color: $inverted-hover;
128
- }
129
-
130
- &.checkbox__icon-wrapper--checked {
131
- color: $blueberry200;
132
- }
133
-
134
- :active > & {
135
- color: $white;
136
- }
137
- }
138
-
139
- &--invalid {
140
- color: $cherry500;
141
-
142
- :hover > & {
143
- background-color: $cherry100;
144
- }
145
-
146
- &.checkbox__icon-wrapper--checked {
147
- color: $cherry500;
148
- }
149
-
150
- :active > & {
151
- color: $black;
152
- }
153
- }
154
-
155
- &--disabled {
156
- color: $neutral400;
157
- &.checkbox__icon-wrapper--checked {
158
- color: $neutral400;
159
- }
160
- :hover > & {
161
- box-shadow: 0 0 0 getSpacer(3xs);
162
- background-color: transparent;
163
- }
164
-
165
- :active > & {
166
- color: $neutral400;
167
- }
168
- }
169
- }
170
-
171
- &__icon {
172
- position: relative;
173
- top: 0.1rem;
174
- right: 0.05rem;
175
- }
176
-
177
- &:focus {
178
- & + .checkbox__icon-wrapper {
179
- box-shadow: 0 0 0 getSpacer(2xs);
180
- color: $black;
181
-
182
- &--on-dark {
183
- color: $white;
184
- }
185
-
186
- &--invalid {
187
- color: $black;
188
- }
189
- }
190
- }
191
- }
@@ -1,25 +0,0 @@
1
- export type Styles = {
2
- checkbox: string;
3
- checkbox__icon: string;
4
- 'checkbox__icon-wrapper': string;
5
- 'checkbox__icon-wrapper--checked': string;
6
- 'checkbox__icon-wrapper--disabled': string;
7
- 'checkbox__icon-wrapper--invalid': string;
8
- 'checkbox__icon-wrapper--on-blueberry': string;
9
- 'checkbox__icon-wrapper--on-dark': string;
10
- 'checkbox-errors': string;
11
- 'checkbox-label': string;
12
- 'checkbox-label--bigform': string;
13
- 'checkbox-label--disabled': string;
14
- 'checkbox-label--invalid': string;
15
- 'checkbox-label--on-blueberry': string;
16
- 'checkbox-label--on-dark': string;
17
- 'checkbox-wrapper--bigform': string;
18
- 'checkbox-wrapper--with-error': string;
19
- };
20
-
21
- export type ClassNames = keyof Styles;
22
-
23
- declare const styles: Styles;
24
-
25
- export default styles;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { FormVariant } from '../FormGroup/FormGroup';
3
- interface FormExampleProps {
4
- exampleType: FormExampleVariants;
5
- variant?: FormVariant;
6
- }
7
- export declare enum FormExampleVariants {
8
- formgroup = "formgroup",
9
- checkbox = "checkbox"
10
- }
11
- export declare const FormExample: React.ForwardRefExoticComponent<FormExampleProps & React.RefAttributes<HTMLElement>>;
12
- export default FormExample;
13
- //# sourceMappingURL=FormExample.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormExample.d.ts","sourceRoot":"","sources":["../../../src/components/FormExample/FormExample.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAkB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIhE,UAAU,gBAAgB;IACxB,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,oBAAY,mBAAmB;IAC7B,SAAS,cAAc;IACvB,QAAQ,aAAa;CACtB;AAED,eAAO,MAAM,WAAW,sFA6DtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -1,63 +0,0 @@
1
- {
2
- "props": {
3
- "exampleType": {
4
- "defaultValue": null,
5
- "description": "",
6
- "name": "exampleType",
7
- "parent": {
8
- "fileName": "designsystem/src/components/FormExample/FormExample.tsx",
9
- "name": "FormExampleProps"
10
- },
11
- "declarations": [
12
- {
13
- "fileName": "designsystem/src/components/FormExample/FormExample.tsx",
14
- "name": "FormExampleProps"
15
- }
16
- ],
17
- "required": true,
18
- "type": {
19
- "name": "enum",
20
- "raw": "FormExampleVariants",
21
- "value": [
22
- {
23
- "value": "\"formgroup\""
24
- },
25
- {
26
- "value": "\"checkbox\""
27
- }
28
- ]
29
- }
30
- },
31
- "variant": {
32
- "defaultValue": null,
33
- "description": "",
34
- "name": "variant",
35
- "parent": {
36
- "fileName": "designsystem/src/components/FormExample/FormExample.tsx",
37
- "name": "FormExampleProps"
38
- },
39
- "declarations": [
40
- {
41
- "fileName": "designsystem/src/components/FormExample/FormExample.tsx",
42
- "name": "FormExampleProps"
43
- }
44
- ],
45
- "required": false,
46
- "type": {
47
- "name": "enum",
48
- "raw": "\"normal\" | \"bigform\" | undefined",
49
- "value": [
50
- {
51
- "value": "undefined"
52
- },
53
- {
54
- "value": "\"normal\""
55
- },
56
- {
57
- "value": "\"bigform\""
58
- }
59
- ]
60
- }
61
- }
62
- }
63
- }
@@ -1,3 +0,0 @@
1
- import FormExample from './FormExample';
2
- export default FormExample;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormExample/index.tsx"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,eAAe,WAAW,CAAC"}
@@ -1,2 +0,0 @@
1
- import r,{createContext as e,useCallback as t,useRef as n,useState as i,useEffect as u,useMemo as a,isValidElement as s}from"react";import{V as c}from"../../Validation-e113da7e.js";import{F as o}from"../../FormGroup-17d2a3d3.js";import{C as f}from"../../Checkbox-ffdd3cb7.js";import{B as l}from"../../Button-7200b617.js";import"../../_rollupPluginBabelHelpers-e1c7fe69.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../FormGroup/styles.module.scss";import"../../Title-863af332.js";import"../Title/styles.module.scss";import"../../uuid-484288be.js";import"../../Check-6291ad09.js";import"../../constants-d1f48e8e.js";import"../../_tslib-51c8a283.js";import"../../color-acb834c6.js";import"../../index-19b48c51.js";import"../../palette-f206f488.js";import"../../grid-11a70eb7.js";import"../Checkbox/styles.module.scss";import"../../Loader-9e099b42.js";import"../Loader/styles.module.scss";import"../../useHover-57ad4df9.js";import"../../useWindowSize-c22d7634.js";import"../Button/styles.module.scss";var d=function(r){return r instanceof HTMLElement},v="blur",m="change",g="input",p="onBlur",y="onChange",h="onSubmit",b="onTouched",O="all",j="max",V="min",A="maxLength",E="minLength",w="pattern",S="required",F="validate";var D=function(r){return null==r},k=function(r){return"object"==typeof r},x=function(r){return!D(r)&&!Array.isArray(r)&&k(r)&&!(r instanceof Date)},C=function(r){return/^\w*$/.test(r)},R=function(r){return r.filter(Boolean)},N=function(r){return R(r.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."))};function B(r,e,t){for(var n=-1,i=C(e)?[e]:N(e),u=i.length,a=u-1;++n<u;){var s=i[n],c=t;if(n!==a){var o=r[s];c=x(o)||Array.isArray(o)?o:isNaN(+i[n+1])?{}:[]}r[s]=c,r=r[s]}return r}var L=function(r,e){for(var t in void 0===e&&(e={}),r)C(t)?e[t]=r[t]:B(e,t,r[t]);return e},T=function(r){return void 0===r},M=function(r,e,t){void 0===r&&(r={});var n=R(e.split(/[,[\].]+?/)).reduce((function(r,e){return D(r)?r:r[e]}),r);return T(n)||n===r?T(r[e])?t:r[e]:n},W=function(r,e){d(r)&&r.removeEventListener&&(r.removeEventListener(g,e),r.removeEventListener(m,e),r.removeEventListener(v,e))},_={isValid:!1,value:null},q=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),_):_},H=function(r){return"radio"===r.type},P=function(r){return"file"===r.type},z=function(r){return"checkbox"===r.type},U=function(r){return"select-multiple"===r.type},$={value:!1,isValid:!1},G={value:!0,isValid:!0},I=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,u=t.attributes;return n?u&&!T(u.value)?T(i)||""===i?G:{value:i,isValid:!0}:G:$}return $};function J(r,e,t,n,i){var u,a=r.current[e];if(a){var s=a.ref,c=s.value,o=s.disabled,f=a.ref,l=a.valueAsNumber,d=a.valueAsDate,v=a.setValueAs;if(o&&n)return;return P(f)?f.files:H(f)?q(a.options).value:U(f)?(u=f.options,[].concat(u).filter((function(r){return r.selected})).map((function(r){return r.value}))):z(f)?I(a.options).value:i?c:l?""===c?NaN:+c:d?f.valueAsDate:v?v(c):c}if(t)return M(t.current,e)}function K(r){return!r||r instanceof HTMLElement&&r.nodeType!==Node.DOCUMENT_NODE&&K(r.parentNode)}var Q=function(r){return x(r)&&!Object.keys(r).length},X=function(r){return"boolean"==typeof r};function Y(r,e){var t,n=C(e)?[e]:N(e),i=1==n.length?r:function(r,e){for(var t=e.slice(0,-1).length,n=0;n<t;)r=T(r)?n++:r[e[n++]];return r}(r,n),u=n[n.length-1];i&&delete i[u];for(var a=0;a<n.slice(0,-1).length;a++){var s=-1,c=void 0,o=n.slice(0,-(a+1)),f=o.length-1;for(a>0&&(t=r);++s<o.length;){var l=o[s];c=c?c[l]:r[l],f===s&&(x(c)&&Q(c)||Array.isArray(c)&&!c.filter((function(r){return x(r)&&!Q(r)||X(r)})).length)&&(t?delete t[l]:delete r[l]),t=c}}return r}var Z=function(r,e){return r&&r.ref===e};var rr=function(r){return D(r)||!k(r)};function er(r,e){if(rr(r)||rr(e))return e;for(var t in e){var n=r[t],i=e[t];try{r[t]=x(n)&&x(i)||Array.isArray(n)&&Array.isArray(i)?er(n,i):i}catch(r){}}return r}function tr(r,e,t){if(rr(r)||rr(e)||r instanceof Date||e instanceof Date)return r===e;if(!s(r)){var n=Object.keys(r),i=Object.keys(e);if(n.length!==i.length)return!1;for(var u=0,a=n;u<a.length;u+=1){var c=a[u],o=r[c];if(!t||"ref"!==c){var f=e[c];if((x(o)||Array.isArray(o))&&(x(f)||Array.isArray(f))?!tr(o,f,t):o!==f)return!1}}}return!0}function nr(r,e,t,n,i){for(var u,a=-1;++a<r.length;){for(var s in r[a])Array.isArray(r[a][s])?(!t[a]&&(t[a]={}),t[a][s]=[],nr(r[a][s],M(e[a]||{},s,[]),t[a][s],t[a],s)):tr(M(e[a]||{},s),r[a][s])?B(t[a]||{},s):t[a]=Object.assign(Object.assign({},t[a]),((u={})[s]=!0,u));n&&!t.length&&delete n[i]}return t}var ir=function(r){return"string"==typeof r},ur=function(r,e,t,n,i){var u={},a=function(e){(T(i)||(ir(i)?e.startsWith(i):Array.isArray(i)&&i.find((function(r){return e.startsWith(r)}))))&&(u[e]=J(r,e,void 0,n))};for(var s in r.current)a(s);return t?L(u):er(e,L(u))},ar=function(r){return r instanceof RegExp},sr=function(r){return x(r)&&!ar(r)?r:{value:r,message:""}},cr=function(r){return"function"==typeof r},or=function(r){return ir(r)||s(r)};function fr(r,e,t){if(void 0===t&&(t="validate"),or(r)||X(r)&&!r)return{type:t,message:or(r)?r:"",ref:e}}var lr=function(r,e,t,n,i){var u;return e?Object.assign(Object.assign({},t[r]),{types:Object.assign(Object.assign({},t[r]&&t[r].types?t[r].types:{}),(u={},u[n]=i||!0,u))}):{}},dr=async function(r,e,t,n){var i=t.ref,u=t.ref.value,a=t.options,s=t.required,c=t.maxLength,o=t.minLength,f=t.min,l=t.max,d=t.pattern,v=t.validate,m=i.name,g={},p=H(i),y=z(i),h=p||y,b=""===u,O=lr.bind(null,m,e,g),k=function(r,e,t,n,u){void 0===n&&(n=A),void 0===u&&(u=E);var a=r?e:t;g[m]=Object.assign({type:r?n:u,message:a,ref:i},O(r?n:u,a))};if(s&&(!p&&!y&&(b||D(u))||X(u)&&!u||y&&!I(a).isValid||p&&!q(a).isValid)){var C=or(s)?{value:!!s,message:s}:sr(s),R=C.value,N=C.message;if(R&&(g[m]=Object.assign({type:S,message:N,ref:h?((r.current[m].options||[])[0]||{}).ref:i},O(S,N)),!e))return g}if(!(D(f)&&D(l)||""===u)){var B,L,T=sr(l),M=sr(f);if(isNaN(u)){var W=i.valueAsDate||new Date(u);ir(T.value)&&(B=W>new Date(T.value)),ir(M.value)&&(L=W<new Date(M.value))}else{var _=i.valueAsNumber||parseFloat(u);D(T.value)||(B=_>T.value),D(M.value)||(L=_<M.value)}if((B||L)&&(k(!!B,T.message,M.message,j,V),!e))return g}if(ir(u)&&!b&&(c||o)){var P=sr(c),U=sr(o),$=!D(P.value)&&u.length>P.value,G=!D(U.value)&&u.length<U.value;if(($||G)&&(k($,P.message,U.message),!e))return g}if(ir(u)&&d&&!b){var K=sr(d),Y=K.value,Z=K.message;if(ar(Y)&&!Y.test(u)&&(g[m]=Object.assign({type:w,message:Z,ref:i},O(w,Z)),!e))return g}if(v){var rr=J(r,m,n,!1,!0),er=h&&a?a[0].ref:i;if(cr(v)){var tr=fr(await v(rr),er);if(tr&&(g[m]=Object.assign(Object.assign({},tr),O(F,tr.message)),!e))return g}else if(x(v)){for(var nr={},ur=0,dr=Object.entries(v);ur<dr.length;ur+=1){var vr=dr[ur],mr=vr[0],gr=vr[1];if(!Q(nr)&&!e)break;var pr=fr(await gr(rr),er,mr);pr&&(nr=Object.assign(Object.assign({},pr),O(mr,pr.message)),e&&(g[m]=nr))}if(!Q(nr)&&(g[m]=Object.assign({ref:er},nr),!e))return g}}return g},vr=function(r,e,t){for(var n in void 0===t&&(t=[]),e){var i=r+(x(e)?"."+n:"["+n+"]");rr(e[n])?t.push(i):vr(i,e[n],t)}return t},mr=function(r,e,t,n,i){var u=void 0;return t.add(e),Q(r)||(u=M(r,e),(x(u)||Array.isArray(u))&&vr(e,u).forEach((function(r){return t.add(r)}))),T(u)?i?n:M(n,e):u},gr=function(r){return r.substring(0,r.indexOf("["))},pr=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 yr="undefined"!=typeof window&&"undefined"!=typeof document;function hr(r){var e,t;if(rr(r)||yr&&(r instanceof File||d(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 u=i[n];t.add(u)}return t}if(r instanceof Map){t=new Map;for(var a=0,s=r.keys();a<s.length;a+=1){var c=s[a];t.set(c,hr(r.get(c)))}return t}for(var o in t=Array.isArray(r)?[]:{},r)t[o]=hr(r[o]);return t}var br,Or=function(r){return{isOnSubmit:!r||r===h,isOnBlur:r===p,isOnChange:r===y,isOnAll:r===O,isOnTouch:r===b}},jr=function(r){return H(r)||z(r)},Vr="undefined"==typeof window,Ar=yr?"Proxy"in window:"undefined"!=typeof Proxy;function Er(r){void 0===r&&(r={});var e=r.mode;void 0===e&&(e=h);var s=r.reValidateMode;void 0===s&&(s=y);var c=r.resolver,o=r.context,f=r.defaultValues;void 0===f&&(f={});var l=r.shouldFocusError;void 0===l&&(l=!0);var p=r.shouldUnregister;void 0===p&&(p=!0);var b=r.criteriaMode,j=n({}),V=n({}),A=n({}),E=n(new Set),w=n({}),S=n({}),F=n({}),k=n({}),N=n(f),_=n(!1),q=n(!1),$=n(),G=n({}),I=n({}),X=n(o),ar=n(c),sr=n(new Set),or=n(Or(e)),fr=or.current,lr=fr.isOnSubmit,br=fr.isOnTouch,Er=b===O,wr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!lr,errors:{}}),Sr=wr[0],Fr=wr[1],Dr=n({isDirty:!Ar,dirtyFields:!Ar,touched:!Ar||br,isValidating:!Ar,isSubmitting:!Ar,isValid:!Ar}),kr=n(Sr),xr=n(),Cr=n(Or(s)).current,Rr=Cr.isOnBlur,Nr=Cr.isOnChange;X.current=o,ar.current=c,kr.current=Sr,G.current=p?{}:Q(G.current)?hr(f):G.current;var Br=t((function(r){void 0===r&&(r={}),_.current||(kr.current=Object.assign(Object.assign({},kr.current),r),Fr(kr.current))}),[]),Lr=function(){return Dr.current.isValidating&&Br({isValidating:!0})},Tr=t((function(r,e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n={});var u=t||function(r){var e=r.errors,t=r.name,n=r.error,i=r.validFields,u=r.fieldsWithValidation,a=T(n),s=M(e,t);return a&&!!s||!a&&!tr(s,n,!0)||a&&M(u,t)&&!M(i,t)}({errors:kr.current.errors,error:e,name:r,validFields:k.current,fieldsWithValidation:F.current}),a=M(kr.current.errors,r);e?(Y(k.current,r),u=u||!a||!tr(a,e,!0),B(kr.current.errors,r,e)):((M(F.current,r)||ar.current)&&(B(k.current,r,!0),u=u||a),Y(kr.current.errors,r)),(u&&!D(t)||!Q(n)||Dr.current.isValidating)&&Br(Object.assign(Object.assign(Object.assign({},n),ar.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Mr=t((function(r,e){var t=j.current[r],n=t.ref,i=t.options,u=yr&&d(n)&&D(e)?"":e;H(n)?(i||[]).forEach((function(r){var e=r.ref;return e.checked=e.value===u})):P(n)&&!ir(u)?n.files=u:U(n)?[].concat(n.options).forEach((function(r){return r.selected=u.includes(r.value)})):z(n)&&i?i.length>1?i.forEach((function(r){var e=r.ref;return e.checked=Array.isArray(u)?!!u.find((function(r){return r===e.value})):u===e.value})):i[0].ref.checked=!!u:n.value=u}),[]),Wr=t((function(r,e){if(Dr.current.isDirty){var t=Jr();return r&&e&&B(t,r,e),!tr(t,N.current)}return!1}),[]),_r=t((function(r,e){if(void 0===e&&(e=!0),Dr.current.isDirty||Dr.current.dirtyFields){var t=!tr(M(N.current,r),J(j,r,G)),n=M(kr.current.dirtyFields,r),i=kr.current.isDirty;t?B(kr.current.dirtyFields,r,!0):Y(kr.current.dirtyFields,r);var u={isDirty:Wr(),dirtyFields:kr.current.dirtyFields},a=Dr.current.isDirty&&i!==u.isDirty||Dr.current.dirtyFields&&n!==M(kr.current.dirtyFields,r);return a&&e&&Br(u),a?u:{}}return{}}),[]),qr=t((async function(r,e){if("production"!==process.env.NODE_ENV&&!j.current[r])return console.warn("📋 Field is missing with `name` attribute: ",r),!1;var t=(await dr(j,Er,j.current[r],G))[r];return Tr(r,t,e),T(t)}),[Tr,Er]),Hr=t((async function(r){var e=(await ar.current(Jr(),X.current,Er)).errors,t=kr.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=M(e,r);return t?B(kr.current.errors,r,t):Y(kr.current.errors,r),!t})).every(Boolean);return Br({isValid:Q(e),isValidating:!1}),n}var i=M(e,r);return Tr(r,i,t!==Q(e),{},Q(e)),!i}),[Tr,Er]),Pr=t((async function(r){var e=r||Object.keys(j.current);if(Lr(),ar.current)return Hr(e);if(Array.isArray(e)){!r&&(kr.current.errors={});var t=await Promise.all(e.map((async function(r){return await qr(r,null)})));return Br({isValidating:!1}),t.every(Boolean)}return await qr(e)}),[Hr,qr]),zr=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,u={};B(u,r,e);for(var a=0,s=vr(r,e);a<s.length;a+=1){var c=s[a];j.current[c]&&(Mr(c,M(u,c)),n&&_r(c),i&&Pr(c))}}),[Pr,Mr,_r]),Ur=t((function(r,e,t){var n,i;if(!p&&!rr(e)&&B(G.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),j.current[r])Mr(r,e),t.shouldDirty&&_r(r),t.shouldValidate&&Pr(r);else if(!rr(e)&&(zr(r,e,t),sr.current.has(r))){var u=gr(r)||r;B(V.current,r,e),I.current[u](((n={})[u]=M(V.current,u),n)),(Dr.current.isDirty||Dr.current.dirtyFields)&&t.shouldDirty&&(B(kr.current.dirtyFields,r,function(r,e,t){return er(nr(r,e,t.slice(0,r.length)),nr(e,r,t.slice(0,r.length)))}(e,M(N.current,r,[]),M(kr.current.dirtyFields,r,[]))),Br({isDirty:!tr(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),N.current)}))}!p&&B(G.current,r,e)}),[_r,Mr,zr]),$r=function(r){return q.current||E.current.has(r)||E.current.has((r.match(/\w+/)||[])[0])},Gr=function(r){var e=!0;if(!Q(w.current))for(var t in w.current)r&&w.current[t].size&&!w.current[t].has(r)&&!w.current[t].has(gr(r))||(S.current[t](),e=!1);return e};function Ir(r){var e;if(!p){for(var t=hr(r),n=0,i=sr.current;n<i.length;n+=1){var u=i[n];C(u)&&!t[u]&&(t=Object.assign(Object.assign({},t),((e={})[u]=[],e)))}return t}return r}function Jr(r){if(ir(r))return J(j,r,G);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];B(e,i,J(j,i,G))}return e}return Ir(ur(j,hr(G.current),p))}$.current=$.current?$.current:async function(r){var e,t,n=r.type,i=r.target,u=i.name,a=j.current[u];if(a){var s=n===v,c=function(r){var e=r.isOnBlur,t=r.isOnChange,n=r.isOnTouch,i=r.isTouched,u=r.isReValidateOnBlur,a=r.isReValidateOnChange,s=r.isBlurEvent,c=r.isSubmitted;return!r.isOnAll&&(!c&&n?!(i||s):(c?u:e)?!s:!(c?a:t)||s)}(Object.assign({isBlurEvent:s,isReValidateOnChange:Nr,isReValidateOnBlur:Rr,isTouched:!!M(kr.current.touched,u),isSubmitted:kr.current.isSubmitted},or.current)),o=_r(u,!1),f=!Q(o)||!s&&$r(u);if(s&&!M(kr.current.touched,u)&&Dr.current.touched&&(B(kr.current.touched,u,!0),o=Object.assign(Object.assign({},o),{touched:kr.current.touched})),!p&&z(i)&&B(G.current,u,J(j,u)),c)return!s&&Gr(u),(!Q(o)||f&&Q(o))&&Br(o);if(Lr(),ar.current){var l=(await ar.current(Jr(),X.current,Er)).errors,d=kr.current.isValid;if(e=M(l,u),z(i)&&!e&&ar.current){var m=gr(u),g=M(l,m,{});g.type&&g.message&&(e=g),m&&(g||M(kr.current.errors,m))&&(u=m)}d!==(t=Q(l))&&(f=!0)}else e=(await dr(j,Er,a,G))[u];!s&&Gr(u),Tr(u,e,f,o,t)}};var Kr=t((async function(r){void 0===r&&(r={});var e=Q(j.current)?N.current:{},t=(await ar.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),X.current,Er)||{}).errors,n=Q(t);kr.current.isValid!==n&&Br({isValid:n})}),[Er]),Qr=t((function(r,e){!function(r,e,t,n,i,u){var a=t.ref,s=t.ref.name,c=r.current[s];if(!i){var o=J(r,s,n);!T(o)&&B(n.current,s,o)}a.type&&c?H(a)||z(a)?Array.isArray(c.options)&&c.options.length?(R(c.options).forEach((function(r,t){void 0===r&&(r={}),(K(r.ref)&&Z(r,r.ref)||u)&&(W(r.ref,e),Y(c.options,"["+t+"]"))})),c.options&&!R(c.options).length&&delete r.current[s]):delete r.current[s]:(K(a)&&Z(c,a)||u)&&(W(a,e),delete r.current[s]):delete r.current[s]}(j,$.current,r,G,p,e),p&&(Y(k.current,r.ref.name),Y(F.current,r.ref.name))}),[p]),Xr=t((function(r){if(q.current)Br();else{for(var e=0,t=E.current;e<t.length;e+=1){if(t[e].startsWith(r)){Br();break}}Gr(r)}}),[]),Yr=t((function(r,e){r&&(Qr(r,e),p&&!R(r.options||[]).length&&(Y(kr.current.errors,r.ref.name),B(kr.current.dirtyFields,r.ref.name,!0),Br({isDirty:Wr()}),Dr.current.isValid&&ar.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?w.current[t]:E.current,i=ur(j,hr(G.current),p,!1,r);if(ir(r)){var u=gr(r)||r;return sr.current.has(u)&&(i=Object.assign(Object.assign({},A.current),i)),mr(i,r,n,T(M(N.current,r))?e:M(N.current,r),!0)}var a=T(e)?N.current:e;return Array.isArray(r)?r.reduce((function(r,e){var t;return Object.assign(Object.assign({},r),((t={})[e]=mr(i,e,n,a),t))}),{}):(q.current=T(t),L(!Q(i)&&i||a))}),[]);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(sr.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,u=r.value,a=Object.assign({ref:r},e),s=j.current,c=jr(r),o=pr(sr.current,n),f=function(e){return yr&&(!d(r)||e===r)},l=s[n],y=!0;if(l&&(c?Array.isArray(l.options)&&R(l.options).find((function(r){return u===r.ref.value&&f(r.ref)})):f(l.ref)))s[n]=Object.assign(Object.assign({},l),e);else{l=i?c?Object.assign({options:R(l&&l.options||[]).concat([{ref:r}]),ref:{type:i,name:n}},e):Object.assign({},a):a,s[n]=l;var h=T(M(G.current,n));Q(N.current)&&h||(t=M(h?N.current:G.current,n),(y=T(t))||o||Mr(n,t)),Q(e)||(B(F.current,n,!0),!lr&&Dr.current.isValid&&dr(j,Er,l,G).then((function(r){var e=kr.current.isValid;Q(r)?B(k.current,n,!0):Y(k.current,n),e!==Q(r)&&Br()}))),!p||o&&y||!o&&Y(kr.current.dirtyFields,n),i&&function(r,e,t){var n=r.ref;d(n)&&t&&(n.addEventListener(e?m:g,t),n.addEventListener(v,t))}(c&&l.options?l.options[l.options.length-1]:l,c||"select-one"===r.type,$.current)}}var ee=t((function(r,e){return async function(t){t&&t.preventDefault&&(t.preventDefault(),t.persist());var n={},i=Ir(ur(j,hr(G.current),p,!0));Dr.current.isSubmitting&&Br({isSubmitting:!0});try{if(ar.current){var u=await ar.current(i,X.current,Er),a=u.errors,s=u.values;kr.current.errors=n=a,i=s}else for(var c=0,o=Object.values(j.current);c<o.length;c+=1){var f=o[c];if(f){var d=f.ref.name,v=await dr(j,Er,f,G);v[d]?(B(n,d,v[d]),Y(k.current,d)):M(F.current,d)&&(Y(kr.current.errors,d),B(k.current,d,!0))}}Q(n)&&Object.keys(kr.current.errors).every((function(r){return r in j.current}))?(Br({errors:{},isSubmitting:!0}),await r(i,t)):(kr.current.errors=Object.assign(Object.assign({},kr.current.errors),n),e&&await e(kr.current.errors,t),l&&function(r,e){for(var t in r)if(M(e,t)){var n=r[t];if(n){if(n.ref.focus&&T(n.ref.focus()))break;if(n.options){n.options[0].ref.focus();break}}}}(j.current,kr.current.errors))}finally{kr.current.isSubmitting=!1,Br({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Q(kr.current.errors),submitCount:kr.current.submitCount+1})}}}),[l,Er]);u((function(){c&&Dr.current.isValid&&Kr(),xr.current=xr.current||!yr?xr.current:function(r,e){var t=new MutationObserver((function(){for(var t=0,n=Object.values(r.current);t<n.length;t+=1){var i=n[t];if(i&&i.options)for(var u=0,a=i.options;u<a.length;u+=1){var s=a[u];s&&s.ref&&K(s.ref)&&e(i)}else i&&K(i.ref)&&e(i)}}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(j,Yr)}),[Yr,N.current]),u((function(){return function(){xr.current&&xr.current.disconnect(),_.current=!0,"production"===process.env.NODE_ENV&&Object.values(j.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!c&&Dr.current.isValid&&(Sr.isValid=tr(k.current,F.current)&&Q(kr.current.errors));var te={trigger:Pr,setValue:t((function(r,e,t){Ur(r,e,t||{}),$r(r)&&Br(),Gr(r)}),[Ur,Pr]),getValues:t(Jr,[]),register:t((function(r,e){if(!Vr)if(ir(r))re({name:r},e);else{if(!x(r)||!("name"in r))return function(e){return e&&re(e,r)};re(r,e)}}),[N.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(j.current[n],!0)}}),[]),formState:Ar?new Proxy(Sr,{get:function(r,e){if("production"!==process.env.NODE_ENV&&"isValid"===e&&lr&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),e in r)return Dr.current[e]=!0,r[e]}}):Sr},ne=a((function(){return Object.assign({isFormDirty:Wr,updateWatchedValue:Xr,shouldUnregister:p,updateFormState:Br,removeFieldEventListener:Qr,watchInternal:Zr,mode:or.current,reValidateMode:{isReValidateOnBlur:Rr,isReValidateOnChange:Nr},validateResolver:c?Kr:void 0,fieldsRef:j,resetFieldArrayFunctionRef:I,useWatchFieldsRef:w,useWatchRenderFunctionsRef:S,fieldArrayDefaultValuesRef:V,validFieldsRef:k,fieldsWithValidationRef:F,fieldArrayNamesRef:sr,readFormStateRef:Dr,formStateRef:kr,defaultValuesRef:N,shallowFieldsStateRef:G,fieldArrayValuesRef:A},te)}),[N.current,Xr,p,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={}),yr)for(var t=0,n=Object.values(j.current);t<n.length;t+=1){var i=n[t];if(i){var u=i.ref,a=i.options,s=jr(u)&&Array.isArray(a)?a[0].ref:u;if(d(s))try{s.closest("form").reset();break}catch(r){}}}j.current={},N.current=Object.assign({},r||N.current),r&&Gr(""),Object.values(I.current).forEach((function(r){return cr(r)&&r()})),G.current=p?{}:hr(r||N.current),function(r){var e=r.errors,t=r.isDirty,n=r.isSubmitted,i=r.touched,u=r.isValid,a=r.submitCount,s=r.dirtyFields;u||(k.current={},F.current={}),V.current={},E.current=new Set,q.current=!1,Br({submitCount:a?kr.current.submitCount:0,isDirty:!!t&&kr.current.isDirty,isSubmitted:!!n&&kr.current.isSubmitted,isValid:!!u&&kr.current.isValid,dirtyFields:s?kr.current.dirtyFields:{},touched:i?kr.current.touched:{},errors:e?kr.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})}(e)}),[]),clearErrors:t((function(r){r&&(Array.isArray(r)?r:[r]).forEach((function(r){return j.current[r]&&C(r)?delete kr.current.errors[r]:Y(kr.current.errors,r)})),Br({errors:r?kr.current.errors:{}})}),[]),setError:t((function(r,e){var t=(j.current[r]||{}).ref;B(kr.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Br({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:Sr.errors},te)}e(null).displayName="RHFContext",function(r){r.formgroup="formgroup",r.checkbox="checkbox"}(br||(br={}));var wr=r.forwardRef((function(e,t){var n=e.exampleType,i=void 0===n?br.formgroup:n,u=Er(),a=u.register,s=u.handleSubmit,d=u.errors,v=d.formgroup1||d.formgroup2,m="Du må velge et alternativ",g=function(r){return r.length>=2||"Du må velge to alternativ"};return r.createElement("form",{onSubmit:s((function(r){console.log(r)}))},r.createElement(c,{variant:e.variant,errorSummary:v?"Sjekk at alt er riktig utfylt":void 0},i===br.formgroup?r.createElement(r.Fragment,null,r.createElement(o,{title:"One amazing title",legend:"Check out these checkboxes!",error:d.formgroup1?d.formgroup1.message:void 0},r.createElement(f,{name:"formgroup1",label:"Checkbox 1",ref:a({required:m})}),r.createElement(f,{name:"formgroup1",label:"Checkbox 2",ref:a({required:m})}),r.createElement(f,{name:"formgroup1",label:"Checkbox 3",ref:a({required:m})})),r.createElement(o,{legend:"Select two options!",error:d.formgroup2?d.formgroup2.message:void 0},r.createElement(f,{name:"formgroup2",label:"Checkbox 4",ref:a({validate:g})}),r.createElement(f,{name:"formgroup2",label:"Checkbox 5",ref:a({validate:g})}),r.createElement(f,{name:"formgroup2",label:"Checkbox 6",ref:a({validate:g})}))):i===br.checkbox?r.createElement(r.Fragment,null,r.createElement(f,{name:"formgroup1",label:"Checkbox 1",error:d.formgroup1,errorText:d.formgroup1?d.formgroup1.message:void 0,ref:a({required:m})})):void 0),r.createElement("br",null),r.createElement(l,null,"Submit"))}));export default wr;
2
- //# sourceMappingURL=index.js.map