Skip to content

Commit

Permalink
Merge pull request #15 from mohit23x/ts
Browse files Browse the repository at this point in the history
type changes in create function
  • Loading branch information
mohit23x authored Feb 21, 2021
2 parents dcd74f9 + 58e5be5 commit b6b9bd7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion build/Sheet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const SKIP_KEYS = ["transform", "transformMatrix"];
class Sheet {
constructor(sourceFn) {
this.source = sourceFn;
Expand All @@ -25,7 +26,7 @@ class Sheet {
const styles = restyle[key];
Object.keys(styles).forEach((styleKey) => {
const styleValue = styles[styleKey];
if (styleValue && Array.isArray(styleValue)) {
if (styleValue && Array.isArray(styleValue) && !SKIP_KEYS.includes(styleKey)) {
// length is checked to allow undefined to set as styleValue
if (activeIndex >= styleValue.length) {
const selectedValue = styleValue[styleValue.length - 1];
Expand Down
2 changes: 1 addition & 1 deletion build/Sugar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Sugar<T> {
_refresh(): void;
build(themeObj: T): void;
configure(newConstants: Partial<ConstantsType>): void;
create<P extends NamedStyles<P> | NamedStyles<any>>(objFn: Fn<T, P>): StyleSheetType<P>;
create<P extends NamedStyles<P> | NamedStyles<any>>(objFn: Fn<T, P> | P): StyleSheetType<P>;
_calculateActiveIndex(): void;
_calcSheets(): void;
_callListeners(event: buildEventType): void;
Expand Down
3 changes: 2 additions & 1 deletion lib/Sheet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ConstantsType, Fn, NamedStyles, StyleSheetType } from './type';

const SKIP_KEYS = ["transform", "transformMatrix"];
export default class Sheet<
T,
P extends NamedStyles<P> | NamedStyles<any>> {
Expand Down Expand Up @@ -38,7 +39,7 @@ export default class Sheet<
const styles = restyle[key];
Object.keys(styles).forEach((styleKey) => {
const styleValue = styles[styleKey];
if (styleValue && Array.isArray(styleValue)) {
if (styleValue && Array.isArray(styleValue) && !SKIP_KEYS.includes(styleKey)) {
// length is checked to allow undefined to set as styleValue
if (activeIndex >= styleValue.length) {
const selectedValue = styleValue[styleValue.length - 1];
Expand Down
2 changes: 1 addition & 1 deletion lib/Sugar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class Sugar<T> {
}

create<P extends NamedStyles<P> | NamedStyles<any>>(
objFn: Fn<T, P>
objFn: Fn<T, P> | P
): StyleSheetType<P> {
if (typeof objFn === 'function') {
const sheet = new Sheet(objFn);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-sugar-style",
"version": "0.1.6",
"version": "0.1.7",
"description": "React Native Stylesheet alternative with theme support",
"author": "mohit23x",
"license": "MIT",
Expand Down

0 comments on commit b6b9bd7

Please sign in to comment.