carbon-react 107.1.4 → 107.1.7

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 (83) hide show
  1. package/esm/__internal__/input/input.component.js +3 -0
  2. package/esm/__internal__/label/icon-wrapper.style.d.ts +2 -0
  3. package/esm/__internal__/label/icon-wrapper.style.js +4 -4
  4. package/esm/__internal__/label/index.d.ts +2 -1
  5. package/esm/__internal__/label/label.component.d.ts +27 -0
  6. package/esm/__internal__/label/label.component.js +42 -80
  7. package/esm/__internal__/label/label.style.d.ts +23 -3
  8. package/esm/__internal__/label/label.style.js +4 -19
  9. package/esm/__internal__/utils/helpers/events/events.d.ts +0 -58
  10. package/esm/__internal__/utils/helpers/events/events.js +12 -128
  11. package/esm/__spec_helper__/test-utils.d.ts +4 -25
  12. package/esm/__spec_helper__/test-utils.js +12 -25
  13. package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +2 -2
  14. package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.d.ts +19 -0
  15. package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.js +14 -21
  16. package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.d.ts +5 -0
  17. package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.js +0 -4
  18. package/esm/components/anchor-navigation/anchor-navigation.component.d.ts +14 -0
  19. package/esm/components/anchor-navigation/anchor-navigation.component.js +55 -72
  20. package/esm/components/anchor-navigation/anchor-navigation.style.d.ts +4 -0
  21. package/esm/components/anchor-navigation/anchor-section-divider.component.d.ts +4 -0
  22. package/esm/components/anchor-navigation/{anchor-section-divider/anchor-section-divider.style.js → anchor-section-divider.component.js} +3 -2
  23. package/esm/components/anchor-navigation/index.d.ts +5 -3
  24. package/esm/components/anchor-navigation/index.js +1 -1
  25. package/esm/components/date/__internal__/date-picker/date-picker.component.js +10 -1
  26. package/esm/components/date/__internal__/weekday/weekday.style.js +1 -1
  27. package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +1 -0
  28. package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -0
  29. package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +1 -0
  30. package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +3 -3
  31. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +1 -0
  32. package/esm/components/help/help.style.d.ts +2 -0
  33. package/esm/components/menu/__internal__/spec-helper/index.js +1 -2
  34. package/esm/components/menu/__internal__/submenu/submenu.component.js +1 -1
  35. package/esm/components/multi-action-button/multi-action-button.component.js +3 -0
  36. package/esm/components/numeral-date/numeral-date.component.js +1 -1
  37. package/esm/components/search/search.component.js +1 -2
  38. package/lib/__internal__/input/input.component.js +3 -0
  39. package/lib/__internal__/label/icon-wrapper.style.d.ts +2 -0
  40. package/lib/__internal__/label/icon-wrapper.style.js +2 -2
  41. package/lib/__internal__/label/index.d.ts +2 -1
  42. package/lib/__internal__/label/label.component.d.ts +27 -0
  43. package/lib/__internal__/label/label.component.js +40 -78
  44. package/lib/__internal__/label/label.style.d.ts +23 -3
  45. package/lib/__internal__/label/label.style.js +4 -22
  46. package/lib/__internal__/utils/helpers/events/events.d.ts +0 -58
  47. package/lib/__internal__/utils/helpers/events/events.js +12 -128
  48. package/lib/__spec_helper__/test-utils.d.ts +4 -25
  49. package/lib/__spec_helper__/test-utils.js +12 -25
  50. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +2 -2
  51. package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.d.ts +19 -0
  52. package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.js +14 -21
  53. package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.d.ts +5 -0
  54. package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.js +0 -7
  55. package/lib/components/anchor-navigation/anchor-navigation.component.d.ts +14 -0
  56. package/lib/components/anchor-navigation/anchor-navigation.component.js +57 -73
  57. package/lib/components/anchor-navigation/anchor-navigation.style.d.ts +4 -0
  58. package/lib/components/anchor-navigation/anchor-section-divider.component.d.ts +4 -0
  59. package/lib/components/anchor-navigation/{anchor-section-divider/anchor-section-divider.style.js → anchor-section-divider.component.js} +3 -2
  60. package/lib/components/anchor-navigation/index.d.ts +5 -3
  61. package/lib/components/anchor-navigation/index.js +1 -1
  62. package/lib/components/date/__internal__/date-picker/date-picker.component.js +10 -1
  63. package/lib/components/date/__internal__/weekday/weekday.style.js +1 -1
  64. package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +1 -0
  65. package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -0
  66. package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +1 -0
  67. package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +2 -4
  68. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +1 -0
  69. package/lib/components/help/help.style.d.ts +2 -0
  70. package/lib/components/menu/__internal__/spec-helper/index.js +1 -2
  71. package/lib/components/menu/__internal__/submenu/submenu.component.js +1 -1
  72. package/lib/components/multi-action-button/multi-action-button.component.js +3 -0
  73. package/lib/components/numeral-date/numeral-date.component.js +1 -1
  74. package/lib/components/search/search.component.js +1 -3
  75. package/package.json +1 -1
  76. package/esm/__internal__/label/label.d.ts +0 -43
  77. package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.d.ts +0 -23
  78. package/esm/components/anchor-navigation/anchor-navigation.d.ts +0 -11
  79. package/esm/components/anchor-navigation/anchor-section-divider/anchor-section-divider.d.ts +0 -12
  80. package/lib/__internal__/label/label.d.ts +0 -43
  81. package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.d.ts +0 -23
  82. package/lib/components/anchor-navigation/anchor-navigation.d.ts +0 -11
  83. package/lib/components/anchor-navigation/anchor-section-divider/anchor-section-divider.d.ts +0 -12
@@ -27,46 +27,33 @@ const makeArrayKeys = n => [...Array(n).keys()];
27
27
 
28
28
  const dispatchKeyPress = code => {
29
29
  const ev = new KeyboardEvent("keydown", {
30
- which: code
30
+ key: code
31
31
  });
32
32
  document.dispatchEvent(ev);
33
33
  };
34
34
 
35
- const keyMap = {
36
- UpArrow: 38,
37
- DownArrow: 40,
38
- RightArrow: 39,
39
- LeftArrow: 37,
40
- Enter: 13,
41
- Tab: 9,
42
- Space: 32,
43
- Escape: 27,
44
- End: 35,
45
- Home: 36,
46
- D: 68,
47
- E: 69,
48
- P: 80,
49
- Z: 90,
50
- 1: 49
51
- };
52
- const keyboard = Object.keys(keyMap).reduce((acc, key) => {
53
- acc[`press${key}`] = () => dispatchKeyPress(keyMap[key]);
35
+ const keys = ["ArrowUp", "ArrowDown", "ArrowRight", "ArrowLeft", "Enter", "Tab", " ", "Escape", "End", "Home", "D", "E", "P", "Z", "1"];
36
+ const keyboard = keys.reduce((acc, key) => {
37
+ const methodName = `press${key === " " ? "Space" : key}`;
38
+
39
+ acc[methodName] = () => dispatchKeyPress(key);
54
40
 
55
41
  return acc;
56
42
  }, {}); // Build an object of Enzyme simulate helpers
57
43
  // e.g. simulate.keydown.pressTab(target, { shiftKey: true })
58
44
  // e.g. simulate.keydown.pressEscape(target)
59
45
 
60
- const keydown = Object.keys(keyMap).reduce((acc, key) => {
61
- acc[`press${key}`] = (target, {
46
+ const keydown = keys.reduce((acc, key) => {
47
+ const methodName = `press${key === " " ? "Space" : key}`;
48
+
49
+ acc[methodName] = (target, {
62
50
  shiftKey
63
51
  } = {
64
52
  shiftKey: false
65
53
  }) => {
66
54
  target.simulate("keydown", {
67
55
  shiftKey,
68
- key,
69
- which: keyMap[key]
56
+ key
70
57
  });
71
58
  };
72
59
 
@@ -112,7 +99,7 @@ const assertCorrectTraversal = method => expect => ({
112
99
  expect(arraysEqual(validIndexes, indexesThatWereSelected)).toBeTruthy();
113
100
  };
114
101
 
115
- const assertKeyboardTraversal = assertCorrectTraversal(() => keyboard.pressDownArrow)(expect);
102
+ const assertKeyboardTraversal = assertCorrectTraversal(() => keyboard.pressArrowDown)(expect);
116
103
  const assertHoverTraversal = assertCorrectTraversal(wrapper => hoverList(wrapper))(expect);
117
104
  const carbonThemesJestTable = carbonThemeList.map(theme => [theme.name, theme]);
118
105
  const marginProps = [["m", "margin"], ["ml", "marginLeft"], ["mr", "marginRight"], ["mt", "marginTop"], ["mb", "marginBottom"], ["mx", "marginLeft"], ["mx", "marginRight"], ["my", "marginTop"], ["my", "marginBottom"]];
@@ -70,8 +70,8 @@ const ActionPopoverMenu = /*#__PURE__*/React.forwardRef(({
70
70
  e.preventDefault();
71
71
  e.stopPropagation();
72
72
  setFocusIndex(items.length - 1);
73
- } else if (Events.isAlphabetKey(e)) {
74
- // A-Za-z: focus the next item on the list that starts with the pressed key
73
+ } else if (e.key.length === 1) {
74
+ // any printable character: focus the next item on the list that starts with that character
75
75
  // selection should wrap to the start of the list
76
76
  e.stopPropagation();
77
77
  let firstMatch;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ export interface AnchorNavigationItemProps {
3
+ /** Reference to the section html element meant to be shown */
4
+ target?: React.RefObject<HTMLElement>;
5
+ /** href to be passed to the anchor element, can be linked with id passed to the scrollable section */
6
+ href?: string;
7
+ /** Indicates if component is selected */
8
+ isSelected?: boolean;
9
+ /** onClick handler */
10
+ onClick?: (ev: React.MouseEvent<HTMLAnchorElement>) => void;
11
+ /** OnKeyDown handler */
12
+ onKeyDown?: (ev: React.KeyboardEvent<HTMLAnchorElement>) => void;
13
+ /** tabIndex passed to the anchor element */
14
+ tabIndex?: number;
15
+ /** Children elements */
16
+ children?: React.ReactNode;
17
+ }
18
+ declare const AnchorNavigationItem: React.ForwardRefExoticComponent<AnchorNavigationItemProps & React.RefAttributes<HTMLAnchorElement>>;
19
+ export default AnchorNavigationItem;
@@ -1,4 +1,3 @@
1
- /* eslint-disable react/no-unused-prop-types */
2
1
  import React from "react";
3
2
  import PropTypes from "prop-types";
4
3
  import StyledNavigationItem from "./anchor-navigation-item.style";
@@ -20,26 +19,20 @@ const AnchorNavigationItem = /*#__PURE__*/React.forwardRef(({
20
19
  "data-element": "anchor-navigation-item"
21
20
  }, children)));
22
21
  AnchorNavigationItem.propTypes = {
23
- children: PropTypes.node,
24
-
25
- /** OnKeyDown handler */
26
- onKeyDown: PropTypes.func,
27
-
28
- /** onClick handler */
29
- onClick: PropTypes.func,
30
-
31
- /** href to be passed to the anchor element, can be linked with id passed to the scrollable section */
32
- href: PropTypes.string,
33
-
34
- /** tabIndex passed to the anchor element */
35
- tabIndex: PropTypes.number,
36
-
37
- /** Indicates if component is selected */
38
- isSelected: PropTypes.bool,
39
-
40
- /** Reference to the section html element meant to be shown */
41
- target: PropTypes.shape({
42
- current: PropTypes.instanceOf(Element)
22
+ "children": PropTypes.node,
23
+ "href": PropTypes.string,
24
+ "isSelected": PropTypes.bool,
25
+ "onClick": PropTypes.func,
26
+ "onKeyDown": PropTypes.func,
27
+ "tabIndex": PropTypes.number,
28
+ "target": PropTypes.shape({
29
+ "current": PropTypes.oneOfType([PropTypes.oneOf([null]), function (props, propName) {
30
+ if (props[propName] == null) {
31
+ return new Error("Prop '" + propName + "' is required but wasn't specified");
32
+ } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
33
+ return new Error("Expected prop '" + propName + "' to be of type Element");
34
+ }
35
+ }]).isRequired
43
36
  })
44
37
  };
45
38
  AnchorNavigationItem.displayName = "AnchorNavigationItem";
@@ -0,0 +1,5 @@
1
+ export interface StyledNavigationItemProps {
2
+ isSelected?: boolean;
3
+ }
4
+ declare const StyledNavigationItem: import("styled-components").StyledComponent<"li", any, StyledNavigationItemProps, never>;
5
+ export default StyledNavigationItem;
@@ -1,4 +1,3 @@
1
- import PropTypes from "prop-types";
2
1
  import styled, { css } from "styled-components";
3
2
  const StyledNavigationItem = styled.li`
4
3
  width: 100%;
@@ -31,7 +30,4 @@ const StyledNavigationItem = styled.li`
31
30
  `}
32
31
  }
33
32
  `;
34
- StyledNavigationItem.propTypes = {
35
- isSelected: PropTypes.bool
36
- };
37
33
  export default StyledNavigationItem;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ export interface AnchorNavigationProps {
3
+ /** Child elements */
4
+ children?: React.ReactNode;
5
+ /** The AnchorNavigationItems components to be rendered in the sticky navigation.
6
+ It is important to maintain proper structure.
7
+ List of AnchorNavigationItems has to be wrapped in React.Fragment */
8
+ stickyNavigation?: React.ReactNode;
9
+ }
10
+ declare const AnchorNavigation: {
11
+ ({ children, stickyNavigation, }: AnchorNavigationProps): JSX.Element;
12
+ displayName: string;
13
+ };
14
+ export default AnchorNavigation;
@@ -1,7 +1,8 @@
1
- import React, { useState, useRef, useEffect, useCallback } from "react";
1
+ import React, { useState, useRef, useEffect, useMemo, useCallback, createRef } from "react";
2
2
  import PropTypes from "prop-types";
3
- import throttle from "lodash/throttle";
4
3
  import { isFragment } from "react-is";
4
+ import invariant from "invariant";
5
+ import throttle from "lodash/throttle";
5
6
  import Event from "../../__internal__/utils/helpers/events";
6
7
  import { StyledAnchorNavigation, StyledNavigation, StyledContent } from "./anchor-navigation.style";
7
8
  import AnchorNavigationItem from "./anchor-navigation-item/anchor-navigation-item.component";
@@ -12,45 +13,56 @@ const AnchorNavigation = ({
12
13
  children,
13
14
  stickyNavigation
14
15
  }) => {
16
+ invariant(isFragment(stickyNavigation), "`stickyNavigation` prop in `AnchorNavigation` should be a React Fragment.");
17
+ const hasCorrectItemStructure = useMemo(() => {
18
+ const incorrectChild = React.Children.toArray(stickyNavigation.props.children).find(child => {
19
+ return ! /*#__PURE__*/React.isValidElement(child) || child.type.displayName !== AnchorNavigationItem.displayName;
20
+ });
21
+ return !incorrectChild;
22
+ }, [stickyNavigation]);
23
+ invariant(hasCorrectItemStructure, `\`stickyNavigation\` prop in \`AnchorNavigation\` should be a React Fragment that only contains children of type \`${AnchorNavigationItem.displayName}\``);
15
24
  const [selectedIndex, setSelectedIndex] = useState(0);
16
25
  const sectionRefs = useRef(React.Children.map(stickyNavigation.props.children, child => child.props.target));
17
26
  const anchorRefs = useRef(Array.from({
18
27
  length: React.Children.count(stickyNavigation.props.children)
19
- }, () => /*#__PURE__*/React.createRef()));
20
- const contentRef = useRef();
21
- const navigationRef = useRef();
28
+ }, () => /*#__PURE__*/createRef()));
29
+ const contentRef = useRef(null);
30
+ const navigationRef = useRef(null);
22
31
  const isUserScroll = useRef(true);
23
32
  const isUserScrollTimer = useRef();
24
33
  const setSelectedAnchorBasedOnScroll = useCallback(() => {
25
- const sectionsTopOffsets = sectionRefs.current.map(({
34
+ // istanbul ignore if
35
+ // function is called only after component is rendered, so ref cannot hold a null value
36
+ if (navigationRef.current === null) return;
37
+ const offsetsWithIndexes = sectionRefs.current.map(({
26
38
  current
27
- }) => current.getBoundingClientRect().top);
39
+ }, index) => [index, current === null || current === void 0 ? void 0 : current.getBoundingClientRect().top]).filter(offsetWithIndex => offsetWithIndex[1] !== undefined);
28
40
  const {
29
41
  top: navTopOffset
30
42
  } = navigationRef.current.getBoundingClientRect();
31
- const indexOfSmallestNegativeTopOffset = sectionsTopOffsets.reduce((currentTopIndex, sectionTopOffset, index) => {
32
- if (sectionTopOffset - SECTION_VISIBILITY_OFFSET > navTopOffset) return currentTopIndex;
33
- return sectionTopOffset > sectionsTopOffsets[currentTopIndex] ? index : currentTopIndex;
34
- }, 0);
43
+ const indexOfSmallestNegativeTopOffset = offsetsWithIndexes.reduce((currentTopIndex, offsetWithIndex) => {
44
+ const [index, offset] = offsetWithIndex;
45
+ if (offset - SECTION_VISIBILITY_OFFSET > navTopOffset) return currentTopIndex;
46
+ return offset > offsetsWithIndexes[currentTopIndex][1] ? index : currentTopIndex;
47
+ }, offsetsWithIndexes[0][0]);
35
48
  setSelectedIndex(indexOfSmallestNegativeTopOffset);
36
49
  }, []);
37
- const scrollHandler = useCallback(throttle(() => {
50
+ const scrollHandler = useMemo(() => throttle(() => {
38
51
  if (isUserScroll.current) {
39
52
  setSelectedAnchorBasedOnScroll();
40
53
  } else {
41
- window.clearTimeout(isUserScrollTimer.current);
54
+ if (isUserScrollTimer.current !== undefined) window.clearTimeout(isUserScrollTimer.current);
42
55
  isUserScrollTimer.current = setTimeout(() => {
43
56
  isUserScroll.current = true;
44
57
  }, SCROLL_THROTTLE + 50);
45
58
  }
46
- }, SCROLL_THROTTLE), []);
59
+ }, SCROLL_THROTTLE), [setSelectedAnchorBasedOnScroll]);
47
60
  useEffect(() => {
48
61
  window.addEventListener("scroll", scrollHandler, true);
49
62
  return () => window.removeEventListener("scroll", scrollHandler, true);
50
63
  }, [scrollHandler]);
51
64
 
52
65
  const focusFirstFocusableChild = section => {
53
- // eslint-disable-next-line max-len
54
66
  const defaultFocusableSelectors = 'button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])';
55
67
  const firstFocusableElement = section.querySelector(defaultFocusableSelectors);
56
68
 
@@ -61,46 +73,45 @@ const AnchorNavigation = ({
61
73
  }
62
74
  };
63
75
 
64
- const scrollToSection = section => {
65
- isUserScroll.current = false;
66
- section.scrollIntoView({
67
- block: "start",
68
- inline: "nearest",
69
- behavior: "smooth"
70
- });
71
- };
76
+ const scrollToSection = index => {
77
+ const sectionToScroll = sectionRefs.current[index].current; // istanbul ignore if
78
+ // function is called only after component is rendered, so ref cannot hold a null value
72
79
 
73
- const handleClick = (event, index) => {
74
- event.preventDefault();
75
- const sectionToScroll = sectionRefs.current[index].current;
80
+ if (sectionToScroll === null) return;
76
81
  focusFirstFocusableChild(sectionToScroll); // workaround due to preventScroll focus method option on firefox not working consistently
77
82
 
78
83
  window.setTimeout(() => {
79
- scrollToSection(sectionToScroll);
84
+ isUserScroll.current = false;
85
+ sectionToScroll.scrollIntoView({
86
+ block: "start",
87
+ inline: "nearest",
88
+ behavior: "smooth"
89
+ });
80
90
  setSelectedIndex(index);
81
91
  }, 10);
82
92
  };
83
93
 
84
- const focusNavItem = (event, index) => {
85
- event.preventDefault();
86
- let newIndex = index;
94
+ const focusNavItem = index => {
95
+ var _anchorRefs$current$c;
87
96
 
88
- if (index === -1) {
89
- newIndex = anchorRefs.current.length - 1;
90
- } else if (index === anchorRefs.current.length) {
91
- newIndex = 0;
92
- }
97
+ const noOfRefs = anchorRefs.current.length;
98
+ (_anchorRefs$current$c = anchorRefs.current[(index % noOfRefs + noOfRefs) % noOfRefs].current) === null || _anchorRefs$current$c === void 0 ? void 0 : _anchorRefs$current$c.focus();
99
+ };
93
100
 
94
- anchorRefs.current[newIndex].current.focus();
101
+ const handleClick = (event, index) => {
102
+ event.preventDefault();
103
+ scrollToSection(index);
95
104
  };
96
105
 
97
106
  const handleKeyDown = (event, index) => {
107
+ event.preventDefault();
108
+
98
109
  if (Event.isUpKey(event)) {
99
- focusNavItem(event, index - 1);
110
+ focusNavItem(index - 1);
100
111
  } else if (Event.isDownKey(event)) {
101
- focusNavItem(event, index + 1);
112
+ focusNavItem(index + 1);
102
113
  } else if (Event.isEnterKey(event) || Event.isSpaceKey(event)) {
103
- handleClick(event, index);
114
+ scrollToSection(index);
104
115
  }
105
116
  };
106
117
 
@@ -113,43 +124,15 @@ const AnchorNavigation = ({
113
124
  }, React.Children.map(stickyNavigation.props.children, (child, index) => /*#__PURE__*/React.cloneElement(child, {
114
125
  isSelected: index === selectedIndex,
115
126
  tabIndex: index === selectedIndex ? 0 : -1,
116
- onClick: ev => handleClick(ev, index),
117
- onKeyDown: ev => handleKeyDown(ev, index),
127
+ onClick: event => handleClick(event, index),
128
+ onKeyDown: event => handleKeyDown(event, index),
118
129
  ref: anchorRefs.current[index]
119
130
  }))), /*#__PURE__*/React.createElement(StyledContent, null, children));
120
131
  };
121
132
 
122
133
  AnchorNavigation.propTypes = {
123
- children: PropTypes.node,
124
-
125
- /** The AnchorNavigationItems components to be rendered in the sticky navigation.
126
- It is important to maintain proper structure.
127
- List of AnchorNavigationItems has to be wrapped in React.Fragment */
128
- stickyNavigation: (props, propName, componentName) => {
129
- let error;
130
- const prop = props[propName];
131
- const errorsList = [];
132
-
133
- if (!isFragment(prop)) {
134
- errorsList.push(`Prop ${propName} container supplied to ${componentName} should be a React.Fragment.`);
135
- }
136
-
137
- let isAnyChildIncorrect = false;
138
- React.Children.forEach(prop.props.children, child => {
139
- if (AnchorNavigationItem.displayName !== child.type.displayName) {
140
- isAnyChildIncorrect = true;
141
- }
142
- });
143
-
144
- if (isAnyChildIncorrect) {
145
- errorsList.push(`Prop ${propName} container supplied to ${componentName} only accepts children of type ${AnchorNavigationItem.displayName}.`);
146
- }
147
-
148
- if (errorsList.length) {
149
- error = new Error(errorsList.join(" "));
150
- }
151
-
152
- return error;
153
- }
134
+ "children": PropTypes.node,
135
+ "stickyNavigation": PropTypes.node
154
136
  };
137
+ AnchorNavigation.displayName = "AnchorNavigation";
155
138
  export default AnchorNavigation;
@@ -0,0 +1,4 @@
1
+ declare const StyledAnchorNavigation: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ declare const StyledNavigation: import("styled-components").StyledComponent<"ul", any, {}, never>;
3
+ declare const StyledContent: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export { StyledAnchorNavigation, StyledNavigation, StyledContent };
@@ -0,0 +1,4 @@
1
+ declare const AnchorSectionDivider: import("styled-components").StyledComponent<"div", any, {
2
+ "data-element": string;
3
+ }, "data-element">;
4
+ export default AnchorSectionDivider;
@@ -1,8 +1,9 @@
1
1
  import styled from "styled-components";
2
- const StyledAnchorDivider = styled.div.attrs({
2
+ const AnchorSectionDivider = styled.div.attrs({
3
3
  "data-element": "anchor-navigation-divider"
4
4
  })`
5
5
  background-color: var(--colorsActionMinor200);
6
6
  height: 1px;
7
7
  `;
8
- export default StyledAnchorDivider;
8
+ AnchorSectionDivider.displayName = "AnchorSectionDivider";
9
+ export default AnchorSectionDivider;
@@ -1,3 +1,5 @@
1
- export { default as AnchorNavigation } from "./anchor-navigation";
2
- export { default as AnchorNavigationItem } from "./anchor-navigation-item/anchor-navigation-item";
3
- export { default as AnchorSectionDivider } from "./anchor-section-divider/anchor-section-divider";
1
+ export { default as AnchorNavigation } from "./anchor-navigation.component";
2
+ export { default as AnchorNavigationItem } from "./anchor-navigation-item/anchor-navigation-item.component";
3
+ export { default as AnchorSectionDivider } from "./anchor-section-divider.component";
4
+ export type { AnchorNavigationProps } from "./anchor-navigation.component";
5
+ export type { AnchorNavigationItemProps } from "./anchor-navigation-item/anchor-navigation-item.component";
@@ -1,3 +1,3 @@
1
1
  export { default as AnchorNavigation } from "./anchor-navigation.component";
2
2
  export { default as AnchorNavigationItem } from "./anchor-navigation-item/anchor-navigation-item.component";
3
- export { default as AnchorSectionDivider } from "./anchor-section-divider/anchor-section-divider.style";
3
+ export { default as AnchorSectionDivider } from "./anchor-section-divider.component";
@@ -65,6 +65,16 @@ const DatePicker = /*#__PURE__*/React.forwardRef(({
65
65
  disabled
66
66
  }, ev) => {
67
67
  if (!disabled) {
68
+ var _inputElement$current;
69
+
70
+ const {
71
+ id,
72
+ name
73
+ } = inputElement === null || inputElement === void 0 ? void 0 : (_inputElement$current = inputElement.current) === null || _inputElement$current === void 0 ? void 0 : _inputElement$current.firstChild;
74
+ ev.target = { ...ev.target,
75
+ id,
76
+ name
77
+ };
68
78
  onDayClick(date, ev);
69
79
  }
70
80
  };
@@ -101,7 +111,6 @@ const DatePicker = /*#__PURE__*/React.forwardRef(({
101
111
  }, weekdaysShort[weekday]);
102
112
  },
103
113
  navbarElement: /*#__PURE__*/React.createElement(Navbar, null),
104
- enableOutsideDays: true,
105
114
  fixedWeeks: true,
106
115
  initialMonth: selectedDays || undefined,
107
116
  disabledDays: getDisabledDays(minDate, maxDate),
@@ -6,7 +6,7 @@ const StyledWeekday = styled.div`
6
6
  height: var(--sizing500);
7
7
  min-width: var(--sizing500);
8
8
  font-weight: 800;
9
- color: var(--colorsActionMinor400);
9
+ color: var(--colorsActionMinor500);
10
10
  text-transform: uppercase;
11
11
  font-size: 12px;
12
12
  //font: var(--typographyDatePickerCalendarDayM) font assets to be updated part of FE-4975
@@ -124,4 +124,5 @@ FlatTableCell.propTypes = {
124
124
  /** Sets a vertical right border color, provide design token, any color from palette or any valid css color value. */
125
125
  verticalBorderColor: PropTypes.string
126
126
  };
127
+ FlatTableCell.displayName = "FlatTableCell";
127
128
  export default FlatTableCell;
@@ -91,4 +91,5 @@ FlatTableCheckbox.propTypes = {
91
91
  */
92
92
  reportCellWidth: PropTypes.func
93
93
  };
94
+ FlatTableCheckbox.displayName = "FlatTableCheckbox";
94
95
  export default FlatTableCheckbox;
@@ -87,4 +87,5 @@ FlatTableHeader.propTypes = {
87
87
  FlatTableHeader.defaultProps = {
88
88
  align: "left"
89
89
  };
90
+ FlatTableHeader.displayName = "FlatTableHeader";
90
91
  export default FlatTableHeader;
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ import React, { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import Event from "../../../__internal__/utils/helpers/events";
6
6
  import StyledFlatTableRow from "./flat-table-row.style";
@@ -37,8 +37,8 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
37
37
  const firstColumnExpandable = expandableArea === "firstColumn";
38
38
  const [stickyCellWidths, setStickyCellWidths] = useState([]);
39
39
  const [leftPositions, setLeftPositions] = useState([]);
40
- const childrenArray = React.Children.toArray(children);
41
- const rowHeaderIndex = childrenArray.findIndex(child => child.type === FlatTableRowHeader);
40
+ const childrenArray = useMemo(() => React.Children.toArray(children), [children]);
41
+ const rowHeaderIndex = useMemo(() => childrenArray.findIndex(child => child.type.displayName === FlatTableRowHeader.displayName), [childrenArray]);
42
42
  const themeContext = useContext(FlatTableThemeContext);
43
43
  const reportCellWidth = useCallback((width, index) => {
44
44
  const copiedArray = stickyCellWidths;
@@ -85,4 +85,5 @@ FlatTableRowHeader.propTypes = {
85
85
  /** Sets a vertical right border color, provide design token, any color from palette or any valid css color value. */
86
86
  verticalBorderColor: PropTypes.string
87
87
  };
88
+ FlatTableRowHeader.displayName = "FlatTableRowHeader";
88
89
  export default FlatTableRowHeader;
@@ -0,0 +1,2 @@
1
+ export default StyledHelp;
2
+ declare const StyledHelp: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -2,8 +2,7 @@ import { act } from "react-dom/test-utils";
2
2
  import StyledMenuItemWrapper from "../../menu-item/menu-item.style";
3
3
  const events = {
4
4
  space: {
5
- key: "Space",
6
- which: 32,
5
+ key: " ",
7
6
  preventDefault: jest.fn()
8
7
  }
9
8
  };
@@ -145,7 +145,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
145
145
  nextIndex = numberOfChildren - 1;
146
146
  }
147
147
 
148
- if (Events.isAlphabetKey(event) || Events.isNumberKey(event)) {
148
+ if (event.key.length === 1) {
149
149
  event.stopPropagation();
150
150
 
151
151
  if (characterTimer.current) {
@@ -283,6 +283,9 @@ MultiActionButton.propTypes = {
283
283
  "color": PropTypes.string,
284
284
  "contentEditable": PropTypes.oneOfType([PropTypes.oneOf(["false", "inherit", "true"]), PropTypes.bool]),
285
285
  "contextMenu": PropTypes.string,
286
+ "css": PropTypes.oneOfType([PropTypes.func, PropTypes.number, PropTypes.object, PropTypes.shape({
287
+ "__emotion_styles": PropTypes.any.isRequired
288
+ }), PropTypes.string, PropTypes.bool]),
286
289
  "dangerouslySetInnerHTML": PropTypes.shape({
287
290
  "__html": PropTypes.string.isRequired
288
291
  }),
@@ -100,7 +100,7 @@ const NumeralDate = ({
100
100
  });
101
101
 
102
102
  const onKeyPress = ev => {
103
- const isValidKey = Events.isNumberKey(ev) || Events.isDeletingKey(ev) || Events.isTabKey(ev);
103
+ const isValidKey = Events.isNumberKey(ev) || Events.isTabKey(ev) || ev.key === "Delete" || ev.key === "Backspace";
104
104
 
105
105
  if (!isValidKey) {
106
106
  ev.preventDefault();
@@ -10,7 +10,6 @@ import { filterStyledSystemMarginProps } from "../../style/utils";
10
10
  import Icon from "../icon";
11
11
  import Textbox from "../textbox";
12
12
  import Button from "../button";
13
- import Events from "../../__internal__/utils/helpers/events";
14
13
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
15
14
 
16
15
  const Search = ({
@@ -121,7 +120,7 @@ const Search = ({
121
120
  };
122
121
 
123
122
  const handleKeyDown = ev => {
124
- if (Events.isAlphabetKey(ev) || Events.isNumberKey(ev)) {
123
+ if (ev.key.length === 1) {
125
124
  ev.stopPropagation();
126
125
  }
127
126
 
@@ -238,6 +238,9 @@ Input.propTypes = {
238
238
  "contentEditable": _propTypes.default.oneOfType([_propTypes.default.oneOf(["false", "inherit", "true"]), _propTypes.default.bool]),
239
239
  "contextMenu": _propTypes.default.string,
240
240
  "crossOrigin": _propTypes.default.string,
241
+ "css": _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
242
+ "__emotion_styles": _propTypes.default.any.isRequired
243
+ }), _propTypes.default.string, _propTypes.default.bool]),
241
244
  "dangerouslySetInnerHTML": _propTypes.default.shape({
242
245
  "__html": _propTypes.default.string.isRequired
243
246
  }),
@@ -0,0 +1,2 @@
1
+ declare const StyledIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export default StyledIconWrapper;
@@ -13,7 +13,7 @@ var _help = _interopRequireDefault(require("../../components/help/help.style"));
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- const IconWrapperStyle = _styledComponents.default.div`
16
+ const StyledIconWrapper = _styledComponents.default.div`
17
17
  display: inline-block;
18
18
  margin: 0;
19
19
  margin-left: 4px;
@@ -32,5 +32,5 @@ const IconWrapperStyle = _styledComponents.default.div`
32
32
  position: static;
33
33
  }
34
34
  `;
35
- var _default = IconWrapperStyle;
35
+ var _default = StyledIconWrapper;
36
36
  exports.default = _default;
@@ -1 +1,2 @@
1
- export { default } from "./label";
1
+ export { default } from "./label.component";
2
+ export type { LabelProps } from "./label.component";
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import { StyledLabelProps, StyledLabelContainerProps } from "./label.style";
3
+ import { ValidationProps } from "../validations";
4
+ import { IconType } from "../../components/icon";
5
+ export interface LabelProps extends ValidationProps, StyledLabelProps, StyledLabelContainerProps {
6
+ /** Children elements */
7
+ children?: React.ReactNode;
8
+ /** A message that the Help component will display */
9
+ help?: React.ReactNode;
10
+ /** Icon type */
11
+ helpIcon?: IconType;
12
+ /** Overrides the default tabindex of the Help component */
13
+ helpTabIndex?: string;
14
+ /** A string that represents the ID of another form element */
15
+ htmlFor?: string;
16
+ /** The unique id of the label element */
17
+ labelId?: string;
18
+ /** The unique id of the Help component tooltip, used for accessibility */
19
+ tooltipId?: string;
20
+ /** Whether to show the validation icon */
21
+ useValidationIcon?: boolean;
22
+ /** Id of the validation icon */
23
+ validationIconId?: string;
24
+ }
25
+ export declare const Label: ({ align, children, disabled, error, help, helpIcon, helpTabIndex, htmlFor, info, inline, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, }: LabelProps) => JSX.Element;
26
+ declare const _default: React.MemoExoticComponent<({ align, children, disabled, error, help, helpIcon, helpTabIndex, htmlFor, info, inline, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, }: LabelProps) => JSX.Element>;
27
+ export default _default;