@react-cupertino-ui/text-field 1.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.
- package/LICENSE +24 -0
- package/dist/index.css +174 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +70 -0
- package/dist/index.scss +185 -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,174 @@
|
|
|
1
|
+
.react-cupertino-ui-textfield-wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 0.35rem;
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.react-cupertino-ui-textfield {
|
|
9
|
+
--textfield-height: 2.875rem;
|
|
10
|
+
--textfield-radius: 1.125rem;
|
|
11
|
+
--textfield-padding-inline: 1.25rem;
|
|
12
|
+
--textfield-gap: 0.65rem;
|
|
13
|
+
--textfield-focus-color: var(--color-blue, #0a84ff);
|
|
14
|
+
--textfield-border-color: rgba(255, 255, 255, 0.2);
|
|
15
|
+
position: relative;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
width: 100%;
|
|
19
|
+
min-height: var(--textfield-height);
|
|
20
|
+
border-radius: var(--textfield-radius);
|
|
21
|
+
padding-inline: var(--textfield-padding-inline);
|
|
22
|
+
gap: var(--textfield-gap);
|
|
23
|
+
color: hsl(var(--foreground));
|
|
24
|
+
font-size: 0.95rem;
|
|
25
|
+
line-height: 1.2;
|
|
26
|
+
isolation: isolate;
|
|
27
|
+
transition-property: border-color, box-shadow, transform, background, color;
|
|
28
|
+
transition-duration: 220ms;
|
|
29
|
+
transition-timing-function: cubic-bezier(0.2, 0, 0.2, 1);
|
|
30
|
+
}
|
|
31
|
+
@supports not (backdrop-filter: blur(2px)) {
|
|
32
|
+
.react-cupertino-ui-textfield {
|
|
33
|
+
background: rgba(255, 255, 255, 0.92);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
.react-cupertino-ui-textfield[data-focused=true] {
|
|
37
|
+
border-color: color-mix(in srgb, var(--textfield-focus-color), white 10%);
|
|
38
|
+
box-shadow: 0 0 0 4px color-mix(in srgb, var(--textfield-focus-color), transparent 75%), 0 10px 38px rgba(15, 15, 15, 0.15);
|
|
39
|
+
}
|
|
40
|
+
.react-cupertino-ui-textfield[data-filled=true] {
|
|
41
|
+
--textfield-border-color: rgba(255, 255, 255, 0.35);
|
|
42
|
+
}
|
|
43
|
+
.react-cupertino-ui-textfield[data-state=error] {
|
|
44
|
+
--textfield-focus-color: var(--color-red, #ff3b30);
|
|
45
|
+
--textfield-border-color: color-mix(in srgb, var(--color-red, #ff3b30), white 15%);
|
|
46
|
+
}
|
|
47
|
+
.react-cupertino-ui-textfield[data-state=success] {
|
|
48
|
+
--textfield-focus-color: var(--green, #34c759);
|
|
49
|
+
--textfield-border-color: color-mix(in srgb, var(--green, #34c759), white 20%);
|
|
50
|
+
}
|
|
51
|
+
.react-cupertino-ui-textfield[data-disabled=true] {
|
|
52
|
+
opacity: 0.55;
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
filter: grayscale(0.18);
|
|
55
|
+
}
|
|
56
|
+
.react-cupertino-ui-textfield.size-sm {
|
|
57
|
+
--textfield-height: 2.45rem;
|
|
58
|
+
--textfield-padding-inline: 1rem;
|
|
59
|
+
font-size: 0.875rem;
|
|
60
|
+
}
|
|
61
|
+
.react-cupertino-ui-textfield.size-lg {
|
|
62
|
+
--textfield-height: 3.35rem;
|
|
63
|
+
--textfield-padding-inline: 1.5rem;
|
|
64
|
+
font-size: 1.05rem;
|
|
65
|
+
}
|
|
66
|
+
.react-cupertino-ui-textfield__control {
|
|
67
|
+
flex: 1;
|
|
68
|
+
position: relative;
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
}
|
|
72
|
+
.react-cupertino-ui-textfield__label {
|
|
73
|
+
position: absolute;
|
|
74
|
+
left: 0;
|
|
75
|
+
top: 50%;
|
|
76
|
+
transform: translateY(-50%);
|
|
77
|
+
font-size: 0.85em;
|
|
78
|
+
color: color-mix(in srgb, hsl(var(--muted-foreground)), transparent 20%);
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1), color 200ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
81
|
+
will-change: transform;
|
|
82
|
+
}
|
|
83
|
+
.react-cupertino-ui-textfield[data-label=raised] .react-cupertino-ui-textfield__label {
|
|
84
|
+
transform: translateY(-145%) scale(0.82);
|
|
85
|
+
color: color-mix(in srgb, var(--textfield-focus-color), white 35%);
|
|
86
|
+
}
|
|
87
|
+
.react-cupertino-ui-textfield__input {
|
|
88
|
+
width: 100%;
|
|
89
|
+
border: none;
|
|
90
|
+
background: transparent;
|
|
91
|
+
color: inherit;
|
|
92
|
+
font: inherit;
|
|
93
|
+
padding: 0.35rem 0 0.15rem;
|
|
94
|
+
line-height: 1.4;
|
|
95
|
+
}
|
|
96
|
+
.react-cupertino-ui-textfield__input:focus {
|
|
97
|
+
outline: none;
|
|
98
|
+
}
|
|
99
|
+
.react-cupertino-ui-textfield__input::placeholder {
|
|
100
|
+
color: color-mix(in srgb, hsl(var(--muted-foreground)), transparent 30%);
|
|
101
|
+
opacity: 0.8;
|
|
102
|
+
}
|
|
103
|
+
.react-cupertino-ui-textfield[data-label] .react-cupertino-ui-textfield__input {
|
|
104
|
+
padding-top: 0.85rem;
|
|
105
|
+
}
|
|
106
|
+
.react-cupertino-ui-textfield__icon {
|
|
107
|
+
display: inline-flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
justify-content: center;
|
|
110
|
+
width: 1.3rem;
|
|
111
|
+
height: 1.3rem;
|
|
112
|
+
color: color-mix(in srgb, hsl(var(--muted-foreground)), transparent 5%);
|
|
113
|
+
flex-shrink: 0;
|
|
114
|
+
filter: drop-shadow(0 2px 6px rgba(15, 15, 15, 0.18));
|
|
115
|
+
}
|
|
116
|
+
.react-cupertino-ui-textfield__icon[data-slot=left] {
|
|
117
|
+
order: -1;
|
|
118
|
+
}
|
|
119
|
+
.react-cupertino-ui-textfield__icon[data-slot=right] {
|
|
120
|
+
order: 1;
|
|
121
|
+
}
|
|
122
|
+
.react-cupertino-ui-textfield__icon svg {
|
|
123
|
+
width: 100%;
|
|
124
|
+
height: 100%;
|
|
125
|
+
}
|
|
126
|
+
.react-cupertino-ui-textfield__message {
|
|
127
|
+
font-size: 0.78rem;
|
|
128
|
+
color: hsl(var(--muted-foreground));
|
|
129
|
+
display: inline-flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
gap: 0.35rem;
|
|
132
|
+
margin-left: 0.35rem;
|
|
133
|
+
margin-top: 0.15rem;
|
|
134
|
+
}
|
|
135
|
+
.react-cupertino-ui-textfield__message.is-error {
|
|
136
|
+
color: var(--color-red, #ff3b30);
|
|
137
|
+
}
|
|
138
|
+
.react-cupertino-ui-textfield__message.is-success {
|
|
139
|
+
color: var(--green, #34c759);
|
|
140
|
+
}
|
|
141
|
+
.react-cupertino-ui-textfield.variant-glass {
|
|
142
|
+
border-color: var(--textfield-border-color);
|
|
143
|
+
background: rgba(255, 255, 255, 0.55);
|
|
144
|
+
backdrop-filter: blur(var(--glass-blur, 24px)) saturate(var(--glass-saturation, 180%));
|
|
145
|
+
-webkit-backdrop-filter: blur(var(--glass-blur, 24px)) saturate(var(--glass-saturation, 180%));
|
|
146
|
+
border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.18));
|
|
147
|
+
box-shadow: var(--glass-shadow, 0 8px 32px rgba(0, 0, 0, 0.12));
|
|
148
|
+
position: relative;
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
}
|
|
151
|
+
.react-cupertino-ui-textfield.variant-glass::before {
|
|
152
|
+
content: "";
|
|
153
|
+
position: absolute;
|
|
154
|
+
inset: 0;
|
|
155
|
+
background: var(--glass-highlight, linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 55%));
|
|
156
|
+
border-radius: inherit;
|
|
157
|
+
opacity: var(--glass-highlight-opacity, 0.95);
|
|
158
|
+
pointer-events: none;
|
|
159
|
+
mix-blend-mode: screen;
|
|
160
|
+
}
|
|
161
|
+
.react-cupertino-ui-textfield.variant-outline {
|
|
162
|
+
background: rgba(255, 255, 255, 0.1);
|
|
163
|
+
border: 1px solid color-mix(in srgb, var(--color-white, #fff), transparent 65%);
|
|
164
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
|
|
165
|
+
backdrop-filter: blur(18px);
|
|
166
|
+
-webkit-backdrop-filter: blur(18px);
|
|
167
|
+
}
|
|
168
|
+
.react-cupertino-ui-textfield.variant-filled {
|
|
169
|
+
background: rgba(255, 255, 255, 0.35);
|
|
170
|
+
border: 1px solid transparent;
|
|
171
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
|
|
172
|
+
backdrop-filter: blur(22px);
|
|
173
|
+
-webkit-backdrop-filter: blur(22px);
|
|
174
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import "./index.scss";
|
|
3
|
+
type NativeInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "value" | "defaultValue" | "onChange" | "onFocus" | "onBlur">;
|
|
4
|
+
export interface TextFieldProps extends NativeInputProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
variant?: "glass" | "default" | "outline" | "filled";
|
|
7
|
+
size?: "default" | "sm" | "lg";
|
|
8
|
+
label?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
success?: string;
|
|
11
|
+
helperText?: string;
|
|
12
|
+
leftIcon?: React.ReactNode;
|
|
13
|
+
rightIcon?: React.ReactNode;
|
|
14
|
+
value?: React.InputHTMLAttributes<HTMLInputElement>["value"];
|
|
15
|
+
defaultValue?: React.InputHTMLAttributes<HTMLInputElement>["defaultValue"];
|
|
16
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
17
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
18
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
19
|
+
}
|
|
20
|
+
declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement>>;
|
|
21
|
+
export { TextField };
|
|
22
|
+
export default TextField;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { BaseVariants } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
|
|
4
|
+
import { cn } from "@react-cupertino-ui/shared/lib/utils";
|
|
5
|
+
import "./index.scss";
|
|
6
|
+
const hasFieldValue = (nextValue) => {
|
|
7
|
+
if (Array.isArray(nextValue)) {
|
|
8
|
+
return nextValue.length > 0;
|
|
9
|
+
}
|
|
10
|
+
if (nextValue === undefined || nextValue === null) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return `${nextValue}`.trim().length > 0;
|
|
14
|
+
};
|
|
15
|
+
const TextField = React.forwardRef(({ className, variant = "glass", size = "default", label, error, helperText, success, leftIcon, rightIcon, disabled, id, value, defaultValue, onChange, onFocus, onBlur, ...rest }, ref) => {
|
|
16
|
+
const resolvedVariant = variant === "default" ? "glass" : variant;
|
|
17
|
+
const generatedId = React.useId();
|
|
18
|
+
const inputId = id ?? `textfield-${generatedId}`;
|
|
19
|
+
const [isFocused, setFocused] = React.useState(false);
|
|
20
|
+
const [isFilled, setFilled] = React.useState(() => hasFieldValue(value ?? defaultValue));
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
if (value !== undefined) {
|
|
23
|
+
setFilled(hasFieldValue(value));
|
|
24
|
+
}
|
|
25
|
+
}, [value]);
|
|
26
|
+
const state = error
|
|
27
|
+
? "error"
|
|
28
|
+
: success
|
|
29
|
+
? "success"
|
|
30
|
+
: "default";
|
|
31
|
+
const message = error ?? success ?? helperText;
|
|
32
|
+
const messageType = error ? "error" : success ? "success" : helperText ? "helper" : null;
|
|
33
|
+
const messageId = messageType ? `${inputId}-${messageType}` : undefined;
|
|
34
|
+
const handleFocus = (event) => {
|
|
35
|
+
setFocused(true);
|
|
36
|
+
onFocus?.(event);
|
|
37
|
+
};
|
|
38
|
+
const handleBlur = (event) => {
|
|
39
|
+
setFocused(false);
|
|
40
|
+
onBlur?.(event);
|
|
41
|
+
};
|
|
42
|
+
const handleChange = (event) => {
|
|
43
|
+
if (value === undefined) {
|
|
44
|
+
setFilled(hasFieldValue(event.target.value));
|
|
45
|
+
}
|
|
46
|
+
onChange?.(event);
|
|
47
|
+
};
|
|
48
|
+
const inputValueProps = value !== undefined
|
|
49
|
+
? { value }
|
|
50
|
+
: { defaultValue };
|
|
51
|
+
const classes = BaseVariants("react-cupertino-ui-textfield", {
|
|
52
|
+
variant: resolvedVariant,
|
|
53
|
+
size,
|
|
54
|
+
className: cn(className, {
|
|
55
|
+
"has-left-icon": Boolean(leftIcon),
|
|
56
|
+
"has-right-icon": Boolean(rightIcon),
|
|
57
|
+
}),
|
|
58
|
+
}, {
|
|
59
|
+
defaultVariants: {
|
|
60
|
+
variant: "glass",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return (_jsxs("div", { className: "react-cupertino-ui-textfield-wrapper", children: [_jsxs("div", { className: classes, "data-focused": isFocused ? "true" : undefined, "data-filled": isFilled ? "true" : undefined, "data-label": label ? (isFocused || isFilled ? "raised" : "resting") : undefined, "data-state": state !== "default" ? state : undefined, "data-disabled": disabled ? "true" : undefined, children: [leftIcon && (_jsx("span", { className: "react-cupertino-ui-textfield__icon", "data-slot": "left", "aria-hidden": "true", children: leftIcon })), _jsxs("div", { className: "react-cupertino-ui-textfield__control", children: [label && (_jsx("label", { className: "react-cupertino-ui-textfield__label", htmlFor: inputId, children: label })), _jsx("input", { id: inputId, ref: ref, className: "react-cupertino-ui-textfield__input", disabled: disabled, "aria-invalid": state === "error" ? "true" : undefined, "aria-describedby": messageId, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, ...inputValueProps, ...rest })] }), rightIcon && (_jsx("span", { className: "react-cupertino-ui-textfield__icon", "data-slot": "right", "aria-hidden": "true", children: rightIcon }))] }), message && (_jsx("span", { id: messageId, className: cn("react-cupertino-ui-textfield__message", {
|
|
64
|
+
"is-error": state === "error",
|
|
65
|
+
"is-success": state === "success",
|
|
66
|
+
}), role: state === "error" ? "alert" : undefined, children: message }))] }));
|
|
67
|
+
});
|
|
68
|
+
TextField.displayName = "TextField";
|
|
69
|
+
export { TextField };
|
|
70
|
+
export default TextField;
|
package/dist/index.scss
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
@use "@/styles/mixins/glass" as glass;
|
|
2
|
+
|
|
3
|
+
.react-cupertino-ui-textfield-wrapper {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: 0.35rem;
|
|
7
|
+
width: 100%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.react-cupertino-ui-textfield {
|
|
11
|
+
--textfield-height: 2.875rem;
|
|
12
|
+
--textfield-radius: 1.125rem;
|
|
13
|
+
--textfield-padding-inline: 1.25rem;
|
|
14
|
+
--textfield-gap: 0.65rem;
|
|
15
|
+
--textfield-focus-color: var(--color-blue, #0a84ff);
|
|
16
|
+
--textfield-border-color: rgba(255, 255, 255, 0.2);
|
|
17
|
+
position: relative;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
width: 100%;
|
|
21
|
+
min-height: var(--textfield-height);
|
|
22
|
+
border-radius: var(--textfield-radius);
|
|
23
|
+
padding-inline: var(--textfield-padding-inline);
|
|
24
|
+
gap: var(--textfield-gap);
|
|
25
|
+
color: hsl(var(--foreground));
|
|
26
|
+
font-size: 0.95rem;
|
|
27
|
+
line-height: 1.2;
|
|
28
|
+
isolation: isolate;
|
|
29
|
+
transition-property: border-color, box-shadow, transform, background, color;
|
|
30
|
+
transition-duration: 220ms;
|
|
31
|
+
transition-timing-function: cubic-bezier(0.2, 0, 0.2, 1);
|
|
32
|
+
|
|
33
|
+
@supports not ((backdrop-filter: blur(2px))) {
|
|
34
|
+
background: rgba(255, 255, 255, 0.92);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&[data-focused="true"] {
|
|
38
|
+
border-color: color-mix(in srgb, var(--textfield-focus-color), white 10%);
|
|
39
|
+
box-shadow: 0 0 0 4px color-mix(in srgb, var(--textfield-focus-color), transparent 75%),
|
|
40
|
+
0 10px 38px rgba(15, 15, 15, 0.15);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&[data-filled="true"] {
|
|
44
|
+
--textfield-border-color: rgba(255, 255, 255, 0.35);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&[data-state="error"] {
|
|
48
|
+
--textfield-focus-color: var(--color-red, #ff3b30);
|
|
49
|
+
--textfield-border-color: color-mix(in srgb, var(--color-red, #ff3b30), white 15%);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&[data-state="success"] {
|
|
53
|
+
--textfield-focus-color: var(--green, #34c759);
|
|
54
|
+
--textfield-border-color: color-mix(in srgb, var(--green, #34c759), white 20%);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&[data-disabled="true"] {
|
|
58
|
+
opacity: 0.55;
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
filter: grayscale(0.18);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&.size-sm {
|
|
64
|
+
--textfield-height: 2.45rem;
|
|
65
|
+
--textfield-padding-inline: 1rem;
|
|
66
|
+
font-size: 0.875rem;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&.size-lg {
|
|
70
|
+
--textfield-height: 3.35rem;
|
|
71
|
+
--textfield-padding-inline: 1.5rem;
|
|
72
|
+
font-size: 1.05rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&__control {
|
|
76
|
+
flex: 1;
|
|
77
|
+
position: relative;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&__label {
|
|
83
|
+
position: absolute;
|
|
84
|
+
left: 0;
|
|
85
|
+
top: 50%;
|
|
86
|
+
transform: translateY(-50%);
|
|
87
|
+
font-size: 0.85em;
|
|
88
|
+
color: color-mix(in srgb, hsl(var(--muted-foreground)), transparent 20%);
|
|
89
|
+
pointer-events: none;
|
|
90
|
+
transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
|
|
91
|
+
color 200ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
92
|
+
will-change: transform;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&[data-label="raised"] &__label {
|
|
96
|
+
transform: translateY(-145%) scale(0.82);
|
|
97
|
+
color: color-mix(in srgb, var(--textfield-focus-color), white 35%);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&__input {
|
|
101
|
+
width: 100%;
|
|
102
|
+
border: none;
|
|
103
|
+
background: transparent;
|
|
104
|
+
color: inherit;
|
|
105
|
+
font: inherit;
|
|
106
|
+
padding: 0.35rem 0 0.15rem;
|
|
107
|
+
line-height: 1.4;
|
|
108
|
+
|
|
109
|
+
&:focus {
|
|
110
|
+
outline: none;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&::placeholder {
|
|
114
|
+
color: color-mix(in srgb, hsl(var(--muted-foreground)), transparent 30%);
|
|
115
|
+
opacity: 0.8;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&[data-label] &__input {
|
|
120
|
+
padding-top: 0.85rem;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&__icon {
|
|
124
|
+
display: inline-flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
justify-content: center;
|
|
127
|
+
width: 1.3rem;
|
|
128
|
+
height: 1.3rem;
|
|
129
|
+
color: color-mix(in srgb, hsl(var(--muted-foreground)), transparent 5%);
|
|
130
|
+
flex-shrink: 0;
|
|
131
|
+
filter: drop-shadow(0 2px 6px rgba(15, 15, 15, 0.18));
|
|
132
|
+
|
|
133
|
+
&[data-slot="left"] {
|
|
134
|
+
order: -1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&[data-slot="right"] {
|
|
138
|
+
order: 1;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
svg {
|
|
142
|
+
width: 100%;
|
|
143
|
+
height: 100%;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&__message {
|
|
148
|
+
font-size: 0.78rem;
|
|
149
|
+
color: hsl(var(--muted-foreground));
|
|
150
|
+
display: inline-flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
gap: 0.35rem;
|
|
153
|
+
margin-left: 0.35rem;
|
|
154
|
+
margin-top: 0.15rem;
|
|
155
|
+
|
|
156
|
+
&.is-error {
|
|
157
|
+
color: var(--color-red, #ff3b30);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&.is-success {
|
|
161
|
+
color: var(--green, #34c759);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&.variant-glass {
|
|
166
|
+
border-color: var(--textfield-border-color);
|
|
167
|
+
@include glass.glass-panel(light, var(--glass-blur, 24px), 0.55);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
&.variant-outline {
|
|
171
|
+
background: rgba(255, 255, 255, 0.1);
|
|
172
|
+
border: 1px solid color-mix(in srgb, var(--color-white, #fff), transparent 65%);
|
|
173
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
|
|
174
|
+
backdrop-filter: blur(18px);
|
|
175
|
+
-webkit-backdrop-filter: blur(18px);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&.variant-filled {
|
|
179
|
+
background: rgba(255, 255, 255, 0.35);
|
|
180
|
+
border: 1px solid transparent;
|
|
181
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
|
|
182
|
+
backdrop-filter: blur(22px);
|
|
183
|
+
-webkit-backdrop-filter: blur(22px);
|
|
184
|
+
}
|
|
185
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-cupertino-ui/text-field",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TextField 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
|
+
}
|