@dxc-technology/halstack-react 0.0.0-64fdce7 → 0.0.0-6501724
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +1329 -5
- package/HalstackContext.js +113 -72
- package/accordion/Accordion.js +6 -11
- package/accordion/Accordion.stories.tsx +52 -3
- package/accordion/Accordion.test.js +1 -1
- package/accordion/types.d.ts +3 -3
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +23 -44
- package/accordion-group/AccordionGroup.test.js +1 -1
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +2 -2
- package/alert/Alert.js +4 -8
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/bleed/Bleed.stories.tsx +1 -0
- package/box/Box.js +3 -5
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +1 -1
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.js +2 -3
- package/button/Button.stories.tsx +95 -10
- package/button/Button.test.js +1 -1
- package/button/types.d.ts +3 -3
- package/card/Card.js +12 -13
- package/card/Card.stories.tsx +12 -13
- package/card/Card.test.js +1 -1
- package/checkbox/Checkbox.js +3 -3
- package/checkbox/Checkbox.stories.tsx +52 -0
- package/checkbox/Checkbox.test.js +1 -1
- package/checkbox/types.d.ts +2 -2
- package/chip/Chip.js +25 -34
- package/chip/Chip.stories.tsx +80 -17
- package/chip/Chip.test.js +3 -5
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1482 -0
- package/common/variables.js +962 -1123
- package/date-input/DateInput.stories.tsx +67 -0
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +55 -86
- package/dialog/Dialog.stories.tsx +145 -217
- package/dialog/Dialog.test.js +302 -3
- package/dialog/types.d.ts +0 -13
- package/dropdown/Dropdown.js +2 -2
- package/dropdown/Dropdown.stories.tsx +46 -1
- package/dropdown/Dropdown.test.js +3 -2
- package/dropdown/DropdownMenu.js +5 -1
- package/dropdown/DropdownMenuItem.js +0 -2
- package/dropdown/types.d.ts +3 -3
- package/file-input/FileInput.js +4 -8
- package/file-input/FileInput.stories.tsx +85 -2
- package/file-input/FileInput.test.js +1 -42
- package/file-input/FileItem.js +1 -0
- package/flex/Flex.js +4 -2
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +70 -5
- package/footer/Footer.js +6 -8
- package/footer/Footer.stories.tsx +91 -0
- package/footer/Footer.test.js +14 -26
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +3 -2
- package/header/Header.js +3 -3
- package/header/Header.stories.tsx +115 -5
- package/header/Header.test.js +2 -2
- package/header/types.d.ts +2 -2
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/inset/Inset.stories.tsx +2 -1
- package/layout/ApplicationLayout.d.ts +3 -3
- package/layout/ApplicationLayout.js +1 -1
- package/layout/types.d.ts +2 -3
- package/link/Link.js +3 -3
- package/link/Link.stories.tsx +60 -0
- package/link/Link.test.js +2 -4
- package/link/types.d.ts +2 -2
- package/main.d.ts +3 -2
- package/main.js +9 -1
- package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
- package/{tabs-nav → nav-tabs}/NavTabs.js +8 -11
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +103 -1
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
- package/{tabs-nav → nav-tabs}/Tab.js +47 -29
- package/{tabs-nav → nav-tabs}/types.d.ts +8 -9
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.test.js +1 -1
- package/package.json +2 -2
- package/paginator/Paginator.js +2 -4
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +40 -37
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/PasswordInput.test.js +1 -1
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +5 -5
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/progress-bar/ProgressBar.test.js +1 -1
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.stories.tsx +14 -0
- package/radio-group/Radio.js +10 -10
- package/radio-group/RadioGroup.js +8 -10
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/radio-group/RadioGroup.test.js +1 -1
- package/resultsetTable/ResultsetTable.js +2 -2
- package/resultsetTable/ResultsetTable.test.js +1 -1
- package/resultsetTable/types.d.ts +3 -3
- package/select/Select.js +13 -11
- package/select/Select.stories.tsx +477 -175
- package/select/Select.test.js +59 -59
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +66 -94
- package/sidenav/Sidenav.stories.tsx +110 -17
- package/sidenav/types.d.ts +21 -18
- package/slider/Slider.js +2 -3
- package/slider/Slider.stories.tsx +57 -0
- package/slider/Slider.test.js +1 -1
- package/slider/types.d.ts +2 -2
- package/spinner/Spinner.js +15 -21
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.js +2 -2
- package/switch/Switch.stories.tsx +33 -0
- package/switch/Switch.test.js +1 -1
- package/switch/types.d.ts +2 -2
- package/table/Table.js +2 -2
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +1 -1
- package/tabs/Tab.js +9 -10
- package/tabs/Tabs.js +11 -17
- package/tabs/Tabs.stories.tsx +38 -0
- package/tabs/Tabs.test.js +4 -5
- package/tabs/types.d.ts +2 -2
- package/tag/Tag.js +7 -9
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/text-input/Suggestion.js +2 -2
- package/text-input/TextInput.js +4 -4
- package/text-input/TextInput.stories.tsx +69 -1
- package/text-input/TextInput.test.js +1 -2
- package/textarea/Textarea.js +3 -4
- package/textarea/Textarea.stories.jsx +60 -1
- package/textarea/Textarea.test.js +2 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +7 -4
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +14 -113
- package/typography/Typography.stories.tsx +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +1 -1
- package/useTranslatedLabels.d.ts +84 -1
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +2 -2
- package/wizard/Wizard.stories.tsx +20 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +5 -6
- /package/{tabs-nav → grid}/types.js +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
package/radio-group/Radio.js
CHANGED
|
@@ -21,7 +21,9 @@ var _uuid = require("uuid");
|
|
|
21
21
|
|
|
22
22
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _Flex = _interopRequireDefault(require("../flex/Flex"));
|
|
25
|
+
|
|
26
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
25
27
|
|
|
26
28
|
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); }
|
|
27
29
|
|
|
@@ -56,7 +58,7 @@ var DxcRadio = function DxcRadio(_ref) {
|
|
|
56
58
|
firstUpdate = _useState4[0],
|
|
57
59
|
setFirstUpdate = _useState4[1];
|
|
58
60
|
|
|
59
|
-
(0, _react.
|
|
61
|
+
(0, _react.useEffect)(function () {
|
|
60
62
|
var _ref$current2;
|
|
61
63
|
|
|
62
64
|
// Don't apply in the first render
|
|
@@ -69,7 +71,7 @@ var DxcRadio = function DxcRadio(_ref) {
|
|
|
69
71
|
}, [focused]);
|
|
70
72
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
71
73
|
theme: colorsTheme.radioGroup
|
|
72
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
74
|
+
}, /*#__PURE__*/_react["default"].createElement(_Flex["default"], null, /*#__PURE__*/_react["default"].createElement(RadioContainer, {
|
|
73
75
|
error: error,
|
|
74
76
|
disabled: disabled,
|
|
75
77
|
readonly: readonly,
|
|
@@ -107,11 +109,9 @@ var getRadioInputStateColor = function getRadioInputStateColor(props, state) {
|
|
|
107
109
|
}
|
|
108
110
|
};
|
|
109
111
|
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
var RadioInputContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
|
|
112
|
+
var RadioInputContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
|
|
113
113
|
|
|
114
|
-
var RadioInput = _styledComponents["default"].span(
|
|
114
|
+
var RadioInput = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n border: 2px solid ", ";\n border-radius: 50%;\n\n &:focus {\n outline: 2px solid ", ";\n outline-offset: 1px;\n }\n ", "\n"])), function (props) {
|
|
115
115
|
return getRadioInputStateColor(props, "enabled");
|
|
116
116
|
}, function (props) {
|
|
117
117
|
return props.theme.focusBorderColor;
|
|
@@ -119,11 +119,11 @@ var RadioInput = _styledComponents["default"].span(_templateObject3 || (_templat
|
|
|
119
119
|
return props.disabled && "pointer-events: none;";
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
var Dot = _styledComponents["default"].span(
|
|
122
|
+
var Dot = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background-color: ", ";\n"])), function (props) {
|
|
123
123
|
return getRadioInputStateColor(props, "enabled");
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
var Label = _styledComponents["default"].span(
|
|
126
|
+
var Label = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
|
|
127
127
|
return props.theme.radioInputLabelMargin;
|
|
128
128
|
}, function (props) {
|
|
129
129
|
return props.theme.fontFamily;
|
|
@@ -139,7 +139,7 @@ var Label = _styledComponents["default"].span(_templateObject5 || (_templateObje
|
|
|
139
139
|
return props.disabled ? "color: ".concat(props.theme.disabledRadioInputLabelFontColor, ";") : "color: ".concat(props.theme.radioInputLabelFontColor);
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
var RadioContainer = _styledComponents["default"].span(
|
|
142
|
+
var RadioContainer = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n\n &:hover {\n ", " {\n border-color: ", ";\n }\n ", " {\n background-color: ", ";\n }\n }\n &:active {\n ", " {\n border-color: ", ";\n }\n ", " {\n background-color: ", ";\n }\n }\n"])), function (props) {
|
|
143
143
|
return props.disabled ? "not-allowed" : props.readonly ? "default" : "pointer";
|
|
144
144
|
}, RadioInput, function (props) {
|
|
145
145
|
return !props.disabled && getRadioInputStateColor(props, "hover");
|
|
@@ -83,14 +83,13 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
83
83
|
|
|
84
84
|
var colorsTheme = (0, _useTheme["default"])();
|
|
85
85
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
86
|
-
var optionalItem = {
|
|
87
|
-
label: optionalItemLabel || translatedLabels.radioGroup.optionalItemLabelDefault,
|
|
88
|
-
value: "",
|
|
89
|
-
disabled: disabled
|
|
90
|
-
};
|
|
91
86
|
var innerOptions = (0, _react.useMemo)(function () {
|
|
92
|
-
return optional ? [].concat((0, _toConsumableArray2["default"])(options), [
|
|
93
|
-
|
|
87
|
+
return optional ? [].concat((0, _toConsumableArray2["default"])(options), [{
|
|
88
|
+
label: optionalItemLabel !== null && optionalItemLabel !== void 0 ? optionalItemLabel : translatedLabels.radioGroup.optionalItemLabelDefault,
|
|
89
|
+
value: "",
|
|
90
|
+
disabled: disabled
|
|
91
|
+
}]) : options;
|
|
92
|
+
}, [optional, options, optionalItemLabel, translatedLabels]);
|
|
94
93
|
|
|
95
94
|
var _useState7 = (0, _react.useState)(getInitialFocusIndex(innerOptions, value !== null && value !== void 0 ? value : innerValue)),
|
|
96
95
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
@@ -202,8 +201,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
202
201
|
name: name,
|
|
203
202
|
disabled: disabled,
|
|
204
203
|
value: (_ref2 = value !== null && value !== void 0 ? value : innerValue) !== null && _ref2 !== void 0 ? _ref2 : "",
|
|
205
|
-
readOnly: true
|
|
206
|
-
"aria-hidden": "true"
|
|
204
|
+
readOnly: true
|
|
207
205
|
}), innerOptions.map(function (option, index) {
|
|
208
206
|
return /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
|
|
209
207
|
key: "radio-".concat(index),
|
|
@@ -225,7 +223,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
225
223
|
}, error)));
|
|
226
224
|
});
|
|
227
225
|
|
|
228
|
-
var RadioGroupContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: column;\n
|
|
226
|
+
var RadioGroupContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n flex-direction: column;\n"])));
|
|
229
227
|
|
|
230
228
|
var Label = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
|
|
231
229
|
return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import DxcRadioGroup from "./RadioGroup";
|
|
5
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: "Radio Group",
|
|
@@ -19,83 +20,195 @@ const options = [
|
|
|
19
20
|
|
|
20
21
|
const single_disabled_options = [{ label: "Option A", value: "A", disabled: true }];
|
|
21
22
|
|
|
23
|
+
const opinionatedTheme = {
|
|
24
|
+
radioGroup: {
|
|
25
|
+
baseColor: "#0086e6",
|
|
26
|
+
fontColor: "#000000",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
22
30
|
export const Chromatic = () => (
|
|
23
31
|
<>
|
|
24
32
|
<Title title="Radio input states" theme="light" level={2} />
|
|
25
33
|
<ExampleContainer>
|
|
26
34
|
<Title title="Enabled" theme="light" level={4} />
|
|
27
|
-
<DxcRadioGroup label="
|
|
35
|
+
<DxcRadioGroup label="Label" helperText="Helper text" defaultValue="A" options={single_option} />
|
|
28
36
|
</ExampleContainer>
|
|
29
37
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
30
38
|
<Title title="Hovered" theme="light" level={4} />
|
|
31
|
-
<DxcRadioGroup label="
|
|
39
|
+
<DxcRadioGroup label="Label" helperText="Helper text" defaultValue="A" options={single_option} />
|
|
32
40
|
</ExampleContainer>
|
|
33
41
|
<ExampleContainer pseudoState="pseudo-active">
|
|
34
42
|
<Title title="Active" theme="light" level={4} />
|
|
35
|
-
<DxcRadioGroup label="
|
|
43
|
+
<DxcRadioGroup label="Label" helperText="Helper text" defaultValue="A" options={single_option} />
|
|
36
44
|
</ExampleContainer>
|
|
37
45
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
38
46
|
<Title title="Focused" theme="light" level={4} />
|
|
39
|
-
<DxcRadioGroup label="
|
|
47
|
+
<DxcRadioGroup label="Label" helperText="Helper text" defaultValue="A" options={single_option} />
|
|
40
48
|
</ExampleContainer>
|
|
41
49
|
<ExampleContainer>
|
|
42
50
|
<Title title="Disabled" theme="light" level={4} />
|
|
43
|
-
<DxcRadioGroup label="
|
|
51
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={single_disabled_options} defaultValue="A" />
|
|
44
52
|
</ExampleContainer>
|
|
45
53
|
<Title title="Readonly radio input sub-states" theme="light" level={3} />
|
|
46
54
|
<ExampleContainer>
|
|
47
55
|
<Title title="Enabled" theme="light" level={4} />
|
|
48
|
-
<DxcRadioGroup label="
|
|
56
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={single_option} defaultValue="A" readonly />
|
|
49
57
|
</ExampleContainer>
|
|
50
58
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
51
59
|
<Title title="Hovered" theme="light" level={4} />
|
|
52
|
-
<DxcRadioGroup label="
|
|
60
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={single_option} defaultValue="A" readonly />
|
|
53
61
|
</ExampleContainer>
|
|
54
62
|
<ExampleContainer pseudoState="pseudo-active">
|
|
55
63
|
<Title title="Active" theme="light" level={4} />
|
|
56
|
-
<DxcRadioGroup label="
|
|
64
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={single_option} defaultValue="A" readonly />
|
|
57
65
|
</ExampleContainer>
|
|
58
66
|
<Title title="Error radio input sub-states" theme="light" level={3} />
|
|
59
67
|
<ExampleContainer>
|
|
60
68
|
<Title title="Enabled" theme="light" level={4} />
|
|
61
|
-
<DxcRadioGroup
|
|
69
|
+
<DxcRadioGroup
|
|
70
|
+
label="Label"
|
|
71
|
+
helperText="Helper text"
|
|
72
|
+
options={single_option}
|
|
73
|
+
defaultValue="A"
|
|
74
|
+
error="Error message"
|
|
75
|
+
/>
|
|
62
76
|
</ExampleContainer>
|
|
63
77
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
64
78
|
<Title title="Hovered" theme="light" level={4} />
|
|
65
|
-
<DxcRadioGroup
|
|
79
|
+
<DxcRadioGroup
|
|
80
|
+
label="Label"
|
|
81
|
+
helperText="Helper text"
|
|
82
|
+
options={single_option}
|
|
83
|
+
defaultValue="A"
|
|
84
|
+
readonly
|
|
85
|
+
error="Error message"
|
|
86
|
+
/>
|
|
66
87
|
</ExampleContainer>
|
|
67
88
|
<ExampleContainer pseudoState="pseudo-active">
|
|
68
89
|
<Title title="Active" theme="light" level={4} />
|
|
69
|
-
<DxcRadioGroup
|
|
90
|
+
<DxcRadioGroup
|
|
91
|
+
label="Label"
|
|
92
|
+
helperText="Helper text"
|
|
93
|
+
options={single_option}
|
|
94
|
+
defaultValue="A"
|
|
95
|
+
readonly
|
|
96
|
+
error="Error message"
|
|
97
|
+
/>
|
|
70
98
|
</ExampleContainer>
|
|
71
99
|
<Title title="Variants" theme="light" level={2} />
|
|
72
100
|
<ExampleContainer>
|
|
73
101
|
<Title title="Column" theme="light" level={4} />
|
|
74
|
-
<DxcRadioGroup label="
|
|
102
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={options} />
|
|
75
103
|
</ExampleContainer>
|
|
76
104
|
<ExampleContainer>
|
|
77
105
|
<Title title="Row" theme="light" level={4} />
|
|
78
|
-
<DxcRadioGroup label="
|
|
106
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={options} stacking="row" />
|
|
79
107
|
</ExampleContainer>
|
|
80
108
|
<ExampleContainer>
|
|
81
109
|
<Title title="Optional" theme="light" level={4} />
|
|
82
|
-
<DxcRadioGroup label="
|
|
110
|
+
<DxcRadioGroup label="Label" optional helperText="Helper text" options={options} stacking="row" />
|
|
83
111
|
</ExampleContainer>
|
|
84
112
|
<ExampleContainer>
|
|
85
113
|
<Title title="Disabled" theme="light" level={4} />
|
|
86
|
-
<DxcRadioGroup label="
|
|
114
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={options} disabled />
|
|
87
115
|
</ExampleContainer>
|
|
88
116
|
<ExampleContainer>
|
|
89
117
|
<Title title="Readonly" theme="light" level={4} />
|
|
90
|
-
<DxcRadioGroup label="
|
|
118
|
+
<DxcRadioGroup label="Label" readonly helperText="Helper text" options={options} />
|
|
91
119
|
</ExampleContainer>
|
|
92
120
|
<ExampleContainer>
|
|
93
121
|
<Title title="Error space reserved" theme="light" level={4} />
|
|
94
|
-
<DxcRadioGroup label="
|
|
122
|
+
<DxcRadioGroup label="Label" error="" helperText="Helper text" options={options} />
|
|
95
123
|
</ExampleContainer>
|
|
96
124
|
<ExampleContainer>
|
|
97
125
|
<Title title="Error" theme="light" level={4} />
|
|
98
|
-
<DxcRadioGroup label="
|
|
126
|
+
<DxcRadioGroup label="Label" error="Error message" helperText="Helper text" options={options} />
|
|
127
|
+
</ExampleContainer>
|
|
128
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
129
|
+
<ExampleContainer>
|
|
130
|
+
<Title title="Enabled" theme="light" level={4} />
|
|
131
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
132
|
+
<DxcRadioGroup label="Label" helperText="Helper text" defaultValue="A" options={single_option} />
|
|
133
|
+
</HalstackProvider>
|
|
134
|
+
</ExampleContainer>
|
|
135
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
136
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
137
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
138
|
+
<DxcRadioGroup label="Label" helperText="Helper text" defaultValue="A" options={single_option} />
|
|
139
|
+
</HalstackProvider>
|
|
140
|
+
</ExampleContainer>
|
|
141
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
142
|
+
<Title title="Active" theme="light" level={4} />
|
|
143
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
144
|
+
<DxcRadioGroup label="Label" helperText="Helper text" defaultValue="A" options={single_option} />
|
|
145
|
+
</HalstackProvider>
|
|
146
|
+
</ExampleContainer>
|
|
147
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
148
|
+
<Title title="Focused" theme="light" level={4} />
|
|
149
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
150
|
+
<DxcRadioGroup label="Label" helperText="Helper text" defaultValue="A" options={single_option} />
|
|
151
|
+
</HalstackProvider>
|
|
152
|
+
</ExampleContainer>
|
|
153
|
+
<ExampleContainer>
|
|
154
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
155
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
156
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={single_disabled_options} defaultValue="A" />
|
|
157
|
+
</HalstackProvider>
|
|
158
|
+
</ExampleContainer>
|
|
159
|
+
<ExampleContainer>
|
|
160
|
+
<Title title="Readonly enabled" theme="light" level={4} />
|
|
161
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
162
|
+
<DxcRadioGroup label="Label" options={single_option} defaultValue="A" readonly />
|
|
163
|
+
</HalstackProvider>
|
|
164
|
+
</ExampleContainer>
|
|
165
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
166
|
+
<Title title="Readonly hovered" theme="light" level={4} />
|
|
167
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
168
|
+
<DxcRadioGroup label="Label" options={single_option} defaultValue="A" readonly />
|
|
169
|
+
</HalstackProvider>
|
|
170
|
+
</ExampleContainer>
|
|
171
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
172
|
+
<Title title="Readonly active" theme="light" level={4} />
|
|
173
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
174
|
+
<DxcRadioGroup label="Label" options={single_option} defaultValue="A" readonly />
|
|
175
|
+
</HalstackProvider>
|
|
176
|
+
</ExampleContainer>
|
|
177
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
178
|
+
<Title title="Readonly focused" theme="light" level={4} />
|
|
179
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
180
|
+
<DxcRadioGroup label="Label" options={single_option} defaultValue="A" readonly />
|
|
181
|
+
</HalstackProvider>
|
|
182
|
+
</ExampleContainer>
|
|
183
|
+
<ExampleContainer>
|
|
184
|
+
<Title title="Enabled" theme="light" level={4} />
|
|
185
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
186
|
+
<DxcRadioGroup label="Label" options={single_option} defaultValue="A" error="Error message" />
|
|
187
|
+
</HalstackProvider>
|
|
188
|
+
</ExampleContainer>
|
|
189
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
190
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
191
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
192
|
+
<DxcRadioGroup label="Label" options={single_option} defaultValue="A" error="Error message" />
|
|
193
|
+
</HalstackProvider>
|
|
194
|
+
</ExampleContainer>
|
|
195
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
196
|
+
<Title title="Active" theme="light" level={4} />
|
|
197
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
198
|
+
<DxcRadioGroup label="Label" options={single_option} defaultValue="A" error="Error message" />
|
|
199
|
+
</HalstackProvider>
|
|
200
|
+
</ExampleContainer>
|
|
201
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
202
|
+
<Title title="Focused" theme="light" level={4} />
|
|
203
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
204
|
+
<DxcRadioGroup label="Label" options={single_option} defaultValue="A" error="Error message" />
|
|
205
|
+
</HalstackProvider>
|
|
206
|
+
</ExampleContainer>
|
|
207
|
+
<ExampleContainer>
|
|
208
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
209
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
210
|
+
<DxcRadioGroup label="Label" helperText="Helper text" options={options} disabled defaultValue="A" />
|
|
211
|
+
</HalstackProvider>
|
|
99
212
|
</ExampleContainer>
|
|
100
213
|
</>
|
|
101
214
|
);
|
|
@@ -73,7 +73,7 @@ describe("Radio Group component tests", function () {
|
|
|
73
73
|
expect(error.getAttribute("aria-live")).toBe("off");
|
|
74
74
|
radios.forEach(function (radio, index) {
|
|
75
75
|
// if no option was previously selected, first option is the focusable one
|
|
76
|
-
index === 0
|
|
76
|
+
if (index === 0) expect(radio.tabIndex).toBe(0);else expect(radio.tabIndex).toBe(-1);
|
|
77
77
|
expect(radio.getAttribute("aria-checked")).toBe("false");
|
|
78
78
|
expect(radio.getAttribute("aria-disabled")).toBe("false");
|
|
79
79
|
expect(radio.getAttribute("aria-labelledby")).toBe(getByText("Option 0".concat(index + 1)).id);
|
|
@@ -19,7 +19,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
21
|
|
|
22
|
-
var _variables = require("../common/variables
|
|
22
|
+
var _variables = require("../common/variables");
|
|
23
23
|
|
|
24
24
|
var _Table = _interopRequireDefault(require("../table/Table"));
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
29
29
|
|
|
30
30
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
31
31
|
|
|
32
|
-
var _utils = require("../common/utils
|
|
32
|
+
var _utils = require("../common/utils");
|
|
33
33
|
|
|
34
34
|
var _templateObject, _templateObject2, _templateObject3;
|
|
35
35
|
|
|
@@ -12,7 +12,7 @@ var _react2 = require("@testing-library/react");
|
|
|
12
12
|
|
|
13
13
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
14
14
|
|
|
15
|
-
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable"));
|
|
15
|
+
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable.tsx"));
|
|
16
16
|
|
|
17
17
|
// Mocking DOMRect for Radix Primitive Popover
|
|
18
18
|
global.globalThis = global;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type Column = {
|
|
9
|
+
export declare type Column = {
|
|
10
10
|
/**
|
|
11
11
|
* Column display value.
|
|
12
12
|
*/
|
package/select/Select.js
CHANGED
|
@@ -25,11 +25,11 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
25
25
|
|
|
26
26
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
27
|
|
|
28
|
-
var _variables = require("../common/variables
|
|
28
|
+
var _variables = require("../common/variables");
|
|
29
29
|
|
|
30
30
|
var _uuid = require("uuid");
|
|
31
31
|
|
|
32
|
-
var _utils = require("../common/utils
|
|
32
|
+
var _utils = require("../common/utils");
|
|
33
33
|
|
|
34
34
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
35
35
|
|
|
@@ -99,9 +99,9 @@ var getSelectedOption = function getSelectedOption(value, options, multiple, opt
|
|
|
99
99
|
options.forEach(function (option) {
|
|
100
100
|
if (option.options) {
|
|
101
101
|
option.options.forEach(function (singleOption) {
|
|
102
|
-
if (value.includes(singleOption.value)) selectedOption.push(singleOption);
|
|
102
|
+
if (value.includes(singleOption.value) && Array.isArray(selectedOption)) selectedOption.push(singleOption);
|
|
103
103
|
});
|
|
104
|
-
} else if (value.includes(option.value)) selectedOption.push(option);
|
|
104
|
+
} else if (value.includes(option.value) && Array.isArray(selectedOption)) selectedOption.push(option);
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
} else {
|
|
@@ -163,7 +163,7 @@ var useWidth = function useWidth(target) {
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
166
|
-
var _selectedOption$label;
|
|
166
|
+
var _ref4, _selectedOption$label;
|
|
167
167
|
|
|
168
168
|
var label = _ref.label,
|
|
169
169
|
_ref$name = _ref.name,
|
|
@@ -256,9 +256,11 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
256
256
|
var newValue;
|
|
257
257
|
|
|
258
258
|
if (multiple) {
|
|
259
|
-
|
|
259
|
+
var _ref2, _ref3;
|
|
260
|
+
|
|
261
|
+
if ((value !== null && value !== void 0 ? value : innerValue).includes(newOption.value)) newValue = ((_ref2 = value && Array.isArray(value) && value) !== null && _ref2 !== void 0 ? _ref2 : innerValue && Array.isArray(innerValue) && innerValue).filter(function (optionVal) {
|
|
260
262
|
return optionVal !== newOption.value;
|
|
261
|
-
});else newValue = [].concat((0, _toConsumableArray2["default"])(value !== null &&
|
|
263
|
+
});else newValue = [].concat((0, _toConsumableArray2["default"])((_ref3 = value && Array.isArray(value) && value) !== null && _ref3 !== void 0 ? _ref3 : innerValue && Array.isArray(innerValue) && innerValue), [newOption.value]);
|
|
262
264
|
} else newValue = newOption.value;
|
|
263
265
|
|
|
264
266
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
@@ -422,7 +424,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
422
424
|
"aria-invalid": error ? true : false,
|
|
423
425
|
"aria-errormessage": error ? errorId : undefined,
|
|
424
426
|
"aria-required": !disabled && !optional
|
|
425
|
-
}, multiple && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
427
|
+
}, multiple && Array.isArray(selectedOption) && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
426
428
|
disabled: disabled
|
|
427
429
|
}, selectedOption.length), /*#__PURE__*/_react["default"].createElement(ClearOptionsAction, {
|
|
428
430
|
disabled: disabled,
|
|
@@ -437,7 +439,7 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
437
439
|
}, _Icons["default"].clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
438
440
|
name: name,
|
|
439
441
|
disabled: disabled,
|
|
440
|
-
value: multiple ? (value !== null &&
|
|
442
|
+
value: multiple ? ((_ref4 = value && Array.isArray(value) && value) !== null && _ref4 !== void 0 ? _ref4 : innerValue && Array.isArray(innerValue) && innerValue).join(",") : value !== null && value !== void 0 ? value : innerValue,
|
|
441
443
|
readOnly: true,
|
|
442
444
|
"aria-hidden": "true"
|
|
443
445
|
}), searchable && /*#__PURE__*/_react["default"].createElement(SearchInput, {
|
|
@@ -451,9 +453,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
451
453
|
}), (!searchable || searchValue === "") && (multiple ? /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
452
454
|
disabled: disabled,
|
|
453
455
|
atBackground: (value !== null && value !== void 0 ? value : innerValue).length === 0 || searchable && isOpen
|
|
454
|
-
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, null, selectedOption.map(function (option) {
|
|
456
|
+
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, null, Array.isArray(selectedOption) && selectedOption.map(function (option) {
|
|
455
457
|
return option.label;
|
|
456
|
-
}).join(", ")), selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
458
|
+
}).join(", ")), Array.isArray(selectedOption) && selectedOption.length === 0 && placeholder) : /*#__PURE__*/_react["default"].createElement(SelectedOption, {
|
|
457
459
|
disabled: disabled,
|
|
458
460
|
atBackground: !(value !== null && value !== void 0 ? value : innerValue) || searchable && isOpen
|
|
459
461
|
}, /*#__PURE__*/_react["default"].createElement(SelectedOptionLabel, null, (_selectedOption$label = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) !== null && _selectedOption$label !== void 0 ? _selectedOption$label : placeholder)))), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, null, _Icons["default"].error), searchable && searchValue.length > 0 && /*#__PURE__*/_react["default"].createElement(ClearSearchAction, {
|