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,94 @@
|
|
|
1
|
+
import { css } from '@emotion/core';
|
|
2
|
+
import theme from '../../theme/settings';
|
|
3
|
+
export const TreeViewRoot = css`
|
|
4
|
+
display: block;
|
|
5
|
+
position: relative;
|
|
6
|
+
.DGN-UI-Accordion {
|
|
7
|
+
box-shadow: none !important;
|
|
8
|
+
.DGN-UI-Accordion-Summary {
|
|
9
|
+
min-height: 40px;
|
|
10
|
+
padding: 0;
|
|
11
|
+
border-radius: 0;
|
|
12
|
+
&.focus {
|
|
13
|
+
background-color: ${theme.colors.focus};
|
|
14
|
+
}
|
|
15
|
+
.Accordion-Icon-Root {
|
|
16
|
+
margin-right: 4px;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
.DGN-UI-Accordion-Details-Content {
|
|
20
|
+
padding: 0;
|
|
21
|
+
margin-left: 16px;
|
|
22
|
+
border-radius: 0;
|
|
23
|
+
}
|
|
24
|
+
.Accordion-Icon-Root {
|
|
25
|
+
transition: opacity 0.2s ease-out;
|
|
26
|
+
opacity: 1;
|
|
27
|
+
&.DGN-Invisible {
|
|
28
|
+
opacity: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
&.DGN-Hidden {
|
|
32
|
+
display: none !important;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
.TreeView-All,
|
|
36
|
+
.TreeView-Content {
|
|
37
|
+
display: block;
|
|
38
|
+
position: relative;
|
|
39
|
+
.DGN-UI-Accordion {
|
|
40
|
+
margin-bottom: 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
.TreeView-Item-Checkbox {
|
|
44
|
+
display: inline-block;
|
|
45
|
+
position: relative;
|
|
46
|
+
height: 100%;
|
|
47
|
+
margin-right: 8px;
|
|
48
|
+
}
|
|
49
|
+
.TreeView-Item {
|
|
50
|
+
display: flex;
|
|
51
|
+
position: relative;
|
|
52
|
+
align-items: center;
|
|
53
|
+
min-height: 40px;
|
|
54
|
+
text-align: left;
|
|
55
|
+
color: ${theme.colors.text};
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
&.non-child {
|
|
58
|
+
transition: background-color 300ms ease;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
&.disabled {
|
|
61
|
+
color: ${theme.colors.disabled};
|
|
62
|
+
cursor: no-drop;
|
|
63
|
+
}
|
|
64
|
+
&:not(.disabled) {
|
|
65
|
+
&:hover {
|
|
66
|
+
background-color: ${theme.colors.hover};
|
|
67
|
+
}
|
|
68
|
+
&:focus {
|
|
69
|
+
background-color: ${theme.colors.focus};
|
|
70
|
+
}
|
|
71
|
+
&:active {
|
|
72
|
+
background-color: ${theme.colors.pressing};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
&.DGN-Hidden {
|
|
76
|
+
display: none !important;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
&.focus {
|
|
80
|
+
background-color: ${theme.colors.focus};
|
|
81
|
+
}
|
|
82
|
+
&.TreeView-Item-active .DGN-UI-Typography {
|
|
83
|
+
font-weight: bold;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
&.expand-able {
|
|
87
|
+
.TreeView-All {
|
|
88
|
+
margin-left: 34px;
|
|
89
|
+
}
|
|
90
|
+
.TreeView-Item.non-child {
|
|
91
|
+
padding-left: 34px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
@@ -0,0 +1,1009 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** @jsxRuntime classic */
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { memo, useMemo, useState, useEffect, useRef, forwardRef, Fragment, useImperativeHandle } from 'react';
|
|
7
|
+
import { render } from 'react-dom';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { jsx } from '@emotion/core';
|
|
10
|
+
import { TreeViewRoot } from './css';
|
|
11
|
+
import { Accordion, AccordionSummary, AccordionDetails, Typography, Checkbox, Divider, InputBase } from '..';
|
|
12
|
+
import Icon from '../../icons';
|
|
13
|
+
import { mapParent, randomString, removeUnicode } from '../../utils';
|
|
14
|
+
import { getGlobal } from '../../global';
|
|
15
|
+
const separatorPattern = /\{\w+\}/g;
|
|
16
|
+
const currentValue = {},
|
|
17
|
+
itemsRenderAsync = {};
|
|
18
|
+
const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
19
|
+
expand,
|
|
20
|
+
disabled,
|
|
21
|
+
disabledMap,
|
|
22
|
+
selectBox,
|
|
23
|
+
multiple,
|
|
24
|
+
selectAll,
|
|
25
|
+
allowSearch,
|
|
26
|
+
showSelectedItems,
|
|
27
|
+
disabledRelevantValue,
|
|
28
|
+
disabledBoldResult,
|
|
29
|
+
autoExpandToResult,
|
|
30
|
+
showChildrenOfResult,
|
|
31
|
+
displayExpr,
|
|
32
|
+
valueExpr,
|
|
33
|
+
id,
|
|
34
|
+
parentID,
|
|
35
|
+
className,
|
|
36
|
+
selectAllLabel,
|
|
37
|
+
multipleValueMode,
|
|
38
|
+
searchMode,
|
|
39
|
+
searchDelayTime,
|
|
40
|
+
renderAsyncWithLength,
|
|
41
|
+
renderAsyncFromLevel,
|
|
42
|
+
expandIcon,
|
|
43
|
+
collapseIcon,
|
|
44
|
+
dataSource,
|
|
45
|
+
value,
|
|
46
|
+
renderItem,
|
|
47
|
+
onChange,
|
|
48
|
+
searchProps,
|
|
49
|
+
...props
|
|
50
|
+
}, reference) => {
|
|
51
|
+
const ref = useRef(null);
|
|
52
|
+
const selectAllRef = useRef(null);
|
|
53
|
+
const inputValueRef = useRef(null);
|
|
54
|
+
const clearIconRef = useRef(null);
|
|
55
|
+
const timer = useRef(null);
|
|
56
|
+
const timeout = useRef(null);
|
|
57
|
+
const [unique] = useState(randomString(6, {
|
|
58
|
+
allowNumber: false,
|
|
59
|
+
allowSymbol: false
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
const determinateCheckbox = (input, determinate) => {
|
|
63
|
+
if (multipleValueMode === 'multiple' || disabledRelevantValue) {
|
|
64
|
+
input.classList[determinate ? 'add' : 'remove']('determinate');
|
|
65
|
+
input.classList[determinate ? 'remove' : 'add']('indeterminate');
|
|
66
|
+
input.nextElementSibling.classList[determinate ? 'add' : 'remove']('determinate');
|
|
67
|
+
input.nextElementSibling.classList[determinate ? 'remove' : 'add']('indeterminate');
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const triggerCheckboxRecursion = (nodes, isChecked) => {
|
|
72
|
+
nodes.forEach(el => {
|
|
73
|
+
if (el.classList.contains('non-child')) {
|
|
74
|
+
el.querySelector('input').checked = isChecked;
|
|
75
|
+
} else {
|
|
76
|
+
el.firstChild.querySelector('input').checked = isChecked;
|
|
77
|
+
triggerCheckboxRecursion(Array.from(el.lastChild.firstChild.childNodes), isChecked);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const checkedParentFollowValue = nodes => {
|
|
83
|
+
if (nodes && nodes.length) {
|
|
84
|
+
nodes.forEach(node => {
|
|
85
|
+
if (!node.classList.contains('non-child')) {
|
|
86
|
+
const input = node.firstChild.querySelector('input');
|
|
87
|
+
|
|
88
|
+
if (input.checked) {
|
|
89
|
+
if (!input.classList.contains('determinate')) {
|
|
90
|
+
determinateCheckbox(input, true);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Array.from(node.querySelectorAll('input')).forEach(el => {
|
|
94
|
+
el.checked = true;
|
|
95
|
+
|
|
96
|
+
if (!el.classList.contains('determinate')) {
|
|
97
|
+
determinateCheckbox(el, true);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
const checkedLeastOfOne = Array.from(node.querySelectorAll('input')).some(el => el.checked);
|
|
102
|
+
|
|
103
|
+
if (checkedLeastOfOne) {
|
|
104
|
+
input.checked = checkedLeastOfOne;
|
|
105
|
+
|
|
106
|
+
if (input.classList.contains('determinate')) {
|
|
107
|
+
determinateCheckbox(input, false);
|
|
108
|
+
}
|
|
109
|
+
} else if (input.checked) {
|
|
110
|
+
input.checked = false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const childNodes = Array.from(node.lastChild.firstChild.childNodes);
|
|
114
|
+
checkedParentFollowValue(childNodes);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const checkParentCheckbox = node => {
|
|
122
|
+
while (ref.current.contains(node)) {
|
|
123
|
+
node = node.parentNode;
|
|
124
|
+
|
|
125
|
+
if (multipleValueMode === 'multiple' && node.classList.contains('DGN-UI-Accordion-Details-Content')) {
|
|
126
|
+
const childNodes = Array.from(node.childNodes);
|
|
127
|
+
|
|
128
|
+
if (childNodes) {
|
|
129
|
+
var _node$parentNode;
|
|
130
|
+
|
|
131
|
+
// Số lượng input đã check, dùng để kiểm tra là đã check tất cả, check chưa đầy đủ hoặc chưa check phần tử nào
|
|
132
|
+
let determinateQuantity = 0;
|
|
133
|
+
const checkedQuantity = childNodes.reduce((quantity, el) => {
|
|
134
|
+
const input = el.querySelector('input');
|
|
135
|
+
determinateQuantity += +input.classList.contains('determinate');
|
|
136
|
+
return quantity + +input.checked;
|
|
137
|
+
}, 0); // Accordion root
|
|
138
|
+
|
|
139
|
+
node = (_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.parentNode;
|
|
140
|
+
|
|
141
|
+
if (node && node.firstChild) {
|
|
142
|
+
const input = node.firstChild.querySelector('input');
|
|
143
|
+
|
|
144
|
+
if (input) {
|
|
145
|
+
if (!checkedQuantity) {
|
|
146
|
+
input.checked = false;
|
|
147
|
+
currentValue[unique][input.value] = false;
|
|
148
|
+
} else {
|
|
149
|
+
input.checked = true;
|
|
150
|
+
|
|
151
|
+
if (checkedQuantity === childNodes.length && checkedQuantity === determinateQuantity) {
|
|
152
|
+
if (!input.classList.contains('determinate')) {
|
|
153
|
+
determinateCheckbox(input, true);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
currentValue[unique][input.value] = true;
|
|
157
|
+
} else {
|
|
158
|
+
if (input.classList.contains('determinate')) {
|
|
159
|
+
determinateCheckbox(input, false);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
currentValue[unique][input.value] = false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} else if (multipleValueMode === 'inheritance' && node.classList.contains('DGN-UI-Accordion')) {
|
|
169
|
+
const input = node.firstChild.firstChild.querySelector('input');
|
|
170
|
+
input.checked = true;
|
|
171
|
+
currentValue[unique][input.value] = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const checkChildrenCheckbox = (node, isChecked) => {
|
|
177
|
+
// node = node.nextElementSibling?.firstChild;
|
|
178
|
+
// if (node) {
|
|
179
|
+
// const childNodes = Array.from(node.childNodes);
|
|
180
|
+
// if (childNodes) {
|
|
181
|
+
// triggerCheckboxRecursion(childNodes, isChecked);
|
|
182
|
+
// }
|
|
183
|
+
// }
|
|
184
|
+
if (node) {
|
|
185
|
+
node.querySelectorAll('input').forEach(el => {
|
|
186
|
+
if (!el.classList.contains('determinate')) {
|
|
187
|
+
determinateCheckbox(el, true);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
el.checked = isChecked;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const checkedSelectAllCheckbox = () => {
|
|
196
|
+
const allInput = Array.from(ref.current.querySelectorAll('input'));
|
|
197
|
+
|
|
198
|
+
if (allInput.some(i => i.checked)) {
|
|
199
|
+
const isCheckedAll = allInput.every(i => i.checked);
|
|
200
|
+
|
|
201
|
+
if (isCheckedAll) {
|
|
202
|
+
if (!selectAllRef.current.classList.contains('determinate')) {
|
|
203
|
+
determinateCheckbox(selectAllRef.current, true);
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
if (selectAllRef.current.classList.contains('determinate')) {
|
|
207
|
+
determinateCheckbox(selectAllRef.current, false);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
selectAllRef.current.checked = true;
|
|
212
|
+
} else if (selectAllRef.current.checked) {
|
|
213
|
+
selectAllRef.current.checked = false;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const handleDisabledChildren = (node, isChecked) => {
|
|
218
|
+
if (node) {
|
|
219
|
+
node.querySelectorAll('.TreeView-Item.non-child, .DGN-UI-Accordion').forEach(el => {
|
|
220
|
+
el.classList[isChecked ? 'add' : 'remove']('disabled');
|
|
221
|
+
|
|
222
|
+
if (el.classList.contains('DGN-UI-Accordion')) {
|
|
223
|
+
el.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild.classList[isChecked ? 'add' : 'remove']('disabled');
|
|
224
|
+
el.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild.disabled = isChecked;
|
|
225
|
+
Array.from(el.childNodes).forEach(e => {
|
|
226
|
+
e.classList[isChecked ? 'add' : 'remove']('treeview-disabled');
|
|
227
|
+
});
|
|
228
|
+
} else {
|
|
229
|
+
el.firstChild.firstChild.firstChild.firstChild.disabled = isChecked;
|
|
230
|
+
el.parentNode.classList[isChecked ? 'add' : 'remove']('disabled');
|
|
231
|
+
el.firstChild.firstChild.firstChild.classList[isChecked ? 'add' : 'remove']('disabled');
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const handleDisabledParent = (node, isChecked) => {
|
|
238
|
+
while (ref.current.contains(node)) {
|
|
239
|
+
node = node.parentNode;
|
|
240
|
+
|
|
241
|
+
if (node.classList.contains('DGN-UI-Accordion') && node.firstChild.classList.contains('DGN-UI-Accordion-Summary')) {
|
|
242
|
+
const checkbox = node.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild; // Trường hợp phải set về false để xét các input đã check không bao gồm node này
|
|
243
|
+
|
|
244
|
+
checkbox.firstChild.checked = isChecked;
|
|
245
|
+
const mustDisabled = !!node.querySelectorAll('input:checked').length; // Nếu có ít nhất một input con được check thì phải checked cho input này
|
|
246
|
+
|
|
247
|
+
checkbox.firstChild.checked = mustDisabled;
|
|
248
|
+
determinateCheckbox(checkbox.firstChild, !mustDisabled);
|
|
249
|
+
node.classList[mustDisabled || isChecked ? 'add' : 'remove']('disabled');
|
|
250
|
+
checkbox.classList[mustDisabled || isChecked ? 'add' : 'remove']('disabled');
|
|
251
|
+
Array.from(node.childNodes).forEach(e => {
|
|
252
|
+
e.classList[mustDisabled || isChecked ? 'add' : 'remove']('treeview-disabled');
|
|
253
|
+
});
|
|
254
|
+
const summaryEl = node.firstChild;
|
|
255
|
+
|
|
256
|
+
if (!summaryEl.classList.contains('expanding')) {
|
|
257
|
+
summaryEl.lastChild.firstChild.click();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const setValue = (data, isChecked) => {
|
|
264
|
+
if (multiple && multipleValueMode !== 'single') {
|
|
265
|
+
currentValue[unique][typeof data === 'object' ? data[valueExpr] : data] = isChecked;
|
|
266
|
+
|
|
267
|
+
if (data.childItems && data.childItems.length) {
|
|
268
|
+
data.childItems.forEach(d => {
|
|
269
|
+
setValue(d, isChecked);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const clearAllValue = () => {
|
|
276
|
+
inputValueRef.current.value = '';
|
|
277
|
+
clearIconRef.current.style.opacity = 0;
|
|
278
|
+
Object.keys(currentValue[unique]).forEach(key => {
|
|
279
|
+
currentValue[unique][key] = false;
|
|
280
|
+
});
|
|
281
|
+
Array.from(ref.current.querySelectorAll('input')).forEach(input => {
|
|
282
|
+
input.checked = false;
|
|
283
|
+
});
|
|
284
|
+
!!onChange && onChange({
|
|
285
|
+
value: [],
|
|
286
|
+
data: []
|
|
287
|
+
}, []);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const setValueIntoInput = data => {
|
|
291
|
+
if (!data || !data.length) {
|
|
292
|
+
inputValueRef.current.value = '';
|
|
293
|
+
clearIconRef.current.style.opacity = 0;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (clearIconRef.current.style.opacity === '0') {
|
|
298
|
+
clearIconRef.current.style.opacity = null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
let result = '';
|
|
302
|
+
const keyArr = displayExpr.match(separatorPattern);
|
|
303
|
+
data.forEach(d => {
|
|
304
|
+
result += keyArr ? renderData(d, keyArr) : d[displayExpr] + ', ';
|
|
305
|
+
});
|
|
306
|
+
inputValueRef.current.value = result.replace(/, $/, '');
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const handleCheckbox = (isChecked = false, value = 'all') => {
|
|
310
|
+
if ((selectBox || multiple) && ref.current) {
|
|
311
|
+
if (value === 'all') {
|
|
312
|
+
ref.current.querySelectorAll('input').forEach(input => input.checked = isChecked);
|
|
313
|
+
} else if (value) {
|
|
314
|
+
if (typeof value === 'string') {
|
|
315
|
+
value = [value];
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
value.forEach(v => {
|
|
319
|
+
const input = ref.current.querySelector(`input[value="${v}"]`);
|
|
320
|
+
|
|
321
|
+
if (input) {
|
|
322
|
+
input.checked = isChecked;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const onClickHandler = (e, data) => {
|
|
330
|
+
const target = e.target;
|
|
331
|
+
const currentTarget = e.currentTarget;
|
|
332
|
+
let value = typeof data === 'object' ? data[valueExpr] : data;
|
|
333
|
+
const justSelected = value;
|
|
334
|
+
const result = [];
|
|
335
|
+
const checkBoxEl = currentTarget.querySelector('.TreeView-Item-Checkbox');
|
|
336
|
+
|
|
337
|
+
if (multiple) {
|
|
338
|
+
let checked = false;
|
|
339
|
+
let inputEl = null; // Click on text (not checkbox)
|
|
340
|
+
|
|
341
|
+
if (!checkBoxEl.contains(target)) {
|
|
342
|
+
inputEl = checkBoxEl.querySelector('input');
|
|
343
|
+
checked = !inputEl.checked || inputEl.classList.contains('indeterminate');
|
|
344
|
+
inputEl.checked = checked;
|
|
345
|
+
} else {
|
|
346
|
+
inputEl = currentTarget.querySelector('input');
|
|
347
|
+
checked = inputEl.checked || inputEl.classList.contains('indeterminate');
|
|
348
|
+
inputEl.checked = checked;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (multipleValueMode !== 'single') {
|
|
352
|
+
if (!currentTarget.classList.contains('non-child')) {
|
|
353
|
+
checkChildrenCheckbox(currentTarget.nextElementSibling, checked);
|
|
354
|
+
|
|
355
|
+
if (checked) {
|
|
356
|
+
determinateCheckbox(inputEl, true);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (checked || multipleValueMode === 'multiple') {
|
|
361
|
+
checkParentCheckbox(currentTarget);
|
|
362
|
+
} // Handle result when multiple
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
setValue(data, checked);
|
|
366
|
+
} else {
|
|
367
|
+
currentValue[unique][value] = checked;
|
|
368
|
+
|
|
369
|
+
if (disabledRelevantValue) {
|
|
370
|
+
// Disabled/Enabled parent and children node
|
|
371
|
+
if (!currentTarget.classList.contains('non-child')) {
|
|
372
|
+
handleDisabledChildren(currentTarget.nextElementSibling, checked);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
handleDisabledParent(currentTarget.parentNode, checked);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
result.push(...Object.keys(currentValue[unique]).filter(v => currentValue[unique][v]));
|
|
380
|
+
value = result;
|
|
381
|
+
|
|
382
|
+
if (value.length) {
|
|
383
|
+
data = dataSource.filter(obj => value.includes(typeof obj === 'object' ? obj[valueExpr] : obj));
|
|
384
|
+
} else {
|
|
385
|
+
data = [];
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (showSelectedItems) {
|
|
389
|
+
setValueIntoInput(data);
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
if (selectBox) {
|
|
393
|
+
const checkedInput = ref.current.querySelectorAll('input:checked');
|
|
394
|
+
let input = currentTarget.querySelector('input'); // Click on checkbox
|
|
395
|
+
|
|
396
|
+
if (checkBoxEl.contains(target)) {
|
|
397
|
+
if (!input.checked) {
|
|
398
|
+
input.checked = true;
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
} else if (checkedInput[0].isSameNode(input)) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (checkedInput) {
|
|
406
|
+
checkedInput.forEach(el => el.checked = false);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
input.checked = true;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
currentValue[unique][value] = true;
|
|
413
|
+
result.push(value);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (selectAllRef.current) {
|
|
417
|
+
checkedSelectAllCheckbox();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
e.value = value;
|
|
421
|
+
e.justSelected = justSelected;
|
|
422
|
+
e.data = data;
|
|
423
|
+
!!onChange && onChange(e, result);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const onSelectAll = e => {
|
|
427
|
+
let result;
|
|
428
|
+
|
|
429
|
+
if (!e.target.checked && e.target.classList.contains('determinate')) {
|
|
430
|
+
ref.current.querySelectorAll('input:checked').forEach(input => input.checked = false);
|
|
431
|
+
e.value = [];
|
|
432
|
+
result = [];
|
|
433
|
+
} else {
|
|
434
|
+
if (!e.target.classList.contains('determinate')) {
|
|
435
|
+
determinateCheckbox(e.target, true);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
e.target.checked = true;
|
|
439
|
+
ref.current.querySelectorAll('input').forEach(input => {
|
|
440
|
+
input.checked = true;
|
|
441
|
+
|
|
442
|
+
if (!input.classList.contains('determinate')) {
|
|
443
|
+
determinateCheckbox(input, true);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
result = Object.keys(currentValue[unique]).map(v => v);
|
|
447
|
+
e.value = result;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
!!onChange && onChange(e, result);
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
const onChangeHandler = e => {
|
|
454
|
+
const value = e.target.value;
|
|
455
|
+
|
|
456
|
+
if (timeout.current) {
|
|
457
|
+
if (timer.current) clearTimeout(timer.current);
|
|
458
|
+
timer.current = setTimeout(() => {
|
|
459
|
+
onSearchHandler(value);
|
|
460
|
+
}, /^\d+$/.test(timeout.current) ? timeout.current : 700);
|
|
461
|
+
} else {
|
|
462
|
+
onSearchHandler(value);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
const onSearchHandler = value => {
|
|
467
|
+
const entries = ref.current.querySelectorAll('.TreeView-Item.non-child, .DGN-UI-Accordion');
|
|
468
|
+
|
|
469
|
+
if (value) {
|
|
470
|
+
entries.forEach(entry => {
|
|
471
|
+
if (compareTwoString(value, entry.textContent)) {
|
|
472
|
+
entry.classList.remove('DGN-Hidden'); // Check exactly entry
|
|
473
|
+
|
|
474
|
+
if (entry.classList.contains('TreeView-Item')) {
|
|
475
|
+
if (!disabledBoldResult && !entry.classList.contains('TreeView-Item-active')) {
|
|
476
|
+
entry.classList.add('TreeView-Item-active');
|
|
477
|
+
}
|
|
478
|
+
} else {
|
|
479
|
+
const summaryEl = entry.firstChild;
|
|
480
|
+
const TreeViewItemEl = summaryEl.querySelector('.TreeView-Item');
|
|
481
|
+
|
|
482
|
+
if (TreeViewItemEl) {
|
|
483
|
+
if (compareTwoString(value, TreeViewItemEl.textContent)) {
|
|
484
|
+
if (!disabledBoldResult && !TreeViewItemEl.classList.contains('TreeView-Item-active')) {
|
|
485
|
+
TreeViewItemEl.classList.add('TreeView-Item-active');
|
|
486
|
+
entry.classList.add('TreeView-Item-contain-children-active');
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if (!compareTwoString(value, entry.lastChild.textContent)) {
|
|
490
|
+
summaryEl.lastChild.classList.add('DGN-Invisible');
|
|
491
|
+
} else {
|
|
492
|
+
summaryEl.lastChild.classList.remove('DGN-Invisible');
|
|
493
|
+
}
|
|
494
|
+
} else if (TreeViewItemEl.classList.contains('TreeView-Item-active')) {
|
|
495
|
+
TreeViewItemEl.classList.remove('TreeView-Item-active');
|
|
496
|
+
entry.classList.remove('TreeView-Item-contain-children-active');
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (autoExpandToResult && !summaryEl.classList.contains('expanding')) {
|
|
500
|
+
summaryEl.lastChild.firstChild.click();
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
entry.classList.add('DGN-Hidden');
|
|
506
|
+
|
|
507
|
+
if (entry.classList.contains('TreeView-Item')) {
|
|
508
|
+
if (entry.classList.contains('TreeView-Item-active')) {
|
|
509
|
+
entry.classList.remove('TreeView-Item-active');
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
entry.classList.remove('TreeView-Item-contain-children-active');
|
|
513
|
+
} else {
|
|
514
|
+
const summaryEl = entry.firstChild;
|
|
515
|
+
const TreeViewItemEl = summaryEl.querySelector('.TreeView-Item');
|
|
516
|
+
|
|
517
|
+
if (TreeViewItemEl) {
|
|
518
|
+
if (TreeViewItemEl.classList.contains('TreeView-Item-active')) {
|
|
519
|
+
TreeViewItemEl.classList.remove('TreeView-Item-active');
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
summaryEl.lastChild.classList.remove('DGN-Invisible');
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
if (showChildrenOfResult) {
|
|
529
|
+
entries.forEach(entry => {
|
|
530
|
+
if (entry.classList.contains('TreeView-Item-contain-children-active')) {
|
|
531
|
+
const hiddenEls = entry.querySelectorAll('.DGN-Hidden, .DGN-Invisible');
|
|
532
|
+
|
|
533
|
+
if (hiddenEls && hiddenEls.length) {
|
|
534
|
+
hiddenEls.forEach(hiddenEl => hiddenEl.classList.remove('DGN-Hidden', 'DGN-Invisible'));
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
} else {
|
|
540
|
+
entries.forEach(entry => {
|
|
541
|
+
entry.classList.remove('DGN-Hidden');
|
|
542
|
+
|
|
543
|
+
if (!entry.classList.contains('TreeView-Item') && entry.firstChild.lastChild.classList.contains('DGN-Invisible')) {
|
|
544
|
+
entry.firstChild.lastChild.classList.remove('DGN-Invisible');
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
const activeEls = ref.current.querySelectorAll('.TreeView-Item-active');
|
|
548
|
+
|
|
549
|
+
if (!disabledBoldResult && activeEls && activeEls.length) {
|
|
550
|
+
activeEls.forEach(activeEl => {
|
|
551
|
+
activeEl.classList.remove('TreeView-Item-active', 'TreeView-Item-contain-children-active');
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
const compareTwoString = (search, content) => {
|
|
558
|
+
if (searchMode === 'similar') {
|
|
559
|
+
search = removeUnicode(search.normalize(), '.*?');
|
|
560
|
+
content = removeUnicode(content);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return new RegExp(search.normalize(), 'img').test(content.normalize());
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
const renderDataAsync = (id, array) => {
|
|
567
|
+
return new Promise(res => {
|
|
568
|
+
const node = array.map(({
|
|
569
|
+
data,
|
|
570
|
+
index,
|
|
571
|
+
level
|
|
572
|
+
}) => {
|
|
573
|
+
return renderTreeView(data, index, level, false);
|
|
574
|
+
});
|
|
575
|
+
const container = document.getElementById(id);
|
|
576
|
+
|
|
577
|
+
if (container && node) {
|
|
578
|
+
render(node, container.firstChild, () => res(1));
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
const renderData = (data, keyArr) => {
|
|
584
|
+
const pattern = keyArr.join('|').replace(/([\{\}])/g, '\\$1');
|
|
585
|
+
const separatorArr = displayExpr.split(new RegExp(pattern));
|
|
586
|
+
let str = '';
|
|
587
|
+
let i = 0;
|
|
588
|
+
|
|
589
|
+
for (i; i < keyArr.length; i++) {
|
|
590
|
+
str += separatorArr[i] + (data[keyArr[i].replace(/\W/g, '')] !== undefined ? data[keyArr[i].replace(/\W/g, '')] : keyArr[i]);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return str + separatorArr[i];
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
const renderContent = (item, keyArr, index) => {
|
|
597
|
+
const displayText = renderItem && typeof renderItem === 'function' ? renderItem({
|
|
598
|
+
data: item,
|
|
599
|
+
index
|
|
600
|
+
}) : typeof item === 'object' ? keyArr ? renderData(item, keyArr) : item[displayExpr] : item;
|
|
601
|
+
return jsx(Typography, {
|
|
602
|
+
mapping: 'div',
|
|
603
|
+
color: 'inherit',
|
|
604
|
+
style: {
|
|
605
|
+
width: '100%'
|
|
606
|
+
}
|
|
607
|
+
}, displayText);
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
const renderTreeView = (data, index, level, sync = true, id) => {
|
|
611
|
+
if (level > renderAsyncFromLevel - 1 && sync) {
|
|
612
|
+
if (itemsRenderAsync[unique][id]) {
|
|
613
|
+
itemsRenderAsync[unique][id].push({
|
|
614
|
+
data,
|
|
615
|
+
index,
|
|
616
|
+
level
|
|
617
|
+
});
|
|
618
|
+
} else {
|
|
619
|
+
itemsRenderAsync[unique][id] = [{
|
|
620
|
+
data,
|
|
621
|
+
index,
|
|
622
|
+
level
|
|
623
|
+
}];
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
const keyArr = displayExpr.match(separatorPattern);
|
|
630
|
+
const isTrue = value.includes(data[valueExpr] || data);
|
|
631
|
+
const focusClass = isTrue && !selectBox && !multiple ? 'focus' : '';
|
|
632
|
+
const childItems = data.childItems; // is Summary
|
|
633
|
+
|
|
634
|
+
if (childItems && childItems.length) {
|
|
635
|
+
const id = randomString(6, {
|
|
636
|
+
allowSymbol: false,
|
|
637
|
+
allowNumber: false
|
|
638
|
+
});
|
|
639
|
+
return jsx(Accordion, {
|
|
640
|
+
key: index,
|
|
641
|
+
className: focusClass,
|
|
642
|
+
expand: expand || data.expand
|
|
643
|
+
}, jsx(AccordionSummary, {
|
|
644
|
+
expandIcon: expandIcon,
|
|
645
|
+
collapseIcon: collapseIcon,
|
|
646
|
+
expandIconAt: 'start',
|
|
647
|
+
expandIconProps: {
|
|
648
|
+
className: 'TreeView'
|
|
649
|
+
},
|
|
650
|
+
className: focusClass,
|
|
651
|
+
onClick: multiple || selectBox || onChange ? e => onClickHandler(e, data) : undefined
|
|
652
|
+
}, jsx("div", {
|
|
653
|
+
className: 'TreeView-Item'
|
|
654
|
+
}, (selectBox || multiple) && jsx("span", {
|
|
655
|
+
className: 'TreeView-Item-Checkbox'
|
|
656
|
+
}, jsx(Checkbox, {
|
|
657
|
+
checked: isTrue,
|
|
658
|
+
inputProps: {
|
|
659
|
+
value: typeof data === 'object' ? data[valueExpr] : data
|
|
660
|
+
}
|
|
661
|
+
})), renderContent(data, keyArr, index))), jsx(AccordionDetails, {
|
|
662
|
+
id: id
|
|
663
|
+
}, childItems.map((child, i) => renderTreeView(child, index + i, level + 1, sync, id))));
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
return jsx("div", {
|
|
667
|
+
className: 'TreeView-Item non-child ' + focusClass,
|
|
668
|
+
onClick: multiple || selectBox || onChange ? e => onClickHandler(e, data) : undefined,
|
|
669
|
+
key: index,
|
|
670
|
+
tabIndex: "-1"
|
|
671
|
+
}, (selectBox || multiple) && jsx("span", {
|
|
672
|
+
className: 'TreeView-Item-Checkbox'
|
|
673
|
+
}, jsx(Checkbox, {
|
|
674
|
+
checked: isTrue,
|
|
675
|
+
inputProps: {
|
|
676
|
+
value: typeof data === 'object' ? data[valueExpr] : data
|
|
677
|
+
}
|
|
678
|
+
})), renderContent(data, keyArr, index));
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
useEffect(() => {
|
|
682
|
+
currentValue[unique] = {};
|
|
683
|
+
return () => {
|
|
684
|
+
currentValue[unique] = null;
|
|
685
|
+
};
|
|
686
|
+
}, []);
|
|
687
|
+
useEffect(() => {
|
|
688
|
+
if (searchDelayTime) {
|
|
689
|
+
var _searchDelayTime$matc, _searchDelayTime$matc2;
|
|
690
|
+
|
|
691
|
+
const units = {
|
|
692
|
+
m: 60000,
|
|
693
|
+
s: 1000,
|
|
694
|
+
ms: 1
|
|
695
|
+
};
|
|
696
|
+
timeout.current = typeof searchDelayTime === 'number' ? searchDelayTime : (((_searchDelayTime$matc = searchDelayTime.match(/[^a-z]+/i)) === null || _searchDelayTime$matc === void 0 ? void 0 : _searchDelayTime$matc[0]) || 1) * units[((_searchDelayTime$matc2 = searchDelayTime.match(/ms|s|m/i)) === null || _searchDelayTime$matc2 === void 0 ? void 0 : _searchDelayTime$matc2[0]) || 's'];
|
|
697
|
+
return () => {
|
|
698
|
+
timeout.current = null;
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
}, [searchDelayTime]);
|
|
702
|
+
useEffect(() => {
|
|
703
|
+
dataSource.forEach(data => {
|
|
704
|
+
currentValue[unique][typeof data === 'object' ? data[valueExpr] : data] = false;
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
if (value && value.length) {
|
|
708
|
+
value.forEach(v => {
|
|
709
|
+
currentValue[unique][v] = true;
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return () => {
|
|
714
|
+
currentValue[unique] = {};
|
|
715
|
+
};
|
|
716
|
+
}, [dataSource, value]);
|
|
717
|
+
useEffect(() => {
|
|
718
|
+
if (value && multiple) {
|
|
719
|
+
if (multipleValueMode !== 'single') {
|
|
720
|
+
const childNodes = Array.from(ref.current.childNodes);
|
|
721
|
+
|
|
722
|
+
if (childNodes && childNodes.length) {
|
|
723
|
+
checkedParentFollowValue(childNodes);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (showSelectedItems) {
|
|
727
|
+
const data = dataSource.filter(d => value.includes(d[valueExpr]));
|
|
728
|
+
setValueIntoInput(data);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
return () => {
|
|
732
|
+
if (ref.current) {
|
|
733
|
+
Array.from(ref.current.querySelectorAll('input')).forEach(input => {
|
|
734
|
+
input.checked = value.includes(input.value);
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
} else if (disabledRelevantValue) {
|
|
739
|
+
Array.from(ref.current.querySelectorAll('.TreeView-Item.non-child, .DGN-UI-Accordion')).forEach(el => {
|
|
740
|
+
if (el.firstChild.querySelector('input').checked) {
|
|
741
|
+
if (!el.classList.contains('non-child')) {
|
|
742
|
+
handleDisabledChildren(el, true);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
handleDisabledParent(el.parentNode, true);
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}, [value]);
|
|
751
|
+
useEffect(() => {
|
|
752
|
+
if (selectAllRef.current) {
|
|
753
|
+
checkedSelectAllCheckbox();
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
if (ref.current.querySelector('.DGN-UI-Accordion-Details-Content')) {
|
|
757
|
+
if (!ref.current.parentNode.classList.contains('expand-able')) {
|
|
758
|
+
ref.current.parentNode.classList.add('expand-able');
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
return () => {
|
|
762
|
+
if (ref.current) {
|
|
763
|
+
ref.current.parentNode.classList.remove('expand-able');
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
}, [dataSource, value, multiple, selectBox]);
|
|
768
|
+
useEffect(() => {
|
|
769
|
+
if (disabled && ref.current) {
|
|
770
|
+
const childNodes = ref.current.childNodes;
|
|
771
|
+
Array.from(childNodes).forEach(node => {
|
|
772
|
+
node.classList.add('disabled');
|
|
773
|
+
});
|
|
774
|
+
return () => {
|
|
775
|
+
Array.from(childNodes).forEach(node => {
|
|
776
|
+
node.classList.remove('disabled');
|
|
777
|
+
});
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
}, [disabled]);
|
|
781
|
+
useEffect(() => {
|
|
782
|
+
if (Object.keys(itemsRenderAsync[unique]).length) {
|
|
783
|
+
Object.keys(itemsRenderAsync[unique]).forEach(async key => {
|
|
784
|
+
await renderDataAsync(key, itemsRenderAsync[unique][key]);
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
}, [dataSource, value, multiple, selectBox, onChange]);
|
|
788
|
+
useImperativeHandle(reference, () => ({
|
|
789
|
+
disabled,
|
|
790
|
+
displayExpr,
|
|
791
|
+
valueExpr,
|
|
792
|
+
id,
|
|
793
|
+
parentID,
|
|
794
|
+
value,
|
|
795
|
+
getValue: () => Object.keys(currentValue[unique]).filter(v => currentValue[unique][v]),
|
|
796
|
+
setValue,
|
|
797
|
+
handleCheckbox,
|
|
798
|
+
get: () => ref.current
|
|
799
|
+
}));
|
|
800
|
+
const TreeViewComp = useMemo(() => {
|
|
801
|
+
if (typeof value === 'string') {
|
|
802
|
+
value = [value];
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
if (!multiple && value.length > 1) {
|
|
806
|
+
value.length = 1;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
itemsRenderAsync[unique] = {};
|
|
810
|
+
const sync = dataSource.length > renderAsyncWithLength;
|
|
811
|
+
return jsx("div", {
|
|
812
|
+
css: TreeViewRoot,
|
|
813
|
+
className: 'DGN-UI-TreeView' + (disabled ? ' disabled' : '')
|
|
814
|
+
}, showSelectedItems && jsx(InputBase, {
|
|
815
|
+
inputRef: inputValueRef,
|
|
816
|
+
viewType: 'outlined',
|
|
817
|
+
readOnly: true,
|
|
818
|
+
style: {
|
|
819
|
+
marginBottom: 1
|
|
820
|
+
},
|
|
821
|
+
inputStyle: {
|
|
822
|
+
whiteSpace: 'nowrap',
|
|
823
|
+
overflow: 'hidden',
|
|
824
|
+
textOverflow: 'ellipsis'
|
|
825
|
+
},
|
|
826
|
+
endIcon: jsx(Icon, {
|
|
827
|
+
ref: clearIconRef,
|
|
828
|
+
name: 'Cancel',
|
|
829
|
+
onClick: clearAllValue
|
|
830
|
+
})
|
|
831
|
+
}), allowSearch && jsx(InputBase, _extends({
|
|
832
|
+
startIcon: 'Search',
|
|
833
|
+
onChange: onChangeHandler,
|
|
834
|
+
viewType: 'outlined'
|
|
835
|
+
}, searchProps)), multiple && selectAll && jsx(Fragment, null, jsx("div", {
|
|
836
|
+
className: 'TreeView-All'
|
|
837
|
+
}, jsx(Checkbox, {
|
|
838
|
+
label: selectAllLabel,
|
|
839
|
+
onChange: onSelectAll,
|
|
840
|
+
inputRef: selectAllRef
|
|
841
|
+
})), jsx(Divider, null)), jsx("div", _extends({
|
|
842
|
+
ref: ref
|
|
843
|
+
}, props, {
|
|
844
|
+
className: ['TreeView-Content', disabled ? 'disabled' : '', className].join(' ').trim()
|
|
845
|
+
}), disabledMap ? dataSource : mapParent(dataSource, id, parentID, true).map((data, index) => renderTreeView(data, index.toString(), 0, sync))));
|
|
846
|
+
}, [dataSource, value, multiple, selectBox, disabledBoldResult, autoExpandToResult, showChildrenOfResult, searchMode, onChange, searchProps]);
|
|
847
|
+
return TreeViewComp;
|
|
848
|
+
}));
|
|
849
|
+
TreeView.defaultProps = {
|
|
850
|
+
expand: false,
|
|
851
|
+
disabled: false,
|
|
852
|
+
disabledMap: false,
|
|
853
|
+
selectBox: false,
|
|
854
|
+
multiple: false,
|
|
855
|
+
selectAll: false,
|
|
856
|
+
allowSearch: false,
|
|
857
|
+
showSelectedItems: false,
|
|
858
|
+
disabledRelevantValue: false,
|
|
859
|
+
disabledBoldResult: false,
|
|
860
|
+
autoExpandToResult: true,
|
|
861
|
+
showChildrenOfResult: false,
|
|
862
|
+
displayExpr: 'name',
|
|
863
|
+
id: 'id',
|
|
864
|
+
parentID: 'parentID',
|
|
865
|
+
valueExpr: '',
|
|
866
|
+
className: '',
|
|
867
|
+
selectAllLabel: getGlobal('selectAll'),
|
|
868
|
+
dataSource: [],
|
|
869
|
+
value: [],
|
|
870
|
+
expandIcon: 'ArrowDown',
|
|
871
|
+
multipleValueMode: 'multiple',
|
|
872
|
+
searchMode: 'contains',
|
|
873
|
+
renderAsyncWithLength: 200,
|
|
874
|
+
renderAsyncFromLevel: 2,
|
|
875
|
+
searchProps: {}
|
|
876
|
+
};
|
|
877
|
+
TreeView.propTypes = {
|
|
878
|
+
/** expand immediate if true */
|
|
879
|
+
expand: PropTypes.bool,
|
|
880
|
+
|
|
881
|
+
/** prevent all event if true */
|
|
882
|
+
disabled: PropTypes.bool,
|
|
883
|
+
|
|
884
|
+
/** Will not map parent from data */
|
|
885
|
+
disabledMap: PropTypes.bool,
|
|
886
|
+
|
|
887
|
+
/** show checkbox in each item */
|
|
888
|
+
selectBox: PropTypes.bool,
|
|
889
|
+
|
|
890
|
+
/** allow select multiple item if true */
|
|
891
|
+
multiple: PropTypes.bool,
|
|
892
|
+
|
|
893
|
+
/** allow select/unselect all items on one click (just support for multiple) */
|
|
894
|
+
selectAll: PropTypes.bool,
|
|
895
|
+
|
|
896
|
+
/** display input box search if true */
|
|
897
|
+
allowSearch: PropTypes.bool,
|
|
898
|
+
|
|
899
|
+
/** display all value in a box */
|
|
900
|
+
showSelectedItems: PropTypes.bool,
|
|
901
|
+
|
|
902
|
+
/** disabled parent and children item if true (only supported for multipleValueMode is single) */
|
|
903
|
+
disabledRelevantValue: PropTypes.bool,
|
|
904
|
+
|
|
905
|
+
/** prevent display content of match values with bold style */
|
|
906
|
+
disabledBoldResult: PropTypes.bool,
|
|
907
|
+
|
|
908
|
+
/** expand TreeView to match result if true */
|
|
909
|
+
autoExpandToResult: PropTypes.bool,
|
|
910
|
+
|
|
911
|
+
/** still show children of last result was found if true */
|
|
912
|
+
showChildrenOfResult: PropTypes.bool,
|
|
913
|
+
|
|
914
|
+
/** Used to identify the parent key */
|
|
915
|
+
id: PropTypes.string.isRequired,
|
|
916
|
+
|
|
917
|
+
/** used for mapping into a nested list */
|
|
918
|
+
parentID: PropTypes.string.isRequired,
|
|
919
|
+
|
|
920
|
+
/** class on element */
|
|
921
|
+
className: PropTypes.string,
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* field name used for text display<br/>
|
|
925
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
926
|
+
* Note: don't use 'id - name', return undefined
|
|
927
|
+
*/
|
|
928
|
+
displayExpr: PropTypes.string,
|
|
929
|
+
|
|
930
|
+
/** the key to determine value to return */
|
|
931
|
+
valueExpr: PropTypes.string,
|
|
932
|
+
|
|
933
|
+
/** return value for the select multiple use case */
|
|
934
|
+
multipleValueMode: PropTypes.oneOf(['single', 'multiple', 'inheritance']),
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* return value for the select multiple use case
|
|
938
|
+
* * contains: "Công ty" contains "công", but not contains "cong"
|
|
939
|
+
* * similar: "Công ty" contains "công" and "cong"
|
|
940
|
+
*/
|
|
941
|
+
searchMode: PropTypes.oneOf(['contains', 'similar']),
|
|
942
|
+
|
|
943
|
+
/** The content display for label of checkbox select all */
|
|
944
|
+
selectAllLabel: PropTypes.string,
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* duration wait enter search content on search<br/>
|
|
948
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
949
|
+
*/
|
|
950
|
+
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
951
|
+
|
|
952
|
+
/** will render asynchronously if the number of elements is greater than this number */
|
|
953
|
+
renderAsyncWithLength: PropTypes.number,
|
|
954
|
+
|
|
955
|
+
/** will render asynchronously from level equal this number */
|
|
956
|
+
renderAsyncFromLevel: PropTypes.oneOf([2, 3, 4, 5]),
|
|
957
|
+
|
|
958
|
+
/** data to show in tree list */
|
|
959
|
+
dataSource: PropTypes.array,
|
|
960
|
+
|
|
961
|
+
/** the value was selected */
|
|
962
|
+
value: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
963
|
+
|
|
964
|
+
/** function displays items by custom<br/>
|
|
965
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
966
|
+
* --> such as: displayExpr={'name - role'}
|
|
967
|
+
*/
|
|
968
|
+
renderItem: PropTypes.func,
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* on change value function<br />
|
|
972
|
+
* return 2 parameters (e, data)<br />
|
|
973
|
+
* * e: element (insist {value, justSelected, data})<br/>
|
|
974
|
+
* + value is one or an array of selected values<br />
|
|
975
|
+
* + justSelected is value has just been selected (either true or false))<br />
|
|
976
|
+
* + data is one or an array of selected values with full information<br />
|
|
977
|
+
* * data: array of selected values (not recommend because it's the same e.value)
|
|
978
|
+
*/
|
|
979
|
+
onChange: PropTypes.func,
|
|
980
|
+
|
|
981
|
+
/** the icon to display for expand icon */
|
|
982
|
+
expandIcon: PropTypes.any,
|
|
983
|
+
|
|
984
|
+
/** the props for InputBase */
|
|
985
|
+
searchProps: PropTypes.object,
|
|
986
|
+
|
|
987
|
+
/** the icon to display for collapse icon */
|
|
988
|
+
collapseIcon: PropTypes.any,
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* get ref of TreeView component, insist:<br/>
|
|
992
|
+
* {<br/>
|
|
993
|
+
* disabled: true/false,<br/>
|
|
994
|
+
* displayExpr: string,<br/>
|
|
995
|
+
* valueExpr: string,<br/>
|
|
996
|
+
* id: string,<br/>
|
|
997
|
+
* parentID: string,<br/>
|
|
998
|
+
* value: string/array<br/>
|
|
999
|
+
* getValue: get selected values (instead of onChange function),<br/>
|
|
1000
|
+
* setValue: set array of value (only multiple),<br/>
|
|
1001
|
+
* handleCheckbox: checked/unchecked a Checkbox, includes 2 parameters (isChecked, value):<br/>
|
|
1002
|
+
* + isChecked: checked if true (default is false) <br/>
|
|
1003
|
+
* + value: selected values, use 'all' for all values (default is 'all') <br/>
|
|
1004
|
+
* get: get DOM of TreeView component<br/>
|
|
1005
|
+
* }
|
|
1006
|
+
*/
|
|
1007
|
+
ref: PropTypes.any
|
|
1008
|
+
};
|
|
1009
|
+
export default TreeView;
|