@primer/components 31.0.2-rc.95622264 → 31.2.0-rc.c285489d

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.
Files changed (81) hide show
  1. package/.storybook/main.js +7 -9
  2. package/.storybook/preview.js +5 -1
  3. package/CHANGELOG.md +11 -1
  4. package/dist/browser.esm.js.map +1 -1
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/Autocomplete/Autocomplete.d.ts +4 -4
  7. package/lib/Autocomplete/AutocompleteInput.d.ts +4 -4
  8. package/lib/Button/Button.d.ts +5 -5
  9. package/lib/Button/ButtonBase.d.ts +1 -1
  10. package/lib/Button/ButtonClose.d.ts +3 -3
  11. package/lib/Button/ButtonDanger.d.ts +5 -5
  12. package/lib/Button/ButtonInvisible.d.ts +5 -5
  13. package/lib/Button/ButtonOutline.d.ts +5 -5
  14. package/lib/Button/ButtonPrimary.d.ts +5 -5
  15. package/lib/CircleBadge.d.ts +2 -2
  16. package/lib/CircleOcticon.d.ts +4 -4
  17. package/lib/Dialog.d.ts +4 -4
  18. package/lib/Dropdown.d.ts +16 -16
  19. package/lib/DropdownMenu/DropdownButton.d.ts +6 -6
  20. package/lib/FilterList.d.ts +3 -3
  21. package/lib/Flash.d.ts +1 -1
  22. package/lib/Label.d.ts +1 -1
  23. package/lib/Position.d.ts +4 -4
  24. package/lib/ProgressBar.d.ts +1 -1
  25. package/lib/SelectMenu/SelectMenu.d.ts +24 -24
  26. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  27. package/lib/TextInputWithTokens.d.ts +4 -4
  28. package/lib/Timeline.d.ts +4 -4
  29. package/lib/Token/AvatarToken.d.ts +1 -1
  30. package/lib/Token/IssueLabelToken.d.ts +1 -1
  31. package/lib/Token/Token.d.ts +1 -1
  32. package/lib/_TextInputWrapper.d.ts +1 -1
  33. package/lib/__tests__/KeyPaths.types.test.d.ts +10 -0
  34. package/lib/__tests__/KeyPaths.types.test.js +10 -0
  35. package/lib/sx.d.ts +8 -2
  36. package/lib/theme.d.ts +78 -0
  37. package/lib/theme.js +3 -1
  38. package/lib/utils/types/KeyPaths.d.ts +3 -0
  39. package/lib/utils/types/KeyPaths.js +1 -0
  40. package/lib-esm/Autocomplete/Autocomplete.d.ts +4 -4
  41. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +4 -4
  42. package/lib-esm/Button/Button.d.ts +5 -5
  43. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  44. package/lib-esm/Button/ButtonClose.d.ts +3 -3
  45. package/lib-esm/Button/ButtonDanger.d.ts +5 -5
  46. package/lib-esm/Button/ButtonInvisible.d.ts +5 -5
  47. package/lib-esm/Button/ButtonOutline.d.ts +5 -5
  48. package/lib-esm/Button/ButtonPrimary.d.ts +5 -5
  49. package/lib-esm/CircleBadge.d.ts +2 -2
  50. package/lib-esm/CircleOcticon.d.ts +4 -4
  51. package/lib-esm/Dialog.d.ts +4 -4
  52. package/lib-esm/Dropdown.d.ts +16 -16
  53. package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -6
  54. package/lib-esm/FilterList.d.ts +3 -3
  55. package/lib-esm/Flash.d.ts +1 -1
  56. package/lib-esm/Label.d.ts +1 -1
  57. package/lib-esm/Position.d.ts +4 -4
  58. package/lib-esm/ProgressBar.d.ts +1 -1
  59. package/lib-esm/SelectMenu/SelectMenu.d.ts +24 -24
  60. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  61. package/lib-esm/TextInputWithTokens.d.ts +4 -4
  62. package/lib-esm/Timeline.d.ts +4 -4
  63. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  64. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  65. package/lib-esm/Token/Token.d.ts +1 -1
  66. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  67. package/lib-esm/__tests__/KeyPaths.types.test.d.ts +10 -0
  68. package/lib-esm/__tests__/KeyPaths.types.test.js +3 -0
  69. package/lib-esm/sx.d.ts +8 -2
  70. package/lib-esm/theme.d.ts +78 -0
  71. package/lib-esm/theme.js +2 -1
  72. package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
  73. package/lib-esm/utils/types/KeyPaths.js +1 -0
  74. package/package-lock.json +37942 -41
  75. package/package.json +2 -1
  76. package/src/__tests__/KeyPaths.types.test.ts +13 -0
  77. package/src/sx.ts +14 -2
  78. package/src/theme.ts +86 -0
  79. package/src/utils/types/KeyPaths.ts +4 -0
  80. package/stats.html +1 -1
  81. package/.changeset/tiny-ghosts-repeat.md +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "31.0.2-rc.95622264",
3
+ "version": "31.2.0-rc.c285489d",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -132,6 +132,7 @@
132
132
  "rollup-plugin-visualizer": "5.5.0",
133
133
  "semver": "7.3.5",
134
134
  "size-limit": "5.0.2",
135
+ "storybook-addon-performance": "0.16.1",
135
136
  "styled-components": "4.4.1",
136
137
  "typescript": "4.2.2"
137
138
  },
@@ -0,0 +1,13 @@
1
+ import {KeyPaths} from '../utils/types/KeyPaths'
2
+
3
+ type NestedObject = {
4
+ a: string
5
+ b: {
6
+ b1: string
7
+ b2: string
8
+ }
9
+ }
10
+
11
+ export function generatesKeyPathsFromObject(x: KeyPaths<NestedObject>): 'a' | 'b.b1' | 'b.b2' {
12
+ return x
13
+ }
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?: SystemStyleObject
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>
@@ -0,0 +1,4 @@
1
+ // Produces a union of dot-delimited keypaths to the string values in a nested object:
2
+ export type KeyPaths<O extends Record<string, unknown>> = {
3
+ [K in keyof O]: K extends string ? (O[K] extends string ? `${K}` : `${K}.${KeyPaths<O[K]>}`) : never
4
+ }[keyof O]