@react-spectrum/s2 3.0.0-nightly-d87cc4422-250109 → 3.0.0-nightly-e4497fdb6-250110

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 (119) hide show
  1. package/dist/ActionBar.cjs +2 -2
  2. package/dist/ActionBar.css +2 -2
  3. package/dist/ActionBar.mjs +2 -2
  4. package/dist/ActionButton.css +1 -1
  5. package/dist/Breadcrumbs.css +1 -1
  6. package/dist/Button.cjs +133 -98
  7. package/dist/Button.cjs.map +1 -1
  8. package/dist/Button.css +118 -37
  9. package/dist/Button.css.map +1 -1
  10. package/dist/Button.mjs +134 -99
  11. package/dist/Button.mjs.map +1 -1
  12. package/dist/Card.cjs +15 -15
  13. package/dist/Card.css +19 -19
  14. package/dist/Card.mjs +15 -15
  15. package/dist/Checkbox.cjs +1 -1
  16. package/dist/Checkbox.css +3 -3
  17. package/dist/Checkbox.mjs +1 -1
  18. package/dist/CheckboxGroup.cjs +12 -12
  19. package/dist/CheckboxGroup.css +12 -12
  20. package/dist/CheckboxGroup.mjs +12 -12
  21. package/dist/CloseButton.cjs +2 -0
  22. package/dist/CloseButton.cjs.map +1 -1
  23. package/dist/CloseButton.css +9 -1
  24. package/dist/CloseButton.css.map +1 -1
  25. package/dist/CloseButton.mjs +2 -0
  26. package/dist/CloseButton.mjs.map +1 -1
  27. package/dist/ColorField.cjs +8 -8
  28. package/dist/ColorField.css +8 -8
  29. package/dist/ColorField.mjs +8 -8
  30. package/dist/ColorSlider.cjs +10 -10
  31. package/dist/ColorSlider.css +10 -10
  32. package/dist/ColorSlider.mjs +10 -10
  33. package/dist/ComboBox.cjs +12 -12
  34. package/dist/ComboBox.css +13 -13
  35. package/dist/ComboBox.mjs +12 -12
  36. package/dist/Disclosure.css +1 -1
  37. package/dist/Field.cjs +12 -12
  38. package/dist/Field.css +13 -13
  39. package/dist/Field.mjs +12 -12
  40. package/dist/Form.cjs +2 -2
  41. package/dist/Form.css +2 -2
  42. package/dist/Form.mjs +2 -2
  43. package/dist/FullscreenDialog.cjs +5 -5
  44. package/dist/FullscreenDialog.css +22 -22
  45. package/dist/FullscreenDialog.mjs +5 -5
  46. package/dist/IllustratedMessage.cjs +19 -19
  47. package/dist/IllustratedMessage.css +22 -22
  48. package/dist/IllustratedMessage.mjs +19 -19
  49. package/dist/InlineAlert.cjs +13 -13
  50. package/dist/InlineAlert.css +15 -15
  51. package/dist/InlineAlert.mjs +13 -13
  52. package/dist/Link.css +1 -1
  53. package/dist/Menu.cjs +37 -37
  54. package/dist/Menu.css +38 -38
  55. package/dist/Menu.mjs +37 -37
  56. package/dist/Meter.cjs +12 -12
  57. package/dist/Meter.css +12 -12
  58. package/dist/Meter.mjs +12 -12
  59. package/dist/Modal.cjs +4 -4
  60. package/dist/Modal.css +2 -2
  61. package/dist/Modal.mjs +4 -4
  62. package/dist/NumberField.cjs +12 -12
  63. package/dist/NumberField.css +13 -13
  64. package/dist/NumberField.mjs +12 -12
  65. package/dist/Picker.cjs +16 -16
  66. package/dist/Picker.css +17 -17
  67. package/dist/Picker.mjs +16 -16
  68. package/dist/Popover.cjs +10 -10
  69. package/dist/Popover.css +5 -5
  70. package/dist/Popover.mjs +10 -10
  71. package/dist/ProgressBar.cjs +19 -19
  72. package/dist/ProgressBar.css +18 -18
  73. package/dist/ProgressBar.mjs +19 -19
  74. package/dist/Radio.cjs +1 -1
  75. package/dist/Radio.css +3 -3
  76. package/dist/Radio.mjs +1 -1
  77. package/dist/RadioGroup.cjs +12 -12
  78. package/dist/RadioGroup.css +12 -12
  79. package/dist/RadioGroup.mjs +12 -12
  80. package/dist/SearchField.cjs +8 -8
  81. package/dist/SearchField.css +8 -8
  82. package/dist/SearchField.mjs +8 -8
  83. package/dist/SegmentedControl.css +1 -1
  84. package/dist/Slider.cjs +27 -27
  85. package/dist/Slider.css +27 -27
  86. package/dist/Slider.mjs +27 -27
  87. package/dist/Switch.cjs +1 -1
  88. package/dist/Switch.css +3 -3
  89. package/dist/Switch.mjs +1 -1
  90. package/dist/Tabs.css +1 -1
  91. package/dist/TabsPicker.cjs +9 -9
  92. package/dist/TabsPicker.css +10 -10
  93. package/dist/TabsPicker.mjs +9 -9
  94. package/dist/TagGroup.cjs +16 -16
  95. package/dist/TagGroup.css +17 -17
  96. package/dist/TagGroup.mjs +16 -16
  97. package/dist/TextField.cjs +8 -8
  98. package/dist/TextField.css +8 -8
  99. package/dist/TextField.mjs +8 -8
  100. package/dist/Tooltip.cjs +5 -5
  101. package/dist/Tooltip.css +4 -4
  102. package/dist/Tooltip.mjs +5 -5
  103. package/dist/types.d.ts.map +1 -1
  104. package/package.json +19 -19
  105. package/src/Button.tsx +107 -75
  106. package/src/CloseButton.tsx +4 -0
  107. package/style/dist/spectrum-theme.cjs +42 -4
  108. package/style/dist/spectrum-theme.cjs.map +1 -1
  109. package/style/dist/spectrum-theme.mjs +42 -4
  110. package/style/dist/spectrum-theme.mjs.map +1 -1
  111. package/style/dist/style-macro.cjs +1 -1
  112. package/style/dist/style-macro.cjs.map +1 -1
  113. package/style/dist/style-macro.mjs +1 -1
  114. package/style/dist/style-macro.mjs.map +1 -1
  115. package/style/dist/types.d.ts +8 -3
  116. package/style/dist/types.d.ts.map +1 -1
  117. package/style/spectrum-theme.ts +57 -6
  118. package/style/style-macro.ts +3 -3
  119. package/style/types.ts +1 -1
package/src/Button.tsx CHANGED
@@ -138,24 +138,6 @@ const button = style<ButtonRenderProps & ButtonStyleProps & {isStaticColor: bool
138
138
  isDisabled: 'GrayText'
139
139
  }
140
140
  },
141
- backgroundImage: {
142
- variant: {
143
- premium: {
144
- default: linearGradient('96deg', ['fuchsia-900', 0], ['indigo-900', 66], ['blue-900', 100]),
145
- isHovered: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),
146
- isPressed: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),
147
- isFocusVisible: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100])
148
- },
149
- genai: {
150
- default: linearGradient('96deg', ['red-900', 0], ['magenta-900', 33], ['indigo-900', 100]),
151
- isHovered: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),
152
- isPressed: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),
153
- isFocusVisible: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100])
154
- }
155
- },
156
- isDisabled: 'none',
157
- forcedColors: 'none'
158
- },
159
141
  backgroundColor: {
160
142
  fillStyle: {
161
143
  fill: {
@@ -296,6 +278,42 @@ const button = style<ButtonRenderProps & ButtonStyleProps & {isStaticColor: bool
296
278
  disableTapHighlight: true
297
279
  }, getAllowedOverrides());
298
280
 
281
+ // Put the gradient background on a separate element from the button to work around a Safari
282
+ // bug where transitions of custom properties cause layout flickering if any properties use rems. 🤣
283
+ // https://bugs.webkit.org/show_bug.cgi?id=285622
284
+ const gradient = style({
285
+ position: 'absolute',
286
+ inset: 0,
287
+ zIndex: -1,
288
+ transition: 'default',
289
+ borderRadius: '[inherit]',
290
+ backgroundImage: {
291
+ variant: {
292
+ premium: {
293
+ default: linearGradient('to bottom right', ['fuchsia-900', 0], ['indigo-900', 66], ['blue-900', 100]),
294
+ isHovered: linearGradient('to bottom right', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),
295
+ isPressed: linearGradient('to bottom right', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),
296
+ isFocusVisible: linearGradient('to bottom right', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100])
297
+ },
298
+ genai: {
299
+ default: linearGradient('to bottom right', ['red-900', 0], ['magenta-900', 33], ['indigo-900', 100]),
300
+ isHovered: linearGradient('to bottom right', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),
301
+ isPressed: linearGradient('to bottom right', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),
302
+ isFocusVisible: linearGradient('to bottom right', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100])
303
+ }
304
+ },
305
+ isDisabled: 'none',
306
+ forcedColors: 'none'
307
+ },
308
+ // Force gradient colors to remain static between light and dark theme.
309
+ colorScheme: {
310
+ variant: {
311
+ premium: 'light',
312
+ genai: 'light'
313
+ }
314
+ }
315
+ });
316
+
299
317
  /**
300
318
  * Buttons allow users to perform an action.
301
319
  * They have multiple styles for various needs, and are ideal for calling attention to
@@ -350,65 +368,79 @@ export const Button = forwardRef(function Button(props: ButtonProps, ref: Focusa
350
368
  staticColor,
351
369
  isStaticColor: !!staticColor
352
370
  }, props.styles)}>
353
- <Provider
354
- values={[
355
- [SkeletonContext, null],
356
- [TextContext, {
357
- styles: style({
358
- paddingY: '--labelPadding',
359
- order: 1,
360
- opacity: {
361
- default: 1,
362
- isProgressVisible: 0
363
- }
364
- })({isProgressVisible}),
365
- // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past
366
- 'data-rsp-slot': 'text'
367
- }],
368
- [IconContext, {
369
- render: centerBaseline({slot: 'icon', styles: style({order: 0})}),
370
- styles: style({
371
- size: fontRelative(20),
372
- marginStart: '--iconMargin',
373
- flexShrink: 0,
374
- opacity: {
375
- default: 1,
376
- isProgressVisible: 0
377
- }
378
- })({isProgressVisible})
379
- }]
380
- ]}>
381
- {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}
382
- {isPending &&
383
- <div
384
- className={style({
385
- position: 'absolute',
386
- top: '[50%]',
387
- left: '[50%]',
388
- transform: 'translate(-50%, -50%)',
389
- opacity: {
390
- default: 0,
391
- isProgressVisible: 1
392
- }
393
- })({isProgressVisible, isPending})}>
394
- <ProgressCircle
395
- isIndeterminate
396
- aria-label={stringFormatter.format('button.pending')}
397
- size="S"
398
- staticColor={staticColor}
399
- styles={style({
400
- size: {
371
+ {(renderProps) => (<>
372
+ {variant === 'genai' || variant === 'premium'
373
+ ? (
374
+ <span
375
+ className={gradient({
376
+ ...renderProps,
377
+ // Retain hover styles when an overlay is open.
378
+ isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,
379
+ isDisabled: renderProps.isDisabled || isProgressVisible,
380
+ variant
381
+ })} />
382
+ )
383
+ : null}
384
+ <Provider
385
+ values={[
386
+ [SkeletonContext, null],
387
+ [TextContext, {
388
+ styles: style({
389
+ paddingY: '--labelPadding',
390
+ order: 1,
391
+ opacity: {
392
+ default: 1,
393
+ isProgressVisible: 0
394
+ }
395
+ })({isProgressVisible}),
396
+ // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past
397
+ 'data-rsp-slot': 'text'
398
+ }],
399
+ [IconContext, {
400
+ render: centerBaseline({slot: 'icon', styles: style({order: 0})}),
401
+ styles: style({
402
+ size: fontRelative(20),
403
+ marginStart: '--iconMargin',
404
+ flexShrink: 0,
405
+ opacity: {
406
+ default: 1,
407
+ isProgressVisible: 0
408
+ }
409
+ })({isProgressVisible})
410
+ }]
411
+ ]}>
412
+ {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}
413
+ {isPending &&
414
+ <div
415
+ className={style({
416
+ position: 'absolute',
417
+ top: '[50%]',
418
+ left: '[50%]',
419
+ transform: 'translate(-50%, -50%)',
420
+ opacity: {
421
+ default: 0,
422
+ isProgressVisible: 1
423
+ }
424
+ })({isProgressVisible, isPending})}>
425
+ <ProgressCircle
426
+ isIndeterminate
427
+ aria-label={stringFormatter.format('button.pending')}
428
+ size="S"
429
+ staticColor={staticColor}
430
+ styles={style({
401
431
  size: {
402
- S: 14,
403
- M: 18,
404
- L: 20,
405
- XL: 24
432
+ size: {
433
+ S: 14,
434
+ M: 18,
435
+ L: 20,
436
+ XL: 24
437
+ }
406
438
  }
407
- }
408
- })({size})} />
409
- </div>
410
- }
411
- </Provider>
439
+ })({size})} />
440
+ </div>
441
+ }
442
+ </Provider>
443
+ </>)}
412
444
  </RACButton>
413
445
  );
414
446
  });
@@ -65,6 +65,10 @@ const styles = style({
65
65
  isStaticColor: {
66
66
  default: baseColor('transparent-overlay-800'),
67
67
  isDisabled: 'transparent-overlay-400'
68
+ },
69
+ forcedColors: {
70
+ default: 'ButtonText',
71
+ isDisabled: 'GrayText'
68
72
  }
69
73
  }
70
74
  },
@@ -492,7 +492,24 @@ function $7dddb03c6ef7d79c$export$9b476054b78b89cd(a, b, percent) {
492
492
  return `[color-mix(in srgb, ${$7dddb03c6ef7d79c$var$parseColor(a)}, ${$7dddb03c6ef7d79c$var$parseColor(b)} ${percent}%)]`;
493
493
  }
494
494
  function $7dddb03c6ef7d79c$export$46def8197cf4dd4c(angle, ...tokens) {
495
- return `linear-gradient(${angle}, ${tokens.map(([color, stop])=>`${$7dddb03c6ef7d79c$var$parseColor(color)} ${stop}%`)})`;
495
+ // Generate @property rules for each gradient stop color. This allows the gradient to be animated.
496
+ let propertyDefinitions = [];
497
+ for(let i = 0; i < tokens.length; i++)propertyDefinitions.push(`@property --g${i} {
498
+ syntax: '<color>';
499
+ initial-value: #0000;
500
+ inherits: false;
501
+ }`);
502
+ if (this && typeof this.addAsset === 'function') this.addAsset({
503
+ type: 'css',
504
+ content: propertyDefinitions.join('\n\n')
505
+ });
506
+ return [
507
+ {
508
+ type: 'linear-gradient',
509
+ angle: angle,
510
+ stops: tokens
511
+ }
512
+ ];
496
513
  }
497
514
  function $7dddb03c6ef7d79c$var$generateSpacing(px) {
498
515
  let res = {};
@@ -671,8 +688,10 @@ let $7dddb03c6ef7d79c$var$gridTrackSize = (value)=>{
671
688
  return value in $7dddb03c6ef7d79c$var$baseSpacing ? $7dddb03c6ef7d79c$var$baseSpacing[value] : value;
672
689
  };
673
690
  const $7dddb03c6ef7d79c$var$transitionProperty = {
674
- default: 'color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter',
675
- colors: 'color, background-color, border-color, text-decoration-color, fill, stroke',
691
+ // var(--gp) is generated by the backgroundImage property when setting a gradient.
692
+ // It includes a list of all of the custom properties used for each color stop.
693
+ default: 'color, background-color, var(--gp), border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter',
694
+ colors: 'color, background-color, var(--gp), border-color, text-decoration-color, fill, stroke',
676
695
  opacity: 'opacity',
677
696
  shadow: 'box-shadow',
678
697
  transform: 'transform, translate, scale, rotate',
@@ -1343,7 +1362,26 @@ const $7dddb03c6ef7d79c$export$1d567c320f4763bc = (0, $b3643cb9d2948e30$exports.
1343
1362
  'dark',
1344
1363
  'light dark'
1345
1364
  ],
1346
- backgroundImage: (0, $b3643cb9d2948e30$exports.createArbitraryProperty)(),
1365
+ backgroundImage: (0, $b3643cb9d2948e30$exports.createArbitraryProperty)((value, property)=>{
1366
+ if (typeof value === 'string') return {
1367
+ [property]: value
1368
+ };
1369
+ else if (Array.isArray(value) && value[0]?.type === 'linear-gradient') {
1370
+ let values = {
1371
+ [property]: `linear-gradient(${value[0].angle}, ${value[0].stops.map(([, stop], i)=>`var(--g${i}) ${stop}%`)})`
1372
+ };
1373
+ // Create a CSS var for each color stop so the gradient can be transitioned.
1374
+ // These are registered via @property in the `linearGradient` macro.
1375
+ let properties = [];
1376
+ value[0].stops.forEach(([color], i)=>{
1377
+ properties.push(`--g${i}`);
1378
+ values[`--g${i}`] = $7dddb03c6ef7d79c$var$parseColor(color);
1379
+ });
1380
+ // This is used by transition-property so we automatically transition all of the color stops.
1381
+ values['--gp'] = properties.join(', ');
1382
+ return values;
1383
+ } else throw new Error('Unexpected backgroundImage value: ' + JSON.stringify(value));
1384
+ }),
1347
1385
  // TODO: do we need separate x and y properties?
1348
1386
  backgroundPosition: [
1349
1387
  'bottom',