@kvdbil/components 14.3.16 → 15.0.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,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("styled-components"),i=require("../../shared/helpers.js"),s=require("../../theme.js"),o=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("styled-components"),i=require("../../shared/helpers.js"),s=require("../../theme.js"),o=require("../../typography/BodyText/index.js");require("../../shared/media-queries.js");var a,l=(a=r)&&a.__esModule?a:{default:a};const t={regular:r.css`
|
|
2
2
|
.circle {
|
|
3
3
|
&--outer {
|
|
4
4
|
height: 24px;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
transform: scale(0.6);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
`},
|
|
27
|
+
`},d=r.css`
|
|
28
28
|
cursor: default;
|
|
29
29
|
|
|
30
30
|
.circle {
|
|
@@ -36,27 +36,27 @@
|
|
|
36
36
|
border: 2px solid ${s.default.colors.gray.light1};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`,
|
|
39
|
+
`,c=r.css`
|
|
40
40
|
.circle {
|
|
41
41
|
&--inner {
|
|
42
42
|
opacity: 1;
|
|
43
43
|
background-color: ${s.default.colors.gray.light1};
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
`,
|
|
46
|
+
`,n=l.default.div`
|
|
47
47
|
display: flex;
|
|
48
48
|
align-items: center;
|
|
49
49
|
box-sizing: border-box;
|
|
50
|
-
`,
|
|
50
|
+
`,u=l.default.span`
|
|
51
51
|
cursor: pointer;
|
|
52
52
|
display: flex;
|
|
53
53
|
position: relative;
|
|
54
54
|
align-items: center;
|
|
55
55
|
justify-content: center;
|
|
56
56
|
|
|
57
|
-
${e=>
|
|
57
|
+
${e=>t[e.size]};
|
|
58
58
|
|
|
59
|
-
${e=>!e.isDisabled&&e.isChecked&&(e=>r.css`
|
|
59
|
+
${e=>!e.isDisabled&&e.isChecked&&((e,i)=>r.css`
|
|
60
60
|
.circle {
|
|
61
61
|
&--inner {
|
|
62
62
|
opacity: 1;
|
|
@@ -64,23 +64,29 @@
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
&--outer {
|
|
67
|
-
border: 2px solid
|
|
67
|
+
border: 2px solid
|
|
68
|
+
${i?s.default.colors.error.dark:s.default.colors[e].main};
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
|
-
`)(e.color)};
|
|
71
|
-
${e=>e.isDisabled&&
|
|
71
|
+
`)(e.color,e.$hasError)};
|
|
72
|
+
${e=>e.isDisabled&&d};
|
|
72
73
|
|
|
73
|
-
${e=>e.isChecked&&e.isDisabled&&
|
|
74
|
-
`,
|
|
74
|
+
${e=>e.isChecked&&e.isDisabled&&c};
|
|
75
|
+
`,h=l.default.input`
|
|
75
76
|
position: fixed;
|
|
76
77
|
opacity: 0;
|
|
77
|
-
|
|
78
|
+
margin: 0;
|
|
79
|
+
${e=>!e.$isDisabled&&"cursor: pointer;"}
|
|
80
|
+
z-index: 1;
|
|
81
|
+
${e=>t[e.$size]};
|
|
82
|
+
`,b=l.default.span`
|
|
78
83
|
display: flex;
|
|
79
84
|
box-sizing: border-box;
|
|
80
85
|
border-radius: 50%;
|
|
81
86
|
|
|
82
|
-
border: 2px solid
|
|
83
|
-
|
|
87
|
+
border: 2px solid
|
|
88
|
+
${e=>e.$hasError?s.default.colors.error.dark:s.default.colors.gray.light1};
|
|
89
|
+
`,p=l.default.span`
|
|
84
90
|
box-sizing: border-box;
|
|
85
91
|
opacity: 0;
|
|
86
92
|
margin: auto;
|
|
@@ -90,9 +96,9 @@
|
|
|
90
96
|
position: absolute;
|
|
91
97
|
top: 0;
|
|
92
98
|
left: 0;
|
|
93
|
-
`,
|
|
99
|
+
`,x=l.default(o.BodyText)`
|
|
94
100
|
cursor: ${({isDisabled:e})=>e?"default":"pointer"};
|
|
95
101
|
user-select: none;
|
|
96
102
|
color: ${({theme:e,isDisabled:r})=>r?e.colors.text.disabled:e.colors.text.dark};
|
|
97
103
|
margin-left: 0.5rem;
|
|
98
|
-
`,
|
|
104
|
+
`,g=({name:r=i.generateNameHash("radio-button"),size:s="regular",checked:o=!1,isDisabled:a=!1,color:l="secondary",label:t,hasError:d,...c})=>e.jsxs(n,{children:[e.jsxs(u,{size:s,color:l,isChecked:o,isDisabled:a,$hasError:d,children:[e.jsx(h,{"data-validate":"checked",checked:o,type:"radio",name:r,id:r,disabled:a,"aria-label":r,"aria-checked":o,className:"circle circle--outer",$size:s,$isDisabled:a,...c}),e.jsx(b,{className:"circle circle--outer",$hasError:d,children:e.jsx(p,{className:"circle circle--inner"})})]}),t&&e.jsx(x,{as:"label",htmlFor:r,isDisabled:a,children:t})]});exports.RadioButton=g,exports.default=g;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as n,jsx as
|
|
1
|
+
import{jsxs as n,jsx as l}from"react/jsx-runtime";import o,{css as s}from"styled-components";import{generateNameHash as m}from"../../shared/helpers.js";import e from"../../theme.js";import{BodyText as u}from"../../typography/BodyText/index.js";import"../../shared/media-queries.js";const x=s`
|
|
2
2
|
.circle {
|
|
3
3
|
&--outer {
|
|
4
4
|
height: 24px;
|
|
@@ -11,7 +11,7 @@ import{jsxs as n,jsx as o}from"react/jsx-runtime";import i,{css as l}from"styled
|
|
|
11
11
|
transform: scale(0.6);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
`,$=s`
|
|
15
15
|
.circle {
|
|
16
16
|
&--outer {
|
|
17
17
|
height: 32px;
|
|
@@ -24,75 +24,81 @@ import{jsxs as n,jsx as o}from"react/jsx-runtime";import i,{css as l}from"styled
|
|
|
24
24
|
transform: scale(0.6);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
`,
|
|
27
|
+
`,h={regular:x,large:$},f=s`
|
|
28
28
|
cursor: default;
|
|
29
29
|
|
|
30
30
|
.circle {
|
|
31
31
|
&--inner {
|
|
32
|
-
background-color: ${
|
|
32
|
+
background-color: ${e.colors.gray.light1};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
&--outer {
|
|
36
|
-
border: 2px solid ${
|
|
36
|
+
border: 2px solid ${e.colors.gray.light1};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`,
|
|
39
|
+
`,y=s`
|
|
40
40
|
.circle {
|
|
41
41
|
&--inner {
|
|
42
42
|
opacity: 1;
|
|
43
|
-
background-color: ${
|
|
43
|
+
background-color: ${e.colors.gray.light1};
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
`,
|
|
46
|
+
`,k=(r,i)=>s`
|
|
47
47
|
.circle {
|
|
48
48
|
&--inner {
|
|
49
49
|
opacity: 1;
|
|
50
|
-
background-color: ${
|
|
50
|
+
background-color: ${e.colors[r].main};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
&--outer {
|
|
54
|
-
border: 2px solid
|
|
54
|
+
border: 2px solid
|
|
55
|
+
${i?e.colors.error.dark:e.colors[r].main};
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
`,z=
|
|
58
|
+
`,z=o.div`
|
|
58
59
|
display: flex;
|
|
59
60
|
align-items: center;
|
|
60
61
|
box-sizing: border-box;
|
|
61
|
-
`,
|
|
62
|
+
`,D=o.span`
|
|
62
63
|
cursor: pointer;
|
|
63
64
|
display: flex;
|
|
64
65
|
position: relative;
|
|
65
66
|
align-items: center;
|
|
66
67
|
justify-content: center;
|
|
67
68
|
|
|
68
|
-
${
|
|
69
|
+
${r=>h[r.size]};
|
|
69
70
|
|
|
70
|
-
${
|
|
71
|
-
${
|
|
71
|
+
${r=>!r.isDisabled&&r.isChecked&&k(r.color,r.$hasError)};
|
|
72
|
+
${r=>r.isDisabled&&f};
|
|
72
73
|
|
|
73
|
-
${
|
|
74
|
-
`,
|
|
74
|
+
${r=>r.isChecked&&r.isDisabled&&y};
|
|
75
|
+
`,E=o.input`
|
|
75
76
|
position: fixed;
|
|
76
77
|
opacity: 0;
|
|
77
|
-
|
|
78
|
+
margin: 0;
|
|
79
|
+
${r=>!r.$isDisabled&&"cursor: pointer;"}
|
|
80
|
+
z-index: 1;
|
|
81
|
+
${r=>h[r.$size]};
|
|
82
|
+
`,w=o.span`
|
|
78
83
|
display: flex;
|
|
79
84
|
box-sizing: border-box;
|
|
80
85
|
border-radius: 50%;
|
|
81
86
|
|
|
82
|
-
border: 2px solid
|
|
83
|
-
|
|
87
|
+
border: 2px solid
|
|
88
|
+
${r=>r.$hasError?e.colors.error.dark:e.colors.gray.light1};
|
|
89
|
+
`,C=o.span`
|
|
84
90
|
box-sizing: border-box;
|
|
85
91
|
opacity: 0;
|
|
86
92
|
margin: auto;
|
|
87
93
|
border-radius: 50%;
|
|
88
|
-
background-color: ${
|
|
94
|
+
background-color: ${e.colors.gray.light1};
|
|
89
95
|
|
|
90
96
|
position: absolute;
|
|
91
97
|
top: 0;
|
|
92
98
|
left: 0;
|
|
93
|
-
`,
|
|
94
|
-
cursor: ${({isDisabled:
|
|
99
|
+
`,N=o(u)`
|
|
100
|
+
cursor: ${({isDisabled:r})=>r?"default":"pointer"};
|
|
95
101
|
user-select: none;
|
|
96
|
-
color: ${({theme:
|
|
102
|
+
color: ${({theme:r,isDisabled:i})=>i?r.colors.text.disabled:r.colors.text.dark};
|
|
97
103
|
margin-left: 0.5rem;
|
|
98
|
-
`,b=({name:
|
|
104
|
+
`,b=({name:r=m("radio-button"),size:i="regular",checked:c=!1,isDisabled:a=!1,color:p="secondary",label:t,hasError:d,...g})=>n(z,{children:[n(D,{size:i,color:p,isChecked:c,isDisabled:a,$hasError:d,children:[l(E,{"data-validate":"checked",checked:c,type:"radio",name:r,id:r,disabled:a,"aria-label":r,"aria-checked":c,className:"circle circle--outer",$size:i,$isDisabled:a,...g}),l(w,{className:"circle circle--outer",$hasError:d,children:l(C,{className:"circle circle--inner"})})]}),t&&l(N,{as:"label",htmlFor:r,isDisabled:a,children:t})]});export{b as RadioButton,b as default};
|
package/package.json
CHANGED
package/package.json.tmp
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
2
|
import { RadioButtonSize, Color } from '../../Types';
|
|
3
|
-
|
|
3
|
+
type ComponentPropsWithoutSize = Omit<ComponentPropsWithoutRef<'input'>, 'size' | 'type'>;
|
|
4
|
+
export interface RadioButtonProps extends ComponentPropsWithoutSize {
|
|
4
5
|
name?: string;
|
|
5
6
|
color?: Color;
|
|
6
7
|
size?: RadioButtonSize;
|
|
7
8
|
checked?: boolean;
|
|
8
9
|
isDisabled?: boolean;
|
|
9
|
-
onChange?(): void;
|
|
10
10
|
label?: ReactNode;
|
|
11
|
+
hasError?: boolean;
|
|
11
12
|
}
|
|
12
|
-
export declare const RadioButton: ({ name, size, checked, isDisabled, color,
|
|
13
|
+
export declare const RadioButton: ({ name, size, checked, isDisabled, color, label, hasError, ...props }: RadioButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export default RadioButton;
|