@primer/components 0.0.0-2021828202352 → 0.0.0-202182821115
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 +6 -2
- package/dist/browser.esm.js +241 -242
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +695 -696
- package/dist/browser.umd.js.map +1 -1
- package/lib/AvatarStack.d.ts +4 -8
- package/lib/AvatarStack.js +6 -7
- package/lib/Dialog/ConfirmationDialog.js +3 -3
- package/lib/Dialog/Dialog.d.ts +5 -0
- package/lib/Dialog/Dialog.js +16 -4
- package/lib/theme-preval.d.ts +58 -4
- package/lib/theme-preval.js +1818 -3701
- package/lib/utils/testing.d.ts +7378 -896
- package/lib-esm/AvatarStack.d.ts +4 -8
- package/lib-esm/AvatarStack.js +7 -8
- package/lib-esm/Dialog/ConfirmationDialog.js +3 -3
- package/lib-esm/Dialog/Dialog.d.ts +5 -0
- package/lib-esm/Dialog/Dialog.js +17 -5
- package/lib-esm/theme-preval.d.ts +58 -4
- package/lib-esm/theme-preval.js +1818 -3701
- package/lib-esm/utils/testing.d.ts +7378 -896
- package/package.json +2 -2
package/lib/AvatarStack.d.ts
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
|
2
|
-
import { SystemCommonProps } from './constants';
|
1
|
+
import React from 'react';
|
3
2
|
import { SxProp } from './sx';
|
4
|
-
import { ComponentProps } from './utils/types';
|
5
|
-
declare const AvatarStackWrapper: import("styled-components").StyledComponent<"span", any, {
|
6
|
-
count?: number | undefined;
|
7
|
-
} & SystemCommonProps & SxProp, never>;
|
8
3
|
export declare type AvatarStackProps = {
|
9
4
|
alignRight?: boolean;
|
10
|
-
|
11
|
-
|
5
|
+
children: React.ReactNode;
|
6
|
+
} & SxProp;
|
7
|
+
declare const AvatarStack: ({ children, alignRight, sx: sxProp }: AvatarStackProps) => JSX.Element;
|
12
8
|
export default AvatarStack;
|
package/lib/AvatarStack.js
CHANGED
@@ -19,12 +19,10 @@ var _sx = _interopRequireDefault(require("./sx"));
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
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); }
|
23
|
-
|
24
22
|
const AvatarStackWrapper = _styledComponents.default.span.withConfig({
|
25
23
|
displayName: "AvatarStack__AvatarStackWrapper",
|
26
24
|
componentId: "sc-1qgzd2v-0"
|
27
|
-
})(["display:flex;position:relative;height:20px;min-width:", ";.pc-AvatarItem{flex-shrink:0;height:20px;width:20px;box-shadow:0 0 0 1px ", ";margin-left:-11px;position:relative;overflow:hidden;transition:margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;&:first-child{margin-left:0;}&:nth-child(n + 4){display:none;}}&.pc-AvatarStack--two{min-width:30px;.pc-AvatarItem{&:nth-child(n + 3){display:none;}}}&.pc-AvatarStack--three-plus{min-width:38px;.pc-AvatarItem{&:nth-child(3){opacity:", "%;margin-left:-17px;}&:nth-child(4){opacity:", "%;margin-left:-17px;}&:nth-child(5){opacity:", "%;margin-left:-17px;}&:nth-child(n + 4){display:block;}&:nth-child(n + 6){opacity:0;visibility:hidden;}}}&.pc-AvatarStack--right{justify-content:flex-end;.pc-AvatarItem{margin-left:0 !important;margin-right:-11px;&:first-child{margin-right:0;}}.pc-AvatarStackBody{flex-direction:row-reverse;&:hover{.pc-AvatarItem{margin-right:", "!important;margin-left:0 !important;&:first-child{margin-right:0 !important;}}}}}&.pc-AvatarStack--three-plus.pc-AvatarStack--right{.pc-AvatarItem{&:nth-child(3){margin-right:-17px;}&:nth-child(4){margin-right:-17px;}&:nth-child(5){margin-right:-17px;}}}.pc-AvatarStackBody:hover{width:auto;.pc-AvatarItem{margin-left:", ";opacity:100%;visibility:visible;box-shadow:0 0 0 4px ", ";&:first-child{margin-left:0;}}}", "
|
25
|
+
})(["display:flex;position:relative;height:20px;min-width:", ";.pc-AvatarItem{flex-shrink:0;height:20px;width:20px;box-shadow:0 0 0 1px ", ";margin-left:-11px;position:relative;overflow:hidden;transition:margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;&:first-child{margin-left:0;}&:nth-child(n + 4){display:none;}}&.pc-AvatarStack--two{min-width:30px;.pc-AvatarItem{&:nth-child(n + 3){display:none;}}}&.pc-AvatarStack--three-plus{min-width:38px;.pc-AvatarItem{&:nth-child(3){opacity:", "%;margin-left:-17px;}&:nth-child(4){opacity:", "%;margin-left:-17px;}&:nth-child(5){opacity:", "%;margin-left:-17px;}&:nth-child(n + 4){display:block;}&:nth-child(n + 6){opacity:0;visibility:hidden;}}}&.pc-AvatarStack--right{justify-content:flex-end;.pc-AvatarItem{margin-left:0 !important;margin-right:-11px;&:first-child{margin-right:0;}}.pc-AvatarStackBody{flex-direction:row-reverse;&:hover{.pc-AvatarItem{margin-right:", "!important;margin-left:0 !important;&:first-child{margin-right:0 !important;}}}}}&.pc-AvatarStack--three-plus.pc-AvatarStack--right{.pc-AvatarItem{&:nth-child(3){margin-right:-17px;}&:nth-child(4){margin-right:-17px;}&:nth-child(5){margin-right:-17px;}}}.pc-AvatarStackBody:hover{width:auto;.pc-AvatarItem{margin-left:", ";opacity:100%;visibility:visible;box-shadow:0 0 0 4px ", ";&:first-child{margin-left:0;}}}", ";"], props => props.count === 1 ? '20px' : props.count === 2 ? '30px' : '38px', (0, _constants.get)('colors.canvas.default'), 100 - 3 * 15, 100 - 4 * 15, 100 - 5 * 15, (0, _constants.get)('space.1'), (0, _constants.get)('space.1'), (0, _constants.get)('colors.canvas.default'), _sx.default);
|
28
26
|
|
29
27
|
const transformChildren = children => {
|
30
28
|
return _react.default.Children.map(children, (child, index) => {
|
@@ -42,7 +40,7 @@ const transformChildren = children => {
|
|
42
40
|
const AvatarStack = ({
|
43
41
|
children,
|
44
42
|
alignRight,
|
45
|
-
|
43
|
+
sx: sxProp
|
46
44
|
}) => {
|
47
45
|
const count = _react.default.Children.count(children);
|
48
46
|
|
@@ -51,10 +49,11 @@ const AvatarStack = ({
|
|
51
49
|
'pc-AvatarStack--three-plus': count > 2,
|
52
50
|
'pc-AvatarStack--right': alignRight
|
53
51
|
});
|
54
|
-
return /*#__PURE__*/_react.default.createElement(AvatarStackWrapper,
|
52
|
+
return /*#__PURE__*/_react.default.createElement(AvatarStackWrapper, {
|
55
53
|
count: count,
|
56
|
-
className: wrapperClassNames
|
57
|
-
|
54
|
+
className: wrapperClassNames,
|
55
|
+
sx: sxProp
|
56
|
+
}, /*#__PURE__*/_react.default.createElement(_.Box, {
|
58
57
|
position: "absolute",
|
59
58
|
display: "flex",
|
60
59
|
width: "38px",
|
@@ -117,13 +117,13 @@ const ConfirmationDialog = props => {
|
|
117
117
|
}, [onClose]);
|
118
118
|
const cancelButton = {
|
119
119
|
content: cancelButtonContent,
|
120
|
-
onClick: onCancelButtonClick
|
121
|
-
autoFocus: true
|
120
|
+
onClick: onCancelButtonClick
|
122
121
|
};
|
123
122
|
const confirmButton = {
|
124
123
|
content: confirmButtonContent,
|
125
124
|
buttonType: confirmButtonType,
|
126
|
-
onClick: onConfirmButtonClick
|
125
|
+
onClick: onConfirmButtonClick,
|
126
|
+
autoFocus: true
|
127
127
|
};
|
128
128
|
const footerButtons = [cancelButton, confirmButton];
|
129
129
|
return /*#__PURE__*/_react.default.createElement(_Dialog.Dialog, {
|
package/lib/Dialog/Dialog.d.ts
CHANGED
@@ -19,6 +19,11 @@ export declare type DialogButtonProps = ButtonProps & {
|
|
19
19
|
* focus this button automatically when the dialog appears.
|
20
20
|
*/
|
21
21
|
autoFocus?: boolean;
|
22
|
+
/**
|
23
|
+
* A reference to the rendered Button’s DOM node, used together with
|
24
|
+
* `autoFocus` for `focusTrap`’s `initialFocus`.
|
25
|
+
*/
|
26
|
+
ref?: React.RefObject<HTMLButtonElement>;
|
22
27
|
};
|
23
28
|
/**
|
24
29
|
* Props to customize the rendering of the Dialog.
|
package/lib/Dialog/Dialog.js
CHANGED
@@ -141,10 +141,19 @@ const _Dialog = /*#__PURE__*/_react.default.forwardRef((props, forwardedRef) =>
|
|
141
141
|
onClose,
|
142
142
|
role = 'dialog',
|
143
143
|
width = 'xlarge',
|
144
|
-
height = 'auto'
|
144
|
+
height = 'auto',
|
145
|
+
footerButtons = []
|
145
146
|
} = props;
|
146
147
|
const dialogLabelId = (0, _ssr.useSSRSafeId)();
|
147
148
|
const dialogDescriptionId = (0, _ssr.useSSRSafeId)();
|
149
|
+
const autoFocusedFooterButtonRef = (0, _react.useRef)(null);
|
150
|
+
|
151
|
+
for (const footerButton of footerButtons) {
|
152
|
+
if (footerButton.autoFocus) {
|
153
|
+
footerButton.ref = autoFocusedFooterButtonRef;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
148
157
|
const defaultedProps = { ...props,
|
149
158
|
title,
|
150
159
|
subtitle,
|
@@ -157,7 +166,8 @@ const _Dialog = /*#__PURE__*/_react.default.forwardRef((props, forwardedRef) =>
|
|
157
166
|
const backdropRef = (0, _react.useRef)(null);
|
158
167
|
(0, _useFocusTrap.useFocusTrap)({
|
159
168
|
containerRef: dialogRef,
|
160
|
-
restoreFocusOnCleanUp: true
|
169
|
+
restoreFocusOnCleanUp: true,
|
170
|
+
initialFocusRef: autoFocusedFooterButtonRef
|
161
171
|
});
|
162
172
|
(0, _hooks.useOnEscapePress)(event => {
|
163
173
|
onClose('escape');
|
@@ -212,7 +222,9 @@ const buttonTypes = {
|
|
212
222
|
const Buttons = ({
|
213
223
|
buttons
|
214
224
|
}) => {
|
215
|
-
|
225
|
+
var _buttons$find;
|
226
|
+
|
227
|
+
const autoFocusRef = (0, _hooks.useProvidedRefOrCreate)((_buttons$find = buttons.find(button => button.autoFocus)) === null || _buttons$find === void 0 ? void 0 : _buttons$find.ref);
|
216
228
|
let autoFocusCount = 0;
|
217
229
|
const [hasRendered, setHasRendered] = (0, _react.useState)(0);
|
218
230
|
(0, _react.useEffect)(() => {
|
@@ -224,7 +236,7 @@ const Buttons = ({
|
|
224
236
|
} else {
|
225
237
|
setHasRendered(hasRendered + 1);
|
226
238
|
}
|
227
|
-
}, [hasRendered]);
|
239
|
+
}, [autoFocusRef, hasRendered]);
|
228
240
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, buttons.map((dialogButtonProps, index) => {
|
229
241
|
const {
|
230
242
|
content,
|
package/lib/theme-preval.d.ts
CHANGED
@@ -9,7 +9,24 @@ export namespace theme {
|
|
9
9
|
export { radii };
|
10
10
|
export { sizes };
|
11
11
|
export { space };
|
12
|
-
export
|
12
|
+
export namespace colorSchemes {
|
13
|
+
namespace light {
|
14
|
+
export { lightColors as colors };
|
15
|
+
export { lightShadows as shadows };
|
16
|
+
}
|
17
|
+
namespace dark {
|
18
|
+
export { darkColors as colors };
|
19
|
+
export { darkShadows as shadows };
|
20
|
+
}
|
21
|
+
namespace dark_dimmed {
|
22
|
+
export { darkDimmedColors as colors };
|
23
|
+
export { darkDimmedShadows as shadows };
|
24
|
+
}
|
25
|
+
namespace dark_high_contrast {
|
26
|
+
export { darkHighContrastColors as colors };
|
27
|
+
export { darkHighContrastShadows as shadows };
|
28
|
+
}
|
29
|
+
}
|
13
30
|
}
|
14
31
|
declare namespace animation {
|
15
32
|
const easeOutCubic: string;
|
@@ -22,7 +39,8 @@ declare namespace fonts {
|
|
22
39
|
}
|
23
40
|
declare const fontSizes: string[];
|
24
41
|
declare namespace fontWeights {
|
25
|
-
|
42
|
+
const light_1: number;
|
43
|
+
export { light_1 as light };
|
26
44
|
const normal_1: number;
|
27
45
|
export { normal_1 as normal };
|
28
46
|
export const semibold: number;
|
@@ -42,8 +60,44 @@ declare namespace sizes {
|
|
42
60
|
}
|
43
61
|
declare const space: string[];
|
44
62
|
/**
|
45
|
-
* @type
|
63
|
+
* @type Partial<typeof primitives.colors.light>
|
46
64
|
*/
|
47
|
-
declare const
|
65
|
+
declare const lightColors: Partial<typeof primitives.colors.light>;
|
66
|
+
/**
|
67
|
+
* @type Partial<typeof primitives.colors.light>
|
68
|
+
*/
|
69
|
+
declare const lightShadows: Partial<typeof primitives.colors.light>;
|
70
|
+
/**
|
71
|
+
* @type Partial<typeof primitives.colors.dark>
|
72
|
+
*/
|
73
|
+
declare const darkColors: Partial<typeof primitives.colors.dark>;
|
74
|
+
/**
|
75
|
+
* @type Partial<typeof primitives.colors.dark>
|
76
|
+
*/
|
77
|
+
declare const darkShadows: Partial<typeof primitives.colors.dark>;
|
78
|
+
/**
|
79
|
+
* @type Partial<typeof primitives.colors.dark_dimmed>
|
80
|
+
*/
|
81
|
+
declare const darkDimmedColors: Partial<typeof primitives.colors.dark_dimmed>;
|
82
|
+
/**
|
83
|
+
* @type Partial<typeof primitives.colors.dark_dimmed>
|
84
|
+
*/
|
85
|
+
declare const darkDimmedShadows: Partial<typeof primitives.colors.dark_dimmed>;
|
86
|
+
/**
|
87
|
+
* @type Partial<typeof primitives.colors.dark_dimmed>
|
88
|
+
*/
|
89
|
+
declare const darkHighContrastColors: Partial<typeof primitives.colors.dark_dimmed>;
|
90
|
+
/**
|
91
|
+
* @type Partial<typeof primitives.colors.dark_high_contrast>
|
92
|
+
*/
|
93
|
+
declare const darkHighContrastShadows: Partial<typeof primitives.colors.dark_high_contrast>;
|
48
94
|
import { default as primitives } from "@primer/primitives";
|
95
|
+
declare const light_2: {
|
96
|
+
colors: {};
|
97
|
+
shadows: {};
|
98
|
+
};
|
99
|
+
declare const dark_1: {
|
100
|
+
colors: {};
|
101
|
+
shadows: {};
|
102
|
+
};
|
49
103
|
export {};
|