@dxc-technology/halstack-react 0.0.0-d3554d7 → 0.0.0-d3df47e
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 +1221 -0
- package/HalstackContext.js +310 -0
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +116 -181
- package/accordion/Accordion.stories.tsx +103 -127
- package/accordion/Accordion.test.js +32 -33
- package/accordion/types.d.ts +9 -16
- package/accordion-group/AccordionGroup.d.ts +5 -4
- package/accordion-group/AccordionGroup.js +38 -107
- package/accordion-group/AccordionGroup.stories.tsx +95 -68
- package/accordion-group/AccordionGroup.test.js +55 -90
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +15 -16
- 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 +23 -59
- package/alert/Alert.stories.tsx +28 -0
- 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 +142 -40
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -2
- package/bleed/Bleed.js +14 -55
- package/bleed/Bleed.stories.tsx +95 -95
- package/bleed/types.d.ts +26 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +30 -81
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +2 -7
- package/box/types.d.ts +3 -14
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +89 -0
- package/bulleted-list/BulletedList.stories.tsx +115 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +62 -113
- package/button/Button.stories.tsx +160 -90
- package/button/Button.test.js +20 -17
- package/button/types.d.ts +12 -8
- package/card/Card.d.ts +1 -1
- package/card/Card.js +58 -102
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +11 -22
- package/card/types.d.ts +6 -11
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +144 -182
- package/checkbox/Checkbox.stories.tsx +166 -136
- package/checkbox/Checkbox.test.js +163 -29
- package/checkbox/types.d.ts +18 -6
- package/chip/Chip.js +39 -79
- package/chip/Chip.stories.tsx +121 -26
- 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 +1367 -0
- package/common/variables.js +1002 -1136
- 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.d.ts +4 -0
- package/date-input/Calendar.js +214 -0
- package/date-input/DateInput.js +171 -306
- package/date-input/DateInput.stories.tsx +203 -56
- package/date-input/DateInput.test.js +708 -369
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +115 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +58 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +100 -0
- package/date-input/types.d.ts +86 -22
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +68 -130
- package/dialog/Dialog.stories.tsx +320 -167
- package/dialog/Dialog.test.js +287 -20
- package/dialog/types.d.ts +18 -25
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +243 -304
- package/dropdown/Dropdown.stories.tsx +245 -56
- package/dropdown/Dropdown.test.js +575 -165
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +63 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +67 -0
- package/dropdown/types.d.ts +32 -14
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +246 -357
- package/file-input/FileInput.stories.tsx +123 -12
- package/file-input/FileInput.test.js +369 -367
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +50 -99
- package/file-input/types.d.ts +25 -8
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +112 -0
- package/flex/types.d.ts +97 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +70 -190
- package/footer/Footer.stories.tsx +60 -19
- package/footer/Footer.test.js +33 -57
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +67 -8
- package/footer/types.d.ts +25 -26
- 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/header/Header.d.ts +4 -3
- package/header/Header.js +99 -203
- package/header/Header.stories.tsx +152 -63
- package/header/Header.test.js +31 -28
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +4 -9
- package/header/types.d.ts +5 -19
- 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/inset/Inset.js +14 -55
- package/inset/Inset.stories.tsx +37 -36
- package/inset/types.d.ts +26 -2
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +84 -181
- package/layout/ApplicationLayout.stories.tsx +85 -94
- package/layout/Icons.d.ts +8 -0
- package/layout/Icons.js +51 -48
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +13 -0
- package/layout/types.d.ts +19 -35
- package/link/Link.d.ts +3 -2
- package/link/Link.js +61 -99
- package/link/Link.stories.tsx +155 -53
- package/link/Link.test.js +25 -53
- package/link/types.d.ts +15 -31
- package/main.d.ts +14 -13
- package/main.js +65 -101
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +93 -0
- package/nav-tabs/NavTabs.stories.tsx +276 -0
- package/nav-tabs/NavTabs.test.js +76 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +118 -0
- package/nav-tabs/types.d.ts +52 -0
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +27 -43
- package/number-input/NumberInput.stories.tsx +44 -28
- package/number-input/NumberInput.test.js +703 -381
- package/number-input/types.d.ts +28 -15
- package/package.json +46 -47
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +21 -47
- package/paginator/Paginator.js +34 -91
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +280 -211
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +5 -0
- package/paragraph/Paragraph.js +22 -0
- package/paragraph/Paragraph.stories.tsx +27 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -123
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +162 -147
- package/password-input/types.d.ts +21 -17
- package/progress-bar/ProgressBar.js +65 -91
- package/progress-bar/ProgressBar.stories.tsx +93 -0
- package/progress-bar/ProgressBar.test.js +72 -44
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +94 -0
- package/quick-nav/QuickNav.stories.tsx +356 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +59 -76
- package/radio-group/RadioGroup.js +72 -116
- package/radio-group/RadioGroup.stories.tsx +135 -17
- package/radio-group/RadioGroup.test.js +529 -467
- package/radio-group/types.d.ts +86 -9
- package/resultset-table/Icons.d.ts +7 -0
- package/resultset-table/Icons.js +47 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +1 -1
- package/resultset-table/ResultsetTable.js +165 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +69 -25
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +117 -118
- package/{resultsetTable → resultset-table}/types.d.ts +13 -7
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +89 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +143 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +87 -0
- package/select/Select.js +223 -502
- package/select/Select.stories.tsx +534 -145
- package/select/Select.test.js +2009 -1539
- package/select/types.d.ts +64 -25
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +131 -71
- package/sidenav/Sidenav.stories.tsx +251 -151
- package/sidenav/Sidenav.test.js +26 -45
- package/sidenav/types.d.ts +52 -26
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +148 -180
- package/slider/Slider.test.js +198 -73
- package/slider/types.d.ts +11 -3
- package/spinner/Spinner.js +31 -75
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +53 -27
- 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.d.ts +2 -2
- package/switch/Switch.js +149 -114
- package/switch/Switch.stories.tsx +44 -67
- package/switch/Switch.test.js +146 -39
- package/switch/types.d.ts +13 -5
- package/table/Table.d.ts +1 -1
- package/table/Table.js +25 -32
- package/table/{Table.stories.jsx → Table.stories.tsx} +178 -1
- package/table/Table.test.js +3 -8
- package/table/types.d.ts +12 -6
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +116 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +316 -145
- package/tabs/Tabs.stories.tsx +120 -14
- package/tabs/Tabs.test.js +238 -67
- package/tabs/types.d.ts +29 -15
- package/tag/Tag.js +41 -78
- package/tag/Tag.stories.tsx +25 -8
- package/tag/Tag.test.js +20 -31
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +56 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +67 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +84 -0
- package/text-input/TextInput.js +324 -548
- package/text-input/TextInput.stories.tsx +272 -281
- package/text-input/TextInput.test.js +1425 -1377
- package/text-input/types.d.ts +70 -24
- package/textarea/Textarea.js +82 -134
- package/textarea/Textarea.stories.tsx +174 -0
- package/textarea/Textarea.test.js +168 -198
- package/textarea/types.d.ts +27 -16
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +92 -105
- package/toggle-group/ToggleGroup.stories.tsx +53 -8
- package/toggle-group/ToggleGroup.test.js +78 -66
- package/toggle-group/types.d.ts +34 -17
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +23 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +1119 -1
- package/useTheme.js +4 -11
- package/useTranslatedLabels.d.ts +85 -0
- package/useTranslatedLabels.js +14 -0
- 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.d.ts +1 -1
- package/wizard/Wizard.js +70 -101
- package/wizard/Wizard.stories.tsx +48 -19
- package/wizard/Wizard.test.js +73 -87
- package/wizard/types.d.ts +12 -8
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/progress-bar/ProgressBar.stories.jsx +0 -58
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/resultsetTable/ResultsetTable.js +0 -254
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -10
- package/slider/Slider.stories.tsx +0 -177
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -9
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/textarea/Textarea.stories.jsx +0 -157
- /package/{list → action-icon}/types.js +0 -0
- /package/{radio → bulleted-list}/types.js +0 -0
- /package/{resultsetTable → container}/types.js +0 -0
- /package/{row → flex}/types.js +0 -0
- /package/{stack → grid}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
package/wizard/Wizard.js
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
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
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
15
|
-
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
16
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
|
-
var _variables = require("../common/variables.js");
|
|
23
|
-
|
|
14
|
+
var _variables = require("../common/variables");
|
|
24
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
-
|
|
26
16
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13;
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
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; }
|
|
31
|
-
|
|
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" != _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; }
|
|
32
19
|
var icons = {
|
|
33
20
|
validIcon: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
34
21
|
id: "check_circle_black_18dp",
|
|
@@ -80,81 +67,77 @@ var icons = {
|
|
|
80
67
|
fill: "#d0011b"
|
|
81
68
|
}))
|
|
82
69
|
};
|
|
83
|
-
|
|
84
70
|
var DxcWizard = function DxcWizard(_ref) {
|
|
71
|
+
var _ref2;
|
|
85
72
|
var _ref$mode = _ref.mode,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var _useState = (0, _react.useState)(currentStep
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
73
|
+
mode = _ref$mode === void 0 ? "horizontal" : _ref$mode,
|
|
74
|
+
defaultCurrentStep = _ref.defaultCurrentStep,
|
|
75
|
+
currentStep = _ref.currentStep,
|
|
76
|
+
onStepClick = _ref.onStepClick,
|
|
77
|
+
steps = _ref.steps,
|
|
78
|
+
margin = _ref.margin,
|
|
79
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
80
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
81
|
+
var _useState = (0, _react.useState)((_ref2 = currentStep !== null && currentStep !== void 0 ? currentStep : defaultCurrentStep) !== null && _ref2 !== void 0 ? _ref2 : 0),
|
|
82
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
83
|
+
innerCurrent = _useState2[0],
|
|
84
|
+
setInnerCurrentStep = _useState2[1];
|
|
99
85
|
var renderedCurrent = currentStep == null ? innerCurrent : currentStep;
|
|
100
86
|
var colorsTheme = (0, _useTheme["default"])();
|
|
101
|
-
|
|
102
87
|
var handleStepClick = function handleStepClick(newValue) {
|
|
103
88
|
if (currentStep == null) {
|
|
104
89
|
setInnerCurrentStep(newValue);
|
|
105
90
|
}
|
|
106
|
-
|
|
107
91
|
if (onStepClick) {
|
|
108
92
|
onStepClick(newValue);
|
|
109
93
|
}
|
|
110
94
|
};
|
|
111
|
-
|
|
112
95
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
113
96
|
theme: colorsTheme.wizard
|
|
114
97
|
}, /*#__PURE__*/_react["default"].createElement(StepsContainer, {
|
|
115
98
|
mode: mode,
|
|
116
|
-
margin: margin
|
|
99
|
+
margin: margin,
|
|
100
|
+
role: "group"
|
|
117
101
|
}, steps === null || steps === void 0 ? void 0 : steps.map(function (step, i) {
|
|
118
102
|
return /*#__PURE__*/_react["default"].createElement(StepContainer, {
|
|
119
103
|
key: "step".concat(i),
|
|
120
104
|
mode: mode,
|
|
121
105
|
lastStep: i === (steps === null || steps === void 0 ? void 0 : steps.length) - 1
|
|
122
106
|
}, /*#__PURE__*/_react["default"].createElement(Step, {
|
|
123
|
-
tabIndex: tabIndex,
|
|
124
107
|
onClick: function onClick() {
|
|
125
|
-
|
|
108
|
+
handleStepClick(i);
|
|
126
109
|
},
|
|
127
|
-
mode: mode,
|
|
128
110
|
disabled: step.disabled,
|
|
111
|
+
mode: mode,
|
|
129
112
|
first: i === 0,
|
|
130
|
-
last: i === (steps === null || steps === void 0 ? void 0 : steps.length) - 1
|
|
131
|
-
|
|
113
|
+
last: i === (steps === null || steps === void 0 ? void 0 : steps.length) - 1,
|
|
114
|
+
"aria-current": renderedCurrent === i ? "step" : "false",
|
|
115
|
+
tabIndex: tabIndex
|
|
116
|
+
}, /*#__PURE__*/_react["default"].createElement(StepHeader, {
|
|
117
|
+
validityIcon: step.valid !== undefined
|
|
118
|
+
}, /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
132
119
|
current: i === renderedCurrent,
|
|
133
120
|
visited: i < renderedCurrent,
|
|
134
121
|
disabled: step.disabled
|
|
135
|
-
}, step.icon ? typeof step.icon === "string" ? /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
122
|
+
}, step.icon ? /*#__PURE__*/_react["default"].createElement(StepIconContainer, null, typeof step.icon === "string" ? /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
136
123
|
src: step.icon
|
|
137
|
-
}) : /*#__PURE__*/_react["default"].createElement(
|
|
138
|
-
|
|
139
|
-
}, (0, _typeof2["default"])(step.icon) === "object" ? step.icon : /*#__PURE__*/_react["default"].createElement(step.icon)) : /*#__PURE__*/_react["default"].createElement(Number, {
|
|
140
|
-
disabled: step.disabled,
|
|
141
|
-
current: i === renderedCurrent
|
|
142
|
-
}, i + 1)), step.valid !== undefined ? step.valid ? /*#__PURE__*/_react["default"].createElement(ValidityIconContainer, null, icons.validIcon) : /*#__PURE__*/_react["default"].createElement(ValidityIconContainer, null, icons.invalidIcon) : ""), step.label || step.description ? /*#__PURE__*/_react["default"].createElement(InfoContainer, null, step.label ? /*#__PURE__*/_react["default"].createElement(Label, {
|
|
124
|
+
}) : step.icon) : /*#__PURE__*/_react["default"].createElement(Number, null, i + 1)), step.valid !== undefined && (step.valid ? /*#__PURE__*/_react["default"].createElement(ValidityIconContainer, null, icons.validIcon) : /*#__PURE__*/_react["default"].createElement(ValidityIconContainer, null, icons.invalidIcon))), (step.label || step.description) && /*#__PURE__*/_react["default"].createElement(InfoContainer, null, step.label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
125
|
+
current: i === renderedCurrent,
|
|
143
126
|
disabled: step.disabled,
|
|
144
127
|
visited: i <= innerCurrent
|
|
145
|
-
}, step.label)
|
|
128
|
+
}, step.label), step.description && /*#__PURE__*/_react["default"].createElement(Description, {
|
|
129
|
+
current: i === renderedCurrent,
|
|
146
130
|
disabled: step.disabled,
|
|
147
131
|
visited: i <= innerCurrent
|
|
148
|
-
}, step.description)
|
|
132
|
+
}, step.description))), i === steps.length - 1 ? "" : /*#__PURE__*/_react["default"].createElement(StepSeparator, {
|
|
149
133
|
mode: mode
|
|
150
134
|
}));
|
|
151
135
|
})));
|
|
152
136
|
};
|
|
153
|
-
|
|
154
|
-
var StepsContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: ", ";\n justify-content: \"center\";\n ", ";\n font-family: ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
137
|
+
var StepsContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n justify-content: center;\n ", ";\n font-family: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
155
138
|
return props.mode === "vertical" ? "column" : "row";
|
|
156
139
|
}, function (props) {
|
|
157
|
-
return props.mode === "vertical"
|
|
140
|
+
return props.mode === "vertical" && "height: 500px";
|
|
158
141
|
}, function (props) {
|
|
159
142
|
return props.theme.fontFamily;
|
|
160
143
|
}, function (props) {
|
|
@@ -168,18 +151,16 @@ var StepsContainer = _styledComponents["default"].div(_templateObject || (_templ
|
|
|
168
151
|
}, function (props) {
|
|
169
152
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
170
153
|
});
|
|
171
|
-
|
|
172
154
|
var StepContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n ", "\n flex-grow: ", ";\n flex-direction: ", ";\n ", "\n"])), function (props) {
|
|
173
|
-
return props.mode
|
|
155
|
+
return props.mode !== "vertical" && "align-items: center;";
|
|
174
156
|
}, function (props) {
|
|
175
157
|
return props.lastStep ? "0" : "1";
|
|
176
158
|
}, function (props) {
|
|
177
159
|
return props.mode === "vertical" ? "column" : "row";
|
|
178
160
|
}, function (props) {
|
|
179
|
-
return props.mode === "vertical"
|
|
161
|
+
return props.mode === "vertical" && "width: fit-content;";
|
|
180
162
|
});
|
|
181
|
-
|
|
182
|
-
var Step = _styledComponents["default"].button(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n border: none;\n background: inherit;\n display: flex;\n justify-content: flex-start;\n align-items: center;\n margin: ", ";\n\n padding: 0px;\n ", ";\n\n &:hover {\n ", ";\n }\n &:focus {\n outline: ", " auto 1px;\n }\n"])), function (props) {
|
|
163
|
+
var Step = _styledComponents["default"].button(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: flex-start;\n align-items: center;\n border: none;\n border-radius: 0.25rem;\n background: inherit;\n margin: ", ";\n\n padding: 0px;\n ", ";\n\n &:hover {\n ", ";\n }\n &:focus {\n outline: 2px solid ", ";\n }\n"])), function (props) {
|
|
183
164
|
return props.first ? props.mode === "vertical" ? "0 0 24px 0" : "0 24px 0 0" : props.last ? props.mode === "vertical" ? "24px 0 0 0" : "0 0 0 24px" : props.mode === "vertical" ? "24px 0" : "0 24px";
|
|
184
165
|
}, function (props) {
|
|
185
166
|
return props.disabled ? "cursor: not-allowed" : "";
|
|
@@ -188,49 +169,43 @@ var Step = _styledComponents["default"].button(_templateObject3 || (_templateObj
|
|
|
188
169
|
}, function (props) {
|
|
189
170
|
return props.theme.focusColor;
|
|
190
171
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n\n ", "\n ", ";\n\n border-radius: ", ";\n display: flex;\n justify-content: center;\n align-items: center;\n"])), function (props) {
|
|
195
|
-
return props.disabled ? props.theme.
|
|
172
|
+
var StepHeader = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n display: inline-flex;\n ", "\n"])), function (props) {
|
|
173
|
+
return props.validityIcon && "padding-bottom: 4px;";
|
|
174
|
+
});
|
|
175
|
+
var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n\n ", "\n ", ";\n\n border-radius: ", ";\n\n display: flex;\n justify-content: center;\n align-items: center;\n"])), function (props) {
|
|
176
|
+
return props.disabled ? props.theme.disabledStepWidth : props.current ? props.theme.selectedStepWidth : props.theme.stepWidth;
|
|
196
177
|
}, function (props) {
|
|
197
|
-
return props.disabled ? props.theme.
|
|
178
|
+
return props.disabled ? props.theme.disabledStepHeight : props.current ? props.theme.selectedStepHeight : props.theme.stepHeight;
|
|
198
179
|
}, function (props) {
|
|
199
|
-
return "\n ".concat(
|
|
180
|
+
return "\n ".concat(props.disabled ? "border: ".concat(props.theme.disabledStepBorderThickness, " ").concat(props.theme.disabledStepBorderStyle, " ").concat(props.theme.disabledStepBorderColor, ";") : props.current ? "border: ".concat(props.theme.selectedStepBorderThickness, " ").concat(props.theme.selectedStepBorderStyle, " ").concat(props.theme.selectedStepBorderColor, ";") : props.visited ? "border: ".concat(props.theme.stepBorderThickness, " ").concat(props.theme.stepBorderStyle, " ").concat(props.theme.visitedStepBorderColor, ";") : "border: ".concat(props.theme.stepBorderThickness, " ").concat(props.theme.stepBorderStyle, " ").concat(props.theme.unvisitedStepBorderColor, ";"), "\n background: ").concat(props.disabled ? "".concat(props.theme.disabledStepBackgroundColor) : props.current ? "".concat(props.theme.selectedStepBackgroundColor) : !props.visited ? "".concat(props.theme.unvisitedStepBackgroundColor) : "".concat(props.theme.visitedStepBackgroundColor), ";\n ");
|
|
200
181
|
}, function (props) {
|
|
201
|
-
return props.disabled ? "color: ".concat(props.theme.
|
|
182
|
+
return props.disabled ? "color: ".concat(props.theme.disabledStepFontColor, ";") : "color: ".concat(props.current ? props.theme.selectedStepFontColor : !props.visited ? props.theme.unvisitedStepFontColor : props.theme.visitedStepFontColor, ";");
|
|
202
183
|
}, function (props) {
|
|
203
|
-
return !props.current && !props.disabled ? props.theme.
|
|
184
|
+
return !props.current && !props.disabled ? props.theme.stepBorderRadius : props.current ? props.theme.selectedStepBorderRadius : props.disabled ? props.theme.disabledStepBorderRadius : "";
|
|
204
185
|
});
|
|
205
|
-
|
|
206
186
|
var Icon = _styledComponents["default"].img(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n"])), function (props) {
|
|
207
|
-
return props.theme.
|
|
187
|
+
return props.theme.stepIconSize;
|
|
208
188
|
}, function (props) {
|
|
209
|
-
return props.theme.
|
|
189
|
+
return props.theme.stepIconSize;
|
|
210
190
|
});
|
|
211
|
-
|
|
212
191
|
var StepIconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n overflow: hidden;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
213
|
-
return props.theme.
|
|
192
|
+
return props.theme.stepIconSize;
|
|
214
193
|
}, function (props) {
|
|
215
|
-
return props.theme.
|
|
194
|
+
return props.theme.stepIconSize;
|
|
216
195
|
});
|
|
217
|
-
|
|
218
196
|
var Number = _styledComponents["default"].p(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n opacity: 1;\n margin: 0px 0px 0px 1px;\n"])), function (props) {
|
|
219
|
-
return props.theme.
|
|
197
|
+
return props.theme.stepFontSize;
|
|
220
198
|
}, function (props) {
|
|
221
|
-
return props.theme.
|
|
199
|
+
return props.theme.stepFontFamily;
|
|
222
200
|
}, function (props) {
|
|
223
|
-
return props.theme.
|
|
201
|
+
return props.theme.stepFontStyle;
|
|
224
202
|
}, function (props) {
|
|
225
|
-
return props.theme.
|
|
203
|
+
return props.theme.stepFontWeight;
|
|
226
204
|
}, function (props) {
|
|
227
|
-
return props.theme.
|
|
205
|
+
return props.theme.stepFontTracking;
|
|
228
206
|
});
|
|
229
|
-
|
|
230
207
|
var ValidityIconContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n width: 18px;\n height: 18px;\n position: absolute;\n top: 22.5px;\n left: 22.5px;\n"])));
|
|
231
|
-
|
|
232
208
|
var InfoContainer = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 12px;\n"])));
|
|
233
|
-
|
|
234
209
|
var Label = _styledComponents["default"].p(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n text-align: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n ", ";\n text-transform: ", ";\n margin: 0;\n"])), function (props) {
|
|
235
210
|
return props.theme.labelTextAlign;
|
|
236
211
|
}, function (props) {
|
|
@@ -242,40 +217,34 @@ var Label = _styledComponents["default"].p(_templateObject11 || (_templateObject
|
|
|
242
217
|
}, function (props) {
|
|
243
218
|
return props.theme.labelFontWeight;
|
|
244
219
|
}, function (props) {
|
|
245
|
-
return props.theme.
|
|
220
|
+
return props.theme.labelFontTracking;
|
|
246
221
|
}, function (props) {
|
|
247
|
-
return props.disabled ? "color: ".concat(props.theme.
|
|
222
|
+
return props.disabled ? "color: ".concat(props.theme.disabledLabelFontColor, ";") : "color: ".concat(!props.visited ? props.theme.unvisitedLabelFontColor : props.current ? props.theme.selectedLabelFontColor : props.theme.visitedLabelFontColor, ";");
|
|
248
223
|
}, function (props) {
|
|
249
224
|
return props.theme.labelFontTextTransform;
|
|
250
225
|
});
|
|
251
|
-
|
|
252
226
|
var Description = _styledComponents["default"].p(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["\n text-align: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n ", ";\n margin: 0;\n"])), function (props) {
|
|
253
|
-
return props.theme.
|
|
227
|
+
return props.theme.helperTextTextAlign;
|
|
254
228
|
}, function (props) {
|
|
255
|
-
return props.theme.
|
|
229
|
+
return props.theme.helperTextFontFamily;
|
|
256
230
|
}, function (props) {
|
|
257
|
-
return props.theme.
|
|
231
|
+
return props.theme.helperTextFontSize;
|
|
258
232
|
}, function (props) {
|
|
259
|
-
return props.theme.
|
|
233
|
+
return props.theme.helperTextFontStyle;
|
|
260
234
|
}, function (props) {
|
|
261
|
-
return props.theme.
|
|
235
|
+
return props.theme.helperTextFontWeight;
|
|
262
236
|
}, function (props) {
|
|
263
|
-
return props.theme.
|
|
237
|
+
return props.theme.helperTextFontTracking;
|
|
264
238
|
}, function (props) {
|
|
265
|
-
return props.theme.
|
|
239
|
+
return props.theme.helperTextFontTextTransform;
|
|
266
240
|
}, function (props) {
|
|
267
|
-
return props.disabled ? "color: ".concat(props.theme.
|
|
241
|
+
return props.disabled ? "color: ".concat(props.theme.disabledHelperTextFontColor, ";") : "color: ".concat(!props.visited ? props.theme.unvisitedHelperTextFontColor : props.current ? props.theme.selectedHelperTextFontColor : props.theme.visitedHelperTextFontColor, ";");
|
|
268
242
|
});
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return props.mode === "horizontal" ? "" : "0";
|
|
243
|
+
var StepSeparator = _styledComponents["default"].div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["\n ", ";\n ", "\n border: ", ";\n opacity: 1;\n flex-grow: 1;\n"])), function (props) {
|
|
244
|
+
return props.mode === "horizontal" ? "height: 0;" : "width: 0;";
|
|
272
245
|
}, function (props) {
|
|
273
|
-
return props.mode === "
|
|
274
|
-
}, function (props) {
|
|
275
|
-
return props.mode === "vertical" ? "margin: 0 18px;" : "";
|
|
246
|
+
return props.mode === "vertical" && "margin: 0 18px;";
|
|
276
247
|
}, function (props) {
|
|
277
248
|
return "".concat(props.theme.separatorBorderStyle, " ").concat(props.theme.separatorBorderThickness, " ").concat(props.theme.separatorColor);
|
|
278
249
|
});
|
|
279
|
-
|
|
280
|
-
var _default = DxcWizard;
|
|
281
|
-
exports["default"] = _default;
|
|
250
|
+
var _default = exports["default"] = DxcWizard;
|
|
@@ -3,29 +3,25 @@ import DxcWizard from "./Wizard";
|
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { userEvent, within } from "@storybook/testing-library";
|
|
6
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: "Wizard",
|
|
9
10
|
component: DxcWizard,
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
const favoriteSVG = (
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<path d="M0 0h24v24H0z" fill="none" />
|
|
25
|
-
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" />
|
|
26
|
-
</svg>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
13
|
+
const favoriteSVG = (
|
|
14
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
15
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
16
|
+
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
const largeIcon = (
|
|
20
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
|
|
21
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
22
|
+
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" />
|
|
23
|
+
</svg>
|
|
24
|
+
);
|
|
29
25
|
|
|
30
26
|
const stepWithLabel = [
|
|
31
27
|
{
|
|
@@ -137,19 +133,41 @@ const stepLargeIcons = [
|
|
|
137
133
|
},
|
|
138
134
|
];
|
|
139
135
|
|
|
136
|
+
const opinionatedTheme = {
|
|
137
|
+
wizard: {
|
|
138
|
+
baseColor: "#5f249f",
|
|
139
|
+
fontColor: "#000000",
|
|
140
|
+
selectedStepFontColor: "#ffffff",
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
140
144
|
export const Chromatic = () => (
|
|
141
145
|
<>
|
|
142
146
|
<ExampleContainer>
|
|
143
147
|
<Title title="Current step in the third step, labels and description" theme="light" level={4} />
|
|
144
|
-
<DxcWizard
|
|
148
|
+
<DxcWizard defaultCurrentStep={2} steps={stepWithLabelDescription}></DxcWizard>
|
|
149
|
+
</ExampleContainer>
|
|
150
|
+
<ExampleContainer>
|
|
145
151
|
<Title title="With long description in horizontal" theme="light" level={4} />
|
|
146
152
|
<DxcWizard steps={stepWithLongDescription}></DxcWizard>
|
|
153
|
+
</ExampleContainer>
|
|
154
|
+
<ExampleContainer>
|
|
147
155
|
<Title title="With long description in vertical" theme="light" level={4} />
|
|
148
156
|
<DxcWizard mode="vertical" steps={stepWithLongDescription}></DxcWizard>
|
|
157
|
+
</ExampleContainer>
|
|
158
|
+
<ExampleContainer>
|
|
149
159
|
<Title title="Disabled steps" theme="light" level={4} />
|
|
150
160
|
<DxcWizard steps={stepDisabled}></DxcWizard>
|
|
161
|
+
</ExampleContainer>
|
|
162
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
163
|
+
<Title title="Focused steps" theme="light" level={4} />
|
|
164
|
+
<DxcWizard steps={stepIcons}></DxcWizard>
|
|
165
|
+
</ExampleContainer>
|
|
166
|
+
<ExampleContainer>
|
|
151
167
|
<Title title="With icons" theme="light" level={4} />
|
|
152
168
|
<DxcWizard steps={stepIcons}></DxcWizard>
|
|
169
|
+
</ExampleContainer>
|
|
170
|
+
<ExampleContainer>
|
|
153
171
|
<Title title="With large icons" theme="light" level={4} />
|
|
154
172
|
<DxcWizard steps={stepLargeIcons}></DxcWizard>
|
|
155
173
|
</ExampleContainer>
|
|
@@ -211,10 +229,21 @@ export const Chromatic = () => (
|
|
|
211
229
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
212
230
|
<DxcWizard mode="vertical" margin="xxlarge" steps={stepWithLabel}></DxcWizard>
|
|
213
231
|
</ExampleContainer>
|
|
232
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
233
|
+
<ExampleContainer>
|
|
234
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
235
|
+
<DxcWizard defaultCurrentStep={2} steps={stepWithLabelDescription}></DxcWizard>
|
|
236
|
+
</HalstackProvider>
|
|
237
|
+
</ExampleContainer>
|
|
214
238
|
</>
|
|
215
239
|
);
|
|
216
240
|
|
|
217
|
-
const WizardSelected = () =>
|
|
241
|
+
const WizardSelected = () => (
|
|
242
|
+
<ExampleContainer>
|
|
243
|
+
<Title title="Clicked step" theme="light" level={4} />
|
|
244
|
+
<DxcWizard steps={stepWithLabel} mode="vertical"></DxcWizard>
|
|
245
|
+
</ExampleContainer>
|
|
246
|
+
);
|
|
218
247
|
|
|
219
248
|
export const WizardStepActived = WizardSelected.bind({});
|
|
220
249
|
WizardStepActived.play = async ({ canvasElement }) => {
|
package/wizard/Wizard.test.js
CHANGED
|
@@ -1,128 +1,114 @@
|
|
|
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
|
-
var _Wizard = _interopRequireDefault(require("./Wizard"));
|
|
10
|
-
|
|
6
|
+
var _Wizard = _interopRequireDefault(require("./Wizard.tsx"));
|
|
11
7
|
describe("Wizard components tests", function () {
|
|
12
8
|
test("Wizard renders with correct steps", function () {
|
|
13
9
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Wizard["default"], {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
steps: [{
|
|
11
|
+
label: "first-step"
|
|
12
|
+
}, {
|
|
13
|
+
label: "second-step"
|
|
14
|
+
}]
|
|
15
|
+
})),
|
|
16
|
+
getByText = _render.getByText,
|
|
17
|
+
getAllByRole = _render.getAllByRole;
|
|
18
|
+
var steps = getAllByRole("button");
|
|
22
19
|
expect(getByText("first-step")).toBeTruthy();
|
|
23
20
|
expect(getByText("second-step")).toBeTruthy();
|
|
21
|
+
expect(steps[0].getAttribute("aria-current")).toBe("step");
|
|
22
|
+
expect(steps[1].getAttribute("aria-current")).toBe("false");
|
|
23
|
+
});
|
|
24
|
+
test("Wizard renders with initially selected step", function () {
|
|
25
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Wizard["default"], {
|
|
26
|
+
defaultCurrentStep: 1,
|
|
27
|
+
steps: [{
|
|
28
|
+
label: "first-step"
|
|
29
|
+
}, {
|
|
30
|
+
label: "second-step"
|
|
31
|
+
}]
|
|
32
|
+
})),
|
|
33
|
+
getAllByRole = _render2.getAllByRole;
|
|
34
|
+
var steps = getAllByRole("button");
|
|
35
|
+
expect(steps[1].getAttribute("aria-current")).toBe("step");
|
|
24
36
|
});
|
|
25
37
|
test("Click on step text", function () {
|
|
26
38
|
var onClick = jest.fn();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getByText = _render2.getByText;
|
|
35
|
-
|
|
39
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Wizard["default"], {
|
|
40
|
+
onStepClick: onClick,
|
|
41
|
+
steps: [{
|
|
42
|
+
label: "first-step"
|
|
43
|
+
}]
|
|
44
|
+
})),
|
|
45
|
+
getByText = _render3.getByText;
|
|
36
46
|
var step = getByText("first-step");
|
|
37
|
-
|
|
38
47
|
_react2.fireEvent.click(step);
|
|
39
|
-
|
|
40
48
|
expect(onClick).toHaveBeenCalled();
|
|
41
49
|
});
|
|
42
50
|
test("Click on step description", function () {
|
|
43
51
|
var onClick = jest.fn();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getByText = _render3.getByText;
|
|
53
|
-
|
|
52
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Wizard["default"], {
|
|
53
|
+
onStepClick: onClick,
|
|
54
|
+
steps: [{
|
|
55
|
+
label: "first-step",
|
|
56
|
+
description: "step-description"
|
|
57
|
+
}]
|
|
58
|
+
})),
|
|
59
|
+
getByText = _render4.getByText;
|
|
54
60
|
var step = getByText("step-description");
|
|
55
|
-
|
|
56
61
|
_react2.fireEvent.click(step);
|
|
57
|
-
|
|
58
62
|
expect(onClick).toHaveBeenCalled();
|
|
59
63
|
});
|
|
60
64
|
test("Click on step number", function () {
|
|
61
65
|
var onClick = jest.fn();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
getByText = _render4.getByText;
|
|
70
|
-
|
|
66
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Wizard["default"], {
|
|
67
|
+
onStepClick: onClick,
|
|
68
|
+
steps: [{
|
|
69
|
+
label: "first-step"
|
|
70
|
+
}]
|
|
71
|
+
})),
|
|
72
|
+
getByText = _render5.getByText;
|
|
71
73
|
var step = getByText("1");
|
|
72
|
-
|
|
73
74
|
_react2.fireEvent.click(step);
|
|
74
|
-
|
|
75
75
|
expect(onClick).toHaveBeenCalled();
|
|
76
76
|
});
|
|
77
77
|
test("Click on disable step", function () {
|
|
78
78
|
var onClick = jest.fn();
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
getByText = _render5.getByText;
|
|
90
|
-
|
|
79
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Wizard["default"], {
|
|
80
|
+
onStepClick: onClick,
|
|
81
|
+
steps: [{
|
|
82
|
+
label: "first-step"
|
|
83
|
+
}, {
|
|
84
|
+
label: "second-step",
|
|
85
|
+
disabled: true
|
|
86
|
+
}]
|
|
87
|
+
})),
|
|
88
|
+
getByText = _render6.getByText;
|
|
91
89
|
var step = getByText("second-step");
|
|
92
|
-
|
|
93
90
|
_react2.fireEvent.click(step);
|
|
94
|
-
|
|
95
91
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
96
92
|
});
|
|
97
93
|
test("Controlled wizard function is called", function () {
|
|
98
94
|
var onClick = jest.fn(function (i) {
|
|
99
95
|
return i;
|
|
100
96
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
_react2.fireEvent.click(step2);
|
|
119
|
-
|
|
120
|
-
_react2.fireEvent.click(step1);
|
|
121
|
-
|
|
122
|
-
expect(onClick).toHaveBeenCalledTimes(3); //Test the received value in the onClick function
|
|
123
|
-
|
|
124
|
-
expect(onClick).toHaveBeenNthCalledWith(1, 0);
|
|
125
|
-
expect(onClick).toHaveBeenNthCalledWith(2, 1);
|
|
126
|
-
expect(onClick).toHaveBeenNthCalledWith(3, 0);
|
|
97
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Wizard["default"], {
|
|
98
|
+
currentStep: 0,
|
|
99
|
+
onStepClick: onClick,
|
|
100
|
+
steps: [{
|
|
101
|
+
label: "first-step"
|
|
102
|
+
}, {
|
|
103
|
+
label: "second-step"
|
|
104
|
+
}]
|
|
105
|
+
})),
|
|
106
|
+
getAllByRole = _render7.getAllByRole;
|
|
107
|
+
var steps = getAllByRole("button");
|
|
108
|
+
_react2.fireEvent.click(steps[1]);
|
|
109
|
+
_react2.fireEvent.click(steps[0]);
|
|
110
|
+
expect(onClick).toHaveBeenCalledTimes(2);
|
|
111
|
+
expect(onClick).toHaveBeenNthCalledWith(1, 1);
|
|
112
|
+
expect(onClick).toHaveBeenNthCalledWith(2, 0);
|
|
127
113
|
});
|
|
128
114
|
});
|