@latte-macchiat-io/latte-vanilla-components 0.0.522 → 0.0.523

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latte-macchiat-io/latte-vanilla-components",
3
- "version": "0.0.522",
3
+ "version": "0.0.523",
4
4
  "description": "Beautiful components for amazing projects, with a touch of Vanilla 🥤",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -1,19 +1,20 @@
1
1
  import { useMemo } from 'react';
2
2
 
3
- import { errorMessage, messageContainer, selectLabel, selectRecipe, selectWrapper, selectWrapperSelect } from './styles.css';
3
+ import { errorMessage, messageContainer, selectLabel, selectRecipe, SelectVariants, selectWrapper, selectWrapperSelect } from './styles.css';
4
4
 
5
5
  import { cn } from '../../../utils/styleOverride';
6
6
 
7
- export type SelectProps = React.SelectHTMLAttributes<HTMLSelectElement> & {
8
- name: string;
9
- label?: string;
10
- icon?: React.ReactNode;
11
- onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
12
- errors?: string | string[];
13
- options: { disabled: boolean; value: string; label: string }[];
14
- };
7
+ export type SelectProps = React.SelectHTMLAttributes<HTMLSelectElement> &
8
+ SelectVariants & {
9
+ name: string;
10
+ label?: string;
11
+ icon?: React.ReactNode;
12
+ onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
13
+ errors?: string | string[];
14
+ options: { disabled: boolean; value: string; label: string }[];
15
+ };
15
16
 
16
- export const Select = ({ options, className, errors, label, name, required, onChange, icon }: SelectProps) => {
17
+ export const Select = ({ options, className, errors, label, labelPosition, name, required, onChange, icon }: SelectProps) => {
17
18
  const hasErrors = useMemo(() => {
18
19
  if (!errors) return false;
19
20
  if (Array.isArray(errors)) return errors.length > 0;
@@ -21,7 +22,7 @@ export const Select = ({ options, className, errors, label, name, required, onCh
21
22
  }, [errors]);
22
23
 
23
24
  return (
24
- <div className={cn(selectRecipe(), className)}>
25
+ <div className={cn(selectRecipe({ labelPosition }), className)}>
25
26
  {label && (
26
27
  <label htmlFor={name} className={selectLabel}>
27
28
  {label}
@@ -10,6 +10,27 @@ export const selectRecipe = recipe(
10
10
  width: '100%',
11
11
  transition: 'all 0.2s ease-in-out',
12
12
  },
13
+
14
+ variants: {
15
+ labelPosition: {
16
+ top: {
17
+ flexDirection: 'column',
18
+ alignItems: 'stretch',
19
+ },
20
+ side: {
21
+ flexDirection: 'row',
22
+ alignItems: 'center',
23
+
24
+ '@media': generateResponsiveMedia({
25
+ gap: themeContract.form.row.gap,
26
+ }),
27
+ },
28
+ },
29
+ },
30
+
31
+ defaultVariants: {
32
+ labelPosition: 'top',
33
+ },
13
34
  },
14
35
  'select'
15
36
  );