@traefik-labs/faency 13.1.0 → 13.2.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/dist/components/Badge/Badge.cjs +1 -5
- package/dist/components/Badge/Badge.cjs.map +1 -1
- package/dist/components/Badge/Badge.js +2 -6
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Button/Button.cjs +1 -2
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js +2 -3
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.cjs +15 -2
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +15 -2
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.themes.cjs +4 -2
- package/dist/components/Checkbox/Checkbox.themes.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.themes.js +4 -2
- package/dist/components/Checkbox/Checkbox.themes.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs +2 -1
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.js +3 -2
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +2 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.js +3 -2
- package/dist/components/CodeBlock/CodeBlock.vanilla.js.map +1 -1
- package/dist/components/DateTimePickerInput/DateTimePickerInput.cjs +1 -1
- package/dist/components/DateTimePickerInput/DateTimePickerInput.cjs.map +1 -1
- package/dist/components/DateTimePickerInput/DateTimePickerInput.js +1 -1
- package/dist/components/DateTimePickerInput/DateTimePickerInput.js.map +1 -1
- package/dist/components/Field/Field.cjs +91 -0
- package/dist/components/Field/Field.cjs.map +1 -0
- package/dist/components/Field/Field.js +89 -0
- package/dist/components/Field/Field.js.map +1 -0
- package/dist/components/Field/Field.vanilla.cjs +95 -0
- package/dist/components/Field/Field.vanilla.cjs.map +1 -0
- package/dist/components/Field/Field.vanilla.css.cjs +6 -0
- package/dist/components/Field/Field.vanilla.css.cjs.map +1 -0
- package/dist/components/Field/Field.vanilla.css.js +6 -0
- package/dist/components/Field/Field.vanilla.css.js.map +1 -0
- package/dist/components/Field/Field.vanilla.js +93 -0
- package/dist/components/Field/Field.vanilla.js.map +1 -0
- package/dist/components/Field/FieldContext.cjs +136 -0
- package/dist/components/Field/FieldContext.cjs.map +1 -0
- package/dist/components/Field/FieldContext.js +130 -0
- package/dist/components/Field/FieldContext.js.map +1 -0
- package/dist/components/Input/Input.cjs +31 -6
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.js +31 -6
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/Input.vanilla.cjs +17 -4
- package/dist/components/Input/Input.vanilla.cjs.map +1 -1
- package/dist/components/Input/Input.vanilla.css.cjs.map +1 -1
- package/dist/components/Input/Input.vanilla.css.js.map +1 -1
- package/dist/components/Input/Input.vanilla.js +17 -4
- package/dist/components/Input/Input.vanilla.js.map +1 -1
- package/dist/components/Radio/Radio.cjs +21 -1
- package/dist/components/Radio/Radio.cjs.map +1 -1
- package/dist/components/Radio/Radio.js +21 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Radio/Radio.themes.cjs +4 -2
- package/dist/components/Radio/Radio.themes.cjs.map +1 -1
- package/dist/components/Radio/Radio.themes.js +4 -2
- package/dist/components/Radio/Radio.themes.js.map +1 -1
- package/dist/components/Select/Select.cjs +33 -4
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.js +33 -4
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Switch/Switch.cjs +19 -5
- package/dist/components/Switch/Switch.cjs.map +1 -1
- package/dist/components/Switch/Switch.js +19 -5
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Switch/Switch.themes.cjs +4 -2
- package/dist/components/Switch/Switch.themes.cjs.map +1 -1
- package/dist/components/Switch/Switch.themes.js +4 -2
- package/dist/components/Switch/Switch.themes.js.map +1 -1
- package/dist/components/Text/Text.themes.cjs +2 -2
- package/dist/components/Text/Text.themes.cjs.map +1 -1
- package/dist/components/Text/Text.themes.js +2 -2
- package/dist/components/Text/Text.themes.js.map +1 -1
- package/dist/components/Text/Text.vanilla.cjs +36 -0
- package/dist/components/Text/Text.vanilla.cjs.map +1 -0
- package/dist/components/Text/Text.vanilla.css.cjs +55 -0
- package/dist/components/Text/Text.vanilla.css.cjs.map +1 -0
- package/dist/components/Text/Text.vanilla.css.js +56 -0
- package/dist/components/Text/Text.vanilla.css.js.map +1 -0
- package/dist/components/Text/Text.vanilla.js +36 -0
- package/dist/components/Text/Text.vanilla.js.map +1 -0
- package/dist/components/TextField/TextField.cjs +74 -78
- package/dist/components/TextField/TextField.cjs.map +1 -1
- package/dist/components/TextField/TextField.js +74 -78
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TextField/TextField.vanilla.cjs +70 -86
- package/dist/components/TextField/TextField.vanilla.cjs.map +1 -1
- package/dist/components/TextField/TextField.vanilla.css.cjs +10 -0
- package/dist/components/TextField/TextField.vanilla.css.cjs.map +1 -0
- package/dist/components/TextField/TextField.vanilla.css.js +8 -0
- package/dist/components/TextField/TextField.vanilla.css.js.map +1 -0
- package/dist/components/TextField/TextField.vanilla.js +71 -87
- package/dist/components/TextField/TextField.vanilla.js.map +1 -1
- package/dist/components/Textarea/Textarea.cjs +51 -41
- package/dist/components/Textarea/Textarea.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.js +51 -41
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.cjs +49 -49
- package/dist/components/Textarea/Textarea.vanilla.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.css.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.css.js.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.js +49 -49
- package/dist/components/Textarea/Textarea.vanilla.js.map +1 -1
- package/dist/faency.css +170 -14
- package/dist/index.cjs +7 -1
- package/dist/index.d.ts +375 -0
- package/dist/index.js +5 -2
- package/dist/styles/themeContext.cjs +2 -1
- package/dist/styles/themeContext.cjs.map +1 -1
- package/dist/styles/themeContext.js +3 -2
- package/dist/styles/themeContext.js.map +1 -1
- package/dist/styles/themes.css.cjs.map +1 -1
- package/dist/styles/themes.css.js.map +1 -1
- package/dist/utils/useIsomorphicLayoutEffect.cjs +6 -0
- package/dist/utils/useIsomorphicLayoutEffect.cjs.map +1 -0
- package/dist/utils/useIsomorphicLayoutEffect.js +6 -0
- package/dist/utils/useIsomorphicLayoutEffect.js.map +1 -0
- package/package.json +15 -15
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { styled } from "../../stitches.config.js";
|
|
2
2
|
import { elevationVariants } from "../Elevation/Elevation.js";
|
|
3
|
+
import { useFieldControl } from "../Field/FieldContext.js";
|
|
3
4
|
import React from "react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
// components/Input/Input.tsx
|
|
@@ -22,12 +23,16 @@ var StyledInput = styled("input", {
|
|
|
22
23
|
fontVariantNumeric: "tabular-nums",
|
|
23
24
|
transition: "box-shadow .1s ease-in-out",
|
|
24
25
|
"&[type=\"number\"]": { pr: "0" },
|
|
25
|
-
"&:-webkit-autofill,&:autofill": {
|
|
26
|
+
"&:-webkit-autofill,&:autofill": {
|
|
27
|
+
boxShadow: "inset 0 0 0 1px $colors$inputBorder, inset 0 0 0 100px $colors$inputBg",
|
|
28
|
+
WebkitTextFillColor: "$colors$hiContrast"
|
|
29
|
+
},
|
|
26
30
|
"&:-webkit-autofill::first-line,&:autofill::first-line": {
|
|
27
31
|
fontFamily: "$rubik",
|
|
28
32
|
color: "$hiContrast"
|
|
29
33
|
},
|
|
30
34
|
"&:focus-visible": { boxShadow: `inset 0 0 0 2px $colors$inputFocusBorder, ${FOCUS_SHADOW}` },
|
|
35
|
+
"&:-webkit-autofill:focus-visible,&:autofill:focus-visible": { boxShadow: `inset 0 0 0 2px $colors$inputFocusBorder, inset 0 0 0 100px $colors$inputBg, ${FOCUS_SHADOW}` },
|
|
31
36
|
"&::placeholder": { color: "$inputPlaceholder" },
|
|
32
37
|
"&:read-only:not(:disabled)": { boxShadow: "none" },
|
|
33
38
|
"&:disabled": {
|
|
@@ -68,7 +73,9 @@ var StyledInput = styled("input", {
|
|
|
68
73
|
} },
|
|
69
74
|
state: { invalid: {
|
|
70
75
|
boxShadow: "inset 0 0 0 1px $colors$inputInvalidBorder",
|
|
71
|
-
"
|
|
76
|
+
"&:-webkit-autofill,&:autofill": { boxShadow: "inset 0 0 0 1px $colors$inputInvalidBorder, inset 0 0 0 100px $colors$inputBg" },
|
|
77
|
+
"&:focus-visible": { boxShadow: `inset 0 0 0 2px $colors$inputInvalidBorder, ${FOCUS_SHADOW}` },
|
|
78
|
+
"&:-webkit-autofill:focus-visible,&:autofill:focus-visible": { boxShadow: `inset 0 0 0 2px $colors$inputInvalidBorder, inset 0 0 0 100px $colors$inputBg, ${FOCUS_SHADOW}` }
|
|
72
79
|
} },
|
|
73
80
|
cursor: {
|
|
74
81
|
default: {
|
|
@@ -143,6 +150,7 @@ var InputWrapper = styled("div", {
|
|
|
143
150
|
outline: "none",
|
|
144
151
|
lineHeight: 0,
|
|
145
152
|
position: "relative",
|
|
153
|
+
isolation: "isolate",
|
|
146
154
|
backgroundColor: "$inputBg",
|
|
147
155
|
color: "$inputPlaceholder",
|
|
148
156
|
"&::before": {
|
|
@@ -223,10 +231,22 @@ var AdornmentWrapper = styled("div", {
|
|
|
223
231
|
},
|
|
224
232
|
defaultVariants: { size: "medium" }
|
|
225
233
|
});
|
|
226
|
-
var AdornmentWrapperStart = styled(AdornmentWrapper, {
|
|
234
|
+
var AdornmentWrapperStart = styled(AdornmentWrapper, {
|
|
235
|
+
left: 0,
|
|
236
|
+
zIndex: 1,
|
|
237
|
+
pointerEvents: "none"
|
|
238
|
+
});
|
|
227
239
|
var AdornmentWrapperEnd = styled(AdornmentWrapper, { right: 0 });
|
|
228
|
-
var Input = React.forwardRef(({ size, startAdornment, endAdornment, css, ...props }, forwardedRef) => {
|
|
240
|
+
var Input = React.forwardRef(({ size, startAdornment, endAdornment, css, state, id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }, forwardedRef) => {
|
|
229
241
|
const inputRef = React.useRef(null);
|
|
242
|
+
const control = useFieldControl({
|
|
243
|
+
id,
|
|
244
|
+
disabled,
|
|
245
|
+
invalid: state === "invalid",
|
|
246
|
+
"aria-describedby": ariaDescribedBy,
|
|
247
|
+
"aria-invalid": ariaInvalid
|
|
248
|
+
});
|
|
249
|
+
const resolvedState = control.invalid ? "invalid" : state;
|
|
230
250
|
React.useImperativeHandle(forwardedRef, () => {
|
|
231
251
|
const { current } = inputRef;
|
|
232
252
|
if (current) current.clear = () => {
|
|
@@ -238,8 +258,8 @@ var Input = React.forwardRef(({ size, startAdornment, endAdornment, css, ...prop
|
|
|
238
258
|
const hasEndAdornment = React.useMemo(() => Boolean(endAdornment), [endAdornment]);
|
|
239
259
|
return /* @__PURE__ */ jsxs(InputWrapper, {
|
|
240
260
|
css,
|
|
241
|
-
disabled:
|
|
242
|
-
state:
|
|
261
|
+
disabled: control.disabled,
|
|
262
|
+
state: resolvedState,
|
|
243
263
|
children: [
|
|
244
264
|
hasStartAdornment && /* @__PURE__ */ jsx(AdornmentWrapperStart, {
|
|
245
265
|
size,
|
|
@@ -250,6 +270,11 @@ var Input = React.forwardRef(({ size, startAdornment, endAdornment, css, ...prop
|
|
|
250
270
|
startAdornment: hasStartAdornment,
|
|
251
271
|
endAdornment: hasEndAdornment,
|
|
252
272
|
size,
|
|
273
|
+
state: resolvedState,
|
|
274
|
+
id: control.id,
|
|
275
|
+
disabled: control.disabled,
|
|
276
|
+
"aria-describedby": control["aria-describedby"],
|
|
277
|
+
"aria-invalid": control["aria-invalid"],
|
|
253
278
|
...props
|
|
254
279
|
}),
|
|
255
280
|
hasEndAdornment && /* @__PURE__ */ jsx(AdornmentWrapperEnd, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","names":[],"sources":["../../../components/Input/Input.tsx"],"sourcesContent":["import React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { elevationVariants } from '../Elevation';\n\n// CONSTANTS\nconst FOCUS_SHADOW = elevationVariants[1].boxShadow; // apply elevation $1 when focus\n\nconst SMALL_HEIGHT = '$5';\nconst MEDIUM_HEIGHT = '$6';\nconst LARGE_HEIGHT = '$7';\n\nconst StyledInput = styled('input', {\n // Reset\n appearance: 'none',\n borderWidth: '0',\n boxSizing: 'border-box',\n fontFamily: '$rubik',\n margin: '0',\n outline: 'none',\n padding: '0',\n width: '100%',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n // Custom\n position: 'relative',\n backgroundColor: 'transparent',\n borderRadius: 'inherit', // inherit border radius from InputWrapper\n boxShadow: 'inset 0 0 0 1px $colors$inputBorder',\n color: '$inputText',\n fontVariantNumeric: 'tabular-nums',\n transition: 'box-shadow .1s ease-in-out',\n\n '&[type=\"number\"]': {\n pr: '0', // remove padding for number native controls\n },\n\n '&:-webkit-autofill,&:autofill': {\n boxShadow: 'inset 0 0 0 1px $colors$inputBorder, inset 0 0 0 100px $colors$inputBg',\n },\n\n '&:-webkit-autofill::first-line,&:autofill::first-line': {\n fontFamily: '$rubik',\n color: '$hiContrast',\n },\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$inputFocusBorder, ${FOCUS_SHADOW}`,\n },\n\n '&::placeholder': {\n color: '$inputPlaceholder',\n },\n\n '&:read-only:not(:disabled)': {\n boxShadow: 'none',\n },\n\n '&:disabled': {\n pointerEvents: 'none',\n color: '$inputDisabledText',\n },\n\n variants: {\n size: {\n small: {\n height: SMALL_HEIGHT,\n fontSize: '$1',\n px: '$2',\n lineHeight: '$sizes$5',\n '&:-webkit-autofill::first-line,&:autofill::first-line': {\n fontSize: '$1',\n },\n },\n medium: {\n height: MEDIUM_HEIGHT,\n fontSize: '$3',\n px: '$3',\n lineHeight: '$sizes$6',\n '&:-webkit-autofill::first-line,&:autofill::first-line': {\n fontSize: '$3',\n },\n },\n large: {\n height: LARGE_HEIGHT,\n fontSize: '$3',\n px: '$3',\n lineHeight: '$sizes$7',\n '&:-webkit-autofill::first-line,&:autofill::first-line': {\n fontSize: '$3',\n },\n },\n },\n startAdornment: {\n true: {},\n },\n endAdornment: {\n true: {},\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n '&:disabled': {\n boxShadow: 'none',\n },\n backgroundColor: 'transparent',\n '&:focus-visible': {\n backgroundColor: '$loContrast',\n },\n },\n },\n state: {\n invalid: {\n boxShadow: 'inset 0 0 0 1px $colors$inputInvalidBorder',\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$inputInvalidBorder, ${FOCUS_SHADOW}`,\n },\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '@hover': {\n '&:hover:not(:read-only)': {\n cursor: 'text',\n },\n },\n '&:focus-visible:not(:read-only)': {\n cursor: 'text',\n },\n },\n text: {\n cursor: 'text',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n cursor: 'default',\n },\n compoundVariants: [\n {\n variant: 'ghost',\n state: 'invalid',\n css: {\n boxShadow: 'inset 0 0 0 1px $colors$inputInvalidBorder',\n },\n },\n {\n startAdornment: true,\n size: 'small',\n css: {\n paddingInlineStart: 'calc($2 + 15px)',\n },\n },\n {\n startAdornment: true,\n size: 'medium',\n css: {\n paddingInlineStart: 'calc($3 + 15px)',\n },\n },\n {\n startAdornment: true,\n size: 'large',\n css: {\n paddingInlineStart: 'calc($3 + 15px)',\n },\n },\n {\n endAdornment: true,\n size: 'small',\n css: {\n paddingInlineEnd: 'calc($2 + 15px)',\n },\n },\n {\n endAdornment: true,\n size: 'medium',\n css: {\n paddingInlineEnd: 'calc($3 + 15px)',\n },\n },\n {\n endAdornment: true,\n size: 'large',\n css: {\n paddingInlineEnd: 'calc($3 + 15px)',\n },\n },\n {\n endAdornment: true,\n size: 'small',\n state: 'invalid',\n css: {\n paddingInlineEnd: 'calc($4 + 30px)', // size padding + adornment margins + icon size + icon size\n },\n },\n {\n endAdornment: true,\n size: 'medium',\n state: 'invalid',\n css: {\n paddingInlineEnd: 'calc($6 + 30px)', // size padding + adornment margins + icon size + icon size\n },\n },\n {\n endAdornment: true,\n size: 'large',\n state: 'invalid',\n css: {\n paddingInlineEnd: 'calc($6 + 30px)', // size padding + adornment margins + icon size + icon size\n },\n },\n ],\n});\n\nconst InputWrapper = styled('div', {\n // Reset\n outline: 'none',\n lineHeight: 0,\n\n position: 'relative',\n backgroundColor: '$inputBg',\n color: '$inputPlaceholder',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$inputFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n '&::before': {\n backgroundColor: '$inputHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n\n variants: {\n disabled: {\n true: {\n opacity: 0.7,\n color: '$inputDisabledText',\n '@hover': {\n '&:hover': {\n '&::before': {\n backgroundColor: 'inherit',\n },\n '&::after': {\n backgroundColor: 'inherit',\n },\n },\n },\n },\n },\n state: {\n invalid: {\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$inputInvalidBorder',\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: '$2',\n '&::before, &::after': {\n borderRadius: '$2',\n },\n },\n medium: {\n borderRadius: '$3',\n '&::before, &::after': {\n borderRadius: '$3',\n },\n },\n large: {\n borderRadius: '$3',\n '&::before, &::after': {\n borderRadius: '$3',\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n disabled: false,\n },\n});\n\nconst AdornmentWrapper = styled('div', {\n position: 'absolute',\n top: 0,\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n variants: {\n size: {\n small: {\n mx: 'calc($2 / 2)',\n },\n medium: {\n mx: 'calc($3 / 2)',\n },\n large: {\n mx: 'calc($3 / 2)',\n },\n },\n variant: {\n start: {\n left: 0,\n },\n end: {\n right: 0,\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nconst AdornmentWrapperStart = styled(AdornmentWrapper, {\n left: 0,\n});\n\nconst AdornmentWrapperEnd = styled(AdornmentWrapper, {\n right: 0,\n});\n\ntype DefaultInputVariants = VariantProps<typeof StyledInput>;\nexport type InputVariants = Omit<DefaultInputVariants, 'startAdornment' | 'endAdornment'>;\nexport interface HTMLInputProps extends React.InputHTMLAttributes<any> {\n startAdornment?: React.ReactNode;\n endAdornment?: React.ReactNode;\n type?: string;\n}\n\nexport type InputProps = Omit<HTMLInputProps, 'size'> & InputVariants & { css?: CSS };\n\nexport interface InputHandle extends HTMLInputElement {\n clear: () => void;\n}\n\nexport const Input = React.forwardRef<InputHandle, InputProps>(\n ({ size, startAdornment, endAdornment, css, ...props }, forwardedRef) => {\n const inputRef = React.useRef<InputHandle>(null);\n\n React.useImperativeHandle(\n forwardedRef,\n () => {\n const { current } = inputRef;\n if (current) {\n current.clear = () => {\n current.value = '';\n };\n }\n return current as InputHandle;\n },\n [inputRef]\n );\n\n const hasStartAdornment = React.useMemo(() => Boolean(startAdornment), [startAdornment]);\n\n const hasEndAdornment = React.useMemo(() => Boolean(endAdornment), [endAdornment]);\n\n return (\n <InputWrapper css={css} disabled={props.disabled} state={props.state}>\n {hasStartAdornment && (\n <AdornmentWrapperStart size={size}>{startAdornment}</AdornmentWrapperStart>\n )}\n\n <StyledInput\n ref={inputRef}\n startAdornment={hasStartAdornment}\n endAdornment={hasEndAdornment}\n size={size}\n {...props}\n />\n {hasEndAdornment && <AdornmentWrapperEnd size={size}>{endAdornment}</AdornmentWrapperEnd>}\n </InputWrapper>\n );\n }\n);\n"],"mappings":";;;;;AAMA,IAAM,eAAe,kBAAkB,EAAE,CAAC;AAM1C,IAAM,cAAc,OAAO,SAAS;CAElC,YAAY;CACZ,aAAa;CACb,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;CACP,yBAAyB;CAGzB,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,WAAW;CACX,OAAO;CACP,oBAAoB;CACpB,YAAY;CAEZ,sBAAoB,EAClB,IAAI,IACN;CAEA,iCAAiC,EAC/B,WAAW,yEACb;CAEA,yDAAyD;EACvD,YAAY;EACZ,OAAO;CACT;CAEA,mBAAmB,EACjB,WAAW,6CAA6C,eAC1D;CAEA,kBAAkB,EAChB,OAAO,oBACT;CAEA,8BAA8B,EAC5B,WAAW,OACb;CAEA,cAAc;EACZ,eAAe;EACf,OAAO;CACT;CAEA,UAAU;EACR,MAAM;GACJ,OAAO;IACL,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,yDAAyD,EACvD,UAAU,KACZ;GACF;GACA,QAAQ;IACN,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,yDAAyD,EACvD,UAAU,KACZ;GACF;GACA,OAAO;IACL,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,yDAAyD,EACvD,UAAU,KACZ;GACF;EACF;EACA,gBAAgB,EACd,MAAM,CAAC,EACT;EACA,cAAc,EACZ,MAAM,CAAC,EACT;EACA,SAAS,EACP,OAAO;GACL,WAAW;GACX,cAAc,EACZ,WAAW,OACb;GACA,iBAAiB;GACjB,mBAAmB,EACjB,iBAAiB,cACnB;EACF,EACF;EACA,OAAO,EACL,SAAS;GACP,WAAW;GACX,mBAAmB,EACjB,WAAW,+CAA+C,eAC5D;EACF,EACF;EACA,QAAQ;GACN,SAAS;IACP,QAAQ;IACR,UAAU,EACR,2BAA2B,EACzB,QAAQ,OACV,EACF;IACA,mCAAmC,EACjC,QAAQ,OACV;GACF;GACA,MAAM,EACJ,QAAQ,OACV;EACF;CACF;CACA,iBAAiB;EACf,MAAM;EACN,QAAQ;CACV;CACA,kBAAkB;EAChB;GACE,SAAS;GACT,OAAO;GACP,KAAK,EACH,WAAW,6CACb;EACF;EACA;GACE,gBAAgB;GAChB,MAAM;GACN,KAAK,EACH,oBAAoB,kBACtB;EACF;EACA;GACE,gBAAgB;GAChB,MAAM;GACN,KAAK,EACH,oBAAoB,kBACtB;EACF;EACA;GACE,gBAAgB;GAChB,MAAM;GACN,KAAK,EACH,oBAAoB,kBACtB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,OAAO;GACP,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,OAAO;GACP,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,OAAO;GACP,KAAK,EACH,kBAAkB,kBACpB;EACF;CACF;AACF,CAAC;AAED,IAAM,eAAe,OAAO,OAAO;CAEjC,SAAS;CACT,YAAY;CAEZ,UAAU;CACV,iBAAiB;CACjB,OAAO;CAEP,aAAa;EACX,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;EACP,eAAe;CACjB;CACA,YAAY;EACV,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;EACP,eAAe;CACjB;CAEA,mBAAmB;EACjB,aAAa,EACX,iBAAiB,gBACnB;EACA,YAAY;GACV,iBAAiB;GACjB,SAAS;EACX;CACF;CAEA,UAAU,EACR,WAAW;EACT,aAAa,EACX,iBAAiB,gBACnB;EACA,YAAY;GACV,iBAAiB;GACjB,SAAS;EACX;CACF,EACF;CAEA,UAAU;EACR,UAAU,EACR,MAAM;GACJ,SAAS;GACT,OAAO;GACP,UAAU,EACR,WAAW;IACT,aAAa,EACX,iBAAiB,UACnB;IACA,YAAY,EACV,iBAAiB,UACnB;GACF,EACF;EACF,EACF;EACA,OAAO,EACL,SAAS,EACP,UAAU,EACR,WAAW,EACT,YAAY,EACV,iBAAiB,sBACnB,EACF,EACF,EACF,EACF;EACA,MAAM;GACJ,OAAO;IACL,cAAc;IACd,uBAAuB,EACrB,cAAc,KAChB;GACF;GACA,QAAQ;IACN,cAAc;IACd,uBAAuB,EACrB,cAAc,KAChB;GACF;GACA,OAAO;IACL,cAAc;IACd,uBAAuB,EACrB,cAAc,KAChB;GACF;EACF;CACF;CACA,iBAAiB;EACf,MAAM;EACN,UAAU;CACZ;AACF,CAAC;AAED,IAAM,mBAAmB,OAAO,OAAO;CACrC,UAAU;CACV,KAAK;CACL,QAAQ;CACR,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,UAAU;EACR,MAAM;GACJ,OAAO,EACL,IAAI,eACN;GACA,QAAQ,EACN,IAAI,eACN;GACA,OAAO,EACL,IAAI,eACN;EACF;EACA,SAAS;GACP,OAAO,EACL,MAAM,EACR;GACA,KAAK,EACH,OAAO,EACT;EACF;CACF;CACA,iBAAiB,EACf,MAAM,SACR;AACF,CAAC;AAED,IAAM,wBAAwB,OAAO,kBAAkB,EACrD,MAAM,EACR,CAAC;AAED,IAAM,sBAAsB,OAAO,kBAAkB,EACnD,OAAO,EACT,CAAC;AAgBD,IAAa,QAAQ,MAAM,YACxB,EAAE,MAAM,gBAAgB,cAAc,KAAK,GAAG,SAAS,iBAAiB;CACvE,MAAM,WAAW,MAAM,OAAoB,IAAI;CAE/C,MAAM,oBACJ,oBACM;EACJ,MAAM,EAAE,YAAY;EACpB,IAAI,SACF,QAAQ,cAAc;GACpB,QAAQ,QAAQ;EAClB;EAEF,OAAO;CACT,GACA,CAAC,QAAQ,CACX;CAEA,MAAM,oBAAoB,MAAM,cAAc,QAAQ,cAAc,GAAG,CAAC,cAAc,CAAC;CAEvF,MAAM,kBAAkB,MAAM,cAAc,QAAQ,YAAY,GAAG,CAAC,YAAY,CAAC;CAEjF,OACE,qBAAC,cAAD;EAAmB;EAAK,UAAU,MAAM;EAAU,OAAO,MAAM;EAA/D,UAAA;GACG,qBACC,oBAAC,uBAAD;IAA6B;IAAO,UAAA;GAAsC,CAAA;GAG5E,oBAAC,aAAD;IACE,KAAK;IACL,gBAAgB;IAChB,cAAc;IACR;IACN,GAAI;GACL,CAAA;GACA,mBAAmB,oBAAC,qBAAD;IAA2B;IAAO,UAAA;GAAkC,CAAA;EAC5E;;AAElB,CACF"}
|
|
1
|
+
{"version":3,"file":"Input.js","names":[],"sources":["../../../components/Input/Input.tsx"],"sourcesContent":["import React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { elevationVariants } from '../Elevation';\nimport { useFieldControl } from '../Field/FieldContext';\n\n// CONSTANTS\nconst FOCUS_SHADOW = elevationVariants[1].boxShadow; // apply elevation $1 when focus\n\nconst SMALL_HEIGHT = '$5';\nconst MEDIUM_HEIGHT = '$6';\nconst LARGE_HEIGHT = '$7';\n\nconst StyledInput = styled('input', {\n // Reset\n appearance: 'none',\n borderWidth: '0',\n boxSizing: 'border-box',\n fontFamily: '$rubik',\n margin: '0',\n outline: 'none',\n padding: '0',\n width: '100%',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n // Custom\n position: 'relative',\n backgroundColor: 'transparent',\n borderRadius: 'inherit', // inherit border radius from InputWrapper\n boxShadow: 'inset 0 0 0 1px $colors$inputBorder',\n color: '$inputText',\n fontVariantNumeric: 'tabular-nums',\n transition: 'box-shadow .1s ease-in-out',\n\n '&[type=\"number\"]': {\n pr: '0', // remove padding for number native controls\n },\n\n '&:-webkit-autofill,&:autofill': {\n boxShadow: 'inset 0 0 0 1px $colors$inputBorder, inset 0 0 0 100px $colors$inputBg',\n WebkitTextFillColor: '$colors$hiContrast',\n },\n\n '&:-webkit-autofill::first-line,&:autofill::first-line': {\n fontFamily: '$rubik',\n color: '$hiContrast',\n },\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$inputFocusBorder, ${FOCUS_SHADOW}`,\n },\n\n '&:-webkit-autofill:focus-visible,&:autofill:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$inputFocusBorder, inset 0 0 0 100px $colors$inputBg, ${FOCUS_SHADOW}`,\n },\n\n '&::placeholder': {\n color: '$inputPlaceholder',\n },\n\n '&:read-only:not(:disabled)': {\n boxShadow: 'none',\n },\n\n '&:disabled': {\n pointerEvents: 'none',\n color: '$inputDisabledText',\n },\n\n variants: {\n size: {\n small: {\n height: SMALL_HEIGHT,\n fontSize: '$1',\n px: '$2',\n lineHeight: '$sizes$5',\n '&:-webkit-autofill::first-line,&:autofill::first-line': {\n fontSize: '$1',\n },\n },\n medium: {\n height: MEDIUM_HEIGHT,\n fontSize: '$3',\n px: '$3',\n lineHeight: '$sizes$6',\n '&:-webkit-autofill::first-line,&:autofill::first-line': {\n fontSize: '$3',\n },\n },\n large: {\n height: LARGE_HEIGHT,\n fontSize: '$3',\n px: '$3',\n lineHeight: '$sizes$7',\n '&:-webkit-autofill::first-line,&:autofill::first-line': {\n fontSize: '$3',\n },\n },\n },\n startAdornment: {\n true: {},\n },\n endAdornment: {\n true: {},\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n '&:disabled': {\n boxShadow: 'none',\n },\n backgroundColor: 'transparent',\n '&:focus-visible': {\n backgroundColor: '$loContrast',\n },\n },\n },\n state: {\n invalid: {\n boxShadow: 'inset 0 0 0 1px $colors$inputInvalidBorder',\n '&:-webkit-autofill,&:autofill': {\n boxShadow:\n 'inset 0 0 0 1px $colors$inputInvalidBorder, inset 0 0 0 100px $colors$inputBg',\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$inputInvalidBorder, ${FOCUS_SHADOW}`,\n },\n '&:-webkit-autofill:focus-visible,&:autofill:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$inputInvalidBorder, inset 0 0 0 100px $colors$inputBg, ${FOCUS_SHADOW}`,\n },\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '@hover': {\n '&:hover:not(:read-only)': {\n cursor: 'text',\n },\n },\n '&:focus-visible:not(:read-only)': {\n cursor: 'text',\n },\n },\n text: {\n cursor: 'text',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n cursor: 'default',\n },\n compoundVariants: [\n {\n variant: 'ghost',\n state: 'invalid',\n css: {\n boxShadow: 'inset 0 0 0 1px $colors$inputInvalidBorder',\n },\n },\n {\n startAdornment: true,\n size: 'small',\n css: {\n paddingInlineStart: 'calc($2 + 15px)',\n },\n },\n {\n startAdornment: true,\n size: 'medium',\n css: {\n paddingInlineStart: 'calc($3 + 15px)',\n },\n },\n {\n startAdornment: true,\n size: 'large',\n css: {\n paddingInlineStart: 'calc($3 + 15px)',\n },\n },\n {\n endAdornment: true,\n size: 'small',\n css: {\n paddingInlineEnd: 'calc($2 + 15px)',\n },\n },\n {\n endAdornment: true,\n size: 'medium',\n css: {\n paddingInlineEnd: 'calc($3 + 15px)',\n },\n },\n {\n endAdornment: true,\n size: 'large',\n css: {\n paddingInlineEnd: 'calc($3 + 15px)',\n },\n },\n {\n endAdornment: true,\n size: 'small',\n state: 'invalid',\n css: {\n paddingInlineEnd: 'calc($4 + 30px)', // size padding + adornment margins + icon size + icon size\n },\n },\n {\n endAdornment: true,\n size: 'medium',\n state: 'invalid',\n css: {\n paddingInlineEnd: 'calc($6 + 30px)', // size padding + adornment margins + icon size + icon size\n },\n },\n {\n endAdornment: true,\n size: 'large',\n state: 'invalid',\n css: {\n paddingInlineEnd: 'calc($6 + 30px)', // size padding + adornment margins + icon size + icon size\n },\n },\n ],\n});\n\nconst InputWrapper = styled('div', {\n // Reset\n outline: 'none',\n lineHeight: 0,\n\n position: 'relative',\n isolation: 'isolate',\n backgroundColor: '$inputBg',\n color: '$inputPlaceholder',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$inputFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n '&::before': {\n backgroundColor: '$inputHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n\n variants: {\n disabled: {\n true: {\n opacity: 0.7,\n color: '$inputDisabledText',\n '@hover': {\n '&:hover': {\n '&::before': {\n backgroundColor: 'inherit',\n },\n '&::after': {\n backgroundColor: 'inherit',\n },\n },\n },\n },\n },\n state: {\n invalid: {\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$inputInvalidBorder',\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: '$2',\n '&::before, &::after': {\n borderRadius: '$2',\n },\n },\n medium: {\n borderRadius: '$3',\n '&::before, &::after': {\n borderRadius: '$3',\n },\n },\n large: {\n borderRadius: '$3',\n '&::before, &::after': {\n borderRadius: '$3',\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n disabled: false,\n },\n});\n\nconst AdornmentWrapper = styled('div', {\n position: 'absolute',\n top: 0,\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n variants: {\n size: {\n small: {\n mx: 'calc($2 / 2)',\n },\n medium: {\n mx: 'calc($3 / 2)',\n },\n large: {\n mx: 'calc($3 / 2)',\n },\n },\n variant: {\n start: {\n left: 0,\n },\n end: {\n right: 0,\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nconst AdornmentWrapperStart = styled(AdornmentWrapper, {\n left: 0,\n zIndex: 1,\n pointerEvents: 'none',\n});\n\nconst AdornmentWrapperEnd = styled(AdornmentWrapper, {\n right: 0,\n});\n\ntype DefaultInputVariants = VariantProps<typeof StyledInput>;\nexport type InputVariants = Omit<DefaultInputVariants, 'startAdornment' | 'endAdornment'>;\nexport interface HTMLInputProps extends React.InputHTMLAttributes<any> {\n startAdornment?: React.ReactNode;\n endAdornment?: React.ReactNode;\n type?: string;\n}\n\nexport type InputProps = Omit<HTMLInputProps, 'size'> & InputVariants & { css?: CSS };\n\nexport interface InputHandle extends HTMLInputElement {\n clear: () => void;\n}\n\nexport const Input = React.forwardRef<InputHandle, InputProps>(\n (\n {\n size,\n startAdornment,\n endAdornment,\n css,\n state,\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputHandle>(null);\n const control = useFieldControl({\n id,\n disabled,\n invalid: state === 'invalid',\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n const resolvedState = control.invalid ? 'invalid' : state;\n\n React.useImperativeHandle(forwardedRef, () => {\n const { current } = inputRef;\n if (current) {\n current.clear = () => {\n current.value = '';\n };\n }\n return current as InputHandle;\n }, [inputRef]);\n\n const hasStartAdornment = React.useMemo(() => Boolean(startAdornment), [startAdornment]);\n\n const hasEndAdornment = React.useMemo(() => Boolean(endAdornment), [endAdornment]);\n\n return (\n <InputWrapper css={css} disabled={control.disabled} state={resolvedState}>\n {hasStartAdornment && (\n <AdornmentWrapperStart size={size}>{startAdornment}</AdornmentWrapperStart>\n )}\n\n <StyledInput\n ref={inputRef}\n startAdornment={hasStartAdornment}\n endAdornment={hasEndAdornment}\n size={size}\n state={resolvedState}\n id={control.id}\n disabled={control.disabled}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n {...props}\n />\n {hasEndAdornment && <AdornmentWrapperEnd size={size}>{endAdornment}</AdornmentWrapperEnd>}\n </InputWrapper>\n );\n },\n);\n"],"mappings":";;;;;;AAOA,IAAM,eAAe,kBAAkB,EAAE,CAAC;AAM1C,IAAM,cAAc,OAAO,SAAS;CAElC,YAAY;CACZ,aAAa;CACb,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;CACP,yBAAyB;CAGzB,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,WAAW;CACX,OAAO;CACP,oBAAoB;CACpB,YAAY;CAEZ,sBAAoB,EAClB,IAAI,IACN;CAEA,iCAAiC;EAC/B,WAAW;EACX,qBAAqB;CACvB;CAEA,yDAAyD;EACvD,YAAY;EACZ,OAAO;CACT;CAEA,mBAAmB,EACjB,WAAW,6CAA6C,eAC1D;CAEA,6DAA6D,EAC3D,WAAW,gFAAgF,eAC7F;CAEA,kBAAkB,EAChB,OAAO,oBACT;CAEA,8BAA8B,EAC5B,WAAW,OACb;CAEA,cAAc;EACZ,eAAe;EACf,OAAO;CACT;CAEA,UAAU;EACR,MAAM;GACJ,OAAO;IACL,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,yDAAyD,EACvD,UAAU,KACZ;GACF;GACA,QAAQ;IACN,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,yDAAyD,EACvD,UAAU,KACZ;GACF;GACA,OAAO;IACL,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,yDAAyD,EACvD,UAAU,KACZ;GACF;EACF;EACA,gBAAgB,EACd,MAAM,CAAC,EACT;EACA,cAAc,EACZ,MAAM,CAAC,EACT;EACA,SAAS,EACP,OAAO;GACL,WAAW;GACX,cAAc,EACZ,WAAW,OACb;GACA,iBAAiB;GACjB,mBAAmB,EACjB,iBAAiB,cACnB;EACF,EACF;EACA,OAAO,EACL,SAAS;GACP,WAAW;GACX,iCAAiC,EAC/B,WACE,gFACJ;GACA,mBAAmB,EACjB,WAAW,+CAA+C,eAC5D;GACA,6DAA6D,EAC3D,WAAW,kFAAkF,eAC/F;EACF,EACF;EACA,QAAQ;GACN,SAAS;IACP,QAAQ;IACR,UAAU,EACR,2BAA2B,EACzB,QAAQ,OACV,EACF;IACA,mCAAmC,EACjC,QAAQ,OACV;GACF;GACA,MAAM,EACJ,QAAQ,OACV;EACF;CACF;CACA,iBAAiB;EACf,MAAM;EACN,QAAQ;CACV;CACA,kBAAkB;EAChB;GACE,SAAS;GACT,OAAO;GACP,KAAK,EACH,WAAW,6CACb;EACF;EACA;GACE,gBAAgB;GAChB,MAAM;GACN,KAAK,EACH,oBAAoB,kBACtB;EACF;EACA;GACE,gBAAgB;GAChB,MAAM;GACN,KAAK,EACH,oBAAoB,kBACtB;EACF;EACA;GACE,gBAAgB;GAChB,MAAM;GACN,KAAK,EACH,oBAAoB,kBACtB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,OAAO;GACP,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,OAAO;GACP,KAAK,EACH,kBAAkB,kBACpB;EACF;EACA;GACE,cAAc;GACd,MAAM;GACN,OAAO;GACP,KAAK,EACH,kBAAkB,kBACpB;EACF;CACF;AACF,CAAC;AAED,IAAM,eAAe,OAAO,OAAO;CAEjC,SAAS;CACT,YAAY;CAEZ,UAAU;CACV,WAAW;CACX,iBAAiB;CACjB,OAAO;CAEP,aAAa;EACX,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;EACP,eAAe;CACjB;CACA,YAAY;EACV,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;EACP,eAAe;CACjB;CAEA,mBAAmB;EACjB,aAAa,EACX,iBAAiB,gBACnB;EACA,YAAY;GACV,iBAAiB;GACjB,SAAS;EACX;CACF;CAEA,UAAU,EACR,WAAW;EACT,aAAa,EACX,iBAAiB,gBACnB;EACA,YAAY;GACV,iBAAiB;GACjB,SAAS;EACX;CACF,EACF;CAEA,UAAU;EACR,UAAU,EACR,MAAM;GACJ,SAAS;GACT,OAAO;GACP,UAAU,EACR,WAAW;IACT,aAAa,EACX,iBAAiB,UACnB;IACA,YAAY,EACV,iBAAiB,UACnB;GACF,EACF;EACF,EACF;EACA,OAAO,EACL,SAAS,EACP,UAAU,EACR,WAAW,EACT,YAAY,EACV,iBAAiB,sBACnB,EACF,EACF,EACF,EACF;EACA,MAAM;GACJ,OAAO;IACL,cAAc;IACd,uBAAuB,EACrB,cAAc,KAChB;GACF;GACA,QAAQ;IACN,cAAc;IACd,uBAAuB,EACrB,cAAc,KAChB;GACF;GACA,OAAO;IACL,cAAc;IACd,uBAAuB,EACrB,cAAc,KAChB;GACF;EACF;CACF;CACA,iBAAiB;EACf,MAAM;EACN,UAAU;CACZ;AACF,CAAC;AAED,IAAM,mBAAmB,OAAO,OAAO;CACrC,UAAU;CACV,KAAK;CACL,QAAQ;CACR,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,UAAU;EACR,MAAM;GACJ,OAAO,EACL,IAAI,eACN;GACA,QAAQ,EACN,IAAI,eACN;GACA,OAAO,EACL,IAAI,eACN;EACF;EACA,SAAS;GACP,OAAO,EACL,MAAM,EACR;GACA,KAAK,EACH,OAAO,EACT;EACF;CACF;CACA,iBAAiB,EACf,MAAM,SACR;AACF,CAAC;AAED,IAAM,wBAAwB,OAAO,kBAAkB;CACrD,MAAM;CACN,QAAQ;CACR,eAAe;AACjB,CAAC;AAED,IAAM,sBAAsB,OAAO,kBAAkB,EACnD,OAAO,EACT,CAAC;AAgBD,IAAa,QAAQ,MAAM,YAEvB,EACE,MACA,gBACA,cACA,KACA,OACA,IACA,UACA,oBAAoB,iBACpB,gBAAgB,aAChB,GAAG,SAEL,iBACG;CACH,MAAM,WAAW,MAAM,OAAoB,IAAI;CAC/C,MAAM,UAAU,gBAAgB;EAC9B;EACA;EACA,SAAS,UAAU;EACnB,oBAAoB;EACpB,gBAAgB;CAClB,CAAC;CACD,MAAM,gBAAgB,QAAQ,UAAU,YAAY;CAEpD,MAAM,oBAAoB,oBAAoB;EAC5C,MAAM,EAAE,YAAY;EACpB,IAAI,SACF,QAAQ,cAAc;GACpB,QAAQ,QAAQ;EAClB;EAEF,OAAO;CACT,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,oBAAoB,MAAM,cAAc,QAAQ,cAAc,GAAG,CAAC,cAAc,CAAC;CAEvF,MAAM,kBAAkB,MAAM,cAAc,QAAQ,YAAY,GAAG,CAAC,YAAY,CAAC;CAEjF,OACE,qBAAC,cAAD;EAAmB;EAAK,UAAU,QAAQ;EAAU,OAAO;EAA3D,UAAA;GACG,qBACC,oBAAC,uBAAD;IAA6B;IAAO,UAAA;GAAsC,CAAA;GAG5E,oBAAC,aAAD;IACE,KAAK;IACL,gBAAgB;IAChB,cAAc;IACR;IACN,OAAO;IACP,IAAI,QAAQ;IACZ,UAAU,QAAQ;IAClB,oBAAkB,QAAQ;IAC1B,gBAAc,QAAQ;IACtB,GAAI;GACL,CAAA;GACA,mBAAmB,oBAAC,qBAAD;IAA2B;IAAO,UAAA;GAAkC,CAAA;EAC5E;;AAElB,CACF"}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
3
3
|
const require_themeContext = require("../../styles/themeContext.cjs");
|
|
4
|
+
const require_FieldContext = require("../Field/FieldContext.cjs");
|
|
4
5
|
const require_Input_vanilla_css = require("./Input.vanilla.css.cjs");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
react = require_runtime.__toESM(react, 1);
|
|
7
8
|
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
8
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
10
|
// components/Input/Input.vanilla.tsx
|
|
10
|
-
var InputVanilla = react.default.forwardRef(({ size, startAdornment, endAdornment, css, variant, state, cursor, className, style, ...props }, forwardedRef) => {
|
|
11
|
+
var InputVanilla = react.default.forwardRef(({ size, startAdornment, endAdornment, css, variant, state, cursor, className, style, id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }, forwardedRef) => {
|
|
11
12
|
const inputRef = react.default.useRef(null);
|
|
13
|
+
const control = require_FieldContext.useFieldControl({
|
|
14
|
+
id,
|
|
15
|
+
disabled,
|
|
16
|
+
invalid: state === "invalid",
|
|
17
|
+
"aria-describedby": ariaDescribedBy,
|
|
18
|
+
"aria-invalid": ariaInvalid
|
|
19
|
+
});
|
|
20
|
+
const resolvedState = control.invalid ? "invalid" : state;
|
|
12
21
|
const { colors } = require_themeContext.useVanillaExtractTheme();
|
|
13
22
|
const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
|
|
14
23
|
const mergedStyles = {
|
|
@@ -26,14 +35,14 @@ var InputVanilla = react.default.forwardRef(({ size, startAdornment, endAdornmen
|
|
|
26
35
|
const hasStartAdornment = react.default.useMemo(() => Boolean(startAdornment), [startAdornment]);
|
|
27
36
|
const hasEndAdornment = react.default.useMemo(() => Boolean(endAdornment), [endAdornment]);
|
|
28
37
|
const inputWrapperClass = require_Input_vanilla_css.inputWrapperRecipe({
|
|
29
|
-
disabled:
|
|
30
|
-
state,
|
|
38
|
+
disabled: control.disabled,
|
|
39
|
+
state: resolvedState,
|
|
31
40
|
size
|
|
32
41
|
});
|
|
33
42
|
const styledInputClass = require_Input_vanilla_css.styledInputRecipe({
|
|
34
43
|
size,
|
|
35
44
|
variant,
|
|
36
|
-
state,
|
|
45
|
+
state: resolvedState,
|
|
37
46
|
cursor,
|
|
38
47
|
startAdornment: hasStartAdornment,
|
|
39
48
|
endAdornment: hasEndAdornment
|
|
@@ -57,6 +66,10 @@ var InputVanilla = react.default.forwardRef(({ size, startAdornment, endAdornmen
|
|
|
57
66
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
58
67
|
ref: inputRef,
|
|
59
68
|
className: styledInputClass,
|
|
69
|
+
id: control.id,
|
|
70
|
+
disabled: control.disabled,
|
|
71
|
+
"aria-describedby": control["aria-describedby"],
|
|
72
|
+
"aria-invalid": control["aria-invalid"],
|
|
60
73
|
...props
|
|
61
74
|
}),
|
|
62
75
|
hasEndAdornment && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.vanilla.cjs","names":["React","useVanillaExtractTheme","processCSSProp","assignInlineVars","inputWrapperRecipe","styledInputRecipe","adornmentWrapperRecipe"],"sources":["../../../components/Input/Input.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { RecipeVariants } from '@vanilla-extract/recipes';\nimport React from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { adornmentWrapperRecipe, inputWrapperRecipe, styledInputRecipe } from './Input.vanilla.css';\n\ntype StyledInputRecipeVariants = NonNullable<RecipeVariants<typeof styledInputRecipe>>;\n\nexport interface InputVanillaOwnProps extends CSSProps {\n size?: StyledInputRecipeVariants['size'];\n variant?: StyledInputRecipeVariants['variant'];\n state?: StyledInputRecipeVariants['state'];\n cursor?: StyledInputRecipeVariants['cursor'];\n startAdornment?: React.ReactNode;\n endAdornment?: React.ReactNode;\n type?: string;\n}\n\nexport type InputVanillaProps = Omit<React.InputHTMLAttributes<any>, 'size'> & InputVanillaOwnProps;\n\nexport interface InputVanillaHandle extends HTMLInputElement {\n clear: () => void;\n}\n\nexport const InputVanilla = React.forwardRef<InputVanillaHandle, InputVanillaProps>(\n (\n {
|
|
1
|
+
{"version":3,"file":"Input.vanilla.cjs","names":["React","useFieldControl","useVanillaExtractTheme","processCSSProp","assignInlineVars","inputWrapperRecipe","styledInputRecipe","adornmentWrapperRecipe"],"sources":["../../../components/Input/Input.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { RecipeVariants } from '@vanilla-extract/recipes';\nimport React from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { useFieldControl } from '../Field/FieldContext';\nimport { adornmentWrapperRecipe, inputWrapperRecipe, styledInputRecipe } from './Input.vanilla.css';\n\ntype StyledInputRecipeVariants = NonNullable<RecipeVariants<typeof styledInputRecipe>>;\n\nexport interface InputVanillaOwnProps extends CSSProps {\n size?: StyledInputRecipeVariants['size'];\n variant?: StyledInputRecipeVariants['variant'];\n state?: StyledInputRecipeVariants['state'];\n cursor?: StyledInputRecipeVariants['cursor'];\n startAdornment?: React.ReactNode;\n endAdornment?: React.ReactNode;\n type?: string;\n}\n\nexport type InputVanillaProps = Omit<React.InputHTMLAttributes<any>, 'size'> & InputVanillaOwnProps;\n\nexport interface InputVanillaHandle extends HTMLInputElement {\n clear: () => void;\n}\n\nexport const InputVanilla = React.forwardRef<InputVanillaHandle, InputVanillaProps>(\n (\n {\n size,\n startAdornment,\n endAdornment,\n css,\n variant,\n state,\n cursor,\n className,\n style,\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputVanillaHandle>(null);\n const control = useFieldControl({\n id,\n disabled,\n invalid: state === 'invalid',\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n const resolvedState = control.invalid ? 'invalid' : state;\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const mergedStyles = { ...cssStyles, ...style, ...assignInlineVars(vars) };\n\n React.useImperativeHandle(forwardedRef, () => {\n const { current } = inputRef;\n if (current) {\n current.clear = () => {\n current.value = '';\n };\n }\n return current as InputVanillaHandle;\n }, [inputRef]);\n\n const hasStartAdornment = React.useMemo(() => Boolean(startAdornment), [startAdornment]);\n const hasEndAdornment = React.useMemo(() => Boolean(endAdornment), [endAdornment]);\n\n const inputWrapperClass = inputWrapperRecipe({\n disabled: control.disabled,\n state: resolvedState,\n size,\n });\n\n const styledInputClass = styledInputRecipe({\n size,\n variant,\n state: resolvedState,\n cursor,\n startAdornment: hasStartAdornment,\n endAdornment: hasEndAdornment,\n });\n\n const adornmentWrapperStartClass = adornmentWrapperRecipe({\n size,\n variant: 'start',\n });\n\n const adornmentWrapperEndClass = adornmentWrapperRecipe({\n size,\n variant: 'end',\n });\n\n return (\n <div className={`${inputWrapperClass} ${className || ''}`.trim()} style={mergedStyles}>\n {hasStartAdornment && <div className={adornmentWrapperStartClass}>{startAdornment}</div>}\n\n <input\n ref={inputRef}\n className={styledInputClass}\n id={control.id}\n disabled={control.disabled}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n {...props}\n />\n\n {hasEndAdornment && <div className={adornmentWrapperEndClass}>{endAdornment}</div>}\n </div>\n );\n },\n);\n\nInputVanilla.displayName = 'InputVanilla';\n"],"mappings":";;;;;;;;;;AA2BA,IAAa,eAAeA,MAAAA,QAAM,YAE9B,EACE,MACA,gBACA,cACA,KACA,SACA,OACA,QACA,WACA,OACA,IACA,UACA,oBAAoB,iBACpB,gBAAgB,aAChB,GAAG,SAEL,iBACG;CACH,MAAM,WAAWA,MAAAA,QAAM,OAA2B,IAAI;CACtD,MAAM,UAAUC,qBAAAA,gBAAgB;EAC9B;EACA;EACA,SAAS,UAAU;EACnB,oBAAoB;EACpB,gBAAgB;CAClB,CAAC;CACD,MAAM,gBAAgB,QAAQ,UAAU,YAAY;CACpD,MAAM,EAAE,WAAWC,qBAAAA,uBAAuB;CAC1C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAC7D,MAAM,eAAe;EAAE,GAAG;EAAW,GAAG;EAAO,IAAA,GAAGC,yBAAAA,iBAAAA,CAAiB,IAAI;CAAE;CAEzE,MAAA,QAAM,oBAAoB,oBAAoB;EAC5C,MAAM,EAAE,YAAY;EACpB,IAAI,SACF,QAAQ,cAAc;GACpB,QAAQ,QAAQ;EAClB;EAEF,OAAO;CACT,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,oBAAoBJ,MAAAA,QAAM,cAAc,QAAQ,cAAc,GAAG,CAAC,cAAc,CAAC;CACvF,MAAM,kBAAkBA,MAAAA,QAAM,cAAc,QAAQ,YAAY,GAAG,CAAC,YAAY,CAAC;CAEjF,MAAM,oBAAoBK,0BAAAA,mBAAmB;EAC3C,UAAU,QAAQ;EAClB,OAAO;EACP;CACF,CAAC;CAED,MAAM,mBAAmBC,0BAAAA,kBAAkB;EACzC;EACA;EACA,OAAO;EACP;EACA,gBAAgB;EAChB,cAAc;CAChB,CAAC;CAED,MAAM,6BAA6BC,0BAAAA,uBAAuB;EACxD;EACA,SAAS;CACX,CAAC;CAED,MAAM,2BAA2BA,0BAAAA,uBAAuB;EACtD;EACA,SAAS;CACX,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAW,GAAG,kBAAkB,GAAG,aAAa,KAAK,KAAK;EAAG,OAAO;EAAzE,UAAA;GACG,qBAAqB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,WAAW;IAA6B,UAAA;GAAoB,CAAA;GAEvF,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;IACE,KAAK;IACL,WAAW;IACX,IAAI,QAAQ;IACZ,UAAU,QAAQ;IAClB,oBAAkB,QAAQ;IAC1B,gBAAc,QAAQ;IACtB,GAAI;GACL,CAAA;GAEA,mBAAmB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,WAAW;IAA2B,UAAA;GAAkB,CAAA;EAC9E;;AAET,CACF;AAEA,aAAa,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.vanilla.css.cjs","names":["_7a468"],"sources":["../../../components/Input/Input.vanilla.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\nimport { recipe } from '@vanilla-extract/recipes';\n\nimport { breakpoints } from '../../styles/breakpoints.css';\nimport { tokens } from '../../styles/tokens.css';\n\n// CONSTANTS\nconst FOCUS_SHADOW =\n '0 1px 5px 0 hsla(0, 0%, 0%, 0.2), 0 3px 1px -2px hsla(0, 0%, 0%, 0.12), 0 2px 2px 0 hsla(0, 0%, 0%, 0.14)';\n\nconst SMALL_HEIGHT = tokens.sizes['5'];\nconst MEDIUM_HEIGHT = tokens.sizes['6'];\nconst LARGE_HEIGHT = tokens.sizes['7'];\n\nconst styledInputBase = style({\n // Reset\n appearance: 'none',\n borderWidth: '0',\n boxSizing: 'border-box',\n fontFamily: tokens.fonts.rubik,\n margin: '0',\n outline: 'none',\n padding: '0',\n width: '100%',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n // Custom\n position: 'relative',\n backgroundColor: 'transparent',\n borderRadius: 'inherit', // inherit border radius from InputWrapper\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputBorder}`,\n color: tokens.colors.inputText,\n fontVariantNumeric: 'tabular-nums',\n transition: 'box-shadow .1s ease-in-out',\n\n selectors: {\n '&[type=\"number\"]': {\n paddingRight: '0', // remove padding for number native controls\n },\n '&:-webkit-autofill, &:autofill': {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}`,\n },\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontFamily: tokens.fonts.rubik,\n color: tokens.colors.hiContrast,\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputFocusBorder}, ${FOCUS_SHADOW}`,\n },\n '&::placeholder': {\n color: tokens.colors.inputPlaceholder,\n },\n '&:read-only:not(:disabled)': {\n boxShadow: 'none',\n },\n '&:disabled': {\n pointerEvents: 'none',\n color: tokens.colors.inputDisabledText,\n },\n },\n});\n\nexport const styledInputRecipe = recipe({\n base: styledInputBase,\n variants: {\n size: {\n small: {\n height: SMALL_HEIGHT,\n fontSize: tokens.fontSizes['1'],\n paddingLeft: tokens.space['2'],\n paddingRight: tokens.space['2'],\n lineHeight: tokens.sizes['5'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['1'],\n },\n },\n },\n medium: {\n height: MEDIUM_HEIGHT,\n fontSize: tokens.fontSizes['3'],\n paddingLeft: tokens.space['3'],\n paddingRight: tokens.space['3'],\n lineHeight: tokens.sizes['6'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['3'],\n },\n },\n },\n large: {\n height: LARGE_HEIGHT,\n fontSize: tokens.fontSizes['3'],\n paddingLeft: tokens.space['3'],\n paddingRight: tokens.space['3'],\n lineHeight: tokens.sizes['7'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['3'],\n },\n },\n },\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n backgroundColor: 'transparent',\n selectors: {\n '&:disabled': {\n boxShadow: 'none',\n },\n '&:focus-visible': {\n backgroundColor: tokens.colors.loContrast,\n },\n },\n },\n },\n state: {\n invalid: {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}`,\n selectors: {\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputInvalidBorder}, ${FOCUS_SHADOW}`,\n },\n },\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover:not(:read-only)': {\n cursor: 'text',\n },\n },\n },\n },\n selectors: {\n '&:focus-visible:not(:read-only)': {\n cursor: 'text',\n },\n },\n },\n text: {\n cursor: 'text',\n },\n },\n startAdornment: {\n true: {},\n },\n endAdornment: {\n true: {},\n },\n },\n compoundVariants: [\n {\n variants: {\n variant: 'ghost',\n state: 'invalid',\n },\n style: {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}`,\n },\n },\n // startAdornment compound variants\n {\n variants: {\n startAdornment: true,\n size: 'small',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['2']} + 15px)`,\n },\n },\n {\n variants: {\n startAdornment: true,\n size: 'medium',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n {\n variants: {\n startAdornment: true,\n size: 'large',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n // endAdornment compound variants\n {\n variants: {\n endAdornment: true,\n size: 'small',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['2']} + 15px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'medium',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'large',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n // endAdornment + invalid compound variants\n {\n variants: {\n endAdornment: true,\n size: 'small',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['4']} + 30px)`, // size padding + adornment margins + icon size + icon size\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'medium',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['6']} + 30px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'large',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['6']} + 30px)`,\n },\n },\n ],\n defaultVariants: {\n size: 'medium',\n cursor: 'default',\n },\n});\n\nconst inputWrapperBase = style({\n // Reset\n outline: 'none',\n lineHeight: 0,\n\n position: 'relative',\n backgroundColor: tokens.colors.inputBg,\n color: tokens.colors.inputPlaceholder,\n\n selectors: {\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: '0',\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: '0',\n pointerEvents: 'none',\n },\n '&:focus-visible::before': {\n backgroundColor: tokens.colors.inputFocusBg,\n },\n '&:focus-visible::after': {\n backgroundColor: tokens.colors.primary,\n opacity: '0.15',\n },\n },\n\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::before': {\n backgroundColor: tokens.colors.inputHoverBg,\n },\n '&:hover::after': {\n backgroundColor: tokens.colors.primary,\n opacity: '0.05',\n },\n },\n },\n },\n});\n\nexport const inputWrapperRecipe = recipe({\n base: inputWrapperBase,\n variants: {\n disabled: {\n true: {\n opacity: '0.7',\n color: tokens.colors.inputDisabledText,\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::before': {\n backgroundColor: 'inherit',\n },\n '&:hover::after': {\n backgroundColor: 'inherit',\n },\n },\n },\n },\n },\n },\n state: {\n invalid: {\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::after': {\n backgroundColor: tokens.colors.inputInvalidBorder,\n },\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: tokens.radii['2'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['2'],\n },\n },\n },\n medium: {\n borderRadius: tokens.radii['3'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['3'],\n },\n },\n },\n large: {\n borderRadius: tokens.radii['3'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['3'],\n },\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n disabled: false,\n },\n});\n\nconst adornmentWrapperBase = style({\n position: 'absolute',\n top: '0',\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n});\n\nexport const adornmentWrapperRecipe = recipe({\n base: adornmentWrapperBase,\n variants: {\n size: {\n small: {\n marginLeft: `calc(${tokens.space['2']} / 2)`,\n marginRight: `calc(${tokens.space['2']} / 2)`,\n },\n medium: {\n marginLeft: `calc(${tokens.space['3']} / 2)`,\n marginRight: `calc(${tokens.space['3']} / 2)`,\n },\n large: {\n marginLeft: `calc(${tokens.space['3']} / 2)`,\n marginRight: `calc(${tokens.space['3']} / 2)`,\n },\n },\n variant: {\n start: {\n left: '0',\n },\n end: {\n right: '0',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Input.vanilla.css.cjs","names":["_7a468"],"sources":["../../../components/Input/Input.vanilla.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\nimport { recipe } from '@vanilla-extract/recipes';\n\nimport { breakpoints } from '../../styles/breakpoints.css';\nimport { tokens } from '../../styles/tokens.css';\n\n// CONSTANTS\nconst FOCUS_SHADOW =\n '0 1px 5px 0 hsla(0, 0%, 0%, 0.2), 0 3px 1px -2px hsla(0, 0%, 0%, 0.12), 0 2px 2px 0 hsla(0, 0%, 0%, 0.14)';\n\nconst SMALL_HEIGHT = tokens.sizes['5'];\nconst MEDIUM_HEIGHT = tokens.sizes['6'];\nconst LARGE_HEIGHT = tokens.sizes['7'];\n\nconst styledInputBase = style({\n // Reset\n appearance: 'none',\n borderWidth: '0',\n boxSizing: 'border-box',\n fontFamily: tokens.fonts.rubik,\n margin: '0',\n outline: 'none',\n padding: '0',\n width: '100%',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n // Custom\n position: 'relative',\n backgroundColor: 'transparent',\n borderRadius: 'inherit', // inherit border radius from InputWrapper\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputBorder}`,\n color: tokens.colors.inputText,\n fontVariantNumeric: 'tabular-nums',\n transition: 'box-shadow .1s ease-in-out',\n\n selectors: {\n '&[type=\"number\"]': {\n paddingRight: '0', // remove padding for number native controls\n },\n '&:-webkit-autofill, &:autofill': {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}`,\n WebkitTextFillColor: tokens.colors.hiContrast,\n },\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontFamily: tokens.fonts.rubik,\n color: tokens.colors.hiContrast,\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputFocusBorder}, ${FOCUS_SHADOW}`,\n },\n '&:-webkit-autofill:focus-visible, &:autofill:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputFocusBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}, ${FOCUS_SHADOW}`,\n },\n '&::placeholder': {\n color: tokens.colors.inputPlaceholder,\n },\n '&:read-only:not(:disabled)': {\n boxShadow: 'none',\n },\n '&:disabled': {\n pointerEvents: 'none',\n color: tokens.colors.inputDisabledText,\n },\n },\n});\n\nexport const styledInputRecipe = recipe({\n base: styledInputBase,\n variants: {\n size: {\n small: {\n height: SMALL_HEIGHT,\n fontSize: tokens.fontSizes['1'],\n paddingLeft: tokens.space['2'],\n paddingRight: tokens.space['2'],\n lineHeight: tokens.sizes['5'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['1'],\n },\n },\n },\n medium: {\n height: MEDIUM_HEIGHT,\n fontSize: tokens.fontSizes['3'],\n paddingLeft: tokens.space['3'],\n paddingRight: tokens.space['3'],\n lineHeight: tokens.sizes['6'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['3'],\n },\n },\n },\n large: {\n height: LARGE_HEIGHT,\n fontSize: tokens.fontSizes['3'],\n paddingLeft: tokens.space['3'],\n paddingRight: tokens.space['3'],\n lineHeight: tokens.sizes['7'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['3'],\n },\n },\n },\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n backgroundColor: 'transparent',\n selectors: {\n '&:disabled': {\n boxShadow: 'none',\n },\n '&:focus-visible': {\n backgroundColor: tokens.colors.loContrast,\n },\n },\n },\n },\n state: {\n invalid: {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}`,\n selectors: {\n '&:-webkit-autofill, &:autofill': {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}`,\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputInvalidBorder}, ${FOCUS_SHADOW}`,\n },\n '&:-webkit-autofill:focus-visible, &:autofill:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputInvalidBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}, ${FOCUS_SHADOW}`,\n },\n },\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover:not(:read-only)': {\n cursor: 'text',\n },\n },\n },\n },\n selectors: {\n '&:focus-visible:not(:read-only)': {\n cursor: 'text',\n },\n },\n },\n text: {\n cursor: 'text',\n },\n },\n startAdornment: {\n true: {},\n },\n endAdornment: {\n true: {},\n },\n },\n compoundVariants: [\n {\n variants: {\n variant: 'ghost',\n state: 'invalid',\n },\n style: {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}`,\n },\n },\n // startAdornment compound variants\n {\n variants: {\n startAdornment: true,\n size: 'small',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['2']} + 15px)`,\n },\n },\n {\n variants: {\n startAdornment: true,\n size: 'medium',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n {\n variants: {\n startAdornment: true,\n size: 'large',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n // endAdornment compound variants\n {\n variants: {\n endAdornment: true,\n size: 'small',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['2']} + 15px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'medium',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'large',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n // endAdornment + invalid compound variants\n {\n variants: {\n endAdornment: true,\n size: 'small',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['4']} + 30px)`, // size padding + adornment margins + icon size + icon size\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'medium',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['6']} + 30px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'large',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['6']} + 30px)`,\n },\n },\n ],\n defaultVariants: {\n size: 'medium',\n cursor: 'default',\n },\n});\n\nconst inputWrapperBase = style({\n // Reset\n outline: 'none',\n lineHeight: 0,\n\n position: 'relative',\n isolation: 'isolate',\n backgroundColor: tokens.colors.inputBg,\n color: tokens.colors.inputPlaceholder,\n\n selectors: {\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: '0',\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: '0',\n pointerEvents: 'none',\n },\n '&:focus-visible::before': {\n backgroundColor: tokens.colors.inputFocusBg,\n },\n '&:focus-visible::after': {\n backgroundColor: tokens.colors.primary,\n opacity: '0.15',\n },\n },\n\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::before': {\n backgroundColor: tokens.colors.inputHoverBg,\n },\n '&:hover::after': {\n backgroundColor: tokens.colors.primary,\n opacity: '0.05',\n },\n },\n },\n },\n});\n\nexport const inputWrapperRecipe = recipe({\n base: inputWrapperBase,\n variants: {\n disabled: {\n true: {\n opacity: '0.7',\n color: tokens.colors.inputDisabledText,\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::before': {\n backgroundColor: 'inherit',\n },\n '&:hover::after': {\n backgroundColor: 'inherit',\n },\n },\n },\n },\n },\n },\n state: {\n invalid: {\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::after': {\n backgroundColor: tokens.colors.inputInvalidBorder,\n },\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: tokens.radii['2'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['2'],\n },\n },\n },\n medium: {\n borderRadius: tokens.radii['3'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['3'],\n },\n },\n },\n large: {\n borderRadius: tokens.radii['3'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['3'],\n },\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n disabled: false,\n },\n});\n\nconst adornmentWrapperBase = style({\n position: 'absolute',\n top: '0',\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n});\n\nexport const adornmentWrapperRecipe = recipe({\n base: adornmentWrapperBase,\n variants: {\n size: {\n small: {\n marginLeft: `calc(${tokens.space['2']} / 2)`,\n marginRight: `calc(${tokens.space['2']} / 2)`,\n },\n medium: {\n marginLeft: `calc(${tokens.space['3']} / 2)`,\n marginRight: `calc(${tokens.space['3']} / 2)`,\n },\n large: {\n marginLeft: `calc(${tokens.space['3']} / 2)`,\n marginRight: `calc(${tokens.space['3']} / 2)`,\n },\n },\n variant: {\n start: {\n left: '0',\n zIndex: 1,\n pointerEvents: 'none',\n },\n end: {\n right: '0',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.vanilla.css.js","names":["_7a468"],"sources":["../../../components/Input/Input.vanilla.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\nimport { recipe } from '@vanilla-extract/recipes';\n\nimport { breakpoints } from '../../styles/breakpoints.css';\nimport { tokens } from '../../styles/tokens.css';\n\n// CONSTANTS\nconst FOCUS_SHADOW =\n '0 1px 5px 0 hsla(0, 0%, 0%, 0.2), 0 3px 1px -2px hsla(0, 0%, 0%, 0.12), 0 2px 2px 0 hsla(0, 0%, 0%, 0.14)';\n\nconst SMALL_HEIGHT = tokens.sizes['5'];\nconst MEDIUM_HEIGHT = tokens.sizes['6'];\nconst LARGE_HEIGHT = tokens.sizes['7'];\n\nconst styledInputBase = style({\n // Reset\n appearance: 'none',\n borderWidth: '0',\n boxSizing: 'border-box',\n fontFamily: tokens.fonts.rubik,\n margin: '0',\n outline: 'none',\n padding: '0',\n width: '100%',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n // Custom\n position: 'relative',\n backgroundColor: 'transparent',\n borderRadius: 'inherit', // inherit border radius from InputWrapper\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputBorder}`,\n color: tokens.colors.inputText,\n fontVariantNumeric: 'tabular-nums',\n transition: 'box-shadow .1s ease-in-out',\n\n selectors: {\n '&[type=\"number\"]': {\n paddingRight: '0', // remove padding for number native controls\n },\n '&:-webkit-autofill, &:autofill': {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}`,\n },\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontFamily: tokens.fonts.rubik,\n color: tokens.colors.hiContrast,\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputFocusBorder}, ${FOCUS_SHADOW}`,\n },\n '&::placeholder': {\n color: tokens.colors.inputPlaceholder,\n },\n '&:read-only:not(:disabled)': {\n boxShadow: 'none',\n },\n '&:disabled': {\n pointerEvents: 'none',\n color: tokens.colors.inputDisabledText,\n },\n },\n});\n\nexport const styledInputRecipe = recipe({\n base: styledInputBase,\n variants: {\n size: {\n small: {\n height: SMALL_HEIGHT,\n fontSize: tokens.fontSizes['1'],\n paddingLeft: tokens.space['2'],\n paddingRight: tokens.space['2'],\n lineHeight: tokens.sizes['5'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['1'],\n },\n },\n },\n medium: {\n height: MEDIUM_HEIGHT,\n fontSize: tokens.fontSizes['3'],\n paddingLeft: tokens.space['3'],\n paddingRight: tokens.space['3'],\n lineHeight: tokens.sizes['6'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['3'],\n },\n },\n },\n large: {\n height: LARGE_HEIGHT,\n fontSize: tokens.fontSizes['3'],\n paddingLeft: tokens.space['3'],\n paddingRight: tokens.space['3'],\n lineHeight: tokens.sizes['7'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['3'],\n },\n },\n },\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n backgroundColor: 'transparent',\n selectors: {\n '&:disabled': {\n boxShadow: 'none',\n },\n '&:focus-visible': {\n backgroundColor: tokens.colors.loContrast,\n },\n },\n },\n },\n state: {\n invalid: {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}`,\n selectors: {\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputInvalidBorder}, ${FOCUS_SHADOW}`,\n },\n },\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover:not(:read-only)': {\n cursor: 'text',\n },\n },\n },\n },\n selectors: {\n '&:focus-visible:not(:read-only)': {\n cursor: 'text',\n },\n },\n },\n text: {\n cursor: 'text',\n },\n },\n startAdornment: {\n true: {},\n },\n endAdornment: {\n true: {},\n },\n },\n compoundVariants: [\n {\n variants: {\n variant: 'ghost',\n state: 'invalid',\n },\n style: {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}`,\n },\n },\n // startAdornment compound variants\n {\n variants: {\n startAdornment: true,\n size: 'small',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['2']} + 15px)`,\n },\n },\n {\n variants: {\n startAdornment: true,\n size: 'medium',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n {\n variants: {\n startAdornment: true,\n size: 'large',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n // endAdornment compound variants\n {\n variants: {\n endAdornment: true,\n size: 'small',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['2']} + 15px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'medium',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'large',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n // endAdornment + invalid compound variants\n {\n variants: {\n endAdornment: true,\n size: 'small',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['4']} + 30px)`, // size padding + adornment margins + icon size + icon size\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'medium',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['6']} + 30px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'large',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['6']} + 30px)`,\n },\n },\n ],\n defaultVariants: {\n size: 'medium',\n cursor: 'default',\n },\n});\n\nconst inputWrapperBase = style({\n // Reset\n outline: 'none',\n lineHeight: 0,\n\n position: 'relative',\n backgroundColor: tokens.colors.inputBg,\n color: tokens.colors.inputPlaceholder,\n\n selectors: {\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: '0',\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: '0',\n pointerEvents: 'none',\n },\n '&:focus-visible::before': {\n backgroundColor: tokens.colors.inputFocusBg,\n },\n '&:focus-visible::after': {\n backgroundColor: tokens.colors.primary,\n opacity: '0.15',\n },\n },\n\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::before': {\n backgroundColor: tokens.colors.inputHoverBg,\n },\n '&:hover::after': {\n backgroundColor: tokens.colors.primary,\n opacity: '0.05',\n },\n },\n },\n },\n});\n\nexport const inputWrapperRecipe = recipe({\n base: inputWrapperBase,\n variants: {\n disabled: {\n true: {\n opacity: '0.7',\n color: tokens.colors.inputDisabledText,\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::before': {\n backgroundColor: 'inherit',\n },\n '&:hover::after': {\n backgroundColor: 'inherit',\n },\n },\n },\n },\n },\n },\n state: {\n invalid: {\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::after': {\n backgroundColor: tokens.colors.inputInvalidBorder,\n },\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: tokens.radii['2'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['2'],\n },\n },\n },\n medium: {\n borderRadius: tokens.radii['3'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['3'],\n },\n },\n },\n large: {\n borderRadius: tokens.radii['3'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['3'],\n },\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n disabled: false,\n },\n});\n\nconst adornmentWrapperBase = style({\n position: 'absolute',\n top: '0',\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n});\n\nexport const adornmentWrapperRecipe = recipe({\n base: adornmentWrapperBase,\n variants: {\n size: {\n small: {\n marginLeft: `calc(${tokens.space['2']} / 2)`,\n marginRight: `calc(${tokens.space['2']} / 2)`,\n },\n medium: {\n marginLeft: `calc(${tokens.space['3']} / 2)`,\n marginRight: `calc(${tokens.space['3']} / 2)`,\n },\n large: {\n marginLeft: `calc(${tokens.space['3']} / 2)`,\n marginRight: `calc(${tokens.space['3']} / 2)`,\n },\n },\n variant: {\n start: {\n left: '0',\n },\n end: {\n right: '0',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Input.vanilla.css.js","names":["_7a468"],"sources":["../../../components/Input/Input.vanilla.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\nimport { recipe } from '@vanilla-extract/recipes';\n\nimport { breakpoints } from '../../styles/breakpoints.css';\nimport { tokens } from '../../styles/tokens.css';\n\n// CONSTANTS\nconst FOCUS_SHADOW =\n '0 1px 5px 0 hsla(0, 0%, 0%, 0.2), 0 3px 1px -2px hsla(0, 0%, 0%, 0.12), 0 2px 2px 0 hsla(0, 0%, 0%, 0.14)';\n\nconst SMALL_HEIGHT = tokens.sizes['5'];\nconst MEDIUM_HEIGHT = tokens.sizes['6'];\nconst LARGE_HEIGHT = tokens.sizes['7'];\n\nconst styledInputBase = style({\n // Reset\n appearance: 'none',\n borderWidth: '0',\n boxSizing: 'border-box',\n fontFamily: tokens.fonts.rubik,\n margin: '0',\n outline: 'none',\n padding: '0',\n width: '100%',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n // Custom\n position: 'relative',\n backgroundColor: 'transparent',\n borderRadius: 'inherit', // inherit border radius from InputWrapper\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputBorder}`,\n color: tokens.colors.inputText,\n fontVariantNumeric: 'tabular-nums',\n transition: 'box-shadow .1s ease-in-out',\n\n selectors: {\n '&[type=\"number\"]': {\n paddingRight: '0', // remove padding for number native controls\n },\n '&:-webkit-autofill, &:autofill': {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}`,\n WebkitTextFillColor: tokens.colors.hiContrast,\n },\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontFamily: tokens.fonts.rubik,\n color: tokens.colors.hiContrast,\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputFocusBorder}, ${FOCUS_SHADOW}`,\n },\n '&:-webkit-autofill:focus-visible, &:autofill:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputFocusBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}, ${FOCUS_SHADOW}`,\n },\n '&::placeholder': {\n color: tokens.colors.inputPlaceholder,\n },\n '&:read-only:not(:disabled)': {\n boxShadow: 'none',\n },\n '&:disabled': {\n pointerEvents: 'none',\n color: tokens.colors.inputDisabledText,\n },\n },\n});\n\nexport const styledInputRecipe = recipe({\n base: styledInputBase,\n variants: {\n size: {\n small: {\n height: SMALL_HEIGHT,\n fontSize: tokens.fontSizes['1'],\n paddingLeft: tokens.space['2'],\n paddingRight: tokens.space['2'],\n lineHeight: tokens.sizes['5'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['1'],\n },\n },\n },\n medium: {\n height: MEDIUM_HEIGHT,\n fontSize: tokens.fontSizes['3'],\n paddingLeft: tokens.space['3'],\n paddingRight: tokens.space['3'],\n lineHeight: tokens.sizes['6'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['3'],\n },\n },\n },\n large: {\n height: LARGE_HEIGHT,\n fontSize: tokens.fontSizes['3'],\n paddingLeft: tokens.space['3'],\n paddingRight: tokens.space['3'],\n lineHeight: tokens.sizes['7'],\n selectors: {\n '&:-webkit-autofill::first-line, &:autofill::first-line': {\n fontSize: tokens.fontSizes['3'],\n },\n },\n },\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n backgroundColor: 'transparent',\n selectors: {\n '&:disabled': {\n boxShadow: 'none',\n },\n '&:focus-visible': {\n backgroundColor: tokens.colors.loContrast,\n },\n },\n },\n },\n state: {\n invalid: {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}`,\n selectors: {\n '&:-webkit-autofill, &:autofill': {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}`,\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputInvalidBorder}, ${FOCUS_SHADOW}`,\n },\n '&:-webkit-autofill:focus-visible, &:autofill:focus-visible': {\n boxShadow: `inset 0 0 0 2px ${tokens.colors.inputInvalidBorder}, inset 0 0 0 100px ${tokens.colors.inputBg}, ${FOCUS_SHADOW}`,\n },\n },\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover:not(:read-only)': {\n cursor: 'text',\n },\n },\n },\n },\n selectors: {\n '&:focus-visible:not(:read-only)': {\n cursor: 'text',\n },\n },\n },\n text: {\n cursor: 'text',\n },\n },\n startAdornment: {\n true: {},\n },\n endAdornment: {\n true: {},\n },\n },\n compoundVariants: [\n {\n variants: {\n variant: 'ghost',\n state: 'invalid',\n },\n style: {\n boxShadow: `inset 0 0 0 1px ${tokens.colors.inputInvalidBorder}`,\n },\n },\n // startAdornment compound variants\n {\n variants: {\n startAdornment: true,\n size: 'small',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['2']} + 15px)`,\n },\n },\n {\n variants: {\n startAdornment: true,\n size: 'medium',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n {\n variants: {\n startAdornment: true,\n size: 'large',\n },\n style: {\n paddingInlineStart: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n // endAdornment compound variants\n {\n variants: {\n endAdornment: true,\n size: 'small',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['2']} + 15px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'medium',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'large',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['3']} + 15px)`,\n },\n },\n // endAdornment + invalid compound variants\n {\n variants: {\n endAdornment: true,\n size: 'small',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['4']} + 30px)`, // size padding + adornment margins + icon size + icon size\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'medium',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['6']} + 30px)`,\n },\n },\n {\n variants: {\n endAdornment: true,\n size: 'large',\n state: 'invalid',\n },\n style: {\n paddingInlineEnd: `calc(${tokens.space['6']} + 30px)`,\n },\n },\n ],\n defaultVariants: {\n size: 'medium',\n cursor: 'default',\n },\n});\n\nconst inputWrapperBase = style({\n // Reset\n outline: 'none',\n lineHeight: 0,\n\n position: 'relative',\n isolation: 'isolate',\n backgroundColor: tokens.colors.inputBg,\n color: tokens.colors.inputPlaceholder,\n\n selectors: {\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: '0',\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: '0',\n pointerEvents: 'none',\n },\n '&:focus-visible::before': {\n backgroundColor: tokens.colors.inputFocusBg,\n },\n '&:focus-visible::after': {\n backgroundColor: tokens.colors.primary,\n opacity: '0.15',\n },\n },\n\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::before': {\n backgroundColor: tokens.colors.inputHoverBg,\n },\n '&:hover::after': {\n backgroundColor: tokens.colors.primary,\n opacity: '0.05',\n },\n },\n },\n },\n});\n\nexport const inputWrapperRecipe = recipe({\n base: inputWrapperBase,\n variants: {\n disabled: {\n true: {\n opacity: '0.7',\n color: tokens.colors.inputDisabledText,\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::before': {\n backgroundColor: 'inherit',\n },\n '&:hover::after': {\n backgroundColor: 'inherit',\n },\n },\n },\n },\n },\n },\n state: {\n invalid: {\n '@media': {\n [breakpoints.hover]: {\n selectors: {\n '&:hover::after': {\n backgroundColor: tokens.colors.inputInvalidBorder,\n },\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: tokens.radii['2'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['2'],\n },\n },\n },\n medium: {\n borderRadius: tokens.radii['3'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['3'],\n },\n },\n },\n large: {\n borderRadius: tokens.radii['3'],\n selectors: {\n '&::before, &::after': {\n borderRadius: tokens.radii['3'],\n },\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n disabled: false,\n },\n});\n\nconst adornmentWrapperBase = style({\n position: 'absolute',\n top: '0',\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n});\n\nexport const adornmentWrapperRecipe = recipe({\n base: adornmentWrapperBase,\n variants: {\n size: {\n small: {\n marginLeft: `calc(${tokens.space['2']} / 2)`,\n marginRight: `calc(${tokens.space['2']} / 2)`,\n },\n medium: {\n marginLeft: `calc(${tokens.space['3']} / 2)`,\n marginRight: `calc(${tokens.space['3']} / 2)`,\n },\n large: {\n marginLeft: `calc(${tokens.space['3']} / 2)`,\n marginRight: `calc(${tokens.space['3']} / 2)`,\n },\n },\n variant: {\n start: {\n left: '0',\n zIndex: 1,\n pointerEvents: 'none',\n },\n end: {\n right: '0',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n"],"mappings":""}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
2
|
import { useVanillaExtractTheme } from "../../styles/themeContext.js";
|
|
3
|
+
import { useFieldControl } from "../Field/FieldContext.js";
|
|
3
4
|
import { adornmentWrapperRecipe, inputWrapperRecipe, styledInputRecipe } from "./Input.vanilla.css.js";
|
|
4
5
|
import React from "react";
|
|
5
6
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
// components/Input/Input.vanilla.tsx
|
|
8
|
-
var InputVanilla = React.forwardRef(({ size, startAdornment, endAdornment, css, variant, state, cursor, className, style, ...props }, forwardedRef) => {
|
|
9
|
+
var InputVanilla = React.forwardRef(({ size, startAdornment, endAdornment, css, variant, state, cursor, className, style, id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }, forwardedRef) => {
|
|
9
10
|
const inputRef = React.useRef(null);
|
|
11
|
+
const control = useFieldControl({
|
|
12
|
+
id,
|
|
13
|
+
disabled,
|
|
14
|
+
invalid: state === "invalid",
|
|
15
|
+
"aria-describedby": ariaDescribedBy,
|
|
16
|
+
"aria-invalid": ariaInvalid
|
|
17
|
+
});
|
|
18
|
+
const resolvedState = control.invalid ? "invalid" : state;
|
|
10
19
|
const { colors } = useVanillaExtractTheme();
|
|
11
20
|
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
12
21
|
const mergedStyles = {
|
|
@@ -24,14 +33,14 @@ var InputVanilla = React.forwardRef(({ size, startAdornment, endAdornment, css,
|
|
|
24
33
|
const hasStartAdornment = React.useMemo(() => Boolean(startAdornment), [startAdornment]);
|
|
25
34
|
const hasEndAdornment = React.useMemo(() => Boolean(endAdornment), [endAdornment]);
|
|
26
35
|
const inputWrapperClass = inputWrapperRecipe({
|
|
27
|
-
disabled:
|
|
28
|
-
state,
|
|
36
|
+
disabled: control.disabled,
|
|
37
|
+
state: resolvedState,
|
|
29
38
|
size
|
|
30
39
|
});
|
|
31
40
|
const styledInputClass = styledInputRecipe({
|
|
32
41
|
size,
|
|
33
42
|
variant,
|
|
34
|
-
state,
|
|
43
|
+
state: resolvedState,
|
|
35
44
|
cursor,
|
|
36
45
|
startAdornment: hasStartAdornment,
|
|
37
46
|
endAdornment: hasEndAdornment
|
|
@@ -55,6 +64,10 @@ var InputVanilla = React.forwardRef(({ size, startAdornment, endAdornment, css,
|
|
|
55
64
|
/* @__PURE__ */ jsx("input", {
|
|
56
65
|
ref: inputRef,
|
|
57
66
|
className: styledInputClass,
|
|
67
|
+
id: control.id,
|
|
68
|
+
disabled: control.disabled,
|
|
69
|
+
"aria-describedby": control["aria-describedby"],
|
|
70
|
+
"aria-invalid": control["aria-invalid"],
|
|
58
71
|
...props
|
|
59
72
|
}),
|
|
60
73
|
hasEndAdornment && /* @__PURE__ */ jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.vanilla.js","names":[],"sources":["../../../components/Input/Input.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { RecipeVariants } from '@vanilla-extract/recipes';\nimport React from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { adornmentWrapperRecipe, inputWrapperRecipe, styledInputRecipe } from './Input.vanilla.css';\n\ntype StyledInputRecipeVariants = NonNullable<RecipeVariants<typeof styledInputRecipe>>;\n\nexport interface InputVanillaOwnProps extends CSSProps {\n size?: StyledInputRecipeVariants['size'];\n variant?: StyledInputRecipeVariants['variant'];\n state?: StyledInputRecipeVariants['state'];\n cursor?: StyledInputRecipeVariants['cursor'];\n startAdornment?: React.ReactNode;\n endAdornment?: React.ReactNode;\n type?: string;\n}\n\nexport type InputVanillaProps = Omit<React.InputHTMLAttributes<any>, 'size'> & InputVanillaOwnProps;\n\nexport interface InputVanillaHandle extends HTMLInputElement {\n clear: () => void;\n}\n\nexport const InputVanilla = React.forwardRef<InputVanillaHandle, InputVanillaProps>(\n (\n {
|
|
1
|
+
{"version":3,"file":"Input.vanilla.js","names":[],"sources":["../../../components/Input/Input.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { RecipeVariants } from '@vanilla-extract/recipes';\nimport React from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { useFieldControl } from '../Field/FieldContext';\nimport { adornmentWrapperRecipe, inputWrapperRecipe, styledInputRecipe } from './Input.vanilla.css';\n\ntype StyledInputRecipeVariants = NonNullable<RecipeVariants<typeof styledInputRecipe>>;\n\nexport interface InputVanillaOwnProps extends CSSProps {\n size?: StyledInputRecipeVariants['size'];\n variant?: StyledInputRecipeVariants['variant'];\n state?: StyledInputRecipeVariants['state'];\n cursor?: StyledInputRecipeVariants['cursor'];\n startAdornment?: React.ReactNode;\n endAdornment?: React.ReactNode;\n type?: string;\n}\n\nexport type InputVanillaProps = Omit<React.InputHTMLAttributes<any>, 'size'> & InputVanillaOwnProps;\n\nexport interface InputVanillaHandle extends HTMLInputElement {\n clear: () => void;\n}\n\nexport const InputVanilla = React.forwardRef<InputVanillaHandle, InputVanillaProps>(\n (\n {\n size,\n startAdornment,\n endAdornment,\n css,\n variant,\n state,\n cursor,\n className,\n style,\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputVanillaHandle>(null);\n const control = useFieldControl({\n id,\n disabled,\n invalid: state === 'invalid',\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n const resolvedState = control.invalid ? 'invalid' : state;\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const mergedStyles = { ...cssStyles, ...style, ...assignInlineVars(vars) };\n\n React.useImperativeHandle(forwardedRef, () => {\n const { current } = inputRef;\n if (current) {\n current.clear = () => {\n current.value = '';\n };\n }\n return current as InputVanillaHandle;\n }, [inputRef]);\n\n const hasStartAdornment = React.useMemo(() => Boolean(startAdornment), [startAdornment]);\n const hasEndAdornment = React.useMemo(() => Boolean(endAdornment), [endAdornment]);\n\n const inputWrapperClass = inputWrapperRecipe({\n disabled: control.disabled,\n state: resolvedState,\n size,\n });\n\n const styledInputClass = styledInputRecipe({\n size,\n variant,\n state: resolvedState,\n cursor,\n startAdornment: hasStartAdornment,\n endAdornment: hasEndAdornment,\n });\n\n const adornmentWrapperStartClass = adornmentWrapperRecipe({\n size,\n variant: 'start',\n });\n\n const adornmentWrapperEndClass = adornmentWrapperRecipe({\n size,\n variant: 'end',\n });\n\n return (\n <div className={`${inputWrapperClass} ${className || ''}`.trim()} style={mergedStyles}>\n {hasStartAdornment && <div className={adornmentWrapperStartClass}>{startAdornment}</div>}\n\n <input\n ref={inputRef}\n className={styledInputClass}\n id={control.id}\n disabled={control.disabled}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n {...props}\n />\n\n {hasEndAdornment && <div className={adornmentWrapperEndClass}>{endAdornment}</div>}\n </div>\n );\n },\n);\n\nInputVanilla.displayName = 'InputVanilla';\n"],"mappings":";;;;;;;;AA2BA,IAAa,eAAe,MAAM,YAE9B,EACE,MACA,gBACA,cACA,KACA,SACA,OACA,QACA,WACA,OACA,IACA,UACA,oBAAoB,iBACpB,gBAAgB,aAChB,GAAG,SAEL,iBACG;CACH,MAAM,WAAW,MAAM,OAA2B,IAAI;CACtD,MAAM,UAAU,gBAAgB;EAC9B;EACA;EACA,SAAS,UAAU;EACnB,oBAAoB;EACpB,gBAAgB;CAClB,CAAC;CACD,MAAM,gBAAgB,QAAQ,UAAU,YAAY;CACpD,MAAM,EAAE,WAAW,uBAAuB;CAC1C,MAAM,EAAE,OAAO,WAAW,SAAS,eAAe,KAAK,MAAM;CAC7D,MAAM,eAAe;EAAE,GAAG;EAAW,GAAG;EAAO,GAAG,iBAAiB,IAAI;CAAE;CAEzE,MAAM,oBAAoB,oBAAoB;EAC5C,MAAM,EAAE,YAAY;EACpB,IAAI,SACF,QAAQ,cAAc;GACpB,QAAQ,QAAQ;EAClB;EAEF,OAAO;CACT,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,oBAAoB,MAAM,cAAc,QAAQ,cAAc,GAAG,CAAC,cAAc,CAAC;CACvF,MAAM,kBAAkB,MAAM,cAAc,QAAQ,YAAY,GAAG,CAAC,YAAY,CAAC;CAEjF,MAAM,oBAAoB,mBAAmB;EAC3C,UAAU,QAAQ;EAClB,OAAO;EACP;CACF,CAAC;CAED,MAAM,mBAAmB,kBAAkB;EACzC;EACA;EACA,OAAO;EACP;EACA,gBAAgB;EAChB,cAAc;CAChB,CAAC;CAED,MAAM,6BAA6B,uBAAuB;EACxD;EACA,SAAS;CACX,CAAC;CAED,MAAM,2BAA2B,uBAAuB;EACtD;EACA,SAAS;CACX,CAAC;CAED,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,kBAAkB,GAAG,aAAa,KAAK,KAAK;EAAG,OAAO;EAAzE,UAAA;GACG,qBAAqB,oBAAC,OAAD;IAAK,WAAW;IAA6B,UAAA;GAAoB,CAAA;GAEvF,oBAAC,SAAD;IACE,KAAK;IACL,WAAW;IACX,IAAI,QAAQ;IACZ,UAAU,QAAQ;IAClB,oBAAkB,QAAQ;IAC1B,gBAAc,QAAQ;IACtB,GAAI;GACL,CAAA;GAEA,mBAAmB,oBAAC,OAAD;IAAK,WAAW;IAA2B,UAAA;GAAkB,CAAA;EAC9E;;AAET,CACF;AAEA,aAAa,cAAc"}
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_stitches_config = require("../../stitches.config.cjs");
|
|
3
|
+
const require_FieldContext = require("../Field/FieldContext.cjs");
|
|
3
4
|
let react = require("react");
|
|
4
5
|
react = require_runtime.__toESM(react, 1);
|
|
5
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
7
|
let _radix_ui_react_radio_group = require("@radix-ui/react-radio-group");
|
|
7
8
|
_radix_ui_react_radio_group = require_runtime.__toESM(_radix_ui_react_radio_group, 1);
|
|
8
9
|
// components/Radio/Radio.tsx
|
|
9
|
-
var
|
|
10
|
+
var RadioGroupRoot = react.default.forwardRef(({ id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, ...props }, forwardedRef) => {
|
|
11
|
+
const control = require_FieldContext.useFieldControl({
|
|
12
|
+
id,
|
|
13
|
+
disabled,
|
|
14
|
+
"aria-describedby": ariaDescribedBy,
|
|
15
|
+
"aria-invalid": ariaInvalid,
|
|
16
|
+
labelable: false
|
|
17
|
+
});
|
|
18
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_radio_group.Root, {
|
|
19
|
+
...props,
|
|
20
|
+
id: control.id,
|
|
21
|
+
disabled: control.disabled,
|
|
22
|
+
"aria-labelledby": ariaLabelledBy ?? control.labelId,
|
|
23
|
+
"aria-describedby": control["aria-describedby"],
|
|
24
|
+
"aria-invalid": control["aria-invalid"],
|
|
25
|
+
ref: forwardedRef
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var RadioGroup = require_stitches_config.styled(RadioGroupRoot, { display: "flex" });
|
|
10
29
|
var INDICATOR_BASE_STYLES = {
|
|
11
30
|
alignItems: "center",
|
|
12
31
|
display: "flex",
|
|
@@ -47,6 +66,7 @@ var RADIO_BASE_STYLES = {
|
|
|
47
66
|
"&[data-state=checked]": { backgroundColor: "$radioIndicator" }
|
|
48
67
|
};
|
|
49
68
|
var StyledRadio = require_stitches_config.styled(_radix_ui_react_radio_group.Item, RADIO_BASE_STYLES, {
|
|
69
|
+
"[role=\"radiogroup\"][aria-invalid=\"true\"] &:not(:focus-visible)": { boxShadow: "inset 0 0 0 1px $colors$radioInvalidBorder" },
|
|
50
70
|
"@hover": { "&:hover": {
|
|
51
71
|
cursor: "pointer",
|
|
52
72
|
boxShadow: "inset 0 0 0 1px $colors$radioHoverBorder"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.cjs","names":["
|
|
1
|
+
{"version":3,"file":"Radio.cjs","names":["React","useFieldControl","RadioGroupPrimitive","styled"],"sources":["../../../components/Radio/Radio.tsx"],"sourcesContent":["import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { useFieldControl } from '../Field/FieldContext';\n\nconst RadioGroupRoot = React.forwardRef<HTMLDivElement, RadioGroupPrimitive.RadioGroupProps>(\n (\n {\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n },\n forwardedRef,\n ) => {\n const control = useFieldControl({\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n labelable: false,\n });\n\n return (\n <RadioGroupPrimitive.Root\n {...props}\n id={control.id}\n disabled={control.disabled}\n aria-labelledby={ariaLabelledBy ?? control.labelId}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n ref={forwardedRef}\n />\n );\n },\n);\n\nexport const RadioGroup = styled(RadioGroupRoot, {\n display: 'flex',\n});\n\nexport const INDICATOR_BASE_STYLES = {\n alignItems: 'center',\n display: 'flex',\n height: '100%',\n justifyContent: 'center',\n width: '100%',\n position: 'relative',\n '&::after': {\n content: '\"\"',\n display: 'block',\n width: '7px',\n height: '7px',\n borderRadius: '$round',\n backgroundColor: '$contentBg',\n },\n};\n\nconst StyledIndicator = styled(RadioGroupPrimitive.Indicator, INDICATOR_BASE_STYLES);\n\nexport const RADIO_BASE_STYLES = {\n all: 'unset',\n boxSizing: 'border-box',\n userSelect: 'none',\n '&::before': {\n boxSizing: 'border-box',\n },\n '&::after': {\n boxSizing: 'border-box',\n },\n alignItems: 'center',\n appearance: 'none',\n display: 'inline-flex',\n justifyContent: 'center',\n lineHeight: '1',\n margin: '0',\n outline: 'none',\n padding: '0',\n textDecoration: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n borderRadius: '50%',\n color: '$hiContrast',\n boxShadow: 'inset 0 0 0 1px $colors$radioBorder',\n overflow: 'hidden',\n '&[data-state=checked]': {\n backgroundColor: '$radioIndicator',\n },\n};\nconst StyledRadio = styled(RadioGroupPrimitive.Item, RADIO_BASE_STYLES, {\n '[role=\"radiogroup\"][aria-invalid=\"true\"] &:not(:focus-visible)': {\n boxShadow: 'inset 0 0 0 1px $colors$radioInvalidBorder',\n },\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n boxShadow: 'inset 0 0 0 1px $colors$radioHoverBorder',\n },\n },\n '&:focus-visible': {\n outline: 'none',\n boxShadow: 'inset 0 0 0 1px $colors$radioFocusBorder, 0 0 0 1px $colors$radioFocusBorder',\n },\n\n '&:disabled': {\n pointerEvents: 'none',\n '&::placeholder': {\n color: '$radioDisabledText',\n },\n '&[data-state=checked]': {\n backgroundColor: '$radioIndicatorDisabledBg',\n },\n\n [`& ${StyledIndicator}`]: {\n '&::after': {\n backgroundColor: '$radioDisabledBg',\n },\n },\n },\n\n variants: {\n size: {\n '1': {\n width: '$3',\n height: '$3',\n },\n '2': {\n width: '$5',\n height: '$5',\n\n [`& ${StyledIndicator}`]: {\n '&::after': {\n width: '$3',\n height: '$3',\n },\n },\n },\n },\n },\n defaultVariants: {\n size: '1',\n },\n});\n\nexport type RadioVariants = VariantProps<typeof StyledRadio>;\ntype RadioGroupItemPrimitiveProps = Omit<\n React.ComponentProps<typeof RadioGroupPrimitive.Item>,\n 'as'\n>;\nexport type RadioProps = RadioGroupItemPrimitiveProps & RadioVariants & { css?: CSS };\n\nexport const Radio = React.forwardRef<React.ElementRef<typeof StyledRadio>, RadioProps>(\n (props, forwardedRef) => (\n <StyledRadio {...props} ref={forwardedRef}>\n <StyledIndicator />\n </StyledRadio>\n ),\n);\n"],"mappings":";;;;;;;;;AAMA,IAAM,iBAAiBA,MAAAA,QAAM,YAEzB,EACE,IACA,UACA,oBAAoB,iBACpB,gBAAgB,aAChB,mBAAmB,gBACnB,GAAG,SAEL,iBACG;CACH,MAAM,UAAUC,qBAAAA,gBAAgB;EAC9B;EACA;EACA,oBAAoB;EACpB,gBAAgB;EAChB,WAAW;CACb,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAoB,MAArB;EACE,GAAI;EACJ,IAAI,QAAQ;EACZ,UAAU,QAAQ;EAClB,mBAAiB,kBAAkB,QAAQ;EAC3C,oBAAkB,QAAQ;EAC1B,gBAAc,QAAQ;EACtB,KAAK;CACN,CAAA;AAEL,CACF;AAEA,IAAa,aAAaC,wBAAAA,OAAO,gBAAgB,EAC/C,SAAS,OACX,CAAC;AAED,IAAa,wBAAwB;CACnC,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,gBAAgB;CAChB,OAAO;CACP,UAAU;CACV,YAAY;EACV,SAAS;EACT,SAAS;EACT,OAAO;EACP,QAAQ;EACR,cAAc;EACd,iBAAiB;CACnB;AACF;AAEA,IAAM,kBAAkBA,wBAAAA,OAAOD,4BAAoB,WAAW,qBAAqB;AAEnF,IAAa,oBAAoB;CAC/B,KAAK;CACL,WAAW;CACX,YAAY;CACZ,aAAa,EACX,WAAW,aACb;CACA,YAAY,EACV,WAAW,aACb;CACA,YAAY;CACZ,YAAY;CACZ,SAAS;CACT,gBAAgB;CAChB,YAAY;CACZ,QAAQ;CACR,SAAS;CACT,SAAS;CACT,gBAAgB;CAChB,yBAAyB;CAEzB,cAAc;CACd,OAAO;CACP,WAAW;CACX,UAAU;CACV,yBAAyB,EACvB,iBAAiB,kBACnB;AACF;AACA,IAAM,cAAcC,wBAAAA,OAAOD,4BAAoB,MAAM,mBAAmB;CACtE,sEAAkE,EAChE,WAAW,6CACb;CACA,UAAU,EACR,WAAW;EACT,QAAQ;EACR,WAAW;CACb,EACF;CACA,mBAAmB;EACjB,SAAS;EACT,WAAW;CACb;CAEA,cAAc;EACZ,eAAe;EACf,kBAAkB,EAChB,OAAO,qBACT;EACA,yBAAyB,EACvB,iBAAiB,4BACnB;GAEC,KAAK,oBAAoB,EACxB,YAAY,EACV,iBAAiB,mBACnB,EACF;CACF;CAEA,UAAU,EACR,MAAM;EACJ,KAAK;GACH,OAAO;GACP,QAAQ;EACV;EACA,KAAK;GACH,OAAO;GACP,QAAQ;IAEP,KAAK,oBAAoB,EACxB,YAAY;IACV,OAAO;IACP,QAAQ;GACV,EACF;EACF;CACF,EACF;CACA,iBAAiB,EACf,MAAM,IACR;AACF,CAAC;AASD,IAAa,QAAQF,MAAAA,QAAM,YACxB,OAAO,iBACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAD;CAAa,GAAI;CAAO,KAAK;CAC3B,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAD,CAAkB,CAAA;AACP,CAAA,CAEjB"}
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { styled } from "../../stitches.config.js";
|
|
2
|
+
import { useFieldControl } from "../Field/FieldContext.js";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
5
6
|
// components/Radio/Radio.tsx
|
|
6
|
-
var
|
|
7
|
+
var RadioGroupRoot = React.forwardRef(({ id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, ...props }, forwardedRef) => {
|
|
8
|
+
const control = useFieldControl({
|
|
9
|
+
id,
|
|
10
|
+
disabled,
|
|
11
|
+
"aria-describedby": ariaDescribedBy,
|
|
12
|
+
"aria-invalid": ariaInvalid,
|
|
13
|
+
labelable: false
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsx(RadioGroupPrimitive.Root, {
|
|
16
|
+
...props,
|
|
17
|
+
id: control.id,
|
|
18
|
+
disabled: control.disabled,
|
|
19
|
+
"aria-labelledby": ariaLabelledBy ?? control.labelId,
|
|
20
|
+
"aria-describedby": control["aria-describedby"],
|
|
21
|
+
"aria-invalid": control["aria-invalid"],
|
|
22
|
+
ref: forwardedRef
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
var RadioGroup = styled(RadioGroupRoot, { display: "flex" });
|
|
7
26
|
var INDICATOR_BASE_STYLES = {
|
|
8
27
|
alignItems: "center",
|
|
9
28
|
display: "flex",
|
|
@@ -44,6 +63,7 @@ var RADIO_BASE_STYLES = {
|
|
|
44
63
|
"&[data-state=checked]": { backgroundColor: "$radioIndicator" }
|
|
45
64
|
};
|
|
46
65
|
var StyledRadio = styled(RadioGroupPrimitive.Item, RADIO_BASE_STYLES, {
|
|
66
|
+
"[role=\"radiogroup\"][aria-invalid=\"true\"] &:not(:focus-visible)": { boxShadow: "inset 0 0 0 1px $colors$radioInvalidBorder" },
|
|
47
67
|
"@hover": { "&:hover": {
|
|
48
68
|
cursor: "pointer",
|
|
49
69
|
boxShadow: "inset 0 0 0 1px $colors$radioHoverBorder"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","names":[],"sources":["../../../components/Radio/Radio.tsx"],"sourcesContent":["import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\n\nexport const RadioGroup = styled(
|
|
1
|
+
{"version":3,"file":"Radio.js","names":[],"sources":["../../../components/Radio/Radio.tsx"],"sourcesContent":["import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { useFieldControl } from '../Field/FieldContext';\n\nconst RadioGroupRoot = React.forwardRef<HTMLDivElement, RadioGroupPrimitive.RadioGroupProps>(\n (\n {\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n },\n forwardedRef,\n ) => {\n const control = useFieldControl({\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n labelable: false,\n });\n\n return (\n <RadioGroupPrimitive.Root\n {...props}\n id={control.id}\n disabled={control.disabled}\n aria-labelledby={ariaLabelledBy ?? control.labelId}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n ref={forwardedRef}\n />\n );\n },\n);\n\nexport const RadioGroup = styled(RadioGroupRoot, {\n display: 'flex',\n});\n\nexport const INDICATOR_BASE_STYLES = {\n alignItems: 'center',\n display: 'flex',\n height: '100%',\n justifyContent: 'center',\n width: '100%',\n position: 'relative',\n '&::after': {\n content: '\"\"',\n display: 'block',\n width: '7px',\n height: '7px',\n borderRadius: '$round',\n backgroundColor: '$contentBg',\n },\n};\n\nconst StyledIndicator = styled(RadioGroupPrimitive.Indicator, INDICATOR_BASE_STYLES);\n\nexport const RADIO_BASE_STYLES = {\n all: 'unset',\n boxSizing: 'border-box',\n userSelect: 'none',\n '&::before': {\n boxSizing: 'border-box',\n },\n '&::after': {\n boxSizing: 'border-box',\n },\n alignItems: 'center',\n appearance: 'none',\n display: 'inline-flex',\n justifyContent: 'center',\n lineHeight: '1',\n margin: '0',\n outline: 'none',\n padding: '0',\n textDecoration: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n borderRadius: '50%',\n color: '$hiContrast',\n boxShadow: 'inset 0 0 0 1px $colors$radioBorder',\n overflow: 'hidden',\n '&[data-state=checked]': {\n backgroundColor: '$radioIndicator',\n },\n};\nconst StyledRadio = styled(RadioGroupPrimitive.Item, RADIO_BASE_STYLES, {\n '[role=\"radiogroup\"][aria-invalid=\"true\"] &:not(:focus-visible)': {\n boxShadow: 'inset 0 0 0 1px $colors$radioInvalidBorder',\n },\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n boxShadow: 'inset 0 0 0 1px $colors$radioHoverBorder',\n },\n },\n '&:focus-visible': {\n outline: 'none',\n boxShadow: 'inset 0 0 0 1px $colors$radioFocusBorder, 0 0 0 1px $colors$radioFocusBorder',\n },\n\n '&:disabled': {\n pointerEvents: 'none',\n '&::placeholder': {\n color: '$radioDisabledText',\n },\n '&[data-state=checked]': {\n backgroundColor: '$radioIndicatorDisabledBg',\n },\n\n [`& ${StyledIndicator}`]: {\n '&::after': {\n backgroundColor: '$radioDisabledBg',\n },\n },\n },\n\n variants: {\n size: {\n '1': {\n width: '$3',\n height: '$3',\n },\n '2': {\n width: '$5',\n height: '$5',\n\n [`& ${StyledIndicator}`]: {\n '&::after': {\n width: '$3',\n height: '$3',\n },\n },\n },\n },\n },\n defaultVariants: {\n size: '1',\n },\n});\n\nexport type RadioVariants = VariantProps<typeof StyledRadio>;\ntype RadioGroupItemPrimitiveProps = Omit<\n React.ComponentProps<typeof RadioGroupPrimitive.Item>,\n 'as'\n>;\nexport type RadioProps = RadioGroupItemPrimitiveProps & RadioVariants & { css?: CSS };\n\nexport const Radio = React.forwardRef<React.ElementRef<typeof StyledRadio>, RadioProps>(\n (props, forwardedRef) => (\n <StyledRadio {...props} ref={forwardedRef}>\n <StyledIndicator />\n </StyledRadio>\n ),\n);\n"],"mappings":";;;;;;AAMA,IAAM,iBAAiB,MAAM,YAEzB,EACE,IACA,UACA,oBAAoB,iBACpB,gBAAgB,aAChB,mBAAmB,gBACnB,GAAG,SAEL,iBACG;CACH,MAAM,UAAU,gBAAgB;EAC9B;EACA;EACA,oBAAoB;EACpB,gBAAgB;EAChB,WAAW;CACb,CAAC;CAED,OACE,oBAAC,oBAAoB,MAArB;EACE,GAAI;EACJ,IAAI,QAAQ;EACZ,UAAU,QAAQ;EAClB,mBAAiB,kBAAkB,QAAQ;EAC3C,oBAAkB,QAAQ;EAC1B,gBAAc,QAAQ;EACtB,KAAK;CACN,CAAA;AAEL,CACF;AAEA,IAAa,aAAa,OAAO,gBAAgB,EAC/C,SAAS,OACX,CAAC;AAED,IAAa,wBAAwB;CACnC,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,gBAAgB;CAChB,OAAO;CACP,UAAU;CACV,YAAY;EACV,SAAS;EACT,SAAS;EACT,OAAO;EACP,QAAQ;EACR,cAAc;EACd,iBAAiB;CACnB;AACF;AAEA,IAAM,kBAAkB,OAAO,oBAAoB,WAAW,qBAAqB;AAEnF,IAAa,oBAAoB;CAC/B,KAAK;CACL,WAAW;CACX,YAAY;CACZ,aAAa,EACX,WAAW,aACb;CACA,YAAY,EACV,WAAW,aACb;CACA,YAAY;CACZ,YAAY;CACZ,SAAS;CACT,gBAAgB;CAChB,YAAY;CACZ,QAAQ;CACR,SAAS;CACT,SAAS;CACT,gBAAgB;CAChB,yBAAyB;CAEzB,cAAc;CACd,OAAO;CACP,WAAW;CACX,UAAU;CACV,yBAAyB,EACvB,iBAAiB,kBACnB;AACF;AACA,IAAM,cAAc,OAAO,oBAAoB,MAAM,mBAAmB;CACtE,sEAAkE,EAChE,WAAW,6CACb;CACA,UAAU,EACR,WAAW;EACT,QAAQ;EACR,WAAW;CACb,EACF;CACA,mBAAmB;EACjB,SAAS;EACT,WAAW;CACb;CAEA,cAAc;EACZ,eAAe;EACf,kBAAkB,EAChB,OAAO,qBACT;EACA,yBAAyB,EACvB,iBAAiB,4BACnB;GAEC,KAAK,oBAAoB,EACxB,YAAY,EACV,iBAAiB,mBACnB,EACF;CACF;CAEA,UAAU,EACR,MAAM;EACJ,KAAK;GACH,OAAO;GACP,QAAQ;EACV;EACA,KAAK;GACH,OAAO;GACP,QAAQ;IAEP,KAAK,oBAAoB,EACxB,YAAY;IACV,OAAO;IACP,QAAQ;GACV,EACF;EACF;CACF,EACF;CACA,iBAAiB,EACf,MAAM,IACR;AACF,CAAC;AASD,IAAa,QAAQ,MAAM,YACxB,OAAO,iBACN,oBAAC,aAAD;CAAa,GAAI;CAAO,KAAK;CAC3B,UAAA,oBAAC,iBAAD,CAAkB,CAAA;AACP,CAAA,CAEjB"}
|
|
@@ -12,7 +12,8 @@ var Theme;
|
|
|
12
12
|
radioFocusBorder: "$primary",
|
|
13
13
|
radioDisabledBg: "$deepBlue3",
|
|
14
14
|
radioDisabledBorder: "$deepBlue5",
|
|
15
|
-
radioIndicatorDisabledBg: (0, tinycolor2.default)(primaryColor.value).setAlpha(.6).toHslString()
|
|
15
|
+
radioIndicatorDisabledBg: (0, tinycolor2.default)(primaryColor.value).setAlpha(.6).toHslString(),
|
|
16
|
+
radioInvalidBorder: "$red9"
|
|
16
17
|
});
|
|
17
18
|
_Theme.getDark = (primaryColor) => ({
|
|
18
19
|
radioIndicator: "$primary",
|
|
@@ -22,7 +23,8 @@ var Theme;
|
|
|
22
23
|
radioFocusBorder: "$primary",
|
|
23
24
|
radioDisabledBg: "$deepBlue3",
|
|
24
25
|
radioDisabledBorder: "$deepBlue4",
|
|
25
|
-
radioIndicatorDisabledBg: (0, tinycolor2.default)(primaryColor.value).setAlpha(.6).toHslString()
|
|
26
|
+
radioIndicatorDisabledBg: (0, tinycolor2.default)(primaryColor.value).setAlpha(.6).toHslString(),
|
|
27
|
+
radioInvalidBorder: "$red9"
|
|
26
28
|
});
|
|
27
29
|
})(Theme || (Theme = {}));
|
|
28
30
|
Object.defineProperty(exports, "Theme", {
|