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,95 @@
|
|
|
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 } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import { white, dark12, brand13 } from '../../../styles/colors';
|
|
10
|
+
const getPosition = {
|
|
11
|
+
bottom: `
|
|
12
|
+
overflow-x: auto;
|
|
13
|
+
word-wrap: no-wrap;
|
|
14
|
+
`,
|
|
15
|
+
right: `
|
|
16
|
+
overflow-x: auto;
|
|
17
|
+
`,
|
|
18
|
+
left: `
|
|
19
|
+
overflow-x: auto;
|
|
20
|
+
direction: rtl;
|
|
21
|
+
text-align: left;
|
|
22
|
+
`
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const scrollbar = ({
|
|
26
|
+
backgroundScroll,
|
|
27
|
+
backgroundThumb,
|
|
28
|
+
backgroundThumbHover,
|
|
29
|
+
children,
|
|
30
|
+
maxWidth,
|
|
31
|
+
maxHeight,
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
style,
|
|
35
|
+
position,
|
|
36
|
+
custom,
|
|
37
|
+
...props
|
|
38
|
+
}) => {
|
|
39
|
+
const Scrollbar = css`
|
|
40
|
+
position: relative;
|
|
41
|
+
display: block;
|
|
42
|
+
padding: 8px 8px;
|
|
43
|
+
margin-right: 8px;
|
|
44
|
+
max-width: ${maxWidth ? isNaN(maxWidth) ? maxWidth : maxWidth + 'px' : '100%'};
|
|
45
|
+
max-height: ${maxHeight ? isNaN(maxHeight) ? maxHeight : maxHeight + 'px' : '100%'};
|
|
46
|
+
&::-webkit-scrollbar{
|
|
47
|
+
width: ${width ? isNaN(width) ? width : width + 'px' : '8px'};
|
|
48
|
+
height: ${height ? isNaN(height) ? height : height + 'px' : '8px'};
|
|
49
|
+
background-color: ${backgroundScroll};
|
|
50
|
+
}
|
|
51
|
+
&::-webkit-scrollbar-thumb{
|
|
52
|
+
border-radius: 10px;
|
|
53
|
+
mix-blend-mode: normal;
|
|
54
|
+
background-color: ${backgroundThumb};
|
|
55
|
+
background-clip: content-box;
|
|
56
|
+
}
|
|
57
|
+
&::-webkit-scrollbar-thumb:hover{
|
|
58
|
+
border-radius: 10px;
|
|
59
|
+
background-color: ${backgroundThumbHover};
|
|
60
|
+
background-clip: content-box;
|
|
61
|
+
}
|
|
62
|
+
${/tract/i.test(custom) ? `&::-webkit-scrollbar-track {
|
|
63
|
+
border-radius: 10px;
|
|
64
|
+
mix-blend-mode: normal;
|
|
65
|
+
background: rgba(21, 26, 48, 0.02);
|
|
66
|
+
}` : ''}
|
|
67
|
+
${getPosition[position]}
|
|
68
|
+
`;
|
|
69
|
+
return jsx("div", _extends({
|
|
70
|
+
css: Scrollbar,
|
|
71
|
+
custom: custom,
|
|
72
|
+
position: position,
|
|
73
|
+
style: style
|
|
74
|
+
}, props), children);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
scrollbar.defaultProps = {
|
|
78
|
+
backgroundScroll: white,
|
|
79
|
+
backgroundThumb: dark12,
|
|
80
|
+
backgroundThumbHover: brand13,
|
|
81
|
+
position: 'right',
|
|
82
|
+
width: 8
|
|
83
|
+
};
|
|
84
|
+
scrollbar.propTypes = {
|
|
85
|
+
custom: PropTypes.string,
|
|
86
|
+
position: PropTypes.string,
|
|
87
|
+
position: PropTypes.oneOf(['bottom', 'right', 'left']),
|
|
88
|
+
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
89
|
+
maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
90
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
91
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
92
|
+
style: PropTypes.object,
|
|
93
|
+
children: PropTypes.node
|
|
94
|
+
};
|
|
95
|
+
export default /*#__PURE__*/memo(scrollbar);
|
|
@@ -0,0 +1,298 @@
|
|
|
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 as _nonUse } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import theme from '../../theme/settings';
|
|
10
|
+
import { Typography } from '../';
|
|
11
|
+
import { ArrowLeft, ArrowRight } from '../../icons';
|
|
12
|
+
import locale from '../../locale';
|
|
13
|
+
import { getGlobal } from '../../global';
|
|
14
|
+
let timer = null;
|
|
15
|
+
const PagingInfo = /*#__PURE__*/memo(({
|
|
16
|
+
fullWidth,
|
|
17
|
+
size,
|
|
18
|
+
bgColor,
|
|
19
|
+
style,
|
|
20
|
+
language,
|
|
21
|
+
currentPage,
|
|
22
|
+
totalItems,
|
|
23
|
+
itemsPerPage,
|
|
24
|
+
listItemsPerPage,
|
|
25
|
+
onChangePage,
|
|
26
|
+
onChangeItemsPerPage,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
const pageNumberRef = useRef(null);
|
|
30
|
+
const ItemsPerPageRef = useRef(null);
|
|
31
|
+
const totalItemRef = useRef(null);
|
|
32
|
+
let currentPageNumber = null;
|
|
33
|
+
const pagingInfo = css`
|
|
34
|
+
display: ${fullWidth ? '' : 'inline-'}flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
font-family: ${theme.typography.fontFamily};
|
|
37
|
+
font-size: ${size === 'small' ? '14px' : '16px'};
|
|
38
|
+
background-color: ${bgColor};
|
|
39
|
+
`;
|
|
40
|
+
const totalPage = css`
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
`;
|
|
44
|
+
const iconPageCss = css`
|
|
45
|
+
display: flex;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
`;
|
|
48
|
+
const pageNumber = css`
|
|
49
|
+
display: flex;
|
|
50
|
+
margin: 0 ${size === 'small' ? 5 : 7}px;
|
|
51
|
+
font-family: inherit;
|
|
52
|
+
font-style: normal;
|
|
53
|
+
font-weight: 500;
|
|
54
|
+
font-size: inherit;
|
|
55
|
+
color: ${theme.colors.primary};
|
|
56
|
+
`;
|
|
57
|
+
const currentPageNum = css`
|
|
58
|
+
outline: none;
|
|
59
|
+
margin-right: 5px;
|
|
60
|
+
border-bottom: 1px solid transparent;
|
|
61
|
+
text-align: center;
|
|
62
|
+
min-width: 27px;
|
|
63
|
+
border-bottom: 1px solid ${theme.colors.primary};
|
|
64
|
+
&:focus {
|
|
65
|
+
border-bottom-color: ${theme.colors.primary};
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
const lineNumberStyle = css`
|
|
69
|
+
display: inline-flex;
|
|
70
|
+
outline: none;
|
|
71
|
+
color: ${theme.colors.input};
|
|
72
|
+
margin: 0 16px;
|
|
73
|
+
font-family: inherit;
|
|
74
|
+
`;
|
|
75
|
+
const listItemsPerPageStyle = css`
|
|
76
|
+
height: 19px;
|
|
77
|
+
min-width: 44px;
|
|
78
|
+
width: max-content;
|
|
79
|
+
font-family: inherit;
|
|
80
|
+
font-style: normal;
|
|
81
|
+
font-weight: 500;
|
|
82
|
+
font-size: inherit;
|
|
83
|
+
color: ${theme.colors.primary};
|
|
84
|
+
background-color: inherit;
|
|
85
|
+
border: none;
|
|
86
|
+
outline: none;
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
const onChangePageHandler = page => {
|
|
90
|
+
const currentPageInput = pageNumberRef.current.textContent;
|
|
91
|
+
const newPage = +currentPageInput + page;
|
|
92
|
+
const lastPage = +pageNumberRef.current.parentNode.lastChild.textContent.replace('/ ', '');
|
|
93
|
+
if (newPage < 1 || newPage > lastPage) return;
|
|
94
|
+
pageNumberRef.current.textContent = newPage;
|
|
95
|
+
currentPageNumber = newPage;
|
|
96
|
+
!!onChangePage && onChangePage(newPage);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const onChangePageNumber = e => {
|
|
100
|
+
let value = e.target.textContent;
|
|
101
|
+
const lastPage = +pageNumberRef.current.parentNode.lastChild.textContent.replace('/ ', '');
|
|
102
|
+
if (timer) clearTimeout(timer);
|
|
103
|
+
timer = setTimeout(() => {
|
|
104
|
+
if (value !== '' && !isNaN(value)) {
|
|
105
|
+
if (value.includes('.')) {
|
|
106
|
+
const index = value.indexOf('.');
|
|
107
|
+
|
|
108
|
+
if (index !== -1) {
|
|
109
|
+
value = value.slice(0, index);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (+value < 0) {
|
|
114
|
+
value = -value;
|
|
115
|
+
} else if (+value === 0) {
|
|
116
|
+
value = 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (+value > lastPage) {
|
|
120
|
+
value = lastPage;
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
value = currentPage;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pageNumberRef.current.textContent = +value;
|
|
127
|
+
|
|
128
|
+
if (currentPageNumber !== +value) {
|
|
129
|
+
currentPageNumber = +value;
|
|
130
|
+
!!onChangePage && onChangePage(+value);
|
|
131
|
+
}
|
|
132
|
+
}, [700]);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const onChangeItemsPerPageHandler = e => {
|
|
136
|
+
const value = +e.target.value;
|
|
137
|
+
const currentPageInput = +pageNumberRef.current.textContent;
|
|
138
|
+
const newLastPage = Math.ceil(totalItems / value);
|
|
139
|
+
pageNumberRef.current.parentNode.lastChild.textContent = '/ ' + newLastPage;
|
|
140
|
+
|
|
141
|
+
if (currentPageInput > newLastPage) {
|
|
142
|
+
onChangePageHandler(newLastPage - currentPageInput);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (onChangeItemsPerPage) onChangeItemsPerPage(value, e.target);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const checkKeyPress = e => {
|
|
149
|
+
if (!/(\d)|(Arrow)|(Delete)|(Backspace)/.test(e.key)) {
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
const currentPageInput = pageNumberRef.current.textContent;
|
|
156
|
+
const itemsPerPageInput = listItemsPerPage.some(i => +i === +itemsPerPage) ? itemsPerPage : listItemsPerPage[0];
|
|
157
|
+
const newLastPage = Math.ceil(totalItems / itemsPerPageInput);
|
|
158
|
+
|
|
159
|
+
if (currentPageInput > newLastPage) {
|
|
160
|
+
onChangePageHandler(newLastPage - currentPageInput);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
pageNumberRef.current.parentNode.lastChild.textContent = '/ ' + newLastPage;
|
|
164
|
+
ItemsPerPageRef.current.value = itemsPerPageInput;
|
|
165
|
+
totalItemRef.current.textContent = totalItems;
|
|
166
|
+
}, [itemsPerPage]);
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
const currentPageInput = +pageNumberRef.current.textContent;
|
|
169
|
+
const itemsPerPageInput = ItemsPerPageRef.current.value;
|
|
170
|
+
const newLastPage = Math.ceil(totalItems / itemsPerPageInput);
|
|
171
|
+
|
|
172
|
+
if (currentPageInput > newLastPage) {
|
|
173
|
+
onChangePageHandler(newLastPage - currentPageInput);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
pageNumberRef.current.parentNode.lastChild.textContent = '/ ' + newLastPage;
|
|
177
|
+
totalItemRef.current.textContent = totalItems;
|
|
178
|
+
ItemsPerPageRef.current.addEventListener('change', onChangeItemsPerPageHandler);
|
|
179
|
+
return () => {
|
|
180
|
+
ItemsPerPageRef.current && ItemsPerPageRef.current.removeEventListener('change', onChangeItemsPerPageHandler);
|
|
181
|
+
};
|
|
182
|
+
}, [totalItems]);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (typeof currentPage === 'number') {
|
|
185
|
+
const lastPage = +pageNumberRef.current.parentNode.lastChild.textContent.replace('/ ', '');
|
|
186
|
+
const currentPageInput = pageNumberRef.current.textContent;
|
|
187
|
+
|
|
188
|
+
if (currentPage > lastPage && currentPageInput) {
|
|
189
|
+
onChangePageHandler(lastPage - +currentPageInput);
|
|
190
|
+
} else if (currentPage < 1) {
|
|
191
|
+
pageNumberRef.current.textContent = 1;
|
|
192
|
+
!!onChangePage && onChangePage(1);
|
|
193
|
+
} else {
|
|
194
|
+
pageNumberRef.current.textContent = currentPage;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, [currentPage]);
|
|
198
|
+
const TotalPageComp = useMemo(() => {
|
|
199
|
+
return jsx("div", {
|
|
200
|
+
css: totalPage
|
|
201
|
+
}, jsx("div", {
|
|
202
|
+
css: iconPageCss,
|
|
203
|
+
onClick: () => onChangePageHandler(-1)
|
|
204
|
+
}, jsx(ArrowLeft, {
|
|
205
|
+
height: size === 'small' ? 20 : 24,
|
|
206
|
+
width: size === 'small' ? 20 : 24,
|
|
207
|
+
viewBox: true
|
|
208
|
+
})), jsx("div", {
|
|
209
|
+
css: pageNumber
|
|
210
|
+
}, jsx("div", {
|
|
211
|
+
ref: pageNumberRef,
|
|
212
|
+
css: currentPageNum,
|
|
213
|
+
contentEditable: true,
|
|
214
|
+
onInput: onChangePageNumber,
|
|
215
|
+
onKeyDown: checkKeyPress
|
|
216
|
+
}), jsx("span", null)), jsx("div", {
|
|
217
|
+
css: iconPageCss,
|
|
218
|
+
onClick: () => onChangePageHandler(1)
|
|
219
|
+
}, jsx(ArrowRight, {
|
|
220
|
+
height: size === 'small' ? 20 : 24,
|
|
221
|
+
width: size === 'small' ? 20 : 24,
|
|
222
|
+
viewBox: true
|
|
223
|
+
})));
|
|
224
|
+
}, [size]);
|
|
225
|
+
const LineNumber = useMemo(() => {
|
|
226
|
+
return jsx("div", {
|
|
227
|
+
css: lineNumberStyle
|
|
228
|
+
}, jsx(Typography, {
|
|
229
|
+
type: size === 'small' ? 'p2' : 'p1'
|
|
230
|
+
}, getGlobal('lineNumber')), ": ", jsx("select", {
|
|
231
|
+
css: listItemsPerPageStyle,
|
|
232
|
+
defaultValue: itemsPerPage,
|
|
233
|
+
ref: ItemsPerPageRef
|
|
234
|
+
}, listItemsPerPage.map((list, index) => jsx("option", {
|
|
235
|
+
key: list + index,
|
|
236
|
+
value: list
|
|
237
|
+
}, list))));
|
|
238
|
+
}, [listItemsPerPage]);
|
|
239
|
+
const TotalItemsComp = useMemo(() => {
|
|
240
|
+
return jsx(Typography, {
|
|
241
|
+
type: size === 'small' ? 'p2' : 'p1'
|
|
242
|
+
}, getGlobal('total'), ": ", jsx("span", {
|
|
243
|
+
ref: totalItemRef
|
|
244
|
+
}));
|
|
245
|
+
}, [size]);
|
|
246
|
+
return jsx("div", _extends({
|
|
247
|
+
css: pagingInfo,
|
|
248
|
+
style: style
|
|
249
|
+
}, props), TotalPageComp, LineNumber, TotalItemsComp);
|
|
250
|
+
});
|
|
251
|
+
PagingInfo.defaultProps = {
|
|
252
|
+
size: 'medium',
|
|
253
|
+
bgColor: '#FFF',
|
|
254
|
+
language: locale.get(),
|
|
255
|
+
fullWidth: false,
|
|
256
|
+
currentPage: 1,
|
|
257
|
+
totalItems: 0,
|
|
258
|
+
itemsPerPage: 10,
|
|
259
|
+
listItemsPerPage: [10, 20, 40, 50]
|
|
260
|
+
};
|
|
261
|
+
PagingInfo.propTypes = {
|
|
262
|
+
/** allows maximum screen width if true */
|
|
263
|
+
fullWidth: PropTypes.bool,
|
|
264
|
+
|
|
265
|
+
/** background color for paging */
|
|
266
|
+
bgColor: PropTypes.string,
|
|
267
|
+
|
|
268
|
+
/** size of paging */
|
|
269
|
+
size: PropTypes.oneOf(['small', 'medium']),
|
|
270
|
+
|
|
271
|
+
/** language to display text on paging */
|
|
272
|
+
language: PropTypes.oneOf(['vi', 'en']),
|
|
273
|
+
|
|
274
|
+
/** current of paging */
|
|
275
|
+
currentPage: PropTypes.number,
|
|
276
|
+
|
|
277
|
+
/** total items of paging */
|
|
278
|
+
totalItems: PropTypes.number,
|
|
279
|
+
|
|
280
|
+
/** the quantity of items on per page */
|
|
281
|
+
itemsPerPage: PropTypes.number,
|
|
282
|
+
|
|
283
|
+
/** the list to choose the number of elements to display per page */
|
|
284
|
+
listItemsPerPage: PropTypes.array,
|
|
285
|
+
|
|
286
|
+
/** style inline for Paging */
|
|
287
|
+
style: PropTypes.object,
|
|
288
|
+
|
|
289
|
+
/** the function will run after change page number */
|
|
290
|
+
onChangePage: PropTypes.func,
|
|
291
|
+
|
|
292
|
+
/** the function will run after change quantity on per page */
|
|
293
|
+
onChangeItemsPerPage: PropTypes.func,
|
|
294
|
+
|
|
295
|
+
/** any props else */
|
|
296
|
+
props: PropTypes.func
|
|
297
|
+
};
|
|
298
|
+
export default PagingInfo;
|
|
@@ -0,0 +1,281 @@
|
|
|
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 React, { memo, useRef, useState, useEffect, forwardRef } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { jsx, css } from '@emotion/core';
|
|
9
|
+
import theme from '../../theme/settings';
|
|
10
|
+
const PagingSelector = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
11
|
+
size,
|
|
12
|
+
style,
|
|
13
|
+
pageItemStyle,
|
|
14
|
+
currentPage: currentPageProps = 1,
|
|
15
|
+
totalItems = 0,
|
|
16
|
+
itemsPerPage = 10,
|
|
17
|
+
onChangePage,
|
|
18
|
+
...props
|
|
19
|
+
}, ref) => {
|
|
20
|
+
if (!ref) {
|
|
21
|
+
ref = useRef(null);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const [currentPage, setCurrentPage] = useState(currentPageProps);
|
|
25
|
+
const [paging, setPaging] = useState([1]);
|
|
26
|
+
const PageItemNum = css`
|
|
27
|
+
color: #FFF;
|
|
28
|
+
font-family: ${theme.typography.fontFamily};
|
|
29
|
+
font-style: normal;
|
|
30
|
+
font-weight: bold;
|
|
31
|
+
z-index: 1502;
|
|
32
|
+
`;
|
|
33
|
+
const morePaging = css`
|
|
34
|
+
position: absolute;
|
|
35
|
+
display: inline-flex;
|
|
36
|
+
opacity: 0;
|
|
37
|
+
transform: scaleX(0);
|
|
38
|
+
transition: all 0.5s;
|
|
39
|
+
z-index: 1503;
|
|
40
|
+
max-width: 176px;
|
|
41
|
+
overflow: scroll hidden;
|
|
42
|
+
padding-bottom: 2px;
|
|
43
|
+
outline: none;
|
|
44
|
+
&.visible {
|
|
45
|
+
opacity: 1;
|
|
46
|
+
transform: scaleX(1);
|
|
47
|
+
}
|
|
48
|
+
&::-webkit-scrollbar {
|
|
49
|
+
height: 4px;
|
|
50
|
+
}
|
|
51
|
+
&::-webkit-scrollbar-thumb {
|
|
52
|
+
border-radius: 10px;
|
|
53
|
+
background-color: #c1c1c1;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
const PageItem = css`
|
|
57
|
+
width: ${size === 'small' ? 20 : 24}px;
|
|
58
|
+
height: ${size === 'small' ? 20 : 24}px;
|
|
59
|
+
font-size: ${size === 'small' ? 12 : 14}px;
|
|
60
|
+
background-color: ${theme.colors.border};
|
|
61
|
+
border-radius: 50%;
|
|
62
|
+
text-align: center;
|
|
63
|
+
display: flex;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
align-items: center;
|
|
66
|
+
margin: 0px 4px;
|
|
67
|
+
user-select: none;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
position: relative;
|
|
70
|
+
&:hover {
|
|
71
|
+
background-color: ${theme.colors.hover};
|
|
72
|
+
&:not(.active) .css-${PageItemNum.name} {
|
|
73
|
+
color: ${theme.colors.primary};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
&.active {
|
|
77
|
+
background-color: ${theme.colors.borderHover};
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
const setPagination = (newCurrentPage = 1) => {
|
|
82
|
+
const newLastPage = Math.ceil(totalItems / itemsPerPage);
|
|
83
|
+
|
|
84
|
+
if (newCurrentPage > newLastPage || newCurrentPage < 0) {
|
|
85
|
+
newCurrentPage = 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setCurrentPage(newCurrentPage);
|
|
89
|
+
|
|
90
|
+
if (newLastPage > 1) {
|
|
91
|
+
const newPaging = [1];
|
|
92
|
+
|
|
93
|
+
if (newLastPage > 5) {
|
|
94
|
+
if (newCurrentPage < 4) {
|
|
95
|
+
newPaging.push(...[2, 3]);
|
|
96
|
+
let morePageRight = [];
|
|
97
|
+
|
|
98
|
+
if (newCurrentPage === 3) {
|
|
99
|
+
newPaging.push(4);
|
|
100
|
+
|
|
101
|
+
for (let r = newCurrentPage + 2; r < newLastPage; r++) {
|
|
102
|
+
morePageRight.push(r);
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
for (let r = 4; r < newLastPage; r++) {
|
|
106
|
+
morePageRight.push(r);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (morePageRight.length === 1) {
|
|
111
|
+
morePageRight = morePageRight[0];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
newPaging.push(...[morePageRight, newLastPage]);
|
|
115
|
+
} else if (newCurrentPage > newLastPage - 3) {
|
|
116
|
+
let morePageLeft = [];
|
|
117
|
+
|
|
118
|
+
if (newCurrentPage - 2 === 2) {
|
|
119
|
+
morePageLeft = 2;
|
|
120
|
+
} else {
|
|
121
|
+
for (let l = 2; l < newCurrentPage - 1 - (newCurrentPage - newLastPage + 1); l++) {
|
|
122
|
+
morePageLeft.push(l);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
newPaging.push(morePageLeft);
|
|
127
|
+
|
|
128
|
+
if (newCurrentPage === newLastPage - 2) {
|
|
129
|
+
newPaging.push(newLastPage - 3);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
newPaging.push(...[newLastPage - 2, newLastPage - 1, newLastPage]);
|
|
133
|
+
} else {
|
|
134
|
+
let morePageLeft = [],
|
|
135
|
+
morePageRight = [];
|
|
136
|
+
|
|
137
|
+
if (newCurrentPage - 2 === 2) {
|
|
138
|
+
morePageLeft = 2;
|
|
139
|
+
} else {
|
|
140
|
+
for (let l = 2; l < newCurrentPage - 1; l++) {
|
|
141
|
+
morePageLeft.push(l);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (newLastPage - 1 === newCurrentPage + 2) {
|
|
146
|
+
morePageRight = newCurrentPage + 2;
|
|
147
|
+
} else {
|
|
148
|
+
for (let r = newCurrentPage + 2; r < newLastPage; r++) {
|
|
149
|
+
morePageRight.push(r);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
newPaging.push(...[morePageLeft, newCurrentPage - 1, newCurrentPage, newCurrentPage + 1, morePageRight, newLastPage]);
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
for (let i = 2; i <= newLastPage; i++) {
|
|
157
|
+
newPaging.push(i);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return newPaging;
|
|
162
|
+
} else if (paging.length !== 1) {
|
|
163
|
+
return [1];
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const onChangePageHandler = (e, pageNum) => {
|
|
168
|
+
if (!e.currentTarget.classList.contains('active')) {
|
|
169
|
+
if (isNaN(pageNum)) {
|
|
170
|
+
const el = e.currentTarget.querySelector(`.css-${morePaging.name}`);
|
|
171
|
+
|
|
172
|
+
if (!el.classList.contains('visible')) {
|
|
173
|
+
el.classList.add('visible');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
el.setAttribute('tabIndex', -1);
|
|
177
|
+
el.focus();
|
|
178
|
+
} else {
|
|
179
|
+
setCurrentPage(pageNum);
|
|
180
|
+
setPaging(setPagination(pageNum)); // paginationRef.current.querySelector('.active').classList.remove('active');
|
|
181
|
+
|
|
182
|
+
if (onChangePage) onChangePage(pageNum);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const closeMorePaging = e => {
|
|
188
|
+
if (e.currentTarget.classList.contains('visible')) {
|
|
189
|
+
e.currentTarget.classList.remove('visible');
|
|
190
|
+
e.currentTarget.blur();
|
|
191
|
+
}
|
|
192
|
+
}; // Get totalItems, itemsPerPage to set last page
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
setPaging(setPagination(currentPageProps));
|
|
197
|
+
}, [currentPageProps]);
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
setPaging(setPagination(currentPage));
|
|
200
|
+
}, [totalItems, itemsPerPage]);
|
|
201
|
+
const RenderPageItem = /*#__PURE__*/memo(({
|
|
202
|
+
pageNum,
|
|
203
|
+
style
|
|
204
|
+
}) => {
|
|
205
|
+
return jsx("div", {
|
|
206
|
+
css: PageItem,
|
|
207
|
+
className: pageNum === currentPage ? 'active' : '',
|
|
208
|
+
style: style,
|
|
209
|
+
onClick: e => onChangePageHandler(e, pageNum)
|
|
210
|
+
}, jsx("div", {
|
|
211
|
+
css: PageItemNum
|
|
212
|
+
}, isNaN(pageNum) ? jsx(React.Fragment, null, jsx("div", {
|
|
213
|
+
css: morePaging,
|
|
214
|
+
onBlur: closeMorePaging,
|
|
215
|
+
style: {
|
|
216
|
+
top: '-100%',
|
|
217
|
+
...(pageNum[0] > currentPage ? {
|
|
218
|
+
right: 3,
|
|
219
|
+
transformOrigin: 'right'
|
|
220
|
+
} : {
|
|
221
|
+
left: 1,
|
|
222
|
+
transformOrigin: 'left'
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
}, pageNum.map(page => jsx("div", {
|
|
226
|
+
key: page,
|
|
227
|
+
css: PageItem,
|
|
228
|
+
style: {
|
|
229
|
+
width: 18,
|
|
230
|
+
height: 18,
|
|
231
|
+
minWidth: 18,
|
|
232
|
+
minHeight: 18,
|
|
233
|
+
fontSize: 8,
|
|
234
|
+
margin: '0px 2px'
|
|
235
|
+
},
|
|
236
|
+
onClick: e => onChangePageHandler(e, page)
|
|
237
|
+
}, jsx("span", {
|
|
238
|
+
css: PageItemNum
|
|
239
|
+
}, page)))), jsx("p", null, "...")) : pageNum));
|
|
240
|
+
});
|
|
241
|
+
return jsx("div", _extends({}, props, {
|
|
242
|
+
ref: ref,
|
|
243
|
+
style: {
|
|
244
|
+
display: 'inline-flex',
|
|
245
|
+
...style
|
|
246
|
+
}
|
|
247
|
+
}), paging.map((pageNum, index) => jsx(RenderPageItem, {
|
|
248
|
+
key: index,
|
|
249
|
+
pageNum: pageNum,
|
|
250
|
+
style: pageItemStyle
|
|
251
|
+
})));
|
|
252
|
+
}));
|
|
253
|
+
PagingSelector.defaultProps = {
|
|
254
|
+
size: 'medium',
|
|
255
|
+
currentPage: 1,
|
|
256
|
+
totalItems: 0,
|
|
257
|
+
itemsPerPage: 10
|
|
258
|
+
};
|
|
259
|
+
PagingSelector.propTypes = {
|
|
260
|
+
/** size of paging */
|
|
261
|
+
size: PropTypes.oneOf(['small', 'medium']),
|
|
262
|
+
|
|
263
|
+
/** current of paging */
|
|
264
|
+
currentPage: PropTypes.number,
|
|
265
|
+
|
|
266
|
+
/** total items of paging */
|
|
267
|
+
totalItems: PropTypes.number.isRequired,
|
|
268
|
+
|
|
269
|
+
/** the quantity of items on per page */
|
|
270
|
+
itemsPerPage: PropTypes.number,
|
|
271
|
+
|
|
272
|
+
/** style inline for PagingSelector */
|
|
273
|
+
style: PropTypes.object,
|
|
274
|
+
|
|
275
|
+
/** style inline for page number element */
|
|
276
|
+
pageItemStyle: PropTypes.object,
|
|
277
|
+
|
|
278
|
+
/** the function will run after change page number */
|
|
279
|
+
onChangePage: PropTypes.func
|
|
280
|
+
};
|
|
281
|
+
export default PagingSelector;
|