@dxc-technology/halstack-react 0.0.0-6a36022 → 0.0.0-6a99bfa

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 (264) hide show
  1. package/README.md +46 -0
  2. package/dist/index.d.mts +6670 -0
  3. package/dist/index.d.ts +6670 -0
  4. package/dist/index.js +14442 -0
  5. package/dist/index.mjs +14385 -0
  6. package/package.json +69 -70
  7. package/BackgroundColorContext.d.ts +0 -10
  8. package/BackgroundColorContext.js +0 -47
  9. package/ThemeContext.d.ts +0 -15
  10. package/ThemeContext.js +0 -243
  11. package/V3Select/V3Select.js +0 -455
  12. package/V3Select/index.d.ts +0 -27
  13. package/V3Textarea/V3Textarea.js +0 -260
  14. package/V3Textarea/index.d.ts +0 -27
  15. package/accordion/Accordion.d.ts +0 -4
  16. package/accordion/Accordion.js +0 -258
  17. package/accordion/Accordion.stories.tsx +0 -307
  18. package/accordion/types.d.ts +0 -68
  19. package/accordion/types.js +0 -5
  20. package/accordion-group/AccordionGroup.d.ts +0 -7
  21. package/accordion-group/AccordionGroup.js +0 -170
  22. package/accordion-group/AccordionGroup.stories.tsx +0 -225
  23. package/accordion-group/types.d.ts +0 -72
  24. package/accordion-group/types.js +0 -5
  25. package/alert/Alert.d.ts +0 -4
  26. package/alert/Alert.js +0 -290
  27. package/alert/Alert.stories.tsx +0 -170
  28. package/alert/types.d.ts +0 -49
  29. package/alert/types.js +0 -5
  30. package/badge/Badge.js +0 -59
  31. package/box/Box.d.ts +0 -4
  32. package/box/Box.js +0 -126
  33. package/box/Box.stories.tsx +0 -132
  34. package/box/types.d.ts +0 -43
  35. package/box/types.js +0 -5
  36. package/button/Button.d.ts +0 -4
  37. package/button/Button.js +0 -179
  38. package/button/Button.stories.tsx +0 -276
  39. package/button/types.d.ts +0 -57
  40. package/button/types.js +0 -5
  41. package/card/Card.d.ts +0 -4
  42. package/card/Card.js +0 -164
  43. package/card/Card.stories.tsx +0 -201
  44. package/card/ice-cream.jpg +0 -0
  45. package/card/types.d.ts +0 -67
  46. package/card/types.js +0 -5
  47. package/checkbox/Checkbox.d.ts +0 -4
  48. package/checkbox/Checkbox.js +0 -253
  49. package/checkbox/Checkbox.stories.tsx +0 -192
  50. package/checkbox/types.d.ts +0 -60
  51. package/checkbox/types.js +0 -5
  52. package/chip/Chip.d.ts +0 -4
  53. package/chip/Chip.js +0 -199
  54. package/chip/Chip.stories.tsx +0 -121
  55. package/chip/types.d.ts +0 -53
  56. package/chip/types.js +0 -5
  57. package/common/OpenSans.css +0 -81
  58. package/common/RequiredComponent.js +0 -32
  59. package/common/fonts/OpenSans-Bold.ttf +0 -0
  60. package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  61. package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  62. package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  63. package/common/fonts/OpenSans-Italic.ttf +0 -0
  64. package/common/fonts/OpenSans-Light.ttf +0 -0
  65. package/common/fonts/OpenSans-LightItalic.ttf +0 -0
  66. package/common/fonts/OpenSans-Regular.ttf +0 -0
  67. package/common/fonts/OpenSans-SemiBold.ttf +0 -0
  68. package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  69. package/common/utils.js +0 -22
  70. package/common/variables.js +0 -1612
  71. package/date/Date.js +0 -373
  72. package/date/index.d.ts +0 -27
  73. package/date-input/DateInput.d.ts +0 -4
  74. package/date-input/DateInput.js +0 -358
  75. package/date-input/DateInput.stories.tsx +0 -138
  76. package/date-input/types.d.ts +0 -100
  77. package/date-input/types.js +0 -5
  78. package/dialog/Dialog.d.ts +0 -4
  79. package/dialog/Dialog.js +0 -166
  80. package/dialog/Dialog.stories.tsx +0 -212
  81. package/dialog/types.d.ts +0 -43
  82. package/dialog/types.js +0 -5
  83. package/dropdown/Dropdown.d.ts +0 -4
  84. package/dropdown/Dropdown.js +0 -417
  85. package/dropdown/Dropdown.stories.tsx +0 -247
  86. package/dropdown/types.d.ts +0 -89
  87. package/dropdown/types.js +0 -5
  88. package/file-input/FileInput.d.ts +0 -4
  89. package/file-input/FileInput.js +0 -590
  90. package/file-input/FileInput.stories.tsx +0 -507
  91. package/file-input/FileItem.d.ts +0 -14
  92. package/file-input/FileItem.js +0 -184
  93. package/file-input/types.d.ts +0 -112
  94. package/file-input/types.js +0 -5
  95. package/footer/Footer.d.ts +0 -4
  96. package/footer/Footer.js +0 -260
  97. package/footer/Footer.stories.tsx +0 -130
  98. package/footer/Icons.d.ts +0 -2
  99. package/footer/Icons.js +0 -77
  100. package/footer/types.d.ts +0 -65
  101. package/footer/types.js +0 -5
  102. package/header/Header.d.ts +0 -7
  103. package/header/Header.js +0 -324
  104. package/header/Header.stories.tsx +0 -162
  105. package/header/Icons.d.ts +0 -2
  106. package/header/Icons.js +0 -34
  107. package/header/types.d.ts +0 -47
  108. package/header/types.js +0 -5
  109. package/heading/Heading.d.ts +0 -4
  110. package/heading/Heading.js +0 -159
  111. package/heading/Heading.stories.tsx +0 -54
  112. package/heading/types.d.ts +0 -33
  113. package/heading/types.js +0 -5
  114. package/input-text/Icons.js +0 -22
  115. package/input-text/InputText.js +0 -611
  116. package/input-text/index.d.ts +0 -36
  117. package/inset/Inset.d.ts +0 -3
  118. package/inset/Inset.js +0 -84
  119. package/inset/Inset.stories.tsx +0 -229
  120. package/inset/types.d.ts +0 -13
  121. package/inset/types.js +0 -5
  122. package/layout/ApplicationLayout.d.ts +0 -10
  123. package/layout/ApplicationLayout.js +0 -225
  124. package/layout/ApplicationLayout.stories.tsx +0 -171
  125. package/layout/Icons.js +0 -55
  126. package/layout/types.d.ts +0 -57
  127. package/layout/types.js +0 -5
  128. package/link/Link.d.ts +0 -3
  129. package/link/Link.js +0 -161
  130. package/link/Link.stories.tsx +0 -146
  131. package/link/types.d.ts +0 -74
  132. package/link/types.js +0 -5
  133. package/list/List.d.ts +0 -8
  134. package/list/List.js +0 -47
  135. package/list/List.stories.tsx +0 -95
  136. package/main.d.ts +0 -48
  137. package/main.js +0 -395
  138. package/number-input/NumberInput.d.ts +0 -4
  139. package/number-input/NumberInput.js +0 -83
  140. package/number-input/NumberInput.stories.tsx +0 -115
  141. package/number-input/NumberInputContext.d.ts +0 -4
  142. package/number-input/NumberInputContext.js +0 -19
  143. package/number-input/numberInputContextTypes.d.ts +0 -19
  144. package/number-input/numberInputContextTypes.js +0 -5
  145. package/number-input/types.d.ts +0 -117
  146. package/number-input/types.js +0 -5
  147. package/paginator/Icons.js +0 -66
  148. package/paginator/Paginator.d.ts +0 -4
  149. package/paginator/Paginator.js +0 -192
  150. package/paginator/Paginator.stories.tsx +0 -63
  151. package/paginator/types.d.ts +0 -38
  152. package/paginator/types.js +0 -5
  153. package/password-input/PasswordInput.d.ts +0 -4
  154. package/password-input/PasswordInput.js +0 -163
  155. package/password-input/PasswordInput.stories.tsx +0 -131
  156. package/password-input/types.d.ts +0 -107
  157. package/password-input/types.js +0 -5
  158. package/progress-bar/ProgressBar.d.ts +0 -4
  159. package/progress-bar/ProgressBar.js +0 -170
  160. package/progress-bar/ProgressBar.stories.jsx +0 -58
  161. package/progress-bar/types.d.ts +0 -37
  162. package/progress-bar/types.js +0 -5
  163. package/radio/Radio.d.ts +0 -4
  164. package/radio/Radio.js +0 -174
  165. package/radio/Radio.stories.tsx +0 -192
  166. package/radio/types.d.ts +0 -54
  167. package/radio/types.js +0 -5
  168. package/radio-group/Radio.d.ts +0 -4
  169. package/radio-group/Radio.js +0 -130
  170. package/radio-group/RadioGroup.d.ts +0 -4
  171. package/radio-group/RadioGroup.js +0 -268
  172. package/radio-group/RadioGroup.stories.tsx +0 -79
  173. package/radio-group/types.d.ts +0 -36
  174. package/radio-group/types.js +0 -5
  175. package/resultsetTable/ResultsetTable.d.ts +0 -4
  176. package/resultsetTable/ResultsetTable.js +0 -251
  177. package/resultsetTable/ResultsetTable.stories.tsx +0 -277
  178. package/resultsetTable/types.d.ts +0 -67
  179. package/resultsetTable/types.js +0 -5
  180. package/row/Row.d.ts +0 -11
  181. package/row/Row.js +0 -127
  182. package/row/Row.stories.tsx +0 -239
  183. package/select/Select.d.ts +0 -4
  184. package/select/Select.js +0 -863
  185. package/select/Select.stories.tsx +0 -572
  186. package/select/types.d.ts +0 -170
  187. package/select/types.js +0 -5
  188. package/sidenav/Sidenav.d.ts +0 -9
  189. package/sidenav/Sidenav.js +0 -136
  190. package/sidenav/Sidenav.stories.tsx +0 -182
  191. package/sidenav/types.d.ts +0 -50
  192. package/sidenav/types.js +0 -5
  193. package/slider/Slider.d.ts +0 -4
  194. package/slider/Slider.js +0 -317
  195. package/slider/Slider.stories.tsx +0 -177
  196. package/slider/types.d.ts +0 -78
  197. package/slider/types.js +0 -5
  198. package/spinner/Spinner.d.ts +0 -4
  199. package/spinner/Spinner.js +0 -250
  200. package/spinner/Spinner.stories.jsx +0 -103
  201. package/spinner/types.d.ts +0 -32
  202. package/spinner/types.js +0 -5
  203. package/stack/Stack.d.ts +0 -10
  204. package/stack/Stack.js +0 -97
  205. package/stack/Stack.stories.tsx +0 -166
  206. package/switch/Switch.d.ts +0 -4
  207. package/switch/Switch.js +0 -179
  208. package/switch/Switch.stories.tsx +0 -160
  209. package/switch/types.d.ts +0 -58
  210. package/switch/types.js +0 -5
  211. package/table/Table.d.ts +0 -4
  212. package/table/Table.js +0 -118
  213. package/table/Table.stories.jsx +0 -277
  214. package/table/types.d.ts +0 -21
  215. package/table/types.js +0 -5
  216. package/tabs/Tabs.d.ts +0 -4
  217. package/tabs/Tabs.js +0 -213
  218. package/tabs/Tabs.stories.tsx +0 -122
  219. package/tabs/types.d.ts +0 -70
  220. package/tabs/types.js +0 -5
  221. package/tag/Tag.d.ts +0 -4
  222. package/tag/Tag.js +0 -193
  223. package/tag/Tag.stories.tsx +0 -145
  224. package/tag/types.d.ts +0 -60
  225. package/tag/types.js +0 -5
  226. package/text/Text.d.ts +0 -7
  227. package/text/Text.js +0 -30
  228. package/text/Text.stories.tsx +0 -19
  229. package/text-input/TextInput.d.ts +0 -4
  230. package/text-input/TextInput.js +0 -794
  231. package/text-input/TextInput.stories.tsx +0 -456
  232. package/text-input/types.d.ts +0 -159
  233. package/text-input/types.js +0 -5
  234. package/textarea/Textarea.d.ts +0 -4
  235. package/textarea/Textarea.js +0 -284
  236. package/textarea/Textarea.stories.jsx +0 -136
  237. package/textarea/types.d.ts +0 -130
  238. package/textarea/types.js +0 -5
  239. package/toggle/Toggle.js +0 -186
  240. package/toggle/index.d.ts +0 -21
  241. package/toggle-group/ToggleGroup.d.ts +0 -4
  242. package/toggle-group/ToggleGroup.js +0 -214
  243. package/toggle-group/ToggleGroup.stories.tsx +0 -173
  244. package/toggle-group/types.d.ts +0 -97
  245. package/toggle-group/types.js +0 -5
  246. package/upload/Upload.js +0 -201
  247. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  248. package/upload/buttons-upload/Icons.js +0 -40
  249. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  250. package/upload/dragAndDropArea/Icons.js +0 -39
  251. package/upload/file-upload/FileToUpload.js +0 -115
  252. package/upload/file-upload/Icons.js +0 -66
  253. package/upload/files-upload/FilesToUpload.js +0 -109
  254. package/upload/index.d.ts +0 -15
  255. package/upload/transaction/Icons.js +0 -160
  256. package/upload/transaction/Transaction.js +0 -104
  257. package/upload/transactions/Transactions.js +0 -94
  258. package/useTheme.d.ts +0 -2
  259. package/useTheme.js +0 -22
  260. package/wizard/Wizard.d.ts +0 -4
  261. package/wizard/Wizard.js +0 -281
  262. package/wizard/Wizard.stories.tsx +0 -224
  263. package/wizard/types.d.ts +0 -60
  264. package/wizard/types.js +0 -5
package/radio/types.d.ts DELETED
@@ -1,54 +0,0 @@
1
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
- declare type Margin = {
3
- top?: Space;
4
- bottom?: Space;
5
- left?: Space;
6
- right?: Space;
7
- };
8
- declare type Props = {
9
- /**
10
- * If true, the radio is selected. If undefined the component will be uncontrolled
11
- * and the value will be managed internally by the component.
12
- */
13
- checked?: boolean;
14
- /**
15
- * Will be passed to the value attribute of the html input element. When inside a
16
- * form, this value will be only submitted if the radio is checked.
17
- */
18
- value?: string;
19
- /**
20
- * Text to be placed next to the radio.
21
- */
22
- label: string;
23
- /**
24
- * Whether the label should appear after or before the radio.
25
- */
26
- labelPosition?: "before" | "after";
27
- /**
28
- * Name attribute of the input element.
29
- */
30
- name?: string;
31
- /**
32
- * If true, the component will be disabled.
33
- */
34
- disabled?: boolean;
35
- /**
36
- * If true, the radio will change its appearence, showing that the value is required.
37
- */
38
- required?: boolean;
39
- /**
40
- * This function will be called when the user clicks the radio. The new value will
41
- * be passed as a parameter.
42
- */
43
- onClick?: (val: boolean) => void;
44
- /**
45
- * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
46
- * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
47
- */
48
- margin?: Space | Margin;
49
- /**
50
- * Size of the component.
51
- */
52
- size?: "small" | "medium" | "large" | "fillParent" | "fitContent";
53
- };
54
- export default Props;
package/radio/types.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import { RadioProps } from "./types";
3
- declare const _default: React.MemoExoticComponent<({ option, currentValue, onClick, onFocus, error, disabled, focused, readonly, }: RadioProps) => JSX.Element>;
4
- export default _default;
@@ -1,130 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = void 0;
11
-
12
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
-
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
-
16
- var _react = _interopRequireWildcard(require("react"));
17
-
18
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
19
-
20
- var _uuid = require("uuid");
21
-
22
- var _useTheme = _interopRequireDefault(require("../useTheme"));
23
-
24
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
25
-
26
- 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
-
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
-
30
- var DxcRadio = function DxcRadio(_ref) {
31
- var option = _ref.option,
32
- currentValue = _ref.currentValue,
33
- _onClick = _ref.onClick,
34
- onFocus = _ref.onFocus,
35
- error = _ref.error,
36
- disabled = _ref.disabled,
37
- focused = _ref.focused,
38
- readonly = _ref.readonly;
39
-
40
- var _useState = (0, _react.useState)("radio-".concat((0, _uuid.v4)())),
41
- _useState2 = (0, _slicedToArray2["default"])(_useState, 1),
42
- radioLabelId = _useState2[0];
43
-
44
- var ref = (0, _react.useRef)(null);
45
- var colorsTheme = (0, _useTheme["default"])();
46
- var checked = option.value === currentValue;
47
-
48
- var _useState3 = (0, _react.useState)(true),
49
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
50
- firstUpdate = _useState4[0],
51
- setFirstUpdate = _useState4[1];
52
-
53
- (0, _react.useLayoutEffect)(function () {
54
- var _ref$current;
55
-
56
- // Don't apply in the first render
57
- if (firstUpdate) {
58
- setFirstUpdate(false);
59
- return;
60
- }
61
-
62
- focused && (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
63
- }, [focused]);
64
- return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
65
- theme: colorsTheme.radioGroup
66
- }, /*#__PURE__*/_react["default"].createElement(RadioContainer, null, /*#__PURE__*/_react["default"].createElement(RadioInputContainer, null, /*#__PURE__*/_react["default"].createElement(RadioInput, {
67
- error: error,
68
- disabled: disabled,
69
- readonly: readonly,
70
- onClick: _onClick,
71
- onFocus: onFocus,
72
- role: "radio",
73
- "aria-checked": checked,
74
- "aria-disabled": option.disabled,
75
- "aria-labelledby": radioLabelId,
76
- tabIndex: disabled ? -1 : focused ? 0 : -1,
77
- ref: ref
78
- }, checked && /*#__PURE__*/_react["default"].createElement(Dot, {
79
- disabled: disabled,
80
- readonly: readonly,
81
- error: error
82
- }))), /*#__PURE__*/_react["default"].createElement(Label, {
83
- id: radioLabelId,
84
- onMouseDown: function onMouseDown(event) {
85
- event.preventDefault();
86
- },
87
- onClick: function onClick() {
88
- var _ref$current2;
89
-
90
- ref === null || ref === void 0 ? void 0 : (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.focus();
91
-
92
- _onClick();
93
- },
94
- disabled: disabled
95
- }, option.label)));
96
- };
97
-
98
- var RadioContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n"])));
99
-
100
- var RadioInputContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
101
-
102
- var RadioInput = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n border: 2px solid\n ", ";\n border-radius: 50%;\n box-shadow: 0 0 0 2px transparent;\n\n ", "\n"])), function (props) {
103
- if (props.disabled) return props.theme.disabledRadioInputColor;else if (props.error) return props.theme.errorRadioInputColor;else if (props.readonly) return props.theme.readonlyRadioInputColor;else return props.theme.radioInputColor;
104
- }, function (props) {
105
- return !props.disabled ? "\n &:focus {\n outline: 2px solid ".concat(props.theme.focusBorderColor, ";\n outline-offset: 1px;\n }\n &:focus-visible {\n outline: 2px solid ").concat(props.theme.focusBorderColor, ";\n outline-offset: 1px;\n }\n &:hover {\n cursor: pointer;\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 &:active {\n cursor: pointer;\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 cursor: not-allowed;\n pointer-events: none;\n :focus-visible {\n outline: none;\n }\n ";
106
- });
107
-
108
- 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) {
109
- if (props.disabled) return props.theme.disabledRadioInputColor;else if (props.error) return props.theme.errorRadioInputColor;else if (props.readonly) return props.theme.readonlyRadioInputColor;else return props.theme.radioInputColor;
110
- });
111
-
112
- 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) {
113
- return props.theme.radioInputLabelMargin;
114
- }, function (props) {
115
- return props.theme.fontFamily;
116
- }, function (props) {
117
- return props.theme.radioInputLabelFontSize;
118
- }, function (props) {
119
- return props.theme.radioInputLabelFontStyle;
120
- }, function (props) {
121
- return props.theme.radioInputLabelFontWeight;
122
- }, function (props) {
123
- return props.theme.radioInputLabelLineHeight;
124
- }, function (props) {
125
- return props.disabled ? "color: ".concat(props.theme.disabledRadioInputLabelFontColor, "; pointer-events: none;") : "cursor: pointer;";
126
- });
127
-
128
- var _default = /*#__PURE__*/_react["default"].memo(DxcRadio);
129
-
130
- exports["default"] = _default;
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import RadioGroupPropsType from "./types";
3
- declare const DxcRadioGroup: React.ForwardRefExoticComponent<RadioGroupPropsType & React.RefAttributes<HTMLDivElement>>;
4
- export default DxcRadioGroup;
@@ -1,268 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = void 0;
11
-
12
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
-
14
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
-
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
-
18
- var _react = _interopRequireWildcard(require("react"));
19
-
20
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
-
22
- var _uuid = require("uuid");
23
-
24
- var _useTheme = _interopRequireDefault(require("../useTheme"));
25
-
26
- var _Radio = _interopRequireDefault(require("./Radio"));
27
-
28
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
29
-
30
- 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); }
31
-
32
- 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; }
33
-
34
- var getInitialFocusIndex = function getInitialFocusIndex(innerOptions, value) {
35
- var initialSelectedOptionIndex = innerOptions.findIndex(function (option) {
36
- return option.value === value;
37
- });
38
- return initialSelectedOptionIndex !== -1 ? initialSelectedOptionIndex : 0;
39
- };
40
-
41
- var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
42
- var label = _ref.label,
43
- name = _ref.name,
44
- helperText = _ref.helperText,
45
- options = _ref.options,
46
- _ref$disabled = _ref.disabled,
47
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
48
- _ref$optional = _ref.optional,
49
- optional = _ref$optional === void 0 ? false : _ref$optional,
50
- _ref$optionalItemLabe = _ref.optionalItemLabel,
51
- optionalItemLabel = _ref$optionalItemLabe === void 0 ? "N/A" : _ref$optionalItemLabe,
52
- _ref$readonly = _ref.readonly,
53
- readonly = _ref$readonly === void 0 ? false : _ref$readonly,
54
- _ref$stacking = _ref.stacking,
55
- stacking = _ref$stacking === void 0 ? "column" : _ref$stacking,
56
- defaultValue = _ref.defaultValue,
57
- value = _ref.value,
58
- onChange = _ref.onChange,
59
- onBlur = _ref.onBlur,
60
- error = _ref.error;
61
-
62
- var _useState = (0, _react.useState)("select-".concat((0, _uuid.v4)())),
63
- _useState2 = (0, _slicedToArray2["default"])(_useState, 1),
64
- radioGroupId = _useState2[0];
65
-
66
- var radioGroupLabelId = "label-".concat(radioGroupId);
67
-
68
- var _useState3 = (0, _react.useState)(defaultValue),
69
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
70
- innerValue = _useState4[0],
71
- setInnerValue = _useState4[1];
72
-
73
- var _useState5 = (0, _react.useState)(true),
74
- _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
75
- firstTimeFocus = _useState6[0],
76
- setFirstTimeFocus = _useState6[1];
77
-
78
- var optionalItem = {
79
- label: optionalItemLabel,
80
- value: "",
81
- disabled: disabled
82
- };
83
- var innerOptions = (0, _react.useMemo)(function () {
84
- return optional ? [].concat((0, _toConsumableArray2["default"])(options), [optionalItem]) : options;
85
- }, [optional, options]);
86
-
87
- var _useState7 = (0, _react.useState)(getInitialFocusIndex(innerOptions, value !== null && value !== void 0 ? value : innerValue)),
88
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
89
- currentFocusIndex = _useState8[0],
90
- setCurrentFocusIndex = _useState8[1];
91
-
92
- var colorsTheme = (0, _useTheme["default"])();
93
- var handleOnChange = (0, _react.useCallback)(function (newValue) {
94
- var currentValue = value !== null && value !== void 0 ? value : innerValue;
95
-
96
- if (newValue !== currentValue && !readonly) {
97
- value !== null && value !== void 0 ? value : setInnerValue(newValue);
98
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
99
- }
100
- }, [value, innerValue, setInnerValue, onChange]);
101
-
102
- var handleOnBlur = function handleOnBlur(e) {
103
- // If the radio group loses the focus to an element not contained inside it...
104
- !e.currentTarget.contains(e.relatedTarget) && setFirstTimeFocus(true);
105
- var currentValue = value !== null && value !== void 0 ? value : innerValue;
106
- !optional && !Boolean(currentValue) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
107
- value: currentValue,
108
- error: "This field is required. Please, choose an option."
109
- }) : onBlur === null || onBlur === void 0 ? void 0 : onBlur({
110
- value: currentValue
111
- });
112
- };
113
-
114
- var setPreviousRadioChecked = function setPreviousRadioChecked() {
115
- if (!disabled) {
116
- setCurrentFocusIndex(function (currentFocusIndex) {
117
- var index = currentFocusIndex === 0 ? innerOptions.length - 1 : currentFocusIndex - 1;
118
-
119
- while (innerOptions[index].disabled) {
120
- index = index === 0 ? innerOptions.length - 1 : index - 1;
121
- }
122
-
123
- return index;
124
- });
125
- }
126
- };
127
-
128
- var setNextRadioChecked = function setNextRadioChecked() {
129
- if (!disabled) {
130
- setCurrentFocusIndex(function (currentFocusIndex) {
131
- var index = currentFocusIndex === innerOptions.length - 1 ? 0 : currentFocusIndex + 1;
132
-
133
- while (innerOptions[index].disabled) {
134
- index = index === innerOptions.length - 1 ? 0 : index + 1;
135
- }
136
-
137
- return index;
138
- });
139
- }
140
- };
141
-
142
- var handleOnKeyDown = function handleOnKeyDown(event) {
143
- switch (event.keyCode) {
144
- case 37: // arrow left
145
-
146
- case 38:
147
- // arrow up
148
- event.preventDefault();
149
- setPreviousRadioChecked();
150
- break;
151
-
152
- case 39: // arrow right
153
-
154
- case 40:
155
- // arrow down
156
- event.preventDefault();
157
- setNextRadioChecked();
158
- break;
159
-
160
- case 13: // enter
161
-
162
- case 32:
163
- // space
164
- event.preventDefault();
165
- handleOnChange(innerOptions[currentFocusIndex].value);
166
- break;
167
- }
168
- };
169
-
170
- return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
171
- theme: colorsTheme.radioGroup
172
- }, /*#__PURE__*/_react["default"].createElement(RadioGroupContainer, {
173
- ref: ref
174
- }, label && /*#__PURE__*/_react["default"].createElement(Label, {
175
- id: radioGroupLabelId,
176
- helperText: helperText,
177
- disabled: disabled
178
- }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, "(Optional)")), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
179
- disabled: disabled
180
- }, helperText), /*#__PURE__*/_react["default"].createElement(RadioGroup, {
181
- onBlur: handleOnBlur,
182
- onKeyDown: handleOnKeyDown,
183
- stacking: stacking,
184
- role: "radiogroup",
185
- "aria-disabled": disabled,
186
- "aria-labelledby": radioGroupLabelId,
187
- "aria-invalid": error ? "true" : "false",
188
- "aria-required": !optional
189
- }, /*#__PURE__*/_react["default"].createElement(ValueInput, {
190
- name: name,
191
- value: value !== null && value !== void 0 ? value : innerValue,
192
- readOnly: true,
193
- "aria-hidden": "true"
194
- }), innerOptions.map(function (option, index) {
195
- return /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
196
- option: option,
197
- currentValue: value !== null && value !== void 0 ? value : innerValue,
198
- onClick: function onClick() {
199
- handleOnChange(option.value);
200
- setCurrentFocusIndex(index);
201
- },
202
- onFocus: function onFocus() {
203
- !firstTimeFocus ? handleOnChange(option.value) : setFirstTimeFocus(false);
204
- },
205
- error: error,
206
- disabled: option.disabled || disabled,
207
- focused: currentFocusIndex === index,
208
- readonly: readonly
209
- });
210
- })), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, null, error)));
211
- });
212
-
213
- var RadioGroupContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n"])));
214
-
215
- 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) {
216
- return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
217
- }, function (props) {
218
- return props.theme.fontFamily;
219
- }, function (props) {
220
- return props.theme.labelFontSize;
221
- }, function (props) {
222
- return props.theme.labelFontStyle;
223
- }, function (props) {
224
- return props.theme.labelFontWeight;
225
- }, function (props) {
226
- return props.theme.labelLineHeight;
227
- }, function (props) {
228
- return !props.helperText && "margin-bottom: ".concat(props.theme.groupLabelMargin);
229
- });
230
-
231
- var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
232
- return props.theme.optionalLabelFontWeight;
233
- });
234
-
235
- var HelperText = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin-bottom: ", ";\n"])), function (props) {
236
- return props.disabled ? props.theme.disabledHelperTextFontColor : props.theme.helperTextFontColor;
237
- }, function (props) {
238
- return props.theme.fontFamily;
239
- }, function (props) {
240
- return props.theme.helperTextFontSize;
241
- }, function (props) {
242
- return props.theme.helperTextFontStyle;
243
- }, function (props) {
244
- return props.theme.helperTextFontWeight;
245
- }, function (props) {
246
- return props.theme.helperTextLineHeight;
247
- }, function (props) {
248
- return props.theme.groupLabelMargin;
249
- });
250
-
251
- var RadioGroup = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n flex-direction: ", ";\n\n row-gap: ", ";\n column-gap: ", ";\n"])), function (props) {
252
- return props.stacking;
253
- }, function (props) {
254
- return props.theme.groupVerticalGutter;
255
- }, function (props) {
256
- return props.theme.groupHorizontalGutter;
257
- });
258
-
259
- var ValueInput = _styledComponents["default"].input(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
260
-
261
- var Error = _styledComponents["default"].span(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n margin-top: 0.5rem;\n"])), function (props) {
262
- return props.theme.errorMessageColor;
263
- }, function (props) {
264
- return props.theme.fontFamily;
265
- });
266
-
267
- var _default = DxcRadioGroup;
268
- exports["default"] = _default;
@@ -1,79 +0,0 @@
1
- import ExampleContainer from "../../.storybook/components/ExampleContainer";
2
- import Title from "../../.storybook/components/Title";
3
- import DxcRadioGroup from "./RadioGroup";
4
-
5
- export default {
6
- title: "Radio Group",
7
- component: DxcRadioGroup,
8
- };
9
-
10
- const options = [
11
- { label: "Option 1", value: "1" },
12
- { label: "Option 2", value: "2" },
13
- { label: "Option 3", value: "3" },
14
- { label: "Option 4", value: "4" },
15
- ];
16
-
17
- const single_disabled_options = [
18
- { label: "Option 1", value: "1" },
19
- { label: "Option 2", value: "2", disabled: true },
20
- { label: "Option 3", value: "3" },
21
- ];
22
-
23
- export const Chromatic = () => (
24
- <>
25
- <ExampleContainer>
26
- <Title title="Label only" theme="light" level={4} />
27
- <DxcRadioGroup label="Example of label" options={options}/>
28
- </ExampleContainer>
29
- <ExampleContainer>
30
- <Title title="Column" theme="light" level={4} />
31
- <DxcRadioGroup label="Example" helperText="Helper text" options={options} defaultValue="3" />
32
- </ExampleContainer>
33
- <ExampleContainer>
34
- <Title title="Row" theme="light" level={4} />
35
- <DxcRadioGroup label="Example" helperText="Helper text" options={options} stacking="row" />
36
- </ExampleContainer>
37
- <ExampleContainer>
38
- <Title title="Disabled" theme="light" level={4} />
39
- <DxcRadioGroup
40
- label="Disabled"
41
- error="Error message"
42
- helperText="Helper text"
43
- options={options}
44
- disabled
45
- optional
46
- defaultValue="2"
47
- />
48
- </ExampleContainer>
49
- <ExampleContainer>
50
- <Title title="Single disabled" theme="light" level={4} />
51
- <DxcRadioGroup label="Disabled" helperText="Helper text" options={single_disabled_options} defaultValue="3" />
52
- </ExampleContainer>
53
- <ExampleContainer>
54
- <Title title="Optional" theme="light" level={4} />
55
- <DxcRadioGroup
56
- label="Example"
57
- optionalItemLabel="No selection"
58
- optional
59
- helperText="Helper text"
60
- options={options}
61
- stacking="row"
62
- />
63
- </ExampleContainer>
64
- <ExampleContainer>
65
- <Title title="Error" theme="light" level={4} />
66
- <DxcRadioGroup
67
- label="Example"
68
- error="Error message"
69
- helperText="Helper text"
70
- options={options}
71
- defaultValue="2"
72
- />
73
- </ExampleContainer>
74
- <ExampleContainer>
75
- <Title title="Readonly" theme="light" level={4} />
76
- <DxcRadioGroup label="Example" readonly helperText="Helper text" options={options} defaultValue="2" />
77
- </ExampleContainer>
78
- </>
79
- );
@@ -1,36 +0,0 @@
1
- export declare type Option = {
2
- value: string;
3
- label: string;
4
- disabled?: boolean;
5
- };
6
- declare type RadioGroupProps = {
7
- label: string;
8
- name?: string;
9
- helperText?: string;
10
- options: Option[];
11
- disabled?: boolean;
12
- optional?: boolean;
13
- optionalItemLabel?: string;
14
- readonly?: boolean;
15
- stacking?: "row" | "column";
16
- defaultValue?: string;
17
- value?: string;
18
- onChange?: (value: string) => void;
19
- onBlur?: (val: {
20
- value?: string;
21
- error?: string;
22
- }) => void;
23
- error?: string;
24
- };
25
- export declare type RefType = HTMLDivElement;
26
- export declare type RadioProps = {
27
- option: Option;
28
- currentValue?: string;
29
- onClick: () => void;
30
- onFocus: () => void;
31
- error?: string;
32
- disabled: boolean;
33
- focused: boolean;
34
- readonly: boolean;
35
- };
36
- export default RadioGroupProps;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import ResultsetTablePropsType from "./types";
3
- declare const DxcResultsetTable: ({ columns, rows, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, margin, tabIndex, }: ResultsetTablePropsType) => JSX.Element;
4
- export default DxcResultsetTable;