native-variants 0.1.56 → 0.1.61

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": "native-variants",
3
- "version": "0.1.56",
3
+ "version": "0.1.61",
4
4
  "description": "A library for handling variants in React Native components with theme support.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
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";
package/dist/index.js DELETED
@@ -1,25 +0,0 @@
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
- };
16
- 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);
25
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
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"}
package/dist/lib/cn.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { StyleProp } from "react-native";
2
- export declare function cn<T extends object>(...styles: StyleProp<T>[]): T;
package/dist/lib/cn.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cn = cn;
4
- function flattenStyle(style) {
5
- if (!style)
6
- return [];
7
- if (Array.isArray(style)) {
8
- return style.flat
9
- ? style.flat().filter(Boolean)
10
- : style.filter(Boolean);
11
- }
12
- // @ts-ignore
13
- return [style];
14
- }
15
- function cn(...styles) {
16
- return styles
17
- .flatMap(flattenStyle)
18
- .filter((s) => !!s)
19
- .reduce((acc, style) => ({ ...acc, ...style }), {});
20
- }
21
- //# sourceMappingURL=cn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cn.js","sourceRoot":"","sources":["../../src/lib/cn.ts"],"names":[],"mappings":";;AAaA,gBAKC;AAhBD,SAAS,YAAY,CAAI,KAAmB;IAC1C,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,IAAI;YACf,CAAC,CAAE,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAS;YACvC,CAAC,CAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAS,CAAC;IACrC,CAAC;IACD,aAAa;IACb,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED,SAAgB,EAAE,CAAmB,GAAG,MAAsB;IAC5D,OAAO,MAAM;SACV,OAAO,CAAC,YAAY,CAAC;SACrB,MAAM,CAAC,CAAC,CAAC,EAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1B,MAAM,CAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,EAAO,CAAC,CAAC;AAChE,CAAC"}
@@ -1,11 +0,0 @@
1
- import { Base, Config, DefaultVariants, DefineConfig, Theme, Variants } from "../types.js";
2
- export declare function styled<S extends string, V extends Variants<S>>(config: Config<S, V>): (props?: DefaultVariants<S, V>) => Base<S>;
3
- export declare function createNVA<Tokens extends Theme>({ theme, }?: {
4
- theme?: Tokens;
5
- }): {
6
- theme: Tokens;
7
- styled: {
8
- <S extends string, V extends Variants<S>>(config: Config<S, V>): (props?: DefaultVariants<S, V>) => Base<S>;
9
- <S extends string, V extends Variants<S>>(configFactory: (defineConfig: DefineConfig, theme: Tokens) => Config<S, V>): (props?: DefaultVariants<S, V>) => Base<S>;
10
- };
11
- };
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.styled = styled;
4
- exports.createNVA = createNVA;
5
- function cache(fn) {
6
- const memo = new Map();
7
- return ((...args) => {
8
- const key = JSON.stringify(args);
9
- if (memo.has(key))
10
- return memo.get(key);
11
- const result = fn(...args);
12
- memo.set(key, result);
13
- return result;
14
- });
15
- }
16
- function variant(slot, variants, props) {
17
- let style = {};
18
- for (const key in variants) {
19
- if (Object.prototype.hasOwnProperty.call(props, key)) {
20
- const value = props[key];
21
- const variantConfig = variants[key];
22
- const styleForValue = variantConfig?.[value]?.[slot];
23
- if (styleForValue) {
24
- style = { ...style, ...styleForValue };
25
- }
26
- }
27
- }
28
- return style;
29
- }
30
- function compound(slot, compoundVariants, props) {
31
- let style = {};
32
- for (const cv of compoundVariants) {
33
- const { css, ...conds } = cv;
34
- const isMatch = Object.entries(conds).every(([k, v]) => props[k] === v);
35
- if (isMatch && css?.[slot]) {
36
- style = { ...style, ...css[slot] };
37
- }
38
- }
39
- return style;
40
- }
41
- function set(slot, base, variants, compoundVariants, props) {
42
- return {
43
- ...base?.[slot],
44
- ...variant(slot, variants, props),
45
- ...compound(slot, compoundVariants, props),
46
- };
47
- }
48
- function styled(config) {
49
- const { slots, base = {}, variants = {}, defaultVariants = {}, compoundVariants = [], } = config;
50
- const computeStyles = (props) => {
51
- const resolvedProps = { ...defaultVariants };
52
- // Override only explicitly defined variant props, keeping defaults untouched
53
- if (props) {
54
- for (const key in props) {
55
- const value = props[key];
56
- if (value !== undefined) {
57
- //@ts-ignore
58
- resolvedProps[key] = value;
59
- }
60
- }
61
- }
62
- const result = {};
63
- for (const slot of slots) {
64
- result[slot] = set(slot, base, variants, compoundVariants, resolvedProps);
65
- }
66
- return result;
67
- };
68
- const cachedComputeStyles = cache(computeStyles);
69
- return cachedComputeStyles;
70
- }
71
- function createNVA({ theme, } = {}) {
72
- function styled(configOrFactory) {
73
- const defineConfig = (config) => config;
74
- const config = typeof configOrFactory === "function"
75
- ? configOrFactory(defineConfig, theme)
76
- : configOrFactory;
77
- const { slots, base = {}, variants = {}, defaultVariants = {}, compoundVariants = [], } = config;
78
- const computeStyles = (props) => {
79
- const resolvedProps = { ...defaultVariants };
80
- if (props) {
81
- for (const key in props) {
82
- if (props[key] !== undefined) {
83
- // @ts-ignore
84
- resolvedProps[key] = props[key];
85
- }
86
- }
87
- }
88
- const result = {};
89
- for (const slot of slots) {
90
- result[slot] = set(slot, base, variants, compoundVariants, resolvedProps);
91
- }
92
- return result;
93
- };
94
- return cache(computeStyles);
95
- }
96
- return {
97
- theme: theme,
98
- styled,
99
- };
100
- }
101
- //# sourceMappingURL=create-nva.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-nva.js","sourceRoot":"","sources":["../../src/lib/create-nva.ts"],"names":[],"mappings":";;AA4EA,wBAqCC;AA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M,MAAM,GAAG,EAAa,CAAC;YAE7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAChB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,aAAa,CACd,CAAC;YACJ,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAEF,OAAO,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,KAAK,EAAE,KAAM;QACb,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const wq: (widthPercent: number | string) => number;
2
- export declare const hq: (heightPercent: number | string) => number;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hq = exports.wq = void 0;
4
- const react_native_1 = require("react-native");
5
- let screenWidth = react_native_1.Dimensions.get("window").width;
6
- let screenHeight = react_native_1.Dimensions.get("window").height;
7
- const wq = (widthPercent) => {
8
- const elemWidth = typeof widthPercent === "number" ? widthPercent : parseFloat(widthPercent);
9
- return react_native_1.PixelRatio.roundToNearestPixel((screenWidth * elemWidth) / 100);
10
- };
11
- exports.wq = wq;
12
- const hq = (heightPercent) => {
13
- const elemHeight = typeof heightPercent === "number"
14
- ? heightPercent
15
- : parseFloat(heightPercent);
16
- return react_native_1.PixelRatio.roundToNearestPixel((screenHeight * elemHeight) / 100);
17
- };
18
- exports.hq = hq;
19
- //# sourceMappingURL=media-query.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"media-query.js","sourceRoot":"","sources":["../../src/lib/media-query.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AAEtD,IAAI,WAAW,GAAG,yBAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AACjD,IAAI,YAAY,GAAG,yBAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;AAE5C,MAAM,EAAE,GAAG,CAAC,YAA6B,EAAU,EAAE;IAC1D,MAAM,SAAS,GACb,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAE7E,OAAO,yBAAU,CAAC,mBAAmB,CAAC,CAAC,WAAW,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC,CAAC;AACzE,CAAC,CAAC;AALW,QAAA,EAAE,MAKb;AAEK,MAAM,EAAE,GAAG,CAAC,aAA8B,EAAU,EAAE;IAC3D,MAAM,UAAU,GACd,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAEhC,OAAO,yBAAU,CAAC,mBAAmB,CAAC,CAAC,YAAY,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC;AAC3E,CAAC,CAAC;AAPW,QAAA,EAAE,MAOb"}
@@ -1,7 +0,0 @@
1
- import { PropsWithChildren } from "react";
2
- export declare const createCTX: <T>() => {
3
- CTXProvider: ({ children, props, }: PropsWithChildren & {
4
- props: T;
5
- }) => import("react/jsx-runtime").JSX.Element;
6
- useCTX: () => T | undefined;
7
- };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCTX = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const createCTX = () => {
7
- const Context = (0, react_1.createContext)(undefined);
8
- const CTXProvider = ({ children, props, }) => {
9
- const value = (0, react_1.useMemo)(() => ({ props }), [props]);
10
- return (0, jsx_runtime_1.jsx)(Context.Provider, { value: value, children: children });
11
- };
12
- const useCTX = () => {
13
- const context = (0, react_1.useContext)(Context);
14
- if (!context) {
15
- return undefined;
16
- }
17
- return context.props;
18
- };
19
- return {
20
- CTXProvider,
21
- useCTX,
22
- };
23
- };
24
- exports.createCTX = createCTX;
25
- //# sourceMappingURL=create-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-provider.js","sourceRoot":"","sources":["../../src/provider/create-provider.tsx"],"names":[],"mappings":";;;;AAAA,iCAA8E;AAMvE,MAAM,SAAS,GAAG,GAAO,EAAE;IAChC,MAAM,OAAO,GAAG,IAAA,qBAAa,EAAgC,SAAS,CAAC,CAAC;IAExE,MAAM,WAAW,GAAG,CAAC,EACnB,QAAQ,EACR,KAAK,GAGN,EAAE,EAAE;QACH,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,OAAO,uBAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoB,CAAC;IACvE,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,GAAkB,EAAE;QACjC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,OAAO,CAAC,CAAC;QAEpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,OAAO,CAAC,KAAU,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO;QACL,WAAW;QACX,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AA5BW,QAAA,SAAS,aA4BpB"}
package/dist/types.d.ts DELETED
@@ -1,40 +0,0 @@
1
- import { FlexStyle, ImageStyle, TextStyle, TransformsStyle, ViewStyle } from "react-native";
2
- export type Styles = Partial<ViewStyle & TextStyle & ImageStyle & FlexStyle & TransformsStyle>;
3
- export type Base<S extends string> = Partial<Record<S, Styles>>;
4
- export type DefaultVariants<S extends string, V extends Variants<S>> = {
5
- [K in keyof V]?: keyof V[K] | boolean;
6
- };
7
- export type CompoundVariant<S extends string, V extends Variants<S>> = {
8
- css?: Partial<Record<S, Styles>>;
9
- } & {
10
- [K in keyof V]?: keyof V[K];
11
- };
12
- export type Variants<S extends string> = {
13
- [K in string]?: {
14
- [K in string]: {
15
- [key in S]?: Styles;
16
- };
17
- };
18
- };
19
- export type MappedVariants<V> = Partial<{
20
- [K in keyof V]: keyof V[K];
21
- }>;
22
- export type DefineConfig = <S extends string, V extends Variants<S>>(config: Config<S, V>) => Config<S, V>;
23
- export type Config<S extends string, V extends Variants<S>> = {
24
- slots: S[];
25
- base?: Base<S>;
26
- variants?: V;
27
- defaultVariants?: DefaultVariants<S, V>;
28
- compoundVariants?: CompoundVariant<S, V>[];
29
- };
30
- export type VariantProps<T extends (...args: any[]) => any> = T extends (props?: infer P) => any ? Partial<P> : never;
31
- export type Theme<C = any, S = any, F = any, R = any, T = any, Z = any, O = any, L = any> = {
32
- colors?: C;
33
- spacing?: S;
34
- fontSizes?: F;
35
- radii?: R;
36
- shadows?: T;
37
- zIndex?: Z;
38
- opacity?: O;
39
- lineHeights?: L;
40
- };
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export declare function alpha(hex: string, opacity: number): string;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.alpha = alpha;
4
- function alpha(hex, opacity) {
5
- if (!/^#([0-9a-f]{6})$/i.test(hex)) {
6
- throw new Error("Hex color must be in the format #RRGGBB.");
7
- }
8
- const alpha = Math.round((opacity / 100) * 255)
9
- .toString(16)
10
- .padStart(2, "0");
11
- return `${hex}${alpha}`;
12
- }
13
- //# sourceMappingURL=alpha.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"alpha.js","sourceRoot":"","sources":["../../src/utils/alpha.ts"],"names":[],"mappings":";;AAAA,sBAUC;AAVD,SAAgB,KAAK,CAAC,GAAW,EAAE,OAAe;IAChD,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;SAC5C,QAAQ,CAAC,EAAE,CAAC;SACZ,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEpB,OAAO,GAAG,GAAG,GAAG,KAAK,EAAE,CAAC;AAC1B,CAAC"}
@@ -1,3 +0,0 @@
1
- type PossibleRef<T> = React.Ref<T> | undefined;
2
- export declare function composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T>;
3
- export {};
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composeRefs = composeRefs;
4
- function setRef(ref, value) {
5
- if (typeof ref === "function") {
6
- return ref(value);
7
- }
8
- else if (ref !== null && ref !== undefined) {
9
- ref.current = value;
10
- }
11
- }
12
- function composeRefs(...refs) {
13
- return (node) => {
14
- let hasCleanup = false;
15
- const cleanups = refs.map((ref) => {
16
- const cleanup = setRef(ref, node);
17
- if (!hasCleanup && typeof cleanup == "function") {
18
- hasCleanup = true;
19
- }
20
- return cleanup;
21
- });
22
- if (hasCleanup) {
23
- return () => {
24
- for (let i = 0; i < cleanups.length; i++) {
25
- const cleanup = cleanups[i];
26
- if (typeof cleanup == "function") {
27
- cleanup();
28
- }
29
- else {
30
- setRef(refs[i], null);
31
- }
32
- }
33
- };
34
- }
35
- };
36
- }
37
- //# sourceMappingURL=compose-refs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compose-refs.js","sourceRoot":"","sources":["../../src/utils/compose-refs.ts"],"names":[],"mappings":";;AAUA,kCA0BC;AAlCD,SAAS,MAAM,CAAI,GAAmB,EAAE,KAAQ;IAC9C,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;SAAM,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QAC7C,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC;AACH,CAAC;AAED,SAAgB,WAAW,CACzB,GAAG,IAAsB;IAEzB,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAChC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAClC,IAAI,CAAC,UAAU,IAAI,OAAO,OAAO,IAAI,UAAU,EAAE,CAAC;gBAChD,UAAU,GAAG,IAAI,CAAC;YACpB,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,GAAG,EAAE;gBACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;oBAC5B,IAAI,OAAO,OAAO,IAAI,UAAU,EAAE,CAAC;wBACjC,OAAO,EAAE,CAAC;oBACZ,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import { TextStyle } from "react-native";
2
- import { Styles } from "../types.js";
3
- export declare function composeText(style?: Styles): Partial<TextStyle>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composeText = composeText;
4
- const textStyleKeys = [
5
- "color",
6
- "fontSize",
7
- "fontWeight",
8
- "fontStyle",
9
- "textAlign",
10
- "textAlignVertical",
11
- "letterSpacing",
12
- "lineHeight",
13
- "textDecorationLine",
14
- "textDecorationColor",
15
- "textDecorationStyle",
16
- "fontFamily",
17
- "includeFontPadding",
18
- "textTransform",
19
- "writingDirection",
20
- "textShadowColor",
21
- "textShadowOffset",
22
- "textShadowRadius",
23
- ];
24
- function composeText(style) {
25
- if (!style)
26
- return {};
27
- return Object.fromEntries(Object.entries(style).filter(([key]) => textStyleKeys.includes(key)));
28
- }
29
- //# sourceMappingURL=compose-text.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compose-text.js","sourceRoot":"","sources":["../../src/utils/compose-text.ts"],"names":[],"mappings":";;AAwBA,kCAQC;AA7BD,MAAM,aAAa,GAAwB;IACzC,OAAO;IACP,UAAU;IACV,YAAY;IACZ,WAAW;IACX,WAAW;IACX,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,qBAAqB;IACrB,YAAY;IACZ,oBAAoB;IACpB,eAAe;IACf,kBAAkB;IAClB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;CACnB,CAAC;AAEF,SAAgB,WAAW,CAAC,KAAc;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAEtB,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CACrC,aAAa,CAAC,QAAQ,CAAC,GAAsB,CAAC,CAC/C,CACF,CAAC;AACJ,CAAC"}