carbon-react 147.5.0 → 147.6.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/components/fieldset/fieldset.component.js +9 -9
- package/esm/components/fieldset/fieldset.style.d.ts +5 -2
- package/esm/components/fieldset/fieldset.style.js +14 -11
- package/lib/components/fieldset/fieldset.component.js +8 -8
- package/lib/components/fieldset/fieldset.style.d.ts +5 -2
- package/lib/components/fieldset/fieldset.style.js +14 -11
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
+
import React, { useState, useEffect, useContext } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
5
5
|
import { FieldsetStyle, StyledLegend } from "./fieldset.style";
|
|
@@ -15,6 +15,9 @@ export const Fieldset = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
const [ref, setRef] = useState(null);
|
|
17
17
|
const marginProps = useFormSpacing(rest);
|
|
18
|
+
const {
|
|
19
|
+
validationRedesignOptIn
|
|
20
|
+
} = useContext(NewValidationContext);
|
|
18
21
|
useEffect(() => {
|
|
19
22
|
if (ref && required) {
|
|
20
23
|
Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
|
|
@@ -22,19 +25,16 @@ export const Fieldset = ({
|
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
27
|
}, [ref, required]);
|
|
25
|
-
return /*#__PURE__*/React.createElement(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}, /*#__PURE__*/React.createElement(FieldsetStyle, _extends({
|
|
30
|
-
ref: setRef
|
|
28
|
+
return /*#__PURE__*/React.createElement(FieldsetStyle, _extends({
|
|
29
|
+
ref: setRef,
|
|
30
|
+
newValidation: validationRedesignOptIn
|
|
31
31
|
}, tagComponent("fieldset", rest), rest, marginProps), legend && /*#__PURE__*/React.createElement(StyledLegend, {
|
|
32
32
|
"data-element": "legend",
|
|
33
33
|
isRequired: required,
|
|
34
34
|
isOptional: isOptional
|
|
35
|
-
}, legend), /*#__PURE__*/React.createElement(FormSpacingProvider, {
|
|
35
|
+
}, legend), validationRedesignOptIn ? children : /*#__PURE__*/React.createElement(FormSpacingProvider, {
|
|
36
36
|
marginBottom: undefined
|
|
37
|
-
}, children))
|
|
37
|
+
}, children));
|
|
38
38
|
};
|
|
39
39
|
Fieldset.displayName = "Fieldset";
|
|
40
40
|
export default Fieldset;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export interface StyledFieldsetProps {
|
|
2
|
+
newValidation?: boolean;
|
|
3
|
+
}
|
|
4
|
+
declare const FieldsetStyle: import("styled-components").StyledComponent<"fieldset", any, StyledFieldsetProps, never>;
|
|
5
|
+
export interface StyledLegendProps {
|
|
2
6
|
/** Flag to configure fields as mandatory. */
|
|
3
7
|
isRequired?: boolean;
|
|
4
8
|
/** Flag to configure fields as optional. */
|
|
5
9
|
isOptional?: boolean;
|
|
6
10
|
}
|
|
7
|
-
declare const
|
|
8
|
-
declare const StyledLegend: import("styled-components").StyledComponent<"legend", any, StyledFieldsetProps, never>;
|
|
11
|
+
declare const StyledLegend: import("styled-components").StyledComponent<"legend", any, StyledLegendProps, never>;
|
|
9
12
|
export { FieldsetStyle, StyledLegend };
|
|
@@ -9,15 +9,19 @@ const FieldsetStyle = styled.fieldset`
|
|
|
9
9
|
border: none;
|
|
10
10
|
padding: 0;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
${({
|
|
13
|
+
newValidation
|
|
14
|
+
}) => !newValidation && css`
|
|
15
|
+
&&&& ${FormFieldStyle} {
|
|
16
|
+
margin-top: 0;
|
|
17
|
+
margin-bottom: -1px;
|
|
18
|
+
}
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
& ${CheckboxStyle} {
|
|
21
|
+
padding-top: 8px;
|
|
22
|
+
padding-bottom: 8px;
|
|
23
|
+
}
|
|
24
|
+
`}
|
|
21
25
|
`;
|
|
22
26
|
FieldsetStyle.defaultProps = {
|
|
23
27
|
theme: baseTheme
|
|
@@ -25,12 +29,11 @@ FieldsetStyle.defaultProps = {
|
|
|
25
29
|
const StyledLegend = styled.legend`
|
|
26
30
|
display: flex;
|
|
27
31
|
align-items: center;
|
|
28
|
-
margin-bottom:
|
|
29
|
-
font-size:
|
|
32
|
+
margin-bottom: var(--spacing250);
|
|
33
|
+
font-size: var(--fontSizes400);
|
|
30
34
|
font-weight: var(--fontWeights500);
|
|
31
35
|
color: var(--colorsUtilityYin090);
|
|
32
36
|
line-height: 24px;
|
|
33
|
-
margin-right: 4px;
|
|
34
37
|
|
|
35
38
|
${({
|
|
36
39
|
isRequired
|
|
@@ -24,6 +24,9 @@ const Fieldset = ({
|
|
|
24
24
|
}) => {
|
|
25
25
|
const [ref, setRef] = (0, _react.useState)(null);
|
|
26
26
|
const marginProps = (0, _useFormSpacing.default)(rest);
|
|
27
|
+
const {
|
|
28
|
+
validationRedesignOptIn
|
|
29
|
+
} = (0, _react.useContext)(_newValidation.default);
|
|
27
30
|
(0, _react.useEffect)(() => {
|
|
28
31
|
if (ref && required) {
|
|
29
32
|
Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
|
|
@@ -31,19 +34,16 @@ const Fieldset = ({
|
|
|
31
34
|
});
|
|
32
35
|
}
|
|
33
36
|
}, [ref, required]);
|
|
34
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
}, /*#__PURE__*/_react.default.createElement(_fieldset.FieldsetStyle, _extends({
|
|
39
|
-
ref: setRef
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement(_fieldset.FieldsetStyle, _extends({
|
|
38
|
+
ref: setRef,
|
|
39
|
+
newValidation: validationRedesignOptIn
|
|
40
40
|
}, (0, _tags.default)("fieldset", rest), rest, marginProps), legend && /*#__PURE__*/_react.default.createElement(_fieldset.StyledLegend, {
|
|
41
41
|
"data-element": "legend",
|
|
42
42
|
isRequired: required,
|
|
43
43
|
isOptional: isOptional
|
|
44
|
-
}, legend), /*#__PURE__*/_react.default.createElement(_formSpacingProvider.default, {
|
|
44
|
+
}, legend), validationRedesignOptIn ? children : /*#__PURE__*/_react.default.createElement(_formSpacingProvider.default, {
|
|
45
45
|
marginBottom: undefined
|
|
46
|
-
}, children))
|
|
46
|
+
}, children));
|
|
47
47
|
};
|
|
48
48
|
exports.Fieldset = Fieldset;
|
|
49
49
|
Fieldset.displayName = "Fieldset";
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export interface StyledFieldsetProps {
|
|
2
|
+
newValidation?: boolean;
|
|
3
|
+
}
|
|
4
|
+
declare const FieldsetStyle: import("styled-components").StyledComponent<"fieldset", any, StyledFieldsetProps, never>;
|
|
5
|
+
export interface StyledLegendProps {
|
|
2
6
|
/** Flag to configure fields as mandatory. */
|
|
3
7
|
isRequired?: boolean;
|
|
4
8
|
/** Flag to configure fields as optional. */
|
|
5
9
|
isOptional?: boolean;
|
|
6
10
|
}
|
|
7
|
-
declare const
|
|
8
|
-
declare const StyledLegend: import("styled-components").StyledComponent<"legend", any, StyledFieldsetProps, never>;
|
|
11
|
+
declare const StyledLegend: import("styled-components").StyledComponent<"legend", any, StyledLegendProps, never>;
|
|
9
12
|
export { FieldsetStyle, StyledLegend };
|
|
@@ -18,15 +18,19 @@ const FieldsetStyle = exports.FieldsetStyle = _styledComponents.default.fieldset
|
|
|
18
18
|
border: none;
|
|
19
19
|
padding: 0;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
${({
|
|
22
|
+
newValidation
|
|
23
|
+
}) => !newValidation && (0, _styledComponents.css)`
|
|
24
|
+
&&&& ${_formField.default} {
|
|
25
|
+
margin-top: 0;
|
|
26
|
+
margin-bottom: -1px;
|
|
27
|
+
}
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
& ${_checkbox.default} {
|
|
30
|
+
padding-top: 8px;
|
|
31
|
+
padding-bottom: 8px;
|
|
32
|
+
}
|
|
33
|
+
`}
|
|
30
34
|
`;
|
|
31
35
|
FieldsetStyle.defaultProps = {
|
|
32
36
|
theme: _base.default
|
|
@@ -34,12 +38,11 @@ FieldsetStyle.defaultProps = {
|
|
|
34
38
|
const StyledLegend = exports.StyledLegend = _styledComponents.default.legend`
|
|
35
39
|
display: flex;
|
|
36
40
|
align-items: center;
|
|
37
|
-
margin-bottom:
|
|
38
|
-
font-size:
|
|
41
|
+
margin-bottom: var(--spacing250);
|
|
42
|
+
font-size: var(--fontSizes400);
|
|
39
43
|
font-weight: var(--fontWeights500);
|
|
40
44
|
color: var(--colorsUtilityYin090);
|
|
41
45
|
line-height: 24px;
|
|
42
|
-
margin-right: 4px;
|
|
43
46
|
|
|
44
47
|
${({
|
|
45
48
|
isRequired
|