@react-spectrum/utils 3.11.4 → 3.11.6

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.
Files changed (53) hide show
  1. package/dist/BreakpointProvider.main.js +75 -0
  2. package/dist/BreakpointProvider.main.js.map +1 -0
  3. package/dist/BreakpointProvider.mjs +64 -0
  4. package/dist/BreakpointProvider.module.js +64 -0
  5. package/dist/BreakpointProvider.module.js.map +1 -0
  6. package/dist/Slots.main.js +73 -0
  7. package/dist/Slots.main.js.map +1 -0
  8. package/dist/Slots.mjs +61 -0
  9. package/dist/Slots.module.js +61 -0
  10. package/dist/Slots.module.js.map +1 -0
  11. package/dist/classNames.main.js +50 -0
  12. package/dist/classNames.main.js.map +1 -0
  13. package/dist/classNames.mjs +39 -0
  14. package/dist/classNames.module.js +39 -0
  15. package/dist/classNames.module.js.map +1 -0
  16. package/dist/getWrappedElement.main.js +32 -0
  17. package/dist/getWrappedElement.main.js.map +1 -0
  18. package/dist/getWrappedElement.mjs +23 -0
  19. package/dist/getWrappedElement.module.js +23 -0
  20. package/dist/getWrappedElement.module.js.map +1 -0
  21. package/dist/import.mjs +10 -742
  22. package/dist/main.js +37 -773
  23. package/dist/main.js.map +1 -1
  24. package/dist/module.js +10 -742
  25. package/dist/module.js.map +1 -1
  26. package/dist/styleProps.main.js +468 -0
  27. package/dist/styleProps.main.js.map +1 -0
  28. package/dist/styleProps.mjs +456 -0
  29. package/dist/styleProps.module.js +456 -0
  30. package/dist/styleProps.module.js.map +1 -0
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/useDOMRef.main.js +64 -0
  33. package/dist/useDOMRef.main.js.map +1 -0
  34. package/dist/useDOMRef.mjs +54 -0
  35. package/dist/useDOMRef.module.js +54 -0
  36. package/dist/useDOMRef.module.js.map +1 -0
  37. package/dist/useHasChild.main.js +35 -0
  38. package/dist/useHasChild.main.js.map +1 -0
  39. package/dist/useHasChild.mjs +30 -0
  40. package/dist/useHasChild.module.js +30 -0
  41. package/dist/useHasChild.module.js.map +1 -0
  42. package/dist/useIsMobileDevice.main.js +28 -0
  43. package/dist/useIsMobileDevice.main.js.map +1 -0
  44. package/dist/useIsMobileDevice.mjs +23 -0
  45. package/dist/useIsMobileDevice.module.js +23 -0
  46. package/dist/useIsMobileDevice.module.js.map +1 -0
  47. package/dist/useMediaQuery.main.js +46 -0
  48. package/dist/useMediaQuery.main.js.map +1 -0
  49. package/dist/useMediaQuery.mjs +41 -0
  50. package/dist/useMediaQuery.module.js +41 -0
  51. package/dist/useMediaQuery.module.js.map +1 -0
  52. package/package.json +6 -6
  53. package/src/styleProps.ts +16 -0
@@ -0,0 +1,456 @@
1
+ import {useBreakpoint as $1051245f87c5981d$export$199d6754bdf4e1e3} from "./BreakpointProvider.mjs";
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.mjs.map