@dxc-technology/halstack-react 0.0.0-eca8a89 → 0.0.0-ecc45e2
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.js +0 -1
- package/HalstackContext.d.ts +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +13 -45
- package/accordion/Accordion.stories.tsx +20 -13
- package/accordion/Accordion.test.js +72 -0
- package/accordion/types.d.ts +7 -7
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +14 -15
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +151 -0
- package/accordion-group/types.d.ts +7 -7
- package/alert/Alert.js +4 -1
- package/alert/Alert.test.js +92 -0
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +5 -0
- package/{radio → badge}/types.js +0 -0
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +51 -0
- package/bleed/Bleed.stories.tsx +341 -0
- package/bleed/types.d.ts +37 -0
- package/bleed/types.js +5 -0
- package/box/Box.js +22 -32
- package/box/Box.test.js +18 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/bulleted-list/types.js +5 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +57 -80
- package/button/Button.stories.tsx +15 -8
- package/button/Button.test.js +35 -0
- package/button/types.d.ts +8 -12
- package/card/Card.js +24 -27
- package/card/Card.stories.tsx +1 -1
- package/card/Card.test.js +50 -0
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +43 -39
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +78 -0
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.d.ts +1 -1
- package/chip/Chip.js +16 -54
- package/chip/Chip.stories.tsx +6 -8
- package/chip/Chip.test.js +56 -0
- package/chip/types.d.ts +7 -15
- package/common/variables.js +267 -337
- package/date-input/DateInput.js +62 -48
- package/date-input/DateInput.stories.tsx +7 -7
- package/date-input/DateInput.test.js +479 -0
- package/date-input/types.d.ts +16 -9
- package/dialog/Dialog.js +48 -51
- package/dialog/Dialog.stories.tsx +1 -2
- package/dialog/Dialog.test.js +70 -0
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +242 -272
- package/dropdown/Dropdown.stories.tsx +312 -0
- package/dropdown/Dropdown.test.js +591 -0
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +29 -18
- package/file-input/FileInput.js +111 -39
- package/file-input/FileInput.stories.tsx +507 -0
- package/file-input/FileInput.test.js +457 -0
- package/file-input/FileItem.js +7 -5
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +21 -0
- package/flex/types.js +5 -0
- package/footer/Footer.js +24 -99
- package/footer/Footer.test.js +109 -0
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +1 -1
- package/header/Header.js +95 -114
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +79 -0
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -2
- package/heading/Heading.stories.tsx +3 -2
- package/heading/Heading.test.js +186 -0
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +51 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +37 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +71 -125
- package/layout/ApplicationLayout.stories.tsx +83 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +60 -85
- package/link/Link.stories.tsx +99 -52
- package/link/Link.test.js +83 -0
- package/link/types.d.ts +9 -29
- package/main.d.ts +11 -15
- package/main.js +53 -79
- package/number-input/NumberInput.js +11 -18
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +506 -0
- package/number-input/types.d.ts +17 -10
- package/package.json +14 -10
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +308 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.stories.tsx +3 -3
- package/password-input/PasswordInput.test.js +180 -0
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +57 -51
- package/progress-bar/ProgressBar.stories.jsx +13 -11
- package/progress-bar/ProgressBar.test.js +110 -0
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +118 -0
- package/quick-nav/QuickNav.stories.tsx +264 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +141 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +281 -0
- package/radio-group/RadioGroup.stories.tsx +100 -0
- package/radio-group/RadioGroup.test.js +695 -0
- package/radio-group/types.d.ts +114 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/ResultsetTable.js +5 -2
- package/resultsetTable/ResultsetTable.stories.tsx +7 -8
- package/resultsetTable/ResultsetTable.test.js +348 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +199 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +146 -366
- package/select/Select.stories.tsx +231 -176
- package/select/Select.test.js +2175 -0
- package/select/types.d.ts +210 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +184 -52
- package/sidenav/Sidenav.stories.tsx +154 -139
- package/sidenav/Sidenav.test.js +44 -0
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +5 -4
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +187 -0
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +1 -1
- package/spinner/Spinner.stories.jsx +1 -0
- package/spinner/Spinner.test.js +64 -0
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +127 -55
- package/switch/Switch.stories.tsx +21 -43
- package/switch/Switch.test.js +212 -0
- package/switch/types.d.ts +9 -6
- package/table/Table.stories.jsx +2 -1
- package/table/Table.test.js +26 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +16 -18
- package/tabs/Tabs.stories.tsx +7 -16
- package/tabs/Tabs.test.js +140 -0
- package/tabs/types.d.ts +27 -15
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +130 -0
- package/tabs-nav/types.d.ts +53 -0
- package/tabs-nav/types.js +5 -0
- package/tag/Tag.d.ts +1 -1
- package/tag/Tag.js +17 -27
- package/tag/Tag.stories.tsx +26 -29
- package/tag/Tag.test.js +60 -0
- package/tag/types.d.ts +23 -14
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.js +80 -105
- package/text-input/TextInput.stories.tsx +35 -18
- package/text-input/TextInput.test.js +1712 -0
- package/text-input/types.d.ts +32 -13
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +19 -56
- package/textarea/Textarea.stories.jsx +37 -15
- package/textarea/Textarea.test.js +437 -0
- package/textarea/types.d.ts +137 -0
- package/textarea/types.js +5 -0
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +12 -14
- package/toggle-group/ToggleGroup.stories.tsx +27 -32
- package/toggle-group/ToggleGroup.test.js +156 -0
- package/toggle-group/types.d.ts +46 -25
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +111 -57
- package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +33 -24
- package/wizard/Wizard.test.js +141 -0
- package/wizard/types.d.ts +12 -11
- package/ThemeContext.d.ts +0 -15
- package/ThemeContext.js +0 -243
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/list/List.d.ts +0 -7
- package/list/List.js +0 -37
- package/list/List.stories.tsx +0 -70
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -11
- package/row/Row.js +0 -124
- package/row/Row.stories.tsx +0 -223
- package/select/index.d.ts +0 -131
- package/stack/Stack.d.ts +0 -10
- package/stack/Stack.js +0 -94
- package/stack/Stack.stories.tsx +0 -150
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/textarea/index.d.ts +0 -127
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
- package/wizard/Icons.js +0 -65
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
17
|
+
|
|
18
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
19
|
+
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
var DropdownMenuItem = function DropdownMenuItem(_ref) {
|
|
27
|
+
var id = _ref.id,
|
|
28
|
+
visuallyFocused = _ref.visuallyFocused,
|
|
29
|
+
iconPosition = _ref.iconPosition,
|
|
30
|
+
_onClick = _ref.onClick,
|
|
31
|
+
option = _ref.option;
|
|
32
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
33
|
+
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
34
|
+
theme: colorsTheme.dropdown
|
|
35
|
+
}, /*#__PURE__*/_react["default"].createElement(DropdownMenuItemContainer, {
|
|
36
|
+
visuallyFocused: visuallyFocused,
|
|
37
|
+
onClick: function onClick() {
|
|
38
|
+
_onClick(option.value);
|
|
39
|
+
},
|
|
40
|
+
id: id,
|
|
41
|
+
role: "menuitem",
|
|
42
|
+
tabIndex: -1
|
|
43
|
+
}, iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(DropdownMenuItemLabel, null, option.label), option.icon && /*#__PURE__*/_react["default"].createElement(DropdownMenuItemIcon, {
|
|
44
|
+
iconPosition: iconPosition,
|
|
45
|
+
label: option.label,
|
|
46
|
+
role: typeof option.icon === "string" ? undefined : "img"
|
|
47
|
+
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
48
|
+
src: option.icon
|
|
49
|
+
}) : option.icon), iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(DropdownMenuItemLabel, null, option.label)));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var DropdownMenuItemContainer = _styledComponents["default"].li(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: ", ";\n min-height: 36px;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n cursor: pointer;\n\n ", "\n :hover {\n background-color: ", ";\n }\n :active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
53
|
+
return props.theme.optionIconSpacing;
|
|
54
|
+
}, function (props) {
|
|
55
|
+
return props.theme.optionPaddingTop;
|
|
56
|
+
}, function (props) {
|
|
57
|
+
return props.theme.optionPaddingBottom;
|
|
58
|
+
}, function (props) {
|
|
59
|
+
return props.theme.optionPaddingLeft;
|
|
60
|
+
}, function (props) {
|
|
61
|
+
return props.theme.optionPaddingRight;
|
|
62
|
+
}, function (props) {
|
|
63
|
+
return props.visuallyFocused && "outline: ".concat(props.theme.focusColor, " solid 2px; outline-offset: -2px;");
|
|
64
|
+
}, function (props) {
|
|
65
|
+
return props.theme.hoverOptionBackgroundColor;
|
|
66
|
+
}, function (props) {
|
|
67
|
+
return props.theme.activeOptionBackgroundColor;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var DropdownMenuItemLabel = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5rem;\n color: ", ";\n"])), function (props) {
|
|
71
|
+
return props.theme.optionFontFamily;
|
|
72
|
+
}, function (props) {
|
|
73
|
+
return props.theme.optionFontSize;
|
|
74
|
+
}, function (props) {
|
|
75
|
+
return props.theme.optionFontStyle;
|
|
76
|
+
}, function (props) {
|
|
77
|
+
return props.theme.optionFontWeight;
|
|
78
|
+
}, function (props) {
|
|
79
|
+
return props.theme.optionFontColor;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
var DropdownMenuItemIcon = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n color: ", ";\n\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
83
|
+
return props.theme.optionIconColor;
|
|
84
|
+
}, function (props) {
|
|
85
|
+
return props.theme.optionIconSize;
|
|
86
|
+
}, function (props) {
|
|
87
|
+
return props.theme.optionIconSize;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
var _default = /*#__PURE__*/_react["default"].memo(DropdownMenuItem);
|
|
91
|
+
|
|
92
|
+
exports["default"] = _default;
|
package/dropdown/types.d.ts
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
-
declare type Margin = {
|
|
2
|
+
export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
export declare type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type
|
|
10
|
-
declare type
|
|
9
|
+
export declare type Size = "small" | "medium" | "large" | "fillParent" | "fitContent";
|
|
10
|
+
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
11
|
+
export declare type Option = {
|
|
11
12
|
/**
|
|
12
13
|
* Option display value.
|
|
13
14
|
*/
|
|
14
15
|
label?: string;
|
|
15
16
|
/**
|
|
16
|
-
* Element used as the icon that will be placed next to the
|
|
17
|
+
* Element or path used as the icon that will be placed next to the
|
|
17
18
|
* option label.
|
|
18
19
|
*/
|
|
19
|
-
icon?: SVG;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated URL of the icon that will be placed next to the option label.
|
|
22
|
-
*/
|
|
23
|
-
iconSrc?: string;
|
|
20
|
+
icon?: string | SVG;
|
|
24
21
|
/**
|
|
25
22
|
* Option inner value.
|
|
26
23
|
*/
|
|
@@ -37,15 +34,10 @@ declare type Props = {
|
|
|
37
34
|
*/
|
|
38
35
|
optionsIconPosition?: "before" | "after";
|
|
39
36
|
/**
|
|
40
|
-
* Element used as the icon that will be placed next to the
|
|
41
|
-
* dropdown label.
|
|
42
|
-
*/
|
|
43
|
-
icon?: SVG;
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated URL of the icon that will be placed next to the
|
|
37
|
+
* Element or path used as the icon that will be placed next to the
|
|
46
38
|
* dropdown label.
|
|
47
39
|
*/
|
|
48
|
-
|
|
40
|
+
icon?: string | SVG;
|
|
49
41
|
/**
|
|
50
42
|
* Whether the icon should appear after or before the label.
|
|
51
43
|
*/
|
|
@@ -76,7 +68,7 @@ declare type Props = {
|
|
|
76
68
|
/**
|
|
77
69
|
* Size of the component.
|
|
78
70
|
*/
|
|
79
|
-
size?:
|
|
71
|
+
size?: Size;
|
|
80
72
|
/**
|
|
81
73
|
* Value of the tabindex.
|
|
82
74
|
*/
|
|
@@ -86,4 +78,23 @@ declare type Props = {
|
|
|
86
78
|
*/
|
|
87
79
|
disabled?: boolean;
|
|
88
80
|
};
|
|
81
|
+
export declare type DropdownMenuProps = {
|
|
82
|
+
id: string;
|
|
83
|
+
dropdownTriggerId: string;
|
|
84
|
+
iconsPosition: "before" | "after";
|
|
85
|
+
visualFocusIndex: number;
|
|
86
|
+
menuItemOnClick: (value: string) => void;
|
|
87
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLUListElement>) => void;
|
|
88
|
+
options: Option[];
|
|
89
|
+
styles: {
|
|
90
|
+
width: number;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export declare type DropdownMenuItemProps = {
|
|
94
|
+
id: string;
|
|
95
|
+
visuallyFocused: boolean;
|
|
96
|
+
iconPosition: "before" | "after";
|
|
97
|
+
onClick: (value: string) => void;
|
|
98
|
+
option: Option;
|
|
99
|
+
};
|
|
89
100
|
export default Props;
|
package/file-input/FileInput.js
CHANGED
|
@@ -17,6 +17,8 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
17
17
|
|
|
18
18
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
19
|
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
20
22
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
21
23
|
|
|
22
24
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -31,6 +33,8 @@ var _variables = require("../common/variables.js");
|
|
|
31
33
|
|
|
32
34
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
33
35
|
|
|
36
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
37
|
+
|
|
34
38
|
var _Button = _interopRequireDefault(require("../button/Button"));
|
|
35
39
|
|
|
36
40
|
var _FileItem = _interopRequireDefault(require("./FileItem"));
|
|
@@ -41,6 +45,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
41
45
|
|
|
42
46
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
43
47
|
|
|
48
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
49
|
+
|
|
50
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
51
|
+
|
|
44
52
|
var audioIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
45
53
|
xmlns: "http://www.w3.org/2000/svg",
|
|
46
54
|
width: "24",
|
|
@@ -121,12 +129,76 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
121
129
|
fileInputId = _useState6[0];
|
|
122
130
|
|
|
123
131
|
var colorsTheme = (0, _useTheme["default"])();
|
|
132
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
124
133
|
(0, _react.useEffect)(function () {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
var getFiles = /*#__PURE__*/function () {
|
|
135
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
136
|
+
var valueFiles;
|
|
137
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
138
|
+
while (1) {
|
|
139
|
+
switch (_context2.prev = _context2.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
if (!value) {
|
|
142
|
+
_context2.next = 5;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_context2.next = 3;
|
|
147
|
+
return Promise.all(value.map( /*#__PURE__*/function () {
|
|
148
|
+
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
|
|
149
|
+
var preview;
|
|
150
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
151
|
+
while (1) {
|
|
152
|
+
switch (_context.prev = _context.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
if (!file.preview) {
|
|
155
|
+
_context.next = 4;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return _context.abrupt("return", file);
|
|
160
|
+
|
|
161
|
+
case 4:
|
|
162
|
+
_context.next = 6;
|
|
163
|
+
return getFilePreview(file.file);
|
|
164
|
+
|
|
165
|
+
case 6:
|
|
166
|
+
preview = _context.sent;
|
|
167
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, file), {}, {
|
|
168
|
+
preview: preview
|
|
169
|
+
}));
|
|
170
|
+
|
|
171
|
+
case 8:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, _callee);
|
|
177
|
+
}));
|
|
178
|
+
|
|
179
|
+
return function (_x) {
|
|
180
|
+
return _ref3.apply(this, arguments);
|
|
181
|
+
};
|
|
182
|
+
}()));
|
|
183
|
+
|
|
184
|
+
case 3:
|
|
185
|
+
valueFiles = _context2.sent;
|
|
186
|
+
setFiles(valueFiles);
|
|
187
|
+
|
|
188
|
+
case 5:
|
|
189
|
+
case "end":
|
|
190
|
+
return _context2.stop();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, _callee2);
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
return function getFiles() {
|
|
197
|
+
return _ref2.apply(this, arguments);
|
|
198
|
+
};
|
|
199
|
+
}();
|
|
200
|
+
|
|
201
|
+
getFiles();
|
|
130
202
|
}, [value]);
|
|
131
203
|
|
|
132
204
|
var handleClick = function handleClick() {
|
|
@@ -135,11 +207,11 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
135
207
|
|
|
136
208
|
var checkFileSize = function checkFileSize(file) {
|
|
137
209
|
if (file.size < minSize) {
|
|
138
|
-
return
|
|
210
|
+
return translatedLabels.fileInput.fileSizeGreaterThanErrorMessage;
|
|
139
211
|
}
|
|
140
212
|
|
|
141
213
|
if (file.size > maxSize) {
|
|
142
|
-
return
|
|
214
|
+
return translatedLabels.fileInput.fileSizeLessThanErrorMessage;
|
|
143
215
|
}
|
|
144
216
|
};
|
|
145
217
|
|
|
@@ -167,13 +239,13 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
167
239
|
};
|
|
168
240
|
|
|
169
241
|
var getFilesToAdd = /*#__PURE__*/function () {
|
|
170
|
-
var
|
|
242
|
+
var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(selectedFiles) {
|
|
171
243
|
var filesToAdd;
|
|
172
|
-
return _regenerator["default"].wrap(function
|
|
244
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
173
245
|
while (1) {
|
|
174
|
-
switch (
|
|
246
|
+
switch (_context3.prev = _context3.next) {
|
|
175
247
|
case 0:
|
|
176
|
-
|
|
248
|
+
_context3.next = 2;
|
|
177
249
|
return Promise.all(selectedFiles.map(function (selectedFile) {
|
|
178
250
|
return getFilePreview(selectedFile);
|
|
179
251
|
})).then(function (previews) {
|
|
@@ -188,71 +260,71 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
188
260
|
});
|
|
189
261
|
|
|
190
262
|
case 2:
|
|
191
|
-
filesToAdd =
|
|
192
|
-
return
|
|
263
|
+
filesToAdd = _context3.sent;
|
|
264
|
+
return _context3.abrupt("return", filesToAdd);
|
|
193
265
|
|
|
194
266
|
case 4:
|
|
195
267
|
case "end":
|
|
196
|
-
return
|
|
268
|
+
return _context3.stop();
|
|
197
269
|
}
|
|
198
270
|
}
|
|
199
|
-
},
|
|
271
|
+
}, _callee3);
|
|
200
272
|
}));
|
|
201
273
|
|
|
202
|
-
return function getFilesToAdd(
|
|
203
|
-
return
|
|
274
|
+
return function getFilesToAdd(_x2) {
|
|
275
|
+
return _ref4.apply(this, arguments);
|
|
204
276
|
};
|
|
205
277
|
}();
|
|
206
278
|
|
|
207
279
|
var addFile = /*#__PURE__*/function () {
|
|
208
|
-
var
|
|
280
|
+
var _ref5 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(selectedFiles) {
|
|
209
281
|
var filesToAdd, finalFiles, fileToAdd;
|
|
210
|
-
return _regenerator["default"].wrap(function
|
|
282
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
211
283
|
while (1) {
|
|
212
|
-
switch (
|
|
284
|
+
switch (_context4.prev = _context4.next) {
|
|
213
285
|
case 0:
|
|
214
286
|
if (!multiple) {
|
|
215
|
-
|
|
287
|
+
_context4.next = 8;
|
|
216
288
|
break;
|
|
217
289
|
}
|
|
218
290
|
|
|
219
|
-
|
|
291
|
+
_context4.next = 3;
|
|
220
292
|
return getFilesToAdd(selectedFiles);
|
|
221
293
|
|
|
222
294
|
case 3:
|
|
223
|
-
filesToAdd =
|
|
295
|
+
filesToAdd = _context4.sent;
|
|
224
296
|
finalFiles = [].concat((0, _toConsumableArray2["default"])(files), (0, _toConsumableArray2["default"])(filesToAdd));
|
|
225
297
|
|
|
226
298
|
if (typeof callbackFile === "function") {
|
|
227
299
|
callbackFile(finalFiles);
|
|
228
300
|
}
|
|
229
301
|
|
|
230
|
-
|
|
302
|
+
_context4.next = 19;
|
|
231
303
|
break;
|
|
232
304
|
|
|
233
305
|
case 8:
|
|
234
306
|
if (!(selectedFiles.length === 1)) {
|
|
235
|
-
|
|
307
|
+
_context4.next = 14;
|
|
236
308
|
break;
|
|
237
309
|
}
|
|
238
310
|
|
|
239
|
-
|
|
311
|
+
_context4.next = 11;
|
|
240
312
|
return getFilesToAdd(selectedFiles);
|
|
241
313
|
|
|
242
314
|
case 11:
|
|
243
|
-
|
|
244
|
-
|
|
315
|
+
_context4.t0 = _context4.sent;
|
|
316
|
+
_context4.next = 17;
|
|
245
317
|
break;
|
|
246
318
|
|
|
247
319
|
case 14:
|
|
248
|
-
|
|
320
|
+
_context4.next = 16;
|
|
249
321
|
return getFilesToAdd([selectedFiles[0]]);
|
|
250
322
|
|
|
251
323
|
case 16:
|
|
252
|
-
|
|
324
|
+
_context4.t0 = _context4.sent;
|
|
253
325
|
|
|
254
326
|
case 17:
|
|
255
|
-
fileToAdd =
|
|
327
|
+
fileToAdd = _context4.t0;
|
|
256
328
|
|
|
257
329
|
if (typeof callbackFile === "function") {
|
|
258
330
|
callbackFile(fileToAdd);
|
|
@@ -260,14 +332,14 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
260
332
|
|
|
261
333
|
case 19:
|
|
262
334
|
case "end":
|
|
263
|
-
return
|
|
335
|
+
return _context4.stop();
|
|
264
336
|
}
|
|
265
337
|
}
|
|
266
|
-
},
|
|
338
|
+
}, _callee4);
|
|
267
339
|
}));
|
|
268
340
|
|
|
269
|
-
return function addFile(
|
|
270
|
-
return
|
|
341
|
+
return function addFile(_x3) {
|
|
342
|
+
return _ref5.apply(this, arguments);
|
|
271
343
|
};
|
|
272
344
|
}();
|
|
273
345
|
|
|
@@ -341,7 +413,7 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
341
413
|
onChange: selectFiles
|
|
342
414
|
}), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
343
415
|
mode: "secondary",
|
|
344
|
-
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : multiple ?
|
|
416
|
+
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : multiple ? translatedLabels.fileInput.multipleButtonLabelDefault : translatedLabels.fileInput.singleButtonLabelDefault,
|
|
345
417
|
onClick: handleClick,
|
|
346
418
|
disabled: disabled,
|
|
347
419
|
size: "medium",
|
|
@@ -381,15 +453,15 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
381
453
|
mode: mode
|
|
382
454
|
}, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
383
455
|
mode: "secondary",
|
|
384
|
-
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel :
|
|
456
|
+
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : translatedLabels.fileInput.dropAreaButtonLabelDefault,
|
|
385
457
|
onClick: handleClick,
|
|
386
458
|
disabled: disabled,
|
|
387
459
|
size: "fitContent"
|
|
388
460
|
})), mode === "dropzone" ? /*#__PURE__*/_react["default"].createElement(DropzoneLabel, {
|
|
389
461
|
disabled: disabled
|
|
390
|
-
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ?
|
|
462
|
+
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ? translatedLabels.fileInput.multipleDropAreaLabelDefault : translatedLabels.fileInput.singleDropAreaLabelDefault) : /*#__PURE__*/_react["default"].createElement(FiledropLabel, {
|
|
391
463
|
disabled: disabled
|
|
392
|
-
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ?
|
|
464
|
+
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ? translatedLabels.fileInput.multipleDropAreaLabelDefault : translatedLabels.fileInput.singleDropAreaLabelDefault)), files.map(function (file) {
|
|
393
465
|
return /*#__PURE__*/_react["default"].createElement(FileItemContainer, {
|
|
394
466
|
mode: mode,
|
|
395
467
|
multiple: multiple,
|