native-variants 0.1.63 → 0.1.69

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.
Files changed (37) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +125 -125
  3. package/dist/example.js +1 -0
  4. package/dist/index.d.ts +17 -8
  5. package/dist/index.js +72 -22
  6. package/dist/index.js.map +1 -1
  7. package/dist/lib/cn.d.ts +82 -2
  8. package/dist/lib/cn.js +138 -8
  9. package/dist/lib/cn.js.map +1 -1
  10. package/dist/lib/create-nva.d.ts +209 -6
  11. package/dist/lib/create-nva.js +460 -47
  12. package/dist/lib/create-nva.js.map +1 -1
  13. package/dist/lib/media-query.d.ts +84 -2
  14. package/dist/lib/media-query.js +103 -9
  15. package/dist/lib/media-query.js.map +1 -1
  16. package/dist/provider/create-provider.d.ts +44 -4
  17. package/dist/provider/create-provider.js +1 -1
  18. package/dist/provider/create-provider.jsx +110 -9
  19. package/dist/provider/create-provider.jsx.map +1 -1
  20. package/dist/provider/theme-provider.d.ts +266 -0
  21. package/dist/provider/theme-provider.js +1 -0
  22. package/dist/provider/theme-provider.jsx +328 -0
  23. package/dist/provider/theme-provider.jsx.map +1 -0
  24. package/dist/tokens/default-tokens.d.ts +2737 -0
  25. package/dist/tokens/default-tokens.js +1067 -0
  26. package/dist/tokens/default-tokens.js.map +1 -0
  27. package/dist/types.d.ts +318 -3
  28. package/dist/utils/alpha.d.ts +68 -0
  29. package/dist/utils/alpha.js +147 -4
  30. package/dist/utils/alpha.js.map +1 -1
  31. package/dist/utils/compose-text.d.ts +64 -2
  32. package/dist/utils/compose-text.js +103 -3
  33. package/dist/utils/compose-text.js.map +1 -1
  34. package/package.json +1 -1
  35. package/dist/utils/compose-refs.d.ts +0 -4
  36. package/dist/utils/compose-refs.js +0 -39
  37. package/dist/utils/compose-refs.js.map +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Matheus Figueiredo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Matheus Figueiredo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,126 +1,126 @@
1
-
2
- <h1 align='center'>native-variants</h1>
3
-
4
- Simplify and streamline style management in React
5
- Native with TypeScript support
6
-
7
-
8
- <h4>Installation</h4>
9
-
10
-
11
- Install `native-variants` using npm or yarn:
12
-
13
-
14
- ```bash
15
- npm install native-variants
16
- //or
17
- yarn add native-variants
18
- ```
19
-
20
- <h4>Overview</h4>
21
-
22
- `native-variants` provides a powerful utility to define, organize, and apply component styling for React Native. It supports multiple slots, variants, default settings, and compound variants, enabling a clean and reusable way to manage styles.
23
-
24
- <h3>Getting Started</h3>
25
-
26
- Here’s a quick example of how to use `native-variants` to style a button component.
27
-
28
-
29
- <h4>Defining Variants</h4>
30
-
31
- ```tsx
32
- import { nv, type VariantProps } from "native-variants";
33
-
34
- const buttonVariants = nv({
35
- slots: ["root", "text"], // Define slots for styling
36
- base: {
37
- root: { paddingHorizontal: 16, paddingVertical: 12 }, // Base styles for root
38
- text: { color: "white", textAlign: "center" }, // Base styles for text
39
- },
40
- variants: {
41
- variant: {
42
- solid: {
43
- root: { backgroundColor: "#ff0006" },
44
- text: { color: "white" },
45
- },
46
- ghost: {
47
- root: { backgroundColor: "transparent" },
48
- text: { color: "#ff0006" },
49
- },
50
- },
51
- },
52
- defaultVariants: {
53
- variant: "solid", // Default variant configuration
54
- },
55
- compoundVariants: [
56
- {
57
- variant: "ghost",
58
- css: {
59
- root: { borderWidth: 1, borderColor: "#fff006" },
60
- },
61
- },
62
- ],
63
- });
64
- ```
65
-
66
- <h4>Using the Variants</h4>
67
-
68
- Create a styled `Button` component:
69
-
70
- ```tsx
71
- import React from "react";
72
- import { Text, TouchableOpacity } from "react-native";
73
-
74
- export interface ButtonProps
75
- extends React.ComponentPropsWithoutRef<typeof TouchableOpacity>,
76
- VariantProps<typeof buttonVariants> {}
77
-
78
- export const Button = React.forwardRef<
79
- React.ComponentRef<typeof TouchableOpacity>,
80
- ButtonProps
81
- >(({ children, variant, ...props }, ref) => {
82
- const { root, text } = buttonVariants({ variant });
83
-
84
- return (
85
- <TouchableOpacity {...props} ref={ref} style={root}>
86
- <Text style={text}>{children}</Text>
87
- </TouchableOpacity>
88
- );
89
- });
90
-
91
- Button.displayName = "Button";
92
- ```
93
-
94
- <h4>Usage Example</h4>
95
-
96
-
97
- ```tsx
98
- import { Button } from "./Button";
99
-
100
- export default function App() {
101
- return (
102
- <>
103
- <Button variant="solid">Solid Button</Button>
104
- <Button variant="ghost">Ghost Button</Button>
105
- </>
106
- );
107
- }
108
- ```
109
-
110
- <h3>Features</h3>
111
-
112
- 1. **Multi-Slot Styling**: Define styles for multiple slots (e.g., `root`, `text`).
113
- 2. **Variant Management**: Easily handle variations like `solid` or `ghost`.
114
- 3. **Default Variants**: Define fallback styles for missing configurations.
115
- 4. **Compound Variants**: Apply conditional styles based on combined properties.
116
-
117
- <h3>Contributing</h3>
118
-
119
- Feel free to contribute by submitting issues or pull requests. For questions, reach out to the maintainer:
120
-
121
- Email: matheussdev3@gmail.com
122
- Maintainer: [matheussatoshi](https://github.com/matheussatoshi)
123
-
124
- <h3>License</h3>
125
-
1
+
2
+ <h1 align='center'>native-variants</h1>
3
+
4
+ Simplify and streamline style management in React
5
+ Native with TypeScript support
6
+
7
+
8
+ <h4>Installation</h4>
9
+
10
+
11
+ Install `native-variants` using npm or yarn:
12
+
13
+
14
+ ```bash
15
+ npm install native-variants
16
+ //or
17
+ yarn add native-variants
18
+ ```
19
+
20
+ <h4>Overview</h4>
21
+
22
+ `native-variants` provides a powerful utility to define, organize, and apply component styling for React Native. It supports multiple slots, variants, default settings, and compound variants, enabling a clean and reusable way to manage styles.
23
+
24
+ <h3>Getting Started</h3>
25
+
26
+ Here’s a quick example of how to use `native-variants` to style a button component.
27
+
28
+
29
+ <h4>Defining Variants</h4>
30
+
31
+ ```tsx
32
+ import { nv, type VariantProps } from "native-variants";
33
+
34
+ const buttonVariants = nv({
35
+ slots: ["root", "text"], // Define slots for styling
36
+ base: {
37
+ root: { paddingHorizontal: 16, paddingVertical: 12 }, // Base styles for root
38
+ text: { color: "white", textAlign: "center" }, // Base styles for text
39
+ },
40
+ variants: {
41
+ variant: {
42
+ solid: {
43
+ root: { backgroundColor: "#ff0006" },
44
+ text: { color: "white" },
45
+ },
46
+ ghost: {
47
+ root: { backgroundColor: "transparent" },
48
+ text: { color: "#ff0006" },
49
+ },
50
+ },
51
+ },
52
+ defaultVariants: {
53
+ variant: "solid", // Default variant configuration
54
+ },
55
+ compoundVariants: [
56
+ {
57
+ variant: "ghost",
58
+ css: {
59
+ root: { borderWidth: 1, borderColor: "#fff006" },
60
+ },
61
+ },
62
+ ],
63
+ });
64
+ ```
65
+
66
+ <h4>Using the Variants</h4>
67
+
68
+ Create a styled `Button` component:
69
+
70
+ ```tsx
71
+ import React from "react";
72
+ import { Text, TouchableOpacity } from "react-native";
73
+
74
+ export interface ButtonProps
75
+ extends React.ComponentPropsWithoutRef<typeof TouchableOpacity>,
76
+ VariantProps<typeof buttonVariants> {}
77
+
78
+ export const Button = React.forwardRef<
79
+ React.ComponentRef<typeof TouchableOpacity>,
80
+ ButtonProps
81
+ >(({ children, variant, ...props }, ref) => {
82
+ const { root, text } = buttonVariants({ variant });
83
+
84
+ return (
85
+ <TouchableOpacity {...props} ref={ref} style={root}>
86
+ <Text style={text}>{children}</Text>
87
+ </TouchableOpacity>
88
+ );
89
+ });
90
+
91
+ Button.displayName = "Button";
92
+ ```
93
+
94
+ <h4>Usage Example</h4>
95
+
96
+
97
+ ```tsx
98
+ import { Button } from "./Button";
99
+
100
+ export default function App() {
101
+ return (
102
+ <>
103
+ <Button variant="solid">Solid Button</Button>
104
+ <Button variant="ghost">Ghost Button</Button>
105
+ </>
106
+ );
107
+ }
108
+ ```
109
+
110
+ <h3>Features</h3>
111
+
112
+ 1. **Multi-Slot Styling**: Define styles for multiple slots (e.g., `root`, `text`).
113
+ 2. **Variant Management**: Easily handle variations like `solid` or `ghost`.
114
+ 3. **Default Variants**: Define fallback styles for missing configurations.
115
+ 4. **Compound Variants**: Apply conditional styles based on combined properties.
116
+
117
+ <h3>Contributing</h3>
118
+
119
+ Feel free to contribute by submitting issues or pull requests. For questions, reach out to the maintainer:
120
+
121
+ Email: matheussdev3@gmail.com
122
+ Maintainer: [matheussatoshi](https://github.com/matheussatoshi)
123
+
124
+ <h3>License</h3>
125
+
126
126
  This library is licensed under the MIT License.
@@ -0,0 +1 @@
1
+ import{createNVA}from"./lib/create-nva.js";const{styled,theme,utils}=createNVA({theme:{colors:{default:{primary:"#3b82f6",background:"#ffffff",foreground:"#000000"},dark:{primary:"#60a5fa",background:"#000000",foreground:"#ffffff"}}},utils:{mx:value=>({marginLeft:value,marginRight:value}),my:value=>({marginTop:value,marginBottom:value}),px:value=>({paddingLeft:value,paddingRight:value}),py:value=>({paddingTop:value,paddingBottom:value}),size:value=>({width:value,height:value}),brd:value=>({borderWidth:value,borderStyle:"solid"})}});const buttonVariants=styled((ctx,t)=>ctx({slots:["root","text"],base:{root:{backgroundColor:t.colors.primary,px:16,py:12,borderRadius:t.radii.lg},text:{color:t.colors.background,fontSize:t.fontSizes.base}},variants:{size:{sm:{root:{px:12,py:8},text:{fontSize:t.fontSizes.sm}},lg:{root:{px:24,py:16},text:{fontSize:t.fontSizes.lg}}},square:{true:{root:{size:48,px:0,py:0}}}},compoundVariants:[{size:"lg",square:true,css:{root:{size:64}}}]}));const styles=buttonVariants({size:"lg"});console.log(styles.root);const squareStyles=buttonVariants({square:true});console.log(squareStyles.root);const combined=buttonVariants({size:"sm",square:false});console.log(combined.root);console.log(theme.colors.primary);console.log(theme.colors.blue500);console.log(theme.spacing["4"]);console.log(theme.fontSizes.lg);console.log(utils.mx(10));
package/dist/index.d.ts CHANGED
@@ -1,8 +1,17 @@
1
- export * from "./lib/cn.js";
2
- export * from "./lib/create-nva.js";
3
- export * from "./lib/media-query.js";
4
- export * from "./provider/create-provider.js";
5
- export * from "./types.js";
6
- export * from "./utils/alpha.js";
7
- export * from "./utils/compose-refs.js";
8
- export * from "./utils/compose-text.js";
1
+ /**
2
+ * Native Variants - A type-safe styling library for React Native
3
+ * with Tailwind CSS inspired design tokens.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ export { cn, cnView, cnText, cnImage } from "./lib/cn.js";
8
+ export { styled, createNVA, clearStyleCache } from "./lib/create-nva.js";
9
+ export { wq, hq, getScreenDimensions, responsiveFontSize } from "./lib/media-query.js";
10
+ export { createCTX } from "./provider/create-provider.js";
11
+ export { ThemeProvider, useTheme, useThemeColors, useIsDark, useColorScheme, createThemedStyles, } from "./provider/theme-provider.js";
12
+ export type { ColorScheme, ThemeMode, ThemeContextValue, ThemeProviderProps, } from "./provider/theme-provider.js";
13
+ export type { Styles, Base, DefaultVariants, CompoundVariant, Variants, MappedVariants, DefineConfig, Config, VariantProps, Theme, ThemeInput, ThemeOutput, ColorSchemeConfig, ColorsInput, UtilFunction, UtilsConfig, UtilParamType, StylesWithUtils, BaseWithUtils, VariantsWithUtils, CompoundVariantWithUtils, DefaultVariantsWithUtils, ConfigWithUtils, } from "./types.js";
14
+ export { alpha, hexToRgba, lighten, darken } from "./utils/alpha.js";
15
+ export { composeText, hasTextStyles, composeView } from "./utils/compose-text.js";
16
+ export { defaultTheme, extendTheme, tailwindColors, tailwindSpacing, tailwindFontSizes, tailwindRadii, tailwindShadows, tailwindZIndex, tailwindOpacity, tailwindLineHeights, tailwindFontWeights, tailwindLetterSpacing, tailwindBorderWidths, tailwindMaxWidths, tailwindDurations, defaultColors, defaultSpacing, defaultFontSizes, defaultRadii, defaultShadows, defaultZIndex, defaultOpacity, defaultLineHeights, defaultFontWeights, defaultLetterSpacing, } from "./tokens/default-tokens.js";
17
+ export type { DefaultTheme, TailwindColors, TailwindSpacing, TailwindFontSizes, TailwindRadii, TailwindShadows, TailwindZIndex, TailwindOpacity, TailwindLineHeights, TailwindFontWeights, TailwindLetterSpacing, TailwindBorderWidths, TailwindMaxWidths, TailwindDurations, DefaultColors, DefaultSpacing, DefaultFontSizes, DefaultRadii, DefaultShadows, DefaultZIndex, DefaultOpacity, DefaultLineHeights, DefaultFontWeights, DefaultLetterSpacing, } from "./tokens/default-tokens.js";
package/dist/index.js CHANGED
@@ -1,25 +1,75 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
2
+ /**
3
+ * Native Variants - A type-safe styling library for React Native
4
+ * with Tailwind CSS inspired design tokens.
5
+ *
6
+ * @packageDocumentation
7
+ */
16
8
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./lib/cn.js"), exports);
18
- __exportStar(require("./lib/create-nva.js"), exports);
19
- __exportStar(require("./lib/media-query.js"), exports);
20
- __exportStar(require("./provider/create-provider.js"), exports);
21
- __exportStar(require("./types.js"), exports);
22
- __exportStar(require("./utils/alpha.js"), exports);
23
- __exportStar(require("./utils/compose-refs.js"), exports);
24
- __exportStar(require("./utils/compose-text.js"), exports);
9
+ exports.defaultLetterSpacing = exports.defaultFontWeights = exports.defaultLineHeights = exports.defaultOpacity = exports.defaultZIndex = exports.defaultShadows = exports.defaultRadii = exports.defaultFontSizes = exports.defaultSpacing = exports.defaultColors = exports.tailwindDurations = exports.tailwindMaxWidths = exports.tailwindBorderWidths = exports.tailwindLetterSpacing = exports.tailwindFontWeights = exports.tailwindLineHeights = exports.tailwindOpacity = exports.tailwindZIndex = exports.tailwindShadows = exports.tailwindRadii = exports.tailwindFontSizes = exports.tailwindSpacing = exports.tailwindColors = exports.extendTheme = exports.defaultTheme = exports.composeView = exports.hasTextStyles = exports.composeText = exports.darken = exports.lighten = exports.hexToRgba = exports.alpha = exports.createThemedStyles = exports.useColorScheme = exports.useIsDark = exports.useThemeColors = exports.useTheme = exports.ThemeProvider = exports.createCTX = exports.responsiveFontSize = exports.getScreenDimensions = exports.hq = exports.wq = exports.clearStyleCache = exports.createNVA = exports.styled = exports.cnImage = exports.cnText = exports.cnView = exports.cn = void 0;
10
+ // Core styling utilities
11
+ var cn_1 = require("./lib/cn.js");
12
+ Object.defineProperty(exports, "cn", { enumerable: true, get: function () { return cn_1.cn; } });
13
+ Object.defineProperty(exports, "cnView", { enumerable: true, get: function () { return cn_1.cnView; } });
14
+ Object.defineProperty(exports, "cnText", { enumerable: true, get: function () { return cn_1.cnText; } });
15
+ Object.defineProperty(exports, "cnImage", { enumerable: true, get: function () { return cn_1.cnImage; } });
16
+ var create_nva_1 = require("./lib/create-nva.js");
17
+ Object.defineProperty(exports, "styled", { enumerable: true, get: function () { return create_nva_1.styled; } });
18
+ Object.defineProperty(exports, "createNVA", { enumerable: true, get: function () { return create_nva_1.createNVA; } });
19
+ Object.defineProperty(exports, "clearStyleCache", { enumerable: true, get: function () { return create_nva_1.clearStyleCache; } });
20
+ var media_query_1 = require("./lib/media-query.js");
21
+ Object.defineProperty(exports, "wq", { enumerable: true, get: function () { return media_query_1.wq; } });
22
+ Object.defineProperty(exports, "hq", { enumerable: true, get: function () { return media_query_1.hq; } });
23
+ Object.defineProperty(exports, "getScreenDimensions", { enumerable: true, get: function () { return media_query_1.getScreenDimensions; } });
24
+ Object.defineProperty(exports, "responsiveFontSize", { enumerable: true, get: function () { return media_query_1.responsiveFontSize; } });
25
+ // Context provider utilities
26
+ var create_provider_1 = require("./provider/create-provider.js");
27
+ Object.defineProperty(exports, "createCTX", { enumerable: true, get: function () { return create_provider_1.createCTX; } });
28
+ // Theme provider and hooks
29
+ var theme_provider_1 = require("./provider/theme-provider.js");
30
+ Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return theme_provider_1.ThemeProvider; } });
31
+ Object.defineProperty(exports, "useTheme", { enumerable: true, get: function () { return theme_provider_1.useTheme; } });
32
+ Object.defineProperty(exports, "useThemeColors", { enumerable: true, get: function () { return theme_provider_1.useThemeColors; } });
33
+ Object.defineProperty(exports, "useIsDark", { enumerable: true, get: function () { return theme_provider_1.useIsDark; } });
34
+ Object.defineProperty(exports, "useColorScheme", { enumerable: true, get: function () { return theme_provider_1.useColorScheme; } });
35
+ Object.defineProperty(exports, "createThemedStyles", { enumerable: true, get: function () { return theme_provider_1.createThemedStyles; } });
36
+ // Utility functions
37
+ var alpha_1 = require("./utils/alpha.js");
38
+ Object.defineProperty(exports, "alpha", { enumerable: true, get: function () { return alpha_1.alpha; } });
39
+ Object.defineProperty(exports, "hexToRgba", { enumerable: true, get: function () { return alpha_1.hexToRgba; } });
40
+ Object.defineProperty(exports, "lighten", { enumerable: true, get: function () { return alpha_1.lighten; } });
41
+ Object.defineProperty(exports, "darken", { enumerable: true, get: function () { return alpha_1.darken; } });
42
+ var compose_text_1 = require("./utils/compose-text.js");
43
+ Object.defineProperty(exports, "composeText", { enumerable: true, get: function () { return compose_text_1.composeText; } });
44
+ Object.defineProperty(exports, "hasTextStyles", { enumerable: true, get: function () { return compose_text_1.hasTextStyles; } });
45
+ Object.defineProperty(exports, "composeView", { enumerable: true, get: function () { return compose_text_1.composeView; } });
46
+ // Default tokens (Tailwind CSS)
47
+ var default_tokens_1 = require("./tokens/default-tokens.js");
48
+ Object.defineProperty(exports, "defaultTheme", { enumerable: true, get: function () { return default_tokens_1.defaultTheme; } });
49
+ Object.defineProperty(exports, "extendTheme", { enumerable: true, get: function () { return default_tokens_1.extendTheme; } });
50
+ // Tailwind exports
51
+ Object.defineProperty(exports, "tailwindColors", { enumerable: true, get: function () { return default_tokens_1.tailwindColors; } });
52
+ Object.defineProperty(exports, "tailwindSpacing", { enumerable: true, get: function () { return default_tokens_1.tailwindSpacing; } });
53
+ Object.defineProperty(exports, "tailwindFontSizes", { enumerable: true, get: function () { return default_tokens_1.tailwindFontSizes; } });
54
+ Object.defineProperty(exports, "tailwindRadii", { enumerable: true, get: function () { return default_tokens_1.tailwindRadii; } });
55
+ Object.defineProperty(exports, "tailwindShadows", { enumerable: true, get: function () { return default_tokens_1.tailwindShadows; } });
56
+ Object.defineProperty(exports, "tailwindZIndex", { enumerable: true, get: function () { return default_tokens_1.tailwindZIndex; } });
57
+ Object.defineProperty(exports, "tailwindOpacity", { enumerable: true, get: function () { return default_tokens_1.tailwindOpacity; } });
58
+ Object.defineProperty(exports, "tailwindLineHeights", { enumerable: true, get: function () { return default_tokens_1.tailwindLineHeights; } });
59
+ Object.defineProperty(exports, "tailwindFontWeights", { enumerable: true, get: function () { return default_tokens_1.tailwindFontWeights; } });
60
+ Object.defineProperty(exports, "tailwindLetterSpacing", { enumerable: true, get: function () { return default_tokens_1.tailwindLetterSpacing; } });
61
+ Object.defineProperty(exports, "tailwindBorderWidths", { enumerable: true, get: function () { return default_tokens_1.tailwindBorderWidths; } });
62
+ Object.defineProperty(exports, "tailwindMaxWidths", { enumerable: true, get: function () { return default_tokens_1.tailwindMaxWidths; } });
63
+ Object.defineProperty(exports, "tailwindDurations", { enumerable: true, get: function () { return default_tokens_1.tailwindDurations; } });
64
+ // Legacy exports (backwards compatibility)
65
+ Object.defineProperty(exports, "defaultColors", { enumerable: true, get: function () { return default_tokens_1.defaultColors; } });
66
+ Object.defineProperty(exports, "defaultSpacing", { enumerable: true, get: function () { return default_tokens_1.defaultSpacing; } });
67
+ Object.defineProperty(exports, "defaultFontSizes", { enumerable: true, get: function () { return default_tokens_1.defaultFontSizes; } });
68
+ Object.defineProperty(exports, "defaultRadii", { enumerable: true, get: function () { return default_tokens_1.defaultRadii; } });
69
+ Object.defineProperty(exports, "defaultShadows", { enumerable: true, get: function () { return default_tokens_1.defaultShadows; } });
70
+ Object.defineProperty(exports, "defaultZIndex", { enumerable: true, get: function () { return default_tokens_1.defaultZIndex; } });
71
+ Object.defineProperty(exports, "defaultOpacity", { enumerable: true, get: function () { return default_tokens_1.defaultOpacity; } });
72
+ Object.defineProperty(exports, "defaultLineHeights", { enumerable: true, get: function () { return default_tokens_1.defaultLineHeights; } });
73
+ Object.defineProperty(exports, "defaultFontWeights", { enumerable: true, get: function () { return default_tokens_1.defaultFontWeights; } });
74
+ Object.defineProperty(exports, "defaultLetterSpacing", { enumerable: true, get: function () { return default_tokens_1.defaultLetterSpacing; } });
25
75
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,mDAAiC;AACjC,oDAAkC;AAClC,6DAA2C;AAC3C,0CAAwB;AACxB,gDAA8B;AAC9B,uDAAqC;AACrC,uDAAqC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yBAAyB;AACzB,+BAAuD;AAA9C,wFAAA,EAAE,OAAA;AAAE,4FAAA,MAAM,OAAA;AAAE,4FAAA,MAAM,OAAA;AAAE,6FAAA,OAAO,OAAA;AACpC,+CAAsE;AAA7D,oGAAA,MAAM,OAAA;AAAE,uGAAA,SAAS,OAAA;AAAE,6GAAA,eAAe,OAAA;AAC3C,iDAAoF;AAA3E,iGAAA,EAAE,OAAA;AAAE,iGAAA,EAAE,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AAExD,6BAA6B;AAC7B,8DAAuD;AAA9C,4GAAA,SAAS,OAAA;AAElB,2BAA2B;AAC3B,4DAOmC;AANjC,+GAAA,aAAa,OAAA;AACb,0GAAA,QAAQ,OAAA;AACR,gHAAA,cAAc,OAAA;AACd,2GAAA,SAAS,OAAA;AACT,gHAAA,cAAc,OAAA;AACd,oHAAA,kBAAkB,OAAA;AAsCpB,oBAAoB;AACpB,uCAAkE;AAAzD,8FAAA,KAAK,OAAA;AAAE,kGAAA,SAAS,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,+FAAA,MAAM,OAAA;AAC1C,qDAA+E;AAAtE,2GAAA,WAAW,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,2GAAA,WAAW,OAAA;AAEhD,gCAAgC;AAChC,0DA4BiC;AA3B/B,8GAAA,YAAY,OAAA;AACZ,6GAAA,WAAW,OAAA;AACX,mBAAmB;AACnB,gHAAA,cAAc,OAAA;AACd,iHAAA,eAAe,OAAA;AACf,mHAAA,iBAAiB,OAAA;AACjB,+GAAA,aAAa,OAAA;AACb,iHAAA,eAAe,OAAA;AACf,gHAAA,cAAc,OAAA;AACd,iHAAA,eAAe,OAAA;AACf,qHAAA,mBAAmB,OAAA;AACnB,qHAAA,mBAAmB,OAAA;AACnB,uHAAA,qBAAqB,OAAA;AACrB,sHAAA,oBAAoB,OAAA;AACpB,mHAAA,iBAAiB,OAAA;AACjB,mHAAA,iBAAiB,OAAA;AACjB,2CAA2C;AAC3C,+GAAA,aAAa,OAAA;AACb,gHAAA,cAAc,OAAA;AACd,kHAAA,gBAAgB,OAAA;AAChB,8GAAA,YAAY,OAAA;AACZ,gHAAA,cAAc,OAAA;AACd,+GAAA,aAAa,OAAA;AACb,gHAAA,cAAc,OAAA;AACd,oHAAA,kBAAkB,OAAA;AAClB,oHAAA,kBAAkB,OAAA;AAClB,sHAAA,oBAAoB,OAAA"}
package/dist/lib/cn.d.ts CHANGED
@@ -1,2 +1,82 @@
1
- import type { StyleProp } from "react-native";
2
- export declare function cn<T extends object>(...styles: StyleProp<T>[]): T;
1
+ import type { FlexStyle, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
2
+ /**
3
+ * Base style type that covers all React Native style types.
4
+ */
5
+ type BaseStyle = ViewStyle | TextStyle | ImageStyle | FlexStyle;
6
+ /**
7
+ * Animated style type compatible with react-native-reanimated.
8
+ * Allows for animated values in style properties.
9
+ */
10
+ type AnimatedStyle<T> = {
11
+ [K in keyof T]: T[K] | {
12
+ value: T[K];
13
+ };
14
+ };
15
+ /**
16
+ * Combined style input type that accepts:
17
+ * - Regular React Native styles (ViewStyle, TextStyle, etc.)
18
+ * - Animated styles from react-native-reanimated
19
+ * - Partial style objects
20
+ * - Style arrays
21
+ * - null/undefined values
22
+ */
23
+ type StyleInput = StyleProp<BaseStyle> | AnimatedStyle<BaseStyle> | Partial<BaseStyle> | Record<string, unknown> | null | undefined;
24
+ /**
25
+ * Combines multiple style objects into a single merged style.
26
+ * Supports React Native StyleProp, animated styles from react-native-reanimated,
27
+ * and regular style objects.
28
+ *
29
+ * Features:
30
+ * - Handles nested style arrays
31
+ * - Compatible with react-native-reanimated animated styles
32
+ * - Filters out null/undefined values
33
+ * - Returns a properly typed style object
34
+ *
35
+ * @param styles - Variable number of style inputs to merge
36
+ * @returns A single merged style object
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * // Basic usage
41
+ * const style = cn(styles.root, { padding: 16 });
42
+ *
43
+ * // With animated styles (react-native-reanimated)
44
+ * const animatedStyle = useAnimatedStyle(() => ({
45
+ * transform: [{ translateX: translateX.value }],
46
+ * }));
47
+ * const style = cn(styles.wrapper, animatedStyle);
48
+ *
49
+ * // Multiple styles
50
+ * const style = cn(
51
+ * baseStyles,
52
+ * conditionalStyles,
53
+ * { opacity: isVisible ? 1 : 0 }
54
+ * );
55
+ * ```
56
+ */
57
+ export declare function cn<T extends BaseStyle = ViewStyle>(...styles: StyleInput[]): T;
58
+ /**
59
+ * Type-safe version of cn specifically for ViewStyle.
60
+ * Use this when you need explicit ViewStyle typing.
61
+ *
62
+ * @param styles - Variable number of style inputs to merge
63
+ * @returns A merged ViewStyle object
64
+ */
65
+ export declare function cnView(...styles: StyleInput[]): ViewStyle;
66
+ /**
67
+ * Type-safe version of cn specifically for TextStyle.
68
+ * Use this when you need explicit TextStyle typing.
69
+ *
70
+ * @param styles - Variable number of style inputs to merge
71
+ * @returns A merged TextStyle object
72
+ */
73
+ export declare function cnText(...styles: StyleInput[]): TextStyle;
74
+ /**
75
+ * Type-safe version of cn specifically for ImageStyle.
76
+ * Use this when you need explicit ImageStyle typing.
77
+ *
78
+ * @param styles - Variable number of style inputs to merge
79
+ * @returns A merged ImageStyle object
80
+ */
81
+ export declare function cnImage(...styles: StyleInput[]): ImageStyle;
82
+ export {};