Skip to content

Commit b6b9bd7

Browse files
authored
Merge pull request #15 from mohit23x/ts
type changes in create function
2 parents dcd74f9 + 58e5be5 commit b6b9bd7

5 files changed

Lines changed: 7 additions & 5 deletions

File tree

build/Sheet.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3+
const SKIP_KEYS = ["transform", "transformMatrix"];
34
class Sheet {
45
constructor(sourceFn) {
56
this.source = sourceFn;
@@ -25,7 +26,7 @@ class Sheet {
2526
const styles = restyle[key];
2627
Object.keys(styles).forEach((styleKey) => {
2728
const styleValue = styles[styleKey];
28-
if (styleValue && Array.isArray(styleValue)) {
29+
if (styleValue && Array.isArray(styleValue) && !SKIP_KEYS.includes(styleKey)) {
2930
// length is checked to allow undefined to set as styleValue
3031
if (activeIndex >= styleValue.length) {
3132
const selectedValue = styleValue[styleValue.length - 1];

build/Sugar.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default class Sugar<T> {
9999
_refresh(): void;
100100
build(themeObj: T): void;
101101
configure(newConstants: Partial<ConstantsType>): void;
102-
create<P extends NamedStyles<P> | NamedStyles<any>>(objFn: Fn<T, P>): StyleSheetType<P>;
102+
create<P extends NamedStyles<P> | NamedStyles<any>>(objFn: Fn<T, P> | P): StyleSheetType<P>;
103103
_calculateActiveIndex(): void;
104104
_calcSheets(): void;
105105
_callListeners(event: buildEventType): void;

lib/Sheet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ConstantsType, Fn, NamedStyles, StyleSheetType } from './type';
22

3+
const SKIP_KEYS = ["transform", "transformMatrix"];
34
export default class Sheet<
45
T,
56
P extends NamedStyles<P> | NamedStyles<any>> {
@@ -38,7 +39,7 @@ export default class Sheet<
3839
const styles = restyle[key];
3940
Object.keys(styles).forEach((styleKey) => {
4041
const styleValue = styles[styleKey];
41-
if (styleValue && Array.isArray(styleValue)) {
42+
if (styleValue && Array.isArray(styleValue) && !SKIP_KEYS.includes(styleKey)) {
4243
// length is checked to allow undefined to set as styleValue
4344
if (activeIndex >= styleValue.length) {
4445
const selectedValue = styleValue[styleValue.length - 1];

lib/Sugar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export default class Sugar<T> {
146146
}
147147

148148
create<P extends NamedStyles<P> | NamedStyles<any>>(
149-
objFn: Fn<T, P>
149+
objFn: Fn<T, P> | P
150150
): StyleSheetType<P> {
151151
if (typeof objFn === 'function') {
152152
const sheet = new Sheet(objFn);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-sugar-style",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "React Native Stylesheet alternative with theme support",
55
"author": "mohit23x",
66
"license": "MIT",

0 commit comments

Comments
 (0)