@latte-macchiat-io/latte-vanilla-components 0.0.177 → 0.0.178
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/package.json +3 -1
- package/src/assets/styles/mediaqueries.tsx +24 -0
- package/src/components/Actions/Actions.tsx +132 -0
- package/src/components/Actions/export.tsx +4 -0
- package/src/components/{Main/stories.ts → Actions/stories.tsx} +14 -13
- package/src/components/Button/Button.tsx +132 -0
- package/src/components/Button/export.tsx +5 -0
- package/src/components/Carousel/Carousel.tsx +328 -0
- package/src/components/Carousel/export.tsx +4 -0
- package/src/components/Columns/Columns.tsx +142 -0
- package/src/components/Columns/export.tsx +5 -0
- package/src/components/ConsentCookie/ConsentCookie.tsx +202 -0
- package/src/components/ConsentCookie/export.tsx +4 -0
- package/src/components/{Icon/stories.ts → ConsentCookie/stories.tsx} +7 -8
- package/src/components/Footer/Footer.tsx +130 -0
- package/src/components/Footer/export.tsx +4 -0
- package/src/components/Footer/stories.tsx +26 -0
- package/src/components/Form/Form.tsx +127 -0
- package/src/components/Form/Row/Row.tsx +137 -0
- package/src/components/Form/Row/index.tsx +0 -0
- package/src/components/Form/Row/stories.tsx +41 -0
- package/src/components/Form/TextField/Input/Input.tsx +139 -0
- package/src/components/Form/TextField/Input/export.tsx +6 -0
- package/src/components/Form/TextField/Label/Label.tsx +133 -0
- package/src/components/Form/TextField/Label/export.tsx +4 -0
- package/src/components/Form/TextField/TextField.tsx +200 -0
- package/src/components/Form/TextField/Textarea/Textarea.tsx +135 -0
- package/src/components/Form/TextField/Textarea/export.tsx +6 -0
- package/src/components/Form/TextField/Textarea/stories.tsx +44 -0
- package/src/components/Form/TextField/export.tsx +4 -0
- package/src/components/Form/export.tsx +4 -0
- package/src/components/Header/Header.tsx +158 -0
- package/src/components/Header/HeaderOverlay/index.tsx +32 -0
- package/src/components/Header/ToggleNav/index.tsx +32 -0
- package/src/components/Header/export.tsx +4 -0
- package/src/components/Header/stories.tsx +26 -0
- package/src/components/Icon/Icon.tsx +159 -0
- package/src/components/Icon/export.tsx +4 -0
- package/src/components/KeyNumber/KeyNumber.tsx +166 -0
- package/src/components/KeyNumber/export.tsx +4 -0
- package/src/components/LanguageSwitcher/LanguageSwitcher.tsx +168 -0
- package/src/components/LanguageSwitcher/export.tsx +4 -0
- package/src/components/Logo/Logo.tsx +137 -0
- package/src/components/Logo/export.tsx +4 -0
- package/src/components/Logo/stories.tsx +28 -0
- package/src/components/Main/Main.tsx +130 -0
- package/src/components/Main/export.tsx +4 -0
- package/src/components/Modal/Modal.tsx +194 -0
- package/src/components/Modal/export.tsx +4 -0
- package/src/components/Modal/types.tsx +5 -0
- package/src/components/Nav/Nav.tsx +129 -0
- package/src/components/Nav/export.tsx +4 -0
- package/src/components/Nav/stories.tsx +28 -0
- package/src/components/NavLegal/NavLegal.tsx +133 -0
- package/src/components/NavLegal/export.tsx +4 -0
- package/src/components/NavLegal/stories.tsx +28 -0
- package/src/components/NavLegal/types.tsx +1 -0
- package/src/components/NavSocial/NavSocial.tsx +169 -0
- package/src/components/NavSocial/export.tsx +5 -0
- package/src/components/{Columns/stories.ts → NavSocial/stories.tsx} +12 -14
- package/src/components/NavSocial/types.tsx +1 -0
- package/src/components/Section/Section.tsx +130 -0
- package/src/components/Section/export.tsx +6 -0
- package/src/components/ToRemove/ToRemove.tsx +3 -0
- package/src/components/Video/Video.tsx +243 -0
- package/src/components/Video/export.tsx +2 -0
- package/src/components/VideoFullWidth/VideoFullWidth.tsx +152 -0
- package/src/components/VideoFullWidth/export.tsx +2 -0
- package/src/components/Button/stories.ts +0 -127
- package/src/components/Section/stories.ts +0 -64
@@ -0,0 +1,137 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { rowRecipe, type RowVariants } from './Row.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../../styles/sprinkles.css';
|
5
|
+
|
6
|
+
export interface RowProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Sprinkles, NonNullable<RowVariants> {
|
7
|
+
css?: string;
|
8
|
+
children: React.ReactNode;
|
9
|
+
isActions?: boolean;
|
10
|
+
isMessage?: boolean;
|
11
|
+
}
|
12
|
+
|
13
|
+
export const Row = forwardRef<HTMLDivElement, RowProps>(
|
14
|
+
(
|
15
|
+
{
|
16
|
+
children,
|
17
|
+
align,
|
18
|
+
variant,
|
19
|
+
spacing,
|
20
|
+
isActions = false,
|
21
|
+
isMessage = false,
|
22
|
+
css,
|
23
|
+
className,
|
24
|
+
// Extract sprinkles props
|
25
|
+
margin,
|
26
|
+
marginTop,
|
27
|
+
marginBottom,
|
28
|
+
marginLeft,
|
29
|
+
marginRight,
|
30
|
+
padding,
|
31
|
+
paddingTop,
|
32
|
+
paddingBottom,
|
33
|
+
paddingLeft,
|
34
|
+
paddingRight,
|
35
|
+
gap,
|
36
|
+
display,
|
37
|
+
flexDirection,
|
38
|
+
justifyContent,
|
39
|
+
flexWrap,
|
40
|
+
flex,
|
41
|
+
width,
|
42
|
+
height,
|
43
|
+
minWidth,
|
44
|
+
maxWidth,
|
45
|
+
minHeight,
|
46
|
+
position,
|
47
|
+
top,
|
48
|
+
bottom,
|
49
|
+
left,
|
50
|
+
right,
|
51
|
+
zIndex,
|
52
|
+
fontSize,
|
53
|
+
fontFamily,
|
54
|
+
lineHeight,
|
55
|
+
textAlign,
|
56
|
+
fontWeight,
|
57
|
+
color,
|
58
|
+
backgroundColor,
|
59
|
+
borderRadius,
|
60
|
+
borderWidth,
|
61
|
+
borderStyle,
|
62
|
+
borderColor,
|
63
|
+
boxShadow,
|
64
|
+
opacity,
|
65
|
+
overflow,
|
66
|
+
overflowX,
|
67
|
+
overflowY,
|
68
|
+
...htmlProps
|
69
|
+
},
|
70
|
+
ref
|
71
|
+
) => {
|
72
|
+
// Determine the variant based on the props
|
73
|
+
let computedVariant = variant;
|
74
|
+
if (isActions) computedVariant = 'actions';
|
75
|
+
if (isMessage) computedVariant = 'message';
|
76
|
+
|
77
|
+
return (
|
78
|
+
<div
|
79
|
+
ref={ref}
|
80
|
+
className={clsx(
|
81
|
+
rowRecipe({ align, variant: computedVariant, spacing }),
|
82
|
+
sprinkles({
|
83
|
+
margin,
|
84
|
+
marginTop,
|
85
|
+
marginBottom,
|
86
|
+
marginLeft,
|
87
|
+
marginRight,
|
88
|
+
padding,
|
89
|
+
paddingTop,
|
90
|
+
paddingBottom,
|
91
|
+
paddingLeft,
|
92
|
+
paddingRight,
|
93
|
+
gap,
|
94
|
+
display,
|
95
|
+
flexDirection,
|
96
|
+
justifyContent,
|
97
|
+
flexWrap,
|
98
|
+
flex,
|
99
|
+
width,
|
100
|
+
height,
|
101
|
+
minWidth,
|
102
|
+
maxWidth,
|
103
|
+
minHeight,
|
104
|
+
position,
|
105
|
+
top,
|
106
|
+
bottom,
|
107
|
+
left,
|
108
|
+
right,
|
109
|
+
zIndex,
|
110
|
+
fontSize,
|
111
|
+
fontFamily,
|
112
|
+
lineHeight,
|
113
|
+
textAlign,
|
114
|
+
fontWeight,
|
115
|
+
color,
|
116
|
+
backgroundColor,
|
117
|
+
borderRadius,
|
118
|
+
borderWidth,
|
119
|
+
borderStyle,
|
120
|
+
borderColor,
|
121
|
+
boxShadow,
|
122
|
+
opacity,
|
123
|
+
overflow,
|
124
|
+
overflowX,
|
125
|
+
overflowY,
|
126
|
+
}),
|
127
|
+
css,
|
128
|
+
className
|
129
|
+
)}
|
130
|
+
{...htmlProps}>
|
131
|
+
{children}
|
132
|
+
</div>
|
133
|
+
);
|
134
|
+
}
|
135
|
+
);
|
136
|
+
|
137
|
+
Row.displayName = 'Row';
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
//
|
3
|
+
// import { TextField } from '../TextField';
|
4
|
+
//
|
5
|
+
// import { Row } from '.';
|
6
|
+
//
|
7
|
+
// // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
8
|
+
// const meta: Meta<typeof Row> = {
|
9
|
+
// title: 'Latte Components / Form / Row',
|
10
|
+
// component: Row,
|
11
|
+
// parameters: {
|
12
|
+
// // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
13
|
+
// layout: 'centered',
|
14
|
+
// },
|
15
|
+
// // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
16
|
+
// tags: ['autodocs'],
|
17
|
+
// // More on argTypes: https://storybook.js.org/docs/api/argtypes
|
18
|
+
// argTypes: {},
|
19
|
+
// // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
20
|
+
// };
|
21
|
+
//
|
22
|
+
// export default meta;
|
23
|
+
// type Story = StoryObj<typeof meta>;
|
24
|
+
//
|
25
|
+
// // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
26
|
+
// export const Default: Story = {
|
27
|
+
// args: {
|
28
|
+
// children: <TextField name="hello" label="hello" />,
|
29
|
+
// },
|
30
|
+
// };
|
31
|
+
//
|
32
|
+
// export const MultipleChildren: Story = {
|
33
|
+
// args: {
|
34
|
+
// children: (
|
35
|
+
// <>
|
36
|
+
// <TextField name="hello" label="hello" />
|
37
|
+
// <TextField name="hello" label="hello" />
|
38
|
+
// </>
|
39
|
+
// ),
|
40
|
+
// },
|
41
|
+
// };
|
@@ -0,0 +1,139 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { inputRecipe, type InputVariants } from './Input.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../../../styles/sprinkles.css';
|
5
|
+
|
6
|
+
export type InputType = 'text' | 'email' | 'search' | 'number' | 'hidden' | 'password' | 'tel' | 'url' | 'date' | 'time' | 'datetime-local' | 'color';
|
7
|
+
|
8
|
+
export interface InputProps
|
9
|
+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'color' | 'size' | 'height' | 'width'>,
|
10
|
+
Sprinkles,
|
11
|
+
NonNullable<InputVariants> {
|
12
|
+
css?: string;
|
13
|
+
name: string;
|
14
|
+
type?: InputType;
|
15
|
+
hasError?: boolean;
|
16
|
+
}
|
17
|
+
|
18
|
+
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
19
|
+
(
|
20
|
+
{
|
21
|
+
name,
|
22
|
+
type = 'text',
|
23
|
+
hasError = false,
|
24
|
+
size,
|
25
|
+
variant,
|
26
|
+
css,
|
27
|
+
className,
|
28
|
+
// Extract sprinkles props
|
29
|
+
margin,
|
30
|
+
marginTop,
|
31
|
+
marginBottom,
|
32
|
+
marginLeft,
|
33
|
+
marginRight,
|
34
|
+
padding,
|
35
|
+
paddingTop,
|
36
|
+
paddingBottom,
|
37
|
+
paddingLeft,
|
38
|
+
paddingRight,
|
39
|
+
gap,
|
40
|
+
display,
|
41
|
+
flexDirection,
|
42
|
+
justifyContent,
|
43
|
+
flexWrap,
|
44
|
+
flex,
|
45
|
+
width,
|
46
|
+
height,
|
47
|
+
minWidth,
|
48
|
+
maxWidth,
|
49
|
+
minHeight,
|
50
|
+
position,
|
51
|
+
top,
|
52
|
+
bottom,
|
53
|
+
left,
|
54
|
+
right,
|
55
|
+
zIndex,
|
56
|
+
fontSize,
|
57
|
+
fontFamily,
|
58
|
+
lineHeight,
|
59
|
+
textAlign,
|
60
|
+
fontWeight,
|
61
|
+
color,
|
62
|
+
backgroundColor,
|
63
|
+
borderRadius,
|
64
|
+
borderWidth,
|
65
|
+
borderStyle,
|
66
|
+
borderColor,
|
67
|
+
boxShadow,
|
68
|
+
opacity,
|
69
|
+
overflow,
|
70
|
+
overflowX,
|
71
|
+
overflowY,
|
72
|
+
...htmlProps
|
73
|
+
},
|
74
|
+
ref
|
75
|
+
) => {
|
76
|
+
return (
|
77
|
+
<input
|
78
|
+
ref={ref}
|
79
|
+
id={name}
|
80
|
+
name={name}
|
81
|
+
type={type}
|
82
|
+
className={clsx(
|
83
|
+
inputRecipe({ size, variant }),
|
84
|
+
sprinkles({
|
85
|
+
margin,
|
86
|
+
marginTop,
|
87
|
+
marginBottom,
|
88
|
+
marginLeft,
|
89
|
+
marginRight,
|
90
|
+
padding,
|
91
|
+
paddingTop,
|
92
|
+
paddingBottom,
|
93
|
+
paddingLeft,
|
94
|
+
paddingRight,
|
95
|
+
gap,
|
96
|
+
display,
|
97
|
+
flexDirection,
|
98
|
+
justifyContent,
|
99
|
+
flexWrap,
|
100
|
+
flex,
|
101
|
+
width,
|
102
|
+
height,
|
103
|
+
minWidth,
|
104
|
+
maxWidth,
|
105
|
+
minHeight,
|
106
|
+
position,
|
107
|
+
top,
|
108
|
+
bottom,
|
109
|
+
left,
|
110
|
+
right,
|
111
|
+
zIndex,
|
112
|
+
fontSize,
|
113
|
+
fontFamily,
|
114
|
+
lineHeight,
|
115
|
+
textAlign,
|
116
|
+
fontWeight,
|
117
|
+
color,
|
118
|
+
backgroundColor,
|
119
|
+
borderRadius,
|
120
|
+
borderWidth,
|
121
|
+
borderStyle,
|
122
|
+
borderColor,
|
123
|
+
boxShadow,
|
124
|
+
opacity,
|
125
|
+
overflow,
|
126
|
+
overflowX,
|
127
|
+
overflowY,
|
128
|
+
}),
|
129
|
+
css,
|
130
|
+
className
|
131
|
+
)}
|
132
|
+
data-error={hasError}
|
133
|
+
{...htmlProps}
|
134
|
+
/>
|
135
|
+
);
|
136
|
+
}
|
137
|
+
);
|
138
|
+
|
139
|
+
Input.displayName = 'Input';
|
@@ -0,0 +1,133 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { labelRecipe, type LabelVariants } from './Label.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../../../styles/sprinkles.css';
|
5
|
+
|
6
|
+
export interface LabelProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'color'>, Sprinkles, NonNullable<LabelVariants> {
|
7
|
+
css?: string;
|
8
|
+
label: string;
|
9
|
+
name: string;
|
10
|
+
required?: boolean;
|
11
|
+
}
|
12
|
+
|
13
|
+
export const Label = forwardRef<HTMLLabelElement, LabelProps>(
|
14
|
+
(
|
15
|
+
{
|
16
|
+
label,
|
17
|
+
name,
|
18
|
+
required = false,
|
19
|
+
size,
|
20
|
+
variant,
|
21
|
+
css,
|
22
|
+
className,
|
23
|
+
// Extract sprinkles props
|
24
|
+
margin,
|
25
|
+
marginTop,
|
26
|
+
marginBottom,
|
27
|
+
marginLeft,
|
28
|
+
marginRight,
|
29
|
+
padding,
|
30
|
+
paddingTop,
|
31
|
+
paddingBottom,
|
32
|
+
paddingLeft,
|
33
|
+
paddingRight,
|
34
|
+
gap,
|
35
|
+
display,
|
36
|
+
flexDirection,
|
37
|
+
justifyContent,
|
38
|
+
flexWrap,
|
39
|
+
flex,
|
40
|
+
width,
|
41
|
+
height,
|
42
|
+
minWidth,
|
43
|
+
maxWidth,
|
44
|
+
minHeight,
|
45
|
+
position,
|
46
|
+
top,
|
47
|
+
bottom,
|
48
|
+
left,
|
49
|
+
right,
|
50
|
+
zIndex,
|
51
|
+
fontSize,
|
52
|
+
fontFamily,
|
53
|
+
lineHeight,
|
54
|
+
textAlign,
|
55
|
+
fontWeight,
|
56
|
+
color,
|
57
|
+
backgroundColor,
|
58
|
+
borderRadius,
|
59
|
+
borderWidth,
|
60
|
+
borderStyle,
|
61
|
+
borderColor,
|
62
|
+
boxShadow,
|
63
|
+
opacity,
|
64
|
+
overflow,
|
65
|
+
overflowX,
|
66
|
+
overflowY,
|
67
|
+
...htmlProps
|
68
|
+
},
|
69
|
+
ref
|
70
|
+
) => {
|
71
|
+
return (
|
72
|
+
<label
|
73
|
+
ref={ref}
|
74
|
+
htmlFor={name}
|
75
|
+
className={clsx(
|
76
|
+
labelRecipe({ size, variant }),
|
77
|
+
sprinkles({
|
78
|
+
margin,
|
79
|
+
marginTop,
|
80
|
+
marginBottom,
|
81
|
+
marginLeft,
|
82
|
+
marginRight,
|
83
|
+
padding,
|
84
|
+
paddingTop,
|
85
|
+
paddingBottom,
|
86
|
+
paddingLeft,
|
87
|
+
paddingRight,
|
88
|
+
gap,
|
89
|
+
display,
|
90
|
+
flexDirection,
|
91
|
+
justifyContent,
|
92
|
+
flexWrap,
|
93
|
+
flex,
|
94
|
+
width,
|
95
|
+
height,
|
96
|
+
minWidth,
|
97
|
+
maxWidth,
|
98
|
+
minHeight,
|
99
|
+
position,
|
100
|
+
top,
|
101
|
+
bottom,
|
102
|
+
left,
|
103
|
+
right,
|
104
|
+
zIndex,
|
105
|
+
fontSize,
|
106
|
+
fontFamily,
|
107
|
+
lineHeight,
|
108
|
+
textAlign,
|
109
|
+
fontWeight,
|
110
|
+
color,
|
111
|
+
backgroundColor,
|
112
|
+
borderRadius,
|
113
|
+
borderWidth,
|
114
|
+
borderStyle,
|
115
|
+
borderColor,
|
116
|
+
boxShadow,
|
117
|
+
opacity,
|
118
|
+
overflow,
|
119
|
+
overflowX,
|
120
|
+
overflowY,
|
121
|
+
}),
|
122
|
+
css,
|
123
|
+
className
|
124
|
+
)}
|
125
|
+
data-required={required}
|
126
|
+
{...htmlProps}>
|
127
|
+
{label}
|
128
|
+
</label>
|
129
|
+
);
|
130
|
+
}
|
131
|
+
);
|
132
|
+
|
133
|
+
Label.displayName = 'Label';
|
@@ -0,0 +1,200 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef, useMemo } from 'react';
|
3
|
+
import { errorMessage, inputBase, labelBase, messageContainer, textareaBase, textFieldRecipe, type TextFieldVariants } from './TextField.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../../styles/sprinkles.css';
|
5
|
+
|
6
|
+
export type InputType = 'text' | 'email' | 'search' | 'number' | 'hidden' | 'password' | 'textarea';
|
7
|
+
|
8
|
+
export interface TextFieldProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color' | 'onChange'>, Sprinkles, NonNullable<TextFieldVariants> {
|
9
|
+
css?: string;
|
10
|
+
name: string;
|
11
|
+
label?: string;
|
12
|
+
value?: string;
|
13
|
+
rows?: number;
|
14
|
+
disabled?: boolean;
|
15
|
+
required?: boolean;
|
16
|
+
placeholder?: string;
|
17
|
+
errors?: string | string[];
|
18
|
+
type?: InputType;
|
19
|
+
onChange?: (e: { target: { value: string | undefined } }) => void | undefined;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const TextField = forwardRef<HTMLDivElement, TextFieldProps>(
|
23
|
+
(
|
24
|
+
{
|
25
|
+
name,
|
26
|
+
label,
|
27
|
+
value = '',
|
28
|
+
rows = 3,
|
29
|
+
disabled = false,
|
30
|
+
required = false,
|
31
|
+
placeholder = '',
|
32
|
+
errors,
|
33
|
+
type = 'text',
|
34
|
+
onChange,
|
35
|
+
size,
|
36
|
+
css,
|
37
|
+
className,
|
38
|
+
// Extract sprinkles props
|
39
|
+
margin,
|
40
|
+
marginTop,
|
41
|
+
marginBottom,
|
42
|
+
marginLeft,
|
43
|
+
marginRight,
|
44
|
+
padding,
|
45
|
+
paddingTop,
|
46
|
+
paddingBottom,
|
47
|
+
paddingLeft,
|
48
|
+
paddingRight,
|
49
|
+
gap,
|
50
|
+
display,
|
51
|
+
flexDirection,
|
52
|
+
justifyContent,
|
53
|
+
flexWrap,
|
54
|
+
flex,
|
55
|
+
width,
|
56
|
+
height,
|
57
|
+
minWidth,
|
58
|
+
maxWidth,
|
59
|
+
minHeight,
|
60
|
+
position,
|
61
|
+
top,
|
62
|
+
bottom,
|
63
|
+
left,
|
64
|
+
right,
|
65
|
+
zIndex,
|
66
|
+
fontSize,
|
67
|
+
fontFamily,
|
68
|
+
lineHeight,
|
69
|
+
textAlign,
|
70
|
+
fontWeight,
|
71
|
+
color,
|
72
|
+
backgroundColor,
|
73
|
+
borderRadius,
|
74
|
+
borderWidth,
|
75
|
+
borderStyle,
|
76
|
+
borderColor,
|
77
|
+
boxShadow,
|
78
|
+
opacity,
|
79
|
+
overflow,
|
80
|
+
overflowX,
|
81
|
+
overflowY,
|
82
|
+
...htmlProps
|
83
|
+
},
|
84
|
+
ref
|
85
|
+
) => {
|
86
|
+
const hasErrors = useMemo(() => {
|
87
|
+
if (!errors) return false;
|
88
|
+
if (Array.isArray(errors)) return errors.length > 0;
|
89
|
+
return Boolean(errors);
|
90
|
+
}, [errors]);
|
91
|
+
|
92
|
+
const isTextarea = type === 'textarea';
|
93
|
+
|
94
|
+
return (
|
95
|
+
<div
|
96
|
+
ref={ref}
|
97
|
+
className={clsx(
|
98
|
+
textFieldRecipe({ size }),
|
99
|
+
sprinkles({
|
100
|
+
margin,
|
101
|
+
marginTop,
|
102
|
+
marginBottom,
|
103
|
+
marginLeft,
|
104
|
+
marginRight,
|
105
|
+
padding,
|
106
|
+
paddingTop,
|
107
|
+
paddingBottom,
|
108
|
+
paddingLeft,
|
109
|
+
paddingRight,
|
110
|
+
gap,
|
111
|
+
display,
|
112
|
+
flexDirection,
|
113
|
+
justifyContent,
|
114
|
+
flexWrap,
|
115
|
+
flex,
|
116
|
+
width,
|
117
|
+
height,
|
118
|
+
minWidth,
|
119
|
+
maxWidth,
|
120
|
+
minHeight,
|
121
|
+
position,
|
122
|
+
top,
|
123
|
+
bottom,
|
124
|
+
left,
|
125
|
+
right,
|
126
|
+
zIndex,
|
127
|
+
fontSize,
|
128
|
+
fontFamily,
|
129
|
+
lineHeight,
|
130
|
+
textAlign,
|
131
|
+
fontWeight,
|
132
|
+
color,
|
133
|
+
backgroundColor,
|
134
|
+
borderRadius,
|
135
|
+
borderWidth,
|
136
|
+
borderStyle,
|
137
|
+
borderColor,
|
138
|
+
boxShadow,
|
139
|
+
opacity,
|
140
|
+
overflow,
|
141
|
+
overflowX,
|
142
|
+
overflowY,
|
143
|
+
}),
|
144
|
+
css,
|
145
|
+
className
|
146
|
+
)}
|
147
|
+
{...htmlProps}>
|
148
|
+
{label && (
|
149
|
+
<label htmlFor={name} className={labelBase} data-required={required}>
|
150
|
+
{label}
|
151
|
+
</label>
|
152
|
+
)}
|
153
|
+
|
154
|
+
{isTextarea ? (
|
155
|
+
<textarea
|
156
|
+
id={name}
|
157
|
+
name={name}
|
158
|
+
rows={rows}
|
159
|
+
value={value}
|
160
|
+
disabled={disabled}
|
161
|
+
placeholder={placeholder}
|
162
|
+
className={textareaBase}
|
163
|
+
onChange={onChange}
|
164
|
+
data-error={hasErrors}
|
165
|
+
required={required}
|
166
|
+
/>
|
167
|
+
) : (
|
168
|
+
<input
|
169
|
+
id={name}
|
170
|
+
name={name}
|
171
|
+
type={type}
|
172
|
+
value={value}
|
173
|
+
disabled={disabled}
|
174
|
+
placeholder={placeholder}
|
175
|
+
className={inputBase}
|
176
|
+
onChange={onChange}
|
177
|
+
data-error={hasErrors}
|
178
|
+
required={required}
|
179
|
+
/>
|
180
|
+
)}
|
181
|
+
|
182
|
+
{hasErrors && (
|
183
|
+
<div className={messageContainer}>
|
184
|
+
{Array.isArray(errors) ? (
|
185
|
+
errors.map((error, index) => (
|
186
|
+
<span key={index} className={errorMessage}>
|
187
|
+
{error}
|
188
|
+
</span>
|
189
|
+
))
|
190
|
+
) : (
|
191
|
+
<span className={errorMessage}>{errors}</span>
|
192
|
+
)}
|
193
|
+
</div>
|
194
|
+
)}
|
195
|
+
</div>
|
196
|
+
);
|
197
|
+
}
|
198
|
+
);
|
199
|
+
|
200
|
+
TextField.displayName = 'TextField';
|