diginet-core-ui 1.3.24
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/assets/avatar/default.svg +3 -0
- package/assets/images/menu/dhr/Default.svg +13 -0
- package/assets/images/menu/dhr/MHRM00N0001.svg +14 -0
- package/assets/images/menu/dhr/MHRM09N0001.svg +1 -0
- package/assets/images/menu/dhr/MHRM09N0002.svg +3 -0
- package/assets/images/menu/dhr/MHRM09N0003.svg +25 -0
- package/assets/images/menu/dhr/MHRM25N0001.svg +26 -0
- package/assets/images/menu/dhr/MHRM29N0001.svg +30 -0
- package/assets/images/menu/dhr/MHRM29N0015.svg +63 -0
- package/assets/images/menu/dhr/MHRM39N0012.svg +43 -0
- package/assets/images/menu/dhr/MHRM39N0013.svg +24 -0
- package/assets/images/menu/dhr/MHRM39N0014.svg +14 -0
- package/assets/images/menu/dhr/MHRM39N0015.svg +36 -0
- package/assets/images/menu/dhr/MHRM39N0016.svg +23 -0
- package/assets/images/menu/dhr/MHRM77N0001.svg +28 -0
- package/assets/images/menu/dhr/MHRM84N0001.svg +27 -0
- package/assets/images/menu/dhr/MHRM84N0002.svg +24 -0
- package/assets/images/menu/dhr/MHRM89N0001.svg +16 -0
- package/assets/images/menu/dhr/MHRP00N0001.svg +10 -0
- package/assets/images/menu/dhr/MHRP09N0001.svg +22 -0
- package/assets/images/menu/dhr/MHRP09N0002.svg +19 -0
- package/assets/images/menu/dhr/MHRP09N0003.svg +12 -0
- package/assets/images/menu/dhr/MHRP09N0004.svg +6 -0
- package/assets/images/menu/dhr/MHRP09N0005.svg +10 -0
- package/assets/images/menu/dhr/MHRP09N0006.svg +17 -0
- package/assets/images/menu/dhr/MHRP09N0007.svg +15 -0
- package/assets/images/menu/dhr/MHRP09N0008.svg +8 -0
- package/assets/images/menu/dhr/MHRP09N0009.svg +10 -0
- package/assets/images/menu/dhr/MHRP09N0010.svg +12 -0
- package/assets/images/menu/dhr/MHRP09N0011.svg +16 -0
- package/assets/images/menu/dhr/MHRP09N0012.svg +6 -0
- package/assets/images/menu/dhr/MHRP09N0013.svg +8 -0
- package/assets/images/menu/dhr/MHRP09N0014.svg +11 -0
- package/assets/images/menu/dhr/MHRP09N0015.svg +12 -0
- package/assets/images/menu/dhr/MHRP09N0016.svg +18 -0
- package/assets/images/menu/dhr/MHRP09N0017.svg +18 -0
- package/assets/images/menu/dhr/MHRP09N0018.svg +12 -0
- package/assets/images/menu/dhr/MHRP09N0019.svg +13 -0
- package/assets/images/menu/dhr/MHRP09N0020.svg +17 -0
- package/assets/images/menu/dhr/MHRP09N0021.svg +10 -0
- package/assets/images/menu/dhr/MHRP09N0022.svg +16 -0
- package/assets/images/menu/dhr/MHRP09N0023.svg +8 -0
- package/assets/images/menu/dhr/MHRP09N0024.svg +15 -0
- package/assets/images/menu/dhr/MHRP09N0025.svg +16 -0
- package/assets/images/menu/dhr/MHRP09N0026.svg +13 -0
- package/assets/images/menu/dhr/MHRP09N0027.svg +10 -0
- package/assets/images/menu/dhr/MHRP13N0001.svg +9 -0
- package/assets/images/menu/dhr/MHRP21N0001.svg +12 -0
- package/assets/images/menu/dhr/MHRP21N0002.svg +13 -0
- package/assets/images/menu/dhr/MHRP25N0001.svg +13 -0
- package/assets/images/menu/dhr/MHRP25N0002.svg +16 -0
- package/assets/images/menu/dhr/MHRP25N0003.svg +38 -0
- package/assets/images/menu/dhr/MHRP25N0004.svg +17 -0
- package/assets/images/menu/dhr/MHRP25N0005.svg +20 -0
- package/assets/images/menu/dhr/MHRP29N0001.svg +18 -0
- package/assets/images/menu/dhr/MHRP29N0002.svg +15 -0
- package/assets/images/menu/dhr/MHRP29N0003.svg +20 -0
- package/assets/images/menu/dhr/MHRP29N0004.svg +21 -0
- package/assets/images/menu/dhr/MHRP29N0005.svg +21 -0
- package/assets/images/menu/dhr/MHRP29N0006.svg +14 -0
- package/assets/images/menu/dhr/MHRP29N0007.svg +19 -0
- package/assets/images/menu/dhr/MHRP29N0008.svg +20 -0
- package/assets/images/menu/dhr/MHRP29N0009.svg +11 -0
- package/assets/images/menu/dhr/MHRP29N0010.svg +11 -0
- package/assets/images/menu/dhr/MHRP29N0011.svg +12 -0
- package/assets/images/menu/dhr/MHRP29N0013.svg +27 -0
- package/assets/images/menu/dhr/MHRP29N0014.svg +32 -0
- package/assets/images/menu/dhr/MHRP29N0016.svg +54 -0
- package/assets/images/menu/dhr/MHRP29N0017.svg +24 -0
- package/assets/images/menu/dhr/MHRP29N0018.svg +44 -0
- package/assets/images/menu/dhr/MHRP29N0019.svg +17 -0
- package/assets/images/menu/dhr/MHRP29N0020.svg +11 -0
- package/assets/images/menu/dhr/MHRP38N0001.svg +13 -0
- package/assets/images/menu/dhr/MHRP38N0002.svg +14 -0
- package/assets/images/menu/dhr/MHRP39N0001.svg +15 -0
- package/assets/images/menu/dhr/MHRP39N0002.svg +13 -0
- package/assets/images/menu/dhr/MHRP39N0003.svg +16 -0
- package/assets/images/menu/dhr/MHRP39N0004.svg +22 -0
- package/assets/images/menu/dhr/MHRP39N0005.svg +16 -0
- package/assets/images/menu/dhr/MHRP39N0006.svg +17 -0
- package/assets/images/menu/dhr/MHRP39N0007.svg +13 -0
- package/assets/images/menu/dhr/MHRP39N0008.svg +3 -0
- package/assets/images/menu/dhr/MHRP39N0009.svg +3 -0
- package/assets/images/menu/dhr/MHRP39N0010.svg +7 -0
- package/assets/images/menu/dhr/MHRP39N0011.svg +14 -0
- package/assets/images/menu/dhr/MHRP39N0013.svg +10 -0
- package/assets/images/menu/dhr/MHRP39N0014.svg +11 -0
- package/assets/images/menu/dhr/MHRP39N1222.svg +12 -0
- package/assets/images/menu/dhr/MHRP51N0001.svg +9 -0
- package/assets/images/menu/dhr/MHRP51N0002.svg +13 -0
- package/assets/images/menu/dhr/MHRP52N0001.svg +21 -0
- package/assets/images/menu/dhr/MHRP52N0002.svg +21 -0
- package/assets/images/menu/dhr/MHRP52N0003.svg +16 -0
- package/assets/images/menu/dhr/MHRP75N0001.svg +19 -0
- package/assets/images/menu/dhr/MHRP75N0002.svg +25 -0
- package/assets/images/menu/dhr/MHRP75N0003.svg +3 -0
- package/assets/images/menu/dhr/MHRP75N0006.svg +14 -0
- package/assets/images/menu/dhr/MHRP75N0007.svg +19 -0
- package/assets/images/menu/dhr/MHRP75N0008.svg +19 -0
- package/assets/images/menu/dhr/MHRP77N0007.svg +28 -0
- package/assets/images/menu/dhr/MHRP77N0008.svg +17 -0
- package/assets/images/menu/dhr/MHRP77N0009.svg +19 -0
- package/assets/images/menu/dhr/MHRP77N0010.svg +20 -0
- package/assets/images/menu/dhr/MHRP89N1000.svg +6 -0
- package/assets/images/menu/dhr/MHRP89N1001.svg +6 -0
- package/assets/images/menu/dhr/W00F0001.svg +3 -0
- package/assets/images/menu/dhr/W00F0002.svg +3 -0
- package/assets/images/menu/dhr/W00F0003.svg +3 -0
- package/assets/images/menu/dhr/W00F0004.svg +3 -0
- package/assets/images/menu/dhr/W00F0005.svg +1 -0
- package/assets/images/menu/dhr/W09F2000-WEB5.svg +17 -0
- package/assets/images/menu/dhr/W09F2000.svg +6 -0
- package/assets/images/menu/dhr/W09F2002-WEB5.svg +21 -0
- package/assets/images/menu/dhr/W09F2005-WEB5.svg +13 -0
- package/assets/images/menu/dhr/W09F2020-WEB5.svg +16 -0
- package/assets/images/menu/dhr/W09F2022-WEB5.svg +20 -0
- package/assets/images/menu/dhr/W09F2150-WEB5.svg +16 -0
- package/assets/images/menu/dhr/W09F2152-WEB5.svg +20 -0
- package/assets/images/menu/dhr/W09F2160-WEB5.svg +14 -0
- package/assets/images/menu/dhr/W09F2162-WEB5.svg +18 -0
- package/assets/images/menu/dhr/W29F4006-WEB5.svg +19 -0
- package/assets/images/menu/dhr/W75F2260-WEB5.svg +15 -0
- package/assets/images/menu/dhr/W75F2261-WEB5.svg +19 -0
- package/assets/images/menu/dhr/W75F3005-WEB5.svg +13 -0
- package/assets/images/menu/dhr/W75F4070-WEB5.svg +21 -0
- package/assets/images/menu/dhr/W75F4071-WEB5.svg +17 -0
- package/assets/images/menu/dhr/W75F4100-WEB5.svg +14 -0
- package/assets/images/menu/dhr/W77F1011.svg +19 -0
- package/assets/images/menu/dhr/W77F1013.svg +22 -0
- package/assets/images/menu/erp/W00F0001.svg +3 -0
- package/assets/images/menu/erp/W00F0002.svg +3 -0
- package/assets/images/menu/erp/W00F0003.svg +3 -0
- package/assets/images/menu/erp/W00F0004.svg +3 -0
- package/assets/images/menu/erp/W05F0001.svg +16 -0
- package/assets/images/menu/erp/W05F0001N0000.svg +16 -0
- package/assets/images/menu/erp/W05F0004N0000.svg +6 -0
- package/assets/images/menu/erp/W05F0006.svg +30 -0
- package/assets/images/menu/erp/W05F0007N0000.svg +6 -0
- package/assets/images/menu/erp/W05F0008.svg +14 -0
- package/assets/images/menu/erp/W05F4000.svg +9 -0
- package/assets/images/menu/erp/W06F0001.svg +17 -0
- package/assets/images/menu/erp/W06F0001N0000.svg +17 -0
- package/assets/images/menu/erp/W06F0004N0000.svg +22 -0
- package/assets/images/menu/erp/W06F0005.svg +22 -0
- package/assets/images/menu/erp/W06F0006.svg +55 -0
- package/assets/images/menu/erp/W06F0008.svg +17 -0
- package/assets/images/menu/erp/WA3F1025.svg +5 -0
- package/assets/images/menu/erp/WA3F2100.svg +10 -0
- package/components/accordion/context.js +6 -0
- package/components/accordion/css.js +159 -0
- package/components/accordion/details.js +60 -0
- package/components/accordion/group.js +122 -0
- package/components/accordion/index.js +117 -0
- package/components/accordion/summary.js +175 -0
- package/components/alert/index.js +264 -0
- package/components/alert/notify.js +192 -0
- package/components/avatar/index.js +556 -0
- package/components/badge/index.js +223 -0
- package/components/button/icon.js +493 -0
- package/components/button/index.js +653 -0
- package/components/button/more.js +135 -0
- package/components/button/ripple-effect.js +85 -0
- package/components/card/body-card.js +67 -0
- package/components/card/card.js +127 -0
- package/components/card/context.js +6 -0
- package/components/card/index.js +50 -0
- package/components/chart/Pie/Circle.js +50 -0
- package/components/chart/Pie/Sector.js +142 -0
- package/components/chart/Pie/Sectors.js +91 -0
- package/components/chart/Pie/index.js +311 -0
- package/components/chart/Pie-v2/Circle.js +50 -0
- package/components/chart/Pie-v2/Sector.js +128 -0
- package/components/chart/Pie-v2/Sectors.js +224 -0
- package/components/chart/Pie-v2/index.js +397 -0
- package/components/chart/bar/Axis.js +79 -0
- package/components/chart/bar/Bar.js +365 -0
- package/components/chart/bar/Grid.js +115 -0
- package/components/chart/bar/Labels.js +175 -0
- package/components/chart/bar/Points.js +111 -0
- package/components/chart/bar/index.js +172 -0
- package/components/chart/bar-v2/Axis.js +79 -0
- package/components/chart/bar-v2/Bar.js +374 -0
- package/components/chart/bar-v2/Grid.js +115 -0
- package/components/chart/bar-v2/Labels.js +175 -0
- package/components/chart/bar-v2/Points.js +111 -0
- package/components/chart/bar-v2/index.js +172 -0
- package/components/chart/line/Axis.js +79 -0
- package/components/chart/line/Grid.js +115 -0
- package/components/chart/line/Labels.js +172 -0
- package/components/chart/line/Path.js +163 -0
- package/components/chart/line/Point.js +348 -0
- package/components/chart/line/Title.js +56 -0
- package/components/chart/line/index.js +174 -0
- package/components/chart/line-v2/Axis.js +79 -0
- package/components/chart/line-v2/Grid.js +115 -0
- package/components/chart/line-v2/Labels.js +172 -0
- package/components/chart/line-v2/Path.js +163 -0
- package/components/chart/line-v2/Point.js +354 -0
- package/components/chart/line-v2/Title.js +56 -0
- package/components/chart/line-v2/index.js +174 -0
- package/components/check-text/index.js +157 -0
- package/components/check-text/interview-confirmation.js +172 -0
- package/components/check-text/interview-status.js +138 -0
- package/components/chip/attach.js +180 -0
- package/components/chip/index.js +340 -0
- package/components/collapse/index.js +67 -0
- package/components/dialogs/colors.js +11 -0
- package/components/divider/index.js +71 -0
- package/components/divider/style.js +12 -0
- package/components/form-control/attachment/index.js +1890 -0
- package/components/form-control/calendar/function.js +673 -0
- package/components/form-control/calendar/index.js +248 -0
- package/components/form-control/calendar/range.js +293 -0
- package/components/form-control/checkbox/index.js +306 -0
- package/components/form-control/control/index.js +92 -0
- package/components/form-control/date-picker/index-old.js +953 -0
- package/components/form-control/date-picker/index.js +676 -0
- package/components/form-control/date-range-picker/index.js +1305 -0
- package/components/form-control/dropdown/index.js +1865 -0
- package/components/form-control/dropdown-box/index.js +292 -0
- package/components/form-control/form/context.js +5 -0
- package/components/form-control/form/index.js +41 -0
- package/components/form-control/form-group/index.js +118 -0
- package/components/form-control/helper-text/index.js +71 -0
- package/components/form-control/input-base/index.js +733 -0
- package/components/form-control/label/index.js +73 -0
- package/components/form-control/money-input/index.js +491 -0
- package/components/form-control/number-input/index.js +633 -0
- package/components/form-control/phone-input/index.js +433 -0
- package/components/form-control/radio/index.js +263 -0
- package/components/form-control/text-input/index.js +523 -0
- package/components/form-control/time-picker/index.js +829 -0
- package/components/form-control/time-picker/swiper.js +590 -0
- package/components/form-control/toggle/index.js +250 -0
- package/components/form-view/helper-text.js +33 -0
- package/components/form-view/index.js +107 -0
- package/components/form-view/input.js +129 -0
- package/components/form-view/label.js +38 -0
- package/components/index.js +100 -0
- package/components/list/list-item-action.js +82 -0
- package/components/list/list-item-icon.js +76 -0
- package/components/list/list-item-text.js +57 -0
- package/components/list/list-item.js +114 -0
- package/components/list/list.js +155 -0
- package/components/list/sub-header.js +61 -0
- package/components/modal/body.js +71 -0
- package/components/modal/context.js +6 -0
- package/components/modal/footer.js +63 -0
- package/components/modal/header.js +108 -0
- package/components/modal/index.js +69 -0
- package/components/modal/modal.js +339 -0
- package/components/others/extra/index.js +124 -0
- package/components/others/scrollbar/index.js +95 -0
- package/components/paging/page-info.js +298 -0
- package/components/paging/page-selector.js +281 -0
- package/components/paper/index.js +119 -0
- package/components/popover/index.js +417 -0
- package/components/popup/danger_popup.js +215 -0
- package/components/popup/index.js +469 -0
- package/components/popup/proposals_popup.js +364 -0
- package/components/popup/v2/danger-popup.js +17 -0
- package/components/popup/v2/index.js +460 -0
- package/components/popup/v2/info-popup.js +17 -0
- package/components/popup/v2/success-popup.js +17 -0
- package/components/popup/v2/warning-popup.js +17 -0
- package/components/popup/v2/yes-no-popup.js +20 -0
- package/components/progress/circular.js +414 -0
- package/components/progress/linear.js +327 -0
- package/components/rating/index.js +392 -0
- package/components/slider/slider-container.js +356 -0
- package/components/slider/slider-item.js +183 -0
- package/components/status/index.js +123 -0
- package/components/tab/context.js +3 -0
- package/components/tab/tab-container.js +83 -0
- package/components/tab/tab-header.js +133 -0
- package/components/tab/tab-panel.js +51 -0
- package/components/tab/tab.js +206 -0
- package/components/tooltip/index.js +602 -0
- package/components/tooltip/portal.js +13 -0
- package/components/transfer/index.js +489 -0
- package/components/tree-view/css.js +94 -0
- package/components/tree-view/index.js +1009 -0
- package/components/typography/index.js +218 -0
- package/css/styles.css +1 -0
- package/css/styles.css.map +1 -0
- package/global/index.js +175 -0
- package/icons/basic.js +6326 -0
- package/icons/effect.js +171 -0
- package/icons/general/clock/clock.js +21 -0
- package/icons/general/color-handler/background.js +41 -0
- package/icons/general/color-handler/text.js +41 -0
- package/icons/general/emoji/emoji.js +35 -0
- package/icons/general/font-properties/bold.js +21 -0
- package/icons/general/font-properties/font-family.js +35 -0
- package/icons/general/font-properties/font-size.js +27 -0
- package/icons/general/font-properties/italic.js +21 -0
- package/icons/general/font-properties/underline.js +31 -0
- package/icons/general/hyperlink/hyperlink.js +38 -0
- package/icons/general/indent/decrease.js +55 -0
- package/icons/general/indent/increase.js +55 -0
- package/icons/general/index.js +21 -0
- package/icons/general/list/bullets.js +77 -0
- package/icons/general/list/numbering.js +71 -0
- package/icons/general/picture/picture.js +21 -0
- package/icons/general/steps/redo.js +21 -0
- package/icons/general/steps/undo.js +21 -0
- package/icons/general/text-align/center.js +21 -0
- package/icons/general/text-align/justify.js +21 -0
- package/icons/general/text-align/left.js +21 -0
- package/icons/general/text-align/right.js +21 -0
- package/icons/index.js +3 -0
- package/icons/menu/dhr.js +2440 -0
- package/icons/menu/erp.js +490 -0
- package/icons/menu/index.js +5 -0
- package/icons/menu/v2/index.js +52 -0
- package/locale/index.js +11 -0
- package/package.json +45 -0
- package/readme.md +517 -0
- package/styles/animation.js +890 -0
- package/styles/color-helper.js +504 -0
- package/styles/colors.js +306 -0
- package/styles/general.js +48 -0
- package/styles/media-queries.js +10 -0
- package/styles/typography.js +122 -0
- package/styles/utils.js +10 -0
- package/theme/index.js +5 -0
- package/theme/make-styles.js +95 -0
- package/theme/set-theme.js +39 -0
- package/theme/settings.js +230 -0
- package/theme/theme-provider.js +68 -0
- package/theme/theme.js +56 -0
- package/theme/with-styles.js +17 -0
- package/theme/with-theme.js +11 -0
- package/utils/array/array.js +186 -0
- package/utils/console.js +34 -0
- package/utils/date.js +471 -0
- package/utils/error/error.js +62 -0
- package/utils/error/errors.js +247 -0
- package/utils/getFileType.js +32 -0
- package/utils/index.js +23 -0
- package/utils/iterator.js +45 -0
- package/utils/map-parent.js +53 -0
- package/utils/number.js +64 -0
- package/utils/object/extend.js +57 -0
- package/utils/object/object.js +68 -0
- package/utils/parseHTML.js +8 -0
- package/utils/promisify.js +38 -0
- package/utils/randomString.js +33 -0
- package/utils/remove-unicode.js +6 -0
- package/utils/render-portal.js +90 -0
- package/utils/renderHTML.js +21 -0
- package/utils/renderIcon.js +57 -0
- package/utils/string/capitalize.js +3 -0
- package/utils/string/capitalizeSentenceCase.js +10 -0
- package/utils/string/string.js +81 -0
- package/utils/type.js +90 -0
- package/utils/updatePosition.js +36 -0
- package/utils/useOnClickOutside.js +23 -0
- package/utils/usePortal.js +56 -0
- package/utils/validate.js +149 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** @jsxRuntime classic */
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { memo, useEffect, useRef, forwardRef } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
const Collapse = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
10
|
+
open,
|
|
11
|
+
children,
|
|
12
|
+
...props
|
|
13
|
+
}, ref) => {
|
|
14
|
+
if (!ref) {
|
|
15
|
+
ref = useRef(null);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const CollapseRoot = css`
|
|
19
|
+
display: block;
|
|
20
|
+
position: relative;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 0;
|
|
23
|
+
transition: height 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
24
|
+
overflow-y: clip;
|
|
25
|
+
`;
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (open) {
|
|
28
|
+
const scrollHeight = ref.current.scrollHeight;
|
|
29
|
+
const duration = Math.min(scrollHeight, 1500);
|
|
30
|
+
ref.current.style.transitionDuration = duration + 'ms';
|
|
31
|
+
ref.current.style.height = scrollHeight + 'px';
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
if (ref.current) {
|
|
34
|
+
ref.current.style.height = 'auto';
|
|
35
|
+
}
|
|
36
|
+
}, duration);
|
|
37
|
+
return () => {
|
|
38
|
+
if (ref.current) {
|
|
39
|
+
ref.current.style.height = scrollHeight + 'px';
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
if (ref.current) {
|
|
42
|
+
ref.current.style.height = null;
|
|
43
|
+
}
|
|
44
|
+
}, 0);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}, [open]);
|
|
49
|
+
return jsx("div", _extends({
|
|
50
|
+
css: CollapseRoot,
|
|
51
|
+
ref: ref
|
|
52
|
+
}, props), children);
|
|
53
|
+
}));
|
|
54
|
+
Collapse.defaultProps = {
|
|
55
|
+
open: false
|
|
56
|
+
};
|
|
57
|
+
Collapse.propTypes = {
|
|
58
|
+
/** expand content if true */
|
|
59
|
+
open: PropTypes.bool,
|
|
60
|
+
|
|
61
|
+
/** The element to display in alert like text props (priority) */
|
|
62
|
+
children: PropTypes.node,
|
|
63
|
+
|
|
64
|
+
/** any props else */
|
|
65
|
+
props: PropTypes.any
|
|
66
|
+
};
|
|
67
|
+
export default Collapse;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const iconDefault = '#687799';
|
|
2
|
+
export const iconHover = '#111d5e';
|
|
3
|
+
export const iconDisabled = '#8f9bb3';
|
|
4
|
+
export const fillHover = '#eff5ff';
|
|
5
|
+
export const fillDisabled = '#e7eaf0';
|
|
6
|
+
export const fillDefault = '#8f9bb3';
|
|
7
|
+
export const fillPath = '#fff';
|
|
8
|
+
export const uiSuccess = '#00c875';
|
|
9
|
+
export const uiWarning = '#ffaa00';
|
|
10
|
+
export const uiDanger = '#ff3d71';
|
|
11
|
+
export const uiInfo = '#0095ff';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** @jsxRuntime classic */
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { memo, useMemo, useEffect, useRef, forwardRef } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import theme from '../../theme/settings';
|
|
10
|
+
const Divider = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
11
|
+
children,
|
|
12
|
+
width,
|
|
13
|
+
height,
|
|
14
|
+
direction,
|
|
15
|
+
color,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}, ref) => {
|
|
19
|
+
if (!ref) {
|
|
20
|
+
ref = useRef(null);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const DividerRoot = css`
|
|
24
|
+
display: block;
|
|
25
|
+
position: relative;
|
|
26
|
+
background-color: ${theme.colors[color] || color};
|
|
27
|
+
&.vertical {
|
|
28
|
+
width: ${width ? isNaN(width) ? width : width + 'px' : '1px'};
|
|
29
|
+
height: ${height ? isNaN(height) ? height : height + 'px' : '100%'};
|
|
30
|
+
margin: auto 5px;
|
|
31
|
+
}
|
|
32
|
+
&.horizontal {
|
|
33
|
+
width: ${width ? isNaN(width) ? height : width + 'px' : '100%'};
|
|
34
|
+
height: ${height ? isNaN(height) ? height : height + 'px' : '1px'};
|
|
35
|
+
margin: 5px auto;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (direction === 'vertical' && !height && ref.current && ref.current.parentNode) {
|
|
40
|
+
ref.current.style.height = ref.current.parentNode.offsetHeight + 'px';
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
const DividerView = useMemo(() => jsx("div", _extends({
|
|
44
|
+
css: DividerRoot,
|
|
45
|
+
ref: ref,
|
|
46
|
+
className: ['DGN-UI-Divider', direction, className].join(' ').trim()
|
|
47
|
+
}, props), children), []);
|
|
48
|
+
return DividerView;
|
|
49
|
+
}));
|
|
50
|
+
Divider.defaultProps = {
|
|
51
|
+
color: theme.colors.divider,
|
|
52
|
+
direction: 'horizontal',
|
|
53
|
+
className: ''
|
|
54
|
+
};
|
|
55
|
+
Divider.propTypes = {
|
|
56
|
+
/** width of divider */
|
|
57
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
58
|
+
|
|
59
|
+
/** color of divider */
|
|
60
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
61
|
+
|
|
62
|
+
/** color of divider */
|
|
63
|
+
color: PropTypes.string,
|
|
64
|
+
|
|
65
|
+
/** direction of divider */
|
|
66
|
+
direction: PropTypes.oneOf(['vertical', 'horizontal']),
|
|
67
|
+
|
|
68
|
+
/** any props else */
|
|
69
|
+
props: PropTypes.object
|
|
70
|
+
};
|
|
71
|
+
export default Divider;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default ((width, height) => ({
|
|
2
|
+
vertical: `
|
|
3
|
+
width: ${isNaN(width) ? width : width + 'px'};
|
|
4
|
+
height: 100%;
|
|
5
|
+
margin: auto 5px;
|
|
6
|
+
`,
|
|
7
|
+
horizontal: `
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: ${isNaN(height) ? height : height + 'px'};
|
|
10
|
+
margin: 5px auto;
|
|
11
|
+
`
|
|
12
|
+
}));
|
|
@@ -0,0 +1,1890 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** @jsxRuntime classic */
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { memo, useMemo, useEffect, useState, useRef, forwardRef, useImperativeHandle } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import ReactDOM from 'react-dom';
|
|
9
|
+
import { jsx, css } from '@emotion/core';
|
|
10
|
+
import { success5, danger5, info5, color } from '../../../styles/colors';
|
|
11
|
+
import { fontFamily, typography } from '../../../styles/typography';
|
|
12
|
+
import { ModalSample, Popup, Popover, List, ListItem, ListItemIcon, ListItemText, Slider, SliderItem, ScrollBar, LinearProgress } from '../../';
|
|
13
|
+
import Icon, { Pdf, Word, Sheet, Presentation, Compressed, Image, Another, Info, View, Download, Delete, Attachment as AttachmentIcon } from '../../../icons';
|
|
14
|
+
import { date as moment, getFileType } from '../../../utils';
|
|
15
|
+
import { getGlobal } from '../../../global';
|
|
16
|
+
import { useTheme, makeStyles } from '../../../theme';
|
|
17
|
+
import { Fragment } from 'react';
|
|
18
|
+
const theme = useTheme();
|
|
19
|
+
const useStyles = makeStyles({
|
|
20
|
+
listItem: {
|
|
21
|
+
'&.DGN-UI-List-Item': {
|
|
22
|
+
'.DGN-UI-List-Item-Icon': {
|
|
23
|
+
minWidth: '28px',
|
|
24
|
+
svg: {
|
|
25
|
+
visibility: 'hidden',
|
|
26
|
+
transform: 'rotate(-90deg)'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
'&.DGN-Active': {
|
|
30
|
+
'.DGN-UI-List-Item-Icon': {
|
|
31
|
+
svg: {
|
|
32
|
+
visibility: 'visible',
|
|
33
|
+
transform: 'rotate(90deg)'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
'&.DGN-Decrease': {
|
|
37
|
+
'.DGN-UI-List-Item-Icon': {
|
|
38
|
+
svg: {
|
|
39
|
+
transform: 'rotate(-90deg)'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const classes = useStyles();
|
|
48
|
+
const icons = {
|
|
49
|
+
detail: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
50
|
+
<path fillRule="evenodd" clipRule="evenodd" d="M6.5 4C5.12167 4 4 5.11457 4 6.48418C4 7.85379 5.12167 8.96835 6.5 8.96835C7.87833 8.96835 9 7.85379 9 6.48418C9 5.11457 7.87833 4 6.5 4ZM12.3333 4C10.955 4 9.83333 5.11457 9.83333 6.48418C9.83333 7.85379 10.955 8.96835 12.3333 8.96835C13.7117 8.96835 14.8333 7.85379 14.8333 6.48418C14.8333 5.11457 13.7117 4 12.3333 4ZM20.6667 6.48418C20.6667 7.85379 19.545 8.96835 18.1667 8.96835C16.7883 8.96835 15.6667 7.85379 15.6667 6.48418C15.6667 5.11457 16.7883 4 18.1667 4C19.545 4 20.6667 5.11457 20.6667 6.48418ZM6.5 9.79641C5.12167 9.79641 4 10.911 4 12.2806C4 13.6502 5.12167 14.7648 6.5 14.7648C7.87833 14.7648 9 13.6502 9 12.2806C9 10.911 7.87833 9.79641 6.5 9.79641ZM9.83333 12.2806C9.83333 10.911 10.955 9.79641 12.3333 9.79641C13.7117 9.79641 14.8333 10.911 14.8333 12.2806C14.8333 13.6502 13.7117 14.7648 12.3333 14.7648C10.955 14.7648 9.83333 13.6502 9.83333 12.2806ZM18.1667 9.79641C16.7883 9.79641 15.6667 10.911 15.6667 12.2806C15.6667 13.6502 16.7883 14.7648 18.1667 14.7648C19.545 14.7648 20.6667 13.6502 20.6667 12.2806C20.6667 10.911 19.545 9.79641 18.1667 9.79641ZM4 18.077C4 16.7074 5.12167 15.5928 6.5 15.5928C7.87833 15.5928 9 16.7074 9 18.077C9 19.4466 7.87833 20.5612 6.5 20.5612C5.12167 20.5612 4 19.4466 4 18.077ZM12.3333 15.5928C10.955 15.5928 9.83333 16.7074 9.83333 18.077C9.83333 19.4466 10.955 20.5612 12.3333 20.5612C13.7117 20.5612 14.8333 19.4466 14.8333 18.077C14.8333 16.7074 13.7117 15.5928 12.3333 15.5928ZM15.6667 18.077C15.6667 16.7074 16.7883 15.5928 18.1667 15.5928C19.545 15.5928 20.6667 16.7074 20.6667 18.077C20.6667 19.4466 19.545 20.5612 18.1667 20.5612C16.7883 20.5612 15.6667 19.4466 15.6667 18.077Z" fill="currentColor"/>
|
|
51
|
+
</svg>`,
|
|
52
|
+
icon: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
53
|
+
<path fillRule="evenodd" clipRule="evenodd" d="M3 7C3 6.448 3.448 6 4 6C4.552 6 5 6.448 5 7C5 7.552 4.552 8 4 8C3.448 8 3 7.552 3 7ZM3 12C3 11.448 3.448 11 4 11C4.552 11 5 11.448 5 12C5 12.552 4.552 13 4 13C3.448 13 3 12.552 3 12ZM4 16C3.448 16 3 16.448 3 17C3 17.552 3.448 18 4 18C4.552 18 5 17.552 5 17C5 16.448 4.552 16 4 16ZM7.9355 11H20.0645C20.5795 11 21.0005 11.421 21.0005 11.936V12.064C21.0005 12.579 20.5795 13 20.0645 13H7.9355C7.4205 13 7.0005 12.579 7.0005 12.064V11.936C7.0005 11.421 7.4205 11 7.9355 11ZM20.0645 16H7.9355C7.4205 16 7.0005 16.421 7.0005 16.936V17.064C7.0005 17.579 7.4205 18 7.9355 18H20.0645C20.5795 18 21.0005 17.579 21.0005 17.064V16.936C21.0005 16.421 20.5795 16 20.0645 16ZM7.9355 6H20.0645C20.5795 6 21.0005 6.421 21.0005 6.936V7.064C21.0005 7.579 20.5795 8 20.0645 8H7.9355C7.4205 8 7.0005 7.579 7.0005 7.064V6.936C7.0005 6.421 7.4205 6 7.9355 6Z" fill="currentColor"/>
|
|
54
|
+
</svg>`,
|
|
55
|
+
pdf: jsx(Pdf, {
|
|
56
|
+
width: '100%',
|
|
57
|
+
height: '100%'
|
|
58
|
+
}),
|
|
59
|
+
word: jsx(Word, {
|
|
60
|
+
width: '100%',
|
|
61
|
+
height: '100%'
|
|
62
|
+
}),
|
|
63
|
+
sheet: jsx(Sheet, {
|
|
64
|
+
width: '100%',
|
|
65
|
+
height: '100%'
|
|
66
|
+
}),
|
|
67
|
+
presentation: jsx(Presentation, {
|
|
68
|
+
width: '100%',
|
|
69
|
+
height: '100%'
|
|
70
|
+
}),
|
|
71
|
+
image: jsx(Image, {
|
|
72
|
+
width: '100%',
|
|
73
|
+
height: '100%'
|
|
74
|
+
}),
|
|
75
|
+
compressed: jsx(Compressed, {
|
|
76
|
+
width: '100%',
|
|
77
|
+
height: '100%'
|
|
78
|
+
}),
|
|
79
|
+
default: jsx(Another, {
|
|
80
|
+
width: '100%',
|
|
81
|
+
height: '100%'
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
const oldAttached = [];
|
|
85
|
+
const allNewAttached = new FormData();
|
|
86
|
+
const attached = [];
|
|
87
|
+
const chosenItems = [];
|
|
88
|
+
let timer = null;
|
|
89
|
+
let prevent = false;
|
|
90
|
+
let existClickOutOfItem = false;
|
|
91
|
+
let maxSize = Infinity;
|
|
92
|
+
let divideSize = null;
|
|
93
|
+
const errorDefault = getGlobal('errorDefault');
|
|
94
|
+
const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
95
|
+
viewType,
|
|
96
|
+
label,
|
|
97
|
+
className,
|
|
98
|
+
deleteNotifyText,
|
|
99
|
+
ownerName,
|
|
100
|
+
hintText,
|
|
101
|
+
multiple,
|
|
102
|
+
disabled,
|
|
103
|
+
allowSort,
|
|
104
|
+
onRemove: onRemoveItem,
|
|
105
|
+
onView: onViewItem,
|
|
106
|
+
onDownload: onDownloadItem,
|
|
107
|
+
onChange,
|
|
108
|
+
onUploadError,
|
|
109
|
+
data,
|
|
110
|
+
maxFile,
|
|
111
|
+
maxSize: maxSizeProp,
|
|
112
|
+
unitSize,
|
|
113
|
+
accept,
|
|
114
|
+
uploadErrorInfo,
|
|
115
|
+
style,
|
|
116
|
+
inputStyle,
|
|
117
|
+
inputProps,
|
|
118
|
+
refs,
|
|
119
|
+
required,
|
|
120
|
+
error,
|
|
121
|
+
errorStyle,
|
|
122
|
+
readOnly,
|
|
123
|
+
...props
|
|
124
|
+
}, reference) => {
|
|
125
|
+
const ref = useRef(null);
|
|
126
|
+
const [open, setOpen] = useState(false);
|
|
127
|
+
const [popup, setPopup] = useState(false);
|
|
128
|
+
const [popover, setPopover] = useState(false);
|
|
129
|
+
const attachTextRef = useRef(null);
|
|
130
|
+
const attachmentHandleIconRef = useRef(null);
|
|
131
|
+
const viewAttachTypeRef = useRef(null);
|
|
132
|
+
const sortIconRef = useRef(null);
|
|
133
|
+
const attachmentImageIconRef = useRef(null);
|
|
134
|
+
const attachmentInputRef = useRef(null);
|
|
135
|
+
const attachmentImageRef = useRef(null);
|
|
136
|
+
const attachedRef = useRef(null);
|
|
137
|
+
const popupRef = useRef(null);
|
|
138
|
+
const popoverRef = useRef(null);
|
|
139
|
+
const isDeleteAll = useRef(false);
|
|
140
|
+
const ViewAttachType = css`
|
|
141
|
+
cursor: pointer;
|
|
142
|
+
height: 24px;
|
|
143
|
+
color: ${color.system.rest};
|
|
144
|
+
&:hover {
|
|
145
|
+
color: ${color.system.active};
|
|
146
|
+
}
|
|
147
|
+
`;
|
|
148
|
+
const attachmentHandleIcon = css`
|
|
149
|
+
display: none;
|
|
150
|
+
height: 24px;
|
|
151
|
+
margin-right: 10px;
|
|
152
|
+
border-right: 1px solid ${color.line.normal};
|
|
153
|
+
span {
|
|
154
|
+
margin-right: 10px;
|
|
155
|
+
color: ${color.system.rest};
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
&:hover {
|
|
158
|
+
color: ${color.system.active};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
const AttachmentHeader = css`
|
|
163
|
+
/* position: relative; */
|
|
164
|
+
height: 48px;
|
|
165
|
+
display: flex;
|
|
166
|
+
padding: 16px 24px;
|
|
167
|
+
align-items: center;
|
|
168
|
+
/* margin-bottom: 10px; */
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
justify-content: space-between;
|
|
171
|
+
.css-${attachmentHandleIcon.name},
|
|
172
|
+
.css-${ViewAttachType.name} {
|
|
173
|
+
z-index: 1;
|
|
174
|
+
}
|
|
175
|
+
`;
|
|
176
|
+
const AttachmentInfo = css`
|
|
177
|
+
display: flex;
|
|
178
|
+
position: relative;
|
|
179
|
+
align-items: center;
|
|
180
|
+
margin: 0;
|
|
181
|
+
&+p.attachment-error {
|
|
182
|
+
color: ${danger5};
|
|
183
|
+
font-family: ${fontFamily};
|
|
184
|
+
font-weight: 600;
|
|
185
|
+
}
|
|
186
|
+
span {
|
|
187
|
+
display: none;
|
|
188
|
+
color: ${danger5};
|
|
189
|
+
margin: 10px;
|
|
190
|
+
cursor: help;
|
|
191
|
+
opacity: 0;
|
|
192
|
+
span {
|
|
193
|
+
display: block;
|
|
194
|
+
position: absolute;
|
|
195
|
+
opacity: 1;
|
|
196
|
+
transform: scaleX(0) translateY(-50%);
|
|
197
|
+
left: 80px;
|
|
198
|
+
z-index: 4;
|
|
199
|
+
width: max-content;
|
|
200
|
+
height: max-content;
|
|
201
|
+
max-height: 72px;
|
|
202
|
+
overflow: auto;
|
|
203
|
+
border: 1px solid ${danger5};
|
|
204
|
+
border-radius: 4px;
|
|
205
|
+
padding: 5px 8px;
|
|
206
|
+
transition: transform 0.3s linear 0.3s;
|
|
207
|
+
transform-origin: left;
|
|
208
|
+
&::-webkit-scrollbar {
|
|
209
|
+
width: 4px;
|
|
210
|
+
background-color: white !important;
|
|
211
|
+
border-radius: 4px;
|
|
212
|
+
}
|
|
213
|
+
&::-webkit-scrollbar-thumb{
|
|
214
|
+
border-radius: 10px;
|
|
215
|
+
mix-blend-mode: normal;
|
|
216
|
+
background-color: ${danger5} !important;
|
|
217
|
+
background-clip: content-box;
|
|
218
|
+
}
|
|
219
|
+
ul {
|
|
220
|
+
display: contents;
|
|
221
|
+
li {
|
|
222
|
+
list-style: none;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
&:hover {
|
|
227
|
+
span {
|
|
228
|
+
transform: scaleX(1) translateY(-50%);
|
|
229
|
+
transition-delay: 0s;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
`;
|
|
234
|
+
const AttachmentText = css`
|
|
235
|
+
font-family: ${fontFamily};
|
|
236
|
+
${typography.heading5};
|
|
237
|
+
text-transform: uppercase;
|
|
238
|
+
color: ${color.text.sub};
|
|
239
|
+
user-select: none;
|
|
240
|
+
`;
|
|
241
|
+
const AttachmentHeaderIcon = css`
|
|
242
|
+
display: flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
`;
|
|
245
|
+
const AttachmentInput = css`
|
|
246
|
+
position: absolute;
|
|
247
|
+
width: 100%;
|
|
248
|
+
height: 100%;
|
|
249
|
+
top: 0;
|
|
250
|
+
left: 0;
|
|
251
|
+
z-index: 4;
|
|
252
|
+
display: none;
|
|
253
|
+
input {
|
|
254
|
+
position: relative;
|
|
255
|
+
opacity: 0;
|
|
256
|
+
top: -20px;
|
|
257
|
+
font-size: 0px;
|
|
258
|
+
width: 100%;
|
|
259
|
+
height: calc(100% + 20px);
|
|
260
|
+
}
|
|
261
|
+
`;
|
|
262
|
+
const AttachmentImageCenter = css`
|
|
263
|
+
width: 100%;
|
|
264
|
+
height: 100%;
|
|
265
|
+
display: flex;
|
|
266
|
+
justify-content: center;
|
|
267
|
+
align-items: center;
|
|
268
|
+
`;
|
|
269
|
+
const AttachmentImageContent = css`
|
|
270
|
+
display: grid;
|
|
271
|
+
text-align: center;
|
|
272
|
+
`;
|
|
273
|
+
const AttachmentImageIcon = css`
|
|
274
|
+
margin-bottom: 0;
|
|
275
|
+
z-index: 3;
|
|
276
|
+
width: 24px;
|
|
277
|
+
height: 24px;
|
|
278
|
+
svg {
|
|
279
|
+
color: ${color.system.rest};
|
|
280
|
+
}
|
|
281
|
+
&:hover {
|
|
282
|
+
border-color: ${color.line.hover};
|
|
283
|
+
svg {
|
|
284
|
+
color: ${color.system.active};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
`;
|
|
288
|
+
const AttachmentImageText = css`
|
|
289
|
+
display: none;
|
|
290
|
+
font-family: ${fontFamily};
|
|
291
|
+
${typography.paragraph3};
|
|
292
|
+
color: ${color.system.rest};
|
|
293
|
+
user-select: none;
|
|
294
|
+
`;
|
|
295
|
+
const AttachmentImage = css`
|
|
296
|
+
margin-right: 10px;
|
|
297
|
+
&.hint-center {
|
|
298
|
+
position: absolute;
|
|
299
|
+
width: 100%;
|
|
300
|
+
height: 100%;
|
|
301
|
+
top: 0;
|
|
302
|
+
left: 0;
|
|
303
|
+
margin-right: 0;
|
|
304
|
+
z-index: 1;
|
|
305
|
+
.css-${AttachmentImageText.name} {
|
|
306
|
+
display: block;
|
|
307
|
+
}
|
|
308
|
+
.css-${AttachmentImageIcon.name} {
|
|
309
|
+
display: flex;
|
|
310
|
+
align-items: center;
|
|
311
|
+
justify-content: center;
|
|
312
|
+
width: 64px;
|
|
313
|
+
height: 64px;
|
|
314
|
+
margin: 0 auto 8px auto;
|
|
315
|
+
border: 1px dashed ${color.line.normal};
|
|
316
|
+
border-radius: 50%;
|
|
317
|
+
svg {
|
|
318
|
+
width: 40px;
|
|
319
|
+
height: 40px;
|
|
320
|
+
}
|
|
321
|
+
&:hover {
|
|
322
|
+
border-color: ${color.line.hover};
|
|
323
|
+
background-color: ${color.fill.hover};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
`;
|
|
328
|
+
const AttachedItemInfo = css`
|
|
329
|
+
/* width: 40%; */
|
|
330
|
+
/* max-width: 350px; */
|
|
331
|
+
border-radius: 4px;
|
|
332
|
+
min-width: 104px;
|
|
333
|
+
display: flex;
|
|
334
|
+
align-items: center;
|
|
335
|
+
user-select: none;
|
|
336
|
+
margin-right: 10px;
|
|
337
|
+
min-width: calc(50% - 10px);
|
|
338
|
+
`;
|
|
339
|
+
const AttachedItemInfoIcon = css`
|
|
340
|
+
display: flex;
|
|
341
|
+
position: relative;
|
|
342
|
+
max-height: 16px;
|
|
343
|
+
max-width: 14px;
|
|
344
|
+
padding: 4px 5px;
|
|
345
|
+
cursor: pointer;
|
|
346
|
+
box-sizing: content-box;
|
|
347
|
+
&.new-file:after {
|
|
348
|
+
content: "";
|
|
349
|
+
position: absolute;
|
|
350
|
+
top: 4.5px;
|
|
351
|
+
left: -2px;
|
|
352
|
+
width: 4px;
|
|
353
|
+
height: 4px;
|
|
354
|
+
border-radius: 50%;
|
|
355
|
+
background: ${success5};
|
|
356
|
+
}
|
|
357
|
+
`;
|
|
358
|
+
const AttachedItemInfoName = css`
|
|
359
|
+
font-family: ${fontFamily};
|
|
360
|
+
${typography.paragraph1};
|
|
361
|
+
color: ${color.system.dark};
|
|
362
|
+
margin-left: 12px;
|
|
363
|
+
padding-top: 1px;
|
|
364
|
+
cursor: pointer;
|
|
365
|
+
overflow: hidden;
|
|
366
|
+
white-space: nowrap;
|
|
367
|
+
text-overflow: ellipsis;
|
|
368
|
+
box-sizing: content-box;
|
|
369
|
+
`;
|
|
370
|
+
const AttachedItemOwner = css`
|
|
371
|
+
display: flex;
|
|
372
|
+
position: relative;
|
|
373
|
+
/* max-width: 50%; */
|
|
374
|
+
height: 100%;
|
|
375
|
+
align-items: center;
|
|
376
|
+
font-family: ${fontFamily};
|
|
377
|
+
${typography.paragraph2};
|
|
378
|
+
color: ${color.text.sub};
|
|
379
|
+
cursor: pointer;
|
|
380
|
+
user-select: none;
|
|
381
|
+
.detail-info {
|
|
382
|
+
display: flex;
|
|
383
|
+
min-width: 333px;
|
|
384
|
+
.username {
|
|
385
|
+
display: inline-block;
|
|
386
|
+
/* width: 35%; */
|
|
387
|
+
min-width: 120px;
|
|
388
|
+
max-width: 120px;
|
|
389
|
+
overflow: hidden;
|
|
390
|
+
white-space: nowrap;
|
|
391
|
+
text-overflow: ellipsis;
|
|
392
|
+
}
|
|
393
|
+
.datetime {
|
|
394
|
+
display: inline-block;
|
|
395
|
+
/* width: 45%; */
|
|
396
|
+
min-width: max-content;
|
|
397
|
+
max-width: max-content;
|
|
398
|
+
}
|
|
399
|
+
.filesize {
|
|
400
|
+
/* width: 20%; */
|
|
401
|
+
float: right;
|
|
402
|
+
text-align: right;
|
|
403
|
+
margin-left: auto;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
`;
|
|
407
|
+
const AttachedLinear = css`
|
|
408
|
+
position: absolute;
|
|
409
|
+
width: 100%;
|
|
410
|
+
top: 0;
|
|
411
|
+
background: #FFF;
|
|
412
|
+
height: 100%;
|
|
413
|
+
display: flex;
|
|
414
|
+
align-items: center;
|
|
415
|
+
`;
|
|
416
|
+
const AttachedItem = css`
|
|
417
|
+
height: 24px;
|
|
418
|
+
display: flex;
|
|
419
|
+
justify-content: space-between;
|
|
420
|
+
align-items: center;
|
|
421
|
+
padding: 0 8px;
|
|
422
|
+
position: relative;
|
|
423
|
+
transition: padding 0.5s ease;
|
|
424
|
+
border-radius: 4px;
|
|
425
|
+
`;
|
|
426
|
+
const Attached = css`
|
|
427
|
+
position: relative;
|
|
428
|
+
/* width: calc(100% - 10px); */
|
|
429
|
+
height: 100%;
|
|
430
|
+
max-height: 152px;
|
|
431
|
+
margin-left: 8px;
|
|
432
|
+
margin-right: 8px;
|
|
433
|
+
/* scroll-snap-type: mandatory;
|
|
434
|
+
scroll-snap-type: y mandatory;
|
|
435
|
+
scroll-snap-points-y: repeat(16px); */
|
|
436
|
+
z-index: 1;
|
|
437
|
+
/* transition: margin 0.5s ease; */
|
|
438
|
+
overflow-y: visible;
|
|
439
|
+
.attachment-row {
|
|
440
|
+
display: block;
|
|
441
|
+
margin-bottom: 8px;
|
|
442
|
+
/* scroll-snap-align: start; */
|
|
443
|
+
&:last-child {
|
|
444
|
+
margin-bottom: 0;
|
|
445
|
+
}
|
|
446
|
+
/* overflow-y: hidden; */
|
|
447
|
+
}
|
|
448
|
+
&.icon-view {
|
|
449
|
+
display: flex;
|
|
450
|
+
flex-wrap: wrap;
|
|
451
|
+
justify-content: space-between;
|
|
452
|
+
&::after {
|
|
453
|
+
content: "";
|
|
454
|
+
flex: auto;
|
|
455
|
+
}
|
|
456
|
+
/* grid-template-columns: repeat(auto-fill, minmax(136px, auto)); */
|
|
457
|
+
max-height: 200px;
|
|
458
|
+
margin-left: 0;
|
|
459
|
+
/* padding-left: 10px; */
|
|
460
|
+
/* padding-right: 10px; */
|
|
461
|
+
width: max-content;
|
|
462
|
+
max-width: calc(100% - 26px);
|
|
463
|
+
.attachment-row {
|
|
464
|
+
position: relative;
|
|
465
|
+
margin-left: 16px;
|
|
466
|
+
overflow-y: visible;
|
|
467
|
+
}
|
|
468
|
+
.css-${AttachedItem.name} {
|
|
469
|
+
display: block;
|
|
470
|
+
height: 80px;
|
|
471
|
+
width: 80px;
|
|
472
|
+
padding: 0;
|
|
473
|
+
position: initial;
|
|
474
|
+
.css-${AttachedItemInfo.name} {
|
|
475
|
+
position: relative;
|
|
476
|
+
display: block;
|
|
477
|
+
width: max-content;
|
|
478
|
+
text-align: center;
|
|
479
|
+
max-width: 80px;
|
|
480
|
+
overflow: hidden;
|
|
481
|
+
white-space: nowrap;
|
|
482
|
+
text-overflow: ellipsis;
|
|
483
|
+
margin-left: auto;
|
|
484
|
+
margin-right: auto;
|
|
485
|
+
min-width: 70px;
|
|
486
|
+
.css-${AttachedItemInfoIcon.name} {
|
|
487
|
+
height: 40px;
|
|
488
|
+
width: 40px;
|
|
489
|
+
max-height: 40px;
|
|
490
|
+
max-width: 40px;
|
|
491
|
+
margin: 4px auto 2px;
|
|
492
|
+
padding: 0;
|
|
493
|
+
display: block;
|
|
494
|
+
&.new-file:after {
|
|
495
|
+
top: -1px;
|
|
496
|
+
left: -7px;
|
|
497
|
+
width: 8px;
|
|
498
|
+
height: 8px;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
.css-${AttachedItemInfoName.name} {
|
|
502
|
+
${typography.paragraph3};
|
|
503
|
+
margin: 0 8px;
|
|
504
|
+
display: -webkit-box;
|
|
505
|
+
word-break: break-word;
|
|
506
|
+
max-width: 100%;
|
|
507
|
+
white-space: pre-wrap;
|
|
508
|
+
-webkit-line-clamp: 2;
|
|
509
|
+
-webkit-box-orient: vertical;
|
|
510
|
+
text-align: center;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
.css-${AttachedItemOwner.name} {
|
|
514
|
+
position: inherit;
|
|
515
|
+
height: auto;
|
|
516
|
+
font-size: 12px;
|
|
517
|
+
line-height: 14px;
|
|
518
|
+
.detail-info {
|
|
519
|
+
display: none;
|
|
520
|
+
}
|
|
521
|
+
.css-${AttachedLinear.name} {
|
|
522
|
+
/* position: initial; */
|
|
523
|
+
/* width: 100%; */
|
|
524
|
+
height: auto;
|
|
525
|
+
bottom: 0;
|
|
526
|
+
top: unset;
|
|
527
|
+
background: none;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
&:not(.icon-view) {
|
|
533
|
+
min-width: 684px;
|
|
534
|
+
}
|
|
535
|
+
`;
|
|
536
|
+
const AttachmentRoot = css`
|
|
537
|
+
border: 1px solid ${color.line.normal};
|
|
538
|
+
display: block;
|
|
539
|
+
position: relative;
|
|
540
|
+
flex-wrap: wrap;
|
|
541
|
+
min-height: 165px;
|
|
542
|
+
flex-direction: column;
|
|
543
|
+
padding-bottom: 20px;
|
|
544
|
+
justify-content: start;
|
|
545
|
+
background-color: ${color.system.white};
|
|
546
|
+
border-radius: 4px;
|
|
547
|
+
&:hover:not(.disabled) {
|
|
548
|
+
.css-${AttachmentImageIcon.name} {
|
|
549
|
+
cursor: pointer;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
.css-${Attached.name} {
|
|
553
|
+
&:not(.disabled) {
|
|
554
|
+
.css-${AttachedItem.name} {
|
|
555
|
+
&:hover {
|
|
556
|
+
background-color: ${color.fill.hover};
|
|
557
|
+
.css-${AttachedLinear.name} {
|
|
558
|
+
background-color: ${color.fill.hover};
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
&:active {
|
|
562
|
+
background-color: ${color.fill.pressed};
|
|
563
|
+
.css-${AttachedLinear.name} {
|
|
564
|
+
background-color: ${color.fill.pressed};
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
&.chosen {
|
|
568
|
+
background-color: ${color.fill.focus};
|
|
569
|
+
.css-${AttachedItemInfo.name},
|
|
570
|
+
.css-${AttachedItemOwner.name} {
|
|
571
|
+
background-color: ${color.fill.focus};
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
&.disabled {
|
|
578
|
+
.css-${AttachedItem.name} {
|
|
579
|
+
pointer-events: none;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
@media (max-width: 716px) {
|
|
583
|
+
.css-${Attached.name}:not(.icon-view) {
|
|
584
|
+
min-width: 575px;
|
|
585
|
+
}
|
|
586
|
+
.css-${AttachedItemInfo.name} {
|
|
587
|
+
max-width: calc(40% - 10px);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
`; // End style
|
|
591
|
+
// Start handler
|
|
592
|
+
|
|
593
|
+
const onShowSortPopover = () => {
|
|
594
|
+
setPopover(true);
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
const onSortElement = (e, type) => {
|
|
598
|
+
let multi = 1;
|
|
599
|
+
const currentActive = popoverRef.current.querySelector('.DGN-Active');
|
|
600
|
+
|
|
601
|
+
if (currentActive) {
|
|
602
|
+
if (e.currentTarget.classList.contains('DGN-Active')) {
|
|
603
|
+
if (e.currentTarget.classList.contains('DGN-Decrease')) {
|
|
604
|
+
e.currentTarget.classList.remove('DGN-Decrease');
|
|
605
|
+
} else {
|
|
606
|
+
multi = -1;
|
|
607
|
+
e.currentTarget.classList.add('DGN-Decrease');
|
|
608
|
+
}
|
|
609
|
+
} else {
|
|
610
|
+
currentActive.classList.remove('DGN-Decrease');
|
|
611
|
+
currentActive.classList.remove('DGN-Active');
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
e.currentTarget.classList.add('DGN-Active');
|
|
616
|
+
const attachedList = Array.from(attachedRef.current.querySelectorAll('.attachment-row'));
|
|
617
|
+
attachedList.sort((a, b) => {
|
|
618
|
+
let textA = a.querySelector('.' + (type === 'filesize' ? 'filename' : type)).textContent;
|
|
619
|
+
let textB = b.querySelector('.' + (type === 'filesize' ? 'filename' : type)).textContent;
|
|
620
|
+
|
|
621
|
+
if (type === 'datetime') {
|
|
622
|
+
textA = textA.replace(/.{10}/, text => moment(text, 'DD/MM/YYYY').format('YYYY/MM/DD'));
|
|
623
|
+
textB = textB.replace(/.{10}/, text => moment(text, 'DD/MM/YYYY').format('YYYY/MM/DD'));
|
|
624
|
+
} else if (type === 'filesize') {
|
|
625
|
+
const objA = attached.find(attach => attach.FileName === textA);
|
|
626
|
+
const objB = attached.find(attach => attach.FileName === textB);
|
|
627
|
+
textA = (objA.size || objA.FileSize).toString();
|
|
628
|
+
textB = (objB.size || objB.FileSize).toString();
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
return multi * textA.localeCompare(textB, 'en', {
|
|
632
|
+
numeric: type === 'filesize'
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
attached.sort((a, b) => {
|
|
636
|
+
let valueA, valueB;
|
|
637
|
+
|
|
638
|
+
if (type === 'filesize' || type === 'datetime') {
|
|
639
|
+
if (type === 'filesize') {
|
|
640
|
+
valueA = a.size || a.FileSize;
|
|
641
|
+
valueB = b.size || b.FileSize;
|
|
642
|
+
} else {
|
|
643
|
+
valueA = new Date(a.CreateDate).getTime();
|
|
644
|
+
valueB = new Date(b.CreateDate).getTime();
|
|
645
|
+
}
|
|
646
|
+
} else if (type === 'filetype') {
|
|
647
|
+
// filetype
|
|
648
|
+
valueA = getType(a);
|
|
649
|
+
valueB = getType(b);
|
|
650
|
+
} else {
|
|
651
|
+
valueA = a[type === 'filename' ? 'FileName' : 'UserName'] || ownerName;
|
|
652
|
+
valueB = b[type === 'filename' ? 'FileName' : 'UserName'] || ownerName;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
return multi * valueA.toString().localeCompare(valueB.toString(), 'en', {
|
|
656
|
+
numeric: type === 'filesize' || type === 'datetime'
|
|
657
|
+
});
|
|
658
|
+
});
|
|
659
|
+
attachedList.forEach(el => {
|
|
660
|
+
attachedRef.current.appendChild(el);
|
|
661
|
+
});
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
const onChangeViewAttachType = (e, viewAttachType2) => {
|
|
665
|
+
const type = viewAttachType2 || viewAttachTypeRef.current.getAttribute('dataviewtype');
|
|
666
|
+
|
|
667
|
+
if (type === 'detail') {
|
|
668
|
+
viewAttachTypeRef.current.setAttribute('dataviewtype', 'icon');
|
|
669
|
+
viewAttachTypeRef.current.innerHTML = icons['icon'];
|
|
670
|
+
attachedRef.current.classList.add('icon-view');
|
|
671
|
+
} else {
|
|
672
|
+
viewAttachTypeRef.current.setAttribute('dataviewtype', 'detail');
|
|
673
|
+
viewAttachTypeRef.current.innerHTML = icons['detail'];
|
|
674
|
+
attachedRef.current.classList.remove('icon-view');
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
const afterChangeFile = (length = 0) => {
|
|
679
|
+
if (!length) {
|
|
680
|
+
if (!attachmentImageRef.current.classList.contains('hint-center')) {
|
|
681
|
+
attachmentImageRef.current.classList.add('hint-center');
|
|
682
|
+
}
|
|
683
|
+
} else {
|
|
684
|
+
attachmentImageRef.current.classList.remove('hint-center');
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
if (sortIconRef.current) {
|
|
688
|
+
if (length > 1) {
|
|
689
|
+
sortIconRef.current.style.display = null;
|
|
690
|
+
} else {
|
|
691
|
+
sortIconRef.current.style.display = 'none';
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
const setError = (errorList, type) => {
|
|
697
|
+
if (errorList[type]) {
|
|
698
|
+
errorList[type]++;
|
|
699
|
+
} else {
|
|
700
|
+
errorList[type] = 1;
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
const notifyError = errorList => {
|
|
705
|
+
const errorInfoIcon = attachTextRef.current.parentNode.childNodes[1];
|
|
706
|
+
|
|
707
|
+
if (JSON.stringify(errorList) !== '{}') {
|
|
708
|
+
if (!errorInfoIcon.style.opacity) {
|
|
709
|
+
errorInfoIcon.style.opacity = 1;
|
|
710
|
+
errorInfoIcon.style.display = 'flex';
|
|
711
|
+
} else if (errorInfoIcon.style.color === 'rgb(0, 149, 255)') {
|
|
712
|
+
errorInfoIcon.style.color = danger5;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
if (onUploadError) {
|
|
716
|
+
onUploadError(errorList);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
Object.keys(errorList).forEach(key => {
|
|
720
|
+
const quantity = `${errorList[key]} file${errorList[key] > 1 ? 's' : ''}`;
|
|
721
|
+
const error = uploadErrorInfo[key] ? `${uploadErrorInfo[key]} (${quantity})` : quantity + errorDefault[key];
|
|
722
|
+
const el = document.createElement('li');
|
|
723
|
+
el.innerHTML = error;
|
|
724
|
+
attachTextRef.current.parentNode.querySelector('ul').insertAdjacentElement('afterBegin', el);
|
|
725
|
+
});
|
|
726
|
+
} else if (errorInfoIcon.style.opacity === '1') {
|
|
727
|
+
errorInfoIcon.style.color = info5;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
const onChangeFiles = async e => {
|
|
732
|
+
if (readOnly || disabled) return;
|
|
733
|
+
|
|
734
|
+
if (e.target && e.target.files && e.target.files.length) {
|
|
735
|
+
let files = e.target.files;
|
|
736
|
+
const errorList = {};
|
|
737
|
+
const lengthAttached = attached.length;
|
|
738
|
+
|
|
739
|
+
for (let i = 0; i < files.length; i++) {
|
|
740
|
+
if (i + 1 > maxFile - lengthAttached || files[i].size > maxSize || checkExistingFile(files[i]) || !checkAcceptFileType(files[i])) {
|
|
741
|
+
if (i + 1 > maxFile - lengthAttached) {
|
|
742
|
+
setError(errorList, 'maxFile');
|
|
743
|
+
} else if (files[i].size > maxSize) {
|
|
744
|
+
setError(errorList, 'maxSize');
|
|
745
|
+
} else if (!checkAcceptFileType(files[i])) {
|
|
746
|
+
setError(errorList, 'fileType');
|
|
747
|
+
} else {
|
|
748
|
+
setError(errorList, 'existingFile');
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
files = removeFileOutInputFiles(i, true);
|
|
752
|
+
i--;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
notifyError(errorList);
|
|
759
|
+
const length = files.length;
|
|
760
|
+
|
|
761
|
+
if (!lengthAttached && !length) {
|
|
762
|
+
afterChangeFile();
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
afterChangeFile(lengthAttached + length);
|
|
767
|
+
|
|
768
|
+
if (multiple || inputProps && inputProps.multiple) {
|
|
769
|
+
for (let i = 0; i < length; i++) {
|
|
770
|
+
// if (files[i].size > maxSize) continue;
|
|
771
|
+
addNewElement(files[i], lengthAttached);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
for (let i = 0; i < length; i++) {
|
|
775
|
+
// if (files[i].size > maxSize) continue;
|
|
776
|
+
files[i].URL = await onProgressing(files[i]);
|
|
777
|
+
files[i].FileName = files[i].name;
|
|
778
|
+
}
|
|
779
|
+
} else if (length) {
|
|
780
|
+
attachedRef.current.innerHTML = null;
|
|
781
|
+
files[0].FileName = files[0].name;
|
|
782
|
+
addNewElement(files[0], lengthAttached);
|
|
783
|
+
files[0].URL = await onProgressing(files[0]);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
insertAttached(files);
|
|
787
|
+
if (onChange) onChange({
|
|
788
|
+
element: e.target,
|
|
789
|
+
attached,
|
|
790
|
+
oldAttached,
|
|
791
|
+
newAttached: files,
|
|
792
|
+
allNewAttached: allNewAttached.getAll('files')
|
|
793
|
+
});
|
|
794
|
+
} else if (!attached.length) {
|
|
795
|
+
afterChangeFile();
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
const onProgressing = file => {
|
|
800
|
+
return new Promise((resolve, reject) => {
|
|
801
|
+
const reader = new FileReader();
|
|
802
|
+
let url;
|
|
803
|
+
reader.readAsDataURL(file);
|
|
804
|
+
|
|
805
|
+
reader.onload = e => {
|
|
806
|
+
url = e.target.result;
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
reader.onloadstart = () => {
|
|
810
|
+
// console.log(attachedRef.current.querySelector(`.css-${AttachedLinear.name}-attached`).parentNode.parentNode.querySelector('.filesize').offsetWidth);
|
|
811
|
+
attachedRef.current.querySelector(`.css-${AttachedLinear.name}-attached`).childNodes[0].style.width = '0%';
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
reader.onprogress = e => {
|
|
815
|
+
attachedRef.current.querySelector(`.css-${AttachedLinear.name}-attached`).childNodes[0].style.width = e.loaded / e.total * 100 + '%';
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
reader.onloadend = () => {
|
|
819
|
+
setTimeout(() => {
|
|
820
|
+
attachedRef.current.querySelector(`.css-${AttachedLinear.name}-attached`).parentNode.remove();
|
|
821
|
+
resolve(url);
|
|
822
|
+
}, 200);
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
reader.onerror = () => {
|
|
826
|
+
console.log('Upload file fail');
|
|
827
|
+
reject(false);
|
|
828
|
+
};
|
|
829
|
+
});
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
const addNewElement = (file, lengthAttached) => {
|
|
833
|
+
const newAttach = getItemDetailHTML(file, lengthAttached + 1);
|
|
834
|
+
attached.push(file);
|
|
835
|
+
const newElement = document.createElement('div');
|
|
836
|
+
newElement.className = 'attachment-row';
|
|
837
|
+
ReactDOM.render(newAttach, attachedRef.current.appendChild(newElement));
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
const getType = data => {
|
|
841
|
+
if (data.type !== undefined) {
|
|
842
|
+
var _type$match;
|
|
843
|
+
|
|
844
|
+
const pattern = /word|sheet|presentation|pdf|image|compressed/i;
|
|
845
|
+
let type = data.type;
|
|
846
|
+
|
|
847
|
+
if (!type) {
|
|
848
|
+
if (/rar/.test(data.name)) {
|
|
849
|
+
type = 'compressed';
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return ((_type$match = type.match(pattern)) === null || _type$match === void 0 ? void 0 : _type$match[0]) || 'default';
|
|
854
|
+
} else {
|
|
855
|
+
var _data$FileName;
|
|
856
|
+
|
|
857
|
+
const FileExt = (_data$FileName = data.FileName) === null || _data$FileName === void 0 ? void 0 : _data$FileName.slice(data.FileName.lastIndexOf('.'));
|
|
858
|
+
return getFileType(FileExt, 'default');
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
const getItemDetailHTML = (data, i) => {
|
|
863
|
+
const date = new Date();
|
|
864
|
+
data.CreateDate = date.toISOString();
|
|
865
|
+
const fileType = getType(data);
|
|
866
|
+
return jsx("div", {
|
|
867
|
+
css: AttachedItem,
|
|
868
|
+
key: i,
|
|
869
|
+
onClick: e => onChooseItem(e),
|
|
870
|
+
onDoubleClick: e => onView(e.currentTarget.parentNode)
|
|
871
|
+
}, jsx("span", {
|
|
872
|
+
css: AttachedItemInfo
|
|
873
|
+
}, jsx("span", {
|
|
874
|
+
css: AttachedItemInfoIcon,
|
|
875
|
+
className: 'new-file'
|
|
876
|
+
}, icons[fileType], jsx("span", {
|
|
877
|
+
className: 'filetype',
|
|
878
|
+
style: {
|
|
879
|
+
display: 'none'
|
|
880
|
+
}
|
|
881
|
+
}, fileType)), jsx("span", {
|
|
882
|
+
css: AttachedItemInfoName,
|
|
883
|
+
className: 'filename'
|
|
884
|
+
}, data.name)), jsx("span", {
|
|
885
|
+
css: AttachedItemOwner
|
|
886
|
+
}, jsx("span", {
|
|
887
|
+
className: 'detail-info'
|
|
888
|
+
}, jsx("span", {
|
|
889
|
+
className: 'username'
|
|
890
|
+
}, ownerName), jsx("span", {
|
|
891
|
+
className: 'datetime'
|
|
892
|
+
}, getDateTime(date)), jsx("span", {
|
|
893
|
+
className: 'filesize'
|
|
894
|
+
}, calculateSize(data.size))), jsx("span", {
|
|
895
|
+
css: AttachedLinear
|
|
896
|
+
}, jsx(LinearProgress, {
|
|
897
|
+
className: `css-${AttachedLinear.name}-attached`,
|
|
898
|
+
determinate: true,
|
|
899
|
+
percent: 0
|
|
900
|
+
}))));
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
const getItemHTMLFromData = (data, i) => {
|
|
904
|
+
const date = new Date(data.CreateDate);
|
|
905
|
+
const type = getType(data);
|
|
906
|
+
return jsx("div", {
|
|
907
|
+
css: AttachedItem,
|
|
908
|
+
key: i,
|
|
909
|
+
onClick: e => onChooseItem(e),
|
|
910
|
+
onDoubleClick: e => onView(e.currentTarget.parentNode, data.AttachmentID)
|
|
911
|
+
}, jsx("span", {
|
|
912
|
+
css: AttachedItemInfo
|
|
913
|
+
}, jsx("span", {
|
|
914
|
+
css: AttachedItemInfoIcon,
|
|
915
|
+
className: data.lastModifiedDate ? 'new-file' : ''
|
|
916
|
+
}, icons[type], jsx("span", {
|
|
917
|
+
className: 'filetype',
|
|
918
|
+
style: {
|
|
919
|
+
display: 'none'
|
|
920
|
+
}
|
|
921
|
+
}, type)), jsx("span", {
|
|
922
|
+
css: AttachedItemInfoName,
|
|
923
|
+
className: 'filename'
|
|
924
|
+
}, data.FileName)), jsx("span", {
|
|
925
|
+
css: AttachedItemOwner
|
|
926
|
+
}, jsx("span", {
|
|
927
|
+
className: 'detail-info'
|
|
928
|
+
}, jsx("span", {
|
|
929
|
+
className: 'username'
|
|
930
|
+
}, data.UserName || (data.lastModifiedDate ? ownerName : '')), jsx("span", {
|
|
931
|
+
className: 'datetime'
|
|
932
|
+
}, getDateTime(date)), jsx("span", {
|
|
933
|
+
className: 'filesize'
|
|
934
|
+
}, calculateSize(data.FileSize || data.size)))));
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
const getDateTime = date => {
|
|
938
|
+
if (String(date) === 'Invalid Date') return 'unknown'; // const d = ('0' + date.getDate()).slice(-2);
|
|
939
|
+
// const m = ('0' + (date.getMonth() + 1)).slice(-2);
|
|
940
|
+
// const y = date.getFullYear();
|
|
941
|
+
// const t = date.toTimeString().slice(0, 8);
|
|
942
|
+
|
|
943
|
+
return jsx(Fragment, null, moment(date).format('DD/MM/YYYY, HH:mm:ss'), " ", jsx("span", {
|
|
944
|
+
style: {
|
|
945
|
+
display: 'none'
|
|
946
|
+
}
|
|
947
|
+
}, date.getMilliseconds()));
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
const calculateSize = size => {
|
|
951
|
+
if (!size && size !== 0) return 'unknown';
|
|
952
|
+
let totalSize = '';
|
|
953
|
+
let unitSizeName = '';
|
|
954
|
+
|
|
955
|
+
if (divideSize) {
|
|
956
|
+
totalSize = size / divideSize;
|
|
957
|
+
unitSizeName = unitSize.toUpperCase();
|
|
958
|
+
|
|
959
|
+
while (totalSize < 0.01 && unitSizeName !== 'B') {
|
|
960
|
+
[unitSizeName, totalSize] = getNewUnitSize(unitSizeName, totalSize, 1);
|
|
961
|
+
}
|
|
962
|
+
} else {
|
|
963
|
+
totalSize = size;
|
|
964
|
+
unitSizeName = 'B';
|
|
965
|
+
|
|
966
|
+
while (totalSize > 1024 && unitSizeName !== 'TB') {
|
|
967
|
+
[unitSizeName, totalSize] = getNewUnitSize(unitSizeName, totalSize, -1);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
if (totalSize < 1000) {
|
|
972
|
+
totalSize = Math.round(totalSize * 100) / 100;
|
|
973
|
+
} else {
|
|
974
|
+
totalSize = Math.round(totalSize);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
return totalSize + ' ' + unitSizeName;
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
const getNewUnitSize = (sizeName, totalSize, num) => {
|
|
981
|
+
if (sizeName === 'B' && num === 1 || sizeName === 'TB' && num === -1) return [sizeName, totalSize];
|
|
982
|
+
const arraySize = ['TB', 'GB', 'MB', 'KB', 'B'];
|
|
983
|
+
const index = arraySize.indexOf(sizeName);
|
|
984
|
+
const newTotalSize = totalSize * Math.pow(1024, num); // newTotalSize = Math.round(newTotalSize*100)/100;
|
|
985
|
+
|
|
986
|
+
return [arraySize[index + num], newTotalSize];
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
const getBit = (size, unit) => {
|
|
990
|
+
switch (true) {
|
|
991
|
+
case /^B$/i.test(unit):
|
|
992
|
+
return size * 1;
|
|
993
|
+
|
|
994
|
+
case /KB/i.test(unit):
|
|
995
|
+
return size * 1024;
|
|
996
|
+
|
|
997
|
+
case /MB/i.test(unit):
|
|
998
|
+
return size * 1024 ** 2;
|
|
999
|
+
|
|
1000
|
+
case /GB/i.test(unit):
|
|
1001
|
+
return size * 1024 ** 3;
|
|
1002
|
+
|
|
1003
|
+
case /TB/i.test(unit):
|
|
1004
|
+
return size * 1024 ** 4;
|
|
1005
|
+
|
|
1006
|
+
default:
|
|
1007
|
+
return size * 1024 * 1024;
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
const onShowPopup = () => {
|
|
1012
|
+
setPopup(true);
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
const onClosePopup = () => {
|
|
1016
|
+
setPopup(false);
|
|
1017
|
+
|
|
1018
|
+
if (isDeleteAll.current) {
|
|
1019
|
+
isDeleteAll.current = false;
|
|
1020
|
+
chosenItems.length = 0;
|
|
1021
|
+
removeActiveChosenItem();
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
const onDownloadMultiple = () => {
|
|
1026
|
+
const index = chosenItems[0];
|
|
1027
|
+
|
|
1028
|
+
if (index < oldAttached.length) {
|
|
1029
|
+
onDownload(oldAttached[index].URL, oldAttached[index].FileName);
|
|
1030
|
+
} else {
|
|
1031
|
+
const files = allNewAttached.getAll('files');
|
|
1032
|
+
onDownload(files[index - oldAttached.length].URL, files[index - oldAttached.length].name);
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
const onRemoveMultiple = () => {
|
|
1037
|
+
const nodeList = attachedRef.current.querySelectorAll('.chosen');
|
|
1038
|
+
const removedAttached = [];
|
|
1039
|
+
nodeList.forEach(itemEl => {
|
|
1040
|
+
const parent = itemEl.parentNode;
|
|
1041
|
+
const index = Array.from(attachedRef.current.children).indexOf(parent);
|
|
1042
|
+
const deletedFile = attached.splice(index, 1)[0];
|
|
1043
|
+
|
|
1044
|
+
if (Object.prototype.toString.call(deletedFile) === '[object File]') {
|
|
1045
|
+
removeFileOutInputFiles(allNewAttached.getAll('files').findIndex(attach => attach.FileName === deletedFile.FileName && attach.CreateDate === deletedFile.CreateDate));
|
|
1046
|
+
} else {
|
|
1047
|
+
oldAttached.splice(oldAttached.findIndex(attach => attach.FileName === deletedFile.FileName && attach.CreateDate === deletedFile.CreateDate), 1);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
removedAttached.push(deletedFile);
|
|
1051
|
+
parent.remove();
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
if (attached.length < 2) {
|
|
1055
|
+
afterChangeFile(attached.length);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
if (onChange) onChange({
|
|
1059
|
+
element: nodeList,
|
|
1060
|
+
attached,
|
|
1061
|
+
removedAttached,
|
|
1062
|
+
oldAttached,
|
|
1063
|
+
allNewAttached: allNewAttached.getAll('files')
|
|
1064
|
+
});
|
|
1065
|
+
!!onRemoveItem && onRemoveItem(removedAttached);
|
|
1066
|
+
onClosePopup();
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
const clearAllAttached = () => {
|
|
1070
|
+
const allAttachEl = attachedRef.current.querySelectorAll('.attachment-row');
|
|
1071
|
+
|
|
1072
|
+
if (allAttachEl && allAttachEl.length) {
|
|
1073
|
+
allAttachEl.forEach(attachEl => attachEl.firstChild.classList.add('chosen'));
|
|
1074
|
+
isDeleteAll.current = true;
|
|
1075
|
+
onShowPopup();
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
const onGetViewItem = (i = 0) => {
|
|
1080
|
+
const index = chosenItems[i];
|
|
1081
|
+
const node = attachedRef.current.childNodes[index];
|
|
1082
|
+
const AttachmentID = attached[index].AttachmentID;
|
|
1083
|
+
onView(node, AttachmentID);
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1086
|
+
const onView = (node, AttachmentID) => {
|
|
1087
|
+
if (timer) {
|
|
1088
|
+
prevent = true;
|
|
1089
|
+
clearTimeout(timer); // if (existClickOutOfItem) {
|
|
1090
|
+
// removeAllChosenItems();
|
|
1091
|
+
// attachedRef.current.querySelectorAll('.chosen').forEach(itemEl => {
|
|
1092
|
+
// itemEl.classList.remove('chosen');
|
|
1093
|
+
// })
|
|
1094
|
+
// }
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
const index = Array.from(attachedRef.current.children).indexOf(node);
|
|
1098
|
+
if (onViewItem) onViewItem(AttachmentID, index);else {
|
|
1099
|
+
setOpen(true);
|
|
1100
|
+
}
|
|
1101
|
+
setTimeout(() => {
|
|
1102
|
+
prevent = false;
|
|
1103
|
+
}, 110);
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
const onDownload = (url, name) => {
|
|
1107
|
+
if (!url) return;
|
|
1108
|
+
fetch(url).then(resp => resp.blob()).then(blob => {
|
|
1109
|
+
const url = window.URL.createObjectURL(blob);
|
|
1110
|
+
const a = document.createElement('a');
|
|
1111
|
+
a.style.display = 'none';
|
|
1112
|
+
a.href = url; // the filename you want
|
|
1113
|
+
|
|
1114
|
+
a.download = name;
|
|
1115
|
+
document.body.appendChild(a);
|
|
1116
|
+
a.click();
|
|
1117
|
+
window.URL.revokeObjectURL(url);
|
|
1118
|
+
}).catch(() => alert('File not found'));
|
|
1119
|
+
if (onDownloadItem) onDownloadItem(url);
|
|
1120
|
+
}; // const onRemove = (e, AttachmentID='') => {
|
|
1121
|
+
// const parent = e.currentTarget.parentNode.parentNode.parentNode;
|
|
1122
|
+
// const index = Array.from(attachedRef.current.children).indexOf(parent);
|
|
1123
|
+
// attached.splice(index, 1);
|
|
1124
|
+
// if (index < oldAttached.length) {
|
|
1125
|
+
// oldAttached.splice(index, 1);
|
|
1126
|
+
// } else {
|
|
1127
|
+
// removeFileOutInputFiles(index - oldAttached.length);
|
|
1128
|
+
// }
|
|
1129
|
+
// parent.remove();
|
|
1130
|
+
// if (!attached.length) {
|
|
1131
|
+
// afterChangeFile();
|
|
1132
|
+
// }
|
|
1133
|
+
// if (onRemoveItem) onRemoveItem({index, element: parent, oldAttached, allNewAttached: allNewAttached.getAll('files'), AttachmentID});
|
|
1134
|
+
// }
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
const removeFileOutInputFiles = (index, keeping) => {
|
|
1138
|
+
const dt = new DataTransfer();
|
|
1139
|
+
|
|
1140
|
+
for (let file of attachmentInputRef.current.files) {
|
|
1141
|
+
if (file !== attachmentInputRef.current.files[index]) {
|
|
1142
|
+
dt.items.add(file);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
if (!keeping) {
|
|
1147
|
+
const files = allNewAttached.getAll('files');
|
|
1148
|
+
files.splice(index, 1);
|
|
1149
|
+
allNewAttached.delete('files');
|
|
1150
|
+
files.forEach(file => allNewAttached.append('files', file));
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
attachmentInputRef.current.files = dt.files;
|
|
1154
|
+
return dt.files;
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
const insertAttached = files => {
|
|
1158
|
+
if (multiple || inputProps && inputProps.multiple) {
|
|
1159
|
+
for (let file of files) {
|
|
1160
|
+
allNewAttached.append('files', file);
|
|
1161
|
+
}
|
|
1162
|
+
} else if (files[0]) {
|
|
1163
|
+
allNewAttached.delete('files');
|
|
1164
|
+
allNewAttached.append('files', files[0]);
|
|
1165
|
+
} // attachmentInputRef.current.files = allNewAttached.getAll('files');
|
|
1166
|
+
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
const checkExistingFile = newFile => {
|
|
1170
|
+
const files = allNewAttached.getAll('files');
|
|
1171
|
+
|
|
1172
|
+
if (files && files.length) {
|
|
1173
|
+
const length = files.length;
|
|
1174
|
+
|
|
1175
|
+
for (let i = 0; i < length; i++) {
|
|
1176
|
+
if (parseStringify(newFile) === parseStringify(files[i])) return true;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
return false;
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
const checkAcceptFileType = newFile => {
|
|
1184
|
+
if (!accept || !accept.length) return true;
|
|
1185
|
+
const type = typeof accept === 'string' ? accept : accept.join('-');
|
|
1186
|
+
|
|
1187
|
+
if (typeof accept === 'string') {
|
|
1188
|
+
const acceptType = type.replace('/*', '');
|
|
1189
|
+
return newFile.type.includes(acceptType);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
const extFile = newFile.name.slice(newFile.name.lastIndexOf('.') + 1);
|
|
1193
|
+
return accept.join('-').includes(extFile);
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
const onChooseItem = e => {
|
|
1197
|
+
const ctrlKey = e.ctrlKey;
|
|
1198
|
+
const shiftKey = e.shiftKey;
|
|
1199
|
+
const itemEl = e.currentTarget;
|
|
1200
|
+
timer = setTimeout(() => {
|
|
1201
|
+
if (!prevent) {
|
|
1202
|
+
const index = Array.from(attachedRef.current.children).indexOf(itemEl.parentNode);
|
|
1203
|
+
|
|
1204
|
+
if (shiftKey && !ctrlKey) {
|
|
1205
|
+
let startIndex = chosenItems[chosenItems.length - 1] || 0;
|
|
1206
|
+
let endIndex = index;
|
|
1207
|
+
|
|
1208
|
+
if (startIndex > endIndex) {
|
|
1209
|
+
endIndex = startIndex;
|
|
1210
|
+
startIndex = index;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
chosenItems.length = 0;
|
|
1214
|
+
attachedRef.current.querySelectorAll(`.css-${AttachedItem.name}`).forEach((itemEl, indexEl) => {
|
|
1215
|
+
if (startIndex <= indexEl && indexEl <= endIndex) {
|
|
1216
|
+
if (!itemEl.classList.contains('chosen')) {
|
|
1217
|
+
itemEl.classList.add('chosen');
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
chosenItems.push(indexEl);
|
|
1221
|
+
} else if (itemEl.classList.contains('chosen')) {
|
|
1222
|
+
itemEl.classList.remove('chosen');
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
|
|
1226
|
+
if (chosenItems[chosenItems.length - 1] !== index) {
|
|
1227
|
+
chosenItems.shift();
|
|
1228
|
+
chosenItems.push(index);
|
|
1229
|
+
}
|
|
1230
|
+
} else if (!ctrlKey) {
|
|
1231
|
+
chosenItems.length = 0;
|
|
1232
|
+
removeActiveChosenItem();
|
|
1233
|
+
chosenItems.push(index);
|
|
1234
|
+
itemEl.classList.add('chosen');
|
|
1235
|
+
} else if (itemEl.classList.contains('chosen')) {
|
|
1236
|
+
chosenItems.splice(chosenItems.indexOf(index));
|
|
1237
|
+
itemEl.classList.remove('chosen');
|
|
1238
|
+
|
|
1239
|
+
if (!chosenItems.length) {
|
|
1240
|
+
setTimeout(() => {
|
|
1241
|
+
removeAllChosenItems();
|
|
1242
|
+
}, 0);
|
|
1243
|
+
}
|
|
1244
|
+
} else {
|
|
1245
|
+
chosenItems.push(index);
|
|
1246
|
+
itemEl.classList.add('chosen');
|
|
1247
|
+
} // Add event listener click out of item
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
if (!existClickOutOfItem) {
|
|
1251
|
+
existClickOutOfItem = true;
|
|
1252
|
+
attachmentHandleIconRef.current.style.display = 'block';
|
|
1253
|
+
document.addEventListener('keydown', onKeyDown);
|
|
1254
|
+
document.addEventListener('click', clickOutOfItem);
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
checkChosenMultiple();
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
prevent = false;
|
|
1261
|
+
}, 100);
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
const removeActiveChosenItem = () => {
|
|
1265
|
+
attachedRef.current.querySelectorAll('.chosen').forEach(itemEl => {
|
|
1266
|
+
itemEl.classList.remove('chosen');
|
|
1267
|
+
});
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
const checkChosenMultiple = () => {
|
|
1271
|
+
const actionIcons = attachmentHandleIconRef.current.childNodes;
|
|
1272
|
+
|
|
1273
|
+
if (chosenItems.length > 1 && actionIcons[0].style.display !== 'none') {
|
|
1274
|
+
actionIcons[0].style.display = 'none';
|
|
1275
|
+
actionIcons[1].style.display = 'none';
|
|
1276
|
+
} else if (chosenItems.length === 1 && actionIcons[0].style.display === 'none') {
|
|
1277
|
+
actionIcons[0].style.display = null;
|
|
1278
|
+
actionIcons[1].style.display = null;
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
const onKeyDown = event => {
|
|
1283
|
+
const key = event.key;
|
|
1284
|
+
|
|
1285
|
+
if (key === "Delete") {
|
|
1286
|
+
// Press Delete key to delete item(s)
|
|
1287
|
+
onShowPopup();
|
|
1288
|
+
} else if (key === 'Enter') {
|
|
1289
|
+
if (popupRef.current.style.display !== 'flex') {
|
|
1290
|
+
onGetViewItem(chosenItems.length - 1);
|
|
1291
|
+
}
|
|
1292
|
+
} else if (/a/i.test(key) && event.ctrlKey) {
|
|
1293
|
+
chosenItems.length = 0;
|
|
1294
|
+
const allAttachEl = attachedRef.current.querySelectorAll('.attachment-row');
|
|
1295
|
+
|
|
1296
|
+
if (allAttachEl && allAttachEl.length) {
|
|
1297
|
+
allAttachEl.forEach((attachEl, index) => chosenItems.push(index) & attachEl.firstChild.classList.add('chosen'));
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
event.preventDefault();
|
|
1301
|
+
return false;
|
|
1302
|
+
} else if (/Arrow/.test(key)) {
|
|
1303
|
+
// Press Arrow key to select another item
|
|
1304
|
+
event.preventDefault();
|
|
1305
|
+
const itemsNode = attachedRef.current.querySelectorAll('.attachment-row');
|
|
1306
|
+
const chosenItemsNode = Array.from(itemsNode).filter(el => el.firstChild.classList.contains('chosen'));
|
|
1307
|
+
const length = itemsNode.length;
|
|
1308
|
+
let index;
|
|
1309
|
+
|
|
1310
|
+
if (key === "ArrowDown" || key === "ArrowRight") {
|
|
1311
|
+
for (let id = length - 1; id >= 0; id--) {
|
|
1312
|
+
if (Array.from(itemsNode)[id].firstChild.classList.contains('chosen')) {
|
|
1313
|
+
index = id;
|
|
1314
|
+
break;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
if (index === length - 1) {
|
|
1319
|
+
if (chosenItemsNode.length !== 1 && !event.shiftKey) {
|
|
1320
|
+
chosenItemsNode.forEach((node, i) => {
|
|
1321
|
+
if (i !== index) {
|
|
1322
|
+
node.firstChild.classList.remove('chosen');
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
chosenItems.length = 0;
|
|
1326
|
+
chosenItems.push(index);
|
|
1327
|
+
Array.from(itemsNode)[index].scrollIntoView({
|
|
1328
|
+
block: 'center',
|
|
1329
|
+
behavior: "smooth"
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
Array.from(itemsNode)[index + 1].scrollIntoView({
|
|
1337
|
+
block: 'center',
|
|
1338
|
+
behavior: "smooth"
|
|
1339
|
+
});
|
|
1340
|
+
|
|
1341
|
+
if (!event.shiftKey) {
|
|
1342
|
+
itemsNode.forEach(node => {
|
|
1343
|
+
node.firstChild.classList.remove('chosen');
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
itemsNode[index + 1].firstChild.classList.add('chosen');
|
|
1348
|
+
chosenItems.push(index + 1);
|
|
1349
|
+
} else if (key === "ArrowUp" || key === "ArrowLeft") {
|
|
1350
|
+
index = Array.from(itemsNode).findIndex(el => el.firstChild.classList.contains('chosen'));
|
|
1351
|
+
|
|
1352
|
+
if (index === 0) {
|
|
1353
|
+
if (chosenItemsNode.length !== 1 && !event.shiftKey) {
|
|
1354
|
+
chosenItemsNode.forEach((node, i) => {
|
|
1355
|
+
if (i !== index) {
|
|
1356
|
+
node.firstChild.classList.remove('chosen');
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
chosenItems.length = 0;
|
|
1360
|
+
chosenItems.push(index);
|
|
1361
|
+
Array.from(itemsNode)[index].scrollIntoView({
|
|
1362
|
+
block: 'center',
|
|
1363
|
+
behavior: "smooth"
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
Array.from(itemsNode)[index - 1].scrollIntoView({
|
|
1371
|
+
block: 'center',
|
|
1372
|
+
behavior: "smooth"
|
|
1373
|
+
});
|
|
1374
|
+
|
|
1375
|
+
if (!event.shiftKey) {
|
|
1376
|
+
chosenItemsNode.forEach(node => {
|
|
1377
|
+
node.firstChild.classList.remove('chosen');
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
itemsNode[index - 1].firstChild.classList.add('chosen');
|
|
1382
|
+
chosenItems.push(index - 1);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
if (!event.shiftKey) {
|
|
1386
|
+
chosenItems.length = 1;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
|
|
1391
|
+
const clickOutOfItem = e => {
|
|
1392
|
+
var _popupRef$current, _popupRef$current$sty;
|
|
1393
|
+
|
|
1394
|
+
if (!attachedRef || !attachedRef.current) {
|
|
1395
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
1396
|
+
document.removeEventListener('click', clickOutOfItem);
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
if (!(attachedRef.current.contains(e.target) && attachedRef.current !== e.target) && !attachmentHandleIconRef.current.contains(e.target) && !isDeleteAll.current && (((_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : (_popupRef$current$sty = _popupRef$current.style) === null || _popupRef$current$sty === void 0 ? void 0 : _popupRef$current$sty.display) !== 'flex' || popupRef.current.querySelector('button.filled.info').contains(e.target))) {
|
|
1401
|
+
removeAllChosenItems();
|
|
1402
|
+
removeActiveChosenItem();
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
|
|
1406
|
+
const removeAllChosenItems = () => {
|
|
1407
|
+
chosenItems.length = 0;
|
|
1408
|
+
existClickOutOfItem = false;
|
|
1409
|
+
attachmentHandleIconRef.current.style.display = null;
|
|
1410
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
1411
|
+
document.removeEventListener('click', clickOutOfItem);
|
|
1412
|
+
};
|
|
1413
|
+
|
|
1414
|
+
const parseStringify = fileInfo => JSON.stringify({
|
|
1415
|
+
lastModified: fileInfo.lastModified,
|
|
1416
|
+
lastModifiedDate: fileInfo.lastModifiedDate,
|
|
1417
|
+
name: fileInfo.name,
|
|
1418
|
+
size: fileInfo.size,
|
|
1419
|
+
type: fileInfo.type,
|
|
1420
|
+
webkitRelativePath: fileInfo.webkitRelativePath
|
|
1421
|
+
});
|
|
1422
|
+
|
|
1423
|
+
useEffect(() => {
|
|
1424
|
+
if (refs) refs(ref);
|
|
1425
|
+
|
|
1426
|
+
if (attached.length) {
|
|
1427
|
+
attached.length = 0;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
return () => {
|
|
1431
|
+
existClickOutOfItem = false;
|
|
1432
|
+
};
|
|
1433
|
+
}, []);
|
|
1434
|
+
useEffect(() => {
|
|
1435
|
+
attachTextRef.current.innerHTML = label + (required ? `<b style="color: ${theme.colors.danger}"> *</b>` : '');
|
|
1436
|
+
let el = null;
|
|
1437
|
+
|
|
1438
|
+
if (error) {
|
|
1439
|
+
attachTextRef.current.style.color = danger5;
|
|
1440
|
+
ref.current.style.borderColor = errorStyle && errorStyle.borderColor || danger5;
|
|
1441
|
+
el = document.createElement('p');
|
|
1442
|
+
el.classList.add('attachment-error');
|
|
1443
|
+
Object.assign(el.style, errorStyle);
|
|
1444
|
+
el.innerHTML = error;
|
|
1445
|
+
attachTextRef.current.parentNode.insertAdjacentElement('afterEnd', el);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
return () => {
|
|
1449
|
+
if (attachTextRef.current && ref.current) {
|
|
1450
|
+
attachTextRef.current.style.color = null;
|
|
1451
|
+
ref.current.style.borderColor = null;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
if (el) {
|
|
1455
|
+
el.remove();
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
}, [required, error]);
|
|
1459
|
+
useEffect(() => {
|
|
1460
|
+
// viewAttachTypeRef.current.innerHTML = icons[viewType];
|
|
1461
|
+
onChangeViewAttachType(null, viewType === 'icon' ? 'detail' : 'icon');
|
|
1462
|
+
}, [viewType]);
|
|
1463
|
+
useEffect(() => {
|
|
1464
|
+
switch (true) {
|
|
1465
|
+
case /^B$/i.test(unitSize):
|
|
1466
|
+
divideSize = 1;
|
|
1467
|
+
break;
|
|
1468
|
+
|
|
1469
|
+
case /KB/i.test(unitSize):
|
|
1470
|
+
divideSize = 1024;
|
|
1471
|
+
break;
|
|
1472
|
+
|
|
1473
|
+
case /MB/i.test(unitSize):
|
|
1474
|
+
divideSize = 1024 ** 2;
|
|
1475
|
+
break;
|
|
1476
|
+
|
|
1477
|
+
case /GB/i.test(unitSize):
|
|
1478
|
+
divideSize = 1024 ** 3;
|
|
1479
|
+
break;
|
|
1480
|
+
|
|
1481
|
+
case /TB/i.test(unitSize):
|
|
1482
|
+
divideSize = 1024 ** 4;
|
|
1483
|
+
break;
|
|
1484
|
+
|
|
1485
|
+
default:
|
|
1486
|
+
divideSize = null;
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
attachmentInputRef.current.addEventListener('change', onChangeFiles);
|
|
1491
|
+
return () => {
|
|
1492
|
+
attachmentInputRef.current && attachmentInputRef.current.removeEventListener('change', onChangeFiles);
|
|
1493
|
+
};
|
|
1494
|
+
}, [unitSize, onChange]);
|
|
1495
|
+
useEffect(() => {
|
|
1496
|
+
oldAttached.length = 0;
|
|
1497
|
+
|
|
1498
|
+
if (data) {
|
|
1499
|
+
afterChangeFile(data.length); // Load files data was upload
|
|
1500
|
+
|
|
1501
|
+
const length = data.length;
|
|
1502
|
+
|
|
1503
|
+
for (let i = 0; i < length; i++) {
|
|
1504
|
+
const newAttach = getItemHTMLFromData(data[i], i);
|
|
1505
|
+
|
|
1506
|
+
if (Object.prototype.toString.call(data[i]) === '[object File]') {
|
|
1507
|
+
allNewAttached.append('files', data[i]);
|
|
1508
|
+
} else {
|
|
1509
|
+
oldAttached.push(data[i]);
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
attached.push(data[i]);
|
|
1513
|
+
const newElement = document.createElement('div');
|
|
1514
|
+
newElement.className = 'attachment-row';
|
|
1515
|
+
ReactDOM.render(newAttach, attachedRef.current.appendChild(newElement));
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
return () => {
|
|
1520
|
+
if (attachedRef.current) {
|
|
1521
|
+
attachedRef.current.innerHTML = null;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
oldAttached.length = 0;
|
|
1525
|
+
attached.length = 0;
|
|
1526
|
+
chosenItems.length = 0;
|
|
1527
|
+
allNewAttached.delete('files');
|
|
1528
|
+
|
|
1529
|
+
if (attachmentInputRef.current) {
|
|
1530
|
+
attachmentInputRef.current.value = '';
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
}, [data]);
|
|
1534
|
+
useEffect(() => {
|
|
1535
|
+
if (inputProps && Object.keys(inputProps).length) {
|
|
1536
|
+
Object.keys(inputProps).forEach(name => {
|
|
1537
|
+
if (typeof inputProps[name] === 'boolean') {
|
|
1538
|
+
attachmentInputRef.current[name] = inputProps[name];
|
|
1539
|
+
} else {
|
|
1540
|
+
attachmentInputRef.current.setAttribute(name, inputProps[name]);
|
|
1541
|
+
}
|
|
1542
|
+
});
|
|
1543
|
+
return () => {
|
|
1544
|
+
if (attachmentInputRef.current) {
|
|
1545
|
+
Object.keys(inputProps).forEach(name => {
|
|
1546
|
+
if (typeof inputProps[name] === 'boolean') {
|
|
1547
|
+
attachmentInputRef.current[name] = false;
|
|
1548
|
+
} else {
|
|
1549
|
+
attachmentInputRef.current.removeAttribute(name);
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
}, [inputProps]);
|
|
1556
|
+
useEffect(() => {
|
|
1557
|
+
if (disabled) {
|
|
1558
|
+
ref.current.classList.add('disabled');
|
|
1559
|
+
} else if (ref.current.classList.contains('disabled')) {
|
|
1560
|
+
ref.current.classList.remove('disabled');
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
attachmentInputRef.current.disabled = disabled || inputProps && inputProps.disabled;
|
|
1564
|
+
}, [disabled]);
|
|
1565
|
+
useEffect(() => {
|
|
1566
|
+
if (maxSizeProp) {
|
|
1567
|
+
if (!isNaN(maxSizeProp)) {
|
|
1568
|
+
maxSize = maxSizeProp * 1024 * 1024;
|
|
1569
|
+
} else {
|
|
1570
|
+
const numberSize = maxSizeProp.match(/\d+/g);
|
|
1571
|
+
const unitMaxSize = maxSizeProp.match(/\D+/g);
|
|
1572
|
+
maxSize = getBit(numberSize, unitMaxSize);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
attachmentInputRef.current.multiple = multiple;
|
|
1577
|
+
|
|
1578
|
+
if (accept && typeof accept === 'string') {
|
|
1579
|
+
attachmentInputRef.current.accept = `${accept}/*`.replace('/*/*', '/*');
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
attachmentInputRef.current.addEventListener('change', onChangeFiles);
|
|
1583
|
+
return () => {
|
|
1584
|
+
if (attachmentInputRef.current) {
|
|
1585
|
+
attachmentInputRef.current.removeEventListener('change', onChangeFiles);
|
|
1586
|
+
attachmentInputRef.current.accept = null;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
maxSize = Infinity;
|
|
1590
|
+
};
|
|
1591
|
+
}, [maxFile, maxSizeProp, multiple, accept]);
|
|
1592
|
+
|
|
1593
|
+
const triggerClickInput = () => {
|
|
1594
|
+
attachmentInputRef.current.click();
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
const onDragFileStart = () => {
|
|
1598
|
+
attachmentInputRef.current.parentNode.style.display = 'block';
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
const onDropInput = () => {
|
|
1602
|
+
attachmentInputRef.current.parentNode.style.display = null;
|
|
1603
|
+
}; // End handler
|
|
1604
|
+
// Start view
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
const AttachHeaderView = useMemo(() => jsx("div", {
|
|
1608
|
+
css: AttachmentHeader
|
|
1609
|
+
}, jsx("div", {
|
|
1610
|
+
css: AttachmentInfo
|
|
1611
|
+
}, jsx("p", {
|
|
1612
|
+
css: AttachmentText,
|
|
1613
|
+
ref: attachTextRef
|
|
1614
|
+
}), jsx("span", null, jsx(Info, {
|
|
1615
|
+
width: '18',
|
|
1616
|
+
height: '18',
|
|
1617
|
+
bgColor: 'currentColor'
|
|
1618
|
+
}), jsx("span", null, " ", jsx("ul", null, " "), " "))), jsx("div", {
|
|
1619
|
+
css: AttachmentHeaderIcon
|
|
1620
|
+
}, jsx("div", {
|
|
1621
|
+
css: attachmentHandleIcon,
|
|
1622
|
+
ref: attachmentHandleIconRef
|
|
1623
|
+
}, jsx("span", {
|
|
1624
|
+
className: 'view',
|
|
1625
|
+
onClick: () => onGetViewItem()
|
|
1626
|
+
}, jsx(View, {
|
|
1627
|
+
color: 'currentColor',
|
|
1628
|
+
viewBox: true
|
|
1629
|
+
})), jsx("span", {
|
|
1630
|
+
className: 'download',
|
|
1631
|
+
onClick: onDownloadMultiple
|
|
1632
|
+
}, jsx(Download, {
|
|
1633
|
+
color: 'currentColor',
|
|
1634
|
+
viewBox: true
|
|
1635
|
+
})), !readOnly && jsx("span", {
|
|
1636
|
+
className: 'delete',
|
|
1637
|
+
onClick: onShowPopup
|
|
1638
|
+
}, jsx(Delete, {
|
|
1639
|
+
color: 'currentColor',
|
|
1640
|
+
viewBox: true
|
|
1641
|
+
}))), jsx("div", {
|
|
1642
|
+
css: AttachmentImage,
|
|
1643
|
+
ref: attachmentImageRef
|
|
1644
|
+
}, !readOnly && jsx("div", {
|
|
1645
|
+
css: AttachmentImageCenter
|
|
1646
|
+
}, jsx("div", {
|
|
1647
|
+
css: AttachmentImageContent
|
|
1648
|
+
}, jsx("span", {
|
|
1649
|
+
css: AttachmentImageIcon,
|
|
1650
|
+
ref: attachmentImageIconRef,
|
|
1651
|
+
onClick: triggerClickInput
|
|
1652
|
+
}, jsx(AttachmentIcon, {
|
|
1653
|
+
viewBox: true,
|
|
1654
|
+
color: 'currentColor'
|
|
1655
|
+
})), jsx("span", {
|
|
1656
|
+
css: AttachmentImageText
|
|
1657
|
+
}, hintText || 'Kéo và thả tập tin vào đây')))), allowSort && jsx(Icon, {
|
|
1658
|
+
name: 'Sort',
|
|
1659
|
+
ref: sortIconRef,
|
|
1660
|
+
viewBox: true,
|
|
1661
|
+
style: {
|
|
1662
|
+
padding: 0,
|
|
1663
|
+
marginRight: 8,
|
|
1664
|
+
display: 'none'
|
|
1665
|
+
},
|
|
1666
|
+
onClick: onShowSortPopover
|
|
1667
|
+
}), jsx("div", {
|
|
1668
|
+
css: ViewAttachType,
|
|
1669
|
+
ref: viewAttachTypeRef,
|
|
1670
|
+
onClick: onChangeViewAttachType,
|
|
1671
|
+
dataviewtype: viewType
|
|
1672
|
+
}))), [allowSort, readOnly]);
|
|
1673
|
+
const AttachmentInputView = useMemo(() => jsx("div", {
|
|
1674
|
+
css: AttachmentInput
|
|
1675
|
+
}, jsx("input", _extends({}, inputProps, {
|
|
1676
|
+
type: "file",
|
|
1677
|
+
ref: attachmentInputRef,
|
|
1678
|
+
title: "",
|
|
1679
|
+
style: inputStyle,
|
|
1680
|
+
onDrop: onDropInput,
|
|
1681
|
+
onDragLeave: onDropInput
|
|
1682
|
+
}))), [inputStyle]);
|
|
1683
|
+
const AttachedView = useMemo(() => jsx(ScrollBar, {
|
|
1684
|
+
style: {
|
|
1685
|
+
marginRight: 5,
|
|
1686
|
+
paddingTop: 0,
|
|
1687
|
+
paddingBottom: 0,
|
|
1688
|
+
paddingRight: 7,
|
|
1689
|
+
overflowY: 'overlay'
|
|
1690
|
+
}
|
|
1691
|
+
}, jsx("div", {
|
|
1692
|
+
css: Attached,
|
|
1693
|
+
ref: attachedRef
|
|
1694
|
+
})), []);
|
|
1695
|
+
const PopoverView = useMemo(() => {
|
|
1696
|
+
return jsx(Popover, {
|
|
1697
|
+
open: popover,
|
|
1698
|
+
ref: popoverRef,
|
|
1699
|
+
anchor: sortIconRef,
|
|
1700
|
+
width: 'max-content',
|
|
1701
|
+
removeAfterClose: false,
|
|
1702
|
+
anchorOrigin: {
|
|
1703
|
+
vertical: 'bottom',
|
|
1704
|
+
horizontal: 'right'
|
|
1705
|
+
},
|
|
1706
|
+
transformOrigin: {
|
|
1707
|
+
vertical: 'top',
|
|
1708
|
+
horizontal: 'right'
|
|
1709
|
+
},
|
|
1710
|
+
onClose: () => setPopover(false)
|
|
1711
|
+
}, jsx(List, null, jsx(ListItem, {
|
|
1712
|
+
className: classes.listItem,
|
|
1713
|
+
button: true,
|
|
1714
|
+
onClick: e => onSortElement(e, 'filename')
|
|
1715
|
+
}, jsx(ListItemText, null, "By name")), jsx(ListItem, {
|
|
1716
|
+
className: classes.listItem,
|
|
1717
|
+
button: true,
|
|
1718
|
+
onClick: e => onSortElement(e, 'filetype')
|
|
1719
|
+
}, jsx(ListItemText, null, "By type")), jsx(ListItem, {
|
|
1720
|
+
className: classes.listItem,
|
|
1721
|
+
button: true,
|
|
1722
|
+
onClick: e => onSortElement(e, 'filesize')
|
|
1723
|
+
}, jsx(ListItemText, null, "By size")), jsx(ListItem, {
|
|
1724
|
+
className: classes.listItem,
|
|
1725
|
+
button: true,
|
|
1726
|
+
onClick: e => onSortElement(e, 'datetime')
|
|
1727
|
+
}, jsx(ListItemText, null, "By date")), jsx(ListItem, {
|
|
1728
|
+
className: classes.listItem,
|
|
1729
|
+
button: true,
|
|
1730
|
+
onClick: e => onSortElement(e, 'username')
|
|
1731
|
+
}, jsx(ListItemText, null, "By owner"))));
|
|
1732
|
+
}, [popover]);
|
|
1733
|
+
const PopupView = useMemo(() => jsx(Popup, {
|
|
1734
|
+
open: popup,
|
|
1735
|
+
ref: popupRef,
|
|
1736
|
+
type: 'yes-no',
|
|
1737
|
+
variant: 'warning',
|
|
1738
|
+
title: deleteNotifyText,
|
|
1739
|
+
fullScreen: true,
|
|
1740
|
+
pressESCToClose: true,
|
|
1741
|
+
autoFocusOKButton: true,
|
|
1742
|
+
onClose: onClosePopup,
|
|
1743
|
+
onConfirm: onRemoveMultiple,
|
|
1744
|
+
onCancel: onClosePopup
|
|
1745
|
+
}), [popup]);
|
|
1746
|
+
const ModalView = useMemo(() => {
|
|
1747
|
+
if (!chosenItems.length) return setOpen(false);
|
|
1748
|
+
const index = chosenItems[0];
|
|
1749
|
+
const data = attached[index]; // let data = oldAttached[index] || allNewAttached.getAll('files')[index-oldAttached.length];
|
|
1750
|
+
|
|
1751
|
+
return jsx(ModalSample, {
|
|
1752
|
+
open: open,
|
|
1753
|
+
title: data.FileName,
|
|
1754
|
+
onClose: () => setOpen(false)
|
|
1755
|
+
}, jsx(Slider, null, jsx(SliderItem, {
|
|
1756
|
+
url: data.URL
|
|
1757
|
+
})));
|
|
1758
|
+
}, [open]); // End view
|
|
1759
|
+
|
|
1760
|
+
useImperativeHandle(reference, () => {
|
|
1761
|
+
ref.current.oldAttached = oldAttached;
|
|
1762
|
+
ref.current.allNewAttached = allNewAttached;
|
|
1763
|
+
ref.current.attached = attached;
|
|
1764
|
+
ref.current.clear = clearAllAttached;
|
|
1765
|
+
return ref.current;
|
|
1766
|
+
});
|
|
1767
|
+
return jsx("div", _extends({}, props, {
|
|
1768
|
+
css: AttachmentRoot,
|
|
1769
|
+
className: ('DGN-UI-Attachment ' + className).trim(),
|
|
1770
|
+
style: style,
|
|
1771
|
+
ref: ref,
|
|
1772
|
+
onDragEnter: onDragFileStart
|
|
1773
|
+
}), AttachHeaderView, AttachmentInputView, AttachedView, PopoverView, PopupView, ModalView);
|
|
1774
|
+
}));
|
|
1775
|
+
Attachment.defaultProps = {
|
|
1776
|
+
deleteNotifyText: getGlobal('deleteNotifyText'),
|
|
1777
|
+
viewType: 'detail',
|
|
1778
|
+
label: getGlobal('attachText'),
|
|
1779
|
+
className: '',
|
|
1780
|
+
allowSort: true,
|
|
1781
|
+
multiple: true,
|
|
1782
|
+
disabled: false,
|
|
1783
|
+
readOnly: false,
|
|
1784
|
+
maxFile: Infinity,
|
|
1785
|
+
data: [],
|
|
1786
|
+
uploadErrorInfo: {}
|
|
1787
|
+
};
|
|
1788
|
+
Attachment.propTypes = {
|
|
1789
|
+
/** List attachment:<br />
|
|
1790
|
+
* [{<br />
|
|
1791
|
+
* "AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
|
|
1792
|
+
* "URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
|
|
1793
|
+
* "FileName": "8a07bee1eeff17a14eee.jpg",<br />
|
|
1794
|
+
* "FileSize": 248837,<br />
|
|
1795
|
+
* "KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
|
|
1796
|
+
* "CreateUserID": "LEMONADMIN",<br />
|
|
1797
|
+
* "CreateDate": "2020-08-24T11:54:04.307Z",<br />
|
|
1798
|
+
* "UserName": "Quản trị hệ thống"<br />
|
|
1799
|
+
* }, ...]
|
|
1800
|
+
*/
|
|
1801
|
+
data: PropTypes.array,
|
|
1802
|
+
|
|
1803
|
+
/** allow sort element on DOM if true */
|
|
1804
|
+
allowSort: PropTypes.bool,
|
|
1805
|
+
|
|
1806
|
+
/** prevent all event if true */
|
|
1807
|
+
disabled: PropTypes.bool,
|
|
1808
|
+
|
|
1809
|
+
/** prevent all event if true */
|
|
1810
|
+
readOnly: PropTypes.bool,
|
|
1811
|
+
|
|
1812
|
+
/** At least one attachment is required */
|
|
1813
|
+
required: PropTypes.bool,
|
|
1814
|
+
|
|
1815
|
+
/** allows to attach multiple files */
|
|
1816
|
+
multiple: PropTypes.bool,
|
|
1817
|
+
|
|
1818
|
+
/** the type of images displayed want to see */
|
|
1819
|
+
viewType: PropTypes.oneOf(['detail', 'icon']),
|
|
1820
|
+
|
|
1821
|
+
/** attach label to display in the upper left corner of attachment box */
|
|
1822
|
+
label: PropTypes.string,
|
|
1823
|
+
|
|
1824
|
+
/** class of Attachment component */
|
|
1825
|
+
className: PropTypes.string,
|
|
1826
|
+
|
|
1827
|
+
/** the name of the person who attached the file when uploading the file */
|
|
1828
|
+
ownerName: PropTypes.string,
|
|
1829
|
+
|
|
1830
|
+
/** Suggested passage attached */
|
|
1831
|
+
hintText: PropTypes.string,
|
|
1832
|
+
|
|
1833
|
+
/** text warning message when deleting files */
|
|
1834
|
+
deleteNotifyText: PropTypes.string,
|
|
1835
|
+
|
|
1836
|
+
/** error of attachment */
|
|
1837
|
+
error: PropTypes.string,
|
|
1838
|
+
|
|
1839
|
+
/** Allows what types of files to be attached */
|
|
1840
|
+
accept: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
1841
|
+
|
|
1842
|
+
/** Maximum capacity allowed to attach */
|
|
1843
|
+
maxSize: PropTypes.string,
|
|
1844
|
+
|
|
1845
|
+
/** Maximum quantity allowed to attach */
|
|
1846
|
+
maxFile: PropTypes.number,
|
|
1847
|
+
|
|
1848
|
+
/** style inline of Attachment component */
|
|
1849
|
+
style: PropTypes.object,
|
|
1850
|
+
|
|
1851
|
+
/** style inline of error in Attachment component */
|
|
1852
|
+
errorStyle: PropTypes.object,
|
|
1853
|
+
|
|
1854
|
+
/** style inline of input in Attachment component */
|
|
1855
|
+
inputStyle: PropTypes.object,
|
|
1856
|
+
|
|
1857
|
+
/** props of input in Attachment component */
|
|
1858
|
+
inputProps: PropTypes.object,
|
|
1859
|
+
|
|
1860
|
+
/** errors show up when the file upload is corrupted */
|
|
1861
|
+
uploadErrorInfo: PropTypes.object,
|
|
1862
|
+
|
|
1863
|
+
/** event when uploading file failed */
|
|
1864
|
+
onUploadError: PropTypes.func,
|
|
1865
|
+
|
|
1866
|
+
/**
|
|
1867
|
+
* event when removed file(s)<br/>
|
|
1868
|
+
* return data: {<br/>
|
|
1869
|
+
* attached: [Files] (insist old and all new files )<br/>
|
|
1870
|
+
* allNewAttached: [Files]<br/>
|
|
1871
|
+
* oldAttached: [Files]<br/>
|
|
1872
|
+
* removedAttached: [Files]<br/>
|
|
1873
|
+
* element: [NodeList (just removed)]<br/>
|
|
1874
|
+
* }
|
|
1875
|
+
*/
|
|
1876
|
+
onRemove: PropTypes.func,
|
|
1877
|
+
|
|
1878
|
+
/** view attached event, if not it will use default */
|
|
1879
|
+
onView: PropTypes.func,
|
|
1880
|
+
|
|
1881
|
+
/** download attached event, if not it will use default */
|
|
1882
|
+
onDownload: PropTypes.func,
|
|
1883
|
+
|
|
1884
|
+
/** event when there is a change attached */
|
|
1885
|
+
onChange: PropTypes.func,
|
|
1886
|
+
|
|
1887
|
+
/** any props else */
|
|
1888
|
+
props: PropTypes.any
|
|
1889
|
+
};
|
|
1890
|
+
export default Attachment;
|