1
1
import React , { forwardRef } from 'react'
2
- import {
3
- DynamicLayoutPipe ,
4
- GetScalePropsFunction ,
5
- ScaleConfig ,
6
- ScaleContext ,
7
- ScaleProps ,
8
- } from './scale-context'
2
+ import { DynamicLayoutPipe , ScaleConfig , ScaleContext , ScaleProps } from './scale-context'
9
3
import useTheme from '../use-theme'
10
4
import { isCSSNumberValue } from '../utils/collections'
5
+ import { generateGetAllScaleProps , generateGetScaleProps } from './utils'
11
6
12
7
const reduceScaleCoefficient = ( scale : number ) => {
13
8
if ( scale === 1 ) return scale
@@ -70,20 +65,9 @@ const withScale = <T, P = {}>(
70
65
const customFactor = factor * Number ( attrValue )
71
66
return `calc(${ customFactor } * ${ unit } )`
72
67
}
73
- const getScaleProps : GetScalePropsFunction = keyOrKeys => {
74
- if ( ! Array . isArray ( keyOrKeys ) ) return props [ keyOrKeys as keyof ScaleProps ]
75
- let value = undefined
76
- for ( const key of keyOrKeys ) {
77
- const currentValue = props [ key ]
78
- if ( typeof currentValue !== 'undefined' ) {
79
- value = currentValue
80
- }
81
- }
82
- return value
83
- }
84
68
85
69
const value : ScaleConfig = {
86
- unit,
70
+ unit : unit ,
87
71
SCALES : {
88
72
pt : makeScaleHandler ( paddingTop ?? pt ?? py ?? padding ) ,
89
73
pr : makeScaleHandler ( paddingRight ?? pr ?? px ?? padding ) ,
@@ -101,7 +85,8 @@ const withScale = <T, P = {}>(
101
85
height : makeScaleHandler ( height ?? h ) ,
102
86
font : makeScaleHandler ( font ) ,
103
87
} ,
104
- getScaleProps,
88
+ getScaleProps : generateGetScaleProps ( props ) ,
89
+ getAllScaleProps : generateGetAllScaleProps ( props ) ,
105
90
}
106
91
107
92
return (
0 commit comments