@peculiar/react-components 0.3.9 → 0.3.10
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.
- package/dist/cjs/Checkbox/checkbox.js +54 -36
- package/dist/cjs/Checkbox/checkbox.js.map +1 -1
- package/dist/cjs/Radio/radio.js +54 -35
- package/dist/cjs/Radio/radio.js.map +1 -1
- package/dist/cjs/Switch/switch.js +41 -36
- package/dist/cjs/Switch/switch.js.map +1 -1
- package/dist/esm/Checkbox/checkbox.js +54 -36
- package/dist/esm/Checkbox/checkbox.js.map +1 -1
- package/dist/esm/Radio/radio.js +54 -35
- package/dist/esm/Radio/radio.js.map +1 -1
- package/dist/esm/Switch/switch.js +41 -36
- package/dist/esm/Switch/switch.js.map +1 -1
- package/dist/esnext/Checkbox/checkbox.js +54 -36
- package/dist/esnext/Checkbox/checkbox.js.map +1 -1
- package/dist/esnext/Radio/radio.js +54 -35
- package/dist/esnext/Radio/radio.js.map +1 -1
- package/dist/esnext/Switch/switch.js +41 -36
- package/dist/esnext/Switch/switch.js.map +1 -1
- package/dist/types/Checkbox/checkbox.d.ts +6 -0
- package/dist/types/Radio/radio.d.ts +3 -0
- package/package.json +2 -2
|
@@ -4,18 +4,14 @@ import { useId } from '../hooks';
|
|
|
4
4
|
import { css, cx } from '../styles';
|
|
5
5
|
const stylesBase = () => css({
|
|
6
6
|
label: 'Switch',
|
|
7
|
-
cursor: 'pointer',
|
|
8
7
|
display: 'inline-flex',
|
|
9
8
|
width: 'var(--pv-size-base-7)',
|
|
10
9
|
height: 'var(--pv-size-base-4)',
|
|
11
10
|
borderRadius: 'var(--pv-size-base-4)',
|
|
12
11
|
justifyContent: 'center',
|
|
12
|
+
position: 'relative',
|
|
13
13
|
alignItems: 'center',
|
|
14
14
|
});
|
|
15
|
-
const stylesBaseDisabled = () => css({
|
|
16
|
-
label: 'disabled',
|
|
17
|
-
cursor: 'not-allowed',
|
|
18
|
-
});
|
|
19
15
|
const stylesInput = (props) => css({
|
|
20
16
|
label: 'Switch-input',
|
|
21
17
|
overflow: 'hidden',
|
|
@@ -23,66 +19,75 @@ const stylesInput = (props) => css({
|
|
|
23
19
|
height: '100%',
|
|
24
20
|
margin: 0,
|
|
25
21
|
padding: 0,
|
|
26
|
-
|
|
27
|
-
borderRadius: '
|
|
22
|
+
outline: 0,
|
|
23
|
+
borderRadius: 'inherit',
|
|
28
24
|
appearance: 'none',
|
|
29
25
|
backgroundColor: 'var(--pv-color-gray-6)',
|
|
30
26
|
'&:checked': {
|
|
31
27
|
backgroundColor: `var(--pv-color-${props.color})`,
|
|
32
28
|
'+ [aria-hidden]': {
|
|
33
|
-
transform: '
|
|
29
|
+
transform: 'translateX(calc(50% - 2px))',
|
|
30
|
+
'&:before': {
|
|
31
|
+
backgroundColor: `var(--pv-color-${props.color}-shade-2)`,
|
|
32
|
+
},
|
|
34
33
|
},
|
|
35
34
|
},
|
|
36
35
|
'&:disabled': {
|
|
36
|
+
cursor: 'not-allowed',
|
|
37
|
+
pointerEvents: 'none',
|
|
37
38
|
opacity: 0.4,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
},
|
|
40
|
+
'&:not(:disabled)': {
|
|
41
|
+
cursor: 'pointer',
|
|
42
|
+
'&:hover': {
|
|
43
|
+
'+ [aria-hidden]:before': {
|
|
44
|
+
opacity: 0.18,
|
|
45
|
+
},
|
|
41
46
|
},
|
|
42
|
-
'
|
|
43
|
-
|
|
47
|
+
'&:focus': {
|
|
48
|
+
'+ [aria-hidden]:before': {
|
|
49
|
+
opacity: 0.23,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
'&:active': {
|
|
53
|
+
'+ [aria-hidden]:before': {
|
|
54
|
+
opacity: 0.30,
|
|
55
|
+
},
|
|
44
56
|
},
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
const stylesControl = (props) => css({
|
|
48
|
-
label: 'Switch-control',
|
|
49
|
-
width: 'var(--pv-size-base-7)',
|
|
50
|
-
height: 'var(--pv-size-base-4)',
|
|
51
|
-
position: 'relative',
|
|
52
|
-
color: `var(--pv-color-${props.color})`,
|
|
53
|
-
'&:after': {
|
|
54
|
-
top: '-10px',
|
|
55
|
-
left: '-10px',
|
|
56
|
-
right: '-10px',
|
|
57
|
-
bottom: '-10px',
|
|
58
|
-
content: '""',
|
|
59
|
-
position: 'absolute',
|
|
60
|
-
borderRadius: '50%',
|
|
61
57
|
},
|
|
62
58
|
});
|
|
63
59
|
const stylesDot = () => css({
|
|
64
60
|
label: 'Switch-dot',
|
|
65
61
|
display: 'block',
|
|
66
62
|
position: 'absolute',
|
|
67
|
-
top: '50%',
|
|
68
63
|
width: 'var(--pv-size-base-3)',
|
|
69
64
|
height: 'var(--pv-size-base-3)',
|
|
70
|
-
transform: 'translate(calc(2px), -50%)',
|
|
71
65
|
transition: 'transform 200ms',
|
|
72
66
|
boxShadow: 'var(--pv-shadow-light-low)',
|
|
73
|
-
|
|
67
|
+
transform: 'translateX(calc(-50% + 2px))',
|
|
68
|
+
pointerEvents: 'none',
|
|
69
|
+
'&:before': {
|
|
70
|
+
top: '-10px',
|
|
71
|
+
left: '-10px',
|
|
72
|
+
right: '-10px',
|
|
73
|
+
bottom: '-10px',
|
|
74
|
+
content: '""',
|
|
75
|
+
position: 'absolute',
|
|
76
|
+
borderRadius: '50%',
|
|
77
|
+
opacity: 0,
|
|
78
|
+
backgroundColor: 'var(--pv-color-gray-9)',
|
|
79
|
+
transition: 'opacity 200ms, background-color 200ms',
|
|
80
|
+
},
|
|
74
81
|
});
|
|
75
82
|
export const Switch = React.forwardRef((props, ref) => {
|
|
76
83
|
const { checked, defaultChecked, color = 'primary', required, inputProps, className, disabled, id: idProp, name, onChange, ...other } = props;
|
|
77
84
|
const id = useId(idProp);
|
|
78
85
|
return (React.createElement("label", { ...other, ref: ref, htmlFor: id, className: cx({
|
|
79
86
|
[stylesBase()]: true,
|
|
80
|
-
[stylesBaseDisabled()]: disabled,
|
|
81
87
|
[className]: !!className,
|
|
82
88
|
}) },
|
|
83
|
-
React.createElement(
|
|
84
|
-
|
|
85
|
-
React.createElement(Box, { "aria-hidden": true, className: cx(stylesDot()), background: `${color}-contrast`, borderColor: "gray-3", borderWidth: 1, borderStyle: "solid", borderRadius: 100 }))));
|
|
89
|
+
React.createElement("input", { ...inputProps, type: "checkbox", name: name, id: id, checked: checked, defaultChecked: defaultChecked, required: required, disabled: disabled, className: cx(stylesInput(props)), onChange: onChange }),
|
|
90
|
+
React.createElement(Box, { "aria-hidden": true, className: cx(stylesDot()), background: `${color}-contrast`, borderColor: "gray-3", borderWidth: 1, borderStyle: "solid", borderRadius: 100 })));
|
|
86
91
|
});
|
|
87
92
|
Switch.displayName = 'Switch';
|
|
88
93
|
Switch.defaultProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/Switch/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAmDpC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC;IAC3B,KAAK,EAAE,QAAQ;IACf,
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/Switch/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAmDpC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC;IAC3B,KAAK,EAAE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AQ,EAAE,QAAQ,GAClB;QACF,oBAAC,GAAG,yBAEF,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,EAC1B,UAAU,EAAE,GAAG,KAAK,WAAW,EAC/B,WAAW,EAAC,QAAQ,EACpB,WAAW,EAAE,CAAC,EACd,WAAW,EAAC,OAAO,EACnB,YAAY,EAAE,GAAG,GACjB,CACI,CACT,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC;AAE9B,MAAM,CAAC,YAAY,GAAG;IACpB,KAAK,EAAE,SAAS;CACjB,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Types.
|
|
4
|
+
*/
|
|
2
5
|
declare type BaseProps = {
|
|
3
6
|
/**
|
|
4
7
|
* If `true`, the component is checked.
|
|
@@ -39,5 +42,8 @@ declare type BaseProps = {
|
|
|
39
42
|
'data-testid'?: string;
|
|
40
43
|
};
|
|
41
44
|
export declare type CheckboxProps = BaseProps & Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'children' | 'htmlFor' | 'onChange'>;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
42
48
|
export declare const Checkbox: React.ForwardRefExoticComponent<BaseProps & Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "children" | "htmlFor" | "onChange"> & React.RefAttributes<HTMLLabelElement>>;
|
|
43
49
|
export {};
|
|
@@ -43,5 +43,8 @@ declare type BaseProps = {
|
|
|
43
43
|
'data-testid'?: string;
|
|
44
44
|
};
|
|
45
45
|
export declare type RadioProps = BaseProps & Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'children' | 'htmlFor' | 'onChange'>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
46
49
|
export declare const Radio: React.ForwardRefExoticComponent<BaseProps & Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "children" | "htmlFor" | "onChange"> & React.RefAttributes<HTMLLabelElement>>;
|
|
47
50
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peculiar/react-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.10",
|
|
5
5
|
"author": "PeculiarVentures Team",
|
|
6
6
|
"description": "A simple and customizable component library to build faster, beautiful, and more accessible React applications.",
|
|
7
7
|
"keywords": [
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"node": ">=12.x"
|
|
94
94
|
},
|
|
95
95
|
"license": "MIT",
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "dbee55269a6826948da728704d8c017ca3c37ef8"
|
|
97
97
|
}
|