@react-spectrum/utils 3.0.0-nightly-641446f65-240905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/BreakpointProvider.main.js +75 -0
- package/dist/BreakpointProvider.main.js.map +1 -0
- package/dist/BreakpointProvider.mjs +64 -0
- package/dist/BreakpointProvider.module.js +64 -0
- package/dist/BreakpointProvider.module.js.map +1 -0
- package/dist/Slots.main.js +73 -0
- package/dist/Slots.main.js.map +1 -0
- package/dist/Slots.mjs +61 -0
- package/dist/Slots.module.js +61 -0
- package/dist/Slots.module.js.map +1 -0
- package/dist/classNames.main.js +50 -0
- package/dist/classNames.main.js.map +1 -0
- package/dist/classNames.mjs +39 -0
- package/dist/classNames.module.js +39 -0
- package/dist/classNames.module.js.map +1 -0
- package/dist/getWrappedElement.main.js +32 -0
- package/dist/getWrappedElement.main.js.map +1 -0
- package/dist/getWrappedElement.mjs +23 -0
- package/dist/getWrappedElement.module.js +23 -0
- package/dist/getWrappedElement.module.js.map +1 -0
- package/dist/import.mjs +36 -0
- package/dist/main.js +70 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +36 -0
- package/dist/module.js.map +1 -0
- package/dist/styleProps.main.js +468 -0
- package/dist/styleProps.main.js.map +1 -0
- package/dist/styleProps.mjs +456 -0
- package/dist/styleProps.module.js +456 -0
- package/dist/styleProps.module.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useDOMRef.main.js +64 -0
- package/dist/useDOMRef.main.js.map +1 -0
- package/dist/useDOMRef.mjs +54 -0
- package/dist/useDOMRef.module.js +54 -0
- package/dist/useDOMRef.module.js.map +1 -0
- package/dist/useHasChild.main.js +35 -0
- package/dist/useHasChild.main.js.map +1 -0
- package/dist/useHasChild.mjs +30 -0
- package/dist/useHasChild.module.js +30 -0
- package/dist/useHasChild.module.js.map +1 -0
- package/dist/useIsMobileDevice.main.js +28 -0
- package/dist/useIsMobileDevice.main.js.map +1 -0
- package/dist/useIsMobileDevice.mjs +23 -0
- package/dist/useIsMobileDevice.module.js +23 -0
- package/dist/useIsMobileDevice.module.js.map +1 -0
- package/dist/useMediaQuery.main.js +46 -0
- package/dist/useMediaQuery.main.js.map +1 -0
- package/dist/useMediaQuery.mjs +41 -0
- package/dist/useMediaQuery.module.js +41 -0
- package/dist/useMediaQuery.module.js.map +1 -0
- package/package.json +41 -0
- package/src/BreakpointProvider.tsx +92 -0
- package/src/Slots.tsx +70 -0
- package/src/classNames.ts +56 -0
- package/src/getWrappedElement.tsx +23 -0
- package/src/index.ts +35 -0
- package/src/styleProps.ts +313 -0
- package/src/useDOMRef.ts +57 -0
- package/src/useHasChild.ts +23 -0
- package/src/useIsMobileDevice.ts +24 -0
- package/src/useMediaQuery.ts +44 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
var $893a66ba513f4a66$exports = require("./BreakpointProvider.main.js");
|
|
2
|
+
var $5XTxG$reactariai18n = require("@react-aria/i18n");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "baseStyleProps", () => $d3b73be57066120b$export$fe9c6e915565b4e8);
|
|
10
|
+
$parcel$export(module.exports, "dimensionValue", () => $d3b73be57066120b$export$abc24f5b99744ea6);
|
|
11
|
+
$parcel$export(module.exports, "passthroughStyle", () => $d3b73be57066120b$export$46b6c81d11d2c30a);
|
|
12
|
+
$parcel$export(module.exports, "viewStyleProps", () => $d3b73be57066120b$export$e0705d1a55f297c);
|
|
13
|
+
$parcel$export(module.exports, "responsiveDimensionValue", () => $d3b73be57066120b$export$f348bec194f2e6b5);
|
|
14
|
+
$parcel$export(module.exports, "getResponsiveProp", () => $d3b73be57066120b$export$52dbfdbe1b2c3541);
|
|
15
|
+
$parcel$export(module.exports, "convertStyleProps", () => $d3b73be57066120b$export$f3c39bb9534218d0);
|
|
16
|
+
$parcel$export(module.exports, "useStyleProps", () => $d3b73be57066120b$export$b8e6fb9d2dff3f41);
|
|
17
|
+
/*
|
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const $d3b73be57066120b$export$fe9c6e915565b4e8 = {
|
|
30
|
+
margin: [
|
|
31
|
+
'margin',
|
|
32
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
33
|
+
],
|
|
34
|
+
marginStart: [
|
|
35
|
+
$d3b73be57066120b$var$rtl('marginLeft', 'marginRight'),
|
|
36
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
37
|
+
],
|
|
38
|
+
marginEnd: [
|
|
39
|
+
$d3b73be57066120b$var$rtl('marginRight', 'marginLeft'),
|
|
40
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
41
|
+
],
|
|
42
|
+
// marginLeft: ['marginLeft', dimensionValue],
|
|
43
|
+
// marginRight: ['marginRight', dimensionValue],
|
|
44
|
+
marginTop: [
|
|
45
|
+
'marginTop',
|
|
46
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
47
|
+
],
|
|
48
|
+
marginBottom: [
|
|
49
|
+
'marginBottom',
|
|
50
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
51
|
+
],
|
|
52
|
+
marginX: [
|
|
53
|
+
[
|
|
54
|
+
'marginLeft',
|
|
55
|
+
'marginRight'
|
|
56
|
+
],
|
|
57
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
58
|
+
],
|
|
59
|
+
marginY: [
|
|
60
|
+
[
|
|
61
|
+
'marginTop',
|
|
62
|
+
'marginBottom'
|
|
63
|
+
],
|
|
64
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
65
|
+
],
|
|
66
|
+
width: [
|
|
67
|
+
'width',
|
|
68
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
69
|
+
],
|
|
70
|
+
height: [
|
|
71
|
+
'height',
|
|
72
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
73
|
+
],
|
|
74
|
+
minWidth: [
|
|
75
|
+
'minWidth',
|
|
76
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
77
|
+
],
|
|
78
|
+
minHeight: [
|
|
79
|
+
'minHeight',
|
|
80
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
81
|
+
],
|
|
82
|
+
maxWidth: [
|
|
83
|
+
'maxWidth',
|
|
84
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
85
|
+
],
|
|
86
|
+
maxHeight: [
|
|
87
|
+
'maxHeight',
|
|
88
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
89
|
+
],
|
|
90
|
+
isHidden: [
|
|
91
|
+
'display',
|
|
92
|
+
$d3b73be57066120b$var$hiddenValue
|
|
93
|
+
],
|
|
94
|
+
alignSelf: [
|
|
95
|
+
'alignSelf',
|
|
96
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
97
|
+
],
|
|
98
|
+
justifySelf: [
|
|
99
|
+
'justifySelf',
|
|
100
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
101
|
+
],
|
|
102
|
+
position: [
|
|
103
|
+
'position',
|
|
104
|
+
$d3b73be57066120b$var$anyValue
|
|
105
|
+
],
|
|
106
|
+
zIndex: [
|
|
107
|
+
'zIndex',
|
|
108
|
+
$d3b73be57066120b$var$anyValue
|
|
109
|
+
],
|
|
110
|
+
top: [
|
|
111
|
+
'top',
|
|
112
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
113
|
+
],
|
|
114
|
+
bottom: [
|
|
115
|
+
'bottom',
|
|
116
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
117
|
+
],
|
|
118
|
+
start: [
|
|
119
|
+
$d3b73be57066120b$var$rtl('left', 'right'),
|
|
120
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
121
|
+
],
|
|
122
|
+
end: [
|
|
123
|
+
$d3b73be57066120b$var$rtl('right', 'left'),
|
|
124
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
125
|
+
],
|
|
126
|
+
left: [
|
|
127
|
+
'left',
|
|
128
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
129
|
+
],
|
|
130
|
+
right: [
|
|
131
|
+
'right',
|
|
132
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
133
|
+
],
|
|
134
|
+
order: [
|
|
135
|
+
'order',
|
|
136
|
+
$d3b73be57066120b$var$anyValue
|
|
137
|
+
],
|
|
138
|
+
flex: [
|
|
139
|
+
'flex',
|
|
140
|
+
$d3b73be57066120b$var$flexValue
|
|
141
|
+
],
|
|
142
|
+
flexGrow: [
|
|
143
|
+
'flexGrow',
|
|
144
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
145
|
+
],
|
|
146
|
+
flexShrink: [
|
|
147
|
+
'flexShrink',
|
|
148
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
149
|
+
],
|
|
150
|
+
flexBasis: [
|
|
151
|
+
'flexBasis',
|
|
152
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
153
|
+
],
|
|
154
|
+
gridArea: [
|
|
155
|
+
'gridArea',
|
|
156
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
157
|
+
],
|
|
158
|
+
gridColumn: [
|
|
159
|
+
'gridColumn',
|
|
160
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
161
|
+
],
|
|
162
|
+
gridColumnEnd: [
|
|
163
|
+
'gridColumnEnd',
|
|
164
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
165
|
+
],
|
|
166
|
+
gridColumnStart: [
|
|
167
|
+
'gridColumnStart',
|
|
168
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
169
|
+
],
|
|
170
|
+
gridRow: [
|
|
171
|
+
'gridRow',
|
|
172
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
173
|
+
],
|
|
174
|
+
gridRowEnd: [
|
|
175
|
+
'gridRowEnd',
|
|
176
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
177
|
+
],
|
|
178
|
+
gridRowStart: [
|
|
179
|
+
'gridRowStart',
|
|
180
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
181
|
+
]
|
|
182
|
+
};
|
|
183
|
+
const $d3b73be57066120b$export$e0705d1a55f297c = {
|
|
184
|
+
...$d3b73be57066120b$export$fe9c6e915565b4e8,
|
|
185
|
+
backgroundColor: [
|
|
186
|
+
'backgroundColor',
|
|
187
|
+
$d3b73be57066120b$var$backgroundColorValue
|
|
188
|
+
],
|
|
189
|
+
borderWidth: [
|
|
190
|
+
'borderWidth',
|
|
191
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
192
|
+
],
|
|
193
|
+
borderStartWidth: [
|
|
194
|
+
$d3b73be57066120b$var$rtl('borderLeftWidth', 'borderRightWidth'),
|
|
195
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
196
|
+
],
|
|
197
|
+
borderEndWidth: [
|
|
198
|
+
$d3b73be57066120b$var$rtl('borderRightWidth', 'borderLeftWidth'),
|
|
199
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
200
|
+
],
|
|
201
|
+
borderLeftWidth: [
|
|
202
|
+
'borderLeftWidth',
|
|
203
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
204
|
+
],
|
|
205
|
+
borderRightWidth: [
|
|
206
|
+
'borderRightWidth',
|
|
207
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
208
|
+
],
|
|
209
|
+
borderTopWidth: [
|
|
210
|
+
'borderTopWidth',
|
|
211
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
212
|
+
],
|
|
213
|
+
borderBottomWidth: [
|
|
214
|
+
'borderBottomWidth',
|
|
215
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
216
|
+
],
|
|
217
|
+
borderXWidth: [
|
|
218
|
+
[
|
|
219
|
+
'borderLeftWidth',
|
|
220
|
+
'borderRightWidth'
|
|
221
|
+
],
|
|
222
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
223
|
+
],
|
|
224
|
+
borderYWidth: [
|
|
225
|
+
[
|
|
226
|
+
'borderTopWidth',
|
|
227
|
+
'borderBottomWidth'
|
|
228
|
+
],
|
|
229
|
+
$d3b73be57066120b$var$borderSizeValue
|
|
230
|
+
],
|
|
231
|
+
borderColor: [
|
|
232
|
+
'borderColor',
|
|
233
|
+
$d3b73be57066120b$var$borderColorValue
|
|
234
|
+
],
|
|
235
|
+
borderStartColor: [
|
|
236
|
+
$d3b73be57066120b$var$rtl('borderLeftColor', 'borderRightColor'),
|
|
237
|
+
$d3b73be57066120b$var$borderColorValue
|
|
238
|
+
],
|
|
239
|
+
borderEndColor: [
|
|
240
|
+
$d3b73be57066120b$var$rtl('borderRightColor', 'borderLeftColor'),
|
|
241
|
+
$d3b73be57066120b$var$borderColorValue
|
|
242
|
+
],
|
|
243
|
+
borderLeftColor: [
|
|
244
|
+
'borderLeftColor',
|
|
245
|
+
$d3b73be57066120b$var$borderColorValue
|
|
246
|
+
],
|
|
247
|
+
borderRightColor: [
|
|
248
|
+
'borderRightColor',
|
|
249
|
+
$d3b73be57066120b$var$borderColorValue
|
|
250
|
+
],
|
|
251
|
+
borderTopColor: [
|
|
252
|
+
'borderTopColor',
|
|
253
|
+
$d3b73be57066120b$var$borderColorValue
|
|
254
|
+
],
|
|
255
|
+
borderBottomColor: [
|
|
256
|
+
'borderBottomColor',
|
|
257
|
+
$d3b73be57066120b$var$borderColorValue
|
|
258
|
+
],
|
|
259
|
+
borderXColor: [
|
|
260
|
+
[
|
|
261
|
+
'borderLeftColor',
|
|
262
|
+
'borderRightColor'
|
|
263
|
+
],
|
|
264
|
+
$d3b73be57066120b$var$borderColorValue
|
|
265
|
+
],
|
|
266
|
+
borderYColor: [
|
|
267
|
+
[
|
|
268
|
+
'borderTopColor',
|
|
269
|
+
'borderBottomColor'
|
|
270
|
+
],
|
|
271
|
+
$d3b73be57066120b$var$borderColorValue
|
|
272
|
+
],
|
|
273
|
+
borderRadius: [
|
|
274
|
+
'borderRadius',
|
|
275
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
276
|
+
],
|
|
277
|
+
borderTopStartRadius: [
|
|
278
|
+
$d3b73be57066120b$var$rtl('borderTopLeftRadius', 'borderTopRightRadius'),
|
|
279
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
280
|
+
],
|
|
281
|
+
borderTopEndRadius: [
|
|
282
|
+
$d3b73be57066120b$var$rtl('borderTopRightRadius', 'borderTopLeftRadius'),
|
|
283
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
284
|
+
],
|
|
285
|
+
borderBottomStartRadius: [
|
|
286
|
+
$d3b73be57066120b$var$rtl('borderBottomLeftRadius', 'borderBottomRightRadius'),
|
|
287
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
288
|
+
],
|
|
289
|
+
borderBottomEndRadius: [
|
|
290
|
+
$d3b73be57066120b$var$rtl('borderBottomRightRadius', 'borderBottomLeftRadius'),
|
|
291
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
292
|
+
],
|
|
293
|
+
borderTopLeftRadius: [
|
|
294
|
+
'borderTopLeftRadius',
|
|
295
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
296
|
+
],
|
|
297
|
+
borderTopRightRadius: [
|
|
298
|
+
'borderTopRightRadius',
|
|
299
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
300
|
+
],
|
|
301
|
+
borderBottomLeftRadius: [
|
|
302
|
+
'borderBottomLeftRadius',
|
|
303
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
304
|
+
],
|
|
305
|
+
borderBottomRightRadius: [
|
|
306
|
+
'borderBottomRightRadius',
|
|
307
|
+
$d3b73be57066120b$var$borderRadiusValue
|
|
308
|
+
],
|
|
309
|
+
padding: [
|
|
310
|
+
'padding',
|
|
311
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
312
|
+
],
|
|
313
|
+
paddingStart: [
|
|
314
|
+
$d3b73be57066120b$var$rtl('paddingLeft', 'paddingRight'),
|
|
315
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
316
|
+
],
|
|
317
|
+
paddingEnd: [
|
|
318
|
+
$d3b73be57066120b$var$rtl('paddingRight', 'paddingLeft'),
|
|
319
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
320
|
+
],
|
|
321
|
+
paddingLeft: [
|
|
322
|
+
'paddingLeft',
|
|
323
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
324
|
+
],
|
|
325
|
+
paddingRight: [
|
|
326
|
+
'paddingRight',
|
|
327
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
328
|
+
],
|
|
329
|
+
paddingTop: [
|
|
330
|
+
'paddingTop',
|
|
331
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
332
|
+
],
|
|
333
|
+
paddingBottom: [
|
|
334
|
+
'paddingBottom',
|
|
335
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
336
|
+
],
|
|
337
|
+
paddingX: [
|
|
338
|
+
[
|
|
339
|
+
'paddingLeft',
|
|
340
|
+
'paddingRight'
|
|
341
|
+
],
|
|
342
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
343
|
+
],
|
|
344
|
+
paddingY: [
|
|
345
|
+
[
|
|
346
|
+
'paddingTop',
|
|
347
|
+
'paddingBottom'
|
|
348
|
+
],
|
|
349
|
+
$d3b73be57066120b$export$abc24f5b99744ea6
|
|
350
|
+
],
|
|
351
|
+
overflow: [
|
|
352
|
+
'overflow',
|
|
353
|
+
$d3b73be57066120b$export$46b6c81d11d2c30a
|
|
354
|
+
]
|
|
355
|
+
};
|
|
356
|
+
const $d3b73be57066120b$var$borderStyleProps = {
|
|
357
|
+
borderWidth: 'borderStyle',
|
|
358
|
+
borderLeftWidth: 'borderLeftStyle',
|
|
359
|
+
borderRightWidth: 'borderRightStyle',
|
|
360
|
+
borderTopWidth: 'borderTopStyle',
|
|
361
|
+
borderBottomWidth: 'borderBottomStyle'
|
|
362
|
+
};
|
|
363
|
+
function $d3b73be57066120b$var$rtl(ltr, rtl) {
|
|
364
|
+
return (direction)=>direction === 'rtl' ? rtl : ltr;
|
|
365
|
+
}
|
|
366
|
+
const $d3b73be57066120b$var$UNIT_RE = /(%|px|em|rem|vw|vh|auto|cm|mm|in|pt|pc|ex|ch|rem|vmin|vmax|fr)$/;
|
|
367
|
+
const $d3b73be57066120b$var$FUNC_RE = /^\s*\w+\(/;
|
|
368
|
+
const $d3b73be57066120b$var$SPECTRUM_VARIABLE_RE = /(static-)?size-\d+|single-line-(height|width)/g;
|
|
369
|
+
function $d3b73be57066120b$export$abc24f5b99744ea6(value) {
|
|
370
|
+
if (typeof value === 'number') return value + 'px';
|
|
371
|
+
if (!value) return undefined;
|
|
372
|
+
if ($d3b73be57066120b$var$UNIT_RE.test(value)) return value;
|
|
373
|
+
if ($d3b73be57066120b$var$FUNC_RE.test(value)) return value.replace($d3b73be57066120b$var$SPECTRUM_VARIABLE_RE, 'var(--spectrum-global-dimension-$&, var(--spectrum-alias-$&))');
|
|
374
|
+
return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;
|
|
375
|
+
}
|
|
376
|
+
function $d3b73be57066120b$export$f348bec194f2e6b5(value, matchedBreakpoints) {
|
|
377
|
+
value = $d3b73be57066120b$export$52dbfdbe1b2c3541(value, matchedBreakpoints);
|
|
378
|
+
return $d3b73be57066120b$export$abc24f5b99744ea6(value);
|
|
379
|
+
}
|
|
380
|
+
function $d3b73be57066120b$var$colorValue(value, type = 'default', version = 5) {
|
|
381
|
+
if (version > 5) return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;
|
|
382
|
+
return `var(--spectrum-legacy-color-${value}, var(--spectrum-global-color-${value}, var(--spectrum-semantic-${value}-color-${type})))`;
|
|
383
|
+
}
|
|
384
|
+
function $d3b73be57066120b$var$backgroundColorValue(value, version = 5) {
|
|
385
|
+
if (!value) return undefined;
|
|
386
|
+
return `var(--spectrum-alias-background-color-${value}, ${$d3b73be57066120b$var$colorValue(value, 'background', version)})`;
|
|
387
|
+
}
|
|
388
|
+
function $d3b73be57066120b$var$borderColorValue(value, version = 5) {
|
|
389
|
+
if (!value) return undefined;
|
|
390
|
+
if (value === 'default') return 'var(--spectrum-alias-border-color)';
|
|
391
|
+
return `var(--spectrum-alias-border-color-${value}, ${$d3b73be57066120b$var$colorValue(value, 'border', version)})`;
|
|
392
|
+
}
|
|
393
|
+
function $d3b73be57066120b$var$borderSizeValue(value) {
|
|
394
|
+
return value && value !== 'none' ? `var(--spectrum-alias-border-size-${value})` : '0';
|
|
395
|
+
}
|
|
396
|
+
function $d3b73be57066120b$var$borderRadiusValue(value) {
|
|
397
|
+
if (!value) return undefined;
|
|
398
|
+
return `var(--spectrum-alias-border-radius-${value})`;
|
|
399
|
+
}
|
|
400
|
+
function $d3b73be57066120b$var$hiddenValue(value) {
|
|
401
|
+
return value ? 'none' : undefined;
|
|
402
|
+
}
|
|
403
|
+
function $d3b73be57066120b$var$anyValue(value) {
|
|
404
|
+
return value;
|
|
405
|
+
}
|
|
406
|
+
function $d3b73be57066120b$var$flexValue(value) {
|
|
407
|
+
if (typeof value === 'boolean') return value ? '1' : undefined;
|
|
408
|
+
return '' + value;
|
|
409
|
+
}
|
|
410
|
+
function $d3b73be57066120b$export$f3c39bb9534218d0(props, handlers, direction, matchedBreakpoints) {
|
|
411
|
+
let style = {};
|
|
412
|
+
for(let key in props){
|
|
413
|
+
let styleProp = handlers[key];
|
|
414
|
+
if (!styleProp || props[key] == null) continue;
|
|
415
|
+
let [name, convert] = styleProp;
|
|
416
|
+
if (typeof name === 'function') name = name(direction);
|
|
417
|
+
let prop = $d3b73be57066120b$export$52dbfdbe1b2c3541(props[key], matchedBreakpoints);
|
|
418
|
+
let value = convert(prop, props.colorVersion);
|
|
419
|
+
if (Array.isArray(name)) for (let k of name)style[k] = value;
|
|
420
|
+
else style[name] = value;
|
|
421
|
+
}
|
|
422
|
+
for(let prop in $d3b73be57066120b$var$borderStyleProps)if (style[prop]) {
|
|
423
|
+
style[$d3b73be57066120b$var$borderStyleProps[prop]] = 'solid';
|
|
424
|
+
style.boxSizing = 'border-box';
|
|
425
|
+
}
|
|
426
|
+
return style;
|
|
427
|
+
}
|
|
428
|
+
function $d3b73be57066120b$export$b8e6fb9d2dff3f41(props, handlers = $d3b73be57066120b$export$fe9c6e915565b4e8, options = {}) {
|
|
429
|
+
let { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, ...otherProps } = props;
|
|
430
|
+
let breakpointProvider = (0, $893a66ba513f4a66$exports.useBreakpoint)();
|
|
431
|
+
let { direction: direction } = (0, $5XTxG$reactariai18n.useLocale)();
|
|
432
|
+
let { matchedBreakpoints: matchedBreakpoints = (breakpointProvider === null || breakpointProvider === void 0 ? void 0 : breakpointProvider.matchedBreakpoints) || [
|
|
433
|
+
'base'
|
|
434
|
+
] } = options;
|
|
435
|
+
let styles = $d3b73be57066120b$export$f3c39bb9534218d0(props, handlers, direction, matchedBreakpoints);
|
|
436
|
+
let style = {
|
|
437
|
+
...UNSAFE_style,
|
|
438
|
+
...styles
|
|
439
|
+
};
|
|
440
|
+
// @ts-ignore
|
|
441
|
+
if (otherProps.className) console.warn("The className prop is unsafe and is unsupported in React Spectrum v3. Please use style props with Spectrum variables, or UNSAFE_className if you absolutely must do something custom. Note that this may break in future versions due to DOM structure changes.");
|
|
442
|
+
// @ts-ignore
|
|
443
|
+
if (otherProps.style) console.warn("The style prop is unsafe and is unsupported in React Spectrum v3. Please use style props with Spectrum variables, or UNSAFE_style if you absolutely must do something custom. Note that this may break in future versions due to DOM structure changes.");
|
|
444
|
+
let styleProps = {
|
|
445
|
+
style: style,
|
|
446
|
+
className: UNSAFE_className
|
|
447
|
+
};
|
|
448
|
+
if ($d3b73be57066120b$export$52dbfdbe1b2c3541(props.isHidden, matchedBreakpoints)) styleProps.hidden = true;
|
|
449
|
+
return {
|
|
450
|
+
styleProps: styleProps
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
function $d3b73be57066120b$export$46b6c81d11d2c30a(value) {
|
|
454
|
+
return value;
|
|
455
|
+
}
|
|
456
|
+
function $d3b73be57066120b$export$52dbfdbe1b2c3541(prop, matchedBreakpoints) {
|
|
457
|
+
if (prop && typeof prop === 'object' && !Array.isArray(prop)) {
|
|
458
|
+
for(let i = 0; i < matchedBreakpoints.length; i++){
|
|
459
|
+
let breakpoint = matchedBreakpoints[i];
|
|
460
|
+
if (prop[breakpoint] != null) return prop[breakpoint];
|
|
461
|
+
}
|
|
462
|
+
return prop.base;
|
|
463
|
+
}
|
|
464
|
+
return prop;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
//# sourceMappingURL=styleProps.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAcM,MAAM,4CAAgC;IAC3C,QAAQ;QAAC;QAAU;KAAe;IAClC,aAAa;QAAC,0BAAI,cAAc;QAAgB;KAAe;IAC/D,WAAW;QAAC,0BAAI,eAAe;QAAe;KAAe;IAC7D,8CAA8C;IAC9C,gDAAgD;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":["packages/@react-spectrum/utils/src/styleProps.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {BackgroundColorValue, BorderColorValue, BorderRadiusValue, BorderSizeValue, ColorValue, ColorVersion, DimensionValue, Direction, Responsive, ResponsiveProp, StyleProps, ViewStyleProps} from '@react-types/shared';\nimport {CSSProperties, HTMLAttributes} from 'react';\nimport {useBreakpoint} from './BreakpointProvider';\nimport {useLocale} from '@react-aria/i18n';\n\ntype Breakpoint = 'base' | 'S' | 'M' | 'L' | string;\ntype StyleName = string | string[] | ((dir: Direction) => string);\ntype StyleHandler = (value: any, colorVersion?: number) => string;\nexport interface StyleHandlers {\n [key: string]: [StyleName, StyleHandler]\n}\n\nexport const baseStyleProps: StyleHandlers = {\n margin: ['margin', dimensionValue],\n marginStart: [rtl('marginLeft', 'marginRight'), dimensionValue],\n marginEnd: [rtl('marginRight', 'marginLeft'), dimensionValue],\n // marginLeft: ['marginLeft', dimensionValue],\n // marginRight: ['marginRight', dimensionValue],\n marginTop: ['marginTop', dimensionValue],\n marginBottom: ['marginBottom', dimensionValue],\n marginX: [['marginLeft', 'marginRight'], dimensionValue],\n marginY: [['marginTop', 'marginBottom'], dimensionValue],\n width: ['width', dimensionValue],\n height: ['height', dimensionValue],\n minWidth: ['minWidth', dimensionValue],\n minHeight: ['minHeight', dimensionValue],\n maxWidth: ['maxWidth', dimensionValue],\n maxHeight: ['maxHeight', dimensionValue],\n isHidden: ['display', hiddenValue],\n alignSelf: ['alignSelf', passthroughStyle],\n justifySelf: ['justifySelf', passthroughStyle],\n position: ['position', anyValue],\n zIndex: ['zIndex', anyValue],\n top: ['top', dimensionValue],\n bottom: ['bottom', dimensionValue],\n start: [rtl('left', 'right'), dimensionValue],\n end: [rtl('right', 'left'), dimensionValue],\n left: ['left', dimensionValue],\n right: ['right', dimensionValue],\n order: ['order', anyValue],\n flex: ['flex', flexValue],\n flexGrow: ['flexGrow', passthroughStyle],\n flexShrink: ['flexShrink', passthroughStyle],\n flexBasis: ['flexBasis', passthroughStyle],\n gridArea: ['gridArea', passthroughStyle],\n gridColumn: ['gridColumn', passthroughStyle],\n gridColumnEnd: ['gridColumnEnd', passthroughStyle],\n gridColumnStart: ['gridColumnStart', passthroughStyle],\n gridRow: ['gridRow', passthroughStyle],\n gridRowEnd: ['gridRowEnd', passthroughStyle],\n gridRowStart: ['gridRowStart', passthroughStyle]\n};\n\nexport const viewStyleProps: StyleHandlers = {\n ...baseStyleProps,\n backgroundColor: ['backgroundColor', backgroundColorValue],\n borderWidth: ['borderWidth', borderSizeValue],\n borderStartWidth: [rtl('borderLeftWidth', 'borderRightWidth'), borderSizeValue],\n borderEndWidth: [rtl('borderRightWidth', 'borderLeftWidth'), borderSizeValue],\n borderLeftWidth: ['borderLeftWidth', borderSizeValue],\n borderRightWidth: ['borderRightWidth', borderSizeValue],\n borderTopWidth: ['borderTopWidth', borderSizeValue],\n borderBottomWidth: ['borderBottomWidth', borderSizeValue],\n borderXWidth: [['borderLeftWidth', 'borderRightWidth'], borderSizeValue],\n borderYWidth: [['borderTopWidth', 'borderBottomWidth'], borderSizeValue],\n borderColor: ['borderColor', borderColorValue],\n borderStartColor: [rtl('borderLeftColor', 'borderRightColor'), borderColorValue],\n borderEndColor: [rtl('borderRightColor', 'borderLeftColor'), borderColorValue],\n borderLeftColor: ['borderLeftColor', borderColorValue],\n borderRightColor: ['borderRightColor', borderColorValue],\n borderTopColor: ['borderTopColor', borderColorValue],\n borderBottomColor: ['borderBottomColor', borderColorValue],\n borderXColor: [['borderLeftColor', 'borderRightColor'], borderColorValue],\n borderYColor: [['borderTopColor', 'borderBottomColor'], borderColorValue],\n borderRadius: ['borderRadius', borderRadiusValue],\n borderTopStartRadius: [rtl('borderTopLeftRadius', 'borderTopRightRadius'), borderRadiusValue],\n borderTopEndRadius: [rtl('borderTopRightRadius', 'borderTopLeftRadius'), borderRadiusValue],\n borderBottomStartRadius: [rtl('borderBottomLeftRadius', 'borderBottomRightRadius'), borderRadiusValue],\n borderBottomEndRadius: [rtl('borderBottomRightRadius', 'borderBottomLeftRadius'), borderRadiusValue],\n borderTopLeftRadius: ['borderTopLeftRadius', borderRadiusValue],\n borderTopRightRadius: ['borderTopRightRadius', borderRadiusValue],\n borderBottomLeftRadius: ['borderBottomLeftRadius', borderRadiusValue],\n borderBottomRightRadius: ['borderBottomRightRadius', borderRadiusValue],\n padding: ['padding', dimensionValue],\n paddingStart: [rtl('paddingLeft', 'paddingRight'), dimensionValue],\n paddingEnd: [rtl('paddingRight', 'paddingLeft'), dimensionValue],\n paddingLeft: ['paddingLeft', dimensionValue],\n paddingRight: ['paddingRight', dimensionValue],\n paddingTop: ['paddingTop', dimensionValue],\n paddingBottom: ['paddingBottom', dimensionValue],\n paddingX: [['paddingLeft', 'paddingRight'], dimensionValue],\n paddingY: [['paddingTop', 'paddingBottom'], dimensionValue],\n overflow: ['overflow', passthroughStyle]\n};\n\nconst borderStyleProps = {\n borderWidth: 'borderStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n borderTopWidth: 'borderTopStyle',\n borderBottomWidth: 'borderBottomStyle'\n};\n\nfunction rtl(ltr: string, rtl: string) {\n return (direction: Direction) => (\n direction === 'rtl' ? rtl : ltr\n );\n}\n\nconst UNIT_RE = /(%|px|em|rem|vw|vh|auto|cm|mm|in|pt|pc|ex|ch|rem|vmin|vmax|fr)$/;\nconst FUNC_RE = /^\\s*\\w+\\(/;\nconst SPECTRUM_VARIABLE_RE = /(static-)?size-\\d+|single-line-(height|width)/g;\n\nexport function dimensionValue(value: DimensionValue) {\n if (typeof value === 'number') {\n return value + 'px';\n }\n\n if (!value) {\n return undefined;\n }\n\n if (UNIT_RE.test(value)) {\n return value;\n }\n\n if (FUNC_RE.test(value)) {\n return value.replace(SPECTRUM_VARIABLE_RE, 'var(--spectrum-global-dimension-$&, var(--spectrum-alias-$&))');\n }\n\n return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;\n}\n\nexport function responsiveDimensionValue(value: Responsive<DimensionValue>, matchedBreakpoints: Breakpoint[]) {\n value = getResponsiveProp(value, matchedBreakpoints);\n return dimensionValue(value);\n}\n\ntype ColorType = 'default' | 'background' | 'border' | 'icon' | 'status';\nfunction colorValue(value: ColorValue, type: ColorType = 'default', version = 5) {\n if (version > 5) {\n return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;\n }\n\n return `var(--spectrum-legacy-color-${value}, var(--spectrum-global-color-${value}, var(--spectrum-semantic-${value}-color-${type})))`;\n}\n\nfunction backgroundColorValue(value: BackgroundColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-background-color-${value}, ${colorValue(value as ColorValue, 'background', version)})`;\n}\n\nfunction borderColorValue(value: BorderColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n if (value === 'default') {\n return 'var(--spectrum-alias-border-color)';\n }\n\n return `var(--spectrum-alias-border-color-${value}, ${colorValue(value as ColorValue, 'border', version)})`;\n}\n\nfunction borderSizeValue(value?: BorderSizeValue | null) {\n return value && value !== 'none'\n ? `var(--spectrum-alias-border-size-${value})`\n : '0';\n}\n\nfunction borderRadiusValue(value: BorderRadiusValue) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-border-radius-${value})`;\n}\n\nfunction hiddenValue(value: boolean) {\n return value ? 'none' : undefined;\n}\n\nfunction anyValue(value: any) {\n return value;\n}\n\nfunction flexValue(value: boolean | number | string) {\n if (typeof value === 'boolean') {\n return value ? '1' : undefined;\n }\n\n return '' + value;\n}\n\nexport function convertStyleProps<C extends ColorVersion>(props: ViewStyleProps<C>, handlers: StyleHandlers, direction: Direction, matchedBreakpoints: Breakpoint[]) {\n let style: CSSProperties = {};\n for (let key in props) {\n let styleProp = handlers[key];\n if (!styleProp || props[key] == null) {\n continue;\n }\n\n let [name, convert] = styleProp;\n if (typeof name === 'function') {\n name = name(direction);\n }\n\n let prop = getResponsiveProp(props[key], matchedBreakpoints);\n let value = convert(prop, props.colorVersion);\n if (Array.isArray(name)) {\n for (let k of name) {\n style[k] = value;\n }\n } else {\n style[name] = value;\n }\n }\n\n for (let prop in borderStyleProps) {\n if (style[prop]) {\n style[borderStyleProps[prop]] = 'solid';\n style.boxSizing = 'border-box';\n }\n }\n\n return style;\n}\n\ntype StylePropsOptions = {\n matchedBreakpoints?: Breakpoint[]\n};\n\nexport function useStyleProps<T extends StyleProps>(\n props: T,\n handlers: StyleHandlers = baseStyleProps,\n options: StylePropsOptions = {}\n) {\n let {\n UNSAFE_className,\n UNSAFE_style,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let {direction} = useLocale();\n let {\n matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base']\n } = options;\n let styles = convertStyleProps(props, handlers, direction, matchedBreakpoints);\n let style = {...UNSAFE_style, ...styles};\n\n // @ts-ignore\n if (otherProps.className) {\n console.warn(\n 'The className prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_className if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n // @ts-ignore\n if (otherProps.style) {\n console.warn(\n 'The style prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_style if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n let styleProps: HTMLAttributes<HTMLElement> = {\n style,\n className: UNSAFE_className\n };\n\n if (getResponsiveProp(props.isHidden, matchedBreakpoints)) {\n styleProps.hidden = true;\n }\n\n return {\n styleProps\n };\n}\n\nexport function passthroughStyle(value) {\n return value;\n}\n\nexport function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T {\n if (prop && typeof prop === 'object' && !Array.isArray(prop)) {\n for (let i = 0; i < matchedBreakpoints.length; i++) {\n let breakpoint = matchedBreakpoints[i];\n if (prop[breakpoint] != null) {\n return prop[breakpoint];\n }\n }\n return (prop as ResponsiveProp<T>).base;\n }\n return prop as T;\n}\n"],"names":[],"version":3,"file":"styleProps.main.js.map"}
|