@dxc-technology/halstack-react 0.0.0-49c38a4 → 0.0.0-4a67e25
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 +12 -0
- package/HalstackContext.js +294 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +121 -123
- package/accordion/Accordion.stories.tsx +13 -14
- package/accordion/Accordion.test.js +25 -11
- package/accordion/types.d.ts +9 -4
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +15 -36
- package/accordion-group/AccordionGroup.stories.tsx +28 -2
- package/accordion-group/AccordionGroup.test.js +30 -37
- package/accordion-group/types.d.ts +14 -3
- package/alert/Alert.js +5 -2
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +25 -1
- package/box/Box.js +23 -33
- package/box/types.d.ts +1 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +53 -68
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +24 -27
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +106 -109
- package/checkbox/Checkbox.stories.tsx +146 -130
- package/checkbox/Checkbox.test.js +100 -10
- package/checkbox/types.d.ts +13 -5
- package/chip/types.d.ts +1 -1
- package/common/variables.js +236 -106
- package/date-input/DateInput.js +56 -42
- package/date-input/DateInput.stories.tsx +19 -8
- package/date-input/DateInput.test.js +161 -87
- package/date-input/types.d.ts +16 -9
- package/dialog/Dialog.js +46 -50
- package/dialog/Dialog.stories.tsx +57 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +3 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +247 -251
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +504 -108
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +25 -5
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +183 -222
- package/file-input/FileInput.stories.tsx +38 -10
- package/file-input/FileInput.test.js +53 -12
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +43 -66
- package/file-input/types.d.ts +17 -0
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +69 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +32 -0
- package/{radio → flex}/types.js +0 -0
- package/footer/Footer.js +15 -88
- package/footer/Footer.stories.tsx +8 -1
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +2 -1
- package/header/Header.js +95 -114
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +18 -2
- package/header/Icons.js +2 -2
- package/header/types.d.ts +3 -2
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +25 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +71 -131
- package/layout/ApplicationLayout.stories.tsx +84 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +58 -75
- package/link/Link.stories.tsx +95 -53
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +7 -23
- package/main.d.ts +8 -10
- package/main.js +46 -56
- package/number-input/NumberInput.js +11 -18
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +45 -11
- package/number-input/types.d.ts +17 -10
- package/package.json +20 -16
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +43 -1
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.test.js +16 -18
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +57 -51
- package/progress-bar/ProgressBar.stories.jsx +13 -11
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +117 -0
- package/quick-nav/QuickNav.stories.tsx +342 -0
- package/quick-nav/types.d.ts +21 -0
- package/{row → quick-nav}/types.js +0 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +43 -28
- package/radio-group/RadioGroup.js +32 -28
- package/radio-group/RadioGroup.stories.tsx +5 -0
- package/radio-group/RadioGroup.test.js +144 -116
- package/radio-group/types.d.ts +79 -2
- package/resultsetTable/ResultsetTable.js +1 -3
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +198 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.js +141 -365
- package/select/Select.stories.tsx +160 -115
- package/select/Select.test.js +609 -276
- package/select/types.d.ts +52 -12
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +184 -52
- package/sidenav/Sidenav.stories.tsx +154 -156
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +122 -96
- package/slider/Slider.stories.tsx +15 -9
- package/slider/Slider.test.js +142 -21
- package/slider/types.d.ts +10 -2
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +150 -67
- package/switch/Switch.stories.tsx +20 -42
- package/switch/Switch.test.js +155 -3
- package/switch/types.d.ts +12 -4
- package/table/Table.js +1 -1
- package/table/Table.test.js +1 -1
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +135 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +362 -108
- package/tabs/Tabs.stories.tsx +74 -8
- package/tabs/Tabs.test.js +241 -13
- package/tabs/types.d.ts +19 -5
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +130 -0
- package/tabs-nav/types.d.ts +53 -0
- package/{stack → tabs-nav}/types.js +0 -0
- package/tag/Tag.js +15 -20
- package/tag/Tag.stories.tsx +12 -8
- package/tag/types.d.ts +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +57 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +214 -333
- package/text-input/TextInput.stories.tsx +199 -192
- package/text-input/TextInput.test.js +686 -753
- package/text-input/types.d.ts +50 -12
- package/textarea/Textarea.js +15 -24
- package/textarea/Textarea.stories.jsx +5 -5
- package/textarea/Textarea.test.js +37 -36
- package/textarea/types.d.ts +18 -11
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +5 -4
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +35 -4
- package/toggle-group/types.d.ts +9 -1
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +58 -54
- package/wizard/Wizard.stories.tsx +33 -24
- package/wizard/Wizard.test.js +36 -23
- package/wizard/types.d.ts +10 -5
- package/ThemeContext.d.ts +0 -15
- package/ThemeContext.js +0 -235
- 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/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/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/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
|
@@ -23,6 +23,8 @@ var _uuid = require("uuid");
|
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
|
+
|
|
26
28
|
var _Radio = _interopRequireDefault(require("./Radio"));
|
|
27
29
|
|
|
28
30
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
@@ -39,6 +41,8 @@ var getInitialFocusIndex = function getInitialFocusIndex(innerOptions, value) {
|
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
44
|
+
var _ref2;
|
|
45
|
+
|
|
42
46
|
var label = _ref.label,
|
|
43
47
|
name = _ref.name,
|
|
44
48
|
helperText = _ref.helperText,
|
|
@@ -47,8 +51,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
47
51
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
48
52
|
_ref$optional = _ref.optional,
|
|
49
53
|
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
50
|
-
|
|
51
|
-
optionalItemLabel = _ref$optionalItemLabe === void 0 ? "N/A" : _ref$optionalItemLabe,
|
|
54
|
+
optionalItemLabel = _ref.optionalItemLabel,
|
|
52
55
|
_ref$readonly = _ref.readonly,
|
|
53
56
|
readonly = _ref$readonly === void 0 ? false : _ref$readonly,
|
|
54
57
|
_ref$stacking = _ref.stacking,
|
|
@@ -78,8 +81,10 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
78
81
|
firstTimeFocus = _useState6[0],
|
|
79
82
|
setFirstTimeFocus = _useState6[1];
|
|
80
83
|
|
|
84
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
85
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
81
86
|
var optionalItem = {
|
|
82
|
-
label: optionalItemLabel,
|
|
87
|
+
label: optionalItemLabel || translatedLabels.radioGroup.optionalItemLabelDefault,
|
|
83
88
|
value: "",
|
|
84
89
|
disabled: disabled
|
|
85
90
|
};
|
|
@@ -92,7 +97,6 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
92
97
|
currentFocusIndex = _useState8[0],
|
|
93
98
|
setCurrentFocusIndex = _useState8[1];
|
|
94
99
|
|
|
95
|
-
var colorsTheme = (0, _useTheme["default"])();
|
|
96
100
|
var handleOnChange = (0, _react.useCallback)(function (newValue) {
|
|
97
101
|
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
98
102
|
|
|
@@ -100,16 +104,16 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
100
104
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
101
105
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
102
106
|
}
|
|
103
|
-
}, [value, innerValue,
|
|
107
|
+
}, [value, innerValue, onChange]);
|
|
104
108
|
|
|
105
|
-
var handleOnBlur = function handleOnBlur(
|
|
109
|
+
var handleOnBlur = function handleOnBlur(event) {
|
|
106
110
|
// If the radio group loses the focus to an element not contained inside it...
|
|
107
|
-
if (!
|
|
111
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
108
112
|
setFirstTimeFocus(true);
|
|
109
113
|
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
110
114
|
!optional && !Boolean(currentValue) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
111
115
|
value: currentValue,
|
|
112
|
-
error:
|
|
116
|
+
error: translatedLabels.formFields.requiredSelectionErrorMessage
|
|
113
117
|
}) : onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
114
118
|
value: currentValue
|
|
115
119
|
});
|
|
@@ -147,27 +151,24 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
147
151
|
};
|
|
148
152
|
|
|
149
153
|
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
150
|
-
switch (event.
|
|
151
|
-
case
|
|
152
|
-
|
|
153
|
-
case
|
|
154
|
-
|
|
154
|
+
switch (event.key) {
|
|
155
|
+
case "Left":
|
|
156
|
+
case "ArrowLeft":
|
|
157
|
+
case "Up":
|
|
158
|
+
case "ArrowUp":
|
|
155
159
|
event.preventDefault();
|
|
156
160
|
setPreviousRadioChecked();
|
|
157
161
|
break;
|
|
158
162
|
|
|
159
|
-
case
|
|
160
|
-
|
|
161
|
-
case
|
|
162
|
-
|
|
163
|
+
case "Right":
|
|
164
|
+
case "ArrowRight":
|
|
165
|
+
case "Down":
|
|
166
|
+
case "ArrowDown":
|
|
163
167
|
event.preventDefault();
|
|
164
168
|
setNextRadioChecked();
|
|
165
169
|
break;
|
|
166
170
|
|
|
167
|
-
case
|
|
168
|
-
|
|
169
|
-
case 32:
|
|
170
|
-
// space
|
|
171
|
+
case " ":
|
|
171
172
|
event.preventDefault();
|
|
172
173
|
handleOnChange(innerOptions[currentFocusIndex].value);
|
|
173
174
|
break;
|
|
@@ -182,7 +183,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
182
183
|
id: radioGroupLabelId,
|
|
183
184
|
helperText: helperText,
|
|
184
185
|
disabled: disabled
|
|
185
|
-
}, label,
|
|
186
|
+
}, label, optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, " ".concat(translatedLabels.formFields.optionalLabel))), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
186
187
|
disabled: disabled
|
|
187
188
|
}, helperText), /*#__PURE__*/_react["default"].createElement(RadioGroup, {
|
|
188
189
|
onBlur: handleOnBlur,
|
|
@@ -192,19 +193,22 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
192
193
|
role: "radiogroup",
|
|
193
194
|
"aria-disabled": disabled,
|
|
194
195
|
"aria-labelledby": radioGroupLabelId,
|
|
195
|
-
"aria-invalid": error ?
|
|
196
|
+
"aria-invalid": error ? true : false,
|
|
196
197
|
"aria-errormessage": error ? errorId : undefined,
|
|
197
198
|
"aria-required": !disabled && !readonly && !optional,
|
|
198
|
-
"aria-readonly": readonly
|
|
199
|
+
"aria-readonly": readonly,
|
|
200
|
+
"aria-orientation": stacking === "column" ? "vertical" : "horizontal"
|
|
199
201
|
}, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
200
202
|
name: name,
|
|
201
|
-
|
|
203
|
+
disabled: disabled,
|
|
204
|
+
value: (_ref2 = value !== null && value !== void 0 ? value : innerValue) !== null && _ref2 !== void 0 ? _ref2 : "",
|
|
202
205
|
readOnly: true,
|
|
203
206
|
"aria-hidden": "true"
|
|
204
207
|
}), innerOptions.map(function (option, index) {
|
|
205
208
|
return /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
|
|
206
|
-
|
|
207
|
-
|
|
209
|
+
key: "radio-".concat(index),
|
|
210
|
+
label: option.label,
|
|
211
|
+
checked: (value !== null && value !== void 0 ? value : innerValue) === option.value,
|
|
208
212
|
onClick: function onClick() {
|
|
209
213
|
handleOnChange(option.value);
|
|
210
214
|
setCurrentFocusIndex(index);
|
|
@@ -259,7 +263,7 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
259
263
|
return props.theme.groupLabelMargin;
|
|
260
264
|
});
|
|
261
265
|
|
|
262
|
-
var RadioGroup = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n flex-direction: ", ";\n
|
|
266
|
+
var RadioGroup = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n flex-direction: ", ";\n row-gap: ", ";\n column-gap: ", ";\n"])), function (props) {
|
|
263
267
|
return props.stacking;
|
|
264
268
|
}, function (props) {
|
|
265
269
|
return props.theme.groupVerticalGutter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
2
3
|
import Title from "../../.storybook/components/Title";
|
|
3
4
|
import DxcRadioGroup from "./RadioGroup";
|
|
@@ -88,6 +89,10 @@ export const Chromatic = () => (
|
|
|
88
89
|
<Title title="Readonly" theme="light" level={4} />
|
|
89
90
|
<DxcRadioGroup label="Example" readonly helperText="Helper text" options={options} />
|
|
90
91
|
</ExampleContainer>
|
|
92
|
+
<ExampleContainer>
|
|
93
|
+
<Title title="Error space reserved" theme="light" level={4} />
|
|
94
|
+
<DxcRadioGroup label="Example" error="" helperText="Helper text" options={options} />
|
|
95
|
+
</ExampleContainer>
|
|
91
96
|
<ExampleContainer>
|
|
92
97
|
<Title title="Error" theme="light" level={4} />
|
|
93
98
|
<DxcRadioGroup label="Example" error="Error message" helperText="Helper text" options={options} />
|