@dxc-technology/halstack-react 0.0.0-fc652e4 → 0.0.0-fd5a25e
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.
- package/BackgroundColorContext.d.ts +10 -0
- package/BackgroundColorContext.js +47 -0
- package/HalstackContext.d.ts +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.d.ts +4 -0
- package/accordion/Accordion.js +226 -0
- package/accordion/Accordion.stories.tsx +307 -0
- package/accordion/Accordion.test.js +72 -0
- package/accordion/types.d.ts +68 -0
- package/accordion/types.js +5 -0
- package/accordion-group/AccordionGroup.d.ts +7 -0
- package/accordion-group/AccordionGroup.js +169 -0
- package/accordion-group/AccordionGroup.stories.tsx +225 -0
- package/accordion-group/AccordionGroup.test.js +151 -0
- package/accordion-group/types.d.ts +72 -0
- package/accordion-group/types.js +5 -0
- package/alert/Alert.d.ts +4 -0
- package/{dist/alert → alert}/Alert.js +47 -157
- package/alert/Alert.stories.tsx +170 -0
- package/alert/Alert.test.js +92 -0
- package/alert/types.d.ts +49 -0
- package/alert/types.js +5 -0
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +61 -0
- package/badge/types.d.ts +5 -0
- package/badge/types.js +5 -0
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +51 -0
- package/bleed/Bleed.stories.tsx +341 -0
- package/bleed/types.d.ts +37 -0
- package/bleed/types.js +5 -0
- package/box/Box.d.ts +4 -0
- package/box/Box.js +116 -0
- package/box/Box.stories.tsx +132 -0
- package/box/Box.test.js +18 -0
- package/box/types.d.ts +43 -0
- package/box/types.js +5 -0
- package/button/Button.d.ts +4 -0
- package/{dist/button → button}/Button.js +34 -98
- package/button/Button.stories.tsx +274 -0
- package/button/Button.test.js +35 -0
- package/button/types.d.ts +53 -0
- package/button/types.js +5 -0
- package/card/Card.d.ts +4 -0
- package/card/Card.js +161 -0
- package/card/Card.stories.tsx +201 -0
- package/card/Card.test.js +50 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +67 -0
- package/card/types.js +5 -0
- package/checkbox/Checkbox.d.ts +4 -0
- package/{dist/checkbox → checkbox}/Checkbox.js +55 -98
- package/checkbox/Checkbox.stories.tsx +188 -0
- package/checkbox/Checkbox.test.js +78 -0
- package/checkbox/types.d.ts +64 -0
- package/checkbox/types.js +5 -0
- package/chip/Chip.d.ts +4 -0
- package/chip/Chip.js +161 -0
- package/chip/Chip.stories.tsx +119 -0
- package/chip/Chip.test.js +56 -0
- package/chip/types.d.ts +45 -0
- package/chip/types.js +5 -0
- package/{dist/common → common}/OpenSans.css +0 -0
- package/{dist/common → common}/RequiredComponent.js +3 -11
- package/{dist/common → common}/fonts/OpenSans-Bold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Italic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Light.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-LightItalic.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-Regular.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-SemiBold.ttf +0 -0
- package/{dist/common → common}/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- package/{dist/common → common}/utils.js +0 -0
- package/{dist/common → common}/variables.js +524 -421
- package/date-input/DateInput.d.ts +4 -0
- package/date-input/DateInput.js +372 -0
- package/date-input/DateInput.stories.tsx +138 -0
- package/date-input/DateInput.test.js +479 -0
- package/date-input/types.d.ts +107 -0
- package/date-input/types.js +5 -0
- package/dialog/Dialog.d.ts +4 -0
- package/dialog/Dialog.js +138 -0
- package/dialog/Dialog.stories.tsx +212 -0
- package/dialog/Dialog.test.js +40 -0
- package/dialog/types.d.ts +43 -0
- package/dialog/types.js +5 -0
- package/dropdown/Dropdown.d.ts +4 -0
- package/{dist/dropdown → dropdown}/Dropdown.js +60 -218
- package/dropdown/Dropdown.stories.tsx +249 -0
- package/dropdown/Dropdown.test.js +189 -0
- package/dropdown/types.d.ts +80 -0
- package/dropdown/types.js +5 -0
- package/file-input/FileInput.d.ts +4 -0
- package/file-input/FileInput.js +593 -0
- package/file-input/FileInput.stories.tsx +507 -0
- package/file-input/FileInput.test.js +457 -0
- package/file-input/FileItem.d.ts +14 -0
- package/file-input/FileItem.js +186 -0
- package/file-input/types.d.ts +112 -0
- package/file-input/types.js +5 -0
- package/footer/Footer.d.ts +4 -0
- package/footer/Footer.js +185 -0
- package/footer/Footer.stories.tsx +130 -0
- package/footer/Footer.test.js +109 -0
- package/footer/Icons.d.ts +2 -0
- package/footer/Icons.js +77 -0
- package/footer/types.d.ts +65 -0
- package/footer/types.js +5 -0
- package/header/Header.d.ts +7 -0
- package/header/Header.js +303 -0
- package/header/Header.stories.tsx +172 -0
- package/header/Header.test.js +79 -0
- package/header/Icons.d.ts +2 -0
- package/header/Icons.js +34 -0
- package/header/types.d.ts +47 -0
- package/header/types.js +5 -0
- package/heading/Heading.d.ts +4 -0
- package/{dist/heading → heading}/Heading.js +31 -90
- package/heading/Heading.stories.tsx +54 -0
- package/heading/Heading.test.js +186 -0
- package/heading/types.d.ts +33 -0
- package/heading/types.js +5 -0
- package/inline/Inline.d.ts +4 -0
- package/inline/Inline.js +60 -0
- package/inline/Inline.stories.tsx +319 -0
- package/inline/types.d.ts +36 -0
- package/inline/types.js +5 -0
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +51 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +37 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +11 -0
- package/layout/ApplicationLayout.js +199 -0
- package/layout/ApplicationLayout.stories.tsx +126 -0
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +66 -0
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +52 -0
- package/layout/types.js +5 -0
- package/link/Link.d.ts +4 -0
- package/link/Link.js +136 -0
- package/link/Link.stories.tsx +186 -0
- package/link/Link.test.js +83 -0
- package/link/types.d.ts +54 -0
- package/link/types.js +5 -0
- package/list/List.d.ts +4 -0
- package/list/List.js +47 -0
- package/list/List.stories.tsx +89 -0
- package/list/types.d.ts +7 -0
- package/list/types.js +5 -0
- package/main.d.ts +48 -0
- package/{dist/main.js → main.js} +151 -101
- package/number-input/NumberInput.d.ts +4 -0
- package/number-input/NumberInput.js +76 -0
- package/number-input/NumberInput.stories.tsx +115 -0
- package/number-input/NumberInput.test.js +506 -0
- package/number-input/NumberInputContext.d.ts +4 -0
- package/{dist/number/NumberContext.js → number-input/NumberInputContext.js} +6 -3
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/number-input/types.d.ts +124 -0
- package/number-input/types.js +5 -0
- package/package.json +39 -27
- package/paginator/Icons.js +66 -0
- package/paginator/Paginator.d.ts +4 -0
- package/paginator/Paginator.js +171 -0
- package/paginator/Paginator.stories.tsx +63 -0
- package/paginator/Paginator.test.js +308 -0
- package/paginator/types.d.ts +38 -0
- package/paginator/types.js +5 -0
- package/password-input/PasswordInput.d.ts +4 -0
- package/{dist/password/Password.js → password-input/PasswordInput.js} +48 -82
- package/password-input/PasswordInput.stories.tsx +131 -0
- package/password-input/PasswordInput.test.js +180 -0
- package/password-input/types.d.ts +110 -0
- package/password-input/types.js +5 -0
- package/progress-bar/ProgressBar.d.ts +4 -0
- package/{dist/progress-bar → progress-bar}/ProgressBar.js +23 -95
- package/progress-bar/ProgressBar.stories.jsx +58 -0
- package/progress-bar/ProgressBar.test.js +65 -0
- package/progress-bar/types.d.ts +37 -0
- package/progress-bar/types.js +5 -0
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +116 -0
- package/quick-nav/QuickNav.stories.tsx +264 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +141 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +283 -0
- package/radio-group/RadioGroup.stories.tsx +100 -0
- package/radio-group/RadioGroup.test.js +695 -0
- package/radio-group/types.d.ts +114 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/{dist/resultsetTable → resultsetTable}/ResultsetTable.js +43 -147
- package/resultsetTable/ResultsetTable.stories.tsx +275 -0
- package/resultsetTable/ResultsetTable.test.js +348 -0
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/row/Row.d.ts +3 -0
- package/row/Row.js +127 -0
- package/row/Row.stories.tsx +237 -0
- package/row/types.d.ts +28 -0
- package/row/types.js +5 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +175 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +660 -0
- package/select/Select.stories.tsx +626 -0
- package/select/Select.test.js +2162 -0
- package/select/types.d.ts +212 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.d.ts +9 -0
- package/sidenav/Sidenav.js +147 -0
- package/sidenav/Sidenav.stories.tsx +182 -0
- package/sidenav/Sidenav.test.js +56 -0
- package/sidenav/types.d.ts +50 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +4 -0
- package/slider/Slider.js +318 -0
- package/slider/Slider.stories.tsx +177 -0
- package/slider/Slider.test.js +150 -0
- package/slider/types.d.ts +82 -0
- package/slider/types.js +5 -0
- package/spinner/Spinner.d.ts +4 -0
- package/spinner/Spinner.js +250 -0
- package/spinner/Spinner.stories.jsx +103 -0
- package/spinner/Spinner.test.js +64 -0
- package/spinner/types.d.ts +32 -0
- package/spinner/types.js +5 -0
- package/stack/Stack.d.ts +4 -0
- package/stack/Stack.js +56 -0
- package/stack/Stack.stories.tsx +263 -0
- package/stack/types.d.ts +32 -0
- package/stack/types.js +5 -0
- package/switch/Switch.d.ts +4 -0
- package/switch/Switch.js +195 -0
- package/switch/Switch.stories.tsx +160 -0
- package/switch/Switch.test.js +98 -0
- package/switch/types.d.ts +62 -0
- package/switch/types.js +5 -0
- package/table/Table.d.ts +4 -0
- package/{dist/table → table}/Table.js +12 -26
- package/table/Table.stories.jsx +277 -0
- package/table/Table.test.js +26 -0
- package/table/types.d.ts +21 -0
- package/table/types.js +5 -0
- package/tabs/Tabs.d.ts +4 -0
- package/tabs/Tabs.js +211 -0
- package/tabs/Tabs.stories.tsx +112 -0
- package/tabs/Tabs.test.js +140 -0
- package/tabs/types.d.ts +82 -0
- package/tabs/types.js +5 -0
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +132 -0
- package/tabs-nav/types.d.ts +53 -0
- package/tabs-nav/types.js +5 -0
- package/tag/Tag.d.ts +4 -0
- package/tag/Tag.js +183 -0
- package/tag/Tag.stories.tsx +142 -0
- package/tag/Tag.test.js +60 -0
- package/tag/types.d.ts +69 -0
- package/tag/types.js +5 -0
- package/text/Text.d.ts +7 -0
- package/text/Text.js +30 -0
- package/text/Text.stories.tsx +19 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +770 -0
- package/text-input/TextInput.stories.tsx +474 -0
- package/text-input/TextInput.test.js +1712 -0
- package/text-input/types.d.ts +178 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.d.ts +4 -0
- package/{dist/new-textarea/NewTextarea.js → textarea/Textarea.js} +88 -157
- package/textarea/Textarea.stories.jsx +157 -0
- package/textarea/Textarea.test.js +437 -0
- package/textarea/types.d.ts +137 -0
- package/textarea/types.js +5 -0
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +215 -0
- package/toggle-group/ToggleGroup.stories.tsx +173 -0
- package/toggle-group/ToggleGroup.test.js +156 -0
- package/toggle-group/types.d.ts +105 -0
- package/toggle-group/types.js +5 -0
- package/useTheme.d.ts +2 -0
- package/{dist/useTheme.js → useTheme.js} +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.d.ts +4 -0
- package/wizard/Wizard.js +292 -0
- package/wizard/Wizard.stories.tsx +214 -0
- package/wizard/Wizard.test.js +141 -0
- package/wizard/types.d.ts +64 -0
- package/wizard/types.js +5 -0
- package/README.md +0 -66
- package/babel.config.js +0 -8
- package/dist/BackgroundColorContext.js +0 -46
- package/dist/ThemeContext.js +0 -241
- package/dist/accordion/Accordion.js +0 -353
- package/dist/accordion-group/AccordionGroup.js +0 -188
- package/dist/accordion-group/AccordionGroup.stories.js +0 -207
- package/dist/accordion-group/readme.md +0 -70
- package/dist/badge/Badge.js +0 -63
- package/dist/box/Box.js +0 -156
- package/dist/card/Card.js +0 -254
- package/dist/checkbox/Checkbox.stories.js +0 -144
- package/dist/checkbox/readme.md +0 -116
- package/dist/chip/Chip.js +0 -265
- package/dist/date/Date.js +0 -381
- package/dist/date/Date.stories.js +0 -205
- package/dist/date/readme.md +0 -73
- package/dist/dialog/Dialog.js +0 -218
- package/dist/footer/Footer.js +0 -395
- package/dist/footer/Footer.stories.js +0 -94
- package/dist/footer/dxc_logo.svg +0 -15
- package/dist/footer/readme.md +0 -41
- package/dist/header/Header.js +0 -403
- package/dist/header/Header.stories.js +0 -176
- package/dist/header/close_icon.svg +0 -1
- package/dist/header/dxc_logo_black.svg +0 -8
- package/dist/header/hamb_menu_black.svg +0 -1
- package/dist/header/hamb_menu_white.svg +0 -1
- package/dist/header/readme.md +0 -33
- package/dist/input-text/InputText.js +0 -707
- package/dist/input-text/InputText.stories.js +0 -209
- package/dist/input-text/error.svg +0 -1
- package/dist/input-text/readme.md +0 -91
- package/dist/layout/ApplicationLayout.js +0 -331
- package/dist/layout/facebook.svg +0 -45
- package/dist/layout/linkedin.svg +0 -50
- package/dist/layout/twitter.svg +0 -53
- package/dist/link/Link.js +0 -241
- package/dist/link/readme.md +0 -51
- package/dist/new-date/NewDate.js +0 -403
- package/dist/new-input-text/NewInputText.js +0 -961
- package/dist/number/Number.js +0 -138
- package/dist/paginator/Paginator.js +0 -289
- package/dist/paginator/images/next.svg +0 -3
- package/dist/paginator/images/nextPage.svg +0 -3
- package/dist/paginator/images/previous.svg +0 -3
- package/dist/paginator/images/previousPage.svg +0 -3
- package/dist/paginator/readme.md +0 -50
- package/dist/password/styles.css +0 -3
- package/dist/progress-bar/ProgressBar.stories.js +0 -280
- package/dist/progress-bar/readme.md +0 -63
- package/dist/radio/Radio.js +0 -209
- package/dist/radio/Radio.stories.js +0 -166
- package/dist/radio/readme.md +0 -70
- package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
- package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
- package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
- package/dist/select/Select.js +0 -585
- package/dist/select/Select.stories.js +0 -235
- package/dist/select/readme.md +0 -72
- package/dist/sidenav/Sidenav.js +0 -177
- package/dist/slider/Slider.js +0 -319
- package/dist/slider/Slider.stories.js +0 -241
- package/dist/slider/readme.md +0 -64
- package/dist/spinner/Spinner.js +0 -218
- package/dist/spinner/Spinner.stories.js +0 -183
- package/dist/spinner/readme.md +0 -65
- package/dist/switch/Switch.js +0 -222
- package/dist/switch/Switch.stories.js +0 -134
- package/dist/switch/readme.md +0 -133
- package/dist/tabs/Tabs.js +0 -343
- package/dist/tabs/Tabs.stories.js +0 -130
- package/dist/tabs/readme.md +0 -78
- package/dist/tabs-for-sections/TabsForSections.js +0 -92
- package/dist/tabs-for-sections/readme.md +0 -78
- package/dist/tag/Tag.js +0 -288
- package/dist/textarea/Textarea.js +0 -264
- package/dist/toggle/Toggle.js +0 -220
- package/dist/toggle/Toggle.stories.js +0 -297
- package/dist/toggle/readme.md +0 -80
- package/dist/toggle-group/ToggleGroup.js +0 -223
- package/dist/upload/Upload.js +0 -205
- package/dist/upload/Upload.stories.js +0 -72
- package/dist/upload/buttons-upload/ButtonsUpload.js +0 -139
- package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
- package/dist/upload/buttons-upload/upload-button.svg +0 -1
- package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -329
- package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
- package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
- package/dist/upload/file-upload/FileToUpload.js +0 -184
- package/dist/upload/file-upload/audio-icon.svg +0 -4
- package/dist/upload/file-upload/close.svg +0 -4
- package/dist/upload/file-upload/file-icon.svg +0 -4
- package/dist/upload/file-upload/video-icon.svg +0 -4
- package/dist/upload/files-upload/FilesToUpload.js +0 -123
- package/dist/upload/readme.md +0 -37
- package/dist/upload/transaction/Transaction.js +0 -175
- package/dist/upload/transaction/audio-icon-err.svg +0 -4
- package/dist/upload/transaction/audio-icon.svg +0 -4
- package/dist/upload/transaction/error-icon.svg +0 -4
- package/dist/upload/transaction/file-icon-err.svg +0 -4
- package/dist/upload/transaction/file-icon.svg +0 -4
- package/dist/upload/transaction/image-icon-err.svg +0 -4
- package/dist/upload/transaction/image-icon.svg +0 -4
- package/dist/upload/transaction/success-icon.svg +0 -4
- package/dist/upload/transaction/video-icon-err.svg +0 -4
- package/dist/upload/transaction/video-icon.svg +0 -4
- package/dist/upload/transactions/Transactions.js +0 -138
- package/dist/wizard/Wizard.js +0 -411
- package/dist/wizard/invalid_icon.svg +0 -5
- package/dist/wizard/valid_icon.svg +0 -5
- package/dist/wizard/validation-wrong.svg +0 -6
- package/test/Accordion.test.js +0 -33
- package/test/AccordionGroup.test.js +0 -125
- package/test/Alert.test.js +0 -53
- package/test/Box.test.js +0 -10
- package/test/Button.test.js +0 -18
- package/test/Card.test.js +0 -30
- package/test/Checkbox.test.js +0 -45
- package/test/Chip.test.js +0 -25
- package/test/Date.test.js +0 -393
- package/test/Dialog.test.js +0 -23
- package/test/Dropdown.test.js +0 -145
- package/test/Footer.test.js +0 -99
- package/test/Header.test.js +0 -39
- package/test/Heading.test.js +0 -35
- package/test/InputText.test.js +0 -240
- package/test/Link.test.js +0 -43
- package/test/NewDate.test.js +0 -203
- package/test/NewInputText.test.js +0 -817
- package/test/NewTextarea.test.js +0 -201
- package/test/Number.test.js +0 -241
- package/test/Paginator.test.js +0 -177
- package/test/Password.test.js +0 -76
- package/test/ProgressBar.test.js +0 -35
- package/test/Radio.test.js +0 -37
- package/test/ResultsetTable.test.js +0 -330
- package/test/Select.test.js +0 -189
- package/test/Sidenav.test.js +0 -45
- package/test/Slider.test.js +0 -82
- package/test/Spinner.test.js +0 -27
- package/test/Switch.test.js +0 -45
- package/test/Table.test.js +0 -36
- package/test/Tabs.test.js +0 -109
- package/test/TabsForSections.test.js +0 -34
- package/test/Tag.test.js +0 -32
- package/test/TextArea.test.js +0 -52
- package/test/ToggleGroup.test.js +0 -81
- package/test/Upload.test.js +0 -60
- package/test/Wizard.test.js +0 -130
- package/test/mocks/pngMock.js +0 -1
- package/test/mocks/svgMock.js +0 -1
|
@@ -0,0 +1,593 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
23
|
+
|
|
24
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
+
|
|
28
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
29
|
+
|
|
30
|
+
var _uuid = require("uuid");
|
|
31
|
+
|
|
32
|
+
var _variables = require("../common/variables.js");
|
|
33
|
+
|
|
34
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
35
|
+
|
|
36
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
37
|
+
|
|
38
|
+
var _Button = _interopRequireDefault(require("../button/Button"));
|
|
39
|
+
|
|
40
|
+
var _FileItem = _interopRequireDefault(require("./FileItem"));
|
|
41
|
+
|
|
42
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
|
43
|
+
|
|
44
|
+
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); }
|
|
45
|
+
|
|
46
|
+
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; }
|
|
47
|
+
|
|
48
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
49
|
+
|
|
50
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
51
|
+
|
|
52
|
+
var audioIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
53
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
+
width: "24",
|
|
55
|
+
height: "24",
|
|
56
|
+
viewBox: "0 0 24 24",
|
|
57
|
+
fill: "currentColor"
|
|
58
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
59
|
+
fill: "none",
|
|
60
|
+
d: "M0 0h24v24H0V0z"
|
|
61
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
62
|
+
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"
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
var videoIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
66
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
67
|
+
width: "24",
|
|
68
|
+
height: "24",
|
|
69
|
+
viewBox: "0 0 24 24",
|
|
70
|
+
fill: "currentColor"
|
|
71
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
72
|
+
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"
|
|
73
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
74
|
+
d: "M0 0h24v24H0z",
|
|
75
|
+
fill: "none"
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
var fileIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
79
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
80
|
+
width: "24",
|
|
81
|
+
height: "24",
|
|
82
|
+
viewBox: "0 0 24 24",
|
|
83
|
+
fill: "currentColor"
|
|
84
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
85
|
+
fill: "none",
|
|
86
|
+
d: "M0 0h24v24H0V0z"
|
|
87
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
88
|
+
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"
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
var DxcFileInput = function DxcFileInput(_ref) {
|
|
92
|
+
var _ref$name = _ref.name,
|
|
93
|
+
name = _ref$name === void 0 ? "" : _ref$name,
|
|
94
|
+
_ref$mode = _ref.mode,
|
|
95
|
+
mode = _ref$mode === void 0 ? "file" : _ref$mode,
|
|
96
|
+
_ref$label = _ref.label,
|
|
97
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
98
|
+
buttonLabel = _ref.buttonLabel,
|
|
99
|
+
dropAreaLabel = _ref.dropAreaLabel,
|
|
100
|
+
_ref$helperText = _ref.helperText,
|
|
101
|
+
helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
|
|
102
|
+
accept = _ref.accept,
|
|
103
|
+
minSize = _ref.minSize,
|
|
104
|
+
maxSize = _ref.maxSize,
|
|
105
|
+
_ref$showPreview = _ref.showPreview,
|
|
106
|
+
showPreview = _ref$showPreview === void 0 ? false : _ref$showPreview,
|
|
107
|
+
_ref$multiple = _ref.multiple,
|
|
108
|
+
multiple = _ref$multiple === void 0 ? true : _ref$multiple,
|
|
109
|
+
_ref$disabled = _ref.disabled,
|
|
110
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
111
|
+
callbackFile = _ref.callbackFile,
|
|
112
|
+
value = _ref.value,
|
|
113
|
+
margin = _ref.margin,
|
|
114
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
115
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
116
|
+
|
|
117
|
+
var _useState = (0, _react.useState)(false),
|
|
118
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
119
|
+
isDragging = _useState2[0],
|
|
120
|
+
setIsDragging = _useState2[1];
|
|
121
|
+
|
|
122
|
+
var _useState3 = (0, _react.useState)([]),
|
|
123
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
124
|
+
files = _useState4[0],
|
|
125
|
+
setFiles = _useState4[1];
|
|
126
|
+
|
|
127
|
+
var _useState5 = (0, _react.useState)("file-input-".concat((0, _uuid.v4)())),
|
|
128
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 1),
|
|
129
|
+
fileInputId = _useState6[0];
|
|
130
|
+
|
|
131
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
132
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
133
|
+
(0, _react.useEffect)(function () {
|
|
134
|
+
var getFiles = /*#__PURE__*/function () {
|
|
135
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
136
|
+
var valueFiles;
|
|
137
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
138
|
+
while (1) {
|
|
139
|
+
switch (_context2.prev = _context2.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
if (!value) {
|
|
142
|
+
_context2.next = 5;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_context2.next = 3;
|
|
147
|
+
return Promise.all(value.map( /*#__PURE__*/function () {
|
|
148
|
+
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
|
|
149
|
+
var preview;
|
|
150
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
151
|
+
while (1) {
|
|
152
|
+
switch (_context.prev = _context.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
if (!file.preview) {
|
|
155
|
+
_context.next = 4;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return _context.abrupt("return", file);
|
|
160
|
+
|
|
161
|
+
case 4:
|
|
162
|
+
_context.next = 6;
|
|
163
|
+
return getFilePreview(file.file);
|
|
164
|
+
|
|
165
|
+
case 6:
|
|
166
|
+
preview = _context.sent;
|
|
167
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, file), {}, {
|
|
168
|
+
preview: preview
|
|
169
|
+
}));
|
|
170
|
+
|
|
171
|
+
case 8:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, _callee);
|
|
177
|
+
}));
|
|
178
|
+
|
|
179
|
+
return function (_x) {
|
|
180
|
+
return _ref3.apply(this, arguments);
|
|
181
|
+
};
|
|
182
|
+
}()));
|
|
183
|
+
|
|
184
|
+
case 3:
|
|
185
|
+
valueFiles = _context2.sent;
|
|
186
|
+
setFiles(valueFiles);
|
|
187
|
+
|
|
188
|
+
case 5:
|
|
189
|
+
case "end":
|
|
190
|
+
return _context2.stop();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, _callee2);
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
return function getFiles() {
|
|
197
|
+
return _ref2.apply(this, arguments);
|
|
198
|
+
};
|
|
199
|
+
}();
|
|
200
|
+
|
|
201
|
+
getFiles();
|
|
202
|
+
}, [value]);
|
|
203
|
+
|
|
204
|
+
var handleClick = function handleClick() {
|
|
205
|
+
document.getElementById(fileInputId).click();
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
var checkFileSize = function checkFileSize(file) {
|
|
209
|
+
if (file.size < minSize) {
|
|
210
|
+
return translatedLabels.fileInput.fileSizeGreaterThanErrorMessage;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (file.size > maxSize) {
|
|
214
|
+
return translatedLabels.fileInput.fileSizeLessThanErrorMessage;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
var getFilePreview = function getFilePreview(file) {
|
|
219
|
+
if (file.type.includes("video")) {
|
|
220
|
+
return videoIcon;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (file.type.includes("audio")) {
|
|
224
|
+
return audioIcon;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (file.type.includes("image")) {
|
|
228
|
+
return new Promise(function (resolve) {
|
|
229
|
+
var reader = new FileReader();
|
|
230
|
+
reader.readAsDataURL(file);
|
|
231
|
+
|
|
232
|
+
reader.onload = function (e) {
|
|
233
|
+
resolve(e.target.result);
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return fileIcon;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
var getFilesToAdd = /*#__PURE__*/function () {
|
|
242
|
+
var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(selectedFiles) {
|
|
243
|
+
var filesToAdd;
|
|
244
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
245
|
+
while (1) {
|
|
246
|
+
switch (_context3.prev = _context3.next) {
|
|
247
|
+
case 0:
|
|
248
|
+
_context3.next = 2;
|
|
249
|
+
return Promise.all(selectedFiles.map(function (selectedFile) {
|
|
250
|
+
return getFilePreview(selectedFile);
|
|
251
|
+
})).then(function (previews) {
|
|
252
|
+
return selectedFiles.map(function (selectedFile, index) {
|
|
253
|
+
var fileInfo = {
|
|
254
|
+
file: selectedFile,
|
|
255
|
+
error: checkFileSize(selectedFile),
|
|
256
|
+
preview: previews[index]
|
|
257
|
+
};
|
|
258
|
+
return fileInfo;
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
case 2:
|
|
263
|
+
filesToAdd = _context3.sent;
|
|
264
|
+
return _context3.abrupt("return", filesToAdd);
|
|
265
|
+
|
|
266
|
+
case 4:
|
|
267
|
+
case "end":
|
|
268
|
+
return _context3.stop();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, _callee3);
|
|
272
|
+
}));
|
|
273
|
+
|
|
274
|
+
return function getFilesToAdd(_x2) {
|
|
275
|
+
return _ref4.apply(this, arguments);
|
|
276
|
+
};
|
|
277
|
+
}();
|
|
278
|
+
|
|
279
|
+
var addFile = /*#__PURE__*/function () {
|
|
280
|
+
var _ref5 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(selectedFiles) {
|
|
281
|
+
var filesToAdd, finalFiles, fileToAdd;
|
|
282
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
283
|
+
while (1) {
|
|
284
|
+
switch (_context4.prev = _context4.next) {
|
|
285
|
+
case 0:
|
|
286
|
+
if (!multiple) {
|
|
287
|
+
_context4.next = 8;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
_context4.next = 3;
|
|
292
|
+
return getFilesToAdd(selectedFiles);
|
|
293
|
+
|
|
294
|
+
case 3:
|
|
295
|
+
filesToAdd = _context4.sent;
|
|
296
|
+
finalFiles = [].concat((0, _toConsumableArray2["default"])(files), (0, _toConsumableArray2["default"])(filesToAdd));
|
|
297
|
+
|
|
298
|
+
if (typeof callbackFile === "function") {
|
|
299
|
+
callbackFile(finalFiles);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
_context4.next = 19;
|
|
303
|
+
break;
|
|
304
|
+
|
|
305
|
+
case 8:
|
|
306
|
+
if (!(selectedFiles.length === 1)) {
|
|
307
|
+
_context4.next = 14;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
_context4.next = 11;
|
|
312
|
+
return getFilesToAdd(selectedFiles);
|
|
313
|
+
|
|
314
|
+
case 11:
|
|
315
|
+
_context4.t0 = _context4.sent;
|
|
316
|
+
_context4.next = 17;
|
|
317
|
+
break;
|
|
318
|
+
|
|
319
|
+
case 14:
|
|
320
|
+
_context4.next = 16;
|
|
321
|
+
return getFilesToAdd([selectedFiles[0]]);
|
|
322
|
+
|
|
323
|
+
case 16:
|
|
324
|
+
_context4.t0 = _context4.sent;
|
|
325
|
+
|
|
326
|
+
case 17:
|
|
327
|
+
fileToAdd = _context4.t0;
|
|
328
|
+
|
|
329
|
+
if (typeof callbackFile === "function") {
|
|
330
|
+
callbackFile(fileToAdd);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
case 19:
|
|
334
|
+
case "end":
|
|
335
|
+
return _context4.stop();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}, _callee4);
|
|
339
|
+
}));
|
|
340
|
+
|
|
341
|
+
return function addFile(_x3) {
|
|
342
|
+
return _ref5.apply(this, arguments);
|
|
343
|
+
};
|
|
344
|
+
}();
|
|
345
|
+
|
|
346
|
+
var selectFiles = function selectFiles(e) {
|
|
347
|
+
var selectedFiles = e.target.files;
|
|
348
|
+
var filesArray = Object.keys(selectedFiles).map(function (key) {
|
|
349
|
+
return selectedFiles[key];
|
|
350
|
+
});
|
|
351
|
+
addFile(filesArray);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
var onDelete = function onDelete(fileName) {
|
|
355
|
+
var filesCopy = (0, _toConsumableArray2["default"])(files);
|
|
356
|
+
var fileToRemove = filesCopy.find(function (file) {
|
|
357
|
+
return file.file.name === fileName;
|
|
358
|
+
});
|
|
359
|
+
var fileIndex = filesCopy.indexOf(fileToRemove);
|
|
360
|
+
filesCopy.splice(fileIndex, 1);
|
|
361
|
+
|
|
362
|
+
if (typeof callbackFile === "function") {
|
|
363
|
+
callbackFile(filesCopy);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
var handleDrag = function handleDrag(e) {
|
|
368
|
+
e.preventDefault();
|
|
369
|
+
e.stopPropagation();
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
var handleDragIn = function handleDragIn(e) {
|
|
373
|
+
if (e.dataTransfer.items && e.dataTransfer.items.length > 0) setIsDragging(true);
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
var handleDragOut = function handleDragOut(e) {
|
|
377
|
+
// only if dragged items leave container (outside, not to childs)
|
|
378
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setIsDragging(false);
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
var handleDrop = function handleDrop(e) {
|
|
382
|
+
e.preventDefault();
|
|
383
|
+
e.stopPropagation();
|
|
384
|
+
setIsDragging(false);
|
|
385
|
+
var filesObject = e.dataTransfer.files;
|
|
386
|
+
|
|
387
|
+
if (filesObject && filesObject.length > 0) {
|
|
388
|
+
var filesArray = Object.keys(filesObject).map(function (key) {
|
|
389
|
+
return filesObject[key];
|
|
390
|
+
});
|
|
391
|
+
addFile(filesArray);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
396
|
+
theme: colorsTheme.fileInput
|
|
397
|
+
}, /*#__PURE__*/_react["default"].createElement(FileInputContainer, {
|
|
398
|
+
margin: margin,
|
|
399
|
+
name: name
|
|
400
|
+
}, /*#__PURE__*/_react["default"].createElement(Label, {
|
|
401
|
+
htmlFor: fileInputId,
|
|
402
|
+
disabled: disabled
|
|
403
|
+
}, label), /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
404
|
+
disabled: disabled
|
|
405
|
+
}, helperText), mode === "file" ? /*#__PURE__*/_react["default"].createElement(FileContainer, {
|
|
406
|
+
multiple: multiple,
|
|
407
|
+
files: files
|
|
408
|
+
}, /*#__PURE__*/_react["default"].createElement(HiddenInputFile, {
|
|
409
|
+
id: fileInputId,
|
|
410
|
+
type: "file",
|
|
411
|
+
accept: accept,
|
|
412
|
+
multiple: multiple,
|
|
413
|
+
onChange: selectFiles
|
|
414
|
+
}), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
415
|
+
mode: "secondary",
|
|
416
|
+
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : multiple ? translatedLabels.fileInput.multipleButtonLabelDefault : translatedLabels.fileInput.singleButtonLabelDefault,
|
|
417
|
+
onClick: handleClick,
|
|
418
|
+
disabled: disabled,
|
|
419
|
+
size: "medium",
|
|
420
|
+
tabIndex: tabIndex
|
|
421
|
+
}), files.map(function (file) {
|
|
422
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(FileItemContainer, {
|
|
423
|
+
mode: mode,
|
|
424
|
+
multiple: multiple,
|
|
425
|
+
files: files
|
|
426
|
+
}, /*#__PURE__*/_react["default"].createElement(_FileItem["default"], {
|
|
427
|
+
mode: mode,
|
|
428
|
+
multiple: multiple,
|
|
429
|
+
name: file.file.name,
|
|
430
|
+
error: file.error,
|
|
431
|
+
showPreview: mode === "file" && !multiple ? false : showPreview,
|
|
432
|
+
numFiles: files.length,
|
|
433
|
+
preview: file.preview,
|
|
434
|
+
type: file.file.type,
|
|
435
|
+
onDelete: onDelete,
|
|
436
|
+
tabIndex: tabIndex
|
|
437
|
+
})));
|
|
438
|
+
})) : /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(HiddenInputFile, {
|
|
439
|
+
id: fileInputId,
|
|
440
|
+
type: "file",
|
|
441
|
+
accept: accept,
|
|
442
|
+
multiple: multiple,
|
|
443
|
+
onChange: selectFiles
|
|
444
|
+
}), /*#__PURE__*/_react["default"].createElement(DragDropArea, {
|
|
445
|
+
isDragging: isDragging,
|
|
446
|
+
disabled: disabled,
|
|
447
|
+
mode: mode,
|
|
448
|
+
onDrop: handleDrop,
|
|
449
|
+
onDragEnter: handleDragIn,
|
|
450
|
+
onDragOver: handleDrag,
|
|
451
|
+
onDragLeave: handleDragOut
|
|
452
|
+
}, /*#__PURE__*/_react["default"].createElement(ButtonContainer, {
|
|
453
|
+
mode: mode
|
|
454
|
+
}, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
455
|
+
mode: "secondary",
|
|
456
|
+
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : translatedLabels.fileInput.dropAreaButtonLabelDefault,
|
|
457
|
+
onClick: handleClick,
|
|
458
|
+
disabled: disabled,
|
|
459
|
+
size: "fitContent"
|
|
460
|
+
})), mode === "dropzone" ? /*#__PURE__*/_react["default"].createElement(DropzoneLabel, {
|
|
461
|
+
disabled: disabled
|
|
462
|
+
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ? translatedLabels.fileInput.multipleDropAreaLabelDefault : translatedLabels.fileInput.singleDropAreaLabelDefault) : /*#__PURE__*/_react["default"].createElement(FiledropLabel, {
|
|
463
|
+
disabled: disabled
|
|
464
|
+
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ? translatedLabels.fileInput.multipleDropAreaLabelDefault : translatedLabels.fileInput.singleDropAreaLabelDefault)), files.map(function (file) {
|
|
465
|
+
return /*#__PURE__*/_react["default"].createElement(FileItemContainer, {
|
|
466
|
+
mode: mode,
|
|
467
|
+
multiple: multiple,
|
|
468
|
+
files: files
|
|
469
|
+
}, /*#__PURE__*/_react["default"].createElement(_FileItem["default"], {
|
|
470
|
+
mode: mode,
|
|
471
|
+
multiple: multiple,
|
|
472
|
+
name: file.file.name,
|
|
473
|
+
error: file.error,
|
|
474
|
+
showPreview: showPreview,
|
|
475
|
+
numFiles: files.length,
|
|
476
|
+
preview: file.preview,
|
|
477
|
+
type: file.file.type,
|
|
478
|
+
onDelete: onDelete,
|
|
479
|
+
tabIndex: tabIndex
|
|
480
|
+
}));
|
|
481
|
+
})), files.length === 1 && files.map(function (file) {
|
|
482
|
+
return file.error && mode === "file" && !multiple && /*#__PURE__*/_react["default"].createElement(ErrorMessage, null, file.error);
|
|
483
|
+
})));
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
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) {
|
|
487
|
+
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
488
|
+
}, function (props) {
|
|
489
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
490
|
+
}, function (props) {
|
|
491
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
|
|
492
|
+
}, function (props) {
|
|
493
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
494
|
+
}, function (props) {
|
|
495
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
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) {
|
|
499
|
+
return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
|
|
500
|
+
}, function (props) {
|
|
501
|
+
return props.theme.labelFontFamily;
|
|
502
|
+
}, function (props) {
|
|
503
|
+
return props.theme.labelFontSize;
|
|
504
|
+
}, function (props) {
|
|
505
|
+
return props.theme.labelFontWeight;
|
|
506
|
+
}, function (props) {
|
|
507
|
+
return props.theme.labelLineHeight;
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
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) {
|
|
511
|
+
return props.disabled ? props.theme.disabledHelperTextFontcolor : props.theme.helperTextFontColor;
|
|
512
|
+
}, function (props) {
|
|
513
|
+
return props.theme.helperTextFontFamily;
|
|
514
|
+
}, function (props) {
|
|
515
|
+
return props.theme.helperTextFontSize;
|
|
516
|
+
}, function (props) {
|
|
517
|
+
return props.theme.helperTextFontWeight;
|
|
518
|
+
}, function (props) {
|
|
519
|
+
return props.theme.helperTextLineHeight;
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
var DragDropArea = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n overflow: hidden;\n box-sizing: border-box;\n flex-direction: ", ";\n ", ";\n align-items: center;\n height: ", ";\n width: 320px;\n\n box-shadow: 0 0 0 2px transparent;\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n ", "\n\n cursor: ", ";\n"])), function (props) {
|
|
523
|
+
return props.mode === "filedrop" ? "row" : "column";
|
|
524
|
+
}, function (props) {
|
|
525
|
+
return props.mode === "dropzone" && "justify-content: center; padding: 1rem;";
|
|
526
|
+
}, function (props) {
|
|
527
|
+
return props.mode === "filedrop" ? "48px" : "160px";
|
|
528
|
+
}, function (props) {
|
|
529
|
+
return props.theme.dropBorderRadius;
|
|
530
|
+
}, function (props) {
|
|
531
|
+
return props.theme.dropBorderThickness;
|
|
532
|
+
}, function (props) {
|
|
533
|
+
return props.theme.dropBorderStyle;
|
|
534
|
+
}, function (props) {
|
|
535
|
+
return props.disabled ? props.theme.disabledDropBorderColor : props.theme.dropBorderColor;
|
|
536
|
+
}, function (props) {
|
|
537
|
+
return props.isDragging && "\n background-color: ".concat(props.theme.dragoverDropBackgroundColor, ";\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.theme.focusDropBorderColor, ";\n ");
|
|
538
|
+
}, function (props) {
|
|
539
|
+
return props.disabled && "not-allowed";
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
var FileContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n margin-top: 0.25rem;\n"])), function (props) {
|
|
543
|
+
return props.multiple || props.files.length > 1 ? "column" : "row";
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
var HiddenInputFile = _styledComponents["default"].input(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n visibility: hidden;\n position: absolute;\n width: 0px;\n height: 0px;\n"])));
|
|
547
|
+
|
|
548
|
+
var ButtonContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n ", ";\n"])), function (props) {
|
|
549
|
+
return props.mode === "filedrop" && "padding: 2px 12px 2px 3px";
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
var DropzoneLabel = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: -webkit-box;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n -webkit-line-clamp: 3;\n text-align: center;\n margin-top: 0.5rem;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
553
|
+
return props.disabled ? props.theme.disabledDropLabelFontColor : props.theme.dropLabelFontColor;
|
|
554
|
+
}, function (props) {
|
|
555
|
+
return props.theme.dropLabelFontFamily;
|
|
556
|
+
}, function (props) {
|
|
557
|
+
return props.theme.dropLabelFontSize;
|
|
558
|
+
}, function (props) {
|
|
559
|
+
return props.theme.dropLabelFontWeight;
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
var FiledropLabel = _styledComponents["default"].span(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n margin-right: 1rem;\n"])), function (props) {
|
|
563
|
+
return props.disabled ? props.theme.disabledDropLabelFontColor : props.theme.dropLabelFontColor;
|
|
564
|
+
}, function (props) {
|
|
565
|
+
return props.theme.dropLabelFontFamily;
|
|
566
|
+
}, function (props) {
|
|
567
|
+
return props.theme.dropLabelFontSize;
|
|
568
|
+
}, function (props) {
|
|
569
|
+
return props.theme.dropLabelFontWeight;
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
var Container = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n margin-top: 0.25rem;\n"])));
|
|
573
|
+
|
|
574
|
+
var FileItemContainer = _styledComponents["default"].div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n margin-top: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
575
|
+
return (props.multiple || props.files.length > 1 || props.mode !== "file") && "4px";
|
|
576
|
+
}, function (props) {
|
|
577
|
+
return props.mode === "file" && props.files.length === 1 && !props.multiple && "4px";
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
var ErrorMessage = _styledComponents["default"].div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin-top: 0.25rem;\n"])), function (props) {
|
|
581
|
+
return props.theme.errorMessageFontColor;
|
|
582
|
+
}, function (props) {
|
|
583
|
+
return props.theme.errorMessageFontFamily;
|
|
584
|
+
}, function (props) {
|
|
585
|
+
return props.theme.errorMessageFontSize;
|
|
586
|
+
}, function (props) {
|
|
587
|
+
return props.theme.errorMessageFontWeight;
|
|
588
|
+
}, function (props) {
|
|
589
|
+
return props.theme.errorMessageLineHeight;
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
var _default = DxcFileInput;
|
|
593
|
+
exports["default"] = _default;
|