@primer/components 31.0.2-rc.c7dafefb → 31.2.0-rc.a53b3afb
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/.storybook/main.js +7 -9
- package/.storybook/preview.js +5 -1
- package/CHANGELOG.md +11 -1
- package/dist/browser.esm.js +11 -10
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +11 -10
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/FilterList.md +2 -2
- package/docs/content/TextInputWithTokens.mdx +114 -0
- package/docs/content/theming.md +23 -0
- package/lib/Autocomplete/Autocomplete.d.ts +4 -4
- package/lib/Autocomplete/AutocompleteInput.d.ts +4 -4
- package/lib/Button/Button.d.ts +5 -5
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +3 -3
- package/lib/Button/ButtonDanger.d.ts +5 -5
- package/lib/Button/ButtonInvisible.d.ts +5 -5
- package/lib/Button/ButtonOutline.d.ts +5 -5
- package/lib/Button/ButtonPrimary.d.ts +5 -5
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +4 -4
- package/lib/Dialog.d.ts +4 -4
- package/lib/Dropdown.d.ts +16 -16
- package/lib/DropdownMenu/DropdownButton.d.ts +6 -6
- package/lib/FilterList.d.ts +3 -3
- package/lib/Flash.d.ts +1 -1
- package/lib/Label.d.ts +1 -1
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.d.ts +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +24 -24
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +8 -4
- package/lib/TextInputWithTokens.js +61 -8
- package/lib/Timeline.d.ts +4 -4
- 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/_TextInputWrapper.d.ts +1 -1
- package/lib/_TextInputWrapper.js +1 -1
- package/lib/__tests__/KeyPaths.types.test.d.ts +10 -0
- package/lib/__tests__/KeyPaths.types.test.js +10 -0
- package/lib/__tests__/TextInputWithTokens.test.js +149 -9
- package/lib/stories/TextInputWithTokens.stories.js +18 -1
- package/lib/sx.d.ts +8 -2
- package/lib/theme.d.ts +78 -0
- package/lib/theme.js +3 -1
- package/lib/utils/types/KeyPaths.d.ts +3 -0
- package/lib/utils/types/KeyPaths.js +1 -0
- package/lib-esm/Autocomplete/Autocomplete.d.ts +4 -4
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +4 -4
- package/lib-esm/Button/Button.d.ts +5 -5
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +3 -3
- package/lib-esm/Button/ButtonDanger.d.ts +5 -5
- package/lib-esm/Button/ButtonInvisible.d.ts +5 -5
- package/lib-esm/Button/ButtonOutline.d.ts +5 -5
- package/lib-esm/Button/ButtonPrimary.d.ts +5 -5
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +4 -4
- package/lib-esm/Dialog.d.ts +4 -4
- package/lib-esm/Dropdown.d.ts +16 -16
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -6
- package/lib-esm/FilterList.d.ts +3 -3
- package/lib-esm/Flash.d.ts +1 -1
- package/lib-esm/Label.d.ts +1 -1
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +24 -24
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +8 -4
- package/lib-esm/TextInputWithTokens.js +60 -8
- package/lib-esm/Timeline.d.ts +4 -4
- 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/_TextInputWrapper.d.ts +1 -1
- package/lib-esm/_TextInputWrapper.js +1 -1
- package/lib-esm/__tests__/KeyPaths.types.test.d.ts +10 -0
- package/lib-esm/__tests__/KeyPaths.types.test.js +3 -0
- package/lib-esm/__tests__/TextInputWithTokens.test.js +142 -9
- package/lib-esm/stories/TextInputWithTokens.stories.js +14 -0
- package/lib-esm/sx.d.ts +8 -2
- package/lib-esm/theme.d.ts +78 -0
- package/lib-esm/theme.js +2 -1
- package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
- package/lib-esm/utils/types/KeyPaths.js +1 -0
- package/package-lock.json +37942 -41
- package/package.json +2 -1
- package/src/TextInputWithTokens.tsx +64 -8
- package/src/_TextInputWrapper.tsx +1 -0
- package/src/__tests__/KeyPaths.types.test.ts +13 -0
- package/src/__tests__/TextInputWithTokens.test.tsx +133 -1
- package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +7 -0
- package/src/__tests__/__snapshots__/TextInput.test.tsx.snap +6 -0
- package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +463 -0
- package/src/stories/TextInputWithTokens.stories.tsx +9 -0
- package/src/sx.ts +14 -2
- package/src/theme.ts +86 -0
- package/src/utils/types/KeyPaths.ts +4 -0
- package/stats.html +1 -1
@@ -121,6 +121,15 @@ export const TokenRemoveButtonsHidden = () => {
|
|
121
121
|
return <TextInputWithTokens hideTokenRemoveButtons tokens={tokens} onTokenRemove={onTokenRemove} />
|
122
122
|
}
|
123
123
|
|
124
|
+
export const WithVisibleTokenCount = () => {
|
125
|
+
const [tokens, setTokens] = useState([...mockTokens].slice(0, 5))
|
126
|
+
const onTokenRemove: (tokenId: string | number) => void = tokenId => {
|
127
|
+
setTokens(tokens.filter(token => token.id !== tokenId))
|
128
|
+
}
|
129
|
+
|
130
|
+
return <TextInputWithTokens tokens={tokens} onTokenRemove={onTokenRemove} visibleTokenCount={2} />
|
131
|
+
}
|
132
|
+
|
124
133
|
export const Unstyled = () => {
|
125
134
|
const [tokens, setTokens] = useState([...mockTokens].slice(0, 2))
|
126
135
|
const onTokenRemove: (tokenId: string | number) => void = tokenId => {
|
package/src/sx.ts
CHANGED
@@ -1,7 +1,19 @@
|
|
1
|
-
import css, {SystemStyleObject} from '@styled-system/css'
|
1
|
+
import css, {SystemCssProperties, SystemStyleObject} from '@styled-system/css'
|
2
|
+
import {ThemeColorPaths, ThemeShadowPaths} from './theme'
|
3
|
+
import {ColorProps, ShadowProps} from 'styled-system'
|
4
|
+
|
5
|
+
export type BetterCssProperties = {
|
6
|
+
[K in keyof SystemCssProperties]: K extends keyof ColorProps
|
7
|
+
? ThemeColorPaths | SystemCssProperties[K]
|
8
|
+
: K extends keyof ShadowProps
|
9
|
+
? ThemeShadowPaths | SystemCssProperties[K]
|
10
|
+
: SystemCssProperties[K]
|
11
|
+
}
|
12
|
+
|
13
|
+
export type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject
|
2
14
|
|
3
15
|
export interface SxProp {
|
4
|
-
sx?:
|
16
|
+
sx?: BetterSystemStyleObject
|
5
17
|
}
|
6
18
|
|
7
19
|
const sx = (props: SxProp) => css(props.sx)
|
package/src/theme.ts
CHANGED
@@ -1,3 +1,89 @@
|
|
1
1
|
import {theme} from './theme-preval'
|
2
|
+
import {KeyPaths} from './utils/types/KeyPaths'
|
2
3
|
|
3
4
|
export default theme
|
5
|
+
|
6
|
+
// NOTE: for now, ThemeColors and ThemeShadows are handcrafted types. It would be nice if these
|
7
|
+
// were exports from primitives (or a different shape but derived from those exports).
|
8
|
+
|
9
|
+
type ThemeColors = {
|
10
|
+
fg: {
|
11
|
+
default: string
|
12
|
+
muted: string
|
13
|
+
subtle: string
|
14
|
+
onEmphasis: string
|
15
|
+
}
|
16
|
+
canvas: {
|
17
|
+
default: string
|
18
|
+
overlay: string
|
19
|
+
inset: string
|
20
|
+
subtle: string
|
21
|
+
}
|
22
|
+
border: {
|
23
|
+
default: string
|
24
|
+
muted: string
|
25
|
+
subtle: string
|
26
|
+
}
|
27
|
+
|
28
|
+
// Roles
|
29
|
+
neutral: {
|
30
|
+
emphasisPlus: string
|
31
|
+
emphasis: string
|
32
|
+
muted: string
|
33
|
+
subtle: string
|
34
|
+
}
|
35
|
+
accent: {
|
36
|
+
fg: string
|
37
|
+
emphasis: string
|
38
|
+
muted: string
|
39
|
+
subtle: string
|
40
|
+
}
|
41
|
+
success: {
|
42
|
+
fg: string
|
43
|
+
emphasis: string
|
44
|
+
muted: string
|
45
|
+
subtle: string
|
46
|
+
}
|
47
|
+
attention: {
|
48
|
+
fg: string
|
49
|
+
emphasis: string
|
50
|
+
muted: string
|
51
|
+
subtle: string
|
52
|
+
}
|
53
|
+
severe: {
|
54
|
+
fg: string
|
55
|
+
emphasis: string
|
56
|
+
muted: string
|
57
|
+
subtle: string
|
58
|
+
}
|
59
|
+
danger: {
|
60
|
+
fg: string
|
61
|
+
emphasis: string
|
62
|
+
muted: string
|
63
|
+
subtle: string
|
64
|
+
}
|
65
|
+
done: {
|
66
|
+
fg: string
|
67
|
+
emphasis: string
|
68
|
+
muted: string
|
69
|
+
subtle: string
|
70
|
+
}
|
71
|
+
sponsors: {
|
72
|
+
fg: string
|
73
|
+
emphasis: string
|
74
|
+
muted: string
|
75
|
+
subtle: string
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
type ThemeShadows = {
|
80
|
+
shadow: {
|
81
|
+
small: string
|
82
|
+
medium: string
|
83
|
+
large: string
|
84
|
+
extraLarge: string
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
export type ThemeColorPaths = KeyPaths<ThemeColors>
|
89
|
+
export type ThemeShadowPaths = KeyPaths<ThemeShadows>
|