@dxc-technology/halstack-react 0.0.0-b39a2d8 → 0.0.0-b3e1a2f

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 (162) hide show
  1. package/BackgroundColorContext.d.ts +10 -0
  2. package/BackgroundColorContext.js +1 -4
  3. package/ThemeContext.d.ts +15 -0
  4. package/ThemeContext.js +5 -8
  5. package/V3Select/V3Select.js +2 -2
  6. package/V3Textarea/V3Textarea.js +2 -2
  7. package/accordion/Accordion.js +2 -2
  8. package/accordion/Accordion.stories.tsx +307 -0
  9. package/accordion/types.d.ts +1 -1
  10. package/accordion-group/AccordionGroup.js +2 -2
  11. package/accordion-group/AccordionGroup.stories.tsx +225 -0
  12. package/accordion-group/types.d.ts +1 -1
  13. package/alert/Alert.js +2 -2
  14. package/badge/Badge.js +1 -1
  15. package/bleed/Bleed.d.ts +3 -0
  16. package/bleed/Bleed.js +84 -0
  17. package/bleed/Bleed.stories.tsx +342 -0
  18. package/bleed/types.d.ts +13 -0
  19. package/bleed/types.js +5 -0
  20. package/box/Box.js +2 -2
  21. package/button/Button.d.ts +1 -1
  22. package/button/Button.js +13 -19
  23. package/button/Button.stories.tsx +6 -8
  24. package/button/types.d.ts +5 -9
  25. package/card/Card.js +1 -1
  26. package/card/Card.stories.tsx +1 -1
  27. package/checkbox/Checkbox.js +2 -2
  28. package/checkbox/types.d.ts +1 -1
  29. package/chip/Chip.d.ts +4 -0
  30. package/chip/Chip.js +5 -27
  31. package/chip/types.d.ts +53 -0
  32. package/chip/types.js +5 -0
  33. package/common/variables.js +57 -22
  34. package/date/Date.js +1 -1
  35. package/date-input/DateInput.js +10 -13
  36. package/dialog/Dialog.js +4 -3
  37. package/dropdown/Dropdown.js +1 -1
  38. package/dropdown/Dropdown.stories.tsx +247 -0
  39. package/dropdown/types.d.ts +1 -1
  40. package/file-input/FileInput.d.ts +1 -1
  41. package/file-input/FileInput.js +160 -81
  42. package/file-input/FileInput.stories.tsx +507 -0
  43. package/file-input/FileItem.js +8 -6
  44. package/file-input/types.d.ts +32 -7
  45. package/footer/Footer.d.ts +1 -1
  46. package/footer/Footer.js +12 -18
  47. package/footer/{Footer.stories.jsx → Footer.stories.tsx} +1 -22
  48. package/footer/Icons.d.ts +2 -0
  49. package/footer/Icons.js +3 -3
  50. package/footer/types.d.ts +21 -17
  51. package/header/Header.js +2 -2
  52. package/header/Icons.d.ts +2 -0
  53. package/heading/Heading.js +1 -1
  54. package/heading/Heading.stories.tsx +54 -0
  55. package/input-text/InputText.js +2 -2
  56. package/inset/Inset.d.ts +3 -0
  57. package/inset/Inset.js +84 -0
  58. package/inset/Inset.stories.tsx +229 -0
  59. package/inset/types.d.ts +13 -0
  60. package/inset/types.js +5 -0
  61. package/layout/ApplicationLayout.d.ts +10 -0
  62. package/layout/ApplicationLayout.js +9 -19
  63. package/layout/ApplicationLayout.stories.tsx +171 -0
  64. package/layout/types.d.ts +57 -0
  65. package/layout/types.js +5 -0
  66. package/link/Link.js +1 -1
  67. package/list/List.d.ts +4 -0
  68. package/list/List.js +47 -0
  69. package/list/List.stories.tsx +95 -0
  70. package/list/types.d.ts +7 -0
  71. package/list/types.js +5 -0
  72. package/main.d.ts +7 -3
  73. package/main.js +34 -2
  74. package/number-input/NumberInput.js +3 -6
  75. package/number-input/NumberInputContext.d.ts +4 -0
  76. package/number-input/NumberInputContext.js +5 -2
  77. package/number-input/numberInputContextTypes.d.ts +19 -0
  78. package/number-input/numberInputContextTypes.js +5 -0
  79. package/package.json +4 -2
  80. package/paginator/Paginator.js +2 -8
  81. package/password-input/PasswordInput.js +19 -18
  82. package/password-input/PasswordInput.stories.tsx +3 -3
  83. package/password-input/types.d.ts +17 -10
  84. package/progress-bar/ProgressBar.js +4 -4
  85. package/radio/Radio.js +2 -2
  86. package/radio-group/Radio.d.ts +4 -0
  87. package/radio-group/Radio.js +130 -0
  88. package/radio-group/RadioGroup.d.ts +4 -0
  89. package/radio-group/RadioGroup.js +268 -0
  90. package/radio-group/RadioGroup.stories.tsx +79 -0
  91. package/radio-group/types.d.ts +36 -0
  92. package/radio-group/types.js +5 -0
  93. package/resultsetTable/ResultsetTable.d.ts +4 -0
  94. package/resultsetTable/ResultsetTable.js +5 -28
  95. package/resultsetTable/ResultsetTable.stories.tsx +275 -0
  96. package/resultsetTable/types.d.ts +67 -0
  97. package/resultsetTable/types.js +5 -0
  98. package/row/Row.d.ts +3 -0
  99. package/row/Row.js +127 -0
  100. package/row/Row.stories.tsx +237 -0
  101. package/row/types.d.ts +10 -0
  102. package/row/types.js +5 -0
  103. package/select/Select.d.ts +4 -0
  104. package/select/Select.js +20 -22
  105. package/select/types.d.ts +170 -0
  106. package/select/types.js +5 -0
  107. package/sidenav/Sidenav.js +2 -2
  108. package/sidenav/Sidenav.stories.tsx +182 -0
  109. package/slider/Slider.js +4 -4
  110. package/spinner/Spinner.js +2 -2
  111. package/spinner/Spinner.stories.jsx +1 -0
  112. package/stack/Stack.d.ts +3 -0
  113. package/stack/Stack.js +97 -0
  114. package/stack/Stack.stories.tsx +164 -0
  115. package/stack/types.d.ts +9 -0
  116. package/stack/types.js +5 -0
  117. package/switch/Switch.js +2 -2
  118. package/switch/Switch.stories.tsx +1 -1
  119. package/table/Table.js +3 -3
  120. package/table/Table.stories.jsx +2 -1
  121. package/tabs/Tabs.js +11 -9
  122. package/tabs/Tabs.stories.tsx +120 -0
  123. package/tabs/types.d.ts +23 -15
  124. package/tag/Tag.js +1 -1
  125. package/tag/Tag.stories.tsx +1 -1
  126. package/text/Text.d.ts +7 -0
  127. package/text/Text.js +30 -0
  128. package/text/Text.stories.tsx +19 -0
  129. package/text-input/TextInput.d.ts +4 -0
  130. package/text-input/TextInput.js +54 -85
  131. package/text-input/TextInput.stories.tsx +456 -0
  132. package/text-input/types.d.ts +159 -0
  133. package/text-input/types.js +5 -0
  134. package/textarea/Textarea.d.ts +4 -0
  135. package/textarea/Textarea.js +27 -60
  136. package/textarea/Textarea.stories.jsx +4 -3
  137. package/textarea/types.d.ts +130 -0
  138. package/textarea/types.js +5 -0
  139. package/toggle/Toggle.js +1 -1
  140. package/toggle-group/ToggleGroup.d.ts +4 -0
  141. package/toggle-group/ToggleGroup.js +16 -45
  142. package/toggle-group/ToggleGroup.stories.tsx +23 -28
  143. package/toggle-group/types.d.ts +97 -0
  144. package/toggle-group/types.js +5 -0
  145. package/upload/buttons-upload/ButtonsUpload.js +2 -2
  146. package/upload/dragAndDropArea/DragAndDropArea.js +2 -2
  147. package/upload/file-upload/FileToUpload.js +1 -1
  148. package/upload/files-upload/FilesToUpload.js +1 -1
  149. package/upload/transaction/Transaction.js +2 -2
  150. package/upload/transactions/Transactions.js +1 -1
  151. package/useTheme.d.ts +2 -0
  152. package/useTheme.js +1 -1
  153. package/wizard/Wizard.js +59 -9
  154. package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +0 -0
  155. package/wizard/types.d.ts +3 -7
  156. package/chip/index.d.ts +0 -22
  157. package/resultsetTable/index.d.ts +0 -19
  158. package/select/index.d.ts +0 -131
  159. package/text-input/index.d.ts +0 -135
  160. package/textarea/index.d.ts +0 -117
  161. package/toggle-group/index.d.ts +0 -21
  162. package/wizard/Icons.js +0 -65
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxc-technology/halstack-react",
3
- "version": "0.0.0-b39a2d8",
3
+ "version": "0.0.0-b3e1a2f",
4
4
  "description": "DXC Halstack React components library",
5
5
  "repository": "dxc-technology/halstack-react",
6
6
  "homepage": "http://developer.dxc.com/tools/react",
@@ -24,6 +24,8 @@
24
24
  "@material-ui/lab": "4.0.0-alpha.17",
25
25
  "@material-ui/pickers": "3.2.2",
26
26
  "@material-ui/styles": "4.0.2",
27
+ "@types/styled-components": "^5.1.24",
28
+ "@types/uuid": "^8.3.4",
27
29
  "color": "^3.1.3",
28
30
  "date-fns": "^2.0.0-beta.4",
29
31
  "moment": "2.24.0",
@@ -52,8 +54,8 @@
52
54
  "@storybook/addon-essentials": "^6.4.9",
53
55
  "@storybook/addon-links": "^6.4.9",
54
56
  "@storybook/react": "^6.4.9",
55
- "@testing-library/react": "^11.2.5",
56
57
  "@storybook/testing-library": "0.0.7",
58
+ "@testing-library/react": "^11.2.5",
57
59
  "@testing-library/user-event": "^12.6.3",
58
60
  "babel-jest": "^24.8.0",
59
61
  "babel-loader": "^8.0.6",
@@ -15,7 +15,7 @@ var _react = _interopRequireDefault(require("react"));
15
15
 
16
16
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
17
17
 
18
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
18
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
19
19
 
20
20
  var _Button = _interopRequireDefault(require("../button/Button"));
21
21
 
@@ -23,7 +23,7 @@ var _Select = _interopRequireDefault(require("../select/Select"));
23
23
 
24
24
  var _Icons = require("./Icons");
25
25
 
26
- var _BackgroundColorContext = require("../BackgroundColorContext.js");
26
+ var _BackgroundColorContext = require("../BackgroundColorContext");
27
27
 
28
28
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
29
29
 
@@ -67,9 +67,6 @@ var DxcPaginator = function DxcPaginator(_ref) {
67
67
  },
68
68
  value: itemsPerPage.toString(),
69
69
  size: "fillParent",
70
- margin: {
71
- top: "xsmall"
72
- },
73
70
  tabIndex: tabIndex
74
71
  }))), /*#__PURE__*/_react["default"].createElement(TotalItemsContainer, null, minItemsPerPage, " to ", maxItemsPerPage, " of ", totalItems), onPageChange && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
75
72
  size: "small",
@@ -109,9 +106,6 @@ var DxcPaginator = function DxcPaginator(_ref) {
109
106
  },
110
107
  value: currentPage.toString(),
111
108
  size: "fillParent",
112
- margin: {
113
- top: "xsmall"
114
- },
115
109
  tabIndex: tabIndex
116
110
  }))) || /*#__PURE__*/_react["default"].createElement(TextContainer, null, "Page: ", currentPageInternal, " of ", totalPages), onPageChange && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
117
111
  size: "small",
@@ -26,21 +26,19 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
26
26
  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; }
27
27
 
28
28
  var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
29
- var _ref$label = _ref.label,
30
- label = _ref$label === void 0 ? "" : _ref$label,
29
+ var label = _ref.label,
31
30
  _ref$name = _ref.name,
32
31
  name = _ref$name === void 0 ? "" : _ref$name,
33
32
  value = _ref.value,
34
- _ref$helperText = _ref.helperText,
35
- helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
33
+ helperText = _ref.helperText,
36
34
  _ref$clearable = _ref.clearable,
37
35
  clearable = _ref$clearable === void 0 ? false : _ref$clearable,
38
36
  onChange = _ref.onChange,
39
37
  onBlur = _ref.onBlur,
40
- _ref$error = _ref.error,
41
- error = _ref$error === void 0 ? "" : _ref$error,
38
+ error = _ref.error,
42
39
  pattern = _ref.pattern,
43
- length = _ref.length,
40
+ minLength = _ref.minLength,
41
+ maxLength = _ref.maxLength,
44
42
  _ref$autocomplete = _ref.autocomplete,
45
43
  autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
46
44
  margin = _ref.margin,
@@ -59,25 +57,27 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
59
57
  var setInputType = function setInputType(type) {
60
58
  var _inputRef$current, _inputRef$current$chi;
61
59
 
62
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : (_inputRef$current$chi = _inputRef$current.children[2]) === null || _inputRef$current$chi === void 0 ? void 0 : _inputRef$current$chi.children[0].setAttribute("type", type);
60
+ inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : (_inputRef$current$chi = _inputRef$current.children[label && helperText ? 2 : label || helperText ? 1 : 0]) === null || _inputRef$current$chi === void 0 ? void 0 : _inputRef$current$chi.children[0].setAttribute("type", type);
63
61
  };
64
62
 
65
63
  var setAriaAttributes = function setAriaAttributes(ariaExpanded, ariaLabel) {
64
+ var inputIndex = label && helperText ? 2 : label || helperText ? 1 : 0;
65
+
66
66
  if (error && clearable && value) {
67
67
  var _inputRef$current2, _inputRef$current2$ch, _inputRef$current2$ch2, _inputRef$current3, _inputRef$current3$ch, _inputRef$current3$ch2;
68
68
 
69
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : (_inputRef$current2$ch = _inputRef$current2.children[2]) === null || _inputRef$current2$ch === void 0 ? void 0 : (_inputRef$current2$ch2 = _inputRef$current2$ch.children[3]) === null || _inputRef$current2$ch2 === void 0 ? void 0 : _inputRef$current2$ch2.setAttribute("aria-expanded", ariaExpanded);
70
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : (_inputRef$current3$ch = _inputRef$current3.children[2]) === null || _inputRef$current3$ch === void 0 ? void 0 : (_inputRef$current3$ch2 = _inputRef$current3$ch.children[3]) === null || _inputRef$current3$ch2 === void 0 ? void 0 : _inputRef$current3$ch2.setAttribute("aria-label", ariaLabel);
69
+ inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : (_inputRef$current2$ch = _inputRef$current2.children[inputIndex]) === null || _inputRef$current2$ch === void 0 ? void 0 : (_inputRef$current2$ch2 = _inputRef$current2$ch.children[3]) === null || _inputRef$current2$ch2 === void 0 ? void 0 : _inputRef$current2$ch2.setAttribute("aria-expanded", ariaExpanded);
70
+ inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : (_inputRef$current3$ch = _inputRef$current3.children[inputIndex]) === null || _inputRef$current3$ch === void 0 ? void 0 : (_inputRef$current3$ch2 = _inputRef$current3$ch.children[3]) === null || _inputRef$current3$ch2 === void 0 ? void 0 : _inputRef$current3$ch2.setAttribute("aria-label", ariaLabel);
71
71
  } else if (error || clearable && !value) {
72
72
  var _inputRef$current4, _inputRef$current4$ch, _inputRef$current4$ch2, _inputRef$current5, _inputRef$current5$ch, _inputRef$current5$ch2;
73
73
 
74
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : (_inputRef$current4$ch = _inputRef$current4.children[2]) === null || _inputRef$current4$ch === void 0 ? void 0 : (_inputRef$current4$ch2 = _inputRef$current4$ch.children[2]) === null || _inputRef$current4$ch2 === void 0 ? void 0 : _inputRef$current4$ch2.setAttribute("aria-expanded", ariaExpanded);
75
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : (_inputRef$current5$ch = _inputRef$current5.children[2]) === null || _inputRef$current5$ch === void 0 ? void 0 : (_inputRef$current5$ch2 = _inputRef$current5$ch.children[2]) === null || _inputRef$current5$ch2 === void 0 ? void 0 : _inputRef$current5$ch2.setAttribute("aria-label", ariaLabel);
74
+ inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : (_inputRef$current4$ch = _inputRef$current4.children[inputIndex]) === null || _inputRef$current4$ch === void 0 ? void 0 : (_inputRef$current4$ch2 = _inputRef$current4$ch.children[2]) === null || _inputRef$current4$ch2 === void 0 ? void 0 : _inputRef$current4$ch2.setAttribute("aria-expanded", ariaExpanded);
75
+ inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : (_inputRef$current5$ch = _inputRef$current5.children[inputIndex]) === null || _inputRef$current5$ch === void 0 ? void 0 : (_inputRef$current5$ch2 = _inputRef$current5$ch.children[2]) === null || _inputRef$current5$ch2 === void 0 ? void 0 : _inputRef$current5$ch2.setAttribute("aria-label", ariaLabel);
76
76
  } else {
77
77
  var _inputRef$current6, _inputRef$current6$ch, _inputRef$current6$ch2, _inputRef$current7, _inputRef$current7$ch, _inputRef$current7$ch2;
78
78
 
79
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : (_inputRef$current6$ch = _inputRef$current6.children[2]) === null || _inputRef$current6$ch === void 0 ? void 0 : (_inputRef$current6$ch2 = _inputRef$current6$ch.children[1]) === null || _inputRef$current6$ch2 === void 0 ? void 0 : _inputRef$current6$ch2.setAttribute("aria-expanded", ariaExpanded);
80
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 ? void 0 : (_inputRef$current7$ch = _inputRef$current7.children[2]) === null || _inputRef$current7$ch === void 0 ? void 0 : (_inputRef$current7$ch2 = _inputRef$current7$ch.children[1]) === null || _inputRef$current7$ch2 === void 0 ? void 0 : _inputRef$current7$ch2.setAttribute("aria-label", ariaLabel);
79
+ inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : (_inputRef$current6$ch = _inputRef$current6.children[inputIndex]) === null || _inputRef$current6$ch === void 0 ? void 0 : (_inputRef$current6$ch2 = _inputRef$current6$ch.children[1]) === null || _inputRef$current6$ch2 === void 0 ? void 0 : _inputRef$current6$ch2.setAttribute("aria-expanded", ariaExpanded);
80
+ inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 ? void 0 : (_inputRef$current7$ch = _inputRef$current7.children[inputIndex]) === null || _inputRef$current7$ch === void 0 ? void 0 : (_inputRef$current7$ch2 = _inputRef$current7$ch.children[1]) === null || _inputRef$current7$ch2 === void 0 ? void 0 : _inputRef$current7$ch2.setAttribute("aria-label", ariaLabel);
81
81
  }
82
82
  };
83
83
 
@@ -86,14 +86,14 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
86
86
  };
87
87
 
88
88
  (0, _react.useEffect)(function () {
89
- setAriaAttributes(false, "Show");
89
+ setAriaAttributes(false, "Show password");
90
90
 
91
91
  if (isPasswordVisible) {
92
92
  setInputType("text");
93
- setAriaAttributes(true, "Hide");
93
+ setAriaAttributes(true, "Hide password");
94
94
  } else {
95
95
  setInputType("password");
96
- setAriaAttributes(false, "Show");
96
+ setAriaAttributes(false, "Show password");
97
97
  }
98
98
  }, [isPasswordVisible]);
99
99
 
@@ -150,7 +150,8 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
150
150
  margin: margin,
151
151
  size: size,
152
152
  pattern: pattern,
153
- length: length,
153
+ minLength: minLength,
154
+ maxLength: maxLength,
154
155
  autocomplete: autocomplete,
155
156
  tabIndex: tabIndex
156
157
  }));
@@ -53,7 +53,7 @@ export const Chromatic = () => (
53
53
  <Title title="Margins" theme="light" level={2} />
54
54
  <ExampleContainer>
55
55
  <Title title="Xxsmall margin" theme="light" level={4} />
56
- <DxcPasswordInput label="Xxsmmall" margin="xxsmall" />
56
+ <DxcPasswordInput label="Xxsmall" margin="xxsmall" />
57
57
  </ExampleContainer>
58
58
  <ExampleContainer>
59
59
  <Title title="Xsmall margin" theme="light" level={4} />
@@ -100,7 +100,7 @@ export const Chromatic = () => (
100
100
  );
101
101
 
102
102
  const Password = () => (
103
- <ExampleContainer>
103
+ <ExampleContainer expanded>
104
104
  <Title title="Show password" theme="light" level={4} />
105
105
  <DxcPasswordInput label="Password input" value="Password" />
106
106
  </ExampleContainer>
@@ -108,7 +108,7 @@ const Password = () => (
108
108
  const PasswordDark = () => (
109
109
  <BackgroundColorProvider color="#333333">
110
110
  <DarkContainer>
111
- <ExampleContainer>
111
+ <ExampleContainer expanded>
112
112
  <Title title="Show password" theme="dark" level={4} />
113
113
  <DxcPasswordInput label="Password input" value="Password" />
114
114
  </ExampleContainer>
@@ -37,10 +37,10 @@ declare type Props = {
37
37
  error: string | null;
38
38
  }) => void;
39
39
  /**
40
- * This function will be called when the input element loses the focus.
41
- * An object including the input value and the error (if the value entered is
42
- * not valid) will be passed to this function. If there is no error, error will be null.
43
- */
40
+ * This function will be called when the input element loses the focus.
41
+ * An object including the input value and the error (if the value entered is
42
+ * not valid) will be passed to this function. If there is no error, error will be null.
43
+ */
44
44
  onBlur?: (val: {
45
45
  value: string;
46
46
  error: string | null;
@@ -62,18 +62,25 @@ declare type Props = {
62
62
  */
63
63
  pattern?: string;
64
64
  /**
65
- * Specifies the minimun and maximum length allowed by the password input.
65
+ * Specifies the minimun length allowed by the password input.
66
+ * This will be checked both when the input element loses the
67
+ * focus and while typing within it. If the string entered does not
68
+ * comply the minimum length, the onBlur and onChange functions will be called
69
+ * with the current value and an internal error informing that the value
70
+ * length does not comply the specified range. If a valid length is
71
+ * reached, the error parameter of both events will be null.
72
+ */
73
+ minLength?: number;
74
+ /**
75
+ * Specifies the maximum length allowed by the password input.
66
76
  * This will be checked both when the input element loses the
67
77
  * focus and while typing within it. If the string entered does not
68
- * comply the length, the onBlur and onChange functions will be called
78
+ * comply the maximum length, the onBlur and onChange functions will be called
69
79
  * with the current value and an internal error informing that the value
70
80
  * length does not comply the specified range. If a valid length is
71
81
  * reached, the error parameter of both events will be null.
72
82
  */
73
- length?: {
74
- min?: number;
75
- max?: number;
76
- };
83
+ maxLength?: number;
77
84
  /**
78
85
  * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
79
86
  * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
@@ -21,9 +21,9 @@ var _LinearProgress = _interopRequireDefault(require("@material-ui/core/LinearPr
21
21
 
22
22
  var _variables = require("../common/variables.js");
23
23
 
24
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
24
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
25
25
 
26
- var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
26
+ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
27
27
 
28
28
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
29
29
 
@@ -59,9 +59,9 @@ var DxcProgressBar = function DxcProgressBar(_ref) {
59
59
  overlay: overlay,
60
60
  showValue: showValue,
61
61
  backgroundType: backgroundType
62
- }, value === null ? 0 : value >= 0 && value <= 100 ? value : value < 0 ? 0 : 100, " %")), /*#__PURE__*/_react["default"].createElement(_LinearProgress["default"], {
62
+ }, value === null || value === undefined ? 0 : value >= 0 && value <= 100 ? value : value < 0 ? 0 : 100, " %")), /*#__PURE__*/_react["default"].createElement(_LinearProgress["default"], {
63
63
  variant: showValue ? "determinate" : "indeterminate",
64
- value: value === null ? 0 : value >= 0 && value <= 100 ? value : value < 0 ? 0 : 100
64
+ value: value === null || value === undefined ? 0 : value >= 0 && value <= 100 ? value : value < 0 ? 0 : 100
65
65
  }), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
66
66
  overlay: overlay,
67
67
  backgroundType: backgroundType
package/radio/Radio.js CHANGED
@@ -27,9 +27,9 @@ var _variables = require("../common/variables.js");
27
27
 
28
28
  var _utils = require("../common/utils.js");
29
29
 
30
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
30
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
31
31
 
32
- var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
32
+ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
33
33
 
34
34
  var _templateObject, _templateObject2;
35
35
 
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,130 @@
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;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import RadioGroupPropsType from "./types";
3
+ declare const DxcRadioGroup: React.ForwardRefExoticComponent<RadioGroupPropsType & React.RefAttributes<HTMLDivElement>>;
4
+ export default DxcRadioGroup;