@lightningtv/solid
Advanced tools
Comparing version 2.3.1 to 2.4.0
@@ -0,1 +1,2 @@ | ||
import { type Styles } from '@lightningtv/core'; | ||
/** | ||
@@ -5,1 +6,2 @@ * Converts a color string to a color number value. | ||
export declare function hexColor(color?: string | number): number; | ||
export declare function combineStyles(...styles: (Styles | undefined)[]): Styles; |
@@ -1,2 +0,3 @@ | ||
import { isInteger } from '@lightningtv/core'; | ||
import { isInteger, isArray } from '@lightningtv/core'; | ||
import { createMemo } from 'solid-js'; | ||
/** | ||
@@ -21,2 +22,22 @@ * Converts a color string to a color number value. | ||
} | ||
export function combineStyles(...styles) { | ||
return createMemo(() => flattenStyles(styles))(); | ||
} | ||
function flattenStyles(obj, result = {}) { | ||
if (isArray(obj)) { | ||
obj.forEach((item) => { | ||
flattenStyles(item, result); | ||
}); | ||
} | ||
else if (obj) { | ||
// handle the case where the object is not an array | ||
for (const key in obj) { | ||
// be careful of 0 values | ||
if (result[key] === undefined) { | ||
result[key] = obj[key]; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@lightningtv/solid", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "Lightning Renderer for Solid Universal", | ||
@@ -45,3 +45,3 @@ "type": "module", | ||
"dependencies": { | ||
"@lightningtv/core": "^2.3.3", | ||
"@lightningtv/core": "^2.4.0", | ||
"@solid-primitives/event-listener": "^2.3.3", | ||
@@ -48,0 +48,0 @@ "@solid-primitives/mouse": "^2.0.19", |
@@ -1,2 +0,3 @@ | ||
import { isInteger } from '@lightningtv/core'; | ||
import { isInteger, isArray, type Styles } from '@lightningtv/core'; | ||
import { createMemo } from 'solid-js'; | ||
@@ -27,1 +28,26 @@ /** | ||
} | ||
export function combineStyles(...styles: (Styles | undefined)[]): Styles { | ||
return createMemo(() => flattenStyles(styles))(); | ||
} | ||
function flattenStyles( | ||
obj: Styles | undefined | (Styles | undefined)[], | ||
result: Styles = {}, | ||
): Styles { | ||
if (isArray(obj)) { | ||
obj.forEach((item) => { | ||
flattenStyles(item, result); | ||
}); | ||
} else if (obj) { | ||
// handle the case where the object is not an array | ||
for (const key in obj) { | ||
// be careful of 0 values | ||
if (result[key] === undefined) { | ||
result[key as keyof Styles] = obj[key as keyof Styles]!; | ||
} | ||
} | ||
} | ||
return result; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168708
2114
Updated@lightningtv/core@^2.4.0