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,327 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** @jsxRuntime classic */
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { jsx, css, keyframes } from '@emotion/core';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { forwardRef, memo, useEffect, useMemo, useRef } from 'react';
|
|
9
|
+
import theme from '../../theme/settings';
|
|
10
|
+
import { Typography } from '../';
|
|
11
|
+
|
|
12
|
+
const cutPX = x => {
|
|
13
|
+
return isNaN(x) ? x : x + 'px';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const validatePercent = p => {
|
|
17
|
+
let per = +p.toString().replace('%', '');
|
|
18
|
+
return Math.max(Math.min(per, 100), 0);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const Indeterminate = /*#__PURE__*/forwardRef(({
|
|
22
|
+
background,
|
|
23
|
+
className,
|
|
24
|
+
color,
|
|
25
|
+
height,
|
|
26
|
+
width,
|
|
27
|
+
...props
|
|
28
|
+
}, ref) => {
|
|
29
|
+
if (!ref) ref = useRef(null);
|
|
30
|
+
const firstBarRef = useRef(null);
|
|
31
|
+
const secondBarRef = useRef(null);
|
|
32
|
+
const unique = {
|
|
33
|
+
container: 'DGN-UI-LinearProgress-Determinate',
|
|
34
|
+
firstBar: 'DGN-UI-LinearProgress-Determinate-BarFirst',
|
|
35
|
+
secondBar: 'DGN-UI-LinearProgress-Determinate-BarSecond'
|
|
36
|
+
};
|
|
37
|
+
const animation = {
|
|
38
|
+
keyframeStart: keyframes`
|
|
39
|
+
from {
|
|
40
|
+
max-height: 0;
|
|
41
|
+
opacity: 0;
|
|
42
|
+
}
|
|
43
|
+
to {
|
|
44
|
+
max-height: 20px;
|
|
45
|
+
opacity: 1;
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
keyframeMove: keyframes`
|
|
49
|
+
0% {
|
|
50
|
+
left: -100%;
|
|
51
|
+
}
|
|
52
|
+
50% {
|
|
53
|
+
left: 100%;
|
|
54
|
+
}
|
|
55
|
+
100% {
|
|
56
|
+
left: 100%;
|
|
57
|
+
}
|
|
58
|
+
`
|
|
59
|
+
};
|
|
60
|
+
const containerCSS = css`
|
|
61
|
+
animation : ${animation.keyframeStart} 0.3s ease-in;
|
|
62
|
+
background-color: ${background};
|
|
63
|
+
border-radius : 4px;
|
|
64
|
+
box-shadow : 0px 2px 2px rgba(0, 0, 0, 0.1);
|
|
65
|
+
height : ${cutPX(height)};
|
|
66
|
+
overflow : hidden;
|
|
67
|
+
position : relative;
|
|
68
|
+
width : ${cutPX(width)};
|
|
69
|
+
.${unique.firstBar} {
|
|
70
|
+
animation : ${animation.keyframeMove} 3s infinite;
|
|
71
|
+
background-color: ${theme.colors[color] || color};
|
|
72
|
+
border-radius : 4px;
|
|
73
|
+
bottom : 0;
|
|
74
|
+
left : 0;
|
|
75
|
+
position : absolute;
|
|
76
|
+
top : 0;
|
|
77
|
+
transition : transform 0.3s ease-in-out;
|
|
78
|
+
width : 100%;
|
|
79
|
+
}
|
|
80
|
+
.${unique.secondBar} {
|
|
81
|
+
animation-delay : 1.5s;
|
|
82
|
+
animation : ${animation.keyframeMove} 3s infinite;
|
|
83
|
+
background-color: ${theme.colors[color] || color};
|
|
84
|
+
border-radius : 4px;
|
|
85
|
+
bottom : 0;
|
|
86
|
+
left : -100%;
|
|
87
|
+
position : absolute;
|
|
88
|
+
top : 0;
|
|
89
|
+
transition : transform 0.3s ease-in-out;
|
|
90
|
+
width : 100%;
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
const FirstBar = useMemo(() => jsx("div", {
|
|
94
|
+
className: unique.firstBar,
|
|
95
|
+
ref: firstBarRef
|
|
96
|
+
}), [color]);
|
|
97
|
+
const SecondBar = useMemo(() => jsx("div", {
|
|
98
|
+
className: unique.secondBar,
|
|
99
|
+
ref: secondBarRef
|
|
100
|
+
}), [color]);
|
|
101
|
+
return jsx("div", _extends({}, props, {
|
|
102
|
+
className: [unique.container, className].join(' ').trimEnd(),
|
|
103
|
+
css: containerCSS,
|
|
104
|
+
ref: ref
|
|
105
|
+
}), FirstBar, SecondBar);
|
|
106
|
+
});
|
|
107
|
+
Indeterminate.defaultProps = {
|
|
108
|
+
background: theme.colors.bgProgress,
|
|
109
|
+
color: theme.colors.info,
|
|
110
|
+
height: 8,
|
|
111
|
+
width: '100%'
|
|
112
|
+
};
|
|
113
|
+
Indeterminate.propTypes = {
|
|
114
|
+
background: PropTypes.string,
|
|
115
|
+
className: PropTypes.string,
|
|
116
|
+
color: PropTypes.string,
|
|
117
|
+
height: PropTypes.number,
|
|
118
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
119
|
+
};
|
|
120
|
+
export const IndeterminateLinearProgress = /*#__PURE__*/memo(Indeterminate);
|
|
121
|
+
const Determinate = /*#__PURE__*/forwardRef(({
|
|
122
|
+
background,
|
|
123
|
+
color,
|
|
124
|
+
className,
|
|
125
|
+
duration,
|
|
126
|
+
height,
|
|
127
|
+
percent,
|
|
128
|
+
percentColor,
|
|
129
|
+
showValue,
|
|
130
|
+
valuePosition,
|
|
131
|
+
width,
|
|
132
|
+
...props
|
|
133
|
+
}, ref) => {
|
|
134
|
+
if (!ref) ref = useRef(null);
|
|
135
|
+
const barRef = useRef(null);
|
|
136
|
+
const valueRef = useRef(null);
|
|
137
|
+
const unique = {
|
|
138
|
+
container: 'DGN-UI-LinearProgress-Determinate',
|
|
139
|
+
bar: 'DGN-UI-LinearProgress-Determinate-Bar',
|
|
140
|
+
value: 'DGN-UI-LinearProgress-Determinate-Value'
|
|
141
|
+
};
|
|
142
|
+
const keyframeStart = keyframes`
|
|
143
|
+
from {
|
|
144
|
+
max-height: 0;
|
|
145
|
+
opacity: 0;
|
|
146
|
+
}
|
|
147
|
+
to {
|
|
148
|
+
max-height: 20px;
|
|
149
|
+
opacity: 1;
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
const containerCSS = css`
|
|
153
|
+
animation : ${keyframeStart} 0.3s ease-in;
|
|
154
|
+
background-color: ${background};
|
|
155
|
+
border-radius : 4px;
|
|
156
|
+
box-shadow : 0px 2px 2px rgba(0, 0, 0, 0.1);
|
|
157
|
+
height : ${cutPX(height)};
|
|
158
|
+
position : relative;
|
|
159
|
+
width : ${cutPX(width)};
|
|
160
|
+
.${unique.bar} {
|
|
161
|
+
background-color: ${theme.colors[color] || color};
|
|
162
|
+
border-radius : 4px;
|
|
163
|
+
bottom : 0;
|
|
164
|
+
left : 0;
|
|
165
|
+
position : absolute;
|
|
166
|
+
top : 0;
|
|
167
|
+
transition : width ${duration}s cubic-bezier(0.770, 0.000, 0.175, 1.000); /* easeInOutQuart */
|
|
168
|
+
}
|
|
169
|
+
.${unique.value} {
|
|
170
|
+
color : ${percentColor ? percentColor : theme.colors[color] || color};
|
|
171
|
+
margin : 4px 0;
|
|
172
|
+
min-width : max-content;
|
|
173
|
+
position : absolute;
|
|
174
|
+
transform : translateX(-50%);
|
|
175
|
+
transition : left ${duration}s cubic-bezier(0.770, 0.000, 0.175, 1.000); /* easeInOutQuart */
|
|
176
|
+
user-select: none;
|
|
177
|
+
${valuePosition === 'bottom' ? 'top: 100%;' : 'bottom: 100%;'};
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
|
|
181
|
+
const updateValuePosition = value => {
|
|
182
|
+
valueRef.current.firstChild.innerText = value + '%';
|
|
183
|
+
const valHalfWidth = valueRef.current.getBoundingClientRect().width / 2;
|
|
184
|
+
|
|
185
|
+
if (value > 90) {
|
|
186
|
+
valueRef.current.style.left = `calc(${value + '%'} - ${valHalfWidth}px)`;
|
|
187
|
+
} else if (value < 10) {
|
|
188
|
+
valueRef.current.style.left = `calc(${value + '%'} + ${valHalfWidth}px)`;
|
|
189
|
+
} else {
|
|
190
|
+
valueRef.current.style.left = value + '%';
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const Bar = useMemo(() => jsx("div", {
|
|
195
|
+
className: unique.bar,
|
|
196
|
+
ref: barRef
|
|
197
|
+
}), [color, duration, percent]);
|
|
198
|
+
const Value = useMemo(() => showValue && jsx("span", {
|
|
199
|
+
className: unique.value,
|
|
200
|
+
ref: valueRef
|
|
201
|
+
}, jsx(Typography, {
|
|
202
|
+
type: 'p2',
|
|
203
|
+
color: 'inherit',
|
|
204
|
+
style: {
|
|
205
|
+
textShadow: '0px 2px 4px rgba(0,0,0,0.3)'
|
|
206
|
+
}
|
|
207
|
+
})), [duration, percentColor, showValue, valuePosition]);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
const value = validatePercent(percent);
|
|
210
|
+
barRef.current.style.width = value + '%';
|
|
211
|
+
|
|
212
|
+
if (showValue) {
|
|
213
|
+
updateValuePosition(value);
|
|
214
|
+
}
|
|
215
|
+
}, [percent, showValue]);
|
|
216
|
+
return jsx("div", _extends({}, props, {
|
|
217
|
+
className: [unique.container, className].join(' ').trim(),
|
|
218
|
+
css: containerCSS,
|
|
219
|
+
ref: ref
|
|
220
|
+
}), Bar, Value);
|
|
221
|
+
});
|
|
222
|
+
Determinate.defaultProps = {
|
|
223
|
+
background: theme.colors.bgProgress,
|
|
224
|
+
color: theme.colors.info,
|
|
225
|
+
duration: 0.1,
|
|
226
|
+
height: 8,
|
|
227
|
+
percent: 69,
|
|
228
|
+
showValue: false,
|
|
229
|
+
valuePosition: 'bottom',
|
|
230
|
+
width: '100%'
|
|
231
|
+
};
|
|
232
|
+
Determinate.propTypes = {
|
|
233
|
+
background: PropTypes.string,
|
|
234
|
+
className: PropTypes.string,
|
|
235
|
+
color: PropTypes.string,
|
|
236
|
+
duration: PropTypes.number,
|
|
237
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
238
|
+
percent: PropTypes.number,
|
|
239
|
+
percentColor: PropTypes.string,
|
|
240
|
+
showValue: PropTypes.bool,
|
|
241
|
+
valuePosition: PropTypes.oneOf(['bottom', 'top']),
|
|
242
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
243
|
+
};
|
|
244
|
+
export const DeterminateLinearProgress = /*#__PURE__*/memo(Determinate);
|
|
245
|
+
const LinearProgress = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
246
|
+
background,
|
|
247
|
+
className,
|
|
248
|
+
color,
|
|
249
|
+
determinate,
|
|
250
|
+
duration,
|
|
251
|
+
height,
|
|
252
|
+
percent,
|
|
253
|
+
percentColor,
|
|
254
|
+
showValue,
|
|
255
|
+
valuePosition,
|
|
256
|
+
width,
|
|
257
|
+
...props
|
|
258
|
+
}, ref) => {
|
|
259
|
+
if (!ref) ref = useRef(null);
|
|
260
|
+
return determinate ? jsx(DeterminateLinearProgress, _extends({
|
|
261
|
+
background: background,
|
|
262
|
+
className: className,
|
|
263
|
+
color: color,
|
|
264
|
+
duration: duration,
|
|
265
|
+
height: height,
|
|
266
|
+
percent: percent,
|
|
267
|
+
percentColor: percentColor,
|
|
268
|
+
showValue: showValue,
|
|
269
|
+
valuePosition: valuePosition,
|
|
270
|
+
width: width
|
|
271
|
+
}, props, {
|
|
272
|
+
ref: ref
|
|
273
|
+
})) : jsx(IndeterminateLinearProgress, _extends({
|
|
274
|
+
background: background,
|
|
275
|
+
className: className,
|
|
276
|
+
color: color,
|
|
277
|
+
height: height,
|
|
278
|
+
width: width
|
|
279
|
+
}, props, {
|
|
280
|
+
ref: ref
|
|
281
|
+
}));
|
|
282
|
+
}));
|
|
283
|
+
LinearProgress.defaultProps = {
|
|
284
|
+
background: theme.colors.bgProgress,
|
|
285
|
+
color: theme.colors.info,
|
|
286
|
+
determinate: false,
|
|
287
|
+
duration: 0.1,
|
|
288
|
+
height: 8,
|
|
289
|
+
percent: 69,
|
|
290
|
+
showValue: false,
|
|
291
|
+
width: '100%'
|
|
292
|
+
};
|
|
293
|
+
LinearProgress.propTypes = {
|
|
294
|
+
/** Color for background stroke of the linear progress. */
|
|
295
|
+
background: PropTypes.string,
|
|
296
|
+
|
|
297
|
+
/** className use in linear progress. */
|
|
298
|
+
className: PropTypes.string,
|
|
299
|
+
|
|
300
|
+
/** color of liner progress. */
|
|
301
|
+
color: PropTypes.string,
|
|
302
|
+
|
|
303
|
+
/** Determinate or Indeterminate. */
|
|
304
|
+
determinate: PropTypes.bool,
|
|
305
|
+
|
|
306
|
+
/** Time to processing. */
|
|
307
|
+
duration: PropTypes.number,
|
|
308
|
+
|
|
309
|
+
/** Dynamic height dimensions of the container. */
|
|
310
|
+
height: PropTypes.number,
|
|
311
|
+
|
|
312
|
+
/** The percent of the determinate progress. */
|
|
313
|
+
percent: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
314
|
+
|
|
315
|
+
/** Color percent-label of the progress. */
|
|
316
|
+
percentColor: PropTypes.string,
|
|
317
|
+
|
|
318
|
+
/** It's boolean to show the percent-label. */
|
|
319
|
+
showValue: PropTypes.bool,
|
|
320
|
+
|
|
321
|
+
/** Dynamic position of the progress value. */
|
|
322
|
+
valuePosition: PropTypes.oneOf(['bottom', 'top']),
|
|
323
|
+
|
|
324
|
+
/** Dynamic width dimensions of the container. */
|
|
325
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
326
|
+
};
|
|
327
|
+
export default LinearProgress;
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** @jsxRuntime classic */
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { memo, useMemo, useRef, useState, useEffect, forwardRef, Fragment } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import theme from '../../theme/settings';
|
|
10
|
+
import { Star } from '../../icons';
|
|
11
|
+
import { randomString } from '../../utils';
|
|
12
|
+
const colors = {
|
|
13
|
+
default: theme.colors.secondary,
|
|
14
|
+
primary: theme.colors.primary,
|
|
15
|
+
info: theme.colors.info,
|
|
16
|
+
success: theme.colors.success,
|
|
17
|
+
warning: theme.colors.warning,
|
|
18
|
+
danger: theme.colors.danger,
|
|
19
|
+
chosen: {
|
|
20
|
+
primary: '#080F43',
|
|
21
|
+
info: theme.colors.linkHover,
|
|
22
|
+
success: theme.colors.button.bgFilledHover.success,
|
|
23
|
+
warning: theme.colors.button.bgFilledHover.warning,
|
|
24
|
+
danger: theme.colors.button.bgFilledHover.danger
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const Rating = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
28
|
+
disabled,
|
|
29
|
+
readOnly,
|
|
30
|
+
half,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
selector,
|
|
34
|
+
quantity,
|
|
35
|
+
defaultValue,
|
|
36
|
+
value,
|
|
37
|
+
color,
|
|
38
|
+
className,
|
|
39
|
+
style,
|
|
40
|
+
starStyle,
|
|
41
|
+
onRating,
|
|
42
|
+
...props
|
|
43
|
+
}, ref) => {
|
|
44
|
+
if (!ref) {
|
|
45
|
+
ref = useRef(null);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const selectRef = useRef(null);
|
|
49
|
+
const [unique] = useState(randomString(6, {
|
|
50
|
+
allowSymbol: false,
|
|
51
|
+
allowNumber: false
|
|
52
|
+
}));
|
|
53
|
+
const RatingItemHaft = css`
|
|
54
|
+
display: flex;
|
|
55
|
+
position: absolute;
|
|
56
|
+
align-items: center;
|
|
57
|
+
width: max-content;
|
|
58
|
+
svg {
|
|
59
|
+
margin-top: 1px;
|
|
60
|
+
color: transparent;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
transition: color 0.15s linear;
|
|
63
|
+
}
|
|
64
|
+
left: 50%;
|
|
65
|
+
&.left {
|
|
66
|
+
transform: rotateY(180deg);
|
|
67
|
+
transform-origin: left;
|
|
68
|
+
}
|
|
69
|
+
&.right {
|
|
70
|
+
right: 0;
|
|
71
|
+
}
|
|
72
|
+
&.half {
|
|
73
|
+
svg:hover {
|
|
74
|
+
color: ${colors[color] || color} !important;
|
|
75
|
+
}
|
|
76
|
+
&.chosen svg {
|
|
77
|
+
color: ${colors.chosen[color] || color};
|
|
78
|
+
}
|
|
79
|
+
&.right.chosen + span {
|
|
80
|
+
svg {
|
|
81
|
+
color: ${colors.chosen[color] || color};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
&.right:hover + span {
|
|
85
|
+
svg {
|
|
86
|
+
color: ${colors[color] || color} !important;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
const RatingItem = css`
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
position: relative;
|
|
94
|
+
align-items: center;
|
|
95
|
+
transition: color 0.15s linear;
|
|
96
|
+
color: ${colors.default};
|
|
97
|
+
&:hover {
|
|
98
|
+
color: ${colors[color] || color} !important;
|
|
99
|
+
}
|
|
100
|
+
&:hover ~ span {
|
|
101
|
+
color: ${colors[color] || color} !important;
|
|
102
|
+
}
|
|
103
|
+
&:hover ~ span > span.css-${RatingItemHaft.name},
|
|
104
|
+
${half ? '' : `&:hover,`}
|
|
105
|
+
&:hover ~ span.full {
|
|
106
|
+
svg {
|
|
107
|
+
color: ${colors[color] || color} !important;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
&.chosen {
|
|
111
|
+
color: ${colors.chosen[color] || color};
|
|
112
|
+
}
|
|
113
|
+
&.chosen ~ span {
|
|
114
|
+
color: ${colors.chosen[color] || color};
|
|
115
|
+
}
|
|
116
|
+
&.chosen ~ span > span.css-${RatingItemHaft.name},
|
|
117
|
+
${half ? '' : `&.chosen,`}
|
|
118
|
+
&.chosen ~ span.full {
|
|
119
|
+
svg {
|
|
120
|
+
color: ${colors.chosen[color] || color};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
&.disabled {
|
|
124
|
+
color: ${theme.colors.disabled} !important;
|
|
125
|
+
&.chosen {
|
|
126
|
+
color: ${theme.colors.disabled} !important;
|
|
127
|
+
svg {
|
|
128
|
+
color: ${theme.colors.disabled} !important;
|
|
129
|
+
}
|
|
130
|
+
.DGN-UI-Rating-Item-Star.half.right:not(.chosen) {
|
|
131
|
+
svg {
|
|
132
|
+
color: transparent !important;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
&.chosen ~ span {
|
|
137
|
+
color: ${theme.colors.disabled} !important;
|
|
138
|
+
}
|
|
139
|
+
&.chosen ~ span > span.css-${RatingItemHaft.name},
|
|
140
|
+
&.chosen ~ span.full {
|
|
141
|
+
svg {
|
|
142
|
+
color: ${theme.colors.disabled} !important;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
const RatingSelect = css`
|
|
148
|
+
position: relative;
|
|
149
|
+
outline: none;
|
|
150
|
+
font-family: ${theme.typography.fontFamily};
|
|
151
|
+
margin-left: 4px;
|
|
152
|
+
color: ${theme.colors.default};
|
|
153
|
+
border-color: ${theme.colors.default};
|
|
154
|
+
`;
|
|
155
|
+
const RatingRoot = css`
|
|
156
|
+
display: inline-flex;
|
|
157
|
+
flex-direction: row-reverse;
|
|
158
|
+
position: relative;
|
|
159
|
+
&.disabled {
|
|
160
|
+
pointer-events: none;
|
|
161
|
+
}
|
|
162
|
+
&.read-only {
|
|
163
|
+
pointer-events: none;
|
|
164
|
+
.DGN-UI-Rating-Item {
|
|
165
|
+
pointer-events: none;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
const onRatingHandler = (e, num, halfRating = 0) => {
|
|
171
|
+
removeChosenRating();
|
|
172
|
+
|
|
173
|
+
if (half) {
|
|
174
|
+
e.currentTarget.parentNode.classList.add('chosen');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
e.currentTarget.classList.add('chosen');
|
|
178
|
+
|
|
179
|
+
if (selectRef.current) {
|
|
180
|
+
selectRef.current.value = num + halfRating / 2;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
e.value = num + halfRating / 2;
|
|
184
|
+
!!onRating && onRating(e);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const onSelectValue = e => {
|
|
188
|
+
const newValue = +e.target.value;
|
|
189
|
+
e.value = newValue;
|
|
190
|
+
setRating(newValue);
|
|
191
|
+
!!onRating && onRating(e);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const setRating = star => {
|
|
195
|
+
removeChosenRating();
|
|
196
|
+
|
|
197
|
+
if (star > quantity) {
|
|
198
|
+
star = quantity;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const position = quantity - Math.floor(star);
|
|
202
|
+
const childNodes = ref.current.querySelectorAll(`.css-${RatingItem.name}`);
|
|
203
|
+
|
|
204
|
+
if (half) {
|
|
205
|
+
const halfRating = star * 10 % 10;
|
|
206
|
+
|
|
207
|
+
if (halfRating >= 5) {
|
|
208
|
+
childNodes[position - 1].classList.add('chosen');
|
|
209
|
+
childNodes[position - 1].querySelector('span.left').classList.add('chosen');
|
|
210
|
+
} else if (star > 0) {
|
|
211
|
+
childNodes[position].classList.add('chosen');
|
|
212
|
+
childNodes[position].querySelector('span.right').classList.add('chosen');
|
|
213
|
+
}
|
|
214
|
+
} else if (star >= 1) {
|
|
215
|
+
childNodes[position].classList.add('chosen');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (selectRef.current) {
|
|
219
|
+
selectRef.current.value = star;
|
|
220
|
+
|
|
221
|
+
if (selectRef.current.firstChild && !selectRef.current.firstChild.value) {
|
|
222
|
+
selectRef.current.firstChild.remove();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const removeChosenRating = () => {
|
|
228
|
+
const chosenNode = ref.current.querySelectorAll('.chosen');
|
|
229
|
+
|
|
230
|
+
if (chosenNode && chosenNode.length) {
|
|
231
|
+
chosenNode.forEach(node => {
|
|
232
|
+
node.classList.remove('chosen');
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
if (defaultValue) {
|
|
239
|
+
setRating(defaultValue);
|
|
240
|
+
}
|
|
241
|
+
}, []);
|
|
242
|
+
useEffect(() => {
|
|
243
|
+
if (disabled) {
|
|
244
|
+
ref.current.classList.add('disabled');
|
|
245
|
+
ref.current.querySelectorAll('.DGN-UI-Rating-Item').forEach(star => {
|
|
246
|
+
star.classList.add('disabled');
|
|
247
|
+
});
|
|
248
|
+
return () => {
|
|
249
|
+
if (ref.current) {
|
|
250
|
+
ref.current.classList.remove('disabled');
|
|
251
|
+
ref.current.querySelectorAll('.DGN-UI-Rating-Item').forEach(star => {
|
|
252
|
+
star.classList.remove('disabled');
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}, [disabled]);
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
if (typeof value === 'number') {
|
|
260
|
+
setRating(value);
|
|
261
|
+
}
|
|
262
|
+
}, [value, quantity, half]);
|
|
263
|
+
return useMemo(() => {
|
|
264
|
+
const ArrayRating = [];
|
|
265
|
+
|
|
266
|
+
if (width) {
|
|
267
|
+
height = width === 20 ? 19 : width * 19 / 20;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (!width && height) {
|
|
271
|
+
width = height * 20 / 19;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
for (let i = 0; i < quantity; i++) {
|
|
275
|
+
ArrayRating.push(i);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return jsx("div", _extends({
|
|
279
|
+
css: RatingRoot,
|
|
280
|
+
ref: ref,
|
|
281
|
+
style: style,
|
|
282
|
+
className: ['DGN-UI-Rating', className, readOnly ? 'read-only' : ''].join(' ').trim()
|
|
283
|
+
}, props), selector && jsx("select", {
|
|
284
|
+
css: RatingSelect,
|
|
285
|
+
ref: selectRef,
|
|
286
|
+
name: `Rating-Select-${unique}`,
|
|
287
|
+
id: `Rating-Select-${unique}`,
|
|
288
|
+
disabled: disabled,
|
|
289
|
+
readOnly: readOnly,
|
|
290
|
+
onChange: onSelectValue
|
|
291
|
+
}, jsx("option", {
|
|
292
|
+
value: '',
|
|
293
|
+
id: unique + '-0'
|
|
294
|
+
}, 0), ArrayRating.map(i => half ? jsx(Fragment, {
|
|
295
|
+
key: i
|
|
296
|
+
}, jsx("option", {
|
|
297
|
+
value: i + 0.5
|
|
298
|
+
}, i + 0.5), jsx("option", {
|
|
299
|
+
value: i + 1
|
|
300
|
+
}, i + 1)) : jsx("option", {
|
|
301
|
+
key: i,
|
|
302
|
+
value: i + 1
|
|
303
|
+
}, i + 1))), ArrayRating.map(i => jsx("span", {
|
|
304
|
+
css: RatingItem,
|
|
305
|
+
style: starStyle,
|
|
306
|
+
key: i,
|
|
307
|
+
className: 'DGN-UI-Rating-Item',
|
|
308
|
+
onClick: half || disabled || readOnly ? undefined : e => onRatingHandler(e, quantity - i)
|
|
309
|
+
}, jsx(Star, {
|
|
310
|
+
width: width,
|
|
311
|
+
height: height,
|
|
312
|
+
outline: true,
|
|
313
|
+
color: color || 'currentColor'
|
|
314
|
+
}), jsx("span", {
|
|
315
|
+
css: RatingItemHaft,
|
|
316
|
+
className: 'DGN-UI-Rating-Item-Star right' + (half ? ' half' : ''),
|
|
317
|
+
onClick: half && !disabled && !readOnly ? e => onRatingHandler(e, quantity - i - 1, 2) : undefined
|
|
318
|
+
}, jsx(Star, {
|
|
319
|
+
half: true,
|
|
320
|
+
width: width * 2 / 5,
|
|
321
|
+
height: height * 14 / 19,
|
|
322
|
+
color: 'currentColor'
|
|
323
|
+
})), jsx("span", {
|
|
324
|
+
css: RatingItemHaft,
|
|
325
|
+
className: 'DGN-UI-Rating-Item-Star left' + (half ? ' half' : ''),
|
|
326
|
+
onClick: half && !disabled && !readOnly ? e => onRatingHandler(e, quantity - i - 1, 1) : undefined
|
|
327
|
+
}, jsx(Star, {
|
|
328
|
+
half: true,
|
|
329
|
+
width: width * 2 / 5,
|
|
330
|
+
height: height * 14 / 19,
|
|
331
|
+
color: 'currentColor'
|
|
332
|
+
})))));
|
|
333
|
+
}, [half, color, quantity, readOnly, disabled, selector, width, height, onRating]);
|
|
334
|
+
}));
|
|
335
|
+
Rating.defaultProps = {
|
|
336
|
+
disabled: false,
|
|
337
|
+
readOnly: false,
|
|
338
|
+
half: false,
|
|
339
|
+
selector: false,
|
|
340
|
+
width: 20,
|
|
341
|
+
quantity: 5,
|
|
342
|
+
defaultValue: 0,
|
|
343
|
+
color: 'primary',
|
|
344
|
+
className: ''
|
|
345
|
+
};
|
|
346
|
+
Rating.propTypes = {
|
|
347
|
+
/** prevent all events and effect */
|
|
348
|
+
disabled: PropTypes.bool,
|
|
349
|
+
|
|
350
|
+
/** prevent all events and effect and keep style */
|
|
351
|
+
readOnly: PropTypes.bool,
|
|
352
|
+
|
|
353
|
+
/** allows rating with an odd number of stars */
|
|
354
|
+
half: PropTypes.bool,
|
|
355
|
+
|
|
356
|
+
/** display select box to select by number */
|
|
357
|
+
selector: PropTypes.bool,
|
|
358
|
+
|
|
359
|
+
/** The default number of stars is selected */
|
|
360
|
+
defaultValue: PropTypes.number,
|
|
361
|
+
|
|
362
|
+
/** The number of stars is selected */
|
|
363
|
+
value: PropTypes.number,
|
|
364
|
+
|
|
365
|
+
/** the maximum number of stars allowed to rate */
|
|
366
|
+
quantity: PropTypes.number,
|
|
367
|
+
|
|
368
|
+
/** width of star icon */
|
|
369
|
+
width: PropTypes.number,
|
|
370
|
+
|
|
371
|
+
/** height of star icon */
|
|
372
|
+
height: PropTypes.number,
|
|
373
|
+
|
|
374
|
+
/** color of stars, ['primary', 'info', 'success', 'warning', 'danger', #hex, rgb(#, #, #)] */
|
|
375
|
+
color: PropTypes.string,
|
|
376
|
+
|
|
377
|
+
/** class name of Rating component */
|
|
378
|
+
className: PropTypes.string,
|
|
379
|
+
|
|
380
|
+
/** style inline of Rating component */
|
|
381
|
+
style: PropTypes.object,
|
|
382
|
+
|
|
383
|
+
/** style inline of stars icon */
|
|
384
|
+
starStyle: PropTypes.object,
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* the function for rating handler, return e:{value, ...element}<br />
|
|
388
|
+
* value: the quantity of star was selected (insist half)
|
|
389
|
+
*/
|
|
390
|
+
onRating: PropTypes.func
|
|
391
|
+
};
|
|
392
|
+
export default Rating;
|