@dxc-technology/halstack-react 0.0.0-d1e7d83 → 0.0.0-d238e47

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 (381) hide show
  1. package/BackgroundColorContext.js +50 -0
  2. package/ThemeContext.js +246 -0
  3. package/V3Select/V3Select.js +455 -0
  4. package/V3Select/index.d.ts +27 -0
  5. package/V3Textarea/V3Textarea.js +260 -0
  6. package/V3Textarea/index.d.ts +27 -0
  7. package/accordion/Accordion.d.ts +4 -0
  8. package/accordion/Accordion.js +258 -0
  9. package/accordion/types.d.ts +68 -0
  10. package/accordion/types.js +5 -0
  11. package/accordion-group/AccordionGroup.d.ts +7 -0
  12. package/accordion-group/AccordionGroup.js +170 -0
  13. package/accordion-group/types.d.ts +72 -0
  14. package/accordion-group/types.js +5 -0
  15. package/alert/Alert.d.ts +4 -0
  16. package/alert/Alert.js +290 -0
  17. package/alert/Alert.stories.tsx +170 -0
  18. package/alert/types.d.ts +49 -0
  19. package/alert/types.js +5 -0
  20. package/badge/Badge.js +59 -0
  21. package/box/Box.d.ts +4 -0
  22. package/box/Box.js +126 -0
  23. package/box/Box.stories.tsx +132 -0
  24. package/box/types.d.ts +43 -0
  25. package/box/types.js +5 -0
  26. package/button/Button.d.ts +4 -0
  27. package/button/Button.js +179 -0
  28. package/button/Button.stories.tsx +276 -0
  29. package/button/types.d.ts +57 -0
  30. package/button/types.js +5 -0
  31. package/card/Card.d.ts +4 -0
  32. package/card/Card.js +164 -0
  33. package/card/Card.stories.tsx +201 -0
  34. package/card/ice-cream.jpg +0 -0
  35. package/card/types.d.ts +67 -0
  36. package/card/types.js +5 -0
  37. package/checkbox/Checkbox.d.ts +4 -0
  38. package/checkbox/Checkbox.js +253 -0
  39. package/checkbox/Checkbox.stories.tsx +192 -0
  40. package/checkbox/types.d.ts +60 -0
  41. package/checkbox/types.js +5 -0
  42. package/chip/Chip.js +221 -0
  43. package/chip/Chip.stories.tsx +121 -0
  44. package/chip/index.d.ts +22 -0
  45. package/{dist/common → common}/OpenSans.css +0 -0
  46. package/{dist/common → common}/RequiredComponent.js +5 -19
  47. package/{dist/common → common}/fonts/OpenSans-Bold.ttf +0 -0
  48. package/{dist/common → common}/fonts/OpenSans-BoldItalic.ttf +0 -0
  49. package/{dist/common → common}/fonts/OpenSans-ExtraBold.ttf +0 -0
  50. package/{dist/common → common}/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  51. package/{dist/common → common}/fonts/OpenSans-Italic.ttf +0 -0
  52. package/{dist/common → common}/fonts/OpenSans-Light.ttf +0 -0
  53. package/{dist/common → common}/fonts/OpenSans-LightItalic.ttf +0 -0
  54. package/{dist/common → common}/fonts/OpenSans-Regular.ttf +0 -0
  55. package/{dist/common → common}/fonts/OpenSans-SemiBold.ttf +0 -0
  56. package/{dist/common → common}/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  57. package/common/utils.js +22 -0
  58. package/common/variables.js +1577 -0
  59. package/{dist/date → date}/Date.js +87 -70
  60. package/date/index.d.ts +27 -0
  61. package/date-input/DateInput.d.ts +4 -0
  62. package/date-input/DateInput.js +361 -0
  63. package/date-input/DateInput.stories.tsx +138 -0
  64. package/date-input/types.d.ts +100 -0
  65. package/date-input/types.js +5 -0
  66. package/dialog/Dialog.d.ts +4 -0
  67. package/dialog/Dialog.js +165 -0
  68. package/dialog/Dialog.stories.tsx +212 -0
  69. package/dialog/types.d.ts +43 -0
  70. package/dialog/types.js +5 -0
  71. package/dropdown/Dropdown.d.ts +4 -0
  72. package/dropdown/Dropdown.js +417 -0
  73. package/dropdown/types.d.ts +89 -0
  74. package/dropdown/types.js +5 -0
  75. package/file-input/FileInput.d.ts +4 -0
  76. package/file-input/FileInput.js +511 -0
  77. package/file-input/FileItem.d.ts +14 -0
  78. package/file-input/FileItem.js +182 -0
  79. package/file-input/types.d.ts +87 -0
  80. package/file-input/types.js +5 -0
  81. package/footer/Footer.d.ts +4 -0
  82. package/footer/Footer.js +266 -0
  83. package/footer/Footer.stories.jsx +151 -0
  84. package/footer/Icons.js +77 -0
  85. package/footer/types.d.ts +61 -0
  86. package/footer/types.js +5 -0
  87. package/header/Header.d.ts +7 -0
  88. package/header/Header.js +324 -0
  89. package/header/Header.stories.tsx +162 -0
  90. package/header/Icons.js +34 -0
  91. package/header/types.d.ts +47 -0
  92. package/header/types.js +5 -0
  93. package/heading/Heading.d.ts +4 -0
  94. package/heading/Heading.js +159 -0
  95. package/heading/Heading.stories.tsx +53 -0
  96. package/heading/types.d.ts +33 -0
  97. package/heading/types.js +5 -0
  98. package/input-text/Icons.js +22 -0
  99. package/input-text/InputText.js +611 -0
  100. package/input-text/index.d.ts +36 -0
  101. package/{dist/layout → layout}/ApplicationLayout.js +43 -142
  102. package/layout/Icons.js +55 -0
  103. package/link/Link.d.ts +3 -0
  104. package/link/Link.js +161 -0
  105. package/link/Link.stories.tsx +146 -0
  106. package/link/types.d.ts +74 -0
  107. package/link/types.js +5 -0
  108. package/main.d.ts +44 -0
  109. package/{dist/main.js → main.js} +137 -53
  110. package/number-input/NumberInput.d.ts +4 -0
  111. package/number-input/NumberInput.js +86 -0
  112. package/number-input/NumberInput.stories.tsx +115 -0
  113. package/number-input/NumberInputContext.d.ts +4 -0
  114. package/{dist/ThemeContext.js → number-input/NumberInputContext.js} +6 -2
  115. package/number-input/numberInputContextTypes.d.ts +19 -0
  116. package/number-input/numberInputContextTypes.js +5 -0
  117. package/number-input/types.d.ts +117 -0
  118. package/number-input/types.js +5 -0
  119. package/package.json +37 -23
  120. package/paginator/Icons.js +66 -0
  121. package/paginator/Paginator.d.ts +4 -0
  122. package/paginator/Paginator.js +198 -0
  123. package/paginator/Paginator.stories.tsx +63 -0
  124. package/paginator/types.d.ts +38 -0
  125. package/paginator/types.js +5 -0
  126. package/password-input/PasswordInput.d.ts +4 -0
  127. package/password-input/PasswordInput.js +162 -0
  128. package/password-input/PasswordInput.stories.tsx +131 -0
  129. package/password-input/types.d.ts +105 -0
  130. package/password-input/types.js +5 -0
  131. package/progress-bar/ProgressBar.d.ts +4 -0
  132. package/progress-bar/ProgressBar.js +170 -0
  133. package/progress-bar/ProgressBar.stories.jsx +58 -0
  134. package/progress-bar/types.d.ts +37 -0
  135. package/progress-bar/types.js +5 -0
  136. package/radio/Radio.d.ts +4 -0
  137. package/radio/Radio.js +174 -0
  138. package/radio/Radio.stories.tsx +192 -0
  139. package/radio/types.d.ts +54 -0
  140. package/radio/types.js +5 -0
  141. package/resultsetTable/ResultsetTable.d.ts +4 -0
  142. package/resultsetTable/ResultsetTable.js +249 -0
  143. package/resultsetTable/types.d.ts +63 -0
  144. package/resultsetTable/types.js +5 -0
  145. package/select/Select.js +865 -0
  146. package/select/Select.stories.tsx +572 -0
  147. package/select/index.d.ts +131 -0
  148. package/sidenav/Sidenav.d.ts +9 -0
  149. package/sidenav/Sidenav.js +136 -0
  150. package/sidenav/Sidenav.stories.tsx +165 -0
  151. package/sidenav/types.d.ts +50 -0
  152. package/sidenav/types.js +5 -0
  153. package/slider/Slider.d.ts +4 -0
  154. package/slider/Slider.js +317 -0
  155. package/slider/Slider.stories.tsx +177 -0
  156. package/slider/types.d.ts +78 -0
  157. package/slider/types.js +5 -0
  158. package/spinner/Spinner.d.ts +4 -0
  159. package/spinner/Spinner.js +250 -0
  160. package/spinner/Spinner.stories.jsx +102 -0
  161. package/spinner/types.d.ts +32 -0
  162. package/spinner/types.js +5 -0
  163. package/switch/Switch.d.ts +4 -0
  164. package/switch/Switch.js +179 -0
  165. package/switch/Switch.stories.tsx +160 -0
  166. package/switch/types.d.ts +58 -0
  167. package/switch/types.js +5 -0
  168. package/table/Table.d.ts +4 -0
  169. package/table/Table.js +118 -0
  170. package/table/Table.stories.jsx +276 -0
  171. package/table/types.d.ts +21 -0
  172. package/table/types.js +5 -0
  173. package/tabs/Tabs.d.ts +4 -0
  174. package/tabs/Tabs.js +213 -0
  175. package/tabs/types.d.ts +70 -0
  176. package/tabs/types.js +5 -0
  177. package/tag/Tag.d.ts +4 -0
  178. package/tag/Tag.js +193 -0
  179. package/tag/Tag.stories.tsx +145 -0
  180. package/tag/types.d.ts +60 -0
  181. package/tag/types.js +5 -0
  182. package/text-input/TextInput.d.ts +4 -0
  183. package/text-input/TextInput.js +785 -0
  184. package/text-input/types.d.ts +157 -0
  185. package/text-input/types.js +5 -0
  186. package/textarea/Textarea.js +317 -0
  187. package/textarea/Textarea.stories.jsx +135 -0
  188. package/textarea/index.d.ts +117 -0
  189. package/{dist/toggle → toggle}/Toggle.js +30 -67
  190. package/toggle/index.d.ts +21 -0
  191. package/toggle-group/ToggleGroup.js +243 -0
  192. package/toggle-group/ToggleGroup.stories.tsx +178 -0
  193. package/toggle-group/index.d.ts +21 -0
  194. package/{dist/upload → upload}/Upload.js +23 -22
  195. package/upload/buttons-upload/ButtonsUpload.js +111 -0
  196. package/upload/buttons-upload/Icons.js +40 -0
  197. package/upload/dragAndDropArea/DragAndDropArea.js +225 -0
  198. package/upload/dragAndDropArea/Icons.js +39 -0
  199. package/upload/file-upload/FileToUpload.js +115 -0
  200. package/upload/file-upload/Icons.js +66 -0
  201. package/upload/files-upload/FilesToUpload.js +109 -0
  202. package/upload/index.d.ts +15 -0
  203. package/upload/transaction/Icons.js +160 -0
  204. package/upload/transaction/Transaction.js +104 -0
  205. package/upload/transactions/Transactions.js +94 -0
  206. package/useTheme.js +22 -0
  207. package/wizard/Icons.js +65 -0
  208. package/wizard/Wizard.d.ts +4 -0
  209. package/wizard/Wizard.js +231 -0
  210. package/wizard/Wizard.stories.jsx +224 -0
  211. package/wizard/types.d.ts +64 -0
  212. package/wizard/types.js +5 -0
  213. package/README.md +0 -66
  214. package/babel.config.js +0 -4
  215. package/dist/accordion/Accordion.js +0 -248
  216. package/dist/accordion/Accordion.stories.js +0 -207
  217. package/dist/accordion/readme.md +0 -96
  218. package/dist/alert/Alert.js +0 -304
  219. package/dist/alert/Alert.stories.js +0 -158
  220. package/dist/alert/close.svg +0 -4
  221. package/dist/alert/error.svg +0 -4
  222. package/dist/alert/info.svg +0 -4
  223. package/dist/alert/readme.md +0 -43
  224. package/dist/alert/success.svg +0 -4
  225. package/dist/alert/warning.svg +0 -4
  226. package/dist/box/Box.js +0 -148
  227. package/dist/button/Button.js +0 -181
  228. package/dist/button/Button.stories.js +0 -224
  229. package/dist/button/readme.md +0 -93
  230. package/dist/card/Card.js +0 -217
  231. package/dist/checkbox/Checkbox.js +0 -240
  232. package/dist/checkbox/Checkbox.stories.js +0 -144
  233. package/dist/checkbox/readme.md +0 -116
  234. package/dist/chip/Chip.js +0 -173
  235. package/dist/common/services/example-service.js +0 -10
  236. package/dist/common/services/example-service.test.js +0 -12
  237. package/dist/common/utils.js +0 -42
  238. package/dist/common/variables.js +0 -434
  239. package/dist/date/Date.stories.js +0 -205
  240. package/dist/date/calendar.svg +0 -1
  241. package/dist/date/calendar_dark.svg +0 -1
  242. package/dist/date/readme.md +0 -73
  243. package/dist/dialog/Dialog.js +0 -197
  244. package/dist/dialog/Dialog.stories.js +0 -217
  245. package/dist/dialog/readme.md +0 -32
  246. package/dist/dropdown/Dropdown.js +0 -416
  247. package/dist/dropdown/Dropdown.stories.js +0 -249
  248. package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
  249. package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
  250. package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
  251. package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
  252. package/dist/dropdown/readme.md +0 -69
  253. package/dist/footer/Footer.js +0 -346
  254. package/dist/footer/Footer.stories.js +0 -94
  255. package/dist/footer/dxc_logo_wht.png +0 -0
  256. package/dist/footer/readme.md +0 -41
  257. package/dist/header/Header.js +0 -360
  258. package/dist/header/Header.stories.js +0 -176
  259. package/dist/header/close_icon.svg +0 -1
  260. package/dist/header/dxc_logo_black.png +0 -0
  261. package/dist/header/dxc_logo_blk_rgb.svg +0 -6
  262. package/dist/header/dxc_logo_white.png +0 -0
  263. package/dist/header/hamb_menu_black.svg +0 -1
  264. package/dist/header/hamb_menu_white.svg +0 -1
  265. package/dist/header/readme.md +0 -33
  266. package/dist/heading/Heading.js +0 -153
  267. package/dist/input-text/InputText.js +0 -519
  268. package/dist/input-text/InputText.stories.js +0 -209
  269. package/dist/input-text/error.svg +0 -1
  270. package/dist/input-text/readme.md +0 -91
  271. package/dist/layout/facebook.svg +0 -45
  272. package/dist/layout/linkedin.svg +0 -50
  273. package/dist/layout/twitter.svg +0 -53
  274. package/dist/link/Link.js +0 -171
  275. package/dist/link/readme.md +0 -51
  276. package/dist/paginator/Paginator.js +0 -196
  277. package/dist/paginator/images/next.svg +0 -3
  278. package/dist/paginator/images/nextPage.svg +0 -3
  279. package/dist/paginator/images/previous.svg +0 -3
  280. package/dist/paginator/images/previousPage.svg +0 -3
  281. package/dist/paginator/readme.md +0 -50
  282. package/dist/progress-bar/ProgressBar.js +0 -185
  283. package/dist/progress-bar/ProgressBar.stories.js +0 -280
  284. package/dist/progress-bar/readme.md +0 -63
  285. package/dist/radio/Radio.js +0 -195
  286. package/dist/radio/Radio.stories.js +0 -166
  287. package/dist/radio/readme.md +0 -70
  288. package/dist/resultsetTable/ResultsetTable.js +0 -333
  289. package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
  290. package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
  291. package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
  292. package/dist/select/Select.js +0 -453
  293. package/dist/select/Select.stories.js +0 -235
  294. package/dist/select/readme.md +0 -72
  295. package/dist/sidenav/Sidenav.js +0 -69
  296. package/dist/slider/Slider.js +0 -266
  297. package/dist/slider/Slider.stories.js +0 -241
  298. package/dist/slider/readme.md +0 -64
  299. package/dist/spinner/Spinner.js +0 -193
  300. package/dist/spinner/Spinner.stories.js +0 -183
  301. package/dist/spinner/readme.md +0 -65
  302. package/dist/switch/Switch.js +0 -199
  303. package/dist/switch/Switch.stories.js +0 -134
  304. package/dist/switch/readme.md +0 -133
  305. package/dist/table/Table.js +0 -105
  306. package/dist/tabs/Tabs.js +0 -172
  307. package/dist/tabs/Tabs.stories.js +0 -130
  308. package/dist/tabs/readme.md +0 -78
  309. package/dist/tabs-for-sections/TabsForSections.js +0 -92
  310. package/dist/tabs-for-sections/readme.md +0 -78
  311. package/dist/tag/Tag.js +0 -234
  312. package/dist/textarea/Textarea.js +0 -227
  313. package/dist/toggle/Toggle.stories.js +0 -297
  314. package/dist/toggle/readme.md +0 -80
  315. package/dist/toggle-group/ToggleGroup.js +0 -214
  316. package/dist/toggle-group/readme.md +0 -82
  317. package/dist/upload/Upload.stories.js +0 -72
  318. package/dist/upload/buttons-upload/ButtonsUpload.js +0 -122
  319. package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
  320. package/dist/upload/buttons-upload/upload-button.svg +0 -1
  321. package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -279
  322. package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
  323. package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
  324. package/dist/upload/file-upload/FileToUpload.js +0 -158
  325. package/dist/upload/file-upload/audio-icon.svg +0 -4
  326. package/dist/upload/file-upload/close.svg +0 -4
  327. package/dist/upload/file-upload/file-icon.svg +0 -4
  328. package/dist/upload/file-upload/video-icon.svg +0 -4
  329. package/dist/upload/files-upload/FilesToUpload.js +0 -123
  330. package/dist/upload/readme.md +0 -37
  331. package/dist/upload/transaction/Transaction.js +0 -155
  332. package/dist/upload/transaction/audio-icon-err.svg +0 -4
  333. package/dist/upload/transaction/audio-icon.svg +0 -4
  334. package/dist/upload/transaction/error-icon.svg +0 -4
  335. package/dist/upload/transaction/file-icon-err.svg +0 -4
  336. package/dist/upload/transaction/file-icon.svg +0 -4
  337. package/dist/upload/transaction/image-icon-err.svg +0 -4
  338. package/dist/upload/transaction/image-icon.svg +0 -4
  339. package/dist/upload/transaction/success-icon.svg +0 -4
  340. package/dist/upload/transaction/video-icon-err.svg +0 -4
  341. package/dist/upload/transaction/video-icon.svg +0 -4
  342. package/dist/upload/transactions/Transactions.js +0 -120
  343. package/dist/wizard/Wizard.js +0 -327
  344. package/dist/wizard/invalid_icon.svg +0 -6
  345. package/dist/wizard/valid_icon.svg +0 -6
  346. package/dist/wizard/validation-wrong.svg +0 -6
  347. package/test/Accordion.test.js +0 -33
  348. package/test/Alert.test.js +0 -53
  349. package/test/Box.test.js +0 -10
  350. package/test/Button.test.js +0 -18
  351. package/test/Card.test.js +0 -30
  352. package/test/Checkbox.test.js +0 -45
  353. package/test/Chip.test.js +0 -25
  354. package/test/Date.test.js +0 -393
  355. package/test/Dialog.test.js +0 -23
  356. package/test/Dropdown.test.js +0 -130
  357. package/test/Footer.test.js +0 -99
  358. package/test/Header.test.js +0 -39
  359. package/test/Heading.test.js +0 -35
  360. package/test/InputText.test.js +0 -236
  361. package/test/Link.test.js +0 -33
  362. package/test/Paginator.test.js +0 -165
  363. package/test/ProgressBar.test.js +0 -35
  364. package/test/Radio.test.js +0 -37
  365. package/test/ResultsetTable.test.js +0 -282
  366. package/test/Select.test.js +0 -191
  367. package/test/Sidenav.test.js +0 -19
  368. package/test/Slider.test.js +0 -82
  369. package/test/Spinner.test.js +0 -27
  370. package/test/Switch.test.js +0 -45
  371. package/test/Table.test.js +0 -36
  372. package/test/Tabs.test.js +0 -88
  373. package/test/TabsForSections.test.js +0 -34
  374. package/test/Tag.test.js +0 -32
  375. package/test/TextArea.test.js +0 -52
  376. package/test/Toggle.test.js +0 -43
  377. package/test/ToggleGroup.test.js +0 -81
  378. package/test/Upload.test.js +0 -60
  379. package/test/Wizard.test.js +0 -130
  380. package/test/mocks/pngMock.js +0 -1
  381. package/test/mocks/svgMock.js +0 -1
@@ -0,0 +1,511 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
+
14
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
+
16
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
17
+
18
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
19
+
20
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
21
+
22
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
23
+
24
+ var _react = _interopRequireWildcard(require("react"));
25
+
26
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
27
+
28
+ var _uuid = require("uuid");
29
+
30
+ var _variables = require("../common/variables.js");
31
+
32
+ var _useTheme = _interopRequireDefault(require("../useTheme.js"));
33
+
34
+ var _Button = _interopRequireDefault(require("../button/Button"));
35
+
36
+ var _FileItem = _interopRequireDefault(require("./FileItem"));
37
+
38
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
39
+
40
+ 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); }
41
+
42
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
43
+
44
+ var audioIcon = /*#__PURE__*/_react["default"].createElement("svg", {
45
+ xmlns: "http://www.w3.org/2000/svg",
46
+ width: "24",
47
+ height: "24",
48
+ viewBox: "0 0 24 24",
49
+ fill: "currentColor"
50
+ }, /*#__PURE__*/_react["default"].createElement("path", {
51
+ fill: "none",
52
+ d: "M0 0h24v24H0V0z"
53
+ }), /*#__PURE__*/_react["default"].createElement("path", {
54
+ d: "M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14zM8 15c0-1.66 1.34-3 3-3 .35 0 .69.07 1 .18V6h5v2h-3v7.03c-.02 1.64-1.35 2.97-3 2.97-1.66 0-3-1.34-3-3z"
55
+ }));
56
+
57
+ var videoIcon = /*#__PURE__*/_react["default"].createElement("svg", {
58
+ xmlns: "http://www.w3.org/2000/svg",
59
+ width: "24",
60
+ height: "24",
61
+ viewBox: "0 0 24 24",
62
+ fill: "currentColor"
63
+ }, /*#__PURE__*/_react["default"].createElement("path", {
64
+ d: "M18 4l2 4h-3l-2-4h-2l2 4h-3l-2-4H8l2 4H7L5 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4h-4z"
65
+ }), /*#__PURE__*/_react["default"].createElement("path", {
66
+ d: "M0 0h24v24H0z",
67
+ fill: "none"
68
+ }));
69
+
70
+ var fileIcon = /*#__PURE__*/_react["default"].createElement("svg", {
71
+ xmlns: "http://www.w3.org/2000/svg",
72
+ width: "24",
73
+ height: "24",
74
+ viewBox: "0 0 24 24",
75
+ fill: "currentColor"
76
+ }, /*#__PURE__*/_react["default"].createElement("path", {
77
+ fill: "none",
78
+ d: "M0 0h24v24H0V0z"
79
+ }), /*#__PURE__*/_react["default"].createElement("path", {
80
+ d: "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z"
81
+ }));
82
+
83
+ var DxcFileInput = function DxcFileInput(_ref) {
84
+ var _ref$name = _ref.name,
85
+ name = _ref$name === void 0 ? "" : _ref$name,
86
+ _ref$mode = _ref.mode,
87
+ mode = _ref$mode === void 0 ? "file" : _ref$mode,
88
+ _ref$label = _ref.label,
89
+ label = _ref$label === void 0 ? "" : _ref$label,
90
+ _ref$helperText = _ref.helperText,
91
+ helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
92
+ accept = _ref.accept,
93
+ minSize = _ref.minSize,
94
+ maxSize = _ref.maxSize,
95
+ _ref$showPreview = _ref.showPreview,
96
+ showPreview = _ref$showPreview === void 0 ? false : _ref$showPreview,
97
+ _ref$multiple = _ref.multiple,
98
+ multiple = _ref$multiple === void 0 ? true : _ref$multiple,
99
+ _ref$disabled = _ref.disabled,
100
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
101
+ callbackFile = _ref.callbackFile,
102
+ value = _ref.value,
103
+ margin = _ref.margin,
104
+ _ref$tabIndex = _ref.tabIndex,
105
+ tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
106
+
107
+ var _useState = (0, _react.useState)(false),
108
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
109
+ isDragging = _useState2[0],
110
+ setIsDragging = _useState2[1];
111
+
112
+ var _useState3 = (0, _react.useState)([]),
113
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
114
+ files = _useState4[0],
115
+ setFiles = _useState4[1];
116
+
117
+ var _useState5 = (0, _react.useState)("file-input-".concat((0, _uuid.v4)())),
118
+ _useState6 = (0, _slicedToArray2["default"])(_useState5, 1),
119
+ fileInputId = _useState6[0];
120
+
121
+ var colorsTheme = (0, _useTheme["default"])();
122
+ (0, _react.useEffect)(function () {
123
+ if (value) {
124
+ setFiles(value);
125
+ } else {
126
+ setFiles([]);
127
+ }
128
+ }, [value]);
129
+
130
+ var handleClick = function handleClick() {
131
+ document.getElementById(fileInputId).click();
132
+ };
133
+
134
+ var checkFileSize = function checkFileSize(file) {
135
+ if (file.size < minSize) {
136
+ return "File size must be greater than min size.";
137
+ }
138
+
139
+ if (file.size > maxSize) {
140
+ return "File size must be less than max size.";
141
+ }
142
+ };
143
+
144
+ var getFilePreview = function getFilePreview(file) {
145
+ if (file.type.includes("video")) {
146
+ return videoIcon;
147
+ }
148
+
149
+ if (file.type.includes("audio")) {
150
+ return audioIcon;
151
+ }
152
+
153
+ if (file.type.includes("image")) {
154
+ return new Promise(function (resolve) {
155
+ var reader = new FileReader();
156
+ reader.readAsDataURL(file);
157
+
158
+ reader.onload = function (e) {
159
+ resolve(e.target.result);
160
+ };
161
+ });
162
+ }
163
+
164
+ return fileIcon;
165
+ };
166
+
167
+ var getFilesToAdd = /*#__PURE__*/function () {
168
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(selectedFiles) {
169
+ var filesToAdd;
170
+ return _regenerator["default"].wrap(function _callee$(_context) {
171
+ while (1) {
172
+ switch (_context.prev = _context.next) {
173
+ case 0:
174
+ _context.next = 2;
175
+ return Promise.all(selectedFiles.map(function (selectedFile) {
176
+ return getFilePreview(selectedFile);
177
+ })).then(function (previews) {
178
+ return selectedFiles.map(function (selectedFile, index) {
179
+ var fileInfo = {
180
+ file: selectedFile,
181
+ error: checkFileSize(selectedFile),
182
+ preview: previews[index]
183
+ };
184
+ return fileInfo;
185
+ });
186
+ });
187
+
188
+ case 2:
189
+ filesToAdd = _context.sent;
190
+ return _context.abrupt("return", filesToAdd);
191
+
192
+ case 4:
193
+ case "end":
194
+ return _context.stop();
195
+ }
196
+ }
197
+ }, _callee);
198
+ }));
199
+
200
+ return function getFilesToAdd(_x) {
201
+ return _ref2.apply(this, arguments);
202
+ };
203
+ }();
204
+
205
+ var addFile = /*#__PURE__*/function () {
206
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(selectedFiles) {
207
+ var filesToAdd, finalFiles, fileToAdd;
208
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
209
+ while (1) {
210
+ switch (_context2.prev = _context2.next) {
211
+ case 0:
212
+ if (!multiple) {
213
+ _context2.next = 8;
214
+ break;
215
+ }
216
+
217
+ _context2.next = 3;
218
+ return getFilesToAdd(selectedFiles);
219
+
220
+ case 3:
221
+ filesToAdd = _context2.sent;
222
+ finalFiles = [].concat((0, _toConsumableArray2["default"])(files), (0, _toConsumableArray2["default"])(filesToAdd));
223
+
224
+ if (typeof callbackFile === "function") {
225
+ callbackFile(finalFiles);
226
+ }
227
+
228
+ _context2.next = 19;
229
+ break;
230
+
231
+ case 8:
232
+ if (!(selectedFiles.length === 1)) {
233
+ _context2.next = 14;
234
+ break;
235
+ }
236
+
237
+ _context2.next = 11;
238
+ return getFilesToAdd(selectedFiles);
239
+
240
+ case 11:
241
+ _context2.t0 = _context2.sent;
242
+ _context2.next = 17;
243
+ break;
244
+
245
+ case 14:
246
+ _context2.next = 16;
247
+ return getFilesToAdd([selectedFiles[0]]);
248
+
249
+ case 16:
250
+ _context2.t0 = _context2.sent;
251
+
252
+ case 17:
253
+ fileToAdd = _context2.t0;
254
+
255
+ if (typeof callbackFile === "function") {
256
+ callbackFile(fileToAdd);
257
+ }
258
+
259
+ case 19:
260
+ case "end":
261
+ return _context2.stop();
262
+ }
263
+ }
264
+ }, _callee2);
265
+ }));
266
+
267
+ return function addFile(_x2) {
268
+ return _ref3.apply(this, arguments);
269
+ };
270
+ }();
271
+
272
+ var selectFiles = function selectFiles(e) {
273
+ var selectedFiles = e.target.files;
274
+ var filesArray = Object.keys(selectedFiles).map(function (key) {
275
+ return selectedFiles[key];
276
+ });
277
+ addFile(filesArray);
278
+ };
279
+
280
+ var onDelete = function onDelete(fileName) {
281
+ var filesCopy = (0, _toConsumableArray2["default"])(files);
282
+ var fileToRemove = filesCopy.find(function (file) {
283
+ return file.file.name === fileName;
284
+ });
285
+ var fileIndex = filesCopy.indexOf(fileToRemove);
286
+ filesCopy.splice(fileIndex, 1);
287
+
288
+ if (typeof callbackFile === "function") {
289
+ callbackFile(filesCopy);
290
+ }
291
+ };
292
+
293
+ var handleDrag = function handleDrag(e) {
294
+ e.preventDefault();
295
+ e.stopPropagation();
296
+ };
297
+
298
+ var handleDragIn = function handleDragIn(e) {
299
+ e.preventDefault();
300
+ e.stopPropagation();
301
+
302
+ if (e.dataTransfer.items && e.dataTransfer.items.length > 0) {
303
+ setIsDragging(true);
304
+ }
305
+ };
306
+
307
+ var handleDragOut = function handleDragOut(e) {
308
+ e.preventDefault();
309
+ e.stopPropagation();
310
+ setIsDragging(false);
311
+ };
312
+
313
+ var handleDrop = function handleDrop(e) {
314
+ e.preventDefault();
315
+ e.stopPropagation();
316
+ setIsDragging(false);
317
+ var filesObject = e.dataTransfer.files;
318
+
319
+ if (filesObject && filesObject.length > 0) {
320
+ var filesArray = Object.keys(filesObject).map(function (key) {
321
+ return filesObject[key];
322
+ });
323
+ addFile(filesArray);
324
+ }
325
+ };
326
+
327
+ return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
328
+ theme: colorsTheme.fileInput
329
+ }, /*#__PURE__*/_react["default"].createElement(FileInputContainer, {
330
+ margin: margin,
331
+ name: name
332
+ }, /*#__PURE__*/_react["default"].createElement(Label, {
333
+ htmlFor: fileInputId,
334
+ disabled: disabled
335
+ }, label), /*#__PURE__*/_react["default"].createElement(HelperText, {
336
+ disabled: disabled
337
+ }, helperText), mode === "file" ? /*#__PURE__*/_react["default"].createElement(FileContainer, {
338
+ multiple: multiple,
339
+ files: files
340
+ }, /*#__PURE__*/_react["default"].createElement(ButtonErrorContainer, null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
341
+ mode: "secondary",
342
+ label: "Select files",
343
+ onClick: handleClick,
344
+ disabled: disabled,
345
+ size: "medium",
346
+ tabIndex: tabIndex
347
+ }), /*#__PURE__*/_react["default"].createElement("input", {
348
+ id: fileInputId,
349
+ type: "file",
350
+ accept: accept,
351
+ multiple: multiple,
352
+ onChange: selectFiles
353
+ }), files.length === 1 && files.map(function (file) {
354
+ return file.error && mode === "file" && !multiple && /*#__PURE__*/_react["default"].createElement(ErrorMessage, null, file.error);
355
+ })), files.map(function (file) {
356
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(FileItemContainer, {
357
+ mode: mode,
358
+ multiple: multiple,
359
+ files: files
360
+ }, /*#__PURE__*/_react["default"].createElement(_FileItem["default"], {
361
+ mode: mode,
362
+ multiple: multiple,
363
+ name: file.file.name,
364
+ error: file.error,
365
+ showPreview: mode === "file" && !multiple ? false : showPreview,
366
+ numFiles: files.length,
367
+ preview: file.preview,
368
+ type: file.file.type,
369
+ onDelete: onDelete,
370
+ tabIndex: tabIndex
371
+ })));
372
+ })) : /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(DragDropArea, {
373
+ isDragging: isDragging,
374
+ disabled: disabled,
375
+ mode: mode,
376
+ onDrop: handleDrop,
377
+ onDragEnter: handleDragIn,
378
+ onDragOver: handleDrag,
379
+ onDragLeave: handleDragOut
380
+ }, /*#__PURE__*/_react["default"].createElement(ButtonContainer, {
381
+ mode: mode
382
+ }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
383
+ mode: "secondary",
384
+ label: "Select",
385
+ onClick: handleClick,
386
+ disabled: disabled,
387
+ size: "fitContent"
388
+ }), /*#__PURE__*/_react["default"].createElement("input", {
389
+ id: fileInputId,
390
+ type: "file",
391
+ accept: accept,
392
+ multiple: multiple,
393
+ onChange: selectFiles
394
+ })), /*#__PURE__*/_react["default"].createElement(DropLabel, {
395
+ disabled: disabled
396
+ }, "or drop files")), files.map(function (file) {
397
+ return /*#__PURE__*/_react["default"].createElement(FileItemContainer, {
398
+ mode: mode,
399
+ multiple: multiple,
400
+ files: files
401
+ }, /*#__PURE__*/_react["default"].createElement(_FileItem["default"], {
402
+ mode: mode,
403
+ multiple: multiple,
404
+ name: file.file.name,
405
+ error: file.error,
406
+ showPreview: showPreview,
407
+ numFiles: files.length,
408
+ preview: file.preview,
409
+ type: file.file.type,
410
+ onDelete: onDelete,
411
+ tabIndex: tabIndex
412
+ }));
413
+ }))));
414
+ };
415
+
416
+ var FileInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n width: fit-content;\n"])), function (props) {
417
+ return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
418
+ }, function (props) {
419
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
420
+ }, function (props) {
421
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
422
+ }, function (props) {
423
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
424
+ }, function (props) {
425
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
426
+ });
427
+
428
+ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
429
+ return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
430
+ }, function (props) {
431
+ return props.theme.labelFontFamily;
432
+ }, function (props) {
433
+ return props.theme.labelFontSize;
434
+ }, function (props) {
435
+ return props.theme.labelFontWeight;
436
+ }, function (props) {
437
+ return props.theme.labelLineHeight;
438
+ });
439
+
440
+ var HelperText = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
441
+ return props.disabled ? props.theme.disabledHelperTextFontcolor : props.theme.helperTextFontColor;
442
+ }, function (props) {
443
+ return props.theme.helperTextFontFamily;
444
+ }, function (props) {
445
+ return props.theme.helperTextFontSize;
446
+ }, function (props) {
447
+ return props.theme.helperTextFontWeight;
448
+ }, function (props) {
449
+ return props.theme.helperTextLineHeight;
450
+ });
451
+
452
+ var DragDropArea = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: calc(320px - 2px);\n display: flex;\n flex-direction: ", ";\n align-items: center;\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n background-color: ", ";\n border-color: ", ";\n cursor: ", ";\n"])), function (props) {
453
+ return props.mode === "filedrop" ? "calc(48px - 2px)" : "calc(160px - 2px)";
454
+ }, function (props) {
455
+ return props.mode === "filedrop" ? "row" : "column";
456
+ }, function (props) {
457
+ return props.theme.dropBorderRadius;
458
+ }, function (props) {
459
+ return !props.isDragging ? props.theme.dropBorderThickness : "2px";
460
+ }, function (props) {
461
+ return !props.isDragging ? props.theme.dropBorderStyle : "solid";
462
+ }, function (props) {
463
+ return props.isDragging && props.theme.dragoverDropBackgroundColor;
464
+ }, function (props) {
465
+ return props.disabled ? props.theme.disabledDropBorderColor : props.isDragging ? props.theme.focusDropBorderColor : props.theme.dropBorderColor;
466
+ }, function (props) {
467
+ return props.disabled && "not-allowed";
468
+ });
469
+
470
+ var FileContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n"])), function (props) {
471
+ return props.multiple || props.files.length > 1 ? "column" : "row";
472
+ });
473
+
474
+ var ButtonErrorContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n margin-top: 0.25rem;\n\n input[type=\"file\"] {\n visibility: hidden;\n position: absolute;\n width: 0px;\n height: 0px;\n }\n"])));
475
+
476
+ var ButtonContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n padding: ", ";\n input[type=\"file\"] {\n visibility: hidden;\n position: absolute;\n width: 0px;\n height: 0px;\n }\n"])), function (props) {
477
+ return props.mode === "filedrop" ? "2px 12px 2px 2px" : "47px 122px 8px 122px";
478
+ });
479
+
480
+ var DropLabel = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
481
+ return props.disabled ? props.theme.disabledDropLabelFontColor : props.theme.dropLabelFontColor;
482
+ }, function (props) {
483
+ return props.theme.dropLabelFontFamily;
484
+ }, function (props) {
485
+ return props.theme.dropLabelFontSize;
486
+ }, function (props) {
487
+ return props.theme.dropLabelFontWeight;
488
+ });
489
+
490
+ var Container = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n margin-top: 0.25rem;\n"])));
491
+
492
+ var FileItemContainer = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n margin-top: ", ";\n margin-left: ", ";\n"])), function (props) {
493
+ return (props.multiple || props.files.length > 1 || props.mode !== "file") && "4px";
494
+ }, function (props) {
495
+ return props.mode === "file" && props.files.length === 1 && !props.multiple && "4px";
496
+ });
497
+
498
+ var ErrorMessage = _styledComponents["default"].div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
499
+ return props.theme.errorMessageFontColor;
500
+ }, function (props) {
501
+ return props.theme.errorMessageFontFamily;
502
+ }, function (props) {
503
+ return props.theme.errorMessageFontSize;
504
+ }, function (props) {
505
+ return props.theme.errorMessageFontWeight;
506
+ }, function (props) {
507
+ return props.theme.errorMessageLineHeight;
508
+ });
509
+
510
+ var _default = DxcFileInput;
511
+ exports["default"] = _default;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ declare const FileItem: ({ mode, multiple, name, error, showPreview, preview, type, numFiles, onDelete, tabIndex, }: {
3
+ mode: any;
4
+ multiple: any;
5
+ name?: string;
6
+ error?: string;
7
+ showPreview: any;
8
+ preview: any;
9
+ type: any;
10
+ numFiles: any;
11
+ onDelete: any;
12
+ tabIndex: any;
13
+ }) => JSX.Element;
14
+ export default FileItem;