@react-spectrum/utils 3.11.5 → 3.11.7
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/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 +10 -742
- package/dist/main.js +37 -773
- package/dist/main.js.map +1 -1
- package/dist/module.js +10 -742
- package/dist/module.js.map +1 -1
- 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.map +1 -1
- 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 +6 -6
- package/src/styleProps.ts +16 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import {useBreakpoint as $1051245f87c5981d$export$199d6754bdf4e1e3} from "./BreakpointProvider.module.js";
|
|
2
|
+
import {useLocale as $9Di9g$useLocale} from "@react-aria/i18n";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const $380ed8f3903c3931$export$fe9c6e915565b4e8 = {
|
|
17
|
+
margin: [
|
|
18
|
+
'margin',
|
|
19
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
20
|
+
],
|
|
21
|
+
marginStart: [
|
|
22
|
+
$380ed8f3903c3931$var$rtl('marginLeft', 'marginRight'),
|
|
23
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
24
|
+
],
|
|
25
|
+
marginEnd: [
|
|
26
|
+
$380ed8f3903c3931$var$rtl('marginRight', 'marginLeft'),
|
|
27
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
28
|
+
],
|
|
29
|
+
// marginLeft: ['marginLeft', dimensionValue],
|
|
30
|
+
// marginRight: ['marginRight', dimensionValue],
|
|
31
|
+
marginTop: [
|
|
32
|
+
'marginTop',
|
|
33
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
34
|
+
],
|
|
35
|
+
marginBottom: [
|
|
36
|
+
'marginBottom',
|
|
37
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
38
|
+
],
|
|
39
|
+
marginX: [
|
|
40
|
+
[
|
|
41
|
+
'marginLeft',
|
|
42
|
+
'marginRight'
|
|
43
|
+
],
|
|
44
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
45
|
+
],
|
|
46
|
+
marginY: [
|
|
47
|
+
[
|
|
48
|
+
'marginTop',
|
|
49
|
+
'marginBottom'
|
|
50
|
+
],
|
|
51
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
52
|
+
],
|
|
53
|
+
width: [
|
|
54
|
+
'width',
|
|
55
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
56
|
+
],
|
|
57
|
+
height: [
|
|
58
|
+
'height',
|
|
59
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
60
|
+
],
|
|
61
|
+
minWidth: [
|
|
62
|
+
'minWidth',
|
|
63
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
64
|
+
],
|
|
65
|
+
minHeight: [
|
|
66
|
+
'minHeight',
|
|
67
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
68
|
+
],
|
|
69
|
+
maxWidth: [
|
|
70
|
+
'maxWidth',
|
|
71
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
72
|
+
],
|
|
73
|
+
maxHeight: [
|
|
74
|
+
'maxHeight',
|
|
75
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
76
|
+
],
|
|
77
|
+
isHidden: [
|
|
78
|
+
'display',
|
|
79
|
+
$380ed8f3903c3931$var$hiddenValue
|
|
80
|
+
],
|
|
81
|
+
alignSelf: [
|
|
82
|
+
'alignSelf',
|
|
83
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
84
|
+
],
|
|
85
|
+
justifySelf: [
|
|
86
|
+
'justifySelf',
|
|
87
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
88
|
+
],
|
|
89
|
+
position: [
|
|
90
|
+
'position',
|
|
91
|
+
$380ed8f3903c3931$var$anyValue
|
|
92
|
+
],
|
|
93
|
+
zIndex: [
|
|
94
|
+
'zIndex',
|
|
95
|
+
$380ed8f3903c3931$var$anyValue
|
|
96
|
+
],
|
|
97
|
+
top: [
|
|
98
|
+
'top',
|
|
99
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
100
|
+
],
|
|
101
|
+
bottom: [
|
|
102
|
+
'bottom',
|
|
103
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
104
|
+
],
|
|
105
|
+
start: [
|
|
106
|
+
$380ed8f3903c3931$var$rtl('left', 'right'),
|
|
107
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
108
|
+
],
|
|
109
|
+
end: [
|
|
110
|
+
$380ed8f3903c3931$var$rtl('right', 'left'),
|
|
111
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
112
|
+
],
|
|
113
|
+
left: [
|
|
114
|
+
'left',
|
|
115
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
116
|
+
],
|
|
117
|
+
right: [
|
|
118
|
+
'right',
|
|
119
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
120
|
+
],
|
|
121
|
+
order: [
|
|
122
|
+
'order',
|
|
123
|
+
$380ed8f3903c3931$var$anyValue
|
|
124
|
+
],
|
|
125
|
+
flex: [
|
|
126
|
+
'flex',
|
|
127
|
+
$380ed8f3903c3931$var$flexValue
|
|
128
|
+
],
|
|
129
|
+
flexGrow: [
|
|
130
|
+
'flexGrow',
|
|
131
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
132
|
+
],
|
|
133
|
+
flexShrink: [
|
|
134
|
+
'flexShrink',
|
|
135
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
136
|
+
],
|
|
137
|
+
flexBasis: [
|
|
138
|
+
'flexBasis',
|
|
139
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
140
|
+
],
|
|
141
|
+
gridArea: [
|
|
142
|
+
'gridArea',
|
|
143
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
144
|
+
],
|
|
145
|
+
gridColumn: [
|
|
146
|
+
'gridColumn',
|
|
147
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
148
|
+
],
|
|
149
|
+
gridColumnEnd: [
|
|
150
|
+
'gridColumnEnd',
|
|
151
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
152
|
+
],
|
|
153
|
+
gridColumnStart: [
|
|
154
|
+
'gridColumnStart',
|
|
155
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
156
|
+
],
|
|
157
|
+
gridRow: [
|
|
158
|
+
'gridRow',
|
|
159
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
160
|
+
],
|
|
161
|
+
gridRowEnd: [
|
|
162
|
+
'gridRowEnd',
|
|
163
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
164
|
+
],
|
|
165
|
+
gridRowStart: [
|
|
166
|
+
'gridRowStart',
|
|
167
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
168
|
+
]
|
|
169
|
+
};
|
|
170
|
+
const $380ed8f3903c3931$export$e0705d1a55f297c = {
|
|
171
|
+
...$380ed8f3903c3931$export$fe9c6e915565b4e8,
|
|
172
|
+
backgroundColor: [
|
|
173
|
+
'backgroundColor',
|
|
174
|
+
$380ed8f3903c3931$var$backgroundColorValue
|
|
175
|
+
],
|
|
176
|
+
borderWidth: [
|
|
177
|
+
'borderWidth',
|
|
178
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
179
|
+
],
|
|
180
|
+
borderStartWidth: [
|
|
181
|
+
$380ed8f3903c3931$var$rtl('borderLeftWidth', 'borderRightWidth'),
|
|
182
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
183
|
+
],
|
|
184
|
+
borderEndWidth: [
|
|
185
|
+
$380ed8f3903c3931$var$rtl('borderRightWidth', 'borderLeftWidth'),
|
|
186
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
187
|
+
],
|
|
188
|
+
borderLeftWidth: [
|
|
189
|
+
'borderLeftWidth',
|
|
190
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
191
|
+
],
|
|
192
|
+
borderRightWidth: [
|
|
193
|
+
'borderRightWidth',
|
|
194
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
195
|
+
],
|
|
196
|
+
borderTopWidth: [
|
|
197
|
+
'borderTopWidth',
|
|
198
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
199
|
+
],
|
|
200
|
+
borderBottomWidth: [
|
|
201
|
+
'borderBottomWidth',
|
|
202
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
203
|
+
],
|
|
204
|
+
borderXWidth: [
|
|
205
|
+
[
|
|
206
|
+
'borderLeftWidth',
|
|
207
|
+
'borderRightWidth'
|
|
208
|
+
],
|
|
209
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
210
|
+
],
|
|
211
|
+
borderYWidth: [
|
|
212
|
+
[
|
|
213
|
+
'borderTopWidth',
|
|
214
|
+
'borderBottomWidth'
|
|
215
|
+
],
|
|
216
|
+
$380ed8f3903c3931$var$borderSizeValue
|
|
217
|
+
],
|
|
218
|
+
borderColor: [
|
|
219
|
+
'borderColor',
|
|
220
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
221
|
+
],
|
|
222
|
+
borderStartColor: [
|
|
223
|
+
$380ed8f3903c3931$var$rtl('borderLeftColor', 'borderRightColor'),
|
|
224
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
225
|
+
],
|
|
226
|
+
borderEndColor: [
|
|
227
|
+
$380ed8f3903c3931$var$rtl('borderRightColor', 'borderLeftColor'),
|
|
228
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
229
|
+
],
|
|
230
|
+
borderLeftColor: [
|
|
231
|
+
'borderLeftColor',
|
|
232
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
233
|
+
],
|
|
234
|
+
borderRightColor: [
|
|
235
|
+
'borderRightColor',
|
|
236
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
237
|
+
],
|
|
238
|
+
borderTopColor: [
|
|
239
|
+
'borderTopColor',
|
|
240
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
241
|
+
],
|
|
242
|
+
borderBottomColor: [
|
|
243
|
+
'borderBottomColor',
|
|
244
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
245
|
+
],
|
|
246
|
+
borderXColor: [
|
|
247
|
+
[
|
|
248
|
+
'borderLeftColor',
|
|
249
|
+
'borderRightColor'
|
|
250
|
+
],
|
|
251
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
252
|
+
],
|
|
253
|
+
borderYColor: [
|
|
254
|
+
[
|
|
255
|
+
'borderTopColor',
|
|
256
|
+
'borderBottomColor'
|
|
257
|
+
],
|
|
258
|
+
$380ed8f3903c3931$var$borderColorValue
|
|
259
|
+
],
|
|
260
|
+
borderRadius: [
|
|
261
|
+
'borderRadius',
|
|
262
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
263
|
+
],
|
|
264
|
+
borderTopStartRadius: [
|
|
265
|
+
$380ed8f3903c3931$var$rtl('borderTopLeftRadius', 'borderTopRightRadius'),
|
|
266
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
267
|
+
],
|
|
268
|
+
borderTopEndRadius: [
|
|
269
|
+
$380ed8f3903c3931$var$rtl('borderTopRightRadius', 'borderTopLeftRadius'),
|
|
270
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
271
|
+
],
|
|
272
|
+
borderBottomStartRadius: [
|
|
273
|
+
$380ed8f3903c3931$var$rtl('borderBottomLeftRadius', 'borderBottomRightRadius'),
|
|
274
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
275
|
+
],
|
|
276
|
+
borderBottomEndRadius: [
|
|
277
|
+
$380ed8f3903c3931$var$rtl('borderBottomRightRadius', 'borderBottomLeftRadius'),
|
|
278
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
279
|
+
],
|
|
280
|
+
borderTopLeftRadius: [
|
|
281
|
+
'borderTopLeftRadius',
|
|
282
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
283
|
+
],
|
|
284
|
+
borderTopRightRadius: [
|
|
285
|
+
'borderTopRightRadius',
|
|
286
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
287
|
+
],
|
|
288
|
+
borderBottomLeftRadius: [
|
|
289
|
+
'borderBottomLeftRadius',
|
|
290
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
291
|
+
],
|
|
292
|
+
borderBottomRightRadius: [
|
|
293
|
+
'borderBottomRightRadius',
|
|
294
|
+
$380ed8f3903c3931$var$borderRadiusValue
|
|
295
|
+
],
|
|
296
|
+
padding: [
|
|
297
|
+
'padding',
|
|
298
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
299
|
+
],
|
|
300
|
+
paddingStart: [
|
|
301
|
+
$380ed8f3903c3931$var$rtl('paddingLeft', 'paddingRight'),
|
|
302
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
303
|
+
],
|
|
304
|
+
paddingEnd: [
|
|
305
|
+
$380ed8f3903c3931$var$rtl('paddingRight', 'paddingLeft'),
|
|
306
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
307
|
+
],
|
|
308
|
+
paddingLeft: [
|
|
309
|
+
'paddingLeft',
|
|
310
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
311
|
+
],
|
|
312
|
+
paddingRight: [
|
|
313
|
+
'paddingRight',
|
|
314
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
315
|
+
],
|
|
316
|
+
paddingTop: [
|
|
317
|
+
'paddingTop',
|
|
318
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
319
|
+
],
|
|
320
|
+
paddingBottom: [
|
|
321
|
+
'paddingBottom',
|
|
322
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
323
|
+
],
|
|
324
|
+
paddingX: [
|
|
325
|
+
[
|
|
326
|
+
'paddingLeft',
|
|
327
|
+
'paddingRight'
|
|
328
|
+
],
|
|
329
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
330
|
+
],
|
|
331
|
+
paddingY: [
|
|
332
|
+
[
|
|
333
|
+
'paddingTop',
|
|
334
|
+
'paddingBottom'
|
|
335
|
+
],
|
|
336
|
+
$380ed8f3903c3931$export$abc24f5b99744ea6
|
|
337
|
+
],
|
|
338
|
+
overflow: [
|
|
339
|
+
'overflow',
|
|
340
|
+
$380ed8f3903c3931$export$46b6c81d11d2c30a
|
|
341
|
+
]
|
|
342
|
+
};
|
|
343
|
+
const $380ed8f3903c3931$var$borderStyleProps = {
|
|
344
|
+
borderWidth: 'borderStyle',
|
|
345
|
+
borderLeftWidth: 'borderLeftStyle',
|
|
346
|
+
borderRightWidth: 'borderRightStyle',
|
|
347
|
+
borderTopWidth: 'borderTopStyle',
|
|
348
|
+
borderBottomWidth: 'borderBottomStyle'
|
|
349
|
+
};
|
|
350
|
+
function $380ed8f3903c3931$var$rtl(ltr, rtl) {
|
|
351
|
+
return (direction)=>direction === 'rtl' ? rtl : ltr;
|
|
352
|
+
}
|
|
353
|
+
const $380ed8f3903c3931$var$UNIT_RE = /(%|px|em|rem|vw|vh|auto|cm|mm|in|pt|pc|ex|ch|rem|vmin|vmax|fr)$/;
|
|
354
|
+
const $380ed8f3903c3931$var$FUNC_RE = /^\s*\w+\(/;
|
|
355
|
+
const $380ed8f3903c3931$var$SPECTRUM_VARIABLE_RE = /(static-)?size-\d+|single-line-(height|width)/g;
|
|
356
|
+
function $380ed8f3903c3931$export$abc24f5b99744ea6(value) {
|
|
357
|
+
if (typeof value === 'number') return value + 'px';
|
|
358
|
+
if (!value) return undefined;
|
|
359
|
+
if ($380ed8f3903c3931$var$UNIT_RE.test(value)) return value;
|
|
360
|
+
if ($380ed8f3903c3931$var$FUNC_RE.test(value)) return value.replace($380ed8f3903c3931$var$SPECTRUM_VARIABLE_RE, 'var(--spectrum-global-dimension-$&, var(--spectrum-alias-$&))');
|
|
361
|
+
return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;
|
|
362
|
+
}
|
|
363
|
+
function $380ed8f3903c3931$export$f348bec194f2e6b5(value, matchedBreakpoints) {
|
|
364
|
+
value = $380ed8f3903c3931$export$52dbfdbe1b2c3541(value, matchedBreakpoints);
|
|
365
|
+
return $380ed8f3903c3931$export$abc24f5b99744ea6(value);
|
|
366
|
+
}
|
|
367
|
+
function $380ed8f3903c3931$var$colorValue(value, type = 'default', version = 5) {
|
|
368
|
+
if (version > 5) return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;
|
|
369
|
+
return `var(--spectrum-legacy-color-${value}, var(--spectrum-global-color-${value}, var(--spectrum-semantic-${value}-color-${type})))`;
|
|
370
|
+
}
|
|
371
|
+
function $380ed8f3903c3931$var$backgroundColorValue(value, version = 5) {
|
|
372
|
+
if (!value) return undefined;
|
|
373
|
+
return `var(--spectrum-alias-background-color-${value}, ${$380ed8f3903c3931$var$colorValue(value, 'background', version)})`;
|
|
374
|
+
}
|
|
375
|
+
function $380ed8f3903c3931$var$borderColorValue(value, version = 5) {
|
|
376
|
+
if (!value) return undefined;
|
|
377
|
+
if (value === 'default') return 'var(--spectrum-alias-border-color)';
|
|
378
|
+
return `var(--spectrum-alias-border-color-${value}, ${$380ed8f3903c3931$var$colorValue(value, 'border', version)})`;
|
|
379
|
+
}
|
|
380
|
+
function $380ed8f3903c3931$var$borderSizeValue(value) {
|
|
381
|
+
return value && value !== 'none' ? `var(--spectrum-alias-border-size-${value})` : '0';
|
|
382
|
+
}
|
|
383
|
+
function $380ed8f3903c3931$var$borderRadiusValue(value) {
|
|
384
|
+
if (!value) return undefined;
|
|
385
|
+
return `var(--spectrum-alias-border-radius-${value})`;
|
|
386
|
+
}
|
|
387
|
+
function $380ed8f3903c3931$var$hiddenValue(value) {
|
|
388
|
+
return value ? 'none' : undefined;
|
|
389
|
+
}
|
|
390
|
+
function $380ed8f3903c3931$var$anyValue(value) {
|
|
391
|
+
return value;
|
|
392
|
+
}
|
|
393
|
+
function $380ed8f3903c3931$var$flexValue(value) {
|
|
394
|
+
if (typeof value === 'boolean') return value ? '1' : undefined;
|
|
395
|
+
return '' + value;
|
|
396
|
+
}
|
|
397
|
+
function $380ed8f3903c3931$export$f3c39bb9534218d0(props, handlers, direction, matchedBreakpoints) {
|
|
398
|
+
let style = {};
|
|
399
|
+
for(let key in props){
|
|
400
|
+
let styleProp = handlers[key];
|
|
401
|
+
if (!styleProp || props[key] == null) continue;
|
|
402
|
+
let [name, convert] = styleProp;
|
|
403
|
+
if (typeof name === 'function') name = name(direction);
|
|
404
|
+
let prop = $380ed8f3903c3931$export$52dbfdbe1b2c3541(props[key], matchedBreakpoints);
|
|
405
|
+
let value = convert(prop, props.colorVersion);
|
|
406
|
+
if (Array.isArray(name)) for (let k of name)style[k] = value;
|
|
407
|
+
else style[name] = value;
|
|
408
|
+
}
|
|
409
|
+
for(let prop in $380ed8f3903c3931$var$borderStyleProps)if (style[prop]) {
|
|
410
|
+
style[$380ed8f3903c3931$var$borderStyleProps[prop]] = 'solid';
|
|
411
|
+
style.boxSizing = 'border-box';
|
|
412
|
+
}
|
|
413
|
+
return style;
|
|
414
|
+
}
|
|
415
|
+
function $380ed8f3903c3931$export$b8e6fb9d2dff3f41(props, handlers = $380ed8f3903c3931$export$fe9c6e915565b4e8, options = {}) {
|
|
416
|
+
let { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, ...otherProps } = props;
|
|
417
|
+
let breakpointProvider = (0, $1051245f87c5981d$export$199d6754bdf4e1e3)();
|
|
418
|
+
let { direction: direction } = (0, $9Di9g$useLocale)();
|
|
419
|
+
let { matchedBreakpoints: matchedBreakpoints = (breakpointProvider === null || breakpointProvider === void 0 ? void 0 : breakpointProvider.matchedBreakpoints) || [
|
|
420
|
+
'base'
|
|
421
|
+
] } = options;
|
|
422
|
+
let styles = $380ed8f3903c3931$export$f3c39bb9534218d0(props, handlers, direction, matchedBreakpoints);
|
|
423
|
+
let style = {
|
|
424
|
+
...UNSAFE_style,
|
|
425
|
+
...styles
|
|
426
|
+
};
|
|
427
|
+
// @ts-ignore
|
|
428
|
+
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.");
|
|
429
|
+
// @ts-ignore
|
|
430
|
+
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.");
|
|
431
|
+
let styleProps = {
|
|
432
|
+
style: style,
|
|
433
|
+
className: UNSAFE_className
|
|
434
|
+
};
|
|
435
|
+
if ($380ed8f3903c3931$export$52dbfdbe1b2c3541(props.isHidden, matchedBreakpoints)) styleProps.hidden = true;
|
|
436
|
+
return {
|
|
437
|
+
styleProps: styleProps
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
function $380ed8f3903c3931$export$46b6c81d11d2c30a(value) {
|
|
441
|
+
return value;
|
|
442
|
+
}
|
|
443
|
+
function $380ed8f3903c3931$export$52dbfdbe1b2c3541(prop, matchedBreakpoints) {
|
|
444
|
+
if (prop && typeof prop === 'object' && !Array.isArray(prop)) {
|
|
445
|
+
for(let i = 0; i < matchedBreakpoints.length; i++){
|
|
446
|
+
let breakpoint = matchedBreakpoints[i];
|
|
447
|
+
if (prop[breakpoint] != null) return prop[breakpoint];
|
|
448
|
+
}
|
|
449
|
+
return prop.base;
|
|
450
|
+
}
|
|
451
|
+
return prop;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
export {$380ed8f3903c3931$export$fe9c6e915565b4e8 as baseStyleProps, $380ed8f3903c3931$export$abc24f5b99744ea6 as dimensionValue, $380ed8f3903c3931$export$46b6c81d11d2c30a as passthroughStyle, $380ed8f3903c3931$export$e0705d1a55f297c as viewStyleProps, $380ed8f3903c3931$export$f348bec194f2e6b5 as responsiveDimensionValue, $380ed8f3903c3931$export$52dbfdbe1b2c3541 as getResponsiveProp, $380ed8f3903c3931$export$f3c39bb9534218d0 as convertStyleProps, $380ed8f3903c3931$export$b8e6fb9d2dff3f41 as useStyleProps};
|
|
456
|
+
//# sourceMappingURL=styleProps.module.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;IAChD,WAAW;QAAC;QAAa;KAAe;IACxC,cAAc;QAAC;QAAgB;KAAe;IAC9C,SAAS;QAAC;YAAC;YAAc;SAAc;QAAE;KAAe;IACxD,SAAS;QAAC;YAAC;YAAa;SAAe;QAAE;KAAe;IACxD,OAAO;QAAC;QAAS;KAAe;IAChC,QAAQ;QAAC;QAAU;KAAe;IAClC,UAAU;QAAC;QAAY;KAAe;IACtC,WAAW;QAAC;QAAa;KAAe;IACxC,UAAU;QAAC;QAAY;KAAe;IACtC,WAAW;QAAC;QAAa;KAAe;IACxC,UAAU;QAAC;QAAW;KAAY;IAClC,WAAW;QAAC;QAAa;KAAiB;IAC1C,aAAa;QAAC;QAAe;KAAiB;IAC9C,UA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B,kBAAkB,KAAI;QAAC;KAAO,EACxE,GAAG;IACJ,IAAI,SAAS,0CAAkB,OAAO,UAAU,WAAW;IAC3D,IAAI,QAAQ;QAAC,GAAG,YAAY;QAAE,GAAG,MAAM;IAAA;IAEvC,aAAa;IACb,IAAI,WAAW,SAAS,EACtB,QAAQ,IAAI,CACV;IAMJ,aAAa;IACb,IAAI,WAAW,KAAK,EAClB,QAAQ,IAAI,CACV;IAMJ,IAAI,aAA0C;eAC5C;QACA,WAAW;IACb;IAEA,IAAI,0CAAkB,MAAM,QAAQ,EAAE,qBACpC,WAAW,MAAM,GAAG;IAGtB,OAAO;oBACL;IACF;AACF;AAEO,SAAS,0CAAiB,KAAK;IACpC,OAAO;AACT;AAEO,SAAS,0CAAqB,IAAmB,EAAE,kBAAgC;IACxF,IAAI,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,OAAO,CAAC,OAAO;QAC5D,IAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,MAAM,EAAE,IAAK;YAClD,IAAI,aAAa,kBAAkB,CAAC,EAAE;YACtC,IAAI,IAAI,CAAC,WAAW,IAAI,MACtB,OAAO,IAAI,CAAC,WAAW;QAE3B;QACA,OAAO,AAAC,KAA2B,IAAI;IACzC;IACA,OAAO;AACT","sources":["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.module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAGA;IACE,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAA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2BAA2B,KAAK,KAAA,qBAa/B;ACtDD,4BAA4B,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,WAMrE;ACLD,qCAAqC,OAAO,CAO3C;ACSD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/BreakpointProvider.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/styleProps.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/classNames.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/getWrappedElement.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useMediaQuery.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useDOMRef.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/Slots.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useHasChild.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useIsMobileDevice.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/index.ts","packages/@react-spectrum/utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"/*\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\n/// <reference types=\"css-module-types\" />\n\nexport type {StyleHandlers} from './styleProps';\nexport {shouldKeepSpectrumClassNames, keepSpectrumClassNames, classNames} from './classNames';\nexport {getWrappedElement} from './getWrappedElement';\nexport {useMediaQuery} from './useMediaQuery';\nexport {createDOMRef, createFocusableRef, useDOMRef, useFocusableRef, unwrapDOMRef, useUnwrapDOMRef} from './useDOMRef';\nexport {\n baseStyleProps,\n viewStyleProps,\n dimensionValue,\n responsiveDimensionValue,\n convertStyleProps,\n useStyleProps,\n passthroughStyle,\n getResponsiveProp\n} from './styleProps';\nexport {useSlotProps, cssModuleToSlots, SlotProvider, ClearSlots} from './Slots';\nexport {useHasChild} from './useHasChild';\nexport {useIsMobileDevice} from './useIsMobileDevice';\nexport {useValueEffect} from '@react-aria/utils';\nexport {BreakpointProvider, useMatchedBreakpoints, useBreakpoint} from './BreakpointProvider';\nexport {useResizeObserver} from '@react-aria/utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var $fXWOI$react = require("react");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "createDOMRef", () => $749a6c35064cd8c6$export$a5795cc979dfae80);
|
|
9
|
+
$parcel$export(module.exports, "createFocusableRef", () => $749a6c35064cd8c6$export$79d69eee6ae4b329);
|
|
10
|
+
$parcel$export(module.exports, "useDOMRef", () => $749a6c35064cd8c6$export$c2c55ef9111cafd8);
|
|
11
|
+
$parcel$export(module.exports, "useFocusableRef", () => $749a6c35064cd8c6$export$96a734597687c040);
|
|
12
|
+
$parcel$export(module.exports, "unwrapDOMRef", () => $749a6c35064cd8c6$export$c7e28c72a4823176);
|
|
13
|
+
$parcel$export(module.exports, "useUnwrapDOMRef", () => $749a6c35064cd8c6$export$1d5cc31d9d8df817);
|
|
14
|
+
/*
|
|
15
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
*
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
+
* governing permissions and limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
function $749a6c35064cd8c6$export$a5795cc979dfae80(ref) {
|
|
26
|
+
return {
|
|
27
|
+
UNSAFE_getDOMNode () {
|
|
28
|
+
return ref.current;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function $749a6c35064cd8c6$export$79d69eee6ae4b329(domRef, focusableRef = domRef) {
|
|
33
|
+
return {
|
|
34
|
+
...$749a6c35064cd8c6$export$a5795cc979dfae80(domRef),
|
|
35
|
+
focus () {
|
|
36
|
+
if (focusableRef.current) focusableRef.current.focus();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function $749a6c35064cd8c6$export$c2c55ef9111cafd8(ref) {
|
|
41
|
+
let domRef = (0, $fXWOI$react.useRef)(null);
|
|
42
|
+
(0, $fXWOI$react.useImperativeHandle)(ref, ()=>$749a6c35064cd8c6$export$a5795cc979dfae80(domRef));
|
|
43
|
+
return domRef;
|
|
44
|
+
}
|
|
45
|
+
function $749a6c35064cd8c6$export$96a734597687c040(ref, focusableRef) {
|
|
46
|
+
let domRef = (0, $fXWOI$react.useRef)(null);
|
|
47
|
+
(0, $fXWOI$react.useImperativeHandle)(ref, ()=>$749a6c35064cd8c6$export$79d69eee6ae4b329(domRef, focusableRef));
|
|
48
|
+
return domRef;
|
|
49
|
+
}
|
|
50
|
+
function $749a6c35064cd8c6$export$c7e28c72a4823176(ref) {
|
|
51
|
+
return {
|
|
52
|
+
get current () {
|
|
53
|
+
return ref.current && ref.current.UNSAFE_getDOMNode();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function $749a6c35064cd8c6$export$1d5cc31d9d8df817(ref) {
|
|
58
|
+
return (0, $fXWOI$react.useMemo)(()=>$749a6c35064cd8c6$export$c7e28c72a4823176(ref), [
|
|
59
|
+
ref
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=useDOMRef.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAKM,SAAS,0CAAkD,GAAiB;IACjF,OAAO;QACL;YACE,OAAO,IAAI,OAAO;QACpB;IACF;AACF;AAEO,SAAS,0CAAwD,MAAoB,EAAE,eAA4C,MAAM;IAC9I,OAAO;QACL,GAAG,0CAAa,OAAO;QACvB;YACE,IAAI,aAAa,OAAO,EACtB,aAAa,OAAO,CAAC,KAAK;QAE9B;IACF;AACF;AAEO,SAAS,0CAA+C,GAAc;IAC3E,IAAI,SAAS,CAAA,GAAA,mBAAK,EAAK;IACvB,CAAA,GAAA,gCAAkB,EAAE,KAAK,IAAM,0CAAa;IAC5C,OAAO;AACT;AAEO,SAAS,0CAAqD,GAAoB,EAAE,YAA0C;IACnI,IAAI,SAAS,CAAA,GAAA,mBAAK,EAAK;IACvB,CAAA,GAAA,gCAAkB,EAAE,KAAK,IAAM,0CAAmB,QAAQ;IAC1D,OAAO;AACT;AAEO,SAAS,0CAAoC,GAA8B;IAChF,OAAO;QACL,IAAI,WAAU;YACZ,OAAO,IAAI,OAAO,IAAI,IAAI,OAAO,CAAC,iBAAiB;QACrD;IACF;AACF;AAEO,SAAS,0CAAuC,GAA8B;IACnF,OAAO,CAAA,GAAA,oBAAM,EAAE,IAAM,0CAAa,MAAM;QAAC;KAAI;AAC/C","sources":["packages/@react-spectrum/utils/src/useDOMRef.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 {DOMRef, DOMRefValue, FocusableElement, FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {RefObject, useImperativeHandle, useMemo, useRef} from 'react';\n\nexport function createDOMRef<T extends HTMLElement = HTMLElement>(ref: RefObject<T>): DOMRefValue<T> {\n return {\n UNSAFE_getDOMNode() {\n return ref.current;\n }\n };\n}\n\nexport function createFocusableRef<T extends HTMLElement = HTMLElement>(domRef: RefObject<T>, focusableRef: RefObject<FocusableElement> = domRef): FocusableRefValue<T> {\n return {\n ...createDOMRef(domRef),\n focus() {\n if (focusableRef.current) {\n focusableRef.current.focus();\n }\n }\n };\n}\n\nexport function useDOMRef<T extends HTMLElement = HTMLElement>(ref: DOMRef<T>): RefObject<T> {\n let domRef = useRef<T>(null);\n useImperativeHandle(ref, () => createDOMRef(domRef));\n return domRef;\n}\n\nexport function useFocusableRef<T extends HTMLElement = HTMLElement>(ref: FocusableRef<T>, focusableRef?: RefObject<FocusableElement>): RefObject<T> {\n let domRef = useRef<T>(null);\n useImperativeHandle(ref, () => createFocusableRef(domRef, focusableRef));\n return domRef;\n}\n\nexport function unwrapDOMRef<T extends HTMLElement>(ref: RefObject<DOMRefValue<T>>): RefObject<T> {\n return {\n get current() {\n return ref.current && ref.current.UNSAFE_getDOMNode();\n }\n };\n}\n\nexport function useUnwrapDOMRef<T extends HTMLElement>(ref: RefObject<DOMRefValue<T>>) : RefObject<T> {\n return useMemo(() => unwrapDOMRef(ref), [ref]);\n}\n"],"names":[],"version":3,"file":"useDOMRef.main.js.map"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {useRef as $39jWF$useRef, useImperativeHandle as $39jWF$useImperativeHandle, useMemo as $39jWF$useMemo} from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $98e5a8ae0e6415af$export$a5795cc979dfae80(ref) {
|
|
15
|
+
return {
|
|
16
|
+
UNSAFE_getDOMNode () {
|
|
17
|
+
return ref.current;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function $98e5a8ae0e6415af$export$79d69eee6ae4b329(domRef, focusableRef = domRef) {
|
|
22
|
+
return {
|
|
23
|
+
...$98e5a8ae0e6415af$export$a5795cc979dfae80(domRef),
|
|
24
|
+
focus () {
|
|
25
|
+
if (focusableRef.current) focusableRef.current.focus();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function $98e5a8ae0e6415af$export$c2c55ef9111cafd8(ref) {
|
|
30
|
+
let domRef = (0, $39jWF$useRef)(null);
|
|
31
|
+
(0, $39jWF$useImperativeHandle)(ref, ()=>$98e5a8ae0e6415af$export$a5795cc979dfae80(domRef));
|
|
32
|
+
return domRef;
|
|
33
|
+
}
|
|
34
|
+
function $98e5a8ae0e6415af$export$96a734597687c040(ref, focusableRef) {
|
|
35
|
+
let domRef = (0, $39jWF$useRef)(null);
|
|
36
|
+
(0, $39jWF$useImperativeHandle)(ref, ()=>$98e5a8ae0e6415af$export$79d69eee6ae4b329(domRef, focusableRef));
|
|
37
|
+
return domRef;
|
|
38
|
+
}
|
|
39
|
+
function $98e5a8ae0e6415af$export$c7e28c72a4823176(ref) {
|
|
40
|
+
return {
|
|
41
|
+
get current () {
|
|
42
|
+
return ref.current && ref.current.UNSAFE_getDOMNode();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function $98e5a8ae0e6415af$export$1d5cc31d9d8df817(ref) {
|
|
47
|
+
return (0, $39jWF$useMemo)(()=>$98e5a8ae0e6415af$export$c7e28c72a4823176(ref), [
|
|
48
|
+
ref
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export {$98e5a8ae0e6415af$export$a5795cc979dfae80 as createDOMRef, $98e5a8ae0e6415af$export$79d69eee6ae4b329 as createFocusableRef, $98e5a8ae0e6415af$export$c2c55ef9111cafd8 as useDOMRef, $98e5a8ae0e6415af$export$96a734597687c040 as useFocusableRef, $98e5a8ae0e6415af$export$c7e28c72a4823176 as unwrapDOMRef, $98e5a8ae0e6415af$export$1d5cc31d9d8df817 as useUnwrapDOMRef};
|
|
54
|
+
//# sourceMappingURL=useDOMRef.module.js.map
|