@kvdbil/components 17.12.2 → 17.12.3
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.
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
right: 0;
|
|
9
9
|
margin-right: auto;
|
|
10
10
|
margin-left: auto;
|
|
11
|
-
`,
|
|
11
|
+
`,l=t.default.label`
|
|
12
12
|
${r.BodyTextStyle}
|
|
13
13
|
pointer-events: none;
|
|
14
14
|
position: absolute;
|
|
15
|
-
max-width: calc(100% - 2rem);
|
|
15
|
+
max-width: ${({suffixWidth:e,hasValue:r,isFocused:o})=>!e||r||o?"calc(100% - 2rem)":`calc(100% - 2rem - ${e}px)`};
|
|
16
16
|
z-index: 1;
|
|
17
17
|
top: ${({height:e})=>e?`calc(${e}rem - 5px)`:"12px"};
|
|
18
18
|
left: calc(0.75rem + 2px);
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
text-overflow: ellipsis;
|
|
24
24
|
background: transparent;
|
|
25
25
|
|
|
26
|
-
${({theme:e,hasValue:r,isFocused:o})=>(r||o)&&`\n span {\n display: block;\n width: 100%;\n height:
|
|
26
|
+
${({theme:e,hasValue:r,isFocused:o})=>(r||o)&&`\n span {\n display: block;\n width: 100%;\n height: 4px;\n position: absolute;\n top: 5px;\n left: 0;\n background-color: ${e.colors.background.light};\n z-index: -1;\n }\n `}
|
|
27
27
|
|
|
28
28
|
${({hasValue:r,isFocused:o,height:t,hasError:s})=>(r||o)&&((r,o)=>e.css`
|
|
29
29
|
transform: translateY(${r});
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
${({centered:e,hasValue:r,isFocused:o})=>(r||o)&&e&&i}
|
|
38
38
|
${({isFocused:e})=>e&&s}
|
|
39
39
|
${({disabled:e})=>e&&a}
|
|
40
|
-
`;exports.Label=
|
|
40
|
+
`;exports.Label=l;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),l=require("styled-components"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),l=require("styled-components"),s=require("../FieldLabel.js"),o=require("../../typography/BodyText/index.js"),t=require("../../hooks/useNameAndId.js");require("../../shared/media-queries.js"),require("../../shared/helpers.js");var a,d=(a=l)&&a.__esModule?a:{default:a};const i=l.css`
|
|
2
2
|
border: 1px solid ${({theme:e})=>e.colors.grayscaleToned.light2};
|
|
3
3
|
color: ${({theme:e})=>e.colors.text.disabled};
|
|
4
4
|
fill: ${({theme:e})=>e.colors.text.disabled};
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
border: 2px solid ${({theme:e})=>e.colors.grayscaleToned.dark5};
|
|
9
9
|
color: ${({theme:e})=>e.colors.text.dark};
|
|
10
10
|
fill: ${({theme:e})=>e.colors.text.dark};
|
|
11
|
-
`,
|
|
11
|
+
`,u=d.default.div`
|
|
12
12
|
position: relative;
|
|
13
13
|
padding: 0;
|
|
14
14
|
display: block;
|
|
15
|
-
`,
|
|
15
|
+
`,h=d.default.div`
|
|
16
16
|
display: flex;
|
|
17
17
|
text-align: center;
|
|
18
18
|
align-items: center;
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
${({disabled:e})=>e&&i}
|
|
31
31
|
${({hasError:e})=>e&&n}
|
|
32
32
|
${({centered:e})=>e&&"text-align: center;"}
|
|
33
|
-
`,m=
|
|
34
|
-
${
|
|
33
|
+
`,m=d.default.input`
|
|
34
|
+
${o.BodyTextStyle}
|
|
35
35
|
width: 100%;
|
|
36
36
|
cursor: text;
|
|
37
37
|
outline: none;
|
|
@@ -42,25 +42,26 @@
|
|
|
42
42
|
color: ${({theme:e})=>e.colors.text.disabled};
|
|
43
43
|
fill: ${({theme:e})=>e.colors.text.disabled};
|
|
44
44
|
}
|
|
45
|
-
`,x=
|
|
45
|
+
`,x=d.default.span`
|
|
46
46
|
display: flex;
|
|
47
47
|
font-family: ${({theme:e})=>e.typography.fontBaseFamily};
|
|
48
48
|
font-size: 1.25rem;
|
|
49
49
|
line-height: 1.5rem;
|
|
50
|
+
white-space: nowrap;
|
|
50
51
|
|
|
51
52
|
svg {
|
|
52
53
|
width: 1.375rem;
|
|
53
54
|
height: 1.375rem;
|
|
54
55
|
}
|
|
55
|
-
`,p=
|
|
56
|
-
${
|
|
56
|
+
`,p=d.default.div`
|
|
57
|
+
${o.CaptionStyle}
|
|
57
58
|
margin-top: 0.25rem;
|
|
58
59
|
|
|
59
60
|
${({centered:e})=>e&&"width: 100%; text-align: center;"}
|
|
60
|
-
`,b=
|
|
61
|
+
`,b=d.default.span`
|
|
61
62
|
display: block;
|
|
62
63
|
color: ${({theme:e})=>e.colors.text.disabled};
|
|
63
|
-
|
|
64
|
+
`,f=d.default.span`
|
|
64
65
|
display: block;
|
|
65
66
|
color: ${({theme:e})=>e.colors.error.dark};
|
|
66
|
-
|
|
67
|
+
`,$=({placeholder:l="",isDisabled:o=!1,centered:a=!1,hasError:d=!1,className:i,helperText:n,label:c="",onBlur:$=(()=>null),onFocus:g=(()=>null),forwardRef:y,suffix:j,name:v,errors:k,isAutoFocused:F=!1,...q})=>{const[T,w]=r.useState(!1),[B,E]=r.useState(void 0),A=r.useRef(null),N=!!q.value,S=k&&Array.isArray(k)&&k?.length>0,{name:_,id:z}=t.useNameAndId("text-input",v),I=k?.map(((e,r)=>`${z}-error-${r}`))??[],L=[n?`${z}-helper`:null,...I].filter(Boolean).join(" ");return r.useEffect((()=>{A.current&&E(A.current.offsetWidth)}),[A.current]),e.jsxs(u,{className:i,children:[e.jsxs(h,{isFocused:T,disabled:o,centered:a,hasError:d,hasPlaceholder:!!l,children:[e.jsx(m,{...q,id:z,name:_,"aria-labelledby":c?`${z}-label`:void 0,"aria-describedby":L||void 0,"aria-invalid":S||d,ref:y,onFocus:e=>{w(!0),g(e)},onBlur:e=>{w(!1),$(e)},disabled:o,placeholder:c&&!T?"":l,autoFocus:F}),j&&e.jsx(x,{ref:A,children:j})]}),c&&e.jsx(s.Label,{id:`${z}-label`,htmlFor:z,isFocused:T,centered:a,hasError:d,hasValue:N,disabled:o,suffixWidth:B,children:e.jsxs(e.Fragment,{children:[c,e.jsx("span",{})]})}),(n||S)&&e.jsxs(p,{centered:a,children:[n&&e.jsx(b,{id:`${z}-helper`,children:n}),S&&k.map(((r,l)=>e.jsx(f,{id:`${z}-error-${l}`,role:"alert","aria-live":"assertive",children:r},`${z}-error-${l}`)))]})]})};exports.TextField=$,exports.default=$;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
transform: translateY(${
|
|
1
|
+
import a,{css as t}from"styled-components";import{BodyTextStyle as i}from"../typography/BodyText/index.js";import"react/jsx-runtime";import"../shared/media-queries.js";const l=(e,o)=>t`
|
|
2
|
+
transform: translateY(${e});
|
|
3
3
|
line-height: 0.875rem;
|
|
4
4
|
font-size: 0.75rem;
|
|
5
5
|
transform-origin: 0 0;
|
|
6
6
|
padding: 0 5px;
|
|
7
7
|
left: 0.5rem;
|
|
8
|
-
color: ${({theme:r})=>
|
|
8
|
+
color: ${({theme:r})=>o?r.colors.error.dark:r.colors.text.dark};
|
|
9
9
|
`,c=t`
|
|
10
|
-
color: ${({theme:
|
|
10
|
+
color: ${({theme:e,hasError:o})=>o?e.colors.error.dark:e.colors.text.dark};
|
|
11
11
|
`,n=t`
|
|
12
|
-
color: ${({theme:
|
|
12
|
+
color: ${({theme:e})=>e.colors.text.disabled};
|
|
13
13
|
`,d=t`
|
|
14
14
|
width: max-content;
|
|
15
15
|
left: 0;
|
|
16
16
|
right: 0;
|
|
17
17
|
margin-right: auto;
|
|
18
18
|
margin-left: auto;
|
|
19
|
-
`,h=
|
|
19
|
+
`,h=a.label`
|
|
20
20
|
${i}
|
|
21
21
|
pointer-events: none;
|
|
22
22
|
position: absolute;
|
|
23
|
-
max-width: calc(100% - 2rem);
|
|
23
|
+
max-width: ${({suffixWidth:e,hasValue:o,isFocused:r})=>e&&!o&&!r?`calc(100% - 2rem - ${e}px)`:"calc(100% - 2rem)"};
|
|
24
24
|
z-index: 1;
|
|
25
|
-
top: ${({height:
|
|
25
|
+
top: ${({height:e})=>e?`calc(${e}rem - 5px)`:"12px"};
|
|
26
26
|
left: calc(0.75rem + 2px);
|
|
27
27
|
transition: 150ms;
|
|
28
|
-
color: ${({theme:
|
|
28
|
+
color: ${({theme:e})=>e.colors.text.dark};
|
|
29
29
|
overflow: hidden;
|
|
30
30
|
white-space: nowrap;
|
|
31
31
|
text-overflow: ellipsis;
|
|
32
32
|
background: transparent;
|
|
33
33
|
|
|
34
|
-
${({theme:
|
|
34
|
+
${({theme:e,hasValue:o,isFocused:r})=>(o||r)&&`
|
|
35
35
|
span {
|
|
36
36
|
display: block;
|
|
37
37
|
width: 100%;
|
|
38
|
-
height:
|
|
38
|
+
height: 4px;
|
|
39
39
|
position: absolute;
|
|
40
|
-
top:
|
|
40
|
+
top: 5px;
|
|
41
41
|
left: 0;
|
|
42
|
-
background-color: ${
|
|
42
|
+
background-color: ${e.colors.background.light};
|
|
43
43
|
z-index: -1;
|
|
44
44
|
}
|
|
45
45
|
`}
|
|
46
46
|
|
|
47
|
-
${({hasValue:
|
|
48
|
-
${({centered:
|
|
49
|
-
${({isFocused:
|
|
50
|
-
${({disabled:
|
|
47
|
+
${({hasValue:e,isFocused:o,height:r,hasError:s})=>(e||o)&&l(`${r?`calc(-${r}rem - 2px)`:"-18px"}`,s)}
|
|
48
|
+
${({centered:e,hasValue:o,isFocused:r})=>(o||r)&&e&&d}
|
|
49
|
+
${({isFocused:e})=>e&&c}
|
|
50
|
+
${({disabled:e})=>e&&n}
|
|
51
51
|
`;export{h as Label};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as m,jsx as t,Fragment as V}from"react/jsx-runtime";import{useState as y,useRef as q,useEffect as C}from"react";import o,{css as u}from"styled-components";import{Label as D}from"../FieldLabel.js";import{BodyTextStyle as G,CaptionStyle as H}from"../../typography/BodyText/index.js";import{useNameAndId as I}from"../../hooks/useNameAndId.js";import"../../shared/media-queries.js";import"../../shared/helpers.js";const J=u`
|
|
2
2
|
border: 1px solid ${({theme:e})=>e.colors.grayscaleToned.light2};
|
|
3
3
|
color: ${({theme:e})=>e.colors.text.disabled};
|
|
4
4
|
fill: ${({theme:e})=>e.colors.text.disabled};
|
|
5
|
-
`,
|
|
5
|
+
`,K=u`
|
|
6
6
|
border: 2px solid ${({theme:e})=>e.colors.error.dark};
|
|
7
|
-
`,
|
|
7
|
+
`,O=u`
|
|
8
8
|
border: 2px solid ${({theme:e})=>e.colors.grayscaleToned.dark5};
|
|
9
9
|
color: ${({theme:e})=>e.colors.text.dark};
|
|
10
10
|
fill: ${({theme:e})=>e.colors.text.dark};
|
|
11
|
-
`,
|
|
11
|
+
`,P=o.div`
|
|
12
12
|
position: relative;
|
|
13
13
|
padding: 0;
|
|
14
14
|
display: block;
|
|
15
|
-
`,
|
|
15
|
+
`,Q=o.div`
|
|
16
16
|
display: flex;
|
|
17
17
|
text-align: center;
|
|
18
18
|
align-items: center;
|
|
@@ -26,12 +26,12 @@ import{jsxs as c,jsx as t,Fragment as z}from"react/jsx-runtime";import{useState
|
|
|
26
26
|
|
|
27
27
|
padding: 0.75rem 0.6rem;
|
|
28
28
|
|
|
29
|
-
${({hasError:e,isFocused:
|
|
30
|
-
${({disabled:e})=>e&&
|
|
31
|
-
${({hasError:e})=>e&&
|
|
29
|
+
${({hasError:e,isFocused:i})=>!e&&i&&O}
|
|
30
|
+
${({disabled:e})=>e&&J}
|
|
31
|
+
${({hasError:e})=>e&&K}
|
|
32
32
|
${({centered:e})=>e&&"text-align: center;"}
|
|
33
|
-
`,
|
|
34
|
-
${
|
|
33
|
+
`,U=o.input`
|
|
34
|
+
${G}
|
|
35
35
|
width: 100%;
|
|
36
36
|
cursor: text;
|
|
37
37
|
outline: none;
|
|
@@ -42,25 +42,26 @@ import{jsxs as c,jsx as t,Fragment as z}from"react/jsx-runtime";import{useState
|
|
|
42
42
|
color: ${({theme:e})=>e.colors.text.disabled};
|
|
43
43
|
fill: ${({theme:e})=>e.colors.text.disabled};
|
|
44
44
|
}
|
|
45
|
-
`,
|
|
45
|
+
`,X=o.span`
|
|
46
46
|
display: flex;
|
|
47
47
|
font-family: ${({theme:e})=>e.typography.fontBaseFamily};
|
|
48
48
|
font-size: 1.25rem;
|
|
49
49
|
line-height: 1.5rem;
|
|
50
|
+
white-space: nowrap;
|
|
50
51
|
|
|
51
52
|
svg {
|
|
52
53
|
width: 1.375rem;
|
|
53
54
|
height: 1.375rem;
|
|
54
55
|
}
|
|
55
56
|
`,_=o.div`
|
|
56
|
-
${
|
|
57
|
+
${H}
|
|
57
58
|
margin-top: 0.25rem;
|
|
58
59
|
|
|
59
60
|
${({centered:e})=>e&&"width: 100%; text-align: center;"}
|
|
60
|
-
`,
|
|
61
|
+
`,M=o.span`
|
|
61
62
|
display: block;
|
|
62
63
|
color: ${({theme:e})=>e.colors.text.disabled};
|
|
63
|
-
`,
|
|
64
|
+
`,Y=o.span`
|
|
64
65
|
display: block;
|
|
65
66
|
color: ${({theme:e})=>e.colors.error.dark};
|
|
66
|
-
`,
|
|
67
|
+
`,k=({placeholder:e="",isDisabled:i=!1,centered:h=!1,hasError:p=!1,className:v,helperText:s,label:d="",onBlur:F=()=>null,onFocus:w=()=>null,forwardRef:B,suffix:$,name:E,errors:a,isAutoFocused:T=!1,...x})=>{const[b,g]=y(!1),[A,S]=y(void 0),n=q(null),j=!!x.value,f=a&&Array.isArray(a)&&a?.length>0,{name:N,id:r}=I("text-input",E),R=a?.map((l,c)=>`${r}-error-${c}`)??[],W=[s?`${r}-helper`:null,...R].filter(Boolean).join(" "),z=l=>{g(!0),w(l)},L=l=>{g(!1),F(l)};return C(()=>{n.current&&S(n.current.offsetWidth)},[n.current]),m(P,{className:v,children:[m(Q,{isFocused:b,disabled:i,centered:h,hasError:p,hasPlaceholder:!!e,children:[t(U,{...x,id:r,name:N,"aria-labelledby":d?`${r}-label`:void 0,"aria-describedby":W||void 0,"aria-invalid":f||p,ref:B,onFocus:z,onBlur:L,disabled:i,placeholder:d&&!b?"":e,autoFocus:T}),$&&t(X,{ref:n,children:$})]}),d&&t(D,{id:`${r}-label`,htmlFor:r,isFocused:b,centered:h,hasError:p,hasValue:j,disabled:i,suffixWidth:A,children:m(V,{children:[d,t("span",{})]})}),(s||f)&&m(_,{centered:h,children:[s&&t(M,{id:`${r}-helper`,children:s}),f&&a.map((l,c)=>t(Y,{id:`${r}-error-${c}`,role:"alert","aria-live":"assertive",children:l},`${r}-error-${c}`))]})]})};export{k as TextField,k as default};
|
package/package.json
CHANGED
package/package.json.tmp
CHANGED