@latte-macchiat-io/latte-vanilla-components 0.0.176 → 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 +9 -22
- 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/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/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/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/dist/components/Actions/Actions.css.ts +0 -113
- package/dist/components/Button/Button.css.ts +0 -119
- package/dist/components/Carousel/Carousel.css.ts +0 -179
- package/dist/components/Columns/Columns.css.ts +0 -185
- package/dist/components/ConsentCookie/ConsentCookie.css.ts +0 -167
- package/dist/components/Footer/Footer.css.ts +0 -108
- package/dist/components/Form/Form.css.ts +0 -64
- package/dist/components/Form/Row/Row.css.ts +0 -70
- package/dist/components/Form/TextField/Input/Input.css.ts +0 -106
- package/dist/components/Form/TextField/Label/Label.css.ts +0 -58
- package/dist/components/Form/TextField/TextField.css.ts +0 -139
- package/dist/components/Form/TextField/Textarea/Textarea.css.ts +0 -121
- package/dist/components/Header/Header.css.ts +0 -111
- package/dist/components/Header/HeaderOverlay/styles.css.ts +0 -33
- package/dist/components/Header/ToggleNav/styles.css.ts +0 -40
- package/dist/components/Icon/Icon.css.ts +0 -102
- package/dist/components/KeyNumber/KeyNumber.css.ts +0 -158
- package/dist/components/LanguageSwitcher/LanguageSwitcher.css.ts +0 -120
- package/dist/components/Logo/Logo.css.ts +0 -98
- package/dist/components/Main/Main.css.ts +0 -62
- package/dist/components/Modal/Modal.css.ts +0 -203
- package/dist/components/Nav/Nav.css.ts +0 -123
- package/dist/components/NavLegal/NavLegal.css.ts +0 -121
- package/dist/components/NavSocial/NavSocial.css.ts +0 -121
- package/dist/components/Section/Section.css.ts +0 -101
- package/dist/components/Video/Video.css.ts +0 -210
- package/dist/components/VideoFullWidth/VideoFullWidth.css.ts +0 -50
- package/dist/css/index.cjs +0 -1
- package/dist/css/index.js +0 -34
- package/dist/index.cjs.js +0 -2
- package/dist/index.es.js +0 -3863
- package/dist/styles/sprinkles.css.ts +0 -84
- package/dist/theme/contract.css.ts +0 -83
- package/dist/theme.css-CNjMk-g_.cjs +0 -1
- package/dist/theme.css-Dj6kL9o0.js +0 -3020
- package/dist/types/components/Actions/Actions.css.d.ts +0 -74
- package/dist/types/components/Actions/Actions.d.ts +0 -7
- package/dist/types/components/Actions/stories.d.ts +0 -0
- package/dist/types/components/Button/Button.css.d.ts +0 -65
- package/dist/types/components/Button/Button.d.ts +0 -8
- package/dist/types/components/Button/export.d.ts +0 -0
- package/dist/types/components/Button/stories.d.ts +0 -0
- package/dist/types/components/Carousel/Carousel.css.d.ts +0 -33
- package/dist/types/components/Carousel/Carousel.d.ts +0 -15
- package/dist/types/components/Carousel/export.d.ts +0 -0
- package/dist/types/components/Columns/Columns.css.d.ts +0 -104
- package/dist/types/components/Columns/Columns.d.ts +0 -8
- package/dist/types/components/Columns/export.d.ts +0 -0
- package/dist/types/components/Columns/stories.d.ts +0 -0
- package/dist/types/components/ConsentCookie/ConsentCookie.css.d.ts +0 -15
- package/dist/types/components/ConsentCookie/ConsentCookie.d.ts +0 -17
- package/dist/types/components/ConsentCookie/export.d.ts +0 -0
- package/dist/types/components/ConsentCookie/stories.d.ts +0 -0
- package/dist/types/components/Footer/Footer.css.d.ts +0 -50
- package/dist/types/components/Footer/Footer.d.ts +0 -7
- package/dist/types/components/Footer/export.d.ts +0 -0
- package/dist/types/components/Footer/stories.d.ts +0 -6
- package/dist/types/components/Form/Form.css.d.ts +0 -46
- package/dist/types/components/Form/Form.d.ts +0 -7
- package/dist/types/components/Form/Row/Row.css.d.ts +0 -51
- package/dist/types/components/Form/Row/Row.d.ts +0 -9
- package/dist/types/components/Form/Row/index.d.ts +0 -0
- package/dist/types/components/Form/Row/stories.d.ts +0 -0
- package/dist/types/components/Form/TextField/Input/Input.css.d.ts +0 -32
- package/dist/types/components/Form/TextField/Input/Input.d.ts +0 -10
- package/dist/types/components/Form/TextField/Input/export.d.ts +0 -0
- package/dist/types/components/Form/TextField/Label/Label.css.d.ts +0 -23
- package/dist/types/components/Form/TextField/Label/Label.d.ts +0 -9
- package/dist/types/components/Form/TextField/Label/export.d.ts +0 -0
- package/dist/types/components/Form/TextField/TextField.css.d.ts +0 -19
- package/dist/types/components/Form/TextField/TextField.d.ts +0 -21
- package/dist/types/components/Form/TextField/Textarea/Textarea.css.d.ts +0 -56
- package/dist/types/components/Form/TextField/Textarea/Textarea.d.ts +0 -8
- package/dist/types/components/Form/TextField/Textarea/export.d.ts +0 -0
- package/dist/types/components/Form/TextField/Textarea/stories.d.ts +0 -0
- package/dist/types/components/Form/TextField/export.d.ts +0 -0
- package/dist/types/components/Form/export.d.ts +0 -0
- package/dist/types/components/Header/Header.css.d.ts +0 -36
- package/dist/types/components/Header/Header.d.ts +0 -11
- package/dist/types/components/Header/HeaderOverlay/index.d.ts +0 -7
- package/dist/types/components/Header/HeaderOverlay/styles.css.d.ts +0 -5
- package/dist/types/components/Header/ToggleNav/index.d.ts +0 -9
- package/dist/types/components/Header/ToggleNav/styles.css.d.ts +0 -5
- package/dist/types/components/Header/export.d.ts +0 -0
- package/dist/types/components/Header/stories.d.ts +0 -6
- package/dist/types/components/Icon/Icon.css.d.ts +0 -45
- package/dist/types/components/Icon/Icon.d.ts +0 -12
- package/dist/types/components/Icon/export.d.ts +0 -0
- package/dist/types/components/Icon/path.d.ts +0 -19
- package/dist/types/components/Icon/stories.d.ts +0 -0
- package/dist/types/components/KeyNumber/KeyNumber.css.d.ts +0 -40
- package/dist/types/components/KeyNumber/KeyNumber.d.ts +0 -15
- package/dist/types/components/KeyNumber/export.d.ts +0 -0
- package/dist/types/components/LanguageSwitcher/LanguageSwitcher.css.d.ts +0 -18
- package/dist/types/components/LanguageSwitcher/LanguageSwitcher.d.ts +0 -16
- package/dist/types/components/LanguageSwitcher/export.d.ts +0 -0
- package/dist/types/components/Logo/Logo.css.d.ts +0 -54
- package/dist/types/components/Logo/Logo.d.ts +0 -8
- package/dist/types/components/Logo/export.d.ts +0 -0
- package/dist/types/components/Logo/stories.d.ts +0 -6
- package/dist/types/components/Main/Main.css.d.ts +0 -32
- package/dist/types/components/Main/Main.d.ts +0 -7
- package/dist/types/components/Main/export.d.ts +0 -0
- package/dist/types/components/Main/stories.d.ts +0 -0
- package/dist/types/components/Modal/Modal.css.d.ts +0 -82
- package/dist/types/components/Modal/Modal.d.ts +0 -15
- package/dist/types/components/Modal/export.d.ts +0 -0
- package/dist/types/components/Modal/types.d.ts +0 -5
- package/dist/types/components/Nav/Nav.css.d.ts +0 -52
- package/dist/types/components/Nav/Nav.d.ts +0 -7
- package/dist/types/components/Nav/export.d.ts +0 -0
- package/dist/types/components/Nav/stories.d.ts +0 -6
- package/dist/types/components/NavLegal/NavLegal.css.d.ts +0 -57
- package/dist/types/components/NavLegal/NavLegal.d.ts +0 -7
- package/dist/types/components/NavLegal/export.d.ts +0 -0
- package/dist/types/components/NavLegal/stories.d.ts +0 -6
- package/dist/types/components/NavSocial/NavSocial.css.d.ts +0 -30
- package/dist/types/components/NavSocial/NavSocial.d.ts +0 -15
- package/dist/types/components/NavSocial/export.d.ts +0 -0
- package/dist/types/components/NavSocial/stories.d.ts +0 -0
- package/dist/types/components/Section/Section.css.d.ts +0 -60
- package/dist/types/components/Section/Section.d.ts +0 -7
- package/dist/types/components/Section/export.d.ts +0 -0
- package/dist/types/components/Section/stories.d.ts +0 -0
- package/dist/types/components/ToRemove/ToRemove.d.ts +0 -1
- package/dist/types/components/Video/Video.css.d.ts +0 -43
- package/dist/types/components/Video/Video.d.ts +0 -17
- package/dist/types/components/Video/export.d.ts +0 -0
- package/dist/types/components/VideoFullWidth/VideoFullWidth.css.d.ts +0 -18
- package/dist/types/components/VideoFullWidth/VideoFullWidth.d.ts +0 -14
- package/dist/types/components/VideoFullWidth/export.d.ts +0 -0
- package/dist/types/css/index.d.ts +0 -28
- package/dist/types/index.d.ts +0 -58
- package/dist/types/styles/mediaqueries.d.ts +0 -16
- package/dist/types/styles/sprinkles.css.d.ts +0 -3423
- package/dist/types/theme/baseThemeValues.d.ts +0 -158
- package/dist/types/theme/contract.css.d.ts +0 -79
- package/dist/types/theme/index.d.ts +0 -3
- package/dist/types/theme/utils.d.ts +0 -86
- package/dist/types/utils/cookie.d.ts +0 -2
- package/dist/types/utils/deep-merge-objects.d.ts +0 -2
- package/dist/types/utils/theme.css.d.ts +0 -173
- package/dist/types/utils/use-breakpoint-key.d.ts +0 -1
- package/dist/types/utils/use-window-size.d.ts +0 -5
- package/dist/utils/theme.css.ts +0 -129
- package/src/components/Button/stories.ts +0 -127
- package/src/components/Section/stories.ts +0 -64
- package/src/css/index.ts +0 -33
- package/src/themes/dark.ts +0 -3
- package/src/themes/index.ts +0 -5
- package/src/themes/light.ts +0 -3
- /package/{dist/types/components/Actions/export.d.ts → src/components/Form/Row/index.tsx} +0 -0
- /package/{dist/types/components/NavLegal/types.d.ts → src/components/NavLegal/types.tsx} +0 -0
- /package/{dist/types/components/NavSocial/types.d.ts → src/components/NavSocial/types.tsx} +0 -0
@@ -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';
|
@@ -0,0 +1,135 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { textareaRecipe, type TextareaVariants } from './Textarea.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../../../styles/sprinkles.css';
|
5
|
+
|
6
|
+
export interface TextareaProps
|
7
|
+
extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'color' | 'size'>,
|
8
|
+
Sprinkles,
|
9
|
+
NonNullable<TextareaVariants> {
|
10
|
+
css?: string;
|
11
|
+
name: string;
|
12
|
+
hasError?: boolean;
|
13
|
+
}
|
14
|
+
|
15
|
+
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
16
|
+
(
|
17
|
+
{
|
18
|
+
name,
|
19
|
+
hasError = false,
|
20
|
+
size,
|
21
|
+
variant,
|
22
|
+
resize,
|
23
|
+
css,
|
24
|
+
className,
|
25
|
+
// Extract sprinkles props
|
26
|
+
margin,
|
27
|
+
marginTop,
|
28
|
+
marginBottom,
|
29
|
+
marginLeft,
|
30
|
+
marginRight,
|
31
|
+
padding,
|
32
|
+
paddingTop,
|
33
|
+
paddingBottom,
|
34
|
+
paddingLeft,
|
35
|
+
paddingRight,
|
36
|
+
gap,
|
37
|
+
display,
|
38
|
+
flexDirection,
|
39
|
+
justifyContent,
|
40
|
+
flexWrap,
|
41
|
+
flex,
|
42
|
+
width,
|
43
|
+
height,
|
44
|
+
minWidth,
|
45
|
+
maxWidth,
|
46
|
+
minHeight,
|
47
|
+
position,
|
48
|
+
top,
|
49
|
+
bottom,
|
50
|
+
left,
|
51
|
+
right,
|
52
|
+
zIndex,
|
53
|
+
fontSize,
|
54
|
+
fontFamily,
|
55
|
+
lineHeight,
|
56
|
+
textAlign,
|
57
|
+
fontWeight,
|
58
|
+
color,
|
59
|
+
backgroundColor,
|
60
|
+
borderRadius,
|
61
|
+
borderWidth,
|
62
|
+
borderStyle,
|
63
|
+
borderColor,
|
64
|
+
boxShadow,
|
65
|
+
opacity,
|
66
|
+
overflow,
|
67
|
+
overflowX,
|
68
|
+
overflowY,
|
69
|
+
...htmlProps
|
70
|
+
},
|
71
|
+
ref
|
72
|
+
) => {
|
73
|
+
return (
|
74
|
+
<textarea
|
75
|
+
ref={ref}
|
76
|
+
id={name}
|
77
|
+
name={name}
|
78
|
+
className={clsx(
|
79
|
+
textareaRecipe({ size, variant, resize }),
|
80
|
+
sprinkles({
|
81
|
+
margin,
|
82
|
+
marginTop,
|
83
|
+
marginBottom,
|
84
|
+
marginLeft,
|
85
|
+
marginRight,
|
86
|
+
padding,
|
87
|
+
paddingTop,
|
88
|
+
paddingBottom,
|
89
|
+
paddingLeft,
|
90
|
+
paddingRight,
|
91
|
+
gap,
|
92
|
+
display,
|
93
|
+
flexDirection,
|
94
|
+
justifyContent,
|
95
|
+
flexWrap,
|
96
|
+
flex,
|
97
|
+
width,
|
98
|
+
height,
|
99
|
+
minWidth,
|
100
|
+
maxWidth,
|
101
|
+
minHeight,
|
102
|
+
position,
|
103
|
+
top,
|
104
|
+
bottom,
|
105
|
+
left,
|
106
|
+
right,
|
107
|
+
zIndex,
|
108
|
+
fontSize,
|
109
|
+
fontFamily,
|
110
|
+
lineHeight,
|
111
|
+
textAlign,
|
112
|
+
fontWeight,
|
113
|
+
color,
|
114
|
+
backgroundColor,
|
115
|
+
borderRadius,
|
116
|
+
borderWidth,
|
117
|
+
borderStyle,
|
118
|
+
borderColor,
|
119
|
+
boxShadow,
|
120
|
+
opacity,
|
121
|
+
overflow,
|
122
|
+
overflowX,
|
123
|
+
overflowY,
|
124
|
+
}),
|
125
|
+
css,
|
126
|
+
className
|
127
|
+
)}
|
128
|
+
data-error={hasError}
|
129
|
+
{...htmlProps}
|
130
|
+
/>
|
131
|
+
);
|
132
|
+
}
|
133
|
+
);
|
134
|
+
|
135
|
+
Textarea.displayName = 'Textarea';
|
@@ -0,0 +1,44 @@
|
|
1
|
+
// import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
//
|
3
|
+
// import { TextFieldTextarea } from '../../../../index';
|
4
|
+
//
|
5
|
+
// // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
6
|
+
// const meta: Meta<typeof TextFieldTextarea> = {
|
7
|
+
// title: 'Latte Components / Form / Text Field / Textarea',
|
8
|
+
// component: TextFieldTextarea,
|
9
|
+
// parameters: {
|
10
|
+
// // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
11
|
+
// layout: 'centered',
|
12
|
+
// },
|
13
|
+
// // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
14
|
+
// tags: ['autodocs'],
|
15
|
+
// // More on argTypes: https://storybook.js.org/docs/api/argtypes
|
16
|
+
// argTypes: {},
|
17
|
+
// // 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
|
18
|
+
// };
|
19
|
+
//
|
20
|
+
// export default meta;
|
21
|
+
// type Story = StoryObj<typeof meta>;
|
22
|
+
//
|
23
|
+
// // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
24
|
+
// export const Default: Story = {
|
25
|
+
// args: {},
|
26
|
+
// };
|
27
|
+
//
|
28
|
+
// export const Placeholder: Story = {
|
29
|
+
// args: {
|
30
|
+
// placeholder: "It's a placeholder",
|
31
|
+
// },
|
32
|
+
// };
|
33
|
+
//
|
34
|
+
// export const Disabled: Story = {
|
35
|
+
// args: {
|
36
|
+
// disabled: true,
|
37
|
+
// },
|
38
|
+
// };
|
39
|
+
//
|
40
|
+
// export const Rows10: Story = {
|
41
|
+
// args: {
|
42
|
+
// rows: 10,
|
43
|
+
// },
|
44
|
+
// };
|
@@ -0,0 +1,158 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef, useState } from 'react';
|
3
|
+
import { headerPlaceholder, headerRecipe, type HeaderVariants } from './Header.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
5
|
+
|
6
|
+
export interface HeaderProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Sprinkles, NonNullable<HeaderVariants> {
|
7
|
+
css?: string;
|
8
|
+
isFixed?: boolean; // Legacy prop for backwards compatibility
|
9
|
+
hideToggleNav?: boolean;
|
10
|
+
childrenOverlay?: React.ReactNode;
|
11
|
+
displayToggleNavOnDesktop?: boolean;
|
12
|
+
as?: 'header' | 'div';
|
13
|
+
}
|
14
|
+
|
15
|
+
export const Header = forwardRef<HTMLElement, HeaderProps>(
|
16
|
+
(
|
17
|
+
{
|
18
|
+
children,
|
19
|
+
position,
|
20
|
+
variant,
|
21
|
+
size,
|
22
|
+
isFixed, // Legacy prop
|
23
|
+
hideToggleNav,
|
24
|
+
childrenOverlay,
|
25
|
+
displayToggleNavOnDesktop,
|
26
|
+
as: Component = 'header',
|
27
|
+
css,
|
28
|
+
className,
|
29
|
+
// Extract sprinkles props
|
30
|
+
margin,
|
31
|
+
marginTop,
|
32
|
+
marginBottom,
|
33
|
+
marginLeft,
|
34
|
+
marginRight,
|
35
|
+
padding,
|
36
|
+
paddingTop,
|
37
|
+
paddingBottom,
|
38
|
+
paddingLeft,
|
39
|
+
paddingRight,
|
40
|
+
gap,
|
41
|
+
display,
|
42
|
+
flexDirection,
|
43
|
+
justifyContent,
|
44
|
+
flexWrap,
|
45
|
+
flex,
|
46
|
+
width,
|
47
|
+
height,
|
48
|
+
minWidth,
|
49
|
+
maxWidth,
|
50
|
+
minHeight,
|
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
|
+
const [isNavOpen, setNavOpen] = useState(false);
|
73
|
+
|
74
|
+
// Handle legacy isFixed prop
|
75
|
+
const headerPosition = position || (isFixed ? 'fixed' : 'relative');
|
76
|
+
|
77
|
+
return (
|
78
|
+
<>
|
79
|
+
<Component
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
81
|
+
ref={ref as any}
|
82
|
+
className={clsx(
|
83
|
+
headerRecipe({ variant, size }),
|
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
|
+
zIndex,
|
107
|
+
fontSize,
|
108
|
+
fontFamily,
|
109
|
+
lineHeight,
|
110
|
+
textAlign,
|
111
|
+
fontWeight,
|
112
|
+
color,
|
113
|
+
backgroundColor,
|
114
|
+
borderRadius,
|
115
|
+
borderWidth,
|
116
|
+
borderStyle,
|
117
|
+
borderColor,
|
118
|
+
boxShadow,
|
119
|
+
opacity,
|
120
|
+
overflow,
|
121
|
+
overflowX,
|
122
|
+
overflowY,
|
123
|
+
}),
|
124
|
+
css,
|
125
|
+
className
|
126
|
+
)}
|
127
|
+
{...htmlProps}>
|
128
|
+
{/* Overlay for mobile navigation */}
|
129
|
+
{childrenOverlay && <div className={clsx('header-overlay', isNavOpen && 'header-overlay--open')}>{childrenOverlay}</div>}
|
130
|
+
|
131
|
+
{children}
|
132
|
+
|
133
|
+
{/* Toggle navigation button */}
|
134
|
+
{!hideToggleNav && (
|
135
|
+
<button
|
136
|
+
type="button"
|
137
|
+
className="header-nav-toggle"
|
138
|
+
onClick={() => setNavOpen(!isNavOpen)}
|
139
|
+
aria-expanded={isNavOpen}
|
140
|
+
aria-label="Toggle navigation">
|
141
|
+
<span className="sr-only">Toggle navigation</span>
|
142
|
+
<div className={`hamburger ${isNavOpen ? 'hamburger--open' : ''}`}>
|
143
|
+
<span></span>
|
144
|
+
<span></span>
|
145
|
+
<span></span>
|
146
|
+
</div>
|
147
|
+
</button>
|
148
|
+
)}
|
149
|
+
</Component>
|
150
|
+
|
151
|
+
{/* Placeholder for fixed headers */}
|
152
|
+
{(headerPosition === 'fixed' || isFixed) && <div className={headerPlaceholder} />}
|
153
|
+
</>
|
154
|
+
);
|
155
|
+
}
|
156
|
+
);
|
157
|
+
|
158
|
+
Header.displayName = 'Header';
|