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,10 @@
|
|
|
1
|
+
import capitalize from './capitalize';
|
|
2
|
+
export default function capitalizeSentenceCase(string, separator = ' ') {
|
|
3
|
+
const sentence = string.toLowerCase().split(`${separator}`);
|
|
4
|
+
|
|
5
|
+
for (let i in sentence) {
|
|
6
|
+
sentence[i] = capitalize(sentence[i]);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return sentence.join(`${separator}`);
|
|
10
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { isFunction, isString } from '../type';
|
|
2
|
+
export const encodeHtml = str => {
|
|
3
|
+
const encodeRegExp = [new RegExp('&', 'g'), new RegExp('"', 'g'), new RegExp("'", 'g'), new RegExp('<', 'g'), new RegExp('>', 'g')];
|
|
4
|
+
return String(str).replace(encodeRegExp[0], '&').replace(encodeRegExp[1], '"').replace(encodeRegExp[2], ''').replace(encodeRegExp[3], '<').replace(encodeRegExp[4], '>');
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const splitQuad = raw => {
|
|
8
|
+
switch (typeof raw) {
|
|
9
|
+
case 'string':
|
|
10
|
+
return raw.split(/\s+/, 4);
|
|
11
|
+
|
|
12
|
+
case 'object':
|
|
13
|
+
return [raw.x || raw.h || raw.left, raw.y || raw.v || raw.top, raw.x || raw.h || raw.right, raw.y || raw.v || raw.bottom];
|
|
14
|
+
|
|
15
|
+
case 'number':
|
|
16
|
+
return [raw];
|
|
17
|
+
|
|
18
|
+
default:
|
|
19
|
+
return raw;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const quadToObject = raw => {
|
|
24
|
+
const quad = splitQuad(raw);
|
|
25
|
+
let left = parseInt(quad && quad[0], 10);
|
|
26
|
+
let top = parseInt(quad && quad[1], 10);
|
|
27
|
+
let right = parseInt(quad && quad[2], 10);
|
|
28
|
+
let bottom = parseInt(quad && quad[3], 10);
|
|
29
|
+
|
|
30
|
+
if (!isFinite(left)) {
|
|
31
|
+
left = 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!isFinite(top)) {
|
|
35
|
+
top = left;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!isFinite(right)) {
|
|
39
|
+
right = left;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!isFinite(bottom)) {
|
|
43
|
+
bottom = top;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
top: top,
|
|
48
|
+
right: right,
|
|
49
|
+
bottom: bottom,
|
|
50
|
+
left: left
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export const format = (template, ...values) => {
|
|
54
|
+
if (isFunction(template)) {
|
|
55
|
+
return template(...values);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
values.forEach((value, index) => {
|
|
59
|
+
if (isString(value)) {
|
|
60
|
+
value = value.replace(/\$/g, '$$$$');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const placeholderReg = new RegExp('\\{' + index + '\\}', 'gm');
|
|
64
|
+
template = template.replace(placeholderReg, value);
|
|
65
|
+
});
|
|
66
|
+
return template;
|
|
67
|
+
};
|
|
68
|
+
export const replaceAll = (() => {
|
|
69
|
+
const quote = str => (str + '').replace(/([+*?.[^\]$(){}><|=!:])/g, '\\$1'); // lgtm[js/incomplete-sanitization]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
return (text, searchToken, replacementToken) => text.replace(new RegExp('(' + quote(searchToken) + ')', 'gi'), replacementToken);
|
|
73
|
+
})();
|
|
74
|
+
export const isEmpty = (() => {
|
|
75
|
+
const SPACE_REGEXP = /\s/g;
|
|
76
|
+
return text => !text || !text.replace(SPACE_REGEXP, '');
|
|
77
|
+
})();
|
|
78
|
+
export const isEmail = str => {
|
|
79
|
+
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
80
|
+
return re.test(String(str).toLowerCase());
|
|
81
|
+
};
|
package/utils/type.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const types = {
|
|
2
|
+
'[object Array]': 'array',
|
|
3
|
+
'[object Date]': 'date',
|
|
4
|
+
'[object Object]': 'object',
|
|
5
|
+
'[object String]': 'string',
|
|
6
|
+
'[object Null]': 'null'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const type = object => {
|
|
10
|
+
const typeOfObject = Object.prototype.toString.call(object);
|
|
11
|
+
return typeof object === 'object' ? types[typeOfObject] || 'object' : typeof object;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const isBoolean = object => {
|
|
15
|
+
return typeof object === 'boolean';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const isExponential = value => {
|
|
19
|
+
return isNumeric(value) && value.toString().indexOf('e') !== -1;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const isDate = object => {
|
|
23
|
+
return type(object) === 'date';
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const isDefined = object => {
|
|
27
|
+
return object !== null && object !== undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const isFunction = object => {
|
|
31
|
+
return typeof object === 'function';
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isString = object => {
|
|
35
|
+
return typeof object === 'string';
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const isNumeric = object => {
|
|
39
|
+
return typeof object === 'number' && isFinite(object) || !isNaN(object - parseFloat(object));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isObject = object => {
|
|
43
|
+
return type(object) === 'object';
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const isEmptyObject = object => {
|
|
47
|
+
let property;
|
|
48
|
+
|
|
49
|
+
for (property in object) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const isPlainObject = object => {
|
|
57
|
+
if (!object || Object.prototype.toString.call(object) !== '[object Object]') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const proto = Object.getPrototypeOf(object);
|
|
62
|
+
const ctor = Object.hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
63
|
+
return typeof ctor === 'function' && Object.toString.call(ctor) === Object.toString.call(Object);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const isPrimitive = value => {
|
|
67
|
+
return ['object', 'array', 'function'].indexOf(type(value)) === -1;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const isWindow = object => {
|
|
71
|
+
return object != null && object === object.window;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const isRenderer = object => {
|
|
75
|
+
return !!(object.jquery || object.dxRenderer);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const isPromise = object => {
|
|
79
|
+
return object && isFunction(object.then);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const isDeferred = object => {
|
|
83
|
+
return object && isFunction(object.done) && isFunction(object.fail);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const isEvent = object => {
|
|
87
|
+
return !!(object && object.preventDefault);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export { isBoolean, isExponential, isDate, isDefined, isFunction, isString, isNumeric, isObject, isEmptyObject, isPlainObject, isPrimitive, isWindow, isRenderer, isPromise, isDeferred, type, isEvent };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const updatePosition = (anchorEl, transformEl, cb) => {
|
|
2
|
+
const {
|
|
3
|
+
top,
|
|
4
|
+
bottom,
|
|
5
|
+
left,
|
|
6
|
+
right
|
|
7
|
+
} = anchorEl.getBoundingClientRect();
|
|
8
|
+
const {
|
|
9
|
+
innerHeight,
|
|
10
|
+
innerWidth
|
|
11
|
+
} = window;
|
|
12
|
+
const {
|
|
13
|
+
height: nodeHeight
|
|
14
|
+
} = transformEl.getBoundingClientRect(); // Vertical
|
|
15
|
+
|
|
16
|
+
if (bottom < 0 || top > innerHeight) {
|
|
17
|
+
cb();
|
|
18
|
+
} else if (bottom + 4 + nodeHeight > innerHeight) {
|
|
19
|
+
if (top - (nodeHeight + 4) > 0) {
|
|
20
|
+
transformEl.style.top = top - (nodeHeight + 4) + 'px';
|
|
21
|
+
} else {
|
|
22
|
+
transformEl.style.top = innerHeight - nodeHeight + 'px';
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
transformEl.style.top = bottom + 4 + 'px';
|
|
26
|
+
} // Horizontal
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if (left < 0 || right > innerWidth) {
|
|
30
|
+
cb();
|
|
31
|
+
} else {
|
|
32
|
+
transformEl.style.left = left + 'px';
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default updatePosition;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://usehooks.com/useOnClickOutside/
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
export default function useOnClickOutside(ref, handler) {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const listener = event => {
|
|
8
|
+
// Do nothing if clicking ref's element or descendent elements
|
|
9
|
+
if (!ref.current || ref.current.contains(event.target)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
handler(event);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
document.addEventListener('mousedown', listener);
|
|
17
|
+
document.addEventListener('touchstart', listener);
|
|
18
|
+
return () => {
|
|
19
|
+
document.removeEventListener('mousedown', listener);
|
|
20
|
+
document.removeEventListener('touchstart', listener);
|
|
21
|
+
};
|
|
22
|
+
}, [ref, handler]);
|
|
23
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Create a element with id
|
|
4
|
+
* @param {string} id
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const createEl = id => {
|
|
8
|
+
const createdEl = document.createElement('div');
|
|
9
|
+
createdEl.setAttribute('id', id);
|
|
10
|
+
return createdEl;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Insert into document.body at last
|
|
14
|
+
* @param {Element} rootElem
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const addRootEl = rootElem => {
|
|
18
|
+
document.body.insertBefore(rootElem, document.body.lastElementChild.nextElementSibling);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Create a portal with id
|
|
22
|
+
* @param {string} id
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const usePortal = id => {
|
|
26
|
+
const rootElemRef = useRef(null);
|
|
27
|
+
|
|
28
|
+
const getRootEl = () => {
|
|
29
|
+
if (!rootElemRef.current) {
|
|
30
|
+
rootElemRef.current = document.createElement('div');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return rootElemRef.current;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const existingParent = document.querySelector(`#${id}`);
|
|
38
|
+
const parentEl = existingParent || createEl(id);
|
|
39
|
+
|
|
40
|
+
if (!existingParent) {
|
|
41
|
+
addRootEl(parentEl);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
parentEl.appendChild(rootElemRef.current);
|
|
45
|
+
return () => {
|
|
46
|
+
rootElemRef.current.remove();
|
|
47
|
+
|
|
48
|
+
if (parentEl.childNodes.length === -1) {
|
|
49
|
+
parentEl.remove();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
return getRootEl();
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default usePortal;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { getGlobal } from '../global';
|
|
2
|
+
import { isEmail as isEmailHandler } from './';
|
|
3
|
+
/**
|
|
4
|
+
* Validation the string is an valid email
|
|
5
|
+
* @param {String} str The string to check an email
|
|
6
|
+
* @param {String} message the error will return if str is not an email
|
|
7
|
+
* @returns {Boolean} true if value is an email, message or default error if value is not an email
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const isEmail = (str, _, message) => {
|
|
11
|
+
if (!nonNullish(str) || str === '') return true;
|
|
12
|
+
return isEmailHandler(str) || (nonNullish(message) ? message : getGlobal(['validate', 'isEmail']));
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Validation value is not an empty string, array or object
|
|
16
|
+
* @param {String|Object|Array} value the value to validate not empty
|
|
17
|
+
* @param {String} message the error will return if value is empty
|
|
18
|
+
* @returns {Boolean} true if value is not empty, message or default error if value is empty
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const isNotEmpty = (value, _, message) => {
|
|
22
|
+
if (!nonNullish(value)) return getGlobal(['validate', 'invalidInput']);
|
|
23
|
+
|
|
24
|
+
if (typeof value === 'string') {
|
|
25
|
+
return value !== '' || message || getGlobal(['validate', 'isNotEmptyString']);
|
|
26
|
+
} else if (typeof value === 'object') {
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
return value.length || message || getGlobal(['validate', 'isNotEmptyArray']);
|
|
29
|
+
} else {
|
|
30
|
+
return Object.keys(value).length || message || getGlobal(['validate', 'isNotEmptyObject']);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Check a number is less than or equal the maximum allowed
|
|
38
|
+
* @param {Number} value the value to compare with maximum
|
|
39
|
+
* @param {Number} maximum the maximum value
|
|
40
|
+
* @param {String} message the error will return if value > maximum
|
|
41
|
+
* @returns {Boolean|String} true if value is valid, message or default error if invalid (both value and maximum)
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
export const max = (value, maximum, message) => {
|
|
45
|
+
if (!nonNullish([value, maximum]) || value === '') return true;
|
|
46
|
+
if (isNaN(value) || isNaN(maximum)) return getGlobal(['validate', 'invalidInput']);
|
|
47
|
+
return value <= maximum || (nonNullish(message) ? message : `${getGlobal(['validate', 'max'])} (${maximum})`);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* check a number is greater than or equal the minimum allowed
|
|
51
|
+
* @param {Number} value the value to compare with minimize
|
|
52
|
+
* @param {Number} minimize the minimize value
|
|
53
|
+
* @param {String} message the error will return if value < minimize
|
|
54
|
+
* @returns {Boolean|String} true if value is valid, message or default error if invalid (both value and minimize)
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
export const min = (value, minimize, message) => {
|
|
58
|
+
if (!nonNullish([value, minimize]) || value === '') return true;
|
|
59
|
+
if (isNaN(value) || isNaN(minimize)) return getGlobal(['validate', 'invalidInput']);
|
|
60
|
+
return value >= minimize || (nonNullish(message) ? message : `${getGlobal(['validate', 'min'])} (${minimize})`);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* check value has anything
|
|
64
|
+
* @param {String|Number|Object} value the value to check
|
|
65
|
+
* @param {String} message the error will return if undefined|null|empty
|
|
66
|
+
* @returns {Boolean|String} true if value is valid, message input or default error if value invalid
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
export const required = (value, message) => {
|
|
70
|
+
return nonNullish(value) && value !== '' || (nonNullish(message) ? message : getGlobal(['validate', 'required']));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const nonNullish = value => {
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
return value.every(v => v !== undefined && v !== null);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return value !== undefined && value !== null;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const validations = {
|
|
82
|
+
isEmail,
|
|
83
|
+
isNotEmpty,
|
|
84
|
+
max,
|
|
85
|
+
min,
|
|
86
|
+
required
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* validation value follow rule(s)
|
|
90
|
+
* @param {String|Number|Object|Array} value the value to validate
|
|
91
|
+
* @param {String|Object|Array} rules the rule(s) to validation value
|
|
92
|
+
* @param {Boolean} returnOneError only return first error if have errors
|
|
93
|
+
* @returns {Boolean|String|Array} true if value is valid, error text or an array error if invalid value
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
const onValidate = (value, rules, returnOneError) => {
|
|
97
|
+
if (!rules) return true;
|
|
98
|
+
let result = true;
|
|
99
|
+
|
|
100
|
+
if (typeof rules === 'function') {
|
|
101
|
+
result = rules(value);
|
|
102
|
+
} else if (typeof rules === 'object') {
|
|
103
|
+
if (Array.isArray(rules)) {
|
|
104
|
+
rules.forEach(rule => {
|
|
105
|
+
let res;
|
|
106
|
+
|
|
107
|
+
if (typeof rule === 'string') {
|
|
108
|
+
res = validations[rule](value);
|
|
109
|
+
} else {
|
|
110
|
+
const name = rule.name || Object.keys(rule)[0];
|
|
111
|
+
const compareValue = rule.compareValue !== undefined ? rule.compareValue : rule[name];
|
|
112
|
+
|
|
113
|
+
if (name && validations[name]) {
|
|
114
|
+
res = validations[name](value, compareValue, rule.message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (res !== true) {
|
|
119
|
+
if (result === true) {
|
|
120
|
+
result = [];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
result.push(res);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
const name = rules.name || Object.keys(rules)[0];
|
|
128
|
+
const compareValue = rules.compareValue !== undefined ? rules.compareValue : rules[name];
|
|
129
|
+
|
|
130
|
+
if (name) {
|
|
131
|
+
result = validations[name](value, compareValue, rules.message);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} else if (validations[rules]) {
|
|
135
|
+
result = validations[rules](value);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (returnOneError) {
|
|
139
|
+
if (result === true) {
|
|
140
|
+
return false;
|
|
141
|
+
} else if (typeof result === 'string') {
|
|
142
|
+
return result;
|
|
143
|
+
} else return result[0];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default onValidate;
|