diginet-core-ui 1.4.39 → 1.4.40
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/.browserslistrc +6 -0
- package/.eslintrc.js +91 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc +32 -0
- package/.storybook/main.js +4 -0
- package/.storybook/manager.js +10 -0
- package/.storybook/preview-head.html +17 -0
- package/.storybook/preview.js +36 -0
- package/.storybook/themeDecorator.js +19 -0
- package/babel.config.json +17 -0
- package/bitbucket-pipelines.yml +18 -0
- package/jsconfig.json +8 -0
- package/package.json +78 -44
- package/package.json.tmp +44 -0
- package/postcss.config.js +9 -0
- package/readme.md +5 -0
- package/src/assets/images/menu/dhr/MHRP15N0002.svg +17 -0
- package/src/assets/images/menu/dhr/MHRP15N0003.svg +26 -0
- package/src/components/accordion/context.js +5 -0
- package/src/components/accordion/details.js +80 -0
- package/src/components/accordion/group.js +140 -0
- package/src/components/accordion/index.js +207 -0
- package/src/components/accordion/index.stories.js +278 -0
- package/src/components/accordion/summary.js +380 -0
- package/src/components/alert/index.js +312 -0
- package/src/components/alert/index.stories.js +109 -0
- package/src/components/alert/notify.js +179 -0
- package/src/components/avatar/index.js +472 -0
- package/src/components/avatar/index.stories.js +80 -0
- package/src/components/badge/index.js +307 -0
- package/src/components/badge/index.stories.js +187 -0
- package/src/components/breadcrumb/index.js +280 -0
- package/src/components/breadcrumb/index.stories.js +69 -0
- package/src/components/button/button.stories.js +34 -0
- package/src/components/button/buttonIcon.stories.js +36 -0
- package/src/components/button/buttonMore.stories.js +58 -0
- package/src/components/button/icon.js +468 -0
- package/src/components/button/index.js +582 -0
- package/src/components/button/more.js +249 -0
- package/src/components/button/ripple-effect.js +95 -0
- package/src/components/button/sample.stories.js +194 -0
- package/src/components/card/body.js +73 -0
- package/src/components/card/extra.js +73 -0
- package/src/components/card/footer.js +73 -0
- package/src/components/card/header.js +74 -0
- package/src/components/card/index.js +256 -0
- package/src/components/card/index.stories.js +242 -0
- package/src/components/chart/Pie/Circle.js +68 -0
- package/src/components/chart/Pie/Sector.js +134 -0
- package/src/components/chart/Pie/Sectors.js +96 -0
- package/src/components/chart/Pie/index.js +312 -0
- package/src/components/chart/Pie/index.stories.js +77 -0
- package/src/components/chart/Pie-v2/Circle.js +62 -0
- package/src/components/chart/Pie-v2/Sector.js +128 -0
- package/src/components/chart/Pie-v2/Sectors.js +353 -0
- package/src/components/chart/Pie-v2/index.js +499 -0
- package/src/components/chart/Pie-v2/index.stories.js +77 -0
- package/src/components/chart/bar/Axis.js +67 -0
- package/src/components/chart/bar/Bar.js +365 -0
- package/src/components/chart/bar/Grid.js +111 -0
- package/src/components/chart/bar/Labels.js +193 -0
- package/src/components/chart/bar/Points.js +112 -0
- package/src/components/chart/bar/index.js +170 -0
- package/src/components/chart/bar/index.stories.js +174 -0
- package/src/components/chart/bar-v2/Axis.js +67 -0
- package/src/components/chart/bar-v2/Bar.js +372 -0
- package/src/components/chart/bar-v2/Grid.js +111 -0
- package/src/components/chart/bar-v2/Labels.js +193 -0
- package/src/components/chart/bar-v2/Points.js +112 -0
- package/src/components/chart/bar-v2/index.js +170 -0
- package/src/components/chart/bar-v2/index.stories.js +174 -0
- package/src/components/chart/line/Axis.js +68 -0
- package/src/components/chart/line/Grid.js +98 -0
- package/src/components/chart/line/Labels.js +191 -0
- package/src/components/chart/line/Path.js +155 -0
- package/src/components/chart/line/Point.js +358 -0
- package/src/components/chart/line/Title.js +50 -0
- package/src/components/chart/line/index.js +202 -0
- package/src/components/chart/line/index.stories.js +148 -0
- package/src/components/chart/line-v2/Axis.js +66 -0
- package/src/components/chart/line-v2/Grid.js +111 -0
- package/src/components/chart/line-v2/Labels.js +190 -0
- package/src/components/chart/line-v2/Path.js +154 -0
- package/src/components/chart/line-v2/Point.js +336 -0
- package/src/components/chart/line-v2/Title.js +50 -0
- package/src/components/chart/line-v2/index.js +172 -0
- package/src/components/chart/line-v2/index.stories.js +148 -0
- package/src/components/check-text/index.js +168 -0
- package/src/components/check-text/index.stories.js +50 -0
- package/src/components/check-text/interview-confirmation.js +169 -0
- package/src/components/check-text/interview-status.js +142 -0
- package/src/components/chip/attach.js +156 -0
- package/src/components/chip/index.js +366 -0
- package/src/components/chip/index.stories.js +190 -0
- package/src/components/collapse/index.js +104 -0
- package/src/components/collapse/index.stories.js +35 -0
- package/src/components/dialogs/colors.js +13 -0
- package/src/components/divider/index.js +87 -0
- package/src/components/divider/index.stories.js +52 -0
- package/src/components/form-control/attachment/index.js +1770 -0
- package/src/components/form-control/attachment/index.stories.js +106 -0
- package/src/components/form-control/calendar/function.js +959 -0
- package/src/components/form-control/calendar/index.js +413 -0
- package/src/components/form-control/calendar/index.stories.js +40 -0
- package/src/components/form-control/calendar/range.js +329 -0
- package/src/components/form-control/checkbox/index.js +382 -0
- package/src/components/form-control/checkbox/index.stories.js +110 -0
- package/src/components/form-control/control/index.js +99 -0
- package/src/components/form-control/date-input/DateField.js +191 -0
- package/src/components/form-control/date-input/index.js +315 -0
- package/src/components/form-control/date-input/index.stories.js +96 -0
- package/src/components/form-control/date-input/useDateInputState.js +138 -0
- package/src/components/form-control/date-input/useIsFocused.js +25 -0
- package/src/components/form-control/date-input/useKeyboardInputEvent.js +45 -0
- package/src/components/form-control/date-input/utils.js +293 -0
- package/src/components/form-control/date-picker/index.js +429 -0
- package/src/components/form-control/date-picker/index.stories.js +141 -0
- package/src/components/form-control/date-range-picker/index.js +1349 -0
- package/src/components/form-control/date-range-picker/index.stories.js +43 -0
- package/src/components/form-control/dropdown/index.js +1858 -0
- package/src/components/form-control/dropdown/index.stories.js +222 -0
- package/src/components/form-control/dropdown-box/index.js +271 -0
- package/src/components/form-control/dropdown-box/index.stories.js +103 -0
- package/src/components/form-control/form/context.js +5 -0
- package/src/components/form-control/form/index.js +39 -0
- package/src/components/form-control/form-group/index.js +131 -0
- package/src/components/form-control/form-group/index.stories.js +57 -0
- package/src/components/form-control/helper-text/index.js +92 -0
- package/src/components/form-control/helper-text/index.stories.js +29 -0
- package/src/components/form-control/input-base/UncontrolledInputBase.js +499 -0
- package/src/components/form-control/input-base/index.js +706 -0
- package/src/components/form-control/input-base/index.stories.js +69 -0
- package/src/components/form-control/label/index.js +127 -0
- package/src/components/form-control/label/index.stories.js +69 -0
- package/src/components/form-control/money-input/index.js +622 -0
- package/src/components/form-control/money-input/index.stories.js +42 -0
- package/src/components/form-control/number-input/index.js +582 -0
- package/src/components/form-control/number-input/index.stories.js +53 -0
- package/src/components/form-control/number-input/index2.js +531 -0
- package/src/components/form-control/password-input/index.js +259 -0
- package/src/components/form-control/password-input/index.stories.js +32 -0
- package/src/components/form-control/phone-input/index.js +382 -0
- package/src/components/form-control/phone-input/index.stories.js +39 -0
- package/src/components/form-control/radio/index.js +241 -0
- package/src/components/form-control/radio/index.stories.js +51 -0
- package/src/components/form-control/text-input/index.js +254 -0
- package/src/components/form-control/text-input/index.stories.js +60 -0
- package/src/components/form-control/time-picker/index.js +782 -0
- package/src/components/form-control/time-picker/index.mdx +49 -0
- package/src/components/form-control/time-picker/index.stories.js +69 -0
- package/src/components/form-control/time-picker/swiper.js +568 -0
- package/src/components/form-control/time-picker/v2/index.js +785 -0
- package/src/components/form-control/time-picker/v2/index.stories.js +43 -0
- package/src/components/form-control/toggle/index.js +247 -0
- package/src/components/form-control/toggle/index.stories.js +51 -0
- package/src/components/form-view/helper-text.js +30 -0
- package/src/components/form-view/index.js +100 -0
- package/src/components/form-view/index.stories.js +25 -0
- package/src/components/form-view/input.js +134 -0
- package/src/components/form-view/label.js +39 -0
- package/src/components/grid/Col.js +89 -0
- package/src/components/grid/Container.js +99 -0
- package/src/components/grid/Row.js +97 -0
- package/src/components/grid/context.js +5 -0
- package/src/components/grid/index.js +323 -0
- package/src/components/grid/index.stories.js +523 -0
- package/src/components/image/index.js +191 -0
- package/src/components/image/index.stories.js +53 -0
- package/src/components/index.js +157 -0
- package/src/components/list/index.stories.js +261 -0
- package/src/components/list/list-item-action.js +94 -0
- package/src/components/list/list-item-icon.js +89 -0
- package/src/components/list/list-item-text.js +69 -0
- package/src/components/list/list-item.js +131 -0
- package/src/components/list/list.js +164 -0
- package/src/components/list/sub-header.js +79 -0
- package/src/components/modal/body.js +84 -0
- package/src/components/modal/context.js +5 -0
- package/src/components/modal/footer.js +90 -0
- package/src/components/modal/header.js +145 -0
- package/src/components/modal/index.js +59 -0
- package/src/components/modal/index.stories.js +95 -0
- package/src/components/modal/modal.js +330 -0
- package/src/components/others/date/index.stories.js +217 -0
- package/src/components/others/extra/index.js +129 -0
- package/src/components/others/extra/index.mdx +39 -0
- package/src/components/others/extra/index.stories.js +17 -0
- package/src/components/others/import/index.js +66 -0
- package/src/components/others/import/index.stories.js +70 -0
- package/src/components/others/locale/index.stories.js +42 -0
- package/src/components/others/option-wrapper/index.js +34 -0
- package/src/components/others/scrollbar/index.js +106 -0
- package/src/components/others/scrollbar/index.stories.js +68 -0
- package/src/components/others/validate/index.stories.js +113 -0
- package/src/components/paging/index.stories.js +76 -0
- package/src/components/paging/page-info.js +637 -0
- package/src/components/paging/page-selector.js +437 -0
- package/src/components/paper/index.js +128 -0
- package/src/components/paper/index.stories.js +37 -0
- package/src/components/popover/body.js +98 -0
- package/src/components/popover/footer.js +96 -0
- package/src/components/popover/header.js +99 -0
- package/src/components/popover/index.js +718 -0
- package/src/components/popover/index.stories.js +189 -0
- package/src/components/popup/danger_popup.js +196 -0
- package/src/components/popup/index.js +464 -0
- package/src/components/popup/v2/index.js +556 -0
- package/src/components/popup/v2/index.stories.js +113 -0
- package/src/components/progress/circular.js +326 -0
- package/src/components/progress/index.stories.js +51 -0
- package/src/components/progress/linear.js +361 -0
- package/src/components/rating/index.js +309 -0
- package/src/components/rating/index.stories.js +78 -0
- package/src/components/skeleton/index.js +79 -0
- package/src/components/skeleton/index.stories.js +29 -0
- package/src/components/slider/index.stories.js +50 -0
- package/src/components/slider/slider-container.js +415 -0
- package/src/components/slider/slider-item.js +222 -0
- package/src/components/status/index.js +145 -0
- package/src/components/status/index.stories.js +71 -0
- package/src/components/tab/context.js +5 -0
- package/src/components/tab/index.stories.js +123 -0
- package/src/components/tab/tab-container.js +109 -0
- package/src/components/tab/tab-header.js +177 -0
- package/src/components/tab/tab-panel.js +101 -0
- package/src/components/tab/tab.js +249 -0
- package/src/components/tooltip/index.js +580 -0
- package/src/components/tooltip/index.stories.js +282 -0
- package/src/components/tooltip/portal.js +10 -0
- package/src/components/transfer/index.js +555 -0
- package/src/components/transfer/index.stories.js +53 -0
- package/src/components/tree-view/index.js +1085 -0
- package/src/components/tree-view/index.stories.js +347 -0
- package/src/components/typography/index.js +331 -0
- package/src/components/typography/index.stories.js +166 -0
- package/src/docs/changelog/changelog.md +1354 -0
- package/src/docs/changelog/index.stories.js +20 -0
- package/src/global/index.js +247 -0
- package/src/icons/basic.js +5930 -0
- package/src/icons/basic.stories.js +178 -0
- package/src/icons/effect.js +167 -0
- package/src/icons/general/clock/clock.js +16 -0
- package/src/icons/general/color-handler/background.js +34 -0
- package/src/icons/general/color-handler/text.js +34 -0
- package/src/icons/general/emoji/emoji.js +27 -0
- package/src/icons/general/font-properties/bold.js +17 -0
- package/src/icons/general/font-properties/font-family.js +27 -0
- package/src/icons/general/font-properties/font-size.js +24 -0
- package/src/icons/general/font-properties/italic.js +17 -0
- package/src/icons/general/font-properties/underline.js +26 -0
- package/src/icons/general/hyperlink/hyperlink.js +33 -0
- package/src/icons/general/indent/decrease.js +54 -0
- package/src/icons/general/indent/increase.js +54 -0
- package/src/icons/general/index.js +21 -0
- package/src/icons/general/index.mdx +68 -0
- package/src/icons/general/list/bullets.js +76 -0
- package/src/icons/general/list/numbering.js +69 -0
- package/src/icons/general/picture/picture.js +17 -0
- package/src/icons/general/steps/redo.js +17 -0
- package/src/icons/general/steps/undo.js +17 -0
- package/src/icons/general/text-align/center.js +17 -0
- package/src/icons/general/text-align/justify.js +17 -0
- package/src/icons/general/text-align/left.js +17 -0
- package/src/icons/general/text-align/right.js +17 -0
- package/src/icons/index.js +3 -0
- package/src/icons/index.stories.js +22 -0
- package/src/icons/menu/dhr.js +2625 -0
- package/src/icons/menu/erp.js +513 -0
- package/src/icons/menu/index.js +6 -0
- package/src/icons/menu/index.stories.js +107 -0
- package/src/icons/menu/v2/index.js +77 -0
- package/src/icons/menu/v2/index.stories.js +426 -0
- package/src/locale/index.js +13 -0
- package/src/scss/styles.scss +10 -0
- package/src/styles/animation.js +930 -0
- package/src/styles/animations.js +13 -0
- package/src/styles/color-helper.js +364 -0
- package/src/styles/colors.js +504 -0
- package/src/styles/colors.stories.js +105 -0
- package/src/styles/font.js +26 -0
- package/src/styles/general.js +824 -0
- package/src/styles/sx/index.js +35 -0
- package/src/styles/typography.js +181 -0
- package/src/styles/utils.js +35 -0
- package/src/theme/createBreakpoints.js +95 -0
- package/src/theme/createSpacing.js +12 -0
- package/src/theme/createTheme.js +29 -0
- package/src/theme/createZIndex.js +10 -0
- package/src/theme/docs/breakpoints.md +242 -0
- package/src/theme/docs/colors.md +64 -0
- package/src/theme/docs/components.md +32 -0
- package/src/theme/docs/darkMode.md +20 -0
- package/src/theme/docs/spacing.md +52 -0
- package/src/theme/docs/theming.md +69 -0
- package/src/theme/docs/zIndex.md +27 -0
- package/src/theme/index.js +15 -0
- package/src/theme/make-styles.js +32 -0
- package/src/theme/settings.js +816 -0
- package/src/theme/stories/breakpoints.stories.js +20 -0
- package/src/theme/stories/colors.stories.js +20 -0
- package/src/theme/stories/components.stories.js +20 -0
- package/src/theme/stories/darkMode.stories.js +20 -0
- package/src/theme/stories/spacing.stories.js +20 -0
- package/src/theme/stories/theming.stories.js +20 -0
- package/src/theme/stories/zIndex.stories.js +20 -0
- package/src/theme/theme-provider.js +101 -0
- package/src/theme/theme.js +57 -0
- package/src/theme/use-classes.js +19 -0
- package/src/theme/utils/getThemeProps.js +11 -0
- package/src/theme/utils/resolveProps.js +16 -0
- package/src/theme/utils/useThemeProps.js +8 -0
- package/src/utils/array/array.js +197 -0
- package/src/utils/classNames/index.js +28 -0
- package/src/utils/classNames/index.stories.js +61 -0
- package/src/utils/console.js +30 -0
- package/src/utils/date.js +391 -0
- package/src/utils/error/error.js +65 -0
- package/src/utils/error/errors.js +250 -0
- package/src/utils/getFileType.js +24 -0
- package/src/utils/handleBreakpoints.js +27 -0
- package/src/utils/hexToRGBA/index.js +25 -0
- package/src/utils/hexToRGBA/index.stories.js +43 -0
- package/src/utils/index.js +40 -0
- package/src/utils/intersectionObserver.js +45 -0
- package/src/utils/isMobile/index.js +22 -0
- package/src/utils/isMobile/index.stories.js +49 -0
- package/src/utils/isUndefined.js +3 -0
- package/src/utils/iterator.js +45 -0
- package/src/utils/map-parent.js +49 -0
- package/src/utils/object/deepmerge.js +129 -0
- package/src/utils/object/extend.js +55 -0
- package/src/utils/object/object.js +61 -0
- package/src/utils/parseHTML.js +20 -0
- package/src/utils/promisify.js +37 -0
- package/src/utils/randomString.js +22 -0
- package/src/utils/refMethodType.js +9 -0
- package/src/utils/refType.js +5 -0
- package/src/utils/remove-unicode.js +13 -0
- package/src/utils/render-portal.js +87 -0
- package/src/utils/renderHTML.js +17 -0
- package/src/utils/renderIcon.js +41 -0
- package/src/utils/sb-template.js +115 -0
- package/src/utils/storybook/index.js +1 -0
- package/src/utils/storybook/refArgTypes.js +46 -0
- package/src/utils/string/capitalize.js +6 -0
- package/src/utils/string/capitalizeSentenceCase.js +9 -0
- package/src/utils/string/string.js +83 -0
- package/src/utils/type.js +121 -0
- package/src/utils/updatePosition.js +27 -0
- package/src/utils/useControlled/index.js +23 -0
- package/src/utils/useDelayUnmount.js +17 -0
- package/src/utils/useElementSize.js +59 -0
- package/src/utils/useEventListener.js +54 -0
- package/src/utils/useInput.js +39 -0
- package/src/utils/useMediaQuery/index.js +50 -0
- package/src/utils/useMediaQuery/index.stories.js +55 -0
- package/src/utils/useOnClickOutside.js +28 -0
- package/src/utils/usePortal.js +54 -0
- package/src/utils/validate.js +135 -0
- package/components/accordion/context.js +0 -6
- package/components/accordion/details.js +0 -76
- package/components/accordion/group.js +0 -135
- package/components/accordion/index.js +0 -178
- package/components/accordion/summary.js +0 -324
- package/components/alert/index.js +0 -257
- package/components/alert/notify.js +0 -140
- package/components/avatar/index.js +0 -388
- package/components/badge/index.js +0 -231
- package/components/breadcrumb/index.js +0 -220
- package/components/button/icon.js +0 -357
- package/components/button/index.js +0 -444
- package/components/button/more.js +0 -210
- package/components/button/ripple-effect.js +0 -81
- package/components/card/body.js +0 -76
- package/components/card/extra.js +0 -76
- package/components/card/footer.js +0 -76
- package/components/card/header.js +0 -80
- package/components/card/index.js +0 -203
- package/components/chart/Pie/Circle.js +0 -50
- package/components/chart/Pie/Sector.js +0 -124
- package/components/chart/Pie/Sectors.js +0 -81
- package/components/chart/Pie/index.js +0 -277
- package/components/chart/Pie-v2/Circle.js +0 -48
- package/components/chart/Pie-v2/Sector.js +0 -108
- package/components/chart/Pie-v2/Sectors.js +0 -204
- package/components/chart/Pie-v2/index.js +0 -488
- package/components/chart/bar/Axis.js +0 -67
- package/components/chart/bar/Bar.js +0 -344
- package/components/chart/bar/Grid.js +0 -97
- package/components/chart/bar/Labels.js +0 -162
- package/components/chart/bar/Points.js +0 -94
- package/components/chart/bar/index.js +0 -161
- package/components/chart/bar-v2/Axis.js +0 -67
- package/components/chart/bar-v2/Bar.js +0 -354
- package/components/chart/bar-v2/Grid.js +0 -97
- package/components/chart/bar-v2/Labels.js +0 -162
- package/components/chart/bar-v2/Points.js +0 -94
- package/components/chart/bar-v2/index.js +0 -161
- package/components/chart/line/Axis.js +0 -68
- package/components/chart/line/Grid.js +0 -99
- package/components/chart/line/Labels.js +0 -160
- package/components/chart/line/Path.js +0 -154
- package/components/chart/line/Point.js +0 -343
- package/components/chart/line/Title.js +0 -52
- package/components/chart/line/index.js +0 -199
- package/components/chart/line-v2/Axis.js +0 -66
- package/components/chart/line-v2/Grid.js +0 -97
- package/components/chart/line-v2/Labels.js +0 -160
- package/components/chart/line-v2/Path.js +0 -153
- package/components/chart/line-v2/Point.js +0 -326
- package/components/chart/line-v2/Title.js +0 -52
- package/components/chart/line-v2/index.js +0 -165
- package/components/check-text/index.js +0 -155
- package/components/check-text/interview-confirmation.js +0 -171
- package/components/check-text/interview-status.js +0 -137
- package/components/chip/attach.js +0 -167
- package/components/chip/index.js +0 -275
- package/components/collapse/index.js +0 -93
- package/components/dialogs/colors.js +0 -13
- package/components/divider/index.js +0 -89
- package/components/form-control/attachment/index.js +0 -1537
- package/components/form-control/calendar/function.js +0 -752
- package/components/form-control/calendar/index.js +0 -317
- package/components/form-control/calendar/range.js +0 -291
- package/components/form-control/checkbox/index.js +0 -329
- package/components/form-control/control/index.js +0 -91
- package/components/form-control/date-input/DateField.js +0 -187
- package/components/form-control/date-input/index.js +0 -292
- package/components/form-control/date-input/useDateInputState.js +0 -129
- package/components/form-control/date-input/useIsFocused.js +0 -20
- package/components/form-control/date-input/useKeyboardInputEvent.js +0 -45
- package/components/form-control/date-input/utils.js +0 -290
- package/components/form-control/date-picker/index.js +0 -357
- package/components/form-control/date-range-picker/index.js +0 -1183
- package/components/form-control/dropdown/index.js +0 -1624
- package/components/form-control/dropdown-box/index.js +0 -238
- package/components/form-control/form/context.js +0 -5
- package/components/form-control/form/index.js +0 -40
- package/components/form-control/form-group/index.js +0 -117
- package/components/form-control/helper-text/index.js +0 -88
- package/components/form-control/input-base/UncontrolledInputBase.js +0 -450
- package/components/form-control/input-base/index.js +0 -646
- package/components/form-control/label/index.js +0 -117
- package/components/form-control/money-input/index.js +0 -513
- package/components/form-control/number-input/index.js +0 -582
- package/components/form-control/number-input/index2.js +0 -481
- package/components/form-control/password-input/index.js +0 -242
- package/components/form-control/phone-input/index.js +0 -364
- package/components/form-control/radio/index.js +0 -224
- package/components/form-control/text-input/index.js +0 -239
- package/components/form-control/time-picker/index.js +0 -781
- package/components/form-control/time-picker/swiper.js +0 -540
- package/components/form-control/time-picker/v2/index.js +0 -809
- package/components/form-control/toggle/index.js +0 -222
- package/components/form-view/helper-text.js +0 -33
- package/components/form-view/index.js +0 -95
- package/components/form-view/input.js +0 -117
- package/components/form-view/label.js +0 -37
- package/components/grid/Col.js +0 -91
- package/components/grid/Container.js +0 -85
- package/components/grid/Row.js +0 -81
- package/components/grid/context.js +0 -3
- package/components/grid/index.js +0 -251
- package/components/image/index.js +0 -170
- package/components/index.js +0 -156
- package/components/list/list-item-action.js +0 -82
- package/components/list/list-item-icon.js +0 -71
- package/components/list/list-item-text.js +0 -56
- package/components/list/list-item.js +0 -108
- package/components/list/list.js +0 -149
- package/components/list/sub-header.js +0 -63
- package/components/modal/body.js +0 -74
- package/components/modal/context.js +0 -6
- package/components/modal/footer.js +0 -78
- package/components/modal/header.js +0 -128
- package/components/modal/index.js +0 -63
- package/components/modal/modal.js +0 -292
- package/components/others/extra/index.js +0 -116
- package/components/others/import/index.js +0 -71
- package/components/others/option-wrapper/index.js +0 -39
- package/components/others/scrollbar/index.js +0 -94
- package/components/paging/page-info.js +0 -582
- package/components/paging/page-selector.js +0 -381
- package/components/paper/index.js +0 -112
- package/components/popover/body.js +0 -86
- package/components/popover/footer.js +0 -84
- package/components/popover/header.js +0 -88
- package/components/popover/index.js +0 -663
- package/components/popup/danger_popup.js +0 -189
- package/components/popup/index.js +0 -414
- package/components/popup/v2/index.js +0 -398
- package/components/progress/circular.js +0 -296
- package/components/progress/linear.js +0 -324
- package/components/rating/index.js +0 -243
- package/components/skeleton/index.js +0 -79
- package/components/slider/slider-container.js +0 -340
- package/components/slider/slider-item.js +0 -205
- package/components/status/index.js +0 -111
- package/components/tab/context.js +0 -3
- package/components/tab/tab-container.js +0 -100
- package/components/tab/tab-header.js +0 -160
- package/components/tab/tab-panel.js +0 -91
- package/components/tab/tab.js +0 -210
- package/components/tooltip/index.js +0 -522
- package/components/tooltip/portal.js +0 -11
- package/components/transfer/index.js +0 -434
- package/components/tree-view/index.js +0 -1017
- package/components/typography/index.js +0 -193
- package/css/styles.css +0 -1
- package/css/styles.css.map +0 -1
- package/global/index.js +0 -194
- package/icons/basic.js +0 -7864
- package/icons/effect.js +0 -131
- package/icons/general/clock/clock.js +0 -20
- package/icons/general/color-handler/background.js +0 -40
- package/icons/general/color-handler/text.js +0 -40
- package/icons/general/emoji/emoji.js +0 -34
- package/icons/general/font-properties/bold.js +0 -20
- package/icons/general/font-properties/font-family.js +0 -34
- package/icons/general/font-properties/font-size.js +0 -26
- package/icons/general/font-properties/italic.js +0 -20
- package/icons/general/font-properties/underline.js +0 -30
- package/icons/general/hyperlink/hyperlink.js +0 -37
- package/icons/general/indent/decrease.js +0 -54
- package/icons/general/indent/increase.js +0 -54
- package/icons/general/index.js +0 -21
- package/icons/general/list/bullets.js +0 -76
- package/icons/general/list/numbering.js +0 -70
- package/icons/general/picture/picture.js +0 -20
- package/icons/general/steps/redo.js +0 -20
- package/icons/general/steps/undo.js +0 -20
- package/icons/general/text-align/center.js +0 -20
- package/icons/general/text-align/justify.js +0 -20
- package/icons/general/text-align/left.js +0 -20
- package/icons/general/text-align/right.js +0 -20
- package/icons/index.js +0 -3
- package/icons/menu/dhr.js +0 -2442
- package/icons/menu/erp.js +0 -491
- package/icons/menu/index.js +0 -5
- package/icons/menu/v2/index.js +0 -71
- package/locale/index.js +0 -11
- package/styles/animation.js +0 -848
- package/styles/animations.js +0 -13
- package/styles/color-helper.js +0 -343
- package/styles/colors.js +0 -476
- package/styles/font.js +0 -24
- package/styles/general.js +0 -568
- package/styles/sx/index.js +0 -28
- package/styles/typography.js +0 -156
- package/styles/utils.js +0 -35
- package/theme/createBreakpoints.js +0 -82
- package/theme/createSpacing.js +0 -10
- package/theme/createTheme.js +0 -26
- package/theme/createZIndex.js +0 -9
- package/theme/index.js +0 -14
- package/theme/make-styles.js +0 -30
- package/theme/settings.js +0 -861
- package/theme/theme-provider.js +0 -102
- package/theme/theme.js +0 -57
- package/theme/use-classes.js +0 -15
- package/theme/utils/getThemeProps.js +0 -12
- package/theme/utils/resolveProps.js +0 -17
- package/theme/utils/useThemeProps.js +0 -14
- package/utils/array/array.js +0 -169
- package/utils/classNames/index.js +0 -25
- package/utils/console.js +0 -27
- package/utils/date.js +0 -401
- package/utils/error/error.js +0 -53
- package/utils/error/errors.js +0 -200
- package/utils/getFileType.js +0 -23
- package/utils/handleBreakpoints.js +0 -25
- package/utils/hexToRGBA/index.js +0 -23
- package/utils/index.js +0 -38
- package/utils/intersectionObserver.js +0 -37
- package/utils/isMobile/index.js +0 -21
- package/utils/isUndefined.js +0 -2
- package/utils/iterator.js +0 -36
- package/utils/map-parent.js +0 -46
- package/utils/object/deepmerge.js +0 -103
- package/utils/object/extend.js +0 -47
- package/utils/object/object.js +0 -54
- package/utils/parseHTML.js +0 -18
- package/utils/promisify.js +0 -34
- package/utils/randomString.js +0 -26
- package/utils/refMethodType.js +0 -6
- package/utils/refType.js +0 -5
- package/utils/remove-unicode.js +0 -5
- package/utils/render-portal.js +0 -87
- package/utils/renderHTML.js +0 -18
- package/utils/renderIcon.js +0 -53
- package/utils/sb-template.js +0 -113
- package/utils/storybook/index.js +0 -1
- package/utils/storybook/refArgTypes.js +0 -41
- package/utils/string/capitalize.js +0 -3
- package/utils/string/capitalizeSentenceCase.js +0 -8
- package/utils/string/string.js +0 -60
- package/utils/type.js +0 -69
- package/utils/updatePosition.js +0 -35
- package/utils/useControlled/index.js +0 -14
- package/utils/useDelayUnmount.js +0 -15
- package/utils/useElementSize.js +0 -55
- package/utils/useEventListener.js +0 -51
- package/utils/useInput.js +0 -33
- package/utils/useMediaQuery/index.js +0 -44
- package/utils/useOnClickOutside.js +0 -21
- package/utils/usePortal.js +0 -49
- package/utils/validate.js +0 -135
- /package/{assets → src/assets}/avatar/default.svg +0 -0
- /package/{assets → src/assets}/fonts/SF-Pro-Display-Bold.otf +0 -0
- /package/{assets → src/assets}/fonts/SF-Pro-Display-Medium.otf +0 -0
- /package/{assets → src/assets}/fonts/SF-Pro-Display-Regular.otf +0 -0
- /package/{assets → src/assets}/fonts/text-security-disc-compat.eot +0 -0
- /package/{assets → src/assets}/fonts/text-security-disc-compat.ttf +0 -0
- /package/{assets → src/assets}/fonts/text-security-disc-compat.woff2 +0 -0
- /package/{assets → src/assets}/fonts/text-security-disc.woff2 +0 -0
- /package/{assets → src/assets}/image/default.png +0 -0
- /package/{assets → src/assets}/images/icons/wifi.svg +0 -0
- /package/{assets → src/assets}/images/menu/bem/WA3F0100.svg +0 -0
- /package/{assets → src/assets}/images/menu/bem/WA3F1025.svg +0 -0
- /package/{assets → src/assets}/images/menu/bem/WA3F2000.svg +0 -0
- /package/{assets → src/assets}/images/menu/bem/WA3F2020.svg +0 -0
- /package/{assets → src/assets}/images/menu/bem/WA3F2030.svg +0 -0
- /package/{assets → src/assets}/images/menu/bem/WA3F2040.svg +0 -0
- /package/{assets → src/assets}/images/menu/bem/WA3F2100.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/ALL.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D00.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D09.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D13.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D15.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D21.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D25.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D29.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D38.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D39.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D51.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D52.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D77.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D84.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/D89.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/Default.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR21N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR29N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR29N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR29N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR29N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR29N0011.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR29N0012.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR29N0013.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR75N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR75N0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR75N0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR75N0008.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR75N0009.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR75N0010.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR89N0014.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MAHR89N0015.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM00N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM00N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM00N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM00N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM00N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM00N0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM00N0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N1010.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N1015.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N1020.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N1025.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N1030.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N1035.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N1040.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM09N1400.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM13N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM13N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM13N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM13N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM15N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM25N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM29N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM29N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM29N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM29N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM29N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM29N0015.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM38N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM38N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM38N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0012.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0013.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0014.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0015.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0016.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0017.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0018.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0019.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0020.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0021.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0022.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM39N0023.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM51N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM51N0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM51N0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM77N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM77N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM82N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM82N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM84N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM84N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM89N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRM89N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP00N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0008.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0009.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0010.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0011.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0012.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0013.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0014.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0015.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0016.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0017.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0018.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0019.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0020.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0021.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0022.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0023.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0024.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0025.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0026.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0027.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0028.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0029.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0030.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0031.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0032.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0033.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0034.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP09N0035.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP13N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP13N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP13N0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP21N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP21N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP25L0101.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP25L0501.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP25N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP25N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP25N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP25N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP25N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0008.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0009.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0010.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0011.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0012.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0013.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0014.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0016.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0017.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0018.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0019.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0020.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0021.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0022.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0023.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0026.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0027.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0028.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0029.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP29N0030.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP38N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP38N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0008.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0009.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0010.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0011.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0013.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0014.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0015.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0017.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0018.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0019.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0020.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N0021.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP39N1222.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP51N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP51N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP51N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP51N0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP52N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP52N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP52N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP75N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP75N0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP75N0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP75N0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP75N0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP75N0008.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP77N0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP77N0008.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP77N0009.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP77N0010.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP77N0011.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP89N1000.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/MHRP89N1001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/TASK.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W00F0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W00F0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W00F0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W00F0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W00F0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2000-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2000.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2002-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2005-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2020-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2022-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2150-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2152-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2160-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W09F2162-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W29F4006-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W75F2260-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W75F2261-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W75F3005-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W75F4070-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W75F4071-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W75F4100-WEB5.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W77F1011.svg +0 -0
- /package/{assets → src/assets}/images/menu/dhr/W77F1013.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/W00F0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/W00F0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/W00F0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/W00F0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76APP0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76APP0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76LIS0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76LIS0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76LIS0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76LIS0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76LIS0005.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76LIS0006.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76LIS0007.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76REQ0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76REQ0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76REQ0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WEO76TRA0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WTM76ACC0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WTM76INF0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WTM76PRO0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/eo/WTM76SYS0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/D05.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/D06.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/D90R.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/DBC.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W00F0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W00F0002.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W00F0003.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W00F0004.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F0001N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F0004N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F0006N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F0007N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F0008N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F0011N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F0013N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W05F4000N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W06F0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W06F0001N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W06F0004N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W06F0005N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W06F0006N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W06F0008N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W94F1000N0000.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/W94F1000N0001.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/WA3F1025.svg +0 -0
- /package/{assets → src/assets}/images/menu/erp/WA3F2100.svg +0 -0
- /package/{assets → src/assets}/storybook/avatar01.svg +0 -0
- /package/{assets → src/assets}/storybook/cover01.svg +0 -0
|
@@ -0,0 +1,1770 @@
|
|
|
1
|
+
/* eslint-disable no-prototype-builtins */
|
|
2
|
+
/** @jsxRuntime classic */
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { css, jsx } from '@emotion/core';
|
|
5
|
+
import {
|
|
6
|
+
ButtonIcon,
|
|
7
|
+
Grid,
|
|
8
|
+
HelperText,
|
|
9
|
+
Icon,
|
|
10
|
+
Image,
|
|
11
|
+
Label,
|
|
12
|
+
LinearProgress,
|
|
13
|
+
List,
|
|
14
|
+
ListItem,
|
|
15
|
+
ListItemText,
|
|
16
|
+
ModalSample,
|
|
17
|
+
Notify,
|
|
18
|
+
Popover,
|
|
19
|
+
Popup,
|
|
20
|
+
ScrollBar,
|
|
21
|
+
Slider,
|
|
22
|
+
SliderItem,
|
|
23
|
+
Typography,
|
|
24
|
+
} from 'components';
|
|
25
|
+
import { getGlobal } from 'global';
|
|
26
|
+
import PropTypes from 'prop-types';
|
|
27
|
+
import { forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
28
|
+
import {
|
|
29
|
+
aspectSquare,
|
|
30
|
+
bgColor,
|
|
31
|
+
border,
|
|
32
|
+
borderDashed,
|
|
33
|
+
borderRadius4px,
|
|
34
|
+
borderRadius50,
|
|
35
|
+
borderRight,
|
|
36
|
+
bottom,
|
|
37
|
+
boxBorder,
|
|
38
|
+
cursorPointer,
|
|
39
|
+
displayFlex,
|
|
40
|
+
displayInlineBlock,
|
|
41
|
+
displayNone,
|
|
42
|
+
flexCol,
|
|
43
|
+
floatRight,
|
|
44
|
+
itemsCenter,
|
|
45
|
+
justifyBetween,
|
|
46
|
+
justifyCenter,
|
|
47
|
+
justifyEnd,
|
|
48
|
+
justifyStart,
|
|
49
|
+
left,
|
|
50
|
+
overflowHidden,
|
|
51
|
+
parseHeight,
|
|
52
|
+
parseMaxWidth,
|
|
53
|
+
parseMinHeight,
|
|
54
|
+
parseMinWidth,
|
|
55
|
+
parseWidth,
|
|
56
|
+
parseWidthHeight,
|
|
57
|
+
positionAbsolute,
|
|
58
|
+
positionRelative,
|
|
59
|
+
textCenter,
|
|
60
|
+
textColor,
|
|
61
|
+
textLeft,
|
|
62
|
+
textRight,
|
|
63
|
+
top,
|
|
64
|
+
truncate,
|
|
65
|
+
userSelectNone,
|
|
66
|
+
} from 'styles/general';
|
|
67
|
+
import { useTheme } from 'theme';
|
|
68
|
+
import useThemeProps from 'theme/utils/useThemeProps';
|
|
69
|
+
import { classNames, getFileType, getProp, date as moment } from 'utils';
|
|
70
|
+
|
|
71
|
+
const oldAttached = [];
|
|
72
|
+
const allNewAttached = new FormData();
|
|
73
|
+
const attached = []; // attached = [...dataState, ...newDataState]
|
|
74
|
+
const chosenItems = [];
|
|
75
|
+
|
|
76
|
+
const getType = data => {
|
|
77
|
+
if (!data) return null;
|
|
78
|
+
if (data?.type) {
|
|
79
|
+
const pattern = /word|sheet|presentation|pdf|image|compressed/i;
|
|
80
|
+
let type = data.type;
|
|
81
|
+
if (!type) {
|
|
82
|
+
if (/rar/.test(data.name)) {
|
|
83
|
+
type = 'compressed';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return type.match(pattern)?.[0] || 'default';
|
|
87
|
+
} else {
|
|
88
|
+
const FileExt = data.FileName?.slice(data.FileName.lastIndexOf('.'));
|
|
89
|
+
return getFileType(FileExt) || 'default';
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const getDateTime = date => {
|
|
94
|
+
if (!(date instanceof Date && !isNaN(date))) return 'unknown';
|
|
95
|
+
const formatter = new Intl.DateTimeFormat('en-GB', {
|
|
96
|
+
day: '2-digit',
|
|
97
|
+
month: '2-digit',
|
|
98
|
+
year: 'numeric',
|
|
99
|
+
hour: '2-digit',
|
|
100
|
+
minute: '2-digit',
|
|
101
|
+
second: '2-digit',
|
|
102
|
+
});
|
|
103
|
+
return formatter.format(date); // DD/MM/YYYY, HH:mm:ss
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const getNewUnitSize = (sizeName, totalSize, num) => {
|
|
107
|
+
if ((sizeName === 'B' && num === 1) || (sizeName === 'TB' && num === -1)) return [sizeName, totalSize];
|
|
108
|
+
const arraySize = ['TB', 'GB', 'MB', 'KB', 'B'];
|
|
109
|
+
const index = arraySize.indexOf(sizeName);
|
|
110
|
+
const newTotalSize = totalSize * Math.pow(1024, num);
|
|
111
|
+
// newTotalSize = Math.round(newTotalSize*100)/100;
|
|
112
|
+
return [arraySize[index + num], newTotalSize];
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const getBit = (size, unit) => {
|
|
116
|
+
const units = {
|
|
117
|
+
B: 1,
|
|
118
|
+
KB: 1024,
|
|
119
|
+
MB: 1024 ** 2,
|
|
120
|
+
GB: 1024 ** 3,
|
|
121
|
+
TB: 1024 ** 4,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const normalizedUnit = unit.toUpperCase();
|
|
125
|
+
const multiplier = units[normalizedUnit] || 1024 * 1024;
|
|
126
|
+
|
|
127
|
+
return size * multiplier;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const formatBytes = (bytes, decimals = 2) => {
|
|
131
|
+
if (!+bytes) return '0 Bytes';
|
|
132
|
+
|
|
133
|
+
const k = 1024;
|
|
134
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
135
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
136
|
+
|
|
137
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
138
|
+
|
|
139
|
+
return [parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), sizes[i]];
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const isBase64URL = url => {
|
|
143
|
+
if (typeof url !== 'string') return false;
|
|
144
|
+
// Check if the URL is a valid data URL with base64 encoding
|
|
145
|
+
const dataPrefix = 'data:';
|
|
146
|
+
const base64Prefix = 'base64,';
|
|
147
|
+
|
|
148
|
+
if (url.startsWith(dataPrefix)) {
|
|
149
|
+
const base64Index = url.indexOf(base64Prefix);
|
|
150
|
+
if (base64Index !== -1) {
|
|
151
|
+
const base64Data = url.slice(base64Index + base64Prefix.length);
|
|
152
|
+
const base64Chars = /^[A-Za-z0-9+/=]+$/;
|
|
153
|
+
return base64Chars.test(base64Data) && base64Data.length % 4 === 0;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return false;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const cloneFile = file => {
|
|
161
|
+
const clonedFile = new File([file], file?.name || file?.FileName, {
|
|
162
|
+
type: file.type,
|
|
163
|
+
lastModified: file.lastModified,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Copy custom properties
|
|
167
|
+
for (const prop in file) {
|
|
168
|
+
if (file.hasOwnProperty(prop) && !clonedFile.hasOwnProperty(prop)) {
|
|
169
|
+
clonedFile[prop] = file[prop];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return clonedFile;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const handleDownload = (url, name, onDownload) => {
|
|
177
|
+
if (!url) {
|
|
178
|
+
console.error('Invalid URL');
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
fetch(url)
|
|
183
|
+
.then(resp => resp.blob())
|
|
184
|
+
.then(blob => {
|
|
185
|
+
const objectURL = window.URL.createObjectURL(blob);
|
|
186
|
+
|
|
187
|
+
const downloadLink = document.createElement('a');
|
|
188
|
+
downloadLink.style.display = 'none';
|
|
189
|
+
downloadLink.href = objectURL;
|
|
190
|
+
downloadLink.download = name;
|
|
191
|
+
|
|
192
|
+
document.body.appendChild(downloadLink);
|
|
193
|
+
downloadLink.click();
|
|
194
|
+
|
|
195
|
+
document.body.removeChild(downloadLink);
|
|
196
|
+
window.URL.revokeObjectURL(objectURL);
|
|
197
|
+
})
|
|
198
|
+
.catch(error => {
|
|
199
|
+
console.error('Error downloading file:', error);
|
|
200
|
+
alert('File download failed');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
if (onDownload) {
|
|
204
|
+
onDownload(url);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const divideSizeMap = new Map([
|
|
209
|
+
['B', 1],
|
|
210
|
+
['KB', 1024],
|
|
211
|
+
['MB', 1024 ** 2],
|
|
212
|
+
['GB', 1024 ** 3],
|
|
213
|
+
['TB', 1024 ** 4],
|
|
214
|
+
]);
|
|
215
|
+
|
|
216
|
+
const viewTypeIconMap = new Map([
|
|
217
|
+
['detail', 'ListView'],
|
|
218
|
+
['icon', 'IconView'],
|
|
219
|
+
['picture', 'ModuleView'],
|
|
220
|
+
]);
|
|
221
|
+
|
|
222
|
+
const viewTypeSwitchMap = new Map([
|
|
223
|
+
['detail', 'icon'],
|
|
224
|
+
['icon', 'picture'],
|
|
225
|
+
['picture', 'detail'],
|
|
226
|
+
]);
|
|
227
|
+
|
|
228
|
+
const Attachment = memo(
|
|
229
|
+
forwardRef((inProps, reference) => {
|
|
230
|
+
if (!reference) reference = useRef(null);
|
|
231
|
+
|
|
232
|
+
const theme = useTheme();
|
|
233
|
+
const { spacing } = useTheme();
|
|
234
|
+
|
|
235
|
+
// props priority: `inProps` > `themeDefaultProps`
|
|
236
|
+
const props = useThemeProps({ props: inProps, name: 'Attachment' });
|
|
237
|
+
const {
|
|
238
|
+
accept,
|
|
239
|
+
allowDelete,
|
|
240
|
+
allowSort,
|
|
241
|
+
className,
|
|
242
|
+
data,
|
|
243
|
+
deleteNotifyText: deleteNotifyTextProp,
|
|
244
|
+
disabled,
|
|
245
|
+
domain: domainProp,
|
|
246
|
+
error,
|
|
247
|
+
height,
|
|
248
|
+
hintText: hintTextProp,
|
|
249
|
+
id,
|
|
250
|
+
inputProps,
|
|
251
|
+
isStripDomain,
|
|
252
|
+
label: labelProp,
|
|
253
|
+
maxFile,
|
|
254
|
+
maxSize: maxSizeProp,
|
|
255
|
+
multiple: multipleProp,
|
|
256
|
+
onChange,
|
|
257
|
+
onDownload,
|
|
258
|
+
onRemove: onRemoveProp,
|
|
259
|
+
onView: onViewProp,
|
|
260
|
+
ownerName,
|
|
261
|
+
readOnly, //deprecated
|
|
262
|
+
required,
|
|
263
|
+
style,
|
|
264
|
+
unitSize,
|
|
265
|
+
uploadErrorInfo: uploadErrorInfoProp,
|
|
266
|
+
viewType,
|
|
267
|
+
} = props;
|
|
268
|
+
|
|
269
|
+
let domain = domainProp;
|
|
270
|
+
|
|
271
|
+
const multiple = maxFile === 1 ? false : multipleProp;
|
|
272
|
+
const deleteNotifyText = deleteNotifyTextProp || getGlobal('deleteNotifyText');
|
|
273
|
+
const hintText = hintTextProp || getGlobal('dropFileHere');
|
|
274
|
+
const label = labelProp || getGlobal('attachText');
|
|
275
|
+
const maxSize = maxSizeProp || getGlobal('maxSizeUpload');
|
|
276
|
+
const uploadErrorInfo = uploadErrorInfoProp || {
|
|
277
|
+
maxFile: getGlobal(['errorDefault', 'maxFile']),
|
|
278
|
+
maxSize: getGlobal(['errorDefault', 'maxSize']),
|
|
279
|
+
fileType: getGlobal(['errorDefault', 'fileType']),
|
|
280
|
+
existingFile: getGlobal(['errorDefault', 'existingFile']),
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const ref = useRef(null);
|
|
284
|
+
const attachmentHandleIconRef = useRef(null);
|
|
285
|
+
const attachmentInputRef = useRef(null);
|
|
286
|
+
const attachedRef = useRef(null);
|
|
287
|
+
const popupRef = useRef(null);
|
|
288
|
+
const popoverRef = useRef(null);
|
|
289
|
+
const isDeleteAll = useRef(false);
|
|
290
|
+
const notifyRef = useRef(null);
|
|
291
|
+
const removedAttachedRef = useRef([]);
|
|
292
|
+
const prevent = useRef(null);
|
|
293
|
+
const existClickOutOfItem = useRef(null);
|
|
294
|
+
const maxSizeRef = useRef(Infinity);
|
|
295
|
+
const timer = useRef(null);
|
|
296
|
+
|
|
297
|
+
const [showModal, setShowModal] = useState(false);
|
|
298
|
+
const [showPopup, setShowPopup] = useState(false);
|
|
299
|
+
const [viewTypeState, setViewTypeState] = useState(viewType);
|
|
300
|
+
const [newDataState, setNewDataState] = useState([]);
|
|
301
|
+
const [dataState, setDataState] = useState([]);
|
|
302
|
+
const [sizeByHeight, setSizeByHeight] = useState(true);
|
|
303
|
+
|
|
304
|
+
const isSpecialCase = viewTypeState === 'picture' && maxFile === 1;
|
|
305
|
+
|
|
306
|
+
const isEnable = !readOnly && !disabled;
|
|
307
|
+
const isEmpty = !(dataState?.length + newDataState?.length);
|
|
308
|
+
|
|
309
|
+
const _AttachmentRootCSS = AttachmentRootCSS(isEmpty, isEnable, height, theme);
|
|
310
|
+
const _AttachmentHandleIconCSS = AttachmentHandleIconCSS(theme);
|
|
311
|
+
const _ButtonAttachmentCSS = ButtonAttachmentCSS(theme);
|
|
312
|
+
const _DotNewFileDetailCSS = DotNewFileDetailCSS(theme);
|
|
313
|
+
const _DotNewFileIconCSS = DotNewFileIconCSS(theme);
|
|
314
|
+
const _AttachedItemOwnerCSS = AttachedItemOwnerCSS(theme);
|
|
315
|
+
const _AttachedLinearCSS = AttachedLinearCSS(theme);
|
|
316
|
+
const _AttachedItemCSS = AttachedItemCSS(theme);
|
|
317
|
+
const _AttachedItemPictureCSS = AttachedItemPictureCSS(theme);
|
|
318
|
+
const _ItemPictureInfoCSS = ItemPictureInfoCSS(theme);
|
|
319
|
+
const _AttachmentInfoCSS = AttachmentInfoCSS(theme);
|
|
320
|
+
const _AttachedItemInfoCSS = AttachedItemInfoCSS(theme);
|
|
321
|
+
const _AttachmentListCSS = AttachmentListCSS(theme);
|
|
322
|
+
|
|
323
|
+
// Start handler
|
|
324
|
+
const onSortElement = (e, type) => {
|
|
325
|
+
const _attached = [...dataState, ...newDataState];
|
|
326
|
+
let multi = 1;
|
|
327
|
+
const currentActive = popoverRef.current.querySelector('.DGN-Active');
|
|
328
|
+
if (currentActive) {
|
|
329
|
+
if (e.currentTarget.classList.contains('DGN-Active')) {
|
|
330
|
+
if (e.currentTarget.classList.contains('DGN-Decrease')) {
|
|
331
|
+
e.currentTarget.classList.remove('DGN-Decrease');
|
|
332
|
+
} else {
|
|
333
|
+
multi = -1;
|
|
334
|
+
e.currentTarget.classList.add('DGN-Decrease');
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
currentActive.classList.remove('DGN-Decrease');
|
|
338
|
+
currentActive.classList.remove('DGN-Active');
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
e.currentTarget.classList.add('DGN-Active');
|
|
342
|
+
const attachedList = Array.from(attachedRef.current.querySelectorAll('.attachment-row'));
|
|
343
|
+
attachedList.sort((a, b) => {
|
|
344
|
+
let textA = a.querySelector('.' + (type === 'filesize' ? 'filename' : type)).textContent;
|
|
345
|
+
let textB = b.querySelector('.' + (type === 'filesize' ? 'filename' : type)).textContent;
|
|
346
|
+
if (type === 'datetime') {
|
|
347
|
+
textA = textA.replace(/.{10}/, text => moment(text, 'DD/MM/YYYY').format('YYYY/MM/DD'));
|
|
348
|
+
textB = textB.replace(/.{10}/, text => moment(text, 'DD/MM/YYYY').format('YYYY/MM/DD'));
|
|
349
|
+
} else if (type === 'filesize') {
|
|
350
|
+
const objA = _attached.find(attach => attach.FileName === textA);
|
|
351
|
+
const objB = _attached.find(attach => attach.FileName === textB);
|
|
352
|
+
textA = (objA.size || objA.FileSize).toString();
|
|
353
|
+
textB = (objB.size || objB.FileSize).toString();
|
|
354
|
+
}
|
|
355
|
+
return multi * textA.localeCompare(textB, 'en', { numeric: type === 'filesize' });
|
|
356
|
+
});
|
|
357
|
+
_attached.sort((a, b) => {
|
|
358
|
+
let valueA, valueB;
|
|
359
|
+
if (type === 'filesize' || type === 'datetime') {
|
|
360
|
+
if (type === 'filesize') {
|
|
361
|
+
valueA = a.size || a.FileSize;
|
|
362
|
+
valueB = b.size || b.FileSize;
|
|
363
|
+
} else {
|
|
364
|
+
valueA = new Date(a.CreateDate).getTime();
|
|
365
|
+
valueB = new Date(b.CreateDate).getTime();
|
|
366
|
+
}
|
|
367
|
+
} else if (type === 'filetype') {
|
|
368
|
+
// filetype
|
|
369
|
+
valueA = getType(a);
|
|
370
|
+
valueB = getType(b);
|
|
371
|
+
} else {
|
|
372
|
+
valueA = a[type === 'filename' ? 'FileName' : 'UserName'] || ownerName;
|
|
373
|
+
valueB = b[type === 'filename' ? 'FileName' : 'UserName'] || ownerName;
|
|
374
|
+
}
|
|
375
|
+
return (
|
|
376
|
+
multi *
|
|
377
|
+
valueA.toString().localeCompare(valueB.toString(), 'en', {
|
|
378
|
+
numeric: type === 'filesize' || type === 'datetime',
|
|
379
|
+
})
|
|
380
|
+
);
|
|
381
|
+
});
|
|
382
|
+
attachedList.forEach(el => {
|
|
383
|
+
attachedRef.current.appendChild(el);
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// const afterChangeFile = (length = 0) => {
|
|
388
|
+
// setIsEmpty(!length);
|
|
389
|
+
// };
|
|
390
|
+
|
|
391
|
+
const onChangeFiles = async e => {
|
|
392
|
+
if (!isEnable) return;
|
|
393
|
+
e.persist();
|
|
394
|
+
if (e?.target?.files?.length) {
|
|
395
|
+
let files = e.target.files;
|
|
396
|
+
// const lengthAttached = attached.length;
|
|
397
|
+
const lengthAttached = [...dataState, ...newDataState]?.length;
|
|
398
|
+
for (let i = 0; i < files.length; i++) {
|
|
399
|
+
if (
|
|
400
|
+
(i + 1 > maxFile - lengthAttached && !isSpecialCase) ||
|
|
401
|
+
files[i].size > maxSizeRef.current ||
|
|
402
|
+
checkExistingFile(files[i]) ||
|
|
403
|
+
!checkAcceptFileType(files[i])
|
|
404
|
+
) {
|
|
405
|
+
if (i + 1 > maxFile - lengthAttached && !isSpecialCase) {
|
|
406
|
+
notifyRef.current.instance.show(`${files[i]?.name} - ${uploadErrorInfo['maxFile']}`);
|
|
407
|
+
} else if (files[i].size > maxSizeRef.current) {
|
|
408
|
+
notifyRef.current.instance.show(`${files[i]?.name} - ${uploadErrorInfo['maxSize']}`);
|
|
409
|
+
} else if (!checkAcceptFileType(files[i])) {
|
|
410
|
+
notifyRef.current.instance.show(`${files[i]?.name} - ${uploadErrorInfo['fileType']}`);
|
|
411
|
+
} else {
|
|
412
|
+
notifyRef.current.instance.show(`${files[i]?.name} - ${uploadErrorInfo['existingFile']}`);
|
|
413
|
+
}
|
|
414
|
+
files = removeFileOutInputFiles(i, true);
|
|
415
|
+
i--;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
const length = files.length;
|
|
419
|
+
if (!lengthAttached && !length) {
|
|
420
|
+
// afterChangeFile();
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
// afterChangeFile(lengthAttached + length);
|
|
424
|
+
if (multiple || (inputProps && inputProps.multiple)) {
|
|
425
|
+
for (let i = 0; i < length; i++) {
|
|
426
|
+
files[i].FileName = files[i].name;
|
|
427
|
+
attached.push(files[i]);
|
|
428
|
+
}
|
|
429
|
+
// setNewDataState([...newDataState, ...Array.from(files)]);
|
|
430
|
+
for (let i = 0; i < length; i++) {
|
|
431
|
+
files[i].URL = await onProgressing(files[i]);
|
|
432
|
+
}
|
|
433
|
+
} else if (length) {
|
|
434
|
+
files[0].FileName = files[0].name;
|
|
435
|
+
if (isSpecialCase) attached.splice(0, 1);
|
|
436
|
+
attached.push(files[0]);
|
|
437
|
+
files[0].URL = await onProgressing(files[0]);
|
|
438
|
+
}
|
|
439
|
+
insertAttached(files);
|
|
440
|
+
stripDomain();
|
|
441
|
+
if (onChange)
|
|
442
|
+
onChange({
|
|
443
|
+
element: e.target,
|
|
444
|
+
attached: isSpecialCase
|
|
445
|
+
? Array.from(files)
|
|
446
|
+
: [...dataState, ...newDataState, ...Array.from(files)],
|
|
447
|
+
oldAttached,
|
|
448
|
+
newAttached: files,
|
|
449
|
+
allNewAttached: [...newDataState, ...Array.from(files)],
|
|
450
|
+
});
|
|
451
|
+
if (maxFile === 1) updateSize();
|
|
452
|
+
}
|
|
453
|
+
// else if (!attached.length) {
|
|
454
|
+
// afterChangeFile();
|
|
455
|
+
// }
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
const onProgressing = file => {
|
|
459
|
+
const key = file?.lastModified + file?.size;
|
|
460
|
+
return new Promise((resolve, reject) => {
|
|
461
|
+
const reader = new FileReader();
|
|
462
|
+
let url;
|
|
463
|
+
reader.readAsDataURL(file);
|
|
464
|
+
reader.onload = e => {
|
|
465
|
+
url = e.target.result;
|
|
466
|
+
};
|
|
467
|
+
reader.onloadstart = () => {
|
|
468
|
+
const LinearProgressEl = attachedRef.current.querySelector(`.DGN-UI-LinearProgress-${key}`);
|
|
469
|
+
if (LinearProgressEl) {
|
|
470
|
+
LinearProgressEl.parentNode.style.display = 'flex';
|
|
471
|
+
LinearProgressEl.childNodes[0].style.width = '0%';
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
reader.onprogress = e => {
|
|
475
|
+
const LinearProgressEl = attachedRef.current.querySelector(`.DGN-UI-LinearProgress-${key}`);
|
|
476
|
+
if (LinearProgressEl) {
|
|
477
|
+
LinearProgressEl.childNodes[0].style.width = (e.loaded / e.total) * 100 + '%';
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
reader.onloadend = () => {
|
|
481
|
+
const LinearProgressEl = attachedRef.current.querySelector(`.DGN-UI-LinearProgress-${key}`);
|
|
482
|
+
if (LinearProgressEl) {
|
|
483
|
+
LinearProgressEl.parentNode.style.display = 'none';
|
|
484
|
+
}
|
|
485
|
+
resolve(url);
|
|
486
|
+
};
|
|
487
|
+
reader.onerror = () => {
|
|
488
|
+
console.log('Upload file fail');
|
|
489
|
+
reject(false);
|
|
490
|
+
};
|
|
491
|
+
});
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
const calculateSize = size => {
|
|
495
|
+
if (!size && size !== 0) return 'unknown';
|
|
496
|
+
let totalSize;
|
|
497
|
+
let unitSizeName;
|
|
498
|
+
const divideSize = unitSize ? divideSizeMap.get(unitSize.toUpperCase()) : null;
|
|
499
|
+
if (divideSize) {
|
|
500
|
+
totalSize = size / divideSize;
|
|
501
|
+
unitSizeName = unitSize.toUpperCase();
|
|
502
|
+
while (totalSize < 0.01 && unitSizeName !== 'B') {
|
|
503
|
+
[unitSizeName, totalSize] = getNewUnitSize(unitSizeName, totalSize, 1);
|
|
504
|
+
}
|
|
505
|
+
} else {
|
|
506
|
+
// auto-detect unit size name
|
|
507
|
+
[totalSize, unitSizeName] = formatBytes(size);
|
|
508
|
+
}
|
|
509
|
+
if (totalSize < 1000) {
|
|
510
|
+
totalSize = Math.round(totalSize * 100) / 100;
|
|
511
|
+
} else {
|
|
512
|
+
totalSize = Math.round(totalSize);
|
|
513
|
+
}
|
|
514
|
+
return totalSize + ' ' + unitSizeName;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
const onShowPopup = () => {
|
|
518
|
+
setShowPopup(true);
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
const onClosePopup = () => {
|
|
522
|
+
setShowPopup(false);
|
|
523
|
+
if (isDeleteAll.current) {
|
|
524
|
+
isDeleteAll.current = false;
|
|
525
|
+
chosenItems.length = 0;
|
|
526
|
+
removeActiveChosenItem();
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
const _onDownload = () => {
|
|
531
|
+
console.log('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
|
|
532
|
+
const index = chosenItems[0];
|
|
533
|
+
const file = mountDomain([...dataState, ...newDataState]?.[index]);
|
|
534
|
+
handleDownload(file?.URL, file?.FileName, onDownload);
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
const onRemoveMultiple = () => {
|
|
538
|
+
const attachedItems = [...dataState, ...newDataState];
|
|
539
|
+
const nodeList = attachedRef.current.querySelectorAll('.chosen');
|
|
540
|
+
const recentRemovedAttached = [];
|
|
541
|
+
const tempDataState = [...dataState];
|
|
542
|
+
const tempNewDataState = [...newDataState];
|
|
543
|
+
nodeList.forEach(itemEl => {
|
|
544
|
+
const index = Array.from(attachedRef.current.children).indexOf(itemEl.parentNode);
|
|
545
|
+
const deletedFile = attachedItems[index];
|
|
546
|
+
removedAttachedRef.current.push(deletedFile);
|
|
547
|
+
recentRemovedAttached.push(deletedFile);
|
|
548
|
+
if (Object.prototype.toString.call(deletedFile) === '[object File]' && tempNewDataState?.length) {
|
|
549
|
+
removeFileOutInputFiles(
|
|
550
|
+
tempNewDataState.findIndex(
|
|
551
|
+
attach =>
|
|
552
|
+
attach?.FileName === deletedFile?.FileName &&
|
|
553
|
+
attach?.CreateDate === deletedFile?.CreateDate
|
|
554
|
+
)
|
|
555
|
+
);
|
|
556
|
+
tempNewDataState.splice(
|
|
557
|
+
tempNewDataState.findIndex(
|
|
558
|
+
attach =>
|
|
559
|
+
attach?.FileName === deletedFile?.FileName &&
|
|
560
|
+
attach?.CreateDate === deletedFile?.CreateDate
|
|
561
|
+
),
|
|
562
|
+
1
|
|
563
|
+
);
|
|
564
|
+
setNewDataState(tempNewDataState);
|
|
565
|
+
} else {
|
|
566
|
+
oldAttached.splice(
|
|
567
|
+
oldAttached.findIndex(
|
|
568
|
+
attach =>
|
|
569
|
+
attach?.FileName === deletedFile?.FileName &&
|
|
570
|
+
attach?.CreateDate === deletedFile?.CreateDate
|
|
571
|
+
),
|
|
572
|
+
1
|
|
573
|
+
);
|
|
574
|
+
tempDataState.splice(
|
|
575
|
+
tempDataState.findIndex(
|
|
576
|
+
attach =>
|
|
577
|
+
attach?.FileName === deletedFile?.FileName &&
|
|
578
|
+
attach?.CreateDate === deletedFile?.CreateDate
|
|
579
|
+
),
|
|
580
|
+
1
|
|
581
|
+
);
|
|
582
|
+
setDataState(tempDataState);
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
const tempAttachedItems = [...tempDataState, ...tempNewDataState];
|
|
586
|
+
// if (tempAttachedItems.length < 2) {
|
|
587
|
+
// afterChangeFile(tempAttachedItems?.length || 0);
|
|
588
|
+
// }
|
|
589
|
+
stripDomain();
|
|
590
|
+
if (onChange)
|
|
591
|
+
onChange({
|
|
592
|
+
element: nodeList,
|
|
593
|
+
attached: tempAttachedItems,
|
|
594
|
+
recentRemovedAttached,
|
|
595
|
+
removedAttached: removedAttachedRef.current,
|
|
596
|
+
oldAttached,
|
|
597
|
+
allNewAttached: tempNewDataState,
|
|
598
|
+
});
|
|
599
|
+
!!onRemoveProp && onRemoveProp(recentRemovedAttached);
|
|
600
|
+
onClosePopup();
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
const clearAllAttached = (confirmPopup = false) => {
|
|
604
|
+
const allAttachEl = Array.from(attachedRef.current.querySelectorAll('.attachment-row')).map(
|
|
605
|
+
item => item.firstChild
|
|
606
|
+
);
|
|
607
|
+
if (allAttachEl && allAttachEl.length) {
|
|
608
|
+
allAttachEl.forEach(attachEl => attachEl.classList.add('chosen'));
|
|
609
|
+
isDeleteAll.current = true;
|
|
610
|
+
confirmPopup ? onShowPopup() : onRemoveMultiple();
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
const onGetViewItem = (i = 0) => {
|
|
615
|
+
const index = chosenItems[i];
|
|
616
|
+
const node = attachedRef.current.childNodes[index];
|
|
617
|
+
const AttachmentID = attached[index]?.AttachmentID || null;
|
|
618
|
+
onView(node, AttachmentID);
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
const onView = (node, AttachmentID) => {
|
|
622
|
+
const index = Array.from(attachedRef.current.children).indexOf(node?.parentNode);
|
|
623
|
+
if (onViewProp) onViewProp(AttachmentID, index);
|
|
624
|
+
else {
|
|
625
|
+
setShowModal(true);
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
const removeFileOutInputFiles = (index, keeping) => {
|
|
630
|
+
const dt = new DataTransfer();
|
|
631
|
+
for (let file of attachmentInputRef.current.files) {
|
|
632
|
+
if (file !== attachmentInputRef.current.files[index]) {
|
|
633
|
+
dt.items.add(file);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (!keeping) {
|
|
637
|
+
const files = allNewAttached.getAll('files');
|
|
638
|
+
files.splice(index, 1);
|
|
639
|
+
allNewAttached.delete('files');
|
|
640
|
+
files.forEach(file => allNewAttached.append('files', file));
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
attachmentInputRef.current.files = dt.files;
|
|
644
|
+
return dt.files;
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
const insertAttached = files => {
|
|
648
|
+
if (multiple || (inputProps && inputProps.multiple)) {
|
|
649
|
+
let tempArr = [];
|
|
650
|
+
for (let file of files) {
|
|
651
|
+
allNewAttached.append('files', file);
|
|
652
|
+
tempArr.push(file);
|
|
653
|
+
}
|
|
654
|
+
setNewDataState([...newDataState, ...tempArr]);
|
|
655
|
+
} else if (files[0]) {
|
|
656
|
+
allNewAttached.delete('files');
|
|
657
|
+
allNewAttached.append('files', files[0]);
|
|
658
|
+
if (isSpecialCase) setDataState([]);
|
|
659
|
+
setTimeout(() => {
|
|
660
|
+
setNewDataState(files[0] ? [files[0]] : []);
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
// attachmentInputRef.current.files = allNewAttached.getAll('files');
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const checkExistingFile = newFile => {
|
|
667
|
+
const files = [...dataState, ...newDataState];
|
|
668
|
+
return files.some(
|
|
669
|
+
file =>
|
|
670
|
+
(file?.FileName || file?.name) === (newFile?.FileName || newFile?.name) &&
|
|
671
|
+
(file?.FileSize || file?.size) === (newFile?.FileSize || newFile?.size)
|
|
672
|
+
);
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
const checkAcceptFileType = newFile => {
|
|
676
|
+
if (!accept || !accept.length) return true;
|
|
677
|
+
const type = typeof accept === 'string' ? accept : accept.join('-');
|
|
678
|
+
if (typeof accept === 'string') {
|
|
679
|
+
const acceptType = type.replace('/*', '');
|
|
680
|
+
return newFile.type.includes(acceptType);
|
|
681
|
+
}
|
|
682
|
+
const extFile = newFile.name.slice(newFile.name.lastIndexOf('.') + 1);
|
|
683
|
+
return accept.join('-').includes(extFile);
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
const onChooseItem = (e, idx) => {
|
|
687
|
+
const ctrlKey = e.ctrlKey;
|
|
688
|
+
const shiftKey = e.shiftKey;
|
|
689
|
+
const itemEl = e.currentTarget.firstChild;
|
|
690
|
+
// timer.current = setTimeout(() => {
|
|
691
|
+
if (!prevent.current) {
|
|
692
|
+
if (shiftKey && !ctrlKey) {
|
|
693
|
+
let startIndex = chosenItems[chosenItems.length - 1] || 0;
|
|
694
|
+
let endIndex = idx;
|
|
695
|
+
if (startIndex > endIndex) {
|
|
696
|
+
endIndex = startIndex;
|
|
697
|
+
startIndex = idx;
|
|
698
|
+
}
|
|
699
|
+
chosenItems.length = 0;
|
|
700
|
+
attachedRef.current
|
|
701
|
+
.querySelectorAll(`.DGN-UI-Attachment-List-Attached-Row`)
|
|
702
|
+
.forEach((itemEl, indexEl) => {
|
|
703
|
+
const _itemEl = itemEl.firstChild;
|
|
704
|
+
if (startIndex <= indexEl && indexEl <= endIndex) {
|
|
705
|
+
if (!_itemEl.classList.contains('chosen')) {
|
|
706
|
+
_itemEl.classList.add('chosen');
|
|
707
|
+
}
|
|
708
|
+
chosenItems.push(indexEl);
|
|
709
|
+
} else if (_itemEl.classList.contains('chosen')) {
|
|
710
|
+
_itemEl.classList.remove('chosen');
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
if (chosenItems[chosenItems.length - 1] !== idx) {
|
|
714
|
+
chosenItems.shift();
|
|
715
|
+
chosenItems.push(idx);
|
|
716
|
+
}
|
|
717
|
+
} else if (!ctrlKey) {
|
|
718
|
+
chosenItems.length = 0;
|
|
719
|
+
removeActiveChosenItem();
|
|
720
|
+
chosenItems.push(idx);
|
|
721
|
+
itemEl.classList.add('chosen');
|
|
722
|
+
} else if (itemEl.classList.contains('chosen')) {
|
|
723
|
+
chosenItems.splice(chosenItems.indexOf(idx));
|
|
724
|
+
itemEl.classList.remove('chosen');
|
|
725
|
+
if (!chosenItems.length) {
|
|
726
|
+
setTimeout(() => {
|
|
727
|
+
removeAllChosenItems();
|
|
728
|
+
}, 0);
|
|
729
|
+
}
|
|
730
|
+
} else {
|
|
731
|
+
chosenItems.push(idx);
|
|
732
|
+
itemEl.classList.add('chosen');
|
|
733
|
+
}
|
|
734
|
+
// Add event listener click out of item
|
|
735
|
+
if (!existClickOutOfItem.current) {
|
|
736
|
+
existClickOutOfItem.current = true;
|
|
737
|
+
attachmentHandleIconRef.current.style.display = 'block';
|
|
738
|
+
document.addEventListener('keydown', onKeyDown);
|
|
739
|
+
document.addEventListener('click', clickOutOfItem);
|
|
740
|
+
}
|
|
741
|
+
checkChosenMultiple();
|
|
742
|
+
}
|
|
743
|
+
prevent.current = false;
|
|
744
|
+
// }, 100);
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
const removeActiveChosenItem = () => {
|
|
748
|
+
attachedRef.current.querySelectorAll('.chosen').forEach(itemEl => {
|
|
749
|
+
itemEl.classList.remove('chosen');
|
|
750
|
+
});
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
const checkChosenMultiple = () => {
|
|
754
|
+
const actionIcons = attachmentHandleIconRef.current.childNodes;
|
|
755
|
+
if (chosenItems.length > 1 && actionIcons[0].style.display !== 'none') {
|
|
756
|
+
actionIcons[0].style.display = 'none';
|
|
757
|
+
actionIcons[1].style.display = 'none';
|
|
758
|
+
} else if (chosenItems.length === 1 && actionIcons[0].style.display === 'none') {
|
|
759
|
+
actionIcons[0].style.display = null;
|
|
760
|
+
actionIcons[1].style.display = null;
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
const onKeyDown = event => {
|
|
765
|
+
const key = event.key;
|
|
766
|
+
if (key === 'Delete') {
|
|
767
|
+
// Press Delete key to delete item(s)
|
|
768
|
+
onShowPopup();
|
|
769
|
+
} else if (key === 'Enter') {
|
|
770
|
+
if (popupRef.current.style.display !== 'flex') {
|
|
771
|
+
onGetViewItem(chosenItems.length - 1);
|
|
772
|
+
}
|
|
773
|
+
} else if (/a/i.test(key) && event.ctrlKey) {
|
|
774
|
+
chosenItems.length = 0;
|
|
775
|
+
const allAttachEl = Array.from(attachedRef.current.querySelectorAll('.attachment-row')).map(
|
|
776
|
+
item => item.firstChild
|
|
777
|
+
);
|
|
778
|
+
if (allAttachEl && allAttachEl.length) {
|
|
779
|
+
allAttachEl.forEach(
|
|
780
|
+
(attachEl, index) => chosenItems.push(index) & attachEl.classList.add('chosen')
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
event.preventDefault();
|
|
784
|
+
return false;
|
|
785
|
+
} else if (/Arrow/.test(key)) {
|
|
786
|
+
// Press Arrow key to select another item
|
|
787
|
+
event.preventDefault();
|
|
788
|
+
const itemsNode = Array.from(attachedRef.current.querySelectorAll('.attachment-row')).map(
|
|
789
|
+
item => item.firstChild
|
|
790
|
+
);
|
|
791
|
+
const chosenItemsNode = Array.from(itemsNode).filter(el => el.classList.contains('chosen'));
|
|
792
|
+
const length = itemsNode.length;
|
|
793
|
+
let index;
|
|
794
|
+
if (key === 'ArrowDown' || key === 'ArrowRight') {
|
|
795
|
+
for (let id = length - 1; id >= 0; id--) {
|
|
796
|
+
if (Array.from(itemsNode)[id].classList.contains('chosen')) {
|
|
797
|
+
index = id;
|
|
798
|
+
break;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
if (index === length - 1) {
|
|
802
|
+
if (chosenItemsNode.length !== 1 && !event.shiftKey) {
|
|
803
|
+
chosenItemsNode.forEach((node, i) => {
|
|
804
|
+
if (i !== index) {
|
|
805
|
+
node.classList.remove('chosen');
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
chosenItems.length = 0;
|
|
809
|
+
chosenItems.push(index);
|
|
810
|
+
Array.from(itemsNode)[index].scrollIntoView({
|
|
811
|
+
block: 'center',
|
|
812
|
+
behavior: 'smooth',
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
Array.from(itemsNode)[index + 1].scrollIntoView({
|
|
818
|
+
block: 'center',
|
|
819
|
+
behavior: 'smooth',
|
|
820
|
+
});
|
|
821
|
+
if (!event.shiftKey) {
|
|
822
|
+
itemsNode.forEach(node => {
|
|
823
|
+
node.classList.remove('chosen');
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
itemsNode[index + 1].classList.add('chosen');
|
|
827
|
+
chosenItems.push(index + 1);
|
|
828
|
+
} else if (key === 'ArrowUp' || key === 'ArrowLeft') {
|
|
829
|
+
index = Array.from(itemsNode).findIndex(el => el.classList.contains('chosen'));
|
|
830
|
+
if (index === 0) {
|
|
831
|
+
if (chosenItemsNode.length !== 1 && !event.shiftKey) {
|
|
832
|
+
chosenItemsNode.forEach((node, i) => {
|
|
833
|
+
if (i !== index) {
|
|
834
|
+
node.classList.remove('chosen');
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
chosenItems.length = 0;
|
|
838
|
+
chosenItems.push(index);
|
|
839
|
+
Array.from(itemsNode)[index].scrollIntoView({
|
|
840
|
+
block: 'center',
|
|
841
|
+
behavior: 'smooth',
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
Array.from(itemsNode)[index - 1].scrollIntoView({
|
|
847
|
+
block: 'center',
|
|
848
|
+
behavior: 'smooth',
|
|
849
|
+
});
|
|
850
|
+
if (!event.shiftKey) {
|
|
851
|
+
chosenItemsNode.forEach(node => {
|
|
852
|
+
node.classList.remove('chosen');
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
itemsNode[index - 1].classList.add('chosen');
|
|
856
|
+
chosenItems.push(index - 1);
|
|
857
|
+
}
|
|
858
|
+
if (!event.shiftKey) {
|
|
859
|
+
chosenItems.length = 1;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
|
|
864
|
+
const clickOutOfItem = e => {
|
|
865
|
+
if (!attachedRef || !attachedRef.current) {
|
|
866
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
867
|
+
document.removeEventListener('click', clickOutOfItem);
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
if (
|
|
871
|
+
!(attachedRef.current.contains(e.target) && attachedRef.current !== e.target) &&
|
|
872
|
+
!attachmentHandleIconRef.current.contains(e.target) &&
|
|
873
|
+
!isDeleteAll.current &&
|
|
874
|
+
(popupRef.current?.style?.display !== 'flex' ||
|
|
875
|
+
popupRef.current.querySelector('button.filled.info').contains(e.target))
|
|
876
|
+
) {
|
|
877
|
+
removeAllChosenItems();
|
|
878
|
+
removeActiveChosenItem();
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
const removeAllChosenItems = () => {
|
|
883
|
+
chosenItems.length = 0;
|
|
884
|
+
existClickOutOfItem.current = false;
|
|
885
|
+
attachmentHandleIconRef.current.style.display = null;
|
|
886
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
887
|
+
document.removeEventListener('click', clickOutOfItem);
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
const mountDomain = item => {
|
|
891
|
+
if (!item) return item;
|
|
892
|
+
const cloneItem = cloneFile(item);
|
|
893
|
+
if (domain) {
|
|
894
|
+
if (!/\/$/.test(domain)) {
|
|
895
|
+
domain = domain + '/';
|
|
896
|
+
}
|
|
897
|
+
if (cloneItem?.URL && !isBase64URL(cloneItem?.URL)) {
|
|
898
|
+
const hasDomain = /^(?:https?:\/\/)?[^\s/$.?#]+\.[^\s]+$/.test(cloneItem.URL);
|
|
899
|
+
cloneItem.URL = hasDomain ? cloneItem.URL : domain + cloneItem.URL;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return cloneItem;
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
const stripDomain = () => {
|
|
906
|
+
if (isStripDomain && domain) {
|
|
907
|
+
const re = new RegExp(domain + '/?');
|
|
908
|
+
attached.forEach(item => {
|
|
909
|
+
item.URL = item?.URL?.replace(re, '') || '';
|
|
910
|
+
});
|
|
911
|
+
oldAttached.forEach(item => {
|
|
912
|
+
item.URL = item?.URL?.replace(re, '') || '';
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
useEffect(() => {
|
|
918
|
+
if (attached?.length) {
|
|
919
|
+
attached.length = 0;
|
|
920
|
+
}
|
|
921
|
+
return () => {
|
|
922
|
+
existClickOutOfItem.current = false;
|
|
923
|
+
};
|
|
924
|
+
}, []);
|
|
925
|
+
|
|
926
|
+
useEffect(() => {
|
|
927
|
+
setViewTypeState(viewType);
|
|
928
|
+
}, [viewType]);
|
|
929
|
+
|
|
930
|
+
useEffect(() => {
|
|
931
|
+
if (maxSize) {
|
|
932
|
+
if (!isNaN(maxSize)) {
|
|
933
|
+
maxSizeRef.current = maxSize * 1024 * 1024;
|
|
934
|
+
} else {
|
|
935
|
+
const [numberSize = ''] = maxSize.match(/\d+/) || [];
|
|
936
|
+
const [unitMaxSize = ''] = maxSize.match(/\D+/) || [];
|
|
937
|
+
maxSizeRef.current = getBit(numberSize, unitMaxSize);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return () => {
|
|
941
|
+
maxSizeRef.current = Infinity;
|
|
942
|
+
};
|
|
943
|
+
}, [maxSize]);
|
|
944
|
+
|
|
945
|
+
useEffect(() => {
|
|
946
|
+
if (multiple && maxFile > 1) attachmentInputRef.current.multiple = multiple;
|
|
947
|
+
}, [multiple, maxFile]);
|
|
948
|
+
|
|
949
|
+
useEffect(() => {
|
|
950
|
+
if (accept && typeof accept === 'string') {
|
|
951
|
+
attachmentInputRef.current.accept = `${accept}/*`.replace('/*/*', '/*');
|
|
952
|
+
}
|
|
953
|
+
}, [accept]);
|
|
954
|
+
|
|
955
|
+
useEffect(() => {
|
|
956
|
+
oldAttached.length = 0;
|
|
957
|
+
// afterChangeFile((data?.length || 0) + (newDataState?.length || 0));
|
|
958
|
+
if (data?.length && !dataState?.length && !newDataState?.length) {
|
|
959
|
+
// Load files data was uploaded
|
|
960
|
+
const length = data.length;
|
|
961
|
+
for (let i = 0; i < length; i++) {
|
|
962
|
+
if (Object.prototype.toString.call(data[i]) === '[object File]') {
|
|
963
|
+
allNewAttached.append('files', data[i]);
|
|
964
|
+
attached.push(data[i]);
|
|
965
|
+
} else {
|
|
966
|
+
const item = mountDomain(data[i]);
|
|
967
|
+
oldAttached.push(item);
|
|
968
|
+
attached.push(item);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
setDataState(data);
|
|
972
|
+
setTimeout(() => {
|
|
973
|
+
setNewDataState([]);
|
|
974
|
+
});
|
|
975
|
+
} else if (data?.length === 0) {
|
|
976
|
+
setDataState([]);
|
|
977
|
+
setTimeout(() => {
|
|
978
|
+
setNewDataState([]);
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
return () => {
|
|
983
|
+
oldAttached.length = 0;
|
|
984
|
+
attached.length = 0;
|
|
985
|
+
chosenItems.length = 0;
|
|
986
|
+
allNewAttached.delete('files');
|
|
987
|
+
if (attachmentInputRef.current) {
|
|
988
|
+
attachmentInputRef.current.value = '';
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
}, [data]);
|
|
992
|
+
|
|
993
|
+
useEffect(() => {
|
|
994
|
+
if (inputProps && Object.keys(inputProps).length) {
|
|
995
|
+
Object.keys(inputProps).forEach(name => {
|
|
996
|
+
if (typeof inputProps[name] === 'boolean') {
|
|
997
|
+
attachmentInputRef.current[name] = inputProps[name];
|
|
998
|
+
} else {
|
|
999
|
+
attachmentInputRef.current.setAttribute(name, inputProps[name]);
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
return () => {
|
|
1003
|
+
if (attachmentInputRef.current) {
|
|
1004
|
+
Object.keys(inputProps).forEach(name => {
|
|
1005
|
+
if (typeof inputProps[name] === 'boolean') {
|
|
1006
|
+
attachmentInputRef.current[name] = false;
|
|
1007
|
+
} else {
|
|
1008
|
+
attachmentInputRef.current.removeAttribute(name);
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
}, [inputProps]);
|
|
1015
|
+
|
|
1016
|
+
const triggerClickInput = () => {
|
|
1017
|
+
attachmentInputRef.current.click();
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
const onDragFileStart = () => {
|
|
1021
|
+
attachmentInputRef.current.style.display = 'block';
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
const onDropInput = e => {
|
|
1025
|
+
attachmentInputRef.current.style.display = 'none';
|
|
1026
|
+
e.target.value = null; // Fix not fire onChange when select same file
|
|
1027
|
+
};
|
|
1028
|
+
// End handler
|
|
1029
|
+
|
|
1030
|
+
useImperativeHandle(reference, () => {
|
|
1031
|
+
stripDomain();
|
|
1032
|
+
const currentRef = ref.current || {};
|
|
1033
|
+
currentRef.element = ref.current;
|
|
1034
|
+
const _instance = {
|
|
1035
|
+
oldAttached: oldAttached,
|
|
1036
|
+
allNewAttached: newDataState,
|
|
1037
|
+
attached: isSpecialCase ? newDataState : [...dataState, ...newDataState],
|
|
1038
|
+
clear: confirmPopup => clearAllAttached(confirmPopup),
|
|
1039
|
+
openFileDialog: triggerClickInput,
|
|
1040
|
+
}; // methods
|
|
1041
|
+
_instance.__proto__ = {}; // hidden methods
|
|
1042
|
+
currentRef.instance = _instance;
|
|
1043
|
+
currentRef.oldAttached = oldAttached;
|
|
1044
|
+
currentRef.allNewAttached = newDataState;
|
|
1045
|
+
currentRef.attached = [...dataState, ...newDataState];
|
|
1046
|
+
currentRef.clear = confirmPopup => clearAllAttached(confirmPopup);
|
|
1047
|
+
currentRef.openFileDialog = triggerClickInput;
|
|
1048
|
+
return currentRef;
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
// Start view
|
|
1052
|
+
const AttachHeaderView = (
|
|
1053
|
+
<div css={AttachmentHeaderCSS(theme)} className={'DGN-UI-Attachment-Header'}>
|
|
1054
|
+
<div css={_AttachmentInfoCSS}>
|
|
1055
|
+
<Label uppercase required={required} type={'h5'} color={'text/sub'}>
|
|
1056
|
+
{label}
|
|
1057
|
+
</Label>
|
|
1058
|
+
{error ? <HelperText>{error}</HelperText> : null}
|
|
1059
|
+
</div>
|
|
1060
|
+
<div css={AttachmentHeaderIconCSS}>
|
|
1061
|
+
<div css={_AttachmentHandleIconCSS} ref={attachmentHandleIconRef}>
|
|
1062
|
+
<ButtonIcon
|
|
1063
|
+
viewType={'ghost'}
|
|
1064
|
+
className={'view'}
|
|
1065
|
+
name={'view'}
|
|
1066
|
+
onClick={() => onGetViewItem()}
|
|
1067
|
+
/>
|
|
1068
|
+
<ButtonIcon viewType={'ghost'} className={'download'} name={'download'} onClick={_onDownload} />
|
|
1069
|
+
{allowDelete && isEnable ? (
|
|
1070
|
+
<ButtonIcon viewType={'ghost'} className={'delete'} name={'delete'} onClick={onShowPopup} />
|
|
1071
|
+
) : null}
|
|
1072
|
+
</div>
|
|
1073
|
+
<div
|
|
1074
|
+
css={
|
|
1075
|
+
isEmpty
|
|
1076
|
+
? AttachmentImageEmptyCSS
|
|
1077
|
+
: css`
|
|
1078
|
+
margin-right: ${spacing([isSpecialCase ? 0 : 2])};
|
|
1079
|
+
`
|
|
1080
|
+
}
|
|
1081
|
+
>
|
|
1082
|
+
<div
|
|
1083
|
+
css={[
|
|
1084
|
+
AttachmentImageCenterCSS,
|
|
1085
|
+
!isEnable && [parseHeight('calc(100% - 32px)'), justifyEnd],
|
|
1086
|
+
]}
|
|
1087
|
+
>
|
|
1088
|
+
{isEnable ? (
|
|
1089
|
+
<div css={AttachmentImageCenterCSS}>
|
|
1090
|
+
<ButtonIcon
|
|
1091
|
+
css={isEmpty && _ButtonAttachmentCSS}
|
|
1092
|
+
circular={isEmpty}
|
|
1093
|
+
viewType={isEmpty ? 'text' : 'ghost'}
|
|
1094
|
+
name={'Attachment'}
|
|
1095
|
+
size={isEmpty ? 'extraGiant' : 'medium'}
|
|
1096
|
+
onClick={triggerClickInput}
|
|
1097
|
+
/>
|
|
1098
|
+
{isEmpty ? (
|
|
1099
|
+
<Typography css={userSelectNone} type={'p3'} color={'system/rest'}>
|
|
1100
|
+
{hintText}
|
|
1101
|
+
</Typography>
|
|
1102
|
+
) : null}
|
|
1103
|
+
</div>
|
|
1104
|
+
) : isEmpty ? (
|
|
1105
|
+
<Typography css={userSelectNone} type={'p3'} color={'system/rest'}>
|
|
1106
|
+
{getGlobal('noFileText')}
|
|
1107
|
+
</Typography>
|
|
1108
|
+
) : null}
|
|
1109
|
+
</div>
|
|
1110
|
+
</div>
|
|
1111
|
+
{allowSort && !isEmpty && !isSpecialCase ? (
|
|
1112
|
+
<Popover
|
|
1113
|
+
ref={popoverRef}
|
|
1114
|
+
anchor={<ButtonIcon viewType={'ghost'} name={'Sort'} style={{ marginRight: 8 }} />}
|
|
1115
|
+
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
1116
|
+
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
|
|
1117
|
+
>
|
|
1118
|
+
<List>
|
|
1119
|
+
<ListItem onClick={e => onSortElement(e, 'filename')}>
|
|
1120
|
+
<ListItemText>{getGlobal('byName')}</ListItemText>
|
|
1121
|
+
</ListItem>
|
|
1122
|
+
<ListItem onClick={e => onSortElement(e, 'filetype')}>
|
|
1123
|
+
<ListItemText>{getGlobal('byType')}</ListItemText>
|
|
1124
|
+
</ListItem>
|
|
1125
|
+
<ListItem onClick={e => onSortElement(e, 'filesize')}>
|
|
1126
|
+
<ListItemText>{getGlobal('bySize')}</ListItemText>
|
|
1127
|
+
</ListItem>
|
|
1128
|
+
<ListItem onClick={e => onSortElement(e, 'datetime')}>
|
|
1129
|
+
<ListItemText>{getGlobal('byDate')}</ListItemText>
|
|
1130
|
+
</ListItem>
|
|
1131
|
+
<ListItem onClick={e => onSortElement(e, 'username')}>
|
|
1132
|
+
<ListItemText>{getGlobal('byOwner')}</ListItemText>
|
|
1133
|
+
</ListItem>
|
|
1134
|
+
</List>
|
|
1135
|
+
</Popover>
|
|
1136
|
+
) : null}
|
|
1137
|
+
{!isEmpty && !isSpecialCase ? (
|
|
1138
|
+
<ButtonIcon
|
|
1139
|
+
viewType={'ghost'}
|
|
1140
|
+
name={viewTypeIconMap.get(viewTypeState)}
|
|
1141
|
+
onClick={() => setViewTypeState(viewTypeSwitchMap.get(viewTypeState))}
|
|
1142
|
+
/>
|
|
1143
|
+
) : null}
|
|
1144
|
+
</div>
|
|
1145
|
+
</div>
|
|
1146
|
+
);
|
|
1147
|
+
|
|
1148
|
+
const AttachmentInputView = (
|
|
1149
|
+
<input
|
|
1150
|
+
ref={attachmentInputRef}
|
|
1151
|
+
type="file"
|
|
1152
|
+
style={{ display: 'none' }}
|
|
1153
|
+
css={css`
|
|
1154
|
+
${positionAbsolute};
|
|
1155
|
+
${parseWidthHeight('100%')};
|
|
1156
|
+
opacity: 0;
|
|
1157
|
+
`}
|
|
1158
|
+
className={'DGN-UI-Attachment-Input'}
|
|
1159
|
+
title=""
|
|
1160
|
+
onDrop={onDropInput}
|
|
1161
|
+
onDragLeave={onDropInput}
|
|
1162
|
+
onClick={e => (e.target.value = null)} // Fix not fire onChange when select same file
|
|
1163
|
+
onChange={onChangeFiles}
|
|
1164
|
+
{...inputProps}
|
|
1165
|
+
/>
|
|
1166
|
+
);
|
|
1167
|
+
|
|
1168
|
+
const renderAttachmentItemDetail = (item, idx, isNew) => {
|
|
1169
|
+
const date = isNew ? new Date() : new Date(item.CreateDate);
|
|
1170
|
+
if (isNew) item.CreateDate = date.toISOString();
|
|
1171
|
+
const type = getType(item);
|
|
1172
|
+
const name = isNew ? item.name : item.FileName;
|
|
1173
|
+
const key = item?.lastModified + item?.size;
|
|
1174
|
+
|
|
1175
|
+
return (
|
|
1176
|
+
<Grid
|
|
1177
|
+
item
|
|
1178
|
+
xs={12}
|
|
1179
|
+
key={idx}
|
|
1180
|
+
onClick={e => onChooseItem(e, idx)}
|
|
1181
|
+
onDoubleClick={e => onView(e.currentTarget, isNew ? null : item.AttachmentID)}
|
|
1182
|
+
className={classNames('DGN-UI-Attachment-List-Attached-Row', 'attachment-row')}
|
|
1183
|
+
>
|
|
1184
|
+
<div css={[_AttachedItemCSS, AttachedItemDetailCSS(theme)]}>
|
|
1185
|
+
<span css={_AttachedItemInfoCSS}>
|
|
1186
|
+
<Icon
|
|
1187
|
+
css={(item.lastModifiedDate || isNew) && _DotNewFileDetailCSS}
|
|
1188
|
+
width={16}
|
|
1189
|
+
height={16}
|
|
1190
|
+
name={type === 'default' ? 'another' : type}
|
|
1191
|
+
/>
|
|
1192
|
+
<span css={displayNone} className={'filetype'}>
|
|
1193
|
+
{type}
|
|
1194
|
+
</span>
|
|
1195
|
+
<Typography
|
|
1196
|
+
className={'filename'}
|
|
1197
|
+
css={css`
|
|
1198
|
+
margin-left: ${spacing([3])};
|
|
1199
|
+
`}
|
|
1200
|
+
type={'p1'}
|
|
1201
|
+
lineClamp={1}
|
|
1202
|
+
>
|
|
1203
|
+
{name}
|
|
1204
|
+
</Typography>
|
|
1205
|
+
</span>
|
|
1206
|
+
<span css={_AttachedItemOwnerCSS}>
|
|
1207
|
+
<span css={DetailInfoCSS}>
|
|
1208
|
+
<Typography className={'username'} type={'p2'} color={'text/sub'}>
|
|
1209
|
+
{item?.UserName || (item.lastModifiedDate && ownerName) || ''}
|
|
1210
|
+
</Typography>
|
|
1211
|
+
<Typography className={'datetime'} type={'p2'} color={'text/sub'}>
|
|
1212
|
+
{getDateTime(date)}
|
|
1213
|
+
</Typography>
|
|
1214
|
+
<Typography className={'filesize'} type={'p2'} color={'text/sub'}>
|
|
1215
|
+
{calculateSize(item.FileSize || item.size)}
|
|
1216
|
+
</Typography>
|
|
1217
|
+
</span>
|
|
1218
|
+
{isNew ? (
|
|
1219
|
+
<span css={[_AttachedLinearCSS, displayNone]}>
|
|
1220
|
+
<LinearProgress
|
|
1221
|
+
className={`DGN-UI-LinearProgress-${key}`}
|
|
1222
|
+
determinate
|
|
1223
|
+
percent={0}
|
|
1224
|
+
/>
|
|
1225
|
+
</span>
|
|
1226
|
+
) : null}
|
|
1227
|
+
</span>
|
|
1228
|
+
</div>
|
|
1229
|
+
</Grid>
|
|
1230
|
+
);
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
const renderAttachmentItemIcon = (item, idx, isNew) => {
|
|
1234
|
+
const date = isNew ? new Date() : new Date(item.CreateDate);
|
|
1235
|
+
if (isNew) item.CreateDate = date.toISOString();
|
|
1236
|
+
const type = getType(item);
|
|
1237
|
+
const name = isNew ? item.name : item.FileName;
|
|
1238
|
+
const key = item?.lastModified + item?.size;
|
|
1239
|
+
|
|
1240
|
+
return (
|
|
1241
|
+
<Grid
|
|
1242
|
+
item
|
|
1243
|
+
xs={'auto'}
|
|
1244
|
+
key={idx}
|
|
1245
|
+
onClick={e => onChooseItem(e, idx)}
|
|
1246
|
+
onDoubleClick={e => onView(e.currentTarget, isNew ? null : item.AttachmentID)}
|
|
1247
|
+
className={classNames('DGN-UI-Attachment-List-Attached-Row', 'attachment-row')}
|
|
1248
|
+
>
|
|
1249
|
+
<div css={_AttachedItemCSS}>
|
|
1250
|
+
<span css={AttachedItemIconInfoCSS(theme)}>
|
|
1251
|
+
<Icon
|
|
1252
|
+
css={[(item.lastModifiedDate || isNew) && _DotNewFileIconCSS]}
|
|
1253
|
+
width={40}
|
|
1254
|
+
height={40}
|
|
1255
|
+
name={type === 'default' ? 'another' : type}
|
|
1256
|
+
/>
|
|
1257
|
+
<Typography
|
|
1258
|
+
className={'filename'}
|
|
1259
|
+
css={[textLeft, parseMaxWidth(64)]}
|
|
1260
|
+
type={'p3'}
|
|
1261
|
+
lineClamp={2}
|
|
1262
|
+
>
|
|
1263
|
+
{name}
|
|
1264
|
+
</Typography>
|
|
1265
|
+
<span css={displayNone} className={'filetype'}>
|
|
1266
|
+
{type}
|
|
1267
|
+
</span>
|
|
1268
|
+
<span css={displayNone} className={'username'}>
|
|
1269
|
+
{item?.UserName || (item.lastModifiedDate && ownerName) || ''}
|
|
1270
|
+
</span>
|
|
1271
|
+
<span css={displayNone} className={'datetime'}>
|
|
1272
|
+
{getDateTime(date)}
|
|
1273
|
+
</span>
|
|
1274
|
+
<span css={displayNone} className={'filesize'}>
|
|
1275
|
+
{calculateSize(item.FileSize || item.size)}
|
|
1276
|
+
</span>
|
|
1277
|
+
</span>
|
|
1278
|
+
{isNew ? (
|
|
1279
|
+
<span css={[_AttachedLinearCSS, displayNone]}>
|
|
1280
|
+
<LinearProgress className={`DGN-UI-LinearProgress-${key}`} determinate percent={0} />
|
|
1281
|
+
</span>
|
|
1282
|
+
) : null}
|
|
1283
|
+
</div>
|
|
1284
|
+
</Grid>
|
|
1285
|
+
);
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
const updateSize = () => {
|
|
1289
|
+
if (timer.current) {
|
|
1290
|
+
clearTimeout(timer.current);
|
|
1291
|
+
}
|
|
1292
|
+
timer.current = setTimeout(() => {
|
|
1293
|
+
if (ref.current) {
|
|
1294
|
+
setSizeByHeight(ref.current.offsetHeight < ref.current.offsetWidth);
|
|
1295
|
+
}
|
|
1296
|
+
}, 300);
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
useLayoutEffect(() => {
|
|
1300
|
+
window.addEventListener('resize', updateSize);
|
|
1301
|
+
updateSize();
|
|
1302
|
+
return () => window.removeEventListener('resize', updateSize);
|
|
1303
|
+
}, []);
|
|
1304
|
+
|
|
1305
|
+
const renderAttachmentItemPicture = (item, idx, isNew) => {
|
|
1306
|
+
const date = isNew ? new Date() : new Date(item.CreateDate);
|
|
1307
|
+
if (isNew) item.CreateDate = date.toISOString();
|
|
1308
|
+
const type = getType(item);
|
|
1309
|
+
const name = isNew ? item.name : item.FileName;
|
|
1310
|
+
const key = item?.lastModified + item?.size;
|
|
1311
|
+
const isTypeImage = type === 'image';
|
|
1312
|
+
const isSpecialByHeight = sizeByHeight && isSpecialCase;
|
|
1313
|
+
const specialBreakpointColumn = isSpecialByHeight ? 'auto' : 12;
|
|
1314
|
+
return (
|
|
1315
|
+
<Grid
|
|
1316
|
+
item
|
|
1317
|
+
xs={isSpecialCase ? specialBreakpointColumn : 6}
|
|
1318
|
+
sm={isSpecialCase ? specialBreakpointColumn : 4}
|
|
1319
|
+
md={isSpecialCase ? specialBreakpointColumn : 3}
|
|
1320
|
+
lg={isSpecialCase ? specialBreakpointColumn : 2}
|
|
1321
|
+
xl={isSpecialCase ? specialBreakpointColumn : 2}
|
|
1322
|
+
key={idx}
|
|
1323
|
+
onClick={e => onChooseItem(e, idx)}
|
|
1324
|
+
onDoubleClick={e => onView(e.currentTarget, isNew ? null : item.AttachmentID)}
|
|
1325
|
+
className={classNames('DGN-UI-Attachment-List-Attached-Row', 'attachment-row')}
|
|
1326
|
+
>
|
|
1327
|
+
<div
|
|
1328
|
+
css={[
|
|
1329
|
+
_AttachedItemPictureCSS,
|
|
1330
|
+
!isTypeImage && AttachedItemPictureImageCSS,
|
|
1331
|
+
isSpecialByHeight && parseWidthHeight(height - 56 - 8 - 2),
|
|
1332
|
+
]}
|
|
1333
|
+
>
|
|
1334
|
+
{isTypeImage ? (
|
|
1335
|
+
<Image
|
|
1336
|
+
square
|
|
1337
|
+
src={item.URL}
|
|
1338
|
+
width={isSpecialByHeight ? 'auto' : '100%'}
|
|
1339
|
+
height={isSpecialByHeight ? '100%' : 'auto'}
|
|
1340
|
+
/>
|
|
1341
|
+
) : (
|
|
1342
|
+
<Icon
|
|
1343
|
+
css={parseWidthHeight('100%')}
|
|
1344
|
+
name={type === 'default' ? 'another' : type}
|
|
1345
|
+
width={'50%'}
|
|
1346
|
+
height={'50%'}
|
|
1347
|
+
/>
|
|
1348
|
+
)}
|
|
1349
|
+
<Typography
|
|
1350
|
+
css={_ItemPictureInfoCSS}
|
|
1351
|
+
type={'p2'}
|
|
1352
|
+
color={'text/tooltip'}
|
|
1353
|
+
lineClamp={10}
|
|
1354
|
+
className={'DGN-UI-Attachment-Item-Picture-Info'}
|
|
1355
|
+
>
|
|
1356
|
+
{name}
|
|
1357
|
+
</Typography>
|
|
1358
|
+
<span css={displayNone} className={'filetype'}>
|
|
1359
|
+
{type}
|
|
1360
|
+
</span>
|
|
1361
|
+
<span css={displayNone} className={'filename'}>
|
|
1362
|
+
{name}
|
|
1363
|
+
</span>
|
|
1364
|
+
<span css={displayNone} className={'username'}>
|
|
1365
|
+
{item?.UserName || (item.lastModifiedDate && ownerName) || ''}
|
|
1366
|
+
</span>
|
|
1367
|
+
<span css={displayNone} className={'datetime'}>
|
|
1368
|
+
{getDateTime(date)}
|
|
1369
|
+
</span>
|
|
1370
|
+
<span css={displayNone} className={'filesize'}>
|
|
1371
|
+
{calculateSize(item.FileSize || item.size)}
|
|
1372
|
+
</span>
|
|
1373
|
+
{isNew ? (
|
|
1374
|
+
<span css={[_AttachedLinearCSS, displayNone]}>
|
|
1375
|
+
<LinearProgress className={`DGN-UI-LinearProgress-${key}`} determinate percent={0} />
|
|
1376
|
+
</span>
|
|
1377
|
+
) : null}
|
|
1378
|
+
</div>
|
|
1379
|
+
</Grid>
|
|
1380
|
+
);
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1383
|
+
const renderAttachmentItem = (item, idx, isNew = false) => {
|
|
1384
|
+
if (!item) return;
|
|
1385
|
+
const date = isNew ? new Date() : new Date(item.CreateDate);
|
|
1386
|
+
if (isNew) item.CreateDate = date.toISOString();
|
|
1387
|
+
return viewTypeState === 'detail'
|
|
1388
|
+
? renderAttachmentItemDetail(item, idx, isNew)
|
|
1389
|
+
: viewTypeState === 'icon'
|
|
1390
|
+
? renderAttachmentItemIcon(item, idx, isNew)
|
|
1391
|
+
: renderAttachmentItemPicture(item, idx, isNew);
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
const AttachedView = useMemo(() => {
|
|
1395
|
+
return (
|
|
1396
|
+
<ScrollBar css={_AttachmentListCSS} className={'DGN-UI-Attachment-List'}>
|
|
1397
|
+
<Grid
|
|
1398
|
+
container
|
|
1399
|
+
css={isSpecialCase && justifyCenter}
|
|
1400
|
+
ref={attachedRef}
|
|
1401
|
+
className={classNames('DGN-UI-Attachment-List-Attached')}
|
|
1402
|
+
spacing={2}
|
|
1403
|
+
>
|
|
1404
|
+
{dataState.map((item, idx) => {
|
|
1405
|
+
return renderAttachmentItem(mountDomain(item), idx);
|
|
1406
|
+
})}
|
|
1407
|
+
{newDataState.map((item, idx) => {
|
|
1408
|
+
return renderAttachmentItem(mountDomain(item), dataState?.length + idx, true);
|
|
1409
|
+
})}
|
|
1410
|
+
</Grid>
|
|
1411
|
+
</ScrollBar>
|
|
1412
|
+
);
|
|
1413
|
+
}, [data, domain, onViewProp, unitSize, dataState, newDataState, viewTypeState, sizeByHeight, theme]);
|
|
1414
|
+
|
|
1415
|
+
const PopupView = (
|
|
1416
|
+
<Popup
|
|
1417
|
+
open={showPopup}
|
|
1418
|
+
ref={popupRef}
|
|
1419
|
+
type={'yesno'}
|
|
1420
|
+
description={deleteNotifyText}
|
|
1421
|
+
pressESCToClose
|
|
1422
|
+
onClose={onClosePopup}
|
|
1423
|
+
onConfirm={onRemoveMultiple}
|
|
1424
|
+
onCancel={onClosePopup}
|
|
1425
|
+
/>
|
|
1426
|
+
);
|
|
1427
|
+
|
|
1428
|
+
const ModalView = useMemo(() => {
|
|
1429
|
+
if (!chosenItems.length) return setShowModal(false);
|
|
1430
|
+
const index = chosenItems[0];
|
|
1431
|
+
const data = mountDomain([...dataState, ...newDataState][index]);
|
|
1432
|
+
const dataType = getType(data);
|
|
1433
|
+
if (isBase64URL(data?.URL) && !['image', 'pdf'].includes(dataType)) setShowModal(false);
|
|
1434
|
+
|
|
1435
|
+
// let data = oldAttached[index] || allNewAttached.getAll('files')[index-oldAttached.length];
|
|
1436
|
+
return (
|
|
1437
|
+
<ModalSample open={showModal} title={data?.FileName} onClose={() => setShowModal(false)}>
|
|
1438
|
+
<Slider>
|
|
1439
|
+
<SliderItem dataType={dataType} url={data?.URL} />
|
|
1440
|
+
</Slider>
|
|
1441
|
+
</ModalSample>
|
|
1442
|
+
);
|
|
1443
|
+
}, [domain, showModal]);
|
|
1444
|
+
|
|
1445
|
+
const NotifyView = <Notify ref={notifyRef} progressing={true} autoDisappear={true} color={'danger'} />;
|
|
1446
|
+
// End view
|
|
1447
|
+
|
|
1448
|
+
return (
|
|
1449
|
+
<div
|
|
1450
|
+
ref={ref}
|
|
1451
|
+
css={_AttachmentRootCSS}
|
|
1452
|
+
id={id}
|
|
1453
|
+
className={classNames('DGN-UI-Attachment', className)}
|
|
1454
|
+
style={style}
|
|
1455
|
+
onDragEnter={onDragFileStart}
|
|
1456
|
+
>
|
|
1457
|
+
{AttachHeaderView}
|
|
1458
|
+
{AttachedView}
|
|
1459
|
+
{AttachmentInputView}
|
|
1460
|
+
{PopupView}
|
|
1461
|
+
{ModalView}
|
|
1462
|
+
{NotifyView}
|
|
1463
|
+
</div>
|
|
1464
|
+
);
|
|
1465
|
+
})
|
|
1466
|
+
);
|
|
1467
|
+
|
|
1468
|
+
const AttachmentHandleIconCSS = ({ colors, spacing }) => css`
|
|
1469
|
+
${displayNone};
|
|
1470
|
+
${parseHeight(24)};
|
|
1471
|
+
margin-right: ${spacing([2])};
|
|
1472
|
+
${borderRight(1, getProp(colors, 'line/normal'))};
|
|
1473
|
+
button {
|
|
1474
|
+
margin-right: ${spacing([2])};
|
|
1475
|
+
}
|
|
1476
|
+
`;
|
|
1477
|
+
|
|
1478
|
+
const AttachmentHeaderCSS = ({ spacing }) => css`
|
|
1479
|
+
${displayFlex};
|
|
1480
|
+
${itemsCenter};
|
|
1481
|
+
${justifyBetween};
|
|
1482
|
+
${boxBorder};
|
|
1483
|
+
${parseWidth('100%')};
|
|
1484
|
+
padding: ${spacing([4, 4])};
|
|
1485
|
+
`;
|
|
1486
|
+
|
|
1487
|
+
const AttachmentInfoCSS = ({ spacing }) => css`
|
|
1488
|
+
${displayFlex};
|
|
1489
|
+
gap: ${spacing([2])};
|
|
1490
|
+
`;
|
|
1491
|
+
|
|
1492
|
+
const AttachmentHeaderIconCSS = css`
|
|
1493
|
+
${displayFlex};
|
|
1494
|
+
${itemsCenter};
|
|
1495
|
+
`;
|
|
1496
|
+
|
|
1497
|
+
const AttachmentImageCenterCSS = css`
|
|
1498
|
+
${displayFlex};
|
|
1499
|
+
${flexCol};
|
|
1500
|
+
${justifyCenter};
|
|
1501
|
+
${itemsCenter};
|
|
1502
|
+
${parseWidthHeight('100%')};
|
|
1503
|
+
`;
|
|
1504
|
+
|
|
1505
|
+
const ButtonAttachmentCSS = ({ colors, spacing }) => css`
|
|
1506
|
+
${border(1, getProp(colors, 'line/normal'))};
|
|
1507
|
+
${borderDashed};
|
|
1508
|
+
margin: ${spacing([0, 'auto', 4])};
|
|
1509
|
+
`;
|
|
1510
|
+
|
|
1511
|
+
const AttachmentImageEmptyCSS = css`
|
|
1512
|
+
${positionAbsolute};
|
|
1513
|
+
${parseWidthHeight('100%')};
|
|
1514
|
+
${top(0)};
|
|
1515
|
+
${left(0)};
|
|
1516
|
+
`;
|
|
1517
|
+
|
|
1518
|
+
const AttachedItemInfoCSS = ({ spacing }) => css`
|
|
1519
|
+
${displayFlex};
|
|
1520
|
+
${itemsCenter};
|
|
1521
|
+
${userSelectNone};
|
|
1522
|
+
${parseMinWidth('calc(50% - 10px)')};
|
|
1523
|
+
margin-right: ${spacing([2])};
|
|
1524
|
+
`;
|
|
1525
|
+
|
|
1526
|
+
const DotNewFileDetailCSS = ({ colors }) => css`
|
|
1527
|
+
:after {
|
|
1528
|
+
content: '';
|
|
1529
|
+
${positionAbsolute};
|
|
1530
|
+
${borderRadius50};
|
|
1531
|
+
${parseWidthHeight(4, 4)};
|
|
1532
|
+
${bgColor(getProp(colors, 'semantic/success'))};
|
|
1533
|
+
${top(0)};
|
|
1534
|
+
${left(4)};
|
|
1535
|
+
}
|
|
1536
|
+
`;
|
|
1537
|
+
|
|
1538
|
+
const DotNewFileIconCSS = ({ colors }) => css`
|
|
1539
|
+
:after {
|
|
1540
|
+
content: '';
|
|
1541
|
+
${positionAbsolute};
|
|
1542
|
+
${borderRadius50};
|
|
1543
|
+
${parseWidthHeight(6, 6)};
|
|
1544
|
+
${bgColor(getProp(colors, 'semantic/success'))};
|
|
1545
|
+
${top(3)};
|
|
1546
|
+
${left(14)};
|
|
1547
|
+
}
|
|
1548
|
+
`;
|
|
1549
|
+
|
|
1550
|
+
const AttachedItemOwnerCSS = ({ colors }) => css`
|
|
1551
|
+
${displayFlex};
|
|
1552
|
+
${positionRelative};
|
|
1553
|
+
${itemsCenter};
|
|
1554
|
+
${userSelectNone};
|
|
1555
|
+
${parseHeight('100%')};
|
|
1556
|
+
${textColor(getProp(colors, 'text/sub'))};
|
|
1557
|
+
`;
|
|
1558
|
+
|
|
1559
|
+
const DetailInfoCSS = css`
|
|
1560
|
+
${displayFlex};
|
|
1561
|
+
${parseMinWidth(333)};
|
|
1562
|
+
.username {
|
|
1563
|
+
${displayInlineBlock};
|
|
1564
|
+
${truncate};
|
|
1565
|
+
${parseMinWidth(120)};
|
|
1566
|
+
${parseMaxWidth(120)};
|
|
1567
|
+
}
|
|
1568
|
+
.datetime {
|
|
1569
|
+
${displayInlineBlock};
|
|
1570
|
+
${parseMinWidth('max-content')};
|
|
1571
|
+
${parseMaxWidth('max-content')};
|
|
1572
|
+
}
|
|
1573
|
+
.filesize {
|
|
1574
|
+
${floatRight};
|
|
1575
|
+
${textRight};
|
|
1576
|
+
margin-left: auto;
|
|
1577
|
+
}
|
|
1578
|
+
`;
|
|
1579
|
+
|
|
1580
|
+
const AttachedLinearCSS = ({ colors }) => css`
|
|
1581
|
+
${displayFlex};
|
|
1582
|
+
${positionAbsolute};
|
|
1583
|
+
${itemsCenter};
|
|
1584
|
+
${bgColor(getProp(colors, 'system/standard'))};
|
|
1585
|
+
${parseWidthHeight('100%')};
|
|
1586
|
+
${top(0)};
|
|
1587
|
+
`;
|
|
1588
|
+
|
|
1589
|
+
const AttachedItemCSS = ({ colors }) => css`
|
|
1590
|
+
${positionRelative};
|
|
1591
|
+
${borderRadius4px};
|
|
1592
|
+
${cursorPointer};
|
|
1593
|
+
transition: padding 0.5s ease;
|
|
1594
|
+
&:hover {
|
|
1595
|
+
${bgColor(getProp(colors, 'fill/hover'))};
|
|
1596
|
+
}
|
|
1597
|
+
&:active {
|
|
1598
|
+
${bgColor(getProp(colors, 'fill/pressed'))};
|
|
1599
|
+
}
|
|
1600
|
+
&.chosen {
|
|
1601
|
+
${bgColor(getProp(colors, 'fill/focus'))};
|
|
1602
|
+
}
|
|
1603
|
+
`;
|
|
1604
|
+
|
|
1605
|
+
const AttachedItemDetailCSS = ({ spacing }) => css`
|
|
1606
|
+
${displayFlex};
|
|
1607
|
+
${justifyBetween};
|
|
1608
|
+
${itemsCenter};
|
|
1609
|
+
${parseMinHeight(24)};
|
|
1610
|
+
padding: ${spacing([0, 2])};
|
|
1611
|
+
`;
|
|
1612
|
+
|
|
1613
|
+
const AttachedItemIconInfoCSS = ({ spacing }) => css`
|
|
1614
|
+
${displayFlex};
|
|
1615
|
+
${flexCol};
|
|
1616
|
+
${itemsCenter};
|
|
1617
|
+
${positionRelative};
|
|
1618
|
+
${textCenter};
|
|
1619
|
+
padding: ${spacing([1, 2])};
|
|
1620
|
+
`;
|
|
1621
|
+
|
|
1622
|
+
const AttachmentListCSS = ({ spacing }) => css`
|
|
1623
|
+
${boxBorder};
|
|
1624
|
+
margin-right: ${spacing([1.25])};
|
|
1625
|
+
padding: ${spacing([0, 1, 2, 4])};
|
|
1626
|
+
overflow-y: scroll;
|
|
1627
|
+
`;
|
|
1628
|
+
|
|
1629
|
+
const AttachmentRootCSS = (isEmpty, isEnable, height, { colors }) => css`
|
|
1630
|
+
${displayFlex};
|
|
1631
|
+
${flexCol};
|
|
1632
|
+
${justifyStart};
|
|
1633
|
+
${positionRelative};
|
|
1634
|
+
${borderRadius4px};
|
|
1635
|
+
${boxBorder};
|
|
1636
|
+
${border(1, getProp(colors, 'line/normal'))};
|
|
1637
|
+
${parseMinHeight(isEmpty && !isEnable ? 120 : isEmpty ? 280 : null)};
|
|
1638
|
+
${parseHeight(height)};
|
|
1639
|
+
${bgColor(getProp(colors, 'system/standard'))};
|
|
1640
|
+
`;
|
|
1641
|
+
|
|
1642
|
+
const AttachedItemPictureCSS = ({ colors }) => css`
|
|
1643
|
+
${displayFlex};
|
|
1644
|
+
${positionRelative};
|
|
1645
|
+
${boxBorder};
|
|
1646
|
+
${borderRadius4px};
|
|
1647
|
+
${cursorPointer};
|
|
1648
|
+
${overflowHidden};
|
|
1649
|
+
${userSelectNone};
|
|
1650
|
+
${border(1, getProp(colors, 'line/category'))};
|
|
1651
|
+
&:focus,
|
|
1652
|
+
&:active,
|
|
1653
|
+
&.chosen {
|
|
1654
|
+
${border(2, getProp(colors, 'line/focus'))};
|
|
1655
|
+
}
|
|
1656
|
+
&:not(:hover) {
|
|
1657
|
+
.DGN-UI-Attachment-Item-Picture-Info {
|
|
1658
|
+
${displayNone};
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
`;
|
|
1662
|
+
|
|
1663
|
+
const AttachedItemPictureImageCSS = css`
|
|
1664
|
+
${itemsCenter};
|
|
1665
|
+
${justifyCenter};
|
|
1666
|
+
${aspectSquare};
|
|
1667
|
+
`;
|
|
1668
|
+
|
|
1669
|
+
const ItemPictureInfoCSS = ({ colors, spacing }) => css`
|
|
1670
|
+
${positionAbsolute};
|
|
1671
|
+
${boxBorder};
|
|
1672
|
+
${bottom(0)};
|
|
1673
|
+
${left(0)};
|
|
1674
|
+
padding: ${spacing([1, 2])};
|
|
1675
|
+
${bgColor(getProp(colors, 'fill/tooltip'))};
|
|
1676
|
+
${parseWidth('100%')};
|
|
1677
|
+
`;
|
|
1678
|
+
|
|
1679
|
+
// Attachment.defaultProps = {
|
|
1680
|
+
// allowDelete: true,
|
|
1681
|
+
// allowSort: true,
|
|
1682
|
+
// className: '',
|
|
1683
|
+
// data: [],
|
|
1684
|
+
// disabled: false,
|
|
1685
|
+
// height: 280,
|
|
1686
|
+
// maxFile: Infinity,
|
|
1687
|
+
// multiple: true,
|
|
1688
|
+
// style: {},
|
|
1689
|
+
// viewType: 'detail',
|
|
1690
|
+
// };
|
|
1691
|
+
|
|
1692
|
+
Attachment.propTypes = {
|
|
1693
|
+
/** File types that can be accepted. */
|
|
1694
|
+
accept: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
1695
|
+
/** If `true`, allow delete attachment. */
|
|
1696
|
+
allowDelete: PropTypes.bool,
|
|
1697
|
+
/** If `true`, allow sort. */
|
|
1698
|
+
allowSort: PropTypes.bool,
|
|
1699
|
+
/** Class for component. */
|
|
1700
|
+
className: PropTypes.string,
|
|
1701
|
+
/** List attachment:<br />
|
|
1702
|
+
* [{<br />
|
|
1703
|
+
* "AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
|
|
1704
|
+
* "URL": "https://apricot.diginet.com.vn/cdn-dev/file/demo.jpg",<br />
|
|
1705
|
+
* "FileName": "8a07bee1eeff17a14eee.jpg",<br />
|
|
1706
|
+
* "FileSize": 248837,<br />
|
|
1707
|
+
* "KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
|
|
1708
|
+
* "CreateUserID": "LEMONADMIN",<br />
|
|
1709
|
+
* "CreateDate": "2020-08-24T11:54:04.307Z",<br />
|
|
1710
|
+
* "UserName": "Quản trị hệ thống"<br />
|
|
1711
|
+
* }, ...]
|
|
1712
|
+
*/
|
|
1713
|
+
data: PropTypes.array,
|
|
1714
|
+
/** The message to display when deleting files. */
|
|
1715
|
+
deleteNotifyText: PropTypes.string,
|
|
1716
|
+
/** If `true`, the component is disabled. */
|
|
1717
|
+
disabled: PropTypes.bool,
|
|
1718
|
+
/** Domain of attachments. */
|
|
1719
|
+
domain: PropTypes.string,
|
|
1720
|
+
/** Error of attachment. */
|
|
1721
|
+
error: PropTypes.string,
|
|
1722
|
+
/** Height of the component. */
|
|
1723
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1724
|
+
/** Suggested passage attached. */
|
|
1725
|
+
hintText: PropTypes.string,
|
|
1726
|
+
/** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes) applied to the input element. */
|
|
1727
|
+
inputProps: PropTypes.object,
|
|
1728
|
+
/** If `true`, strip domain of attachments. */
|
|
1729
|
+
isStripDomain: PropTypes.bool,
|
|
1730
|
+
/** Label of the component. */
|
|
1731
|
+
label: PropTypes.string,
|
|
1732
|
+
/** Limit the number of uploaded files. */
|
|
1733
|
+
maxFile: PropTypes.number,
|
|
1734
|
+
/** Limit the size of uploaded files. */
|
|
1735
|
+
maxSize: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1736
|
+
/** Allows to attach multiple files. */
|
|
1737
|
+
multiple: PropTypes.bool,
|
|
1738
|
+
/** Callback fired when the files attached is changed. */
|
|
1739
|
+
onChange: PropTypes.func,
|
|
1740
|
+
/** Download attached event, if not it will use default. */
|
|
1741
|
+
onDownload: PropTypes.func,
|
|
1742
|
+
/**
|
|
1743
|
+
* event when removed file(s)
|
|
1744
|
+
*
|
|
1745
|
+
* return data: {<br/>
|
|
1746
|
+
* attached: [Files] (insist old and all new files )<br/>
|
|
1747
|
+
* allNewAttached: [Files]<br/>
|
|
1748
|
+
* oldAttached: [Files]<br/>
|
|
1749
|
+
* removedAttached: [Files]<br/>
|
|
1750
|
+
* element: [NodeList (just removed)]<br/>
|
|
1751
|
+
* }
|
|
1752
|
+
*/
|
|
1753
|
+
onRemove: PropTypes.func,
|
|
1754
|
+
/** View attached event, if not it will use default. */
|
|
1755
|
+
onView: PropTypes.func,
|
|
1756
|
+
/** Name of the person who attached the file when uploading the file. */
|
|
1757
|
+
ownerName: PropTypes.string,
|
|
1758
|
+
/** At least one attachment is required. */
|
|
1759
|
+
required: PropTypes.bool,
|
|
1760
|
+
/** Style inline of component. */
|
|
1761
|
+
style: PropTypes.object,
|
|
1762
|
+
/** Unit size name, default auto-detect. */
|
|
1763
|
+
unitSize: PropTypes.string,
|
|
1764
|
+
/** Errors show up when the file upload is corrupted. */
|
|
1765
|
+
uploadErrorInfo: PropTypes.object,
|
|
1766
|
+
/** The view type of files. */
|
|
1767
|
+
viewType: PropTypes.oneOf(['detail', 'icon', 'picture']),
|
|
1768
|
+
};
|
|
1769
|
+
|
|
1770
|
+
export default Attachment;
|