@primer/components 31.2.1-rc.48ecca6e → 31.2.1-rc.f73a0f8c
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/CHANGELOG.md +2 -0
- package/dist/browser.esm.js +194 -190
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +204 -200
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.js +27 -52
- package/lib/ActionList/Item.jsx +17 -40
- package/lib/utils/testing.d.ts +6 -60
- package/lib-esm/ActionList/Item.js +28 -53
- package/lib-esm/theme-preval.js +66 -366
- package/lib-esm/utils/testing.d.ts +6 -60
- package/package-lock.json +7 -7
- package/package.json +2 -2
- package/src/ActionList/Item.tsx +17 -46
- package/src/__tests__/__snapshots__/ActionList.test.tsx.snap +5 -5
- package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +25 -25
- package/stats.html +1 -1
package/src/ActionList/Item.tsx
CHANGED
@@ -7,7 +7,7 @@ import {ItemInput} from './List'
|
|
7
7
|
import styled from 'styled-components'
|
8
8
|
import {StyledHeader} from './Header'
|
9
9
|
import {StyledDivider} from './Divider'
|
10
|
-
import {
|
10
|
+
import {useTheme} from '../ThemeProvider'
|
11
11
|
import {
|
12
12
|
activeDescendantActivatedDirectly,
|
13
13
|
activeDescendantActivatedIndirectly,
|
@@ -17,36 +17,6 @@ import {useSSRSafeId} from '@react-aria/ssr'
|
|
17
17
|
import {ForwardRefComponent as PolymorphicForwardRefComponent} from '@radix-ui/react-polymorphic'
|
18
18
|
import {AriaRole} from '../utils/types'
|
19
19
|
|
20
|
-
/**
|
21
|
-
* These colors are not yet in our default theme. Need to remove this once they are added.
|
22
|
-
*/
|
23
|
-
const customItemThemes = {
|
24
|
-
default: {
|
25
|
-
hover: {
|
26
|
-
light: 'rgba(46, 77, 108, 0.06)',
|
27
|
-
dark: 'rgba(201, 206, 212, 0.12)',
|
28
|
-
dark_dimmed: 'rgba(201, 206, 212, 0.12)'
|
29
|
-
},
|
30
|
-
focus: {
|
31
|
-
light: 'rgba(54, 77, 100, 0.16)',
|
32
|
-
dark: 'rgba(201, 206, 212, 0.24)',
|
33
|
-
dark_dimmed: 'rgba(201, 206, 212, 0.24)'
|
34
|
-
}
|
35
|
-
},
|
36
|
-
danger: {
|
37
|
-
hover: {
|
38
|
-
light: 'rgba(234, 74, 90, 0.08)',
|
39
|
-
dark: 'rgba(248, 81, 73, 0.16)',
|
40
|
-
dark_dimmed: 'rgba(248, 81, 73, 0.16)'
|
41
|
-
},
|
42
|
-
focus: {
|
43
|
-
light: 'rgba(234, 74, 90, 0.14)',
|
44
|
-
dark: 'rgba(248, 81, 73, 0.24)',
|
45
|
-
dark_dimmed: 'rgba(248, 81, 73, 0.24)'
|
46
|
-
}
|
47
|
-
}
|
48
|
-
} as const
|
49
|
-
|
50
20
|
/**
|
51
21
|
* Contract for props passed to the `Item` component.
|
52
22
|
*/
|
@@ -166,14 +136,19 @@ const getItemVariant = (variant = 'default', disabled?: boolean) => {
|
|
166
136
|
color: get('colors.danger.fg'),
|
167
137
|
iconColor: get('colors.danger.fg'),
|
168
138
|
annotationColor: get('colors.fg.muted'),
|
169
|
-
hoverCursor: 'pointer'
|
139
|
+
hoverCursor: 'pointer',
|
140
|
+
hoverBg: get('colors.actionListItem.danger.hoverBg'),
|
141
|
+
focusBg: get('colors.actionListItem.danger.activeBg'),
|
142
|
+
hoverText: get('colors.actionListItem.danger.hoverText')
|
170
143
|
}
|
171
144
|
default:
|
172
145
|
return {
|
173
146
|
color: get('colors.fg.default'),
|
174
147
|
iconColor: get('colors.fg.muted'),
|
175
148
|
annotationColor: get('colors.fg.muted'),
|
176
|
-
hoverCursor: 'pointer'
|
149
|
+
hoverCursor: 'pointer',
|
150
|
+
hoverBg: get('colors.actionListItem.default.hoverBg'),
|
151
|
+
focusBg: get('colors.actionListItem.default.activeBg')
|
177
152
|
}
|
178
153
|
}
|
179
154
|
}
|
@@ -200,8 +175,6 @@ const StyledItem = styled.div<
|
|
200
175
|
variant: ItemProps['variant']
|
201
176
|
showDivider: ItemProps['showDivider']
|
202
177
|
item?: ItemInput
|
203
|
-
hoverBackground: string
|
204
|
-
focusBackground: string
|
205
178
|
} & SxProp
|
206
179
|
>`
|
207
180
|
/* 6px vertical padding + 20px line height = 32px total height
|
@@ -220,7 +193,11 @@ const StyledItem = styled.div<
|
|
220
193
|
@media (hover: hover) and (pointer: fine) {
|
221
194
|
:hover {
|
222
195
|
// allow override in case another item in the list is active/focused
|
223
|
-
background: var(
|
196
|
+
background: var(
|
197
|
+
--item-hover-bg-override,
|
198
|
+
${({variant, item}) => getItemVariant(variant, item?.disabled).hoverBg}
|
199
|
+
);
|
200
|
+
color: ${({variant, item}) => getItemVariant(variant, item?.disabled).hoverText};
|
224
201
|
cursor: ${({variant, item}) => getItemVariant(variant, item?.disabled).hoverCursor};
|
225
202
|
}
|
226
203
|
}
|
@@ -266,19 +243,19 @@ const StyledItem = styled.div<
|
|
266
243
|
|
267
244
|
// Active Descendant
|
268
245
|
&[${isActiveDescendantAttribute}='${activeDescendantActivatedDirectly}'] {
|
269
|
-
background: ${({
|
246
|
+
background: ${({variant, item}) => getItemVariant(variant, item?.disabled).focusBg};
|
270
247
|
}
|
271
248
|
&[${isActiveDescendantAttribute}='${activeDescendantActivatedIndirectly}'] {
|
272
|
-
background: ${({
|
249
|
+
background: ${({variant, item}) => getItemVariant(variant, item?.disabled).hoverBg};
|
273
250
|
}
|
274
251
|
|
275
252
|
&:focus {
|
276
|
-
background: ${({
|
253
|
+
background: ${({variant, item}) => getItemVariant(variant, item?.disabled).focusBg};
|
277
254
|
outline: none;
|
278
255
|
}
|
279
256
|
|
280
257
|
&:active {
|
281
|
-
background: ${({
|
258
|
+
background: ${({variant, item}) => getItemVariant(variant, item?.disabled).focusBg};
|
282
259
|
}
|
283
260
|
|
284
261
|
${sx}
|
@@ -404,10 +381,6 @@ export const Item = React.forwardRef((itemProps, ref) => {
|
|
404
381
|
[onAction, disabled, itemProps, onClick]
|
405
382
|
)
|
406
383
|
|
407
|
-
const customItemTheme = customItemThemes[variant]
|
408
|
-
const hoverBackground = useColorSchemeVar(customItemTheme.hover, 'inherit')
|
409
|
-
const focusBackground = useColorSchemeVar(customItemTheme.focus, 'inherit')
|
410
|
-
|
411
384
|
const {theme} = useTheme()
|
412
385
|
|
413
386
|
return (
|
@@ -424,8 +397,6 @@ export const Item = React.forwardRef((itemProps, ref) => {
|
|
424
397
|
data-id={id}
|
425
398
|
onKeyPress={keyPressHandler}
|
426
399
|
onClick={clickHandler}
|
427
|
-
hoverBackground={disabled ? 'inherit' : hoverBackground}
|
428
|
-
focusBackground={disabled ? 'inherit' : focusBackground}
|
429
400
|
>
|
430
401
|
{!!selected === selected && (
|
431
402
|
<BaseVisualContainer>
|
@@ -178,25 +178,25 @@ exports[`ActionList.Item renders consistently 1`] = `
|
|
178
178
|
}
|
179
179
|
|
180
180
|
.c1[data-is-active-descendant='activated-directly'] {
|
181
|
-
background: rgba(
|
181
|
+
background: rgba(208,215,222,0.48);
|
182
182
|
}
|
183
183
|
|
184
184
|
.c1[data-is-active-descendant='activated-indirectly'] {
|
185
|
-
background: rgba(
|
185
|
+
background: rgba(208,215,222,0.32);
|
186
186
|
}
|
187
187
|
|
188
188
|
.c1:focus {
|
189
|
-
background: rgba(
|
189
|
+
background: rgba(208,215,222,0.48);
|
190
190
|
outline: none;
|
191
191
|
}
|
192
192
|
|
193
193
|
.c1:active {
|
194
|
-
background: rgba(
|
194
|
+
background: rgba(208,215,222,0.48);
|
195
195
|
}
|
196
196
|
|
197
197
|
@media (hover:hover) and (pointer:fine) {
|
198
198
|
.c1:hover {
|
199
|
-
background: var(--item-hover-bg-override,rgba(
|
199
|
+
background: var( --item-hover-bg-override,rgba(208,215,222,0.32) );
|
200
200
|
cursor: pointer;
|
201
201
|
}
|
202
202
|
}
|
@@ -436,20 +436,20 @@ Array [
|
|
436
436
|
}
|
437
437
|
|
438
438
|
.c4[data-is-active-descendant='activated-directly'] {
|
439
|
-
background: rgba(
|
439
|
+
background: rgba(208,215,222,0.48);
|
440
440
|
}
|
441
441
|
|
442
442
|
.c4[data-is-active-descendant='activated-indirectly'] {
|
443
|
-
background: rgba(
|
443
|
+
background: rgba(208,215,222,0.32);
|
444
444
|
}
|
445
445
|
|
446
446
|
.c4:focus {
|
447
|
-
background: rgba(
|
447
|
+
background: rgba(208,215,222,0.48);
|
448
448
|
outline: none;
|
449
449
|
}
|
450
450
|
|
451
451
|
.c4:active {
|
452
|
-
background: rgba(
|
452
|
+
background: rgba(208,215,222,0.48);
|
453
453
|
}
|
454
454
|
|
455
455
|
.c5 {
|
@@ -530,7 +530,7 @@ Array [
|
|
530
530
|
|
531
531
|
@media (hover:hover) and (pointer:fine) {
|
532
532
|
.c4:hover {
|
533
|
-
background: var(--item-hover-bg-override,rgba(
|
533
|
+
background: var( --item-hover-bg-override,rgba(208,215,222,0.32) );
|
534
534
|
cursor: pointer;
|
535
535
|
}
|
536
536
|
}
|
@@ -1343,20 +1343,20 @@ Array [
|
|
1343
1343
|
}
|
1344
1344
|
|
1345
1345
|
.c4[data-is-active-descendant='activated-directly'] {
|
1346
|
-
background: rgba(
|
1346
|
+
background: rgba(208,215,222,0.48);
|
1347
1347
|
}
|
1348
1348
|
|
1349
1349
|
.c4[data-is-active-descendant='activated-indirectly'] {
|
1350
|
-
background: rgba(
|
1350
|
+
background: rgba(208,215,222,0.32);
|
1351
1351
|
}
|
1352
1352
|
|
1353
1353
|
.c4:focus {
|
1354
|
-
background: rgba(
|
1354
|
+
background: rgba(208,215,222,0.48);
|
1355
1355
|
outline: none;
|
1356
1356
|
}
|
1357
1357
|
|
1358
1358
|
.c4:active {
|
1359
|
-
background: rgba(
|
1359
|
+
background: rgba(208,215,222,0.48);
|
1360
1360
|
}
|
1361
1361
|
|
1362
1362
|
.c5 {
|
@@ -1400,7 +1400,7 @@ Array [
|
|
1400
1400
|
|
1401
1401
|
@media (hover:hover) and (pointer:fine) {
|
1402
1402
|
.c4:hover {
|
1403
|
-
background: var(--item-hover-bg-override,rgba(
|
1403
|
+
background: var( --item-hover-bg-override,rgba(208,215,222,0.32) );
|
1404
1404
|
cursor: pointer;
|
1405
1405
|
}
|
1406
1406
|
}
|
@@ -2160,20 +2160,20 @@ Array [
|
|
2160
2160
|
}
|
2161
2161
|
|
2162
2162
|
.c4[data-is-active-descendant='activated-directly'] {
|
2163
|
-
background: rgba(
|
2163
|
+
background: rgba(208,215,222,0.48);
|
2164
2164
|
}
|
2165
2165
|
|
2166
2166
|
.c4[data-is-active-descendant='activated-indirectly'] {
|
2167
|
-
background: rgba(
|
2167
|
+
background: rgba(208,215,222,0.32);
|
2168
2168
|
}
|
2169
2169
|
|
2170
2170
|
.c4:focus {
|
2171
|
-
background: rgba(
|
2171
|
+
background: rgba(208,215,222,0.48);
|
2172
2172
|
outline: none;
|
2173
2173
|
}
|
2174
2174
|
|
2175
2175
|
.c4:active {
|
2176
|
-
background: rgba(
|
2176
|
+
background: rgba(208,215,222,0.48);
|
2177
2177
|
}
|
2178
2178
|
|
2179
2179
|
.c5 {
|
@@ -2227,7 +2227,7 @@ Array [
|
|
2227
2227
|
|
2228
2228
|
@media (hover:hover) and (pointer:fine) {
|
2229
2229
|
.c4:hover {
|
2230
|
-
background: var(--item-hover-bg-override,rgba(
|
2230
|
+
background: var( --item-hover-bg-override,rgba(208,215,222,0.32) );
|
2231
2231
|
cursor: pointer;
|
2232
2232
|
}
|
2233
2233
|
}
|
@@ -2987,20 +2987,20 @@ Array [
|
|
2987
2987
|
}
|
2988
2988
|
|
2989
2989
|
.c4[data-is-active-descendant='activated-directly'] {
|
2990
|
-
background: rgba(
|
2990
|
+
background: rgba(208,215,222,0.48);
|
2991
2991
|
}
|
2992
2992
|
|
2993
2993
|
.c4[data-is-active-descendant='activated-indirectly'] {
|
2994
|
-
background: rgba(
|
2994
|
+
background: rgba(208,215,222,0.32);
|
2995
2995
|
}
|
2996
2996
|
|
2997
2997
|
.c4:focus {
|
2998
|
-
background: rgba(
|
2998
|
+
background: rgba(208,215,222,0.48);
|
2999
2999
|
outline: none;
|
3000
3000
|
}
|
3001
3001
|
|
3002
3002
|
.c4:active {
|
3003
|
-
background: rgba(
|
3003
|
+
background: rgba(208,215,222,0.48);
|
3004
3004
|
}
|
3005
3005
|
|
3006
3006
|
.c1 {
|
@@ -3016,7 +3016,7 @@ Array [
|
|
3016
3016
|
|
3017
3017
|
@media (hover:hover) and (pointer:fine) {
|
3018
3018
|
.c4:hover {
|
3019
|
-
background: var(--item-hover-bg-override,rgba(
|
3019
|
+
background: var( --item-hover-bg-override,rgba(208,215,222,0.32) );
|
3020
3020
|
cursor: pointer;
|
3021
3021
|
}
|
3022
3022
|
}
|
@@ -3430,20 +3430,20 @@ Array [
|
|
3430
3430
|
}
|
3431
3431
|
|
3432
3432
|
.c4[data-is-active-descendant='activated-directly'] {
|
3433
|
-
background: rgba(
|
3433
|
+
background: rgba(208,215,222,0.48);
|
3434
3434
|
}
|
3435
3435
|
|
3436
3436
|
.c4[data-is-active-descendant='activated-indirectly'] {
|
3437
|
-
background: rgba(
|
3437
|
+
background: rgba(208,215,222,0.32);
|
3438
3438
|
}
|
3439
3439
|
|
3440
3440
|
.c4:focus {
|
3441
|
-
background: rgba(
|
3441
|
+
background: rgba(208,215,222,0.48);
|
3442
3442
|
outline: none;
|
3443
3443
|
}
|
3444
3444
|
|
3445
3445
|
.c4:active {
|
3446
|
-
background: rgba(
|
3446
|
+
background: rgba(208,215,222,0.48);
|
3447
3447
|
}
|
3448
3448
|
|
3449
3449
|
.c1 {
|
@@ -3459,7 +3459,7 @@ Array [
|
|
3459
3459
|
|
3460
3460
|
@media (hover:hover) and (pointer:fine) {
|
3461
3461
|
.c4:hover {
|
3462
|
-
background: var(--item-hover-bg-override,rgba(
|
3462
|
+
background: var( --item-hover-bg-override,rgba(208,215,222,0.32) );
|
3463
3463
|
cursor: pointer;
|
3464
3464
|
}
|
3465
3465
|
}
|