@dxc-technology/halstack-react 0.0.0-c25d3b6 → 0.0.0-c2834c3

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 (104) hide show
  1. package/HalstackContext.d.ts +12 -0
  2. package/HalstackContext.js +298 -0
  3. package/accordion/Accordion.d.ts +1 -1
  4. package/accordion/Accordion.js +7 -28
  5. package/accordion/Accordion.stories.tsx +11 -11
  6. package/accordion/Accordion.test.js +19 -4
  7. package/accordion/types.d.ts +4 -0
  8. package/accordion-group/AccordionGroup.d.ts +1 -1
  9. package/accordion-group/AccordionGroup.js +13 -15
  10. package/accordion-group/AccordionGroup.stories.tsx +1 -1
  11. package/accordion-group/AccordionGroup.test.js +24 -6
  12. package/accordion-group/types.d.ts +4 -0
  13. package/alert/Alert.js +4 -1
  14. package/button/Button.js +14 -11
  15. package/card/Card.js +27 -28
  16. package/checkbox/Checkbox.d.ts +1 -1
  17. package/checkbox/Checkbox.js +43 -39
  18. package/checkbox/Checkbox.stories.tsx +124 -128
  19. package/checkbox/Checkbox.test.js +13 -0
  20. package/checkbox/types.d.ts +7 -3
  21. package/common/variables.js +181 -70
  22. package/date-input/DateInput.js +38 -20
  23. package/date-input/DateInput.test.js +9 -22
  24. package/date-input/types.d.ts +12 -9
  25. package/dialog/Dialog.js +4 -32
  26. package/dropdown/Dropdown.js +13 -17
  27. package/file-input/FileInput.js +9 -6
  28. package/file-input/FileItem.js +7 -5
  29. package/footer/Footer.js +15 -88
  30. package/header/Header.js +27 -48
  31. package/header/Header.stories.tsx +46 -36
  32. package/header/Header.test.js +18 -2
  33. package/inset/types.d.ts +24 -0
  34. package/layout/ApplicationLayout.js +5 -18
  35. package/link/Link.d.ts +3 -2
  36. package/link/Link.js +65 -56
  37. package/link/Link.stories.tsx +87 -52
  38. package/link/Link.test.js +7 -15
  39. package/link/types.d.ts +8 -23
  40. package/main.d.ts +3 -2
  41. package/main.js +19 -5
  42. package/number-input/NumberInput.test.js +2 -4
  43. package/number-input/types.d.ts +13 -10
  44. package/package.json +6 -5
  45. package/paginator/Paginator.js +17 -38
  46. package/password-input/PasswordInput.js +7 -4
  47. package/password-input/PasswordInput.test.js +3 -6
  48. package/password-input/types.d.ts +14 -11
  49. package/quick-nav/QuickNav.d.ts +4 -0
  50. package/quick-nav/QuickNav.js +116 -0
  51. package/quick-nav/QuickNav.stories.tsx +237 -0
  52. package/quick-nav/types.d.ts +21 -0
  53. package/quick-nav/types.js +5 -0
  54. package/radio/Radio.js +10 -11
  55. package/radio-group/Radio.js +1 -1
  56. package/radio-group/RadioGroup.js +8 -6
  57. package/row/types.d.ts +18 -0
  58. package/select/Listbox.d.ts +4 -0
  59. package/select/Listbox.js +152 -0
  60. package/select/Option.js +1 -1
  61. package/select/Select.js +53 -139
  62. package/select/Select.stories.tsx +14 -2
  63. package/select/Select.test.js +83 -42
  64. package/select/types.d.ts +33 -11
  65. package/slider/Slider.d.ts +1 -1
  66. package/slider/Slider.js +2 -1
  67. package/slider/Slider.stories.tsx +8 -8
  68. package/slider/Slider.test.js +31 -10
  69. package/slider/types.d.ts +4 -0
  70. package/spinner/Spinner.js +1 -1
  71. package/switch/Switch.d.ts +1 -1
  72. package/switch/Switch.js +35 -19
  73. package/switch/Switch.stories.tsx +14 -14
  74. package/switch/Switch.test.js +25 -0
  75. package/switch/types.d.ts +6 -2
  76. package/tabs/Tabs.d.ts +1 -1
  77. package/tabs/Tabs.js +9 -11
  78. package/tabs/Tabs.stories.tsx +0 -8
  79. package/tabs/Tabs.test.js +26 -9
  80. package/tabs/types.d.ts +4 -0
  81. package/tag/Tag.js +5 -8
  82. package/text-input/Suggestion.d.ts +4 -0
  83. package/text-input/Suggestion.js +55 -0
  84. package/text-input/TextInput.js +48 -76
  85. package/text-input/TextInput.test.js +22 -35
  86. package/text-input/types.d.ts +27 -12
  87. package/textarea/Textarea.js +12 -23
  88. package/textarea/Textarea.test.js +10 -20
  89. package/textarea/types.d.ts +14 -11
  90. package/toggle-group/ToggleGroup.d.ts +1 -1
  91. package/toggle-group/ToggleGroup.js +5 -4
  92. package/toggle-group/ToggleGroup.stories.tsx +4 -4
  93. package/toggle-group/ToggleGroup.test.js +35 -4
  94. package/toggle-group/types.d.ts +8 -0
  95. package/useTheme.js +2 -2
  96. package/useTranslatedLabels.d.ts +2 -0
  97. package/useTranslatedLabels.js +20 -0
  98. package/wizard/Wizard.d.ts +1 -1
  99. package/wizard/Wizard.js +55 -44
  100. package/wizard/Wizard.stories.tsx +13 -23
  101. package/wizard/Wizard.test.js +36 -23
  102. package/wizard/types.d.ts +6 -2
  103. package/ThemeContext.d.ts +0 -10
  104. package/ThemeContext.js +0 -243
@@ -17,6 +17,8 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
17
17
 
18
18
  var _useTheme = _interopRequireDefault(require("../useTheme"));
19
19
 
20
+ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
21
+
20
22
  var _Button = _interopRequireDefault(require("../button/Button"));
21
23
 
22
24
  var _Select = _interopRequireDefault(require("../select/Select"));
@@ -49,13 +51,14 @@ var DxcPaginator = function DxcPaginator(_ref) {
49
51
  var minItemsPerPage = currentPageInternal === 1 || currentPageInternal === 0 ? currentPageInternal : (currentPageInternal - 1) * itemsPerPage + 1;
50
52
  var maxItemsPerPage = minItemsPerPage - 1 + itemsPerPage > totalItems ? totalItems : minItemsPerPage - 1 + itemsPerPage;
51
53
  var colorsTheme = (0, _useTheme["default"])();
54
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
52
55
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
53
56
  theme: colorsTheme.paginator
54
57
  }, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
55
58
  color: colorsTheme.paginator.backgroundColor
56
59
  }, /*#__PURE__*/_react["default"].createElement(DxcPaginatorContainer, {
57
60
  disabled: currentPageInternal === 1
58
- }, /*#__PURE__*/_react["default"].createElement(LabelsContainer, null, itemsPerPageOptions && /*#__PURE__*/_react["default"].createElement(ItemsPageContainer, null, /*#__PURE__*/_react["default"].createElement(ItemsLabel, null, "Items per page "), /*#__PURE__*/_react["default"].createElement(SelectContainer, null, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
61
+ }, /*#__PURE__*/_react["default"].createElement(LabelsContainer, null, itemsPerPageOptions && /*#__PURE__*/_react["default"].createElement(ItemsPageContainer, null, /*#__PURE__*/_react["default"].createElement(ItemsLabel, null, translatedLabels.paginator.itemsPerPageText), /*#__PURE__*/_react["default"].createElement(SelectContainer, null, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
59
62
  options: itemsPerPageOptions.map(function (num) {
60
63
  return {
61
64
  label: num.toString(),
@@ -68,14 +71,10 @@ var DxcPaginator = function DxcPaginator(_ref) {
68
71
  value: itemsPerPage.toString(),
69
72
  size: "fillParent",
70
73
  tabIndex: tabIndex
71
- }))), /*#__PURE__*/_react["default"].createElement(TotalItemsContainer, null, minItemsPerPage, " to ", maxItemsPerPage, " of ", totalItems), onPageChange && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
74
+ }))), /*#__PURE__*/_react["default"].createElement(TotalItemsContainer, null, translatedLabels.paginator.minToMaxOfText(minItemsPerPage, maxItemsPerPage, totalItems)), onPageChange && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
72
75
  size: "small",
73
76
  mode: "secondary",
74
77
  disabled: currentPageInternal === 1 || currentPageInternal === 0,
75
- margin: {
76
- left: "xxsmall",
77
- right: "xxsmall"
78
- },
79
78
  icon: _Icons.firstIcon,
80
79
  tabIndex: tabIndex,
81
80
  onClick: function onClick() {
@@ -85,16 +84,12 @@ var DxcPaginator = function DxcPaginator(_ref) {
85
84
  size: "small",
86
85
  mode: "secondary",
87
86
  disabled: currentPageInternal === 1 || currentPageInternal === 0,
88
- margin: {
89
- left: "xxsmall",
90
- right: "xxsmall"
91
- },
92
87
  icon: _Icons.previousIcon,
93
88
  tabIndex: tabIndex,
94
89
  onClick: function onClick() {
95
90
  onPageChange(currentPage - 1);
96
91
  }
97
- }), showGoToPage && /*#__PURE__*/_react["default"].createElement(PageToSelectContainer, null, /*#__PURE__*/_react["default"].createElement(GoToLabel, null, "Go to page: "), /*#__PURE__*/_react["default"].createElement(SelectContainer, null, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
92
+ }), showGoToPage && /*#__PURE__*/_react["default"].createElement(PageToSelectContainer, null, /*#__PURE__*/_react["default"].createElement(GoToLabel, null, translatedLabels.paginator.goToPageText, " "), /*#__PURE__*/_react["default"].createElement(SelectContainer, null, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
98
93
  options: Array.from(Array(totalPages), function (e, num) {
99
94
  return {
100
95
  label: (num + 1).toString(),
@@ -107,14 +102,10 @@ var DxcPaginator = function DxcPaginator(_ref) {
107
102
  value: currentPage.toString(),
108
103
  size: "fillParent",
109
104
  tabIndex: tabIndex
110
- }))) || /*#__PURE__*/_react["default"].createElement(TextContainer, null, "Page: ", currentPageInternal, " of ", totalPages), onPageChange && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
105
+ }))) || /*#__PURE__*/_react["default"].createElement(TextContainer, null, translatedLabels.paginator.pageOfText(currentPageInternal, totalPages)), onPageChange && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
111
106
  size: "small",
112
107
  mode: "secondary",
113
108
  disabled: currentPageInternal === totalPages,
114
- margin: {
115
- left: "xxsmall",
116
- right: "xxsmall"
117
- },
118
109
  icon: _Icons.nextIcon,
119
110
  tabIndex: tabIndex,
120
111
  onClick: function onClick() {
@@ -124,10 +115,6 @@ var DxcPaginator = function DxcPaginator(_ref) {
124
115
  size: "small",
125
116
  mode: "secondary",
126
117
  disabled: currentPageInternal === totalPages,
127
- margin: {
128
- left: "xxsmall",
129
- right: "xxsmall"
130
- },
131
118
  icon: _Icons.lastIcon,
132
119
  tabIndex: tabIndex,
133
120
  onClick: function onClick() {
@@ -136,11 +123,7 @@ var DxcPaginator = function DxcPaginator(_ref) {
136
123
  })))));
137
124
  };
138
125
 
139
- var DxcPaginatorContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n height: ", ";\n width: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n font-style: ", ";\n text-transform: ", ";\n background-color: ", ";\n color: ", ";\n\n button {\n &:disabled {\n background-color: transparent !important;\n opacity: 0.3 !important;\n }\n }\n"])), function (props) {
140
- return props.theme.height;
141
- }, function (props) {
142
- return props.theme.width;
143
- }, function (props) {
126
+ var DxcPaginatorContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n font-style: ", ";\n text-transform: ", ";\n background-color: ", ";\n color: ", ";\n padding: ", " ", ";\n\n button {\n &:disabled {\n background-color: transparent !important;\n opacity: 0.3 !important;\n }\n }\n"])), function (props) {
144
127
  return props.theme.fontFamily;
145
128
  }, function (props) {
146
129
  return props.theme.fontSize;
@@ -154,9 +137,13 @@ var DxcPaginatorContainer = _styledComponents["default"].div(_templateObject ||
154
137
  return props.theme.backgroundColor;
155
138
  }, function (props) {
156
139
  return props.theme.fontColor;
140
+ }, function (props) {
141
+ return props.theme.verticalPadding;
142
+ }, function (props) {
143
+ return props.theme.horizontalPadding;
157
144
  });
158
145
 
159
- var SelectContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n max-width: 100px;\n"])));
146
+ var SelectContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n min-width: 5.25rem;\n"])));
160
147
 
161
148
  var ItemsPageContainer = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n margin-right: ", ";\n margin-left: ", ";\n\n label {\n height: 0px;\n }\n label + .MuiInput-formControl {\n margin-top: 0px;\n }\n"])), function (props) {
162
149
  return props.theme.itemsPerPageSelectorMarginRight;
@@ -164,9 +151,9 @@ var ItemsPageContainer = _styledComponents["default"].span(_templateObject3 || (
164
151
  return props.theme.itemsPerPageSelectorMarginLeft;
165
152
  });
166
153
 
167
- var ItemsLabel = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: 15px;\n"])));
154
+ var ItemsLabel = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: 0.5rem;\n"])));
168
155
 
169
- var GoToLabel = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: 10px;\n margin-left: 10px;\n"])));
156
+ var GoToLabel = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: 0.5rem;\n margin-left: 1rem;\n"])));
170
157
 
171
158
  var TotalItemsContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: ", ";\n margin-left: ", ";\n"])), function (props) {
172
159
  return props.theme.totalItemsContainerMarginRight;
@@ -174,17 +161,9 @@ var TotalItemsContainer = _styledComponents["default"].span(_templateObject6 ||
174
161
  return props.theme.totalItemsContainerMarginLeft;
175
162
  });
176
163
 
177
- var LabelsContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n width: 100%;\n justify-content: flex-end;\n align-items: center;\n margin: 0 ", " 0 ", ";\n"])), function (props) {
178
- return props.theme.marginRight;
179
- }, function (props) {
180
- return props.theme.marginLeft;
181
- });
164
+ var LabelsContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n gap: 0.5rem;\n width: 100%;\n justify-content: flex-end;\n align-items: center;\n"])));
182
165
 
183
- var PageToSelectContainer = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n margin-right: ", ";\n margin-left: ", ";\n\n label {\n height: 0px;\n }\n label + .MuiInput-formControl {\n margin-top: 0px;\n }\n"])), function (props) {
184
- return props.theme.pageSelectorMarginRight;
185
- }, function (props) {
186
- return props.theme.pageSelectorMarginLeft;
187
- });
166
+ var PageToSelectContainer = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n\n label {\n height: 0px;\n }\n label + .MuiInput-formControl {\n margin-top: 0px;\n }\n"])));
188
167
 
189
168
  var TextContainer = _styledComponents["default"].span(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])([""])));
190
169
 
@@ -19,6 +19,8 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
19
19
 
20
20
  var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
21
21
 
22
+ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
23
+
22
24
  var _templateObject;
23
25
 
24
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); }
@@ -53,6 +55,7 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
53
55
  setIsPasswordVisible = _useState2[1];
54
56
 
55
57
  var inputRef = (0, _react.useRef)(null);
58
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
56
59
 
57
60
  var setInputType = function setInputType(type) {
58
61
  var _inputRef$current, _inputRef$current$chi;
@@ -82,18 +85,18 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
82
85
  };
83
86
 
84
87
  var getIconTitle = function getIconTitle() {
85
- return isPasswordVisible ? "Hide password" : "Show password";
88
+ return isPasswordVisible ? translatedLabels.passwordInput.inputHidePasswordTitle : translatedLabels.passwordInput.inputShowPasswordTitle;
86
89
  };
87
90
 
88
91
  (0, _react.useEffect)(function () {
89
- setAriaAttributes(false, "Show password");
92
+ setAriaAttributes(false, translatedLabels.passwordInput.inputShowPasswordTitle);
90
93
 
91
94
  if (isPasswordVisible) {
92
95
  setInputType("text");
93
- setAriaAttributes(true, "Hide password");
96
+ setAriaAttributes(true, translatedLabels.passwordInput.inputHidePasswordTitle);
94
97
  } else {
95
98
  setInputType("password");
96
- setAriaAttributes(false, "Show password");
99
+ setAriaAttributes(false, translatedLabels.passwordInput.inputShowPasswordTitle);
97
100
  }
98
101
  }, [isPasswordVisible]);
99
102
 
@@ -53,8 +53,7 @@ describe("Password input component tests", function () {
53
53
  _userEvent["default"].type(passwordInput, "Pa$$w0rd");
54
54
 
55
55
  expect(onChange).toHaveBeenCalledWith({
56
- value: "P",
57
- error: null
56
+ value: "P"
58
57
  });
59
58
  expect(passwordInput.value).toBe("Pa$$w0rd");
60
59
  });
@@ -74,8 +73,7 @@ describe("Password input component tests", function () {
74
73
  _react2.fireEvent.blur(passwordInput);
75
74
 
76
75
  expect(onBlur).toHaveBeenCalledWith({
77
- value: "Pa$$w0rd",
78
- error: null
76
+ value: "Pa$$w0rd"
79
77
  });
80
78
  expect(passwordInput.value).toBe("Pa$$w0rd");
81
79
  });
@@ -171,13 +169,12 @@ describe("Password input component tests", function () {
171
169
  var passwordInput = getByRole("textbox");
172
170
  expect(passwordInput.getAttribute("aria-autocomplete")).toBeNull();
173
171
  expect(passwordInput.getAttribute("aria-controls")).toBeNull();
172
+ expect(passwordInput.getAttribute("aria-expanded")).toBeNull();
174
173
  var showButton = getByRole("button");
175
- expect(showButton.getAttribute("aria-expanded")).toBe("false");
176
174
  expect(showButton.getAttribute("aria-label")).toBe("Show password");
177
175
 
178
176
  _userEvent["default"].click(showButton);
179
177
 
180
- expect(showButton.getAttribute("aria-expanded")).toBe("true");
181
178
  expect(showButton.getAttribute("aria-label")).toBe("Hide password");
182
179
  });
183
180
  });
@@ -30,25 +30,28 @@ declare type Props = {
30
30
  * This function will be called when the user types within the input
31
31
  * element of the component. An object including the current value and
32
32
  * the error (if the value entered is not valid) will be passed to this
33
- * function. If there is no error, error will be null.
33
+ * function. If there is no error, error will not be defined.
34
34
  * */
35
35
  onChange?: (val: {
36
36
  value: string;
37
- error: string | null;
37
+ error?: string;
38
38
  }) => void;
39
39
  /**
40
40
  * This function will be called when the input element loses the focus.
41
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.
42
+ * not valid) will be passed to this function. If there is no error, error will not be defined.
43
43
  */
44
44
  onBlur?: (val: {
45
45
  value: string;
46
- error: string | null;
46
+ error?: string;
47
47
  }) => void;
48
48
  /**
49
- * If it is defined, the component will change its appearance, showing
50
- * the error below the password input component. If it is not defined, the
51
- * error messages will be managed internally, but never displayed on its own.
49
+ * If it is a defined value and also a truthy string, the component will
50
+ * change its appearance, showing the error below the password input
51
+ * component. If the defined value is an empty string, it will reserve a
52
+ * space below the component for a future error, but it would not change
53
+ * its look. In case of being undefined or null, both the appearance and
54
+ * the space for the error message would not be modified.
52
55
  */
53
56
  error?: string;
54
57
  /**
@@ -58,7 +61,7 @@ declare type Props = {
58
61
  * the pattern, the onBlur and onChange functions will be called with the
59
62
  * current value and an internal error informing that this value does not
60
63
  * match the pattern. If the pattern is met, the error parameter of both
61
- * events will be null.
64
+ * events will not be defined.
62
65
  */
63
66
  pattern?: string;
64
67
  /**
@@ -68,7 +71,7 @@ declare type Props = {
68
71
  * comply the minimum length, the onBlur and onChange functions will be called
69
72
  * with the current value and an internal error informing that the value
70
73
  * length does not comply the specified range. If a valid length is
71
- * reached, the error parameter of both events will be null.
74
+ * reached, the error parameter of both events will not be defined.
72
75
  */
73
76
  minLength?: number;
74
77
  /**
@@ -78,7 +81,7 @@ declare type Props = {
78
81
  * comply the maximum length, the onBlur and onChange functions will be called
79
82
  * with the current value and an internal error informing that the value
80
83
  * length does not comply the specified range. If a valid length is
81
- * reached, the error parameter of both events will be null.
84
+ * reached, the error parameter of both events will not be defined.
82
85
  */
83
86
  maxLength?: number;
84
87
  /**
@@ -92,7 +95,7 @@ declare type Props = {
92
95
  */
93
96
  margin?: Space | Margin;
94
97
  /**
95
- * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
98
+ * Size of the component.
96
99
  */
97
100
  size?: "small" | "medium" | "large" | "fillParent";
98
101
  /**
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import QuickNavTypes from "./types";
3
+ declare const DxcQuickNav: ({ title, links }: QuickNavTypes) => JSX.Element;
4
+ export default DxcQuickNav;
@@ -0,0 +1,116 @@
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 _react = _interopRequireDefault(require("react"));
15
+
16
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
17
+
18
+ var _slugify = _interopRequireDefault(require("slugify"));
19
+
20
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
21
+
22
+ var _Heading = _interopRequireDefault(require("../heading/Heading"));
23
+
24
+ var _Stack = _interopRequireDefault(require("../stack/Stack"));
25
+
26
+ var _Inset = _interopRequireDefault(require("../inset/Inset"));
27
+
28
+ var _List = _interopRequireDefault(require("../list/List"));
29
+
30
+ var _Text = _interopRequireDefault(require("../text/Text"));
31
+
32
+ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
33
+
34
+ var _templateObject, _templateObject2;
35
+
36
+ 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); }
37
+
38
+ 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; }
39
+
40
+ var DxcQuickNav = function DxcQuickNav(_ref) {
41
+ var title = _ref.title,
42
+ links = _ref.links;
43
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
44
+ var colorsTheme = (0, _useTheme["default"])();
45
+ return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
46
+ theme: colorsTheme.quickNav
47
+ }, /*#__PURE__*/_react["default"].createElement(QuickNavContainer, null, /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
48
+ gutter: "xsmall"
49
+ }, /*#__PURE__*/_react["default"].createElement(_Heading["default"], {
50
+ level: 4,
51
+ text: title || translatedLabels.quickNav.contentTitle
52
+ }), /*#__PURE__*/_react["default"].createElement(_List["default"], null, /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
53
+ gutter: "xsmall"
54
+ }, links.map(function (link) {
55
+ var _link$links;
56
+
57
+ return /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
58
+ space: "xxsmall"
59
+ }, /*#__PURE__*/_react["default"].createElement(_Text["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
60
+ href: "#".concat((0, _slugify["default"])(link === null || link === void 0 ? void 0 : link.label, {
61
+ lower: true
62
+ })),
63
+ isSelected: location.href.includes("#".concat((0, _slugify["default"])(link === null || link === void 0 ? void 0 : link.label, {
64
+ lower: true
65
+ })))
66
+ }, link === null || link === void 0 ? void 0 : link.label), (_link$links = link.links) === null || _link$links === void 0 ? void 0 : _link$links.map(function (sublink) {
67
+ return /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
68
+ horizontal: "xsmall"
69
+ }, /*#__PURE__*/_react["default"].createElement(_Text["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
70
+ href: "#".concat((0, _slugify["default"])(sublink === null || sublink === void 0 ? void 0 : sublink.label, {
71
+ lower: true
72
+ })),
73
+ isSelected: location.href.includes("#".concat((0, _slugify["default"])(sublink === null || sublink === void 0 ? void 0 : sublink.label, {
74
+ lower: true
75
+ })))
76
+ }, sublink === null || sublink === void 0 ? void 0 : sublink.label)));
77
+ })));
78
+ }))))));
79
+ };
80
+
81
+ var QuickNavContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n border-left: 2px solid ", ";\n li > div:first-child {\n display: none;\n }\n"])), function (props) {
82
+ return props.theme.paddingTop;
83
+ }, function (props) {
84
+ return props.theme.paddingBottom;
85
+ }, function (props) {
86
+ return props.theme.paddingLeft;
87
+ }, function (props) {
88
+ return props.theme.paddingRight;
89
+ }, function (props) {
90
+ return props.theme.dividerBorderColor;
91
+ });
92
+
93
+ var Link = _styledComponents["default"].a(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n text-decoration: none;\n font-size: ", ";\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n &:focus {\n outline-color: ", ";\n outline-style: ", ";\n outline-width: ", ";\n border-radius: ", ";\n }\n"])), function (props) {
94
+ return props.theme.fontSize;
95
+ }, function (props) {
96
+ return props.theme.fontFamily;
97
+ }, function (props) {
98
+ return props.theme.fontStyle;
99
+ }, function (props) {
100
+ return props.theme.fontWeight;
101
+ }, function (props) {
102
+ return props.isSelected && props.theme.selectedFontColor || props.theme.fontColor;
103
+ }, function (props) {
104
+ return props.theme.hoverFontColor;
105
+ }, function (props) {
106
+ return props.theme.focusBorderColor;
107
+ }, function (props) {
108
+ return props.theme.focusBorderStyle;
109
+ }, function (props) {
110
+ return props.theme.focusBorderThickness;
111
+ }, function (props) {
112
+ return props.theme.focusBorderRadius;
113
+ });
114
+
115
+ var _default = DxcQuickNav;
116
+ exports["default"] = _default;