1
- import { isPlainObject , props } from 'uinix-fp' ;
2
- import { themeMapping } from 'uinix-theme' ;
1
+ import { isPlainObject } from 'uinix-fp' ;
2
+ import { defaultThemeSpec } from 'uinix-theme' ;
3
+
4
+ import { props } from '../util/props.js' ;
3
5
4
6
export { themeValue } ;
5
7
export { resolveThemeValues as _resolveThemeValues } ;
6
8
7
9
/**
8
10
* @typedef {import('fela').IStyle } IStyle
9
- * @typedef {import('uinix-theme').ThemeMapping } UinixThemeThemeMapping
11
+ * @typedef {import('uinix-theme').ThemeSpec } UinixThemeThemeMapping
10
12
* @typedef {import('../types.js').AnyProps } AnyProps
11
13
* @typedef {import('../types.js').StyleObject } StyleObject
12
14
* @typedef {import('../types.js').SystemTheme } SystemTheme
@@ -50,9 +52,9 @@ const themeValue = () => (style, _type, _renderer, props) =>
50
52
*/
51
53
const resolveThemeValues = ( style , theme ) => {
52
54
const NEGATIVE_REGEXP = / ^ \s * - / ;
53
- const mapping = createThemeMapping ( themeMapping ) ;
55
+ const mapping = createThemeMapping ( defaultThemeSpec ) ;
54
56
55
- Object . entries ( style ) . forEach ( ( [ property , styleValue ] ) => {
57
+ for ( let [ property , styleValue ] of Object . entries ( style ) ) {
56
58
const resolveThemeValue = mapping [ property ] ;
57
59
if ( resolveThemeValue ) {
58
60
const isNegative = NEGATIVE_REGEXP . test ( styleValue ) ;
@@ -73,7 +75,7 @@ const resolveThemeValues = (style, theme) => {
73
75
// @ts -ignore: we CAN access from IStyle
74
76
style [ property ] = resolveThemeValues ( style [ property ] , theme ) ;
75
77
}
76
- } ) ;
78
+ }
77
79
78
80
return style ;
79
81
} ;
@@ -92,9 +94,10 @@ const createThemeMapping = (themeMapping) => {
92
94
const initialAcc = { } ;
93
95
return Object . entries ( themeMapping ) . reduce (
94
96
( acc , [ themeProperty , cssProperties ] ) => {
95
- cssProperties . forEach ( ( cssProperty ) => {
97
+ for ( const cssProperty of cssProperties ) {
96
98
acc [ cssProperty ] = props ( themeProperty ) ;
97
- } ) ;
99
+ }
100
+
98
101
return acc ;
99
102
} ,
100
103
initialAcc ,
0 commit comments