@primer/components 31.0.0-rc.f601fc1f → 31.0.2-rc.1e80de40
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/.github/workflows/check_for_changeset.yml +25 -0
- package/CHANGELOG.md +14 -2
- package/dist/browser.esm.js +40 -37
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +34 -31
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/Autocomplete.mdx +51 -21
- package/lib/ActionList/Item.js +3 -3
- package/lib/Button/Button.js +1 -1
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/Pagination/Pagination.js +1 -1
- package/lib/TextInputWithTokens.js +17 -10
- package/lib/Token/Token.js +13 -2
- package/lib/Token/TokenBase.js +0 -4
- package/lib/Token/_RemoveTokenButton.js +15 -2
- package/lib/_TextInputWrapper.js +1 -1
- package/lib/stories/Autocomplete.stories.js +67 -56
- package/lib/stories/Button.stories.js +12 -1
- package/lib/stories/useAnchoredPosition.stories.js +1 -1
- package/lib-esm/ActionList/Item.js +3 -3
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonTableList.js +1 -1
- package/lib-esm/Pagination/Pagination.js +1 -1
- package/lib-esm/TextInputWithTokens.js +17 -10
- package/lib-esm/Token/Token.js +13 -2
- package/lib-esm/Token/TokenBase.js +0 -4
- package/lib-esm/Token/_RemoveTokenButton.js +11 -2
- package/lib-esm/_TextInputWrapper.js +1 -1
- package/lib-esm/stories/Autocomplete.stories.js +67 -56
- package/lib-esm/stories/Button.stories.js +8 -0
- package/lib-esm/stories/useAnchoredPosition.stories.js +1 -1
- package/package-lock.json +6090 -7003
- package/package.json +6 -6
- package/src/ActionList/Item.tsx +3 -3
- package/src/Button/Button.tsx +1 -1
- package/src/Button/ButtonTableList.tsx +1 -1
- package/src/Pagination/Pagination.tsx +1 -1
- package/src/TextInputWithTokens.tsx +49 -40
- package/src/Token/Token.tsx +16 -2
- package/src/Token/TokenBase.tsx +0 -5
- package/src/Token/_RemoveTokenButton.tsx +15 -2
- package/src/_TextInputWrapper.tsx +1 -1
- package/src/__tests__/Pagination/__snapshots__/Pagination.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/ActionMenu.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +3 -3
- package/src/__tests__/__snapshots__/Button.test.tsx.snap +3 -3
- package/src/__tests__/__snapshots__/ConfirmationDialog.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/Dropdown.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/DropdownMenu.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/SelectMenu.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/SelectPanel.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +3374 -3166
- package/src/__tests__/__snapshots__/Token.test.tsx.snap +31 -24
- package/src/stories/Autocomplete.stories.tsx +142 -59
- package/src/stories/Button.stories.tsx +4 -0
- package/src/stories/useAnchoredPosition.stories.tsx +13 -1
- package/stats.html +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/components",
|
3
|
-
"version": "31.0.
|
3
|
+
"version": "31.0.2-rc.1e80de40",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -76,11 +76,11 @@
|
|
76
76
|
"@rollup/plugin-commonjs": "19.0.2",
|
77
77
|
"@rollup/plugin-node-resolve": "13.0.5",
|
78
78
|
"@size-limit/preset-big-lib": "5.0.2",
|
79
|
-
"@storybook/addon-a11y": "6.3.
|
80
|
-
"@storybook/addon-actions": "^6.
|
81
|
-
"@storybook/addon-essentials": "6.
|
82
|
-
"@storybook/addon-links": "^6.
|
83
|
-
"@storybook/react": "6.3.
|
79
|
+
"@storybook/addon-a11y": "6.3.12",
|
80
|
+
"@storybook/addon-actions": "^6.3.12",
|
81
|
+
"@storybook/addon-essentials": "6.3.12",
|
82
|
+
"@storybook/addon-links": "^6.3.12",
|
83
|
+
"@storybook/react": "6.3.12",
|
84
84
|
"@testing-library/dom": "7.31.2",
|
85
85
|
"@testing-library/react": "11.2.7",
|
86
86
|
"@testing-library/react-hooks": "7.0.2",
|
package/src/ActionList/Item.tsx
CHANGED
@@ -153,9 +153,9 @@ export interface ItemProps extends SxProp {
|
|
153
153
|
const getItemVariant = (variant = 'default', disabled?: boolean) => {
|
154
154
|
if (disabled) {
|
155
155
|
return {
|
156
|
-
color: get('colors.fg.
|
157
|
-
iconColor: get('colors.fg.
|
158
|
-
annotationColor: get('colors.fg.
|
156
|
+
color: get('colors.primer.fg.disabled'),
|
157
|
+
iconColor: get('colors.primer.fg.disabled'),
|
158
|
+
annotationColor: get('colors.primer.fg.disabled'),
|
159
159
|
hoverCursor: 'default'
|
160
160
|
}
|
161
161
|
}
|
package/src/Button/Button.tsx
CHANGED
@@ -27,7 +27,7 @@ const Button = styled(ButtonBase)<ButtonBaseProps & ButtonSystemProps & SxProp>`
|
|
27
27
|
}
|
28
28
|
|
29
29
|
&:disabled {
|
30
|
-
color: ${get('colors.fg.
|
30
|
+
color: ${get('colors.primer.fg.disabled')};
|
31
31
|
background-color: ${get('colors.btn.bg')};
|
32
32
|
border-color: ${get('colors.btn.border')};
|
33
33
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, {FocusEventHandler, KeyboardEventHandler, useRef, useState} from 'react'
|
1
|
+
import React, {FocusEventHandler, KeyboardEventHandler, RefObject, useRef, useState} from 'react'
|
2
2
|
import {omit} from '@styled-system/props'
|
3
3
|
import {FocusKeys} from './behaviors/focusZone'
|
4
4
|
import {useCombinedRefs} from './hooks/useCombinedRefs'
|
@@ -184,16 +184,7 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
|
|
184
184
|
minWidth={minWidthProp}
|
185
185
|
maxWidth={maxWidthProp}
|
186
186
|
variant={variantProp}
|
187
|
-
ref={containerRef}
|
188
187
|
sx={{
|
189
|
-
alignItems: 'center',
|
190
|
-
flexWrap: preventTokenWrapping ? 'nowrap' : 'wrap',
|
191
|
-
gap: '0.25rem',
|
192
|
-
|
193
|
-
'> *': {
|
194
|
-
flexShrink: 0
|
195
|
-
},
|
196
|
-
|
197
188
|
...(block
|
198
189
|
? {
|
199
190
|
display: 'flex',
|
@@ -218,40 +209,58 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
|
|
218
209
|
}}
|
219
210
|
>
|
220
211
|
<Box
|
212
|
+
ref={containerRef as RefObject<HTMLDivElement>}
|
213
|
+
display="flex"
|
221
214
|
sx={{
|
222
|
-
|
223
|
-
|
215
|
+
alignItems: 'center',
|
216
|
+
flexWrap: preventTokenWrapping ? 'nowrap' : 'wrap',
|
217
|
+
marginLeft: '-0.25rem',
|
218
|
+
marginBottom: '-0.25rem',
|
219
|
+
flexGrow: 1,
|
220
|
+
|
221
|
+
'> *': {
|
222
|
+
flexShrink: 0,
|
223
|
+
marginLeft: '0.25rem',
|
224
|
+
marginBottom: '0.25rem'
|
225
|
+
}
|
224
226
|
}}
|
225
227
|
>
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
228
|
+
<Box
|
229
|
+
sx={{
|
230
|
+
order: 1,
|
231
|
+
flexGrow: 1
|
232
|
+
}}
|
233
|
+
>
|
234
|
+
{IconComponent && <IconComponent className="TextInput-icon" />}
|
235
|
+
<UnstyledTextInput
|
236
|
+
ref={combinedInputRef}
|
237
|
+
disabled={disabled}
|
238
|
+
onFocus={handleInputFocus}
|
239
|
+
onKeyDown={handleInputKeyDown}
|
240
|
+
type="text"
|
241
|
+
sx={{height: '100%'}}
|
242
|
+
{...inputPropsRest}
|
243
|
+
/>
|
244
|
+
</Box>
|
245
|
+
{tokens.length && TokenComponent
|
246
|
+
? tokens.map(({id, ...tokenRest}, i) => (
|
247
|
+
<TokenComponent
|
248
|
+
key={id}
|
249
|
+
onFocus={handleTokenFocus(i)}
|
250
|
+
onBlur={handleTokenBlur}
|
251
|
+
onKeyUp={handleTokenKeyUp}
|
252
|
+
isSelected={selectedTokenIndex === i}
|
253
|
+
onRemove={() => {
|
254
|
+
handleTokenRemove(id)
|
255
|
+
}}
|
256
|
+
hideRemoveButton={hideTokenRemoveButtons}
|
257
|
+
size={size}
|
258
|
+
tabIndex={0}
|
259
|
+
{...tokenRest}
|
260
|
+
/>
|
261
|
+
))
|
262
|
+
: null}
|
236
263
|
</Box>
|
237
|
-
{tokens.length && TokenComponent
|
238
|
-
? tokens.map(({id, ...tokenRest}, i) => (
|
239
|
-
<TokenComponent
|
240
|
-
key={id}
|
241
|
-
onFocus={handleTokenFocus(i)}
|
242
|
-
onBlur={handleTokenBlur}
|
243
|
-
onKeyUp={handleTokenKeyUp}
|
244
|
-
isSelected={selectedTokenIndex === i}
|
245
|
-
onRemove={() => {
|
246
|
-
handleTokenRemove(id)
|
247
|
-
}}
|
248
|
-
hideRemoveButton={hideTokenRemoveButtons}
|
249
|
-
size={size}
|
250
|
-
tabIndex={0}
|
251
|
-
{...tokenRest}
|
252
|
-
/>
|
253
|
-
))
|
254
|
-
: null}
|
255
264
|
</TextInputWrapper>
|
256
265
|
)
|
257
266
|
}
|
package/src/Token/Token.tsx
CHANGED
@@ -44,9 +44,23 @@ const DefaultTokenStyled = styled(TokenBase)<TokenProps & {isTokenInteractive: b
|
|
44
44
|
}}
|
45
45
|
`
|
46
46
|
|
47
|
-
const LeadingVisualContainer = styled('span')
|
47
|
+
const LeadingVisualContainer = styled('span')<Pick<TokenBaseProps, 'size'>>`
|
48
48
|
flex-shrink: 0;
|
49
49
|
line-height: 0;
|
50
|
+
|
51
|
+
${props => {
|
52
|
+
switch (props.size) {
|
53
|
+
case 'large':
|
54
|
+
case 'extralarge':
|
55
|
+
return css`
|
56
|
+
margin-right: ${get('space.2')};
|
57
|
+
`
|
58
|
+
default:
|
59
|
+
return css`
|
60
|
+
margin-right: ${get('space.1')};
|
61
|
+
`
|
62
|
+
}
|
63
|
+
}}
|
50
64
|
`
|
51
65
|
|
52
66
|
const Token = forwardRef<HTMLAnchorElement | HTMLButtonElement | HTMLSpanElement, TokenProps & SxProp>(
|
@@ -76,7 +90,7 @@ const Token = forwardRef<HTMLAnchorElement | HTMLButtonElement | HTMLSpanElement
|
|
76
90
|
ref={forwardedRef}
|
77
91
|
>
|
78
92
|
{LeadingVisual ? (
|
79
|
-
<LeadingVisualContainer>
|
93
|
+
<LeadingVisualContainer size={size}>
|
80
94
|
<LeadingVisual />
|
81
95
|
</LeadingVisualContainer>
|
82
96
|
) : null}
|
package/src/Token/TokenBase.tsx
CHANGED
@@ -48,7 +48,6 @@ const variants = variant<
|
|
48
48
|
fontSize: number
|
49
49
|
height: string
|
50
50
|
lineHeight: string
|
51
|
-
gap: number
|
52
51
|
paddingLeft: number
|
53
52
|
paddingRight: number
|
54
53
|
paddingTop: number
|
@@ -60,7 +59,6 @@ const variants = variant<
|
|
60
59
|
variants: {
|
61
60
|
small: {
|
62
61
|
fontSize: 0,
|
63
|
-
gap: 1,
|
64
62
|
height: tokenSizes.small,
|
65
63
|
// without setting lineHeight to match height, the "x" appears vertically mis-aligned
|
66
64
|
lineHeight: tokenSizes.small,
|
@@ -73,7 +71,6 @@ const variants = variant<
|
|
73
71
|
},
|
74
72
|
medium: {
|
75
73
|
fontSize: 0,
|
76
|
-
gap: 1,
|
77
74
|
height: tokenSizes.medium,
|
78
75
|
lineHeight: tokenSizes.medium,
|
79
76
|
paddingLeft: 2,
|
@@ -83,7 +80,6 @@ const variants = variant<
|
|
83
80
|
},
|
84
81
|
large: {
|
85
82
|
fontSize: 0,
|
86
|
-
gap: 2,
|
87
83
|
height: tokenSizes.large,
|
88
84
|
lineHeight: tokenSizes.large,
|
89
85
|
paddingLeft: 2,
|
@@ -93,7 +89,6 @@ const variants = variant<
|
|
93
89
|
},
|
94
90
|
extralarge: {
|
95
91
|
fontSize: 1,
|
96
|
-
gap: 2,
|
97
92
|
height: tokenSizes.extralarge,
|
98
93
|
lineHeight: tokenSizes.extralarge,
|
99
94
|
paddingLeft: 3,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import {XIcon} from '@primer/octicons-react'
|
3
|
-
import styled from 'styled-components'
|
3
|
+
import styled, {css} from 'styled-components'
|
4
4
|
import {variant} from 'styled-system'
|
5
5
|
import {get} from '../constants'
|
6
6
|
import sx, {SxProp} from '../sx'
|
@@ -50,11 +50,24 @@ const StyledTokenButton = styled.span<TokenButtonProps & SxProp>`
|
|
50
50
|
text-decoration: none;
|
51
51
|
padding: 0;
|
52
52
|
transform: ${props => `translate(${props.borderOffset}px, -${props.borderOffset}px)`};
|
53
|
-
|
54
53
|
align-self: baseline;
|
55
54
|
border: 0;
|
56
55
|
border-radius: 999px;
|
57
56
|
|
57
|
+
${props => {
|
58
|
+
switch (props.size) {
|
59
|
+
case 'large':
|
60
|
+
case 'extralarge':
|
61
|
+
return css`
|
62
|
+
margin-left: ${get('space.2')};
|
63
|
+
`
|
64
|
+
default:
|
65
|
+
return css`
|
66
|
+
margin-left: ${get('space.1')};
|
67
|
+
`
|
68
|
+
}
|
69
|
+
}}
|
70
|
+
|
58
71
|
&:hover,
|
59
72
|
&:focus {
|
60
73
|
// TODO: choose a better functional color variable for this
|
@@ -79,7 +79,7 @@ const TextInputWrapper = styled.span<StyledWrapperProps>`
|
|
79
79
|
${props =>
|
80
80
|
props.disabled &&
|
81
81
|
css`
|
82
|
-
color: ${get('colors.fg.
|
82
|
+
color: ${get('colors.primer.fg.disabled')};
|
83
83
|
background-color: ${get('colors.input.disabledBg')};
|
84
84
|
border-color: ${get('colors.border.default')};
|
85
85
|
`}
|
@@ -68,7 +68,7 @@ exports[`AnchoredOverlay renders consistently 1`] = `
|
|
68
68
|
}
|
69
69
|
|
70
70
|
.c1:disabled {
|
71
|
-
color: #
|
71
|
+
color: #8c959f;
|
72
72
|
background-color: #f6f8fa;
|
73
73
|
border-color: rgba(27,31,36,0.15);
|
74
74
|
}
|
@@ -163,7 +163,7 @@ Object {
|
|
163
163
|
}
|
164
164
|
|
165
165
|
.c1:disabled {
|
166
|
-
color: #
|
166
|
+
color: #8c959f;
|
167
167
|
background-color: #f6f8fa;
|
168
168
|
border-color: rgba(27,31,36,0.15);
|
169
169
|
}
|
@@ -243,7 +243,7 @@ Object {
|
|
243
243
|
<button
|
244
244
|
aria-haspopup="true"
|
245
245
|
aria-labelledby="react-aria-1"
|
246
|
-
class="ButtonBase-sc-181ps9o-0 Button-xjtz72-0
|
246
|
+
class="ButtonBase-sc-181ps9o-0 Button-xjtz72-0 iRqJHc"
|
247
247
|
id="react-aria-1"
|
248
248
|
tabindex="0"
|
249
249
|
>
|
@@ -62,7 +62,7 @@ exports[`Button renders consistently 1`] = `
|
|
62
62
|
}
|
63
63
|
|
64
64
|
.c0:disabled {
|
65
|
-
color: #
|
65
|
+
color: #8c959f;
|
66
66
|
background-color: #f6f8fa;
|
67
67
|
border-color: rgba(27,31,36,0.15);
|
68
68
|
}
|
@@ -134,7 +134,7 @@ exports[`Button respects the "disabled" prop 1`] = `
|
|
134
134
|
}
|
135
135
|
|
136
136
|
.c0:disabled {
|
137
|
-
color: #
|
137
|
+
color: #8c959f;
|
138
138
|
background-color: #f6f8fa;
|
139
139
|
border-color: rgba(27,31,36,0.15);
|
140
140
|
}
|
@@ -819,7 +819,7 @@ exports[`ButtonTableList renders consistently 1`] = `
|
|
819
819
|
|
820
820
|
.c0:disabled,
|
821
821
|
.c0:disabled:hover {
|
822
|
-
color:
|
822
|
+
color: #8c959f;
|
823
823
|
cursor: default;
|
824
824
|
}
|
825
825
|
|