carbon-react 106.6.0 → 106.6.3

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 (86) hide show
  1. package/esm/__internal__/popover/popover.component.js +4 -5
  2. package/esm/__spec_helper__/expect.d.ts +8 -1
  3. package/esm/__spec_helper__/expect.js +1 -5
  4. package/esm/__spec_helper__/test-utils.d.ts +71 -33
  5. package/esm/__spec_helper__/test-utils.js +63 -65
  6. package/esm/components/action-popover/action-popover-context.d.ts +7 -2
  7. package/esm/components/action-popover/action-popover-context.js +1 -1
  8. package/esm/components/action-popover/action-popover-divider/action-popover-divider.component.d.ts +1 -1
  9. package/esm/components/action-popover/action-popover-item/action-popover-item.component.d.ts +28 -41
  10. package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +99 -118
  11. package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.d.ts +35 -2
  12. package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +42 -53
  13. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +20 -18
  14. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +13 -5
  15. package/esm/components/action-popover/action-popover-test.stories.js +76 -0
  16. package/esm/components/action-popover/action-popover.component.d.ts +30 -53
  17. package/esm/components/action-popover/action-popover.component.js +205 -67
  18. package/esm/components/action-popover/action-popover.style.d.ts +17 -11
  19. package/esm/components/action-popover/action-popover.style.js +20 -26
  20. package/esm/components/action-popover/index.d.ts +9 -5
  21. package/esm/components/box/box.component.d.ts +12 -1
  22. package/esm/components/box/box.component.js +12 -23
  23. package/esm/components/box/box.config.d.ts +10 -12
  24. package/esm/components/box/index.d.ts +2 -1
  25. package/esm/components/dismissible-box/dismissible-box.style.d.ts +1 -2
  26. package/esm/components/drawer/drawer.style.d.ts +1 -2
  27. package/esm/components/duelling-picklist/picklist/picklist.style.d.ts +2 -3
  28. package/esm/components/flat-table/flat-table.style.d.ts +1 -2
  29. package/esm/components/form/form.component.js +2 -1
  30. package/esm/components/modal/modal.component.js +3 -60
  31. package/esm/components/select/select.style.js +1 -1
  32. package/esm/components/toast/toast.component.js +3 -13
  33. package/esm/hooks/__internal__/useModalManager/index.d.ts +1 -0
  34. package/esm/hooks/__internal__/useModalManager/index.js +1 -0
  35. package/esm/hooks/__internal__/useModalManager/useModalManager.d.ts +3 -0
  36. package/esm/hooks/__internal__/useModalManager/useModalManager.js +66 -0
  37. package/lib/__internal__/popover/popover.component.js +4 -5
  38. package/lib/__spec_helper__/expect.d.ts +8 -1
  39. package/lib/__spec_helper__/expect.js +2 -4
  40. package/lib/__spec_helper__/test-utils.d.ts +71 -33
  41. package/lib/__spec_helper__/test-utils.js +63 -65
  42. package/lib/components/action-popover/action-popover-context.d.ts +7 -2
  43. package/lib/components/action-popover/action-popover-context.js +1 -1
  44. package/lib/components/action-popover/action-popover-divider/action-popover-divider.component.d.ts +1 -1
  45. package/lib/components/action-popover/action-popover-item/action-popover-item.component.d.ts +28 -41
  46. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +100 -119
  47. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.d.ts +35 -2
  48. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +44 -55
  49. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +20 -18
  50. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +13 -5
  51. package/lib/components/action-popover/action-popover-test.stories.js +95 -0
  52. package/lib/components/action-popover/action-popover.component.d.ts +30 -53
  53. package/lib/components/action-popover/action-popover.component.js +206 -71
  54. package/lib/components/action-popover/action-popover.style.d.ts +17 -11
  55. package/lib/components/action-popover/action-popover.style.js +21 -28
  56. package/lib/components/action-popover/index.d.ts +9 -5
  57. package/lib/components/box/box.component.d.ts +12 -1
  58. package/lib/components/box/box.component.js +13 -26
  59. package/lib/components/box/box.config.d.ts +10 -12
  60. package/lib/components/box/index.d.ts +2 -1
  61. package/lib/components/dismissible-box/dismissible-box.style.d.ts +1 -2
  62. package/lib/components/drawer/drawer.style.d.ts +1 -2
  63. package/lib/components/duelling-picklist/picklist/picklist.style.d.ts +2 -3
  64. package/lib/components/flat-table/flat-table.style.d.ts +1 -2
  65. package/lib/components/form/form.component.js +2 -1
  66. package/lib/components/modal/modal.component.js +3 -62
  67. package/lib/components/select/select.style.js +1 -1
  68. package/lib/components/toast/toast.component.js +4 -17
  69. package/lib/hooks/__internal__/useModalManager/index.d.ts +1 -0
  70. package/lib/hooks/__internal__/useModalManager/index.js +15 -0
  71. package/lib/hooks/__internal__/useModalManager/package.json +6 -0
  72. package/lib/hooks/__internal__/useModalManager/useModalManager.d.ts +3 -0
  73. package/lib/hooks/__internal__/useModalManager/useModalManager.js +79 -0
  74. package/package.json +5 -1
  75. package/esm/components/action-popover/action-popover-divider/action-popover-divider.d.ts +0 -12
  76. package/esm/components/action-popover/action-popover-item/action-popover-item.d.ts +0 -26
  77. package/esm/components/action-popover/action-popover-menu/action-popover-menu.d.ts +0 -33
  78. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.d.ts +0 -13
  79. package/esm/components/action-popover/action-popover.d.ts +0 -39
  80. package/esm/components/box/box.d.ts +0 -31
  81. package/lib/components/action-popover/action-popover-divider/action-popover-divider.d.ts +0 -12
  82. package/lib/components/action-popover/action-popover-item/action-popover-item.d.ts +0 -26
  83. package/lib/components/action-popover/action-popover-menu/action-popover-menu.d.ts +0 -33
  84. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.d.ts +0 -13
  85. package/lib/components/action-popover/action-popover.d.ts +0 -39
  86. package/lib/components/box/box.d.ts +0 -31
@@ -1,2 +1,13 @@
1
+ import React from "react";
2
+ import { SpaceProps, LayoutProps, FlexboxProps, ColorProps } from "styled-system";
3
+ export declare type OverflowWrap = "break-word" | "anywhere";
4
+ export declare type ScrollVariant = "light" | "dark";
5
+ export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorProps {
6
+ as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
7
+ /** String to set Box content break strategy. Note "anywhere" is not supported in Safari */
8
+ overflowWrap?: OverflowWrap;
9
+ /** scroll styling attribute */
10
+ scrollVariant?: ScrollVariant;
11
+ }
12
+ declare const Box: import("styled-components").StyledComponent<"div", any, BoxProps, never>;
1
13
  export default Box;
2
- declare const Box: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,15 +1,23 @@
1
- import propTypes from "@styled-system/prop-types";
2
- import PropTypes from "prop-types";
3
1
  import styled, { css } from "styled-components";
4
2
  import { space, layout, flexbox } from "styled-system";
5
3
  import BaseTheme from "../../style/themes/base";
6
- import color from "../../style/utils/color";
4
+ import styledColor from "../../style/utils/color";
7
5
  import boxConfig from "./box.config";
8
6
  const Box = styled.div`
9
7
  ${space}
10
8
  ${layout}
11
9
  ${flexbox}
12
- ${color}
10
+ ${({
11
+ color,
12
+ bg,
13
+ backgroundColor,
14
+ ...rest
15
+ }) => styledColor({
16
+ color,
17
+ bg,
18
+ backgroundColor,
19
+ ...rest
20
+ })}
13
21
 
14
22
  ${({
15
23
  overflowWrap
@@ -34,25 +42,6 @@ const Box = styled.div`
34
42
  }
35
43
  `}
36
44
  `;
37
- Box.propTypes = {
38
- /** Styled system box props */
39
- ...propTypes.space,
40
-
41
- /** Styled system flex props */
42
- ...propTypes.flexbox,
43
-
44
- /** Styled system layout props */
45
- ...propTypes.layout,
46
-
47
- /** Styled system color props */
48
- ...propTypes.color,
49
-
50
- /** String to set Box content break strategy. Note "anywhere" is not supported in Safari and IE11 */
51
- overflowWrap: PropTypes.oneOf(["break-word", "anywhere"]),
52
-
53
- /** scroll styling attribute */
54
- scrollVariant: PropTypes.oneOf(["light", "dark"])
55
- };
56
45
  Box.defaultProps = {
57
46
  theme: BaseTheme
58
47
  };
@@ -1,13 +1,11 @@
1
- declare namespace _default {
2
- namespace light {
3
- const thumb: string;
4
- const track: string;
5
- }
6
- namespace dark {
7
- const thumb_1: string;
8
- export { thumb_1 as thumb };
9
- const track_1: string;
10
- export { track_1 as track };
11
- }
12
- }
1
+ declare const _default: {
2
+ light: {
3
+ thumb: string;
4
+ track: string;
5
+ };
6
+ dark: {
7
+ thumb: string;
8
+ track: string;
9
+ };
10
+ };
13
11
  export default _default;
@@ -1 +1,2 @@
1
- export { default } from "./box";
1
+ export { default } from "./box.component";
2
+ export type { BoxProps } from "./box.component";
@@ -1,3 +1,2 @@
1
- declare var _default: import("styled-components").StyledComponent<typeof Box, any, {}, never>;
1
+ declare var _default: import("styled-components").StyledComponent<"div", any, import("../box").BoxProps, never>;
2
2
  export default _default;
3
- import Box from "../box";
@@ -2,9 +2,8 @@ export const StyledSidebarHeader: import("styled-components").StyledComponent<"d
2
2
  export const StyledDrawerWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
3
  export const StyledDrawerContent: import("styled-components").StyledComponent<"div", any, {}, never>;
4
4
  export const StyledDrawerChildren: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export const StyledDrawerSidebar: import("styled-components").StyledComponent<typeof Box, any, {}, never>;
5
+ export const StyledDrawerSidebar: import("styled-components").StyledComponent<"div", any, import("../box").BoxProps, never>;
6
6
  export const StyledSidebarTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
7
7
  export const StyledButton: import("styled-components").StyledComponent<"button", any, {
8
8
  type: "button";
9
9
  }, "type">;
10
- import Box from "../box";
@@ -1,5 +1,4 @@
1
- export const StyledPicklist: import("styled-components").StyledComponent<typeof Box, any, {
2
- as: "ul";
1
+ export const StyledPicklist: import("styled-components").StyledComponent<"div", any, import("../../box").BoxProps & {
2
+ as: string;
3
3
  }, "as">;
4
4
  export const StyledEmptyContainer: import("styled-components").StyledComponent<"li", any, {}, never>;
5
- import Box from "../../box";
@@ -1,5 +1,4 @@
1
- export const StyledFlatTableWrapper: import("styled-components").StyledComponent<typeof Box, any, {}, never>;
1
+ export const StyledFlatTableWrapper: import("styled-components").StyledComponent<"div", any, import("../box").BoxProps, never>;
2
2
  export const StyledFlatTable: import("styled-components").StyledComponent<"table", any, {}, never>;
3
3
  export const StyledFlatTableFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
4
4
  export const StyledTableContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- import Box from "../box";
@@ -27,6 +27,7 @@ const Form = ({
27
27
  } = useContext(SidebarContext);
28
28
  const formRef = useRef();
29
29
  const formFooterRef = useRef();
30
+ const renderFooter = !!(saveButton || leftSideButtons || rightSideButtons || errorCount || warningCount);
30
31
  return /*#__PURE__*/React.createElement(StyledForm, _extends({
31
32
  ref: formRef,
32
33
  stickyFooter: stickyFooter,
@@ -40,7 +41,7 @@ const Form = ({
40
41
  "data-element": "form-content",
41
42
  stickyFooter: stickyFooter,
42
43
  className: stickyFooter ? "sticky" : ""
43
- }, children), /*#__PURE__*/React.createElement(StyledFormFooter, {
44
+ }, children), renderFooter && /*#__PURE__*/React.createElement(StyledFormFooter, {
44
45
  "data-element": "form-footer",
45
46
  className: stickyFooter ? "sticky" : "",
46
47
  ref: formFooterRef,
@@ -6,7 +6,7 @@ import { TransitionGroup, CSSTransition } from "react-transition-group";
6
6
  import useScrollBlock from "../../hooks/__internal__/useScrollBlock";
7
7
  import Portal from "../portal";
8
8
  import Events from "../../__internal__/utils/helpers/events";
9
- import ModalManager from "./__internal__/modal-manager";
9
+ import useModalManager from "../../hooks/__internal__/useModalManager";
10
10
  import { StyledModal, StyledModalBackground } from "./modal.style";
11
11
  export const ModalContext = /*#__PURE__*/React.createContext({});
12
12
 
@@ -23,8 +23,6 @@ const Modal = ({
23
23
  const ref = useRef();
24
24
  const backgroundNodeRef = useRef();
25
25
  const contentNodeRef = useRef();
26
- const listenerAdded = useRef(false);
27
- const modalRegistered = useRef(false);
28
26
  const [isAnimationComplete, setAnimationComplete] = useState(false);
29
27
  const [triggerRefocusFlag, setTriggerRefocusFlag] = useState(false);
30
28
  const {
@@ -50,67 +48,12 @@ const Modal = ({
50
48
  };
51
49
  }, [allowScroll, enableBackgroundUI]);
52
50
  const closeModal = useCallback(ev => {
53
- const isTopmost = ModalManager.isTopmost(ref.current);
54
-
55
- if (onCancel && !disableClose && !disableEscKey && Events.isEscKey(ev) && isTopmost) {
51
+ if (onCancel && !disableClose && !disableEscKey && Events.isEscKey(ev)) {
56
52
  ev.stopImmediatePropagation();
57
53
  onCancel(ev);
58
54
  }
59
55
  }, [disableClose, disableEscKey, onCancel]);
60
- const addListener = useCallback(() => {
61
- /* istanbul ignore else */
62
- if (!listenerAdded.current) {
63
- document.addEventListener("keyup", closeModal);
64
- listenerAdded.current = true;
65
- }
66
- }, [closeModal]);
67
- const removeListener = useCallback(() => {
68
- if (listenerAdded.current) {
69
- document.removeEventListener("keyup", closeModal);
70
- listenerAdded.current = false;
71
- }
72
- }, [closeModal]);
73
- useEffect(() => {
74
- if (open) {
75
- addListener();
76
- }
77
-
78
- if (!open) {
79
- removeListener();
80
- }
81
- }, [addListener, open, removeListener]);
82
- useEffect(() => {
83
- return () => {
84
- removeListener();
85
- };
86
- }, [removeListener]);
87
- const registerModal = useCallback(() => {
88
- /* istanbul ignore else */
89
- if (!modalRegistered.current) {
90
- ModalManager.addModal(ref.current, setTriggerRefocusFlag);
91
- modalRegistered.current = true;
92
- }
93
- }, []);
94
- const unregisterModal = useCallback(() => {
95
- if (modalRegistered.current) {
96
- ModalManager.removeModal(ref.current);
97
- modalRegistered.current = false;
98
- }
99
- }, []);
100
- useEffect(() => {
101
- if (open) {
102
- registerModal();
103
- }
104
-
105
- if (!open) {
106
- unregisterModal();
107
- }
108
- }, [open, registerModal, unregisterModal]);
109
- useEffect(() => {
110
- return () => {
111
- unregisterModal();
112
- };
113
- }, [unregisterModal]);
56
+ useModalManager(open, closeModal, ref, setTriggerRefocusFlag);
114
57
  let background;
115
58
  let content;
116
59
 
@@ -18,7 +18,7 @@ const StyledSelect = styled.div`
18
18
  position: relative;
19
19
 
20
20
  ${StyledInput} {
21
- cursor: "text";
21
+ cursor: text;
22
22
 
23
23
  ${disabled && css`
24
24
  cursor: not-allowed;
@@ -8,9 +8,9 @@ import Icon from "../icon";
8
8
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
9
9
  import { ToastStyle, TypeIcon, ToastContentStyle, ToastWrapper, StyledPortal } from "./toast.style";
10
10
  import IconButton from "../icon-button";
11
- import ModalManager from "../modal/__internal__/modal-manager";
12
11
  import Events from "../../__internal__/utils/helpers/events";
13
12
  import useLocale from "../../hooks/__internal__/useLocale";
13
+ import useModalManager from "../../hooks/__internal__/useModalManager";
14
14
  import Logger from "../../__internal__/utils/logger";
15
15
  let deprecatedWarnTriggered = false;
16
16
 
@@ -42,22 +42,12 @@ const Toast = ({
42
42
  return classNames(className);
43
43
  }, [className]);
44
44
  const dismissToast = useCallback(ev => {
45
- const isTopmost = ModalManager.isTopmost(toastRef.current);
46
-
47
- if (onDismiss && Events.isEscKey(ev) && isTopmost) {
45
+ if (onDismiss && Events.isEscKey(ev)) {
48
46
  ev.stopImmediatePropagation();
49
47
  onDismiss(ev);
50
48
  }
51
49
  }, [onDismiss]);
52
- useEffect(() => {
53
- const currentElement = toastRef.current;
54
- ModalManager.addModal(currentElement);
55
- document.addEventListener("keyup", dismissToast);
56
- return () => {
57
- ModalManager.removeModal(currentElement);
58
- document.removeEventListener("keyup", dismissToast);
59
- };
60
- }, [dismissToast]);
50
+ useModalManager(open, dismissToast, toastRef);
61
51
  useEffect(() => {
62
52
  clearTimeout(timer.current);
63
53
 
@@ -0,0 +1 @@
1
+ export { default } from "./useModalManager";
@@ -0,0 +1 @@
1
+ export { default } from "./useModalManager";
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const useModalManager: (open: boolean, closeModal: (e: KeyboardEvent) => void, modalRef: React.RefObject<HTMLElement>, setTriggerRefocusFlag?: ((flag: boolean) => void) | undefined) => void;
3
+ export default useModalManager;
@@ -0,0 +1,66 @@
1
+ import { useEffect, useRef, useCallback } from "react";
2
+ import ModalManager from "../../../components/modal/__internal__/modal-manager";
3
+
4
+ const useModalManager = (open, closeModal, modalRef, setTriggerRefocusFlag) => {
5
+ const listenerAdded = useRef(false);
6
+ const modalRegistered = useRef(false);
7
+ const handleClose = useCallback(ev => {
8
+ const isTopmost = ModalManager.isTopmost(modalRef.current);
9
+
10
+ if (isTopmost) {
11
+ closeModal(ev);
12
+ }
13
+ }, [modalRef, closeModal]);
14
+ const addListener = useCallback(() => {
15
+ /* istanbul ignore else */
16
+ if (!listenerAdded.current) {
17
+ document.addEventListener("keyup", handleClose);
18
+ listenerAdded.current = true;
19
+ }
20
+ }, [handleClose]);
21
+ const removeListener = useCallback(() => {
22
+ if (listenerAdded.current) {
23
+ document.removeEventListener("keyup", handleClose);
24
+ listenerAdded.current = false;
25
+ }
26
+ }, [handleClose]);
27
+ useEffect(() => {
28
+ if (open) {
29
+ addListener();
30
+ } else {
31
+ removeListener();
32
+ }
33
+ }, [addListener, open, removeListener]);
34
+ useEffect(() => {
35
+ return () => {
36
+ removeListener();
37
+ };
38
+ }, [removeListener]);
39
+ const registerModal = useCallback(() => {
40
+ /* istanbul ignore else */
41
+ if (!modalRegistered.current) {
42
+ ModalManager.addModal(modalRef.current, setTriggerRefocusFlag);
43
+ modalRegistered.current = true;
44
+ }
45
+ }, [modalRef, setTriggerRefocusFlag]);
46
+ const unregisterModal = useCallback(() => {
47
+ if (modalRegistered.current) {
48
+ ModalManager.removeModal(modalRef.current);
49
+ modalRegistered.current = false;
50
+ }
51
+ }, [modalRef]);
52
+ useEffect(() => {
53
+ if (open) {
54
+ registerModal();
55
+ } else {
56
+ unregisterModal();
57
+ }
58
+ }, [open, registerModal, unregisterModal]);
59
+ useEffect(() => {
60
+ return () => {
61
+ unregisterModal();
62
+ };
63
+ }, [unregisterModal]);
64
+ };
65
+
66
+ export default useModalManager;
@@ -36,15 +36,14 @@ const Popover = ({
36
36
  modifiers,
37
37
  disableBackgroundUI
38
38
  }) => {
39
+ var _reference$current;
40
+
39
41
  const elementDOM = (0, _react.useRef)();
40
42
  const {
41
43
  isInModal
42
44
  } = (0, _react.useContext)(_modal.ModalContext);
43
- let mountNode = document.body;
44
-
45
- if (isInModal && reference.current) {
46
- mountNode = reference.current.closest("[role='dialog']");
47
- }
45
+ const candidateNode = (_reference$current = reference.current) === null || _reference$current === void 0 ? void 0 : _reference$current.closest("[role='dialog']");
46
+ const mountNode = isInModal && candidateNode ? candidateNode : document.body;
48
47
 
49
48
  if (!elementDOM.current && !disablePortal) {
50
49
  elementDOM.current = document.createElement("div");
@@ -1 +1,8 @@
1
- export {};
1
+ import "jest-styled-components";
2
+ declare global {
3
+ namespace jest {
4
+ interface Matchers<R> {
5
+ toBeFocused(): R;
6
+ }
7
+ }
8
+ }
@@ -4,9 +4,7 @@ require("jest-styled-components");
4
4
 
5
5
  var _enzyme = require("enzyme");
6
6
 
7
- const {
8
- diff
9
- } = require("jest-matcher-utils");
7
+ var _jestMatcherUtils = require("jest-matcher-utils");
10
8
 
11
9
  expect.extend({
12
10
  toBeFocused(received) {
@@ -19,7 +17,7 @@ expect.extend({
19
17
  const hint = this.utils.matcherHint("toBeFocused", "DOMNode", "", options);
20
18
 
21
19
  const positive = () => {
22
- const diffString = diff(expected, DOMNode, {
20
+ const diffString = (0, _jestMatcherUtils.diff)(expected, DOMNode, {
23
21
  expand: this.expand
24
22
  });
25
23
  return `${hint}\n\n${// eslint-disable-next-line multiline-ternary
@@ -1,34 +1,72 @@
1
- export function getDefaultValue(value: any): any;
2
- export function assertStyleMatch(styleSpec: any, component: any, opts: any): void;
3
- export function toCSSCase(str: any): any;
4
- export function hoverList(wrapper: any): (item: any) => void;
5
- export function selectedItemOf(wrapper: any): any;
6
- export function childrenFrom(node: any): any;
7
- export function makeArrayKeys(n: any): number[];
8
- export const keyboard: {};
9
- export function assertKeyboardTraversal({ num, nonSelectables, }: {
10
- num: any;
11
- nonSelectables?: any[] | undefined;
12
- }): (wrapper: any) => void;
13
- export function assertHoverTraversal({ num, nonSelectables, }: {
14
- num: any;
15
- nonSelectables?: any[] | undefined;
16
- }): (wrapper: any) => void;
17
- export function listFrom(wrapper: any): any;
18
- export function click(wrapper: any): any;
19
- export namespace simulate {
20
- export { keydown };
21
- }
22
- export const carbonThemesJestTable: (string | Partial<import("style/themes/base/base-theme.config").ThemeObject> | undefined)[][];
1
+ /// <reference types="react" />
2
+ import { ReactWrapper, ShallowWrapper } from "enzyme";
3
+ import { LayoutProps, FlexboxProps, BackgroundProps } from "styled-system";
4
+ import { ReactTestRendererJSON } from "react-test-renderer";
23
5
  import { mockMatchMedia } from "./mock-match-media";
24
- export function testStyledSystemSpacing(component: any, defaults: any, styleContainer: any, assertOpts: any): void;
25
- export function testStyledSystemMargin(component: any, defaults: any, styleContainer: any, assertOpts: any): void;
26
- export function testStyledSystemPadding(component: any, defaults: any, styleContainer: any, assertOpts: any): void;
27
- export function testStyledSystemColor(component: any, styleContainer: any): void;
28
- export function testStyledSystemWidth(component: any, styleContainer: any): void;
29
- export function testStyledSystemLayout(component: any, styleContainer: any): void;
30
- export function testStyledSystemFlexBox(component: any, styleContainer: any): void;
31
- export function testStyledSystemBackground(component: any, styleContainer: any): void;
32
- export function expectConsoleOutput(message: any, type?: string): () => void;
33
- declare const keydown: {};
34
- export { mockMatchMedia };
6
+ declare const toCSSCase: (str: string) => string;
7
+ declare const assertStyleMatch: <Props>(styleSpec: {
8
+ [key: string]: string | number | undefined;
9
+ }, component: ReactWrapper<Props, {}, import("react").Component<{}, {}, any>> | ShallowWrapper<Props, {}, import("react").Component<{}, {}, any>> | ReactTestRendererJSON | ReactTestRendererJSON[] | null, opts?: jest.Options | undefined) => void;
10
+ declare const makeArrayKeys: (n: number) => number[];
11
+ declare const keyMap: {
12
+ readonly UpArrow: 38;
13
+ readonly DownArrow: 40;
14
+ readonly RightArrow: 39;
15
+ readonly LeftArrow: 37;
16
+ readonly Enter: 13;
17
+ readonly Tab: 9;
18
+ readonly Space: 32;
19
+ readonly Escape: 27;
20
+ readonly End: 35;
21
+ readonly Home: 36;
22
+ readonly D: 68;
23
+ readonly E: 69;
24
+ readonly P: 80;
25
+ readonly Z: 90;
26
+ readonly 1: 49;
27
+ };
28
+ declare type Keys = keyof typeof keyMap;
29
+ declare type MappedKeys = `press${Keys}`;
30
+ declare type KeyboardAccumulatorType = Record<MappedKeys, () => void>;
31
+ declare const keyboard: KeyboardAccumulatorType;
32
+ declare type KeydownAccumulatorType = Record<MappedKeys, (wrapper: ReactWrapper<any>, options?: {
33
+ shiftKey: boolean;
34
+ }) => void>;
35
+ declare const simulate: {
36
+ keydown: KeydownAccumulatorType;
37
+ };
38
+ declare const listFrom: (wrapper: ReactWrapper) => ReactWrapper<import("enzyme").HTMLAttributes, any, import("react").Component<{}, {}, any>>;
39
+ declare const childrenFrom: (node: ReactWrapper) => ReactWrapper<any, any, import("react").Component<{}, {}, any>>;
40
+ declare const hoverList: (wrapper: ReactWrapper) => (item: number) => void;
41
+ declare const click: (wrapper: ReactWrapper) => ReactWrapper<{}, {}, import("react").Component<{}, {}, any>>;
42
+ declare const selectedItemOf: (wrapper: ReactWrapper) => number;
43
+ declare const assertKeyboardTraversal: ({ num, nonSelectables, }: {
44
+ num: number;
45
+ nonSelectables?: number[] | undefined;
46
+ }) => (wrapper: ReactWrapper) => void;
47
+ declare const assertHoverTraversal: ({ num, nonSelectables, }: {
48
+ num: number;
49
+ nonSelectables?: number[] | undefined;
50
+ }) => (wrapper: ReactWrapper) => void;
51
+ declare const carbonThemesJestTable: (string | Partial<import("style/themes/base/base-theme.config").ThemeObject> | undefined)[][];
52
+ declare const marginProps: readonly [readonly ["m", "margin"], readonly ["ml", "marginLeft"], readonly ["mr", "marginRight"], readonly ["mt", "marginTop"], readonly ["mb", "marginBottom"], readonly ["mx", "marginLeft"], readonly ["mx", "marginRight"], readonly ["my", "marginTop"], readonly ["my", "marginBottom"]];
53
+ declare type MarginProps = {
54
+ [K in typeof marginProps[number][0]]?: string | number;
55
+ };
56
+ declare const paddingProps: readonly [readonly ["p", "padding"], readonly ["pl", "paddingLeft"], readonly ["pr", "paddingRight"], readonly ["pt", "paddingTop"], readonly ["pb", "paddingBottom"], readonly ["px", "paddingLeft"], readonly ["px", "paddingRight"], readonly ["py", "paddingTop"], readonly ["py", "paddingBottom"]];
57
+ declare type PaddingProps = {
58
+ [K in typeof paddingProps[number][0]]?: string | number;
59
+ };
60
+ export declare const getDefaultValue: (value?: string | number | undefined) => string | number | undefined;
61
+ declare const testStyledSystemMargin: (component: (spacingProps?: MarginProps | undefined) => JSX.Element, defaults?: MarginProps | undefined, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined, assertOpts?: jest.Options | undefined) => void;
62
+ declare const testStyledSystemPadding: (component: (spacingProps?: PaddingProps | undefined) => JSX.Element, defaults?: PaddingProps | undefined, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined, assertOpts?: jest.Options | undefined) => void;
63
+ declare const testStyledSystemSpacing: (component: (spacingProps?: MarginProps | PaddingProps | undefined) => JSX.Element, defaults?: MarginProps | PaddingProps | undefined, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined, assertOpts?: jest.Options | undefined) => void;
64
+ declare const testStyledSystemColor: (component: (colorProperties?: any) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => void) | undefined) => void;
65
+ declare const testStyledSystemWidth: (component: (widthProperties?: {
66
+ width: string;
67
+ } | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
68
+ declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
69
+ declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
70
+ declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
71
+ declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
72
+ export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground, expectConsoleOutput, };