@react-cupertino-ui/radio 1.0.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.
- package/LICENSE +24 -0
- package/dist/index.css +114 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +17 -0
- package/dist/index.scss +116 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Anderson Lima
|
|
4
|
+
|
|
5
|
+
This project is inspired by Apple's design principles but is not affiliated with, endorsed, or sponsored by Apple Inc.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
.react-cupertino-ui-radio {
|
|
2
|
+
--radio-size: 1.35rem;
|
|
3
|
+
--radio-dot-size: 0.52rem;
|
|
4
|
+
--radio-gap: 0.75rem;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: var(--radio-gap);
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
user-select: none;
|
|
10
|
+
}
|
|
11
|
+
.react-cupertino-ui-radio[data-disabled=true] {
|
|
12
|
+
opacity: 0.55;
|
|
13
|
+
cursor: not-allowed;
|
|
14
|
+
}
|
|
15
|
+
.react-cupertino-ui-radio__input {
|
|
16
|
+
position: absolute;
|
|
17
|
+
opacity: 0;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
20
|
+
.react-cupertino-ui-radio__control {
|
|
21
|
+
width: var(--radio-size);
|
|
22
|
+
height: var(--radio-size);
|
|
23
|
+
position: relative;
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
}
|
|
28
|
+
.react-cupertino-ui-radio__ring {
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
border-radius: 50%;
|
|
32
|
+
border: 1px solid rgba(255, 255, 255, 0.4);
|
|
33
|
+
transition: box-shadow 220ms ease, background 220ms ease;
|
|
34
|
+
background: rgba(255, 255, 255, 0.5);
|
|
35
|
+
backdrop-filter: blur(32px) saturate(var(--glass-saturation, 180%));
|
|
36
|
+
-webkit-backdrop-filter: blur(32px) saturate(var(--glass-saturation, 180%));
|
|
37
|
+
border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.18));
|
|
38
|
+
box-shadow: var(--glass-shadow, 0 8px 32px rgba(0, 0, 0, 0.12));
|
|
39
|
+
position: relative;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
}
|
|
42
|
+
.react-cupertino-ui-radio__ring::before {
|
|
43
|
+
content: "";
|
|
44
|
+
position: absolute;
|
|
45
|
+
inset: 0;
|
|
46
|
+
background: var(--glass-highlight, linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 55%));
|
|
47
|
+
border-radius: inherit;
|
|
48
|
+
opacity: var(--glass-highlight-opacity, 0.95);
|
|
49
|
+
pointer-events: none;
|
|
50
|
+
mix-blend-mode: screen;
|
|
51
|
+
}
|
|
52
|
+
.react-cupertino-ui-radio__dot {
|
|
53
|
+
position: absolute;
|
|
54
|
+
width: var(--radio-dot-size);
|
|
55
|
+
height: var(--radio-dot-size);
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
background: linear-gradient(130deg, rgba(10, 132, 255, 0.95), rgba(90, 200, 250, 0.95));
|
|
58
|
+
box-shadow: 0 8px 20px rgba(10, 132, 255, 0.35);
|
|
59
|
+
transform: scale(0);
|
|
60
|
+
opacity: 0;
|
|
61
|
+
transition: transform 200ms ease, opacity 200ms ease;
|
|
62
|
+
}
|
|
63
|
+
.react-cupertino-ui-radio__text {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
gap: 0.1rem;
|
|
67
|
+
}
|
|
68
|
+
.react-cupertino-ui-radio__label {
|
|
69
|
+
font-size: 0.95rem;
|
|
70
|
+
font-weight: 600;
|
|
71
|
+
color: hsl(var(--foreground));
|
|
72
|
+
}
|
|
73
|
+
.react-cupertino-ui-radio__helper {
|
|
74
|
+
font-size: 0.78rem;
|
|
75
|
+
color: hsl(var(--muted-foreground));
|
|
76
|
+
}
|
|
77
|
+
.react-cupertino-ui-radio__error {
|
|
78
|
+
font-size: 0.78rem;
|
|
79
|
+
color: var(--pink);
|
|
80
|
+
}
|
|
81
|
+
.react-cupertino-ui-radio[data-error=true] .react-cupertino-ui-radio__ring {
|
|
82
|
+
box-shadow: 0 0 0 2px rgba(255, 45, 85, 0.25);
|
|
83
|
+
}
|
|
84
|
+
.react-cupertino-ui-radio:focus-within .react-cupertino-ui-radio__ring {
|
|
85
|
+
box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25);
|
|
86
|
+
}
|
|
87
|
+
.react-cupertino-ui-radio__input:checked ~ .react-cupertino-ui-radio__control .react-cupertino-ui-radio__dot {
|
|
88
|
+
transform: scale(1);
|
|
89
|
+
opacity: 1;
|
|
90
|
+
}
|
|
91
|
+
.react-cupertino-ui-radio.variant-solid .react-cupertino-ui-radio__ring {
|
|
92
|
+
background: linear-gradient(120deg, rgba(10, 10, 10, 0.8), rgba(40, 40, 40, 0.95));
|
|
93
|
+
border-color: rgba(255, 255, 255, 0.25);
|
|
94
|
+
}
|
|
95
|
+
.react-cupertino-ui-radio.variant-outline .react-cupertino-ui-radio__ring {
|
|
96
|
+
background: rgba(255, 255, 255, 0.08);
|
|
97
|
+
border: 1px solid rgba(255, 255, 255, 0.5);
|
|
98
|
+
}
|
|
99
|
+
.react-cupertino-ui-radio.size-sm {
|
|
100
|
+
--radio-size: 1.15rem;
|
|
101
|
+
--radio-dot-size: 0.4rem;
|
|
102
|
+
--radio-gap: 0.6rem;
|
|
103
|
+
}
|
|
104
|
+
.react-cupertino-ui-radio.size-sm__label {
|
|
105
|
+
font-size: 0.85rem;
|
|
106
|
+
}
|
|
107
|
+
.react-cupertino-ui-radio.size-lg {
|
|
108
|
+
--radio-size: 1.6rem;
|
|
109
|
+
--radio-dot-size: 0.65rem;
|
|
110
|
+
--radio-gap: 0.85rem;
|
|
111
|
+
}
|
|
112
|
+
.react-cupertino-ui-radio.size-lg__label {
|
|
113
|
+
font-size: 1.05rem;
|
|
114
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import "./index.scss";
|
|
3
|
+
export interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "onBlur" | "onFocus"> {
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: "default" | "sm" | "lg";
|
|
6
|
+
label?: string;
|
|
7
|
+
helperText?: string;
|
|
8
|
+
error?: string;
|
|
9
|
+
variant?: "glass" | "solid" | "outline";
|
|
10
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
11
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
12
|
+
}
|
|
13
|
+
declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>;
|
|
14
|
+
export { Radio };
|
|
15
|
+
export default Radio;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "@react-cupertino-ui/shared/lib/utils";
|
|
4
|
+
import "./index.scss";
|
|
5
|
+
const Radio = React.forwardRef(({ className, size = "default", label, helperText, error, variant = "glass", id, disabled, onFocus, onBlur, ...props }, forwardedRef) => {
|
|
6
|
+
const generatedId = React.useId();
|
|
7
|
+
const controlId = id ?? `radio-${generatedId}`;
|
|
8
|
+
const helperId = helperText ? `${controlId}-helper` : undefined;
|
|
9
|
+
const errorId = error ? `${controlId}-error` : undefined;
|
|
10
|
+
const messageId = error ? errorId : helperId;
|
|
11
|
+
const internalRef = React.useRef(null);
|
|
12
|
+
React.useImperativeHandle(forwardedRef, () => internalRef.current);
|
|
13
|
+
return (_jsxs("label", { className: cn("react-cupertino-ui-radio", `size-${size}`, `variant-${variant}`, className), "data-disabled": disabled ? "true" : undefined, "data-error": error ? "true" : undefined, htmlFor: controlId, children: [_jsx("input", { ref: internalRef, id: controlId, type: "radio", className: "react-cupertino-ui-radio__input", disabled: disabled, "aria-describedby": messageId, onFocus: onFocus, onBlur: onBlur, ...props }), _jsxs("span", { className: "react-cupertino-ui-radio__control", "aria-hidden": "true", children: [_jsx("span", { className: "react-cupertino-ui-radio__ring" }), _jsx("span", { className: "react-cupertino-ui-radio__dot" })] }), (label || helperText || error) && (_jsxs("span", { className: "react-cupertino-ui-radio__text", children: [label && _jsx("span", { className: "react-cupertino-ui-radio__label", children: label }), helperText && !error && (_jsx("span", { id: helperId, className: "react-cupertino-ui-radio__helper", children: helperText })), error && (_jsx("span", { id: errorId, className: "react-cupertino-ui-radio__error", role: "alert", children: error }))] }))] }));
|
|
14
|
+
});
|
|
15
|
+
Radio.displayName = "Radio";
|
|
16
|
+
export { Radio };
|
|
17
|
+
export default Radio;
|
package/dist/index.scss
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
@use "@/styles/mixins/glass" as glass;
|
|
2
|
+
|
|
3
|
+
.react-cupertino-ui-radio {
|
|
4
|
+
--radio-size: 1.35rem;
|
|
5
|
+
--radio-dot-size: 0.52rem;
|
|
6
|
+
--radio-gap: 0.75rem;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: var(--radio-gap);
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
user-select: none;
|
|
12
|
+
|
|
13
|
+
&[data-disabled="true"] {
|
|
14
|
+
opacity: 0.55;
|
|
15
|
+
cursor: not-allowed;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__input {
|
|
19
|
+
position: absolute;
|
|
20
|
+
opacity: 0;
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&__control {
|
|
25
|
+
width: var(--radio-size);
|
|
26
|
+
height: var(--radio-size);
|
|
27
|
+
position: relative;
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__ring {
|
|
34
|
+
width: 100%;
|
|
35
|
+
height: 100%;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
border: 1px solid rgba(255, 255, 255, 0.4);
|
|
38
|
+
transition: box-shadow 220ms ease, background 220ms ease;
|
|
39
|
+
@include glass.glass-panel(light, 32px, 0.5);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&__dot {
|
|
43
|
+
position: absolute;
|
|
44
|
+
width: var(--radio-dot-size);
|
|
45
|
+
height: var(--radio-dot-size);
|
|
46
|
+
border-radius: 50%;
|
|
47
|
+
background: linear-gradient(130deg, rgba(10, 132, 255, 0.95), rgba(90, 200, 250, 0.95));
|
|
48
|
+
box-shadow: 0 8px 20px rgba(10, 132, 255, 0.35);
|
|
49
|
+
transform: scale(0);
|
|
50
|
+
opacity: 0;
|
|
51
|
+
transition: transform 200ms ease, opacity 200ms ease;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&__text {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: 0.1rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&__label {
|
|
61
|
+
font-size: 0.95rem;
|
|
62
|
+
font-weight: 600;
|
|
63
|
+
color: hsl(var(--foreground));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&__helper {
|
|
67
|
+
font-size: 0.78rem;
|
|
68
|
+
color: hsl(var(--muted-foreground));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&__error {
|
|
72
|
+
font-size: 0.78rem;
|
|
73
|
+
color: var(--pink);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&[data-error="true"] &__ring {
|
|
77
|
+
box-shadow: 0 0 0 2px rgba(255, 45, 85, 0.25);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&:focus-within &__ring {
|
|
81
|
+
box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&__input:checked ~ &__control &__dot {
|
|
85
|
+
transform: scale(1);
|
|
86
|
+
opacity: 1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.variant-solid &__ring {
|
|
90
|
+
background: linear-gradient(120deg, rgba(10, 10, 10, 0.8), rgba(40, 40, 40, 0.95));
|
|
91
|
+
border-color: rgba(255, 255, 255, 0.25);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&.variant-outline &__ring {
|
|
95
|
+
background: rgba(255, 255, 255, 0.08);
|
|
96
|
+
border: 1px solid rgba(255, 255, 255, 0.5);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&.size-sm {
|
|
100
|
+
--radio-size: 1.15rem;
|
|
101
|
+
--radio-dot-size: 0.4rem;
|
|
102
|
+
--radio-gap: 0.6rem;
|
|
103
|
+
&__label {
|
|
104
|
+
font-size: 0.85rem;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&.size-lg {
|
|
109
|
+
--radio-size: 1.6rem;
|
|
110
|
+
--radio-dot-size: 0.65rem;
|
|
111
|
+
--radio-gap: 0.85rem;
|
|
112
|
+
&__label {
|
|
113
|
+
font-size: 1.05rem;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-cupertino-ui/radio",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Radio component from React Cupertino UI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./dist/**/*.css",
|
|
14
|
+
"./dist/**/*.scss"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.build.json && npm run build:styles",
|
|
18
|
+
"build:styles": "node ../../../scripts/build-styles.mjs"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": "^18.3.1",
|
|
22
|
+
"react-dom": "^18.3.1"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@react-cupertino-ui/shared": "workspace:*"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.2.2"
|
|
29
|
+
},
|
|
30
|
+
"gitHead": "3f53987bdb936a331665691b517c2ba9984777f8",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|