@dxc-technology/halstack-react 0.0.0-ee92231 → 0.0.0-efa7c74
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/alert/Alert.stories.tsx +170 -0
- package/alert/types.d.ts +1 -1
- package/box/Box.d.ts +1 -1
- package/box/Box.js +2 -5
- package/box/types.d.ts +0 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +4 -2
- package/button/Button.stories.tsx +216 -233
- package/button/types.d.ts +2 -2
- package/card/Card.js +4 -5
- package/card/Card.stories.tsx +201 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +4 -6
- package/checkbox/types.d.ts +1 -1
- package/chip/Chip.stories.tsx +121 -0
- package/common/variables.js +13 -5
- package/date-input/DateInput.stories.tsx +138 -0
- package/dialog/Dialog.stories.tsx +212 -0
- package/file-input/FileInput.d.ts +4 -0
- package/file-input/FileInput.js +7 -28
- package/file-input/FileItem.d.ts +14 -0
- package/file-input/FileItem.js +4 -15
- package/file-input/types.d.ts +87 -0
- package/file-input/types.js +5 -0
- package/footer/types.d.ts +1 -1
- package/header/Header.stories.tsx +162 -0
- package/header/types.d.ts +4 -2
- package/heading/Heading.d.ts +4 -0
- package/heading/Heading.js +6 -23
- package/heading/Heading.stories.tsx +53 -0
- package/heading/types.d.ts +33 -0
- package/heading/types.js +5 -0
- package/link/Link.js +2 -2
- package/link/Link.stories.tsx +146 -0
- package/number-input/NumberInput.d.ts +4 -0
- package/number-input/NumberInput.js +2 -44
- package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +0 -0
- package/number-input/NumberInputContext.d.ts +4 -0
- package/number-input/NumberInputContext.js +5 -2
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/number-input/types.d.ts +117 -0
- package/number-input/types.js +5 -0
- package/package.json +1 -1
- package/password-input/types.d.ts +13 -8
- package/radio/types.d.ts +2 -2
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +0 -25
- package/resultsetTable/types.d.ts +63 -0
- package/resultsetTable/types.js +5 -0
- package/select/Select.stories.tsx +572 -0
- package/sidenav/Sidenav.d.ts +9 -0
- package/sidenav/Sidenav.js +4 -13
- package/sidenav/Sidenav.stories.tsx +165 -0
- package/sidenav/types.d.ts +50 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +41 -30
- package/slider/Slider.stories.tsx +177 -0
- package/slider/types.d.ts +2 -7
- package/table/Table.js +1 -1
- package/tabs/Tabs.js +3 -1
- package/tabs/Tabs.stories.tsx +121 -0
- package/tabs/types.d.ts +2 -3
- package/tag/Tag.d.ts +4 -0
- package/tag/Tag.js +3 -24
- package/tag/{Tag.stories.jsx → Tag.stories.tsx} +0 -0
- package/tag/types.d.ts +60 -0
- package/tag/types.js +5 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +4 -44
- package/text-input/types.d.ts +157 -0
- package/text-input/types.js +5 -0
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +5 -31
- package/toggle-group/ToggleGroup.stories.tsx +178 -0
- package/toggle-group/types.d.ts +84 -0
- package/toggle-group/types.js +5 -0
- package/wizard/Wizard.d.ts +4 -0
- package/wizard/Wizard.js +11 -51
- package/wizard/Wizard.stories.jsx +224 -0
- package/wizard/types.d.ts +64 -0
- package/wizard/types.js +5 -0
- package/file-input/index.d.ts +0 -81
- package/heading/index.d.ts +0 -17
- package/number-input/index.d.ts +0 -113
- package/resultsetTable/index.d.ts +0 -19
- package/sidenav/index.d.ts +0 -13
- package/tag/index.d.ts +0 -24
- package/text-input/index.d.ts +0 -135
- package/toggle-group/index.d.ts +0 -21
- package/wizard/index.d.ts +0 -18
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
3
|
+
import DxcToggleGroup from "./ToggleGroup";
|
|
4
|
+
import Title from "../../.storybook/components/Title";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "ToggleGroup",
|
|
9
|
+
component: DxcToggleGroup,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const ethernetSVG = () => {
|
|
13
|
+
return (
|
|
14
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
15
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
16
|
+
<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" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
const gMobileSVG = () => {
|
|
21
|
+
return (
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
23
|
+
<g>
|
|
24
|
+
<path d="M0,0h24v24H0V0z" fill="none" />
|
|
25
|
+
</g>
|
|
26
|
+
<g>
|
|
27
|
+
<g>
|
|
28
|
+
<path d="M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z" />
|
|
29
|
+
</g>
|
|
30
|
+
</g>
|
|
31
|
+
</svg>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
const wifiSVG = () => {
|
|
35
|
+
return (
|
|
36
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
37
|
+
<path d="M0 0h24v24H0V0zm0 0h24v24H0V0z" fill="none" />
|
|
38
|
+
<path 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" />
|
|
39
|
+
</svg>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
const options = [
|
|
43
|
+
{
|
|
44
|
+
value: 1,
|
|
45
|
+
label: "Facebook",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: 2,
|
|
49
|
+
label: "Twitter",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
value: 3,
|
|
53
|
+
label: "Linkedin",
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
const optionsWithIcon = [
|
|
57
|
+
{
|
|
58
|
+
value: 1,
|
|
59
|
+
icon: wifiSVG,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: 2,
|
|
63
|
+
icon: ethernetSVG,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: 3,
|
|
67
|
+
icon: gMobileSVG,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
const optionsWithIconAndLabel = [
|
|
71
|
+
{
|
|
72
|
+
value: 1,
|
|
73
|
+
label: "Wi-fi",
|
|
74
|
+
icon: wifiSVG,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
value: 2,
|
|
78
|
+
label: "Ethernet",
|
|
79
|
+
icon: ethernetSVG,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
value: 3,
|
|
83
|
+
label: "3G Mobile",
|
|
84
|
+
icon: gMobileSVG,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
const twoOptions = [
|
|
88
|
+
{
|
|
89
|
+
value: 1,
|
|
90
|
+
label: "Facebook",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
value: 2,
|
|
94
|
+
label: "Twitter",
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
export const Chromatic = () => (
|
|
98
|
+
<>
|
|
99
|
+
<ExampleContainer>
|
|
100
|
+
<Title title="Basic toggle group" theme="light" level={4} />
|
|
101
|
+
<DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />
|
|
102
|
+
</ExampleContainer>
|
|
103
|
+
<ExampleContainer>
|
|
104
|
+
<Title title="Selected" theme="light" level={4} />
|
|
105
|
+
<DxcToggleGroup label="Selected" helperText="HelperText" value={2} options={options} />
|
|
106
|
+
</ExampleContainer>
|
|
107
|
+
<ExampleContainer>
|
|
108
|
+
<Title title="Icons toggle group" theme="light" level={4} />
|
|
109
|
+
<DxcToggleGroup label="Icons group" options={optionsWithIcon} />
|
|
110
|
+
</ExampleContainer>
|
|
111
|
+
<ExampleContainer>
|
|
112
|
+
<Title title="Icons & label toggle group" theme="light" level={4} />
|
|
113
|
+
<DxcToggleGroup label="Icons & label" options={optionsWithIconAndLabel} />
|
|
114
|
+
</ExampleContainer>
|
|
115
|
+
<ExampleContainer>
|
|
116
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
117
|
+
<DxcToggleGroup label="Disabled" value={2} options={options} disabled />
|
|
118
|
+
</ExampleContainer>
|
|
119
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
120
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
121
|
+
<DxcToggleGroup label="Hovered" options={twoOptions} value={2} />
|
|
122
|
+
</ExampleContainer>
|
|
123
|
+
<ExampleContainer>
|
|
124
|
+
<Title title="Multiple toggleGroup" theme="light" level={4} />
|
|
125
|
+
<DxcToggleGroup
|
|
126
|
+
label="Toggle group"
|
|
127
|
+
helperText="Please select one or more"
|
|
128
|
+
options={options}
|
|
129
|
+
value={[1, 3]}
|
|
130
|
+
multiple
|
|
131
|
+
></DxcToggleGroup>
|
|
132
|
+
</ExampleContainer>
|
|
133
|
+
<Title title="Margins" theme="light" level={2} />
|
|
134
|
+
<ExampleContainer>
|
|
135
|
+
<Title title="xxSmall" theme="light" level={4} />
|
|
136
|
+
<DxcToggleGroup label="xxSmall margin" options={options} margin="xxsmall" />
|
|
137
|
+
</ExampleContainer>
|
|
138
|
+
<ExampleContainer>
|
|
139
|
+
<Title title="xSmall" theme="light" level={4} />
|
|
140
|
+
<DxcToggleGroup label="xSmall margin" options={options} margin="xsmall" />
|
|
141
|
+
</ExampleContainer>
|
|
142
|
+
<ExampleContainer>
|
|
143
|
+
<Title title="Small" theme="light" level={4} />
|
|
144
|
+
<DxcToggleGroup label="Small margin" options={options} margin="small" />
|
|
145
|
+
</ExampleContainer>
|
|
146
|
+
<ExampleContainer>
|
|
147
|
+
<Title title="Medium" theme="light" level={4} />
|
|
148
|
+
<DxcToggleGroup label="Medium margin" options={options} margin="medium" />
|
|
149
|
+
</ExampleContainer>
|
|
150
|
+
<ExampleContainer>
|
|
151
|
+
<Title title="Large" theme="light" level={4} />
|
|
152
|
+
<DxcToggleGroup label="Large margin" options={options} margin="large" />
|
|
153
|
+
</ExampleContainer>
|
|
154
|
+
<ExampleContainer>
|
|
155
|
+
<Title title="xLarge" theme="light" level={4} />
|
|
156
|
+
<DxcToggleGroup label="xLarge margin" options={options} margin="xlarge" />
|
|
157
|
+
</ExampleContainer>
|
|
158
|
+
<ExampleContainer>
|
|
159
|
+
<Title title="xxLarge" theme="light" level={4} />
|
|
160
|
+
<DxcToggleGroup label="xxLarge margin" options={options} margin="xxlarge" />
|
|
161
|
+
</ExampleContainer>
|
|
162
|
+
</>
|
|
163
|
+
);
|
|
164
|
+
const OptionSelected = () => <DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />;
|
|
165
|
+
|
|
166
|
+
export const ToggleGroupSelectedActived = OptionSelected.bind({});
|
|
167
|
+
ToggleGroupSelectedActived.play = async ({ canvasElement }) => {
|
|
168
|
+
const canvas = within(canvasElement);
|
|
169
|
+
const option = canvas.getByText("Linkedin");
|
|
170
|
+
await userEvent.click(option);
|
|
171
|
+
};
|
|
172
|
+
export const ToggleGroupUnselectedActived = OptionSelected.bind({});
|
|
173
|
+
ToggleGroupUnselectedActived.play = async ({ canvasElement }) => {
|
|
174
|
+
const canvas = within(canvasElement);
|
|
175
|
+
const option = canvas.getByText("Twitter");
|
|
176
|
+
await userEvent.click(option);
|
|
177
|
+
userEvent.tab();
|
|
178
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Margin = {
|
|
4
|
+
top?: Space;
|
|
5
|
+
bottom?: Space;
|
|
6
|
+
left?: Space;
|
|
7
|
+
right?: Space;
|
|
8
|
+
};
|
|
9
|
+
declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
|
|
10
|
+
declare type OptionCommons = {
|
|
11
|
+
/**
|
|
12
|
+
* Number with the option inner value.
|
|
13
|
+
*/
|
|
14
|
+
value: string;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated URL of the icon that will be placed. IconSrc and label can't be used at same time.
|
|
17
|
+
*/
|
|
18
|
+
iconSrc?: string;
|
|
19
|
+
};
|
|
20
|
+
declare type OptionIcon = OptionCommons & {
|
|
21
|
+
/**
|
|
22
|
+
* String with the option display value.
|
|
23
|
+
*/
|
|
24
|
+
label?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Element used as the icon. Icon and label can't be used at same time.
|
|
27
|
+
*/
|
|
28
|
+
icon: SVG;
|
|
29
|
+
};
|
|
30
|
+
declare type OptionLabel = OptionCommons & {
|
|
31
|
+
/**
|
|
32
|
+
* String with the option display value.
|
|
33
|
+
*/
|
|
34
|
+
label: string;
|
|
35
|
+
/**
|
|
36
|
+
* Element used as the icon. Icon and label can't be used at same time.
|
|
37
|
+
*/
|
|
38
|
+
icon?: SVG;
|
|
39
|
+
};
|
|
40
|
+
declare type Option = OptionIcon | OptionLabel;
|
|
41
|
+
declare type Props = {
|
|
42
|
+
/**
|
|
43
|
+
* Text to be placed above the component.
|
|
44
|
+
*/
|
|
45
|
+
label?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Helper text to be placed above the component.
|
|
48
|
+
*/
|
|
49
|
+
helperText?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The key(s) of the selected value(s). If the toggle group component doesn't allow multiple selection,
|
|
52
|
+
* it must be one unique value. If the component allows multiple selection, value must be an array.
|
|
53
|
+
* If undefined, the component will be uncontrolled and the value will be managed internally by the component.
|
|
54
|
+
*/
|
|
55
|
+
value?: string | string[];
|
|
56
|
+
/**
|
|
57
|
+
* This function will be called every time the selection changes. The number with the key of the selected
|
|
58
|
+
* value will be passed as a parameter to this function.
|
|
59
|
+
* If multiple selection is allowed, an array of keys will be passed.
|
|
60
|
+
*/
|
|
61
|
+
onChange?: (optionIndex: number | number[]) => void;
|
|
62
|
+
/**
|
|
63
|
+
* If true, the component will be disabled.
|
|
64
|
+
*/
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* An array of objects representing the selectable options.
|
|
68
|
+
*/
|
|
69
|
+
options: [Option, ...Option[]];
|
|
70
|
+
/**
|
|
71
|
+
* If true, the toggle group will support multiple selection. In that case, value must be an array of numbers with the keys of the selected values.
|
|
72
|
+
*/
|
|
73
|
+
multiple?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
76
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
77
|
+
*/
|
|
78
|
+
margin?: Space | Margin;
|
|
79
|
+
/**
|
|
80
|
+
* Value of the tabindex.
|
|
81
|
+
*/
|
|
82
|
+
tabIndex?: number;
|
|
83
|
+
};
|
|
84
|
+
export default Props;
|
package/wizard/Wizard.js
CHANGED
|
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
13
|
|
|
16
14
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
@@ -21,15 +19,13 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
21
19
|
|
|
22
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
23
21
|
|
|
24
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
-
|
|
26
22
|
var _variables = require("../common/variables.js");
|
|
27
23
|
|
|
28
24
|
var _useTheme = _interopRequireDefault(require("../useTheme.js"));
|
|
29
25
|
|
|
30
26
|
var _Icons = require("./Icons");
|
|
31
27
|
|
|
32
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13
|
|
28
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13;
|
|
33
29
|
|
|
34
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
31
|
|
|
@@ -68,11 +64,11 @@ var DxcWizard = function DxcWizard(_ref) {
|
|
|
68
64
|
}, /*#__PURE__*/_react["default"].createElement(StepsContainer, {
|
|
69
65
|
mode: mode,
|
|
70
66
|
margin: margin
|
|
71
|
-
}, steps.map(function (step, i) {
|
|
67
|
+
}, steps === null || steps === void 0 ? void 0 : steps.map(function (step, i) {
|
|
72
68
|
return /*#__PURE__*/_react["default"].createElement(StepContainer, {
|
|
73
69
|
key: "step".concat(i),
|
|
74
70
|
mode: mode,
|
|
75
|
-
lastStep: i === steps.length - 1
|
|
71
|
+
lastStep: i === (steps === null || steps === void 0 ? void 0 : steps.length) - 1
|
|
76
72
|
}, /*#__PURE__*/_react["default"].createElement(Step, {
|
|
77
73
|
tabIndex: tabIndex,
|
|
78
74
|
onClick: function onClick() {
|
|
@@ -81,17 +77,14 @@ var DxcWizard = function DxcWizard(_ref) {
|
|
|
81
77
|
mode: mode,
|
|
82
78
|
disabled: step.disabled,
|
|
83
79
|
first: i === 0,
|
|
84
|
-
last: i === steps.length - 1
|
|
80
|
+
last: i === (steps === null || steps === void 0 ? void 0 : steps.length) - 1
|
|
85
81
|
}, /*#__PURE__*/_react["default"].createElement(StepHeader, null, /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
86
82
|
current: i === renderedCurrent,
|
|
87
83
|
visited: i < renderedCurrent,
|
|
88
84
|
disabled: step.disabled
|
|
89
85
|
}, step.icon ? /*#__PURE__*/_react["default"].createElement(StepIconContainer, {
|
|
90
86
|
disabled: step.disabled
|
|
91
|
-
}, (0, _typeof2["default"])(step.icon) === "object" ? step.icon
|
|
92
|
-
current: i === renderedCurrent,
|
|
93
|
-
img: step.icon.props.src
|
|
94
|
-
}) : step.icon : /*#__PURE__*/_react["default"].createElement(step.icon)) : step.iconSrc ? /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
87
|
+
}, (0, _typeof2["default"])(step.icon) === "object" ? step.icon : /*#__PURE__*/_react["default"].createElement(step.icon)) : step.iconSrc ? /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
95
88
|
src: step.iconSrc
|
|
96
89
|
}) : /*#__PURE__*/_react["default"].createElement(Number, {
|
|
97
90
|
disabled: step.disabled,
|
|
@@ -172,20 +165,7 @@ var StepIconContainer = _styledComponents["default"].div(_templateObject7 || (_t
|
|
|
172
165
|
return props.theme.stepContainerIconSize;
|
|
173
166
|
});
|
|
174
167
|
|
|
175
|
-
var
|
|
176
|
-
return props.current ? props.theme.stepContainerSelectedFontColor : props.theme.stepContainerFontColor;
|
|
177
|
-
}, function (_ref2) {
|
|
178
|
-
var img = _ref2.img;
|
|
179
|
-
return img;
|
|
180
|
-
}, function (props) {
|
|
181
|
-
return "".concat(props.theme.stepContainerIconSize, " ").concat(props.theme.stepContainerIconSize);
|
|
182
|
-
}, function (props) {
|
|
183
|
-
return props.theme.stepContainerIconSize;
|
|
184
|
-
}, function (props) {
|
|
185
|
-
return props.theme.stepContainerIconSize;
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
var Number = _styledComponents["default"].p(_templateObject9 || (_templateObject9 = (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) {
|
|
168
|
+
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) {
|
|
189
169
|
return props.theme.stepContainerFontSize;
|
|
190
170
|
}, function (props) {
|
|
191
171
|
return props.theme.stepContainerFontFamily;
|
|
@@ -197,11 +177,11 @@ var Number = _styledComponents["default"].p(_templateObject9 || (_templateObject
|
|
|
197
177
|
return props.theme.stepContainerLetterSpacing;
|
|
198
178
|
});
|
|
199
179
|
|
|
200
|
-
var ValidityIconContainer = _styledComponents["default"].div(
|
|
180
|
+
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"])));
|
|
201
181
|
|
|
202
|
-
var InfoContainer = _styledComponents["default"].div(
|
|
182
|
+
var InfoContainer = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 12px;\n"])));
|
|
203
183
|
|
|
204
|
-
var Label = _styledComponents["default"].p(
|
|
184
|
+
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) {
|
|
205
185
|
return props.theme.labelTextAlign;
|
|
206
186
|
}, function (props) {
|
|
207
187
|
return props.theme.labelFontFamily;
|
|
@@ -219,7 +199,7 @@ var Label = _styledComponents["default"].p(_templateObject12 || (_templateObject
|
|
|
219
199
|
return props.theme.labelFontTextTransform;
|
|
220
200
|
});
|
|
221
201
|
|
|
222
|
-
var Description = _styledComponents["default"].p(
|
|
202
|
+
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) {
|
|
223
203
|
return props.theme.descriptionTextAlign;
|
|
224
204
|
}, function (props) {
|
|
225
205
|
return props.theme.descriptionFontFamily;
|
|
@@ -237,7 +217,7 @@ var Description = _styledComponents["default"].p(_templateObject13 || (_template
|
|
|
237
217
|
return props.disabled ? "color: ".concat(props.theme.disabledFontColor, ";") : "color: ".concat(props.visited ? props.theme.visitedDescriptionFontColor : props.theme.descriptionFontColor, ";");
|
|
238
218
|
});
|
|
239
219
|
|
|
240
|
-
var StepSeparator = _styledComponents["default"].div(
|
|
220
|
+
var StepSeparator = _styledComponents["default"].div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", "\n border: ", ";\n opacity: 1;\n flex-grow: 1;\n"])), function (props) {
|
|
241
221
|
return props.mode === "horizontal" ? "" : "0";
|
|
242
222
|
}, function (props) {
|
|
243
223
|
return props.mode === "horizontal" ? "0" : "";
|
|
@@ -247,25 +227,5 @@ var StepSeparator = _styledComponents["default"].div(_templateObject14 || (_temp
|
|
|
247
227
|
return "".concat(props.theme.separatorBorderStyle, " ").concat(props.theme.separatorBorderThickness, " ").concat(props.theme.separatorColor);
|
|
248
228
|
});
|
|
249
229
|
|
|
250
|
-
DxcWizard.propTypes = {
|
|
251
|
-
mode: _propTypes["default"].oneOf(["horizontal", "vertical"]),
|
|
252
|
-
currentStep: _propTypes["default"].number,
|
|
253
|
-
onStepClick: _propTypes["default"].func,
|
|
254
|
-
steps: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
255
|
-
label: _propTypes["default"].string,
|
|
256
|
-
description: _propTypes["default"].string,
|
|
257
|
-
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
|
|
258
|
-
iconSrc: _propTypes["default"].string,
|
|
259
|
-
disabled: _propTypes["default"].bool,
|
|
260
|
-
valid: _propTypes["default"].bool
|
|
261
|
-
})),
|
|
262
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
263
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
264
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
265
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
266
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
267
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
268
|
-
tabIndex: _propTypes["default"].number
|
|
269
|
-
};
|
|
270
230
|
var _default = DxcWizard;
|
|
271
231
|
exports["default"] = _default;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import DxcWizard from "./Wizard";
|
|
3
|
+
import Title from "../../.storybook/components/Title";
|
|
4
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Wizard",
|
|
9
|
+
component: DxcWizard,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const favoriteSVG = () => {
|
|
13
|
+
return (
|
|
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
|
+
};
|
|
20
|
+
|
|
21
|
+
const largeIcon = () => {
|
|
22
|
+
return (
|
|
23
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
|
|
24
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
25
|
+
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" />
|
|
26
|
+
</svg>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const stepWithLabel = [
|
|
31
|
+
{
|
|
32
|
+
label: "First step",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Second step",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: "Third step",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: "Forth step",
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const stepWithLabelDescription = [
|
|
46
|
+
{
|
|
47
|
+
label: "First step",
|
|
48
|
+
description: "Description",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: "Second step",
|
|
52
|
+
description: "Description",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "Third step",
|
|
56
|
+
description: "Description",
|
|
57
|
+
valid: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: "Forth step",
|
|
61
|
+
description: "Description",
|
|
62
|
+
valid: false,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const stepWithLongDescription = [
|
|
67
|
+
{
|
|
68
|
+
label: "First step",
|
|
69
|
+
description:
|
|
70
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: "Second step",
|
|
74
|
+
description:
|
|
75
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
label: "Third step",
|
|
79
|
+
description:
|
|
80
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ",
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
const stepDisabled = [
|
|
85
|
+
{
|
|
86
|
+
label: "First step",
|
|
87
|
+
description: "Description",
|
|
88
|
+
disabled: true,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: "Second step",
|
|
92
|
+
description: "Description",
|
|
93
|
+
icon: favoriteSVG,
|
|
94
|
+
disabled: true,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
label: "Third step",
|
|
98
|
+
description: "Description",
|
|
99
|
+
disabled: true,
|
|
100
|
+
valid: true,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
label: "Forth step",
|
|
104
|
+
description: "Description",
|
|
105
|
+
valid: false,
|
|
106
|
+
disabled: true,
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const stepIcons = [
|
|
111
|
+
{
|
|
112
|
+
label: "First step",
|
|
113
|
+
icon: favoriteSVG,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: "Second step",
|
|
117
|
+
icon: favoriteSVG,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
label: "Third step",
|
|
121
|
+
icon: favoriteSVG,
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
const stepLargeIcons = [
|
|
126
|
+
{
|
|
127
|
+
label: "First step",
|
|
128
|
+
icon: largeIcon,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: "Second step",
|
|
132
|
+
icon: largeIcon,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
label: "Third step",
|
|
136
|
+
icon: largeIcon,
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
export const Chromatic = () => (
|
|
141
|
+
<>
|
|
142
|
+
<ExampleContainer>
|
|
143
|
+
<Title title="Current step in the third step, labels and description" theme="light" level={4} />
|
|
144
|
+
<DxcWizard currentStep={2} steps={stepWithLabelDescription}></DxcWizard>
|
|
145
|
+
<Title title="With long description in horizontal" theme="light" level={4} />
|
|
146
|
+
<DxcWizard steps={stepWithLongDescription}></DxcWizard>
|
|
147
|
+
<Title title="With long description in vertical" theme="light" level={4} />
|
|
148
|
+
<DxcWizard mode="vertical" steps={stepWithLongDescription}></DxcWizard>
|
|
149
|
+
<Title title="Disabled steps" theme="light" level={4} />
|
|
150
|
+
<DxcWizard steps={stepDisabled}></DxcWizard>
|
|
151
|
+
<Title title="With icons" theme="light" level={4} />
|
|
152
|
+
<DxcWizard steps={stepIcons}></DxcWizard>
|
|
153
|
+
<Title title="With large icons" theme="light" level={4} />
|
|
154
|
+
<DxcWizard steps={stepLargeIcons}></DxcWizard>
|
|
155
|
+
</ExampleContainer>
|
|
156
|
+
<Title title="Margins horizontal" theme="light" level={2} />
|
|
157
|
+
<ExampleContainer>
|
|
158
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
159
|
+
<DxcWizard margin="xxsmall" steps={stepWithLabel}></DxcWizard>
|
|
160
|
+
</ExampleContainer>
|
|
161
|
+
<ExampleContainer>
|
|
162
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
163
|
+
<DxcWizard margin="xsmall" steps={stepWithLabel}></DxcWizard>
|
|
164
|
+
</ExampleContainer>
|
|
165
|
+
<ExampleContainer>
|
|
166
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
167
|
+
<DxcWizard margin="small" steps={stepWithLabel}></DxcWizard>
|
|
168
|
+
</ExampleContainer>
|
|
169
|
+
<ExampleContainer>
|
|
170
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
171
|
+
<DxcWizard margin="medium" steps={stepWithLabel}></DxcWizard>
|
|
172
|
+
</ExampleContainer>
|
|
173
|
+
<ExampleContainer>
|
|
174
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
175
|
+
<DxcWizard margin="large" steps={stepWithLabel}></DxcWizard>
|
|
176
|
+
</ExampleContainer>
|
|
177
|
+
<ExampleContainer>
|
|
178
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
179
|
+
<DxcWizard margin="xlarge" steps={stepWithLabel}></DxcWizard>
|
|
180
|
+
</ExampleContainer>
|
|
181
|
+
<ExampleContainer>
|
|
182
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
183
|
+
<DxcWizard margin="xxlarge" steps={stepWithLabel}></DxcWizard>
|
|
184
|
+
</ExampleContainer>
|
|
185
|
+
<Title title="Margins vertical" theme="light" level={2} />
|
|
186
|
+
<ExampleContainer>
|
|
187
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
188
|
+
<DxcWizard mode="vertical" margin="xxsmall" steps={stepWithLabelDescription}></DxcWizard>
|
|
189
|
+
</ExampleContainer>
|
|
190
|
+
<ExampleContainer>
|
|
191
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
192
|
+
<DxcWizard mode="vertical" margin="xsmall" steps={stepWithLabel}></DxcWizard>
|
|
193
|
+
</ExampleContainer>
|
|
194
|
+
<ExampleContainer>
|
|
195
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
196
|
+
<DxcWizard mode="vertical" margin="small" steps={stepWithLabel}></DxcWizard>
|
|
197
|
+
</ExampleContainer>
|
|
198
|
+
<ExampleContainer>
|
|
199
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
200
|
+
<DxcWizard mode="vertical" margin="medium" steps={stepWithLabel}></DxcWizard>
|
|
201
|
+
</ExampleContainer>
|
|
202
|
+
<ExampleContainer>
|
|
203
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
204
|
+
<DxcWizard mode="vertical" margin="large" steps={stepWithLabel}></DxcWizard>
|
|
205
|
+
</ExampleContainer>
|
|
206
|
+
<ExampleContainer>
|
|
207
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
208
|
+
<DxcWizard mode="vertical" margin="xlarge" steps={stepWithLabel}></DxcWizard>
|
|
209
|
+
</ExampleContainer>
|
|
210
|
+
<ExampleContainer>
|
|
211
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
212
|
+
<DxcWizard mode="vertical" margin="xxlarge" steps={stepWithLabel}></DxcWizard>
|
|
213
|
+
</ExampleContainer>
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const WizardSelected = () => <DxcWizard steps={stepWithLabel}></DxcWizard>;
|
|
218
|
+
|
|
219
|
+
export const WizardStepActived = WizardSelected.bind({});
|
|
220
|
+
WizardStepActived.play = async ({ canvasElement }) => {
|
|
221
|
+
const canvas = within(canvasElement);
|
|
222
|
+
const option = canvas.getByText("Third step");
|
|
223
|
+
await userEvent.click(option);
|
|
224
|
+
};
|