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,223 @@
|
|
|
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, useRef, forwardRef, useEffect, useMemo } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import * as Icons from '../../icons';
|
|
10
|
+
import { capitalize } from '../../utils';
|
|
11
|
+
import { useTheme } from '../../theme';
|
|
12
|
+
const {
|
|
13
|
+
colors,
|
|
14
|
+
typography: {
|
|
15
|
+
fontFamily
|
|
16
|
+
}
|
|
17
|
+
} = useTheme();
|
|
18
|
+
const sizes = {
|
|
19
|
+
small: {
|
|
20
|
+
height: 24,
|
|
21
|
+
number: 14,
|
|
22
|
+
icon: 19,
|
|
23
|
+
fontSize: 12
|
|
24
|
+
},
|
|
25
|
+
medium: {
|
|
26
|
+
height: 32,
|
|
27
|
+
number: 18,
|
|
28
|
+
icon: 25.33,
|
|
29
|
+
fontSize: 14
|
|
30
|
+
},
|
|
31
|
+
large: {
|
|
32
|
+
height: 40,
|
|
33
|
+
number: 22,
|
|
34
|
+
icon: 31.67,
|
|
35
|
+
fontSize: 16
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
39
|
+
content,
|
|
40
|
+
max,
|
|
41
|
+
name,
|
|
42
|
+
color,
|
|
43
|
+
iconProps,
|
|
44
|
+
size,
|
|
45
|
+
style,
|
|
46
|
+
badgeNumStyle,
|
|
47
|
+
refs,
|
|
48
|
+
onClick,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
51
|
+
}, ref) => {
|
|
52
|
+
if (!ref) {
|
|
53
|
+
ref = useRef(null);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const badgeNumSize = sizes[size || 'medium'].number || 18;
|
|
57
|
+
const badgeIconSize = sizes[size || 'medium'].icon || 25.33;
|
|
58
|
+
const BadgeRoot = css`
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
align-items: flex-end;
|
|
61
|
+
position: relative;
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
color: #000;
|
|
64
|
+
height: ${sizes[size || 'medium'].height || 32}px;
|
|
65
|
+
width: ${sizes[size || 'medium'].height || 32}px;
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
&.click-able {
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
const BadgeIcon = css`
|
|
72
|
+
display: flex;
|
|
73
|
+
position: relative;
|
|
74
|
+
justify-content: flex-start;
|
|
75
|
+
align-items: flex-end;
|
|
76
|
+
height: ${badgeIconSize}px;
|
|
77
|
+
`;
|
|
78
|
+
const BadgeNumber = css`
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-wrap: wrap;
|
|
81
|
+
position: absolute;
|
|
82
|
+
top: 0;
|
|
83
|
+
right: 0;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
align-items: center;
|
|
86
|
+
font-family: ${fontFamily};
|
|
87
|
+
font-size: ${sizes[size || 'medium'].fontSize}px;
|
|
88
|
+
line-height: ${badgeNumSize}px;
|
|
89
|
+
font-style: normal;
|
|
90
|
+
height: ${badgeNumSize}px;
|
|
91
|
+
min-width: ${badgeNumSize}px;
|
|
92
|
+
padding: 0 3px;
|
|
93
|
+
color: #000;
|
|
94
|
+
background-color: ${colors.secondary};
|
|
95
|
+
border-radius: ${badgeNumSize / 2}px;
|
|
96
|
+
box-sizing: border-box;
|
|
97
|
+
z-index: 1;
|
|
98
|
+
&.primary {
|
|
99
|
+
color: #FFF;
|
|
100
|
+
background-color: ${colors.primary};
|
|
101
|
+
}
|
|
102
|
+
&.info {
|
|
103
|
+
color: #FFF;
|
|
104
|
+
background-color: ${colors.info};
|
|
105
|
+
}
|
|
106
|
+
&.success {
|
|
107
|
+
color: #FFF;
|
|
108
|
+
background-color: ${colors.success};
|
|
109
|
+
}
|
|
110
|
+
&.warning {
|
|
111
|
+
color: #FFF;
|
|
112
|
+
background-color: ${colors.warning};
|
|
113
|
+
}
|
|
114
|
+
&.danger {
|
|
115
|
+
color: #FFF;
|
|
116
|
+
background-color: ${colors.danger};
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (refs) refs(ref);
|
|
121
|
+
}, []);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (color && color !== 'default' && content) {
|
|
124
|
+
ref.current.querySelector(`.css-${BadgeNumber.name}`).classList.add(color);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return () => {
|
|
128
|
+
if (ref.current && color && color !== 'default' && content) {
|
|
129
|
+
ref.current.querySelector(`.css-${BadgeNumber.name}`).classList.remove(color);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}, [color]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (onClick) {
|
|
135
|
+
ref.current.classList.add('click-able');
|
|
136
|
+
ref.current.addEventListener('click', onClick);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return () => {
|
|
140
|
+
if (onClick && ref.current) {
|
|
141
|
+
ref.current.classList.remove('click-able');
|
|
142
|
+
ref.current.removeEventListener('click', onClick);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}, [onClick]);
|
|
146
|
+
const BadgeView = useMemo(() => {
|
|
147
|
+
let node = children;
|
|
148
|
+
|
|
149
|
+
if (!node && name) {
|
|
150
|
+
const IconNode = Icons[capitalize(name)];
|
|
151
|
+
|
|
152
|
+
if (IconNode) {
|
|
153
|
+
node = jsx(IconNode, _extends({
|
|
154
|
+
width: badgeIconSize,
|
|
155
|
+
height: badgeIconSize
|
|
156
|
+
}, iconProps));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return jsx("div", _extends({
|
|
161
|
+
css: BadgeRoot,
|
|
162
|
+
style: style,
|
|
163
|
+
ref: ref
|
|
164
|
+
}, props), jsx("span", {
|
|
165
|
+
css: BadgeIcon
|
|
166
|
+
}, node), content !== undefined && jsx("span", {
|
|
167
|
+
css: BadgeNumber,
|
|
168
|
+
style: badgeNumStyle
|
|
169
|
+
}, max && content > max ? max + '+' : content));
|
|
170
|
+
}, [content, name, size, children]);
|
|
171
|
+
return BadgeView;
|
|
172
|
+
}));
|
|
173
|
+
Badge.defaultProps = {
|
|
174
|
+
color: 'default',
|
|
175
|
+
size: 'medium',
|
|
176
|
+
iconProps: {
|
|
177
|
+
color: '#000',
|
|
178
|
+
viewBox: true
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
Badge.propTypes = {
|
|
182
|
+
/** the quantity is shown on the badge */
|
|
183
|
+
content: PropTypes.number,
|
|
184
|
+
|
|
185
|
+
/** the largest number is displayed on the badge */
|
|
186
|
+
max: PropTypes.number,
|
|
187
|
+
|
|
188
|
+
/** background color of badge */
|
|
189
|
+
color: PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'danger']),
|
|
190
|
+
|
|
191
|
+
/** name of icon in the icons store */
|
|
192
|
+
name: PropTypes.string,
|
|
193
|
+
|
|
194
|
+
/** size of Badge */
|
|
195
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
196
|
+
|
|
197
|
+
/** color for icon (if use name instead of children) */
|
|
198
|
+
iconProps: PropTypes.shape({
|
|
199
|
+
color: PropTypes.string,
|
|
200
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
201
|
+
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
202
|
+
viewBox: PropTypes.bool
|
|
203
|
+
}),
|
|
204
|
+
|
|
205
|
+
/** style inline of badge */
|
|
206
|
+
style: PropTypes.object,
|
|
207
|
+
|
|
208
|
+
/** style inline of badge number */
|
|
209
|
+
badgeNumStyle: PropTypes.object,
|
|
210
|
+
|
|
211
|
+
/** the function get ref */
|
|
212
|
+
refs: PropTypes.func,
|
|
213
|
+
|
|
214
|
+
/** the function will run when click on badge */
|
|
215
|
+
onClick: PropTypes.func,
|
|
216
|
+
|
|
217
|
+
/** the content displayed under the number of the badge */
|
|
218
|
+
children: PropTypes.node,
|
|
219
|
+
|
|
220
|
+
/** any props else */
|
|
221
|
+
props: PropTypes.any
|
|
222
|
+
};
|
|
223
|
+
export default Badge;
|
|
@@ -0,0 +1,493 @@
|
|
|
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, useRef, useEffect, useMemo, forwardRef } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import * as colors from '../../styles/colors';
|
|
10
|
+
import { hexToRgb, isColor, isColorName, lighten } from '../../styles/color-helper';
|
|
11
|
+
import { capitalize } from '../../utils';
|
|
12
|
+
import * as Icons from '../../icons';
|
|
13
|
+
import Ripple from './ripple-effect';
|
|
14
|
+
import theme from '../../theme/settings';
|
|
15
|
+
import { getClassNameFromColor, getRippleColor } from '.';
|
|
16
|
+
import CircularProgress from "../progress/circular";
|
|
17
|
+
const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
18
|
+
type,
|
|
19
|
+
viewType,
|
|
20
|
+
color,
|
|
21
|
+
size,
|
|
22
|
+
name,
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
className,
|
|
26
|
+
circular,
|
|
27
|
+
viewBox,
|
|
28
|
+
disabled,
|
|
29
|
+
style,
|
|
30
|
+
onClick,
|
|
31
|
+
icon,
|
|
32
|
+
children,
|
|
33
|
+
refs,
|
|
34
|
+
loading,
|
|
35
|
+
...props
|
|
36
|
+
}, ref) => {
|
|
37
|
+
if (!ref) {
|
|
38
|
+
ref = useRef(null);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const ButtonRoot = css`
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
position: relative;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
align-items: center;
|
|
46
|
+
outline: none;
|
|
47
|
+
margin: 2px;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
border-radius: ${circular ? '50%' : '4px'};
|
|
50
|
+
transition: background-color 0.5s, filter 0.5s;
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
user-select: none;
|
|
54
|
+
&.tiny {
|
|
55
|
+
padding: 4px;
|
|
56
|
+
&.outlined {
|
|
57
|
+
padding: 3px;
|
|
58
|
+
}
|
|
59
|
+
.DGN-UI-ButtonIcon-Icon {
|
|
60
|
+
height: 16px;
|
|
61
|
+
width: 16px;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
&.small {
|
|
65
|
+
padding: 6px;
|
|
66
|
+
&.outlined {
|
|
67
|
+
padding: 5px;
|
|
68
|
+
}
|
|
69
|
+
.DGN-UI-ButtonIcon-Icon {
|
|
70
|
+
height: 20px;
|
|
71
|
+
width: 20px;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
&.medium {
|
|
75
|
+
padding: 8px;
|
|
76
|
+
&.outlined {
|
|
77
|
+
padding: 7px;
|
|
78
|
+
}
|
|
79
|
+
.DGN-UI-ButtonIcon-Icon {
|
|
80
|
+
height: 24px;
|
|
81
|
+
width: 24px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
&.large {
|
|
85
|
+
padding: 8px;
|
|
86
|
+
&.outlined {
|
|
87
|
+
padding: 7px;
|
|
88
|
+
}
|
|
89
|
+
.DGN-UI-ButtonIcon-Icon {
|
|
90
|
+
height: 32px;
|
|
91
|
+
width: 32px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
&.giant {
|
|
95
|
+
padding: 8px;
|
|
96
|
+
&.outlined {
|
|
97
|
+
padding: 7px;
|
|
98
|
+
}
|
|
99
|
+
.DGN-UI-ButtonIcon-Icon {
|
|
100
|
+
height: 40px;
|
|
101
|
+
width: 40px;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
&.outlined {
|
|
105
|
+
background-color: ${theme.colors.white};
|
|
106
|
+
font-weight : bold;
|
|
107
|
+
&.default {
|
|
108
|
+
border: 1px solid ${theme.colors.secondary};
|
|
109
|
+
color : ${theme.colors.default};
|
|
110
|
+
&:hover {
|
|
111
|
+
background-color: ${lighten(theme.colors.default, 0.9)};
|
|
112
|
+
}
|
|
113
|
+
&:focus {
|
|
114
|
+
background-color: ${lighten(theme.colors.default, 0.8)};
|
|
115
|
+
}
|
|
116
|
+
&:active {
|
|
117
|
+
background-color: ${lighten(theme.colors.default, 0.7)};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
&.primary {
|
|
121
|
+
border: 1px solid ${theme.colors.primary};
|
|
122
|
+
color : ${theme.colors.primary};
|
|
123
|
+
&:hover {
|
|
124
|
+
background-color: ${lighten(theme.colors.primary, 0.9)};
|
|
125
|
+
}
|
|
126
|
+
&:focus {
|
|
127
|
+
background-color: ${lighten(theme.colors.primary, 0.8)};
|
|
128
|
+
}
|
|
129
|
+
&:active {
|
|
130
|
+
background-color: ${lighten(theme.colors.primary, 0.7)};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
&.success {
|
|
134
|
+
border: 1px solid ${theme.colors.success};
|
|
135
|
+
color : ${theme.colors.success};
|
|
136
|
+
&:hover {
|
|
137
|
+
background-color: ${lighten(theme.colors.success, 0.9)};
|
|
138
|
+
}
|
|
139
|
+
&:focus {
|
|
140
|
+
background-color: ${lighten(theme.colors.success, 0.8)};
|
|
141
|
+
}
|
|
142
|
+
&:active {
|
|
143
|
+
background-color: ${lighten(theme.colors.success, 0.7)};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
&.warning {
|
|
147
|
+
border: 1px solid ${theme.colors.warning};
|
|
148
|
+
color : ${theme.colors.warning};
|
|
149
|
+
&:hover {
|
|
150
|
+
background-color: ${lighten(theme.colors.warning, 0.9)};
|
|
151
|
+
}
|
|
152
|
+
&:focus {
|
|
153
|
+
background-color: ${lighten(theme.colors.warning, 0.8)};
|
|
154
|
+
}
|
|
155
|
+
&:active {
|
|
156
|
+
background-color: ${lighten(theme.colors.warning, 0.7)};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
&.danger {
|
|
160
|
+
border: 1px solid ${theme.colors.danger};
|
|
161
|
+
color : ${theme.colors.danger};
|
|
162
|
+
&:hover {
|
|
163
|
+
background-color: ${lighten(theme.colors.danger, 0.9)};
|
|
164
|
+
}
|
|
165
|
+
&:focus {
|
|
166
|
+
background-color: ${lighten(theme.colors.danger, 0.8)};
|
|
167
|
+
}
|
|
168
|
+
&:active {
|
|
169
|
+
background-color: ${lighten(theme.colors.danger, 0.7)};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
&.info {
|
|
173
|
+
border: 1px solid ${theme.colors.info};
|
|
174
|
+
color : ${theme.colors.info};
|
|
175
|
+
&:hover {
|
|
176
|
+
background-color: ${lighten(theme.colors.info, 0.9)};
|
|
177
|
+
}
|
|
178
|
+
&:focus {
|
|
179
|
+
background-color: ${lighten(theme.colors.info, 0.8)};
|
|
180
|
+
}
|
|
181
|
+
&:active {
|
|
182
|
+
background-color: ${lighten(theme.colors.info, 0.7)};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
${isColor(color) && `&.custom-color {
|
|
186
|
+
border: 1px solid ${color};
|
|
187
|
+
color : ${color};
|
|
188
|
+
&:hover {
|
|
189
|
+
background-color: ${lighten(color, 0.9)};
|
|
190
|
+
}
|
|
191
|
+
&:focus {
|
|
192
|
+
background-color: ${lighten(color, 0.8)};
|
|
193
|
+
}
|
|
194
|
+
&:active {
|
|
195
|
+
background-color: ${lighten(color, 0.7)};
|
|
196
|
+
}
|
|
197
|
+
}`}
|
|
198
|
+
${isColorName(color) && `&.custom-color {
|
|
199
|
+
border: 1px solid ${isColorName(color)};
|
|
200
|
+
color : ${isColorName(color)};
|
|
201
|
+
&:hover {
|
|
202
|
+
background-color: ${lighten(isColorName(color), 0.9)};
|
|
203
|
+
}
|
|
204
|
+
&:focus {
|
|
205
|
+
background-color: ${lighten(isColorName(color), 0.8)};
|
|
206
|
+
}
|
|
207
|
+
&:active {
|
|
208
|
+
background-color: ${lighten(isColorName(color), 0.7)};
|
|
209
|
+
}
|
|
210
|
+
}`}
|
|
211
|
+
}
|
|
212
|
+
&.filled {
|
|
213
|
+
border : none;
|
|
214
|
+
color : ${theme.colors.white};
|
|
215
|
+
font-weight: bold;
|
|
216
|
+
&:hover, &:focus {
|
|
217
|
+
filter: brightness(0.85);
|
|
218
|
+
}
|
|
219
|
+
&:active {
|
|
220
|
+
filter: brightness(0.7);
|
|
221
|
+
}
|
|
222
|
+
&.default {
|
|
223
|
+
background-color: ${theme.colors.secondary};
|
|
224
|
+
}
|
|
225
|
+
&.primary {
|
|
226
|
+
background-color: ${theme.colors.primary};
|
|
227
|
+
}
|
|
228
|
+
&.success {
|
|
229
|
+
background-color: ${theme.colors.success};
|
|
230
|
+
}
|
|
231
|
+
&.warning {
|
|
232
|
+
background-color: ${theme.colors.warning};
|
|
233
|
+
}
|
|
234
|
+
&.danger {
|
|
235
|
+
background-color: ${theme.colors.danger};
|
|
236
|
+
}
|
|
237
|
+
&.info {
|
|
238
|
+
background-color: ${theme.colors.info};
|
|
239
|
+
}
|
|
240
|
+
${isColor(color) && `&.custom-color {
|
|
241
|
+
background-color: ${color};
|
|
242
|
+
}`}
|
|
243
|
+
${isColorName(color) && `&.custom-color {
|
|
244
|
+
background-color: ${isColorName(color)};
|
|
245
|
+
}`}
|
|
246
|
+
}
|
|
247
|
+
&.text {
|
|
248
|
+
background-color: transparent;
|
|
249
|
+
border : none !important;
|
|
250
|
+
&.default {
|
|
251
|
+
color : ${theme.colors.secondary};
|
|
252
|
+
&:hover {
|
|
253
|
+
background-color: ${lighten(theme.colors.secondary, 0.9)};
|
|
254
|
+
}
|
|
255
|
+
&:focus {
|
|
256
|
+
background-color: ${lighten(theme.colors.secondary, 0.8)};
|
|
257
|
+
}
|
|
258
|
+
&:active {
|
|
259
|
+
background-color: ${lighten(theme.colors.secondary, 0.7)};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
&.primary {
|
|
263
|
+
color : ${theme.colors.primary};
|
|
264
|
+
&:hover {
|
|
265
|
+
background-color: ${lighten(theme.colors.primary, 0.9)};
|
|
266
|
+
}
|
|
267
|
+
&:focus {
|
|
268
|
+
background-color: ${lighten(theme.colors.primary, 0.8)};
|
|
269
|
+
}
|
|
270
|
+
&:active {
|
|
271
|
+
background-color: ${lighten(theme.colors.primary, 0.7)};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
&.success {
|
|
275
|
+
color : ${theme.colors.success};
|
|
276
|
+
&:hover {
|
|
277
|
+
background-color: ${lighten(theme.colors.success, 0.9)};
|
|
278
|
+
}
|
|
279
|
+
&:focus {
|
|
280
|
+
background-color: ${lighten(theme.colors.success, 0.8)};
|
|
281
|
+
}
|
|
282
|
+
&:active {
|
|
283
|
+
background-color: ${lighten(theme.colors.success, 0.7)};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
&.warning {
|
|
287
|
+
color : ${theme.colors.warning};
|
|
288
|
+
&:hover {
|
|
289
|
+
background-color: ${lighten(theme.colors.warning, 0.9)};
|
|
290
|
+
}
|
|
291
|
+
&:focus {
|
|
292
|
+
background-color: ${lighten(theme.colors.warning, 0.8)};
|
|
293
|
+
}
|
|
294
|
+
&:active {
|
|
295
|
+
background-color: ${lighten(theme.colors.warning, 0.7)};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
&.danger {
|
|
299
|
+
color : ${theme.colors.danger};
|
|
300
|
+
&:hover {
|
|
301
|
+
background-color: ${lighten(theme.colors.danger, 0.9)};
|
|
302
|
+
}
|
|
303
|
+
&:focus {
|
|
304
|
+
background-color: ${lighten(theme.colors.danger, 0.8)};
|
|
305
|
+
}
|
|
306
|
+
&:active {
|
|
307
|
+
background-color: ${lighten(theme.colors.danger, 0.7)};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
&.info {
|
|
311
|
+
color : ${theme.colors.info};
|
|
312
|
+
&:hover {
|
|
313
|
+
background-color: ${lighten(theme.colors.info, 0.9)};
|
|
314
|
+
}
|
|
315
|
+
&:focus {
|
|
316
|
+
background-color: ${lighten(theme.colors.info, 0.8)};
|
|
317
|
+
}
|
|
318
|
+
&:active {
|
|
319
|
+
background-color: ${lighten(theme.colors.info, 0.7)};
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
${isColor(color) && `&.custom-color {
|
|
323
|
+
color : ${color};
|
|
324
|
+
&:hover {
|
|
325
|
+
background-color: ${lighten(color, 0.9)};
|
|
326
|
+
}
|
|
327
|
+
&:focus {
|
|
328
|
+
background-color: ${lighten(color, 0.8)};
|
|
329
|
+
}
|
|
330
|
+
&:active {
|
|
331
|
+
background-color: ${lighten(color, 0.7)};
|
|
332
|
+
}
|
|
333
|
+
}`}
|
|
334
|
+
${isColorName(color) && `&.custom-color {
|
|
335
|
+
color : ${isColorName(color)};
|
|
336
|
+
&:hover {
|
|
337
|
+
background-color: ${lighten(isColorName(color), 0.9)};
|
|
338
|
+
}
|
|
339
|
+
&:focus {
|
|
340
|
+
background-color: ${lighten(isColorName(color), 0.8)};
|
|
341
|
+
}
|
|
342
|
+
&:active {
|
|
343
|
+
background-color: ${lighten(isColorName(color), 0.7)};
|
|
344
|
+
}
|
|
345
|
+
}`}
|
|
346
|
+
}
|
|
347
|
+
&:disabled {
|
|
348
|
+
pointer-events: none;
|
|
349
|
+
color: ${colors.dark4} !important;
|
|
350
|
+
&.filled, &.outlined {
|
|
351
|
+
background-color: ${theme.colors.bgDisabled} !important;
|
|
352
|
+
filter: brightness(1);
|
|
353
|
+
}
|
|
354
|
+
&.outlined {
|
|
355
|
+
border-color: ${theme.colors.disabled};
|
|
356
|
+
}
|
|
357
|
+
&.text {
|
|
358
|
+
background-color: transparent !important;
|
|
359
|
+
}
|
|
360
|
+
.DGN-UI-ButtonIcon-Icon {
|
|
361
|
+
pointer-events: auto;
|
|
362
|
+
cursor: no-drop;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
&:not(:disabled):focus {
|
|
366
|
+
box-shadow: ${viewType !== 'text' ? '0 0 0 2px ' + hexToRgb(colors.brand + '20') : 'none'};
|
|
367
|
+
}
|
|
368
|
+
.DGN-UI-ButtonIcon-Icon {
|
|
369
|
+
display: flex;
|
|
370
|
+
position: relative;
|
|
371
|
+
box-sizing: border-box;
|
|
372
|
+
justify-content: center;
|
|
373
|
+
align-items: center;
|
|
374
|
+
}
|
|
375
|
+
`;
|
|
376
|
+
const NotFoundIcon = css`
|
|
377
|
+
display: block;
|
|
378
|
+
width: 70%;
|
|
379
|
+
height: 70%;
|
|
380
|
+
border: 1px dashed ${theme.colors.border};
|
|
381
|
+
`;
|
|
382
|
+
useEffect(() => {
|
|
383
|
+
if (refs) refs(ref);
|
|
384
|
+
}, []);
|
|
385
|
+
|
|
386
|
+
const iconLoading = () => {
|
|
387
|
+
return jsx(CircularProgress, {
|
|
388
|
+
size: "extraSmall",
|
|
389
|
+
background: "transparent",
|
|
390
|
+
color: 'currentColor',
|
|
391
|
+
strokeWidth: 3,
|
|
392
|
+
width: 24
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
const _onClick = event => {
|
|
397
|
+
if (disabled || loading) return;
|
|
398
|
+
onClick && onClick(event);
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
const ButtonView = useMemo(() => {
|
|
402
|
+
let node = children;
|
|
403
|
+
|
|
404
|
+
if (!node) {
|
|
405
|
+
const IconComp = Icons[capitalize(name)];
|
|
406
|
+
|
|
407
|
+
if (IconComp) {
|
|
408
|
+
node = jsx(IconComp, {
|
|
409
|
+
width: width,
|
|
410
|
+
height: height,
|
|
411
|
+
color: 'currentColor',
|
|
412
|
+
viewBox: viewBox
|
|
413
|
+
});
|
|
414
|
+
} else {
|
|
415
|
+
node = jsx("span", {
|
|
416
|
+
css: NotFoundIcon
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return jsx("button", _extends({
|
|
422
|
+
css: ButtonRoot,
|
|
423
|
+
style: style,
|
|
424
|
+
ref: ref,
|
|
425
|
+
type: type,
|
|
426
|
+
onClick: _onClick,
|
|
427
|
+
disabled: disabled,
|
|
428
|
+
className: ['DGN-UI-ButtonIcon', viewType, getClassNameFromColor(color), size, className].join(' ').trim().replace(/\s+/g, ' ')
|
|
429
|
+
}, props), loading && iconLoading(), !loading && jsx("span", {
|
|
430
|
+
className: 'DGN-UI-ButtonIcon-Icon'
|
|
431
|
+
}, " ", node, " "), !disabled && jsx(Ripple, {
|
|
432
|
+
color: getRippleColor(color, viewType, colors)
|
|
433
|
+
}));
|
|
434
|
+
}, [size, viewType, color, disabled, name, children, onClick, loading, circular, viewBox]);
|
|
435
|
+
return ButtonView;
|
|
436
|
+
}));
|
|
437
|
+
ButtonIcon.defaultProps = {
|
|
438
|
+
viewType: 'outlined',
|
|
439
|
+
color: 'default',
|
|
440
|
+
size: 'medium',
|
|
441
|
+
className: '',
|
|
442
|
+
width: '100%',
|
|
443
|
+
height: '100%',
|
|
444
|
+
circular: false,
|
|
445
|
+
disabled: false
|
|
446
|
+
};
|
|
447
|
+
ButtonIcon.propTypes = {
|
|
448
|
+
/** The type attribute specifies the type of tag button */
|
|
449
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
450
|
+
|
|
451
|
+
/** used to fill background for button */
|
|
452
|
+
viewType: PropTypes.oneOf(['text', 'outlined', 'filled']),
|
|
453
|
+
|
|
454
|
+
/** color for button */
|
|
455
|
+
color: PropTypes.string,
|
|
456
|
+
|
|
457
|
+
/** size button */
|
|
458
|
+
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant']),
|
|
459
|
+
|
|
460
|
+
/** name of icon in icons store */
|
|
461
|
+
name: PropTypes.string,
|
|
462
|
+
|
|
463
|
+
/** the class for button */
|
|
464
|
+
className: PropTypes.string,
|
|
465
|
+
|
|
466
|
+
/** the width of icon */
|
|
467
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
468
|
+
|
|
469
|
+
/** the height of icon */
|
|
470
|
+
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
471
|
+
|
|
472
|
+
/** has view box if true */
|
|
473
|
+
viewBox: PropTypes.bool,
|
|
474
|
+
|
|
475
|
+
/** circle button if true */
|
|
476
|
+
circular: PropTypes.bool,
|
|
477
|
+
|
|
478
|
+
/** prevent all event if true */
|
|
479
|
+
disabled: PropTypes.bool,
|
|
480
|
+
|
|
481
|
+
/** style inline of button */
|
|
482
|
+
style: PropTypes.object,
|
|
483
|
+
|
|
484
|
+
/** element to display in button */
|
|
485
|
+
children: PropTypes.node,
|
|
486
|
+
|
|
487
|
+
/** any props else */
|
|
488
|
+
props: PropTypes.any,
|
|
489
|
+
|
|
490
|
+
/** status loading of button */
|
|
491
|
+
loading: PropTypes.bool
|
|
492
|
+
};
|
|
493
|
+
export default ButtonIcon;
|