@primer/components 0.0.0-20219266052 → 0.0.0-202192711181

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 (134) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/browser.esm.js +615 -615
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +176 -176
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Description.d.ts +6 -0
  7. package/lib/ActionList2/Description.js +53 -0
  8. package/lib/ActionList2/Divider.d.ts +8 -0
  9. package/lib/ActionList2/Divider.js +42 -0
  10. package/lib/ActionList2/Group.d.ts +8 -0
  11. package/lib/ActionList2/Group.js +39 -0
  12. package/lib/ActionList2/Header.d.ts +26 -0
  13. package/lib/ActionList2/Header.js +55 -0
  14. package/lib/ActionList2/Item.d.ts +48 -0
  15. package/lib/ActionList2/Item.js +205 -0
  16. package/lib/ActionList2/List.d.ts +12 -0
  17. package/lib/ActionList2/List.js +55 -0
  18. package/lib/ActionList2/Selection.d.ts +5 -0
  19. package/lib/ActionList2/Selection.js +67 -0
  20. package/lib/ActionList2/Visuals.d.ts +11 -0
  21. package/lib/ActionList2/Visuals.js +90 -0
  22. package/lib/ActionList2/hacks.d.ts +30 -0
  23. package/lib/ActionList2/hacks.js +38 -0
  24. package/lib/ActionList2/index.d.ts +26 -0
  25. package/lib/ActionList2/index.js +36 -0
  26. package/lib/Autocomplete/Autocomplete.d.ts +9 -9
  27. package/lib/Autocomplete/AutocompleteInput.d.ts +9 -9
  28. package/lib/Button/Button.d.ts +11 -11
  29. package/lib/Button/ButtonBase.d.ts +1 -1
  30. package/lib/Button/ButtonClose.d.ts +29 -29
  31. package/lib/Button/ButtonDanger.d.ts +11 -11
  32. package/lib/Button/ButtonInvisible.d.ts +11 -11
  33. package/lib/Button/ButtonOutline.d.ts +11 -11
  34. package/lib/Button/ButtonPrimary.d.ts +11 -11
  35. package/lib/Button/ButtonStyles.js +1 -1
  36. package/lib/CircleBadge.d.ts +2 -2
  37. package/lib/CircleOcticon.d.ts +33 -33
  38. package/lib/Dialog.d.ts +35 -35
  39. package/lib/Dropdown.d.ts +110 -110
  40. package/lib/DropdownMenu/DropdownButton.d.ts +30 -30
  41. package/lib/FilterList.d.ts +26 -26
  42. package/lib/Label.d.ts +1 -1
  43. package/lib/Position.d.ts +4 -4
  44. package/lib/ProgressBar.d.ts +1 -1
  45. package/lib/SelectMenu/SelectMenu.d.ts +149 -149
  46. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  47. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  48. package/lib/TextInputWithTokens.d.ts +9 -9
  49. package/lib/Timeline.d.ts +33 -33
  50. package/lib/Token/AvatarToken.d.ts +1 -1
  51. package/lib/Token/IssueLabelToken.d.ts +1 -1
  52. package/lib/Token/Token.d.ts +1 -1
  53. package/lib/_TextInputWrapper.d.ts +1 -1
  54. package/lib/constants.js +1 -3
  55. package/lib/index.d.ts +1 -0
  56. package/lib/index.js +8 -0
  57. package/lib/sx.d.ts +2 -0
  58. package/lib/sx.js +8 -0
  59. package/lib/utils/create-slots.d.ts +17 -0
  60. package/lib/utils/create-slots.js +105 -0
  61. package/lib/utils/testing.d.ts +1 -1
  62. package/lib/utils/use-force-update.d.ts +1 -0
  63. package/lib/utils/use-force-update.js +19 -0
  64. package/lib-esm/ActionList2/Description.d.ts +6 -0
  65. package/lib-esm/ActionList2/Description.js +37 -0
  66. package/lib-esm/ActionList2/Divider.d.ts +8 -0
  67. package/lib-esm/ActionList2/Divider.js +30 -0
  68. package/lib-esm/ActionList2/Group.d.ts +8 -0
  69. package/lib-esm/ActionList2/Group.js +29 -0
  70. package/lib-esm/ActionList2/Header.d.ts +26 -0
  71. package/lib-esm/ActionList2/Header.js +45 -0
  72. package/lib-esm/ActionList2/Item.d.ts +48 -0
  73. package/lib-esm/ActionList2/Item.js +198 -0
  74. package/lib-esm/ActionList2/List.d.ts +12 -0
  75. package/lib-esm/ActionList2/List.js +37 -0
  76. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  77. package/lib-esm/ActionList2/Selection.js +50 -0
  78. package/lib-esm/ActionList2/Visuals.d.ts +11 -0
  79. package/lib-esm/ActionList2/Visuals.js +68 -0
  80. package/lib-esm/ActionList2/hacks.d.ts +30 -0
  81. package/lib-esm/ActionList2/hacks.js +30 -0
  82. package/lib-esm/ActionList2/index.d.ts +26 -0
  83. package/lib-esm/ActionList2/index.js +23 -0
  84. package/lib-esm/Autocomplete/Autocomplete.d.ts +9 -9
  85. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +9 -9
  86. package/lib-esm/Button/Button.d.ts +11 -11
  87. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  88. package/lib-esm/Button/ButtonClose.d.ts +29 -29
  89. package/lib-esm/Button/ButtonDanger.d.ts +11 -11
  90. package/lib-esm/Button/ButtonInvisible.d.ts +11 -11
  91. package/lib-esm/Button/ButtonOutline.d.ts +11 -11
  92. package/lib-esm/Button/ButtonPrimary.d.ts +11 -11
  93. package/lib-esm/Button/ButtonStyles.js +1 -1
  94. package/lib-esm/CircleBadge.d.ts +2 -2
  95. package/lib-esm/CircleOcticon.d.ts +33 -33
  96. package/lib-esm/Dialog.d.ts +35 -35
  97. package/lib-esm/Dropdown.d.ts +110 -110
  98. package/lib-esm/DropdownMenu/DropdownButton.d.ts +30 -30
  99. package/lib-esm/FilterList.d.ts +26 -26
  100. package/lib-esm/Label.d.ts +1 -1
  101. package/lib-esm/Position.d.ts +4 -4
  102. package/lib-esm/ProgressBar.d.ts +1 -1
  103. package/lib-esm/SelectMenu/SelectMenu.d.ts +149 -149
  104. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  105. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  106. package/lib-esm/TextInputWithTokens.d.ts +9 -9
  107. package/lib-esm/Timeline.d.ts +33 -33
  108. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  109. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  110. package/lib-esm/Token/Token.d.ts +1 -1
  111. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  112. package/lib-esm/constants.js +1 -3
  113. package/lib-esm/index.d.ts +1 -0
  114. package/lib-esm/index.js +1 -0
  115. package/lib-esm/sx.d.ts +2 -0
  116. package/lib-esm/sx.js +3 -1
  117. package/lib-esm/utils/create-slots.d.ts +17 -0
  118. package/lib-esm/utils/create-slots.js +84 -0
  119. package/lib-esm/utils/testing.d.ts +1 -1
  120. package/lib-esm/utils/use-force-update.d.ts +1 -0
  121. package/lib-esm/utils/use-force-update.js +6 -0
  122. package/package.json +1 -1
  123. package/lib/NewButton/button.d.ts +0 -24
  124. package/lib/NewButton/button.js +0 -292
  125. package/lib/NewButton/counter.d.ts +0 -6
  126. package/lib/NewButton/counter.js +0 -33
  127. package/lib/NewButton/index.d.ts +0 -4
  128. package/lib/NewButton/index.js +0 -21
  129. package/lib-esm/NewButton/button.d.ts +0 -24
  130. package/lib-esm/NewButton/button.js +0 -268
  131. package/lib-esm/NewButton/counter.d.ts +0 -6
  132. package/lib-esm/NewButton/counter.js +0 -21
  133. package/lib-esm/NewButton/index.d.ts +0 -4
  134. package/lib-esm/NewButton/index.js +0 -3
@@ -0,0 +1,84 @@
1
+ import React from 'react';
2
+ import { useForceUpdate } from './use-force-update';
3
+ /** createSlots is a factory that can create a
4
+ * typesafe Slots + Slot pair to use in a component definition
5
+ * For example: ActionList.Item uses createSlots to get a Slots wrapper
6
+ * + Slot component that is used by LeadingVisual, Description
7
+ */
8
+
9
+ const createSlots = slotNames => {
10
+ const SlotsContext = /*#__PURE__*/React.createContext({
11
+ registerSlot: () => null,
12
+ unregisterSlot: () => null,
13
+ context: {}
14
+ });
15
+ /** Slots uses a Double render strategy inspired by [reach-ui/descendants](https://github.com/reach/reach-ui/tree/develop/packages/descendants)
16
+ * Slot registers themself with the Slots parent.
17
+ * When all the children have mounted = registered themselves in slot,
18
+ * we re-render the parent component to render with slots
19
+ */
20
+
21
+ const Slots = ({
22
+ context,
23
+ children
24
+ }) => {
25
+ // initialise slots
26
+ const slotsDefinition = {};
27
+ slotNames.map(name => slotsDefinition[name] = null);
28
+ const slotsRef = React.useRef(slotsDefinition);
29
+ const rerenderWithSlots = useForceUpdate();
30
+ const [isMounted, setIsMounted] = React.useState(false); // fires after all the effects in children
31
+
32
+ React.useEffect(() => {
33
+ rerenderWithSlots();
34
+ setIsMounted(true);
35
+ }, [rerenderWithSlots]);
36
+ const registerSlot = React.useCallback((name, contents) => {
37
+ slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
38
+
39
+ if (isMounted) rerenderWithSlots();
40
+ }, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
41
+ // we need to unregister them from the slot
42
+
43
+ const unregisterSlot = React.useCallback(name => {
44
+ slotsRef.current[name] = null;
45
+ rerenderWithSlots();
46
+ }, [rerenderWithSlots]);
47
+ /**
48
+ * Slots uses a render prop API so abstract the
49
+ * implementation detail of using a context provider.
50
+ */
51
+
52
+ const slots = slotsRef.current;
53
+ return /*#__PURE__*/React.createElement(SlotsContext.Provider, {
54
+ value: {
55
+ registerSlot,
56
+ unregisterSlot,
57
+ context
58
+ }
59
+ }, children(slots));
60
+ };
61
+
62
+ const Slot = ({
63
+ name,
64
+ children
65
+ }) => {
66
+ const {
67
+ registerSlot,
68
+ unregisterSlot,
69
+ context
70
+ } = React.useContext(SlotsContext);
71
+ React.useEffect(() => {
72
+ registerSlot(name, typeof children === 'function' ? children(context) : children);
73
+ return () => unregisterSlot(name);
74
+ }, [name, children, registerSlot, unregisterSlot, context]);
75
+ return null;
76
+ };
77
+
78
+ return {
79
+ Slots,
80
+ Slot
81
+ };
82
+ };
83
+
84
+ export default createSlots;
@@ -53,7 +53,7 @@ export declare function render(component: React.ReactElement, theme?: {
53
53
  xlarge: string;
54
54
  };
55
55
  space: string[];
56
- colorSchemes: Record<"dark" | "light" | "light_protanopia" | "dark_dimmed" | "dark_high_contrast" | "dark_protanopia", Record<"colors" | "shadows", Partial<{
56
+ colorSchemes: Record<"light" | "light_protanopia" | "dark" | "dark_dimmed" | "dark_high_contrast" | "dark_protanopia", Record<"colors" | "shadows", Partial<{
57
57
  canvasDefaultTransparent: string;
58
58
  marketingIcon: {
59
59
  primary: string;
@@ -0,0 +1 @@
1
+ export declare const useForceUpdate: () => () => void;
@@ -0,0 +1,6 @@
1
+ // Inspired from reach-ui: https://github.com/reach/reach-ui/blob/develop/packages/utils/src/use-force-update.ts
2
+ import React from 'react';
3
+ export const useForceUpdate = () => {
4
+ const [, rerender] = React.useState({});
5
+ return React.useCallback(() => rerender({}), []);
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "0.0.0-20219266052",
3
+ "version": "0.0.0-202192711181",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -1,24 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { IconProps } from '@primer/octicons-react';
3
- import { FontSizeProps } from 'styled-system';
4
- import { SxProp } from '../sx';
5
- declare type Variant = 'default' | 'primary' | 'invisible' | 'danger';
6
- export declare type ButtonProps = {
7
- caret?: boolean;
8
- children: ReactNode;
9
- variant: Variant;
10
- size: 'small' | 'medium' | 'large';
11
- icon?: React.FunctionComponent<IconProps>;
12
- } & SxProp & FontSizeProps;
13
- declare const NewButton: React.ForwardRefExoticComponent<{
14
- caret?: boolean | undefined;
15
- children: ReactNode;
16
- variant: Variant;
17
- size: 'small' | 'medium' | 'large';
18
- icon?: React.FunctionComponent<IconProps> | undefined;
19
- } & SxProp & FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>> & {
20
- Counter: ({ count }: {
21
- count: number;
22
- }) => JSX.Element;
23
- };
24
- export default NewButton;
@@ -1,292 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _octiconsReact = require("@primer/octicons-react");
11
-
12
- var _Box = _interopRequireDefault(require("../Box"));
13
-
14
- var _styledSystem = require("styled-system");
15
-
16
- var _styledComponents = _interopRequireDefault(require("styled-components"));
17
-
18
- var _sx = _interopRequireDefault(require("../sx"));
19
-
20
- var _constants = require("../constants");
21
-
22
- var _ButtonStyles = _interopRequireDefault(require("../Button/ButtonStyles"));
23
-
24
- var _counter = _interopRequireDefault(require("./counter"));
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
-
30
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
-
32
- 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); }
33
-
34
- const sizes = (0, _styledSystem.variant)({
35
- prop: 'size',
36
- variants: {
37
- small: {
38
- p: '4px 12px',
39
- fontSize: 0
40
- },
41
- medium: {
42
- fontSize: 1
43
- },
44
- large: {
45
- fontSize: 2,
46
- p: '10px 20px'
47
- }
48
- }
49
- });
50
-
51
- const getVariantStyles = (theme, variant = 'default') => {
52
- const style = {
53
- default: `
54
- padding: 5px 16px;
55
- color: ${(0, _constants.get)('colors.btn.text')({
56
- theme
57
- })};
58
- background-color: ${(0, _constants.get)('colors.btn.bg')({
59
- theme
60
- })};
61
- border-width: 1px;
62
- border-style: solid;
63
- border-color: ${(0, _constants.get)('colors.btn.border')({
64
- theme
65
- })};
66
- box-shadow: ${((0, _constants.get)('shadows.btn.shadow')({
67
- theme
68
- }), (0, _constants.get)('shadows.btn.insetShadow')({
69
- theme
70
- }))};
71
- &:hover {
72
- background-color: ${(0, _constants.get)('colors.btn.hoverBg')({
73
- theme
74
- })};
75
- }
76
- // focus must come before :active so that the active box shadow overrides
77
- &:focus {
78
- box-shadow: ${(0, _constants.get)('shadows.btn.focusShadow')({
79
- theme
80
- })};
81
- }
82
- &:active {
83
- background-color: ${(0, _constants.get)('colors.btn.selectedBg')({
84
- theme
85
- })};
86
- box-shadow: ${(0, _constants.get)('shadows.btn.shadowActive')({
87
- theme
88
- })};
89
- }
90
- &:disabled {
91
- color: ${(0, _constants.get)('colors.primer.fg.disabled')({
92
- theme
93
- })};
94
- }
95
- `,
96
- primary: `
97
- padding: 5px 16px;
98
- color: ${(0, _constants.get)('colors.btn.primary.text')({
99
- theme
100
- })};
101
- background-color: ${(0, _constants.get)('colors.btn.primary.bg')({
102
- theme
103
- })};
104
- border-width: 1px;
105
- border-style: solid;
106
- border-color: ${(0, _constants.get)('colors.border.subtle')({
107
- theme
108
- })};
109
- box-shadow: ${(0, _constants.get)('shadows.btn.primary.shadow')({
110
- theme
111
- })};
112
-
113
- &:hover {
114
- color: ${(0, _constants.get)('colors.btn.primary.hoverText')({
115
- theme
116
- })};
117
- background-color: ${(0, _constants.get)('colors.btn.primary.hoverBg')({
118
- theme
119
- })};
120
- }
121
- // focus must come before :active so that the active box shadow overrides
122
- &:focus {
123
- box-shadow: ${(0, _constants.get)('shadows.btn.primary.focusShadow')({
124
- theme
125
- })};
126
- }
127
-
128
- &:active {
129
- background-color: ${(0, _constants.get)('colors.btn.primary.selectedBg')({
130
- theme
131
- })};
132
- box-shadow: ${(0, _constants.get)('shadows.btn.primary.selectedShadow')({
133
- theme
134
- })};
135
- }
136
-
137
- &:disabled {
138
- color: ${(0, _constants.get)('colors.btn.primary.disabledText')({
139
- theme
140
- })};
141
- background-color: ${(0, _constants.get)('colors.btn.primary.disabledBg')({
142
- theme
143
- })};
144
- }`,
145
- danger: `
146
- padding: 5px 16px;
147
- color: ${(0, _constants.get)('colors.btn.danger.text')({
148
- theme
149
- })};
150
- border: 1px solid ${(0, _constants.get)('colors.btn.border')({
151
- theme
152
- })};
153
- background-color: ${(0, _constants.get)('colors.btn.bg')({
154
- theme
155
- })};
156
- box-shadow: ${(0, _constants.get)('shadows.btn.shadow')({
157
- theme
158
- })};
159
-
160
- &:hover {
161
- color: ${(0, _constants.get)('colors.btn.danger.hoverText')({
162
- theme
163
- })};
164
- background-color: ${(0, _constants.get)('colors.btn.danger.hoverBg')({
165
- theme
166
- })};
167
- border-color: ${(0, _constants.get)('colors.btn.danger.hoverBorder')({
168
- theme
169
- })};
170
- box-shadow: ${(0, _constants.get)('shadows.btn.danger.hoverShadow')({
171
- theme
172
- })};
173
- }
174
- // focus must come before :active so that the active box shadow overrides
175
- &:focus {
176
- border-color: ${(0, _constants.get)('colors.btn.danger.focusBorder')({
177
- theme
178
- })};
179
- box-shadow: ${(0, _constants.get)('shadows.btn.danger.focusShadow')({
180
- theme
181
- })};
182
- }
183
-
184
- &:active {
185
- color: ${(0, _constants.get)('colors.btn.danger.selectedText')({
186
- theme
187
- })};
188
- background-color: ${(0, _constants.get)('colors.btn.danger.selectedBg')({
189
- theme
190
- })};
191
- box-shadow: ${(0, _constants.get)('shadows.btn.danger.selectedShadow')({
192
- theme
193
- })};
194
- border-color: ${(0, _constants.get)('colors.btn.danger.selectedBorder')({
195
- theme
196
- })};
197
- }
198
-
199
- &:disabled {
200
- color: ${(0, _constants.get)('colors.btn.danger.disabledText')({
201
- theme
202
- })};
203
- background-color: ${(0, _constants.get)('colors.btn.danger.disabledBg')({
204
- theme
205
- })};
206
- border-color: ${(0, _constants.get)('colors.btn.danger.disabledBorder')({
207
- theme
208
- })};
209
- }
210
- `,
211
- invisible: `
212
- padding: 6px 16px;
213
- color: ${(0, _constants.get)('colors.accent.fg')({
214
- theme
215
- })};
216
- background-color: transparent;
217
- border: 0;
218
- border-radius: ${(0, _constants.get)('radii.2')({
219
- theme
220
- })};
221
- box-shadow: none;
222
-
223
- &:disabled {
224
- color: ${(0, _constants.get)('colors.primer.fg.disabled')({
225
- theme
226
- })};
227
- }
228
- &:focus {
229
- box-shadow: ${(0, _constants.get)('shadows.btn.focusShadow')({
230
- theme
231
- })};
232
- }
233
- &:hover {
234
- background-color: ${(0, _constants.get)('colors.btn.hoverBg')({
235
- theme
236
- })};
237
- }
238
- &:active {
239
- background-color: ${(0, _constants.get)('colors.btn.selectedBg')({
240
- theme
241
- })};
242
- }
243
- `
244
- };
245
- return style[variant];
246
- };
247
-
248
- const ButtonBase = _styledComponents.default.button.withConfig({
249
- displayName: "button__ButtonBase",
250
- componentId: "sc-15k5iqk-0"
251
- })(["", " ", " ", " ", " ", " ", ""], _ButtonStyles.default, props => getVariantStyles(props.theme, props.variant), sizes, props => props.iconOnly ? `padding: 4px 6px;` : '', _sx.default, _styledSystem.fontSize);
252
-
253
- const Button = /*#__PURE__*/(0, _react.forwardRef)(({
254
- icon: Icon,
255
- caret,
256
- children,
257
- ...props
258
- }) => {
259
- let iconOnly = false;
260
-
261
- if (!children) {
262
- iconOnly = true;
263
- }
264
-
265
- let iconWrapStyles = {
266
- display: 'inline-block',
267
- ...(!iconOnly ? {
268
- pr: 3
269
- } : {})
270
- };
271
- return /*#__PURE__*/_react.default.createElement(ButtonBase, _extends({}, props, {
272
- iconOnly: iconOnly
273
- }), Icon && /*#__PURE__*/_react.default.createElement(_Box.default, {
274
- sx: iconWrapStyles,
275
- "aria-hidden": !iconOnly
276
- }, /*#__PURE__*/_react.default.createElement(Icon, null)), children, caret && /*#__PURE__*/_react.default.createElement(_Box.default, {
277
- sx: {
278
- display: 'inline-block',
279
- pl: 3
280
- },
281
- "aria-hidden": true
282
- }, /*#__PURE__*/_react.default.createElement(_octiconsReact.TriangleDownIcon, null)));
283
- });
284
- Button.displayName = 'Button';
285
- Button.defaultProps = {
286
- size: 'medium'
287
- };
288
- const NewButton = Object.assign(Button, {
289
- Counter: _counter.default
290
- });
291
- var _default = NewButton;
292
- exports.default = _default;
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- declare type CounterProps = {
3
- count: number;
4
- };
5
- declare const Counter: ({ count }: CounterProps) => JSX.Element;
6
- export default Counter;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _Box = _interopRequireDefault(require("../Box"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- const styles = {
15
- display: 'inline-block',
16
- padding: '0px 6px',
17
- backgroundColor: 'neutral.muted',
18
- borderRadius: '50%',
19
- marginLeft: '8px'
20
- };
21
-
22
- const Counter = ({
23
- count
24
- }) => {
25
- // get this to announce new count. How? Change aria property for every render? or aria-live?
26
- return /*#__PURE__*/_react.default.createElement(_Box.default, {
27
- sx: styles
28
- }, count);
29
- };
30
-
31
- Counter.displayName = "Counter";
32
- var _default = Counter;
33
- exports.default = _default;
@@ -1,4 +0,0 @@
1
- export default Button;
2
- export { ButtonProps };
3
- import Button from "./button";
4
- import { ButtonProps } from "./button";
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "ButtonProps", {
7
- enumerable: true,
8
- get: function () {
9
- return _button.ButtonProps;
10
- }
11
- });
12
- exports.default = void 0;
13
-
14
- var _button = _interopRequireWildcard(require("./button"));
15
-
16
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
- var _default = _button.default;
21
- exports.default = _default;
@@ -1,24 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { IconProps } from '@primer/octicons-react';
3
- import { FontSizeProps } from 'styled-system';
4
- import { SxProp } from '../sx';
5
- declare type Variant = 'default' | 'primary' | 'invisible' | 'danger';
6
- export declare type ButtonProps = {
7
- caret?: boolean;
8
- children: ReactNode;
9
- variant: Variant;
10
- size: 'small' | 'medium' | 'large';
11
- icon?: React.FunctionComponent<IconProps>;
12
- } & SxProp & FontSizeProps;
13
- declare const NewButton: React.ForwardRefExoticComponent<{
14
- caret?: boolean | undefined;
15
- children: ReactNode;
16
- variant: Variant;
17
- size: 'small' | 'medium' | 'large';
18
- icon?: React.FunctionComponent<IconProps> | undefined;
19
- } & SxProp & FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>> & {
20
- Counter: ({ count }: {
21
- count: number;
22
- }) => JSX.Element;
23
- };
24
- export default NewButton;