11import { Numeric } from '@const/defaultOptions'
22import compose from '@utils/functions/compose'
3- import transformNumeric from '@utils/math/transformNumeric'
43import sanitizeTemplateArea from '@utils/strings/sanitizeTemplateArea'
54
6- export type ValueTransformer < Input , Return > = ( value : Input ) => Return
5+ export type ValueTransformer < Input , Return > = (
6+ value : Input ,
7+ Layout : any ,
8+ ) => Return
79
810interface PropAlias {
911 output : string [ ]
@@ -14,6 +16,13 @@ export interface PropAliases {
1416 [ aliasName : string ] : PropAlias
1517}
1618
19+ const deferredTransformNumeric : ValueTransformer < Numeric , string > = (
20+ value ,
21+ Layout ,
22+ ) => {
23+ return Layout . transformNumeric ( value )
24+ }
25+
1726type TransformTemplateString = ( template : string ) => string
1827const transformTemplateString : TransformTemplateString = compose (
1928 ( areas : string [ ] ) => areas . join ( '\n' ) ,
@@ -67,35 +76,35 @@ const propAliases: PropAliases = {
6776 } ,
6877 gap : {
6978 output : [ 'grid-gap' ] ,
70- transformValue : transformNumeric ,
79+ transformValue : deferredTransformNumeric ,
7180 } ,
7281 gapCol : {
7382 output : [ 'grid-column-gap' ] ,
74- transformValue : transformNumeric ,
83+ transformValue : deferredTransformNumeric ,
7584 } ,
7685 gapRow : {
7786 output : [ 'grid-row-gap' ] ,
78- transformValue : transformNumeric ,
87+ transformValue : deferredTransformNumeric ,
7988 } ,
8089 gutter : {
8190 output : [ 'grid-gap' ] ,
82- transformValue : transformNumeric ,
91+ transformValue : deferredTransformNumeric ,
8392 } ,
8493 gutterCol : {
8594 output : [ 'grid-column-gap' ] ,
86- transformValue : transformNumeric ,
95+ transformValue : deferredTransformNumeric ,
8796 } ,
8897 gutterRow : {
8998 output : [ 'grid-row-gap' ] ,
90- transformValue : transformNumeric ,
99+ transformValue : deferredTransformNumeric ,
91100 } ,
92101 autoRows : {
93102 output : [ 'grid-auto-rows' ] ,
94- transformValue : transformNumeric ,
103+ transformValue : deferredTransformNumeric ,
95104 } ,
96105 autoCols : {
97106 output : [ 'grid-auto-columns' ] ,
98- transformValue : transformNumeric ,
107+ transformValue : deferredTransformNumeric ,
99108 } ,
100109 autoFlow : {
101110 output : [ 'grid-auto-flow' ] ,
@@ -142,86 +151,86 @@ const propAliases: PropAliases = {
142151 /* Dimensions */
143152 height : {
144153 output : [ 'height' ] ,
145- transformValue : transformNumeric ,
154+ transformValue : deferredTransformNumeric ,
146155 } ,
147156 minHeight : {
148157 output : [ 'min-height' ] ,
149- transformValue : transformNumeric ,
158+ transformValue : deferredTransformNumeric ,
150159 } ,
151160 maxHeight : {
152161 output : [ 'max-height' ] ,
153- transformValue : transformNumeric ,
162+ transformValue : deferredTransformNumeric ,
154163 } ,
155164 width : {
156165 output : [ 'width' ] ,
157- transformValue : transformNumeric ,
166+ transformValue : deferredTransformNumeric ,
158167 } ,
159168 minWidth : {
160169 output : [ 'min-width' ] ,
161- transformValue : transformNumeric ,
170+ transformValue : deferredTransformNumeric ,
162171 } ,
163172 maxWidth : {
164173 output : [ 'max-width' ] ,
165- transformValue : transformNumeric ,
174+ transformValue : deferredTransformNumeric ,
166175 } ,
167176
168177 /* Spacing */
169178 margin : {
170179 output : [ 'margin' ] ,
171- transformValue : transformNumeric ,
180+ transformValue : deferredTransformNumeric ,
172181 } ,
173182 marginTop : {
174183 output : [ 'margin-top' ] ,
175- transformValue : transformNumeric ,
184+ transformValue : deferredTransformNumeric ,
176185 } ,
177186 marginRight : {
178187 output : [ 'margin-right' ] ,
179- transformValue : transformNumeric ,
188+ transformValue : deferredTransformNumeric ,
180189 } ,
181190 marginBottom : {
182191 output : [ 'margin-bottom' ] ,
183- transformValue : transformNumeric ,
192+ transformValue : deferredTransformNumeric ,
184193 } ,
185194 marginLeft : {
186195 output : [ 'margin-left' ] ,
187- transformValue : transformNumeric ,
196+ transformValue : deferredTransformNumeric ,
188197 } ,
189198 marginVertical : {
190199 output : [ 'margin-top' , 'margin-bottom' ] ,
191- transformValue : transformNumeric ,
200+ transformValue : deferredTransformNumeric ,
192201 } ,
193202 marginHorizontal : {
194203 output : [ 'margin-right' , 'margin-left' ] ,
195- transformValue : transformNumeric ,
204+ transformValue : deferredTransformNumeric ,
196205 } ,
197206
198207 padding : {
199208 output : [ 'padding' ] ,
200- transformValue : transformNumeric ,
209+ transformValue : deferredTransformNumeric ,
201210 } ,
202211 paddingTop : {
203212 output : [ 'padding-top' ] ,
204- transformValue : transformNumeric ,
213+ transformValue : deferredTransformNumeric ,
205214 } ,
206215 paddingRight : {
207216 output : [ 'padding-right' ] ,
208- transformValue : transformNumeric ,
217+ transformValue : deferredTransformNumeric ,
209218 } ,
210219 paddingBottom : {
211220 output : [ 'padding-bottom' ] ,
212- transformValue : transformNumeric ,
221+ transformValue : deferredTransformNumeric ,
213222 } ,
214223 paddingLeft : {
215224 output : [ 'padding-left' ] ,
216- transformValue : transformNumeric ,
225+ transformValue : deferredTransformNumeric ,
217226 } ,
218227 paddingVertical : {
219228 output : [ 'padding-top' , 'padding-bottom' ] ,
220- transformValue : transformNumeric ,
229+ transformValue : deferredTransformNumeric ,
221230 } ,
222231 paddingHorizontal : {
223232 output : [ 'padding-right' , 'padding-left' ] ,
224- transformValue : transformNumeric ,
233+ transformValue : deferredTransformNumeric ,
225234 } ,
226235}
227236
0 commit comments