@primer/components 32.0.2-rc.859381a1 → 32.1.1-rc.b4502a34
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 +13 -1
- package/dist/browser.esm.js +9 -2
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +9 -2
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/ActionList2.mdx +23 -3
- package/docs/content/Avatar.mdx +21 -1
- package/docs/content/AvatarStack.mdx +23 -3
- package/docs/content/BranchName.md +24 -4
- package/docs/content/Breadcrumbs.md +22 -1
- package/docs/content/Buttons.md +2 -1
- package/docs/content/Checkbox.md +118 -0
- package/docs/content/CircleBadge.md +1 -0
- package/docs/content/CircleOcticon.md +2 -1
- package/docs/content/CounterLabel.md +1 -1
- package/docs/content/Details.md +2 -1
- package/docs/content/Dialog.md +1 -0
- package/docs/content/Dialog2.mdx +1 -0
- package/docs/content/Dropdown.md +1 -0
- package/docs/content/DropdownMenu.mdx +1 -0
- package/docs/content/FilterList.md +1 -0
- package/docs/content/FilteredSearch.md +1 -0
- package/docs/content/Flash.md +1 -0
- package/docs/content/FormGroup.md +1 -0
- package/docs/content/Header.md +1 -0
- package/docs/content/Heading.md +8 -4
- package/docs/content/Label.md +1 -0
- package/docs/content/LabelGroup.md +1 -0
- package/docs/content/Link.md +1 -0
- package/docs/content/Overlay.mdx +1 -0
- package/docs/content/Pagehead.md +1 -0
- package/docs/content/Pagination.md +1 -0
- package/docs/content/PointerBox.md +1 -0
- package/docs/content/Popover.md +1 -0
- package/docs/content/Portal.mdx +1 -0
- package/docs/content/Position.md +2 -9
- package/docs/content/ProgressBar.mdx +1 -0
- package/docs/content/SelectMenu.md +1 -0
- package/docs/content/SideNav.md +1 -0
- package/docs/content/StateLabel.md +1 -0
- package/docs/content/StyledOcticon.md +1 -1
- package/docs/content/SubNav.md +1 -0
- package/docs/content/TabNav.md +1 -0
- package/docs/content/Text.md +10 -3
- package/docs/content/TextInput.md +9 -1
- package/docs/content/Timeline.md +1 -0
- package/docs/content/Tooltip.md +1 -0
- package/docs/content/Truncate.md +1 -0
- package/docs/content/UnderlineNav.md +1 -0
- package/docs/content/status.mdx +10 -0
- package/docs/src/@primer/gatsby-theme-doctocat/mdx-components.js +9 -0
- package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +4 -0
- package/docs/src/component-statuses.js +74 -0
- package/lib/ActionList/Item.js +3 -3
- package/lib/ActionList2/Item.js +3 -1
- package/lib/ActionList2/List.js +1 -2
- package/lib/ActionList2/Selection.js +3 -1
- package/lib/Autocomplete/Autocomplete.d.ts +1 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +1 -0
- package/lib/Button/Button.d.ts +1 -0
- package/lib/Button/ButtonClose.d.ts +2 -1
- package/lib/Button/ButtonDanger.d.ts +1 -0
- package/lib/Button/ButtonInvisible.d.ts +1 -0
- package/lib/Button/ButtonOutline.d.ts +1 -0
- package/lib/Button/ButtonPrimary.d.ts +1 -0
- package/lib/Checkbox.d.ts +29 -0
- package/lib/Checkbox.js +64 -0
- package/lib/CircleOcticon.d.ts +1 -0
- package/lib/Dialog.d.ts +3 -2
- package/lib/Dropdown.d.ts +4 -0
- package/lib/DropdownMenu/DropdownButton.d.ts +2 -1
- package/lib/FilterList.d.ts +1 -0
- package/lib/Position.d.ts +4 -4
- package/lib/SelectMenu/SelectMenu.d.ts +10 -4
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +1 -0
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/__tests__/ActionList2.test.d.ts +1 -0
- package/lib/__tests__/ActionList2.test.js +117 -0
- package/lib/__tests__/Checkbox.test.d.ts +2 -0
- package/lib/__tests__/Checkbox.test.js +189 -0
- package/lib/__tests__/themePreval.test.d.ts +1 -0
- package/lib/__tests__/themePreval.test.js +14 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/stories/ActionList2.stories.js +20 -6
- package/lib/stories/Checkbox.stories.js +227 -0
- package/lib/utils/testing.d.ts +1 -0
- package/lib/utils/testing.js +29 -0
- package/lib-esm/ActionList/Item.js +3 -3
- package/lib-esm/ActionList2/Item.js +3 -1
- package/lib-esm/ActionList2/List.js +1 -2
- package/lib-esm/ActionList2/Selection.js +3 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +1 -0
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -0
- package/lib-esm/Button/Button.d.ts +1 -0
- package/lib-esm/Button/ButtonClose.d.ts +2 -1
- package/lib-esm/Button/ButtonDanger.d.ts +1 -0
- package/lib-esm/Button/ButtonInvisible.d.ts +1 -0
- package/lib-esm/Button/ButtonOutline.d.ts +1 -0
- package/lib-esm/Button/ButtonPrimary.d.ts +1 -0
- package/lib-esm/Checkbox.d.ts +29 -0
- package/lib-esm/Checkbox.js +44 -0
- package/lib-esm/CircleOcticon.d.ts +1 -0
- package/lib-esm/Dialog.d.ts +3 -2
- package/lib-esm/Dropdown.d.ts +4 -0
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +2 -1
- package/lib-esm/FilterList.d.ts +1 -0
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -4
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +1 -0
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/__tests__/ActionList2.test.d.ts +1 -0
- package/lib-esm/__tests__/ActionList2.test.js +105 -2
- package/lib-esm/__tests__/Checkbox.test.d.ts +2 -0
- package/lib-esm/__tests__/Checkbox.test.js +169 -0
- package/lib-esm/__tests__/themePreval.test.d.ts +1 -0
- package/lib-esm/__tests__/themePreval.test.js +7 -0
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/stories/ActionList2.stories.js +20 -6
- package/lib-esm/stories/Checkbox.stories.js +197 -0
- package/lib-esm/utils/testing.d.ts +1 -0
- package/lib-esm/utils/testing.js +24 -0
- package/package-lock.json +179 -20
- package/package.json +2 -2
- package/src/ActionList/Item.tsx +2 -1
- package/src/ActionList2/Item.tsx +3 -2
- package/src/ActionList2/List.tsx +1 -6
- package/src/ActionList2/Selection.tsx +2 -1
- package/src/Checkbox.tsx +75 -0
- package/src/__tests__/ActionList2.test.tsx +111 -2
- package/src/__tests__/Checkbox.test.tsx +155 -0
- package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +13 -0
- package/src/__tests__/__snapshots__/Checkbox.test.tsx.snap +16 -0
- package/src/__tests__/__snapshots__/themePreval.test.ts.snap +3176 -0
- package/src/__tests__/themePreval.test.ts +8 -0
- package/src/index.ts +3 -0
- package/src/stories/ActionList2.stories.tsx +22 -8
- package/src/stories/Checkbox.stories.tsx +164 -0
- package/src/utils/testing.tsx +22 -0
- package/stats.html +1 -1
- package/docs/content/TextInputTokens.mdx +0 -89
- package/lib/ActionList2/Header.d.ts +0 -26
- package/lib/ActionList2/Header.js +0 -55
- package/lib-esm/ActionList2/Header.d.ts +0 -26
- package/lib-esm/ActionList2/Header.js +0 -44
- package/src/ActionList2/Header.tsx +0 -58
@@ -1,89 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: TextInputWithTokens
|
3
|
-
status: Alpha
|
4
|
-
source: https://github.com/primer/react/tree/main/src/TextInputWithTokens.tsx
|
5
|
-
---
|
6
|
-
|
7
|
-
import {Props} from '../src/props'
|
8
|
-
import {TextInputWithTokens} from '@primer/components'
|
9
|
-
|
10
|
-
A `TextInputWithTokens` component is used to show multiple values in one field.
|
11
|
-
|
12
|
-
It supports all of the features of a [TextInput](/TextInput) component, but it can render a list of [Tokens](/Token) next to the area a user types in.
|
13
|
-
|
14
|
-
## Basic Example
|
15
|
-
|
16
|
-
```javascript live noinline
|
17
|
-
const BasicExample = () => {
|
18
|
-
const [tokens, setTokens] = React.useState([
|
19
|
-
{text: 'zero', id: 0},
|
20
|
-
{text: 'one', id: 1},
|
21
|
-
{text: 'two', id: 2}
|
22
|
-
])
|
23
|
-
const onTokenRemove = tokenId => {
|
24
|
-
setTokens(tokens.filter(token => token.id !== tokenId))
|
25
|
-
}
|
26
|
-
|
27
|
-
return (
|
28
|
-
<>
|
29
|
-
<Box as="label" display="block" htmlFor="inputWithTokens-basic">
|
30
|
-
Basic example tokens
|
31
|
-
</Box>
|
32
|
-
<TextInputWithTokens tokens={tokens} onTokenRemove={onTokenRemove} id="inputWithTokens-basic" />
|
33
|
-
</>
|
34
|
-
)
|
35
|
-
}
|
36
|
-
|
37
|
-
render(BasicExample)
|
38
|
-
```
|
39
|
-
|
40
|
-
## Component Props
|
41
|
-
|
42
|
-
<Props of={TextInputWithTokens} />
|
43
|
-
|
44
|
-
## Adding and removing tokens
|
45
|
-
|
46
|
-
The array passed to the `tokens` prop needs to be manually updated to add and remove tokens.
|
47
|
-
|
48
|
-
The function passed to the `onRemoveToken` prop is called when:
|
49
|
-
|
50
|
-
- Clicking the remove button in the token
|
51
|
-
- Pressing the `Backspace` key when the input is empty
|
52
|
-
- Selecting a token using the arrow keys or by clicking on a token and then pressing the `Backspace` key
|
53
|
-
|
54
|
-
There is no function that gets called to "add" a token, so the user needs to be provided with a UI to select tokens.
|
55
|
-
|
56
|
-
## Custom token rendering
|
57
|
-
|
58
|
-
By default, the `Token` component is used to render the tokens in the input. If this component does not make sense for the kinds of tokens you're rendering, you can pass a component to the `tokenComponent` prop
|
59
|
-
|
60
|
-
Example: a `TextInputWithTokens` that renders tokens as `IssueLabelToken`:
|
61
|
-
|
62
|
-
```javascript live noinline
|
63
|
-
const UsingIssueLabelTokens = () => {
|
64
|
-
const [tokens, setTokens] = React.useState([
|
65
|
-
{text: 'enhancement', id: 1, fillColor: '#a2eeef'},
|
66
|
-
{text: 'bug', id: 2, fillColor: '#d73a4a'},
|
67
|
-
{text: 'good first issue', id: 3, fillColor: '#0cf478'}
|
68
|
-
])
|
69
|
-
const onTokenRemove = tokenId => {
|
70
|
-
setTokens(tokens.filter(token => token.id !== tokenId))
|
71
|
-
}
|
72
|
-
|
73
|
-
return (
|
74
|
-
<>
|
75
|
-
<Box as="label" display="block" htmlFor="inputWithTokens-issueLabels">
|
76
|
-
Issue labels
|
77
|
-
</Box>
|
78
|
-
<TextInputWithTokens
|
79
|
-
tokenComponent={IssueLabelToken}
|
80
|
-
tokens={tokens}
|
81
|
-
onTokenRemove={onTokenRemove}
|
82
|
-
id="inputWithTokens-issueLabels"
|
83
|
-
/>
|
84
|
-
</>
|
85
|
-
)
|
86
|
-
}
|
87
|
-
|
88
|
-
render(<UsingIssueLabelTokens />)
|
89
|
-
```
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { SxProp } from '../sx';
|
3
|
-
/**
|
4
|
-
* Contract for props passed to the `Header` component.
|
5
|
-
*/
|
6
|
-
export declare type HeaderProps = {
|
7
|
-
/**
|
8
|
-
* Style variations. Usage is discretionary.
|
9
|
-
*
|
10
|
-
* - `"filled"` - Superimposed on a background, offset from nearby content
|
11
|
-
* - `"subtle"` - Relatively less offset from nearby content
|
12
|
-
*/
|
13
|
-
variant?: 'subtle' | 'filled';
|
14
|
-
/**
|
15
|
-
* Primary text which names a `Group`.
|
16
|
-
*/
|
17
|
-
title?: string;
|
18
|
-
/**
|
19
|
-
* Secondary text which provides additional information about a `Group`.
|
20
|
-
*/
|
21
|
-
auxiliaryText?: string;
|
22
|
-
} & SxProp;
|
23
|
-
/**
|
24
|
-
* Displays the name and description of a `Group`.
|
25
|
-
*/
|
26
|
-
export declare const Header: ({ variant, title, auxiliaryText, sx, ...props }: HeaderProps) => JSX.Element;
|
@@ -1,55 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Header = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
-
|
12
|
-
var _List = require("./List");
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Displays the name and description of a `Group`.
|
20
|
-
*/
|
21
|
-
const Header = ({
|
22
|
-
variant = 'subtle',
|
23
|
-
title,
|
24
|
-
auxiliaryText,
|
25
|
-
sx = {},
|
26
|
-
...props
|
27
|
-
}) => {
|
28
|
-
const {
|
29
|
-
variant: listVariant
|
30
|
-
} = _react.default.useContext(_List.ListContext);
|
31
|
-
|
32
|
-
const styles = {
|
33
|
-
paddingY: '6px',
|
34
|
-
paddingX: listVariant === 'full' ? 2 : 3,
|
35
|
-
fontSize: 0,
|
36
|
-
fontWeight: 'bold',
|
37
|
-
color: 'fg.muted',
|
38
|
-
...(variant === 'filled' && {
|
39
|
-
backgroundColor: 'canvas.subtle',
|
40
|
-
marginX: 0,
|
41
|
-
marginBottom: 2,
|
42
|
-
borderTop: '1px solid',
|
43
|
-
borderBottom: '1px solid',
|
44
|
-
borderColor: 'neutral.muted'
|
45
|
-
}),
|
46
|
-
...sx
|
47
|
-
};
|
48
|
-
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
49
|
-
sx: styles,
|
50
|
-
role: "heading"
|
51
|
-
}, props), title, auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, auxiliaryText));
|
52
|
-
};
|
53
|
-
|
54
|
-
exports.Header = Header;
|
55
|
-
Header.displayName = "Header";
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { SxProp } from '../sx';
|
3
|
-
/**
|
4
|
-
* Contract for props passed to the `Header` component.
|
5
|
-
*/
|
6
|
-
export declare type HeaderProps = {
|
7
|
-
/**
|
8
|
-
* Style variations. Usage is discretionary.
|
9
|
-
*
|
10
|
-
* - `"filled"` - Superimposed on a background, offset from nearby content
|
11
|
-
* - `"subtle"` - Relatively less offset from nearby content
|
12
|
-
*/
|
13
|
-
variant?: 'subtle' | 'filled';
|
14
|
-
/**
|
15
|
-
* Primary text which names a `Group`.
|
16
|
-
*/
|
17
|
-
title?: string;
|
18
|
-
/**
|
19
|
-
* Secondary text which provides additional information about a `Group`.
|
20
|
-
*/
|
21
|
-
auxiliaryText?: string;
|
22
|
-
} & SxProp;
|
23
|
-
/**
|
24
|
-
* Displays the name and description of a `Group`.
|
25
|
-
*/
|
26
|
-
export declare const Header: ({ variant, title, auxiliaryText, sx, ...props }: HeaderProps) => JSX.Element;
|
@@ -1,44 +0,0 @@
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
-
|
3
|
-
import React from 'react';
|
4
|
-
import Box from '../Box';
|
5
|
-
import { ListContext } from './List';
|
6
|
-
/**
|
7
|
-
* Contract for props passed to the `Header` component.
|
8
|
-
*/
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Displays the name and description of a `Group`.
|
12
|
-
*/
|
13
|
-
export const Header = ({
|
14
|
-
variant = 'subtle',
|
15
|
-
title,
|
16
|
-
auxiliaryText,
|
17
|
-
sx = {},
|
18
|
-
...props
|
19
|
-
}) => {
|
20
|
-
const {
|
21
|
-
variant: listVariant
|
22
|
-
} = React.useContext(ListContext);
|
23
|
-
const styles = {
|
24
|
-
paddingY: '6px',
|
25
|
-
paddingX: listVariant === 'full' ? 2 : 3,
|
26
|
-
fontSize: 0,
|
27
|
-
fontWeight: 'bold',
|
28
|
-
color: 'fg.muted',
|
29
|
-
...(variant === 'filled' && {
|
30
|
-
backgroundColor: 'canvas.subtle',
|
31
|
-
marginX: 0,
|
32
|
-
marginBottom: 2,
|
33
|
-
borderTop: '1px solid',
|
34
|
-
borderBottom: '1px solid',
|
35
|
-
borderColor: 'neutral.muted'
|
36
|
-
}),
|
37
|
-
...sx
|
38
|
-
};
|
39
|
-
return /*#__PURE__*/React.createElement(Box, _extends({
|
40
|
-
sx: styles,
|
41
|
-
role: "heading"
|
42
|
-
}, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, auxiliaryText));
|
43
|
-
};
|
44
|
-
Header.displayName = "Header";
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import Box from '../Box'
|
3
|
-
import {SxProp} from '../sx'
|
4
|
-
import {ListContext} from './List'
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Contract for props passed to the `Header` component.
|
8
|
-
*/
|
9
|
-
export type HeaderProps = {
|
10
|
-
/**
|
11
|
-
* Style variations. Usage is discretionary.
|
12
|
-
*
|
13
|
-
* - `"filled"` - Superimposed on a background, offset from nearby content
|
14
|
-
* - `"subtle"` - Relatively less offset from nearby content
|
15
|
-
*/
|
16
|
-
variant?: 'subtle' | 'filled'
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Primary text which names a `Group`.
|
20
|
-
*/
|
21
|
-
title?: string
|
22
|
-
|
23
|
-
/**
|
24
|
-
* Secondary text which provides additional information about a `Group`.
|
25
|
-
*/
|
26
|
-
auxiliaryText?: string
|
27
|
-
} & SxProp
|
28
|
-
|
29
|
-
/**
|
30
|
-
* Displays the name and description of a `Group`.
|
31
|
-
*/
|
32
|
-
export const Header = ({variant = 'subtle', title, auxiliaryText, sx = {}, ...props}: HeaderProps): JSX.Element => {
|
33
|
-
const {variant: listVariant} = React.useContext(ListContext)
|
34
|
-
|
35
|
-
const styles = {
|
36
|
-
paddingY: '6px',
|
37
|
-
paddingX: listVariant === 'full' ? 2 : 3,
|
38
|
-
fontSize: 0,
|
39
|
-
fontWeight: 'bold',
|
40
|
-
color: 'fg.muted',
|
41
|
-
...(variant === 'filled' && {
|
42
|
-
backgroundColor: 'canvas.subtle',
|
43
|
-
marginX: 0,
|
44
|
-
marginBottom: 2,
|
45
|
-
borderTop: '1px solid',
|
46
|
-
borderBottom: '1px solid',
|
47
|
-
borderColor: 'neutral.muted'
|
48
|
-
}),
|
49
|
-
...sx
|
50
|
-
}
|
51
|
-
|
52
|
-
return (
|
53
|
-
<Box sx={styles} role="heading" {...props}>
|
54
|
-
{title}
|
55
|
-
{auxiliaryText && <span>{auxiliaryText}</span>}
|
56
|
-
</Box>
|
57
|
-
)
|
58
|
-
}
|