@dxc-technology/halstack-react 0.0.0-50c4df3 → 0.0.0-51152f3
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 +1 -10
- package/BackgroundColorContext.js +5 -22
- package/HalstackContext.d.ts +1231 -6
- package/HalstackContext.js +67 -100
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +30 -87
- package/accordion/Accordion.stories.tsx +2 -114
- package/accordion/Accordion.test.js +19 -34
- package/accordion/types.d.ts +5 -17
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +29 -77
- package/accordion-group/AccordionGroup.stories.tsx +78 -77
- package/accordion-group/AccordionGroup.test.js +44 -72
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +6 -18
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +47 -0
- package/action-icon/ActionIcon.stories.tsx +41 -0
- package/action-icon/ActionIcon.test.js +64 -0
- package/action-icon/types.d.ts +26 -0
- package/alert/Alert.js +19 -58
- package/alert/Alert.test.js +29 -46
- package/alert/types.d.ts +5 -5
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +141 -43
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/bleed/Bleed.js +13 -21
- 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 +18 -59
- package/box/Box.stories.tsx +25 -53
- package/box/Box.test.js +2 -7
- package/box/types.d.ts +3 -15
- package/bulleted-list/BulletedList.js +19 -53
- package/bulleted-list/BulletedList.stories.tsx +8 -93
- package/bulleted-list/types.d.ts +32 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +68 -102
- package/button/Button.stories.tsx +9 -90
- package/button/Button.test.js +20 -17
- package/button/types.d.ts +8 -4
- package/card/Card.d.ts +1 -1
- package/card/Card.js +48 -89
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +11 -22
- package/card/types.d.ts +6 -12
- package/checkbox/Checkbox.js +87 -122
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +108 -64
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.js +36 -70
- package/chip/Chip.stories.tsx +25 -17
- package/chip/Chip.test.js +16 -31
- package/chip/types.d.ts +4 -4
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +237 -0
- package/common/coreTokens.js +184 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +6 -12
- package/common/variables.d.ts +1383 -0
- package/common/variables.js +880 -1163
- package/container/Container.d.ts +4 -0
- package/container/Container.js +194 -0
- package/container/Container.stories.tsx +214 -0
- package/container/types.d.ts +74 -0
- package/date-input/Calendar.js +15 -59
- 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.d.ts +1 -1
- package/dialog/Dialog.js +61 -117
- package/dialog/Dialog.stories.tsx +292 -216
- package/dialog/Dialog.test.js +269 -32
- package/dialog/types.d.ts +18 -26
- package/dropdown/Dropdown.js +50 -102
- package/dropdown/Dropdown.test.js +393 -379
- package/dropdown/DropdownMenu.js +13 -20
- package/dropdown/DropdownMenuItem.js +5 -19
- package/dropdown/types.d.ts +17 -19
- package/file-input/FileInput.js +181 -250
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +357 -355
- package/file-input/FileItem.js +14 -41
- package/file-input/types.d.ts +10 -10
- package/flex/Flex.js +27 -39
- 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 +70 -117
- package/footer/Footer.stories.tsx +38 -95
- package/footer/Footer.test.js +33 -57
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +66 -7
- package/footer/types.d.ts +25 -27
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +76 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/grid/types.js +5 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +34 -117
- package/header/Header.stories.tsx +7 -71
- package/header/Header.test.js +13 -26
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +2 -7
- package/header/types.d.ts +5 -20
- package/heading/Heading.js +10 -32
- package/heading/Heading.test.js +71 -88
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/image/types.js +5 -0
- package/inset/Inset.js +13 -21
- 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 +29 -66
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +8 -5
- package/layout/Icons.js +51 -59
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +3 -9
- package/layout/types.d.ts +5 -6
- package/link/Link.js +24 -45
- package/link/Link.test.js +24 -44
- package/link/types.d.ts +14 -14
- package/main.d.ts +7 -4
- package/main.js +32 -58
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +22 -54
- package/nav-tabs/NavTabs.stories.tsx +21 -5
- package/nav-tabs/NavTabs.test.js +39 -45
- package/nav-tabs/Tab.js +43 -75
- package/nav-tabs/types.d.ts +14 -15
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +47 -37
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +860 -413
- package/number-input/types.d.ts +11 -5
- package/package.json +31 -29
- package/paginator/Icons.d.ts +5 -5
- package/paginator/Icons.js +5 -19
- package/paginator/Paginator.js +17 -47
- package/paginator/Paginator.test.js +235 -215
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +6 -22
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -126
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +158 -141
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +22 -54
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +36 -53
- package/progress-bar/types.d.ts +4 -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 +31 -63
- package/radio-group/RadioGroup.js +45 -93
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +505 -471
- 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/resultset-table/ResultsetTable.d.ts +7 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.js +38 -66
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +86 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +139 -93
- package/{resultsetTable → resultset-table}/types.d.ts +13 -7
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.js +13 -39
- package/select/Option.js +17 -27
- package/select/Select.js +94 -168
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +1952 -1810
- package/select/types.d.ts +14 -15
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +81 -151
- package/sidenav/Sidenav.stories.tsx +60 -60
- package/sidenav/Sidenav.test.js +3 -10
- package/sidenav/types.d.ts +31 -28
- package/slider/Slider.js +70 -128
- package/slider/Slider.test.js +108 -104
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +29 -73
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +28 -28
- package/spinner/Spinner.test.js +26 -35
- package/spinner/types.d.ts +3 -3
- package/status-light/StatusLight.d.ts +4 -0
- package/status-light/StatusLight.js +51 -0
- package/status-light/StatusLight.stories.tsx +74 -0
- package/status-light/StatusLight.test.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/switch/Switch.js +51 -99
- package/switch/Switch.stories.tsx +0 -34
- package/switch/Switch.test.js +52 -97
- package/switch/types.d.ts +4 -4
- package/table/ActionsCell.d.ts +4 -0
- package/table/ActionsCell.js +55 -0
- package/table/DropdownTheme.js +58 -0
- package/table/Table.d.ts +4 -1
- package/table/Table.js +27 -32
- package/table/{Table.stories.jsx → Table.stories.tsx} +261 -2
- package/table/Table.test.js +94 -7
- package/table/types.d.ts +45 -6
- package/tabs/Tab.js +23 -40
- package/tabs/Tabs.js +62 -145
- package/tabs/Tabs.stories.tsx +1 -1
- package/tabs/Tabs.test.js +66 -123
- package/tabs/types.d.ts +19 -19
- package/tag/Tag.js +28 -60
- package/tag/Tag.test.js +20 -31
- 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 +11 -28
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +15 -65
- package/text-input/TextInput.js +220 -328
- package/text-input/TextInput.stories.tsx +48 -152
- package/text-input/TextInput.test.js +1228 -1196
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.js +70 -113
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
- package/textarea/Textarea.test.js +152 -183
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +92 -106
- package/toggle-group/ToggleGroup.stories.tsx +7 -4
- package/toggle-group/ToggleGroup.test.js +69 -88
- package/toggle-group/types.d.ts +26 -17
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +15 -123
- package/typography/Typography.stories.tsx +1 -1
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +1135 -1
- package/useTheme.js +2 -9
- package/useTranslatedLabels.d.ts +84 -1
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +94 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +124 -0
- package/wizard/Wizard.js +16 -51
- package/wizard/Wizard.test.js +54 -81
- package/wizard/types.d.ts +8 -9
- package/card/ice-cream.jpg +0 -0
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/resultsetTable/Icons.d.ts +0 -7
- package/resultsetTable/ResultsetTable.d.ts +0 -4
- package/slider/Slider.stories.tsx +0 -240
- /package/{resultsetTable → action-icon}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → container/types.js} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _ActionIcon = _interopRequireDefault(require("../action-icon/ActionIcon"));
|
|
10
|
+
var _main = require("../main");
|
|
11
|
+
var _DropdownTheme = _interopRequireDefault(require("./DropdownTheme"));
|
|
12
|
+
var moreVertIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
height: "24",
|
|
15
|
+
viewBox: "0 -960 960 960",
|
|
16
|
+
width: "24",
|
|
17
|
+
fill: "currentColor"
|
|
18
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
19
|
+
d: "M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"
|
|
20
|
+
}));
|
|
21
|
+
var DxcActionsCell = function DxcActionsCell(_ref) {
|
|
22
|
+
var actions = _ref.actions;
|
|
23
|
+
var actionIcons = actions.filter(function (action) {
|
|
24
|
+
return !action.options;
|
|
25
|
+
});
|
|
26
|
+
var actionDropdown = actions.find(function (action) {
|
|
27
|
+
return action.options;
|
|
28
|
+
});
|
|
29
|
+
var maxNumberOfActions = actionDropdown ? 2 : 3;
|
|
30
|
+
return /*#__PURE__*/_react["default"].createElement(_main.DxcFlex, {
|
|
31
|
+
gap: "0.5rem",
|
|
32
|
+
alignItems: "center"
|
|
33
|
+
}, actionIcons.map(function (action, index) {
|
|
34
|
+
var _action$disabled, _action$tabIndex;
|
|
35
|
+
return index < maxNumberOfActions && /*#__PURE__*/_react["default"].createElement(_ActionIcon["default"], {
|
|
36
|
+
icon: action.icon,
|
|
37
|
+
title: action.title,
|
|
38
|
+
onClick: action.onClick,
|
|
39
|
+
disabled: (_action$disabled = action.disabled) !== null && _action$disabled !== void 0 ? _action$disabled : false,
|
|
40
|
+
tabIndex: (_action$tabIndex = action.tabIndex) !== null && _action$tabIndex !== void 0 ? _action$tabIndex : 0,
|
|
41
|
+
key: "action-".concat(index)
|
|
42
|
+
});
|
|
43
|
+
}), actionDropdown && /*#__PURE__*/_react["default"].createElement(_main.HalstackProvider, {
|
|
44
|
+
advancedTheme: _DropdownTheme["default"],
|
|
45
|
+
key: "provider-dropdown"
|
|
46
|
+
}, /*#__PURE__*/_react["default"].createElement(_main.DxcDropdown, {
|
|
47
|
+
options: actionDropdown.options,
|
|
48
|
+
onSelectOption: actionDropdown.onClick,
|
|
49
|
+
disabled: actionDropdown.disabled,
|
|
50
|
+
icon: moreVertIcon,
|
|
51
|
+
tabIndex: actionDropdown.tabIndex,
|
|
52
|
+
caretHidden: true
|
|
53
|
+
})));
|
|
54
|
+
};
|
|
55
|
+
var _default = exports["default"] = DxcActionsCell;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _variables = require("../common/variables");
|
|
8
|
+
var _default = exports["default"] = {
|
|
9
|
+
dropdown: {
|
|
10
|
+
// Breadcrumbs tokens
|
|
11
|
+
buttonIconSize: "16px",
|
|
12
|
+
buttonPaddingTop: "4px",
|
|
13
|
+
buttonPaddingBottom: "4px",
|
|
14
|
+
buttonPaddingLeft: "4px",
|
|
15
|
+
buttonPaddingRight: "4px",
|
|
16
|
+
buttonHeight: "24px",
|
|
17
|
+
buttonBorderRadius: "2px",
|
|
18
|
+
buttonBorderColor: "transparent",
|
|
19
|
+
optionFontSize: "14px",
|
|
20
|
+
optionPaddingTop: "0px",
|
|
21
|
+
optionPaddingBottom: "0px",
|
|
22
|
+
optionPaddingLeft: "16px",
|
|
23
|
+
optionPaddingRight: "16px",
|
|
24
|
+
// Dropdown tokens
|
|
25
|
+
buttonBackgroundColor: _variables.componentTokens.table.actionBackgroundColor,
|
|
26
|
+
hoverButtonBackgroundColor: _variables.componentTokens.table.hoverActionBackgroundColor,
|
|
27
|
+
activeButtonBackgroundColor: _variables.componentTokens.table.activeActionBackgroundColor,
|
|
28
|
+
buttonFontFamily: _variables.componentTokens.dropdown.buttonFontFamily,
|
|
29
|
+
buttonFontSize: _variables.componentTokens.dropdown.buttonFontSize,
|
|
30
|
+
buttonFontStyle: _variables.componentTokens.dropdown.buttonFontStyle,
|
|
31
|
+
buttonFontWeight: _variables.componentTokens.dropdown.buttonFontWeight,
|
|
32
|
+
buttonFontColor: _variables.componentTokens.dropdown.buttonFontColor,
|
|
33
|
+
buttonIconSpacing: _variables.componentTokens.dropdown.buttonIconSpacing,
|
|
34
|
+
buttonIconColor: _variables.componentTokens.table.actionIconColor,
|
|
35
|
+
disabledColor: _variables.componentTokens.table.disabledActionIconColor,
|
|
36
|
+
disabledButtonBackgroundColor: _variables.componentTokens.table.disabledActionBackgroundColor,
|
|
37
|
+
disabledBorderColor: _variables.componentTokens.dropdown.disabledBorderColor,
|
|
38
|
+
optionBackgroundColor: _variables.componentTokens.dropdown.optionBackgroundColor,
|
|
39
|
+
hoverOptionBackgroundColor: _variables.componentTokens.dropdown.hoverOptionBackgroundColor,
|
|
40
|
+
activeOptionBackgroundColor: _variables.componentTokens.dropdown.activeOptionBackgroundColor,
|
|
41
|
+
optionFontFamily: _variables.componentTokens.dropdown.optionFontFamily,
|
|
42
|
+
optionFontStyle: _variables.componentTokens.dropdown.optionFontStyle,
|
|
43
|
+
optionFontWeight: _variables.componentTokens.dropdown.optionFontWeight,
|
|
44
|
+
optionFontColor: _variables.componentTokens.dropdown.optionFontColor,
|
|
45
|
+
optionIconSize: _variables.componentTokens.dropdown.optionIconSize,
|
|
46
|
+
optionIconSpacing: _variables.componentTokens.dropdown.optionIconSpacing,
|
|
47
|
+
optionIconColor: _variables.componentTokens.dropdown.optionIconColor,
|
|
48
|
+
caretIconSize: _variables.componentTokens.dropdown.caretIconSize,
|
|
49
|
+
caretIconColor: _variables.componentTokens.dropdown.caretIconColor,
|
|
50
|
+
caretIconSpacing: _variables.componentTokens.dropdown.caretIconSpacing,
|
|
51
|
+
borderRadius: _variables.componentTokens.dropdown.borderRadius,
|
|
52
|
+
borderStyle: _variables.componentTokens.dropdown.borderStyle,
|
|
53
|
+
borderThickness: _variables.componentTokens.dropdown.borderThickness,
|
|
54
|
+
borderColor: _variables.componentTokens.dropdown.borderColor,
|
|
55
|
+
scrollBarThumbColor: _variables.componentTokens.dropdown.scrollBarThumbColor,
|
|
56
|
+
scrollBarTrackColor: _variables.componentTokens.dropdown.scrollBarTrackColor
|
|
57
|
+
}
|
|
58
|
+
};
|
package/table/Table.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import TablePropsType from "./types";
|
|
3
|
-
declare const DxcTable:
|
|
3
|
+
declare const DxcTable: {
|
|
4
|
+
({ children, margin, mode }: TablePropsType): JSX.Element;
|
|
5
|
+
ActionsCell: ({ actions }: import("./types").ActionCellsPropsType) => JSX.Element;
|
|
6
|
+
};
|
|
4
7
|
export default DxcTable;
|
package/table/Table.js
CHANGED
|
@@ -1,53 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = 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 _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
12
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var _utils = require("../common/utils.js");
|
|
23
|
-
|
|
13
|
+
var _variables = require("../common/variables");
|
|
14
|
+
var _utils = require("../common/utils");
|
|
24
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
16
|
+
var _coreTokens = _interopRequireDefault(require("../common/coreTokens"));
|
|
17
|
+
var _ActionsCell = _interopRequireDefault(require("./ActionsCell"));
|
|
28
18
|
var _templateObject, _templateObject2;
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
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; }
|
|
33
|
-
|
|
19
|
+
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); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(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
21
|
var DxcTable = function DxcTable(_ref) {
|
|
35
22
|
var children = _ref.children,
|
|
36
|
-
|
|
23
|
+
margin = _ref.margin,
|
|
24
|
+
_ref$mode = _ref.mode,
|
|
25
|
+
mode = _ref$mode === void 0 ? "default" : _ref$mode;
|
|
37
26
|
var colorsTheme = (0, _useTheme["default"])();
|
|
38
27
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
39
28
|
theme: colorsTheme.table
|
|
40
29
|
}, /*#__PURE__*/_react["default"].createElement(DxcTableContainer, {
|
|
41
30
|
margin: margin
|
|
42
|
-
}, /*#__PURE__*/_react["default"].createElement(DxcTableContent,
|
|
43
|
-
|
|
44
|
-
}, children)))
|
|
31
|
+
}, /*#__PURE__*/_react["default"].createElement(DxcTableContent, {
|
|
32
|
+
mode: mode
|
|
33
|
+
}, children)));
|
|
45
34
|
};
|
|
46
|
-
|
|
47
35
|
var calculateWidth = function calculateWidth(margin) {
|
|
48
36
|
return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
49
37
|
};
|
|
50
|
-
|
|
51
38
|
var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n overflow: auto;\n &::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n }\n &::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 6px;\n }\n &::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 6px;\n }\n"])), function (props) {
|
|
52
39
|
return calculateWidth(props.margin);
|
|
53
40
|
}, function (props) {
|
|
@@ -65,9 +52,10 @@ var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_te
|
|
|
65
52
|
}, function (props) {
|
|
66
53
|
return props.theme.scrollBarTrackColor;
|
|
67
54
|
});
|
|
68
|
-
|
|
69
|
-
var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n border-collapse: collapse;\n width: 100%;\n\n & tr {\n border-bottom: ", ";\n height: 60px;\n }\n & td {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th:first-child {\n border-top-left-radius: ", ";\n }\n & th:last-child {\n border-top-right-radius: ", ";\n }\n & td:last-child {\n padding-right: 40px;\n }\n"])), function (props) {
|
|
55
|
+
var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n border-collapse: collapse;\n width: 100%;\n\n & tr {\n border-bottom: ", ";\n height: ", ";\n }\n & td {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th:first-child {\n border-top-left-radius: ", ";\n padding-left: ", ";\n }\n & th:last-child {\n border-top-right-radius: ", ";\n padding-right: ", ";\n }\n & td:first-child {\n padding-left: ", ";\n }\n & td:last-child {\n padding-right: ", ";\n }\n"])), function (props) {
|
|
70
56
|
return "".concat(props.theme.rowSeparatorThickness, " ").concat(props.theme.rowSeparatorStyle, " ").concat(props.theme.rowSeparatorColor);
|
|
57
|
+
}, function (props) {
|
|
58
|
+
return props.mode === "default" ? "60px" : "36px";
|
|
71
59
|
}, function (props) {
|
|
72
60
|
return props.theme.dataBackgroundColor;
|
|
73
61
|
}, function (props) {
|
|
@@ -87,7 +75,7 @@ var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_t
|
|
|
87
75
|
}, function (props) {
|
|
88
76
|
return props.theme.dataTextLineHeight;
|
|
89
77
|
}, function (props) {
|
|
90
|
-
return "".concat(props.theme.dataPaddingTop, " ").concat(props.theme.dataPaddingRight, " ").concat(props.theme.dataPaddingBottom, " ").concat(props.theme.dataPaddingLeft);
|
|
78
|
+
return props.mode === "default" ? "".concat(props.theme.dataPaddingTop, " ").concat(props.theme.dataPaddingRight, " ").concat(props.theme.dataPaddingBottom, " ").concat(props.theme.dataPaddingLeft) : "".concat(_coreTokens["default"].spacing_8, " ").concat(_coreTokens["default"].spacing_16);
|
|
91
79
|
}, function (props) {
|
|
92
80
|
return props.theme.headerBackgroundColor;
|
|
93
81
|
}, function (props) {
|
|
@@ -107,12 +95,19 @@ var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_t
|
|
|
107
95
|
}, function (props) {
|
|
108
96
|
return props.theme.headerTextLineHeight;
|
|
109
97
|
}, function (props) {
|
|
110
|
-
return "".concat(props.theme.headerPaddingTop, " ").concat(props.theme.headerPaddingRight, " ").concat(props.theme.headerPaddingBottom, " ").concat(props.theme.headerPaddingLeft);
|
|
98
|
+
return props.mode === "default" ? "".concat(props.theme.headerPaddingTop, " ").concat(props.theme.headerPaddingRight, " ").concat(props.theme.headerPaddingBottom, " ").concat(props.theme.headerPaddingLeft) : "".concat(_coreTokens["default"].spacing_8, " ").concat(_coreTokens["default"].spacing_16);
|
|
111
99
|
}, function (props) {
|
|
112
100
|
return props.theme.headerBorderRadius;
|
|
101
|
+
}, function (props) {
|
|
102
|
+
return props.mode === "default" ? _coreTokens["default"].spacing_24 : "20px";
|
|
113
103
|
}, function (props) {
|
|
114
104
|
return props.theme.headerBorderRadius;
|
|
105
|
+
}, function (props) {
|
|
106
|
+
return props.mode === "default" ? _coreTokens["default"].spacing_24 : "20px";
|
|
107
|
+
}, function (props) {
|
|
108
|
+
return props.mode === "default" ? _coreTokens["default"].spacing_24 : "20px";
|
|
109
|
+
}, function (props) {
|
|
110
|
+
return props.mode === "default" ? _coreTokens["default"].spacing_24 : "20px";
|
|
115
111
|
});
|
|
116
|
-
|
|
117
|
-
var _default = DxcTable;
|
|
118
|
-
exports["default"] = _default;
|
|
112
|
+
DxcTable.ActionsCell = _ActionsCell["default"];
|
|
113
|
+
var _default = exports["default"] = DxcTable;
|
|
@@ -3,6 +3,7 @@ import DxcTable from "./Table";
|
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { HalstackProvider } from "../HalstackContext";
|
|
6
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: "Table",
|
|
@@ -17,11 +18,197 @@ const opinionatedTheme = {
|
|
|
17
18
|
},
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
const icon1 = (
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
23
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
24
|
+
<path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z" />
|
|
25
|
+
</svg>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const actions = [
|
|
29
|
+
{
|
|
30
|
+
title: "icon",
|
|
31
|
+
onClick: (value?) => {
|
|
32
|
+
console.log(value);
|
|
33
|
+
},
|
|
34
|
+
options: [
|
|
35
|
+
{
|
|
36
|
+
value: "1",
|
|
37
|
+
label: "Amazon with a very long text",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: "2",
|
|
41
|
+
label: "Ebay",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
value: "3",
|
|
45
|
+
label: "Apple",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: "icon",
|
|
51
|
+
onClick: (value?) => {
|
|
52
|
+
console.log(value);
|
|
53
|
+
},
|
|
54
|
+
options: [
|
|
55
|
+
{
|
|
56
|
+
value: "1",
|
|
57
|
+
label: "Amazon with a very long text",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
value: "2",
|
|
61
|
+
label: "Ebay",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: "3",
|
|
65
|
+
label: "Apple",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
disabled: true,
|
|
71
|
+
title: "icon",
|
|
72
|
+
onClick: (value?) => {
|
|
73
|
+
console.log(value);
|
|
74
|
+
},
|
|
75
|
+
options: [
|
|
76
|
+
{
|
|
77
|
+
value: "1",
|
|
78
|
+
label: "Amazon with a very long text",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "2",
|
|
82
|
+
label: "Ebay",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
value: "3",
|
|
86
|
+
label: "Apple",
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
icon: icon1,
|
|
92
|
+
title: "icon",
|
|
93
|
+
onClick: () => {},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
icon: icon1,
|
|
97
|
+
title: "icon",
|
|
98
|
+
onClick: () => {},
|
|
99
|
+
disabled: true,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
|
|
20
103
|
export const Chromatic = () => (
|
|
21
104
|
<>
|
|
22
105
|
<ExampleContainer>
|
|
23
106
|
<Title title="Default" theme="light" level={4} />
|
|
24
107
|
<DxcTable>
|
|
108
|
+
<tr>
|
|
109
|
+
<th>header 1</th>
|
|
110
|
+
<th>header 2</th>
|
|
111
|
+
<th>actions</th>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<td>cell 1</td>
|
|
115
|
+
<td>cell 2</td>
|
|
116
|
+
<td>
|
|
117
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
<tr>
|
|
121
|
+
<td>cell 4</td>
|
|
122
|
+
<td>cell 5</td>
|
|
123
|
+
<td>
|
|
124
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
125
|
+
</td>
|
|
126
|
+
</tr>
|
|
127
|
+
<tr>
|
|
128
|
+
<td>cell 7</td>
|
|
129
|
+
<td>cell 8</td>
|
|
130
|
+
<td>
|
|
131
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
132
|
+
</td>
|
|
133
|
+
</tr>
|
|
134
|
+
</DxcTable>
|
|
135
|
+
</ExampleContainer>
|
|
136
|
+
<ExampleContainer>
|
|
137
|
+
<Title title="With scrollbar" theme="light" level={4} />
|
|
138
|
+
<div
|
|
139
|
+
style={{ height: 200 + "px", display: "flex", flexDirection: "row", width: 100 + "%", marginBottom: 50 + "px" }}
|
|
140
|
+
>
|
|
141
|
+
<DxcTable>
|
|
142
|
+
<tr>
|
|
143
|
+
<th>
|
|
144
|
+
header<br></br>subheader
|
|
145
|
+
</th>
|
|
146
|
+
<th>
|
|
147
|
+
header<br></br>subheader
|
|
148
|
+
</th>
|
|
149
|
+
<th>
|
|
150
|
+
header<br></br>subheader
|
|
151
|
+
</th>
|
|
152
|
+
</tr>
|
|
153
|
+
<tr>
|
|
154
|
+
<td>
|
|
155
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
156
|
+
dolore magna aliqua.
|
|
157
|
+
</td>
|
|
158
|
+
<td>
|
|
159
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
160
|
+
consequat.
|
|
161
|
+
</td>
|
|
162
|
+
<td>
|
|
163
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
|
164
|
+
</td>
|
|
165
|
+
</tr>
|
|
166
|
+
<tr>
|
|
167
|
+
<td>cell data</td>
|
|
168
|
+
<td>cell data</td>
|
|
169
|
+
<td>cell data</td>
|
|
170
|
+
</tr>
|
|
171
|
+
<tr>
|
|
172
|
+
<td>cell data</td>
|
|
173
|
+
<td>cell data</td>
|
|
174
|
+
<td>cell data</td>
|
|
175
|
+
</tr>
|
|
176
|
+
<tr>
|
|
177
|
+
<td>cell data</td>
|
|
178
|
+
<td>cell data</td>
|
|
179
|
+
<td>cell data</td>
|
|
180
|
+
</tr>
|
|
181
|
+
<tr>
|
|
182
|
+
<td>cell data</td>
|
|
183
|
+
<td>cell data</td>
|
|
184
|
+
<td>cell data</td>
|
|
185
|
+
</tr>
|
|
186
|
+
<tr>
|
|
187
|
+
<td>cell data</td>
|
|
188
|
+
<td>cell data</td>
|
|
189
|
+
<td>cell data</td>
|
|
190
|
+
</tr>
|
|
191
|
+
<tr>
|
|
192
|
+
<td>cell data</td>
|
|
193
|
+
<td>cell data</td>
|
|
194
|
+
<td>cell data</td>
|
|
195
|
+
</tr>
|
|
196
|
+
<tr>
|
|
197
|
+
<td>cell data</td>
|
|
198
|
+
<td>cell data</td>
|
|
199
|
+
<td>cell data</td>
|
|
200
|
+
</tr>
|
|
201
|
+
<tr>
|
|
202
|
+
<td>cell data</td>
|
|
203
|
+
<td>cell data</td>
|
|
204
|
+
<td>cell data</td>
|
|
205
|
+
</tr>
|
|
206
|
+
</DxcTable>
|
|
207
|
+
</div>
|
|
208
|
+
</ExampleContainer>
|
|
209
|
+
<ExampleContainer>
|
|
210
|
+
<Title title="Default reduced" theme="light" level={4} />
|
|
211
|
+
<DxcTable mode="reduced">
|
|
25
212
|
<tr>
|
|
26
213
|
<th>header 1</th>
|
|
27
214
|
<th>header 2</th>
|
|
@@ -45,11 +232,11 @@ export const Chromatic = () => (
|
|
|
45
232
|
</DxcTable>
|
|
46
233
|
</ExampleContainer>
|
|
47
234
|
<ExampleContainer>
|
|
48
|
-
<Title title="
|
|
235
|
+
<Title title="Reduced with scrollbar" theme="light" level={4} />
|
|
49
236
|
<div
|
|
50
237
|
style={{ height: 200 + "px", display: "flex", flexDirection: "row", width: 100 + "%", marginBottom: 50 + "px" }}
|
|
51
238
|
>
|
|
52
|
-
<DxcTable>
|
|
239
|
+
<DxcTable mode="reduced">
|
|
53
240
|
<tr>
|
|
54
241
|
<th>
|
|
55
242
|
header<br></br>subheader
|
|
@@ -117,6 +304,37 @@ export const Chromatic = () => (
|
|
|
117
304
|
</DxcTable>
|
|
118
305
|
</div>
|
|
119
306
|
</ExampleContainer>
|
|
307
|
+
<ExampleContainer>
|
|
308
|
+
<Title title="Reduced table with actions" theme="light" level={4} />
|
|
309
|
+
<DxcTable mode="reduced">
|
|
310
|
+
<tr>
|
|
311
|
+
<th>header 1</th>
|
|
312
|
+
<th>header 2</th>
|
|
313
|
+
<th>header 3</th>
|
|
314
|
+
</tr>
|
|
315
|
+
<tr>
|
|
316
|
+
<td>cell 1</td>
|
|
317
|
+
<td>cell 2</td>
|
|
318
|
+
<td>
|
|
319
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
320
|
+
</td>
|
|
321
|
+
</tr>
|
|
322
|
+
<tr>
|
|
323
|
+
<td>cell 4</td>
|
|
324
|
+
<td>cell 5</td>
|
|
325
|
+
<td>
|
|
326
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
327
|
+
</td>
|
|
328
|
+
</tr>
|
|
329
|
+
<tr>
|
|
330
|
+
<td>cell 7</td>
|
|
331
|
+
<td>cell 8</td>
|
|
332
|
+
<td>
|
|
333
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
334
|
+
</td>
|
|
335
|
+
</tr>
|
|
336
|
+
</DxcTable>
|
|
337
|
+
</ExampleContainer>
|
|
120
338
|
<Title title="Margins" theme="light" level={2} />
|
|
121
339
|
<ExampleContainer>
|
|
122
340
|
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
@@ -354,3 +572,44 @@ export const Chromatic = () => (
|
|
|
354
572
|
</ExampleContainer>
|
|
355
573
|
</>
|
|
356
574
|
);
|
|
575
|
+
|
|
576
|
+
const ActionsCellDropdown = () => (
|
|
577
|
+
<ExampleContainer>
|
|
578
|
+
<Title title="Dropdown Action" theme="light" level={4} />
|
|
579
|
+
<DxcTable>
|
|
580
|
+
<tr>
|
|
581
|
+
<th>header 1</th>
|
|
582
|
+
<th>header 2</th>
|
|
583
|
+
<th>actions</th>
|
|
584
|
+
</tr>
|
|
585
|
+
<tr>
|
|
586
|
+
<td>cell 1</td>
|
|
587
|
+
<td>cell 2</td>
|
|
588
|
+
<td>
|
|
589
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
590
|
+
</td>
|
|
591
|
+
</tr>
|
|
592
|
+
<tr>
|
|
593
|
+
<td>cell 4</td>
|
|
594
|
+
<td>cell 5</td>
|
|
595
|
+
<td>
|
|
596
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
597
|
+
</td>
|
|
598
|
+
</tr>
|
|
599
|
+
<tr>
|
|
600
|
+
<td>cell 7</td>
|
|
601
|
+
<td>cell 8</td>
|
|
602
|
+
<td>
|
|
603
|
+
<DxcTable.ActionsCell actions={actions} />
|
|
604
|
+
</td>
|
|
605
|
+
</tr>
|
|
606
|
+
</DxcTable>
|
|
607
|
+
</ExampleContainer>
|
|
608
|
+
);
|
|
609
|
+
|
|
610
|
+
export const DropdownAction = ActionsCellDropdown.bind({});
|
|
611
|
+
DropdownAction.play = async ({ canvasElement }) => {
|
|
612
|
+
const canvas = within(canvasElement);
|
|
613
|
+
const nextButton = canvas.getAllByRole("button")[8];
|
|
614
|
+
await userEvent.click(nextButton);
|
|
615
|
+
};
|
package/table/Table.test.js
CHANGED
|
@@ -1,18 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
4
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
5
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
5
8
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
9
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
10
|
+
var _Table = _interopRequireDefault(require("./Table.tsx"));
|
|
11
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
12
|
+
global.globalThis = global;
|
|
13
|
+
global.DOMRect = {
|
|
14
|
+
fromRect: function fromRect() {
|
|
15
|
+
return {
|
|
16
|
+
top: 0,
|
|
17
|
+
left: 0,
|
|
18
|
+
bottom: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
width: 0,
|
|
21
|
+
height: 0
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
26
|
+
function ResizeObserver() {
|
|
27
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
28
|
+
}
|
|
29
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
30
|
+
key: "observe",
|
|
31
|
+
value: function observe() {}
|
|
32
|
+
}, {
|
|
33
|
+
key: "unobserve",
|
|
34
|
+
value: function unobserve() {}
|
|
35
|
+
}, {
|
|
36
|
+
key: "disconnect",
|
|
37
|
+
value: function disconnect() {}
|
|
38
|
+
}]);
|
|
39
|
+
return ResizeObserver;
|
|
40
|
+
}();
|
|
41
|
+
var icon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
42
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
43
|
+
height: "24px",
|
|
44
|
+
viewBox: "0 0 24 24",
|
|
45
|
+
width: "24px",
|
|
46
|
+
fill: "currentColor"
|
|
47
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
48
|
+
d: "M0 0h24v24H0V0zm0 0h24v24H0V0z",
|
|
49
|
+
fill: "none"
|
|
50
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
51
|
+
d: "M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z"
|
|
52
|
+
}));
|
|
11
53
|
describe("Table component tests", function () {
|
|
12
54
|
test("Table renders with correct content", function () {
|
|
13
55
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("th", null, "header-1"), /*#__PURE__*/_react["default"].createElement("th", null, "header-2"), /*#__PURE__*/_react["default"].createElement("th", null, "header-3"))), /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-1"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-2"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-4"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-5"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-6"))))),
|
|
14
|
-
|
|
15
|
-
|
|
56
|
+
getByText = _render.getByText;
|
|
16
57
|
expect(getByText("header-1")).toBeTruthy();
|
|
17
58
|
expect(getByText("header-2")).toBeTruthy();
|
|
18
59
|
expect(getByText("header-3")).toBeTruthy();
|
|
@@ -23,4 +64,50 @@ describe("Table component tests", function () {
|
|
|
23
64
|
expect(getByText("cell-5")).toBeTruthy();
|
|
24
65
|
expect(getByText("cell-6")).toBeTruthy();
|
|
25
66
|
});
|
|
67
|
+
test("Table ActionsCell", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
68
|
+
var onSelectOption, onClick, actions, _render2, getAllByRole, getByRole, getByText, dropdown, option, action;
|
|
69
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
70
|
+
while (1) switch (_context.prev = _context.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
onSelectOption = jest.fn();
|
|
73
|
+
onClick = jest.fn();
|
|
74
|
+
actions = [{
|
|
75
|
+
icon: icon,
|
|
76
|
+
title: "icon1",
|
|
77
|
+
onClick: onSelectOption,
|
|
78
|
+
options: [{
|
|
79
|
+
value: "1",
|
|
80
|
+
label: "Amazon"
|
|
81
|
+
}, {
|
|
82
|
+
value: "2",
|
|
83
|
+
label: "Ebay"
|
|
84
|
+
}, {
|
|
85
|
+
value: "3",
|
|
86
|
+
label: "Aliexpress"
|
|
87
|
+
}]
|
|
88
|
+
}, {
|
|
89
|
+
icon: icon,
|
|
90
|
+
title: "icon2",
|
|
91
|
+
onClick: onClick
|
|
92
|
+
}];
|
|
93
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("th", null, "header-1"), /*#__PURE__*/_react["default"].createElement("th", null, "header-2"), /*#__PURE__*/_react["default"].createElement("th", null, "header-3"))), /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-1"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-2"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-4"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-5"), /*#__PURE__*/_react["default"].createElement("td", null, /*#__PURE__*/_react["default"].createElement(_Table["default"].ActionsCell, {
|
|
94
|
+
actions: actions
|
|
95
|
+
})))))), getAllByRole = _render2.getAllByRole, getByRole = _render2.getByRole, getByText = _render2.getByText;
|
|
96
|
+
dropdown = getAllByRole("button")[1];
|
|
97
|
+
(0, _react2.act)(function () {
|
|
98
|
+
_userEvent["default"].click(dropdown);
|
|
99
|
+
});
|
|
100
|
+
expect(getByRole("menu")).toBeTruthy();
|
|
101
|
+
option = getByText("Aliexpress");
|
|
102
|
+
_userEvent["default"].click(option);
|
|
103
|
+
expect(onSelectOption).toHaveBeenCalledWith("3");
|
|
104
|
+
action = getAllByRole("button")[0];
|
|
105
|
+
_userEvent["default"].click(action);
|
|
106
|
+
expect(onClick).toHaveBeenCalled();
|
|
107
|
+
case 13:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
111
|
+
}, _callee);
|
|
112
|
+
})));
|
|
26
113
|
});
|