@primer/components 0.0.0-20219266052 → 0.0.0-202192723547
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 +14 -4
- package/dist/browser.esm.js +436 -439
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +444 -447
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.d.ts +6 -0
- package/lib/ActionList/Item.js +5 -1
- package/lib/Dialog/Dialog.d.ts +5 -5
- package/lib/Dialog/Dialog.js +13 -22
- package/lib-esm/ActionList/Item.d.ts +6 -0
- package/lib-esm/ActionList/Item.js +5 -1
- package/lib-esm/Dialog/Dialog.d.ts +5 -5
- package/lib-esm/Dialog/Dialog.js +13 -21
- package/package.json +1 -1
package/lib/ActionList/Item.d.ts
CHANGED
@@ -28,13 +28,19 @@ export interface ItemProps extends SxProp {
|
|
28
28
|
*/
|
29
29
|
leadingVisual?: React.FunctionComponent<IconProps>;
|
30
30
|
/**
|
31
|
+
* @deprecated Use `trailingVisual` instead
|
31
32
|
* Icon (or similar) positioned after `Item` text.
|
32
33
|
*/
|
33
34
|
trailingIcon?: React.FunctionComponent<IconProps>;
|
34
35
|
/**
|
36
|
+
* @deprecated Use `trailingVisual` instead
|
35
37
|
* Text positioned after `Item` text and optional trailing icon.
|
36
38
|
*/
|
37
39
|
trailingText?: string;
|
40
|
+
/**
|
41
|
+
* Icon or text positioned after `Item` text.
|
42
|
+
*/
|
43
|
+
trailingVisual?: React.ReactNode;
|
38
44
|
/**
|
39
45
|
* Style variations associated with various `Item` types.
|
40
46
|
*
|
package/lib/ActionList/Item.js
CHANGED
@@ -187,6 +187,7 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
|
|
187
187
|
selectionVariant,
|
188
188
|
leadingVisual: LeadingVisual,
|
189
189
|
trailingIcon: TrailingIcon,
|
190
|
+
trailingVisual: TrailingVisual,
|
190
191
|
trailingText,
|
191
192
|
variant = 'default',
|
192
193
|
showDivider,
|
@@ -278,7 +279,10 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
|
|
278
279
|
title: description,
|
279
280
|
inline: true,
|
280
281
|
maxWidth: "100%"
|
281
|
-
}, description)) : null),
|
282
|
+
}, description)) : null), TrailingVisual ? /*#__PURE__*/_react.default.createElement(TrailingContent, {
|
283
|
+
variant: variant,
|
284
|
+
disabled: disabled
|
285
|
+
}, typeof TrailingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(TrailingVisual, null) : TrailingVisual) : TrailingIcon || trailingText ? /*#__PURE__*/_react.default.createElement(TrailingContent, {
|
282
286
|
variant: variant,
|
283
287
|
disabled: disabled
|
284
288
|
}, trailingText, TrailingIcon && /*#__PURE__*/_react.default.createElement(TrailingIcon, null)) : null));
|
package/lib/Dialog/Dialog.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { ButtonProps } from '../
|
2
|
+
import { ButtonProps } from '../NewButton';
|
3
3
|
import { SxProp } from '../sx';
|
4
4
|
/**
|
5
5
|
* Props that characterize a button to be rendered into the footer of
|
@@ -9,7 +9,7 @@ export declare type DialogButtonProps = ButtonProps & {
|
|
9
9
|
/**
|
10
10
|
* The type of Button element to use
|
11
11
|
*/
|
12
|
-
buttonType?: '
|
12
|
+
buttonType?: 'default' | 'primary' | 'danger' | 'invisible';
|
13
13
|
/**
|
14
14
|
* The Button's inner text
|
15
15
|
*/
|
@@ -160,8 +160,8 @@ export declare const Dialog: React.ForwardRefExoticComponent<DialogProps & {
|
|
160
160
|
Buttons: React.FC<{
|
161
161
|
buttons: DialogButtonProps[];
|
162
162
|
}>;
|
163
|
-
CloseButton:
|
164
|
-
onClose:
|
165
|
-
}
|
163
|
+
CloseButton: ({ onClose }: {
|
164
|
+
onClose: any;
|
165
|
+
}) => JSX.Element;
|
166
166
|
};
|
167
167
|
export {};
|
package/lib/Dialog/Dialog.js
CHANGED
@@ -9,7 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
10
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
11
11
|
|
12
|
-
var
|
12
|
+
var _NewButton = _interopRequireDefault(require("../NewButton"));
|
13
13
|
|
14
14
|
var _Box = _interopRequireDefault(require("../Box"));
|
15
15
|
|
@@ -21,8 +21,6 @@ var _useFocusTrap = require("../hooks/useFocusTrap");
|
|
21
21
|
|
22
22
|
var _sx = _interopRequireDefault(require("../sx"));
|
23
23
|
|
24
|
-
var _StyledOcticon = _interopRequireDefault(require("../StyledOcticon"));
|
25
|
-
|
26
24
|
var _octiconsReact = require("@primer/octicons-react");
|
27
25
|
|
28
26
|
var _useFocusZone = require("../hooks/useFocusZone");
|
@@ -213,11 +211,7 @@ const Footer = (0, _styledComponents.default)(_Box.default).attrs({
|
|
213
211
|
displayName: "Dialog__Footer",
|
214
212
|
componentId: "sc-11pkgky-6"
|
215
213
|
})(["box-shadow:0 -1px 0 ", ";padding:", ";display:flex;flex-flow:wrap;justify-content:flex-end;z-index:1;flex-shrink:0;button{margin-left:", ";&:first-child{margin-left:0;}}"], (0, _constants.get)('colors.border.default'), (0, _constants.get)('space.3'), (0, _constants.get)('space.1'));
|
216
|
-
const buttonTypes =
|
217
|
-
normal: _Button.default,
|
218
|
-
primary: _Button.ButtonPrimary,
|
219
|
-
danger: _Button.ButtonDanger
|
220
|
-
};
|
214
|
+
const buttonTypes = ['default', 'primary', 'danger'];
|
221
215
|
|
222
216
|
const Buttons = ({
|
223
217
|
buttons
|
@@ -240,33 +234,30 @@ const Buttons = ({
|
|
240
234
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, buttons.map((dialogButtonProps, index) => {
|
241
235
|
const {
|
242
236
|
content,
|
243
|
-
buttonType = '
|
237
|
+
buttonType = 'default',
|
244
238
|
autoFocus = false,
|
245
239
|
...buttonProps
|
246
240
|
} = dialogButtonProps;
|
247
|
-
|
248
|
-
return /*#__PURE__*/_react.default.createElement(ButtonElement, _extends({
|
241
|
+
return /*#__PURE__*/_react.default.createElement(_NewButton.default, _extends({
|
249
242
|
key: index
|
250
243
|
}, buttonProps, {
|
244
|
+
variant: buttonType,
|
251
245
|
ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++, autoFocusRef) : null
|
252
246
|
}), content);
|
253
247
|
}));
|
254
248
|
};
|
255
249
|
|
256
|
-
const DialogCloseButton = (0, _styledComponents.default)(_Button.default).withConfig({
|
257
|
-
displayName: "Dialog__DialogCloseButton",
|
258
|
-
componentId: "sc-11pkgky-7"
|
259
|
-
})(["border-radius:4px;background:transparent;border:0;vertical-align:middle;color:", ";padding:", ";align-self:flex-start;line-height:normal;box-shadow:none;"], (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'));
|
260
|
-
|
261
250
|
const CloseButton = ({
|
262
251
|
onClose
|
263
252
|
}) => {
|
264
|
-
return /*#__PURE__*/_react.default.createElement(
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
253
|
+
return /*#__PURE__*/_react.default.createElement(_NewButton.default, {
|
254
|
+
sx: {
|
255
|
+
alignSelf: 'flex-start'
|
256
|
+
},
|
257
|
+
variant: "invisible",
|
258
|
+
onClick: onClose,
|
259
|
+
icon: () => /*#__PURE__*/_react.default.createElement(_octiconsReact.XIcon, null)
|
260
|
+
});
|
270
261
|
};
|
271
262
|
|
272
263
|
CloseButton.displayName = "CloseButton";
|
@@ -28,13 +28,19 @@ export interface ItemProps extends SxProp {
|
|
28
28
|
*/
|
29
29
|
leadingVisual?: React.FunctionComponent<IconProps>;
|
30
30
|
/**
|
31
|
+
* @deprecated Use `trailingVisual` instead
|
31
32
|
* Icon (or similar) positioned after `Item` text.
|
32
33
|
*/
|
33
34
|
trailingIcon?: React.FunctionComponent<IconProps>;
|
34
35
|
/**
|
36
|
+
* @deprecated Use `trailingVisual` instead
|
35
37
|
* Text positioned after `Item` text and optional trailing icon.
|
36
38
|
*/
|
37
39
|
trailingText?: string;
|
40
|
+
/**
|
41
|
+
* Icon or text positioned after `Item` text.
|
42
|
+
*/
|
43
|
+
trailingVisual?: React.ReactNode;
|
38
44
|
/**
|
39
45
|
* Style variations associated with various `Item` types.
|
40
46
|
*
|
@@ -154,6 +154,7 @@ export const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
|
|
154
154
|
selectionVariant,
|
155
155
|
leadingVisual: LeadingVisual,
|
156
156
|
trailingIcon: TrailingIcon,
|
157
|
+
trailingVisual: TrailingVisual,
|
157
158
|
trailingText,
|
158
159
|
variant = 'default',
|
159
160
|
showDivider,
|
@@ -245,7 +246,10 @@ export const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
|
|
245
246
|
title: description,
|
246
247
|
inline: true,
|
247
248
|
maxWidth: "100%"
|
248
|
-
}, description)) : null),
|
249
|
+
}, description)) : null), TrailingVisual ? /*#__PURE__*/React.createElement(TrailingContent, {
|
250
|
+
variant: variant,
|
251
|
+
disabled: disabled
|
252
|
+
}, typeof TrailingVisual === 'function' ? /*#__PURE__*/React.createElement(TrailingVisual, null) : TrailingVisual) : TrailingIcon || trailingText ? /*#__PURE__*/React.createElement(TrailingContent, {
|
249
253
|
variant: variant,
|
250
254
|
disabled: disabled
|
251
255
|
}, trailingText, TrailingIcon && /*#__PURE__*/React.createElement(TrailingIcon, null)) : null));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { ButtonProps } from '../
|
2
|
+
import { ButtonProps } from '../NewButton';
|
3
3
|
import { SxProp } from '../sx';
|
4
4
|
/**
|
5
5
|
* Props that characterize a button to be rendered into the footer of
|
@@ -9,7 +9,7 @@ export declare type DialogButtonProps = ButtonProps & {
|
|
9
9
|
/**
|
10
10
|
* The type of Button element to use
|
11
11
|
*/
|
12
|
-
buttonType?: '
|
12
|
+
buttonType?: 'default' | 'primary' | 'danger' | 'invisible';
|
13
13
|
/**
|
14
14
|
* The Button's inner text
|
15
15
|
*/
|
@@ -160,8 +160,8 @@ export declare const Dialog: React.ForwardRefExoticComponent<DialogProps & {
|
|
160
160
|
Buttons: React.FC<{
|
161
161
|
buttons: DialogButtonProps[];
|
162
162
|
}>;
|
163
|
-
CloseButton:
|
164
|
-
onClose:
|
165
|
-
}
|
163
|
+
CloseButton: ({ onClose }: {
|
164
|
+
onClose: any;
|
165
|
+
}) => JSX.Element;
|
166
166
|
};
|
167
167
|
export {};
|
package/lib-esm/Dialog/Dialog.js
CHANGED
@@ -2,13 +2,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
2
2
|
|
3
3
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
4
4
|
import styled from 'styled-components';
|
5
|
-
import
|
5
|
+
import NewButton from '../NewButton';
|
6
6
|
import Box from '../Box';
|
7
7
|
import { get, COMMON, POSITION } from '../constants';
|
8
8
|
import { useOnEscapePress, useProvidedRefOrCreate } from '../hooks';
|
9
9
|
import { useFocusTrap } from '../hooks/useFocusTrap';
|
10
10
|
import sx from '../sx';
|
11
|
-
import StyledOcticon from '../StyledOcticon';
|
12
11
|
import { XIcon } from '@primer/octicons-react';
|
13
12
|
import { useFocusZone } from '../hooks/useFocusZone';
|
14
13
|
import { FocusKeys } from '../behaviors/focusZone';
|
@@ -184,11 +183,7 @@ const Footer = styled(Box).attrs({
|
|
184
183
|
displayName: "Dialog__Footer",
|
185
184
|
componentId: "sc-11pkgky-6"
|
186
185
|
})(["box-shadow:0 -1px 0 ", ";padding:", ";display:flex;flex-flow:wrap;justify-content:flex-end;z-index:1;flex-shrink:0;button{margin-left:", ";&:first-child{margin-left:0;}}"], get('colors.border.default'), get('space.3'), get('space.1'));
|
187
|
-
const buttonTypes =
|
188
|
-
normal: Button,
|
189
|
-
primary: ButtonPrimary,
|
190
|
-
danger: ButtonDanger
|
191
|
-
};
|
186
|
+
const buttonTypes = ['default', 'primary', 'danger'];
|
192
187
|
|
193
188
|
const Buttons = ({
|
194
189
|
buttons
|
@@ -211,33 +206,30 @@ const Buttons = ({
|
|
211
206
|
return /*#__PURE__*/React.createElement(React.Fragment, null, buttons.map((dialogButtonProps, index) => {
|
212
207
|
const {
|
213
208
|
content,
|
214
|
-
buttonType = '
|
209
|
+
buttonType = 'default',
|
215
210
|
autoFocus = false,
|
216
211
|
...buttonProps
|
217
212
|
} = dialogButtonProps;
|
218
|
-
|
219
|
-
return /*#__PURE__*/React.createElement(ButtonElement, _extends({
|
213
|
+
return /*#__PURE__*/React.createElement(NewButton, _extends({
|
220
214
|
key: index
|
221
215
|
}, buttonProps, {
|
216
|
+
variant: buttonType,
|
222
217
|
ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++, autoFocusRef) : null
|
223
218
|
}), content);
|
224
219
|
}));
|
225
220
|
};
|
226
221
|
|
227
|
-
const DialogCloseButton = styled(Button).withConfig({
|
228
|
-
displayName: "Dialog__DialogCloseButton",
|
229
|
-
componentId: "sc-11pkgky-7"
|
230
|
-
})(["border-radius:4px;background:transparent;border:0;vertical-align:middle;color:", ";padding:", ";align-self:flex-start;line-height:normal;box-shadow:none;"], get('colors.fg.muted'), get('space.2'));
|
231
|
-
|
232
222
|
const CloseButton = ({
|
233
223
|
onClose
|
234
224
|
}) => {
|
235
|
-
return /*#__PURE__*/React.createElement(
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
225
|
+
return /*#__PURE__*/React.createElement(NewButton, {
|
226
|
+
sx: {
|
227
|
+
alignSelf: 'flex-start'
|
228
|
+
},
|
229
|
+
variant: "invisible",
|
230
|
+
onClick: onClose,
|
231
|
+
icon: () => /*#__PURE__*/React.createElement(XIcon, null)
|
232
|
+
});
|
241
233
|
};
|
242
234
|
|
243
235
|
CloseButton.displayName = "CloseButton";
|