carbon-react 114.15.0 → 114.17.0
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/heading/heading.component.d.ts +4 -1
- package/esm/components/heading/heading.component.js +3 -1
- package/esm/components/heading/index.d.ts +1 -1
- package/esm/components/search/index.d.ts +1 -1
- package/esm/components/settings-row/settings-row.component.js +5 -0
- package/esm/components/settings-row/settings-row.d.ts +3 -0
- package/esm/components/settings-row/settings-row.style.js +1 -10
- 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/heading/heading.component.d.ts +4 -1
- package/lib/components/heading/heading.component.js +3 -1
- package/lib/components/heading/index.d.ts +1 -1
- package/lib/components/search/index.d.ts +1 -1
- package/lib/components/settings-row/settings-row.component.js +5 -0
- package/lib/components/settings-row/settings-row.d.ts +3 -0
- package/lib/components/settings-row/settings-row.style.js +0 -9
- 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 +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";
|
|
@@ -57,15 +57,21 @@ Alert.propTypes = {
|
|
|
57
57
|
}
|
|
58
58
|
})),
|
|
59
59
|
"focusableSelectors": _propTypes.default.string,
|
|
60
|
-
"focusFirstElement": _propTypes.default.
|
|
61
|
-
|
|
60
|
+
"focusFirstElement": _propTypes.default.oneOfType([function (props, propName) {
|
|
61
|
+
if (props[propName] == null) {
|
|
62
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
63
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
64
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
65
|
+
}
|
|
66
|
+
}, _propTypes.default.shape({
|
|
67
|
+
"current": function (props, propName) {
|
|
62
68
|
if (props[propName] == null) {
|
|
63
|
-
return
|
|
69
|
+
return null;
|
|
64
70
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
65
71
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
66
72
|
}
|
|
67
|
-
}
|
|
68
|
-
}),
|
|
73
|
+
}
|
|
74
|
+
})]),
|
|
69
75
|
"height": _propTypes.default.string,
|
|
70
76
|
"help": _propTypes.default.string,
|
|
71
77
|
"onCancel": _propTypes.default.func,
|
|
@@ -165,15 +165,21 @@ Confirm.propTypes = {
|
|
|
165
165
|
"disableCancel": _propTypes.default.bool,
|
|
166
166
|
"disableConfirm": _propTypes.default.bool,
|
|
167
167
|
"disableEscKey": _propTypes.default.bool,
|
|
168
|
-
"focusFirstElement": _propTypes.default.
|
|
169
|
-
|
|
168
|
+
"focusFirstElement": _propTypes.default.oneOfType([function (props, propName) {
|
|
169
|
+
if (props[propName] == null) {
|
|
170
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
171
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
172
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
173
|
+
}
|
|
174
|
+
}, _propTypes.default.shape({
|
|
175
|
+
"current": function (props, propName) {
|
|
170
176
|
if (props[propName] == null) {
|
|
171
|
-
return
|
|
177
|
+
return null;
|
|
172
178
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
173
179
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
174
180
|
}
|
|
175
|
-
}
|
|
176
|
-
}),
|
|
181
|
+
}
|
|
182
|
+
})]),
|
|
177
183
|
"height": _propTypes.default.string,
|
|
178
184
|
"iconType": _propTypes.default.oneOf(["error", "warning"]),
|
|
179
185
|
"isLoadingConfirm": _propTypes.default.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. */
|
|
@@ -248,15 +248,21 @@ Dialog.propTypes = {
|
|
|
248
248
|
}
|
|
249
249
|
})),
|
|
250
250
|
"focusableSelectors": _propTypes.default.string,
|
|
251
|
-
"focusFirstElement": _propTypes.default.
|
|
252
|
-
|
|
251
|
+
"focusFirstElement": _propTypes.default.oneOfType([function (props, propName) {
|
|
252
|
+
if (props[propName] == null) {
|
|
253
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
254
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
255
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
256
|
+
}
|
|
257
|
+
}, _propTypes.default.shape({
|
|
258
|
+
"current": function (props, propName) {
|
|
253
259
|
if (props[propName] == null) {
|
|
254
|
-
return
|
|
260
|
+
return null;
|
|
255
261
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
256
262
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
257
263
|
}
|
|
258
|
-
}
|
|
259
|
-
}),
|
|
264
|
+
}
|
|
265
|
+
})]),
|
|
260
266
|
"height": _propTypes.default.string,
|
|
261
267
|
"help": _propTypes.default.string,
|
|
262
268
|
"onCancel": _propTypes.default.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 */
|
|
@@ -162,24 +162,30 @@ DialogFullScreen.propTypes = {
|
|
|
162
162
|
"disableEscKey": _propTypes.default.bool,
|
|
163
163
|
"enableBackgroundUI": _propTypes.default.bool,
|
|
164
164
|
"focusableContainers": _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
165
|
-
"current":
|
|
165
|
+
"current": function (props, propName) {
|
|
166
166
|
if (props[propName] == null) {
|
|
167
|
-
return
|
|
167
|
+
return null;
|
|
168
168
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
169
169
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
170
170
|
}
|
|
171
|
-
}
|
|
171
|
+
}
|
|
172
172
|
})),
|
|
173
173
|
"focusableSelectors": _propTypes.default.string,
|
|
174
|
-
"focusFirstElement": _propTypes.default.
|
|
175
|
-
|
|
174
|
+
"focusFirstElement": _propTypes.default.oneOfType([function (props, propName) {
|
|
175
|
+
if (props[propName] == null) {
|
|
176
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
177
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
178
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
179
|
+
}
|
|
180
|
+
}, _propTypes.default.shape({
|
|
181
|
+
"current": function (props, propName) {
|
|
176
182
|
if (props[propName] == null) {
|
|
177
|
-
return
|
|
183
|
+
return null;
|
|
178
184
|
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
179
185
|
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
180
186
|
}
|
|
181
|
-
}
|
|
182
|
-
}),
|
|
187
|
+
}
|
|
188
|
+
})]),
|
|
183
189
|
"headerChildren": _propTypes.default.node,
|
|
184
190
|
"help": _propTypes.default.string,
|
|
185
191
|
"onCancel": _propTypes.default.func,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
4
|
+
export declare type HeadingType = "h1" | "h2" | "h3" | "h4" | "h5";
|
|
4
5
|
export interface HeadingProps extends MarginProps, TagProps {
|
|
5
6
|
/** Child elements */
|
|
6
7
|
children?: React.ReactNode;
|
|
@@ -12,6 +13,8 @@ export interface HeadingProps extends MarginProps, TagProps {
|
|
|
12
13
|
subheader?: React.ReactNode;
|
|
13
14
|
/** Defines the subtitle id for the heading. */
|
|
14
15
|
subtitleId?: string;
|
|
16
|
+
/** Defines the HTML heading element of the title. */
|
|
17
|
+
headingType?: HeadingType;
|
|
15
18
|
/** Defines the help text for the heading. */
|
|
16
19
|
help?: string;
|
|
17
20
|
/** Defines the help link for the heading. */
|
|
@@ -27,5 +30,5 @@ export interface HeadingProps extends MarginProps, TagProps {
|
|
|
27
30
|
/** Aria label for rendered help component */
|
|
28
31
|
helpAriaLabel?: string;
|
|
29
32
|
}
|
|
30
|
-
export declare const Heading: ({ children, backLink, divider, help, helpAriaLabel, helpLink, pills, separator, subheader, subtitleId, title, titleId, ...rest }: HeadingProps) => JSX.Element | null;
|
|
33
|
+
export declare const Heading: ({ children, backLink, divider, help, helpAriaLabel, helpLink, pills, separator, subheader, subtitleId, headingType, title, titleId, ...rest }: HeadingProps) => JSX.Element | null;
|
|
31
34
|
export default Heading;
|
|
@@ -32,6 +32,7 @@ const Heading = ({
|
|
|
32
32
|
separator = false,
|
|
33
33
|
subheader,
|
|
34
34
|
subtitleId,
|
|
35
|
+
headingType = "h1",
|
|
35
36
|
title,
|
|
36
37
|
titleId,
|
|
37
38
|
...rest
|
|
@@ -90,7 +91,7 @@ const Heading = ({
|
|
|
90
91
|
hasBackLink: !!backLink
|
|
91
92
|
}, backLink && getBackButton(), /*#__PURE__*/_react.default.createElement(_heading.StyledHeaderContent, null, /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingTitle, {
|
|
92
93
|
withMargin: !!pills || !!help,
|
|
93
|
-
variant:
|
|
94
|
+
variant: headingType,
|
|
94
95
|
"data-element": "title",
|
|
95
96
|
id: titleId
|
|
96
97
|
}, title), (help || helpLink) && getHelp(), pills && getPills()), separator && /*#__PURE__*/_react.default.createElement(_heading.StyledSeparator, null), subheader && getSubheader()), divider && /*#__PURE__*/_react.default.createElement(_heading.StyledDivider, {
|
|
@@ -106,6 +107,7 @@ Heading.propTypes = {
|
|
|
106
107
|
"data-element": _propTypes.default.string,
|
|
107
108
|
"data-role": _propTypes.default.string,
|
|
108
109
|
"divider": _propTypes.default.bool,
|
|
110
|
+
"headingType": _propTypes.default.oneOf(["h1", "h2", "h3", "h4", "h5"]),
|
|
109
111
|
"help": _propTypes.default.string,
|
|
110
112
|
"helpAriaLabel": _propTypes.default.string,
|
|
111
113
|
"helpLink": _propTypes.default.string,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "./heading.component";
|
|
2
|
-
export type { HeadingProps } from "./heading.component";
|
|
2
|
+
export type { HeadingProps, HeadingType } from "./heading.component";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "./search.component";
|
|
2
|
-
export type { SearchProps } from "./search.component";
|
|
2
|
+
export type { SearchProps, SearchEvent } from "./search.component";
|
|
@@ -27,6 +27,7 @@ const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.de
|
|
|
27
27
|
|
|
28
28
|
const SettingsRow = ({
|
|
29
29
|
title,
|
|
30
|
+
headingType = "h3",
|
|
30
31
|
description,
|
|
31
32
|
children,
|
|
32
33
|
className,
|
|
@@ -36,6 +37,7 @@ const SettingsRow = ({
|
|
|
36
37
|
const heading = () => {
|
|
37
38
|
if (!title) return null;
|
|
38
39
|
return /*#__PURE__*/_react.default.createElement(_heading.default, {
|
|
40
|
+
headingType: headingType,
|
|
39
41
|
title: title,
|
|
40
42
|
subheader: description,
|
|
41
43
|
separator: description !== undefined,
|
|
@@ -62,6 +64,9 @@ SettingsRow.propTypes = { ...marginPropTypes,
|
|
|
62
64
|
/** A title for this group of settings. */
|
|
63
65
|
title: _propTypes.default.string,
|
|
64
66
|
|
|
67
|
+
/** Defines the HTML heading element of the `title` within the component. */
|
|
68
|
+
headingType: _propTypes.default.oneOf(["h1", "h2", "h3", "h4", "h5"]),
|
|
69
|
+
|
|
65
70
|
/** A string or JSX object that provides a short description about the group of settings. */
|
|
66
71
|
description: _propTypes.default.node,
|
|
67
72
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { HeadingType } from "../heading";
|
|
2
3
|
|
|
3
4
|
export interface SettingsRowProps {
|
|
4
5
|
/** The CSS classes to apply to the component. */
|
|
5
6
|
className?: string;
|
|
6
7
|
/** A title for this group of settings. */
|
|
7
8
|
title?: string;
|
|
9
|
+
/** Defines the HTML heading element of the `title` within the component. */
|
|
10
|
+
headingType?: HeadingType;
|
|
8
11
|
/** A string or JSX object that provides a short description about the group of settings. */
|
|
9
12
|
description?: React.ReactNode;
|
|
10
13
|
/** Shows a divider below the component. */
|
|
@@ -41,15 +41,6 @@ const StyledSettingsRow = _styledComponents.default.div`
|
|
|
41
41
|
margin-bottom: 0;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
${_heading.StyledHeadingTitle} {
|
|
45
|
-
color: var(--colorsUtilityYin090);
|
|
46
|
-
font-size: 15px;
|
|
47
|
-
font-weight: bold;
|
|
48
|
-
line-height: 18px;
|
|
49
|
-
margin-bottom: 10px;
|
|
50
|
-
text-transform: uppercase;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
44
|
${_heading.StyledSeparator} {
|
|
54
45
|
margin-bottom: 17px;
|
|
55
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as SimpleColorPicker } from "./simple-color-picker.component";
|
|
2
|
-
export type { SimpleColorPickerProps } from "./simple-color-picker.component";
|
|
2
|
+
export type { SimpleColorPickerProps, SimpleColorPickerRef, } from "./simple-color-picker.component";
|
|
3
3
|
export { default as SimpleColor } from "./simple-color";
|
|
4
4
|
export type { SimpleColorProps } from "./simple-color";
|
|
@@ -27,5 +27,9 @@ export interface SimpleColorPickerProps extends ValidationProps, MarginProps {
|
|
|
27
27
|
/** The currently selected color. */
|
|
28
28
|
value?: string;
|
|
29
29
|
}
|
|
30
|
-
export
|
|
30
|
+
export interface SimpleColorPickerRef {
|
|
31
|
+
/** List of color input HTML refs */
|
|
32
|
+
gridItemRefs: (HTMLInputElement | null)[];
|
|
33
|
+
}
|
|
34
|
+
export declare const SimpleColorPicker: React.ForwardRefExoticComponent<SimpleColorPickerProps & React.RefAttributes<SimpleColorPickerRef>>;
|
|
31
35
|
export default SimpleColorPicker;
|
|
@@ -37,7 +37,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
37
37
|
|
|
38
38
|
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); }
|
|
39
39
|
|
|
40
|
-
const SimpleColorPicker = props => {
|
|
40
|
+
const SimpleColorPicker = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
41
41
|
const {
|
|
42
42
|
children,
|
|
43
43
|
error,
|
|
@@ -77,7 +77,7 @@ const SimpleColorPicker = props => {
|
|
|
77
77
|
let blankSlots = itemsPerRow * rowCount - (filteredChildren === null || filteredChildren === void 0 ? void 0 : filteredChildren.length);
|
|
78
78
|
let currentRow = 1;
|
|
79
79
|
let loopCounter = 1;
|
|
80
|
-
const gridItemRefs = (0, _react.
|
|
80
|
+
const gridItemRefs = (0, _react.useRef)([]);
|
|
81
81
|
const navigationGrid = filteredChildren.map((child, index) => {
|
|
82
82
|
const allowUp = currentRow !== 1;
|
|
83
83
|
let allowDown = false;
|
|
@@ -107,7 +107,9 @@ const SimpleColorPicker = props => {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
const childProps = {
|
|
110
|
-
ref:
|
|
110
|
+
ref: element => {
|
|
111
|
+
gridItemRefs.current[index] = element;
|
|
112
|
+
},
|
|
111
113
|
"data-up": allowUp,
|
|
112
114
|
"data-down": allowDown,
|
|
113
115
|
"data-item-up": upItem,
|
|
@@ -117,6 +119,14 @@ const SimpleColorPicker = props => {
|
|
|
117
119
|
loopCounter += 1;
|
|
118
120
|
return /*#__PURE__*/_react.default.cloneElement(child, childProps);
|
|
119
121
|
});
|
|
122
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
123
|
+
gridItemRefs: gridItemRefs.current
|
|
124
|
+
}), [gridItemRefs]);
|
|
125
|
+
const getElementPosition = (0, _react.useCallback)(target => {
|
|
126
|
+
return navigationGrid.findIndex(element => {
|
|
127
|
+
return target.getAttribute("value") === element.props.value;
|
|
128
|
+
});
|
|
129
|
+
}, [navigationGrid]);
|
|
120
130
|
const onKeyDownHandler = (0, _react.useCallback)(e => {
|
|
121
131
|
if (onKeyDown) {
|
|
122
132
|
onKeyDown(e);
|
|
@@ -137,14 +147,10 @@ const SimpleColorPicker = props => {
|
|
|
137
147
|
}
|
|
138
148
|
|
|
139
149
|
if (_events.default.isLeftKey(e) || _events.default.isRightKey(e)) {
|
|
140
|
-
const position = element => {
|
|
141
|
-
return target.getAttribute("value") === element.props.value;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
150
|
if (_events.default.isLeftKey(e)) {
|
|
145
|
-
itemIndex =
|
|
151
|
+
itemIndex = getElementPosition(target) - 1;
|
|
146
152
|
} else {
|
|
147
|
-
itemIndex =
|
|
153
|
+
itemIndex = getElementPosition(target) + 1;
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
if (itemIndex < 0) {
|
|
@@ -157,11 +163,11 @@ const SimpleColorPicker = props => {
|
|
|
157
163
|
|
|
158
164
|
|
|
159
165
|
if (itemIndex !== null) {
|
|
160
|
-
const item = gridItemRefs[itemIndex]
|
|
166
|
+
const item = gridItemRefs.current[itemIndex];
|
|
161
167
|
item === null || item === void 0 ? void 0 : item.focus();
|
|
162
168
|
item === null || item === void 0 ? void 0 : item.click();
|
|
163
169
|
}
|
|
164
|
-
}, [onKeyDown, navigationGrid,
|
|
170
|
+
}, [onKeyDown, navigationGrid, getElementPosition]);
|
|
165
171
|
|
|
166
172
|
const handleClickOutside = ev => {
|
|
167
173
|
if (internalRef.current && ev.target && !internalRef.current.contains(ev.target)) {
|
|
@@ -229,7 +235,7 @@ const SimpleColorPicker = props => {
|
|
|
229
235
|
}, navigationGrid))), !validationOnLegend && /*#__PURE__*/_react.default.createElement(_validationIcon.default, _extends({}, validationProps, {
|
|
230
236
|
tooltipFlipOverrides: ["top", "bottom"]
|
|
231
237
|
}))));
|
|
232
|
-
};
|
|
238
|
+
});
|
|
233
239
|
|
|
234
240
|
exports.SimpleColorPicker = SimpleColorPicker;
|
|
235
241
|
SimpleColorPicker.propTypes = {
|
|
@@ -403,5 +409,6 @@ SimpleColorPicker.propTypes = {
|
|
|
403
409
|
"value": _propTypes.default.string,
|
|
404
410
|
"warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool])
|
|
405
411
|
};
|
|
412
|
+
SimpleColorPicker.displayName = "SimpleColorPicker";
|
|
406
413
|
var _default = SimpleColorPicker;
|
|
407
414
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { MarginProps } from "styled-system";
|
|
3
|
-
|
|
4
|
-
export interface AdvancedColor {
|
|
5
|
-
label: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface AdvancedColorPickerPropTypes extends MarginProps {
|
|
10
|
-
/** Prop to specify the aria-describedby property of the component */
|
|
11
|
-
"aria-describedby"?: string;
|
|
12
|
-
/** Prop to specify the aria-label of the component */
|
|
13
|
-
"aria-label"?: string;
|
|
14
|
-
/** Prop to specify the aria-labeledby property of the component */
|
|
15
|
-
"aria-labelledby"?: string;
|
|
16
|
-
/** Prop for `availableColors` containing array of objects of colors */
|
|
17
|
-
availableColors: AdvancedColor[];
|
|
18
|
-
/** Prop for `defaultColor` containing the default color for `uncontrolled` use */
|
|
19
|
-
defaultColor: string;
|
|
20
|
-
/** Specifies the name prop to be applied to each color in the group */
|
|
21
|
-
name: string;
|
|
22
|
-
/** Prop for `onBlur` event */
|
|
23
|
-
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
24
|
-
/** Prop for `onChange` event */
|
|
25
|
-
onChange?: (ev: React.ChangeEvent<HTMLElement>) => void;
|
|
26
|
-
/** Prop for `onClose` event */
|
|
27
|
-
onClose?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
28
|
-
/** Prop for `onOpen` event */
|
|
29
|
-
onOpen?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
30
|
-
/** Prop for `open` status */
|
|
31
|
-
open?: boolean;
|
|
32
|
-
/** The ARIA role to be applied to the component container */
|
|
33
|
-
role?: string;
|
|
34
|
-
/** Prop for `selectedColor` containing pre-selected color for `controlled` use */
|
|
35
|
-
selectedColor?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
declare function AdvancedColorPicker(
|
|
39
|
-
props: AdvancedColorPickerPropTypes
|
|
40
|
-
): JSX.Element;
|
|
41
|
-
|
|
42
|
-
export default AdvancedColorPicker;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { MarginProps } from "styled-system";
|
|
3
|
-
|
|
4
|
-
export interface AdvancedColor {
|
|
5
|
-
label: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface AdvancedColorPickerPropTypes extends MarginProps {
|
|
10
|
-
/** Prop to specify the aria-describedby property of the component */
|
|
11
|
-
"aria-describedby"?: string;
|
|
12
|
-
/** Prop to specify the aria-label of the component */
|
|
13
|
-
"aria-label"?: string;
|
|
14
|
-
/** Prop to specify the aria-labeledby property of the component */
|
|
15
|
-
"aria-labelledby"?: string;
|
|
16
|
-
/** Prop for `availableColors` containing array of objects of colors */
|
|
17
|
-
availableColors: AdvancedColor[];
|
|
18
|
-
/** Prop for `defaultColor` containing the default color for `uncontrolled` use */
|
|
19
|
-
defaultColor: string;
|
|
20
|
-
/** Specifies the name prop to be applied to each color in the group */
|
|
21
|
-
name: string;
|
|
22
|
-
/** Prop for `onBlur` event */
|
|
23
|
-
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
24
|
-
/** Prop for `onChange` event */
|
|
25
|
-
onChange?: (ev: React.ChangeEvent<HTMLElement>) => void;
|
|
26
|
-
/** Prop for `onClose` event */
|
|
27
|
-
onClose?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
28
|
-
/** Prop for `onOpen` event */
|
|
29
|
-
onOpen?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
30
|
-
/** Prop for `open` status */
|
|
31
|
-
open?: boolean;
|
|
32
|
-
/** The ARIA role to be applied to the component container */
|
|
33
|
-
role?: string;
|
|
34
|
-
/** Prop for `selectedColor` containing pre-selected color for `controlled` use */
|
|
35
|
-
selectedColor?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
declare function AdvancedColorPicker(
|
|
39
|
-
props: AdvancedColorPickerPropTypes
|
|
40
|
-
): JSX.Element;
|
|
41
|
-
|
|
42
|
-
export default AdvancedColorPicker;
|