@primer/components 31.0.2-rc.95622264 → 31.2.0-rc.50908ce9

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 (93) hide show
  1. package/.storybook/main.js +7 -9
  2. package/.storybook/preview.js +5 -1
  3. package/CHANGELOG.md +15 -1
  4. package/dist/browser.esm.js +1 -1
  5. package/dist/browser.esm.js.map +1 -1
  6. package/dist/browser.umd.js +1 -1
  7. package/dist/browser.umd.js.map +1 -1
  8. package/docs/content/FilterList.md +2 -2
  9. package/docs/content/theming.md +23 -0
  10. package/lib/ActionList/Header.js +1 -1
  11. package/lib/Autocomplete/Autocomplete.d.ts +4 -4
  12. package/lib/Autocomplete/AutocompleteInput.d.ts +4 -4
  13. package/lib/Button/Button.d.ts +5 -5
  14. package/lib/Button/ButtonBase.d.ts +1 -1
  15. package/lib/Button/ButtonClose.d.ts +3 -3
  16. package/lib/Button/ButtonDanger.d.ts +5 -5
  17. package/lib/Button/ButtonInvisible.d.ts +5 -5
  18. package/lib/Button/ButtonOutline.d.ts +5 -5
  19. package/lib/Button/ButtonPrimary.d.ts +5 -5
  20. package/lib/CircleBadge.d.ts +2 -2
  21. package/lib/CircleOcticon.d.ts +4 -4
  22. package/lib/Dialog.d.ts +4 -4
  23. package/lib/Dropdown.d.ts +16 -16
  24. package/lib/DropdownMenu/DropdownButton.d.ts +6 -6
  25. package/lib/FilterList.d.ts +3 -3
  26. package/lib/Flash.d.ts +1 -1
  27. package/lib/Label.d.ts +1 -1
  28. package/lib/Position.d.ts +4 -4
  29. package/lib/ProgressBar.d.ts +1 -1
  30. package/lib/SelectMenu/SelectMenu.d.ts +24 -24
  31. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  32. package/lib/TextInputWithTokens.d.ts +4 -4
  33. package/lib/Timeline.d.ts +4 -4
  34. package/lib/Token/AvatarToken.d.ts +1 -1
  35. package/lib/Token/IssueLabelToken.d.ts +1 -1
  36. package/lib/Token/Token.d.ts +1 -1
  37. package/lib/_TextInputWrapper.d.ts +1 -1
  38. package/lib/__tests__/KeyPaths.types.test.d.ts +11 -0
  39. package/lib/__tests__/KeyPaths.types.test.js +10 -0
  40. package/lib/stories/Token.stories.js +19 -2
  41. package/lib/sx.d.ts +8 -2
  42. package/lib/theme.d.ts +78 -0
  43. package/lib/theme.js +3 -1
  44. package/lib/utils/types/KeyPaths.d.ts +3 -0
  45. package/lib/utils/types/KeyPaths.js +1 -0
  46. package/lib-esm/ActionList/Header.js +1 -1
  47. package/lib-esm/Autocomplete/Autocomplete.d.ts +4 -4
  48. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +4 -4
  49. package/lib-esm/Button/Button.d.ts +5 -5
  50. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  51. package/lib-esm/Button/ButtonClose.d.ts +3 -3
  52. package/lib-esm/Button/ButtonDanger.d.ts +5 -5
  53. package/lib-esm/Button/ButtonInvisible.d.ts +5 -5
  54. package/lib-esm/Button/ButtonOutline.d.ts +5 -5
  55. package/lib-esm/Button/ButtonPrimary.d.ts +5 -5
  56. package/lib-esm/CircleBadge.d.ts +2 -2
  57. package/lib-esm/CircleOcticon.d.ts +4 -4
  58. package/lib-esm/Dialog.d.ts +4 -4
  59. package/lib-esm/Dropdown.d.ts +16 -16
  60. package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -6
  61. package/lib-esm/FilterList.d.ts +3 -3
  62. package/lib-esm/Flash.d.ts +1 -1
  63. package/lib-esm/Label.d.ts +1 -1
  64. package/lib-esm/Position.d.ts +4 -4
  65. package/lib-esm/ProgressBar.d.ts +1 -1
  66. package/lib-esm/SelectMenu/SelectMenu.d.ts +24 -24
  67. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  68. package/lib-esm/TextInputWithTokens.d.ts +4 -4
  69. package/lib-esm/Timeline.d.ts +4 -4
  70. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  71. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  72. package/lib-esm/Token/Token.d.ts +1 -1
  73. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  74. package/lib-esm/__tests__/KeyPaths.types.test.d.ts +11 -0
  75. package/lib-esm/__tests__/KeyPaths.types.test.js +3 -0
  76. package/lib-esm/stories/Token.stories.js +14 -1
  77. package/lib-esm/sx.d.ts +8 -2
  78. package/lib-esm/theme.d.ts +78 -0
  79. package/lib-esm/theme.js +2 -1
  80. package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
  81. package/lib-esm/utils/types/KeyPaths.js +1 -0
  82. package/package-lock.json +37956 -42
  83. package/package.json +3 -1
  84. package/script/build +2 -0
  85. package/src/ActionList/Header.tsx +1 -1
  86. package/src/__tests__/KeyPaths.types.test.ts +14 -0
  87. package/src/stories/Button.stories.tsx +1 -1
  88. package/src/stories/Token.stories.tsx +12 -1
  89. package/src/sx.ts +14 -2
  90. package/src/theme.ts +86 -0
  91. package/src/utils/types/KeyPaths.ts +10 -0
  92. package/stats.html +1 -1
  93. package/.changeset/tiny-ghosts-repeat.md +0 -5
@@ -7,6 +7,7 @@ import { BaseStyles, ThemeProvider } from '..';
7
7
  import Box from '../Box';
8
8
  import Token from '../Token/Token';
9
9
  import Text from '../Text';
10
+ import { GitBranchIcon } from '@primer/octicons-react';
10
11
  export default {
11
12
  title: 'Tokens/Default',
12
13
  component: Token,
@@ -19,7 +20,7 @@ export default {
19
20
  return /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(BaseStyles, null, /*#__PURE__*/React.createElement(Story, null)));
20
21
  }]
21
22
  };
22
- const excludedControlKeys = ['id', 'as', 'tabIndex', 'onRemove'];
23
+ const excludedControlKeys = ['id', 'as', 'tabIndex', 'onRemove', 'leadingVisual'];
23
24
 
24
25
  const SingleExampleContainer = ({
25
26
  children,
@@ -91,6 +92,18 @@ Interactive.parameters = {
91
92
  exclude: [...excludedControlKeys, 'hideRemoveButton', 'text']
92
93
  }
93
94
  };
95
+ export const WithLeadingVisual = args => {
96
+ return /*#__PURE__*/React.createElement(ExampleCollectionContainer, null, /*#__PURE__*/React.createElement(Token, _extends({}, args, {
97
+ leadingVisual: () => /*#__PURE__*/React.createElement(GitBranchIcon, null)
98
+ })));
99
+ };
100
+ WithLeadingVisual.displayName = "WithLeadingVisual";
101
+ WithLeadingVisual.storyName = 'with leadingVisual';
102
+ WithLeadingVisual.parameters = {
103
+ controls: {
104
+ exclude: [...excludedControlKeys, 'hideRemoveButton']
105
+ }
106
+ };
94
107
  export const WithOnRemoveFn = args => {
95
108
  return /*#__PURE__*/React.createElement(ExampleCollectionContainer, null, /*#__PURE__*/React.createElement(SingleExampleContainer, {
96
109
  label: "w/ onRemove passed"
package/lib-esm/sx.d.ts CHANGED
@@ -1,6 +1,12 @@
1
- import { SystemStyleObject } from '@styled-system/css';
1
+ import { SystemCssProperties, SystemStyleObject } from '@styled-system/css';
2
+ import { ThemeColorPaths, ThemeShadowPaths } from './theme';
3
+ import { ColorProps, ShadowProps } from 'styled-system';
4
+ export declare type BetterCssProperties = {
5
+ [K in keyof SystemCssProperties]: K extends keyof ColorProps ? ThemeColorPaths | SystemCssProperties[K] : K extends keyof ShadowProps ? ThemeShadowPaths | SystemCssProperties[K] : SystemCssProperties[K];
6
+ };
7
+ export declare type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject;
2
8
  export interface SxProp {
3
- sx?: SystemStyleObject;
9
+ sx?: BetterSystemStyleObject;
4
10
  }
5
11
  declare const sx: (props: SxProp) => import("@styled-system/css").CssFunctionReturnType;
6
12
  export default sx;
@@ -1,2 +1,80 @@
1
1
  import { theme } from './theme-preval';
2
+ import { KeyPaths } from './utils/types/KeyPaths';
2
3
  export default theme;
4
+ declare type ThemeColors = {
5
+ fg: {
6
+ default: string;
7
+ muted: string;
8
+ subtle: string;
9
+ onEmphasis: string;
10
+ };
11
+ canvas: {
12
+ default: string;
13
+ overlay: string;
14
+ inset: string;
15
+ subtle: string;
16
+ };
17
+ border: {
18
+ default: string;
19
+ muted: string;
20
+ subtle: string;
21
+ };
22
+ neutral: {
23
+ emphasisPlus: string;
24
+ emphasis: string;
25
+ muted: string;
26
+ subtle: string;
27
+ };
28
+ accent: {
29
+ fg: string;
30
+ emphasis: string;
31
+ muted: string;
32
+ subtle: string;
33
+ };
34
+ success: {
35
+ fg: string;
36
+ emphasis: string;
37
+ muted: string;
38
+ subtle: string;
39
+ };
40
+ attention: {
41
+ fg: string;
42
+ emphasis: string;
43
+ muted: string;
44
+ subtle: string;
45
+ };
46
+ severe: {
47
+ fg: string;
48
+ emphasis: string;
49
+ muted: string;
50
+ subtle: string;
51
+ };
52
+ danger: {
53
+ fg: string;
54
+ emphasis: string;
55
+ muted: string;
56
+ subtle: string;
57
+ };
58
+ done: {
59
+ fg: string;
60
+ emphasis: string;
61
+ muted: string;
62
+ subtle: string;
63
+ };
64
+ sponsors: {
65
+ fg: string;
66
+ emphasis: string;
67
+ muted: string;
68
+ subtle: string;
69
+ };
70
+ };
71
+ declare type ThemeShadows = {
72
+ shadow: {
73
+ small: string;
74
+ medium: string;
75
+ large: string;
76
+ extraLarge: string;
77
+ };
78
+ };
79
+ export declare type ThemeColorPaths = KeyPaths<ThemeColors>;
80
+ export declare type ThemeShadowPaths = KeyPaths<ThemeShadows>;
package/lib-esm/theme.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import { theme } from './theme-preval';
2
- export default theme;
2
+ export default theme; // NOTE: for now, ThemeColors and ThemeShadows are handcrafted types. It would be nice if these
3
+ // were exports from primitives (or a different shape but derived from those exports).
@@ -0,0 +1,3 @@
1
+ export declare type KeyPaths<O extends Record<string, unknown>> = {
2
+ [K in keyof O]: K extends string ? O[K] extends string ? `${K}` : `${K}.${KeyPaths<O[K]>}` : never;
3
+ }[keyof O];
@@ -0,0 +1 @@
1
+ export {};