@dxc-technology/halstack-react 10.1.0 → 11.0.0
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 +2 -2
- package/BackgroundColorContext.js +5 -17
- package/HalstackContext.d.ts +18 -6
- package/HalstackContext.js +9 -34
- package/accordion/Accordion.js +21 -58
- package/accordion/Accordion.stories.tsx +1 -15
- package/accordion/Accordion.test.js +18 -33
- package/accordion/types.d.ts +5 -5
- package/accordion-group/AccordionGroup.js +15 -42
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +42 -60
- package/accordion-group/AccordionGroupAccordion.js +9 -21
- package/accordion-group/types.d.ts +6 -6
- package/alert/Alert.js +14 -46
- package/alert/Alert.test.js +28 -45
- package/alert/types.d.ts +5 -5
- package/badge/Badge.js +4 -17
- package/badge/types.d.ts +1 -1
- package/bleed/Bleed.js +13 -21
- package/bleed/types.d.ts +2 -2
- package/box/Box.js +10 -29
- package/box/Box.test.js +1 -6
- package/box/types.d.ts +3 -3
- package/bulleted-list/BulletedList.js +7 -33
- package/bulleted-list/BulletedList.stories.tsx +1 -91
- package/bulleted-list/types.d.ts +5 -5
- package/button/Button.js +23 -46
- package/button/Button.stories.tsx +5 -86
- package/button/Button.test.js +11 -21
- package/button/types.d.ts +4 -4
- package/card/Card.js +21 -44
- package/card/Card.test.js +10 -21
- package/card/types.d.ts +5 -5
- package/checkbox/Checkbox.js +81 -111
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +107 -63
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.js +12 -31
- package/chip/Chip.test.js +15 -28
- package/chip/types.d.ts +4 -4
- package/common/coreTokens.js +1 -2
- package/common/utils.js +2 -8
- package/common/variables.d.ts +15 -6
- package/common/variables.js +17 -15
- package/date-input/Calendar.js +13 -57
- package/date-input/DateInput.js +50 -96
- package/date-input/DateInput.stories.tsx +11 -30
- package/date-input/DateInput.test.js +674 -701
- package/date-input/DatePicker.js +11 -42
- package/date-input/Icons.d.ts +6 -6
- package/date-input/Icons.js +6 -23
- package/date-input/YearPicker.js +8 -34
- package/date-input/types.d.ts +27 -21
- package/dialog/Dialog.js +11 -35
- package/dialog/Dialog.test.js +125 -187
- package/dialog/types.d.ts +18 -13
- package/dropdown/Dropdown.js +39 -93
- package/dropdown/Dropdown.test.js +391 -378
- package/dropdown/DropdownMenu.js +8 -19
- package/dropdown/DropdownMenuItem.js +5 -17
- package/dropdown/types.d.ts +17 -19
- package/file-input/FileInput.js +131 -220
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +293 -342
- package/file-input/FileItem.js +12 -39
- package/file-input/types.d.ts +9 -9
- package/flex/Flex.js +25 -39
- package/flex/types.d.ts +6 -6
- package/footer/Footer.js +9 -39
- package/footer/Footer.test.js +18 -32
- package/footer/Icons.d.ts +2 -2
- package/footer/Icons.js +2 -7
- package/footer/types.d.ts +13 -13
- package/grid/Grid.js +1 -16
- package/grid/types.d.ts +10 -10
- package/header/Header.d.ts +1 -1
- package/header/Header.js +19 -64
- package/header/Header.test.js +12 -25
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +2 -7
- package/header/types.d.ts +5 -7
- package/heading/Heading.js +9 -31
- package/heading/Heading.test.js +70 -87
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +2 -2
- package/image/Image.js +17 -32
- package/image/types.d.ts +2 -2
- package/inset/Inset.js +13 -21
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +1 -1
- package/layout/ApplicationLayout.js +14 -54
- package/layout/Icons.d.ts +5 -5
- package/layout/Icons.js +1 -5
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +3 -9
- package/layout/types.d.ts +3 -3
- package/link/Link.js +21 -42
- package/link/Link.test.js +23 -41
- package/link/types.d.ts +14 -14
- package/main.d.ts +1 -1
- package/main.js +3 -52
- package/nav-tabs/NavTabs.js +11 -43
- package/nav-tabs/NavTabs.stories.tsx +1 -1
- package/nav-tabs/NavTabs.test.js +36 -43
- package/nav-tabs/Tab.js +16 -45
- package/nav-tabs/types.d.ts +9 -9
- package/number-input/NumberInput.d.ts +1 -1
- package/number-input/NumberInput.js +24 -35
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +682 -577
- package/number-input/types.d.ts +11 -5
- package/package.json +27 -25
- package/paginator/Icons.d.ts +5 -5
- package/paginator/Icons.js +5 -19
- package/paginator/Paginator.js +14 -39
- package/paginator/Paginator.test.js +224 -207
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.js +3 -14
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/Icons.d.ts +3 -3
- package/password-input/Icons.js +1 -5
- package/password-input/PasswordInput.js +26 -48
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +153 -129
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.js +16 -42
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +35 -52
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.js +4 -27
- package/quick-nav/QuickNav.stories.tsx +1 -1
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +22 -54
- package/radio-group/RadioGroup.js +37 -83
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +504 -470
- package/radio-group/types.d.ts +8 -8
- package/resultset-table/Icons.d.ts +7 -0
- package/{resultsetTable → resultset-table}/Icons.js +1 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.js +22 -58
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +72 -92
- package/{resultsetTable → resultset-table}/types.d.ts +7 -7
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.js +13 -39
- package/select/Option.js +9 -26
- package/select/Select.js +54 -138
- package/select/Select.test.js +1902 -1796
- package/select/types.d.ts +14 -15
- package/sidenav/Icons.d.ts +4 -4
- package/sidenav/Icons.js +1 -5
- package/sidenav/Sidenav.js +24 -63
- package/sidenav/Sidenav.test.js +3 -10
- package/sidenav/types.d.ts +18 -18
- package/slider/Slider.js +38 -86
- package/slider/Slider.test.js +107 -103
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +10 -40
- package/spinner/Spinner.test.js +25 -34
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.js +26 -69
- package/switch/Switch.stories.tsx +0 -34
- package/switch/Switch.test.js +51 -96
- package/switch/types.d.ts +4 -4
- package/table/Table.js +4 -23
- package/table/Table.test.js +1 -6
- package/table/types.d.ts +8 -8
- package/tabs/Tab.js +10 -29
- package/tabs/Tabs.js +48 -124
- package/tabs/Tabs.test.js +62 -118
- package/tabs/types.d.ts +19 -19
- package/tag/Tag.js +21 -51
- package/tag/Tag.test.js +19 -30
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +5 -5
- package/text-input/Icons.js +1 -5
- package/text-input/Suggestion.js +9 -26
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +12 -57
- package/text-input/TextInput.js +128 -193
- package/text-input/TextInput.stories.tsx +48 -152
- package/text-input/TextInput.test.js +1210 -1194
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.js +60 -96
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -99
- package/textarea/Textarea.test.js +150 -179
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.js +20 -57
- package/toggle-group/ToggleGroup.stories.tsx +1 -1
- package/toggle-group/ToggleGroup.test.js +48 -81
- package/toggle-group/types.d.ts +10 -10
- package/typography/Typography.js +4 -13
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +12 -3
- package/useTheme.js +1 -8
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +2 -2
- package/utils/BaseTypography.js +16 -30
- package/utils/FocusLock.js +12 -36
- package/wizard/Wizard.js +14 -49
- package/wizard/Wizard.test.js +53 -80
- package/wizard/types.d.ts +6 -6
- package/resultsetTable/Icons.d.ts +0 -7
- package/slider/Slider.stories.tsx +0 -240
- /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
- /package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +0 -0
- /package/{resultsetTable → resultset-table}/types.js +0 -0
- /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
- /package/table/{Table.stories.jsx → Table.stories.tsx} +0 -0
package/tag/Tag.test.js
CHANGED
|
@@ -1,60 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
6
|
var _Tag = _interopRequireDefault(require("./Tag.tsx"));
|
|
10
|
-
|
|
11
7
|
describe("Tag component tests", function () {
|
|
12
8
|
test("Tag renders with correct label", function () {
|
|
13
9
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
label: "tag-test"
|
|
11
|
+
})),
|
|
12
|
+
getByText = _render.getByText;
|
|
18
13
|
expect(getByText("tag-test")).toBeTruthy();
|
|
19
14
|
});
|
|
20
15
|
test("Tag renders with correct label before", function () {
|
|
21
16
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
label: "tag-test",
|
|
18
|
+
labelPosition: "before"
|
|
19
|
+
})),
|
|
20
|
+
getByText = _render2.getByText;
|
|
27
21
|
expect(getByText("tag-test")).toBeTruthy();
|
|
28
22
|
});
|
|
29
23
|
test("Tag renders with correct icon", function () {
|
|
30
24
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
label: "tag-test",
|
|
26
|
+
icon: "/test-icon.jpg"
|
|
27
|
+
})),
|
|
28
|
+
getByRole = _render3.getByRole;
|
|
36
29
|
expect(getByRole("img").getAttribute("src")).toBe("/test-icon.jpg");
|
|
37
30
|
});
|
|
38
31
|
test("Tag renders with link href", function () {
|
|
39
32
|
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
label: "tag-test",
|
|
34
|
+
linkHref: "/test/page"
|
|
35
|
+
})),
|
|
36
|
+
getByRole = _render4.getByRole;
|
|
45
37
|
expect(getByRole("link").getAttribute("href")).toBe("/test/page");
|
|
46
38
|
});
|
|
47
39
|
test("Call correct function on click", function () {
|
|
48
40
|
var onClick = jest.fn();
|
|
49
|
-
|
|
50
41
|
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
label: "tag-test",
|
|
43
|
+
onClick: onClick
|
|
44
|
+
})),
|
|
45
|
+
getByText = _render5.getByText;
|
|
56
46
|
_react2.fireEvent.click(getByText("tag-test"));
|
|
57
|
-
|
|
58
47
|
expect(onClick).toHaveBeenCalled();
|
|
59
48
|
});
|
|
60
49
|
});
|
package/tag/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
+
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 @@ declare type TagCommonProps = {
|
|
|
45
45
|
*/
|
|
46
46
|
tabIndex?: number;
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
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 @@ declare type TagLabelProps = TagCommonProps & {
|
|
|
55
55
|
*/
|
|
56
56
|
label: string;
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
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 @@ declare type TagIconProps = TagCommonProps & {
|
|
|
65
65
|
*/
|
|
66
66
|
label?: string;
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
type Props = TagLabelProps | TagIconProps;
|
|
69
69
|
export default Props;
|
package/text-input/Icons.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
declare const icons: {
|
|
3
|
-
error: JSX.Element;
|
|
4
|
-
clear: JSX.Element;
|
|
5
|
-
increment: JSX.Element;
|
|
6
|
-
decrement: JSX.Element;
|
|
3
|
+
error: React.JSX.Element;
|
|
4
|
+
clear: React.JSX.Element;
|
|
5
|
+
increment: React.JSX.Element;
|
|
6
|
+
decrement: React.JSX.Element;
|
|
7
7
|
};
|
|
8
8
|
export default icons;
|
package/text-input/Icons.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var icons = {
|
|
13
10
|
error: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
14
11
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -56,5 +53,4 @@ var icons = {
|
|
|
56
53
|
d: "M19 13H5v-2h14v2z"
|
|
57
54
|
}))
|
|
58
55
|
};
|
|
59
|
-
var _default = icons;
|
|
60
|
-
exports["default"] = _default;
|
|
56
|
+
var _default = exports["default"] = icons;
|
package/text-input/Suggestion.js
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
|
-
|
|
18
12
|
var _templateObject, _templateObject2;
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
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
|
-
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
24
15
|
var transformSpecialChars = function transformSpecialChars(str) {
|
|
25
16
|
var specialCharsRegex = /[\\*()\[\]{}+?/]/;
|
|
26
17
|
var value = str;
|
|
27
|
-
|
|
28
18
|
if (specialCharsRegex.test(value)) {
|
|
29
19
|
var regexAsString = specialCharsRegex.toString().split("");
|
|
30
20
|
var uniqueSpecialChars = regexAsString.filter(function (item, index) {
|
|
@@ -34,18 +24,16 @@ var transformSpecialChars = function transformSpecialChars(str) {
|
|
|
34
24
|
if (str.includes(specialChar)) value = value.replace(specialChar, "\\" + specialChar);
|
|
35
25
|
});
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
return value;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
var Suggestion = function Suggestion(_ref) {
|
|
42
30
|
var id = _ref.id,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
value = _ref.value,
|
|
32
|
+
_onClick = _ref.onClick,
|
|
33
|
+
suggestion = _ref.suggestion,
|
|
34
|
+
isLast = _ref.isLast,
|
|
35
|
+
visuallyFocused = _ref.visuallyFocused,
|
|
36
|
+
highlighted = _ref.highlighted;
|
|
49
37
|
var matchedSuggestion = (0, _react.useMemo)(function () {
|
|
50
38
|
var regEx = new RegExp(transformSpecialChars(value), "i");
|
|
51
39
|
return {
|
|
@@ -66,7 +54,6 @@ var Suggestion = function Suggestion(_ref) {
|
|
|
66
54
|
visuallyFocused: visuallyFocused
|
|
67
55
|
}, highlighted ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedSuggestion.matchedWords), matchedSuggestion.noMatchedWords) : suggestion));
|
|
68
56
|
};
|
|
69
|
-
|
|
70
57
|
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) {
|
|
71
58
|
return props.visuallyFocused ? props.theme.focusListOptionBorderColor : "transparent";
|
|
72
59
|
}, function (props) {
|
|
@@ -74,11 +61,7 @@ var SuggestionContainer = _styledComponents["default"].li(_templateObject || (_t
|
|
|
74
61
|
}, function (props) {
|
|
75
62
|
return props.theme.activeListOptionBackgroundColor;
|
|
76
63
|
});
|
|
77
|
-
|
|
78
64
|
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) {
|
|
79
65
|
return props.isLast || props.visuallyFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
80
66
|
});
|
|
81
|
-
|
|
82
|
-
var _default = /*#__PURE__*/_react["default"].memo(Suggestion);
|
|
83
|
-
|
|
84
|
-
exports["default"] = _default;
|
|
67
|
+
var _default = exports["default"] = /*#__PURE__*/_react["default"].memo(Suggestion);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SuggestionsProps } from "./types";
|
|
3
|
-
declare const _default: React.MemoExoticComponent<({ id, value, suggestions, visualFocusIndex, highlightedSuggestions, searchHasErrors, isSearching, suggestionOnClick,
|
|
3
|
+
declare const _default: React.MemoExoticComponent<({ id, value, suggestions, visualFocusIndex, highlightedSuggestions, searchHasErrors, isSearching, suggestionOnClick, styles, }: SuggestionsProps) => JSX.Element>;
|
|
4
4
|
export default _default;
|
|
@@ -1,80 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
11
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
|
-
|
|
20
12
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
21
|
-
|
|
22
13
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
23
|
-
|
|
24
14
|
var _Suggestion = _interopRequireDefault(require("./Suggestion"));
|
|
25
|
-
|
|
26
15
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
27
|
-
|
|
28
16
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
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
|
-
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
34
19
|
var Suggestions = function Suggestions(_ref) {
|
|
35
20
|
var id = _ref.id,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
value = _ref.value,
|
|
22
|
+
suggestions = _ref.suggestions,
|
|
23
|
+
visualFocusIndex = _ref.visualFocusIndex,
|
|
24
|
+
highlightedSuggestions = _ref.highlightedSuggestions,
|
|
25
|
+
searchHasErrors = _ref.searchHasErrors,
|
|
26
|
+
isSearching = _ref.isSearching,
|
|
27
|
+
suggestionOnClick = _ref.suggestionOnClick,
|
|
28
|
+
styles = _ref.styles;
|
|
44
29
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
45
30
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
46
31
|
var listboxRef = (0, _react.useRef)(null);
|
|
47
|
-
|
|
48
|
-
var _useState = (0, _react.useState)(null),
|
|
49
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
50
|
-
styles = _useState2[0],
|
|
51
|
-
setStyles = _useState2[1];
|
|
52
|
-
|
|
53
|
-
(0, _react.useLayoutEffect)(function () {
|
|
32
|
+
(0, _react.useEffect)(function () {
|
|
54
33
|
var _listboxRef$current, _visualFocusedOptionE;
|
|
55
|
-
|
|
56
34
|
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];
|
|
57
35
|
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
|
|
58
36
|
block: "nearest",
|
|
59
37
|
inline: "start"
|
|
60
38
|
});
|
|
61
39
|
}, [visualFocusIndex]);
|
|
62
|
-
|
|
63
|
-
var handleResize = function handleResize() {
|
|
64
|
-
setStyles({
|
|
65
|
-
width: getTextInputWidth()
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
(0, _react.useLayoutEffect)(function () {
|
|
70
|
-
handleResize();
|
|
71
|
-
}, [getTextInputWidth]);
|
|
72
|
-
(0, _react.useEffect)(function () {
|
|
73
|
-
window.addEventListener("resize", handleResize);
|
|
74
|
-
return function () {
|
|
75
|
-
window.removeEventListener("resize", handleResize);
|
|
76
|
-
};
|
|
77
|
-
}, [getTextInputWidth]);
|
|
78
40
|
return /*#__PURE__*/_react["default"].createElement(SuggestionsContainer, {
|
|
79
41
|
id: id,
|
|
80
42
|
error: searchHasErrors ? true : false,
|
|
@@ -100,7 +62,6 @@ var Suggestions = function Suggestions(_ref) {
|
|
|
100
62
|
backgroundType: backgroundType
|
|
101
63
|
}, _Icons["default"].error), translatedLabels.textInput.fetchingDataErrorMessage));
|
|
102
64
|
};
|
|
103
|
-
|
|
104
65
|
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) {
|
|
105
66
|
return props.error ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
|
|
106
67
|
}, function (props) {
|
|
@@ -116,19 +77,13 @@ var SuggestionsContainer = _styledComponents["default"].ul(_templateObject || (_
|
|
|
116
77
|
}, function (props) {
|
|
117
78
|
return props.theme.listOptionFontWeight;
|
|
118
79
|
});
|
|
119
|
-
|
|
120
80
|
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) {
|
|
121
81
|
return props.theme.systemMessageFontColor;
|
|
122
82
|
});
|
|
123
|
-
|
|
124
83
|
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) {
|
|
125
84
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
126
85
|
});
|
|
127
|
-
|
|
128
86
|
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) {
|
|
129
87
|
return props.theme.errorListDialogFontColor;
|
|
130
88
|
});
|
|
131
|
-
|
|
132
|
-
var _default = /*#__PURE__*/_react["default"].memo(Suggestions);
|
|
133
|
-
|
|
134
|
-
exports["default"] = _default;
|
|
89
|
+
var _default = exports["default"] = /*#__PURE__*/_react["default"].memo(Suggestions);
|