@dxc-technology/halstack-react 0.0.0-a799608 → 0.0.0-a7fec42
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/accordion/types.d.ts +1 -0
- package/accordion-group/types.d.ts +1 -0
- package/alert/Alert.js +1 -1
- package/box/Box.js +1 -1
- package/box/types.d.ts +1 -0
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.js +87 -95
- package/checkbox/Checkbox.test.js +93 -16
- package/checkbox/types.d.ts +2 -2
- package/common/variables.js +1 -1
- package/dialog/Dialog.js +4 -4
- package/dialog/Dialog.stories.tsx +56 -0
- package/dialog/types.d.ts +1 -0
- package/dropdown/Dropdown.js +6 -5
- package/dropdown/Dropdown.test.js +2 -3
- package/dropdown/DropdownMenuItem.js +1 -1
- package/flex/Flex.d.ts +1 -1
- package/flex/Flex.js +31 -19
- package/flex/types.d.ts +14 -3
- package/footer/types.d.ts +1 -0
- package/header/types.d.ts +1 -0
- package/number-input/NumberInput.test.js +1 -1
- package/package.json +6 -6
- package/password-input/PasswordInput.js +4 -2
- package/password-input/PasswordInput.test.js +13 -12
- package/quick-nav/QuickNav.js +11 -12
- package/quick-nav/QuickNav.stories.tsx +97 -19
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +43 -28
- package/radio-group/RadioGroup.js +15 -13
- package/radio-group/RadioGroup.stories.tsx +1 -0
- package/radio-group/RadioGroup.test.js +123 -96
- package/radio-group/types.d.ts +2 -2
- package/select/Listbox.js +0 -1
- package/select/Select.js +3 -1
- package/select/Select.test.js +267 -209
- package/slider/Slider.js +15 -6
- package/switch/Switch.js +91 -81
- package/switch/Switch.test.js +26 -13
- package/table/Table.js +1 -1
- package/tabs-nav/Tab.js +1 -1
- package/tag/Tag.js +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.js +7 -5
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +171 -259
- package/text-input/TextInput.stories.tsx +189 -181
- package/text-input/TextInput.test.js +165 -163
- package/text-input/types.d.ts +23 -4
package/radio-group/Radio.js
CHANGED
|
@@ -28,10 +28,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
28
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
29
|
|
|
30
30
|
var DxcRadio = function DxcRadio(_ref) {
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
var option = _ref.option,
|
|
34
|
-
currentValue = _ref.currentValue,
|
|
31
|
+
var label = _ref.label,
|
|
32
|
+
checked = _ref.checked,
|
|
35
33
|
onClick = _ref.onClick,
|
|
36
34
|
error = _ref.error,
|
|
37
35
|
disabled = _ref.disabled,
|
|
@@ -50,7 +48,7 @@ var DxcRadio = function DxcRadio(_ref) {
|
|
|
50
48
|
var _ref$current;
|
|
51
49
|
|
|
52
50
|
onClick();
|
|
53
|
-
|
|
51
|
+
document.activeElement !== (ref === null || ref === void 0 ? void 0 : ref.current) && (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
|
|
54
52
|
};
|
|
55
53
|
|
|
56
54
|
var _useState3 = (0, _react.useState)(true),
|
|
@@ -75,52 +73,57 @@ var DxcRadio = function DxcRadio(_ref) {
|
|
|
75
73
|
error: error,
|
|
76
74
|
disabled: disabled,
|
|
77
75
|
readonly: readonly,
|
|
78
|
-
|
|
79
|
-
// Prevents div's onClick from stealing the radio input's focus
|
|
80
|
-
event.preventDefault();
|
|
81
|
-
},
|
|
82
|
-
onClick: handleOnClick
|
|
76
|
+
onClick: disabled ? undefined : handleOnClick
|
|
83
77
|
}, /*#__PURE__*/_react["default"].createElement(RadioInputContainer, null, /*#__PURE__*/_react["default"].createElement(RadioInput, {
|
|
84
78
|
error: error,
|
|
85
79
|
disabled: disabled,
|
|
86
80
|
readonly: readonly,
|
|
87
81
|
role: "radio",
|
|
88
|
-
"aria-checked":
|
|
89
|
-
"aria-disabled":
|
|
82
|
+
"aria-checked": checked,
|
|
83
|
+
"aria-disabled": disabled,
|
|
90
84
|
"aria-labelledby": radioLabelId,
|
|
91
85
|
tabIndex: disabled ? -1 : focused ? tabIndex : -1,
|
|
92
86
|
ref: ref
|
|
93
|
-
},
|
|
87
|
+
}, checked && /*#__PURE__*/_react["default"].createElement(Dot, {
|
|
94
88
|
disabled: disabled,
|
|
95
89
|
readonly: readonly,
|
|
96
90
|
error: error
|
|
97
91
|
}))), /*#__PURE__*/_react["default"].createElement(Label, {
|
|
98
92
|
id: radioLabelId,
|
|
99
93
|
disabled: disabled
|
|
100
|
-
},
|
|
94
|
+
}, label))));
|
|
101
95
|
};
|
|
102
96
|
|
|
103
|
-
var
|
|
97
|
+
var getRadioInputStateColor = function getRadioInputStateColor(props, state) {
|
|
98
|
+
switch (state) {
|
|
99
|
+
case "enabled":
|
|
100
|
+
return props.disabled ? props.theme.disabledRadioInputColor : props.error ? props.theme.errorRadioInputColor : props.readonly ? props.theme.readonlyRadioInputColor : props.theme.radioInputColor;
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}, function (props) {
|
|
108
|
-
return !props.disabled ? "\n &:hover {\n & > div > div { \n border-color: ".concat(props.error ? props.theme.hoverErrorRadioInputColor : props.readonly ? props.theme.hoverReadonlyRadioInputColor : props.theme.hoverRadioInputColor, ";\n & > span {\n background-color: ").concat(props.error ? props.theme.hoverErrorRadioInputColor : props.readonly ? props.theme.hoverReadonlyRadioInputColor : props.theme.hoverRadioInputColor, ";\n }\n };\n }\n &:active {\n & > div > div {\n border-color: ").concat(props.error ? props.theme.activeErrorRadioInputColor : props.readonly ? props.theme.activeReadonlyRadioInputColor : props.theme.activeRadioInputColor, ";\n & > span {\n background-color: ").concat(props.error ? props.theme.activeErrorRadioInputColor : props.readonly ? props.theme.activeReadonlyRadioInputColor : props.theme.activeRadioInputColor, ";\n }\n }\n }\n ") : "pointer-events: none;";
|
|
109
|
-
});
|
|
102
|
+
case "hover":
|
|
103
|
+
return props.error ? props.theme.hoverErrorRadioInputColor : props.readonly ? props.theme.hoverReadonlyRadioInputColor : props.theme.hoverRadioInputColor;
|
|
110
104
|
|
|
111
|
-
|
|
105
|
+
case "active":
|
|
106
|
+
return props.error ? props.theme.activeErrorRadioInputColor : props.readonly ? props.theme.activeReadonlyRadioInputColor : props.theme.activeRadioInputColor;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
112
109
|
|
|
113
|
-
var
|
|
114
|
-
|
|
110
|
+
var RadioMainContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n"])));
|
|
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"])));
|
|
113
|
+
|
|
114
|
+
var RadioInput = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (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
|
+
return getRadioInputStateColor(props, "enabled");
|
|
116
|
+
}, function (props) {
|
|
117
|
+
return props.theme.focusBorderColor;
|
|
115
118
|
}, function (props) {
|
|
116
|
-
return
|
|
119
|
+
return props.disabled && "pointer-events: none;";
|
|
117
120
|
});
|
|
118
121
|
|
|
119
|
-
var Dot = _styledComponents["default"].span(
|
|
120
|
-
|
|
122
|
+
var Dot = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background-color: ", ";\n"])), function (props) {
|
|
123
|
+
return getRadioInputStateColor(props, "enabled");
|
|
121
124
|
});
|
|
122
125
|
|
|
123
|
-
var Label = _styledComponents["default"].span(
|
|
126
|
+
var Label = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (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) {
|
|
124
127
|
return props.theme.radioInputLabelMargin;
|
|
125
128
|
}, function (props) {
|
|
126
129
|
return props.theme.fontFamily;
|
|
@@ -133,7 +136,19 @@ var Label = _styledComponents["default"].span(_templateObject6 || (_templateObje
|
|
|
133
136
|
}, function (props) {
|
|
134
137
|
return props.theme.radioInputLabelLineHeight;
|
|
135
138
|
}, function (props) {
|
|
136
|
-
return props.disabled ? "color: ".concat(props.theme.disabledRadioInputLabelFontColor, ";
|
|
139
|
+
return props.disabled ? "color: ".concat(props.theme.disabledRadioInputLabelFontColor, ";") : "color: ".concat(props.theme.radioInputLabelFontColor);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
var RadioContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (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
|
+
return props.disabled ? "not-allowed" : props.readonly ? "default" : "pointer";
|
|
144
|
+
}, RadioInput, function (props) {
|
|
145
|
+
return !props.disabled && getRadioInputStateColor(props, "hover");
|
|
146
|
+
}, Dot, function (props) {
|
|
147
|
+
return !props.disabled && getRadioInputStateColor(props, "hover");
|
|
148
|
+
}, RadioInput, function (props) {
|
|
149
|
+
return !props.disabled && getRadioInputStateColor(props, "active");
|
|
150
|
+
}, Dot, function (props) {
|
|
151
|
+
return !props.disabled && getRadioInputStateColor(props, "active");
|
|
137
152
|
});
|
|
138
153
|
|
|
139
154
|
var _default = /*#__PURE__*/_react["default"].memo(DxcRadio);
|
|
@@ -41,6 +41,8 @@ var getInitialFocusIndex = function getInitialFocusIndex(innerOptions, value) {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
44
|
+
var _ref2;
|
|
45
|
+
|
|
44
46
|
var label = _ref.label,
|
|
45
47
|
name = _ref.name,
|
|
46
48
|
helperText = _ref.helperText,
|
|
@@ -102,11 +104,11 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
102
104
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
103
105
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
104
106
|
}
|
|
105
|
-
}, [value, innerValue,
|
|
107
|
+
}, [value, innerValue, onChange]);
|
|
106
108
|
|
|
107
|
-
var handleOnBlur = function handleOnBlur(
|
|
109
|
+
var handleOnBlur = function handleOnBlur(event) {
|
|
108
110
|
// If the radio group loses the focus to an element not contained inside it...
|
|
109
|
-
if (!
|
|
111
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
110
112
|
setFirstTimeFocus(true);
|
|
111
113
|
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
112
114
|
!optional && !Boolean(currentValue) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
@@ -166,8 +168,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
166
168
|
setNextRadioChecked();
|
|
167
169
|
break;
|
|
168
170
|
|
|
169
|
-
case "
|
|
170
|
-
case "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,20 +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
199
|
"aria-readonly": readonly,
|
|
199
200
|
"aria-orientation": stacking === "column" ? "vertical" : "horizontal"
|
|
200
201
|
}, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
201
202
|
name: name,
|
|
202
|
-
|
|
203
|
+
disabled: disabled,
|
|
204
|
+
value: (_ref2 = value !== null && value !== void 0 ? value : innerValue) !== null && _ref2 !== void 0 ? _ref2 : "",
|
|
203
205
|
readOnly: true,
|
|
204
206
|
"aria-hidden": "true"
|
|
205
207
|
}), innerOptions.map(function (option, index) {
|
|
206
208
|
return /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
key: "radio-".concat(index),
|
|
210
|
+
label: option.label,
|
|
211
|
+
checked: (value !== null && value !== void 0 ? value : innerValue) === option.value,
|
|
209
212
|
onClick: function onClick() {
|
|
210
213
|
handleOnChange(option.value);
|
|
211
214
|
setCurrentFocusIndex(index);
|
|
@@ -214,8 +217,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
214
217
|
disabled: option.disabled || disabled,
|
|
215
218
|
focused: currentFocusIndex === index,
|
|
216
219
|
readonly: readonly,
|
|
217
|
-
tabIndex: tabIndex
|
|
218
|
-
key: "radio-".concat(index)
|
|
220
|
+
tabIndex: tabIndex
|
|
219
221
|
});
|
|
220
222
|
})), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
221
223
|
id: errorId,
|
|
@@ -261,7 +263,7 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
261
263
|
return props.theme.groupLabelMargin;
|
|
262
264
|
});
|
|
263
265
|
|
|
264
|
-
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) {
|
|
265
267
|
return props.stacking;
|
|
266
268
|
}, function (props) {
|
|
267
269
|
return props.theme.groupVerticalGutter;
|