@dxc-technology/halstack-react 0.0.0-9bd9511 → 0.0.0-9c20370
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/BackgroundColorContext.d.ts +3 -3
- package/BackgroundColorContext.js +12 -2
- package/HalstackContext.d.ts +1330 -7
- package/HalstackContext.js +84 -67
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +74 -55
- package/accordion/Accordion.stories.tsx +3 -101
- package/accordion/Accordion.test.js +34 -19
- package/accordion/types.d.ts +4 -16
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +49 -42
- package/accordion-group/AccordionGroup.stories.tsx +77 -76
- package/accordion-group/AccordionGroup.test.js +62 -54
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +6 -18
- package/alert/Alert.js +47 -20
- package/alert/Alert.test.js +46 -29
- package/alert/types.d.ts +3 -3
- package/badge/Badge.js +14 -2
- package/badge/types.d.ts +1 -1
- package/bleed/Bleed.js +21 -13
- package/bleed/Bleed.stories.tsx +1 -0
- package/bleed/types.d.ts +2 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +33 -33
- package/box/Box.stories.tsx +25 -53
- package/box/Box.test.js +7 -2
- package/box/types.d.ts +3 -15
- package/bulleted-list/BulletedList.js +36 -9
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +32 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +83 -71
- package/button/Button.stories.tsx +4 -4
- package/button/Button.test.js +28 -8
- package/button/types.d.ts +8 -4
- package/card/Card.d.ts +1 -1
- package/card/Card.js +67 -62
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +22 -11
- package/card/types.d.ts +4 -10
- package/checkbox/Checkbox.js +71 -27
- package/checkbox/Checkbox.test.js +60 -33
- package/checkbox/types.d.ts +4 -4
- package/chip/Chip.js +51 -48
- package/chip/Chip.stories.tsx +25 -17
- package/chip/Chip.test.js +29 -17
- package/chip/types.d.ts +4 -4
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +8 -3
- package/common/variables.d.ts +226 -175
- package/common/variables.js +956 -1133
- package/date-input/Calendar.js +55 -12
- package/date-input/DateInput.js +82 -35
- package/date-input/DateInput.test.js +351 -164
- package/date-input/DatePicker.js +38 -8
- package/date-input/Icons.js +12 -0
- package/date-input/YearPicker.js +30 -5
- package/date-input/types.d.ts +7 -7
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +83 -86
- package/dialog/Dialog.stories.tsx +127 -221
- package/dialog/Dialog.test.js +331 -18
- package/dialog/types.d.ts +1 -14
- package/dropdown/Dropdown.js +86 -32
- package/dropdown/Dropdown.test.js +211 -104
- package/dropdown/DropdownMenu.js +22 -8
- package/dropdown/DropdownMenuItem.js +15 -6
- package/dropdown/types.d.ts +8 -8
- package/file-input/FileInput.js +218 -134
- package/file-input/FileInput.test.js +343 -331
- package/file-input/FileItem.js +39 -12
- package/file-input/types.d.ts +10 -10
- package/flex/Flex.js +39 -25
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +74 -9
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +80 -68
- package/footer/Footer.stories.tsx +12 -89
- package/footer/Footer.test.js +47 -40
- package/footer/Icons.js +4 -0
- package/footer/types.d.ts +15 -17
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +72 -55
- package/header/Header.stories.tsx +7 -71
- package/header/Header.test.js +26 -13
- package/header/Icons.js +4 -0
- package/header/types.d.ts +2 -16
- package/heading/Heading.js +28 -7
- package/heading/Heading.test.js +88 -71
- package/heading/types.d.ts +3 -3
- package/inset/Inset.js +21 -13
- package/inset/Inset.stories.tsx +2 -1
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +5 -5
- package/layout/ApplicationLayout.js +57 -15
- package/layout/Icons.js +10 -0
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +4 -0
- package/layout/types.d.ts +5 -6
- package/link/Link.js +41 -21
- package/link/Link.test.js +42 -26
- package/link/types.d.ts +4 -4
- package/main.d.ts +2 -1
- package/main.js +55 -0
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +43 -16
- package/nav-tabs/NavTabs.stories.tsx +14 -0
- package/nav-tabs/NavTabs.test.js +44 -37
- package/nav-tabs/Tab.js +71 -45
- package/nav-tabs/types.d.ts +10 -11
- package/number-input/NumberInput.js +30 -20
- package/number-input/NumberInput.test.js +249 -113
- package/number-input/NumberInputContext.js +5 -0
- package/number-input/numberInputContextTypes.d.ts +1 -1
- package/number-input/types.d.ts +4 -4
- package/package.json +7 -7
- package/paginator/Icons.js +10 -0
- package/paginator/Paginator.js +39 -17
- package/paginator/Paginator.test.js +156 -104
- package/paginator/types.d.ts +1 -1
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +18 -8
- package/password-input/PasswordInput.js +51 -22
- package/password-input/PasswordInput.test.js +94 -51
- package/password-input/types.d.ts +4 -4
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +39 -14
- package/progress-bar/ProgressBar.test.js +53 -36
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +24 -2
- package/quick-nav/types.d.ts +2 -2
- package/radio-group/Radio.js +53 -22
- package/radio-group/RadioGroup.js +84 -41
- package/radio-group/RadioGroup.test.js +288 -186
- package/radio-group/types.d.ts +4 -4
- package/resultsetTable/Icons.js +3 -0
- package/resultsetTable/ResultsetTable.js +56 -21
- package/resultsetTable/ResultsetTable.test.js +75 -42
- package/resultsetTable/types.d.ts +5 -5
- package/select/Icons.js +3 -0
- package/select/Listbox.js +35 -10
- package/select/Option.js +24 -8
- package/select/Select.js +143 -56
- package/select/Select.test.js +839 -456
- package/select/types.d.ts +12 -12
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +116 -104
- package/sidenav/Sidenav.stories.tsx +60 -60
- package/sidenav/Sidenav.test.js +10 -3
- package/sidenav/types.d.ts +26 -23
- package/slider/Slider.js +84 -38
- package/slider/Slider.test.js +104 -76
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +51 -28
- package/spinner/Spinner.stories.jsx +28 -28
- package/spinner/Spinner.test.js +35 -26
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.js +66 -24
- package/switch/Switch.test.js +97 -52
- package/switch/types.d.ts +4 -4
- package/table/Table.js +22 -4
- package/table/Table.test.js +7 -2
- package/table/types.d.ts +3 -3
- package/tabs/Tab.js +39 -22
- package/tabs/Tabs.js +131 -62
- package/tabs/Tabs.test.js +122 -67
- package/tabs/types.d.ts +8 -8
- package/tag/Tag.js +54 -27
- package/tag/Tag.test.js +31 -20
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.js +3 -0
- package/text-input/Suggestion.js +24 -8
- package/text-input/Suggestions.js +36 -11
- package/text-input/TextInput.js +144 -59
- package/text-input/TextInput.stories.tsx +1 -1
- package/text-input/TextInput.test.js +858 -539
- package/text-input/types.d.ts +9 -9
- package/textarea/Textarea.js +73 -38
- package/textarea/Textarea.test.js +173 -98
- package/textarea/types.d.ts +4 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +59 -21
- package/toggle-group/ToggleGroup.test.js +72 -40
- package/toggle-group/types.d.ts +11 -11
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +23 -110
- package/typography/Typography.stories.tsx +1 -1
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +6 -0
- package/useTranslatedLabels.d.ts +84 -2
- package/useTranslatedLabels.js +5 -0
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +47 -13
- package/wizard/Wizard.test.js +81 -54
- package/wizard/types.d.ts +7 -8
- package/card/ice-cream.jpg +0 -0
- package/translatedLabelsType.d.ts +0 -82
- /package/{translatedLabelsType.js → grid/types.js} +0 -0
package/tag/Tag.test.js
CHANGED
|
@@ -1,49 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
5
7
|
var _react2 = require("@testing-library/react");
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
var _Tag = _interopRequireDefault(require("./Tag.tsx"));
|
|
10
|
+
|
|
7
11
|
describe("Tag component tests", function () {
|
|
8
12
|
test("Tag renders with correct label", function () {
|
|
9
13
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
label: "tag-test"
|
|
15
|
+
})),
|
|
16
|
+
getByText = _render.getByText;
|
|
17
|
+
|
|
13
18
|
expect(getByText("tag-test")).toBeTruthy();
|
|
14
19
|
});
|
|
15
20
|
test("Tag renders with correct label before", function () {
|
|
16
21
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
label: "tag-test",
|
|
23
|
+
labelPosition: "before"
|
|
24
|
+
})),
|
|
25
|
+
getByText = _render2.getByText;
|
|
26
|
+
|
|
21
27
|
expect(getByText("tag-test")).toBeTruthy();
|
|
22
28
|
});
|
|
23
29
|
test("Tag renders with correct icon", function () {
|
|
24
30
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
label: "tag-test",
|
|
32
|
+
icon: "/test-icon.jpg"
|
|
33
|
+
})),
|
|
34
|
+
getByRole = _render3.getByRole;
|
|
35
|
+
|
|
29
36
|
expect(getByRole("img").getAttribute("src")).toBe("/test-icon.jpg");
|
|
30
37
|
});
|
|
31
38
|
test("Tag renders with link href", function () {
|
|
32
39
|
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
label: "tag-test",
|
|
41
|
+
linkHref: "/test/page"
|
|
42
|
+
})),
|
|
43
|
+
getByRole = _render4.getByRole;
|
|
44
|
+
|
|
37
45
|
expect(getByRole("link").getAttribute("href")).toBe("/test/page");
|
|
38
46
|
});
|
|
39
47
|
test("Call correct function on click", function () {
|
|
40
48
|
var onClick = jest.fn();
|
|
49
|
+
|
|
41
50
|
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
label: "tag-test",
|
|
52
|
+
onClick: onClick
|
|
53
|
+
})),
|
|
54
|
+
getByText = _render5.getByText;
|
|
55
|
+
|
|
46
56
|
_react2.fireEvent.click(getByText("tag-test"));
|
|
57
|
+
|
|
47
58
|
expect(onClick).toHaveBeenCalled();
|
|
48
59
|
});
|
|
49
60
|
});
|
package/tag/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
-
type Margin = {
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
-
type TagCommonProps = {
|
|
9
|
+
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
+
declare type TagCommonProps = {
|
|
11
11
|
/**
|
|
12
12
|
* If defined, the tag will be displayed as an anchor, using this prop as "href".
|
|
13
13
|
* Component will show some visual feedback on hover.
|
|
@@ -45,7 +45,7 @@ type TagCommonProps = {
|
|
|
45
45
|
*/
|
|
46
46
|
tabIndex?: number;
|
|
47
47
|
};
|
|
48
|
-
type TagLabelProps = TagCommonProps & {
|
|
48
|
+
declare type TagLabelProps = TagCommonProps & {
|
|
49
49
|
/**
|
|
50
50
|
* Element or path used as the icon that will be placed next to the label.
|
|
51
51
|
*/
|
|
@@ -55,7 +55,7 @@ type TagLabelProps = TagCommonProps & {
|
|
|
55
55
|
*/
|
|
56
56
|
label: string;
|
|
57
57
|
};
|
|
58
|
-
type TagIconProps = TagCommonProps & {
|
|
58
|
+
declare type TagIconProps = TagCommonProps & {
|
|
59
59
|
/**
|
|
60
60
|
* Element or path used as the icon that will be placed next to the label.
|
|
61
61
|
*/
|
|
@@ -65,5 +65,5 @@ type TagIconProps = TagCommonProps & {
|
|
|
65
65
|
*/
|
|
66
66
|
label?: string;
|
|
67
67
|
};
|
|
68
|
-
type Props = TagLabelProps | TagIconProps;
|
|
68
|
+
declare type Props = TagLabelProps | TagIconProps;
|
|
69
69
|
export default Props;
|
package/text-input/Icons.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
9
12
|
var icons = {
|
|
10
13
|
error: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
11
14
|
xmlns: "http://www.w3.org/2000/svg",
|
package/text-input/Suggestion.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = void 0;
|
|
11
|
+
|
|
9
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
10
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
11
16
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
|
+
|
|
12
18
|
var _templateObject, _templateObject2;
|
|
19
|
+
|
|
13
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
14
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
23
|
+
|
|
15
24
|
var transformSpecialChars = function transformSpecialChars(str) {
|
|
16
25
|
var specialCharsRegex = /[\\*()\[\]{}+?/]/;
|
|
17
26
|
var value = str;
|
|
27
|
+
|
|
18
28
|
if (specialCharsRegex.test(value)) {
|
|
19
29
|
var regexAsString = specialCharsRegex.toString().split("");
|
|
20
30
|
var uniqueSpecialChars = regexAsString.filter(function (item, index) {
|
|
@@ -24,16 +34,18 @@ var transformSpecialChars = function transformSpecialChars(str) {
|
|
|
24
34
|
if (str.includes(specialChar)) value = value.replace(specialChar, "\\" + specialChar);
|
|
25
35
|
});
|
|
26
36
|
}
|
|
37
|
+
|
|
27
38
|
return value;
|
|
28
39
|
};
|
|
40
|
+
|
|
29
41
|
var Suggestion = function Suggestion(_ref) {
|
|
30
42
|
var id = _ref.id,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
value = _ref.value,
|
|
44
|
+
_onClick = _ref.onClick,
|
|
45
|
+
suggestion = _ref.suggestion,
|
|
46
|
+
isLast = _ref.isLast,
|
|
47
|
+
visuallyFocused = _ref.visuallyFocused,
|
|
48
|
+
highlighted = _ref.highlighted;
|
|
37
49
|
var matchedSuggestion = (0, _react.useMemo)(function () {
|
|
38
50
|
var regEx = new RegExp(transformSpecialChars(value), "i");
|
|
39
51
|
return {
|
|
@@ -50,10 +62,11 @@ var Suggestion = function Suggestion(_ref) {
|
|
|
50
62
|
role: "option",
|
|
51
63
|
"aria-selected": visuallyFocused ? true : undefined
|
|
52
64
|
}, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
|
|
53
|
-
|
|
65
|
+
isLast: isLast,
|
|
54
66
|
visuallyFocused: visuallyFocused
|
|
55
67
|
}, highlighted ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedSuggestion.matchedWords), matchedSuggestion.noMatchedWords) : suggestion));
|
|
56
68
|
};
|
|
69
|
+
|
|
57
70
|
var SuggestionContainer = _styledComponents["default"].li(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0 0.5rem;\n line-height: 1.715em;\n cursor: pointer;\n box-shadow: inset 0 0 0 2px\n ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
58
71
|
return props.visuallyFocused ? props.theme.focusListOptionBorderColor : "transparent";
|
|
59
72
|
}, function (props) {
|
|
@@ -61,8 +74,11 @@ var SuggestionContainer = _styledComponents["default"].li(_templateObject || (_t
|
|
|
61
74
|
}, function (props) {
|
|
62
75
|
return props.theme.activeListOptionBackgroundColor;
|
|
63
76
|
});
|
|
77
|
+
|
|
64
78
|
var StyledSuggestion = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n padding: 0.25rem 0.5rem 0.188rem 0.5rem;\n ", ";\n"])), function (props) {
|
|
65
|
-
return props.
|
|
79
|
+
return props.isLast || props.visuallyFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
66
80
|
});
|
|
81
|
+
|
|
67
82
|
var _default = /*#__PURE__*/_react["default"].memo(Suggestion);
|
|
83
|
+
|
|
68
84
|
exports["default"] = _default;
|
|
@@ -1,52 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = void 0;
|
|
11
|
+
|
|
9
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
10
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
11
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
12
18
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
|
+
|
|
13
20
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
21
|
+
|
|
14
22
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
23
|
+
|
|
15
24
|
var _Suggestion = _interopRequireDefault(require("./Suggestion"));
|
|
25
|
+
|
|
16
26
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
27
|
+
|
|
17
28
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
29
|
+
|
|
18
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
19
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
33
|
+
|
|
20
34
|
var Suggestions = function Suggestions(_ref) {
|
|
21
35
|
var id = _ref.id,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
value = _ref.value,
|
|
37
|
+
suggestions = _ref.suggestions,
|
|
38
|
+
visualFocusIndex = _ref.visualFocusIndex,
|
|
39
|
+
highlightedSuggestions = _ref.highlightedSuggestions,
|
|
40
|
+
searchHasErrors = _ref.searchHasErrors,
|
|
41
|
+
isSearching = _ref.isSearching,
|
|
42
|
+
suggestionOnClick = _ref.suggestionOnClick,
|
|
43
|
+
getTextInputWidth = _ref.getTextInputWidth;
|
|
30
44
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
31
45
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
32
46
|
var listboxRef = (0, _react.useRef)(null);
|
|
47
|
+
|
|
33
48
|
var _useState = (0, _react.useState)(null),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
50
|
+
styles = _useState2[0],
|
|
51
|
+
setStyles = _useState2[1];
|
|
52
|
+
|
|
37
53
|
(0, _react.useLayoutEffect)(function () {
|
|
38
54
|
var _listboxRef$current, _visualFocusedOptionE;
|
|
55
|
+
|
|
39
56
|
var visualFocusedOptionEl = listboxRef === null || listboxRef === void 0 ? void 0 : (_listboxRef$current = listboxRef.current) === null || _listboxRef$current === void 0 ? void 0 : _listboxRef$current.querySelectorAll("[role='option']")[visualFocusIndex];
|
|
40
57
|
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
|
|
41
58
|
block: "nearest",
|
|
42
59
|
inline: "start"
|
|
43
60
|
});
|
|
44
61
|
}, [visualFocusIndex]);
|
|
62
|
+
|
|
45
63
|
var handleResize = function handleResize() {
|
|
46
64
|
setStyles({
|
|
47
65
|
width: getTextInputWidth()
|
|
48
66
|
});
|
|
49
67
|
};
|
|
68
|
+
|
|
50
69
|
(0, _react.useLayoutEffect)(function () {
|
|
51
70
|
handleResize();
|
|
52
71
|
}, [getTextInputWidth]);
|
|
@@ -81,6 +100,7 @@ var Suggestions = function Suggestions(_ref) {
|
|
|
81
100
|
backgroundType: backgroundType
|
|
82
101
|
}, _Icons["default"].error), translatedLabels.textInput.fetchingDataErrorMessage));
|
|
83
102
|
};
|
|
103
|
+
|
|
84
104
|
var SuggestionsContainer = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n max-height: 304px;\n overflow-y: auto;\n margin: 0;\n padding: 0.25rem 0;\n background-color: ", ";\n border: 1px solid\n ", ";\n\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
85
105
|
return props.error ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
|
|
86
106
|
}, function (props) {
|
|
@@ -96,14 +116,19 @@ var SuggestionsContainer = _styledComponents["default"].ul(_templateObject || (_
|
|
|
96
116
|
}, function (props) {
|
|
97
117
|
return props.theme.listOptionFontWeight;
|
|
98
118
|
});
|
|
119
|
+
|
|
99
120
|
var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n color: ", ";\n line-height: 1.715em;\n"])), function (props) {
|
|
100
121
|
return props.theme.systemMessageFontColor;
|
|
101
122
|
});
|
|
123
|
+
|
|
102
124
|
var SuggestionsErrorIcon = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n margin-right: 0.5rem;\n height: 18px;\n width: 18px;\n color: ", ";\n"])), function (props) {
|
|
103
125
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
104
126
|
});
|
|
127
|
+
|
|
105
128
|
var SuggestionsError = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n align-items: center;\n line-height: 1.715em;\n color: ", ";\n"])), function (props) {
|
|
106
129
|
return props.theme.errorListDialogFontColor;
|
|
107
130
|
});
|
|
131
|
+
|
|
108
132
|
var _default = /*#__PURE__*/_react["default"].memo(Suggestions);
|
|
133
|
+
|
|
109
134
|
exports["default"] = _default;
|