carbon-react 105.1.0 → 105.2.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.
Files changed (165) hide show
  1. package/esm/__internal__/tooltip-provider/index.d.ts +19 -24
  2. package/esm/__internal__/tooltip-provider/index.js +0 -10
  3. package/esm/__spec_helper__/mock-match-media.d.ts +3 -1
  4. package/esm/components/app-wrapper/app-wrapper.component.d.ts +4 -0
  5. package/esm/components/badge/badge.style.d.ts +4 -2
  6. package/esm/components/button/button-types.style.d.ts +1 -2
  7. package/esm/components/button/button-types.style.js +3 -1
  8. package/esm/components/button/button.component.d.ts +67 -36
  9. package/esm/components/button/button.component.js +3314 -165
  10. package/esm/components/button/button.config.d.ts +4 -3
  11. package/esm/components/button/button.style.d.ts +6 -8
  12. package/esm/components/button/button.style.js +51 -95
  13. package/esm/components/button/index.d.ts +2 -2
  14. package/esm/components/duelling-picklist/picklist-group/picklist-group.style.d.ts +1 -2
  15. package/esm/components/duelling-picklist/picklist-item/picklist-item.style.d.ts +1 -2
  16. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
  17. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
  18. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +9 -0
  19. package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
  20. package/esm/components/heading/heading.component.d.ts +5 -0
  21. package/esm/components/icon/index.d.ts +1 -0
  22. package/esm/components/multi-action-button/multi-action-button.component.d.ts +3 -1
  23. package/esm/components/multi-action-button/multi-action-button.component.js +7 -5
  24. package/esm/components/multi-action-button/multi-action-button.d.ts +4 -2
  25. package/esm/components/multi-step-wizard/multi-step-wizard.d.ts +22 -0
  26. package/esm/components/multi-step-wizard/step/step.d.ts +6 -0
  27. package/esm/components/multi-step-wizard/step/step.style.d.ts +4 -2
  28. package/esm/components/radio-button/radio-button-svg.component.js +29 -16
  29. package/esm/components/scrollable-list/scrollable-list.component.d.ts +8 -0
  30. package/esm/components/select/option/index.d.ts +1 -1
  31. package/esm/components/split-button/split-button-toggle.style.d.ts +2 -6
  32. package/esm/components/split-button/split-button.component.d.ts +3 -1
  33. package/esm/components/split-button/split-button.component.js +7 -4
  34. package/esm/components/split-button/split-button.d.ts +5 -2
  35. package/esm/components/tooltip/index.d.ts +2 -1
  36. package/esm/components/tooltip/tooltip-pointer.style.d.ts +10 -1
  37. package/esm/components/tooltip/tooltip-pointer.style.js +5 -12
  38. package/esm/components/tooltip/tooltip.component.d.ts +33 -2
  39. package/esm/components/tooltip/tooltip.component.js +255 -110
  40. package/esm/components/tooltip/tooltip.config.d.ts +2 -1
  41. package/esm/components/tooltip/tooltip.style.d.ts +7 -2
  42. package/esm/components/tooltip/tooltip.style.js +7 -21
  43. package/esm/components/typography/typography.component.d.ts +1 -1
  44. package/esm/hooks/__internal__/useCharacterCount/index.d.ts +1 -2
  45. package/esm/hooks/__internal__/useCharacterCount/index.js +1 -18
  46. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +3 -0
  47. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +24 -0
  48. package/esm/hooks/__internal__/useInputAccessibility/index.d.ts +1 -24
  49. package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +11 -11
  50. package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.js +1 -3
  51. package/esm/hooks/__internal__/useIsAboveBreakpoint/index.d.ts +1 -1
  52. package/esm/hooks/__internal__/useIsAboveBreakpoint/index.js +1 -6
  53. package/esm/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.d.ts +1 -0
  54. package/esm/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js +6 -0
  55. package/esm/hooks/__internal__/useLocale/index.d.ts +1 -1
  56. package/esm/hooks/__internal__/useLocale/index.js +1 -5
  57. package/esm/hooks/__internal__/useLocale/useLocale.d.ts +1 -0
  58. package/esm/hooks/__internal__/useLocale/useLocale.js +5 -0
  59. package/esm/hooks/__internal__/useResizeObserver/index.d.ts +1 -10
  60. package/esm/hooks/__internal__/useResizeObserver/index.js +1 -23
  61. package/esm/hooks/__internal__/useResizeObserver/useResizeObserver.d.ts +8 -0
  62. package/esm/hooks/__internal__/useResizeObserver/useResizeObserver.js +29 -0
  63. package/esm/hooks/__internal__/useScrollBlock/index.d.ts +1 -4
  64. package/esm/hooks/__internal__/useScrollBlock/scroll-block-manager.d.ts +23 -9
  65. package/esm/hooks/__internal__/useScrollBlock/scroll-block-manager.js +24 -12
  66. package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.d.ts +2 -2
  67. package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.js +3 -5
  68. package/esm/hooks/useMediaQuery/index.d.ts +1 -1
  69. package/esm/hooks/useMediaQuery/index.js +1 -19
  70. package/esm/hooks/useMediaQuery/useMediaQuery.d.ts +1 -0
  71. package/esm/hooks/useMediaQuery/useMediaQuery.js +19 -0
  72. package/esm/locales/en-gb.d.ts +3 -5
  73. package/esm/locales/en-gb.js +5 -4
  74. package/esm/locales/index.d.ts +1 -1
  75. package/esm/locales/index.js +2 -0
  76. package/esm/locales/locale.d.ts +99 -105
  77. package/esm/locales/locale.js +1 -0
  78. package/esm/locales/pl-pl.d.ts +3 -5
  79. package/esm/locales/pl-pl.js +5 -4
  80. package/lib/__internal__/tooltip-provider/index.d.ts +19 -24
  81. package/lib/__internal__/tooltip-provider/index.js +1 -12
  82. package/lib/__spec_helper__/mock-match-media.d.ts +3 -1
  83. package/lib/components/app-wrapper/app-wrapper.component.d.ts +4 -0
  84. package/lib/components/badge/badge.style.d.ts +4 -2
  85. package/lib/components/button/button-types.style.d.ts +1 -2
  86. package/lib/components/button/button-types.style.js +0 -1
  87. package/lib/components/button/button.component.d.ts +67 -36
  88. package/lib/components/button/button.component.js +3381 -172
  89. package/lib/components/button/button.config.d.ts +4 -3
  90. package/lib/components/button/button.style.d.ts +6 -8
  91. package/lib/components/button/button.style.js +52 -101
  92. package/lib/components/button/index.d.ts +2 -2
  93. package/lib/components/duelling-picklist/picklist-group/picklist-group.style.d.ts +1 -2
  94. package/lib/components/duelling-picklist/picklist-item/picklist-item.style.d.ts +1 -2
  95. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
  96. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
  97. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +22 -0
  98. package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
  99. package/lib/components/heading/heading.component.d.ts +5 -0
  100. package/lib/components/icon/index.d.ts +1 -0
  101. package/lib/components/multi-action-button/multi-action-button.component.d.ts +3 -1
  102. package/lib/components/multi-action-button/multi-action-button.component.js +6 -4
  103. package/lib/components/multi-action-button/multi-action-button.d.ts +4 -2
  104. package/lib/components/multi-step-wizard/multi-step-wizard.d.ts +22 -0
  105. package/lib/components/multi-step-wizard/step/step.d.ts +6 -0
  106. package/lib/components/multi-step-wizard/step/step.style.d.ts +4 -2
  107. package/lib/components/radio-button/radio-button-svg.component.js +38 -20
  108. package/lib/components/scrollable-list/scrollable-list.component.d.ts +8 -0
  109. package/lib/components/select/option/index.d.ts +1 -1
  110. package/lib/components/split-button/split-button-toggle.style.d.ts +2 -6
  111. package/lib/components/split-button/split-button.component.d.ts +3 -1
  112. package/lib/components/split-button/split-button.component.js +6 -3
  113. package/lib/components/split-button/split-button.d.ts +5 -2
  114. package/lib/components/tooltip/index.d.ts +2 -1
  115. package/lib/components/tooltip/tooltip-pointer.style.d.ts +10 -1
  116. package/lib/components/tooltip/tooltip-pointer.style.js +7 -15
  117. package/lib/components/tooltip/tooltip.component.d.ts +33 -2
  118. package/lib/components/tooltip/tooltip.component.js +221 -130
  119. package/lib/components/tooltip/tooltip.config.d.ts +2 -1
  120. package/lib/components/tooltip/tooltip.style.d.ts +7 -2
  121. package/lib/components/tooltip/tooltip.style.js +7 -22
  122. package/lib/components/typography/typography.component.d.ts +1 -1
  123. package/lib/components/vertical-divider/vertical-divider.component.js +3 -0
  124. package/lib/hooks/__internal__/useCharacterCount/index.d.ts +1 -2
  125. package/lib/hooks/__internal__/useCharacterCount/index.js +8 -27
  126. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +3 -0
  127. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +40 -0
  128. package/lib/hooks/__internal__/useInputAccessibility/index.d.ts +1 -24
  129. package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +11 -11
  130. package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.js +1 -3
  131. package/lib/hooks/__internal__/useIsAboveBreakpoint/index.d.ts +1 -1
  132. package/lib/hooks/__internal__/useIsAboveBreakpoint/index.js +8 -9
  133. package/lib/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.d.ts +1 -0
  134. package/lib/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js +16 -0
  135. package/lib/hooks/__internal__/useLocale/index.d.ts +1 -1
  136. package/lib/hooks/__internal__/useLocale/index.js +8 -9
  137. package/lib/hooks/__internal__/useLocale/useLocale.d.ts +1 -0
  138. package/lib/hooks/__internal__/useLocale/useLocale.js +16 -0
  139. package/lib/hooks/__internal__/useResizeObserver/index.d.ts +1 -10
  140. package/lib/hooks/__internal__/useResizeObserver/index.js +8 -24
  141. package/lib/hooks/__internal__/useResizeObserver/useResizeObserver.d.ts +8 -0
  142. package/lib/hooks/__internal__/useResizeObserver/useResizeObserver.js +37 -0
  143. package/lib/hooks/__internal__/useScrollBlock/index.d.ts +1 -4
  144. package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.d.ts +23 -9
  145. package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.js +24 -12
  146. package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.d.ts +2 -2
  147. package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +3 -5
  148. package/lib/hooks/useMediaQuery/index.d.ts +1 -1
  149. package/lib/hooks/useMediaQuery/index.js +8 -25
  150. package/lib/hooks/useMediaQuery/useMediaQuery.d.ts +1 -0
  151. package/lib/hooks/useMediaQuery/useMediaQuery.js +32 -0
  152. package/lib/locales/en-gb.d.ts +3 -5
  153. package/lib/locales/en-gb.js +2 -1
  154. package/lib/locales/index.d.ts +1 -1
  155. package/lib/locales/index.js +23 -0
  156. package/lib/locales/locale.d.ts +99 -105
  157. package/lib/locales/locale.js +5 -0
  158. package/lib/locales/package.json +6 -0
  159. package/lib/locales/pl-pl.d.ts +3 -5
  160. package/lib/locales/pl-pl.js +2 -1
  161. package/package.json +11 -6
  162. package/esm/components/button/button.d.ts +0 -85
  163. package/esm/components/tooltip/tooltip.d.ts +0 -40
  164. package/lib/components/button/button.d.ts +0 -85
  165. package/lib/components/tooltip/tooltip.d.ts +0 -40
@@ -1,26 +1,21 @@
1
- import * as React from "react";
2
-
3
- export interface ToolbarContextProps {
4
- tooltipPosition: "top" | "bottom" | "left" | "right";
1
+ import React from "react";
2
+ interface TooltipProviderProps {
3
+ /** The position to display the tooltip */
4
+ tooltipPosition?: "top" | "bottom" | "left" | "right";
5
+ /** Control whether the tooltip is visible */
6
+ children: React.ReactNode;
7
+ /** Aria label for rendered help component */
8
+ helpAriaLabel?: string;
9
+ focusable?: boolean;
10
+ tooltipVisible?: boolean;
11
+ disabled?: boolean;
12
+ target?: Element;
5
13
  }
6
-
7
- export interface TooltipProviderProps {
8
- /** The position to display the tooltip */
9
- tooltipPosition?: "top" | "bottom" | "left" | "right";
10
- /** Control whether the tooltip is visible */
11
- children: React.ReactNode;
12
- /** Aria label for rendered help component */
13
- helpAriaLabel?: string;
14
- focusable?: boolean;
15
- tooltipVisible?: boolean;
16
- disabled?: boolean;
17
- target?: Element;
14
+ interface ToolbarContextProps extends Omit<TooltipProviderProps, "children"> {
15
+ tooltipId?: {
16
+ current: string;
17
+ };
18
18
  }
19
-
20
- declare const ToolbarContext: React.Context<ToolbarContextProps>;
21
-
22
- declare function TooltipProvider(props: TooltipProviderProps): JSX.Element;
23
-
24
- export { ToolbarContext };
25
-
26
- export default TooltipProvider;
19
+ export declare const TooltipContext: React.Context<ToolbarContextProps>;
20
+ export declare const TooltipProvider: ({ children, tooltipPosition, helpAriaLabel, focusable, tooltipVisible, disabled, target, }: TooltipProviderProps) => JSX.Element;
21
+ export {};
@@ -1,5 +1,4 @@
1
1
  import React, { useRef } from "react";
2
- import PropTypes from "prop-types";
3
2
  import guid from "../utils/helpers/guid/guid";
4
3
  export const TooltipContext = /*#__PURE__*/React.createContext({});
5
4
  export const TooltipProvider = ({
@@ -23,13 +22,4 @@ export const TooltipProvider = ({
23
22
  target
24
23
  }
25
24
  }, children);
26
- };
27
- TooltipProvider.propTypes = {
28
- children: PropTypes.node.isRequired,
29
- tooltipPosition: PropTypes.oneOf(["top", "bottom", "left", "right"]),
30
- helpAriaLabel: PropTypes.string,
31
- focusable: PropTypes.bool,
32
- tooltipVisible: PropTypes.bool,
33
- disabled: PropTypes.bool,
34
- target: PropTypes.instanceOf(Element)
35
25
  };
@@ -1,4 +1,6 @@
1
1
  declare function setup(): void;
2
- declare function mockMatchMedia(matches?: boolean): jest.Mock;
2
+ declare function mockMatchMedia(
3
+ matches?: boolean
4
+ ): { removeListener: jest.Mock };
3
5
 
4
6
  export { setup, mockMatchMedia };
@@ -11,6 +11,10 @@ declare class AppWrapper extends React.Component<any, any, any> {
11
11
  * @return {String}
12
12
  */
13
13
  classes(): string;
14
+ /**
15
+ * @method render
16
+ */
17
+ render(): JSX.Element;
14
18
  }
15
19
  declare namespace AppWrapper {
16
20
  namespace propTypes {
@@ -1,6 +1,8 @@
1
1
  export const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export const StyledButton: import("styled-components").StyledComponent<typeof Button, any, {}, never>;
2
+ export const StyledButton: import("styled-components").StyledComponent<{
3
+ ({ size, subtext, as, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: import("../button").ButtonProps): JSX.Element;
4
+ displayName: string;
5
+ }, any, {}, never>;
3
6
  export const StyledCrossIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
4
7
  export const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- import Button from "../button";
6
8
  import Icon from "../icon";
@@ -1,5 +1,4 @@
1
- export function makeColors(color: any): string;
2
- declare function _default(isDisabled: any, destructive: any): {
1
+ declare const _default: (isDisabled?: boolean | undefined, destructive?: boolean | undefined) => {
3
2
  primary: string;
4
3
  secondary: string;
5
4
  tertiary: string;
@@ -1,5 +1,6 @@
1
1
  import StyledIcon from "../icon/icon.style";
2
- export function makeColors(color) {
2
+
3
+ function makeColors(color) {
3
4
  return `
4
5
  color: ${color};
5
6
  ${StyledIcon} {
@@ -7,6 +8,7 @@ export function makeColors(color) {
7
8
  }
8
9
  `;
9
10
  }
11
+
10
12
  export default ((isDisabled, destructive) => ({
11
13
  primary: `
12
14
  background: var(--colorsActionMajor500);
@@ -1,37 +1,68 @@
1
- export default Button;
2
- export const ButtonWithForwardRef: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- declare function Button({ size, subtext, as, children, forwardRef, "aria-label": ariaLabel, disabled, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, ...rest }: {
4
- [x: string]: any;
5
- size: any;
6
- subtext: any;
7
- as: any;
8
- children: any;
9
- forwardRef: any;
10
- "aria-label": any;
11
- disabled: any;
12
- buttonType: any;
13
- iconType: any;
14
- iconPosition: any;
15
- href: any;
16
- m?: number | undefined;
17
- px: any;
18
- noWrap: any;
19
- target: any;
20
- rel: any;
21
- iconTooltipMessage: any;
22
- iconTooltipPosition: any;
23
- }): JSX.Element;
24
- declare namespace Button {
25
- const propTypes: any;
26
- namespace defaultProps {
27
- const buttonType: string;
28
- const size: string;
29
- const fullWidth: boolean;
30
- const disabled: boolean;
31
- const destructive: boolean;
32
- const iconPosition: string;
33
- const subtext: string;
34
- }
35
- const displayName: string;
36
- }
37
1
  import React from "react";
2
+ import { SpaceProps } from "styled-system";
3
+ import { IconType, TooltipPositions } from "../icon";
4
+ export declare type ButtonTypes = "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground";
5
+ export declare type SizeOptions = "small" | "medium" | "large";
6
+ export declare type ButtonIconPosition = "before" | "after";
7
+ export interface ButtonProps extends SpaceProps {
8
+ /** Prop to specify the aria-label text.
9
+ * Only to be used in Button when only an icon is rendered.
10
+ * This is required to comply with WCAG 4.1.2 - Buttons must have discernible text
11
+ */
12
+ "aria-label"?: string;
13
+ /** [Legacy] Button types for legacy theme: "primary" | "secondary" */
14
+ as?: ButtonTypes;
15
+ /** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "darkBackground" */
16
+ buttonType?: ButtonTypes;
17
+ /** The text the button displays */
18
+ children?: React.ReactNode;
19
+ /** Name attribute */
20
+ name?: string;
21
+ /** Apply disabled state to the button */
22
+ disabled?: boolean;
23
+ /** Apply destructive style to the button */
24
+ destructive?: boolean;
25
+ /** Ref to be forwarded */
26
+ forwardRef?: React.RefCallback<HTMLButtonElement> | React.MutableRefObject<HTMLButtonElement | null> | null;
27
+ /** Apply fullWidth style to the button */
28
+ fullWidth?: boolean;
29
+ /** Used to transform button into anchor */
30
+ href?: string;
31
+ /** Defines an Icon position related to the children: "before" | "after" */
32
+ iconPosition?: ButtonIconPosition;
33
+ /** Provides a tooltip message when the icon is hovered. */
34
+ iconTooltipMessage?: string;
35
+ /** Provides positioning when the tooltip is displayed. */
36
+ iconTooltipPosition?: TooltipPositions;
37
+ /** Defines an Icon type within the button */
38
+ iconType?: IconType;
39
+ /** If provided, the text inside a button will not wrap */
40
+ noWrap?: boolean;
41
+ /** Specify a callback triggered on blur */
42
+ onBlur?: (ev: React.FocusEvent<HTMLButtonElement>) => void;
43
+ /** Specify a callback triggered on change */
44
+ onChange?: (ev: React.ChangeEvent<HTMLButtonElement>) => void;
45
+ /** Specify a callback triggered on focus */
46
+ onFocus?: (ev: React.FocusEvent<HTMLButtonElement>) => void;
47
+ /** Specify a callback triggered on keyDown */
48
+ onKeyDown?: (ev: React.KeyboardEvent<HTMLButtonElement>) => void;
49
+ /** onClick handler */
50
+ onClick?: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void;
51
+ /** Assigns a size to the button: "small" | "medium" | "large" */
52
+ size?: SizeOptions;
53
+ /** Second text child, renders under main text, only when size is "large" */
54
+ subtext?: string;
55
+ /** HTML button type property */
56
+ type?: string;
57
+ /** HTML target attribute */
58
+ target?: string;
59
+ /** HTML rel attribute */
60
+ rel?: string;
61
+ }
62
+ declare const Button: {
63
+ ({ size, subtext, as, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: ButtonProps): JSX.Element;
64
+ displayName: string;
65
+ };
66
+ declare const ButtonWithForwardRef: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
67
+ export { ButtonWithForwardRef };
68
+ export default Button;