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,364 @@
|
|
|
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, useMemo, useRef, forwardRef } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import theme from '../../theme/settings';
|
|
10
|
+
import { Button } from '../';
|
|
11
|
+
import Icon, { Close, Approval } from '../../icons';
|
|
12
|
+
import TextInput from '../form-control/text-input';
|
|
13
|
+
const ProposalsPopup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
14
|
+
open,
|
|
15
|
+
clearAble,
|
|
16
|
+
pressESCToClose,
|
|
17
|
+
readOnly,
|
|
18
|
+
disabled,
|
|
19
|
+
style,
|
|
20
|
+
popupStyle,
|
|
21
|
+
anchor,
|
|
22
|
+
anchorOrigin,
|
|
23
|
+
transformOrigin,
|
|
24
|
+
refs,
|
|
25
|
+
onClose,
|
|
26
|
+
onConfirm,
|
|
27
|
+
onCancel,
|
|
28
|
+
value,
|
|
29
|
+
defaultValue,
|
|
30
|
+
type,
|
|
31
|
+
viewType,
|
|
32
|
+
error,
|
|
33
|
+
label,
|
|
34
|
+
buttonText,
|
|
35
|
+
placeholder,
|
|
36
|
+
...props
|
|
37
|
+
}, ref) => {
|
|
38
|
+
if (!ref) {
|
|
39
|
+
ref = useRef(null);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const PopupContainer = css`
|
|
43
|
+
display: flex;
|
|
44
|
+
position: fixed;
|
|
45
|
+
width: 80%;
|
|
46
|
+
max-width: 480px;
|
|
47
|
+
z-index: 1000;
|
|
48
|
+
transform: scale(0);
|
|
49
|
+
transition: transform 0.2s linear;
|
|
50
|
+
&.open {
|
|
51
|
+
transform: scale(1);
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
const PopupFrame = css`
|
|
55
|
+
display: block;
|
|
56
|
+
align-items: baseline;
|
|
57
|
+
position: relative;
|
|
58
|
+
background: #FFFFFF;
|
|
59
|
+
width: 100%;
|
|
60
|
+
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
61
|
+
border-radius: 4px;
|
|
62
|
+
padding: 24px 16px;
|
|
63
|
+
`;
|
|
64
|
+
const PopupContent = css`
|
|
65
|
+
width: 100%;
|
|
66
|
+
height: 100%;
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
padding: 0 24px;
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
`;
|
|
73
|
+
const PopupInput = css`
|
|
74
|
+
display: block;
|
|
75
|
+
width: 100%;
|
|
76
|
+
`;
|
|
77
|
+
const PopupAction = css`
|
|
78
|
+
display: block;
|
|
79
|
+
margin-left: auto;
|
|
80
|
+
`;
|
|
81
|
+
const PopupClearIcon = css`
|
|
82
|
+
display: block;
|
|
83
|
+
position: absolute;
|
|
84
|
+
width: 24px;
|
|
85
|
+
height: 24px;
|
|
86
|
+
top: 16px;
|
|
87
|
+
right: 24px;
|
|
88
|
+
color: ${theme.colors.secondary};
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
&:hover {
|
|
91
|
+
color: '#404456' !important;
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
const onClosePopup = () => {
|
|
96
|
+
if (onClose) onClose();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const onProposals = () => {
|
|
100
|
+
const input = PopupInputRef.current.querySelector('input');
|
|
101
|
+
|
|
102
|
+
if (/^cancel$/i.test(type)) {
|
|
103
|
+
if (onCancel) onCancel(input);
|
|
104
|
+
} else if (onConfirm) onConfirm(input);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const pressESCHandler = event => {
|
|
108
|
+
if (event.key === 'Escape') {
|
|
109
|
+
onClosePopup();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const calPosition = (position, originBounding) => {
|
|
116
|
+
switch (position) {
|
|
117
|
+
case 'bottom':
|
|
118
|
+
case 'right':
|
|
119
|
+
{
|
|
120
|
+
return [originBounding.height, originBounding.width];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
case 'center':
|
|
124
|
+
{
|
|
125
|
+
return [originBounding.height / 2, originBounding.width / 2];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
default:
|
|
129
|
+
return [0, 0];
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (refs) refs(ref);
|
|
135
|
+
}, []);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (open && ref.current) {
|
|
138
|
+
let top = 0,
|
|
139
|
+
left = 0,
|
|
140
|
+
vertical = 0,
|
|
141
|
+
horizontal = 0; // Position's anchor
|
|
142
|
+
|
|
143
|
+
if (anchorOrigin && anchor) {
|
|
144
|
+
if (anchor.current) {
|
|
145
|
+
anchor = anchor.current;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (anchorOrigin === 'center') {
|
|
149
|
+
anchorOrigin = {
|
|
150
|
+
vertical: 'center',
|
|
151
|
+
horizontal: 'center'
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const anchorBounding = anchor.getBoundingClientRect();
|
|
156
|
+
vertical = anchorBounding.y + calPosition(anchorOrigin.vertical, anchorBounding)[0];
|
|
157
|
+
horizontal = anchorBounding.x + calPosition(anchorOrigin.horizontal, anchorBounding)[1];
|
|
158
|
+
} // Position's transform
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
if (transformOrigin) {
|
|
162
|
+
if (transformOrigin === 'center') {
|
|
163
|
+
transformOrigin = {
|
|
164
|
+
vertical: 'center',
|
|
165
|
+
horizontal: 'center'
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const offsetHeight = ref.current.offsetHeight;
|
|
170
|
+
const offsetWidth = ref.current.offsetWidth;
|
|
171
|
+
|
|
172
|
+
switch (transformOrigin.vertical) {
|
|
173
|
+
case 'center':
|
|
174
|
+
top = vertical - offsetHeight / 2;
|
|
175
|
+
break;
|
|
176
|
+
|
|
177
|
+
case 'bottom':
|
|
178
|
+
top = vertical - offsetHeight;
|
|
179
|
+
break;
|
|
180
|
+
|
|
181
|
+
default:
|
|
182
|
+
top = vertical;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
switch (transformOrigin.horizontal) {
|
|
186
|
+
case 'center':
|
|
187
|
+
left = horizontal - offsetWidth / 2;
|
|
188
|
+
break;
|
|
189
|
+
|
|
190
|
+
case 'right':
|
|
191
|
+
left = horizontal - offsetWidth;
|
|
192
|
+
break;
|
|
193
|
+
|
|
194
|
+
default:
|
|
195
|
+
left = horizontal;
|
|
196
|
+
} // Reset position if the element overflow window screen size
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
if (top < 0) {
|
|
200
|
+
top = 0;
|
|
201
|
+
} else if (top + offsetHeight > window.innerHeight) {
|
|
202
|
+
top = window.innerHeight - offsetHeight;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (left < 0) {
|
|
206
|
+
left = 0;
|
|
207
|
+
} else if (left + offsetWidth > window.innerWidth) {
|
|
208
|
+
left = window.innerWidth - offsetWidth;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
ref.current.style.top = top + 'px';
|
|
212
|
+
ref.current.style.left = left + 'px';
|
|
213
|
+
ref.current.style.transformOrigin = `${transformOrigin.horizontal || 'left'} ${transformOrigin.vertical || 'top'}`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
ref.current.classList.add('open'); // Allow press ESC to close popup
|
|
217
|
+
|
|
218
|
+
if (pressESCToClose) {
|
|
219
|
+
document.addEventListener('keydown', pressESCHandler);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return () => {
|
|
224
|
+
if (open && ref.current) {
|
|
225
|
+
ref.current.classList.remove('open');
|
|
226
|
+
|
|
227
|
+
if (pressESCToClose) {
|
|
228
|
+
document.removeEventListener('keydown', pressESCHandler);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}, [open]);
|
|
233
|
+
const popupInput = useMemo(() => jsx("div", {
|
|
234
|
+
css: PopupInput
|
|
235
|
+
}, jsx(TextInput, {
|
|
236
|
+
error: error,
|
|
237
|
+
viewType: viewType,
|
|
238
|
+
label: label,
|
|
239
|
+
value: value,
|
|
240
|
+
defaultValue: defaultValue,
|
|
241
|
+
placeholder: placeholder,
|
|
242
|
+
disabled: disabled,
|
|
243
|
+
readOnly: readOnly,
|
|
244
|
+
style: {
|
|
245
|
+
marginLeft: 0,
|
|
246
|
+
marginRight: 0,
|
|
247
|
+
marginTop: 0
|
|
248
|
+
}
|
|
249
|
+
})), [label, placeholder, value, error, disabled]);
|
|
250
|
+
const popupAction = useMemo(() => {
|
|
251
|
+
const IconName = /cancel/i.test(type) ? Close : Approval;
|
|
252
|
+
const text = buttonText || (/cancel/i.test(type) ? 'Từ chối' : 'Duyệt');
|
|
253
|
+
return jsx("div", {
|
|
254
|
+
css: PopupAction
|
|
255
|
+
}, jsx(Button, {
|
|
256
|
+
viewType: 'outlined',
|
|
257
|
+
style: {
|
|
258
|
+
border: 'none',
|
|
259
|
+
padding: 0,
|
|
260
|
+
minWidth: 'auto',
|
|
261
|
+
backgroundColor: 'transparent'
|
|
262
|
+
},
|
|
263
|
+
color: /cancel/i.test(type) ? 'danger' : 'success',
|
|
264
|
+
onClick: onProposals,
|
|
265
|
+
disabled: disabled,
|
|
266
|
+
startIcon: jsx(IconName, {
|
|
267
|
+
color: 'currentColor',
|
|
268
|
+
viewBox: true,
|
|
269
|
+
bgFill: 'none',
|
|
270
|
+
outline: true
|
|
271
|
+
})
|
|
272
|
+
}, text));
|
|
273
|
+
}, [type, buttonText, disabled]);
|
|
274
|
+
const popupClearIcon = useMemo(() => clearAble && jsx("div", {
|
|
275
|
+
css: PopupClearIcon
|
|
276
|
+
}, jsx(Icon, {
|
|
277
|
+
name: 'Close',
|
|
278
|
+
width: "12",
|
|
279
|
+
height: "12",
|
|
280
|
+
onClick: onClosePopup,
|
|
281
|
+
style: {
|
|
282
|
+
width: '100%',
|
|
283
|
+
height: '100%'
|
|
284
|
+
}
|
|
285
|
+
})), [clearAble]);
|
|
286
|
+
return jsx("div", {
|
|
287
|
+
css: PopupContainer,
|
|
288
|
+
ref: ref,
|
|
289
|
+
style: style
|
|
290
|
+
}, jsx("div", _extends({
|
|
291
|
+
css: PopupFrame
|
|
292
|
+
}, props, {
|
|
293
|
+
style: popupStyle
|
|
294
|
+
}), jsx("div", {
|
|
295
|
+
css: PopupContent
|
|
296
|
+
}, popupInput, popupAction), popupClearIcon));
|
|
297
|
+
}));
|
|
298
|
+
ProposalsPopup.defaultProps = {
|
|
299
|
+
type: 'confirm',
|
|
300
|
+
viewType: 'underlined',
|
|
301
|
+
clearAble: true,
|
|
302
|
+
open: false,
|
|
303
|
+
pressESCToClose: true,
|
|
304
|
+
anchorOrigin: {},
|
|
305
|
+
transformOrigin: {}
|
|
306
|
+
};
|
|
307
|
+
ProposalsPopup.propTypes = {
|
|
308
|
+
/** type of Popup, corresponding to the button */
|
|
309
|
+
type: PropTypes.oneOf(['confirm', 'cancel']),
|
|
310
|
+
|
|
311
|
+
/** type of TextInput */
|
|
312
|
+
viewType: PropTypes.oneOf(['underlined', 'outlined']),
|
|
313
|
+
|
|
314
|
+
/** placeholder to display in TextInput */
|
|
315
|
+
placeholder: PropTypes.string,
|
|
316
|
+
|
|
317
|
+
/** label to display on TextInput */
|
|
318
|
+
label: PropTypes.string,
|
|
319
|
+
|
|
320
|
+
/** the content to display in button */
|
|
321
|
+
buttonText: PropTypes.string,
|
|
322
|
+
|
|
323
|
+
/** value to display in TextInput */
|
|
324
|
+
value: PropTypes.string,
|
|
325
|
+
|
|
326
|
+
/** display clear icon if true */
|
|
327
|
+
clearAble: PropTypes.bool,
|
|
328
|
+
|
|
329
|
+
/** show Popup if true */
|
|
330
|
+
open: PropTypes.bool,
|
|
331
|
+
|
|
332
|
+
/** allow close Popup when press ESC */
|
|
333
|
+
pressESCToClose: PropTypes.bool,
|
|
334
|
+
|
|
335
|
+
/** style inline for Popup container */
|
|
336
|
+
style: PropTypes.object,
|
|
337
|
+
|
|
338
|
+
/** style inline for Popup */
|
|
339
|
+
popupStyle: PropTypes.object,
|
|
340
|
+
|
|
341
|
+
/** positions are displayed under this object */
|
|
342
|
+
anchor: PropTypes.object,
|
|
343
|
+
|
|
344
|
+
/** The root is displayed according to the position of the anchor */
|
|
345
|
+
anchorOrigin: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
346
|
+
// {vertical: 'top', horizontal: 'left'}
|
|
347
|
+
|
|
348
|
+
/** Popup's native display */
|
|
349
|
+
transformOrigin: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
350
|
+
// {vertical: 'bottom', horizontal: 'right'}
|
|
351
|
+
|
|
352
|
+
/** the function to get ref of Popup */
|
|
353
|
+
refs: PropTypes.func,
|
|
354
|
+
|
|
355
|
+
/** the function run when close Popup */
|
|
356
|
+
onClose: PropTypes.func,
|
|
357
|
+
|
|
358
|
+
/** the function run when click confirm button */
|
|
359
|
+
onConfirm: PropTypes.func,
|
|
360
|
+
|
|
361
|
+
/** the function run when click cancel button */
|
|
362
|
+
onCancel: PropTypes.func
|
|
363
|
+
};
|
|
364
|
+
export default ProposalsPopup;
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { jsx } from '@emotion/core';
|
|
7
|
+
import { memo, forwardRef } from 'react';
|
|
8
|
+
import PopupV2 from '.';
|
|
9
|
+
const DangerPopup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({ ...props
|
|
10
|
+
}, ref) => {
|
|
11
|
+
return jsx(PopupV2, _extends({
|
|
12
|
+
ref: ref
|
|
13
|
+
}, props, {
|
|
14
|
+
type: 'danger'
|
|
15
|
+
}));
|
|
16
|
+
}));
|
|
17
|
+
export default DangerPopup;
|
|
@@ -0,0 +1,460 @@
|
|
|
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, useState, forwardRef, useImperativeHandle, Fragment } from 'react';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
8
|
+
import { bool, oneOf, oneOfType, string, func, object, number, node, shape, instanceOf, elementType } from 'prop-types';
|
|
9
|
+
import { jsx, css } from '@emotion/core';
|
|
10
|
+
import { Button, Typography } from '../../';
|
|
11
|
+
import { Close, Info, Archive, Warning, Failed } from '../../../icons';
|
|
12
|
+
import { getGlobal } from '../../../global';
|
|
13
|
+
import { lighten } from '../../../styles/color-helper';
|
|
14
|
+
import { useTheme } from '../../../theme';
|
|
15
|
+
import { capitalize, renderIcon } from '../../../utils';
|
|
16
|
+
import { animations } from '../../../styles/animation';
|
|
17
|
+
const {
|
|
18
|
+
colors
|
|
19
|
+
} = useTheme();
|
|
20
|
+
export const icons = {
|
|
21
|
+
yesno: jsx(Info, {
|
|
22
|
+
viewBox: true,
|
|
23
|
+
width: 40,
|
|
24
|
+
height: 40
|
|
25
|
+
}),
|
|
26
|
+
info: jsx(Info, {
|
|
27
|
+
viewBox: true,
|
|
28
|
+
width: 40,
|
|
29
|
+
height: 40
|
|
30
|
+
}),
|
|
31
|
+
success: jsx(Archive, {
|
|
32
|
+
viewBox: true,
|
|
33
|
+
width: 40,
|
|
34
|
+
height: 40
|
|
35
|
+
}),
|
|
36
|
+
warning: jsx(Warning, {
|
|
37
|
+
viewBox: true,
|
|
38
|
+
width: 40,
|
|
39
|
+
height: 40
|
|
40
|
+
}),
|
|
41
|
+
danger: jsx(Failed, {
|
|
42
|
+
viewBox: true,
|
|
43
|
+
width: 40,
|
|
44
|
+
height: 40
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
48
|
+
open,
|
|
49
|
+
type,
|
|
50
|
+
icon,
|
|
51
|
+
title,
|
|
52
|
+
subtitle,
|
|
53
|
+
description,
|
|
54
|
+
fullScreen,
|
|
55
|
+
pressESCToClose,
|
|
56
|
+
className,
|
|
57
|
+
style,
|
|
58
|
+
onClose,
|
|
59
|
+
onConfirm,
|
|
60
|
+
onCancel,
|
|
61
|
+
confirmProps,
|
|
62
|
+
cancelProps,
|
|
63
|
+
width,
|
|
64
|
+
top,
|
|
65
|
+
yesText,
|
|
66
|
+
noText,
|
|
67
|
+
...props
|
|
68
|
+
}, reference) => {
|
|
69
|
+
const ref = useRef(null);
|
|
70
|
+
const [openState, setOpenState] = useState(open);
|
|
71
|
+
const [custom, setCustom] = useState(null);
|
|
72
|
+
const [showMoreDescription, setShowMoreDescription] = useState(false);
|
|
73
|
+
const fadeInDown = animations.fadeInDown;
|
|
74
|
+
const fadeOutUp = animations.fadeOutUp;
|
|
75
|
+
const PopupRoot = css`
|
|
76
|
+
display: flex;
|
|
77
|
+
position: fixed;
|
|
78
|
+
width: 100%;
|
|
79
|
+
height: 100%;
|
|
80
|
+
top: 0;
|
|
81
|
+
left: 0;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
inset: 0;
|
|
84
|
+
background-color: rgba(21, 26, 48, 0.5);
|
|
85
|
+
opacity: 0;
|
|
86
|
+
transition: opacity 0.3s ease;
|
|
87
|
+
z-index: 9002;
|
|
88
|
+
word-break: break-word;
|
|
89
|
+
.DGN-UI-Popup {
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
width: ${isNaN(width) ? width : width + 'px'};
|
|
93
|
+
height: fit-content;
|
|
94
|
+
max-width: 80%;
|
|
95
|
+
max-height: 80%;
|
|
96
|
+
margin: ${isNaN(top) ? top : top + 'px'} auto auto;
|
|
97
|
+
background-color: ${colors.white};
|
|
98
|
+
border-radius: 4px;
|
|
99
|
+
box-sizing: border-box;
|
|
100
|
+
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
|
|
101
|
+
animation: ${fadeOutUp} 0.2s ease;
|
|
102
|
+
animation-fill-mode: forwards;
|
|
103
|
+
&.DGN-Show {
|
|
104
|
+
animation-name: ${fadeInDown};
|
|
105
|
+
}
|
|
106
|
+
.DGN-UI-Popup-Header {
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: row;
|
|
109
|
+
align-items: center;
|
|
110
|
+
min-height: 40px;
|
|
111
|
+
padding: 0 16px;
|
|
112
|
+
border-radius: 4px 4px 0px 0px;
|
|
113
|
+
.DGN-UI-Popup-Header-Title {
|
|
114
|
+
display: flex;
|
|
115
|
+
width: calc(100% - 24px);
|
|
116
|
+
white-space: nowrap;
|
|
117
|
+
overflow-x: hidden;
|
|
118
|
+
text-overflow: ellipsis;
|
|
119
|
+
font-weight: bold;
|
|
120
|
+
}
|
|
121
|
+
.DGN-UI-Popup-Header-Icon {
|
|
122
|
+
display: block;
|
|
123
|
+
width: 24px;
|
|
124
|
+
height: 24px;
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
transition: filter 0.1s linear;
|
|
127
|
+
&:hover {
|
|
128
|
+
filter: brightness(0.85);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
color: ${colors[type === 'yesno' ? 'info' : type]};
|
|
132
|
+
background-color: ${lighten(colors[type === 'yesno' ? 'info' : type], 0.85)};
|
|
133
|
+
}
|
|
134
|
+
.DGN-UI-Popup-Body {
|
|
135
|
+
display: flex;
|
|
136
|
+
position: relative;
|
|
137
|
+
flex-direction: row;
|
|
138
|
+
flex: 1 1 auto;
|
|
139
|
+
padding: 16px;
|
|
140
|
+
overflow: auto;
|
|
141
|
+
&::-webkit-scrollbar {
|
|
142
|
+
width: 24px;
|
|
143
|
+
background-color: #fff !important;
|
|
144
|
+
border-radius: 4px;
|
|
145
|
+
}
|
|
146
|
+
&::-webkit-scrollbar-thumb {
|
|
147
|
+
border-radius: 24px;
|
|
148
|
+
border: 8px solid transparent;
|
|
149
|
+
mix-blend-mode: normal;
|
|
150
|
+
background-color: ${colors.scrollbar} !important;
|
|
151
|
+
background-clip: content-box;
|
|
152
|
+
}
|
|
153
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
154
|
+
border-radius: 24px;
|
|
155
|
+
border: 8px solid transparent;
|
|
156
|
+
mix-blend-mode: normal;
|
|
157
|
+
background-color: ${colors.scrollbarHover} !important;
|
|
158
|
+
background-clip: content-box;
|
|
159
|
+
}
|
|
160
|
+
.DGN-UI-Popup-Body-Icon {
|
|
161
|
+
display: block;
|
|
162
|
+
width: 40px;
|
|
163
|
+
margin-right: 16px;
|
|
164
|
+
border-radius: 50%;
|
|
165
|
+
}
|
|
166
|
+
.DGN-UI-Popup-Body-Description {
|
|
167
|
+
display: flex;
|
|
168
|
+
position: relative;
|
|
169
|
+
min-height: 40px;
|
|
170
|
+
height: max-content;
|
|
171
|
+
align-items: center;
|
|
172
|
+
.DGN-UI-Popup-Body-Subtitle {
|
|
173
|
+
margin-bottom: ${(description === null || description === void 0 ? void 0 : description.length) > 0 ? '8px' : '0px'};
|
|
174
|
+
}
|
|
175
|
+
.DGN-UI-Popup-Body-Detail {
|
|
176
|
+
overflow: hidden;
|
|
177
|
+
text-overflow: ellipsis;
|
|
178
|
+
display: -webkit-box;
|
|
179
|
+
-webkit-line-clamp: ${showMoreDescription ? 'none' : subtitle ? 1 : 3};
|
|
180
|
+
-webkit-box-orient: vertical;
|
|
181
|
+
}
|
|
182
|
+
.DGN-More-Action {
|
|
183
|
+
display: block;
|
|
184
|
+
width: fit-content;
|
|
185
|
+
margin-top: 16px;
|
|
186
|
+
margin-bottom: ${type === 'yesno' ? '0px' : '8px'};
|
|
187
|
+
text-decoration: underline;
|
|
188
|
+
color: ${colors.info};
|
|
189
|
+
cursor: pointer;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
.DGN-UI-Popup-Action {
|
|
194
|
+
display: flex;
|
|
195
|
+
flex-direction: row;
|
|
196
|
+
justify-content: flex-end;
|
|
197
|
+
padding: 8px 16px 16px 16px;
|
|
198
|
+
.DGN-UI-Button {
|
|
199
|
+
margin: 0;
|
|
200
|
+
min-width: 80px;
|
|
201
|
+
&.filled {
|
|
202
|
+
margin-right: 8px;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
`;
|
|
208
|
+
|
|
209
|
+
const getTitle = (tit, typ = type) => {
|
|
210
|
+
if (tit !== null && tit !== undefined) {
|
|
211
|
+
return tit;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const map = {
|
|
215
|
+
danger: 'error',
|
|
216
|
+
info: 'notify',
|
|
217
|
+
success: 'confirm',
|
|
218
|
+
warning: 'warning'
|
|
219
|
+
};
|
|
220
|
+
return getGlobal(map[typ] || 'notify');
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const pressESCHandler = event => {
|
|
224
|
+
if (event.key === 'Escape') {
|
|
225
|
+
onClosePopup(custom === null);
|
|
226
|
+
document.removeEventListener('keydown', pressESCHandler);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const onShowPopup = (options, cb) => {
|
|
233
|
+
if (options && typeof options === 'object' && Object.keys(object).length) {
|
|
234
|
+
const newProps = {
|
|
235
|
+
type: options.type !== undefined ? options.type : type,
|
|
236
|
+
title: options.title !== undefined ? options.title : title,
|
|
237
|
+
icon: options.icon !== undefined ? options.icon : icon,
|
|
238
|
+
description: options.description !== undefined ? options.description : description,
|
|
239
|
+
yesText: options.yesText !== undefined ? options.yesText : yesText,
|
|
240
|
+
noText: options.noText !== undefined ? options.noText : noText,
|
|
241
|
+
confirmProps: options.confirmProps !== undefined ? options.confirmProps : confirmProps,
|
|
242
|
+
cancelProps: options.cancelProps !== undefined ? options.cancelProps : cancelProps,
|
|
243
|
+
onCancel: cb ? () => cb(false) : options.onCancel !== undefined ? options.onCancel : onCancel,
|
|
244
|
+
onConfirm: cb ? () => cb(true) : options.onConfirm !== undefined ? options.onConfirm : onConfirm
|
|
245
|
+
};
|
|
246
|
+
const popup = jsx(Fragment, null, jsx("div", {
|
|
247
|
+
className: 'DGN-UI-Popup-Header ' + 'DGN-' + capitalize(newProps.type)
|
|
248
|
+
}, jsx(Typography, {
|
|
249
|
+
className: 'DGN-UI-Popup-Header-Title',
|
|
250
|
+
color: 'inherit'
|
|
251
|
+
}, getTitle(newProps.title, newProps.type)), jsx("div", {
|
|
252
|
+
className: 'DGN-UI-Popup-Header-Icon',
|
|
253
|
+
onClick: () => onClosePopup()
|
|
254
|
+
}, jsx(Close, {
|
|
255
|
+
viewBox: true,
|
|
256
|
+
color: 'currentColor'
|
|
257
|
+
}))), jsx("div", {
|
|
258
|
+
className: 'DGN-UI-Popup-Body'
|
|
259
|
+
}, newProps.icon !== false && jsx("div", {
|
|
260
|
+
className: 'DGN-UI-Popup-Body-Icon'
|
|
261
|
+
}, newProps.icon === true ? icons[newProps.type] : renderIcon(newProps.icon, 'name', {
|
|
262
|
+
viewBox: true,
|
|
263
|
+
width: 40,
|
|
264
|
+
height: 40,
|
|
265
|
+
color: newProps.type
|
|
266
|
+
})), jsx("div", {
|
|
267
|
+
className: 'DGN-UI-Popup-Body-Description'
|
|
268
|
+
}, jsx(Typography, {
|
|
269
|
+
type: 'p2'
|
|
270
|
+
}, newProps.description))), (newProps.onConfirm || newProps.onCancel || newProps.type === 'yesno') && jsx("div", {
|
|
271
|
+
className: 'DGN-UI-Popup-Action'
|
|
272
|
+
}, (newProps.onConfirm || newProps.type === 'yesno') && jsx(Button, _extends({
|
|
273
|
+
viewType: 'filled',
|
|
274
|
+
label: newProps.yesText || getGlobal('ok').toUpperCase(),
|
|
275
|
+
color: newProps.type,
|
|
276
|
+
onClick: newProps.onConfirm
|
|
277
|
+
}, newProps.confirmProps)), (newProps.onCancel || newProps.type === 'yesno') && jsx(Button, _extends({
|
|
278
|
+
viewType: 'outlined',
|
|
279
|
+
label: newProps.noText || getGlobal('cancel').toUpperCase(),
|
|
280
|
+
color: newProps.type,
|
|
281
|
+
onClick: newProps.onCancel
|
|
282
|
+
}, newProps.cancelProps))));
|
|
283
|
+
setCustom(popup);
|
|
284
|
+
} else {
|
|
285
|
+
setCustom(false);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
setOpenState(true);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const onClosePopup = (action = false) => {
|
|
292
|
+
if (onClose && action) {
|
|
293
|
+
onClose();
|
|
294
|
+
} else {
|
|
295
|
+
if (ref.current) {
|
|
296
|
+
setTimeout(() => {
|
|
297
|
+
setOpenState(false);
|
|
298
|
+
}, 300);
|
|
299
|
+
ref.current.style.opacity = null;
|
|
300
|
+
ref.current.firstChild.classList.remove('DGN-Show');
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
if (open) {
|
|
307
|
+
setOpenState(open);
|
|
308
|
+
} else {
|
|
309
|
+
onClosePopup();
|
|
310
|
+
}
|
|
311
|
+
}, [open]);
|
|
312
|
+
useEffect(() => {
|
|
313
|
+
if (openState) {
|
|
314
|
+
ref.current.style.opacity = 1;
|
|
315
|
+
ref.current.firstChild.classList.add('DGN-Show');
|
|
316
|
+
|
|
317
|
+
if (pressESCToClose) {
|
|
318
|
+
document.addEventListener('keydown', pressESCHandler);
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
setCustom(null);
|
|
322
|
+
}
|
|
323
|
+
}, [openState]);
|
|
324
|
+
useImperativeHandle(reference, () => {
|
|
325
|
+
const abc = ref.current || {};
|
|
326
|
+
abc.show = onShowPopup;
|
|
327
|
+
abc.close = onClosePopup;
|
|
328
|
+
return abc;
|
|
329
|
+
});
|
|
330
|
+
return openState && /*#__PURE__*/createPortal(jsx("div", {
|
|
331
|
+
css: PopupRoot,
|
|
332
|
+
ref: ref,
|
|
333
|
+
style: style,
|
|
334
|
+
className: ('DGN-UI-Portal DGN-UI-Popup-Portal ' + className).trimRight()
|
|
335
|
+
}, jsx("div", _extends({
|
|
336
|
+
className: 'DGN-UI-Popup'
|
|
337
|
+
}, props), custom ? custom : jsx(Fragment, null, jsx("div", {
|
|
338
|
+
className: 'DGN-UI-Popup-Header ' + 'DGN-' + capitalize(type)
|
|
339
|
+
}, jsx(Typography, {
|
|
340
|
+
className: 'DGN-UI-Popup-Header-Title',
|
|
341
|
+
color: 'inherit'
|
|
342
|
+
}, getTitle(title)), jsx("div", {
|
|
343
|
+
className: 'DGN-UI-Popup-Header-Icon',
|
|
344
|
+
onClick: e => onClosePopup(custom === false ? false : e)
|
|
345
|
+
}, jsx(Close, {
|
|
346
|
+
viewBox: true,
|
|
347
|
+
color: 'currentColor'
|
|
348
|
+
}))), jsx("div", {
|
|
349
|
+
className: 'DGN-UI-Popup-Body'
|
|
350
|
+
}, icon !== false && jsx("div", {
|
|
351
|
+
className: 'DGN-UI-Popup-Body-Icon'
|
|
352
|
+
}, icon === true ? icons[type] : renderIcon(icon, 'name', {
|
|
353
|
+
viewBox: true,
|
|
354
|
+
width: 40,
|
|
355
|
+
height: 40,
|
|
356
|
+
color: type
|
|
357
|
+
})), jsx("div", {
|
|
358
|
+
className: 'DGN-UI-Popup-Body-Description'
|
|
359
|
+
}, jsx(Typography, {
|
|
360
|
+
type: 'p2'
|
|
361
|
+
}, subtitle && jsx(Typography, {
|
|
362
|
+
className: 'DGN-UI-Popup-Body-Subtitle',
|
|
363
|
+
fullWidth: true
|
|
364
|
+
}, subtitle), jsx(Typography, {
|
|
365
|
+
type: 'p2',
|
|
366
|
+
className: 'DGN-UI-Popup-Body-Detail'
|
|
367
|
+
}, description), description && typeof description === 'string' && (description === null || description === void 0 ? void 0 : description.length) > 62 && jsx("span", {
|
|
368
|
+
className: 'DGN-More-Action',
|
|
369
|
+
onClick: () => setShowMoreDescription(!showMoreDescription)
|
|
370
|
+
}, getGlobal(showMoreDescription ? 'showLess' : 'showMore'))))), (onConfirm || onCancel || type === 'yesno') && jsx("div", {
|
|
371
|
+
className: 'DGN-UI-Popup-Action'
|
|
372
|
+
}, (onConfirm || type === 'yesno') && jsx(Button, _extends({
|
|
373
|
+
viewType: 'filled',
|
|
374
|
+
label: yesText || getGlobal('ok').toUpperCase(),
|
|
375
|
+
color: type === 'yesno' ? 'info' : type,
|
|
376
|
+
onClick: () => {
|
|
377
|
+
onConfirm && onConfirm();
|
|
378
|
+
onClose();
|
|
379
|
+
}
|
|
380
|
+
}, confirmProps)), (onCancel || type === 'yesno') && jsx(Button, _extends({
|
|
381
|
+
viewType: 'outlined',
|
|
382
|
+
label: noText || getGlobal('cancel').toUpperCase(),
|
|
383
|
+
color: type === 'yesno' ? 'info' : type,
|
|
384
|
+
onClick: () => {
|
|
385
|
+
onCancel && onCancel();
|
|
386
|
+
onClose();
|
|
387
|
+
}
|
|
388
|
+
}, cancelProps)))))), document.body);
|
|
389
|
+
}));
|
|
390
|
+
Popup.defaultProps = {
|
|
391
|
+
open: false,
|
|
392
|
+
pressESCToClose: false,
|
|
393
|
+
icon: true,
|
|
394
|
+
width: 480,
|
|
395
|
+
top: 50,
|
|
396
|
+
type: 'info',
|
|
397
|
+
className: ''
|
|
398
|
+
};
|
|
399
|
+
Popup.propTypes = {
|
|
400
|
+
/** show Popup if true */
|
|
401
|
+
open: bool,
|
|
402
|
+
|
|
403
|
+
/** allow close Popup when press ESC */
|
|
404
|
+
pressESCToClose: bool,
|
|
405
|
+
|
|
406
|
+
/** the icon to display before content */
|
|
407
|
+
icon: oneOfType([bool, string]),
|
|
408
|
+
|
|
409
|
+
/** width of Popup */
|
|
410
|
+
width: oneOfType([number, string]),
|
|
411
|
+
|
|
412
|
+
/** set top position for Popup */
|
|
413
|
+
top: oneOfType([number, string]),
|
|
414
|
+
|
|
415
|
+
/** the content show on header */
|
|
416
|
+
title: node,
|
|
417
|
+
|
|
418
|
+
/** the main content show in body */
|
|
419
|
+
subtitle: node,
|
|
420
|
+
|
|
421
|
+
/** details content show in body */
|
|
422
|
+
description: string,
|
|
423
|
+
|
|
424
|
+
/** class of Popup */
|
|
425
|
+
className: string,
|
|
426
|
+
|
|
427
|
+
/** type of Popup, corresponding to the color of header, button */
|
|
428
|
+
type: oneOf(['info', 'success', 'warning', 'danger', 'yesno']),
|
|
429
|
+
|
|
430
|
+
/** label of confirm button */
|
|
431
|
+
yesText: string,
|
|
432
|
+
|
|
433
|
+
/** label of cancel button */
|
|
434
|
+
noText: string,
|
|
435
|
+
|
|
436
|
+
/** the props of confirm button */
|
|
437
|
+
confirmProps: object,
|
|
438
|
+
|
|
439
|
+
/** the props of cancel button */
|
|
440
|
+
cancelProps: object,
|
|
441
|
+
|
|
442
|
+
/** the function will run when click on confirm button */
|
|
443
|
+
onConfirm: func,
|
|
444
|
+
|
|
445
|
+
/** the function will run when click on cancel button */
|
|
446
|
+
onCancel: func,
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* named ref: get ref of Popup component, insist:<br />
|
|
450
|
+
* * element<br />
|
|
451
|
+
* * show: the method to show Popup (ref.current.show(options, callback))<br />
|
|
452
|
+
* + options: {type, title, icon, yesNo, description, confirmProps, cancelProps, onCancel, onConfirm}<br />
|
|
453
|
+
* + callback: the function will run after click on button (callback(true) with confirm Button and callback(false) with cancel Button). Alternate both onCancel, onConfirm methods of options<br />
|
|
454
|
+
* * close: the method to close Popup<br />
|
|
455
|
+
*/
|
|
456
|
+
reference: oneOfType([func, shape({
|
|
457
|
+
current: instanceOf(elementType)
|
|
458
|
+
})])
|
|
459
|
+
};
|
|
460
|
+
export default Popup;
|