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,633 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** @jsxRuntime classic */
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { memo, useEffect, useRef, forwardRef, useState, useImperativeHandle } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import locale from '../../../locale';
|
|
10
|
+
import { InputBase, Label, HelperText } from '../../';
|
|
11
|
+
import { onValidate } from '../../../utils';
|
|
12
|
+
const NumberInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
13
|
+
viewType,
|
|
14
|
+
required,
|
|
15
|
+
disabledNegative,
|
|
16
|
+
nonStyle,
|
|
17
|
+
decimalDigit: decimalDigitProp,
|
|
18
|
+
decimalSymbol,
|
|
19
|
+
label,
|
|
20
|
+
defaultValue,
|
|
21
|
+
value,
|
|
22
|
+
min,
|
|
23
|
+
max,
|
|
24
|
+
step,
|
|
25
|
+
placeholder,
|
|
26
|
+
startIcon,
|
|
27
|
+
endIcon,
|
|
28
|
+
valueTypeReturn,
|
|
29
|
+
autoComplete,
|
|
30
|
+
autoFocus,
|
|
31
|
+
disabled,
|
|
32
|
+
readOnly,
|
|
33
|
+
refs,
|
|
34
|
+
inputRef,
|
|
35
|
+
inputProps,
|
|
36
|
+
iconStyle,
|
|
37
|
+
inputStyle,
|
|
38
|
+
labelProps,
|
|
39
|
+
errorProps,
|
|
40
|
+
error,
|
|
41
|
+
format,
|
|
42
|
+
onChange,
|
|
43
|
+
onBlur,
|
|
44
|
+
onFocus,
|
|
45
|
+
onInput,
|
|
46
|
+
onKeyDown,
|
|
47
|
+
onKeyUp,
|
|
48
|
+
validates,
|
|
49
|
+
...props
|
|
50
|
+
}, reference) => {
|
|
51
|
+
const ref = useRef(null);
|
|
52
|
+
const local = useRef({
|
|
53
|
+
isSpecialSymbol: false,
|
|
54
|
+
isDeleteDecimalSymbol: false,
|
|
55
|
+
isPaste: false,
|
|
56
|
+
clipboardText: ''
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (!inputRef) {
|
|
60
|
+
inputRef = useRef(null);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const separatorSymbol = useRef(decimalSymbol === '.' ? ',' : '.');
|
|
64
|
+
const updated = useRef(false);
|
|
65
|
+
const [decimalDigit, setDecimalDigit] = useState(decimalDigitProp);
|
|
66
|
+
const formatPattern = new RegExp(`[0-9]|Backspace|Delete|Arrow|Home|End|Tab${decimalDigit === 0 ? '' : '|\\' + decimalSymbol}${disabledNegative ? '' : '|\-'}`);
|
|
67
|
+
/* Start styled */
|
|
68
|
+
|
|
69
|
+
const NumberInputRoot = css`
|
|
70
|
+
display: block;
|
|
71
|
+
position: relative;
|
|
72
|
+
margin-bottom: 20px;
|
|
73
|
+
`;
|
|
74
|
+
/* End styled */
|
|
75
|
+
|
|
76
|
+
/* Start handler */
|
|
77
|
+
|
|
78
|
+
const getFormat = v => {
|
|
79
|
+
var _format$match;
|
|
80
|
+
|
|
81
|
+
let [number, decimal = ''] = v.split(decimalSymbol);
|
|
82
|
+
let existDecimalSymbol = v.includes(decimalSymbol);
|
|
83
|
+
if (!number || String(+number) === 'NaN') return number;
|
|
84
|
+
|
|
85
|
+
if (typeof format === 'function') {
|
|
86
|
+
return format(number);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (/^#.###$/.test(format)) {
|
|
90
|
+
return number.replace(/\B(?=(\d{3})+(?!\d))/g, separatorSymbol.current) + (existDecimalSymbol ? decimalSymbol + decimal : '');
|
|
91
|
+
} // #.##.###, #.### %%
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
const numberFormat = format.slice(0, format.lastIndexOf('#') + 1);
|
|
95
|
+
|
|
96
|
+
if (numberFormat) {
|
|
97
|
+
if (/^#.###$/.test(numberFormat)) {
|
|
98
|
+
number = number.replace(/\B(?=(\d{3})+(?!\d))/g, separatorSymbol.current);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const dFormat = (_format$match = format.match(/(\d+)?%+$/g)) === null || _format$match === void 0 ? void 0 : _format$match[0];
|
|
103
|
+
|
|
104
|
+
if (dFormat && decimal) {
|
|
105
|
+
const dDigit = +(dFormat.replaceAll('%', '') || dFormat.length);
|
|
106
|
+
|
|
107
|
+
if (dDigit === 0) {
|
|
108
|
+
existDecimalSymbol = false;
|
|
109
|
+
decimal = '';
|
|
110
|
+
} else if (decimal && decimal.length > dDigit) {
|
|
111
|
+
decimal = decimal.slice(0, dDigit);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return number + (existDecimalSymbol ? decimalSymbol + decimal : '');
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const getValueWithDecimal = v => {
|
|
119
|
+
if (v && typeof decimalDigit === 'number') {
|
|
120
|
+
let [number, decimal] = v.split(decimalSymbol);
|
|
121
|
+
|
|
122
|
+
if (decimal && decimal.length > decimalDigit) {
|
|
123
|
+
if (decimalDigit) {
|
|
124
|
+
decimal = decimal.slice(0, decimalDigit);
|
|
125
|
+
return number + decimalSymbol + decimal;
|
|
126
|
+
} else {
|
|
127
|
+
return number;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return v;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const isDeleteSymbol = v => {
|
|
136
|
+
const valueArr = v.split(separatorSymbol.current);
|
|
137
|
+
|
|
138
|
+
for (let i = 0; i < valueArr.length; i++) {
|
|
139
|
+
if (valueArr[i].length > 3) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return false;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const onKeyDownHandler = e => {
|
|
148
|
+
const key = e.key;
|
|
149
|
+
const keyCode = e.keyCode;
|
|
150
|
+
const value = inputRef.current.value;
|
|
151
|
+
let cursor = inputRef.current.selectionStart;
|
|
152
|
+
|
|
153
|
+
if (key.charCodeAt(0) > 127) {
|
|
154
|
+
local.current.isSpecialSymbol = true;
|
|
155
|
+
|
|
156
|
+
if (local.current.currentKeyCode === 8) {
|
|
157
|
+
local.current.currentKeyCode = null;
|
|
158
|
+
inputRef.current.value = local.current.currentValue;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!formatPattern.test(key) && !(/a|x|c|v/i.test(key) && e.ctrlKey)) {
|
|
166
|
+
local.current.currentKey = key;
|
|
167
|
+
local.current.currentKeyCode = keyCode;
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (/Arrow(Up|Down)/.test(key)) {
|
|
173
|
+
const number = +value.replace(new RegExp(`[^0-9\\${decimalSymbol}\\-]`, 'g'), '').replace(decimalSymbol, '.');
|
|
174
|
+
const plusNumber = key === 'ArrowDown' ? -step : step;
|
|
175
|
+
let result = number + plusNumber;
|
|
176
|
+
|
|
177
|
+
if (result < min) {
|
|
178
|
+
result = min;
|
|
179
|
+
} else if (result > max) {
|
|
180
|
+
result = max;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (result !== number) {
|
|
184
|
+
local.current.currentKey = key;
|
|
185
|
+
result = result.toString().replace('.', decimalSymbol);
|
|
186
|
+
inputRef.current.value = result;
|
|
187
|
+
onChangeHandler({
|
|
188
|
+
target: inputRef.current
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (keyCode === 8) {
|
|
197
|
+
if (local.current.currentKeyCode === 231 || local.current.isSpecialSymbol) {
|
|
198
|
+
setTimeout(() => {
|
|
199
|
+
local.current.isSpecialSymbol = false;
|
|
200
|
+
}, 100);
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
local.current.currentKeyCode = 8;
|
|
206
|
+
local.current.currentValue = value;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (value.includes('-') && cursor === 0 && /[1-9]/.test(key)) {
|
|
210
|
+
inputRef.current.value = value.replace('-', `-${key}`);
|
|
211
|
+
inputRef.current.setSelectionRange(2, 2);
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (key === '-' && (cursor !== 0 || value[0] === '-') || key === decimalSymbol && value.includes(key)) {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (/x/i.test(key)) {
|
|
222
|
+
local.current.clipboardText = window.getSelection().toString();
|
|
223
|
+
} else if (/\d/.test(key)) {
|
|
224
|
+
local.current.currentValue = value;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
local.current.isSpecialSymbol = false;
|
|
228
|
+
local.current.isDeleteDecimalSymbol = key === 'Backspace' && value[cursor - 1] === decimalSymbol;
|
|
229
|
+
local.current.currentKey = key;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const onPasteHandler = e => {
|
|
233
|
+
var _local$current$clipbo;
|
|
234
|
+
|
|
235
|
+
const value = e.target.value;
|
|
236
|
+
const existMinus = value.includes('-');
|
|
237
|
+
const pattern = new RegExp(`^${disabledNegative || existMinus ? '' : '-?'}(?:\\d{1,3}(?:,\\d{3})*|\\d+)?(?:\\${decimalSymbol}(\\d+)?)?$`, 'g');
|
|
238
|
+
local.current.clipboardText = (e.clipboardData || window.clipboardData).getData('text');
|
|
239
|
+
const decimalSymbolDigit = (_local$current$clipbo = local.current.clipboardText.match(new RegExp(decimalSymbol, 'g'))) === null || _local$current$clipbo === void 0 ? void 0 : _local$current$clipbo.length;
|
|
240
|
+
let selectionText = window.getSelection().toString(); // Only includes number and decimalSymbol
|
|
241
|
+
|
|
242
|
+
if (!pattern.test(local.current.clipboardText.replaceAll(separatorSymbol.current, '')) || decimalSymbolDigit && value.includes(decimalSymbol) && !selectionText.includes(decimalSymbol)) {
|
|
243
|
+
e.preventDefault();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
local.current.isPaste = true;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const onChangeHandler = e => {
|
|
251
|
+
const value = e.target.value.replace(new RegExp(`[^0-9\\${decimalSymbol}\\${separatorSymbol.current}\\-]`, 'g'), '');
|
|
252
|
+
|
|
253
|
+
if (!value) {
|
|
254
|
+
e.value = null;
|
|
255
|
+
!!onChange && onChange(e);
|
|
256
|
+
e.value = undefined;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
let result = getValueWithMinMax(value);
|
|
261
|
+
|
|
262
|
+
if (/\d/.test(local.current.currentKey)) {
|
|
263
|
+
if (!!+result && result === getValueWithMinMax(value.replace(local.current.currentKey, ''))) {
|
|
264
|
+
e.target.value = local.current.currentValue;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
let cursor = e.target.selectionStart;
|
|
270
|
+
const el = { ...e
|
|
271
|
+
};
|
|
272
|
+
el.target = { ...e.target
|
|
273
|
+
};
|
|
274
|
+
const hasDecimal = result.includes(decimalSymbol);
|
|
275
|
+
let [number, decimal = ''] = result.split(decimalSymbol);
|
|
276
|
+
|
|
277
|
+
if (hasDecimal) {
|
|
278
|
+
if (typeof decimalDigit === 'number') {
|
|
279
|
+
decimal = decimal.replaceAll(separatorSymbol.current, '').substr(0, decimalDigit);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
decimal = (hasDecimal ? decimalSymbol : '') + decimal;
|
|
283
|
+
result = number + decimal;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (format && (formatPattern.test(local.current.currentKey) || local.current.isPaste || /x|Arrow(Up|Down)/i.test(local.current.currentKey))) {
|
|
287
|
+
const decimalSymbolIndex = result.indexOf(decimalSymbol);
|
|
288
|
+
number = number.replaceAll(separatorSymbol.current, '');
|
|
289
|
+
|
|
290
|
+
if (local.current.currentKey === decimalSymbol) {
|
|
291
|
+
cursor = number.length + Math.ceil(number.length / 3);
|
|
292
|
+
} else if (!isNaN(local.current.currentKey)) {
|
|
293
|
+
if ((decimalSymbolIndex === -1 || cursor <= decimalSymbolIndex) && number.length % 3 === 1) {
|
|
294
|
+
cursor++;
|
|
295
|
+
}
|
|
296
|
+
} else if (local.current.currentKey === 'Backspace') {
|
|
297
|
+
if (local.current.isDeleteDecimalSymbol) {
|
|
298
|
+
cursor++;
|
|
299
|
+
} else if (number.length % 3 === 0 && !isDeleteSymbol(value)) {
|
|
300
|
+
cursor--;
|
|
301
|
+
}
|
|
302
|
+
} else if (local.current.currentKey === 'Delete') {
|
|
303
|
+
if (isDeleteSymbol(value)) {
|
|
304
|
+
cursor++;
|
|
305
|
+
} else if (number.length % 3 === 0 && value[cursor] !== separatorSymbol.current) {
|
|
306
|
+
cursor--;
|
|
307
|
+
}
|
|
308
|
+
} else if (local.current.isPaste) {
|
|
309
|
+
var _result$slice$match, _local$current$clipbo2;
|
|
310
|
+
|
|
311
|
+
const simpleNumber = number + decimal;
|
|
312
|
+
const cursorBefore = cursor - local.current.clipboardText.length;
|
|
313
|
+
const cursorAfter = cursorBefore - (((_result$slice$match = result.slice(0, cursorBefore).match(new RegExp(`\\${separatorSymbol.current}`, 'g'))) === null || _result$slice$match === void 0 ? void 0 : _result$slice$match.length) || 0) + local.current.clipboardText.length;
|
|
314
|
+
const decimalSymbolIndex = (simpleNumber.indexOf(decimalSymbol) + 1 || number.length + 1) - 1;
|
|
315
|
+
const spaceQuantity = Math.floor((number.length - 1) / 3) - Math.floor(Math.max(0, decimalSymbolIndex - cursorAfter) / 3);
|
|
316
|
+
cursor = cursorAfter + spaceQuantity - (((_local$current$clipbo2 = local.current.clipboardText.match(new RegExp(`\\${separatorSymbol.current}`, 'g'))) === null || _local$current$clipbo2 === void 0 ? void 0 : _local$current$clipbo2.length) || 0);
|
|
317
|
+
local.current.isPaste = false;
|
|
318
|
+
local.current.clipboardText = '';
|
|
319
|
+
} else if (/x/i.test(local.current.currentKey)) {
|
|
320
|
+
cursor -= +(Math.ceil(number.length / 3) !== Math.ceil((number.length + local.current.clipboardText.length) / 3));
|
|
321
|
+
} else if (/Arrow(Up|Down)/i.test(local.current.currentKey)) {
|
|
322
|
+
cursor += Math.floor((number.length - 1) / 3);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
result = number + decimal;
|
|
326
|
+
cursor = Math.max(0, cursor);
|
|
327
|
+
e.target.value = getFormat(number) + decimal;
|
|
328
|
+
e.target.setSelectionRange(cursor, cursor);
|
|
329
|
+
} else {
|
|
330
|
+
e.target.value = result;
|
|
331
|
+
e.target.setSelectionRange(cursor, cursor);
|
|
332
|
+
} // el.target.value = result;
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
if (valueTypeReturn === 'string') {
|
|
336
|
+
el.value = result;
|
|
337
|
+
} else {
|
|
338
|
+
el.value = String(+result.replace(',', '.')) !== 'NaN' ? +result.replace(',', '.') : result;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
!!onChange && onChange(el);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const onBlurHandler = e => {
|
|
345
|
+
const v = e.target.value.replace(new RegExp(`[^0-9\\${decimalSymbol}\\-]`, 'g'), '').replace(decimalSymbol, '.');
|
|
346
|
+
|
|
347
|
+
if (v !== getValueWithMinMax(v)) {
|
|
348
|
+
e.target.value = getValueWithMinMax(v);
|
|
349
|
+
onChangeHandler(e);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
!!onBlur && onBlur(e);
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
const setValueIntoInput = v => {
|
|
356
|
+
if (v === null || v === undefined) {
|
|
357
|
+
inputRef.current.value = '';
|
|
358
|
+
} else {
|
|
359
|
+
v = getValueWithDecimal(getValueWithMinMax(v).replace('.', decimalSymbol));
|
|
360
|
+
inputRef.current.value = format ? getFormat(v) : v;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const getValueWithMinMax = v => {
|
|
365
|
+
v = v.toString().replace(new RegExp(`[^0-9\\${decimalSymbol}\\-]`, 'g'), '').replace(decimalSymbol, '.');
|
|
366
|
+
|
|
367
|
+
if (+v < min) {
|
|
368
|
+
v = min.toString();
|
|
369
|
+
} else if (+v > max) {
|
|
370
|
+
v = max.toString();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return v.replace('.', decimalSymbol);
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
useEffect(() => {
|
|
377
|
+
if (format) {
|
|
378
|
+
if (typeof format === 'string') {
|
|
379
|
+
const numberFormat = format.slice(0, format.lastIndexOf('#') + 1);
|
|
380
|
+
|
|
381
|
+
if (/^#.###$/.test(numberFormat)) {
|
|
382
|
+
separatorSymbol.current = format[1];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (updated.current) {
|
|
387
|
+
const v = inputRef.current.value;
|
|
388
|
+
|
|
389
|
+
if (v) {
|
|
390
|
+
setValueIntoInput(v);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}, [format]);
|
|
395
|
+
useEffect(() => {
|
|
396
|
+
!!refs && refs(ref);
|
|
397
|
+
|
|
398
|
+
if (defaultValue !== undefined && defaultValue !== '') {
|
|
399
|
+
setValueIntoInput(defaultValue);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
inputRef.current.addEventListener('focus', () => {
|
|
403
|
+
inputRef.current.addEventListener('keydown', onKeyDownHandler);
|
|
404
|
+
}, {
|
|
405
|
+
once: true
|
|
406
|
+
});
|
|
407
|
+
}, []);
|
|
408
|
+
useEffect(() => {
|
|
409
|
+
if (placeholder !== undefined) {
|
|
410
|
+
inputRef.current.placeholder = placeholder;
|
|
411
|
+
}
|
|
412
|
+
}, [placeholder]);
|
|
413
|
+
useEffect(() => {
|
|
414
|
+
if (value !== undefined || updated.current) {
|
|
415
|
+
setValueIntoInput(value);
|
|
416
|
+
}
|
|
417
|
+
}, [value]);
|
|
418
|
+
useEffect(() => {
|
|
419
|
+
let dDigit = decimalDigitProp;
|
|
420
|
+
|
|
421
|
+
if (format && typeof format === 'string') {
|
|
422
|
+
var _format$match2;
|
|
423
|
+
|
|
424
|
+
const dFormat = (_format$match2 = format.match(/(\d+)?%+$/g)) === null || _format$match2 === void 0 ? void 0 : _format$match2[0];
|
|
425
|
+
|
|
426
|
+
if (dFormat) {
|
|
427
|
+
dDigit = +(dFormat.replaceAll('%', '') || dFormat.length);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
setDecimalDigit(dDigit);
|
|
432
|
+
|
|
433
|
+
if (typeof dDigit === 'number') {
|
|
434
|
+
const valueInput = inputRef.current.value;
|
|
435
|
+
|
|
436
|
+
if (valueInput) {
|
|
437
|
+
let [number, decimal] = valueInput.split(decimalSymbol);
|
|
438
|
+
|
|
439
|
+
if (decimal && decimal.length > dDigit) {
|
|
440
|
+
if (dDigit) {
|
|
441
|
+
decimal = decimal.slice(0, dDigit);
|
|
442
|
+
inputRef.current.value = number + decimalSymbol + decimal;
|
|
443
|
+
} else {
|
|
444
|
+
inputRef.current.value = number;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (!updated.current) {
|
|
451
|
+
updated.current = true;
|
|
452
|
+
}
|
|
453
|
+
}, [decimalDigitProp, format]);
|
|
454
|
+
/* End handler */
|
|
455
|
+
|
|
456
|
+
const validateResult = validates && onValidate(value, validates, true);
|
|
457
|
+
useImperativeHandle(reference, () => {
|
|
458
|
+
ref.current.getFormat = getFormat;
|
|
459
|
+
ref.current.setValueIntoInput = setValueIntoInput;
|
|
460
|
+
ref.current.getValueWithMinMax = getValueWithMinMax;
|
|
461
|
+
return ref.current;
|
|
462
|
+
});
|
|
463
|
+
return jsx("div", _extends({
|
|
464
|
+
ref: ref,
|
|
465
|
+
css: NumberInputRoot
|
|
466
|
+
}, props), !!label && jsx(Label, {
|
|
467
|
+
required: required,
|
|
468
|
+
disabled: disabled
|
|
469
|
+
}, label), jsx(InputBase, {
|
|
470
|
+
inputRef: inputRef,
|
|
471
|
+
viewType: viewType,
|
|
472
|
+
defaultValue: defaultValue,
|
|
473
|
+
value: value,
|
|
474
|
+
placeholder: placeholder,
|
|
475
|
+
autoFocus: autoFocus,
|
|
476
|
+
disabled: disabled,
|
|
477
|
+
readOnly: readOnly,
|
|
478
|
+
status: !!error || validateResult ? 'danger' : 'default',
|
|
479
|
+
inputProps: inputProps,
|
|
480
|
+
inputStyle: inputStyle,
|
|
481
|
+
startIcon: startIcon,
|
|
482
|
+
endIcon: endIcon,
|
|
483
|
+
nonStyle: nonStyle,
|
|
484
|
+
onChange: onChangeHandler,
|
|
485
|
+
onBlur: onBlurHandler,
|
|
486
|
+
onFocus: onFocus,
|
|
487
|
+
onInput: onInput,
|
|
488
|
+
onKeyDown: onKeyDown,
|
|
489
|
+
onKeyUp: onKeyUp,
|
|
490
|
+
onPaste: onPasteHandler
|
|
491
|
+
}), !!error && jsx(HelperText, {
|
|
492
|
+
disabled: disabled
|
|
493
|
+
}, error), !error && validateResult && jsx(HelperText, {
|
|
494
|
+
disabled: disabled
|
|
495
|
+
}, validateResult));
|
|
496
|
+
}));
|
|
497
|
+
NumberInput.defaultProps = {
|
|
498
|
+
viewType: 'underlined',
|
|
499
|
+
label: '',
|
|
500
|
+
placeholder: '',
|
|
501
|
+
error: '',
|
|
502
|
+
startIcon: '',
|
|
503
|
+
endIcon: '',
|
|
504
|
+
decimalSymbol: locale.get() === 'vi' ? ',' : '.',
|
|
505
|
+
required: false,
|
|
506
|
+
nonStyle: false,
|
|
507
|
+
autoFocus: false,
|
|
508
|
+
disabled: false,
|
|
509
|
+
readOnly: false,
|
|
510
|
+
disabledNegative: false,
|
|
511
|
+
step: 1,
|
|
512
|
+
min: -Infinity,
|
|
513
|
+
max: Infinity,
|
|
514
|
+
inputProps: {}
|
|
515
|
+
};
|
|
516
|
+
NumberInput.propTypes = {
|
|
517
|
+
/** the type of border you want to display */
|
|
518
|
+
viewType: PropTypes.oneOf(['underlined', 'outlined']),
|
|
519
|
+
|
|
520
|
+
/** the type of value which you want to return */
|
|
521
|
+
valueTypeReturn: PropTypes.oneOf(['number', 'string']),
|
|
522
|
+
|
|
523
|
+
/** separator symbol */
|
|
524
|
+
decimalSymbol: PropTypes.oneOf([',', '.']),
|
|
525
|
+
|
|
526
|
+
/** default value is displayed for first render */
|
|
527
|
+
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
528
|
+
|
|
529
|
+
/** the displayed value for each change */
|
|
530
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
531
|
+
|
|
532
|
+
/** number of decimal places allowed */
|
|
533
|
+
decimalDigit: PropTypes.number,
|
|
534
|
+
|
|
535
|
+
/** min of value was allowed */
|
|
536
|
+
min: PropTypes.number,
|
|
537
|
+
|
|
538
|
+
/** max of value was allowed */
|
|
539
|
+
max: PropTypes.number,
|
|
540
|
+
|
|
541
|
+
/** step of input */
|
|
542
|
+
step: PropTypes.number,
|
|
543
|
+
|
|
544
|
+
/** label for input */
|
|
545
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
546
|
+
|
|
547
|
+
/** hints for input */
|
|
548
|
+
placeholder: PropTypes.string,
|
|
549
|
+
|
|
550
|
+
/** error for input */
|
|
551
|
+
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
552
|
+
|
|
553
|
+
/** type auto complete of input (like new-password) */
|
|
554
|
+
autoComplete: PropTypes.string,
|
|
555
|
+
|
|
556
|
+
/** icon at start */
|
|
557
|
+
startIcon: PropTypes.any,
|
|
558
|
+
|
|
559
|
+
/** icon at end */
|
|
560
|
+
endIcon: PropTypes.any,
|
|
561
|
+
|
|
562
|
+
/** prevent all event if true, hide all icon */
|
|
563
|
+
disabled: PropTypes.bool,
|
|
564
|
+
|
|
565
|
+
/** transparent border color if true */
|
|
566
|
+
nonStyle: PropTypes.bool,
|
|
567
|
+
|
|
568
|
+
/** prevent all event if true */
|
|
569
|
+
readOnly: PropTypes.bool,
|
|
570
|
+
|
|
571
|
+
/** auto focus after first render */
|
|
572
|
+
autoFocus: PropTypes.bool,
|
|
573
|
+
|
|
574
|
+
/** negative numbers are not allowed if true */
|
|
575
|
+
disabledNegative: PropTypes.bool,
|
|
576
|
+
|
|
577
|
+
/** At least one character is required */
|
|
578
|
+
required: PropTypes.bool,
|
|
579
|
+
|
|
580
|
+
/** props of input in NumberInput component */
|
|
581
|
+
inputProps: PropTypes.object,
|
|
582
|
+
|
|
583
|
+
/** style inline of input in NumberInput component */
|
|
584
|
+
inputStyle: PropTypes.object,
|
|
585
|
+
|
|
586
|
+
/** any props of label in NumberInput component */
|
|
587
|
+
labelProps: PropTypes.object,
|
|
588
|
+
|
|
589
|
+
/** any props of error in NumberInput component */
|
|
590
|
+
errorProps: PropTypes.object,
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* the format to display value<br/>
|
|
594
|
+
* * function: value => function(value)<br/>
|
|
595
|
+
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
596
|
+
* #: integer part digit<br/>
|
|
597
|
+
* . / '_': separator symbol<br/>
|
|
598
|
+
* %: decimal digit, '2%' === '%%'
|
|
599
|
+
*/
|
|
600
|
+
format: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
601
|
+
|
|
602
|
+
/** The function to get ref of NumberInput component */
|
|
603
|
+
refs: PropTypes.func,
|
|
604
|
+
|
|
605
|
+
/** validation value, argument can:<br/>
|
|
606
|
+
* * string: the validation rule. Example required.<br/>
|
|
607
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
608
|
+
* * array: the validation rule list, insist object/string
|
|
609
|
+
*/
|
|
610
|
+
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
611
|
+
|
|
612
|
+
/** on key down function */
|
|
613
|
+
onKeyDown: PropTypes.func,
|
|
614
|
+
|
|
615
|
+
/** on key up function */
|
|
616
|
+
onKeyUp: PropTypes.func,
|
|
617
|
+
|
|
618
|
+
/** on input function */
|
|
619
|
+
onInput: PropTypes.func,
|
|
620
|
+
|
|
621
|
+
/** on change function */
|
|
622
|
+
onChange: PropTypes.func,
|
|
623
|
+
|
|
624
|
+
/** on blur function */
|
|
625
|
+
onBlur: PropTypes.func,
|
|
626
|
+
|
|
627
|
+
/** on focus function */
|
|
628
|
+
onFocus: PropTypes.func,
|
|
629
|
+
|
|
630
|
+
/** inputRef of NumberInput component */
|
|
631
|
+
inputRef: PropTypes.any
|
|
632
|
+
};
|
|
633
|
+
export default NumberInput;
|