carbon-react 109.2.4 → 109.3.2
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__/field-help/field-help.component.d.ts +10 -0
- package/esm/__internal__/field-help/field-help.component.js +12 -16
- package/esm/__internal__/field-help/field-help.style.d.ts +8 -0
- package/esm/__internal__/field-help/field-help.style.js +2 -10
- package/esm/__internal__/field-help/index.d.ts +2 -1
- package/esm/__internal__/focus-trap/focus-trap-utils.d.ts +1 -2
- package/esm/__internal__/focus-trap/focus-trap-utils.js +57 -8
- package/esm/__internal__/focus-trap/focus-trap.component.js +35 -25
- package/esm/__spec_helper__/index.d.ts +1 -0
- package/esm/__spec_helper__/index.js +4 -10
- package/esm/__spec_helper__/mock-match-media.d.ts +2 -2
- package/esm/__spec_helper__/mock-match-media.js +2 -2
- package/esm/__spec_helper__/mock-resize-observer.d.ts +2 -0
- package/esm/components/alert/alert.component.js +9 -0
- package/esm/components/dialog/dialog.component.js +9 -2
- package/esm/components/dialog/dialog.d.ts +2 -0
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +9 -2
- package/esm/components/dialog-full-screen/dialog-full-screen.d.ts +2 -0
- package/esm/components/grid/grid-container/grid-container.component.d.ts +8 -0
- package/esm/components/grid/grid-container/grid-container.component.js +1821 -21
- package/esm/components/grid/grid-container/grid-container.style.d.ts +3 -0
- package/esm/components/grid/grid-container/grid-container.style.js +2 -2
- package/esm/components/grid/grid-container/index.d.ts +2 -1
- package/esm/components/grid/grid-item/grid-item.component.d.ts +11 -0
- package/esm/components/grid/grid-item/grid-item.component.js +1221 -45
- package/esm/components/grid/grid-item/grid-item.style.d.ts +17 -0
- package/esm/components/grid/grid-item/grid-item.style.js +38 -62
- package/esm/components/grid/grid-item/index.d.ts +2 -1
- package/esm/components/grid/index.d.ts +2 -0
- package/esm/components/grid/index.js +2 -3
- package/esm/components/multi-action-button/multi-action-button.component.js +14 -84
- package/esm/components/select/utils/highlight-part-of-text.js +13 -1
- package/esm/components/select/utils/with-filter.hoc.js +3 -2
- package/esm/components/sidebar/sidebar.component.js +9 -2
- package/esm/components/sidebar/sidebar.d.ts +2 -0
- package/esm/components/split-button/split-button.component.js +15 -82
- package/esm/components/toast/toast.component.js +35 -9
- package/esm/components/toast/toast.d.ts +5 -1
- package/esm/hooks/__internal__/useMenuKeyboardNavigation/index.d.ts +1 -0
- package/esm/hooks/__internal__/useMenuKeyboardNavigation/index.js +1 -0
- package/esm/hooks/__internal__/useMenuKeyboardNavigation/useMenuKeyboardNavigation.d.ts +2 -0
- package/esm/hooks/__internal__/useMenuKeyboardNavigation/useMenuKeyboardNavigation.js +70 -0
- package/lib/__internal__/field-help/field-help.component.d.ts +10 -0
- package/lib/__internal__/field-help/field-help.component.js +12 -16
- package/lib/__internal__/field-help/field-help.style.d.ts +8 -0
- package/lib/__internal__/field-help/field-help.style.js +2 -13
- package/lib/__internal__/field-help/index.d.ts +2 -1
- package/lib/__internal__/focus-trap/focus-trap-utils.d.ts +1 -2
- package/lib/__internal__/focus-trap/focus-trap-utils.js +57 -10
- package/lib/__internal__/focus-trap/focus-trap.component.js +34 -24
- package/lib/__spec_helper__/index.d.ts +1 -0
- package/lib/__spec_helper__/index.js +3 -10
- package/lib/__spec_helper__/mock-match-media.d.ts +2 -2
- package/lib/__spec_helper__/mock-match-media.js +4 -4
- package/lib/__spec_helper__/mock-resize-observer.d.ts +2 -0
- package/lib/components/alert/alert.component.js +9 -0
- package/lib/components/dialog/dialog.component.js +9 -2
- package/lib/components/dialog/dialog.d.ts +2 -0
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +9 -2
- package/lib/components/dialog-full-screen/dialog-full-screen.d.ts +2 -0
- package/lib/components/grid/grid-container/grid-container.component.d.ts +8 -0
- package/lib/components/grid/grid-container/grid-container.component.js +1826 -22
- package/lib/components/grid/grid-container/grid-container.style.d.ts +3 -0
- package/lib/components/grid/grid-container/grid-container.style.js +2 -2
- package/lib/components/grid/grid-container/index.d.ts +2 -1
- package/lib/components/grid/grid-item/grid-item.component.d.ts +11 -0
- package/lib/components/grid/grid-item/grid-item.component.js +1221 -46
- package/lib/components/grid/grid-item/grid-item.style.d.ts +17 -0
- package/lib/components/grid/grid-item/grid-item.style.js +37 -67
- package/lib/components/grid/grid-item/index.d.ts +2 -1
- package/lib/components/grid/index.d.ts +2 -0
- package/lib/components/multi-action-button/multi-action-button.component.js +13 -83
- package/lib/components/select/utils/highlight-part-of-text.js +13 -1
- package/lib/components/select/utils/with-filter.hoc.js +3 -2
- package/lib/components/sidebar/sidebar.component.js +9 -2
- package/lib/components/sidebar/sidebar.d.ts +2 -0
- package/lib/components/split-button/split-button.component.js +14 -83
- package/lib/components/toast/toast.component.js +35 -7
- package/lib/components/toast/toast.d.ts +5 -1
- package/lib/hooks/__internal__/useMenuKeyboardNavigation/index.d.ts +1 -0
- package/lib/hooks/__internal__/useMenuKeyboardNavigation/index.js +15 -0
- package/lib/hooks/__internal__/useMenuKeyboardNavigation/package.json +6 -0
- package/lib/hooks/__internal__/useMenuKeyboardNavigation/useMenuKeyboardNavigation.d.ts +2 -0
- package/lib/hooks/__internal__/useMenuKeyboardNavigation/useMenuKeyboardNavigation.js +85 -0
- package/package.json +3 -4
- package/esm/__internal__/field-help/field-help.d.ts +0 -14
- package/esm/components/grid/grid-container/grid-container.d.ts +0 -18
- package/esm/components/grid/grid-item/grid-item.d.ts +0 -42
- package/lib/__internal__/field-help/field-help.d.ts +0 -14
- package/lib/components/grid/grid-container/grid-container.d.ts +0 -18
- package/lib/components/grid/grid-item/grid-item.d.ts +0 -42
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useMenuKeyboardNavigation.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _useMenuKeyboardNavigation = _interopRequireDefault(require("./useMenuKeyboardNavigation"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _events = _interopRequireDefault(require("../../../__internal__/utils/helpers/events"));
|
|
11
|
+
|
|
12
|
+
var _focusTrapUtils = require("../../../__internal__/focus-trap/focus-trap-utils");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
var _default = (mainControlRef, childrenRefs, hide) => {
|
|
17
|
+
const childrenLength = (0, _react.useMemo)(() => childrenRefs.length, [childrenRefs]);
|
|
18
|
+
const handleKeyDown = (0, _react.useCallback)(ev => {
|
|
19
|
+
ev.preventDefault();
|
|
20
|
+
const currentIndex = childrenRefs === null || childrenRefs === void 0 ? void 0 : childrenRefs.findIndex(node => node.current === document.activeElement);
|
|
21
|
+
let nextIndex = -1;
|
|
22
|
+
|
|
23
|
+
const refocusMainControl = () => {
|
|
24
|
+
var _mainControlRef$curre;
|
|
25
|
+
|
|
26
|
+
hide();
|
|
27
|
+
(_mainControlRef$curre = mainControlRef.current) === null || _mainControlRef$curre === void 0 ? void 0 : _mainControlRef$curre.focus();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const arrowModifierPressed = ev.ctrlKey || ev.metaKey;
|
|
31
|
+
|
|
32
|
+
if (_events.default.isEndKey(ev) || arrowModifierPressed && _events.default.isDownKey(ev)) {
|
|
33
|
+
nextIndex = childrenLength - 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (_events.default.isHomeKey(ev) || arrowModifierPressed && _events.default.isUpKey(ev)) {
|
|
37
|
+
nextIndex = 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!arrowModifierPressed && _events.default.isUpKey(ev) && currentIndex > 0) {
|
|
41
|
+
nextIndex = currentIndex - 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!arrowModifierPressed && _events.default.isDownKey(ev) && currentIndex < childrenLength - 1) {
|
|
45
|
+
nextIndex = currentIndex + 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const tabPressed = _events.default.isTabKey(ev);
|
|
49
|
+
|
|
50
|
+
const tabShiftPressed = tabPressed && _events.default.isShiftKey(ev);
|
|
51
|
+
|
|
52
|
+
if (tabShiftPressed) {
|
|
53
|
+
if (currentIndex === 0) {
|
|
54
|
+
refocusMainControl();
|
|
55
|
+
} else {
|
|
56
|
+
nextIndex = currentIndex - 1;
|
|
57
|
+
}
|
|
58
|
+
} else if (tabPressed) {
|
|
59
|
+
if (currentIndex === childrenLength - 1) {
|
|
60
|
+
var _elements;
|
|
61
|
+
|
|
62
|
+
const elements = Array.from(document.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
|
|
63
|
+
const indexOf = elements.indexOf(mainControlRef.current);
|
|
64
|
+
(_elements = elements[indexOf + 1]) === null || _elements === void 0 ? void 0 : _elements.focus(); // // timeout enforces that the "hide" method will be run after browser focuses on the next element
|
|
65
|
+
|
|
66
|
+
setTimeout(hide, 0);
|
|
67
|
+
} else {
|
|
68
|
+
nextIndex = currentIndex + 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (nextIndex > -1) {
|
|
73
|
+
var _childrenRefs$nextInd;
|
|
74
|
+
|
|
75
|
+
(_childrenRefs$nextInd = childrenRefs[nextIndex].current) === null || _childrenRefs$nextInd === void 0 ? void 0 : _childrenRefs$nextInd.focus();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (_events.default.isEscKey(ev)) {
|
|
79
|
+
refocusMainControl();
|
|
80
|
+
}
|
|
81
|
+
}, [childrenLength, hide, childrenRefs, mainControlRef]);
|
|
82
|
+
return handleKeyDown;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "109.2
|
|
3
|
+
"version": "109.3.2",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -16,11 +16,10 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"start": "node ./scripts/check_node_version.js && start-storybook -p 9001 -c .storybook",
|
|
18
18
|
"start:debug-theme": "cross-env STORYBOOK_DEBUG_THEME=true npm run start",
|
|
19
|
-
"test": "jest --config=./jest.
|
|
20
|
-
"test-update": "jest --config=./jest.
|
|
19
|
+
"test": "jest --config=./jest.config.json",
|
|
20
|
+
"test-update": "jest --config=./jest.config.json --updateSnapshot",
|
|
21
21
|
"test:cypress": "npx cypress open --e2e",
|
|
22
22
|
"cypress:react": "npx cypress open --component",
|
|
23
|
-
"debug": "node --inspect ./node_modules/jest-cli/bin/jest --watch --config=./jest.conf.json",
|
|
24
23
|
"format": "prettier --write './src'",
|
|
25
24
|
"lint": "eslint ./src",
|
|
26
25
|
"build": "node ./scripts/build.js",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
export interface FieldHelpProps {
|
|
4
|
-
/** Child elements */
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
/** When true, label is placed in line an input */
|
|
7
|
-
labelInline?: boolean;
|
|
8
|
-
/** Width of a label in percentage. Works only when labelInline is true */
|
|
9
|
-
labelWidth?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare function FieldHelp(props: FieldHelpProps): JSX.Element;
|
|
13
|
-
|
|
14
|
-
export default FieldHelp;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { SpaceProps, GridProps } from "styled-system";
|
|
3
|
-
import { GridItemProps } from "../grid-item/grid-item";
|
|
4
|
-
|
|
5
|
-
type GridContainerChild =
|
|
6
|
-
| React.ReactElement<GridItemProps>
|
|
7
|
-
| boolean
|
|
8
|
-
| null
|
|
9
|
-
| undefined;
|
|
10
|
-
|
|
11
|
-
export interface GridContainerProps extends SpaceProps, GridProps {
|
|
12
|
-
/** Defines the Components to be rendered within the GridContainer. Requires GridItemProps */
|
|
13
|
-
children?: GridContainerChild | GridContainerChild[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare function GridContainer(props: GridContainerProps): JSX.Element;
|
|
17
|
-
|
|
18
|
-
export default GridContainer;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
PaddingProps,
|
|
4
|
-
GridAreaProps,
|
|
5
|
-
GridRowProps,
|
|
6
|
-
GridColumnProps,
|
|
7
|
-
} from "styled-system";
|
|
8
|
-
|
|
9
|
-
interface ResponsiveSettingsShape extends PaddingProps {
|
|
10
|
-
/** How the grid item is aligned along the block (column) axis. Values: start, end, center, stretch */
|
|
11
|
-
alignSelf?: string;
|
|
12
|
-
/** How the grid item is aligned along the inline (row) axis. Values: start, end, center, stretch */
|
|
13
|
-
justifySelf?: string;
|
|
14
|
-
/** Maximum width of the item */
|
|
15
|
-
maxWidth?: string;
|
|
16
|
-
/** Shorthand property for gridColumn and gridRow */
|
|
17
|
-
gridArea?: GridAreaProps;
|
|
18
|
-
/** Starting and ending column position of the GridItem within the GridContainer separated by "/" */
|
|
19
|
-
gridColumn?: GridColumnProps;
|
|
20
|
-
/** Starting and ending row position of the GridItem within the GridContainer separated by "/" */
|
|
21
|
-
gridRow?: GridRowProps;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface GridItemProps extends PaddingProps {
|
|
25
|
-
/** How the grid item is aligned along the block (column) axis. Values: start, end, center, stretch */
|
|
26
|
-
alignSelf?: string;
|
|
27
|
-
/** How the grid item is aligned along the inline (row) axis. Values: start, end, center, stretch */
|
|
28
|
-
justifySelf?: string;
|
|
29
|
-
/** Defines the Component(s) to be rendered within the GridItem */
|
|
30
|
-
children?: React.ReactNode;
|
|
31
|
-
/** Shorthand property for gridColumn and gridRow */
|
|
32
|
-
gridArea?: GridAreaProps;
|
|
33
|
-
/** Starting and ending column position of the GridItem within the GridContainer separated by "/" */
|
|
34
|
-
gridColumn?: GridColumnProps;
|
|
35
|
-
/** Starting and ending row position of the GridItem within the GridContainer separated by "/" */
|
|
36
|
-
gridRow?: GridRowProps;
|
|
37
|
-
responsiveSettings?: ResponsiveSettingsShape[];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
declare function GridItem(props: GridItemProps): JSX.Element;
|
|
41
|
-
|
|
42
|
-
export default GridItem;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
export interface FieldHelpProps {
|
|
4
|
-
/** Child elements */
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
/** When true, label is placed in line an input */
|
|
7
|
-
labelInline?: boolean;
|
|
8
|
-
/** Width of a label in percentage. Works only when labelInline is true */
|
|
9
|
-
labelWidth?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare function FieldHelp(props: FieldHelpProps): JSX.Element;
|
|
13
|
-
|
|
14
|
-
export default FieldHelp;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { SpaceProps, GridProps } from "styled-system";
|
|
3
|
-
import { GridItemProps } from "../grid-item/grid-item";
|
|
4
|
-
|
|
5
|
-
type GridContainerChild =
|
|
6
|
-
| React.ReactElement<GridItemProps>
|
|
7
|
-
| boolean
|
|
8
|
-
| null
|
|
9
|
-
| undefined;
|
|
10
|
-
|
|
11
|
-
export interface GridContainerProps extends SpaceProps, GridProps {
|
|
12
|
-
/** Defines the Components to be rendered within the GridContainer. Requires GridItemProps */
|
|
13
|
-
children?: GridContainerChild | GridContainerChild[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare function GridContainer(props: GridContainerProps): JSX.Element;
|
|
17
|
-
|
|
18
|
-
export default GridContainer;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
PaddingProps,
|
|
4
|
-
GridAreaProps,
|
|
5
|
-
GridRowProps,
|
|
6
|
-
GridColumnProps,
|
|
7
|
-
} from "styled-system";
|
|
8
|
-
|
|
9
|
-
interface ResponsiveSettingsShape extends PaddingProps {
|
|
10
|
-
/** How the grid item is aligned along the block (column) axis. Values: start, end, center, stretch */
|
|
11
|
-
alignSelf?: string;
|
|
12
|
-
/** How the grid item is aligned along the inline (row) axis. Values: start, end, center, stretch */
|
|
13
|
-
justifySelf?: string;
|
|
14
|
-
/** Maximum width of the item */
|
|
15
|
-
maxWidth?: string;
|
|
16
|
-
/** Shorthand property for gridColumn and gridRow */
|
|
17
|
-
gridArea?: GridAreaProps;
|
|
18
|
-
/** Starting and ending column position of the GridItem within the GridContainer separated by "/" */
|
|
19
|
-
gridColumn?: GridColumnProps;
|
|
20
|
-
/** Starting and ending row position of the GridItem within the GridContainer separated by "/" */
|
|
21
|
-
gridRow?: GridRowProps;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface GridItemProps extends PaddingProps {
|
|
25
|
-
/** How the grid item is aligned along the block (column) axis. Values: start, end, center, stretch */
|
|
26
|
-
alignSelf?: string;
|
|
27
|
-
/** How the grid item is aligned along the inline (row) axis. Values: start, end, center, stretch */
|
|
28
|
-
justifySelf?: string;
|
|
29
|
-
/** Defines the Component(s) to be rendered within the GridItem */
|
|
30
|
-
children?: React.ReactNode;
|
|
31
|
-
/** Shorthand property for gridColumn and gridRow */
|
|
32
|
-
gridArea?: GridAreaProps;
|
|
33
|
-
/** Starting and ending column position of the GridItem within the GridContainer separated by "/" */
|
|
34
|
-
gridColumn?: GridColumnProps;
|
|
35
|
-
/** Starting and ending row position of the GridItem within the GridContainer separated by "/" */
|
|
36
|
-
gridRow?: GridRowProps;
|
|
37
|
-
responsiveSettings?: ResponsiveSettingsShape[];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
declare function GridItem(props: GridItemProps): JSX.Element;
|
|
41
|
-
|
|
42
|
-
export default GridItem;
|