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,306 @@
|
|
|
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 { css, jsx } from '@emotion/core';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { forwardRef, memo, useEffect, useRef, useState, useImperativeHandle } from 'react';
|
|
9
|
+
import { Typography } from '../..';
|
|
10
|
+
import theme from '../../../theme/settings';
|
|
11
|
+
import { randomString } from '../../../utils';
|
|
12
|
+
const colors = {
|
|
13
|
+
primary: theme.colors.primary,
|
|
14
|
+
info: theme.colors.info,
|
|
15
|
+
success: theme.colors.success,
|
|
16
|
+
warning: theme.colors.warning,
|
|
17
|
+
danger: theme.colors.danger
|
|
18
|
+
};
|
|
19
|
+
const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
20
|
+
id,
|
|
21
|
+
className,
|
|
22
|
+
disabled,
|
|
23
|
+
readOnly,
|
|
24
|
+
name,
|
|
25
|
+
label,
|
|
26
|
+
color,
|
|
27
|
+
value,
|
|
28
|
+
checked,
|
|
29
|
+
defaultChecked,
|
|
30
|
+
determinate,
|
|
31
|
+
onChange,
|
|
32
|
+
inputRef,
|
|
33
|
+
children,
|
|
34
|
+
inputProps,
|
|
35
|
+
...props
|
|
36
|
+
}, reference) => {
|
|
37
|
+
if (!inputRef) {
|
|
38
|
+
inputRef = useRef(null);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const ref = useRef(null);
|
|
42
|
+
|
|
43
|
+
if (!id) {
|
|
44
|
+
[id] = useState('DGN-UI-' + randomString(10, {
|
|
45
|
+
allowNumber: false,
|
|
46
|
+
allowSymbol: false
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const CheckBoxInput = css`
|
|
51
|
+
&:checked + span {
|
|
52
|
+
background-color: ${colors[color] || color};
|
|
53
|
+
border-color: ${colors[color] || color};
|
|
54
|
+
&.determinate {
|
|
55
|
+
&::after {
|
|
56
|
+
transform: translate(-50%, -66%) scale(1) rotate(-45deg);
|
|
57
|
+
background:
|
|
58
|
+
linear-gradient(${theme.colors.white}, ${theme.colors.white}) left bottom/2px 100%,
|
|
59
|
+
linear-gradient(${theme.colors.white}, ${theme.colors.white}) left bottom/100% 2px;
|
|
60
|
+
background-repeat: no-repeat;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
&.indeterminate {
|
|
64
|
+
&::after {
|
|
65
|
+
transform: scale(1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
const CheckBoxSquare = css`
|
|
71
|
+
display: flex;
|
|
72
|
+
position: relative;
|
|
73
|
+
width: 18px;
|
|
74
|
+
height: 18px;
|
|
75
|
+
background-color: ${theme.colors.white};
|
|
76
|
+
border: 2px solid ${theme.colors.border};
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
border-radius: 2px;
|
|
79
|
+
&.determinate {
|
|
80
|
+
&::after {
|
|
81
|
+
content : '';
|
|
82
|
+
display : block;
|
|
83
|
+
height : 7px;
|
|
84
|
+
left : 50%;
|
|
85
|
+
position : absolute;
|
|
86
|
+
top : 43%;
|
|
87
|
+
transform : translate(-50%, -50%) scale(0) rotate(45deg);
|
|
88
|
+
transition: transform 0.3s;
|
|
89
|
+
width : 12.6px;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
&.indeterminate {
|
|
93
|
+
&::after {
|
|
94
|
+
content: "";
|
|
95
|
+
display: flex;
|
|
96
|
+
position: absolute;
|
|
97
|
+
background-color: white;
|
|
98
|
+
left: 2px;
|
|
99
|
+
top: 6px;
|
|
100
|
+
width: 10px;
|
|
101
|
+
height: 2px;
|
|
102
|
+
transition: transform 0.3s;
|
|
103
|
+
transform: scale(0);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
&:hover {
|
|
107
|
+
box-shadow:
|
|
108
|
+
0 0 2px 2px ${theme.colors.focus};
|
|
109
|
+
background-color:${theme.colors.focus};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
`;
|
|
113
|
+
const CheckBoxLabel = css`
|
|
114
|
+
display: flex;
|
|
115
|
+
position: relative;
|
|
116
|
+
align-items: center;
|
|
117
|
+
padding-left: 8px;
|
|
118
|
+
box-sizing: border-box;
|
|
119
|
+
`;
|
|
120
|
+
const CheckBoxRoot = css`
|
|
121
|
+
display: flex;
|
|
122
|
+
position: relative;
|
|
123
|
+
align-items: center;
|
|
124
|
+
margin: 3px 0;
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
user-select: none;
|
|
127
|
+
box-sizing: border-box;
|
|
128
|
+
&.disabled {
|
|
129
|
+
pointer-events: none;
|
|
130
|
+
.css-${CheckBoxSquare.name} {
|
|
131
|
+
border-color:${theme.colors.disabled};
|
|
132
|
+
}
|
|
133
|
+
.css-${CheckBoxInput.name} {
|
|
134
|
+
&:checked {
|
|
135
|
+
&.determinate + span::after {
|
|
136
|
+
background:
|
|
137
|
+
linear-gradient(${theme.colors.white},${theme.colors.white}) left bottom/2px 100%,
|
|
138
|
+
linear-gradient(${theme.colors.white},${theme.colors.white}) left bottom/ 100% 2px;
|
|
139
|
+
background-repeat: no-repeat;
|
|
140
|
+
}
|
|
141
|
+
&.indeterminate + span::after {
|
|
142
|
+
background-color: ${theme.colors.white};
|
|
143
|
+
}
|
|
144
|
+
& + span {
|
|
145
|
+
background-color:${theme.colors.disabled};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
&.read-only {
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
user-select: none;
|
|
153
|
+
}
|
|
154
|
+
&:not(.disabled):hover {
|
|
155
|
+
.css-${CheckBoxSquare.name} {
|
|
156
|
+
background-color:${theme.colors.hover};
|
|
157
|
+
border-color:${colors[color] || color};
|
|
158
|
+
}
|
|
159
|
+
.css-${CheckBoxInput.name} {
|
|
160
|
+
&:checked {
|
|
161
|
+
&.determinate + span::after {
|
|
162
|
+
background:
|
|
163
|
+
linear-gradient(${colors[color] || color},${colors[color] || color}) left bottom/2px 100%,
|
|
164
|
+
linear-gradient(${colors[color] || color},${colors[color] || color}) left bottom/100% 2px;
|
|
165
|
+
background-repeat: no-repeat;
|
|
166
|
+
}
|
|
167
|
+
&.indeterminate + span::after {
|
|
168
|
+
background-color: ${colors[color] || color};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
const CheckboxContainer = css`
|
|
175
|
+
display: block;
|
|
176
|
+
position: relative;
|
|
177
|
+
width: max-content;
|
|
178
|
+
&.disabled {
|
|
179
|
+
cursor: no-drop;
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
182
|
+
|
|
183
|
+
const handleChange = () => {
|
|
184
|
+
if (readOnly || inputProps.readOnly || disabled || inputProps.disabled) return;
|
|
185
|
+
const checked = !inputRef.current.checked;
|
|
186
|
+
inputRef.current.checked = checked;
|
|
187
|
+
const e = {
|
|
188
|
+
value: checked,
|
|
189
|
+
target: inputRef.current
|
|
190
|
+
};
|
|
191
|
+
if (onChange) onChange(e, checked);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const setChecked = check => {
|
|
195
|
+
if (typeof check === 'boolean') {
|
|
196
|
+
inputRef.current.checked = check;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
setChecked(checked);
|
|
202
|
+
}, [checked]);
|
|
203
|
+
useImperativeHandle(reference, () => {
|
|
204
|
+
ref.current.determinate = determinate;
|
|
205
|
+
ref.current.setChecked = setChecked;
|
|
206
|
+
|
|
207
|
+
ref.current.getChecked = () => inputRef.current.checked;
|
|
208
|
+
|
|
209
|
+
return ref.current;
|
|
210
|
+
});
|
|
211
|
+
return jsx("div", _extends({
|
|
212
|
+
id: 'DGN-UI-Checkbox-' + id.replace('DGN-UI-', ''),
|
|
213
|
+
css: CheckboxContainer,
|
|
214
|
+
className: ['DGN-UI-Checkbox', disabled ? 'disabled' : '', className].join(' ').trim(),
|
|
215
|
+
ref: ref
|
|
216
|
+
}, props, {
|
|
217
|
+
onClick: handleChange
|
|
218
|
+
}), jsx("div", {
|
|
219
|
+
css: CheckBoxRoot,
|
|
220
|
+
className: disabled ? 'disabled' : readOnly ? 'read-only' : ''
|
|
221
|
+
}, jsx("input", _extends({
|
|
222
|
+
value: value
|
|
223
|
+
}, inputProps, {
|
|
224
|
+
className: [determinate ? 'determinate' : 'indeterminate', inputProps.className || ''].join(' ').trim(),
|
|
225
|
+
readOnly: readOnly || inputProps.readOnly,
|
|
226
|
+
disabled: disabled || inputProps.disabled,
|
|
227
|
+
ref: inputRef,
|
|
228
|
+
css: CheckBoxInput,
|
|
229
|
+
id: id,
|
|
230
|
+
name: name,
|
|
231
|
+
type: "checkbox",
|
|
232
|
+
defaultChecked: checked || defaultChecked,
|
|
233
|
+
hidden: true
|
|
234
|
+
})), jsx("span", {
|
|
235
|
+
css: CheckBoxSquare,
|
|
236
|
+
className: determinate ? 'determinate' : 'indeterminate'
|
|
237
|
+
}), (children || label) && jsx("div", {
|
|
238
|
+
css: CheckBoxLabel
|
|
239
|
+
}, jsx(Typography, {
|
|
240
|
+
style: {
|
|
241
|
+
display: 'inline-flex',
|
|
242
|
+
alignItems: 'center'
|
|
243
|
+
}
|
|
244
|
+
}, children || label))));
|
|
245
|
+
}));
|
|
246
|
+
Checkbox.defaultProps = {
|
|
247
|
+
label: '',
|
|
248
|
+
className: '',
|
|
249
|
+
color: 'primary',
|
|
250
|
+
disabled: false,
|
|
251
|
+
readOnly: false,
|
|
252
|
+
defaultChecked: false,
|
|
253
|
+
determinate: true,
|
|
254
|
+
inputProps: {}
|
|
255
|
+
};
|
|
256
|
+
Checkbox.propTypes = {
|
|
257
|
+
/** value to check/uncheck square */
|
|
258
|
+
checked: PropTypes.bool,
|
|
259
|
+
|
|
260
|
+
/** value to check/uncheck square (just one time) */
|
|
261
|
+
defaultChecked: PropTypes.bool,
|
|
262
|
+
|
|
263
|
+
/** Prevent all event if true */
|
|
264
|
+
disabled: PropTypes.bool,
|
|
265
|
+
|
|
266
|
+
/** Prevent all event if true (keeping style) */
|
|
267
|
+
readOnly: PropTypes.bool,
|
|
268
|
+
|
|
269
|
+
/** display tick or hyphen icon */
|
|
270
|
+
determinate: PropTypes.bool,
|
|
271
|
+
|
|
272
|
+
/** Id is randomized randomly to avoid duplication. */
|
|
273
|
+
id: PropTypes.string,
|
|
274
|
+
|
|
275
|
+
/** value of input */
|
|
276
|
+
value: PropTypes.string,
|
|
277
|
+
|
|
278
|
+
/** class of Checkbox */
|
|
279
|
+
className: PropTypes.string,
|
|
280
|
+
|
|
281
|
+
/** The name of the Checkbox corresponds to the label displayed on the interface */
|
|
282
|
+
name: PropTypes.string,
|
|
283
|
+
|
|
284
|
+
/** The name of the Radio is displayed on the interface */
|
|
285
|
+
label: PropTypes.string,
|
|
286
|
+
|
|
287
|
+
/** color of checkbox background ['primary', 'info', 'success', 'warning', 'danger', #hex, rgb(#, #, #)] */
|
|
288
|
+
color: PropTypes.string,
|
|
289
|
+
|
|
290
|
+
/** props for input */
|
|
291
|
+
inputProps: PropTypes.object,
|
|
292
|
+
|
|
293
|
+
/** The function will run to return a true or false value of Radio Component */
|
|
294
|
+
onChange: PropTypes.func,
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* named ref: get ref of Checkbox component, insist:<br />
|
|
298
|
+
* * element<br />
|
|
299
|
+
* * setChecked: the method to set checked for input<br />
|
|
300
|
+
* * getChecked: the method to get checked of input<br />
|
|
301
|
+
*/
|
|
302
|
+
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
303
|
+
current: PropTypes.instanceOf(PropTypes.elementType)
|
|
304
|
+
})])
|
|
305
|
+
};
|
|
306
|
+
export default Checkbox;
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { css, jsx } from '@emotion/core';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { Children, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';
|
|
9
|
+
import theme from '../../../theme/settings';
|
|
10
|
+
const {
|
|
11
|
+
typography,
|
|
12
|
+
colors
|
|
13
|
+
} = theme;
|
|
14
|
+
const Control = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
disabled,
|
|
18
|
+
error,
|
|
19
|
+
style,
|
|
20
|
+
...props
|
|
21
|
+
}, reference) => {
|
|
22
|
+
const ref = useRef(null);
|
|
23
|
+
useImperativeHandle(reference, () => ref.current);
|
|
24
|
+
const classes = {
|
|
25
|
+
disabled: 'DGN-UI-Control-disabled',
|
|
26
|
+
error: 'DGN-UI-Control-error'
|
|
27
|
+
};
|
|
28
|
+
const controlRootCSS = css`
|
|
29
|
+
font-family : ${typography.fontFamily};
|
|
30
|
+
margin-bottom: 20px;
|
|
31
|
+
position : relative;
|
|
32
|
+
&.${classes.disabled} {
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
user-select : none;
|
|
35
|
+
}
|
|
36
|
+
&.${classes.error} {
|
|
37
|
+
* :not(label) {
|
|
38
|
+
color: ${colors.danger};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
`;
|
|
43
|
+
useLayoutEffect(() => {
|
|
44
|
+
if (disabled) {
|
|
45
|
+
ref.current.classList.add(classes.disabled);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!disabled && error) {
|
|
49
|
+
ref.current.classList.add(classes.error);
|
|
50
|
+
ref.current.querySelector('div.DGN-UI-InputBase').classList.add('danger');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
if (disabled) {
|
|
55
|
+
ref.current.classList.remove(classes.disabled);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!disabled && error) {
|
|
59
|
+
ref.current.classList.remove(classes.error);
|
|
60
|
+
ref.current.querySelector('div.DGN-UI-InputBase').classList.remove('danger');
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}, [disabled, error]);
|
|
64
|
+
return jsx("div", _extends({}, props, {
|
|
65
|
+
className: ['DGN-UI-Control', className].join(' '),
|
|
66
|
+
css: controlRootCSS,
|
|
67
|
+
style: style,
|
|
68
|
+
ref: ref
|
|
69
|
+
}), children);
|
|
70
|
+
}));
|
|
71
|
+
Control.defaultProps = {
|
|
72
|
+
className: '',
|
|
73
|
+
disabled: false,
|
|
74
|
+
error: ''
|
|
75
|
+
};
|
|
76
|
+
Control.propTypes = {
|
|
77
|
+
/** children of the form control */
|
|
78
|
+
children: PropTypes.oneOfType([PropTypes.element, PropTypes.node]).isRequired,
|
|
79
|
+
|
|
80
|
+
/** the class for the form control */
|
|
81
|
+
className: PropTypes.string,
|
|
82
|
+
|
|
83
|
+
/** prevent all event if true, hide all icon */
|
|
84
|
+
disabled: PropTypes.bool,
|
|
85
|
+
|
|
86
|
+
/** error for input */
|
|
87
|
+
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
88
|
+
|
|
89
|
+
/** style of the component */
|
|
90
|
+
style: PropTypes.object
|
|
91
|
+
};
|
|
92
|
+
export default Control;
|
|
@@ -0,0 +1,953 @@
|
|
|
1
|
+
// /** @jsxRuntime classic */
|
|
2
|
+
// /** @jsx jsx */
|
|
3
|
+
// import { jsx, css } from '@emotion/core';
|
|
4
|
+
// import PropTypes from 'prop-types';
|
|
5
|
+
// import React, { forwardRef, memo, useEffect, useMemo, useRef } from 'react';
|
|
6
|
+
// import { Calendar as CalendarIcon, Cancel as CancelIcon } from '../../../icons';
|
|
7
|
+
// import { randomString, useOnClickOutside } from '../../../utils';
|
|
8
|
+
// import { blue4, blue13, brand, danger5, danger8, dark, dark4, dark6, dark8, info5, info8, success5, white } from '../../../styles/colors';
|
|
9
|
+
// import { fontFamily } from '../../../styles/typography';
|
|
10
|
+
// // import CalendarNavigator from './calendar-navigator'
|
|
11
|
+
// const getElById = (id) => {
|
|
12
|
+
// return document.getElementById(id);
|
|
13
|
+
// };
|
|
14
|
+
// const addZeroToText = (number) => {
|
|
15
|
+
// return +number < 10 ? '0' + number : number;
|
|
16
|
+
// };
|
|
17
|
+
// const checkActiveDay = (format, time, string) => {
|
|
18
|
+
// let a = {}, b = {
|
|
19
|
+
// year : time.getFullYear(),
|
|
20
|
+
// month: time.getMonth(),
|
|
21
|
+
// date : time.getDate(),
|
|
22
|
+
// };
|
|
23
|
+
// if (/^(dd|DD)[\/\-](mm|MM)[\/\-]((y|Y){4})$/.test(format)) {
|
|
24
|
+
// if (string.split('-').length < 3) {
|
|
25
|
+
// a.year = string.split('/')[2];
|
|
26
|
+
// a.month = string.split('/')[1];
|
|
27
|
+
// a.date = string.split('/')[0];
|
|
28
|
+
// return Date.parse(new Date(a.year, a.month - 1, a.date)) === Date.parse(new Date(b.year, b.month, b.date));
|
|
29
|
+
// } else if(string.split('/').length < 3) {
|
|
30
|
+
// a.year = string.split('-')[2];
|
|
31
|
+
// a.month = string.split('-')[1];
|
|
32
|
+
// a.date = string.split('-')[0];
|
|
33
|
+
// return Date.parse(new Date(a.year, a.month, a.date)) === Date.parse(new Date(b.year, b.month, b.date));
|
|
34
|
+
// } else {
|
|
35
|
+
// return false;
|
|
36
|
+
// }
|
|
37
|
+
// }
|
|
38
|
+
// // if (/^(mm|MM)[\/\-](dd|DD)[\/\-]((y|Y){4})$/.test(format)) {
|
|
39
|
+
// // }
|
|
40
|
+
// // if (/^((y|Y){4})[\/\-](mm|MM)[\/\-](dd|DD)$/.test(format)) {
|
|
41
|
+
// // }
|
|
42
|
+
// };
|
|
43
|
+
// // const cutPX = (x) => {
|
|
44
|
+
// // return isNaN(x) ? x : x + 'px';
|
|
45
|
+
// // };
|
|
46
|
+
// const weekdaysLong = ['Hai', 'Ba', 'Tư', 'Năm', 'Sáu', 'Bảy', 'CN'];
|
|
47
|
+
// const weekdaysShort = ['H', 'B', 'T', 'N', 'S', 'B', 'CN'];
|
|
48
|
+
// const months = ['tháng 01', 'tháng 02', 'tháng 03', 'tháng 04', 'tháng 05', 'tháng 06', 'tháng 07', 'tháng 08', 'tháng 09', 'tháng 10', 'tháng 11', 'tháng 12'];
|
|
49
|
+
// const validateAlert = 'Invalidate value';
|
|
50
|
+
// const DatePicker = memo(forwardRef(({defaultValue, disabled, error, helperInvalid, helperValid, inputProps, inputRef, label, onChange, required, size, viewType, ...props}, ref) => {
|
|
51
|
+
// const Id = randomString(7, { allowSymbol: false, allowNumber: false });
|
|
52
|
+
// const IDs = {
|
|
53
|
+
// inputTypeDate : 'DCUI-input-type-date' + Id,
|
|
54
|
+
// daysOfMonth : 'DCUI-days-of-month' + Id,
|
|
55
|
+
// daysOfThisMonth : 'DCUI-days-of-this-month' + Id,
|
|
56
|
+
// daysOfPrevMonth : 'DCUI-days-of-prev-month' + Id,
|
|
57
|
+
// daysOfNextMonth : 'DCUI-days-of-next-month' + Id,
|
|
58
|
+
// };
|
|
59
|
+
// if (!ref) {
|
|
60
|
+
// ref = useRef(null);
|
|
61
|
+
// }
|
|
62
|
+
// if (!inputRef) {
|
|
63
|
+
// inputRef = useRef(null);
|
|
64
|
+
// }
|
|
65
|
+
// const allDaysOfMonthRef = useRef(null);
|
|
66
|
+
// const calendarRef = useRef(null);
|
|
67
|
+
// const headerRef = useRef(null);
|
|
68
|
+
// const headerTitleRef = useRef(null);
|
|
69
|
+
// const helperRef = useRef(null);
|
|
70
|
+
// const inputContainerRef = useRef(null);
|
|
71
|
+
// const nowDate = !isNaN(Date.parse(defaultValue)) ? new Date(defaultValue) : new Date();
|
|
72
|
+
// useOnClickOutside(inputContainerRef, () => onClickOutside());
|
|
73
|
+
// const styles = {
|
|
74
|
+
// container: css`
|
|
75
|
+
// * {
|
|
76
|
+
// box-sizing: border-box;
|
|
77
|
+
// font-family: ${fontFamily};
|
|
78
|
+
// }
|
|
79
|
+
// border-radius: 4px;
|
|
80
|
+
// box-sizing: border-box;
|
|
81
|
+
// display: block;
|
|
82
|
+
// font-family: sans-serif;
|
|
83
|
+
// position: relative;
|
|
84
|
+
// width: 100%;
|
|
85
|
+
// `,
|
|
86
|
+
// helper: css`
|
|
87
|
+
// position: relative;
|
|
88
|
+
// text-align: center;
|
|
89
|
+
// .helper-text {
|
|
90
|
+
// position: absolute;
|
|
91
|
+
// right: 0;
|
|
92
|
+
// top: 0;
|
|
93
|
+
// transform: translateY(-100%);
|
|
94
|
+
// visibility: hidden;
|
|
95
|
+
// }
|
|
96
|
+
// .valid {
|
|
97
|
+
// color: ${success5};
|
|
98
|
+
// }
|
|
99
|
+
// .invalid {
|
|
100
|
+
// color: ${danger5};
|
|
101
|
+
// }
|
|
102
|
+
// `,
|
|
103
|
+
// label: css`
|
|
104
|
+
// color: ${disabled ? dark4 : dark8};
|
|
105
|
+
// display: block;
|
|
106
|
+
// font-size: 12px;
|
|
107
|
+
// font-weight: 700;
|
|
108
|
+
// margin-bottom: 4px;
|
|
109
|
+
// padding: 0;
|
|
110
|
+
// transition: color 0.2s cubic-bezier(0.075, 0.82, 0.165, 1);
|
|
111
|
+
// user-select: ${disabled ? 'none' : 'initial'};
|
|
112
|
+
// `,
|
|
113
|
+
// require: css`
|
|
114
|
+
// color: ${danger5};
|
|
115
|
+
// font-size: 12px;
|
|
116
|
+
// font-weight: bold;
|
|
117
|
+
// `,
|
|
118
|
+
// input: {
|
|
119
|
+
// container: {
|
|
120
|
+
// outlined: css`
|
|
121
|
+
// background-color: ${white};
|
|
122
|
+
// border-radius: 4px;
|
|
123
|
+
// box-sizing: border-box;
|
|
124
|
+
// cursor: text;
|
|
125
|
+
// display: flex;
|
|
126
|
+
// flex-direction: column;
|
|
127
|
+
// height: 40px;
|
|
128
|
+
// max-height: 40px;
|
|
129
|
+
// pointer-events: ${disabled ? 'none' : 'initial'};
|
|
130
|
+
// position: relative;
|
|
131
|
+
// transition: width 0.2s linear;
|
|
132
|
+
// width: 100%;
|
|
133
|
+
// .svg {
|
|
134
|
+
// color: ${dark6};
|
|
135
|
+
// cursor: ${disabled ? 'initial' : 'pointer'};
|
|
136
|
+
// font-size: 20px;
|
|
137
|
+
// position: absolute;
|
|
138
|
+
// right: 20px;
|
|
139
|
+
// top: 50%;
|
|
140
|
+
// transform: translateY(-50%);
|
|
141
|
+
// transition: color 0.3s ease, visibility 0.3s ease;
|
|
142
|
+
// }
|
|
143
|
+
// .svg-focus {
|
|
144
|
+
// opacity: 0;
|
|
145
|
+
// visibility: hidden;
|
|
146
|
+
// :hover {
|
|
147
|
+
// color: ${brand};
|
|
148
|
+
// }
|
|
149
|
+
// }
|
|
150
|
+
// .svg-default {
|
|
151
|
+
// height: 20px;
|
|
152
|
+
// opacity: 1;
|
|
153
|
+
// }
|
|
154
|
+
// &:before {
|
|
155
|
+
// border-radius: 4px;
|
|
156
|
+
// border: 1px solid ${dark6};
|
|
157
|
+
// bottom: 0;
|
|
158
|
+
// content: '\\00a0';
|
|
159
|
+
// left: 0;
|
|
160
|
+
// pointer-events: none;
|
|
161
|
+
// position: absolute;
|
|
162
|
+
// right: 0;
|
|
163
|
+
// top: 0;
|
|
164
|
+
// }
|
|
165
|
+
// &.focused {
|
|
166
|
+
// box-shadow: none;
|
|
167
|
+
// height: max-content;
|
|
168
|
+
// &::before {
|
|
169
|
+
// border: solid 2px ${info5};
|
|
170
|
+
// bottom: -1px;
|
|
171
|
+
// left: -1px;
|
|
172
|
+
// right: -1px;
|
|
173
|
+
// top: -1px;
|
|
174
|
+
// }
|
|
175
|
+
// input::placeholder {
|
|
176
|
+
// color: ${brand};
|
|
177
|
+
// }
|
|
178
|
+
// .calendar {
|
|
179
|
+
// opacity: 1;
|
|
180
|
+
// transform: scale(1);
|
|
181
|
+
// }
|
|
182
|
+
// .svg-default {
|
|
183
|
+
// opacity: 0;
|
|
184
|
+
// visibility: hidden;
|
|
185
|
+
// }
|
|
186
|
+
// .svg-focus {
|
|
187
|
+
// opacity: 1;
|
|
188
|
+
// visibility: visible;
|
|
189
|
+
// }
|
|
190
|
+
// }
|
|
191
|
+
// &:hover:not(.focused):not(.error-message) {
|
|
192
|
+
// &:before {
|
|
193
|
+
// border: solid 1px ${brand};
|
|
194
|
+
// }
|
|
195
|
+
// .svg {
|
|
196
|
+
// color: ${brand};
|
|
197
|
+
// }
|
|
198
|
+
// input::placeholder {
|
|
199
|
+
// color: ${brand};
|
|
200
|
+
// }
|
|
201
|
+
// }
|
|
202
|
+
// &.error-message {
|
|
203
|
+
// &:before {
|
|
204
|
+
// border-color: ${danger5};
|
|
205
|
+
// }
|
|
206
|
+
// .svg-default {
|
|
207
|
+
// color: ${danger5};
|
|
208
|
+
// }
|
|
209
|
+
// }
|
|
210
|
+
// `,
|
|
211
|
+
// underlined: css`
|
|
212
|
+
// background-color: white;
|
|
213
|
+
// cursor: text;
|
|
214
|
+
// display: flex;
|
|
215
|
+
// height: 40px;
|
|
216
|
+
// pointer-events: ${disabled ? 'none' : 'initial'};
|
|
217
|
+
// position: relative;
|
|
218
|
+
// transition: all 0.2s ease-out;
|
|
219
|
+
// width: 100%;
|
|
220
|
+
// .svg {
|
|
221
|
+
// cursor: ${disabled ? 'initial' : 'pointer'};
|
|
222
|
+
// color: ${dark6};
|
|
223
|
+
// height: 20px;
|
|
224
|
+
// position: absolute;
|
|
225
|
+
// right: 6px;
|
|
226
|
+
// top: 50%;
|
|
227
|
+
// transform: translateY(-50%);
|
|
228
|
+
// transition: opacity 0.5s cubic-bezier(0.075, 0.82, 0.165, 1), color 0.2s cubic-bezier(0.075, 0.82, 0.165, 1);
|
|
229
|
+
// }
|
|
230
|
+
// .svg-focus {
|
|
231
|
+
// /* right: 4px; */
|
|
232
|
+
// /* top: 0; */
|
|
233
|
+
// visibility: hidden;
|
|
234
|
+
// :hover {
|
|
235
|
+
// color: ${brand};
|
|
236
|
+
// }
|
|
237
|
+
// }
|
|
238
|
+
// .svg-default {
|
|
239
|
+
// /* right: 4px; */
|
|
240
|
+
// /* top: 0; */
|
|
241
|
+
// }
|
|
242
|
+
// &:after {
|
|
243
|
+
// border-bottom: 2px solid ${info5};
|
|
244
|
+
// bottom: 0;
|
|
245
|
+
// content: '';
|
|
246
|
+
// left: 0;
|
|
247
|
+
// pointer-events: none;
|
|
248
|
+
// position: absolute;
|
|
249
|
+
// right: 0;
|
|
250
|
+
// top: 0;
|
|
251
|
+
// transform: scaleX(0);
|
|
252
|
+
// transform-origin: left;
|
|
253
|
+
// transition: transform 0.3s cubic-bezier(0.075, 0.82, 0.165, 1);
|
|
254
|
+
// }
|
|
255
|
+
// &:before {
|
|
256
|
+
// border-bottom: solid 1px ${dark6};
|
|
257
|
+
// bottom: 0;
|
|
258
|
+
// content: '\\00a0';
|
|
259
|
+
// left: 0;
|
|
260
|
+
// position: absolute;
|
|
261
|
+
// pointer-events: none;
|
|
262
|
+
// right: 0;
|
|
263
|
+
// top: 0;
|
|
264
|
+
// transition: border-bottom-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
265
|
+
// }
|
|
266
|
+
// &.focused {
|
|
267
|
+
// transition: width 0.3s ease-in-out;
|
|
268
|
+
// &:after {
|
|
269
|
+
// transform: scaleX(1);
|
|
270
|
+
// }
|
|
271
|
+
// input::placeholder {
|
|
272
|
+
// color: ${brand};
|
|
273
|
+
// }
|
|
274
|
+
// .calendar {
|
|
275
|
+
// opacity: 1;
|
|
276
|
+
// display: flex;
|
|
277
|
+
// transform: scaleY(1);
|
|
278
|
+
// }
|
|
279
|
+
// .svg-default {
|
|
280
|
+
// visibility: hidden;
|
|
281
|
+
// }
|
|
282
|
+
// .svg-focus {
|
|
283
|
+
// visibility: visible;
|
|
284
|
+
// }
|
|
285
|
+
// }
|
|
286
|
+
// &:hover:not(.focused):not(.error-message) {
|
|
287
|
+
// &:before {
|
|
288
|
+
// border-bottom: solid 1px ${brand};
|
|
289
|
+
// }
|
|
290
|
+
// .svg {
|
|
291
|
+
// color: ${brand};
|
|
292
|
+
// }
|
|
293
|
+
// input::placeholder {
|
|
294
|
+
// color: ${brand};
|
|
295
|
+
// }
|
|
296
|
+
// }
|
|
297
|
+
// &.error-message {
|
|
298
|
+
// &:before {
|
|
299
|
+
// border-color: ${danger5};
|
|
300
|
+
// }
|
|
301
|
+
// &:after {
|
|
302
|
+
// border-color: ${danger5};
|
|
303
|
+
// }
|
|
304
|
+
// .svg-default {
|
|
305
|
+
// color: ${danger5};
|
|
306
|
+
// }
|
|
307
|
+
// }
|
|
308
|
+
// `,
|
|
309
|
+
// },
|
|
310
|
+
// input: {
|
|
311
|
+
// outlined: css`
|
|
312
|
+
// background-color: ${white};
|
|
313
|
+
// border: 0;
|
|
314
|
+
// font-size: 16px;
|
|
315
|
+
// height: 40px;
|
|
316
|
+
// margin: auto 0 auto 16px;
|
|
317
|
+
// outline: none;
|
|
318
|
+
// padding: 0;
|
|
319
|
+
// &::placeholder {
|
|
320
|
+
// color: ${dark6};
|
|
321
|
+
// letter-spacing: 0.0675em;
|
|
322
|
+
// transition: color 0.2s cubic-bezier(0.075, 0.82, 0.165, 1) 0ms;
|
|
323
|
+
// }
|
|
324
|
+
// &:disabled {
|
|
325
|
+
// pointer-events: none;
|
|
326
|
+
// &::placeholder {
|
|
327
|
+
// color: #151a30;
|
|
328
|
+
// user-select: none;
|
|
329
|
+
// }
|
|
330
|
+
// .svg {
|
|
331
|
+
// color: ${dark4};
|
|
332
|
+
// }
|
|
333
|
+
// &.input-container:before {
|
|
334
|
+
// border: 1px solid ${dark4};
|
|
335
|
+
// }
|
|
336
|
+
// }
|
|
337
|
+
// `,
|
|
338
|
+
// underlined: css`
|
|
339
|
+
// background-color: ${white};
|
|
340
|
+
// border: none;
|
|
341
|
+
// font-size: 16px;
|
|
342
|
+
// height: 40px;
|
|
343
|
+
// line-height: 20px;
|
|
344
|
+
// margin: auto 0;
|
|
345
|
+
// outline: none;
|
|
346
|
+
// padding: 0;
|
|
347
|
+
// width: 100%;
|
|
348
|
+
// &::placeholder {
|
|
349
|
+
// color: ${dark6};
|
|
350
|
+
// letter-spacing: 0.0675em;
|
|
351
|
+
// transition: color 0.2s cubic-bezier(0.075, 0.82, 0.165, 1) 0ms;
|
|
352
|
+
// }
|
|
353
|
+
// &:disabled {
|
|
354
|
+
// pointer-events: none;
|
|
355
|
+
// &::placeholder {
|
|
356
|
+
// color: #151a30;
|
|
357
|
+
// user-select: none;
|
|
358
|
+
// }
|
|
359
|
+
// ~ .svg {
|
|
360
|
+
// color: ${dark4};
|
|
361
|
+
// }
|
|
362
|
+
// ~ .input-container:before {
|
|
363
|
+
// border-bottom: 1px solid ${dark4};
|
|
364
|
+
// }
|
|
365
|
+
// }
|
|
366
|
+
// `,
|
|
367
|
+
// },
|
|
368
|
+
// },
|
|
369
|
+
// error: css`
|
|
370
|
+
// color: ${danger5};
|
|
371
|
+
// font-size: 12px;
|
|
372
|
+
// position: absolute;
|
|
373
|
+
// bottom: ${viewType === 'box' ? -18 : -24 }px;
|
|
374
|
+
// font-weight: 400;
|
|
375
|
+
// line-height: 12px;
|
|
376
|
+
// `,
|
|
377
|
+
// calendar: css`
|
|
378
|
+
// align-items: center;
|
|
379
|
+
// background-color: ${white};
|
|
380
|
+
// border-radius: 4px;
|
|
381
|
+
// box-shadow: 0px 2px 14px 4px rgba(0, 0, 0, 0.1);
|
|
382
|
+
// box-sizing: border-box;
|
|
383
|
+
// flex-direction: column;
|
|
384
|
+
// font-size: 12px;
|
|
385
|
+
// height: auto;
|
|
386
|
+
// opacity: 0;
|
|
387
|
+
// padding: 16px 10px;
|
|
388
|
+
// position: fixed;
|
|
389
|
+
// transform-origin: center center;
|
|
390
|
+
// transform: scaleY(0);
|
|
391
|
+
// transition: transform 0.2s linear, opacity 0.2s linear;
|
|
392
|
+
// width: ${size === 'medium' ? 350 : 245}px;
|
|
393
|
+
// z-index: 9003;
|
|
394
|
+
// `,
|
|
395
|
+
// header: css`
|
|
396
|
+
// align-items: center;
|
|
397
|
+
// display: flex;
|
|
398
|
+
// height: 24px;
|
|
399
|
+
// justify-content: center;
|
|
400
|
+
// width: 100%;
|
|
401
|
+
// .calender-header {
|
|
402
|
+
// color: ${brand};
|
|
403
|
+
// cursor: initial;
|
|
404
|
+
// font-size: 16px;
|
|
405
|
+
// font-weight: 700;
|
|
406
|
+
// margin: 0;
|
|
407
|
+
// user-select: none;
|
|
408
|
+
// width: 60%;
|
|
409
|
+
// word-break: keep-all;
|
|
410
|
+
// }
|
|
411
|
+
// `,
|
|
412
|
+
// button: css`
|
|
413
|
+
// background-color: transparent;
|
|
414
|
+
// border-radius: 50%;
|
|
415
|
+
// border: 0;
|
|
416
|
+
// box-sizing: border-box;
|
|
417
|
+
// cursor: pointer;
|
|
418
|
+
// display: flex;
|
|
419
|
+
// justify-content: center;
|
|
420
|
+
// margin: 0;
|
|
421
|
+
// width: 10%;
|
|
422
|
+
// &:focus {
|
|
423
|
+
// outline: none;
|
|
424
|
+
// path {
|
|
425
|
+
// fill: ${brand};
|
|
426
|
+
// }
|
|
427
|
+
// }
|
|
428
|
+
// &:hover:not(:focus) {
|
|
429
|
+
// path {
|
|
430
|
+
// fill: ${info5};
|
|
431
|
+
// }
|
|
432
|
+
// }
|
|
433
|
+
// `,
|
|
434
|
+
// days: css`
|
|
435
|
+
// margin: 0;
|
|
436
|
+
// margin-top: ${size === 'medium' ? 14 : 8}px;
|
|
437
|
+
// padding: 0;
|
|
438
|
+
// table-layout: fixed;
|
|
439
|
+
// width: 100%;
|
|
440
|
+
// th {
|
|
441
|
+
// color: ${dark8};
|
|
442
|
+
// font-weight: 500;
|
|
443
|
+
// height: 20px;
|
|
444
|
+
// line-height: 20px;
|
|
445
|
+
// margin: 0;
|
|
446
|
+
// padding: 0;
|
|
447
|
+
// text-align: center !important;
|
|
448
|
+
// user-select: none;
|
|
449
|
+
// }
|
|
450
|
+
// td {
|
|
451
|
+
// color: ${dark};
|
|
452
|
+
// font-size: 12px;
|
|
453
|
+
// font-weight: 500;
|
|
454
|
+
// line-height: 16px;
|
|
455
|
+
// }
|
|
456
|
+
// .days-of-month {
|
|
457
|
+
// color: ${dark};
|
|
458
|
+
// cursor: pointer;
|
|
459
|
+
// line-height: ${size === 'medium' ? 26 : 22}px;
|
|
460
|
+
// padding: 4px;
|
|
461
|
+
// position: relative;
|
|
462
|
+
// text-align: center;
|
|
463
|
+
// user-select: none;
|
|
464
|
+
// width: calc(100% / 7);
|
|
465
|
+
// ::before {
|
|
466
|
+
// background-color: ${white};
|
|
467
|
+
// border-radius: 50%;
|
|
468
|
+
// content: '';
|
|
469
|
+
// height: ${size === 'medium' ? 26 : 24}px;
|
|
470
|
+
// left: 50%;
|
|
471
|
+
// position: absolute;
|
|
472
|
+
// top: 50%;
|
|
473
|
+
// transform: translate(-50%,-50%);
|
|
474
|
+
// transition: background-color 0.2s ease-in, color 0.2s ease-in;
|
|
475
|
+
// width: ${size === 'medium' ? 26 : 24}px;
|
|
476
|
+
// z-index: -1;
|
|
477
|
+
// }
|
|
478
|
+
// &:hover:not(.today):not(.day-active):not(.prev-date):not(.next-date) {
|
|
479
|
+
// ::before{
|
|
480
|
+
// background-color: ${blue13};
|
|
481
|
+
// }
|
|
482
|
+
// }
|
|
483
|
+
// }
|
|
484
|
+
// .prev-date,
|
|
485
|
+
// .next-date {
|
|
486
|
+
// opacity: 0.4;
|
|
487
|
+
// cursor: default;
|
|
488
|
+
// }
|
|
489
|
+
// .today:not(.day-active) {
|
|
490
|
+
// font-weight: 700;
|
|
491
|
+
// :hover {
|
|
492
|
+
// ::before {
|
|
493
|
+
// background-color: ${blue13};
|
|
494
|
+
// }
|
|
495
|
+
// }
|
|
496
|
+
// ::after {
|
|
497
|
+
// border-bottom: 2px solid ${dark};
|
|
498
|
+
// content : '';
|
|
499
|
+
// left : 16px;
|
|
500
|
+
// bottom : 8px;
|
|
501
|
+
// position : absolute;
|
|
502
|
+
// right : 16px;
|
|
503
|
+
// }
|
|
504
|
+
// }
|
|
505
|
+
// .day-active {
|
|
506
|
+
// ::before {
|
|
507
|
+
// background-color: ${blue4};
|
|
508
|
+
// font-weight: bold;
|
|
509
|
+
// }
|
|
510
|
+
// }
|
|
511
|
+
// td:nth-of-type(7n - 1) {
|
|
512
|
+
// color: ${info8};
|
|
513
|
+
// }
|
|
514
|
+
// td:nth-of-type(7n) {
|
|
515
|
+
// color: ${danger8};
|
|
516
|
+
// }
|
|
517
|
+
// th:nth-of-type(6) {
|
|
518
|
+
// color: ${info8};
|
|
519
|
+
// }
|
|
520
|
+
// th:nth-of-type(7) {
|
|
521
|
+
// color: ${danger8};
|
|
522
|
+
// }
|
|
523
|
+
// `,
|
|
524
|
+
// };
|
|
525
|
+
// const getScrollParent = element => {
|
|
526
|
+
// const style = getComputedStyle (element);
|
|
527
|
+
// let scrollParent = window;
|
|
528
|
+
// if (style.position !== 'fixed') {
|
|
529
|
+
// let parent = element.parentElement;
|
|
530
|
+
// while (parent) {
|
|
531
|
+
// const parentStyle = getComputedStyle (parent);
|
|
532
|
+
// if (/(auto|scroll)/.test ( parentStyle.overflow + parentStyle.overflowY + parentStyle.overflowX)) {
|
|
533
|
+
// scrollParent = parent;
|
|
534
|
+
// parent = undefined;
|
|
535
|
+
// } else {
|
|
536
|
+
// parent = parent.parentElement;
|
|
537
|
+
// }
|
|
538
|
+
// }
|
|
539
|
+
// }
|
|
540
|
+
// return scrollParent;
|
|
541
|
+
// };
|
|
542
|
+
// const setPosition = () => {
|
|
543
|
+
// const el = calendarRef.current;
|
|
544
|
+
// const target = ref.current;
|
|
545
|
+
// if (!el || !target) {
|
|
546
|
+
// return;
|
|
547
|
+
// }
|
|
548
|
+
// const { bottom, left, top } = target.getBoundingClientRect();
|
|
549
|
+
// if (top > window.innerHeight) {
|
|
550
|
+
// el.style.top = null;
|
|
551
|
+
// el.style.bottom = '5px';
|
|
552
|
+
// el.style.transformOrigin = 'bottom';
|
|
553
|
+
// } else if (bottom < 0) {
|
|
554
|
+
// el.style.top = '5px';
|
|
555
|
+
// el.style.bottom = null;
|
|
556
|
+
// el.style.transformOrigin = 'top';
|
|
557
|
+
// } else {
|
|
558
|
+
// if (window.innerHeight - bottom < el.offsetHeight) {
|
|
559
|
+
// if (top < el.offsetHeight) {
|
|
560
|
+
// el.style.top = (window.innerHeight - el.offsetHeight) / 2 + 'px';
|
|
561
|
+
// el.style.bottom = null;
|
|
562
|
+
// el.style.transformOrigin = 'center center';
|
|
563
|
+
// } else {
|
|
564
|
+
// el.style.top = top - el.offsetHeight + 'px';
|
|
565
|
+
// el.style.bottom = null;
|
|
566
|
+
// el.style.transformOrigin = 'bottom';
|
|
567
|
+
// }
|
|
568
|
+
// } else {
|
|
569
|
+
// el.style.bottom = null;
|
|
570
|
+
// el.style.top = bottom + 5 + 'px';
|
|
571
|
+
// el.style.transformOrigin = 'top';
|
|
572
|
+
// }
|
|
573
|
+
// }
|
|
574
|
+
// if (left < 0) {
|
|
575
|
+
// el.style.left = '5px';
|
|
576
|
+
// } else if (left + el.offsetWidth > window.innerWidth) {
|
|
577
|
+
// el.style.left = (window.innerWidth - el.offsetWidth) / 2 + 'px';
|
|
578
|
+
// } else {
|
|
579
|
+
// el.style.left = left + 'px';
|
|
580
|
+
// }
|
|
581
|
+
// };
|
|
582
|
+
// const escKeyFunc = (ev) => {
|
|
583
|
+
// //call the useOnClickOutside when press esc key
|
|
584
|
+
// if (ev.keyCode === 27) {
|
|
585
|
+
// onClickOutside();
|
|
586
|
+
// inputContainerRef.current.childNodes[0].blur();
|
|
587
|
+
// }
|
|
588
|
+
// };
|
|
589
|
+
// const onInputBlur = () => {};
|
|
590
|
+
// const onInputFocus = () => {
|
|
591
|
+
// inputContainerRef.current.classList.add('focused');
|
|
592
|
+
// // document.body.style.overflow = 'hidden';
|
|
593
|
+
// setPosition();
|
|
594
|
+
// };
|
|
595
|
+
// const onClickOutside = () => {
|
|
596
|
+
// inputContainerRef.current.classList.remove('focused');
|
|
597
|
+
// // document.body.style.overflow = null;
|
|
598
|
+
// };
|
|
599
|
+
// const changeDayOfWeek = (date) => {
|
|
600
|
+
// // get day number from 0 (monday) to 6 (sunday)
|
|
601
|
+
// let day = date.getDay();
|
|
602
|
+
// if (day === 0) day = 7; // make Sunday (0) the last day
|
|
603
|
+
// return day - 1;
|
|
604
|
+
// };
|
|
605
|
+
// const renderCalendar = (nowDate) => {
|
|
606
|
+
// const monthDays = allDaysOfMonthRef.current;
|
|
607
|
+
// const header = headerTitleRef.current;
|
|
608
|
+
// const input = inputRef.current;
|
|
609
|
+
// const newDate = new Date(nowDate);
|
|
610
|
+
// const date = new Date(newDate.setDate(1));
|
|
611
|
+
// const lastTime = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
612
|
+
// const lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
|
613
|
+
// const prevTime = new Date(date.getFullYear(), date.getMonth(), 0);
|
|
614
|
+
// const prevLastDay = prevTime.getDate()
|
|
615
|
+
// const lastDayIndex = changeDayOfWeek(lastTime);
|
|
616
|
+
// const firstDayIndex = changeDayOfWeek(date);
|
|
617
|
+
// const daysOfNextMonth = 7 - lastDayIndex;
|
|
618
|
+
// let days = [];
|
|
619
|
+
// let x = firstDayIndex;
|
|
620
|
+
// for (x; x > 0; x--) {
|
|
621
|
+
// if (prevTime.getFullYear() === +input.value.split('/')[2] && prevTime.getMonth() + 1 === +input.value.split('/')[1] && prevLastDay - x + 1 === +input.value.split('/')[0]) {
|
|
622
|
+
// days.push(`<td id='${IDs.daysOfPrevMonth + '-' + (prevLastDay - x + 1)}' class='days-of-month day-active prev-date'>${prevLastDay - x + 1}</td>`);
|
|
623
|
+
// }
|
|
624
|
+
// else {
|
|
625
|
+
// days.push(`<td id='${IDs.daysOfPrevMonth + '-' + (prevLastDay - x + 1)}' class='days-of-month prev-date'>${prevLastDay - x + 1}</td>`);
|
|
626
|
+
// }
|
|
627
|
+
// }
|
|
628
|
+
// for (let i = 1; i <= lastDay; i++) {
|
|
629
|
+
// if (i === new Date().getDate() && date.getMonth() === new Date().getMonth() && date.getFullYear() === new Date().getFullYear()) {
|
|
630
|
+
// days.push(`<td id='${IDs.daysOfThisMonth + '-' + i}' class='days-of-month this-month today'><span>${i}</span></td>`);
|
|
631
|
+
// } else {
|
|
632
|
+
// days.push(`<td id='${IDs.daysOfThisMonth + '-' + i}' class='days-of-month this-month'><span>${i}</span></td>`);
|
|
633
|
+
// }
|
|
634
|
+
// }
|
|
635
|
+
// for (let j = 1; j <= daysOfNextMonth - 1; j++) {
|
|
636
|
+
// if (checkActiveDay('dd/mm/yyyy', new Date(lastTime.getFullYear(), lastTime.getMonth(), lastTime.getDate() + j), input.value)) {
|
|
637
|
+
// days.push(`<td id='${IDs.daysOfNextMonth + '-' + j}' class='days-of-month day-active next-date'>${j}</td>`);
|
|
638
|
+
// } else {
|
|
639
|
+
// days.push(`<td id='${IDs.daysOfNextMonth + '-' + j}' class='days-of-month next-date'>${j}</td>`);
|
|
640
|
+
// }
|
|
641
|
+
// }
|
|
642
|
+
// let table = '';
|
|
643
|
+
// table += '<tr>';
|
|
644
|
+
// for (let i = 0; i < weekdaysLong.length; i++){
|
|
645
|
+
// table += `<th id="${IDs.calendarWeekday + '-' + i}" className="weekday">
|
|
646
|
+
// ${size === 'small' ? weekdaysShort[i] : weekdaysLong[i]}
|
|
647
|
+
// </th>`;
|
|
648
|
+
// };
|
|
649
|
+
// table += '</tr>';
|
|
650
|
+
// for (let r = 0; r <= 5; r++) {
|
|
651
|
+
// table += '<tr>';
|
|
652
|
+
// for (let d = 0; d <= 6; d++) {
|
|
653
|
+
// if (days[7 * r + d]) {
|
|
654
|
+
// table += days[7 * r + d];
|
|
655
|
+
// };
|
|
656
|
+
// }
|
|
657
|
+
// table += '</tr>';
|
|
658
|
+
// }
|
|
659
|
+
// monthDays.innerHTML = table;
|
|
660
|
+
// header.innerHTML = size === 'medium' ? `${months[date.getMonth()]} năm ${date.getFullYear()}` : addZeroToText(date.getMonth() + 1) + '/' + date.getFullYear();
|
|
661
|
+
// monthDays.querySelectorAll('.days-of-month.this-month').forEach((dc) => {
|
|
662
|
+
// dc.addEventListener('click', (e) => setActiveDay(e, date));
|
|
663
|
+
// });
|
|
664
|
+
// };
|
|
665
|
+
// const parseStringToDateTime = (text) => {
|
|
666
|
+
// if (text.split('/').length > 1) {
|
|
667
|
+
// return new Date(text.split('/')[1] + ' ' + text.split('/')[0] + ' ' + text.split('/')[2]);
|
|
668
|
+
// }
|
|
669
|
+
// if (text.split('-').length > 1) {
|
|
670
|
+
// return new Date(text.split('-')[1] + ' ' + text.split('-')[0] + ' ' + text.split('-')[2]);
|
|
671
|
+
// }
|
|
672
|
+
// };
|
|
673
|
+
// const onChangeValue = (e) => {
|
|
674
|
+
// const valid = helperRef.current.childNodes[0];
|
|
675
|
+
// const invalid = helperRef.current.childNodes[1];
|
|
676
|
+
// const text = e.target.value;
|
|
677
|
+
// const time = parseStringToDateTime(text);
|
|
678
|
+
// if (text.length >= 8) {
|
|
679
|
+
// if (onValidateDate(text)) {
|
|
680
|
+
// const date = text.split(/[\/|-]/);
|
|
681
|
+
// e.value = date[2] + '-' + date[1] + '-' + date[0];
|
|
682
|
+
// invalid.style.visibility = 'hidden';
|
|
683
|
+
// valid.style.visibility = 'visible';
|
|
684
|
+
// onChange && onChange(e);
|
|
685
|
+
// setTimeout(() => { valid.style.visibility = 'hidden';}, 3000);
|
|
686
|
+
// nowDate.setTime(time);
|
|
687
|
+
// renderCalendar(nowDate);
|
|
688
|
+
// getElById(`${IDs.daysOfThisMonth + '-' + time.getDate()}`).classList.add('day-active');
|
|
689
|
+
// } else {
|
|
690
|
+
// invalid.style.visibility = 'visible';
|
|
691
|
+
// valid.style.visibility = 'hidden';
|
|
692
|
+
// onChange && onChange(e.target);
|
|
693
|
+
// }
|
|
694
|
+
// } else {
|
|
695
|
+
// invalid.style.visibility = 'visible';
|
|
696
|
+
// valid.style.visibility = 'hidden';
|
|
697
|
+
// onChange && onChange(e.target);
|
|
698
|
+
// }
|
|
699
|
+
// };
|
|
700
|
+
// const onValidateDate = (inputText) => {
|
|
701
|
+
// const dateformat = /^(0?[1-9]|[12][0-9]|3[01])\/(0?[1-9]|1[012])\/\d{4}$/;
|
|
702
|
+
// // Match the date format through regular expression
|
|
703
|
+
// if (typeof inputText === 'string' && inputText.match(dateformat)) {
|
|
704
|
+
// //Test which separator is used '/' or '-'
|
|
705
|
+
// let opera1 = inputText.split('/');
|
|
706
|
+
// let opera2 = inputText.split('-');
|
|
707
|
+
// // Extract the string into month, date and year
|
|
708
|
+
// let pDate;
|
|
709
|
+
// if (opera1.length > 1) {
|
|
710
|
+
// pDate = inputText.split('/');
|
|
711
|
+
// } else if (opera2.length > 1) {
|
|
712
|
+
// pDate = inputText.split('-');
|
|
713
|
+
// }
|
|
714
|
+
// let dd = parseInt(pDate[0]);
|
|
715
|
+
// let mm = parseInt(pDate[1]);
|
|
716
|
+
// let yy = parseInt(pDate[2]);
|
|
717
|
+
// // Create list of days of a month [assume there is no leap year by default]
|
|
718
|
+
// const ListOfDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
719
|
+
// if (mm === 1 || mm > 2) {
|
|
720
|
+
// if (dd > ListOfDays[mm - 1]) {
|
|
721
|
+
// return false;
|
|
722
|
+
// }
|
|
723
|
+
// }
|
|
724
|
+
// if (mm === 2) {
|
|
725
|
+
// let lYear = false;
|
|
726
|
+
// if ((!(yy % 4) && yy % 100) || !(yy % 400)) {
|
|
727
|
+
// lYear = true;
|
|
728
|
+
// }
|
|
729
|
+
// if (lYear === false && dd >= 29) {
|
|
730
|
+
// return false;
|
|
731
|
+
// }
|
|
732
|
+
// if (lYear === true && dd > 29) {
|
|
733
|
+
// return false;
|
|
734
|
+
// }
|
|
735
|
+
// }
|
|
736
|
+
// if (yy < 1900) {
|
|
737
|
+
// return false;
|
|
738
|
+
// }
|
|
739
|
+
// } else {
|
|
740
|
+
// return false;
|
|
741
|
+
// }
|
|
742
|
+
// return true;
|
|
743
|
+
// };
|
|
744
|
+
// const checkInputValue = (e) => {
|
|
745
|
+
// if (!disabled) {
|
|
746
|
+
// if (!/[0-9\\/]/.test(e.key)) {
|
|
747
|
+
// e.preventDefault();
|
|
748
|
+
// }
|
|
749
|
+
// } else {
|
|
750
|
+
// e.preventDefault();
|
|
751
|
+
// }
|
|
752
|
+
// };
|
|
753
|
+
// const setValueInput = (e, d) => {
|
|
754
|
+
// //set the input's value with format dd/mm/yyyy (01/02/xxxx)
|
|
755
|
+
// helperRef.current.childNodes[0].style.visibility = 'hidden';
|
|
756
|
+
// helperRef.current.childNodes[1].style.visibility = 'hidden';
|
|
757
|
+
// const input = inputRef.current;
|
|
758
|
+
// input.value = `${addZeroToText(e)}/${addZeroToText(d.getMonth() + 1)}/${d.getFullYear()}`;
|
|
759
|
+
// let sentValue = { value: null };
|
|
760
|
+
// sentValue.value = `${d.getFullYear()}-${addZeroToText(d.getMonth() + 1)}-${addZeroToText(e)}`;
|
|
761
|
+
// onChange && onChange(sentValue);
|
|
762
|
+
// };
|
|
763
|
+
// const setActiveDay = (e, date) => {
|
|
764
|
+
// //find the active day then remove this, add the new class active for the new day and set value for input
|
|
765
|
+
// const find = allDaysOfMonthRef.current.querySelector('.day-active');
|
|
766
|
+
// if (find) {
|
|
767
|
+
// find.classList.remove('day-active');
|
|
768
|
+
// }
|
|
769
|
+
// e.target.classList.add('day-active');
|
|
770
|
+
// setValueInput(e.target.textContent, date);
|
|
771
|
+
// };
|
|
772
|
+
// const setPrevMonth = () => {
|
|
773
|
+
// //set month to the the previous month (month - 1) and re-render the calendar
|
|
774
|
+
// const input = inputRef.current;
|
|
775
|
+
// const date = parseStringToDateTime(input.value);
|
|
776
|
+
// nowDate.setMonth(nowDate.getMonth() - 1);
|
|
777
|
+
// renderCalendar(nowDate);
|
|
778
|
+
// if (date && date.getFullYear() === nowDate.getFullYear() && date.getMonth() === nowDate.getMonth()) {
|
|
779
|
+
// getElById(`${IDs.daysOfThisMonth + '-' + date.getDate()}`).classList.add('day-active');
|
|
780
|
+
// }
|
|
781
|
+
// };
|
|
782
|
+
// const setPrevYear = () => {
|
|
783
|
+
// //set year to the the previous year (year - 1) and re-render the calendar
|
|
784
|
+
// const input = inputRef.current;
|
|
785
|
+
// const date = parseStringToDateTime(input.value);
|
|
786
|
+
// nowDate.setFullYear(nowDate.getFullYear() - 1);
|
|
787
|
+
// renderCalendar(nowDate);
|
|
788
|
+
// if (date && date.getFullYear() === nowDate.getFullYear() && date.getMonth() === nowDate.getMonth()) {
|
|
789
|
+
// getElById(`${IDs.daysOfThisMonth + '-' + date.getDate()}`).classList.add('day-active');
|
|
790
|
+
// }
|
|
791
|
+
// };
|
|
792
|
+
// const setNextMonth = () => {
|
|
793
|
+
// //set month to the the next month (month + 1) and re-render the calendar
|
|
794
|
+
// const input = inputRef.current;
|
|
795
|
+
// const date = parseStringToDateTime(input.value);
|
|
796
|
+
// nowDate.setMonth(nowDate.getMonth() + 1);
|
|
797
|
+
// renderCalendar(nowDate);
|
|
798
|
+
// if (date && date.getFullYear() === nowDate.getFullYear() && date.getMonth() === nowDate.getMonth()) {
|
|
799
|
+
// getElById(`${IDs.daysOfThisMonth + '-' + date.getDate()}`).classList.add('day-active');
|
|
800
|
+
// }
|
|
801
|
+
// };
|
|
802
|
+
// const setNextYear = () => {
|
|
803
|
+
// //set year to the next year (year + 1) and re-render the calendar
|
|
804
|
+
// const input = inputRef.current;
|
|
805
|
+
// const date = parseStringToDateTime(input.value);
|
|
806
|
+
// nowDate.setFullYear(nowDate.getFullYear() + 1);
|
|
807
|
+
// renderCalendar(nowDate);
|
|
808
|
+
// if (date && date.getFullYear() === nowDate.getFullYear() && date.getMonth() === nowDate.getMonth()) {
|
|
809
|
+
// getElById(`${IDs.daysOfThisMonth + '-' + date.getDate()}`).classList.add('day-active');
|
|
810
|
+
// }
|
|
811
|
+
// };
|
|
812
|
+
// const checkDefaultValue = (defaultTime, inputEl) => {
|
|
813
|
+
// if (!isNaN(Date.parse(defaultValue))) {
|
|
814
|
+
// let date = addZeroToText(defaultTime.getDate());
|
|
815
|
+
// let month = addZeroToText(defaultTime.getMonth() + 1);
|
|
816
|
+
// let year = defaultTime.getFullYear();
|
|
817
|
+
// let time = `${date}/${month}/${year}`;
|
|
818
|
+
// inputEl.value = onValidateDate(defaultValue) ? defaultValue : (defaultTime && defaultTime.getDate()) ? time : validateAlert;
|
|
819
|
+
// getElById(`${IDs.daysOfThisMonth + '-' + defaultTime.getDate()}`).classList.add('day-active');
|
|
820
|
+
// }
|
|
821
|
+
// };
|
|
822
|
+
// useEffect(() => {
|
|
823
|
+
// const input = inputRef.current;
|
|
824
|
+
// const container = ref.current;
|
|
825
|
+
// const scrollArea = getScrollParent(container);
|
|
826
|
+
// setPosition();
|
|
827
|
+
// renderCalendar(nowDate);
|
|
828
|
+
// checkDefaultValue(nowDate, input);
|
|
829
|
+
// scrollArea.addEventListener('scroll', setPosition);
|
|
830
|
+
// window.addEventListener('resize', setPosition);
|
|
831
|
+
// document.addEventListener('keydown', e => escKeyFunc(e));
|
|
832
|
+
// return () => {
|
|
833
|
+
// scrollArea.removeEventListener('scroll', setPosition);
|
|
834
|
+
// window.removeEventListener('resize', setPosition);
|
|
835
|
+
// document.removeEventListener('keydown', e => escKeyFunc(e));
|
|
836
|
+
// }
|
|
837
|
+
// }, []);
|
|
838
|
+
// useEffect(() => {
|
|
839
|
+
// if (error && error !== '') {
|
|
840
|
+
// inputContainerRef.current.classList.add('error-message');
|
|
841
|
+
// } else {
|
|
842
|
+
// inputContainerRef.current.classList.remove('error-message')
|
|
843
|
+
// }
|
|
844
|
+
// },[error]);
|
|
845
|
+
// useEffect(() => {
|
|
846
|
+
// renderCalendar(nowDate)
|
|
847
|
+
// }, [size]);
|
|
848
|
+
// const RequireMemo = useMemo(() => ( required && <span css={styles.require}>*</span> ), [error, required]);
|
|
849
|
+
// const LabelMemo = useMemo(() => (
|
|
850
|
+
// <label css={styles.label} disabled={disabled}>
|
|
851
|
+
// {label}{RequireMemo}
|
|
852
|
+
// </label>
|
|
853
|
+
// ), [disabled, error, required, label]);
|
|
854
|
+
// const HelperMemo = useMemo(() => (
|
|
855
|
+
// <div css={styles.helper} ref={helperRef}>
|
|
856
|
+
// <span className={'helper-text valid'}>
|
|
857
|
+
// {helperValid}
|
|
858
|
+
// </span>
|
|
859
|
+
// <span className={'helper-text invalid'}>
|
|
860
|
+
// {helperInvalid}
|
|
861
|
+
// </span>
|
|
862
|
+
// </div>
|
|
863
|
+
// ), [helperValid, helperInvalid]);
|
|
864
|
+
// const InputMemo = useMemo(() => (
|
|
865
|
+
// <input
|
|
866
|
+
// {...inputProps}
|
|
867
|
+
// css={styles.input.input[viewType]}
|
|
868
|
+
// className={'input-type-date'}
|
|
869
|
+
// disabled={disabled}
|
|
870
|
+
// id={IDs.inputTypeDate}
|
|
871
|
+
// placeholder={'dd/mm/yyyy'}
|
|
872
|
+
// onBlur={onInputBlur}
|
|
873
|
+
// onChange={(e) => onChangeValue(e)}
|
|
874
|
+
// onFocus={(e) => onInputFocus(e)}
|
|
875
|
+
// onKeyPress={(e) => checkInputValue(e)}
|
|
876
|
+
// ref={inputRef}
|
|
877
|
+
// />
|
|
878
|
+
// ), [defaultValue, disabled, viewType]);
|
|
879
|
+
// const IconMemo = useMemo(() => (
|
|
880
|
+
// <React.Fragment>
|
|
881
|
+
// <span className={'svg svg-default'} onClick={(e) => onInputFocus(e)}>
|
|
882
|
+
// <CalendarIcon color={'currentColor'} />
|
|
883
|
+
// </span>
|
|
884
|
+
// <span className={'svg svg-focus'} onClick={(e) => onClickOutside(e)}>
|
|
885
|
+
// <CancelIcon color={'currentColor'} width={'15'} height={'15'} />
|
|
886
|
+
// </span>
|
|
887
|
+
// </React.Fragment>
|
|
888
|
+
// ), [disabled]);
|
|
889
|
+
// const HeaderMemo = useMemo(() => (
|
|
890
|
+
// // <CalendarNavigator ref={headerRef} contentRef={headerTitleRef} onArrowDBLeftClick={setPrevYear}
|
|
891
|
+
// // onArrowDBRightClick={setNextYear} onArrowLeftClick={setPrevMonth} onArrowRightClick={setNextMonth} />
|
|
892
|
+
// <div></div>
|
|
893
|
+
// ), [size, viewType]);
|
|
894
|
+
// const DaysMemo = useMemo(() => (
|
|
895
|
+
// <table className={`${viewType}-days`} css={styles.days} ref={allDaysOfMonthRef} />
|
|
896
|
+
// ), [defaultValue, size, viewType]);
|
|
897
|
+
// const CalendarMemo = useMemo(() => (
|
|
898
|
+
// <div className={'calendar'} css={styles.calendar} ref={calendarRef}>
|
|
899
|
+
// {HeaderMemo}
|
|
900
|
+
// {DaysMemo}
|
|
901
|
+
// </div>
|
|
902
|
+
// ), [defaultValue, size, viewType]);
|
|
903
|
+
// const MainMemo = useMemo(() => (
|
|
904
|
+
// <div className={'input-container'} css={styles.input.container[viewType]} disabled={disabled} ref={inputContainerRef}>
|
|
905
|
+
// {InputMemo}
|
|
906
|
+
// {IconMemo}
|
|
907
|
+
// {error && <span css={styles.error}>{error}</span>}
|
|
908
|
+
// {CalendarMemo}
|
|
909
|
+
// </div>
|
|
910
|
+
// ), [defaultValue, disabled, error, size, viewType]);
|
|
911
|
+
// return (
|
|
912
|
+
// <div {...props} css={styles.container} ref={ref}>
|
|
913
|
+
// {LabelMemo}
|
|
914
|
+
// {HelperMemo}
|
|
915
|
+
// {MainMemo}
|
|
916
|
+
// </div>
|
|
917
|
+
// );
|
|
918
|
+
// }));
|
|
919
|
+
// DatePicker.defaultProps = {
|
|
920
|
+
// defaultValue : '',
|
|
921
|
+
// disabled : false,
|
|
922
|
+
// error : '',
|
|
923
|
+
// helperInvalid : 'Value is invalid',
|
|
924
|
+
// helperValid : 'Value is valid',
|
|
925
|
+
// required : false,
|
|
926
|
+
// size : 'medium',
|
|
927
|
+
// viewType : 'underlined',
|
|
928
|
+
// }
|
|
929
|
+
// DatePicker.propTypes = {
|
|
930
|
+
// /** the default value of the calendar, it exist when render */
|
|
931
|
+
// defaultValue : PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
932
|
+
// /** if 'true' the form control will be disabled */
|
|
933
|
+
// disabled : PropTypes.bool,
|
|
934
|
+
// /** error of the form control */
|
|
935
|
+
// error : PropTypes.string,
|
|
936
|
+
// /** helper text when the value typed wrong */
|
|
937
|
+
// helperInvalid: PropTypes.string,
|
|
938
|
+
// /** helper text when the value typed really right */
|
|
939
|
+
// helperValid : PropTypes.string,
|
|
940
|
+
// /** inputProps is properties of the input */
|
|
941
|
+
// inputProps : PropTypes.object,
|
|
942
|
+
// /** label of the form control */
|
|
943
|
+
// label : PropTypes.string,
|
|
944
|
+
// /** a callback function when value input change */
|
|
945
|
+
// onChange : PropTypes.func,
|
|
946
|
+
// /** required state of the form control */
|
|
947
|
+
// required : PropTypes.bool,
|
|
948
|
+
// /** size of the calendar */
|
|
949
|
+
// size : PropTypes.oneOf(['medium', 'small']),
|
|
950
|
+
// /** view type of the form control */
|
|
951
|
+
// viewType : PropTypes.oneOf(['outlined', 'underlined']),
|
|
952
|
+
// };
|
|
953
|
+
// export default DatePicker;
|