@dxc-technology/halstack-react 0.0.0-9b45027 → 0.0.0-9bce4c7

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 (269) hide show
  1. package/README.md +46 -0
  2. package/dist/index.d.mts +6703 -0
  3. package/dist/index.d.ts +6703 -0
  4. package/dist/index.js +1 -0
  5. package/dist/index.mjs +1 -0
  6. package/package.json +70 -68
  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/bleed/Bleed.d.ts +0 -3
  32. package/bleed/Bleed.js +0 -84
  33. package/bleed/Bleed.stories.tsx +0 -342
  34. package/bleed/types.d.ts +0 -13
  35. package/bleed/types.js +0 -5
  36. package/box/Box.d.ts +0 -4
  37. package/box/Box.js +0 -126
  38. package/box/Box.stories.tsx +0 -132
  39. package/box/types.d.ts +0 -43
  40. package/box/types.js +0 -5
  41. package/button/Button.d.ts +0 -4
  42. package/button/Button.js +0 -171
  43. package/button/Button.stories.tsx +0 -274
  44. package/button/types.d.ts +0 -53
  45. package/button/types.js +0 -5
  46. package/card/Card.d.ts +0 -4
  47. package/card/Card.js +0 -164
  48. package/card/Card.stories.tsx +0 -201
  49. package/card/ice-cream.jpg +0 -0
  50. package/card/types.d.ts +0 -67
  51. package/card/types.js +0 -5
  52. package/checkbox/Checkbox.d.ts +0 -4
  53. package/checkbox/Checkbox.js +0 -253
  54. package/checkbox/Checkbox.stories.tsx +0 -192
  55. package/checkbox/types.d.ts +0 -60
  56. package/checkbox/types.js +0 -5
  57. package/chip/Chip.d.ts +0 -4
  58. package/chip/Chip.js +0 -199
  59. package/chip/Chip.stories.tsx +0 -121
  60. package/chip/types.d.ts +0 -53
  61. package/chip/types.js +0 -5
  62. package/common/OpenSans.css +0 -81
  63. package/common/RequiredComponent.js +0 -32
  64. package/common/fonts/OpenSans-Bold.ttf +0 -0
  65. package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  66. package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  67. package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  68. package/common/fonts/OpenSans-Italic.ttf +0 -0
  69. package/common/fonts/OpenSans-Light.ttf +0 -0
  70. package/common/fonts/OpenSans-LightItalic.ttf +0 -0
  71. package/common/fonts/OpenSans-Regular.ttf +0 -0
  72. package/common/fonts/OpenSans-SemiBold.ttf +0 -0
  73. package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  74. package/common/utils.js +0 -22
  75. package/common/variables.js +0 -1612
  76. package/date/Date.js +0 -373
  77. package/date/index.d.ts +0 -27
  78. package/date-input/DateInput.d.ts +0 -4
  79. package/date-input/DateInput.js +0 -358
  80. package/date-input/DateInput.stories.tsx +0 -138
  81. package/date-input/types.d.ts +0 -100
  82. package/date-input/types.js +0 -5
  83. package/dialog/Dialog.d.ts +0 -4
  84. package/dialog/Dialog.js +0 -166
  85. package/dialog/Dialog.stories.tsx +0 -212
  86. package/dialog/types.d.ts +0 -43
  87. package/dialog/types.js +0 -5
  88. package/dropdown/Dropdown.d.ts +0 -4
  89. package/dropdown/Dropdown.js +0 -417
  90. package/dropdown/Dropdown.stories.tsx +0 -247
  91. package/dropdown/types.d.ts +0 -89
  92. package/dropdown/types.js +0 -5
  93. package/file-input/FileInput.d.ts +0 -4
  94. package/file-input/FileInput.js +0 -590
  95. package/file-input/FileInput.stories.tsx +0 -507
  96. package/file-input/FileItem.d.ts +0 -14
  97. package/file-input/FileItem.js +0 -184
  98. package/file-input/types.d.ts +0 -112
  99. package/file-input/types.js +0 -5
  100. package/footer/Footer.d.ts +0 -4
  101. package/footer/Footer.js +0 -260
  102. package/footer/Footer.stories.tsx +0 -130
  103. package/footer/Icons.d.ts +0 -2
  104. package/footer/Icons.js +0 -77
  105. package/footer/types.d.ts +0 -65
  106. package/footer/types.js +0 -5
  107. package/header/Header.d.ts +0 -7
  108. package/header/Header.js +0 -324
  109. package/header/Header.stories.tsx +0 -162
  110. package/header/Icons.d.ts +0 -2
  111. package/header/Icons.js +0 -34
  112. package/header/types.d.ts +0 -47
  113. package/header/types.js +0 -5
  114. package/heading/Heading.d.ts +0 -4
  115. package/heading/Heading.js +0 -159
  116. package/heading/Heading.stories.tsx +0 -54
  117. package/heading/types.d.ts +0 -33
  118. package/heading/types.js +0 -5
  119. package/input-text/Icons.js +0 -22
  120. package/input-text/InputText.js +0 -611
  121. package/input-text/index.d.ts +0 -36
  122. package/inset/Inset.d.ts +0 -3
  123. package/inset/Inset.js +0 -84
  124. package/inset/Inset.stories.tsx +0 -229
  125. package/inset/types.d.ts +0 -13
  126. package/inset/types.js +0 -5
  127. package/layout/ApplicationLayout.d.ts +0 -10
  128. package/layout/ApplicationLayout.js +0 -225
  129. package/layout/ApplicationLayout.stories.tsx +0 -171
  130. package/layout/Icons.js +0 -55
  131. package/layout/types.d.ts +0 -57
  132. package/layout/types.js +0 -5
  133. package/link/Link.d.ts +0 -3
  134. package/link/Link.js +0 -161
  135. package/link/Link.stories.tsx +0 -146
  136. package/link/types.d.ts +0 -74
  137. package/link/types.js +0 -5
  138. package/list/List.d.ts +0 -8
  139. package/list/List.js +0 -47
  140. package/list/List.stories.tsx +0 -95
  141. package/main.d.ts +0 -48
  142. package/main.js +0 -395
  143. package/number-input/NumberInput.d.ts +0 -4
  144. package/number-input/NumberInput.js +0 -83
  145. package/number-input/NumberInput.stories.tsx +0 -115
  146. package/number-input/NumberInputContext.d.ts +0 -4
  147. package/number-input/NumberInputContext.js +0 -19
  148. package/number-input/numberInputContextTypes.d.ts +0 -19
  149. package/number-input/numberInputContextTypes.js +0 -5
  150. package/number-input/types.d.ts +0 -117
  151. package/number-input/types.js +0 -5
  152. package/paginator/Icons.js +0 -66
  153. package/paginator/Paginator.d.ts +0 -4
  154. package/paginator/Paginator.js +0 -192
  155. package/paginator/Paginator.stories.tsx +0 -63
  156. package/paginator/types.d.ts +0 -38
  157. package/paginator/types.js +0 -5
  158. package/password-input/PasswordInput.d.ts +0 -4
  159. package/password-input/PasswordInput.js +0 -163
  160. package/password-input/PasswordInput.stories.tsx +0 -131
  161. package/password-input/types.d.ts +0 -107
  162. package/password-input/types.js +0 -5
  163. package/progress-bar/ProgressBar.d.ts +0 -4
  164. package/progress-bar/ProgressBar.js +0 -170
  165. package/progress-bar/ProgressBar.stories.jsx +0 -58
  166. package/progress-bar/types.d.ts +0 -37
  167. package/progress-bar/types.js +0 -5
  168. package/radio/Radio.d.ts +0 -4
  169. package/radio/Radio.js +0 -174
  170. package/radio/Radio.stories.tsx +0 -192
  171. package/radio/types.d.ts +0 -54
  172. package/radio/types.js +0 -5
  173. package/radio-group/Radio.d.ts +0 -4
  174. package/radio-group/Radio.js +0 -130
  175. package/radio-group/RadioGroup.d.ts +0 -4
  176. package/radio-group/RadioGroup.js +0 -268
  177. package/radio-group/RadioGroup.stories.tsx +0 -79
  178. package/radio-group/types.d.ts +0 -36
  179. package/radio-group/types.js +0 -5
  180. package/resultsetTable/ResultsetTable.d.ts +0 -4
  181. package/resultsetTable/ResultsetTable.js +0 -251
  182. package/resultsetTable/ResultsetTable.stories.tsx +0 -275
  183. package/resultsetTable/types.d.ts +0 -67
  184. package/resultsetTable/types.js +0 -5
  185. package/row/Row.d.ts +0 -11
  186. package/row/Row.js +0 -127
  187. package/row/Row.stories.tsx +0 -239
  188. package/select/Select.d.ts +0 -4
  189. package/select/Select.js +0 -863
  190. package/select/Select.stories.tsx +0 -572
  191. package/select/types.d.ts +0 -170
  192. package/select/types.js +0 -5
  193. package/sidenav/Sidenav.d.ts +0 -9
  194. package/sidenav/Sidenav.js +0 -136
  195. package/sidenav/Sidenav.stories.tsx +0 -182
  196. package/sidenav/types.d.ts +0 -50
  197. package/sidenav/types.js +0 -5
  198. package/slider/Slider.d.ts +0 -4
  199. package/slider/Slider.js +0 -317
  200. package/slider/Slider.stories.tsx +0 -177
  201. package/slider/types.d.ts +0 -78
  202. package/slider/types.js +0 -5
  203. package/spinner/Spinner.d.ts +0 -4
  204. package/spinner/Spinner.js +0 -250
  205. package/spinner/Spinner.stories.jsx +0 -103
  206. package/spinner/types.d.ts +0 -32
  207. package/spinner/types.js +0 -5
  208. package/stack/Stack.d.ts +0 -10
  209. package/stack/Stack.js +0 -97
  210. package/stack/Stack.stories.tsx +0 -166
  211. package/switch/Switch.d.ts +0 -4
  212. package/switch/Switch.js +0 -179
  213. package/switch/Switch.stories.tsx +0 -160
  214. package/switch/types.d.ts +0 -58
  215. package/switch/types.js +0 -5
  216. package/table/Table.d.ts +0 -4
  217. package/table/Table.js +0 -118
  218. package/table/Table.stories.jsx +0 -277
  219. package/table/types.d.ts +0 -21
  220. package/table/types.js +0 -5
  221. package/tabs/Tabs.d.ts +0 -4
  222. package/tabs/Tabs.js +0 -213
  223. package/tabs/Tabs.stories.tsx +0 -120
  224. package/tabs/types.d.ts +0 -78
  225. package/tabs/types.js +0 -5
  226. package/tag/Tag.d.ts +0 -4
  227. package/tag/Tag.js +0 -193
  228. package/tag/Tag.stories.tsx +0 -145
  229. package/tag/types.d.ts +0 -60
  230. package/tag/types.js +0 -5
  231. package/text/Text.d.ts +0 -7
  232. package/text/Text.js +0 -30
  233. package/text/Text.stories.tsx +0 -19
  234. package/text-input/TextInput.d.ts +0 -4
  235. package/text-input/TextInput.js +0 -794
  236. package/text-input/TextInput.stories.tsx +0 -456
  237. package/text-input/types.d.ts +0 -159
  238. package/text-input/types.js +0 -5
  239. package/textarea/Textarea.d.ts +0 -4
  240. package/textarea/Textarea.js +0 -284
  241. package/textarea/Textarea.stories.jsx +0 -136
  242. package/textarea/types.d.ts +0 -130
  243. package/textarea/types.js +0 -5
  244. package/toggle/Toggle.js +0 -186
  245. package/toggle/index.d.ts +0 -21
  246. package/toggle-group/ToggleGroup.d.ts +0 -4
  247. package/toggle-group/ToggleGroup.js +0 -214
  248. package/toggle-group/ToggleGroup.stories.tsx +0 -173
  249. package/toggle-group/types.d.ts +0 -97
  250. package/toggle-group/types.js +0 -5
  251. package/upload/Upload.js +0 -201
  252. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  253. package/upload/buttons-upload/Icons.js +0 -40
  254. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  255. package/upload/dragAndDropArea/Icons.js +0 -39
  256. package/upload/file-upload/FileToUpload.js +0 -115
  257. package/upload/file-upload/Icons.js +0 -66
  258. package/upload/files-upload/FilesToUpload.js +0 -109
  259. package/upload/index.d.ts +0 -15
  260. package/upload/transaction/Icons.js +0 -160
  261. package/upload/transaction/Transaction.js +0 -104
  262. package/upload/transactions/Transactions.js +0 -94
  263. package/useTheme.d.ts +0 -2
  264. package/useTheme.js +0 -22
  265. package/wizard/Wizard.d.ts +0 -4
  266. package/wizard/Wizard.js +0 -281
  267. package/wizard/Wizard.stories.tsx +0 -224
  268. package/wizard/types.d.ts +0 -60
  269. 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;