carbon-react 118.0.0 → 118.1.1
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__/filter-object-properties/filter-object-properties.d.ts +1 -1
- package/esm/components/button-minor/button-minor.style.js +8 -0
- package/esm/components/pager/pager.component.js +5 -5
- package/esm/components/pill/pill.component.d.ts +3 -1
- package/esm/components/pill/pill.component.js +1 -0
- package/esm/components/select/__internal__/select-list-context.d.ts +7 -0
- package/esm/components/select/__internal__/select-text/index.d.ts +2 -0
- package/esm/components/select/__internal__/select-text/index.js +1 -0
- package/esm/components/select/__internal__/select-text/select-text.component.d.ts +33 -0
- package/esm/components/select/__internal__/select-text/select-text.component.js +16 -36
- package/esm/components/select/__internal__/select-text/select-text.style.d.ts +6 -1
- package/esm/components/select/filterable-select/filterable-select.component.d.ts +65 -0
- package/esm/components/select/filterable-select/filterable-select.component.js +568 -102
- package/esm/components/select/filterable-select/index.d.ts +2 -1
- package/esm/components/select/filterable-select/index.js +1 -0
- package/esm/components/select/index.d.ts +6 -0
- package/esm/components/select/index.js +6 -6
- package/esm/components/select/list-action-button/index.d.ts +2 -0
- package/esm/components/select/list-action-button/index.js +1 -0
- package/esm/components/select/list-action-button/list-action-button.component.d.ts +7 -0
- package/esm/components/select/list-action-button/list-action-button.component.js +9 -6
- package/esm/components/select/list-action-button/list-action-button.style.d.ts +2 -0
- package/esm/components/select/multi-select/index.d.ts +2 -1
- package/esm/components/select/multi-select/index.js +1 -0
- package/esm/components/select/multi-select/multi-select.component.d.ts +62 -0
- package/esm/components/select/multi-select/multi-select.component.js +575 -104
- package/esm/components/select/multi-select/multi-select.style.d.ts +4 -0
- package/esm/components/select/multi-select/multi-select.style.js +1 -0
- package/esm/components/select/option/index.d.ts +2 -25
- package/esm/components/select/option/index.js +1 -0
- package/esm/components/select/option/option.component.d.ts +34 -0
- package/esm/components/select/option/option.component.js +399 -62
- package/esm/components/select/option/option.style.d.ts +6 -0
- package/esm/components/select/option/option.style.js +0 -5
- package/esm/components/select/option-group-header/index.d.ts +2 -10
- package/esm/components/select/option-group-header/index.js +1 -0
- package/esm/components/select/option-group-header/option-group-header.component.d.ts +16 -0
- package/esm/components/select/option-group-header/option-group-header.component.js +4 -15
- package/esm/components/select/option-group-header/option-group-header.style.d.ts +2 -0
- package/esm/components/select/option-row/index.d.ts +2 -16
- package/esm/components/select/option-row/index.js +1 -0
- package/esm/components/select/option-row/option-row.component.d.ts +42 -0
- package/esm/components/select/option-row/option-row.component.js +10 -40
- package/esm/components/select/option-row/option-row.style.d.ts +6 -0
- package/esm/components/select/select-list/index.d.ts +2 -0
- package/esm/components/select/select-list/index.js +1 -0
- package/esm/components/select/select-list/select-list-container.style.d.ts +6 -0
- package/esm/components/select/select-list/select-list.component.d.ts +64 -0
- package/esm/components/select/select-list/select-list.component.js +69 -100
- package/esm/components/select/select-list/select-list.style.d.ts +12 -0
- package/esm/components/select/select-list/select-list.style.js +2 -2
- package/esm/components/select/select-textbox/index.d.ts +2 -1
- package/esm/components/select/select-textbox/index.js +1 -0
- package/esm/components/select/select-textbox/select-textbox.component.d.ts +81 -0
- package/esm/components/select/select-textbox/select-textbox.component.js +567 -142
- package/esm/components/select/select.style.d.ts +8 -0
- package/esm/components/select/simple-select/index.d.ts +2 -1
- package/esm/components/select/simple-select/index.js +1 -0
- package/esm/components/select/simple-select/simple-select.component.d.ts +58 -0
- package/esm/components/select/simple-select/simple-select.component.js +578 -111
- package/esm/components/select/utils/get-next-child-by-text.d.ts +5 -0
- package/esm/components/select/utils/get-next-child-by-text.js +20 -17
- package/esm/components/select/utils/get-next-index-by-key.d.ts +2 -0
- package/esm/components/select/utils/highlight-part-of-text.d.ts +2 -0
- package/esm/components/select/utils/highlight-part-of-text.js +10 -3
- package/esm/components/select/utils/is-expected-option.d.ts +2 -0
- package/esm/components/select/utils/is-expected-option.js +1 -1
- package/esm/components/select/utils/is-expected-value.d.ts +1 -0
- package/esm/components/select/utils/is-expected-value.js +1 -1
- package/esm/components/select/utils/is-navigation-key.d.ts +1 -0
- package/esm/components/select/utils/matching-text.style.d.ts +2 -0
- package/esm/components/select/utils/with-filter.hoc.d.ts +14 -0
- package/esm/components/select/utils/with-filter.hoc.js +59 -41
- package/esm/components/tabs/__internal__/tab-title/tab-title.component.js +1 -0
- package/lib/__internal__/filter-object-properties/filter-object-properties.d.ts +1 -1
- package/lib/components/button-minor/button-minor.style.js +8 -0
- package/lib/components/pager/pager.component.js +5 -5
- package/lib/components/pill/pill.component.d.ts +3 -1
- package/lib/components/pill/pill.component.js +1 -0
- package/lib/components/select/__internal__/select-list-context.d.ts +7 -0
- package/lib/components/select/__internal__/select-text/index.d.ts +2 -0
- package/lib/components/select/__internal__/select-text/index.js +15 -0
- package/lib/components/select/__internal__/select-text/package.json +6 -0
- package/lib/components/select/__internal__/select-text/select-text.component.d.ts +33 -0
- package/lib/components/select/__internal__/select-text/select-text.component.js +16 -36
- package/lib/components/select/__internal__/select-text/select-text.style.d.ts +6 -1
- package/lib/components/select/filterable-select/filterable-select.component.d.ts +65 -0
- package/lib/components/select/filterable-select/filterable-select.component.js +569 -103
- package/lib/components/select/filterable-select/index.d.ts +2 -1
- package/lib/components/select/filterable-select/index.js +15 -0
- package/lib/components/select/filterable-select/package.json +6 -0
- package/lib/components/select/index.d.ts +6 -0
- package/lib/components/select/index.js +6 -6
- package/lib/components/select/list-action-button/index.d.ts +2 -0
- package/lib/components/select/list-action-button/index.js +15 -0
- package/lib/components/select/list-action-button/list-action-button.component.d.ts +7 -0
- package/lib/components/select/list-action-button/list-action-button.component.js +9 -6
- package/lib/components/select/list-action-button/list-action-button.style.d.ts +2 -0
- package/lib/components/select/list-action-button/package.json +6 -0
- package/lib/components/select/multi-select/index.d.ts +2 -1
- package/lib/components/select/multi-select/index.js +15 -0
- package/lib/components/select/multi-select/multi-select.component.d.ts +62 -0
- package/lib/components/select/multi-select/multi-select.component.js +576 -105
- package/lib/components/select/multi-select/multi-select.style.d.ts +4 -0
- package/lib/components/select/multi-select/multi-select.style.js +1 -0
- package/lib/components/select/multi-select/package.json +6 -0
- package/lib/components/select/option/index.d.ts +2 -25
- package/lib/components/select/option/index.js +15 -0
- package/lib/components/select/option/option.component.d.ts +34 -0
- package/lib/components/select/option/option.component.js +399 -62
- package/lib/components/select/option/option.style.d.ts +6 -0
- package/lib/components/select/option/option.style.js +0 -8
- package/lib/components/select/option/package.json +6 -0
- package/lib/components/select/option-group-header/index.d.ts +2 -10
- package/lib/components/select/option-group-header/index.js +15 -0
- package/lib/components/select/option-group-header/option-group-header.component.d.ts +16 -0
- package/lib/components/select/option-group-header/option-group-header.component.js +4 -15
- package/lib/components/select/option-group-header/option-group-header.style.d.ts +2 -0
- package/lib/components/select/option-group-header/package.json +6 -0
- package/lib/components/select/option-row/index.d.ts +2 -16
- package/lib/components/select/option-row/index.js +15 -0
- package/lib/components/select/option-row/option-row.component.d.ts +42 -0
- package/lib/components/select/option-row/option-row.component.js +10 -40
- package/lib/components/select/option-row/option-row.style.d.ts +6 -0
- package/lib/components/select/option-row/package.json +6 -0
- package/lib/components/select/select-list/index.d.ts +2 -0
- package/lib/components/select/select-list/index.js +15 -0
- package/lib/components/select/select-list/package.json +6 -0
- package/lib/components/select/select-list/select-list-container.style.d.ts +6 -0
- package/lib/components/select/select-list/select-list.component.d.ts +64 -0
- package/lib/components/select/select-list/select-list.component.js +69 -100
- package/lib/components/select/select-list/select-list.style.d.ts +12 -0
- package/lib/components/select/select-list/select-list.style.js +2 -2
- package/lib/components/select/select-textbox/index.d.ts +2 -1
- package/lib/components/select/select-textbox/index.js +15 -0
- package/lib/components/select/select-textbox/package.json +6 -0
- package/lib/components/select/select-textbox/select-textbox.component.d.ts +81 -0
- package/lib/components/select/select-textbox/select-textbox.component.js +567 -142
- package/lib/components/select/select.style.d.ts +8 -0
- package/lib/components/select/simple-select/index.d.ts +2 -1
- package/lib/components/select/simple-select/index.js +15 -0
- package/lib/components/select/simple-select/package.json +6 -0
- package/lib/components/select/simple-select/simple-select.component.d.ts +58 -0
- package/lib/components/select/simple-select/simple-select.component.js +579 -113
- package/lib/components/select/utils/get-next-child-by-text.d.ts +5 -0
- package/lib/components/select/utils/get-next-child-by-text.js +20 -17
- package/lib/components/select/utils/get-next-index-by-key.d.ts +2 -0
- package/lib/components/select/utils/highlight-part-of-text.d.ts +2 -0
- package/lib/components/select/utils/highlight-part-of-text.js +10 -3
- package/lib/components/select/utils/is-expected-option.d.ts +2 -0
- package/lib/components/select/utils/is-expected-option.js +1 -1
- package/lib/components/select/utils/is-expected-value.d.ts +1 -0
- package/lib/components/select/utils/is-expected-value.js +1 -1
- package/lib/components/select/utils/is-navigation-key.d.ts +1 -0
- package/lib/components/select/utils/matching-text.style.d.ts +2 -0
- package/lib/components/select/utils/with-filter.hoc.d.ts +14 -0
- package/lib/components/select/utils/with-filter.hoc.js +59 -42
- package/lib/components/tabs/__internal__/tab-title/tab-title.component.js +1 -0
- package/package.json +1 -1
- package/esm/components/select/__internal__/select-text/select-text.d.ts +0 -36
- package/esm/components/select/filterable-select/filterable-select.d.ts +0 -71
- package/esm/components/select/multi-select/multi-select.d.ts +0 -68
- package/esm/components/select/select-textbox/select-textbox.d.ts +0 -72
- package/esm/components/select/simple-select/simple-select.d.ts +0 -64
- package/lib/components/select/__internal__/select-text/select-text.d.ts +0 -36
- package/lib/components/select/filterable-select/filterable-select.d.ts +0 -71
- package/lib/components/select/multi-select/multi-select.d.ts +0 -68
- package/lib/components/select/select-textbox/select-textbox.d.ts +0 -72
- package/lib/components/select/simple-select/simple-select.d.ts +0 -64
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Recreates HTML Select element functionality of finding first match based on typed characters
|
|
4
|
+
* */
|
|
5
|
+
export default function getNextChildByText(textToMatch: string, arrayOfChildren: React.ReactElement[], previousIndex?: number): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default function getNextChildByText(textToMatch, arrayOfChildren, previousIndex = -1) {
|
|
5
|
-
const lastCharacter = textToMatch.slice(-1);
|
|
6
|
-
const isTheSameCharacter = textToMatch.split("").every(character => character === lastCharacter);
|
|
7
|
-
let indexOfMatch = findElementStartingWithText(textToMatch, arrayOfChildren);
|
|
8
|
-
const listOfMatches = getListOfMatches(arrayOfChildren, lastCharacter);
|
|
9
|
-
|
|
10
|
-
if (isTheSameCharacter && listOfMatches.length > 1) {
|
|
11
|
-
indexOfMatch = getIndexOfNextElement(listOfMatches, previousIndex);
|
|
12
|
-
}
|
|
1
|
+
function findElementStartingWithText(textToMatch, list) {
|
|
2
|
+
return list.findIndex(child => {
|
|
3
|
+
var _child$props$text;
|
|
13
4
|
|
|
14
|
-
|
|
5
|
+
return (_child$props$text = child.props.text) === null || _child$props$text === void 0 ? void 0 : _child$props$text.toLowerCase().startsWith(textToMatch.toLowerCase());
|
|
6
|
+
});
|
|
15
7
|
}
|
|
16
8
|
|
|
17
9
|
function getListOfMatches(arrayOfChildren, lastCharacter) {
|
|
@@ -33,9 +25,20 @@ function getIndexOfNextElement(listOfMatches, previousIndex) {
|
|
|
33
25
|
|
|
34
26
|
return listOfMatches[listOfMatches.indexOf(previousIndex) + 1];
|
|
35
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Recreates HTML Select element functionality of finding first match based on typed characters
|
|
30
|
+
* */
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
|
|
33
|
+
export default function getNextChildByText(textToMatch, arrayOfChildren, previousIndex = -1) {
|
|
34
|
+
const lastCharacter = textToMatch.slice(-1);
|
|
35
|
+
const isTheSameCharacter = textToMatch.split("").every(character => character === lastCharacter);
|
|
36
|
+
let indexOfMatch = findElementStartingWithText(textToMatch, arrayOfChildren);
|
|
37
|
+
const listOfMatches = getListOfMatches(arrayOfChildren, lastCharacter);
|
|
38
|
+
|
|
39
|
+
if (isTheSameCharacter && listOfMatches.length > 1) {
|
|
40
|
+
indexOfMatch = getIndexOfNextElement(listOfMatches, previousIndex);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return arrayOfChildren[indexOfMatch];
|
|
41
44
|
}
|
|
@@ -13,10 +13,11 @@ function highlightPartOfText(text, partToHighlight) {
|
|
|
13
13
|
|
|
14
14
|
const precedingText = text.substr(0, indexOfFirstMatch);
|
|
15
15
|
const matchingText = text.substr(indexOfFirstMatch, partToHighlight.length);
|
|
16
|
-
|
|
16
|
+
const followingText = text.substr(indexOfFirstMatch + partToHighlight.length, text.length);
|
|
17
|
+
let followingTextNode = followingText;
|
|
17
18
|
|
|
18
19
|
if (followingText.length >= partToHighlight.length) {
|
|
19
|
-
|
|
20
|
+
followingTextNode = highlightPartOfText(followingText, partToHighlight);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const newValue = [/*#__PURE__*/React.createElement("span", {
|
|
@@ -25,7 +26,7 @@ function highlightPartOfText(text, partToHighlight) {
|
|
|
25
26
|
key: "match"
|
|
26
27
|
}, matchingText), /*#__PURE__*/React.createElement("span", {
|
|
27
28
|
key: "following"
|
|
28
|
-
},
|
|
29
|
+
}, followingTextNode)];
|
|
29
30
|
return newValue;
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -33,6 +34,12 @@ export default function highlightPartOfTextRecursive(child, partToHighlight) {
|
|
|
33
34
|
if (typeof child === "string") {
|
|
34
35
|
return highlightPartOfText(child, partToHighlight);
|
|
35
36
|
}
|
|
37
|
+
/* istanbul ignore if */
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
41
|
+
return child;
|
|
42
|
+
}
|
|
36
43
|
|
|
37
44
|
const highlightedChildren = React.Children.map(child.props.children, grandChild => highlightPartOfTextRecursive(grandChild, partToHighlight));
|
|
38
45
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isExpectedValue(currentValue: string | Record<string, unknown>, expectedValue: string | Record<string, unknown>): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default function isExpectedValue(currentValue, expectedValue) {
|
|
2
|
-
if (typeof currentValue === "object" && currentValue.id !== null && currentValue.id !== undefined) {
|
|
2
|
+
if (typeof currentValue === "object" && currentValue.id !== null && currentValue.id !== undefined && typeof expectedValue === "object") {
|
|
3
3
|
return currentValue.id === expectedValue.id;
|
|
4
4
|
}
|
|
5
5
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isNavigationKey(key: string): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface WrappedComponentProps {
|
|
3
|
+
filterText?: string;
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
multiColumn?: boolean;
|
|
6
|
+
tableHeader?: React.ReactNode;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export interface FilteredComponentProps extends WrappedComponentProps {
|
|
10
|
+
noResultsMessage?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Filters wrapped component children based on provided filter text and highlights matching content */
|
|
13
|
+
declare const withFilter: <T extends WrappedComponentProps>(WrappedComponent: React.ComponentType<T>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<FilteredComponentProps & T> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default withFilter;
|
|
@@ -1,11 +1,10 @@
|
|
|
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
3
|
import React, { useCallback } from "react";
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
4
|
import useLocale from "../../../hooks/__internal__/useLocale";
|
|
6
5
|
import StyledOptionRow from "../option-row/option-row.style";
|
|
7
6
|
import StyledOption from "../option/option.style";
|
|
8
|
-
import Option from "../option
|
|
7
|
+
import Option from "../option";
|
|
9
8
|
import OptionRow from "../option-row/option-row.component";
|
|
10
9
|
import highlightPartOfText from "./highlight-part-of-text";
|
|
11
10
|
|
|
@@ -25,6 +24,11 @@ const filterOptions = (option, filterText) => {
|
|
|
25
24
|
const filterOptionRows = (optionRow, filterText) => {
|
|
26
25
|
const cells = React.Children.toArray(optionRow.props.children);
|
|
27
26
|
const hasText = cells.find(cell => {
|
|
27
|
+
/* istanbul ignore if */
|
|
28
|
+
if (! /*#__PURE__*/React.isValidElement(cell)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
if (typeof cell.props.children === "string") {
|
|
29
33
|
const processedText = cell.props.children.toLowerCase();
|
|
30
34
|
const processedValue = filterText.toLowerCase();
|
|
@@ -43,24 +47,63 @@ const filterOptionRows = (optionRow, filterText) => {
|
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
const filterChildren = filterText => children => {
|
|
46
|
-
// eslint-disable-next-line consistent-return
|
|
47
50
|
const filteredChildren = React.Children.map(children, child => {
|
|
51
|
+
/* istanbul ignore if */
|
|
52
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
if (child.type === Option) {
|
|
49
57
|
return filterOptions(child, filterText);
|
|
50
58
|
}
|
|
59
|
+
/* istanbul ignore else */
|
|
60
|
+
|
|
51
61
|
|
|
52
62
|
if (child.type === OptionRow) {
|
|
53
63
|
return filterOptionRows(child, filterText);
|
|
54
64
|
}
|
|
65
|
+
/* istanbul ignore next */
|
|
66
|
+
|
|
55
67
|
|
|
56
68
|
return null;
|
|
57
69
|
});
|
|
58
70
|
if (React.Children.count(filteredChildren)) return filteredChildren;
|
|
59
71
|
return null;
|
|
60
72
|
};
|
|
61
|
-
/** Filters wrapped component children based on provided filter text and highlights matching content */
|
|
62
73
|
|
|
74
|
+
function addHighlightedContent(filteredElements, filterText) {
|
|
75
|
+
return React.Children.map(filteredElements, child => {
|
|
76
|
+
let highlightedContent;
|
|
77
|
+
/* istanbul ignore if */
|
|
78
|
+
|
|
79
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
80
|
+
return child;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (child.type === Option) {
|
|
84
|
+
highlightedContent = highlightPartOfText(child.props.text, filterText);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (child.type === OptionRow) {
|
|
88
|
+
highlightedContent = React.Children.map(child.props.children, cell => {
|
|
89
|
+
/* istanbul ignore if */
|
|
90
|
+
if (! /*#__PURE__*/React.isValidElement(cell)) {
|
|
91
|
+
return cell;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return /*#__PURE__*/React.cloneElement(cell, {
|
|
95
|
+
children: highlightPartOfText(cell.props.children, filterText)
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
101
|
+
children: highlightedContent
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
63
105
|
|
|
106
|
+
/** Filters wrapped component children based on provided filter text and highlights matching content */
|
|
64
107
|
const withFilter = WrappedComponent => {
|
|
65
108
|
const FilteredComponent = /*#__PURE__*/React.forwardRef(({
|
|
66
109
|
children,
|
|
@@ -84,7 +127,9 @@ const withFilter = WrappedComponent => {
|
|
|
84
127
|
if (multiColumn) {
|
|
85
128
|
var _tableHeader$props;
|
|
86
129
|
|
|
87
|
-
const colSpan = React.
|
|
130
|
+
const colSpan = /*#__PURE__*/React.isValidElement(tableHeader) ?
|
|
131
|
+
/* istanbul ignore next */
|
|
132
|
+
React.Children.count(tableHeader === null || tableHeader === void 0 ? void 0 : (_tableHeader$props = tableHeader.props) === null || _tableHeader$props === void 0 ? void 0 : _tableHeader$props.children) : 1;
|
|
88
133
|
return /*#__PURE__*/React.createElement(StyledOptionRow, null, /*#__PURE__*/React.createElement("td", {
|
|
89
134
|
style: {
|
|
90
135
|
fontWeight: "normal"
|
|
@@ -101,45 +146,18 @@ const withFilter = WrappedComponent => {
|
|
|
101
146
|
|
|
102
147
|
return children;
|
|
103
148
|
}, [children, filterText, isLoading, multiColumn, noResultsMessage, tableHeader, l]);
|
|
104
|
-
|
|
105
|
-
filterText
|
|
106
|
-
isLoading
|
|
107
|
-
multiColumn
|
|
108
|
-
tableHeader
|
|
109
|
-
|
|
149
|
+
const wrappedComponentProps = {
|
|
150
|
+
filterText,
|
|
151
|
+
isLoading,
|
|
152
|
+
multiColumn,
|
|
153
|
+
tableHeader,
|
|
154
|
+
...props
|
|
155
|
+
};
|
|
156
|
+
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, wrappedComponentProps, {
|
|
110
157
|
ref: forwardedRef
|
|
111
158
|
}), getFilteredChildren());
|
|
112
159
|
});
|
|
113
|
-
|
|
114
|
-
function addHighlightedContent(filteredElements, filterText) {
|
|
115
|
-
return React.Children.map(filteredElements, child => {
|
|
116
|
-
let highlightedContent;
|
|
117
|
-
|
|
118
|
-
if (child.type === Option) {
|
|
119
|
-
highlightedContent = highlightPartOfText(child.props.text, filterText);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (child.type === OptionRow) {
|
|
123
|
-
highlightedContent = React.Children.map(child.props.children, cell => /*#__PURE__*/React.cloneElement(cell, {
|
|
124
|
-
children: highlightPartOfText(cell.props.children, filterText)
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
129
|
-
children: highlightedContent
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
FilteredComponent.propTypes = {
|
|
135
|
-
forwardedRef: PropTypes.object,
|
|
136
|
-
children: PropTypes.node,
|
|
137
|
-
filterText: PropTypes.string,
|
|
138
|
-
noResultsMessage: PropTypes.string,
|
|
139
|
-
isLoading: PropTypes.bool,
|
|
140
|
-
multiColumn: PropTypes.bool,
|
|
141
|
-
tableHeader: PropTypes.node
|
|
142
|
-
};
|
|
160
|
+
FilteredComponent.displayName = "FilteredComponent";
|
|
143
161
|
return FilteredComponent;
|
|
144
162
|
};
|
|
145
163
|
|
|
@@ -190,6 +190,7 @@ const TabTitle = /*#__PURE__*/React.forwardRef(({
|
|
|
190
190
|
href: href,
|
|
191
191
|
target: "_blank"
|
|
192
192
|
}), titleChildren) : /*#__PURE__*/React.createElement(StyledTabTitleButton, _extends({}, titleWrapperProps, {
|
|
193
|
+
type: "button",
|
|
193
194
|
ref: ref
|
|
194
195
|
}), titleChildren);
|
|
195
196
|
return /*#__PURE__*/React.createElement(TooltipProvider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function filterObjectProperties(originalObject:
|
|
1
|
+
export default function filterObjectProperties<T extends object>(originalObject: T, keyList: string[]): Partial<T>;
|
|
@@ -32,6 +32,14 @@ function makeColors(color) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const StyledButtonMinor = (0, _styledComponents.default)(_button.default)`
|
|
35
|
+
${({
|
|
36
|
+
children
|
|
37
|
+
}) => !children && (0, _styledComponents.css)`
|
|
38
|
+
${_icon.default} {
|
|
39
|
+
position: absolute;
|
|
40
|
+
}
|
|
41
|
+
`}
|
|
42
|
+
|
|
35
43
|
${({
|
|
36
44
|
buttonType,
|
|
37
45
|
destructive,
|
|
@@ -121,12 +121,12 @@ const Pager = ({
|
|
|
121
121
|
onPrevious(e);
|
|
122
122
|
}
|
|
123
123
|
}, [page, onPrevious]);
|
|
124
|
-
const handleOnPagination = (0, _react.useCallback)(
|
|
125
|
-
setValue(
|
|
126
|
-
setCurrentPageSize(+
|
|
127
|
-
onPagination(1, +
|
|
124
|
+
const handleOnPagination = (0, _react.useCallback)(selectedValue => {
|
|
125
|
+
setValue(selectedValue);
|
|
126
|
+
setCurrentPageSize(+selectedValue);
|
|
127
|
+
onPagination(1, +selectedValue, "page-select");
|
|
128
128
|
}, [onPagination]);
|
|
129
|
-
const handleKeyDown = (0, _react.useCallback)(e => _events.default.isEnterKey(e) && handleOnPagination(e), [handleOnPagination]);
|
|
129
|
+
const handleKeyDown = (0, _react.useCallback)(e => _events.default.isEnterKey(e) && handleOnPagination(e.target.value), [handleOnPagination]);
|
|
130
130
|
|
|
131
131
|
const sizeSelector = () => {
|
|
132
132
|
return /*#__PURE__*/_react.default.createElement(_pager.StyledSelectContainer, null, /*#__PURE__*/_react.default.createElement(_select.Select, {
|
|
@@ -14,11 +14,13 @@ export interface PillProps extends StyledPillProps {
|
|
|
14
14
|
/** Callback function for when the pill is clicked. */
|
|
15
15
|
onClick?: (ev: React.MouseEvent<HTMLSpanElement>) => void;
|
|
16
16
|
/** Callback function for when the remove icon is clicked. */
|
|
17
|
-
onDelete?: (ev
|
|
17
|
+
onDelete?: (ev?: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
18
18
|
/** Sets the type of pill in use. */
|
|
19
19
|
pillRole?: "tag" | "status";
|
|
20
20
|
/** Sets custom aria-label attribute on the remove button */
|
|
21
21
|
ariaLabelOfRemoveButton?: string;
|
|
22
|
+
/** @private @ignore title attribute passed down to underlying element */
|
|
23
|
+
title?: string;
|
|
22
24
|
}
|
|
23
25
|
export declare const Pill: ({ wrapText, borderColor, colorVariant, children, fill, maxWidth, onClick, onDelete, pillRole, size, ariaLabelOfRemoveButton, ...rest }: PillProps) => JSX.Element;
|
|
24
26
|
export default Pill;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare type SelectListContextProps = {
|
|
3
|
+
currentOptionsListIndex?: number;
|
|
4
|
+
multiselectValues?: (string | Record<string, unknown>)[];
|
|
5
|
+
};
|
|
6
|
+
declare const SelectListContext: React.Context<SelectListContextProps>;
|
|
7
|
+
export default SelectListContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _selectText.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _selectText = _interopRequireDefault(require("./select-text.component"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface SelectTextProps {
|
|
3
|
+
/** If true the Component will be disabled */
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
/** Value to be displayed */
|
|
6
|
+
formattedValue?: string;
|
|
7
|
+
/** Label id passed from Select component */
|
|
8
|
+
labelId?: string;
|
|
9
|
+
/** If true, the list is displayed */
|
|
10
|
+
isOpen?: boolean;
|
|
11
|
+
/** Callback function for when the Select Textbox loses it's focus. */
|
|
12
|
+
onBlur?: (ev: React.FocusEvent<HTMLElement>) => void;
|
|
13
|
+
/** Callback function for when the component is clicked. */
|
|
14
|
+
onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
15
|
+
/** Callback function for when the Select Textbox is focused. */
|
|
16
|
+
onFocus?: (ev: React.FocusEvent<HTMLElement>) => void;
|
|
17
|
+
/** Callback function for when the key is pressed when focused on Select Text. */
|
|
18
|
+
onKeyDown?: (ev: React.KeyboardEvent<HTMLElement>) => void;
|
|
19
|
+
/** Callback function for when the left mouse key is pressed when focused on Select Text. */
|
|
20
|
+
onMouseDown?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
21
|
+
/** Placeholder string to be displayed when formattedValue is empty */
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
/** If true the Component will be read-only */
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
/** If true the component has no border and a transparent background */
|
|
26
|
+
transparent?: boolean;
|
|
27
|
+
/** Id of the Select Text element */
|
|
28
|
+
textId?: string;
|
|
29
|
+
/** Component size */
|
|
30
|
+
size?: "small" | "medium" | "large";
|
|
31
|
+
}
|
|
32
|
+
declare const SelectText: ({ disabled, formattedValue, onClick, onKeyDown, onMouseDown, placeholder, readOnly, textId, transparent, size, }: SelectTextProps) => JSX.Element;
|
|
33
|
+
export default SelectText;
|
|
@@ -26,58 +26,38 @@ const SelectText = ({
|
|
|
26
26
|
size = "medium"
|
|
27
27
|
}) => {
|
|
28
28
|
const hasPlaceholder = !disabled && !readOnly && !formattedValue;
|
|
29
|
-
|
|
30
|
-
function handleClick(event) {
|
|
31
|
-
onClick(event);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
29
|
return /*#__PURE__*/_react.default.createElement(_selectText.default, {
|
|
35
30
|
"aria-hidden": true,
|
|
36
31
|
"data-element": "select-text",
|
|
37
32
|
disabled: disabled,
|
|
38
33
|
hasPlaceholder: hasPlaceholder,
|
|
39
34
|
id: textId,
|
|
40
|
-
onClick:
|
|
35
|
+
onClick: onClick,
|
|
41
36
|
onKeyDown: onKeyDown,
|
|
42
37
|
onMouseDown: onMouseDown,
|
|
43
38
|
readOnly: readOnly,
|
|
44
39
|
role: "button",
|
|
45
|
-
tabIndex:
|
|
40
|
+
tabIndex: -1,
|
|
46
41
|
transparent: transparent,
|
|
47
42
|
size: size
|
|
48
43
|
}, hasPlaceholder ? placeholder : formattedValue);
|
|
49
44
|
};
|
|
50
45
|
|
|
51
46
|
SelectText.propTypes = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/** Placeholder string to be displayed when formattedValue is empty */
|
|
68
|
-
placeholder: _propTypes.default.string,
|
|
69
|
-
|
|
70
|
-
/** If true the Component will be read-only */
|
|
71
|
-
readOnly: _propTypes.default.bool,
|
|
72
|
-
|
|
73
|
-
/** If true the component has no border and a transparent background */
|
|
74
|
-
transparent: _propTypes.default.bool,
|
|
75
|
-
|
|
76
|
-
/** Id of the Select Text element */
|
|
77
|
-
textId: _propTypes.default.string,
|
|
78
|
-
|
|
79
|
-
/** Component size */
|
|
80
|
-
size: _propTypes.default.string
|
|
47
|
+
"disabled": _propTypes.default.bool,
|
|
48
|
+
"formattedValue": _propTypes.default.string,
|
|
49
|
+
"isOpen": _propTypes.default.bool,
|
|
50
|
+
"labelId": _propTypes.default.string,
|
|
51
|
+
"onBlur": _propTypes.default.func,
|
|
52
|
+
"onClick": _propTypes.default.func,
|
|
53
|
+
"onFocus": _propTypes.default.func,
|
|
54
|
+
"onKeyDown": _propTypes.default.func,
|
|
55
|
+
"onMouseDown": _propTypes.default.func,
|
|
56
|
+
"placeholder": _propTypes.default.string,
|
|
57
|
+
"readOnly": _propTypes.default.bool,
|
|
58
|
+
"size": _propTypes.default.oneOf(["large", "medium", "small"]),
|
|
59
|
+
"textId": _propTypes.default.string,
|
|
60
|
+
"transparent": _propTypes.default.bool
|
|
81
61
|
};
|
|
82
62
|
var _default = SelectText;
|
|
83
63
|
exports.default = _default;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
import { SelectTextProps } from ".";
|
|
2
|
+
interface StyledSelectTextProps extends Pick<SelectTextProps, "disabled" | "readOnly" | "transparent"> {
|
|
3
|
+
hasPlaceholder: boolean;
|
|
4
|
+
size: NonNullable<SelectTextProps["size"]>;
|
|
5
|
+
}
|
|
6
|
+
declare const StyledSelectText: import("styled-components").StyledComponent<"span", any, StyledSelectTextProps, never>;
|
|
1
7
|
export default StyledSelectText;
|
|
2
|
-
declare const StyledSelectText: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Side } from "@floating-ui/dom";
|
|
3
|
+
import { ButtonProps } from "../../button";
|
|
4
|
+
import { FormInputPropTypes } from "../select-textbox";
|
|
5
|
+
export interface FilterableSelectProps extends Omit<FormInputPropTypes, "defaultValue" | "value"> {
|
|
6
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
7
|
+
"aria-label"?: string;
|
|
8
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
9
|
+
"aria-labelledby"?: string;
|
|
10
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
11
|
+
"data-component"?: string;
|
|
12
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
13
|
+
"data-element"?: string;
|
|
14
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
15
|
+
"data-role"?: string;
|
|
16
|
+
/** Child components (such as Option or OptionRow) for the SelectList */
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
/** The default selected value(s), when the component is operating in uncontrolled mode */
|
|
19
|
+
defaultValue?: string | Record<string, unknown>;
|
|
20
|
+
/** Boolean to toggle where SelectList is rendered in relation to the Select Input */
|
|
21
|
+
disablePortal?: boolean;
|
|
22
|
+
/** If true the loader animation is displayed in the option list */
|
|
23
|
+
isLoading?: boolean;
|
|
24
|
+
/** True for default text button or a Button Component to be rendered */
|
|
25
|
+
listActionButton?: boolean | React.ReactElement<ButtonProps>;
|
|
26
|
+
/** When true component will work in multi column mode.
|
|
27
|
+
* Children should consist of OptionRow components in this mode
|
|
28
|
+
*/
|
|
29
|
+
multiColumn?: boolean;
|
|
30
|
+
/** A custom message to be displayed when any option does not match the filter text */
|
|
31
|
+
noResultsMessage?: string;
|
|
32
|
+
/** A custom callback for when the input text changes */
|
|
33
|
+
onFilterChange?: (filterText: string) => void;
|
|
34
|
+
/** A custom callback for when the dropdown menu opens */
|
|
35
|
+
onOpen?: () => void;
|
|
36
|
+
/** A callback for when the Action Button is triggered */
|
|
37
|
+
onListAction?: () => void;
|
|
38
|
+
/** A callback that is triggered when a user scrolls to the bottom of the list */
|
|
39
|
+
onListScrollBottom?: () => void;
|
|
40
|
+
/** If true the Component opens on focus */
|
|
41
|
+
openOnFocus?: boolean;
|
|
42
|
+
/** SelectList table header, should consist of multiple th elements.
|
|
43
|
+
* Works only in multiColumn mode
|
|
44
|
+
*/
|
|
45
|
+
tableHeader?: React.ReactNode;
|
|
46
|
+
/** The selected value(s), when the component is operating in controlled mode */
|
|
47
|
+
value?: string | Record<string, unknown>;
|
|
48
|
+
/** Overrides the default tooltip position */
|
|
49
|
+
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
50
|
+
/** Maximum list height - defaults to 180 */
|
|
51
|
+
listMaxHeight?: number;
|
|
52
|
+
/** Placement of the select list in relation to the input element */
|
|
53
|
+
listPlacement?: Side;
|
|
54
|
+
/** Use the opposite list placement if the set placement does not fit */
|
|
55
|
+
flipEnabled?: boolean;
|
|
56
|
+
/** Set this prop to enable a virtualised list of options. If it is not used then all options will be in the
|
|
57
|
+
* DOM at all times, which may cause performance problems on very large lists */
|
|
58
|
+
enableVirtualScroll?: boolean;
|
|
59
|
+
/** The number of options to render into the DOM at once, either side of the currently-visible ones.
|
|
60
|
+
* Higher values make for smoother scrolling but may impact performance.
|
|
61
|
+
* Only used if the `enableVirtualScroll` prop is set. */
|
|
62
|
+
virtualScrollOverscan?: number;
|
|
63
|
+
}
|
|
64
|
+
export declare const FilterableSelect: React.ForwardRefExoticComponent<FilterableSelectProps & React.RefAttributes<unknown>>;
|
|
65
|
+
export default FilterableSelect;
|