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,264 @@
|
|
|
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 } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import { info1, info9, success1, success9, warning1, warning9, danger1, danger9 } from '../../styles/colors';
|
|
10
|
+
import theme from '../../theme/settings';
|
|
11
|
+
import { Close, Archive, Info, Warning, Block } from '../../icons';
|
|
12
|
+
import LinearProgress from '../progress/linear';
|
|
13
|
+
const icons = {
|
|
14
|
+
primary: jsx(Info, null),
|
|
15
|
+
success: jsx(Archive, null),
|
|
16
|
+
warning: jsx(Warning, null),
|
|
17
|
+
danger: jsx(Block, {
|
|
18
|
+
color: 'currentColor'
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
const colors = {
|
|
22
|
+
color: {
|
|
23
|
+
primary: theme.colors.info,
|
|
24
|
+
success: theme.colors.success,
|
|
25
|
+
warning: theme.colors.warning,
|
|
26
|
+
danger: theme.colors.danger
|
|
27
|
+
},
|
|
28
|
+
backgroundColor: {
|
|
29
|
+
primary: info1,
|
|
30
|
+
success: success1,
|
|
31
|
+
warning: warning1,
|
|
32
|
+
danger: danger1
|
|
33
|
+
},
|
|
34
|
+
borderColor: {
|
|
35
|
+
primary: theme.colors.info,
|
|
36
|
+
success: theme.colors.success,
|
|
37
|
+
warning: theme.colors.warning,
|
|
38
|
+
danger: theme.colors.danger
|
|
39
|
+
},
|
|
40
|
+
hover: {
|
|
41
|
+
primary: info9,
|
|
42
|
+
success: success9,
|
|
43
|
+
warning: warning9,
|
|
44
|
+
danger: danger9
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const Alert = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
48
|
+
color,
|
|
49
|
+
text,
|
|
50
|
+
secondary,
|
|
51
|
+
size,
|
|
52
|
+
className,
|
|
53
|
+
progressing,
|
|
54
|
+
autoDisappear,
|
|
55
|
+
duration,
|
|
56
|
+
clearAble,
|
|
57
|
+
refs,
|
|
58
|
+
onClose,
|
|
59
|
+
usedByNotify,
|
|
60
|
+
children,
|
|
61
|
+
...props
|
|
62
|
+
}, ref) => {
|
|
63
|
+
const clearIconRef = useRef(null);
|
|
64
|
+
const [percentState, setPercentState] = useState(100);
|
|
65
|
+
const AlertContainer = css`
|
|
66
|
+
position: relative;
|
|
67
|
+
display: block;
|
|
68
|
+
margin-bottom: 1rem;
|
|
69
|
+
transition: opacity ${progressing ? duration / 2 + 1 : duration * 1}s ease ${progressing ? duration / 2 : 0}s;
|
|
70
|
+
pointer-events: auto;
|
|
71
|
+
z-index: 9001;
|
|
72
|
+
`;
|
|
73
|
+
const AlertInfo = css`
|
|
74
|
+
display: flex;
|
|
75
|
+
position: relative;
|
|
76
|
+
width: 100%;
|
|
77
|
+
min-width: 333px;
|
|
78
|
+
border: 1px solid ${colors.borderColor[color]};
|
|
79
|
+
color: ${colors.color[color]};
|
|
80
|
+
background-color: ${colors.backgroundColor[color]};
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
border-radius: 4px;
|
|
83
|
+
padding: 8px 16px;
|
|
84
|
+
opacity: 1;
|
|
85
|
+
word-break: break-word;
|
|
86
|
+
`;
|
|
87
|
+
const AlertIcon = css`
|
|
88
|
+
display: inherit;
|
|
89
|
+
margin-right: 10px;
|
|
90
|
+
max-width: ${/^(small|sm)$/i.test(size) ? 16 : 24}px;
|
|
91
|
+
max-height: ${/^(small|sm)$/i.test(size) ? 16 : 24}px;
|
|
92
|
+
`;
|
|
93
|
+
const AlertText = css`
|
|
94
|
+
display: block;
|
|
95
|
+
margin-right: 10px;
|
|
96
|
+
`;
|
|
97
|
+
const AlertPrimary = css`
|
|
98
|
+
display: flex;
|
|
99
|
+
position: relative;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: flex-start;
|
|
102
|
+
font-family: ${theme.typography.fontFamily};
|
|
103
|
+
font-style: normal;
|
|
104
|
+
font-weight: 500;
|
|
105
|
+
font-size: ${/^(small|sm)$/i.test(size) ? 14 : 16}px;
|
|
106
|
+
line-height: ${/^(small|sm)$/i.test(size) ? 16 : 24}px;
|
|
107
|
+
user-select: none;
|
|
108
|
+
`;
|
|
109
|
+
const AlertSecondary = css`
|
|
110
|
+
display: block;
|
|
111
|
+
margin-right: 10px;
|
|
112
|
+
font-family: ${theme.typography.fontFamily};
|
|
113
|
+
font-style: normal;
|
|
114
|
+
font-weight: 500;
|
|
115
|
+
font-size: ${/^(small|sm)$/i.test(size) ? 12 : 14}px;
|
|
116
|
+
line-height: 16px;
|
|
117
|
+
user-select: none;
|
|
118
|
+
`;
|
|
119
|
+
const AlertClearIcon = css`
|
|
120
|
+
display: inherit;
|
|
121
|
+
margin-left: auto;
|
|
122
|
+
color: ${colors.color[color]};
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
max-width: ${/^(small|sm)$/i.test(size) ? 16 : 24}px;
|
|
125
|
+
max-height: ${/^(small|sm)$/i.test(size) ? 16 : 24}px;
|
|
126
|
+
&:hover {
|
|
127
|
+
color: ${colors.hover[color]};
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
const linearProgressStyle = css`
|
|
131
|
+
display: block;
|
|
132
|
+
position: relative;
|
|
133
|
+
margin-top: ${/^(small|sm)$/i.test(size) ? 2 : 6}px;
|
|
134
|
+
padding: 0 5px;
|
|
135
|
+
`;
|
|
136
|
+
|
|
137
|
+
const onClearAlert = (el, urgency) => {
|
|
138
|
+
var _el$parentNode;
|
|
139
|
+
|
|
140
|
+
if (!el) return;
|
|
141
|
+
el.style.pointerEvent = 'none';
|
|
142
|
+
const alertNode = el === null || el === void 0 ? void 0 : (_el$parentNode = el.parentNode) === null || _el$parentNode === void 0 ? void 0 : _el$parentNode.parentNode;
|
|
143
|
+
|
|
144
|
+
if (alertNode) {
|
|
145
|
+
if (urgency) {
|
|
146
|
+
alertNode.style.transition = `opacity 1s ease`;
|
|
147
|
+
alertNode.style.opacity = 1;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
alertNode.style.opacity = 0;
|
|
152
|
+
}, 0);
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
if (onClose) onClose(alertNode);
|
|
155
|
+
alertNode.remove();
|
|
156
|
+
}, !urgency && progressing ? duration * 1000 + 300 : duration * 1000);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const AlertView = useMemo(() => jsx("div", _extends({
|
|
161
|
+
css: AlertInfo,
|
|
162
|
+
className: ['DGN-UI-Alert', className].join(' ').trim()
|
|
163
|
+
}, props), jsx("span", {
|
|
164
|
+
css: AlertIcon
|
|
165
|
+
}, icons[color]), jsx("span", {
|
|
166
|
+
css: AlertText
|
|
167
|
+
}, jsx("span", {
|
|
168
|
+
css: AlertPrimary
|
|
169
|
+
}, children ? typeof children === 'string' ? children : jsx("children", null) : text), secondary && jsx("span", {
|
|
170
|
+
css: AlertSecondary
|
|
171
|
+
}, secondary)), jsx("span", {
|
|
172
|
+
css: AlertClearIcon,
|
|
173
|
+
onClick: e => onClearAlert(e.currentTarget, true),
|
|
174
|
+
ref: clearIconRef
|
|
175
|
+
}, clearAble ? jsx(Close, {
|
|
176
|
+
color: 'currentColor',
|
|
177
|
+
height: /small/.test(size) ? 16 : 24,
|
|
178
|
+
width: /small/.test(size) ? 16 : 24,
|
|
179
|
+
viewBox: true
|
|
180
|
+
}) : null)), [color, text, clearAble]);
|
|
181
|
+
const LinearView = useMemo(() => {
|
|
182
|
+
return progressing ? jsx("span", {
|
|
183
|
+
css: linearProgressStyle
|
|
184
|
+
}, jsx(LinearProgress, {
|
|
185
|
+
determinate: true,
|
|
186
|
+
background: 'transparent',
|
|
187
|
+
color: colors.color[color],
|
|
188
|
+
percent: percentState,
|
|
189
|
+
duration: duration,
|
|
190
|
+
height: /^(small|sm)$/i.test(size) ? 2 : 4,
|
|
191
|
+
style: {
|
|
192
|
+
boxShadow: 'none'
|
|
193
|
+
}
|
|
194
|
+
})) : null;
|
|
195
|
+
}, [percentState]);
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (refs) refs(ref);
|
|
198
|
+
|
|
199
|
+
if (progressing) {
|
|
200
|
+
setTimeout(() => {
|
|
201
|
+
setPercentState(0);
|
|
202
|
+
}, 1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (autoDisappear) {
|
|
206
|
+
onClearAlert(clearIconRef.current);
|
|
207
|
+
}
|
|
208
|
+
}, []);
|
|
209
|
+
return jsx("div", {
|
|
210
|
+
css: AlertContainer,
|
|
211
|
+
ref: ref
|
|
212
|
+
}, AlertView, LinearView);
|
|
213
|
+
}));
|
|
214
|
+
Alert.defaultProps = {
|
|
215
|
+
color: 'primary',
|
|
216
|
+
size: 'medium',
|
|
217
|
+
className: '',
|
|
218
|
+
clearAble: true,
|
|
219
|
+
progressing: false,
|
|
220
|
+
usedByNotify: false,
|
|
221
|
+
autoDisappear: false,
|
|
222
|
+
duration: 5
|
|
223
|
+
};
|
|
224
|
+
Alert.propTypes = {
|
|
225
|
+
/** color is a string, it's background color of Alert */
|
|
226
|
+
color: PropTypes.oneOf(['primary', 'success', 'warning', 'danger']),
|
|
227
|
+
|
|
228
|
+
/** class for Alert component */
|
|
229
|
+
className: PropTypes.string,
|
|
230
|
+
|
|
231
|
+
/** The text to show in alert */
|
|
232
|
+
text: PropTypes.string,
|
|
233
|
+
|
|
234
|
+
/** The secondary text to show in alert (under primary) */
|
|
235
|
+
secondary: PropTypes.string,
|
|
236
|
+
|
|
237
|
+
/** size is a string, size of Alert */
|
|
238
|
+
size: PropTypes.oneOf(['small', 'medium']),
|
|
239
|
+
|
|
240
|
+
/** Display clear icon to close alert */
|
|
241
|
+
clearAble: PropTypes.bool,
|
|
242
|
+
|
|
243
|
+
/** use to display linear progress in duration time show Alert */
|
|
244
|
+
progressing: PropTypes.bool,
|
|
245
|
+
|
|
246
|
+
/** Automatically remove the Alert component after the timer ends (duration) */
|
|
247
|
+
autoDisappear: PropTypes.bool,
|
|
248
|
+
|
|
249
|
+
/** The amount of time the alert is displayed. The unit is the second */
|
|
250
|
+
duration: PropTypes.number,
|
|
251
|
+
|
|
252
|
+
/** refs is a function, use to get ref of Alert component */
|
|
253
|
+
refs: PropTypes.func,
|
|
254
|
+
|
|
255
|
+
/** The function will run after remove an Alert component */
|
|
256
|
+
onClose: PropTypes.func,
|
|
257
|
+
|
|
258
|
+
/** The element to display in alert like text props (priority) */
|
|
259
|
+
children: PropTypes.node,
|
|
260
|
+
|
|
261
|
+
/** any props else */
|
|
262
|
+
props: PropTypes.any
|
|
263
|
+
};
|
|
264
|
+
export default Alert;
|
|
@@ -0,0 +1,192 @@
|
|
|
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
|
+
import React, { memo, useEffect, forwardRef, useImperativeHandle } from 'react';
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import Alert from './';
|
|
7
|
+
import { randomString } from '../../utils';
|
|
8
|
+
const positions = {
|
|
9
|
+
general: {
|
|
10
|
+
position: 'fixed',
|
|
11
|
+
zIndex: 9002,
|
|
12
|
+
backgroundColor: 'transparent',
|
|
13
|
+
pointerEvents: 'none'
|
|
14
|
+
},
|
|
15
|
+
vertical: {
|
|
16
|
+
top: {
|
|
17
|
+
top: '15px'
|
|
18
|
+
},
|
|
19
|
+
center: {
|
|
20
|
+
top: '50%',
|
|
21
|
+
transform: 'translateY(-50%)'
|
|
22
|
+
},
|
|
23
|
+
bottom: {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
flexDirection: 'column-reverse',
|
|
26
|
+
bottom: 0
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
horizontal: {
|
|
30
|
+
left: {
|
|
31
|
+
left: '15px'
|
|
32
|
+
},
|
|
33
|
+
center: {
|
|
34
|
+
left: '50%',
|
|
35
|
+
transform: 'translateX(-50%)'
|
|
36
|
+
},
|
|
37
|
+
right: {
|
|
38
|
+
right: '15px'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const str = randomString(6, {
|
|
43
|
+
allowSymbol: false
|
|
44
|
+
});
|
|
45
|
+
const AlertNotify = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
46
|
+
position,
|
|
47
|
+
getAddNotify,
|
|
48
|
+
width,
|
|
49
|
+
maxWidth,
|
|
50
|
+
height,
|
|
51
|
+
maxHeight,
|
|
52
|
+
...props
|
|
53
|
+
}, reference) => {
|
|
54
|
+
// Return true if it's a new position
|
|
55
|
+
const checkPosition = pos => {
|
|
56
|
+
if (pos === position || pos.vertical === (position.vertical || 'bottom') && pos.horizontal === (position.horizontal || 'center')) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (pos === 'center') {
|
|
61
|
+
pos = {
|
|
62
|
+
vertical: 'center',
|
|
63
|
+
horizontal: 'center'
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (pos.vertical && pos.horizontal && /^top|center|bottom$/.test(pos.vertical) && /^left|center|right$/.test(pos.horizontal)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return false;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const renderNotifyAlertPosition = (pos, className) => {
|
|
75
|
+
if (pos === 'center') {
|
|
76
|
+
pos = {
|
|
77
|
+
vertical: 'center',
|
|
78
|
+
horizontal: 'center'
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const el = document.createElement('div');
|
|
83
|
+
el.className = `Notify-Alert-${className || pos.vertical + '-' + pos.horizontal}`;
|
|
84
|
+
Object.assign(el.style, positions.general, positions.vertical[pos.vertical || 'bottom'], positions.horizontal[pos.horizontal || 'center'], pos.vertical === pos.horizontal ? {
|
|
85
|
+
transform: 'translate(-50%, -50%)'
|
|
86
|
+
} : {}, {
|
|
87
|
+
width,
|
|
88
|
+
maxWidth,
|
|
89
|
+
height,
|
|
90
|
+
maxHeight
|
|
91
|
+
});
|
|
92
|
+
document.body.appendChild(el);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const onClose = (e, removePosition) => {
|
|
96
|
+
var _e$parentNode;
|
|
97
|
+
|
|
98
|
+
(_e$parentNode = e.parentNode) === null || _e$parentNode === void 0 ? void 0 : _e$parentNode.remove();
|
|
99
|
+
|
|
100
|
+
if (removePosition) {
|
|
101
|
+
const node = document.querySelector(`div[class^="Notify-Alert-${removePosition.vertical}-${removePosition.horizontal}"]`);
|
|
102
|
+
|
|
103
|
+
if (node && node.childNodes && !node.childNodes.length) {
|
|
104
|
+
node.remove();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const onAddAlert = (message, {
|
|
110
|
+
position,
|
|
111
|
+
...options
|
|
112
|
+
} = {}) => {
|
|
113
|
+
options = typeof options === 'object' ? options : {};
|
|
114
|
+
const el = document.createElement('div');
|
|
115
|
+
el.className = `Notify-Alert-${str}-item`;
|
|
116
|
+
|
|
117
|
+
if (position && checkPosition(position)) {
|
|
118
|
+
if (!document.querySelector(`div[class^="Notify-Alert-${position.vertical}-${position.horizontal}"]`)) {
|
|
119
|
+
renderNotifyAlertPosition(position);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(Alert, _extends({
|
|
123
|
+
onClose: e => onClose(e, position),
|
|
124
|
+
usedByNotify: true
|
|
125
|
+
}, props, options), message), document.querySelector(`div[class^="Notify-Alert-${position.vertical}-${position.horizontal}"]`).appendChild(el));
|
|
126
|
+
} else {
|
|
127
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(Alert, _extends({
|
|
128
|
+
onClose: onClose,
|
|
129
|
+
usedByNotify: true
|
|
130
|
+
}, props, options), message), document.querySelector(`div[class^="Notify-Alert-"]`).appendChild(el));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (getAddNotify && typeof getAddNotify === 'function') getAddNotify(onAddAlert);
|
|
136
|
+
}, [props]);
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
renderNotifyAlertPosition(position, str);
|
|
139
|
+
return () => {
|
|
140
|
+
document.querySelector(`div[class^="Notify-Alert-${str}"]`).remove();
|
|
141
|
+
};
|
|
142
|
+
}, [position, width, maxWidth, height, maxHeight]);
|
|
143
|
+
useImperativeHandle(reference, () => ({
|
|
144
|
+
add: onAddAlert
|
|
145
|
+
}));
|
|
146
|
+
return null;
|
|
147
|
+
}));
|
|
148
|
+
AlertNotify.defaultProps = {
|
|
149
|
+
position: {
|
|
150
|
+
vertical: 'bottom',
|
|
151
|
+
horizontal: 'center'
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
AlertNotify.propTypes = {
|
|
155
|
+
/**
|
|
156
|
+
* used to set position of Alert (is a string or an object)
|
|
157
|
+
* string is center (obligatory) as {vertical: 'center', horizontal: 'center'}
|
|
158
|
+
*/
|
|
159
|
+
position: PropTypes.oneOfType([PropTypes.oneOf(['center']), PropTypes.shape({
|
|
160
|
+
vertical: PropTypes.oneOf(['top', 'center', 'bottom']).isRequired,
|
|
161
|
+
horizontal: PropTypes.oneOf(['left', 'center', 'right']).isRequired
|
|
162
|
+
})]),
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* get the function used to add a new alert<br />
|
|
166
|
+
* 2 parameters:<br />
|
|
167
|
+
* + message: message for notify<br />
|
|
168
|
+
* + options: is an object insist {<br />
|
|
169
|
+
* position: position other than the default (if necessary)<br />
|
|
170
|
+
* duration: new duration,<br />
|
|
171
|
+
* color: new color,<br />
|
|
172
|
+
* progressing: new progressing value,<br />
|
|
173
|
+
* autoDisappear: new autoDisappear value,<br />
|
|
174
|
+
* size: new autoDisappear,<br />
|
|
175
|
+
* and any props else in Alert component <br />
|
|
176
|
+
* }
|
|
177
|
+
*/
|
|
178
|
+
getAddNotify: PropTypes.func.isRequired,
|
|
179
|
+
|
|
180
|
+
/** the width of the alert box */
|
|
181
|
+
width: PropTypes.string,
|
|
182
|
+
|
|
183
|
+
/** the maximum width of the alert box */
|
|
184
|
+
maxWidth: PropTypes.string,
|
|
185
|
+
|
|
186
|
+
/** the height of the alert box */
|
|
187
|
+
height: PropTypes.string,
|
|
188
|
+
|
|
189
|
+
/** the maximum height of the alert box */
|
|
190
|
+
maxHeight: PropTypes.string
|
|
191
|
+
};
|
|
192
|
+
export default AlertNotify;
|