@dxc-technology/halstack-react 9.1.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.
Files changed (109) hide show
  1. package/HalstackContext.d.ts +11 -6
  2. package/HalstackContext.js +1 -1
  3. package/README.md +47 -0
  4. package/accordion/Accordion.d.ts +1 -1
  5. package/accordion/Accordion.js +2 -14
  6. package/accordion/Accordion.stories.tsx +2 -100
  7. package/accordion/types.d.ts +0 -12
  8. package/accordion-group/AccordionGroup.d.ts +4 -3
  9. package/accordion-group/AccordionGroup.js +21 -42
  10. package/accordion-group/AccordionGroup.stories.tsx +77 -76
  11. package/accordion-group/AccordionGroup.test.js +6 -16
  12. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  13. package/accordion-group/AccordionGroupAccordion.js +43 -0
  14. package/accordion-group/types.d.ts +0 -12
  15. package/alert/Alert.js +1 -3
  16. package/box/Box.d.ts +1 -1
  17. package/box/Box.js +5 -22
  18. package/box/Box.stories.tsx +25 -53
  19. package/box/types.d.ts +0 -12
  20. package/bulleted-list/BulletedList.js +4 -2
  21. package/bulleted-list/BulletedList.stories.tsx +7 -1
  22. package/bulleted-list/types.d.ts +31 -4
  23. package/button/Button.d.ts +1 -1
  24. package/button/Button.js +45 -54
  25. package/button/Button.stories.tsx +3 -3
  26. package/button/Button.test.js +11 -0
  27. package/button/types.d.ts +4 -0
  28. package/card/Card.d.ts +1 -1
  29. package/card/Card.js +18 -35
  30. package/card/Card.stories.tsx +0 -29
  31. package/card/types.d.ts +1 -7
  32. package/chip/Chip.js +23 -36
  33. package/chip/Chip.stories.tsx +25 -17
  34. package/common/OpenSans.css +68 -80
  35. package/common/coreTokens.d.ts +146 -0
  36. package/common/coreTokens.js +167 -0
  37. package/common/variables.d.ts +9 -144
  38. package/common/variables.js +960 -1095
  39. package/date-input/Calendar.js +2 -2
  40. package/dialog/Dialog.d.ts +1 -1
  41. package/dialog/Dialog.js +4 -22
  42. package/dialog/Dialog.stories.tsx +52 -176
  43. package/dialog/types.d.ts +0 -13
  44. package/dropdown/DropdownMenu.js +5 -1
  45. package/file-input/FileItem.js +2 -2
  46. package/file-input/types.d.ts +1 -1
  47. package/flex/Flex.js +4 -2
  48. package/flex/Flex.stories.tsx +24 -10
  49. package/flex/types.d.ts +70 -5
  50. package/footer/Footer.d.ts +1 -1
  51. package/footer/Footer.js +43 -61
  52. package/footer/Footer.stories.tsx +19 -95
  53. package/footer/Footer.test.js +3 -1
  54. package/footer/types.d.ts +10 -12
  55. package/grid/Grid.d.ts +1 -1
  56. package/grid/Grid.js +1 -1
  57. package/grid/Grid.stories.tsx +38 -38
  58. package/header/Header.d.ts +1 -1
  59. package/header/Header.js +3 -30
  60. package/header/Header.stories.tsx +7 -71
  61. package/header/types.d.ts +0 -14
  62. package/image/Image.d.ts +4 -0
  63. package/image/Image.js +85 -0
  64. package/image/Image.stories.tsx +127 -0
  65. package/image/types.d.ts +72 -0
  66. package/inset/Inset.stories.tsx +1 -1
  67. package/layout/ApplicationLayout.d.ts +2 -2
  68. package/layout/ApplicationLayout.js +14 -11
  69. package/layout/ApplicationLayout.stories.tsx +1 -1
  70. package/layout/Icons.d.ts +7 -4
  71. package/layout/Icons.js +52 -56
  72. package/link/Link.js +1 -1
  73. package/main.d.ts +2 -1
  74. package/main.js +8 -0
  75. package/nav-tabs/NavTabs.d.ts +2 -2
  76. package/nav-tabs/NavTabs.js +7 -10
  77. package/nav-tabs/NavTabs.stories.tsx +14 -0
  78. package/nav-tabs/Tab.js +22 -26
  79. package/nav-tabs/types.d.ts +8 -9
  80. package/number-input/NumberInput.d.ts +7 -0
  81. package/number-input/NumberInput.js +6 -4
  82. package/number-input/NumberInput.test.js +278 -95
  83. package/package.json +2 -2
  84. package/paginator/Paginator.js +1 -1
  85. package/paginator/Paginator.test.js +13 -0
  86. package/password-input/Icons.d.ts +6 -0
  87. package/password-input/Icons.js +39 -0
  88. package/password-input/PasswordInput.js +35 -82
  89. package/password-input/PasswordInput.stories.tsx +1 -0
  90. package/password-input/PasswordInput.test.js +27 -34
  91. package/radio-group/Radio.js +10 -10
  92. package/radio-group/RadioGroup.js +8 -10
  93. package/select/Select.stories.tsx +3 -3
  94. package/select/Select.test.js +4 -4
  95. package/sidenav/Sidenav.js +21 -23
  96. package/text-input/TextInput.js +62 -78
  97. package/text-input/TextInput.stories.tsx +1 -1
  98. package/toggle-group/ToggleGroup.d.ts +2 -2
  99. package/toggle-group/ToggleGroup.js +79 -56
  100. package/toggle-group/ToggleGroup.stories.tsx +6 -3
  101. package/toggle-group/ToggleGroup.test.js +37 -23
  102. package/toggle-group/types.d.ts +22 -13
  103. package/useTheme.d.ts +9 -1
  104. package/utils/FocusLock.js +2 -3
  105. package/card/ice-cream.jpg +0 -0
  106. package/number-input/NumberInputContext.d.ts +0 -4
  107. package/number-input/NumberInputContext.js +0 -19
  108. package/number-input/numberInputContextTypes.d.ts +0 -19
  109. /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
@@ -27,7 +27,9 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
27
27
 
28
28
  var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
29
29
 
30
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
30
+ var _Flex = _interopRequireDefault(require("../flex/Flex"));
31
+
32
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
31
33
 
32
34
  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); }
33
35
 
@@ -47,17 +49,17 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
47
49
  multiple = _ref$multiple === void 0 ? false : _ref$multiple,
48
50
  _ref$tabIndex = _ref.tabIndex,
49
51
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
50
- var colorsTheme = (0, _useTheme["default"])();
51
52
 
52
- var _useState = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : multiple ? [] : -1),
53
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
54
- selectedValue = _useState2[0],
55
- setSelectedValue = _useState2[1];
53
+ var _useState = (0, _react.useState)("label-toggle-group-".concat((0, _uuid.v4)())),
54
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 1),
55
+ toggleGroupLabelId = _useState2[0];
56
56
 
57
- var _useState3 = (0, _react.useState)("toggle-group-".concat((0, _uuid.v4)())),
58
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
59
- toggleGroupId = _useState4[0];
57
+ var _useState3 = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : multiple ? [] : -1),
58
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
59
+ selectedValue = _useState4[0],
60
+ setSelectedValue = _useState4[1];
60
61
 
62
+ var colorsTheme = (0, _useTheme["default"])();
61
63
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
62
64
 
63
65
  var handleToggleChange = function handleToggleChange(selectedOption) {
@@ -93,9 +95,13 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
93
95
  onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? newSelectedOptions : selectedOption);
94
96
  };
95
97
 
96
- var handleKeyPress = function handleKeyPress(event, optionValue) {
97
- event.preventDefault();
98
- if (!disabled && (event.nativeEvent.code === "Enter" || event.nativeEvent.code === "Space")) handleToggleChange(optionValue);
98
+ var handleOnKeyDown = function handleOnKeyDown(event, optionValue) {
99
+ switch (event.key) {
100
+ case "Enter":
101
+ case " ":
102
+ event.preventDefault();
103
+ handleToggleChange(optionValue);
104
+ }
99
105
  };
100
106
 
101
107
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
@@ -103,40 +109,53 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
103
109
  }, /*#__PURE__*/_react["default"].createElement(ToggleGroup, {
104
110
  margin: margin
105
111
  }, /*#__PURE__*/_react["default"].createElement(Label, {
106
- htmlFor: toggleGroupId,
112
+ id: toggleGroupLabelId,
107
113
  disabled: disabled
108
114
  }, label), /*#__PURE__*/_react["default"].createElement(HelperText, {
109
115
  disabled: disabled
110
116
  }, helperText), /*#__PURE__*/_react["default"].createElement(OptionsContainer, {
111
- id: toggleGroupId,
112
- role: multiple ? "group" : "radiogroup"
117
+ "aria-labelledby": toggleGroupLabelId
113
118
  }, options.map(function (option, i) {
114
- return /*#__PURE__*/_react["default"].createElement(ToggleContainer, {
115
- selected: multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
116
- role: multiple ? "switch" : "radio",
117
- backgroundType: backgroundType,
118
- "aria-checked": multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
119
- tabIndex: !disabled ? tabIndex : -1,
119
+ return /*#__PURE__*/_react["default"].createElement(ToggleButton, {
120
+ key: "toggle-".concat(i, "-").concat(option.label),
121
+ "aria-label": option.title,
122
+ "aria-pressed": multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
123
+ disabled: disabled,
120
124
  onClick: function onClick() {
121
- return !disabled && handleToggleChange(option.value);
125
+ handleToggleChange(option.value);
122
126
  },
123
- isLast: i === options.length - 1,
124
- isIcon: option.icon,
125
- optionLabel: option.label,
126
- disabled: disabled,
127
- onKeyPress: function onKeyPress(event) {
128
- handleKeyPress(event, option.value);
127
+ onKeyDown: function onKeyDown(event) {
128
+ handleOnKeyDown(event, option.value);
129
129
  },
130
- key: "toggle-".concat(i, "-").concat(option.label)
131
- }, /*#__PURE__*/_react["default"].createElement(OptionContent, null, option.icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
130
+ tabIndex: !disabled ? tabIndex : -1,
131
+ title: option.title,
132
+ backgroundType: backgroundType,
133
+ hasIcon: option.icon,
134
+ optionLabel: option.label,
135
+ selected: multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue
136
+ }, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
137
+ alignItems: "center"
138
+ }, option.icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
132
139
  optionLabel: option.label
133
- }, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement(Icon, {
140
+ }, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
134
141
  src: option.icon
135
142
  }) : option.icon), option.label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, option.label)));
136
143
  }))));
137
144
  };
138
145
 
139
- var Label = _styledComponents["default"].label(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
146
+ var ToggleGroup = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
147
+ return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
148
+ }, function (props) {
149
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
150
+ }, function (props) {
151
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
152
+ }, function (props) {
153
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
154
+ }, function (props) {
155
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
156
+ });
157
+
158
+ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
140
159
  return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
141
160
  }, function (props) {
142
161
  return props.theme.labelFontFamily;
@@ -150,7 +169,7 @@ var Label = _styledComponents["default"].label(_templateObject || (_templateObje
150
169
  return props.theme.labelLineHeight;
151
170
  });
152
171
 
153
- var HelperText = _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"])), function (props) {
172
+ var HelperText = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
154
173
  return props.disabled ? props.theme.disabledHelperTextFontcolor : props.theme.helperTextFontColor;
155
174
  }, function (props) {
156
175
  return props.theme.helperTextFontFamily;
@@ -164,19 +183,7 @@ var HelperText = _styledComponents["default"].span(_templateObject2 || (_templat
164
183
  return props.theme.helperTextLineHeight;
165
184
  });
166
185
 
167
- var ToggleGroup = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
168
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
169
- }, function (props) {
170
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
171
- }, function (props) {
172
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
173
- }, function (props) {
174
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
175
- }, function (props) {
176
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
177
- });
178
-
179
- var OptionsContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n width: max-content;\n opacity: 1;\n height: calc(48px - 4px - 4px);\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n border-color: ", ";\n background-color: ", ";\n padding: 4px;\n margin-top: ", ";\n"])), function (props) {
186
+ var OptionsContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n gap: 0.25rem;\n width: max-content;\n height: calc(48px - 4px - 4px);\n padding: 0.25rem;\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n border-color: ", ";\n margin-top: ", ";\n background-color: ", ";\n"])), function (props) {
180
187
  return props.theme.containerBorderThickness;
181
188
  }, function (props) {
182
189
  return props.theme.containerBorderStyle;
@@ -184,16 +191,36 @@ var OptionsContainer = _styledComponents["default"].div(_templateObject4 || (_te
184
191
  return props.theme.containerBorderRadius;
185
192
  }, function (props) {
186
193
  return props.theme.containerBorderColor;
187
- }, function (props) {
188
- return props.theme.containerBackgroundColor;
189
194
  }, function (props) {
190
195
  return props.theme.containerMarginTop;
196
+ }, function (props) {
197
+ return props.theme.containerBackgroundColor;
191
198
  });
192
199
 
193
- var ToggleContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n margin-right: ", ";\n\n ", "\n"])), function (props) {
194
- return !props.isLast && "4px";
200
+ var ToggleButton = _styledComponents["default"].button(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n padding-left: ", ";\n padding-right: ", ";\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n background-color: ", ";\n color: ", ";\n cursor: pointer;\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n color: #ffffff;\n }\n &:focus {\n outline: none;\n box-shadow: ", ";\n }\n &:disabled {\n background-color: ", ";\n color: ", ";\n cursor: not-allowed;\n }\n"])), function (props) {
201
+ return props.optionLabel && props.hasIcon || props.optionLabel && !props.hasIcon ? props.theme.labelPaddingLeft : props.theme.iconPaddingLeft;
195
202
  }, function (props) {
196
- return "\n background-color: ".concat(props.selected ? props.disabled ? props.theme.selectedDisabledBackgroundColor : props.theme.selectedBackgroundColor : props.disabled ? props.theme.unselectedDisabledBackgroundColor : props.theme.unselectedBackgroundColor, ";\n border-width: ").concat(props.theme.optionBorderThickness, ";\n border-style: ").concat(props.theme.optionBorderStyle, ";\n border-radius: ").concat(props.theme.optionBorderRadius, ";\n padding-left: ").concat(props.optionLabel && props.isIcon || props.optionLabel && !props.isIcon ? props.theme.labelPaddingLeft : props.theme.iconPaddingLeft, ";\n padding-right: ").concat(props.optionLabel && props.isIcon || props.optionLabel && !props.isIcon ? props.theme.labelPaddingRight : props.theme.iconPaddingRight, ";\n ").concat(!props.disabled ? ":hover {\n background-color: ".concat(props.selected ? props.theme.selectedHoverBackgroundColor : props.theme.unselectedHoverBackgroundColor, ";\n }\n :active {\n background-color: ").concat(props.selected ? props.theme.selectedActiveBackgroundColor : props.theme.unselectedActiveBackgroundColor, ";\n color: #ffffff;\n } \n :focus {\n border-color: transparent;\n box-shadow: 0 0 0 ").concat(props.theme.optionFocusBorderThickness, " ").concat(props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor, ";\n }\n &:focus-visible {\n outline: none;\n }\n cursor: pointer;\n color: ").concat(props.selected ? props.theme.selectedFontColor : props.theme.unselectedFontColor, ";\n") : "color: ".concat(props.selected ? props.theme.selectedDisabledFontColor : props.theme.unselectedDisabledFontColor, ";\n cursor: not-allowed;"), "\n ");
203
+ return props.optionLabel && props.hasIcon || props.optionLabel && !props.hasIcon ? props.theme.labelPaddingRight : props.theme.iconPaddingRight;
204
+ }, function (props) {
205
+ return props.theme.optionBorderThickness;
206
+ }, function (props) {
207
+ return props.theme.optionBorderStyle;
208
+ }, function (props) {
209
+ return props.theme.optionBorderRadius;
210
+ }, function (props) {
211
+ return props.selected ? props.theme.selectedBackgroundColor : props.theme.unselectedBackgroundColor;
212
+ }, function (props) {
213
+ return props.selected ? props.theme.selectedFontColor : props.theme.unselectedFontColor;
214
+ }, function (props) {
215
+ return props.selected ? props.theme.selectedHoverBackgroundColor : props.theme.unselectedHoverBackgroundColor;
216
+ }, function (props) {
217
+ return props.selected ? props.theme.selectedActiveBackgroundColor : props.theme.unselectedActiveBackgroundColor;
218
+ }, function (props) {
219
+ return "0 0 0 ".concat(props.theme.optionFocusBorderThickness, " ").concat(props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor);
220
+ }, function (props) {
221
+ return props.selected ? props.theme.selectedDisabledBackgroundColor : props.theme.unselectedDisabledBackgroundColor;
222
+ }, function (props) {
223
+ return props.selected ? props.theme.selectedDisabledFontColor : props.theme.unselectedDisabledFontColor;
197
224
  });
198
225
 
199
226
  var LabelContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
@@ -206,11 +233,7 @@ var LabelContainer = _styledComponents["default"].span(_templateObject6 || (_tem
206
233
  return props.theme.optionLabelFontWeight;
207
234
  });
208
235
 
209
- var OptionContent = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n align-items: center;\n"])));
210
-
211
- var Icon = _styledComponents["default"].img(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])([""])));
212
-
213
- var IconContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: ", ";\n height: 24px;\n width: 24px;\n overflow: hidden;\n display: flex;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
236
+ var IconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n height: 24px;\n width: 24px;\n margin-right: ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
214
237
  return props.optionLabel && props.theme.iconMarginRight;
215
238
  });
216
239
 
@@ -42,7 +42,7 @@ const options = [
42
42
  },
43
43
  {
44
44
  value: 2,
45
- label: "Twitter",
45
+ label: "X",
46
46
  },
47
47
  {
48
48
  value: 3,
@@ -53,14 +53,17 @@ const optionsWithIcon = [
53
53
  {
54
54
  value: 1,
55
55
  icon: wifiSVG,
56
+ title: "WiFi connection",
56
57
  },
57
58
  {
58
59
  value: 2,
59
60
  icon: ethernetSVG,
61
+ title: "Ethernet connection",
60
62
  },
61
63
  {
62
64
  value: 3,
63
65
  icon: gMobileSVG,
66
+ title: "3G Mobile data connection",
64
67
  },
65
68
  ];
66
69
  const optionsWithIconAndLabel = [
@@ -87,7 +90,7 @@ const twoOptions = [
87
90
  },
88
91
  {
89
92
  value: 2,
90
- label: "Twitter",
93
+ label: "X",
91
94
  },
92
95
  ];
93
96
 
@@ -209,7 +212,7 @@ ToggleGroupSelectedActived.play = async ({ canvasElement }) => {
209
212
  export const ToggleGroupUnselectedActived = OptionSelected.bind({});
210
213
  ToggleGroupUnselectedActived.play = async ({ canvasElement }) => {
211
214
  const canvas = within(canvasElement);
212
- const option = canvas.getByText("Twitter");
215
+ const option = canvas.getByText("X");
213
216
  await userEvent.click(option);
214
217
  userEvent.tab();
215
218
  };
@@ -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 _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
57
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
44
58
  options: options,
45
59
  onChange: onChange
46
60
  })),
47
- getByText = _render2.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 _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
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 = _render3.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 _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
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 = _render4.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 _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
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 = _render5.getAllByRole;
109
+ getAllByRole = _render6.getAllByRole;
96
110
 
97
- var toggleOptions = getAllByRole("switch");
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-checked")).toBe("true");
109
- expect(toggleOptions[1].getAttribute("aria-checked")).toBe("true");
110
- expect(toggleOptions[3].getAttribute("aria-checked")).toBe("true");
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 _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
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 = _render6.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 _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
149
+ var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
136
150
  options: options,
137
151
  defaultValue: 2
138
152
  })),
139
- getAllByRole = _render7.getAllByRole;
153
+ getAllByRole = _render8.getAllByRole;
140
154
 
141
- var toggleOptions = getAllByRole("radio");
142
- expect(toggleOptions[1].getAttribute("aria-checked")).toBe("true");
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 _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
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 = _render8.getAllByRole;
164
+ getAllByRole = _render9.getAllByRole;
151
165
 
152
- var toggleOptions = getAllByRole("switch");
153
- expect(toggleOptions[1].getAttribute("aria-checked")).toBe("true");
154
- expect(toggleOptions[3].getAttribute("aria-checked")).toBe("true");
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
  });
@@ -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 OptionCommons = {
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?: string;
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 = OptionCommons & {
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 = OptionIcon | OptionLabel;
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 SingleSelectionToggle = CommonProps & {
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 MultipleSelectionToggle = CommonProps & {
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 = SingleSelectionToggle | MultipleSelectionToggle;
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;
@@ -499,7 +507,7 @@ declare const useTheme: () => {
499
507
  underlineSpacing: string;
500
508
  underlineStyle: string;
501
509
  underlineThickness: string;
502
- disabledColor: string;
510
+ disabledFontColor: string;
503
511
  hoverFontColor: string;
504
512
  hoverUnderlineColor: string;
505
513
  visitedFontColor: string;
@@ -18,11 +18,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
18
18
  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; }
19
19
 
20
20
  var not = {
21
- inert: ":not([inert]):not([inert] *)",
22
21
  negTabIndex: ':not([tabindex^="-"])',
23
22
  disabled: ":not(:disabled)"
24
23
  };
25
- var focusableQuery = ["a[href]".concat(not.inert).concat(not.negTabIndex), "area[href]".concat(not.inert).concat(not.negTabIndex), "input:not([type=\"hidden\"])".concat(not.inert).concat(not.negTabIndex).concat(not.disabled), "select".concat(not.inert).concat(not.negTabIndex).concat(not.disabled), "textarea".concat(not.inert).concat(not.negTabIndex).concat(not.disabled), "button".concat(not.inert).concat(not.negTabIndex).concat(not.disabled), "details".concat(not.inert, " > summary:first-of-type").concat(not.negTabIndex), "iframe".concat(not.inert).concat(not.negTabIndex), "audio[controls]".concat(not.inert).concat(not.negTabIndex), "video[controls]".concat(not.inert).concat(not.negTabIndex), "[contenteditable]".concat(not.inert).concat(not.negTabIndex), "[tabindex]".concat(not.inert).concat(not.negTabIndex).concat(not.disabled)].join(",");
24
+ var focusableQuery = ["a[href]".concat(not.negTabIndex), "area[href]".concat(not.negTabIndex), "input:not([type=\"hidden\"])".concat(not.negTabIndex).concat(not.disabled), "select".concat(not.negTabIndex).concat(not.disabled), "textarea".concat(not.negTabIndex).concat(not.disabled), "button".concat(not.negTabIndex).concat(not.disabled), "details > summary:first-of-type".concat(not.negTabIndex), "iframe".concat(not.negTabIndex), "audio[controls]".concat(not.negTabIndex), "video[controls]".concat(not.negTabIndex), "[contenteditable]".concat(not.negTabIndex), "[tabindex]".concat(not.negTabIndex).concat(not.disabled)].join(",");
26
25
 
27
26
  var getFocusableElements = function getFocusableElements(container) {
28
27
  return Array.prototype.slice.call(container.querySelectorAll(focusableQuery)).filter(function (element) {
@@ -44,7 +43,7 @@ var attempFocus = function attempFocus(element) {
44
43
  };
45
44
  /**
46
45
  * @param element: HTMLElement
47
- * @returns boolean: true if element is contained inside a Radix Portal, false otherwise.
46
+ * @returns boolean: true if element is contained inside a Radix Portal, false otherwise.
48
47
  */
49
48
 
50
49
 
Binary file
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import NumberInputContextPropsType from "./numberInputContextTypes";
3
- declare const NumberInputContext: React.Context<NumberInputContextPropsType>;
4
- export default NumberInputContext;
@@ -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;