@dxc-technology/halstack-react 0.0.0-bf77201 → 0.0.0-bfc9025

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 (204) hide show
  1. package/README.md +27 -47
  2. package/dist/index.d.mts +6802 -0
  3. package/dist/index.d.ts +6802 -0
  4. package/dist/index.js +14240 -0
  5. package/dist/index.mjs +14151 -0
  6. package/package.json +76 -67
  7. package/babel.config.js +0 -8
  8. package/dist/BackgroundColorContext.js +0 -46
  9. package/dist/ThemeContext.js +0 -216
  10. package/dist/accordion/Accordion.js +0 -348
  11. package/dist/accordion/Accordion.stories.js +0 -207
  12. package/dist/accordion/readme.md +0 -96
  13. package/dist/accordion-group/AccordionGroup.js +0 -188
  14. package/dist/accordion-group/AccordionGroup.stories.js +0 -207
  15. package/dist/accordion-group/readme.md +0 -70
  16. package/dist/alert/Alert.js +0 -392
  17. package/dist/alert/Alert.stories.js +0 -158
  18. package/dist/alert/close.svg +0 -4
  19. package/dist/alert/error.svg +0 -4
  20. package/dist/alert/info.svg +0 -4
  21. package/dist/alert/readme.md +0 -43
  22. package/dist/alert/success.svg +0 -4
  23. package/dist/alert/warning.svg +0 -4
  24. package/dist/badge/Badge.js +0 -63
  25. package/dist/box/Box.js +0 -156
  26. package/dist/button/Button.js +0 -232
  27. package/dist/button/Button.stories.js +0 -224
  28. package/dist/button/readme.md +0 -93
  29. package/dist/card/Card.js +0 -254
  30. package/dist/checkbox/Checkbox.js +0 -294
  31. package/dist/checkbox/Checkbox.stories.js +0 -144
  32. package/dist/checkbox/readme.md +0 -116
  33. package/dist/chip/Chip.js +0 -265
  34. package/dist/common/OpenSans.css +0 -81
  35. package/dist/common/RequiredComponent.js +0 -40
  36. package/dist/common/fonts/OpenSans-Bold.ttf +0 -0
  37. package/dist/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  38. package/dist/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  39. package/dist/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  40. package/dist/common/fonts/OpenSans-Italic.ttf +0 -0
  41. package/dist/common/fonts/OpenSans-Light.ttf +0 -0
  42. package/dist/common/fonts/OpenSans-LightItalic.ttf +0 -0
  43. package/dist/common/fonts/OpenSans-Regular.ttf +0 -0
  44. package/dist/common/fonts/OpenSans-SemiBold.ttf +0 -0
  45. package/dist/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  46. package/dist/common/utils.js +0 -22
  47. package/dist/common/variables.js +0 -1365
  48. package/dist/date/Date.js +0 -381
  49. package/dist/date/Date.stories.js +0 -205
  50. package/dist/date/readme.md +0 -73
  51. package/dist/dialog/Dialog.js +0 -240
  52. package/dist/dialog/Dialog.stories.js +0 -217
  53. package/dist/dialog/readme.md +0 -32
  54. package/dist/dropdown/Dropdown.js +0 -504
  55. package/dist/dropdown/Dropdown.stories.js +0 -249
  56. package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
  57. package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
  58. package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
  59. package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
  60. package/dist/dropdown/readme.md +0 -69
  61. package/dist/footer/Footer.js +0 -395
  62. package/dist/footer/Footer.stories.js +0 -94
  63. package/dist/footer/dxc_logo.svg +0 -15
  64. package/dist/footer/readme.md +0 -41
  65. package/dist/header/Header.js +0 -423
  66. package/dist/header/Header.stories.js +0 -176
  67. package/dist/header/close_icon.svg +0 -1
  68. package/dist/header/dxc_logo_black.svg +0 -8
  69. package/dist/header/hamb_menu_black.svg +0 -1
  70. package/dist/header/hamb_menu_white.svg +0 -1
  71. package/dist/header/readme.md +0 -33
  72. package/dist/heading/Heading.js +0 -218
  73. package/dist/input-text/InputText.js +0 -707
  74. package/dist/input-text/InputText.stories.js +0 -209
  75. package/dist/input-text/error.svg +0 -1
  76. package/dist/input-text/readme.md +0 -91
  77. package/dist/layout/ApplicationLayout.js +0 -331
  78. package/dist/layout/facebook.svg +0 -45
  79. package/dist/layout/linkedin.svg +0 -50
  80. package/dist/layout/twitter.svg +0 -53
  81. package/dist/link/Link.js +0 -241
  82. package/dist/link/readme.md +0 -51
  83. package/dist/main.js +0 -351
  84. package/dist/new-date/NewDate.js +0 -403
  85. package/dist/new-input-text/NewInputText.js +0 -961
  86. package/dist/new-textarea/NewTextarea.js +0 -346
  87. package/dist/number/Number.js +0 -138
  88. package/dist/number/NumberContext.js +0 -16
  89. package/dist/paginator/Paginator.js +0 -289
  90. package/dist/paginator/images/next.svg +0 -3
  91. package/dist/paginator/images/nextPage.svg +0 -3
  92. package/dist/paginator/images/previous.svg +0 -3
  93. package/dist/paginator/images/previousPage.svg +0 -3
  94. package/dist/paginator/readme.md +0 -50
  95. package/dist/password/Password.js +0 -200
  96. package/dist/password/styles.css +0 -3
  97. package/dist/progress-bar/ProgressBar.js +0 -206
  98. package/dist/progress-bar/ProgressBar.stories.js +0 -280
  99. package/dist/progress-bar/readme.md +0 -63
  100. package/dist/radio/Radio.js +0 -209
  101. package/dist/radio/Radio.stories.js +0 -166
  102. package/dist/radio/readme.md +0 -70
  103. package/dist/resultsetTable/ResultsetTable.js +0 -358
  104. package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
  105. package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
  106. package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
  107. package/dist/select/Select.js +0 -585
  108. package/dist/select/Select.stories.js +0 -235
  109. package/dist/select/readme.md +0 -72
  110. package/dist/sidenav/Sidenav.js +0 -177
  111. package/dist/slider/Slider.js +0 -315
  112. package/dist/slider/Slider.stories.js +0 -241
  113. package/dist/slider/readme.md +0 -64
  114. package/dist/spinner/Spinner.js +0 -218
  115. package/dist/spinner/Spinner.stories.js +0 -183
  116. package/dist/spinner/readme.md +0 -65
  117. package/dist/switch/Switch.js +0 -222
  118. package/dist/switch/Switch.stories.js +0 -134
  119. package/dist/switch/readme.md +0 -133
  120. package/dist/table/Table.js +0 -132
  121. package/dist/tabs/Tabs.js +0 -343
  122. package/dist/tabs/Tabs.stories.js +0 -130
  123. package/dist/tabs/readme.md +0 -78
  124. package/dist/tabs-for-sections/TabsForSections.js +0 -92
  125. package/dist/tabs-for-sections/readme.md +0 -78
  126. package/dist/tag/Tag.js +0 -288
  127. package/dist/textarea/Textarea.js +0 -264
  128. package/dist/toggle/Toggle.js +0 -220
  129. package/dist/toggle/Toggle.stories.js +0 -297
  130. package/dist/toggle/readme.md +0 -80
  131. package/dist/toggle-group/ToggleGroup.js +0 -241
  132. package/dist/toggle-group/readme.md +0 -82
  133. package/dist/upload/Upload.js +0 -205
  134. package/dist/upload/Upload.stories.js +0 -72
  135. package/dist/upload/buttons-upload/ButtonsUpload.js +0 -139
  136. package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
  137. package/dist/upload/buttons-upload/upload-button.svg +0 -1
  138. package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -329
  139. package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
  140. package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
  141. package/dist/upload/file-upload/FileToUpload.js +0 -184
  142. package/dist/upload/file-upload/audio-icon.svg +0 -4
  143. package/dist/upload/file-upload/close.svg +0 -4
  144. package/dist/upload/file-upload/file-icon.svg +0 -4
  145. package/dist/upload/file-upload/video-icon.svg +0 -4
  146. package/dist/upload/files-upload/FilesToUpload.js +0 -123
  147. package/dist/upload/readme.md +0 -37
  148. package/dist/upload/transaction/Transaction.js +0 -175
  149. package/dist/upload/transaction/audio-icon-err.svg +0 -4
  150. package/dist/upload/transaction/audio-icon.svg +0 -4
  151. package/dist/upload/transaction/error-icon.svg +0 -4
  152. package/dist/upload/transaction/file-icon-err.svg +0 -4
  153. package/dist/upload/transaction/file-icon.svg +0 -4
  154. package/dist/upload/transaction/image-icon-err.svg +0 -4
  155. package/dist/upload/transaction/image-icon.svg +0 -4
  156. package/dist/upload/transaction/success-icon.svg +0 -4
  157. package/dist/upload/transaction/video-icon-err.svg +0 -4
  158. package/dist/upload/transaction/video-icon.svg +0 -4
  159. package/dist/upload/transactions/Transactions.js +0 -138
  160. package/dist/useTheme.js +0 -22
  161. package/dist/wizard/Wizard.js +0 -411
  162. package/dist/wizard/invalid_icon.svg +0 -5
  163. package/dist/wizard/valid_icon.svg +0 -5
  164. package/dist/wizard/validation-wrong.svg +0 -6
  165. package/test/Accordion.test.js +0 -33
  166. package/test/AccordionGroup.test.js +0 -125
  167. package/test/Alert.test.js +0 -53
  168. package/test/Box.test.js +0 -10
  169. package/test/Button.test.js +0 -18
  170. package/test/Card.test.js +0 -30
  171. package/test/Checkbox.test.js +0 -45
  172. package/test/Chip.test.js +0 -25
  173. package/test/Date.test.js +0 -393
  174. package/test/Dialog.test.js +0 -23
  175. package/test/Dropdown.test.js +0 -145
  176. package/test/Footer.test.js +0 -99
  177. package/test/Header.test.js +0 -39
  178. package/test/Heading.test.js +0 -35
  179. package/test/InputText.test.js +0 -240
  180. package/test/Link.test.js +0 -43
  181. package/test/NewDate.test.js +0 -203
  182. package/test/NewInputText.test.js +0 -817
  183. package/test/NewTextarea.test.js +0 -201
  184. package/test/Number.test.js +0 -241
  185. package/test/Paginator.test.js +0 -177
  186. package/test/Password.test.js +0 -76
  187. package/test/ProgressBar.test.js +0 -35
  188. package/test/Radio.test.js +0 -37
  189. package/test/ResultsetTable.test.js +0 -330
  190. package/test/Select.test.js +0 -189
  191. package/test/Sidenav.test.js +0 -45
  192. package/test/Slider.test.js +0 -82
  193. package/test/Spinner.test.js +0 -27
  194. package/test/Switch.test.js +0 -45
  195. package/test/Table.test.js +0 -36
  196. package/test/Tabs.test.js +0 -109
  197. package/test/TabsForSections.test.js +0 -34
  198. package/test/Tag.test.js +0 -32
  199. package/test/TextArea.test.js +0 -52
  200. package/test/ToggleGroup.test.js +0 -81
  201. package/test/Upload.test.js +0 -60
  202. package/test/Wizard.test.js +0 -130
  203. package/test/mocks/pngMock.js +0 -1
  204. package/test/mocks/svgMock.js +0 -1
@@ -1,585 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = void 0;
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
-
16
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
17
-
18
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
-
20
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
21
-
22
- var _react = _interopRequireWildcard(require("react"));
23
-
24
- var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
25
-
26
- var _InputLabel = _interopRequireDefault(require("@material-ui/core/InputLabel"));
27
-
28
- var _FormControl = _interopRequireDefault(require("@material-ui/core/FormControl"));
29
-
30
- var _FormHelperText = _interopRequireDefault(require("@material-ui/core/FormHelperText"));
31
-
32
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
33
-
34
- var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
35
-
36
- var _styles = require("@material-ui/core/styles");
37
-
38
- var _propTypes = _interopRequireDefault(require("prop-types"));
39
-
40
- var _Checkbox = _interopRequireDefault(require("../checkbox/Checkbox"));
41
-
42
- var _variables = require("../common/variables.js");
43
-
44
- var _utils = require("../common/utils.js");
45
-
46
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
47
-
48
- var _RequiredComponent = _interopRequireDefault(require("../common/RequiredComponent"));
49
-
50
- var _BackgroundColorContext = _interopRequireWildcard(require("../BackgroundColorContext.js"));
51
-
52
- function _templateObject8() {
53
- var data = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n display: inline-block;\n\n .MuiFormControl-root {\n width: 100%;\n }\n\n .MuiFormHelperText-root {\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n margin-top: 6px;\n\n &.Mui-disabled {\n color: ", ";\n cursor: not-allowed;\n }\n }\n\n .MuiFormLabel-root {\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n margin-top: -3px;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n height: 22px;\n display: flex;\n align-items: center;\n\n &.Mui-disabled {\n color: ", ";\n }\n &.Mui-focused {\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n }\n }\n\n .MuiSelect-select.MuiSelect-select {\n padding-right: unset;\n }\n\n .MuiSelect-select {\n width: 100%;\n height: 20px;\n display: flex;\n padding-right: 10px;\n align-items: center;\n :focus {\n background-color: transparent;\n outline: ", "\n auto 1px;\n }\n & > *:last-child::after {\n content: unset;\n }\n & > *:last-child::before {\n content: unset;\n }\n &.Mui-disabled {\n color: ", ";\n cursor: not-allowed;\n &:focus {\n outline: none;\n }\n }\n }\n .MuiInputBase-input {\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n\n svg {\n color: ", ";\n }\n }\n .MuiInput-underline {\n &.Mui-focused {\n border-bottom-width: ", ";\n border-bottom-color: ", ";\n }\n &.Mui-disabled:before {\n border-bottom-style: solid;\n }\n }\n .MuiInput-underline:hover:not(.Mui-disabled):before {\n border-bottom: ", " solid;\n border-bottom-color: ", ";\n }\n .MuiInput-underline:after {\n border-bottom: ", " solid;\n border-bottom-color: ", ";\n }\n .MuiInput-underline:before {\n border-bottom: ", " solid;\n border-bottom-color: ", ";\n }\n .MuiSelect-icon {\n color: ", " !important;\n }\n & label {\n text-overflow: ellipsis;\n overflow: hidden;\n width: calc(100% - 24px);\n }\n"]);
54
-
55
- _templateObject8 = function _templateObject8() {
56
- return data;
57
- };
58
-
59
- return data;
60
- }
61
-
62
- function _templateObject7() {
63
- var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n width: ", ";\n height: ", ";\n margin-left: ", ";\n margin-right: ", ";\n overflow: hidden;\n opacity: ", ";\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"]);
64
-
65
- _templateObject7 = function _templateObject7() {
66
- return data;
67
- };
68
-
69
- return data;
70
- }
71
-
72
- function _templateObject6() {
73
- var data = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n margin-left: ", ";\n margin-right: ", ";\n"]);
74
-
75
- _templateObject6 = function _templateObject6() {
76
- return data;
77
- };
78
-
79
- return data;
80
- }
81
-
82
- function _templateObject5() {
83
- var data = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n display: flex;\n align-items: center;\n flex-direction: ", ";\n overflow: hidden;\n text-overflow: ellipsis;\n ", "\n"]);
84
-
85
- _templateObject5 = function _templateObject5() {
86
- return data;
87
- };
88
-
89
- return data;
90
- }
91
-
92
- function _templateObject4() {
93
- var data = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n margin-left: ", ";\n margin-right: ", ";\n overflow: hidden;\n text-overflow: ellipsis;\n"]);
94
-
95
- _templateObject4 = function _templateObject4() {
96
- return data;
97
- };
98
-
99
- return data;
100
- }
101
-
102
- function _templateObject3() {
103
- var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n justify-content: ", ";\n margin-right: ", ";\n overflow: hidden;\n text-overflow: ellipsis;\n width: ", ";\n\n &::before {\n margin: 0 4px;\n ", ";\n }\n &::after {\n margin: 0 4px;\n ", ";\n }\n"]);
104
-
105
- _templateObject3 = function _templateObject3() {
106
- return data;
107
- };
108
-
109
- return data;
110
- }
111
-
112
- function _templateObject2() {
113
- var data = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n color: ", ";\n"]);
114
-
115
- _templateObject2 = function _templateObject2() {
116
- return data;
117
- };
118
-
119
- return data;
120
- }
121
-
122
- function _templateObject() {
123
- var data = (0, _taggedTemplateLiteral2["default"])(["\n width: calc(100% - 24px);\n overflow: hidden;\n text-overflow: ellipsis;\n"]);
124
-
125
- _templateObject = function _templateObject() {
126
- return data;
127
- };
128
-
129
- return data;
130
- }
131
-
132
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
133
-
134
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
135
-
136
- var useStyles = (0, _styles.makeStyles)(function () {
137
- return {
138
- root: function root(props) {
139
- return {
140
- minWidth: props.width
141
- };
142
- },
143
- dropdownStyle: function dropdownStyle(props) {
144
- return {
145
- backgroundColor: props.optionBackgroundColor,
146
- boxShadow: "0px 2px 10px 0px rgba(0, 0, 0, 0.3)",
147
- minWidth: props.width,
148
- width: props.width,
149
- maxHeight: "250px",
150
- borderColor: props.optionBorderColor,
151
- borderWidth: props.optionBorderThickness,
152
- borderStyle: props.optionBorderStyle,
153
- "&::-webkit-scrollbar": {
154
- width: "3px",
155
- margin: "5px"
156
- },
157
- "&::-webkit-scrollbar-track": {
158
- borderRadius: "3px",
159
- backgroundColor: props.scrollBarTrackColor
160
- },
161
- "&::-webkit-scrollbar-thumb": {
162
- borderRadius: "3px",
163
- backgroundColor: props.scrollBarThumbColor
164
- },
165
- "& .MuiList-root": {
166
- width: "auto !important",
167
- paddingRight: "0 !important"
168
- }
169
- };
170
- },
171
- itemList: function itemList(props) {
172
- return {
173
- "&.MuiList-padding": {
174
- paddingBottom: "0px",
175
- paddingTop: "0px"
176
- },
177
- "& li": {
178
- fontSize: props.optionFontSize,
179
- fontStyle: props.optionFontStyle,
180
- fontWeight: props.optionFontWeight,
181
- paddingBottom: props.optionPaddingBottom,
182
- paddingTop: props.optionPaddingTop,
183
- "&:hover": {
184
- backgroundColor: "".concat(props.backgroundType === "dark" ? props.hoverOptionBackgroundColorOnDark : props.hoverOptionBackgroundColor, " !important"),
185
- color: "".concat(props.optionFontColor)
186
- },
187
- "&:active": {
188
- backgroundColor: "".concat(props.backgroundType === "dark" ? props.selectedOptionBackgroundColorOnDark : props.selectedOptionBackgroundColor) + "".concat(props.backgroundType === "dark" ? props.hoverOptionBackgroundColorOnDark : props.hoverOptionBackgroundColor)
189
- },
190
- "&:focus": {
191
- outline: "".concat(props.backgroundType === "dark" ? props.focusColorOnDark : props.focusColor, " auto 2px")
192
- },
193
- "&.MuiListItem-root.Mui-selected": {
194
- backgroundColor: "".concat(props.backgroundType === "dark" ? props.selectedOptionBackgroundColorOnDark : props.selectedOptionBackgroundColor, " !important")
195
- },
196
- "&.MuiListItem-root.Mui-focusVisible": {
197
- backgroundColor: "unset"
198
- },
199
- "& span.MuiButtonBase-root": {
200
- padding: "0px",
201
- margin: "5px 0px",
202
- "& span.MuiIconButton-label > svg": {
203
- width: "26px",
204
- height: "26px"
205
- },
206
- "&:hover": {
207
- color: "".concat(props.backgroundType === "dark" ? props.borderColorOnDark : props.borderColor)
208
- },
209
- "&.Mui-checked:hover": {
210
- color: "".concat(props.backgroundType === "dark" ? props.backgroundColorCheckedOnDark : props.backgroundColorChecked)
211
- }
212
- }
213
- }
214
- };
215
- }
216
- };
217
- });
218
-
219
- var DxcSelect = function DxcSelect(_ref) {
220
- var value = _ref.value,
221
- name = _ref.name,
222
- onChange = _ref.onChange,
223
- label = _ref.label,
224
- assistiveText = _ref.assistiveText,
225
- _ref$required = _ref.required,
226
- required = _ref$required === void 0 ? false : _ref$required,
227
- _ref$disabled = _ref.disabled,
228
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
229
- _ref$invalid = _ref.invalid,
230
- invalid = _ref$invalid === void 0 ? false : _ref$invalid,
231
- _ref$options = _ref.options,
232
- options = _ref$options === void 0 ? [] : _ref$options,
233
- _ref$iconPosition = _ref.iconPosition,
234
- iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
235
- _ref$multiple = _ref.multiple,
236
- multiple = _ref$multiple === void 0 ? false : _ref$multiple,
237
- margin = _ref.margin,
238
- _ref$size = _ref.size,
239
- size = _ref$size === void 0 ? "medium" : _ref$size,
240
- _ref$tabIndex = _ref.tabIndex,
241
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
242
- var colorsTheme = (0, _useTheme["default"])();
243
- var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
244
-
245
- var _useState = (0, _react.useState)(multiple && [] || ""),
246
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
247
- selectedValue = _useState2[0],
248
- setSelectedValue = _useState2[1];
249
-
250
- var selectValues = _objectSpread({
251
- width: "auto"
252
- }, colorsTheme.select, {}, colorsTheme.checkbox, {
253
- backgroundType: backgroundType
254
- });
255
-
256
- var classes = useStyles(selectValues);
257
-
258
- var handleSelectChange = function handleSelectChange(selectedOption) {
259
- if (multiple) {
260
- setSelectedValue(selectedOption.target.value);
261
-
262
- if (typeof onChange === "function") {
263
- onChange(selectedOption.target.value);
264
- }
265
- } else {
266
- setSelectedValue(selectedOption.target.value);
267
-
268
- if (typeof onChange === "function") {
269
- onChange(selectedOption.target.value);
270
- }
271
- }
272
- };
273
-
274
- var getLabelForSingleSelect = function getLabelForSingleSelect(selected) {
275
- var selectedItem = options.filter(function (option) {
276
- return option.value === selected;
277
- })[0];
278
- return _react["default"].createElement(SelectedIconContainer, {
279
- iconPosition: iconPosition,
280
- multiple: multiple,
281
- label: selectedItem && selectedItem.label,
282
- key: selectedItem && selectedItem.label
283
- }, selectedItem && selectedItem.icon ? _react["default"].createElement(ListIconContainer, {
284
- disabled: disabled
285
- }, (0, _typeof2["default"])(selectedItem.icon) === "object" ? selectedItem.icon : _react["default"].createElement(selectedItem.icon)) : selectedItem && selectedItem.iconSrc && _react["default"].createElement(ListIcon, {
286
- src: selectedItem && selectedItem.iconSrc
287
- }), selectedItem && selectedItem.label && _react["default"].createElement(SelectedLabelContainer, {
288
- iconSrc: selectedItem && selectedItem.iconSrc && selectedItem.icon,
289
- iconPosition: iconPosition,
290
- disabled: disabled
291
- }, selectedItem && selectedItem.label));
292
- };
293
-
294
- var getSelectedValuesWithLabel = function getSelectedValuesWithLabel(optionsList, selected) {
295
- return _react["default"].createElement(MultipleLabelSelected, null, optionsList.filter(function (x) {
296
- return selected.includes(x.value);
297
- }).map(function (optionToRender) {
298
- return optionToRender.label;
299
- }).join(", "));
300
- };
301
-
302
- var getSelectedValuesWithIcons = function getSelectedValuesWithIcons(optionsList, selected) {
303
- return options.filter(function (x) {
304
- return selected.includes(x.value);
305
- }).map(function (optionToRender) {
306
- return getLabelForSingleSelect(optionToRender.value);
307
- });
308
- };
309
-
310
- var labelForMultipleSelect = function labelForMultipleSelect(selected) {
311
- return options.findIndex(function (option) {
312
- return !option.label;
313
- }) !== -1 ? getSelectedValuesWithIcons(options, selected) : getSelectedValuesWithLabel(options, selected);
314
- };
315
-
316
- var getRenderValue = function getRenderValue(selected) {
317
- return multiple && labelForMultipleSelect(selected) || getLabelForSingleSelect(selected);
318
- };
319
-
320
- var isChecked = function isChecked(checkedValue, value, option) {
321
- if (value !== undefined) {
322
- var result = false;
323
- value.map(function (val) {
324
- if (val === option.value) {
325
- result = true;
326
- }
327
- });
328
- return result;
329
- } else if (checkedValue) {
330
- return checkedValue.findIndex(function (element) {
331
- return element === option.value;
332
- }) !== -1 || false;
333
- }
334
- };
335
-
336
- var ThemedOption = function ThemedOption(_ref2) {
337
- var option = _ref2.option;
338
- var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
339
- return _react["default"].createElement(_react["default"].Fragment, null, multiple && _react["default"].createElement(_Checkbox["default"], {
340
- size: "fitContent",
341
- checked: isChecked(selectedValue, value, option)
342
- }), _react["default"].createElement(OptionContainer, {
343
- iconPosition: iconPosition,
344
- multiple: multiple
345
- }, option.icon ? _react["default"].createElement(ListIconContainer, {
346
- backgroundType: backgroundType,
347
- label: option.label,
348
- iconPosition: iconPosition
349
- }, (0, _typeof2["default"])(option.icon) === "object" ? option.icon : _react["default"].createElement(option.icon)) : option.iconSrc && _react["default"].createElement(ListIcon, {
350
- src: option.iconSrc,
351
- label: option.label,
352
- iconPosition: iconPosition
353
- }), " ", _react["default"].createElement(LabelContainer, {
354
- backgroundType: backgroundType
355
- }, option.label)));
356
- };
357
-
358
- return _react["default"].createElement(_styledComponents.ThemeProvider, {
359
- theme: colorsTheme.select
360
- }, _react["default"].createElement(SelectContainer, {
361
- margin: margin,
362
- size: size,
363
- invalid: invalid,
364
- disabled: disabled,
365
- backgroundType: backgroundType
366
- }, _react["default"].createElement(_FormControl["default"], null, _react["default"].createElement(_InputLabel["default"], {
367
- disabled: disabled
368
- }, required && _react["default"].createElement(_RequiredComponent["default"], null), label), _react["default"].createElement(_Select["default"], {
369
- name: name,
370
- multiple: multiple,
371
- renderValue: getRenderValue,
372
- onChange: handleSelectChange,
373
- value: value !== undefined ? value : selectedValue,
374
- disabled: disabled,
375
- MenuProps: {
376
- classes: {
377
- paper: classes.dropdownStyle,
378
- list: classes.itemList
379
- },
380
- getContentAnchorEl: null,
381
- anchorOrigin: {
382
- vertical: "bottom",
383
- horizontal: "left"
384
- }
385
- },
386
- inputProps: {
387
- tabIndex: disabled ? -1 : tabIndex
388
- }
389
- }, options.map(function (option) {
390
- return _react["default"].createElement(_MenuItem["default"], {
391
- id: option.value,
392
- value: option.value,
393
- disableRipple: true,
394
- key: option.value
395
- }, _react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
396
- color: colorsTheme.select.optionBackgroundColor
397
- }, _react["default"].createElement(ThemedOption, {
398
- option: option
399
- })));
400
- })), assistiveText && _react["default"].createElement(_FormHelperText["default"], {
401
- disabled: disabled
402
- }, assistiveText))));
403
- };
404
-
405
- var sizes = {
406
- small: "60px",
407
- medium: "240px",
408
- large: "480px",
409
- fillParent: "100%"
410
- };
411
-
412
- var calculateWidth = function calculateWidth(margin, size) {
413
- if (size === "fillParent") {
414
- return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
415
- }
416
-
417
- return sizes[size];
418
- };
419
-
420
- var MultipleLabelSelected = _styledComponents["default"].div(_templateObject());
421
-
422
- var LabelContainer = _styledComponents["default"].span(_templateObject2(), function (props) {
423
- return props.backgroundType === "dark" ? props.theme.optionFontColorOnDark : props.theme.optionFontColor;
424
- });
425
-
426
- var SelectedIconContainer = _styledComponents["default"].div(_templateObject3(), function (props) {
427
- return props.iconPosition === "before" && "row" || "row-reverse";
428
- }, function (props) {
429
- return props.iconPosition === "before" && "flex-start" || "flex-end";
430
- }, function (props) {
431
- return props.multiple && props.label && "15px" || "0px";
432
- }, function (props) {
433
- return !props.multiple && "calc(100% - 24px)" || "auto";
434
- }, function (props) {
435
- return props.iconPosition === "after" && (props.label !== "" || props.label === undefined) && "content:','";
436
- }, function (props) {
437
- return props.iconPosition === "before" && (props.label !== "" || props.label === undefined) && "content:','";
438
- });
439
-
440
- var SelectedLabelContainer = _styledComponents["default"].span(_templateObject4(), function (props) {
441
- return props.theme.fontFamily;
442
- }, function (props) {
443
- return (props.iconPosition === "after" || !props.iconSrc) && "0px" || "10px";
444
- }, function (props) {
445
- return (props.iconPosition === "before" || !props.iconSrc) && "0px" || "10px";
446
- });
447
-
448
- var OptionContainer = _styledComponents["default"].div(_templateObject5(), function (props) {
449
- return props.theme.fontFamily;
450
- }, function (props) {
451
- return props.iconPosition === "before" && "row" || "row-reverse";
452
- }, function (props) {
453
- return props.multiple && "margin-left: ".concat(props.theme.optionCheckboxSpacing, ";");
454
- });
455
-
456
- var ListIcon = _styledComponents["default"].img(_templateObject6(), function (props) {
457
- return props.theme.iconSize;
458
- }, function (props) {
459
- return props.theme.iconSize;
460
- }, function (props) {
461
- return props.iconPosition === "after" && props.label !== "" && props.theme.optionIconSpacing || "0px";
462
- }, function (props) {
463
- return props.iconPosition === "before" && props.label !== "" && props.theme.optionIconSpacing || "0px";
464
- });
465
-
466
- var ListIconContainer = _styledComponents["default"].div(_templateObject7(), function (props) {
467
- return props.backgroundType === "dark" ? props.theme.optionIconColorOnDark : props.theme.optionIconColor;
468
- }, function (props) {
469
- return props.theme.optionIconSize;
470
- }, function (props) {
471
- return props.theme.optionIconSize;
472
- }, function (props) {
473
- return props.iconPosition === "after" && props.label !== "" && props.theme.optionIconSpacing || "0px";
474
- }, function (props) {
475
- return props.iconPosition === "before" && props.label !== "" && props.theme.optionIconSpacing || "0px";
476
- }, function (props) {
477
- return props.disabled && "0.34";
478
- });
479
-
480
- var SelectContainer = _styledComponents["default"].div(_templateObject8(), function (props) {
481
- return calculateWidth(props.margin, props.size);
482
- }, function (props) {
483
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
484
- }, function (props) {
485
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
486
- }, function (props) {
487
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
488
- }, function (props) {
489
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
490
- }, function (props) {
491
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
492
- }, function (props) {
493
- return props.theme.fontFamily;
494
- }, function (props) {
495
- return props.theme.assistiveTextFontSize;
496
- }, function (props) {
497
- return props.theme.assistiveTextFontStyle;
498
- }, function (props) {
499
- return props.theme.assistiveTextFontWeight;
500
- }, function (props) {
501
- return props.backgroundType === "dark" ? props.invalid === true ? props.theme.errorColorOnDark : props.theme.assistiveTextFontColorOnDark : props.invalid === true ? props.theme.errorColor : props.theme.assistiveTextFontColor;
502
- }, function (props) {
503
- return props.backgroundType === "dark" ? props.theme.disabledColorOnDark : props.theme.disabledColor;
504
- }, function (props) {
505
- return props.theme.fontFamily;
506
- }, function (props) {
507
- return props.theme.labelFontSize;
508
- }, function (props) {
509
- return props.theme.labelFontStyle;
510
- }, function (props) {
511
- return props.theme.labelFontWeight;
512
- }, function (props) {
513
- return props.backgroundType === "dark" ? props.invalid === true ? props.theme.errorColorOnDark : props.theme.labelFontColorOnDark : props.invalid === true ? props.theme.errorColor : props.theme.labelFontColor;
514
- }, function (props) {
515
- return props.backgroundType === "dark" ? props.theme.disabledColorOnDark : props.theme.disabledColor;
516
- }, function (props) {
517
- return props.theme.labelFontSize;
518
- }, function (props) {
519
- return props.theme.labelFontStyle;
520
- }, function (props) {
521
- return props.theme.labelFontWeight;
522
- }, function (props) {
523
- return props.backgroundType === "dark" ? props.invalid === true ? props.theme.errorColorOnDark : props.theme.labelFontColorOnDark : props.invalid === true ? props.theme.errorColor : props.theme.labelFontColor;
524
- }, function (props) {
525
- return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
526
- }, function (props) {
527
- return props.backgroundType === "dark" ? props.theme.disabledColorOnDark : props.theme.disabledColor;
528
- }, function (props) {
529
- return props.theme.valueFontSize;
530
- }, function (props) {
531
- return props.theme.valueFontStyle;
532
- }, function (props) {
533
- return props.theme.valueFontWeight;
534
- }, function (props) {
535
- return props.backgroundType === "dark" ? props.theme.valueFontColorOnDark : props.theme.valueFontColor;
536
- }, function (props) {
537
- return props.backgroundType === "dark" ? props.theme.optionIconColorOnDark : props.theme.optionIconColor;
538
- }, function (props) {
539
- return props.theme.underlineThickness;
540
- }, function (props) {
541
- return props.backgroundType === "dark" ? props.invalid === true && props.theme.errorColorOnDark || props.disabled && props.theme.disabledColorOnDark || props.theme.underlineFocusColorOnDark : props.invalid === true && props.theme.errorColor || props.disabled && props.theme.disabledColor || props.theme.underlineFocusColor;
542
- }, function (props) {
543
- return props.theme.underlineThickness;
544
- }, function (props) {
545
- return props.backgroundType === "dark" ? props.invalid === true && props.theme.errorColorOnDark || props.disabled && props.theme.disabledColorOnDark || props.theme.underlineColorOnDark : props.invalid === true && props.theme.errorColor || props.disabled && props.theme.disabledColor || props.theme.underlineColor;
546
- }, function (props) {
547
- return props.theme.underlineThickness;
548
- }, function (props) {
549
- return props.backgroundType === "dark" ? props.invalid === true ? props.theme.errorColorOnDark : props.theme.underlineFocusColorOnDark : props.invalid === true ? props.theme.errorColor : props.theme.underlineFocusColor;
550
- }, function (props) {
551
- return props.theme.underlineThickness;
552
- }, function (props) {
553
- return props.backgroundType === "dark" ? props.invalid === true && props.theme.errorColorOnDark || props.disabled && props.theme.disabledColorOnDark || props.theme.underlineColorOnDark : props.invalid === true && props.theme.errorColor || props.disabled && props.theme.disabledColor || props.theme.underlineColor;
554
- }, function (props) {
555
- return props.backgroundType === "dark" ? props.disabled && props.theme.disabledColorOnDark || props.theme.arrowColorOnDark : props.disabled && props.theme.disabledColor || props.theme.arrowColor;
556
- });
557
-
558
- DxcSelect.propTypes = {
559
- size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
560
- label: _propTypes["default"].string,
561
- assistiveText: _propTypes["default"].string,
562
- name: _propTypes["default"].string,
563
- value: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number, _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]))]),
564
- disabled: _propTypes["default"].bool,
565
- required: _propTypes["default"].bool,
566
- invalid: _propTypes["default"].bool,
567
- iconPosition: _propTypes["default"].oneOf(["after", "before"]),
568
- onChange: _propTypes["default"].func,
569
- options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
570
- value: _propTypes["default"].any.isRequired,
571
- label: _propTypes["default"].string,
572
- icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
573
- iconSrc: _propTypes["default"].string
574
- })),
575
- multiple: _propTypes["default"].bool,
576
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
577
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
578
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
579
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
580
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
581
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
582
- tabIndex: _propTypes["default"].number
583
- };
584
- var _default = DxcSelect;
585
- exports["default"] = _default;