@primer/components 0.0.0-202192952423 → 0.0.0-2021931194355

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 (144) hide show
  1. package/CHANGELOG.md +1 -7
  2. package/dist/browser.esm.js +439 -436
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +443 -440
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Item.d.ts +0 -6
  7. package/lib/ActionList/Item.js +1 -5
  8. package/lib/ActionMenu.js +2 -2
  9. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
  10. package/lib/Autocomplete/Autocomplete.d.ts +13 -11
  11. package/lib/Autocomplete/AutocompleteInput.d.ts +13 -11
  12. package/lib/Button/Button.d.ts +11 -11
  13. package/lib/Button/ButtonBase.d.ts +1 -1
  14. package/lib/Button/ButtonClose.d.ts +29 -29
  15. package/lib/Button/ButtonDanger.d.ts +11 -11
  16. package/lib/Button/ButtonInvisible.d.ts +11 -11
  17. package/lib/Button/ButtonOutline.d.ts +11 -11
  18. package/lib/Button/ButtonPrimary.d.ts +11 -11
  19. package/lib/CircleBadge.d.ts +2 -2
  20. package/lib/CircleOcticon.d.ts +33 -33
  21. package/lib/DatePicker/DatePicker.d.ts +48 -0
  22. package/lib/DatePicker/DatePicker.js +106 -0
  23. package/lib/DatePicker/DatePickerAnchor.d.ts +5 -0
  24. package/lib/DatePicker/DatePickerAnchor.js +223 -0
  25. package/lib/DatePicker/DatePickerOverlay.d.ts +3 -0
  26. package/lib/DatePicker/DatePickerOverlay.js +48 -0
  27. package/lib/DatePicker/DatePickerPanel.d.ts +2 -0
  28. package/lib/DatePicker/DatePickerPanel.js +143 -0
  29. package/lib/DatePicker/Day.d.ts +14 -0
  30. package/lib/DatePicker/Day.js +192 -0
  31. package/lib/DatePicker/Month.d.ts +9 -0
  32. package/lib/DatePicker/Month.js +122 -0
  33. package/lib/DatePicker/dateParser.d.ts +11 -0
  34. package/lib/DatePicker/dateParser.js +192 -0
  35. package/lib/DatePicker/index.d.ts +2 -0
  36. package/lib/DatePicker/index.js +13 -0
  37. package/lib/DatePicker/useDatePicker.d.ts +89 -0
  38. package/lib/DatePicker/useDatePicker.js +439 -0
  39. package/lib/Dialog/Dialog.d.ts +4 -4
  40. package/lib/Dialog/Dialog.js +22 -12
  41. package/lib/Dialog.d.ts +35 -35
  42. package/lib/Dropdown.d.ts +165 -87
  43. package/lib/Dropdown.js +5 -6
  44. package/lib/DropdownMenu/DropdownButton.d.ts +30 -30
  45. package/lib/FilterList.d.ts +26 -26
  46. package/lib/Label.d.ts +1 -1
  47. package/lib/Position.d.ts +4 -4
  48. package/lib/ProgressBar.d.ts +1 -1
  49. package/lib/SelectMenu/SelectMenu.d.ts +153 -151
  50. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  51. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  52. package/lib/TextInputWithTokens.d.ts +13 -11
  53. package/lib/Timeline.d.ts +33 -33
  54. package/lib/Token/AvatarToken.d.ts +1 -1
  55. package/lib/Token/IssueLabelToken.d.ts +1 -1
  56. package/lib/Token/Token.d.ts +1 -1
  57. package/lib/_TextInputWrapper.d.ts +1 -1
  58. package/lib/constants.js +1 -3
  59. package/lib/hooks/useDebounce.d.ts +2 -0
  60. package/lib/hooks/useDebounce.js +24 -0
  61. package/lib/hooks/useResizeObserver.d.ts +1 -1
  62. package/lib/hooks/useResizeObserver.js +1 -1
  63. package/lib/index.d.ts +0 -2
  64. package/lib/index.js +0 -8
  65. package/lib/theme-preval.js +2 -2
  66. package/lib/utils/testing.d.ts +1 -1
  67. package/lib-esm/ActionList/Item.d.ts +0 -6
  68. package/lib-esm/ActionList/Item.js +1 -5
  69. package/lib-esm/ActionMenu.js +2 -2
  70. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
  71. package/lib-esm/Autocomplete/Autocomplete.d.ts +13 -11
  72. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +13 -11
  73. package/lib-esm/Button/Button.d.ts +11 -11
  74. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  75. package/lib-esm/Button/ButtonClose.d.ts +29 -29
  76. package/lib-esm/Button/ButtonDanger.d.ts +11 -11
  77. package/lib-esm/Button/ButtonInvisible.d.ts +11 -11
  78. package/lib-esm/Button/ButtonOutline.d.ts +11 -11
  79. package/lib-esm/Button/ButtonPrimary.d.ts +11 -11
  80. package/lib-esm/CircleBadge.d.ts +2 -2
  81. package/lib-esm/CircleOcticon.d.ts +33 -33
  82. package/lib-esm/DatePicker/DatePicker.d.ts +48 -0
  83. package/lib-esm/DatePicker/DatePicker.js +89 -0
  84. package/lib-esm/DatePicker/DatePickerAnchor.d.ts +5 -0
  85. package/lib-esm/DatePicker/DatePickerAnchor.js +196 -0
  86. package/lib-esm/DatePicker/DatePickerOverlay.d.ts +3 -0
  87. package/lib-esm/DatePicker/DatePickerOverlay.js +29 -0
  88. package/lib-esm/DatePicker/DatePickerPanel.d.ts +2 -0
  89. package/lib-esm/DatePicker/DatePickerPanel.js +116 -0
  90. package/lib-esm/DatePicker/Day.d.ts +14 -0
  91. package/lib-esm/DatePicker/Day.js +169 -0
  92. package/lib-esm/DatePicker/Month.d.ts +9 -0
  93. package/lib-esm/DatePicker/Month.js +98 -0
  94. package/lib-esm/DatePicker/dateParser.d.ts +11 -0
  95. package/lib-esm/DatePicker/dateParser.js +178 -0
  96. package/lib-esm/DatePicker/index.d.ts +2 -0
  97. package/lib-esm/DatePicker/index.js +1 -0
  98. package/lib-esm/DatePicker/useDatePicker.d.ts +89 -0
  99. package/lib-esm/DatePicker/useDatePicker.js +408 -0
  100. package/lib-esm/Dialog/Dialog.d.ts +4 -4
  101. package/lib-esm/Dialog/Dialog.js +21 -12
  102. package/lib-esm/Dialog.d.ts +35 -35
  103. package/lib-esm/Dropdown.d.ts +165 -87
  104. package/lib-esm/Dropdown.js +3 -4
  105. package/lib-esm/DropdownMenu/DropdownButton.d.ts +30 -30
  106. package/lib-esm/FilterList.d.ts +26 -26
  107. package/lib-esm/Label.d.ts +1 -1
  108. package/lib-esm/Position.d.ts +4 -4
  109. package/lib-esm/ProgressBar.d.ts +1 -1
  110. package/lib-esm/SelectMenu/SelectMenu.d.ts +153 -151
  111. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  112. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  113. package/lib-esm/TextInputWithTokens.d.ts +13 -11
  114. package/lib-esm/Timeline.d.ts +33 -33
  115. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  116. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  117. package/lib-esm/Token/Token.d.ts +1 -1
  118. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  119. package/lib-esm/constants.js +1 -3
  120. package/lib-esm/hooks/useDebounce.d.ts +2 -0
  121. package/lib-esm/hooks/useDebounce.js +16 -0
  122. package/lib-esm/hooks/useResizeObserver.d.ts +1 -1
  123. package/lib-esm/hooks/useResizeObserver.js +1 -1
  124. package/lib-esm/index.d.ts +0 -2
  125. package/lib-esm/index.js +0 -1
  126. package/lib-esm/theme-preval.js +2 -2
  127. package/lib-esm/utils/testing.d.ts +1 -1
  128. package/package.json +14 -13
  129. package/lib/NewButton/button.d.ts +0 -581
  130. package/lib/NewButton/button.js +0 -332
  131. package/lib/NewButton/buttonStyles.d.ts +0 -2
  132. package/lib/NewButton/buttonStyles.js +0 -14
  133. package/lib/NewButton/counter.d.ts +0 -6
  134. package/lib/NewButton/counter.js +0 -33
  135. package/lib/NewButton/index.d.ts +0 -4
  136. package/lib/NewButton/index.js +0 -21
  137. package/lib-esm/NewButton/button.d.ts +0 -581
  138. package/lib-esm/NewButton/button.js +0 -308
  139. package/lib-esm/NewButton/buttonStyles.d.ts +0 -2
  140. package/lib-esm/NewButton/buttonStyles.js +0 -3
  141. package/lib-esm/NewButton/counter.d.ts +0 -6
  142. package/lib-esm/NewButton/counter.js +0 -21
  143. package/lib-esm/NewButton/index.d.ts +0 -4
  144. package/lib-esm/NewButton/index.js +0 -3
@@ -1,308 +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, { forwardRef } from 'react';
4
- import { TriangleDownIcon } from '@primer/octicons-react';
5
- import Box from '../Box';
6
- import { fontSize, variant as variantFn } from 'styled-system';
7
- import styled from 'styled-components';
8
- import sx from '../sx';
9
- import { get } from '../constants';
10
- import buttonBaseStyles from './buttonStyles';
11
- import Counter from './counter';
12
- const sizes = variantFn({
13
- prop: 'size',
14
- variants: {
15
- small: {
16
- fontSize: 0
17
- },
18
- medium: {
19
- fontSize: 1
20
- },
21
- large: {
22
- fontSize: 2
23
- }
24
- }
25
- });
26
-
27
- const getVariantStyles = (theme, variant = 'default') => {
28
- const style = {
29
- default: `
30
- color: ${get('colors.btn.text')({
31
- theme
32
- })};
33
- background-color: ${get('colors.btn.bg')({
34
- theme
35
- })};
36
- border-width: 1px;
37
- border-style: solid;
38
- border-color: ${get('colors.btn.border')({
39
- theme
40
- })};
41
- box-shadow: ${(get('shadows.btn.shadow')({
42
- theme
43
- }), get('shadows.btn.insetShadow')({
44
- theme
45
- }))};
46
- &:hover:not([disabled]) {
47
- background-color: ${get('colors.btn.hoverBg')({
48
- theme
49
- })};
50
- }
51
- // focus must come before :active so that the active box shadow overrides
52
- &:focus:not([disabled]) {
53
- box-shadow: ${get('shadows.btn.focusShadow')({
54
- theme
55
- })};
56
- }
57
- &:active:not([disabled]) {
58
- background-color: ${get('colors.btn.selectedBg')({
59
- theme
60
- })};
61
- box-shadow: ${get('shadows.btn.shadowActive')({
62
- theme
63
- })};
64
- }
65
- &:disabled {
66
- color: ${get('colors.primer.fg.disabled')({
67
- theme
68
- })};
69
- background-color: ${get('colors.btn.disabledBg')({
70
- theme
71
- })};
72
- }
73
- `,
74
- primary: `
75
- color: ${get('colors.btn.primary.text')({
76
- theme
77
- })};
78
- background-color: ${get('colors.btn.primary.bg')({
79
- theme
80
- })};
81
- border-width: 1px;
82
- border-style: solid;
83
- border-color: ${get('colors.border.subtle')({
84
- theme
85
- })};
86
- box-shadow: ${get('shadows.btn.primary.shadow')({
87
- theme
88
- })};
89
-
90
- &:hover:not([disabled]) {
91
- color: ${get('colors.btn.primary.hoverText')({
92
- theme
93
- })};
94
- background-color: ${get('colors.btn.primary.hoverBg')({
95
- theme
96
- })};
97
- }
98
- // focus must come before :active so that the active box shadow overrides
99
- &:focus:not([disabled]) {
100
- box-shadow: ${get('shadows.btn.primary.focusShadow')({
101
- theme
102
- })};
103
- }
104
-
105
- &:active:not([disabled]) {
106
- background-color: ${get('colors.btn.primary.selectedBg')({
107
- theme
108
- })};
109
- box-shadow: ${get('shadows.btn.primary.selectedShadow')({
110
- theme
111
- })};
112
- }
113
-
114
- &:disabled {
115
- color: ${get('colors.btn.primary.disabledText')({
116
- theme
117
- })};
118
- background-color: ${get('colors.btn.primary.disabledBg')({
119
- theme
120
- })};
121
- }`,
122
- danger: `
123
- color: ${get('colors.btn.danger.text')({
124
- theme
125
- })};
126
- border: 1px solid ${get('colors.btn.border')({
127
- theme
128
- })};
129
- background-color: ${get('colors.btn.bg')({
130
- theme
131
- })};
132
- box-shadow: ${get('shadows.btn.shadow')({
133
- theme
134
- })};
135
-
136
- &:hover:not([disabled]) {
137
- color: ${get('colors.btn.danger.hoverText')({
138
- theme
139
- })};
140
- background-color: ${get('colors.btn.danger.hoverBg')({
141
- theme
142
- })};
143
- border-color: ${get('colors.btn.danger.hoverBorder')({
144
- theme
145
- })};
146
- box-shadow: ${get('shadows.btn.danger.hoverShadow')({
147
- theme
148
- })};
149
- }
150
- // focus must come before :active so that the active box shadow overrides
151
- &:focus:not([disabled]) {
152
- border-color: ${get('colors.btn.danger.focusBorder')({
153
- theme
154
- })};
155
- box-shadow: ${get('shadows.btn.danger.focusShadow')({
156
- theme
157
- })};
158
- }
159
-
160
- &:active:not([disabled]) {
161
- color: ${get('colors.btn.danger.selectedText')({
162
- theme
163
- })};
164
- background-color: ${get('colors.btn.danger.selectedBg')({
165
- theme
166
- })};
167
- box-shadow: ${get('shadows.btn.danger.selectedShadow')({
168
- theme
169
- })};
170
- border-color: ${get('colors.btn.danger.selectedBorder')({
171
- theme
172
- })};
173
- }
174
-
175
- &:disabled {
176
- color: ${get('colors.btn.danger.disabledText')({
177
- theme
178
- })};
179
- background-color: ${get('colors.btn.danger.disabledBg')({
180
- theme
181
- })};
182
- border-color: ${get('colors.btn.danger.disabledBorder')({
183
- theme
184
- })};
185
- }
186
- `,
187
- invisible: `
188
- color: ${get('colors.accent.fg')({
189
- theme
190
- })};
191
- background-color: transparent;
192
- border: 0;
193
- border-radius: ${get('radii.2')({
194
- theme
195
- })};
196
- box-shadow: none;
197
-
198
- &:disabled {
199
- color: ${get('colors.primer.fg.disabled')({
200
- theme
201
- })};
202
- }
203
- &:focus:not([disabled]) {
204
- box-shadow: ${get('shadows.btn.focusShadow')({
205
- theme
206
- })};
207
- }
208
- &:hover:not([disabled]) {
209
- background-color: ${get('colors.btn.hoverBg')({
210
- theme
211
- })};
212
- }
213
- &:active:not([disabled]) {
214
- background-color: ${get('colors.btn.selectedBg')({
215
- theme
216
- })};
217
- }
218
- `
219
- };
220
- return style[variant];
221
- };
222
-
223
- const getSizes = (size = 'medium', variant = 'default', iconOnly) => {
224
- let paddingTop, paddingLeft;
225
-
226
- switch (size) {
227
- case 'small':
228
- paddingTop = 3;
229
- paddingLeft = 12;
230
- break;
231
-
232
- case 'large':
233
- paddingTop = 9;
234
- paddingLeft = 20;
235
- break;
236
-
237
- case 'medium':
238
- default:
239
- paddingTop = 5;
240
- paddingLeft = 16;
241
- }
242
-
243
- if (iconOnly) {
244
- paddingLeft = paddingTop + 2;
245
- }
246
-
247
- if (variant === 'invisible') {
248
- paddingTop = paddingTop + 1;
249
- }
250
-
251
- return `
252
- padding:${paddingTop}px ${paddingLeft}px;
253
- `;
254
- };
255
-
256
- const ButtonBase = styled.button.withConfig({
257
- displayName: "button__ButtonBase",
258
- componentId: "sc-15k5iqk-0"
259
- })(["", " ", " ", " ", " ", " ", ""], buttonBaseStyles, props => getVariantStyles(props.theme, props.variant), props => getSizes(props.size, props.variant, props.iconOnly), sizes, sx, fontSize);
260
- const Button = /*#__PURE__*/forwardRef(({
261
- children,
262
- ...props
263
- }, forwardedRef) => {
264
- const {
265
- icon: Icon,
266
- caret,
267
- size
268
- } = props;
269
- let iconOnly = false;
270
-
271
- if (Icon && !children) {
272
- iconOnly = true;
273
- }
274
-
275
- const iconWrapStyles = {
276
- display: 'inline-block',
277
- ...(!iconOnly ? {
278
- pr: 3
279
- } : {})
280
- };
281
- return /*#__PURE__*/React.createElement(ButtonBase, _extends({
282
- ref: forwardedRef
283
- }, props, {
284
- iconOnly: iconOnly
285
- }), Icon && /*#__PURE__*/React.createElement(Box, {
286
- sx: iconWrapStyles,
287
- "aria-hidden": !iconOnly
288
- }, /*#__PURE__*/React.createElement(Icon, {
289
- size: size
290
- })), children, caret && /*#__PURE__*/React.createElement(Box, {
291
- sx: {
292
- display: 'inline-block',
293
- pl: 3
294
- },
295
- "aria-hidden": true
296
- }, /*#__PURE__*/React.createElement(TriangleDownIcon, {
297
- size: size
298
- })));
299
- });
300
- Button.displayName = 'Button';
301
- Button.defaultProps = {
302
- size: 'medium',
303
- variant: 'default'
304
- };
305
- const NewButton = Object.assign(Button, {
306
- Counter
307
- });
308
- export default NewButton;
@@ -1,2 +0,0 @@
1
- declare const _default: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
2
- export default _default;
@@ -1,3 +0,0 @@
1
- import { css } from 'styled-components';
2
- import { get } from '../constants';
3
- export default css(["position:relative;display:inline-block;font-family:inherit;font-weight:", ";line-height:20px;white-space:nowrap;vertical-align:middle;cursor:pointer;user-select:none;border-radius:", ";appearance:none;text-decoration:none;text-align:center;&:hover{text-decoration:none;}&:focus{outline:none;}&:disabled{cursor:default;}&:disabled svg{opacity:0.6;}"], get('fontWeights.bold'), get('radii.2'));
@@ -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,21 +0,0 @@
1
- import React from 'react';
2
- import Box from '../Box';
3
- const styles = {
4
- display: 'inline-block',
5
- padding: '0px 6px',
6
- backgroundColor: 'neutral.muted',
7
- borderRadius: '50%',
8
- marginLeft: '8px'
9
- };
10
-
11
- const Counter = ({
12
- count
13
- }) => {
14
- // get this to announce new count. How? Change aria property for every render? or aria-live?
15
- return /*#__PURE__*/React.createElement(Box, {
16
- sx: styles
17
- }, count);
18
- };
19
-
20
- Counter.displayName = "Counter";
21
- export default Counter;
@@ -1,4 +0,0 @@
1
- export default Button;
2
- export { NewButtonProps as ButtonProps };
3
- import Button from "./button";
4
- import { NewButtonProps } from "./button";
@@ -1,3 +0,0 @@
1
- import Button, { NewButtonProps } from './button';
2
- export default Button;
3
- export { NewButtonProps as ButtonProps };