@react-spectrum/s2 3.0.0-nightly-326f48154-241216 → 3.0.0-nightly-fee532d6a-241217
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/ActionButton.cjs +58 -80
- package/dist/ActionButton.cjs.map +1 -1
- package/dist/ActionButton.css +76 -96
- package/dist/ActionButton.css.map +1 -1
- package/dist/ActionButton.mjs +58 -80
- package/dist/ActionButton.mjs.map +1 -1
- package/dist/ActionButtonGroup.cjs.map +1 -1
- package/dist/ActionButtonGroup.css.map +1 -1
- package/dist/ActionButtonGroup.mjs.map +1 -1
- package/dist/Badge.cjs +66 -66
- package/dist/Badge.css +43 -43
- package/dist/Badge.mjs +66 -66
- package/dist/Breadcrumbs.cjs +6 -6
- package/dist/Breadcrumbs.css +4 -4
- package/dist/Breadcrumbs.mjs +6 -6
- package/dist/Button.cjs +89 -134
- package/dist/Button.cjs.map +1 -1
- package/dist/Button.css +102 -134
- package/dist/Button.css.map +1 -1
- package/dist/Button.mjs +89 -134
- package/dist/Button.mjs.map +1 -1
- package/dist/Card.cjs +4 -4
- package/dist/Card.css +3 -3
- package/dist/Card.mjs +4 -4
- package/dist/CardView.cjs +1 -1
- package/dist/CardView.css +1 -1
- package/dist/CardView.mjs +1 -1
- package/dist/Checkbox.cjs +10 -10
- package/dist/Checkbox.css +10 -10
- package/dist/Checkbox.mjs +10 -10
- package/dist/CloseButton.cjs +17 -28
- package/dist/CloseButton.cjs.map +1 -1
- package/dist/CloseButton.css +19 -31
- package/dist/CloseButton.css.map +1 -1
- package/dist/CloseButton.mjs +17 -28
- package/dist/CloseButton.mjs.map +1 -1
- package/dist/ColorArea.cjs +1 -1
- package/dist/ColorArea.css +1 -1
- package/dist/ColorArea.mjs +1 -1
- package/dist/ColorHandle.cjs +3 -3
- package/dist/ColorHandle.css +3 -3
- package/dist/ColorHandle.mjs +3 -3
- package/dist/ColorSlider.cjs +1 -1
- package/dist/ColorSlider.css +1 -1
- package/dist/ColorSlider.mjs +1 -1
- package/dist/ColorSwatchPicker.cjs +1 -1
- package/dist/ColorSwatchPicker.css +1 -1
- package/dist/ColorSwatchPicker.mjs +1 -1
- package/dist/ColorWheel.cjs +2 -2
- package/dist/ColorWheel.css +1 -1
- package/dist/ColorWheel.mjs +2 -2
- package/dist/ComboBox.cjs +5 -5
- package/dist/ComboBox.css +4 -4
- package/dist/ComboBox.mjs +5 -5
- package/dist/Disclosure.cjs +1 -1
- package/dist/Disclosure.css +1 -1
- package/dist/Disclosure.mjs +1 -1
- package/dist/Divider.cjs +8 -8
- package/dist/Divider.cjs.map +1 -1
- package/dist/Divider.css +13 -13
- package/dist/Divider.css.map +1 -1
- package/dist/Divider.mjs +8 -8
- package/dist/Divider.mjs.map +1 -1
- package/dist/DropZone.cjs +4 -4
- package/dist/DropZone.css +2 -2
- package/dist/DropZone.mjs +4 -4
- package/dist/Field.cjs +7 -8
- package/dist/Field.cjs.map +1 -1
- package/dist/Field.css +7 -11
- package/dist/Field.css.map +1 -1
- package/dist/Field.mjs +7 -8
- package/dist/Field.mjs.map +1 -1
- package/dist/InlineAlert.cjs +23 -23
- package/dist/InlineAlert.css +15 -15
- package/dist/InlineAlert.mjs +23 -23
- package/dist/Link.cjs +7 -6
- package/dist/Link.cjs.map +1 -1
- package/dist/Link.css +14 -14
- package/dist/Link.css.map +1 -1
- package/dist/Link.mjs +7 -6
- package/dist/Link.mjs.map +1 -1
- package/dist/Menu.cjs +26 -6
- package/dist/Menu.cjs.map +1 -1
- package/dist/Menu.css +3 -3
- package/dist/Menu.css.map +1 -1
- package/dist/Menu.mjs +27 -7
- package/dist/Menu.mjs.map +1 -1
- package/dist/Meter.cjs +13 -13
- package/dist/Meter.cjs.map +1 -1
- package/dist/Meter.css +18 -22
- package/dist/Meter.css.map +1 -1
- package/dist/Meter.mjs +13 -13
- package/dist/Meter.mjs.map +1 -1
- package/dist/Modal.cjs +1 -1
- package/dist/Modal.css +1 -1
- package/dist/Modal.mjs +1 -1
- package/dist/NumberField.cjs +4 -4
- package/dist/NumberField.css +4 -4
- package/dist/NumberField.mjs +4 -4
- package/dist/Picker.cjs +4 -4
- package/dist/Picker.css +4 -4
- package/dist/Picker.mjs +4 -4
- package/dist/Popover.cjs +3 -3
- package/dist/Popover.css +3 -3
- package/dist/Popover.mjs +3 -3
- package/dist/ProgressBar.cjs +20 -18
- package/dist/ProgressBar.cjs.map +1 -1
- package/dist/ProgressBar.css +20 -24
- package/dist/ProgressBar.css.map +1 -1
- package/dist/ProgressBar.mjs +20 -18
- package/dist/ProgressBar.mjs.map +1 -1
- package/dist/ProgressCircle.cjs +11 -9
- package/dist/ProgressCircle.cjs.map +1 -1
- package/dist/ProgressCircle.css +14 -14
- package/dist/ProgressCircle.css.map +1 -1
- package/dist/ProgressCircle.mjs +11 -9
- package/dist/ProgressCircle.mjs.map +1 -1
- package/dist/Provider.cjs +1 -1
- package/dist/Provider.css +1 -1
- package/dist/Provider.mjs +1 -1
- package/dist/Radio.cjs +6 -6
- package/dist/Radio.css +6 -6
- package/dist/Radio.mjs +6 -6
- package/dist/SearchField.cjs +1 -1
- package/dist/SearchField.css +1 -1
- package/dist/SearchField.mjs +1 -1
- package/dist/SegmentedControl.cjs +8 -8
- package/dist/SegmentedControl.css +8 -8
- package/dist/SegmentedControl.mjs +8 -8
- package/dist/Slider.cjs +8 -8
- package/dist/Slider.css +5 -5
- package/dist/Slider.mjs +8 -8
- package/dist/Switch.cjs +7 -7
- package/dist/Switch.css +6 -6
- package/dist/Switch.mjs +7 -7
- package/dist/TableView.cjs +17 -17
- package/dist/TableView.css +11 -11
- package/dist/TableView.mjs +17 -17
- package/dist/Tabs.cjs +5 -5
- package/dist/Tabs.css +5 -5
- package/dist/Tabs.mjs +5 -5
- package/dist/TabsPicker.cjs +1 -1
- package/dist/TabsPicker.css +1 -1
- package/dist/TabsPicker.mjs +1 -1
- package/dist/TagGroup.cjs +10 -10
- package/dist/TagGroup.css +8 -8
- package/dist/TagGroup.mjs +10 -10
- package/dist/ToggleButton.cjs +1 -0
- package/dist/ToggleButton.cjs.map +1 -1
- package/dist/ToggleButton.css.map +1 -1
- package/dist/ToggleButton.mjs +1 -0
- package/dist/ToggleButton.mjs.map +1 -1
- package/dist/Tooltip.cjs +1 -1
- package/dist/Tooltip.css +1 -1
- package/dist/Tooltip.mjs +1 -1
- package/dist/types.d.ts +9 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/ActionButton.tsx +19 -43
- package/src/ActionButtonGroup.tsx +1 -1
- package/src/Button.tsx +36 -79
- package/src/CloseButton.tsx +10 -20
- package/src/Divider.tsx +10 -16
- package/src/Field.tsx +2 -2
- package/src/Link.tsx +7 -12
- package/src/Menu.tsx +22 -6
- package/src/Meter.tsx +7 -14
- package/src/ProgressBar.tsx +8 -15
- package/src/ProgressCircle.tsx +12 -15
- package/src/ToggleButton.tsx +1 -0
- package/src/bar-utils.ts +3 -10
- package/src/style-utils.ts +15 -8
- package/style/dist/spectrum-theme.cjs +15 -1
- package/style/dist/spectrum-theme.cjs.map +1 -1
- package/style/dist/spectrum-theme.mjs +15 -1
- package/style/dist/spectrum-theme.mjs.map +1 -1
- package/style/dist/types.d.ts +40 -27
- package/style/dist/types.d.ts.map +1 -1
- package/style/spectrum-theme.ts +4 -2
- package/style/tokens.ts +30 -0
package/src/Button.tsx
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import {baseColor, focusRing, fontRelative, style} from '../style' with {type: 'macro'};
|
|
14
14
|
import {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';
|
|
15
15
|
import {centerBaseline} from './CenterBaseline';
|
|
16
|
-
import {centerPadding, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
|
|
16
|
+
import {centerPadding, getAllowedOverrides, staticColor, StyleProps} from './style-utils' with {type: 'macro'};
|
|
17
17
|
import {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';
|
|
18
18
|
import {FocusableRef, FocusableRefValue} from '@react-types/shared';
|
|
19
19
|
import {IconContext} from './Icon';
|
|
@@ -48,7 +48,7 @@ interface ButtonStyleProps {
|
|
|
48
48
|
*/
|
|
49
49
|
size?: 'S' | 'M' | 'L' | 'XL',
|
|
50
50
|
/** The static color style to apply. Useful when the Button appears over a color background. */
|
|
51
|
-
staticColor?: 'white' | 'black'
|
|
51
|
+
staticColor?: 'white' | 'black' | 'auto'
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {
|
|
@@ -65,8 +65,9 @@ export const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRe
|
|
|
65
65
|
export const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);
|
|
66
66
|
|
|
67
67
|
const iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))';
|
|
68
|
-
const button = style<ButtonRenderProps & ButtonStyleProps>({
|
|
68
|
+
const button = style<ButtonRenderProps & ButtonStyleProps & {isStaticColor: boolean}>({
|
|
69
69
|
...focusRing(),
|
|
70
|
+
...staticColor(),
|
|
70
71
|
position: 'relative',
|
|
71
72
|
display: 'flex',
|
|
72
73
|
alignItems: {
|
|
@@ -120,21 +121,12 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
|
|
|
120
121
|
secondary: baseColor('gray-300')
|
|
121
122
|
},
|
|
122
123
|
isDisabled: 'disabled',
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
secondary: baseColor('transparent-white-300')
|
|
128
|
-
},
|
|
129
|
-
isDisabled: 'transparent-white-300'
|
|
124
|
+
isStaticColor: {
|
|
125
|
+
variant: {
|
|
126
|
+
primary: baseColor('transparent-overlay-800'),
|
|
127
|
+
secondary: baseColor('transparent-overlay-300')
|
|
130
128
|
},
|
|
131
|
-
|
|
132
|
-
variant: {
|
|
133
|
-
primary: baseColor('transparent-black-800'),
|
|
134
|
-
secondary: baseColor('transparent-black-300')
|
|
135
|
-
},
|
|
136
|
-
isDisabled: 'transparent-black-300'
|
|
137
|
-
}
|
|
129
|
+
isDisabled: 'transparent-overlay-300'
|
|
138
130
|
},
|
|
139
131
|
forcedColors: {
|
|
140
132
|
default: 'ButtonBorder',
|
|
@@ -161,41 +153,21 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
|
|
|
161
153
|
isDisabled: 'transparent'
|
|
162
154
|
}
|
|
163
155
|
},
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
secondary: baseColor('transparent-white-100')
|
|
171
|
-
},
|
|
172
|
-
isDisabled: 'transparent-white-100'
|
|
173
|
-
},
|
|
174
|
-
outline: {
|
|
175
|
-
default: 'transparent',
|
|
176
|
-
isHovered: 'transparent-white-100',
|
|
177
|
-
isPressed: 'transparent-white-100',
|
|
178
|
-
isFocusVisible: 'transparent-white-100',
|
|
179
|
-
isDisabled: 'transparent'
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
black: {
|
|
184
|
-
fillStyle: {
|
|
185
|
-
fill: {
|
|
186
|
-
variant: {
|
|
187
|
-
primary: baseColor('transparent-black-800'),
|
|
188
|
-
secondary: baseColor('transparent-black-100')
|
|
189
|
-
},
|
|
190
|
-
isDisabled: 'transparent-black-100'
|
|
156
|
+
isStaticColor: {
|
|
157
|
+
fillStyle: {
|
|
158
|
+
fill: {
|
|
159
|
+
variant: {
|
|
160
|
+
primary: baseColor('transparent-overlay-800'),
|
|
161
|
+
secondary: baseColor('transparent-overlay-100')
|
|
191
162
|
},
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
163
|
+
isDisabled: 'transparent-overlay-100'
|
|
164
|
+
},
|
|
165
|
+
outline: {
|
|
166
|
+
default: 'transparent',
|
|
167
|
+
isHovered: 'transparent-overlay-100',
|
|
168
|
+
isPressed: 'transparent-overlay-100',
|
|
169
|
+
isFocusVisible: 'transparent-overlay-100',
|
|
170
|
+
isDisabled: 'transparent'
|
|
199
171
|
}
|
|
200
172
|
}
|
|
201
173
|
},
|
|
@@ -226,31 +198,17 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
|
|
|
226
198
|
isDisabled: 'disabled'
|
|
227
199
|
}
|
|
228
200
|
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
outline: baseColor('transparent-white-800')
|
|
201
|
+
isStaticColor: {
|
|
202
|
+
fillStyle: {
|
|
203
|
+
fill: {
|
|
204
|
+
variant: {
|
|
205
|
+
primary: 'auto',
|
|
206
|
+
secondary: baseColor('transparent-overlay-800')
|
|
207
|
+
}
|
|
239
208
|
},
|
|
240
|
-
|
|
209
|
+
outline: baseColor('transparent-overlay-800')
|
|
241
210
|
},
|
|
242
|
-
|
|
243
|
-
fillStyle: {
|
|
244
|
-
fill: {
|
|
245
|
-
variant: {
|
|
246
|
-
primary: 'white',
|
|
247
|
-
secondary: baseColor('transparent-black-800')
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
outline: baseColor('transparent-black-800')
|
|
251
|
-
},
|
|
252
|
-
isDisabled: 'transparent-black-400'
|
|
253
|
-
}
|
|
211
|
+
isDisabled: 'transparent-overlay-400'
|
|
254
212
|
},
|
|
255
213
|
forcedColors: {
|
|
256
214
|
fillStyle: {
|
|
@@ -271,10 +229,7 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
|
|
|
271
229
|
},
|
|
272
230
|
outlineColor: {
|
|
273
231
|
default: 'focus-ring',
|
|
274
|
-
|
|
275
|
-
white: 'white',
|
|
276
|
-
black: 'black'
|
|
277
|
-
},
|
|
232
|
+
isStaticColor: 'transparent-overlay-1000',
|
|
278
233
|
forcedColors: 'Highlight'
|
|
279
234
|
},
|
|
280
235
|
forcedColorAdjust: 'none',
|
|
@@ -332,7 +287,8 @@ export const Button = forwardRef(function Button(props: ButtonProps, ref: Focusa
|
|
|
332
287
|
variant,
|
|
333
288
|
fillStyle,
|
|
334
289
|
size,
|
|
335
|
-
staticColor
|
|
290
|
+
staticColor,
|
|
291
|
+
isStaticColor: !!staticColor
|
|
336
292
|
}, props.styles)}>
|
|
337
293
|
<Provider
|
|
338
294
|
values={[
|
|
@@ -419,6 +375,7 @@ export const LinkButton = forwardRef(function LinkButton(props: LinkButtonProps,
|
|
|
419
375
|
fillStyle: props.fillStyle || 'fill',
|
|
420
376
|
size: props.size || 'M',
|
|
421
377
|
staticColor: props.staticColor,
|
|
378
|
+
isStaticColor: !!props.staticColor,
|
|
422
379
|
isPending: false
|
|
423
380
|
}, props.styles)}>
|
|
424
381
|
<Provider
|
package/src/CloseButton.tsx
CHANGED
|
@@ -15,7 +15,7 @@ import {Button, ButtonProps, ContextValue} from 'react-aria-components';
|
|
|
15
15
|
import {createContext, forwardRef} from 'react';
|
|
16
16
|
import CrossIcon from '../ui-icons/Cross';
|
|
17
17
|
import {FocusableRef, FocusableRefValue} from '@react-types/shared';
|
|
18
|
-
import {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
|
|
18
|
+
import {getAllowedOverrides, staticColor, StyleProps} from './style-utils' with {type: 'macro'};
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
import intlMessages from '../intl/*.json';
|
|
21
21
|
import {pressScale} from './pressScale';
|
|
@@ -31,19 +31,18 @@ export interface CloseButtonProps extends Pick<ButtonProps, 'isDisabled'>, Style
|
|
|
31
31
|
*/
|
|
32
32
|
size?: 'S' | 'M' | 'L' | 'XL',
|
|
33
33
|
/** The static color style to apply. Useful when the Button appears over a color background. */
|
|
34
|
-
staticColor?: 'white' | 'black'
|
|
34
|
+
staticColor?: 'white' | 'black' | 'auto'
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// TODO(design): this is inconsistent with ActionButton
|
|
37
38
|
const hoverBackground = {
|
|
38
39
|
default: 'gray-100',
|
|
39
|
-
|
|
40
|
-
white: 'transparent-white-100',
|
|
41
|
-
black: 'transparent-black-100'
|
|
42
|
-
}
|
|
40
|
+
isStaticColor: 'transparent-overlay-100'
|
|
43
41
|
} as const;
|
|
44
42
|
|
|
45
43
|
const styles = style({
|
|
46
44
|
...focusRing(),
|
|
45
|
+
...staticColor(),
|
|
47
46
|
display: 'flex',
|
|
48
47
|
alignItems: 'center',
|
|
49
48
|
justifyContent: 'center',
|
|
@@ -64,24 +63,15 @@ const styles = style({
|
|
|
64
63
|
value: {
|
|
65
64
|
default: 'neutral',
|
|
66
65
|
isDisabled: 'disabled',
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
isDisabled: 'transparent-white-400'
|
|
71
|
-
},
|
|
72
|
-
black: {
|
|
73
|
-
default: baseColor('transparent-black-800'),
|
|
74
|
-
isDisabled: 'transparent-black-400'
|
|
75
|
-
}
|
|
66
|
+
isStaticColor: {
|
|
67
|
+
default: baseColor('transparent-overlay-800'),
|
|
68
|
+
isDisabled: 'transparent-overlay-400'
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
},
|
|
79
72
|
outlineColor: {
|
|
80
73
|
default: 'focus-ring',
|
|
81
|
-
|
|
82
|
-
white: 'white',
|
|
83
|
-
black: 'black'
|
|
84
|
-
},
|
|
74
|
+
isStaticColor: 'transparent-overlay-1000',
|
|
85
75
|
forcedColors: 'Highlight'
|
|
86
76
|
}
|
|
87
77
|
}, getAllowedOverrides());
|
|
@@ -103,7 +93,7 @@ export const CloseButton = forwardRef(function CloseButton(props: CloseButtonPro
|
|
|
103
93
|
slot="close"
|
|
104
94
|
aria-label={stringFormatter.format('dialog.dismiss')}
|
|
105
95
|
style={pressScale(domRef, UNSAFE_style)}
|
|
106
|
-
className={renderProps => UNSAFE_className + styles({...renderProps, staticColor: props.staticColor}, props.styles)}>
|
|
96
|
+
className={renderProps => UNSAFE_className + styles({...renderProps, staticColor: props.staticColor, isStaticColor: !!props.staticColor}, props.styles)}>
|
|
107
97
|
<CrossIcon size={({S: 'L', M: 'XL', L: 'XXL', XL: 'XXXL'} as const)[props.size || 'M']} />
|
|
108
98
|
</Button>
|
|
109
99
|
);
|
package/src/Divider.tsx
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import {ContextValue, Separator as RACSeparator, SeparatorProps as RACSeparatorProps} from 'react-aria-components';
|
|
14
14
|
import {createContext, forwardRef} from 'react';
|
|
15
15
|
import {DOMRef, DOMRefValue} from '@react-types/shared';
|
|
16
|
-
import {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
|
|
16
|
+
import {getAllowedOverrides, staticColor, StyleProps} from './style-utils' with {type: 'macro'};
|
|
17
17
|
import {style} from '../style' with {type: 'macro'};
|
|
18
18
|
import {useDOMRef} from '@react-spectrum/utils';
|
|
19
19
|
import {useSpectrumContextProps} from './useSpectrumContextProps';
|
|
@@ -34,7 +34,7 @@ interface DividerSpectrumProps {
|
|
|
34
34
|
*/
|
|
35
35
|
orientation?: 'horizontal' | 'vertical',
|
|
36
36
|
/** The static color style to apply. Useful when the Divider appears over a color background. */
|
|
37
|
-
staticColor?: 'white' | 'black'
|
|
37
|
+
staticColor?: 'white' | 'black' | 'auto'
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// TODO: allow overriding height (only when orientation is vertical)??
|
|
@@ -42,25 +42,18 @@ export interface DividerProps extends DividerSpectrumProps, Omit<RACSeparatorPro
|
|
|
42
42
|
|
|
43
43
|
export const DividerContext = createContext<ContextValue<DividerProps, DOMRefValue>>(null);
|
|
44
44
|
|
|
45
|
-
export const divider = style<DividerSpectrumProps>({
|
|
45
|
+
export const divider = style<DividerSpectrumProps & {isStaticColor: boolean}>({
|
|
46
|
+
...staticColor(),
|
|
46
47
|
alignSelf: 'stretch',
|
|
47
48
|
backgroundColor: {
|
|
48
49
|
default: 'gray-200',
|
|
49
50
|
size: {
|
|
50
51
|
L: 'gray-800'
|
|
51
52
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
L: 'transparent-white-800'
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
black: {
|
|
60
|
-
default: 'transparent-black-200',
|
|
61
|
-
size: {
|
|
62
|
-
L: 'transparent-black-800'
|
|
63
|
-
}
|
|
53
|
+
isStaticColor: {
|
|
54
|
+
default: 'transparent-overlay-200',
|
|
55
|
+
size: {
|
|
56
|
+
L: 'transparent-overlay-800'
|
|
64
57
|
}
|
|
65
58
|
},
|
|
66
59
|
forcedColors: 'ButtonBorder'
|
|
@@ -109,7 +102,8 @@ export const Divider = /*#__PURE__*/ forwardRef(function Divider(props: DividerP
|
|
|
109
102
|
className={(props.UNSAFE_className || '') + divider({
|
|
110
103
|
size: props.size || 'M',
|
|
111
104
|
orientation: props.orientation || 'horizontal',
|
|
112
|
-
staticColor: props.staticColor
|
|
105
|
+
staticColor: props.staticColor,
|
|
106
|
+
isStaticColor: !!props.staticColor
|
|
113
107
|
}, props.styles)} />
|
|
114
108
|
);
|
|
115
109
|
});
|
package/src/Field.tsx
CHANGED
|
@@ -36,7 +36,7 @@ interface FieldLabelProps extends Omit<LabelProps, 'className' | 'style' | 'chil
|
|
|
36
36
|
labelAlign?: Alignment,
|
|
37
37
|
labelPosition?: 'top' | 'side',
|
|
38
38
|
includeNecessityIndicatorInAccessibilityName?: boolean,
|
|
39
|
-
staticColor?: 'white' | 'black',
|
|
39
|
+
staticColor?: 'white' | 'black' | 'auto',
|
|
40
40
|
contextualHelp?: ReactNode,
|
|
41
41
|
isQuiet?: boolean,
|
|
42
42
|
children?: ReactNode
|
|
@@ -98,7 +98,7 @@ export const FieldLabel = forwardRef(function FieldLabel(props: FieldLabelProps,
|
|
|
98
98
|
{...labelProps}
|
|
99
99
|
ref={domRef}
|
|
100
100
|
style={UNSAFE_style}
|
|
101
|
-
className={UNSAFE_className + mergeStyles(style(fieldLabel())({labelPosition, isDisabled, size, staticColor}), props.styles)}>
|
|
101
|
+
className={UNSAFE_className + mergeStyles(style(fieldLabel())({labelPosition, isDisabled, size, isStaticColor: !!staticColor}), props.styles)}>
|
|
102
102
|
{props.children}
|
|
103
103
|
{(isRequired || necessityIndicator === 'label') && (
|
|
104
104
|
<span className={style({whiteSpace: 'nowrap'})}>
|
package/src/Link.tsx
CHANGED
|
@@ -14,7 +14,7 @@ import {ContextValue, LinkRenderProps, Link as RACLink, LinkProps as RACLinkProp
|
|
|
14
14
|
import {createContext, forwardRef, ReactNode, useContext} from 'react';
|
|
15
15
|
import {FocusableRef, FocusableRefValue} from '@react-types/shared';
|
|
16
16
|
import {focusRing, style} from '../style' with {type: 'macro'};
|
|
17
|
-
import {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
|
|
17
|
+
import {getAllowedOverrides, staticColor, StyleProps} from './style-utils' with {type: 'macro'};
|
|
18
18
|
import {SkeletonContext, useSkeletonText} from './Skeleton';
|
|
19
19
|
import {useFocusableRef} from '@react-spectrum/utils';
|
|
20
20
|
import {useLayoutEffect} from '@react-aria/utils';
|
|
@@ -27,7 +27,7 @@ interface LinkStyleProps {
|
|
|
27
27
|
*/
|
|
28
28
|
variant?: 'primary' | 'secondary',
|
|
29
29
|
/** The static color style to apply. Useful when the link appears over a color background. */
|
|
30
|
-
staticColor?: 'white' | 'black',
|
|
30
|
+
staticColor?: 'white' | 'black' | 'auto',
|
|
31
31
|
/** Whether the link is on its own vs inside a longer string of text. */
|
|
32
32
|
isStandalone?: boolean,
|
|
33
33
|
/** Whether the link should be displayed with a quiet style. */
|
|
@@ -40,8 +40,9 @@ export interface LinkProps extends Omit<RACLinkProps, 'isDisabled' | 'className'
|
|
|
40
40
|
|
|
41
41
|
export const LinkContext = createContext<ContextValue<LinkProps, FocusableRefValue<HTMLAnchorElement>>>(null);
|
|
42
42
|
|
|
43
|
-
const link = style<LinkRenderProps & LinkStyleProps & {isSkeleton: boolean}>({
|
|
43
|
+
const link = style<LinkRenderProps & LinkStyleProps & {isSkeleton: boolean, isStaticColor: boolean}>({
|
|
44
44
|
...focusRing(),
|
|
45
|
+
...staticColor(),
|
|
45
46
|
borderRadius: 'sm',
|
|
46
47
|
font: {
|
|
47
48
|
isStandalone: 'ui'
|
|
@@ -51,10 +52,7 @@ const link = style<LinkRenderProps & LinkStyleProps & {isSkeleton: boolean}>({
|
|
|
51
52
|
primary: 'accent',
|
|
52
53
|
secondary: 'neutral' // TODO: should there be an option to inherit from the paragraph? What about hover states?
|
|
53
54
|
},
|
|
54
|
-
|
|
55
|
-
white: 'white',
|
|
56
|
-
black: 'black'
|
|
57
|
-
},
|
|
55
|
+
isStaticColor: 'transparent-overlay-1000',
|
|
58
56
|
forcedColors: 'LinkText'
|
|
59
57
|
},
|
|
60
58
|
transition: 'default',
|
|
@@ -74,10 +72,7 @@ const link = style<LinkRenderProps & LinkStyleProps & {isSkeleton: boolean}>({
|
|
|
74
72
|
},
|
|
75
73
|
outlineColor: {
|
|
76
74
|
default: 'focus-ring',
|
|
77
|
-
|
|
78
|
-
white: 'white',
|
|
79
|
-
black: 'black'
|
|
80
|
-
},
|
|
75
|
+
isStaticColor: 'transparent-overlay-1000',
|
|
81
76
|
forcedColors: 'Highlight'
|
|
82
77
|
},
|
|
83
78
|
disableTapHighlight: true
|
|
@@ -107,7 +102,7 @@ export const Link = /*#__PURE__*/ forwardRef(function Link(props: LinkProps, ref
|
|
|
107
102
|
{...props}
|
|
108
103
|
ref={domRef}
|
|
109
104
|
style={UNSAFE_style}
|
|
110
|
-
className={renderProps => UNSAFE_className + link({...renderProps, variant, staticColor, isQuiet, isStandalone, isSkeleton}, styles)}>
|
|
105
|
+
className={renderProps => UNSAFE_className + link({...renderProps, variant, staticColor, isStaticColor: !!staticColor, isQuiet, isStandalone, isSkeleton}, styles)}>
|
|
111
106
|
{children}
|
|
112
107
|
</RACLink>
|
|
113
108
|
);
|
package/src/Menu.tsx
CHANGED
|
@@ -32,9 +32,9 @@ import {centerBaseline} from './CenterBaseline';
|
|
|
32
32
|
import {centerPadding, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
|
|
33
33
|
import CheckmarkIcon from '../ui-icons/Checkmark';
|
|
34
34
|
import ChevronRightIcon from '../ui-icons/Chevron';
|
|
35
|
-
import {createContext, forwardRef, JSX, ReactNode, useContext, useRef} from 'react';
|
|
35
|
+
import {createContext, forwardRef, JSX, ReactNode, useContext, useRef, useState} from 'react';
|
|
36
36
|
import {divider} from './Divider';
|
|
37
|
-
import {DOMRef, DOMRefValue} from '@react-types/shared';
|
|
37
|
+
import {DOMRef, DOMRefValue, PressEvent} from '@react-types/shared';
|
|
38
38
|
import {forwardRefType} from './types';
|
|
39
39
|
import {HeaderContext, HeadingContext, KeyboardContext, Text, TextContext} from './Content';
|
|
40
40
|
import {IconContext} from './Icon'; // chevron right removed??
|
|
@@ -45,6 +45,7 @@ import {Placement, useLocale} from 'react-aria';
|
|
|
45
45
|
import {PopoverBase} from './Popover';
|
|
46
46
|
import {PressResponder} from '@react-aria/interactions';
|
|
47
47
|
import {pressScale} from './pressScale';
|
|
48
|
+
import {useGlobalListeners} from '@react-aria/utils';
|
|
48
49
|
import {useSpectrumContextProps} from './useSpectrumContextProps';
|
|
49
50
|
// viewbox on LinkOut is super weird just because i copied the icon from designs...
|
|
50
51
|
// need to strip id's from icons
|
|
@@ -399,7 +400,7 @@ export function Divider(props: SeparatorProps) {
|
|
|
399
400
|
divider({
|
|
400
401
|
size: 'M',
|
|
401
402
|
orientation: 'horizontal',
|
|
402
|
-
|
|
403
|
+
isStaticColor: false
|
|
403
404
|
}), style({
|
|
404
405
|
display: {
|
|
405
406
|
default: 'grid',
|
|
@@ -520,6 +521,23 @@ export function MenuItem(props: MenuItemProps) {
|
|
|
520
521
|
* linking the Menu's open state with the trigger's press state.
|
|
521
522
|
*/
|
|
522
523
|
function MenuTrigger(props: MenuTriggerProps) {
|
|
524
|
+
// RAC sets isPressed via PressResponder when the menu is open.
|
|
525
|
+
// We don't want press scaling to appear to get "stuck", so override this.
|
|
526
|
+
// For mouse interactions, menus open on press start. When the popover underlay appears
|
|
527
|
+
// it covers the trigger button, causing onPressEnd to fire immediately and no press scaling
|
|
528
|
+
// to occur. We override this by listening for pointerup on the document ourselves.
|
|
529
|
+
let [isPressed, setPressed] = useState(false);
|
|
530
|
+
let {addGlobalListener} = useGlobalListeners();
|
|
531
|
+
let onPressStart = (e: PressEvent) => {
|
|
532
|
+
if (e.pointerType !== 'mouse') {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
setPressed(true);
|
|
536
|
+
addGlobalListener(document, 'pointerup', () => {
|
|
537
|
+
setPressed(false);
|
|
538
|
+
}, {once: true, capture: true});
|
|
539
|
+
};
|
|
540
|
+
|
|
523
541
|
return (
|
|
524
542
|
<InternalMenuTriggerContext.Provider
|
|
525
543
|
value={{
|
|
@@ -528,9 +546,7 @@ function MenuTrigger(props: MenuTriggerProps) {
|
|
|
528
546
|
shouldFlip: props.shouldFlip
|
|
529
547
|
}}>
|
|
530
548
|
<AriaMenuTrigger {...props}>
|
|
531
|
-
{
|
|
532
|
-
We don't want press scaling to appear to get "stuck", so override this. */}
|
|
533
|
-
<PressResponder isPressed={false}>
|
|
549
|
+
<PressResponder onPressStart={onPressStart} isPressed={isPressed}>
|
|
534
550
|
{props.children}
|
|
535
551
|
</PressResponder>
|
|
536
552
|
</AriaMenuTrigger>
|
package/src/Meter.tsx
CHANGED
|
@@ -40,7 +40,7 @@ interface MeterStyleProps {
|
|
|
40
40
|
/**
|
|
41
41
|
* The static color style to apply. Useful when the button appears over a color background.
|
|
42
42
|
*/
|
|
43
|
-
staticColor?: 'white' | 'black',
|
|
43
|
+
staticColor?: 'white' | 'black' | 'auto',
|
|
44
44
|
/**
|
|
45
45
|
* The label's overall position relative to the element it is labeling.
|
|
46
46
|
* @default 'top'
|
|
@@ -77,7 +77,7 @@ const trackStyles = style({
|
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
const fillStyles = style<MeterStyleProps>({
|
|
80
|
+
const fillStyles = style<MeterStyleProps & {isStaticColor: boolean}>({
|
|
81
81
|
height: 'full',
|
|
82
82
|
borderStyle: 'none',
|
|
83
83
|
borderRadius: 'full',
|
|
@@ -88,15 +88,7 @@ const fillStyles = style<MeterStyleProps>({
|
|
|
88
88
|
notice: lightDark('notice-800', 'notice-900'), // 'notice-visual',
|
|
89
89
|
negative: lightDark('negative-800', 'negative-900') // 'negative-visual'
|
|
90
90
|
},
|
|
91
|
-
|
|
92
|
-
white: {
|
|
93
|
-
default: 'transparent-white-900'
|
|
94
|
-
},
|
|
95
|
-
// TODO: Is there a black static color in S2?
|
|
96
|
-
black: {
|
|
97
|
-
default: 'transparent-black-900'
|
|
98
|
-
}
|
|
99
|
-
},
|
|
91
|
+
isStaticColor: 'transparent-overlay-900',
|
|
100
92
|
forcedColors: 'ButtonText'
|
|
101
93
|
}
|
|
102
94
|
});
|
|
@@ -120,6 +112,7 @@ export const Meter = forwardRef(function Meter(props: MeterProps, ref: DOMRef<HT
|
|
|
120
112
|
labelPosition = 'top',
|
|
121
113
|
...groupProps
|
|
122
114
|
} = props;
|
|
115
|
+
let isStaticColor = !!staticColor;
|
|
123
116
|
|
|
124
117
|
return (
|
|
125
118
|
<AriaMeter
|
|
@@ -135,10 +128,10 @@ export const Meter = forwardRef(function Meter(props: MeterProps, ref: DOMRef<HT
|
|
|
135
128
|
{({percentage, valueText}) => (
|
|
136
129
|
<>
|
|
137
130
|
{label && <FieldLabel size={size} labelAlign="start" labelPosition={labelPosition} staticColor={staticColor}>{label}</FieldLabel>}
|
|
138
|
-
{label && <Text styles={valueStyles({size, labelAlign: 'end',
|
|
131
|
+
{label && <Text styles={valueStyles({size, labelAlign: 'end', isStaticColor})}>{valueText}</Text>}
|
|
139
132
|
<SkeletonWrapper>
|
|
140
|
-
<div className={trackStyles({
|
|
141
|
-
<div className={fillStyles({
|
|
133
|
+
<div className={trackStyles({isStaticColor, size})}>
|
|
134
|
+
<div className={fillStyles({isStaticColor, variant})} style={{width: percentage + '%'}} />
|
|
142
135
|
</div>
|
|
143
136
|
</SkeletonWrapper>
|
|
144
137
|
</>
|
package/src/ProgressBar.tsx
CHANGED
|
@@ -41,7 +41,7 @@ interface ProgressBarStyleProps {
|
|
|
41
41
|
/**
|
|
42
42
|
* The static color style to apply. Useful when the button appears over a color background.
|
|
43
43
|
*/
|
|
44
|
-
staticColor?: 'white' | 'black',
|
|
44
|
+
staticColor?: 'white' | 'black' | 'auto',
|
|
45
45
|
/**
|
|
46
46
|
* The label's overall position relative to the element it is labeling.
|
|
47
47
|
* @default 'top'
|
|
@@ -135,21 +135,13 @@ const trackStyles = style({
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
-
const fill = style<ProgressBarStyleProps>({
|
|
138
|
+
const fill = style<ProgressBarStyleProps & {isStaticColor: boolean}>({
|
|
139
139
|
height: 'full',
|
|
140
140
|
borderStyle: 'none',
|
|
141
141
|
borderRadius: 'full',
|
|
142
142
|
backgroundColor: {
|
|
143
143
|
default: 'accent',
|
|
144
|
-
|
|
145
|
-
white: {
|
|
146
|
-
default: 'transparent-white-900'
|
|
147
|
-
},
|
|
148
|
-
// TODO: Is there a black static color in S2?
|
|
149
|
-
black: {
|
|
150
|
-
default: 'transparent-black-900'
|
|
151
|
-
}
|
|
152
|
-
},
|
|
144
|
+
isStaticColor: 'transparent-overlay-900',
|
|
153
145
|
forcedColors: 'ButtonText'
|
|
154
146
|
},
|
|
155
147
|
width: {
|
|
@@ -190,20 +182,21 @@ export const ProgressBar = /*#__PURE__*/ forwardRef(function ProgressBar(props:
|
|
|
190
182
|
} = props;
|
|
191
183
|
let domRef = useDOMRef(ref);
|
|
192
184
|
let {direction} = useLocale();
|
|
185
|
+
let isStaticColor = !!staticColor;
|
|
193
186
|
|
|
194
187
|
return (
|
|
195
188
|
<AriaProgressBar
|
|
196
189
|
{...props}
|
|
197
190
|
ref={domRef}
|
|
198
191
|
style={UNSAFE_style}
|
|
199
|
-
className={UNSAFE_className + wrapper({...props, size, labelPosition}, props.styles)}>
|
|
192
|
+
className={UNSAFE_className + wrapper({...props, size, labelPosition, staticColor}, props.styles)}>
|
|
200
193
|
{({percentage, valueText}) => (
|
|
201
194
|
<>
|
|
202
195
|
{label && <FieldLabel size={size} labelAlign="start" labelPosition={labelPosition} staticColor={staticColor}>{label}</FieldLabel>}
|
|
203
|
-
{label && !isIndeterminate && <span className={valueStyles({size, labelAlign: 'end',
|
|
204
|
-
<div className={trackStyles({
|
|
196
|
+
{label && !isIndeterminate && <span className={valueStyles({size, labelAlign: 'end', isStaticColor})}>{valueText}</span>}
|
|
197
|
+
<div className={trackStyles({isStaticColor, size})}>
|
|
205
198
|
<div
|
|
206
|
-
className={mergeStyles(fill({...props,
|
|
199
|
+
className={mergeStyles(fill({...props, isStaticColor}), (isIndeterminate ? indeterminateAnimation({direction}) : null))}
|
|
207
200
|
style={{width: isIndeterminate ? undefined : percentage + '%'}} />
|
|
208
201
|
</div>
|
|
209
202
|
</>
|
package/src/ProgressCircle.tsx
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import {ContextValue, ProgressBar as RACProgressBar, ProgressBarProps as RACProgressBarProps} from 'react-aria-components';
|
|
14
14
|
import {createContext, forwardRef} from 'react';
|
|
15
15
|
import {DOMRef, DOMRefValue} from '@react-types/shared';
|
|
16
|
-
import {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};
|
|
16
|
+
import {getAllowedOverrides, staticColor, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};
|
|
17
17
|
import {keyframes} from '../style/style-macro' with {type: 'macro'};
|
|
18
18
|
import {style} from '../style' with {type: 'macro'};
|
|
19
19
|
import {useDOMRef} from '@react-spectrum/utils';
|
|
@@ -27,7 +27,7 @@ export interface ProgressCircleStyleProps {
|
|
|
27
27
|
*/
|
|
28
28
|
size?: 'S' | 'M' | 'L',
|
|
29
29
|
/** The static color style to apply. Useful when the button appears over a color background. */
|
|
30
|
-
staticColor?: 'black' | 'white',
|
|
30
|
+
staticColor?: 'black' | 'white' | 'auto',
|
|
31
31
|
/**
|
|
32
32
|
* Whether presentation is indeterminate when progress isn't known.
|
|
33
33
|
*/
|
|
@@ -38,6 +38,7 @@ export const ProgressCircleContext = createContext<ContextValue<ProgressCirclePr
|
|
|
38
38
|
|
|
39
39
|
// Double check the types passed to each style, may not need all for each
|
|
40
40
|
const wrapper = style<ProgressCircleStyleProps>({
|
|
41
|
+
...staticColor(),
|
|
41
42
|
size: {
|
|
42
43
|
default: 32,
|
|
43
44
|
size: {
|
|
@@ -48,24 +49,18 @@ const wrapper = style<ProgressCircleStyleProps>({
|
|
|
48
49
|
aspectRatio: 'square'
|
|
49
50
|
}, getAllowedOverrides({height: true}));
|
|
50
51
|
|
|
51
|
-
const track = style
|
|
52
|
+
const track = style({
|
|
52
53
|
stroke: {
|
|
53
54
|
default: 'gray-300',
|
|
54
|
-
|
|
55
|
-
white: 'transparent-white-300',
|
|
56
|
-
black: 'transparent-black-300'
|
|
57
|
-
},
|
|
55
|
+
isStaticColor: 'transparent-overlay-300',
|
|
58
56
|
forcedColors: 'Background'
|
|
59
57
|
}
|
|
60
58
|
});
|
|
61
59
|
|
|
62
|
-
const fill = style
|
|
60
|
+
const fill = style({
|
|
63
61
|
stroke: {
|
|
64
62
|
default: 'blue-900',
|
|
65
|
-
|
|
66
|
-
white: 'transparent-white-900',
|
|
67
|
-
black: 'transparent-black-900'
|
|
68
|
-
},
|
|
63
|
+
isStaticColor: 'transparent-overlay-900',
|
|
69
64
|
forcedColors: 'Highlight'
|
|
70
65
|
},
|
|
71
66
|
rotate: -90,
|
|
@@ -121,6 +116,7 @@ export const ProgressCircle = /*#__PURE__*/ forwardRef(function ProgressCircle(p
|
|
|
121
116
|
|
|
122
117
|
// SVG strokes are centered, so subtract half the stroke width from the radius to create an inner stroke.
|
|
123
118
|
let radius = `calc(50% - ${strokeWidth / 2}px)`;
|
|
119
|
+
let isStaticColor = !!staticColor;
|
|
124
120
|
|
|
125
121
|
return (
|
|
126
122
|
<RACProgressBar
|
|
@@ -129,7 +125,8 @@ export const ProgressCircle = /*#__PURE__*/ forwardRef(function ProgressCircle(p
|
|
|
129
125
|
style={UNSAFE_style}
|
|
130
126
|
className={renderProps => UNSAFE_className + wrapper({
|
|
131
127
|
...renderProps,
|
|
132
|
-
size
|
|
128
|
+
size,
|
|
129
|
+
staticColor
|
|
133
130
|
}, props.styles)}>
|
|
134
131
|
{({percentage, isIndeterminate}) => (
|
|
135
132
|
<svg
|
|
@@ -141,13 +138,13 @@ export const ProgressCircle = /*#__PURE__*/ forwardRef(function ProgressCircle(p
|
|
|
141
138
|
cy="50%"
|
|
142
139
|
r={radius}
|
|
143
140
|
strokeWidth={strokeWidth}
|
|
144
|
-
className={track({
|
|
141
|
+
className={track({isStaticColor})} />
|
|
145
142
|
<circle
|
|
146
143
|
cx="50%"
|
|
147
144
|
cy="50%"
|
|
148
145
|
r={radius}
|
|
149
146
|
strokeWidth={strokeWidth}
|
|
150
|
-
className={fill({
|
|
147
|
+
className={fill({isStaticColor})}
|
|
151
148
|
style={{
|
|
152
149
|
// These cubic-bezier timing functions were derived from the previous animation keyframes
|
|
153
150
|
// using a best fit algorithm, and then manually adjusted to approximate the original animation.
|
package/src/ToggleButton.tsx
CHANGED