@kvdbil/components 8.3.0 → 8.3.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("styled-components"),t=require("../../shared/helpers.js"),i=require("../../theme.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("styled-components"),t=require("../../shared/helpers.js"),i=require("../../theme.js"),o=require("../../typography/BodyText/index.js"),a=require("../../icons/components/CheckmarkIcon.js"),s=require("../IconButton.js");function l(f){return f&&typeof f=="object"&&"default"in f?f:{default:f}}require("../../shared/media-queries.js");var d=l(e),c=l(r);const n={regular:r.css`
|
|
2
2
|
width: 24px;
|
|
3
3
|
height: 24px;
|
|
4
4
|
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
`,h=r.css`
|
|
21
21
|
background: ${i.default.colors.gray.light2};
|
|
22
22
|
`,p=c.default.div`
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
box-sizing: border-box;
|
|
23
|
+
position: relative;
|
|
24
|
+
display: inline-block;
|
|
26
25
|
`,b=c.default.input.attrs({type:"checkbox"})`
|
|
27
26
|
position: absolute;
|
|
28
27
|
appearance: none;
|
|
@@ -30,17 +29,21 @@
|
|
|
30
29
|
height: 100%;
|
|
31
30
|
margin: 0;
|
|
32
31
|
padding: 0;
|
|
32
|
+
outline: none;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
${f=>n[f.boxSize]};
|
|
33
36
|
|
|
34
37
|
:focus-visible {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
height: calc(100% + 1.25rem);
|
|
39
|
+
width: calc(100% + 1.25rem);
|
|
40
|
+
top: -0.625rem;
|
|
41
|
+
left: -0.625rem;
|
|
42
|
+
|
|
40
43
|
appearance: initial;
|
|
41
44
|
border-radius: 10rem;
|
|
42
45
|
transition: background-color 400ms;
|
|
43
|
-
${
|
|
46
|
+
${s.BackgroundStyles}
|
|
44
47
|
}
|
|
45
48
|
`,m=c.default.span`
|
|
46
49
|
box-sizing: border-box;
|
|
@@ -49,17 +52,18 @@
|
|
|
49
52
|
position: relative;
|
|
50
53
|
align-items: center;
|
|
51
54
|
justify-content: center;
|
|
55
|
+
z-index: 0;
|
|
52
56
|
|
|
53
57
|
border: 2px solid ${i.default.colors.gray.dark5};
|
|
54
58
|
|
|
55
|
-
${
|
|
59
|
+
${f=>n[f.size]};
|
|
56
60
|
|
|
57
61
|
svg {
|
|
58
62
|
opacity: 0;
|
|
59
|
-
color: ${({theme:
|
|
63
|
+
color: ${({theme:f})=>f.colors.common.white};
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
${
|
|
66
|
+
${f=>{return f.isChecked&&(k=f.color,r.css`
|
|
63
67
|
svg {
|
|
64
68
|
opacity: 1;
|
|
65
69
|
}
|
|
@@ -70,12 +74,12 @@
|
|
|
70
74
|
background: ${i.default.colors[k].main};
|
|
71
75
|
border: 2px solid ${i.default.colors[k].main};
|
|
72
76
|
`);var k}};
|
|
73
|
-
${
|
|
77
|
+
${f=>f.isDisabled&&u};
|
|
74
78
|
|
|
75
|
-
${
|
|
76
|
-
`,
|
|
77
|
-
cursor: ${({isDisabled:
|
|
79
|
+
${f=>f.isChecked&&f.isDisabled&&h};
|
|
80
|
+
`,x=c.default(o.BodyText)`
|
|
81
|
+
cursor: ${({isDisabled:f})=>f?"default":"pointer"};
|
|
78
82
|
user-select: none;
|
|
79
|
-
color: ${({theme:
|
|
83
|
+
color: ${({theme:f,isDisabled:k})=>k?f.colors.text.disabled:f.colors.text.dark};
|
|
80
84
|
margin-left: 0.5rem;
|
|
81
|
-
`,g=({name:
|
|
85
|
+
`,g=({name:f=t.generateNameHash("check-box"),isDisabled:k=!1,size:y="regular",checked:v=!1,color:$="secondary",label:j,...q})=>d.default.createElement(p,null,d.default.createElement(b,{...q,type:"checkbox",checked:v,"data-validate":"checked",name:f,id:f,color:$,disabled:k,isDisabled:k,boxSize:y}),d.default.createElement(m,{size:y,color:$,isChecked:v,isDisabled:k},d.default.createElement(a.default,null)),j&&d.default.createElement(x,{as:"label",htmlFor:f,isDisabled:k},j));exports.CheckBox=g,exports.default=g;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"react";import c,{css as r}from"styled-components";import{generateNameHash as m}from"../../shared/helpers.js";import i from"../../theme.js";import{BodyText as g}from"../../typography/BodyText/index.js";import x from"../../icons/components/CheckmarkIcon.js";import{BackgroundStyles as u}from"../IconButton.js";import"../../shared/media-queries.js";const b=r`
|
|
2
2
|
width: 24px;
|
|
3
3
|
height: 24px;
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import o from"react";import s,{css as r}from"styled-components";import{generateN
|
|
|
6
6
|
width: 15px;
|
|
7
7
|
height: 15px;
|
|
8
8
|
}
|
|
9
|
-
`,
|
|
9
|
+
`,k=r`
|
|
10
10
|
width: 32px;
|
|
11
11
|
height: 32px;
|
|
12
12
|
|
|
@@ -14,10 +14,10 @@ import o from"react";import s,{css as r}from"styled-components";import{generateN
|
|
|
14
14
|
width: 22px;
|
|
15
15
|
height: 22px;
|
|
16
16
|
}
|
|
17
|
-
`,
|
|
17
|
+
`,d={regular:b,large:k},y=r`
|
|
18
18
|
cursor: default;
|
|
19
19
|
border: 2px solid ${i.colors.gray.light2};
|
|
20
|
-
`,
|
|
20
|
+
`,f=e=>r`
|
|
21
21
|
svg {
|
|
22
22
|
opacity: 1;
|
|
23
23
|
}
|
|
@@ -27,55 +27,59 @@ import o from"react";import s,{css as r}from"styled-components";import{generateN
|
|
|
27
27
|
|
|
28
28
|
background: ${i.colors[e].main};
|
|
29
29
|
border: 2px solid ${i.colors[e].main};
|
|
30
|
-
|
|
30
|
+
`,$=r`
|
|
31
31
|
background: ${i.colors.gray.light2};
|
|
32
|
-
`,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
`,w=s.input.attrs({type:"checkbox"})`
|
|
32
|
+
`,v=c.div`
|
|
33
|
+
position: relative;
|
|
34
|
+
display: inline-block;
|
|
35
|
+
`,C=c.input.attrs({type:"checkbox"})`
|
|
37
36
|
position: absolute;
|
|
38
37
|
appearance: none;
|
|
39
38
|
width: 100%;
|
|
40
39
|
height: 100%;
|
|
41
40
|
margin: 0;
|
|
42
41
|
padding: 0;
|
|
42
|
+
outline: none;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
z-index: 1;
|
|
45
|
+
${e=>d[e.boxSize]};
|
|
43
46
|
|
|
44
47
|
:focus-visible {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
height: calc(100% + 1.25rem);
|
|
49
|
+
width: calc(100% + 1.25rem);
|
|
50
|
+
top: -0.625rem;
|
|
51
|
+
left: -0.625rem;
|
|
52
|
+
|
|
50
53
|
appearance: initial;
|
|
51
54
|
border-radius: 10rem;
|
|
52
55
|
transition: background-color 400ms;
|
|
53
56
|
${u}
|
|
54
57
|
}
|
|
55
|
-
`,z=
|
|
58
|
+
`,z=c.span`
|
|
56
59
|
box-sizing: border-box;
|
|
57
60
|
cursor: pointer;
|
|
58
61
|
display: flex;
|
|
59
62
|
position: relative;
|
|
60
63
|
align-items: center;
|
|
61
64
|
justify-content: center;
|
|
65
|
+
z-index: 0;
|
|
62
66
|
|
|
63
67
|
border: 2px solid ${i.colors.gray.dark5};
|
|
64
68
|
|
|
65
|
-
${e=>
|
|
69
|
+
${e=>d[e.size]};
|
|
66
70
|
|
|
67
71
|
svg {
|
|
68
72
|
opacity: 0;
|
|
69
73
|
color: ${({theme:e})=>e.colors.common.white};
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
${e=>e.isChecked&&
|
|
73
|
-
${e=>e.isDisabled
|
|
76
|
+
${e=>e.isChecked&&f(e.color)};
|
|
77
|
+
${e=>e.isDisabled&&y};
|
|
74
78
|
|
|
75
|
-
${e=>e.isChecked&&e.isDisabled
|
|
76
|
-
`,
|
|
79
|
+
${e=>e.isChecked&&e.isDisabled&&$};
|
|
80
|
+
`,S=c(g)`
|
|
77
81
|
cursor: ${({isDisabled:e})=>e?"default":"pointer"};
|
|
78
82
|
user-select: none;
|
|
79
|
-
color: ${({theme:e,isDisabled:
|
|
83
|
+
color: ${({theme:e,isDisabled:o})=>o?e.colors.text.disabled:e.colors.text.dark};
|
|
80
84
|
margin-left: 0.5rem;
|
|
81
|
-
`,
|
|
85
|
+
`,h=({name:e=m("check-box"),isDisabled:o=!1,size:s="regular",checked:a=!1,color:n="secondary",label:l,...p})=>t.createElement(v,null,t.createElement(C,{...p,type:"checkbox",checked:a,"data-validate":"checked",name:e,id:e,color:n,disabled:o,isDisabled:o,boxSize:s}),t.createElement(z,{size:s,color:n,isChecked:a,isDisabled:o},t.createElement(x,null)),l&&t.createElement(S,{as:"label",htmlFor:e,isDisabled:o},l));export{h as CheckBox,h as default};
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
2
|
import { CheckboxSize, Color } from '../../Types';
|
|
3
|
-
|
|
3
|
+
declare type ComponentPropsWithoutSize = Omit<ComponentPropsWithoutRef<'input'>, 'size'>;
|
|
4
|
+
export interface CheckBoxProps extends ComponentPropsWithoutSize {
|
|
4
5
|
name?: string;
|
|
5
6
|
size?: CheckboxSize;
|
|
6
|
-
value?: string;
|
|
7
7
|
color?: Color;
|
|
8
8
|
checked?: boolean;
|
|
9
9
|
isDisabled?: boolean;
|
|
10
|
-
onClick?(): void;
|
|
11
10
|
label?: ReactNode;
|
|
12
11
|
}
|
|
13
|
-
export declare const CheckBox: ({ name, isDisabled, size, checked, color,
|
|
12
|
+
export declare const CheckBox: ({ name, isDisabled, size, checked, color, label, ...rest }: CheckBoxProps) => JSX.Element;
|
|
14
13
|
export default CheckBox;
|