@kvdbil/components 13.1.0 → 13.1.2

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.
@@ -1,34 +1,39 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("styled-components"),t=require("../../theme.js"),l=require("../Spinner/index.js"),s=require("../../typography/ButtonText/index.js"),i=require("./styles.js");function a(x){return x&&typeof x=="object"&&"default"in x?x:{default:x}}var o=a(e),n=a(r);const u=n.default.button`
2
- ${s.BasicButtonFontStyle}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("styled-components"),l=require("../../theme.js"),r=require("../Spinner/index.js"),i=require("../../typography/ButtonText/index.js"),a=require("./styles.js");function s(x){return x&&typeof x=="object"&&"default"in x?x:{default:x}}var o=s(e),n=s(t);const u=n.default.button`
2
+ ${i.BasicButtonFontStyle}
3
3
  box-sizing: border-box;
4
4
  outline: none;
5
5
  cursor: pointer;
6
6
  user-select: none;
7
7
  position: relative;
8
8
  border: none;
9
+ min-width: ${({minWidth:x})=>x||"auto"};
9
10
  width: ${({fullWidth:x})=>x&&"100%"};
10
11
  display: flex;
11
12
  align-items: center;
12
- justify-content: ${({sufixIcon:x,prefixIcon:y})=>x||y?"space-between":"center"};
13
+ justify-content: ${({sufixIcon:x,prefixIcon:b,isLoading:z})=>z||!x&&!b?"center":"space-between"};
13
14
 
14
- ${({size:x="small"})=>i.fontSizes[x]||s.ButtonRegularTextStyle}
15
- ${({size:x,isLoading:y,minWidth:b})=>r.css`
16
- ${x==="smaller"&&i.smallerSizeStyles(y,b)}
17
- ${x==="small"&&i.smallSizeStyles(y,b)}
18
- ${x==="regular"&&i.regularSizeStyles(y,b)}
19
- ${x==="large"&&i.largeSizeStyles(y,b)}
15
+ ${({size:x="small"})=>a.fontSizes[x]||i.ButtonRegularTextStyle}
16
+ ${({size:x})=>t.css`
17
+ ${(x==="smaller"||x==="small")&&a.smallerAndSmallSizeStyles()}
18
+ ${x==="regular"&&a.regularSizeStyles()}
19
+ ${x==="large"&&a.largeSizeStyles()}
20
20
  `}
21
21
  background-color: transparent;
22
22
  transition: color 0.3s ease, background-color 0.3s ease, border 0.3s ease;
23
- ${({variant:x="solid",color:y="primary",disabled:b,theme:h})=>r.css`
24
- ${b?i.disabledColorStyles(h,x):i.colorStyles[x](h,y)}
23
+ ${({variant:x="solid",color:b="primary",disabled:z,theme:S})=>t.css`
24
+ ${z?a.disabledColorStyles(S,x):a.colorStyles[x](S,b)}
25
25
  `}
26
26
  &:focus-visible {
27
27
  box-shadow: 0px 0px 0px 1px ${({theme:x})=>x.colors.gray.light5};
28
28
  }
29
- `,d={smaller:"1rem",small:"1rem",regular:"1.5rem",large:"1.5rem"},c={smaller:"0.5rem",small:"0.5rem",regular:"1rem",large:"1rem"},f=n.default.span`
29
+ `,d={smaller:"1rem",small:"1rem",regular:"1.5rem",large:"1.5rem"},f={smaller:"0.5rem",small:"0.5rem",regular:"1rem",large:"1rem"},c=n.default.span`
30
30
  display: flex;
31
- margin-right: ${({type:x,size:y})=>x==="prefix"?c[y]:0};
32
- margin-left: ${({type:x,size:y})=>x==="sufix"?c[y]:0};
31
+ margin-right: ${({type:x,size:b})=>x==="prefix"?f[b]:0};
32
+ margin-left: ${({type:x,size:b})=>x==="sufix"?f[b]:0};
33
33
  font-size: ${({size:x})=>d[x]};
34
- `,m=n.default(l.default)``,p={smaller:1,small:1,regular:1.5,large:1.5},g=e.forwardRef(({size:x="small",color:y="primary",variant:b="solid",fullWidth:h=!1,isDisabled:v=!1,isLoading:z=!1,children:j,sufixIcon:$,prefixIcon:S,minWidth:q,as:B="button",...I},W)=>o.default.createElement(u,{...I,as:B,minWidth:q,color:y,disabled:v||z,fullWidth:h,theme:t.default,variant:b,size:x,isLoading:z,ref:W,prefixIcon:S,sufixIcon:$},z?o.default.createElement(m,{color:t.default.colors.gray.light1,size:p[x]}):o.default.createElement(o.default.Fragment,null,S&&o.default.createElement(f,{size:x,type:"prefix"},S),j,$&&o.default.createElement(f,{size:x,type:"sufix"},$))));g.displayName="Button",exports.Button=g,exports.default=g;
34
+ opacity: ${({isLoading:x})=>x?0:1};
35
+ `,m=n.default(r.default)`
36
+ position: absolute;
37
+ `,p=n.default.span`
38
+ opacity: ${({isLoading:x})=>x?0:1};
39
+ `,g={smaller:1,small:1,regular:1.5,large:1.5},y=e.forwardRef(({size:x="small",color:b="primary",variant:z="solid",fullWidth:S=!1,isDisabled:j=!1,isLoading:$=!1,children:q,sufixIcon:v,prefixIcon:E,minWidth:B,as:I="button",...W},w)=>{return o.default.createElement(u,{...W,as:I,minWidth:B,color:b,disabled:j||$,fullWidth:S,theme:l.default,variant:z,size:x,isLoading:$,ref:w,prefixIcon:E,sufixIcon:v},o.default.createElement(o.default.Fragment,null,E&&o.default.createElement(c,{size:x,type:"prefix",isLoading:$},E),(L=$,typeof(h=q)=="string"||typeof h=="number"?o.default.createElement(p,{isLoading:L},h):o.default.isValidElement(h)?o.default.cloneElement(h,{style:{...h.props.style,opacity:L?0:1}}):h),v&&o.default.createElement(c,{size:x,type:"sufix",isLoading:$},v),$&&o.default.createElement(m,{color:l.default.colors.gray.light1,size:g[x]})));var h,L});y.displayName="Button",exports.Button=y,exports.default=y;
@@ -1,62 +1,55 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("../../typography/ButtonText/index.js");require("react"),require("styled-components");const r={smaller:o.ButtonSmallTextStyle,small:o.ButtonRegularTextStyle,regular:o.ButtonRegularTextStyle,large:o.ButtonLargeTextStyle},n=(s,i)=>`
2
- color: ${s.colors[i].main};
3
- border: 2px solid ${s.colors[i].main};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("../../typography/ButtonText/index.js");require("react"),require("styled-components");const r={smaller:o.ButtonSmallTextStyle,small:o.ButtonRegularTextStyle,regular:o.ButtonRegularTextStyle,large:o.ButtonLargeTextStyle},l=(s,a)=>`
2
+ color: ${s.colors[a].main};
3
+ border: 2px solid ${s.colors[a].main};
4
4
  background-color: transparent;
5
5
 
6
6
  :hover {
7
- border: 2px solid ${s.colors[i].dark};
8
- color: ${s.colors[i].dark};
7
+ border: 2px solid ${s.colors[a].dark};
8
+ color: ${s.colors[a].dark};
9
9
  }
10
10
 
11
11
  :active {
12
- border: 2px solid ${s.colors[i].light};
13
- color: ${s.colors[i].light};
12
+ border: 2px solid ${s.colors[a].light};
13
+ color: ${s.colors[a].light};
14
14
  }
15
- `,e=(s,i)=>`
16
- color: ${i!=="neutral"?s.colors[i].main:s.colors.neutral.light};
15
+ `,n=(s,a)=>`
16
+ color: ${a!=="neutral"?s.colors[a].main:s.colors.neutral.light};
17
17
  background-color: transparent;
18
18
 
19
19
  :hover {
20
- color: ${s.colors[i].dark};
20
+ color: ${s.colors[a].dark};
21
21
  }
22
22
 
23
23
  :active {
24
- color: ${s.colors[i].dark};
24
+ color: ${s.colors[a].dark};
25
25
  }
26
- `,l=s=>`
26
+ `,e=s=>`
27
27
  color: ${s.colors.gray.light1};
28
28
  cursor: not-allowed;
29
- `,t={solid:(s,i)=>`
29
+ `,t={solid:(s,a)=>`
30
30
  color: ${s.colors.text.light};
31
- background-color: ${s.colors[i].main};
31
+ background-color: ${s.colors[a].main};
32
32
 
33
33
  :hover {
34
- border-color: ${s.colors[i].dark};
35
- background-color: ${s.colors[i].dark};
34
+ border-color: ${s.colors[a].dark};
35
+ background-color: ${s.colors[a].dark};
36
36
  }
37
37
 
38
38
  :active {
39
- border-color: ${s.colors[i].light};
40
- background-color: ${s.colors[i].light}
39
+ border-color: ${s.colors[a].light};
40
+ background-color: ${s.colors[a].light}
41
41
  }
42
- `,outline:n,flat:e};exports.colorStyles=t,exports.disabledColorStyles=(s,i)=>i==="solid"?`
43
- ${l(s)};
44
- background-color: ${s.colors.gray.light4};`:i==="outline"?`
45
- ${l(s)};
46
- border: 2px solid ${s.colors.gray.light1};`:l(s),exports.flatColorStyles=e,exports.fontSizes=r,exports.largeSizeStyles=(s,i="auto")=>`
47
- min-width: ${s?"8.5rem":i};
48
- padding: 0 1.5rem;
42
+ `,outline:l,flat:n};exports.colorStyles=t,exports.disabledColorStyles=(s,a)=>a==="solid"?`
43
+ ${e(s)};
44
+ background-color: ${s.colors.gray.light4};`:a==="outline"?`
45
+ ${e(s)};
46
+ border: 2px solid ${s.colors.gray.light1};`:e(s),exports.flatColorStyles=n,exports.fontSizes=r,exports.largeSizeStyles=()=>`
47
+ padding: 0.25rem 1.5rem;
49
48
  min-height: 3.75rem;
50
- `,exports.outlineColorStyles=n,exports.regularSizeStyles=(s,i="auto")=>`
51
- min-width: ${s?"6rem":i};
52
- padding: 0 1.5rem;
49
+ `,exports.outlineColorStyles=l,exports.regularSizeStyles=()=>`
50
+ padding: 0.25rem 1.5rem;
53
51
  min-height: 3rem;
54
- `,exports.smallSizeStyles=(s,i="auto")=>`
55
- min-width: ${s?"4.5rem":i};
56
- padding: 0 0.75rem;
57
- min-height: 2.5rem;
58
- `,exports.smallerSizeStyles=(s,i="auto")=>`
59
- min-width: ${s?"4rem":i};
60
- padding: 0 0.75rem;
52
+ `,exports.smallerAndSmallSizeStyles=()=>`
53
+ padding: 0.25rem 0.75rem;
61
54
  min-height: 2.5rem;
62
55
  `;
@@ -12,7 +12,7 @@
12
12
  position: relative;
13
13
  padding: 0;
14
14
  display: block;
15
- `,m=s.default.div`
15
+ `,h=s.default.div`
16
16
  display: flex;
17
17
  text-align: center;
18
18
  align-items: center;
@@ -30,7 +30,7 @@
30
30
  ${({disabled:y})=>y&&i}
31
31
  ${({hasError:y})=>y&&n}
32
32
  ${({centered:y})=>y&&"text-align: center;"}
33
- `,h=s.default.input`
33
+ `,m=s.default.input`
34
34
  ${l.BodyTextStyle}
35
35
  width: 100%;
36
36
  cursor: text;
@@ -63,4 +63,4 @@
63
63
  `,x=s.default.span`
64
64
  display: block;
65
65
  color: ${({theme:y})=>y.colors.error.dark};
66
- `,g=({placeholder:y="",isDisabled:k=!1,centered:F=!1,hasError:w=!1,className:z,helperText:j,label:E="",onBlur:L=()=>null,onFocus:P=()=>null,forwardRef:_,suffix:T,name:v=a.generateNameHash("text-input"),errors:B,isAutoFocused:A=!1,...N})=>{const[q,S]=e.useState(!1),C=Boolean(N.value);return d.default.createElement(u,{className:z},d.default.createElement(m,{isFocused:q,disabled:k,centered:F,hasError:w,hasPlaceholder:!!y},d.default.createElement(h,{...N,id:v,name:v,"aria-label":E||v,ref:_,onFocus:$=>{S(!0),P($)},onBlur:$=>{S(!1),L($)},disabled:k,placeholder:E&&!q?"":y,autoFocus:A}),T&&d.default.createElement(f,null,T)),E&&d.default.createElement(t.Label,{htmlFor:v,isFocused:q,centered:F,hasError:w,hasValue:C,disabled:k},E),(j||B)&&d.default.createElement(p,{centered:F},j&&d.default.createElement(b,null,j),B&&B.map($=>d.default.createElement(x,{key:$},$))))};exports.TextField=g,exports.default=g;
66
+ `,g=({placeholder:y="",isDisabled:k=!1,centered:B=!1,hasError:w=!1,className:z,helperText:F,label:E="",onBlur:L=()=>null,onFocus:P=()=>null,forwardRef:_,suffix:T,name:j=a.generateNameHash("text-input"),errors:v,isAutoFocused:C=!1,...A})=>{const[q,N]=e.useState(!1),D=Boolean(A.value),S=v&&Array.isArray(v)&&(v==null?void 0:v.length)>0;return d.default.createElement(u,{className:z},d.default.createElement(h,{isFocused:q,disabled:k,centered:B,hasError:w,hasPlaceholder:!!y},d.default.createElement(m,{...A,id:j,name:j,"aria-label":E||j,ref:_,onFocus:$=>{N(!0),P($)},onBlur:$=>{N(!1),L($)},disabled:k,placeholder:E&&!q?"":y,autoFocus:C}),T&&d.default.createElement(f,null,T)),E&&d.default.createElement(t.Label,{htmlFor:j,isFocused:q,centered:B,hasError:w,hasValue:D,disabled:k},E),(F||S)&&d.default.createElement(p,{centered:B},F&&d.default.createElement(b,null,F),S&&v.map($=>d.default.createElement(x,{key:$},$))))};exports.TextField=g,exports.default=g;
@@ -1,34 +1,39 @@
1
- import l,{forwardRef as x}from"react";import m,{css as c}from"styled-components";import p from"../../theme.js";import h from"../Spinner/index.js";import{BasicButtonFontStyle as B,ButtonRegularTextStyle as j}from"../../typography/ButtonText/index.js";import{fontSizes as E,smallerSizeStyles as w,smallSizeStyles as z,regularSizeStyles as R,largeSizeStyles as k,disabledColorStyles as C,colorStyles as F}from"./styles.js";const T=m.button`
2
- ${B}
1
+ import r,{forwardRef as w}from"react";import n,{css as y}from"styled-components";import f from"../../theme.js";import h from"../Spinner/index.js";import{BasicButtonFontStyle as C,ButtonRegularTextStyle as R}from"../../typography/ButtonText/index.js";import{fontSizes as T,smallerAndSmallSizeStyles as z,regularSizeStyles as A,largeSizeStyles as _,disabledColorStyles as k,colorStyles as F}from"./styles.js";const p=0,N=n.button`
2
+ ${C}
3
3
  box-sizing: border-box;
4
4
  outline: none;
5
5
  cursor: pointer;
6
6
  user-select: none;
7
7
  position: relative;
8
8
  border: none;
9
+ min-width: ${({minWidth:e})=>e||"auto"};
9
10
  width: ${({fullWidth:e})=>e&&"100%"};
10
11
  display: flex;
11
12
  align-items: center;
12
- justify-content: ${({sufixIcon:e,prefixIcon:r})=>e||r?"space-between":"center"};
13
+ justify-content: ${({sufixIcon:e,prefixIcon:t,isLoading:s})=>!s&&(e||t)?"space-between":"center"};
13
14
 
14
- ${({size:e="small"})=>E[e]||j}
15
- ${({size:e,isLoading:r,minWidth:t})=>c`
16
- ${e==="smaller"&&w(r,t)}
17
- ${e==="small"&&z(r,t)}
18
- ${e==="regular"&&R(r,t)}
19
- ${e==="large"&&k(r,t)}
15
+ ${({size:e="small"})=>T[e]||R}
16
+ ${({size:e})=>y`
17
+ ${(e==="smaller"||e==="small")&&z()}
18
+ ${e==="regular"&&A()}
19
+ ${e==="large"&&_()}
20
20
  `}
21
21
  background-color: transparent;
22
22
  transition: color 0.3s ease, background-color 0.3s ease, border 0.3s ease;
23
- ${({variant:e="solid",color:r="primary",disabled:t,theme:o})=>c`
24
- ${t?C(o,e):F[e](o,r)}
23
+ ${({variant:e="solid",color:t="primary",disabled:s,theme:a})=>y`
24
+ ${s?k(a,e):F[e](a,t)}
25
25
  `}
26
26
  &:focus-visible {
27
27
  box-shadow: 0px 0px 0px 1px ${({theme:e})=>e.colors.gray.light5};
28
28
  }
29
- `,_={smaller:"1rem",small:"1rem",regular:"1.5rem",large:"1.5rem"},u={smaller:"0.5rem",small:"0.5rem",regular:"1rem",large:"1rem"},y=m.span`
29
+ `,O={smaller:"1rem",small:"1rem",regular:"1.5rem",large:"1.5rem"},g={smaller:"0.5rem",small:"0.5rem",regular:"1rem",large:"1rem"},S=n.span`
30
30
  display: flex;
31
- margin-right: ${({type:e,size:r})=>e==="prefix"?u[r]:0};
32
- margin-left: ${({type:e,size:r})=>e==="sufix"?u[r]:0};
33
- font-size: ${({size:e})=>_[e]};
34
- `,v=m(h)``,M={smaller:1,small:1,regular:1.5,large:1.5},i=x(({size:e="small",color:r="primary",variant:t="solid",fullWidth:o=!1,isDisabled:g=!1,isLoading:s=!1,children:f,sufixIcon:a,prefixIcon:n,minWidth:S,as:d="button",...$},b)=>l.createElement(T,{...$,as:d,minWidth:S,color:r,disabled:g||s,fullWidth:o,theme:p,variant:t,size:e,isLoading:s,ref:b,prefixIcon:n,sufixIcon:a},s?l.createElement(v,{color:p.colors.gray.light1,size:M[e]}):l.createElement(l.Fragment,null,n&&l.createElement(y,{size:e,type:"prefix"},n),f,a&&l.createElement(y,{size:e,type:"sufix"},a))));i.displayName="Button";export{i as Button,i as default};
31
+ margin-right: ${({type:e,size:t})=>e==="prefix"?g[t]:0};
32
+ margin-left: ${({type:e,size:t})=>e==="sufix"?g[t]:0};
33
+ font-size: ${({size:e})=>O[e]};
34
+ opacity: ${({isLoading:e})=>e?p:1};
35
+ `,v=n(h)`
36
+ position: absolute;
37
+ `,D=n.span`
38
+ opacity: ${({isLoading:e})=>e?p:1};
39
+ `,G={smaller:1,small:1,regular:1.5,large:1.5},c=w(({size:e="small",color:t="primary",variant:s="solid",fullWidth:a=!1,isDisabled:$=!1,isLoading:o=!1,children:b,sufixIcon:m,prefixIcon:i,minWidth:d,as:x="button",...E},B)=>{const j=(l,u)=>typeof l=="string"||typeof l=="number"?r.createElement(D,{isLoading:u},l):r.isValidElement(l)?r.cloneElement(l,{style:{...l.props.style,opacity:u?p:1}}):l;return r.createElement(N,{...E,as:x,minWidth:d,color:t,disabled:$||o,fullWidth:a,theme:f,variant:s,size:e,isLoading:o,ref:B,prefixIcon:i,sufixIcon:m},r.createElement(r.Fragment,null,i&&r.createElement(S,{size:e,type:"prefix",isLoading:o},i),j(b,o),m&&r.createElement(S,{size:e,type:"sufix",isLoading:o},m),o&&r.createElement(v,{color:f.colors.gray.light1,size:G[e]})))});c.displayName="Button";export{c as Button,c as default};
@@ -1,20 +1,13 @@
1
- import{ButtonSmallTextStyle as n,ButtonRegularTextStyle as t,ButtonLargeTextStyle as a}from"../../typography/ButtonText/index.js";import"react";import"styled-components";const c={smaller:n,small:t,regular:t,large:a},d=(o,r="auto")=>`
2
- min-width: ${o?"4rem":r};
3
- padding: 0 0.75rem;
1
+ import{ButtonSmallTextStyle as a,ButtonRegularTextStyle as s,ButtonLargeTextStyle as c}from"../../typography/ButtonText/index.js";import"react";import"styled-components";const i={smaller:a,small:s,regular:s,large:c},d=()=>`
2
+ padding: 0.25rem 0.75rem;
4
3
  min-height: 2.5rem;
5
- `,e=(o,r="auto")=>`
6
- min-width: ${o?"4.5rem":r};
7
- padding: 0 0.75rem;
8
- min-height: 2.5rem;
9
- `,g=(o,r="auto")=>`
10
- min-width: ${o?"6rem":r};
11
- padding: 0 1.5rem;
4
+ `,e=()=>`
5
+ padding: 0.25rem 1.5rem;
12
6
  min-height: 3rem;
13
- `,u=(o,r="auto")=>`
14
- min-width: ${o?"8.5rem":r};
15
- padding: 0 1.5rem;
7
+ `,g=()=>`
8
+ padding: 0.25rem 1.5rem;
16
9
  min-height: 3.75rem;
17
- `,$=(o,r)=>`
10
+ `,u=(o,r)=>`
18
11
  color: ${o.colors.text.light};
19
12
  background-color: ${o.colors[r].main};
20
13
 
@@ -27,7 +20,7 @@ import{ButtonSmallTextStyle as n,ButtonRegularTextStyle as t,ButtonLargeTextStyl
27
20
  border-color: ${o.colors[r].light};
28
21
  background-color: ${o.colors[r].light}
29
22
  }
30
- `,s=(o,r)=>`
23
+ `,t=(o,r)=>`
31
24
  color: ${o.colors[r].main};
32
25
  border: 2px solid ${o.colors[r].main};
33
26
  background-color: transparent;
@@ -41,7 +34,7 @@ import{ButtonSmallTextStyle as n,ButtonRegularTextStyle as t,ButtonLargeTextStyl
41
34
  border: 2px solid ${o.colors[r].light};
42
35
  color: ${o.colors[r].light};
43
36
  }
44
- `,i=(o,r)=>`
37
+ `,n=(o,r)=>`
45
38
  color: ${r!=="neutral"?o.colors[r].main:o.colors.neutral.light};
46
39
  background-color: transparent;
47
40
 
@@ -55,8 +48,8 @@ import{ButtonSmallTextStyle as n,ButtonRegularTextStyle as t,ButtonLargeTextStyl
55
48
  `,l=o=>`
56
49
  color: ${o.colors.gray.light1};
57
50
  cursor: not-allowed;
58
- `,m=(o,r)=>r==="solid"?`
51
+ `,$=(o,r)=>r==="solid"?`
59
52
  ${l(o)};
60
53
  background-color: ${o.colors.gray.light4};`:r==="outline"?`
61
54
  ${l(o)};
62
- border: 2px solid ${o.colors.gray.light1};`:l(o),y={solid:$,outline:s,flat:i};export{y as colorStyles,m as disabledColorStyles,i as flatColorStyles,c as fontSizes,u as largeSizeStyles,s as outlineColorStyles,g as regularSizeStyles,e as smallSizeStyles,d as smallerSizeStyles};
55
+ border: 2px solid ${o.colors.gray.light1};`:l(o),y={solid:u,outline:t,flat:n};export{y as colorStyles,$ as disabledColorStyles,n as flatColorStyles,i as fontSizes,g as largeSizeStyles,t as outlineColorStyles,e as regularSizeStyles,d as smallerAndSmallSizeStyles};
@@ -1,4 +1,4 @@
1
- import o,{useState as v}from"react";import t,{css as p}from"styled-components";import{Label as B}from"../FieldLabel.js";import{BodyTextStyle as T,CaptionStyle as j}from"../../typography/BodyText/index.js";import{generateNameHash as w}from"../../shared/helpers.js";import"../../shared/media-queries.js";const H=p`
1
+ import t,{useState as B}from"react";import o,{css as p}from"styled-components";import{Label as T}from"../FieldLabel.js";import{BodyTextStyle as j,CaptionStyle as w}from"../../typography/BodyText/index.js";import{generateNameHash as A}from"../../shared/helpers.js";import"../../shared/media-queries.js";const H=p`
2
2
  border: 1px solid ${({theme:e})=>e.colors.gray.light2};
3
3
  color: ${({theme:e})=>e.colors.text.disabled};
4
4
  fill: ${({theme:e})=>e.colors.text.disabled};
@@ -8,11 +8,11 @@ import o,{useState as v}from"react";import t,{css as p}from"styled-components";i
8
8
  border: 2px solid ${({theme:e})=>e.colors.gray.dark5};
9
9
  color: ${({theme:e})=>e.colors.text.dark};
10
10
  fill: ${({theme:e})=>e.colors.text.dark};
11
- `,C=t.div`
11
+ `,C=o.div`
12
12
  position: relative;
13
13
  padding: 0;
14
14
  display: block;
15
- `,L=t.div`
15
+ `,L=o.div`
16
16
  display: flex;
17
17
  text-align: center;
18
18
  align-items: center;
@@ -26,12 +26,12 @@ import o,{useState as v}from"react";import t,{css as p}from"styled-components";i
26
26
 
27
27
  padding: 0.75rem 0.6rem;
28
28
 
29
- ${({hasError:e,isFocused:l})=>!e&&l&&z}
29
+ ${({hasError:e,isFocused:r})=>!e&&r&&z}
30
30
  ${({disabled:e})=>e&&H}
31
31
  ${({hasError:e})=>e&&I}
32
32
  ${({centered:e})=>e&&"text-align: center;"}
33
- `,W=t.input`
34
- ${T}
33
+ `,W=o.input`
34
+ ${j}
35
35
  width: 100%;
36
36
  cursor: text;
37
37
  outline: none;
@@ -42,7 +42,7 @@ import o,{useState as v}from"react";import t,{css as p}from"styled-components";i
42
42
  color: ${({theme:e})=>e.colors.text.disabled};
43
43
  fill: ${({theme:e})=>e.colors.text.disabled};
44
44
  }
45
- `,_=t.span`
45
+ `,_=o.span`
46
46
  display: flex;
47
47
  font-family: ${({theme:e})=>e.typography.fontBaseFamily};
48
48
  font-size: 1.25rem;
@@ -52,15 +52,15 @@ import o,{useState as v}from"react";import t,{css as p}from"styled-components";i
52
52
  width: 1.375rem;
53
53
  height: 1.375rem;
54
54
  }
55
- `,q=t.div`
56
- ${j}
55
+ `,q=o.div`
56
+ ${w}
57
57
  margin-top: 0.25rem;
58
58
 
59
59
  ${({centered:e})=>e&&"width: 100%; text-align: center;"}
60
- `,A=t.span`
60
+ `,N=o.span`
61
61
  display: block;
62
62
  color: ${({theme:e})=>e.colors.text.disabled};
63
- `,N=t.span`
63
+ `,P=o.span`
64
64
  display: block;
65
65
  color: ${({theme:e})=>e.colors.error.dark};
66
- `,y=({placeholder:e="",isDisabled:l=!1,centered:n=!1,hasError:m=!1,className:g,helperText:d,label:s="",onBlur:b=()=>null,onFocus:$=()=>null,forwardRef:h,suffix:u,name:a=w("text-input"),errors:i,isAutoFocused:k=!1,...x})=>{const[c,f]=v(!1),F=Boolean(x.value),E=r=>{f(!0),$(r)},S=r=>{f(!1),b(r)};return o.createElement(C,{className:g},o.createElement(L,{isFocused:c,disabled:l,centered:n,hasError:m,hasPlaceholder:!!e},o.createElement(W,{...x,id:a,name:a,"aria-label":s||a,ref:h,onFocus:E,onBlur:S,disabled:l,placeholder:s&&!c?"":e,autoFocus:k}),u&&o.createElement(_,null,u)),s&&o.createElement(B,{htmlFor:a,isFocused:c,centered:n,hasError:m,hasValue:F,disabled:l},s),(d||i)&&o.createElement(q,{centered:n},d&&o.createElement(A,null,d),i&&i.map(r=>o.createElement(N,{key:r},r))))};export{y as TextField,y as default};
66
+ `,g=({placeholder:e="",isDisabled:r=!1,centered:d=!1,hasError:m=!1,className:b,helperText:i,label:a="",onBlur:h=()=>null,onFocus:$=()=>null,forwardRef:k,suffix:u,name:n=A("text-input"),errors:s,isAutoFocused:E=!1,...x})=>{const[c,y]=B(!1),F=Boolean(x.value),f=s&&Array.isArray(s)&&(s==null?void 0:s.length)>0,v=l=>{y(!0),$(l)},S=l=>{y(!1),h(l)};return t.createElement(C,{className:b},t.createElement(L,{isFocused:c,disabled:r,centered:d,hasError:m,hasPlaceholder:!!e},t.createElement(W,{...x,id:n,name:n,"aria-label":a||n,ref:k,onFocus:v,onBlur:S,disabled:r,placeholder:a&&!c?"":e,autoFocus:E}),u&&t.createElement(_,null,u)),a&&t.createElement(T,{htmlFor:n,isFocused:c,centered:d,hasError:m,hasValue:F,disabled:r},a),(i||f)&&t.createElement(q,{centered:d},i&&t.createElement(N,null,i),f&&s.map(l=>t.createElement(P,{key:l},l))))};export{g as TextField,g as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kvdbil/components",
3
- "version": "13.1.0",
3
+ "version": "13.1.2",
4
4
  "sideEffects": false,
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -15,5 +15,5 @@ interface Props {
15
15
  as?: keyof JSX.IntrinsicElements;
16
16
  }
17
17
  export declare type ButtonProps = ComponentPropsWithRef<'button'> & Props;
18
- export declare const Button: React.ForwardRefExoticComponent<Pick<ButtonProps, "form" | "slot" | "style" | "title" | "type" | "name" | "key" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "as" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "size" | "fullWidth" | "sufixIcon" | "prefixIcon" | "isLoading" | "minWidth" | "variant" | "isDisabled"> & React.RefAttributes<HTMLElement>>;
18
+ export declare const Button: React.ForwardRefExoticComponent<Pick<ButtonProps, "form" | "slot" | "style" | "title" | "type" | "name" | "key" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "as" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "size" | "minWidth" | "fullWidth" | "sufixIcon" | "prefixIcon" | "isLoading" | "variant" | "isDisabled"> & React.RefAttributes<HTMLElement>>;
19
19
  export default Button;
@@ -6,10 +6,9 @@ export declare const fontSizes: {
6
6
  regular: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
7
7
  large: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
8
8
  };
9
- export declare const smallerSizeStyles: (isLoading?: boolean | undefined, minWidth?: string) => string;
10
- export declare const smallSizeStyles: (isLoading?: boolean | undefined, minWidth?: string) => string;
11
- export declare const regularSizeStyles: (isLoading?: boolean | undefined, minWidth?: string) => string;
12
- export declare const largeSizeStyles: (isLoading?: boolean | undefined, minWidth?: string) => string;
9
+ export declare const smallerAndSmallSizeStyles: () => string;
10
+ export declare const regularSizeStyles: () => string;
11
+ export declare const largeSizeStyles: () => string;
13
12
  export declare const outlineColorStyles: (theme: Theme, color: Color) => string;
14
13
  export declare const flatColorStyles: (theme: Theme, color: Color) => string;
15
14
  export declare const disabledColorStyles: (theme: Theme, variant: Variant) => string;