@dxc-technology/halstack-react 10.0.0 → 10.1.0
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/HalstackContext.d.ts +8 -0
- package/README.md +47 -0
- package/common/variables.d.ts +8 -0
- package/common/variables.js +8 -0
- package/footer/Footer.stories.tsx +8 -7
- package/image/Image.d.ts +4 -0
- package/image/Image.js +85 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/layout/ApplicationLayout.js +11 -11
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +7 -4
- package/layout/Icons.js +52 -56
- package/main.d.ts +2 -1
- package/main.js +8 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +6 -4
- package/number-input/NumberInput.test.js +278 -95
- package/package.json +2 -2
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +39 -0
- package/password-input/PasswordInput.js +35 -82
- package/password-input/PasswordInput.stories.tsx +1 -0
- package/password-input/PasswordInput.test.js +27 -34
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +4 -4
- package/text-input/TextInput.js +61 -77
- package/toggle-group/ToggleGroup.js +79 -56
- package/toggle-group/ToggleGroup.stories.tsx +6 -3
- package/toggle-group/ToggleGroup.test.js +37 -23
- package/toggle-group/types.d.ts +22 -13
- package/useTheme.d.ts +8 -0
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
|
@@ -37,14 +37,28 @@ describe("Toggle group component tests", function () {
|
|
|
37
37
|
expect(getByText("Apple")).toBeTruthy();
|
|
38
38
|
expect(getByText("Google")).toBeTruthy();
|
|
39
39
|
});
|
|
40
|
+
test("Toggle group renders with correct aria-label in only-icon scenario", function () {
|
|
41
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
42
|
+
label: "Toggle group label",
|
|
43
|
+
helperText: "Toggle group helper text",
|
|
44
|
+
options: [{
|
|
45
|
+
value: 1,
|
|
46
|
+
icon: "https://cdn.icon-icons.com/icons2/2645/PNG/512/mic_mute_icon_159965.png",
|
|
47
|
+
title: "Mute"
|
|
48
|
+
}]
|
|
49
|
+
})),
|
|
50
|
+
getByRole = _render2.getByRole;
|
|
51
|
+
|
|
52
|
+
expect(getByRole("button").getAttribute("aria-label")).toBe("Mute");
|
|
53
|
+
});
|
|
40
54
|
test("Uncontrolled toggle group calls correct function on change with value", function () {
|
|
41
55
|
var onChange = jest.fn();
|
|
42
56
|
|
|
43
|
-
var
|
|
57
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
44
58
|
options: options,
|
|
45
59
|
onChange: onChange
|
|
46
60
|
})),
|
|
47
|
-
getByText =
|
|
61
|
+
getByText = _render3.getByText;
|
|
48
62
|
|
|
49
63
|
var option = getByText("Ebay");
|
|
50
64
|
|
|
@@ -55,12 +69,12 @@ describe("Toggle group component tests", function () {
|
|
|
55
69
|
test("Controlled toggle group calls correct function on change with value", function () {
|
|
56
70
|
var onChange = jest.fn();
|
|
57
71
|
|
|
58
|
-
var
|
|
72
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
59
73
|
options: options,
|
|
60
74
|
onChange: onChange,
|
|
61
75
|
value: 1
|
|
62
76
|
})),
|
|
63
|
-
getByText =
|
|
77
|
+
getByText = _render4.getByText;
|
|
64
78
|
|
|
65
79
|
var option = getByText("Ebay");
|
|
66
80
|
|
|
@@ -71,12 +85,12 @@ describe("Toggle group component tests", function () {
|
|
|
71
85
|
test("Function on change is not called when disable", function () {
|
|
72
86
|
var onChange = jest.fn();
|
|
73
87
|
|
|
74
|
-
var
|
|
88
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
75
89
|
options: options,
|
|
76
90
|
onChange: onChange,
|
|
77
91
|
disabled: true
|
|
78
92
|
})),
|
|
79
|
-
getByText =
|
|
93
|
+
getByText = _render5.getByText;
|
|
80
94
|
|
|
81
95
|
var option = getByText("Ebay");
|
|
82
96
|
|
|
@@ -87,14 +101,14 @@ describe("Toggle group component tests", function () {
|
|
|
87
101
|
test("Uncontrolled multiple toggle group calls correct function on change with value when is multiple", function () {
|
|
88
102
|
var onChange = jest.fn();
|
|
89
103
|
|
|
90
|
-
var
|
|
104
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
91
105
|
options: options,
|
|
92
106
|
onChange: onChange,
|
|
93
107
|
multiple: true
|
|
94
108
|
})),
|
|
95
|
-
getAllByRole =
|
|
109
|
+
getAllByRole = _render6.getAllByRole;
|
|
96
110
|
|
|
97
|
-
var toggleOptions = getAllByRole("
|
|
111
|
+
var toggleOptions = getAllByRole("button");
|
|
98
112
|
|
|
99
113
|
_react2.fireEvent.click(toggleOptions[0]);
|
|
100
114
|
|
|
@@ -105,20 +119,20 @@ describe("Toggle group component tests", function () {
|
|
|
105
119
|
_react2.fireEvent.click(toggleOptions[3]);
|
|
106
120
|
|
|
107
121
|
expect(onChange).toHaveBeenCalledWith([1, 2, 4]);
|
|
108
|
-
expect(toggleOptions[0].getAttribute("aria-
|
|
109
|
-
expect(toggleOptions[1].getAttribute("aria-
|
|
110
|
-
expect(toggleOptions[3].getAttribute("aria-
|
|
122
|
+
expect(toggleOptions[0].getAttribute("aria-pressed")).toBe("true");
|
|
123
|
+
expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
|
|
124
|
+
expect(toggleOptions[3].getAttribute("aria-pressed")).toBe("true");
|
|
111
125
|
});
|
|
112
126
|
test("Controlled multiple toggle returns always same values", function () {
|
|
113
127
|
var onChange = jest.fn();
|
|
114
128
|
|
|
115
|
-
var
|
|
129
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
116
130
|
options: options,
|
|
117
131
|
onChange: onChange,
|
|
118
132
|
value: [1],
|
|
119
133
|
multiple: true
|
|
120
134
|
})),
|
|
121
|
-
getByText =
|
|
135
|
+
getByText = _render7.getByText;
|
|
122
136
|
|
|
123
137
|
var option = getByText("Ebay");
|
|
124
138
|
|
|
@@ -132,25 +146,25 @@ describe("Toggle group component tests", function () {
|
|
|
132
146
|
expect(onChange).toHaveBeenNthCalledWith(2, [1, 4]);
|
|
133
147
|
});
|
|
134
148
|
test("Single selection: Renders with correct default value", function () {
|
|
135
|
-
var
|
|
149
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
136
150
|
options: options,
|
|
137
151
|
defaultValue: 2
|
|
138
152
|
})),
|
|
139
|
-
getAllByRole =
|
|
153
|
+
getAllByRole = _render8.getAllByRole;
|
|
140
154
|
|
|
141
|
-
var toggleOptions = getAllByRole("
|
|
142
|
-
expect(toggleOptions[1].getAttribute("aria-
|
|
155
|
+
var toggleOptions = getAllByRole("button");
|
|
156
|
+
expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
|
|
143
157
|
});
|
|
144
158
|
test("Multiple selection: Renders with correct default value", function () {
|
|
145
|
-
var
|
|
159
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
146
160
|
options: options,
|
|
147
161
|
defaultValue: [2, 4],
|
|
148
162
|
multiple: true
|
|
149
163
|
})),
|
|
150
|
-
getAllByRole =
|
|
164
|
+
getAllByRole = _render9.getAllByRole;
|
|
151
165
|
|
|
152
|
-
var toggleOptions = getAllByRole("
|
|
153
|
-
expect(toggleOptions[1].getAttribute("aria-
|
|
154
|
-
expect(toggleOptions[3].getAttribute("aria-
|
|
166
|
+
var toggleOptions = getAllByRole("button");
|
|
167
|
+
expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
|
|
168
|
+
expect(toggleOptions[3].getAttribute("aria-pressed")).toBe("true");
|
|
155
169
|
});
|
|
156
170
|
});
|
package/toggle-group/types.d.ts
CHANGED
|
@@ -7,23 +7,22 @@ declare type Margin = {
|
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
9
|
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
-
declare type
|
|
11
|
-
/**
|
|
12
|
-
* Number with the option inner value.
|
|
13
|
-
*/
|
|
14
|
-
value: number;
|
|
15
|
-
};
|
|
16
|
-
declare type OptionIcon = OptionCommons & {
|
|
10
|
+
declare type OptionIcon = {
|
|
17
11
|
/**
|
|
18
12
|
* String with the option display value.
|
|
19
13
|
*/
|
|
20
|
-
label?:
|
|
14
|
+
label?: never;
|
|
21
15
|
/**
|
|
22
16
|
* Element used as the icon. Icon and label can't be used at same time.
|
|
23
17
|
*/
|
|
24
18
|
icon: string | SVG;
|
|
19
|
+
/**
|
|
20
|
+
* Value for the HTML properties title and aria-label.
|
|
21
|
+
* When a label is defined, this prop can not be use.
|
|
22
|
+
*/
|
|
23
|
+
title: string;
|
|
25
24
|
};
|
|
26
|
-
export declare type OptionLabel =
|
|
25
|
+
export declare type OptionLabel = {
|
|
27
26
|
/**
|
|
28
27
|
* String with the option display value.
|
|
29
28
|
*/
|
|
@@ -32,8 +31,18 @@ export declare type OptionLabel = OptionCommons & {
|
|
|
32
31
|
* Element used as the icon. Icon and label can't be used at same time.
|
|
33
32
|
*/
|
|
34
33
|
icon?: string | SVG;
|
|
34
|
+
/**
|
|
35
|
+
* Value for the HTML properties title and aria-label.
|
|
36
|
+
* When a label is defined, this prop can not be use.
|
|
37
|
+
*/
|
|
38
|
+
title?: never;
|
|
35
39
|
};
|
|
36
|
-
declare type Option =
|
|
40
|
+
declare type Option = {
|
|
41
|
+
/**
|
|
42
|
+
* Number with the option inner value.
|
|
43
|
+
*/
|
|
44
|
+
value: number;
|
|
45
|
+
} & (OptionIcon | OptionLabel);
|
|
37
46
|
declare type CommonProps = {
|
|
38
47
|
/**
|
|
39
48
|
* Text to be placed above the component.
|
|
@@ -61,7 +70,7 @@ declare type CommonProps = {
|
|
|
61
70
|
*/
|
|
62
71
|
tabIndex?: number;
|
|
63
72
|
};
|
|
64
|
-
declare type
|
|
73
|
+
declare type SingleSelectionToggleGroup = CommonProps & {
|
|
65
74
|
/**
|
|
66
75
|
* 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.
|
|
67
76
|
*/
|
|
@@ -81,7 +90,7 @@ declare type SingleSelectionToggle = CommonProps & {
|
|
|
81
90
|
*/
|
|
82
91
|
onChange?: (optionIndex: number) => void;
|
|
83
92
|
};
|
|
84
|
-
declare type
|
|
93
|
+
declare type MultipleSelectionToggleGroup = CommonProps & {
|
|
85
94
|
/**
|
|
86
95
|
* 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.
|
|
87
96
|
*/
|
|
@@ -101,5 +110,5 @@ declare type MultipleSelectionToggle = CommonProps & {
|
|
|
101
110
|
*/
|
|
102
111
|
onChange?: (optionIndex: number[]) => void;
|
|
103
112
|
};
|
|
104
|
-
declare type Props =
|
|
113
|
+
declare type Props = SingleSelectionToggleGroup | MultipleSelectionToggleGroup;
|
|
105
114
|
export default Props;
|
package/useTheme.d.ts
CHANGED
|
@@ -488,6 +488,14 @@ declare const useTheme: () => {
|
|
|
488
488
|
level5LineHeight: string;
|
|
489
489
|
level5LetterSpacing: string;
|
|
490
490
|
}>;
|
|
491
|
+
image?: Partial<{
|
|
492
|
+
captionFontColor: string;
|
|
493
|
+
captionFontFamily: string;
|
|
494
|
+
captionFontSize: string;
|
|
495
|
+
captionFontStyle: string;
|
|
496
|
+
captionFontWeight: string;
|
|
497
|
+
captionLineHeight: string;
|
|
498
|
+
}>;
|
|
491
499
|
link?: Partial<{
|
|
492
500
|
fontColor: string;
|
|
493
501
|
fontFamily: string;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var defaultState = {
|
|
13
|
-
stepNumber: 1
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
var NumberInputContext = /*#__PURE__*/_react["default"].createContext(defaultState);
|
|
17
|
-
|
|
18
|
-
var _default = NumberInputContext;
|
|
19
|
-
exports["default"] = _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare type Props = {
|
|
2
|
-
/**
|
|
3
|
-
* Type of the input.
|
|
4
|
-
*/
|
|
5
|
-
typeNumber?: string;
|
|
6
|
-
/**
|
|
7
|
-
* Minimum value allowed by the number input.
|
|
8
|
-
*/
|
|
9
|
-
minNumber?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Maximum value allowed by the number input.
|
|
12
|
-
*/
|
|
13
|
-
maxNumber?: number;
|
|
14
|
-
/**
|
|
15
|
-
* The step interval to use when using the up and down arrows to adjust the value.
|
|
16
|
-
*/
|
|
17
|
-
stepNumber?: number;
|
|
18
|
-
};
|
|
19
|
-
export default Props;
|
|
File without changes
|