carbon-react 114.16.0 → 114.17.1
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/esm/__internal__/focus-trap/focus-trap.component.d.ts +2 -2
- package/esm/__internal__/focus-trap/index.d.ts +1 -1
- package/esm/components/advanced-color-picker/advanced-color-picker-cell.style.d.ts +4 -0
- package/esm/components/advanced-color-picker/advanced-color-picker.component.d.ts +43 -0
- package/esm/components/advanced-color-picker/advanced-color-picker.component.js +203 -74
- package/esm/components/advanced-color-picker/advanced-color-picker.style.d.ts +6 -0
- package/esm/components/advanced-color-picker/index.d.ts +2 -1
- package/esm/components/alert/alert.component.js +11 -5
- package/esm/components/confirm/confirm.component.js +11 -5
- package/esm/components/dialog/dialog.component.d.ts +2 -4
- package/esm/components/dialog/dialog.component.js +11 -5
- package/esm/components/dialog-full-screen/dialog-full-screen.component.d.ts +3 -2
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +14 -8
- package/esm/components/menu/__internal__/submenu/submenu.component.js +5 -2
- package/esm/components/menu/menu-item/menu-item.component.js +3 -2
- package/esm/components/search/index.d.ts +1 -1
- package/esm/components/simple-color-picker/index.d.ts +1 -1
- package/esm/components/simple-color-picker/simple-color-picker.component.d.ts +5 -1
- package/esm/components/simple-color-picker/simple-color-picker.component.js +20 -15
- package/lib/__internal__/focus-trap/focus-trap.component.d.ts +2 -2
- package/lib/__internal__/focus-trap/index.d.ts +1 -1
- package/lib/components/advanced-color-picker/advanced-color-picker-cell.style.d.ts +4 -0
- package/lib/components/advanced-color-picker/advanced-color-picker.component.d.ts +43 -0
- package/lib/components/advanced-color-picker/advanced-color-picker.component.js +203 -76
- package/lib/components/advanced-color-picker/advanced-color-picker.style.d.ts +6 -0
- package/lib/components/advanced-color-picker/index.d.ts +2 -1
- package/lib/components/alert/alert.component.js +11 -5
- package/lib/components/confirm/confirm.component.js +11 -5
- package/lib/components/dialog/dialog.component.d.ts +2 -4
- package/lib/components/dialog/dialog.component.js +11 -5
- package/lib/components/dialog-full-screen/dialog-full-screen.component.d.ts +3 -2
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +14 -8
- package/lib/components/menu/__internal__/submenu/submenu.component.js +5 -2
- package/lib/components/menu/menu-item/menu-item.component.js +3 -2
- package/lib/components/search/index.d.ts +1 -1
- package/lib/components/simple-color-picker/index.d.ts +1 -1
- package/lib/components/simple-color-picker/simple-color-picker.component.d.ts +5 -1
- package/lib/components/simple-color-picker/simple-color-picker.component.js +19 -12
- package/package.json +1 -1
- package/esm/components/advanced-color-picker/advanced-color-picker.d.ts +0 -42
- package/lib/components/advanced-color-picker/advanced-color-picker.d.ts +0 -42
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
declare type CustomRefObject<T> = {
|
|
2
|
+
export declare type CustomRefObject<T> = {
|
|
3
3
|
current?: T | null;
|
|
4
4
|
};
|
|
5
5
|
export interface FocusTrapProps {
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
autoFocus?: boolean;
|
|
8
8
|
/** provide a custom first element to focus */
|
|
9
|
-
focusFirstElement?: CustomRefObject<HTMLElement> | HTMLElement;
|
|
9
|
+
focusFirstElement?: CustomRefObject<HTMLElement> | HTMLElement | null;
|
|
10
10
|
/** a custom callback that will override the default focus trap behaviour */
|
|
11
11
|
bespokeTrap?: (ev: KeyboardEvent, firstElement?: HTMLElement, lastElement?: HTMLElement) => void;
|
|
12
12
|
/** optional selector to identify the focusable elements, if not provided a default selector is used */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "./focus-trap.component";
|
|
2
|
-
export type { FocusTrapProps } from "./focus-trap.component";
|
|
2
|
+
export type { CustomRefObject, FocusTrapProps } from "./focus-trap.component";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
export interface AdvancedColor {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AdvancedColorPickerProps extends MarginProps {
|
|
8
|
+
/** Prop to specify the aria-describedby property of the component */
|
|
9
|
+
"aria-describedby"?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Prop to specify the aria-label of the component.
|
|
12
|
+
* To be used only when the title prop is not defined, and the component is not labelled by any internal element.
|
|
13
|
+
*/
|
|
14
|
+
"aria-label"?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Prop to specify the aria-labeledby property of the component
|
|
17
|
+
* To be used when the title prop is a custom React Node,
|
|
18
|
+
* or the component is labelled by an internal element other than the title.
|
|
19
|
+
*/
|
|
20
|
+
"aria-labelledby"?: string;
|
|
21
|
+
/** Prop for `availableColors` containing array of objects of colors */
|
|
22
|
+
availableColors: AdvancedColor[];
|
|
23
|
+
/** Prop for `defaultColor` containing the default color for `uncontrolled` use */
|
|
24
|
+
defaultColor: string;
|
|
25
|
+
/** Specifies the name prop to be applied to each color in the group */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Prop for `onBlur` event */
|
|
28
|
+
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
29
|
+
/** Prop for `onChange` event */
|
|
30
|
+
onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
31
|
+
/** Prop for `onClose` event */
|
|
32
|
+
onClose?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
33
|
+
/** Prop for `onOpen` event */
|
|
34
|
+
onOpen?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
35
|
+
/** Prop for `open` status */
|
|
36
|
+
open?: boolean;
|
|
37
|
+
/** The ARIA role to be applied to the component container */
|
|
38
|
+
role?: string;
|
|
39
|
+
/** Prop for `selectedColor` containing pre-selected color for `controlled` use */
|
|
40
|
+
selectedColor?: string;
|
|
41
|
+
}
|
|
42
|
+
declare const AdvancedColorPicker: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, availableColors, defaultColor, name, onOpen, onClose, onChange, onBlur, open, role, selectedColor, ...props }: AdvancedColorPickerProps) => JSX.Element;
|
|
43
|
+
export default AdvancedColorPicker;
|
|
@@ -2,36 +2,31 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import React, { useState, useEffect, useCallback, useRef } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
5
|
import { StyledAdvancedColorPickerWrapper, StyledAdvancedColorPickerCell, StyledAdvancedColorPickerPreview, DialogStyle } from "./advanced-color-picker.style";
|
|
7
6
|
import { SimpleColorPicker, SimpleColor } from "../simple-color-picker";
|
|
8
7
|
import Events from "../../__internal__/utils/helpers/events";
|
|
9
8
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
10
|
-
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
11
9
|
|
|
12
10
|
const AdvancedColorPicker = ({
|
|
13
11
|
"aria-describedby": ariaDescribedBy,
|
|
14
12
|
"aria-label": ariaLabel,
|
|
15
13
|
"aria-labelledby": ariaLabelledBy,
|
|
14
|
+
availableColors,
|
|
15
|
+
defaultColor,
|
|
16
16
|
name,
|
|
17
|
-
open,
|
|
18
17
|
onOpen,
|
|
19
18
|
onClose,
|
|
20
19
|
onChange,
|
|
21
20
|
onBlur,
|
|
22
|
-
|
|
23
|
-
defaultColor,
|
|
24
|
-
selectedColor,
|
|
21
|
+
open = false,
|
|
25
22
|
role,
|
|
23
|
+
selectedColor,
|
|
26
24
|
...props
|
|
27
25
|
}) => {
|
|
28
|
-
const isOpen = open || false;
|
|
29
26
|
const [dialogOpen, setDialogOpen] = useState();
|
|
30
27
|
const currentColor = selectedColor || defaultColor;
|
|
31
|
-
const [selectedColorRef, setSelectedColorRef] = useState();
|
|
32
|
-
const
|
|
33
|
-
length: availableColors.length
|
|
34
|
-
}, () => /*#__PURE__*/React.createRef()));
|
|
28
|
+
const [selectedColorRef, setSelectedColorRef] = useState(null);
|
|
29
|
+
const simpleColorPickerData = useRef(null);
|
|
35
30
|
const colors = availableColors.map(({
|
|
36
31
|
value,
|
|
37
32
|
label
|
|
@@ -39,21 +34,28 @@ const AdvancedColorPicker = ({
|
|
|
39
34
|
return {
|
|
40
35
|
value,
|
|
41
36
|
label,
|
|
42
|
-
|
|
37
|
+
getRef: () =>
|
|
38
|
+
/* Fallback to null to satisfy the TypeScript compiler */
|
|
39
|
+
|
|
40
|
+
/* istanbul ignore next */
|
|
41
|
+
simpleColorPickerData.current ? simpleColorPickerData.current.gridItemRefs[index] : null
|
|
43
42
|
};
|
|
44
43
|
});
|
|
45
44
|
useEffect(() => {
|
|
46
|
-
if (dialogOpen ||
|
|
47
|
-
const
|
|
48
|
-
|
|
45
|
+
if (dialogOpen || open) {
|
|
46
|
+
const newColor = colors === null || colors === void 0 ? void 0 : colors.find(c => currentColor === c.value);
|
|
47
|
+
/* istanbul ignore else */
|
|
48
|
+
|
|
49
|
+
if (newColor) {
|
|
50
|
+
setSelectedColorRef(newColor.getRef());
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
|
-
}, [colors, currentColor, dialogOpen,
|
|
53
|
+
}, [colors, currentColor, dialogOpen, open]);
|
|
51
54
|
const handleFocus = useCallback((e, firstFocusableElement) => {
|
|
55
|
+
/* istanbul ignore else */
|
|
52
56
|
if (e.key === "Tab") {
|
|
53
|
-
/* istanbul ignore else */
|
|
54
57
|
if (e.shiftKey) {
|
|
55
|
-
|
|
56
|
-
if (document.activeElement === firstFocusableElement) {
|
|
58
|
+
if (document.activeElement === firstFocusableElement && selectedColorRef) {
|
|
57
59
|
selectedColorRef.focus();
|
|
58
60
|
e.preventDefault();
|
|
59
61
|
}
|
|
@@ -78,8 +80,14 @@ const AdvancedColorPicker = ({
|
|
|
78
80
|
}
|
|
79
81
|
}, [onClose]);
|
|
80
82
|
const handleOnChange = useCallback(e => {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
+
const newColor = colors === null || colors === void 0 ? void 0 : colors.find(c => e.target.value === c.value);
|
|
84
|
+
/* istanbul ignore else */
|
|
85
|
+
|
|
86
|
+
if (newColor) {
|
|
87
|
+
setSelectedColorRef(newColor.getRef());
|
|
88
|
+
}
|
|
89
|
+
/* istanbul ignore else */
|
|
90
|
+
|
|
83
91
|
|
|
84
92
|
if (onChange) {
|
|
85
93
|
onChange(e);
|
|
@@ -109,12 +117,12 @@ const AdvancedColorPicker = ({
|
|
|
109
117
|
onClick: handleOnOpen,
|
|
110
118
|
onKeyDown: handleOnKeyDown,
|
|
111
119
|
color: currentColor,
|
|
112
|
-
tabIndex:
|
|
120
|
+
tabIndex: 0
|
|
113
121
|
}), /*#__PURE__*/React.createElement(DialogStyle, {
|
|
114
122
|
"aria-describedby": ariaDescribedBy,
|
|
115
123
|
"aria-label": ariaLabel,
|
|
116
124
|
"aria-labelledby": ariaLabelledBy,
|
|
117
|
-
open: dialogOpen ||
|
|
125
|
+
open: dialogOpen || open,
|
|
118
126
|
size: "auto",
|
|
119
127
|
onCancel: handleOnClose,
|
|
120
128
|
bespokeFocusTrap: handleFocus,
|
|
@@ -128,69 +136,190 @@ const AdvancedColorPicker = ({
|
|
|
128
136
|
legend: "",
|
|
129
137
|
onChange: handleOnChange,
|
|
130
138
|
onBlur: handleOnBlur,
|
|
131
|
-
onKeyDown: handleColorOnKeyDown
|
|
132
|
-
|
|
139
|
+
onKeyDown: handleColorOnKeyDown,
|
|
140
|
+
ref: simpleColorPickerData
|
|
141
|
+
}, colors === null || colors === void 0 ? void 0 : colors.map(({
|
|
133
142
|
value,
|
|
134
|
-
label
|
|
135
|
-
ref
|
|
143
|
+
label
|
|
136
144
|
}) => /*#__PURE__*/React.createElement(SimpleColor, {
|
|
137
145
|
value: value,
|
|
138
146
|
key: value,
|
|
139
147
|
"aria-label": label,
|
|
140
148
|
id: value,
|
|
141
|
-
defaultChecked: value === currentColor
|
|
142
|
-
ref: ref
|
|
149
|
+
defaultChecked: value === currentColor
|
|
143
150
|
})))));
|
|
144
151
|
};
|
|
145
152
|
|
|
146
153
|
AdvancedColorPicker.propTypes = {
|
|
147
|
-
/** Filtered styled system margin props */
|
|
148
|
-
...marginPropTypes,
|
|
149
|
-
|
|
150
|
-
/** Prop to specify the aria-describedby property of the component */
|
|
151
154
|
"aria-describedby": PropTypes.string,
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Prop to specify the aria-label of the component.
|
|
155
|
-
* To be used only when the title prop is not defined, and the component is not labelled by any internal element.
|
|
156
|
-
*/
|
|
157
155
|
"aria-label": PropTypes.string,
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Prop to specify the aria-labeledby property of the component
|
|
161
|
-
* To be used when the title prop is a custom React Node,
|
|
162
|
-
* or the component is labelled by an internal element other than the title.
|
|
163
|
-
*/
|
|
164
156
|
"aria-labelledby": PropTypes.string,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
157
|
+
"availableColors": PropTypes.arrayOf(PropTypes.shape({
|
|
158
|
+
"label": PropTypes.string.isRequired,
|
|
159
|
+
"value": PropTypes.string.isRequired
|
|
160
|
+
})).isRequired,
|
|
161
|
+
"defaultColor": PropTypes.string.isRequired,
|
|
162
|
+
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
163
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
164
|
+
"description": PropTypes.string,
|
|
165
|
+
"toString": PropTypes.func.isRequired,
|
|
166
|
+
"valueOf": PropTypes.func.isRequired
|
|
167
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
168
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
169
|
+
"description": PropTypes.string,
|
|
170
|
+
"toString": PropTypes.func.isRequired,
|
|
171
|
+
"valueOf": PropTypes.func.isRequired
|
|
172
|
+
}), PropTypes.string]),
|
|
173
|
+
"margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
174
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
175
|
+
"description": PropTypes.string,
|
|
176
|
+
"toString": PropTypes.func.isRequired,
|
|
177
|
+
"valueOf": PropTypes.func.isRequired
|
|
178
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
179
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
180
|
+
"description": PropTypes.string,
|
|
181
|
+
"toString": PropTypes.func.isRequired,
|
|
182
|
+
"valueOf": PropTypes.func.isRequired
|
|
183
|
+
}), PropTypes.string]),
|
|
184
|
+
"marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
185
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
186
|
+
"description": PropTypes.string,
|
|
187
|
+
"toString": PropTypes.func.isRequired,
|
|
188
|
+
"valueOf": PropTypes.func.isRequired
|
|
189
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
190
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
191
|
+
"description": PropTypes.string,
|
|
192
|
+
"toString": PropTypes.func.isRequired,
|
|
193
|
+
"valueOf": PropTypes.func.isRequired
|
|
194
|
+
}), PropTypes.string]),
|
|
195
|
+
"marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
196
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
197
|
+
"description": PropTypes.string,
|
|
198
|
+
"toString": PropTypes.func.isRequired,
|
|
199
|
+
"valueOf": PropTypes.func.isRequired
|
|
200
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
201
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
202
|
+
"description": PropTypes.string,
|
|
203
|
+
"toString": PropTypes.func.isRequired,
|
|
204
|
+
"valueOf": PropTypes.func.isRequired
|
|
205
|
+
}), PropTypes.string]),
|
|
206
|
+
"marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
207
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
208
|
+
"description": PropTypes.string,
|
|
209
|
+
"toString": PropTypes.func.isRequired,
|
|
210
|
+
"valueOf": PropTypes.func.isRequired
|
|
211
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
212
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
213
|
+
"description": PropTypes.string,
|
|
214
|
+
"toString": PropTypes.func.isRequired,
|
|
215
|
+
"valueOf": PropTypes.func.isRequired
|
|
216
|
+
}), PropTypes.string]),
|
|
217
|
+
"marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
218
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
219
|
+
"description": PropTypes.string,
|
|
220
|
+
"toString": PropTypes.func.isRequired,
|
|
221
|
+
"valueOf": PropTypes.func.isRequired
|
|
222
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
223
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
224
|
+
"description": PropTypes.string,
|
|
225
|
+
"toString": PropTypes.func.isRequired,
|
|
226
|
+
"valueOf": PropTypes.func.isRequired
|
|
227
|
+
}), PropTypes.string]),
|
|
228
|
+
"marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
229
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
230
|
+
"description": PropTypes.string,
|
|
231
|
+
"toString": PropTypes.func.isRequired,
|
|
232
|
+
"valueOf": PropTypes.func.isRequired
|
|
233
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
234
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
235
|
+
"description": PropTypes.string,
|
|
236
|
+
"toString": PropTypes.func.isRequired,
|
|
237
|
+
"valueOf": PropTypes.func.isRequired
|
|
238
|
+
}), PropTypes.string]),
|
|
239
|
+
"marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
240
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
241
|
+
"description": PropTypes.string,
|
|
242
|
+
"toString": PropTypes.func.isRequired,
|
|
243
|
+
"valueOf": PropTypes.func.isRequired
|
|
244
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
245
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
246
|
+
"description": PropTypes.string,
|
|
247
|
+
"toString": PropTypes.func.isRequired,
|
|
248
|
+
"valueOf": PropTypes.func.isRequired
|
|
249
|
+
}), PropTypes.string]),
|
|
250
|
+
"mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
251
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
252
|
+
"description": PropTypes.string,
|
|
253
|
+
"toString": PropTypes.func.isRequired,
|
|
254
|
+
"valueOf": PropTypes.func.isRequired
|
|
255
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
256
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
257
|
+
"description": PropTypes.string,
|
|
258
|
+
"toString": PropTypes.func.isRequired,
|
|
259
|
+
"valueOf": PropTypes.func.isRequired
|
|
260
|
+
}), PropTypes.string]),
|
|
261
|
+
"ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
262
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
263
|
+
"description": PropTypes.string,
|
|
264
|
+
"toString": PropTypes.func.isRequired,
|
|
265
|
+
"valueOf": PropTypes.func.isRequired
|
|
266
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
267
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
268
|
+
"description": PropTypes.string,
|
|
269
|
+
"toString": PropTypes.func.isRequired,
|
|
270
|
+
"valueOf": PropTypes.func.isRequired
|
|
271
|
+
}), PropTypes.string]),
|
|
272
|
+
"mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
273
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
274
|
+
"description": PropTypes.string,
|
|
275
|
+
"toString": PropTypes.func.isRequired,
|
|
276
|
+
"valueOf": PropTypes.func.isRequired
|
|
277
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
278
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
279
|
+
"description": PropTypes.string,
|
|
280
|
+
"toString": PropTypes.func.isRequired,
|
|
281
|
+
"valueOf": PropTypes.func.isRequired
|
|
282
|
+
}), PropTypes.string]),
|
|
283
|
+
"mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
284
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
285
|
+
"description": PropTypes.string,
|
|
286
|
+
"toString": PropTypes.func.isRequired,
|
|
287
|
+
"valueOf": PropTypes.func.isRequired
|
|
288
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
289
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
290
|
+
"description": PropTypes.string,
|
|
291
|
+
"toString": PropTypes.func.isRequired,
|
|
292
|
+
"valueOf": PropTypes.func.isRequired
|
|
293
|
+
}), PropTypes.string]),
|
|
294
|
+
"mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
295
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
296
|
+
"description": PropTypes.string,
|
|
297
|
+
"toString": PropTypes.func.isRequired,
|
|
298
|
+
"valueOf": PropTypes.func.isRequired
|
|
299
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
300
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
301
|
+
"description": PropTypes.string,
|
|
302
|
+
"toString": PropTypes.func.isRequired,
|
|
303
|
+
"valueOf": PropTypes.func.isRequired
|
|
304
|
+
}), PropTypes.string]),
|
|
305
|
+
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
306
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
307
|
+
"description": PropTypes.string,
|
|
308
|
+
"toString": PropTypes.func.isRequired,
|
|
309
|
+
"valueOf": PropTypes.func.isRequired
|
|
310
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
311
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
312
|
+
"description": PropTypes.string,
|
|
313
|
+
"toString": PropTypes.func.isRequired,
|
|
314
|
+
"valueOf": PropTypes.func.isRequired
|
|
315
|
+
}), PropTypes.string]),
|
|
316
|
+
"name": PropTypes.string.isRequired,
|
|
317
|
+
"onBlur": PropTypes.func,
|
|
318
|
+
"onChange": PropTypes.func,
|
|
319
|
+
"onClose": PropTypes.func,
|
|
320
|
+
"onOpen": PropTypes.func,
|
|
321
|
+
"open": PropTypes.bool,
|
|
322
|
+
"role": PropTypes.string,
|
|
323
|
+
"selectedColor": PropTypes.string
|
|
195
324
|
};
|
|
196
325
|
export default AdvancedColorPicker;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import StyledAdvancedColorPickerCell from "./advanced-color-picker-cell.style";
|
|
3
|
+
declare const StyledAdvancedColorPickerWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
declare const StyledAdvancedColorPickerPreview: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
declare const DialogStyle: import("styled-components").StyledComponent<({ className, children, open, height, size, title, disableEscKey, subtitle, disableAutoFocus, focusFirstElement, focusableSelectors, onCancel, showCloseIcon, bespokeFocusTrap, disableClose, help, role, contentPadding, focusableContainers, ...rest }: import("../dialog/dialog.component").DialogProps) => JSX.Element, any, {}, never>;
|
|
6
|
+
export { StyledAdvancedColorPickerWrapper, StyledAdvancedColorPickerCell, StyledAdvancedColorPickerPreview, DialogStyle, };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./advanced-color-picker";
|
|
1
|
+
export { default } from "./advanced-color-picker.component";
|
|
2
|
+
export type { AdvancedColorPickerProps } from "./advanced-color-picker.component";
|
|
@@ -45,15 +45,21 @@ Alert.propTypes = {
|
|
|
45
45
|
}
|
|
46
46
|
})),
|
|
47
47
|
"focusableSelectors": PropTypes.string,
|
|
48
|
-
"focusFirstElement": PropTypes.
|
|
49
|
-
|
|
48
|
+
"focusFirstElement": PropTypes.oneOfType([function (props, propName) {
|
|
49
|
+
if (props[propName] == null) {
|
|
50
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
51
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
52
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
53
|
+
}
|
|
54
|
+
}, PropTypes.shape({
|
|
55
|
+
"current": function (props, propName) {
|
|
50
56
|
if (props[propName] == null) {
|
|
51
|
-
return
|
|
57
|
+
return null;
|
|
52
58
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
53
59
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
54
60
|
}
|
|
55
|
-
}
|
|
56
|
-
}),
|
|
61
|
+
}
|
|
62
|
+
})]),
|
|
57
63
|
"height": PropTypes.string,
|
|
58
64
|
"help": PropTypes.string,
|
|
59
65
|
"onCancel": PropTypes.func,
|
|
@@ -142,15 +142,21 @@ Confirm.propTypes = {
|
|
|
142
142
|
"disableCancel": PropTypes.bool,
|
|
143
143
|
"disableConfirm": PropTypes.bool,
|
|
144
144
|
"disableEscKey": PropTypes.bool,
|
|
145
|
-
"focusFirstElement": PropTypes.
|
|
146
|
-
|
|
145
|
+
"focusFirstElement": PropTypes.oneOfType([function (props, propName) {
|
|
146
|
+
if (props[propName] == null) {
|
|
147
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
148
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
149
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
150
|
+
}
|
|
151
|
+
}, PropTypes.shape({
|
|
152
|
+
"current": function (props, propName) {
|
|
147
153
|
if (props[propName] == null) {
|
|
148
|
-
return
|
|
154
|
+
return null;
|
|
149
155
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
150
156
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
151
157
|
}
|
|
152
|
-
}
|
|
153
|
-
}),
|
|
158
|
+
}
|
|
159
|
+
})]),
|
|
154
160
|
"height": PropTypes.string,
|
|
155
161
|
"iconType": PropTypes.oneOf(["error", "warning"]),
|
|
156
162
|
"isLoadingConfirm": PropTypes.bool,
|
|
@@ -2,11 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { ModalProps } from "../modal";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
4
4
|
import { DialogSizes } from "./dialog.config";
|
|
5
|
+
import { CustomRefObject } from "../../__internal__/focus-trap";
|
|
5
6
|
declare const PADDING_VALUES: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
6
7
|
declare type PaddingValues = typeof PADDING_VALUES[number];
|
|
7
|
-
declare type CustomRefObject<T> = {
|
|
8
|
-
current?: T | null;
|
|
9
|
-
};
|
|
10
8
|
export interface ContentPaddingInterface {
|
|
11
9
|
p?: PaddingValues;
|
|
12
10
|
py?: PaddingValues;
|
|
@@ -37,7 +35,7 @@ export interface DialogProps extends ModalProps, TagProps {
|
|
|
37
35
|
*/
|
|
38
36
|
bespokeFocusTrap?: (ev: KeyboardEvent, firstElement?: HTMLElement, lastElement?: HTMLElement) => void;
|
|
39
37
|
/** Optional reference to an element meant to be focused on open */
|
|
40
|
-
focusFirstElement?:
|
|
38
|
+
focusFirstElement?: CustomRefObject<HTMLElement> | HTMLElement | null;
|
|
41
39
|
/** Optional selector to identify the focusable elements, if not provided a default selector is used */
|
|
42
40
|
focusableSelectors?: string;
|
|
43
41
|
/** Allows developers to specify a specific height for the dialog. */
|
|
@@ -220,15 +220,21 @@ Dialog.propTypes = {
|
|
|
220
220
|
}
|
|
221
221
|
})),
|
|
222
222
|
"focusableSelectors": PropTypes.string,
|
|
223
|
-
"focusFirstElement": PropTypes.
|
|
224
|
-
|
|
223
|
+
"focusFirstElement": PropTypes.oneOfType([function (props, propName) {
|
|
224
|
+
if (props[propName] == null) {
|
|
225
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
226
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
227
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
228
|
+
}
|
|
229
|
+
}, PropTypes.shape({
|
|
230
|
+
"current": function (props, propName) {
|
|
225
231
|
if (props[propName] == null) {
|
|
226
|
-
return
|
|
232
|
+
return null;
|
|
227
233
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
228
234
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
229
235
|
}
|
|
230
|
-
}
|
|
231
|
-
}),
|
|
236
|
+
}
|
|
237
|
+
})]),
|
|
232
238
|
"height": PropTypes.string,
|
|
233
239
|
"help": PropTypes.string,
|
|
234
240
|
"onCancel": PropTypes.func,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ModalProps } from "../modal";
|
|
3
|
+
import { CustomRefObject } from "../../__internal__/focus-trap";
|
|
3
4
|
export interface DialogFullScreenProps extends ModalProps {
|
|
4
5
|
/** Prop to specify the aria-describedby property of the DialogFullscreen component */
|
|
5
6
|
"aria-describedby"?: string;
|
|
@@ -23,7 +24,7 @@ export interface DialogFullScreenProps extends ModalProps {
|
|
|
23
24
|
/** remove padding from content */
|
|
24
25
|
disableContentPadding?: boolean;
|
|
25
26
|
/** Optional reference to an element meant to be focused on open */
|
|
26
|
-
focusFirstElement?:
|
|
27
|
+
focusFirstElement?: CustomRefObject<HTMLElement> | HTMLElement | null;
|
|
27
28
|
/**
|
|
28
29
|
* Function to replace focus trap
|
|
29
30
|
* @ignore
|
|
@@ -45,7 +46,7 @@ export interface DialogFullScreenProps extends ModalProps {
|
|
|
45
46
|
/** The ARIA role to be applied to the DialogFullscreen container */
|
|
46
47
|
role?: string;
|
|
47
48
|
/** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
|
|
48
|
-
focusableContainers?:
|
|
49
|
+
focusableContainers?: CustomRefObject<HTMLElement>[];
|
|
49
50
|
/** Optional selector to identify the focusable elements, if not provided a default selector is used */
|
|
50
51
|
focusableSelectors?: string;
|
|
51
52
|
/** A custom close event handler */
|
|
@@ -135,24 +135,30 @@ DialogFullScreen.propTypes = {
|
|
|
135
135
|
"disableEscKey": PropTypes.bool,
|
|
136
136
|
"enableBackgroundUI": PropTypes.bool,
|
|
137
137
|
"focusableContainers": PropTypes.arrayOf(PropTypes.shape({
|
|
138
|
-
"current":
|
|
138
|
+
"current": function (props, propName) {
|
|
139
139
|
if (props[propName] == null) {
|
|
140
|
-
return
|
|
140
|
+
return null;
|
|
141
141
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
142
142
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
143
143
|
}
|
|
144
|
-
}
|
|
144
|
+
}
|
|
145
145
|
})),
|
|
146
146
|
"focusableSelectors": PropTypes.string,
|
|
147
|
-
"focusFirstElement": PropTypes.
|
|
148
|
-
|
|
147
|
+
"focusFirstElement": PropTypes.oneOfType([function (props, propName) {
|
|
148
|
+
if (props[propName] == null) {
|
|
149
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
150
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
151
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
152
|
+
}
|
|
153
|
+
}, PropTypes.shape({
|
|
154
|
+
"current": function (props, propName) {
|
|
149
155
|
if (props[propName] == null) {
|
|
150
|
-
return
|
|
156
|
+
return null;
|
|
151
157
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
152
158
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
153
159
|
}
|
|
154
|
-
}
|
|
155
|
-
}),
|
|
160
|
+
}
|
|
161
|
+
})]),
|
|
156
162
|
"headerChildren": PropTypes.node,
|
|
157
163
|
"help": PropTypes.string,
|
|
158
164
|
"onCancel": PropTypes.func,
|
|
@@ -43,6 +43,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
43
43
|
const [submenuItemIds, setSubmenuItemIds] = useState([]);
|
|
44
44
|
const [characterString, setCharacterString] = useState("");
|
|
45
45
|
const shiftTabPressed = useRef(false);
|
|
46
|
+
const focusFirstMenuItemOnOpen = useRef(false);
|
|
46
47
|
const registerItem = useCallback(id => {
|
|
47
48
|
setSubmenuItemIds(prevState => {
|
|
48
49
|
return [...prevState, id];
|
|
@@ -109,6 +110,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
109
110
|
if (Events.isEnterKey(event) || Events.isSpaceKey(event) || Events.isDownKey(event) || Events.isUpKey(event)) {
|
|
110
111
|
event.preventDefault();
|
|
111
112
|
openSubmenu();
|
|
113
|
+
focusFirstMenuItemOnOpen.current = !href;
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
|
|
@@ -212,10 +214,11 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
212
214
|
}
|
|
213
215
|
}, [submenuItemIds, submenuOpen, href, numberOfChildren, submenuFocusId, findCurrentIndex, openSubmenu, closeSubmenu, onKeyDown, characterString, restartCharacterTimeout, startCharacterTimeout]);
|
|
214
216
|
useEffect(() => {
|
|
215
|
-
if (
|
|
217
|
+
if (focusFirstMenuItemOnOpen.current && submenuOpen && !submenuFocusId && submenuItemIds.length) {
|
|
218
|
+
focusFirstMenuItemOnOpen.current = false;
|
|
216
219
|
setSubmenuFocusId(submenuItemIds[0]);
|
|
217
220
|
}
|
|
218
|
-
}, [submenuOpen,
|
|
221
|
+
}, [submenuOpen, submenuFocusId, submenuItemIds]);
|
|
219
222
|
|
|
220
223
|
const handleClickAway = () => {
|
|
221
224
|
document.removeEventListener("click", handleClickAway);
|