carbon-react 147.4.3 → 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.
@@ -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(NewValidationContext.Provider, {
26
- value: {
27
- validationRedesignOptIn: false
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 FieldsetStyle: import("styled-components").StyledComponent<"fieldset", any, {}, never>;
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
- &&&& ${FormFieldStyle} {
13
- margin-top: 0;
14
- margin-bottom: -1px;
15
- }
12
+ ${({
13
+ newValidation
14
+ }) => !newValidation && css`
15
+ &&&& ${FormFieldStyle} {
16
+ margin-top: 0;
17
+ margin-bottom: -1px;
18
+ }
16
19
 
17
- & ${CheckboxStyle} {
18
- padding-top: 8px;
19
- padding-bottom: 8px;
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: 32px;
29
- font-size: 20px;
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
@@ -1,2 +1,2 @@
1
1
  export { default } from "./multi-action-button.component";
2
- export type { MultiActionButtonProps } from "./multi-action-button.component";
2
+ export type { MultiActionButtonHandle, MultiActionButtonProps, } from "./multi-action-button.component";
@@ -7,5 +7,9 @@ export interface MultiActionButtonProps extends WidthProps, Omit<SplitButtonProp
7
7
  /** Second text child, renders under main text, only when size is "large" */
8
8
  subtext?: string;
9
9
  }
10
- export declare const MultiActionButton: ({ align, position, disabled, buttonType, size, children, text, subtext, width, onClick, "data-element": dataElement, "data-role": dataRole, ...rest }: MultiActionButtonProps) => React.JSX.Element;
10
+ export declare type MultiActionButtonHandle = {
11
+ /** Programmatically focus the main button */
12
+ focusMainButton: () => void;
13
+ } | null;
14
+ export declare const MultiActionButton: React.ForwardRefExoticComponent<MultiActionButtonProps & React.RefAttributes<MultiActionButtonHandle>>;
11
15
  export default MultiActionButton;