@dxc-technology/halstack-react 0.0.0-d20b360 → 0.0.0-d238e47

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.
Files changed (110) hide show
  1. package/alert/Alert.stories.tsx +170 -0
  2. package/alert/types.d.ts +1 -1
  3. package/box/Box.d.ts +4 -0
  4. package/box/Box.js +4 -30
  5. package/box/{Box.stories.jsx → Box.stories.tsx} +0 -0
  6. package/box/types.d.ts +43 -0
  7. package/box/types.js +5 -0
  8. package/button/Button.d.ts +1 -1
  9. package/button/Button.js +7 -10
  10. package/button/Button.stories.tsx +217 -234
  11. package/button/types.d.ts +11 -11
  12. package/card/Card.js +4 -5
  13. package/card/Card.stories.tsx +201 -0
  14. package/card/ice-cream.jpg +0 -0
  15. package/card/types.d.ts +4 -6
  16. package/checkbox/types.d.ts +1 -1
  17. package/chip/Chip.stories.tsx +121 -0
  18. package/common/variables.js +29 -21
  19. package/date-input/DateInput.stories.tsx +138 -0
  20. package/dialog/Dialog.stories.tsx +212 -0
  21. package/file-input/FileInput.d.ts +4 -0
  22. package/file-input/FileInput.js +7 -28
  23. package/file-input/FileItem.d.ts +14 -0
  24. package/file-input/FileItem.js +4 -15
  25. package/file-input/types.d.ts +87 -0
  26. package/file-input/types.js +5 -0
  27. package/footer/types.d.ts +1 -1
  28. package/header/Header.stories.tsx +162 -0
  29. package/header/types.d.ts +4 -2
  30. package/heading/Heading.d.ts +4 -0
  31. package/heading/Heading.js +6 -23
  32. package/heading/Heading.stories.tsx +53 -0
  33. package/heading/types.d.ts +33 -0
  34. package/heading/types.js +5 -0
  35. package/link/Link.d.ts +3 -0
  36. package/link/Link.js +3 -25
  37. package/link/Link.stories.tsx +146 -0
  38. package/link/types.d.ts +74 -0
  39. package/link/types.js +5 -0
  40. package/number-input/NumberInput.d.ts +4 -0
  41. package/number-input/NumberInput.js +2 -44
  42. package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +0 -0
  43. package/number-input/NumberInputContext.d.ts +4 -0
  44. package/number-input/NumberInputContext.js +5 -2
  45. package/number-input/numberInputContextTypes.d.ts +19 -0
  46. package/number-input/numberInputContextTypes.js +5 -0
  47. package/number-input/types.d.ts +117 -0
  48. package/number-input/types.js +5 -0
  49. package/package.json +1 -1
  50. package/password-input/PasswordInput.d.ts +4 -0
  51. package/password-input/PasswordInput.js +0 -37
  52. package/password-input/{PasswordInput.stories.jsx → PasswordInput.stories.tsx} +1 -1
  53. package/password-input/types.d.ts +105 -0
  54. package/password-input/types.js +5 -0
  55. package/progress-bar/ProgressBar.stories.jsx +58 -0
  56. package/radio/types.d.ts +2 -2
  57. package/resultsetTable/ResultsetTable.d.ts +4 -0
  58. package/resultsetTable/ResultsetTable.js +0 -25
  59. package/resultsetTable/types.d.ts +63 -0
  60. package/resultsetTable/types.js +5 -0
  61. package/select/Select.stories.tsx +572 -0
  62. package/sidenav/Sidenav.d.ts +9 -0
  63. package/sidenav/Sidenav.js +4 -13
  64. package/sidenav/Sidenav.stories.tsx +165 -0
  65. package/sidenav/types.d.ts +50 -0
  66. package/sidenav/types.js +5 -0
  67. package/slider/Slider.d.ts +1 -1
  68. package/slider/Slider.js +41 -30
  69. package/slider/Slider.stories.tsx +177 -0
  70. package/slider/types.d.ts +2 -7
  71. package/spinner/Spinner.d.ts +4 -0
  72. package/spinner/Spinner.js +0 -17
  73. package/spinner/types.d.ts +32 -0
  74. package/spinner/types.js +5 -0
  75. package/switch/Switch.js +2 -2
  76. package/switch/Switch.stories.tsx +160 -0
  77. package/table/Table.d.ts +4 -0
  78. package/table/Table.js +1 -1
  79. package/table/types.d.ts +21 -0
  80. package/table/types.js +5 -0
  81. package/tabs/Tabs.js +3 -1
  82. package/tabs/types.d.ts +2 -3
  83. package/tag/Tag.d.ts +4 -0
  84. package/tag/Tag.js +20 -35
  85. package/tag/Tag.stories.tsx +145 -0
  86. package/tag/types.d.ts +60 -0
  87. package/tag/types.js +5 -0
  88. package/text-input/TextInput.d.ts +4 -0
  89. package/text-input/TextInput.js +4 -44
  90. package/text-input/types.d.ts +157 -0
  91. package/text-input/types.js +5 -0
  92. package/toggle-group/ToggleGroup.stories.tsx +178 -0
  93. package/wizard/Wizard.d.ts +4 -0
  94. package/wizard/Wizard.js +11 -51
  95. package/wizard/Wizard.stories.jsx +224 -0
  96. package/wizard/types.d.ts +64 -0
  97. package/wizard/types.js +5 -0
  98. package/box/index.d.ts +0 -25
  99. package/file-input/index.d.ts +0 -81
  100. package/heading/index.d.ts +0 -17
  101. package/link/index.d.ts +0 -23
  102. package/number-input/index.d.ts +0 -113
  103. package/password-input/index.d.ts +0 -94
  104. package/resultsetTable/index.d.ts +0 -19
  105. package/sidenav/index.d.ts +0 -13
  106. package/spinner/index.d.ts +0 -17
  107. package/table/index.d.ts +0 -13
  108. package/tag/index.d.ts +0 -24
  109. package/text-input/index.d.ts +0 -135
  110. package/wizard/index.d.ts +0 -18
package/tag/types.d.ts ADDED
@@ -0,0 +1,60 @@
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 Props = {
11
+ /**
12
+ * Element used as the icon that will be placed next to the label.
13
+ */
14
+ icon?: SVG;
15
+ /**
16
+ * @deprecated URL of the icon.
17
+ */
18
+ iconSrc?: string;
19
+ /**
20
+ * Text to be placed next inside the tag.
21
+ */
22
+ label?: string;
23
+ /**
24
+ * If defined, the tag will be displayed as an anchor, using this prop as "href".
25
+ * Component will show some visual feedback on hover.
26
+ */
27
+ linkHref?: string;
28
+ /**
29
+ * If defined, the tag will be displayed as a button. This function will
30
+ * be called when the user clicks the tag. Component will show some
31
+ * visual feedback on hover.
32
+ */
33
+ onClick?: () => void;
34
+ /**
35
+ * Background color of the icon section of the tag.
36
+ */
37
+ iconBgColor?: string;
38
+ /**
39
+ * Whether the label should appear after or before the icon.
40
+ */
41
+ labelPosition?: "before" | "after";
42
+ /**
43
+ * If true, the page is opened in a new browser tab.
44
+ */
45
+ newWindow?: boolean;
46
+ /**
47
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
48
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
49
+ */
50
+ margin?: Space | Margin;
51
+ /**
52
+ * Size of the component.
53
+ */
54
+ size?: "small" | "medium" | "large" | "fillParent" | "fitContent";
55
+ /**
56
+ * Value of the tabindex attribute.
57
+ */
58
+ tabIndex?: number;
59
+ };
60
+ export default Props;
package/tag/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import TextInputPropsType from "./types";
3
+ declare const DxcTextInput: React.ForwardRefExoticComponent<TextInputPropsType & React.RefAttributes<HTMLDivElement>>;
4
+ export default DxcTextInput;
@@ -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 _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
13
 
16
14
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
@@ -23,8 +21,6 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
23
21
 
24
22
  var _useTheme = _interopRequireDefault(require("../useTheme.js"));
25
23
 
26
- var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
24
  var _variables = require("../common/variables.js");
29
25
 
30
26
  var _utils = require("../common/utils.js");
@@ -33,7 +29,7 @@ var _uuid = require("uuid");
33
29
 
34
30
  var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
35
31
 
36
- var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext.js"));
32
+ var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext"));
37
33
 
38
34
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
39
35
 
@@ -317,7 +313,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
317
313
  switch (event.keyCode) {
318
314
  case 40:
319
315
  // Arrow Down
320
- if (numberInputContext) {
316
+ if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
321
317
  decrementNumber();
322
318
  event.preventDefault();
323
319
  } else {
@@ -335,7 +331,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
335
331
 
336
332
  case 38:
337
333
  // Arrow Up
338
- if (numberInputContext) {
334
+ if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
339
335
  incrementNumber();
340
336
  event.preventDefault();
341
337
  } else {
@@ -474,7 +470,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
474
470
  changeVisualFocusedSuggIndex(-1);
475
471
  }
476
472
 
477
- numberInputContext && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
473
+ (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
478
474
  }, [value, innerValue, suggestions, numberInputContext]);
479
475
 
480
476
  var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
@@ -785,41 +781,5 @@ var SuggestionsError = _styledComponents["default"].span(_templateObject18 || (_
785
781
  return props.theme.errorListDialogFontColor;
786
782
  });
787
783
 
788
- DxcTextInput.propTypes = {
789
- label: _propTypes["default"].string,
790
- name: _propTypes["default"].string,
791
- value: _propTypes["default"].string,
792
- helperText: _propTypes["default"].string,
793
- placeholder: _propTypes["default"].string,
794
- action: _propTypes["default"].shape({
795
- onClick: _propTypes["default"].func.isRequired,
796
- icon: _propTypes["default"].oneOfType([_propTypes["default"].shape({
797
- type: _propTypes["default"].oneOf(["svg"])
798
- }), _propTypes["default"].string]).isRequired
799
- }),
800
- clearable: _propTypes["default"].bool,
801
- disabled: _propTypes["default"].bool,
802
- optional: _propTypes["default"].bool,
803
- prefix: _propTypes["default"].string,
804
- suffix: _propTypes["default"].string,
805
- onChange: _propTypes["default"].func,
806
- onBlur: _propTypes["default"].func,
807
- error: _propTypes["default"].string,
808
- autocomplete: _propTypes["default"].string,
809
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
810
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
811
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
812
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
813
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
814
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
815
- size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
816
- suggestions: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].array]),
817
- pattern: _propTypes["default"].string,
818
- length: _propTypes["default"].shape({
819
- min: _propTypes["default"].number,
820
- max: _propTypes["default"].number
821
- }),
822
- tabIndex: _propTypes["default"].number
823
- };
824
784
  var _default = DxcTextInput;
825
785
  exports["default"] = _default;
@@ -0,0 +1,157 @@
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 Action = {
11
+ /**
12
+ * This function will be called when the user clicks the action.
13
+ */
14
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
15
+ /**
16
+ * Icon to be shown in the action.
17
+ */
18
+ icon: string | SVG;
19
+ /**
20
+ * Title of the action.
21
+ */
22
+ title?: string;
23
+ };
24
+ declare type RequiredMinLength = {
25
+ min: number;
26
+ max?: number;
27
+ };
28
+ declare type RequiredMaxLength = {
29
+ min?: number;
30
+ max: number;
31
+ };
32
+ declare type Props = {
33
+ /**
34
+ * Text to be placed above the input. This label will be used as the aria-label attribute of the list of suggestions.
35
+ */
36
+ label?: string;
37
+ /**
38
+ * Name attribute of the input element.
39
+ */
40
+ name?: string;
41
+ /**
42
+ * Value of the input. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
43
+ */
44
+ value?: string;
45
+ /**
46
+ * Helper text to be placed above the input.
47
+ */
48
+ helperText?: string;
49
+ /**
50
+ * Text to be put as placeholder of the input.
51
+ */
52
+ placeholder?: string;
53
+ /**
54
+ * Action to be shown in the input. This is an object composed of an onClick function and an icon,
55
+ * being the latter either an inline svg or a URL to the image.
56
+ */
57
+ action?: Action;
58
+ /**
59
+ * If true, the input will have an action to clear the entered value.
60
+ */
61
+ clearable?: boolean;
62
+ /**
63
+ * If true, the component will be disabled.
64
+ */
65
+ disabled?: boolean;
66
+ /**
67
+ * If true, the input will be optional, showing '(Optional)'
68
+ * next to the label. Otherwise, the field will be considered required and an error will be
69
+ * passed as a parameter to the OnBlur and onChange functions when it has
70
+ * not been filled.
71
+ */
72
+ optional?: boolean;
73
+ /**
74
+ * Prefix to be placed before the input value.
75
+ */
76
+ prefix?: string;
77
+ /**
78
+ * Suffix to be placed after the input value.
79
+ */
80
+ suffix?: string;
81
+ /**
82
+ * This function will be called when the user types within the input
83
+ * element of the component. An object including the current value and
84
+ * the error (if the value entered is not valid) will be passed to this
85
+ * function. If there is no error, error will be null.
86
+ */
87
+ onChange?: (val: {
88
+ value: string;
89
+ error: string | null;
90
+ }) => void;
91
+ /**
92
+ * This function will be called when the input element loses the focus.
93
+ * An object including the input value and the error (if the value
94
+ * entered is not valid) will be passed to this function. If there is no error,
95
+ * error will be null.
96
+ */
97
+ onBlur?: (val: {
98
+ value: string;
99
+ error: string | null;
100
+ }) => void;
101
+ /**
102
+ * If it is defined, the component will change its appearance, showing
103
+ * the error below the input component. If it is not defined, the error
104
+ * messages will be managed internally, but never displayed on its own.
105
+ */
106
+ error?: string;
107
+ /**
108
+ * These are the options to be displayed as suggestions. It can be either an array or a function:
109
+ * - Array: Array of options that will be filtered by the component.
110
+ * - Function: This function will be called when the user changes the value, we will send as a parameter the new value;
111
+ * apart from that this function should return one promise on which we should make 'then' to get the suggestions filtered.
112
+ */
113
+ suggestions?: string[] | ((value: string) => Promise<string[]>);
114
+ /**
115
+ * Regular expression that defines the valid format allowed by the input.
116
+ * This will be checked both when the input element loses the focus and
117
+ * while typing within it. If the string entered does not match the
118
+ * pattern, the onBlur and onChange functions will be called with the
119
+ * current value and an internal error informing that this value does not
120
+ * match the pattern. If the pattern is met, the error parameter of both
121
+ * events will be null.
122
+ */
123
+ pattern?: string;
124
+ /**
125
+ * Specifies the minimun and maximum length allowed by the input.
126
+ * This will be checked both when the input element loses the
127
+ * focus and while typing within it. If the string entered does not
128
+ * comply the length, the onBlur and onChange functions will be called
129
+ * with the current value and an internal error informing that the value
130
+ * length does not comply the specified range. If a valid length is
131
+ * reached, the error parameter of both events will be null.
132
+ */
133
+ length?: RequiredMinLength | RequiredMaxLength;
134
+ /**
135
+ * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
136
+ * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
137
+ */
138
+ autocomplete?: string;
139
+ /**
140
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
141
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
142
+ */
143
+ margin?: Space | Margin;
144
+ /**
145
+ * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
146
+ */
147
+ size?: "small" | "medium" | "large" | "fillParent";
148
+ /**
149
+ * Value of the tabindex attribute.
150
+ */
151
+ tabIndex?: number;
152
+ };
153
+ /**
154
+ * Reference to the component.
155
+ */
156
+ export declare type RefType = HTMLDivElement;
157
+ export default Props;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -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,4 @@
1
+ /// <reference types="react" />
2
+ import WizardPropsType from "./types";
3
+ declare const DxcWizard: ({ mode, currentStep, onStepClick, steps, margin, tabIndex, }: WizardPropsType) => JSX.Element;
4
+ export default DxcWizard;
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, _templateObject14;
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.type === "img" ? /*#__PURE__*/_react["default"].createElement(ImgContainer, {
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 ImgContainer = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n mask: url(", ") no-repeat center;\n mask-size: ", ";\n height: ", ";\n width: ", ";\n"])), function (props) {
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(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n width: 18px;\n height: 18px;\n position: absolute;\n top: 22.5px;\n left: 22.5px;\n"])));
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(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 12px;\n"])));
182
+ var InfoContainer = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 12px;\n"])));
203
183
 
204
- var Label = _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 ", ";\n text-transform: ", ";\n margin: 0;\n"])), function (props) {
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(_templateObject13 || (_templateObject13 = (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) {
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(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", "\n border: ", ";\n opacity: 1;\n flex-grow: 1;\n"])), function (props) {
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;