@koobiq/components 17.0.0-rc.1 → 17.0.0-rc.11
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/README.md +1 -2
- package/alert/_alert-theme.scss +48 -24
- package/alert/alert.component.d.ts +23 -3
- package/alert/alert.component.scss +91 -59
- package/alert/public-api.d.ts +1 -1
- package/autocomplete/_autocomplete-theme.scss +3 -3
- package/autocomplete/autocomplete.scss +8 -18
- package/autocomplete/public-api.d.ts +2 -2
- package/badge/_badge-theme.scss +30 -45
- package/badge/badge.component.scss +18 -39
- package/badge/public-api.d.ts +1 -1
- package/button/_button-base.scss +7 -14
- package/button/_button-theme.scss +30 -86
- package/button/button.component.d.ts +4 -3
- package/button/button.scss +7 -17
- package/button/public-api.d.ts +1 -1
- package/button-toggle/_button-toggle-theme.scss +19 -20
- package/button-toggle/button-toggle.scss +17 -44
- package/button-toggle/public-api.d.ts +1 -1
- package/card/_card-theme.scss +18 -17
- package/card/card.component.d.ts +1 -1
- package/card/card.component.scss +3 -6
- package/card/public-api.d.ts +1 -1
- package/checkbox/_checkbox-theme.scss +50 -50
- package/checkbox/checkbox.scss +31 -35
- package/code-block/README.md +18 -14
- package/code-block/_code-block-theme.scss +53 -23
- package/code-block/actionbar.component.scss +11 -25
- package/code-block/code-block.component.d.ts +12 -4
- package/code-block/code-block.scss +62 -77
- package/code-block/public-api.d.ts +1 -1
- package/core/animation/index.d.ts +1 -1
- package/core/common-behaviors/index.d.ts +3 -3
- package/core/datetime/index.d.ts +1 -1
- package/core/form-field/form-field-ref.d.ts +2 -0
- package/core/formatters/index.d.ts +1 -1
- package/core/forms/_forms-theme.scss +4 -8
- package/core/forms/_forms.scss +13 -43
- package/core/forms/index.d.ts +1 -1
- package/core/locales/formatters.d.ts +96 -0
- package/core/locales/index.d.ts +1 -1
- package/core/locales/locale-service.d.ts +97 -0
- package/core/option/_optgroup-theme.scss +4 -6
- package/core/option/_option-action-theme.scss +8 -11
- package/core/option/_option-theme.scss +15 -20
- package/core/option/index.d.ts +2 -2
- package/core/option/optgroup.scss +2 -3
- package/core/option/option.scss +0 -1
- package/core/pop-up/_pop-up.scss +0 -1
- package/core/pop-up/pop-up-trigger.d.ts +4 -2
- package/core/public-api.d.ts +3 -3
- package/core/select/common.d.ts +35 -0
- package/core/select/constants.d.ts +1 -1
- package/core/select/index.d.ts +3 -2
- package/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss +15 -19
- package/core/selection/pseudo-checkbox/pseudo-checkbox.scss +9 -9
- package/core/services/theme.service.d.ts +3 -2
- package/core/styles/_core.scss +0 -1
- package/core/styles/_koobiq-theme.scss +5 -3
- package/core/styles/common/_animation.scss +9 -8
- package/core/styles/common/_button.scss +0 -2
- package/core/styles/common/_clearfix.scss +1 -1
- package/core/styles/common/_groups.scss +3 -9
- package/core/styles/common/_list.scss +24 -66
- package/core/styles/common/_overlay.scss +4 -3
- package/core/styles/common/_popup.scss +5 -5
- package/core/styles/common/_rtl.scss +4 -4
- package/core/styles/common/_select.scss +48 -42
- package/core/styles/common/_tokens.scss +47 -0
- package/core/styles/functions/_number.scss +14 -19
- package/core/styles/functions/_string.scss +18 -19
- package/core/styles/functions/_timing.scss +24 -24
- package/core/styles/theming/_components-theming.scss +1322 -1326
- package/core/styles/theming/_scrollbar-theme.scss +8 -5
- package/core/styles/theming/_theming.scss +26 -29
- package/core/styles/typography/_typography-utils.scss +1 -2
- package/core/styles/typography/_typography.scss +138 -85
- package/core/styles/visual/_body.scss +0 -2
- package/core/styles/visual/_layout.scss +44 -38
- package/core/utils/data-size/config.d.ts +20 -2
- package/core/utils/data-size/data-size.pipe.d.ts +10 -9
- package/core/utils/data-size/index.d.ts +1 -1
- package/core/utils/data-size/size.d.ts +3 -4
- package/core/utils/public-api.d.ts +1 -1
- package/datepicker/_datepicker-theme.scss +38 -40
- package/datepicker/calendar-body.scss +3 -11
- package/datepicker/calendar-header.scss +4 -10
- package/datepicker/calendar.scss +5 -17
- package/datepicker/datepicker-content.scss +5 -15
- package/datepicker/datepicker-input.directive.d.ts +1 -0
- package/datepicker/datepicker-input.scss +0 -5
- package/datepicker/datepicker-toggle.scss +3 -3
- package/datepicker/public-api.d.ts +4 -4
- package/divider/_divider-theme.scss +2 -1
- package/divider/divider.scss +9 -26
- package/dl/_dl-theme.scss +5 -8
- package/dl/dl.scss +5 -20
- package/dl/public-api.d.ts +1 -1
- package/dropdown/_dropdown-theme.scss +30 -22
- package/dropdown/dropdown-content.directive.d.ts +1 -1
- package/dropdown/dropdown-item.component.d.ts +1 -1
- package/dropdown/dropdown-item.scss +12 -16
- package/dropdown/dropdown-trigger.directive.d.ts +2 -2
- package/dropdown/dropdown.component.d.ts +1 -1
- package/dropdown/dropdown.scss +6 -15
- package/dropdown/public-api.d.ts +5 -5
- package/ellipsis-center/ellipsis-center.directive.d.ts +4 -3
- package/empty-state/README.md +0 -0
- package/empty-state/_empty-state-theme.scss +56 -0
- package/empty-state/empty-state.component.d.ts +31 -0
- package/empty-state/empty-state.module.d.ts +10 -0
- package/empty-state/empty-state.scss +81 -0
- package/empty-state/index.d.ts +1 -0
- package/empty-state/public-api.d.ts +2 -0
- package/esm2022/alert/alert.component.mjs +52 -5
- package/esm2022/alert/alert.module.mjs +1 -1
- package/esm2022/alert/public-api.mjs +2 -2
- package/esm2022/autocomplete/autocomplete-origin.directive.mjs +1 -1
- package/esm2022/autocomplete/autocomplete-trigger.directive.mjs +23 -31
- package/esm2022/autocomplete/autocomplete.component.mjs +14 -9
- package/esm2022/autocomplete/autocomplete.module.mjs +3 -3
- package/esm2022/autocomplete/public-api.mjs +3 -3
- package/esm2022/badge/badge.component.mjs +8 -6
- package/esm2022/badge/badge.module.mjs +1 -1
- package/esm2022/badge/public-api.mjs +2 -2
- package/esm2022/button/button.component.mjs +20 -10
- package/esm2022/button/button.module.mjs +1 -1
- package/esm2022/button/public-api.mjs +2 -2
- package/esm2022/button-toggle/button-toggle.component.mjs +24 -16
- package/esm2022/button-toggle/button-toggle.module.mjs +1 -1
- package/esm2022/button-toggle/public-api.mjs +2 -2
- package/esm2022/card/card.component.mjs +2 -2
- package/esm2022/card/card.module.mjs +1 -1
- package/esm2022/card/public-api.mjs +2 -2
- package/esm2022/checkbox/checkbox-config.mjs +1 -1
- package/esm2022/checkbox/checkbox-module.mjs +1 -1
- package/esm2022/checkbox/checkbox-required-validator.mjs +1 -1
- package/esm2022/checkbox/checkbox.mjs +6 -6
- package/esm2022/checkbox/public-api.mjs +1 -1
- package/esm2022/code-block/actionbar.component.mjs +4 -6
- package/esm2022/code-block/code-block.component.mjs +64 -17
- package/esm2022/code-block/code-block.module.mjs +9 -5
- package/esm2022/code-block/public-api.mjs +2 -2
- package/esm2022/core/animation/fade-animations.mjs +1 -1
- package/esm2022/core/animation/index.mjs +2 -2
- package/esm2022/core/animation/select-animations.mjs +5 -5
- package/esm2022/core/common-behaviors/color.mjs +4 -2
- package/esm2022/core/common-behaviors/common-module.mjs +2 -2
- package/esm2022/core/common-behaviors/constructor.mjs +1 -1
- package/esm2022/core/common-behaviors/disabled.mjs +1 -1
- package/esm2022/core/common-behaviors/error-state.mjs +1 -1
- package/esm2022/core/common-behaviors/index.mjs +4 -4
- package/esm2022/core/common-behaviors/tabindex.mjs +1 -1
- package/esm2022/core/datetime/date-adapter.mjs +1 -1
- package/esm2022/core/datetime/date-formats.mjs +1 -1
- package/esm2022/core/datetime/index.mjs +2 -2
- package/esm2022/core/error/error-options.mjs +1 -1
- package/esm2022/core/form-field/form-field-ref.mjs +1 -1
- package/esm2022/core/formatters/date/formatter.mjs +1 -1
- package/esm2022/core/formatters/date/formatter.pipe.mjs +1 -1
- package/esm2022/core/formatters/index.mjs +2 -2
- package/esm2022/core/formatters/number/formatter.mjs +19 -20
- package/esm2022/core/forms/forms-module.mjs +1 -1
- package/esm2022/core/forms/forms.directive.mjs +1 -1
- package/esm2022/core/forms/index.mjs +2 -2
- package/esm2022/core/highlight/highlight.pipe.mjs +1 -1
- package/esm2022/core/highlight/index.mjs +1 -1
- package/esm2022/core/label/label-options.mjs +1 -1
- package/esm2022/core/line/line.mjs +2 -2
- package/esm2022/core/locales/en-US.mjs +1 -1
- package/esm2022/core/locales/es-LA.mjs +1 -1
- package/esm2022/core/locales/fa-IR.mjs +1 -1
- package/esm2022/core/locales/formatters.mjs +97 -1
- package/esm2022/core/locales/index.mjs +2 -2
- package/esm2022/core/locales/locale-service.mjs +10 -4
- package/esm2022/core/locales/locale-service.module.mjs +1 -1
- package/esm2022/core/locales/pt-BR.mjs +1 -1
- package/esm2022/core/locales/ru-RU.mjs +3 -3
- package/esm2022/core/locales/zh-CN.mjs +1 -1
- package/esm2022/core/option/action.mjs +20 -12
- package/esm2022/core/option/index.mjs +3 -3
- package/esm2022/core/option/optgroup.mjs +4 -4
- package/esm2022/core/option/option-module.mjs +1 -1
- package/esm2022/core/option/option.mjs +13 -7
- package/esm2022/core/overlay/overlay-position-map.mjs +1 -1
- package/esm2022/core/pop-up/pop-up-trigger.mjs +29 -30
- package/esm2022/core/pop-up/pop-up.mjs +1 -1
- package/esm2022/core/public-api.mjs +4 -4
- package/esm2022/core/select/common.mjs +120 -0
- package/esm2022/core/select/constants.mjs +1 -1
- package/esm2022/core/select/index.mjs +4 -3
- package/esm2022/core/selection/pseudo-checkbox/pseudo-checkbox.mjs +3 -3
- package/esm2022/core/selection/pseudo-checkbox/pseudo-checkbox.module.mjs +1 -1
- package/esm2022/core/services/measure-scrollbar.service.mjs +1 -1
- package/esm2022/core/services/theme.service.mjs +5 -4
- package/esm2022/core/title/title-text-ref.mjs +1 -1
- package/esm2022/core/utils/data-size/config.mjs +5 -17
- package/esm2022/core/utils/data-size/data-size.pipe.mjs +35 -22
- package/esm2022/core/utils/data-size/index.mjs +2 -2
- package/esm2022/core/utils/data-size/size.mjs +7 -14
- package/esm2022/core/utils/public-api.mjs +2 -2
- package/esm2022/core/utils/utils.mjs +4 -2
- package/esm2022/core/validation/validation.mjs +4 -2
- package/esm2022/core/version.mjs +2 -2
- package/esm2022/datepicker/calendar-body.component.mjs +3 -3
- package/esm2022/datepicker/calendar-header.component.mjs +8 -7
- package/esm2022/datepicker/calendar.component.mjs +6 -6
- package/esm2022/datepicker/datepicker-animations.mjs +2 -2
- package/esm2022/datepicker/datepicker-errors.mjs +1 -1
- package/esm2022/datepicker/datepicker-input.directive.mjs +42 -34
- package/esm2022/datepicker/datepicker-intl.mjs +1 -1
- package/esm2022/datepicker/datepicker-module.mjs +2 -2
- package/esm2022/datepicker/datepicker-toggle.component.mjs +11 -10
- package/esm2022/datepicker/datepicker.component.mjs +15 -15
- package/esm2022/datepicker/month-view.component.mjs +14 -13
- package/esm2022/datepicker/public-api.mjs +5 -5
- package/esm2022/divider/divider.component.mjs +1 -1
- package/esm2022/divider/divider.module.mjs +1 -1
- package/esm2022/dl/dl.component.mjs +1 -1
- package/esm2022/dl/dl.module.mjs +2 -2
- package/esm2022/dl/public-api.mjs +2 -2
- package/esm2022/dropdown/dropdown-animations.mjs +5 -5
- package/esm2022/dropdown/dropdown-content.directive.mjs +3 -3
- package/esm2022/dropdown/dropdown-item.component.mjs +5 -5
- package/esm2022/dropdown/dropdown-trigger.directive.mjs +25 -31
- package/esm2022/dropdown/dropdown.component.mjs +10 -18
- package/esm2022/dropdown/dropdown.module.mjs +1 -1
- package/esm2022/dropdown/dropdown.types.mjs +1 -1
- package/esm2022/dropdown/public-api.mjs +6 -6
- package/esm2022/ellipsis-center/ellipsis-center.directive.mjs +9 -7
- package/esm2022/empty-state/empty-state.component.mjs +104 -0
- package/esm2022/empty-state/empty-state.module.mjs +50 -0
- package/esm2022/empty-state/index.mjs +2 -0
- package/esm2022/empty-state/koobiq-components-empty-state.mjs +5 -0
- package/esm2022/empty-state/public-api.mjs +3 -0
- package/esm2022/file-upload/file-drop.mjs +2 -2
- package/esm2022/file-upload/file-upload.mjs +1 -1
- package/esm2022/file-upload/file-upload.module.mjs +12 -6
- package/esm2022/file-upload/index.mjs +1 -1
- package/esm2022/file-upload/multiple-file-upload.component.mjs +96 -29
- package/esm2022/file-upload/public-api.mjs +2 -2
- package/esm2022/file-upload/single-file-upload.component.mjs +100 -25
- package/esm2022/form-field/cleaner.mjs +13 -3
- package/esm2022/form-field/form-field-control.mjs +1 -1
- package/esm2022/form-field/form-field-errors.mjs +1 -1
- package/esm2022/form-field/form-field.mjs +8 -13
- package/esm2022/form-field/form-field.module.mjs +1 -1
- package/esm2022/form-field/hint.mjs +4 -4
- package/esm2022/form-field/password-hint.mjs +15 -15
- package/esm2022/form-field/password-toggle.mjs +14 -15
- package/esm2022/form-field/prefix.mjs +1 -1
- package/esm2022/form-field/public-api.mjs +4 -4
- package/esm2022/form-field/stepper.mjs +33 -29
- package/esm2022/form-field/suffix.mjs +1 -1
- package/esm2022/form-field/validate.directive.mjs +6 -5
- package/esm2022/icon/icon-button.component.mjs +2 -2
- package/esm2022/icon/icon-item.component.mjs +16 -6
- package/esm2022/icon/icon.component.mjs +3 -4
- package/esm2022/icon/icon.module.mjs +1 -1
- package/esm2022/icon/public-api.mjs +3 -3
- package/esm2022/input/input-number-validators.mjs +1 -1
- package/esm2022/input/input-number.mjs +35 -36
- package/esm2022/input/input-password.mjs +13 -7
- package/esm2022/input/input-value-accessor.mjs +1 -1
- package/esm2022/input/input.mjs +13 -7
- package/esm2022/input/input.module.mjs +1 -1
- package/esm2022/input/public-api.mjs +3 -3
- package/esm2022/link/link.component.mjs +2 -2
- package/esm2022/link/link.module.mjs +1 -1
- package/esm2022/link/public-api.mjs +2 -2
- package/esm2022/list/list-selection.component.mjs +34 -36
- package/esm2022/list/list.component.mjs +3 -3
- package/esm2022/list/list.module.mjs +2 -2
- package/esm2022/list/public-api.mjs +3 -3
- package/esm2022/loader-overlay/loader-overlay.component.mjs +4 -4
- package/esm2022/loader-overlay/loader-overlay.module.mjs +1 -1
- package/esm2022/loader-overlay/public-api.mjs +2 -2
- package/esm2022/markdown/markdown.component.mjs +22 -8
- package/esm2022/markdown/markdown.module.mjs +1 -1
- package/esm2022/markdown/markdown.service.mjs +1 -1
- package/esm2022/modal/css-unit.pipe.mjs +1 -1
- package/esm2022/modal/modal-control.service.mjs +3 -2
- package/esm2022/modal/modal-ref.class.mjs +1 -1
- package/esm2022/modal/modal-util.mjs +1 -1
- package/esm2022/modal/modal.component.mjs +54 -32
- package/esm2022/modal/modal.directive.mjs +27 -11
- package/esm2022/modal/modal.module.mjs +2 -2
- package/esm2022/modal/modal.service.mjs +3 -2
- package/esm2022/modal/modal.type.mjs +1 -1
- package/esm2022/modal/public-api.mjs +3 -3
- package/esm2022/navbar/index.mjs +1 -1
- package/esm2022/navbar/navbar-item.component.mjs +47 -38
- package/esm2022/navbar/navbar.component.mjs +19 -28
- package/esm2022/navbar/navbar.module.mjs +2 -2
- package/esm2022/navbar/public-api.mjs +3 -3
- package/esm2022/navbar/vertical-navbar.component.mjs +17 -18
- package/esm2022/popover/popover-animations.mjs +1 -1
- package/esm2022/popover/popover-confirm.component.mjs +3 -3
- package/esm2022/popover/popover.component.mjs +5 -5
- package/esm2022/popover/popover.module.mjs +1 -1
- package/esm2022/popover/public-api.mjs +3 -3
- package/esm2022/progress-bar/progress-bar.component.mjs +4 -4
- package/esm2022/progress-bar/progress-bar.module.mjs +2 -2
- package/esm2022/progress-bar/public-api.mjs +2 -2
- package/esm2022/progress-spinner/progress-spinner.component.mjs +4 -4
- package/esm2022/progress-spinner/progress-spinner.module.mjs +1 -1
- package/esm2022/progress-spinner/public-api.mjs +2 -2
- package/esm2022/radio/public-api.mjs +2 -2
- package/esm2022/radio/radio.component.mjs +9 -10
- package/esm2022/radio/radio.module.mjs +1 -1
- package/esm2022/risk-level/public-api.mjs +2 -2
- package/esm2022/risk-level/risk-level.component.mjs +1 -1
- package/esm2022/risk-level/risk-level.module.mjs +1 -1
- package/esm2022/scrollbar/public-api.mjs +2 -2
- package/esm2022/scrollbar/scrollbar.component.mjs +15 -13
- package/esm2022/scrollbar/scrollbar.directive.mjs +3 -3
- package/esm2022/scrollbar/scrollbar.module.mjs +2 -2
- package/esm2022/scrollbar/scrollbar.types.mjs +3 -2
- package/esm2022/select/public-api.mjs +3 -3
- package/esm2022/select/select-option.directive.mjs +14 -9
- package/esm2022/select/select.component.mjs +92 -172
- package/esm2022/select/select.module.mjs +28 -28
- package/esm2022/sidebar/public-api.mjs +2 -2
- package/esm2022/sidebar/sidebar-animations.mjs +1 -1
- package/esm2022/sidebar/sidebar.component.mjs +3 -3
- package/esm2022/sidebar/sidebar.module.mjs +1 -1
- package/esm2022/sidepanel/public-api.mjs +4 -4
- package/esm2022/sidepanel/sidepanel-animations.mjs +7 -3
- package/esm2022/sidepanel/sidepanel-config.mjs +1 -1
- package/esm2022/sidepanel/sidepanel-container.component.mjs +4 -4
- package/esm2022/sidepanel/sidepanel-directives.mjs +30 -16
- package/esm2022/sidepanel/sidepanel-ref.mjs +10 -4
- package/esm2022/sidepanel/sidepanel.module.mjs +1 -1
- package/esm2022/sidepanel/sidepanel.service.mjs +11 -14
- package/esm2022/splitter/public-api.mjs +2 -2
- package/esm2022/splitter/splitter.component.mjs +45 -35
- package/esm2022/splitter/splitter.module.mjs +1 -1
- package/esm2022/table/public-api.mjs +2 -2
- package/esm2022/table/table.component.mjs +29 -6
- package/esm2022/table/table.module.mjs +14 -6
- package/esm2022/tabs/paginated-tab-header.mjs +8 -11
- package/esm2022/tabs/public-api.mjs +6 -6
- package/esm2022/tabs/tab-body.component.mjs +9 -9
- package/esm2022/tabs/tab-content.directive.mjs +1 -1
- package/esm2022/tabs/tab-group.component.mjs +61 -21
- package/esm2022/tabs/tab-header.component.mjs +4 -4
- package/esm2022/tabs/tab-label-wrapper.directive.mjs +1 -1
- package/esm2022/tabs/tab-label.directive.mjs +1 -1
- package/esm2022/tabs/tab-nav-bar/index.mjs +1 -1
- package/esm2022/tabs/tab-nav-bar/tab-nav-bar.mjs +4 -4
- package/esm2022/tabs/tab.component.mjs +4 -6
- package/esm2022/tabs/tabs-animations.mjs +1 -1
- package/esm2022/tabs/tabs.module.mjs +2 -2
- package/esm2022/tags/public-api.mjs +5 -5
- package/esm2022/tags/tag-default-options.mjs +1 -1
- package/esm2022/tags/tag-input.mjs +26 -14
- package/esm2022/tags/tag-list.component.mjs +14 -20
- package/esm2022/tags/tag-text-control.mjs +1 -1
- package/esm2022/tags/tag.component.mjs +6 -8
- package/esm2022/tags/tag.module.mjs +9 -5
- package/esm2022/textarea/index.mjs +1 -1
- package/esm2022/textarea/textarea.component.mjs +15 -15
- package/esm2022/textarea/textarea.module.mjs +1 -1
- package/esm2022/timepicker/public-api.mjs +2 -2
- package/esm2022/timepicker/timepicker.constants.mjs +6 -1
- package/esm2022/timepicker/timepicker.directive.mjs +72 -28
- package/esm2022/timepicker/timepicker.module.mjs +1 -1
- package/esm2022/timezone/cities-by-filter.pipe.mjs +1 -1
- package/esm2022/timezone/timezone-option.component.mjs +12 -11
- package/esm2022/timezone/timezone-option.directive.mjs +9 -7
- package/esm2022/timezone/timezone-select.component.mjs +7 -7
- package/esm2022/timezone/timezone.module.mjs +1 -1
- package/esm2022/timezone/timezone.utils.mjs +5 -9
- package/esm2022/timezone/utc-offset.pipe.mjs +1 -1
- package/esm2022/title/public-api.mjs +2 -2
- package/esm2022/title/title.directive.mjs +11 -8
- package/esm2022/title/title.module.mjs +1 -1
- package/esm2022/toast/public-api.mjs +4 -4
- package/esm2022/toast/toast-animations.mjs +2 -2
- package/esm2022/toast/toast-container.component.mjs +5 -6
- package/esm2022/toast/toast.component.mjs +6 -6
- package/esm2022/toast/toast.module.mjs +1 -1
- package/esm2022/toast/toast.service.mjs +26 -37
- package/esm2022/toast/toast.type.mjs +3 -1
- package/esm2022/toggle/public-api.mjs +2 -2
- package/esm2022/toggle/toggle.component.mjs +17 -9
- package/esm2022/toggle/toggle.module.mjs +1 -1
- package/esm2022/tooltip/public-api.mjs +2 -2
- package/esm2022/tooltip/tooltip.animations.mjs +1 -1
- package/esm2022/tooltip/tooltip.component.mjs +32 -16
- package/esm2022/tooltip/tooltip.module.mjs +2 -2
- package/esm2022/tree/control/base-tree-control.mjs +1 -1
- package/esm2022/tree/control/flat-tree-control.filters.mjs +4 -7
- package/esm2022/tree/control/flat-tree-control.mjs +4 -7
- package/esm2022/tree/control/nested-tree-control.mjs +1 -1
- package/esm2022/tree/control/tree-control.mjs +1 -1
- package/esm2022/tree/data-source/flat-data-source.mjs +3 -8
- package/esm2022/tree/data-source/nested-data-source.mjs +2 -3
- package/esm2022/tree/node.mjs +1 -1
- package/esm2022/tree/outlet.mjs +1 -1
- package/esm2022/tree/padding.directive.mjs +5 -6
- package/esm2022/tree/public-api.mjs +11 -11
- package/esm2022/tree/toggle.mjs +8 -5
- package/esm2022/tree/tree-base.mjs +4 -4
- package/esm2022/tree/tree-errors.mjs +1 -1
- package/esm2022/tree/tree-option.component.mjs +9 -13
- package/esm2022/tree/tree-selection.component.mjs +19 -33
- package/esm2022/tree/tree.mjs +7 -3
- package/esm2022/tree/tree.module.mjs +4 -4
- package/esm2022/tree-select/public-api.mjs +2 -2
- package/esm2022/tree-select/tree-select.component.mjs +73 -98
- package/esm2022/tree-select/tree-select.module.mjs +31 -11
- package/fesm2022/koobiq-components-alert.mjs +55 -8
- package/fesm2022/koobiq-components-alert.mjs.map +1 -1
- package/fesm2022/koobiq-components-autocomplete.mjs +58 -61
- package/fesm2022/koobiq-components-autocomplete.mjs.map +1 -1
- package/fesm2022/koobiq-components-badge.mjs +10 -8
- package/fesm2022/koobiq-components-badge.mjs.map +1 -1
- package/fesm2022/koobiq-components-button-toggle.mjs +28 -20
- package/fesm2022/koobiq-components-button-toggle.mjs.map +1 -1
- package/fesm2022/koobiq-components-button.mjs +22 -12
- package/fesm2022/koobiq-components-button.mjs.map +1 -1
- package/fesm2022/koobiq-components-card.mjs +2 -2
- package/fesm2022/koobiq-components-card.mjs.map +1 -1
- package/fesm2022/koobiq-components-checkbox.mjs +3 -3
- package/fesm2022/koobiq-components-checkbox.mjs.map +1 -1
- package/fesm2022/koobiq-components-code-block.mjs +75 -27
- package/fesm2022/koobiq-components-code-block.mjs.map +1 -1
- package/fesm2022/koobiq-components-core.mjs +623 -397
- package/fesm2022/koobiq-components-core.mjs.map +1 -1
- package/fesm2022/koobiq-components-datepicker.mjs +101 -90
- package/fesm2022/koobiq-components-datepicker.mjs.map +1 -1
- package/fesm2022/koobiq-components-divider.mjs.map +1 -1
- package/fesm2022/koobiq-components-dl.mjs +3 -3
- package/fesm2022/koobiq-components-dl.mjs.map +1 -1
- package/fesm2022/koobiq-components-dropdown.mjs +127 -141
- package/fesm2022/koobiq-components-dropdown.mjs.map +1 -1
- package/fesm2022/koobiq-components-ellipsis-center.mjs +5 -4
- package/fesm2022/koobiq-components-ellipsis-center.mjs.map +1 -1
- package/fesm2022/koobiq-components-empty-state.mjs +157 -0
- package/fesm2022/koobiq-components-empty-state.mjs.map +1 -0
- package/fesm2022/koobiq-components-file-upload.mjs +207 -62
- package/fesm2022/koobiq-components-file-upload.mjs.map +1 -1
- package/fesm2022/koobiq-components-form-field.mjs +88 -81
- package/fesm2022/koobiq-components-form-field.mjs.map +1 -1
- package/fesm2022/koobiq-components-icon.mjs +17 -8
- package/fesm2022/koobiq-components-icon.mjs.map +1 -1
- package/fesm2022/koobiq-components-input.mjs +62 -51
- package/fesm2022/koobiq-components-input.mjs.map +1 -1
- package/fesm2022/koobiq-components-link.mjs +1 -1
- package/fesm2022/koobiq-components-link.mjs.map +1 -1
- package/fesm2022/koobiq-components-list.mjs +39 -41
- package/fesm2022/koobiq-components-list.mjs.map +1 -1
- package/fesm2022/koobiq-components-loader-overlay.mjs +7 -7
- package/fesm2022/koobiq-components-loader-overlay.mjs.map +1 -1
- package/fesm2022/koobiq-components-markdown.mjs +20 -6
- package/fesm2022/koobiq-components-markdown.mjs.map +1 -1
- package/fesm2022/koobiq-components-modal.mjs +88 -49
- package/fesm2022/koobiq-components-modal.mjs.map +1 -1
- package/fesm2022/koobiq-components-navbar.mjs +84 -85
- package/fesm2022/koobiq-components-navbar.mjs.map +1 -1
- package/fesm2022/koobiq-components-popover.mjs +12 -12
- package/fesm2022/koobiq-components-popover.mjs.map +1 -1
- package/fesm2022/koobiq-components-progress-bar.mjs +5 -5
- package/fesm2022/koobiq-components-progress-bar.mjs.map +1 -1
- package/fesm2022/koobiq-components-progress-spinner.mjs +5 -5
- package/fesm2022/koobiq-components-progress-spinner.mjs.map +1 -1
- package/fesm2022/koobiq-components-radio.mjs +11 -12
- package/fesm2022/koobiq-components-radio.mjs.map +1 -1
- package/fesm2022/koobiq-components-risk-level.mjs +2 -2
- package/fesm2022/koobiq-components-risk-level.mjs.map +1 -1
- package/fesm2022/koobiq-components-scrollbar.mjs +17 -14
- package/fesm2022/koobiq-components-scrollbar.mjs.map +1 -1
- package/fesm2022/koobiq-components-select.mjs +136 -212
- package/fesm2022/koobiq-components-select.mjs.map +1 -1
- package/fesm2022/koobiq-components-sidebar.mjs +3 -3
- package/fesm2022/koobiq-components-sidebar.mjs.map +1 -1
- package/fesm2022/koobiq-components-sidepanel.mjs +108 -87
- package/fesm2022/koobiq-components-sidepanel.mjs.map +1 -1
- package/fesm2022/koobiq-components-splitter.mjs +46 -36
- package/fesm2022/koobiq-components-splitter.mjs.map +1 -1
- package/fesm2022/koobiq-components-table.mjs +42 -11
- package/fesm2022/koobiq-components-table.mjs.map +1 -1
- package/fesm2022/koobiq-components-tabs.mjs +87 -52
- package/fesm2022/koobiq-components-tabs.mjs.map +1 -1
- package/fesm2022/koobiq-components-tags.mjs +53 -46
- package/fesm2022/koobiq-components-tags.mjs.map +1 -1
- package/fesm2022/koobiq-components-textarea.mjs +13 -13
- package/fesm2022/koobiq-components-textarea.mjs.map +1 -1
- package/fesm2022/koobiq-components-timepicker.mjs +79 -30
- package/fesm2022/koobiq-components-timepicker.mjs.map +1 -1
- package/fesm2022/koobiq-components-timezone.mjs +23 -25
- package/fesm2022/koobiq-components-timezone.mjs.map +1 -1
- package/fesm2022/koobiq-components-title.mjs +13 -10
- package/fesm2022/koobiq-components-title.mjs.map +1 -1
- package/fesm2022/koobiq-components-toast.mjs +86 -95
- package/fesm2022/koobiq-components-toast.mjs.map +1 -1
- package/fesm2022/koobiq-components-toggle.mjs +17 -9
- package/fesm2022/koobiq-components-toggle.mjs.map +1 -1
- package/fesm2022/koobiq-components-tooltip.mjs +33 -18
- package/fesm2022/koobiq-components-tooltip.mjs.map +1 -1
- package/fesm2022/koobiq-components-tree-select.mjs +110 -114
- package/fesm2022/koobiq-components-tree-select.mjs.map +1 -1
- package/fesm2022/koobiq-components-tree.mjs +509 -533
- package/fesm2022/koobiq-components-tree.mjs.map +1 -1
- package/file-upload/_file-upload-theme.scss +124 -73
- package/file-upload/file-upload.module.d.ts +11 -10
- package/file-upload/file-upload.scss +0 -6
- package/file-upload/multiple-file-upload.component.d.ts +37 -7
- package/file-upload/multiple-file-upload.component.scss +50 -120
- package/file-upload/public-api.d.ts +1 -1
- package/file-upload/single-file-upload.component.d.ts +37 -7
- package/file-upload/single-file-upload.component.scss +12 -33
- package/form-field/_form-field-theme.scss +46 -36
- package/form-field/_hint-theme.scss +15 -20
- package/form-field/cleaner.scss +3 -9
- package/form-field/form-field.scss +23 -26
- package/form-field/hint.scss +5 -8
- package/form-field/password-toggle.d.ts +3 -2
- package/form-field/password-toggle.scss +3 -10
- package/form-field/public-api.d.ts +3 -3
- package/form-field/stepper.scss +4 -11
- package/icon/_icon-button-theme.scss +47 -36
- package/icon/_icon-item-theme.scss +47 -26
- package/icon/_icon-theme.scss +12 -14
- package/icon/icon-button.scss +5 -20
- package/icon/icon-item.component.d.ts +3 -1
- package/icon/icon-item.scss +10 -8
- package/icon/icon.scss +0 -6
- package/icon/public-api.d.ts +2 -2
- package/input/_input-theme.scss +6 -4
- package/input/input.scss +11 -10
- package/input/public-api.d.ts +2 -2
- package/link/_link-theme.scss +32 -49
- package/link/link.component.d.ts +1 -1
- package/link/public-api.d.ts +1 -1
- package/list/_list-theme.scss +21 -19
- package/list/list-selection.component.d.ts +2 -2
- package/list/list.scss +2 -6
- package/list/public-api.d.ts +2 -2
- package/loader-overlay/_loader-overlay-theme.scss +17 -18
- package/loader-overlay/loader-overlay.scss +9 -33
- package/loader-overlay/public-api.d.ts +1 -1
- package/markdown/_markdown-theme.scss +47 -47
- package/markdown/markdown.scss +41 -91
- package/modal/README.md +4 -3
- package/modal/_modal-animation.scss +0 -1
- package/modal/_modal-confirm.scss +2 -7
- package/modal/_modal-theme.scss +11 -13
- package/modal/modal.component.d.ts +1 -1
- package/modal/modal.directive.d.ts +3 -3
- package/modal/modal.scss +15 -31
- package/modal/modal.type.d.ts +2 -2
- package/modal/public-api.d.ts +2 -2
- package/navbar/README.md +21 -20
- package/navbar/_navbar-item_horizontal.scss +40 -33
- package/navbar/_navbar-item_vertical.scss +31 -33
- package/navbar/_navbar-theme.scss +20 -24
- package/navbar/navbar-brand.scss +24 -27
- package/navbar/navbar-divider.scss +4 -8
- package/navbar/navbar-item.component.d.ts +4 -4
- package/navbar/navbar-item.scss +20 -15
- package/navbar/navbar.scss +2 -6
- package/navbar/public-api.d.ts +2 -2
- package/navbar/vertical-navbar.scss +4 -6
- package/package.json +17 -10
- package/popover/README.md +18 -14
- package/popover/_popover-theme.scss +9 -17
- package/popover/popover.component.d.ts +1 -1
- package/popover/popover.scss +15 -29
- package/popover/public-api.d.ts +2 -2
- package/prebuilt-themes/dark-theme.css +1 -1
- package/prebuilt-themes/light-theme.css +1 -1
- package/progress-bar/_progress-bar-theme.scss +7 -11
- package/progress-bar/progress-bar.scss +6 -19
- package/progress-bar/public-api.d.ts +1 -1
- package/progress-spinner/_progress-spinner-theme.scss +6 -8
- package/progress-spinner/progress-spinner.scss +8 -18
- package/progress-spinner/public-api.d.ts +1 -1
- package/radio/_radio-theme.scss +37 -37
- package/radio/public-api.d.ts +1 -1
- package/radio/radio.scss +35 -40
- package/risk-level/_risk-level-theme.scss +25 -31
- package/risk-level/public-api.d.ts +1 -1
- package/risk-level/risk-level.component.scss +4 -10
- package/schematics/collection.json +11 -0
- package/schematics/ng-add/index.js +70 -0
- package/schematics/ng-add/schema.json +15 -0
- package/scrollbar/_scrollbar-component-theme.scss +15 -19
- package/scrollbar/public-api.d.ts +1 -1
- package/scrollbar/scrollbar.component.scss +68 -63
- package/scrollbar/scrollbar.directive.d.ts +1 -1
- package/scrollbar/scrollbar.types.d.ts +1 -1
- package/select/_select-theme.scss +14 -16
- package/select/public-api.d.ts +2 -2
- package/select/select-option.directive.d.ts +3 -2
- package/select/select.component.d.ts +12 -33
- package/select/select.module.d.ts +1 -1
- package/select/select.scss +3 -11
- package/sidebar/public-api.d.ts +1 -1
- package/sidepanel/_sidepanel-theme.scss +8 -10
- package/sidepanel/public-api.d.ts +3 -3
- package/sidepanel/sidepanel.scss +20 -37
- package/splitter/_splitter-theme.scss +5 -6
- package/splitter/public-api.d.ts +1 -1
- package/splitter/splitter.component.d.ts +10 -5
- package/splitter/splitter.scss +0 -1
- package/table/_table-theme.scss +16 -15
- package/table/public-api.d.ts +1 -1
- package/table/table.component.d.ts +8 -1
- package/table/table.module.d.ts +1 -1
- package/table/table.scss +41 -42
- package/tabs/_tabs-common.scss +13 -15
- package/tabs/_tabs-theme.scss +76 -44
- package/tabs/paginated-tab-header.d.ts +1 -1
- package/tabs/public-api.d.ts +5 -5
- package/tabs/tab-body.component.d.ts +4 -4
- package/tabs/tab-group.component.d.ts +10 -4
- package/tabs/tab-group.scss +2 -8
- package/tabs/tab-header.scss +0 -10
- package/tabs/tab-nav-bar/tab-nav-bar.scss +2 -9
- package/tags/_tag-theme.scss +22 -27
- package/tags/public-api.d.ts +4 -4
- package/tags/tag-default-options.d.ts +1 -0
- package/tags/tag-input.d.ts +8 -2
- package/tags/tag-list.scss +15 -12
- package/tags/tag.component.d.ts +1 -1
- package/tags/tag.scss +5 -11
- package/textarea/_textarea-theme.scss +2 -5
- package/textarea/textarea.component.d.ts +1 -1
- package/textarea/textarea.scss +5 -10
- package/timepicker/public-api.d.ts +1 -1
- package/timepicker/timepicker.constants.d.ts +2 -0
- package/timepicker/timepicker.directive.d.ts +11 -4
- package/timepicker/timepicker.scss +2 -8
- package/timezone/_timezone-option-theme.scss +8 -10
- package/timezone/timezone-option.component.scss +5 -8
- package/timezone/timezone-option.directive.d.ts +4 -3
- package/timezone/timezone-select.component.d.ts +2 -1
- package/timezone/timezone-select.component.scss +2 -4
- package/timezone/timezone.utils.d.ts +1 -1
- package/title/public-api.d.ts +1 -1
- package/title/title.directive.d.ts +0 -1
- package/toast/_toast-theme.scss +20 -16
- package/toast/public-api.d.ts +3 -3
- package/toast/toast-container.component.scss +5 -6
- package/toast/toast.component.scss +28 -29
- package/toast/toast.service.d.ts +9 -5
- package/toast/toast.type.d.ts +3 -1
- package/toggle/_toggle-theme.scss +49 -42
- package/toggle/public-api.d.ts +1 -1
- package/toggle/toggle.scss +9 -22
- package/tooltip/_tooltip-theme.scss +12 -16
- package/tooltip/public-api.d.ts +1 -1
- package/tooltip/tooltip.component.d.ts +14 -10
- package/tooltip/tooltip.scss +7 -13
- package/tree/_tree-theme.scss +20 -23
- package/tree/public-api.d.ts +10 -10
- package/tree/toggle.scss +3 -6
- package/tree/tree-base.d.ts +2 -2
- package/tree/tree-option.component.d.ts +1 -1
- package/tree/tree-option.scss +17 -14
- package/tree/tree-selection.component.d.ts +2 -1
- package/tree-select/_tree-select-theme.scss +12 -15
- package/tree-select/public-api.d.ts +1 -1
- package/tree-select/tree-select.component.d.ts +13 -20
- package/tree-select/tree-select.module.d.ts +1 -2
- package/tree-select/tree-select.scss +1 -6
- package/core/styles/_variables.scss +0 -1
|
@@ -1,25 +1,452 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { SelectionModel, DataSource } from '@angular/cdk/collections';
|
|
2
|
+
import { BehaviorSubject, merge, Subject, Observable, of, asyncScheduler } from 'rxjs';
|
|
3
|
+
import * as i2$1 from '@koobiq/components/core';
|
|
4
|
+
import { escapeRegExp, mixinDisabled, KBQ_TITLE_TEXT_REF, KBQ_OPTION_ACTION_PARENT, KbqPseudoCheckbox, KbqOptionActionComponent, MultipleMode, getKbqSelectNonArrayValueError, KbqPseudoCheckboxModule } from '@koobiq/components/core';
|
|
5
|
+
import { take, map, takeUntil, delay } from 'rxjs/operators';
|
|
3
6
|
import * as i0 from '@angular/core';
|
|
4
7
|
import { Directive, Input, ViewChild, ContentChildren, forwardRef, Inject, Component, ViewEncapsulation, ChangeDetectionStrategy, InjectionToken, EventEmitter, ContentChild, Output, Optional, QueryList, Attribute, NgModule } from '@angular/core';
|
|
5
|
-
import * as i2$1 from '@koobiq/components/core';
|
|
6
|
-
import { mixinDisabled, KBQ_TITLE_TEXT_REF, KBQ_OPTION_ACTION_PARENT, KbqPseudoCheckbox, KbqOptionActionComponent, escapeRegExp, MultipleMode, getKbqSelectNonArrayValueError, KbqPseudoCheckboxModule } from '@koobiq/components/core';
|
|
7
|
-
import * as i2 from '@koobiq/components/icon';
|
|
8
|
-
import { KbqIconModule } from '@koobiq/components/icon';
|
|
9
|
-
import { BehaviorSubject, Subject, Observable, of, merge, asyncScheduler } from 'rxjs';
|
|
10
|
-
import * as i1$1 from 'rxjs/internal/scheduler/AsyncScheduler';
|
|
11
|
-
import { AsyncScheduler } from 'rxjs/internal/scheduler/AsyncScheduler';
|
|
12
8
|
import * as i3 from '@angular/cdk/bidi';
|
|
13
9
|
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
|
14
|
-
import { TreeSizeIndentLevel } from '@koobiq/design-tokens
|
|
15
|
-
import { takeUntil, take, delay, map } from 'rxjs/operators';
|
|
10
|
+
import { TreeSizeIndentLevel } from '@koobiq/design-tokens';
|
|
16
11
|
import { TAB, hasModifierKey, SPACE, LEFT_ARROW, RIGHT_ARROW, isVerticalMovement, isSelectAll, isCopy, DOWN_ARROW, UP_ARROW, ENTER, HOME, END, PAGE_UP, PAGE_DOWN } from '@koobiq/cdk/keycodes';
|
|
17
12
|
import { KbqDropdownTrigger } from '@koobiq/components/dropdown';
|
|
18
13
|
import { KbqTooltipTrigger } from '@koobiq/components/tooltip';
|
|
14
|
+
import * as i2 from '@koobiq/components/icon';
|
|
15
|
+
import { KbqIconModule } from '@koobiq/components/icon';
|
|
16
|
+
import * as i1 from '@angular/common';
|
|
17
|
+
import { CommonModule } from '@angular/common';
|
|
19
18
|
import * as i2$2 from '@angular/cdk/clipboard';
|
|
20
|
-
import { SelectionModel, DataSource } from '@angular/cdk/collections';
|
|
21
19
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
22
20
|
import { FocusKeyManager } from '@koobiq/cdk/a11y';
|
|
21
|
+
import * as i1$1 from 'rxjs/internal/scheduler/AsyncScheduler';
|
|
22
|
+
import { AsyncScheduler } from 'rxjs/internal/scheduler/AsyncScheduler';
|
|
23
|
+
|
|
24
|
+
/** Base tree control. It has basic toggle/expand/collapse operations on a single data node. */
|
|
25
|
+
/* tslint:disable-next-line:naming-convention */
|
|
26
|
+
class BaseTreeControl {
|
|
27
|
+
constructor() {
|
|
28
|
+
/** A selection model with multi-selection to track expansion status. */
|
|
29
|
+
this.expansionModel = new SelectionModel(true);
|
|
30
|
+
this.filterModel = new SelectionModel(true);
|
|
31
|
+
this.filterValue = new BehaviorSubject('');
|
|
32
|
+
}
|
|
33
|
+
/** Toggles one single data node's expanded/collapsed state. */
|
|
34
|
+
toggle(dataNode) {
|
|
35
|
+
if (this.filterValue.value?.length) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.expansionModel.toggle(dataNode);
|
|
39
|
+
}
|
|
40
|
+
/** Expands one single data node. */
|
|
41
|
+
expand(dataNode) {
|
|
42
|
+
if (this.filterValue.value?.length) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.expansionModel.select(dataNode);
|
|
46
|
+
}
|
|
47
|
+
/** Collapses one single data node. */
|
|
48
|
+
collapse(dataNode) {
|
|
49
|
+
if (this.filterValue.value?.length) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.expansionModel.deselect(dataNode);
|
|
53
|
+
}
|
|
54
|
+
/** Whether a given data node is expanded or not. Returns true if the data node is expanded. */
|
|
55
|
+
isExpanded(dataNode) {
|
|
56
|
+
return this.expansionModel.isSelected(dataNode);
|
|
57
|
+
}
|
|
58
|
+
/** Toggles a subtree rooted at `node` recursively. */
|
|
59
|
+
toggleDescendants(dataNode) {
|
|
60
|
+
this.expansionModel.isSelected(dataNode)
|
|
61
|
+
? this.collapseDescendants(dataNode)
|
|
62
|
+
: this.expandDescendants(dataNode);
|
|
63
|
+
}
|
|
64
|
+
/** Collapse all dataNodes in the tree. */
|
|
65
|
+
collapseAll() {
|
|
66
|
+
this.expansionModel.clear();
|
|
67
|
+
}
|
|
68
|
+
/** Expands a subtree rooted at given data node recursively. */
|
|
69
|
+
expandDescendants(dataNode) {
|
|
70
|
+
const toBeProcessed = [dataNode];
|
|
71
|
+
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
72
|
+
this.expansionModel.select(...toBeProcessed);
|
|
73
|
+
}
|
|
74
|
+
/** Collapses a subtree rooted at given data node recursively. */
|
|
75
|
+
collapseDescendants(dataNode) {
|
|
76
|
+
const toBeProcessed = [dataNode];
|
|
77
|
+
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
78
|
+
this.expansionModel.deselect(...toBeProcessed);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class FilterByViewValue {
|
|
83
|
+
constructor(control) {
|
|
84
|
+
this.control = control;
|
|
85
|
+
}
|
|
86
|
+
handle(value) {
|
|
87
|
+
const viewValue = value || null;
|
|
88
|
+
this.result = this.control.dataNodes.filter((node) => this.control.compareViewValues(this.control.getViewValue(node), viewValue));
|
|
89
|
+
return this.result;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
class FilterParentsForNodes {
|
|
93
|
+
constructor(control) {
|
|
94
|
+
this.control = control;
|
|
95
|
+
}
|
|
96
|
+
handle(_, prevFilter) {
|
|
97
|
+
const result = new Set();
|
|
98
|
+
this.control.dataNodes
|
|
99
|
+
.filter((node) => prevFilter?.result.includes(node))
|
|
100
|
+
.forEach((node) => {
|
|
101
|
+
this.control.getParents(node, []).forEach((parent) => result.add(parent));
|
|
102
|
+
result.add(node);
|
|
103
|
+
});
|
|
104
|
+
this.result = Array.from(result);
|
|
105
|
+
return this.result;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
class FilterByValues {
|
|
109
|
+
constructor(control) {
|
|
110
|
+
this.control = control;
|
|
111
|
+
this.values = [];
|
|
112
|
+
this.setValues = (values) => {
|
|
113
|
+
this.values = values;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
handle(_, prevFilter) {
|
|
117
|
+
const found = this.control.dataNodes.filter((node) => this.values.includes(this.control.getValue(node)));
|
|
118
|
+
this.result = Array.from(new Set([...(prevFilter?.result || []), ...found]));
|
|
119
|
+
return this.result;
|
|
120
|
+
}
|
|
121
|
+
getValues() {
|
|
122
|
+
return this.values;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function defaultCompareValues(firstValue, secondValue) {
|
|
127
|
+
return firstValue === secondValue;
|
|
128
|
+
}
|
|
129
|
+
function defaultCompareViewValues(firstViewValue, secondViewValue) {
|
|
130
|
+
return RegExp(escapeRegExp(secondViewValue), 'gi').test(firstViewValue);
|
|
131
|
+
}
|
|
132
|
+
/** Flat tree control. Able to expand/collapse a subtree recursively for flattened tree. */
|
|
133
|
+
class FlatTreeControl extends BaseTreeControl {
|
|
134
|
+
/** Construct with flat tree data node functions getLevel, isExpandable, getValue and getViewValue. */
|
|
135
|
+
constructor(getLevel, isExpandable,
|
|
136
|
+
/** getValue will be used to determine if the tree contains value or not. Used in method hasValue */
|
|
137
|
+
getValue,
|
|
138
|
+
/** getViewValue will be used for filter nodes. Returned value will be first argument in filterNodesFunction */
|
|
139
|
+
getViewValue,
|
|
140
|
+
/** compareValues will be used to comparing values. */
|
|
141
|
+
compareValues = defaultCompareValues,
|
|
142
|
+
/** compareValues will be used to comparing values. */
|
|
143
|
+
compareViewValues = defaultCompareViewValues,
|
|
144
|
+
/** isDisabled will be used to determine if the node is disabled. */
|
|
145
|
+
isDisabled = () => false) {
|
|
146
|
+
super();
|
|
147
|
+
this.getLevel = getLevel;
|
|
148
|
+
this.isExpandable = isExpandable;
|
|
149
|
+
this.getValue = getValue;
|
|
150
|
+
this.getViewValue = getViewValue;
|
|
151
|
+
this.compareValues = compareValues;
|
|
152
|
+
this.compareViewValues = compareViewValues;
|
|
153
|
+
this.isDisabled = isDisabled;
|
|
154
|
+
this.setFilters(new FilterByViewValue(this), new FilterParentsForNodes(this));
|
|
155
|
+
}
|
|
156
|
+
getFilters() {
|
|
157
|
+
return this.filters;
|
|
158
|
+
}
|
|
159
|
+
setFilters(...filters) {
|
|
160
|
+
this.filters = filters;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Gets a list of the data node's subtree of descendent data nodes.
|
|
164
|
+
*
|
|
165
|
+
* To make this working, the `dataNodes` of the TreeControl must be flattened tree nodes
|
|
166
|
+
* with correct levels.
|
|
167
|
+
*/
|
|
168
|
+
getDescendants(dataNode) {
|
|
169
|
+
const startIndex = this.dataNodes.indexOf(dataNode);
|
|
170
|
+
const results = [];
|
|
171
|
+
// Goes through flattened tree nodes in the `dataNodes` array, and get all descendants.
|
|
172
|
+
// The level of descendants of a tree node must be greater than the level of the given
|
|
173
|
+
// tree node.
|
|
174
|
+
// If we reach a node whose level is equal to the level of the tree node, we hit a sibling.
|
|
175
|
+
// If we reach a node whose level is greater than the level of the tree node, we hit a
|
|
176
|
+
// sibling of an ancestor.
|
|
177
|
+
for (let i = startIndex + 1; i < this.dataNodes.length && this.getLevel(dataNode) < this.getLevel(this.dataNodes[i]); i++) {
|
|
178
|
+
results.push(this.dataNodes[i]);
|
|
179
|
+
}
|
|
180
|
+
return results;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Expands all data nodes in the tree.
|
|
184
|
+
*
|
|
185
|
+
* To make this working, the `dataNodes` variable of the TreeControl must be set to all flattened
|
|
186
|
+
* data nodes of the tree.
|
|
187
|
+
*/
|
|
188
|
+
expandAll() {
|
|
189
|
+
this.expansionModel.select(...this.dataNodes);
|
|
190
|
+
}
|
|
191
|
+
getParents(node, result) {
|
|
192
|
+
if (node.parent) {
|
|
193
|
+
result.unshift(node.parent);
|
|
194
|
+
return this.getParents(node.parent, result);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
hasValue(value) {
|
|
201
|
+
return this.dataNodes.find((node) => this.compareValues(this.getValue(node), value));
|
|
202
|
+
}
|
|
203
|
+
filterNodes(value = null) {
|
|
204
|
+
this.saveExpansionState();
|
|
205
|
+
let result = [];
|
|
206
|
+
this.filters.forEach((filter, index, filters) => {
|
|
207
|
+
const prevFilter = filters[index - 1] || null;
|
|
208
|
+
result = filter.handle(value, prevFilter);
|
|
209
|
+
});
|
|
210
|
+
this.filterModel.clear();
|
|
211
|
+
this.filterModel.select(...result);
|
|
212
|
+
// set current expansion state according to filtered tree
|
|
213
|
+
this.expansionModel.setSelection(...result.filter((node) => this.isExpandable(node)));
|
|
214
|
+
this.updateFilterValue(value || result);
|
|
215
|
+
Promise.resolve().then(() => this.restoreExpansionState());
|
|
216
|
+
}
|
|
217
|
+
updateFilterValue(value) {
|
|
218
|
+
Promise.resolve().then(() => this.filterValue.next(value));
|
|
219
|
+
}
|
|
220
|
+
saveExpansionState() {
|
|
221
|
+
if (!this.filterValue.value?.length) {
|
|
222
|
+
this.expandedItemsBeforeFiltration = this.expansionModel.selected;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
restoreExpansionState() {
|
|
226
|
+
if (!this.filterValue.value?.length) {
|
|
227
|
+
this.expansionModel.setSelection(...this.expandedItemsBeforeFiltration);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Nested tree control. Able to expand/collapse a subtree recursively for NestedNode type. */
|
|
233
|
+
class NestedTreeControl extends BaseTreeControl {
|
|
234
|
+
/** Construct with nested tree function getChildren. */
|
|
235
|
+
constructor(getChildren) {
|
|
236
|
+
super();
|
|
237
|
+
this.getChildren = getChildren;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Expands all dataNodes in the tree.
|
|
241
|
+
*
|
|
242
|
+
* To make this working, the `dataNodes` variable of the TreeControl must be set to all root level
|
|
243
|
+
* data nodes of the tree.
|
|
244
|
+
*/
|
|
245
|
+
expandAll() {
|
|
246
|
+
this.expansionModel.clear();
|
|
247
|
+
const allNodes = this.dataNodes.reduce((accumulator, dataNode) => [...accumulator, ...this.getDescendants(dataNode), dataNode], []);
|
|
248
|
+
this.expansionModel.select(...allNodes);
|
|
249
|
+
}
|
|
250
|
+
/** Gets a list of descendant dataNodes of a subtree rooted at given data node recursively. */
|
|
251
|
+
getDescendants(dataNode) {
|
|
252
|
+
const descendants = [];
|
|
253
|
+
this._getDescendants(descendants, dataNode);
|
|
254
|
+
return descendants.splice(1);
|
|
255
|
+
}
|
|
256
|
+
/** A helper function to get descendants recursively. */
|
|
257
|
+
// todo нужно придумать другое название и понять в чем отличие между getDescendants и _getDescendants
|
|
258
|
+
/* tslint:disable-next-line:naming-convention */
|
|
259
|
+
_getDescendants(descendants, dataNode) {
|
|
260
|
+
descendants.push(dataNode);
|
|
261
|
+
this.getChildren(dataNode)
|
|
262
|
+
.pipe(take(1))
|
|
263
|
+
.subscribe((children) => {
|
|
264
|
+
if (children && children.length > 0) {
|
|
265
|
+
children.forEach((child) => this._getDescendants(descendants, child));
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Tree flattener to convert a normal type of node to node with children & level information.
|
|
273
|
+
* Transform nested nodes of type `T` to flattened nodes of type `F`.
|
|
274
|
+
*
|
|
275
|
+
* For example, the input data of type `T` is nested, and contains its children data:
|
|
276
|
+
* SomeNode: {
|
|
277
|
+
* key: 'Fruits',
|
|
278
|
+
* children: [
|
|
279
|
+
* NodeOne: {
|
|
280
|
+
* key: 'Apple',
|
|
281
|
+
* },
|
|
282
|
+
* NodeTwo: {
|
|
283
|
+
* key: 'Pear',
|
|
284
|
+
* }
|
|
285
|
+
* ]
|
|
286
|
+
* }
|
|
287
|
+
* After flattener flatten the tree, the structure will become
|
|
288
|
+
* SomeNode: {
|
|
289
|
+
* key: 'Fruits',
|
|
290
|
+
* expandable: true,
|
|
291
|
+
* level: 1
|
|
292
|
+
* },
|
|
293
|
+
* NodeOne: {
|
|
294
|
+
* key: 'Apple',
|
|
295
|
+
* expandable: false,
|
|
296
|
+
* level: 2
|
|
297
|
+
* },
|
|
298
|
+
* NodeTwo: {
|
|
299
|
+
* key: 'Pear',
|
|
300
|
+
* expandable: false,
|
|
301
|
+
* level: 2
|
|
302
|
+
* }
|
|
303
|
+
* and the output flattened type is `F` with additional information.
|
|
304
|
+
*/
|
|
305
|
+
class KbqTreeFlattener {
|
|
306
|
+
constructor(transformFunction, getLevel, isExpandable, getChildren) {
|
|
307
|
+
this.transformFunction = transformFunction;
|
|
308
|
+
this.getLevel = getLevel;
|
|
309
|
+
this.isExpandable = isExpandable;
|
|
310
|
+
this.getChildren = getChildren;
|
|
311
|
+
}
|
|
312
|
+
flattenNode(node, level, resultNodes, parent) {
|
|
313
|
+
const flatNode = this.transformFunction(node, level, parent);
|
|
314
|
+
resultNodes.push(flatNode);
|
|
315
|
+
if (this.isExpandable(flatNode)) {
|
|
316
|
+
const childrenNodes = this.getChildren(node);
|
|
317
|
+
if (childrenNodes) {
|
|
318
|
+
if (Array.isArray(childrenNodes)) {
|
|
319
|
+
this.flattenChildren(childrenNodes, level, resultNodes, flatNode);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
childrenNodes.pipe(take(1)).subscribe((children) => {
|
|
323
|
+
this.flattenChildren(children, level, resultNodes, flatNode);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return resultNodes;
|
|
329
|
+
}
|
|
330
|
+
flattenChildren(children, level, resultNodes, parent) {
|
|
331
|
+
children.forEach((child) => {
|
|
332
|
+
this.flattenNode(child, level + 1, resultNodes, parent);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Flatten a list of node type T to flattened version of node F.
|
|
337
|
+
* Please note that type T may be nested, and the length of `structuredData` may be different
|
|
338
|
+
* from that of returned list `F[]`.
|
|
339
|
+
*/
|
|
340
|
+
flattenNodes(structuredData) {
|
|
341
|
+
const resultNodes = [];
|
|
342
|
+
structuredData.forEach((node) => this.flattenNode(node, 0, resultNodes, null));
|
|
343
|
+
return resultNodes;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Expand flattened node with current expansion status.
|
|
347
|
+
* The returned list may have different length.
|
|
348
|
+
*/
|
|
349
|
+
expandFlattenedNodes(nodes, treeControl) {
|
|
350
|
+
const results = [];
|
|
351
|
+
const currentExpand = [];
|
|
352
|
+
currentExpand[0] = true;
|
|
353
|
+
nodes.forEach((node) => {
|
|
354
|
+
let expand = true;
|
|
355
|
+
for (let i = 0; i <= this.getLevel(node); i++) {
|
|
356
|
+
expand = expand && currentExpand[i];
|
|
357
|
+
}
|
|
358
|
+
if (expand) {
|
|
359
|
+
results.push(node);
|
|
360
|
+
}
|
|
361
|
+
if (this.isExpandable(node)) {
|
|
362
|
+
currentExpand[this.getLevel(node) + 1] = treeControl.isExpanded(node);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
return results;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
var KbqTreeDataSourceChangeTypes;
|
|
369
|
+
(function (KbqTreeDataSourceChangeTypes) {
|
|
370
|
+
KbqTreeDataSourceChangeTypes["Expansion"] = "expansion";
|
|
371
|
+
KbqTreeDataSourceChangeTypes["Filter"] = "filter";
|
|
372
|
+
})(KbqTreeDataSourceChangeTypes || (KbqTreeDataSourceChangeTypes = {}));
|
|
373
|
+
/**
|
|
374
|
+
* Data source for flat tree.
|
|
375
|
+
* The data source need to handle expansion/collapsion of the tree node and change the data feed
|
|
376
|
+
* to `KbqTree`.
|
|
377
|
+
* The nested tree nodes of type `T` are flattened through `MсTreeFlattener`, and converted
|
|
378
|
+
* to type `F` for `KbqTree` to consume.
|
|
379
|
+
*/
|
|
380
|
+
class KbqTreeFlatDataSource extends DataSource {
|
|
381
|
+
get data() {
|
|
382
|
+
return this._data.value;
|
|
383
|
+
}
|
|
384
|
+
set data(value) {
|
|
385
|
+
this._data.next(value);
|
|
386
|
+
this.flattenedData.next(this.treeFlattener.flattenNodes(this.data));
|
|
387
|
+
this.treeControl.dataNodes = this.flattenedData.value;
|
|
388
|
+
}
|
|
389
|
+
constructor(treeControl, treeFlattener, initialData = []) {
|
|
390
|
+
super();
|
|
391
|
+
this.treeControl = treeControl;
|
|
392
|
+
this.treeFlattener = treeFlattener;
|
|
393
|
+
this.flattenedData = new BehaviorSubject([]);
|
|
394
|
+
this.expandedData = new BehaviorSubject([]);
|
|
395
|
+
this.filteredData = new BehaviorSubject([]);
|
|
396
|
+
this._data = new BehaviorSubject(initialData);
|
|
397
|
+
}
|
|
398
|
+
connect(collectionViewer) {
|
|
399
|
+
return merge(collectionViewer.viewChange, this.treeControl.expansionModel.changed.pipe(map((value) => ({ type: KbqTreeDataSourceChangeTypes.Expansion, value }))), this.treeControl.filterValue.pipe(map((value) => ({ type: KbqTreeDataSourceChangeTypes.Filter, value }))), this.flattenedData).pipe(map((changeObj) => {
|
|
400
|
+
if (changeObj.type === KbqTreeDataSourceChangeTypes.Filter) {
|
|
401
|
+
if (changeObj.value && changeObj.value.length > 0) {
|
|
402
|
+
return this.filterHandler();
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
return this.expansionHandler(changeObj.value);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return this.expansionHandler(changeObj.value);
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
411
|
+
filterHandler() {
|
|
412
|
+
this.filteredData.next(this.treeControl.filterModel.selected);
|
|
413
|
+
return this.filteredData.value;
|
|
414
|
+
}
|
|
415
|
+
expansionHandler(_change) {
|
|
416
|
+
const expandedNodes = this.treeFlattener.expandFlattenedNodes(this.flattenedData.value, this.treeControl);
|
|
417
|
+
this.expandedData.next(expandedNodes);
|
|
418
|
+
return this.expandedData.value;
|
|
419
|
+
}
|
|
420
|
+
disconnect() {
|
|
421
|
+
// no op
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Data source for nested tree.
|
|
427
|
+
*
|
|
428
|
+
* The data source for nested tree doesn't have to consider node flattener, or the way to expand
|
|
429
|
+
* or collapse. The expansion/collapsion will be handled by TreeControl and each non-leaf node.
|
|
430
|
+
*/
|
|
431
|
+
class KbqTreeNestedDataSource extends DataSource {
|
|
432
|
+
constructor() {
|
|
433
|
+
super(...arguments);
|
|
434
|
+
/* tslint:disable-next-line:naming-convention */
|
|
435
|
+
this._data = new BehaviorSubject([]);
|
|
436
|
+
}
|
|
437
|
+
get data() {
|
|
438
|
+
return this._data.value;
|
|
439
|
+
}
|
|
440
|
+
set data(value) {
|
|
441
|
+
this._data.next(value);
|
|
442
|
+
}
|
|
443
|
+
connect(collectionViewer) {
|
|
444
|
+
return merge(...[collectionViewer.viewChange, this._data]).pipe(map(() => this.data));
|
|
445
|
+
}
|
|
446
|
+
disconnect() {
|
|
447
|
+
// no op
|
|
448
|
+
}
|
|
449
|
+
}
|
|
23
450
|
|
|
24
451
|
/** Context provided to the tree node component. */
|
|
25
452
|
class KbqTreeNodeOutletContext {
|
|
@@ -103,7 +530,7 @@ class KbqTreeBase {
|
|
|
103
530
|
/**
|
|
104
531
|
* Provides a stream containing the latest data array to render. Influenced by the tree's
|
|
105
532
|
* stream of view window (what dataNodes are currently on screen).
|
|
106
|
-
* Data source can be an observable of data array, or a
|
|
533
|
+
* Data source can be an observable of data array, or a data array to render.
|
|
107
534
|
*/
|
|
108
535
|
get dataSource() {
|
|
109
536
|
return this._dataSource;
|
|
@@ -356,8 +783,7 @@ class KbqTreeNodeToggleBaseDirective extends KbqTreeNodeToggleMixinBase {
|
|
|
356
783
|
this.tree = tree;
|
|
357
784
|
this.treeNode = treeNode;
|
|
358
785
|
this._recursive = false;
|
|
359
|
-
this.tree.treeControl.filterValue
|
|
360
|
-
.subscribe((value) => this.disabled = !!value?.length);
|
|
786
|
+
this.tree.treeControl.filterValue.subscribe((value) => (this.disabled = !!value?.length));
|
|
361
787
|
}
|
|
362
788
|
toggle(event) {
|
|
363
789
|
if (this.disabled) {
|
|
@@ -381,11 +807,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImpor
|
|
|
381
807
|
}] } });
|
|
382
808
|
class KbqTreeNodeToggleComponent extends KbqTreeNodeToggleBaseDirective {
|
|
383
809
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTreeNodeToggleComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
384
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.0", type: KbqTreeNodeToggleComponent, selector: "kbq-tree-node-toggle", inputs: { disabled: "disabled" }, host: { listeners: { "click": "toggle($event)" }, properties: { "class.kbq-expanded": "iconState", "attr.disabled": "disabled || null" }, classAttribute: "kbq-tree-node-toggle" }, exportAs: ["kbqTreeNodeToggle"], usesInheritance: true, ngImport: i0, template:
|
|
810
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.0", type: KbqTreeNodeToggleComponent, selector: "kbq-tree-node-toggle", inputs: { disabled: "disabled" }, host: { listeners: { "click": "toggle($event)" }, properties: { "class.kbq-expanded": "iconState", "attr.disabled": "disabled || null" }, classAttribute: "kbq-tree-node-toggle" }, exportAs: ["kbqTreeNodeToggle"], usesInheritance: true, ngImport: i0, template: `
|
|
811
|
+
<i kbq-icon="mc-angle-down-S_16"></i>
|
|
812
|
+
`, isInline: true, styles: [".kbq-tree-node-toggle{display:flex;align-items:center;justify-content:center;flex-shrink:0;height:100%;padding-left:var(--kbq-tree-size-toggle-padding, );padding-right:var(--kbq-tree-size-toggle-padding, );cursor:pointer}.kbq-tree-node-toggle .kbq-icon{transform:rotate(-90deg)}.kbq-tree-node-toggle.kbq-expanded .kbq-icon{transform:rotate(0)}.kbq-tree-node-toggle[disabled]{cursor:default}\n"], dependencies: [{ kind: "component", type: i2.KbqIcon, selector: "[kbq-icon]", inputs: ["color", "small", "autoColor"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
385
813
|
}
|
|
386
814
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTreeNodeToggleComponent, decorators: [{
|
|
387
815
|
type: Component,
|
|
388
|
-
args: [{ selector: 'kbq-tree-node-toggle', exportAs: 'kbqTreeNodeToggle', template:
|
|
816
|
+
args: [{ selector: 'kbq-tree-node-toggle', exportAs: 'kbqTreeNodeToggle', template: `
|
|
817
|
+
<i kbq-icon="mc-angle-down-S_16"></i>
|
|
818
|
+
`, host: {
|
|
389
819
|
class: 'kbq-tree-node-toggle',
|
|
390
820
|
'[class.kbq-expanded]': 'iconState',
|
|
391
821
|
'[attr.disabled]': 'disabled || null',
|
|
@@ -502,8 +932,7 @@ class KbqTreeOption extends KbqTreeNode {
|
|
|
502
932
|
};
|
|
503
933
|
}
|
|
504
934
|
ngAfterContentInit() {
|
|
505
|
-
Promise.resolve()
|
|
506
|
-
.then(this.updateCheckboxState);
|
|
935
|
+
Promise.resolve().then(this.updateCheckboxState);
|
|
507
936
|
this.value = this.tree.treeControl.getValue(this.data);
|
|
508
937
|
}
|
|
509
938
|
descendantsAllSelected() {
|
|
@@ -515,11 +944,8 @@ class KbqTreeOption extends KbqTreeNode {
|
|
|
515
944
|
return descendants.some((child) => this.tree?.selectionModel.isSelected(child));
|
|
516
945
|
}
|
|
517
946
|
updateParentsCheckboxState(node) {
|
|
518
|
-
this.tree.treeControl
|
|
519
|
-
.
|
|
520
|
-
.forEach((parent) => {
|
|
521
|
-
const parentOption = this.tree.unorderedOptions
|
|
522
|
-
.find((option) => option.data === parent);
|
|
947
|
+
this.tree.treeControl.getParents(node, []).forEach((parent) => {
|
|
948
|
+
const parentOption = this.tree.unorderedOptions.find((option) => option.data === parent);
|
|
523
949
|
parentOption?.updateCheckboxState();
|
|
524
950
|
});
|
|
525
951
|
}
|
|
@@ -643,7 +1069,7 @@ class KbqTreeOption extends KbqTreeNode {
|
|
|
643
1069
|
{ provide: KbqTreeNode, useExisting: KbqTreeOption },
|
|
644
1070
|
{ provide: KBQ_TITLE_TEXT_REF, useExisting: KbqTreeOption },
|
|
645
1071
|
{ provide: KBQ_OPTION_ACTION_PARENT, useExisting: KbqTreeOption }
|
|
646
|
-
], queries: [{ propertyName: "toggleElementDirective", first: true, predicate: KbqTreeNodeToggleDirective, descendants: true }, { propertyName: "toggleElementComponent", first: true, predicate: KbqTreeNodeToggleComponent, descendants: true }, { propertyName: "pseudoCheckbox", first: true, predicate: KbqPseudoCheckbox, descendants: true }, { propertyName: "actionButton", first: true, predicate: KbqOptionActionComponent, descendants: true }, { propertyName: "tooltipTrigger", first: true, predicate: KbqTooltipTrigger, descendants: true }, { propertyName: "dropdownTrigger", first: true, predicate: KbqDropdownTrigger, descendants: true }], viewQueries: [{ propertyName: "parentTextElement", first: true, predicate: ["kbqTitleContainer"], descendants: true }], exportAs: ["kbqTreeOption"], usesInheritance: true, ngImport: i0, template: "<ng-content select=\"kbq-tree-node-toggle, [kbq-tree-node-toggle], [kbqTreeNodeToggle]\"></ng-content>\n\n<ng-container [ngSwitch]=\"externalPseudoCheckbox\">\n <ng-content
|
|
1072
|
+
], queries: [{ propertyName: "toggleElementDirective", first: true, predicate: KbqTreeNodeToggleDirective, descendants: true }, { propertyName: "toggleElementComponent", first: true, predicate: KbqTreeNodeToggleComponent, descendants: true }, { propertyName: "pseudoCheckbox", first: true, predicate: KbqPseudoCheckbox, descendants: true }, { propertyName: "actionButton", first: true, predicate: KbqOptionActionComponent, descendants: true }, { propertyName: "tooltipTrigger", first: true, predicate: KbqTooltipTrigger, descendants: true }, { propertyName: "dropdownTrigger", first: true, predicate: KbqDropdownTrigger, descendants: true }], viewQueries: [{ propertyName: "parentTextElement", first: true, predicate: ["kbqTitleContainer"], descendants: true }], exportAs: ["kbqTreeOption"], usesInheritance: true, ngImport: i0, template: "<ng-content select=\"kbq-tree-node-toggle, [kbq-tree-node-toggle], [kbqTreeNodeToggle]\"></ng-content>\n\n<ng-container [ngSwitch]=\"externalPseudoCheckbox\">\n <ng-content\n *ngSwitchCase=\"true\"\n select=\"kbq-pseudo-checkbox\"\n ></ng-content>\n\n <ng-container *ngSwitchCase=\"false\">\n <kbq-pseudo-checkbox\n *ngIf=\"showCheckbox\"\n [disabled]=\"disabled\"\n [state]=\"checkboxState\"\n ></kbq-pseudo-checkbox>\n </ng-container>\n</ng-container>\n\n<ng-content select=\"kbq-checkbox\"></ng-content>\n\n<ng-content select=\"[kbq-icon]\"></ng-content>\n\n<ng-content select=\"kbq-progress-spinner\"></ng-content>\n\n<span\n #kbqTitleContainer\n class=\"kbq-option-text\"\n>\n <ng-content></ng-content>\n</span>\n\n<ng-content select=\"kbq-option-action\"></ng-content>\n", styles: ["@keyframes kbq-progress{0%{background-position:0 0}to{background-position:29px 0}}.kbq-progress{position:relative}.kbq-progress:after{content:\"\";position:absolute;border-radius:inherit;inset:0;background:linear-gradient(135deg,#0000000a 10px,#ffffff0a 10px 20px,#0000000a 20px 30px,#ffffff0a 31px) repeat;background-size:32px 32px;animation:kbq-progress 1s linear infinite}.kbq-group{display:flex;flex-direction:row}.kbq-group .kbq-group_justified>.kbq-group-item{width:100%}.kbq-group .kbq-group-item+.kbq-group-item{margin-left:calc(-1 * var(--kbq-button-size-border-width, 2px))}.kbq-group>.kbq-group-item:first-child:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.kbq-group>.kbq-group-item:first-child:not(:last-child)>.kbq-form-field__container{border-bottom-right-radius:0;border-top-right-radius:0}.kbq-group>.kbq-group-item:last-child:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.kbq-group>.kbq-group-item:last-child:not(:first-child)>.kbq-form-field__container{border-bottom-left-radius:0;border-top-left-radius:0}.kbq-group>.kbq-group-item:not(:first-child):not(:last-child){border-radius:0}.kbq-group>.kbq-group-item:not(:first-child):not(:last-child)>.kbq-form-field__container{border-radius:0}.kbq-vertical-group{display:flex;flex-direction:column}.kbq-vertical-group>.kbq-group-item:first-child:not(:last-child){border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-right-radius:var(--kbq-button-size-border-radius, 8px)}.kbq-vertical-group>.kbq-group-item:first-child:not(:last-child)>.kbq-form-field__container{border-bottom-right-radius:0;border-bottom-left-radius:0}.kbq-vertical-group>.kbq-group-item:last-child:not(:first-child){border-top-right-radius:0;border-top-left-radius:0;border-bottom-left-radius:var(--kbq-button-size-border-radius, 8px)}.kbq-vertical-group>.kbq-group-item:last-child:not(:first-child)>.kbq-form-field__container{border-top-right-radius:0;border-top-left-radius:0}.kbq-vertical-group>.kbq-group-item:not(:first-child):not(:last-child){border-radius:0}.kbq-vertical-group>.kbq-group-item:not(:first-child):not(:last-child)>.kbq-form-field__container{border-radius:0}.kbq-vertical-group .kbq-group-item+.kbq-group-item{margin-top:calc(-1 * var(--kbq-button-size-border-width, 2px))}.kbq-no-select{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.kbq-tree-option{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;box-sizing:border-box;display:flex;align-items:center;min-height:32px;word-wrap:break-word;border-width:var(--kbq-tree-size-container-focus-outline-width, 2px);border-style:solid;border-color:transparent;padding-top:calc(var(--kbq-tree-size-container-padding-vertical, 4px) - var(--kbq-tree-size-container-focus-outline-width, 2px));padding-right:calc(var(--kbq-tree-size-container-padding-right, 8px) - var(--kbq-tree-size-container-focus-outline-width, 2px));padding-bottom:calc(var(--kbq-tree-size-container-padding-vertical, 4px) - var(--kbq-tree-size-container-focus-outline-width, 2px));gap:var(--kbq-tree-size-container-content-gap-horizontal, 8px)}.kbq-tree-option .kbq-option-text{display:flex;flex-direction:column;width:100%;box-sizing:content-box;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-top:var(--kbq-list-size-text-padding-vertical, 0);padding-bottom:var(--kbq-list-size-text-padding-vertical, 0)}.kbq-tree-option .kbq-option-text>*{margin:0;padding:0;font-weight:400;font-size:inherit}.kbq-tree-option .kbq-option-text:empty{display:none}.kbq-tree-option:focus{outline:none}.kbq-tree-option:not(.kbq-disabled){cursor:pointer}.kbq-tree-option .kbq-option-action{display:none}.kbq-tree-option:not(.kbq-disabled):hover .kbq-option-action,.kbq-tree-option:not(.kbq-disabled).kbq-focused .kbq-option-action,.kbq-tree-option:not(.kbq-disabled).kbq-action-button-focused .kbq-option-action{display:flex}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "component", type: i2$1.KbqPseudoCheckbox, selector: "kbq-pseudo-checkbox", inputs: ["color", "big", "state", "disabled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
647
1073
|
}
|
|
648
1074
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTreeOption, decorators: [{
|
|
649
1075
|
type: Component,
|
|
@@ -664,7 +1090,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImpor
|
|
|
664
1090
|
{ provide: KbqTreeNode, useExisting: KbqTreeOption },
|
|
665
1091
|
{ provide: KBQ_TITLE_TEXT_REF, useExisting: KbqTreeOption },
|
|
666
1092
|
{ provide: KBQ_OPTION_ACTION_PARENT, useExisting: KbqTreeOption }
|
|
667
|
-
], template: "<ng-content select=\"kbq-tree-node-toggle, [kbq-tree-node-toggle], [kbqTreeNodeToggle]\"></ng-content>\n\n<ng-container [ngSwitch]=\"externalPseudoCheckbox\">\n <ng-content
|
|
1093
|
+
], template: "<ng-content select=\"kbq-tree-node-toggle, [kbq-tree-node-toggle], [kbqTreeNodeToggle]\"></ng-content>\n\n<ng-container [ngSwitch]=\"externalPseudoCheckbox\">\n <ng-content\n *ngSwitchCase=\"true\"\n select=\"kbq-pseudo-checkbox\"\n ></ng-content>\n\n <ng-container *ngSwitchCase=\"false\">\n <kbq-pseudo-checkbox\n *ngIf=\"showCheckbox\"\n [disabled]=\"disabled\"\n [state]=\"checkboxState\"\n ></kbq-pseudo-checkbox>\n </ng-container>\n</ng-container>\n\n<ng-content select=\"kbq-checkbox\"></ng-content>\n\n<ng-content select=\"[kbq-icon]\"></ng-content>\n\n<ng-content select=\"kbq-progress-spinner\"></ng-content>\n\n<span\n #kbqTitleContainer\n class=\"kbq-option-text\"\n>\n <ng-content></ng-content>\n</span>\n\n<ng-content select=\"kbq-option-action\"></ng-content>\n", styles: ["@keyframes kbq-progress{0%{background-position:0 0}to{background-position:29px 0}}.kbq-progress{position:relative}.kbq-progress:after{content:\"\";position:absolute;border-radius:inherit;inset:0;background:linear-gradient(135deg,#0000000a 10px,#ffffff0a 10px 20px,#0000000a 20px 30px,#ffffff0a 31px) repeat;background-size:32px 32px;animation:kbq-progress 1s linear infinite}.kbq-group{display:flex;flex-direction:row}.kbq-group .kbq-group_justified>.kbq-group-item{width:100%}.kbq-group .kbq-group-item+.kbq-group-item{margin-left:calc(-1 * var(--kbq-button-size-border-width, 2px))}.kbq-group>.kbq-group-item:first-child:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.kbq-group>.kbq-group-item:first-child:not(:last-child)>.kbq-form-field__container{border-bottom-right-radius:0;border-top-right-radius:0}.kbq-group>.kbq-group-item:last-child:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.kbq-group>.kbq-group-item:last-child:not(:first-child)>.kbq-form-field__container{border-bottom-left-radius:0;border-top-left-radius:0}.kbq-group>.kbq-group-item:not(:first-child):not(:last-child){border-radius:0}.kbq-group>.kbq-group-item:not(:first-child):not(:last-child)>.kbq-form-field__container{border-radius:0}.kbq-vertical-group{display:flex;flex-direction:column}.kbq-vertical-group>.kbq-group-item:first-child:not(:last-child){border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-right-radius:var(--kbq-button-size-border-radius, 8px)}.kbq-vertical-group>.kbq-group-item:first-child:not(:last-child)>.kbq-form-field__container{border-bottom-right-radius:0;border-bottom-left-radius:0}.kbq-vertical-group>.kbq-group-item:last-child:not(:first-child){border-top-right-radius:0;border-top-left-radius:0;border-bottom-left-radius:var(--kbq-button-size-border-radius, 8px)}.kbq-vertical-group>.kbq-group-item:last-child:not(:first-child)>.kbq-form-field__container{border-top-right-radius:0;border-top-left-radius:0}.kbq-vertical-group>.kbq-group-item:not(:first-child):not(:last-child){border-radius:0}.kbq-vertical-group>.kbq-group-item:not(:first-child):not(:last-child)>.kbq-form-field__container{border-radius:0}.kbq-vertical-group .kbq-group-item+.kbq-group-item{margin-top:calc(-1 * var(--kbq-button-size-border-width, 2px))}.kbq-no-select{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.kbq-tree-option{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;box-sizing:border-box;display:flex;align-items:center;min-height:32px;word-wrap:break-word;border-width:var(--kbq-tree-size-container-focus-outline-width, 2px);border-style:solid;border-color:transparent;padding-top:calc(var(--kbq-tree-size-container-padding-vertical, 4px) - var(--kbq-tree-size-container-focus-outline-width, 2px));padding-right:calc(var(--kbq-tree-size-container-padding-right, 8px) - var(--kbq-tree-size-container-focus-outline-width, 2px));padding-bottom:calc(var(--kbq-tree-size-container-padding-vertical, 4px) - var(--kbq-tree-size-container-focus-outline-width, 2px));gap:var(--kbq-tree-size-container-content-gap-horizontal, 8px)}.kbq-tree-option .kbq-option-text{display:flex;flex-direction:column;width:100%;box-sizing:content-box;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-top:var(--kbq-list-size-text-padding-vertical, 0);padding-bottom:var(--kbq-list-size-text-padding-vertical, 0)}.kbq-tree-option .kbq-option-text>*{margin:0;padding:0;font-weight:400;font-size:inherit}.kbq-tree-option .kbq-option-text:empty{display:none}.kbq-tree-option:focus{outline:none}.kbq-tree-option:not(.kbq-disabled){cursor:pointer}.kbq-tree-option .kbq-option-action{display:none}.kbq-tree-option:not(.kbq-disabled):hover .kbq-option-action,.kbq-tree-option:not(.kbq-disabled).kbq-focused .kbq-option-action,.kbq-tree-option:not(.kbq-disabled).kbq-action-button-focused .kbq-option-action{display:flex}\n"] }]
|
|
668
1094
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
|
669
1095
|
type: Inject,
|
|
670
1096
|
args: [KBQ_TREE_OPTION_PARENT_COMPONENT]
|
|
@@ -730,8 +1156,7 @@ class KbqTreeNodePadding {
|
|
|
730
1156
|
this.baseLeftPadding = 8;
|
|
731
1157
|
this.iconWidth = 24;
|
|
732
1158
|
this.destroyed = new Subject();
|
|
733
|
-
this.dir?.change?.pipe(takeUntil(this.destroyed))
|
|
734
|
-
.subscribe(() => this.setPadding());
|
|
1159
|
+
this.dir?.change?.pipe(takeUntil(this.destroyed)).subscribe(() => this.setPadding());
|
|
735
1160
|
}
|
|
736
1161
|
ngAfterViewInit() {
|
|
737
1162
|
this.withIcon = this.option.isToggleInDefaultPlace;
|
|
@@ -742,11 +1167,11 @@ class KbqTreeNodePadding {
|
|
|
742
1167
|
this.destroyed.complete();
|
|
743
1168
|
}
|
|
744
1169
|
paddingIndent() {
|
|
745
|
-
const nodeLevel =
|
|
1170
|
+
const nodeLevel = this.treeNode.data && this.tree.treeControl.getLevel
|
|
746
1171
|
? this.tree.treeControl.getLevel(this.treeNode.data)
|
|
747
1172
|
: 0;
|
|
748
1173
|
const level = this.level || nodeLevel;
|
|
749
|
-
return level > 0 ? `${
|
|
1174
|
+
return level > 0 ? `${level * this._indent + this.leftPadding}px` : `${this.leftPadding}px`;
|
|
750
1175
|
}
|
|
751
1176
|
/**
|
|
752
1177
|
* This has been extracted to a util because of TS 4 and VE.
|
|
@@ -771,259 +1196,49 @@ class KbqTreeNodePadding {
|
|
|
771
1196
|
let value = indent;
|
|
772
1197
|
let units = 'px';
|
|
773
1198
|
if (typeof indent === 'string') {
|
|
774
|
-
const parts = indent.split(cssUnitPattern);
|
|
775
|
-
value = parts[0];
|
|
776
|
-
units = parts[1] || units;
|
|
777
|
-
}
|
|
778
|
-
this.indentUnits = units;
|
|
779
|
-
this._indent = coerceNumberProperty(value);
|
|
780
|
-
this.setPadding();
|
|
781
|
-
}
|
|
782
|
-
setPadding() {
|
|
783
|
-
const padding = this.paddingIndent();
|
|
784
|
-
const paddingProp = this.dir?.value === 'rtl' ? 'paddingRight' : 'paddingLeft';
|
|
785
|
-
this.renderer.setStyle(this.element.nativeElement, paddingProp, padding);
|
|
786
|
-
}
|
|
787
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTreeNodePadding, deps: [{ token: KbqTreeNode }, { token: KbqTreeBase }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: KbqTreeOption }, { token: i3.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
788
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.0", type: KbqTreeNodePadding, selector: "[kbqTreeNodePadding]", inputs: { indent: ["kbqTreeNodePaddingIndent", "indent"] }, exportAs: ["kbqTreeNodePadding"], ngImport: i0 }); }
|
|
789
|
-
}
|
|
790
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTreeNodePadding, decorators: [{
|
|
791
|
-
type: Directive,
|
|
792
|
-
args: [{
|
|
793
|
-
selector: '[kbqTreeNodePadding]',
|
|
794
|
-
exportAs: 'kbqTreeNodePadding'
|
|
795
|
-
}]
|
|
796
|
-
}], ctorParameters: () => [{ type: KbqTreeNode }, { type: KbqTreeBase }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: KbqTreeOption }, { type: i3.Directionality, decorators: [{
|
|
797
|
-
type: Optional
|
|
798
|
-
}] }], propDecorators: { indent: [{
|
|
799
|
-
type: Input,
|
|
800
|
-
args: ['kbqTreeNodePaddingIndent']
|
|
801
|
-
}] } });
|
|
802
|
-
|
|
803
|
-
class KbqTree extends KbqTreeBase {
|
|
804
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTree, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
805
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.0", type: KbqTree, selector: "kbq-tree", host: { classAttribute: "kbq-tree" }, exportAs: ["kbqTree"], usesInheritance: true, ngImport: i0, template: `<ng-container kbqTreeNodeOutlet></ng-container>`, isInline: true, styles: [".kbq-tree{display:block}\n"], dependencies: [{ kind: "directive", type: KbqTreeNodeOutlet, selector: "[kbqTreeNodeOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
806
|
-
}
|
|
807
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTree, decorators: [{
|
|
808
|
-
type: Component,
|
|
809
|
-
args: [{ selector: 'kbq-tree', exportAs: 'kbqTree', template: `<ng-container kbqTreeNodeOutlet></ng-container>`, host: {
|
|
810
|
-
class: 'kbq-tree'
|
|
811
|
-
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".kbq-tree{display:block}\n"] }]
|
|
812
|
-
}] });
|
|
813
|
-
|
|
814
|
-
/** Base tree control. It has basic toggle/expand/collapse operations on a single data node. */
|
|
815
|
-
/* tslint:disable-next-line:naming-convention */
|
|
816
|
-
class BaseTreeControl {
|
|
817
|
-
constructor() {
|
|
818
|
-
/** A selection model with multi-selection to track expansion status. */
|
|
819
|
-
this.expansionModel = new SelectionModel(true);
|
|
820
|
-
this.filterModel = new SelectionModel(true);
|
|
821
|
-
this.filterValue = new BehaviorSubject('');
|
|
822
|
-
}
|
|
823
|
-
/** Toggles one single data node's expanded/collapsed state. */
|
|
824
|
-
toggle(dataNode) {
|
|
825
|
-
if (this.filterValue.value?.length) {
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
this.expansionModel.toggle(dataNode);
|
|
829
|
-
}
|
|
830
|
-
/** Expands one single data node. */
|
|
831
|
-
expand(dataNode) {
|
|
832
|
-
if (this.filterValue.value?.length) {
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
this.expansionModel.select(dataNode);
|
|
836
|
-
}
|
|
837
|
-
/** Collapses one single data node. */
|
|
838
|
-
collapse(dataNode) {
|
|
839
|
-
if (this.filterValue.value?.length) {
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
this.expansionModel.deselect(dataNode);
|
|
843
|
-
}
|
|
844
|
-
/** Whether a given data node is expanded or not. Returns true if the data node is expanded. */
|
|
845
|
-
isExpanded(dataNode) {
|
|
846
|
-
return this.expansionModel.isSelected(dataNode);
|
|
847
|
-
}
|
|
848
|
-
/** Toggles a subtree rooted at `node` recursively. */
|
|
849
|
-
toggleDescendants(dataNode) {
|
|
850
|
-
this.expansionModel.isSelected(dataNode)
|
|
851
|
-
? this.collapseDescendants(dataNode)
|
|
852
|
-
: this.expandDescendants(dataNode);
|
|
853
|
-
}
|
|
854
|
-
/** Collapse all dataNodes in the tree. */
|
|
855
|
-
collapseAll() {
|
|
856
|
-
this.expansionModel.clear();
|
|
857
|
-
}
|
|
858
|
-
/** Expands a subtree rooted at given data node recursively. */
|
|
859
|
-
expandDescendants(dataNode) {
|
|
860
|
-
const toBeProcessed = [dataNode];
|
|
861
|
-
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
862
|
-
this.expansionModel.select(...toBeProcessed);
|
|
863
|
-
}
|
|
864
|
-
/** Collapses a subtree rooted at given data node recursively. */
|
|
865
|
-
collapseDescendants(dataNode) {
|
|
866
|
-
const toBeProcessed = [dataNode];
|
|
867
|
-
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
868
|
-
this.expansionModel.deselect(...toBeProcessed);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
class FilterByViewValue {
|
|
873
|
-
constructor(control) {
|
|
874
|
-
this.control = control;
|
|
875
|
-
}
|
|
876
|
-
handle(value) {
|
|
877
|
-
const viewValue = value || null;
|
|
878
|
-
this.result = this.control.dataNodes
|
|
879
|
-
.filter((node) => this.control.compareViewValues(this.control.getViewValue(node), viewValue));
|
|
880
|
-
return this.result;
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
class FilterParentsForNodes {
|
|
884
|
-
constructor(control) {
|
|
885
|
-
this.control = control;
|
|
886
|
-
}
|
|
887
|
-
handle(_, prevFilter) {
|
|
888
|
-
const result = new Set();
|
|
889
|
-
this.control.dataNodes
|
|
890
|
-
.filter((node) => prevFilter?.result.includes(node))
|
|
891
|
-
.forEach((node) => {
|
|
892
|
-
this.control.getParents(node, [])
|
|
893
|
-
.forEach((parent) => result.add(parent));
|
|
894
|
-
result.add(node);
|
|
895
|
-
});
|
|
896
|
-
this.result = Array.from(result);
|
|
897
|
-
return this.result;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
class FilterByValues {
|
|
901
|
-
constructor(control) {
|
|
902
|
-
this.control = control;
|
|
903
|
-
this.values = [];
|
|
904
|
-
this.setValues = (values) => {
|
|
905
|
-
this.values = values;
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
handle(_, prevFilter) {
|
|
909
|
-
const found = this.control.dataNodes
|
|
910
|
-
.filter((node) => this.values.includes(this.control.getValue(node)));
|
|
911
|
-
this.result = Array.from(new Set([...(prevFilter?.result || []), ...found]));
|
|
912
|
-
return this.result;
|
|
913
|
-
}
|
|
914
|
-
getValues() {
|
|
915
|
-
return this.values;
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
function defaultCompareValues(firstValue, secondValue) {
|
|
920
|
-
return firstValue === secondValue;
|
|
921
|
-
}
|
|
922
|
-
function defaultCompareViewValues(firstViewValue, secondViewValue) {
|
|
923
|
-
return RegExp(escapeRegExp(secondViewValue), 'gi').test(firstViewValue);
|
|
924
|
-
}
|
|
925
|
-
/** Flat tree control. Able to expand/collapse a subtree recursively for flattened tree. */
|
|
926
|
-
class FlatTreeControl extends BaseTreeControl {
|
|
927
|
-
/** Construct with flat tree data node functions getLevel, isExpandable, getValue and getViewValue. */
|
|
928
|
-
constructor(getLevel, isExpandable,
|
|
929
|
-
/** getValue will be used to determine if the tree contains value or not. Used in method hasValue */
|
|
930
|
-
getValue,
|
|
931
|
-
/** getViewValue will be used for filter nodes. Returned value will be first argument in filterNodesFunction */
|
|
932
|
-
getViewValue,
|
|
933
|
-
/** compareValues will be used to comparing values. */
|
|
934
|
-
compareValues = defaultCompareValues,
|
|
935
|
-
/** compareValues will be used to comparing values. */
|
|
936
|
-
compareViewValues = defaultCompareViewValues,
|
|
937
|
-
/** isDisabled will be used to determine if the node is disabled. */
|
|
938
|
-
isDisabled = () => false) {
|
|
939
|
-
super();
|
|
940
|
-
this.getLevel = getLevel;
|
|
941
|
-
this.isExpandable = isExpandable;
|
|
942
|
-
this.getValue = getValue;
|
|
943
|
-
this.getViewValue = getViewValue;
|
|
944
|
-
this.compareValues = compareValues;
|
|
945
|
-
this.compareViewValues = compareViewValues;
|
|
946
|
-
this.isDisabled = isDisabled;
|
|
947
|
-
this.setFilters(new FilterByViewValue(this), new FilterParentsForNodes(this));
|
|
948
|
-
}
|
|
949
|
-
getFilters() {
|
|
950
|
-
return this.filters;
|
|
951
|
-
}
|
|
952
|
-
setFilters(...filters) {
|
|
953
|
-
this.filters = filters;
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Gets a list of the data node's subtree of descendent data nodes.
|
|
957
|
-
*
|
|
958
|
-
* To make this working, the `dataNodes` of the TreeControl must be flattened tree nodes
|
|
959
|
-
* with correct levels.
|
|
960
|
-
*/
|
|
961
|
-
getDescendants(dataNode) {
|
|
962
|
-
const startIndex = this.dataNodes.indexOf(dataNode);
|
|
963
|
-
const results = [];
|
|
964
|
-
// Goes through flattened tree nodes in the `dataNodes` array, and get all descendants.
|
|
965
|
-
// The level of descendants of a tree node must be greater than the level of the given
|
|
966
|
-
// tree node.
|
|
967
|
-
// If we reach a node whose level is equal to the level of the tree node, we hit a sibling.
|
|
968
|
-
// If we reach a node whose level is greater than the level of the tree node, we hit a
|
|
969
|
-
// sibling of an ancestor.
|
|
970
|
-
for (let i = startIndex + 1; i < this.dataNodes.length && this.getLevel(dataNode) < this.getLevel(this.dataNodes[i]); i++) {
|
|
971
|
-
results.push(this.dataNodes[i]);
|
|
972
|
-
}
|
|
973
|
-
return results;
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Expands all data nodes in the tree.
|
|
977
|
-
*
|
|
978
|
-
* To make this working, the `dataNodes` variable of the TreeControl must be set to all flattened
|
|
979
|
-
* data nodes of the tree.
|
|
980
|
-
*/
|
|
981
|
-
expandAll() {
|
|
982
|
-
this.expansionModel.select(...this.dataNodes);
|
|
983
|
-
}
|
|
984
|
-
getParents(node, result) {
|
|
985
|
-
if (node.parent) {
|
|
986
|
-
result.unshift(node.parent);
|
|
987
|
-
return this.getParents(node.parent, result);
|
|
988
|
-
}
|
|
989
|
-
else {
|
|
990
|
-
return result;
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
hasValue(value) {
|
|
994
|
-
return this.dataNodes.find((node) => this.compareValues(this.getValue(node), value));
|
|
995
|
-
}
|
|
996
|
-
filterNodes(value = null) {
|
|
997
|
-
this.saveExpansionState();
|
|
998
|
-
let result = [];
|
|
999
|
-
this.filters
|
|
1000
|
-
.forEach((filter, index, filters) => {
|
|
1001
|
-
const prevFilter = filters[index - 1] || null;
|
|
1002
|
-
result = filter.handle(value, prevFilter);
|
|
1003
|
-
});
|
|
1004
|
-
this.filterModel.clear();
|
|
1005
|
-
this.filterModel.select(...result);
|
|
1006
|
-
// set current expansion state according to filtered tree
|
|
1007
|
-
this.expansionModel.setSelection(...result.filter((node) => this.isExpandable(node)));
|
|
1008
|
-
this.updateFilterValue(value || result);
|
|
1009
|
-
Promise.resolve()
|
|
1010
|
-
.then(() => this.restoreExpansionState());
|
|
1011
|
-
}
|
|
1012
|
-
updateFilterValue(value) {
|
|
1013
|
-
Promise.resolve()
|
|
1014
|
-
.then(() => this.filterValue.next(value));
|
|
1015
|
-
}
|
|
1016
|
-
saveExpansionState() {
|
|
1017
|
-
if (!this.filterValue.value?.length) {
|
|
1018
|
-
this.expandedItemsBeforeFiltration = this.expansionModel.selected;
|
|
1199
|
+
const parts = indent.split(cssUnitPattern);
|
|
1200
|
+
value = parts[0];
|
|
1201
|
+
units = parts[1] || units;
|
|
1019
1202
|
}
|
|
1203
|
+
this.indentUnits = units;
|
|
1204
|
+
this._indent = coerceNumberProperty(value);
|
|
1205
|
+
this.setPadding();
|
|
1020
1206
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1207
|
+
setPadding() {
|
|
1208
|
+
const padding = this.paddingIndent();
|
|
1209
|
+
const paddingProp = this.dir?.value === 'rtl' ? 'paddingRight' : 'paddingLeft';
|
|
1210
|
+
this.renderer.setStyle(this.element.nativeElement, paddingProp, padding);
|
|
1025
1211
|
}
|
|
1212
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTreeNodePadding, deps: [{ token: KbqTreeNode }, { token: KbqTreeBase }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: KbqTreeOption }, { token: i3.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1213
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.0", type: KbqTreeNodePadding, selector: "[kbqTreeNodePadding]", inputs: { indent: ["kbqTreeNodePaddingIndent", "indent"] }, exportAs: ["kbqTreeNodePadding"], ngImport: i0 }); }
|
|
1214
|
+
}
|
|
1215
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTreeNodePadding, decorators: [{
|
|
1216
|
+
type: Directive,
|
|
1217
|
+
args: [{
|
|
1218
|
+
selector: '[kbqTreeNodePadding]',
|
|
1219
|
+
exportAs: 'kbqTreeNodePadding'
|
|
1220
|
+
}]
|
|
1221
|
+
}], ctorParameters: () => [{ type: KbqTreeNode }, { type: KbqTreeBase }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: KbqTreeOption }, { type: i3.Directionality, decorators: [{
|
|
1222
|
+
type: Optional
|
|
1223
|
+
}] }], propDecorators: { indent: [{
|
|
1224
|
+
type: Input,
|
|
1225
|
+
args: ['kbqTreeNodePaddingIndent']
|
|
1226
|
+
}] } });
|
|
1227
|
+
|
|
1228
|
+
class KbqTree extends KbqTreeBase {
|
|
1229
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTree, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
1230
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.0", type: KbqTree, selector: "kbq-tree", host: { classAttribute: "kbq-tree" }, exportAs: ["kbqTree"], usesInheritance: true, ngImport: i0, template: `
|
|
1231
|
+
<ng-container kbqTreeNodeOutlet></ng-container>
|
|
1232
|
+
`, isInline: true, styles: [".kbq-tree{display:block}\n"], dependencies: [{ kind: "directive", type: KbqTreeNodeOutlet, selector: "[kbqTreeNodeOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
1026
1233
|
}
|
|
1234
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: KbqTree, decorators: [{
|
|
1235
|
+
type: Component,
|
|
1236
|
+
args: [{ selector: 'kbq-tree', exportAs: 'kbqTree', template: `
|
|
1237
|
+
<ng-container kbqTreeNodeOutlet></ng-container>
|
|
1238
|
+
`, host: {
|
|
1239
|
+
class: 'kbq-tree'
|
|
1240
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".kbq-tree{display:block}\n"] }]
|
|
1241
|
+
}] });
|
|
1027
1242
|
|
|
1028
1243
|
/* tslint:disable:no-empty */
|
|
1029
1244
|
const KBQ_SELECTION_TREE_VALUE_ACCESSOR = {
|
|
@@ -1149,14 +1364,11 @@ class KbqTreeSelection extends KbqTreeBase {
|
|
|
1149
1364
|
this.selectionModel = new SelectionModel(this.multiple);
|
|
1150
1365
|
}
|
|
1151
1366
|
ngAfterContentInit() {
|
|
1152
|
-
this.unorderedOptions.changes
|
|
1153
|
-
.subscribe(this.updateRenderedOptions);
|
|
1367
|
+
this.unorderedOptions.changes.subscribe(this.updateRenderedOptions);
|
|
1154
1368
|
this.keyManager = new FocusKeyManager(this.renderedOptions)
|
|
1155
1369
|
.withVerticalOrientation(true)
|
|
1156
1370
|
.withHorizontalOrientation(null);
|
|
1157
|
-
this.keyManager.change
|
|
1158
|
-
.pipe(takeUntil(this.destroy))
|
|
1159
|
-
.subscribe(() => {
|
|
1371
|
+
this.keyManager.change.pipe(takeUntil(this.destroy)).subscribe(() => {
|
|
1160
1372
|
if (this.keyManager.activeItem) {
|
|
1161
1373
|
this.emitNavigationEvent(this.keyManager.activeItem);
|
|
1162
1374
|
// todo need check this logic
|
|
@@ -1165,18 +1377,12 @@ class KbqTreeSelection extends KbqTreeBase {
|
|
|
1165
1377
|
}
|
|
1166
1378
|
}
|
|
1167
1379
|
});
|
|
1168
|
-
this.keyManager.tabOut
|
|
1169
|
-
|
|
1170
|
-
.subscribe(() => this.allowFocusEscape());
|
|
1171
|
-
this.selectionModel.changed
|
|
1172
|
-
.pipe(takeUntil(this.destroy))
|
|
1173
|
-
.subscribe(() => {
|
|
1380
|
+
this.keyManager.tabOut.pipe(takeUntil(this.destroy)).subscribe(() => this.allowFocusEscape());
|
|
1381
|
+
this.selectionModel.changed.pipe(takeUntil(this.destroy)).subscribe(() => {
|
|
1174
1382
|
this.onChange(this.getSelectedValues());
|
|
1175
1383
|
this.renderedOptions.notifyOnChanges();
|
|
1176
1384
|
});
|
|
1177
|
-
this.renderedOptions.changes
|
|
1178
|
-
.pipe(takeUntil(this.destroy), delay(0, this.scheduler))
|
|
1179
|
-
.subscribe((options) => {
|
|
1385
|
+
this.renderedOptions.changes.pipe(takeUntil(this.destroy), delay(0, this.scheduler)).subscribe((options) => {
|
|
1180
1386
|
this.resetOptions();
|
|
1181
1387
|
// Check to see if we need to update our tab index
|
|
1182
1388
|
this.updateTabIndex();
|
|
@@ -1205,6 +1411,9 @@ class KbqTreeSelection extends KbqTreeBase {
|
|
|
1205
1411
|
this.keyManager.setFirstItemActive();
|
|
1206
1412
|
this.keyManager.setFocusOrigin('program');
|
|
1207
1413
|
}
|
|
1414
|
+
highlightSelectedOption() {
|
|
1415
|
+
this.renderedOptions.find((item) => item.data === this.selectionModel.selected[0])?.focus();
|
|
1416
|
+
}
|
|
1208
1417
|
blur() {
|
|
1209
1418
|
if (!this.hasFocusedOption() && this.resetFocusedItemOnBlur) {
|
|
1210
1419
|
this.keyManager.setActiveItem(-1);
|
|
@@ -1314,7 +1523,7 @@ class KbqTreeSelection extends KbqTreeBase {
|
|
|
1314
1523
|
selectActiveOptions() {
|
|
1315
1524
|
const options = this.renderedOptions.toArray();
|
|
1316
1525
|
let fromIndex = this.keyManager.previousActiveItemIndex;
|
|
1317
|
-
let toIndex = this.keyManager.previousActiveItemIndex = this.keyManager.activeItemIndex;
|
|
1526
|
+
let toIndex = (this.keyManager.previousActiveItemIndex = this.keyManager.activeItemIndex);
|
|
1318
1527
|
const selectedOptionState = options[fromIndex]?.selected;
|
|
1319
1528
|
if (toIndex === fromIndex || fromIndex === -1) {
|
|
1320
1529
|
options[toIndex].toggle();
|
|
@@ -1355,11 +1564,9 @@ class KbqTreeSelection extends KbqTreeBase {
|
|
|
1355
1564
|
this.selectionChange.emit(new KbqTreeNavigationChange(this, option));
|
|
1356
1565
|
}
|
|
1357
1566
|
selectAllOptions() {
|
|
1358
|
-
const optionsToSelect = this.renderedOptions
|
|
1359
|
-
.filter((option) => !option.disabled);
|
|
1567
|
+
const optionsToSelect = this.renderedOptions.filter((option) => !option.disabled);
|
|
1360
1568
|
const hasDeselectedOptions = optionsToSelect.some((option) => !option.selected);
|
|
1361
|
-
optionsToSelect
|
|
1362
|
-
.forEach((option) => option.setSelected(hasDeselectedOptions));
|
|
1569
|
+
optionsToSelect.forEach((option) => option.setSelected(hasDeselectedOptions));
|
|
1363
1570
|
this.onSelectAll.emit(new KbqTreeSelectAllEvent(this, optionsToSelect));
|
|
1364
1571
|
}
|
|
1365
1572
|
copyActiveOption() {
|
|
@@ -1468,18 +1675,14 @@ class KbqTreeSelection extends KbqTreeBase {
|
|
|
1468
1675
|
}
|
|
1469
1676
|
}
|
|
1470
1677
|
listenToOptionsFocus() {
|
|
1471
|
-
this.optionFocusSubscription = this.optionFocusChanges
|
|
1472
|
-
.subscribe((event) => {
|
|
1678
|
+
this.optionFocusSubscription = this.optionFocusChanges.subscribe((event) => {
|
|
1473
1679
|
const index = this.renderedOptions.toArray().indexOf(event.option);
|
|
1474
|
-
this.renderedOptions
|
|
1475
|
-
.filter((option) => option.hasFocus)
|
|
1476
|
-
.forEach((option) => option.hasFocus = false);
|
|
1680
|
+
this.renderedOptions.filter((option) => option.hasFocus).forEach((option) => (option.hasFocus = false));
|
|
1477
1681
|
if (this.isValidIndex(index)) {
|
|
1478
1682
|
this.keyManager.updateActiveItem(index);
|
|
1479
1683
|
}
|
|
1480
1684
|
});
|
|
1481
|
-
this.optionBlurSubscription = this.optionBlurChanges
|
|
1482
|
-
.subscribe(() => this.blur());
|
|
1685
|
+
this.optionBlurSubscription = this.optionBlurChanges.subscribe(() => this.blur());
|
|
1483
1686
|
}
|
|
1484
1687
|
/**
|
|
1485
1688
|
* Utility to ensure all indexes are valid.
|
|
@@ -1497,9 +1700,7 @@ class KbqTreeSelection extends KbqTreeBase {
|
|
|
1497
1700
|
this.renderedOptions.forEach((option) => option.markForCheck());
|
|
1498
1701
|
}
|
|
1499
1702
|
updateOptionsFocus() {
|
|
1500
|
-
this.renderedOptions
|
|
1501
|
-
.filter((option) => option.hasFocus)
|
|
1502
|
-
.forEach((option) => option.hasFocus = false);
|
|
1703
|
+
this.renderedOptions.filter((option) => option.hasFocus).forEach((option) => (option.hasFocus = false));
|
|
1503
1704
|
}
|
|
1504
1705
|
canDeselectLast(option) {
|
|
1505
1706
|
return !(this.noUnselectLast && this.selectionModel.selected.length === 1 && option.selected);
|
|
@@ -1613,231 +1814,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImpor
|
|
|
1613
1814
|
}]
|
|
1614
1815
|
}] });
|
|
1615
1816
|
|
|
1616
|
-
/** Nested tree control. Able to expand/collapse a subtree recursively for NestedNode type. */
|
|
1617
|
-
class NestedTreeControl extends BaseTreeControl {
|
|
1618
|
-
/** Construct with nested tree function getChildren. */
|
|
1619
|
-
constructor(getChildren) {
|
|
1620
|
-
super();
|
|
1621
|
-
this.getChildren = getChildren;
|
|
1622
|
-
}
|
|
1623
|
-
/**
|
|
1624
|
-
* Expands all dataNodes in the tree.
|
|
1625
|
-
*
|
|
1626
|
-
* To make this working, the `dataNodes` variable of the TreeControl must be set to all root level
|
|
1627
|
-
* data nodes of the tree.
|
|
1628
|
-
*/
|
|
1629
|
-
expandAll() {
|
|
1630
|
-
this.expansionModel.clear();
|
|
1631
|
-
const allNodes = this.dataNodes.reduce((accumulator, dataNode) => [...accumulator, ...this.getDescendants(dataNode), dataNode], []);
|
|
1632
|
-
this.expansionModel.select(...allNodes);
|
|
1633
|
-
}
|
|
1634
|
-
/** Gets a list of descendant dataNodes of a subtree rooted at given data node recursively. */
|
|
1635
|
-
getDescendants(dataNode) {
|
|
1636
|
-
const descendants = [];
|
|
1637
|
-
this._getDescendants(descendants, dataNode);
|
|
1638
|
-
return descendants.splice(1);
|
|
1639
|
-
}
|
|
1640
|
-
/** A helper function to get descendants recursively. */
|
|
1641
|
-
// todo нужно придумать другое название и понять в чем отличие между getDescendants и _getDescendants
|
|
1642
|
-
/* tslint:disable-next-line:naming-convention */
|
|
1643
|
-
_getDescendants(descendants, dataNode) {
|
|
1644
|
-
descendants.push(dataNode);
|
|
1645
|
-
this.getChildren(dataNode)
|
|
1646
|
-
.pipe(take(1))
|
|
1647
|
-
.subscribe((children) => {
|
|
1648
|
-
if (children && children.length > 0) {
|
|
1649
|
-
children.forEach((child) => this._getDescendants(descendants, child));
|
|
1650
|
-
}
|
|
1651
|
-
});
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
/**
|
|
1656
|
-
* Tree flattener to convert a normal type of node to node with children & level information.
|
|
1657
|
-
* Transform nested nodes of type `T` to flattened nodes of type `F`.
|
|
1658
|
-
*
|
|
1659
|
-
* For example, the input data of type `T` is nested, and contains its children data:
|
|
1660
|
-
* SomeNode: {
|
|
1661
|
-
* key: 'Fruits',
|
|
1662
|
-
* children: [
|
|
1663
|
-
* NodeOne: {
|
|
1664
|
-
* key: 'Apple',
|
|
1665
|
-
* },
|
|
1666
|
-
* NodeTwo: {
|
|
1667
|
-
* key: 'Pear',
|
|
1668
|
-
* }
|
|
1669
|
-
* ]
|
|
1670
|
-
* }
|
|
1671
|
-
* After flattener flatten the tree, the structure will become
|
|
1672
|
-
* SomeNode: {
|
|
1673
|
-
* key: 'Fruits',
|
|
1674
|
-
* expandable: true,
|
|
1675
|
-
* level: 1
|
|
1676
|
-
* },
|
|
1677
|
-
* NodeOne: {
|
|
1678
|
-
* key: 'Apple',
|
|
1679
|
-
* expandable: false,
|
|
1680
|
-
* level: 2
|
|
1681
|
-
* },
|
|
1682
|
-
* NodeTwo: {
|
|
1683
|
-
* key: 'Pear',
|
|
1684
|
-
* expandable: false,
|
|
1685
|
-
* level: 2
|
|
1686
|
-
* }
|
|
1687
|
-
* and the output flattened type is `F` with additional information.
|
|
1688
|
-
*/
|
|
1689
|
-
class KbqTreeFlattener {
|
|
1690
|
-
constructor(transformFunction, getLevel, isExpandable, getChildren) {
|
|
1691
|
-
this.transformFunction = transformFunction;
|
|
1692
|
-
this.getLevel = getLevel;
|
|
1693
|
-
this.isExpandable = isExpandable;
|
|
1694
|
-
this.getChildren = getChildren;
|
|
1695
|
-
}
|
|
1696
|
-
flattenNode(node, level, resultNodes, parent) {
|
|
1697
|
-
const flatNode = this.transformFunction(node, level, parent);
|
|
1698
|
-
resultNodes.push(flatNode);
|
|
1699
|
-
if (this.isExpandable(flatNode)) {
|
|
1700
|
-
const childrenNodes = this.getChildren(node);
|
|
1701
|
-
if (childrenNodes) {
|
|
1702
|
-
if (Array.isArray(childrenNodes)) {
|
|
1703
|
-
this.flattenChildren(childrenNodes, level, resultNodes, flatNode);
|
|
1704
|
-
}
|
|
1705
|
-
else {
|
|
1706
|
-
childrenNodes
|
|
1707
|
-
.pipe(take(1))
|
|
1708
|
-
.subscribe((children) => {
|
|
1709
|
-
this.flattenChildren(children, level, resultNodes, flatNode);
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
return resultNodes;
|
|
1715
|
-
}
|
|
1716
|
-
flattenChildren(children, level, resultNodes, parent) {
|
|
1717
|
-
children.forEach((child) => {
|
|
1718
|
-
this.flattenNode(child, level + 1, resultNodes, parent);
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
/**
|
|
1722
|
-
* Flatten a list of node type T to flattened version of node F.
|
|
1723
|
-
* Please note that type T may be nested, and the length of `structuredData` may be different
|
|
1724
|
-
* from that of returned list `F[]`.
|
|
1725
|
-
*/
|
|
1726
|
-
flattenNodes(structuredData) {
|
|
1727
|
-
const resultNodes = [];
|
|
1728
|
-
structuredData.forEach((node) => this.flattenNode(node, 0, resultNodes, null));
|
|
1729
|
-
return resultNodes;
|
|
1730
|
-
}
|
|
1731
|
-
/**
|
|
1732
|
-
* Expand flattened node with current expansion status.
|
|
1733
|
-
* The returned list may have different length.
|
|
1734
|
-
*/
|
|
1735
|
-
expandFlattenedNodes(nodes, treeControl) {
|
|
1736
|
-
const results = [];
|
|
1737
|
-
const currentExpand = [];
|
|
1738
|
-
currentExpand[0] = true;
|
|
1739
|
-
nodes.forEach((node) => {
|
|
1740
|
-
let expand = true;
|
|
1741
|
-
for (let i = 0; i <= this.getLevel(node); i++) {
|
|
1742
|
-
expand = expand && currentExpand[i];
|
|
1743
|
-
}
|
|
1744
|
-
if (expand) {
|
|
1745
|
-
results.push(node);
|
|
1746
|
-
}
|
|
1747
|
-
if (this.isExpandable(node)) {
|
|
1748
|
-
currentExpand[this.getLevel(node) + 1] = treeControl.isExpanded(node);
|
|
1749
|
-
}
|
|
1750
|
-
});
|
|
1751
|
-
return results;
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
var KbqTreeDataSourceChangeTypes;
|
|
1755
|
-
(function (KbqTreeDataSourceChangeTypes) {
|
|
1756
|
-
KbqTreeDataSourceChangeTypes["Expansion"] = "expansion";
|
|
1757
|
-
KbqTreeDataSourceChangeTypes["Filter"] = "filter";
|
|
1758
|
-
})(KbqTreeDataSourceChangeTypes || (KbqTreeDataSourceChangeTypes = {}));
|
|
1759
|
-
/**
|
|
1760
|
-
* Data source for flat tree.
|
|
1761
|
-
* The data source need to handle expansion/collapsion of the tree node and change the data feed
|
|
1762
|
-
* to `KbqTree`.
|
|
1763
|
-
* The nested tree nodes of type `T` are flattened through `MсTreeFlattener`, and converted
|
|
1764
|
-
* to type `F` for `KbqTree` to consume.
|
|
1765
|
-
*/
|
|
1766
|
-
class KbqTreeFlatDataSource extends DataSource {
|
|
1767
|
-
get data() {
|
|
1768
|
-
return this._data.value;
|
|
1769
|
-
}
|
|
1770
|
-
set data(value) {
|
|
1771
|
-
this._data.next(value);
|
|
1772
|
-
this.flattenedData.next(this.treeFlattener.flattenNodes(this.data));
|
|
1773
|
-
this.treeControl.dataNodes = this.flattenedData.value;
|
|
1774
|
-
}
|
|
1775
|
-
constructor(treeControl, treeFlattener, initialData = []) {
|
|
1776
|
-
super();
|
|
1777
|
-
this.treeControl = treeControl;
|
|
1778
|
-
this.treeFlattener = treeFlattener;
|
|
1779
|
-
this.flattenedData = new BehaviorSubject([]);
|
|
1780
|
-
this.expandedData = new BehaviorSubject([]);
|
|
1781
|
-
this.filteredData = new BehaviorSubject([]);
|
|
1782
|
-
this._data = new BehaviorSubject(initialData);
|
|
1783
|
-
}
|
|
1784
|
-
connect(collectionViewer) {
|
|
1785
|
-
return merge(collectionViewer.viewChange, this.treeControl.expansionModel.changed
|
|
1786
|
-
.pipe(map((value) => ({ type: KbqTreeDataSourceChangeTypes.Expansion, value }))), this.treeControl.filterValue
|
|
1787
|
-
.pipe(map((value) => ({ type: KbqTreeDataSourceChangeTypes.Filter, value }))), this.flattenedData)
|
|
1788
|
-
.pipe(map((changeObj) => {
|
|
1789
|
-
if (changeObj.type === KbqTreeDataSourceChangeTypes.Filter) {
|
|
1790
|
-
if (changeObj.value && changeObj.value.length > 0) {
|
|
1791
|
-
return this.filterHandler();
|
|
1792
|
-
}
|
|
1793
|
-
else {
|
|
1794
|
-
return this.expansionHandler(changeObj.value);
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
return this.expansionHandler(changeObj.value);
|
|
1798
|
-
}));
|
|
1799
|
-
}
|
|
1800
|
-
filterHandler() {
|
|
1801
|
-
this.filteredData.next(this.treeControl.filterModel.selected);
|
|
1802
|
-
return this.filteredData.value;
|
|
1803
|
-
}
|
|
1804
|
-
expansionHandler(_change) {
|
|
1805
|
-
const expandedNodes = this.treeFlattener.expandFlattenedNodes(this.flattenedData.value, this.treeControl);
|
|
1806
|
-
this.expandedData.next(expandedNodes);
|
|
1807
|
-
return this.expandedData.value;
|
|
1808
|
-
}
|
|
1809
|
-
disconnect() {
|
|
1810
|
-
// no op
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
/**
|
|
1815
|
-
* Data source for nested tree.
|
|
1816
|
-
*
|
|
1817
|
-
* The data source for nested tree doesn't have to consider node flattener, or the way to expand
|
|
1818
|
-
* or collapse. The expansion/collapsion will be handled by TreeControl and each non-leaf node.
|
|
1819
|
-
*/
|
|
1820
|
-
class KbqTreeNestedDataSource extends DataSource {
|
|
1821
|
-
constructor() {
|
|
1822
|
-
super(...arguments);
|
|
1823
|
-
/* tslint:disable-next-line:naming-convention */
|
|
1824
|
-
this._data = new BehaviorSubject([]);
|
|
1825
|
-
}
|
|
1826
|
-
get data() {
|
|
1827
|
-
return this._data.value;
|
|
1828
|
-
}
|
|
1829
|
-
set data(value) {
|
|
1830
|
-
this._data.next(value);
|
|
1831
|
-
}
|
|
1832
|
-
connect(collectionViewer) {
|
|
1833
|
-
return merge(...[collectionViewer.viewChange, this._data])
|
|
1834
|
-
.pipe(map(() => this.data));
|
|
1835
|
-
}
|
|
1836
|
-
disconnect() {
|
|
1837
|
-
// no op
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
|
|
1841
1817
|
/**
|
|
1842
1818
|
* Generated bundle index. Do not edit.
|
|
1843
1819
|
*/
|