@kvdbil/components 12.2.0 → 12.3.0
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,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("styled-components"),t=require("../FieldLabel.js"),l=require("../../typography/BodyText/index.js"),a=require("../../shared/helpers.js");function o(y){return y&&typeof y=="object"&&"default"in y?y:{default:y}}require("../../shared/media-queries.js");var d=o(e),s=o(r);const i=r.css`
|
|
2
|
-
border: 1px solid ${({theme:y})=>y.colors.gray.light2}
|
|
2
|
+
border: 1px solid ${({theme:y})=>y.colors.gray.light2};
|
|
3
3
|
color: ${({theme:y})=>y.colors.text.disabled};
|
|
4
4
|
fill: ${({theme:y})=>y.colors.text.disabled};
|
|
5
5
|
`,n=r.css`
|
|
6
6
|
border: 2px solid ${({theme:y})=>y.colors.error.dark};
|
|
7
7
|
`,c=r.css`
|
|
8
|
-
border: 2px solid ${({theme:y})=>y.colors.gray.dark5}
|
|
8
|
+
border: 2px solid ${({theme:y})=>y.colors.gray.dark5};
|
|
9
9
|
color: ${({theme:y})=>y.colors.text.dark};
|
|
10
10
|
fill: ${({theme:y})=>y.colors.text.dark};
|
|
11
11
|
`,u=s.default.div`
|
|
@@ -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:
|
|
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;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
border: 1px solid ${({theme:e})=>e.colors.gray.light2}
|
|
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`
|
|
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};
|
|
5
|
-
`,H=p`
|
|
6
|
-
border: 2px solid ${({theme:e})=>e.colors.error.dark};
|
|
7
5
|
`,I=p`
|
|
8
|
-
border: 2px solid ${({theme:e})=>e.colors.
|
|
6
|
+
border: 2px solid ${({theme:e})=>e.colors.error.dark};
|
|
7
|
+
`,z=p`
|
|
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
|
-
`,
|
|
11
|
+
`,C=t.div`
|
|
12
12
|
position: relative;
|
|
13
13
|
padding: 0;
|
|
14
14
|
display: block;
|
|
15
|
-
`,
|
|
15
|
+
`,L=t.div`
|
|
16
16
|
display: flex;
|
|
17
17
|
text-align: center;
|
|
18
18
|
align-items: center;
|
|
@@ -26,12 +26,12 @@ import t,{useState as S}from"react";import o,{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&&
|
|
30
|
-
${({disabled:e})=>e&&
|
|
31
|
-
${({hasError:e})=>e&&
|
|
29
|
+
${({hasError:e,isFocused:l})=>!e&&l&&z}
|
|
30
|
+
${({disabled:e})=>e&&H}
|
|
31
|
+
${({hasError:e})=>e&&I}
|
|
32
32
|
${({centered:e})=>e&&"text-align: center;"}
|
|
33
|
-
`,
|
|
34
|
-
${
|
|
33
|
+
`,W=t.input`
|
|
34
|
+
${T}
|
|
35
35
|
width: 100%;
|
|
36
36
|
cursor: text;
|
|
37
37
|
outline: none;
|
|
@@ -42,7 +42,7 @@ import t,{useState as S}from"react";import o,{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
|
-
`,
|
|
45
|
+
`,_=t.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 t,{useState as S}from"react";import o,{css as p}from"styled-components";i
|
|
|
52
52
|
width: 1.375rem;
|
|
53
53
|
height: 1.375rem;
|
|
54
54
|
}
|
|
55
|
-
`,
|
|
56
|
-
${
|
|
55
|
+
`,q=t.div`
|
|
56
|
+
${j}
|
|
57
57
|
margin-top: 0.25rem;
|
|
58
58
|
|
|
59
59
|
${({centered:e})=>e&&"width: 100%; text-align: center;"}
|
|
60
|
-
`,
|
|
60
|
+
`,A=t.span`
|
|
61
61
|
display: block;
|
|
62
62
|
color: ${({theme:e})=>e.colors.text.disabled};
|
|
63
|
-
`,
|
|
63
|
+
`,N=t.span`
|
|
64
64
|
display: block;
|
|
65
65
|
color: ${({theme:e})=>e.colors.error.dark};
|
|
66
|
-
`,
|
|
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};
|
package/package.json
CHANGED
|
@@ -8,7 +8,8 @@ export interface TextFieldProps extends ComponentPropsWithoutRef<'input'> {
|
|
|
8
8
|
suffix?: ReactNode;
|
|
9
9
|
forwardRef?: RefObject<HTMLInputElement>;
|
|
10
10
|
errors?: string[];
|
|
11
|
+
isAutoFocused?: boolean;
|
|
11
12
|
}
|
|
12
13
|
/** The main text field used */
|
|
13
|
-
export declare const TextField: ({ placeholder, isDisabled, centered, hasError, className, helperText, label, onBlur, onFocus, forwardRef, suffix, name, errors, ...props }: TextFieldProps) => JSX.Element;
|
|
14
|
+
export declare const TextField: ({ placeholder, isDisabled, centered, hasError, className, helperText, label, onBlur, onFocus, forwardRef, suffix, name, errors, isAutoFocused, ...props }: TextFieldProps) => JSX.Element;
|
|
14
15
|
export default TextField;
|