nave-ui-library 1.0.0-beta.1
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/base/Badge.d.ts +11 -0
- package/dist/components/base/Badge.js +29 -0
- package/dist/components/base/Button.d.ts +8 -0
- package/dist/components/base/Button.js +40 -0
- package/dist/components/base/Checkbox.d.ts +8 -0
- package/dist/components/base/Checkbox.js +27 -0
- package/dist/components/base/Icon.d.ts +26 -0
- package/dist/components/base/Icon.js +39 -0
- package/dist/components/base/Input.d.ts +7 -0
- package/dist/components/base/Input.js +18 -0
- package/dist/components/base/Label.d.ts +8 -0
- package/dist/components/base/Label.js +18 -0
- package/dist/components/base/Radio.d.ts +2 -0
- package/dist/components/base/Radio.js +34 -0
- package/dist/components/base/Select.d.ts +16 -0
- package/dist/components/base/Select.js +31 -0
- package/dist/components/base/Switch.d.ts +8 -0
- package/dist/components/base/Switch.js +42 -0
- package/dist/components/base/Tooltip.d.ts +12 -0
- package/dist/components/base/Tooltip.js +41 -0
- package/dist/components/base/index.d.ts +10 -0
- package/dist/components/base/index.js +10 -0
- package/dist/components/base/native-only-animated-view.d.ts +12 -0
- package/dist/components/base/native-only-animated-view.js +22 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/core/cn.d.ts +2 -0
- package/dist/core/cn.js +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/native/button.native.d.ts +7 -0
- package/dist/native/button.native.js +6 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.js +1 -0
- package/dist/theme/ThemeContext.d.ts +7 -0
- package/dist/theme/ThemeContext.js +14 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +3 -0
- package/dist/theme/resolveTokens.d.ts +1 -0
- package/dist/theme/resolveTokens.js +13 -0
- package/dist/theme/theme-context.d.ts +3 -0
- package/dist/theme/theme-context.js +13 -0
- package/dist/theme/theme-resolver.d.ts +55 -0
- package/dist/theme/theme-resolver.js +74 -0
- package/dist/theme/theme.d.ts +3 -0
- package/dist/theme/theme.js +7 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +5 -0
- package/dist/web/Badge.web.d.ts +9 -0
- package/dist/web/Badge.web.js +22 -0
- package/dist/web/Button.web.d.ts +8 -0
- package/dist/web/Button.web.js +29 -0
- package/dist/web/Checkbox.web.d.ts +7 -0
- package/dist/web/Checkbox.web.js +32 -0
- package/dist/web/Icon.web.d.ts +26 -0
- package/dist/web/Icon.web.js +39 -0
- package/dist/web/Input.web.d.ts +6 -0
- package/dist/web/Input.web.js +37 -0
- package/dist/web/Label.web.d.ts +4 -0
- package/dist/web/Label.web.js +8 -0
- package/dist/web/Radio.web.d.ts +10 -0
- package/dist/web/Radio.web.js +41 -0
- package/dist/web/Select.web.d.ts +14 -0
- package/dist/web/Select.web.js +35 -0
- package/dist/web/Switch.web.d.ts +7 -0
- package/dist/web/Switch.web.js +38 -0
- package/dist/web/Tooltip.web.d.ts +7 -0
- package/dist/web/Tooltip.web.js +17 -0
- package/dist/web/button.d.ts +5 -0
- package/dist/web/button.js +10 -0
- package/dist/web/index.d.ts +10 -0
- package/dist/web/index.js +10 -0
- package/dist/web/native-only-animated-view.d.ts +12 -0
- package/dist/web/native-only-animated-view.js +22 -0
- package/dist/web/text.d.ts +12 -0
- package/dist/web/text.js +51 -0
- package/package.json +62 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
declare const badgeVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "secondary" | "destructive" | "outline" | null | undefined;
|
|
5
|
+
} & import("node_modules/class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
6
|
+
declare function Badge({ className, variant, asChild, tokens, style, platform, ...props }: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
tokens?: any;
|
|
9
|
+
platform?: 'web' | 'native';
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
6
|
+
const badgeVariants = cva('inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden', {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: '',
|
|
10
|
+
secondary: '',
|
|
11
|
+
destructive: '',
|
|
12
|
+
outline: '',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
variant: 'default',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
function Badge({ className, variant, asChild = false, tokens, style, platform = 'web', ...props }) {
|
|
20
|
+
const Comp = asChild ? Slot : 'span';
|
|
21
|
+
const theme = useTheme();
|
|
22
|
+
//merge tokens | depende de plataforma Web o Android/iOS
|
|
23
|
+
const mergedTokens = resolveTokens({ componentName: 'badge', variant, tokens }, theme);
|
|
24
|
+
const styles = platform === 'web'
|
|
25
|
+
? { ...resolveWebStyles(mergedTokens), ...style }
|
|
26
|
+
: resolveNativeStyles(mergedTokens);
|
|
27
|
+
return (_jsx(Comp, { "data-slot": "badge", className: cn(badgeVariants({ variant }), className), style: styles, ...props }));
|
|
28
|
+
}
|
|
29
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function Button({ className, variant, size, asChild, tokens, style, platform, children, ...props }: React.ComponentProps<'button'> & {
|
|
3
|
+
tokens?: any;
|
|
4
|
+
variant?: string;
|
|
5
|
+
size?: any;
|
|
6
|
+
platform?: 'web' | 'native';
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { cn } from '../../utils/cn';
|
|
6
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
7
|
+
const buttonBaseClasses = cva('inline-flex items-center justify-center whitespace-nowrap font-medium transition-all disabled:pointer-events-none disabled:opacity-50 outline-none', {
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: '',
|
|
11
|
+
destructive: '',
|
|
12
|
+
outline: '',
|
|
13
|
+
secondary: '',
|
|
14
|
+
ghost: '',
|
|
15
|
+
link: '',
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: '',
|
|
19
|
+
sm: '',
|
|
20
|
+
lg: '',
|
|
21
|
+
icon: 'size-9',
|
|
22
|
+
'icon-sm': 'size-8',
|
|
23
|
+
'icon-lg': 'size-10',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
variant: 'default',
|
|
28
|
+
size: 'default',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
export function Button({ className, variant, size, asChild = false, tokens, style, platform = 'web', children, ...props }) {
|
|
32
|
+
const theme = useTheme();
|
|
33
|
+
//merge tokens | depende de plataforma Web o Android/iOS
|
|
34
|
+
const mergedTokens = resolveTokens({ componentName: 'button', variant, size, tokens }, theme);
|
|
35
|
+
const styles = platform === 'web'
|
|
36
|
+
? { ...resolveWebStyles(mergedTokens), ...style }
|
|
37
|
+
: resolveNativeStyles(mergedTokens);
|
|
38
|
+
const Comp = asChild ? Slot : 'button';
|
|
39
|
+
return (_jsx(Comp, { "data-slot": "button", className: cn(buttonBaseClasses({ size }), className), style: styles, ...props, children: children }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
3
|
+
interface Props extends React.ComponentProps<typeof CheckboxPrimitive.Root> {
|
|
4
|
+
tokens?: any;
|
|
5
|
+
platform?: 'web' | 'mobile';
|
|
6
|
+
}
|
|
7
|
+
export declare function Checkbox({ className, tokens, style, platform, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
4
|
+
import { CheckIcon } from 'lucide-react';
|
|
5
|
+
import { cn } from '../../utils/cn';
|
|
6
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
7
|
+
export function Checkbox({ className, tokens, style, platform = 'web', ...props }) {
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
const mergedTokens = resolveTokens({ componentName: 'checkbox', tokens }, theme);
|
|
10
|
+
const styles = platform === 'web'
|
|
11
|
+
? { ...resolveWebStyles(mergedTokens), ...style }
|
|
12
|
+
: resolveNativeStyles(mergedTokens);
|
|
13
|
+
const stylesReafactoring = {
|
|
14
|
+
...styles,
|
|
15
|
+
width: '25px',
|
|
16
|
+
height: '25px',
|
|
17
|
+
display: 'inline-flex',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
justifyContent: 'center',
|
|
20
|
+
};
|
|
21
|
+
return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer shrink-0', 'transition-all outline-none', className), style: stylesReafactoring, ...props, children: _jsx(CheckboxPrimitive.Indicator, { "data-slot": "checkbox-indicator", style: {
|
|
22
|
+
color: stylesReafactoring.checkColor,
|
|
23
|
+
display: 'flex',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
}, children: _jsx(CheckIcon, { width: 20, height: 20 }) }) }));
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LucideIcon, LucideProps } from 'lucide-react';
|
|
2
|
+
type IconProps = LucideProps & {
|
|
3
|
+
as: LucideIcon;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* A wrapper component for Lucide icons with Nativewind `className` support via `cssInterop`.
|
|
7
|
+
*
|
|
8
|
+
* This component allows you to render any Lucide icon while applying utility classes
|
|
9
|
+
* using `nativewind`. It avoids the need to wrap or configure each icon individually.
|
|
10
|
+
*
|
|
11
|
+
* @component
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { ArrowRight } from 'lucide-react-native';
|
|
15
|
+
* import { Icon } from '@/registry/components/ui/icon';
|
|
16
|
+
*
|
|
17
|
+
* <Icon as={ArrowRight} className="text-red-500" size={16} />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param {LucideIcon} as - The Lucide icon component to render.
|
|
21
|
+
* @param {string} className - Utility classes to style the icon using Nativewind.
|
|
22
|
+
* @param {number} size - Icon size (defaults to 14).
|
|
23
|
+
* @param {...LucideProps} ...props - Additional Lucide icon props passed to the "as" icon.
|
|
24
|
+
*/
|
|
25
|
+
declare function Icon({ as: IconComponent, className, size, ...props }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export { Icon };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { cssInterop } from 'nativewind';
|
|
4
|
+
function IconImpl({ as: IconComponent, ...props }) {
|
|
5
|
+
return _jsx(IconComponent, { ...props });
|
|
6
|
+
}
|
|
7
|
+
cssInterop(IconImpl, {
|
|
8
|
+
className: {
|
|
9
|
+
target: 'style',
|
|
10
|
+
nativeStyleToProp: {
|
|
11
|
+
height: 'size',
|
|
12
|
+
width: 'size',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* A wrapper component for Lucide icons with Nativewind `className` support via `cssInterop`.
|
|
18
|
+
*
|
|
19
|
+
* This component allows you to render any Lucide icon while applying utility classes
|
|
20
|
+
* using `nativewind`. It avoids the need to wrap or configure each icon individually.
|
|
21
|
+
*
|
|
22
|
+
* @component
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { ArrowRight } from 'lucide-react-native';
|
|
26
|
+
* import { Icon } from '@/registry/components/ui/icon';
|
|
27
|
+
*
|
|
28
|
+
* <Icon as={ArrowRight} className="text-red-500" size={16} />
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param {LucideIcon} as - The Lucide icon component to render.
|
|
32
|
+
* @param {string} className - Utility classes to style the icon using Nativewind.
|
|
33
|
+
* @param {number} size - Icon size (defaults to 14).
|
|
34
|
+
* @param {...LucideProps} ...props - Additional Lucide icon props passed to the "as" icon.
|
|
35
|
+
*/
|
|
36
|
+
function Icon({ as: IconComponent, className, size = 14, ...props }) {
|
|
37
|
+
return (_jsx(IconImpl, { as: IconComponent, className: cn('text-foreground', className), size: size, ...props }));
|
|
38
|
+
}
|
|
39
|
+
export { Icon };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface InputProps extends React.ComponentProps<'input'> {
|
|
3
|
+
tokens?: any;
|
|
4
|
+
platform?: 'web' | 'mobile';
|
|
5
|
+
}
|
|
6
|
+
export declare function Input({ className, type, tokens, platform, style, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from '../../utils/cn';
|
|
4
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
5
|
+
export function Input({ className, type, tokens, platform = 'web', style, ...props }) {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const mergedTokens = resolveTokens({ componentName: 'input', tokens }, theme);
|
|
8
|
+
const styles = platform === 'web'
|
|
9
|
+
? { ...resolveWebStyles(mergedTokens), ...style }
|
|
10
|
+
: resolveNativeStyles(mergedTokens);
|
|
11
|
+
return (_jsx("input", { type: type, "data-slot": "input", className: cn('outline-none disabled:pointer-events-none disabled:opacity-50', className), style: styles, onFocus: (e) => {
|
|
12
|
+
e.target.style.borderColor = styles.borderColor;
|
|
13
|
+
e.target.style.borderWidth = styles.borderWidth;
|
|
14
|
+
}, onBlur: (e) => {
|
|
15
|
+
e.target.style.borderColor = styles.borderColor;
|
|
16
|
+
e.target.style.borderWidth = styles.borderWidth;
|
|
17
|
+
}, placeholder: props.placeholder, ...props }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
3
|
+
interface LabelProps extends React.ComponentProps<typeof LabelPrimitive.Root> {
|
|
4
|
+
platform?: 'web' | 'mobile';
|
|
5
|
+
tokens?: any;
|
|
6
|
+
}
|
|
7
|
+
export declare function Label({ className, tokens, platform, style, ...props }: LabelProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
6
|
+
export function Label({ className, tokens, platform = 'web', style, ...props }) {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const mergedTokens = resolveTokens({ componentName: 'label', tokens }, theme);
|
|
9
|
+
const styles = platform === 'web'
|
|
10
|
+
? { ...resolveWebStyles(mergedTokens), ...style }
|
|
11
|
+
: resolveNativeStyles(mergedTokens);
|
|
12
|
+
const stylesReafactoring = {
|
|
13
|
+
...styles,
|
|
14
|
+
display: 'block',
|
|
15
|
+
width: 'auto',
|
|
16
|
+
};
|
|
17
|
+
return (_jsx(LabelPrimitive.Root, { style: stylesReafactoring, "data-slot": "label", className: cn('flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50', className), ...props }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
4
|
+
import { CircleIcon } from 'lucide-react';
|
|
5
|
+
import { cn } from '../../utils/cn';
|
|
6
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
7
|
+
export function RadioGroup({ className, ...props }) {
|
|
8
|
+
return (_jsx(RadioGroupPrimitive.Root, { "data-slot": "radio-group", className: cn('grid gap-3', className), ...props }));
|
|
9
|
+
}
|
|
10
|
+
export function RadioGroupItem({ className, tokens, style, platform = 'web', value, ...props }) {
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
const mergedTokens = resolveTokens({ componentName: 'radio', tokens }, theme);
|
|
13
|
+
const styles = platform === 'web'
|
|
14
|
+
? resolveWebStyles(mergedTokens)
|
|
15
|
+
: resolveNativeStyles(mergedTokens);
|
|
16
|
+
const stylesReafactoring = {
|
|
17
|
+
...styles,
|
|
18
|
+
width: styles.width || '28px',
|
|
19
|
+
height: mergedTokens.height || '28px',
|
|
20
|
+
display: 'inline-flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
borderRadius: '50%',
|
|
24
|
+
};
|
|
25
|
+
return (_jsx(RadioGroupPrimitive.Item, { value: value, "data-slot": "radio-group-item", className: cn('shrink-0 rounded-full transition-all outline-none', className), style: stylesReafactoring, ...props, children: _jsx(RadioGroupPrimitive.Indicator, { "data-slot": "radio-group-indicator", style: {
|
|
26
|
+
display: 'flex',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
}, children: _jsx(CircleIcon, { style: {
|
|
30
|
+
width: '14px',
|
|
31
|
+
height: '14px',
|
|
32
|
+
fill: stylesReafactoring.checkColor ?? '#000',
|
|
33
|
+
} }) }) }));
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SelectItem {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
interface Props {
|
|
6
|
+
value?: string;
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
items: SelectItem[];
|
|
10
|
+
className?: string;
|
|
11
|
+
tokens?: any;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
platform?: 'web' | 'native';
|
|
14
|
+
}
|
|
15
|
+
export declare function Select({ value, onValueChange, placeholder, items, className, tokens, platform, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
4
|
+
import { Check, ChevronsUpDown } from 'lucide-react';
|
|
5
|
+
import { cn } from '../../utils/cn';
|
|
6
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
7
|
+
export function Select({ value, onValueChange, placeholder = 'Seleccionar...', items, className, tokens, platform = 'web', }) {
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
// 🔥 1. RESOLVER TOKENS
|
|
10
|
+
const mergedTokens = resolveTokens({ componentName: 'select', tokens }, theme);
|
|
11
|
+
// 🔥 2. RESOLVER ESTILOS BASE PARA WEB O NATIVE
|
|
12
|
+
const styles = platform === 'web'
|
|
13
|
+
? resolveWebStyles(mergedTokens)
|
|
14
|
+
: resolveNativeStyles(mergedTokens);
|
|
15
|
+
// 🔥 3. ESTILOS ESPECÍFICOS PARA SUBCOMPONENTES
|
|
16
|
+
const triggerStyle = {
|
|
17
|
+
...styles,
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'space-between',
|
|
21
|
+
width: '100%',
|
|
22
|
+
};
|
|
23
|
+
const itemStyle = {
|
|
24
|
+
fontSize: styles.fontSize,
|
|
25
|
+
padding: mergedTokens.padding ?? '10px',
|
|
26
|
+
};
|
|
27
|
+
return (_jsxs(SelectPrimitive.Root, { value: value, onValueChange: onValueChange, children: [_jsxs(SelectPrimitive.Trigger, { className: cn('outline-none', className), style: triggerStyle, children: [_jsx(SelectPrimitive.Value, { placeholder: placeholder, style: { color: styles.color } }), _jsx(SelectPrimitive.Icon, { children: _jsx(ChevronsUpDown, { className: "h-4 w-4 opacity-50" }) })] }), _jsx(SelectPrimitive.Content, { className: "relative z-50 w-full shadow-lg rounded-md", style: {
|
|
28
|
+
backgroundColor: mergedTokens.dropdownBackground ?? '#FFFFFF',
|
|
29
|
+
borderRadius: mergedTokens.borderRadius ?? '6px',
|
|
30
|
+
}, children: _jsx(SelectPrimitive.Viewport, { className: "p-1", children: items.map((item) => (_jsxs(SelectPrimitive.Item, { value: item.value, className: "relative flex cursor-pointer select-none items-center rounded-sm outline-none hover:bg-gray-100", style: itemStyle, children: [_jsx(SelectPrimitive.ItemText, { children: item.label }), _jsx(SelectPrimitive.ItemIndicator, { className: "absolute right-2 flex items-center", children: _jsx(Check, { className: "h-4 w-4" }) })] }, item.value))) }) })] }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
3
|
+
interface SwitchProps extends React.ComponentProps<typeof SwitchPrimitive.Root> {
|
|
4
|
+
tokens?: any;
|
|
5
|
+
platform?: 'web' | 'native';
|
|
6
|
+
}
|
|
7
|
+
declare const Switch: ({ className, tokens, style, platform, ...props }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export { Switch };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
6
|
+
const Switch = ({ className, tokens, style, platform = 'web', ...props }) => {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const mergedTokens = resolveTokens({ componentName: 'switch', tokens }, theme);
|
|
9
|
+
const styles = platform === 'web'
|
|
10
|
+
? resolveWebStyles(mergedTokens)
|
|
11
|
+
: resolveNativeStyles(mergedTokens);
|
|
12
|
+
const stylesReafactoring = {
|
|
13
|
+
...styles,
|
|
14
|
+
trackWidth: mergedTokens?.trackWidth ?? 36,
|
|
15
|
+
trackHeight: mergedTokens?.trackHeight ?? 20,
|
|
16
|
+
backgroundColor: mergedTokens?.backgroundColor ?? '#CCCCCC',
|
|
17
|
+
activeBackgroundColor: mergedTokens?.activeBackgroundColor ?? '#652BDF',
|
|
18
|
+
thumbSize: mergedTokens?.thumbSize ?? 16,
|
|
19
|
+
thumbColor: mergedTokens?.thumbColor ?? '#FFFFFF',
|
|
20
|
+
transitionDuration: mergedTokens?.transitionDuration ?? '150ms',
|
|
21
|
+
};
|
|
22
|
+
return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", className: cn('peer inline-flex items-center rounded-full border border-transparent shadow-xs outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50', className), style: {
|
|
23
|
+
width: stylesReafactoring.trackWidth,
|
|
24
|
+
height: stylesReafactoring.trackHeight,
|
|
25
|
+
backgroundColor: props.checked
|
|
26
|
+
? stylesReafactoring.activeBackgroundColor
|
|
27
|
+
: stylesReafactoring.backgroundColor,
|
|
28
|
+
transition: `background-color ${stylesReafactoring.transitionDuration}`,
|
|
29
|
+
}, ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "pointer-events-none block rounded-full", style: {
|
|
30
|
+
width: stylesReafactoring.thumbSize,
|
|
31
|
+
height: stylesReafactoring.thumbSize,
|
|
32
|
+
backgroundColor: stylesReafactoring.thumbColor,
|
|
33
|
+
transform: props.checked
|
|
34
|
+
? `translateX(${stylesReafactoring.trackWidth - stylesReafactoring.thumbSize}px)`
|
|
35
|
+
: 'translateX(0)',
|
|
36
|
+
transition: `transform ${stylesReafactoring.transitionDuration}`,
|
|
37
|
+
boxShadow: props.checked
|
|
38
|
+
? '0 0 8px rgba(101, 43, 223, 0.6)'
|
|
39
|
+
: '0 0 4px rgba(0,0,0,0.2)',
|
|
40
|
+
} }) }));
|
|
41
|
+
};
|
|
42
|
+
export { Switch };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
3
|
+
export declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function Tooltip({ tokens, platform, ...props }: React.ComponentProps<typeof TooltipPrimitive.Root> & {
|
|
5
|
+
tokens?: any;
|
|
6
|
+
platform?: 'web' | 'native';
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function TooltipContent({ className, sideOffset, tokens, platform, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content> & {
|
|
10
|
+
tokens?: any;
|
|
11
|
+
platform?: 'web' | 'native';
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import { resolveNativeStyles, resolveTokens, resolveWebStyles, useTheme, } from '../../theme';
|
|
6
|
+
/* --------------------- */
|
|
7
|
+
/* PROVIDER */
|
|
8
|
+
/* --------------------- */
|
|
9
|
+
export function TooltipProvider({ delayDuration = 0, ...props }) {
|
|
10
|
+
return (_jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delayDuration: delayDuration, ...props }));
|
|
11
|
+
}
|
|
12
|
+
/* --------------------- */
|
|
13
|
+
/* ROOT (Tooltip) */
|
|
14
|
+
/* --------------------- */
|
|
15
|
+
export function Tooltip({ tokens, platform = 'web', ...props }) {
|
|
16
|
+
return (_jsx(TooltipProvider, { children: _jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) }));
|
|
17
|
+
}
|
|
18
|
+
/* --------------------- */
|
|
19
|
+
/* TRIGGER */
|
|
20
|
+
/* --------------------- */
|
|
21
|
+
export function TooltipTrigger({ ...props }) {
|
|
22
|
+
return _jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
23
|
+
}
|
|
24
|
+
/* --------------------- */
|
|
25
|
+
/* CONTENT */
|
|
26
|
+
/* --------------------- */
|
|
27
|
+
export function TooltipContent({ className, sideOffset = 4, tokens, platform = 'web', children, ...props }) {
|
|
28
|
+
const theme = useTheme();
|
|
29
|
+
const mergedTokens = resolveTokens({ componentName: 'tooltip', tokens }, theme);
|
|
30
|
+
const styles = platform === 'web'
|
|
31
|
+
? resolveWebStyles(mergedTokens)
|
|
32
|
+
: resolveNativeStyles(mergedTokens);
|
|
33
|
+
return (_jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, { "data-slot": "tooltip-content", sideOffset: sideOffset, className: cn('animate-in fade-in-0 zoom-in-95 ' +
|
|
34
|
+
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 ' +
|
|
35
|
+
'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 ' +
|
|
36
|
+
'data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ' +
|
|
37
|
+
'z-50 w-fit rounded-md px-3 py-1.5 text-xs', className), style: styles, ...props, children: [children, _jsx(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]", style: {
|
|
38
|
+
backgroundColor: styles.backgroundColor,
|
|
39
|
+
fill: styles.backgroundColor,
|
|
40
|
+
} })] }) }));
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './Badge';
|
|
2
|
+
export * from './Button';
|
|
3
|
+
export * from './Checkbox';
|
|
4
|
+
export * from './Icon';
|
|
5
|
+
export * from './Input';
|
|
6
|
+
export * from './Label';
|
|
7
|
+
export * from './Radio';
|
|
8
|
+
export * from './Select';
|
|
9
|
+
export * from './Switch';
|
|
10
|
+
export * from './Tooltip';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './Badge';
|
|
2
|
+
export * from './Button';
|
|
3
|
+
export * from './Checkbox';
|
|
4
|
+
export * from './Icon';
|
|
5
|
+
export * from './Input';
|
|
6
|
+
export * from './Label';
|
|
7
|
+
export * from './Radio';
|
|
8
|
+
export * from './Select';
|
|
9
|
+
export * from './Switch';
|
|
10
|
+
export * from './Tooltip';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Animated from 'react-native-reanimated';
|
|
2
|
+
/**
|
|
3
|
+
* This component is used to wrap animated views that should only be animated on native.
|
|
4
|
+
* @param props - The props for the animated view.
|
|
5
|
+
* @returns The animated view if the platform is native, otherwise the children.
|
|
6
|
+
* @example
|
|
7
|
+
* <NativeOnlyAnimatedView entering={FadeIn} exiting={FadeOut}>
|
|
8
|
+
* <Text>I am only animated on native</Text>
|
|
9
|
+
* </NativeOnlyAnimatedView>
|
|
10
|
+
*/
|
|
11
|
+
declare function NativeOnlyAnimatedView(props: React.ComponentProps<typeof Animated.View> & React.RefAttributes<Animated.View>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export { NativeOnlyAnimatedView };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import Animated from 'react-native-reanimated';
|
|
5
|
+
/**
|
|
6
|
+
* This component is used to wrap animated views that should only be animated on native.
|
|
7
|
+
* @param props - The props for the animated view.
|
|
8
|
+
* @returns The animated view if the platform is native, otherwise the children.
|
|
9
|
+
* @example
|
|
10
|
+
* <NativeOnlyAnimatedView entering={FadeIn} exiting={FadeOut}>
|
|
11
|
+
* <Text>I am only animated on native</Text>
|
|
12
|
+
* </NativeOnlyAnimatedView>
|
|
13
|
+
*/
|
|
14
|
+
function NativeOnlyAnimatedView(props) {
|
|
15
|
+
if (Platform.OS === 'web') {
|
|
16
|
+
return _jsx(_Fragment, { children: props.children });
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return _jsx(Animated.View, { ...props });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export { NativeOnlyAnimatedView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base';
|
package/dist/core/cn.js
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PressableProps } from "react-native";
|
|
2
|
+
interface ButtonNativeProps extends PressableProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function ButtonNative({ className, children, ...props }: ButtonNativeProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, Text } from "react-native";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
export function ButtonNative({ className, children, ...props }) {
|
|
5
|
+
return (_jsx(Pressable, { className: cn("px-4 py-2 rounded-lg bg-purple-600 active:bg-purple-700", className), ...props, children: _jsx(Text, { className: "text-white font-semibold", children: children }) }));
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './button.native';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './button.native';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type Theme = Record<string, any>;
|
|
3
|
+
export declare function ThemeProvider({ theme, children, }: {
|
|
4
|
+
theme: Theme;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function useTheme(): Theme;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
const ThemeContext = createContext(null);
|
|
5
|
+
export function ThemeProvider({ theme, children, }) {
|
|
6
|
+
return (_jsx(ThemeContext.Provider, { value: theme, children: children }));
|
|
7
|
+
}
|
|
8
|
+
export function useTheme() {
|
|
9
|
+
const ctx = useContext(ThemeContext);
|
|
10
|
+
if (!ctx) {
|
|
11
|
+
throw new Error("useTheme debe usarse dentro de un <ThemeProvider>");
|
|
12
|
+
}
|
|
13
|
+
return ctx;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveTokens(input: any, theme: any): any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function resolveTokens(input, theme) {
|
|
2
|
+
const { componentName, variant, size, ...localTokens } = input;
|
|
3
|
+
const componentTheme = theme?.components?.[componentName] ?? {};
|
|
4
|
+
const base = componentTheme.base ?? {};
|
|
5
|
+
const variantTokens = componentTheme.variants?.[variant] ?? {};
|
|
6
|
+
const sizeTokens = componentTheme.sizes?.[size] ?? {};
|
|
7
|
+
return {
|
|
8
|
+
...base,
|
|
9
|
+
...variantTokens,
|
|
10
|
+
...sizeTokens,
|
|
11
|
+
...localTokens, // el componente siempre gana
|
|
12
|
+
};
|
|
13
|
+
}
|