@primer/components 0.0.0-202182921545 → 0.0.0-2021829233555
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 +11 -5
- package/dist/browser.esm.js +241 -241
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +695 -695
- package/dist/browser.umd.js.map +1 -1
- package/lib/Dialog/ConfirmationDialog.js +3 -3
- package/lib/Dialog/Dialog.d.ts +0 -5
- package/lib/Dialog/Dialog.js +4 -16
- package/lib/theme-preval.d.ts +4 -58
- package/lib/theme-preval.js +3696 -1813
- package/lib/utils/testing.d.ts +889 -7380
- package/lib-esm/Dialog/ConfirmationDialog.js +3 -3
- package/lib-esm/Dialog/Dialog.d.ts +0 -5
- package/lib-esm/Dialog/Dialog.js +5 -17
- package/lib-esm/theme-preval.d.ts +4 -58
- package/lib-esm/theme-preval.js +3696 -1813
- package/lib-esm/utils/testing.d.ts +889 -7380
- package/package.json +4 -4
@@ -97,13 +97,13 @@ export const ConfirmationDialog = props => {
|
|
97
97
|
}, [onClose]);
|
98
98
|
const cancelButton = {
|
99
99
|
content: cancelButtonContent,
|
100
|
-
onClick: onCancelButtonClick
|
100
|
+
onClick: onCancelButtonClick,
|
101
|
+
autoFocus: true
|
101
102
|
};
|
102
103
|
const confirmButton = {
|
103
104
|
content: confirmButtonContent,
|
104
105
|
buttonType: confirmButtonType,
|
105
|
-
onClick: onConfirmButtonClick
|
106
|
-
autoFocus: true
|
106
|
+
onClick: onConfirmButtonClick
|
107
107
|
};
|
108
108
|
const footerButtons = [cancelButton, confirmButton];
|
109
109
|
return /*#__PURE__*/React.createElement(Dialog, {
|
@@ -19,11 +19,6 @@ 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>;
|
27
22
|
};
|
28
23
|
/**
|
29
24
|
* Props to customize the rendering of the Dialog.
|
package/lib-esm/Dialog/Dialog.js
CHANGED
@@ -5,7 +5,7 @@ import styled from 'styled-components';
|
|
5
5
|
import Button, { ButtonPrimary, ButtonDanger } from '../Button';
|
6
6
|
import Box from '../Box';
|
7
7
|
import { get, COMMON, POSITION } from '../constants';
|
8
|
-
import { useOnEscapePress
|
8
|
+
import { useOnEscapePress } from '../hooks';
|
9
9
|
import { useFocusTrap } from '../hooks/useFocusTrap';
|
10
10
|
import sx from '../sx';
|
11
11
|
import StyledOcticon from '../StyledOcticon';
|
@@ -112,19 +112,10 @@ const _Dialog = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
112
112
|
onClose,
|
113
113
|
role = 'dialog',
|
114
114
|
width = 'xlarge',
|
115
|
-
height = 'auto'
|
116
|
-
footerButtons = []
|
115
|
+
height = 'auto'
|
117
116
|
} = props;
|
118
117
|
const dialogLabelId = useSSRSafeId();
|
119
118
|
const dialogDescriptionId = useSSRSafeId();
|
120
|
-
const autoFocusedFooterButtonRef = useRef(null);
|
121
|
-
|
122
|
-
for (const footerButton of footerButtons) {
|
123
|
-
if (footerButton.autoFocus) {
|
124
|
-
footerButton.ref = autoFocusedFooterButtonRef;
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
119
|
const defaultedProps = { ...props,
|
129
120
|
title,
|
130
121
|
subtitle,
|
@@ -137,8 +128,7 @@ const _Dialog = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
137
128
|
const backdropRef = useRef(null);
|
138
129
|
useFocusTrap({
|
139
130
|
containerRef: dialogRef,
|
140
|
-
restoreFocusOnCleanUp: true
|
141
|
-
initialFocusRef: autoFocusedFooterButtonRef
|
131
|
+
restoreFocusOnCleanUp: true
|
142
132
|
});
|
143
133
|
useOnEscapePress(event => {
|
144
134
|
onClose('escape');
|
@@ -193,9 +183,7 @@ const buttonTypes = {
|
|
193
183
|
const Buttons = ({
|
194
184
|
buttons
|
195
185
|
}) => {
|
196
|
-
|
197
|
-
|
198
|
-
const autoFocusRef = useProvidedRefOrCreate((_buttons$find = buttons.find(button => button.autoFocus)) === null || _buttons$find === void 0 ? void 0 : _buttons$find.ref);
|
186
|
+
const autoFocusRef = useRef(null);
|
199
187
|
let autoFocusCount = 0;
|
200
188
|
const [hasRendered, setHasRendered] = useState(0);
|
201
189
|
useEffect(() => {
|
@@ -207,7 +195,7 @@ const Buttons = ({
|
|
207
195
|
} else {
|
208
196
|
setHasRendered(hasRendered + 1);
|
209
197
|
}
|
210
|
-
}, [
|
198
|
+
}, [hasRendered]);
|
211
199
|
return /*#__PURE__*/React.createElement(React.Fragment, null, buttons.map((dialogButtonProps, index) => {
|
212
200
|
const {
|
213
201
|
content,
|
@@ -9,24 +9,7 @@ export namespace theme {
|
|
9
9
|
export { radii };
|
10
10
|
export { sizes };
|
11
11
|
export { space };
|
12
|
-
export
|
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
|
-
}
|
12
|
+
export { colorSchemes };
|
30
13
|
}
|
31
14
|
declare namespace animation {
|
32
15
|
const easeOutCubic: string;
|
@@ -39,8 +22,7 @@ declare namespace fonts {
|
|
39
22
|
}
|
40
23
|
declare const fontSizes: string[];
|
41
24
|
declare namespace fontWeights {
|
42
|
-
const
|
43
|
-
export { light_1 as light };
|
25
|
+
export const light: number;
|
44
26
|
const normal_1: number;
|
45
27
|
export { normal_1 as normal };
|
46
28
|
export const semibold: number;
|
@@ -60,44 +42,8 @@ declare namespace sizes {
|
|
60
42
|
}
|
61
43
|
declare const space: string[];
|
62
44
|
/**
|
63
|
-
* @type Partial<typeof primitives.colors.light
|
45
|
+
* @type Record<keyof typeof primitives.colors, Record<'colors' | 'shadows', Partial<typeof primitives.colors.light>>
|
64
46
|
*/
|
65
|
-
declare const
|
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>;
|
47
|
+
declare const colorSchemes: Record<keyof typeof primitives.colors, Record<'colors' | 'shadows', Partial<typeof primitives.colors.light>>>;
|
94
48
|
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
|
-
};
|
103
49
|
export {};
|