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,119 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
import { memo, useEffect, useMemo, useRef, forwardRef } from 'react';
|
|
3
|
+
import { string, number, bool, node, oneOfType, func } from 'prop-types';
|
|
4
|
+
import { css } from '@emotion/core';
|
|
5
|
+
import { renderHTML } from '../../utils';
|
|
6
|
+
import theme from '../../theme/settings';
|
|
7
|
+
const Paper = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
8
|
+
width,
|
|
9
|
+
height,
|
|
10
|
+
mapping,
|
|
11
|
+
bg,
|
|
12
|
+
className,
|
|
13
|
+
square,
|
|
14
|
+
scrollAble,
|
|
15
|
+
refs,
|
|
16
|
+
children,
|
|
17
|
+
...props
|
|
18
|
+
}, ref) => {
|
|
19
|
+
if (!ref) {
|
|
20
|
+
ref = useRef(null);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const PaperRoot = css`
|
|
24
|
+
width: ${isNaN(width) ? width : width + 'px'};
|
|
25
|
+
height: ${isNaN(height) ? height : height + 'px'};
|
|
26
|
+
border: 1px solid ${theme.colors.border};
|
|
27
|
+
border-radius: 4px;
|
|
28
|
+
background-color: ${bg};
|
|
29
|
+
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
|
|
30
|
+
&.square {
|
|
31
|
+
border-radius: 0;
|
|
32
|
+
}
|
|
33
|
+
&.scroll-able {
|
|
34
|
+
max-height: ${isNaN(height) ? height : height + 'px'};
|
|
35
|
+
overflow-y: auto;
|
|
36
|
+
&::-webkit-scrollbar {
|
|
37
|
+
width: 8px;
|
|
38
|
+
background-color: #FFF !important;
|
|
39
|
+
border-radius: 4px;
|
|
40
|
+
}
|
|
41
|
+
&::-webkit-scrollbar-thumb {
|
|
42
|
+
border-radius: 4px;
|
|
43
|
+
mix-blend-mode: normal;
|
|
44
|
+
background-color: ${theme.colors.bgDisabled} !important;
|
|
45
|
+
background-clip: content-box;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
refs && refs(ref);
|
|
51
|
+
}, []);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (square) {
|
|
54
|
+
ref.current.classList.add('square');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return () => {
|
|
58
|
+
if (square && ref.current) {
|
|
59
|
+
ref.current.classList.remove('square');
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}, [square]);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (scrollAble && !ref.current.classList.contains('scroll-able')) {
|
|
65
|
+
ref.current.classList.add('scroll-able');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return () => {
|
|
69
|
+
if (scrollAble && ref.current) {
|
|
70
|
+
ref.current.classList.remove('scroll-able');
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}, [scrollAble]);
|
|
74
|
+
const PaperView = useMemo(() => renderHTML(children, mapping, {
|
|
75
|
+
ref,
|
|
76
|
+
css: PaperRoot,
|
|
77
|
+
className: [className, scrollAble ? 'scroll-able' : ''].join(' ').trim(),
|
|
78
|
+
...props
|
|
79
|
+
}), [children]);
|
|
80
|
+
return PaperView;
|
|
81
|
+
}));
|
|
82
|
+
Paper.defaultProps = {
|
|
83
|
+
width: 240,
|
|
84
|
+
height: 240,
|
|
85
|
+
mapping: 'div',
|
|
86
|
+
bg: 'white',
|
|
87
|
+
className: '',
|
|
88
|
+
square: false,
|
|
89
|
+
scrollAble: false
|
|
90
|
+
};
|
|
91
|
+
Paper.propTypes = {
|
|
92
|
+
/** the width of Paper */
|
|
93
|
+
width: oneOfType([string, number]),
|
|
94
|
+
|
|
95
|
+
/** the height of Paper */
|
|
96
|
+
height: oneOfType([string, number]),
|
|
97
|
+
|
|
98
|
+
/** html tag to render */
|
|
99
|
+
mapping: string,
|
|
100
|
+
|
|
101
|
+
/** background color of Paper */
|
|
102
|
+
bg: string,
|
|
103
|
+
|
|
104
|
+
/** className of Paper component */
|
|
105
|
+
className: string,
|
|
106
|
+
|
|
107
|
+
/** rounded Paper if false */
|
|
108
|
+
square: bool,
|
|
109
|
+
|
|
110
|
+
/** Allow to roll if the height exceeds the limit */
|
|
111
|
+
scrollAble: bool,
|
|
112
|
+
|
|
113
|
+
/** the function to get ref of Paper */
|
|
114
|
+
refs: func,
|
|
115
|
+
|
|
116
|
+
/** content to display in Paper */
|
|
117
|
+
children: node
|
|
118
|
+
};
|
|
119
|
+
export default Paper;
|
|
@@ -0,0 +1,417 @@
|
|
|
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, useState, useEffect, useMemo, useRef, forwardRef, useImperativeHandle, Fragment } from 'react';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { jsx, css } from '@emotion/core';
|
|
10
|
+
import { randomString } from '../../utils';
|
|
11
|
+
import theme from '../../theme/settings';
|
|
12
|
+
const timer = {};
|
|
13
|
+
const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
14
|
+
open,
|
|
15
|
+
pressESCToClose,
|
|
16
|
+
removeAfterClose,
|
|
17
|
+
fullScreen,
|
|
18
|
+
arrow,
|
|
19
|
+
style,
|
|
20
|
+
anchor,
|
|
21
|
+
anchorOrigin,
|
|
22
|
+
transformOrigin,
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
bgColor,
|
|
26
|
+
refs,
|
|
27
|
+
onClose,
|
|
28
|
+
zIndex,
|
|
29
|
+
children,
|
|
30
|
+
...props
|
|
31
|
+
}, reference) => {
|
|
32
|
+
const ref = useRef(null);
|
|
33
|
+
const [unique] = useState(randomString(6, {
|
|
34
|
+
allowNumber: false,
|
|
35
|
+
allowSymbol: false
|
|
36
|
+
}));
|
|
37
|
+
const [openState, setOpenState] = useState(open);
|
|
38
|
+
const [element, setElement] = useState(null);
|
|
39
|
+
const PopoverContainer = css`
|
|
40
|
+
display: flex;
|
|
41
|
+
position: fixed;
|
|
42
|
+
width: ${isNaN(width) ? width : width + 'px'};
|
|
43
|
+
max-width: 100%;
|
|
44
|
+
max-height: 100%;
|
|
45
|
+
height: ${isNaN(height) ? height : height + 'px'};
|
|
46
|
+
z-index: 1000;
|
|
47
|
+
transform: scale(0);
|
|
48
|
+
transition: transform 0.2s linear;
|
|
49
|
+
pointer-events: initial;
|
|
50
|
+
&.open {
|
|
51
|
+
transform: scale(1);
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
const PopoverRoot = css`
|
|
55
|
+
display: block;
|
|
56
|
+
position: relative;
|
|
57
|
+
background-color: ${bgColor};
|
|
58
|
+
font-family: ${theme.typography.fontFamily};
|
|
59
|
+
width: 100%;
|
|
60
|
+
height: 100%;
|
|
61
|
+
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
62
|
+
border-radius: 4px;
|
|
63
|
+
`;
|
|
64
|
+
const PopoverArrow = css`
|
|
65
|
+
display: block;
|
|
66
|
+
position: absolute;
|
|
67
|
+
height: 0;
|
|
68
|
+
width: 0;
|
|
69
|
+
border-left: 6px solid transparent;
|
|
70
|
+
border-right: 6px solid transparent;
|
|
71
|
+
border-bottom: 6px solid ${bgColor};
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const onClosePopover = byOpenProps => {
|
|
75
|
+
const popovers = document.querySelectorAll('.DGN-UI-Portal');
|
|
76
|
+
|
|
77
|
+
if (popovers && popovers.length > 1 && Array.from(popovers)[popovers.length - 1] && !Array.from(popovers)[popovers.length - 1].contains(ref.current)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!byOpenProps && onClose) onClose();
|
|
82
|
+
|
|
83
|
+
if (ref.current) {
|
|
84
|
+
var _ref$current;
|
|
85
|
+
|
|
86
|
+
setOpenState(false);
|
|
87
|
+
if (ref !== null && ref !== void 0 && (_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.classList) ref.current.classList.remove('open');
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const pressESCHandler = event => {
|
|
92
|
+
if (event.key === 'Escape') {
|
|
93
|
+
onClosePopover();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const clickOutOfPopover = event => {
|
|
100
|
+
if (!ref.current) {
|
|
101
|
+
document.removeEventListener('click', clickOutOfPopover);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!ref.current.contains(event.target) && (!fullScreen || ref.current.parentNode.contains(event.target)) && ref.current.classList.contains('open')) {
|
|
106
|
+
onClosePopover();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
|
|
111
|
+
if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
|
|
112
|
+
translate.left = -6;
|
|
113
|
+
translate.transform = 'rotateZ(270deg)';
|
|
114
|
+
return 'left';
|
|
115
|
+
} else if (anchorOrigin.horizontal === 'left' && transformOrigin.horizontal === 'right') {
|
|
116
|
+
translate.left = 6;
|
|
117
|
+
translate.transform = 'rotateZ(90deg)';
|
|
118
|
+
return 'right';
|
|
119
|
+
} else if (transformOrigin.vertical === 'bottom') {
|
|
120
|
+
translate.top = 6;
|
|
121
|
+
translate.transform = 'rotateZ(180deg)';
|
|
122
|
+
return 'bottom';
|
|
123
|
+
} else {
|
|
124
|
+
translate.top = -6;
|
|
125
|
+
return 'top';
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const calPosition = (position, originBounding) => {
|
|
130
|
+
const {
|
|
131
|
+
width,
|
|
132
|
+
height
|
|
133
|
+
} = originBounding;
|
|
134
|
+
|
|
135
|
+
switch (position) {
|
|
136
|
+
case 'bottom':
|
|
137
|
+
case 'right':
|
|
138
|
+
{
|
|
139
|
+
return [height, width];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
case 'center':
|
|
143
|
+
{
|
|
144
|
+
return [height / 2, width / 2];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
default:
|
|
148
|
+
return [0, 0];
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const updatePositionPopover = (el = null) => {
|
|
153
|
+
setElement(el instanceof Element ? el : null);
|
|
154
|
+
|
|
155
|
+
if (!ref.current) {
|
|
156
|
+
window.removeEventListener('scroll', updatePositionPopover);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let top = 0,
|
|
161
|
+
left = 0,
|
|
162
|
+
vertical = 0,
|
|
163
|
+
horizontal = 0,
|
|
164
|
+
arrowPosition = {},
|
|
165
|
+
translate = {
|
|
166
|
+
left: 0,
|
|
167
|
+
top: 0
|
|
168
|
+
},
|
|
169
|
+
anchorBounding = null,
|
|
170
|
+
aPosition = '';
|
|
171
|
+
|
|
172
|
+
if (transformOrigin === 'center') {
|
|
173
|
+
transformOrigin = {
|
|
174
|
+
vertical: 'center',
|
|
175
|
+
horizontal: 'center'
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (element || anchor) {
|
|
180
|
+
if (element) anchor = element;else if (anchor.current) {
|
|
181
|
+
anchor = anchor.current;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (anchorOrigin === 'center') {
|
|
185
|
+
anchorOrigin = {
|
|
186
|
+
vertical: 'center',
|
|
187
|
+
horizontal: 'center'
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (arrow && anchorOrigin.vertical !== anchorOrigin.horizontal && transformOrigin.vertical !== transformOrigin.horizontal) {
|
|
192
|
+
aPosition = getArrowPosition(anchorOrigin, transformOrigin, translate);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
anchorBounding = anchor.getBoundingClientRect();
|
|
196
|
+
vertical = anchorBounding.y + calPosition(anchorOrigin.vertical, anchorBounding)[0] - translate.top;
|
|
197
|
+
horizontal = anchorBounding.x + calPosition(anchorOrigin.horizontal, anchorBounding)[1] - translate.left;
|
|
198
|
+
} // Position's transform
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
const offsetHeight = ref.current.offsetHeight;
|
|
202
|
+
const offsetWidth = ref.current.offsetWidth;
|
|
203
|
+
|
|
204
|
+
switch (transformOrigin.vertical) {
|
|
205
|
+
case 'center':
|
|
206
|
+
top = vertical - offsetHeight / 2;
|
|
207
|
+
break;
|
|
208
|
+
|
|
209
|
+
case 'bottom':
|
|
210
|
+
top = vertical - offsetHeight;
|
|
211
|
+
break;
|
|
212
|
+
|
|
213
|
+
default:
|
|
214
|
+
top = vertical;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
switch (transformOrigin.horizontal) {
|
|
218
|
+
case 'center':
|
|
219
|
+
left = horizontal - offsetWidth / 2;
|
|
220
|
+
break;
|
|
221
|
+
|
|
222
|
+
case 'right':
|
|
223
|
+
left = horizontal - offsetWidth;
|
|
224
|
+
break;
|
|
225
|
+
|
|
226
|
+
default:
|
|
227
|
+
left = horizontal;
|
|
228
|
+
} // Reset position if the element overflow window screen size
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
if (top < 0) {
|
|
232
|
+
top = 0;
|
|
233
|
+
} else if (top + offsetHeight > window.innerHeight) {
|
|
234
|
+
top = window.innerHeight - offsetHeight;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (left < 0) {
|
|
238
|
+
left = 0;
|
|
239
|
+
} else if (left + offsetWidth > window.innerWidth) {
|
|
240
|
+
left = window.innerWidth - offsetWidth;
|
|
241
|
+
} // Get arrow's position
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
if (arrow && translate) {
|
|
245
|
+
switch (aPosition) {
|
|
246
|
+
case 'top':
|
|
247
|
+
case 'bottom':
|
|
248
|
+
arrowPosition.left = anchorBounding.width / 2 + anchorBounding.left - left - 6 + 'px';
|
|
249
|
+
arrowPosition[aPosition] = `-6px`;
|
|
250
|
+
break;
|
|
251
|
+
|
|
252
|
+
case 'left':
|
|
253
|
+
case 'right':
|
|
254
|
+
arrowPosition.top = Math.max(4, anchorBounding.height / 2 + anchorBounding.top - top - 2 * Math.sqrt(2)) + 'px';
|
|
255
|
+
arrowPosition[aPosition] = `-9px`;
|
|
256
|
+
break;
|
|
257
|
+
|
|
258
|
+
default:
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
Object.assign(ref.current.querySelector(`.css-${PopoverArrow.name}`).style, arrowPosition, {
|
|
263
|
+
transform: translate.transform
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
ref.current.style.top = top + 'px';
|
|
268
|
+
ref.current.style.left = left + 'px';
|
|
269
|
+
ref.current.style.transformOrigin = `${transformOrigin.horizontal || 'left'} ${transformOrigin.vertical || 'top'}`;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
if (refs) refs(ref);
|
|
274
|
+
return () => {
|
|
275
|
+
if (pressESCToClose) {
|
|
276
|
+
document.removeEventListener('keydown', pressESCHandler);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
document.removeEventListener('click', clickOutOfPopover);
|
|
280
|
+
window.removeEventListener('scroll', updatePositionPopover);
|
|
281
|
+
|
|
282
|
+
if (timer[unique]) {
|
|
283
|
+
clearTimeout(timer[unique]);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}, []);
|
|
287
|
+
useEffect(() => {
|
|
288
|
+
if (open) {
|
|
289
|
+
if (timer[unique]) {
|
|
290
|
+
clearTimeout(timer[unique]);
|
|
291
|
+
|
|
292
|
+
if (ref.current) {
|
|
293
|
+
ref.current.classList.add('open');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
setOpenState(open);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return () => {
|
|
301
|
+
if (open && ref.current) {
|
|
302
|
+
timer[unique] = setTimeout(() => {
|
|
303
|
+
setOpenState(false);
|
|
304
|
+
}, 500);
|
|
305
|
+
onClosePopover(true);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}, [open]);
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
if (openState && ref.current) {
|
|
311
|
+
// Position's anchor
|
|
312
|
+
updatePositionPopover();
|
|
313
|
+
ref.current.classList.add('open');
|
|
314
|
+
|
|
315
|
+
if (fullScreen && !removeAfterClose) {
|
|
316
|
+
ref.current.parentNode.style.pointerEvents = 'initial';
|
|
317
|
+
} // Allow press ESC to close popup
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
if (pressESCToClose) {
|
|
321
|
+
document.addEventListener('keydown', pressESCHandler);
|
|
322
|
+
} // Click out popover to close popover
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
document.addEventListener('click', clickOutOfPopover); // Update position popover on scroll
|
|
326
|
+
|
|
327
|
+
window.addEventListener('scroll', updatePositionPopover);
|
|
328
|
+
return () => {
|
|
329
|
+
if (pressESCToClose) {
|
|
330
|
+
document.removeEventListener('keydown', pressESCHandler);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
document.removeEventListener('click', clickOutOfPopover);
|
|
334
|
+
window.removeEventListener('scroll', updatePositionPopover);
|
|
335
|
+
};
|
|
336
|
+
} else if (ref.current) {
|
|
337
|
+
if (fullScreen && !removeAfterClose) {
|
|
338
|
+
ref.current.parentNode.style.pointerEvents = 'none';
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}, [openState]);
|
|
342
|
+
useImperativeHandle(reference, () => {
|
|
343
|
+
const currentRef = ref.current || {};
|
|
344
|
+
|
|
345
|
+
currentRef.show = () => setOpenState(true);
|
|
346
|
+
|
|
347
|
+
currentRef.close = () => onClosePopover();
|
|
348
|
+
|
|
349
|
+
currentRef.setPosition = el => updatePositionPopover(el);
|
|
350
|
+
|
|
351
|
+
return currentRef;
|
|
352
|
+
});
|
|
353
|
+
const PopoverView = useMemo(() => {
|
|
354
|
+
if (openState || !removeAfterClose) {
|
|
355
|
+
const node = jsx("div", {
|
|
356
|
+
className: 'DGN-UI-Portal DGN-UI-Popover',
|
|
357
|
+
style: {
|
|
358
|
+
position: 'fixed',
|
|
359
|
+
zIndex,
|
|
360
|
+
inset: 0,
|
|
361
|
+
pointerEvents: fullScreen ? 'initial' : 'none'
|
|
362
|
+
}
|
|
363
|
+
}, jsx("div", _extends({
|
|
364
|
+
css: PopoverContainer,
|
|
365
|
+
ref: ref
|
|
366
|
+
}, props), jsx("div", {
|
|
367
|
+
css: PopoverRoot,
|
|
368
|
+
style: style
|
|
369
|
+
}, arrow && jsx("span", {
|
|
370
|
+
css: PopoverArrow
|
|
371
|
+
}), children)));
|
|
372
|
+
return /*#__PURE__*/createPortal(node, document.body);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return null;
|
|
376
|
+
});
|
|
377
|
+
return PopoverView;
|
|
378
|
+
}));
|
|
379
|
+
Popover.defaultProps = {
|
|
380
|
+
open: false,
|
|
381
|
+
pressESCToClose: true,
|
|
382
|
+
removeAfterClose: true,
|
|
383
|
+
fullScreen: true,
|
|
384
|
+
arrow: false,
|
|
385
|
+
width: 150,
|
|
386
|
+
height: 'auto',
|
|
387
|
+
bgColor: '#FFF',
|
|
388
|
+
zIndex: 9001,
|
|
389
|
+
anchorOrigin: {
|
|
390
|
+
vertical: 'bottom',
|
|
391
|
+
horizontal: 'center'
|
|
392
|
+
},
|
|
393
|
+
transformOrigin: {
|
|
394
|
+
vertical: 'top',
|
|
395
|
+
horizontal: 'center'
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
Popover.propTypes = {
|
|
399
|
+
open: PropTypes.bool,
|
|
400
|
+
arrow: PropTypes.bool,
|
|
401
|
+
pressESCToClose: PropTypes.bool,
|
|
402
|
+
removeAfterClose: PropTypes.bool,
|
|
403
|
+
bgColor: PropTypes.string,
|
|
404
|
+
style: PropTypes.object,
|
|
405
|
+
anchor: PropTypes.object,
|
|
406
|
+
anchorOrigin: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
407
|
+
// {vertical: 'top', horizontal: 'left'}
|
|
408
|
+
transformOrigin: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
409
|
+
// {vertical: 'bottom', horizontal: 'right'}
|
|
410
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
411
|
+
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
412
|
+
zIndex: PropTypes.number,
|
|
413
|
+
refs: PropTypes.func,
|
|
414
|
+
onClose: PropTypes.func,
|
|
415
|
+
children: PropTypes.node
|
|
416
|
+
};
|
|
417
|
+
export default Popover;
|