carbon-react 107.1.5 → 107.1.8
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/__internal__/input/input.component.js +3 -0
- package/esm/__internal__/label/icon-wrapper.style.d.ts +2 -0
- package/esm/__internal__/label/icon-wrapper.style.js +4 -4
- package/esm/__internal__/label/index.d.ts +2 -1
- package/esm/__internal__/label/label.component.d.ts +27 -0
- package/esm/__internal__/label/label.component.js +42 -80
- package/esm/__internal__/label/label.style.d.ts +23 -3
- package/esm/__internal__/label/label.style.js +4 -19
- package/esm/__internal__/utils/helpers/events/events.d.ts +0 -58
- package/esm/__internal__/utils/helpers/events/events.js +12 -128
- package/esm/__spec_helper__/test-utils.d.ts +4 -25
- package/esm/__spec_helper__/test-utils.js +12 -25
- package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +2 -2
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.d.ts +19 -0
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.js +14 -21
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.d.ts +5 -0
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.js +0 -4
- package/esm/components/anchor-navigation/anchor-navigation.component.d.ts +14 -0
- package/esm/components/anchor-navigation/anchor-navigation.component.js +55 -72
- package/esm/components/anchor-navigation/anchor-navigation.style.d.ts +4 -0
- package/esm/components/anchor-navigation/anchor-section-divider.component.d.ts +4 -0
- package/esm/components/anchor-navigation/{anchor-section-divider/anchor-section-divider.style.js → anchor-section-divider.component.js} +3 -2
- package/esm/components/anchor-navigation/index.d.ts +5 -3
- package/esm/components/anchor-navigation/index.js +1 -1
- package/esm/components/date/__internal__/weekday/weekday.style.js +1 -1
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +1 -0
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -0
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +1 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +3 -3
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +1 -0
- package/esm/components/help/help.style.d.ts +2 -0
- package/esm/components/menu/__internal__/spec-helper/index.js +1 -2
- package/esm/components/menu/__internal__/submenu/submenu.component.js +2 -4
- package/esm/components/multi-action-button/multi-action-button.component.js +3 -0
- package/esm/components/numeral-date/numeral-date.component.js +1 -1
- package/esm/components/search/search.component.js +1 -2
- package/lib/__internal__/input/input.component.js +3 -0
- package/lib/__internal__/label/icon-wrapper.style.d.ts +2 -0
- package/lib/__internal__/label/icon-wrapper.style.js +2 -2
- package/lib/__internal__/label/index.d.ts +2 -1
- package/lib/__internal__/label/label.component.d.ts +27 -0
- package/lib/__internal__/label/label.component.js +40 -78
- package/lib/__internal__/label/label.style.d.ts +23 -3
- package/lib/__internal__/label/label.style.js +4 -22
- package/lib/__internal__/utils/helpers/events/events.d.ts +0 -58
- package/lib/__internal__/utils/helpers/events/events.js +12 -128
- package/lib/__spec_helper__/test-utils.d.ts +4 -25
- package/lib/__spec_helper__/test-utils.js +12 -25
- package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +2 -2
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.d.ts +19 -0
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.js +14 -21
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.d.ts +5 -0
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.js +0 -7
- package/lib/components/anchor-navigation/anchor-navigation.component.d.ts +14 -0
- package/lib/components/anchor-navigation/anchor-navigation.component.js +57 -73
- package/lib/components/anchor-navigation/anchor-navigation.style.d.ts +4 -0
- package/lib/components/anchor-navigation/anchor-section-divider.component.d.ts +4 -0
- package/lib/components/anchor-navigation/{anchor-section-divider/anchor-section-divider.style.js → anchor-section-divider.component.js} +3 -2
- package/lib/components/anchor-navigation/index.d.ts +5 -3
- package/lib/components/anchor-navigation/index.js +1 -1
- package/lib/components/date/__internal__/weekday/weekday.style.js +1 -1
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +1 -0
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -0
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +1 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +2 -4
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +1 -0
- package/lib/components/help/help.style.d.ts +2 -0
- package/lib/components/menu/__internal__/spec-helper/index.js +1 -2
- package/lib/components/menu/__internal__/submenu/submenu.component.js +2 -4
- package/lib/components/multi-action-button/multi-action-button.component.js +3 -0
- package/lib/components/numeral-date/numeral-date.component.js +1 -1
- package/lib/components/search/search.component.js +1 -3
- package/package.json +1 -1
- package/esm/__internal__/label/label.d.ts +0 -43
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.d.ts +0 -23
- package/esm/components/anchor-navigation/anchor-navigation.d.ts +0 -11
- package/esm/components/anchor-navigation/anchor-section-divider/anchor-section-divider.d.ts +0 -12
- package/lib/__internal__/label/label.d.ts +0 -43
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.d.ts +0 -23
- package/lib/components/anchor-navigation/anchor-navigation.d.ts +0 -11
- package/lib/components/anchor-navigation/anchor-section-divider/anchor-section-divider.d.ts +0 -12
|
@@ -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;
|
package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.js
CHANGED
|
@@ -13,7 +13,6 @@ var _anchorNavigationItem = _interopRequireDefault(require("./anchor-navigation-
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
/* eslint-disable react/no-unused-prop-types */
|
|
17
16
|
const AnchorNavigationItem = /*#__PURE__*/_react.default.forwardRef(({
|
|
18
17
|
children,
|
|
19
18
|
onKeyDown,
|
|
@@ -33,26 +32,20 @@ const AnchorNavigationItem = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
33
32
|
}, children)));
|
|
34
33
|
|
|
35
34
|
AnchorNavigationItem.propTypes = {
|
|
36
|
-
children: _propTypes.default.node,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/** Indicates if component is selected */
|
|
51
|
-
isSelected: _propTypes.default.bool,
|
|
52
|
-
|
|
53
|
-
/** Reference to the section html element meant to be shown */
|
|
54
|
-
target: _propTypes.default.shape({
|
|
55
|
-
current: _propTypes.default.instanceOf(Element)
|
|
35
|
+
"children": _propTypes.default.node,
|
|
36
|
+
"href": _propTypes.default.string,
|
|
37
|
+
"isSelected": _propTypes.default.bool,
|
|
38
|
+
"onClick": _propTypes.default.func,
|
|
39
|
+
"onKeyDown": _propTypes.default.func,
|
|
40
|
+
"tabIndex": _propTypes.default.number,
|
|
41
|
+
"target": _propTypes.default.shape({
|
|
42
|
+
"current": _propTypes.default.oneOfType([_propTypes.default.oneOf([null]), function (props, propName) {
|
|
43
|
+
if (props[propName] == null) {
|
|
44
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
45
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
46
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
47
|
+
}
|
|
48
|
+
}]).isRequired
|
|
56
49
|
})
|
|
57
50
|
};
|
|
58
51
|
AnchorNavigationItem.displayName = "AnchorNavigationItem";
|
package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.js
CHANGED
|
@@ -5,16 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
9
|
|
|
12
10
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
13
11
|
|
|
14
12
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
13
|
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
14
|
const StyledNavigationItem = _styledComponents.default.li`
|
|
19
15
|
width: 100%;
|
|
20
16
|
|
|
@@ -46,8 +42,5 @@ const StyledNavigationItem = _styledComponents.default.li`
|
|
|
46
42
|
`}
|
|
47
43
|
}
|
|
48
44
|
`;
|
|
49
|
-
StyledNavigationItem.propTypes = {
|
|
50
|
-
isSelected: _propTypes.default.bool
|
|
51
|
-
};
|
|
52
45
|
var _default = StyledNavigationItem;
|
|
53
46
|
exports.default = _default;
|
|
@@ -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;
|
|
@@ -9,10 +9,12 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
13
|
-
|
|
14
12
|
var _reactIs = require("react-is");
|
|
15
13
|
|
|
14
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
15
|
+
|
|
16
|
+
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
17
|
+
|
|
16
18
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
17
19
|
|
|
18
20
|
var _anchorNavigation = require("./anchor-navigation.style");
|
|
@@ -32,45 +34,57 @@ const AnchorNavigation = ({
|
|
|
32
34
|
children,
|
|
33
35
|
stickyNavigation
|
|
34
36
|
}) => {
|
|
37
|
+
(0, _invariant.default)((0, _reactIs.isFragment)(stickyNavigation), "`stickyNavigation` prop in `AnchorNavigation` should be a React Fragment.");
|
|
38
|
+
const hasCorrectItemStructure = (0, _react.useMemo)(() => {
|
|
39
|
+
const incorrectChild = _react.default.Children.toArray(stickyNavigation.props.children).find(child => {
|
|
40
|
+
return ! /*#__PURE__*/_react.default.isValidElement(child) || child.type.displayName !== _anchorNavigationItem.default.displayName;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return !incorrectChild;
|
|
44
|
+
}, [stickyNavigation]);
|
|
45
|
+
(0, _invariant.default)(hasCorrectItemStructure, `\`stickyNavigation\` prop in \`AnchorNavigation\` should be a React Fragment that only contains children of type \`${_anchorNavigationItem.default.displayName}\``);
|
|
35
46
|
const [selectedIndex, setSelectedIndex] = (0, _react.useState)(0);
|
|
36
47
|
const sectionRefs = (0, _react.useRef)(_react.default.Children.map(stickyNavigation.props.children, child => child.props.target));
|
|
37
48
|
const anchorRefs = (0, _react.useRef)(Array.from({
|
|
38
49
|
length: _react.default.Children.count(stickyNavigation.props.children)
|
|
39
|
-
}, () => /*#__PURE__*/_react.
|
|
40
|
-
const contentRef = (0, _react.useRef)();
|
|
41
|
-
const navigationRef = (0, _react.useRef)();
|
|
50
|
+
}, () => /*#__PURE__*/(0, _react.createRef)()));
|
|
51
|
+
const contentRef = (0, _react.useRef)(null);
|
|
52
|
+
const navigationRef = (0, _react.useRef)(null);
|
|
42
53
|
const isUserScroll = (0, _react.useRef)(true);
|
|
43
54
|
const isUserScrollTimer = (0, _react.useRef)();
|
|
44
55
|
const setSelectedAnchorBasedOnScroll = (0, _react.useCallback)(() => {
|
|
45
|
-
|
|
56
|
+
// istanbul ignore if
|
|
57
|
+
// function is called only after component is rendered, so ref cannot hold a null value
|
|
58
|
+
if (navigationRef.current === null) return;
|
|
59
|
+
const offsetsWithIndexes = sectionRefs.current.map(({
|
|
46
60
|
current
|
|
47
|
-
}) => current.getBoundingClientRect().top);
|
|
61
|
+
}, index) => [index, current === null || current === void 0 ? void 0 : current.getBoundingClientRect().top]).filter(offsetWithIndex => offsetWithIndex[1] !== undefined);
|
|
48
62
|
const {
|
|
49
63
|
top: navTopOffset
|
|
50
64
|
} = navigationRef.current.getBoundingClientRect();
|
|
51
|
-
const indexOfSmallestNegativeTopOffset =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
const indexOfSmallestNegativeTopOffset = offsetsWithIndexes.reduce((currentTopIndex, offsetWithIndex) => {
|
|
66
|
+
const [index, offset] = offsetWithIndex;
|
|
67
|
+
if (offset - SECTION_VISIBILITY_OFFSET > navTopOffset) return currentTopIndex;
|
|
68
|
+
return offset > offsetsWithIndexes[currentTopIndex][1] ? index : currentTopIndex;
|
|
69
|
+
}, offsetsWithIndexes[0][0]);
|
|
55
70
|
setSelectedIndex(indexOfSmallestNegativeTopOffset);
|
|
56
71
|
}, []);
|
|
57
|
-
const scrollHandler = (0, _react.
|
|
72
|
+
const scrollHandler = (0, _react.useMemo)(() => (0, _throttle.default)(() => {
|
|
58
73
|
if (isUserScroll.current) {
|
|
59
74
|
setSelectedAnchorBasedOnScroll();
|
|
60
75
|
} else {
|
|
61
|
-
window.clearTimeout(isUserScrollTimer.current);
|
|
76
|
+
if (isUserScrollTimer.current !== undefined) window.clearTimeout(isUserScrollTimer.current);
|
|
62
77
|
isUserScrollTimer.current = setTimeout(() => {
|
|
63
78
|
isUserScroll.current = true;
|
|
64
79
|
}, SCROLL_THROTTLE + 50);
|
|
65
80
|
}
|
|
66
|
-
}, SCROLL_THROTTLE), []);
|
|
81
|
+
}, SCROLL_THROTTLE), [setSelectedAnchorBasedOnScroll]);
|
|
67
82
|
(0, _react.useEffect)(() => {
|
|
68
83
|
window.addEventListener("scroll", scrollHandler, true);
|
|
69
84
|
return () => window.removeEventListener("scroll", scrollHandler, true);
|
|
70
85
|
}, [scrollHandler]);
|
|
71
86
|
|
|
72
87
|
const focusFirstFocusableChild = section => {
|
|
73
|
-
// eslint-disable-next-line max-len
|
|
74
88
|
const defaultFocusableSelectors = 'button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
75
89
|
const firstFocusableElement = section.querySelector(defaultFocusableSelectors);
|
|
76
90
|
|
|
@@ -81,46 +95,45 @@ const AnchorNavigation = ({
|
|
|
81
95
|
}
|
|
82
96
|
};
|
|
83
97
|
|
|
84
|
-
const scrollToSection =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
block: "start",
|
|
88
|
-
inline: "nearest",
|
|
89
|
-
behavior: "smooth"
|
|
90
|
-
});
|
|
91
|
-
};
|
|
98
|
+
const scrollToSection = index => {
|
|
99
|
+
const sectionToScroll = sectionRefs.current[index].current; // istanbul ignore if
|
|
100
|
+
// function is called only after component is rendered, so ref cannot hold a null value
|
|
92
101
|
|
|
93
|
-
|
|
94
|
-
event.preventDefault();
|
|
95
|
-
const sectionToScroll = sectionRefs.current[index].current;
|
|
102
|
+
if (sectionToScroll === null) return;
|
|
96
103
|
focusFirstFocusableChild(sectionToScroll); // workaround due to preventScroll focus method option on firefox not working consistently
|
|
97
104
|
|
|
98
105
|
window.setTimeout(() => {
|
|
99
|
-
|
|
106
|
+
isUserScroll.current = false;
|
|
107
|
+
sectionToScroll.scrollIntoView({
|
|
108
|
+
block: "start",
|
|
109
|
+
inline: "nearest",
|
|
110
|
+
behavior: "smooth"
|
|
111
|
+
});
|
|
100
112
|
setSelectedIndex(index);
|
|
101
113
|
}, 10);
|
|
102
114
|
};
|
|
103
115
|
|
|
104
|
-
const focusNavItem =
|
|
105
|
-
|
|
106
|
-
let newIndex = index;
|
|
116
|
+
const focusNavItem = index => {
|
|
117
|
+
var _anchorRefs$current$c;
|
|
107
118
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
newIndex = 0;
|
|
112
|
-
}
|
|
119
|
+
const noOfRefs = anchorRefs.current.length;
|
|
120
|
+
(_anchorRefs$current$c = anchorRefs.current[(index % noOfRefs + noOfRefs) % noOfRefs].current) === null || _anchorRefs$current$c === void 0 ? void 0 : _anchorRefs$current$c.focus();
|
|
121
|
+
};
|
|
113
122
|
|
|
114
|
-
|
|
123
|
+
const handleClick = (event, index) => {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
scrollToSection(index);
|
|
115
126
|
};
|
|
116
127
|
|
|
117
128
|
const handleKeyDown = (event, index) => {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
|
|
118
131
|
if (_events.default.isUpKey(event)) {
|
|
119
|
-
focusNavItem(
|
|
132
|
+
focusNavItem(index - 1);
|
|
120
133
|
} else if (_events.default.isDownKey(event)) {
|
|
121
|
-
focusNavItem(
|
|
134
|
+
focusNavItem(index + 1);
|
|
122
135
|
} else if (_events.default.isEnterKey(event) || _events.default.isSpaceKey(event)) {
|
|
123
|
-
|
|
136
|
+
scrollToSection(index);
|
|
124
137
|
}
|
|
125
138
|
};
|
|
126
139
|
|
|
@@ -133,45 +146,16 @@ const AnchorNavigation = ({
|
|
|
133
146
|
}, _react.default.Children.map(stickyNavigation.props.children, (child, index) => /*#__PURE__*/_react.default.cloneElement(child, {
|
|
134
147
|
isSelected: index === selectedIndex,
|
|
135
148
|
tabIndex: index === selectedIndex ? 0 : -1,
|
|
136
|
-
onClick:
|
|
137
|
-
onKeyDown:
|
|
149
|
+
onClick: event => handleClick(event, index),
|
|
150
|
+
onKeyDown: event => handleKeyDown(event, index),
|
|
138
151
|
ref: anchorRefs.current[index]
|
|
139
152
|
}))), /*#__PURE__*/_react.default.createElement(_anchorNavigation.StyledContent, null, children));
|
|
140
153
|
};
|
|
141
154
|
|
|
142
155
|
AnchorNavigation.propTypes = {
|
|
143
|
-
children: _propTypes.default.node,
|
|
144
|
-
|
|
145
|
-
/** The AnchorNavigationItems components to be rendered in the sticky navigation.
|
|
146
|
-
It is important to maintain proper structure.
|
|
147
|
-
List of AnchorNavigationItems has to be wrapped in React.Fragment */
|
|
148
|
-
stickyNavigation: (props, propName, componentName) => {
|
|
149
|
-
let error;
|
|
150
|
-
const prop = props[propName];
|
|
151
|
-
const errorsList = [];
|
|
152
|
-
|
|
153
|
-
if (!(0, _reactIs.isFragment)(prop)) {
|
|
154
|
-
errorsList.push(`Prop ${propName} container supplied to ${componentName} should be a React.Fragment.`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
let isAnyChildIncorrect = false;
|
|
158
|
-
|
|
159
|
-
_react.default.Children.forEach(prop.props.children, child => {
|
|
160
|
-
if (_anchorNavigationItem.default.displayName !== child.type.displayName) {
|
|
161
|
-
isAnyChildIncorrect = true;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
if (isAnyChildIncorrect) {
|
|
166
|
-
errorsList.push(`Prop ${propName} container supplied to ${componentName} only accepts children of type ${_anchorNavigationItem.default.displayName}.`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (errorsList.length) {
|
|
170
|
-
error = new Error(errorsList.join(" "));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return error;
|
|
174
|
-
}
|
|
156
|
+
"children": _propTypes.default.node,
|
|
157
|
+
"stickyNavigation": _propTypes.default.node
|
|
175
158
|
};
|
|
159
|
+
AnchorNavigation.displayName = "AnchorNavigation";
|
|
176
160
|
var _default = AnchorNavigation;
|
|
177
161
|
exports.default = _default;
|
|
@@ -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 };
|
|
@@ -9,11 +9,12 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const AnchorSectionDivider = _styledComponents.default.div.attrs({
|
|
13
13
|
"data-element": "anchor-navigation-divider"
|
|
14
14
|
})`
|
|
15
15
|
background-color: var(--colorsActionMinor200);
|
|
16
16
|
height: 1px;
|
|
17
17
|
`;
|
|
18
|
-
|
|
18
|
+
AnchorSectionDivider.displayName = "AnchorSectionDivider";
|
|
19
|
+
var _default = AnchorSectionDivider;
|
|
19
20
|
exports.default = _default;
|
|
@@ -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
|
|
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";
|
|
@@ -26,6 +26,6 @@ var _anchorNavigation = _interopRequireDefault(require("./anchor-navigation.comp
|
|
|
26
26
|
|
|
27
27
|
var _anchorNavigationItem = _interopRequireDefault(require("./anchor-navigation-item/anchor-navigation-item.component"));
|
|
28
28
|
|
|
29
|
-
var _anchorSectionDivider = _interopRequireDefault(require("./anchor-section-divider
|
|
29
|
+
var _anchorSectionDivider = _interopRequireDefault(require("./anchor-section-divider.component"));
|
|
30
30
|
|
|
31
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -16,7 +16,7 @@ const StyledWeekday = _styledComponents.default.div`
|
|
|
16
16
|
height: var(--sizing500);
|
|
17
17
|
min-width: var(--sizing500);
|
|
18
18
|
font-weight: 800;
|
|
19
|
-
color: var(--
|
|
19
|
+
color: var(--colorsActionMinor500);
|
|
20
20
|
text-transform: uppercase;
|
|
21
21
|
font-size: 12px;
|
|
22
22
|
//font: var(--typographyDatePickerCalendarDayM) font assets to be updated part of FE-4975
|
|
@@ -143,5 +143,6 @@ FlatTableCell.propTypes = {
|
|
|
143
143
|
/** Sets a vertical right border color, provide design token, any color from palette or any valid css color value. */
|
|
144
144
|
verticalBorderColor: _propTypes.default.string
|
|
145
145
|
};
|
|
146
|
+
FlatTableCell.displayName = "FlatTableCell";
|
|
146
147
|
var _default = FlatTableCell;
|
|
147
148
|
exports.default = _default;
|
|
@@ -59,10 +59,8 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
59
59
|
const firstColumnExpandable = expandableArea === "firstColumn";
|
|
60
60
|
const [stickyCellWidths, setStickyCellWidths] = (0, _react.useState)([]);
|
|
61
61
|
const [leftPositions, setLeftPositions] = (0, _react.useState)([]);
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const rowHeaderIndex = childrenArray.findIndex(child => child.type === _flatTableRowHeader.default);
|
|
62
|
+
const childrenArray = (0, _react.useMemo)(() => _react.default.Children.toArray(children), [children]);
|
|
63
|
+
const rowHeaderIndex = (0, _react.useMemo)(() => childrenArray.findIndex(child => child.type.displayName === _flatTableRowHeader.default.displayName), [childrenArray]);
|
|
66
64
|
const themeContext = (0, _react.useContext)(_flatTable.FlatTableThemeContext);
|
|
67
65
|
const reportCellWidth = (0, _react.useCallback)((width, index) => {
|
|
68
66
|
const copiedArray = stickyCellWidths;
|
|
@@ -100,5 +100,6 @@ FlatTableRowHeader.propTypes = {
|
|
|
100
100
|
/** Sets a vertical right border color, provide design token, any color from palette or any valid css color value. */
|
|
101
101
|
verticalBorderColor: _propTypes.default.string
|
|
102
102
|
};
|
|
103
|
+
FlatTableRowHeader.displayName = "FlatTableRowHeader";
|
|
103
104
|
var _default = FlatTableRowHeader;
|
|
104
105
|
exports.default = _default;
|
|
@@ -172,7 +172,7 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
172
172
|
nextIndex = numberOfChildren - 1;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
if (
|
|
175
|
+
if (event.key.length === 1) {
|
|
176
176
|
event.stopPropagation();
|
|
177
177
|
|
|
178
178
|
if (characterTimer.current) {
|
|
@@ -218,9 +218,7 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
218
218
|
};
|
|
219
219
|
|
|
220
220
|
const handleClick = event => {
|
|
221
|
-
|
|
222
|
-
openSubmenu();
|
|
223
|
-
}
|
|
221
|
+
openSubmenu();
|
|
224
222
|
|
|
225
223
|
if (onClick) {
|
|
226
224
|
onClick(event);
|
|
@@ -304,6 +304,9 @@ MultiActionButton.propTypes = {
|
|
|
304
304
|
"color": _propTypes.default.string,
|
|
305
305
|
"contentEditable": _propTypes.default.oneOfType([_propTypes.default.oneOf(["false", "inherit", "true"]), _propTypes.default.bool]),
|
|
306
306
|
"contextMenu": _propTypes.default.string,
|
|
307
|
+
"css": _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
308
|
+
"__emotion_styles": _propTypes.default.any.isRequired
|
|
309
|
+
}), _propTypes.default.string, _propTypes.default.bool]),
|
|
307
310
|
"dangerouslySetInnerHTML": _propTypes.default.shape({
|
|
308
311
|
"__html": _propTypes.default.string.isRequired
|
|
309
312
|
}),
|
|
@@ -130,7 +130,7 @@ const NumeralDate = ({
|
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
const onKeyPress = ev => {
|
|
133
|
-
const isValidKey = _events.default.isNumberKey(ev) || _events.default.
|
|
133
|
+
const isValidKey = _events.default.isNumberKey(ev) || _events.default.isTabKey(ev) || ev.key === "Delete" || ev.key === "Backspace";
|
|
134
134
|
|
|
135
135
|
if (!isValidKey) {
|
|
136
136
|
ev.preventDefault();
|
|
@@ -25,8 +25,6 @@ var _textbox = _interopRequireDefault(require("../textbox"));
|
|
|
25
25
|
|
|
26
26
|
var _button = _interopRequireDefault(require("../button"));
|
|
27
27
|
|
|
28
|
-
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
29
|
-
|
|
30
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
29
|
|
|
32
30
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -145,7 +143,7 @@ const Search = ({
|
|
|
145
143
|
};
|
|
146
144
|
|
|
147
145
|
const handleKeyDown = ev => {
|
|
148
|
-
if (
|
|
146
|
+
if (ev.key.length === 1) {
|
|
149
147
|
ev.stopPropagation();
|
|
150
148
|
}
|
|
151
149
|
|
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { ValidationProps } from "../validations";
|
|
3
|
-
|
|
4
|
-
export interface LabelPropTypes extends ValidationProps {
|
|
5
|
-
/** Label width */
|
|
6
|
-
width?: number;
|
|
7
|
-
/** Label alignment */
|
|
8
|
-
align?: "left" | "right";
|
|
9
|
-
/** When true, label is placed in line an input */
|
|
10
|
-
inline?: boolean;
|
|
11
|
-
/** Flag to configure component as mandatory */
|
|
12
|
-
isRequired?: boolean;
|
|
13
|
-
/** If true, the component will be disabled */
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
/** Flag to configure component as optional in Form */
|
|
16
|
-
optional?: boolean;
|
|
17
|
-
/** The unique id of the label element */
|
|
18
|
-
labelId?: string;
|
|
19
|
-
/** The unique id of the Help component tooltip, used for accessibility */
|
|
20
|
-
tooltipId?: string;
|
|
21
|
-
/** Children elements */
|
|
22
|
-
children?: React.ReactNode;
|
|
23
|
-
/** A message that the Help component will display */
|
|
24
|
-
help?: React.ReactNode;
|
|
25
|
-
/** Icon type */
|
|
26
|
-
helpIcon?: string;
|
|
27
|
-
/** Overrides the default tabindex of the Help component */
|
|
28
|
-
helpTabIndex?: string;
|
|
29
|
-
/** Whether to show the validation icon */
|
|
30
|
-
useValidationIcon?: boolean;
|
|
31
|
-
/** A string that represents the ID of another form element */
|
|
32
|
-
htmlFor?: string;
|
|
33
|
-
/** Padding right, integer multiplied by base spacing constant (8) */
|
|
34
|
-
pr?: 1 | 2;
|
|
35
|
-
/** Padding left, integer multiplied by base spacing constant (8) */
|
|
36
|
-
pl?: 1 | 2;
|
|
37
|
-
/** Id of the validation icon */
|
|
38
|
-
validationIconId?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare function Label(props: LabelPropTypes): JSX.Element;
|
|
42
|
-
|
|
43
|
-
export default Label;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
export interface AnchorNavigationItemProps {
|
|
4
|
-
children?: React.ReactNode;
|
|
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
|
-
/** Reference to the section html element meant to be shown */
|
|
16
|
-
target?: React.Ref<HTMLElement>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare function AnchorNavigationItem(
|
|
20
|
-
props: AnchorNavigationItemProps & React.RefAttributes<HTMLAnchorElement>
|
|
21
|
-
): JSX.Element;
|
|
22
|
-
|
|
23
|
-
export default AnchorNavigationItem;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
export interface AnchorNavigationProps {
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
/** The AnchorNavigationItems components to be rendered in the sticky navigation */
|
|
6
|
-
stickyNavigation?: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare function AnchorNavigation(props: AnchorNavigationProps): JSX.Element;
|
|
10
|
-
|
|
11
|
-
export default AnchorNavigation;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { StyledComponentProps } from "styled-components";
|
|
2
|
-
|
|
3
|
-
declare function AnchorSectionDivider(
|
|
4
|
-
attrs: StyledComponentProps<
|
|
5
|
-
"div",
|
|
6
|
-
Record<string, unknown>,
|
|
7
|
-
Record<string, unknown>,
|
|
8
|
-
""
|
|
9
|
-
>
|
|
10
|
-
): JSX.Element;
|
|
11
|
-
|
|
12
|
-
export default AnchorSectionDivider;
|