carbon-react 109.0.0 → 109.1.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.js +8 -11
- package/esm/components/flat-table/flat-table.style.js +1 -1
- package/esm/components/form/form.style.js +1 -1
- package/esm/components/inline-inputs/inline-inputs.component.d.ts +5 -9
- package/esm/components/inline-inputs/inline-inputs.component.js +14 -2
- package/esm/components/inline-inputs/inline-inputs.style.d.ts +18 -3
- package/esm/components/inline-inputs/inline-inputs.style.js +6 -2
- package/lib/__internal__/focus-trap/focus-trap.component.js +8 -11
- package/lib/components/flat-table/flat-table.style.js +1 -1
- package/lib/components/form/form.style.js +1 -1
- package/lib/components/inline-inputs/inline-inputs.component.d.ts +5 -9
- package/lib/components/inline-inputs/inline-inputs.component.js +15 -2
- package/lib/components/inline-inputs/inline-inputs.style.d.ts +18 -3
- package/lib/components/inline-inputs/inline-inputs.style.js +6 -2
- package/package.json +1 -1
|
@@ -109,12 +109,6 @@ const FocusTrap = ({
|
|
|
109
109
|
setCurrentFocusedElement(element);
|
|
110
110
|
}
|
|
111
111
|
}, [focusableElements]);
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
document.addEventListener("focusin", updateCurrentFocusedElement);
|
|
114
|
-
return () => {
|
|
115
|
-
document.removeEventListener("focusin", updateCurrentFocusedElement);
|
|
116
|
-
};
|
|
117
|
-
}, [updateCurrentFocusedElement]);
|
|
118
112
|
const refocusTrap = useCallback(() => {
|
|
119
113
|
var _wrapperRef$current;
|
|
120
114
|
|
|
@@ -148,13 +142,16 @@ const FocusTrap = ({
|
|
|
148
142
|
}
|
|
149
143
|
};
|
|
150
144
|
|
|
151
|
-
const focusProps = {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
145
|
+
const focusProps = hasNoTabIndex => ({ ...(hasNoTabIndex && {
|
|
146
|
+
tabIndex,
|
|
147
|
+
onBlur
|
|
148
|
+
}),
|
|
149
|
+
onFocus: updateCurrentFocusedElement
|
|
150
|
+
}); // passes focusProps, sets tabIndex and onBlur if no tabIndex has been expicitly set on child
|
|
151
|
+
|
|
155
152
|
|
|
156
153
|
const clonedChildren = React.Children.map(children, child => {
|
|
157
|
-
return
|
|
154
|
+
return /*#__PURE__*/React.cloneElement(child, focusProps(child.props.tabIndex === undefined));
|
|
158
155
|
});
|
|
159
156
|
return /*#__PURE__*/React.createElement("div", {
|
|
160
157
|
ref: trapRef
|
|
@@ -116,7 +116,7 @@ const StyledFlatTableWrapper = styled(Box)`
|
|
|
116
116
|
${StyledFlatTableHead} ${StyledFlatTableCheckbox} {
|
|
117
117
|
background-color: var(--colorsUtilityMajor100);
|
|
118
118
|
border-right: 1px solid var(--colorsUtilityMajor150);
|
|
119
|
-
border-bottom-color: var(--
|
|
119
|
+
border-bottom-color: var(--colorsUtilityMajor150);
|
|
120
120
|
}
|
|
121
121
|
`;
|
|
122
122
|
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { StyledContentContainerProps, StyledInlineInputsProps } from "./inline-inputs.style";
|
|
2
3
|
interface InlineInputsContextProps {
|
|
3
4
|
ariaLabelledBy?: string;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
export interface InlineInputsProps extends StyledContentContainerProps, StyledInlineInputsProps {
|
|
7
|
+
/** Breakpoint for adaptive label (inline label change to top aligned). Enables the adaptive behaviour when set */
|
|
8
|
+
adaptiveLabelBreakpoint?: number;
|
|
7
9
|
/** Children elements */
|
|
8
10
|
children?: React.ReactNode;
|
|
9
11
|
/** [Legacy prop] A custom class name for the component. */
|
|
10
12
|
className?: string;
|
|
11
|
-
/** Gutter prop gets passed down to Row component if false gutter value is "none" */
|
|
12
|
-
gutter?: GutterOptions;
|
|
13
13
|
/** The id of the corresponding input control for the label */
|
|
14
14
|
htmlFor?: string;
|
|
15
|
-
/** Width of the inline inputs container in percentage */
|
|
16
|
-
inputWidth?: number;
|
|
17
15
|
/** Defines the label text for the heading. */
|
|
18
16
|
label?: string;
|
|
19
|
-
/** Width of a label in percentage */
|
|
20
|
-
labelWidth?: number;
|
|
21
17
|
}
|
|
22
18
|
export declare const InlineInputsContext: React.Context<InlineInputsContextProps>;
|
|
23
19
|
declare const InlineInputs: {
|
|
24
|
-
({ label, htmlFor, children, className, gutter, inputWidth, labelWidth, }: InlineInputsProps): JSX.Element;
|
|
20
|
+
({ adaptiveLabelBreakpoint, label, htmlFor, children, className, gutter, inputWidth, labelInline, labelWidth, }: InlineInputsProps): JSX.Element;
|
|
25
21
|
displayName: string;
|
|
26
22
|
};
|
|
27
23
|
export default InlineInputs;
|
|
@@ -3,6 +3,7 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
import Label from "../../__internal__/label";
|
|
4
4
|
import StyledInlineInputs, { StyledContentContainer, StyledInlineInput } from "./inline-inputs.style";
|
|
5
5
|
import createGuid from "../../__internal__/utils/helpers/guid";
|
|
6
|
+
import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
|
|
6
7
|
export const InlineInputsContext = /*#__PURE__*/React.createContext({});
|
|
7
8
|
|
|
8
9
|
const columnWrapper = (children, gutter, labelId) => {
|
|
@@ -19,21 +20,29 @@ const columnWrapper = (children, gutter, labelId) => {
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
const InlineInputs = ({
|
|
23
|
+
adaptiveLabelBreakpoint,
|
|
22
24
|
label,
|
|
23
25
|
htmlFor,
|
|
24
26
|
children = null,
|
|
25
27
|
className = "",
|
|
26
28
|
gutter = "none",
|
|
27
29
|
inputWidth,
|
|
30
|
+
labelInline = true,
|
|
28
31
|
labelWidth
|
|
29
32
|
}) => {
|
|
30
33
|
const labelId = useRef(createGuid());
|
|
34
|
+
const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
|
|
35
|
+
let inlineLabel = labelInline;
|
|
36
|
+
|
|
37
|
+
if (adaptiveLabelBreakpoint) {
|
|
38
|
+
inlineLabel = largeScreen;
|
|
39
|
+
}
|
|
31
40
|
|
|
32
41
|
function renderLabel() {
|
|
33
42
|
if (!label) return null;
|
|
34
43
|
return /*#__PURE__*/React.createElement(Label, {
|
|
35
44
|
labelId: labelId.current,
|
|
36
|
-
inline:
|
|
45
|
+
inline: inlineLabel,
|
|
37
46
|
htmlFor: htmlFor
|
|
38
47
|
}, label);
|
|
39
48
|
}
|
|
@@ -42,7 +51,8 @@ const InlineInputs = ({
|
|
|
42
51
|
gutter: gutter,
|
|
43
52
|
"data-component": "inline-inputs",
|
|
44
53
|
className: className,
|
|
45
|
-
labelWidth: labelWidth
|
|
54
|
+
labelWidth: labelWidth,
|
|
55
|
+
labelInline: inlineLabel
|
|
46
56
|
}, renderLabel(), /*#__PURE__*/React.createElement(StyledContentContainer, {
|
|
47
57
|
gutter: gutter,
|
|
48
58
|
"data-element": "inline-inputs-container",
|
|
@@ -51,12 +61,14 @@ const InlineInputs = ({
|
|
|
51
61
|
};
|
|
52
62
|
|
|
53
63
|
InlineInputs.propTypes = {
|
|
64
|
+
"adaptiveLabelBreakpoint": PropTypes.number,
|
|
54
65
|
"children": PropTypes.node,
|
|
55
66
|
"className": PropTypes.string,
|
|
56
67
|
"gutter": PropTypes.oneOf(["extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "none", "small"]),
|
|
57
68
|
"htmlFor": PropTypes.string,
|
|
58
69
|
"inputWidth": PropTypes.number,
|
|
59
70
|
"label": PropTypes.string,
|
|
71
|
+
"labelInline": PropTypes.bool,
|
|
60
72
|
"labelWidth": PropTypes.number
|
|
61
73
|
};
|
|
62
74
|
InlineInputs.displayName = "InlineInputs";
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { InlineInputsProps } from "./inline-inputs.component";
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
declare type GutterOptions = "none" | "extra-small" | "small" | "medium-small" | "medium" | "medium-large" | "large" | "extra-large";
|
|
3
|
+
interface StyledInlineInputProps {
|
|
4
|
+
/** Gutter prop gets passed down to Row component if false gutter value is "none" */
|
|
5
|
+
gutter?: GutterOptions;
|
|
6
|
+
}
|
|
7
|
+
export interface StyledContentContainerProps extends StyledInlineInputProps {
|
|
8
|
+
/** Width of the inline inputs container in percentage */
|
|
9
|
+
inputWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface StyledInlineInputsProps extends StyledInlineInputProps {
|
|
12
|
+
/** Width of a label in percentage */
|
|
13
|
+
labelWidth?: number;
|
|
14
|
+
/** @ignore @private */
|
|
15
|
+
labelInline?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const StyledInlineInput: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
|
|
18
|
+
declare const StyledContentContainer: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
|
|
19
|
+
declare const StyledInlineInputs: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
|
|
5
20
|
export { StyledContentContainer, StyledInlineInput };
|
|
6
21
|
export default StyledInlineInputs;
|
|
@@ -42,12 +42,16 @@ const StyledContentContainer = styled.div`
|
|
|
42
42
|
`}
|
|
43
43
|
`;
|
|
44
44
|
const StyledInlineInputs = styled.div`
|
|
45
|
-
display:
|
|
45
|
+
display: ${({
|
|
46
|
+
labelInline
|
|
47
|
+
}) => labelInline ? `flex` : `block`};
|
|
46
48
|
align-items: center;
|
|
47
49
|
|
|
48
50
|
${StyledLabelContainer} {
|
|
49
51
|
width: auto;
|
|
50
|
-
margin-bottom:
|
|
52
|
+
margin-bottom: ${({
|
|
53
|
+
labelInline
|
|
54
|
+
}) => labelInline ? `0px` : `8px`};
|
|
51
55
|
padding-right: 16px;
|
|
52
56
|
flex: 0 0 ${({
|
|
53
57
|
labelWidth
|
|
@@ -126,12 +126,6 @@ const FocusTrap = ({
|
|
|
126
126
|
setCurrentFocusedElement(element);
|
|
127
127
|
}
|
|
128
128
|
}, [focusableElements]);
|
|
129
|
-
(0, _react.useEffect)(() => {
|
|
130
|
-
document.addEventListener("focusin", updateCurrentFocusedElement);
|
|
131
|
-
return () => {
|
|
132
|
-
document.removeEventListener("focusin", updateCurrentFocusedElement);
|
|
133
|
-
};
|
|
134
|
-
}, [updateCurrentFocusedElement]);
|
|
135
129
|
const refocusTrap = (0, _react.useCallback)(() => {
|
|
136
130
|
var _wrapperRef$current;
|
|
137
131
|
|
|
@@ -165,13 +159,16 @@ const FocusTrap = ({
|
|
|
165
159
|
}
|
|
166
160
|
};
|
|
167
161
|
|
|
168
|
-
const focusProps = {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
162
|
+
const focusProps = hasNoTabIndex => ({ ...(hasNoTabIndex && {
|
|
163
|
+
tabIndex,
|
|
164
|
+
onBlur
|
|
165
|
+
}),
|
|
166
|
+
onFocus: updateCurrentFocusedElement
|
|
167
|
+
}); // passes focusProps, sets tabIndex and onBlur if no tabIndex has been expicitly set on child
|
|
168
|
+
|
|
172
169
|
|
|
173
170
|
const clonedChildren = _react.default.Children.map(children, child => {
|
|
174
|
-
return
|
|
171
|
+
return /*#__PURE__*/_react.default.cloneElement(child, focusProps(child.props.tabIndex === undefined));
|
|
175
172
|
});
|
|
176
173
|
|
|
177
174
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -141,7 +141,7 @@ const StyledFlatTableWrapper = (0, _styledComponents.default)(_box.default)`
|
|
|
141
141
|
${_flatTableHead.default} ${_flatTableCheckbox.default} {
|
|
142
142
|
background-color: var(--colorsUtilityMajor100);
|
|
143
143
|
border-right: 1px solid var(--colorsUtilityMajor150);
|
|
144
|
-
border-bottom-color: var(--
|
|
144
|
+
border-bottom-color: var(--colorsUtilityMajor150);
|
|
145
145
|
}
|
|
146
146
|
`;
|
|
147
147
|
|
|
@@ -41,7 +41,7 @@ const StyledFormContent = _styledComponents.default.div`
|
|
|
41
41
|
isInModal
|
|
42
42
|
}) => (0, _styledComponents.css)`
|
|
43
43
|
${stickyFooter && (0, _styledComponents.css)`
|
|
44
|
-
overflow-y: ${isInModal ? "visible" : "
|
|
44
|
+
overflow-y: ${isInModal ? "visible" : "inherit"};
|
|
45
45
|
flex: 1;
|
|
46
46
|
`}
|
|
47
47
|
`}
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { StyledContentContainerProps, StyledInlineInputsProps } from "./inline-inputs.style";
|
|
2
3
|
interface InlineInputsContextProps {
|
|
3
4
|
ariaLabelledBy?: string;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
export interface InlineInputsProps extends StyledContentContainerProps, StyledInlineInputsProps {
|
|
7
|
+
/** Breakpoint for adaptive label (inline label change to top aligned). Enables the adaptive behaviour when set */
|
|
8
|
+
adaptiveLabelBreakpoint?: number;
|
|
7
9
|
/** Children elements */
|
|
8
10
|
children?: React.ReactNode;
|
|
9
11
|
/** [Legacy prop] A custom class name for the component. */
|
|
10
12
|
className?: string;
|
|
11
|
-
/** Gutter prop gets passed down to Row component if false gutter value is "none" */
|
|
12
|
-
gutter?: GutterOptions;
|
|
13
13
|
/** The id of the corresponding input control for the label */
|
|
14
14
|
htmlFor?: string;
|
|
15
|
-
/** Width of the inline inputs container in percentage */
|
|
16
|
-
inputWidth?: number;
|
|
17
15
|
/** Defines the label text for the heading. */
|
|
18
16
|
label?: string;
|
|
19
|
-
/** Width of a label in percentage */
|
|
20
|
-
labelWidth?: number;
|
|
21
17
|
}
|
|
22
18
|
export declare const InlineInputsContext: React.Context<InlineInputsContextProps>;
|
|
23
19
|
declare const InlineInputs: {
|
|
24
|
-
({ label, htmlFor, children, className, gutter, inputWidth, labelWidth, }: InlineInputsProps): JSX.Element;
|
|
20
|
+
({ adaptiveLabelBreakpoint, label, htmlFor, children, className, gutter, inputWidth, labelInline, labelWidth, }: InlineInputsProps): JSX.Element;
|
|
25
21
|
displayName: string;
|
|
26
22
|
};
|
|
27
23
|
export default InlineInputs;
|
|
@@ -15,6 +15,8 @@ var _inlineInputs = _interopRequireWildcard(require("./inline-inputs.style"));
|
|
|
15
15
|
|
|
16
16
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
17
17
|
|
|
18
|
+
var _useIsAboveBreakpoint = _interopRequireDefault(require("../../hooks/__internal__/useIsAboveBreakpoint"));
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
22
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -39,21 +41,29 @@ const columnWrapper = (children, gutter, labelId) => {
|
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
const InlineInputs = ({
|
|
44
|
+
adaptiveLabelBreakpoint,
|
|
42
45
|
label,
|
|
43
46
|
htmlFor,
|
|
44
47
|
children = null,
|
|
45
48
|
className = "",
|
|
46
49
|
gutter = "none",
|
|
47
50
|
inputWidth,
|
|
51
|
+
labelInline = true,
|
|
48
52
|
labelWidth
|
|
49
53
|
}) => {
|
|
50
54
|
const labelId = (0, _react.useRef)((0, _guid.default)());
|
|
55
|
+
const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveLabelBreakpoint);
|
|
56
|
+
let inlineLabel = labelInline;
|
|
57
|
+
|
|
58
|
+
if (adaptiveLabelBreakpoint) {
|
|
59
|
+
inlineLabel = largeScreen;
|
|
60
|
+
}
|
|
51
61
|
|
|
52
62
|
function renderLabel() {
|
|
53
63
|
if (!label) return null;
|
|
54
64
|
return /*#__PURE__*/_react.default.createElement(_label.default, {
|
|
55
65
|
labelId: labelId.current,
|
|
56
|
-
inline:
|
|
66
|
+
inline: inlineLabel,
|
|
57
67
|
htmlFor: htmlFor
|
|
58
68
|
}, label);
|
|
59
69
|
}
|
|
@@ -62,7 +72,8 @@ const InlineInputs = ({
|
|
|
62
72
|
gutter: gutter,
|
|
63
73
|
"data-component": "inline-inputs",
|
|
64
74
|
className: className,
|
|
65
|
-
labelWidth: labelWidth
|
|
75
|
+
labelWidth: labelWidth,
|
|
76
|
+
labelInline: inlineLabel
|
|
66
77
|
}, renderLabel(), /*#__PURE__*/_react.default.createElement(_inlineInputs.StyledContentContainer, {
|
|
67
78
|
gutter: gutter,
|
|
68
79
|
"data-element": "inline-inputs-container",
|
|
@@ -71,12 +82,14 @@ const InlineInputs = ({
|
|
|
71
82
|
};
|
|
72
83
|
|
|
73
84
|
InlineInputs.propTypes = {
|
|
85
|
+
"adaptiveLabelBreakpoint": _propTypes.default.number,
|
|
74
86
|
"children": _propTypes.default.node,
|
|
75
87
|
"className": _propTypes.default.string,
|
|
76
88
|
"gutter": _propTypes.default.oneOf(["extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "none", "small"]),
|
|
77
89
|
"htmlFor": _propTypes.default.string,
|
|
78
90
|
"inputWidth": _propTypes.default.number,
|
|
79
91
|
"label": _propTypes.default.string,
|
|
92
|
+
"labelInline": _propTypes.default.bool,
|
|
80
93
|
"labelWidth": _propTypes.default.number
|
|
81
94
|
};
|
|
82
95
|
InlineInputs.displayName = "InlineInputs";
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { InlineInputsProps } from "./inline-inputs.component";
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
declare type GutterOptions = "none" | "extra-small" | "small" | "medium-small" | "medium" | "medium-large" | "large" | "extra-large";
|
|
3
|
+
interface StyledInlineInputProps {
|
|
4
|
+
/** Gutter prop gets passed down to Row component if false gutter value is "none" */
|
|
5
|
+
gutter?: GutterOptions;
|
|
6
|
+
}
|
|
7
|
+
export interface StyledContentContainerProps extends StyledInlineInputProps {
|
|
8
|
+
/** Width of the inline inputs container in percentage */
|
|
9
|
+
inputWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface StyledInlineInputsProps extends StyledInlineInputProps {
|
|
12
|
+
/** Width of a label in percentage */
|
|
13
|
+
labelWidth?: number;
|
|
14
|
+
/** @ignore @private */
|
|
15
|
+
labelInline?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const StyledInlineInput: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
|
|
18
|
+
declare const StyledContentContainer: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
|
|
19
|
+
declare const StyledInlineInputs: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
|
|
5
20
|
export { StyledContentContainer, StyledInlineInput };
|
|
6
21
|
export default StyledInlineInputs;
|
|
@@ -61,12 +61,16 @@ const StyledContentContainer = _styledComponents.default.div`
|
|
|
61
61
|
`;
|
|
62
62
|
exports.StyledContentContainer = StyledContentContainer;
|
|
63
63
|
const StyledInlineInputs = _styledComponents.default.div`
|
|
64
|
-
display:
|
|
64
|
+
display: ${({
|
|
65
|
+
labelInline
|
|
66
|
+
}) => labelInline ? `flex` : `block`};
|
|
65
67
|
align-items: center;
|
|
66
68
|
|
|
67
69
|
${_label.StyledLabelContainer} {
|
|
68
70
|
width: auto;
|
|
69
|
-
margin-bottom:
|
|
71
|
+
margin-bottom: ${({
|
|
72
|
+
labelInline
|
|
73
|
+
}) => labelInline ? `0px` : `8px`};
|
|
70
74
|
padding-right: 16px;
|
|
71
75
|
flex: 0 0 ${({
|
|
72
76
|
labelWidth
|