@primer/components 0.0.0-202192563541 → 0.0.0-202192602912
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/CHANGELOG.md +8 -4
- package/dist/browser.esm.js +3 -3
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +3 -3
- package/dist/browser.umd.js.map +1 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
- package/lib/Autocomplete/Autocomplete.d.ts +13 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +13 -11
- package/lib/Button/Button.d.ts +11 -11
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +29 -29
- package/lib/Button/ButtonDanger.d.ts +11 -11
- package/lib/Button/ButtonInvisible.d.ts +11 -11
- package/lib/Button/ButtonOutline.d.ts +11 -11
- package/lib/Button/ButtonPrimary.d.ts +11 -11
- package/lib/Button/ButtonStyles.js +1 -1
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +33 -33
- package/lib/DatePicker/DatePicker.d.ts +48 -0
- package/lib/DatePicker/DatePicker.js +92 -0
- package/lib/DatePicker/DatePickerAnchor.d.ts +5 -0
- package/lib/DatePicker/DatePickerAnchor.js +158 -0
- package/lib/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib/DatePicker/DatePickerOverlay.js +39 -0
- package/lib/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib/DatePicker/DatePickerPanel.js +126 -0
- package/lib/DatePicker/Day.d.ts +14 -0
- package/lib/DatePicker/Day.js +174 -0
- package/lib/DatePicker/Month.d.ts +9 -0
- package/lib/DatePicker/Month.js +107 -0
- package/lib/DatePicker/index.d.ts +2 -0
- package/lib/DatePicker/index.js +13 -0
- package/lib/DatePicker/useDatePicker.d.ts +83 -0
- package/lib/DatePicker/useDatePicker.js +375 -0
- package/lib/Dialog.d.ts +35 -35
- package/lib/Dropdown.d.ts +110 -110
- package/lib/DropdownMenu/DropdownButton.d.ts +30 -30
- package/lib/FilterList.d.ts +26 -26
- 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 +153 -151
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +13 -11
- package/lib/Timeline.d.ts +33 -33
- 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/constants.js +1 -3
- package/lib/hooks/useDebounce.d.ts +2 -0
- package/lib/hooks/useDebounce.js +24 -0
- package/lib/theme-preval.js +2 -2
- package/lib/utils/testing.d.ts +1 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
- package/lib-esm/Autocomplete/Autocomplete.d.ts +13 -11
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +13 -11
- package/lib-esm/Button/Button.d.ts +11 -11
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +29 -29
- package/lib-esm/Button/ButtonDanger.d.ts +11 -11
- package/lib-esm/Button/ButtonInvisible.d.ts +11 -11
- package/lib-esm/Button/ButtonOutline.d.ts +11 -11
- package/lib-esm/Button/ButtonPrimary.d.ts +11 -11
- package/lib-esm/Button/ButtonStyles.js +1 -1
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +33 -33
- package/lib-esm/DatePicker/DatePicker.d.ts +48 -0
- package/lib-esm/DatePicker/DatePicker.js +75 -0
- package/lib-esm/DatePicker/DatePickerAnchor.d.ts +5 -0
- package/lib-esm/DatePicker/DatePickerAnchor.js +132 -0
- package/lib-esm/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib-esm/DatePicker/DatePickerOverlay.js +24 -0
- package/lib-esm/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib-esm/DatePicker/DatePickerPanel.js +100 -0
- package/lib-esm/DatePicker/Day.d.ts +14 -0
- package/lib-esm/DatePicker/Day.js +151 -0
- package/lib-esm/DatePicker/Month.d.ts +9 -0
- package/lib-esm/DatePicker/Month.js +83 -0
- package/lib-esm/DatePicker/index.d.ts +2 -0
- package/lib-esm/DatePicker/index.js +1 -0
- package/lib-esm/DatePicker/useDatePicker.d.ts +83 -0
- package/lib-esm/DatePicker/useDatePicker.js +347 -0
- package/lib-esm/Dialog.d.ts +35 -35
- package/lib-esm/Dropdown.d.ts +110 -110
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +30 -30
- package/lib-esm/FilterList.d.ts +26 -26
- 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 +153 -151
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +13 -11
- package/lib-esm/Timeline.d.ts +33 -33
- 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/constants.js +1 -3
- package/lib-esm/hooks/useDebounce.d.ts +2 -0
- package/lib-esm/hooks/useDebounce.js +16 -0
- package/lib-esm/theme-preval.js +2 -2
- package/lib-esm/utils/testing.d.ts +1 -1
- package/package.json +9 -8
- package/lib/NewButton/button.d.ts +0 -18
- package/lib/NewButton/button.js +0 -278
- package/lib/NewButton/index.d.ts +0 -4
- package/lib/NewButton/index.js +0 -21
- package/lib-esm/NewButton/button.d.ts +0 -18
- package/lib-esm/NewButton/button.js +0 -256
- package/lib-esm/NewButton/index.d.ts +0 -4
- package/lib-esm/NewButton/index.js +0 -3
@@ -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<"
|
56
|
+
colorSchemes: Record<"light" | "light_colorblind" | "dark" | "dark_dimmed" | "dark_high_contrast" | "dark_colorblind", Record<"colors" | "shadows", Partial<{
|
57
57
|
canvasDefaultTransparent: string;
|
58
58
|
marketingIcon: {
|
59
59
|
primary: string;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/components",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-202192602912",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -43,20 +43,16 @@
|
|
43
43
|
"author": "GitHub, Inc.",
|
44
44
|
"license": "MIT",
|
45
45
|
"dependencies": {
|
46
|
-
"@primer/octicons-react": "^
|
47
|
-
"@primer/primitives": "
|
46
|
+
"@primer/octicons-react": "^16.1.0",
|
47
|
+
"@primer/primitives": "6.0.0",
|
48
48
|
"@radix-ui/react-polymorphic": "0.0.14",
|
49
49
|
"@react-aria/ssr": "3.1.0",
|
50
50
|
"@styled-system/css": "5.1.5",
|
51
51
|
"@styled-system/props": "5.1.5",
|
52
52
|
"@styled-system/theme-get": "5.1.2",
|
53
|
-
"@types/history": "4.7.8",
|
54
|
-
"@types/styled-components": "5.1.11",
|
55
|
-
"@types/styled-system": "5.1.12",
|
56
|
-
"@types/styled-system__css": "5.0.16",
|
57
|
-
"@types/styled-system__theme-get": "5.0.1",
|
58
53
|
"classnames": "2.3.1",
|
59
54
|
"color2k": "1.2.4",
|
55
|
+
"date-fns": "2.25.0",
|
60
56
|
"deepmerge": "4.2.2",
|
61
57
|
"focus-visible": "5.2.0",
|
62
58
|
"styled-system": "5.1.5"
|
@@ -85,6 +81,11 @@
|
|
85
81
|
"@testing-library/react": "11.2.7",
|
86
82
|
"@testing-library/react-hooks": "7.0.2",
|
87
83
|
"@testing-library/user-event": "13.1.9",
|
84
|
+
"@types/history": "4.7.9",
|
85
|
+
"@types/styled-components": "5.1.15",
|
86
|
+
"@types/styled-system": "5.1.13",
|
87
|
+
"@types/styled-system__css": "5.0.16",
|
88
|
+
"@types/styled-system__theme-get": "5.0.1",
|
88
89
|
"@types/chroma-js": "2.1.3",
|
89
90
|
"@types/enzyme": "3.10.9",
|
90
91
|
"@types/jest": "26.0.23",
|
@@ -1,18 +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' | 'block' | 'danger';
|
6
|
-
export declare type ButtonProps = {
|
7
|
-
children: ReactNode;
|
8
|
-
variant: Variant;
|
9
|
-
size: 'small' | 'medium' | 'large';
|
10
|
-
icon?: React.FunctionComponent<IconProps>;
|
11
|
-
} & SxProp & FontSizeProps;
|
12
|
-
declare const Button: React.ForwardRefExoticComponent<{
|
13
|
-
children: ReactNode;
|
14
|
-
variant: Variant;
|
15
|
-
size: 'small' | 'medium' | 'large';
|
16
|
-
icon?: React.FunctionComponent<IconProps> | undefined;
|
17
|
-
} & SxProp & FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
18
|
-
export default Button;
|
package/lib/NewButton/button.js
DELETED
@@ -1,278 +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 _Box = _interopRequireDefault(require("../Box"));
|
11
|
-
|
12
|
-
var _styledSystem = require("styled-system");
|
13
|
-
|
14
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
15
|
-
|
16
|
-
var _sx = _interopRequireDefault(require("../sx"));
|
17
|
-
|
18
|
-
var _constants = require("../constants");
|
19
|
-
|
20
|
-
var _ButtonStyles = _interopRequireDefault(require("../Button/ButtonStyles"));
|
21
|
-
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
|
-
|
24
|
-
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); }
|
25
|
-
|
26
|
-
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; }
|
27
|
-
|
28
|
-
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); }
|
29
|
-
|
30
|
-
const sizes = (0, _styledSystem.variant)({
|
31
|
-
prop: 'size',
|
32
|
-
variants: {
|
33
|
-
small: {
|
34
|
-
p: '4px 12px',
|
35
|
-
fontSize: 0
|
36
|
-
},
|
37
|
-
medium: {
|
38
|
-
fontSize: 1
|
39
|
-
},
|
40
|
-
large: {
|
41
|
-
fontSize: 2,
|
42
|
-
p: '10px 20px'
|
43
|
-
}
|
44
|
-
}
|
45
|
-
});
|
46
|
-
|
47
|
-
const getVariantStyles = (theme, variant = 'default') => {
|
48
|
-
const style = {
|
49
|
-
default: `
|
50
|
-
padding: 5px 16px;
|
51
|
-
color: ${(0, _constants.get)('colors.btn.text')({
|
52
|
-
theme
|
53
|
-
})};
|
54
|
-
background-color: ${(0, _constants.get)('colors.btn.bg')({
|
55
|
-
theme
|
56
|
-
})};
|
57
|
-
border-width: 1px;
|
58
|
-
border-style: solid;
|
59
|
-
border-color: ${(0, _constants.get)('colors.btn.border')({
|
60
|
-
theme
|
61
|
-
})};
|
62
|
-
box-shadow: ${((0, _constants.get)('shadows.btn.shadow')({
|
63
|
-
theme
|
64
|
-
}), (0, _constants.get)('shadows.btn.insetShadow')({
|
65
|
-
theme
|
66
|
-
}))};
|
67
|
-
&:hover {
|
68
|
-
background-color: ${(0, _constants.get)('colors.btn.hoverBg')({
|
69
|
-
theme
|
70
|
-
})};
|
71
|
-
}
|
72
|
-
// focus must come before :active so that the active box shadow overrides
|
73
|
-
&:focus {
|
74
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.focusShadow')({
|
75
|
-
theme
|
76
|
-
})};
|
77
|
-
}
|
78
|
-
&:active {
|
79
|
-
background-color: ${(0, _constants.get)('colors.btn.selectedBg')({
|
80
|
-
theme
|
81
|
-
})};
|
82
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.shadowActive')({
|
83
|
-
theme
|
84
|
-
})};
|
85
|
-
}
|
86
|
-
&:disabled {
|
87
|
-
color: ${(0, _constants.get)('colors.primer.fg.disabled')({
|
88
|
-
theme
|
89
|
-
})};
|
90
|
-
}
|
91
|
-
`,
|
92
|
-
primary: `
|
93
|
-
padding: 5px 16px;
|
94
|
-
color: ${(0, _constants.get)('colors.btn.primary.text')({
|
95
|
-
theme
|
96
|
-
})};
|
97
|
-
background-color: ${(0, _constants.get)('colors.btn.primary.bg')({
|
98
|
-
theme
|
99
|
-
})};
|
100
|
-
border-width: 1px;
|
101
|
-
border-style: solid;
|
102
|
-
border-color: ${(0, _constants.get)('colors.border.subtle')({
|
103
|
-
theme
|
104
|
-
})};
|
105
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.primary.shadow')({
|
106
|
-
theme
|
107
|
-
})};
|
108
|
-
|
109
|
-
&:hover {
|
110
|
-
color: ${(0, _constants.get)('colors.btn.primary.hoverText')({
|
111
|
-
theme
|
112
|
-
})};
|
113
|
-
background-color: ${(0, _constants.get)('colors.btn.primary.hoverBg')({
|
114
|
-
theme
|
115
|
-
})};
|
116
|
-
}
|
117
|
-
// focus must come before :active so that the active box shadow overrides
|
118
|
-
&:focus {
|
119
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.primary.focusShadow')({
|
120
|
-
theme
|
121
|
-
})};
|
122
|
-
}
|
123
|
-
|
124
|
-
&:active {
|
125
|
-
background-color: ${(0, _constants.get)('colors.btn.primary.selectedBg')({
|
126
|
-
theme
|
127
|
-
})};
|
128
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.primary.selectedShadow')({
|
129
|
-
theme
|
130
|
-
})};
|
131
|
-
}
|
132
|
-
|
133
|
-
&:disabled {
|
134
|
-
color: ${(0, _constants.get)('colors.btn.primary.disabledText')({
|
135
|
-
theme
|
136
|
-
})};
|
137
|
-
background-color: ${(0, _constants.get)('colors.btn.primary.disabledBg')({
|
138
|
-
theme
|
139
|
-
})};
|
140
|
-
}`,
|
141
|
-
danger: `
|
142
|
-
padding: 5px 16px;
|
143
|
-
color: ${(0, _constants.get)('colors.btn.danger.text')({
|
144
|
-
theme
|
145
|
-
})};
|
146
|
-
border: 1px solid ${(0, _constants.get)('colors.btn.border')({
|
147
|
-
theme
|
148
|
-
})};
|
149
|
-
background-color: ${(0, _constants.get)('colors.btn.bg')({
|
150
|
-
theme
|
151
|
-
})};
|
152
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.shadow')({
|
153
|
-
theme
|
154
|
-
})};
|
155
|
-
|
156
|
-
&:hover {
|
157
|
-
color: ${(0, _constants.get)('colors.btn.danger.hoverText')({
|
158
|
-
theme
|
159
|
-
})};
|
160
|
-
background-color: ${(0, _constants.get)('colors.btn.danger.hoverBg')({
|
161
|
-
theme
|
162
|
-
})};
|
163
|
-
border-color: ${(0, _constants.get)('colors.btn.danger.hoverBorder')({
|
164
|
-
theme
|
165
|
-
})};
|
166
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.danger.hoverShadow')({
|
167
|
-
theme
|
168
|
-
})};
|
169
|
-
}
|
170
|
-
// focus must come before :active so that the active box shadow overrides
|
171
|
-
&:focus {
|
172
|
-
border-color: ${(0, _constants.get)('colors.btn.danger.focusBorder')({
|
173
|
-
theme
|
174
|
-
})};
|
175
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.danger.focusShadow')({
|
176
|
-
theme
|
177
|
-
})};
|
178
|
-
}
|
179
|
-
|
180
|
-
&:active {
|
181
|
-
color: ${(0, _constants.get)('colors.btn.danger.selectedText')({
|
182
|
-
theme
|
183
|
-
})};
|
184
|
-
background-color: ${(0, _constants.get)('colors.btn.danger.selectedBg')({
|
185
|
-
theme
|
186
|
-
})};
|
187
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.danger.selectedShadow')({
|
188
|
-
theme
|
189
|
-
})};
|
190
|
-
border-color: ${(0, _constants.get)('colors.btn.danger.selectedBorder')({
|
191
|
-
theme
|
192
|
-
})};
|
193
|
-
}
|
194
|
-
|
195
|
-
&:disabled {
|
196
|
-
color: ${(0, _constants.get)('colors.btn.danger.disabledText')({
|
197
|
-
theme
|
198
|
-
})};
|
199
|
-
background-color: ${(0, _constants.get)('colors.btn.danger.disabledBg')({
|
200
|
-
theme
|
201
|
-
})};
|
202
|
-
border-color: ${(0, _constants.get)('colors.btn.danger.disabledBorder')({
|
203
|
-
theme
|
204
|
-
})};
|
205
|
-
}
|
206
|
-
`,
|
207
|
-
invisible: `
|
208
|
-
padding: 6px 16px;
|
209
|
-
color: ${(0, _constants.get)('colors.accent.fg')({
|
210
|
-
theme
|
211
|
-
})};
|
212
|
-
background-color: transparent;
|
213
|
-
border: 0;
|
214
|
-
border-radius: ${(0, _constants.get)('radii.2')({
|
215
|
-
theme
|
216
|
-
})};
|
217
|
-
box-shadow: none;
|
218
|
-
|
219
|
-
&:disabled {
|
220
|
-
color: ${(0, _constants.get)('colors.primer.fg.disabled')({
|
221
|
-
theme
|
222
|
-
})};
|
223
|
-
}
|
224
|
-
&:focus {
|
225
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.focusShadow')({
|
226
|
-
theme
|
227
|
-
})};
|
228
|
-
}
|
229
|
-
&:hover {
|
230
|
-
background-color: ${(0, _constants.get)('colors.btn.hoverBg')({
|
231
|
-
theme
|
232
|
-
})};
|
233
|
-
}
|
234
|
-
&:active {
|
235
|
-
background-color: ${(0, _constants.get)('colors.btn.selectedBg')({
|
236
|
-
theme
|
237
|
-
})};
|
238
|
-
}
|
239
|
-
`,
|
240
|
-
block: ``
|
241
|
-
};
|
242
|
-
return style[variant];
|
243
|
-
};
|
244
|
-
|
245
|
-
const ButtonBase = _styledComponents.default.button.withConfig({
|
246
|
-
displayName: "button__ButtonBase",
|
247
|
-
componentId: "sc-15k5iqk-0"
|
248
|
-
})(["", " ", " ", " ", " ", " ", ""], _ButtonStyles.default, props => getVariantStyles(props.theme, props.variant), sizes, props => props.iconOnly ? `padding: 4px 6px;` : '', _sx.default, _styledSystem.fontSize);
|
249
|
-
|
250
|
-
const Button = /*#__PURE__*/(0, _react.forwardRef)(({
|
251
|
-
icon: Icon,
|
252
|
-
children,
|
253
|
-
...props
|
254
|
-
}) => {
|
255
|
-
let iconOnly = false;
|
256
|
-
|
257
|
-
if (!children) {
|
258
|
-
iconOnly = true;
|
259
|
-
}
|
260
|
-
|
261
|
-
let iconWrapStyles = {
|
262
|
-
display: 'inline-block',
|
263
|
-
...(!iconOnly ? {
|
264
|
-
pr: 3
|
265
|
-
} : {})
|
266
|
-
};
|
267
|
-
return /*#__PURE__*/_react.default.createElement(ButtonBase, _extends({}, props, {
|
268
|
-
iconOnly: iconOnly
|
269
|
-
}), Icon && /*#__PURE__*/_react.default.createElement(_Box.default, {
|
270
|
-
sx: iconWrapStyles
|
271
|
-
}, /*#__PURE__*/_react.default.createElement(Icon, null)), children);
|
272
|
-
});
|
273
|
-
Button.displayName = 'Button';
|
274
|
-
Button.defaultProps = {
|
275
|
-
size: 'medium'
|
276
|
-
};
|
277
|
-
var _default = Button;
|
278
|
-
exports.default = _default;
|
package/lib/NewButton/index.d.ts
DELETED
package/lib/NewButton/index.js
DELETED
@@ -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,18 +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' | 'block' | 'danger';
|
6
|
-
export declare type ButtonProps = {
|
7
|
-
children: ReactNode;
|
8
|
-
variant: Variant;
|
9
|
-
size: 'small' | 'medium' | 'large';
|
10
|
-
icon?: React.FunctionComponent<IconProps>;
|
11
|
-
} & SxProp & FontSizeProps;
|
12
|
-
declare const Button: React.ForwardRefExoticComponent<{
|
13
|
-
children: ReactNode;
|
14
|
-
variant: Variant;
|
15
|
-
size: 'small' | 'medium' | 'large';
|
16
|
-
icon?: React.FunctionComponent<IconProps> | undefined;
|
17
|
-
} & SxProp & FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
18
|
-
export default Button;
|
@@ -1,256 +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 Box from '../Box';
|
5
|
-
import { fontSize, variant } from 'styled-system';
|
6
|
-
import styled from 'styled-components';
|
7
|
-
import sx from '../sx';
|
8
|
-
import { get } from '../constants';
|
9
|
-
import buttonBaseStyles from '../Button/ButtonStyles';
|
10
|
-
const sizes = variant({
|
11
|
-
prop: 'size',
|
12
|
-
variants: {
|
13
|
-
small: {
|
14
|
-
p: '4px 12px',
|
15
|
-
fontSize: 0
|
16
|
-
},
|
17
|
-
medium: {
|
18
|
-
fontSize: 1
|
19
|
-
},
|
20
|
-
large: {
|
21
|
-
fontSize: 2,
|
22
|
-
p: '10px 20px'
|
23
|
-
}
|
24
|
-
}
|
25
|
-
});
|
26
|
-
|
27
|
-
const getVariantStyles = (theme, variant = 'default') => {
|
28
|
-
const style = {
|
29
|
-
default: `
|
30
|
-
padding: 5px 16px;
|
31
|
-
color: ${get('colors.btn.text')({
|
32
|
-
theme
|
33
|
-
})};
|
34
|
-
background-color: ${get('colors.btn.bg')({
|
35
|
-
theme
|
36
|
-
})};
|
37
|
-
border-width: 1px;
|
38
|
-
border-style: solid;
|
39
|
-
border-color: ${get('colors.btn.border')({
|
40
|
-
theme
|
41
|
-
})};
|
42
|
-
box-shadow: ${(get('shadows.btn.shadow')({
|
43
|
-
theme
|
44
|
-
}), get('shadows.btn.insetShadow')({
|
45
|
-
theme
|
46
|
-
}))};
|
47
|
-
&:hover {
|
48
|
-
background-color: ${get('colors.btn.hoverBg')({
|
49
|
-
theme
|
50
|
-
})};
|
51
|
-
}
|
52
|
-
// focus must come before :active so that the active box shadow overrides
|
53
|
-
&:focus {
|
54
|
-
box-shadow: ${get('shadows.btn.focusShadow')({
|
55
|
-
theme
|
56
|
-
})};
|
57
|
-
}
|
58
|
-
&:active {
|
59
|
-
background-color: ${get('colors.btn.selectedBg')({
|
60
|
-
theme
|
61
|
-
})};
|
62
|
-
box-shadow: ${get('shadows.btn.shadowActive')({
|
63
|
-
theme
|
64
|
-
})};
|
65
|
-
}
|
66
|
-
&:disabled {
|
67
|
-
color: ${get('colors.primer.fg.disabled')({
|
68
|
-
theme
|
69
|
-
})};
|
70
|
-
}
|
71
|
-
`,
|
72
|
-
primary: `
|
73
|
-
padding: 5px 16px;
|
74
|
-
color: ${get('colors.btn.primary.text')({
|
75
|
-
theme
|
76
|
-
})};
|
77
|
-
background-color: ${get('colors.btn.primary.bg')({
|
78
|
-
theme
|
79
|
-
})};
|
80
|
-
border-width: 1px;
|
81
|
-
border-style: solid;
|
82
|
-
border-color: ${get('colors.border.subtle')({
|
83
|
-
theme
|
84
|
-
})};
|
85
|
-
box-shadow: ${get('shadows.btn.primary.shadow')({
|
86
|
-
theme
|
87
|
-
})};
|
88
|
-
|
89
|
-
&:hover {
|
90
|
-
color: ${get('colors.btn.primary.hoverText')({
|
91
|
-
theme
|
92
|
-
})};
|
93
|
-
background-color: ${get('colors.btn.primary.hoverBg')({
|
94
|
-
theme
|
95
|
-
})};
|
96
|
-
}
|
97
|
-
// focus must come before :active so that the active box shadow overrides
|
98
|
-
&:focus {
|
99
|
-
box-shadow: ${get('shadows.btn.primary.focusShadow')({
|
100
|
-
theme
|
101
|
-
})};
|
102
|
-
}
|
103
|
-
|
104
|
-
&:active {
|
105
|
-
background-color: ${get('colors.btn.primary.selectedBg')({
|
106
|
-
theme
|
107
|
-
})};
|
108
|
-
box-shadow: ${get('shadows.btn.primary.selectedShadow')({
|
109
|
-
theme
|
110
|
-
})};
|
111
|
-
}
|
112
|
-
|
113
|
-
&:disabled {
|
114
|
-
color: ${get('colors.btn.primary.disabledText')({
|
115
|
-
theme
|
116
|
-
})};
|
117
|
-
background-color: ${get('colors.btn.primary.disabledBg')({
|
118
|
-
theme
|
119
|
-
})};
|
120
|
-
}`,
|
121
|
-
danger: `
|
122
|
-
padding: 5px 16px;
|
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 {
|
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 {
|
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 {
|
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
|
-
padding: 6px 16px;
|
189
|
-
color: ${get('colors.accent.fg')({
|
190
|
-
theme
|
191
|
-
})};
|
192
|
-
background-color: transparent;
|
193
|
-
border: 0;
|
194
|
-
border-radius: ${get('radii.2')({
|
195
|
-
theme
|
196
|
-
})};
|
197
|
-
box-shadow: none;
|
198
|
-
|
199
|
-
&:disabled {
|
200
|
-
color: ${get('colors.primer.fg.disabled')({
|
201
|
-
theme
|
202
|
-
})};
|
203
|
-
}
|
204
|
-
&:focus {
|
205
|
-
box-shadow: ${get('shadows.btn.focusShadow')({
|
206
|
-
theme
|
207
|
-
})};
|
208
|
-
}
|
209
|
-
&:hover {
|
210
|
-
background-color: ${get('colors.btn.hoverBg')({
|
211
|
-
theme
|
212
|
-
})};
|
213
|
-
}
|
214
|
-
&:active {
|
215
|
-
background-color: ${get('colors.btn.selectedBg')({
|
216
|
-
theme
|
217
|
-
})};
|
218
|
-
}
|
219
|
-
`,
|
220
|
-
block: ``
|
221
|
-
};
|
222
|
-
return style[variant];
|
223
|
-
};
|
224
|
-
|
225
|
-
const ButtonBase = styled.button.withConfig({
|
226
|
-
displayName: "button__ButtonBase",
|
227
|
-
componentId: "sc-15k5iqk-0"
|
228
|
-
})(["", " ", " ", " ", " ", " ", ""], buttonBaseStyles, props => getVariantStyles(props.theme, props.variant), sizes, props => props.iconOnly ? `padding: 4px 6px;` : '', sx, fontSize);
|
229
|
-
const Button = /*#__PURE__*/forwardRef(({
|
230
|
-
icon: Icon,
|
231
|
-
children,
|
232
|
-
...props
|
233
|
-
}) => {
|
234
|
-
let iconOnly = false;
|
235
|
-
|
236
|
-
if (!children) {
|
237
|
-
iconOnly = true;
|
238
|
-
}
|
239
|
-
|
240
|
-
let iconWrapStyles = {
|
241
|
-
display: 'inline-block',
|
242
|
-
...(!iconOnly ? {
|
243
|
-
pr: 3
|
244
|
-
} : {})
|
245
|
-
};
|
246
|
-
return /*#__PURE__*/React.createElement(ButtonBase, _extends({}, props, {
|
247
|
-
iconOnly: iconOnly
|
248
|
-
}), Icon && /*#__PURE__*/React.createElement(Box, {
|
249
|
-
sx: iconWrapStyles
|
250
|
-
}, /*#__PURE__*/React.createElement(Icon, null)), children);
|
251
|
-
});
|
252
|
-
Button.displayName = 'Button';
|
253
|
-
Button.defaultProps = {
|
254
|
-
size: 'medium'
|
255
|
-
};
|
256
|
-
export default Button;
|